address comments

This commit is contained in:
Bill He
2023-12-12 12:58:55 -05:00
parent 086bb4d10a
commit 234f3f2c93
3 changed files with 10 additions and 5 deletions
+5 -4
View File
@@ -31,6 +31,7 @@ import { log } from '@/lib/telemetry';
import { useAccounts } from './useAccounts';
import { useTokenConfigs } from './useTokenConfigs';
import { useDydxClient } from './useDydxClient';
import { hashFromTx } from '@/lib/hashfromTx';
type SubaccountContextType = ReturnType<typeof useSubaccountContext>;
const SubaccountContext = createContext<SubaccountContextType>({} as SubaccountContextType);
@@ -293,7 +294,7 @@ export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: Lo
);
const sendSquidWithdraw = useCallback(
async (amount: number, payload: string, isCCtp?: boolean) => {
async (amount: number, payload: string, isCctp?: boolean) => {
const cctpWithdraw = () => {
return new Promise<string>((resolve, reject) =>
@@ -307,15 +308,15 @@ export const useSubaccountContext = ({ localDydxWallet }: { localDydxWallet?: Lo
})
)
}
if (isCCtp) {
if (isCctp) {
return await cctpWithdraw();
}
if (!subaccountClient) {
return;
}
const txHash = await sendSquidWithdrawFromSubaccount({ subaccountClient, amount, payload });
return `0x${Buffer.from(txHash?.hash).toString('hex')}`;
const tx = await sendSquidWithdrawFromSubaccount({ subaccountClient, amount, payload });
return hashFromTx(tx?.hash);
},
[subaccountClient, sendSquidWithdrawFromSubaccount]
);
+2 -1
View File
@@ -42,6 +42,7 @@ import { openDialog } from '@/state/dialogs';
import { StatefulOrderError } from '../errors';
import { bytesToBigInt } from '../numbers';
import { log } from '../telemetry';
import { hashFromTx } from '../hashfromTx';
class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
private compositeClient: CompositeClient | undefined;
@@ -415,7 +416,7 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
);
return JSON.stringify({
txHash: `0x${Buffer.from(tx?.hash).toString('hex')}`
txHash: hashFromTx(tx?.hash)
});
} catch (error) {
log('DydxChainTransactions/withdrawToNobleIBC', error);
+3
View File
@@ -0,0 +1,3 @@
export const hashFromTx = (
txHash: string | Uint8Array
): string => `0x${Buffer.from(txHash).toString('hex')}`;