diff --git a/packages/blockchain-libs/src/provider/chains/eth/provider.ts b/packages/blockchain-libs/src/provider/chains/eth/provider.ts index ffda117ea5d..73b71568ae8 100644 --- a/packages/blockchain-libs/src/provider/chains/eth/provider.ts +++ b/packages/blockchain-libs/src/provider/chains/eth/provider.ts @@ -205,10 +205,27 @@ class Provider extends BaseProvider { signer: Signer, address?: string, ): Promise => { - const messageHash = hashMessage( - message.type as MessageTypes, - message.message, - ); + let finalMessage: any = message.message; + + // Special temporary fix for attribute name error on SpaceSwap + // https://onekeyhq.atlassian.net/browse/OK-18748 + try { + finalMessage = JSON.parse(message.message); + if ( + finalMessage.message.value1 !== undefined && + finalMessage.message.value === undefined + ) { + finalMessage.message.value = finalMessage.message.value1; + + finalMessage = JSON.stringify(finalMessage); + } else { + finalMessage = message.message; + } + } catch (e) { + finalMessage = message.message; + } + + const messageHash = hashMessage(message.type as MessageTypes, finalMessage); const [sig, recId] = await signer.sign(ethUtil.toBuffer(messageHash)); return ethUtil.addHexPrefix( Buffer.concat([sig, Buffer.from([recId + 27])]).toString('hex'), diff --git a/packages/engine/src/vaults/impl/sol/KeyringHardware.ts b/packages/engine/src/vaults/impl/sol/KeyringHardware.ts index 2f701ef0098..4a61d9a6ca5 100644 --- a/packages/engine/src/vaults/impl/sol/KeyringHardware.ts +++ b/packages/engine/src/vaults/impl/sol/KeyringHardware.ts @@ -1,6 +1,8 @@ /* eslint no-unused-vars: ["warn", { "argsIgnorePattern": "^_" }] */ /* eslint @typescript-eslint/no-unused-vars: ["warn", { "argsIgnorePattern": "^_" }] */ +import { VersionedTransaction } from '@solana/web3.js'; + import type { SignedTx, UnsignedTx } from '@onekeyhq/engine/src/types/provider'; import { convertDeviceError } from '@onekeyhq/shared/src/device/deviceErrorUtils'; import { @@ -20,7 +22,8 @@ import type { IPrepareHardwareAccountsParams, ISignCredentialOptions, } from '../../types'; -import type { PublicKey, Transaction } from '@solana/web3.js'; +import type { INativeTxSol } from './types'; +import type { PublicKey } from '@solana/web3.js'; export class KeyringHardware extends KeyringHardwareBase { override async signTransaction( @@ -32,13 +35,17 @@ export class KeyringHardware extends KeyringHardwareBase { const { connectId, deviceId } = await this.getHardwareInfo(); const passphraseState = await this.getWalletPassphraseState(); const { nativeTx: transaction, feePayer } = unsignedTx.payload as { - nativeTx: Transaction; + nativeTx: INativeTxSol; feePayer: PublicKey; }; + const isVersionedTransaction = transaction instanceof VersionedTransaction; + const response = await HardwareSDK.solSignTransaction(connectId, deviceId, { path: dbAccount.path, - rawTx: transaction.serializeMessage().toString('hex'), + rawTx: isVersionedTransaction + ? Buffer.from(transaction.message.serialize()).toString('hex') + : transaction.serializeMessage().toString('hex'), ...passphraseState, }); @@ -47,9 +54,9 @@ export class KeyringHardware extends KeyringHardwareBase { transaction.addSignature(feePayer, Buffer.from(signature, 'hex')); return { txid: signature, - rawTx: transaction - .serialize({ requireAllSignatures: false }) - .toString('base64'), + rawTx: Buffer.from( + transaction.serialize({ requireAllSignatures: false }), + ).toString('base64'), }; }