@chainflip/sdk 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ type SDKOptions = {
5
5
  network?: Exclude<ChainflipNetwork, 'mainnet'>;
6
6
  signer: Signer;
7
7
  };
8
- type TransactionHash = string;
8
+ type TransactionHash = `0x${string}`;
9
9
  declare class FundingSDK {
10
10
  private readonly options;
11
11
  constructor(options: SDKOptions);
package/dist/funding.d.ts CHANGED
@@ -5,7 +5,7 @@ type SDKOptions = {
5
5
  network?: Exclude<ChainflipNetwork, 'mainnet'>;
6
6
  signer: Signer;
7
7
  };
8
- type TransactionHash = string;
8
+ type TransactionHash = `0x${string}`;
9
9
  declare class FundingSDK {
10
10
  private readonly options;
11
11
  constructor(options: SDKOptions);
package/dist/funding.js CHANGED
@@ -996,7 +996,7 @@ var _FundingSDK = class _FundingSDK {
996
996
  */
997
997
  async approveStateChainGateway(amount, txOpts = {}) {
998
998
  const receipt = await approveStateChainGateway(amount, this.options, txOpts);
999
- return receipt && receipt.hash;
999
+ return receipt ? receipt.hash : null;
1000
1000
  }
1001
1001
  };
1002
1002
  __name(_FundingSDK, "FundingSDK");
package/dist/funding.mjs CHANGED
@@ -82,7 +82,7 @@ var _FundingSDK = class _FundingSDK {
82
82
  */
83
83
  async approveStateChainGateway(amount, txOpts = {}) {
84
84
  const receipt = await approveStateChainGateway(amount, this.options, txOpts);
85
- return receipt && receipt.hash;
85
+ return receipt ? receipt.hash : null;
86
86
  }
87
87
  };
88
88
  __name(_FundingSDK, "FundingSDK");
package/dist/swap.d.mts CHANGED
@@ -14,16 +14,16 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
14
14
  amount: bigint;
15
15
  srcChain: "Ethereum";
16
16
  srcAsset: "FLIP";
17
+ destAsset: "USDC" | "ETH";
17
18
  destChain: "Ethereum";
18
19
  destAddress: `0x${string}`;
19
- destAsset: "USDC" | "ETH";
20
20
  }, {
21
21
  amount: bigint;
22
22
  srcChain: "Ethereum";
23
23
  srcAsset: "FLIP";
24
+ destAsset: "USDC" | "ETH";
24
25
  destChain: "Ethereum";
25
26
  destAddress: `0x${string}`;
26
- destAsset: "USDC" | "ETH";
27
27
  }>, z.ZodObject<{
28
28
  amount: z.ZodBigInt;
29
29
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -35,174 +35,174 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
35
35
  amount: bigint;
36
36
  srcChain: "Ethereum";
37
37
  srcAsset: "USDC";
38
+ destAsset: "FLIP" | "ETH";
38
39
  destChain: "Ethereum";
39
40
  destAddress: `0x${string}`;
40
- destAsset: "FLIP" | "ETH";
41
41
  }, {
42
42
  amount: bigint;
43
43
  srcChain: "Ethereum";
44
44
  srcAsset: "USDC";
45
+ destAsset: "FLIP" | "ETH";
45
46
  destChain: "Ethereum";
46
47
  destAddress: `0x${string}`;
47
- destAsset: "FLIP" | "ETH";
48
48
  }>, z.ZodObject<{
49
49
  amount: z.ZodBigInt;
50
50
  srcChain: z.ZodLiteral<"Ethereum">;
51
+ destAsset: z.ZodLiteral<"DOT">;
51
52
  destChain: z.ZodLiteral<"Polkadot">;
52
53
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
53
- destAsset: z.ZodLiteral<"DOT">;
54
54
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
55
55
  }, "strip", z.ZodTypeAny, {
56
56
  amount: bigint;
57
57
  srcChain: "Ethereum";
58
58
  srcAsset: "FLIP" | "USDC";
59
+ destAsset: "DOT";
59
60
  destChain: "Polkadot";
60
61
  destAddress: string;
61
- destAsset: "DOT";
62
62
  }, {
63
63
  amount: bigint;
64
64
  srcChain: "Ethereum";
65
65
  srcAsset: "FLIP" | "USDC";
66
+ destAsset: "DOT";
66
67
  destChain: "Polkadot";
67
68
  destAddress: string;
68
- destAsset: "DOT";
69
69
  }>, z.ZodObject<{
70
70
  amount: z.ZodBigInt;
71
71
  srcChain: z.ZodLiteral<"Ethereum">;
72
+ destAsset: z.ZodLiteral<"BTC">;
72
73
  destChain: z.ZodLiteral<"Bitcoin">;
73
74
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
74
- destAsset: z.ZodLiteral<"BTC">;
75
75
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
76
76
  }, "strip", z.ZodTypeAny, {
77
77
  amount: bigint;
78
78
  srcChain: "Ethereum";
79
79
  srcAsset: "FLIP" | "USDC";
80
+ destAsset: "BTC";
80
81
  destChain: "Bitcoin";
81
82
  destAddress: string;
82
- destAsset: "BTC";
83
83
  }, {
84
84
  amount: bigint;
85
85
  srcChain: "Ethereum";
86
86
  srcAsset: "FLIP" | "USDC";
87
+ destAsset: "BTC";
87
88
  destChain: "Bitcoin";
88
89
  destAddress: string;
89
- destAsset: "BTC";
90
90
  }>]>;
91
91
  declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
92
92
  amount: z.ZodBigInt;
93
93
  srcChain: z.ZodLiteral<"Ethereum">;
94
94
  srcAsset: z.ZodLiteral<"ETH">;
95
+ destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
95
96
  destChain: z.ZodLiteral<"Ethereum">;
96
97
  destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
97
- destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
98
98
  ccmMetadata: z.ZodObject<{
99
- message: z.ZodString;
100
99
  gasBudget: z.ZodString;
100
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
101
101
  }, "strip", z.ZodTypeAny, {
102
- message: string;
102
+ message: `0x${string}`;
103
103
  gasBudget: string;
104
104
  }, {
105
- message: string;
105
+ message: `0x${string}`;
106
106
  gasBudget: string;
107
107
  }>;
108
108
  }, "strip", z.ZodTypeAny, {
109
109
  amount: bigint;
110
110
  srcChain: "Ethereum";
111
111
  srcAsset: "ETH";
112
+ destAsset: "FLIP" | "USDC";
112
113
  destChain: "Ethereum";
113
114
  destAddress: `0x${string}`;
114
- destAsset: "FLIP" | "USDC";
115
115
  ccmMetadata: {
116
- message: string;
116
+ message: `0x${string}`;
117
117
  gasBudget: string;
118
118
  };
119
119
  }, {
120
120
  amount: bigint;
121
121
  srcChain: "Ethereum";
122
122
  srcAsset: "ETH";
123
+ destAsset: "FLIP" | "USDC";
123
124
  destChain: "Ethereum";
124
125
  destAddress: `0x${string}`;
125
- destAsset: "FLIP" | "USDC";
126
126
  ccmMetadata: {
127
- message: string;
127
+ message: `0x${string}`;
128
128
  gasBudget: string;
129
129
  };
130
130
  }>, z.ZodUnion<[z.ZodObject<{
131
131
  amount: z.ZodBigInt;
132
132
  srcChain: z.ZodLiteral<"Ethereum">;
133
133
  srcAsset: z.ZodLiteral<"FLIP">;
134
+ destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
134
135
  destChain: z.ZodLiteral<"Ethereum">;
135
136
  destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
136
- destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
137
137
  ccmMetadata: z.ZodObject<{
138
- message: z.ZodString;
139
138
  gasBudget: z.ZodString;
139
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
140
140
  }, "strip", z.ZodTypeAny, {
141
- message: string;
141
+ message: `0x${string}`;
142
142
  gasBudget: string;
143
143
  }, {
144
- message: string;
144
+ message: `0x${string}`;
145
145
  gasBudget: string;
146
146
  }>;
147
147
  }, "strip", z.ZodTypeAny, {
148
148
  amount: bigint;
149
149
  srcChain: "Ethereum";
150
150
  srcAsset: "FLIP";
151
+ destAsset: "USDC" | "ETH";
151
152
  destChain: "Ethereum";
152
153
  destAddress: `0x${string}`;
153
- destAsset: "USDC" | "ETH";
154
154
  ccmMetadata: {
155
- message: string;
155
+ message: `0x${string}`;
156
156
  gasBudget: string;
157
157
  };
158
158
  }, {
159
159
  amount: bigint;
160
160
  srcChain: "Ethereum";
161
161
  srcAsset: "FLIP";
162
+ destAsset: "USDC" | "ETH";
162
163
  destChain: "Ethereum";
163
164
  destAddress: `0x${string}`;
164
- destAsset: "USDC" | "ETH";
165
165
  ccmMetadata: {
166
- message: string;
166
+ message: `0x${string}`;
167
167
  gasBudget: string;
168
168
  };
169
169
  }>, z.ZodObject<{
170
170
  amount: z.ZodBigInt;
171
171
  srcChain: z.ZodLiteral<"Ethereum">;
172
172
  srcAsset: z.ZodLiteral<"USDC">;
173
+ destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
173
174
  destChain: z.ZodLiteral<"Ethereum">;
174
175
  destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
175
- destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
176
176
  ccmMetadata: z.ZodObject<{
177
- message: z.ZodString;
178
177
  gasBudget: z.ZodString;
178
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
179
179
  }, "strip", z.ZodTypeAny, {
180
- message: string;
180
+ message: `0x${string}`;
181
181
  gasBudget: string;
182
182
  }, {
183
- message: string;
183
+ message: `0x${string}`;
184
184
  gasBudget: string;
185
185
  }>;
186
186
  }, "strip", z.ZodTypeAny, {
187
187
  amount: bigint;
188
188
  srcChain: "Ethereum";
189
189
  srcAsset: "USDC";
190
+ destAsset: "FLIP" | "ETH";
190
191
  destChain: "Ethereum";
191
192
  destAddress: `0x${string}`;
192
- destAsset: "FLIP" | "ETH";
193
193
  ccmMetadata: {
194
- message: string;
194
+ message: `0x${string}`;
195
195
  gasBudget: string;
196
196
  };
197
197
  }, {
198
198
  amount: bigint;
199
199
  srcChain: "Ethereum";
200
200
  srcAsset: "USDC";
201
+ destAsset: "FLIP" | "ETH";
201
202
  destChain: "Ethereum";
202
203
  destAddress: `0x${string}`;
203
- destAsset: "FLIP" | "ETH";
204
204
  ccmMetadata: {
205
- message: string;
205
+ message: `0x${string}`;
206
206
  gasBudget: string;
207
207
  };
208
208
  }>]>, z.ZodUnion<[z.ZodObject<{
@@ -216,16 +216,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
216
216
  amount: bigint;
217
217
  srcChain: "Ethereum";
218
218
  srcAsset: "ETH";
219
+ destAsset: "FLIP" | "USDC";
219
220
  destChain: "Ethereum";
220
221
  destAddress: `0x${string}`;
221
- destAsset: "FLIP" | "USDC";
222
222
  }, {
223
223
  amount: bigint;
224
224
  srcChain: "Ethereum";
225
225
  srcAsset: "ETH";
226
+ destAsset: "FLIP" | "USDC";
226
227
  destChain: "Ethereum";
227
228
  destAddress: `0x${string}`;
228
- destAsset: "FLIP" | "USDC";
229
229
  }>, z.ZodObject<{
230
230
  amount: z.ZodBigInt;
231
231
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -237,16 +237,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
237
237
  amount: bigint;
238
238
  srcChain: "Ethereum";
239
239
  srcAsset: "ETH";
240
+ destAsset: "DOT";
240
241
  destChain: "Polkadot";
241
242
  destAddress: string;
242
- destAsset: "DOT";
243
243
  }, {
244
244
  amount: bigint;
245
245
  srcChain: "Ethereum";
246
246
  srcAsset: "ETH";
247
+ destAsset: "DOT";
247
248
  destChain: "Polkadot";
248
249
  destAddress: string;
249
- destAsset: "DOT";
250
250
  }>, z.ZodObject<{
251
251
  amount: z.ZodBigInt;
252
252
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -258,16 +258,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
258
258
  amount: bigint;
259
259
  srcChain: "Ethereum";
260
260
  srcAsset: "ETH";
261
+ destAsset: "BTC";
261
262
  destChain: "Bitcoin";
262
263
  destAddress: string;
263
- destAsset: "BTC";
264
264
  }, {
265
265
  amount: bigint;
266
266
  srcChain: "Ethereum";
267
267
  srcAsset: "ETH";
268
+ destAsset: "BTC";
268
269
  destChain: "Bitcoin";
269
270
  destAddress: string;
270
- destAsset: "BTC";
271
271
  }>]>, z.ZodUnion<[z.ZodObject<{
272
272
  amount: z.ZodBigInt;
273
273
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -279,16 +279,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
279
279
  amount: bigint;
280
280
  srcChain: "Ethereum";
281
281
  srcAsset: "FLIP";
282
+ destAsset: "USDC" | "ETH";
282
283
  destChain: "Ethereum";
283
284
  destAddress: `0x${string}`;
284
- destAsset: "USDC" | "ETH";
285
285
  }, {
286
286
  amount: bigint;
287
287
  srcChain: "Ethereum";
288
288
  srcAsset: "FLIP";
289
+ destAsset: "USDC" | "ETH";
289
290
  destChain: "Ethereum";
290
291
  destAddress: `0x${string}`;
291
- destAsset: "USDC" | "ETH";
292
292
  }>, z.ZodObject<{
293
293
  amount: z.ZodBigInt;
294
294
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -300,71 +300,71 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
300
300
  amount: bigint;
301
301
  srcChain: "Ethereum";
302
302
  srcAsset: "USDC";
303
+ destAsset: "FLIP" | "ETH";
303
304
  destChain: "Ethereum";
304
305
  destAddress: `0x${string}`;
305
- destAsset: "FLIP" | "ETH";
306
306
  }, {
307
307
  amount: bigint;
308
308
  srcChain: "Ethereum";
309
309
  srcAsset: "USDC";
310
+ destAsset: "FLIP" | "ETH";
310
311
  destChain: "Ethereum";
311
312
  destAddress: `0x${string}`;
312
- destAsset: "FLIP" | "ETH";
313
313
  }>, z.ZodObject<{
314
314
  amount: z.ZodBigInt;
315
315
  srcChain: z.ZodLiteral<"Ethereum">;
316
+ destAsset: z.ZodLiteral<"DOT">;
316
317
  destChain: z.ZodLiteral<"Polkadot">;
317
318
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
318
- destAsset: z.ZodLiteral<"DOT">;
319
319
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
320
320
  }, "strip", z.ZodTypeAny, {
321
321
  amount: bigint;
322
322
  srcChain: "Ethereum";
323
323
  srcAsset: "FLIP" | "USDC";
324
+ destAsset: "DOT";
324
325
  destChain: "Polkadot";
325
326
  destAddress: string;
326
- destAsset: "DOT";
327
327
  }, {
328
328
  amount: bigint;
329
329
  srcChain: "Ethereum";
330
330
  srcAsset: "FLIP" | "USDC";
331
+ destAsset: "DOT";
331
332
  destChain: "Polkadot";
332
333
  destAddress: string;
333
- destAsset: "DOT";
334
334
  }>, z.ZodObject<{
335
335
  amount: z.ZodBigInt;
336
336
  srcChain: z.ZodLiteral<"Ethereum">;
337
+ destAsset: z.ZodLiteral<"BTC">;
337
338
  destChain: z.ZodLiteral<"Bitcoin">;
338
339
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
339
- destAsset: z.ZodLiteral<"BTC">;
340
340
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
341
341
  }, "strip", z.ZodTypeAny, {
342
342
  amount: bigint;
343
343
  srcChain: "Ethereum";
344
344
  srcAsset: "FLIP" | "USDC";
345
+ destAsset: "BTC";
345
346
  destChain: "Bitcoin";
346
347
  destAddress: string;
347
- destAsset: "BTC";
348
348
  }, {
349
349
  amount: bigint;
350
350
  srcChain: "Ethereum";
351
351
  srcAsset: "FLIP" | "USDC";
352
+ destAsset: "BTC";
352
353
  destChain: "Bitcoin";
353
354
  destAddress: string;
354
- destAsset: "BTC";
355
355
  }>]>]>;
356
356
  type ExecuteSwapParams = z.infer<typeof executeSwapParamsSchema>;
357
357
  type TokenSwapParams = z.infer<typeof tokenSwapParamsSchema>;
358
358
 
359
359
  declare const ccmMetadataSchema: z.ZodObject<{
360
- gasBudget: z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodNumber]>;
361
- message: z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodString]>;
360
+ gasBudget: z.ZodString;
361
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
362
362
  }, "strip", z.ZodTypeAny, {
363
- message: string;
364
- gasBudget: number | `0x${string}`;
363
+ message: `0x${string}`;
364
+ gasBudget: string;
365
365
  }, {
366
- message: string;
367
- gasBudget: number | `0x${string}`;
366
+ message: `0x${string}`;
367
+ gasBudget: string;
368
368
  }>;
369
369
  type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
370
370
  declare const quoteResponseSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
@@ -536,7 +536,7 @@ type RequestOptions = {
536
536
  signal?: AbortSignal;
537
537
  };
538
538
 
539
- type TransactionHash = string;
539
+ type TransactionHash = `0x${string}`;
540
540
  type SDKOptions = {
541
541
  network?: Exclude<ChainflipNetwork, 'mainnet'>;
542
542
  signer?: Signer;
package/dist/swap.d.ts CHANGED
@@ -14,16 +14,16 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
14
14
  amount: bigint;
15
15
  srcChain: "Ethereum";
16
16
  srcAsset: "FLIP";
17
+ destAsset: "USDC" | "ETH";
17
18
  destChain: "Ethereum";
18
19
  destAddress: `0x${string}`;
19
- destAsset: "USDC" | "ETH";
20
20
  }, {
21
21
  amount: bigint;
22
22
  srcChain: "Ethereum";
23
23
  srcAsset: "FLIP";
24
+ destAsset: "USDC" | "ETH";
24
25
  destChain: "Ethereum";
25
26
  destAddress: `0x${string}`;
26
- destAsset: "USDC" | "ETH";
27
27
  }>, z.ZodObject<{
28
28
  amount: z.ZodBigInt;
29
29
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -35,174 +35,174 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
35
35
  amount: bigint;
36
36
  srcChain: "Ethereum";
37
37
  srcAsset: "USDC";
38
+ destAsset: "FLIP" | "ETH";
38
39
  destChain: "Ethereum";
39
40
  destAddress: `0x${string}`;
40
- destAsset: "FLIP" | "ETH";
41
41
  }, {
42
42
  amount: bigint;
43
43
  srcChain: "Ethereum";
44
44
  srcAsset: "USDC";
45
+ destAsset: "FLIP" | "ETH";
45
46
  destChain: "Ethereum";
46
47
  destAddress: `0x${string}`;
47
- destAsset: "FLIP" | "ETH";
48
48
  }>, z.ZodObject<{
49
49
  amount: z.ZodBigInt;
50
50
  srcChain: z.ZodLiteral<"Ethereum">;
51
+ destAsset: z.ZodLiteral<"DOT">;
51
52
  destChain: z.ZodLiteral<"Polkadot">;
52
53
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
53
- destAsset: z.ZodLiteral<"DOT">;
54
54
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
55
55
  }, "strip", z.ZodTypeAny, {
56
56
  amount: bigint;
57
57
  srcChain: "Ethereum";
58
58
  srcAsset: "FLIP" | "USDC";
59
+ destAsset: "DOT";
59
60
  destChain: "Polkadot";
60
61
  destAddress: string;
61
- destAsset: "DOT";
62
62
  }, {
63
63
  amount: bigint;
64
64
  srcChain: "Ethereum";
65
65
  srcAsset: "FLIP" | "USDC";
66
+ destAsset: "DOT";
66
67
  destChain: "Polkadot";
67
68
  destAddress: string;
68
- destAsset: "DOT";
69
69
  }>, z.ZodObject<{
70
70
  amount: z.ZodBigInt;
71
71
  srcChain: z.ZodLiteral<"Ethereum">;
72
+ destAsset: z.ZodLiteral<"BTC">;
72
73
  destChain: z.ZodLiteral<"Bitcoin">;
73
74
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
74
- destAsset: z.ZodLiteral<"BTC">;
75
75
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
76
76
  }, "strip", z.ZodTypeAny, {
77
77
  amount: bigint;
78
78
  srcChain: "Ethereum";
79
79
  srcAsset: "FLIP" | "USDC";
80
+ destAsset: "BTC";
80
81
  destChain: "Bitcoin";
81
82
  destAddress: string;
82
- destAsset: "BTC";
83
83
  }, {
84
84
  amount: bigint;
85
85
  srcChain: "Ethereum";
86
86
  srcAsset: "FLIP" | "USDC";
87
+ destAsset: "BTC";
87
88
  destChain: "Bitcoin";
88
89
  destAddress: string;
89
- destAsset: "BTC";
90
90
  }>]>;
91
91
  declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
92
92
  amount: z.ZodBigInt;
93
93
  srcChain: z.ZodLiteral<"Ethereum">;
94
94
  srcAsset: z.ZodLiteral<"ETH">;
95
+ destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
95
96
  destChain: z.ZodLiteral<"Ethereum">;
96
97
  destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
97
- destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
98
98
  ccmMetadata: z.ZodObject<{
99
- message: z.ZodString;
100
99
  gasBudget: z.ZodString;
100
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
101
101
  }, "strip", z.ZodTypeAny, {
102
- message: string;
102
+ message: `0x${string}`;
103
103
  gasBudget: string;
104
104
  }, {
105
- message: string;
105
+ message: `0x${string}`;
106
106
  gasBudget: string;
107
107
  }>;
108
108
  }, "strip", z.ZodTypeAny, {
109
109
  amount: bigint;
110
110
  srcChain: "Ethereum";
111
111
  srcAsset: "ETH";
112
+ destAsset: "FLIP" | "USDC";
112
113
  destChain: "Ethereum";
113
114
  destAddress: `0x${string}`;
114
- destAsset: "FLIP" | "USDC";
115
115
  ccmMetadata: {
116
- message: string;
116
+ message: `0x${string}`;
117
117
  gasBudget: string;
118
118
  };
119
119
  }, {
120
120
  amount: bigint;
121
121
  srcChain: "Ethereum";
122
122
  srcAsset: "ETH";
123
+ destAsset: "FLIP" | "USDC";
123
124
  destChain: "Ethereum";
124
125
  destAddress: `0x${string}`;
125
- destAsset: "FLIP" | "USDC";
126
126
  ccmMetadata: {
127
- message: string;
127
+ message: `0x${string}`;
128
128
  gasBudget: string;
129
129
  };
130
130
  }>, z.ZodUnion<[z.ZodObject<{
131
131
  amount: z.ZodBigInt;
132
132
  srcChain: z.ZodLiteral<"Ethereum">;
133
133
  srcAsset: z.ZodLiteral<"FLIP">;
134
+ destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
134
135
  destChain: z.ZodLiteral<"Ethereum">;
135
136
  destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
136
- destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
137
137
  ccmMetadata: z.ZodObject<{
138
- message: z.ZodString;
139
138
  gasBudget: z.ZodString;
139
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
140
140
  }, "strip", z.ZodTypeAny, {
141
- message: string;
141
+ message: `0x${string}`;
142
142
  gasBudget: string;
143
143
  }, {
144
- message: string;
144
+ message: `0x${string}`;
145
145
  gasBudget: string;
146
146
  }>;
147
147
  }, "strip", z.ZodTypeAny, {
148
148
  amount: bigint;
149
149
  srcChain: "Ethereum";
150
150
  srcAsset: "FLIP";
151
+ destAsset: "USDC" | "ETH";
151
152
  destChain: "Ethereum";
152
153
  destAddress: `0x${string}`;
153
- destAsset: "USDC" | "ETH";
154
154
  ccmMetadata: {
155
- message: string;
155
+ message: `0x${string}`;
156
156
  gasBudget: string;
157
157
  };
158
158
  }, {
159
159
  amount: bigint;
160
160
  srcChain: "Ethereum";
161
161
  srcAsset: "FLIP";
162
+ destAsset: "USDC" | "ETH";
162
163
  destChain: "Ethereum";
163
164
  destAddress: `0x${string}`;
164
- destAsset: "USDC" | "ETH";
165
165
  ccmMetadata: {
166
- message: string;
166
+ message: `0x${string}`;
167
167
  gasBudget: string;
168
168
  };
169
169
  }>, z.ZodObject<{
170
170
  amount: z.ZodBigInt;
171
171
  srcChain: z.ZodLiteral<"Ethereum">;
172
172
  srcAsset: z.ZodLiteral<"USDC">;
173
+ destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
173
174
  destChain: z.ZodLiteral<"Ethereum">;
174
175
  destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
175
- destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
176
176
  ccmMetadata: z.ZodObject<{
177
- message: z.ZodString;
178
177
  gasBudget: z.ZodString;
178
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
179
179
  }, "strip", z.ZodTypeAny, {
180
- message: string;
180
+ message: `0x${string}`;
181
181
  gasBudget: string;
182
182
  }, {
183
- message: string;
183
+ message: `0x${string}`;
184
184
  gasBudget: string;
185
185
  }>;
186
186
  }, "strip", z.ZodTypeAny, {
187
187
  amount: bigint;
188
188
  srcChain: "Ethereum";
189
189
  srcAsset: "USDC";
190
+ destAsset: "FLIP" | "ETH";
190
191
  destChain: "Ethereum";
191
192
  destAddress: `0x${string}`;
192
- destAsset: "FLIP" | "ETH";
193
193
  ccmMetadata: {
194
- message: string;
194
+ message: `0x${string}`;
195
195
  gasBudget: string;
196
196
  };
197
197
  }, {
198
198
  amount: bigint;
199
199
  srcChain: "Ethereum";
200
200
  srcAsset: "USDC";
201
+ destAsset: "FLIP" | "ETH";
201
202
  destChain: "Ethereum";
202
203
  destAddress: `0x${string}`;
203
- destAsset: "FLIP" | "ETH";
204
204
  ccmMetadata: {
205
- message: string;
205
+ message: `0x${string}`;
206
206
  gasBudget: string;
207
207
  };
208
208
  }>]>, z.ZodUnion<[z.ZodObject<{
@@ -216,16 +216,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
216
216
  amount: bigint;
217
217
  srcChain: "Ethereum";
218
218
  srcAsset: "ETH";
219
+ destAsset: "FLIP" | "USDC";
219
220
  destChain: "Ethereum";
220
221
  destAddress: `0x${string}`;
221
- destAsset: "FLIP" | "USDC";
222
222
  }, {
223
223
  amount: bigint;
224
224
  srcChain: "Ethereum";
225
225
  srcAsset: "ETH";
226
+ destAsset: "FLIP" | "USDC";
226
227
  destChain: "Ethereum";
227
228
  destAddress: `0x${string}`;
228
- destAsset: "FLIP" | "USDC";
229
229
  }>, z.ZodObject<{
230
230
  amount: z.ZodBigInt;
231
231
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -237,16 +237,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
237
237
  amount: bigint;
238
238
  srcChain: "Ethereum";
239
239
  srcAsset: "ETH";
240
+ destAsset: "DOT";
240
241
  destChain: "Polkadot";
241
242
  destAddress: string;
242
- destAsset: "DOT";
243
243
  }, {
244
244
  amount: bigint;
245
245
  srcChain: "Ethereum";
246
246
  srcAsset: "ETH";
247
+ destAsset: "DOT";
247
248
  destChain: "Polkadot";
248
249
  destAddress: string;
249
- destAsset: "DOT";
250
250
  }>, z.ZodObject<{
251
251
  amount: z.ZodBigInt;
252
252
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -258,16 +258,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
258
258
  amount: bigint;
259
259
  srcChain: "Ethereum";
260
260
  srcAsset: "ETH";
261
+ destAsset: "BTC";
261
262
  destChain: "Bitcoin";
262
263
  destAddress: string;
263
- destAsset: "BTC";
264
264
  }, {
265
265
  amount: bigint;
266
266
  srcChain: "Ethereum";
267
267
  srcAsset: "ETH";
268
+ destAsset: "BTC";
268
269
  destChain: "Bitcoin";
269
270
  destAddress: string;
270
- destAsset: "BTC";
271
271
  }>]>, z.ZodUnion<[z.ZodObject<{
272
272
  amount: z.ZodBigInt;
273
273
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -279,16 +279,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
279
279
  amount: bigint;
280
280
  srcChain: "Ethereum";
281
281
  srcAsset: "FLIP";
282
+ destAsset: "USDC" | "ETH";
282
283
  destChain: "Ethereum";
283
284
  destAddress: `0x${string}`;
284
- destAsset: "USDC" | "ETH";
285
285
  }, {
286
286
  amount: bigint;
287
287
  srcChain: "Ethereum";
288
288
  srcAsset: "FLIP";
289
+ destAsset: "USDC" | "ETH";
289
290
  destChain: "Ethereum";
290
291
  destAddress: `0x${string}`;
291
- destAsset: "USDC" | "ETH";
292
292
  }>, z.ZodObject<{
293
293
  amount: z.ZodBigInt;
294
294
  srcChain: z.ZodLiteral<"Ethereum">;
@@ -300,71 +300,71 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
300
300
  amount: bigint;
301
301
  srcChain: "Ethereum";
302
302
  srcAsset: "USDC";
303
+ destAsset: "FLIP" | "ETH";
303
304
  destChain: "Ethereum";
304
305
  destAddress: `0x${string}`;
305
- destAsset: "FLIP" | "ETH";
306
306
  }, {
307
307
  amount: bigint;
308
308
  srcChain: "Ethereum";
309
309
  srcAsset: "USDC";
310
+ destAsset: "FLIP" | "ETH";
310
311
  destChain: "Ethereum";
311
312
  destAddress: `0x${string}`;
312
- destAsset: "FLIP" | "ETH";
313
313
  }>, z.ZodObject<{
314
314
  amount: z.ZodBigInt;
315
315
  srcChain: z.ZodLiteral<"Ethereum">;
316
+ destAsset: z.ZodLiteral<"DOT">;
316
317
  destChain: z.ZodLiteral<"Polkadot">;
317
318
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
318
- destAsset: z.ZodLiteral<"DOT">;
319
319
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
320
320
  }, "strip", z.ZodTypeAny, {
321
321
  amount: bigint;
322
322
  srcChain: "Ethereum";
323
323
  srcAsset: "FLIP" | "USDC";
324
+ destAsset: "DOT";
324
325
  destChain: "Polkadot";
325
326
  destAddress: string;
326
- destAsset: "DOT";
327
327
  }, {
328
328
  amount: bigint;
329
329
  srcChain: "Ethereum";
330
330
  srcAsset: "FLIP" | "USDC";
331
+ destAsset: "DOT";
331
332
  destChain: "Polkadot";
332
333
  destAddress: string;
333
- destAsset: "DOT";
334
334
  }>, z.ZodObject<{
335
335
  amount: z.ZodBigInt;
336
336
  srcChain: z.ZodLiteral<"Ethereum">;
337
+ destAsset: z.ZodLiteral<"BTC">;
337
338
  destChain: z.ZodLiteral<"Bitcoin">;
338
339
  destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
339
- destAsset: z.ZodLiteral<"BTC">;
340
340
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
341
341
  }, "strip", z.ZodTypeAny, {
342
342
  amount: bigint;
343
343
  srcChain: "Ethereum";
344
344
  srcAsset: "FLIP" | "USDC";
345
+ destAsset: "BTC";
345
346
  destChain: "Bitcoin";
346
347
  destAddress: string;
347
- destAsset: "BTC";
348
348
  }, {
349
349
  amount: bigint;
350
350
  srcChain: "Ethereum";
351
351
  srcAsset: "FLIP" | "USDC";
352
+ destAsset: "BTC";
352
353
  destChain: "Bitcoin";
353
354
  destAddress: string;
354
- destAsset: "BTC";
355
355
  }>]>]>;
356
356
  type ExecuteSwapParams = z.infer<typeof executeSwapParamsSchema>;
357
357
  type TokenSwapParams = z.infer<typeof tokenSwapParamsSchema>;
358
358
 
359
359
  declare const ccmMetadataSchema: z.ZodObject<{
360
- gasBudget: z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodNumber]>;
361
- message: z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodString]>;
360
+ gasBudget: z.ZodString;
361
+ message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
362
362
  }, "strip", z.ZodTypeAny, {
363
- message: string;
364
- gasBudget: number | `0x${string}`;
363
+ message: `0x${string}`;
364
+ gasBudget: string;
365
365
  }, {
366
- message: string;
367
- gasBudget: number | `0x${string}`;
366
+ message: `0x${string}`;
367
+ gasBudget: string;
368
368
  }>;
369
369
  type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
370
370
  declare const quoteResponseSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
@@ -536,7 +536,7 @@ type RequestOptions = {
536
536
  signal?: AbortSignal;
537
537
  };
538
538
 
539
- type TransactionHash = string;
539
+ type TransactionHash = `0x${string}`;
540
540
  type SDKOptions = {
541
541
  network?: Exclude<ChainflipNetwork, 'mainnet'>;
542
542
  signer?: Signer;
package/dist/swap.js CHANGED
@@ -411,8 +411,8 @@ zod.z.object({
411
411
  "Btc"
412
412
  ])
413
413
  }).transform(({ __kind }) => __kind.toUpperCase());
414
- zod.z.nativeEnum(Chains);
415
- zod.z.nativeEnum(Assets);
414
+ var chainflipChain = zod.z.nativeEnum(Chains);
415
+ var chainflipAsset = zod.z.nativeEnum(Assets);
416
416
  zod.z.nativeEnum(ChainflipNetworks);
417
417
  zod.z.union([
418
418
  zod.z.object({
@@ -435,6 +435,45 @@ zod.z.union([
435
435
  type: "SWAP"
436
436
  }))
437
437
  ]);
438
+ zod.z.object({
439
+ srcAsset: chainflipAsset,
440
+ destAsset: chainflipAsset,
441
+ amount: numericString
442
+ });
443
+ var ccmMetadataSchema = zod.z.object({
444
+ gasBudget: numericString,
445
+ message: hexString
446
+ });
447
+ zod.z.object({
448
+ srcAsset: chainflipAsset,
449
+ destAsset: chainflipAsset,
450
+ srcChain: chainflipChain,
451
+ destChain: chainflipChain,
452
+ destAddress: zod.z.string(),
453
+ amount: numericString,
454
+ ccmMetadata: ccmMetadataSchema.optional()
455
+ }).transform(({ amount, ...rest }) => ({
456
+ ...rest,
457
+ expectedDepositAmount: amount
458
+ }));
459
+ zod.z.union([
460
+ zod.z.object({
461
+ id: zod.z.string(),
462
+ intermediate_amount: numericString,
463
+ egress_amount: numericString
464
+ }).transform(({ id, ...rest }) => ({
465
+ id,
466
+ intermediateAmount: rest.intermediate_amount,
467
+ egressAmount: rest.egress_amount
468
+ })),
469
+ zod.z.object({
470
+ id: zod.z.string(),
471
+ egress_amount: numericString
472
+ }).transform(({ id, ...rest }) => ({
473
+ id,
474
+ egressAmount: rest.egress_amount
475
+ }))
476
+ ]);
438
477
 
439
478
  // ../shared/src/vault/schemas.ts
440
479
  var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
@@ -498,10 +537,6 @@ var tokenSwapParamsSchema = zod.z.union([
498
537
  erc20ToDot,
499
538
  erc20ToBtc
500
539
  ]);
501
- var ccmMetadataSchema = zod.z.object({
502
- message: zod.z.string(),
503
- gasBudget: numericString
504
- });
505
540
  var ccmFlipToEthereumAssset = flipToEthereumAsset.extend({
506
541
  ccmMetadata: ccmMetadataSchema
507
542
  });
@@ -1904,7 +1939,7 @@ var getVaultManagerContractAddress = /* @__PURE__ */ __name((network) => {
1904
1939
  var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, networkOpts, txOpts) => {
1905
1940
  const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
1906
1941
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
1907
- const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "", {
1942
+ const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "0x", {
1908
1943
  value: amount,
1909
1944
  ...extractOverrides(txOpts)
1910
1945
  });
@@ -1917,13 +1952,13 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
1917
1952
  const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
1918
1953
  assert(isAllowable, "Swap amount exceeds allowance");
1919
1954
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
1920
- const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "", extractOverrides(txOpts));
1955
+ const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "0x", extractOverrides(txOpts));
1921
1956
  return transaction.wait(txOpts.wait);
1922
1957
  }, "swapToken");
1923
1958
  var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
1924
1959
  const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
1925
1960
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
1926
- const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "", {
1961
+ const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "0x", {
1927
1962
  value: params.amount,
1928
1963
  ...extractOverrides(txOpts)
1929
1964
  });
@@ -1936,7 +1971,7 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
1936
1971
  const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
1937
1972
  assert(isAllowable, "Swap amount exceeds allowance");
1938
1973
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
1939
- const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "", extractOverrides(txOpts));
1974
+ const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
1940
1975
  return transaction.wait(txOpts.wait);
1941
1976
  }, "callToken");
1942
1977
  var executeSwap = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
@@ -2182,7 +2217,7 @@ var _SwapSDK = class _SwapSDK {
2182
2217
  signer: this.signer,
2183
2218
  network: this.network
2184
2219
  }, txOpts);
2185
- return receipt && receipt.hash;
2220
+ return receipt ? receipt.hash : null;
2186
2221
  }
2187
2222
  };
2188
2223
  __name(_SwapSDK, "SwapSDK");
package/dist/swap.mjs CHANGED
@@ -299,8 +299,8 @@ z.object({
299
299
  "Btc"
300
300
  ])
301
301
  }).transform(({ __kind }) => __kind.toUpperCase());
302
- z.nativeEnum(Chains);
303
- z.nativeEnum(Assets);
302
+ var chainflipChain = z.nativeEnum(Chains);
303
+ var chainflipAsset = z.nativeEnum(Assets);
304
304
  z.nativeEnum(ChainflipNetworks);
305
305
  z.union([
306
306
  z.object({
@@ -323,6 +323,45 @@ z.union([
323
323
  type: "SWAP"
324
324
  }))
325
325
  ]);
326
+ z.object({
327
+ srcAsset: chainflipAsset,
328
+ destAsset: chainflipAsset,
329
+ amount: numericString
330
+ });
331
+ var ccmMetadataSchema = z.object({
332
+ gasBudget: numericString,
333
+ message: hexString
334
+ });
335
+ z.object({
336
+ srcAsset: chainflipAsset,
337
+ destAsset: chainflipAsset,
338
+ srcChain: chainflipChain,
339
+ destChain: chainflipChain,
340
+ destAddress: z.string(),
341
+ amount: numericString,
342
+ ccmMetadata: ccmMetadataSchema.optional()
343
+ }).transform(({ amount, ...rest }) => ({
344
+ ...rest,
345
+ expectedDepositAmount: amount
346
+ }));
347
+ z.union([
348
+ z.object({
349
+ id: z.string(),
350
+ intermediate_amount: numericString,
351
+ egress_amount: numericString
352
+ }).transform(({ id, ...rest }) => ({
353
+ id,
354
+ intermediateAmount: rest.intermediate_amount,
355
+ egressAmount: rest.egress_amount
356
+ })),
357
+ z.object({
358
+ id: z.string(),
359
+ egress_amount: numericString
360
+ }).transform(({ id, ...rest }) => ({
361
+ id,
362
+ egressAmount: rest.egress_amount
363
+ }))
364
+ ]);
326
365
 
327
366
  // ../shared/src/vault/schemas.ts
328
367
  var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
@@ -386,10 +425,6 @@ var tokenSwapParamsSchema = z.union([
386
425
  erc20ToDot,
387
426
  erc20ToBtc
388
427
  ]);
389
- var ccmMetadataSchema = z.object({
390
- message: z.string(),
391
- gasBudget: numericString
392
- });
393
428
  var ccmFlipToEthereumAssset = flipToEthereumAsset.extend({
394
429
  ccmMetadata: ccmMetadataSchema
395
430
  });
@@ -415,7 +450,7 @@ var executeSwapParamsSchema = z.union([
415
450
  var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, networkOpts, txOpts) => {
416
451
  const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
417
452
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
418
- const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "", {
453
+ const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "0x", {
419
454
  value: amount,
420
455
  ...extractOverrides(txOpts)
421
456
  });
@@ -428,13 +463,13 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
428
463
  const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
429
464
  assert(isAllowable, "Swap amount exceeds allowance");
430
465
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
431
- const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "", extractOverrides(txOpts));
466
+ const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "0x", extractOverrides(txOpts));
432
467
  return transaction.wait(txOpts.wait);
433
468
  }, "swapToken");
434
469
  var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
435
470
  const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
436
471
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
437
- const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "", {
472
+ const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "0x", {
438
473
  value: params.amount,
439
474
  ...extractOverrides(txOpts)
440
475
  });
@@ -447,7 +482,7 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
447
482
  const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
448
483
  assert(isAllowable, "Swap amount exceeds allowance");
449
484
  const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
450
- const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "", extractOverrides(txOpts));
485
+ const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
451
486
  return transaction.wait(txOpts.wait);
452
487
  }, "callToken");
453
488
  var executeSwap = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
@@ -693,7 +728,7 @@ var _SwapSDK = class _SwapSDK {
693
728
  signer: this.signer,
694
729
  network: this.network
695
730
  }, txOpts);
696
- return receipt && receipt.hash;
731
+ return receipt ? receipt.hash : null;
697
732
  }
698
733
  };
699
734
  __name(_SwapSDK, "SwapSDK");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {
@@ -41,8 +41,8 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "@polkadot/util": "^12.4.2",
45
- "@polkadot/util-crypto": "^12.4.2",
44
+ "@polkadot/util": "^12.5.1",
45
+ "@polkadot/util-crypto": "^12.5.1",
46
46
  "axios": "^1.5.0",
47
47
  "ethers": "6.7.1",
48
48
  "zod": "^3.22.2"