Skip to content

Commit f16d671

Browse files
committed
chore: added new consts for sui metadata
Signed-off-by: Kaan Caglan <[email protected]>
1 parent c57ddb0 commit f16d671

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

app2/src/lib/transfer/shared/data/transfer-data.svelte.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import {
1919
EU_SOLVER_ON_UNION_METADATA,
2020
SUI_ADDR,
2121
SUI_NATIVE_COIN,
22+
SUI_U_COIN,
2223
SUI_SOLVER_ON_COSMOS_METADATA,
24+
SUI_SOLVER_ON_SUI_METADATA,
2325
U_BANK,
2426
U_ERC20,
2527
U_SOLVER_ON_ETH_METADATA,
@@ -114,6 +116,8 @@ export class TransferData {
114116
EU_ERC20.address.toLowerCase(), //
115117
toHex(EU_LST.address),
116118
toHex(SUI_NATIVE_COIN.address),
119+
toHex(SUI_U_COIN.address),
120+
toHex(SUI_ADDR.address),
117121
// TODO: add eU base
118122
// TODO: add eU quote
119123
],
@@ -132,6 +136,11 @@ export class TransferData {
132136
]).pipe(
133137
Option.flatMap(
134138
([baseToken, sourceChain, destinationChain, quoteTokens]) => {
139+
console.log("isSolve: ", this.isSolve);
140+
console.log("baseToken: ", this.baseToken);
141+
console.log("quoteTokens: ", this.quoteTokens);
142+
console.log("destinationChain: ", this.destinationChain);
143+
console.log("sourceChain: ", this.baseToken);
135144
if (this.isSolve) {
136145
return Match.value([
137146
Brand.unbranded(baseToken.denom).toLowerCase(),
@@ -150,6 +159,14 @@ export class TransferData {
150159
[toHex(SUI_NATIVE_COIN.address), "cosmos", Str.startsWith("union.")],
151160
() => Token.Cw20.make({ address: SUI_ADDR.address }),
152161
),
162+
Match.when(
163+
[toHex(SUI_U_COIN.address), "cosmos", Str.startsWith("union.")],
164+
() => U_BANK
165+
),
166+
Match.when(
167+
[toHex(SUI_ADDR.address), "sui", Str.startsWith("sui.")],
168+
() => SUI_NATIVE_COIN
169+
),
153170
Match.when(
154171
[U_ERC20.address.toLowerCase(), "evm", Match.any],
155172
() => U_ERC20,
@@ -281,11 +298,19 @@ export class TransferData {
281298
Match.when(
282299
["solve", toHex(SUI_NATIVE_COIN.address), "cosmos", Str.startsWith("union.")],
283300
() => Option.some(SUI_SOLVER_ON_COSMOS_METADATA),
301+
),
302+
Match.when(
303+
["solve", toHex(SUI_ADDR.address), "sui", Str.startsWith("sui.")],
304+
() => Option.some(SUI_SOLVER_ON_SUI_METADATA),
284305
),
285306
Match.when(
286307
["solve", U_ERC20.address.toLowerCase(), "cosmos", Str.startsWith("union.")],
287308
() => Option.some(U_SOLVER_ON_UNION_METADATA),
288309
),
310+
Match.when(
311+
["solve", toHex(SUI_U_COIN.address), "cosmos", Str.startsWith("union.")],
312+
() => Option.some(U_SOLVER_ON_UNION_METADATA),
313+
),
289314
Match.when(
290315
["solve", EU_ERC20.address.toLowerCase(), "evm", Str.startsWith("union.")],
291316
() => Option.some(EU_SOLVER_ON_ETH_METADATA),

app2/src/lib/transfer/shared/services/filling/create-context.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ export const createContext = Effect.fn((
141141
const batch = yield* produceBatch
142142

143143
// TODO: vaultId & ibcStoreId will be fetched from hubble probably
144-
// but objectId & typeArg should be provided by user
145-
// OR we need to find another way of doing this
146144
const SUI_HARDCODED_TRANSPORT = {
147145
sui: {
148146
vaultId: "0xbe65f53d47a4578c14b4d69d0594c1295d3761379319a185522cd6baad6473d4",

ts-sdk-sui/src/Sui.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export namespace Sui {
3131
export interface WalletClient {
3232
readonly client: SuiClient
3333
readonly signer: Ed25519Keypair
34+
readonly rpc: string
3435
}
3536

3637
/**
@@ -386,7 +387,7 @@ export const getCoinsWithBalance = (coinType: string, min: bigint) =>
386387
let total = 0n
387388

388389
while (true) {
389-
const page = await client.getCoins({ owner: resolvedOwner, coinType, cursor, limit: 50 })
390+
const page = await client.getCoins({ owner: resolvedOwner, coinType: coinType })
390391
for (const c of page.data) {
391392
acc.push({ coinObjectId: c.coinObjectId, balance: c.balance })
392393
total += BigInt(c.balance)
@@ -424,7 +425,7 @@ export const prepareCoinForAmount = (
424425
const [out] = tx.splitCoins(tx.gas, [tx.pure.u64(amount)])
425426
return out
426427
}
427-
const { coins, hasEnough } = yield* getCoinsWithBalance(coinType, amount, owner)
428+
const { coins, hasEnough } = yield* getCoinsWithBalance(coinType, amount)
428429
if (!hasEnough || coins.length === 0) {
429430
return yield* Effect.fail(
430431
new ReadCoinError({ cause: `Insufficient ${coinType} balance for split ${amount}` }),

ts-sdk/src/Constants.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ export const SUI_NATIVE_COIN = Token.SuiCoin.make({
269269
address: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
270270
})
271271

272+
/**
273+
* @category constants
274+
* @since 2.0.0
275+
*/
276+
export const SUI_U_COIN = Token.SuiCoin.make({
277+
address: "0xc0d9421ae241dc48a720102016190a4b7bf3e14b5995dbe6e83d11fb966e5a99::u::U",
278+
})
279+
272280
/**
273281
* @category constants
274282
* @since 2.0.0
@@ -312,6 +320,13 @@ export const EU_SOLVER_ON_ETH_METADATA =
312320
export const SUI_SOLVER_ON_COSMOS_METADATA =
313321
"0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040756e696f6e316675666174676b79643233716d716c7a74346176776a33366b6668766a757572323070716a66387865776e78326d6e6873736573366473706d660000000000000000000000000000000000000000000000000000000000000000" as const
314322

323+
/**
324+
* @category constants
325+
* @since 2.0.0
326+
*/
327+
export const SUI_SOLVER_ON_SUI_METADATA =
328+
"0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001775637330332d7a6b676d2d657363726f772d7661756c74000000000000000000" as const
329+
315330
/**
316331
* @category constants
317332
* @since 2.0.0

0 commit comments

Comments
 (0)