Skip to content

Commit bec93eb

Browse files
committed
feat: add getTariBalance & some cleanup
1 parent 8af3e72 commit bec93eb

7 files changed

Lines changed: 1284 additions & 1083 deletions

File tree

bridge-tapp-v2.2.zip

-14.3 MB
Binary file not shown.

clients/tari-l1-signer.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,23 @@ export class TariL1Signer {
4040
return sendSignerCall(req, id)
4141
}
4242

43+
/**
44+
* @description check if Tari Signer is connected with the Tari Universe
45+
* @returns true or false
46+
*/
4347
public async isConnected(): Promise<boolean> {
4448
return this.sendRequest({
4549
methodName: 'isConnected',
4650
args: [],
4751
})
4852
}
4953

50-
// TODO what do we need as response?
54+
/**
55+
* @description get Tari Account details
56+
* @returns account data
57+
*/
5158
public async getAccount(): Promise<AccountData> {
52-
// TODO implement in TU
59+
// TODO what do we need as response?
5360
const resp = await this.sendRequest({
5461
methodName: 'getAccount',
5562
args: [],
@@ -62,23 +69,34 @@ export class TariL1Signer {
6269
}
6370

6471
/**
65-
*
6672
* @description send XTM via one-sided transaction
6773
* @param amount XTM amount (uT or T)
6874
* @param address Tari Address one-sided
6975
* @param message (optional) payment-id
70-
* @returns
76+
* @returns true if tx success; otherwise false
7177
*/
7278
public async sendOneSided({
7379
amount,
7480
address,
7581
message,
76-
}: SendOneSidedRequest): Promise<void> {
82+
}: SendOneSidedRequest): Promise<boolean> {
7783
return this.sendRequest({
7884
methodName: 'sendOneSided',
7985
args: [{ amount, address, message }],
8086
})
8187
}
88+
89+
/**
90+
* @description get Tari Account balance
91+
* @returns XTM amount
92+
*/
93+
public async getTariBalance(): Promise<string> {
94+
//TODO implement on TU side
95+
return this.sendRequest({
96+
methodName: 'getTariBalance',
97+
args: [],
98+
})
99+
}
82100
}
83101

84102
function sendSignerCall<MethodName extends SignerMethodNames>(

hooks/use-bridge-to-ethereum.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
OpenAPI,
88
} from '@tari-project/wxtm-bridge-backend-api'
99

10-
// import { useTariWalletAddress } from './use-tari-wallet-address'
1110
import { parseWxtmTokenAmount } from '@/utils/parse-wxtm-token-amount'
1211
import useTariSigner from '@/store/signer'
1312
import useTariAccount from '@/store/account'
@@ -21,7 +20,6 @@ export const useBridgeToEthereum = () => {
2120
const confirmTokenSent = useMutation({
2221
mutationFn: WrapTokenService.updateToTokensSent,
2322
})
24-
// const { tariWalletAddress } = useTariWalletAddress()
2523
const { signer } = useTariSigner()
2624
const { tariAccount } = useTariAccount()
2725
const [isBridging, setIsBridging] = useState(false)
@@ -37,24 +35,27 @@ export const useBridgeToEthereum = () => {
3735
if (!tariAccount) return
3836
const tokenAmount = parseWxtmTokenAmount(amount)
3937

38+
console.log('[TAPPLET] start bridging to eth')
4039
const { paymentId } = await createTransaction.mutateAsync({
4140
to: ethAddress,
4241
from: tariAccount.address,
4342
tokenAmount,
4443
})
44+
console.log('[TAPPLET] response from mutate paymentid:', paymentId)
4545

4646
// TODO how can we get tari address to send XTM?
4747
const tariColdWalletAddress =
48-
'f22p3ubvTRM2SW6qrBg1gYb2gSbrWygByywTv14YU13umzphPWV2jDkZHZb1WN7nLKsYTesaZEnGt3vTpVoQBrhZxHj'
48+
'f2Kjz1SH4vRSXpNSb15SUNoECBNkxE57USorF7PpXT7hT4pJ1QViLMzinU5WiEoPn7m6hZ1BmS7AGPXAr4WpdNAU65m'
4949

50-
//
51-
await signer?.sendOneSided({
50+
const isSend = await signer?.sendOneSided({
5251
amount,
5352
address: tariColdWalletAddress,
5453
message: paymentId,
5554
})
5655

57-
await confirmTokenSent.mutateAsync(paymentId)
56+
console.log('[TAPPLET] send one sided done? ', isSend)
57+
const { success } = await confirmTokenSent.mutateAsync(paymentId)
58+
console.log('[TAPPLET] confirm token sent success: ', success)
5859

5960
setIsBridging(false)
6061
}

0 commit comments

Comments
 (0)