@subwallet/extension-base 1.3.34-0 → 1.3.36-0

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.
Files changed (49) hide show
  1. package/background/KoniTypes.d.ts +10 -0
  2. package/cjs/core/logic-validation/request.js +1 -1
  3. package/cjs/koni/background/handlers/Extension.js +32 -4
  4. package/cjs/koni/background/utils.js +64 -29
  5. package/cjs/packageInfo.js +1 -1
  6. package/cjs/services/balance-service/helpers/process.js +1 -5
  7. package/cjs/services/balance-service/index.js +20 -1
  8. package/cjs/services/balance-service/transfer/xcm/acrossBridge/index.js +91 -175
  9. package/cjs/services/balance-service/transfer/xcm/index.js +7 -6
  10. package/cjs/services/price-service/coingecko.js +22 -15
  11. package/cjs/services/price-service/index.js +12 -0
  12. package/cjs/services/request-service/handler/EvmRequestHandler.js +4 -1
  13. package/cjs/services/swap-service/handler/kyber-handler.js +355 -0
  14. package/cjs/services/swap-service/handler/uniswap-handler.js +223 -41
  15. package/cjs/services/swap-service/index.js +34 -2
  16. package/cjs/services/swap-service/utils.js +4 -1
  17. package/cjs/services/transaction-service/index.js +297 -52
  18. package/cjs/types/swap/index.js +2 -1
  19. package/core/logic-validation/request.js +1 -1
  20. package/koni/background/handlers/Extension.d.ts +1 -0
  21. package/koni/background/handlers/Extension.js +32 -4
  22. package/koni/background/utils.d.ts +3 -5
  23. package/koni/background/utils.js +64 -29
  24. package/package.json +11 -6
  25. package/packageInfo.js +1 -1
  26. package/services/balance-service/helpers/process.d.ts +2 -2
  27. package/services/balance-service/helpers/process.js +1 -5
  28. package/services/balance-service/index.js +21 -2
  29. package/services/balance-service/transfer/xcm/acrossBridge/index.d.ts +9 -8
  30. package/services/balance-service/transfer/xcm/acrossBridge/index.js +91 -174
  31. package/services/balance-service/transfer/xcm/index.js +7 -6
  32. package/services/event-service/types.d.ts +6 -6
  33. package/services/price-service/coingecko.d.ts +1 -1
  34. package/services/price-service/coingecko.js +22 -16
  35. package/services/price-service/index.d.ts +1 -0
  36. package/services/price-service/index.js +12 -0
  37. package/services/request-service/handler/EvmRequestHandler.js +4 -1
  38. package/services/swap-service/handler/kyber-handler.d.ts +28 -0
  39. package/services/swap-service/handler/kyber-handler.js +346 -0
  40. package/services/swap-service/handler/uniswap-handler.d.ts +48 -0
  41. package/services/swap-service/handler/uniswap-handler.js +224 -42
  42. package/services/swap-service/index.js +34 -2
  43. package/services/swap-service/utils.js +4 -1
  44. package/services/transaction-service/helpers/index.d.ts +5 -5
  45. package/services/transaction-service/index.d.ts +10 -5
  46. package/services/transaction-service/index.js +279 -36
  47. package/services/transaction-service/types.d.ts +23 -10
  48. package/types/swap/index.d.ts +4 -1
  49. package/types/swap/index.js +2 -1
@@ -142,6 +142,7 @@ export interface PriceJson {
142
142
  exchangeRateMap: Record<string, ExchangeRateJSON>;
143
143
  priceMap: Record<string, number>;
144
144
  price24hMap: Record<string, number>;
145
+ priceCoinGeckoSupported: string[];
145
146
  lastUpdatedMap: Record<string, Date>;
146
147
  }
147
148
  export interface HistoryTokenPriceJSON {
@@ -902,6 +903,13 @@ export interface EvmSendTransactionRequest extends TransactionConfig, EvmSignReq
902
903
  isToContract: boolean;
903
904
  errors?: ErrorValidation[];
904
905
  }
906
+ export interface SubmitApiRequest extends EvmSignRequest {
907
+ id: string;
908
+ type: string;
909
+ payload: unknown;
910
+ errors?: ErrorValidation[];
911
+ processId?: string;
912
+ }
905
913
  export declare enum CardanoProviderErrorType {
906
914
  INVALID_REQUEST = "INVALID_REQUEST",
907
915
  REFUSED_REQUEST = "REFUSED_REQUEST",
@@ -1013,6 +1021,7 @@ export interface ConfirmationDefinitions {
1013
1021
  evmSendTransactionRequest: [ConfirmationsQueueItem<EvmSendTransactionRequest>, ConfirmationResult<string>];
1014
1022
  evmWatchTransactionRequest: [ConfirmationsQueueItem<EvmWatchTransactionRequest>, ConfirmationResult<string>];
1015
1023
  errorConnectNetwork: [ConfirmationsQueueItem<ErrorNetworkConnection>, ConfirmationResult<null>];
1024
+ submitApiRequest: [ConfirmationsQueueItem<SubmitApiRequest>, ConfirmationResult<string>];
1016
1025
  }
1017
1026
  export interface ConfirmationDefinitionsTon {
1018
1027
  tonSignatureRequest: [ConfirmationsQueueItem<TonSignatureRequest>, ConfirmationResult<string>];
@@ -1674,6 +1683,7 @@ export interface KoniRequestSignatures {
1674
1683
  'pri(price.getPrice)': [RequestPrice, PriceJson];
1675
1684
  'pri(price.getSubscription)': [RequestSubscribePrice, PriceJson, PriceJson];
1676
1685
  'pri(price.getHistory)': [RequestGetHistoryTokenPriceData, HistoryTokenPriceJSON];
1686
+ 'pri(price.checkCoinGeckoPriceSupport)': [string, boolean];
1677
1687
  'pri(price.subscribeCurrentTokenPrice)': [string, ResponseSubscribeCurrentTokenPrice, CurrentTokenPrice];
1678
1688
  'pri(balance.getBalance)': [RequestBalance, BalanceJson];
1679
1689
  'pri(balance.getSubscription)': [RequestSubscribeBalance, BalanceJson, BalanceJson];
@@ -371,7 +371,7 @@ async function validationEvmDataTransactionMiddleware(koni, url, payload) {
371
371
  transaction.maxPriorityFeePerGas = feeCombine.maxPriorityFeePerGas;
372
372
  } else if (feeCombine.gasPrice) {
373
373
  estimateGas = new _bignumber.default(feeCombine.gasPrice || 0).multipliedBy(gasLimit).toFixed(0);
374
- transaction.maxPriorityFeePerGas = feeCombine.gasPrice;
374
+ transaction.gasPrice = feeCombine.gasPrice;
375
375
  }
376
376
  }
377
377
  } catch (e) {
@@ -925,6 +925,9 @@ class KoniExtension {
925
925
  } = _ref29;
926
926
  return this.#koniState.priceService.getHistoryTokenPriceData(priceId, timeframe);
927
927
  }
928
+ checkCoinGeckoPriceSupport(priceId) {
929
+ return this.#koniState.priceService.checkCoinGeckoPriceSupport(priceId);
930
+ }
928
931
  subscribeCurrentTokenPrice(priceId, id, port) {
929
932
  const cb = (0, _subscriptions.createSubscription)(id, port);
930
933
  const {
@@ -1490,7 +1493,8 @@ class KoniExtension {
1490
1493
  xcmFeeDryRun = dryRunInfo.fee;
1491
1494
  }
1492
1495
  if (isAcrossBridgeTransfer) {
1493
- const metadata = await (0, _acrossBridge.getAcrossQuote)(params);
1496
+ const data = await (0, _acrossBridge.getAcrossQuote)(params);
1497
+ const metadata = data.metadata;
1494
1498
  inputData.metadata = {
1495
1499
  amountOut: metadata.outputAmount,
1496
1500
  rate: metadata.rate,
@@ -2648,11 +2652,12 @@ class KoniExtension {
2648
2652
  let registry = new _types5.TypeRegistry();
2649
2653
  if (isJsonPayload(payload)) {
2650
2654
  const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
2651
- const allRegistry = [(0, _utils9.setupApiRegistry)(chainInfo, this.#koniState), (0, _utils9.setupDatabaseRegistry)(await this.#koniState.chainService.getMetadataByHash(payload.genesisHash), chainInfo, payload), (0, _utils9.setupDappRegistry)(this.#koniState.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash), payload)].filter(item => item !== null && item.registry !== undefined);
2652
- if (allRegistry.length === 0) {
2655
+ const registries = await Promise.all([(0, _utils9.setupApiRegistry)(chainInfo, this.#koniState), (0, _utils9.setupDatabaseRegistry)(chainInfo, payload, this.#koniState), (0, _utils9.setupDappRegistry)(payload, this.#koniState)]);
2656
+ const validRegistries = registries.filter(item => !!(item !== null && item !== void 0 && item.registry));
2657
+ if (validRegistries.length === 0) {
2653
2658
  registry.setSignedExtensions(payload.signedExtensions);
2654
2659
  } else {
2655
- registry = (0, _utils9.getSuitableRegistry)(allRegistry, payload);
2660
+ registry = (0, _utils9.getSuitableRegistry)(validRegistries, payload);
2656
2661
  }
2657
2662
  }
2658
2663
  const result = request.sign(registry, pair);
@@ -2781,6 +2786,7 @@ class KoniExtension {
2781
2786
  let {
2782
2787
  id
2783
2788
  } = _ref50;
2789
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2784
2790
  const {
2785
2791
  transaction,
2786
2792
  ...transactionResult
@@ -2792,6 +2798,7 @@ class KoniExtension {
2792
2798
  function convertRs(rs, processMap) {
2793
2799
  return Object.fromEntries(Object.entries(rs).map(_ref51 => {
2794
2800
  let [key, value] = _ref51;
2801
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2795
2802
  const {
2796
2803
  additionalValidator,
2797
2804
  eventsHandler,
@@ -3849,6 +3856,7 @@ class KoniExtension {
3849
3856
  chainType,
3850
3857
  extrinsic,
3851
3858
  extrinsicType,
3859
+ isDutch,
3852
3860
  isPermit,
3853
3861
  transferNativeAmount,
3854
3862
  txChain,
@@ -3905,6 +3913,24 @@ class KoniExtension {
3905
3913
  step
3906
3914
  });
3907
3915
  }
3916
+ if (isDutch) {
3917
+ return await this.#koniState.transactionService.handleDutchTransaction({
3918
+ address,
3919
+ chain: txChain,
3920
+ transaction: extrinsic,
3921
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
3922
+ data: txData,
3923
+ extrinsicType,
3924
+ // change this depends on step
3925
+ chainType,
3926
+ resolveOnDone: !isLastStep,
3927
+ transferNativeAmount,
3928
+ ...this.createPassConfirmationParams(isPassConfirmation),
3929
+ errorOnTimeOut,
3930
+ eventsHandler,
3931
+ step
3932
+ });
3933
+ }
3908
3934
  return await this.#koniState.transactionService.handleTransaction({
3909
3935
  address,
3910
3936
  chain: txChain,
@@ -4360,6 +4386,8 @@ class KoniExtension {
4360
4386
  return await this.subscribePrice(id, port);
4361
4387
  case 'pri(price.getHistory)':
4362
4388
  return await this.getHistoryTokenPrice(request);
4389
+ case 'pri(price.checkCoinGeckoPriceSupport)':
4390
+ return this.checkCoinGeckoPriceSupport(request);
4363
4391
  case 'pri(price.subscribeCurrentTokenPrice)':
4364
4392
  return this.subscribeCurrentTokenPrice(request, id, port);
4365
4393
  case 'pri(settings.savePriceCurrency)':
@@ -7,6 +7,7 @@ exports.getSuitableRegistry = getSuitableRegistry;
7
7
  exports.setupApiRegistry = setupApiRegistry;
8
8
  exports.setupDappRegistry = setupDappRegistry;
9
9
  exports.setupDatabaseRegistry = setupDatabaseRegistry;
10
+ var _utils = require("@subwallet/extension-base/utils");
10
11
  var _bundle = require("@subwallet/extension-chains/bundle");
11
12
  var _types = require("@polkadot/types");
12
13
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
@@ -32,41 +33,75 @@ function getSuitableRegistry(registries, payload) {
32
33
  });
33
34
  return sortedRegistries[0].registry;
34
35
  }
35
- function setupApiRegistry(chainInfo, koniState) {
36
+ async function setupApiRegistry(chainInfo, koniState) {
36
37
  if (!chainInfo) {
37
38
  return null;
38
39
  }
39
- const api = koniState.getSubstrateApi(chainInfo.slug).api;
40
- const apiSpecVersion = api === null || api === void 0 ? void 0 : api.runtimeVersion.specVersion.toString();
41
- const registry = api === null || api === void 0 ? void 0 : api.registry;
42
- return {
43
- registry,
44
- specVersion: apiSpecVersion
45
- };
46
- }
47
- function setupDatabaseRegistry(metadata, chainInfo, payload) {
48
- if (!metadata || !metadata.genesisHash || !chainInfo) {
40
+ try {
41
+ const api = koniState.getSubstrateApi(chainInfo.slug).api;
42
+ if (!api) {
43
+ return null;
44
+ }
45
+
46
+ // Wait for the API to be ready or timeout after 1 second
47
+ await Promise.race([(0, _utils.wait)(1000).then(() => {
48
+ throw new Error('Timeout waiting for API to be ready');
49
+ }), api.isReady]);
50
+
51
+ // Extract the spec version and registry
52
+ const apiSpecVersion = api.runtimeVersion.specVersion.toString();
53
+ const registry = api.registry;
54
+ return {
55
+ registry,
56
+ specVersion: apiSpecVersion
57
+ };
58
+ } catch (e) {
59
+ console.error('Error in setupApiRegistry:', e);
49
60
  return null;
50
61
  }
51
- const registry = new _types.TypeRegistry();
52
- const _metadata = new _types.Metadata(registry, metadata.hexValue);
53
- registry.register(metadata.types);
54
- registry.setChainProperties(registry.createType('ChainProperties', metadata.tokenInfo));
55
- registry.setMetadata(_metadata, payload.signedExtensions, metadata.userExtensions);
56
- return {
57
- registry,
58
- specVersion: metadata.specVersion
59
- };
60
62
  }
61
- function setupDappRegistry(metadata, payload) {
62
- if (!metadata || !metadata.genesisHash) {
63
+ async function setupDatabaseRegistry(chainInfo, payload, koniState) {
64
+ if (!chainInfo) {
65
+ console.warn('setupDatabaseRegistry: Missing chainInfo');
66
+ return null;
67
+ }
68
+ try {
69
+ const metadata = await koniState.chainService.getMetadataByHash(payload.genesisHash);
70
+ if (!(metadata !== null && metadata !== void 0 && metadata.genesisHash)) {
71
+ console.warn('setupDatabaseRegistry: Metadata not found or invalid for genesisHash:', payload.genesisHash);
72
+ return null;
73
+ }
74
+ const registry = new _types.TypeRegistry();
75
+ const _metadata = new _types.Metadata(registry, metadata.hexValue);
76
+ registry.register(metadata.types);
77
+ registry.setChainProperties(registry.createType('ChainProperties', metadata.tokenInfo));
78
+ registry.setMetadata(_metadata, payload.signedExtensions, metadata.userExtensions);
79
+ return {
80
+ registry,
81
+ specVersion: metadata.specVersion
82
+ };
83
+ } catch (e) {
84
+ console.error('setupDatabaseRegistry: Error setting up database registry:', e);
63
85
  return null;
64
86
  }
65
- const expanded = (0, _bundle.metadataExpand)(metadata, false);
66
- const registry = expanded.registry;
67
- registry.setSignedExtensions(payload.signedExtensions, expanded.definition.userExtensions);
68
- return {
69
- registry,
70
- specVersion: metadata.specVersion
71
- };
87
+ }
88
+ function setupDappRegistry(payload, koniState) {
89
+ return new Promise(resolve => {
90
+ const metadata = koniState.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash);
91
+ if (!(metadata !== null && metadata !== void 0 && metadata.genesisHash)) {
92
+ return resolve(null);
93
+ }
94
+ try {
95
+ const expanded = (0, _bundle.metadataExpand)(metadata, false);
96
+ const registry = expanded.registry;
97
+ registry.setSignedExtensions(payload.signedExtensions, expanded.definition.userExtensions);
98
+ resolve({
99
+ registry,
100
+ specVersion: metadata.specVersion
101
+ });
102
+ } catch (e) {
103
+ console.error('setupDappRegistry: Error setting up DApp registry:', e);
104
+ resolve(null);
105
+ }
106
+ });
72
107
  }
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.3.34-0'
16
+ version: '1.3.36-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -8,8 +8,6 @@ exports.getDefaultTransferProcess = getDefaultTransferProcess;
8
8
  exports.getSnowbridgeTransferProcessFromEvm = getSnowbridgeTransferProcessFromEvm;
9
9
  var _chainList = require("@subwallet/chain-list");
10
10
  var _serviceBase = require("@subwallet/extension-base/types/service-base");
11
- var _utils = require("../../chain-service/utils");
12
- var _acrossBridge = require("../transfer/xcm/acrossBridge");
13
11
  // Copyright 2019-2022 @subwallet/extension-base
14
12
  // SPDX-License-Identifier: Apache-2.0
15
13
 
@@ -52,9 +50,7 @@ async function getSnowbridgeTransferProcessFromEvm(address, evmApi, tokenInfo, a
52
50
  result.totalFee.push(_serviceBase.MOCK_STEP_FEE);
53
51
  return Promise.resolve(result);
54
52
  }
55
- async function getAcrossbridgeTransferProcessFromEvm(originChainInfo) {
56
- const chainId = (0, _utils._getEvmChainId)(originChainInfo);
57
- const SpokePoolAddress = _acrossBridge.SpokePoolMapping[chainId].SpokePool.address;
53
+ async function getAcrossbridgeTransferProcessFromEvm(SpokePoolAddress) {
58
54
  const result = {
59
55
  totalFee: [_serviceBase.MOCK_STEP_FEE],
60
56
  steps: [_serviceBase.DEFAULT_FIRST_STEP]
@@ -586,7 +586,26 @@ class BalanceService {
586
586
  if ((0, _acrossBridge._isAcrossChainBridge)(originChainInfo.slug, destChainInfo.slug)) {
587
587
  const tokenInfo = this.state.chainService.getAssetBySlug(params.tokenSlug);
588
588
  if (!(0, _utils._isNativeToken)(tokenInfo)) {
589
- return (0, _process.getAcrossbridgeTransferProcessFromEvm)(originChainInfo);
589
+ const chainInfoMap = this.state.getChainInfoMap();
590
+ const originTokenInfo = this.state.getAssetBySlug(params.tokenSlug);
591
+ const destinationTokenInfo = this.state.getXcmEqualAssetByChain(params.destChain, params.tokenSlug);
592
+ if (!destinationTokenInfo) {
593
+ throw new Error('Destination token info not found');
594
+ }
595
+ const inputData = {
596
+ destinationTokenInfo,
597
+ originTokenInfo,
598
+ sendingValue: params.amount,
599
+ sender: params.address,
600
+ recipient: params.address,
601
+ destinationChain: chainInfoMap[destinationTokenInfo.originChain],
602
+ originChain: chainInfoMap[originTokenInfo.originChain]
603
+ };
604
+ const data = await (0, _acrossBridge.getAcrossQuote)(inputData);
605
+ if (!data) {
606
+ throw new Error('Failed to fetch Across Bridge Data. Please try again later');
607
+ }
608
+ return (0, _process.getAcrossbridgeTransferProcessFromEvm)(data.to);
590
609
  }
591
610
  }
592
611
  return (0, _process.getDefaultTransferProcess)();
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.SpokePoolMapping = exports.AcrossErrorMsg = void 0;
7
+ exports.AcrossErrorMsg = void 0;
8
8
  exports._isAcrossChainBridge = _isAcrossChainBridge;
9
9
  exports._isAcrossTestnetBridge = _isAcrossTestnetBridge;
10
10
  exports.getAcrossQuote = void 0;
@@ -25,177 +25,6 @@ function _isAcrossChainBridge(srcChain, destChain) {
25
25
  function _isAcrossTestnetBridge(srcChain) {
26
26
  return srcChain === 'base_sepolia' || srcChain === 'arbitrum_sepolia' || srcChain === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA;
27
27
  }
28
- const SpokePoolMapping = {
29
- 1: {
30
- SpokePool: {
31
- address: '0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5',
32
- blockNumber: 17117454
33
- }
34
- },
35
- 10: {
36
- SpokePool: {
37
- address: '0x6f26Bf09B1C792e3228e5467807a900A503c0281',
38
- blockNumber: 93903076
39
- }
40
- },
41
- 11155111: {
42
- SpokePool: {
43
- address: '0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662',
44
- blockNumber: 5288470
45
- }
46
- },
47
- 11155420: {
48
- SpokePool: {
49
- address: '0x4e8E101924eDE233C13e2D8622DC8aED2872d505',
50
- blockNumber: 7762656
51
- }
52
- },
53
- 1135: {
54
- SpokePool: {
55
- address: '0x9552a0a6624A23B848060AE5901659CDDa1f83f8',
56
- blockNumber: 2602337
57
- }
58
- },
59
- 130: {
60
- SpokePool: {
61
- address: '0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64',
62
- blockNumber: 7915488
63
- }
64
- },
65
- 137: {
66
- SpokePool: {
67
- address: '0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096',
68
- blockNumber: 41908657
69
- }
70
- },
71
- 168587773: {
72
- SpokePool: {
73
- address: '0x5545092553Cf5Bf786e87a87192E902D50D8f022',
74
- blockNumber: 7634204
75
- }
76
- },
77
- 1868: {
78
- SpokePool: {
79
- address: '0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96',
80
- blockNumber: 1709997
81
- }
82
- },
83
- 288: {
84
- SpokePool: {
85
- address: '0xBbc6009fEfFc27ce705322832Cb2068F8C1e0A58',
86
- blockNumber: 619993
87
- }
88
- },
89
- 324: {
90
- SpokePool: {
91
- address: '0xE0B015E54d54fc84a6cB9B666099c46adE9335FF',
92
- blockNumber: 10352565
93
- }
94
- },
95
- 34443: {
96
- SpokePool: {
97
- address: '0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96',
98
- blockNumber: 8043187
99
- }
100
- },
101
- 37111: {
102
- SpokePool: {
103
- address: '0x6A0a7f39530923911832Dd60667CE5da5449967B',
104
- blockNumber: 156275
105
- }
106
- },
107
- 41455: {
108
- SpokePool: {
109
- address: '0x13fDac9F9b4777705db45291bbFF3c972c6d1d97',
110
- blockNumber: 4240318
111
- }
112
- },
113
- 4202: {
114
- SpokePool: {
115
- address: '0xeF684C38F94F48775959ECf2012D7E864ffb9dd4',
116
- blockNumber: 7267988
117
- }
118
- },
119
- 42161: {
120
- SpokePool: {
121
- address: '0xe35e9842fceaCA96570B734083f4a58e8F7C5f2A',
122
- blockNumber: 83868041
123
- }
124
- },
125
- 421614: {
126
- SpokePool: {
127
- address: '0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75',
128
- blockNumber: 12411026
129
- }
130
- },
131
- 480: {
132
- SpokePool: {
133
- address: '0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64',
134
- blockNumber: 4524742
135
- }
136
- },
137
- 534352: {
138
- SpokePool: {
139
- address: '0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96',
140
- blockNumber: 7489705
141
- }
142
- },
143
- 57073: {
144
- SpokePool: {
145
- address: '0xeF684C38F94F48775959ECf2012D7E864ffb9dd4',
146
- blockNumber: 1139240
147
- }
148
- },
149
- 59144: {
150
- SpokePool: {
151
- address: '0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75',
152
- blockNumber: 2721169
153
- }
154
- },
155
- 690: {
156
- SpokePool: {
157
- address: '0x13fDac9F9b4777705db45291bbFF3c972c6d1d97',
158
- blockNumber: 5512122
159
- }
160
- },
161
- 7777777: {
162
- SpokePool: {
163
- address: '0x13fDac9F9b4777705db45291bbFF3c972c6d1d97',
164
- blockNumber: 18382867
165
- }
166
- },
167
- 80002: {
168
- SpokePool: {
169
- address: '0xd08baaE74D6d2eAb1F3320B2E1a53eeb391ce8e5',
170
- blockNumber: 7529960
171
- }
172
- },
173
- 81457: {
174
- SpokePool: {
175
- address: '0x2D509190Ed0172ba588407D4c2df918F955Cc6E1',
176
- blockNumber: 5574280
177
- }
178
- },
179
- 8453: {
180
- SpokePool: {
181
- address: '0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64',
182
- blockNumber: 2164878
183
- }
184
- },
185
- 84532: {
186
- SpokePool: {
187
- address: '0x82B564983aE7274c86695917BBf8C99ECb6F0F8F',
188
- blockNumber: 6082004
189
- }
190
- },
191
- 919: {
192
- SpokePool: {
193
- address: '0xbd886FC0725Cc459b55BbFEb3E4278610331f83b',
194
- blockNumber: 13999465
195
- }
196
- }
197
- };
198
- exports.SpokePoolMapping = SpokePoolMapping;
199
28
  const AcrossErrorMsg = {
200
29
  AMOUNT_TOO_LOW: 'amount too low',
201
30
  AMOUNT_TOO_HIGH: 'amount too high'
@@ -222,12 +51,99 @@ const getAcrossQuote = async _ref => {
222
51
  try {
223
52
  var _subwalletApiSdk$xcmA;
224
53
  const data = await ((_subwalletApiSdk$xcmA = _subwalletApiSdk.default.xcmApi) === null || _subwalletApiSdk$xcmA === void 0 ? void 0 : _subwalletApiSdk$xcmA.fetchXcmData(sender, originTokenInfo.slug, destinationTokenInfo.slug, recipient, sendingValue));
225
- if (!data || !data.metadata) {
226
- throw new Error('Failed to get AcrossBridge quote');
54
+ if (!data) {
55
+ throw new Error('Failed to fetch Across Bridge Data. Please try again later');
227
56
  }
228
- return data.metadata;
57
+ return data;
229
58
  } catch (error) {
230
59
  return Promise.reject(error);
231
60
  }
232
61
  };
62
+
63
+ // export const SpokePoolMapping: Record<number, { SpokePool: { address: string; blockNumber: number } }> = {
64
+ // 1: {
65
+ // SpokePool: { address: '0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5', blockNumber: 17117454 }
66
+ // },
67
+ // 10: {
68
+ // SpokePool: { address: '0x6f26Bf09B1C792e3228e5467807a900A503c0281', blockNumber: 93903076 }
69
+ // },
70
+ // 11155111: {
71
+ // SpokePool: { address: '0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662', blockNumber: 5288470 }
72
+ // },
73
+ // 11155420: {
74
+ // SpokePool: { address: '0x4e8E101924eDE233C13e2D8622DC8aED2872d505', blockNumber: 7762656 }
75
+ // },
76
+ // 1135: {
77
+ // SpokePool: { address: '0x9552a0a6624A23B848060AE5901659CDDa1f83f8', blockNumber: 2602337 }
78
+ // },
79
+ // 130: {
80
+ // SpokePool: { address: '0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64', blockNumber: 7915488 }
81
+ // },
82
+ // 137: {
83
+ // SpokePool: { address: '0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096', blockNumber: 41908657 }
84
+ // },
85
+ // 168587773: {
86
+ // SpokePool: { address: '0x5545092553Cf5Bf786e87a87192E902D50D8f022', blockNumber: 7634204 }
87
+ // },
88
+ // 1868: {
89
+ // SpokePool: { address: '0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96', blockNumber: 1709997 }
90
+ // },
91
+ // 288: {
92
+ // SpokePool: { address: '0xBbc6009fEfFc27ce705322832Cb2068F8C1e0A58', blockNumber: 619993 }
93
+ // },
94
+ // 324: {
95
+ // SpokePool: { address: '0xE0B015E54d54fc84a6cB9B666099c46adE9335FF', blockNumber: 10352565 }
96
+ // },
97
+ // 34443: {
98
+ // SpokePool: { address: '0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96', blockNumber: 8043187 }
99
+ // },
100
+ // 37111: {
101
+ // SpokePool: { address: '0x6A0a7f39530923911832Dd60667CE5da5449967B', blockNumber: 156275 }
102
+ // },
103
+ // 41455: {
104
+ // SpokePool: { address: '0x13fDac9F9b4777705db45291bbFF3c972c6d1d97', blockNumber: 4240318 }
105
+ // },
106
+ // 4202: {
107
+ // SpokePool: { address: '0xeF684C38F94F48775959ECf2012D7E864ffb9dd4', blockNumber: 7267988 }
108
+ // },
109
+ // 42161: {
110
+ // SpokePool: { address: '0xe35e9842fceaCA96570B734083f4a58e8F7C5f2A', blockNumber: 83868041 }
111
+ // },
112
+ // 421614: {
113
+ // SpokePool: { address: '0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75', blockNumber: 12411026 }
114
+ // },
115
+ // 480: {
116
+ // SpokePool: { address: '0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64', blockNumber: 4524742 }
117
+ // },
118
+ // 534352: {
119
+ // SpokePool: { address: '0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96', blockNumber: 7489705 }
120
+ // },
121
+ // 57073: {
122
+ // SpokePool: { address: '0xeF684C38F94F48775959ECf2012D7E864ffb9dd4', blockNumber: 1139240 }
123
+ // },
124
+ // 59144: {
125
+ // SpokePool: { address: '0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75', blockNumber: 2721169 }
126
+ // },
127
+ // 690: {
128
+ // SpokePool: { address: '0x13fDac9F9b4777705db45291bbFF3c972c6d1d97', blockNumber: 5512122 }
129
+ // },
130
+ // 7777777: {
131
+ // SpokePool: { address: '0x13fDac9F9b4777705db45291bbFF3c972c6d1d97', blockNumber: 18382867 }
132
+ // },
133
+ // 80002: {
134
+ // SpokePool: { address: '0xd08baaE74D6d2eAb1F3320B2E1a53eeb391ce8e5', blockNumber: 7529960 }
135
+ // },
136
+ // 81457: {
137
+ // SpokePool: { address: '0x2D509190Ed0172ba588407D4c2df918F955Cc6E1', blockNumber: 5574280 }
138
+ // },
139
+ // 8453: {
140
+ // SpokePool: { address: '0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64', blockNumber: 2164878 }
141
+ // },
142
+ // 84532: {
143
+ // SpokePool: { address: '0x82B564983aE7274c86695917BBf8C99ECb6F0F8F', blockNumber: 6082004 }
144
+ // },
145
+ // 919: {
146
+ // SpokePool: { address: '0xbd886FC0725Cc459b55BbFEb3E4278610331f83b', blockNumber: 13999465 }
147
+ // }
148
+ // };
233
149
  exports.getAcrossQuote = getAcrossQuote;
@@ -202,13 +202,14 @@ const createAcrossBridgeExtrinsic = async _ref6 => {
202
202
  const data = await ((_subwalletApiSdk$xcmA = _subwalletApiSdk.default.xcmApi) === null || _subwalletApiSdk$xcmA === void 0 ? void 0 : _subwalletApiSdk$xcmA.fetchXcmData(sender, originTokenInfo.slug, destinationTokenInfo.slug, recipient, sendingValue));
203
203
  const _feeCustom = feeCustom;
204
204
  const feeCombine = (0, _utils3.combineEthFee)(feeInfo, feeOption, _feeCustom);
205
-
206
- // todo: validate data before sending
205
+ if (!data) {
206
+ throw new Error('Failed to fetch Across Bridge Data. Please try again later');
207
+ }
207
208
  const transactionConfig = {
208
- from: data === null || data === void 0 ? void 0 : data.sender,
209
- to: data === null || data === void 0 ? void 0 : data.to,
210
- value: data === null || data === void 0 ? void 0 : data.value,
211
- data: data === null || data === void 0 ? void 0 : data.transferEncodedCall,
209
+ from: data.sender,
210
+ to: data.to,
211
+ value: data.value,
212
+ data: data.transferEncodedCall,
212
213
  ...feeCombine
213
214
  };
214
215
  const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);