@subwallet/extension-base 1.3.7-0 → 1.3.9-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.
- package/background/KoniTypes.d.ts +11 -5
- package/background/KoniTypes.js +1 -1
- package/cjs/background/KoniTypes.js +1 -1
- package/cjs/core/logic-validation/transfer.js +35 -24
- package/cjs/core/substrate/system-pallet.js +1 -1
- package/cjs/core/substrate/xcm-parser.js +16 -2
- package/cjs/core/utils.js +2 -2
- package/cjs/koni/api/contract-handler/utils/index.js +15 -1
- package/cjs/koni/background/handlers/Extension.js +158 -86
- package/cjs/koni/background/handlers/State.js +11 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/index.js +24 -2
- package/cjs/services/balance-service/transfer/smart-contract.js +16 -5
- package/cjs/services/balance-service/transfer/xcm/index.js +31 -1
- package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +108 -0
- package/cjs/services/chain-online-service/constants.js +32 -0
- package/cjs/services/chain-online-service/index.js +190 -0
- package/cjs/services/chain-service/constants.js +3 -1
- package/cjs/services/chain-service/index.js +87 -127
- package/cjs/services/chain-service/utils/index.js +0 -2
- package/cjs/services/chain-service/utils/patch.js +7 -3
- package/cjs/services/fee-service/utils/index.js +14 -0
- package/cjs/services/inapp-notification-service/consts.js +6 -4
- package/cjs/services/inapp-notification-service/index.js +110 -6
- package/cjs/services/inapp-notification-service/interfaces.js +9 -1
- package/cjs/services/inapp-notification-service/utils/avail.js +88 -0
- package/cjs/services/inapp-notification-service/{utils.js → utils/common.js} +1 -84
- package/cjs/services/inapp-notification-service/utils/index.js +38 -0
- package/cjs/services/inapp-notification-service/utils/polygon.js +66 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +37 -0
- package/cjs/services/migration-service/scripts/index.js +3 -1
- package/cjs/services/setting-service/SettingService.js +8 -0
- package/cjs/services/setting-service/constants.js +2 -1
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/stores/ChainlistStore.js +18 -0
- package/cjs/types/index.js +11 -0
- package/cjs/types/transaction/error.js +1 -0
- package/cjs/utils/account/transform.js +1 -1
- package/core/logic-validation/transfer.d.ts +2 -1
- package/core/logic-validation/transfer.js +36 -25
- package/core/substrate/system-pallet.js +1 -1
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +15 -2
- package/core/types.d.ts +1 -0
- package/core/utils.js +2 -2
- package/koni/api/contract-handler/utils/index.d.ts +2 -0
- package/koni/api/contract-handler/utils/index.js +12 -0
- package/koni/api/contract-handler/utils/polygon_bridge_abi.json +1004 -0
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +93 -22
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +11 -2
- package/package.json +56 -14
- package/packageInfo.js +1 -1
- package/services/balance-service/index.d.ts +3 -0
- package/services/balance-service/index.js +21 -2
- package/services/balance-service/transfer/smart-contract.js +16 -5
- package/services/balance-service/transfer/xcm/index.d.ts +1 -0
- package/services/balance-service/transfer/xcm/index.js +29 -1
- package/services/balance-service/transfer/xcm/polygonBridge.d.ts +22 -0
- package/services/balance-service/transfer/xcm/polygonBridge.js +95 -0
- package/services/chain-online-service/constants.d.ts +4 -0
- package/services/chain-online-service/constants.js +23 -0
- package/services/chain-online-service/index.d.ts +22 -0
- package/services/chain-online-service/index.js +182 -0
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +1 -0
- package/services/chain-service/index.d.ts +6 -7
- package/services/chain-service/index.js +78 -116
- package/services/chain-service/utils/index.js +0 -2
- package/services/chain-service/utils/patch.d.ts +16 -1
- package/services/chain-service/utils/patch.js +7 -3
- package/services/fee-service/utils/index.js +14 -0
- package/services/inapp-notification-service/consts.d.ts +3 -1
- package/services/inapp-notification-service/consts.js +6 -4
- package/services/inapp-notification-service/index.d.ts +10 -2
- package/services/inapp-notification-service/index.js +111 -7
- package/services/inapp-notification-service/interfaces.d.ts +27 -3
- package/services/inapp-notification-service/interfaces.js +7 -0
- package/services/inapp-notification-service/utils/avail.d.ts +40 -0
- package/services/inapp-notification-service/utils/avail.js +73 -0
- package/services/inapp-notification-service/utils/common.d.ts +11 -0
- package/services/inapp-notification-service/{utils.js → utils/common.js} +1 -72
- package/services/inapp-notification-service/utils/index.d.ts +3 -0
- package/services/inapp-notification-service/utils/index.js +6 -0
- package/services/inapp-notification-service/utils/polygon.d.ts +71 -0
- package/services/inapp-notification-service/utils/polygon.js +54 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBridge.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +29 -0
- package/services/migration-service/scripts/index.js +3 -1
- package/services/setting-service/SettingService.d.ts +4 -0
- package/services/setting-service/SettingService.js +8 -0
- package/services/setting-service/constants.js +2 -1
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/transaction-service/index.js +1 -1
- package/stores/ChainlistStore.d.ts +7 -0
- package/stores/ChainlistStore.js +10 -0
- package/types/{avail-bridge → bridge}/index.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/notification/index.d.ts +5 -0
- package/types/transaction/error.d.ts +2 -1
- package/types/transaction/error.js +1 -0
- package/utils/account/transform.js +1 -1
- package/services/inapp-notification-service/utils.d.ts +0 -55
- /package/cjs/types/{avail-bridge → bridge}/index.js +0 -0
- /package/types/{avail-bridge → bridge}/index.js +0 -0
|
@@ -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 (
|
|
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
|
|
package/core/types.d.ts
CHANGED
package/core/utils.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
-
import { LEDGER_GENERIC_ALLOW_NETWORKS } from '@subwallet/extension-base/core/consts';
|
|
6
5
|
import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
|
|
7
6
|
import { tonAddressInfo } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
|
|
8
7
|
import { _isChainEvmCompatible, _isChainSubstrateCompatible, _isChainTonCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
@@ -99,6 +98,7 @@ export function _isNotDuplicateAddress(validateRecipientParams) {
|
|
|
99
98
|
export function _isSupportLedgerAccount(validateRecipientParams) {
|
|
100
99
|
const {
|
|
101
100
|
account,
|
|
101
|
+
allowLedgerGenerics,
|
|
102
102
|
destChainInfo
|
|
103
103
|
} = validateRecipientParams;
|
|
104
104
|
if (account !== null && account !== void 0 && account.isHardware) {
|
|
@@ -113,7 +113,7 @@ export function _isSupportLedgerAccount(validateRecipientParams) {
|
|
|
113
113
|
} else {
|
|
114
114
|
// For ledger generic
|
|
115
115
|
const ledgerCheck = ledgerMustCheckNetwork(account);
|
|
116
|
-
if (ledgerCheck !== 'unnecessary' && !
|
|
116
|
+
if (ledgerCheck !== 'unnecessary' && !allowLedgerGenerics.includes(destChainInfo.slug)) {
|
|
117
117
|
return `Ledger ${ledgerCheck === 'polkadot' ? 'Polkadot' : 'Migration'} address is not supported for this transfer`;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -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
|
}
|