Skip to content

Commit

Permalink
fix(typescript-sdk): type errors for modules that will be upgraded la…
Browse files Browse the repository at this point in the history
…ter on
  • Loading branch information
cor committed Jan 7, 2025
1 parent 9285a08 commit a2bd8af
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
8 changes: 4 additions & 4 deletions typescript-sdk/src/aptos/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -154,7 +154,7 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => {
simulate,
receiver,
denomAddress,
sourceChannel,
sourceChannel: sourceChannel.toString(),
destinationChainId,
relayContractAddress,
...aptosClient
Expand Down Expand Up @@ -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
Expand All @@ -221,7 +221,7 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => {
amount,
receiver,
denomAddress,
sourceChannel,
sourceChannel: sourceChannel.toString(),
destinationChainId,
relayContractAddress,
...aptosClient
Expand Down
11 changes: 5 additions & 6 deletions typescript-sdk/src/cosmos/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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") {
Expand Down Expand Up @@ -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() },
Expand Down Expand Up @@ -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
Expand All @@ -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") {
Expand Down Expand Up @@ -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() },
Expand Down
24 changes: 12 additions & 12 deletions typescript-sdk/src/evm/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
http
} from "viem"
import {
evmSameChainTransfer,
// evmSameChainTransfer,
transferAssetFromEvm,
evmApproveTransferAsset,
transferAssetFromEvmSimulate
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion typescript-sdk/src/query/offchain/tenderly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "",
Expand Down

0 comments on commit a2bd8af

Please sign in to comment.