@subwallet/extension-base 1.1.16-0 → 1.1.17-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/cjs/koni/api/nft/config.js +5 -1
- package/cjs/koni/api/nft/index.js +6 -0
- package/cjs/koni/api/nft/statemint_nft/index.js +143 -0
- package/cjs/koni/api/nft/transfer.js +12 -1
- package/cjs/koni/api/nft/vara_nft/index.js +107 -0
- package/cjs/koni/background/handlers/Extension.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +5 -3
- package/cjs/services/chain-service/index.js +2 -0
- package/cjs/services/keyring-service/index.js +32 -0
- package/cjs/services/migration-service/scripts/EnableChain.js +18 -0
- package/cjs/services/migration-service/scripts/EnableVaraChain.js +15 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +5 -20
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/index.js +5 -1
- package/cjs/services/transaction-service/index.js +6 -1
- package/koni/api/nft/config.d.ts +1 -0
- package/koni/api/nft/config.js +4 -0
- package/koni/api/nft/index.js +6 -0
- package/koni/api/nft/statemint_nft/index.d.ts +18 -0
- package/koni/api/nft/statemint_nft/index.js +135 -0
- package/koni/api/nft/transfer.d.ts +1 -0
- package/koni/api/nft/transfer.js +11 -1
- package/koni/api/nft/vara_nft/index.d.ts +9 -0
- package/koni/api/nft/vara_nft/index.js +99 -0
- package/koni/background/handlers/Extension.js +1 -1
- package/package.json +36 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +5 -3
- package/services/chain-service/index.js +2 -0
- package/services/chain-service/types.d.ts +3 -1
- package/services/keyring-service/index.js +32 -0
- package/services/migration-service/scripts/EnableChain.d.ts +5 -0
- package/services/migration-service/scripts/EnableChain.js +10 -0
- package/services/migration-service/scripts/EnableVaraChain.d.ts +4 -0
- package/services/migration-service/scripts/EnableVaraChain.js +7 -0
- package/services/migration-service/scripts/MigrateEthProvider.d.ts +5 -3
- package/services/migration-service/scripts/MigrateEthProvider.js +5 -20
- package/services/migration-service/scripts/MigratePioneerProvider.d.ts +6 -0
- package/services/migration-service/scripts/MigratePioneerProvider.js +9 -0
- package/services/migration-service/scripts/MigrateProvider.d.ts +7 -0
- package/services/migration-service/scripts/MigrateProvider.js +21 -0
- package/services/migration-service/scripts/index.js +5 -1
- package/services/transaction-service/index.js +6 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseNftApi, HandleNftParams } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
2
|
+
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
3
|
+
export default class StatemintNftApi extends BaseNftApi {
|
|
4
|
+
constructor(api: _SubstrateApi | null, addresses: string[], chain: string);
|
|
5
|
+
private getMetadata;
|
|
6
|
+
/**
|
|
7
|
+
* Retrieve id of NFTs
|
|
8
|
+
*
|
|
9
|
+
* @returns the array of NFT Ids
|
|
10
|
+
* @param addresses
|
|
11
|
+
*/
|
|
12
|
+
private getNfts;
|
|
13
|
+
private getTokenDetails;
|
|
14
|
+
private getCollectionDetail;
|
|
15
|
+
handleNft(address: string, params: HandleNftParams): Promise<void>;
|
|
16
|
+
handleNfts(params: HandleNftParams): Promise<void>;
|
|
17
|
+
fetchNfts(params: HandleNftParams): Promise<number>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
5
|
+
import { isUrl } from '@subwallet/extension-base/utils';
|
|
6
|
+
import fetch from 'cross-fetch';
|
|
7
|
+
export default class StatemintNftApi extends BaseNftApi {
|
|
8
|
+
// eslint-disable-next-line no-useless-constructor
|
|
9
|
+
constructor(api, addresses, chain) {
|
|
10
|
+
super(chain, api, addresses);
|
|
11
|
+
}
|
|
12
|
+
getMetadata(metadataUrl) {
|
|
13
|
+
let url = metadataUrl;
|
|
14
|
+
if (!isUrl(metadataUrl)) {
|
|
15
|
+
url = this.parseUrl(metadataUrl);
|
|
16
|
+
if (!url || url.length === 0) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return fetch(url, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json'
|
|
24
|
+
}
|
|
25
|
+
}).then(res => res.json());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Retrieve id of NFTs
|
|
30
|
+
*
|
|
31
|
+
* @returns the array of NFT Ids
|
|
32
|
+
* @param addresses
|
|
33
|
+
*/
|
|
34
|
+
async getNfts(addresses) {
|
|
35
|
+
if (!this.substrateApi) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const assetIds = [];
|
|
39
|
+
await Promise.all(addresses.map(async address => {
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
const resp = await this.substrateApi.api.query.nfts.account.keys(address);
|
|
42
|
+
if (resp) {
|
|
43
|
+
for (const key of resp) {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
45
|
+
const data = key.toHuman();
|
|
46
|
+
assetIds.push({
|
|
47
|
+
classId: data[1],
|
|
48
|
+
tokenId: this.parseTokenId(data[2])
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
return assetIds;
|
|
54
|
+
}
|
|
55
|
+
async getTokenDetails(assetId) {
|
|
56
|
+
if (!this.substrateApi) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const {
|
|
60
|
+
classId,
|
|
61
|
+
tokenId
|
|
62
|
+
} = assetId;
|
|
63
|
+
const metadataNft = (await this.substrateApi.api.query.nfts.itemMetadataOf(this.parseTokenId(classId), this.parseTokenId(tokenId))).toHuman();
|
|
64
|
+
if (!(metadataNft !== null && metadataNft !== void 0 && metadataNft.data)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
return this.getMetadata(metadataNft === null || metadataNft === void 0 ? void 0 : metadataNft.data);
|
|
70
|
+
}
|
|
71
|
+
async getCollectionDetail(collectionId) {
|
|
72
|
+
if (!this.substrateApi) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const collectionMetadata = (await this.substrateApi.api.query.nfts.collectionMetadataOf(collectionId)).toHuman();
|
|
76
|
+
if (!(collectionMetadata !== null && collectionMetadata !== void 0 && collectionMetadata.data)) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
return this.getMetadata(collectionMetadata === null || collectionMetadata === void 0 ? void 0 : collectionMetadata.data);
|
|
82
|
+
}
|
|
83
|
+
async handleNft(address, params) {
|
|
84
|
+
// const start = performance.now();
|
|
85
|
+
|
|
86
|
+
const assetIds = await this.getNfts([address]);
|
|
87
|
+
try {
|
|
88
|
+
if (!assetIds || assetIds.length === 0) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const collectionIds = [];
|
|
92
|
+
const nftIds = [];
|
|
93
|
+
await Promise.all(assetIds.map(async assetId => {
|
|
94
|
+
const parsedClassId = this.parseTokenId(assetId.classId);
|
|
95
|
+
const parsedTokenId = this.parseTokenId(assetId.tokenId);
|
|
96
|
+
if (!collectionIds.includes(parsedClassId)) {
|
|
97
|
+
collectionIds.push(parsedClassId);
|
|
98
|
+
}
|
|
99
|
+
nftIds.push(parsedTokenId);
|
|
100
|
+
const [tokenInfo, collectionMeta] = await Promise.all([this.getTokenDetails(assetId), this.getCollectionDetail(parseInt(parsedClassId))]);
|
|
101
|
+
const parsedNft = {
|
|
102
|
+
id: parsedTokenId,
|
|
103
|
+
name: tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.name,
|
|
104
|
+
description: tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.description,
|
|
105
|
+
image: tokenInfo && tokenInfo.image ? this.parseUrl(tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.image) : undefined,
|
|
106
|
+
collectionId: this.parseTokenId(parsedClassId),
|
|
107
|
+
chain: this.chain,
|
|
108
|
+
owner: address
|
|
109
|
+
};
|
|
110
|
+
params.updateItem(this.chain, parsedNft, address);
|
|
111
|
+
const parsedCollection = {
|
|
112
|
+
collectionId: parsedClassId,
|
|
113
|
+
chain: this.chain,
|
|
114
|
+
collectionName: collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.name,
|
|
115
|
+
image: collectionMeta && collectionMeta.image ? this.parseUrl(collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.image) : undefined
|
|
116
|
+
};
|
|
117
|
+
params.updateCollection(this.chain, parsedCollection);
|
|
118
|
+
}));
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error(`${this.chain}`, e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async handleNfts(params) {
|
|
124
|
+
await Promise.all(this.addresses.map(address => this.handleNft(address, params)));
|
|
125
|
+
}
|
|
126
|
+
async fetchNfts(params) {
|
|
127
|
+
try {
|
|
128
|
+
await this.connect();
|
|
129
|
+
await this.handleNfts(params);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
return 1;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -5,4 +5,5 @@ export declare function rmrkGetExtrinsic(substrateApi: _SubstrateApi, senderAddr
|
|
|
5
5
|
export declare function uniqueGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
6
6
|
export declare function quartzGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
7
7
|
export declare function statemineGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
8
|
+
export declare function statemintGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
8
9
|
export declare function getNftTransferExtrinsic(networkKey: string, substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
package/koni/api/nft/transfer.js
CHANGED
|
@@ -63,6 +63,16 @@ export function statemineGetExtrinsic(substrateApi, senderAddress, recipientAddr
|
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
export function statemintGetExtrinsic(substrateApi, senderAddress, recipientAddress, params) {
|
|
67
|
+
try {
|
|
68
|
+
const itemId = params.itemId;
|
|
69
|
+
const collectionId = params.collectionId;
|
|
70
|
+
return substrateApi.api.tx.nfts.transfer(collectionId, itemId, recipientAddress);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.error(e);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
66
76
|
export function getNftTransferExtrinsic(networkKey, substrateApi, senderAddress, recipientAddress, params) {
|
|
67
77
|
switch (networkKey) {
|
|
68
78
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.acala:
|
|
@@ -80,7 +90,7 @@ export function getNftTransferExtrinsic(networkKey, substrateApi, senderAddress,
|
|
|
80
90
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.statemine:
|
|
81
91
|
return statemineGetExtrinsic(substrateApi, senderAddress, recipientAddress, params);
|
|
82
92
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.statemint:
|
|
83
|
-
return
|
|
93
|
+
return statemintGetExtrinsic(substrateApi, senderAddress, recipientAddress, params);
|
|
84
94
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.bitcountry:
|
|
85
95
|
return acalaGetExtrinsic(substrateApi, senderAddress, recipientAddress, params);
|
|
86
96
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.pioneer:
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseNftApi, HandleNftParams } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
2
|
+
export declare class VaraNftApi extends BaseNftApi {
|
|
3
|
+
endpoint: string;
|
|
4
|
+
constructor(chain: string, addresses: string[]);
|
|
5
|
+
private static parseNftRequest;
|
|
6
|
+
private getNftByAccount;
|
|
7
|
+
handleNfts(params: HandleNftParams): Promise<void>;
|
|
8
|
+
fetchNfts(params: HandleNftParams): Promise<number>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { VARA_SCAN_ENDPOINT } from '@subwallet/extension-base/koni/api/nft/config';
|
|
5
|
+
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
6
|
+
import fetch from 'cross-fetch';
|
|
7
|
+
import { hexAddPrefix, u8aToHex } from '@polkadot/util';
|
|
8
|
+
import { decodeAddress } from '@polkadot/util-crypto';
|
|
9
|
+
export class VaraNftApi extends BaseNftApi {
|
|
10
|
+
endpoint = VARA_SCAN_ENDPOINT;
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line no-useless-constructor
|
|
13
|
+
constructor(chain, addresses) {
|
|
14
|
+
super(chain, undefined, addresses);
|
|
15
|
+
}
|
|
16
|
+
static parseNftRequest(publicKey) {
|
|
17
|
+
return {
|
|
18
|
+
// eslint-disable-next-line
|
|
19
|
+
query: `
|
|
20
|
+
query MyQuery {
|
|
21
|
+
accountById(id: "${publicKey}") {
|
|
22
|
+
id
|
|
23
|
+
nfts {
|
|
24
|
+
id
|
|
25
|
+
mediaUrl
|
|
26
|
+
name
|
|
27
|
+
tokenId
|
|
28
|
+
attribUrl
|
|
29
|
+
description
|
|
30
|
+
collection {
|
|
31
|
+
id
|
|
32
|
+
name
|
|
33
|
+
description
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// private static parseNftCollectionRequest (collectionId: string) {
|
|
43
|
+
// return {
|
|
44
|
+
// // eslint-disable-next-line
|
|
45
|
+
// query: `query MyQuery { collections(where: {collection_id: {_eq: \"${collectionId}\"}}) { collection_id name } }`
|
|
46
|
+
// };
|
|
47
|
+
// }
|
|
48
|
+
|
|
49
|
+
async getNftByAccount(address) {
|
|
50
|
+
var _result$data, _result$data$accountB;
|
|
51
|
+
const publicKey = hexAddPrefix(u8aToHex(decodeAddress(address)));
|
|
52
|
+
const resp = await fetch(this.endpoint, {
|
|
53
|
+
method: 'post',
|
|
54
|
+
headers: {
|
|
55
|
+
'Content-Type': 'application/json'
|
|
56
|
+
},
|
|
57
|
+
body: JSON.stringify(VaraNftApi.parseNftRequest(publicKey))
|
|
58
|
+
});
|
|
59
|
+
const result = await resp.json();
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
62
|
+
return result === null || result === void 0 ? void 0 : (_result$data = result.data) === null || _result$data === void 0 ? void 0 : (_result$data$accountB = _result$data.accountById) === null || _result$data$accountB === void 0 ? void 0 : _result$data$accountB.nfts;
|
|
63
|
+
}
|
|
64
|
+
async handleNfts(params) {
|
|
65
|
+
try {
|
|
66
|
+
await Promise.all(this.addresses.map(async address => {
|
|
67
|
+
const nfts = await this.getNftByAccount(address);
|
|
68
|
+
for (const nft of nfts) {
|
|
69
|
+
const parsedNft = {
|
|
70
|
+
id: nft.tokenId,
|
|
71
|
+
chain: this.chain,
|
|
72
|
+
owner: address,
|
|
73
|
+
name: nft.name,
|
|
74
|
+
image: this.parseUrl(nft.mediaUrl),
|
|
75
|
+
description: nft.description,
|
|
76
|
+
collectionId: nft.collection.id
|
|
77
|
+
};
|
|
78
|
+
const parsedCollection = {
|
|
79
|
+
collectionId: nft.collection.id,
|
|
80
|
+
chain: this.chain,
|
|
81
|
+
collectionName: nft.collection.name
|
|
82
|
+
};
|
|
83
|
+
params.updateItem(this.chain, parsedNft, address);
|
|
84
|
+
params.updateCollection(this.chain, parsedCollection);
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
} catch (e) {
|
|
88
|
+
console.error(`Failed to fetch ${this.chain} nft`, e);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async fetchNfts(params) {
|
|
92
|
+
try {
|
|
93
|
+
await this.handleNfts(params);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -3233,7 +3233,7 @@ export default class KoniExtension {
|
|
|
3233
3233
|
const wcId = request.request.id;
|
|
3234
3234
|
const params = request.request.params;
|
|
3235
3235
|
const requiredNamespaces = params.requiredNamespaces;
|
|
3236
|
-
const optionalNamespaces = params.optionalNamespaces;
|
|
3236
|
+
const optionalNamespaces = params.optionalNamespaces || {};
|
|
3237
3237
|
const availableNamespaces = {};
|
|
3238
3238
|
const namespaces = {};
|
|
3239
3239
|
const chainInfoMap = this.#koniState.getChainInfoMap();
|
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.17-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -249,6 +249,11 @@
|
|
|
249
249
|
"require": "./cjs/koni/api/nft/statemine_nft/index.js",
|
|
250
250
|
"default": "./koni/api/nft/statemine_nft/index.js"
|
|
251
251
|
},
|
|
252
|
+
"./koni/api/nft/statemint_nft": {
|
|
253
|
+
"types": "./koni/api/nft/statemint_nft/index.d.ts",
|
|
254
|
+
"require": "./cjs/koni/api/nft/statemint_nft/index.js",
|
|
255
|
+
"default": "./koni/api/nft/statemint_nft/index.js"
|
|
256
|
+
},
|
|
252
257
|
"./koni/api/nft/transfer": {
|
|
253
258
|
"types": "./koni/api/nft/transfer.d.ts",
|
|
254
259
|
"require": "./cjs/koni/api/nft/transfer.js",
|
|
@@ -274,6 +279,11 @@
|
|
|
274
279
|
"require": "./cjs/koni/api/nft/unique_nft/uniqueNftV2.js",
|
|
275
280
|
"default": "./koni/api/nft/unique_nft/uniqueNftV2.js"
|
|
276
281
|
},
|
|
282
|
+
"./koni/api/nft/vara_nft": {
|
|
283
|
+
"types": "./koni/api/nft/vara_nft/index.d.ts",
|
|
284
|
+
"require": "./cjs/koni/api/nft/vara_nft/index.js",
|
|
285
|
+
"default": "./koni/api/nft/vara_nft/index.js"
|
|
286
|
+
},
|
|
277
287
|
"./koni/api/nft/wasm_nft": {
|
|
278
288
|
"types": "./koni/api/nft/wasm_nft/index.d.ts",
|
|
279
289
|
"require": "./cjs/koni/api/nft/wasm_nft/index.js",
|
|
@@ -668,6 +678,16 @@
|
|
|
668
678
|
"require": "./cjs/services/migration-service/scripts/DeleteChain.js",
|
|
669
679
|
"default": "./services/migration-service/scripts/DeleteChain.js"
|
|
670
680
|
},
|
|
681
|
+
"./services/migration-service/scripts/EnableChain": {
|
|
682
|
+
"types": "./services/migration-service/scripts/EnableChain.d.ts",
|
|
683
|
+
"require": "./cjs/services/migration-service/scripts/EnableChain.js",
|
|
684
|
+
"default": "./services/migration-service/scripts/EnableChain.js"
|
|
685
|
+
},
|
|
686
|
+
"./services/migration-service/scripts/EnableVaraChain": {
|
|
687
|
+
"types": "./services/migration-service/scripts/EnableVaraChain.d.ts",
|
|
688
|
+
"require": "./cjs/services/migration-service/scripts/EnableVaraChain.js",
|
|
689
|
+
"default": "./services/migration-service/scripts/EnableVaraChain.js"
|
|
690
|
+
},
|
|
671
691
|
"./services/migration-service/scripts/MigrateAuthUrls": {
|
|
672
692
|
"types": "./services/migration-service/scripts/MigrateAuthUrls.d.ts",
|
|
673
693
|
"require": "./cjs/services/migration-service/scripts/MigrateAuthUrls.js",
|
|
@@ -703,6 +723,16 @@
|
|
|
703
723
|
"require": "./cjs/services/migration-service/scripts/MigrateNetworkSettings.js",
|
|
704
724
|
"default": "./services/migration-service/scripts/MigrateNetworkSettings.js"
|
|
705
725
|
},
|
|
726
|
+
"./services/migration-service/scripts/MigratePioneerProvider": {
|
|
727
|
+
"types": "./services/migration-service/scripts/MigratePioneerProvider.d.ts",
|
|
728
|
+
"require": "./cjs/services/migration-service/scripts/MigratePioneerProvider.js",
|
|
729
|
+
"default": "./services/migration-service/scripts/MigratePioneerProvider.js"
|
|
730
|
+
},
|
|
731
|
+
"./services/migration-service/scripts/MigrateProvider": {
|
|
732
|
+
"types": "./services/migration-service/scripts/MigrateProvider.d.ts",
|
|
733
|
+
"require": "./cjs/services/migration-service/scripts/MigrateProvider.js",
|
|
734
|
+
"default": "./services/migration-service/scripts/MigrateProvider.js"
|
|
735
|
+
},
|
|
706
736
|
"./services/migration-service/scripts/MigrateSettings": {
|
|
707
737
|
"types": "./services/migration-service/scripts/MigrateSettings.d.ts",
|
|
708
738
|
"require": "./cjs/services/migration-service/scripts/MigrateSettings.js",
|
|
@@ -1227,11 +1257,11 @@
|
|
|
1227
1257
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1228
1258
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1229
1259
|
"@substrate/connect": "^0.7.26",
|
|
1230
|
-
"@subwallet/chain-list": "0.2.16-beta.
|
|
1231
|
-
"@subwallet/extension-base": "^1.1.
|
|
1232
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1233
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1234
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1260
|
+
"@subwallet/chain-list": "0.2.16-beta.12",
|
|
1261
|
+
"@subwallet/extension-base": "^1.1.17-0",
|
|
1262
|
+
"@subwallet/extension-chains": "^1.1.17-0",
|
|
1263
|
+
"@subwallet/extension-dapp": "^1.1.17-0",
|
|
1264
|
+
"@subwallet/extension-inject": "^1.1.17-0",
|
|
1235
1265
|
"@subwallet/keyring": "^0.1.1",
|
|
1236
1266
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1237
1267
|
"@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.17-0'
|
|
11
11
|
};
|
|
@@ -26,8 +26,10 @@ export declare const _NFT_CHAIN_GROUP: {
|
|
|
26
26
|
karura: string[];
|
|
27
27
|
rmrk: string[];
|
|
28
28
|
statemine: string[];
|
|
29
|
+
statemint: string[];
|
|
29
30
|
unique_network: string[];
|
|
30
31
|
bitcountry: string[];
|
|
32
|
+
vara: string[];
|
|
31
33
|
};
|
|
32
34
|
export declare const _STAKING_CHAIN_GROUP: {
|
|
33
35
|
relay: string[];
|
|
@@ -41,9 +41,11 @@ export const _NFT_CHAIN_GROUP = {
|
|
|
41
41
|
karura: ['karura'],
|
|
42
42
|
// TODO: karura and acala should be the same
|
|
43
43
|
rmrk: ['kusama'],
|
|
44
|
-
statemine: ['statemine'
|
|
44
|
+
statemine: ['statemine'],
|
|
45
|
+
statemint: ['statemint'],
|
|
45
46
|
unique_network: ['unique_network'],
|
|
46
|
-
bitcountry: ['bitcountry', 'pioneer']
|
|
47
|
+
bitcountry: ['bitcountry', 'pioneer'],
|
|
48
|
+
vara: ['vara_network']
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
@@ -216,7 +218,7 @@ export const _XCM_TYPE = {
|
|
|
216
218
|
PR: `${_SubstrateChainType.PARACHAIN}-${_SubstrateChainType.RELAYCHAIN}` // UMP
|
|
217
219
|
};
|
|
218
220
|
|
|
219
|
-
export const _DEFAULT_ACTIVE_CHAINS = [..._DEFAULT_CHAINS];
|
|
221
|
+
export const _DEFAULT_ACTIVE_CHAINS = [..._DEFAULT_CHAINS, 'vara_network'];
|
|
220
222
|
export const EVM_PASS_CONNECT_STATUS = {
|
|
221
223
|
acala: ['acala_evm', 'karura_evm']
|
|
222
224
|
};
|
|
@@ -834,6 +834,8 @@ export class ChainService {
|
|
|
834
834
|
let evmInfo = null;
|
|
835
835
|
if (params.chainSpec.genesisHash !== '') {
|
|
836
836
|
substrateInfo = {
|
|
837
|
+
crowdloanFunds: params.chainSpec.crowdloanFunds || null,
|
|
838
|
+
crowdloanParaId: params.chainSpec.crowdloanParaId || null,
|
|
837
839
|
addressPrefix: params.chainSpec.addressPrefix,
|
|
838
840
|
blockExplorer: params.chainEditInfo.blockExplorer || null,
|
|
839
841
|
chainType: params.chainSpec.paraId !== null ? _SubstrateChainType.PARACHAIN : _SubstrateChainType.RELAYCHAIN,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
1
|
+
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _CrowdloanFund } from '@subwallet/chain-list/types';
|
|
2
2
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
4
|
import Web3 from 'web3';
|
|
@@ -89,6 +89,8 @@ export declare type _NetworkUpsertParams = {
|
|
|
89
89
|
genesisHash: string;
|
|
90
90
|
paraId: number | null;
|
|
91
91
|
addressPrefix: number;
|
|
92
|
+
crowdloanFunds?: _CrowdloanFund[] | null;
|
|
93
|
+
crowdloanParaId?: number | null;
|
|
92
94
|
evmChainId: number | null;
|
|
93
95
|
existentialDeposit: string;
|
|
94
96
|
decimals: number;
|
|
@@ -110,8 +110,40 @@ export class KeyringService {
|
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
}));
|
|
113
|
+
const currentAddress = this.currentAccountSubject.value.address;
|
|
114
|
+
const afterAccounts = {};
|
|
115
|
+
Object.keys(this.accounts).forEach(adr => {
|
|
116
|
+
afterAccounts[adr] = true;
|
|
117
|
+
});
|
|
118
|
+
accounts.forEach(value => {
|
|
119
|
+
afterAccounts[value.address] = true;
|
|
120
|
+
});
|
|
121
|
+
if (Object.keys(afterAccounts).length === 1) {
|
|
122
|
+
this.currentAccountSubject.next({
|
|
123
|
+
address: Object.keys(afterAccounts)[0],
|
|
124
|
+
currentGenesisHash: null
|
|
125
|
+
});
|
|
126
|
+
} else if (Object.keys(afterAccounts).indexOf(currentAddress) === -1) {
|
|
127
|
+
this.currentAccountSubject.next({
|
|
128
|
+
address: ALL_ACCOUNT_KEY,
|
|
129
|
+
currentGenesisHash: null
|
|
130
|
+
});
|
|
131
|
+
}
|
|
113
132
|
}
|
|
114
133
|
removeInjectAccounts(addresses) {
|
|
134
|
+
const currentAddress = this.currentAccountSubject.value.address;
|
|
135
|
+
const afterAccounts = Object.keys(this.accounts).filter(address => addresses.indexOf(address) < 0);
|
|
136
|
+
if (afterAccounts.length === 1) {
|
|
137
|
+
this.currentAccountSubject.next({
|
|
138
|
+
address: afterAccounts[0],
|
|
139
|
+
currentGenesisHash: null
|
|
140
|
+
});
|
|
141
|
+
} else if (addresses.indexOf(currentAddress) === -1) {
|
|
142
|
+
this.currentAccountSubject.next({
|
|
143
|
+
address: ALL_ACCOUNT_KEY,
|
|
144
|
+
currentGenesisHash: null
|
|
145
|
+
});
|
|
146
|
+
}
|
|
115
147
|
keyring.removeInjects(addresses);
|
|
116
148
|
}
|
|
117
149
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class EnableChain extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
const state = this.state;
|
|
8
|
+
await state.enableChain(this.slug, true);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class MigrateEthProvider extends
|
|
3
|
-
|
|
1
|
+
import MigrateProvider from './MigrateProvider';
|
|
2
|
+
export default class MigrateEthProvider extends MigrateProvider {
|
|
3
|
+
newProvider: string;
|
|
4
|
+
oldProvider: string;
|
|
5
|
+
slug: string;
|
|
4
6
|
}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
export default class MigrateEthProvider extends
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const oldProvider = 'Cloudflare';
|
|
10
|
-
const newProvider = 'Llamarpc';
|
|
11
|
-
const chainState = state.getChainStateByKey(slug);
|
|
12
|
-
const chainInfo = state.getChainInfo(slug);
|
|
13
|
-
if (chainState.active && chainState.currentProvider === oldProvider) {
|
|
14
|
-
await state.upsertChainInfo({
|
|
15
|
-
mode: 'update',
|
|
16
|
-
chainEditInfo: {
|
|
17
|
-
currentProvider: newProvider,
|
|
18
|
-
slug: slug,
|
|
19
|
-
providers: chainInfo.providers
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
4
|
+
import MigrateProvider from "./MigrateProvider.js";
|
|
5
|
+
export default class MigrateEthProvider extends MigrateProvider {
|
|
6
|
+
newProvider = 'ethereum';
|
|
7
|
+
oldProvider = 'Cloudflare';
|
|
8
|
+
slug = 'Llamarpc';
|
|
24
9
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import MigrateProvider from "./MigrateProvider.js";
|
|
5
|
+
export default class MigratePioneerProvider extends MigrateProvider {
|
|
6
|
+
slug = 'pioneer';
|
|
7
|
+
oldProvider = 'OnFinality';
|
|
8
|
+
newProvider = 'Pioneer';
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
2
|
+
export default abstract class MigrateProvider extends BaseMigrationJob {
|
|
3
|
+
abstract slug: string;
|
|
4
|
+
abstract oldProvider: string;
|
|
5
|
+
abstract newProvider: string;
|
|
6
|
+
run(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateProvider extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
const state = this.state;
|
|
8
|
+
const chainState = state.getChainStateByKey(this.slug);
|
|
9
|
+
const chainInfo = state.getChainInfo(this.slug);
|
|
10
|
+
if (chainState.active && chainState.currentProvider === this.oldProvider) {
|
|
11
|
+
await state.upsertChainInfo({
|
|
12
|
+
mode: 'update',
|
|
13
|
+
chainEditInfo: {
|
|
14
|
+
currentProvider: this.newProvider,
|
|
15
|
+
slug: this.slug,
|
|
16
|
+
providers: chainInfo.providers
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import DeleteChain from '@subwallet/extension-base/services/migration-service/scripts/DeleteChain';
|
|
5
5
|
import AutoEnableChainsTokens from "./AutoEnableChainsTokens.js";
|
|
6
|
+
import EnableVaraChain from "./EnableVaraChain.js";
|
|
6
7
|
import MigrateAuthUrls from "./MigrateAuthUrls.js";
|
|
7
8
|
import MigrateAutoLock from "./MigrateAutoLock.js";
|
|
8
9
|
import MigrateChainPatrol from "./MigrateChainPatrol.js";
|
|
@@ -10,6 +11,7 @@ import MigrateEthProvider from "./MigrateEthProvider.js";
|
|
|
10
11
|
import MigrateImportedToken from "./MigrateImportedToken.js";
|
|
11
12
|
import MigrateLedgerAccount from "./MigrateLedgerAccount.js";
|
|
12
13
|
import MigrateNetworkSettings from "./MigrateNetworkSettings.js";
|
|
14
|
+
import MigratePioneerProvider from "./MigratePioneerProvider.js";
|
|
13
15
|
import MigrateSettings from "./MigrateSettings.js";
|
|
14
16
|
import MigrateTokenDecimals from "./MigrateTokenDecimals.js";
|
|
15
17
|
import MigrateTransactionHistory from "./MigrateTransactionHistory.js";
|
|
@@ -28,6 +30,8 @@ export default {
|
|
|
28
30
|
'1.0.12-02': MigrateEthProvider,
|
|
29
31
|
'1.1.6-01': MigrateWalletReference,
|
|
30
32
|
'1.1.7': DeleteChain,
|
|
31
|
-
'1.1.13-01': MigrateTokenDecimals
|
|
33
|
+
'1.1.13-01': MigrateTokenDecimals,
|
|
34
|
+
'1.1.17-01': MigratePioneerProvider,
|
|
35
|
+
'1.1.17-03': EnableVaraChain
|
|
32
36
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
33
37
|
};
|