@subwallet/extension-base 1.2.10-0 → 1.2.11-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 +19 -0
- package/background/types.d.ts +42 -0
- package/cjs/koni/background/handlers/Extension.js +47 -15
- package/cjs/koni/background/handlers/State.js +3 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +8 -4
- package/cjs/services/chain-service/handler/SubstrateApi.js +20 -14
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +31 -16
- package/cjs/services/migration-service/scripts/ClearMetadataDatabase.js +19 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccountV2.js +51 -0
- package/cjs/services/migration-service/scripts/index.js +5 -1
- package/cjs/services/transaction-service/index.js +15 -4
- package/cjs/types/index.js +22 -11
- package/cjs/types/metadata.js +1 -0
- package/cjs/utils/index.js +12 -0
- package/cjs/utils/metadata.js +48 -0
- package/cjs/utils/registry.js +4 -3
- package/koni/background/handlers/Extension.js +48 -16
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +3 -1
- package/package.json +26 -5
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/index.js +8 -4
- package/services/chain-service/handler/SubstrateApi.js +20 -14
- package/services/chain-service/handler/SubstrateChainHandler.js +31 -16
- package/services/migration-service/scripts/ClearMetadataDatabase.d.ts +4 -0
- package/services/migration-service/scripts/ClearMetadataDatabase.js +11 -0
- package/services/migration-service/scripts/MigrateLedgerAccountV2.d.ts +4 -0
- package/services/migration-service/scripts/MigrateLedgerAccountV2.js +42 -0
- package/services/migration-service/scripts/index.js +5 -1
- package/services/transaction-service/index.js +16 -5
- package/types/index.d.ts +2 -1
- package/types/index.js +2 -1
- package/types/metadata.d.ts +6 -0
- package/types/metadata.js +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/metadata.d.ts +3 -0
- package/utils/metadata.js +39 -0
- package/utils/registry.d.ts +2 -2
- package/utils/registry.js +4 -3
package/types/index.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ export interface Message extends MessageEvent {
|
|
|
11
11
|
export * from './balance';
|
|
12
12
|
export * from './buy';
|
|
13
13
|
export * from './campaigns';
|
|
14
|
+
export * from './common';
|
|
14
15
|
export * from './fee';
|
|
16
|
+
export * from './metadata';
|
|
15
17
|
export * from './ordinal';
|
|
16
18
|
export * from './transaction';
|
|
17
19
|
export * from './yield';
|
|
18
|
-
export * from './common';
|
package/types/index.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
export * from "./balance/index.js";
|
|
5
5
|
export * from "./buy.js";
|
|
6
6
|
export * from "./campaigns/index.js";
|
|
7
|
+
export * from "./common/index.js";
|
|
7
8
|
export * from "./fee/index.js";
|
|
9
|
+
export * from "./metadata.js";
|
|
8
10
|
export * from "./ordinal.js";
|
|
9
11
|
export * from "./transaction.js";
|
|
10
12
|
export * from "./yield/index.js";
|
|
11
|
-
export * from "./common/index.js";
|
|
12
13
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -353,6 +353,7 @@ export * from "./fetchEvmChainInfo.js";
|
|
|
353
353
|
export * from "./fetchStaticData.js";
|
|
354
354
|
export * from "./gear/index.js";
|
|
355
355
|
export * from "./lazy.js";
|
|
356
|
+
export * from "./metadata.js";
|
|
356
357
|
export * from "./number.js";
|
|
357
358
|
export * from "./object.js";
|
|
358
359
|
export * from "./promise.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
const LEDGER_API_URL = 'https://ledger-api.subwallet.app';
|
|
5
|
+
const createUrl = path => `${LEDGER_API_URL}/${path}`;
|
|
6
|
+
export const _isRuntimeUpdated = signedExtensions => {
|
|
7
|
+
return signedExtensions.includes('CheckMetadataHash');
|
|
8
|
+
};
|
|
9
|
+
export const getMetadataHash = async chain => {
|
|
10
|
+
const data = {
|
|
11
|
+
id: chain
|
|
12
|
+
};
|
|
13
|
+
const resp = await fetch(createUrl('node/metadata/hash'), {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/json'
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify(data)
|
|
19
|
+
});
|
|
20
|
+
const rs = await resp.json();
|
|
21
|
+
return rs.metadataHash;
|
|
22
|
+
};
|
|
23
|
+
export const getShortMetadata = async (chain, blob) => {
|
|
24
|
+
const data = {
|
|
25
|
+
chain: {
|
|
26
|
+
id: chain
|
|
27
|
+
},
|
|
28
|
+
txBlob: blob
|
|
29
|
+
};
|
|
30
|
+
const resp = await fetch(createUrl('transaction/metadata'), {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(data)
|
|
36
|
+
});
|
|
37
|
+
const rs = await resp.json();
|
|
38
|
+
return rs.txMetadata;
|
|
39
|
+
};
|
package/utils/registry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
import { ResponseFindRawMetadata } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
3
|
import { Registry } from '@polkadot/types/types';
|
|
3
|
-
|
|
4
|
-
export declare const createRegistry: (chain: _ChainInfo, rawMetadata: HexString) => Registry;
|
|
4
|
+
export declare const createRegistry: (chain: _ChainInfo, data: ResponseFindRawMetadata) => Registry;
|
package/utils/registry.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
5
5
|
import { Metadata, TypeRegistry } from '@polkadot/types';
|
|
6
|
-
export const createRegistry = (chain,
|
|
6
|
+
export const createRegistry = (chain, data) => {
|
|
7
7
|
var _chain$substrateInfo;
|
|
8
8
|
const registry = new TypeRegistry();
|
|
9
|
-
const metadata = new Metadata(registry, rawMetadata);
|
|
10
|
-
registry.setMetadata(metadata);
|
|
9
|
+
const metadata = new Metadata(registry, data.rawMetadata);
|
|
11
10
|
const tokenInfo = _getChainNativeTokenBasicInfo(chain);
|
|
11
|
+
registry.register(data.types);
|
|
12
|
+
registry.setMetadata(metadata, undefined, data.userExtensions);
|
|
12
13
|
registry.setChainProperties(registry.createType('ChainProperties', {
|
|
13
14
|
ss58Format: ((_chain$substrateInfo = chain.substrateInfo) === null || _chain$substrateInfo === void 0 ? void 0 : _chain$substrateInfo.addressPrefix) || 42,
|
|
14
15
|
tokenDecimals: tokenInfo.decimals,
|