@subwallet/extension-base 1.3.6-1 → 1.3.8-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 (132) hide show
  1. package/background/KoniTypes.d.ts +20 -5
  2. package/background/KoniTypes.js +1 -1
  3. package/cjs/background/KoniTypes.js +1 -1
  4. package/cjs/constants/blocked-actions.js +108 -0
  5. package/cjs/constants/index.js +4 -4
  6. package/cjs/core/substrate/xcm-parser.js +20 -5
  7. package/cjs/koni/api/contract-handler/utils/index.js +15 -1
  8. package/cjs/koni/api/nft/config.js +6 -4
  9. package/cjs/koni/api/nft/index.js +9 -0
  10. package/cjs/koni/api/nft/story_odyssey_nft/index.js +126 -0
  11. package/cjs/koni/background/handlers/Extension.js +64 -4
  12. package/cjs/koni/background/handlers/State.js +23 -2
  13. package/cjs/packageInfo.js +1 -1
  14. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +2 -1
  15. package/cjs/services/balance-service/transfer/xcm/index.js +31 -1
  16. package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +108 -0
  17. package/cjs/services/chain-online-service/constants.js +32 -0
  18. package/cjs/services/chain-online-service/index.js +190 -0
  19. package/cjs/services/chain-service/constants.js +2 -1
  20. package/cjs/services/chain-service/index.js +87 -127
  21. package/cjs/services/chain-service/utils/index.js +0 -2
  22. package/cjs/services/chain-service/utils/patch.js +7 -3
  23. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +20 -17
  24. package/cjs/services/environment-service/stores/Environment.js +19 -0
  25. package/cjs/services/fee-service/utils/index.js +14 -0
  26. package/cjs/services/inapp-notification-service/consts.js +6 -4
  27. package/cjs/services/inapp-notification-service/index.js +110 -6
  28. package/cjs/services/inapp-notification-service/interfaces.js +9 -1
  29. package/cjs/services/inapp-notification-service/utils/avail.js +88 -0
  30. package/cjs/services/inapp-notification-service/{utils.js → utils/common.js} +1 -84
  31. package/cjs/services/inapp-notification-service/utils/index.js +38 -0
  32. package/cjs/services/inapp-notification-service/utils/polygon.js +66 -0
  33. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +37 -0
  34. package/cjs/services/migration-service/scripts/index.js +3 -1
  35. package/cjs/services/setting-service/SettingService.js +21 -0
  36. package/cjs/services/setting-service/constants.js +2 -1
  37. package/cjs/services/storage-service/DatabaseService.js +3 -0
  38. package/cjs/services/transaction-service/index.js +13 -7
  39. package/cjs/services/transaction-service/utils.js +3 -0
  40. package/cjs/stores/ChainlistStore.js +18 -0
  41. package/cjs/stores/EnvironmentStore.js +18 -0
  42. package/cjs/stores/index.js +8 -1
  43. package/cjs/types/index.js +11 -0
  44. package/cjs/utils/account/transform.js +1 -1
  45. package/cjs/utils/environment.js +15 -1
  46. package/cjs/utils/staticData/index.js +7 -2
  47. package/constants/blocked-actions.d.ts +29 -0
  48. package/constants/blocked-actions.js +96 -0
  49. package/constants/index.d.ts +1 -1
  50. package/constants/index.js +1 -1
  51. package/core/substrate/xcm-parser.d.ts +2 -1
  52. package/core/substrate/xcm-parser.js +19 -5
  53. package/koni/api/contract-handler/utils/index.d.ts +2 -0
  54. package/koni/api/contract-handler/utils/index.js +12 -0
  55. package/koni/api/contract-handler/utils/polygon_bridge_abi.json +1004 -0
  56. package/koni/api/nft/config.d.ts +1 -1
  57. package/koni/api/nft/config.js +5 -2
  58. package/koni/api/nft/index.js +9 -0
  59. package/koni/api/nft/story_odyssey_nft/index.d.ts +40 -0
  60. package/koni/api/nft/story_odyssey_nft/index.js +119 -0
  61. package/koni/background/handlers/Extension.d.ts +5 -0
  62. package/koni/background/handlers/Extension.js +65 -5
  63. package/koni/background/handlers/State.d.ts +5 -0
  64. package/koni/background/handlers/State.js +23 -2
  65. package/package.json +76 -18
  66. package/packageInfo.js +1 -1
  67. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -1
  68. package/services/balance-service/transfer/xcm/index.d.ts +1 -0
  69. package/services/balance-service/transfer/xcm/index.js +29 -1
  70. package/services/balance-service/transfer/xcm/polygonBridge.d.ts +22 -0
  71. package/services/balance-service/transfer/xcm/polygonBridge.js +95 -0
  72. package/services/chain-online-service/constants.d.ts +4 -0
  73. package/services/chain-online-service/constants.js +23 -0
  74. package/services/chain-online-service/index.d.ts +22 -0
  75. package/services/chain-online-service/index.js +182 -0
  76. package/services/chain-service/constants.d.ts +1 -0
  77. package/services/chain-service/constants.js +2 -1
  78. package/services/chain-service/index.d.ts +6 -7
  79. package/services/chain-service/index.js +78 -116
  80. package/services/chain-service/utils/index.js +0 -2
  81. package/services/chain-service/utils/patch.d.ts +16 -1
  82. package/services/chain-service/utils/patch.js +7 -3
  83. package/services/earning-service/handlers/native-staking/para-chain.js +20 -17
  84. package/services/environment-service/stores/Environment.d.ts +10 -0
  85. package/services/environment-service/stores/Environment.js +12 -0
  86. package/services/fee-service/utils/index.js +14 -0
  87. package/services/inapp-notification-service/consts.d.ts +3 -1
  88. package/services/inapp-notification-service/consts.js +6 -4
  89. package/services/inapp-notification-service/index.d.ts +10 -2
  90. package/services/inapp-notification-service/index.js +111 -7
  91. package/services/inapp-notification-service/interfaces.d.ts +27 -3
  92. package/services/inapp-notification-service/interfaces.js +7 -0
  93. package/services/inapp-notification-service/utils/avail.d.ts +40 -0
  94. package/services/inapp-notification-service/utils/avail.js +73 -0
  95. package/services/inapp-notification-service/utils/common.d.ts +11 -0
  96. package/services/inapp-notification-service/{utils.js → utils/common.js} +1 -72
  97. package/services/inapp-notification-service/utils/index.d.ts +3 -0
  98. package/services/inapp-notification-service/utils/index.js +6 -0
  99. package/services/inapp-notification-service/utils/polygon.d.ts +71 -0
  100. package/services/inapp-notification-service/utils/polygon.js +54 -0
  101. package/services/migration-service/scripts/MigrateTransactionHistoryBridge.d.ts +4 -0
  102. package/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +29 -0
  103. package/services/migration-service/scripts/index.js +3 -1
  104. package/services/setting-service/SettingService.d.ts +9 -0
  105. package/services/setting-service/SettingService.js +21 -0
  106. package/services/setting-service/constants.js +2 -1
  107. package/services/storage-service/DatabaseService.d.ts +1 -0
  108. package/services/storage-service/DatabaseService.js +3 -0
  109. package/services/transaction-service/index.js +14 -8
  110. package/services/transaction-service/utils.js +3 -0
  111. package/stores/ChainlistStore.d.ts +7 -0
  112. package/stores/ChainlistStore.js +10 -0
  113. package/stores/EnvironmentStore.d.ts +5 -0
  114. package/stores/EnvironmentStore.js +10 -0
  115. package/stores/index.d.ts +1 -0
  116. package/stores/index.js +2 -1
  117. package/types/{avail-bridge → bridge}/index.d.ts +1 -1
  118. package/types/index.d.ts +1 -0
  119. package/types/index.js +1 -0
  120. package/types/notification/index.d.ts +5 -0
  121. package/utils/account/transform.js +1 -1
  122. package/utils/environment.d.ts +6 -0
  123. package/utils/environment.js +8 -0
  124. package/utils/staticData/blockedActions.json +1 -0
  125. package/utils/staticData/index.d.ts +7 -3
  126. package/utils/staticData/index.js +5 -1
  127. package/cjs/constants/blocked-actions-list.js +0 -14
  128. package/constants/blocked-actions-list.d.ts +0 -7
  129. package/constants/blocked-actions-list.js +0 -7
  130. package/services/inapp-notification-service/utils.d.ts +0 -55
  131. /package/cjs/types/{avail-bridge → bridge}/index.js +0 -0
  132. /package/types/{avail-bridge → bridge}/index.js +0 -0
@@ -0,0 +1,29 @@
1
+ import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
2
+ export interface BlockedActionsFeaturesMap {
3
+ blockedActionsMap: Record<ExtrinsicType, string[]>;
4
+ blockedFeaturesList: string[];
5
+ }
6
+ export declare const APP_ENV: string;
7
+ export declare const APP_VER: string;
8
+ export interface EnvConfig {
9
+ appConfig?: AppConfig;
10
+ browserConfig?: BrowserConfig;
11
+ osConfig?: OSConfig;
12
+ }
13
+ export interface AppConfig {
14
+ environment: string;
15
+ version?: string;
16
+ }
17
+ export interface BrowserConfig {
18
+ type: string;
19
+ version?: string;
20
+ }
21
+ export interface OSConfig {
22
+ type: string;
23
+ version?: string;
24
+ }
25
+ declare type BlockedConfigObjects = Record<string, EnvConfig>;
26
+ export declare function fetchBlockedConfigObjects(): Promise<BlockedConfigObjects>;
27
+ export declare function getPassConfigId(currentConfig: EnvConfig, blockedConfigObjects: BlockedConfigObjects): string[];
28
+ export declare function fetchLastestBlockedActionsAndFeatures(ids: string[]): Promise<BlockedActionsFeaturesMap[]>;
29
+ export {};
@@ -0,0 +1,96 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { packageInfo } from '@subwallet/extension-base';
5
+ import { fetchStaticData } from '@subwallet/extension-base/utils';
6
+ import { staticData, StaticKey } from '@subwallet/extension-base/utils/staticData';
7
+ export const APP_ENV = process.env.TARGET_ENV;
8
+ export const APP_VER = packageInfo.version;
9
+ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
10
+ const branchName = process.env.BRANCH_NAME || 'koni-dev';
11
+ const targetFolder = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list' : 'preview';
12
+ export async function fetchBlockedConfigObjects() {
13
+ const targetFile = `${targetFolder}/envConfig.json`;
14
+ return await fetchStaticData('blocked-actions', targetFile);
15
+ }
16
+ export function getPassConfigId(currentConfig, blockedConfigObjects) {
17
+ const passList = [];
18
+ Object.entries(blockedConfigObjects).forEach(([key, appliedConfig]) => {
19
+ let passAppConfig = false;
20
+ let passBrowserConfig = false;
21
+ let passOSConfig = false;
22
+ if (!appliedConfig.appConfig || !currentConfig.appConfig) {
23
+ passAppConfig = true;
24
+ } else {
25
+ const isPassEnv = currentConfig.appConfig.environment === appliedConfig.appConfig.environment;
26
+ const isPassVer = isPassVersion(currentConfig.appConfig.version, appliedConfig.appConfig.version);
27
+ passAppConfig = isPassEnv && isPassVer;
28
+ }
29
+ if (!appliedConfig.browserConfig || !currentConfig.browserConfig) {
30
+ passBrowserConfig = true;
31
+ } else {
32
+ const isPassType = currentConfig.browserConfig.type === appliedConfig.browserConfig.type;
33
+ const isPassVer = isPassVersion(currentConfig.browserConfig.version, appliedConfig.browserConfig.version);
34
+ passBrowserConfig = isPassType && isPassVer;
35
+ }
36
+ if (!appliedConfig.osConfig || !currentConfig.osConfig) {
37
+ passOSConfig = true;
38
+ } else {
39
+ const isPassType = currentConfig.osConfig.type === appliedConfig.osConfig.type;
40
+ const isPassVer = isPassVersion(currentConfig.osConfig.version, appliedConfig.osConfig.version);
41
+ passOSConfig = isPassType && isPassVer;
42
+ }
43
+ if (passAppConfig && passBrowserConfig && passOSConfig) {
44
+ passList.push(key);
45
+ }
46
+ });
47
+ return passList;
48
+ }
49
+ function isPassVersion(versionStr, versionCondition) {
50
+ // todo: check if has case versionStr = undefined?
51
+ const versionArr = versionStr.split('.');
52
+ if (!versionCondition) {
53
+ return true;
54
+ }
55
+ if (versionCondition.includes('>=')) {
56
+ const versionConditionStr = versionCondition.replace('>=', '').trim();
57
+ const versionConditionArr = versionConditionStr.split('.'); // todo: map(Number) instead of parseInt later
58
+
59
+ if (versionConditionStr === versionStr) {
60
+ return true;
61
+ }
62
+ for (let i = 0; i < versionArr.length; i++) {
63
+ if (parseInt(versionArr[i]) < parseInt(versionConditionArr[i])) {
64
+ return false;
65
+ }
66
+ if (parseInt(versionArr[i]) > parseInt(versionConditionArr[i])) {
67
+ return true;
68
+ }
69
+ }
70
+ return true;
71
+ }
72
+ if (versionCondition.includes('>')) {
73
+ const versionConditionArr = versionCondition.replace('>', '').trim().split('.');
74
+ for (let i = 0; i < versionArr.length; i++) {
75
+ if (parseInt(versionArr[i]) < parseInt(versionConditionArr[i])) {
76
+ return false;
77
+ }
78
+ if (parseInt(versionArr[i]) > parseInt(versionConditionArr[i])) {
79
+ return true;
80
+ }
81
+ }
82
+ return false;
83
+ }
84
+
85
+ // todo: also handle less use cases: <, <=
86
+
87
+ const versionConditionStr = versionCondition.trim();
88
+ return versionStr === versionConditionStr;
89
+ }
90
+ export async function fetchLastestBlockedActionsAndFeatures(ids) {
91
+ if (ids.length === 0) {
92
+ return [staticData[StaticKey.BLOCKED_ACTIONS_FEATURES]];
93
+ }
94
+ const targetFiles = ids.map(id => `${targetFolder}/${id}.json`);
95
+ return await Promise.all(targetFiles.map(targetFile => fetchStaticData('blocked-actions', targetFile)));
96
+ }
@@ -35,7 +35,7 @@ export declare const NETWORK_MULTI_GAS_FEE: string[];
35
35
  export declare const ORDINAL_COLLECTION = "__Ordinal__";
36
36
  export declare const ORDINAL_METHODS: string[];
37
37
  export declare const PERMISSIONS_TO_REVOKE: string[];
38
- export * from './blocked-actions-list';
38
+ export * from './blocked-actions';
39
39
  export * from './environment';
40
40
  export * from './signing';
41
41
  export * from './staking';
@@ -37,7 +37,7 @@ export const NETWORK_MULTI_GAS_FEE = ['*'];
37
37
  export const ORDINAL_COLLECTION = '__Ordinal__';
38
38
  export const ORDINAL_METHODS = ['drc-20', 'pol-20'];
39
39
  export const PERMISSIONS_TO_REVOKE = ['eth_accounts'];
40
- export * from "./blocked-actions-list.js";
40
+ export * from "./blocked-actions.js";
41
41
  export * from "./environment.js";
42
42
  export * from "./signing.js";
43
43
  export * from "./staking.js";
@@ -53,4 +53,5 @@ export declare function _isXcmWithinSameConsensus(originChainInfo: _ChainInfo, d
53
53
  export declare function _isSnowBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
54
54
  export declare function _isAvailBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
55
55
  export declare function _isMythosFromHydrationToMythos(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): boolean;
56
- export declare function _adaptX1Interior(assetIdentifier: Record<string, any>, version: number): Record<string, any>;
56
+ export declare function _isPolygonBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
57
+ export declare function _adaptX1Interior(_assetIdentifier: Record<string, any>, version: number): Record<string, any>;
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
5
5
  import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
6
+ import { _isPolygonChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
6
7
  import { _getChainSubstrateAddressPrefix, _getEvmChainId, _getSubstrateParaId, _getSubstrateRelayParent, _getXcmAssetMultilocation, _isChainEvmCompatible, _isPureEvmChain, _isSubstrateParaChain } from '@subwallet/extension-base/services/chain-service/utils';
7
8
  import { decodeAddress, evmToAddress } from '@polkadot/util-crypto';
8
9
  const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
@@ -48,7 +49,7 @@ export function _getXcmMultiLocation(originChainInfo, destChainInfo, version, re
48
49
  };
49
50
  }
50
51
  export function _isXcmTransferUnstable(originChainInfo, destChainInfo, assetSlug) {
51
- return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug);
52
+ return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo);
52
53
  }
53
54
  function getAssetHubBridgeUnstableWarning(originChainInfo) {
54
55
  switch (originChainInfo.slug) {
@@ -76,8 +77,17 @@ function getMythosFromHydrationToMythosWarning() {
76
77
  function getAvailBridgeWarning() {
77
78
  return 'Cross-chain transfer of this token may take up to 90 minutes, and you’ll need to manually claim the funds on the destination network to complete the transfer. Do you still want to continue?';
78
79
  }
80
+ function getPolygonBridgeWarning(originChainInfo) {
81
+ if (originChainInfo.slug === COMMON_CHAIN_SLUGS.ETHEREUM || originChainInfo.slug === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
82
+ return 'Cross-chain transfer of this token may take up to 40 minutes. Do you still want to continue?';
83
+ } else {
84
+ return 'Cross-chain transfer of this token may take up to 3 hours, and you’ll need to manually claim the funds on the destination network to complete the transfer. Do you still want to continue?';
85
+ }
86
+ }
79
87
  export function _getXcmUnstableWarning(originChainInfo, destChainInfo, assetSlug) {
80
- if (_isAvailBridgeXcm(originChainInfo, destChainInfo)) {
88
+ if (_isPolygonBridgeXcm(originChainInfo, destChainInfo)) {
89
+ return getPolygonBridgeWarning(originChainInfo);
90
+ } else if (_isAvailBridgeXcm(originChainInfo, destChainInfo)) {
81
91
  return getAvailBridgeWarning();
82
92
  } else if (_isSnowBridgeXcm(originChainInfo, destChainInfo)) {
83
93
  return getSnowBridgeUnstableWarning(originChainInfo);
@@ -101,6 +111,9 @@ export function _isAvailBridgeXcm(originChainInfo, destChainInfo) {
101
111
  export function _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) {
102
112
  return originChainInfo.slug === 'hydradx_main' && destChainInfo.slug === 'mythos' && assetSlug === 'hydradx_main-LOCAL-MYTH';
103
113
  }
114
+ export function _isPolygonBridgeXcm(originChainInfo, destChainInfo) {
115
+ return _isPolygonChainBridge(originChainInfo.slug, destChainInfo.slug);
116
+ }
104
117
 
105
118
  // ---------------------------------------------------------------------------------------------------------------------
106
119
 
@@ -215,17 +228,18 @@ function _getAssetIdentifier(tokenInfo, version) {
215
228
  throw new Error('Asset must have multilocation');
216
229
  }
217
230
  const assetIdentifier = ['statemint-LOCAL-KSM', 'statemine-LOCAL-DOT'].includes(tokenInfo.slug) // todo: hotfix for ksm statemint recheck all chain
218
- ? _assetIdentifier : _adaptX1Interior(structuredClone(_assetIdentifier), version);
231
+ ? _assetIdentifier : _adaptX1Interior(_assetIdentifier, version);
219
232
  return version >= 4 // from V4, Concrete is removed
220
233
  ? assetIdentifier : {
221
234
  Concrete: assetIdentifier
222
235
  };
223
236
  }
224
- export function _adaptX1Interior(assetIdentifier, version) {
237
+ export function _adaptX1Interior(_assetIdentifier, version) {
238
+ const assetIdentifier = structuredClone(_assetIdentifier);
225
239
  const interior = assetIdentifier.interior;
226
240
  const isInteriorObj = typeof interior === 'object' && interior !== null;
227
241
  const isX1 = isInteriorObj && 'X1' in interior;
228
- const needModifyX1 = version <= 4 && Array.isArray(interior.X1);
242
+ const needModifyX1 = version < 4 && Array.isArray(interior.X1);
229
243
  if (isInteriorObj && isX1 && needModifyX1) {
230
244
  // X1 is an object for version < 4. From V4, it's an array
231
245
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
@@ -11,7 +11,9 @@ export declare const _AZERO_DOMAIN_REGISTRY_ABI: Record<string, any>;
11
11
  export declare const _SNOWBRIDGE_GATEWAY_ABI: Record<string, any>;
12
12
  export declare const _AVAIL_BRIDGE_GATEWAY_ABI: Record<string, any>;
13
13
  export declare const _AVAIL_TEST_BRIDGE_GATEWAY_ABI: Record<string, any>;
14
+ export declare const _POLYGON_BRIDGE_ABI: Record<string, any>;
14
15
  export declare function getSnowBridgeGatewayContract(chain: string): "0x27ca963C279c93801941e1eB8799c23f407d68e7" | "0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd";
15
16
  export declare function isSnowBridgeGatewayContract(contractAddress: _Address): boolean;
16
17
  export declare function getAvailBridgeGatewayContract(chain: string): "0x054fd961708D8E2B9c10a63F6157c74458889F0a" | "0x967F7DdC4ec508462231849AE81eeaa68Ad01389";
17
18
  export declare function isAvailBridgeGatewayContract(contractAddress: _Address): boolean;
19
+ export declare function getPolygonBridgeContract(chain: string): string;
@@ -24,6 +24,8 @@ export const _SNOWBRIDGE_GATEWAY_ABI = require("./snowbridge_gateway_abi.json");
24
24
  export const _AVAIL_BRIDGE_GATEWAY_ABI = require("./avail_bridge_abi.json");
25
25
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
26
26
  export const _AVAIL_TEST_BRIDGE_GATEWAY_ABI = require("./avail_test_bridge_abi.json");
27
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
28
+ export const _POLYGON_BRIDGE_ABI = require("./polygon_bridge_abi.json");
27
29
  const SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x27ca963C279c93801941e1eB8799c23f407d68e7';
28
30
  const SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd';
29
31
  export function getSnowBridgeGatewayContract(chain) {
@@ -45,4 +47,14 @@ export function getAvailBridgeGatewayContract(chain) {
45
47
  }
46
48
  export function isAvailBridgeGatewayContract(contractAddress) {
47
49
  return [AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
50
+ }
51
+ const POLYGONBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe';
52
+ const POLYGONBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582';
53
+ export function getPolygonBridgeContract(chain) {
54
+ if (chain === 'polygonzkEvm_cardona' || chain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
55
+ return POLYGONBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS;
56
+ } else if (chain === 'polygonZkEvm' || chain === COMMON_CHAIN_SLUGS.ETHEREUM) {
57
+ return POLYGONBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS;
58
+ }
59
+ throw new Error('Invalid chain');
48
60
  }