Skip to content

Commit 394883d

Browse files
committed
chore(app): frontend works for movement<->union both side
Signed-off-by: Kaan Caglan <[email protected]>
1 parent b8f5382 commit 394883d

File tree

4 files changed

+51
-70
lines changed

4 files changed

+51
-70
lines changed

app/src/lib/components/TransferCube/components/Cube/faces/Transfer.svelte

+4-6
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ const transfer = async () => {
114114
115115
if (stepBefore($transferState, "TRANSFERRING")) {
116116
try {
117+
let account = await wallet?.getAccount();
117118
const client = createUnionClient({
118119
chainId: sourceChain.chain_id as AptosChainId,
119-
account: await wallet?.getAccount(),
120-
transport: http(`${rpcUrl}`),
120+
account: account,
121+
transport: wallet
121122
})
122123
123124
let realArgs = {
@@ -141,10 +142,7 @@ const transfer = async () => {
141142
}
142143
}
143144
}
144-
145-
// /** --- APTOS END --- */
146-
// /** --- COSMOS START --- */
147-
if (sourceChain.rpc_type === "cosmos" && transferArgs !== "NO_QUOTE_AVAILABLE") {
145+
else if (sourceChain.rpc_type === "cosmos" && transferArgs !== "NO_QUOTE_AVAILABLE") {
148146
const { connectedWallet, connectionStatus } = get(cosmosStore)
149147
if ($userAddrCosmos === null) return toast.error("No Cosmos user address found")
150148

typescript-sdk/playground/movement-to-union.ts

+28-25
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const AMOUNT = 1n
5656
const SOURCE_CHAIN_ID = "250"
5757
const DESTINATION_CHAIN_ID = "union-testnet-9"
5858

59-
const RECEIVER = bech32AddressToHex({ address: "bbn14vcpe0yt8xdzaapm8yy6tm26sf45rdgu4u2ka9" })
60-
// const RECEIVER =
61-
// "756E696F6E31786434787A356E346371657638643378657270666A656367706565706C34667834323263676A"
59+
// const RECEIVER = bech32AddressToHex({ address: "bbn14vcpe0yt8xdzaapm8yy6tm26sf45rdgu4u2ka9" })
60+
const RECEIVER =
61+
"756E696F6E31786434787A356E346371657638643378657270666A656367706565706C34667834323263676A"
6262
/*
6363
--------------------------------------------------------
6464
-------------- HOW TO CALCULATE RECEIVER :--------------
@@ -69,23 +69,25 @@ const RECEIVER = bech32AddressToHex({ address: "bbn14vcpe0yt8xdzaapm8yy6tm26sf45
6969
*/
7070

7171
const channels = await getRecommendedChannels()
72+
console.info("channels", channels)
7273

7374
let channel_info = getChannelInfo(SOURCE_CHAIN_ID, DESTINATION_CHAIN_ID, channels)
75+
console.info("channel_info", channel_info)
76+
7477
if (channel_info === null) {
75-
// Creating movement channel since its not found in hubble.
76-
// consola.info("no channel found")
77-
// process.exit(1)
78-
channel_info = {
79-
source_chain_id: SOURCE_CHAIN_ID,
80-
source_port_id: "80a825c8878d4e22f459f76e581cb477d82f0222e136b06f01ad146e2ae9ed84",
81-
source_channel_id: 2,
82-
source_connection_id: 1,
83-
destination_chain_id: DESTINATION_CHAIN_ID,
84-
destination_port_id:
85-
"756e696f6e3178326a7a65757037757766786a78787274666e61326b746375676c746e746775366b766330656561796b306438326c32343763717a3636396565",
86-
destination_channel_id: 27,
87-
destination_connection_id: 36
88-
}
78+
consola.info("no channel found")
79+
process.exit(1)
80+
// channel_info = {
81+
// source_chain_id: SOURCE_CHAIN_ID,
82+
// source_port_id: "80a825c8878d4e22f459f76e581cb477d82f0222e136b06f01ad146e2ae9ed84",
83+
// source_channel_id: 1,
84+
// source_connection_id: 1,
85+
// destination_chain_id: DESTINATION_CHAIN_ID,
86+
// destination_port_id:
87+
// "756e696f6e3178326a7a65757037757766786a78787274666e61326b746375676c746e746775366b766330656561796b306438326c32343763717a3636396565",
88+
// destination_channel_id: 18,
89+
// destination_connection_id: 23
90+
// }
8991
}
9092

9193
consola.info("channel", channel_info)
@@ -96,14 +98,15 @@ if (quoteToken.isErr()) {
9698
consola.error(quoteToken.error)
9799
process.exit(1)
98100
}
99-
100-
// manual quote token:
101-
quoteToken = {
102-
type: "UNWRAPPED",
103-
value: {
104-
quote_token: `0x6d756e6f`
105-
}
106-
}
101+
console.info("quote token", quoteToken)
102+
103+
// // manual quote token:
104+
// quoteToken = {
105+
// type: "UNWRAPPED",
106+
// value: {
107+
// quote_token: `0x6d756e6f`
108+
// }
109+
// }
107110

108111
if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
109112
consola.error("No quote token available")

typescript-sdk/playground/union-to-movement.ts

+19-38
Original file line numberDiff line numberDiff line change
@@ -48,63 +48,44 @@ const cliArgs = parseArgs({
4848
})
4949

5050
const PRIVATE_KEY = cliArgs.values["private-key"]
51-
const MUNO_DENOM = "0x6d756e6f"
52-
const AMOUNT = 15n
51+
const MUNO_DENOM = "muno"
52+
const MUNO_HEX = "0x6d756e6f"
53+
const AMOUNT = 1n
5354
const RECEIVER = "0x4d8a66ece11f6352224942bd1dabc456b4bb5316124f02b9a7b6292ad61f7777"
5455
const SOURCE_CHAIN_ID = "union-testnet-9"
5556
const DESTINATION_CHAIN_ID = "250"
5657

5758
const channels = await getRecommendedChannels()
5859

5960
let channel_info = getChannelInfo(SOURCE_CHAIN_ID, DESTINATION_CHAIN_ID, channels)
60-
if (channel_info === null || true) {
61-
// Creating movement channel since its not found in hubble.
62-
channel_info = {
63-
source_chain_id: SOURCE_CHAIN_ID,
64-
source_port_id:
65-
"756e696f6e3178326a7a65757037757766786a78787274666e61326b746375676c746e746775366b766330656561796b306438326c32343763717a3636396565",
66-
source_channel_id: 27,
67-
source_connection_id: 36,
68-
destination_chain_id: DESTINATION_CHAIN_ID,
69-
destination_port_id: "0x80a825c8878d4e22f459f76e581cb477d82f0222e136b06f01ad146e2ae9ed84",
70-
destination_channel_id: 2,
71-
destination_connection_id: 1
72-
}
73-
}
7461

62+
if (channel_info === null) {
63+
consola.info("no channel found")
64+
process.exit(1)
65+
}
7566
consola.info("channel", channel_info)
7667

77-
let quoteToken = await getQuoteToken(SOURCE_CHAIN_ID, MUNO_DENOM, channel_info)
78-
// if (quoteToken.isErr()) {
79-
// consola.info("could not get quote token")
80-
// consola.error(quoteToken.error)
81-
// process.exit(1)
82-
// }
83-
console.info("quote token", quoteToken)
84-
process.exit(1)
85-
// manual quote token:
86-
quoteToken = {
87-
type: "UNWRAPPED",
88-
value: {
89-
quote_token: `0x188b41399546602e35658962477fdf72bd52443474a899d9d48636e8bc299c2c`
90-
}
68+
let quoteToken = await getQuoteToken(SOURCE_CHAIN_ID, MUNO_HEX, channel_info
69+
70+
)
71+
if (quoteToken.isErr()) {
72+
consola.info("could not get quote token")
73+
consola.error(quoteToken.error)
74+
process.exit(1)
9175
}
76+
console.info("quote token", quoteToken)
9277

93-
// if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
94-
// consola.error("No quote token available")
95-
// process.exit(1)
96-
// }
78+
if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
79+
consola.error("No quote token available")
80+
process.exit(1)
81+
}
9782
consola.info("quote token", quoteToken.value)
9883

9984
if (!PRIVATE_KEY) {
10085
consola.error("no private key provided")
10186
process.exit(1)
10287
}
10388

104-
if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") {
105-
consola.error("No quote token available")
106-
process.exit(1)
107-
}
10889

10990
const unionClient = createUnionClient({
11091
chainId: SOURCE_CHAIN_ID,

typescript-sdk/src/aptos/client.ts

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export const createAptosClient = (clientParameters: AptosClientParameters) => {
125125
return createClient({ transport: fallback([]) })
126126
.extend(() => ({
127127
getAptosClient: async () => {
128-
console.info("create aptos client params:", clientParameters)
129128
// Use the transport type to determine which client to create.
130129
if (typeof clientParameters.transport === "function") {
131130
console.info("returning key-based client")

0 commit comments

Comments
 (0)