Skip to content

Commit c3573a8

Browse files
committed
chore(ts-sdk-sui): fixed token order , still issues with display
Signed-off-by: kaancaglan <[email protected]>
1 parent a0aa234 commit c3573a8

File tree

2 files changed

+35
-27
lines changed

2 files changed

+35
-27
lines changed

ts-sdk-sui/examples/sui-create-client-generate-instruction.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,41 @@ const program = Effect.gen(function* () {
3838

3939
// TODO: Destination will be somewhere
4040
const destination = yield* ChainRegistry.byUniversalId(
41-
UniversalChainId.make("ethereum.11155111"),
41+
UniversalChainId.make("union.union-1"),
4242
)
4343
const wallet = yield* WalletClient
4444

4545
const sender = wallet.signer.toSuiAddress();
4646

47-
// TODO: Fix this tokenOrder and write something working
47+
48+
// deployed contract: union1l0rpy8yauy7nzv4vu6mgz6kjpqzvws85l8mgzm6eansasx90t57sc7k4ue
49+
50+
console.log("sender:", sender)
51+
4852
const tokenOrder = yield* TokenOrder.make({
4953
source,
5054
destination,
5155
sender: "0x06627714f3F17a701f7074a12C02847a5D2Ca487",
52-
receiver: "0x50A22f95bcB21E7bFb63c7A8544AC0683dCeA302",
53-
// LINK on Holesky
54-
baseToken: "0x685ce6742351ae9b618f383883d6d1e0c5a31b4b",
55-
baseAmount: 10n,
56-
// Holesky LINK on Sepolia
57-
quoteToken: "0x80fdbf104ec58a527ec40f7b03f88c404ef4ba63",
58-
quoteAmount: 10n,
59-
kind: "escrow",
60-
metadata: undefined,
56+
receiver: "0x756E696F6E317779637938673876357366663667736A6C3979686A73343371393878706C30357033676E3273",
57+
baseToken: "0x3078323A3A7375693A3A535549",
58+
baseAmount: 100000n,
59+
quoteToken: "0x756E696F6E316C307270793879617579376E7A76347675366D677A366B6A70717A76777338356C386D677A6D3665616E7361737839307435377363376B347565",
60+
quoteAmount: 10000n,
61+
kind: "solve",
62+
metadata:
63+
"0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040756e696f6e31736b673532343468706b61643630337a7a37376b64656b7a77366666677066726465336c646b387270647a30366e36326b34687163743077346a",
6164
version: 2,
6265
})
6366

64-
yield* Effect.log("Token Order V2", tokenOrder)
65-
66-
// TODO: Fix this request too
6767
const request = ZkgmClientRequest.make({
6868
source,
6969
destination,
7070
channelId: ChannelId.make(1),
71-
ucs03Address: "0x5fbe74a283f7954f10aa04c2edf55578811aeb03",
72-
kind: "simulateAndExecute",
71+
ucs03Address: "union1rfz3ytg6l60wxk5rxsk27jvn2907cyav04sz8kde3xhmmf9nplxqr8y05c",
7372
instruction: tokenOrder,
7473
})
7574

75+
7676
const zkgmClient = yield* ZkgmClient.ZkgmClient
7777

7878
const response: ZkgmClientResponse.ZkgmClientResponse = yield* zkgmClient.execute(request)
@@ -93,7 +93,7 @@ const program = Effect.gen(function* () {
9393
Effect.provide(
9494
WalletClient.Live({
9595
url: getFullnodeUrl("testnet"),
96-
signer: keypair, // ✅ Sui signer
96+
signer: keypair,
9797
}),
9898
),
9999

ts-sdk-sui/src/internal/zkgmClient.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,28 @@ export const fromWallet = (
113113

114114
console.log("[@unionlabs/sdk-sui/internal/zkgmClient]", { operand })
115115

116-
// ---- Sui PTB: begin_send -> send_with_coin -> end_send ----
117116

118117
const tx = new Transaction()
119118
const CLOCK_OBJECT_ID = "0x6" // Sui system clock
120119
const tHeight = 0n
121-
const packageId = "0x8675045186976da5b60baf20dc94413fb5415a7054052dc14d93c13d3dbdf830" //zkgm package id TODO: This should be fetched from somewhere
122120
const module = "zkgm" //zkgm module name
121+
122+
123+
// These will be fetched from hubble or from deployments.json
124+
const packageId = "0x8675045186976da5b60baf20dc94413fb5415a7054052dc14d93c13d3dbdf830" //zkgm package id
125+
// TODO: packageId can be changed when zkgm updated
126+
const relayStoreId = "0x393a99c6d55d9a79efa52dea6ea253fef25d2526787127290b985222cc20a924" // This won't be changed for a while
127+
const vaultId = "0x7c4ade19208295ed6bf3c4b58487aa4b917ba87d31460e9e7a917f7f12207ca3" // This won't be changed for a while
128+
const ibcStoreId = "0xac7814eebdfbf975235bbb796e07533718a9d83201346769e5f281dc90009175" // This won't be changed
129+
130+
131+
// This 2 will be get by user all the time
123132
const typeArg = "0x2::sui::SUI" // TODO: This should be dynamic based on the token sent
124-
const relayStoreId = "0x393a99c6d55d9a79efa52dea6ea253fef25d2526787127290b985222cc20a924" // TODO: This should be fetched from somewhere
125-
const vaultId = "0x7c4ade19208295ed6bf3c4b58487aa4b917ba87d31460e9e7a917f7f12207ca3" // TODO: This should be fetched from somewhere
126-
const ibcStoreId = "0xac7814eebdfbf975235bbb796e07533718a9d83201346769e5f281dc90009175" // TODO: This should be fetched from somewhere
127-
const coinObjectId = "0xc2c61b8de5aa6167dc744d6db61854fa29b53257d5e54a40c2f5b7dcc6f04d0b" // TODO: This should be given by user
128-
129-
// helpers
133+
const coinObjectId = "0xfdb7b5b54d61ed21373f2785c7583c1ff6fd85e9b04fa289da50bba563190b62" // TODO: This should be given by user
134+
// Note: There can be multiple coins, for simplicity we are using one coin here
135+
// User should be able to provide typeArgs and coinObjectIds array
136+
137+
130138
const hexToBytes = (hex: `0x${string}`): Uint8Array => {
131139
const s = hex.slice(2)
132140
const out = new Uint8Array(s.length / 2)
@@ -139,8 +147,8 @@ export const fromWallet = (
139147
target: `${packageId}::${module}::begin_send`,
140148
typeArguments: [],
141149
arguments: [
142-
tx.pure.u32(Number(request.channelId)), // channel id (u32)
143-
tx.pure.vector("u8", hexToBytes(salt as `0x${string}`)), // salt bytes
150+
tx.pure.u32(Number(request.channelId)),
151+
tx.pure.vector("u8", hexToBytes(salt as `0x${string}`)),
144152
],
145153
})
146154

0 commit comments

Comments
 (0)