Skip to content

Commit

Permalink
Add MixedSets check for HW wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljscript committed Oct 22, 2024
1 parent 368cb36 commit 0cf5a87
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Transaction, WasmModuleProxy} from '@emurgo/cross-csl-core'
import {has_transaction_set_tag, TransactionSetsState} from '@emurgo/csl-mobile-bridge'
import {createSignedLedgerTxFromCbor} from '@emurgo/yoroi-lib'
import {normalizeToAddress} from '@emurgo/yoroi-lib/dist/internals/utils/addresses'
import {HW, Wallet} from '@yoroi/types'
Expand All @@ -21,10 +22,16 @@ class CIP30LedgerExtension {
async signTx(cbor: string, partial: boolean, hwDeviceInfo: HW.DeviceInfo, useUSB: boolean): Promise<Transaction> {
const {csl, release} = wrappedCsl()
try {
const tx = await csl.Transaction.fromHex(cbor)
const tx = await csl.FixedTransaction.fromHex(cbor)
if (!partial) await assertHasAllSigners(cbor, this.wallet, this.meta)
const txBody = await tx.body()

const transactionSetTag = await has_transaction_set_tag(await txBody.toBytes())

if (transactionSetTag === TransactionSetsState.MixedSets) {
throw new Error('Mixed transaction sets are not supported when using a HW wallet')
}

const payload = await toLedgerSignRequest(
csl,
txBody,
Expand Down

0 comments on commit 0cf5a87

Please sign in to comment.