@chainflip/sdk 0.1.5 → 0.1.7
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.
- package/dist/swap.d.ts +9 -12
- package/dist/swap.js +27 -6
- package/dist/swap.mjs +27 -6
- package/package.json +1 -1
package/dist/swap.d.ts
CHANGED
|
@@ -246,25 +246,25 @@ declare const executeCallParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
246
246
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
247
247
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
248
248
|
message: z.ZodString;
|
|
249
|
-
|
|
249
|
+
gasBudget: z.ZodString;
|
|
250
250
|
}, "strip", z.ZodTypeAny, {
|
|
251
251
|
amount: string | bigint;
|
|
252
252
|
message: string;
|
|
253
|
-
gasAmount: string;
|
|
254
253
|
srcChain: "Ethereum";
|
|
255
254
|
srcAsset: "ETH";
|
|
256
255
|
destChain: "Ethereum";
|
|
257
256
|
destAddress: `0x${string}`;
|
|
258
257
|
destAsset: "FLIP" | "USDC";
|
|
258
|
+
gasBudget: string;
|
|
259
259
|
}, {
|
|
260
260
|
amount: string | bigint;
|
|
261
261
|
message: string;
|
|
262
|
-
gasAmount: string;
|
|
263
262
|
srcChain: "Ethereum";
|
|
264
263
|
srcAsset: "ETH";
|
|
265
264
|
destChain: "Ethereum";
|
|
266
265
|
destAddress: `0x${string}`;
|
|
267
266
|
destAsset: "FLIP" | "USDC";
|
|
267
|
+
gasBudget: string;
|
|
268
268
|
}>, z.ZodUnion<[z.ZodObject<{
|
|
269
269
|
amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
|
|
270
270
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -273,25 +273,25 @@ declare const executeCallParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
273
273
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
274
274
|
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
275
275
|
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
276
|
-
|
|
276
|
+
gasBudget: z.ZodString;
|
|
277
277
|
}, "strip", z.ZodTypeAny, {
|
|
278
278
|
amount: string | bigint;
|
|
279
279
|
message: `0x${string}`;
|
|
280
|
-
gasAmount: string;
|
|
281
280
|
srcChain: "Ethereum";
|
|
282
281
|
srcAsset: "FLIP";
|
|
283
282
|
destChain: "Ethereum";
|
|
284
283
|
destAddress: `0x${string}`;
|
|
285
284
|
destAsset: "USDC" | "ETH";
|
|
285
|
+
gasBudget: string;
|
|
286
286
|
}, {
|
|
287
287
|
amount: string | bigint;
|
|
288
288
|
message: `0x${string}`;
|
|
289
|
-
gasAmount: string;
|
|
290
289
|
srcChain: "Ethereum";
|
|
291
290
|
srcAsset: "FLIP";
|
|
292
291
|
destChain: "Ethereum";
|
|
293
292
|
destAddress: `0x${string}`;
|
|
294
293
|
destAsset: "USDC" | "ETH";
|
|
294
|
+
gasBudget: string;
|
|
295
295
|
}>, z.ZodObject<{
|
|
296
296
|
amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
|
|
297
297
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -300,40 +300,37 @@ declare const executeCallParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
300
300
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
301
301
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
302
302
|
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
303
|
-
|
|
303
|
+
gasBudget: z.ZodString;
|
|
304
304
|
}, "strip", z.ZodTypeAny, {
|
|
305
305
|
amount: string | bigint;
|
|
306
306
|
message: `0x${string}`;
|
|
307
|
-
gasAmount: string;
|
|
308
307
|
srcChain: "Ethereum";
|
|
309
308
|
srcAsset: "USDC";
|
|
310
309
|
destChain: "Ethereum";
|
|
311
310
|
destAddress: `0x${string}`;
|
|
312
311
|
destAsset: "FLIP" | "ETH";
|
|
312
|
+
gasBudget: string;
|
|
313
313
|
}, {
|
|
314
314
|
amount: string | bigint;
|
|
315
315
|
message: `0x${string}`;
|
|
316
|
-
gasAmount: string;
|
|
317
316
|
srcChain: "Ethereum";
|
|
318
317
|
srcAsset: "USDC";
|
|
319
318
|
destChain: "Ethereum";
|
|
320
319
|
destAddress: `0x${string}`;
|
|
321
320
|
destAsset: "FLIP" | "ETH";
|
|
321
|
+
gasBudget: string;
|
|
322
322
|
}>]>]>;
|
|
323
323
|
type ExecuteCallParams = z.infer<typeof executeCallParamsSchema>;
|
|
324
324
|
|
|
325
325
|
declare const ccmMetadataSchema: z.ZodObject<{
|
|
326
326
|
gasBudget: z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodNumber]>;
|
|
327
327
|
message: z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodString]>;
|
|
328
|
-
cfParameters: z.ZodOptional<z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodString]>>;
|
|
329
328
|
}, "strip", z.ZodTypeAny, {
|
|
330
329
|
message: string;
|
|
331
330
|
gasBudget: number | `0x${string}`;
|
|
332
|
-
cfParameters?: string | undefined;
|
|
333
331
|
}, {
|
|
334
332
|
message: string;
|
|
335
333
|
gasBudget: number | `0x${string}`;
|
|
336
|
-
cfParameters?: string | undefined;
|
|
337
334
|
}>;
|
|
338
335
|
type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
|
|
339
336
|
declare const quoteResponseSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
package/dist/swap.js
CHANGED
|
@@ -1750,7 +1750,7 @@ var u128 = zod.z.union([
|
|
|
1750
1750
|
numericString,
|
|
1751
1751
|
hexString
|
|
1752
1752
|
]).transform((arg) => BigInt(arg));
|
|
1753
|
-
zod.z.union([
|
|
1753
|
+
var unsignedInteger = zod.z.union([
|
|
1754
1754
|
u128,
|
|
1755
1755
|
zod.z.number().transform((n) => BigInt(n))
|
|
1756
1756
|
]);
|
|
@@ -1766,6 +1766,27 @@ zod.z.object({
|
|
|
1766
1766
|
zod.z.nativeEnum(Chains);
|
|
1767
1767
|
zod.z.nativeEnum(Assets);
|
|
1768
1768
|
var chainflipNetwork = zod.z.nativeEnum(ChainflipNetworks);
|
|
1769
|
+
zod.z.union([
|
|
1770
|
+
zod.z.object({
|
|
1771
|
+
__kind: zod.z.literal("CcmPrincipal"),
|
|
1772
|
+
value: unsignedInteger
|
|
1773
|
+
}).transform(({ value: ccmId }) => ({
|
|
1774
|
+
type: "PRINCIPAL",
|
|
1775
|
+
ccmId
|
|
1776
|
+
})),
|
|
1777
|
+
zod.z.object({
|
|
1778
|
+
__kind: zod.z.literal("CcmGas"),
|
|
1779
|
+
value: unsignedInteger
|
|
1780
|
+
}).transform(({ value: ccmId }) => ({
|
|
1781
|
+
type: "GAS",
|
|
1782
|
+
ccmId
|
|
1783
|
+
})),
|
|
1784
|
+
zod.z.object({
|
|
1785
|
+
__kind: zod.z.literal("Swap")
|
|
1786
|
+
}).transform(() => ({
|
|
1787
|
+
type: "SWAP"
|
|
1788
|
+
}))
|
|
1789
|
+
]);
|
|
1769
1790
|
|
|
1770
1791
|
// ../shared/src/vault/schemas.ts
|
|
1771
1792
|
var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
@@ -1840,7 +1861,7 @@ var executeSwapParamsSchema = zod.z.union([
|
|
|
1840
1861
|
var nativeCallParamsSchema = ethereumBase.extend({
|
|
1841
1862
|
destAsset: erc20,
|
|
1842
1863
|
message: zod.z.string(),
|
|
1843
|
-
|
|
1864
|
+
gasBudget: numericString
|
|
1844
1865
|
});
|
|
1845
1866
|
var tokenCallParamsSchema = zod.z.union([
|
|
1846
1867
|
ethereumBase.extend({
|
|
@@ -1850,7 +1871,7 @@ var tokenCallParamsSchema = zod.z.union([
|
|
|
1850
1871
|
zod.z.literal(Assets.ETH)
|
|
1851
1872
|
]),
|
|
1852
1873
|
message: hexString,
|
|
1853
|
-
|
|
1874
|
+
gasBudget: numericString
|
|
1854
1875
|
}),
|
|
1855
1876
|
ethereumBase.extend({
|
|
1856
1877
|
srcAsset: zod.z.literal(Assets.USDC),
|
|
@@ -1859,7 +1880,7 @@ var tokenCallParamsSchema = zod.z.union([
|
|
|
1859
1880
|
zod.z.literal(Assets.ETH)
|
|
1860
1881
|
]),
|
|
1861
1882
|
message: hexString,
|
|
1862
|
-
|
|
1883
|
+
gasBudget: numericString
|
|
1863
1884
|
})
|
|
1864
1885
|
]);
|
|
1865
1886
|
var executeCallParamsSchema = zod.z.union([
|
|
@@ -1917,7 +1938,7 @@ var executeSwap_default = executeSwap;
|
|
|
1917
1938
|
var callNative = /* @__PURE__ */ __name(async (params, { nonce, ...opts }) => {
|
|
1918
1939
|
const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
|
|
1919
1940
|
const vault = Vault__factory.connect(vaultContractAddress, opts.signer);
|
|
1920
|
-
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.
|
|
1941
|
+
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, [], {
|
|
1921
1942
|
value: params.amount,
|
|
1922
1943
|
nonce
|
|
1923
1944
|
});
|
|
@@ -1930,7 +1951,7 @@ var callToken = /* @__PURE__ */ __name(async (params, { signer, ...opts }) => {
|
|
|
1930
1951
|
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, signer);
|
|
1931
1952
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
1932
1953
|
const vault = Vault__factory.connect(vaultContractAddress, signer);
|
|
1933
|
-
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.
|
|
1954
|
+
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, erc20Address, params.amount, [], {
|
|
1934
1955
|
nonce: opts.nonce
|
|
1935
1956
|
});
|
|
1936
1957
|
return transaction.wait(1);
|
package/dist/swap.mjs
CHANGED
|
@@ -283,7 +283,7 @@ var u128 = z.union([
|
|
|
283
283
|
numericString,
|
|
284
284
|
hexString
|
|
285
285
|
]).transform((arg) => BigInt(arg));
|
|
286
|
-
z.union([
|
|
286
|
+
var unsignedInteger = z.union([
|
|
287
287
|
u128,
|
|
288
288
|
z.number().transform((n) => BigInt(n))
|
|
289
289
|
]);
|
|
@@ -299,6 +299,27 @@ z.object({
|
|
|
299
299
|
z.nativeEnum(Chains);
|
|
300
300
|
z.nativeEnum(Assets);
|
|
301
301
|
var chainflipNetwork = z.nativeEnum(ChainflipNetworks);
|
|
302
|
+
z.union([
|
|
303
|
+
z.object({
|
|
304
|
+
__kind: z.literal("CcmPrincipal"),
|
|
305
|
+
value: unsignedInteger
|
|
306
|
+
}).transform(({ value: ccmId }) => ({
|
|
307
|
+
type: "PRINCIPAL",
|
|
308
|
+
ccmId
|
|
309
|
+
})),
|
|
310
|
+
z.object({
|
|
311
|
+
__kind: z.literal("CcmGas"),
|
|
312
|
+
value: unsignedInteger
|
|
313
|
+
}).transform(({ value: ccmId }) => ({
|
|
314
|
+
type: "GAS",
|
|
315
|
+
ccmId
|
|
316
|
+
})),
|
|
317
|
+
z.object({
|
|
318
|
+
__kind: z.literal("Swap")
|
|
319
|
+
}).transform(() => ({
|
|
320
|
+
type: "SWAP"
|
|
321
|
+
}))
|
|
322
|
+
]);
|
|
302
323
|
|
|
303
324
|
// ../shared/src/vault/schemas.ts
|
|
304
325
|
var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
@@ -373,7 +394,7 @@ var executeSwapParamsSchema = z.union([
|
|
|
373
394
|
var nativeCallParamsSchema = ethereumBase.extend({
|
|
374
395
|
destAsset: erc20,
|
|
375
396
|
message: z.string(),
|
|
376
|
-
|
|
397
|
+
gasBudget: numericString
|
|
377
398
|
});
|
|
378
399
|
var tokenCallParamsSchema = z.union([
|
|
379
400
|
ethereumBase.extend({
|
|
@@ -383,7 +404,7 @@ var tokenCallParamsSchema = z.union([
|
|
|
383
404
|
z.literal(Assets.ETH)
|
|
384
405
|
]),
|
|
385
406
|
message: hexString,
|
|
386
|
-
|
|
407
|
+
gasBudget: numericString
|
|
387
408
|
}),
|
|
388
409
|
ethereumBase.extend({
|
|
389
410
|
srcAsset: z.literal(Assets.USDC),
|
|
@@ -392,7 +413,7 @@ var tokenCallParamsSchema = z.union([
|
|
|
392
413
|
z.literal(Assets.ETH)
|
|
393
414
|
]),
|
|
394
415
|
message: hexString,
|
|
395
|
-
|
|
416
|
+
gasBudget: numericString
|
|
396
417
|
})
|
|
397
418
|
]);
|
|
398
419
|
var executeCallParamsSchema = z.union([
|
|
@@ -450,7 +471,7 @@ var executeSwap_default = executeSwap;
|
|
|
450
471
|
var callNative = /* @__PURE__ */ __name(async (params, { nonce, ...opts }) => {
|
|
451
472
|
const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
|
|
452
473
|
const vault = Vault__factory.connect(vaultContractAddress, opts.signer);
|
|
453
|
-
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.
|
|
474
|
+
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, [], {
|
|
454
475
|
value: params.amount,
|
|
455
476
|
nonce
|
|
456
477
|
});
|
|
@@ -463,7 +484,7 @@ var callToken = /* @__PURE__ */ __name(async (params, { signer, ...opts }) => {
|
|
|
463
484
|
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, signer);
|
|
464
485
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
465
486
|
const vault = Vault__factory.connect(vaultContractAddress, signer);
|
|
466
|
-
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.
|
|
487
|
+
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, erc20Address, params.amount, [], {
|
|
467
488
|
nonce: opts.nonce
|
|
468
489
|
});
|
|
469
490
|
return transaction.wait(1);
|