@subwallet/extension-base 1.3.42-0 → 1.3.44-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 +35 -23
- package/background/errors/BitcoinProviderError.d.ts +1 -1
- package/background/errors/BitcoinProviderError.js +2 -2
- package/background/types.d.ts +1 -1
- package/cjs/background/errors/BitcoinProviderError.js +2 -2
- package/cjs/core/logic-validation/recipientAddress.js +8 -2
- package/cjs/core/logic-validation/request.js +316 -3
- package/cjs/koni/background/handlers/Extension.js +418 -90
- package/cjs/koni/background/handlers/State.js +198 -6
- 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/buy-service/index.js +17 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +27 -5
- package/cjs/services/request-service/handler/AuthRequestHandler.js +18 -0
- package/cjs/services/request-service/handler/BitcoinRequestHandler.js +48 -61
- package/cjs/services/request-service/index.js +2 -2
- package/cjs/services/transaction-service/index.js +71 -2
- package/cjs/utils/auth.js +2 -1
- package/core/logic-validation/recipientAddress.js +8 -2
- package/core/logic-validation/request.d.ts +6 -2
- package/core/logic-validation/request.js +309 -3
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +330 -6
- package/koni/background/handlers/State.d.ts +4 -1
- package/koni/background/handlers/State.js +189 -4
- package/koni/background/handlers/Tabs.d.ts +7 -2
- package/koni/background/handlers/Tabs.js +119 -9
- package/package.json +11 -6
- 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/transfer/cardano-transfer.d.ts +2 -0
- package/services/buy-service/index.js +17 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +27 -5
- package/services/request-service/handler/AuthRequestHandler.js +19 -1
- package/services/request-service/handler/BitcoinRequestHandler.d.ts +3 -4
- package/services/request-service/handler/BitcoinRequestHandler.js +48 -61
- package/services/request-service/index.d.ts +1 -2
- package/services/request-service/index.js +2 -2
- package/services/transaction-service/index.d.ts +1 -0
- package/services/transaction-service/index.js +71 -2
- package/services/transaction-service/types.d.ts +1 -0
- package/types/balance/transfer.d.ts +4 -2
- package/types/buy.d.ts +1 -1
- package/utils/auth.js +3 -2
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
import { BitcoinProviderError } from '@subwallet/extension-base/background/errors/BitcoinProviderError';
|
|
5
5
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
6
6
|
import { BitcoinProviderErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
7
|
-
import { createBitcoinTransaction } from '@subwallet/extension-base/services/balance-service/transfer/bitcoin-transfer';
|
|
8
7
|
import { BasicTxErrorType } from '@subwallet/extension-base/types';
|
|
9
8
|
import { createPromiseHandler } from '@subwallet/extension-base/utils';
|
|
10
|
-
import { getId } from '@subwallet/extension-base/utils/getId';
|
|
11
9
|
import { isInternalRequest } from '@subwallet/extension-base/utils/request';
|
|
12
10
|
import keyring from '@subwallet/ui-keyring';
|
|
13
11
|
import { Psbt } from 'bitcoinjs-lib';
|
|
@@ -19,7 +17,6 @@ export default class BitcoinRequestHandler {
|
|
|
19
17
|
#requestService;
|
|
20
18
|
#chainService;
|
|
21
19
|
#transactionService;
|
|
22
|
-
#feeService;
|
|
23
20
|
#logger;
|
|
24
21
|
confirmationsQueueSubjectBitcoin = new BehaviorSubject({
|
|
25
22
|
bitcoinSignatureRequest: {},
|
|
@@ -29,10 +26,9 @@ export default class BitcoinRequestHandler {
|
|
|
29
26
|
bitcoinSignPsbtRequest: {}
|
|
30
27
|
});
|
|
31
28
|
confirmationsPromiseMap = {};
|
|
32
|
-
constructor(requestService, chainService,
|
|
29
|
+
constructor(requestService, chainService, transactionService) {
|
|
33
30
|
this.#requestService = requestService;
|
|
34
31
|
this.#chainService = chainService;
|
|
35
|
-
this.#feeService = feeService;
|
|
36
32
|
this.#transactionService = transactionService;
|
|
37
33
|
this.#logger = createLogger('BitcoinRequestHandler');
|
|
38
34
|
}
|
|
@@ -51,7 +47,7 @@ export default class BitcoinRequestHandler {
|
|
|
51
47
|
const confirmationType = confirmations[type];
|
|
52
48
|
const payloadJson = JSON.stringify(payload);
|
|
53
49
|
const isInternal = isInternalRequest(url);
|
|
54
|
-
if (['bitcoinSignatureRequest', 'bitcoinSendTransactionRequest', 'bitcoinSendTransactionRequestAfterConfirmation'].includes(type)) {
|
|
50
|
+
if (['bitcoinSignatureRequest', 'bitcoinSendTransactionRequest', 'bitcoinSendTransactionRequestAfterConfirmation', 'bitcoinSignPsbtRequest'].includes(type)) {
|
|
55
51
|
const isAlwaysRequired = await this.#requestService.settingService.isAlwaysRequired;
|
|
56
52
|
if (isAlwaysRequired) {
|
|
57
53
|
this.#requestService.keyringService.lock();
|
|
@@ -110,10 +106,9 @@ export default class BitcoinRequestHandler {
|
|
|
110
106
|
}
|
|
111
107
|
signMessageBitcoin(confirmation) {
|
|
112
108
|
const {
|
|
113
|
-
|
|
109
|
+
address,
|
|
114
110
|
payload
|
|
115
111
|
} = confirmation.payload;
|
|
116
|
-
const address = account.address;
|
|
117
112
|
const pair = keyring.getPair(address);
|
|
118
113
|
if (pair.isLocked) {
|
|
119
114
|
keyring.unlockPair(pair.address);
|
|
@@ -146,10 +141,9 @@ export default class BitcoinRequestHandler {
|
|
|
146
141
|
signTransactionBitcoin(request) {
|
|
147
142
|
// Extract necessary information from the BitcoinSendTransactionRequest
|
|
148
143
|
const {
|
|
149
|
-
|
|
144
|
+
address,
|
|
150
145
|
hashPayload
|
|
151
146
|
} = request.payload;
|
|
152
|
-
const address = account.address;
|
|
153
147
|
const pair = keyring.getPair(address);
|
|
154
148
|
|
|
155
149
|
// Unlock the pair if it is locked
|
|
@@ -169,59 +163,25 @@ export default class BitcoinRequestHandler {
|
|
|
169
163
|
const {
|
|
170
164
|
chain,
|
|
171
165
|
emitterTransaction,
|
|
172
|
-
feeCustom,
|
|
173
|
-
feeOption,
|
|
174
166
|
id
|
|
175
167
|
} = transaction;
|
|
176
168
|
const {
|
|
177
|
-
from
|
|
178
|
-
to,
|
|
179
|
-
value
|
|
169
|
+
from
|
|
180
170
|
} = transaction.data;
|
|
171
|
+
const {
|
|
172
|
+
promise,
|
|
173
|
+
reject,
|
|
174
|
+
resolve
|
|
175
|
+
} = createPromiseHandler();
|
|
181
176
|
if (!emitterTransaction) {
|
|
182
177
|
throw new BitcoinProviderError(BitcoinProviderErrorType.INTERNAL_ERROR);
|
|
183
178
|
}
|
|
184
|
-
const chainInfo = this.#chainService.getChainInfoByKey(chain);
|
|
185
|
-
const bitcoinApi = this.#chainService.getBitcoinApi(chain);
|
|
186
179
|
const eventData = {
|
|
187
180
|
id,
|
|
188
181
|
errors: [],
|
|
189
182
|
warnings: [],
|
|
190
183
|
extrinsicHash: id
|
|
191
184
|
};
|
|
192
|
-
const network = chainInfo.isTestnet ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
|
|
193
|
-
const feeInfo = await this.#feeService.subscribeChainFee(getId(), chain, 'bitcoin');
|
|
194
|
-
const [psbt] = await createBitcoinTransaction({
|
|
195
|
-
bitcoinApi,
|
|
196
|
-
chain,
|
|
197
|
-
from,
|
|
198
|
-
feeCustom,
|
|
199
|
-
feeOption,
|
|
200
|
-
feeInfo,
|
|
201
|
-
to,
|
|
202
|
-
transferAll: false,
|
|
203
|
-
value: value || '0',
|
|
204
|
-
network
|
|
205
|
-
});
|
|
206
|
-
const pair = keyring.getPair(from);
|
|
207
|
-
|
|
208
|
-
// Unlock the pair if it is locked
|
|
209
|
-
if (pair.isLocked) {
|
|
210
|
-
keyring.unlockPair(pair.address);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Finalize all inputs in the Psbt
|
|
214
|
-
|
|
215
|
-
// Sign the Psbt using the pair's bitcoin object
|
|
216
|
-
const signedTransaction = pair.bitcoin.signTransaction(psbt, psbt.txInputs.map((v, i) => i));
|
|
217
|
-
signedTransaction.finalizeAllInputs();
|
|
218
|
-
const signature = signedTransaction.extractTransaction().toHex();
|
|
219
|
-
this.#transactionService.emitterEventTransaction(emitterTransaction, eventData, chainInfo.slug, signature);
|
|
220
|
-
const {
|
|
221
|
-
promise,
|
|
222
|
-
reject,
|
|
223
|
-
resolve
|
|
224
|
-
} = createPromiseHandler();
|
|
225
185
|
emitterTransaction.on('extrinsicHash', data => {
|
|
226
186
|
if (!data.extrinsicHash) {
|
|
227
187
|
reject(BitcoinProviderErrorType.INTERNAL_ERROR);
|
|
@@ -232,34 +192,56 @@ export default class BitcoinRequestHandler {
|
|
|
232
192
|
emitterTransaction.on('error', error => {
|
|
233
193
|
reject(error);
|
|
234
194
|
});
|
|
195
|
+
try {
|
|
196
|
+
const chainInfo = this.#chainService.getChainInfoByKey(chain);
|
|
197
|
+
const psbt = transaction.transaction;
|
|
198
|
+
const pair = keyring.getPair(from);
|
|
199
|
+
|
|
200
|
+
// Unlock the pair if it is locked
|
|
201
|
+
if (pair.isLocked) {
|
|
202
|
+
keyring.unlockPair(pair.address);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Finalize all inputs in the Psbt
|
|
206
|
+
// Sign the Psbt using the pair's bitcoin object
|
|
207
|
+
const signedTransaction = pair.bitcoin.signTransaction(psbt, psbt.txInputs.map((v, i) => i));
|
|
208
|
+
signedTransaction.finalizeAllInputs();
|
|
209
|
+
const signature = signedTransaction.extractTransaction().toHex();
|
|
210
|
+
this.#transactionService.emitterEventTransaction(emitterTransaction, eventData, chainInfo.slug, signature);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
emitterTransaction.emit('error', {
|
|
213
|
+
...eventData,
|
|
214
|
+
errors: [new TransactionError(BasicTxErrorType.INTERNAL_ERROR, e.message)]
|
|
215
|
+
});
|
|
216
|
+
}
|
|
235
217
|
return promise;
|
|
236
218
|
}
|
|
237
219
|
async signPsbt(request) {
|
|
238
220
|
// Extract necessary information from the BitcoinSendTransactionRequest
|
|
239
221
|
const {
|
|
240
|
-
|
|
222
|
+
address,
|
|
241
223
|
payload
|
|
242
224
|
} = request.payload;
|
|
243
225
|
const {
|
|
244
226
|
allowedSighash,
|
|
227
|
+
autoFinalized = true,
|
|
245
228
|
broadcast,
|
|
246
|
-
|
|
229
|
+
network,
|
|
230
|
+
psbt: psbtHex,
|
|
247
231
|
signAtIndex
|
|
248
232
|
} = payload;
|
|
249
233
|
const transaction = this.#transactionService.getTransaction(request.id);
|
|
234
|
+
const bitcoinNetwork = network === 'bitcoinTestnet' ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
|
|
235
|
+
const psbt = bitcoin.Psbt.fromHex(psbtHex, {
|
|
236
|
+
network: bitcoinNetwork
|
|
237
|
+
});
|
|
250
238
|
let eventData = {
|
|
251
239
|
id: request.id,
|
|
252
240
|
errors: [],
|
|
253
241
|
warnings: [],
|
|
254
242
|
extrinsicHash: request.id
|
|
255
243
|
};
|
|
256
|
-
|
|
257
|
-
// todo: validate type of the account
|
|
258
|
-
|
|
259
|
-
if (Object.keys(account).length === 0) {
|
|
260
|
-
throw new BitcoinProviderError(BitcoinProviderErrorType.INVALID_PARAMS, 'Please connect to Wallet to try this request');
|
|
261
|
-
}
|
|
262
|
-
const pair = keyring.getPair(account.address);
|
|
244
|
+
const pair = keyring.getPair(address);
|
|
263
245
|
|
|
264
246
|
// Unlock the pair if it is locked
|
|
265
247
|
if (pair.isLocked) {
|
|
@@ -287,8 +269,10 @@ export default class BitcoinRequestHandler {
|
|
|
287
269
|
throw new Error('Unable to sign');
|
|
288
270
|
}
|
|
289
271
|
if (!broadcast) {
|
|
290
|
-
|
|
291
|
-
|
|
272
|
+
if (autoFinalized) {
|
|
273
|
+
for (const index of signAtIndexGenerate) {
|
|
274
|
+
psptSignedTransaction.finalizeInput(index);
|
|
275
|
+
}
|
|
292
276
|
}
|
|
293
277
|
return {
|
|
294
278
|
psbt: psptSignedTransaction.toHex()
|
|
@@ -313,6 +297,9 @@ export default class BitcoinRequestHandler {
|
|
|
313
297
|
}
|
|
314
298
|
const chainInfo = this.#chainService.getChainInfoByKey(chain);
|
|
315
299
|
try {
|
|
300
|
+
if (!autoFinalized) {
|
|
301
|
+
throw new Error('Unable to send transaction without autoFinalized');
|
|
302
|
+
}
|
|
316
303
|
psptSignedTransaction.finalizeAllInputs();
|
|
317
304
|
} catch (e) {
|
|
318
305
|
emitterTransaction.emit('error', {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AuthRequestV2, ConfirmationDefinitions, ConfirmationDefinitionsBitcoin, ConfirmationDefinitionsCardano, ConfirmationDefinitionsTon, ConfirmationsQueue, ConfirmationsQueueBitcoin, ConfirmationsQueueCardano, ConfirmationsQueueItemOptions, ConfirmationsQueueTon, ConfirmationType, ConfirmationTypeBitcoin, ConfirmationTypeCardano, ConfirmationTypeTon, RequestConfirmationComplete, RequestConfirmationCompleteBitcoin, RequestConfirmationCompleteCardano, RequestConfirmationCompleteTon } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import { AccountAuthType, AuthorizeRequest, MetadataRequest, RequestAuthorizeTab, RequestSign, ResponseSigning, SigningRequest } from '@subwallet/extension-base/background/types';
|
|
3
3
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
4
|
-
import FeeService from '@subwallet/extension-base/services/fee-service/service';
|
|
5
4
|
import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
|
|
6
5
|
import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
|
|
7
6
|
import TransactionService from '@subwallet/extension-base/services/transaction-service';
|
|
@@ -14,7 +13,7 @@ export default class RequestService {
|
|
|
14
13
|
#private;
|
|
15
14
|
readonly settingService: SettingService;
|
|
16
15
|
readonly keyringService: KeyringService;
|
|
17
|
-
constructor(chainService: ChainService, settingService: SettingService, keyringService: KeyringService,
|
|
16
|
+
constructor(chainService: ChainService, settingService: SettingService, keyringService: KeyringService, transactionService: TransactionService);
|
|
18
17
|
get numAllRequests(): number;
|
|
19
18
|
updateIconV2(shouldClose?: boolean): void;
|
|
20
19
|
getAddressList(value?: boolean): Record<string, boolean>;
|
|
@@ -20,7 +20,7 @@ export default class RequestService {
|
|
|
20
20
|
#notSupportWCRequestHandler;
|
|
21
21
|
|
|
22
22
|
// Common
|
|
23
|
-
constructor(chainService, settingService, keyringService,
|
|
23
|
+
constructor(chainService, settingService, keyringService, transactionService) {
|
|
24
24
|
this.#chainService = chainService;
|
|
25
25
|
this.settingService = settingService;
|
|
26
26
|
this.keyringService = keyringService;
|
|
@@ -31,7 +31,7 @@ export default class RequestService {
|
|
|
31
31
|
this.#evmRequestHandler = new EvmRequestHandler(this);
|
|
32
32
|
this.#tonRequestHandler = new TonRequestHandler(this);
|
|
33
33
|
this.#cardanoRequestHandler = new CardanoRequestHandler(this);
|
|
34
|
-
this.#bitcoinRequestHandler = new BitcoinRequestHandler(this, this.#chainService,
|
|
34
|
+
this.#bitcoinRequestHandler = new BitcoinRequestHandler(this, this.#chainService, transactionService);
|
|
35
35
|
this.#connectWCRequestHandler = new ConnectWCRequestHandler(this);
|
|
36
36
|
this.#notSupportWCRequestHandler = new NotSupportWCRequestHandler(this);
|
|
37
37
|
|
|
@@ -36,6 +36,7 @@ export default class TransactionService {
|
|
|
36
36
|
addDutchTransaction(inputTransaction: SWDutchTransactionInput): TransactionEmitter;
|
|
37
37
|
generateBeforeHandleResponseErrors(errors: TransactionError[]): SWTransactionResponse;
|
|
38
38
|
handleTransaction(transaction: SWTransactionInput): Promise<SWTransactionResponse>;
|
|
39
|
+
handleTransactionAfterConfirmation(transaction: SWTransactionInput): Promise<SWTransactionResponse>;
|
|
39
40
|
handlePermitTransaction(transaction: SWPermitTransactionInput): Promise<SWTransactionResponse>;
|
|
40
41
|
handleDutchTransaction(transaction: SWDutchTransactionInput): Promise<SWTransactionResponse>;
|
|
41
42
|
private sendTransaction;
|
|
@@ -119,7 +119,9 @@ export default class TransactionService {
|
|
|
119
119
|
const isNonNativeTokenPayFee = tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug);
|
|
120
120
|
const nonNativeTokenPayFeeInfo = isNonNativeTokenPayFee ? this.state.chainService.getAssetBySlug(tokenPayFeeSlug) : undefined;
|
|
121
121
|
const priceMap = (await this.state.priceService.getPrice()).priceMap;
|
|
122
|
-
|
|
122
|
+
if (!transactionInput.skipFeeRecalculation) {
|
|
123
|
+
validationResponse.estimateFee = await estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, transactionInput.isTransferLocalTokenAndPayThatTokenAsFee);
|
|
124
|
+
}
|
|
123
125
|
const chainInfoMap = this.state.chainService.getChainInfoMap();
|
|
124
126
|
|
|
125
127
|
// Check account signing transaction
|
|
@@ -300,6 +302,73 @@ export default class TransactionService {
|
|
|
300
302
|
'eventsHandler' in validatedTransaction && delete validatedTransaction.eventsHandler;
|
|
301
303
|
return validatedTransaction;
|
|
302
304
|
}
|
|
305
|
+
async handleTransactionAfterConfirmation(transaction) {
|
|
306
|
+
const validatedTransaction = await this.validateTransaction(transaction);
|
|
307
|
+
const stopByErrors = validatedTransaction.errors.length > 0;
|
|
308
|
+
const stopByWarnings = validatedTransaction.warnings.length > 0 && !validatedTransaction.ignoreWarnings;
|
|
309
|
+
if (stopByErrors || stopByWarnings) {
|
|
310
|
+
// @ts-ignore
|
|
311
|
+
'transaction' in validatedTransaction && delete validatedTransaction.transaction;
|
|
312
|
+
'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
|
|
313
|
+
'eventsHandler' in validatedTransaction && delete validatedTransaction.eventsHandler;
|
|
314
|
+
return validatedTransaction;
|
|
315
|
+
}
|
|
316
|
+
validatedTransaction.warnings = [];
|
|
317
|
+
const transactionsSubject = this.transactions;
|
|
318
|
+
const emitter = new EventEmitter();
|
|
319
|
+
|
|
320
|
+
// Fill transaction default info
|
|
321
|
+
const transactionUpdated = this.fillTransactionDefaultInfo(validatedTransaction);
|
|
322
|
+
|
|
323
|
+
// Add Transaction
|
|
324
|
+
transactionsSubject[transactionUpdated.id] = {
|
|
325
|
+
...transactionUpdated,
|
|
326
|
+
emitterTransaction: emitter
|
|
327
|
+
};
|
|
328
|
+
this.transactionSubject.next({
|
|
329
|
+
...transactionsSubject
|
|
330
|
+
});
|
|
331
|
+
emitter.on('success', data => {
|
|
332
|
+
validatedTransaction.id = data.id;
|
|
333
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
334
|
+
this.handlePostProcessing(data.id);
|
|
335
|
+
this.onSuccess(data);
|
|
336
|
+
});
|
|
337
|
+
emitter.on('signed', data => {
|
|
338
|
+
validatedTransaction.id = data.id;
|
|
339
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
340
|
+
this.onSigned(data);
|
|
341
|
+
});
|
|
342
|
+
emitter.on('error', data => {
|
|
343
|
+
if (data.errors.length > 0) {
|
|
344
|
+
validatedTransaction.errors.push(...data.errors);
|
|
345
|
+
}
|
|
346
|
+
this.onFailed({
|
|
347
|
+
...data,
|
|
348
|
+
errors: [...data.errors, new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
emitter.on('send', data => {
|
|
352
|
+
this.onSend(data);
|
|
353
|
+
});
|
|
354
|
+
emitter.on('extrinsicHash', data => {
|
|
355
|
+
this.onHasTransactionHash(data);
|
|
356
|
+
});
|
|
357
|
+
emitter.on('timeout', data => {
|
|
358
|
+
this.onTimeOut({
|
|
359
|
+
...data,
|
|
360
|
+
errors: [...data.errors, new TransactionError(BasicTxErrorType.TIMEOUT)]
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// @ts-ignore
|
|
365
|
+
'transaction' in validatedTransaction && delete validatedTransaction.transaction;
|
|
366
|
+
'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
|
|
367
|
+
'eventsHandler' in validatedTransaction && delete validatedTransaction.eventsHandler;
|
|
368
|
+
return {
|
|
369
|
+
...validatedTransaction
|
|
370
|
+
};
|
|
371
|
+
}
|
|
303
372
|
async handlePermitTransaction(transaction) {
|
|
304
373
|
var _transaction$step;
|
|
305
374
|
const transactionId = getTransactionId(transaction.chainType, transaction.chain, true);
|
|
@@ -1923,7 +1992,7 @@ export default class TransactionService {
|
|
|
1923
1992
|
const payload = {
|
|
1924
1993
|
payload: undefined,
|
|
1925
1994
|
payloadJson: undefined,
|
|
1926
|
-
|
|
1995
|
+
address,
|
|
1927
1996
|
canSign: true,
|
|
1928
1997
|
hashPayload: tx.toHex(),
|
|
1929
1998
|
id
|
|
@@ -60,6 +60,7 @@ export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransact
|
|
|
60
60
|
isTransferLocalTokenAndPayThatTokenAsFee?: boolean;
|
|
61
61
|
resolveOnDone?: boolean;
|
|
62
62
|
skipFeeValidation?: boolean;
|
|
63
|
+
skipFeeRecalculation?: boolean;
|
|
63
64
|
}
|
|
64
65
|
export interface SWPermitTransactionInput extends Omit<SWTransactionInput, 'transaction'> {
|
|
65
66
|
transaction?: SWPermitTransaction['transaction'] | null;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PsbtTransactionArg } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import { BaseRequestSign } from '@subwallet/extension-base/types';
|
|
3
|
-
import { Psbt } from 'bitcoinjs-lib';
|
|
4
3
|
import { FeeChainType, FeeDetail, TransactionFee } from '../fee';
|
|
5
4
|
export interface RequestSubscribeTransfer extends TransactionFee {
|
|
6
5
|
address: string;
|
|
@@ -21,6 +20,9 @@ export interface ResponseSubscribeTransfer {
|
|
|
21
20
|
export interface RequestSubmitTransferWithId extends RequestSubmitTransfer {
|
|
22
21
|
id?: string;
|
|
23
22
|
}
|
|
23
|
+
export interface ResponseSubscribeTransferConfirmation extends Omit<ResponseSubscribeTransfer, 'maxTransferable'> {
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
24
26
|
export interface RequestSubmitTransfer extends BaseRequestSign, TransactionFee {
|
|
25
27
|
chain: string;
|
|
26
28
|
from: string;
|
|
@@ -39,5 +41,5 @@ export interface RequestSubmitSignPsbtTransfer extends BaseRequestSign {
|
|
|
39
41
|
txInput: PsbtTransactionArg[];
|
|
40
42
|
txOutput: PsbtTransactionArg[];
|
|
41
43
|
tokenSlug: string;
|
|
42
|
-
psbt:
|
|
44
|
+
psbt: string;
|
|
43
45
|
}
|
package/types/buy.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface BuyService {
|
|
|
4
4
|
symbol: string;
|
|
5
5
|
}
|
|
6
6
|
export declare type SupportService = 'transak' | 'banxa' | 'coinbase' | 'moonpay' | 'onramper' | 'meld';
|
|
7
|
-
export declare type OnrampAccountSupportType = 'ETHEREUM' | 'SUBSTRATE';
|
|
7
|
+
export declare type OnrampAccountSupportType = 'ETHEREUM' | 'SUBSTRATE' | 'TON' | 'CARDANO';
|
|
8
8
|
export interface BuyTokenInfo {
|
|
9
9
|
network: string;
|
|
10
10
|
symbol: string;
|
package/utils/auth.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { getKeypairTypeByAddress } from '@subwallet/keyring';
|
|
5
|
-
import { CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
5
|
+
import { BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
6
6
|
export const isAddressValidWithAuthType = (address, accountAuthTypes) => {
|
|
7
7
|
const keypairType = getKeypairTypeByAddress(address);
|
|
8
8
|
const validTypes = {
|
|
9
9
|
evm: EthereumKeypairTypes,
|
|
10
10
|
substrate: SubstrateKeypairTypes,
|
|
11
11
|
ton: TonKeypairTypes,
|
|
12
|
-
cardano: CardanoKeypairTypes
|
|
12
|
+
cardano: CardanoKeypairTypes,
|
|
13
|
+
bitcoin: BitcoinKeypairTypes
|
|
13
14
|
};
|
|
14
15
|
return !!(accountAuthTypes !== null && accountAuthTypes !== void 0 && accountAuthTypes.some(authType => {
|
|
15
16
|
var _validTypes$authType;
|