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
2 changes: 2 additions & 0 deletions modules/sdk-coin-canton/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface TxData {
type: TransactionType;
sender: string;
receiver: string;
acknowledgeData?: TransferAcknowledge;
}

export interface PreparedTxnParsedInfo {
Expand Down Expand Up @@ -87,6 +88,7 @@ export interface PartySignature {
}

export interface TransactionBroadcastData {
acknowledgeData?: TransferAcknowledge;
prepareCommandResponse?: CantonPrepareCommandResponse;
txType: string;
preparedTransaction?: string;
Expand Down
18 changes: 18 additions & 0 deletions modules/sdk-coin-canton/src/lib/transaction/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
PartySignature,
PreparedTxnParsedInfo,
TransactionBroadcastData,
TransferAcknowledge,
TxData,
} from '../iface';
import utils from '../utils';
Expand All @@ -14,6 +15,7 @@ import { DUMMY_HASH, HASHING_SCHEME_VERSION, SIGNATURE_ALGORITHM_SPEC, SIGNATURE
export class Transaction extends BaseTransaction {
private _prepareCommand: CantonPrepareCommandResponse;
private _signerFingerprint: string;
private _acknowledgeData: TransferAcknowledge;

constructor(coinConfig: Readonly<CoinConfig>) {
super(coinConfig);
Expand All @@ -31,6 +33,10 @@ export class Transaction extends BaseTransaction {
this._type = transactionType;
}

set acknowledgeData(data: TransferAcknowledge) {
this._acknowledgeData = data;
}

get id(): string {
if (!this._id) {
throw new InvalidTransactionError('transaction is is not set');
Expand Down Expand Up @@ -59,9 +65,13 @@ export class Transaction extends BaseTransaction {
throw new InvalidTransactionError('Transaction type is not set');
}
if (this._type === TransactionType.TransferAcknowledge) {
if (!this._acknowledgeData) {
throw new InvalidTransactionError('AcknowledgeData is not set');
}
const minData: TransactionBroadcastData = {
txType: TransactionType[this._type],
submissionId: this.id,
acknowledgeData: this._acknowledgeData,
};
return Buffer.from(JSON.stringify(minData)).toString('base64');
}
Expand Down Expand Up @@ -119,6 +129,10 @@ export class Transaction extends BaseTransaction {
receiver: '',
};
if (this._type === TransactionType.TransferAcknowledge) {
if (!this._acknowledgeData) {
throw new InvalidTransactionError('AcknowledgeData is not set');
}
result.acknowledgeData = this._acknowledgeData;
return result;
}
if (!this._prepareCommand || !this._prepareCommand.preparedTransaction) {
Expand Down Expand Up @@ -159,6 +173,10 @@ export class Transaction extends BaseTransaction {
this.signerFingerprint = decoded.partySignatures.signatures[0].party.split('::')[1];
this.signatures = decoded.partySignatures.signatures[0].signatures[0].signature;
}
} else {
if (decoded.acknowledgeData) {
this.acknowledgeData = decoded.acknowledgeData;
}
}
} catch (e) {
throw new InvalidTransactionError('Unable to parse raw transaction data');
Expand Down