import { serializedPath, validatePath } from '../helpers/pathUtils'; import { BaseMethod } from '../BaseMethod'; import { validateParams } from '../helpers/paramsValidator'; import { formatAnyHex } from '../helpers/hexUtils'; import type { SolanaSignTransactionParams } from '../../types'; import type { AlgorandSignTx as HardwareAlgorandSignTx } from '@onekeyfe/hd-transport'; export default class AlgoSignTransaction extends BaseMethod { getSupportedProtocols() { return ['V1', 'V2'] as const; } hasBundle = false; init() { this.checkDeviceId = true; this.allowDeviceMode = [...this.allowDeviceMode]; this.allowUsePreInitialize = true; // check payload validateParams(this.payload, [ { name: 'path', required: true }, { name: 'rawTx', type: 'hexString', required: true }, ]); // init params const { path, rawTx } = this.payload as SolanaSignTransactionParams; const addressN = validatePath(path, 3); this.params = { address_n: addressN, raw_tx: formatAnyHex(rawTx), }; } getVersionRange() { return { model_mini: { min: '2.6.0', }, }; } async run() { const res = await this.device.commands.typedCall('AlgorandSignTx', 'AlgorandSignedTx', { ...this.params, }); const { signature } = res.message; return { path: serializedPath(this.params.address_n), signature, }; } }