@chainflip/sdk 1.2.1 → 1.2.2-alpha.1

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.
@@ -1,5 +1,5 @@
1
- import { ccmMetadataSchema } from './chunk-KLVDY4K6.mjs';
2
- import { z, __name, Chains, assetAndChain, numericString, hexString, btcAddress, hexStringFromNumber, dotAddress, unsignedInteger } from './chunk-3LCS6BBP.mjs';
1
+ import { ccmMetadataSchema } from './chunk-MEARHD4S.mjs';
2
+ import { z, __name, Chains, assetAndChain, numericString, hexString, btcAddress, hexStringFromNumber, dotAddress, unsignedInteger } from './chunk-D22I3FZH.mjs';
3
3
  import { u8aToHex } from '@polkadot/util';
4
4
  import { decodeAddress } from '@polkadot/util-crypto';
5
5
  import axios from 'axios';
@@ -527,21 +527,24 @@ var chainConstants = {
527
527
  Assets.USDC
528
528
  ],
529
529
  gasAsset: Assets.ETH,
530
- contractId: 1
530
+ contractId: 1,
531
+ blockTimeSeconds: 12
531
532
  },
532
533
  [Chains.Polkadot]: {
533
534
  assets: [
534
535
  Assets.DOT
535
536
  ],
536
537
  gasAsset: Assets.DOT,
537
- contractId: 2
538
+ contractId: 2,
539
+ blockTimeSeconds: 6
538
540
  },
539
541
  [Chains.Bitcoin]: {
540
542
  assets: [
541
543
  Assets.BTC
542
544
  ],
543
545
  gasAsset: Assets.BTC,
544
- contractId: 3
546
+ contractId: 3,
547
+ blockTimeSeconds: 10 * 60
545
548
  }
546
549
  };
547
550
  function isValidAssetAndChain(assetAndChain2) {
@@ -4412,6 +4415,7 @@ var z = /* @__PURE__ */ Object.freeze({
4412
4415
 
4413
4416
  // ../shared/src/guards.ts
4414
4417
  var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
4418
+ var isNotNullish = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isNotNullish");
4415
4419
  function assert(condition, message) {
4416
4420
  if (condition)
4417
4421
  return;
@@ -4564,4 +4568,4 @@ z.union([
4564
4568
  }))
4565
4569
  ]);
4566
4570
 
4567
- export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, asset, assetAndChain, assetConstants, btcAddress, chain, chainConstants, dotAddress, ethereumAddress, getInternalAsset, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isTestnet, isTokenCall, isTokenSwap, numericString, readChainAssetValue, unsignedInteger, z };
4571
+ export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, asset, assetAndChain, assetConstants, btcAddress, chain, chainConstants, dotAddress, ethereumAddress, getInternalAsset, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isNotNullish, isTestnet, isTokenCall, isTokenSwap, numericString, readChainAssetValue, unsignedInteger, z };
@@ -1,4 +1,4 @@
1
- import { z, chain, asset, numericString, hexStringWithMaxByteSize } from './chunk-3LCS6BBP.mjs';
1
+ import { z, chain, asset, numericString, hexStringWithMaxByteSize } from './chunk-D22I3FZH.mjs';
2
2
 
3
3
  // ../shared/src/schemas.ts
4
4
  z.object({
@@ -1,4 +1,4 @@
1
- import { z, ChainflipNetworks, hexString, __name, __publicField, InternalAssets } from './chunk-3LCS6BBP.mjs';
1
+ import { z, ChainflipNetworks, hexString, __name, __publicField, InternalAssets } from './chunk-D22I3FZH.mjs';
2
2
  import axios from 'axios';
3
3
  import { Interface, Contract } from 'ethers';
4
4
 
@@ -57,6 +57,12 @@ var chainAssetMap = /* @__PURE__ */ __name((parser) => z.object({
57
57
  }), "chainAssetMap");
58
58
  var chainAssetNumberMap = chainAssetMap(numberOrHex);
59
59
  var chainAssetNumberNullableMap = chainAssetMap(numberOrHex.nullable());
60
+ var chainMap = /* @__PURE__ */ __name((parser) => z.object({
61
+ Bitcoin: parser,
62
+ Ethereum: parser,
63
+ Polkadot: parser
64
+ }), "chainMap");
65
+ var chainNumberNullableMap = chainMap(numberOrHex.nullable());
60
66
  var swappingEnvironment = z.object({
61
67
  maximum_swap_amounts: chainAssetNumberNullableMap
62
68
  });
@@ -69,6 +75,7 @@ var ingressEgressEnvironment = z.object({
69
75
  minimum_deposit_amounts: chainAssetNumberMap,
70
76
  ingress_fees: chainAssetNumberMap,
71
77
  egress_fees: chainAssetNumberMap,
78
+ witness_safety_margins: chainNumberNullableMap,
72
79
  // TODO(1.2): remove optional and default value
73
80
  egress_dust_limits: chainAssetNumberMap.optional().default({
74
81
  Bitcoin: {
@@ -14,16 +14,19 @@ declare const chainConstants: {
14
14
  readonly assets: ["ETH", "FLIP", "USDC"];
15
15
  readonly gasAsset: "ETH";
16
16
  readonly contractId: 1;
17
+ readonly blockTimeSeconds: 12;
17
18
  };
18
19
  readonly Polkadot: {
19
20
  readonly assets: ["DOT"];
20
21
  readonly gasAsset: "DOT";
21
22
  readonly contractId: 2;
23
+ readonly blockTimeSeconds: 6;
22
24
  };
23
25
  readonly Bitcoin: {
24
26
  readonly assets: ["BTC"];
25
27
  readonly gasAsset: "BTC";
26
28
  readonly contractId: 3;
29
+ readonly blockTimeSeconds: number;
27
30
  };
28
31
  };
29
32
  type AssetOfChain<C extends Chain> = (typeof chainConstants)[C]['assets'][number];
@@ -36,6 +39,9 @@ type ChainAssetMap<T> = {
36
39
  [A in AssetOfChain<C>]: T;
37
40
  };
38
41
  };
42
+ type ChainMap<T> = {
43
+ [C in Chain]: T;
44
+ };
39
45
  declare function getInternalAsset(asset: UncheckedAssetAndChain): InternalAsset;
40
46
 
41
47
  type TransactionOptions = {
@@ -47,4 +53,4 @@ type TransactionOptions = {
47
53
  wait?: number;
48
54
  };
49
55
 
50
- export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, Chains as d, Assets as e, InternalAssets as f, ChainflipNetworks as g, getInternalAsset as h };
56
+ export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, type ChainMap as d, Chains as e, Assets as f, InternalAssets as g, ChainflipNetworks as h, getInternalAsset as i };
@@ -14,16 +14,19 @@ declare const chainConstants: {
14
14
  readonly assets: ["ETH", "FLIP", "USDC"];
15
15
  readonly gasAsset: "ETH";
16
16
  readonly contractId: 1;
17
+ readonly blockTimeSeconds: 12;
17
18
  };
18
19
  readonly Polkadot: {
19
20
  readonly assets: ["DOT"];
20
21
  readonly gasAsset: "DOT";
21
22
  readonly contractId: 2;
23
+ readonly blockTimeSeconds: 6;
22
24
  };
23
25
  readonly Bitcoin: {
24
26
  readonly assets: ["BTC"];
25
27
  readonly gasAsset: "BTC";
26
28
  readonly contractId: 3;
29
+ readonly blockTimeSeconds: number;
27
30
  };
28
31
  };
29
32
  type AssetOfChain<C extends Chain> = (typeof chainConstants)[C]['assets'][number];
@@ -36,6 +39,9 @@ type ChainAssetMap<T> = {
36
39
  [A in AssetOfChain<C>]: T;
37
40
  };
38
41
  };
42
+ type ChainMap<T> = {
43
+ [C in Chain]: T;
44
+ };
39
45
  declare function getInternalAsset(asset: UncheckedAssetAndChain): InternalAsset;
40
46
 
41
47
  type TransactionOptions = {
@@ -47,4 +53,4 @@ type TransactionOptions = {
47
53
  wait?: number;
48
54
  };
49
55
 
50
- export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, Chains as d, Assets as e, InternalAssets as f, ChainflipNetworks as g, getInternalAsset as h };
56
+ export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, type ChainMap as d, Chains as e, Assets as f, InternalAssets as g, ChainflipNetworks as h, getInternalAsset as i };
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { C as ChainflipNetwork, T as TransactionOptions } from './contracts-JL66gtg_.mjs';
2
+ import { C as ChainflipNetwork, T as TransactionOptions } from './contracts-NCUAyhz5.mjs';
3
3
 
4
4
  type PendingRedemption = {
5
5
  amount: bigint;
package/dist/funding.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { C as ChainflipNetwork, T as TransactionOptions } from './contracts-JL66gtg_.js';
2
+ import { C as ChainflipNetwork, T as TransactionOptions } from './contracts-NCUAyhz5.js';
3
3
 
4
4
  type PendingRedemption = {
5
5
  amount: bigint;
package/dist/funding.js CHANGED
@@ -1303,21 +1303,24 @@ var chainConstants = {
1303
1303
  Assets.USDC
1304
1304
  ],
1305
1305
  gasAsset: Assets.ETH,
1306
- contractId: 1
1306
+ contractId: 1,
1307
+ blockTimeSeconds: 12
1307
1308
  },
1308
1309
  [Chains.Polkadot]: {
1309
1310
  assets: [
1310
1311
  Assets.DOT
1311
1312
  ],
1312
1313
  gasAsset: Assets.DOT,
1313
- contractId: 2
1314
+ contractId: 2,
1315
+ blockTimeSeconds: 6
1314
1316
  },
1315
1317
  [Chains.Bitcoin]: {
1316
1318
  assets: [
1317
1319
  Assets.BTC
1318
1320
  ],
1319
1321
  gasAsset: Assets.BTC,
1320
- contractId: 3
1322
+ contractId: 3,
1323
+ blockTimeSeconds: 10 * 60
1321
1324
  }
1322
1325
  };
1323
1326
  function isValidAssetAndChain(assetAndChain2) {
@@ -5379,6 +5382,12 @@ var chainAssetMap = /* @__PURE__ */ __name((parser) => z.object({
5379
5382
  }), "chainAssetMap");
5380
5383
  var chainAssetNumberMap = chainAssetMap(numberOrHex);
5381
5384
  var chainAssetNumberNullableMap = chainAssetMap(numberOrHex.nullable());
5385
+ var chainMap = /* @__PURE__ */ __name((parser) => z.object({
5386
+ Bitcoin: parser,
5387
+ Ethereum: parser,
5388
+ Polkadot: parser
5389
+ }), "chainMap");
5390
+ var chainNumberNullableMap = chainMap(numberOrHex.nullable());
5382
5391
  var swappingEnvironment = z.object({
5383
5392
  maximum_swap_amounts: chainAssetNumberNullableMap
5384
5393
  });
@@ -5391,6 +5400,7 @@ var ingressEgressEnvironment = z.object({
5391
5400
  minimum_deposit_amounts: chainAssetNumberMap,
5392
5401
  ingress_fees: chainAssetNumberMap,
5393
5402
  egress_fees: chainAssetNumberMap,
5403
+ witness_safety_margins: chainNumberNullableMap,
5394
5404
  // TODO(1.2): remove optional and default value
5395
5405
  egress_dust_limits: chainAssetNumberMap.optional().default({
5396
5406
  Bitcoin: {
package/dist/funding.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-2GNHNTY7.mjs';
2
- import { __name, __publicField, ChainflipNetworks, InternalAssets, assert } from './chunk-3LCS6BBP.mjs';
1
+ import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-X5KSXKLT.mjs';
2
+ import { __name, __publicField, ChainflipNetworks, InternalAssets, assert } from './chunk-D22I3FZH.mjs';
3
3
 
4
4
  // ../shared/src/stateChainGateway/utils.ts
5
5
  var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
package/dist/swap.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Signer } from 'ethers';
2
- import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap } from './contracts-JL66gtg_.mjs';
3
- export { e as Assets, f as ChainflipIds, g as ChainflipNetworks, d as Chains, h as getChainflipId } from './contracts-JL66gtg_.mjs';
2
+ import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap, d as ChainMap } from './contracts-NCUAyhz5.mjs';
3
+ export { f as Assets, g as ChainflipIds, h as ChainflipNetworks, e as Chains, i as getChainflipId } from './contracts-NCUAyhz5.mjs';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const tokenSwapParamsSchema: (network: ChainflipNetwork) => z.ZodUnion<[z.ZodObject<{
@@ -378,12 +378,14 @@ type QuoteQueryResponse = {
378
378
  egressAmount: string;
379
379
  includedFees: SwapFee[];
380
380
  lowLiquidityWarning: boolean | undefined;
381
+ estimatedDurationSeconds: number;
381
382
  };
382
383
 
383
384
  interface ChainData {
384
385
  chain: Chain;
385
386
  name: string;
386
387
  isMainnet: boolean;
388
+ requiredBlockConfirmations: number | undefined;
387
389
  }
388
390
  type AssetData = {
389
391
  [C in Chain]: {
@@ -615,6 +617,7 @@ declare class SwapSDK {
615
617
  minimumSwapAmounts: ChainAssetMap<bigint>;
616
618
  maximumSwapAmounts: ChainAssetMap<bigint | null>;
617
619
  }>;
620
+ getRequiredBlockConfirmations(): Promise<ChainMap<number | undefined>>;
618
621
  }
619
622
 
620
623
  export { Asset, type AssetData, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
package/dist/swap.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Signer } from 'ethers';
2
- import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap } from './contracts-JL66gtg_.js';
3
- export { e as Assets, f as ChainflipIds, g as ChainflipNetworks, d as Chains, h as getChainflipId } from './contracts-JL66gtg_.js';
2
+ import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap, d as ChainMap } from './contracts-NCUAyhz5.js';
3
+ export { f as Assets, g as ChainflipIds, h as ChainflipNetworks, e as Chains, i as getChainflipId } from './contracts-NCUAyhz5.js';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const tokenSwapParamsSchema: (network: ChainflipNetwork) => z.ZodUnion<[z.ZodObject<{
@@ -378,12 +378,14 @@ type QuoteQueryResponse = {
378
378
  egressAmount: string;
379
379
  includedFees: SwapFee[];
380
380
  lowLiquidityWarning: boolean | undefined;
381
+ estimatedDurationSeconds: number;
381
382
  };
382
383
 
383
384
  interface ChainData {
384
385
  chain: Chain;
385
386
  name: string;
386
387
  isMainnet: boolean;
388
+ requiredBlockConfirmations: number | undefined;
387
389
  }
388
390
  type AssetData = {
389
391
  [C in Chain]: {
@@ -615,6 +617,7 @@ declare class SwapSDK {
615
617
  minimumSwapAmounts: ChainAssetMap<bigint>;
616
618
  maximumSwapAmounts: ChainAssetMap<bigint | null>;
617
619
  }>;
620
+ getRequiredBlockConfirmations(): Promise<ChainMap<number | undefined>>;
618
621
  }
619
622
 
620
623
  export { Asset, type AssetData, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
package/dist/swap.js CHANGED
@@ -174,21 +174,24 @@ var init_enums = __esm({
174
174
  exports.Assets.USDC
175
175
  ],
176
176
  gasAsset: exports.Assets.ETH,
177
- contractId: 1
177
+ contractId: 1,
178
+ blockTimeSeconds: 12
178
179
  },
179
180
  [exports.Chains.Polkadot]: {
180
181
  assets: [
181
182
  exports.Assets.DOT
182
183
  ],
183
184
  gasAsset: exports.Assets.DOT,
184
- contractId: 2
185
+ contractId: 2,
186
+ blockTimeSeconds: 6
185
187
  },
186
188
  [exports.Chains.Bitcoin]: {
187
189
  assets: [
188
190
  exports.Assets.BTC
189
191
  ],
190
192
  gasAsset: exports.Assets.BTC,
191
- contractId: 3
193
+ contractId: 3,
194
+ blockTimeSeconds: 10 * 60
192
195
  }
193
196
  };
194
197
  __name(isValidAssetAndChain, "isValidAssetAndChain");
@@ -212,11 +215,12 @@ function assert(condition, message) {
212
215
  }
213
216
  throw error;
214
217
  }
215
- var isString2, isTokenSwap, isTokenCall;
218
+ var isString2, isNotNullish, isTokenSwap, isTokenCall;
216
219
  var init_guards = __esm({
217
220
  "../shared/src/guards.ts"() {
218
221
  init_enums();
219
222
  isString2 = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
223
+ isNotNullish = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isNotNullish");
220
224
  __name(assert, "assert");
221
225
  isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== exports.Assets.ETH, "isTokenSwap");
222
226
  isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== exports.Assets.ETH, "isTokenCall");
@@ -7047,6 +7051,12 @@ var chainAssetMap = /* @__PURE__ */ __name((parser) => z.object({
7047
7051
  }), "chainAssetMap");
7048
7052
  var chainAssetNumberMap = chainAssetMap(numberOrHex);
7049
7053
  var chainAssetNumberNullableMap = chainAssetMap(numberOrHex.nullable());
7054
+ var chainMap = /* @__PURE__ */ __name((parser) => z.object({
7055
+ Bitcoin: parser,
7056
+ Ethereum: parser,
7057
+ Polkadot: parser
7058
+ }), "chainMap");
7059
+ var chainNumberNullableMap = chainMap(numberOrHex.nullable());
7050
7060
  var swappingEnvironment = z.object({
7051
7061
  maximum_swap_amounts: chainAssetNumberNullableMap
7052
7062
  });
@@ -7059,6 +7069,7 @@ var ingressEgressEnvironment = z.object({
7059
7069
  minimum_deposit_amounts: chainAssetNumberMap,
7060
7070
  ingress_fees: chainAssetNumberMap,
7061
7071
  egress_fees: chainAssetNumberMap,
7072
+ witness_safety_margins: chainNumberNullableMap,
7062
7073
  // TODO(1.2): remove optional and default value
7063
7074
  egress_dust_limits: chainAssetNumberMap.optional().default({
7064
7075
  Bitcoin: {
@@ -8759,44 +8770,39 @@ var btc$ = assetFactory("Btc");
8759
8770
 
8760
8771
  // src/swap/chains.ts
8761
8772
  init_enums();
8762
- var ethereum = /* @__PURE__ */ __name((network) => ({
8763
- chain: exports.Chains.Ethereum,
8764
- name: "Ethereum",
8765
- isMainnet: !isTestnet(network)
8766
- }), "ethereum");
8767
- var polkadot = /* @__PURE__ */ __name((network) => ({
8768
- chain: exports.Chains.Polkadot,
8769
- name: "Polkadot",
8770
- isMainnet: !isTestnet(network)
8771
- }), "polkadot");
8772
- var bitcoin = /* @__PURE__ */ __name((network) => ({
8773
- chain: exports.Chains.Bitcoin,
8774
- name: "Bitcoin",
8775
- isMainnet: !isTestnet(network)
8776
- }), "bitcoin");
8773
+ init_guards();
8774
+ var chainFactory = /* @__PURE__ */ __name((chain2) => (network, env) => ({
8775
+ chain: chain2,
8776
+ name: exports.Chains[chain2],
8777
+ isMainnet: !isTestnet(network),
8778
+ requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[exports.Chains[chain2]]) ? Number(env.ingressEgress.witnessSafetyMargins[exports.Chains[chain2]]) + 1 : void 0
8779
+ }), "chainFactory");
8780
+ var ethereum = chainFactory(exports.Chains.Ethereum);
8781
+ var polkadot = chainFactory(exports.Chains.Polkadot);
8782
+ var bitcoin = chainFactory(exports.Chains.Bitcoin);
8777
8783
 
8778
8784
  // src/swap/services/ApiService.ts
8779
- var getChains = /* @__PURE__ */ __name(async (network) => [
8780
- ethereum(network),
8781
- polkadot(network),
8782
- bitcoin(network)
8785
+ var getChains = /* @__PURE__ */ __name(async (network, env) => [
8786
+ ethereum(network, env),
8787
+ polkadot(network, env),
8788
+ bitcoin(network, env)
8783
8789
  ], "getChains");
8784
- var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, network) => {
8790
+ var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, network, env) => {
8785
8791
  if (sourceChain === exports.Chains.Ethereum)
8786
8792
  return [
8787
- ethereum(network),
8788
- bitcoin(network),
8789
- polkadot(network)
8793
+ ethereum(network, env),
8794
+ bitcoin(network, env),
8795
+ polkadot(network, env)
8790
8796
  ];
8791
8797
  if (sourceChain === exports.Chains.Polkadot)
8792
8798
  return [
8793
- ethereum(network),
8794
- bitcoin(network)
8799
+ ethereum(network, env),
8800
+ bitcoin(network, env)
8795
8801
  ];
8796
8802
  if (sourceChain === exports.Chains.Bitcoin)
8797
8803
  return [
8798
- ethereum(network),
8799
- polkadot(network)
8804
+ ethereum(network, env),
8805
+ polkadot(network, env)
8800
8806
  ];
8801
8807
  throw new Error("received unknown chain");
8802
8808
  }, "getPossibleDestinationChains");
@@ -8882,11 +8888,12 @@ var _SwapSDK = class _SwapSDK {
8882
8888
  network: this.network
8883
8889
  };
8884
8890
  }
8885
- getChains(sourceChain) {
8891
+ async getChains(sourceChain) {
8892
+ const env = await this.getStateChainEnvironment();
8886
8893
  if (sourceChain !== void 0) {
8887
- return ApiService_default.getPossibleDestinationChains(sourceChain, this.network);
8894
+ return ApiService_default.getPossibleDestinationChains(sourceChain, this.network, env);
8888
8895
  }
8889
- return ApiService_default.getChains(this.network);
8896
+ return ApiService_default.getChains(this.network, env);
8890
8897
  }
8891
8898
  async getStateChainEnvironment() {
8892
8899
  this.stateChainEnvironment ?? (this.stateChainEnvironment = await getEnvironment(this.rpcConfig));
@@ -8971,6 +8978,13 @@ var _SwapSDK = class _SwapSDK {
8971
8978
  maximumSwapAmounts
8972
8979
  };
8973
8980
  }
8981
+ async getRequiredBlockConfirmations() {
8982
+ const { ingressEgress: { witnessSafetyMargins } } = await this.getStateChainEnvironment();
8983
+ return Object.keys(exports.Chains).reduce((acc, chain2) => {
8984
+ acc[chain2] = witnessSafetyMargins[chain2] ? Number(witnessSafetyMargins[chain2]) + 1 : void 0;
8985
+ return acc;
8986
+ }, {});
8987
+ }
8974
8988
  };
8975
8989
  __name(_SwapSDK, "SwapSDK");
8976
8990
  var SwapSDK = _SwapSDK;
package/dist/swap.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { getTokenContractAddress, getEnvironment, getVaultManagerContractAddress, approve, checkAllowance, Vault__factory, extractOverrides } from './chunk-2GNHNTY7.mjs';
2
- import { ccmMetadataSchema } from './chunk-KLVDY4K6.mjs';
3
- import { __name, z, numericString, Chains, Assets, ethereumAddress, dotAddress, ChainflipNetworks, assetConstants, isTestnet, readChainAssetValue, __publicField, assert, isTokenCall, isTokenSwap, getInternalAsset, chainConstants, btcAddress } from './chunk-3LCS6BBP.mjs';
4
- export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-3LCS6BBP.mjs';
1
+ import { getTokenContractAddress, getEnvironment, getVaultManagerContractAddress, approve, checkAllowance, Vault__factory, extractOverrides } from './chunk-X5KSXKLT.mjs';
2
+ import { ccmMetadataSchema } from './chunk-MEARHD4S.mjs';
3
+ import { __name, z, numericString, Chains, Assets, ethereumAddress, dotAddress, ChainflipNetworks, assetConstants, isTestnet, readChainAssetValue, isNotNullish, __publicField, assert, isTokenCall, isTokenSwap, getInternalAsset, chainConstants, btcAddress } from './chunk-D22I3FZH.mjs';
4
+ export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-D22I3FZH.mjs';
5
5
  import { decodeAddress } from '@polkadot/util-crypto';
6
6
  import axios from 'axios';
7
7
 
@@ -2427,44 +2427,38 @@ var dot$ = assetFactory("Dot");
2427
2427
  var btc$ = assetFactory("Btc");
2428
2428
 
2429
2429
  // src/swap/chains.ts
2430
- var ethereum = /* @__PURE__ */ __name((network) => ({
2431
- chain: Chains.Ethereum,
2432
- name: "Ethereum",
2433
- isMainnet: !isTestnet(network)
2434
- }), "ethereum");
2435
- var polkadot = /* @__PURE__ */ __name((network) => ({
2436
- chain: Chains.Polkadot,
2437
- name: "Polkadot",
2438
- isMainnet: !isTestnet(network)
2439
- }), "polkadot");
2440
- var bitcoin = /* @__PURE__ */ __name((network) => ({
2441
- chain: Chains.Bitcoin,
2442
- name: "Bitcoin",
2443
- isMainnet: !isTestnet(network)
2444
- }), "bitcoin");
2430
+ var chainFactory = /* @__PURE__ */ __name((chain) => (network, env) => ({
2431
+ chain,
2432
+ name: Chains[chain],
2433
+ isMainnet: !isTestnet(network),
2434
+ requiredBlockConfirmations: isNotNullish(env.ingressEgress.witnessSafetyMargins[Chains[chain]]) ? Number(env.ingressEgress.witnessSafetyMargins[Chains[chain]]) + 1 : void 0
2435
+ }), "chainFactory");
2436
+ var ethereum = chainFactory(Chains.Ethereum);
2437
+ var polkadot = chainFactory(Chains.Polkadot);
2438
+ var bitcoin = chainFactory(Chains.Bitcoin);
2445
2439
 
2446
2440
  // src/swap/services/ApiService.ts
2447
- var getChains = /* @__PURE__ */ __name(async (network) => [
2448
- ethereum(network),
2449
- polkadot(network),
2450
- bitcoin(network)
2441
+ var getChains = /* @__PURE__ */ __name(async (network, env) => [
2442
+ ethereum(network, env),
2443
+ polkadot(network, env),
2444
+ bitcoin(network, env)
2451
2445
  ], "getChains");
2452
- var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, network) => {
2446
+ var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, network, env) => {
2453
2447
  if (sourceChain === Chains.Ethereum)
2454
2448
  return [
2455
- ethereum(network),
2456
- bitcoin(network),
2457
- polkadot(network)
2449
+ ethereum(network, env),
2450
+ bitcoin(network, env),
2451
+ polkadot(network, env)
2458
2452
  ];
2459
2453
  if (sourceChain === Chains.Polkadot)
2460
2454
  return [
2461
- ethereum(network),
2462
- bitcoin(network)
2455
+ ethereum(network, env),
2456
+ bitcoin(network, env)
2463
2457
  ];
2464
2458
  if (sourceChain === Chains.Bitcoin)
2465
2459
  return [
2466
- ethereum(network),
2467
- polkadot(network)
2460
+ ethereum(network, env),
2461
+ polkadot(network, env)
2468
2462
  ];
2469
2463
  throw new Error("received unknown chain");
2470
2464
  }, "getPossibleDestinationChains");
@@ -2550,11 +2544,12 @@ var _SwapSDK = class _SwapSDK {
2550
2544
  network: this.network
2551
2545
  };
2552
2546
  }
2553
- getChains(sourceChain) {
2547
+ async getChains(sourceChain) {
2548
+ const env = await this.getStateChainEnvironment();
2554
2549
  if (sourceChain !== void 0) {
2555
- return ApiService_default.getPossibleDestinationChains(sourceChain, this.network);
2550
+ return ApiService_default.getPossibleDestinationChains(sourceChain, this.network, env);
2556
2551
  }
2557
- return ApiService_default.getChains(this.network);
2552
+ return ApiService_default.getChains(this.network, env);
2558
2553
  }
2559
2554
  async getStateChainEnvironment() {
2560
2555
  this.stateChainEnvironment ?? (this.stateChainEnvironment = await getEnvironment(this.rpcConfig));
@@ -2578,7 +2573,7 @@ var _SwapSDK = class _SwapSDK {
2578
2573
  }, BigInt(amount));
2579
2574
  let response;
2580
2575
  if (this.brokerConfig !== void 0) {
2581
- const { requestSwapDepositAddress } = await import('./broker-6ALZEHLT.mjs');
2576
+ const { requestSwapDepositAddress } = await import('./broker-VIDTY3VV.mjs');
2582
2577
  const result = await requestSwapDepositAddress(depositAddressRequest, this.brokerConfig, this.network);
2583
2578
  response = {
2584
2579
  id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
@@ -2639,6 +2634,13 @@ var _SwapSDK = class _SwapSDK {
2639
2634
  maximumSwapAmounts
2640
2635
  };
2641
2636
  }
2637
+ async getRequiredBlockConfirmations() {
2638
+ const { ingressEgress: { witnessSafetyMargins } } = await this.getStateChainEnvironment();
2639
+ return Object.keys(Chains).reduce((acc, chain) => {
2640
+ acc[chain] = witnessSafetyMargins[chain] ? Number(witnessSafetyMargins[chain]) + 1 : void 0;
2641
+ return acc;
2642
+ }, {});
2643
+ }
2642
2644
  };
2643
2645
  __name(_SwapSDK, "SwapSDK");
2644
2646
  var SwapSDK = _SwapSDK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "1.2.1",
3
+ "version": "1.2.2-alpha.1",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {