@chainflip/sdk 0.1.12 → 0.1.14

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.
@@ -26,10 +26,10 @@ var Assets = arrayToMap([
26
26
  "BTC"
27
27
  ]);
28
28
  var ChainflipNetworks = arrayToMap([
29
+ "partnernet",
29
30
  "sisyphos",
30
31
  "perseverance",
31
- "mainnet",
32
- "partnernet"
32
+ "mainnet"
33
33
  ]);
34
34
  var isTestnet = /* @__PURE__ */ __name((network) => network !== ChainflipNetworks.mainnet, "isTestnet");
35
35
  var assetChains = {
@@ -2125,4 +2125,4 @@ var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
2125
2125
  return balance.toBigInt();
2126
2126
  }, "getFlipBalance");
2127
2127
 
2128
- export { Assets, ChainflipNetworks, Chains, StateChainGateway__factory, Vault__factory, __name, approve, assert, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds, checkAllowance, getFlipBalance, getStateChainGatewayContractAddress, getTokenContractAddress, getVaultManagerContractAddress, isString, isTestnet, isTokenCall, isTokenSwap };
2128
+ export { Assets, ChainflipNetworks, Chains, StateChainGateway__factory, Vault__factory, __name, __publicField, approve, assert, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds, checkAllowance, getFlipBalance, getStateChainGatewayContractAddress, getTokenContractAddress, getVaultManagerContractAddress, isString, isTestnet, isTokenCall, isTokenSwap };
@@ -5,7 +5,7 @@ declare const Chains: ArrayToMap<readonly ["Bitcoin", "Ethereum", "Polkadot"]>;
5
5
  type Chain = (typeof Chains)[keyof typeof Chains];
6
6
  declare const Assets: ArrayToMap<readonly ["FLIP", "USDC", "DOT", "ETH", "BTC"]>;
7
7
  type Asset = (typeof Assets)[keyof typeof Assets];
8
- declare const ChainflipNetworks: ArrayToMap<readonly ["sisyphos", "perseverance", "mainnet", "partnernet"]>;
8
+ declare const ChainflipNetworks: ArrayToMap<readonly ["partnernet", "sisyphos", "perseverance", "mainnet"]>;
9
9
  type ChainflipNetwork = (typeof ChainflipNetworks)[keyof typeof ChainflipNetworks];
10
10
  declare const assetChains: {
11
11
  ETH: "Ethereum";
package/dist/funding.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { a as ChainflipNetwork } from './enums-d5fa72fa.js';
2
+ import { a as ChainflipNetwork } from './enums-3131916c.js';
3
3
 
4
4
  type SDKOptions = {
5
5
  network?: Exclude<ChainflipNetwork, 'mainnet'>;
package/dist/funding.js CHANGED
@@ -777,10 +777,10 @@ var Assets = arrayToMap([
777
777
  "BTC"
778
778
  ]);
779
779
  var ChainflipNetworks = arrayToMap([
780
+ "partnernet",
780
781
  "sisyphos",
781
782
  "perseverance",
782
- "mainnet",
783
- "partnernet"
783
+ "mainnet"
784
784
  ]);
785
785
  ({
786
786
  [Assets.ETH]: Chains.Ethereum,
@@ -945,6 +945,7 @@ var getRedemptionDelay = /* @__PURE__ */ __name((options) => {
945
945
  // src/funding/index.ts
946
946
  var FundingSDK = class {
947
947
  constructor(options) {
948
+ __publicField(this, "options");
948
949
  this.options = {
949
950
  signer: options.signer,
950
951
  network: options.network ?? ChainflipNetworks.perseverance
package/dist/funding.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { __name, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, StateChainGateway__factory } from './chunk-CMPMNSTZ.mjs';
1
+ import { __name, __publicField, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, StateChainGateway__factory } from './chunk-7N46BL6F.mjs';
2
2
 
3
3
  // ../shared/src/stateChainGateway/utils.ts
4
4
  var getStateChainGateway = /* @__PURE__ */ __name((options) => {
@@ -49,6 +49,7 @@ var getRedemptionDelay = /* @__PURE__ */ __name((options) => {
49
49
  // src/funding/index.ts
50
50
  var FundingSDK = class {
51
51
  constructor(options) {
52
+ __publicField(this, "options");
52
53
  this.options = {
53
54
  signer: options.signer,
54
55
  network: options.network ?? ChainflipNetworks.perseverance
package/dist/swap.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import ethers, { Signer } from 'ethers';
2
- import { C as Chain, c as chainAssets, A as Asset, a as ChainflipNetwork } from './enums-d5fa72fa.js';
3
- export { d as Assets, e as ChainflipNetworks, b as Chains, f as assetChains, h as assetContractIds, g as assetDecimals, i as chainContractIds } from './enums-d5fa72fa.js';
2
+ import { C as Chain, c as chainAssets, A as Asset, a as ChainflipNetwork } from './enums-3131916c.js';
3
+ export { d as Assets, e as ChainflipNetworks, b as Chains, f as assetChains, h as assetContractIds, g as assetDecimals, i as chainContractIds } from './enums-3131916c.js';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
@@ -70,7 +70,7 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
70
70
  amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
71
71
  srcChain: z.ZodLiteral<"Ethereum">;
72
72
  destChain: z.ZodLiteral<"Bitcoin">;
73
- destAddress: z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
73
+ 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
74
  destAsset: z.ZodLiteral<"BTC">;
75
75
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
76
76
  }, "strip", z.ZodTypeAny, {
@@ -88,8 +88,124 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
88
88
  destAddress: string;
89
89
  destAsset: "BTC";
90
90
  }>]>;
91
- type TokenSwapParams = z.infer<typeof tokenSwapParamsSchema>;
92
- declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
91
+ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
92
+ amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
93
+ srcChain: z.ZodLiteral<"Ethereum">;
94
+ srcAsset: z.ZodLiteral<"ETH">;
95
+ destChain: z.ZodLiteral<"Ethereum">;
96
+ 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
+ ccmMetadata: z.ZodObject<{
99
+ message: z.ZodString;
100
+ gasBudget: z.ZodString;
101
+ }, "strip", z.ZodTypeAny, {
102
+ message: string;
103
+ gasBudget: string;
104
+ }, {
105
+ message: string;
106
+ gasBudget: string;
107
+ }>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ amount: string | bigint;
110
+ srcChain: "Ethereum";
111
+ srcAsset: "ETH";
112
+ destChain: "Ethereum";
113
+ destAddress: `0x${string}`;
114
+ destAsset: "FLIP" | "USDC";
115
+ ccmMetadata: {
116
+ message: string;
117
+ gasBudget: string;
118
+ };
119
+ }, {
120
+ amount: string | bigint;
121
+ srcChain: "Ethereum";
122
+ srcAsset: "ETH";
123
+ destChain: "Ethereum";
124
+ destAddress: `0x${string}`;
125
+ destAsset: "FLIP" | "USDC";
126
+ ccmMetadata: {
127
+ message: string;
128
+ gasBudget: string;
129
+ };
130
+ }>, z.ZodUnion<[z.ZodObject<{
131
+ amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
132
+ srcChain: z.ZodLiteral<"Ethereum">;
133
+ srcAsset: z.ZodLiteral<"FLIP">;
134
+ destChain: z.ZodLiteral<"Ethereum">;
135
+ 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
+ ccmMetadata: z.ZodObject<{
138
+ message: z.ZodString;
139
+ gasBudget: z.ZodString;
140
+ }, "strip", z.ZodTypeAny, {
141
+ message: string;
142
+ gasBudget: string;
143
+ }, {
144
+ message: string;
145
+ gasBudget: string;
146
+ }>;
147
+ }, "strip", z.ZodTypeAny, {
148
+ amount: string | bigint;
149
+ srcChain: "Ethereum";
150
+ srcAsset: "FLIP";
151
+ destChain: "Ethereum";
152
+ destAddress: `0x${string}`;
153
+ destAsset: "USDC" | "ETH";
154
+ ccmMetadata: {
155
+ message: string;
156
+ gasBudget: string;
157
+ };
158
+ }, {
159
+ amount: string | bigint;
160
+ srcChain: "Ethereum";
161
+ srcAsset: "FLIP";
162
+ destChain: "Ethereum";
163
+ destAddress: `0x${string}`;
164
+ destAsset: "USDC" | "ETH";
165
+ ccmMetadata: {
166
+ message: string;
167
+ gasBudget: string;
168
+ };
169
+ }>, z.ZodObject<{
170
+ amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
171
+ srcChain: z.ZodLiteral<"Ethereum">;
172
+ srcAsset: z.ZodLiteral<"USDC">;
173
+ destChain: z.ZodLiteral<"Ethereum">;
174
+ 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
+ ccmMetadata: z.ZodObject<{
177
+ message: z.ZodString;
178
+ gasBudget: z.ZodString;
179
+ }, "strip", z.ZodTypeAny, {
180
+ message: string;
181
+ gasBudget: string;
182
+ }, {
183
+ message: string;
184
+ gasBudget: string;
185
+ }>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ amount: string | bigint;
188
+ srcChain: "Ethereum";
189
+ srcAsset: "USDC";
190
+ destChain: "Ethereum";
191
+ destAddress: `0x${string}`;
192
+ destAsset: "FLIP" | "ETH";
193
+ ccmMetadata: {
194
+ message: string;
195
+ gasBudget: string;
196
+ };
197
+ }, {
198
+ amount: string | bigint;
199
+ srcChain: "Ethereum";
200
+ srcAsset: "USDC";
201
+ destChain: "Ethereum";
202
+ destAddress: `0x${string}`;
203
+ destAsset: "FLIP" | "ETH";
204
+ ccmMetadata: {
205
+ message: string;
206
+ gasBudget: string;
207
+ };
208
+ }>]>, z.ZodUnion<[z.ZodObject<{
93
209
  amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
94
210
  srcChain: z.ZodLiteral<"Ethereum">;
95
211
  srcAsset: z.ZodLiteral<"ETH">;
@@ -136,7 +252,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
136
252
  srcChain: z.ZodLiteral<"Ethereum">;
137
253
  srcAsset: z.ZodLiteral<"ETH">;
138
254
  destChain: z.ZodLiteral<"Bitcoin">;
139
- destAddress: z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
255
+ 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>;
140
256
  destAsset: z.ZodLiteral<"BTC">;
141
257
  }, "strip", z.ZodTypeAny, {
142
258
  amount: string | bigint;
@@ -219,7 +335,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
219
335
  amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
220
336
  srcChain: z.ZodLiteral<"Ethereum">;
221
337
  destChain: z.ZodLiteral<"Bitcoin">;
222
- destAddress: z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
338
+ 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>;
223
339
  destAsset: z.ZodLiteral<"BTC">;
224
340
  srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
225
341
  }, "strip", z.ZodTypeAny, {
@@ -238,89 +354,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
238
354
  destAsset: "BTC";
239
355
  }>]>]>;
240
356
  type ExecuteSwapParams = z.infer<typeof executeSwapParamsSchema>;
241
- declare const executeCallParamsSchema: z.ZodUnion<[z.ZodObject<{
242
- amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
243
- srcChain: z.ZodLiteral<"Ethereum">;
244
- srcAsset: z.ZodLiteral<"ETH">;
245
- destChain: z.ZodLiteral<"Ethereum">;
246
- destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
247
- destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
248
- message: z.ZodString;
249
- gasBudget: z.ZodString;
250
- }, "strip", z.ZodTypeAny, {
251
- amount: string | bigint;
252
- message: string;
253
- srcChain: "Ethereum";
254
- srcAsset: "ETH";
255
- destChain: "Ethereum";
256
- destAddress: `0x${string}`;
257
- destAsset: "FLIP" | "USDC";
258
- gasBudget: string;
259
- }, {
260
- amount: string | bigint;
261
- message: string;
262
- srcChain: "Ethereum";
263
- srcAsset: "ETH";
264
- destChain: "Ethereum";
265
- destAddress: `0x${string}`;
266
- destAsset: "FLIP" | "USDC";
267
- gasBudget: string;
268
- }>, z.ZodUnion<[z.ZodObject<{
269
- amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
270
- srcChain: z.ZodLiteral<"Ethereum">;
271
- destChain: z.ZodLiteral<"Ethereum">;
272
- destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
273
- srcAsset: z.ZodLiteral<"FLIP">;
274
- destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
275
- message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
276
- gasBudget: z.ZodString;
277
- }, "strip", z.ZodTypeAny, {
278
- amount: string | bigint;
279
- message: `0x${string}`;
280
- srcChain: "Ethereum";
281
- srcAsset: "FLIP";
282
- destChain: "Ethereum";
283
- destAddress: `0x${string}`;
284
- destAsset: "USDC" | "ETH";
285
- gasBudget: string;
286
- }, {
287
- amount: string | bigint;
288
- message: `0x${string}`;
289
- srcChain: "Ethereum";
290
- srcAsset: "FLIP";
291
- destChain: "Ethereum";
292
- destAddress: `0x${string}`;
293
- destAsset: "USDC" | "ETH";
294
- gasBudget: string;
295
- }>, z.ZodObject<{
296
- amount: z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodBigInt]>;
297
- srcChain: z.ZodLiteral<"Ethereum">;
298
- destChain: z.ZodLiteral<"Ethereum">;
299
- destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
300
- srcAsset: z.ZodLiteral<"USDC">;
301
- destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
302
- message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
303
- gasBudget: z.ZodString;
304
- }, "strip", z.ZodTypeAny, {
305
- amount: string | bigint;
306
- message: `0x${string}`;
307
- srcChain: "Ethereum";
308
- srcAsset: "USDC";
309
- destChain: "Ethereum";
310
- destAddress: `0x${string}`;
311
- destAsset: "FLIP" | "ETH";
312
- gasBudget: string;
313
- }, {
314
- amount: string | bigint;
315
- message: `0x${string}`;
316
- srcChain: "Ethereum";
317
- srcAsset: "USDC";
318
- destChain: "Ethereum";
319
- destAddress: `0x${string}`;
320
- destAsset: "FLIP" | "ETH";
321
- gasBudget: string;
322
- }>]>]>;
323
- type ExecuteCallParams = z.infer<typeof executeCallParamsSchema>;
357
+ type TokenSwapParams = z.infer<typeof tokenSwapParamsSchema>;
324
358
  type Overrides = Omit<ethers.providers.TransactionRequest, 'to' | 'data' | 'value' | 'from'>;
325
359
 
326
360
  declare const ccmMetadataSchema: z.ZodObject<{
@@ -515,7 +549,6 @@ declare class SwapSDK {
515
549
  requestDepositAddress(depositAddressRequest: DepositAddressRequest, options?: RequestOptions): Promise<DepositAddressResponse>;
516
550
  getStatus(swapStatusRequest: SwapStatusRequest, options?: RequestOptions): Promise<SwapStatusResponse>;
517
551
  executeSwap(params: ExecuteSwapParams, overrides?: Overrides): Promise<TransactionHash>;
518
- executeCall(params: ExecuteCallParams, overrides?: Overrides): Promise<TransactionHash>;
519
552
  approveVault(params: Pick<TokenSwapParams, 'srcAsset' | 'amount'>, overrides?: Overrides): Promise<TransactionHash | null>;
520
553
  }
521
554
 
package/dist/swap.js CHANGED
@@ -55,10 +55,10 @@ var Assets = arrayToMap([
55
55
  "BTC"
56
56
  ]);
57
57
  var ChainflipNetworks = arrayToMap([
58
+ "partnernet",
58
59
  "sisyphos",
59
60
  "perseverance",
60
- "mainnet",
61
- "partnernet"
61
+ "mainnet"
62
62
  ]);
63
63
  var isTestnet = /* @__PURE__ */ __name((network) => network !== ChainflipNetworks.mainnet, "isTestnet");
64
64
  var assetChains = {
@@ -1449,22 +1449,22 @@ var getTokenContractAddress = /* @__PURE__ */ __name((asset, network) => {
1449
1449
  return GOERLI_USDC_CONTRACT_ADDRESS;
1450
1450
  }, "getTokenContractAddress");
1451
1451
  var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20Address, signer) => {
1452
- const erc202 = ERC20__factory.connect(erc20Address, signer);
1452
+ const erc20 = ERC20__factory.connect(erc20Address, signer);
1453
1453
  const signerAddress = await signer.getAddress();
1454
- const allowance = await erc202.allowance(signerAddress, spenderAddress);
1454
+ const allowance = await erc20.allowance(signerAddress, spenderAddress);
1455
1455
  return {
1456
1456
  allowance,
1457
1457
  isAllowable: allowance.gte(amount),
1458
- erc20: erc202
1458
+ erc20
1459
1459
  };
1460
1460
  }, "checkAllowance");
1461
- var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc202, allowance, nonce) => {
1461
+ var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allowance, nonce) => {
1462
1462
  const amountBigNumber = ethers.BigNumber.from(amount);
1463
1463
  const allowanceBigNumber = ethers.BigNumber.from(allowance);
1464
1464
  if (allowanceBigNumber.gte(amountBigNumber))
1465
1465
  return null;
1466
1466
  const requiredAmount = amountBigNumber.sub(allowanceBigNumber);
1467
- const tx = await erc202.approve(spenderAddress, requiredAmount, {
1467
+ const tx = await erc20.approve(spenderAddress, requiredAmount, {
1468
1468
  nonce
1469
1469
  });
1470
1470
  return tx.wait(1);
@@ -1712,7 +1712,7 @@ var validateBitcoinTestnetAddress = /* @__PURE__ */ __name((address) => validate
1712
1712
  var validateBitcoinRegtestAddress = /* @__PURE__ */ __name((address) => validateBitcoinAddress(address, "regtest"), "validateBitcoinRegtestAddress");
1713
1713
 
1714
1714
  // ../shared/src/parsers.ts
1715
- var errorMap = /* @__PURE__ */ __name((issue, context) => ({
1715
+ var errorMap = /* @__PURE__ */ __name((_issue, context) => ({
1716
1716
  message: `received: ${JSON.stringify(context.data)}`
1717
1717
  }), "errorMap");
1718
1718
  var string = zod.z.string({
@@ -1725,11 +1725,15 @@ var numericString = string.regex(/^[0-9]+$/);
1725
1725
  var hexString = zod.z.custom((val) => typeof val === "string" && /^0x[0-9a-f]+$/i.test(val));
1726
1726
  numericString.transform((arg) => ethers__namespace.BigNumber.from(arg).toHexString()).refine((arg) => arg.startsWith("0x"));
1727
1727
  string.regex(/^[0-9a-f]+$/);
1728
- var btcAddress = zod.z.union([
1729
- string.regex(/^(1|3|bc1)/).refine(validateBitcoinMainnetAddress),
1730
- string.regex(/^(m|n|2|tb1)/).refine(validateBitcoinTestnetAddress),
1731
- string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress)
1732
- ]);
1728
+ var btcAddress = /* @__PURE__ */ __name((env) => {
1729
+ const network = env ?? process.env.CHAINFLIP_NETWORK;
1730
+ if (network === "mainnet")
1731
+ return string.regex(/^(1|3|bc1)/).refine(validateBitcoinMainnetAddress);
1732
+ return zod.z.union([
1733
+ string.regex(/^(m|n|2|tb1)/).refine(validateBitcoinTestnetAddress),
1734
+ string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress)
1735
+ ]);
1736
+ }, "btcAddress");
1733
1737
  var dotAddress = zod.z.union([
1734
1738
  string,
1735
1739
  hexString
@@ -1793,7 +1797,7 @@ var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
1793
1797
  ...arr
1794
1798
  ].map((v) => v.toString(16).padStart(2, "0")).join("")}`, "bytesToHex");
1795
1799
  var utf8ToHex = /* @__PURE__ */ __name((str) => `0x${Buffer.from(str).toString("hex")}`, "utf8ToHex");
1796
- var base = zod.z.object({
1800
+ var eth = zod.z.object({
1797
1801
  amount: zod.z.union([
1798
1802
  numericString,
1799
1803
  hexString,
@@ -1802,91 +1806,86 @@ var base = zod.z.object({
1802
1806
  srcChain: zod.z.literal(Chains.Ethereum),
1803
1807
  srcAsset: zod.z.literal(Assets.ETH)
1804
1808
  });
1805
- var ethereumBase = base.extend({
1809
+ var ethToEthereum = eth.extend({
1806
1810
  destChain: zod.z.literal(Chains.Ethereum),
1807
1811
  destAddress: ethereumAddress
1808
1812
  });
1809
- var polkadotBase = base.extend({
1813
+ var ethToDot = eth.extend({
1810
1814
  destChain: zod.z.literal(Chains.Polkadot),
1811
- destAddress: dotAddress.transform((addr) => bytesToHex(utilCrypto.decodeAddress(addr)))
1815
+ destAddress: dotAddress.transform((addr) => bytesToHex(utilCrypto.decodeAddress(addr))),
1816
+ destAsset: zod.z.literal(Assets.DOT)
1812
1817
  });
1813
- var bitcoinBase = base.extend({
1818
+ var ethToBtc = eth.extend({
1814
1819
  destChain: zod.z.literal(Chains.Bitcoin),
1815
- destAddress: btcAddress.transform(utf8ToHex)
1820
+ destAddress: btcAddress().transform(utf8ToHex),
1821
+ destAsset: zod.z.literal(Assets.BTC)
1816
1822
  });
1817
- var erc20 = zod.z.union([
1823
+ var erc20Asset = zod.z.union([
1818
1824
  zod.z.literal(Assets.FLIP),
1819
1825
  zod.z.literal(Assets.USDC)
1820
1826
  ]);
1821
- var ethereumNative = ethereumBase.extend({
1822
- destAsset: erc20
1823
- });
1824
- var polkadotNative = polkadotBase.extend({
1825
- destAsset: zod.z.literal(Assets.DOT)
1826
- });
1827
- var bitcoinNative = bitcoinBase.extend({
1828
- destAsset: zod.z.literal(Assets.BTC)
1827
+ var ethToERC20 = ethToEthereum.extend({
1828
+ destAsset: erc20Asset
1829
1829
  });
1830
1830
  var nativeSwapParamsSchema = zod.z.union([
1831
- ethereumNative,
1832
- polkadotNative,
1833
- bitcoinNative
1831
+ ethToERC20,
1832
+ ethToDot,
1833
+ ethToBtc
1834
1834
  ]);
1835
+ var flipToEthereumAsset = ethToEthereum.extend({
1836
+ srcAsset: zod.z.literal(Assets.FLIP),
1837
+ destAsset: zod.z.union([
1838
+ zod.z.literal(Assets.USDC),
1839
+ zod.z.literal(Assets.ETH)
1840
+ ])
1841
+ });
1842
+ var usdcToEthereumAsset = ethToEthereum.extend({
1843
+ srcAsset: zod.z.literal(Assets.USDC),
1844
+ destAsset: zod.z.union([
1845
+ zod.z.literal(Assets.FLIP),
1846
+ zod.z.literal(Assets.ETH)
1847
+ ])
1848
+ });
1849
+ var erc20ToDot = ethToDot.extend({
1850
+ srcAsset: erc20Asset
1851
+ });
1852
+ var erc20ToBtc = ethToBtc.extend({
1853
+ srcAsset: erc20Asset
1854
+ });
1835
1855
  var tokenSwapParamsSchema = zod.z.union([
1836
- ethereumBase.extend({
1837
- srcAsset: zod.z.literal(Assets.FLIP),
1838
- destAsset: zod.z.union([
1839
- zod.z.literal(Assets.USDC),
1840
- zod.z.literal(Assets.ETH)
1841
- ])
1842
- }),
1843
- ethereumBase.extend({
1844
- srcAsset: zod.z.literal(Assets.USDC),
1845
- destAsset: zod.z.union([
1846
- zod.z.literal(Assets.FLIP),
1847
- zod.z.literal(Assets.ETH)
1848
- ])
1849
- }),
1850
- polkadotNative.extend({
1851
- srcAsset: erc20
1852
- }),
1853
- bitcoinNative.extend({
1854
- srcAsset: erc20
1855
- })
1856
- ]);
1857
- var executeSwapParamsSchema = zod.z.union([
1858
- nativeSwapParamsSchema,
1859
- tokenSwapParamsSchema
1856
+ flipToEthereumAsset,
1857
+ usdcToEthereumAsset,
1858
+ erc20ToDot,
1859
+ erc20ToBtc
1860
1860
  ]);
1861
- var nativeCallParamsSchema = ethereumBase.extend({
1862
- destAsset: erc20,
1861
+ var ccmMetadataSchema = zod.z.object({
1863
1862
  message: zod.z.string(),
1864
1863
  gasBudget: numericString
1865
1864
  });
1865
+ var ccmFlipToEthereumAssset = flipToEthereumAsset.extend({
1866
+ ccmMetadata: ccmMetadataSchema
1867
+ });
1868
+ var ccmUsdcToEthereumAsset = usdcToEthereumAsset.extend({
1869
+ ccmMetadata: ccmMetadataSchema
1870
+ });
1866
1871
  var tokenCallParamsSchema = zod.z.union([
1867
- ethereumBase.extend({
1868
- srcAsset: zod.z.literal(Assets.FLIP),
1869
- destAsset: zod.z.union([
1870
- zod.z.literal(Assets.USDC),
1871
- zod.z.literal(Assets.ETH)
1872
- ]),
1873
- message: hexString,
1874
- gasBudget: numericString
1875
- }),
1876
- ethereumBase.extend({
1877
- srcAsset: zod.z.literal(Assets.USDC),
1878
- destAsset: zod.z.union([
1879
- zod.z.literal(Assets.FLIP),
1880
- zod.z.literal(Assets.ETH)
1881
- ]),
1882
- message: hexString,
1883
- gasBudget: numericString
1884
- })
1872
+ ccmFlipToEthereumAssset,
1873
+ ccmUsdcToEthereumAsset
1885
1874
  ]);
1886
- var executeCallParamsSchema = zod.z.union([
1875
+ var nativeCallParamsSchema = ethToERC20.extend({
1876
+ ccmMetadata: ccmMetadataSchema
1877
+ });
1878
+ var executeSwapParamsSchema = zod.z.union([
1879
+ // call schemas needs to precede swap schemas
1887
1880
  nativeCallParamsSchema,
1888
- tokenCallParamsSchema
1881
+ tokenCallParamsSchema,
1882
+ nativeSwapParamsSchema,
1883
+ tokenSwapParamsSchema
1889
1884
  ]);
1885
+ var stripOverrides = /* @__PURE__ */ __name((obj) => {
1886
+ const { to, from, value, data, ...rest } = obj;
1887
+ return rest;
1888
+ }, "stripOverrides");
1890
1889
  var executeOptionsSchema = zod.z.intersection(zod.z.object({
1891
1890
  signer: zod.z.instanceof(ethers.Signer)
1892
1891
  }).passthrough(), zod.z.union([
@@ -1898,7 +1897,7 @@ var executeOptionsSchema = zod.z.intersection(zod.z.object({
1898
1897
  vaultContractAddress: zod.z.string(),
1899
1898
  srcTokenContractAddress: zod.z.string().optional()
1900
1899
  }).passthrough()
1901
- ]));
1900
+ ])).transform(stripOverrides);
1902
1901
 
1903
1902
  // ../shared/src/vault/executeSwap.ts
1904
1903
  var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, { network, vaultContractAddress: address, signer, ...opts }) => {
@@ -1920,18 +1919,10 @@ var swapToken = /* @__PURE__ */ __name(async (params, { network, vaultContractAd
1920
1919
  const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, [], opts);
1921
1920
  return transaction.wait(1);
1922
1921
  }, "swapToken");
1923
- var executeSwap = /* @__PURE__ */ __name(async (params, options) => {
1924
- const parsedParams = executeSwapParamsSchema.parse(params);
1925
- const opts = executeOptionsSchema.parse(options);
1926
- return isTokenSwap(parsedParams) ? swapToken(parsedParams, opts) : swapNative(parsedParams, opts);
1927
- }, "executeSwap");
1928
- var executeSwap_default = executeSwap;
1929
-
1930
- // ../shared/src/vault/executeCall.ts
1931
1922
  var callNative = /* @__PURE__ */ __name(async (params, { network, vaultContractAddress: vaultAddress, signer, ...opts }) => {
1932
1923
  const vaultContractAddress = network === "localnet" ? vaultAddress : getVaultManagerContractAddress(network);
1933
1924
  const vault = Vault__factory.connect(vaultContractAddress, signer);
1934
- const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, [], {
1925
+ const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, [], {
1935
1926
  value: params.amount,
1936
1927
  ...opts
1937
1928
  });
@@ -1944,15 +1935,18 @@ var callToken = /* @__PURE__ */ __name(async (params, { signer, network, vaultCo
1944
1935
  const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, signer);
1945
1936
  assert(isAllowable, "Swap amount exceeds allowance");
1946
1937
  const vault = Vault__factory.connect(vaultContractAddress, signer);
1947
- const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, erc20Address, params.amount, [], opts);
1938
+ const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, [], opts);
1948
1939
  return transaction.wait(1);
1949
1940
  }, "callToken");
1950
- var executeCall = /* @__PURE__ */ __name(async (params, options) => {
1951
- const parsedParams = executeCallParamsSchema.parse(params);
1941
+ var executeSwap = /* @__PURE__ */ __name(async (params, options) => {
1942
+ const parsedParams = executeSwapParamsSchema.parse(params);
1952
1943
  const opts = executeOptionsSchema.parse(options);
1953
- return isTokenCall(parsedParams) ? callToken(parsedParams, opts) : callNative(parsedParams, opts);
1954
- }, "executeCall");
1955
- var executeCall_default = executeCall;
1944
+ if ("ccmMetadata" in parsedParams) {
1945
+ return isTokenCall(parsedParams) ? callToken(parsedParams, opts) : callNative(parsedParams, opts);
1946
+ }
1947
+ return isTokenSwap(parsedParams) ? swapToken(parsedParams, opts) : swapNative(parsedParams, opts);
1948
+ }, "executeSwap");
1949
+ var executeSwap_default = executeSwap;
1956
1950
 
1957
1951
  // ../shared/src/vault/approval.ts
1958
1952
  var checkVaultAllowance = /* @__PURE__ */ __name((params, opts) => {
@@ -1962,11 +1956,11 @@ var checkVaultAllowance = /* @__PURE__ */ __name((params, opts) => {
1962
1956
  return checkAllowance(params.amount, vaultContractAddress, erc20Address, opts.signer);
1963
1957
  }, "checkVaultAllowance");
1964
1958
  var approveVault = /* @__PURE__ */ __name(async (params, opts) => {
1965
- const { isAllowable, erc20: erc202, allowance } = await checkVaultAllowance(params, opts);
1959
+ const { isAllowable, erc20, allowance } = await checkVaultAllowance(params, opts);
1966
1960
  if (isAllowable)
1967
1961
  return null;
1968
1962
  const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
1969
- return approve(params.amount, vaultContractAddress, erc202, allowance, opts.nonce);
1963
+ return approve(params.amount, vaultContractAddress, erc20, allowance, opts.nonce);
1970
1964
  }, "approveVault");
1971
1965
 
1972
1966
  // src/swap/consts.ts
@@ -2137,6 +2131,9 @@ var ApiService_default = {
2137
2131
  // src/swap/sdk.ts
2138
2132
  var SwapSDK = class {
2139
2133
  constructor(options = {}) {
2134
+ __publicField(this, "baseUrl");
2135
+ __publicField(this, "network");
2136
+ __publicField(this, "signer");
2140
2137
  this.network = options.network ?? ChainflipNetworks.partnernet;
2141
2138
  this.baseUrl = options.backendUrl ?? BACKEND_SERVICE_URLS[this.network];
2142
2139
  this.signer = options.signer;
@@ -2168,15 +2165,6 @@ var SwapSDK = class {
2168
2165
  });
2169
2166
  return receipt.transactionHash;
2170
2167
  }
2171
- async executeCall(params, overrides = {}) {
2172
- assert(this.signer, "No signer provided");
2173
- const receipt = await executeCall_default(params, {
2174
- ...overrides,
2175
- network: this.network,
2176
- signer: this.signer
2177
- });
2178
- return receipt.transactionHash;
2179
- }
2180
2168
  async approveVault(params, overrides = {}) {
2181
2169
  if (!("srcAsset" in params))
2182
2170
  return null;
package/dist/swap.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { isString, Chains, Assets, ChainflipNetworks, __name, assert, getVaultManagerContractAddress, approve, isTokenSwap, isTokenCall, getTokenContractAddress, checkAllowance, Vault__factory, chainContractIds, assetContractIds, assetDecimals, isTestnet } from './chunk-CMPMNSTZ.mjs';
2
- export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-CMPMNSTZ.mjs';
1
+ import { isString, Chains, Assets, ChainflipNetworks, __name, __publicField, assert, getVaultManagerContractAddress, approve, isTokenCall, isTokenSwap, getTokenContractAddress, checkAllowance, Vault__factory, chainContractIds, assetContractIds, assetDecimals, isTestnet } from './chunk-7N46BL6F.mjs';
2
+ export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-7N46BL6F.mjs';
3
3
  import { encodeAddress, decodeAddress } from '@polkadot/util-crypto';
4
4
  import * as ethers from 'ethers';
5
5
  import { Signer } from 'ethers';
@@ -245,7 +245,7 @@ var validateBitcoinTestnetAddress = /* @__PURE__ */ __name((address) => validate
245
245
  var validateBitcoinRegtestAddress = /* @__PURE__ */ __name((address) => validateBitcoinAddress(address, "regtest"), "validateBitcoinRegtestAddress");
246
246
 
247
247
  // ../shared/src/parsers.ts
248
- var errorMap = /* @__PURE__ */ __name((issue, context) => ({
248
+ var errorMap = /* @__PURE__ */ __name((_issue, context) => ({
249
249
  message: `received: ${JSON.stringify(context.data)}`
250
250
  }), "errorMap");
251
251
  var string = z.string({
@@ -258,11 +258,15 @@ var numericString = string.regex(/^[0-9]+$/);
258
258
  var hexString = z.custom((val) => typeof val === "string" && /^0x[0-9a-f]+$/i.test(val));
259
259
  numericString.transform((arg) => ethers.BigNumber.from(arg).toHexString()).refine((arg) => arg.startsWith("0x"));
260
260
  string.regex(/^[0-9a-f]+$/);
261
- var btcAddress = z.union([
262
- string.regex(/^(1|3|bc1)/).refine(validateBitcoinMainnetAddress),
263
- string.regex(/^(m|n|2|tb1)/).refine(validateBitcoinTestnetAddress),
264
- string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress)
265
- ]);
261
+ var btcAddress = /* @__PURE__ */ __name((env) => {
262
+ const network = env ?? process.env.CHAINFLIP_NETWORK;
263
+ if (network === "mainnet")
264
+ return string.regex(/^(1|3|bc1)/).refine(validateBitcoinMainnetAddress);
265
+ return z.union([
266
+ string.regex(/^(m|n|2|tb1)/).refine(validateBitcoinTestnetAddress),
267
+ string.regex(/^bcrt1/).refine(validateBitcoinRegtestAddress)
268
+ ]);
269
+ }, "btcAddress");
266
270
  var dotAddress = z.union([
267
271
  string,
268
272
  hexString
@@ -326,7 +330,7 @@ var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
326
330
  ...arr
327
331
  ].map((v) => v.toString(16).padStart(2, "0")).join("")}`, "bytesToHex");
328
332
  var utf8ToHex = /* @__PURE__ */ __name((str) => `0x${Buffer.from(str).toString("hex")}`, "utf8ToHex");
329
- var base = z.object({
333
+ var eth = z.object({
330
334
  amount: z.union([
331
335
  numericString,
332
336
  hexString,
@@ -335,91 +339,86 @@ var base = z.object({
335
339
  srcChain: z.literal(Chains.Ethereum),
336
340
  srcAsset: z.literal(Assets.ETH)
337
341
  });
338
- var ethereumBase = base.extend({
342
+ var ethToEthereum = eth.extend({
339
343
  destChain: z.literal(Chains.Ethereum),
340
344
  destAddress: ethereumAddress
341
345
  });
342
- var polkadotBase = base.extend({
346
+ var ethToDot = eth.extend({
343
347
  destChain: z.literal(Chains.Polkadot),
344
- destAddress: dotAddress.transform((addr) => bytesToHex(decodeAddress(addr)))
348
+ destAddress: dotAddress.transform((addr) => bytesToHex(decodeAddress(addr))),
349
+ destAsset: z.literal(Assets.DOT)
345
350
  });
346
- var bitcoinBase = base.extend({
351
+ var ethToBtc = eth.extend({
347
352
  destChain: z.literal(Chains.Bitcoin),
348
- destAddress: btcAddress.transform(utf8ToHex)
353
+ destAddress: btcAddress().transform(utf8ToHex),
354
+ destAsset: z.literal(Assets.BTC)
349
355
  });
350
- var erc20 = z.union([
356
+ var erc20Asset = z.union([
351
357
  z.literal(Assets.FLIP),
352
358
  z.literal(Assets.USDC)
353
359
  ]);
354
- var ethereumNative = ethereumBase.extend({
355
- destAsset: erc20
356
- });
357
- var polkadotNative = polkadotBase.extend({
358
- destAsset: z.literal(Assets.DOT)
359
- });
360
- var bitcoinNative = bitcoinBase.extend({
361
- destAsset: z.literal(Assets.BTC)
360
+ var ethToERC20 = ethToEthereum.extend({
361
+ destAsset: erc20Asset
362
362
  });
363
363
  var nativeSwapParamsSchema = z.union([
364
- ethereumNative,
365
- polkadotNative,
366
- bitcoinNative
364
+ ethToERC20,
365
+ ethToDot,
366
+ ethToBtc
367
367
  ]);
368
+ var flipToEthereumAsset = ethToEthereum.extend({
369
+ srcAsset: z.literal(Assets.FLIP),
370
+ destAsset: z.union([
371
+ z.literal(Assets.USDC),
372
+ z.literal(Assets.ETH)
373
+ ])
374
+ });
375
+ var usdcToEthereumAsset = ethToEthereum.extend({
376
+ srcAsset: z.literal(Assets.USDC),
377
+ destAsset: z.union([
378
+ z.literal(Assets.FLIP),
379
+ z.literal(Assets.ETH)
380
+ ])
381
+ });
382
+ var erc20ToDot = ethToDot.extend({
383
+ srcAsset: erc20Asset
384
+ });
385
+ var erc20ToBtc = ethToBtc.extend({
386
+ srcAsset: erc20Asset
387
+ });
368
388
  var tokenSwapParamsSchema = z.union([
369
- ethereumBase.extend({
370
- srcAsset: z.literal(Assets.FLIP),
371
- destAsset: z.union([
372
- z.literal(Assets.USDC),
373
- z.literal(Assets.ETH)
374
- ])
375
- }),
376
- ethereumBase.extend({
377
- srcAsset: z.literal(Assets.USDC),
378
- destAsset: z.union([
379
- z.literal(Assets.FLIP),
380
- z.literal(Assets.ETH)
381
- ])
382
- }),
383
- polkadotNative.extend({
384
- srcAsset: erc20
385
- }),
386
- bitcoinNative.extend({
387
- srcAsset: erc20
388
- })
389
- ]);
390
- var executeSwapParamsSchema = z.union([
391
- nativeSwapParamsSchema,
392
- tokenSwapParamsSchema
389
+ flipToEthereumAsset,
390
+ usdcToEthereumAsset,
391
+ erc20ToDot,
392
+ erc20ToBtc
393
393
  ]);
394
- var nativeCallParamsSchema = ethereumBase.extend({
395
- destAsset: erc20,
394
+ var ccmMetadataSchema = z.object({
396
395
  message: z.string(),
397
396
  gasBudget: numericString
398
397
  });
398
+ var ccmFlipToEthereumAssset = flipToEthereumAsset.extend({
399
+ ccmMetadata: ccmMetadataSchema
400
+ });
401
+ var ccmUsdcToEthereumAsset = usdcToEthereumAsset.extend({
402
+ ccmMetadata: ccmMetadataSchema
403
+ });
399
404
  var tokenCallParamsSchema = z.union([
400
- ethereumBase.extend({
401
- srcAsset: z.literal(Assets.FLIP),
402
- destAsset: z.union([
403
- z.literal(Assets.USDC),
404
- z.literal(Assets.ETH)
405
- ]),
406
- message: hexString,
407
- gasBudget: numericString
408
- }),
409
- ethereumBase.extend({
410
- srcAsset: z.literal(Assets.USDC),
411
- destAsset: z.union([
412
- z.literal(Assets.FLIP),
413
- z.literal(Assets.ETH)
414
- ]),
415
- message: hexString,
416
- gasBudget: numericString
417
- })
405
+ ccmFlipToEthereumAssset,
406
+ ccmUsdcToEthereumAsset
418
407
  ]);
419
- var executeCallParamsSchema = z.union([
408
+ var nativeCallParamsSchema = ethToERC20.extend({
409
+ ccmMetadata: ccmMetadataSchema
410
+ });
411
+ var executeSwapParamsSchema = z.union([
412
+ // call schemas needs to precede swap schemas
420
413
  nativeCallParamsSchema,
421
- tokenCallParamsSchema
414
+ tokenCallParamsSchema,
415
+ nativeSwapParamsSchema,
416
+ tokenSwapParamsSchema
422
417
  ]);
418
+ var stripOverrides = /* @__PURE__ */ __name((obj) => {
419
+ const { to, from, value, data, ...rest } = obj;
420
+ return rest;
421
+ }, "stripOverrides");
423
422
  var executeOptionsSchema = z.intersection(z.object({
424
423
  signer: z.instanceof(Signer)
425
424
  }).passthrough(), z.union([
@@ -431,7 +430,7 @@ var executeOptionsSchema = z.intersection(z.object({
431
430
  vaultContractAddress: z.string(),
432
431
  srcTokenContractAddress: z.string().optional()
433
432
  }).passthrough()
434
- ]));
433
+ ])).transform(stripOverrides);
435
434
 
436
435
  // ../shared/src/vault/executeSwap.ts
437
436
  var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, { network, vaultContractAddress: address, signer, ...opts }) => {
@@ -453,18 +452,10 @@ var swapToken = /* @__PURE__ */ __name(async (params, { network, vaultContractAd
453
452
  const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, [], opts);
454
453
  return transaction.wait(1);
455
454
  }, "swapToken");
456
- var executeSwap = /* @__PURE__ */ __name(async (params, options) => {
457
- const parsedParams = executeSwapParamsSchema.parse(params);
458
- const opts = executeOptionsSchema.parse(options);
459
- return isTokenSwap(parsedParams) ? swapToken(parsedParams, opts) : swapNative(parsedParams, opts);
460
- }, "executeSwap");
461
- var executeSwap_default = executeSwap;
462
-
463
- // ../shared/src/vault/executeCall.ts
464
455
  var callNative = /* @__PURE__ */ __name(async (params, { network, vaultContractAddress: vaultAddress, signer, ...opts }) => {
465
456
  const vaultContractAddress = network === "localnet" ? vaultAddress : getVaultManagerContractAddress(network);
466
457
  const vault = Vault__factory.connect(vaultContractAddress, signer);
467
- const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, [], {
458
+ const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, [], {
468
459
  value: params.amount,
469
460
  ...opts
470
461
  });
@@ -477,15 +468,18 @@ var callToken = /* @__PURE__ */ __name(async (params, { signer, network, vaultCo
477
468
  const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, signer);
478
469
  assert(isAllowable, "Swap amount exceeds allowance");
479
470
  const vault = Vault__factory.connect(vaultContractAddress, signer);
480
- const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.message, params.gasBudget, erc20Address, params.amount, [], opts);
471
+ const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, [], opts);
481
472
  return transaction.wait(1);
482
473
  }, "callToken");
483
- var executeCall = /* @__PURE__ */ __name(async (params, options) => {
484
- const parsedParams = executeCallParamsSchema.parse(params);
474
+ var executeSwap = /* @__PURE__ */ __name(async (params, options) => {
475
+ const parsedParams = executeSwapParamsSchema.parse(params);
485
476
  const opts = executeOptionsSchema.parse(options);
486
- return isTokenCall(parsedParams) ? callToken(parsedParams, opts) : callNative(parsedParams, opts);
487
- }, "executeCall");
488
- var executeCall_default = executeCall;
477
+ if ("ccmMetadata" in parsedParams) {
478
+ return isTokenCall(parsedParams) ? callToken(parsedParams, opts) : callNative(parsedParams, opts);
479
+ }
480
+ return isTokenSwap(parsedParams) ? swapToken(parsedParams, opts) : swapNative(parsedParams, opts);
481
+ }, "executeSwap");
482
+ var executeSwap_default = executeSwap;
489
483
 
490
484
  // ../shared/src/vault/approval.ts
491
485
  var checkVaultAllowance = /* @__PURE__ */ __name((params, opts) => {
@@ -495,11 +489,11 @@ var checkVaultAllowance = /* @__PURE__ */ __name((params, opts) => {
495
489
  return checkAllowance(params.amount, vaultContractAddress, erc20Address, opts.signer);
496
490
  }, "checkVaultAllowance");
497
491
  var approveVault = /* @__PURE__ */ __name(async (params, opts) => {
498
- const { isAllowable, erc20: erc202, allowance } = await checkVaultAllowance(params, opts);
492
+ const { isAllowable, erc20, allowance } = await checkVaultAllowance(params, opts);
499
493
  if (isAllowable)
500
494
  return null;
501
495
  const vaultContractAddress = opts.network === "localnet" ? opts.vaultContractAddress : getVaultManagerContractAddress(opts.network);
502
- return approve(params.amount, vaultContractAddress, erc202, allowance, opts.nonce);
496
+ return approve(params.amount, vaultContractAddress, erc20, allowance, opts.nonce);
503
497
  }, "approveVault");
504
498
 
505
499
  // src/swap/consts.ts
@@ -670,6 +664,9 @@ var ApiService_default = {
670
664
  // src/swap/sdk.ts
671
665
  var SwapSDK = class {
672
666
  constructor(options = {}) {
667
+ __publicField(this, "baseUrl");
668
+ __publicField(this, "network");
669
+ __publicField(this, "signer");
673
670
  this.network = options.network ?? ChainflipNetworks.partnernet;
674
671
  this.baseUrl = options.backendUrl ?? BACKEND_SERVICE_URLS[this.network];
675
672
  this.signer = options.signer;
@@ -701,15 +698,6 @@ var SwapSDK = class {
701
698
  });
702
699
  return receipt.transactionHash;
703
700
  }
704
- async executeCall(params, overrides = {}) {
705
- assert(this.signer, "No signer provided");
706
- const receipt = await executeCall_default(params, {
707
- ...overrides,
708
- network: this.network,
709
- signer: this.signer
710
- });
711
- return receipt.transactionHash;
712
- }
713
701
  async approveVault(params, overrides = {}) {
714
702
  if (!("srcAsset" in params))
715
703
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {