@trezor/connect 9.1.9 → 9.1.11
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 +16 -0
- package/README.md +1 -1
- package/lib/api/applyFlags.d.ts +4 -2
- package/lib/api/applyFlags.js +3 -2
- package/lib/api/applySettings.d.ts +4 -2
- package/lib/api/applySettings.js +3 -13
- package/lib/api/authenticateDevice.js +3 -11
- package/lib/api/authorizeCoinjoin.d.ts +3 -1
- package/lib/api/authorizeCoinjoin.js +3 -11
- package/lib/api/backupDevice.d.ts +3 -1
- package/lib/api/binance/api/binanceGetAddress.d.ts +4 -2
- package/lib/api/binance/api/binanceGetAddress.js +4 -10
- package/lib/api/binance/api/binanceGetPublicKey.d.ts +9 -1
- package/lib/api/binance/api/binanceGetPublicKey.js +3 -5
- package/lib/api/binance/api/binanceSignTransaction.d.ts +4 -1
- package/lib/api/binance/api/binanceSignTransaction.js +5 -6
- package/lib/api/binance/binanceSignTx.d.ts +84 -3
- package/lib/api/binance/binanceSignTx.js +3 -26
- package/lib/api/bitcoin/Fees.d.ts +14 -2
- package/lib/api/bitcoin/TransactionComposer.d.ts +13 -2
- package/lib/api/bitcoin/refTx.d.ts +2 -2
- package/lib/api/bitcoin/refTx.js +22 -24
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/blockchainDisconnect.d.ts +1 -1
- package/lib/api/blockchainDisconnect.js +3 -2
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
- package/lib/api/blockchainGetTransactions.d.ts +1 -1
- package/lib/api/cancelCoinjoinAuthorization.d.ts +3 -1
- package/lib/api/cancelCoinjoinAuthorization.js +3 -0
- package/lib/api/cardano/api/cardanoGetAddress.d.ts +4 -2
- package/lib/api/cardano/api/cardanoGetAddress.js +4 -13
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.d.ts +1 -1
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +3 -13
- package/lib/api/cardano/api/cardanoGetPublicKey.d.ts +1 -1
- package/lib/api/cardano/api/cardanoGetPublicKey.js +4 -7
- package/lib/api/cardano/api/cardanoSignTransaction.d.ts +26 -4
- package/lib/api/cardano/api/cardanoSignTransaction.js +15 -46
- package/lib/api/cardano/cardanoAddressParameters.d.ts +1 -1
- package/lib/api/cardano/cardanoAddressParameters.js +3 -14
- package/lib/api/cardano/cardanoAuxiliaryData.d.ts +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.js +5 -20
- package/lib/api/cardano/cardanoCertificate.d.ts +1 -1
- package/lib/api/cardano/cardanoCertificate.js +20 -59
- package/lib/api/cardano/cardanoInputs.d.ts +20 -8
- package/lib/api/cardano/cardanoInputs.js +18 -14
- package/lib/api/cardano/cardanoOutputs.d.ts +31 -2
- package/lib/api/cardano/cardanoOutputs.js +14 -11
- package/lib/api/cardano/cardanoTokenBundle.d.ts +11 -6
- package/lib/api/cardano/cardanoTokenBundle.js +9 -21
- package/lib/api/changePin.d.ts +4 -2
- package/lib/api/changePin.js +3 -2
- package/lib/api/changeWipeCode.d.ts +3 -1
- package/lib/api/cipherKeyValue.d.ts +5 -1
- package/lib/api/cipherKeyValue.js +13 -21
- package/lib/api/common/paramsValidator.js +5 -4
- package/lib/api/eos/api/eosGetPublicKey.d.ts +11 -1
- package/lib/api/eos/api/eosGetPublicKey.js +3 -6
- package/lib/api/eos/api/eosSignTransaction.js +3 -5
- package/lib/api/eos/eosSignTx.d.ts +160 -2
- package/lib/api/ethereum/api/ethereumGetAddress.js +4 -10
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +21 -1
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +3 -5
- package/lib/api/ethereum/api/ethereumSignMessage.d.ts +6 -3
- package/lib/api/ethereum/api/ethereumSignMessage.js +3 -5
- package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +2 -2
- package/lib/api/ethereum/api/ethereumSignTransaction.js +3 -25
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +83 -3
- package/lib/api/ethereum/api/ethereumSignTypedData.js +20 -12
- package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +3 -1
- package/lib/api/ethereum/api/ethereumVerifyMessage.js +3 -6
- package/lib/api/ethereum/ethereumDefinitions.d.ts +37 -19
- package/lib/api/ethereum/ethereumDefinitions.js +21 -15
- package/lib/api/ethereum/ethereumSignTx.d.ts +1 -1
- package/lib/api/firmware/getBinary.js +5 -4
- package/lib/api/firmware/modifyFirmware.js +3 -2
- package/lib/api/firmware/uploadFirmware.d.ts +3 -1
- package/lib/api/firmware/verifyAuthenticityProof.js +3 -3
- package/lib/api/firmwareUpdate.js +10 -15
- package/lib/api/getAccountDescriptor.d.ts +2 -2
- package/lib/api/getAccountDescriptor.js +4 -7
- package/lib/api/getAccountInfo.d.ts +8 -8
- package/lib/api/getAddress.d.ts +8 -2
- package/lib/api/getAddress.js +10 -20
- package/lib/api/getCoinInfo.d.ts +117 -2
- package/lib/api/getCoinInfo.js +3 -2
- package/lib/api/getFeatures.d.ts +49 -1
- package/lib/api/getFirmwareHash.d.ts +3 -1
- package/lib/api/getFirmwareHash.js +3 -1
- package/lib/api/getOwnershipId.js +4 -7
- package/lib/api/getOwnershipProof.js +4 -11
- package/lib/api/getPublicKey.d.ts +21 -1
- package/lib/api/getPublicKey.js +4 -18
- package/lib/api/nem/api/nemGetAddress.d.ts +4 -2
- package/lib/api/nem/api/nemGetAddress.js +4 -11
- package/lib/api/nem/api/nemSignTransaction.d.ts +4 -1
- package/lib/api/nem/api/nemSignTransaction.js +7 -5
- package/lib/api/nem/nemSignTx.d.ts +75 -1
- package/lib/api/pushTransaction.js +3 -5
- package/lib/api/rebootToBootloader.d.ts +3 -1
- package/lib/api/recoveryDevice.d.ts +3 -1
- package/lib/api/recoveryDevice.js +3 -12
- package/lib/api/requestLogin.js +7 -9
- package/lib/api/resetDevice.d.ts +3 -1
- package/lib/api/resetDevice.js +3 -12
- package/lib/api/ripple/api/rippleGetAddress.d.ts +4 -2
- package/lib/api/ripple/api/rippleGetAddress.js +4 -10
- package/lib/api/ripple/api/rippleSignTransaction.js +3 -17
- package/lib/api/setBusy.d.ts +3 -1
- package/lib/api/setBusy.js +3 -1
- package/lib/api/showDeviceTutorial.d.ts +3 -1
- package/lib/api/signMessage.d.ts +4 -1
- package/lib/api/signMessage.js +3 -7
- package/lib/api/solana/additionalInfo.js +3 -14
- package/lib/api/solana/api/solanaGetAddress.d.ts +4 -2
- package/lib/api/solana/api/solanaGetAddress.js +4 -7
- package/lib/api/solana/api/solanaGetPublicKey.d.ts +13 -1
- package/lib/api/solana/api/solanaGetPublicKey.js +3 -5
- package/lib/api/solana/api/solanaSignTransaction.js +3 -4
- package/lib/api/stellar/api/stellarGetAddress.d.ts +4 -2
- package/lib/api/stellar/api/stellarGetAddress.js +4 -10
- package/lib/api/stellar/api/stellarSignTransaction.js +3 -5
- package/lib/api/stellar/stellarSignTx.d.ts +5 -3
- package/lib/api/stellar/stellarSignTx.js +3 -15
- package/lib/api/tezos/api/tezosGetAddress.d.ts +4 -2
- package/lib/api/tezos/api/tezosGetAddress.js +4 -10
- package/lib/api/tezos/api/tezosGetPublicKey.d.ts +9 -1
- package/lib/api/tezos/api/tezosGetPublicKey.js +3 -6
- package/lib/api/tezos/api/tezosSignTransaction.d.ts +5 -1
- package/lib/api/tezos/api/tezosSignTransaction.js +3 -5
- package/lib/api/tezos/tezosSignTx.d.ts +70 -2
- package/lib/api/tezos/tezosSignTx.js +3 -44
- package/lib/api/unlockPath.js +3 -4
- package/lib/api/verifyMessage.d.ts +3 -1
- package/lib/api/verifyMessage.js +3 -7
- package/lib/api/wipeDevice.d.ts +3 -1
- package/lib/constants/index.d.ts +1 -1
- package/lib/constants/index.js +1 -1
- package/lib/constants/nem.d.ts +7 -0
- package/lib/constants/nem.js +5 -1
- package/lib/core/AbstractMethod.d.ts +1 -1
- package/lib/core/AbstractMethod.js +4 -3
- package/lib/core/index.js +4 -4
- package/lib/data/coinInfo.d.ts +588 -12
- package/lib/data/coinInfo.js +6 -6
- package/lib/data/config.js +5 -0
- package/lib/data/deviceAuthenticityConfig.d.ts +19 -13
- package/lib/data/deviceAuthenticityConfig.js +23 -1
- package/lib/data/firmwareInfo.js +11 -10
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +2 -6
- package/lib/device/Device.js +8 -27
- package/lib/device/DeviceCommands.d.ts +36 -4
- package/lib/device/DeviceCommands.js +5 -2
- package/lib/device/DeviceList.js +1 -1
- package/lib/events/ui-promise.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/types/api/applySettings.d.ts +18 -2
- package/lib/types/api/applySettings.js +9 -0
- package/lib/types/api/authenticateDevice.d.ts +22 -5
- package/lib/types/api/authenticateDevice.js +7 -0
- package/lib/types/api/authorizeCoinjoin.d.ts +15 -13
- package/lib/types/api/authorizeCoinjoin.js +15 -0
- package/lib/types/api/binance/index.d.ts +203 -30
- package/lib/types/api/binance/index.js +48 -0
- package/lib/types/api/bitcoin/index.d.ts +18 -15
- package/lib/types/api/bitcoin/index.js +17 -0
- package/lib/types/api/cancelCoinjoinAuthorization.d.ts +5 -4
- package/lib/types/api/cancelCoinjoinAuthorization.js +5 -0
- package/lib/types/api/cardano/index.d.ts +685 -187
- package/lib/types/api/cardano/index.js +208 -0
- package/lib/types/api/cardanoSignTransaction.d.ts +5 -8
- package/lib/types/api/cipherKeyValue.d.ts +12 -11
- package/lib/types/api/cipherKeyValue.js +12 -0
- package/lib/types/api/eos/index.d.ts +783 -116
- package/lib/types/api/eos/index.js +177 -0
- package/lib/types/api/ethereum/index.d.ts +163 -57
- package/lib/types/api/ethereum/index.js +90 -0
- package/lib/types/api/firmwareUpdate.d.ts +11 -11
- package/lib/types/api/firmwareUpdate.js +15 -0
- package/lib/types/api/getAccountDescriptor.d.ts +10 -8
- package/lib/types/api/getAccountDescriptor.js +10 -0
- package/lib/types/api/getAddress.d.ts +42 -9
- package/lib/types/api/getAddress.js +14 -0
- package/lib/types/api/getOwnershipId.d.ts +33 -8
- package/lib/types/api/getOwnershipId.js +10 -0
- package/lib/types/api/getOwnershipProof.d.ts +37 -12
- package/lib/types/api/getOwnershipProof.js +14 -0
- package/lib/types/api/getPublicKey.d.ts +31 -21
- package/lib/types/api/getPublicKey.js +26 -0
- package/lib/types/api/nem/index.d.ts +841 -91
- package/lib/types/api/nem/index.js +130 -0
- package/lib/types/api/pushTransaction.d.ts +6 -4
- package/lib/types/api/pushTransaction.js +6 -0
- package/lib/types/api/recoveryDevice.d.ts +14 -4
- package/lib/types/api/recoveryDevice.js +9 -0
- package/lib/types/api/requestLogin.d.ts +38 -13
- package/lib/types/api/requestLogin.js +15 -0
- package/lib/types/api/resetDevice.d.ts +15 -13
- package/lib/types/api/resetDevice.js +9 -0
- package/lib/types/api/ripple/index.d.ts +40 -22
- package/lib/types/api/ripple/index.js +24 -0
- package/lib/types/api/solana/index.d.ts +42 -21
- package/lib/types/api/solana/index.js +26 -0
- package/lib/types/api/stellar/index.d.ts +890 -180
- package/lib/types/api/stellar/index.js +249 -0
- package/lib/types/api/tezos/index.d.ts +162 -59
- package/lib/types/api/tezos/index.js +61 -0
- package/lib/types/api/unlockPath.d.ts +7 -5
- package/lib/types/api/unlockPath.js +7 -0
- package/lib/types/coinInfo.d.ts +273 -56
- package/lib/types/coinInfo.js +81 -0
- package/lib/types/device.d.ts +1 -1
- package/lib/types/device.js +2 -2
- package/lib/types/fees.d.ts +29 -25
- package/lib/types/fees.js +36 -0
- package/lib/types/firmware.d.ts +1 -0
- package/lib/types/firmware.js +3 -0
- package/lib/types/params.d.ts +26 -17
- package/lib/types/params.js +23 -0
- package/lib/utils/deviceFeaturesUtils.js +5 -4
- package/lib/utils/firmwareUtils.js +5 -4
- package/lib/utils/hdnodeUtils.d.ts +191 -1
- package/lib/utils/pathUtils.d.ts +191 -1
- package/lib/utils/urlUtils.js +3 -3
- package/package.json +10 -9
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
-
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
4
|
const constants_1 = require("../constants");
|
|
6
5
|
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
7
6
|
const coinInfo_1 = require("../data/coinInfo");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
8
9
|
class BlockchainDisconnect extends AbstractMethod_1.AbstractMethod {
|
|
9
10
|
init() {
|
|
10
11
|
this.requiredPermissions = [];
|
|
11
12
|
this.useDevice = false;
|
|
12
13
|
this.useUi = false;
|
|
13
14
|
const { payload } = this;
|
|
14
|
-
(0,
|
|
15
|
+
(0, schema_utils_1.Assert)(types_1.CoinObj, payload);
|
|
15
16
|
const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
|
|
16
17
|
if (!coinInfo) {
|
|
17
18
|
throw constants_1.ERRORS.TypedError('Method_UnknownCoin');
|
|
@@ -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("
|
|
9
|
+
run(): Promise<import("@trezor/blockchain-link-types/lib/common").AccountBalanceHistory[]>;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=blockchainGetAccountBalanceHistory.d.ts.map
|
|
@@ -9,7 +9,7 @@ export default class BlockchainGetCurrentFiatRates extends AbstractMethod<'block
|
|
|
9
9
|
init(): void;
|
|
10
10
|
run(): Promise<{
|
|
11
11
|
ts: number;
|
|
12
|
-
rates: import("
|
|
12
|
+
rates: import("@trezor/blockchain-link-types/lib/common").FiatRates;
|
|
13
13
|
}>;
|
|
14
14
|
}
|
|
15
15
|
export {};
|
|
@@ -11,7 +11,7 @@ export default class BlockchainGetFiatRatesForTimestamps extends AbstractMethod<
|
|
|
11
11
|
run(): Promise<{
|
|
12
12
|
tickers: {
|
|
13
13
|
ts: number;
|
|
14
|
-
rates: import("
|
|
14
|
+
rates: import("@trezor/blockchain-link-types/lib/common").FiatRates;
|
|
15
15
|
}[];
|
|
16
16
|
}>;
|
|
17
17
|
}
|
|
@@ -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("
|
|
9
|
+
run(): Promise<import("@trezor/blockchain-link-types/lib/common").Transaction[]>;
|
|
10
10
|
}
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=blockchainGetTransactions.d.ts.map
|
|
@@ -3,6 +3,8 @@ import { PROTO } from '../constants';
|
|
|
3
3
|
export default class CancelCoinjoinAuthorization extends AbstractMethod<'cancelCoinjoinAuthorization', PROTO.CancelAuthorization> {
|
|
4
4
|
init(): void;
|
|
5
5
|
get info(): string;
|
|
6
|
-
run(): Promise<
|
|
6
|
+
run(): Promise<{
|
|
7
|
+
message: string;
|
|
8
|
+
}>;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=cancelCoinjoinAuthorization.d.ts.map
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
4
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
6
|
+
const cancelCoinjoinAuthorization_1 = require("../types/api/cancelCoinjoinAuthorization");
|
|
5
7
|
class CancelCoinjoinAuthorization extends AbstractMethod_1.AbstractMethod {
|
|
6
8
|
init() {
|
|
7
9
|
const { payload } = this;
|
|
10
|
+
(0, schema_utils_1.Assert)(cancelCoinjoinAuthorization_1.CancelCoinjoinAuthorization, payload);
|
|
8
11
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
|
|
9
12
|
this.preauthorized =
|
|
10
13
|
typeof payload.preauthorized === 'boolean' ? payload.preauthorized : true;
|
|
@@ -16,9 +16,11 @@ export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress
|
|
|
16
16
|
} | undefined;
|
|
17
17
|
confirmation(): Promise<boolean>;
|
|
18
18
|
noBackupConfirmation(): Promise<boolean>;
|
|
19
|
-
_call({ address_parameters, protocol_magic, network_id, derivation_type, show_display, chunkify, }: Params): Promise<
|
|
19
|
+
_call({ address_parameters, protocol_magic, network_id, derivation_type, show_display, chunkify, }: Params): Promise<{
|
|
20
|
+
address: string;
|
|
21
|
+
}>;
|
|
20
22
|
_ensureFirmwareSupportsBatch(batch: Params): void;
|
|
21
|
-
run(): Promise<import("
|
|
23
|
+
run(): Promise<import("../../../types").CardanoAddress | import("../../../types").CardanoAddress[]>;
|
|
22
24
|
}
|
|
23
25
|
export {};
|
|
24
26
|
//# sourceMappingURL=cardanoGetAddress.d.ts.map
|
|
@@ -7,6 +7,9 @@ const pathUtils_1 = require("../../../utils/pathUtils");
|
|
|
7
7
|
const cardanoAddressParameters_1 = require("../cardanoAddressParameters");
|
|
8
8
|
const constants_1 = require("../../../constants");
|
|
9
9
|
const events_1 = require("../../../events");
|
|
10
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
11
|
+
const types_1 = require("../../../types");
|
|
12
|
+
const cardano_1 = require("../../../types/api/cardano");
|
|
10
13
|
class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
11
14
|
constructor() {
|
|
12
15
|
super(...arguments);
|
|
@@ -19,20 +22,8 @@ class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
19
22
|
const payload = !this.payload.bundle
|
|
20
23
|
? { ...this.payload, bundle: [this.payload] }
|
|
21
24
|
: this.payload;
|
|
22
|
-
(0,
|
|
23
|
-
{ name: 'bundle', type: 'array' },
|
|
24
|
-
{ name: 'useEventListener', type: 'boolean' },
|
|
25
|
-
]);
|
|
25
|
+
(0, schema_utils_1.Assert)((0, types_1.Bundle)(cardano_1.CardanoGetAddress), payload);
|
|
26
26
|
this.params = payload.bundle.map(batch => {
|
|
27
|
-
(0, paramsValidator_1.validateParams)(batch, [
|
|
28
|
-
{ name: 'addressParameters', type: 'object', required: true },
|
|
29
|
-
{ name: 'networkId', type: 'number', required: true },
|
|
30
|
-
{ name: 'protocolMagic', type: 'number', required: true },
|
|
31
|
-
{ name: 'derivationType', type: 'number' },
|
|
32
|
-
{ name: 'address', type: 'string' },
|
|
33
|
-
{ name: 'showOnTrezor', type: 'boolean' },
|
|
34
|
-
{ name: 'chunkify', type: 'boolean' },
|
|
35
|
-
]);
|
|
36
27
|
(0, cardanoAddressParameters_1.validateAddressParameters)(batch.addressParameters);
|
|
37
28
|
return {
|
|
38
29
|
address_parameters: (0, cardanoAddressParameters_1.addressParametersToProto)(batch.addressParameters),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PROTO } from '../../../constants';
|
|
2
2
|
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
3
|
-
import
|
|
3
|
+
import { CardanoNativeScript } from '../../../types/api/cardano';
|
|
4
4
|
export default class CardanoGetNativeScriptHash extends AbstractMethod<'cardanoGetNativeScriptHash', PROTO.CardanoGetNativeScriptHash> {
|
|
5
5
|
init(): void;
|
|
6
6
|
get info(): string;
|
|
@@ -5,16 +5,14 @@ const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
|
5
5
|
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
7
|
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
|
+
const cardano_1 = require("../../../types/api/cardano");
|
|
9
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
8
10
|
class CardanoGetNativeScriptHash extends AbstractMethod_1.AbstractMethod {
|
|
9
11
|
init() {
|
|
10
12
|
this.requiredPermissions = ['read'];
|
|
11
13
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Cardano'), this.firmwareRange);
|
|
12
14
|
const { payload } = this;
|
|
13
|
-
(0,
|
|
14
|
-
{ name: 'script', type: 'object', required: true },
|
|
15
|
-
{ name: 'displayFormat', type: 'number', required: true },
|
|
16
|
-
{ name: 'derivationType', type: 'number' },
|
|
17
|
-
]);
|
|
15
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoGetNativeScriptHash, payload);
|
|
18
16
|
this.validateScript(payload.script);
|
|
19
17
|
this.params = {
|
|
20
18
|
script: this.scriptToProto(payload.script),
|
|
@@ -28,14 +26,6 @@ class CardanoGetNativeScriptHash extends AbstractMethod_1.AbstractMethod {
|
|
|
28
26
|
return 'Get Cardano native script hash';
|
|
29
27
|
}
|
|
30
28
|
validateScript(script) {
|
|
31
|
-
(0, paramsValidator_1.validateParams)(script, [
|
|
32
|
-
{ name: 'type', type: 'number', required: true },
|
|
33
|
-
{ name: 'scripts', type: 'array', allowEmpty: true },
|
|
34
|
-
{ name: 'keyHash', type: 'string' },
|
|
35
|
-
{ name: 'requiredSignaturesCount', type: 'number' },
|
|
36
|
-
{ name: 'invalidBefore', type: 'uint' },
|
|
37
|
-
{ name: 'invalidHereafter', type: 'uint' },
|
|
38
|
-
]);
|
|
39
29
|
if (script.keyPath) {
|
|
40
30
|
(0, pathUtils_1.validatePath)(script.keyPath, 3);
|
|
41
31
|
}
|
|
@@ -10,7 +10,7 @@ export default class CardanoGetPublicKey extends AbstractMethod<'cardanoGetPubli
|
|
|
10
10
|
get info(): string;
|
|
11
11
|
confirmation(): Promise<boolean>;
|
|
12
12
|
noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
|
|
13
|
-
run(): Promise<import("
|
|
13
|
+
run(): Promise<import("../../../types").CardanoPublicKey | import("../../../types").CardanoPublicKey[]>;
|
|
14
14
|
}
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=cardanoGetPublicKey.d.ts.map
|
|
@@ -6,6 +6,9 @@ const paramsValidator_1 = require("../../common/paramsValidator");
|
|
|
6
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
7
|
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
8
|
const events_1 = require("../../../events");
|
|
9
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
10
|
+
const types_1 = require("../../../types");
|
|
11
|
+
const cardano_1 = require("../../../types/api/cardano");
|
|
9
12
|
class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
10
13
|
init() {
|
|
11
14
|
this.requiredPermissions = ['read'];
|
|
@@ -14,14 +17,8 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
14
17
|
const payload = !this.payload.bundle
|
|
15
18
|
? { ...this.payload, bundle: [this.payload] }
|
|
16
19
|
: this.payload;
|
|
17
|
-
(0,
|
|
20
|
+
(0, schema_utils_1.Assert)((0, types_1.Bundle)(cardano_1.CardanoGetPublicKey), payload);
|
|
18
21
|
this.params = payload.bundle.map(batch => {
|
|
19
|
-
(0, paramsValidator_1.validateParams)(batch, [
|
|
20
|
-
{ name: 'path', required: true },
|
|
21
|
-
{ name: 'derivationType', type: 'number' },
|
|
22
|
-
{ name: 'showOnTrezor', type: 'boolean' },
|
|
23
|
-
{ name: 'suppressBackupWarning', type: 'boolean' },
|
|
24
|
-
]);
|
|
25
22
|
const path = (0, pathUtils_1.validatePath)(batch.path, 3);
|
|
26
23
|
return {
|
|
27
24
|
address_n: path,
|
|
@@ -3,7 +3,7 @@ import type { CertificateWithPoolOwnersAndRelays } from '../cardanoCertificate';
|
|
|
3
3
|
import { Path, InputWithPath, CollateralInputWithPath } from '../cardanoInputs';
|
|
4
4
|
import type { OutputWithData } from '../cardanoOutputs';
|
|
5
5
|
import { PROTO } from '../../../constants';
|
|
6
|
-
import
|
|
6
|
+
import { type CardanoSignedTxData } from '../../../types/api/cardano';
|
|
7
7
|
import type { AssetGroupWithTokens } from '../cardanoTokenBundle';
|
|
8
8
|
declare const CardanoSignTransactionFeatures: Readonly<{
|
|
9
9
|
TransactionStreaming: string[];
|
|
@@ -55,11 +55,33 @@ export default class CardanoSignTransaction extends AbstractMethod<'cardanoSignT
|
|
|
55
55
|
_ensureFeatureIsSupported(feature: keyof typeof CardanoSignTransactionFeatures): void;
|
|
56
56
|
_ensureFirmwareSupportsParams(): void;
|
|
57
57
|
_sign_tx(): Promise<CardanoSignedTxData>;
|
|
58
|
-
run(): Promise<
|
|
58
|
+
run(): Promise<{
|
|
59
|
+
auxiliaryDataSupplement?: {
|
|
60
|
+
cVoteRegistrationSignature?: string | undefined;
|
|
61
|
+
type: PROTO.CardanoTxAuxiliaryDataSupplementType;
|
|
62
|
+
auxiliaryDataHash: string;
|
|
63
|
+
} | undefined;
|
|
64
|
+
hash: string;
|
|
65
|
+
witnesses: {
|
|
66
|
+
chainCode?: string | undefined;
|
|
67
|
+
type: PROTO.CardanoTxWitnessType;
|
|
68
|
+
signature: string;
|
|
69
|
+
pubKey: string;
|
|
70
|
+
}[];
|
|
71
|
+
} | {
|
|
59
72
|
serializedTx: string;
|
|
73
|
+
auxiliaryDataSupplement?: {
|
|
74
|
+
cVoteRegistrationSignature?: string | undefined;
|
|
75
|
+
type: PROTO.CardanoTxAuxiliaryDataSupplementType;
|
|
76
|
+
auxiliaryDataHash: string;
|
|
77
|
+
} | undefined;
|
|
60
78
|
hash: string;
|
|
61
|
-
witnesses:
|
|
62
|
-
|
|
79
|
+
witnesses: {
|
|
80
|
+
chainCode?: string | undefined;
|
|
81
|
+
type: PROTO.CardanoTxWitnessType;
|
|
82
|
+
signature: string;
|
|
83
|
+
pubKey: string;
|
|
84
|
+
}[];
|
|
63
85
|
}>;
|
|
64
86
|
}
|
|
65
87
|
export {};
|
|
@@ -10,8 +10,10 @@ const cardanoCertificate_1 = require("../cardanoCertificate");
|
|
|
10
10
|
const cardanoInputs_1 = require("../cardanoInputs");
|
|
11
11
|
const cardanoOutputs_1 = require("../cardanoOutputs");
|
|
12
12
|
const constants_1 = require("../../../constants");
|
|
13
|
+
const cardano_1 = require("../../../types/api/cardano");
|
|
13
14
|
const cardanoWitnesses_1 = require("../cardanoWitnesses");
|
|
14
15
|
const cardanoTokenBundle_1 = require("../cardanoTokenBundle");
|
|
16
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
15
17
|
const CardanoSignTransactionFeatures = Object.freeze({
|
|
16
18
|
TransactionStreaming: ['0', '2.4.2'],
|
|
17
19
|
TokenMinting: ['0', '2.4.3'],
|
|
@@ -46,30 +48,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
46
48
|
payload.auxiliaryData.cVoteRegistrationParameters =
|
|
47
49
|
payload.auxiliaryData.governanceRegistrationParameters;
|
|
48
50
|
}
|
|
49
|
-
(0,
|
|
50
|
-
{ name: 'signingMode', type: 'number', required: true },
|
|
51
|
-
{ name: 'inputs', type: 'array', required: true },
|
|
52
|
-
{ name: 'outputs', type: 'array', required: true, allowEmpty: true },
|
|
53
|
-
{ name: 'fee', type: 'uint', required: true },
|
|
54
|
-
{ name: 'ttl', type: 'uint' },
|
|
55
|
-
{ name: 'certificates', type: 'array', allowEmpty: true },
|
|
56
|
-
{ name: 'withdrawals', type: 'array', allowEmpty: true },
|
|
57
|
-
{ name: 'mint', type: 'array', allowEmpty: true },
|
|
58
|
-
{ name: 'validityIntervalStart', type: 'uint' },
|
|
59
|
-
{ name: 'scriptDataHash', type: 'string' },
|
|
60
|
-
{ name: 'collateralInputs', type: 'array', allowEmpty: true },
|
|
61
|
-
{ name: 'requiredSigners', type: 'array', allowEmpty: true },
|
|
62
|
-
{ name: 'totalCollateral', type: 'uint' },
|
|
63
|
-
{ name: 'referenceInputs', type: 'array', allowEmpty: true },
|
|
64
|
-
{ name: 'protocolMagic', type: 'number', required: true },
|
|
65
|
-
{ name: 'networkId', type: 'number', required: true },
|
|
66
|
-
{ name: 'additionalWitnessRequests', type: 'array', allowEmpty: true },
|
|
67
|
-
{ name: 'derivationType', type: 'number' },
|
|
68
|
-
{ name: 'includeNetworkId', type: 'boolean' },
|
|
69
|
-
{ name: 'unsignedTx', type: 'object' },
|
|
70
|
-
{ name: 'testnet', type: 'boolean' },
|
|
71
|
-
{ name: 'chunkify', type: 'boolean' },
|
|
72
|
-
]);
|
|
51
|
+
(0, schema_utils_1.AssertWeak)(schema_utils_1.Type.Union([cardano_1.CardanoSignTransaction, cardano_1.CardanoSignTransactionExtended]), payload);
|
|
73
52
|
const inputsWithPath = payload.inputs.map(cardanoInputs_1.transformInput);
|
|
74
53
|
const outputsWithData = payload.outputs.map(cardanoOutputs_1.transformOutput);
|
|
75
54
|
let certificatesWithPoolOwnersAndRelays = [];
|
|
@@ -78,19 +57,12 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
78
57
|
}
|
|
79
58
|
let withdrawals = [];
|
|
80
59
|
if (payload.withdrawals) {
|
|
81
|
-
withdrawals = payload.withdrawals.map(withdrawal => {
|
|
82
|
-
(0,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
path: withdrawal.path ? (0, pathUtils_1.validatePath)(withdrawal.path, 5) : undefined,
|
|
89
|
-
amount: withdrawal.amount,
|
|
90
|
-
script_hash: withdrawal.scriptHash,
|
|
91
|
-
key_hash: withdrawal.keyHash,
|
|
92
|
-
};
|
|
93
|
-
});
|
|
60
|
+
withdrawals = payload.withdrawals.map(withdrawal => ({
|
|
61
|
+
path: withdrawal.path ? (0, pathUtils_1.validatePath)(withdrawal.path, 5) : undefined,
|
|
62
|
+
amount: withdrawal.amount,
|
|
63
|
+
script_hash: withdrawal.scriptHash,
|
|
64
|
+
key_hash: withdrawal.keyHash,
|
|
65
|
+
}));
|
|
94
66
|
}
|
|
95
67
|
let mint = [];
|
|
96
68
|
if (payload.mint) {
|
|
@@ -110,15 +82,12 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
110
82
|
}
|
|
111
83
|
let requiredSigners = [];
|
|
112
84
|
if (payload.requiredSigners) {
|
|
113
|
-
requiredSigners = payload.requiredSigners.map(requiredSigner => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
key_hash: requiredSigner.keyHash,
|
|
120
|
-
};
|
|
121
|
-
});
|
|
85
|
+
requiredSigners = payload.requiredSigners.map(requiredSigner => ({
|
|
86
|
+
key_path: requiredSigner.keyPath
|
|
87
|
+
? (0, pathUtils_1.validatePath)(requiredSigner.keyPath, 3)
|
|
88
|
+
: undefined,
|
|
89
|
+
key_hash: requiredSigner.keyHash,
|
|
90
|
+
}));
|
|
122
91
|
}
|
|
123
92
|
const collateralReturnWithData = payload.collateralReturn
|
|
124
93
|
? (0, cardanoOutputs_1.transformOutput)(payload.collateralReturn)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PROTO } from '../../constants';
|
|
2
2
|
import type { Device } from '../../device/Device';
|
|
3
|
-
import
|
|
3
|
+
import { CardanoAddressParameters } from '../../types/api/cardano';
|
|
4
4
|
export declare const validateAddressParameters: (addressParameters: CardanoAddressParameters) => void;
|
|
5
5
|
export declare const modifyAddressParametersForBackwardsCompatibility: (device: Device, address_parameters: PROTO.CardanoAddressParametersType) => PROTO.CardanoAddressParametersType;
|
|
6
6
|
export declare const addressParametersToProto: (addressParameters: CardanoAddressParameters) => PROTO.CardanoAddressParametersType;
|
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addressParametersFromProto = exports.addressParametersToProto = exports.modifyAddressParametersForBackwardsCompatibility = exports.validateAddressParameters = void 0;
|
|
4
|
-
const paramsValidator_1 = require("../common/paramsValidator");
|
|
5
4
|
const pathUtils_1 = require("../../utils/pathUtils");
|
|
6
5
|
const constants_1 = require("../../constants");
|
|
6
|
+
const cardano_1 = require("../../types/api/cardano");
|
|
7
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
7
8
|
const validateAddressParameters = (addressParameters) => {
|
|
8
|
-
(0,
|
|
9
|
-
{ name: 'addressType', type: 'number', required: true },
|
|
10
|
-
{ name: 'stakingKeyHash', type: 'string' },
|
|
11
|
-
{ name: 'paymentScriptHash', type: 'string' },
|
|
12
|
-
{ name: 'stakingScriptHash', type: 'string' },
|
|
13
|
-
]);
|
|
9
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoAddressParameters, addressParameters);
|
|
14
10
|
if (addressParameters.path) {
|
|
15
11
|
(0, pathUtils_1.validatePath)(addressParameters.path);
|
|
16
12
|
}
|
|
17
13
|
if (addressParameters.stakingPath) {
|
|
18
14
|
(0, pathUtils_1.validatePath)(addressParameters.stakingPath);
|
|
19
15
|
}
|
|
20
|
-
if (addressParameters.certificatePointer) {
|
|
21
|
-
(0, paramsValidator_1.validateParams)(addressParameters.certificatePointer, [
|
|
22
|
-
{ name: 'blockIndex', type: 'number', required: true },
|
|
23
|
-
{ name: 'txIndex', type: 'number', required: true },
|
|
24
|
-
{ name: 'certificateIndex', type: 'number', required: true },
|
|
25
|
-
]);
|
|
26
|
-
}
|
|
27
16
|
};
|
|
28
17
|
exports.validateAddressParameters = validateAddressParameters;
|
|
29
18
|
const modifyAddressParametersForBackwardsCompatibility = (device, address_parameters) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Device } from '../../device/Device';
|
|
2
2
|
import { PROTO } from '../../constants';
|
|
3
|
-
import
|
|
3
|
+
import { CardanoAuxiliaryData } from '../../types/api/cardano';
|
|
4
4
|
export declare const transformAuxiliaryData: (auxiliaryData: CardanoAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
|
|
5
5
|
export declare const modifyAuxiliaryDataForBackwardsCompatibility: (device: Device, auxiliary_data: PROTO.CardanoTxAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
|
|
6
6
|
//# sourceMappingURL=cardanoAuxiliaryData.d.ts.map
|
|
@@ -2,19 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.modifyAuxiliaryDataForBackwardsCompatibility = exports.transformAuxiliaryData = void 0;
|
|
4
4
|
const cardanoAddressParameters_1 = require("./cardanoAddressParameters");
|
|
5
|
-
const paramsValidator_1 = require("../common/paramsValidator");
|
|
6
5
|
const pathUtils_1 = require("../../utils/pathUtils");
|
|
7
6
|
const constants_1 = require("../../constants");
|
|
7
|
+
const cardano_1 = require("../../types/api/cardano");
|
|
8
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
8
9
|
const MAX_DELEGATION_COUNT = 32;
|
|
9
10
|
const transformDelegation = (delegation) => {
|
|
10
11
|
if (delegation.votingPublicKey) {
|
|
11
12
|
console.warn('Please use votePublicKey instead of votingPublicKey.');
|
|
12
13
|
delegation.votePublicKey = delegation.votingPublicKey;
|
|
13
14
|
}
|
|
14
|
-
(0,
|
|
15
|
-
{ name: 'votePublicKey', type: 'string', required: true },
|
|
16
|
-
{ name: 'weight', type: 'uint', required: true },
|
|
17
|
-
]);
|
|
15
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoCVoteRegistrationDelegation, delegation);
|
|
18
16
|
return {
|
|
19
17
|
vote_public_key: delegation.votePublicKey,
|
|
20
18
|
weight: delegation.weight,
|
|
@@ -30,15 +28,7 @@ const transformCvoteRegistrationParameters = (cVoteRegistrationParameters) => {
|
|
|
30
28
|
cVoteRegistrationParameters.paymentAddressParameters =
|
|
31
29
|
cVoteRegistrationParameters.rewardAddressParameters;
|
|
32
30
|
}
|
|
33
|
-
(0,
|
|
34
|
-
{ name: 'votePublicKey', type: 'string' },
|
|
35
|
-
{ name: 'stakingPath', required: true },
|
|
36
|
-
{ name: 'nonce', type: 'uint', required: true },
|
|
37
|
-
{ name: 'format', type: 'number' },
|
|
38
|
-
{ name: 'delegations', type: 'array', allowEmpty: true },
|
|
39
|
-
{ name: 'votingPurpose', type: 'uint' },
|
|
40
|
-
{ name: 'address', type: 'string' },
|
|
41
|
-
]);
|
|
31
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoCVoteRegistrationParameters, cVoteRegistrationParameters);
|
|
42
32
|
const { paymentAddressParameters } = cVoteRegistrationParameters;
|
|
43
33
|
if (paymentAddressParameters) {
|
|
44
34
|
(0, cardanoAddressParameters_1.validateAddressParameters)(paymentAddressParameters);
|
|
@@ -61,12 +51,7 @@ const transformCvoteRegistrationParameters = (cVoteRegistrationParameters) => {
|
|
|
61
51
|
};
|
|
62
52
|
};
|
|
63
53
|
const transformAuxiliaryData = (auxiliaryData) => {
|
|
64
|
-
(0,
|
|
65
|
-
{
|
|
66
|
-
name: 'hash',
|
|
67
|
-
type: 'string',
|
|
68
|
-
},
|
|
69
|
-
]);
|
|
54
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoAuxiliaryData, auxiliaryData);
|
|
70
55
|
let cVoteRegistrationParameters;
|
|
71
56
|
if (auxiliaryData.cVoteRegistrationParameters) {
|
|
72
57
|
cVoteRegistrationParameters = transformCvoteRegistrationParameters(auxiliaryData.cVoteRegistrationParameters);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PROTO } from '../../constants';
|
|
2
|
-
import
|
|
2
|
+
import { CardanoCertificate } from '../../types/api/cardano';
|
|
3
3
|
export type CertificateWithPoolOwnersAndRelays = {
|
|
4
4
|
certificate: PROTO.CardanoTxCertificate;
|
|
5
5
|
poolOwners: PROTO.CardanoPoolOwner[];
|
|
@@ -1,57 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformCertificate = void 0;
|
|
4
|
-
const paramsValidator_1 = require("../common/paramsValidator");
|
|
5
4
|
const pathUtils_1 = require("../../utils/pathUtils");
|
|
6
5
|
const constants_1 = require("../../constants");
|
|
6
|
+
const cardano_1 = require("../../types/api/cardano");
|
|
7
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
7
8
|
const ipv4AddressToHex = (ipv4Address) => Buffer.from(ipv4Address.split('.').map(ipPart => parseInt(ipPart, 10))).toString('hex');
|
|
8
9
|
const ipv6AddressToHex = (ipv6Address) => ipv6Address.split(':').join('');
|
|
9
|
-
const validatePoolMargin = (margin) => {
|
|
10
|
-
(0, paramsValidator_1.validateParams)(margin, [
|
|
11
|
-
{ name: 'numerator', type: 'string', required: true },
|
|
12
|
-
{ name: 'denominator', type: 'string', required: true },
|
|
13
|
-
]);
|
|
14
|
-
};
|
|
15
|
-
const validatePoolMetadata = (metadata) => {
|
|
16
|
-
(0, paramsValidator_1.validateParams)(metadata, [
|
|
17
|
-
{ name: 'url', type: 'string', required: true },
|
|
18
|
-
{ name: 'hash', type: 'string', required: true },
|
|
19
|
-
]);
|
|
20
|
-
};
|
|
21
10
|
const validatePoolRelay = (relay) => {
|
|
22
|
-
(0,
|
|
11
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoPoolRelay, relay);
|
|
23
12
|
if (relay.type === constants_1.PROTO.CardanoPoolRelayType.SINGLE_HOST_IP) {
|
|
24
|
-
const paramsToValidate = [
|
|
25
|
-
{ name: 'port', type: 'number', required: true },
|
|
26
|
-
];
|
|
27
|
-
if (relay.ipv4Address) {
|
|
28
|
-
paramsToValidate.push({ name: 'ipv4Address', type: 'string', required: false });
|
|
29
|
-
}
|
|
30
|
-
if (relay.ipv6Address) {
|
|
31
|
-
paramsToValidate.push({ name: 'ipv6Address', type: 'string', required: false });
|
|
32
|
-
}
|
|
33
|
-
(0, paramsValidator_1.validateParams)(relay, paramsToValidate);
|
|
34
13
|
if (!relay.ipv4Address && !relay.ipv6Address) {
|
|
35
14
|
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Either ipv4Address or ipv6Address must be supplied');
|
|
36
15
|
}
|
|
37
16
|
}
|
|
38
17
|
else if (relay.type === constants_1.PROTO.CardanoPoolRelayType.SINGLE_HOST_NAME) {
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
18
|
+
if (!relay.hostName) {
|
|
19
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'hostName must be supplied');
|
|
20
|
+
}
|
|
21
|
+
if (!relay.port) {
|
|
22
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'port must be supplied');
|
|
23
|
+
}
|
|
43
24
|
}
|
|
44
25
|
else if (relay.type === constants_1.PROTO.CardanoPoolRelayType.MULTIPLE_HOST_NAME) {
|
|
45
|
-
(
|
|
26
|
+
if (!relay.hostName) {
|
|
27
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'hostName must be supplied');
|
|
28
|
+
}
|
|
46
29
|
}
|
|
47
30
|
};
|
|
48
31
|
const validatePoolOwners = (owners) => {
|
|
49
32
|
owners.forEach(owner => {
|
|
50
|
-
if (owner.stakingKeyHash) {
|
|
51
|
-
(0, paramsValidator_1.validateParams)(owner, [
|
|
52
|
-
{ name: 'stakingKeyHash', type: 'string', required: !owner.stakingKeyPath },
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
33
|
if (owner.stakingKeyPath) {
|
|
56
34
|
(0, pathUtils_1.validatePath)(owner.stakingKeyPath, 5);
|
|
57
35
|
}
|
|
@@ -65,23 +43,9 @@ const validatePoolOwners = (owners) => {
|
|
|
65
43
|
}
|
|
66
44
|
};
|
|
67
45
|
const validatePoolParameters = (poolParameters) => {
|
|
68
|
-
(0,
|
|
69
|
-
{ name: 'poolId', type: 'string', required: true },
|
|
70
|
-
{ name: 'vrfKeyHash', type: 'string', required: true },
|
|
71
|
-
{ name: 'pledge', type: 'string', required: true },
|
|
72
|
-
{ name: 'cost', type: 'string', required: true },
|
|
73
|
-
{ name: 'margin', type: 'object', required: true },
|
|
74
|
-
{ name: 'rewardAccount', type: 'string', required: true },
|
|
75
|
-
{ name: 'owners', type: 'array', required: true },
|
|
76
|
-
{ name: 'relays', type: 'array', required: true, allowEmpty: true },
|
|
77
|
-
{ name: 'metadata', type: 'object' },
|
|
78
|
-
]);
|
|
79
|
-
validatePoolMargin(poolParameters.margin);
|
|
46
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoPoolParameters, poolParameters);
|
|
80
47
|
validatePoolOwners(poolParameters.owners);
|
|
81
48
|
poolParameters.relays.forEach(validatePoolRelay);
|
|
82
|
-
if (poolParameters.metadata) {
|
|
83
|
-
validatePoolMetadata(poolParameters.metadata);
|
|
84
|
-
}
|
|
85
49
|
};
|
|
86
50
|
const transformPoolParameters = (poolParameters) => {
|
|
87
51
|
if (!poolParameters) {
|
|
@@ -117,20 +81,17 @@ const transformPoolParameters = (poolParameters) => {
|
|
|
117
81
|
};
|
|
118
82
|
};
|
|
119
83
|
const transformCertificate = (certificate) => {
|
|
120
|
-
|
|
121
|
-
{ name: 'type', type: 'number', required: true },
|
|
122
|
-
];
|
|
123
|
-
if (certificate.type !== constants_1.PROTO.CardanoCertificateType.STAKE_POOL_REGISTRATION) {
|
|
124
|
-
paramsToValidate.push({ name: 'scriptHash', type: 'string' });
|
|
125
|
-
paramsToValidate.push({ name: 'keyHash', type: 'string' });
|
|
126
|
-
}
|
|
84
|
+
(0, schema_utils_1.Assert)(cardano_1.CardanoCertificate, certificate);
|
|
127
85
|
if (certificate.type === constants_1.PROTO.CardanoCertificateType.STAKE_DELEGATION) {
|
|
128
|
-
|
|
86
|
+
if (!certificate.pool) {
|
|
87
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'pool must be supplied for STAKE_DELEGATION');
|
|
88
|
+
}
|
|
129
89
|
}
|
|
130
90
|
if (certificate.type === constants_1.PROTO.CardanoCertificateType.STAKE_POOL_REGISTRATION) {
|
|
131
|
-
|
|
91
|
+
if (!certificate.poolParameters) {
|
|
92
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'poolParameters must be supplied for STAKE_POOL_REGISTRATION');
|
|
93
|
+
}
|
|
132
94
|
}
|
|
133
|
-
(0, paramsValidator_1.validateParams)(certificate, paramsToValidate);
|
|
134
95
|
const { poolParameters, poolOwners, poolRelays } = transformPoolParameters(certificate.poolParameters);
|
|
135
96
|
return {
|
|
136
97
|
certificate: {
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PROTO } from '../../constants';
|
|
2
|
+
import { Static } from '@trezor/schema-utils';
|
|
2
3
|
export type Path = number[];
|
|
3
|
-
export
|
|
4
|
-
input: PROTO.CardanoTxInput;
|
|
5
|
-
path?: Path;
|
|
6
|
-
};
|
|
4
|
+
export declare const Path: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>;
|
|
7
5
|
export type CollateralInputWithPath = {
|
|
8
6
|
collateralInput: PROTO.CardanoTxCollateralInput;
|
|
9
7
|
path?: Path;
|
|
10
8
|
};
|
|
11
|
-
export
|
|
12
|
-
export declare const
|
|
13
|
-
|
|
9
|
+
export type InputWithPath = Static<typeof InputWithPath>;
|
|
10
|
+
export declare const InputWithPath: import("@sinclair/typebox").TObject<{
|
|
11
|
+
input: import("@sinclair/typebox").TObject<{
|
|
12
|
+
prev_hash: import("@sinclair/typebox").TString;
|
|
13
|
+
prev_index: import("@sinclair/typebox").TNumber;
|
|
14
|
+
}>;
|
|
15
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>>;
|
|
16
|
+
}>;
|
|
17
|
+
export type InputWithPathParam = Static<typeof InputWithPath>;
|
|
18
|
+
export declare const InputWithPathParam: import("@sinclair/typebox").TObject<{
|
|
19
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>]>>;
|
|
20
|
+
prev_hash: import("@sinclair/typebox").TString;
|
|
21
|
+
prev_index: import("@sinclair/typebox").TNumber;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const transformInput: (input: unknown) => InputWithPath;
|
|
24
|
+
export declare const transformCollateralInput: (collateralInput: unknown) => CollateralInputWithPath;
|
|
25
|
+
export declare const transformReferenceInput: (referenceInput: unknown) => PROTO.CardanoTxReferenceInput;
|
|
14
26
|
//# sourceMappingURL=cardanoInputs.d.ts.map
|