@subwallet/extension-base 1.0.4-0 → 1.0.5-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 +37 -16
- package/background/KoniTypes.js +2 -0
- package/background/errors/TransactionError.js +4 -0
- package/background/handlers/State.d.ts +1 -1
- package/background/handlers/State.js +2 -8
- package/background/handlers/subscriptions.js +0 -1
- package/background/types.d.ts +2 -2
- package/cjs/background/KoniTypes.js +2 -0
- package/cjs/background/errors/TransactionError.js +4 -0
- package/cjs/background/handlers/State.js +1 -7
- package/cjs/background/handlers/subscriptions.js +0 -1
- package/cjs/constants/index.js +6 -6
- package/cjs/koni/api/coingecko.js +1 -4
- package/cjs/koni/api/dotsama/balance.js +7 -5
- package/cjs/koni/api/dotsama/crowdloan.js +0 -4
- package/cjs/koni/api/dotsama/transfer.js +0 -4
- package/cjs/koni/api/nft/acala_nft/index.js +1 -1
- package/cjs/koni/api/nft/bit.country/index.js +1 -1
- package/cjs/koni/api/nft/evm_nft/index.js +2 -3
- package/cjs/koni/api/nft/index.js +1 -2
- package/cjs/koni/api/nft/karura_nft/index.js +1 -1
- package/cjs/koni/api/nft/quartz_nft/index.js +1 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +2 -3
- package/cjs/koni/api/nft/statemine_nft/index.js +1 -1
- package/cjs/koni/api/nft/transfer.js +5 -5
- package/cjs/koni/api/nft/unique_nft/index.js +1 -1
- package/cjs/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +1 -2
- package/cjs/koni/api/staking/bonding/amplitude.js +9 -2
- package/cjs/koni/api/staking/bonding/astar.js +37 -13
- package/cjs/koni/api/staking/bonding/paraChain.js +10 -2
- package/cjs/koni/api/staking/bonding/relayChain.js +21 -4
- package/cjs/koni/api/staking/bonding/utils.js +4 -0
- package/cjs/koni/api/staking/relayChain.js +0 -1
- package/cjs/koni/api/staking/subsquidStaking.js +0 -2
- package/cjs/koni/api/tokens/wasm/index.js +0 -1
- package/cjs/koni/api/tokens/wasm/utils.js +0 -1
- package/cjs/koni/api/xcm/index.js +0 -1
- package/cjs/koni/background/cron.js +0 -45
- package/cjs/koni/background/handlers/Extension.js +204 -132
- package/cjs/koni/background/handlers/State.js +30 -3
- package/cjs/koni/background/handlers/Tabs.js +34 -2
- package/cjs/koni/background/handlers/index.js +3 -2
- package/cjs/koni/background/subscription.js +0 -26
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +1 -1
- package/cjs/services/chain-service/handler/EvmChainHandler.js +1 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +3 -10
- package/cjs/services/chain-service/handler/light-client/index.js +9 -6
- package/cjs/services/chain-service/index.js +75 -28
- package/cjs/services/chain-service/utils.js +3 -0
- package/cjs/services/history-service/helpers/recoverHistoryStatus.js +108 -0
- package/cjs/services/history-service/index.js +60 -5
- package/cjs/services/history-service/subsquid-multi-chain-history.js +3 -2
- package/cjs/services/history-service/testChainMap.js +724 -0
- package/cjs/services/keyring-service/index.js +9 -2
- package/cjs/services/migration-service/index.js +7 -7
- package/cjs/services/migration-service/scripts/MigrateAuthUrls.js +39 -0
- package/cjs/services/migration-service/scripts/MigrateAutoLock.js +30 -0
- package/cjs/services/migration-service/scripts/MigrateChainPatrol.js +30 -0
- package/cjs/services/migration-service/scripts/index.js +7 -1
- package/cjs/services/price-service/coingecko.js +1 -1
- package/cjs/services/price-service/index.js +0 -4
- package/cjs/services/request-service/handler/AuthRequestHandler.js +8 -1
- package/cjs/services/request-service/handler/EvmRequestHandler.js +21 -0
- package/cjs/services/request-service/handler/MetadataRequestHandler.js +6 -0
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +6 -0
- package/cjs/services/request-service/index.js +6 -0
- package/cjs/services/setting-service/SettingService.js +4 -9
- package/cjs/services/setting-service/constants.js +18 -2
- package/cjs/services/storage-service/DatabaseService.js +16 -44
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStore.js +3 -0
- package/cjs/services/transaction-service/constants.js +11 -0
- package/cjs/services/transaction-service/index.js +31 -9
- package/cjs/services/transaction-service/utils.js +25 -14
- package/constants/index.d.ts +1 -1
- package/constants/index.js +1 -1
- package/koni/api/coingecko.js +1 -4
- package/koni/api/dotsama/balance.js +7 -5
- package/koni/api/dotsama/crowdloan.js +0 -4
- package/koni/api/dotsama/transfer.js +0 -4
- package/koni/api/nft/acala_nft/index.js +1 -1
- package/koni/api/nft/bit.country/index.js +1 -1
- package/koni/api/nft/evm_nft/index.js +2 -3
- package/koni/api/nft/index.js +1 -2
- package/koni/api/nft/karura_nft/index.js +1 -1
- package/koni/api/nft/quartz_nft/index.js +1 -1
- package/koni/api/nft/rmrk_nft/index.js +2 -3
- package/koni/api/nft/statemine_nft/index.js +1 -1
- package/koni/api/nft/transfer.js +5 -5
- package/koni/api/nft/unique_nft/index.js +1 -1
- package/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
- package/koni/api/nft/wasm_nft/index.js +1 -2
- package/koni/api/staking/bonding/amplitude.js +9 -2
- package/koni/api/staking/bonding/astar.d.ts +2 -1
- package/koni/api/staking/bonding/astar.js +36 -13
- package/koni/api/staking/bonding/paraChain.js +10 -2
- package/koni/api/staking/bonding/relayChain.js +21 -4
- package/koni/api/staking/bonding/utils.js +4 -0
- package/koni/api/staking/relayChain.js +0 -1
- package/koni/api/staking/subsquidStaking.js +0 -2
- package/koni/api/tokens/wasm/index.js +0 -1
- package/koni/api/tokens/wasm/utils.js +0 -1
- package/koni/api/xcm/index.js +0 -1
- package/koni/background/cron.js +0 -45
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +120 -51
- package/koni/background/handlers/State.d.ts +4 -1
- package/koni/background/handlers/State.js +30 -3
- package/koni/background/handlers/Tabs.d.ts +1 -0
- package/koni/background/handlers/Tabs.js +32 -1
- package/koni/background/handlers/index.js +3 -2
- package/koni/background/subscription.d.ts +0 -1
- package/koni/background/subscription.js +0 -26
- package/package.json +65 -39
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.js +1 -1
- package/services/chain-service/handler/EvmChainHandler.js +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +3 -10
- package/services/chain-service/handler/light-client/index.js +8 -6
- package/services/chain-service/helper/api-helper/spec/acala.d.ts +3 -3
- package/services/chain-service/index.d.ts +2 -1
- package/services/chain-service/index.js +75 -28
- package/services/chain-service/utils.js +3 -0
- package/services/history-service/helpers/recoverHistoryStatus.d.ts +11 -0
- package/services/history-service/helpers/recoverHistoryStatus.js +98 -0
- package/services/history-service/index.d.ts +6 -0
- package/services/history-service/index.js +61 -6
- package/services/history-service/subsquid-multi-chain-history.js +3 -2
- package/services/history-service/testChainMap.d.ts +3 -0
- package/services/history-service/testChainMap.js +716 -0
- package/services/keyring-service/index.d.ts +1 -0
- package/services/keyring-service/index.js +9 -2
- package/services/migration-service/index.js +7 -7
- package/services/migration-service/scripts/MigrateAuthUrls.d.ts +4 -0
- package/services/migration-service/scripts/MigrateAuthUrls.js +31 -0
- package/services/migration-service/scripts/MigrateAutoLock.d.ts +4 -0
- package/services/migration-service/scripts/MigrateAutoLock.js +22 -0
- package/services/migration-service/scripts/MigrateChainPatrol.d.ts +4 -0
- package/services/migration-service/scripts/MigrateChainPatrol.js +22 -0
- package/services/migration-service/scripts/index.js +7 -1
- package/services/price-service/coingecko.js +1 -1
- package/services/price-service/index.js +0 -4
- package/services/request-service/handler/AuthRequestHandler.d.ts +1 -0
- package/services/request-service/handler/AuthRequestHandler.js +8 -1
- package/services/request-service/handler/EvmRequestHandler.d.ts +1 -0
- package/services/request-service/handler/EvmRequestHandler.js +21 -0
- package/services/request-service/handler/MetadataRequestHandler.d.ts +1 -0
- package/services/request-service/handler/MetadataRequestHandler.js +6 -0
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -0
- package/services/request-service/handler/SubstrateRequestHandler.js +6 -0
- package/services/request-service/index.d.ts +1 -0
- package/services/request-service/index.js +6 -0
- package/services/setting-service/SettingService.d.ts +1 -0
- package/services/setting-service/SettingService.js +5 -10
- package/services/setting-service/constants.d.ts +4 -1
- package/services/setting-service/constants.js +14 -1
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +16 -44
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStore.d.ts +1 -0
- package/services/storage-service/db-stores/BaseStore.js +3 -0
- package/services/transaction-service/constants.d.ts +1 -0
- package/services/transaction-service/constants.js +4 -0
- package/services/transaction-service/index.d.ts +2 -0
- package/services/transaction-service/index.js +32 -10
- package/services/transaction-service/utils.d.ts +1 -1
- package/services/transaction-service/utils.js +24 -13
|
@@ -24,6 +24,7 @@ var _wasm = require("@subwallet/extension-base/koni/api/tokens/wasm");
|
|
|
24
24
|
var _xcm = require("@subwallet/extension-base/koni/api/xcm");
|
|
25
25
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
26
26
|
var _constants2 = require("@subwallet/extension-base/services/request-service/constants");
|
|
27
|
+
var _constants3 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
27
28
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
28
29
|
var _address2 = require("@subwallet/extension-base/utils/address");
|
|
29
30
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
@@ -65,8 +66,20 @@ const ACCOUNT_ALL_JSON = {
|
|
|
65
66
|
class KoniExtension {
|
|
66
67
|
#lockTimeOut = undefined;
|
|
67
68
|
#koniState;
|
|
69
|
+
#timeAutoLock = _constants3.DEFAULT_AUTO_LOCK_TIME;
|
|
68
70
|
constructor(state) {
|
|
69
71
|
this.#koniState = state;
|
|
72
|
+
const updateTimeAutoLock = rs => {
|
|
73
|
+
this.#timeAutoLock = rs.timeAutoLock;
|
|
74
|
+
clearTimeout(this.#lockTimeOut);
|
|
75
|
+
this.#lockTimeOut = setTimeout(() => {
|
|
76
|
+
this.keyringLock();
|
|
77
|
+
}, this.#timeAutoLock * 60 * 1000);
|
|
78
|
+
};
|
|
79
|
+
this.#koniState.settingService.getSettings(updateTimeAutoLock);
|
|
80
|
+
this.#koniState.settingService.getSubject().subscribe({
|
|
81
|
+
next: updateTimeAutoLock
|
|
82
|
+
});
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
/// Clone from PolkadotJs
|
|
@@ -352,7 +365,6 @@ class KoniExtension {
|
|
|
352
365
|
windowOpen(path) {
|
|
353
366
|
const url = `${chrome.extension.getURL('index.html')}#${path}`;
|
|
354
367
|
if (!_defaults.ALLOWED_PATH.includes(path)) {
|
|
355
|
-
console.error('Not allowed to open the url:', url);
|
|
356
368
|
return false;
|
|
357
369
|
}
|
|
358
370
|
(0, _helpers.withErrorLog)(() => chrome.tabs.create({
|
|
@@ -747,7 +759,6 @@ class KoniExtension {
|
|
|
747
759
|
(0, _util.assert)(value, 'The source is not known');
|
|
748
760
|
if (this.isAddressValidWithAuthType(address, value[url].accountAuthType)) {
|
|
749
761
|
value[url].isAllowedMap[address] = connectValue;
|
|
750
|
-
console.log('Devbu: ', value);
|
|
751
762
|
this.#koniState.setAuthorize(value, () => {
|
|
752
763
|
callBack && callBack(value);
|
|
753
764
|
});
|
|
@@ -760,7 +771,6 @@ class KoniExtension {
|
|
|
760
771
|
this.#koniState.getAuthorize(value => {
|
|
761
772
|
(0, _util.assert)(value, 'The source is not known');
|
|
762
773
|
value[id].isAllowed = connectValue;
|
|
763
|
-
console.log('Devbu: ', value);
|
|
764
774
|
this.#koniState.setAuthorize(value);
|
|
765
775
|
});
|
|
766
776
|
}
|
|
@@ -768,7 +778,6 @@ class KoniExtension {
|
|
|
768
778
|
this.#koniState.getAuthorize(value => {
|
|
769
779
|
(0, _util.assert)(value, 'The source is not known');
|
|
770
780
|
value[id].isAllowedMap = values;
|
|
771
|
-
console.log('Devbu: ', value);
|
|
772
781
|
this.#koniState.setAuthorize(value);
|
|
773
782
|
});
|
|
774
783
|
}
|
|
@@ -797,22 +806,18 @@ class KoniExtension {
|
|
|
797
806
|
});
|
|
798
807
|
});
|
|
799
808
|
}
|
|
800
|
-
toggleBalancesVisibility(
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
809
|
+
async toggleBalancesVisibility() {
|
|
810
|
+
return new Promise(resolve => {
|
|
811
|
+
this.#koniState.getSettings(value => {
|
|
812
|
+
const updateValue = {
|
|
813
|
+
...value,
|
|
814
|
+
isShowBalance: !value.isShowBalance
|
|
815
|
+
};
|
|
816
|
+
this.#koniState.setSettings(updateValue, () => {
|
|
817
|
+
resolve(!value.isShowBalance);
|
|
818
|
+
});
|
|
810
819
|
});
|
|
811
820
|
});
|
|
812
|
-
port.onDisconnect.addListener(() => {
|
|
813
|
-
this.cancelSubscription(id);
|
|
814
|
-
});
|
|
815
|
-
return true;
|
|
816
821
|
}
|
|
817
822
|
saveAccountAllLogo(data, id, port) {
|
|
818
823
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
@@ -854,6 +859,13 @@ class KoniExtension {
|
|
|
854
859
|
});
|
|
855
860
|
return true;
|
|
856
861
|
}
|
|
862
|
+
setAutoLockTime(_ref28) {
|
|
863
|
+
let {
|
|
864
|
+
autoLockTime
|
|
865
|
+
} = _ref28;
|
|
866
|
+
this.#koniState.setAutoLockTime(autoLockTime);
|
|
867
|
+
return true;
|
|
868
|
+
}
|
|
857
869
|
async subscribeSettings(id, port) {
|
|
858
870
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
859
871
|
const balancesVisibilitySubscription = this.#koniState.subscribeSettingsSubject().subscribe({
|
|
@@ -867,6 +879,13 @@ class KoniExtension {
|
|
|
867
879
|
});
|
|
868
880
|
return await this.getSettings();
|
|
869
881
|
}
|
|
882
|
+
setEnableChainPatrol(_ref29) {
|
|
883
|
+
let {
|
|
884
|
+
enable
|
|
885
|
+
} = _ref29;
|
|
886
|
+
this.#koniState.setEnableChainPatrol(enable);
|
|
887
|
+
return true;
|
|
888
|
+
}
|
|
870
889
|
async subscribeAuthUrls(id, port) {
|
|
871
890
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
872
891
|
const authorizeUrlSubscription = this.#koniState.subscribeAuthorizeUrlSubject().subscribe({
|
|
@@ -930,11 +949,11 @@ class KoniExtension {
|
|
|
930
949
|
}
|
|
931
950
|
async updateAssetSetting(params) {
|
|
932
951
|
try {
|
|
933
|
-
await this.#koniState.chainService.updateAssetSetting(params.tokenSlug, params.assetSetting);
|
|
952
|
+
await this.#koniState.chainService.updateAssetSetting(params.tokenSlug, params.assetSetting, params.autoEnableNativeToken);
|
|
934
953
|
this.#koniState.eventService.emit('asset.updateState', params.tokenSlug);
|
|
935
954
|
return true;
|
|
936
955
|
} catch (e) {
|
|
937
|
-
console.error(
|
|
956
|
+
console.error(e);
|
|
938
957
|
return false;
|
|
939
958
|
}
|
|
940
959
|
}
|
|
@@ -1039,7 +1058,7 @@ class KoniExtension {
|
|
|
1039
1058
|
}
|
|
1040
1059
|
});
|
|
1041
1060
|
}
|
|
1042
|
-
async accountsCreateSuriV2(
|
|
1061
|
+
async accountsCreateSuriV2(_ref30) {
|
|
1043
1062
|
let {
|
|
1044
1063
|
genesisHash,
|
|
1045
1064
|
isAllowed,
|
|
@@ -1047,7 +1066,7 @@ class KoniExtension {
|
|
|
1047
1066
|
password,
|
|
1048
1067
|
suri: _suri,
|
|
1049
1068
|
types
|
|
1050
|
-
} =
|
|
1069
|
+
} = _ref30;
|
|
1051
1070
|
const addressDict = {};
|
|
1052
1071
|
let changedAccount = false;
|
|
1053
1072
|
const hasMasterPassword = _uiKeyring.keyring.keyring.hasMasterPassword;
|
|
@@ -1095,10 +1114,10 @@ class KoniExtension {
|
|
|
1095
1114
|
});
|
|
1096
1115
|
return addressDict;
|
|
1097
1116
|
}
|
|
1098
|
-
async accountsForgetOverride(
|
|
1117
|
+
async accountsForgetOverride(_ref31) {
|
|
1099
1118
|
let {
|
|
1100
1119
|
address
|
|
1101
|
-
} =
|
|
1120
|
+
} = _ref31;
|
|
1102
1121
|
_uiKeyring.keyring.forgetAccount(address);
|
|
1103
1122
|
await new Promise(resolve => {
|
|
1104
1123
|
this.#koniState.removeAccountRef(address, () => {
|
|
@@ -1130,12 +1149,12 @@ class KoniExtension {
|
|
|
1130
1149
|
});
|
|
1131
1150
|
return true;
|
|
1132
1151
|
}
|
|
1133
|
-
seedCreateV2(
|
|
1152
|
+
seedCreateV2(_ref32) {
|
|
1134
1153
|
let {
|
|
1135
1154
|
length = _Extension.SEED_DEFAULT_LENGTH,
|
|
1136
1155
|
seed: _seed,
|
|
1137
1156
|
types
|
|
1138
|
-
} =
|
|
1157
|
+
} = _ref32;
|
|
1139
1158
|
const seed = _seed || (0, _utilCrypto.mnemonicGenerate)(length);
|
|
1140
1159
|
const rs = {
|
|
1141
1160
|
seed: seed,
|
|
@@ -1146,11 +1165,11 @@ class KoniExtension {
|
|
|
1146
1165
|
});
|
|
1147
1166
|
return rs;
|
|
1148
1167
|
}
|
|
1149
|
-
seedValidateV2(
|
|
1168
|
+
seedValidateV2(_ref33) {
|
|
1150
1169
|
let {
|
|
1151
1170
|
suri,
|
|
1152
1171
|
types
|
|
1153
|
-
} =
|
|
1172
|
+
} = _ref33;
|
|
1154
1173
|
const {
|
|
1155
1174
|
phrase
|
|
1156
1175
|
} = (0, _utilCrypto.keyExtractSuri)(suri);
|
|
@@ -1170,11 +1189,11 @@ class KoniExtension {
|
|
|
1170
1189
|
});
|
|
1171
1190
|
return rs;
|
|
1172
1191
|
}
|
|
1173
|
-
_checkValidatePrivateKey(
|
|
1192
|
+
_checkValidatePrivateKey(_ref34) {
|
|
1174
1193
|
let {
|
|
1175
1194
|
suri,
|
|
1176
1195
|
types
|
|
1177
|
-
} =
|
|
1196
|
+
} = _ref34;
|
|
1178
1197
|
let autoAddPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1179
1198
|
const {
|
|
1180
1199
|
phrase
|
|
@@ -1197,11 +1216,11 @@ class KoniExtension {
|
|
|
1197
1216
|
}
|
|
1198
1217
|
return rs;
|
|
1199
1218
|
}
|
|
1200
|
-
metamaskPrivateKeyValidateV2(
|
|
1219
|
+
metamaskPrivateKeyValidateV2(_ref35) {
|
|
1201
1220
|
let {
|
|
1202
1221
|
suri,
|
|
1203
1222
|
types
|
|
1204
|
-
} =
|
|
1223
|
+
} = _ref35;
|
|
1205
1224
|
const isValidSuri = suri.startsWith('0x');
|
|
1206
1225
|
if (isValidSuri) {
|
|
1207
1226
|
return this._checkValidatePrivateKey({
|
|
@@ -1226,14 +1245,14 @@ class KoniExtension {
|
|
|
1226
1245
|
throw new Error(`"${suri}" is not a valid derivation path`);
|
|
1227
1246
|
}
|
|
1228
1247
|
}
|
|
1229
|
-
derivationCreateV2(
|
|
1248
|
+
derivationCreateV2(_ref36) {
|
|
1230
1249
|
let {
|
|
1231
1250
|
genesisHash,
|
|
1232
1251
|
isAllowed,
|
|
1233
1252
|
name,
|
|
1234
1253
|
parentAddress,
|
|
1235
1254
|
suri
|
|
1236
|
-
} =
|
|
1255
|
+
} = _ref36;
|
|
1237
1256
|
const childPair = this.deriveV2(parentAddress, suri, {
|
|
1238
1257
|
genesisHash,
|
|
1239
1258
|
name,
|
|
@@ -1247,14 +1266,14 @@ class KoniExtension {
|
|
|
1247
1266
|
});
|
|
1248
1267
|
return true;
|
|
1249
1268
|
}
|
|
1250
|
-
jsonRestoreV2(
|
|
1269
|
+
jsonRestoreV2(_ref37) {
|
|
1251
1270
|
let {
|
|
1252
1271
|
address,
|
|
1253
1272
|
file,
|
|
1254
1273
|
isAllowed,
|
|
1255
1274
|
password,
|
|
1256
1275
|
withMasterPassword
|
|
1257
|
-
} =
|
|
1276
|
+
} = _ref37;
|
|
1258
1277
|
const isPasswordValidated = this.validatePassword(file, password);
|
|
1259
1278
|
if (isPasswordValidated) {
|
|
1260
1279
|
try {
|
|
@@ -1269,13 +1288,13 @@ class KoniExtension {
|
|
|
1269
1288
|
throw new Error('Unable to decode using the supplied passphrase');
|
|
1270
1289
|
}
|
|
1271
1290
|
}
|
|
1272
|
-
batchRestoreV2(
|
|
1291
|
+
batchRestoreV2(_ref38) {
|
|
1273
1292
|
let {
|
|
1274
1293
|
accountsInfo,
|
|
1275
1294
|
file,
|
|
1276
1295
|
isAllowed,
|
|
1277
1296
|
password
|
|
1278
|
-
} =
|
|
1297
|
+
} = _ref38;
|
|
1279
1298
|
const addressList = accountsInfo.map(acc => acc.address);
|
|
1280
1299
|
const isPasswordValidated = this.validatedAccountsPassword(file, password);
|
|
1281
1300
|
if (isPasswordValidated) {
|
|
@@ -1555,11 +1574,11 @@ class KoniExtension {
|
|
|
1555
1574
|
async enableChain(networkKey) {
|
|
1556
1575
|
return await this.#koniState.enableChain(networkKey);
|
|
1557
1576
|
}
|
|
1558
|
-
async validateNetwork(
|
|
1577
|
+
async validateNetwork(_ref39) {
|
|
1559
1578
|
let {
|
|
1560
1579
|
existedChainSlug,
|
|
1561
1580
|
provider
|
|
1562
|
-
} =
|
|
1581
|
+
} = _ref39;
|
|
1563
1582
|
return await this.#koniState.validateCustomChain(provider, existedChainSlug);
|
|
1564
1583
|
}
|
|
1565
1584
|
resetDefaultNetwork() {
|
|
@@ -1569,7 +1588,7 @@ class KoniExtension {
|
|
|
1569
1588
|
try {
|
|
1570
1589
|
return this.#koniState.refreshSubstrateApi(networkKey);
|
|
1571
1590
|
} catch (e) {
|
|
1572
|
-
console.error(
|
|
1591
|
+
console.error(e);
|
|
1573
1592
|
return false;
|
|
1574
1593
|
}
|
|
1575
1594
|
}
|
|
@@ -1578,7 +1597,7 @@ class KoniExtension {
|
|
|
1578
1597
|
await this.#koniState.upsertCustomToken(data);
|
|
1579
1598
|
return true;
|
|
1580
1599
|
} catch (e) {
|
|
1581
|
-
console.error(
|
|
1600
|
+
console.error(e);
|
|
1582
1601
|
return false;
|
|
1583
1602
|
}
|
|
1584
1603
|
}
|
|
@@ -1597,22 +1616,22 @@ class KoniExtension {
|
|
|
1597
1616
|
async validateCustomAsset(data) {
|
|
1598
1617
|
return await this.#koniState.validateCustomAsset(data);
|
|
1599
1618
|
}
|
|
1600
|
-
async getAddressFreeBalance(
|
|
1619
|
+
async getAddressFreeBalance(_ref40) {
|
|
1601
1620
|
let {
|
|
1602
1621
|
address,
|
|
1603
1622
|
networkKey,
|
|
1604
1623
|
token
|
|
1605
|
-
} =
|
|
1624
|
+
} = _ref40;
|
|
1606
1625
|
return await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
|
|
1607
1626
|
}
|
|
1608
|
-
async transferGetMaxTransferable(
|
|
1627
|
+
async transferGetMaxTransferable(_ref41) {
|
|
1609
1628
|
let {
|
|
1610
1629
|
address,
|
|
1611
1630
|
destChain,
|
|
1612
1631
|
isXcmTransfer,
|
|
1613
1632
|
networkKey,
|
|
1614
1633
|
token
|
|
1615
|
-
} =
|
|
1634
|
+
} = _ref41;
|
|
1616
1635
|
const freeBalance = await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
|
|
1617
1636
|
const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
|
|
1618
1637
|
if (!(0, _utils._isNativeToken)(tokenInfo)) {
|
|
@@ -1642,26 +1661,39 @@ class KoniExtension {
|
|
|
1642
1661
|
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
|
|
1643
1662
|
} catch (e) {
|
|
1644
1663
|
estimatedFee = '0';
|
|
1645
|
-
console.warn(
|
|
1664
|
+
console.warn(e);
|
|
1646
1665
|
}
|
|
1647
1666
|
}
|
|
1648
1667
|
} else {
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
networkKey
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1668
|
+
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
1669
|
+
if ((0, _utils._isChainEvmCompatible)(chainInfo)) {
|
|
1670
|
+
const web3 = this.#koniState.chainService.getEvmApi(networkKey);
|
|
1671
|
+
const transaction = {
|
|
1672
|
+
value: 1,
|
|
1673
|
+
to: address,
|
|
1674
|
+
from: address
|
|
1675
|
+
};
|
|
1676
|
+
const gasPrice = await web3.api.eth.getGasPrice();
|
|
1677
|
+
const gasLimit = await web3.api.eth.estimateGas(transaction);
|
|
1678
|
+
estimatedFee = (gasLimit * parseInt(gasPrice)).toString();
|
|
1679
|
+
} else {
|
|
1680
|
+
const [mockTx] = await (0, _transfer.createTransferExtrinsic)({
|
|
1681
|
+
from: address,
|
|
1682
|
+
networkKey,
|
|
1683
|
+
substrateApi,
|
|
1684
|
+
to: address,
|
|
1685
|
+
tokenInfo,
|
|
1686
|
+
transferAll: true,
|
|
1687
|
+
value: '0'
|
|
1688
|
+
});
|
|
1689
|
+
try {
|
|
1690
|
+
var _paymentInfo$partialF2;
|
|
1691
|
+
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
1692
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
1693
|
+
} catch (e) {
|
|
1694
|
+
estimatedFee = '0';
|
|
1695
|
+
console.warn('Error estimating fee', e);
|
|
1696
|
+
}
|
|
1665
1697
|
}
|
|
1666
1698
|
}
|
|
1667
1699
|
maxTransferable = maxTransferable.sub(new _util.BN(estimatedFee));
|
|
@@ -1671,12 +1703,12 @@ class KoniExtension {
|
|
|
1671
1703
|
};
|
|
1672
1704
|
}
|
|
1673
1705
|
}
|
|
1674
|
-
async subscribeAddressFreeBalance(
|
|
1706
|
+
async subscribeAddressFreeBalance(_ref42, id, port) {
|
|
1675
1707
|
let {
|
|
1676
1708
|
address,
|
|
1677
1709
|
networkKey,
|
|
1678
1710
|
token
|
|
1679
|
-
} =
|
|
1711
|
+
} = _ref42;
|
|
1680
1712
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1681
1713
|
const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, cb);
|
|
1682
1714
|
this.createUnsubscriptionHandle(id, unsub);
|
|
@@ -1685,26 +1717,26 @@ class KoniExtension {
|
|
|
1685
1717
|
});
|
|
1686
1718
|
return currentFreeBalance;
|
|
1687
1719
|
}
|
|
1688
|
-
async transferCheckReferenceCount(
|
|
1720
|
+
async transferCheckReferenceCount(_ref43) {
|
|
1689
1721
|
let {
|
|
1690
1722
|
address,
|
|
1691
1723
|
networkKey
|
|
1692
|
-
} =
|
|
1724
|
+
} = _ref43;
|
|
1693
1725
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
|
|
1694
1726
|
return await (0, _transfer.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
|
|
1695
1727
|
}
|
|
1696
|
-
async transferCheckSupporting(
|
|
1728
|
+
async transferCheckSupporting(_ref44) {
|
|
1697
1729
|
let {
|
|
1698
1730
|
networkKey,
|
|
1699
1731
|
tokenSlug
|
|
1700
|
-
} =
|
|
1732
|
+
} = _ref44;
|
|
1701
1733
|
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
1702
1734
|
return await (0, _transfer.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
|
|
1703
1735
|
}
|
|
1704
|
-
transferGetExistentialDeposit(
|
|
1736
|
+
transferGetExistentialDeposit(_ref45) {
|
|
1705
1737
|
let {
|
|
1706
1738
|
tokenSlug
|
|
1707
|
-
} =
|
|
1739
|
+
} = _ref45;
|
|
1708
1740
|
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
1709
1741
|
return (0, _utils._getTokenMinAmount)(tokenInfo);
|
|
1710
1742
|
}
|
|
@@ -1746,24 +1778,24 @@ class KoniExtension {
|
|
|
1746
1778
|
}
|
|
1747
1779
|
return true;
|
|
1748
1780
|
}
|
|
1749
|
-
getAccountMeta(
|
|
1781
|
+
getAccountMeta(_ref46) {
|
|
1750
1782
|
let {
|
|
1751
1783
|
address
|
|
1752
|
-
} =
|
|
1784
|
+
} = _ref46;
|
|
1753
1785
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
1754
1786
|
(0, _util.assert)(pair, 'Unable to find pair');
|
|
1755
1787
|
return {
|
|
1756
1788
|
meta: pair.meta
|
|
1757
1789
|
};
|
|
1758
1790
|
}
|
|
1759
|
-
accountsTie2(
|
|
1791
|
+
accountsTie2(_ref47) {
|
|
1760
1792
|
let {
|
|
1761
1793
|
address,
|
|
1762
1794
|
genesisHash
|
|
1763
|
-
} =
|
|
1795
|
+
} = _ref47;
|
|
1764
1796
|
return this.#koniState.setAccountTie(address, genesisHash);
|
|
1765
1797
|
}
|
|
1766
|
-
async accountsCreateExternalV2(
|
|
1798
|
+
async accountsCreateExternalV2(_ref48) {
|
|
1767
1799
|
let {
|
|
1768
1800
|
address,
|
|
1769
1801
|
genesisHash,
|
|
@@ -1771,7 +1803,7 @@ class KoniExtension {
|
|
|
1771
1803
|
isEthereum,
|
|
1772
1804
|
isReadOnly,
|
|
1773
1805
|
name
|
|
1774
|
-
} =
|
|
1806
|
+
} = _ref48;
|
|
1775
1807
|
try {
|
|
1776
1808
|
let result;
|
|
1777
1809
|
try {
|
|
@@ -1830,7 +1862,7 @@ class KoniExtension {
|
|
|
1830
1862
|
}];
|
|
1831
1863
|
}
|
|
1832
1864
|
}
|
|
1833
|
-
async accountsCreateHardwareV2(
|
|
1865
|
+
async accountsCreateHardwareV2(_ref49) {
|
|
1834
1866
|
let {
|
|
1835
1867
|
accountIndex,
|
|
1836
1868
|
address,
|
|
@@ -1839,7 +1871,7 @@ class KoniExtension {
|
|
|
1839
1871
|
hardwareType,
|
|
1840
1872
|
isAllowed,
|
|
1841
1873
|
name
|
|
1842
|
-
} =
|
|
1874
|
+
} = _ref49;
|
|
1843
1875
|
const key = _uiKeyring.keyring.addHardware(address, hardwareType, {
|
|
1844
1876
|
accountIndex,
|
|
1845
1877
|
addressOffset,
|
|
@@ -1862,10 +1894,10 @@ class KoniExtension {
|
|
|
1862
1894
|
});
|
|
1863
1895
|
return true;
|
|
1864
1896
|
}
|
|
1865
|
-
async accountsCreateHardwareMultiple(
|
|
1897
|
+
async accountsCreateHardwareMultiple(_ref50) {
|
|
1866
1898
|
let {
|
|
1867
1899
|
accounts
|
|
1868
|
-
} =
|
|
1900
|
+
} = _ref50;
|
|
1869
1901
|
const addresses = [];
|
|
1870
1902
|
if (!accounts.length) {
|
|
1871
1903
|
throw new Error('No accounts to import');
|
|
@@ -1916,14 +1948,14 @@ class KoniExtension {
|
|
|
1916
1948
|
});
|
|
1917
1949
|
return true;
|
|
1918
1950
|
}
|
|
1919
|
-
async accountsCreateWithSecret(
|
|
1951
|
+
async accountsCreateWithSecret(_ref51) {
|
|
1920
1952
|
let {
|
|
1921
1953
|
isAllow,
|
|
1922
1954
|
isEthereum,
|
|
1923
1955
|
name,
|
|
1924
1956
|
publicKey,
|
|
1925
1957
|
secretKey
|
|
1926
|
-
} =
|
|
1958
|
+
} = _ref51;
|
|
1927
1959
|
try {
|
|
1928
1960
|
let keyringPair = null;
|
|
1929
1961
|
if (isEthereum) {
|
|
@@ -2066,30 +2098,30 @@ class KoniExtension {
|
|
|
2066
2098
|
|
|
2067
2099
|
// Parse transaction
|
|
2068
2100
|
|
|
2069
|
-
parseSubstrateTransaction(
|
|
2101
|
+
parseSubstrateTransaction(_ref52) {
|
|
2070
2102
|
let {
|
|
2071
2103
|
data,
|
|
2072
2104
|
networkKey
|
|
2073
|
-
} =
|
|
2105
|
+
} = _ref52;
|
|
2074
2106
|
const apiProps = this.#koniState.getSubstrateApi(networkKey);
|
|
2075
2107
|
const apiPromise = apiProps.api;
|
|
2076
2108
|
return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
|
|
2077
2109
|
}
|
|
2078
|
-
async parseEVMRLP(
|
|
2110
|
+
async parseEVMRLP(_ref53) {
|
|
2079
2111
|
let {
|
|
2080
2112
|
data
|
|
2081
|
-
} =
|
|
2113
|
+
} = _ref53;
|
|
2082
2114
|
return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
|
|
2083
2115
|
}
|
|
2084
2116
|
|
|
2085
2117
|
// Sign
|
|
2086
2118
|
|
|
2087
|
-
qrSignSubstrate(
|
|
2119
|
+
qrSignSubstrate(_ref54) {
|
|
2088
2120
|
let {
|
|
2089
2121
|
address,
|
|
2090
2122
|
data,
|
|
2091
2123
|
networkKey
|
|
2092
|
-
} =
|
|
2124
|
+
} = _ref54;
|
|
2093
2125
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
2094
2126
|
(0, _util.assert)(pair, 'Unable to find pair');
|
|
2095
2127
|
if (pair.isLocked) {
|
|
@@ -2106,13 +2138,13 @@ class KoniExtension {
|
|
|
2106
2138
|
signature: signed
|
|
2107
2139
|
};
|
|
2108
2140
|
}
|
|
2109
|
-
async qrSignEVM(
|
|
2141
|
+
async qrSignEVM(_ref55) {
|
|
2110
2142
|
let {
|
|
2111
2143
|
address,
|
|
2112
2144
|
chainId,
|
|
2113
2145
|
message,
|
|
2114
2146
|
type
|
|
2115
|
-
} =
|
|
2147
|
+
} = _ref55;
|
|
2116
2148
|
let signed;
|
|
2117
2149
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2118
2150
|
if (!network) {
|
|
@@ -2193,11 +2225,11 @@ class KoniExtension {
|
|
|
2193
2225
|
});
|
|
2194
2226
|
return this.#koniState.getNominatorMetadata();
|
|
2195
2227
|
}
|
|
2196
|
-
async getBondingOptions(
|
|
2228
|
+
async getBondingOptions(_ref56) {
|
|
2197
2229
|
let {
|
|
2198
2230
|
chain,
|
|
2199
2231
|
type
|
|
2200
|
-
} =
|
|
2232
|
+
} = _ref56;
|
|
2201
2233
|
const apiProps = this.#koniState.getSubstrateApi(chain);
|
|
2202
2234
|
const chainInfo = this.#koniState.getChainInfo(chain);
|
|
2203
2235
|
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
|
|
@@ -2211,7 +2243,6 @@ class KoniExtension {
|
|
|
2211
2243
|
}
|
|
2212
2244
|
async getNominationPoolOptions(chain) {
|
|
2213
2245
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2214
|
-
console.log('chain', chain);
|
|
2215
2246
|
return await (0, _bonding.getNominationPoolsInfo)(chain, substrateApi);
|
|
2216
2247
|
}
|
|
2217
2248
|
async submitBonding(inputData) {
|
|
@@ -2233,7 +2264,6 @@ class KoniExtension {
|
|
|
2233
2264
|
}
|
|
2234
2265
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2235
2266
|
const extrinsic = await (0, _bonding.getBondingExtrinsic)(chainInfo, amount, selectedValidators, substrateApi, address, nominatorMetadata);
|
|
2236
|
-
console.log('Bonding extrinsic: ', chain, extrinsic.toHex());
|
|
2237
2267
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2238
2268
|
address,
|
|
2239
2269
|
chain: chain,
|
|
@@ -2262,7 +2292,6 @@ class KoniExtension {
|
|
|
2262
2292
|
}
|
|
2263
2293
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2264
2294
|
const extrinsic = await (0, _bonding.getUnbondingExtrinsic)(nominatorMetadata, amount, chain, substrateApi, validatorAddress);
|
|
2265
|
-
console.log('Unbonding extrinsic: ', extrinsic.toHex());
|
|
2266
2295
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2267
2296
|
address: nominatorMetadata.address,
|
|
2268
2297
|
chain: chain,
|
|
@@ -2283,7 +2312,6 @@ class KoniExtension {
|
|
|
2283
2312
|
}
|
|
2284
2313
|
const dotSamaApi = this.#koniState.getSubstrateApi(chain);
|
|
2285
2314
|
const extrinsic = await (0, _bonding.getWithdrawalExtrinsic)(dotSamaApi, chain, nominatorMetadata, validatorAddress);
|
|
2286
|
-
console.log('Stake withdrawal extrinsic: ', extrinsic.toHex());
|
|
2287
2315
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2288
2316
|
address: nominatorMetadata.address,
|
|
2289
2317
|
chain: chain,
|
|
@@ -2305,7 +2333,6 @@ class KoniExtension {
|
|
|
2305
2333
|
}
|
|
2306
2334
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2307
2335
|
const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
|
|
2308
|
-
console.log('Staking claim reward extrinsic: ', extrinsic.toHex());
|
|
2309
2336
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2310
2337
|
address,
|
|
2311
2338
|
chain: chain,
|
|
@@ -2326,7 +2353,6 @@ class KoniExtension {
|
|
|
2326
2353
|
}
|
|
2327
2354
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2328
2355
|
const extrinsic = await (0, _bonding.getCancelWithdrawalExtrinsic)(substrateApi, chain, selectedUnstaking);
|
|
2329
|
-
console.log('Cancel stake withdrawal extrinsic', extrinsic.toHex());
|
|
2330
2356
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2331
2357
|
address,
|
|
2332
2358
|
chain,
|
|
@@ -2355,7 +2381,6 @@ class KoniExtension {
|
|
|
2355
2381
|
}
|
|
2356
2382
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2357
2383
|
const extrinsic = await (0, _relayChain.getPoolingBondingExtrinsic)(substrateApi, amount, selectedPool.id, nominatorMetadata);
|
|
2358
|
-
console.log('Join nomination pool extrinsic', extrinsic.toHex());
|
|
2359
2384
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2360
2385
|
address,
|
|
2361
2386
|
chain,
|
|
@@ -2381,7 +2406,6 @@ class KoniExtension {
|
|
|
2381
2406
|
}
|
|
2382
2407
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2383
2408
|
const extrinsic = await (0, _relayChain.getPoolingUnbondingExtrinsic)(substrateApi, amount, nominatorMetadata);
|
|
2384
|
-
console.log('Nomination pool unbond extrinsic', extrinsic.toHex());
|
|
2385
2409
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2386
2410
|
address: nominatorMetadata.address,
|
|
2387
2411
|
chain,
|
|
@@ -2393,12 +2417,12 @@ class KoniExtension {
|
|
|
2393
2417
|
}
|
|
2394
2418
|
|
|
2395
2419
|
// EVM Transaction
|
|
2396
|
-
async parseContractInput(
|
|
2420
|
+
async parseContractInput(_ref57) {
|
|
2397
2421
|
let {
|
|
2398
2422
|
chainId,
|
|
2399
2423
|
contract,
|
|
2400
2424
|
data
|
|
2401
|
-
} =
|
|
2425
|
+
} = _ref57;
|
|
2402
2426
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2403
2427
|
return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
|
|
2404
2428
|
}
|
|
@@ -2451,6 +2475,11 @@ class KoniExtension {
|
|
|
2451
2475
|
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2452
2476
|
});
|
|
2453
2477
|
}
|
|
2478
|
+
|
|
2479
|
+
/// Keyring state
|
|
2480
|
+
|
|
2481
|
+
// Subscribe keyring state
|
|
2482
|
+
|
|
2454
2483
|
keyringStateSubscribe(id, port) {
|
|
2455
2484
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
2456
2485
|
const keyringStateSubject = this.#koniState.keyringService.keyringStateSubject;
|
|
@@ -2461,12 +2490,15 @@ class KoniExtension {
|
|
|
2461
2490
|
});
|
|
2462
2491
|
return this.#koniState.keyringService.keyringState;
|
|
2463
2492
|
}
|
|
2464
|
-
|
|
2493
|
+
|
|
2494
|
+
// Change master password
|
|
2495
|
+
|
|
2496
|
+
keyringChangeMasterPassword(_ref58) {
|
|
2465
2497
|
let {
|
|
2466
2498
|
createNew,
|
|
2467
2499
|
newPassword,
|
|
2468
2500
|
oldPassword
|
|
2469
|
-
} =
|
|
2501
|
+
} = _ref58;
|
|
2470
2502
|
try {
|
|
2471
2503
|
// Remove isMasterPassword meta if createNew
|
|
2472
2504
|
if (createNew) {
|
|
@@ -2497,11 +2529,14 @@ class KoniExtension {
|
|
|
2497
2529
|
errors: []
|
|
2498
2530
|
};
|
|
2499
2531
|
}
|
|
2500
|
-
|
|
2532
|
+
|
|
2533
|
+
// Migrate password
|
|
2534
|
+
|
|
2535
|
+
keyringMigrateMasterPassword(_ref59) {
|
|
2501
2536
|
let {
|
|
2502
2537
|
address,
|
|
2503
2538
|
password
|
|
2504
|
-
} =
|
|
2539
|
+
} = _ref59;
|
|
2505
2540
|
try {
|
|
2506
2541
|
_uiKeyring.keyring.migrateWithMasterPassword(address, password);
|
|
2507
2542
|
} catch (e) {
|
|
@@ -2516,10 +2551,13 @@ class KoniExtension {
|
|
|
2516
2551
|
errors: []
|
|
2517
2552
|
};
|
|
2518
2553
|
}
|
|
2519
|
-
|
|
2554
|
+
|
|
2555
|
+
// Unlock wallet
|
|
2556
|
+
|
|
2557
|
+
keyringUnlock(_ref60) {
|
|
2520
2558
|
let {
|
|
2521
2559
|
password
|
|
2522
|
-
} =
|
|
2560
|
+
} = _ref60;
|
|
2523
2561
|
try {
|
|
2524
2562
|
_uiKeyring.keyring.unlockKeyring(password);
|
|
2525
2563
|
} catch (e) {
|
|
@@ -2534,16 +2572,22 @@ class KoniExtension {
|
|
|
2534
2572
|
errors: []
|
|
2535
2573
|
};
|
|
2536
2574
|
}
|
|
2575
|
+
|
|
2576
|
+
// Lock wallet
|
|
2577
|
+
|
|
2537
2578
|
keyringLock() {
|
|
2538
2579
|
_uiKeyring.keyring.lockAll();
|
|
2539
2580
|
this.#koniState.updateKeyringState();
|
|
2540
2581
|
clearTimeout(this.#lockTimeOut);
|
|
2541
2582
|
}
|
|
2542
|
-
|
|
2583
|
+
|
|
2584
|
+
// Export mnemonic
|
|
2585
|
+
|
|
2586
|
+
keyringExportMnemonic(_ref61) {
|
|
2543
2587
|
let {
|
|
2544
2588
|
address,
|
|
2545
2589
|
password
|
|
2546
|
-
} =
|
|
2590
|
+
} = _ref61;
|
|
2547
2591
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
2548
2592
|
const result = pair.exportMnemonic(password);
|
|
2549
2593
|
return {
|
|
@@ -2551,11 +2595,31 @@ class KoniExtension {
|
|
|
2551
2595
|
};
|
|
2552
2596
|
}
|
|
2553
2597
|
|
|
2598
|
+
// Reset wallet
|
|
2599
|
+
|
|
2600
|
+
async resetWallet(_ref62) {
|
|
2601
|
+
let {
|
|
2602
|
+
resetAll
|
|
2603
|
+
} = _ref62;
|
|
2604
|
+
try {
|
|
2605
|
+
await this.#koniState.resetWallet(resetAll);
|
|
2606
|
+
return {
|
|
2607
|
+
errors: [],
|
|
2608
|
+
status: true
|
|
2609
|
+
};
|
|
2610
|
+
} catch (e) {
|
|
2611
|
+
return {
|
|
2612
|
+
errors: [e.message],
|
|
2613
|
+
status: false
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2554
2618
|
/// Signing external request
|
|
2555
|
-
signingApprovePasswordV2(
|
|
2619
|
+
signingApprovePasswordV2(_ref63) {
|
|
2556
2620
|
let {
|
|
2557
2621
|
id
|
|
2558
|
-
} =
|
|
2622
|
+
} = _ref63;
|
|
2559
2623
|
const queued = this.#koniState.getSignRequest(id);
|
|
2560
2624
|
(0, _util.assert)(queued, 'Unable to find request');
|
|
2561
2625
|
const {
|
|
@@ -2608,22 +2672,22 @@ class KoniExtension {
|
|
|
2608
2672
|
|
|
2609
2673
|
/// Derive account
|
|
2610
2674
|
|
|
2611
|
-
derivationCreateMultiple(
|
|
2675
|
+
derivationCreateMultiple(_ref64) {
|
|
2612
2676
|
let {
|
|
2613
2677
|
isAllowed,
|
|
2614
2678
|
items,
|
|
2615
2679
|
parentAddress
|
|
2616
|
-
} =
|
|
2680
|
+
} = _ref64;
|
|
2617
2681
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2618
2682
|
const isEvm = parentPair.type === 'ethereum';
|
|
2619
2683
|
if (parentPair.isLocked) {
|
|
2620
2684
|
_uiKeyring.keyring.unlockPair(parentPair.address);
|
|
2621
2685
|
}
|
|
2622
|
-
const createChild =
|
|
2686
|
+
const createChild = _ref65 => {
|
|
2623
2687
|
let {
|
|
2624
2688
|
name,
|
|
2625
2689
|
suri
|
|
2626
|
-
} =
|
|
2690
|
+
} = _ref65;
|
|
2627
2691
|
const meta = {
|
|
2628
2692
|
name: name,
|
|
2629
2693
|
parentAddress
|
|
@@ -2656,7 +2720,7 @@ class KoniExtension {
|
|
|
2656
2720
|
this._addAddressToAuthList(address, isAllowed);
|
|
2657
2721
|
result.push(childPair);
|
|
2658
2722
|
} catch (e) {
|
|
2659
|
-
console.log(
|
|
2723
|
+
console.log(e);
|
|
2660
2724
|
}
|
|
2661
2725
|
}
|
|
2662
2726
|
if (result.length === 1) {
|
|
@@ -2669,10 +2733,10 @@ class KoniExtension {
|
|
|
2669
2733
|
}
|
|
2670
2734
|
return true;
|
|
2671
2735
|
}
|
|
2672
|
-
derivationCreateV3(
|
|
2736
|
+
derivationCreateV3(_ref66) {
|
|
2673
2737
|
let {
|
|
2674
2738
|
address: parentAddress
|
|
2675
|
-
} =
|
|
2739
|
+
} = _ref66;
|
|
2676
2740
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2677
2741
|
const isEvm = parentPair.type === 'ethereum';
|
|
2678
2742
|
if (parentPair.isLocked) {
|
|
@@ -2704,11 +2768,11 @@ class KoniExtension {
|
|
|
2704
2768
|
});
|
|
2705
2769
|
return true;
|
|
2706
2770
|
}
|
|
2707
|
-
validateDerivePath(
|
|
2771
|
+
validateDerivePath(_ref67) {
|
|
2708
2772
|
let {
|
|
2709
2773
|
parentAddress,
|
|
2710
2774
|
suri
|
|
2711
|
-
} =
|
|
2775
|
+
} = _ref67;
|
|
2712
2776
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2713
2777
|
const isEvm = parentPair.type === 'ethereum';
|
|
2714
2778
|
if (parentPair.isLocked) {
|
|
@@ -2741,12 +2805,12 @@ class KoniExtension {
|
|
|
2741
2805
|
suri: meta.suri
|
|
2742
2806
|
};
|
|
2743
2807
|
}
|
|
2744
|
-
getListDeriveAccounts(
|
|
2808
|
+
getListDeriveAccounts(_ref68) {
|
|
2745
2809
|
let {
|
|
2746
2810
|
limit,
|
|
2747
2811
|
page,
|
|
2748
2812
|
parentAddress
|
|
2749
|
-
} =
|
|
2813
|
+
} = _ref68;
|
|
2750
2814
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2751
2815
|
const isEvm = parentPair.type === 'ethereum';
|
|
2752
2816
|
if (parentPair.isLocked) {
|
|
@@ -2837,10 +2901,10 @@ class KoniExtension {
|
|
|
2837
2901
|
getSupportedSmartContractTypes() {
|
|
2838
2902
|
return this.#koniState.getSupportedSmartContractTypes();
|
|
2839
2903
|
}
|
|
2840
|
-
getTransaction(
|
|
2904
|
+
getTransaction(_ref69) {
|
|
2841
2905
|
let {
|
|
2842
2906
|
id
|
|
2843
|
-
} =
|
|
2907
|
+
} = _ref69;
|
|
2844
2908
|
const {
|
|
2845
2909
|
transaction,
|
|
2846
2910
|
...transactionResult
|
|
@@ -2850,8 +2914,8 @@ class KoniExtension {
|
|
|
2850
2914
|
subscribeTransactions(id, port) {
|
|
2851
2915
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
2852
2916
|
function convertRs(rs) {
|
|
2853
|
-
return Object.fromEntries(Object.entries(rs).map(
|
|
2854
|
-
let [key, value] =
|
|
2917
|
+
return Object.fromEntries(Object.entries(rs).map(_ref70 => {
|
|
2918
|
+
let [key, value] = _ref70;
|
|
2855
2919
|
const {
|
|
2856
2920
|
transaction,
|
|
2857
2921
|
...transactionResult
|
|
@@ -2881,10 +2945,10 @@ class KoniExtension {
|
|
|
2881
2945
|
});
|
|
2882
2946
|
return notificationSubject.value;
|
|
2883
2947
|
}
|
|
2884
|
-
async reloadCron(
|
|
2948
|
+
async reloadCron(_ref71) {
|
|
2885
2949
|
let {
|
|
2886
2950
|
data
|
|
2887
|
-
} =
|
|
2951
|
+
} = _ref71;
|
|
2888
2952
|
if (data === 'nft') {
|
|
2889
2953
|
return await this.#koniState.reloadNft();
|
|
2890
2954
|
} else if (data === 'staking') {
|
|
@@ -2906,7 +2970,7 @@ class KoniExtension {
|
|
|
2906
2970
|
clearTimeout(this.#lockTimeOut);
|
|
2907
2971
|
this.#lockTimeOut = setTimeout(() => {
|
|
2908
2972
|
this.keyringLock();
|
|
2909
|
-
},
|
|
2973
|
+
}, this.#timeAutoLock * 60 * 1000);
|
|
2910
2974
|
switch (type) {
|
|
2911
2975
|
/// Clone from PolkadotJs
|
|
2912
2976
|
case 'pri(accounts.create.external)':
|
|
@@ -2986,7 +3050,9 @@ class KoniExtension {
|
|
|
2986
3050
|
case 'pri(authorize.toggle)':
|
|
2987
3051
|
return this.toggleAuthorization2(request);
|
|
2988
3052
|
case 'pri(settings.changeBalancesVisibility)':
|
|
2989
|
-
return this.toggleBalancesVisibility(
|
|
3053
|
+
return await this.toggleBalancesVisibility();
|
|
3054
|
+
|
|
3055
|
+
// Settings
|
|
2990
3056
|
case 'pri(settings.subscribe)':
|
|
2991
3057
|
return await this.subscribeSettings(id, port);
|
|
2992
3058
|
case 'pri(settings.saveAccountAllLogo)':
|
|
@@ -2997,6 +3063,10 @@ class KoniExtension {
|
|
|
2997
3063
|
return this.saveTheme(request, id, port);
|
|
2998
3064
|
case 'pri(settings.saveBrowserConfirmationType)':
|
|
2999
3065
|
return this.saveBrowserConfirmationType(request, id, port);
|
|
3066
|
+
case 'pri(settings.saveAutoLockTime)':
|
|
3067
|
+
return this.setAutoLockTime(request);
|
|
3068
|
+
case 'pri(settings.saveEnableChainPatrol)':
|
|
3069
|
+
return this.setEnableChainPatrol(request);
|
|
3000
3070
|
case 'pri(price.getPrice)':
|
|
3001
3071
|
return await this.getPrice();
|
|
3002
3072
|
case 'pri(price.getSubscription)':
|
|
@@ -3232,6 +3302,8 @@ class KoniExtension {
|
|
|
3232
3302
|
return this.keyringLock();
|
|
3233
3303
|
case 'pri(keyring.export.mnemonic)':
|
|
3234
3304
|
return this.keyringExportMnemonic(request);
|
|
3305
|
+
case 'pri(keyring.reset)':
|
|
3306
|
+
return await this.resetWallet(request);
|
|
3235
3307
|
|
|
3236
3308
|
/// Signing external
|
|
3237
3309
|
case 'pri(signing.approve.passwordV2)':
|