@subwallet/extension-base 1.0.12-0 → 1.0.13-1
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 +89 -0
- package/background/KoniTypes.js +18 -19
- package/background/handlers/Extension.js +17 -2
- package/background/handlers/State.d.ts +0 -1
- package/background/handlers/State.js +4 -8
- package/background/types.d.ts +6 -1
- package/cjs/background/KoniTypes.js +21 -11
- package/cjs/background/handlers/Extension.js +22 -6
- package/cjs/background/handlers/State.js +4 -8
- package/cjs/constants/index.js +7 -1
- package/cjs/defaults.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +5 -0
- package/cjs/koni/api/dotsama/transfer.js +6 -0
- package/cjs/koni/api/nft/config.js +11 -6
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
- package/cjs/koni/api/xcm/xTokens.js +2 -2
- package/cjs/koni/background/cron.js +12 -1
- package/cjs/koni/background/handlers/Extension.js +457 -131
- package/cjs/koni/background/handlers/State.js +236 -53
- package/cjs/koni/background/handlers/Tabs.js +61 -9
- package/cjs/koni/background/subscription.js +3 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/Metadata.js +3 -0
- package/cjs/services/chain-service/constants.js +10 -4
- package/cjs/services/chain-service/handler/SubstrateApi.js +2 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +3 -1
- package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +147 -0
- package/cjs/services/chain-service/index.js +54 -5
- package/cjs/services/chain-service/utils.js +32 -0
- package/cjs/services/event-service/types.js +3 -1
- package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -9
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +2 -2
- package/cjs/services/request-service/handler/WalletConnectRequestHandler.js +71 -0
- package/cjs/services/request-service/index.js +24 -6
- package/cjs/services/storage-service/DatabaseService.js +31 -1
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/MantaPay.js +40 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -2
- package/cjs/services/transaction-service/index.js +2 -1
- package/cjs/services/wallet-connect-service/constants.js +38 -0
- package/cjs/services/wallet-connect-service/handler/Eip155RequestHandler.js +113 -0
- package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +123 -0
- package/cjs/services/wallet-connect-service/helpers.js +81 -0
- package/cjs/services/wallet-connect-service/index.js +273 -0
- package/cjs/services/wallet-connect-service/types.js +27 -0
- package/cjs/utils/array.js +17 -0
- package/cjs/utils/environment.js +66 -0
- package/cjs/utils/index.js +78 -1
- package/cjs/utils/lazy.js +52 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +2 -0
- package/defaults.d.ts +1 -1
- package/defaults.js +1 -1
- package/koni/api/dotsama/balance.js +6 -1
- package/koni/api/dotsama/transfer.js +7 -1
- package/koni/api/nft/config.js +11 -6
- package/koni/api/xcm/polkadotXcm.js +1 -1
- package/koni/api/xcm/xTokens.js +2 -2
- package/koni/background/cron.d.ts +1 -0
- package/koni/background/cron.js +13 -2
- package/koni/background/handlers/Extension.d.ts +11 -0
- package/koni/background/handlers/Extension.js +329 -12
- package/koni/background/handlers/State.d.ts +17 -3
- package/koni/background/handlers/State.js +238 -52
- package/koni/background/handlers/Tabs.d.ts +2 -0
- package/koni/background/handlers/Tabs.js +58 -7
- package/koni/background/subscription.js +3 -0
- package/package.json +72 -6
- package/packageInfo.js +1 -1
- package/page/Metadata.d.ts +2 -0
- package/page/Metadata.js +3 -0
- package/services/chain-service/constants.d.ts +3 -0
- package/services/chain-service/constants.js +5 -2
- package/services/chain-service/handler/SubstrateApi.d.ts +1 -1
- package/services/chain-service/handler/SubstrateApi.js +2 -1
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +3 -1
- package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +30 -0
- package/services/chain-service/handler/manta/MantaPrivateHandler.js +140 -0
- package/services/chain-service/handler/types.d.ts +2 -0
- package/services/chain-service/index.d.ts +7 -3
- package/services/chain-service/index.js +56 -7
- package/services/chain-service/utils.d.ts +3 -0
- package/services/chain-service/utils.js +28 -0
- package/services/event-service/types.d.ts +3 -0
- package/services/event-service/types.js +3 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +0 -1
- package/services/request-service/handler/AuthRequestHandler.js +5 -10
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -1
- package/services/request-service/handler/SubstrateRequestHandler.js +2 -2
- package/services/request-service/handler/WalletConnectRequestHandler.d.ts +15 -0
- package/services/request-service/handler/WalletConnectRequestHandler.js +62 -0
- package/services/request-service/index.d.ts +7 -2
- package/services/request-service/index.js +24 -6
- package/services/storage-service/DatabaseService.d.ts +10 -1
- package/services/storage-service/DatabaseService.js +31 -1
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/MantaPay.d.ts +9 -0
- package/services/storage-service/db-stores/MantaPay.js +32 -0
- package/services/transaction-service/helpers/index.d.ts +1 -1
- package/services/transaction-service/helpers/index.js +2 -2
- package/services/transaction-service/index.js +2 -1
- package/services/transaction-service/types.d.ts +2 -1
- package/services/wallet-connect-service/constants.d.ts +11 -0
- package/services/wallet-connect-service/constants.js +23 -0
- package/services/wallet-connect-service/handler/Eip155RequestHandler.d.ts +8 -0
- package/services/wallet-connect-service/handler/Eip155RequestHandler.js +106 -0
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.d.ts +8 -0
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +114 -0
- package/services/wallet-connect-service/helpers.d.ts +12 -0
- package/services/wallet-connect-service/helpers.js +67 -0
- package/services/wallet-connect-service/index.d.ts +20 -0
- package/services/wallet-connect-service/index.js +265 -0
- package/services/wallet-connect-service/types.d.ts +46 -0
- package/services/wallet-connect-service/types.js +20 -0
- package/utils/array.d.ts +1 -0
- package/utils/array.js +10 -0
- package/utils/environment.d.ts +2 -0
- package/utils/environment.js +59 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.js +10 -2
- package/utils/lazy.d.ts +2 -0
- package/utils/lazy.js +43 -0
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.0.
|
|
20
|
+
"version": "1.0.13-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -530,6 +530,11 @@
|
|
|
530
530
|
"require": "./cjs/services/chain-service/handler/light-client/index.js",
|
|
531
531
|
"default": "./services/chain-service/handler/light-client/index.js"
|
|
532
532
|
},
|
|
533
|
+
"./services/chain-service/handler/manta/MantaPrivateHandler": {
|
|
534
|
+
"types": "./services/chain-service/handler/manta/MantaPrivateHandler.d.ts",
|
|
535
|
+
"require": "./cjs/services/chain-service/handler/manta/MantaPrivateHandler.js",
|
|
536
|
+
"default": "./services/chain-service/handler/manta/MantaPrivateHandler.js"
|
|
537
|
+
},
|
|
533
538
|
"./services/chain-service/handler/SubstrateApi": {
|
|
534
539
|
"types": "./services/chain-service/handler/SubstrateApi.d.ts",
|
|
535
540
|
"require": "./cjs/services/chain-service/handler/SubstrateApi.js",
|
|
@@ -735,6 +740,11 @@
|
|
|
735
740
|
"require": "./cjs/services/request-service/handler/SubstrateRequestHandler.js",
|
|
736
741
|
"default": "./services/request-service/handler/SubstrateRequestHandler.js"
|
|
737
742
|
},
|
|
743
|
+
"./services/request-service/handler/WalletConnectRequestHandler": {
|
|
744
|
+
"types": "./services/request-service/handler/WalletConnectRequestHandler.d.ts",
|
|
745
|
+
"require": "./cjs/services/request-service/handler/WalletConnectRequestHandler.js",
|
|
746
|
+
"default": "./services/request-service/handler/WalletConnectRequestHandler.js"
|
|
747
|
+
},
|
|
738
748
|
"./services/request-service/helper": {
|
|
739
749
|
"types": "./services/request-service/helper/index.d.ts",
|
|
740
750
|
"require": "./cjs/services/request-service/helper/index.js",
|
|
@@ -815,6 +825,11 @@
|
|
|
815
825
|
"require": "./cjs/services/storage-service/db-stores/Crowdloan.js",
|
|
816
826
|
"default": "./services/storage-service/db-stores/Crowdloan.js"
|
|
817
827
|
},
|
|
828
|
+
"./services/storage-service/db-stores/MantaPay": {
|
|
829
|
+
"types": "./services/storage-service/db-stores/MantaPay.d.ts",
|
|
830
|
+
"require": "./cjs/services/storage-service/db-stores/MantaPay.js",
|
|
831
|
+
"default": "./services/storage-service/db-stores/MantaPay.js"
|
|
832
|
+
},
|
|
818
833
|
"./services/storage-service/db-stores/Metadata": {
|
|
819
834
|
"types": "./services/storage-service/db-stores/Metadata.d.ts",
|
|
820
835
|
"require": "./cjs/services/storage-service/db-stores/Metadata.js",
|
|
@@ -900,6 +915,36 @@
|
|
|
900
915
|
"require": "./cjs/services/transaction-service/utils.js",
|
|
901
916
|
"default": "./services/transaction-service/utils.js"
|
|
902
917
|
},
|
|
918
|
+
"./services/wallet-connect-service": {
|
|
919
|
+
"types": "./services/wallet-connect-service/index.d.ts",
|
|
920
|
+
"require": "./cjs/services/wallet-connect-service/index.js",
|
|
921
|
+
"default": "./services/wallet-connect-service/index.js"
|
|
922
|
+
},
|
|
923
|
+
"./services/wallet-connect-service/constants": {
|
|
924
|
+
"types": "./services/wallet-connect-service/constants.d.ts",
|
|
925
|
+
"require": "./cjs/services/wallet-connect-service/constants.js",
|
|
926
|
+
"default": "./services/wallet-connect-service/constants.js"
|
|
927
|
+
},
|
|
928
|
+
"./services/wallet-connect-service/handler/Eip155RequestHandler": {
|
|
929
|
+
"types": "./services/wallet-connect-service/handler/Eip155RequestHandler.d.ts",
|
|
930
|
+
"require": "./cjs/services/wallet-connect-service/handler/Eip155RequestHandler.js",
|
|
931
|
+
"default": "./services/wallet-connect-service/handler/Eip155RequestHandler.js"
|
|
932
|
+
},
|
|
933
|
+
"./services/wallet-connect-service/handler/PolkadotRequestHandler": {
|
|
934
|
+
"types": "./services/wallet-connect-service/handler/PolkadotRequestHandler.d.ts",
|
|
935
|
+
"require": "./cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js",
|
|
936
|
+
"default": "./services/wallet-connect-service/handler/PolkadotRequestHandler.js"
|
|
937
|
+
},
|
|
938
|
+
"./services/wallet-connect-service/helpers": {
|
|
939
|
+
"types": "./services/wallet-connect-service/helpers.d.ts",
|
|
940
|
+
"require": "./cjs/services/wallet-connect-service/helpers.js",
|
|
941
|
+
"default": "./services/wallet-connect-service/helpers.js"
|
|
942
|
+
},
|
|
943
|
+
"./services/wallet-connect-service/types": {
|
|
944
|
+
"types": "./services/wallet-connect-service/types.d.ts",
|
|
945
|
+
"require": "./cjs/services/wallet-connect-service/types.js",
|
|
946
|
+
"default": "./services/wallet-connect-service/types.js"
|
|
947
|
+
},
|
|
903
948
|
"./signers/substrates/KeyringSigner": {
|
|
904
949
|
"types": "./signers/substrates/KeyringSigner.d.ts",
|
|
905
950
|
"require": "./cjs/signers/substrates/KeyringSigner.js",
|
|
@@ -1020,11 +1065,21 @@
|
|
|
1020
1065
|
"require": "./cjs/utils/address.js",
|
|
1021
1066
|
"default": "./utils/address.js"
|
|
1022
1067
|
},
|
|
1068
|
+
"./utils/array": {
|
|
1069
|
+
"types": "./utils/array.d.ts",
|
|
1070
|
+
"require": "./cjs/utils/array.js",
|
|
1071
|
+
"default": "./utils/array.js"
|
|
1072
|
+
},
|
|
1023
1073
|
"./utils/canDerive": {
|
|
1024
1074
|
"types": "./utils/canDerive.d.ts",
|
|
1025
1075
|
"require": "./cjs/utils/canDerive.js",
|
|
1026
1076
|
"default": "./utils/canDerive.js"
|
|
1027
1077
|
},
|
|
1078
|
+
"./utils/environment": {
|
|
1079
|
+
"types": "./utils/environment.d.ts",
|
|
1080
|
+
"require": "./cjs/utils/environment.js",
|
|
1081
|
+
"default": "./utils/environment.js"
|
|
1082
|
+
},
|
|
1028
1083
|
"./utils/eth": {
|
|
1029
1084
|
"types": "./utils/eth.d.ts",
|
|
1030
1085
|
"require": "./cjs/utils/eth.js",
|
|
@@ -1055,6 +1110,11 @@
|
|
|
1055
1110
|
"require": "./cjs/utils/keyring.js",
|
|
1056
1111
|
"default": "./utils/keyring.js"
|
|
1057
1112
|
},
|
|
1113
|
+
"./utils/lazy": {
|
|
1114
|
+
"types": "./utils/lazy.d.ts",
|
|
1115
|
+
"require": "./cjs/utils/lazy.js",
|
|
1116
|
+
"default": "./utils/lazy.js"
|
|
1117
|
+
},
|
|
1058
1118
|
"./utils/number": {
|
|
1059
1119
|
"types": "./utils/number.d.ts",
|
|
1060
1120
|
"require": "./cjs/utils/number.js",
|
|
@@ -1078,6 +1138,7 @@
|
|
|
1078
1138
|
"@ethereumjs/common": "^2.6.5",
|
|
1079
1139
|
"@ethereumjs/tx": "^4.0.2",
|
|
1080
1140
|
"@ethersproject/abi": "^5.7.0",
|
|
1141
|
+
"@json-rpc-tools/utils": "^1.7.6",
|
|
1081
1142
|
"@metamask/safe-event-emitter": "^2.0.0",
|
|
1082
1143
|
"@metaverse-network-sdk/type-definitions": "^0.0.1-13",
|
|
1083
1144
|
"@oak-foundation/types": "^0.0.23",
|
|
@@ -1097,16 +1158,20 @@
|
|
|
1097
1158
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1098
1159
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1099
1160
|
"@substrate/connect": "^0.7.26",
|
|
1100
|
-
"@subwallet/chain-list": "^0.2.
|
|
1101
|
-
"@subwallet/extension-base": "^1.0.
|
|
1102
|
-
"@subwallet/extension-chains": "^1.0.
|
|
1103
|
-
"@subwallet/extension-dapp": "^1.0.
|
|
1104
|
-
"@subwallet/extension-inject": "^1.0.
|
|
1161
|
+
"@subwallet/chain-list": "^0.2.4",
|
|
1162
|
+
"@subwallet/extension-base": "^1.0.13-1",
|
|
1163
|
+
"@subwallet/extension-chains": "^1.0.13-1",
|
|
1164
|
+
"@subwallet/extension-dapp": "^1.0.13-1",
|
|
1165
|
+
"@subwallet/extension-inject": "^1.0.13-1",
|
|
1105
1166
|
"@subwallet/keyring": "^0.0.10",
|
|
1106
1167
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1168
|
+
"@walletconnect/sign-client": "^2.8.4",
|
|
1169
|
+
"@walletconnect/types": "^2.8.4",
|
|
1170
|
+
"@walletconnect/utils": "^2.8.4",
|
|
1107
1171
|
"axios": "^1.2.1",
|
|
1108
1172
|
"bignumber.js": "^9.1.1",
|
|
1109
1173
|
"bn.js": "^5.2.1",
|
|
1174
|
+
"browser-passworder": "^2.0.3",
|
|
1110
1175
|
"buffer": "^6.0.3",
|
|
1111
1176
|
"cross-fetch": "^3.1.5",
|
|
1112
1177
|
"dexie": "^3.2.2",
|
|
@@ -1119,6 +1184,7 @@
|
|
|
1119
1184
|
"i18next": "^21.9.2",
|
|
1120
1185
|
"is-buffer": "^2.0.5",
|
|
1121
1186
|
"json-rpc-engine": "^6.1.0",
|
|
1187
|
+
"manta-extension-sdk": "^1.1.0",
|
|
1122
1188
|
"moment": "^2.29.4",
|
|
1123
1189
|
"protobufjs": "^7.1.2",
|
|
1124
1190
|
"rxjs": "^7.8.1",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.0.
|
|
10
|
+
version: '1.0.13-1'
|
|
11
11
|
};
|
package/page/Metadata.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { InjectedMetadata, InjectedMetadataKnown, MetadataDef } from '@subwallet/extension-inject/types';
|
|
2
2
|
import type { SendRequest } from './types';
|
|
3
|
+
import { RequestAddPspToken } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
4
|
export default class Metadata implements InjectedMetadata {
|
|
4
5
|
constructor(_sendRequest: SendRequest);
|
|
5
6
|
get(): Promise<InjectedMetadataKnown[]>;
|
|
6
7
|
provide(definition: MetadataDef): Promise<boolean>;
|
|
8
|
+
addToken(request: RequestAddPspToken): Promise<boolean>;
|
|
7
9
|
}
|
package/page/Metadata.js
CHANGED
|
@@ -70,6 +70,9 @@ export declare const _TRANSFER_CHAIN_GROUP: {
|
|
|
70
70
|
export declare const _BALANCE_PARSING_CHAIN_GROUP: {
|
|
71
71
|
bobabeam: string[];
|
|
72
72
|
};
|
|
73
|
+
export declare const _MANTA_ZK_CHAIN_GROUP: string[];
|
|
74
|
+
export declare const _ZK_ASSET_PREFIX = "zk";
|
|
75
|
+
export declare const _DEFAULT_MANTA_ZK_CHAIN = "calamari";
|
|
73
76
|
export declare const _XCM_CHAIN_GROUP: {
|
|
74
77
|
polkadotXcm: string[];
|
|
75
78
|
xcmPallet: string[];
|
|
@@ -27,7 +27,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
27
27
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
28
28
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
29
29
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main'],
|
|
30
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel'],
|
|
30
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari'],
|
|
31
31
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'] // perhaps there are some runtime updates
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -189,6 +189,9 @@ export const _TRANSFER_CHAIN_GROUP = {
|
|
|
189
189
|
export const _BALANCE_PARSING_CHAIN_GROUP = {
|
|
190
190
|
bobabeam: ['bobabeam', 'bobabase']
|
|
191
191
|
};
|
|
192
|
+
export const _MANTA_ZK_CHAIN_GROUP = ['calamari'];
|
|
193
|
+
export const _ZK_ASSET_PREFIX = 'zk';
|
|
194
|
+
export const _DEFAULT_MANTA_ZK_CHAIN = 'calamari';
|
|
192
195
|
|
|
193
196
|
// XCM------------------------------------------------------------------------------------------------------------------
|
|
194
197
|
|
|
@@ -209,7 +212,7 @@ export const _XCM_TYPE = {
|
|
|
209
212
|
export const _DEFAULT_ACTIVE_CHAINS = [..._DEFAULT_CHAINS];
|
|
210
213
|
|
|
211
214
|
// TODO: review
|
|
212
|
-
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni-
|
|
215
|
+
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni/dev/issue-15' : 'master';
|
|
213
216
|
export const _CHAIN_INFO_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainInfo.json`;
|
|
214
217
|
export const _CHAIN_ASSET_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainAsset.json`;
|
|
215
218
|
export const _ASSET_REF_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/AssetRef.json`;
|
|
@@ -33,7 +33,7 @@ export declare class SubstrateApi implements _SubstrateApi {
|
|
|
33
33
|
systemVersion: string;
|
|
34
34
|
private createProvider;
|
|
35
35
|
private createApi;
|
|
36
|
-
constructor(chainSlug: string, apiUrl: string, { metadata, providerName }?: _ApiOptions);
|
|
36
|
+
constructor(chainSlug: string, apiUrl: string, { externalApiPromise, metadata, providerName }?: _ApiOptions);
|
|
37
37
|
get isReady(): Promise<_SubstrateApi>;
|
|
38
38
|
updateApiUrl(apiUrl: string): Promise<void>;
|
|
39
39
|
connect(): void;
|
|
@@ -68,6 +68,7 @@ export class SubstrateApi {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
constructor(chainSlug, apiUrl, {
|
|
71
|
+
externalApiPromise,
|
|
71
72
|
metadata,
|
|
72
73
|
providerName
|
|
73
74
|
} = {}) {
|
|
@@ -77,7 +78,7 @@ export class SubstrateApi {
|
|
|
77
78
|
this.registry = new TypeRegistry();
|
|
78
79
|
this.metadata = metadata;
|
|
79
80
|
this.provider = this.createProvider(apiUrl);
|
|
80
|
-
this.api = this.createApi(this.provider);
|
|
81
|
+
this.api = externalApiPromise || this.createApi(this.provider);
|
|
81
82
|
this.handleApiReady = createPromiseHandler();
|
|
82
83
|
this.api.on('ready', this.onReady.bind(this));
|
|
83
84
|
this.api.on('connected', this.onConnect.bind(this));
|
|
@@ -19,5 +19,5 @@ export declare class SubstrateChainHandler extends AbstractChainHandler {
|
|
|
19
19
|
getSmartContractTokenInfo(contractAddress: string, tokenType: _AssetType, originChain: string, contractCaller?: string): Promise<_SmartContractTokenInfo>;
|
|
20
20
|
setSubstrateApi(chainSlug: string, substrateApi: SubstrateApi): void;
|
|
21
21
|
destroySubstrateApi(chainSlug: string): void;
|
|
22
|
-
initApi(chainSlug: string, apiUrl: string, { onUpdateStatus, providerName }?: Omit<_ApiOptions, 'metadata'>): Promise<
|
|
22
|
+
initApi(chainSlug: string, apiUrl: string, { externalApiPromise, onUpdateStatus, providerName }?: Omit<_ApiOptions, 'metadata'>): Promise<SubstrateApi>;
|
|
23
23
|
}
|
|
@@ -173,6 +173,7 @@ export class SubstrateChainHandler extends AbstractChainHandler {
|
|
|
173
173
|
substrateAPI === null || substrateAPI === void 0 ? void 0 : substrateAPI.destroy().catch(console.error);
|
|
174
174
|
}
|
|
175
175
|
async initApi(chainSlug, apiUrl, {
|
|
176
|
+
externalApiPromise,
|
|
176
177
|
onUpdateStatus,
|
|
177
178
|
providerName
|
|
178
179
|
} = {}) {
|
|
@@ -190,7 +191,8 @@ export class SubstrateChainHandler extends AbstractChainHandler {
|
|
|
190
191
|
const metadata = await ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.getMetadata(chainSlug));
|
|
191
192
|
const apiObject = new SubstrateApi(chainSlug, apiUrl, {
|
|
192
193
|
providerName,
|
|
193
|
-
metadata
|
|
194
|
+
metadata,
|
|
195
|
+
externalApiPromise
|
|
194
196
|
});
|
|
195
197
|
apiObject.isApiConnectedSubject.subscribe(this.handleConnect.bind(this, chainSlug));
|
|
196
198
|
onUpdateStatus && apiObject.isApiConnectedSubject.subscribe(onUpdateStatus);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MantaAuthorizationContext, MantaPayConfig, MantaPaySyncState } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
3
|
+
import { MantaPayWallet } from 'manta-extension-sdk';
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
|
+
export declare class MantaPrivateHandler {
|
|
6
|
+
private dbService;
|
|
7
|
+
private _privateWallet;
|
|
8
|
+
private currentAddress;
|
|
9
|
+
private syncStateSubject;
|
|
10
|
+
private syncState;
|
|
11
|
+
constructor(dbService: DatabaseService);
|
|
12
|
+
setCurrentAddress(address: string): void;
|
|
13
|
+
getSyncState(): MantaPaySyncState;
|
|
14
|
+
get privateWallet(): MantaPayWallet | undefined;
|
|
15
|
+
subscribeSyncState(): Subject<MantaPaySyncState>;
|
|
16
|
+
updateMantaPayConfig(address: string, chain: string, changes: Record<string, any>): Promise<void>;
|
|
17
|
+
saveMantaPayConfig(config: MantaPayConfig): Promise<void>;
|
|
18
|
+
getMantaPayConfig(address: string, chain: string): Promise<any>;
|
|
19
|
+
getMantaPayFirstConfig(chain: string): Promise<any>;
|
|
20
|
+
deleteMantaPayConfig(address: string, chain: string): Promise<any>;
|
|
21
|
+
saveMantaAuthContext(context: MantaAuthorizationContext): Promise<void>;
|
|
22
|
+
getMantaAuthContext(address: string, chain: string): Promise<any>;
|
|
23
|
+
deleteMantaAuthContext(address: string, chain: string): Promise<number>;
|
|
24
|
+
private saveLedgerState;
|
|
25
|
+
private getLedgerState;
|
|
26
|
+
initMantaPay(providerUrl: string, network: string): Promise<import("@polkadot/api").ApiPromise>;
|
|
27
|
+
getCurrentLedgerState(): Promise<number>;
|
|
28
|
+
setSyncState(data: MantaPaySyncState): void;
|
|
29
|
+
subscribeSyncProgress(): Promise<() => void>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { BaseWallet, MantaPayWallet } from 'manta-extension-sdk';
|
|
5
|
+
import { Subject } from 'rxjs';
|
|
6
|
+
export class MantaPrivateHandler {
|
|
7
|
+
_privateWallet = undefined;
|
|
8
|
+
syncStateSubject = new Subject();
|
|
9
|
+
constructor(dbService) {
|
|
10
|
+
this.dbService = dbService;
|
|
11
|
+
this.syncState = {
|
|
12
|
+
isSyncing: false,
|
|
13
|
+
progress: 0
|
|
14
|
+
};
|
|
15
|
+
this.syncStateSubject.next(this.syncState);
|
|
16
|
+
}
|
|
17
|
+
setCurrentAddress(address) {
|
|
18
|
+
this.currentAddress = address;
|
|
19
|
+
}
|
|
20
|
+
getSyncState() {
|
|
21
|
+
return this.syncState;
|
|
22
|
+
}
|
|
23
|
+
get privateWallet() {
|
|
24
|
+
return this._privateWallet;
|
|
25
|
+
}
|
|
26
|
+
subscribeSyncState() {
|
|
27
|
+
return this.syncStateSubject;
|
|
28
|
+
}
|
|
29
|
+
async updateMantaPayConfig(address, chain, changes) {
|
|
30
|
+
await this.dbService.updateMantaPayData(`config_${chain}_${address}`, changes);
|
|
31
|
+
}
|
|
32
|
+
async saveMantaPayConfig(config) {
|
|
33
|
+
await this.dbService.setMantaPayData({
|
|
34
|
+
key: `config_${config.chain}_${config.address}`,
|
|
35
|
+
...config
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async getMantaPayConfig(address, chain) {
|
|
39
|
+
return this.dbService.getMantaPayData(`config_${chain}_${address}`);
|
|
40
|
+
}
|
|
41
|
+
async getMantaPayFirstConfig(chain) {
|
|
42
|
+
return this.dbService.getMantaPayFirstConfig(chain);
|
|
43
|
+
}
|
|
44
|
+
async deleteMantaPayConfig(address, chain) {
|
|
45
|
+
return this.dbService.deleteMantaPayConfig(`config_${chain}_${address}`);
|
|
46
|
+
}
|
|
47
|
+
async saveMantaAuthContext(context) {
|
|
48
|
+
await this.dbService.setMantaPayData({
|
|
49
|
+
key: `authContext_${context.chain}_${context.address}`,
|
|
50
|
+
...context
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async getMantaAuthContext(address, chain) {
|
|
54
|
+
return this.dbService.getMantaPayData(`authContext_${chain}_${address}`);
|
|
55
|
+
}
|
|
56
|
+
async deleteMantaAuthContext(address, chain) {
|
|
57
|
+
return this.dbService.deleteMantaPayConfig(`authContext_${chain}_${address}`);
|
|
58
|
+
}
|
|
59
|
+
async saveLedgerState(palletName, network, data) {
|
|
60
|
+
try {
|
|
61
|
+
const suffix = this.currentAddress ? `_${this.currentAddress}` : '';
|
|
62
|
+
await this.dbService.setMantaPayData({
|
|
63
|
+
key: `storage_state_${palletName}_${network}${suffix}`,
|
|
64
|
+
...data
|
|
65
|
+
});
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error('manta-pay', e);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
async getLedgerState(palletName, network) {
|
|
73
|
+
let result;
|
|
74
|
+
try {
|
|
75
|
+
const suffix = this.currentAddress ? `_${this.currentAddress}` : '';
|
|
76
|
+
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
78
|
+
result = await this.dbService.getMantaPayData(`storage_state_${palletName}_${network}${suffix}`);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
console.error(e);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
84
|
+
return result || null;
|
|
85
|
+
}
|
|
86
|
+
async initMantaPay(providerUrl, network) {
|
|
87
|
+
const networkParam = network.charAt(0).toUpperCase() + network.slice(1); // Manta || Calamari || Dolphin
|
|
88
|
+
|
|
89
|
+
const baseWallet = await BaseWallet.init({
|
|
90
|
+
apiEndpoint: providerUrl,
|
|
91
|
+
loggingEnabled: false,
|
|
92
|
+
provingFilePath: './manta-pay/proving',
|
|
93
|
+
parametersFilePath: './manta-pay/parameters',
|
|
94
|
+
saveStorageStateToLocal: this.saveLedgerState.bind(this),
|
|
95
|
+
getStorageStateFromLocal: this.getLedgerState.bind(this)
|
|
96
|
+
});
|
|
97
|
+
this._privateWallet = MantaPayWallet.init(networkParam, baseWallet);
|
|
98
|
+
return this._privateWallet.api;
|
|
99
|
+
}
|
|
100
|
+
async getCurrentLedgerState() {
|
|
101
|
+
var _this$_privateWallet;
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
103
|
+
const ledgerState = await this.getLedgerState('mantaPay', 'Calamari');
|
|
104
|
+
if (!ledgerState) {
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
109
|
+
return await ((_this$_privateWallet = this._privateWallet) === null || _this$_privateWallet === void 0 ? void 0 : _this$_privateWallet.getLedgerCurrentCount(ledgerState.checkpoint));
|
|
110
|
+
}
|
|
111
|
+
setSyncState(data) {
|
|
112
|
+
this.syncState = data;
|
|
113
|
+
this.syncStateSubject.next(this.syncState);
|
|
114
|
+
}
|
|
115
|
+
async subscribeSyncProgress() {
|
|
116
|
+
var _this$_privateWallet2;
|
|
117
|
+
const ledgerTotalCount = await ((_this$_privateWallet2 = this._privateWallet) === null || _this$_privateWallet2 === void 0 ? void 0 : _this$_privateWallet2.getLedgerTotalCount());
|
|
118
|
+
const interval = setInterval(() => {
|
|
119
|
+
this.getCurrentLedgerState().then(currentCount => {
|
|
120
|
+
const progress = Math.floor(currentCount / ledgerTotalCount * 100);
|
|
121
|
+
if (progress === 100) {
|
|
122
|
+
this.syncState = {
|
|
123
|
+
isSyncing: false,
|
|
124
|
+
progress
|
|
125
|
+
};
|
|
126
|
+
clearInterval(interval);
|
|
127
|
+
} else {
|
|
128
|
+
this.syncState = {
|
|
129
|
+
isSyncing: true,
|
|
130
|
+
progress
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
this.syncStateSubject.next(this.syncState);
|
|
134
|
+
}).catch(console.error);
|
|
135
|
+
}, 1000);
|
|
136
|
+
return () => {
|
|
137
|
+
interval && clearInterval(interval);
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MetadataItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import { ApiPromise } from '@polkadot/api';
|
|
2
3
|
export interface _EvmChainSpec {
|
|
3
4
|
evmChainId: number;
|
|
4
5
|
name: string;
|
|
@@ -19,6 +20,7 @@ export interface _ApiOptions {
|
|
|
19
20
|
providerName?: string;
|
|
20
21
|
metadata?: MetadataItem;
|
|
21
22
|
onUpdateStatus?: (isConnected: boolean) => void;
|
|
23
|
+
externalApiPromise?: ApiPromise;
|
|
22
24
|
}
|
|
23
25
|
export declare enum _CHAIN_VALIDATION_ERROR {
|
|
24
26
|
INVALID_INFO_TYPE = "invalidInfoType",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
2
|
import { AssetSetting, ValidateNetworkResponse } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
-
import {
|
|
3
|
+
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
4
4
|
import { _ChainConnectionStatus, _ChainState, _NetworkUpsertParams, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse } from '@subwallet/extension-base/services/chain-service/types';
|
|
5
5
|
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
6
6
|
import { IMetadataItem } from '@subwallet/extension-base/services/storage-service/databases';
|
|
@@ -13,6 +13,8 @@ export declare class ChainService {
|
|
|
13
13
|
private lockChainInfoMap;
|
|
14
14
|
private substrateChainHandler;
|
|
15
15
|
private evmChainHandler;
|
|
16
|
+
private mantaChainHandler;
|
|
17
|
+
get mantaPay(): MantaPrivateHandler;
|
|
16
18
|
private chainInfoMapSubject;
|
|
17
19
|
private chainStateMapSubject;
|
|
18
20
|
private assetRegistrySubject;
|
|
@@ -25,8 +27,8 @@ export declare class ChainService {
|
|
|
25
27
|
getXcmRefMap(): Record<string, _AssetRef>;
|
|
26
28
|
getEvmApi(slug: string): import("./handler/EvmApi").EvmApi;
|
|
27
29
|
getEvmApiMap(): Record<string, import("./handler/EvmApi").EvmApi>;
|
|
28
|
-
getSubstrateApiMap(): Record<string, SubstrateApi>;
|
|
29
|
-
getSubstrateApi(slug: string): SubstrateApi;
|
|
30
|
+
getSubstrateApiMap(): Record<string, import("./handler/SubstrateApi").SubstrateApi>;
|
|
31
|
+
getSubstrateApi(slug: string): import("./handler/SubstrateApi").SubstrateApi;
|
|
30
32
|
getChainCurrentProviderByKey(slug: string): {
|
|
31
33
|
endpoint: string;
|
|
32
34
|
providerName: string;
|
|
@@ -54,6 +56,7 @@ export declare class ChainService {
|
|
|
54
56
|
getChainInfoByKey(key: string): _ChainInfo;
|
|
55
57
|
getActiveChainInfos(): Record<string, _ChainInfo>;
|
|
56
58
|
getAssetBySlug(slug: string): _ChainAsset;
|
|
59
|
+
getMantaZkAssets(chain: string): Record<string, _ChainAsset>;
|
|
57
60
|
getFungibleTokensByChain(chainSlug: string, checkActive?: boolean): Record<string, _ChainAsset>;
|
|
58
61
|
getXcmEqualAssetByChain(destinationChainSlug: string, originTokenSlug: string): _ChainAsset | undefined;
|
|
59
62
|
getAssetByChainAndType(chainSlug: string, assetTypes: _AssetType[]): Record<string, _ChainAsset>;
|
|
@@ -96,6 +99,7 @@ export declare class ChainService {
|
|
|
96
99
|
checkAndUpdateStatusMapForChain(chainSlug: string): void;
|
|
97
100
|
initAssetSettings(): Promise<void>;
|
|
98
101
|
setAssetSettings(assetSettings: Record<string, AssetSetting>, emitEvent?: boolean): void;
|
|
102
|
+
setMantaZkAssetSettings(visible: boolean): void;
|
|
99
103
|
getStoreAssetSettings(): Promise<Record<string, AssetSetting>>;
|
|
100
104
|
getAssetSettings(): Promise<Record<string, AssetSetting>>;
|
|
101
105
|
updateAssetSetting(assetSlug: string, assetSetting: AssetSetting, autoEnableNativeToken?: boolean): Promise<boolean | undefined>;
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import { AssetLogoMap, AssetRefMap, ChainAssetMap, ChainInfoMap, ChainLogoMap, MultiChainAssetMap } from '@subwallet/chain-list';
|
|
5
5
|
import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
6
|
-
import { _ASSET_LOGO_MAP_SRC, _ASSET_REF_SRC, _CHAIN_ASSET_SRC, _CHAIN_INFO_SRC, _CHAIN_LOGO_MAP_SRC, _DEFAULT_ACTIVE_CHAINS, _MULTI_CHAIN_ASSET_SRC } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
|
+
import { _ASSET_LOGO_MAP_SRC, _ASSET_REF_SRC, _CHAIN_ASSET_SRC, _CHAIN_INFO_SRC, _CHAIN_LOGO_MAP_SRC, _DEFAULT_ACTIVE_CHAINS, _MANTA_ZK_CHAIN_GROUP, _MULTI_CHAIN_ASSET_SRC, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
7
|
import { EvmChainHandler } from '@subwallet/extension-base/services/chain-service/handler/EvmChainHandler';
|
|
8
|
+
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
8
9
|
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
9
10
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
10
11
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
11
|
-
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isEqualContractAddress, _isEqualSmartContractAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
12
|
+
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
12
13
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
13
14
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
14
15
|
import Web3 from 'web3';
|
|
@@ -22,6 +23,10 @@ export class ChainService {
|
|
|
22
23
|
};
|
|
23
24
|
lockChainInfoMap = false; // prevent unwanted changes (edit, enable, disable) to chainInfoMap
|
|
24
25
|
|
|
26
|
+
get mantaPay() {
|
|
27
|
+
return this.mantaChainHandler;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
// TODO: consider BehaviorSubject
|
|
26
31
|
chainInfoMapSubject = new Subject();
|
|
27
32
|
chainStateMapSubject = new Subject();
|
|
@@ -35,6 +40,10 @@ export class ChainService {
|
|
|
35
40
|
constructor(dbService, eventService) {
|
|
36
41
|
this.dbService = dbService;
|
|
37
42
|
this.eventService = eventService;
|
|
43
|
+
this.substrateChainHandler = new SubstrateChainHandler();
|
|
44
|
+
this.evmChainHandler = new EvmChainHandler();
|
|
45
|
+
this.mantaChainHandler = new MantaPrivateHandler(dbService);
|
|
46
|
+
this.chainInfoMapSubject.next(this.dataMap.chainInfoMap);
|
|
38
47
|
this.chainStateMapSubject.next(this.dataMap.chainStateMap);
|
|
39
48
|
this.chainInfoMapSubject.next(this.dataMap.chainInfoMap);
|
|
40
49
|
this.assetRegistrySubject.next(this.dataMap.assetRegistry);
|
|
@@ -212,6 +221,15 @@ export class ChainService {
|
|
|
212
221
|
getAssetBySlug(slug) {
|
|
213
222
|
return this.getAssetRegistry()[slug];
|
|
214
223
|
}
|
|
224
|
+
getMantaZkAssets(chain) {
|
|
225
|
+
const result = {};
|
|
226
|
+
Object.values(this.getAssetRegistry()).forEach(chainAsset => {
|
|
227
|
+
if (chainAsset.originChain === chain && _isAssetFungibleToken(chainAsset) && chainAsset.symbol.startsWith(_ZK_ASSET_PREFIX)) {
|
|
228
|
+
result[chainAsset.slug] = chainAsset;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
215
233
|
getFungibleTokensByChain(chainSlug, checkActive = false) {
|
|
216
234
|
const result = {};
|
|
217
235
|
const assetSettings = this.assetSettingSubject.value;
|
|
@@ -399,11 +417,21 @@ export class ChainService {
|
|
|
399
417
|
}
|
|
400
418
|
};
|
|
401
419
|
if (chainInfo.substrateInfo !== null && chainInfo.substrateInfo !== undefined) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
420
|
+
if (_MANTA_ZK_CHAIN_GROUP.includes(chainInfo.slug)) {
|
|
421
|
+
const apiPromise = await this.mantaChainHandler.initMantaPay(endpoint, chainInfo.slug);
|
|
422
|
+
const chainApi = await this.substrateChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
423
|
+
providerName,
|
|
424
|
+
externalApiPromise: apiPromise,
|
|
425
|
+
onUpdateStatus
|
|
426
|
+
});
|
|
427
|
+
this.substrateChainHandler.setSubstrateApi(chainInfo.slug, chainApi);
|
|
428
|
+
} else {
|
|
429
|
+
const chainApi = await this.substrateChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
430
|
+
providerName,
|
|
431
|
+
onUpdateStatus
|
|
432
|
+
});
|
|
433
|
+
this.substrateChainHandler.setSubstrateApi(chainInfo.slug, chainApi);
|
|
434
|
+
}
|
|
407
435
|
}
|
|
408
436
|
if (chainInfo.evmInfo !== null && chainInfo.evmInfo !== undefined) {
|
|
409
437
|
const chainApi = await this.evmChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
@@ -1161,6 +1189,27 @@ export class ChainService {
|
|
|
1161
1189
|
});
|
|
1162
1190
|
this.store.set('AssetSetting', assetSettings);
|
|
1163
1191
|
}
|
|
1192
|
+
setMantaZkAssetSettings(visible) {
|
|
1193
|
+
const zkAssetSettings = {};
|
|
1194
|
+
Object.values(this.dataMap.assetRegistry).forEach(asset => {
|
|
1195
|
+
if (_isMantaZkAsset(asset)) {
|
|
1196
|
+
zkAssetSettings[asset.slug] = {
|
|
1197
|
+
visible
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
this.store.get('AssetSetting', storedAssetSettings => {
|
|
1202
|
+
const newAssetSettings = {
|
|
1203
|
+
...storedAssetSettings,
|
|
1204
|
+
...zkAssetSettings
|
|
1205
|
+
};
|
|
1206
|
+
this.store.set('AssetSetting', newAssetSettings);
|
|
1207
|
+
this.assetSettingSubject.next(newAssetSettings);
|
|
1208
|
+
Object.keys(zkAssetSettings).forEach(slug => {
|
|
1209
|
+
this.eventService.emit('asset.updateState', slug);
|
|
1210
|
+
});
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1164
1213
|
async getStoreAssetSettings() {
|
|
1165
1214
|
return new Promise(resolve => {
|
|
1166
1215
|
this.store.get('AssetSetting', resolve);
|
|
@@ -63,3 +63,6 @@ export declare function _isAssetFungibleToken(chainAsset: _ChainAsset): boolean;
|
|
|
63
63
|
export declare function _getCrowdloanUrlFromChain(chainInfo: _ChainInfo): string;
|
|
64
64
|
export declare function _isCustomProvider(providerKey: string): boolean;
|
|
65
65
|
export declare function _generateCustomProviderKey(index: number): string;
|
|
66
|
+
export declare const findChainInfoByHalfGenesisHash: (chainMap: Record<string, _ChainInfo>, halfGenesisHash?: string) => _ChainInfo | null;
|
|
67
|
+
export declare const findChainInfoByChainId: (chainMap: Record<string, _ChainInfo>, chainId?: number) => _ChainInfo | null;
|
|
68
|
+
export declare function _isMantaZkAsset(chainAsset: _ChainAsset): boolean;
|