@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
|
@@ -5,7 +5,7 @@ import { RMRK_VER } from '@subwallet/extension-base/background/KoniTypes';
|
|
|
5
5
|
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
6
6
|
import { isUrl, reformatAddress } from '@subwallet/extension-base/utils';
|
|
7
7
|
import fetch from 'cross-fetch';
|
|
8
|
-
import {
|
|
8
|
+
import { SINGULAR_V1_COLLECTION_ENDPOINT, SINGULAR_V2_COLLECTION_ENDPOINT, SINGULAR_V2_ENDPOINT } from "../config.js";
|
|
9
9
|
var RMRK_SOURCE;
|
|
10
10
|
(function (RMRK_SOURCE) {
|
|
11
11
|
RMRK_SOURCE["BIRD_KANARIA"] = "bird_kanaria";
|
|
@@ -18,18 +18,23 @@ export class RmrkNftApi extends BaseNftApi {
|
|
|
18
18
|
constructor(addresses, chain) {
|
|
19
19
|
super(chain, null, addresses);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
|
|
22
|
+
// override parseUrl (input: string): string | undefined {
|
|
23
|
+
// if (!input || input.length === 0) {
|
|
24
|
+
// return undefined;
|
|
25
|
+
// }
|
|
26
|
+
//
|
|
27
|
+
// if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
28
|
+
// return input;
|
|
29
|
+
// }
|
|
30
|
+
//
|
|
31
|
+
// if (!input.includes('ipfs://ipfs/')) {
|
|
32
|
+
// return getRandomIpfsGateway() + input;
|
|
33
|
+
// }
|
|
34
|
+
//
|
|
35
|
+
// return getRandomIpfsGateway() + input.split('ipfs://ipfs/')[1];
|
|
36
|
+
// }
|
|
37
|
+
|
|
33
38
|
async getMetadata(metadataUrl) {
|
|
34
39
|
let url = metadataUrl;
|
|
35
40
|
if (!isUrl(metadataUrl)) {
|
|
@@ -69,53 +74,57 @@ export class RmrkNftApi extends BaseNftApi {
|
|
|
69
74
|
}));
|
|
70
75
|
const nfts = [];
|
|
71
76
|
await Promise.all(data.map(async item => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...item,
|
|
93
|
-
metadata: {
|
|
94
|
-
description: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.description,
|
|
95
|
-
name: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.name,
|
|
96
|
-
attributes: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.attributes,
|
|
97
|
-
animation_url: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.animation_url),
|
|
98
|
-
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.image)
|
|
99
|
-
},
|
|
100
|
-
owner: account
|
|
101
|
-
});
|
|
102
|
-
} else if (item.source === RMRK_SOURCE.SINGULAR_V2) {
|
|
103
|
-
const id = item.id;
|
|
104
|
-
if (!id.toLowerCase().includes(KANBIRD_KEYWORD)) {
|
|
105
|
-
// excludes kanaria bird, already handled above
|
|
77
|
+
try {
|
|
78
|
+
const primaryResource = item.primaryResource ? item.primaryResource : null;
|
|
79
|
+
const metadataUri = primaryResource && primaryResource.metadata ? primaryResource.metadata : item.metadata;
|
|
80
|
+
const nftMetadata = await this.getMetadata(metadataUri);
|
|
81
|
+
if (item.source === RMRK_SOURCE.BIRD_KANARIA) {
|
|
82
|
+
nfts.push({
|
|
83
|
+
...item,
|
|
84
|
+
metadata: nftMetadata,
|
|
85
|
+
owner: account
|
|
86
|
+
});
|
|
87
|
+
} else if (item.source === RMRK_SOURCE.KANARIA) {
|
|
88
|
+
nfts.push({
|
|
89
|
+
...item,
|
|
90
|
+
metadata: {
|
|
91
|
+
...nftMetadata,
|
|
92
|
+
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.image)
|
|
93
|
+
},
|
|
94
|
+
owner: account
|
|
95
|
+
});
|
|
96
|
+
} else if (item.source === RMRK_SOURCE.SINGULAR_V1) {
|
|
106
97
|
nfts.push({
|
|
107
98
|
...item,
|
|
108
99
|
metadata: {
|
|
109
100
|
description: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.description,
|
|
110
101
|
name: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.name,
|
|
111
102
|
attributes: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.attributes,
|
|
112
|
-
properties: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.properties,
|
|
113
103
|
animation_url: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.animation_url),
|
|
114
|
-
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.
|
|
104
|
+
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.image)
|
|
115
105
|
},
|
|
116
106
|
owner: account
|
|
117
107
|
});
|
|
108
|
+
} else if (item.source === RMRK_SOURCE.SINGULAR_V2) {
|
|
109
|
+
const id = item.id;
|
|
110
|
+
if (!id.toLowerCase().includes(KANBIRD_KEYWORD)) {
|
|
111
|
+
// excludes kanaria bird, already handled above
|
|
112
|
+
nfts.push({
|
|
113
|
+
...item,
|
|
114
|
+
metadata: {
|
|
115
|
+
description: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.description,
|
|
116
|
+
name: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.name,
|
|
117
|
+
attributes: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.attributes,
|
|
118
|
+
properties: nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.properties,
|
|
119
|
+
animation_url: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.animation_url),
|
|
120
|
+
image: this.parseUrl(nftMetadata === null || nftMetadata === void 0 ? void 0 : nftMetadata.mediaUri)
|
|
121
|
+
},
|
|
122
|
+
owner: account
|
|
123
|
+
});
|
|
124
|
+
}
|
|
118
125
|
}
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.log('error fetching RMRK NFT', e);
|
|
119
128
|
}
|
|
120
129
|
}));
|
|
121
130
|
return nfts;
|
|
@@ -53,7 +53,7 @@ export default class KoniExtension {
|
|
|
53
53
|
private forgetSite;
|
|
54
54
|
private _forgetAllSite;
|
|
55
55
|
private forgetAllSite;
|
|
56
|
-
private
|
|
56
|
+
private getAccounts;
|
|
57
57
|
private isAddressValidWithAuthType;
|
|
58
58
|
private filterAccountsByAccountAuthType;
|
|
59
59
|
private _changeAuthorizationAll;
|
|
@@ -197,6 +197,9 @@ export default class KoniExtension {
|
|
|
197
197
|
private rejectWalletConnectSession;
|
|
198
198
|
private subscribeWalletConnectSessions;
|
|
199
199
|
private disconnectWalletConnectSession;
|
|
200
|
+
private WCNotSupportSubscribe;
|
|
201
|
+
private approveWalletConnectNotSupport;
|
|
202
|
+
private rejectWalletConnectNotSupport;
|
|
200
203
|
private enableMantaPay;
|
|
201
204
|
private initSyncMantaPay;
|
|
202
205
|
private disableMantaPay;
|
|
@@ -660,10 +660,10 @@ export default class KoniExtension {
|
|
|
660
660
|
});
|
|
661
661
|
return true;
|
|
662
662
|
}
|
|
663
|
-
|
|
663
|
+
getAccounts() {
|
|
664
664
|
const storedAccounts = this.#koniState.keyringService.accounts;
|
|
665
665
|
const transformedAccounts = transformAccounts(storedAccounts);
|
|
666
|
-
return transformedAccounts.
|
|
666
|
+
return transformedAccounts.map(a => a.address);
|
|
667
667
|
}
|
|
668
668
|
isAddressValidWithAuthType(address, accountAuthType) {
|
|
669
669
|
if (accountAuthType === 'substrate') {
|
|
@@ -685,12 +685,12 @@ export default class KoniExtension {
|
|
|
685
685
|
_changeAuthorizationAll(connectValue, callBack) {
|
|
686
686
|
this.#koniState.getAuthorize(value => {
|
|
687
687
|
assert(value, 'The source is not known');
|
|
688
|
-
const
|
|
688
|
+
const accounts = this.getAccounts();
|
|
689
689
|
Object.keys(value).forEach(url => {
|
|
690
690
|
if (!value[url].isAllowed) {
|
|
691
691
|
return;
|
|
692
692
|
}
|
|
693
|
-
const targetAccounts = this.filterAccountsByAccountAuthType(
|
|
693
|
+
const targetAccounts = this.filterAccountsByAccountAuthType(accounts, value[url].accountAuthType);
|
|
694
694
|
targetAccounts.forEach(address => {
|
|
695
695
|
value[url].isAllowedMap[address] = connectValue;
|
|
696
696
|
});
|
|
@@ -713,8 +713,8 @@ export default class KoniExtension {
|
|
|
713
713
|
_changeAuthorization(url, connectValue, callBack) {
|
|
714
714
|
this.#koniState.getAuthorize(value => {
|
|
715
715
|
assert(value[url], 'The source is not known');
|
|
716
|
-
const
|
|
717
|
-
const targetAccounts = this.filterAccountsByAccountAuthType(
|
|
716
|
+
const accounts = this.getAccounts();
|
|
717
|
+
const targetAccounts = this.filterAccountsByAccountAuthType(accounts, value[url].accountAuthType);
|
|
718
718
|
targetAccounts.forEach(address => {
|
|
719
719
|
value[url].isAllowedMap[address] = connectValue;
|
|
720
720
|
});
|
|
@@ -3219,6 +3219,32 @@ export default class KoniExtension {
|
|
|
3219
3219
|
await this.#koniState.walletConnectService.disconnect(topic);
|
|
3220
3220
|
return true;
|
|
3221
3221
|
}
|
|
3222
|
+
WCNotSupportSubscribe(id, port) {
|
|
3223
|
+
const cb = createSubscription(id, port);
|
|
3224
|
+
const subscription = this.#koniState.requestService.notSupportWCSubject.subscribe(requests => cb(requests));
|
|
3225
|
+
port.onDisconnect.addListener(() => {
|
|
3226
|
+
this.cancelSubscription(id);
|
|
3227
|
+
subscription.unsubscribe();
|
|
3228
|
+
});
|
|
3229
|
+
return this.#koniState.requestService.allNotSupportWCRequests;
|
|
3230
|
+
}
|
|
3231
|
+
approveWalletConnectNotSupport({
|
|
3232
|
+
id
|
|
3233
|
+
}) {
|
|
3234
|
+
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
3235
|
+
request.resolve();
|
|
3236
|
+
return true;
|
|
3237
|
+
}
|
|
3238
|
+
rejectWalletConnectNotSupport({
|
|
3239
|
+
id
|
|
3240
|
+
}) {
|
|
3241
|
+
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
3242
|
+
request.reject(new Error('USER_REJECTED'));
|
|
3243
|
+
return true;
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
/// Manta
|
|
3247
|
+
|
|
3222
3248
|
async enableMantaPay({
|
|
3223
3249
|
address,
|
|
3224
3250
|
password
|
|
@@ -3743,7 +3769,7 @@ export default class KoniExtension {
|
|
|
3743
3769
|
/// Wallet Connect
|
|
3744
3770
|
case 'pri(walletConnect.connect)':
|
|
3745
3771
|
return this.connectWalletConnect(request);
|
|
3746
|
-
case 'pri(walletConnect.requests.subscribe)':
|
|
3772
|
+
case 'pri(walletConnect.requests.connect.subscribe)':
|
|
3747
3773
|
return this.connectWCSubscribe(id, port);
|
|
3748
3774
|
case 'pri(walletConnect.session.approve)':
|
|
3749
3775
|
return this.approveWalletConnectSession(request);
|
|
@@ -3753,6 +3779,16 @@ export default class KoniExtension {
|
|
|
3753
3779
|
return this.subscribeWalletConnectSessions(id, port);
|
|
3754
3780
|
case 'pri(walletConnect.session.disconnect)':
|
|
3755
3781
|
return this.disconnectWalletConnectSession(request);
|
|
3782
|
+
|
|
3783
|
+
// Not support
|
|
3784
|
+
case 'pri(walletConnect.requests.notSupport.subscribe)':
|
|
3785
|
+
return this.WCNotSupportSubscribe(id, port);
|
|
3786
|
+
case 'pri(walletConnect.notSupport.approve)':
|
|
3787
|
+
return this.approveWalletConnectNotSupport(request);
|
|
3788
|
+
case 'pri(walletConnect.notSupport.reject)':
|
|
3789
|
+
return this.rejectWalletConnectNotSupport(request);
|
|
3790
|
+
|
|
3791
|
+
// Manta
|
|
3756
3792
|
case 'pri(mantaPay.enable)':
|
|
3757
3793
|
return await this.enableMantaPay(request);
|
|
3758
3794
|
case 'pri(mantaPay.initSyncMantaPay)':
|
|
@@ -3,6 +3,7 @@ import { AuthUrlInfo } from '@subwallet/extension-base/background/handlers/State
|
|
|
3
3
|
import { RequestAddPspToken } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import { MessageTypes, RequestTypes, ResponseTypes } from '@subwallet/extension-base/background/types';
|
|
5
5
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
6
|
+
import { AuthUrls } from '@subwallet/extension-base/services/request-service/types';
|
|
6
7
|
import { RequestArguments } from 'web3-core';
|
|
7
8
|
export declare const chainPatrolCheckUrl: (url: string) => Promise<boolean>;
|
|
8
9
|
export default class KoniTabs {
|
|
@@ -26,9 +27,10 @@ export default class KoniTabs {
|
|
|
26
27
|
protected redirectIfPhishing(url: string): Promise<boolean>;
|
|
27
28
|
private cancelSubscription;
|
|
28
29
|
private createUnsubscriptionHandle;
|
|
29
|
-
getAuthInfo(url: string): Promise<AuthUrlInfo | undefined>;
|
|
30
|
+
getAuthInfo(url: string, fromList?: AuthUrls): Promise<AuthUrlInfo | undefined>;
|
|
30
31
|
private accountsListV2;
|
|
31
32
|
private accountsSubscribeV2;
|
|
33
|
+
private accountsUnsubscribe;
|
|
32
34
|
private authorizeV2;
|
|
33
35
|
private getEvmCurrentAccount;
|
|
34
36
|
private getEvmState;
|
|
@@ -77,6 +77,7 @@ export const chainPatrolCheckUrl = async url => {
|
|
|
77
77
|
return data.status === 'BLOCKED';
|
|
78
78
|
};
|
|
79
79
|
export default class KoniTabs {
|
|
80
|
+
#accountSubs = {};
|
|
80
81
|
#koniState;
|
|
81
82
|
evmEventEmitterMap = {};
|
|
82
83
|
#chainPatrolService = DEFAULT_CHAIN_PATROL_ENABLE;
|
|
@@ -105,17 +106,25 @@ export default class KoniTabs {
|
|
|
105
106
|
assert(pair, 'Unable to find keypair');
|
|
106
107
|
return pair;
|
|
107
108
|
}
|
|
108
|
-
bytesSign(url, request) {
|
|
109
|
+
async bytesSign(url, request) {
|
|
109
110
|
const address = request.address;
|
|
110
111
|
const pair = this.getSigningPair(address);
|
|
112
|
+
const authInfo = await this.getAuthInfo(url);
|
|
113
|
+
if (!authInfo || !authInfo.isAllowed || !authInfo.isAllowedMap[pair.address]) {
|
|
114
|
+
throw new Error('Account {{address}} not in allowed list'.replace('{{address}}', address));
|
|
115
|
+
}
|
|
111
116
|
return this.#koniState.sign(url, new RequestBytesSign(request), {
|
|
112
117
|
address,
|
|
113
118
|
...pair.meta
|
|
114
119
|
});
|
|
115
120
|
}
|
|
116
|
-
extrinsicSign(url, request) {
|
|
121
|
+
async extrinsicSign(url, request) {
|
|
117
122
|
const address = request.address;
|
|
118
123
|
const pair = this.getSigningPair(address);
|
|
124
|
+
const authInfo = await this.getAuthInfo(url);
|
|
125
|
+
if (!authInfo || !authInfo.isAllowed || !authInfo.isAllowedMap[pair.address]) {
|
|
126
|
+
throw new Error('Account {{address}} not in allowed list'.replace('{{address}}', address));
|
|
127
|
+
}
|
|
119
128
|
return this.#koniState.sign(url, new RequestExtrinsicSign(request), {
|
|
120
129
|
address,
|
|
121
130
|
...pair.meta
|
|
@@ -217,8 +226,8 @@ export default class KoniTabs {
|
|
|
217
226
|
createUnsubscriptionHandle(id, unsubscribe) {
|
|
218
227
|
this.#koniState.createUnsubscriptionHandle(id, unsubscribe);
|
|
219
228
|
}
|
|
220
|
-
async getAuthInfo(url) {
|
|
221
|
-
const authList = await this.#koniState.getAuthList();
|
|
229
|
+
async getAuthInfo(url, fromList) {
|
|
230
|
+
const authList = fromList || (await this.#koniState.getAuthList());
|
|
222
231
|
const shortenUrl = stripUrl(url);
|
|
223
232
|
return authList[shortenUrl];
|
|
224
233
|
}
|
|
@@ -233,15 +242,35 @@ export default class KoniTabs {
|
|
|
233
242
|
accountAuthType
|
|
234
243
|
}, id, port) {
|
|
235
244
|
const cb = createSubscription(id, port);
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
245
|
+
const authInfoSubject = this.#koniState.requestService.subscribeAuthorizeUrlSubject;
|
|
246
|
+
|
|
247
|
+
// Update unsubscribe from @polkadot/extension-base
|
|
248
|
+
this.#accountSubs[id] = {
|
|
249
|
+
subscription: authInfoSubject.subscribe(infos => {
|
|
250
|
+
this.getAuthInfo(url, infos).then(authInfo => {
|
|
251
|
+
const accounts = this.#koniState.keyringService.accounts;
|
|
252
|
+
return cb(transformAccountsV2(accounts, false, authInfo, accountAuthType));
|
|
253
|
+
}).catch(console.error);
|
|
254
|
+
}),
|
|
255
|
+
url
|
|
256
|
+
};
|
|
242
257
|
port.onDisconnect.addListener(() => {
|
|
243
|
-
this.
|
|
258
|
+
this.accountsUnsubscribe(url, {
|
|
259
|
+
id
|
|
260
|
+
});
|
|
244
261
|
});
|
|
262
|
+
return id;
|
|
263
|
+
}
|
|
264
|
+
accountsUnsubscribe(url, {
|
|
265
|
+
id
|
|
266
|
+
}) {
|
|
267
|
+
const sub = this.#accountSubs[id];
|
|
268
|
+
if (!sub || sub.url !== url) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
delete this.#accountSubs[id];
|
|
272
|
+
unsubscribe(id);
|
|
273
|
+
sub.subscription.unsubscribe();
|
|
245
274
|
return true;
|
|
246
275
|
}
|
|
247
276
|
authorizeV2(url, request) {
|
|
@@ -897,6 +926,8 @@ export default class KoniTabs {
|
|
|
897
926
|
return this.metadataList(url);
|
|
898
927
|
case 'pub(metadata.provide)':
|
|
899
928
|
return this.metadataProvide(url, request);
|
|
929
|
+
case 'pub(ping)':
|
|
930
|
+
return Promise.resolve(true);
|
|
900
931
|
case 'pub(rpc.listProviders)':
|
|
901
932
|
return this.rpcListProviders();
|
|
902
933
|
case 'pub(rpc.send)':
|
|
@@ -919,6 +950,8 @@ export default class KoniTabs {
|
|
|
919
950
|
return this.accountsListV2(url, request);
|
|
920
951
|
case 'pub(accounts.subscribeV2)':
|
|
921
952
|
return this.accountsSubscribeV2(url, request, id, port);
|
|
953
|
+
case 'pub(accounts.unsubscribe)':
|
|
954
|
+
return this.accountsUnsubscribe(url, request);
|
|
922
955
|
case 'evm(events.subscribe)':
|
|
923
956
|
return await this.evmSubscribeEvents(url, id, port);
|
|
924
957
|
case 'evm(request)':
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.5-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -720,11 +720,21 @@
|
|
|
720
720
|
"require": "./cjs/services/request-service/constants.js",
|
|
721
721
|
"default": "./services/request-service/constants.js"
|
|
722
722
|
},
|
|
723
|
+
"./services/request-service/handler": {
|
|
724
|
+
"types": "./services/request-service/handler/index.d.ts",
|
|
725
|
+
"require": "./cjs/services/request-service/handler/index.js",
|
|
726
|
+
"default": "./services/request-service/handler/index.js"
|
|
727
|
+
},
|
|
723
728
|
"./services/request-service/handler/AuthRequestHandler": {
|
|
724
729
|
"types": "./services/request-service/handler/AuthRequestHandler.d.ts",
|
|
725
730
|
"require": "./cjs/services/request-service/handler/AuthRequestHandler.js",
|
|
726
731
|
"default": "./services/request-service/handler/AuthRequestHandler.js"
|
|
727
732
|
},
|
|
733
|
+
"./services/request-service/handler/ConnectWCRequestHandler": {
|
|
734
|
+
"types": "./services/request-service/handler/ConnectWCRequestHandler.d.ts",
|
|
735
|
+
"require": "./cjs/services/request-service/handler/ConnectWCRequestHandler.js",
|
|
736
|
+
"default": "./services/request-service/handler/ConnectWCRequestHandler.js"
|
|
737
|
+
},
|
|
728
738
|
"./services/request-service/handler/EvmRequestHandler": {
|
|
729
739
|
"types": "./services/request-service/handler/EvmRequestHandler.d.ts",
|
|
730
740
|
"require": "./cjs/services/request-service/handler/EvmRequestHandler.js",
|
|
@@ -735,6 +745,11 @@
|
|
|
735
745
|
"require": "./cjs/services/request-service/handler/MetadataRequestHandler.js",
|
|
736
746
|
"default": "./services/request-service/handler/MetadataRequestHandler.js"
|
|
737
747
|
},
|
|
748
|
+
"./services/request-service/handler/NotSupportWCRequestHandler": {
|
|
749
|
+
"types": "./services/request-service/handler/NotSupportWCRequestHandler.d.ts",
|
|
750
|
+
"require": "./cjs/services/request-service/handler/NotSupportWCRequestHandler.js",
|
|
751
|
+
"default": "./services/request-service/handler/NotSupportWCRequestHandler.js"
|
|
752
|
+
},
|
|
738
753
|
"./services/request-service/handler/PopupHandler": {
|
|
739
754
|
"types": "./services/request-service/handler/PopupHandler.d.ts",
|
|
740
755
|
"require": "./cjs/services/request-service/handler/PopupHandler.js",
|
|
@@ -745,11 +760,6 @@
|
|
|
745
760
|
"require": "./cjs/services/request-service/handler/SubstrateRequestHandler.js",
|
|
746
761
|
"default": "./services/request-service/handler/SubstrateRequestHandler.js"
|
|
747
762
|
},
|
|
748
|
-
"./services/request-service/handler/WalletConnectRequestHandler": {
|
|
749
|
-
"types": "./services/request-service/handler/WalletConnectRequestHandler.d.ts",
|
|
750
|
-
"require": "./cjs/services/request-service/handler/WalletConnectRequestHandler.js",
|
|
751
|
-
"default": "./services/request-service/handler/WalletConnectRequestHandler.js"
|
|
752
|
-
},
|
|
753
763
|
"./services/request-service/helper": {
|
|
754
764
|
"types": "./services/request-service/helper/index.d.ts",
|
|
755
765
|
"require": "./cjs/services/request-service/helper/index.js",
|
|
@@ -1173,11 +1183,11 @@
|
|
|
1173
1183
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1174
1184
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1175
1185
|
"@substrate/connect": "^0.7.26",
|
|
1176
|
-
"@subwallet/chain-list": "^0.2.
|
|
1177
|
-
"@subwallet/extension-base": "^1.1.
|
|
1178
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1179
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1180
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1186
|
+
"@subwallet/chain-list": "^0.2.8",
|
|
1187
|
+
"@subwallet/extension-base": "^1.1.5-0",
|
|
1188
|
+
"@subwallet/extension-chains": "^1.1.5-0",
|
|
1189
|
+
"@subwallet/extension-dapp": "^1.1.5-0",
|
|
1190
|
+
"@subwallet/extension-inject": "^1.1.5-0",
|
|
1181
1191
|
"@subwallet/keyring": "^0.0.10",
|
|
1182
1192
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1183
1193
|
"@walletconnect/sign-client": "^2.8.4",
|
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.1.
|
|
10
|
+
version: '1.1.5-0'
|
|
11
11
|
};
|
package/page/Accounts.js
CHANGED
|
@@ -14,11 +14,16 @@ export default class Accounts {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
subscribe(cb) {
|
|
17
|
+
let id = null;
|
|
17
18
|
sendRequest('pub(accounts.subscribeV2)', {
|
|
18
19
|
accountAuthType: 'substrate'
|
|
19
|
-
}, cb).
|
|
20
|
+
}, cb).then(subId => {
|
|
21
|
+
id = subId;
|
|
22
|
+
}).catch(console.error);
|
|
20
23
|
return () => {
|
|
21
|
-
|
|
24
|
+
id && sendRequest('pub(accounts.unsubscribe)', {
|
|
25
|
+
id
|
|
26
|
+
}).catch(console.error);
|
|
22
27
|
};
|
|
23
28
|
}
|
|
24
29
|
}
|
package/page/Injected.js
CHANGED
|
@@ -11,5 +11,10 @@ export default class {
|
|
|
11
11
|
this.metadata = new Metadata(sendRequest);
|
|
12
12
|
this.provider = new PostMessageProvider(sendRequest);
|
|
13
13
|
this.signer = new Signer(sendRequest);
|
|
14
|
+
setInterval(() => {
|
|
15
|
+
sendRequest('pub(ping)', null).catch(() => {
|
|
16
|
+
console.error('Extension unavailable, ping failed');
|
|
17
|
+
});
|
|
18
|
+
}, 5000 + Math.floor(Math.random() * 5000));
|
|
14
19
|
}
|
|
15
20
|
}
|
|
@@ -697,6 +697,15 @@ export class ChainService {
|
|
|
697
697
|
async initAssetRegistry(deprecatedCustomChainMap) {
|
|
698
698
|
const storedAssetRegistry = await this.dbService.getAllAssetStore();
|
|
699
699
|
const latestAssetRegistry = await this.fetchLatestData(_CHAIN_ASSET_SRC, ChainAssetMap);
|
|
700
|
+
|
|
701
|
+
// Fill out zk assets from latestAssetRegistry if not supported
|
|
702
|
+
if (!MODULE_SUPPORT.MANTA_ZK) {
|
|
703
|
+
Object.keys(latestAssetRegistry).forEach(slug => {
|
|
704
|
+
if (_isMantaZkAsset(latestAssetRegistry[slug])) {
|
|
705
|
+
delete latestAssetRegistry[slug];
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
}
|
|
700
709
|
if (storedAssetRegistry.length === 0) {
|
|
701
710
|
this.dataMap.assetRegistry = latestAssetRegistry;
|
|
702
711
|
} else {
|
|
@@ -5,7 +5,7 @@ import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
|
5
5
|
import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
|
|
6
6
|
import RequestService from '@subwallet/extension-base/services/request-service';
|
|
7
7
|
import { AuthUrls } from '@subwallet/extension-base/services/request-service/types';
|
|
8
|
-
import { BehaviorSubject
|
|
8
|
+
import { BehaviorSubject } from 'rxjs';
|
|
9
9
|
export default class AuthRequestHandler {
|
|
10
10
|
#private;
|
|
11
11
|
private keyringService;
|
|
@@ -31,8 +31,8 @@ export default class AuthRequestHandler {
|
|
|
31
31
|
private authCompleteV2;
|
|
32
32
|
authorizeUrlV2(url: string, request: RequestAuthorizeTab): Promise<boolean>;
|
|
33
33
|
getAuthRequestV2(id: string): AuthRequestV2;
|
|
34
|
-
get subscribeEvmChainChange():
|
|
35
|
-
get subscribeAuthorizeUrlSubject():
|
|
34
|
+
get subscribeEvmChainChange(): BehaviorSubject<AuthUrls>;
|
|
35
|
+
get subscribeAuthorizeUrlSubject(): BehaviorSubject<AuthUrls>;
|
|
36
36
|
ensureUrlAuthorizedV2(url: string): Promise<boolean>;
|
|
37
37
|
resetWallet(): void;
|
|
38
38
|
}
|
|
@@ -6,7 +6,7 @@ import { PREDEFINED_CHAIN_DAPP_CHAIN_MAP } from '@subwallet/extension-base/servi
|
|
|
6
6
|
import AuthorizeStore from '@subwallet/extension-base/stores/Authorize';
|
|
7
7
|
import { getDomainFromUrl, stripUrl } from '@subwallet/extension-base/utils';
|
|
8
8
|
import { getId } from '@subwallet/extension-base/utils/getId';
|
|
9
|
-
import { BehaviorSubject
|
|
9
|
+
import { BehaviorSubject } from 'rxjs';
|
|
10
10
|
import { assert } from '@polkadot/util';
|
|
11
11
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
12
12
|
const AUTH_URLS_KEY = 'authUrls';
|
|
@@ -16,8 +16,8 @@ export default class AuthRequestHandler {
|
|
|
16
16
|
authorizeStore = new AuthorizeStore();
|
|
17
17
|
#authRequestsV2 = {};
|
|
18
18
|
authorizeCached = undefined;
|
|
19
|
-
authorizeUrlSubject = new
|
|
20
|
-
evmChainSubject = new
|
|
19
|
+
authorizeUrlSubject = new BehaviorSubject({});
|
|
20
|
+
evmChainSubject = new BehaviorSubject({});
|
|
21
21
|
authSubjectV2 = new BehaviorSubject([]);
|
|
22
22
|
constructor(requestService, chainService, keyringService) {
|
|
23
23
|
this.keyringService = keyringService;
|
|
@@ -64,6 +64,8 @@ export default class AuthRequestHandler {
|
|
|
64
64
|
} else {
|
|
65
65
|
this.authorizeStore.get('authUrls', data => {
|
|
66
66
|
this.authorizeCached = data || {};
|
|
67
|
+
this.evmChainSubject.next(this.authorizeCached);
|
|
68
|
+
this.authorizeUrlSubject.next(this.authorizeCached);
|
|
67
69
|
update(this.authorizeCached);
|
|
68
70
|
});
|
|
69
71
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import RequestService from '@subwallet/extension-base/services/request-service';
|
|
2
2
|
import { RequestWalletConnectSession, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
|
-
export default class
|
|
4
|
+
export default class ConnectWCRequestHandler {
|
|
5
5
|
#private;
|
|
6
6
|
readonly connectWCSubject: BehaviorSubject<WalletConnectSessionRequest[]>;
|
|
7
7
|
constructor(requestService: RequestService);
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
import { BehaviorSubject } from 'rxjs';
|
|
5
5
|
|
|
6
6
|
// WC = WalletConnect
|
|
7
|
-
export default class
|
|
7
|
+
export default class ConnectWCRequestHandler {
|
|
8
8
|
#requestService;
|
|
9
|
-
#
|
|
9
|
+
#connectWCRequests = {};
|
|
10
10
|
connectWCSubject = new BehaviorSubject([]);
|
|
11
11
|
constructor(requestService) {
|
|
12
12
|
this.#requestService = requestService;
|
|
13
13
|
}
|
|
14
14
|
get allConnectWCRequests() {
|
|
15
|
-
return Object.values(this.#
|
|
15
|
+
return Object.values(this.#connectWCRequests)
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
17
|
.map(({
|
|
18
18
|
reject,
|
|
@@ -21,10 +21,10 @@ export default class WalletConnectRequestHandler {
|
|
|
21
21
|
}) => data);
|
|
22
22
|
}
|
|
23
23
|
get numConnectWCRequests() {
|
|
24
|
-
return Object.keys(this.#
|
|
24
|
+
return Object.keys(this.#connectWCRequests).length;
|
|
25
25
|
}
|
|
26
26
|
getConnectWCRequest(id) {
|
|
27
|
-
return this.#
|
|
27
|
+
return this.#connectWCRequests[id];
|
|
28
28
|
}
|
|
29
29
|
updateIconConnectWC(shouldClose) {
|
|
30
30
|
this.connectWCSubject.next(this.allConnectWCRequests);
|
|
@@ -32,7 +32,7 @@ export default class WalletConnectRequestHandler {
|
|
|
32
32
|
}
|
|
33
33
|
connectWCComplete = id => {
|
|
34
34
|
const complete = shouldClose => {
|
|
35
|
-
delete this.#
|
|
35
|
+
delete this.#connectWCRequests[id];
|
|
36
36
|
this.updateIconConnectWC(shouldClose);
|
|
37
37
|
};
|
|
38
38
|
return {
|
|
@@ -46,7 +46,7 @@ export default class WalletConnectRequestHandler {
|
|
|
46
46
|
};
|
|
47
47
|
addConnectWCRequest(request) {
|
|
48
48
|
const id = request.id;
|
|
49
|
-
this.#
|
|
49
|
+
this.#connectWCRequests[id] = {
|
|
50
50
|
...this.connectWCComplete(id),
|
|
51
51
|
...request
|
|
52
52
|
};
|
|
@@ -54,7 +54,7 @@ export default class WalletConnectRequestHandler {
|
|
|
54
54
|
this.#requestService.popupOpen();
|
|
55
55
|
}
|
|
56
56
|
resetWallet() {
|
|
57
|
-
for (const request of Object.values(this.#
|
|
57
|
+
for (const request of Object.values(this.#connectWCRequests)) {
|
|
58
58
|
request.reject(new Error('Reset wallet'));
|
|
59
59
|
}
|
|
60
60
|
this.connectWCSubject.next([]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import RequestService from '@subwallet/extension-base/services/request-service';
|
|
2
|
+
import { RequestWalletConnectNotSupport, WalletConnectNotSupportRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
4
|
+
export default class NotSupportWCRequestHandler {
|
|
5
|
+
#private;
|
|
6
|
+
readonly notSupportWCSubject: BehaviorSubject<WalletConnectNotSupportRequest[]>;
|
|
7
|
+
constructor(requestService: RequestService);
|
|
8
|
+
get allNotSupportWCRequests(): WalletConnectNotSupportRequest[];
|
|
9
|
+
get numNotSupportWCRequests(): number;
|
|
10
|
+
getNotSupportWCRequest(id: string): RequestWalletConnectNotSupport;
|
|
11
|
+
private updateIconNotSupportWC;
|
|
12
|
+
private notSupportWCComplete;
|
|
13
|
+
addNotSupportWCRequest(request: WalletConnectNotSupportRequest): void;
|
|
14
|
+
resetWallet(): void;
|
|
15
|
+
}
|