@trezor/connect 9.4.7 → 9.4.8-beta.2
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 +59 -8
- package/README.md +1 -1
- package/lib/api/applyFlags.d.ts +1 -1
- package/lib/api/applyFlags.js +1 -1
- package/lib/api/applySettings.d.ts +1 -1
- package/lib/api/authenticateDevice.js +1 -1
- package/lib/api/authorizeCoinjoin.d.ts +1 -1
- package/lib/api/authorizeCoinjoin.js +1 -1
- package/lib/api/backupDevice.d.ts +1 -1
- package/lib/api/backupDevice.js +1 -1
- package/lib/api/binance/api/binanceGetAddress.d.ts +1 -1
- package/lib/api/binance/api/binanceGetAddress.js +3 -3
- package/lib/api/binance/api/binanceGetPublicKey.d.ts +1 -1
- package/lib/api/binance/api/binanceGetPublicKey.js +2 -2
- package/lib/api/binance/api/binanceSignTransaction.js +2 -2
- package/lib/api/binance/binanceSignTx.d.ts +1 -1
- package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
- package/lib/api/bitcoin/inputs.d.ts +1 -1
- package/lib/api/bitcoin/inputs.js +1 -1
- package/lib/api/bitcoin/outputs.js +2 -2
- package/lib/api/bitcoin/refTx.d.ts +2 -2
- package/lib/api/bitcoin/refTx.js +4 -4
- package/lib/api/bitcoin/signtx.d.ts +2 -2
- package/lib/api/bitcoin/signtxLegacy.d.ts +1 -1
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/blockchainDisconnect.js +2 -2
- package/lib/api/blockchainEstimateFee.d.ts +1 -1
- package/lib/api/blockchainEstimateFee.js +3 -2
- package/lib/api/blockchainEvmRpcCall.js +2 -2
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
- package/lib/api/blockchainGetAccountBalanceHistory.js +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.js +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.js +1 -1
- package/lib/api/blockchainGetInfo.js +1 -1
- package/lib/api/blockchainGetTransactions.js +1 -1
- package/lib/api/blockchainSetCustomBackend.js +1 -1
- package/lib/api/blockchainSubscribe.d.ts +1 -1
- package/lib/api/blockchainSubscribe.js +1 -1
- package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -1
- package/lib/api/blockchainSubscribeFiatRates.js +1 -1
- package/lib/api/blockchainUnsubscribe.d.ts +1 -1
- package/lib/api/blockchainUnsubscribe.js +1 -1
- package/lib/api/blockchainUnsubscribeFiatRates.js +1 -1
- package/lib/api/cancelCoinjoinAuthorization.d.ts +1 -1
- package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +1 -1
- package/lib/api/cardano/api/cardanoComposeTransaction.js +3 -11
- package/lib/api/cardano/api/cardanoGetAddress.d.ts +1 -1
- package/lib/api/cardano/api/cardanoGetAddress.js +4 -4
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +2 -2
- package/lib/api/cardano/api/cardanoGetPublicKey.js +2 -2
- package/lib/api/cardano/api/cardanoSignTransaction.d.ts +3 -3
- package/lib/api/cardano/api/cardanoSignTransaction.js +4 -4
- package/lib/api/cardano/cardanoAddressParameters.js +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.js +1 -1
- package/lib/api/cardano/cardanoCertificate.js +1 -1
- package/lib/api/cardano/cardanoInputs.js +1 -1
- package/lib/api/cardano/cardanoUtils.js +30 -0
- package/lib/api/changePin.d.ts +1 -1
- package/lib/api/changePin.js +1 -1
- package/lib/api/changeWipeCode.d.ts +1 -1
- package/lib/api/cipherKeyValue.d.ts +1 -1
- package/lib/api/cipherKeyValue.js +3 -3
- package/lib/api/common/Discovery.d.ts +2 -2
- package/lib/api/common/paramsValidator.js +1 -1
- package/lib/api/composeTransaction.d.ts +3 -3
- package/lib/api/composeTransaction.js +9 -9
- package/lib/api/eos/api/eosGetPublicKey.d.ts +1 -1
- package/lib/api/eos/api/eosGetPublicKey.js +2 -2
- package/lib/api/eos/api/eosSignTransaction.d.ts +1 -1
- package/lib/api/eos/api/eosSignTransaction.js +2 -2
- package/lib/api/eos/eosSignTx.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumGetAddress.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumGetAddress.js +6 -6
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +3 -3
- package/lib/api/ethereum/api/ethereumSignMessage.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumSignMessage.js +3 -3
- package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +2 -2
- package/lib/api/ethereum/api/ethereumSignTransaction.js +4 -4
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -1
- package/lib/api/ethereum/api/ethereumSignTypedData.js +6 -6
- package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumVerifyMessage.js +2 -2
- package/lib/api/ethereum/ethereumDefinitions.d.ts +2 -2
- package/lib/api/ethereum/ethereumDefinitions.js +1 -0
- package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +2 -2
- package/lib/api/firmware/parseFirmwareHeaders.d.ts +2 -1
- package/lib/api/firmware/uploadFirmware.d.ts +1 -1
- package/lib/api/firmware/uploadFirmware.js +1 -1
- package/lib/api/firmware/verifyAuthenticityProof.d.ts +1 -1
- package/lib/api/firmware/verifyEntropy.d.ts +19 -0
- package/lib/api/firmware/verifyEntropy.js +112 -0
- package/lib/api/getAccountDescriptor.js +4 -4
- package/lib/api/getAccountInfo.d.ts +21 -1
- package/lib/api/getAccountInfo.js +7 -7
- package/lib/api/getAddress.d.ts +1 -1
- package/lib/api/getAddress.js +3 -3
- package/lib/api/getCoinInfo.d.ts +3 -0
- package/lib/api/getCoinInfo.js +1 -1
- package/lib/api/getDeviceState.js +1 -1
- package/lib/api/getFirmwareHash.d.ts +1 -1
- package/lib/api/getFirmwareHash.js +1 -1
- package/lib/api/getOwnershipId.d.ts +1 -1
- package/lib/api/getOwnershipId.js +2 -2
- package/lib/api/getOwnershipProof.d.ts +1 -1
- package/lib/api/getOwnershipProof.js +2 -2
- package/lib/api/getPublicKey.d.ts +1 -1
- package/lib/api/getPublicKey.js +4 -4
- package/lib/api/loadDevice.d.ts +1 -1
- package/lib/api/loadDevice.js +1 -1
- package/lib/api/nem/api/nemGetAddress.d.ts +1 -1
- package/lib/api/nem/api/nemGetAddress.js +3 -3
- package/lib/api/nem/api/nemSignTransaction.d.ts +1 -1
- package/lib/api/nem/api/nemSignTransaction.js +2 -2
- package/lib/api/pushTransaction.js +2 -2
- package/lib/api/recoveryDevice.d.ts +1 -1
- package/lib/api/requestLogin.d.ts +1 -1
- package/lib/api/requestLogin.js +2 -2
- package/lib/api/resetDevice.d.ts +3 -1
- package/lib/api/resetDevice.js +58 -3
- package/lib/api/ripple/api/rippleGetAddress.d.ts +1 -1
- package/lib/api/ripple/api/rippleGetAddress.js +3 -3
- package/lib/api/ripple/api/rippleSignTransaction.d.ts +1 -1
- package/lib/api/ripple/api/rippleSignTransaction.js +2 -2
- package/lib/api/setBrightness.d.ts +1 -1
- package/lib/api/setBrightness.js +1 -1
- package/lib/api/setBusy.d.ts +1 -1
- package/lib/api/setBusy.js +1 -1
- package/lib/api/setProxy.js +1 -1
- package/lib/api/showDeviceTutorial.d.ts +1 -1
- package/lib/api/showDeviceTutorial.js +1 -1
- package/lib/api/signMessage.d.ts +1 -1
- package/lib/api/signMessage.js +2 -2
- package/lib/api/signTransaction.d.ts +2 -2
- package/lib/api/signTransaction.js +3 -3
- package/lib/api/solana/api/index.d.ts +1 -0
- package/lib/api/solana/api/index.js +3 -1
- package/lib/api/solana/api/solanaComposeTransaction.d.ts +25 -0
- package/lib/api/solana/api/solanaComposeTransaction.js +61 -0
- package/lib/api/solana/api/solanaGetAddress.js +2 -2
- package/lib/api/solana/api/solanaGetPublicKey.js +2 -2
- package/lib/api/solana/api/solanaSignTransaction.d.ts +9 -1
- package/lib/api/solana/api/solanaSignTransaction.js +20 -2
- package/lib/api/solana/solanaUtils.d.ts +48 -0
- package/lib/api/solana/solanaUtils.js +213 -0
- package/lib/api/stellar/api/stellarGetAddress.d.ts +1 -1
- package/lib/api/stellar/api/stellarGetAddress.js +3 -3
- package/lib/api/stellar/api/stellarSignTransaction.js +3 -3
- package/lib/api/tezos/api/tezosGetAddress.d.ts +1 -1
- package/lib/api/tezos/api/tezosGetAddress.js +3 -3
- package/lib/api/tezos/api/tezosGetPublicKey.d.ts +1 -1
- package/lib/api/tezos/api/tezosGetPublicKey.js +2 -2
- package/lib/api/tezos/api/tezosSignTransaction.d.ts +1 -1
- package/lib/api/tezos/api/tezosSignTransaction.js +2 -2
- package/lib/api/tezos/tezosSignTx.d.ts +17 -17
- package/lib/api/unlockPath.d.ts +1 -1
- package/lib/api/verifyMessage.d.ts +1 -1
- package/lib/api/verifyMessage.js +3 -3
- package/lib/backend/BackendManager.d.ts +1 -1
- package/lib/backend/BackendManager.js +1 -1
- package/lib/backend/Blockchain.d.ts +2 -2
- package/lib/backend/Blockchain.js +4 -7
- package/lib/constants/errors.d.ts +2 -0
- package/lib/constants/errors.js +4 -0
- package/lib/core/AbstractMethod.d.ts +2 -2
- package/lib/core/AbstractMethod.js +2 -1
- package/lib/core/index.d.ts +3 -3
- package/lib/core/index.js +44 -48
- package/lib/core/onCallFirmwareUpdate.d.ts +3 -8
- package/lib/core/onCallFirmwareUpdate.js +63 -21
- package/lib/data/DataManager.js +1 -5
- package/lib/data/coinInfo.d.ts +15 -131
- package/lib/data/coinInfo.js +8 -8
- package/lib/data/config.d.ts +23 -0
- package/lib/data/config.js +4 -0
- package/lib/data/connectSettings.js +1 -1
- package/lib/data/defaultFeeLevels.d.ts +2 -2
- package/lib/data/defaultFeeLevels.js +34 -14
- package/lib/data/deviceAuthenticityConfigTypes.d.ts +1 -0
- package/lib/data/deviceAuthenticityConfigTypes.js +2 -2
- package/lib/data/firmwareInfo.js +1 -1
- package/lib/data/models.js +5 -1
- package/lib/data/transportInfo.d.ts +0 -1
- package/lib/data/transportInfo.js +41 -28
- package/lib/data/udevInfo.d.ts +0 -1
- package/lib/data/udevInfo.js +2 -5
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +11 -10
- package/lib/device/Device.js +47 -17
- package/lib/device/DeviceCommands.d.ts +2 -2
- package/lib/device/DeviceCommands.js +42 -27
- package/lib/device/DeviceList.d.ts +27 -22
- package/lib/device/DeviceList.js +222 -133
- package/lib/device/StateStorage.js +11 -13
- package/lib/device/prompts.js +28 -36
- package/lib/device/resolveDescriptorForTaproot.d.ts +2 -2
- package/lib/device/resolveDescriptorForTaproot.js +5 -13
- package/lib/events/blockchain.d.ts +1 -1
- package/lib/events/call.d.ts +1 -1
- package/lib/events/core.d.ts +3 -3
- package/lib/events/device.d.ts +11 -1
- package/lib/events/device.js +1 -0
- package/lib/events/popup.d.ts +2 -2
- package/lib/events/transport.d.ts +15 -9
- package/lib/events/transport.js +10 -1
- package/lib/events/ui-promise.d.ts +1 -1
- package/lib/events/ui-request.d.ts +3 -3
- package/lib/factory.d.ts +3 -2
- package/lib/factory.js +3 -1
- package/lib/impl/core-in-module.d.ts +4 -2
- package/lib/impl/core-in-module.js +9 -1
- package/lib/impl/dynamic.d.ts +4 -2
- package/lib/impl/dynamic.js +5 -4
- package/lib/index-browser.js +1 -0
- package/lib/index.js +11 -3
- package/lib/types/account.d.ts +1 -1
- package/lib/types/api/authenticateDevice.d.ts +1 -0
- package/lib/types/api/authorizeCoinjoin.d.ts +1 -1
- package/lib/types/api/authorizeCoinjoin.js +1 -1
- package/lib/types/api/binanceGetAddress.d.ts +1 -1
- package/lib/types/api/binanceGetPublicKey.d.ts +1 -1
- package/lib/types/api/blockchainEstimateFee.d.ts +1 -1
- package/lib/types/api/blockchainSetCustomBackend.d.ts +1 -1
- package/lib/types/api/blockchainSubscribe.d.ts +1 -1
- package/lib/types/api/cardanoComposeTransaction.d.ts +112 -6
- package/lib/types/api/cardanoComposeTransaction.js +77 -0
- package/lib/types/api/cardanoGetAddress.d.ts +1 -1
- package/lib/types/api/cardanoGetPublicKey.d.ts +1 -1
- package/lib/types/api/changeLanguage.d.ts +1 -1
- package/lib/types/api/cipherKeyValue.d.ts +1 -1
- package/lib/types/api/composeTransaction.d.ts +1 -1
- package/lib/types/api/eosGetPublicKey.d.ts +1 -1
- package/lib/types/api/ethereumGetAddress.d.ts +1 -1
- package/lib/types/api/ethereumGetPublicKey.d.ts +1 -1
- package/lib/types/api/ethereumSignTypedData.d.ts +1 -1
- package/lib/types/api/firmwareUpdate.d.ts +11 -2
- package/lib/types/api/getAccountDescriptor.d.ts +1 -1
- package/lib/types/api/getAccountInfo.d.ts +1 -1
- package/lib/types/api/getAddress.d.ts +2 -1
- package/lib/types/api/getCoinInfo.d.ts +1 -1
- package/lib/types/api/getDeviceState.d.ts +1 -1
- package/lib/types/api/getFeatures.d.ts +1 -1
- package/lib/types/api/getOwnershipId.d.ts +2 -1
- package/lib/types/api/getOwnershipProof.d.ts +2 -1
- package/lib/types/api/getPublicKey.d.ts +1 -1
- package/lib/types/api/index.d.ts +7 -3
- package/lib/types/api/nem/index.d.ts +1 -1
- package/lib/types/api/nemGetAddress.d.ts +1 -1
- package/lib/types/api/on.d.ts +1 -1
- package/lib/types/api/recoveryDevice.d.ts +1 -1
- package/lib/types/api/rippleGetAddress.d.ts +1 -1
- package/lib/types/api/setTransports.d.ts +4 -0
- package/lib/types/api/setTransports.js +3 -0
- package/lib/types/api/solana/index.d.ts +41 -0
- package/lib/types/api/solana/index.js +31 -1
- package/lib/types/api/solanaComposeTransaction.d.ts +4 -0
- package/lib/types/api/solanaComposeTransaction.js +3 -0
- package/lib/types/api/solanaGetAddress.d.ts +1 -1
- package/lib/types/api/solanaGetPublicKey.d.ts +1 -1
- package/lib/types/api/stellarGetAddress.d.ts +1 -1
- package/lib/types/api/tezosGetAddress.d.ts +1 -1
- package/lib/types/api/tezosGetPublicKey.d.ts +1 -1
- package/lib/types/api/unlockPath.d.ts +1 -1
- package/lib/types/coinInfo.d.ts +33 -0
- package/lib/types/coinInfo.js +8 -2
- package/lib/types/params.d.ts +1 -1
- package/lib/utils/abortablePromise.d.ts +5 -0
- package/lib/utils/abortablePromise.js +17 -0
- package/lib/utils/accountUtils.d.ts +1 -1
- package/lib/utils/accountUtils.js +1 -1
- package/lib/utils/assetUtils.js +1 -2
- package/lib/utils/assets-browser.d.ts +1 -1
- package/lib/utils/assets.js +1 -1
- package/lib/utils/assets.native.d.ts +1 -1
- package/lib/utils/deviceFeaturesUtils.d.ts +1 -1
- package/lib/utils/deviceFeaturesUtils.js +6 -12
- package/lib/utils/ethereumUtils.d.ts +3 -2
- package/lib/utils/firmwareUtils.d.ts +1 -1
- package/lib/utils/firmwareUtils.js +11 -4
- package/lib/utils/pathUtils.d.ts +1 -1
- package/lib/utils/urlUtils.js +2 -0
- package/lib/workers/workers-browser.d.ts +2 -2
- package/lib/workers/workers-browser.js +2 -2
- package/lib/workers/workers.native.d.ts +1 -1
- package/lib/workers/workers.native.js +2 -2
- package/package.json +22 -12
- package/lib/utils/promiseUtils.d.ts +0 -5
- package/lib/utils/promiseUtils.js +0 -14
package/lib/api/resetDevice.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
|
+
const utils_1 = require("@trezor/utils");
|
|
5
|
+
const verifyEntropy_1 = require("../api/firmware/verifyEntropy");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
4
7
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
8
|
+
const prompts_1 = require("../device/prompts");
|
|
5
9
|
const events_1 = require("../events");
|
|
6
10
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
7
|
-
const
|
|
11
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
8
12
|
class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
9
13
|
init() {
|
|
10
14
|
this.allowDeviceMode = [events_1.UI.INITIALIZE, events_1.UI.SEEDLESS];
|
|
@@ -23,6 +27,7 @@ class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
|
23
27
|
skip_backup: payload.skip_backup,
|
|
24
28
|
no_backup: payload.no_backup,
|
|
25
29
|
backup_type: payload.backup_type,
|
|
30
|
+
entropy_check: typeof payload.entropy_check === 'boolean' ? payload.entropy_check : true,
|
|
26
31
|
};
|
|
27
32
|
}
|
|
28
33
|
get info() {
|
|
@@ -34,10 +39,60 @@ class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
|
34
39
|
label: 'Do you really you want to create a new wallet?',
|
|
35
40
|
};
|
|
36
41
|
}
|
|
42
|
+
async getEntropyData(type) {
|
|
43
|
+
const cmd = this.device.getCommands();
|
|
44
|
+
const entropy = (0, verifyEntropy_1.generateEntropy)(32).toString('hex');
|
|
45
|
+
const params = type === 'ResetDevice' ? this.params : {};
|
|
46
|
+
const entropyRequest = await cmd.typedCall(type, 'EntropyRequest', params);
|
|
47
|
+
await cmd.typedCall('EntropyAck', ['EntropyCheckReady', 'Success'], { entropy });
|
|
48
|
+
return {
|
|
49
|
+
...entropyRequest.message,
|
|
50
|
+
host_entropy: entropy,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async entropyCheck(prevData) {
|
|
54
|
+
const cmd = this.device.getCommands();
|
|
55
|
+
const paths = ["m/84'/0'/0'", "m/44'/60'/0'"];
|
|
56
|
+
const xpubs = {};
|
|
57
|
+
for (let i = 0; i < paths.length; i++) {
|
|
58
|
+
const p = paths[i];
|
|
59
|
+
const pubKey = await cmd.getPublicKey({ address_n: (0, pathUtils_1.validatePath)(p) });
|
|
60
|
+
xpubs[p] = pubKey.xpub;
|
|
61
|
+
}
|
|
62
|
+
const currentData = await this.getEntropyData('EntropyCheckContinue');
|
|
63
|
+
const res = await (0, verifyEntropy_1.verifyEntropy)({
|
|
64
|
+
type: this.params.backup_type,
|
|
65
|
+
strength: this.params.strength,
|
|
66
|
+
commitment: prevData.entropy_commitment,
|
|
67
|
+
hostEntropy: prevData.host_entropy,
|
|
68
|
+
trezorEntropy: currentData.prev_entropy,
|
|
69
|
+
xpubs,
|
|
70
|
+
});
|
|
71
|
+
if (res.error) {
|
|
72
|
+
await (0, prompts_1.cancelPrompt)(this.device);
|
|
73
|
+
throw new Error(res.error);
|
|
74
|
+
}
|
|
75
|
+
return currentData;
|
|
76
|
+
}
|
|
37
77
|
async run() {
|
|
38
78
|
const cmd = this.device.getCommands();
|
|
39
|
-
|
|
40
|
-
|
|
79
|
+
if (this.params.entropy_check && this.device.unavailableCapabilities['entropyCheck']) {
|
|
80
|
+
this.params.entropy_check = false;
|
|
81
|
+
}
|
|
82
|
+
let entropyData = await this.getEntropyData('ResetDevice');
|
|
83
|
+
if (this.params.entropy_check) {
|
|
84
|
+
const tries = (0, utils_1.getRandomInt)(1, 5);
|
|
85
|
+
for (let i = 0; i < tries; i++) {
|
|
86
|
+
try {
|
|
87
|
+
entropyData = await this.entropyCheck(entropyData);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw constants_1.ERRORS.TypedError('Failure_EntropyCheck', error.message);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
await cmd.typedCall('EntropyCheckContinue', 'Success', { finish: true });
|
|
94
|
+
}
|
|
95
|
+
return { message: 'Success' };
|
|
41
96
|
}
|
|
42
97
|
}
|
|
43
98
|
exports.default = ResetDevice;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
|
+
const constants_1 = require("../../../constants");
|
|
4
5
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
5
|
-
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
|
-
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
|
-
const constants_1 = require("../../../constants");
|
|
9
7
|
const events_1 = require("../../../events");
|
|
10
8
|
const types_1 = require("../../../types");
|
|
11
9
|
const getAddress_1 = require("../../../types/api/getAddress");
|
|
10
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
11
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
12
12
|
class RippleGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
1
|
import type { PROTO } from '../../../constants';
|
|
2
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
3
3
|
export default class RippleSignTransaction extends AbstractMethod<'rippleSignTransaction', PROTO.RippleSignTx> {
|
|
4
4
|
init(): void;
|
|
5
5
|
get info(): string;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
4
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
5
|
-
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
5
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
|
-
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
6
|
const ripple_1 = require("../../../types/api/ripple");
|
|
7
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
9
9
|
class RippleSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
10
10
|
init() {
|
|
11
11
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
1
|
import { PROTO } from '../constants';
|
|
2
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
3
|
export default class SetBrightness extends AbstractMethod<'setBrightness', PROTO.SetBrightness> {
|
|
4
4
|
init(): void;
|
|
5
5
|
run(): Promise<{
|
package/lib/api/setBrightness.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
|
-
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
5
4
|
const constants_1 = require("../constants");
|
|
5
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
6
6
|
class SetBrightness extends AbstractMethod_1.AbstractMethod {
|
|
7
7
|
init() {
|
|
8
8
|
this.requiredPermissions = ['management'];
|
package/lib/api/setBusy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
1
|
import { PROTO } from '../constants';
|
|
2
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
3
|
export default class SetBusy extends AbstractMethod<'setBusy', PROTO.SetBusy> {
|
|
4
4
|
init(): void;
|
|
5
5
|
run(): Promise<{
|
package/lib/api/setBusy.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
|
+
const constants_1 = require("../constants");
|
|
4
5
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
5
6
|
const events_1 = require("../events");
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
7
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
8
8
|
class SetBusy extends AbstractMethod_1.AbstractMethod {
|
|
9
9
|
init() {
|
package/lib/api/setProxy.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
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 DataManager_1 = require("../data/DataManager");
|
|
6
5
|
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
6
|
+
const DataManager_1 = require("../data/DataManager");
|
|
7
7
|
class SetProxy extends AbstractMethod_1.AbstractMethod {
|
|
8
8
|
init() {
|
|
9
9
|
this.requiredPermissions = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
1
|
import { PROTO } from '../constants';
|
|
2
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
3
|
export default class ShowDeviceTutorial extends AbstractMethod<'showDeviceTutorial', PROTO.ShowDeviceTutorial> {
|
|
4
4
|
init(): void;
|
|
5
5
|
get info(): string;
|
|
@@ -1,8 +1,8 @@
|
|
|
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 events_1 = require("../events");
|
|
5
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
6
|
class ShowDeviceTutorial extends AbstractMethod_1.AbstractMethod {
|
|
7
7
|
init() {
|
|
8
8
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
|
package/lib/api/signMessage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
1
|
import type { PROTO } from '../constants';
|
|
2
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
3
|
export default class SignMessage extends AbstractMethod<'signMessage', PROTO.SignMessage> {
|
|
4
4
|
init(): void;
|
|
5
5
|
get info(): string;
|
package/lib/api/signMessage.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
4
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
5
|
+
const types_1 = require("../types");
|
|
5
6
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
|
-
const pathUtils_1 = require("../utils/pathUtils");
|
|
7
7
|
const coinInfo_1 = require("../data/coinInfo");
|
|
8
8
|
const formatUtils_1 = require("../utils/formatUtils");
|
|
9
|
-
const
|
|
9
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
10
10
|
class SignMessage extends AbstractMethod_1.AbstractMethod {
|
|
11
11
|
init() {
|
|
12
12
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
1
|
import { PROTO } from '../constants';
|
|
3
|
-
import
|
|
2
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
|
+
import type { AccountAddresses, BitcoinNetworkInfo } from '../types';
|
|
4
4
|
import type { RefTransaction, TransactionOptions } from '../types/api/bitcoin';
|
|
5
5
|
type Params = {
|
|
6
6
|
inputs: PROTO.TxInputType[];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const bitcoin_1 = require("./bitcoin");
|
|
6
|
+
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
4
7
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
5
8
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
9
|
const coinInfo_1 = require("../data/coinInfo");
|
|
7
10
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
8
|
-
const constants_1 = require("../constants");
|
|
9
|
-
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
10
|
-
const bitcoin_1 = require("./bitcoin");
|
|
11
11
|
class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
12
12
|
init() {
|
|
13
13
|
var _a, _b, _c;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default as solanaComposeTransaction } from './solanaComposeTransaction';
|
|
1
2
|
export { default as solanaGetAddress } from './solanaGetAddress';
|
|
2
3
|
export { default as solanaGetPublicKey } from './solanaGetPublicKey';
|
|
3
4
|
export { default as solanaSignTransaction } from './solanaSignTransaction';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.solanaSignTransaction = exports.solanaGetPublicKey = exports.solanaGetAddress = void 0;
|
|
3
|
+
exports.solanaSignTransaction = exports.solanaGetPublicKey = exports.solanaGetAddress = exports.solanaComposeTransaction = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
var solanaComposeTransaction_1 = require("./solanaComposeTransaction");
|
|
6
|
+
Object.defineProperty(exports, "solanaComposeTransaction", { enumerable: true, get: function () { return tslib_1.__importDefault(solanaComposeTransaction_1).default; } });
|
|
5
7
|
var solanaGetAddress_1 = require("./solanaGetAddress");
|
|
6
8
|
Object.defineProperty(exports, "solanaGetAddress", { enumerable: true, get: function () { return tslib_1.__importDefault(solanaGetAddress_1).default; } });
|
|
7
9
|
var solanaGetPublicKey_1 = require("./solanaGetPublicKey");
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
+
import { CoinInfo } from '../../../types';
|
|
3
|
+
import { SolanaComposeTransaction as SolanaComposeTransactionSchema } from '../../../types/api/solana';
|
|
4
|
+
type SolanaComposeTransactionParams = SolanaComposeTransactionSchema & {
|
|
5
|
+
coinInfo: CoinInfo;
|
|
6
|
+
};
|
|
7
|
+
export default class SolanaComposeTransaction extends AbstractMethod<'solanaComposeTransaction', SolanaComposeTransactionParams> {
|
|
8
|
+
init(): void;
|
|
9
|
+
get info(): string;
|
|
10
|
+
run(): Promise<{
|
|
11
|
+
serializedTx: string;
|
|
12
|
+
additionalInfo: {
|
|
13
|
+
isCreatingAccount: boolean;
|
|
14
|
+
newTokenAccountProgramName: "spl-token" | "spl-token-2022" | undefined;
|
|
15
|
+
tokenAccountInfo: {
|
|
16
|
+
baseAddress: string;
|
|
17
|
+
tokenProgram: string;
|
|
18
|
+
tokenMint: string;
|
|
19
|
+
tokenAccount: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=solanaComposeTransaction.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const solana_1 = require("@trezor/blockchain-link-utils/lib/solana");
|
|
4
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
5
|
+
const BlockchainLink_1 = require("../../../backend/BlockchainLink");
|
|
6
|
+
const constants_1 = require("../../../constants");
|
|
7
|
+
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
8
|
+
const coinInfo_1 = require("../../../data/coinInfo");
|
|
9
|
+
const solana_2 = require("../../../types/api/solana");
|
|
10
|
+
const solanaUtils_1 = require("../solanaUtils");
|
|
11
|
+
class SolanaComposeTransaction extends AbstractMethod_1.AbstractMethod {
|
|
12
|
+
init() {
|
|
13
|
+
this.useDevice = false;
|
|
14
|
+
this.useUi = false;
|
|
15
|
+
const { payload } = this;
|
|
16
|
+
(0, schema_utils_1.Assert)(solana_2.SolanaComposeTransaction, payload);
|
|
17
|
+
const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin || 'sol');
|
|
18
|
+
if (!coinInfo) {
|
|
19
|
+
throw constants_1.ERRORS.TypedError('Method_UnknownCoin');
|
|
20
|
+
}
|
|
21
|
+
(0, BlockchainLink_1.isBackendSupported)(coinInfo);
|
|
22
|
+
this.params = {
|
|
23
|
+
coinInfo,
|
|
24
|
+
...payload,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
get info() {
|
|
28
|
+
return 'Compose Solana transaction';
|
|
29
|
+
}
|
|
30
|
+
async run() {
|
|
31
|
+
var _a;
|
|
32
|
+
const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity);
|
|
33
|
+
const [recipientAccountOwner, recipientTokenAccounts] = this.params.token
|
|
34
|
+
? await (0, solanaUtils_1.fetchAccountOwnerAndTokenInfoForAddress)(backend, this.params.toAddress, this.params.token.mint, this.params.token.program)
|
|
35
|
+
: [undefined, undefined];
|
|
36
|
+
const tokenTransferTxAndDestinationAddress = this.params.token && this.params.token.accounts
|
|
37
|
+
? await (0, solanaUtils_1.buildTokenTransferTransaction)(this.params.fromAddress, this.params.toAddress, recipientAccountOwner || solana_1.SYSTEM_PROGRAM_PUBLIC_KEY, this.params.token.mint, this.params.amount || '0', this.params.token.decimals, this.params.token.accounts, recipientTokenAccounts, this.params.blockHash, this.params.lastValidBlockHeight, this.params.priorityFees || solanaUtils_1.dummyPriorityFeesForFeeEstimation, this.params.token.program)
|
|
38
|
+
: undefined;
|
|
39
|
+
if (this.params.token && !tokenTransferTxAndDestinationAddress)
|
|
40
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Token accounts not found');
|
|
41
|
+
const tx = tokenTransferTxAndDestinationAddress
|
|
42
|
+
? tokenTransferTxAndDestinationAddress.transaction
|
|
43
|
+
: await (0, solanaUtils_1.buildTransferTransaction)(this.params.fromAddress, this.params.toAddress, this.params.amount, this.params.blockHash, this.params.lastValidBlockHeight, this.params.priorityFees || solanaUtils_1.dummyPriorityFeesForFeeEstimation);
|
|
44
|
+
const isCreatingAccount = this.params.token &&
|
|
45
|
+
recipientTokenAccounts === undefined &&
|
|
46
|
+
(recipientAccountOwner === solana_1.SYSTEM_PROGRAM_PUBLIC_KEY || recipientAccountOwner == null);
|
|
47
|
+
const newTokenAccountProgramName = isCreatingAccount
|
|
48
|
+
? (_a = this.params.token) === null || _a === void 0 ? void 0 : _a.program
|
|
49
|
+
: undefined;
|
|
50
|
+
return {
|
|
51
|
+
serializedTx: tx.serialize(),
|
|
52
|
+
additionalInfo: {
|
|
53
|
+
isCreatingAccount: !!isCreatingAccount,
|
|
54
|
+
newTokenAccountProgramName,
|
|
55
|
+
tokenAccountInfo: tokenTransferTxAndDestinationAddress === null || tokenTransferTxAndDestinationAddress === void 0 ? void 0 : tokenTransferTxAndDestinationAddress.tokenAccountInfo,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = SolanaComposeTransaction;
|
|
61
|
+
//# sourceMappingURL=solanaComposeTransaction.js.map
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
4
|
const constants_1 = require("../../../constants");
|
|
5
5
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
6
|
-
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
7
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
8
|
-
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
9
7
|
const events_1 = require("../../../events");
|
|
10
8
|
const types_1 = require("../../../types");
|
|
11
9
|
const getAddress_1 = require("../../../types/api/getAddress");
|
|
10
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
11
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
12
12
|
class SolanaGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
4
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
5
|
-
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
5
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
|
-
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
6
|
const events_1 = require("../../../events");
|
|
9
7
|
const types_1 = require("../../../types");
|
|
8
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
9
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
10
10
|
class SolanaGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
11
11
|
init() {
|
|
12
12
|
this.noBackupConfirmationMode = 'always';
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { PROTO } from '../../../constants';
|
|
2
2
|
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
3
|
-
|
|
3
|
+
type Params = PROTO.SolanaSignTx & {
|
|
4
|
+
serialize: boolean;
|
|
5
|
+
};
|
|
6
|
+
export default class SolanaSignTransaction extends AbstractMethod<'solanaSignTransaction', Params> {
|
|
4
7
|
init(): void;
|
|
5
8
|
get info(): string;
|
|
6
9
|
run(): Promise<{
|
|
7
10
|
signature: string;
|
|
11
|
+
serializedTx: string;
|
|
12
|
+
} | {
|
|
13
|
+
signature: string;
|
|
14
|
+
serializedTx?: undefined;
|
|
8
15
|
}>;
|
|
9
16
|
}
|
|
17
|
+
export {};
|
|
10
18
|
//# sourceMappingURL=solanaSignTransaction.d.ts.map
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
4
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
5
|
-
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
5
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
6
|
+
const solana_1 = require("../../../types/api/solana");
|
|
7
7
|
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
8
9
|
const additionalInfo_1 = require("../additionalInfo");
|
|
9
|
-
const
|
|
10
|
+
const solanaUtils_1 = require("../solanaUtils");
|
|
10
11
|
class SolanaSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
11
12
|
init() {
|
|
12
13
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -19,6 +20,7 @@ class SolanaSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
19
20
|
address_n: path,
|
|
20
21
|
serialized_tx: payload.serializedTx,
|
|
21
22
|
additional_info: (0, additionalInfo_1.transformAdditionalInfo)(payload.additionalInfo),
|
|
23
|
+
serialize: !!payload.serialize,
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
26
|
get info() {
|
|
@@ -26,6 +28,22 @@ class SolanaSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
26
28
|
}
|
|
27
29
|
async run() {
|
|
28
30
|
const cmd = this.device.getCommands();
|
|
31
|
+
if (this.params.serialize) {
|
|
32
|
+
const tx = await (0, solanaUtils_1.createTransactionShimFromHex)(this.params.serialized_tx);
|
|
33
|
+
const { message } = await cmd.typedCall('SolanaSignTx', 'SolanaTxSignature', {
|
|
34
|
+
...this.params,
|
|
35
|
+
serialized_tx: tx.serializeMessage(),
|
|
36
|
+
});
|
|
37
|
+
const addressCall = await cmd.typedCall('SolanaGetAddress', 'SolanaAddress', {
|
|
38
|
+
address_n: this.params.address_n,
|
|
39
|
+
show_display: false,
|
|
40
|
+
chunkify: false,
|
|
41
|
+
});
|
|
42
|
+
const { address } = addressCall.message;
|
|
43
|
+
tx.addSignature(address, message.signature);
|
|
44
|
+
const signedSerializedTx = tx.serialize();
|
|
45
|
+
return { signature: message.signature, serializedTx: signedSerializedTx };
|
|
46
|
+
}
|
|
29
47
|
const { message } = await cmd.typedCall('SolanaSignTx', 'SolanaTxSignature', this.params);
|
|
30
48
|
return { signature: message.signature };
|
|
31
49
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type CompilableTransactionMessage } from '@solana/web3.js';
|
|
2
|
+
import type { TokenAccount } from '@trezor/blockchain-link-types';
|
|
3
|
+
import type { TokenProgramName } from '@trezor/blockchain-link-utils/lib/solana';
|
|
4
|
+
import { BigNumber } from '@trezor/utils/lib/bigNumber';
|
|
5
|
+
import { Blockchain } from '../../backend/Blockchain';
|
|
6
|
+
export declare const getLamportsFromSol: (amountInSol: string) => bigint;
|
|
7
|
+
type PriorityFees = {
|
|
8
|
+
computeUnitPrice: string;
|
|
9
|
+
computeUnitLimit: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const dummyPriorityFeesForFeeEstimation: PriorityFees;
|
|
12
|
+
export declare function createTransactionShim(message: CompilableTransactionMessage): Promise<{
|
|
13
|
+
addSignature(signerPubKey: string, signatureHex: string): void;
|
|
14
|
+
serializeMessage(): string;
|
|
15
|
+
serialize(): string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function createTransactionShimFromHex(rawTx: string): Promise<{
|
|
18
|
+
addSignature(signerPubKey: string, signatureHex: string): void;
|
|
19
|
+
serializeMessage(): string;
|
|
20
|
+
serialize(): string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const buildTransferTransaction: (fromAddress: string, toAddress: string, amountInSol: string, blockhash: string, lastValidBlockHeight: number, priorityFees: PriorityFees) => Promise<{
|
|
23
|
+
addSignature(signerPubKey: string, signatureHex: string): void;
|
|
24
|
+
serializeMessage(): string;
|
|
25
|
+
serialize(): string;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const buildTokenTransferInstruction: (from: string, to: string, owner: string, amount: BigNumber, mint: string, decimals: number, tokenProgramName: TokenProgramName) => Promise<import("@solana-program/token").TransferCheckedInstruction<import("@solana/web3.js").Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">, string, string, string, string, []> | import("@solana-program/token-2022").TransferCheckedInstruction<import("@solana/web3.js").Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">, string, string, string, string, []>>;
|
|
28
|
+
export declare const getAssociatedTokenAccountAddress: (baseAddress: string, tokenMintAddress: string, tokenProgramName: TokenProgramName) => Promise<import("@solana/web3.js").Address<string>>;
|
|
29
|
+
export declare const buildCreateAssociatedTokenAccountInstruction: (funderAddress: string, newOwnerAddress: string, tokenMintAddress: string, tokenProgramName: TokenProgramName) => Promise<readonly [import("@solana-program/token").CreateAssociatedTokenInstruction<import("@solana/web3.js").Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">, string, string, string, string, string, string, []>, import("@solana/web3.js").Address<string>]>;
|
|
30
|
+
type TokenTransferTxWithDestinationAddress = {
|
|
31
|
+
transaction: {
|
|
32
|
+
addSignature(signerPubKey: string, signatureHex: string): void;
|
|
33
|
+
serializeMessage(): string;
|
|
34
|
+
serialize(): string;
|
|
35
|
+
};
|
|
36
|
+
destinationAddress: string;
|
|
37
|
+
tokenAccountInfo?: {
|
|
38
|
+
baseAddress: string;
|
|
39
|
+
tokenProgram: string;
|
|
40
|
+
tokenMint: string;
|
|
41
|
+
tokenAccount: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const getMinimumRequiredTokenAccountsForTransfer: (tokenAccounts: TokenAccount[], requiredAmount: string) => TokenAccount[];
|
|
45
|
+
export declare const buildTokenTransferTransaction: (fromAddress: string, toAddress: string, toAddressOwner: string, tokenMint: string, tokenUiAmount: string, tokenDecimals: number, fromTokenAccounts: TokenAccount[], toTokenAccount: TokenAccount | undefined, blockhash: string, lastValidBlockHeight: number, priorityFees: PriorityFees, tokenProgramName: TokenProgramName) => Promise<TokenTransferTxWithDestinationAddress>;
|
|
46
|
+
export declare const fetchAccountOwnerAndTokenInfoForAddress: (blockchain: Blockchain, address: string, mint: string, tokenProgram: TokenProgramName) => Promise<readonly [string | undefined, TokenAccount | undefined]>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=solanaUtils.d.ts.map
|