@trezor/connect 9.5.3-beta.1 → 9.5.4-beta.1
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/CHANGELOG.md +39 -5
- package/README.md +1 -1
- package/lib/api/binance/api/binanceSignTransaction.js +1 -1
- package/lib/api/bitcoin/BitcoinFees.d.ts +4 -6
- package/lib/api/bitcoin/BitcoinFees.js +8 -2
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/bitcoin/signtxVerify.js +3 -3
- package/lib/api/blockchainEstimateFee.js +13 -13
- package/lib/api/cardano/api/cardanoSignTransaction.js +1 -1
- package/lib/api/common/Discovery.d.ts +4 -4
- package/lib/api/common/Discovery.js +3 -4
- package/lib/api/common/MiscFees.d.ts +5 -9
- package/lib/api/common/MiscFees.js +6 -21
- package/lib/api/composeTransaction.js +4 -3
- package/lib/api/eos/api/eosSignTransaction.js +1 -1
- package/lib/api/eos/eosSignTx.d.ts +2 -2
- package/lib/api/ethereum/EthereumFees.d.ts +5 -8
- package/lib/api/ethereum/EthereumFees.js +24 -38
- package/lib/api/ethereum/api/ethereumGetAddress.d.ts +1 -5
- package/lib/api/ethereum/api/ethereumGetAddress.js +7 -8
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +11 -7
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +12 -5
- package/lib/api/ethereum/api/ethereumSignTransaction.js +2 -2
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -4
- package/lib/api/ethereum/api/ethereumSignTypedData.js +1 -1
- package/lib/api/firmware/uploadFirmware.d.ts +2 -2
- package/lib/api/getAccountDescriptor.js +1 -3
- package/lib/api/getAccountInfo.js +4 -9
- package/lib/api/getAddress.js +6 -7
- package/lib/api/getCoinInfo.d.ts +12 -18
- package/lib/api/getPublicKey.d.ts +11 -7
- package/lib/api/resetDevice.js +1 -3
- package/lib/api/signTransaction.js +3 -3
- package/lib/api/stellar/api/stellarSignTransaction.js +1 -1
- package/lib/constants/errors.d.ts +1 -2
- package/lib/constants/errors.js +8 -3
- package/lib/core/index.js +36 -15
- package/lib/core/onCallFirmwareUpdate.js +6 -3
- package/lib/data/coinInfo.d.ts +44 -66
- package/lib/data/config.d.ts +10 -0
- package/lib/data/config.js +10 -0
- package/lib/data/deviceAuthenticityConfig.js +4 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +82 -16
- package/lib/device/Device.js +51 -61
- package/lib/device/DeviceCommands.d.ts +37 -4549
- package/lib/device/DeviceCommands.js +55 -264
- package/lib/device/DeviceCurrentSession.d.ts +4531 -0
- package/lib/device/DeviceCurrentSession.js +209 -0
- package/lib/device/DeviceList.js +4 -6
- package/lib/device/TransportManager.d.ts +1 -1
- package/lib/device/TransportManager.js +5 -4
- package/lib/events/ui-response.d.ts +3 -3
- package/lib/impl/dynamic.d.ts +4 -1
- package/lib/impl/dynamic.js +17 -4
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/lib/types/api/getPublicKey.d.ts +5 -3
- package/lib/types/api/getPublicKey.js +13 -12
- package/lib/types/coinInfo.d.ts +12 -24
- package/lib/types/fees.d.ts +2 -11
- package/lib/types/fees.js +3 -11
- package/lib/utils/versionCheck.js +1 -1
- package/package.json +14 -14
- package/lib/device/prompts.d.ts +0 -866
- package/lib/device/prompts.js +0 -60
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
| Package | Stable | Canary |
|
|
2
2
|
| :------------------------------: | :----: | :----------: |
|
|
3
|
-
| npm @trezor/connect | 9.5.
|
|
4
|
-
| npm @trezor/connect-web | 9.5.
|
|
5
|
-
| npm @trezor/connect-webextension | 9.5.
|
|
3
|
+
| npm @trezor/connect | 9.5.3 | 9.5.4-beta.1 |
|
|
4
|
+
| npm @trezor/connect-web | 9.5.3 | 9.5.4-beta.1 |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.5.3 | 9.5.4-beta.1 |
|
|
6
6
|
| npm @trezor/connect-mobile | - | 0.0.1-beta.1 |
|
|
7
7
|
|
|
8
8
|
| Deployment | Stable | Canary |
|
|
9
9
|
| :----------------: | :----: | :----------: |
|
|
10
|
-
| connect.trezor.io/ | 9.5.
|
|
10
|
+
| connect.trezor.io/ | 9.5.3 | 9.5.4-beta.1 |
|
|
11
11
|
|
|
12
12
|
Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to access the latest stable version of Connect Explorer.
|
|
13
13
|
|
|
14
|
-
# 9.5.
|
|
14
|
+
# 9.5.4-beta.1
|
|
15
|
+
|
|
16
|
+
If you are using @trezor/connect-web you must be using at least 9.1.5 starting from this release.
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- add descriptor to getPublicKey response (cbfec9b)
|
|
21
|
+
- implement EVM EIP-1559 fees for ethereum in blockchainEstimateFee method (0475047)
|
|
22
|
+
- improvements in @trezor/connect-web package regarding support of calling @trezor/connect inside suite-desktop application. always attempt reconnection for core in desktop (21da232); implement @trezor/websocket client in core-in-suite-desktop (9744c5b); error fallback for core in desktop (64cbd47)
|
|
23
|
+
|
|
24
|
+
## Fixes
|
|
25
|
+
|
|
26
|
+
- fixing session releasing on page unload (6d01d78)
|
|
27
|
+
- fixing missing session owner in device object (e2116c1)
|
|
28
|
+
- turn off language update during fw update for T3T1 since it does not fit device memory (283d829)
|
|
29
|
+
|
|
30
|
+
## Chores
|
|
31
|
+
|
|
32
|
+
- migrate ripple-lib to xrpl.js (422c175)
|
|
33
|
+
- reuse PublicKey type in HDNodeResponse type definition (6c841d9)
|
|
34
|
+
- update device authenticity config (bf82b92)
|
|
35
|
+
- connect core refactoring (1d62c9b 19b6e5e 0dd2933 f9998f3 7dc1290 b685518 fb14734)
|
|
36
|
+
- pass full request object parameter in blockchainEstimateFee method down to @trezor/blockchain-link to allow more fine-grained backend calls (19c5952)
|
|
37
|
+
- refactoring in visual components (00e7df5, b3a4791)
|
|
38
|
+
|
|
39
|
+
## Deps
|
|
40
|
+
|
|
41
|
+
- update next-seo from 6.0.0 to 6.6.0 (b5a818e)
|
|
42
|
+
- update swr from 2.2.5 to 2.3.3 (6d98da6)
|
|
43
|
+
- update remark-gfm from 4.0.0 to 4.0.1 (21a8f89)
|
|
44
|
+
- update zod from 3.23.8 to 3.24.2 (afc3d9b)
|
|
45
|
+
- update ua-parser-js@2.0.3 (840d5c6)
|
|
46
|
+
- upgrade next js for connect explorer theme (951e047)
|
|
47
|
+
|
|
48
|
+
# 9.5.3
|
|
15
49
|
|
|
16
50
|
## Fixes
|
|
17
51
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.5.
|
|
3
|
+
API version 9.5.4-beta.1
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -27,7 +27,7 @@ class BinanceSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
27
27
|
return 'Sign Binance transaction';
|
|
28
28
|
}
|
|
29
29
|
run() {
|
|
30
|
-
return helper.signTx(this.device.getCommands().typedCall
|
|
30
|
+
return helper.signTx(this.device.getCommands().typedCall, this.params.path, this.params.transaction, this.params.chunkify);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
exports.default = BinanceSignTransaction;
|
|
@@ -8,17 +8,15 @@ export declare class BitcoinFeeLevels {
|
|
|
8
8
|
blocks: Blocks;
|
|
9
9
|
constructor(coinInfo: BitcoinNetworkInfo);
|
|
10
10
|
load(blockchain: Blockchain): Promise<{
|
|
11
|
+
feePerTx?: string | undefined;
|
|
12
|
+
feeLimit?: string | undefined;
|
|
13
|
+
baseFeePerGas?: string | undefined;
|
|
11
14
|
maxFeePerGas?: string | undefined;
|
|
12
15
|
maxPriorityFeePerGas?: string | undefined;
|
|
13
16
|
maxWaitTimeEstimate?: number | undefined;
|
|
14
|
-
minWaitTimeEstimate?: number | undefined;
|
|
15
|
-
feeLimit?: string | undefined;
|
|
16
|
-
feePerTx?: string | undefined;
|
|
17
|
-
baseFeePerGas?: string | undefined;
|
|
18
|
-
effectiveGasPrice?: string | undefined;
|
|
19
17
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
20
|
-
feePerUnit: string;
|
|
21
18
|
blocks: number;
|
|
19
|
+
feePerUnit: string;
|
|
22
20
|
}[]>;
|
|
23
21
|
updateBitcoinCustomFee(feePerUnit: string): void;
|
|
24
22
|
}
|
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BitcoinFeeLevels = void 0;
|
|
4
4
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
|
-
const
|
|
5
|
+
const findBlocksForFee = (feePerUnit, blocks) => {
|
|
6
|
+
const fee = new bigNumber_1.BigNumber(feePerUnit);
|
|
7
|
+
const lower = blocks.find(block => typeof block === 'string' && fee.gte(block));
|
|
8
|
+
if (!lower)
|
|
9
|
+
return -1;
|
|
10
|
+
return blocks.indexOf(lower);
|
|
11
|
+
};
|
|
6
12
|
const convertFeeRate = (fee, minFee) => {
|
|
7
13
|
const feePerKB = new bigNumber_1.BigNumber(fee);
|
|
8
14
|
if (feePerKB.isNaN() || feePerKB.lte('0'))
|
|
@@ -86,7 +92,7 @@ class BitcoinFeeLevels {
|
|
|
86
92
|
}
|
|
87
93
|
updateBitcoinCustomFee(feePerUnit) {
|
|
88
94
|
this.levels = this.levels.filter(l => l.label !== 'custom');
|
|
89
|
-
const blocks =
|
|
95
|
+
const blocks = findBlocksForFee(feePerUnit, this.blocks);
|
|
90
96
|
this.levels.push({
|
|
91
97
|
label: 'custom',
|
|
92
98
|
feePerUnit,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PROTO } from '../../constants';
|
|
2
2
|
import type { DeviceCommands } from '../../device/DeviceCommands';
|
|
3
3
|
import type { BitcoinNetworkInfo } from '../../types';
|
|
4
|
-
type GetHDNode = DeviceCommands['getHDNode'];
|
|
4
|
+
type GetHDNode = ReturnType<typeof DeviceCommands>['getHDNode'];
|
|
5
5
|
export declare const verifyTx: (getHDNode: GetHDNode, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[], serializedTx: string, coinInfo: BitcoinNetworkInfo, unlockPath?: PROTO.UnlockPath) => Promise<import("@trezor/utxo-lib/lib/transaction/base").TransactionBase<undefined> | import("@trezor/utxo-lib/lib/transaction/base").TransactionBase<import("@trezor/utxo-lib/lib/transaction/dash").DashSpecific> | import("@trezor/utxo-lib/lib/transaction/base").TransactionBase<import("@trezor/utxo-lib/lib/transaction/zcash").ZcashSpecific>>;
|
|
6
6
|
export declare const verifyTicketTx: (getHDNode: GetHDNode, inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[], serializedTx: string, coinInfo: BitcoinNetworkInfo) => Promise<void>;
|
|
7
7
|
export {};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.verifyTicketTx = exports.verifyTx = void 0;
|
|
4
4
|
const utxo_lib_1 = require("@trezor/utxo-lib");
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
|
-
const derivePubKeyHash = async (
|
|
6
|
+
const derivePubKeyHash = async (getHDNode, address_n, coinInfo, unlockPath) => {
|
|
7
7
|
if (address_n.length === 5) {
|
|
8
8
|
const response = await getHDNode({ address_n: address_n.slice(0, 4) }, { coinInfo, unlockPath });
|
|
9
9
|
const node = utxo_lib_1.bip32.fromBase58(response.xpub, coinInfo.network);
|
|
@@ -25,7 +25,7 @@ const deriveOutputScript = async (getHDNode, output, coinInfo, unlockPath) => {
|
|
|
25
25
|
if (!output.address_n) {
|
|
26
26
|
throw constants_1.ERRORS.TypedError('Runtime', 'deriveOutputScript: Neither address or address_n is set');
|
|
27
27
|
}
|
|
28
|
-
const node = await derivePubKeyHash(output.address_n,
|
|
28
|
+
const node = await derivePubKeyHash(getHDNode, output.address_n, coinInfo, unlockPath);
|
|
29
29
|
const payment = { hash: node.identifier, network: coinInfo.network };
|
|
30
30
|
if (output.script_type === 'PAYTOADDRESS') {
|
|
31
31
|
return utxo_lib_1.payments.p2pkh(payment).output;
|
|
@@ -105,7 +105,7 @@ const verifyTicketTx = async (getHDNode, inputs, outputs, serializedTx, coinInfo
|
|
|
105
105
|
if (!output.address_n) {
|
|
106
106
|
throw constants_1.ERRORS.TypedError('Runtime', `verifyTicketTx: Output 1 should have address_n.`);
|
|
107
107
|
}
|
|
108
|
-
const node = await derivePubKeyHash(output.address_n,
|
|
108
|
+
const node = await derivePubKeyHash(getHDNode, output.address_n, coinInfo);
|
|
109
109
|
scriptA = utxo_lib_1.payments.sstxcommitment({
|
|
110
110
|
hash: node.identifier,
|
|
111
111
|
amount: output.amount.toString(),
|
|
@@ -8,6 +8,16 @@ const coinInfo_1 = require("../data/coinInfo");
|
|
|
8
8
|
const BitcoinFees_1 = require("./bitcoin/BitcoinFees");
|
|
9
9
|
const MiscFees_1 = require("./common/MiscFees");
|
|
10
10
|
const EthereumFees_1 = require("./ethereum/EthereumFees");
|
|
11
|
+
const getFees = (coinInfo) => {
|
|
12
|
+
switch (coinInfo.type) {
|
|
13
|
+
case 'bitcoin':
|
|
14
|
+
return new BitcoinFees_1.BitcoinFeeLevels(coinInfo);
|
|
15
|
+
case 'ethereum':
|
|
16
|
+
return new EthereumFees_1.EthereumFeeLevels(coinInfo);
|
|
17
|
+
default:
|
|
18
|
+
return new MiscFees_1.MiscFeeLevels(coinInfo);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
11
21
|
class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
|
|
12
22
|
init() {
|
|
13
23
|
this.useDevice = false;
|
|
@@ -56,21 +66,11 @@ class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
|
|
|
56
66
|
dustLimit: coinInfo.type === 'bitcoin' ? coinInfo.dustLimit : undefined,
|
|
57
67
|
levels: [],
|
|
58
68
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
case 'bitcoin':
|
|
62
|
-
return new BitcoinFees_1.BitcoinFeeLevels(coinInfo);
|
|
63
|
-
case 'ethereum':
|
|
64
|
-
return new EthereumFees_1.EthereumFeeLevels(coinInfo);
|
|
65
|
-
default:
|
|
66
|
-
return new MiscFees_1.MiscFeeLevels(coinInfo);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
if (request && request.feeLevels) {
|
|
70
|
-
const fees = getFees();
|
|
69
|
+
if (request?.feeLevels) {
|
|
70
|
+
const fees = getFees(coinInfo);
|
|
71
71
|
if (request.feeLevels === 'smart') {
|
|
72
72
|
const backend = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage, identity);
|
|
73
|
-
await fees.load(backend);
|
|
73
|
+
await fees.load(backend, request);
|
|
74
74
|
}
|
|
75
75
|
feeInfo.levels = fees.levels;
|
|
76
76
|
}
|
|
@@ -143,7 +143,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
async _sign_tx() {
|
|
146
|
-
const typedCall = this.device.getCommands()
|
|
146
|
+
const { typedCall } = this.device.getCommands();
|
|
147
147
|
const hasAuxiliaryData = !!this.params.auxiliaryData;
|
|
148
148
|
const signTxInitMessage = {
|
|
149
149
|
signing_mode: this.params.signingMode,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
import { Blockchain } from '../../backend/BlockchainLink';
|
|
3
3
|
import { PROTO } from '../../constants';
|
|
4
|
-
import { DeviceCommands } from '../../device/DeviceCommands';
|
|
4
|
+
import type { DeviceCommands } from '../../device/DeviceCommands';
|
|
5
5
|
import type { CoinInfo, DiscoveryAccount, DiscoveryAccountType } from '../../types';
|
|
6
6
|
import type { GetAccountInfo } from '../../types/api/getAccountInfo';
|
|
7
7
|
type DiscoveryType = {
|
|
8
8
|
type: DiscoveryAccountType;
|
|
9
9
|
getPath: (index: number) => number[];
|
|
10
10
|
};
|
|
11
|
+
type GetDescriptor = (path: number[]) => ReturnType<ReturnType<typeof DeviceCommands>['getAccountDescriptor']>;
|
|
11
12
|
type DiscoveryOptions = {
|
|
12
13
|
blockchain: Blockchain;
|
|
13
|
-
|
|
14
|
+
getDescriptor: GetDescriptor;
|
|
14
15
|
limit?: number;
|
|
15
|
-
derivationType?: PROTO.CardanoDerivationType;
|
|
16
16
|
};
|
|
17
17
|
export declare class Discovery extends EventEmitter {
|
|
18
18
|
types: DiscoveryType[];
|
|
@@ -20,7 +20,7 @@ export declare class Discovery extends EventEmitter {
|
|
|
20
20
|
accounts: DiscoveryAccount[];
|
|
21
21
|
coinInfo: CoinInfo;
|
|
22
22
|
blockchain: Blockchain;
|
|
23
|
-
|
|
23
|
+
getDescriptor: GetDescriptor;
|
|
24
24
|
index: number;
|
|
25
25
|
interrupted: boolean;
|
|
26
26
|
completed: boolean;
|
|
@@ -12,7 +12,7 @@ class Discovery extends events_1.default {
|
|
|
12
12
|
accounts;
|
|
13
13
|
coinInfo;
|
|
14
14
|
blockchain;
|
|
15
|
-
|
|
15
|
+
getDescriptor;
|
|
16
16
|
index;
|
|
17
17
|
interrupted;
|
|
18
18
|
completed;
|
|
@@ -25,9 +25,8 @@ class Discovery extends events_1.default {
|
|
|
25
25
|
this.interrupted = false;
|
|
26
26
|
this.completed = false;
|
|
27
27
|
this.blockchain = options.blockchain;
|
|
28
|
-
this.commands = options.commands;
|
|
29
28
|
this.coinInfo = options.blockchain.coinInfo;
|
|
30
|
-
this.
|
|
29
|
+
this.getDescriptor = options.getDescriptor;
|
|
31
30
|
const { coinInfo } = this;
|
|
32
31
|
if (coinInfo.type === 'bitcoin') {
|
|
33
32
|
const getDescriptor = (purpose, index) => (0, accountUtils_1.getAccountAddressN)(coinInfo, index, { purpose });
|
|
@@ -69,7 +68,7 @@ class Discovery extends events_1.default {
|
|
|
69
68
|
const label = `Account #${this.index + 1}`;
|
|
70
69
|
const overTheLimit = this.index >= limit;
|
|
71
70
|
const path = accountType.getPath(this.index);
|
|
72
|
-
const descriptor = await this.
|
|
71
|
+
const descriptor = await this.getDescriptor(path);
|
|
73
72
|
if (!descriptor) {
|
|
74
73
|
throw constants_1.ERRORS.TypedError('Runtime', 'Discovery: descriptor not found');
|
|
75
74
|
}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import { Blockchain } from '../../backend/BlockchainLink';
|
|
2
2
|
import type { CoinInfo, FeeLevel } from '../../types';
|
|
3
3
|
export type Blocks = Array<string | undefined>;
|
|
4
|
-
export declare const findBlocksForFee: (feePerUnit: string, blocks: Blocks) => number;
|
|
5
4
|
export declare class MiscFeeLevels {
|
|
6
5
|
coinInfo: CoinInfo;
|
|
7
6
|
levels: FeeLevel[];
|
|
8
7
|
longTermFeeRate?: string;
|
|
9
8
|
blocks: Blocks;
|
|
10
9
|
constructor(coinInfo: CoinInfo);
|
|
11
|
-
load(blockchain: Blockchain): Promise<{
|
|
10
|
+
load(blockchain: Blockchain, request: Parameters<typeof blockchain.estimateFee>[0]): Promise<{
|
|
11
|
+
feePerTx?: string | undefined;
|
|
12
|
+
feeLimit?: string | undefined;
|
|
13
|
+
baseFeePerGas?: string | undefined;
|
|
12
14
|
maxFeePerGas?: string | undefined;
|
|
13
15
|
maxPriorityFeePerGas?: string | undefined;
|
|
14
16
|
maxWaitTimeEstimate?: number | undefined;
|
|
15
|
-
minWaitTimeEstimate?: number | undefined;
|
|
16
|
-
feeLimit?: string | undefined;
|
|
17
|
-
feePerTx?: string | undefined;
|
|
18
|
-
baseFeePerGas?: string | undefined;
|
|
19
|
-
effectiveGasPrice?: string | undefined;
|
|
20
17
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
21
|
-
feePerUnit: string;
|
|
22
18
|
blocks: number;
|
|
19
|
+
feePerUnit: string;
|
|
23
20
|
}[]>;
|
|
24
|
-
updateCustomFee(feePerUnit: string): void;
|
|
25
21
|
}
|
|
26
22
|
//# sourceMappingURL=MiscFees.d.ts.map
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MiscFeeLevels =
|
|
3
|
+
exports.MiscFeeLevels = void 0;
|
|
4
4
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
|
-
const findBlocksForFee = (feePerUnit, blocks) => {
|
|
6
|
-
const bn = new bigNumber_1.BigNumber(feePerUnit);
|
|
7
|
-
const lower = blocks.find(b => typeof b === 'string' && bn.gte(b));
|
|
8
|
-
if (!lower)
|
|
9
|
-
return -1;
|
|
10
|
-
return blocks.indexOf(lower);
|
|
11
|
-
};
|
|
12
|
-
exports.findBlocksForFee = findBlocksForFee;
|
|
13
5
|
class MiscFeeLevels {
|
|
14
6
|
coinInfo;
|
|
15
7
|
levels;
|
|
@@ -19,28 +11,21 @@ class MiscFeeLevels {
|
|
|
19
11
|
this.coinInfo = coinInfo;
|
|
20
12
|
this.levels = coinInfo.defaultFees;
|
|
21
13
|
}
|
|
22
|
-
async load(blockchain) {
|
|
14
|
+
async load(blockchain, request) {
|
|
23
15
|
try {
|
|
24
|
-
const [response] = await blockchain.estimateFee(
|
|
16
|
+
const [response] = await blockchain.estimateFee(request);
|
|
17
|
+
const fee = new bigNumber_1.BigNumber(response.feePerUnit).toNumber();
|
|
18
|
+
const feePerUnit = Math.min(this.coinInfo.maxFee, Math.max(this.coinInfo.minFee, fee)).toString();
|
|
25
19
|
this.levels[0] = {
|
|
26
20
|
...this.levels[0],
|
|
27
21
|
...response,
|
|
28
|
-
feePerUnit
|
|
22
|
+
feePerUnit,
|
|
29
23
|
};
|
|
30
24
|
}
|
|
31
25
|
catch {
|
|
32
26
|
}
|
|
33
27
|
return this.levels;
|
|
34
28
|
}
|
|
35
|
-
updateCustomFee(feePerUnit) {
|
|
36
|
-
this.levels = this.levels.filter(l => l.label !== 'custom');
|
|
37
|
-
const blocks = (0, exports.findBlocksForFee)(feePerUnit, this.blocks);
|
|
38
|
-
this.levels.push({
|
|
39
|
-
label: 'custom',
|
|
40
|
-
feePerUnit,
|
|
41
|
-
blocks,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
29
|
}
|
|
45
30
|
exports.MiscFeeLevels = MiscFeeLevels;
|
|
46
31
|
//# sourceMappingURL=MiscFees.js.map
|
|
@@ -151,7 +151,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
151
151
|
const discovery = this.discovery ||
|
|
152
152
|
new Discovery_1.Discovery({
|
|
153
153
|
blockchain,
|
|
154
|
-
|
|
154
|
+
getDescriptor: path => this.device.getCommands().getAccountDescriptor(this.params.coinInfo, path),
|
|
155
155
|
});
|
|
156
156
|
this.discovery = discovery;
|
|
157
157
|
discovery.on('progress', accounts => {
|
|
@@ -247,15 +247,16 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
247
247
|
const signTxMethod = !this.device.unavailableCapabilities.replaceTransaction
|
|
248
248
|
? bitcoin_1.signTx
|
|
249
249
|
: bitcoin_1.signTxLegacy;
|
|
250
|
+
const cmd = this.device.getCommands();
|
|
250
251
|
const response = await signTxMethod({
|
|
251
|
-
typedCall:
|
|
252
|
+
typedCall: cmd.typedCall,
|
|
252
253
|
inputs,
|
|
253
254
|
outputs,
|
|
254
255
|
refTxs,
|
|
255
256
|
options,
|
|
256
257
|
coinInfo,
|
|
257
258
|
});
|
|
258
|
-
await (0, bitcoin_1.verifyTx)(
|
|
259
|
+
await (0, bitcoin_1.verifyTx)(cmd.getHDNode, inputs, outputs, response.serializedTx, coinInfo);
|
|
259
260
|
if (this.params.push) {
|
|
260
261
|
const blockchain = await this.getBlockchain();
|
|
261
262
|
const txid = await blockchain.pushTransaction(response.serializedTx);
|
|
@@ -29,7 +29,7 @@ class EosSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
29
29
|
return 'Sign EOS transaction';
|
|
30
30
|
}
|
|
31
31
|
async run() {
|
|
32
|
-
const response = await helper.signTx(this.device.getCommands().typedCall
|
|
32
|
+
const response = await helper.signTx(this.device.getCommands().typedCall, this.params.path, this.params.chain_id, this.params.header, this.params.ack, this.params.chunkify);
|
|
33
33
|
return {
|
|
34
34
|
signature: response.signature,
|
|
35
35
|
};
|
|
@@ -105,15 +105,15 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
105
105
|
permission: string;
|
|
106
106
|
} | undefined;
|
|
107
107
|
link_auth?: {
|
|
108
|
+
code: string;
|
|
108
109
|
type: string;
|
|
109
110
|
account: string;
|
|
110
|
-
code: string;
|
|
111
111
|
requirement: string;
|
|
112
112
|
} | undefined;
|
|
113
113
|
unlink_auth?: {
|
|
114
|
+
code: string;
|
|
114
115
|
type: string;
|
|
115
116
|
account: string;
|
|
116
|
-
code: string;
|
|
117
117
|
} | undefined;
|
|
118
118
|
new_account?: {
|
|
119
119
|
name: string;
|
|
@@ -6,19 +6,16 @@ export declare class EthereumFeeLevels extends MiscFeeLevels {
|
|
|
6
6
|
levels: FeeLevel[];
|
|
7
7
|
blocks: Blocks;
|
|
8
8
|
constructor(coinInfo: EthereumNetworkInfo);
|
|
9
|
-
load(blockchain: Blockchain): Promise<{
|
|
9
|
+
load(blockchain: Blockchain, request: Parameters<typeof blockchain.estimateFee>[0]): Promise<{
|
|
10
|
+
feePerTx?: string | undefined;
|
|
11
|
+
feeLimit?: string | undefined;
|
|
12
|
+
baseFeePerGas?: string | undefined;
|
|
10
13
|
maxFeePerGas?: string | undefined;
|
|
11
14
|
maxPriorityFeePerGas?: string | undefined;
|
|
12
15
|
maxWaitTimeEstimate?: number | undefined;
|
|
13
|
-
minWaitTimeEstimate?: number | undefined;
|
|
14
|
-
feeLimit?: string | undefined;
|
|
15
|
-
feePerTx?: string | undefined;
|
|
16
|
-
baseFeePerGas?: string | undefined;
|
|
17
|
-
effectiveGasPrice?: string | undefined;
|
|
18
16
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
19
|
-
feePerUnit: string;
|
|
20
17
|
blocks: number;
|
|
18
|
+
feePerUnit: string;
|
|
21
19
|
}[]>;
|
|
22
|
-
updateEthereumCustomFee(feePerUnit: string, effectiveGasPrice?: string, maxPriorityFeePerGas?: string): void;
|
|
23
20
|
}
|
|
24
21
|
//# sourceMappingURL=EthereumFees.d.ts.map
|
|
@@ -12,60 +12,46 @@ class EthereumFeeLevels extends MiscFees_1.MiscFeeLevels {
|
|
|
12
12
|
this.coinInfo = coinInfo;
|
|
13
13
|
this.levels = coinInfo.defaultFees;
|
|
14
14
|
}
|
|
15
|
-
async load(blockchain) {
|
|
15
|
+
async load(blockchain, request) {
|
|
16
16
|
try {
|
|
17
|
-
const [response] = await blockchain.estimateFee(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const eip1559Levels = eip1559ResponseLevelKeys.map(levelKey => {
|
|
17
|
+
const [response] = await blockchain.estimateFee(request);
|
|
18
|
+
const { eip1559 } = response;
|
|
19
|
+
const maxFeeInWei = new bigNumber_1.BigNumber(this.coinInfo.maxFee).multipliedBy('1e+9').toNumber();
|
|
20
|
+
const minFeeInWei = new bigNumber_1.BigNumber(this.coinInfo.minFee).multipliedBy('1e+9').toNumber();
|
|
21
|
+
const feeInWei = new bigNumber_1.BigNumber(response.feePerUnit).toNumber();
|
|
22
|
+
const feePerUnit = Math.min(maxFeeInWei, Math.max(minFeeInWei, feeInWei)).toString();
|
|
23
|
+
if (eip1559?.baseFeePerGas) {
|
|
24
|
+
const levels = ['low', 'medium', 'high'].map(levelKey => {
|
|
26
25
|
const level = eip1559[levelKey];
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const label = levelKey === 'medium' ? 'normal' : levelKey;
|
|
27
|
+
if (!level?.maxFeePerGas || !level?.maxPriorityFeePerGas) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
31
30
|
return {
|
|
32
31
|
label,
|
|
33
|
-
|
|
34
|
-
effectiveGasPrice: calculatedMaxFeePerGas,
|
|
35
|
-
maxPriorityFeePerGas: level?.maxPriorityFeePerGas || '0',
|
|
36
|
-
baseFeePerGas: eip1559.baseFeePerGas,
|
|
37
|
-
minWaitTimeEstimate: level?.minWaitTimeEstimate
|
|
38
|
-
? level.minWaitTimeEstimate / 1000
|
|
39
|
-
: undefined,
|
|
40
|
-
maxWaitTimeEstimate: level?.maxWaitTimeEstimate
|
|
41
|
-
? level.maxWaitTimeEstimate / 1000
|
|
42
|
-
: undefined,
|
|
43
|
-
feePerUnit: '0',
|
|
32
|
+
feePerUnit,
|
|
44
33
|
feeLimit: response.feeLimit,
|
|
45
34
|
blocks: -1,
|
|
35
|
+
baseFeePerGas: eip1559.baseFeePerGas,
|
|
36
|
+
maxFeePerGas: level?.maxFeePerGas,
|
|
37
|
+
maxPriorityFeePerGas: level?.maxPriorityFeePerGas,
|
|
38
|
+
maxWaitTimeEstimate: level?.maxWaitTimeEstimate,
|
|
46
39
|
};
|
|
47
40
|
});
|
|
48
|
-
this.levels =
|
|
41
|
+
this.levels = levels.filter(level => level);
|
|
49
42
|
}
|
|
50
43
|
else {
|
|
51
|
-
|
|
44
|
+
this.levels[0] = {
|
|
45
|
+
...this.levels[0],
|
|
46
|
+
...response,
|
|
47
|
+
feePerUnit,
|
|
48
|
+
};
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
catch {
|
|
55
52
|
}
|
|
56
53
|
return this.levels;
|
|
57
54
|
}
|
|
58
|
-
updateEthereumCustomFee(feePerUnit, effectiveGasPrice, maxPriorityFeePerGas) {
|
|
59
|
-
this.levels = this.levels.filter(l => l.label !== 'custom');
|
|
60
|
-
const blocks = (0, MiscFees_1.findBlocksForFee)(feePerUnit, this.blocks);
|
|
61
|
-
this.levels.push({
|
|
62
|
-
label: 'custom',
|
|
63
|
-
feePerUnit,
|
|
64
|
-
blocks,
|
|
65
|
-
maxPriorityFeePerGas,
|
|
66
|
-
effectiveGasPrice,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
55
|
}
|
|
70
56
|
exports.EthereumFeeLevels = EthereumFeeLevels;
|
|
71
57
|
//# sourceMappingURL=EthereumFees.js.map
|
|
@@ -21,11 +21,7 @@ export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddre
|
|
|
21
21
|
view: "export-address";
|
|
22
22
|
label: string;
|
|
23
23
|
};
|
|
24
|
-
_call
|
|
25
|
-
path: number[];
|
|
26
|
-
serializedPath: string;
|
|
27
|
-
address: string;
|
|
28
|
-
}>;
|
|
24
|
+
private _call;
|
|
29
25
|
run(): Promise<import("../../../types").Address | import("../../../types").Address[]>;
|
|
30
26
|
}
|
|
31
27
|
export {};
|
|
@@ -85,14 +85,13 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
85
85
|
label: this.info,
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
_call(
|
|
89
|
-
const
|
|
90
|
-
return
|
|
91
|
-
address_n,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
88
|
+
async _call(params) {
|
|
89
|
+
const response = await this.device.getCommands().ethereumGetAddress(params);
|
|
90
|
+
return {
|
|
91
|
+
path: params.address_n,
|
|
92
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(params.address_n),
|
|
93
|
+
address: response.address,
|
|
94
|
+
};
|
|
96
95
|
}
|
|
97
96
|
async run() {
|
|
98
97
|
const responses = [];
|
|
@@ -12,29 +12,33 @@ export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPub
|
|
|
12
12
|
view: "export-xpub";
|
|
13
13
|
label: string;
|
|
14
14
|
};
|
|
15
|
-
run(): Promise<{
|
|
16
|
-
xpubSegwit?: string | undefined;
|
|
17
|
-
descriptorChecksum?: string | undefined;
|
|
15
|
+
run(): Promise<({
|
|
18
16
|
path: number[];
|
|
19
17
|
publicKey: string;
|
|
20
18
|
serializedPath: string;
|
|
19
|
+
} & {
|
|
20
|
+
descriptor?: string | undefined;
|
|
21
|
+
xpubSegwit?: string | undefined;
|
|
22
|
+
descriptorChecksum?: string | undefined;
|
|
21
23
|
depth: number;
|
|
22
24
|
fingerprint: number;
|
|
23
25
|
chainCode: string;
|
|
24
26
|
childNum: number;
|
|
25
27
|
xpub: string;
|
|
26
|
-
} | {
|
|
27
|
-
xpubSegwit?: string | undefined;
|
|
28
|
-
descriptorChecksum?: string | undefined;
|
|
28
|
+
}) | ({
|
|
29
29
|
path: number[];
|
|
30
30
|
publicKey: string;
|
|
31
31
|
serializedPath: string;
|
|
32
|
+
} & {
|
|
33
|
+
descriptor?: string | undefined;
|
|
34
|
+
xpubSegwit?: string | undefined;
|
|
35
|
+
descriptorChecksum?: string | undefined;
|
|
32
36
|
depth: number;
|
|
33
37
|
fingerprint: number;
|
|
34
38
|
chainCode: string;
|
|
35
39
|
childNum: number;
|
|
36
40
|
xpub: string;
|
|
37
|
-
}[]>;
|
|
41
|
+
})[]>;
|
|
38
42
|
}
|
|
39
43
|
export {};
|
|
40
44
|
//# sourceMappingURL=ethereumGetPublicKey.d.ts.map
|
|
@@ -50,11 +50,18 @@ class EthereumGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
50
50
|
const responses = [];
|
|
51
51
|
const cmd = this.device.getCommands();
|
|
52
52
|
for (let i = 0; i < this.params.length; i++) {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const { address_n, show_display } = this.params[i];
|
|
54
|
+
const publicKey = await cmd.ethereumGetPublicKey({ address_n, show_display });
|
|
55
|
+
const response = {
|
|
56
|
+
path: address_n,
|
|
57
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(address_n),
|
|
58
|
+
childNum: publicKey.node.child_num,
|
|
59
|
+
xpub: publicKey.xpub,
|
|
60
|
+
chainCode: publicKey.node.chain_code,
|
|
61
|
+
publicKey: publicKey.node.public_key,
|
|
62
|
+
fingerprint: publicKey.node.fingerprint,
|
|
63
|
+
depth: publicKey.node.depth,
|
|
64
|
+
};
|
|
58
65
|
responses.push(response);
|
|
59
66
|
if (this.hasBundle) {
|
|
60
67
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.BUNDLE_PROGRESS, {
|
|
@@ -63,8 +63,8 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
63
63
|
const { type, tx, definitions, chunkify } = this.params;
|
|
64
64
|
const isLegacy = type === 'legacy';
|
|
65
65
|
const signature = isLegacy
|
|
66
|
-
? await helper.ethereumSignTx(this.device.getCommands().typedCall
|
|
67
|
-
: await helper.ethereumSignTxEIP1559(this.device.getCommands().typedCall
|
|
66
|
+
? await helper.ethereumSignTx(this.device.getCommands().typedCall, this.params.path, tx.to, tx.value, tx.gasLimit, tx.gasPrice, tx.nonce, tx.chainId, chunkify, tx.data, tx.txType, definitions)
|
|
67
|
+
: await helper.ethereumSignTxEIP1559(this.device.getCommands().typedCall, this.params.path, tx.to, tx.value, tx.gasLimit, tx.maxFeePerGas, tx.maxPriorityFeePerGas, tx.nonce, tx.chainId, chunkify, tx.data, tx.accessList, definitions);
|
|
68
68
|
const serializedTx = helper.serializeEthereumTx(tx, signature, isLegacy);
|
|
69
69
|
return { ...signature, serializedTx };
|
|
70
70
|
}
|