@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,29 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
6
|
+
import Dexie from 'dexie';
|
|
7
|
+
export default class MigrateTransactionHistoryBridge extends BaseMigrationJob {
|
|
8
|
+
async run() {
|
|
9
|
+
const state = this.state;
|
|
10
|
+
const newTransactionItems = [];
|
|
11
|
+
try {
|
|
12
|
+
const db = new Dexie('SubWalletDB_v2');
|
|
13
|
+
const dexieDB = await db.open();
|
|
14
|
+
const transactionTable = dexieDB.table('transactions');
|
|
15
|
+
const oldTransactionData = await transactionTable.toArray();
|
|
16
|
+
const claimAvailBridgeTransactions = oldTransactionData.filter(item => item.type === 'claim.claim_avail_bridge');
|
|
17
|
+
claimAvailBridgeTransactions.forEach(item => {
|
|
18
|
+
const newItem = {
|
|
19
|
+
...item,
|
|
20
|
+
type: ExtrinsicType.CLAIM_BRIDGE
|
|
21
|
+
};
|
|
22
|
+
newTransactionItems.push(newItem);
|
|
23
|
+
});
|
|
24
|
+
await state.dbService.upsertHistory(newTransactionItems);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
this.logger.error(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -27,6 +27,7 @@ import MigrateNetworkSettings from "./MigrateNetworkSettings.js";
|
|
|
27
27
|
import MigrateSettings from "./MigrateSettings.js";
|
|
28
28
|
import MigrateTokenDecimals from "./MigrateTokenDecimals.js";
|
|
29
29
|
import MigrateTransactionHistory from "./MigrateTransactionHistory.js";
|
|
30
|
+
import MigrateTransactionHistoryBridge from "./MigrateTransactionHistoryBridge.js";
|
|
30
31
|
import MigrateTransactionHistoryBySymbol from "./MigrateTransactionHistoryBySymbol.js";
|
|
31
32
|
import MigrateWalletReference from "./MigrateWalletReference.js";
|
|
32
33
|
export const EVERYTIME = '__everytime__';
|
|
@@ -59,7 +60,8 @@ export default {
|
|
|
59
60
|
'1.2.69-01': MigrateRemoveGenesisHash,
|
|
60
61
|
'1.2.13-01': ReloadMetadata,
|
|
61
62
|
'1.2.14-01': ClearMetadataDatabase,
|
|
62
|
-
'1.2.32-01': MigratePairData
|
|
63
|
+
'1.2.32-01': MigratePairData,
|
|
64
|
+
'1.3.6-01': MigrateTransactionHistoryBridge
|
|
63
65
|
// [`${EVERYTIME}-1.1.42-02`]: MigrateTransactionHistoryBySymbol
|
|
64
66
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
65
67
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { PassPhishing, RequestSettingsType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import { EnvConfig } from '@subwallet/extension-base/constants';
|
|
3
|
+
import { ChainlistConfig } from '@subwallet/extension-base/stores/ChainlistStore';
|
|
3
4
|
import { Subject } from 'rxjs';
|
|
4
5
|
export default class SettingService {
|
|
5
6
|
private readonly settingsStore;
|
|
6
7
|
private readonly passPhishingStore;
|
|
8
|
+
private readonly chainlistStore;
|
|
7
9
|
private readonly environmentStore;
|
|
8
10
|
constructor();
|
|
9
11
|
private initSetting;
|
|
@@ -13,6 +15,8 @@ export default class SettingService {
|
|
|
13
15
|
passPhishingSubject(): Subject<Record<string, PassPhishing>>;
|
|
14
16
|
getPassPhishingList(update: (value: Record<string, PassPhishing>) => void): void;
|
|
15
17
|
setPassPhishing(data: Record<string, PassPhishing>, callback?: () => void): void;
|
|
18
|
+
getChainlistSetting(): Promise<ChainlistConfig>;
|
|
19
|
+
setChainlist(data: ChainlistConfig, callback?: () => void): void;
|
|
16
20
|
getEnvironmentSetting(): EnvConfig;
|
|
17
21
|
getEnvironmentList(update: (value: EnvConfig) => void): void;
|
|
18
22
|
setEnvironment(data: EnvConfig): void;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { LANGUAGE } from '@subwallet/extension-base/constants';
|
|
5
5
|
import { EnvironmentStoreSubject } from '@subwallet/extension-base/services/environment-service/stores/Environment';
|
|
6
6
|
import { SWStorage } from '@subwallet/extension-base/storage';
|
|
7
|
+
import ChainlistStore from '@subwallet/extension-base/stores/ChainlistStore';
|
|
7
8
|
import PassPhishingStore from '@subwallet/extension-base/stores/PassPhishingStore';
|
|
8
9
|
import SettingsStore from '@subwallet/extension-base/stores/Settings';
|
|
9
10
|
import i18n from "./i18n/i18n.js";
|
|
@@ -11,6 +12,7 @@ import { DEFAULT_SETTING } from "./constants.js";
|
|
|
11
12
|
export default class SettingService {
|
|
12
13
|
settingsStore = new SettingsStore();
|
|
13
14
|
passPhishingStore = new PassPhishingStore();
|
|
15
|
+
chainlistStore = new ChainlistStore();
|
|
14
16
|
environmentStore = new EnvironmentStoreSubject();
|
|
15
17
|
constructor() {
|
|
16
18
|
this.initSetting().catch(console.error);
|
|
@@ -63,6 +65,12 @@ export default class SettingService {
|
|
|
63
65
|
setPassPhishing(data, callback) {
|
|
64
66
|
this.passPhishingStore.set('PassPhishing', data, callback);
|
|
65
67
|
}
|
|
68
|
+
getChainlistSetting() {
|
|
69
|
+
return this.chainlistStore.asyncGet('Chainlist');
|
|
70
|
+
}
|
|
71
|
+
setChainlist(data, callback) {
|
|
72
|
+
this.chainlistStore.set('Chainlist', data, callback);
|
|
73
|
+
}
|
|
66
74
|
getEnvironmentSetting() {
|
|
67
75
|
return this.environmentStore.subject.value;
|
|
68
76
|
}
|
|
@@ -21,7 +21,8 @@ export const DEFAULT_NOTIFICATION_SETUP = {
|
|
|
21
21
|
// receive: true,
|
|
22
22
|
earningClaim: true,
|
|
23
23
|
earningWithdraw: true,
|
|
24
|
-
availBridgeClaim: true
|
|
24
|
+
availBridgeClaim: true,
|
|
25
|
+
polygonBridgeClaim: true
|
|
25
26
|
// isHideWithdraw: false, // todo: just for test, remove later
|
|
26
27
|
// isHideMarketing: false,
|
|
27
28
|
// isHideAnnouncement: false
|
|
@@ -82,6 +82,7 @@ export default class DatabaseService {
|
|
|
82
82
|
removeFromChainStore(chains: string[]): Promise<number>;
|
|
83
83
|
getAllChainStore(): Promise<IChain[]>;
|
|
84
84
|
updateAssetStore(item: _ChainAsset): Promise<unknown>;
|
|
85
|
+
bulkUpdateAssetsStore(items: _ChainAsset[]): Promise<unknown>;
|
|
85
86
|
getAllAssetStore(): Promise<_ChainAsset[]>;
|
|
86
87
|
removeFromAssetStore(items: string[]): Promise<number>;
|
|
87
88
|
updateChainStakingMetadata(item: ChainStakingMetadata, changes?: Record<string, unknown>): Promise<unknown>;
|
|
@@ -332,6 +332,9 @@ export default class DatabaseService {
|
|
|
332
332
|
async updateAssetStore(item) {
|
|
333
333
|
return this.stores.asset.upsert(item);
|
|
334
334
|
}
|
|
335
|
+
async bulkUpdateAssetsStore(items) {
|
|
336
|
+
return this.stores.asset.bulkUpsert(items);
|
|
337
|
+
}
|
|
335
338
|
async getAllAssetStore() {
|
|
336
339
|
return this.stores.asset.getAll();
|
|
337
340
|
}
|
|
@@ -585,7 +585,7 @@ export default class TransactionService {
|
|
|
585
585
|
historyItem.additionalInfo = data;
|
|
586
586
|
break;
|
|
587
587
|
}
|
|
588
|
-
case ExtrinsicType.
|
|
588
|
+
case ExtrinsicType.CLAIM_BRIDGE:
|
|
589
589
|
{
|
|
590
590
|
const data = parseTransactionData(transaction.data); // TODO: switch by provider
|
|
591
591
|
const metadata = data.notification.metadata;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { EXTENSION_PREFIX } from '@subwallet/extension-base/defaults';
|
|
5
|
+
import SubscribableStore from '@subwallet/extension-base/stores/SubscribableStore';
|
|
6
|
+
export default class ChainlistStore extends SubscribableStore {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(EXTENSION_PREFIX ? `${EXTENSION_PREFIX}chainlist` : null);
|
|
9
|
+
}
|
|
10
|
+
}
|
package/types/index.d.ts
CHANGED
package/types/index.js
CHANGED
|
@@ -135,7 +135,7 @@ const EARN_QDOT_ACTIONS = [ExtrinsicType.MINT_QDOT, ExtrinsicType.REDEEM_QDOT, E
|
|
|
135
135
|
const EARN_STDOT_ACTIONS = [ExtrinsicType.MINT_STDOT, ExtrinsicType.REDEEM_STDOT, ExtrinsicType.UNSTAKE_STDOT];
|
|
136
136
|
const EARN_VMANTA_ACTIONS = [ExtrinsicType.MINT_VMANTA, ExtrinsicType.REDEEM_VMANTA, ExtrinsicType.UNSTAKE_VMANTA];
|
|
137
137
|
const EVM_ACTIONS = [ExtrinsicType.TOKEN_SPENDING_APPROVAL, ExtrinsicType.EVM_EXECUTE];
|
|
138
|
-
const CLAIM_AVAIL_BRIDGE = [ExtrinsicType.
|
|
138
|
+
const CLAIM_AVAIL_BRIDGE = [ExtrinsicType.CLAIM_BRIDGE];
|
|
139
139
|
const OTHER_ACTIONS = [ExtrinsicType.TRANSFER_XCM, ExtrinsicType.SEND_NFT, ExtrinsicType.SWAP, ExtrinsicType.CROWDLOAN];
|
|
140
140
|
export const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
|
|
141
141
|
if ([AccountSignMode.PASSWORD, AccountSignMode.INJECTED].includes(signMode)) {
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
-
import { _BaseNotificationInfo, NotificationTab } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
3
|
-
import { EarningRewardItem, UnstakingInfo, YieldPoolType } from '@subwallet/extension-base/types';
|
|
4
|
-
export declare function getWithdrawDescription(amount: string, symbol: string, stakingType: YieldPoolType): string;
|
|
5
|
-
export declare function getClaimDescription(amount: string, symbol: string): string;
|
|
6
|
-
export declare function getSendDescription(amount: string, symbol: string): string;
|
|
7
|
-
export declare function getReceiveDescription(amount: string, symbol: string): string;
|
|
8
|
-
export declare function getAvailBridgeClaimDescription(amount: string, symbol: string): string;
|
|
9
|
-
export declare function getIsTabRead(notificationTab: NotificationTab): boolean | undefined;
|
|
10
|
-
export declare function createWithdrawNotifications(unstakingInfos: UnstakingInfo[], tokenInfo: _ChainAsset, address: string, stakingSlug: string, stakingType: YieldPoolType): _BaseNotificationInfo[];
|
|
11
|
-
export declare function createClaimNotification(claimItemInfo: EarningRewardItem, tokenInfo: _ChainAsset): _BaseNotificationInfo;
|
|
12
|
-
export declare const AVAIL_BRIDGE_INDEXER: {
|
|
13
|
-
AVAIL_MAINNET: string;
|
|
14
|
-
AVAIL_TESTNET: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const AVAIL_BRIDGE_API: {
|
|
17
|
-
AVAIL_MAINNET: string;
|
|
18
|
-
AVAIL_TESTNET: string;
|
|
19
|
-
};
|
|
20
|
-
interface AvailBridgeTransactionsResponse {
|
|
21
|
-
data: {
|
|
22
|
-
paginationData: {
|
|
23
|
-
hasNextPage: boolean;
|
|
24
|
-
page: number;
|
|
25
|
-
pageSize: number;
|
|
26
|
-
totalCount: number;
|
|
27
|
-
};
|
|
28
|
-
result: AvailBridgeTransaction[];
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export interface AvailBridgeTransaction {
|
|
32
|
-
messageId: string;
|
|
33
|
-
sourceChain: AvailBridgeSourceChain;
|
|
34
|
-
sourceTransactionHash: string;
|
|
35
|
-
depositorAddress: string;
|
|
36
|
-
receiverAddress: string;
|
|
37
|
-
amount: string;
|
|
38
|
-
sourceBlockHash: string;
|
|
39
|
-
sourceTransactionIndex: string;
|
|
40
|
-
status: AvailBridgeTransactionStatus;
|
|
41
|
-
}
|
|
42
|
-
export declare enum AvailBridgeTransactionStatus {
|
|
43
|
-
READY_TO_CLAIM = "READY_TO_CLAIM",
|
|
44
|
-
CLAIMED = "CLAIMED",
|
|
45
|
-
BRIDGED = "BRIDGED"
|
|
46
|
-
}
|
|
47
|
-
export declare enum AvailBridgeSourceChain {
|
|
48
|
-
AVAIL = "AVAIL",
|
|
49
|
-
ETHEREUM = "ETHEREUM"
|
|
50
|
-
}
|
|
51
|
-
export declare function fetchAllAvailBridgeClaimable(address: string, sourceChain: AvailBridgeSourceChain, isTestnet: boolean): Promise<AvailBridgeTransaction[]>;
|
|
52
|
-
export declare function fetchAvailBridgeTransactions(userAddress: string, sourceChain: AvailBridgeSourceChain, status: AvailBridgeTransactionStatus, pageSize: number | undefined, page: number | undefined, isTestnet: boolean): Promise<AvailBridgeTransactionsResponse | undefined>;
|
|
53
|
-
export declare function filterClaimableOfAddress(address: string, transactions: AvailBridgeTransaction[]): AvailBridgeTransaction[];
|
|
54
|
-
export declare function hrsToMillisecond(hours: number): number;
|
|
55
|
-
export {};
|
|
File without changes
|
|
File without changes
|