Skip to content

Commit 02564c8

Browse files
committed
fix: lots of small bugs, improvements & cleanups
1 parent 9479195 commit 02564c8

11 files changed

Lines changed: 828 additions & 1167 deletions

File tree

app/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function Home() {
5959
try {
6060
await setTariAccount()
6161
} catch (error) {
62-
console.error('Failed to set Tari Account:', error)
62+
console.error('[ TAPPLET-BRIDGE ] Failed to set Tari Account:', error)
6363
}
6464
}
6565
if (!signer) {
@@ -114,7 +114,7 @@ export default function Home() {
114114
setModalStep(2)
115115
})
116116
.catch((error) => {
117-
console.error('Bridge operation failed:', error)
117+
console.error('[ TAPPLET-BRIDGE ] Bridge operation failed:', error)
118118

119119
removePendingTransaction(txId)
120120
})
@@ -128,7 +128,6 @@ export default function Home() {
128128
])
129129

130130
const handleBridgeToTari = () => {
131-
console.log('[ TAPPLET-BRIDGE ] Bridging to Tari...')
132131
setModalStep(2)
133132
}
134133

app/providers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Providers = ({ children }: { children: ReactNode }) => {
1818
}, [config])
1919

2020
if (!initialState)
21-
console.error('[ Bridge ] provider initial state undefined')
21+
console.error('[ TAPPLET-BRIDGE ] provider initial state undefined')
2222

2323
return (
2424
<WagmiProvider config={config} initialState={initialState}>

bridge-v0.1.0.zip

14.3 MB
Binary file not shown.

clients/tari-l1-signer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
export interface SendOneSidedRequest {
1212
amount: string
1313
address: string
14-
paymentId: string
14+
paymentId?: string
1515
}
1616

1717
export interface BridgeTxDetails {

components/modals/wrap-modal/wrap-modal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const WrapModal: React.FC<WrapModalProps> = ({
2424
tariWalletAddress!,
2525
)
2626

27+
// TODO temp solution if backend is not ready to be fetched
2728
// in case tx is still pending
2829
const amountPending = pendingBridgeTxFromTU?.amount ?? amount
2930
const amountAfterFeePending =

hooks/use-bridge-to-ethereum.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,28 @@ export const useBridgeToEthereum = () => {
3535
}) => {
3636
setIsBridging(true)
3737
if (!tariAccount) return
38-
const tokenAmount = parseWxtmTokenAmount(amount)
38+
const parsedAmount = parseWxtmTokenAmount(amount)
3939

40-
console.debug('[ TAPPLET-BRIDGE ] start bridging to eth')
40+
console.debug(
41+
'[ TAPPLET-BRIDGE ] start bridging to eth with amount:',
42+
parsedAmount,
43+
)
4144
const { paymentId } = await createTransaction.mutateAsync({
4245
to: ethAddress,
4346
from: tariAccount.address,
44-
tokenAmount,
47+
tokenAmount: parsedAmount,
4548
})
4649
console.debug('[ TAPPLET-BRIDGE ] created tx with id: ', paymentId)
4750

51+
// the amount is parsed in TU in the `send_one_sided_to_stealth_address` function
52+
// so here it is necessary to pass the value entered by the user as is
4853
const isSend = await signer?.sendOneSided({
49-
amount: tokenAmount,
54+
amount: amount,
5055
address: config.TARI_BRIDGE_COLDWALLET_ADDRESS,
5156
paymentId: paymentId,
5257
})
5358
await signer?.addPendingTappletTx({
54-
amount: tokenAmount,
59+
amount: parsedAmount,
5560
amountToReceive: amountAfterFee,
5661
destinationAddress: ethAddress,
5762
paymentId: paymentId,

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

store/account.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const initialState: State = {
3434
export const useTariAccount = create<OotleWalletStoreState>()((set) => ({
3535
...initialState,
3636
setTariAccount: async () => {
37-
console.info('[ TAPPLET-BRIDGE ] set tari account')
3837
const signer = useTariSigner.getState().signer
3938
try {
4039
if (!signer) {
@@ -43,8 +42,8 @@ export const useTariAccount = create<OotleWalletStoreState>()((set) => ({
4342
}
4443
const account = await signer.getAccount()
4544
const balance = await signer.getTariBalance()
45+
// TODO temp solution if backend is not ready to be fetched
4646
const pendingTx = await signer.getPendingTappletTx()
47-
console.info('[ TAPPLET-BRIDGE ] call TU pending tx', pendingTx)
4847
set({
4948
tariAccount: {
5049
account_id: account.account_id,
@@ -55,7 +54,10 @@ export const useTariAccount = create<OotleWalletStoreState>()((set) => ({
5554
isProcessingTransaction: !!pendingTx,
5655
})
5756
} catch (error) {
58-
console.error('Could not set the Tari account: ', error)
57+
console.error(
58+
'[ TAPPLET-BRIDGE ] error setting the Tari account: ',
59+
error,
60+
)
5961
}
6062
},
6163

store/signer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ export interface SignerStore<TSigner extends TariL1Signer> {
1010
const useTariSigner = create<SignerStore<TariL1Signer>>()((set) => ({
1111
signer: null,
1212
setSigner(signer) {
13-
console.info(
14-
'[ TAPPLET-BRIDGE ] set tari signer with name:',
15-
signer.signerName,
16-
)
17-
1813
set({ signer })
1914
},
2015
}))

utils/parse-wxtm-token-amount.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { parseUnits } from 'ethers'
2+
13
export function parseWxtmTokenAmount(amount: string): string {
24
if (amount.split('.')[1] && amount.split('.')[1][0].length > 6) {
35
throw new Error('Invalid amount: more than 6 decimal places')
46
}
57

68
const sanitizedAmount = amount.replace(/,/g, '')
79

8-
// commented out because the amount is parsed when sending transactions from the TU
9-
// const parsed = parseUnits(sanitizedAmount, 6)
10-
return sanitizedAmount
10+
const parsed = parseUnits(sanitizedAmount, 6)
11+
return parsed.toString()
1112
}

0 commit comments

Comments
 (0)