@subwallet/extension-base 1.0.2-1b → 1.0.2-3
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 +31 -5
- package/background/KoniTypes.js +2 -1
- package/background/errors/TransactionError.js +4 -0
- package/background/types.d.ts +10 -5
- package/cjs/background/KoniTypes.js +2 -1
- package/cjs/background/errors/TransactionError.js +4 -0
- package/cjs/koni/api/dotsama/transfer.js +6 -12
- package/cjs/koni/api/nft/acala_nft/index.js +7 -10
- package/cjs/koni/api/nft/bit.country/index.js +7 -9
- package/cjs/koni/api/nft/evm_nft/index.js +2 -1
- package/cjs/koni/api/nft/karura_nft/index.js +7 -9
- package/cjs/koni/api/nft/rmrk_nft/index.js +4 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +7 -9
- package/cjs/koni/api/nft/unique_nft/index.js +5 -6
- package/cjs/koni/api/nft/wasm_nft/index.js +2 -1
- package/cjs/koni/api/staking/bonding/relayChain.js +3 -0
- package/cjs/koni/background/cron.js +53 -46
- package/cjs/koni/background/handlers/Extension.js +292 -159
- package/cjs/koni/background/handlers/State.js +24 -14
- package/cjs/koni/background/handlers/Tabs.js +42 -16
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/handler/light-client/index.js +0 -2
- package/cjs/services/chain-service/index.js +53 -38
- package/cjs/services/history-service/index.js +3 -3
- package/cjs/services/history-service/subsquid-multi-chain-history.js +1 -1
- package/cjs/services/keyring-service/index.js +11 -13
- package/cjs/services/request-service/handler/AuthRequestHandler.js +7 -5
- package/cjs/services/request-service/handler/EvmRequestHandler.js +8 -12
- package/cjs/services/request-service/index.js +14 -5
- package/cjs/services/storage-service/DatabaseService.js +8 -5
- package/cjs/services/storage-service/db-stores/Nft.js +9 -4
- package/cjs/services/transaction-service/index.js +3 -1
- package/cjs/utils/address.js +10 -1
- package/cjs/utils/index.js +2 -1
- package/koni/api/dotsama/transfer.js +6 -12
- package/koni/api/nft/acala_nft/index.js +7 -9
- package/koni/api/nft/bit.country/index.js +7 -8
- package/koni/api/nft/evm_nft/index.js +2 -1
- package/koni/api/nft/index.d.ts +1 -1
- package/koni/api/nft/karura_nft/index.js +7 -8
- package/koni/api/nft/nft.d.ts +1 -1
- package/koni/api/nft/rmrk_nft/index.js +4 -1
- package/koni/api/nft/statemine_nft/index.js +7 -8
- package/koni/api/nft/unique_nft/index.js +5 -5
- package/koni/api/nft/wasm_nft/index.js +2 -1
- package/koni/api/staking/bonding/relayChain.js +3 -0
- package/koni/background/cron.js +53 -46
- package/koni/background/handlers/Extension.d.ts +6 -1
- package/koni/background/handlers/Extension.js +203 -73
- package/koni/background/handlers/State.d.ts +1 -1
- package/koni/background/handlers/State.js +26 -14
- package/koni/background/handlers/Tabs.js +42 -16
- package/package.json +13 -13
- package/packageInfo.js +1 -1
- package/services/chain-service/handler/light-client/index.d.ts +1 -17
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/index.d.ts +3 -2
- package/services/chain-service/index.js +47 -33
- package/services/chain-service/types.d.ts +1 -0
- package/services/history-service/index.d.ts +3 -1
- package/services/history-service/index.js +3 -3
- package/services/history-service/subsquid-multi-chain-history.js +1 -1
- package/services/keyring-service/index.d.ts +4 -2
- package/services/keyring-service/index.js +11 -13
- package/services/request-service/handler/AuthRequestHandler.d.ts +3 -1
- package/services/request-service/handler/AuthRequestHandler.js +7 -5
- package/services/request-service/handler/EvmRequestHandler.js +8 -12
- package/services/request-service/index.d.ts +3 -1
- package/services/request-service/index.js +14 -5
- package/services/storage-service/DatabaseService.d.ts +1 -1
- package/services/storage-service/DatabaseService.js +8 -5
- package/services/storage-service/db-stores/Nft.d.ts +2 -1
- package/services/storage-service/db-stores/Nft.js +9 -4
- package/services/transaction-service/index.js +3 -1
- package/utils/address.d.ts +3 -0
- package/utils/address.js +8 -1
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -1
|
@@ -24,11 +24,12 @@ 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 _utils2 = require("@subwallet/extension-base/utils");
|
|
28
|
+
var _address2 = require("@subwallet/extension-base/utils/address");
|
|
27
29
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
28
30
|
var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
29
31
|
var _keyring = require("@subwallet/keyring");
|
|
30
32
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
31
|
-
var _accounts = require("@subwallet/ui-keyring/observable/accounts");
|
|
32
33
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
33
34
|
var _ethereumjsTx = require("ethereumjs-tx");
|
|
34
35
|
var _types = require("@polkadot/types");
|
|
@@ -181,7 +182,8 @@ class KoniExtension {
|
|
|
181
182
|
// FIXME This looks very much like what we have in Tabs
|
|
182
183
|
accountsSubscribe(id, port) {
|
|
183
184
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
184
|
-
const
|
|
185
|
+
const accountSubject = this.#koniState.keyringService.accountSubject;
|
|
186
|
+
const subscription = accountSubject.subscribe(accounts => cb(transformAccounts(accounts)));
|
|
185
187
|
port.onDisconnect.addListener(() => {
|
|
186
188
|
this.cancelSubscription(id);
|
|
187
189
|
subscription.unsubscribe();
|
|
@@ -433,8 +435,7 @@ class KoniExtension {
|
|
|
433
435
|
const keyringService = this.#koniState.keyringService;
|
|
434
436
|
await this.#koniState.eventService.waitAccountReady;
|
|
435
437
|
const currentAccount = keyringService.currentAccount;
|
|
436
|
-
const
|
|
437
|
-
const transformedAccounts = transformAccounts(accountsSubject.value);
|
|
438
|
+
const transformedAccounts = transformAccounts(keyringService.accounts);
|
|
438
439
|
const responseData = {
|
|
439
440
|
accounts: transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [{
|
|
440
441
|
...ACCOUNT_ALL_JSON
|
|
@@ -442,7 +443,7 @@ class KoniExtension {
|
|
|
442
443
|
currentAddress: currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.address,
|
|
443
444
|
currentGenesisHash: currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.currentGenesisHash
|
|
444
445
|
};
|
|
445
|
-
const subscriptionAccounts =
|
|
446
|
+
const subscriptionAccounts = keyringService.accountSubject.subscribe(storedAccounts => {
|
|
446
447
|
const transformedAccounts = transformAccounts(storedAccounts);
|
|
447
448
|
responseData.accounts = transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [{
|
|
448
449
|
...ACCOUNT_ALL_JSON
|
|
@@ -477,26 +478,69 @@ class KoniExtension {
|
|
|
477
478
|
});
|
|
478
479
|
return id;
|
|
479
480
|
}
|
|
480
|
-
|
|
481
|
+
subscribeAddresses(id, port) {
|
|
482
|
+
const _cb = (0, _subscriptions.createSubscription)(id, port);
|
|
483
|
+
const subscription = this.#koniState.keyringService.addressesSubject.subscribe(subjectInfo => {
|
|
484
|
+
const addresses = (0, _address2.convertSubjectInfoToAddresses)(subjectInfo);
|
|
485
|
+
_cb({
|
|
486
|
+
addresses: addresses
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
490
|
+
port.onDisconnect.addListener(() => {
|
|
491
|
+
this.cancelSubscription(id);
|
|
492
|
+
});
|
|
493
|
+
const subjectInfo = this.#koniState.keyringService.addresses;
|
|
494
|
+
return {
|
|
495
|
+
addresses: (0, _address2.convertSubjectInfoToAddresses)(subjectInfo)
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
saveRecentAccount(_ref21) {
|
|
481
499
|
let {
|
|
482
500
|
accountId
|
|
483
501
|
} = _ref21;
|
|
484
|
-
|
|
502
|
+
if ((0, _utilCrypto.isAddress)(accountId)) {
|
|
503
|
+
const address = (0, _utils2.reformatAddress)(accountId);
|
|
504
|
+
const account = _uiKeyring.keyring.getAccount(address);
|
|
505
|
+
const contact = _uiKeyring.keyring.getAddress(address);
|
|
506
|
+
return account || contact || {
|
|
507
|
+
..._uiKeyring.keyring.saveRecent(accountId).json,
|
|
508
|
+
publicKey: (0, _utilCrypto.decodeAddress)(address)
|
|
509
|
+
};
|
|
510
|
+
} else {
|
|
511
|
+
throw Error('Invalid address');
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
editContactAccount(_ref22) {
|
|
515
|
+
let {
|
|
516
|
+
address,
|
|
517
|
+
meta
|
|
518
|
+
} = _ref22;
|
|
519
|
+
if ((0, _utilCrypto.isAddress)(address)) {
|
|
520
|
+
const _address = (0, _utils2.reformatAddress)(address);
|
|
521
|
+
_uiKeyring.keyring.saveAddress(_address, meta);
|
|
522
|
+
return true;
|
|
523
|
+
} else {
|
|
524
|
+
throw Error('Invalid address');
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
deleteContactAccount(_ref23) {
|
|
528
|
+
let {
|
|
529
|
+
address
|
|
530
|
+
} = _ref23;
|
|
531
|
+
if ((0, _utilCrypto.isAddress)(address)) {
|
|
532
|
+
const _address = (0, _utils2.reformatAddress)(address);
|
|
533
|
+
_uiKeyring.keyring.forgetAddress(_address);
|
|
534
|
+
return true;
|
|
535
|
+
} else {
|
|
536
|
+
throw Error('Invalid address');
|
|
537
|
+
}
|
|
485
538
|
}
|
|
486
|
-
|
|
487
|
-
// private triggerAccountsSubscription (): boolean {
|
|
488
|
-
// const accountsSubject = accountsObservable.subject;
|
|
489
|
-
//
|
|
490
|
-
// accountsSubject.next(accountsSubject.getValue());
|
|
491
|
-
//
|
|
492
|
-
// return true;
|
|
493
|
-
// }
|
|
494
|
-
|
|
495
539
|
_getAuthListV2() {
|
|
540
|
+
const keyringService = this.#koniState.keyringService;
|
|
496
541
|
return new Promise((resolve, reject) => {
|
|
497
542
|
this.#koniState.getAuthorize(rs => {
|
|
498
|
-
const
|
|
499
|
-
const addressList = Object.keys(accounts);
|
|
543
|
+
const addressList = Object.keys(keyringService.accounts);
|
|
500
544
|
const urlList = Object.keys(rs);
|
|
501
545
|
if (Object.keys(rs[urlList[0]].isAllowedMap).toString() !== addressList.toString()) {
|
|
502
546
|
urlList.forEach(url => {
|
|
@@ -532,11 +576,11 @@ class KoniExtension {
|
|
|
532
576
|
list: authList
|
|
533
577
|
};
|
|
534
578
|
}
|
|
535
|
-
authorizeApproveV2(
|
|
579
|
+
authorizeApproveV2(_ref24) {
|
|
536
580
|
let {
|
|
537
581
|
accounts,
|
|
538
582
|
id
|
|
539
|
-
} =
|
|
583
|
+
} = _ref24;
|
|
540
584
|
const queued = this.#koniState.getAuthRequestV2(id);
|
|
541
585
|
(0, _util.assert)(queued, 'Unable to find request');
|
|
542
586
|
const {
|
|
@@ -548,10 +592,10 @@ class KoniExtension {
|
|
|
548
592
|
});
|
|
549
593
|
return true;
|
|
550
594
|
}
|
|
551
|
-
authorizeRejectV2(
|
|
595
|
+
authorizeRejectV2(_ref25) {
|
|
552
596
|
let {
|
|
553
597
|
id
|
|
554
|
-
} =
|
|
598
|
+
} = _ref25;
|
|
555
599
|
const queued = this.#koniState.getAuthRequestV2(id);
|
|
556
600
|
(0, _util.assert)(queued, 'Unable to find request');
|
|
557
601
|
const {
|
|
@@ -560,10 +604,10 @@ class KoniExtension {
|
|
|
560
604
|
reject(new Error('Rejected'));
|
|
561
605
|
return true;
|
|
562
606
|
}
|
|
563
|
-
authorizeCancelV2(
|
|
607
|
+
authorizeCancelV2(_ref26) {
|
|
564
608
|
let {
|
|
565
609
|
id
|
|
566
|
-
} =
|
|
610
|
+
} = _ref26;
|
|
567
611
|
const queued = this.#koniState.getAuthRequestV2(id);
|
|
568
612
|
(0, _util.assert)(queued, 'Unable to find request');
|
|
569
613
|
const {
|
|
@@ -613,7 +657,7 @@ class KoniExtension {
|
|
|
613
657
|
return true;
|
|
614
658
|
}
|
|
615
659
|
getNonReadonlyAccounts() {
|
|
616
|
-
const storedAccounts =
|
|
660
|
+
const storedAccounts = this.#koniState.keyringService.accounts;
|
|
617
661
|
const transformedAccounts = transformAccounts(storedAccounts);
|
|
618
662
|
return transformedAccounts.filter(a => !a.isReadOnly).map(a => a.address);
|
|
619
663
|
}
|
|
@@ -795,10 +839,10 @@ class KoniExtension {
|
|
|
795
839
|
});
|
|
796
840
|
return true;
|
|
797
841
|
}
|
|
798
|
-
setCamera(
|
|
842
|
+
setCamera(_ref27) {
|
|
799
843
|
let {
|
|
800
844
|
camera
|
|
801
|
-
} =
|
|
845
|
+
} = _ref27;
|
|
802
846
|
this.#koniState.setCamera(camera);
|
|
803
847
|
return true;
|
|
804
848
|
}
|
|
@@ -995,7 +1039,7 @@ class KoniExtension {
|
|
|
995
1039
|
}
|
|
996
1040
|
});
|
|
997
1041
|
}
|
|
998
|
-
async accountsCreateSuriV2(
|
|
1042
|
+
async accountsCreateSuriV2(_ref28) {
|
|
999
1043
|
let {
|
|
1000
1044
|
genesisHash,
|
|
1001
1045
|
isAllowed,
|
|
@@ -1003,7 +1047,7 @@ class KoniExtension {
|
|
|
1003
1047
|
password,
|
|
1004
1048
|
suri: _suri,
|
|
1005
1049
|
types
|
|
1006
|
-
} =
|
|
1050
|
+
} = _ref28;
|
|
1007
1051
|
const addressDict = {};
|
|
1008
1052
|
let changedAccount = false;
|
|
1009
1053
|
const hasMasterPassword = _uiKeyring.keyring.keyring.hasMasterPassword;
|
|
@@ -1051,10 +1095,10 @@ class KoniExtension {
|
|
|
1051
1095
|
});
|
|
1052
1096
|
return addressDict;
|
|
1053
1097
|
}
|
|
1054
|
-
async accountsForgetOverride(
|
|
1098
|
+
async accountsForgetOverride(_ref29) {
|
|
1055
1099
|
let {
|
|
1056
1100
|
address
|
|
1057
|
-
} =
|
|
1101
|
+
} = _ref29;
|
|
1058
1102
|
_uiKeyring.keyring.forgetAccount(address);
|
|
1059
1103
|
await new Promise(resolve => {
|
|
1060
1104
|
this.#koniState.removeAccountRef(address, () => {
|
|
@@ -1086,12 +1130,12 @@ class KoniExtension {
|
|
|
1086
1130
|
});
|
|
1087
1131
|
return true;
|
|
1088
1132
|
}
|
|
1089
|
-
seedCreateV2(
|
|
1133
|
+
seedCreateV2(_ref30) {
|
|
1090
1134
|
let {
|
|
1091
1135
|
length = _Extension.SEED_DEFAULT_LENGTH,
|
|
1092
1136
|
seed: _seed,
|
|
1093
1137
|
types
|
|
1094
|
-
} =
|
|
1138
|
+
} = _ref30;
|
|
1095
1139
|
const seed = _seed || (0, _utilCrypto.mnemonicGenerate)(length);
|
|
1096
1140
|
const rs = {
|
|
1097
1141
|
seed: seed,
|
|
@@ -1102,11 +1146,11 @@ class KoniExtension {
|
|
|
1102
1146
|
});
|
|
1103
1147
|
return rs;
|
|
1104
1148
|
}
|
|
1105
|
-
seedValidateV2(
|
|
1149
|
+
seedValidateV2(_ref31) {
|
|
1106
1150
|
let {
|
|
1107
1151
|
suri,
|
|
1108
1152
|
types
|
|
1109
|
-
} =
|
|
1153
|
+
} = _ref31;
|
|
1110
1154
|
const {
|
|
1111
1155
|
phrase
|
|
1112
1156
|
} = (0, _utilCrypto.keyExtractSuri)(suri);
|
|
@@ -1126,11 +1170,11 @@ class KoniExtension {
|
|
|
1126
1170
|
});
|
|
1127
1171
|
return rs;
|
|
1128
1172
|
}
|
|
1129
|
-
_checkValidatePrivateKey(
|
|
1173
|
+
_checkValidatePrivateKey(_ref32) {
|
|
1130
1174
|
let {
|
|
1131
1175
|
suri,
|
|
1132
1176
|
types
|
|
1133
|
-
} =
|
|
1177
|
+
} = _ref32;
|
|
1134
1178
|
let autoAddPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1135
1179
|
const {
|
|
1136
1180
|
phrase
|
|
@@ -1153,11 +1197,11 @@ class KoniExtension {
|
|
|
1153
1197
|
}
|
|
1154
1198
|
return rs;
|
|
1155
1199
|
}
|
|
1156
|
-
metamaskPrivateKeyValidateV2(
|
|
1200
|
+
metamaskPrivateKeyValidateV2(_ref33) {
|
|
1157
1201
|
let {
|
|
1158
1202
|
suri,
|
|
1159
1203
|
types
|
|
1160
|
-
} =
|
|
1204
|
+
} = _ref33;
|
|
1161
1205
|
const isValidSuri = suri.startsWith('0x');
|
|
1162
1206
|
if (isValidSuri) {
|
|
1163
1207
|
return this._checkValidatePrivateKey({
|
|
@@ -1182,14 +1226,14 @@ class KoniExtension {
|
|
|
1182
1226
|
throw new Error(`"${suri}" is not a valid derivation path`);
|
|
1183
1227
|
}
|
|
1184
1228
|
}
|
|
1185
|
-
derivationCreateV2(
|
|
1229
|
+
derivationCreateV2(_ref34) {
|
|
1186
1230
|
let {
|
|
1187
1231
|
genesisHash,
|
|
1188
1232
|
isAllowed,
|
|
1189
1233
|
name,
|
|
1190
1234
|
parentAddress,
|
|
1191
1235
|
suri
|
|
1192
|
-
} =
|
|
1236
|
+
} = _ref34;
|
|
1193
1237
|
const childPair = this.deriveV2(parentAddress, suri, {
|
|
1194
1238
|
genesisHash,
|
|
1195
1239
|
name,
|
|
@@ -1203,14 +1247,14 @@ class KoniExtension {
|
|
|
1203
1247
|
});
|
|
1204
1248
|
return true;
|
|
1205
1249
|
}
|
|
1206
|
-
jsonRestoreV2(
|
|
1250
|
+
jsonRestoreV2(_ref35) {
|
|
1207
1251
|
let {
|
|
1208
1252
|
address,
|
|
1209
1253
|
file,
|
|
1210
1254
|
isAllowed,
|
|
1211
1255
|
password,
|
|
1212
1256
|
withMasterPassword
|
|
1213
|
-
} =
|
|
1257
|
+
} = _ref35;
|
|
1214
1258
|
const isPasswordValidated = this.validatePassword(file, password);
|
|
1215
1259
|
if (isPasswordValidated) {
|
|
1216
1260
|
try {
|
|
@@ -1225,13 +1269,13 @@ class KoniExtension {
|
|
|
1225
1269
|
throw new Error('Unable to decode using the supplied passphrase');
|
|
1226
1270
|
}
|
|
1227
1271
|
}
|
|
1228
|
-
batchRestoreV2(
|
|
1272
|
+
batchRestoreV2(_ref36) {
|
|
1229
1273
|
let {
|
|
1230
1274
|
accountsInfo,
|
|
1231
1275
|
file,
|
|
1232
1276
|
isAllowed,
|
|
1233
1277
|
password
|
|
1234
|
-
} =
|
|
1278
|
+
} = _ref36;
|
|
1235
1279
|
const addressList = accountsInfo.map(acc => acc.address);
|
|
1236
1280
|
const isPasswordValidated = this.validatedAccountsPassword(file, password);
|
|
1237
1281
|
if (isPasswordValidated) {
|
|
@@ -1325,6 +1369,14 @@ class KoniExtension {
|
|
|
1325
1369
|
});
|
|
1326
1370
|
return historySubject.getValue();
|
|
1327
1371
|
}
|
|
1372
|
+
addContact(to) {
|
|
1373
|
+
const toAddress = (0, _utils2.reformatAddress)(to);
|
|
1374
|
+
const account = _uiKeyring.keyring.getAccount(toAddress);
|
|
1375
|
+
const contact = _uiKeyring.keyring.getAddress(toAddress);
|
|
1376
|
+
if (!account && (!contact || contact.meta.isRecent)) {
|
|
1377
|
+
_uiKeyring.keyring.saveAddress(toAddress, {});
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1328
1380
|
validateTransfer(tokenSlug, from, to, value, transferAll) {
|
|
1329
1381
|
const errors = [];
|
|
1330
1382
|
const keypair = _uiKeyring.keyring.getPair(from);
|
|
@@ -1398,6 +1450,7 @@ class KoniExtension {
|
|
|
1398
1450
|
});
|
|
1399
1451
|
}
|
|
1400
1452
|
const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
|
|
1453
|
+
this.addContact(to);
|
|
1401
1454
|
return this.#koniState.transactionService.handleTransaction({
|
|
1402
1455
|
errors,
|
|
1403
1456
|
warnings,
|
|
@@ -1450,6 +1503,7 @@ class KoniExtension {
|
|
|
1450
1503
|
substrateApi
|
|
1451
1504
|
});
|
|
1452
1505
|
}
|
|
1506
|
+
this.addContact(to);
|
|
1453
1507
|
return await this.#koniState.transactionService.handleTransaction({
|
|
1454
1508
|
url: _constants2.EXTENSION_REQUEST_URL,
|
|
1455
1509
|
address: from,
|
|
@@ -1459,6 +1513,7 @@ class KoniExtension {
|
|
|
1459
1513
|
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
|
|
1460
1514
|
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
1461
1515
|
transferNativeAmount: (0, _utils._isNativeToken)(originTokenInfo) ? value : '0',
|
|
1516
|
+
isTransferAll: inputData.transferAll,
|
|
1462
1517
|
errors
|
|
1463
1518
|
});
|
|
1464
1519
|
}
|
|
@@ -1472,6 +1527,7 @@ class KoniExtension {
|
|
|
1472
1527
|
const contractAddress = params.contractAddress;
|
|
1473
1528
|
const tokenId = params.tokenId;
|
|
1474
1529
|
const transaction = await (0, _transfer3.getERC721Transaction)(this.#koniState.getEvmApi(networkKey), contractAddress, senderAddress, recipientAddress, tokenId);
|
|
1530
|
+
this.addContact(recipientAddress);
|
|
1475
1531
|
return await this.#koniState.transactionService.handleTransaction({
|
|
1476
1532
|
address: senderAddress,
|
|
1477
1533
|
chain: networkKey,
|
|
@@ -1499,11 +1555,11 @@ class KoniExtension {
|
|
|
1499
1555
|
async enableChain(networkKey) {
|
|
1500
1556
|
return await this.#koniState.enableChain(networkKey);
|
|
1501
1557
|
}
|
|
1502
|
-
async validateNetwork(
|
|
1558
|
+
async validateNetwork(_ref37) {
|
|
1503
1559
|
let {
|
|
1504
1560
|
existedChainSlug,
|
|
1505
1561
|
provider
|
|
1506
|
-
} =
|
|
1562
|
+
} = _ref37;
|
|
1507
1563
|
return await this.#koniState.validateCustomChain(provider, existedChainSlug);
|
|
1508
1564
|
}
|
|
1509
1565
|
resetDefaultNetwork() {
|
|
@@ -1541,20 +1597,86 @@ class KoniExtension {
|
|
|
1541
1597
|
async validateCustomAsset(data) {
|
|
1542
1598
|
return await this.#koniState.validateCustomAsset(data);
|
|
1543
1599
|
}
|
|
1544
|
-
async getAddressFreeBalance(
|
|
1600
|
+
async getAddressFreeBalance(_ref38) {
|
|
1545
1601
|
let {
|
|
1546
1602
|
address,
|
|
1547
1603
|
networkKey,
|
|
1548
1604
|
token
|
|
1549
|
-
} =
|
|
1605
|
+
} = _ref38;
|
|
1550
1606
|
return await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
|
|
1551
1607
|
}
|
|
1552
|
-
async
|
|
1608
|
+
async transferGetMaxTransferable(_ref39) {
|
|
1553
1609
|
let {
|
|
1554
1610
|
address,
|
|
1611
|
+
destChain,
|
|
1612
|
+
isXcmTransfer,
|
|
1555
1613
|
networkKey,
|
|
1556
1614
|
token
|
|
1557
|
-
} =
|
|
1615
|
+
} = _ref39;
|
|
1616
|
+
const freeBalance = await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
|
|
1617
|
+
const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
|
|
1618
|
+
if (!(0, _utils._isNativeToken)(tokenInfo)) {
|
|
1619
|
+
return freeBalance;
|
|
1620
|
+
} else {
|
|
1621
|
+
const substrateApi = this.#koniState.chainService.getSubstrateApi(networkKey);
|
|
1622
|
+
let estimatedFee;
|
|
1623
|
+
let maxTransferable = new _util.BN(freeBalance.value);
|
|
1624
|
+
if (isXcmTransfer) {
|
|
1625
|
+
const chainInfoMap = this.#koniState.chainService.getChainInfoMap();
|
|
1626
|
+
const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destChain, tokenInfo.slug);
|
|
1627
|
+
if (!destinationTokenInfo) {
|
|
1628
|
+
estimatedFee = '0';
|
|
1629
|
+
} else {
|
|
1630
|
+
maxTransferable = maxTransferable.sub(new _util.BN(tokenInfo.minAmount || '0'));
|
|
1631
|
+
const mockTx = await (0, _xcm.createXcmExtrinsic)({
|
|
1632
|
+
chainInfoMap,
|
|
1633
|
+
destinationTokenInfo,
|
|
1634
|
+
originTokenInfo: tokenInfo,
|
|
1635
|
+
recipient: address,
|
|
1636
|
+
sendingValue: '0',
|
|
1637
|
+
substrateApi
|
|
1638
|
+
});
|
|
1639
|
+
try {
|
|
1640
|
+
var _paymentInfo$partialF;
|
|
1641
|
+
const paymentInfo = await mockTx.paymentInfo(address);
|
|
1642
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
|
|
1643
|
+
} catch (e) {
|
|
1644
|
+
estimatedFee = '0';
|
|
1645
|
+
console.warn('Error estimating fee', e);
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
} else {
|
|
1649
|
+
const [mockTx] = await (0, _transfer.createTransferExtrinsic)({
|
|
1650
|
+
from: address,
|
|
1651
|
+
networkKey,
|
|
1652
|
+
substrateApi,
|
|
1653
|
+
to: address,
|
|
1654
|
+
tokenInfo,
|
|
1655
|
+
transferAll: true,
|
|
1656
|
+
value: '0'
|
|
1657
|
+
});
|
|
1658
|
+
try {
|
|
1659
|
+
var _paymentInfo$partialF2;
|
|
1660
|
+
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
1661
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
1662
|
+
} catch (e) {
|
|
1663
|
+
estimatedFee = '0';
|
|
1664
|
+
console.warn('Error estimating fee', e);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
maxTransferable = maxTransferable.sub(new _util.BN(estimatedFee));
|
|
1668
|
+
return {
|
|
1669
|
+
...freeBalance,
|
|
1670
|
+
value: maxTransferable.gt(_util.BN_ZERO) ? maxTransferable.toString() || '0' : '0'
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
async subscribeAddressFreeBalance(_ref40, id, port) {
|
|
1675
|
+
let {
|
|
1676
|
+
address,
|
|
1677
|
+
networkKey,
|
|
1678
|
+
token
|
|
1679
|
+
} = _ref40;
|
|
1558
1680
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1559
1681
|
const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, cb);
|
|
1560
1682
|
this.createUnsubscriptionHandle(id, unsub);
|
|
@@ -1563,26 +1685,26 @@ class KoniExtension {
|
|
|
1563
1685
|
});
|
|
1564
1686
|
return currentFreeBalance;
|
|
1565
1687
|
}
|
|
1566
|
-
async transferCheckReferenceCount(
|
|
1688
|
+
async transferCheckReferenceCount(_ref41) {
|
|
1567
1689
|
let {
|
|
1568
1690
|
address,
|
|
1569
1691
|
networkKey
|
|
1570
|
-
} =
|
|
1692
|
+
} = _ref41;
|
|
1571
1693
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
|
|
1572
1694
|
return await (0, _transfer.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
|
|
1573
1695
|
}
|
|
1574
|
-
async transferCheckSupporting(
|
|
1696
|
+
async transferCheckSupporting(_ref42) {
|
|
1575
1697
|
let {
|
|
1576
1698
|
networkKey,
|
|
1577
1699
|
tokenSlug
|
|
1578
|
-
} =
|
|
1700
|
+
} = _ref42;
|
|
1579
1701
|
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
1580
1702
|
return await (0, _transfer.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
|
|
1581
1703
|
}
|
|
1582
|
-
transferGetExistentialDeposit(
|
|
1704
|
+
transferGetExistentialDeposit(_ref43) {
|
|
1583
1705
|
let {
|
|
1584
1706
|
tokenSlug
|
|
1585
|
-
} =
|
|
1707
|
+
} = _ref43;
|
|
1586
1708
|
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
1587
1709
|
return (0, _utils._getTokenMinAmount)(tokenInfo);
|
|
1588
1710
|
}
|
|
@@ -1599,6 +1721,7 @@ class KoniExtension {
|
|
|
1599
1721
|
const networkKey = params === null || params === void 0 ? void 0 : params.networkKey;
|
|
1600
1722
|
const apiProps = this.#koniState.getSubstrateApi(networkKey);
|
|
1601
1723
|
const extrinsic = !isPSP34 ? (0, _transfer2.getNftTransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {}) : await (0, _wasm.getPSP34TransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {});
|
|
1724
|
+
this.addContact(recipientAddress);
|
|
1602
1725
|
const rs = await this.#koniState.transactionService.handleTransaction({
|
|
1603
1726
|
address: senderAddress,
|
|
1604
1727
|
chain: networkKey,
|
|
@@ -1623,41 +1746,24 @@ class KoniExtension {
|
|
|
1623
1746
|
}
|
|
1624
1747
|
return true;
|
|
1625
1748
|
}
|
|
1626
|
-
getAccountMeta(
|
|
1749
|
+
getAccountMeta(_ref44) {
|
|
1627
1750
|
let {
|
|
1628
1751
|
address
|
|
1629
|
-
} =
|
|
1752
|
+
} = _ref44;
|
|
1630
1753
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
1631
1754
|
(0, _util.assert)(pair, 'Unable to find pair');
|
|
1632
1755
|
return {
|
|
1633
1756
|
meta: pair.meta
|
|
1634
1757
|
};
|
|
1635
1758
|
}
|
|
1636
|
-
|
|
1637
|
-
// private async isInWalletAccount (address?: string) {
|
|
1638
|
-
// return new Promise((resolve) => {
|
|
1639
|
-
// if (address) {
|
|
1640
|
-
// accountsObservable.subject.subscribe((storedAccounts: SubjectInfo): void => {
|
|
1641
|
-
// if (storedAccounts[address]) {
|
|
1642
|
-
// resolve(true);
|
|
1643
|
-
// }
|
|
1644
|
-
//
|
|
1645
|
-
// resolve(false);
|
|
1646
|
-
// });
|
|
1647
|
-
// } else {
|
|
1648
|
-
// resolve(false);
|
|
1649
|
-
// }
|
|
1650
|
-
// });
|
|
1651
|
-
// }
|
|
1652
|
-
|
|
1653
|
-
accountsTie2(_ref42) {
|
|
1759
|
+
accountsTie2(_ref45) {
|
|
1654
1760
|
let {
|
|
1655
1761
|
address,
|
|
1656
1762
|
genesisHash
|
|
1657
|
-
} =
|
|
1763
|
+
} = _ref45;
|
|
1658
1764
|
return this.#koniState.setAccountTie(address, genesisHash);
|
|
1659
1765
|
}
|
|
1660
|
-
async accountsCreateExternalV2(
|
|
1766
|
+
async accountsCreateExternalV2(_ref46) {
|
|
1661
1767
|
let {
|
|
1662
1768
|
address,
|
|
1663
1769
|
genesisHash,
|
|
@@ -1665,7 +1771,7 @@ class KoniExtension {
|
|
|
1665
1771
|
isEthereum,
|
|
1666
1772
|
isReadOnly,
|
|
1667
1773
|
name
|
|
1668
|
-
} =
|
|
1774
|
+
} = _ref46;
|
|
1669
1775
|
try {
|
|
1670
1776
|
let result;
|
|
1671
1777
|
try {
|
|
@@ -1724,7 +1830,7 @@ class KoniExtension {
|
|
|
1724
1830
|
}];
|
|
1725
1831
|
}
|
|
1726
1832
|
}
|
|
1727
|
-
async accountsCreateHardwareV2(
|
|
1833
|
+
async accountsCreateHardwareV2(_ref47) {
|
|
1728
1834
|
let {
|
|
1729
1835
|
accountIndex,
|
|
1730
1836
|
address,
|
|
@@ -1733,7 +1839,7 @@ class KoniExtension {
|
|
|
1733
1839
|
hardwareType,
|
|
1734
1840
|
isAllowed,
|
|
1735
1841
|
name
|
|
1736
|
-
} =
|
|
1842
|
+
} = _ref47;
|
|
1737
1843
|
const key = _uiKeyring.keyring.addHardware(address, hardwareType, {
|
|
1738
1844
|
accountIndex,
|
|
1739
1845
|
addressOffset,
|
|
@@ -1756,10 +1862,10 @@ class KoniExtension {
|
|
|
1756
1862
|
});
|
|
1757
1863
|
return true;
|
|
1758
1864
|
}
|
|
1759
|
-
async accountsCreateHardwareMultiple(
|
|
1865
|
+
async accountsCreateHardwareMultiple(_ref48) {
|
|
1760
1866
|
let {
|
|
1761
1867
|
accounts
|
|
1762
|
-
} =
|
|
1868
|
+
} = _ref48;
|
|
1763
1869
|
const addresses = [];
|
|
1764
1870
|
if (!accounts.length) {
|
|
1765
1871
|
throw new Error('No accounts to import');
|
|
@@ -1810,14 +1916,14 @@ class KoniExtension {
|
|
|
1810
1916
|
});
|
|
1811
1917
|
return true;
|
|
1812
1918
|
}
|
|
1813
|
-
async accountsCreateWithSecret(
|
|
1919
|
+
async accountsCreateWithSecret(_ref49) {
|
|
1814
1920
|
let {
|
|
1815
1921
|
isAllow,
|
|
1816
1922
|
isEthereum,
|
|
1817
1923
|
name,
|
|
1818
1924
|
publicKey,
|
|
1819
1925
|
secretKey
|
|
1820
|
-
} =
|
|
1926
|
+
} = _ref49;
|
|
1821
1927
|
try {
|
|
1822
1928
|
let keyringPair = null;
|
|
1823
1929
|
if (isEthereum) {
|
|
@@ -1960,30 +2066,30 @@ class KoniExtension {
|
|
|
1960
2066
|
|
|
1961
2067
|
// Parse transaction
|
|
1962
2068
|
|
|
1963
|
-
parseSubstrateTransaction(
|
|
2069
|
+
parseSubstrateTransaction(_ref50) {
|
|
1964
2070
|
let {
|
|
1965
2071
|
data,
|
|
1966
2072
|
networkKey
|
|
1967
|
-
} =
|
|
2073
|
+
} = _ref50;
|
|
1968
2074
|
const apiProps = this.#koniState.getSubstrateApi(networkKey);
|
|
1969
2075
|
const apiPromise = apiProps.api;
|
|
1970
2076
|
return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
|
|
1971
2077
|
}
|
|
1972
|
-
async parseEVMRLP(
|
|
2078
|
+
async parseEVMRLP(_ref51) {
|
|
1973
2079
|
let {
|
|
1974
2080
|
data
|
|
1975
|
-
} =
|
|
2081
|
+
} = _ref51;
|
|
1976
2082
|
return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
|
|
1977
2083
|
}
|
|
1978
2084
|
|
|
1979
2085
|
// Sign
|
|
1980
2086
|
|
|
1981
|
-
qrSignSubstrate(
|
|
2087
|
+
qrSignSubstrate(_ref52) {
|
|
1982
2088
|
let {
|
|
1983
2089
|
address,
|
|
1984
2090
|
data,
|
|
1985
2091
|
networkKey
|
|
1986
|
-
} =
|
|
2092
|
+
} = _ref52;
|
|
1987
2093
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
1988
2094
|
(0, _util.assert)(pair, 'Unable to find pair');
|
|
1989
2095
|
if (pair.isLocked) {
|
|
@@ -2000,13 +2106,13 @@ class KoniExtension {
|
|
|
2000
2106
|
signature: signed
|
|
2001
2107
|
};
|
|
2002
2108
|
}
|
|
2003
|
-
async qrSignEVM(
|
|
2109
|
+
async qrSignEVM(_ref53) {
|
|
2004
2110
|
let {
|
|
2005
2111
|
address,
|
|
2006
2112
|
chainId,
|
|
2007
2113
|
message,
|
|
2008
2114
|
type
|
|
2009
|
-
} =
|
|
2115
|
+
} = _ref53;
|
|
2010
2116
|
let signed;
|
|
2011
2117
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2012
2118
|
if (!network) {
|
|
@@ -2087,11 +2193,11 @@ class KoniExtension {
|
|
|
2087
2193
|
});
|
|
2088
2194
|
return this.#koniState.getNominatorMetadata();
|
|
2089
2195
|
}
|
|
2090
|
-
async getBondingOptions(
|
|
2196
|
+
async getBondingOptions(_ref54) {
|
|
2091
2197
|
let {
|
|
2092
2198
|
chain,
|
|
2093
2199
|
type
|
|
2094
|
-
} =
|
|
2200
|
+
} = _ref54;
|
|
2095
2201
|
const apiProps = this.#koniState.getSubstrateApi(chain);
|
|
2096
2202
|
const chainInfo = this.#koniState.getChainInfo(chain);
|
|
2097
2203
|
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
|
|
@@ -2287,12 +2393,12 @@ class KoniExtension {
|
|
|
2287
2393
|
}
|
|
2288
2394
|
|
|
2289
2395
|
// EVM Transaction
|
|
2290
|
-
async parseContractInput(
|
|
2396
|
+
async parseContractInput(_ref55) {
|
|
2291
2397
|
let {
|
|
2292
2398
|
chainId,
|
|
2293
2399
|
contract,
|
|
2294
2400
|
data
|
|
2295
|
-
} =
|
|
2401
|
+
} = _ref55;
|
|
2296
2402
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2297
2403
|
return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
|
|
2298
2404
|
}
|
|
@@ -2355,12 +2461,12 @@ class KoniExtension {
|
|
|
2355
2461
|
});
|
|
2356
2462
|
return this.#koniState.keyringService.keyringState;
|
|
2357
2463
|
}
|
|
2358
|
-
keyringChangeMasterPassword(
|
|
2464
|
+
keyringChangeMasterPassword(_ref56) {
|
|
2359
2465
|
let {
|
|
2360
2466
|
createNew,
|
|
2361
2467
|
newPassword,
|
|
2362
2468
|
oldPassword
|
|
2363
|
-
} =
|
|
2469
|
+
} = _ref56;
|
|
2364
2470
|
try {
|
|
2365
2471
|
// Remove isMasterPassword meta if createNew
|
|
2366
2472
|
if (createNew) {
|
|
@@ -2391,11 +2497,11 @@ class KoniExtension {
|
|
|
2391
2497
|
errors: []
|
|
2392
2498
|
};
|
|
2393
2499
|
}
|
|
2394
|
-
keyringMigrateMasterPassword(
|
|
2500
|
+
keyringMigrateMasterPassword(_ref57) {
|
|
2395
2501
|
let {
|
|
2396
2502
|
address,
|
|
2397
2503
|
password
|
|
2398
|
-
} =
|
|
2504
|
+
} = _ref57;
|
|
2399
2505
|
try {
|
|
2400
2506
|
_uiKeyring.keyring.migrateWithMasterPassword(address, password);
|
|
2401
2507
|
} catch (e) {
|
|
@@ -2410,10 +2516,10 @@ class KoniExtension {
|
|
|
2410
2516
|
errors: []
|
|
2411
2517
|
};
|
|
2412
2518
|
}
|
|
2413
|
-
keyringUnlock(
|
|
2519
|
+
keyringUnlock(_ref58) {
|
|
2414
2520
|
let {
|
|
2415
2521
|
password
|
|
2416
|
-
} =
|
|
2522
|
+
} = _ref58;
|
|
2417
2523
|
try {
|
|
2418
2524
|
_uiKeyring.keyring.unlockKeyring(password);
|
|
2419
2525
|
} catch (e) {
|
|
@@ -2433,11 +2539,11 @@ class KoniExtension {
|
|
|
2433
2539
|
this.#koniState.updateKeyringState();
|
|
2434
2540
|
clearTimeout(this.#lockTimeOut);
|
|
2435
2541
|
}
|
|
2436
|
-
keyringExportMnemonic(
|
|
2542
|
+
keyringExportMnemonic(_ref59) {
|
|
2437
2543
|
let {
|
|
2438
2544
|
address,
|
|
2439
2545
|
password
|
|
2440
|
-
} =
|
|
2546
|
+
} = _ref59;
|
|
2441
2547
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
2442
2548
|
const result = pair.exportMnemonic(password);
|
|
2443
2549
|
return {
|
|
@@ -2446,10 +2552,10 @@ class KoniExtension {
|
|
|
2446
2552
|
}
|
|
2447
2553
|
|
|
2448
2554
|
/// Signing external request
|
|
2449
|
-
signingApprovePasswordV2(
|
|
2555
|
+
signingApprovePasswordV2(_ref60) {
|
|
2450
2556
|
let {
|
|
2451
2557
|
id
|
|
2452
|
-
} =
|
|
2558
|
+
} = _ref60;
|
|
2453
2559
|
const queued = this.#koniState.getSignRequest(id);
|
|
2454
2560
|
(0, _util.assert)(queued, 'Unable to find request');
|
|
2455
2561
|
const {
|
|
@@ -2502,22 +2608,22 @@ class KoniExtension {
|
|
|
2502
2608
|
|
|
2503
2609
|
/// Derive account
|
|
2504
2610
|
|
|
2505
|
-
derivationCreateMultiple(
|
|
2611
|
+
derivationCreateMultiple(_ref61) {
|
|
2506
2612
|
let {
|
|
2507
2613
|
isAllowed,
|
|
2508
2614
|
items,
|
|
2509
2615
|
parentAddress
|
|
2510
|
-
} =
|
|
2616
|
+
} = _ref61;
|
|
2511
2617
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2512
2618
|
const isEvm = parentPair.type === 'ethereum';
|
|
2513
2619
|
if (parentPair.isLocked) {
|
|
2514
2620
|
_uiKeyring.keyring.unlockPair(parentPair.address);
|
|
2515
2621
|
}
|
|
2516
|
-
const createChild =
|
|
2622
|
+
const createChild = _ref62 => {
|
|
2517
2623
|
let {
|
|
2518
2624
|
name,
|
|
2519
2625
|
suri
|
|
2520
|
-
} =
|
|
2626
|
+
} = _ref62;
|
|
2521
2627
|
const meta = {
|
|
2522
2628
|
name: name,
|
|
2523
2629
|
parentAddress
|
|
@@ -2563,10 +2669,10 @@ class KoniExtension {
|
|
|
2563
2669
|
}
|
|
2564
2670
|
return true;
|
|
2565
2671
|
}
|
|
2566
|
-
derivationCreateV3(
|
|
2672
|
+
derivationCreateV3(_ref63) {
|
|
2567
2673
|
let {
|
|
2568
2674
|
address: parentAddress
|
|
2569
|
-
} =
|
|
2675
|
+
} = _ref63;
|
|
2570
2676
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2571
2677
|
const isEvm = parentPair.type === 'ethereum';
|
|
2572
2678
|
if (parentPair.isLocked) {
|
|
@@ -2598,11 +2704,11 @@ class KoniExtension {
|
|
|
2598
2704
|
});
|
|
2599
2705
|
return true;
|
|
2600
2706
|
}
|
|
2601
|
-
validateDerivePath(
|
|
2707
|
+
validateDerivePath(_ref64) {
|
|
2602
2708
|
let {
|
|
2603
2709
|
parentAddress,
|
|
2604
2710
|
suri
|
|
2605
|
-
} =
|
|
2711
|
+
} = _ref64;
|
|
2606
2712
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2607
2713
|
const isEvm = parentPair.type === 'ethereum';
|
|
2608
2714
|
if (parentPair.isLocked) {
|
|
@@ -2635,12 +2741,12 @@ class KoniExtension {
|
|
|
2635
2741
|
suri: meta.suri
|
|
2636
2742
|
};
|
|
2637
2743
|
}
|
|
2638
|
-
getListDeriveAccounts(
|
|
2744
|
+
getListDeriveAccounts(_ref65) {
|
|
2639
2745
|
let {
|
|
2640
2746
|
limit,
|
|
2641
2747
|
page,
|
|
2642
2748
|
parentAddress
|
|
2643
|
-
} =
|
|
2749
|
+
} = _ref65;
|
|
2644
2750
|
const parentPair = _uiKeyring.keyring.getPair(parentAddress);
|
|
2645
2751
|
const isEvm = parentPair.type === 'ethereum';
|
|
2646
2752
|
if (parentPair.isLocked) {
|
|
@@ -2731,10 +2837,10 @@ class KoniExtension {
|
|
|
2731
2837
|
getSupportedSmartContractTypes() {
|
|
2732
2838
|
return this.#koniState.getSupportedSmartContractTypes();
|
|
2733
2839
|
}
|
|
2734
|
-
getTransaction(
|
|
2840
|
+
getTransaction(_ref66) {
|
|
2735
2841
|
let {
|
|
2736
2842
|
id
|
|
2737
|
-
} =
|
|
2843
|
+
} = _ref66;
|
|
2738
2844
|
const {
|
|
2739
2845
|
transaction,
|
|
2740
2846
|
...transactionResult
|
|
@@ -2744,8 +2850,8 @@ class KoniExtension {
|
|
|
2744
2850
|
subscribeTransactions(id, port) {
|
|
2745
2851
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
2746
2852
|
function convertRs(rs) {
|
|
2747
|
-
return Object.fromEntries(Object.entries(rs).map(
|
|
2748
|
-
let [key, value] =
|
|
2853
|
+
return Object.fromEntries(Object.entries(rs).map(_ref67 => {
|
|
2854
|
+
let [key, value] = _ref67;
|
|
2749
2855
|
const {
|
|
2750
2856
|
transaction,
|
|
2751
2857
|
...transactionResult
|
|
@@ -2775,10 +2881,10 @@ class KoniExtension {
|
|
|
2775
2881
|
});
|
|
2776
2882
|
return notificationSubject.value;
|
|
2777
2883
|
}
|
|
2778
|
-
async reloadCron(
|
|
2884
|
+
async reloadCron(_ref68) {
|
|
2779
2885
|
let {
|
|
2780
2886
|
data
|
|
2781
|
-
} =
|
|
2887
|
+
} = _ref68;
|
|
2782
2888
|
if (data === 'nft') {
|
|
2783
2889
|
return await this.#koniState.reloadNft();
|
|
2784
2890
|
} else if (data === 'staking') {
|
|
@@ -2804,8 +2910,6 @@ class KoniExtension {
|
|
|
2804
2910
|
return this.accountsCreateSuri(request);
|
|
2805
2911
|
case 'pri(accounts.changePassword)':
|
|
2806
2912
|
return this.accountsChangePassword(request);
|
|
2807
|
-
case 'pri(accounts.edit)':
|
|
2808
|
-
return this.accountsEdit(request);
|
|
2809
2913
|
case 'pri(accounts.export)':
|
|
2810
2914
|
return this.accountsExport(request);
|
|
2811
2915
|
case 'pri(accounts.show)':
|
|
@@ -2874,38 +2978,6 @@ class KoniExtension {
|
|
|
2874
2978
|
return this.getAuthListV2();
|
|
2875
2979
|
case 'pri(authorize.toggle)':
|
|
2876
2980
|
return this.toggleAuthorization2(request);
|
|
2877
|
-
case 'pri(accounts.create.suriV2)':
|
|
2878
|
-
return await this.accountsCreateSuriV2(request);
|
|
2879
|
-
case 'pri(accounts.forget)':
|
|
2880
|
-
return await this.accountsForgetOverride(request);
|
|
2881
|
-
case 'pri(accounts.create.externalV2)':
|
|
2882
|
-
return await this.accountsCreateExternalV2(request);
|
|
2883
|
-
case 'pri(accounts.create.hardwareV2)':
|
|
2884
|
-
return await this.accountsCreateHardwareV2(request);
|
|
2885
|
-
case 'pri(accounts.create.hardwareMultiple)':
|
|
2886
|
-
return await this.accountsCreateHardwareMultiple(request);
|
|
2887
|
-
case 'pri(accounts.create.withSecret)':
|
|
2888
|
-
return await this.accountsCreateWithSecret(request);
|
|
2889
|
-
case 'pri(seed.createV2)':
|
|
2890
|
-
return this.seedCreateV2(request);
|
|
2891
|
-
case 'pri(seed.validateV2)':
|
|
2892
|
-
return this.seedValidateV2(request);
|
|
2893
|
-
case 'pri(privateKey.validateV2)':
|
|
2894
|
-
return this.metamaskPrivateKeyValidateV2(request);
|
|
2895
|
-
case 'pri(accounts.exportPrivateKey)':
|
|
2896
|
-
return this.accountExportPrivateKey(request);
|
|
2897
|
-
case 'pri(accounts.checkPublicAndSecretKey)':
|
|
2898
|
-
return this.checkPublicAndSecretKey(request);
|
|
2899
|
-
case 'pri(accounts.subscribeWithCurrentAddress)':
|
|
2900
|
-
return await this.accountsGetAllWithCurrentAddress(id, port);
|
|
2901
|
-
case 'pri(accounts.subscribeAccountsInputAddress)':
|
|
2902
|
-
return this.accountsGetAll(id, port);
|
|
2903
|
-
case 'pri(accounts.saveRecent)':
|
|
2904
|
-
return this.saveRecentAccountId(request);
|
|
2905
|
-
case 'pri(currentAccount.saveAddress)':
|
|
2906
|
-
return await this.saveCurrentAccountAddress(request);
|
|
2907
|
-
case 'pri(accounts.updateCurrentAddress)':
|
|
2908
|
-
return this.updateCurrentAccountAddress(request);
|
|
2909
2981
|
case 'pri(settings.changeBalancesVisibility)':
|
|
2910
2982
|
return this.toggleBalancesVisibility(id, port);
|
|
2911
2983
|
case 'pri(settings.subscribe)':
|
|
@@ -2955,6 +3027,65 @@ class KoniExtension {
|
|
|
2955
3027
|
case 'pri(transaction.history.getSubscription)':
|
|
2956
3028
|
return await this.subscribeHistory(id, port);
|
|
2957
3029
|
|
|
3030
|
+
/// Account management
|
|
3031
|
+
// Add account
|
|
3032
|
+
case 'pri(accounts.create.suriV2)':
|
|
3033
|
+
return await this.accountsCreateSuriV2(request);
|
|
3034
|
+
case 'pri(accounts.create.externalV2)':
|
|
3035
|
+
return await this.accountsCreateExternalV2(request);
|
|
3036
|
+
case 'pri(accounts.create.hardwareV2)':
|
|
3037
|
+
return await this.accountsCreateHardwareV2(request);
|
|
3038
|
+
case 'pri(accounts.create.hardwareMultiple)':
|
|
3039
|
+
return await this.accountsCreateHardwareMultiple(request);
|
|
3040
|
+
case 'pri(accounts.create.withSecret)':
|
|
3041
|
+
return await this.accountsCreateWithSecret(request);
|
|
3042
|
+
case 'pri(seed.createV2)':
|
|
3043
|
+
return this.seedCreateV2(request);
|
|
3044
|
+
|
|
3045
|
+
// Remove account
|
|
3046
|
+
case 'pri(accounts.forget)':
|
|
3047
|
+
return await this.accountsForgetOverride(request);
|
|
3048
|
+
|
|
3049
|
+
// Validate account
|
|
3050
|
+
case 'pri(seed.validateV2)':
|
|
3051
|
+
return this.seedValidateV2(request);
|
|
3052
|
+
case 'pri(privateKey.validateV2)':
|
|
3053
|
+
return this.metamaskPrivateKeyValidateV2(request);
|
|
3054
|
+
case 'pri(accounts.checkPublicAndSecretKey)':
|
|
3055
|
+
return this.checkPublicAndSecretKey(request);
|
|
3056
|
+
|
|
3057
|
+
// Export account
|
|
3058
|
+
case 'pri(accounts.exportPrivateKey)':
|
|
3059
|
+
return this.accountExportPrivateKey(request);
|
|
3060
|
+
|
|
3061
|
+
// Subscribe account
|
|
3062
|
+
case 'pri(accounts.subscribeWithCurrentAddress)':
|
|
3063
|
+
return await this.accountsGetAllWithCurrentAddress(id, port);
|
|
3064
|
+
case 'pri(accounts.subscribeAccountsInputAddress)':
|
|
3065
|
+
return this.accountsGetAll(id, port);
|
|
3066
|
+
|
|
3067
|
+
// Save current account
|
|
3068
|
+
case 'pri(currentAccount.saveAddress)':
|
|
3069
|
+
return await this.saveCurrentAccountAddress(request);
|
|
3070
|
+
case 'pri(accounts.updateCurrentAddress)':
|
|
3071
|
+
return this.updateCurrentAccountAddress(request);
|
|
3072
|
+
|
|
3073
|
+
// Edit account
|
|
3074
|
+
case 'pri(accounts.edit)':
|
|
3075
|
+
return this.accountsEdit(request);
|
|
3076
|
+
|
|
3077
|
+
// Save contact address
|
|
3078
|
+
case 'pri(accounts.saveRecent)':
|
|
3079
|
+
return this.saveRecentAccount(request);
|
|
3080
|
+
case 'pri(accounts.editContact)':
|
|
3081
|
+
return this.editContactAccount(request);
|
|
3082
|
+
case 'pri(accounts.deleteContact)':
|
|
3083
|
+
return this.deleteContactAccount(request);
|
|
3084
|
+
|
|
3085
|
+
// Subscribe address
|
|
3086
|
+
case 'pri(accounts.subscribeAddresses)':
|
|
3087
|
+
return this.subscribeAddresses(id, port);
|
|
3088
|
+
|
|
2958
3089
|
// ChainService
|
|
2959
3090
|
case 'pri(chainService.subscribeChainInfoMap)':
|
|
2960
3091
|
return this.subscribeChainInfoMap(id, port);
|
|
@@ -2998,6 +3129,8 @@ class KoniExtension {
|
|
|
2998
3129
|
return await this.transferCheckSupporting(request);
|
|
2999
3130
|
case 'pri(transfer.getExistentialDeposit)':
|
|
3000
3131
|
return this.transferGetExistentialDeposit(request);
|
|
3132
|
+
case 'pri(transfer.getMaxTransferable)':
|
|
3133
|
+
return this.transferGetMaxTransferable(request);
|
|
3001
3134
|
case 'pri(freeBalance.get)':
|
|
3002
3135
|
return this.getAddressFreeBalance(request);
|
|
3003
3136
|
case 'pri(freeBalance.subscribe)':
|
|
@@ -3009,7 +3142,7 @@ class KoniExtension {
|
|
|
3009
3142
|
case 'pri(accounts.get.meta)':
|
|
3010
3143
|
return this.getAccountMeta(request);
|
|
3011
3144
|
|
|
3012
|
-
|
|
3145
|
+
/// Send NFT
|
|
3013
3146
|
case 'pri(evmNft.submitTransaction)':
|
|
3014
3147
|
return this.evmNftSubmitTransaction(request);
|
|
3015
3148
|
case 'pri(substrateNft.submitTransaction)':
|