@subwallet/extension-base 1.3.41-0 → 1.3.42-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 +121 -4
- package/background/KoniTypes.js +18 -0
- package/background/errors/BitcoinProviderError.d.ts +6 -0
- package/background/errors/BitcoinProviderError.js +47 -0
- 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/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 +59 -3
- package/cjs/koni/background/handlers/State.js +52 -11
- package/cjs/packageInfo.js +1 -1
- 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/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/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/BitcoinRequestHandler.js +440 -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 +136 -15
- 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/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/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 +2 -0
- package/koni/background/handlers/Extension.js +58 -4
- package/koni/background/handlers/State.d.ts +7 -3
- package/koni/background/handlers/State.js +52 -12
- package/package.json +144 -8
- package/packageInfo.js +1 -1
- 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/token.js +2 -0
- package/services/base/types.d.ts +2 -0
- package/services/base/types.js +2 -0
- 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/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/BitcoinRequestHandler.d.ts +23 -0
- package/services/request-service/handler/BitcoinRequestHandler.js +427 -0
- package/services/request-service/index.d.ts +9 -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 +3 -5
- package/services/transaction-service/index.js +135 -16
- package/services/transaction-service/types.d.ts +12 -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 +17 -0
- package/types/bitcoin.d.ts +93 -0
- package/types/bitcoin.js +17 -0
- 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/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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export interface UtxoResponseItem {
|
|
2
|
+
txid: string;
|
|
3
|
+
vout: number;
|
|
4
|
+
status: {
|
|
5
|
+
confirmed: boolean;
|
|
6
|
+
block_height?: number;
|
|
7
|
+
block_hash?: string;
|
|
8
|
+
block_time?: number;
|
|
9
|
+
};
|
|
10
|
+
value: number;
|
|
11
|
+
}
|
|
12
|
+
export interface DetermineUtxosForSpendArgs {
|
|
13
|
+
sender: string;
|
|
14
|
+
amount: number;
|
|
15
|
+
feeRate: number;
|
|
16
|
+
recipient: string;
|
|
17
|
+
utxos: UtxoResponseItem[];
|
|
18
|
+
}
|
|
19
|
+
interface DetermineUtxosOutput {
|
|
20
|
+
value: number;
|
|
21
|
+
address?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface DetermineUtxosForSpendResult {
|
|
24
|
+
filteredUtxos: UtxoResponseItem[];
|
|
25
|
+
inputs: UtxoResponseItem[];
|
|
26
|
+
outputs: DetermineUtxosOutput[];
|
|
27
|
+
size: number;
|
|
28
|
+
fee: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class InsufficientFundsError extends Error {
|
|
31
|
+
constructor();
|
|
32
|
+
}
|
|
33
|
+
interface BitcoinTransactionIssuance {
|
|
34
|
+
asset_id: string;
|
|
35
|
+
is_reissuance: boolean;
|
|
36
|
+
asset_blinding_nonce: number;
|
|
37
|
+
asset_entropy: number;
|
|
38
|
+
contract_hash: string;
|
|
39
|
+
assetamount?: number;
|
|
40
|
+
assetamountcommitment?: number;
|
|
41
|
+
tokenamount?: number;
|
|
42
|
+
tokenamountcommitment?: number;
|
|
43
|
+
}
|
|
44
|
+
interface BitcoinTransactionPegOut {
|
|
45
|
+
genesis_hash: string;
|
|
46
|
+
scriptpubkey: string;
|
|
47
|
+
scriptpubkey_asm: string;
|
|
48
|
+
scriptpubkey_address: string;
|
|
49
|
+
}
|
|
50
|
+
export interface BitcoinTransactionStatus {
|
|
51
|
+
confirmed: boolean;
|
|
52
|
+
block_height?: number | null;
|
|
53
|
+
block_hash?: string | null;
|
|
54
|
+
block_time?: number | null;
|
|
55
|
+
}
|
|
56
|
+
export interface BitcoinTransactionVectorOutput {
|
|
57
|
+
scriptpubkey: string;
|
|
58
|
+
scriptpubkey_asm: string;
|
|
59
|
+
scriptpubkey_type: string;
|
|
60
|
+
scriptpubkey_address: string;
|
|
61
|
+
value: number;
|
|
62
|
+
valuecommitment?: number;
|
|
63
|
+
asset?: string;
|
|
64
|
+
assetcommitment?: number;
|
|
65
|
+
pegout?: BitcoinTransactionPegOut | null;
|
|
66
|
+
}
|
|
67
|
+
export interface BitcoinTransactionVectorInput {
|
|
68
|
+
inner_redeemscript_asm?: string;
|
|
69
|
+
inner_witnessscript_asm?: string;
|
|
70
|
+
is_coinbase: boolean;
|
|
71
|
+
is_pegin?: boolean;
|
|
72
|
+
issuance?: BitcoinTransactionIssuance | null;
|
|
73
|
+
prevout: BitcoinTransactionVectorOutput;
|
|
74
|
+
scriptsig: string;
|
|
75
|
+
scriptsig_asm: string;
|
|
76
|
+
sequence: number;
|
|
77
|
+
txid: string;
|
|
78
|
+
vout: number;
|
|
79
|
+
witness: string[];
|
|
80
|
+
}
|
|
81
|
+
export interface BitcoinTx {
|
|
82
|
+
fee: number;
|
|
83
|
+
locktime: number;
|
|
84
|
+
size: number;
|
|
85
|
+
status: BitcoinTransactionStatus;
|
|
86
|
+
tx_type?: string;
|
|
87
|
+
txid: string;
|
|
88
|
+
version: number;
|
|
89
|
+
vin: BitcoinTransactionVectorInput[];
|
|
90
|
+
vout: BitcoinTransactionVectorOutput[];
|
|
91
|
+
weight: number;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
package/types/bitcoin.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// https://github.com/leather-wallet/extension/blob/dev/src/app/query/bitcoin/bitcoin-client.ts
|
|
5
|
+
|
|
6
|
+
// https://github.com/leather-wallet/extension/blob/dev/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts
|
|
7
|
+
|
|
8
|
+
// https://github.com/leather-wallet/extension/blob/dev/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts
|
|
9
|
+
export class InsufficientFundsError extends Error {
|
|
10
|
+
constructor() {
|
|
11
|
+
super('Insufficient funds');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// Source: https://github.com/Blockstream/esplora/blob/master/API.md#transaction-format
|
|
15
|
+
// ---------------
|
|
16
|
+
|
|
17
|
+
// ---------------
|
package/types/fee/base.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare type FeeChainType = 'evm' | 'substrate' | 'ton' | 'cardano';
|
|
1
|
+
export declare type FeeChainType = 'evm' | 'substrate' | 'ton' | 'cardano' | 'bitcoin';
|
|
2
2
|
export interface BaseFeeInfo {
|
|
3
3
|
busyNetwork: boolean;
|
|
4
4
|
type: FeeChainType;
|
|
@@ -6,3 +6,6 @@ export interface BaseFeeInfo {
|
|
|
6
6
|
export interface BaseFeeDetail {
|
|
7
7
|
estimatedFee: string;
|
|
8
8
|
}
|
|
9
|
+
export interface BaseFeeTime {
|
|
10
|
+
time: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseFeeDetail, BaseFeeInfo, BaseFeeTime } from './base';
|
|
2
|
+
import { FeeDefaultOption } from './option';
|
|
3
|
+
export interface BitcoinFeeRate {
|
|
4
|
+
feeRate: number;
|
|
5
|
+
}
|
|
6
|
+
export declare type BitcoinFeeRateDetail = BitcoinFeeRate & BaseFeeTime;
|
|
7
|
+
export interface BitcoinFeeInfo extends BaseFeeInfo {
|
|
8
|
+
type: 'bitcoin';
|
|
9
|
+
options: {
|
|
10
|
+
slow: BitcoinFeeRateDetail;
|
|
11
|
+
average: BitcoinFeeRateDetail;
|
|
12
|
+
fast: BitcoinFeeRateDetail;
|
|
13
|
+
default: FeeDefaultOption;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface BitcoinFeeDetail extends BitcoinFeeInfo, BaseFeeDetail {
|
|
17
|
+
vSize: number;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/fee/index.d.ts
CHANGED
package/types/fee/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { BitcoinFeeDetail, BitcoinFeeInfo, BitcoinFeeRate } from '@subwallet/extension-base/types';
|
|
1
2
|
import { BehaviorSubject } from 'rxjs';
|
|
2
3
|
import { CardanoFeeDetail, CardanoFeeInfo, CardanoTipInfo } from './cardano';
|
|
3
4
|
import { EvmEIP1559FeeOption, EvmFeeDetail, EvmFeeInfo } from './evm';
|
|
4
5
|
import { SubstrateFeeDetail, SubstrateFeeInfo, SubstrateTipInfo } from './substrate';
|
|
5
6
|
import { TonFeeDetail, TonFeeInfo, TonTipInfo } from './ton';
|
|
6
|
-
export declare type FeeInfo = EvmFeeInfo | SubstrateFeeInfo | TonFeeInfo | CardanoFeeInfo;
|
|
7
|
-
export declare type FeeDetail = EvmFeeDetail | SubstrateFeeDetail | TonFeeDetail | CardanoFeeDetail;
|
|
8
|
-
export declare type FeeCustom = EvmEIP1559FeeOption | SubstrateTipInfo | TonTipInfo | CardanoTipInfo;
|
|
7
|
+
export declare type FeeInfo = EvmFeeInfo | SubstrateFeeInfo | TonFeeInfo | CardanoFeeInfo | BitcoinFeeInfo;
|
|
8
|
+
export declare type FeeDetail = EvmFeeDetail | SubstrateFeeDetail | TonFeeDetail | CardanoFeeDetail | BitcoinFeeDetail;
|
|
9
|
+
export declare type FeeCustom = EvmEIP1559FeeOption | SubstrateTipInfo | TonTipInfo | CardanoTipInfo | BitcoinFeeRate;
|
|
9
10
|
export interface FeeSubscription {
|
|
10
11
|
observer: BehaviorSubject<FeeInfo | undefined>;
|
|
11
12
|
subscription: Record<string, VoidFunction>;
|
package/types/index.d.ts
CHANGED
package/types/index.js
CHANGED
package/utils/account/analyze.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { resolveAzeroAddressToDomain, resolveAzeroDomainToAddress } from '@subwallet/extension-base/koni/api/dotsama/domain';
|
|
5
|
-
import {
|
|
5
|
+
import { _getChainSubstrateAddressPrefix, _isChainInfoCompatibleWithAccountInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { AccountChainType, AnalyzedGroup } from '@subwallet/extension-base/types';
|
|
7
|
+
import { getKeypairTypeByAddress } from '@subwallet/keyring';
|
|
7
8
|
import { isAddress } from '@polkadot/util-crypto';
|
|
8
9
|
import { _reformatAddressWithChain, reformatAddress } from "./common.js";
|
|
9
10
|
// TODO: Re-confirm to compare without
|
|
@@ -51,14 +52,13 @@ export const _analyzeAddress = async (data, accountProxies, contacts, chainInfo,
|
|
|
51
52
|
const chain = chainInfo.slug;
|
|
52
53
|
const _data = data.trim().toLowerCase();
|
|
53
54
|
const options = [];
|
|
54
|
-
const currentChainType = _chainInfoToChainType(chainInfo);
|
|
55
55
|
let current;
|
|
56
56
|
|
|
57
57
|
// Filter account proxies
|
|
58
58
|
for (const accountProxy of accountProxies) {
|
|
59
59
|
const _name = accountProxy.name.trim().toLowerCase();
|
|
60
60
|
const nameCondition = isNameValid(_data, _name);
|
|
61
|
-
const filterAccounts = accountProxy.accounts.filter(account => account.chainType
|
|
61
|
+
const filterAccounts = accountProxy.accounts.filter(account => _isChainInfoCompatibleWithAccountInfo(chainInfo, account.chainType, account.type));
|
|
62
62
|
for (const account of filterAccounts) {
|
|
63
63
|
const addressCondition = isStrValidWithAddress(_data, account, chainInfo);
|
|
64
64
|
const condition = nameCondition !== 'invalid' ? nameCondition : addressCondition;
|
|
@@ -86,7 +86,7 @@ export const _analyzeAddress = async (data, accountProxies, contacts, chainInfo,
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
const filterContacts = contacts.filter(contact => contact.chainType
|
|
89
|
+
const filterContacts = contacts.filter(contact => _isChainInfoCompatibleWithAccountInfo(chainInfo, contact.chainType, getKeypairTypeByAddress(contact.address)));
|
|
90
90
|
|
|
91
91
|
// Filter address book addresses
|
|
92
92
|
for (const contact of filterContacts) {
|
|
@@ -6,15 +6,14 @@ export declare function isAccountAll(address?: string): boolean;
|
|
|
6
6
|
export declare function reformatAddress(address: string, networkPrefix?: number, isEthereum?: boolean): string;
|
|
7
7
|
export declare const _reformatAddressWithChain: (address: string, chainInfo: _ChainInfo) => string;
|
|
8
8
|
export declare const getAccountChainTypeForAddress: (address: string) => AccountChainType;
|
|
9
|
-
|
|
10
|
-
[ChainType
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[ChainType.CARDANO]: string[];
|
|
9
|
+
declare type AddressesByChainType = {
|
|
10
|
+
[key in ChainType]: string[];
|
|
11
|
+
};
|
|
12
|
+
interface ExtendAddressesByChainType extends AddressesByChainType {
|
|
13
|
+
_bitcoin: string[];
|
|
15
14
|
}
|
|
16
|
-
export declare function getAddressesByChainType(addresses: string[], chainTypes: ChainType[]): string[];
|
|
17
|
-
export declare function getAddressesByChainTypeMap(addresses: string[]):
|
|
15
|
+
export declare function getAddressesByChainType(addresses: string[], chainTypes: ChainType[], chainInfo?: _ChainInfo): string[];
|
|
16
|
+
export declare function getAddressesByChainTypeMap(addresses: string[], chainInfo?: _ChainInfo): ExtendAddressesByChainType;
|
|
18
17
|
export declare function quickFormatAddressToCompare(address?: string): string | undefined;
|
|
19
18
|
/** @deprecated */
|
|
20
19
|
export declare const modifyAccountName: (type: KeypairType, name: string, modify: boolean) => string;
|
package/utils/account/common.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
4
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
6
5
|
import { _chainInfoToChainType, _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
6
|
import { AccountChainType } from '@subwallet/extension-base/types';
|
|
8
7
|
import { getAccountChainTypeFromKeypairType } from '@subwallet/extension-base/utils';
|
|
9
8
|
import { decodeAddress, encodeAddress, getKeypairTypeByAddress, isAddress, isBitcoinAddress, isCardanoAddress, isTonAddress } from '@subwallet/keyring';
|
|
9
|
+
import { getBitcoinAddressInfo } from '@subwallet/keyring/utils/address/validate';
|
|
10
10
|
import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
11
11
|
export function isAccountAll(address) {
|
|
12
12
|
return address === ALL_ACCOUNT_KEY;
|
|
@@ -52,20 +52,22 @@ export const getAccountChainTypeForAddress = address => {
|
|
|
52
52
|
const type = getKeypairTypeByAddress(address);
|
|
53
53
|
return getAccountChainTypeFromKeypairType(type);
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
// TODO: Recheck the usage of this function for Bitcoin; it is currently applied to history.
|
|
56
|
+
export function getAddressesByChainType(addresses, chainTypes, chainInfo) {
|
|
57
|
+
const addressByChainTypeMap = getAddressesByChainTypeMap(addresses, chainInfo);
|
|
57
58
|
return chainTypes.map(chainType => {
|
|
58
59
|
return addressByChainTypeMap[chainType];
|
|
59
60
|
}).flat(); // todo: recheck
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
export function getAddressesByChainTypeMap(addresses) {
|
|
63
|
+
export function getAddressesByChainTypeMap(addresses, chainInfo) {
|
|
63
64
|
const addressByChainType = {
|
|
64
65
|
substrate: [],
|
|
65
66
|
evm: [],
|
|
66
67
|
bitcoin: [],
|
|
67
68
|
ton: [],
|
|
68
|
-
cardano: []
|
|
69
|
+
cardano: [],
|
|
70
|
+
_bitcoin: []
|
|
69
71
|
};
|
|
70
72
|
addresses.forEach(address => {
|
|
71
73
|
if (isEthereumAddress(address)) {
|
|
@@ -73,7 +75,15 @@ export function getAddressesByChainTypeMap(addresses) {
|
|
|
73
75
|
} else if (isTonAddress(address)) {
|
|
74
76
|
addressByChainType.ton.push(address);
|
|
75
77
|
} else if (isBitcoinAddress(address)) {
|
|
76
|
-
|
|
78
|
+
const addressInfo = getBitcoinAddressInfo(address);
|
|
79
|
+
if (chainInfo !== null && chainInfo !== void 0 && chainInfo.bitcoinInfo) {
|
|
80
|
+
const isNetworkMatch = addressInfo.network === chainInfo.bitcoinInfo.bitcoinNetwork;
|
|
81
|
+
if (isNetworkMatch) {
|
|
82
|
+
addressByChainType.bitcoin.push(address);
|
|
83
|
+
} else {
|
|
84
|
+
addressByChainType._bitcoin.push(address);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
77
87
|
} else if (isCardanoAddress(address)) {
|
|
78
88
|
addressByChainType.cardano.push(address);
|
|
79
89
|
} else {
|
|
@@ -2,32 +2,55 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { getDerivePath } from '@subwallet/keyring';
|
|
5
|
-
import { EthereumKeypairTypes, SubstrateKeypairTypes } from '@subwallet/keyring/types';
|
|
5
|
+
import { BitcoinKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes } from '@subwallet/keyring/types';
|
|
6
6
|
import { keyring } from '@subwallet/ui-keyring';
|
|
7
7
|
import { t } from 'i18next';
|
|
8
8
|
import { assert } from '@polkadot/util';
|
|
9
|
-
import { validateCardanoDerivationPath, validateEvmDerivationPath, validateOtherSubstrateDerivationPath, validateSr25519DerivationPath, validateTonDerivationPath, validateUnifiedDerivationPath } from "../validate.js";
|
|
9
|
+
import { validateBitcoinDerivationPath, validateCardanoDerivationPath, validateEvmDerivationPath, validateOtherSubstrateDerivationPath, validateSr25519DerivationPath, validateTonDerivationPath, validateUnifiedDerivationPath } from "../validate.js";
|
|
10
|
+
const bitPathLv1 = "m/{proposal}'/{slip44}'/{firstIndex}'/0/0";
|
|
11
|
+
const bitPathLv2 = "m/{proposal}'/{slip44}'/{firstIndex}'/0/0/{secondIndex}";
|
|
12
|
+
const getBitLv1DerivePathFunction = (slip44, proposal) => {
|
|
13
|
+
return bitPathLv1.replace('{proposal}', proposal.toString()).replace('{slip44}', slip44.toString());
|
|
14
|
+
};
|
|
15
|
+
const getBitLv2DerivePathFunction = (slip44, proposal) => {
|
|
16
|
+
return bitPathLv2.replace('{proposal}', proposal.toString()).replace('{slip44}', slip44.toString());
|
|
17
|
+
};
|
|
18
|
+
const level1DerivationPathMap = {
|
|
19
|
+
ethereum: "m/44'/60'/0'/0/{firstIndex}",
|
|
20
|
+
ton: "m/44'/607'/{firstIndex}'",
|
|
21
|
+
cardano: "m/1852'/1815'/{firstIndex}'",
|
|
22
|
+
'bitcoin-44': getBitLv1DerivePathFunction(0, 44),
|
|
23
|
+
'bitcoin-84': getBitLv1DerivePathFunction(0, 84),
|
|
24
|
+
'bitcoin-86': getBitLv1DerivePathFunction(0, 86),
|
|
25
|
+
'bittest-44': getBitLv1DerivePathFunction(1, 44),
|
|
26
|
+
'bittest-84': getBitLv1DerivePathFunction(1, 84),
|
|
27
|
+
'bittest-86': getBitLv1DerivePathFunction(1, 86)
|
|
28
|
+
};
|
|
29
|
+
const level2DerivationPathMap = {
|
|
30
|
+
ethereum: "m/44'/60'/0'/0/{firstIndex}/{secondIndex}",
|
|
31
|
+
ton: "m/44'/607'/{firstIndex}'/{secondIndex}'",
|
|
32
|
+
cardano: "m/1852'/1815'/{firstIndex}'/{secondIndex}'",
|
|
33
|
+
'bitcoin-44': getBitLv2DerivePathFunction(0, 44),
|
|
34
|
+
'bitcoin-84': getBitLv2DerivePathFunction(0, 84),
|
|
35
|
+
'bitcoin-86': getBitLv2DerivePathFunction(0, 86),
|
|
36
|
+
'bittest-44': getBitLv2DerivePathFunction(1, 44),
|
|
37
|
+
'bittest-84': getBitLv2DerivePathFunction(1, 84),
|
|
38
|
+
'bittest-86': getBitLv2DerivePathFunction(1, 86)
|
|
39
|
+
};
|
|
10
40
|
export const parseUnifiedSuriToDerivationPath = (suri, type) => {
|
|
11
41
|
const reg = /^\/\/(\d+)(\/\/\d+)?$/;
|
|
12
42
|
if (suri.match(reg)) {
|
|
13
43
|
const [, firstIndex, secondData] = suri.match(reg);
|
|
14
|
-
const first = parseInt(firstIndex, 10);
|
|
15
44
|
if (secondData) {
|
|
16
45
|
const [, secondIndex] = secondData.match(/\/\/(\d+)/);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return `m/44'/607'/${first}'/${secondIndex}'`;
|
|
21
|
-
} else if (type === 'cardano') {
|
|
22
|
-
return `m/1852'/1815'/${first}'/${secondIndex}'`;
|
|
46
|
+
const path = level2DerivationPathMap[type];
|
|
47
|
+
if (path) {
|
|
48
|
+
return path.replace('{firstIndex}', firstIndex).replace('{secondIndex}', secondIndex);
|
|
23
49
|
}
|
|
24
50
|
} else {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return `m/44'/607'/${first}'`;
|
|
29
|
-
} else if (type === 'cardano') {
|
|
30
|
-
return `m/1852'/1815'/${first}'`;
|
|
51
|
+
const path = level1DerivationPathMap[type];
|
|
52
|
+
if (path) {
|
|
53
|
+
return path.replace('{firstIndex}', firstIndex);
|
|
31
54
|
}
|
|
32
55
|
}
|
|
33
56
|
if (SubstrateKeypairTypes.includes(type)) {
|
|
@@ -36,6 +59,33 @@ export const parseUnifiedSuriToDerivationPath = (suri, type) => {
|
|
|
36
59
|
}
|
|
37
60
|
return '';
|
|
38
61
|
};
|
|
62
|
+
const validateNonSubstrateDerivationPath = (derivePath, type) => {
|
|
63
|
+
let validateTypeRs;
|
|
64
|
+
switch (type) {
|
|
65
|
+
case 'ethereum':
|
|
66
|
+
validateTypeRs = validateEvmDerivationPath(derivePath);
|
|
67
|
+
break;
|
|
68
|
+
case 'ton':
|
|
69
|
+
validateTypeRs = validateTonDerivationPath(derivePath);
|
|
70
|
+
break;
|
|
71
|
+
case 'cardano':
|
|
72
|
+
validateTypeRs = validateCardanoDerivationPath(derivePath);
|
|
73
|
+
break;
|
|
74
|
+
case 'bitcoin-44':
|
|
75
|
+
case 'bitcoin-84':
|
|
76
|
+
case 'bitcoin-86':
|
|
77
|
+
case 'bittest-44':
|
|
78
|
+
case 'bittest-84':
|
|
79
|
+
case 'bittest-86':
|
|
80
|
+
validateTypeRs = validateBitcoinDerivationPath(derivePath);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (validateTypeRs && validateTypeRs.type === type) {
|
|
84
|
+
return validateTypeRs;
|
|
85
|
+
} else {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
39
89
|
export const getSoloDerivationInfo = (type, metadata = {}) => {
|
|
40
90
|
const {
|
|
41
91
|
derivationPath: derivePath,
|
|
@@ -44,8 +94,7 @@ export const getSoloDerivationInfo = (type, metadata = {}) => {
|
|
|
44
94
|
} = metadata;
|
|
45
95
|
if (suri) {
|
|
46
96
|
if (derivePath) {
|
|
47
|
-
const
|
|
48
|
-
const validateTypeRs = validateTypeFunc(derivePath);
|
|
97
|
+
const validateTypeRs = validateNonSubstrateDerivationPath(derivePath, type);
|
|
49
98
|
if (validateTypeRs) {
|
|
50
99
|
return {
|
|
51
100
|
suri: validateTypeRs.suri,
|
|
@@ -101,8 +150,7 @@ export const getSoloDerivationInfo = (type, metadata = {}) => {
|
|
|
101
150
|
}
|
|
102
151
|
} else {
|
|
103
152
|
if (derivePath) {
|
|
104
|
-
const
|
|
105
|
-
const validateTypeRs = validateTypeFunc(derivePath);
|
|
153
|
+
const validateTypeRs = validateNonSubstrateDerivationPath(derivePath, type);
|
|
106
154
|
if (validateTypeRs) {
|
|
107
155
|
return {
|
|
108
156
|
suri: validateTypeRs.suri,
|
|
@@ -215,6 +263,7 @@ export const derivePair = (parentPair, name, suri, derivationPath) => {
|
|
|
215
263
|
const isEvm = EthereumKeypairTypes.includes(parentPair.type);
|
|
216
264
|
const isTon = parentPair.type === 'ton';
|
|
217
265
|
const isCardano = parentPair.type === 'cardano';
|
|
266
|
+
const isBitcoin = BitcoinKeypairTypes.includes(parentPair.type);
|
|
218
267
|
const meta = {
|
|
219
268
|
name,
|
|
220
269
|
parentAddress: parentPair.address,
|
|
@@ -225,8 +274,8 @@ export const derivePair = (parentPair, name, suri, derivationPath) => {
|
|
|
225
274
|
if (isTon && (_parentPair$ton = parentPair.ton) !== null && _parentPair$ton !== void 0 && _parentPair$ton.contractVersion) {
|
|
226
275
|
meta.tonContractVersion = parentPair.ton.contractVersion;
|
|
227
276
|
}
|
|
228
|
-
if (derivationPath && (isEvm || isTon || isCardano)) {
|
|
229
|
-
return isEvm ? parentPair.evm.deriveCustom(derivationPath, meta) : isTon ? parentPair.ton.deriveCustom(derivationPath, meta) : parentPair.cardano.deriveCustom(derivationPath, meta);
|
|
277
|
+
if (derivationPath && (isEvm || isTon || isCardano || isBitcoin)) {
|
|
278
|
+
return isEvm ? parentPair.evm.deriveCustom(derivationPath, meta) : isTon ? parentPair.ton.deriveCustom(derivationPath, meta) : isCardano ? parentPair.cardano.deriveCustom(derivationPath, meta) : parentPair.bitcoin.deriveCustom(derivationPath, meta);
|
|
230
279
|
} else {
|
|
231
280
|
return parentPair.substrate.derive(suri, meta);
|
|
232
281
|
}
|
|
@@ -88,6 +88,8 @@ export const findUnifiedNextDerive = (proxyId, accounts) => {
|
|
|
88
88
|
index++;
|
|
89
89
|
} else if (currentDepth === 0 && deriveIndex === 0 && index > deriveIndex) {
|
|
90
90
|
// Special case for the first account on the root
|
|
91
|
+
} else if (deriveIndex === index - 1) {
|
|
92
|
+
// Special case, increased index before that, ex: 1/0, 1/1, 1/2
|
|
91
93
|
} else {
|
|
92
94
|
break;
|
|
93
95
|
}
|
|
@@ -3,6 +3,7 @@ import { KeypairType, SubstrateKeypairType } from '@subwallet/keyring/types';
|
|
|
3
3
|
export declare const validateUnifiedDerivationPath: (raw: string) => DerivePathInfo | undefined;
|
|
4
4
|
export declare const validateEvmDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
5
5
|
export declare const validateTonDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
6
|
+
export declare const validateBitcoinDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
6
7
|
export declare const validateCardanoDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
7
8
|
export declare const validateSr25519DerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
8
9
|
export declare const validateOtherSubstrateDerivationPath: (raw: string, type: Exclude<SubstrateKeypairType, 'sr25519'>) => IDerivePathInfo_ | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { BitcoinKeypairTypes } from '@subwallet/keyring/types';
|
|
4
5
|
export const validateUnifiedDerivationPath = raw => {
|
|
5
6
|
const reg = /^\/\/(\d+)(\/\/\d+)?$/;
|
|
6
7
|
if (raw.match(reg)) {
|
|
@@ -96,6 +97,66 @@ export const validateTonDerivationPath = raw => {
|
|
|
96
97
|
return undefined;
|
|
97
98
|
}
|
|
98
99
|
};
|
|
100
|
+
export const validateBitcoinDerivationPath = raw => {
|
|
101
|
+
const reg = /^m\/(44|84|86)'\/([01])'\/(\d+)'\/0\/0(\/\d+)?$/;
|
|
102
|
+
if (raw.match(reg)) {
|
|
103
|
+
const [, proposal, slip44, firstIndex, secondData] = raw.match(reg);
|
|
104
|
+
const first = parseInt(firstIndex, 10);
|
|
105
|
+
const autoIndexes = [first];
|
|
106
|
+
let depth;
|
|
107
|
+
let suri = `//${first}`;
|
|
108
|
+
let type;
|
|
109
|
+
if (slip44 === '0') {
|
|
110
|
+
switch (proposal) {
|
|
111
|
+
case '44':
|
|
112
|
+
type = 'bitcoin-44';
|
|
113
|
+
break;
|
|
114
|
+
case '84':
|
|
115
|
+
type = 'bitcoin-84';
|
|
116
|
+
break;
|
|
117
|
+
case '86':
|
|
118
|
+
type = 'bitcoin-86';
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
} else if (slip44 === '1') {
|
|
122
|
+
switch (proposal) {
|
|
123
|
+
case '44':
|
|
124
|
+
type = 'bittest-44';
|
|
125
|
+
break;
|
|
126
|
+
case '84':
|
|
127
|
+
type = 'bittest-84';
|
|
128
|
+
break;
|
|
129
|
+
case '86':
|
|
130
|
+
type = 'bittest-86';
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!type) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
if (first === 0) {
|
|
138
|
+
depth = 0;
|
|
139
|
+
} else {
|
|
140
|
+
depth = 1;
|
|
141
|
+
}
|
|
142
|
+
if (secondData) {
|
|
143
|
+
const [, secondIndex] = secondData.match(/\/(\d+)/);
|
|
144
|
+
const second = parseInt(secondIndex, 10);
|
|
145
|
+
autoIndexes.push(second);
|
|
146
|
+
depth = 2;
|
|
147
|
+
suri += `//${second}`;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
depth,
|
|
151
|
+
type,
|
|
152
|
+
suri,
|
|
153
|
+
derivationPath: raw,
|
|
154
|
+
autoIndexes
|
|
155
|
+
};
|
|
156
|
+
} else {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
99
160
|
export const validateCardanoDerivationPath = raw => {
|
|
100
161
|
const reg = /^m\/1852'\/1815'\/(\d+)'(\/\d+')?$/;
|
|
101
162
|
if (raw.match(reg)) {
|
|
@@ -189,10 +250,16 @@ export const validateDerivationPath = (raw, type) => {
|
|
|
189
250
|
return validateOtherSubstrateDerivationPath(raw, type);
|
|
190
251
|
} else if (type === 'cardano') {
|
|
191
252
|
return validateCardanoDerivationPath(raw);
|
|
253
|
+
} else if (BitcoinKeypairTypes.includes(type)) {
|
|
254
|
+
const rs = validateBitcoinDerivationPath(raw);
|
|
255
|
+
if (rs && rs.type === type) {
|
|
256
|
+
return rs;
|
|
257
|
+
}
|
|
258
|
+
return undefined;
|
|
192
259
|
} else {
|
|
193
260
|
return undefined;
|
|
194
261
|
}
|
|
195
262
|
} else {
|
|
196
|
-
return validateUnifiedDerivationPath(raw) || validateEvmDerivationPath(raw) || validateTonDerivationPath(raw) || validateSr25519DerivationPath(raw) || validateCardanoDerivationPath(raw);
|
|
263
|
+
return validateUnifiedDerivationPath(raw) || validateEvmDerivationPath(raw) || validateTonDerivationPath(raw) || validateSr25519DerivationPath(raw) || validateCardanoDerivationPath(raw) || validateBitcoinDerivationPath(raw);
|
|
197
264
|
}
|
|
198
265
|
};
|
|
@@ -5,7 +5,7 @@ import { KeypairType, KeyringPair, KeyringPair$Meta } from '@subwallet/keyring/t
|
|
|
5
5
|
import { SingleAddress, SubjectInfo } from '@subwallet/ui-keyring/observable/types';
|
|
6
6
|
export declare const createAccountProxyId: (_suri: string, derivationPath?: string) => `0x${string}`;
|
|
7
7
|
export declare const getAccountChainTypeFromKeypairType: (type: KeypairType) => AccountChainType;
|
|
8
|
-
export declare const getDefaultKeypairTypeFromAccountChainType: (type: AccountChainType) => KeypairType;
|
|
8
|
+
export declare const getDefaultKeypairTypeFromAccountChainType: (type: AccountChainType) => KeypairType[];
|
|
9
9
|
export declare const getAccountSignMode: (address: string, _meta?: KeyringPair$Meta) => AccountSignMode;
|
|
10
10
|
export declare const getAccountActions: (signMode: AccountSignMode, networkType: AccountChainType, type: KeypairType, _meta?: KeyringPair$Meta, parentAccount?: AccountJson) => AccountActions[];
|
|
11
11
|
export declare const getAccountTransactionActions: (signMode: AccountSignMode, networkType: AccountChainType, type?: KeypairType, _meta?: KeyringPair$Meta, _specialNetwork?: string) => ExtrinsicType[];
|
|
@@ -37,15 +37,15 @@ export const getAccountChainTypeFromKeypairType = type => {
|
|
|
37
37
|
};
|
|
38
38
|
export const getDefaultKeypairTypeFromAccountChainType = type => {
|
|
39
39
|
if (type === AccountChainType.ETHEREUM) {
|
|
40
|
-
return 'ethereum';
|
|
40
|
+
return ['ethereum'];
|
|
41
41
|
} else if (type === AccountChainType.TON) {
|
|
42
|
-
return 'ton';
|
|
42
|
+
return ['ton'];
|
|
43
43
|
} else if (type === AccountChainType.BITCOIN) {
|
|
44
|
-
return 'bitcoin-84';
|
|
44
|
+
return ['bitcoin-44', 'bitcoin-84', 'bitcoin-86', 'bittest-44', 'bittest-84', 'bittest-86'];
|
|
45
45
|
} else if (type === AccountChainType.CARDANO) {
|
|
46
|
-
return 'cardano';
|
|
46
|
+
return ['cardano'];
|
|
47
47
|
} else {
|
|
48
|
-
return 'sr25519';
|
|
48
|
+
return ['sr25519'];
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
export const getAccountSignMode = (address, _meta) => {
|
|
@@ -162,6 +162,8 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
162
162
|
return [...BASE_TRANSFER_ACTIONS];
|
|
163
163
|
case AccountChainType.CARDANO:
|
|
164
164
|
return [...BASE_TRANSFER_ACTIONS];
|
|
165
|
+
case AccountChainType.BITCOIN:
|
|
166
|
+
return [...BASE_TRANSFER_ACTIONS];
|
|
165
167
|
}
|
|
166
168
|
} else if (signMode === AccountSignMode.QR) {
|
|
167
169
|
switch (networkType) {
|
|
@@ -173,6 +175,8 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
173
175
|
return [];
|
|
174
176
|
case AccountChainType.CARDANO:
|
|
175
177
|
return [];
|
|
178
|
+
case AccountChainType.BITCOIN:
|
|
179
|
+
return [];
|
|
176
180
|
}
|
|
177
181
|
} else if (signMode === AccountSignMode.GENERIC_LEDGER) {
|
|
178
182
|
switch (networkType) {
|
|
@@ -190,6 +194,8 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
190
194
|
return [...BASE_TRANSFER_ACTIONS];
|
|
191
195
|
case AccountChainType.CARDANO:
|
|
192
196
|
return [];
|
|
197
|
+
case AccountChainType.BITCOIN:
|
|
198
|
+
return [];
|
|
193
199
|
}
|
|
194
200
|
} else if (signMode === AccountSignMode.LEGACY_LEDGER) {
|
|
195
201
|
// Only for Substrate
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { _BitcoinApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
2
|
+
import { UtxoResponseItem } from '@subwallet/extension-base/types';
|
|
3
|
+
import BigN from 'bignumber.js';
|
|
4
|
+
export declare function getSizeInfo(payload: {
|
|
5
|
+
inputLength: number;
|
|
6
|
+
recipients: string[];
|
|
7
|
+
sender: string;
|
|
8
|
+
}): {
|
|
9
|
+
txVBytes: number;
|
|
10
|
+
txBytes: number;
|
|
11
|
+
txWeight: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function getSpendableAmount({ feeRate, recipients, sender, utxos }: {
|
|
14
|
+
utxos: UtxoResponseItem[];
|
|
15
|
+
feeRate: number;
|
|
16
|
+
recipients: string[];
|
|
17
|
+
sender: string;
|
|
18
|
+
}): {
|
|
19
|
+
spendableAmount: BigN;
|
|
20
|
+
fee: number;
|
|
21
|
+
};
|
|
22
|
+
export declare const getTransferableBitcoinUtxos: (bitcoinApi: _BitcoinApi, address: string) => Promise<UtxoResponseItem[]>;
|