@trezor/connect 9.5.0 → 9.5.1-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 +20 -8
- package/README.md +1 -1
- package/lib/api/bitcoin/BitcoinFees.d.ts +25 -0
- package/lib/api/bitcoin/{Fees.js → BitcoinFees.js} +8 -29
- package/lib/api/bitcoin/TransactionComposer.d.ts +2 -2
- package/lib/api/bitcoin/TransactionComposer.js +5 -5
- package/lib/api/bitcoin/index.d.ts +1 -1
- package/lib/api/bitcoin/index.js +1 -1
- package/lib/api/blockchainEstimateFee.js +15 -4
- package/lib/api/{bitcoin/Fees.d.ts → common/MiscFees.d.ts} +10 -11
- package/lib/api/common/MiscFees.js +46 -0
- package/lib/api/common/paramsValidator.js +1 -1
- package/lib/api/ethereum/EthereumFees.d.ts +24 -0
- package/lib/api/ethereum/EthereumFees.js +71 -0
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +6 -0
- package/lib/api/ethereum/ethereumDefinitions.js +1 -3
- package/lib/api/getCoinInfo.d.ts +18 -0
- package/lib/api/solana/api/solanaComposeTransaction.d.ts +1 -2
- package/lib/api/solana/api/solanaComposeTransaction.js +2 -5
- package/lib/api/unlockPath.d.ts +1 -1
- package/lib/backend/Blockchain.d.ts +1 -0
- package/lib/core/AbstractMethod.js +1 -1
- package/lib/data/coinInfo.d.ts +66 -0
- package/lib/data/connectSettings.js +3 -0
- package/lib/data/defaultFeeLevels.js +1 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +3 -5
- package/lib/device/Device.js +25 -20
- package/lib/device/DeviceList.d.ts +6 -13
- package/lib/device/DeviceList.js +44 -174
- package/lib/device/TransportList.d.ts +9 -0
- package/lib/device/TransportList.js +50 -0
- package/lib/device/TransportManager.d.ts +34 -0
- package/lib/device/TransportManager.js +149 -0
- package/lib/device/checkFirmwareRevision.js +9 -5
- package/lib/types/api/solana/index.d.ts +1 -2
- package/lib/types/api/solana/index.js +1 -2
- package/lib/types/coinInfo.d.ts +36 -0
- package/lib/types/device.d.ts +6 -0
- package/lib/types/fees.d.ts +13 -0
- package/lib/types/fees.js +13 -1
- package/lib/types/settings.d.ts +3 -1
- package/lib/types/utils.d.ts +0 -1
- package/lib/types/utils.js +0 -3
- package/lib/utils/assets-browser.d.ts +4 -0
- package/lib/utils/assets-browser.js +11 -2
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
| Package | Stable | Canary |
|
|
2
2
|
| :------------------------------: | :----: | :----------: |
|
|
3
|
-
| npm @trezor/connect | 9.5.0 |
|
|
4
|
-
| npm @trezor/connect-web | 9.5.0 |
|
|
5
|
-
| npm @trezor/connect-webextension | 9.5.0 |
|
|
3
|
+
| npm @trezor/connect | 9.5.0 | 9.5.1-beta.1 |
|
|
4
|
+
| npm @trezor/connect-web | 9.5.0 | 9.5.1-beta.1 |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.5.0 | 9.5.1-beta.1 |
|
|
6
6
|
| npm @trezor/connect-mobile | - | 0.0.1-beta.1 |
|
|
7
7
|
|
|
8
|
-
| Deployment | Stable |
|
|
9
|
-
| :----------------: | :----: |
|
|
10
|
-
| connect.trezor.io/ | 9.5.0 |
|
|
11
|
-
|
|
12
|
-
| connect.trezor.io/ | 9.4.7 | 9.5.0-beta.1 |
|
|
8
|
+
| Deployment | Stable | Canary |
|
|
9
|
+
| :----------------: | :----: | :----------: |
|
|
10
|
+
| connect.trezor.io/ | 9.5.0 | 9.5.1-beta.1 |
|
|
13
11
|
|
|
14
12
|
Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to access the latest stable version of Connect Explorer.
|
|
15
13
|
|
|
14
|
+
# 9.5.1-beta.1
|
|
15
|
+
|
|
16
|
+
## Feature
|
|
17
|
+
|
|
18
|
+
- added backends so that each EVM has 4 endpoints (f5c057c)
|
|
19
|
+
- logic for rent fee calculation (2650f6b)
|
|
20
|
+
|
|
21
|
+
## Fixes
|
|
22
|
+
|
|
23
|
+
- solana creating account parameter in e2e (356edd4)
|
|
24
|
+
- reacquire when cancel timeouts (141a29c)
|
|
25
|
+
- don't cancel preventively on T1 in certain cases (bf6d9ff)
|
|
26
|
+
- FW revision check for unknown models (522880d)
|
|
27
|
+
|
|
16
28
|
# 9.5.0
|
|
17
29
|
|
|
18
30
|
Starting with this release we changed de target in all `@trezor` packages to ES2022. It might be problematic in some very old environment or if you use Typescript with lower than ES2022 you might have to add ES2022 lib to your tsconfig. We are also include esm builds in our npm packages. For now only in `@trezor/connect-plugin-stellar` and `@trezor/connect-plugin-ethereum`.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.5.
|
|
3
|
+
API version 9.5.1-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)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Blockchain } from '../../backend/BlockchainLink';
|
|
2
|
+
import type { BitcoinNetworkInfo, FeeLevel } from '../../types';
|
|
3
|
+
import { Blocks } from '../common/MiscFees';
|
|
4
|
+
export declare class BitcoinFeeLevels {
|
|
5
|
+
coinInfo: BitcoinNetworkInfo;
|
|
6
|
+
levels: FeeLevel[];
|
|
7
|
+
longTermFeeRate?: string;
|
|
8
|
+
blocks: Blocks;
|
|
9
|
+
constructor(coinInfo: BitcoinNetworkInfo);
|
|
10
|
+
load(blockchain: Blockchain): Promise<{
|
|
11
|
+
maxFeePerGas?: string | undefined;
|
|
12
|
+
maxPriorityFeePerGas?: string | undefined;
|
|
13
|
+
maxWaitTimeEstimate?: number | undefined;
|
|
14
|
+
minWaitTimeEstimate?: number | undefined;
|
|
15
|
+
feeLimit?: string | undefined;
|
|
16
|
+
feePerTx?: string | undefined;
|
|
17
|
+
baseFeePerGas?: string | undefined;
|
|
18
|
+
effectiveGasPrice?: string | undefined;
|
|
19
|
+
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
20
|
+
feePerUnit: string;
|
|
21
|
+
blocks: number;
|
|
22
|
+
}[]>;
|
|
23
|
+
updateBitcoinCustomFee(feePerUnit: string): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=BitcoinFees.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BitcoinFeeLevels = void 0;
|
|
4
4
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
|
+
const MiscFees_1 = require("../common/MiscFees");
|
|
5
6
|
const convertFeeRate = (fee, minFee) => {
|
|
6
7
|
const feePerKB = new bigNumber_1.BigNumber(fee);
|
|
7
8
|
if (feePerKB.isNaN() || feePerKB.lte('0'))
|
|
@@ -39,14 +40,7 @@ const findLowest = (blocks) => blocks
|
|
|
39
40
|
.slice(0)
|
|
40
41
|
.reverse()
|
|
41
42
|
.find(item => typeof item === 'string');
|
|
42
|
-
|
|
43
|
-
const bn = new bigNumber_1.BigNumber(feePerUnit);
|
|
44
|
-
const lower = blocks.find(b => typeof b === 'string' && bn.gte(b));
|
|
45
|
-
if (!lower)
|
|
46
|
-
return -1;
|
|
47
|
-
return blocks.indexOf(lower);
|
|
48
|
-
};
|
|
49
|
-
class FeeLevels {
|
|
43
|
+
class BitcoinFeeLevels {
|
|
50
44
|
coinInfo;
|
|
51
45
|
levels;
|
|
52
46
|
longTermFeeRate;
|
|
@@ -55,22 +49,7 @@ class FeeLevels {
|
|
|
55
49
|
this.coinInfo = coinInfo;
|
|
56
50
|
this.levels = coinInfo.defaultFees;
|
|
57
51
|
}
|
|
58
|
-
async loadMisc(blockchain) {
|
|
59
|
-
try {
|
|
60
|
-
const [response] = await blockchain.estimateFee({ blocks: [1] });
|
|
61
|
-
this.levels[0] = {
|
|
62
|
-
...this.levels[0],
|
|
63
|
-
...response,
|
|
64
|
-
feePerUnit: Math.min(this.coinInfo.maxFee, Math.max(this.coinInfo.minFee, parseInt(response.feePerUnit, 10))).toString(),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
}
|
|
69
|
-
return this.levels;
|
|
70
|
-
}
|
|
71
52
|
async load(blockchain) {
|
|
72
|
-
if (this.coinInfo.type !== 'bitcoin')
|
|
73
|
-
return this.loadMisc(blockchain);
|
|
74
53
|
let blocks = fillGap(0, 1, 10);
|
|
75
54
|
if (this.levels.length > 1) {
|
|
76
55
|
blocks = this.levels
|
|
@@ -90,7 +69,7 @@ class FeeLevels {
|
|
|
90
69
|
try {
|
|
91
70
|
const response = await blockchain.estimateFee({ blocks });
|
|
92
71
|
response.forEach(({ feePerUnit }, index) => {
|
|
93
|
-
this.blocks[blocks[index]] = convertFeeRate(feePerUnit, this.coinInfo.minFee);
|
|
72
|
+
this.blocks[blocks[index]] = convertFeeRate(feePerUnit || '0', this.coinInfo.minFee);
|
|
94
73
|
});
|
|
95
74
|
this.levels.forEach(level => {
|
|
96
75
|
const updatedValue = findNearest(level.blocks, this.blocks);
|
|
@@ -105,9 +84,9 @@ class FeeLevels {
|
|
|
105
84
|
}
|
|
106
85
|
return this.levels;
|
|
107
86
|
}
|
|
108
|
-
|
|
87
|
+
updateBitcoinCustomFee(feePerUnit) {
|
|
109
88
|
this.levels = this.levels.filter(l => l.label !== 'custom');
|
|
110
|
-
const blocks = findBlocksForFee(feePerUnit, this.blocks);
|
|
89
|
+
const blocks = (0, MiscFees_1.findBlocksForFee)(feePerUnit, this.blocks);
|
|
111
90
|
this.levels.push({
|
|
112
91
|
label: 'custom',
|
|
113
92
|
feePerUnit,
|
|
@@ -115,5 +94,5 @@ class FeeLevels {
|
|
|
115
94
|
});
|
|
116
95
|
}
|
|
117
96
|
}
|
|
118
|
-
exports.
|
|
119
|
-
//# sourceMappingURL=
|
|
97
|
+
exports.BitcoinFeeLevels = BitcoinFeeLevels;
|
|
98
|
+
//# sourceMappingURL=BitcoinFees.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComposeOutput, TransactionInputOutputSortingStrategy } from '@trezor/utxo-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { BitcoinFeeLevels } from './BitcoinFees';
|
|
3
3
|
import { Blockchain } from '../../backend/BlockchainLink';
|
|
4
4
|
import type { BitcoinNetworkInfo, DiscoveryAccount } from '../../types';
|
|
5
5
|
import type { ComposeResult, ComposeUtxo, ComposedInputs } from '../../types/api/composeTransaction';
|
|
@@ -19,7 +19,7 @@ export declare class TransactionComposer {
|
|
|
19
19
|
blockHeight: number;
|
|
20
20
|
baseFee: number;
|
|
21
21
|
sortingStrategy: TransactionInputOutputSortingStrategy;
|
|
22
|
-
feeLevels:
|
|
22
|
+
feeLevels: BitcoinFeeLevels;
|
|
23
23
|
composed: {
|
|
24
24
|
[key: string]: ComposeResult;
|
|
25
25
|
};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TransactionComposer = void 0;
|
|
4
4
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
5
|
const utxo_lib_1 = require("@trezor/utxo-lib");
|
|
6
|
-
const
|
|
6
|
+
const BitcoinFees_1 = require("./BitcoinFees");
|
|
7
7
|
class TransactionComposer {
|
|
8
8
|
account;
|
|
9
9
|
utxos;
|
|
@@ -21,7 +21,7 @@ class TransactionComposer {
|
|
|
21
21
|
this.blockHeight = 0;
|
|
22
22
|
this.baseFee = options.baseFee || 0;
|
|
23
23
|
this.sortingStrategy = options.sortingStrategy;
|
|
24
|
-
this.feeLevels = new
|
|
24
|
+
this.feeLevels = new BitcoinFees_1.BitcoinFeeLevels(options.coinInfo);
|
|
25
25
|
const { addresses } = options.account;
|
|
26
26
|
const allAddresses = !addresses
|
|
27
27
|
? []
|
|
@@ -66,7 +66,7 @@ class TransactionComposer {
|
|
|
66
66
|
lastFee = lastFee.minus(1);
|
|
67
67
|
const tx = this.compose(lastFee.toString());
|
|
68
68
|
if (tx.type === 'final') {
|
|
69
|
-
this.feeLevels.
|
|
69
|
+
this.feeLevels.updateBitcoinCustomFee(lastFee.toString());
|
|
70
70
|
this.composed.custom = tx;
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
@@ -79,10 +79,10 @@ class TransactionComposer {
|
|
|
79
79
|
const tx = this.compose(fee);
|
|
80
80
|
this.composed.custom = tx;
|
|
81
81
|
if (tx.type === 'final') {
|
|
82
|
-
this.feeLevels.
|
|
82
|
+
this.feeLevels.updateBitcoinCustomFee(tx.feePerByte);
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
this.feeLevels.
|
|
85
|
+
this.feeLevels.updateBitcoinCustomFee(fee);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
getFeeLevelList() {
|
package/lib/api/bitcoin/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./createPendingTx"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./enhanceSignTx"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./
|
|
6
|
+
tslib_1.__exportStar(require("./BitcoinFees"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./inputs"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./outputs"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./refTx"), exports);
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const constants_1 = require("../constants");
|
|
4
4
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
5
|
-
const Fees_1 = require("./bitcoin/Fees");
|
|
6
5
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
7
6
|
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
8
7
|
const coinInfo_1 = require("../data/coinInfo");
|
|
8
|
+
const BitcoinFees_1 = require("./bitcoin/BitcoinFees");
|
|
9
|
+
const MiscFees_1 = require("./common/MiscFees");
|
|
10
|
+
const EthereumFees_1 = require("./ethereum/EthereumFees");
|
|
9
11
|
class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
|
|
10
12
|
init() {
|
|
11
13
|
this.useDevice = false;
|
|
@@ -30,8 +32,7 @@ class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
|
|
|
30
32
|
{ name: 'from', type: 'string' },
|
|
31
33
|
{ name: 'to', type: 'string' },
|
|
32
34
|
{ name: 'txsize', type: 'number' },
|
|
33
|
-
{ name: '
|
|
34
|
-
{ name: 'newTokenAccountProgramName', type: 'string' },
|
|
35
|
+
{ name: 'newAccountProgramName', type: 'string' },
|
|
35
36
|
]);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -55,8 +56,18 @@ class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
|
|
|
55
56
|
dustLimit: coinInfo.type === 'bitcoin' ? coinInfo.dustLimit : undefined,
|
|
56
57
|
levels: [],
|
|
57
58
|
};
|
|
59
|
+
const getFees = () => {
|
|
60
|
+
switch (coinInfo.type) {
|
|
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
|
+
};
|
|
58
69
|
if (request && request.feeLevels) {
|
|
59
|
-
const fees =
|
|
70
|
+
const fees = getFees();
|
|
60
71
|
if (request.feeLevels === 'smart') {
|
|
61
72
|
const backend = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage, identity);
|
|
62
73
|
await fees.load(backend);
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { Blockchain } from '../../backend/BlockchainLink';
|
|
2
2
|
import type { CoinInfo, FeeLevel } from '../../types';
|
|
3
|
-
type Blocks = Array<string | undefined>;
|
|
4
|
-
export declare
|
|
3
|
+
export type Blocks = Array<string | undefined>;
|
|
4
|
+
export declare const findBlocksForFee: (feePerUnit: string, blocks: Blocks) => number;
|
|
5
|
+
export declare class MiscFeeLevels {
|
|
5
6
|
coinInfo: CoinInfo;
|
|
6
7
|
levels: FeeLevel[];
|
|
7
8
|
longTermFeeRate?: string;
|
|
8
9
|
blocks: Blocks;
|
|
9
10
|
constructor(coinInfo: CoinInfo);
|
|
10
|
-
loadMisc(blockchain: Blockchain): Promise<{
|
|
11
|
-
feeLimit?: string | undefined;
|
|
12
|
-
feePerTx?: string | undefined;
|
|
13
|
-
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
14
|
-
feePerUnit: string;
|
|
15
|
-
blocks: number;
|
|
16
|
-
}[]>;
|
|
17
11
|
load(blockchain: Blockchain): Promise<{
|
|
12
|
+
maxFeePerGas?: string | undefined;
|
|
13
|
+
maxPriorityFeePerGas?: string | undefined;
|
|
14
|
+
maxWaitTimeEstimate?: number | undefined;
|
|
15
|
+
minWaitTimeEstimate?: number | undefined;
|
|
18
16
|
feeLimit?: string | undefined;
|
|
19
17
|
feePerTx?: string | undefined;
|
|
18
|
+
baseFeePerGas?: string | undefined;
|
|
19
|
+
effectiveGasPrice?: string | undefined;
|
|
20
20
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
21
21
|
feePerUnit: string;
|
|
22
22
|
blocks: number;
|
|
23
23
|
}[]>;
|
|
24
24
|
updateCustomFee(feePerUnit: string): void;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=Fees.d.ts.map
|
|
26
|
+
//# sourceMappingURL=MiscFees.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MiscFeeLevels = exports.findBlocksForFee = void 0;
|
|
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
|
+
class MiscFeeLevels {
|
|
14
|
+
coinInfo;
|
|
15
|
+
levels;
|
|
16
|
+
longTermFeeRate;
|
|
17
|
+
blocks = [];
|
|
18
|
+
constructor(coinInfo) {
|
|
19
|
+
this.coinInfo = coinInfo;
|
|
20
|
+
this.levels = coinInfo.defaultFees;
|
|
21
|
+
}
|
|
22
|
+
async load(blockchain) {
|
|
23
|
+
try {
|
|
24
|
+
const [response] = await blockchain.estimateFee({ blocks: [1] });
|
|
25
|
+
this.levels[0] = {
|
|
26
|
+
...this.levels[0],
|
|
27
|
+
...response,
|
|
28
|
+
feePerUnit: Math.min(this.coinInfo.maxFee, Math.max(this.coinInfo.minFee, parseInt(response.feePerUnit ?? '0', 10))).toString(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
}
|
|
33
|
+
return this.levels;
|
|
34
|
+
}
|
|
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
|
+
}
|
|
45
|
+
exports.MiscFeeLevels = MiscFeeLevels;
|
|
46
|
+
//# sourceMappingURL=MiscFees.js.map
|
|
@@ -69,7 +69,7 @@ const validateCoinPath = (path, coinInfo) => {
|
|
|
69
69
|
exports.validateCoinPath = validateCoinPath;
|
|
70
70
|
const getFirmwareRange = (method, coinInfo, currentRange) => {
|
|
71
71
|
const range = JSON.parse(JSON.stringify(currentRange));
|
|
72
|
-
const models =
|
|
72
|
+
const models = (0, utils_1.typedObjectKeys)(range);
|
|
73
73
|
if (coinInfo) {
|
|
74
74
|
models.forEach(model => {
|
|
75
75
|
const supportVersion = coinInfo.support ? coinInfo.support[model] : false;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Blockchain } from '../../backend/BlockchainLink';
|
|
2
|
+
import type { EthereumNetworkInfo, FeeLevel } from '../../types';
|
|
3
|
+
import { Blocks, MiscFeeLevels } from '../common/MiscFees';
|
|
4
|
+
export declare class EthereumFeeLevels extends MiscFeeLevels {
|
|
5
|
+
coinInfo: EthereumNetworkInfo;
|
|
6
|
+
levels: FeeLevel[];
|
|
7
|
+
blocks: Blocks;
|
|
8
|
+
constructor(coinInfo: EthereumNetworkInfo);
|
|
9
|
+
load(blockchain: Blockchain): Promise<{
|
|
10
|
+
maxFeePerGas?: string | undefined;
|
|
11
|
+
maxPriorityFeePerGas?: string | undefined;
|
|
12
|
+
maxWaitTimeEstimate?: number | undefined;
|
|
13
|
+
minWaitTimeEstimate?: number | undefined;
|
|
14
|
+
feeLimit?: string | undefined;
|
|
15
|
+
feePerTx?: string | undefined;
|
|
16
|
+
baseFeePerGas?: string | undefined;
|
|
17
|
+
effectiveGasPrice?: string | undefined;
|
|
18
|
+
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
19
|
+
feePerUnit: string;
|
|
20
|
+
blocks: number;
|
|
21
|
+
}[]>;
|
|
22
|
+
updateEthereumCustomFee(feePerUnit: string, effectiveGasPrice?: string, maxPriorityFeePerGas?: string): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=EthereumFees.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EthereumFeeLevels = void 0;
|
|
4
|
+
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
|
+
const MiscFees_1 = require("../common/MiscFees");
|
|
6
|
+
class EthereumFeeLevels extends MiscFees_1.MiscFeeLevels {
|
|
7
|
+
coinInfo;
|
|
8
|
+
levels;
|
|
9
|
+
blocks = [];
|
|
10
|
+
constructor(coinInfo) {
|
|
11
|
+
super(coinInfo);
|
|
12
|
+
this.coinInfo = coinInfo;
|
|
13
|
+
this.levels = coinInfo.defaultFees;
|
|
14
|
+
}
|
|
15
|
+
async load(blockchain) {
|
|
16
|
+
try {
|
|
17
|
+
const [response] = await blockchain.estimateFee({ blocks: [1] });
|
|
18
|
+
if (response.eip1559) {
|
|
19
|
+
const eip1559ResponseLevelKeys = [
|
|
20
|
+
'low',
|
|
21
|
+
'medium',
|
|
22
|
+
'high',
|
|
23
|
+
];
|
|
24
|
+
const { eip1559 } = response;
|
|
25
|
+
const eip1559Levels = eip1559ResponseLevelKeys.map(levelKey => {
|
|
26
|
+
const level = eip1559[levelKey];
|
|
27
|
+
const calculatedMaxFeePerGas = bigNumber_1.BigNumber.minimum(new bigNumber_1.BigNumber(level?.maxFeePerGas || '0'), new bigNumber_1.BigNumber(eip1559.baseFeePerGas || '0').plus(level?.maxPriorityFeePerGas || '0')).toFixed();
|
|
28
|
+
const label = levelKey === 'medium'
|
|
29
|
+
? 'normal'
|
|
30
|
+
: levelKey;
|
|
31
|
+
return {
|
|
32
|
+
label,
|
|
33
|
+
maxFeePerGas: level?.maxFeePerGas || '0',
|
|
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',
|
|
44
|
+
feeLimit: response.feeLimit,
|
|
45
|
+
blocks: -1,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
this.levels = [...eip1559Levels];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
super.load(blockchain);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
}
|
|
56
|
+
return this.levels;
|
|
57
|
+
}
|
|
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
|
+
}
|
|
70
|
+
exports.EthereumFeeLevels = EthereumFeeLevels;
|
|
71
|
+
//# sourceMappingURL=EthereumFees.js.map
|
|
@@ -80,6 +80,12 @@ declare const Params: import("@trezor/schema-utils").TIntersect<[import("@trezor
|
|
|
80
80
|
blocks: import("@trezor/schema-utils").TNumber;
|
|
81
81
|
feeLimit: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
82
82
|
feePerTx: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
83
|
+
baseFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
84
|
+
maxFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
85
|
+
effectiveGasPrice: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
86
|
+
maxPriorityFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
87
|
+
maxWaitTimeEstimate: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
88
|
+
minWaitTimeEstimate: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
83
89
|
}>>;
|
|
84
90
|
}>, import("@trezor/schema-utils").TObject<{
|
|
85
91
|
type: import("@trezor/schema-utils").TLiteral<"ethereum">;
|
|
@@ -75,9 +75,7 @@ const decodeEthereumDefinition = (encodedDefinition) => {
|
|
|
75
75
|
const { definitionType, protobufPayload } = protocol_1.trzd.decode(encodedPayload);
|
|
76
76
|
const messages = DataManager_1.DataManager.getProtobufMessages();
|
|
77
77
|
const proto = (0, protobuf_1.parseConfigure)(messages);
|
|
78
|
-
const
|
|
79
|
-
const Message = proto.lookupType(type);
|
|
80
|
-
const decodedDefinition = (0, protobuf_1.decode)(Message, protobufPayload);
|
|
78
|
+
const { message: decodedDefinition } = (0, protobuf_1.decodeMessage)(proto, definitionType === 0 ? 'EthereumNetworkInfo' : 'EthereumTokenInfo', protobufPayload);
|
|
81
79
|
if (key === 'encoded_network') {
|
|
82
80
|
(0, schema_utils_1.Assert)(exports.EthereumNetworkDefinitionDecoded, decodedDefinition);
|
|
83
81
|
decoded.network = decodedDefinition;
|
package/lib/api/getCoinInfo.d.ts
CHANGED
|
@@ -29,8 +29,14 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
29
29
|
};
|
|
30
30
|
decimals: number;
|
|
31
31
|
defaultFees: {
|
|
32
|
+
maxFeePerGas?: string | undefined;
|
|
33
|
+
maxPriorityFeePerGas?: string | undefined;
|
|
34
|
+
maxWaitTimeEstimate?: number | undefined;
|
|
35
|
+
minWaitTimeEstimate?: number | undefined;
|
|
32
36
|
feeLimit?: string | undefined;
|
|
33
37
|
feePerTx?: string | undefined;
|
|
38
|
+
baseFeePerGas?: string | undefined;
|
|
39
|
+
effectiveGasPrice?: string | undefined;
|
|
34
40
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
35
41
|
feePerUnit: string;
|
|
36
42
|
blocks: number;
|
|
@@ -88,8 +94,14 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
88
94
|
};
|
|
89
95
|
decimals: number;
|
|
90
96
|
defaultFees: {
|
|
97
|
+
maxFeePerGas?: string | undefined;
|
|
98
|
+
maxPriorityFeePerGas?: string | undefined;
|
|
99
|
+
maxWaitTimeEstimate?: number | undefined;
|
|
100
|
+
minWaitTimeEstimate?: number | undefined;
|
|
91
101
|
feeLimit?: string | undefined;
|
|
92
102
|
feePerTx?: string | undefined;
|
|
103
|
+
baseFeePerGas?: string | undefined;
|
|
104
|
+
effectiveGasPrice?: string | undefined;
|
|
93
105
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
94
106
|
feePerUnit: string;
|
|
95
107
|
blocks: number;
|
|
@@ -122,8 +134,14 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
122
134
|
};
|
|
123
135
|
decimals: number;
|
|
124
136
|
defaultFees: {
|
|
137
|
+
maxFeePerGas?: string | undefined;
|
|
138
|
+
maxPriorityFeePerGas?: string | undefined;
|
|
139
|
+
maxWaitTimeEstimate?: number | undefined;
|
|
140
|
+
minWaitTimeEstimate?: number | undefined;
|
|
125
141
|
feeLimit?: string | undefined;
|
|
126
142
|
feePerTx?: string | undefined;
|
|
143
|
+
baseFeePerGas?: string | undefined;
|
|
144
|
+
effectiveGasPrice?: string | undefined;
|
|
127
145
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
128
146
|
feePerUnit: string;
|
|
129
147
|
blocks: number;
|
|
@@ -10,8 +10,7 @@ export default class SolanaComposeTransaction extends AbstractMethod<'solanaComp
|
|
|
10
10
|
run(): Promise<{
|
|
11
11
|
serializedTx: string;
|
|
12
12
|
additionalInfo: {
|
|
13
|
-
|
|
14
|
-
newTokenAccountProgramName: "spl-token" | "spl-token-2022" | undefined;
|
|
13
|
+
newAccountProgramName: "spl-token" | "spl-token-2022" | undefined;
|
|
15
14
|
tokenAccountInfo: {
|
|
16
15
|
baseAddress: string;
|
|
17
16
|
tokenProgram: string;
|
|
@@ -43,14 +43,11 @@ class SolanaComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
43
43
|
const isCreatingAccount = this.params.token &&
|
|
44
44
|
recipientTokenAccounts === undefined &&
|
|
45
45
|
(recipientAccountOwner === solana_1.SYSTEM_PROGRAM_PUBLIC_KEY || recipientAccountOwner == null);
|
|
46
|
-
const
|
|
47
|
-
? this.params.token?.program
|
|
48
|
-
: undefined;
|
|
46
|
+
const newAccountProgramName = isCreatingAccount ? this.params.token?.program : undefined;
|
|
49
47
|
return {
|
|
50
48
|
serializedTx: tx.serialize(),
|
|
51
49
|
additionalInfo: {
|
|
52
|
-
|
|
53
|
-
newTokenAccountProgramName,
|
|
50
|
+
newAccountProgramName,
|
|
54
51
|
tokenAccountInfo: tokenTransferTxAndDestinationAddress?.tokenAccountInfo,
|
|
55
52
|
},
|
|
56
53
|
};
|
package/lib/api/unlockPath.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ class AbstractMethod {
|
|
|
109
109
|
this.allowDeviceMode = [events_1.UI.SEEDLESS];
|
|
110
110
|
}
|
|
111
111
|
this.network = 'bitcoin';
|
|
112
|
-
|
|
112
|
+
(0, utils_1.typedObjectKeys)(constants_1.NETWORK.TYPES).forEach(key => {
|
|
113
113
|
if (this.name.startsWith(key)) {
|
|
114
114
|
this.network = key;
|
|
115
115
|
}
|