@trezor/connect 9.0.7 → 9.0.8
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 +13 -0
- package/README.md +1 -1
- package/lib/api/bitcoin/createPendingTx.d.ts +35 -0
- package/lib/api/bitcoin/createPendingTx.js +60 -0
- package/lib/api/bitcoin/index.d.ts +1 -0
- package/lib/api/bitcoin/index.js +1 -0
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +2 -1
- package/lib/api/blockchainGetCurrentFiatRates.js +6 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +3 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.js +9 -1
- package/lib/api/blockchainGetTransactions.d.ts +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.js +43 -23
- package/lib/api/cardanoSignTransaction.d.ts +2 -1
- package/lib/api/cardanoSignTransaction.js +21 -11
- package/lib/api/composeTransaction.js +2 -2
- package/lib/api/ethereum/ethereumDefinitions.d.ts +7 -0
- package/lib/api/ethereum/ethereumDefinitions.js +43 -0
- package/lib/api/ethereum/ethereumSignTx.d.ts +3 -2
- package/lib/api/ethereum/ethereumSignTx.js +4 -2
- package/lib/api/ethereumGetAddress.d.ts +2 -1
- package/lib/api/ethereumGetAddress.js +19 -2
- package/lib/api/ethereumSignMessage.js +13 -0
- package/lib/api/ethereumSignTransaction.js +10 -3
- package/lib/api/ethereumSignTypedData.js +13 -0
- package/lib/api/firmware/getBinary.d.ts +3 -12
- package/lib/api/firmware/getBinary.js +5 -9
- package/lib/api/firmwareUpdate.d.ts +3 -2
- package/lib/api/firmwareUpdate.js +4 -5
- package/lib/api/getAccountInfo.d.ts +8 -8
- package/lib/api/getAccountInfo.js +1 -1
- package/lib/api/setBusy.js +1 -4
- package/lib/api/setProxy.js +1 -1
- package/lib/api/signTransaction.d.ts +2 -1
- package/lib/api/signTransaction.js +12 -2
- package/lib/api/unlockPath.js +1 -4
- package/lib/backend/Blockchain.d.ts +3 -0
- package/lib/core/AbstractMethod.d.ts +1 -0
- package/lib/core/AbstractMethod.js +9 -0
- package/lib/core/index.js +13 -7
- package/lib/data/DataManager.d.ts +92 -15
- package/lib/data/DataManager.js +3 -54
- package/lib/data/config.js +9 -3
- package/lib/data/connectSettings.d.ts +0 -1
- package/lib/data/connectSettings.js +10 -57
- package/lib/data/firmwareInfo.js +48 -46
- package/lib/data/transportInfo.d.ts +1 -0
- package/lib/data/transportInfo.js +14 -1
- package/lib/data/udevInfo.d.ts +1 -0
- package/lib/data/udevInfo.js +14 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/DescriptorStream.js +1 -1
- package/lib/device/DeviceCommands.d.ts +1 -1
- package/lib/device/DeviceCommands.js +2 -1
- package/lib/device/DeviceList.d.ts +1 -2
- package/lib/device/DeviceList.js +20 -10
- package/lib/events/iframe.d.ts +2 -1
- package/lib/events/popup.d.ts +2 -1
- package/lib/index.js +1 -4
- package/lib/types/api/bitcoin/index.d.ts +4 -0
- package/lib/types/api/cardano/index.d.ts +10 -9
- package/lib/types/api/firmwareUpdate.d.ts +2 -1
- package/lib/types/firmware.d.ts +2 -3
- package/lib/types/index.d.ts +1 -1
- package/lib/types/settings.d.ts +10 -1
- package/lib/utils/firmwareUtils.d.ts +0 -1
- package/lib/utils/firmwareUtils.js +1 -9
- package/lib/utils/pathUtils.d.ts +1 -0
- package/lib/utils/pathUtils.js +3 -1
- package/lib/utils/promiseUtils.d.ts +5 -1
- package/lib/utils/promiseUtils.js +7 -3
- package/lib/utils/urlUtils.d.ts +2 -1
- package/lib/utils/urlUtils.js +18 -3
- package/lib/utils/versionUtils.d.ts +3 -1
- package/lib/utils/versionUtils.js +5 -2
- package/package.json +12 -13
- package/lib/device/AbortController.d.ts +0 -21
- package/lib/device/AbortController.js +0 -40
- package/lib/utils/browserUtils.d.ts +0 -21
- package/lib/utils/browserUtils.js +0 -100
- package/lib/utils/windowsUtils.d.ts +0 -2
- package/lib/utils/windowsUtils.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# 9.0.8
|
|
2
|
+
|
|
3
|
+
- feat: support multiple intermediary FWs for model 1 and devkit binaries
|
|
4
|
+
- `FirmwareUpdate` now accepts `intermediaryVersion` param instead of `intermediary`
|
|
5
|
+
- `getInfo` returns `intermediaryVersion` needed for T1 and removed `latest` param. 'release' always return latest version for T1 so it means abandoning the concept of incremental updates for T1.
|
|
6
|
+
- feat: signTransaction now returns `signedTransaction` which can be used for visualization purposes before notification about pending transaction from blockchain is received.
|
|
7
|
+
- feat(blockchain): `blockchainGetCurrentFiatRates` and `blockchainGetFiatRatesForTimestamps` now accept additional `token` parameter
|
|
8
|
+
- feat: support coinjoin for model 1
|
|
9
|
+
- feat(transport): eth definitions
|
|
10
|
+
- feat(webextension): Ignore port events if it is not port created by current popup
|
|
11
|
+
- feat(cardano): allow external reward addresses in governance registrations
|
|
12
|
+
- refactor(connect): removing browser related code from @trezor/connect
|
|
13
|
+
|
|
1
14
|
# 9.0.7
|
|
2
15
|
|
|
3
16
|
- feat(connect-ui): connect UI will now display a warning in case it was opened by an application listed in https://github.com/MetaMask/eth-phishing-detect (#7488)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.0.
|
|
3
|
+
API version 9.0.8
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Transaction as BitcoinJsTransaction } from '@trezor/utxo-lib';
|
|
2
|
+
import { PROTO } from '../../constants';
|
|
3
|
+
import type { AccountAddresses, AccountUtxo } from '../../types';
|
|
4
|
+
export declare const createPendingTransaction: (tx: BitcoinJsTransaction, { utxo, addresses, inputs, outputs, }: {
|
|
5
|
+
utxo: AccountUtxo[];
|
|
6
|
+
addresses: AccountAddresses;
|
|
7
|
+
inputs: PROTO.TxInputType[];
|
|
8
|
+
outputs: PROTO.TxOutputType[];
|
|
9
|
+
}) => {
|
|
10
|
+
txid: string;
|
|
11
|
+
hex: string;
|
|
12
|
+
blockHeight: number;
|
|
13
|
+
blockTime: number;
|
|
14
|
+
confirmations: number;
|
|
15
|
+
vsize: number;
|
|
16
|
+
size: number;
|
|
17
|
+
value: string;
|
|
18
|
+
valueIn: string;
|
|
19
|
+
fees: string;
|
|
20
|
+
vin: {
|
|
21
|
+
n: number;
|
|
22
|
+
txid: string;
|
|
23
|
+
vout: number;
|
|
24
|
+
isAddress: boolean;
|
|
25
|
+
addresses: string[];
|
|
26
|
+
value: string;
|
|
27
|
+
}[];
|
|
28
|
+
vout: {
|
|
29
|
+
n: number;
|
|
30
|
+
isAddress: boolean;
|
|
31
|
+
addresses: string[];
|
|
32
|
+
value: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=createPendingTx.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPendingTransaction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
|
|
6
|
+
const pathUtils_1 = require("../../utils/pathUtils");
|
|
7
|
+
const createPendingTransaction = (tx, { utxo, addresses, inputs, outputs, }) => {
|
|
8
|
+
const valueOut = outputs.reduce((sum, out) => (0, bignumber_js_1.default)(sum).plus(out.amount), new bignumber_js_1.default('0'));
|
|
9
|
+
const valueIn = inputs.reduce((sum, ins) => (0, bignumber_js_1.default)(sum).plus(ins.amount), new bignumber_js_1.default('0'));
|
|
10
|
+
return {
|
|
11
|
+
txid: tx.getId(),
|
|
12
|
+
hex: tx.toHex(),
|
|
13
|
+
blockHeight: 0,
|
|
14
|
+
blockTime: Math.floor(Date.now() / 1000),
|
|
15
|
+
confirmations: 0,
|
|
16
|
+
vsize: tx.virtualSize(),
|
|
17
|
+
size: tx.weight(),
|
|
18
|
+
value: valueOut.toString(),
|
|
19
|
+
valueIn: valueIn.toString(),
|
|
20
|
+
fees: valueIn.minus(valueOut).toString(),
|
|
21
|
+
vin: inputs.map((ins, n) => ({
|
|
22
|
+
n,
|
|
23
|
+
txid: ins.prev_hash,
|
|
24
|
+
vout: ins.prev_index,
|
|
25
|
+
isAddress: true,
|
|
26
|
+
addresses: utxo
|
|
27
|
+
.filter(utxo => utxo.txid === ins.prev_hash && utxo.vout === ins.prev_index)
|
|
28
|
+
.map(utxo => utxo.address),
|
|
29
|
+
value: ins.amount.toString(),
|
|
30
|
+
})),
|
|
31
|
+
vout: outputs.map((out, n) => {
|
|
32
|
+
let transformedAddresses = [];
|
|
33
|
+
if (out.address) {
|
|
34
|
+
transformedAddresses = [out.address];
|
|
35
|
+
}
|
|
36
|
+
else if ('op_return_data' in out) {
|
|
37
|
+
transformedAddresses = [
|
|
38
|
+
`OP_RETURN (${Buffer.from(out.op_return_data, 'hex').toString('ascii')})`,
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
transformedAddresses = [
|
|
43
|
+
...addresses.change,
|
|
44
|
+
...addresses.unused,
|
|
45
|
+
...addresses.used,
|
|
46
|
+
]
|
|
47
|
+
.filter(address => out.address_n && address.path === (0, pathUtils_1.getSerializedPath)(out.address_n))
|
|
48
|
+
.map(address => address.address);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
n,
|
|
52
|
+
isAddress: out.script_type !== 'PAYTOOPRETURN',
|
|
53
|
+
addresses: transformedAddresses,
|
|
54
|
+
value: out.amount.toString(),
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.createPendingTransaction = createPendingTransaction;
|
|
60
|
+
//# sourceMappingURL=createPendingTx.js.map
|
package/lib/api/bitcoin/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./createPendingTx"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./enhanceSignTx"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./Fees"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./inputs"), exports);
|
|
@@ -6,7 +6,7 @@ type Params = {
|
|
|
6
6
|
};
|
|
7
7
|
export default class BlockchainGetAccountBalanceHistory extends AbstractMethod<'blockchainGetAccountBalanceHistory', Params> {
|
|
8
8
|
init(): void;
|
|
9
|
-
run(): Promise<import("packages/blockchain-link/lib/
|
|
9
|
+
run(): Promise<import("packages/blockchain-link-types/lib/common").AccountBalanceHistory[]>;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=blockchainGetAccountBalanceHistory.d.ts.map
|
|
@@ -3,12 +3,13 @@ import type { CoinInfo } from '../types';
|
|
|
3
3
|
type Params = {
|
|
4
4
|
coinInfo: CoinInfo;
|
|
5
5
|
currencies: Payload<'blockchainGetCurrentFiatRates'>['currencies'];
|
|
6
|
+
token: Payload<'blockchainGetCurrentFiatRates'>['token'];
|
|
6
7
|
};
|
|
7
8
|
export default class BlockchainGetCurrentFiatRates extends AbstractMethod<'blockchainGetCurrentFiatRates', Params> {
|
|
8
9
|
init(): void;
|
|
9
10
|
run(): Promise<{
|
|
10
11
|
ts: number;
|
|
11
|
-
rates: import("packages/blockchain-link/lib").FiatRates;
|
|
12
|
+
rates: import("packages/blockchain-link-types/lib/common").FiatRates;
|
|
12
13
|
}>;
|
|
13
14
|
}
|
|
14
15
|
export {};
|
|
@@ -12,6 +12,7 @@ class BlockchainGetCurrentFiatRates extends AbstractMethod_1.AbstractMethod {
|
|
|
12
12
|
const { payload } = this;
|
|
13
13
|
(0, paramsValidator_1.validateParams)(payload, [
|
|
14
14
|
{ name: 'currencies', type: 'array', required: false },
|
|
15
|
+
{ name: 'token', type: 'string' },
|
|
15
16
|
{ name: 'coin', type: 'string', required: true },
|
|
16
17
|
]);
|
|
17
18
|
const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
|
|
@@ -21,12 +22,16 @@ class BlockchainGetCurrentFiatRates extends AbstractMethod_1.AbstractMethod {
|
|
|
21
22
|
(0, BlockchainLink_1.isBackendSupported)(coinInfo);
|
|
22
23
|
this.params = {
|
|
23
24
|
currencies: payload.currencies,
|
|
25
|
+
token: payload.token,
|
|
24
26
|
coinInfo,
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
async run() {
|
|
28
30
|
const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
|
|
29
|
-
return backend.getCurrentFiatRates({
|
|
31
|
+
return backend.getCurrentFiatRates({
|
|
32
|
+
currencies: this.params.currencies,
|
|
33
|
+
token: this.params.token,
|
|
34
|
+
});
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
exports.default = BlockchainGetCurrentFiatRates;
|
|
@@ -2,14 +2,16 @@ import { Payload, AbstractMethod } from '../core/AbstractMethod';
|
|
|
2
2
|
import type { CoinInfo } from '../types';
|
|
3
3
|
type Params = {
|
|
4
4
|
coinInfo: CoinInfo;
|
|
5
|
+
currencies: Payload<'blockchainGetFiatRatesForTimestamps'>['currencies'];
|
|
5
6
|
timestamps: Payload<'blockchainGetFiatRatesForTimestamps'>['timestamps'];
|
|
7
|
+
token: Payload<'blockchainGetFiatRatesForTimestamps'>['token'];
|
|
6
8
|
};
|
|
7
9
|
export default class BlockchainGetFiatRatesForTimestamps extends AbstractMethod<'blockchainGetFiatRatesForTimestamps', Params> {
|
|
8
10
|
init(): void;
|
|
9
11
|
run(): Promise<{
|
|
10
12
|
tickers: {
|
|
11
13
|
ts: number;
|
|
12
|
-
rates: import("packages/blockchain-link/lib").FiatRates;
|
|
14
|
+
rates: import("packages/blockchain-link-types/lib/common").FiatRates;
|
|
13
15
|
}[];
|
|
14
16
|
}>;
|
|
15
17
|
}
|
|
@@ -11,7 +11,9 @@ class BlockchainGetFiatRatesForTimestamps extends AbstractMethod_1.AbstractMetho
|
|
|
11
11
|
this.useUi = false;
|
|
12
12
|
const { payload } = this;
|
|
13
13
|
(0, paramsValidator_1.validateParams)(payload, [
|
|
14
|
+
{ name: 'currencies', type: 'array', required: false },
|
|
14
15
|
{ name: 'timestamps', type: 'array', required: true },
|
|
16
|
+
{ name: 'token', type: 'string' },
|
|
15
17
|
{ name: 'coin', type: 'string', required: true },
|
|
16
18
|
]);
|
|
17
19
|
const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
|
|
@@ -20,13 +22,19 @@ class BlockchainGetFiatRatesForTimestamps extends AbstractMethod_1.AbstractMetho
|
|
|
20
22
|
}
|
|
21
23
|
(0, BlockchainLink_1.isBackendSupported)(coinInfo);
|
|
22
24
|
this.params = {
|
|
25
|
+
currencies: payload.currencies,
|
|
23
26
|
timestamps: payload.timestamps,
|
|
27
|
+
token: payload.token,
|
|
24
28
|
coinInfo,
|
|
25
29
|
};
|
|
26
30
|
}
|
|
27
31
|
async run() {
|
|
28
32
|
const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage);
|
|
29
|
-
return backend.getFiatRatesForTimestamps({
|
|
33
|
+
return backend.getFiatRatesForTimestamps({
|
|
34
|
+
currencies: this.params.currencies,
|
|
35
|
+
timestamps: this.params.timestamps,
|
|
36
|
+
token: this.params.token,
|
|
37
|
+
});
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
exports.default = BlockchainGetFiatRatesForTimestamps;
|
|
@@ -6,7 +6,7 @@ type Params = {
|
|
|
6
6
|
};
|
|
7
7
|
export default class BlockchainGetTransactions extends AbstractMethod<'blockchainGetTransactions', Params> {
|
|
8
8
|
init(): void;
|
|
9
|
-
run(): Promise<import("packages/blockchain-link/lib").TypedRawTransaction[]>;
|
|
9
|
+
run(): Promise<import("packages/blockchain-link-types/lib").TypedRawTransaction[]>;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=blockchainGetTransactions.d.ts.map
|
|
@@ -7,37 +7,57 @@ const pathUtils_1 = require("../../utils/pathUtils");
|
|
|
7
7
|
const constants_1 = require("../../constants");
|
|
8
8
|
const MAX_DELEGATION_COUNT = 32;
|
|
9
9
|
const transformDelegation = (delegation) => {
|
|
10
|
+
if (delegation.votingPublicKey) {
|
|
11
|
+
console.warn('Please use votePublicKey instead of votingPublicKey.');
|
|
12
|
+
delegation.votePublicKey = delegation.votingPublicKey;
|
|
13
|
+
}
|
|
10
14
|
(0, paramsValidator_1.validateParams)(delegation, [
|
|
11
|
-
{ name: '
|
|
15
|
+
{ name: 'votePublicKey', type: 'string', required: true },
|
|
12
16
|
{ name: 'weight', type: 'uint', required: true },
|
|
13
17
|
]);
|
|
14
18
|
return {
|
|
15
|
-
|
|
19
|
+
vote_public_key: delegation.votePublicKey,
|
|
16
20
|
weight: delegation.weight,
|
|
17
21
|
};
|
|
18
22
|
};
|
|
19
|
-
const
|
|
20
|
-
(
|
|
21
|
-
|
|
23
|
+
const transformCvoteRegistrationParameters = (cVoteRegistrationParameters) => {
|
|
24
|
+
if (cVoteRegistrationParameters.votingPublicKey) {
|
|
25
|
+
console.warn('Please use votePublicKey instead of votingPublicKey.');
|
|
26
|
+
cVoteRegistrationParameters.votePublicKey = cVoteRegistrationParameters.votingPublicKey;
|
|
27
|
+
}
|
|
28
|
+
if (cVoteRegistrationParameters.rewardAddressParameters) {
|
|
29
|
+
console.warn('Please use paymentAddressParameters instead of rewardAddressParameters.');
|
|
30
|
+
cVoteRegistrationParameters.paymentAddressParameters =
|
|
31
|
+
cVoteRegistrationParameters.rewardAddressParameters;
|
|
32
|
+
}
|
|
33
|
+
(0, paramsValidator_1.validateParams)(cVoteRegistrationParameters, [
|
|
34
|
+
{ name: 'votePublicKey', type: 'string' },
|
|
22
35
|
{ name: 'stakingPath', required: true },
|
|
23
36
|
{ name: 'nonce', type: 'uint', required: true },
|
|
24
37
|
{ name: 'format', type: 'number' },
|
|
25
38
|
{ name: 'delegations', type: 'array', allowEmpty: true },
|
|
26
39
|
{ name: 'votingPurpose', type: 'uint' },
|
|
40
|
+
{ name: 'address', type: 'string' },
|
|
27
41
|
]);
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
const { paymentAddressParameters } = cVoteRegistrationParameters;
|
|
43
|
+
if (paymentAddressParameters) {
|
|
44
|
+
(0, cardanoAddressParameters_1.validateAddressParameters)(paymentAddressParameters);
|
|
45
|
+
}
|
|
46
|
+
const { delegations } = cVoteRegistrationParameters;
|
|
30
47
|
if (delegations && delegations.length > MAX_DELEGATION_COUNT) {
|
|
31
|
-
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `At most ${MAX_DELEGATION_COUNT} delegations are allowed in a
|
|
48
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `At most ${MAX_DELEGATION_COUNT} delegations are allowed in a CIP-36 registration`);
|
|
32
49
|
}
|
|
33
50
|
return {
|
|
34
|
-
|
|
35
|
-
staking_path: (0, pathUtils_1.validatePath)(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
vote_public_key: cVoteRegistrationParameters.votePublicKey,
|
|
52
|
+
staking_path: (0, pathUtils_1.validatePath)(cVoteRegistrationParameters.stakingPath, 3),
|
|
53
|
+
payment_address_parameters: paymentAddressParameters
|
|
54
|
+
? (0, cardanoAddressParameters_1.addressParametersToProto)(paymentAddressParameters)
|
|
55
|
+
: undefined,
|
|
56
|
+
nonce: cVoteRegistrationParameters.nonce,
|
|
57
|
+
format: cVoteRegistrationParameters.format,
|
|
39
58
|
delegations: delegations === null || delegations === void 0 ? void 0 : delegations.map(transformDelegation),
|
|
40
|
-
voting_purpose:
|
|
59
|
+
voting_purpose: cVoteRegistrationParameters.votingPurpose,
|
|
60
|
+
payment_address: cVoteRegistrationParameters.paymentAddress,
|
|
41
61
|
};
|
|
42
62
|
};
|
|
43
63
|
const transformAuxiliaryData = (auxiliaryData) => {
|
|
@@ -47,24 +67,24 @@ const transformAuxiliaryData = (auxiliaryData) => {
|
|
|
47
67
|
type: 'string',
|
|
48
68
|
},
|
|
49
69
|
]);
|
|
50
|
-
let
|
|
51
|
-
if (auxiliaryData.
|
|
52
|
-
|
|
70
|
+
let cVoteRegistrationParameters;
|
|
71
|
+
if (auxiliaryData.cVoteRegistrationParameters) {
|
|
72
|
+
cVoteRegistrationParameters = transformCvoteRegistrationParameters(auxiliaryData.cVoteRegistrationParameters);
|
|
53
73
|
}
|
|
54
74
|
return {
|
|
55
75
|
hash: auxiliaryData.hash,
|
|
56
|
-
|
|
76
|
+
cvote_registration_parameters: cVoteRegistrationParameters,
|
|
57
77
|
};
|
|
58
78
|
};
|
|
59
79
|
exports.transformAuxiliaryData = transformAuxiliaryData;
|
|
60
80
|
const modifyAuxiliaryDataForBackwardsCompatibility = (device, auxiliary_data) => {
|
|
61
|
-
const {
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
(0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device,
|
|
81
|
+
const { cvote_registration_parameters } = auxiliary_data;
|
|
82
|
+
if (cvote_registration_parameters === null || cvote_registration_parameters === void 0 ? void 0 : cvote_registration_parameters.payment_address_parameters) {
|
|
83
|
+
cvote_registration_parameters.payment_address_parameters =
|
|
84
|
+
(0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device, cvote_registration_parameters.payment_address_parameters);
|
|
65
85
|
return {
|
|
66
86
|
...auxiliary_data,
|
|
67
|
-
|
|
87
|
+
cvote_registration_parameters,
|
|
68
88
|
};
|
|
69
89
|
}
|
|
70
90
|
return auxiliary_data;
|
|
@@ -15,7 +15,8 @@ declare const CardanoSignTransactionFeatures: Readonly<{
|
|
|
15
15
|
Plutus: string[];
|
|
16
16
|
KeyHashStakeCredential: string[];
|
|
17
17
|
Babbage: string[];
|
|
18
|
-
|
|
18
|
+
CIP36Registration: string[];
|
|
19
|
+
CIP36RegistrationExternalPaymentAddress: string[];
|
|
19
20
|
}>;
|
|
20
21
|
export type CardanoSignTransactionParams = {
|
|
21
22
|
signingMode: PROTO.CardanoTxSigningMode;
|
|
@@ -21,7 +21,8 @@ const CardanoSignTransactionFeatures = Object.freeze({
|
|
|
21
21
|
Plutus: ['0', '2.4.4'],
|
|
22
22
|
KeyHashStakeCredential: ['0', '2.4.4'],
|
|
23
23
|
Babbage: ['0', '2.5.2'],
|
|
24
|
-
|
|
24
|
+
CIP36Registration: ['0', '2.5.3'],
|
|
25
|
+
CIP36RegistrationExternalPaymentAddress: ['0', '2.5.4'],
|
|
25
26
|
});
|
|
26
27
|
class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
27
28
|
init() {
|
|
@@ -36,10 +37,15 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
36
37
|
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Auxiliary data can now only be sent as a hash.');
|
|
37
38
|
}
|
|
38
39
|
if (payload.auxiliaryData && payload.auxiliaryData.catalystRegistrationParameters) {
|
|
39
|
-
console.warn('Please use
|
|
40
|
-
payload.auxiliaryData.
|
|
40
|
+
console.warn('Please use cVoteRegistrationParameters instead of catalystRegistrationParameters.');
|
|
41
|
+
payload.auxiliaryData.cVoteRegistrationParameters =
|
|
41
42
|
payload.auxiliaryData.catalystRegistrationParameters;
|
|
42
43
|
}
|
|
44
|
+
if (payload.auxiliaryData && payload.auxiliaryData.governanceRegistrationParameters) {
|
|
45
|
+
console.warn('Please use cVoteRegistrationParameters instead of governanceRegistrationParameters.');
|
|
46
|
+
payload.auxiliaryData.cVoteRegistrationParameters =
|
|
47
|
+
payload.auxiliaryData.governanceRegistrationParameters;
|
|
48
|
+
}
|
|
43
49
|
(0, paramsValidator_1.validateParams)(payload, [
|
|
44
50
|
{ name: 'signingMode', type: 'number', required: true },
|
|
45
51
|
{ name: 'inputs', type: 'array', required: true },
|
|
@@ -204,12 +210,15 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
204
210
|
params.signingMode !== constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
|
|
205
211
|
this._ensureFeatureIsSupported('Babbage');
|
|
206
212
|
}
|
|
207
|
-
if ((_a = params.auxiliaryData) === null || _a === void 0 ? void 0 : _a.
|
|
208
|
-
const { format, delegations, voting_purpose } = params.auxiliaryData.
|
|
209
|
-
if (format === constants_1.PROTO.
|
|
213
|
+
if ((_a = params.auxiliaryData) === null || _a === void 0 ? void 0 : _a.cvote_registration_parameters) {
|
|
214
|
+
const { format, delegations, voting_purpose, payment_address } = params.auxiliaryData.cvote_registration_parameters;
|
|
215
|
+
if (format === constants_1.PROTO.CardanoCVoteRegistrationFormat.CIP36 ||
|
|
210
216
|
(delegations === null || delegations === void 0 ? void 0 : delegations.length) ||
|
|
211
217
|
voting_purpose != null) {
|
|
212
|
-
this._ensureFeatureIsSupported('
|
|
218
|
+
this._ensureFeatureIsSupported('CIP36Registration');
|
|
219
|
+
}
|
|
220
|
+
if (payment_address) {
|
|
221
|
+
this._ensureFeatureIsSupported('CIP36RegistrationExternalPaymentAddress');
|
|
213
222
|
}
|
|
214
223
|
}
|
|
215
224
|
}
|
|
@@ -261,8 +270,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
261
270
|
}
|
|
262
271
|
let auxiliaryDataSupplement;
|
|
263
272
|
if (this.params.auxiliaryData) {
|
|
264
|
-
const {
|
|
265
|
-
if (
|
|
273
|
+
const { cvote_registration_parameters } = this.params.auxiliaryData;
|
|
274
|
+
if (cvote_registration_parameters) {
|
|
266
275
|
this.params.auxiliaryData = (0, cardanoAuxiliaryData_1.modifyAuxiliaryDataForBackwardsCompatibility)(this.device, this.params.auxiliaryData);
|
|
267
276
|
}
|
|
268
277
|
const { message } = await typedCall('CardanoTxAuxiliaryData', 'CardanoTxAuxiliaryDataSupplement', this.params.auxiliaryData);
|
|
@@ -271,8 +280,9 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
271
280
|
auxiliaryDataSupplement = {
|
|
272
281
|
type: auxiliaryDataType,
|
|
273
282
|
auxiliaryDataHash: message.auxiliary_data_hash,
|
|
274
|
-
|
|
275
|
-
catalystSignature: message.
|
|
283
|
+
cVoteRegistrationSignature: message.cvote_registration_signature,
|
|
284
|
+
catalystSignature: message.cvote_registration_signature,
|
|
285
|
+
governanceSignature: message.cvote_registration_signature,
|
|
276
286
|
};
|
|
277
287
|
}
|
|
278
288
|
await typedCall('CardanoTxHostAck', 'CardanoTxItemAck');
|
|
@@ -172,7 +172,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
172
172
|
discovery.removeAllListeners();
|
|
173
173
|
discovery.stop();
|
|
174
174
|
if (!discovery.completed) {
|
|
175
|
-
await (0, promiseUtils_1.resolveAfter)(501);
|
|
175
|
+
await (0, promiseUtils_1.resolveAfter)(501).promise;
|
|
176
176
|
}
|
|
177
177
|
const account = discovery.accounts[uiResp.payload];
|
|
178
178
|
this.params.coinInfo = (0, coinInfo_1.fixCoinInfoNetwork)(this.params.coinInfo, account.address_n);
|
|
@@ -195,7 +195,7 @@ class ComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
195
195
|
const hasFunds = composer.composeAllFeeLevels();
|
|
196
196
|
if (!hasFunds) {
|
|
197
197
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.INSUFFICIENT_FUNDS));
|
|
198
|
-
await (0, promiseUtils_1.resolveAfter)(2000, null);
|
|
198
|
+
await (0, promiseUtils_1.resolveAfter)(2000, null).promise;
|
|
199
199
|
return 'change-account';
|
|
200
200
|
}
|
|
201
201
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.SELECT_FEE, {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EthereumDefinitions } from '@trezor/transport/lib/types/messages';
|
|
2
|
+
export declare const getEthereumDefinitions: ({ chainId, slip44, contractAddress, }: {
|
|
3
|
+
chainId: number | undefined;
|
|
4
|
+
slip44?: number | undefined;
|
|
5
|
+
contractAddress?: string | undefined;
|
|
6
|
+
}) => Promise<EthereumDefinitions>;
|
|
7
|
+
//# sourceMappingURL=ethereumDefinitions.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEthereumDefinitions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
|
|
6
|
+
const getEthereumDefinitions = async ({ chainId, slip44, contractAddress, }) => {
|
|
7
|
+
const definitions = {};
|
|
8
|
+
if (!chainId && !slip44) {
|
|
9
|
+
throw new Error('argument chainId or slip44 is required');
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const networkDefinitionUrl = `https://data.trezor.io/firmware/eth-definitions/${chainId ? 'chain-id' : 'slip44'}/${chainId !== null && chainId !== void 0 ? chainId : slip44}/network.dat`;
|
|
13
|
+
const networkDefinition = await (0, cross_fetch_1.default)(networkDefinitionUrl);
|
|
14
|
+
if (networkDefinition.status === 200) {
|
|
15
|
+
definitions.encoded_network = await networkDefinition.arrayBuffer();
|
|
16
|
+
}
|
|
17
|
+
else if (networkDefinition.status !== 404) {
|
|
18
|
+
throw new Error(`unexpected status: $${networkDefinition.status}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.warn(`unable to download or parse ${chainId} definition. detail: ${err.message}`);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
if (contractAddress) {
|
|
26
|
+
const lowerCaseContractAddress = contractAddress.toLowerCase();
|
|
27
|
+
const tokenDefinitionUrl = `https://data.trezor.io/firmware/eth-definitions/${chainId ? 'chain-id' : 'slip44'}/${chainId !== null && chainId !== void 0 ? chainId : slip44}/token-${lowerCaseContractAddress}.dat`;
|
|
28
|
+
const tokenDefinition = await (0, cross_fetch_1.default)(tokenDefinitionUrl);
|
|
29
|
+
if (tokenDefinition.status === 200) {
|
|
30
|
+
definitions.encoded_token = await tokenDefinition.arrayBuffer();
|
|
31
|
+
}
|
|
32
|
+
else if (tokenDefinition.status !== 404) {
|
|
33
|
+
throw new Error(`unexpected status: $${tokenDefinition.status}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
console.warn(`unable to download or parse ${chainId}/${contractAddress} definition. detail: ${err.message}`);
|
|
39
|
+
}
|
|
40
|
+
return definitions;
|
|
41
|
+
};
|
|
42
|
+
exports.getEthereumDefinitions = getEthereumDefinitions;
|
|
43
|
+
//# sourceMappingURL=ethereumDefinitions.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { EthereumDefinitions } from '@trezor/transport/lib/types/messages';
|
|
1
2
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
2
3
|
import type { EthereumAccessList } from '../../types/api/ethereum';
|
|
3
|
-
export declare const ethereumSignTx: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, gas_price: string, nonce: string, chain_id: number, data?: string, tx_type?: number) => Promise<{
|
|
4
|
+
export declare const ethereumSignTx: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, gas_price: string, nonce: string, chain_id: number, data?: string, tx_type?: number, definitions?: EthereumDefinitions) => Promise<{
|
|
4
5
|
v: string;
|
|
5
6
|
r: string;
|
|
6
7
|
s: string;
|
|
7
8
|
}>;
|
|
8
|
-
export declare const ethereumSignTxEIP1559: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, max_gas_fee: string, max_priority_fee: string, nonce: string, chain_id: number, data?: string, access_list?: EthereumAccessList[]) => Promise<{
|
|
9
|
+
export declare const ethereumSignTxEIP1559: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, max_gas_fee: string, max_priority_fee: string, nonce: string, chain_id: number, data?: string, access_list?: EthereumAccessList[], definitions?: EthereumDefinitions) => Promise<{
|
|
9
10
|
v: string;
|
|
10
11
|
r: string;
|
|
11
12
|
s: string;
|
|
@@ -37,7 +37,7 @@ const stripLeadingZeroes = (str) => {
|
|
|
37
37
|
}
|
|
38
38
|
return str;
|
|
39
39
|
};
|
|
40
|
-
const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_price, nonce, chain_id, data, tx_type) => {
|
|
40
|
+
const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_price, nonce, chain_id, data, tx_type, definitions) => {
|
|
41
41
|
const length = data == null ? 0 : data.length / 2;
|
|
42
42
|
const [first, rest] = splitString(data, 1024 * 2);
|
|
43
43
|
let message = {
|
|
@@ -48,6 +48,7 @@ const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_pr
|
|
|
48
48
|
gas_limit: stripLeadingZeroes(gas_limit),
|
|
49
49
|
to,
|
|
50
50
|
value: stripLeadingZeroes(value),
|
|
51
|
+
definitions,
|
|
51
52
|
};
|
|
52
53
|
if (length !== 0) {
|
|
53
54
|
message = {
|
|
@@ -66,7 +67,7 @@ const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_pr
|
|
|
66
67
|
return processTxRequest(typedCall, response.message, rest, chain_id);
|
|
67
68
|
};
|
|
68
69
|
exports.ethereumSignTx = ethereumSignTx;
|
|
69
|
-
const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit, max_gas_fee, max_priority_fee, nonce, chain_id, data, access_list) => {
|
|
70
|
+
const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit, max_gas_fee, max_priority_fee, nonce, chain_id, data, access_list, definitions) => {
|
|
70
71
|
const length = data == null ? 0 : data.length / 2;
|
|
71
72
|
const [first, rest] = splitString(data, 1024 * 2);
|
|
72
73
|
const message = {
|
|
@@ -84,6 +85,7 @@ const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit,
|
|
|
84
85
|
address: a.address,
|
|
85
86
|
storage_keys: a.storageKeys,
|
|
86
87
|
})),
|
|
88
|
+
definitions,
|
|
87
89
|
};
|
|
88
90
|
const response = await typedCall('EthereumSignTxEIP1559', 'EthereumTxRequest', message);
|
|
89
91
|
return processTxRequest(typedCall, response.message, rest);
|
|
@@ -4,6 +4,7 @@ import type { EthereumNetworkInfo } from '../types';
|
|
|
4
4
|
type Params = PROTO.EthereumGetAddress & {
|
|
5
5
|
address?: string;
|
|
6
6
|
network?: EthereumNetworkInfo;
|
|
7
|
+
encoded_network?: ArrayBuffer;
|
|
7
8
|
};
|
|
8
9
|
export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddress', Params[]> {
|
|
9
10
|
hasBundle?: boolean;
|
|
@@ -17,7 +18,7 @@ export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddre
|
|
|
17
18
|
} | undefined;
|
|
18
19
|
confirmation(): Promise<boolean>;
|
|
19
20
|
noBackupConfirmation(): Promise<boolean>;
|
|
20
|
-
_call({ address_n, show_display }: Params): Promise<{
|
|
21
|
+
_call({ address_n, show_display, encoded_network }: Params): Promise<{
|
|
21
22
|
path: number[];
|
|
22
23
|
serializedPath: string;
|
|
23
24
|
address: string;
|
|
@@ -8,6 +8,7 @@ const coinInfo_1 = require("../data/coinInfo");
|
|
|
8
8
|
const formatUtils_1 = require("../utils/formatUtils");
|
|
9
9
|
const constants_1 = require("../constants");
|
|
10
10
|
const events_1 = require("../events");
|
|
11
|
+
const ethereumDefinitions_1 = require("./ethereum/ethereumDefinitions");
|
|
11
12
|
class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
@@ -90,20 +91,33 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
90
91
|
const uiResp = await uiPromise.promise;
|
|
91
92
|
return uiResp.payload;
|
|
92
93
|
}
|
|
93
|
-
_call({ address_n, show_display }) {
|
|
94
|
+
_call({ address_n, show_display, encoded_network }) {
|
|
94
95
|
const cmd = this.device.getCommands();
|
|
95
96
|
return cmd.ethereumGetAddress({
|
|
96
97
|
address_n,
|
|
97
98
|
show_display,
|
|
99
|
+
encoded_network,
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
102
|
async run() {
|
|
103
|
+
var _a;
|
|
101
104
|
const responses = [];
|
|
102
105
|
for (let i = 0; i < this.params.length; i++) {
|
|
103
106
|
const batch = this.params[i];
|
|
107
|
+
const slip44 = (0, pathUtils_1.getSlip44ByPath)(batch.address_n);
|
|
108
|
+
const definitions = await (0, ethereumDefinitions_1.getEthereumDefinitions)({
|
|
109
|
+
chainId: (_a = batch === null || batch === void 0 ? void 0 : batch.network) === null || _a === void 0 ? void 0 : _a.chainId,
|
|
110
|
+
slip44,
|
|
111
|
+
});
|
|
112
|
+
const definitionParams = {
|
|
113
|
+
...(definitions.encoded_network && {
|
|
114
|
+
encoded_network: definitions.encoded_network,
|
|
115
|
+
}),
|
|
116
|
+
};
|
|
104
117
|
if (batch.show_display) {
|
|
105
118
|
const silent = await this._call({
|
|
106
119
|
...batch,
|
|
120
|
+
...definitionParams,
|
|
107
121
|
show_display: false,
|
|
108
122
|
});
|
|
109
123
|
if (typeof batch.address === 'string') {
|
|
@@ -116,7 +130,10 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
116
130
|
batch.address = silent.address;
|
|
117
131
|
}
|
|
118
132
|
}
|
|
119
|
-
const response = await this._call(
|
|
133
|
+
const response = await this._call({
|
|
134
|
+
...batch,
|
|
135
|
+
...definitionParams,
|
|
136
|
+
});
|
|
120
137
|
responses.push(response);
|
|
121
138
|
if (this.hasBundle) {
|
|
122
139
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.BUNDLE_PROGRESS, {
|