Skip to content

Commit

Permalink
Merge pull request #465 from input-output-hk/feat/ADP-2246-tx-builder…
Browse files Browse the repository at this point in the history
…-build-method-should-return-the-input-selection

feat(wallet): tx builder returns inputSelection and hash on build
  • Loading branch information
rhyslbw committed Sep 28, 2022
2 parents 706ef85 + 466275e commit 1b2ccd2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/wallet/src/TxBuilder/buildTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ export class ObservableWalletTxBuilder implements TxBuilder {
auxiliaryData: this.auxiliaryData && { ...this.auxiliaryData },
body: tx.body,
extraSigners: this.extraSigners && [...this.extraSigners],
hash: tx.hash,
inputSelection: tx.inputSelection,
isValid: true,
sign: () =>
createSignedTx({
Expand Down
4 changes: 3 additions & 1 deletion packages/wallet/src/TxBuilder/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Cardano } from '@cardano-sdk/core';
import { CustomError } from 'ts-custom-error';

import { InputSelectionError } from '@cardano-sdk/input-selection';
import { InputSelectionError, SelectionSkeleton } from '@cardano-sdk/input-selection';

import { OutputValidation } from '../types';
import { SignTransactionOptions, TransactionSigner } from '@cardano-sdk/key-management';
Expand Down Expand Up @@ -126,6 +126,8 @@ export interface ValidTxBody {
readonly auxiliaryData?: Cardano.AuxiliaryData;
readonly extraSigners?: TransactionSigner[];
readonly signingOptions?: SignTransactionOptions;
readonly inputSelection: SelectionSkeleton;
readonly hash: Cardano.TransactionId;

sign(): Promise<SignedTx>;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/wallet/test/integration/buildTx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ describe('buildTx', () => {
it('can be used to build, sign and submit a tx', async () => {
const tx = await buildTx({ logger, observableWallet }).addOutput(mocks.utxo[0][1]).build();
if (tx.isValid) {
expect(tx.inputSelection).toBeTruthy();
const signedTx = await tx.sign();
expect(signedTx.tx.id).toEqual(tx.hash);
await signedTx.submit();
} else {
expect(tx.errors.length).toBeGreaterThan(0);
Expand Down

0 comments on commit 1b2ccd2

Please sign in to comment.