diff --git a/utilities/wallet-tester/src/common/components/TxBuilder.tsx b/utilities/wallet-tester/src/common/components/TxBuilder.tsx index 3f06a0d9f7..fe29b8f31b 100644 --- a/utilities/wallet-tester/src/common/components/TxBuilder.tsx +++ b/utilities/wallet-tester/src/common/components/TxBuilder.tsx @@ -354,9 +354,10 @@ function TxBuilder({ utxos, addresses, onSubmit: onPropSubmit = noop }: Props) { onRemoveClick={() => resetField("networkId")} render={() => ( diff --git a/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts b/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts index 420b2aa823..e6da7201fc 100644 --- a/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts +++ b/utilities/wallet-tester/src/common/helpers/buildUnsignedTx.ts @@ -11,6 +11,7 @@ import { GeneralTransactionMetadata, Int, LinearFee, + NetworkId, RewardAddress, StakeCredential, StakeDelegation, @@ -173,8 +174,7 @@ export default async function buildUnsignedTx( // #15 add network id if (builder.networkId) { - txBuilder.add_change_if_needed - // note: auto generated + // note: network id will be after build the transaction builder } // aux data @@ -223,7 +223,15 @@ export default async function buildUnsignedTx( } // build a full transaction, passing in empty witness set - const unsignedTx = Transaction.new(txBuilder.build(), TransactionWitnessSet.new(), auxMetadata); + const txBody = txBuilder.build(); + + // set network id after build + if (builder.networkId && [0, 1].includes(Number(builder.networkId))) { + const networkId = Number(builder.networkId) === 0 ? NetworkId.testnet() : NetworkId.mainnet() + txBody.set_network_id(networkId); + } + + const unsignedTx = Transaction.new(txBody, TransactionWitnessSet.new(), auxMetadata); return unsignedTx; }