@subwallet/extension-base 1.3.41-0 → 1.3.43-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 +134 -5
- package/background/KoniTypes.js +18 -0
- package/background/errors/BitcoinProviderError.d.ts +6 -0
- package/background/errors/BitcoinProviderError.js +47 -0
- package/background/types.d.ts +1 -1
- package/cjs/background/KoniTypes.js +20 -1
- package/cjs/background/errors/BitcoinProviderError.js +54 -0
- package/cjs/constants/bitcoin.js +22 -0
- package/cjs/constants/index.js +16 -1
- package/cjs/core/logic-validation/recipientAddress.js +9 -0
- package/cjs/core/logic-validation/request.js +316 -3
- package/cjs/core/logic-validation/transfer.js +25 -5
- package/cjs/core/types.js +1 -0
- package/cjs/core/utils.js +15 -1
- package/cjs/koni/background/handlers/Extension.js +477 -93
- package/cjs/koni/background/handlers/State.js +249 -16
- package/cjs/koni/background/handlers/Tabs.js +119 -6
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/bitcoin/index.js +67 -0
- package/cjs/page/index.js +5 -0
- package/cjs/services/balance-service/helpers/subscribe/bitcoin.js +94 -0
- package/cjs/services/balance-service/helpers/subscribe/index.js +19 -7
- package/cjs/services/balance-service/index.js +32 -4
- package/cjs/services/balance-service/transfer/bitcoin-transfer.js +119 -0
- package/cjs/services/balance-service/transfer/token.js +2 -0
- package/cjs/services/base/types.js +2 -0
- package/cjs/services/buy-service/index.js +17 -2
- package/cjs/services/chain-service/constants.js +14 -3
- package/cjs/services/chain-service/handler/bitcoin/BitcoinApi.js +105 -0
- package/cjs/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +78 -0
- package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +371 -0
- package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +19 -0
- package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +368 -0
- package/cjs/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +302 -0
- package/cjs/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
- package/cjs/services/chain-service/index.js +27 -3
- package/cjs/services/chain-service/utils/index.js +57 -4
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +27 -5
- package/cjs/services/event-service/index.js +4 -0
- package/cjs/services/fee-service/service.js +8 -3
- package/cjs/services/hiro-service/index.js +96 -0
- package/cjs/services/hiro-service/utils/index.js +85 -0
- package/cjs/services/history-service/bitcoin-history.js +58 -0
- package/cjs/services/history-service/helpers/recoverHistoryStatus.js +96 -4
- package/cjs/services/history-service/index.js +41 -3
- package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
- package/cjs/services/keyring-service/context/handlers/Migration.js +2 -2
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +4 -3
- package/cjs/services/migration-service/scripts/MigrateNewUnifiedAccount.js +29 -0
- package/cjs/services/migration-service/scripts/index.js +3 -1
- package/cjs/services/request-service/handler/AuthRequestHandler.js +18 -0
- package/cjs/services/request-service/handler/BitcoinRequestHandler.js +427 -0
- package/cjs/services/request-service/index.js +29 -3
- package/cjs/services/rune-service/index.js +105 -0
- package/cjs/services/transaction-service/helpers/index.js +7 -1
- package/cjs/services/transaction-service/index.js +206 -16
- package/cjs/services/transaction-service/utils.js +6 -3
- package/cjs/strategy/api-request-strategy/context/base.js +31 -0
- package/cjs/strategy/api-request-strategy/index.js +90 -0
- package/cjs/strategy/api-request-strategy/types.js +1 -0
- package/cjs/strategy/api-request-strategy/utils/index.js +33 -0
- package/cjs/types/account/info/keyring.js +1 -1
- package/cjs/types/bitcoin.js +24 -0
- package/cjs/types/fee/bitcoin.js +1 -0
- package/cjs/types/fee/index.js +11 -0
- package/cjs/types/index.js +11 -0
- package/cjs/utils/account/analyze.js +3 -3
- package/cjs/utils/account/common.js +16 -6
- package/cjs/utils/account/derive/info/solo.js +68 -19
- package/cjs/utils/account/derive/info/unified.js +2 -0
- package/cjs/utils/account/derive/validate.js +70 -2
- package/cjs/utils/account/transform.js +11 -5
- package/cjs/utils/auth.js +2 -1
- package/cjs/utils/bitcoin/common.js +98 -0
- package/cjs/utils/bitcoin/fee.js +21 -0
- package/cjs/utils/bitcoin/index.js +38 -0
- package/cjs/utils/bitcoin/utxo-management.js +281 -0
- package/cjs/utils/fee/transfer.js +48 -0
- package/cjs/utils/index.js +15 -1
- package/constants/bitcoin.d.ts +3 -0
- package/constants/bitcoin.js +13 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +3 -1
- package/core/logic-validation/recipientAddress.js +10 -1
- package/core/logic-validation/request.d.ts +6 -2
- package/core/logic-validation/request.js +309 -3
- package/core/logic-validation/transfer.d.ts +2 -2
- package/core/logic-validation/transfer.js +27 -7
- package/core/types.d.ts +1 -0
- package/core/types.js +1 -0
- package/core/utils.d.ts +1 -0
- package/core/utils.js +15 -2
- package/koni/background/handlers/Extension.d.ts +5 -0
- package/koni/background/handlers/Extension.js +387 -9
- package/koni/background/handlers/State.d.ts +10 -3
- package/koni/background/handlers/State.js +240 -15
- package/koni/background/handlers/Tabs.d.ts +7 -2
- package/koni/background/handlers/Tabs.js +119 -9
- package/package.json +149 -8
- package/packageInfo.js +1 -1
- package/page/bitcoin/index.d.ts +17 -0
- package/page/bitcoin/index.js +60 -0
- package/page/index.d.ts +2 -1
- package/page/index.js +4 -0
- package/services/balance-service/helpers/subscribe/bitcoin.d.ts +2 -0
- package/services/balance-service/helpers/subscribe/bitcoin.js +87 -0
- package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
- package/services/balance-service/helpers/subscribe/index.js +20 -8
- package/services/balance-service/index.d.ts +2 -0
- package/services/balance-service/index.js +32 -4
- package/services/balance-service/transfer/bitcoin-transfer.d.ts +14 -0
- package/services/balance-service/transfer/bitcoin-transfer.js +112 -0
- package/services/balance-service/transfer/cardano-transfer.d.ts +2 -0
- package/services/balance-service/transfer/token.js +2 -0
- package/services/base/types.d.ts +2 -0
- package/services/base/types.js +2 -0
- package/services/buy-service/index.js +17 -2
- package/services/chain-service/constants.d.ts +6 -0
- package/services/chain-service/constants.js +8 -2
- package/services/chain-service/handler/bitcoin/BitcoinApi.d.ts +31 -0
- package/services/chain-service/handler/bitcoin/BitcoinApi.js +98 -0
- package/services/chain-service/handler/bitcoin/BitcoinChainHandler.d.ts +16 -0
- package/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +70 -0
- package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.d.ts +28 -0
- package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +362 -0
- package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.d.ts +2 -0
- package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +5 -0
- package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.d.ts +28 -0
- package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +359 -0
- package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.d.ts +28 -0
- package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +293 -0
- package/services/chain-service/handler/bitcoin/strategy/types.d.ts +291 -0
- package/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
- package/services/chain-service/index.d.ts +3 -0
- package/services/chain-service/index.js +31 -5
- package/services/chain-service/types.d.ts +20 -0
- package/services/chain-service/utils/index.d.ts +4 -0
- package/services/chain-service/utils/index.js +50 -4
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/native-staking/para-chain.js +27 -5
- package/services/event-service/index.d.ts +3 -0
- package/services/event-service/index.js +4 -0
- package/services/event-service/types.d.ts +3 -0
- package/services/fee-service/service.js +8 -3
- package/services/hiro-service/index.d.ts +17 -0
- package/services/hiro-service/index.js +88 -0
- package/services/hiro-service/utils/index.d.ts +6 -0
- package/services/hiro-service/utils/index.js +72 -0
- package/services/history-service/bitcoin-history.d.ts +4 -0
- package/services/history-service/bitcoin-history.js +52 -0
- package/services/history-service/helpers/recoverHistoryStatus.d.ts +3 -1
- package/services/history-service/helpers/recoverHistoryStatus.js +96 -4
- package/services/history-service/index.d.ts +1 -0
- package/services/history-service/index.js +42 -4
- package/services/keyring-service/context/handlers/Derive.js +2 -2
- package/services/keyring-service/context/handlers/Migration.js +2 -2
- package/services/keyring-service/context/handlers/Mnemonic.js +4 -3
- package/services/migration-service/scripts/MigrateNewUnifiedAccount.d.ts +4 -0
- package/services/migration-service/scripts/MigrateNewUnifiedAccount.js +21 -0
- package/services/migration-service/scripts/index.js +3 -1
- package/services/request-service/handler/AuthRequestHandler.js +19 -1
- package/services/request-service/handler/BitcoinRequestHandler.d.ts +22 -0
- package/services/request-service/handler/BitcoinRequestHandler.js +414 -0
- package/services/request-service/index.d.ts +8 -2
- package/services/request-service/index.js +25 -3
- package/services/rune-service/index.d.ts +17 -0
- package/services/rune-service/index.js +97 -0
- package/services/transaction-service/helpers/index.d.ts +3 -1
- package/services/transaction-service/helpers/index.js +5 -0
- package/services/transaction-service/index.d.ts +4 -5
- package/services/transaction-service/index.js +205 -17
- package/services/transaction-service/types.d.ts +13 -2
- package/services/transaction-service/utils.js +7 -4
- package/strategy/api-request-strategy/context/base.d.ts +15 -0
- package/strategy/api-request-strategy/context/base.js +24 -0
- package/strategy/api-request-strategy/index.d.ts +15 -0
- package/strategy/api-request-strategy/index.js +83 -0
- package/strategy/api-request-strategy/types.d.ts +22 -0
- package/strategy/api-request-strategy/types.js +1 -0
- package/strategy/api-request-strategy/utils/index.d.ts +2 -0
- package/strategy/api-request-strategy/utils/index.js +23 -0
- package/types/account/info/keyring.d.ts +1 -1
- package/types/account/info/keyring.js +1 -1
- package/types/balance/index.d.ts +4 -1
- package/types/balance/transfer.d.ts +19 -0
- package/types/bitcoin.d.ts +93 -0
- package/types/bitcoin.js +17 -0
- package/types/buy.d.ts +1 -1
- package/types/fee/base.d.ts +4 -1
- package/types/fee/bitcoin.d.ts +18 -0
- package/types/fee/bitcoin.js +1 -0
- package/types/fee/index.d.ts +1 -0
- package/types/fee/index.js +2 -1
- package/types/fee/subscription.d.ts +4 -3
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/utils/account/analyze.js +4 -4
- package/utils/account/common.d.ts +7 -8
- package/utils/account/common.js +16 -6
- package/utils/account/derive/info/solo.js +70 -21
- package/utils/account/derive/info/unified.js +2 -0
- package/utils/account/derive/validate.d.ts +1 -0
- package/utils/account/derive/validate.js +68 -1
- package/utils/account/transform.d.ts +1 -1
- package/utils/account/transform.js +11 -5
- package/utils/auth.js +3 -2
- package/utils/bitcoin/common.d.ts +22 -0
- package/utils/bitcoin/common.js +88 -0
- package/utils/bitcoin/fee.d.ts +2 -0
- package/utils/bitcoin/fee.js +14 -0
- package/utils/bitcoin/index.d.ts +3 -0
- package/utils/bitcoin/index.js +6 -0
- package/utils/bitcoin/utxo-management.d.ts +33 -0
- package/utils/bitcoin/utxo-management.js +266 -0
- package/utils/fee/transfer.d.ts +3 -1
- package/utils/fee/transfer.js +47 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +6 -3
|
@@ -46,10 +46,6 @@ class TransactionService {
|
|
|
46
46
|
}
|
|
47
47
|
constructor(state) {
|
|
48
48
|
this.state = state;
|
|
49
|
-
this.eventService = state.eventService;
|
|
50
|
-
this.historyService = state.historyService;
|
|
51
|
-
this.notificationService = state.notificationService;
|
|
52
|
-
this.chainService = state.chainService;
|
|
53
49
|
}
|
|
54
50
|
get allTransactions() {
|
|
55
51
|
return Object.values(this.transactions);
|
|
@@ -81,6 +77,7 @@ class TransactionService {
|
|
|
81
77
|
additionalValidator,
|
|
82
78
|
address,
|
|
83
79
|
chain,
|
|
80
|
+
chainType,
|
|
84
81
|
extrinsicType
|
|
85
82
|
} = validationResponse;
|
|
86
83
|
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
@@ -110,27 +107,32 @@ class TransactionService {
|
|
|
110
107
|
const evmApi = this.state.chainService.getEvmApi(chainInfo.slug);
|
|
111
108
|
const tonApi = this.state.chainService.getTonApi(chainInfo.slug);
|
|
112
109
|
const cardanoApi = this.state.chainService.getCardanoApi(chainInfo.slug);
|
|
110
|
+
const bitcoinApi = this.state.chainService.getBitcoinApi(chainInfo.slug);
|
|
113
111
|
// todo: should split into isEvmTx && isNoEvmApi. Because other chains type also has no Evm Api. Same to all blockchain.
|
|
114
112
|
// todo: refactor check evmTransaction.
|
|
115
|
-
const isNoEvmApi = transaction && !(0, _helpers.isSubstrateTransaction)(transaction) && !(0, _helpers.isTonTransaction)(transaction) && !(0, _helpers.isCardanoTransaction)(transaction) && !evmApi;
|
|
113
|
+
const isNoEvmApi = transaction && !(0, _helpers.isSubstrateTransaction)(transaction) && !(0, _helpers.isTonTransaction)(transaction) && !(0, _helpers.isCardanoTransaction)(transaction) && !(0, _helpers.isBitcoinTransaction)(transaction) && !evmApi;
|
|
116
114
|
const isNoTonApi = transaction && (0, _helpers.isTonTransaction)(transaction) && !tonApi;
|
|
117
115
|
const isNoCardanoApi = transaction && (0, _helpers.isCardanoTransaction)(transaction) && !cardanoApi;
|
|
118
|
-
|
|
116
|
+
const isNoBitcoinApi = transaction && (0, _helpers.isBitcoinTransaction)(transaction) && !bitcoinApi;
|
|
117
|
+
if (isNoEvmApi || isNoTonApi || isNoCardanoApi || isNoBitcoinApi) {
|
|
119
118
|
validationResponse.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
// Estimate fee for transaction
|
|
123
122
|
const id = (0, _getId.getId)();
|
|
124
|
-
const feeInfo = await this.state.feeService.subscribeChainFee(id, chain,
|
|
123
|
+
const feeInfo = await this.state.feeService.subscribeChainFee(id, chain, chainType);
|
|
125
124
|
const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(chain);
|
|
126
125
|
const tokenPayFeeSlug = transactionInput.tokenPayFeeSlug;
|
|
127
126
|
const isNonNativeTokenPayFee = tokenPayFeeSlug && !(0, _utils2._isNativeTokenBySlug)(tokenPayFeeSlug);
|
|
128
|
-
const nonNativeTokenPayFeeInfo = isNonNativeTokenPayFee ? this.chainService.getAssetBySlug(tokenPayFeeSlug) : undefined;
|
|
127
|
+
const nonNativeTokenPayFeeInfo = isNonNativeTokenPayFee ? this.state.chainService.getAssetBySlug(tokenPayFeeSlug) : undefined;
|
|
129
128
|
const priceMap = (await this.state.priceService.getPrice()).priceMap;
|
|
130
|
-
|
|
129
|
+
if (!transactionInput.skipFeeRecalculation) {
|
|
130
|
+
validationResponse.estimateFee = await (0, _transfer.estimateFeeForTransaction)(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, transactionInput.isTransferLocalTokenAndPayThatTokenAsFee);
|
|
131
|
+
}
|
|
131
132
|
const chainInfoMap = this.state.chainService.getChainInfoMap();
|
|
132
133
|
|
|
133
134
|
// Check account signing transaction
|
|
135
|
+
|
|
134
136
|
(0, _transfer.checkSigningAccountForTransaction)(validationResponse, chainInfoMap);
|
|
135
137
|
const nativeTokenAvailable = await this.state.balanceService.getTransferableBalance(address, chain, nativeTokenInfo.slug, extrinsicType);
|
|
136
138
|
|
|
@@ -193,7 +195,7 @@ class TransactionService {
|
|
|
193
195
|
}
|
|
194
196
|
fillTransactionDefaultInfo(transaction) {
|
|
195
197
|
const isInternal = !transaction.url;
|
|
196
|
-
const transactionId = (0, _helpers.getTransactionId)(transaction.chainType, transaction.chain, isInternal, (0, _helpers2.isWalletConnectRequest)(transaction.id));
|
|
198
|
+
const transactionId = transaction.id || (0, _helpers.getTransactionId)(transaction.chainType, transaction.chain, isInternal, (0, _helpers2.isWalletConnectRequest)(transaction.id));
|
|
197
199
|
return {
|
|
198
200
|
...transaction,
|
|
199
201
|
createdAt: new Date().getTime(),
|
|
@@ -307,6 +309,73 @@ class TransactionService {
|
|
|
307
309
|
'eventsHandler' in validatedTransaction && delete validatedTransaction.eventsHandler;
|
|
308
310
|
return validatedTransaction;
|
|
309
311
|
}
|
|
312
|
+
async handleTransactionAfterConfirmation(transaction) {
|
|
313
|
+
const validatedTransaction = await this.validateTransaction(transaction);
|
|
314
|
+
const stopByErrors = validatedTransaction.errors.length > 0;
|
|
315
|
+
const stopByWarnings = validatedTransaction.warnings.length > 0 && !validatedTransaction.ignoreWarnings;
|
|
316
|
+
if (stopByErrors || stopByWarnings) {
|
|
317
|
+
// @ts-ignore
|
|
318
|
+
'transaction' in validatedTransaction && delete validatedTransaction.transaction;
|
|
319
|
+
'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
|
|
320
|
+
'eventsHandler' in validatedTransaction && delete validatedTransaction.eventsHandler;
|
|
321
|
+
return validatedTransaction;
|
|
322
|
+
}
|
|
323
|
+
validatedTransaction.warnings = [];
|
|
324
|
+
const transactionsSubject = this.transactions;
|
|
325
|
+
const emitter = new _eventemitter.default();
|
|
326
|
+
|
|
327
|
+
// Fill transaction default info
|
|
328
|
+
const transactionUpdated = this.fillTransactionDefaultInfo(validatedTransaction);
|
|
329
|
+
|
|
330
|
+
// Add Transaction
|
|
331
|
+
transactionsSubject[transactionUpdated.id] = {
|
|
332
|
+
...transactionUpdated,
|
|
333
|
+
emitterTransaction: emitter
|
|
334
|
+
};
|
|
335
|
+
this.transactionSubject.next({
|
|
336
|
+
...transactionsSubject
|
|
337
|
+
});
|
|
338
|
+
emitter.on('success', data => {
|
|
339
|
+
validatedTransaction.id = data.id;
|
|
340
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
341
|
+
this.handlePostProcessing(data.id);
|
|
342
|
+
this.onSuccess(data);
|
|
343
|
+
});
|
|
344
|
+
emitter.on('signed', data => {
|
|
345
|
+
validatedTransaction.id = data.id;
|
|
346
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
347
|
+
this.onSigned(data);
|
|
348
|
+
});
|
|
349
|
+
emitter.on('error', data => {
|
|
350
|
+
if (data.errors.length > 0) {
|
|
351
|
+
validatedTransaction.errors.push(...data.errors);
|
|
352
|
+
}
|
|
353
|
+
this.onFailed({
|
|
354
|
+
...data,
|
|
355
|
+
errors: [...data.errors, new _TransactionError.TransactionError(_types.BasicTxErrorType.INTERNAL_ERROR)]
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
emitter.on('send', data => {
|
|
359
|
+
this.onSend(data);
|
|
360
|
+
});
|
|
361
|
+
emitter.on('extrinsicHash', data => {
|
|
362
|
+
this.onHasTransactionHash(data);
|
|
363
|
+
});
|
|
364
|
+
emitter.on('timeout', data => {
|
|
365
|
+
this.onTimeOut({
|
|
366
|
+
...data,
|
|
367
|
+
errors: [...data.errors, new _TransactionError.TransactionError(_types.BasicTxErrorType.TIMEOUT)]
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// @ts-ignore
|
|
372
|
+
'transaction' in validatedTransaction && delete validatedTransaction.transaction;
|
|
373
|
+
'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
|
|
374
|
+
'eventsHandler' in validatedTransaction && delete validatedTransaction.eventsHandler;
|
|
375
|
+
return {
|
|
376
|
+
...validatedTransaction
|
|
377
|
+
};
|
|
378
|
+
}
|
|
310
379
|
async handlePermitTransaction(transaction) {
|
|
311
380
|
var _transaction$step;
|
|
312
381
|
const transactionId = (0, _helpers.getTransactionId)(transaction.chainType, transaction.chain, true);
|
|
@@ -417,7 +486,7 @@ class TransactionService {
|
|
|
417
486
|
}
|
|
418
487
|
async sendTransaction(transaction) {
|
|
419
488
|
// Send Transaction
|
|
420
|
-
const emitter = await (transaction.chainType === 'substrate' ? this.signAndSendSubstrateTransaction(transaction) : transaction.chainType === 'evm' ? this.signAndSendEvmTransaction(transaction) : transaction.chainType === 'cardano' ? this.signAndSendCardanoTransaction(transaction) : this.signAndSendTonTransaction(transaction));
|
|
489
|
+
const emitter = await (transaction.chainType === 'substrate' ? this.signAndSendSubstrateTransaction(transaction) : transaction.chainType === 'evm' ? this.signAndSendEvmTransaction(transaction) : transaction.chainType === 'cardano' ? this.signAndSendCardanoTransaction(transaction) : transaction.chainType === 'ton' ? this.signAndSendTonTransaction(transaction) : this.signAndSendBitcoinTransaction(transaction));
|
|
421
490
|
const {
|
|
422
491
|
eventsHandler,
|
|
423
492
|
step
|
|
@@ -676,6 +745,7 @@ class TransactionService {
|
|
|
676
745
|
extrinsicHash: transaction.extrinsicHash,
|
|
677
746
|
time: transaction.createdAt,
|
|
678
747
|
fee: transaction.estimateFee,
|
|
748
|
+
blockTime: undefined,
|
|
679
749
|
blockNumber: 0,
|
|
680
750
|
// Will be added in next step
|
|
681
751
|
blockHash: '',
|
|
@@ -1065,6 +1135,24 @@ class TransactionService {
|
|
|
1065
1135
|
if ([_KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_BOND, _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL, _KoniTypes.ExtrinsicType.MINT_LDOT, _KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.ExtrinsicType.MINT_SDOT, _KoniTypes.ExtrinsicType.MINT_STDOT, _KoniTypes.ExtrinsicType.MINT_VDOT, _KoniTypes.ExtrinsicType.MINT_VMANTA].includes(transaction.extrinsicType)) {
|
|
1066
1136
|
this.handlePostEarningTransaction(id);
|
|
1067
1137
|
}
|
|
1138
|
+
|
|
1139
|
+
// Trigger balance update for Bitcoin transactions after receiving extrinsicHash
|
|
1140
|
+
if (_KoniTypes.ExtrinsicType.TRANSFER_BALANCE && transaction.chainType === 'bitcoin') {
|
|
1141
|
+
const balanceService = this.state.balanceService;
|
|
1142
|
+
const inputData = (0, _utils3.parseTransactionData)(transaction.data);
|
|
1143
|
+
try {
|
|
1144
|
+
const sender = _uiKeyring.default.getPair(inputData.from);
|
|
1145
|
+
balanceService.refreshBalanceForAddress(sender.address, transaction.chain, inputData.tokenSlug, transaction.extrinsicType).catch(error => console.error('Failed to run balance subscription:', error));
|
|
1146
|
+
} catch (e) {
|
|
1147
|
+
console.error(e);
|
|
1148
|
+
}
|
|
1149
|
+
try {
|
|
1150
|
+
const recipient = _uiKeyring.default.getPair(inputData.to);
|
|
1151
|
+
balanceService.refreshBalanceForAddress(recipient.address, transaction.chain, inputData.tokenSlug, transaction.extrinsicType).catch(error => console.error('Failed to run balance subscription:', error));
|
|
1152
|
+
} catch (e) {
|
|
1153
|
+
console.error(e);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1068
1156
|
}
|
|
1069
1157
|
handlePostProcessing(id) {
|
|
1070
1158
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -1104,6 +1192,7 @@ class TransactionService {
|
|
|
1104
1192
|
let {
|
|
1105
1193
|
blockHash,
|
|
1106
1194
|
blockNumber,
|
|
1195
|
+
blockTime,
|
|
1107
1196
|
extrinsicHash,
|
|
1108
1197
|
id
|
|
1109
1198
|
} = _ref4;
|
|
@@ -1118,7 +1207,8 @@ class TransactionService {
|
|
|
1118
1207
|
extrinsicHash,
|
|
1119
1208
|
status: _KoniTypes.ExtrinsicStatus.SUCCESS,
|
|
1120
1209
|
blockNumber: blockNumber || 0,
|
|
1121
|
-
blockHash: blockHash || ''
|
|
1210
|
+
blockHash: blockHash || '',
|
|
1211
|
+
blockTime
|
|
1122
1212
|
}).catch(console.error);
|
|
1123
1213
|
const info = (0, _util.isHex)(extrinsicHash) ? extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.state.chainService.getChainInfoMap());
|
|
1124
1214
|
this.state.notificationService.notify({
|
|
@@ -1193,14 +1283,14 @@ class TransactionService {
|
|
|
1193
1283
|
errors,
|
|
1194
1284
|
extrinsicHash
|
|
1195
1285
|
});
|
|
1196
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
1286
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
1197
1287
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
1198
1288
|
status: nextStatus,
|
|
1199
1289
|
blockNumber: blockNumber || 0,
|
|
1200
1290
|
blockHash: blockHash || ''
|
|
1201
1291
|
}).catch(console.error);
|
|
1202
|
-
const info = (0, _util.isHex)(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.chainService.getChainInfoMap());
|
|
1203
|
-
this.notificationService.notify({
|
|
1292
|
+
const info = (0, _util.isHex)(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : (0, _helpers.getBaseTransactionInfo)(transaction, this.state.chainService.getChainInfoMap());
|
|
1293
|
+
this.state.notificationService.notify({
|
|
1204
1294
|
type: _KoniTypes.NotificationType.ERROR,
|
|
1205
1295
|
title: (0, _i18next.t)('Transaction timed out'),
|
|
1206
1296
|
message: (0, _i18next.t)('Transaction {{info}} timed out', {
|
|
@@ -1214,7 +1304,7 @@ class TransactionService {
|
|
|
1214
1304
|
notifyViaBrowser: true
|
|
1215
1305
|
});
|
|
1216
1306
|
}
|
|
1217
|
-
this.eventService.emit('transaction.timeout', transaction);
|
|
1307
|
+
this.state.eventService.emit('transaction.timeout', transaction);
|
|
1218
1308
|
}
|
|
1219
1309
|
generateHashPayload(chain, transaction) {
|
|
1220
1310
|
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
@@ -1894,6 +1984,106 @@ class TransactionService {
|
|
|
1894
1984
|
});
|
|
1895
1985
|
return emitter;
|
|
1896
1986
|
}
|
|
1987
|
+
emitterEventTransaction = (emitter, eventData, chain, payload) => {
|
|
1988
|
+
// Emit signed event
|
|
1989
|
+
emitter.emit('signed', eventData);
|
|
1990
|
+
// Add start info
|
|
1991
|
+
emitter.emit('send', eventData);
|
|
1992
|
+
const event = this.state.chainService.getBitcoinApi(chain).api.sendRawTransaction(payload);
|
|
1993
|
+
event.on('extrinsicHash', txHash => {
|
|
1994
|
+
eventData.extrinsicHash = txHash;
|
|
1995
|
+
emitter.emit('extrinsicHash', eventData);
|
|
1996
|
+
});
|
|
1997
|
+
event.on('success', transactionStatus => {
|
|
1998
|
+
console.log(transactionStatus);
|
|
1999
|
+
eventData.blockHash = transactionStatus.block_hash || undefined;
|
|
2000
|
+
eventData.blockNumber = transactionStatus.block_height || undefined;
|
|
2001
|
+
eventData.blockTime = transactionStatus.block_time ? transactionStatus.block_time * 1000 : undefined;
|
|
2002
|
+
emitter.emit('success', eventData);
|
|
2003
|
+
});
|
|
2004
|
+
event.on('error', error => {
|
|
2005
|
+
eventData.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.UNABLE_TO_SEND, error));
|
|
2006
|
+
emitter.emit('error', eventData);
|
|
2007
|
+
});
|
|
2008
|
+
};
|
|
2009
|
+
signAndSendBitcoinTransaction(_ref22) {
|
|
2010
|
+
let {
|
|
2011
|
+
address,
|
|
2012
|
+
chain,
|
|
2013
|
+
id,
|
|
2014
|
+
transaction,
|
|
2015
|
+
url
|
|
2016
|
+
} = _ref22;
|
|
2017
|
+
const tx = transaction;
|
|
2018
|
+
// const bitcoinApi = this.state.chainService.getBitcoinApi(chain);
|
|
2019
|
+
// const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
2020
|
+
|
|
2021
|
+
const accountPair = _uiKeyring.default.getPair(address);
|
|
2022
|
+
const account = (0, _utils4.pairToAccount)(accountPair);
|
|
2023
|
+
const payload = {
|
|
2024
|
+
payload: undefined,
|
|
2025
|
+
payloadJson: undefined,
|
|
2026
|
+
address,
|
|
2027
|
+
canSign: true,
|
|
2028
|
+
hashPayload: tx.toHex(),
|
|
2029
|
+
id
|
|
2030
|
+
};
|
|
2031
|
+
const emitter = new _eventemitter.default();
|
|
2032
|
+
const eventData = {
|
|
2033
|
+
id,
|
|
2034
|
+
errors: [],
|
|
2035
|
+
warnings: [],
|
|
2036
|
+
extrinsicHash: id
|
|
2037
|
+
};
|
|
2038
|
+
const isInjected = !!account.isInjected;
|
|
2039
|
+
// const isExternal = !!account.isExternal;
|
|
2040
|
+
|
|
2041
|
+
if (isInjected) {
|
|
2042
|
+
throw new _TransactionError.TransactionError(_types.BasicTxErrorType.UNSUPPORTED);
|
|
2043
|
+
} else {
|
|
2044
|
+
this.state.requestService.addConfirmationBitcoin(id, url || _constants2.EXTENSION_REQUEST_URL, 'bitcoinSendTransactionRequest', payload, {}).then(_ref23 => {
|
|
2045
|
+
let {
|
|
2046
|
+
isApproved,
|
|
2047
|
+
payload
|
|
2048
|
+
} = _ref23;
|
|
2049
|
+
if (isApproved) {
|
|
2050
|
+
if (!payload) {
|
|
2051
|
+
throw new Error('Bad signature');
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
// Emit signed event
|
|
2055
|
+
emitter.emit('signed', eventData);
|
|
2056
|
+
// Add start info
|
|
2057
|
+
emitter.emit('send', eventData);
|
|
2058
|
+
const bitcoinApi = this.state.chainService.getBitcoinApi(chain);
|
|
2059
|
+
const event = bitcoinApi.api.sendRawTransaction(payload);
|
|
2060
|
+
event.on('extrinsicHash', txHash => {
|
|
2061
|
+
eventData.extrinsicHash = txHash;
|
|
2062
|
+
emitter.emit('extrinsicHash', eventData);
|
|
2063
|
+
});
|
|
2064
|
+
event.on('success', transactionStatus => {
|
|
2065
|
+
eventData.blockHash = transactionStatus.block_hash || undefined;
|
|
2066
|
+
eventData.blockNumber = transactionStatus.block_height || undefined;
|
|
2067
|
+
eventData.blockTime = transactionStatus.block_time ? transactionStatus.block_time * 1000 : undefined;
|
|
2068
|
+
emitter.emit('success', eventData);
|
|
2069
|
+
});
|
|
2070
|
+
event.on('error', error => {
|
|
2071
|
+
eventData.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.UNABLE_TO_SEND, error));
|
|
2072
|
+
emitter.emit('error', eventData);
|
|
2073
|
+
});
|
|
2074
|
+
} else {
|
|
2075
|
+
this.removeTransaction(id);
|
|
2076
|
+
eventData.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.USER_REJECT_REQUEST));
|
|
2077
|
+
emitter.emit('error', eventData);
|
|
2078
|
+
}
|
|
2079
|
+
}).catch(e => {
|
|
2080
|
+
this.removeTransaction(id);
|
|
2081
|
+
eventData.errors.push(new _TransactionError.TransactionError(_types.BasicTxErrorType.UNABLE_TO_SIGN, e.message));
|
|
2082
|
+
emitter.emit('error', eventData);
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
return emitter;
|
|
2086
|
+
}
|
|
1897
2087
|
handleTransactionTimeout(emitter, eventData) {
|
|
1898
2088
|
const timeout = setTimeout(() => {
|
|
1899
2089
|
const transaction = this.getTransaction(eventData.id);
|
|
@@ -37,8 +37,8 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
37
37
|
if (explorerLink.includes('statescan.io')) {
|
|
38
38
|
return '#/accounts';
|
|
39
39
|
}
|
|
40
|
-
if (explorerLink.includes('explorer.
|
|
41
|
-
return '
|
|
40
|
+
if (explorerLink.includes('explorer.gen6.app')) {
|
|
41
|
+
return '#/accounts';
|
|
42
42
|
}
|
|
43
43
|
if (explorerLink.includes('astral.autonomys')) {
|
|
44
44
|
return 'accounts';
|
|
@@ -49,7 +49,7 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
49
49
|
return 'address';
|
|
50
50
|
}
|
|
51
51
|
function getBlockExplorerTxRoute(chainInfo) {
|
|
52
|
-
if ((0, _utils._isPureEvmChain)(chainInfo)) {
|
|
52
|
+
if ((0, _utils._isPureEvmChain)(chainInfo) || (0, _utils._isPureBitcoinChain)(chainInfo)) {
|
|
53
53
|
return 'tx';
|
|
54
54
|
}
|
|
55
55
|
if ((0, _utils._isPureCardanoChain)(chainInfo)) {
|
|
@@ -58,6 +58,9 @@ function getBlockExplorerTxRoute(chainInfo) {
|
|
|
58
58
|
if (['aventus', 'deeper_network'].includes(chainInfo.slug)) {
|
|
59
59
|
return 'transaction';
|
|
60
60
|
}
|
|
61
|
+
if (['gen6_public'].includes(chainInfo.slug)) {
|
|
62
|
+
return '#/extrinsics';
|
|
63
|
+
}
|
|
61
64
|
const explorerLink = (0, _utils._getBlockExplorerFromChain)(chainInfo);
|
|
62
65
|
if (explorerLink && explorerLink.includes('statescan.io')) {
|
|
63
66
|
return '#/extrinsics';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BaseApiRequestContext = void 0;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
class BaseApiRequestContext {
|
|
11
|
+
callRate = 2; // limit per interval check
|
|
12
|
+
limitRate = 2; // max rate per interval check
|
|
13
|
+
intervalCheck = 1000; // interval check in ms
|
|
14
|
+
maxRetry = 9; // interval check in ms
|
|
15
|
+
rollbackRateTime = 30 * 1000; // rollback rate time in ms
|
|
16
|
+
timeoutRollbackRate = undefined;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.callRate = (options === null || options === void 0 ? void 0 : options.limitRate) || this.callRate;
|
|
19
|
+
this.limitRate = (options === null || options === void 0 ? void 0 : options.limitRate) || this.limitRate;
|
|
20
|
+
this.intervalCheck = (options === null || options === void 0 ? void 0 : options.intervalCheck) || this.intervalCheck;
|
|
21
|
+
this.maxRetry = (options === null || options === void 0 ? void 0 : options.maxRetry) || this.maxRetry;
|
|
22
|
+
}
|
|
23
|
+
reduceLimitRate() {
|
|
24
|
+
clearTimeout(this.timeoutRollbackRate);
|
|
25
|
+
this.callRate = Math.ceil(this.limitRate / 2);
|
|
26
|
+
this.timeoutRollbackRate = setTimeout(() => {
|
|
27
|
+
this.callRate = this.limitRate;
|
|
28
|
+
}, this.rollbackRateTime);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BaseApiRequestContext = BaseApiRequestContext;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BaseApiRequestStrategy = void 0;
|
|
7
|
+
var _SWError = require("@subwallet/extension-base/background/errors/SWError");
|
|
8
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
9
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
|
|
11
|
+
class BaseApiRequestStrategy {
|
|
12
|
+
nextId = 0;
|
|
13
|
+
isRunning = false;
|
|
14
|
+
requestMap = {};
|
|
15
|
+
processInterval = undefined;
|
|
16
|
+
getId() {
|
|
17
|
+
return this.nextId++;
|
|
18
|
+
}
|
|
19
|
+
constructor(context) {
|
|
20
|
+
this.context = context;
|
|
21
|
+
}
|
|
22
|
+
addRequest(run, ordinal) {
|
|
23
|
+
const newId = this.getId();
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
this.requestMap[newId] = {
|
|
26
|
+
id: newId,
|
|
27
|
+
status: 'pending',
|
|
28
|
+
retry: -1,
|
|
29
|
+
ordinal,
|
|
30
|
+
run,
|
|
31
|
+
resolve,
|
|
32
|
+
reject
|
|
33
|
+
};
|
|
34
|
+
if (!this.isRunning) {
|
|
35
|
+
this.process();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
process() {
|
|
40
|
+
this.stop();
|
|
41
|
+
this.isRunning = true;
|
|
42
|
+
const maxRetry = this.context.maxRetry;
|
|
43
|
+
const interval = setInterval(() => {
|
|
44
|
+
const remainingRequests = Object.values(this.requestMap);
|
|
45
|
+
if (remainingRequests.length === 0) {
|
|
46
|
+
this.isRunning = false;
|
|
47
|
+
clearInterval(interval);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Get first this.limit requests base on id
|
|
52
|
+
const requests = remainingRequests.filter(request => request.status !== 'running').sort((a, b) => a.id - b.id).sort((a, b) => a.ordinal - b.ordinal).slice(0, this.context.callRate);
|
|
53
|
+
|
|
54
|
+
// Start requests
|
|
55
|
+
requests.forEach(request => {
|
|
56
|
+
request.status = 'running';
|
|
57
|
+
request.run().then(rs => {
|
|
58
|
+
request.resolve(rs);
|
|
59
|
+
}).catch(e => {
|
|
60
|
+
const isRateLimited = this.isRateLimited(e);
|
|
61
|
+
|
|
62
|
+
// Limit rate
|
|
63
|
+
if (isRateLimited) {
|
|
64
|
+
if (request.retry < maxRetry) {
|
|
65
|
+
request.status = 'pending';
|
|
66
|
+
request.retry++;
|
|
67
|
+
this.context.reduceLimitRate();
|
|
68
|
+
} else {
|
|
69
|
+
// Reject request
|
|
70
|
+
request.reject(new _SWError.SWError('MAX_RETRY', String(e)));
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
request.reject(new _SWError.SWError('UNKNOWN', String(e)));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}, this.context.intervalCheck);
|
|
78
|
+
this.processInterval = interval;
|
|
79
|
+
}
|
|
80
|
+
stop() {
|
|
81
|
+
clearInterval(this.processInterval);
|
|
82
|
+
this.processInterval = undefined;
|
|
83
|
+
}
|
|
84
|
+
setContext(context) {
|
|
85
|
+
this.stop();
|
|
86
|
+
this.context = context;
|
|
87
|
+
this.process();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.BaseApiRequestStrategy = BaseApiRequestStrategy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.postRequest = exports.getRequest = void 0;
|
|
8
|
+
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
const postRequest = function (url, body, headers) {
|
|
13
|
+
let jsonBody = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
14
|
+
return (0, _crossFetch.default)(url, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: headers || {
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
},
|
|
19
|
+
body: jsonBody ? JSON.stringify(body) : body
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.postRequest = postRequest;
|
|
23
|
+
const getRequest = (url, params, headers) => {
|
|
24
|
+
const queryString = params ? Object.keys(params).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join('&') : '';
|
|
25
|
+
const _url = `${url}?${queryString}`;
|
|
26
|
+
return (0, _crossFetch.default)(_url, {
|
|
27
|
+
method: 'GET',
|
|
28
|
+
headers: headers || {
|
|
29
|
+
'Content-Type': 'application/json'
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getRequest = getRequest;
|
|
@@ -77,7 +77,7 @@ const ACCOUNT_CHAIN_TYPE_ORDINAL_MAP = {
|
|
|
77
77
|
[AccountChainType.BITCOIN]: 5
|
|
78
78
|
};
|
|
79
79
|
exports.ACCOUNT_CHAIN_TYPE_ORDINAL_MAP = ACCOUNT_CHAIN_TYPE_ORDINAL_MAP;
|
|
80
|
-
const SUPPORTED_ACCOUNT_CHAIN_TYPES = [
|
|
80
|
+
const SUPPORTED_ACCOUNT_CHAIN_TYPES = [AccountChainType.SUBSTRATE, AccountChainType.ETHEREUM, AccountChainType.TON, AccountChainType.CARDANO, AccountChainType.BITCOIN];
|
|
81
81
|
exports.SUPPORTED_ACCOUNT_CHAIN_TYPES = SUPPORTED_ACCOUNT_CHAIN_TYPES;
|
|
82
82
|
let AccountActions;
|
|
83
83
|
/**
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InsufficientFundsError = void 0;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
// https://github.com/leather-wallet/extension/blob/dev/src/app/query/bitcoin/bitcoin-client.ts
|
|
11
|
+
|
|
12
|
+
// https://github.com/leather-wallet/extension/blob/dev/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts
|
|
13
|
+
|
|
14
|
+
// https://github.com/leather-wallet/extension/blob/dev/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts
|
|
15
|
+
class InsufficientFundsError extends Error {
|
|
16
|
+
constructor() {
|
|
17
|
+
super('Insufficient funds');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Source: https://github.com/Blockstream/esplora/blob/master/API.md#transaction-format
|
|
21
|
+
// ---------------
|
|
22
|
+
|
|
23
|
+
// ---------------
|
|
24
|
+
exports.InsufficientFundsError = InsufficientFundsError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/cjs/types/fee/index.js
CHANGED
|
@@ -57,4 +57,15 @@ Object.keys(_substrate).forEach(function (key) {
|
|
|
57
57
|
return _substrate[key];
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
});
|
|
61
|
+
var _bitcoin = require("./bitcoin");
|
|
62
|
+
Object.keys(_bitcoin).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _bitcoin[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _bitcoin[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
60
71
|
});
|
package/cjs/types/index.js
CHANGED
|
@@ -167,4 +167,15 @@ Object.keys(_setting).forEach(function (key) {
|
|
|
167
167
|
return _setting[key];
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
|
+
});
|
|
171
|
+
var _bitcoin = require("./bitcoin");
|
|
172
|
+
Object.keys(_bitcoin).forEach(function (key) {
|
|
173
|
+
if (key === "default" || key === "__esModule") return;
|
|
174
|
+
if (key in exports && exports[key] === _bitcoin[key]) return;
|
|
175
|
+
Object.defineProperty(exports, key, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return _bitcoin[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
170
181
|
});
|
|
@@ -7,6 +7,7 @@ exports._analyzeAddress = void 0;
|
|
|
7
7
|
var _domain = require("@subwallet/extension-base/koni/api/dotsama/domain");
|
|
8
8
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
9
9
|
var _types = require("@subwallet/extension-base/types");
|
|
10
|
+
var _keyring = require("@subwallet/keyring");
|
|
10
11
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
11
12
|
var _common = require("./common");
|
|
12
13
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
@@ -57,14 +58,13 @@ const _analyzeAddress = async (data, accountProxies, contacts, chainInfo, substr
|
|
|
57
58
|
const chain = chainInfo.slug;
|
|
58
59
|
const _data = data.trim().toLowerCase();
|
|
59
60
|
const options = [];
|
|
60
|
-
const currentChainType = (0, _utils._chainInfoToChainType)(chainInfo);
|
|
61
61
|
let current;
|
|
62
62
|
|
|
63
63
|
// Filter account proxies
|
|
64
64
|
for (const accountProxy of accountProxies) {
|
|
65
65
|
const _name = accountProxy.name.trim().toLowerCase();
|
|
66
66
|
const nameCondition = isNameValid(_data, _name);
|
|
67
|
-
const filterAccounts = accountProxy.accounts.filter(account => account.chainType
|
|
67
|
+
const filterAccounts = accountProxy.accounts.filter(account => (0, _utils._isChainInfoCompatibleWithAccountInfo)(chainInfo, account.chainType, account.type));
|
|
68
68
|
for (const account of filterAccounts) {
|
|
69
69
|
const addressCondition = isStrValidWithAddress(_data, account, chainInfo);
|
|
70
70
|
const condition = nameCondition !== 'invalid' ? nameCondition : addressCondition;
|
|
@@ -92,7 +92,7 @@ const _analyzeAddress = async (data, accountProxies, contacts, chainInfo, substr
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
const filterContacts = contacts.filter(contact => contact.chainType
|
|
95
|
+
const filterContacts = contacts.filter(contact => (0, _utils._isChainInfoCompatibleWithAccountInfo)(chainInfo, contact.chainType, (0, _keyring.getKeypairTypeByAddress)(contact.address)));
|
|
96
96
|
|
|
97
97
|
// Filter address book addresses
|
|
98
98
|
for (const contact of filterContacts) {
|