@subwallet/extension-base 1.3.7-0 → 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.
- package/background/KoniTypes.d.ts +7 -5
- package/background/KoniTypes.js +1 -1
- package/cjs/background/KoniTypes.js +1 -1
- package/cjs/core/substrate/xcm-parser.js +16 -2
- package/cjs/koni/api/contract-handler/utils/index.js +15 -1
- package/cjs/koni/background/handlers/Extension.js +42 -3
- package/cjs/koni/background/handlers/State.js +11 -2
- package/cjs/packageInfo.js +1 -1
- 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/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/utils/account/transform.js +1 -1
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +15 -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 +2 -0
- package/koni/background/handlers/Extension.js +43 -4
- 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/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/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/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
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AssetLogoMap, ChainLogoMap } from '@subwallet/chain-list';
|
|
5
|
+
import { LATEST_CHAIN_PATCH_FETCHING_INTERVAL, md5HashChainAsset, md5HashChainInfo } from '@subwallet/extension-base/services/chain-online-service/constants';
|
|
6
|
+
import { filterAssetInfoMap } from '@subwallet/extension-base/services/chain-service';
|
|
7
|
+
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
8
|
+
import { fetchPatchData, randomizeProvider } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
+
export class ChainOnlineService {
|
|
10
|
+
constructor(chainService, settingService, eventService, dbService) {
|
|
11
|
+
this.chainService = chainService;
|
|
12
|
+
this.settingService = settingService;
|
|
13
|
+
this.eventService = eventService;
|
|
14
|
+
this.dbService = dbService;
|
|
15
|
+
this.firstApplied = false;
|
|
16
|
+
}
|
|
17
|
+
validatePatchWithHash(latestPatch) {
|
|
18
|
+
const {
|
|
19
|
+
ChainAsset,
|
|
20
|
+
ChainAssetHashMap,
|
|
21
|
+
ChainInfo,
|
|
22
|
+
ChainInfoHashMap
|
|
23
|
+
} = latestPatch;
|
|
24
|
+
for (const [chainSlug, chain] of Object.entries(ChainInfo)) {
|
|
25
|
+
if (md5HashChainInfo(chain) !== ChainInfoHashMap[chainSlug]) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const [assetSlug, asset] of Object.entries(ChainAsset)) {
|
|
30
|
+
if (md5HashChainAsset(asset) !== ChainAssetHashMap[assetSlug]) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
validatePatchBeforeStore(candidateChainInfoMap, candidateAssetRegistry, latestPatch) {
|
|
37
|
+
for (const [chainSlug, chainHash] of Object.entries(latestPatch.ChainInfoHashMap)) {
|
|
38
|
+
if (md5HashChainInfo(candidateChainInfoMap[chainSlug]) !== chainHash) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const [assetSlug, assetHash] of Object.entries(latestPatch.ChainAssetHashMap)) {
|
|
43
|
+
if (!candidateAssetRegistry[assetSlug]) {
|
|
44
|
+
if (!latestPatch.ChainInfo[assetSlug]) {
|
|
45
|
+
// assets are not existed in case chain is removed
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (md5HashChainAsset(candidateAssetRegistry[assetSlug]) !== assetHash) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
async handleLatestPatch(latestPatch) {
|
|
57
|
+
try {
|
|
58
|
+
var _await$this$settingSe;
|
|
59
|
+
// 1. validate fetch data with its hash
|
|
60
|
+
const isSafePatch = this.validatePatchWithHash(latestPatch);
|
|
61
|
+
const {
|
|
62
|
+
AssetLogoMap: latestAssetLogoMap,
|
|
63
|
+
ChainAsset: latestAssetInfo,
|
|
64
|
+
ChainInfo: latestChainInfo,
|
|
65
|
+
ChainLogoMap: latestChainLogoMap,
|
|
66
|
+
patchVersion: latestPatchVersion
|
|
67
|
+
} = latestPatch;
|
|
68
|
+
const currentPatchVersion = ((_await$this$settingSe = await this.settingService.getChainlistSetting()) === null || _await$this$settingSe === void 0 ? void 0 : _await$this$settingSe.patchVersion) || '';
|
|
69
|
+
const oldChainInfoMap = structuredClone(this.chainService.getChainInfoMap());
|
|
70
|
+
const oldAssetRegistry = structuredClone(this.chainService.getAssetRegistry());
|
|
71
|
+
let chainInfoMap = structuredClone(this.chainService.getChainInfoMap());
|
|
72
|
+
let assetRegistry = structuredClone(this.chainService.getAssetRegistry());
|
|
73
|
+
const currentChainStateMap = structuredClone(this.chainService.getChainStateMap());
|
|
74
|
+
const currentChainStatusMap = structuredClone(this.chainService.getChainStatusMap());
|
|
75
|
+
let addedChain = [];
|
|
76
|
+
if (isSafePatch && (!this.firstApplied || currentPatchVersion !== latestPatchVersion)) {
|
|
77
|
+
this.firstApplied = true;
|
|
78
|
+
|
|
79
|
+
// 2. merge data map
|
|
80
|
+
if (latestChainInfo && Object.keys(latestChainInfo).length > 0) {
|
|
81
|
+
chainInfoMap = Object.assign({}, oldChainInfoMap, latestChainInfo);
|
|
82
|
+
const [currentChainStateKey, newChainKey] = [Object.keys(currentChainStateMap), Object.keys(chainInfoMap)];
|
|
83
|
+
addedChain = newChainKey.filter(chain => !currentChainStateKey.includes(chain));
|
|
84
|
+
addedChain.forEach(key => {
|
|
85
|
+
currentChainStateMap[key] = {
|
|
86
|
+
active: false,
|
|
87
|
+
currentProvider: randomizeProvider(chainInfoMap[key].providers).providerKey,
|
|
88
|
+
manualTurnOff: false,
|
|
89
|
+
slug: key
|
|
90
|
+
};
|
|
91
|
+
currentChainStatusMap[key] = {
|
|
92
|
+
slug: key,
|
|
93
|
+
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
94
|
+
lastUpdated: Date.now()
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (latestAssetInfo && Object.keys(latestAssetInfo).length > 0) {
|
|
99
|
+
assetRegistry = filterAssetInfoMap(oldChainInfoMap, Object.assign({}, oldAssetRegistry, latestAssetInfo), addedChain);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 3. validate data before write
|
|
103
|
+
const isCorrectPatch = this.validatePatchBeforeStore(chainInfoMap, assetRegistry, latestPatch);
|
|
104
|
+
|
|
105
|
+
// 4. write to subject
|
|
106
|
+
if (isCorrectPatch) {
|
|
107
|
+
this.chainService.setChainInfoMap(chainInfoMap);
|
|
108
|
+
this.chainService.subscribeChainInfoMap().next(chainInfoMap);
|
|
109
|
+
this.chainService.setAssetRegistry(assetRegistry);
|
|
110
|
+
this.chainService.subscribeAssetRegistry().next(assetRegistry);
|
|
111
|
+
this.chainService.autoEnableTokens().then(() => {
|
|
112
|
+
this.eventService.emit('asset.updateState', '');
|
|
113
|
+
}).catch(console.error);
|
|
114
|
+
this.chainService.setChainStateMap(currentChainStateMap);
|
|
115
|
+
this.chainService.subscribeChainStateMap().next(currentChainStateMap);
|
|
116
|
+
this.chainService.subscribeChainStatusMap().next(currentChainStatusMap);
|
|
117
|
+
const storedChainInfoList = Object.keys(chainInfoMap).map(chainSlug => {
|
|
118
|
+
return {
|
|
119
|
+
...chainInfoMap[chainSlug],
|
|
120
|
+
...currentChainStateMap[chainSlug]
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
await this.dbService.bulkUpdateChainStore(storedChainInfoList);
|
|
124
|
+
const addedAssets = [];
|
|
125
|
+
|
|
126
|
+
// todo: the stored asset is lack of adding new assets and edited assets of old chain, update to tracking exactly updated assets from patch online.
|
|
127
|
+
Object.entries(assetRegistry).forEach(([slug, asset]) => {
|
|
128
|
+
if (addedChain.includes(asset.originChain)) {
|
|
129
|
+
addedAssets.push(asset);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
await this.dbService.bulkUpdateAssetsStore(addedAssets);
|
|
133
|
+
if (latestChainLogoMap) {
|
|
134
|
+
const logoMap = Object.assign({}, ChainLogoMap, latestChainLogoMap);
|
|
135
|
+
this.chainService.subscribeChainLogoMap().next(logoMap);
|
|
136
|
+
}
|
|
137
|
+
if (latestAssetLogoMap) {
|
|
138
|
+
const logoMap = Object.assign({}, AssetLogoMap, latestAssetLogoMap);
|
|
139
|
+
this.chainService.subscribeAssetLogoMap().next(logoMap);
|
|
140
|
+
}
|
|
141
|
+
this.settingService.setChainlist({
|
|
142
|
+
patchVersion: latestPatchVersion
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} catch (e) {
|
|
147
|
+
console.error('Error fetching latest patch data');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async fetchLatestPatchData() {
|
|
151
|
+
return await fetchPatchData();
|
|
152
|
+
}
|
|
153
|
+
handleLatestPatchData() {
|
|
154
|
+
this.fetchLatestPatchData().then(latestPatch => {
|
|
155
|
+
return new Promise(resolve => {
|
|
156
|
+
if (latestPatch && !this.chainService.getlockChainInfoMap()) {
|
|
157
|
+
this.eventService.waitAssetReady.then(() => {
|
|
158
|
+
this.chainService.setLockChainInfoMap(true);
|
|
159
|
+
this.handleLatestPatch(latestPatch).then(() => this.chainService.setLockChainInfoMap(false)).catch(e => {
|
|
160
|
+
this.chainService.setLockChainInfoMap(false);
|
|
161
|
+
console.error('Error update latest patch', e);
|
|
162
|
+
}).finally(resolve);
|
|
163
|
+
}).catch(e => {
|
|
164
|
+
console.error('Asset fail to ready', e);
|
|
165
|
+
resolve();
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
resolve();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}).catch(e => {
|
|
172
|
+
console.error('Error get latest patch or data map is locking', e);
|
|
173
|
+
}).finally(() => {
|
|
174
|
+
this.eventService.emit('asset.online.ready', true);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
checkLatestData() {
|
|
178
|
+
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
179
|
+
this.handleLatestPatchData();
|
|
180
|
+
this.refreshLatestChainDataTimeOut = setInterval(this.handleLatestPatchData.bind(this), LATEST_CHAIN_PATCH_FETCHING_INTERVAL);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -8,6 +8,7 @@ import { IMetadataItem } from '@subwallet/extension-base/services/storage-servic
|
|
|
8
8
|
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
9
9
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
10
10
|
import { ExtraInfo } from '@polkadot-api/merkleize-metadata';
|
|
11
|
+
export declare const filterAssetInfoMap: (chainInfo: Record<string, _ChainInfo>, assets: Record<string, _ChainAsset>, addedChains?: string[]) => Record<string, _ChainAsset>;
|
|
11
12
|
export declare class ChainService {
|
|
12
13
|
private dataMap;
|
|
13
14
|
private dbService;
|
|
@@ -29,8 +30,6 @@ export declare class ChainService {
|
|
|
29
30
|
private assetLogoMapSubject;
|
|
30
31
|
private chainLogoMapSubject;
|
|
31
32
|
private ledgerGenericAllowChainsSubject;
|
|
32
|
-
private assetMapPatch;
|
|
33
|
-
private assetLogoPatch;
|
|
34
33
|
private store;
|
|
35
34
|
private assetSettingSubject;
|
|
36
35
|
private logger;
|
|
@@ -44,6 +43,8 @@ export declare class ChainService {
|
|
|
44
43
|
subscribeSwapRefMap(): Subject<Record<string, _AssetRef>>;
|
|
45
44
|
get xcmRefMap(): Record<string, _AssetRef>;
|
|
46
45
|
get swapRefMap(): Record<string, _AssetRef>;
|
|
46
|
+
getlockChainInfoMap(): boolean;
|
|
47
|
+
setLockChainInfoMap(isLock: boolean): void;
|
|
47
48
|
getEvmApi(slug: string): import("./handler/EvmApi").EvmApi;
|
|
48
49
|
getEvmApiMap(): Record<string, import("./handler/EvmApi").EvmApi>;
|
|
49
50
|
getSubstrateApi(slug: string): _SubstrateApi;
|
|
@@ -61,16 +62,19 @@ export declare class ChainService {
|
|
|
61
62
|
subscribeChainStateMap(): Subject<Record<string, _ChainState>>;
|
|
62
63
|
subscribeChainStatusMap(): BehaviorSubject<Record<string, _ChainApiStatus>>;
|
|
63
64
|
getAssetRegistry(): Record<string, _ChainAsset>;
|
|
65
|
+
setAssetRegistry(assetRegistry: Record<string, _ChainAsset>): void;
|
|
64
66
|
getMultiChainAssetMap(): Record<string, _MultiChainAsset>;
|
|
65
67
|
getSmartContractTokens(): Record<string, _ChainAsset>;
|
|
66
68
|
getAssetHubToken(): Record<string, _ChainAsset>;
|
|
67
69
|
getChainInfoMap(): Record<string, _ChainInfo>;
|
|
70
|
+
setChainInfoMap(chainInfoMap: Record<string, _ChainInfo>): void;
|
|
68
71
|
getEvmChainInfoMap(): Record<string, _ChainInfo>;
|
|
69
72
|
getSubstrateChainInfoMap(): Record<string, _ChainInfo>;
|
|
70
73
|
getAllPriceIds(): string[];
|
|
71
74
|
getNativeTokenInfo(chainSlug: string): _ChainAsset;
|
|
72
75
|
getAssetRefMap(): Record<string, _AssetRef>;
|
|
73
76
|
getChainStateMap(): Record<string, _ChainState>;
|
|
77
|
+
setChainStateMap(chainStateMap: Record<string, _ChainState>): void;
|
|
74
78
|
getChainStateByKey(key: string): _ChainState;
|
|
75
79
|
getChainStatusMap(): Record<string, _ChainApiStatus>;
|
|
76
80
|
getChainStatusByKey(key: string): _ChainApiStatus;
|
|
@@ -99,9 +103,6 @@ export declare class ChainService {
|
|
|
99
103
|
checkLatestData(): void;
|
|
100
104
|
stopCheckLatestChainData(): void;
|
|
101
105
|
handleLatestChainData(latestChainInfo: _ChainInfo[]): void;
|
|
102
|
-
handleLatestAssetRef(latestBlockedAssetRefList: string[], latestAssetRefMap: Record<string, _AssetRef> | null): void;
|
|
103
|
-
handleLatestPriceId(latestPriceIds: Record<string, string | null>): void;
|
|
104
|
-
handleLatestAssetData(latestAssetInfo: Record<string, _ChainAsset> | null, latestAssetLogoMap: Record<string, string> | null): void;
|
|
105
106
|
autoEnableTokens(): Promise<void>;
|
|
106
107
|
handleLatestLedgerGenericAllowChains(latestledgerGenericAllowChains: string[]): void;
|
|
107
108
|
handleLatestData(): void;
|
|
@@ -115,9 +116,7 @@ export declare class ChainService {
|
|
|
115
116
|
disableChain(chainSlug: string): boolean;
|
|
116
117
|
private checkExistedPredefinedChain;
|
|
117
118
|
private fetchLatestChainData;
|
|
118
|
-
private fetchLatestAssetData;
|
|
119
119
|
private fetchLatestPriceIdsData;
|
|
120
|
-
private fetchLatestAssetRef;
|
|
121
120
|
private fetchLatestLedgerGenericAllowChains;
|
|
122
121
|
private initChains;
|
|
123
122
|
private initAssetRegistry;
|
|
@@ -10,7 +10,7 @@ import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-
|
|
|
10
10
|
import { TonChainHandler } from '@subwallet/extension-base/services/chain-service/handler/TonChainHandler';
|
|
11
11
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
12
12
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
13
|
-
import { _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey,
|
|
13
|
+
import { _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
14
14
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
15
15
|
import { addLazy, calculateMetadataHash, fetchStaticData, filterAssetsByChainAndType, getShortMetadata, MODULE_SUPPORT } from '@subwallet/extension-base/utils';
|
|
16
16
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
@@ -20,26 +20,9 @@ const filterChainInfoMap = (data, ignoredChains) => {
|
|
|
20
20
|
return Object.fromEntries(Object.entries(data).filter(([slug, info]) => !info.bitcoinInfo && !ignoredChains.includes(slug)));
|
|
21
21
|
};
|
|
22
22
|
const ignoredList = ['bevm', 'bevmTest', 'bevm_testnet', 'layerEdge_testnet', 'merlinEvm', 'botanixEvmTest', 'syscoin_evm', 'syscoin_evm_testnet', 'rollux_evm', 'rollux_testnet', 'boolAlpha', 'boolBeta_testnet', 'core', 'satoshivm', 'satoshivm_testnet', 'storyPartner_testnet'];
|
|
23
|
-
const filterAssetInfoMap = (chainInfo, assets) => {
|
|
24
|
-
return Object.fromEntries(Object.entries(assets).filter(([, info]) => chainInfo[info.originChain]));
|
|
23
|
+
export const filterAssetInfoMap = (chainInfo, assets, addedChains) => {
|
|
24
|
+
return Object.fromEntries(Object.entries(assets).filter(([, info]) => chainInfo[info.originChain] || (addedChains === null || addedChains === void 0 ? void 0 : addedChains.includes(info.originChain))));
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
// const rawAssetRefMap = (assetRefMap: Record<string, _AssetRef>) => {
|
|
28
|
-
// const result: Record<string, _AssetRef> = {};
|
|
29
|
-
//
|
|
30
|
-
// Object.entries(assetRefMap).forEach(([key, assetRef]) => {
|
|
31
|
-
// const originChainInfo = ChainInfoMap[assetRef.srcChain];
|
|
32
|
-
// const destChainInfo = ChainInfoMap[assetRef.destChain];
|
|
33
|
-
// const isSnowBridgeXcm = assetRef.path === _AssetRefPath.XCM && _isSnowBridgeXcm(originChainInfo, destChainInfo);
|
|
34
|
-
//
|
|
35
|
-
// if (!isSnowBridgeXcm) {
|
|
36
|
-
// result[key] = assetRef;
|
|
37
|
-
// }
|
|
38
|
-
// });
|
|
39
|
-
//
|
|
40
|
-
// return result;
|
|
41
|
-
// };
|
|
42
|
-
|
|
43
26
|
export class ChainService {
|
|
44
27
|
dataMap = {
|
|
45
28
|
chainInfoMap: {},
|
|
@@ -64,8 +47,6 @@ export class ChainService {
|
|
|
64
47
|
assetLogoMapSubject = new BehaviorSubject(AssetLogoMap);
|
|
65
48
|
chainLogoMapSubject = new BehaviorSubject(ChainLogoMap);
|
|
66
49
|
ledgerGenericAllowChainsSubject = new BehaviorSubject([]);
|
|
67
|
-
assetMapPatch = JSON.stringify({});
|
|
68
|
-
assetLogoPatch = JSON.stringify({});
|
|
69
50
|
|
|
70
51
|
// Todo: Update to new store indexed DB
|
|
71
52
|
store = new AssetSettingStore();
|
|
@@ -126,6 +107,12 @@ export class ChainService {
|
|
|
126
107
|
});
|
|
127
108
|
return result;
|
|
128
109
|
}
|
|
110
|
+
getlockChainInfoMap() {
|
|
111
|
+
return this.lockChainInfoMap;
|
|
112
|
+
}
|
|
113
|
+
setLockChainInfoMap(isLock) {
|
|
114
|
+
this.lockChainInfoMap = isLock;
|
|
115
|
+
}
|
|
129
116
|
getEvmApi(slug) {
|
|
130
117
|
return this.evmChainHandler.getEvmApiByChain(slug);
|
|
131
118
|
}
|
|
@@ -174,6 +161,9 @@ export class ChainService {
|
|
|
174
161
|
getAssetRegistry() {
|
|
175
162
|
return this.dataMap.assetRegistry;
|
|
176
163
|
}
|
|
164
|
+
setAssetRegistry(assetRegistry) {
|
|
165
|
+
this.dataMap.assetRegistry = assetRegistry;
|
|
166
|
+
}
|
|
177
167
|
getMultiChainAssetMap() {
|
|
178
168
|
return MultiChainAssetMap;
|
|
179
169
|
}
|
|
@@ -198,6 +188,9 @@ export class ChainService {
|
|
|
198
188
|
getChainInfoMap() {
|
|
199
189
|
return this.dataMap.chainInfoMap;
|
|
200
190
|
}
|
|
191
|
+
setChainInfoMap(chainInfoMap) {
|
|
192
|
+
this.dataMap.chainInfoMap = chainInfoMap;
|
|
193
|
+
}
|
|
201
194
|
getEvmChainInfoMap() {
|
|
202
195
|
const result = {};
|
|
203
196
|
Object.values(this.getChainInfoMap()).forEach(chainInfo => {
|
|
@@ -254,6 +247,9 @@ export class ChainService {
|
|
|
254
247
|
getChainStateMap() {
|
|
255
248
|
return this.dataMap.chainStateMap;
|
|
256
249
|
}
|
|
250
|
+
setChainStateMap(chainStateMap) {
|
|
251
|
+
this.dataMap.chainStateMap = chainStateMap;
|
|
252
|
+
}
|
|
257
253
|
getChainStateByKey(key) {
|
|
258
254
|
return this.dataMap.chainStateMap[key];
|
|
259
255
|
}
|
|
@@ -498,10 +494,10 @@ export class ChainService {
|
|
|
498
494
|
await this.initChains();
|
|
499
495
|
this.chainInfoMapSubject.next(this.getChainInfoMap());
|
|
500
496
|
this.assetRegistrySubject.next(this.getAssetRegistry());
|
|
497
|
+
this.initAssetRefMap();
|
|
501
498
|
this.xcmRefMapSubject.next(this.xcmRefMap);
|
|
502
499
|
await this.initApis();
|
|
503
500
|
await this.initAssetSettings();
|
|
504
|
-
this.initAssetRefMap();
|
|
505
501
|
await this.autoEnableTokens();
|
|
506
502
|
}
|
|
507
503
|
initAssetRefMap() {
|
|
@@ -534,79 +530,25 @@ export class ChainService {
|
|
|
534
530
|
console.error('Error fetching latest chain data');
|
|
535
531
|
}
|
|
536
532
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
Object.entries(latestPriceIds).forEach(([slug, priceId]) => {
|
|
557
|
-
if (this.dataMap.assetRegistry[slug] && this.dataMap.assetRegistry[slug].priceId !== priceId) {
|
|
558
|
-
isUpdated = true;
|
|
559
|
-
this.dataMap.assetRegistry[slug].priceId = priceId;
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
if (isUpdated) {
|
|
563
|
-
this.assetRegistrySubject.next(this.dataMap.assetRegistry);
|
|
564
|
-
this.eventService.emit('asset.updateState', '');
|
|
565
|
-
}
|
|
566
|
-
this.logger.log('Finished updating latest price IDs');
|
|
567
|
-
}
|
|
568
|
-
handleLatestAssetData(latestAssetInfo, latestAssetLogoMap) {
|
|
569
|
-
try {
|
|
570
|
-
if (latestAssetInfo) {
|
|
571
|
-
const latestAssetPatch = JSON.stringify(latestAssetInfo);
|
|
572
|
-
if (this.assetMapPatch !== latestAssetPatch) {
|
|
573
|
-
const assetRegistry = filterAssetInfoMap(this.getChainInfoMap(), Object.assign({}, this.dataMap.assetRegistry, latestAssetInfo));
|
|
574
|
-
this.assetMapPatch = latestAssetPatch;
|
|
575
|
-
this.dataMap.assetRegistry = assetRegistry;
|
|
576
|
-
this.assetRegistrySubject.next(assetRegistry);
|
|
577
|
-
this.autoEnableTokens().then(() => {
|
|
578
|
-
this.eventService.emit('asset.updateState', '');
|
|
579
|
-
}).catch(console.error);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
if (latestAssetLogoMap) {
|
|
583
|
-
const latestAssetLogoPatch = JSON.stringify(latestAssetLogoMap);
|
|
584
|
-
if (this.assetLogoPatch !== latestAssetLogoPatch) {
|
|
585
|
-
const logoMap = {
|
|
586
|
-
...AssetLogoMap,
|
|
587
|
-
...latestAssetLogoMap
|
|
588
|
-
};
|
|
589
|
-
this.assetLogoPatch = latestAssetLogoPatch;
|
|
590
|
-
this.assetLogoMapSubject.next(logoMap);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
if (latestAssetLogoMap) {
|
|
594
|
-
const latestAssetLogoPatch = JSON.stringify(latestAssetLogoMap);
|
|
595
|
-
if (this.assetLogoPatch !== latestAssetLogoPatch) {
|
|
596
|
-
const logoMap = {
|
|
597
|
-
...AssetLogoMap,
|
|
598
|
-
...latestAssetLogoMap
|
|
599
|
-
};
|
|
600
|
-
this.assetLogoPatch = latestAssetLogoPatch;
|
|
601
|
-
this.assetLogoMapSubject.next(logoMap);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
} catch (e) {
|
|
605
|
-
console.error('Error fetching latest asset data');
|
|
606
|
-
}
|
|
607
|
-
this.eventService.emit('asset.online.ready', true);
|
|
608
|
-
this.logger.log('Finished updating latest asset');
|
|
609
|
-
}
|
|
533
|
+
|
|
534
|
+
// handleLatestPriceId (latestPriceIds: Record<string, string | null>) {
|
|
535
|
+
// let isUpdated = false;
|
|
536
|
+
//
|
|
537
|
+
// Object.entries(latestPriceIds).forEach(([slug, priceId]) => {
|
|
538
|
+
// if (this.dataMap.assetRegistry[slug] && this.dataMap.assetRegistry[slug].priceId !== priceId) {
|
|
539
|
+
// isUpdated = true;
|
|
540
|
+
// this.dataMap.assetRegistry[slug].priceId = priceId;
|
|
541
|
+
// }
|
|
542
|
+
// });
|
|
543
|
+
//
|
|
544
|
+
// if (isUpdated) {
|
|
545
|
+
// this.assetRegistrySubject.next(this.dataMap.assetRegistry);
|
|
546
|
+
// this.eventService.emit('asset.updateState', '');
|
|
547
|
+
// }
|
|
548
|
+
//
|
|
549
|
+
// this.logger.log('Finished updating latest price IDs');
|
|
550
|
+
// }
|
|
551
|
+
|
|
610
552
|
async autoEnableTokens() {
|
|
611
553
|
const autoEnableTokens = Object.values(this.dataMap.assetRegistry).filter(asset => _isAssetAutoEnable(asset));
|
|
612
554
|
const assetSettings = this.assetSettingSubject.value;
|
|
@@ -640,20 +582,19 @@ export class ChainService {
|
|
|
640
582
|
this.logger.log('Finished updating latest ledger generic allow chains');
|
|
641
583
|
}
|
|
642
584
|
handleLatestData() {
|
|
643
|
-
this.fetchLatestAssetData().then(([latestAssetInfo, latestAssetLogoMap]) => {
|
|
644
|
-
this.eventService.waitAssetReady.then(() => {
|
|
645
|
-
this.handleLatestAssetData(latestAssetInfo, latestAssetLogoMap);
|
|
646
|
-
}).catch(console.error);
|
|
647
|
-
}).catch(console.error);
|
|
648
585
|
this.fetchLatestChainData().then(latestChainInfo => {
|
|
586
|
+
this.lockChainInfoMap = true; // do not need to check current lockChainInfoMap because all remains action is fast enough and don't affect this feature.
|
|
649
587
|
this.handleLatestChainData(latestChainInfo);
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
this.
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
588
|
+
this.lockChainInfoMap = false;
|
|
589
|
+
}).catch(e => {
|
|
590
|
+
this.lockChainInfoMap = false;
|
|
591
|
+
console.error('Error update latest chain data', e);
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// this.fetchLatestPriceIdsData().then((latestPriceIds) => {
|
|
595
|
+
// this.handleLatestPriceId(latestPriceIds);
|
|
596
|
+
// }).catch(console.error);
|
|
597
|
+
|
|
657
598
|
this.fetchLatestLedgerGenericAllowChains().then(latestledgerGenericAllowChains => {
|
|
658
599
|
this.handleLatestLedgerGenericAllowChains(latestledgerGenericAllowChains);
|
|
659
600
|
}).catch(console.error);
|
|
@@ -911,17 +852,10 @@ export class ChainService {
|
|
|
911
852
|
// }
|
|
912
853
|
}
|
|
913
854
|
|
|
914
|
-
async fetchLatestAssetData() {
|
|
915
|
-
return await Promise.all([fetchPatchData('ChainAsset.json'), fetchPatchData('AssetLogoMap.json')]);
|
|
916
|
-
}
|
|
917
|
-
|
|
918
855
|
// @ts-ignore
|
|
919
856
|
async fetchLatestPriceIdsData() {
|
|
920
857
|
return await fetchStaticData('chain-assets/price-map');
|
|
921
858
|
}
|
|
922
|
-
async fetchLatestAssetRef() {
|
|
923
|
-
return await Promise.all([fetchStaticData('chain-assets/disabled-xcm-channels'), fetchPatchData('AssetRef.json')]);
|
|
924
|
-
}
|
|
925
859
|
async fetchLatestLedgerGenericAllowChains() {
|
|
926
860
|
return (await fetchStaticData('chains/ledger-generic-allow-chains')) || [];
|
|
927
861
|
}
|
|
@@ -1069,7 +1003,35 @@ export class ChainService {
|
|
|
1069
1003
|
});
|
|
1070
1004
|
}
|
|
1071
1005
|
} else {
|
|
1072
|
-
|
|
1006
|
+
var _storedChainInfo$bitc2;
|
|
1007
|
+
// added chain from patch
|
|
1008
|
+
this.dataMap.chainStateMap[storedSlug] = {
|
|
1009
|
+
currentProvider: storedChainInfo.currentProvider,
|
|
1010
|
+
slug: storedSlug,
|
|
1011
|
+
active: storedChainInfo.active,
|
|
1012
|
+
manualTurnOff
|
|
1013
|
+
};
|
|
1014
|
+
this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);
|
|
1015
|
+
newStorageData.push({
|
|
1016
|
+
...storedChainSettingMap[storedSlug],
|
|
1017
|
+
active: storedChainInfo.active,
|
|
1018
|
+
currentProvider: storedChainInfo.currentProvider,
|
|
1019
|
+
manualTurnOff
|
|
1020
|
+
});
|
|
1021
|
+
mergedChainInfoMap[storedSlug] = {
|
|
1022
|
+
slug: storedSlug,
|
|
1023
|
+
name: storedChainInfo.name,
|
|
1024
|
+
providers: storedChainInfo.providers,
|
|
1025
|
+
evmInfo: storedChainInfo.evmInfo,
|
|
1026
|
+
substrateInfo: storedChainInfo.substrateInfo,
|
|
1027
|
+
bitcoinInfo: (_storedChainInfo$bitc2 = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc2 !== void 0 ? _storedChainInfo$bitc2 : null,
|
|
1028
|
+
tonInfo: storedChainInfo.tonInfo,
|
|
1029
|
+
isTestnet: storedChainInfo.isTestnet,
|
|
1030
|
+
chainStatus: storedChainInfo.chainStatus,
|
|
1031
|
+
icon: storedChainInfo.icon,
|
|
1032
|
+
extraInfo: storedChainInfo.extraInfo
|
|
1033
|
+
};
|
|
1034
|
+
deprecatedChainMap[storedSlug] = storedSlug; // todo: set a better name
|
|
1073
1035
|
}
|
|
1074
1036
|
}
|
|
1075
1037
|
|
|
@@ -525,8 +525,6 @@ export function updateLatestChainInfo(currentDataMap, latestChainInfoList) {
|
|
|
525
525
|
}
|
|
526
526
|
if (currentChainInfo) {
|
|
527
527
|
needUpdate = true;
|
|
528
|
-
currentChainInfo.extraInfo = latestChainInfo.extraInfo;
|
|
529
|
-
currentChainInfo.chainStatus = latestChainInfo.chainStatus;
|
|
530
528
|
if (Object.keys(currentChainInfo.providers).length === 0) {
|
|
531
529
|
currentChainInfo.chainStatus = _ChainStatus.INACTIVE;
|
|
532
530
|
}
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
+
export interface PatchInfo {
|
|
3
|
+
patchVersion: string;
|
|
4
|
+
appliedVersion: string;
|
|
5
|
+
fetchedDate: string;
|
|
6
|
+
ChainInfo: Record<string, _ChainInfo>;
|
|
7
|
+
ChainInfoHashMap: Record<string, string>;
|
|
8
|
+
ChainAsset: Record<string, _ChainAsset>;
|
|
9
|
+
ChainAssetHashMap: Record<string, string>;
|
|
10
|
+
MultiChainAsset: Record<string, _MultiChainAsset>;
|
|
11
|
+
MultiChainAssetHashMap: Record<string, string>;
|
|
12
|
+
ChainLogoMap: Record<string, string>;
|
|
13
|
+
AssetLogoMap: Record<string, string>;
|
|
14
|
+
mAssetLogoMap: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
export declare function fetchPatchData<T>(): Promise<T | null>;
|
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
+
const ChainListVersion = '0.2.95'; // update this when build chainlist
|
|
9
|
+
|
|
10
|
+
// todo: move this interface to chainlist
|
|
11
|
+
|
|
12
|
+
export async function fetchPatchData() {
|
|
9
13
|
try {
|
|
10
|
-
const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${
|
|
14
|
+
const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${fetchFile}`);
|
|
11
15
|
const timeout = new Promise(resolve => {
|
|
12
16
|
const id = setTimeout(() => {
|
|
13
17
|
clearTimeout(id);
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { GAS_PRICE_RATIO, NETWORK_MULTI_GAS_FEE } from '@subwallet/extension-base/constants';
|
|
5
5
|
import { BN_WEI, BN_ZERO } from '@subwallet/extension-base/utils';
|
|
6
6
|
import BigN from 'bignumber.js';
|
|
7
|
+
import { POLYGON_GAS_INDEXER } from "../../balance-service/transfer/xcm/polygonBridge.js";
|
|
7
8
|
const INFURA_API_KEY = process.env.INFURA_API_KEY || '';
|
|
8
9
|
const INFURA_API_KEY_SECRET = process.env.INFURA_API_KEY_SECRET || '';
|
|
9
10
|
const INFURA_AUTH = 'Basic ' + Buffer.from(INFURA_API_KEY + ':' + INFURA_API_KEY_SECRET).toString('base64');
|
|
@@ -91,6 +92,19 @@ export const calculateGasFeeParams = async (web3, networkKey, useOnline = true,
|
|
|
91
92
|
} catch (e) {}
|
|
92
93
|
}
|
|
93
94
|
try {
|
|
95
|
+
if (networkKey === 'polygonzkEvm_cardona' || networkKey === 'polygonZkEvm') {
|
|
96
|
+
const isTestnet = networkKey === 'polygonzkEvm_cardona';
|
|
97
|
+
const gasDomain = isTestnet ? POLYGON_GAS_INDEXER.TESTNET : POLYGON_GAS_INDEXER.MAINNET;
|
|
98
|
+
const gasResponse = await fetch(`${gasDomain}`).then(res => res.json());
|
|
99
|
+
const gasPriceInWei = gasResponse.standard * 1e9 + 200000;
|
|
100
|
+
return {
|
|
101
|
+
gasPrice: gasPriceInWei.toString(),
|
|
102
|
+
maxFeePerGas: undefined,
|
|
103
|
+
maxPriorityFeePerGas: undefined,
|
|
104
|
+
baseGasFee: undefined,
|
|
105
|
+
busyNetwork: false
|
|
106
|
+
};
|
|
107
|
+
}
|
|
94
108
|
const numBlock = 20;
|
|
95
109
|
const rewardPercent = [];
|
|
96
110
|
for (let i = 0; i <= 100; i = i + 5) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAvailBridgeClaimDescription, getClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from '
|
|
1
|
+
import { getAvailBridgeClaimDescription, getClaimDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from './utils';
|
|
2
2
|
export declare const NotificationTitleMap: {
|
|
3
3
|
WITHDRAW: string;
|
|
4
4
|
CLAIM: string;
|
|
@@ -6,6 +6,7 @@ export declare const NotificationTitleMap: {
|
|
|
6
6
|
RECEIVE: string;
|
|
7
7
|
CLAIM_AVAIL_BRIDGE_ON_AVAIL: string;
|
|
8
8
|
CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: string;
|
|
9
|
+
CLAIM_POLYGON_BRIDGE: string;
|
|
9
10
|
};
|
|
10
11
|
export declare const NotificationDescriptionMap: {
|
|
11
12
|
WITHDRAW: typeof getWithdrawDescription;
|
|
@@ -14,5 +15,6 @@ export declare const NotificationDescriptionMap: {
|
|
|
14
15
|
RECEIVE: typeof getReceiveDescription;
|
|
15
16
|
CLAIM_AVAIL_BRIDGE_ON_AVAIL: typeof getAvailBridgeClaimDescription;
|
|
16
17
|
CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: typeof getAvailBridgeClaimDescription;
|
|
18
|
+
CLAIM_POLYGON_BRIDGE: typeof getPolygonBridgeClaimDescription;
|
|
17
19
|
};
|
|
18
20
|
export declare const ONE_DAY_MILLISECOND: number;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { NotificationActionType } from
|
|
5
|
-
import { getAvailBridgeClaimDescription, getClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from
|
|
4
|
+
import { NotificationActionType } from "./interfaces.js";
|
|
5
|
+
import { getAvailBridgeClaimDescription, getClaimDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from "./utils/index.js";
|
|
6
6
|
export const NotificationTitleMap = {
|
|
7
7
|
[NotificationActionType.WITHDRAW]: '[{{accountName}}] WITHDRAW {{tokenSymbol}}',
|
|
8
8
|
[NotificationActionType.CLAIM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
9
9
|
[NotificationActionType.SEND]: '[{{accountName}}] SEND {{tokenSymbol}}',
|
|
10
10
|
[NotificationActionType.RECEIVE]: '[{{accountName}}] RECEIVE {{tokenSymbol}}',
|
|
11
11
|
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
12
|
-
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: '[{{accountName}}] CLAIM {{tokenSymbol}}'
|
|
12
|
+
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
13
|
+
[NotificationActionType.CLAIM_POLYGON_BRIDGE]: '[{{accountName}}] CLAIM {{tokenSymbol}}'
|
|
13
14
|
};
|
|
14
15
|
export const NotificationDescriptionMap = {
|
|
15
16
|
[NotificationActionType.WITHDRAW]: getWithdrawDescription,
|
|
@@ -17,6 +18,7 @@ export const NotificationDescriptionMap = {
|
|
|
17
18
|
[NotificationActionType.SEND]: getSendDescription,
|
|
18
19
|
[NotificationActionType.RECEIVE]: getReceiveDescription,
|
|
19
20
|
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: getAvailBridgeClaimDescription,
|
|
20
|
-
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: getAvailBridgeClaimDescription
|
|
21
|
+
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: getAvailBridgeClaimDescription,
|
|
22
|
+
[NotificationActionType.CLAIM_POLYGON_BRIDGE]: getPolygonBridgeClaimDescription
|
|
21
23
|
};
|
|
22
24
|
export const ONE_DAY_MILLISECOND = 1000 * 24 * 60 * 60;
|