Skip to content

Commit

Permalink
fix(devnet): build error (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
npty authored Jan 27, 2025
1 parent de704c3 commit a5292eb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function useInterchainTransferMutation(

const mutation = useMutation<void, unknown, UseSendInterchainTokenInput>({
mutationFn: async ({ amount, tokenId, destinationAddress, decimals }) => {
if (!(decimals && address && config.gas)) {
if (!(decimals && address && config.gas && tokenId && destinationAddress)) {
return;
}

Expand All @@ -81,7 +81,6 @@ export function useInterchainTransferMutation(
let txHash: any;
if (config.sourceChainName === "sui") {
const coinObjectId = await getCoinType(config.tokenAddress);
console.log("coinObjectId", coinObjectId);
const sendTokenTxJSON = await getSendTokenTx({
sender: address,
tokenId: tokenId,
Expand Down
10 changes: 10 additions & 0 deletions apps/maestro/src/server/routers/axelarjsSDK/getChainInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export const getChainInfo = publicProcedure

return output;
} catch (error) {

// Remove this once we have sui supported in the urlMap from the axelarjs-sdk
if(input.axelarChainId === "sui"){
return {
id: "sui",
chainName: "sui",
blockConfirmations: 1,
estimatedWaitTimeInMinutes: 1,
}
}
// If we get a TRPC error, we throw it
if (error instanceof TRPCError) {
throw error;
Expand Down
2 changes: 1 addition & 1 deletion apps/maestro/src/server/routers/sui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export const suiRouter = router({
"0x",
CLOCK_PACKAGE_ID,
],
typeArguments: [input.tokenType],
typeArguments: [input.coinObjectId],
});

const tx2 = await buildTx(input.sender, txBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,54 @@ const STATUS_COLORS: Partial<
pending: "neutral",
};

export function useGMPTxProgress(txHash: `0x${string}`, chainId: number) {
export function useGMPTxProgress(txHash: string, chainId: number) {
const { combinedComputed } = useAllChainConfigsQuery();

const { data: txInfo } = useTransaction({
hash: txHash,
chainId,
});

const { data: chainInfo } = useChainInfoQuery({
axelarChainId: combinedComputed.indexedByChainId[chainId]?.id,
});

const isNonEvm = chainInfo?.id === "sui";

// Make sure this supports sui as well
const { data: txInfo } = useTransaction({
hash: txHash as `0x${string}`,
chainId,
query: {
enabled: !isNonEvm,
}
});

const { data: currentBlockNumber } = useBlockNumber({
chainId,
watch: true,
query: {
enabled: Boolean(chainInfo?.blockConfirmations && txInfo?.blockNumber),
enabled: !isNonEvm && Boolean(chainInfo?.blockConfirmations && txInfo?.blockNumber),
},
});

const elapsedBlocks = useMemo(
() =>
currentBlockNumber && txInfo?.blockNumber
() => {
return isNonEvm ? 1 : currentBlockNumber && txInfo?.blockNumber
? Number(currentBlockNumber - txInfo.blockNumber)
: 0,
[currentBlockNumber, txInfo?.blockNumber]
: 0
},
[currentBlockNumber, isNonEvm, txInfo?.blockNumber]
);

const expectedConfirmations = Number(chainInfo?.blockConfirmations ?? 1);
const expectedConfirmations = useMemo(() => {
return isNonEvm ? 1 : Number(chainInfo?.blockConfirmations ?? 1);
}, [isNonEvm, chainInfo?.blockConfirmations]);


const { progress, progressRatio } = useMemo(() => {
if (isNonEvm) {
return {
progress: '100%',
progressRatio: 100,
};
}

const ratio = elapsedBlocks / expectedConfirmations;
const clampedRatio = clamp(0, 1, ratio);

Expand All @@ -84,7 +101,7 @@ export function useGMPTxProgress(txHash: `0x${string}`, chainId: number) {
progress,
progressRatio: clampedRatio * 100,
};
}, [elapsedBlocks, expectedConfirmations]);
}, [elapsedBlocks, isNonEvm, expectedConfirmations]);

return {
progress,
Expand Down

0 comments on commit a5292eb

Please sign in to comment.