@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,291 @@
|
|
|
1
|
+
import { ApiRequestStrategy } from '@subwallet/extension-base/strategy/api-request-strategy/types';
|
|
2
|
+
import { BitcoinFeeInfo, BitcoinTransactionStatus, BitcoinTx, UtxoResponseItem } from '@subwallet/extension-base/types';
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
|
+
export interface BitcoinApiStrategy extends Omit<ApiRequestStrategy, 'addRequest'> {
|
|
5
|
+
getBlockTime(): Promise<number>;
|
|
6
|
+
computeBlockTime(): Promise<number>;
|
|
7
|
+
getAddressSummaryInfo(address: string): Promise<BitcoinAddressSummaryInfo>;
|
|
8
|
+
getRunes(address: string): Promise<RunesInfoByAddress[]>;
|
|
9
|
+
getRuneUtxos(address: string): Promise<RuneUtxo[]>;
|
|
10
|
+
getAddressInscriptions(address: string): Promise<Inscription[]>;
|
|
11
|
+
getAddressTransaction(address: string, limit?: number): Promise<BitcoinTx[]>;
|
|
12
|
+
getTransactionStatus(txHash: string): Promise<BitcoinTransactionStatus>;
|
|
13
|
+
getTransactionDetail(txHash: string): Promise<BitcoinTx>;
|
|
14
|
+
getFeeRate(): Promise<BitcoinFeeInfo>;
|
|
15
|
+
getRecommendedFeeRate(): Promise<BitcoinFeeInfo>;
|
|
16
|
+
getUtxos(address: string): Promise<UtxoResponseItem[]>;
|
|
17
|
+
getTxHex(txHash: string): Promise<string>;
|
|
18
|
+
sendRawTransaction(rawTransaction: string): EventEmitter<BitcoinTransactionEventMap>;
|
|
19
|
+
simpleSendRawTransaction(rawTransaction: string): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
export interface BitcoinTransactionEventMap {
|
|
22
|
+
extrinsicHash: (txHash: string) => void;
|
|
23
|
+
error: (error: string) => void;
|
|
24
|
+
success: (data: BitcoinTransactionStatus) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface BlockStreamBlock {
|
|
27
|
+
id: string;
|
|
28
|
+
height: number;
|
|
29
|
+
version: number;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
tx_count: number;
|
|
32
|
+
size: number;
|
|
33
|
+
weight: number;
|
|
34
|
+
merkle_root: string;
|
|
35
|
+
previousblockhash: string;
|
|
36
|
+
mediantime: number;
|
|
37
|
+
nonce: number;
|
|
38
|
+
bits: number;
|
|
39
|
+
difficulty: number;
|
|
40
|
+
}
|
|
41
|
+
export interface BlockstreamAddressResponse {
|
|
42
|
+
address: string;
|
|
43
|
+
chain_stats: {
|
|
44
|
+
funded_txo_count: number;
|
|
45
|
+
funded_txo_sum: number;
|
|
46
|
+
spent_txo_count: number;
|
|
47
|
+
spent_txo_sum: number;
|
|
48
|
+
tx_count: number;
|
|
49
|
+
};
|
|
50
|
+
mempool_stats: {
|
|
51
|
+
funded_txo_count: number;
|
|
52
|
+
funded_txo_sum: number;
|
|
53
|
+
spent_txo_count: number;
|
|
54
|
+
spent_txo_sum: number;
|
|
55
|
+
tx_count: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface BitcoinAddressSummaryInfo extends BlockstreamAddressResponse {
|
|
59
|
+
balance: number;
|
|
60
|
+
total_inscription: number;
|
|
61
|
+
balance_rune: string;
|
|
62
|
+
balance_inscription: string;
|
|
63
|
+
}
|
|
64
|
+
export interface RunesInfoByAddressResponse {
|
|
65
|
+
statusCode: number;
|
|
66
|
+
data: RunesInfoByAddressFetchedData;
|
|
67
|
+
}
|
|
68
|
+
export interface RunesInfoByAddressFetchedData {
|
|
69
|
+
limit: number;
|
|
70
|
+
offset: number;
|
|
71
|
+
total: number;
|
|
72
|
+
runes: RunesInfoByAddress[];
|
|
73
|
+
}
|
|
74
|
+
export interface RunesInfoByAddress {
|
|
75
|
+
amount: string;
|
|
76
|
+
address: string;
|
|
77
|
+
rune_id: string;
|
|
78
|
+
rune: {
|
|
79
|
+
rune: string;
|
|
80
|
+
rune_name: string;
|
|
81
|
+
divisibility: number;
|
|
82
|
+
premine: string;
|
|
83
|
+
spacers: string;
|
|
84
|
+
symbol: string;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export interface RunesCollectionInfoResponse {
|
|
88
|
+
statusCode: number;
|
|
89
|
+
data: RunesCollectionInfoFetchedData;
|
|
90
|
+
}
|
|
91
|
+
interface RunesCollectionInfoFetchedData {
|
|
92
|
+
limit: number;
|
|
93
|
+
offset: number;
|
|
94
|
+
total: number;
|
|
95
|
+
runes: RunesCollectionInfo[];
|
|
96
|
+
}
|
|
97
|
+
export interface RunesCollectionInfo {
|
|
98
|
+
rune_id: string;
|
|
99
|
+
rune: string;
|
|
100
|
+
rune_name: string;
|
|
101
|
+
divisibility: string;
|
|
102
|
+
spacers: string;
|
|
103
|
+
}
|
|
104
|
+
export interface RuneTxsResponse {
|
|
105
|
+
statusCode: number;
|
|
106
|
+
data: RuneTxsFetchedData;
|
|
107
|
+
}
|
|
108
|
+
interface RuneTxsFetchedData {
|
|
109
|
+
limit: number;
|
|
110
|
+
offset: number;
|
|
111
|
+
total: number;
|
|
112
|
+
transactions: RuneTxs[];
|
|
113
|
+
}
|
|
114
|
+
export interface RuneTxs {
|
|
115
|
+
txid: string;
|
|
116
|
+
vout: RuneTxsUtxosVout[];
|
|
117
|
+
}
|
|
118
|
+
interface RuneTxsUtxosVout {
|
|
119
|
+
n: number;
|
|
120
|
+
value: number;
|
|
121
|
+
runeInject: any;
|
|
122
|
+
}
|
|
123
|
+
export interface Brc20MetadataFetchedData {
|
|
124
|
+
token: Brc20Metadata;
|
|
125
|
+
}
|
|
126
|
+
export interface Brc20Metadata {
|
|
127
|
+
ticker: string;
|
|
128
|
+
decimals: number;
|
|
129
|
+
}
|
|
130
|
+
export interface Brc20BalanceFetchedData {
|
|
131
|
+
limit: number;
|
|
132
|
+
offset: number;
|
|
133
|
+
total: number;
|
|
134
|
+
results: Brc20Balance[];
|
|
135
|
+
}
|
|
136
|
+
export interface Brc20Balance {
|
|
137
|
+
ticker: string;
|
|
138
|
+
available_balance: string;
|
|
139
|
+
transferrable_balance: string;
|
|
140
|
+
overall_balance: string;
|
|
141
|
+
}
|
|
142
|
+
export interface Brc20BalanceItem {
|
|
143
|
+
free: string;
|
|
144
|
+
locked: string;
|
|
145
|
+
}
|
|
146
|
+
export interface InscriptionFetchedData {
|
|
147
|
+
limit: number;
|
|
148
|
+
offset: number;
|
|
149
|
+
total: number;
|
|
150
|
+
results: Inscription[];
|
|
151
|
+
}
|
|
152
|
+
export interface Inscription {
|
|
153
|
+
id: string;
|
|
154
|
+
number: number;
|
|
155
|
+
address: string;
|
|
156
|
+
genesis_block_height: number;
|
|
157
|
+
genesis_block_hash: string;
|
|
158
|
+
genesis_timestamp: number;
|
|
159
|
+
tx_id: string;
|
|
160
|
+
location: string;
|
|
161
|
+
output: string;
|
|
162
|
+
value: string;
|
|
163
|
+
offset: string;
|
|
164
|
+
fee: number;
|
|
165
|
+
sat_ordinal: string;
|
|
166
|
+
sat_rarity: string;
|
|
167
|
+
content_type: string;
|
|
168
|
+
content_length: number;
|
|
169
|
+
}
|
|
170
|
+
export interface UpdateOpenBitUtxo {
|
|
171
|
+
totalUtxo: number;
|
|
172
|
+
utxoItems: BlockStreamUtxo[];
|
|
173
|
+
}
|
|
174
|
+
export interface BlockStreamUtxo {
|
|
175
|
+
txid: string;
|
|
176
|
+
vout: number;
|
|
177
|
+
status: {
|
|
178
|
+
confirmed: boolean;
|
|
179
|
+
block_height?: number;
|
|
180
|
+
block_hash: string;
|
|
181
|
+
block_time?: number;
|
|
182
|
+
};
|
|
183
|
+
value: number;
|
|
184
|
+
}
|
|
185
|
+
export interface BlockStreamTransactionStatus {
|
|
186
|
+
confirmed: boolean;
|
|
187
|
+
block_height: number;
|
|
188
|
+
block_hash: string;
|
|
189
|
+
block_time: number;
|
|
190
|
+
}
|
|
191
|
+
export interface BlockStreamFeeEstimates {
|
|
192
|
+
1: number;
|
|
193
|
+
2: number;
|
|
194
|
+
3: number;
|
|
195
|
+
4: number;
|
|
196
|
+
5: number;
|
|
197
|
+
6: number;
|
|
198
|
+
7: number;
|
|
199
|
+
8: number;
|
|
200
|
+
}
|
|
201
|
+
export interface RecommendedFeeEstimates {
|
|
202
|
+
fastestFee: number;
|
|
203
|
+
halfHourFee: number;
|
|
204
|
+
hourFee: number;
|
|
205
|
+
economyFee: number;
|
|
206
|
+
minimumFee: number;
|
|
207
|
+
}
|
|
208
|
+
export interface BlockStreamTransactionVectorOutput {
|
|
209
|
+
scriptpubkey: string;
|
|
210
|
+
scriptpubkey_asm: string;
|
|
211
|
+
scriptpubkey_type: string;
|
|
212
|
+
scriptpubkey_address: string;
|
|
213
|
+
value: number;
|
|
214
|
+
}
|
|
215
|
+
export interface BlockStreamTransactionVectorInput {
|
|
216
|
+
is_coinbase: boolean;
|
|
217
|
+
prevout: BlockStreamTransactionVectorOutput;
|
|
218
|
+
scriptsig: string;
|
|
219
|
+
scriptsig_asm: string;
|
|
220
|
+
sequence: number;
|
|
221
|
+
txid: string;
|
|
222
|
+
vout: number;
|
|
223
|
+
witness: string[];
|
|
224
|
+
}
|
|
225
|
+
export interface BlockStreamTransactionDetail {
|
|
226
|
+
txid: string;
|
|
227
|
+
version: number;
|
|
228
|
+
locktime: number;
|
|
229
|
+
totalVin: number;
|
|
230
|
+
totalVout: number;
|
|
231
|
+
size: number;
|
|
232
|
+
weight: number;
|
|
233
|
+
fee: number;
|
|
234
|
+
status: {
|
|
235
|
+
confirmed: boolean;
|
|
236
|
+
block_height?: number;
|
|
237
|
+
block_hash?: string;
|
|
238
|
+
block_time?: number;
|
|
239
|
+
};
|
|
240
|
+
vin: BlockStreamTransactionVectorInput[];
|
|
241
|
+
vout: BlockStreamTransactionVectorOutput[];
|
|
242
|
+
}
|
|
243
|
+
export interface RuneUtxoResponse {
|
|
244
|
+
total: number;
|
|
245
|
+
results: RuneUtxo[];
|
|
246
|
+
}
|
|
247
|
+
export interface RuneUtxo {
|
|
248
|
+
height: number;
|
|
249
|
+
confirmations: number;
|
|
250
|
+
address: string;
|
|
251
|
+
satoshi: number;
|
|
252
|
+
scriptPk: string;
|
|
253
|
+
txid: string;
|
|
254
|
+
vout: number;
|
|
255
|
+
runes: RuneInject[];
|
|
256
|
+
}
|
|
257
|
+
interface RuneInject {
|
|
258
|
+
rune: string;
|
|
259
|
+
runeid: string;
|
|
260
|
+
spacedRune: string;
|
|
261
|
+
amount: string;
|
|
262
|
+
symbol: string;
|
|
263
|
+
divisibility: number;
|
|
264
|
+
}
|
|
265
|
+
export interface RuneMetadata {
|
|
266
|
+
id: string;
|
|
267
|
+
mintable: boolean;
|
|
268
|
+
parent: string;
|
|
269
|
+
entry: RuneInfo;
|
|
270
|
+
}
|
|
271
|
+
interface RuneInfo {
|
|
272
|
+
block: number;
|
|
273
|
+
burned: string;
|
|
274
|
+
divisibility: number;
|
|
275
|
+
etching: string;
|
|
276
|
+
mints: string;
|
|
277
|
+
number: number;
|
|
278
|
+
premine: string;
|
|
279
|
+
spaced_rune: string;
|
|
280
|
+
symbol: string;
|
|
281
|
+
terms: RuneTerms;
|
|
282
|
+
timestamp: string;
|
|
283
|
+
turbo: boolean;
|
|
284
|
+
}
|
|
285
|
+
interface RuneTerms {
|
|
286
|
+
amount: string;
|
|
287
|
+
cap: string;
|
|
288
|
+
height: string[];
|
|
289
|
+
offset: string[];
|
|
290
|
+
}
|
|
291
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,6 +18,7 @@ export declare class ChainService {
|
|
|
18
18
|
private lockChainInfoMap;
|
|
19
19
|
private substrateChainHandler;
|
|
20
20
|
private evmChainHandler;
|
|
21
|
+
private bitcoinChainHandler;
|
|
21
22
|
private tonChainHandler;
|
|
22
23
|
private cardanoChainHandler;
|
|
23
24
|
private mantaChainHandler;
|
|
@@ -58,6 +59,8 @@ export declare class ChainService {
|
|
|
58
59
|
getEvmApiMap(): Record<string, import("./handler/EvmApi").EvmApi>;
|
|
59
60
|
getSubstrateApi(slug: string): _SubstrateApi;
|
|
60
61
|
getSubstrateApiMap(): Record<string, _SubstrateApi>;
|
|
62
|
+
getBitcoinApi(slug: string): import("./handler/bitcoin/BitcoinApi").BitcoinApi;
|
|
63
|
+
getBitcoinApiMap(): Record<string, import("./handler/bitcoin/BitcoinApi").BitcoinApi>;
|
|
61
64
|
getTonApi(slug: string): import("./handler/TonApi").TonApi;
|
|
62
65
|
getTonApiMap(): Record<string, import("./handler/TonApi").TonApi>;
|
|
63
66
|
getCardanoApi(slug: string): import("./handler/CardanoApi").CardanoApi;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { AssetLogoMap, AssetRefMap, ChainAssetMap, ChainInfoMap, ChainLogoMap, MultiChainAssetMap } from '@subwallet/chain-list';
|
|
5
5
|
import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
6
6
|
import { _DEFAULT_ACTIVE_CHAINS, _ZK_ASSET_PREFIX, LATEST_CHAIN_DATA_FETCHING_INTERVAL } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
|
+
import { BitcoinChainHandler } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/BitcoinChainHandler';
|
|
7
8
|
import { CardanoChainHandler } from '@subwallet/extension-base/services/chain-service/handler/CardanoChainHandler';
|
|
8
9
|
import { EvmChainHandler } from '@subwallet/extension-base/services/chain-service/handler/EvmChainHandler';
|
|
9
10
|
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
@@ -11,7 +12,7 @@ import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-
|
|
|
11
12
|
import { TonChainHandler } from '@subwallet/extension-base/services/chain-service/handler/TonChainHandler';
|
|
12
13
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
13
14
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
14
|
-
import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
15
|
+
import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainBitcoinCompatible, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
15
16
|
import { MYTHOS_MIGRATION_KEY } from '@subwallet/extension-base/services/migration-service/scripts';
|
|
16
17
|
import { convertUtxoRawToUtxo } from '@subwallet/extension-base/services/request-service/helper';
|
|
17
18
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
@@ -21,11 +22,19 @@ import Web3 from 'web3';
|
|
|
21
22
|
import { isArray } from '@polkadot/util';
|
|
22
23
|
import { logger as createLogger } from '@polkadot/util/logger';
|
|
23
24
|
const filterChainInfoMap = (data, ignoredChains) => {
|
|
24
|
-
return Object.fromEntries(Object.entries(data).filter(([slug, info]) => !
|
|
25
|
+
return Object.fromEntries(Object.entries(data).filter(([slug, info]) => !ignoredChains.includes(slug)));
|
|
25
26
|
};
|
|
27
|
+
// .filter(([slug, info]) => !info.bitcoinInfo && !ignoredChains.includes(slug))
|
|
28
|
+
|
|
26
29
|
const ignoredList = ['bevm', 'bevmTest', 'bevm_testnet', 'layerEdge_testnet', 'merlinEvm', 'botanixEvmTest', 'syscoin_evm', 'syscoin_evm_testnet', 'rollux_evm', 'rollux_testnet', 'boolAlpha', 'boolBeta_testnet', 'core', 'satoshivm', 'satoshivm_testnet', 'storyPartner_testnet'];
|
|
27
30
|
export const filterAssetInfoMap = (chainInfo, assets, addedChains) => {
|
|
28
|
-
return Object.fromEntries(Object.entries(assets).filter(([, info]) =>
|
|
31
|
+
return Object.fromEntries(Object.entries(assets).filter(([, info]) => {
|
|
32
|
+
const isBitcoinChain = (chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo[info.originChain]) && _isChainBitcoinCompatible(chainInfo[info.originChain]);
|
|
33
|
+
if (isBitcoinChain) {
|
|
34
|
+
return ![_AssetType.RUNE, _AssetType.BRC20].includes(info.assetType);
|
|
35
|
+
}
|
|
36
|
+
return chainInfo[info.originChain] || (addedChains === null || addedChains === void 0 ? void 0 : addedChains.includes(info.originChain));
|
|
37
|
+
}));
|
|
29
38
|
};
|
|
30
39
|
export class ChainService {
|
|
31
40
|
dataMap = {
|
|
@@ -73,6 +82,7 @@ export class ChainService {
|
|
|
73
82
|
this.evmChainHandler = new EvmChainHandler(this);
|
|
74
83
|
this.tonChainHandler = new TonChainHandler(this);
|
|
75
84
|
this.cardanoChainHandler = new CardanoChainHandler(this);
|
|
85
|
+
this.bitcoinChainHandler = new BitcoinChainHandler(this);
|
|
76
86
|
this.logger = createLogger('chain-service');
|
|
77
87
|
}
|
|
78
88
|
get value() {
|
|
@@ -148,6 +158,12 @@ export class ChainService {
|
|
|
148
158
|
getSubstrateApiMap() {
|
|
149
159
|
return this.substrateChainHandler.getSubstrateApiMap();
|
|
150
160
|
}
|
|
161
|
+
getBitcoinApi(slug) {
|
|
162
|
+
return this.bitcoinChainHandler.getApiByChain(slug);
|
|
163
|
+
}
|
|
164
|
+
getBitcoinApiMap() {
|
|
165
|
+
return this.bitcoinChainHandler.getApiMap();
|
|
166
|
+
}
|
|
151
167
|
getTonApi(slug) {
|
|
152
168
|
return this.tonChainHandler.getTonApiByChain(slug);
|
|
153
169
|
}
|
|
@@ -823,6 +839,13 @@ export class ChainService {
|
|
|
823
839
|
});
|
|
824
840
|
this.cardanoChainHandler.setCardanoApi(chainInfo.slug, chainApi);
|
|
825
841
|
}
|
|
842
|
+
if (chainInfo.bitcoinInfo !== null && chainInfo.bitcoinInfo !== undefined) {
|
|
843
|
+
const chainApi = await this.bitcoinChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
844
|
+
providerName,
|
|
845
|
+
onUpdateStatus
|
|
846
|
+
});
|
|
847
|
+
this.bitcoinChainHandler.setApi(chainInfo.slug, chainApi);
|
|
848
|
+
}
|
|
826
849
|
}
|
|
827
850
|
destroyApiForChain(chainInfo) {
|
|
828
851
|
if (chainInfo.substrateInfo !== null) {
|
|
@@ -837,6 +860,9 @@ export class ChainService {
|
|
|
837
860
|
if (chainInfo.cardanoInfo !== null) {
|
|
838
861
|
this.cardanoChainHandler.destroyCardanoApi(chainInfo.slug);
|
|
839
862
|
}
|
|
863
|
+
if (chainInfo.bitcoinInfo !== null && chainInfo.bitcoinInfo !== undefined) {
|
|
864
|
+
this.bitcoinChainHandler.destroyApi(chainInfo.slug);
|
|
865
|
+
}
|
|
840
866
|
}
|
|
841
867
|
async enableChain(chainSlug) {
|
|
842
868
|
const chainInfo = this.getChainInfoByKey(chainSlug);
|
|
@@ -1692,11 +1718,11 @@ export class ChainService {
|
|
|
1692
1718
|
this.evmChainHandler.recoverApi(slug).catch(console.error);
|
|
1693
1719
|
}
|
|
1694
1720
|
async stopAllChainApis() {
|
|
1695
|
-
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep(), this.cardanoChainHandler.sleep()]);
|
|
1721
|
+
await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep(), this.cardanoChainHandler.sleep(), this.bitcoinChainHandler.sleep()]);
|
|
1696
1722
|
this.stopCheckLatestChainData();
|
|
1697
1723
|
}
|
|
1698
1724
|
async resumeAllChainApis() {
|
|
1699
|
-
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp(), this.cardanoChainHandler.wakeUp()]);
|
|
1725
|
+
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp(), this.cardanoChainHandler.wakeUp(), this.bitcoinChainHandler.wakeUp()]);
|
|
1700
1726
|
this.checkLatestData();
|
|
1701
1727
|
}
|
|
1702
1728
|
initAssetSettings() {
|
|
@@ -2,6 +2,7 @@ import type { ApiInterfaceRx } from '@polkadot/api/types';
|
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _CrowdloanFund } from '@subwallet/chain-list/types';
|
|
3
3
|
import { CardanoBalanceItem } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/types';
|
|
4
4
|
import { AccountState, TxByMsgResponse } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/types';
|
|
5
|
+
import { BitcoinApiStrategy } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/strategy/types';
|
|
5
6
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
6
7
|
import { TonWalletContract } from '@subwallet/keyring/types';
|
|
7
8
|
import { Cell } from '@ton/core';
|
|
@@ -186,4 +187,23 @@ export interface _ValidateCustomAssetResponse extends _SmartContractTokenInfo {
|
|
|
186
187
|
export declare const _FUNGIBLE_CONTRACT_STANDARDS: _AssetType[];
|
|
187
188
|
export declare const _NFT_CONTRACT_STANDARDS: _AssetType[];
|
|
188
189
|
export declare const _SMART_CONTRACT_STANDARDS: _AssetType[];
|
|
190
|
+
export interface BitcoinApiProxy {
|
|
191
|
+
setBaseUrl: (baseUrl: string) => void;
|
|
192
|
+
getRequest: (urlPath: string, params?: Record<string, string>, headers?: Record<string, string>) => Promise<Response>;
|
|
193
|
+
postRequest: (urlPath: string, body?: BodyInit, headers?: Record<string, string>) => Promise<Response>;
|
|
194
|
+
}
|
|
195
|
+
export interface _BitcoinApi extends _ChainBaseApi {
|
|
196
|
+
isReady: Promise<_BitcoinApi>;
|
|
197
|
+
api: BitcoinApiStrategy;
|
|
198
|
+
}
|
|
199
|
+
export interface OBResponse<T> {
|
|
200
|
+
status_code: number;
|
|
201
|
+
message: string;
|
|
202
|
+
result: T;
|
|
203
|
+
}
|
|
204
|
+
export interface OBRuneResponse<T> {
|
|
205
|
+
status_code: number;
|
|
206
|
+
message: string;
|
|
207
|
+
result: T;
|
|
208
|
+
}
|
|
189
209
|
export {};
|
|
@@ -3,6 +3,7 @@ import { BasicTokenInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
|
3
3
|
import { _ChainState, _DataMap } from '@subwallet/extension-base/services/chain-service/types';
|
|
4
4
|
import { IChain } from '@subwallet/extension-base/services/storage-service/databases';
|
|
5
5
|
import { AccountChainType } from '@subwallet/extension-base/types';
|
|
6
|
+
import { KeypairType } from '@subwallet/keyring/types';
|
|
6
7
|
export declare function _isCustomChain(slug: string): boolean;
|
|
7
8
|
export declare function _isCustomAsset(slug: string): boolean;
|
|
8
9
|
export declare function _getCustomAssets(assetRegistry: Record<string, _ChainAsset>): Record<string, _ChainAsset>;
|
|
@@ -12,6 +13,7 @@ export declare function _isPureEvmChain(chainInfo: _ChainInfo): boolean;
|
|
|
12
13
|
export declare function _isPureSubstrateChain(chainInfo: _ChainInfo): boolean;
|
|
13
14
|
export declare function _isPureTonChain(chainInfo: _ChainInfo): boolean;
|
|
14
15
|
export declare function _isPureCardanoChain(chainInfo: _ChainInfo): boolean;
|
|
16
|
+
export declare function _isPureBitcoinChain(chainInfo: _ChainInfo): boolean;
|
|
15
17
|
export declare function _getOriginChainOfAsset(assetSlug: string): string;
|
|
16
18
|
export declare function _getContractAddressOfToken(tokenInfo: _ChainAsset): string;
|
|
17
19
|
/**
|
|
@@ -32,6 +34,7 @@ export declare function _checkSmartContractSupportByChain(chainInfo: _ChainInfo,
|
|
|
32
34
|
export declare function _isJettonToken(tokenInfo: _ChainAsset): boolean;
|
|
33
35
|
export declare function _isTokenTransferredByTon(tokenInfo: _ChainAsset): boolean;
|
|
34
36
|
export declare function _isTokenTransferredByCardano(tokenInfo: _ChainAsset): boolean;
|
|
37
|
+
export declare function _isTokenTransferredByBitcoin(tokenInfo: _ChainAsset): boolean;
|
|
35
38
|
export declare function _getTokenOnChainAssetId(tokenInfo: _ChainAsset): string;
|
|
36
39
|
export declare function _getTokenOnChainInfo(tokenInfo: _ChainAsset): Record<string, any>;
|
|
37
40
|
export declare function _isBridgedToken(tokenInfo: _ChainAsset): boolean;
|
|
@@ -116,5 +119,6 @@ export declare function updateLatestChainInfo(currentDataMap: _DataMap, latestCh
|
|
|
116
119
|
needUpdateChainApiList: _ChainInfo[];
|
|
117
120
|
};
|
|
118
121
|
export declare const _chainInfoToChainType: (chainInfo: _ChainInfo) => AccountChainType;
|
|
122
|
+
export declare const _isChainInfoCompatibleWithAccountInfo: (chainInfo: _ChainInfo, accountChainType: AccountChainType, accountType: KeypairType) => boolean;
|
|
119
123
|
export declare const _getAssetNetuid: (assetInfo: _ChainAsset) => number;
|
|
120
124
|
export * from './patch';
|
|
@@ -5,6 +5,7 @@ import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@s
|
|
|
5
5
|
import { _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
6
|
import { _CUSTOM_PREFIX, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
7
7
|
import { AccountChainType } from '@subwallet/extension-base/types';
|
|
8
|
+
import { BitcoinMainnetKeypairTypes, BitcoinTestnetKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
8
9
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
9
10
|
export function _isCustomChain(slug) {
|
|
10
11
|
if (slug.length === 0) {
|
|
@@ -48,16 +49,19 @@ export function _isEqualSmartContractAsset(asset1, asset2) {
|
|
|
48
49
|
return false;
|
|
49
50
|
}
|
|
50
51
|
export function _isPureEvmChain(chainInfo) {
|
|
51
|
-
return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
52
|
+
return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
|
|
52
53
|
}
|
|
53
54
|
export function _isPureSubstrateChain(chainInfo) {
|
|
54
|
-
return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
55
|
+
return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
|
|
55
56
|
}
|
|
56
57
|
export function _isPureTonChain(chainInfo) {
|
|
57
|
-
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo && !chainInfo.cardanoInfo;
|
|
58
|
+
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo && !chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
|
|
58
59
|
}
|
|
59
60
|
export function _isPureCardanoChain(chainInfo) {
|
|
60
|
-
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !!chainInfo.cardanoInfo;
|
|
61
|
+
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !!chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
|
|
62
|
+
}
|
|
63
|
+
export function _isPureBitcoinChain(chainInfo) {
|
|
64
|
+
return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo && !!chainInfo.bitcoinInfo;
|
|
61
65
|
}
|
|
62
66
|
export function _getOriginChainOfAsset(assetSlug) {
|
|
63
67
|
if (assetSlug.startsWith(_CUSTOM_PREFIX)) {
|
|
@@ -114,6 +118,11 @@ export function _isTokenTransferredByCardano(tokenInfo) {
|
|
|
114
118
|
return _isCIP26Token(tokenInfo) || _isNativeToken(tokenInfo);
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
// TODO [Review]: Currently supports transferring only the native token, Bitcoin.
|
|
122
|
+
export function _isTokenTransferredByBitcoin(tokenInfo) {
|
|
123
|
+
return _isNativeToken(tokenInfo);
|
|
124
|
+
}
|
|
125
|
+
|
|
117
126
|
// Utils for balance functions
|
|
118
127
|
export function _getTokenOnChainAssetId(tokenInfo) {
|
|
119
128
|
var _tokenInfo$metadata5;
|
|
@@ -289,6 +298,11 @@ export function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
|
289
298
|
symbol: chainInfo.cardanoInfo.symbol,
|
|
290
299
|
decimals: chainInfo.cardanoInfo.decimals
|
|
291
300
|
};
|
|
301
|
+
} else if (chainInfo.bitcoinInfo) {
|
|
302
|
+
return {
|
|
303
|
+
symbol: chainInfo.bitcoinInfo.symbol,
|
|
304
|
+
decimals: chainInfo.bitcoinInfo.decimals
|
|
305
|
+
};
|
|
292
306
|
}
|
|
293
307
|
return defaultTokenInfo;
|
|
294
308
|
}
|
|
@@ -402,6 +416,9 @@ export function _getBlockExplorerFromChain(chainInfo) {
|
|
|
402
416
|
} else if (_isPureCardanoChain(chainInfo)) {
|
|
403
417
|
var _chainInfo$cardanoInf;
|
|
404
418
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$cardanoInf = chainInfo.cardanoInfo) === null || _chainInfo$cardanoInf === void 0 ? void 0 : _chainInfo$cardanoInf.blockExplorer;
|
|
419
|
+
} else if (_isPureBitcoinChain(chainInfo)) {
|
|
420
|
+
var _chainInfo$bitcoinInf;
|
|
421
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$bitcoinInf = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf === void 0 ? void 0 : _chainInfo$bitcoinInf.blockExplorer;
|
|
405
422
|
} else {
|
|
406
423
|
var _chainInfo$substrateI18;
|
|
407
424
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
|
|
@@ -577,6 +594,35 @@ export const _chainInfoToChainType = chainInfo => {
|
|
|
577
594
|
}
|
|
578
595
|
return AccountChainType.SUBSTRATE;
|
|
579
596
|
};
|
|
597
|
+
export const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountChainType, accountType) => {
|
|
598
|
+
if (accountChainType === AccountChainType.SUBSTRATE) {
|
|
599
|
+
return _isPureSubstrateChain(chainInfo) && SubstrateKeypairTypes.includes(accountType);
|
|
600
|
+
}
|
|
601
|
+
if (accountChainType === AccountChainType.ETHEREUM) {
|
|
602
|
+
return _isChainEvmCompatible(chainInfo) && EthereumKeypairTypes.includes(accountType);
|
|
603
|
+
}
|
|
604
|
+
if (accountChainType === AccountChainType.TON) {
|
|
605
|
+
return _isChainTonCompatible(chainInfo) && TonKeypairTypes.includes(accountType);
|
|
606
|
+
}
|
|
607
|
+
if (accountChainType === AccountChainType.CARDANO) {
|
|
608
|
+
return _isChainCardanoCompatible(chainInfo) && CardanoKeypairTypes.includes(accountType);
|
|
609
|
+
}
|
|
610
|
+
if (accountChainType === AccountChainType.BITCOIN) {
|
|
611
|
+
var _chainInfo$bitcoinInf2;
|
|
612
|
+
if (!_isChainBitcoinCompatible(chainInfo) || ![...BitcoinMainnetKeypairTypes, ...BitcoinTestnetKeypairTypes].includes(accountType)) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
const network = (_chainInfo$bitcoinInf2 = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf2 === void 0 ? void 0 : _chainInfo$bitcoinInf2.bitcoinNetwork;
|
|
616
|
+
if (BitcoinMainnetKeypairTypes.includes(accountType)) {
|
|
617
|
+
return network === 'mainnet';
|
|
618
|
+
}
|
|
619
|
+
if (BitcoinTestnetKeypairTypes.includes(accountType)) {
|
|
620
|
+
return network === 'testnet';
|
|
621
|
+
}
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
return false;
|
|
625
|
+
};
|
|
580
626
|
export const _getAssetNetuid = assetInfo => {
|
|
581
627
|
var _assetInfo$metadata$n, _assetInfo$metadata;
|
|
582
628
|
// @ts-ignore
|
|
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
7
7
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
-
const ChainListVersion = '0.2.
|
|
8
|
+
const ChainListVersion = '0.2.107'; // update this when build chainlist
|
|
9
9
|
|
|
10
10
|
// todo: move this interface to chainlist
|
|
11
11
|
|
|
@@ -6,6 +6,9 @@ export declare class EventService extends EventEmitter<EventRegistry> {
|
|
|
6
6
|
private lazyEmitter;
|
|
7
7
|
readonly waitCryptoReady: Promise<boolean>;
|
|
8
8
|
readonly waitDatabaseReady: Promise<boolean>;
|
|
9
|
+
readonly waitAppInitialized: Promise<boolean>;
|
|
10
|
+
readonly waitAppStart: Promise<boolean>;
|
|
11
|
+
readonly waitAppStartFull: Promise<boolean>;
|
|
9
12
|
readonly waitKeyringReady: Promise<boolean>;
|
|
10
13
|
readonly waitAccountReady: Promise<boolean>;
|
|
11
14
|
readonly waitInjectReady: Promise<boolean>;
|
|
@@ -18,6 +18,10 @@ export class EventService extends EventEmitter {
|
|
|
18
18
|
this.waitDatabaseReady = this.generateWaitPromise('database.ready');
|
|
19
19
|
this.waitKeyringReady = this.generateWaitPromise('keyring.ready');
|
|
20
20
|
this.waitAccountReady = this.generateWaitPromise('account.ready');
|
|
21
|
+
this.waitAppInitialized = this.generateWaitPromise('general.init');
|
|
22
|
+
this.waitAppStart = this.generateWaitPromise('general.start');
|
|
23
|
+
this.waitAppStartFull = this.generateWaitPromise('general.start_full');
|
|
24
|
+
|
|
21
25
|
// TODO: Need to merge logic on web-runner file
|
|
22
26
|
this.waitInjectReady = TARGET_ENV === 'webapp' ? this.generateWaitPromise('inject.ready') : Promise.resolve(true);
|
|
23
27
|
this.waitChainReady = this.generateWaitPromise('chain.ready');
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SWTransactionBase } from '@subwallet/extension-base/services/transaction-service/types';
|
|
2
2
|
import { CurrentAccountInfo } from '@subwallet/extension-base/types';
|
|
3
3
|
export interface EventRegistry {
|
|
4
|
+
'general.init': [boolean];
|
|
5
|
+
'general.start': [boolean];
|
|
6
|
+
'general.start_full': [boolean];
|
|
4
7
|
'general.sleep': [boolean];
|
|
5
8
|
'general.wakeup': [boolean];
|
|
6
9
|
'crypto.ready': [boolean];
|
|
@@ -10,7 +10,8 @@ export default class FeeService {
|
|
|
10
10
|
evm: {},
|
|
11
11
|
substrate: {},
|
|
12
12
|
ton: {},
|
|
13
|
-
cardano: {}
|
|
13
|
+
cardano: {},
|
|
14
|
+
bitcoin: {}
|
|
14
15
|
};
|
|
15
16
|
constructor(state) {
|
|
16
17
|
this.state = state;
|
|
@@ -101,10 +102,9 @@ export default class FeeService {
|
|
|
101
102
|
if (cancel) {
|
|
102
103
|
clearInterval(interval);
|
|
103
104
|
} else {
|
|
104
|
-
const api = this.state.getEvmApi(chain);
|
|
105
|
-
|
|
106
105
|
// TODO: Handle case type === evm and not have api
|
|
107
106
|
if (type === 'evm') {
|
|
107
|
+
const api = this.state.getEvmApi(chain);
|
|
108
108
|
if (api) {
|
|
109
109
|
calculateGasFeeParams(api, chain).then(info => {
|
|
110
110
|
observer.next(info);
|
|
@@ -126,6 +126,11 @@ export default class FeeService {
|
|
|
126
126
|
options: undefined
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
+
} else if (type === 'bitcoin') {
|
|
130
|
+
const api = this.state.getBitcoinApi(chain);
|
|
131
|
+
api.api.getRecommendedFeeRate().then(info => {
|
|
132
|
+
observer.next(info);
|
|
133
|
+
}).catch(console.error);
|
|
129
134
|
} else {
|
|
130
135
|
observer.next({
|
|
131
136
|
type,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Brc20BalanceFetchedData, Brc20MetadataFetchedData, InscriptionFetchedData } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/strategy/types';
|
|
2
|
+
import { BaseApiRequestStrategy } from '@subwallet/extension-base/strategy/api-request-strategy';
|
|
3
|
+
export declare class HiroService extends BaseApiRequestStrategy {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
private constructor();
|
|
6
|
+
private headers;
|
|
7
|
+
isRateLimited(): boolean;
|
|
8
|
+
getUrl(path: string): string;
|
|
9
|
+
getBRC20Metadata(ticker: string): Promise<Brc20MetadataFetchedData>;
|
|
10
|
+
getAddressBRC20BalanceInfo(address: string, params: Record<string, string>): Promise<Brc20BalanceFetchedData>;
|
|
11
|
+
getAddressInscriptionsInfo(params: Record<string, string>): Promise<InscriptionFetchedData>;
|
|
12
|
+
getInscriptionContent(inscriptionId: string): Promise<Record<string, any>>;
|
|
13
|
+
getPreviewUrl(inscriptionId: string): string;
|
|
14
|
+
private static mainnet;
|
|
15
|
+
private static testnet;
|
|
16
|
+
static getInstance(isTestnet?: boolean): HiroService;
|
|
17
|
+
}
|