@subwallet/extension-base 1.1.3-0 → 1.1.5-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 +14 -4
- package/background/types.d.ts +4 -0
- package/cjs/koni/api/nft/config.js +19 -16
- package/cjs/koni/api/nft/nft.js +1 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +57 -48
- package/cjs/koni/background/handlers/Extension.js +49 -11
- package/cjs/koni/background/handlers/Tabs.js +65 -31
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/Accounts.js +7 -2
- package/cjs/page/Injected.js +5 -0
- package/cjs/services/chain-service/index.js +9 -0
- package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -2
- package/cjs/services/request-service/handler/{WalletConnectRequestHandler.js → ConnectWCRequestHandler.js} +9 -9
- package/cjs/services/request-service/handler/NotSupportWCRequestHandler.js +71 -0
- package/cjs/services/request-service/handler/index.js +55 -0
- package/cjs/services/request-service/index.js +36 -22
- package/cjs/services/transaction-service/index.js +5 -1
- package/cjs/services/wallet-connect-service/helpers.js +10 -1
- package/cjs/services/wallet-connect-service/index.js +5 -0
- package/koni/api/nft/config.d.ts +3 -3
- package/koni/api/nft/config.js +15 -12
- package/koni/api/nft/nft.js +1 -1
- package/koni/api/nft/rmrk_nft/index.d.ts +0 -1
- package/koni/api/nft/rmrk_nft/index.js +58 -49
- package/koni/background/handlers/Extension.d.ts +4 -1
- package/koni/background/handlers/Extension.js +43 -7
- package/koni/background/handlers/Tabs.d.ts +3 -1
- package/koni/background/handlers/Tabs.js +44 -11
- package/package.json +21 -11
- package/packageInfo.js +1 -1
- package/page/Accounts.js +7 -2
- package/page/Injected.js +5 -0
- package/services/chain-service/index.js +9 -0
- package/services/request-service/handler/AuthRequestHandler.d.ts +3 -3
- package/services/request-service/handler/AuthRequestHandler.js +5 -3
- package/services/request-service/handler/{WalletConnectRequestHandler.d.ts → ConnectWCRequestHandler.d.ts} +1 -1
- package/services/request-service/handler/{WalletConnectRequestHandler.js → ConnectWCRequestHandler.js} +8 -8
- package/services/request-service/handler/NotSupportWCRequestHandler.d.ts +15 -0
- package/services/request-service/handler/NotSupportWCRequestHandler.js +62 -0
- package/services/request-service/handler/index.d.ts +7 -0
- package/services/request-service/handler/index.js +10 -0
- package/services/request-service/index.d.ts +11 -6
- package/services/request-service/index.js +31 -16
- package/services/transaction-service/index.js +5 -1
- package/services/wallet-connect-service/helpers.d.ts +2 -1
- package/services/wallet-connect-service/helpers.js +8 -0
- package/services/wallet-connect-service/index.js +6 -1
- package/services/wallet-connect-service/types.d.ts +5 -0
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
3
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
4
4
|
import { AuthUrls, Resolver } from '@subwallet/extension-base/background/handlers/State';
|
|
5
|
-
import { AccountAuthType, AccountJson, AddressJson, AuthorizeRequest, ConfirmationRequestBase, RequestAccountList, RequestAccountSubscribe, RequestAuthorizeCancel, RequestAuthorizeReject, RequestAuthorizeSubscribe, RequestAuthorizeTab, RequestCurrentAccountAddress, ResponseAuthorizeList, ResponseJsonGetAccountInfo, SeedLengths } from '@subwallet/extension-base/background/types';
|
|
5
|
+
import { AccountAuthType, AccountJson, AddressJson, AuthorizeRequest, ConfirmationRequestBase, RequestAccountList, RequestAccountSubscribe, RequestAccountUnsubscribe, RequestAuthorizeCancel, RequestAuthorizeReject, RequestAuthorizeSubscribe, RequestAuthorizeTab, RequestCurrentAccountAddress, ResponseAuthorizeList, ResponseJsonGetAccountInfo, SeedLengths } from '@subwallet/extension-base/background/types';
|
|
6
6
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
7
7
|
import { _ChainState, _EvmApi, _NetworkUpsertParams, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse, EnableChainParams, EnableMultiChainParams } from '@subwallet/extension-base/services/chain-service/types';
|
|
8
8
|
import { SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
|
|
9
|
-
import { WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
9
|
+
import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
10
10
|
import { InjectedAccount, MetadataDefBase } from '@subwallet/extension-inject/types';
|
|
11
11
|
import { KeyringPair$Json, KeyringPair$Meta } from '@subwallet/keyring/types';
|
|
12
12
|
import { KeyringOptions } from '@subwallet/ui-keyring/options/types';
|
|
@@ -1466,6 +1466,12 @@ export interface RequestReconnectConnectWalletSession {
|
|
|
1466
1466
|
export interface RequestDisconnectWalletConnectSession {
|
|
1467
1467
|
topic: string;
|
|
1468
1468
|
}
|
|
1469
|
+
export interface RequestRejectWalletConnectNotSupport {
|
|
1470
|
+
id: string;
|
|
1471
|
+
}
|
|
1472
|
+
export interface RequestApproveWalletConnectNotSupport {
|
|
1473
|
+
id: string;
|
|
1474
|
+
}
|
|
1469
1475
|
export interface MantaPayConfig {
|
|
1470
1476
|
address: string;
|
|
1471
1477
|
zkAddress: string;
|
|
@@ -1626,7 +1632,8 @@ export interface KoniRequestSignatures {
|
|
|
1626
1632
|
'pri(confirmations.complete)': [RequestConfirmationComplete, boolean];
|
|
1627
1633
|
'pub(utils.getRandom)': [RandomTestRequest, number];
|
|
1628
1634
|
'pub(accounts.listV2)': [RequestAccountList, InjectedAccount[]];
|
|
1629
|
-
'pub(accounts.subscribeV2)': [RequestAccountSubscribe,
|
|
1635
|
+
'pub(accounts.subscribeV2)': [RequestAccountSubscribe, string, InjectedAccount[]];
|
|
1636
|
+
'pub(accounts.unsubscribe)': [RequestAccountUnsubscribe, boolean];
|
|
1630
1637
|
'pri(account.isLocked)': [RequestAccountIsLocked, ResponseAccountIsLocked];
|
|
1631
1638
|
'pri(qr.transaction.parse.substrate)': [RequestParseTransactionSubstrate, ResponseParseTransactionSubstrate];
|
|
1632
1639
|
'pri(qr.transaction.parse.evm)': [RequestQrParseRLP, ResponseQrParseRLP];
|
|
@@ -1669,12 +1676,15 @@ export interface KoniRequestSignatures {
|
|
|
1669
1676
|
'mobile(subscription.restart)': [SubscriptionServiceType[], void];
|
|
1670
1677
|
'pub(token.add)': [RequestAddPspToken, boolean];
|
|
1671
1678
|
'pri(walletConnect.connect)': [RequestConnectWalletConnect, boolean];
|
|
1672
|
-
'pri(walletConnect.requests.subscribe)': [null, WalletConnectSessionRequest[], WalletConnectSessionRequest[]];
|
|
1679
|
+
'pri(walletConnect.requests.connect.subscribe)': [null, WalletConnectSessionRequest[], WalletConnectSessionRequest[]];
|
|
1673
1680
|
'pri(walletConnect.session.approve)': [RequestApproveConnectWalletSession, boolean];
|
|
1674
1681
|
'pri(walletConnect.session.reject)': [RequestRejectConnectWalletSession, boolean];
|
|
1675
1682
|
'pri(walletConnect.session.reconnect)': [RequestReconnectConnectWalletSession, boolean];
|
|
1676
1683
|
'pri(walletConnect.session.subscribe)': [null, SessionTypes.Struct[], SessionTypes.Struct[]];
|
|
1677
1684
|
'pri(walletConnect.session.disconnect)': [RequestDisconnectWalletConnectSession, boolean];
|
|
1685
|
+
'pri(walletConnect.requests.notSupport.subscribe)': [null, WalletConnectNotSupportRequest[], WalletConnectNotSupportRequest[]];
|
|
1686
|
+
'pri(walletConnect.notSupport.approve)': [RequestApproveWalletConnectNotSupport, boolean];
|
|
1687
|
+
'pri(walletConnect.notSupport.reject)': [RequestRejectWalletConnectNotSupport, boolean];
|
|
1678
1688
|
'pri(metadata.find)': [RequestFindRawMetadata, ResponseFindRawMetadata];
|
|
1679
1689
|
}
|
|
1680
1690
|
export interface ApplicationMetadataType {
|
package/background/types.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export interface RequestSignatures extends KoniRequestSignatures {
|
|
|
134
134
|
'pub(metadata.list)': [null, InjectedMetadataKnown[]];
|
|
135
135
|
'pub(metadata.provide)': [MetadataDef, boolean];
|
|
136
136
|
'pub(phishing.redirectIfDenied)': [null, boolean];
|
|
137
|
+
'pub(ping)': [null, boolean];
|
|
137
138
|
'pub(rpc.listProviders)': [void, ResponseRpcListProviders];
|
|
138
139
|
'pub(rpc.send)': [RequestRpcSend, JsonRpcResponse<unknown>];
|
|
139
140
|
'pub(rpc.startProvider)': [string, ProviderMeta];
|
|
@@ -252,6 +253,9 @@ export interface RequestAccountList {
|
|
|
252
253
|
export interface RequestAccountSubscribe {
|
|
253
254
|
accountAuthType?: AccountAuthType;
|
|
254
255
|
}
|
|
256
|
+
export interface RequestAccountUnsubscribe {
|
|
257
|
+
id: string;
|
|
258
|
+
}
|
|
255
259
|
export interface RequestRpcSend {
|
|
256
260
|
method: string;
|
|
257
261
|
params: unknown[];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.
|
|
6
|
+
exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_W3S_LINK = exports.IPFS_HARDBIN = exports.IPFS_GATEWAY_4EVERLAND = exports.IPFS_FLEEK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = exports.BIT_COUNTRY_IPFS_SERVER = void 0;
|
|
7
7
|
exports.getRandomIpfsGateway = getRandomIpfsGateway;
|
|
8
8
|
var _utils = require("@subwallet/extension-base/utils");
|
|
9
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -43,18 +43,18 @@ const UNIQUE_IPFS_GATEWAY = 'https://ipfs.unique.network/ipfs/';
|
|
|
43
43
|
exports.UNIQUE_IPFS_GATEWAY = UNIQUE_IPFS_GATEWAY;
|
|
44
44
|
const NFT_STORAGE_GATEWAY = 'https://nftstorage.link/ipfs/';
|
|
45
45
|
exports.NFT_STORAGE_GATEWAY = NFT_STORAGE_GATEWAY;
|
|
46
|
-
const
|
|
47
|
-
exports.
|
|
46
|
+
const IPFS_W3S_LINK = 'https://w3s.link/ipfs/';
|
|
47
|
+
exports.IPFS_W3S_LINK = IPFS_W3S_LINK;
|
|
48
48
|
const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
|
|
49
49
|
exports.GATEWAY_IPFS_IO = GATEWAY_IPFS_IO;
|
|
50
50
|
const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
51
51
|
exports.DWEB_LINK = DWEB_LINK;
|
|
52
|
-
const
|
|
53
|
-
exports.
|
|
52
|
+
const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
53
|
+
exports.IPFS_GATEWAY_4EVERLAND = IPFS_GATEWAY_4EVERLAND;
|
|
54
54
|
const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
55
55
|
exports.IPFS_FLEEK = IPFS_FLEEK;
|
|
56
|
-
const
|
|
57
|
-
exports.
|
|
56
|
+
const IPFS_HARDBIN = 'https://hardbin.com/ipfs';
|
|
57
|
+
exports.IPFS_HARDBIN = IPFS_HARDBIN;
|
|
58
58
|
let SUPPORTED_NFT_NETWORKS;
|
|
59
59
|
exports.SUPPORTED_NFT_NETWORKS = SUPPORTED_NFT_NETWORKS;
|
|
60
60
|
(function (SUPPORTED_NFT_NETWORKS) {
|
|
@@ -103,9 +103,6 @@ exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = SUPPORTED_TRANSFER_SUBSTRATE_C
|
|
|
103
103
|
SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME["pioneer"] = "pioneer";
|
|
104
104
|
})(SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME || (exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = {}));
|
|
105
105
|
const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
106
|
-
provider: IPFS_IO_GATEWAY,
|
|
107
|
-
weight: 0 // Not stable
|
|
108
|
-
}, {
|
|
109
106
|
provider: CF_IPFS_GATEWAY,
|
|
110
107
|
weight: 4
|
|
111
108
|
}, {
|
|
@@ -120,12 +117,6 @@ const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
|
120
117
|
}, {
|
|
121
118
|
provider: DWEB_LINK,
|
|
122
119
|
weight: 5
|
|
123
|
-
}, {
|
|
124
|
-
provider: IPFS_GATEWAY_CLOUD,
|
|
125
|
-
weight: 0 // Deceptive site warning
|
|
126
|
-
}, {
|
|
127
|
-
provider: IPFS_TELOS_MIAMI,
|
|
128
|
-
weight: 0
|
|
129
120
|
}];
|
|
130
121
|
if (!_utils.RuntimeInfo.protocol || _utils.RuntimeInfo.protocol && !_utils.RuntimeInfo.protocol.startsWith('http')) {
|
|
131
122
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
@@ -136,6 +127,18 @@ if (!_utils.RuntimeInfo.protocol || _utils.RuntimeInfo.protocol && !_utils.Runti
|
|
|
136
127
|
provider: IPFS_FLEEK,
|
|
137
128
|
weight: 4
|
|
138
129
|
});
|
|
130
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
131
|
+
provider: IPFS_HARDBIN,
|
|
132
|
+
weight: 1
|
|
133
|
+
});
|
|
134
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
135
|
+
provider: IPFS_GATEWAY_4EVERLAND,
|
|
136
|
+
weight: 2
|
|
137
|
+
});
|
|
138
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
139
|
+
provider: IPFS_W3S_LINK,
|
|
140
|
+
weight: 1
|
|
141
|
+
});
|
|
139
142
|
}
|
|
140
143
|
const RANDOM_IPFS_GATEWAY_TOTAL_WEIGHT = RANDOM_IPFS_GATEWAY_SETTING.reduce((value, item) => value + item.weight, 0);
|
|
141
144
|
function getRandomIpfsGateway() {
|
package/cjs/koni/api/nft/nft.js
CHANGED
|
@@ -74,7 +74,7 @@ class BaseNftApi {
|
|
|
74
74
|
if (!input || input.length === 0) {
|
|
75
75
|
return undefined;
|
|
76
76
|
}
|
|
77
|
-
if ((0, _utils.isUrl)(input)) {
|
|
77
|
+
if ((0, _utils.isUrl)(input) || input.includes('https://') || input.includes('http')) {
|
|
78
78
|
return input;
|
|
79
79
|
}
|
|
80
80
|
if (input.startsWith('/ipfs/')) {
|
|
@@ -24,18 +24,23 @@ class RmrkNftApi extends _nft.BaseNftApi {
|
|
|
24
24
|
constructor(addresses, chain) {
|
|
25
25
|
super(chain, null, addresses);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
|
|
28
|
+
// override parseUrl (input: string): string | undefined {
|
|
29
|
+
// if (!input || input.length === 0) {
|
|
30
|
+
// return undefined;
|
|
31
|
+
// }
|
|
32
|
+
//
|
|
33
|
+
// if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
34
|
+
// return input;
|
|
35
|
+
// }
|
|
36
|
+
//
|
|
37
|
+
// if (!input.includes('ipfs://ipfs/')) {
|
|
38
|
+
// return getRandomIpfsGateway() + input;
|
|
39
|
+
// }
|
|
40
|
+
//
|
|
41
|
+
// return getRandomIpfsGateway() + input.split('ipfs://ipfs/')[1];
|
|
42
|
+
// }
|
|
43
|
+
|
|
39
44
|
async getMetadata(metadataUrl) {
|
|
40
45
|
let url = metadataUrl;
|
|
41
46
|
if (!(0, _utils.isUrl)(metadataUrl)) {
|
|
@@ -76,53 +81,57 @@ class RmrkNftApi extends _nft.BaseNftApi {
|
|
|
76
81
|
}));
|
|
77
82
|
const nfts = [];
|
|
78
83
|
await Promise.all(data.map(async item => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
...item,
|
|
100
|
-
metadata: {
|
|
101
|
-
description: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.description,
|
|
102
|
-
name: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.name,
|
|
103
|
-
attributes: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.attributes,
|
|
104
|
-
animation_url: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.animation_url),
|
|
105
|
-
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.image)
|
|
106
|
-
},
|
|
107
|
-
owner: account
|
|
108
|
-
});
|
|
109
|
-
} else if (item.source === RMRK_SOURCE.SINGULAR_V2) {
|
|
110
|
-
const id = item.id;
|
|
111
|
-
if (!id.toLowerCase().includes(KANBIRD_KEYWORD)) {
|
|
112
|
-
// excludes kanaria bird, already handled above
|
|
84
|
+
try {
|
|
85
|
+
const primaryResource = item.primaryResource ? item.primaryResource : null;
|
|
86
|
+
const metadataUri = primaryResource && primaryResource.metadata ? primaryResource.metadata : item.metadata;
|
|
87
|
+
const nftMetadata = await this.getMetadata(metadataUri);
|
|
88
|
+
if (item.source === RMRK_SOURCE.BIRD_KANARIA) {
|
|
89
|
+
nfts.push({
|
|
90
|
+
...item,
|
|
91
|
+
metadata: nftMetadata,
|
|
92
|
+
owner: account
|
|
93
|
+
});
|
|
94
|
+
} else if (item.source === RMRK_SOURCE.KANARIA) {
|
|
95
|
+
nfts.push({
|
|
96
|
+
...item,
|
|
97
|
+
metadata: {
|
|
98
|
+
...nftMetadata,
|
|
99
|
+
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.image)
|
|
100
|
+
},
|
|
101
|
+
owner: account
|
|
102
|
+
});
|
|
103
|
+
} else if (item.source === RMRK_SOURCE.SINGULAR_V1) {
|
|
113
104
|
nfts.push({
|
|
114
105
|
...item,
|
|
115
106
|
metadata: {
|
|
116
107
|
description: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.description,
|
|
117
108
|
name: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.name,
|
|
118
109
|
attributes: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.attributes,
|
|
119
|
-
properties: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.properties,
|
|
120
110
|
animation_url: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.animation_url),
|
|
121
|
-
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.
|
|
111
|
+
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.image)
|
|
122
112
|
},
|
|
123
113
|
owner: account
|
|
124
114
|
});
|
|
115
|
+
} else if (item.source === RMRK_SOURCE.SINGULAR_V2) {
|
|
116
|
+
const id = item.id;
|
|
117
|
+
if (!id.toLowerCase().includes(KANBIRD_KEYWORD)) {
|
|
118
|
+
// excludes kanaria bird, already handled above
|
|
119
|
+
nfts.push({
|
|
120
|
+
...item,
|
|
121
|
+
metadata: {
|
|
122
|
+
description: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.description,
|
|
123
|
+
name: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.name,
|
|
124
|
+
attributes: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.attributes,
|
|
125
|
+
properties: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.properties,
|
|
126
|
+
animation_url: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.animation_url),
|
|
127
|
+
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.mediaUri)
|
|
128
|
+
},
|
|
129
|
+
owner: account
|
|
130
|
+
});
|
|
131
|
+
}
|
|
125
132
|
}
|
|
133
|
+
} catch (e) {
|
|
134
|
+
console.log('error fetching RMRK NFT', e);
|
|
126
135
|
}
|
|
127
136
|
}));
|
|
128
137
|
return nfts;
|
|
@@ -696,10 +696,10 @@ class KoniExtension {
|
|
|
696
696
|
});
|
|
697
697
|
return true;
|
|
698
698
|
}
|
|
699
|
-
|
|
699
|
+
getAccounts() {
|
|
700
700
|
const storedAccounts = this.#koniState.keyringService.accounts;
|
|
701
701
|
const transformedAccounts = transformAccounts(storedAccounts);
|
|
702
|
-
return transformedAccounts.
|
|
702
|
+
return transformedAccounts.map(a => a.address);
|
|
703
703
|
}
|
|
704
704
|
isAddressValidWithAuthType(address, accountAuthType) {
|
|
705
705
|
if (accountAuthType === 'substrate') {
|
|
@@ -721,12 +721,12 @@ class KoniExtension {
|
|
|
721
721
|
_changeAuthorizationAll(connectValue, callBack) {
|
|
722
722
|
this.#koniState.getAuthorize(value => {
|
|
723
723
|
(0, _util.assert)(value, 'The source is not known');
|
|
724
|
-
const
|
|
724
|
+
const accounts = this.getAccounts();
|
|
725
725
|
Object.keys(value).forEach(url => {
|
|
726
726
|
if (!value[url].isAllowed) {
|
|
727
727
|
return;
|
|
728
728
|
}
|
|
729
|
-
const targetAccounts = this.filterAccountsByAccountAuthType(
|
|
729
|
+
const targetAccounts = this.filterAccountsByAccountAuthType(accounts, value[url].accountAuthType);
|
|
730
730
|
targetAccounts.forEach(address => {
|
|
731
731
|
value[url].isAllowedMap[address] = connectValue;
|
|
732
732
|
});
|
|
@@ -749,8 +749,8 @@ class KoniExtension {
|
|
|
749
749
|
_changeAuthorization(url, connectValue, callBack) {
|
|
750
750
|
this.#koniState.getAuthorize(value => {
|
|
751
751
|
(0, _util.assert)(value[url], 'The source is not known');
|
|
752
|
-
const
|
|
753
|
-
const targetAccounts = this.filterAccountsByAccountAuthType(
|
|
752
|
+
const accounts = this.getAccounts();
|
|
753
|
+
const targetAccounts = this.filterAccountsByAccountAuthType(accounts, value[url].accountAuthType);
|
|
754
754
|
targetAccounts.forEach(address => {
|
|
755
755
|
value[url].isAllowedMap[address] = connectValue;
|
|
756
756
|
});
|
|
@@ -3314,11 +3314,39 @@ class KoniExtension {
|
|
|
3314
3314
|
await this.#koniState.walletConnectService.disconnect(topic);
|
|
3315
3315
|
return true;
|
|
3316
3316
|
}
|
|
3317
|
-
|
|
3317
|
+
WCNotSupportSubscribe(id, port) {
|
|
3318
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3319
|
+
const subscription = this.#koniState.requestService.notSupportWCSubject.subscribe(requests => cb(requests));
|
|
3320
|
+
port.onDisconnect.addListener(() => {
|
|
3321
|
+
this.cancelSubscription(id);
|
|
3322
|
+
subscription.unsubscribe();
|
|
3323
|
+
});
|
|
3324
|
+
return this.#koniState.requestService.allNotSupportWCRequests;
|
|
3325
|
+
}
|
|
3326
|
+
approveWalletConnectNotSupport(_ref86) {
|
|
3327
|
+
let {
|
|
3328
|
+
id
|
|
3329
|
+
} = _ref86;
|
|
3330
|
+
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
3331
|
+
request.resolve();
|
|
3332
|
+
return true;
|
|
3333
|
+
}
|
|
3334
|
+
rejectWalletConnectNotSupport(_ref87) {
|
|
3335
|
+
let {
|
|
3336
|
+
id
|
|
3337
|
+
} = _ref87;
|
|
3338
|
+
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
3339
|
+
request.reject(new Error('USER_REJECTED'));
|
|
3340
|
+
return true;
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
/// Manta
|
|
3344
|
+
|
|
3345
|
+
async enableMantaPay(_ref88) {
|
|
3318
3346
|
let {
|
|
3319
3347
|
address,
|
|
3320
3348
|
password
|
|
3321
|
-
} =
|
|
3349
|
+
} = _ref88;
|
|
3322
3350
|
// always takes the current account
|
|
3323
3351
|
function timeout() {
|
|
3324
3352
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
@@ -3442,10 +3470,10 @@ class KoniExtension {
|
|
|
3442
3470
|
|
|
3443
3471
|
/// Metadata
|
|
3444
3472
|
|
|
3445
|
-
async findRawMetadata(
|
|
3473
|
+
async findRawMetadata(_ref89) {
|
|
3446
3474
|
let {
|
|
3447
3475
|
genesisHash
|
|
3448
|
-
} =
|
|
3476
|
+
} = _ref89;
|
|
3449
3477
|
const {
|
|
3450
3478
|
metadata,
|
|
3451
3479
|
specVersion
|
|
@@ -3840,7 +3868,7 @@ class KoniExtension {
|
|
|
3840
3868
|
/// Wallet Connect
|
|
3841
3869
|
case 'pri(walletConnect.connect)':
|
|
3842
3870
|
return this.connectWalletConnect(request);
|
|
3843
|
-
case 'pri(walletConnect.requests.subscribe)':
|
|
3871
|
+
case 'pri(walletConnect.requests.connect.subscribe)':
|
|
3844
3872
|
return this.connectWCSubscribe(id, port);
|
|
3845
3873
|
case 'pri(walletConnect.session.approve)':
|
|
3846
3874
|
return this.approveWalletConnectSession(request);
|
|
@@ -3850,6 +3878,16 @@ class KoniExtension {
|
|
|
3850
3878
|
return this.subscribeWalletConnectSessions(id, port);
|
|
3851
3879
|
case 'pri(walletConnect.session.disconnect)':
|
|
3852
3880
|
return this.disconnectWalletConnectSession(request);
|
|
3881
|
+
|
|
3882
|
+
// Not support
|
|
3883
|
+
case 'pri(walletConnect.requests.notSupport.subscribe)':
|
|
3884
|
+
return this.WCNotSupportSubscribe(id, port);
|
|
3885
|
+
case 'pri(walletConnect.notSupport.approve)':
|
|
3886
|
+
return this.approveWalletConnectNotSupport(request);
|
|
3887
|
+
case 'pri(walletConnect.notSupport.reject)':
|
|
3888
|
+
return this.rejectWalletConnectNotSupport(request);
|
|
3889
|
+
|
|
3890
|
+
// Manta
|
|
3853
3891
|
case 'pri(mantaPay.enable)':
|
|
3854
3892
|
return await this.enableMantaPay(request);
|
|
3855
3893
|
case 'pri(mantaPay.initSyncMantaPay)':
|
|
@@ -109,6 +109,7 @@ const chainPatrolCheckUrl = async url => {
|
|
|
109
109
|
};
|
|
110
110
|
exports.chainPatrolCheckUrl = chainPatrolCheckUrl;
|
|
111
111
|
class KoniTabs {
|
|
112
|
+
#accountSubs = {};
|
|
112
113
|
#koniState;
|
|
113
114
|
evmEventEmitterMap = {};
|
|
114
115
|
#chainPatrolService = _constants2.DEFAULT_CHAIN_PATROL_ENABLE;
|
|
@@ -137,17 +138,25 @@ class KoniTabs {
|
|
|
137
138
|
(0, _util.assert)(pair, 'Unable to find keypair');
|
|
138
139
|
return pair;
|
|
139
140
|
}
|
|
140
|
-
bytesSign(url, request) {
|
|
141
|
+
async bytesSign(url, request) {
|
|
141
142
|
const address = request.address;
|
|
142
143
|
const pair = this.getSigningPair(address);
|
|
144
|
+
const authInfo = await this.getAuthInfo(url);
|
|
145
|
+
if (!authInfo || !authInfo.isAllowed || !authInfo.isAllowedMap[pair.address]) {
|
|
146
|
+
throw new Error('Account {{address}} not in allowed list'.replace('{{address}}', address));
|
|
147
|
+
}
|
|
143
148
|
return this.#koniState.sign(url, new _RequestBytesSign.default(request), {
|
|
144
149
|
address,
|
|
145
150
|
...pair.meta
|
|
146
151
|
});
|
|
147
152
|
}
|
|
148
|
-
extrinsicSign(url, request) {
|
|
153
|
+
async extrinsicSign(url, request) {
|
|
149
154
|
const address = request.address;
|
|
150
155
|
const pair = this.getSigningPair(address);
|
|
156
|
+
const authInfo = await this.getAuthInfo(url);
|
|
157
|
+
if (!authInfo || !authInfo.isAllowed || !authInfo.isAllowedMap[pair.address]) {
|
|
158
|
+
throw new Error('Account {{address}} not in allowed list'.replace('{{address}}', address));
|
|
159
|
+
}
|
|
151
160
|
return this.#koniState.sign(url, new _RequestExtrinsicSign.default(request), {
|
|
152
161
|
address,
|
|
153
162
|
...pair.meta
|
|
@@ -255,8 +264,8 @@ class KoniTabs {
|
|
|
255
264
|
createUnsubscriptionHandle(id, unsubscribe) {
|
|
256
265
|
this.#koniState.createUnsubscriptionHandle(id, unsubscribe);
|
|
257
266
|
}
|
|
258
|
-
async getAuthInfo(url) {
|
|
259
|
-
const authList = await this.#koniState.getAuthList();
|
|
267
|
+
async getAuthInfo(url, fromList) {
|
|
268
|
+
const authList = fromList || (await this.#koniState.getAuthList());
|
|
260
269
|
const shortenUrl = (0, _utils2.stripUrl)(url);
|
|
261
270
|
return authList[shortenUrl];
|
|
262
271
|
}
|
|
@@ -273,15 +282,36 @@ class KoniTabs {
|
|
|
273
282
|
accountAuthType
|
|
274
283
|
} = _ref11;
|
|
275
284
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
const authInfoSubject = this.#koniState.requestService.subscribeAuthorizeUrlSubject;
|
|
286
|
+
|
|
287
|
+
// Update unsubscribe from @polkadot/extension-base
|
|
288
|
+
this.#accountSubs[id] = {
|
|
289
|
+
subscription: authInfoSubject.subscribe(infos => {
|
|
290
|
+
this.getAuthInfo(url, infos).then(authInfo => {
|
|
291
|
+
const accounts = this.#koniState.keyringService.accounts;
|
|
292
|
+
return cb(transformAccountsV2(accounts, false, authInfo, accountAuthType));
|
|
293
|
+
}).catch(console.error);
|
|
294
|
+
}),
|
|
295
|
+
url
|
|
296
|
+
};
|
|
282
297
|
port.onDisconnect.addListener(() => {
|
|
283
|
-
this.
|
|
298
|
+
this.accountsUnsubscribe(url, {
|
|
299
|
+
id
|
|
300
|
+
});
|
|
284
301
|
});
|
|
302
|
+
return id;
|
|
303
|
+
}
|
|
304
|
+
accountsUnsubscribe(url, _ref12) {
|
|
305
|
+
let {
|
|
306
|
+
id
|
|
307
|
+
} = _ref12;
|
|
308
|
+
const sub = this.#accountSubs[id];
|
|
309
|
+
if (!sub || sub.url !== url) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
delete this.#accountSubs[id];
|
|
313
|
+
(0, _subscriptions.unsubscribe)(id);
|
|
314
|
+
sub.subscription.unsubscribe();
|
|
285
315
|
return true;
|
|
286
316
|
}
|
|
287
317
|
authorizeV2(url, request) {
|
|
@@ -382,10 +412,10 @@ class KoniTabs {
|
|
|
382
412
|
date: new Date().getTime()
|
|
383
413
|
}];
|
|
384
414
|
}
|
|
385
|
-
async switchEvmChain(id, url,
|
|
415
|
+
async switchEvmChain(id, url, _ref13) {
|
|
386
416
|
let {
|
|
387
417
|
params
|
|
388
|
-
} =
|
|
418
|
+
} = _ref13;
|
|
389
419
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
390
420
|
const chainId = params[0].chainId;
|
|
391
421
|
const evmState = await this.getEvmState(url);
|
|
@@ -400,11 +430,11 @@ class KoniTabs {
|
|
|
400
430
|
}
|
|
401
431
|
return null;
|
|
402
432
|
}
|
|
403
|
-
async addEvmToken(id, url,
|
|
433
|
+
async addEvmToken(id, url, _ref14) {
|
|
404
434
|
var _input$type, _input$options, _input$options2, _input$options3, _input$options4, _input$options5;
|
|
405
435
|
let {
|
|
406
436
|
params
|
|
407
|
-
} =
|
|
437
|
+
} = _ref14;
|
|
408
438
|
const input = params;
|
|
409
439
|
const _tokenType = (input === null || input === void 0 ? void 0 : (_input$type = input.type) === null || _input$type === void 0 ? void 0 : _input$type.toLowerCase()) || '';
|
|
410
440
|
if (_tokenType !== 'erc20' && _tokenType !== 'erc721') {
|
|
@@ -457,10 +487,10 @@ class KoniTabs {
|
|
|
457
487
|
|
|
458
488
|
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
459
489
|
}
|
|
460
|
-
async addEvmChain(id, url,
|
|
490
|
+
async addEvmChain(id, url, _ref15) {
|
|
461
491
|
let {
|
|
462
492
|
params
|
|
463
|
-
} =
|
|
493
|
+
} = _ref15;
|
|
464
494
|
const input = params;
|
|
465
495
|
if (input && input.length > 0) {
|
|
466
496
|
const {
|
|
@@ -663,11 +693,11 @@ class KoniTabs {
|
|
|
663
693
|
const networkCheckInterval = setInterval(networkCheck, _constants.CRON_GET_API_MAP_STATUS);
|
|
664
694
|
const provider = await this.getEvmProvider(url);
|
|
665
695
|
const eventMap = {};
|
|
666
|
-
eventMap.data =
|
|
696
|
+
eventMap.data = _ref16 => {
|
|
667
697
|
let {
|
|
668
698
|
method,
|
|
669
699
|
params
|
|
670
|
-
} =
|
|
700
|
+
} = _ref16;
|
|
671
701
|
emitEvent('message', {
|
|
672
702
|
type: method,
|
|
673
703
|
data: params
|
|
@@ -676,8 +706,8 @@ class KoniTabs {
|
|
|
676
706
|
eventMap.error = rs => {
|
|
677
707
|
emitEvent('error', rs);
|
|
678
708
|
};
|
|
679
|
-
Object.entries(eventMap).forEach(
|
|
680
|
-
let [event, callback] =
|
|
709
|
+
Object.entries(eventMap).forEach(_ref17 => {
|
|
710
|
+
let [event, callback] = _ref17;
|
|
681
711
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
682
712
|
(provider === null || provider === void 0 ? void 0 : provider.on) && (provider === null || provider === void 0 ? void 0 : provider.on(event, callback));
|
|
683
713
|
});
|
|
@@ -691,8 +721,8 @@ class KoniTabs {
|
|
|
691
721
|
if (this.evmEventEmitterMap[url][id]) {
|
|
692
722
|
delete this.evmEventEmitterMap[url][id];
|
|
693
723
|
}
|
|
694
|
-
Object.entries(eventMap).forEach(
|
|
695
|
-
let [event, callback] =
|
|
724
|
+
Object.entries(eventMap).forEach(_ref18 => {
|
|
725
|
+
let [event, callback] = _ref18;
|
|
696
726
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
697
727
|
(provider === null || provider === void 0 ? void 0 : provider.removeListener) && (provider === null || provider === void 0 ? void 0 : provider.removeListener(event, callback));
|
|
698
728
|
});
|
|
@@ -727,11 +757,11 @@ class KoniTabs {
|
|
|
727
757
|
}
|
|
728
758
|
return provider;
|
|
729
759
|
}
|
|
730
|
-
async performWeb3Method(id, url,
|
|
760
|
+
async performWeb3Method(id, url, _ref19, callback) {
|
|
731
761
|
let {
|
|
732
762
|
method,
|
|
733
763
|
params
|
|
734
|
-
} =
|
|
764
|
+
} = _ref19;
|
|
735
765
|
const provider = await this.getEvmProvider(url);
|
|
736
766
|
this.checkAndHandleProviderStatus(provider);
|
|
737
767
|
return new Promise((resolve, reject) => {
|
|
@@ -756,11 +786,11 @@ class KoniTabs {
|
|
|
756
786
|
const allowedAccounts = await this.getEvmCurrentAccount(url, true);
|
|
757
787
|
return !!allowedAccounts.find(acc => acc.toLowerCase() === address.toLowerCase());
|
|
758
788
|
}
|
|
759
|
-
async evmSign(id, url,
|
|
789
|
+
async evmSign(id, url, _ref20) {
|
|
760
790
|
let {
|
|
761
791
|
method,
|
|
762
792
|
params
|
|
763
|
-
} =
|
|
793
|
+
} = _ref20;
|
|
764
794
|
const allowedAccounts = await this.getEvmCurrentAccount(url, true);
|
|
765
795
|
const signResult = await this.#koniState.evmSign(id, url, method, params, allowedAccounts);
|
|
766
796
|
if (signResult) {
|
|
@@ -769,10 +799,10 @@ class KoniTabs {
|
|
|
769
799
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Have something wrong to sign message');
|
|
770
800
|
}
|
|
771
801
|
}
|
|
772
|
-
async evmSendTransaction(id, url,
|
|
802
|
+
async evmSendTransaction(id, url, _ref21) {
|
|
773
803
|
let {
|
|
774
804
|
params
|
|
775
|
-
} =
|
|
805
|
+
} = _ref21;
|
|
776
806
|
const transactionParams = params[0];
|
|
777
807
|
const canUseAccount = transactionParams.from && this.canUseAccount(transactionParams.from, url);
|
|
778
808
|
const evmState = await this.getEvmState(url);
|
|
@@ -870,11 +900,11 @@ class KoniTabs {
|
|
|
870
900
|
return false;
|
|
871
901
|
}
|
|
872
902
|
}
|
|
873
|
-
async addPspToken(id, url,
|
|
903
|
+
async addPspToken(id, url, _ref22) {
|
|
874
904
|
let {
|
|
875
905
|
genesisHash,
|
|
876
906
|
tokenInfo: input
|
|
877
|
-
} =
|
|
907
|
+
} = _ref22;
|
|
878
908
|
const _tokenType = input.type;
|
|
879
909
|
if (_tokenType !== 'psp22' && _tokenType !== 'psp34') {
|
|
880
910
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, `Assets type ${_tokenType} is not supported`);
|
|
@@ -948,6 +978,8 @@ class KoniTabs {
|
|
|
948
978
|
return this.metadataList(url);
|
|
949
979
|
case 'pub(metadata.provide)':
|
|
950
980
|
return this.metadataProvide(url, request);
|
|
981
|
+
case 'pub(ping)':
|
|
982
|
+
return Promise.resolve(true);
|
|
951
983
|
case 'pub(rpc.listProviders)':
|
|
952
984
|
return this.rpcListProviders();
|
|
953
985
|
case 'pub(rpc.send)':
|
|
@@ -970,6 +1002,8 @@ class KoniTabs {
|
|
|
970
1002
|
return this.accountsListV2(url, request);
|
|
971
1003
|
case 'pub(accounts.subscribeV2)':
|
|
972
1004
|
return this.accountsSubscribeV2(url, request, id, port);
|
|
1005
|
+
case 'pub(accounts.unsubscribe)':
|
|
1006
|
+
return this.accountsUnsubscribe(url, request);
|
|
973
1007
|
case 'evm(events.subscribe)':
|
|
974
1008
|
return await this.evmSubscribeEvents(url, id, port);
|
|
975
1009
|
case 'evm(request)':
|