@subwallet/extension-base 1.0.6-2 → 1.0.7-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +7 -0
- package/cjs/koni/background/handlers/State.js +1 -0
- package/cjs/koni/background/handlers/Tabs.js +68 -19
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/migration-service/index.js +2 -2
- package/cjs/services/request-service/handler/EvmRequestHandler.js +23 -0
- package/cjs/services/request-service/index.js +5 -0
- package/koni/background/handlers/State.js +1 -0
- package/koni/background/handlers/Tabs.js +68 -19
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/types.d.ts +3 -0
- package/services/migration-service/index.js +2 -2
- package/services/request-service/handler/EvmRequestHandler.d.ts +1 -0
- package/services/request-service/handler/EvmRequestHandler.js +21 -0
- package/services/request-service/index.d.ts +1 -0
- package/services/request-service/index.js +3 -0
|
@@ -902,6 +902,11 @@ export interface AddNetworkRequestExternal {
|
|
|
902
902
|
chainName: string;
|
|
903
903
|
blockExplorerUrls?: string[];
|
|
904
904
|
requestId?: string;
|
|
905
|
+
nativeCurrency: {
|
|
906
|
+
name: string;
|
|
907
|
+
symbol: string;
|
|
908
|
+
decimals: number;
|
|
909
|
+
};
|
|
905
910
|
}
|
|
906
911
|
export interface AddNetworkExternalRequest {
|
|
907
912
|
chainId: string;
|
|
@@ -918,6 +923,8 @@ export interface AddTokenRequestExternal {
|
|
|
918
923
|
name: string;
|
|
919
924
|
symbol: string;
|
|
920
925
|
decimals: number;
|
|
926
|
+
validated: boolean;
|
|
927
|
+
contractError: boolean;
|
|
921
928
|
}
|
|
922
929
|
export interface ConfirmationDefinitions {
|
|
923
930
|
addNetworkRequest: [ConfirmationsQueueItem<_NetworkUpsertParams>, ConfirmationResult<null>];
|
|
@@ -14,6 +14,7 @@ var _RequestBytesSign = _interopRequireDefault(require("@subwallet/extension-bas
|
|
|
14
14
|
var _RequestExtrinsicSign = _interopRequireDefault(require("@subwallet/extension-base/background/RequestExtrinsicSign"));
|
|
15
15
|
var _constants = require("@subwallet/extension-base/constants");
|
|
16
16
|
var _defaults = require("@subwallet/extension-base/defaults");
|
|
17
|
+
var _types2 = require("@subwallet/extension-base/services/chain-service/handler/types");
|
|
17
18
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
18
19
|
var _constants2 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
19
20
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
@@ -405,7 +406,7 @@ class KoniTabs {
|
|
|
405
406
|
return null;
|
|
406
407
|
}
|
|
407
408
|
async addEvmToken(id, url, _ref13) {
|
|
408
|
-
var _input$type, _input$options, _input$options2;
|
|
409
|
+
var _input$type, _input$options, _input$options2, _input$options3, _input$options4, _input$options5;
|
|
409
410
|
let {
|
|
410
411
|
params
|
|
411
412
|
} = _ref13;
|
|
@@ -423,28 +424,42 @@ class KoniTabs {
|
|
|
423
424
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, 'Current chain is not available');
|
|
424
425
|
}
|
|
425
426
|
const tokenType = _tokenType === 'erc20' ? _types._AssetType.ERC20 : _types._AssetType.ERC721;
|
|
426
|
-
const
|
|
427
|
+
const tokenInfo = {
|
|
428
|
+
slug: '',
|
|
429
|
+
type: tokenType,
|
|
430
|
+
name: (input === null || input === void 0 ? void 0 : (_input$options3 = input.options) === null || _input$options3 === void 0 ? void 0 : _input$options3.symbol) || '',
|
|
431
|
+
contractAddress: input.options.address,
|
|
432
|
+
symbol: (input === null || input === void 0 ? void 0 : (_input$options4 = input.options) === null || _input$options4 === void 0 ? void 0 : _input$options4.symbol) || '',
|
|
433
|
+
decimals: (input === null || input === void 0 ? void 0 : (_input$options5 = input.options) === null || _input$options5 === void 0 ? void 0 : _input$options5.decimals) || 0,
|
|
434
|
+
originChain: chain,
|
|
435
|
+
contractError: false,
|
|
436
|
+
validated: false
|
|
437
|
+
};
|
|
438
|
+
this.#koniState.validateCustomAsset({
|
|
427
439
|
type: tokenType,
|
|
428
440
|
contractAddress: input.options.address,
|
|
429
441
|
originChain: chain
|
|
442
|
+
}).then(validate => {
|
|
443
|
+
if (validate.contractError) {
|
|
444
|
+
tokenInfo.contractError = true;
|
|
445
|
+
} else {
|
|
446
|
+
tokenInfo.slug = validate === null || validate === void 0 ? void 0 : validate.existedSlug;
|
|
447
|
+
tokenInfo.name = validate.name;
|
|
448
|
+
tokenInfo.symbol = validate.symbol;
|
|
449
|
+
tokenInfo.decimals = validate.decimals;
|
|
450
|
+
}
|
|
451
|
+
}).catch(() => {
|
|
452
|
+
tokenInfo.contractError = true;
|
|
453
|
+
}).finally(() => {
|
|
454
|
+
tokenInfo.validated = true;
|
|
455
|
+
this.#koniState.requestService.updateConfirmation(id, 'addTokenRequest', tokenInfo);
|
|
430
456
|
});
|
|
431
457
|
|
|
432
458
|
// Below code is comment because we will handle exited token in the ui-view
|
|
433
459
|
// if (validate.isExist) {
|
|
434
460
|
// throw new EvmProviderError(EvmProviderErrorType.INTERNAL_ERROR, 'Current token is existed');
|
|
435
461
|
// } else
|
|
436
|
-
|
|
437
|
-
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Contract address is invalid');
|
|
438
|
-
}
|
|
439
|
-
const tokenInfo = {
|
|
440
|
-
slug: validate === null || validate === void 0 ? void 0 : validate.existedSlug,
|
|
441
|
-
type: tokenType,
|
|
442
|
-
name: validate.name,
|
|
443
|
-
contractAddress: input.options.address,
|
|
444
|
-
symbol: validate.symbol,
|
|
445
|
-
decimals: validate.decimals,
|
|
446
|
-
originChain: chain
|
|
447
|
-
};
|
|
462
|
+
|
|
448
463
|
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
449
464
|
}
|
|
450
465
|
async addEvmChain(id, url, _ref14) {
|
|
@@ -457,6 +472,10 @@ class KoniTabs {
|
|
|
457
472
|
blockExplorerUrls,
|
|
458
473
|
chainId,
|
|
459
474
|
chainName,
|
|
475
|
+
nativeCurrency: {
|
|
476
|
+
decimals,
|
|
477
|
+
symbol
|
|
478
|
+
},
|
|
460
479
|
rpcUrls
|
|
461
480
|
} = input[0];
|
|
462
481
|
if (chainId) {
|
|
@@ -507,12 +526,19 @@ class KoniTabs {
|
|
|
507
526
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, 'Currently HTTP provider for EVM network');
|
|
508
527
|
}
|
|
509
528
|
const provider = filteredUrls[0];
|
|
510
|
-
const chainInfo =
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
529
|
+
const chainInfo = {
|
|
530
|
+
existentialDeposit: '0',
|
|
531
|
+
genesisHash: '',
|
|
532
|
+
success: true,
|
|
533
|
+
addressPrefix: '',
|
|
534
|
+
evmChainId: chainIdNum,
|
|
535
|
+
decimals: decimals,
|
|
536
|
+
symbol: symbol,
|
|
537
|
+
paraId: null,
|
|
538
|
+
name: chainName
|
|
539
|
+
};
|
|
514
540
|
const newProviderKey = (0, _utils._generateCustomProviderKey)(0);
|
|
515
|
-
|
|
541
|
+
const networkData = {
|
|
516
542
|
mode: 'insert',
|
|
517
543
|
chainSpec: {
|
|
518
544
|
evmChainId: chainInfo.evmChainId,
|
|
@@ -532,8 +558,31 @@ class KoniTabs {
|
|
|
532
558
|
symbol: chainInfo.symbol,
|
|
533
559
|
chainType: 'EVM',
|
|
534
560
|
name: chainInfo.name
|
|
561
|
+
},
|
|
562
|
+
unconfirmed: true
|
|
563
|
+
};
|
|
564
|
+
this.#koniState.validateCustomChain(provider).then(res => {
|
|
565
|
+
if (!res.success) {
|
|
566
|
+
networkData.providerError = res.error;
|
|
567
|
+
} else {
|
|
568
|
+
networkData.chainSpec = {
|
|
569
|
+
evmChainId: res.evmChainId,
|
|
570
|
+
decimals: res.decimals,
|
|
571
|
+
existentialDeposit: res.existentialDeposit,
|
|
572
|
+
genesisHash: res.genesisHash,
|
|
573
|
+
paraId: res.paraId,
|
|
574
|
+
addressPrefix: res.addressPrefix ? parseInt(res.addressPrefix) : 0
|
|
575
|
+
};
|
|
576
|
+
networkData.chainEditInfo.symbol = res.symbol;
|
|
577
|
+
networkData.chainEditInfo.name = res.name;
|
|
535
578
|
}
|
|
579
|
+
}).catch(() => {
|
|
580
|
+
networkData.providerError = _types2._CHAIN_VALIDATION_ERROR.NONE;
|
|
581
|
+
}).finally(() => {
|
|
582
|
+
networkData.unconfirmed = false;
|
|
583
|
+
this.#koniState.requestService.updateConfirmation(id, 'addNetworkRequest', networkData);
|
|
536
584
|
});
|
|
585
|
+
return await this.#koniState.addNetworkConfirm(id, url, networkData);
|
|
537
586
|
} else {
|
|
538
587
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Invalid provider');
|
|
539
588
|
}
|
package/cjs/packageInfo.js
CHANGED
|
@@ -19,8 +19,8 @@ class MigrationService {
|
|
|
19
19
|
async run() {
|
|
20
20
|
const keys = Object.keys(_scripts.default).sort((a, b) => a.localeCompare(b));
|
|
21
21
|
|
|
22
|
-
// Await timeout
|
|
23
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
22
|
+
// Await timeout 1s
|
|
23
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
24
24
|
for (let i = 0; i < keys.length; i++) {
|
|
25
25
|
try {
|
|
26
26
|
const JobClass = _scripts.default[keys[i]];
|
|
@@ -81,6 +81,29 @@ class EvmRequestHandler {
|
|
|
81
81
|
this.#requestService.updateIconV2();
|
|
82
82
|
return promise;
|
|
83
83
|
}
|
|
84
|
+
updateConfirmation(id, type, payload) {
|
|
85
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
86
|
+
let validator = arguments.length > 4 ? arguments[4] : undefined;
|
|
87
|
+
const confirmations = this.confirmationsQueueSubject.getValue();
|
|
88
|
+
const confirmationType = confirmations[type];
|
|
89
|
+
|
|
90
|
+
// Check duplicate request
|
|
91
|
+
const exists = confirmationType[id];
|
|
92
|
+
if (!exists) {
|
|
93
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Request does not exist');
|
|
94
|
+
}
|
|
95
|
+
const payloadJson = JSON.stringify(payload);
|
|
96
|
+
confirmationType[id] = {
|
|
97
|
+
...exists,
|
|
98
|
+
payload,
|
|
99
|
+
payloadJson,
|
|
100
|
+
...options
|
|
101
|
+
};
|
|
102
|
+
if (validator) {
|
|
103
|
+
this.confirmationsPromiseMap[id].validator = validator;
|
|
104
|
+
}
|
|
105
|
+
this.confirmationsQueueSubject.next(confirmations);
|
|
106
|
+
}
|
|
84
107
|
async signMessage(confirmation) {
|
|
85
108
|
const {
|
|
86
109
|
account,
|
|
@@ -164,6 +164,11 @@ class RequestService {
|
|
|
164
164
|
async completeConfirmation(request) {
|
|
165
165
|
return await this.#evmRequestHandler.completeConfirmation(request);
|
|
166
166
|
}
|
|
167
|
+
updateConfirmation(id, type, payload) {
|
|
168
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
169
|
+
let validator = arguments.length > 4 ? arguments[4] : undefined;
|
|
170
|
+
return this.#evmRequestHandler.updateConfirmation(id, type, payload, options, validator);
|
|
171
|
+
}
|
|
167
172
|
|
|
168
173
|
// General methods
|
|
169
174
|
get numRequests() {
|
|
@@ -10,6 +10,7 @@ import RequestBytesSign from '@subwallet/extension-base/background/RequestBytesS
|
|
|
10
10
|
import RequestExtrinsicSign from '@subwallet/extension-base/background/RequestExtrinsicSign';
|
|
11
11
|
import { ALL_ACCOUNT_KEY, CRON_GET_API_MAP_STATUS } from '@subwallet/extension-base/constants';
|
|
12
12
|
import { PHISHING_PAGE_REDIRECT } from '@subwallet/extension-base/defaults';
|
|
13
|
+
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
13
14
|
import { _generateCustomProviderKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
14
15
|
import { DEFAULT_CHAIN_PATROL_ENABLE } from '@subwallet/extension-base/services/setting-service/constants';
|
|
15
16
|
import { canDerive } from '@subwallet/extension-base/utils';
|
|
@@ -365,7 +366,7 @@ export default class KoniTabs {
|
|
|
365
366
|
async addEvmToken(id, url, {
|
|
366
367
|
params
|
|
367
368
|
}) {
|
|
368
|
-
var _input$type, _input$options, _input$options2;
|
|
369
|
+
var _input$type, _input$options, _input$options2, _input$options3, _input$options4, _input$options5;
|
|
369
370
|
const input = params;
|
|
370
371
|
const _tokenType = (input === null || input === void 0 ? void 0 : (_input$type = input.type) === null || _input$type === void 0 ? void 0 : _input$type.toLowerCase()) || '';
|
|
371
372
|
if (_tokenType !== 'erc20' && _tokenType !== 'erc721') {
|
|
@@ -380,28 +381,42 @@ export default class KoniTabs {
|
|
|
380
381
|
throw new EvmProviderError(EvmProviderErrorType.INTERNAL_ERROR, 'Current chain is not available');
|
|
381
382
|
}
|
|
382
383
|
const tokenType = _tokenType === 'erc20' ? _AssetType.ERC20 : _AssetType.ERC721;
|
|
383
|
-
const
|
|
384
|
+
const tokenInfo = {
|
|
385
|
+
slug: '',
|
|
386
|
+
type: tokenType,
|
|
387
|
+
name: (input === null || input === void 0 ? void 0 : (_input$options3 = input.options) === null || _input$options3 === void 0 ? void 0 : _input$options3.symbol) || '',
|
|
388
|
+
contractAddress: input.options.address,
|
|
389
|
+
symbol: (input === null || input === void 0 ? void 0 : (_input$options4 = input.options) === null || _input$options4 === void 0 ? void 0 : _input$options4.symbol) || '',
|
|
390
|
+
decimals: (input === null || input === void 0 ? void 0 : (_input$options5 = input.options) === null || _input$options5 === void 0 ? void 0 : _input$options5.decimals) || 0,
|
|
391
|
+
originChain: chain,
|
|
392
|
+
contractError: false,
|
|
393
|
+
validated: false
|
|
394
|
+
};
|
|
395
|
+
this.#koniState.validateCustomAsset({
|
|
384
396
|
type: tokenType,
|
|
385
397
|
contractAddress: input.options.address,
|
|
386
398
|
originChain: chain
|
|
399
|
+
}).then(validate => {
|
|
400
|
+
if (validate.contractError) {
|
|
401
|
+
tokenInfo.contractError = true;
|
|
402
|
+
} else {
|
|
403
|
+
tokenInfo.slug = validate === null || validate === void 0 ? void 0 : validate.existedSlug;
|
|
404
|
+
tokenInfo.name = validate.name;
|
|
405
|
+
tokenInfo.symbol = validate.symbol;
|
|
406
|
+
tokenInfo.decimals = validate.decimals;
|
|
407
|
+
}
|
|
408
|
+
}).catch(() => {
|
|
409
|
+
tokenInfo.contractError = true;
|
|
410
|
+
}).finally(() => {
|
|
411
|
+
tokenInfo.validated = true;
|
|
412
|
+
this.#koniState.requestService.updateConfirmation(id, 'addTokenRequest', tokenInfo);
|
|
387
413
|
});
|
|
388
414
|
|
|
389
415
|
// Below code is comment because we will handle exited token in the ui-view
|
|
390
416
|
// if (validate.isExist) {
|
|
391
417
|
// throw new EvmProviderError(EvmProviderErrorType.INTERNAL_ERROR, 'Current token is existed');
|
|
392
418
|
// } else
|
|
393
|
-
|
|
394
|
-
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, 'Contract address is invalid');
|
|
395
|
-
}
|
|
396
|
-
const tokenInfo = {
|
|
397
|
-
slug: validate === null || validate === void 0 ? void 0 : validate.existedSlug,
|
|
398
|
-
type: tokenType,
|
|
399
|
-
name: validate.name,
|
|
400
|
-
contractAddress: input.options.address,
|
|
401
|
-
symbol: validate.symbol,
|
|
402
|
-
decimals: validate.decimals,
|
|
403
|
-
originChain: chain
|
|
404
|
-
};
|
|
419
|
+
|
|
405
420
|
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
406
421
|
}
|
|
407
422
|
async addEvmChain(id, url, {
|
|
@@ -413,6 +428,10 @@ export default class KoniTabs {
|
|
|
413
428
|
blockExplorerUrls,
|
|
414
429
|
chainId,
|
|
415
430
|
chainName,
|
|
431
|
+
nativeCurrency: {
|
|
432
|
+
decimals,
|
|
433
|
+
symbol
|
|
434
|
+
},
|
|
416
435
|
rpcUrls
|
|
417
436
|
} = input[0];
|
|
418
437
|
if (chainId) {
|
|
@@ -463,12 +482,19 @@ export default class KoniTabs {
|
|
|
463
482
|
throw new EvmProviderError(EvmProviderErrorType.INTERNAL_ERROR, 'Currently HTTP provider for EVM network');
|
|
464
483
|
}
|
|
465
484
|
const provider = filteredUrls[0];
|
|
466
|
-
const chainInfo =
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
485
|
+
const chainInfo = {
|
|
486
|
+
existentialDeposit: '0',
|
|
487
|
+
genesisHash: '',
|
|
488
|
+
success: true,
|
|
489
|
+
addressPrefix: '',
|
|
490
|
+
evmChainId: chainIdNum,
|
|
491
|
+
decimals: decimals,
|
|
492
|
+
symbol: symbol,
|
|
493
|
+
paraId: null,
|
|
494
|
+
name: chainName
|
|
495
|
+
};
|
|
470
496
|
const newProviderKey = _generateCustomProviderKey(0);
|
|
471
|
-
|
|
497
|
+
const networkData = {
|
|
472
498
|
mode: 'insert',
|
|
473
499
|
chainSpec: {
|
|
474
500
|
evmChainId: chainInfo.evmChainId,
|
|
@@ -488,8 +514,31 @@ export default class KoniTabs {
|
|
|
488
514
|
symbol: chainInfo.symbol,
|
|
489
515
|
chainType: 'EVM',
|
|
490
516
|
name: chainInfo.name
|
|
517
|
+
},
|
|
518
|
+
unconfirmed: true
|
|
519
|
+
};
|
|
520
|
+
this.#koniState.validateCustomChain(provider).then(res => {
|
|
521
|
+
if (!res.success) {
|
|
522
|
+
networkData.providerError = res.error;
|
|
523
|
+
} else {
|
|
524
|
+
networkData.chainSpec = {
|
|
525
|
+
evmChainId: res.evmChainId,
|
|
526
|
+
decimals: res.decimals,
|
|
527
|
+
existentialDeposit: res.existentialDeposit,
|
|
528
|
+
genesisHash: res.genesisHash,
|
|
529
|
+
paraId: res.paraId,
|
|
530
|
+
addressPrefix: res.addressPrefix ? parseInt(res.addressPrefix) : 0
|
|
531
|
+
};
|
|
532
|
+
networkData.chainEditInfo.symbol = res.symbol;
|
|
533
|
+
networkData.chainEditInfo.name = res.name;
|
|
491
534
|
}
|
|
535
|
+
}).catch(() => {
|
|
536
|
+
networkData.providerError = _CHAIN_VALIDATION_ERROR.NONE;
|
|
537
|
+
}).finally(() => {
|
|
538
|
+
networkData.unconfirmed = false;
|
|
539
|
+
this.#koniState.requestService.updateConfirmation(id, 'addNetworkRequest', networkData);
|
|
492
540
|
});
|
|
541
|
+
return await this.#koniState.addNetworkConfirm(id, url, networkData);
|
|
493
542
|
} else {
|
|
494
543
|
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, 'Invalid provider');
|
|
495
544
|
}
|
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.7-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1697,11 +1697,11 @@
|
|
|
1697
1697
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1698
1698
|
"@subsocial/types": "^0.6.8",
|
|
1699
1699
|
"@substrate/connect": "^0.7.26",
|
|
1700
|
-
"@subwallet/chain-list": "^0.1.
|
|
1701
|
-
"@subwallet/extension-base": "^1.0.
|
|
1702
|
-
"@subwallet/extension-chains": "^1.0.
|
|
1703
|
-
"@subwallet/extension-dapp": "^1.0.
|
|
1704
|
-
"@subwallet/extension-inject": "^1.0.
|
|
1700
|
+
"@subwallet/chain-list": "^0.1.9",
|
|
1701
|
+
"@subwallet/extension-base": "^1.0.7-0",
|
|
1702
|
+
"@subwallet/extension-chains": "^1.0.7-0",
|
|
1703
|
+
"@subwallet/extension-dapp": "^1.0.7-0",
|
|
1704
|
+
"@subwallet/extension-inject": "^1.0.7-0",
|
|
1705
1705
|
"@subwallet/keyring": "^0.0.9",
|
|
1706
1706
|
"@subwallet/ui-keyring": "^0.0.9",
|
|
1707
1707
|
"@unique-nft/types": "^0.6.0-4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.0.
|
|
10
|
+
version: '1.0.7-0'
|
|
11
11
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
+
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
2
3
|
import Web3 from 'web3';
|
|
3
4
|
import { ApiPromise } from '@polkadot/api';
|
|
4
5
|
import { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types';
|
|
@@ -88,6 +89,8 @@ export declare type _NetworkUpsertParams = {
|
|
|
88
89
|
existentialDeposit: string;
|
|
89
90
|
decimals: number;
|
|
90
91
|
};
|
|
92
|
+
unconfirmed?: boolean;
|
|
93
|
+
providerError?: _CHAIN_VALIDATION_ERROR;
|
|
91
94
|
};
|
|
92
95
|
export declare const _CUSTOM_PREFIX = "custom-";
|
|
93
96
|
export interface _ValidateCustomAssetRequest {
|
|
@@ -11,8 +11,8 @@ export default class MigrationService {
|
|
|
11
11
|
async run() {
|
|
12
12
|
const keys = Object.keys(MigrationScripts).sort((a, b) => a.localeCompare(b));
|
|
13
13
|
|
|
14
|
-
// Await timeout
|
|
15
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
14
|
+
// Await timeout 1s
|
|
15
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
16
16
|
for (let i = 0; i < keys.length; i++) {
|
|
17
17
|
try {
|
|
18
18
|
const JobClass = MigrationScripts[keys[i]];
|
|
@@ -11,6 +11,7 @@ export default class EvmRequestHandler {
|
|
|
11
11
|
get numEvmRequests(): number;
|
|
12
12
|
getConfirmationsQueueSubject(): BehaviorSubject<ConfirmationsQueue>;
|
|
13
13
|
addConfirmation<CT extends ConfirmationType>(id: string, url: string, type: CT, payload: ConfirmationDefinitions[CT][0]['payload'], options?: ConfirmationsQueueItemOptions, validator?: (input: ConfirmationDefinitions[CT][1]) => Error | undefined): Promise<ConfirmationDefinitions[CT][1]>;
|
|
14
|
+
updateConfirmation<CT extends ConfirmationType>(id: string, type: CT, payload: ConfirmationDefinitions[CT][0]['payload'], options?: ConfirmationsQueueItemOptions, validator?: (input: ConfirmationDefinitions[CT][1]) => Error | undefined): void;
|
|
14
15
|
private signMessage;
|
|
15
16
|
configToTransaction(config: TransactionConfig): Transaction;
|
|
16
17
|
private signTransaction;
|
|
@@ -72,6 +72,27 @@ export default class EvmRequestHandler {
|
|
|
72
72
|
this.#requestService.updateIconV2();
|
|
73
73
|
return promise;
|
|
74
74
|
}
|
|
75
|
+
updateConfirmation(id, type, payload, options = {}, validator) {
|
|
76
|
+
const confirmations = this.confirmationsQueueSubject.getValue();
|
|
77
|
+
const confirmationType = confirmations[type];
|
|
78
|
+
|
|
79
|
+
// Check duplicate request
|
|
80
|
+
const exists = confirmationType[id];
|
|
81
|
+
if (!exists) {
|
|
82
|
+
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, 'Request does not exist');
|
|
83
|
+
}
|
|
84
|
+
const payloadJson = JSON.stringify(payload);
|
|
85
|
+
confirmationType[id] = {
|
|
86
|
+
...exists,
|
|
87
|
+
payload,
|
|
88
|
+
payloadJson,
|
|
89
|
+
...options
|
|
90
|
+
};
|
|
91
|
+
if (validator) {
|
|
92
|
+
this.confirmationsPromiseMap[id].validator = validator;
|
|
93
|
+
}
|
|
94
|
+
this.confirmationsQueueSubject.next(confirmations);
|
|
95
|
+
}
|
|
75
96
|
async signMessage(confirmation) {
|
|
76
97
|
const {
|
|
77
98
|
account,
|
|
@@ -51,6 +51,7 @@ export default class RequestService {
|
|
|
51
51
|
signInternalTransaction(id: string, address: string, url: string, payload: SignerPayloadJSON): Promise<ResponseSigning>;
|
|
52
52
|
addConfirmation<CT extends ConfirmationType>(id: string, url: string, type: CT, payload: ConfirmationDefinitions[CT][0]['payload'], options?: ConfirmationsQueueItemOptions, validator?: (input: ConfirmationDefinitions[CT][1]) => Error | undefined): Promise<ConfirmationDefinitions[CT][1]>;
|
|
53
53
|
completeConfirmation(request: RequestConfirmationComplete): Promise<boolean>;
|
|
54
|
+
updateConfirmation<CT extends ConfirmationType>(id: string, type: CT, payload: ConfirmationDefinitions[CT][0]['payload'], options?: ConfirmationsQueueItemOptions, validator?: (input: ConfirmationDefinitions[CT][1]) => Error | undefined): void;
|
|
54
55
|
get numRequests(): number;
|
|
55
56
|
resetWallet(): void;
|
|
56
57
|
}
|
|
@@ -154,6 +154,9 @@ export default class RequestService {
|
|
|
154
154
|
async completeConfirmation(request) {
|
|
155
155
|
return await this.#evmRequestHandler.completeConfirmation(request);
|
|
156
156
|
}
|
|
157
|
+
updateConfirmation(id, type, payload, options = {}, validator) {
|
|
158
|
+
return this.#evmRequestHandler.updateConfirmation(id, type, payload, options, validator);
|
|
159
|
+
}
|
|
157
160
|
|
|
158
161
|
// General methods
|
|
159
162
|
get numRequests() {
|