@subwallet/extension-base 1.3.3-0 → 1.3.4-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 +13 -0
- package/background/KoniTypes.js +1 -0
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/constants/blocked-actions-list.js +1 -2
- package/cjs/constants/index.js +16 -1
- package/cjs/constants/remind-notification-time.js +14 -0
- package/cjs/core/logic-validation/transfer.js +12 -6
- package/cjs/core/substrate/xcm-parser.js +13 -1
- package/cjs/koni/api/contract-handler/utils/index.js +20 -1
- package/cjs/koni/background/handlers/Extension.js +110 -23
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +2 -1
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +198 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +50 -5
- package/cjs/services/chain-service/handler/EvmApi.js +12 -21
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +29 -0
- package/cjs/services/chain-service/index.js +44 -13
- package/cjs/services/chain-service/utils/index.js +20 -0
- package/cjs/services/earning-service/handlers/base.js +12 -3
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +10 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +2 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
- package/cjs/services/earning-service/handlers/native-staking/tao.js +10 -2
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +9 -4
- package/cjs/services/earning-service/service.js +5 -0
- package/cjs/services/inapp-notification-service/consts.js +31 -0
- package/cjs/services/inapp-notification-service/index.js +260 -0
- package/cjs/services/inapp-notification-service/interfaces.js +32 -0
- package/cjs/services/inapp-notification-service/utils.js +197 -0
- package/cjs/services/keyring-service/context/account-context.js +9 -0
- package/cjs/services/keyring-service/context/state.js +4 -0
- package/cjs/services/setting-service/SettingService.js +9 -1
- package/cjs/services/setting-service/constants.js +16 -1
- package/cjs/services/storage-service/DatabaseService.js +42 -3
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +81 -0
- package/cjs/services/transaction-service/index.js +13 -0
- package/cjs/types/avail-bridge/index.js +1 -0
- package/cjs/types/notification/index.js +1 -0
- package/cjs/utils/account/transform.js +9 -5
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/blocked-actions-list.js +1 -2
- package/constants/index.d.ts +2 -0
- package/constants/index.js +3 -1
- package/constants/remind-notification-time.d.ts +2 -0
- package/constants/remind-notification-time.js +7 -0
- package/core/logic-validation/transfer.js +12 -6
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +12 -1
- package/koni/api/contract-handler/utils/avail_bridge_abi.json +1659 -0
- package/koni/api/contract-handler/utils/avail_test_bridge_abi.json +1692 -0
- package/koni/api/contract-handler/utils/index.d.ts +4 -0
- package/koni/api/contract-handler/utils/index.js +15 -0
- package/koni/background/handlers/Extension.d.ts +7 -0
- package/koni/background/handlers/Extension.js +112 -25
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/package.json +54 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.js +2 -1
- package/services/balance-service/transfer/xcm/availBridge.d.ts +45 -0
- package/services/balance-service/transfer/xcm/availBridge.js +186 -0
- package/services/balance-service/transfer/xcm/index.d.ts +8 -8
- package/services/balance-service/transfer/xcm/index.js +46 -5
- package/services/chain-service/handler/EvmApi.js +12 -21
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +2 -0
- package/services/chain-service/handler/SubstrateChainHandler.js +29 -0
- package/services/chain-service/index.d.ts +2 -0
- package/services/chain-service/index.js +45 -14
- package/services/chain-service/types.d.ts +2 -1
- package/services/chain-service/utils/index.d.ts +3 -0
- package/services/chain-service/utils/index.js +14 -0
- package/services/earning-service/handlers/base.d.ts +2 -0
- package/services/earning-service/handlers/base.js +9 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +10 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +2 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
- package/services/earning-service/handlers/native-staking/tao.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/tao.js +5 -1
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
- package/services/earning-service/handlers/nomination-pool/index.js +9 -4
- package/services/earning-service/service.d.ts +2 -0
- package/services/earning-service/service.js +5 -0
- package/services/inapp-notification-service/consts.d.ts +18 -0
- package/services/inapp-notification-service/consts.js +22 -0
- package/services/inapp-notification-service/index.d.ts +37 -0
- package/services/inapp-notification-service/index.js +252 -0
- package/services/inapp-notification-service/interfaces.d.ts +77 -0
- package/services/inapp-notification-service/interfaces.js +24 -0
- package/services/inapp-notification-service/utils.d.ts +55 -0
- package/services/inapp-notification-service/utils.js +173 -0
- package/services/keyring-service/context/account-context.d.ts +3 -0
- package/services/keyring-service/context/account-context.js +9 -0
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +4 -0
- package/services/setting-service/SettingService.js +9 -1
- package/services/setting-service/constants.d.ts +2 -0
- package/services/setting-service/constants.js +15 -0
- package/services/storage-service/DatabaseService.d.ts +15 -0
- package/services/storage-service/DatabaseService.js +42 -3
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +14 -0
- package/services/storage-service/db-stores/InappNotification.js +73 -0
- package/services/transaction-service/index.js +13 -0
- package/types/avail-bridge/index.d.ts +6 -0
- package/types/avail-bridge/index.js +1 -0
- package/types/notification/index.d.ts +9 -0
- package/types/notification/index.js +1 -0
- package/utils/account/transform.js +9 -5
- package/utils/staticData/index.d.ts +5 -1
- package/utils/staticData/index.js +5 -2
- package/utils/staticData/remindNotificationTime.json +1 -0
|
@@ -8,5 +8,9 @@ export declare const _PINK_PSP34_ABI: Record<string, any>;
|
|
|
8
8
|
export declare const _NEUROGUNS_PSP34_ABI: Record<string, any>;
|
|
9
9
|
export declare const _AZERO_DOMAIN_REGISTRY_ABI: Record<string, any>;
|
|
10
10
|
export declare const _SNOWBRIDGE_GATEWAY_ABI: Record<string, any>;
|
|
11
|
+
export declare const _AVAIL_BRIDGE_GATEWAY_ABI: Record<string, any>;
|
|
12
|
+
export declare const _AVAIL_TEST_BRIDGE_GATEWAY_ABI: Record<string, any>;
|
|
11
13
|
export declare function getSnowBridgeGatewayContract(chain: string): "0x27ca963C279c93801941e1eB8799c23f407d68e7" | "0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd";
|
|
12
14
|
export declare function isSnowBridgeGatewayContract(contractAddress: _Address): boolean;
|
|
15
|
+
export declare function getAvailBridgeGatewayContract(chain: string): "0x054fd961708D8E2B9c10a63F6157c74458889F0a" | "0x967F7DdC4ec508462231849AE81eeaa68Ad01389";
|
|
16
|
+
export declare function isAvailBridgeGatewayContract(contractAddress: _Address): boolean;
|
|
@@ -20,6 +20,10 @@ export const _NEUROGUNS_PSP34_ABI = require("./neuroguns_psp34_abi.json");
|
|
|
20
20
|
export const _AZERO_DOMAIN_REGISTRY_ABI = require("./azero_domain_registry_abi.json");
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
22
22
|
export const _SNOWBRIDGE_GATEWAY_ABI = require("./snowbridge_gateway_abi.json");
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
24
|
+
export const _AVAIL_BRIDGE_GATEWAY_ABI = require("./avail_bridge_abi.json");
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
26
|
+
export const _AVAIL_TEST_BRIDGE_GATEWAY_ABI = require("./avail_test_bridge_abi.json");
|
|
23
27
|
const SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x27ca963C279c93801941e1eB8799c23f407d68e7';
|
|
24
28
|
const SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd';
|
|
25
29
|
export function getSnowBridgeGatewayContract(chain) {
|
|
@@ -30,4 +34,15 @@ export function getSnowBridgeGatewayContract(chain) {
|
|
|
30
34
|
}
|
|
31
35
|
export function isSnowBridgeGatewayContract(contractAddress) {
|
|
32
36
|
return [SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
|
|
37
|
+
}
|
|
38
|
+
const AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x054fd961708D8E2B9c10a63F6157c74458889F0a';
|
|
39
|
+
const AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x967F7DdC4ec508462231849AE81eeaa68Ad01389';
|
|
40
|
+
export function getAvailBridgeGatewayContract(chain) {
|
|
41
|
+
if (chain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
|
|
42
|
+
return AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS;
|
|
43
|
+
}
|
|
44
|
+
return AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS;
|
|
45
|
+
}
|
|
46
|
+
export function isAvailBridgeGatewayContract(contractAddress) {
|
|
47
|
+
return [AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
|
|
33
48
|
}
|
|
@@ -76,6 +76,7 @@ export default class KoniExtension {
|
|
|
76
76
|
private setUnlockType;
|
|
77
77
|
private subscribeSettings;
|
|
78
78
|
private setEnableChainPatrol;
|
|
79
|
+
private saveNotificationSetup;
|
|
79
80
|
private setShowZeroBalance;
|
|
80
81
|
private setLanguage;
|
|
81
82
|
private setShowBalance;
|
|
@@ -247,6 +248,12 @@ export default class KoniExtension {
|
|
|
247
248
|
private getLatestSwapQuote;
|
|
248
249
|
private validateSwapProcess;
|
|
249
250
|
private handleSwapStep;
|
|
251
|
+
private subscribeUnreadNotificationCountMap;
|
|
252
|
+
private markAllReadNotification;
|
|
253
|
+
private switchReadNotificationStatus;
|
|
254
|
+
private fetchInappNotifications;
|
|
255
|
+
private getInappNotification;
|
|
256
|
+
private submitClaimAvailBridge;
|
|
250
257
|
private subscribeLedgerGenericAllowChains;
|
|
251
258
|
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
|
|
252
259
|
}
|
|
@@ -13,7 +13,7 @@ import { additionalValidateTransfer, additionalValidateXcmTransfer, validateTran
|
|
|
13
13
|
import { _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
14
14
|
import { ALLOWED_PATH } from '@subwallet/extension-base/defaults';
|
|
15
15
|
import { getERC20SpendingApprovalTx } from '@subwallet/extension-base/koni/api/contract-handler/evm/web3';
|
|
16
|
-
import { _ERC721_ABI, isSnowBridgeGatewayContract } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
16
|
+
import { _ERC721_ABI, isAvailBridgeGatewayContract, isSnowBridgeGatewayContract } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
17
17
|
import { resolveAzeroAddressToDomain, resolveAzeroDomainToAddress } from '@subwallet/extension-base/koni/api/dotsama/domain';
|
|
18
18
|
import { parseSubstrateTransaction } from '@subwallet/extension-base/koni/api/dotsama/parseTransaction';
|
|
19
19
|
import { UNSUPPORTED_TRANSFER_EVM_CHAIN_NAME } from '@subwallet/extension-base/koni/api/nft/config';
|
|
@@ -26,7 +26,8 @@ import { isBounceableAddress } from '@subwallet/extension-base/services/balance-
|
|
|
26
26
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject, getPSP34TransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
27
27
|
import { createTransferExtrinsic, getTransferMockTxFee } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
28
28
|
import { createTonTransaction } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
29
|
-
import { createSnowBridgeExtrinsic, createXcmExtrinsic, getXcmMockTxFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
29
|
+
import { createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createSnowBridgeExtrinsic, createXcmExtrinsic, getXcmMockTxFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
30
|
+
import { getClaimTxOnAvail, getClaimTxOnEthereum, isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
30
31
|
import { _API_OPTIONS_CHAIN_GROUP, _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
31
32
|
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
32
33
|
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _isAssetSmartContractNft, _isChainEvmCompatible, _isChainTonCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
|
|
@@ -772,6 +773,10 @@ export default class KoniExtension {
|
|
|
772
773
|
this.#koniState.updateSetting('enableChainPatrol', enable);
|
|
773
774
|
return true;
|
|
774
775
|
}
|
|
776
|
+
saveNotificationSetup(request) {
|
|
777
|
+
this.#koniState.updateSetting('notificationSetup', request);
|
|
778
|
+
return true;
|
|
779
|
+
}
|
|
775
780
|
setShowZeroBalance({
|
|
776
781
|
show
|
|
777
782
|
}) {
|
|
@@ -1071,8 +1076,8 @@ export default class KoniExtension {
|
|
|
1071
1076
|
owner,
|
|
1072
1077
|
spenderAddress
|
|
1073
1078
|
} = params;
|
|
1074
|
-
if (!isSnowBridgeGatewayContract(spenderAddress)) {
|
|
1075
|
-
throw new Error('Only SnowBridge is supported'); // todo: support all ERC20 spending approval
|
|
1079
|
+
if (!isSnowBridgeGatewayContract(spenderAddress) && !isAvailBridgeGatewayContract(spenderAddress)) {
|
|
1080
|
+
throw new Error('Only SnowBridge and AvailBridge is supported'); // todo: support all ERC20 spending approval
|
|
1076
1081
|
}
|
|
1077
1082
|
|
|
1078
1083
|
const evmApi = this.#koniState.getEvmApi(chain);
|
|
@@ -1247,32 +1252,35 @@ export default class KoniExtension {
|
|
|
1247
1252
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(errors);
|
|
1248
1253
|
}
|
|
1249
1254
|
const chainInfoMap = this.#koniState.getChainInfoMap();
|
|
1250
|
-
const
|
|
1255
|
+
const isAvailBridgeFromEvm = _isPureEvmChain(chainInfoMap[originNetworkKey]) && isAvailChainBridge(destinationNetworkKey);
|
|
1256
|
+
const isAvailBridgeFromAvail = isAvailChainBridge(originNetworkKey) && _isPureEvmChain(chainInfoMap[destinationNetworkKey]);
|
|
1257
|
+
const isSnowBridgeEvmTransfer = _isPureEvmChain(chainInfoMap[originNetworkKey]) && _isSnowBridgeXcm(chainInfoMap[originNetworkKey], chainInfoMap[destinationNetworkKey]) && !isAvailBridgeFromEvm;
|
|
1251
1258
|
let additionalValidator;
|
|
1252
1259
|
let eventsHandler;
|
|
1253
1260
|
if (fromKeyPair && destinationTokenInfo) {
|
|
1261
|
+
const evmApi = this.#koniState.getEvmApi(originNetworkKey);
|
|
1262
|
+
const substrateApi = this.#koniState.getSubstrateApi(originNetworkKey);
|
|
1263
|
+
const params = {
|
|
1264
|
+
destinationTokenInfo,
|
|
1265
|
+
originTokenInfo,
|
|
1266
|
+
sendingValue: value,
|
|
1267
|
+
sender: from,
|
|
1268
|
+
recipient: to,
|
|
1269
|
+
chainInfoMap,
|
|
1270
|
+
substrateApi,
|
|
1271
|
+
evmApi
|
|
1272
|
+
};
|
|
1273
|
+
let funcCreateExtrinsic;
|
|
1254
1274
|
if (isSnowBridgeEvmTransfer) {
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
sender: from,
|
|
1261
|
-
recipient: to,
|
|
1262
|
-
chainInfoMap,
|
|
1263
|
-
evmApi
|
|
1264
|
-
});
|
|
1275
|
+
funcCreateExtrinsic = createSnowBridgeExtrinsic;
|
|
1276
|
+
} else if (isAvailBridgeFromEvm) {
|
|
1277
|
+
funcCreateExtrinsic = createAvailBridgeTxFromEth;
|
|
1278
|
+
} else if (isAvailBridgeFromAvail) {
|
|
1279
|
+
funcCreateExtrinsic = createAvailBridgeExtrinsicFromAvail;
|
|
1265
1280
|
} else {
|
|
1266
|
-
|
|
1267
|
-
extrinsic = await createXcmExtrinsic({
|
|
1268
|
-
destinationTokenInfo,
|
|
1269
|
-
originTokenInfo,
|
|
1270
|
-
sendingValue: value,
|
|
1271
|
-
recipient: to,
|
|
1272
|
-
chainInfoMap,
|
|
1273
|
-
substrateApi
|
|
1274
|
-
});
|
|
1281
|
+
funcCreateExtrinsic = createXcmExtrinsic;
|
|
1275
1282
|
}
|
|
1283
|
+
extrinsic = await funcCreateExtrinsic(params);
|
|
1276
1284
|
additionalValidator = async inputTransaction => {
|
|
1277
1285
|
const {
|
|
1278
1286
|
value: senderTransferable
|
|
@@ -1328,7 +1336,7 @@ export default class KoniExtension {
|
|
|
1328
1336
|
transaction: extrinsic,
|
|
1329
1337
|
data: inputData,
|
|
1330
1338
|
extrinsicType: ExtrinsicType.TRANSFER_XCM,
|
|
1331
|
-
chainType: !isSnowBridgeEvmTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1339
|
+
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1332
1340
|
transferNativeAmount: _isNativeToken(originTokenInfo) ? value : '0',
|
|
1333
1341
|
ignoreWarnings,
|
|
1334
1342
|
isTransferAll: transferAll,
|
|
@@ -3317,6 +3325,65 @@ export default class KoniExtension {
|
|
|
3317
3325
|
}
|
|
3318
3326
|
/* Swap service */
|
|
3319
3327
|
|
|
3328
|
+
/* Notification service */
|
|
3329
|
+
async subscribeUnreadNotificationCountMap(id, port) {
|
|
3330
|
+
const cb = createSubscription(id, port);
|
|
3331
|
+
const callback = rs => {
|
|
3332
|
+
cb(rs);
|
|
3333
|
+
};
|
|
3334
|
+
const subscription = this.#koniState.inappNotificationService.subscribeUnreadNotificationsCountMap(callback);
|
|
3335
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
3336
|
+
port.onDisconnect.addListener(() => {
|
|
3337
|
+
this.cancelSubscription(id);
|
|
3338
|
+
});
|
|
3339
|
+
return await this.#koniState.inappNotificationService.getUnreadNotificationsCountMap();
|
|
3340
|
+
}
|
|
3341
|
+
markAllReadNotification(proxyId) {
|
|
3342
|
+
return this.#koniState.inappNotificationService.markAllRead(proxyId);
|
|
3343
|
+
}
|
|
3344
|
+
switchReadNotificationStatus(params) {
|
|
3345
|
+
return this.#koniState.inappNotificationService.switchReadStatus(params);
|
|
3346
|
+
}
|
|
3347
|
+
async fetchInappNotifications(params) {
|
|
3348
|
+
return this.#koniState.inappNotificationService.fetchNotificationsByParams(params);
|
|
3349
|
+
}
|
|
3350
|
+
async getInappNotification(id) {
|
|
3351
|
+
const result = await this.#koniState.inappNotificationService.getNotificationById(id);
|
|
3352
|
+
if (!result) {
|
|
3353
|
+
throw new Error('Notification not found');
|
|
3354
|
+
}
|
|
3355
|
+
return result;
|
|
3356
|
+
}
|
|
3357
|
+
/* Notification service */
|
|
3358
|
+
|
|
3359
|
+
async submitClaimAvailBridge(data) {
|
|
3360
|
+
const {
|
|
3361
|
+
address,
|
|
3362
|
+
chain,
|
|
3363
|
+
notification
|
|
3364
|
+
} = data;
|
|
3365
|
+
const extrinsicType = ExtrinsicType.CLAIM_AVAIL_BRIDGE;
|
|
3366
|
+
let transaction = null;
|
|
3367
|
+
let chainType;
|
|
3368
|
+
if (isSubstrateAddress(address)) {
|
|
3369
|
+
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
3370
|
+
transaction = await getClaimTxOnAvail(notification, substrateApi);
|
|
3371
|
+
chainType = ChainType.SUBSTRATE;
|
|
3372
|
+
} else {
|
|
3373
|
+
const evmApi = this.#koniState.getEvmApi(chain);
|
|
3374
|
+
transaction = await getClaimTxOnEthereum(chain, notification, evmApi);
|
|
3375
|
+
chainType = ChainType.EVM;
|
|
3376
|
+
}
|
|
3377
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3378
|
+
address,
|
|
3379
|
+
chain,
|
|
3380
|
+
transaction,
|
|
3381
|
+
data,
|
|
3382
|
+
extrinsicType,
|
|
3383
|
+
chainType
|
|
3384
|
+
});
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3320
3387
|
/* Ledger */
|
|
3321
3388
|
|
|
3322
3389
|
async subscribeLedgerGenericAllowChains(id, port) {
|
|
@@ -3415,6 +3482,8 @@ export default class KoniExtension {
|
|
|
3415
3482
|
return this.setUnlockType(request);
|
|
3416
3483
|
case 'pri(settings.saveEnableChainPatrol)':
|
|
3417
3484
|
return this.setEnableChainPatrol(request);
|
|
3485
|
+
case 'pri(settings.saveNotificationSetup)':
|
|
3486
|
+
return this.saveNotificationSetup(request);
|
|
3418
3487
|
case 'pri(settings.saveShowZeroBalance)':
|
|
3419
3488
|
return this.setShowZeroBalance(request);
|
|
3420
3489
|
case 'pri(settings.saveLanguage)':
|
|
@@ -3882,6 +3951,24 @@ export default class KoniExtension {
|
|
|
3882
3951
|
return this.handleSwapStep(request);
|
|
3883
3952
|
/* Swap service */
|
|
3884
3953
|
|
|
3954
|
+
/* Notification service */
|
|
3955
|
+
case 'pri(inappNotification.subscribeUnreadNotificationCountMap)':
|
|
3956
|
+
return await this.subscribeUnreadNotificationCountMap(id, port);
|
|
3957
|
+
case 'pri(inappNotification.markAllReadNotification)':
|
|
3958
|
+
return this.markAllReadNotification(request);
|
|
3959
|
+
case 'pri(inappNotification.switchReadNotificationStatus)':
|
|
3960
|
+
return this.switchReadNotificationStatus(request);
|
|
3961
|
+
case 'pri(inappNotification.fetch)':
|
|
3962
|
+
return this.fetchInappNotifications(request);
|
|
3963
|
+
case 'pri(inappNotification.get)':
|
|
3964
|
+
return this.getInappNotification(request);
|
|
3965
|
+
/* Notification service */
|
|
3966
|
+
|
|
3967
|
+
/* Avail Bridge */
|
|
3968
|
+
case 'pri(availBridge.submitClaimAvailBridgeOnAvail)':
|
|
3969
|
+
return this.submitClaimAvailBridge(request);
|
|
3970
|
+
/* Avail Bridge */
|
|
3971
|
+
|
|
3885
3972
|
/* Ledger */
|
|
3886
3973
|
case 'pri(ledger.generic.allow)':
|
|
3887
3974
|
return this.subscribeLedgerGenericAllowChains(id, port);
|
|
@@ -11,6 +11,7 @@ import EarningService from '@subwallet/extension-base/services/earning-service/s
|
|
|
11
11
|
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
12
12
|
import FeeService from '@subwallet/extension-base/services/fee-service/service';
|
|
13
13
|
import { HistoryService } from '@subwallet/extension-base/services/history-service';
|
|
14
|
+
import { InappNotificationService } from '@subwallet/extension-base/services/inapp-notification-service';
|
|
14
15
|
import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
|
|
15
16
|
import MigrationService from '@subwallet/extension-base/services/migration-service';
|
|
16
17
|
import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
|
|
@@ -73,6 +74,7 @@ export default class KoniState {
|
|
|
73
74
|
readonly earningService: EarningService;
|
|
74
75
|
readonly feeService: FeeService;
|
|
75
76
|
readonly swapService: SwapService;
|
|
77
|
+
readonly inappNotificationService: InappNotificationService;
|
|
76
78
|
private generalStatus;
|
|
77
79
|
private waitSleeping;
|
|
78
80
|
private waitStarting;
|
|
@@ -19,6 +19,7 @@ import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
|
19
19
|
import FeeService from '@subwallet/extension-base/services/fee-service/service';
|
|
20
20
|
import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
|
|
21
21
|
import { HistoryService } from '@subwallet/extension-base/services/history-service';
|
|
22
|
+
import { InappNotificationService } from '@subwallet/extension-base/services/inapp-notification-service';
|
|
22
23
|
import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
|
|
23
24
|
import MigrationService from '@subwallet/extension-base/services/migration-service';
|
|
24
25
|
import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
|
|
@@ -103,6 +104,7 @@ export default class KoniState {
|
|
|
103
104
|
this.earningService = new EarningService(this);
|
|
104
105
|
this.feeService = new FeeService(this);
|
|
105
106
|
this.swapService = new SwapService(this);
|
|
107
|
+
this.inappNotificationService = new InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
|
|
106
108
|
this.subscription = new KoniSubscription(this, this.dbService);
|
|
107
109
|
this.cron = new KoniCron(this, this.subscription, this.dbService);
|
|
108
110
|
this.logger = createLogger('State');
|
|
@@ -204,6 +206,7 @@ export default class KoniState {
|
|
|
204
206
|
await this.balanceService.init();
|
|
205
207
|
await this.earningService.init();
|
|
206
208
|
await this.swapService.init();
|
|
209
|
+
await this.inappNotificationService.init();
|
|
207
210
|
this.onReady();
|
|
208
211
|
this.onAccountAdd();
|
|
209
212
|
this.onAccountRemove();
|
|
@@ -1180,7 +1183,7 @@ export default class KoniState {
|
|
|
1180
1183
|
this.campaignService.stop();
|
|
1181
1184
|
await Promise.all([this.cron.stop(), this.subscription.stop()]);
|
|
1182
1185
|
await this.pauseAllNetworks(undefined, 'IDLE mode');
|
|
1183
|
-
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop()]);
|
|
1186
|
+
await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop()]);
|
|
1184
1187
|
|
|
1185
1188
|
// Complete sleeping
|
|
1186
1189
|
sleeping.resolve();
|
|
@@ -1213,7 +1216,7 @@ export default class KoniState {
|
|
|
1213
1216
|
}
|
|
1214
1217
|
|
|
1215
1218
|
// Start services
|
|
1216
|
-
await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start()]);
|
|
1219
|
+
await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start()]);
|
|
1217
1220
|
|
|
1218
1221
|
// Complete starting
|
|
1219
1222
|
starting.resolve();
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.4-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -129,6 +129,11 @@
|
|
|
129
129
|
"require": "./cjs/constants/i18n.js",
|
|
130
130
|
"default": "./constants/i18n.js"
|
|
131
131
|
},
|
|
132
|
+
"./constants/remind-notification-time": {
|
|
133
|
+
"types": "./constants/remind-notification-time.d.ts",
|
|
134
|
+
"require": "./cjs/constants/remind-notification-time.js",
|
|
135
|
+
"default": "./constants/remind-notification-time.js"
|
|
136
|
+
},
|
|
132
137
|
"./constants/signing": {
|
|
133
138
|
"types": "./constants/signing.d.ts",
|
|
134
139
|
"require": "./cjs/constants/signing.js",
|
|
@@ -259,6 +264,8 @@
|
|
|
259
264
|
"require": "./cjs/koni/api/contract-handler/utils/index.js",
|
|
260
265
|
"default": "./koni/api/contract-handler/utils/index.js"
|
|
261
266
|
},
|
|
267
|
+
"./koni/api/contract-handler/utils/avail_bridge_abi.json": "./koni/api/contract-handler/utils/avail_bridge_abi.json",
|
|
268
|
+
"./koni/api/contract-handler/utils/avail_test_bridge_abi.json": "./koni/api/contract-handler/utils/avail_test_bridge_abi.json",
|
|
262
269
|
"./koni/api/contract-handler/utils/azero_domain_registry_abi.json": "./koni/api/contract-handler/utils/azero_domain_registry_abi.json",
|
|
263
270
|
"./koni/api/contract-handler/utils/erc20_abi.json": "./koni/api/contract-handler/utils/erc20_abi.json",
|
|
264
271
|
"./koni/api/contract-handler/utils/erc721_abi.json": "./koni/api/contract-handler/utils/erc721_abi.json",
|
|
@@ -689,6 +696,11 @@
|
|
|
689
696
|
"require": "./cjs/services/balance-service/transfer/xcm/index.js",
|
|
690
697
|
"default": "./services/balance-service/transfer/xcm/index.js"
|
|
691
698
|
},
|
|
699
|
+
"./services/balance-service/transfer/xcm/availBridge": {
|
|
700
|
+
"types": "./services/balance-service/transfer/xcm/availBridge.d.ts",
|
|
701
|
+
"require": "./cjs/services/balance-service/transfer/xcm/availBridge.js",
|
|
702
|
+
"default": "./services/balance-service/transfer/xcm/availBridge.js"
|
|
703
|
+
},
|
|
692
704
|
"./services/balance-service/transfer/xcm/polkadotXcm": {
|
|
693
705
|
"types": "./services/balance-service/transfer/xcm/polkadotXcm.d.ts",
|
|
694
706
|
"require": "./cjs/services/balance-service/transfer/xcm/polkadotXcm.js",
|
|
@@ -1081,6 +1093,26 @@
|
|
|
1081
1093
|
"require": "./cjs/services/history-service/testChainMap.js",
|
|
1082
1094
|
"default": "./services/history-service/testChainMap.js"
|
|
1083
1095
|
},
|
|
1096
|
+
"./services/inapp-notification-service": {
|
|
1097
|
+
"types": "./services/inapp-notification-service/index.d.ts",
|
|
1098
|
+
"require": "./cjs/services/inapp-notification-service/index.js",
|
|
1099
|
+
"default": "./services/inapp-notification-service/index.js"
|
|
1100
|
+
},
|
|
1101
|
+
"./services/inapp-notification-service/consts": {
|
|
1102
|
+
"types": "./services/inapp-notification-service/consts.d.ts",
|
|
1103
|
+
"require": "./cjs/services/inapp-notification-service/consts.js",
|
|
1104
|
+
"default": "./services/inapp-notification-service/consts.js"
|
|
1105
|
+
},
|
|
1106
|
+
"./services/inapp-notification-service/interfaces": {
|
|
1107
|
+
"types": "./services/inapp-notification-service/interfaces.d.ts",
|
|
1108
|
+
"require": "./cjs/services/inapp-notification-service/interfaces.js",
|
|
1109
|
+
"default": "./services/inapp-notification-service/interfaces.js"
|
|
1110
|
+
},
|
|
1111
|
+
"./services/inapp-notification-service/utils": {
|
|
1112
|
+
"types": "./services/inapp-notification-service/utils.d.ts",
|
|
1113
|
+
"require": "./cjs/services/inapp-notification-service/utils.js",
|
|
1114
|
+
"default": "./services/inapp-notification-service/utils.js"
|
|
1115
|
+
},
|
|
1084
1116
|
"./services/keyring-service": {
|
|
1085
1117
|
"types": "./services/keyring-service/index.d.ts",
|
|
1086
1118
|
"require": "./cjs/services/keyring-service/index.js",
|
|
@@ -1571,6 +1603,11 @@
|
|
|
1571
1603
|
"require": "./cjs/services/storage-service/db-stores/Crowdloan.js",
|
|
1572
1604
|
"default": "./services/storage-service/db-stores/Crowdloan.js"
|
|
1573
1605
|
},
|
|
1606
|
+
"./services/storage-service/db-stores/InappNotification": {
|
|
1607
|
+
"types": "./services/storage-service/db-stores/InappNotification.d.ts",
|
|
1608
|
+
"require": "./cjs/services/storage-service/db-stores/InappNotification.js",
|
|
1609
|
+
"default": "./services/storage-service/db-stores/InappNotification.js"
|
|
1610
|
+
},
|
|
1574
1611
|
"./services/storage-service/db-stores/KeyValue": {
|
|
1575
1612
|
"types": "./services/storage-service/db-stores/KeyValue.d.ts",
|
|
1576
1613
|
"require": "./cjs/services/storage-service/db-stores/KeyValue.js",
|
|
@@ -1951,6 +1988,11 @@
|
|
|
1951
1988
|
"require": "./cjs/types/account/info/proxy.js",
|
|
1952
1989
|
"default": "./types/account/info/proxy.js"
|
|
1953
1990
|
},
|
|
1991
|
+
"./types/avail-bridge": {
|
|
1992
|
+
"types": "./types/avail-bridge/index.d.ts",
|
|
1993
|
+
"require": "./cjs/types/avail-bridge/index.js",
|
|
1994
|
+
"default": "./types/avail-bridge/index.js"
|
|
1995
|
+
},
|
|
1954
1996
|
"./types/balance": {
|
|
1955
1997
|
"types": "./types/balance/index.d.ts",
|
|
1956
1998
|
"require": "./cjs/types/balance/index.js",
|
|
@@ -2006,6 +2048,11 @@
|
|
|
2006
2048
|
"require": "./cjs/types/metadata.js",
|
|
2007
2049
|
"default": "./types/metadata.js"
|
|
2008
2050
|
},
|
|
2051
|
+
"./types/notification": {
|
|
2052
|
+
"types": "./types/notification/index.d.ts",
|
|
2053
|
+
"require": "./cjs/types/notification/index.js",
|
|
2054
|
+
"default": "./types/notification/index.js"
|
|
2055
|
+
},
|
|
2009
2056
|
"./types/ordinal": {
|
|
2010
2057
|
"types": "./types/ordinal.d.ts",
|
|
2011
2058
|
"require": "./cjs/types/ordinal.js",
|
|
@@ -2333,6 +2380,7 @@
|
|
|
2333
2380
|
"./utils/staticData/crowdloanFunds.json": "./utils/staticData/crowdloanFunds.json",
|
|
2334
2381
|
"./utils/staticData/currencySymbol.json": "./utils/staticData/currencySymbol.json",
|
|
2335
2382
|
"./utils/staticData/marketingCampaigns.json": "./utils/staticData/marketingCampaigns.json",
|
|
2383
|
+
"./utils/staticData/remindNotificationTime.json": "./utils/staticData/remindNotificationTime.json",
|
|
2336
2384
|
"./utils/staticData/termAndCondition.json": "./utils/staticData/termAndCondition.json",
|
|
2337
2385
|
"./utils/swap": {
|
|
2338
2386
|
"types": "./utils/swap.d.ts",
|
|
@@ -2381,11 +2429,11 @@
|
|
|
2381
2429
|
"@reduxjs/toolkit": "^1.9.1",
|
|
2382
2430
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2383
2431
|
"@substrate/connect": "^0.8.9",
|
|
2384
|
-
"@subwallet/chain-list": "0.2.
|
|
2385
|
-
"@subwallet/extension-base": "^1.3.
|
|
2386
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2387
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2388
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2432
|
+
"@subwallet/chain-list": "0.2.91",
|
|
2433
|
+
"@subwallet/extension-base": "^1.3.4-0",
|
|
2434
|
+
"@subwallet/extension-chains": "^1.3.4-0",
|
|
2435
|
+
"@subwallet/extension-dapp": "^1.3.4-0",
|
|
2436
|
+
"@subwallet/extension-inject": "^1.3.4-0",
|
|
2389
2437
|
"@subwallet/keyring": "^0.1.8-beta.0",
|
|
2390
2438
|
"@subwallet/ui-keyring": "^0.1.8-beta.0",
|
|
2391
2439
|
"@ton/core": "^0.56.3",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.3.
|
|
10
|
+
version: '1.3.4-0'
|
|
11
11
|
};
|
|
@@ -14,8 +14,9 @@ export function getDefaultTransferProcess() {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
export async function getSnowbridgeTransferProcessFromEvm(address, evmApi, tokenInfo, amount) {
|
|
17
|
+
// todo: refactor, AvailBridge also go into this function
|
|
17
18
|
if (![COMMON_CHAIN_SLUGS.ETHEREUM, COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA].includes(tokenInfo.originChain)) {
|
|
18
|
-
throw new Error('Snowbridge only has support for Ethereum');
|
|
19
|
+
throw new Error('Snowbridge or AvailBridge only has support for Ethereum');
|
|
19
20
|
}
|
|
20
21
|
const result = {
|
|
21
22
|
totalFee: [MOCK_STEP_FEE],
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
import { _EvmApi, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
|
+
import { _NotificationInfo } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
4
|
+
import { TransactionConfig } from 'web3-core';
|
|
5
|
+
export declare const AvailBridgeConfig: {
|
|
6
|
+
ASSET_ID: string;
|
|
7
|
+
ETHEREUM_DOMAIN: number;
|
|
8
|
+
AVAIL_DOMAIN: number;
|
|
9
|
+
};
|
|
10
|
+
export interface merkleProof {
|
|
11
|
+
blobRoot: string;
|
|
12
|
+
blockHash: string;
|
|
13
|
+
bridgeRoot: string;
|
|
14
|
+
dataRoot: string;
|
|
15
|
+
dataRootCommitment: string;
|
|
16
|
+
dataRootIndex: number;
|
|
17
|
+
dataRootProof: DataRootProof;
|
|
18
|
+
leaf: string;
|
|
19
|
+
leafIndex: number;
|
|
20
|
+
leafProof: LeafProof;
|
|
21
|
+
message: Message;
|
|
22
|
+
rangeHash: string;
|
|
23
|
+
}
|
|
24
|
+
declare type DataRootProof = `0x${string}`[];
|
|
25
|
+
declare type LeafProof = `0x${string}`[];
|
|
26
|
+
declare type Message = {
|
|
27
|
+
destinationDomain: number;
|
|
28
|
+
from: string;
|
|
29
|
+
id: number;
|
|
30
|
+
message: {
|
|
31
|
+
fungibleToken: {
|
|
32
|
+
amount: bigint;
|
|
33
|
+
asset_id: `0x${string}`;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
originDomain: number;
|
|
37
|
+
to: string;
|
|
38
|
+
messageType: string;
|
|
39
|
+
};
|
|
40
|
+
export declare function getAvailBridgeTxFromEth(originChainInfo: _ChainInfo, sender: string, recipient: string, value: string, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
41
|
+
export declare function getAvailBridgeExtrinsicFromAvail(recipient: string, sendingValue: string, substrateApi: _SubstrateApi): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
42
|
+
export declare function getClaimTxOnAvail(notification: _NotificationInfo, substrateApi: _SubstrateApi): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
43
|
+
export declare function getClaimTxOnEthereum(chainSlug: string, notification: _NotificationInfo, evmApi: _EvmApi): Promise<TransactionConfig>;
|
|
44
|
+
export declare function isAvailChainBridge(chainSlug: string): boolean;
|
|
45
|
+
export {};
|