From a2bd8afd45cc9e6ffc3669706bf270a128caeb5d Mon Sep 17 00:00:00 2001 From: cor Date: Tue, 7 Jan 2025 22:18:29 +0000 Subject: [PATCH] fix(typescript-sdk): type errors for modules that will be upgraded later on --- typescript-sdk/src/aptos/client.ts | 8 +++---- typescript-sdk/src/cosmos/client.ts | 11 ++++----- typescript-sdk/src/evm/client.ts | 24 +++++++++---------- typescript-sdk/src/query/offchain/tenderly.ts | 2 +- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/typescript-sdk/src/aptos/client.ts b/typescript-sdk/src/aptos/client.ts index e3c3192495..42b744cddc 100644 --- a/typescript-sdk/src/aptos/client.ts +++ b/typescript-sdk/src/aptos/client.ts @@ -131,7 +131,7 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => { if (!chainDetails.value.port) return err(new Error("Port not found in hubble")) const pfmMemo = createPfmMemo({ port: chainDetails.value.port, - channel: chainDetails.value.destinationChannel, + channel: chainDetails.value.destinationChannel.toString(), /** * TODO: * check if normal Aptos hex address is valid here or do we need to do some transformation @@ -154,7 +154,7 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => { simulate, receiver, denomAddress, - sourceChannel, + sourceChannel: sourceChannel.toString(), destinationChainId, relayContractAddress, ...aptosClient @@ -199,7 +199,7 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => { if (!chainDetails.value.port) return err(new Error("Port not found in hubble")) const pfmMemo = createPfmMemo({ port: chainDetails.value.port, - channel: chainDetails.value.destinationChannel, + channel: chainDetails.value.destinationChannel.toString(), /** * TODO: * check if normal Aptos hex address is valid here or do we need to do some transformation @@ -221,7 +221,7 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => { amount, receiver, denomAddress, - sourceChannel, + sourceChannel: sourceChannel.toString(), destinationChainId, relayContractAddress, ...aptosClient diff --git a/typescript-sdk/src/cosmos/client.ts b/typescript-sdk/src/cosmos/client.ts index 37d0324ab3..9c42d364e7 100644 --- a/typescript-sdk/src/cosmos/client.ts +++ b/typescript-sdk/src/cosmos/client.ts @@ -75,7 +75,7 @@ export const createCosmosClient = (parameters: CosmosClientParameters) => if (!chainDetails.value.port) return err(new Error("Port not found in hubble")) const pfmMemo = createPfmMemo({ port: chainDetails.value.port, - channel: chainDetails.value.destinationChannel, + channel: chainDetails.value.destinationChannel.toString(), receiver: cosmosChainId.includes(destinationChainId) ? bech32AddressToHex({ address: receiver }) : receiver @@ -85,7 +85,6 @@ export const createCosmosClient = (parameters: CosmosClientParameters) => } const sourceChannel = chainDetails.value.sourceChannel - destinationChainId = chainDetails.value.destinationChainId relayContractAddress ??= chainDetails.value.relayContractAddress if (sourceChainId === "union-testnet-8") { @@ -125,7 +124,7 @@ export const createCosmosClient = (parameters: CosmosClientParameters) => gasPrice, messageTransfers: [ { - sourceChannel, + sourceChannel: sourceChannel.toString(), sourcePort: "transfer", sender: account_?.address, token: { denom: denomAddress, amount: amount.toString() }, @@ -178,7 +177,7 @@ export const createCosmosClient = (parameters: CosmosClientParameters) => if (!chainDetails.value.port) return err(new Error("Port not found in hubble")) const pfmMemo = createPfmMemo({ port: chainDetails.value.port, - channel: chainDetails.value.destinationChannel, + channel: chainDetails.value.destinationChannel.toString(), receiver: cosmosChainId.includes(destinationChainId) ? bech32AddressToHex({ address: receiver }) : receiver @@ -187,7 +186,7 @@ export const createCosmosClient = (parameters: CosmosClientParameters) => memo = pfmMemo.value } const sourceChannel = chainDetails.value.sourceChannel - destinationChainId = chainDetails.value.destinationChainId + // destinationChainId = chainDetails.value.destinationChainId relayContractAddress ??= chainDetails.value.relayContractAddress if (sourceChainId === "union-testnet-8") { @@ -228,7 +227,7 @@ export const createCosmosClient = (parameters: CosmosClientParameters) => rpcUrl, messageTransfers: [ { - sourceChannel, + sourceChannel: sourceChannel.toString(), sourcePort: "transfer", sender: account_?.address, token: { denom: denomAddress, amount: amount.toString() }, diff --git a/typescript-sdk/src/evm/client.ts b/typescript-sdk/src/evm/client.ts index 813acbe0b3..2c399921f2 100644 --- a/typescript-sdk/src/evm/client.ts +++ b/typescript-sdk/src/evm/client.ts @@ -11,7 +11,7 @@ import { http } from "viem" import { - evmSameChainTransfer, + // evmSameChainTransfer, transferAssetFromEvm, evmApproveTransferAsset, transferAssetFromEvmSimulate @@ -78,17 +78,17 @@ export const createEvmClient = (parameters: EvmClientParameters) => { account ||= client.account console.log(`EVM client created for chainId: ${parameters.chainId}`) // first check if chain ids are the same, if yes then we can skip the hubble check and do a simple erc20 transfer - if (parameters.chainId === destinationChainId) { - const transfer = await evmSameChainTransfer(client, { - amount, - account, - simulate, - receiver, - denomAddress - }) - if (transfer.isErr()) return err(transfer.error) - return ok(transfer.value) - } + // if (parameters.chainId === destinationChainId) { + // const transfer = await evmSameChainTransfer(client, { + // amount, + // account, + // simulate, + // receiver, + // denomAddress + // }) + // if (transfer.isErr()) return err(transfer.error) + // return ok(transfer.value) + // } const chainDetails = await getHubbleChainDetails({ sourceChainId: parameters.chainId, diff --git a/typescript-sdk/src/query/offchain/tenderly.ts b/typescript-sdk/src/query/offchain/tenderly.ts index 0c6117cae3..bb2f8e4a84 100644 --- a/typescript-sdk/src/query/offchain/tenderly.ts +++ b/typescript-sdk/src/query/offchain/tenderly.ts @@ -97,7 +97,7 @@ export async function simulateTransaction({ abi: ucs01RelayAbi, functionName: "send", args: [ - sourceChannel, + sourceChannel.toString(), receiver.startsWith("0x") ? getAddress(receiver) : bech32AddressToHex({ address: receiver }), [{ denom: denomAddress, amount }], memo ?? "",