Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions modules/sdk-coin-icp/src/lib/transactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js';
import { BaseTransactionBuilder, BuildTransactionError, BaseAddress, SigningError, BaseKey } from '@bitgo/sdk-core';
import { Transaction } from './transaction';
import utils from './utils';
import { IcpTransactionData } from './iface';
import { IcpTransactionData, Signatures } from './iface';
import { SignedTransactionBuilder } from './signedTransactionBuilder';

export abstract class TransactionBuilder extends BaseTransactionBuilder {
Expand All @@ -19,6 +19,14 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
this._transaction = new Transaction(_coinConfig, utils);
}

get signaturePayload(): Signatures[] {
return this._transaction.signaturePayload;
}

get unsignedTransaction(): string {
return this._transaction.payloadsData.unsigned_transaction;
}

/**
* Sets the public key and the address of the sender of this transaction.
*
Expand Down Expand Up @@ -147,7 +155,7 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
}

// combine the unsigned transaction with the signature payload and generates the signed transaction
protected combine(): void {
public combine(): void {
const signedTransactionBuilder = new SignedTransactionBuilder(
this._transaction.unsignedTransaction,
this._transaction.signaturePayload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ describe('ICP Transaction Builder', async () => {
should.equal(icpTransaction.operations[1].amount.value, '10');
should.equal(icpTransaction.operations[2].amount.value, '-10000');
should.equal(icpTransaction.public_keys[0].hex_bytes, testData.accounts.account1.publicKey);
payloadsData.unsigned_transaction.should.be.a.String();
txBuilder.unsignedTransaction.should.be.a.String();
payloadsData.payloads.should.be.an.Array();
payloadsData.payloads.length.should.equal(2);
should.equal(payloadsData.unsigned_transaction, testData.payloadsData.unsigned_transaction);
should.equal(txBuilder.unsignedTransaction, testData.payloadsData.unsigned_transaction);
should.deepEqual(payloadsData.payloads, testData.payloadsData.payloads);
});

Expand Down Expand Up @@ -90,7 +90,7 @@ describe('ICP Transaction Builder', async () => {
it('should sign a txn and then give txn in broadcast format', async () => {
const baseKey: BaseKey = { key: testData.accounts.account1.secretKey };
txBuilder.sign(baseKey);
should.deepEqual(txn.signaturePayload, testData.signatures);
should.deepEqual(txBuilder.signaturePayload, testData.signatures);
txBuilder.combine();
const signedTxn = txBuilder.transaction.signedTransaction;
signedTxn.should.be.a.String();
Expand Down