Skip to content

Commit

Permalink
chore(app): frontend works for movement<->union both side
Browse files Browse the repository at this point in the history
Signed-off-by: Kaan Caglan <[email protected]>
  • Loading branch information
Caglankaan committed Feb 28, 2025
1 parent ab14988 commit f26a57e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ const transfer = async () => {
if (stepBefore($transferState, "TRANSFERRING")) {
try {
let account = await wallet?.getAccount();
const client = createUnionClient({
chainId: sourceChain.chain_id as AptosChainId,
account: await wallet?.getAccount(),
transport: http(`${rpcUrl}`),
account: account,
transport: wallet
})
let realArgs = {
Expand All @@ -141,10 +142,7 @@ const transfer = async () => {
}
}
}
// /** --- APTOS END --- */
// /** --- COSMOS START --- */
if (sourceChain.rpc_type === "cosmos" && transferArgs !== "NO_QUOTE_AVAILABLE") {
else if (sourceChain.rpc_type === "cosmos" && transferArgs !== "NO_QUOTE_AVAILABLE") {
const { connectedWallet, connectionStatus } = get(cosmosStore)
if ($userAddrCosmos === null) return toast.error("No Cosmos user address found")
Expand Down
53 changes: 28 additions & 25 deletions typescript-sdk/playground/movement-to-union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ const cliArgs = parseArgs({
// npx tsx playground/movement-to-union.ts --private-key

const PRIVATE_KEY = cliArgs.values["private-key"]
const WRAPPED_MUNO_DENOM = "0x5b8dc541f42c8f31fceaf74f40e3e450a058406ca370779f96b25776c88f672e"
const WRAPPED_MUNO_DENOM = "0x188b41399546602e35658962477fdf72bd52443474a899d9d48636e8bc299c2c"
const AMOUNT = 1n
const SOURCE_CHAIN_ID = "250"
const DESTINATION_CHAIN_ID = "union-testnet-9"

const RECEIVER = bech32AddressToHex({ address: "bbn14vcpe0yt8xdzaapm8yy6tm26sf45rdgu4u2ka9" })
// const RECEIVER =
// "756E696F6E31786434787A356E346371657638643378657270666A656367706565706C34667834323263676A"
// const RECEIVER = bech32AddressToHex({ address: "bbn14vcpe0yt8xdzaapm8yy6tm26sf45rdgu4u2ka9" })
const RECEIVER =
"756E696F6E31786434787A356E346371657638643378657270666A656367706565706C34667834323263676A"
/*
--------------------------------------------------------
-------------- HOW TO CALCULATE RECEIVER :--------------
Expand All @@ -69,23 +69,25 @@ const RECEIVER = bech32AddressToHex({ address: "bbn14vcpe0yt8xdzaapm8yy6tm26sf45
*/

const channels = await getRecommendedChannels()
console.info("channels", channels)

let channel_info = getChannelInfo(SOURCE_CHAIN_ID, DESTINATION_CHAIN_ID, channels)
console.info("channel_info", channel_info)

if (channel_info === null) {
// Creating movement channel since its not found in hubble.
consola.info("no channel found")
// process.exit(1)
channel_info = {
source_chain_id: SOURCE_CHAIN_ID,
source_port_id: "7e385b7c720b279f6871bbd409dd2fb026d3193e2b40c705e8896d51141c1076",
source_channel_id: 1,
source_connection_id: 1,
destination_chain_id: DESTINATION_CHAIN_ID,
destination_port_id:
"756e696f6e3178326a7a65757037757766786a78787274666e61326b746375676c746e746775366b766330656561796b306438326c32343763717a3636396565",
destination_channel_id: 18,
destination_connection_id: 23
}
process.exit(1)
// channel_info = {
// source_chain_id: SOURCE_CHAIN_ID,
// source_port_id: "80a825c8878d4e22f459f76e581cb477d82f0222e136b06f01ad146e2ae9ed84",
// source_channel_id: 1,
// source_connection_id: 1,
// destination_chain_id: DESTINATION_CHAIN_ID,
// destination_port_id:
// "756e696f6e3178326a7a65757037757766786a78787274666e61326b746375676c746e746775366b766330656561796b306438326c32343763717a3636396565",
// destination_channel_id: 18,
// destination_connection_id: 23
// }
}

consola.info("channel", channel_info)
Expand All @@ -96,14 +98,15 @@ if (quoteToken.isErr()) {
consola.error(quoteToken.error)
process.exit(1)
}

// manual quote token:
quoteToken = {
type: "UNWRAPPED",
value: {
quote_token: `0x6d756e6f`
}
}
console.info("quote token", quoteToken)

// // manual quote token:
// quoteToken = {
// type: "UNWRAPPED",
// value: {
// quote_token: `0x6d756e6f`
// }
// }

if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
consola.error("No quote token available")
Expand Down
57 changes: 19 additions & 38 deletions typescript-sdk/playground/union-to-movement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,63 +48,44 @@ const cliArgs = parseArgs({
})

const PRIVATE_KEY = cliArgs.values["private-key"]
const MUNO_DENOM = "0x6d756e6f"
const AMOUNT = 15n
const MUNO_DENOM = "muno"
const MUNO_HEX = "0x6d756e6f"
const AMOUNT = 1n
const RECEIVER = "0x4d8a66ece11f6352224942bd1dabc456b4bb5316124f02b9a7b6292ad61f7777"
const SOURCE_CHAIN_ID = "union-testnet-9"
const DESTINATION_CHAIN_ID = "250"

const channels = await getRecommendedChannels()

let channel_info = getChannelInfo(SOURCE_CHAIN_ID, DESTINATION_CHAIN_ID, channels)
if (channel_info === null || true) {
// Creating movement channel since its not found in hubble.
channel_info = {
source_chain_id: SOURCE_CHAIN_ID,
source_port_id:
"756e696f6e3178326a7a65757037757766786a78787274666e61326b746375676c746e746775366b766330656561796b306438326c32343763717a3636396565",
source_channel_id: 27,
source_connection_id: 36,
destination_chain_id: DESTINATION_CHAIN_ID,
destination_port_id: "0x80a825c8878d4e22f459f76e581cb477d82f0222e136b06f01ad146e2ae9ed84",
destination_channel_id: 2,
destination_connection_id: 1
}
}

if (channel_info === null) {
consola.info("no channel found")
process.exit(1)
}
consola.info("channel", channel_info)

let quoteToken = await getQuoteToken(SOURCE_CHAIN_ID, MUNO_DENOM, channel_info)
// if (quoteToken.isErr()) {
// consola.info("could not get quote token")
// consola.error(quoteToken.error)
// process.exit(1)
// }
console.info("quote token", quoteToken)
process.exit(1)
// manual quote token:
quoteToken = {
type: "UNWRAPPED",
value: {
quote_token: `0x188b41399546602e35658962477fdf72bd52443474a899d9d48636e8bc299c2c`
}
let quoteToken = await getQuoteToken(SOURCE_CHAIN_ID, MUNO_HEX, channel_info

)
if (quoteToken.isErr()) {
consola.info("could not get quote token")
consola.error(quoteToken.error)
process.exit(1)
}
console.info("quote token", quoteToken)

// if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
// consola.error("No quote token available")
// process.exit(1)
// }
if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
consola.error("No quote token available")
process.exit(1)
}
consola.info("quote token", quoteToken.value)

if (!PRIVATE_KEY) {
consola.error("no private key provided")
process.exit(1)
}

if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
consola.error("No quote token available")
process.exit(1)
}

const unionClient = createUnionClient({
chainId: SOURCE_CHAIN_ID,
Expand Down
1 change: 0 additions & 1 deletion typescript-sdk/src/aptos/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => {
return createClient({ transport: fallback([]) })
.extend(() => ({
getAptosClient: async () => {
console.info("create aptos client params:", clientParameters)
// Use the transport type to determine which client to create.
if (typeof clientParameters.transport === "function") {
console.info("returning key-based client")
Expand Down

0 comments on commit f26a57e

Please sign in to comment.