@subwallet/extension-base 1.3.76-0 → 1.3.77-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 +2 -1
- package/cjs/core/substrate/xcm-parser.js +8 -11
- package/cjs/koni/background/handlers/Extension.js +258 -63
- package/cjs/koni/background/handlers/Tabs.js +2 -3
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +4 -1
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +8 -5
- package/cjs/services/earning-service/service.js +18 -2
- package/cjs/services/multisig-service/index.js +1 -1
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +12 -0
- package/cjs/services/request-service/index.js +3 -0
- package/cjs/services/setting-service/constants.js +2 -1
- package/cjs/services/storage-service/db-stores/InappNotification.js +1 -1
- package/cjs/services/transaction-service/index.js +9 -0
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +7 -11
- package/koni/background/handlers/Extension.d.ts +19 -0
- package/koni/background/handlers/Extension.js +197 -5
- package/koni/background/handlers/Tabs.js +2 -3
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +2 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +1 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +6 -4
- package/services/earning-service/service.js +20 -4
- package/services/inapp-notification-service/interfaces.d.ts +1 -0
- package/services/multisig-service/index.js +1 -1
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -0
- package/services/request-service/handler/SubstrateRequestHandler.js +12 -0
- package/services/request-service/index.d.ts +1 -0
- package/services/request-service/index.js +3 -0
- package/services/request-service/types.d.ts +1 -0
- package/services/setting-service/constants.js +2 -1
- package/services/storage-service/db-stores/InappNotification.js +1 -1
- package/services/transaction-service/index.d.ts +1 -1
- package/services/transaction-service/index.js +9 -0
- package/types/balance/transfer.d.ts +2 -0
- package/types/multisig/index.d.ts +12 -0
|
@@ -13,6 +13,7 @@ var _TransactionError = require("@subwallet/extension-base/background/errors/Tra
|
|
|
13
13
|
var _helpers = require("@subwallet/extension-base/background/handlers/helpers");
|
|
14
14
|
var _subscriptions = require("@subwallet/extension-base/background/handlers/subscriptions");
|
|
15
15
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
16
|
+
var _RequestExtrinsicSign = _interopRequireDefault(require("@subwallet/extension-base/background/RequestExtrinsicSign"));
|
|
16
17
|
var _constants = require("@subwallet/extension-base/constants");
|
|
17
18
|
var _transfer = require("@subwallet/extension-base/core/logic-validation/transfer");
|
|
18
19
|
var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
|
|
@@ -3221,8 +3222,134 @@ class KoniExtension {
|
|
|
3221
3222
|
});
|
|
3222
3223
|
}
|
|
3223
3224
|
|
|
3225
|
+
// Helper for prepareMultisigSignRequest: reconstruct the original extrinsic from the payload's method & args
|
|
3226
|
+
async buildExtrinsicFromPayload(chain, payload) {
|
|
3227
|
+
const substrateApi = await this.#koniState.chainService.getSubstrateApi(chain).isReady;
|
|
3228
|
+
const call = substrateApi.api.createType('Call', payload.method);
|
|
3229
|
+
const {
|
|
3230
|
+
method,
|
|
3231
|
+
section
|
|
3232
|
+
} = substrateApi.api.registry.findMetaCall(call.callIndex);
|
|
3233
|
+
const extrinsic = substrateApi.api.tx[section][method](...call.args);
|
|
3234
|
+
return {
|
|
3235
|
+
substrateApi,
|
|
3236
|
+
extrinsic,
|
|
3237
|
+
call
|
|
3238
|
+
};
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
/**
|
|
3242
|
+
* ─────────────────────────────────────────────────────────────
|
|
3243
|
+
* prepareMultisigSignRequest
|
|
3244
|
+
* ─────────────────────────────────────────────────────────────
|
|
3245
|
+
* Called when a dApp sends a signing request to a multisig account.
|
|
3246
|
+
* This method wraps the original extrinsic into a multisig.asMulti call so that it can be submitted by one of the signers on behalf of the multisig account.
|
|
3247
|
+
*
|
|
3248
|
+
* Important:
|
|
3249
|
+
* - The original sign request is MUTATED in-place via updateSignRequest.
|
|
3250
|
+
* After this method returns, the UI will prompt the signer to sign
|
|
3251
|
+
* the wrapped multisig extrinsic, not the original one.
|
|
3252
|
+
* - Errors are collected (not thrown) and returned in the response
|
|
3253
|
+
* so the UI can display them without crashing.
|
|
3254
|
+
* - This method does NOT submit the transaction; it only prepares
|
|
3255
|
+
* the payload for signing.
|
|
3256
|
+
* ─────────────────────────────────────────────────────────────
|
|
3257
|
+
*/
|
|
3258
|
+
async prepareMultisigSignRequest(request) {
|
|
3259
|
+
const {
|
|
3260
|
+
id,
|
|
3261
|
+
signer
|
|
3262
|
+
} = request;
|
|
3263
|
+
|
|
3264
|
+
// ── Step 1: Retrieve the pending sign request from the queue ──
|
|
3265
|
+
const queued = this.#koniState.getSignRequest(id);
|
|
3266
|
+
(0, _util.assert)(queued, (0, _i18next.t)('bg.koni.handler.Extension.unableToProceed'));
|
|
3267
|
+
const errors = [];
|
|
3268
|
+
let submittedCallData = '';
|
|
3269
|
+
let callData = '';
|
|
3270
|
+
let depositAmount = '';
|
|
3271
|
+
let networkFee = '';
|
|
3272
|
+
const payload = queued.request.payload;
|
|
3273
|
+
|
|
3274
|
+
// ── Step 2: Validate payload format ──
|
|
3275
|
+
// Only JSON payloads (SignerPayloadJSON) contain the structured fields
|
|
3276
|
+
// (genesisHash, method, etc.) needed to reconstruct the extrinsic.
|
|
3277
|
+
// Raw (bytes) payloads cannot be wrapped into a multisig call.
|
|
3278
|
+
if (!isJsonPayload(payload)) {
|
|
3279
|
+
errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('bg.koni.handler.Extension.unableToProceed')));
|
|
3280
|
+
} else {
|
|
3281
|
+
var _chainInfo$substrateI;
|
|
3282
|
+
// ── Step 3: Resolve chain from genesisHash & check multisig support ──
|
|
3283
|
+
callData = payload.method;
|
|
3284
|
+
const [chain, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
|
|
3285
|
+
if (!chain || !(chainInfo !== null && chainInfo !== void 0 && (_chainInfo$substrateI = chainInfo.substrateInfo) !== null && _chainInfo$substrateI !== void 0 && _chainInfo$substrateI.supportMultisig)) {
|
|
3286
|
+
errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.UNSUPPORTED, (0, _i18next.t)('bg.koni.handler.Extension.unableToProceed')));
|
|
3287
|
+
} else {
|
|
3288
|
+
// ── Step 4: Look up multisig account configuration ──
|
|
3289
|
+
// queued.address is the multisig account address (the "from" in the original request).
|
|
3290
|
+
// We need its threshold and signers list to construct the asMulti call.
|
|
3291
|
+
const accountProxy = this.#koniState.keyringService.context.getMultisigAccountByAddress(queued.address);
|
|
3292
|
+
if (!accountProxy) {
|
|
3293
|
+
errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('bg.koni.handler.Extension.unableToProceed')));
|
|
3294
|
+
} else {
|
|
3295
|
+
const threshold = accountProxy.accounts[0].threshold;
|
|
3296
|
+
const signers = accountProxy.accounts[0].signers;
|
|
3297
|
+
|
|
3298
|
+
// ── Step 5: Rebuild the original extrinsic from payload call data ──
|
|
3299
|
+
const {
|
|
3300
|
+
extrinsic: originExtrinsic,
|
|
3301
|
+
substrateApi
|
|
3302
|
+
} = await this.buildExtrinsicFromPayload(chain, payload);
|
|
3303
|
+
|
|
3304
|
+
// ── Step 6: Wrap into multisig initiation extrinsic ──
|
|
3305
|
+
const multisigExtrinsic = (0, _utils8.createInitMultisigExtrinsic)(substrateApi.api, threshold, signers, signer, originExtrinsic);
|
|
3306
|
+
|
|
3307
|
+
// ── Step 7: Estimate fee & calculate multisig deposit ──
|
|
3308
|
+
submittedCallData = multisigExtrinsic.method.toHex();
|
|
3309
|
+
networkFee = (await multisigExtrinsic.paymentInfo(signer)).partialFee.toString();
|
|
3310
|
+
const depositBase = substrateApi.api.consts.multisig.depositBase.toString();
|
|
3311
|
+
const depositFactor = substrateApi.api.consts.multisig.depositFactor.toString();
|
|
3312
|
+
depositAmount = (0, _utils8.calcDepositAmount)(depositBase, threshold, depositFactor);
|
|
3313
|
+
|
|
3314
|
+
// ── Step 8: Validate signer has sufficient balance ──
|
|
3315
|
+
const signerBalance = await this.getAddressTransferableBalance({
|
|
3316
|
+
address: signer,
|
|
3317
|
+
networkKey: chain,
|
|
3318
|
+
token: this.#koniState.chainService.getNativeTokenInfo(chain).slug,
|
|
3319
|
+
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_TOKEN
|
|
3320
|
+
});
|
|
3321
|
+
const requiredBalance = new _bignumber.default(depositAmount).plus(networkFee);
|
|
3322
|
+
if (new _bignumber.default(signerBalance.value).lt(requiredBalance)) {
|
|
3323
|
+
errors.push(new _TransactionError.TransactionError(_types5.BasicTxErrorType.NOT_ENOUGH_BALANCE, (0, _i18next.t)('bg.koni.handler.Extension.notEnoughBalanceForMultisigDepositAndFee')));
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
// ── Step 9: Replace the original sign request with the wrapped payload ──
|
|
3327
|
+
// After this, the signing UI will show the multisig extrinsic instead of
|
|
3328
|
+
// the original one. The signer's address and fresh nonce are used so
|
|
3329
|
+
// the transaction is submitted from the signer (not the multisig account).
|
|
3330
|
+
const nonce = await substrateApi.api.rpc.system.accountNextIndex(signer);
|
|
3331
|
+
const wrappedPayload = {
|
|
3332
|
+
...payload,
|
|
3333
|
+
address: signer,
|
|
3334
|
+
nonce: nonce.toHex(),
|
|
3335
|
+
method: multisigExtrinsic.method.toHex()
|
|
3336
|
+
};
|
|
3337
|
+
this.#koniState.requestService.updateSignRequest(id, new _RequestExtrinsicSign.default(wrappedPayload), signer);
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
return {
|
|
3342
|
+
submittedCallData: submittedCallData,
|
|
3343
|
+
callData: callData,
|
|
3344
|
+
depositAmount,
|
|
3345
|
+
networkFee,
|
|
3346
|
+
errors
|
|
3347
|
+
};
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3224
3350
|
// Substrate Proxy Account
|
|
3225
3351
|
async handleSubstrateProxyWrappedTx(request) {
|
|
3352
|
+
var _originTransaction;
|
|
3226
3353
|
const {
|
|
3227
3354
|
chain,
|
|
3228
3355
|
proxyMetadata,
|
|
@@ -3239,8 +3366,8 @@ class KoniExtension {
|
|
|
3239
3366
|
* ─────────────────────────────
|
|
3240
3367
|
*/
|
|
3241
3368
|
const substrateApi = await this.#koniState.chainService.getSubstrateApi(chain).isReady;
|
|
3242
|
-
|
|
3243
|
-
const extrinsicOriginTransaction = originTransaction === null ||
|
|
3369
|
+
let originTransaction = this.#koniState.transactionService.getTransaction(transactionId);
|
|
3370
|
+
const extrinsicOriginTransaction = (_originTransaction = originTransaction) === null || _originTransaction === void 0 ? void 0 : _originTransaction.transaction;
|
|
3244
3371
|
const callData = extrinsicOriginTransaction.method.toHex();
|
|
3245
3372
|
const decodedCallData = (0, _utils8.decodeCallData)({
|
|
3246
3373
|
api: substrateApi.api,
|
|
@@ -3312,7 +3439,8 @@ class KoniExtension {
|
|
|
3312
3439
|
* update history transaction accordingly.
|
|
3313
3440
|
*/
|
|
3314
3441
|
const eventsHandler = eventEmitter => {
|
|
3315
|
-
|
|
3442
|
+
var _originTransaction2;
|
|
3443
|
+
if (!((_originTransaction2 = originTransaction) !== null && _originTransaction2 !== void 0 && _originTransaction2.emitterTransaction)) {
|
|
3316
3444
|
return;
|
|
3317
3445
|
}
|
|
3318
3446
|
const originEmitter = originTransaction.emitterTransaction;
|
|
@@ -3364,6 +3492,52 @@ class KoniExtension {
|
|
|
3364
3492
|
* ─────────────────────────────
|
|
3365
3493
|
*/
|
|
3366
3494
|
|
|
3495
|
+
const originTransferData = originTransaction.data;
|
|
3496
|
+
const isTransferAllBalance = originTransaction.extrinsicType === _KoniTypes.ExtrinsicType.TRANSFER_BALANCE && !!(originTransferData !== null && originTransferData !== void 0 && originTransferData.transferAll);
|
|
3497
|
+
const maxTransferableWithoutFee = originTransferData === null || originTransferData === void 0 ? void 0 : originTransferData.maxTransferableWithoutFee;
|
|
3498
|
+
const maxTransferable = originTransferData === null || originTransferData === void 0 ? void 0 : originTransferData.maxTransferable;
|
|
3499
|
+
if (isTransferAllBalance && !!maxTransferableWithoutFee && !!maxTransferable) {
|
|
3500
|
+
if (isSignerProxiedAccount) {
|
|
3501
|
+
this.#koniState.transactionService.updateTransaction(transactionId, {
|
|
3502
|
+
data: {
|
|
3503
|
+
...originTransferData,
|
|
3504
|
+
value: maxTransferable,
|
|
3505
|
+
transferNativeAmount: maxTransferable
|
|
3506
|
+
}
|
|
3507
|
+
});
|
|
3508
|
+
} else {
|
|
3509
|
+
this.#koniState.transactionService.updateTransaction(transactionId, {
|
|
3510
|
+
data: {
|
|
3511
|
+
...originTransferData,
|
|
3512
|
+
value: maxTransferableWithoutFee,
|
|
3513
|
+
transferNativeAmount: maxTransferableWithoutFee
|
|
3514
|
+
}
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
|
|
3518
|
+
// Refresh originTransaction after update
|
|
3519
|
+
originTransaction = this.#koniState.transactionService.getTransaction(transactionId);
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
// If signer is the proxied account itself, the original transaction will be signed and sent directly without proxy execution.
|
|
3523
|
+
if (isSignerProxiedAccount) {
|
|
3524
|
+
const restData = Object.fromEntries(Object.entries(originTransaction.data || {}).filter(_ref50 => {
|
|
3525
|
+
let [key] = _ref50;
|
|
3526
|
+
return key !== 'signer';
|
|
3527
|
+
}));
|
|
3528
|
+
this.#koniState.transactionService.updateTransaction(transactionId, {
|
|
3529
|
+
data: restData
|
|
3530
|
+
});
|
|
3531
|
+
} else {
|
|
3532
|
+
this.#koniState.transactionService.updateTransaction(transactionId, {
|
|
3533
|
+
data: {
|
|
3534
|
+
...originTransaction.data,
|
|
3535
|
+
signer
|
|
3536
|
+
}
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
originTransaction = this.#koniState.transactionService.getTransaction(transactionId);
|
|
3540
|
+
|
|
3367
3541
|
// Case 1: signer === proxied address → handle original transaction
|
|
3368
3542
|
if (isSignerProxiedAccount) {
|
|
3369
3543
|
let callDataFinal = callData;
|
|
@@ -3411,6 +3585,8 @@ class KoniExtension {
|
|
|
3411
3585
|
decodedCallData,
|
|
3412
3586
|
submittedCallData: substrateProxyExtrinsic.toHex(),
|
|
3413
3587
|
callData,
|
|
3588
|
+
signer,
|
|
3589
|
+
signerAddress: signer,
|
|
3414
3590
|
networkFee
|
|
3415
3591
|
},
|
|
3416
3592
|
wrappingStatus: _types4.SubstrateTransactionWrappingStatus.WRAP_RESULT,
|
|
@@ -3420,12 +3596,12 @@ class KoniExtension {
|
|
|
3420
3596
|
}
|
|
3421
3597
|
|
|
3422
3598
|
// EVM Transaction
|
|
3423
|
-
async parseContractInput(
|
|
3599
|
+
async parseContractInput(_ref51) {
|
|
3424
3600
|
let {
|
|
3425
3601
|
chainId,
|
|
3426
3602
|
contract,
|
|
3427
3603
|
data
|
|
3428
|
-
} =
|
|
3604
|
+
} = _ref51;
|
|
3429
3605
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
3430
3606
|
return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
|
|
3431
3607
|
}
|
|
@@ -3525,10 +3701,10 @@ class KoniExtension {
|
|
|
3525
3701
|
|
|
3526
3702
|
// Unlock wallet
|
|
3527
3703
|
|
|
3528
|
-
keyringUnlock(
|
|
3704
|
+
keyringUnlock(_ref52) {
|
|
3529
3705
|
let {
|
|
3530
3706
|
password
|
|
3531
|
-
} =
|
|
3707
|
+
} = _ref52;
|
|
3532
3708
|
try {
|
|
3533
3709
|
_uiKeyring.keyring.unlockKeyring(password);
|
|
3534
3710
|
// this.#koniState.initMantaPay(password)
|
|
@@ -3559,11 +3735,11 @@ class KoniExtension {
|
|
|
3559
3735
|
|
|
3560
3736
|
// Export mnemonic
|
|
3561
3737
|
|
|
3562
|
-
keyringExportMnemonic(
|
|
3738
|
+
keyringExportMnemonic(_ref53) {
|
|
3563
3739
|
let {
|
|
3564
3740
|
address,
|
|
3565
3741
|
password
|
|
3566
|
-
} =
|
|
3742
|
+
} = _ref53;
|
|
3567
3743
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
3568
3744
|
const result = pair.exportMnemonic(password);
|
|
3569
3745
|
return {
|
|
@@ -3573,10 +3749,10 @@ class KoniExtension {
|
|
|
3573
3749
|
|
|
3574
3750
|
// Reset wallet
|
|
3575
3751
|
|
|
3576
|
-
async resetWallet(
|
|
3752
|
+
async resetWallet(_ref54) {
|
|
3577
3753
|
let {
|
|
3578
3754
|
resetAll
|
|
3579
|
-
} =
|
|
3755
|
+
} = _ref54;
|
|
3580
3756
|
try {
|
|
3581
3757
|
await this.#koniState.resetWallet(resetAll);
|
|
3582
3758
|
return {
|
|
@@ -3592,10 +3768,10 @@ class KoniExtension {
|
|
|
3592
3768
|
}
|
|
3593
3769
|
|
|
3594
3770
|
// Signing substrate request
|
|
3595
|
-
async signingApprovePasswordV2(
|
|
3771
|
+
async signingApprovePasswordV2(_ref55) {
|
|
3596
3772
|
let {
|
|
3597
3773
|
id
|
|
3598
|
-
} =
|
|
3774
|
+
} = _ref55;
|
|
3599
3775
|
const queued = this.#koniState.getSignRequest(id);
|
|
3600
3776
|
(0, _util.assert)(queued, (0, _i18next.t)('bg.koni.handler.Extension.unableToProceed'));
|
|
3601
3777
|
const {
|
|
@@ -3603,7 +3779,8 @@ class KoniExtension {
|
|
|
3603
3779
|
request,
|
|
3604
3780
|
resolve
|
|
3605
3781
|
} = queued;
|
|
3606
|
-
const
|
|
3782
|
+
const signingAddress = queued.signerAddress || queued.address;
|
|
3783
|
+
const pair = _uiKeyring.keyring.getPair(signingAddress);
|
|
3607
3784
|
|
|
3608
3785
|
// unlike queued.account.address the following
|
|
3609
3786
|
// address is encoded with the default prefix
|
|
@@ -3633,10 +3810,26 @@ class KoniExtension {
|
|
|
3633
3810
|
}
|
|
3634
3811
|
}
|
|
3635
3812
|
const result = request.sign(registry, pair);
|
|
3813
|
+
let signedTransaction;
|
|
3814
|
+
if (queued.signerAddress && isJsonPayload(payload)) {
|
|
3815
|
+
try {
|
|
3816
|
+
const [chain] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
|
|
3817
|
+
if (chain) {
|
|
3818
|
+
const {
|
|
3819
|
+
extrinsic
|
|
3820
|
+
} = await this.buildExtrinsicFromPayload(chain, payload);
|
|
3821
|
+
extrinsic.addSignature(payload.address, result.signature, payload);
|
|
3822
|
+
signedTransaction = extrinsic.toHex();
|
|
3823
|
+
}
|
|
3824
|
+
} catch (e) {
|
|
3825
|
+
console.error('Failed to build signed transaction for wrapped multisig signing', e);
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3636
3828
|
resolve({
|
|
3637
3829
|
id,
|
|
3638
3830
|
// In case evm chain, must be cut 2 character after 0x
|
|
3639
|
-
signature: result.signature
|
|
3831
|
+
signature: result.signature,
|
|
3832
|
+
signedTransaction
|
|
3640
3833
|
});
|
|
3641
3834
|
if (this.#alwaysLock) {
|
|
3642
3835
|
this.keyringLock();
|
|
@@ -3754,10 +3947,10 @@ class KoniExtension {
|
|
|
3754
3947
|
getSupportedSmartContractTypes() {
|
|
3755
3948
|
return this.#koniState.getSupportedSmartContractTypes();
|
|
3756
3949
|
}
|
|
3757
|
-
getTransaction(
|
|
3950
|
+
getTransaction(_ref56) {
|
|
3758
3951
|
let {
|
|
3759
3952
|
id
|
|
3760
|
-
} =
|
|
3953
|
+
} = _ref56;
|
|
3761
3954
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3762
3955
|
const {
|
|
3763
3956
|
transaction,
|
|
@@ -3768,8 +3961,8 @@ class KoniExtension {
|
|
|
3768
3961
|
async subscribeTransactions(id, port) {
|
|
3769
3962
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3770
3963
|
function convertRs(rs, processMap) {
|
|
3771
|
-
return Object.fromEntries(Object.entries(rs).map(
|
|
3772
|
-
let [key, value] =
|
|
3964
|
+
return Object.fromEntries(Object.entries(rs).map(_ref57 => {
|
|
3965
|
+
let [key, value] = _ref57;
|
|
3773
3966
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3774
3967
|
const {
|
|
3775
3968
|
additionalValidator,
|
|
@@ -3795,11 +3988,11 @@ class KoniExtension {
|
|
|
3795
3988
|
const subscription = (0, _rxjs.combineLatest)({
|
|
3796
3989
|
transactions: transactionsObservable,
|
|
3797
3990
|
processMap: processTransactionObservable
|
|
3798
|
-
}).subscribe(
|
|
3991
|
+
}).subscribe(_ref58 => {
|
|
3799
3992
|
let {
|
|
3800
3993
|
processMap,
|
|
3801
3994
|
transactions
|
|
3802
|
-
} =
|
|
3995
|
+
} = _ref58;
|
|
3803
3996
|
cb(convertRs(transactions, processMap));
|
|
3804
3997
|
});
|
|
3805
3998
|
port.onDisconnect.addListener(() => {
|
|
@@ -3820,10 +4013,10 @@ class KoniExtension {
|
|
|
3820
4013
|
});
|
|
3821
4014
|
return notificationSubject.value;
|
|
3822
4015
|
}
|
|
3823
|
-
async reloadCron(
|
|
4016
|
+
async reloadCron(_ref59) {
|
|
3824
4017
|
let {
|
|
3825
4018
|
data
|
|
3826
|
-
} =
|
|
4019
|
+
} = _ref59;
|
|
3827
4020
|
if (data === 'nft') {
|
|
3828
4021
|
return await this.#koniState.reloadNft();
|
|
3829
4022
|
} else if (data === 'staking') {
|
|
@@ -3864,10 +4057,10 @@ class KoniExtension {
|
|
|
3864
4057
|
}
|
|
3865
4058
|
|
|
3866
4059
|
// Phishing detect
|
|
3867
|
-
async passPhishingPage(
|
|
4060
|
+
async passPhishingPage(_ref60) {
|
|
3868
4061
|
let {
|
|
3869
4062
|
url
|
|
3870
|
-
} =
|
|
4063
|
+
} = _ref60;
|
|
3871
4064
|
return await this.#koniState.approvePassPhishingPage(url);
|
|
3872
4065
|
}
|
|
3873
4066
|
|
|
@@ -3884,10 +4077,10 @@ class KoniExtension {
|
|
|
3884
4077
|
this.#koniState.saveEnvConfig('osConfig', request.osConfig);
|
|
3885
4078
|
return true;
|
|
3886
4079
|
}
|
|
3887
|
-
async saveSubscanApiKey(
|
|
4080
|
+
async saveSubscanApiKey(_ref61) {
|
|
3888
4081
|
let {
|
|
3889
4082
|
apiKey
|
|
3890
|
-
} =
|
|
4083
|
+
} = _ref61;
|
|
3891
4084
|
return await this.#koniState.saveSubscanApiKey(apiKey);
|
|
3892
4085
|
}
|
|
3893
4086
|
async getSubscanApiKey() {
|
|
@@ -3897,10 +4090,10 @@ class KoniExtension {
|
|
|
3897
4090
|
/// Wallet connect
|
|
3898
4091
|
|
|
3899
4092
|
// Connect
|
|
3900
|
-
async connectWalletConnect(
|
|
4093
|
+
async connectWalletConnect(_ref62) {
|
|
3901
4094
|
let {
|
|
3902
4095
|
uri
|
|
3903
|
-
} =
|
|
4096
|
+
} = _ref62;
|
|
3904
4097
|
await this.#koniState.walletConnectService.connect(uri);
|
|
3905
4098
|
return true;
|
|
3906
4099
|
}
|
|
@@ -3913,11 +4106,11 @@ class KoniExtension {
|
|
|
3913
4106
|
});
|
|
3914
4107
|
return this.#koniState.requestService.allConnectWCRequests;
|
|
3915
4108
|
}
|
|
3916
|
-
async approveWalletConnectSession(
|
|
4109
|
+
async approveWalletConnectSession(_ref63) {
|
|
3917
4110
|
let {
|
|
3918
4111
|
accounts: selectedAccounts,
|
|
3919
4112
|
id
|
|
3920
|
-
} =
|
|
4113
|
+
} = _ref63;
|
|
3921
4114
|
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
3922
4115
|
if ((0, _helpers2.isProposalExpired)(request.request.params)) {
|
|
3923
4116
|
throw new Error('The proposal has been expired');
|
|
@@ -3929,8 +4122,8 @@ class KoniExtension {
|
|
|
3929
4122
|
const availableNamespaces = {};
|
|
3930
4123
|
const namespaces = {};
|
|
3931
4124
|
const chainInfoMap = this.#koniState.getChainInfoMap();
|
|
3932
|
-
Object.entries(requiredNamespaces).forEach(
|
|
3933
|
-
let [key, namespace] =
|
|
4125
|
+
Object.entries(requiredNamespaces).forEach(_ref64 => {
|
|
4126
|
+
let [key, namespace] = _ref64;
|
|
3934
4127
|
if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
|
|
3935
4128
|
if (namespace.chains) {
|
|
3936
4129
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
@@ -3943,8 +4136,8 @@ class KoniExtension {
|
|
|
3943
4136
|
throw new Error((0, _utils1.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
3944
4137
|
}
|
|
3945
4138
|
});
|
|
3946
|
-
Object.entries(optionalNamespaces).forEach(
|
|
3947
|
-
let [key, namespace] =
|
|
4139
|
+
Object.entries(optionalNamespaces).forEach(_ref65 => {
|
|
4140
|
+
let [key, namespace] = _ref65;
|
|
3948
4141
|
if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
|
|
3949
4142
|
if (namespace.chains) {
|
|
3950
4143
|
const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
|
|
@@ -3968,8 +4161,8 @@ class KoniExtension {
|
|
|
3968
4161
|
}
|
|
3969
4162
|
}
|
|
3970
4163
|
});
|
|
3971
|
-
Object.entries(availableNamespaces).forEach(
|
|
3972
|
-
let [key, namespace] =
|
|
4164
|
+
Object.entries(availableNamespaces).forEach(_ref66 => {
|
|
4165
|
+
let [key, namespace] = _ref66;
|
|
3973
4166
|
if (namespace.chains) {
|
|
3974
4167
|
const accounts = selectedAccounts.filter(address => {
|
|
3975
4168
|
const [_namespace] = address.split(':');
|
|
@@ -3993,10 +4186,10 @@ class KoniExtension {
|
|
|
3993
4186
|
request.resolve();
|
|
3994
4187
|
return true;
|
|
3995
4188
|
}
|
|
3996
|
-
async rejectWalletConnectSession(
|
|
4189
|
+
async rejectWalletConnectSession(_ref67) {
|
|
3997
4190
|
let {
|
|
3998
4191
|
id
|
|
3999
|
-
} =
|
|
4192
|
+
} = _ref67;
|
|
4000
4193
|
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
4001
4194
|
const wcId = request.request.id;
|
|
4002
4195
|
if ((0, _helpers2.isProposalExpired)(request.request.params)) {
|
|
@@ -4018,10 +4211,10 @@ class KoniExtension {
|
|
|
4018
4211
|
});
|
|
4019
4212
|
return this.#koniState.walletConnectService.sessions;
|
|
4020
4213
|
}
|
|
4021
|
-
async disconnectWalletConnectSession(
|
|
4214
|
+
async disconnectWalletConnectSession(_ref68) {
|
|
4022
4215
|
let {
|
|
4023
4216
|
topic
|
|
4024
|
-
} =
|
|
4217
|
+
} = _ref68;
|
|
4025
4218
|
await this.#koniState.walletConnectService.disconnect(topic);
|
|
4026
4219
|
return true;
|
|
4027
4220
|
}
|
|
@@ -4034,18 +4227,18 @@ class KoniExtension {
|
|
|
4034
4227
|
});
|
|
4035
4228
|
return this.#koniState.requestService.allNotSupportWCRequests;
|
|
4036
4229
|
}
|
|
4037
|
-
approveWalletConnectNotSupport(
|
|
4230
|
+
approveWalletConnectNotSupport(_ref69) {
|
|
4038
4231
|
let {
|
|
4039
4232
|
id
|
|
4040
|
-
} =
|
|
4233
|
+
} = _ref69;
|
|
4041
4234
|
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
4042
4235
|
request.resolve();
|
|
4043
4236
|
return true;
|
|
4044
4237
|
}
|
|
4045
|
-
rejectWalletConnectNotSupport(
|
|
4238
|
+
rejectWalletConnectNotSupport(_ref70) {
|
|
4046
4239
|
let {
|
|
4047
4240
|
id
|
|
4048
|
-
} =
|
|
4241
|
+
} = _ref70;
|
|
4049
4242
|
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
4050
4243
|
request.reject(new Error('USER_REJECTED'));
|
|
4051
4244
|
return true;
|
|
@@ -4053,11 +4246,11 @@ class KoniExtension {
|
|
|
4053
4246
|
|
|
4054
4247
|
/// Manta
|
|
4055
4248
|
|
|
4056
|
-
async enableMantaPay(
|
|
4249
|
+
async enableMantaPay(_ref71) {
|
|
4057
4250
|
let {
|
|
4058
4251
|
address,
|
|
4059
4252
|
password
|
|
4060
|
-
} =
|
|
4253
|
+
} = _ref71;
|
|
4061
4254
|
// always takes the current account
|
|
4062
4255
|
function timeout() {
|
|
4063
4256
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
@@ -4147,11 +4340,11 @@ class KoniExtension {
|
|
|
4147
4340
|
async disableMantaPay(address) {
|
|
4148
4341
|
return this.#koniState.disableMantaPay(address);
|
|
4149
4342
|
}
|
|
4150
|
-
async isTonBounceableAddress(
|
|
4343
|
+
async isTonBounceableAddress(_ref72) {
|
|
4151
4344
|
let {
|
|
4152
4345
|
address,
|
|
4153
4346
|
chain
|
|
4154
|
-
} =
|
|
4347
|
+
} = _ref72;
|
|
4155
4348
|
try {
|
|
4156
4349
|
const tonApi = this.#koniState.getTonApi(chain);
|
|
4157
4350
|
const state = await tonApi.getAccountState(address);
|
|
@@ -4197,10 +4390,10 @@ class KoniExtension {
|
|
|
4197
4390
|
|
|
4198
4391
|
/* Metadata */
|
|
4199
4392
|
|
|
4200
|
-
async findRawMetadata(
|
|
4393
|
+
async findRawMetadata(_ref73) {
|
|
4201
4394
|
let {
|
|
4202
4395
|
genesisHash
|
|
4203
|
-
} =
|
|
4396
|
+
} = _ref73;
|
|
4204
4397
|
const {
|
|
4205
4398
|
metadata,
|
|
4206
4399
|
specVersion,
|
|
@@ -4214,20 +4407,20 @@ class KoniExtension {
|
|
|
4214
4407
|
userExtensions
|
|
4215
4408
|
};
|
|
4216
4409
|
}
|
|
4217
|
-
async calculateMetadataHash(
|
|
4410
|
+
async calculateMetadataHash(_ref74) {
|
|
4218
4411
|
let {
|
|
4219
4412
|
chain
|
|
4220
|
-
} =
|
|
4413
|
+
} = _ref74;
|
|
4221
4414
|
const hash = await this.#koniState.calculateMetadataHash(chain);
|
|
4222
4415
|
return {
|
|
4223
4416
|
metadataHash: hash || ''
|
|
4224
4417
|
};
|
|
4225
4418
|
}
|
|
4226
|
-
async shortenMetadata(
|
|
4419
|
+
async shortenMetadata(_ref75) {
|
|
4227
4420
|
let {
|
|
4228
4421
|
chain,
|
|
4229
4422
|
txBlob
|
|
4230
|
-
} =
|
|
4423
|
+
} = _ref75;
|
|
4231
4424
|
const shorten = await this.#koniState.shortenMetadata(chain, txBlob);
|
|
4232
4425
|
return {
|
|
4233
4426
|
txMetadata: shorten || ''
|
|
@@ -4622,18 +4815,18 @@ class KoniExtension {
|
|
|
4622
4815
|
}
|
|
4623
4816
|
/* Campaign */
|
|
4624
4817
|
|
|
4625
|
-
unlockDotCheckCanMint(
|
|
4818
|
+
unlockDotCheckCanMint(_ref76) {
|
|
4626
4819
|
let {
|
|
4627
4820
|
address,
|
|
4628
4821
|
network,
|
|
4629
4822
|
slug
|
|
4630
|
-
} =
|
|
4823
|
+
} = _ref76;
|
|
4631
4824
|
return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
|
|
4632
4825
|
}
|
|
4633
|
-
unlockDotSubscribeMintedData(id, port,
|
|
4826
|
+
unlockDotSubscribeMintedData(id, port, _ref77) {
|
|
4634
4827
|
let {
|
|
4635
4828
|
transactionId
|
|
4636
|
-
} =
|
|
4829
|
+
} = _ref77;
|
|
4637
4830
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
4638
4831
|
const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
|
|
4639
4832
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
@@ -4665,10 +4858,10 @@ class KoniExtension {
|
|
|
4665
4858
|
});
|
|
4666
4859
|
return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
|
|
4667
4860
|
}
|
|
4668
|
-
async completeCampaignBanner(
|
|
4861
|
+
async completeCampaignBanner(_ref78) {
|
|
4669
4862
|
let {
|
|
4670
4863
|
slug
|
|
4671
|
-
} =
|
|
4864
|
+
} = _ref78;
|
|
4672
4865
|
const campaign = await this.#koniState.dbService.getCampaign(slug);
|
|
4673
4866
|
if (campaign) {
|
|
4674
4867
|
await this.#koniState.dbService.upsertCampaign({
|
|
@@ -5203,8 +5396,8 @@ class KoniExtension {
|
|
|
5203
5396
|
resolve();
|
|
5204
5397
|
}
|
|
5205
5398
|
};
|
|
5206
|
-
this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(
|
|
5207
|
-
let [_unsub, rs] =
|
|
5399
|
+
this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(_ref79 => {
|
|
5400
|
+
let [_unsub, rs] = _ref79;
|
|
5208
5401
|
unsub = _unsub;
|
|
5209
5402
|
onRs(rs);
|
|
5210
5403
|
}).catch(console.error);
|
|
@@ -6104,6 +6297,8 @@ class KoniExtension {
|
|
|
6104
6297
|
return await this.cancelPendingTx(request);
|
|
6105
6298
|
case 'pri(multisig.initMultisigTx)':
|
|
6106
6299
|
return await this.initMultisigTx(request);
|
|
6300
|
+
case 'pri(multisig.prepareSignRequest)':
|
|
6301
|
+
return await this.prepareMultisigSignRequest(request);
|
|
6107
6302
|
case 'pri(multisig.getSignableAccountInfos)':
|
|
6108
6303
|
return this.#koniState.keyringService.context.getSignableAccountInfos(request);
|
|
6109
6304
|
/* Multisig Account */
|
|
@@ -83,12 +83,11 @@ function transformAccountsV2(accounts) {
|
|
|
83
83
|
let {
|
|
84
84
|
json: {
|
|
85
85
|
meta: {
|
|
86
|
-
isHidden
|
|
87
|
-
isMultisig
|
|
86
|
+
isHidden
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
} = _ref2;
|
|
91
|
-
return !isHidden
|
|
90
|
+
return !isHidden;
|
|
92
91
|
}).filter(authTypeFilter).filter(_ref3 => {
|
|
93
92
|
let {
|
|
94
93
|
json: {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -12,7 +12,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
12
12
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
13
13
|
const fetchDomain = process.env.PATCH_CHAIN_LIST_URL || (PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev');
|
|
14
14
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
15
|
-
const ChainListVersion = '0.2.
|
|
15
|
+
const ChainListVersion = '0.2.126'; // update this when build chain-list
|
|
16
16
|
|
|
17
17
|
// todo: move this interface to chainlist
|
|
18
18
|
exports.ChainListVersion = ChainListVersion;
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports._STAKING_CHAIN_GROUP = exports.TON_CHAINS = exports.ST_LIQUID_TOKEN_ABI = exports.STAKING_IDENTITY_API_SLUG = exports.RELAY_HANDLER_DIRECT_STAKING_CHAINS = exports.MaxEraRewardPointsEras = exports.MANTA_VALIDATOR_POINTS_PER_BLOCK = exports.MANTA_MIN_DELEGATION = exports.CHANNEL_ID = void 0;
|
|
6
|
+
exports._STAKING_CHAIN_GROUP = exports.TON_CHAINS = exports.SUNSETTED_YIELD_POOL_SLUGS = exports.ST_LIQUID_TOKEN_ABI = exports.STAKING_IDENTITY_API_SLUG = exports.RELAY_HANDLER_DIRECT_STAKING_CHAINS = exports.MaxEraRewardPointsEras = exports.MANTA_VALIDATOR_POINTS_PER_BLOCK = exports.MANTA_MIN_DELEGATION = exports.CHANNEL_ID = void 0;
|
|
7
|
+
var _stellaSwap = require("../handlers/liquid-staking/stella-swap");
|
|
7
8
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
9
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
10
|
|
|
@@ -29,6 +30,8 @@ const _STAKING_CHAIN_GROUP = {
|
|
|
29
30
|
tanssi: ['tanssi', 'dancelight']
|
|
30
31
|
};
|
|
31
32
|
exports._STAKING_CHAIN_GROUP = _STAKING_CHAIN_GROUP;
|
|
33
|
+
const SUNSETTED_YIELD_POOL_SLUGS = [_stellaSwap.STELLA_SWAP_LIQUID_STAKING_SLUG, 'MANTA___native_staking___manta_network'];
|
|
34
|
+
exports.SUNSETTED_YIELD_POOL_SLUGS = SUNSETTED_YIELD_POOL_SLUGS;
|
|
32
35
|
const RELAY_HANDLER_DIRECT_STAKING_CHAINS = [..._STAKING_CHAIN_GROUP.relay, ..._STAKING_CHAIN_GROUP.assetHub];
|
|
33
36
|
exports.RELAY_HANDLER_DIRECT_STAKING_CHAINS = RELAY_HANDLER_DIRECT_STAKING_CHAINS;
|
|
34
37
|
const TON_CHAINS = ['ton', 'ton_testnet'];
|