@subwallet/extension-base 1.0.12-0 → 1.0.13-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 +52 -0
- package/background/KoniTypes.js +10 -18
- package/background/handlers/State.d.ts +0 -1
- package/background/handlers/State.js +4 -8
- package/cjs/background/KoniTypes.js +12 -10
- package/cjs/background/handlers/State.js +4 -8
- package/cjs/koni/api/nft/config.js +11 -6
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
- package/cjs/koni/api/xcm/xTokens.js +2 -2
- package/cjs/koni/background/handlers/Extension.js +150 -1
- package/cjs/koni/background/handlers/State.js +14 -3
- package/cjs/koni/background/handlers/Tabs.js +61 -9
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/Metadata.js +3 -0
- package/cjs/services/chain-service/utils.js +28 -1
- package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -9
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +2 -2
- package/cjs/services/request-service/handler/WalletConnectRequestHandler.js +71 -0
- package/cjs/services/request-service/index.js +24 -6
- package/cjs/services/transaction-service/helpers/index.js +3 -2
- package/cjs/services/transaction-service/index.js +2 -1
- package/cjs/services/wallet-connect-service/constants.js +38 -0
- package/cjs/services/wallet-connect-service/handler/Eip155RequestHandler.js +113 -0
- package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +123 -0
- package/cjs/services/wallet-connect-service/helpers.js +81 -0
- package/cjs/services/wallet-connect-service/index.js +273 -0
- package/cjs/services/wallet-connect-service/types.js +27 -0
- package/cjs/utils/array.js +17 -0
- package/cjs/utils/environment.js +66 -0
- package/cjs/utils/index.js +66 -1
- package/koni/api/nft/config.js +11 -6
- package/koni/api/xcm/polkadotXcm.js +1 -1
- package/koni/api/xcm/xTokens.js +2 -2
- package/koni/background/handlers/Extension.d.ts +6 -0
- package/koni/background/handlers/Extension.js +144 -2
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +14 -3
- package/koni/background/handlers/Tabs.d.ts +2 -0
- package/koni/background/handlers/Tabs.js +58 -7
- package/package.json +55 -6
- package/packageInfo.js +1 -1
- package/page/Metadata.d.ts +2 -0
- package/page/Metadata.js +3 -0
- package/services/chain-service/utils.d.ts +2 -0
- package/services/chain-service/utils.js +25 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +0 -1
- package/services/request-service/handler/AuthRequestHandler.js +5 -10
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -1
- package/services/request-service/handler/SubstrateRequestHandler.js +2 -2
- package/services/request-service/handler/WalletConnectRequestHandler.d.ts +15 -0
- package/services/request-service/handler/WalletConnectRequestHandler.js +62 -0
- package/services/request-service/index.d.ts +7 -2
- package/services/request-service/index.js +24 -6
- package/services/transaction-service/helpers/index.d.ts +1 -1
- package/services/transaction-service/helpers/index.js +2 -2
- package/services/transaction-service/index.js +2 -1
- package/services/transaction-service/types.d.ts +2 -1
- package/services/wallet-connect-service/constants.d.ts +11 -0
- package/services/wallet-connect-service/constants.js +23 -0
- package/services/wallet-connect-service/handler/Eip155RequestHandler.d.ts +8 -0
- package/services/wallet-connect-service/handler/Eip155RequestHandler.js +106 -0
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.d.ts +8 -0
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +114 -0
- package/services/wallet-connect-service/helpers.d.ts +12 -0
- package/services/wallet-connect-service/helpers.js +67 -0
- package/services/wallet-connect-service/index.d.ts +20 -0
- package/services/wallet-connect-service/index.js +265 -0
- package/services/wallet-connect-service/types.d.ts +46 -0
- package/services/wallet-connect-service/types.js +20 -0
- package/utils/array.d.ts +1 -0
- package/utils/array.js +10 -0
- package/utils/environment.d.ts +2 -0
- package/utils/environment.js +59 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +9 -2
package/cjs/utils/index.js
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
notDef: true,
|
|
8
|
+
isDef: true,
|
|
9
|
+
nonEmptyArr: true,
|
|
10
|
+
isEmptyArray: true,
|
|
11
|
+
isAccountAll: true,
|
|
12
|
+
reformatAddress: true,
|
|
13
|
+
filterAddressByNetworkKey: true,
|
|
14
|
+
categoryAddresses: true,
|
|
15
|
+
categoryNetworks: true,
|
|
16
|
+
convertToEvmAddress: true,
|
|
17
|
+
isUrl: true,
|
|
18
|
+
inJestTest: true,
|
|
19
|
+
parseIpfsLink: true,
|
|
20
|
+
hexToStr: true,
|
|
21
|
+
utf16ToString: true,
|
|
22
|
+
hexToUTF16: true,
|
|
23
|
+
isValidSubstrateAddress: true,
|
|
24
|
+
toUnit: true,
|
|
25
|
+
sumBN: true,
|
|
26
|
+
convertFundStatus: true,
|
|
27
|
+
isAddressesEqual: true,
|
|
28
|
+
isValidProvider: true,
|
|
29
|
+
getCurrentProvider: true,
|
|
30
|
+
getNftProvider: true,
|
|
31
|
+
mergeNetworkProviders: true,
|
|
32
|
+
filterAndSortingAccountByAuthType: true,
|
|
33
|
+
parseRawNumber: true,
|
|
34
|
+
isSameAddress: true,
|
|
35
|
+
getDomainFromUrl: true,
|
|
36
|
+
waitTimeout: true,
|
|
37
|
+
stripUrl: true,
|
|
38
|
+
canDerive: true
|
|
39
|
+
};
|
|
6
40
|
Object.defineProperty(exports, "canDerive", {
|
|
7
41
|
enumerable: true,
|
|
8
42
|
get: function () {
|
|
@@ -29,6 +63,7 @@ exports.mergeNetworkProviders = mergeNetworkProviders;
|
|
|
29
63
|
exports.parseIpfsLink = exports.notDef = exports.nonEmptyArr = void 0;
|
|
30
64
|
exports.parseRawNumber = parseRawNumber;
|
|
31
65
|
exports.reformatAddress = reformatAddress;
|
|
66
|
+
exports.stripUrl = void 0;
|
|
32
67
|
exports.sumBN = sumBN;
|
|
33
68
|
exports.toUnit = void 0;
|
|
34
69
|
exports.utf16ToString = utf16ToString;
|
|
@@ -38,6 +73,30 @@ var _constants = require("@subwallet/extension-base/constants");
|
|
|
38
73
|
var _util = require("@polkadot/util");
|
|
39
74
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
40
75
|
var _canDerive = require("./canDerive");
|
|
76
|
+
var _array = require("./array");
|
|
77
|
+
Object.keys(_array).forEach(function (key) {
|
|
78
|
+
if (key === "default" || key === "__esModule") return;
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
80
|
+
if (key in exports && exports[key] === _array[key]) return;
|
|
81
|
+
Object.defineProperty(exports, key, {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return _array[key];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
var _environment = require("./environment");
|
|
89
|
+
Object.keys(_environment).forEach(function (key) {
|
|
90
|
+
if (key === "default" || key === "__esModule") return;
|
|
91
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
92
|
+
if (key in exports && exports[key] === _environment[key]) return;
|
|
93
|
+
Object.defineProperty(exports, key, {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return _environment[key];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
41
100
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
42
101
|
// SPDX-License-Identifier: Apache-2.0
|
|
43
102
|
|
|
@@ -329,4 +388,10 @@ function getDomainFromUrl(url) {
|
|
|
329
388
|
}
|
|
330
389
|
async function waitTimeout(ms) {
|
|
331
390
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
332
|
-
}
|
|
391
|
+
}
|
|
392
|
+
const stripUrl = url => {
|
|
393
|
+
(0, _util.assert)(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')), `Invalid url ${url}, expected to start with http: or https: or ipfs: or ipns:`);
|
|
394
|
+
const parts = url.split('/');
|
|
395
|
+
return parts[2];
|
|
396
|
+
};
|
|
397
|
+
exports.stripUrl = stripUrl;
|
package/koni/api/nft/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { RuntimeInfo } from '@subwallet/extension-base/utils';
|
|
4
5
|
export const SINGULAR_V1_ENDPOINT = 'https://singular.rmrk-api.xyz/api/account-rmrk1/';
|
|
5
6
|
export const SINGULAR_V2_ENDPOINT = 'https://singular.rmrk-api.xyz/api/account/';
|
|
6
7
|
export const KANARIA_ENDPOINT = 'https://kanaria.rmrk.app/api/rmrk2/';
|
|
@@ -68,9 +69,6 @@ export let SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME;
|
|
|
68
69
|
const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
69
70
|
provider: IPFS_IO_GATEWAY,
|
|
70
71
|
weight: 0 // Not stable
|
|
71
|
-
}, {
|
|
72
|
-
provider: NFT_STORAGE_GATEWAY,
|
|
73
|
-
weight: 50
|
|
74
72
|
}, {
|
|
75
73
|
provider: CF_IPFS_GATEWAY,
|
|
76
74
|
weight: 4
|
|
@@ -89,13 +87,20 @@ const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
|
89
87
|
}, {
|
|
90
88
|
provider: IPFS_GATEWAY_CLOUD,
|
|
91
89
|
weight: 0 // Deceptive site warning
|
|
92
|
-
}, {
|
|
93
|
-
provider: IPFS_FLEEK,
|
|
94
|
-
weight: 4
|
|
95
90
|
}, {
|
|
96
91
|
provider: IPFS_TELOS_MIAMI,
|
|
97
92
|
weight: 0
|
|
98
93
|
}];
|
|
94
|
+
if (!RuntimeInfo.protocol || RuntimeInfo.protocol && !RuntimeInfo.protocol.startsWith('http')) {
|
|
95
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
96
|
+
provider: NFT_STORAGE_GATEWAY,
|
|
97
|
+
weight: 50
|
|
98
|
+
});
|
|
99
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
100
|
+
provider: IPFS_FLEEK,
|
|
101
|
+
weight: 4
|
|
102
|
+
});
|
|
103
|
+
}
|
|
99
104
|
const RANDOM_IPFS_GATEWAY_TOTAL_WEIGHT = RANDOM_IPFS_GATEWAY_SETTING.reduce((value, item) => value + item.weight, 0);
|
|
100
105
|
export function getRandomIpfsGateway() {
|
|
101
106
|
const weighedItems = [];
|
|
@@ -5,7 +5,7 @@ import { getBeneficiary, getDestinationChainLocation, getDestWeight, getTokenLoc
|
|
|
5
5
|
import { _isNativeToken, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
export function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
7
7
|
const weightParam = getDestWeight();
|
|
8
|
-
const version = ['statemint', 'statemine', 'shiden'].includes(originChainInfo.slug) ? 'V3' : 'V1';
|
|
8
|
+
const version = ['statemint', 'statemine', 'shiden', 'astar'].includes(originChainInfo.slug) ? 'V3' : 'V1';
|
|
9
9
|
const beneficiary = getBeneficiary(destinationChainInfo, recipientAddress, version);
|
|
10
10
|
const destination = getDestinationChainLocation(originChainInfo, destinationChainInfo, version);
|
|
11
11
|
let assetLocation = getTokenLocation(tokenInfo, value, version);
|
package/koni/api/xcm/xTokens.js
CHANGED
|
@@ -18,7 +18,7 @@ function getCurrencyId(tokenInfo) {
|
|
|
18
18
|
return _getTokenOnChainInfo(tokenInfo) || _getTokenOnChainAssetId(tokenInfo);
|
|
19
19
|
}
|
|
20
20
|
export function getExtrinsicByXtokensPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
21
|
-
const weightParam = ['pioneer'
|
|
22
|
-
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
21
|
+
const weightParam = ['pioneer'].includes(originChainInfo.slug) ? FOUR_INSTRUCTIONS_WEIGHT : getDestWeight();
|
|
22
|
+
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
23
23
|
return api.tx.xTokens.transfer(getCurrencyId(tokenInfo), value, getDestMultilocation(destinationChainInfo, recipientAddress, destVersion), weightParam);
|
|
24
24
|
}
|
|
@@ -188,5 +188,11 @@ export default class KoniExtension {
|
|
|
188
188
|
private reloadCron;
|
|
189
189
|
private getLogoMap;
|
|
190
190
|
private passPhishingPage;
|
|
191
|
+
private connectWalletConnect;
|
|
192
|
+
private connectWCSubscribe;
|
|
193
|
+
private approveWalletConnectSession;
|
|
194
|
+
private rejectWalletConnectSession;
|
|
195
|
+
private subscribeWalletConnectSessions;
|
|
196
|
+
private disconnectWalletConnectSession;
|
|
191
197
|
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
|
|
192
198
|
}
|
|
@@ -23,13 +23,16 @@ import { createXcmExtrinsic } from '@subwallet/extension-base/koni/api/xcm';
|
|
|
23
23
|
import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getSubstrateGenesisHash, _getTokenMinAmount, _isAssetSmartContractNft, _isChainEvmCompatible, _isCustomAsset, _isLocalToken, _isNativeToken, _isTokenEvmSmartContract, _isTokenTransferredByEvm } from '@subwallet/extension-base/services/chain-service/utils';
|
|
24
24
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
25
25
|
import { DEFAULT_AUTO_LOCK_TIME } from '@subwallet/extension-base/services/setting-service/constants';
|
|
26
|
-
import {
|
|
26
|
+
import { WALLET_CONNECT_EIP155_NAMESPACE } from '@subwallet/extension-base/services/wallet-connect-service/constants';
|
|
27
|
+
import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectNamespace } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
|
|
28
|
+
import { reformatAddress, uniqueStringArray } from '@subwallet/extension-base/utils';
|
|
27
29
|
import { convertSubjectInfoToAddresses } from '@subwallet/extension-base/utils/address';
|
|
28
30
|
import { createTransactionFromRLP, signatureToHex } from '@subwallet/extension-base/utils/eth';
|
|
29
31
|
import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
30
32
|
import { balanceFormatter, formatNumber } from '@subwallet/extension-base/utils/number';
|
|
31
33
|
import { createPair } from '@subwallet/keyring';
|
|
32
34
|
import { keyring } from '@subwallet/ui-keyring';
|
|
35
|
+
import { getSdkError } from '@walletconnect/utils';
|
|
33
36
|
import BigN from 'bignumber.js';
|
|
34
37
|
import { Transaction } from 'ethereumjs-tx';
|
|
35
38
|
import { TypeRegistry } from '@polkadot/types';
|
|
@@ -489,7 +492,7 @@ export default class KoniExtension {
|
|
|
489
492
|
const account = keyring.getAccount(address);
|
|
490
493
|
const contact = keyring.getAddress(address);
|
|
491
494
|
return account || contact || {
|
|
492
|
-
...keyring.saveRecent(
|
|
495
|
+
...keyring.saveRecent(address).json,
|
|
493
496
|
publicKey: decodeAddress(address)
|
|
494
497
|
};
|
|
495
498
|
} else {
|
|
@@ -3012,6 +3015,131 @@ export default class KoniExtension {
|
|
|
3012
3015
|
return await this.#koniState.approvePassPhishingPage(url);
|
|
3013
3016
|
}
|
|
3014
3017
|
|
|
3018
|
+
/// Wallet connect
|
|
3019
|
+
|
|
3020
|
+
// Connect
|
|
3021
|
+
async connectWalletConnect({
|
|
3022
|
+
uri
|
|
3023
|
+
}) {
|
|
3024
|
+
await this.#koniState.walletConnectService.connect(uri);
|
|
3025
|
+
return true;
|
|
3026
|
+
}
|
|
3027
|
+
connectWCSubscribe(id, port) {
|
|
3028
|
+
const cb = createSubscription(id, port);
|
|
3029
|
+
const subscription = this.#koniState.requestService.connectWCSubject.subscribe(requests => cb(requests));
|
|
3030
|
+
port.onDisconnect.addListener(() => {
|
|
3031
|
+
this.cancelSubscription(id);
|
|
3032
|
+
subscription.unsubscribe();
|
|
3033
|
+
});
|
|
3034
|
+
return this.#koniState.requestService.allConnectWCRequests;
|
|
3035
|
+
}
|
|
3036
|
+
async approveWalletConnectSession({
|
|
3037
|
+
accounts: selectedAccounts,
|
|
3038
|
+
id
|
|
3039
|
+
}) {
|
|
3040
|
+
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
3041
|
+
if (isProposalExpired(request.request.params)) {
|
|
3042
|
+
throw new Error('The proposal has been expired');
|
|
3043
|
+
}
|
|
3044
|
+
const wcId = request.request.id;
|
|
3045
|
+
const params = request.request.params;
|
|
3046
|
+
const requiredNamespaces = params.requiredNamespaces;
|
|
3047
|
+
const optionalNamespaces = params.optionalNamespaces;
|
|
3048
|
+
const availableNamespaces = {};
|
|
3049
|
+
const namespaces = {};
|
|
3050
|
+
const chainInfoMap = this.#koniState.getChainInfoMap();
|
|
3051
|
+
Object.entries(requiredNamespaces).forEach(([key, namespace]) => {
|
|
3052
|
+
if (isSupportWalletConnectNamespace(key)) {
|
|
3053
|
+
if (namespace.chains) {
|
|
3054
|
+
const unSupportChains = namespace.chains.filter(chain => !isSupportWalletConnectChain(chain, chainInfoMap));
|
|
3055
|
+
if (unSupportChains.length) {
|
|
3056
|
+
throw new Error(getSdkError('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
|
|
3057
|
+
}
|
|
3058
|
+
availableNamespaces[key] = namespace;
|
|
3059
|
+
}
|
|
3060
|
+
} else {
|
|
3061
|
+
throw new Error(getSdkError('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
3062
|
+
}
|
|
3063
|
+
});
|
|
3064
|
+
Object.entries(optionalNamespaces).forEach(([key, namespace]) => {
|
|
3065
|
+
if (isSupportWalletConnectNamespace(key)) {
|
|
3066
|
+
if (namespace.chains) {
|
|
3067
|
+
const supportChains = namespace.chains.filter(chain => isSupportWalletConnectChain(chain, chainInfoMap)) || [];
|
|
3068
|
+
const requiredNameSpace = availableNamespaces[key];
|
|
3069
|
+
const defaultChains = [];
|
|
3070
|
+
if (requiredNameSpace) {
|
|
3071
|
+
availableNamespaces[key] = {
|
|
3072
|
+
chains: [...(requiredNameSpace.chains || defaultChains), ...(supportChains || defaultChains)],
|
|
3073
|
+
events: requiredNameSpace.events,
|
|
3074
|
+
methods: requiredNameSpace.methods
|
|
3075
|
+
};
|
|
3076
|
+
} else {
|
|
3077
|
+
if (supportChains.length) {
|
|
3078
|
+
availableNamespaces[key] = {
|
|
3079
|
+
chains: supportChains,
|
|
3080
|
+
events: namespace.events,
|
|
3081
|
+
methods: namespace.methods
|
|
3082
|
+
};
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
});
|
|
3088
|
+
Object.entries(availableNamespaces).forEach(([key, namespace]) => {
|
|
3089
|
+
if (namespace.chains) {
|
|
3090
|
+
const accounts = [];
|
|
3091
|
+
const chains = uniqueStringArray(namespace.chains);
|
|
3092
|
+
chains.forEach(chain => {
|
|
3093
|
+
accounts.push(...selectedAccounts.filter(address => isEthereumAddress(address) === (key === WALLET_CONNECT_EIP155_NAMESPACE)).map(address => `${chain}:${address}`));
|
|
3094
|
+
});
|
|
3095
|
+
namespaces[key] = {
|
|
3096
|
+
accounts,
|
|
3097
|
+
methods: namespace.methods,
|
|
3098
|
+
events: namespace.events,
|
|
3099
|
+
chains: chains
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
});
|
|
3103
|
+
const result = {
|
|
3104
|
+
id: wcId,
|
|
3105
|
+
namespaces: namespaces,
|
|
3106
|
+
relayProtocol: params.relays[0].protocol
|
|
3107
|
+
};
|
|
3108
|
+
await this.#koniState.walletConnectService.approveSession(result);
|
|
3109
|
+
request.resolve();
|
|
3110
|
+
return true;
|
|
3111
|
+
}
|
|
3112
|
+
async rejectWalletConnectSession({
|
|
3113
|
+
id
|
|
3114
|
+
}) {
|
|
3115
|
+
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
3116
|
+
const wcId = request.request.id;
|
|
3117
|
+
if (isProposalExpired(request.request.params)) {
|
|
3118
|
+
request.reject(new Error('The proposal has been expired'));
|
|
3119
|
+
return true;
|
|
3120
|
+
}
|
|
3121
|
+
await this.#koniState.walletConnectService.rejectSession(wcId);
|
|
3122
|
+
request.reject(new Error('USER_REJECTED'));
|
|
3123
|
+
return true;
|
|
3124
|
+
}
|
|
3125
|
+
subscribeWalletConnectSessions(id, port) {
|
|
3126
|
+
const cb = createSubscription(id, port);
|
|
3127
|
+
const subscription = this.#koniState.walletConnectService.sessionSubject.subscribe(rs => {
|
|
3128
|
+
cb(rs);
|
|
3129
|
+
});
|
|
3130
|
+
port.onDisconnect.addListener(() => {
|
|
3131
|
+
subscription.unsubscribe();
|
|
3132
|
+
this.cancelSubscription(id);
|
|
3133
|
+
});
|
|
3134
|
+
return this.#koniState.walletConnectService.sessions;
|
|
3135
|
+
}
|
|
3136
|
+
async disconnectWalletConnectSession({
|
|
3137
|
+
topic
|
|
3138
|
+
}) {
|
|
3139
|
+
await this.#koniState.walletConnectService.disconnect(topic);
|
|
3140
|
+
return true;
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3015
3143
|
// --------------------------------------------------------------
|
|
3016
3144
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
3017
3145
|
async handle(id, type, request, port) {
|
|
@@ -3385,6 +3513,20 @@ export default class KoniExtension {
|
|
|
3385
3513
|
case 'pri(settings.getLogoMaps)':
|
|
3386
3514
|
return await this.getLogoMap();
|
|
3387
3515
|
|
|
3516
|
+
/// Wallet Connect
|
|
3517
|
+
case 'pri(walletConnect.connect)':
|
|
3518
|
+
return this.connectWalletConnect(request);
|
|
3519
|
+
case 'pri(walletConnect.requests.subscribe)':
|
|
3520
|
+
return this.connectWCSubscribe(id, port);
|
|
3521
|
+
case 'pri(walletConnect.session.approve)':
|
|
3522
|
+
return this.approveWalletConnectSession(request);
|
|
3523
|
+
case 'pri(walletConnect.session.reject)':
|
|
3524
|
+
return this.rejectWalletConnectSession(request);
|
|
3525
|
+
case 'pri(walletConnect.session.subscribe)':
|
|
3526
|
+
return this.subscribeWalletConnectSessions(id, port);
|
|
3527
|
+
case 'pri(walletConnect.session.disconnect)':
|
|
3528
|
+
return this.disconnectWalletConnectSession(request);
|
|
3529
|
+
|
|
3388
3530
|
// Default
|
|
3389
3531
|
default:
|
|
3390
3532
|
throw new Error(`Unable to handle message of type ${type}`);
|
|
@@ -17,6 +17,7 @@ import SettingService from '@subwallet/extension-base/services/setting-service/S
|
|
|
17
17
|
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
18
18
|
import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
|
|
19
19
|
import TransactionService from '@subwallet/extension-base/services/transaction-service';
|
|
20
|
+
import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
|
|
20
21
|
import { MetadataDef, ProviderMeta } from '@subwallet/extension-inject/types';
|
|
21
22
|
import SimpleKeyring from 'eth-simple-keyring';
|
|
22
23
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
@@ -58,6 +59,7 @@ export default class KoniState {
|
|
|
58
59
|
readonly balanceService: BalanceService;
|
|
59
60
|
readonly migrationService: MigrationService;
|
|
60
61
|
readonly subscanService: SubscanService;
|
|
62
|
+
readonly walletConnectService: WalletConnectService;
|
|
61
63
|
private generalStatus;
|
|
62
64
|
private waitSleeping;
|
|
63
65
|
private waitStarting;
|
|
@@ -24,7 +24,9 @@ import DatabaseService from '@subwallet/extension-base/services/storage-service/
|
|
|
24
24
|
import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
|
|
25
25
|
import { SUBSCAN_CHAIN_MAP_REVERSE } from '@subwallet/extension-base/services/subscan-service/subscan-chain-map';
|
|
26
26
|
import TransactionService from '@subwallet/extension-base/services/transaction-service';
|
|
27
|
+
import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
|
|
27
28
|
import AccountRefStore from '@subwallet/extension-base/stores/AccountRef';
|
|
29
|
+
import { stripUrl } from '@subwallet/extension-base/utils';
|
|
28
30
|
import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
29
31
|
import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
30
32
|
import { decodePair } from '@subwallet/keyring/pair/decode';
|
|
@@ -92,6 +94,7 @@ export default class KoniState {
|
|
|
92
94
|
this.balanceService = new BalanceService(this.chainService);
|
|
93
95
|
this.historyService = new HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService);
|
|
94
96
|
this.transactionService = new TransactionService(this.chainService, this.eventService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
|
|
97
|
+
this.walletConnectService = new WalletConnectService(this, this.requestService);
|
|
95
98
|
this.migrationService = new MigrationService(this);
|
|
96
99
|
this.subscription = new KoniSubscription(this, this.dbService);
|
|
97
100
|
this.cron = new KoniCron(this, this.subscription, this.dbService);
|
|
@@ -1248,9 +1251,10 @@ export default class KoniState {
|
|
|
1248
1251
|
const transactionData = {
|
|
1249
1252
|
...transaction
|
|
1250
1253
|
};
|
|
1254
|
+
const token = this.chainService.getNativeTokenInfo(networkKey);
|
|
1251
1255
|
if (eType === ExtrinsicType.TRANSFER_BALANCE) {
|
|
1252
1256
|
// @ts-ignore
|
|
1253
|
-
transactionData.tokenSlug =
|
|
1257
|
+
transactionData.tokenSlug = token.slug;
|
|
1254
1258
|
}
|
|
1255
1259
|
|
|
1256
1260
|
// Custom handle this instead of general handler transaction
|
|
@@ -1261,7 +1265,13 @@ export default class KoniState {
|
|
|
1261
1265
|
url,
|
|
1262
1266
|
data: transactionData,
|
|
1263
1267
|
extrinsicType: eType,
|
|
1264
|
-
chainType: ChainType.EVM
|
|
1268
|
+
chainType: ChainType.EVM,
|
|
1269
|
+
estimateFee: {
|
|
1270
|
+
value: estimateGas,
|
|
1271
|
+
symbol: token.symbol,
|
|
1272
|
+
decimals: token.decimals || 18
|
|
1273
|
+
},
|
|
1274
|
+
id
|
|
1265
1275
|
});
|
|
1266
1276
|
|
|
1267
1277
|
// Wait extrinsic hash
|
|
@@ -1505,7 +1515,7 @@ export default class KoniState {
|
|
|
1505
1515
|
const result = {
|
|
1506
1516
|
...value
|
|
1507
1517
|
};
|
|
1508
|
-
const url =
|
|
1518
|
+
const url = stripUrl(_url);
|
|
1509
1519
|
result[url] = {
|
|
1510
1520
|
pass: true
|
|
1511
1521
|
};
|
|
@@ -1525,6 +1535,7 @@ export default class KoniState {
|
|
|
1525
1535
|
this.settingService.resetWallet();
|
|
1526
1536
|
}
|
|
1527
1537
|
this.chainService.resetWallet(resetAll);
|
|
1538
|
+
await this.walletConnectService.resetWallet(resetAll);
|
|
1528
1539
|
await this.chainService.init();
|
|
1529
1540
|
}
|
|
1530
1541
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="chrome" />
|
|
2
2
|
import { AuthUrlInfo } from '@subwallet/extension-base/background/handlers/State';
|
|
3
|
+
import { RequestAddPspToken } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
4
|
import { MessageTypes, RequestTypes, ResponseTypes } from '@subwallet/extension-base/background/types';
|
|
4
5
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
5
6
|
import { RequestArguments } from 'web3-core';
|
|
@@ -46,5 +47,6 @@ export default class KoniTabs {
|
|
|
46
47
|
private handleEvmRequest;
|
|
47
48
|
private handleEvmSend;
|
|
48
49
|
isEvmPublicRequest(type: string, request: RequestArguments): boolean;
|
|
50
|
+
addPspToken(id: string, url: string, { genesisHash, tokenInfo: input }: RequestAddPspToken): Promise<true>;
|
|
49
51
|
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], url: string, port: chrome.runtime.Port): Promise<ResponseTypes[keyof ResponseTypes]>;
|
|
50
52
|
}
|
|
@@ -13,16 +13,11 @@ import { PHISHING_PAGE_REDIRECT } from '@subwallet/extension-base/defaults';
|
|
|
13
13
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
14
14
|
import { _generateCustomProviderKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
15
15
|
import { DEFAULT_CHAIN_PATROL_ENABLE } from '@subwallet/extension-base/services/setting-service/constants';
|
|
16
|
-
import { canDerive } from '@subwallet/extension-base/utils';
|
|
16
|
+
import { canDerive, stripUrl } from '@subwallet/extension-base/utils';
|
|
17
17
|
import keyring from '@subwallet/ui-keyring';
|
|
18
18
|
import Web3 from 'web3';
|
|
19
19
|
import { checkIfDenied } from '@polkadot/phishing';
|
|
20
20
|
import { assert, isNumber } from '@polkadot/util';
|
|
21
|
-
function stripUrl(url) {
|
|
22
|
-
assert(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')), `Invalid url ${url}, expected to start with http: or https: or ipfs: or ipns:`);
|
|
23
|
-
const parts = url.split('/');
|
|
24
|
-
return parts[2];
|
|
25
|
-
}
|
|
26
21
|
function transformAccountsV2(accounts, anyType = false, authInfo, accountAuthType) {
|
|
27
22
|
const accountSelected = authInfo ? authInfo.isAllowed ? Object.keys(authInfo.isAllowedMap).filter(address => authInfo.isAllowedMap[address]) : [] : [];
|
|
28
23
|
let authTypeFilter = ({
|
|
@@ -401,7 +396,7 @@ export default class KoniTabs {
|
|
|
401
396
|
tokenInfo.contractError = true;
|
|
402
397
|
} else {
|
|
403
398
|
tokenInfo.slug = validate === null || validate === void 0 ? void 0 : validate.existedSlug;
|
|
404
|
-
tokenInfo.name = validate.name;
|
|
399
|
+
tokenInfo.name = validate.name || tokenInfo.name;
|
|
405
400
|
tokenInfo.symbol = validate.symbol;
|
|
406
401
|
tokenInfo.decimals = validate.decimals;
|
|
407
402
|
}
|
|
@@ -825,6 +820,60 @@ export default class KoniTabs {
|
|
|
825
820
|
return false;
|
|
826
821
|
}
|
|
827
822
|
}
|
|
823
|
+
async addPspToken(id, url, {
|
|
824
|
+
genesisHash,
|
|
825
|
+
tokenInfo: input
|
|
826
|
+
}) {
|
|
827
|
+
const _tokenType = input.type;
|
|
828
|
+
if (_tokenType !== 'psp22' && _tokenType !== 'psp34') {
|
|
829
|
+
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, `Assets type ${_tokenType} is not supported`);
|
|
830
|
+
}
|
|
831
|
+
if (!input.address || !input.symbol) {
|
|
832
|
+
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, 'Assets params require address and symbol');
|
|
833
|
+
}
|
|
834
|
+
const [chain] = this.#koniState.findNetworkKeyByGenesisHash(genesisHash);
|
|
835
|
+
if (!chain) {
|
|
836
|
+
throw new EvmProviderError(EvmProviderErrorType.INTERNAL_ERROR, 'Current chain is not available');
|
|
837
|
+
}
|
|
838
|
+
const state = this.#koniState.getChainStateByKey(chain);
|
|
839
|
+
if (!state.active) {
|
|
840
|
+
await this.#koniState.enableChain(chain, false);
|
|
841
|
+
const api = this.#koniState.getSubstrateApi(chain);
|
|
842
|
+
await api.isReady;
|
|
843
|
+
}
|
|
844
|
+
const tokenType = _tokenType === 'psp22' ? _AssetType.PSP22 : _AssetType.PSP34;
|
|
845
|
+
const tokenInfo = {
|
|
846
|
+
slug: '',
|
|
847
|
+
type: tokenType,
|
|
848
|
+
name: input.symbol || '',
|
|
849
|
+
contractAddress: input.address,
|
|
850
|
+
symbol: input.symbol || '',
|
|
851
|
+
decimals: input.decimals || 0,
|
|
852
|
+
originChain: chain,
|
|
853
|
+
contractError: false,
|
|
854
|
+
validated: false
|
|
855
|
+
};
|
|
856
|
+
this.#koniState.validateCustomAsset({
|
|
857
|
+
type: tokenType,
|
|
858
|
+
contractAddress: input.address,
|
|
859
|
+
originChain: chain
|
|
860
|
+
}).then(validate => {
|
|
861
|
+
if (validate.contractError) {
|
|
862
|
+
tokenInfo.contractError = true;
|
|
863
|
+
} else {
|
|
864
|
+
tokenInfo.slug = validate === null || validate === void 0 ? void 0 : validate.existedSlug;
|
|
865
|
+
tokenInfo.name = validate.name || tokenInfo.name;
|
|
866
|
+
tokenInfo.symbol = validate.symbol;
|
|
867
|
+
tokenInfo.decimals = validate.decimals;
|
|
868
|
+
}
|
|
869
|
+
}).catch(() => {
|
|
870
|
+
tokenInfo.contractError = true;
|
|
871
|
+
}).finally(() => {
|
|
872
|
+
tokenInfo.validated = true;
|
|
873
|
+
this.#koniState.requestService.updateConfirmation(id, 'addTokenRequest', tokenInfo);
|
|
874
|
+
});
|
|
875
|
+
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
876
|
+
}
|
|
828
877
|
async handle(id, type, request, url, port) {
|
|
829
878
|
if (type === 'pub(phishing.redirectIfDenied)') {
|
|
830
879
|
return this.redirectIfPhishing(url);
|
|
@@ -860,6 +909,8 @@ export default class KoniTabs {
|
|
|
860
909
|
return this.rpcSubscribeConnected(request, id, port);
|
|
861
910
|
case 'pub(rpc.unsubscribe)':
|
|
862
911
|
return this.rpcUnsubscribe(request, port);
|
|
912
|
+
case 'pub(token.add)':
|
|
913
|
+
return this.addPspToken(id, url, request);
|
|
863
914
|
|
|
864
915
|
///
|
|
865
916
|
case 'pub(authorize.tabV2)':
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.0.
|
|
20
|
+
"version": "1.0.13-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -735,6 +735,11 @@
|
|
|
735
735
|
"require": "./cjs/services/request-service/handler/SubstrateRequestHandler.js",
|
|
736
736
|
"default": "./services/request-service/handler/SubstrateRequestHandler.js"
|
|
737
737
|
},
|
|
738
|
+
"./services/request-service/handler/WalletConnectRequestHandler": {
|
|
739
|
+
"types": "./services/request-service/handler/WalletConnectRequestHandler.d.ts",
|
|
740
|
+
"require": "./cjs/services/request-service/handler/WalletConnectRequestHandler.js",
|
|
741
|
+
"default": "./services/request-service/handler/WalletConnectRequestHandler.js"
|
|
742
|
+
},
|
|
738
743
|
"./services/request-service/helper": {
|
|
739
744
|
"types": "./services/request-service/helper/index.d.ts",
|
|
740
745
|
"require": "./cjs/services/request-service/helper/index.js",
|
|
@@ -900,6 +905,36 @@
|
|
|
900
905
|
"require": "./cjs/services/transaction-service/utils.js",
|
|
901
906
|
"default": "./services/transaction-service/utils.js"
|
|
902
907
|
},
|
|
908
|
+
"./services/wallet-connect-service": {
|
|
909
|
+
"types": "./services/wallet-connect-service/index.d.ts",
|
|
910
|
+
"require": "./cjs/services/wallet-connect-service/index.js",
|
|
911
|
+
"default": "./services/wallet-connect-service/index.js"
|
|
912
|
+
},
|
|
913
|
+
"./services/wallet-connect-service/constants": {
|
|
914
|
+
"types": "./services/wallet-connect-service/constants.d.ts",
|
|
915
|
+
"require": "./cjs/services/wallet-connect-service/constants.js",
|
|
916
|
+
"default": "./services/wallet-connect-service/constants.js"
|
|
917
|
+
},
|
|
918
|
+
"./services/wallet-connect-service/handler/Eip155RequestHandler": {
|
|
919
|
+
"types": "./services/wallet-connect-service/handler/Eip155RequestHandler.d.ts",
|
|
920
|
+
"require": "./cjs/services/wallet-connect-service/handler/Eip155RequestHandler.js",
|
|
921
|
+
"default": "./services/wallet-connect-service/handler/Eip155RequestHandler.js"
|
|
922
|
+
},
|
|
923
|
+
"./services/wallet-connect-service/handler/PolkadotRequestHandler": {
|
|
924
|
+
"types": "./services/wallet-connect-service/handler/PolkadotRequestHandler.d.ts",
|
|
925
|
+
"require": "./cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js",
|
|
926
|
+
"default": "./services/wallet-connect-service/handler/PolkadotRequestHandler.js"
|
|
927
|
+
},
|
|
928
|
+
"./services/wallet-connect-service/helpers": {
|
|
929
|
+
"types": "./services/wallet-connect-service/helpers.d.ts",
|
|
930
|
+
"require": "./cjs/services/wallet-connect-service/helpers.js",
|
|
931
|
+
"default": "./services/wallet-connect-service/helpers.js"
|
|
932
|
+
},
|
|
933
|
+
"./services/wallet-connect-service/types": {
|
|
934
|
+
"types": "./services/wallet-connect-service/types.d.ts",
|
|
935
|
+
"require": "./cjs/services/wallet-connect-service/types.js",
|
|
936
|
+
"default": "./services/wallet-connect-service/types.js"
|
|
937
|
+
},
|
|
903
938
|
"./signers/substrates/KeyringSigner": {
|
|
904
939
|
"types": "./signers/substrates/KeyringSigner.d.ts",
|
|
905
940
|
"require": "./cjs/signers/substrates/KeyringSigner.js",
|
|
@@ -1020,11 +1055,21 @@
|
|
|
1020
1055
|
"require": "./cjs/utils/address.js",
|
|
1021
1056
|
"default": "./utils/address.js"
|
|
1022
1057
|
},
|
|
1058
|
+
"./utils/array": {
|
|
1059
|
+
"types": "./utils/array.d.ts",
|
|
1060
|
+
"require": "./cjs/utils/array.js",
|
|
1061
|
+
"default": "./utils/array.js"
|
|
1062
|
+
},
|
|
1023
1063
|
"./utils/canDerive": {
|
|
1024
1064
|
"types": "./utils/canDerive.d.ts",
|
|
1025
1065
|
"require": "./cjs/utils/canDerive.js",
|
|
1026
1066
|
"default": "./utils/canDerive.js"
|
|
1027
1067
|
},
|
|
1068
|
+
"./utils/environment": {
|
|
1069
|
+
"types": "./utils/environment.d.ts",
|
|
1070
|
+
"require": "./cjs/utils/environment.js",
|
|
1071
|
+
"default": "./utils/environment.js"
|
|
1072
|
+
},
|
|
1028
1073
|
"./utils/eth": {
|
|
1029
1074
|
"types": "./utils/eth.d.ts",
|
|
1030
1075
|
"require": "./cjs/utils/eth.js",
|
|
@@ -1078,6 +1123,7 @@
|
|
|
1078
1123
|
"@ethereumjs/common": "^2.6.5",
|
|
1079
1124
|
"@ethereumjs/tx": "^4.0.2",
|
|
1080
1125
|
"@ethersproject/abi": "^5.7.0",
|
|
1126
|
+
"@json-rpc-tools/utils": "^1.7.6",
|
|
1081
1127
|
"@metamask/safe-event-emitter": "^2.0.0",
|
|
1082
1128
|
"@metaverse-network-sdk/type-definitions": "^0.0.1-13",
|
|
1083
1129
|
"@oak-foundation/types": "^0.0.23",
|
|
@@ -1097,13 +1143,16 @@
|
|
|
1097
1143
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1098
1144
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1099
1145
|
"@substrate/connect": "^0.7.26",
|
|
1100
|
-
"@subwallet/chain-list": "^0.2.
|
|
1101
|
-
"@subwallet/extension-base": "^1.0.
|
|
1102
|
-
"@subwallet/extension-chains": "^1.0.
|
|
1103
|
-
"@subwallet/extension-dapp": "^1.0.
|
|
1104
|
-
"@subwallet/extension-inject": "^1.0.
|
|
1146
|
+
"@subwallet/chain-list": "^0.2.4",
|
|
1147
|
+
"@subwallet/extension-base": "^1.0.13-0",
|
|
1148
|
+
"@subwallet/extension-chains": "^1.0.13-0",
|
|
1149
|
+
"@subwallet/extension-dapp": "^1.0.13-0",
|
|
1150
|
+
"@subwallet/extension-inject": "^1.0.13-0",
|
|
1105
1151
|
"@subwallet/keyring": "^0.0.10",
|
|
1106
1152
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1153
|
+
"@walletconnect/sign-client": "^2.8.4",
|
|
1154
|
+
"@walletconnect/types": "^2.8.4",
|
|
1155
|
+
"@walletconnect/utils": "^2.8.4",
|
|
1107
1156
|
"axios": "^1.2.1",
|
|
1108
1157
|
"bignumber.js": "^9.1.1",
|
|
1109
1158
|
"bn.js": "^5.2.1",
|
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.0.
|
|
10
|
+
version: '1.0.13-0'
|
|
11
11
|
};
|
package/page/Metadata.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { InjectedMetadata, InjectedMetadataKnown, MetadataDef } from '@subwallet/extension-inject/types';
|
|
2
2
|
import type { SendRequest } from './types';
|
|
3
|
+
import { RequestAddPspToken } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
4
|
export default class Metadata implements InjectedMetadata {
|
|
4
5
|
constructor(_sendRequest: SendRequest);
|
|
5
6
|
get(): Promise<InjectedMetadataKnown[]>;
|
|
6
7
|
provide(definition: MetadataDef): Promise<boolean>;
|
|
8
|
+
addToken(request: RequestAddPspToken): Promise<boolean>;
|
|
7
9
|
}
|