Skip to content

Commit f9da33b

Browse files
committed
feat(sdk-coin-canton): added acknowledgement data in transaction
Ticket: COIN-6182
1 parent 5b70b72 commit f9da33b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

modules/sdk-coin-canton/src/lib/iface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface TxData {
99
type: TransactionType;
1010
sender: string;
1111
receiver: string;
12+
acknowledgeData?: TransferAcknowledge;
1213
}
1314

1415
export interface PreparedTxnParsedInfo {
@@ -87,6 +88,7 @@ export interface PartySignature {
8788
}
8889

8990
export interface TransactionBroadcastData {
91+
acknowledgeData?: TransferAcknowledge;
9092
prepareCommandResponse?: CantonPrepareCommandResponse;
9193
txType: string;
9294
preparedTransaction?: string;

modules/sdk-coin-canton/src/lib/transaction/transaction.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
PartySignature,
77
PreparedTxnParsedInfo,
88
TransactionBroadcastData,
9+
TransferAcknowledge,
910
TxData,
1011
} from '../iface';
1112
import utils from '../utils';
@@ -14,6 +15,7 @@ import { DUMMY_HASH, HASHING_SCHEME_VERSION, SIGNATURE_ALGORITHM_SPEC, SIGNATURE
1415
export class Transaction extends BaseTransaction {
1516
private _prepareCommand: CantonPrepareCommandResponse;
1617
private _signerFingerprint: string;
18+
private _acknowledgeData: TransferAcknowledge;
1719

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

36+
set acknowledgeData(data: TransferAcknowledge) {
37+
this._acknowledgeData = data;
38+
}
39+
3440
get id(): string {
3541
if (!this._id) {
3642
throw new InvalidTransactionError('transaction is is not set');
@@ -59,9 +65,13 @@ export class Transaction extends BaseTransaction {
5965
throw new InvalidTransactionError('Transaction type is not set');
6066
}
6167
if (this._type === TransactionType.TransferAcknowledge) {
68+
if (!this._acknowledgeData) {
69+
throw new InvalidTransactionError('AcknowledgeData is not set');
70+
}
6271
const minData: TransactionBroadcastData = {
6372
txType: TransactionType[this._type],
6473
submissionId: this.id,
74+
acknowledgeData: this._acknowledgeData,
6575
};
6676
return Buffer.from(JSON.stringify(minData)).toString('base64');
6777
}
@@ -119,6 +129,10 @@ export class Transaction extends BaseTransaction {
119129
receiver: '',
120130
};
121131
if (this._type === TransactionType.TransferAcknowledge) {
132+
if (!this._acknowledgeData) {
133+
throw new InvalidTransactionError('AcknowledgeData is not set');
134+
}
135+
result.acknowledgeData = this._acknowledgeData;
122136
return result;
123137
}
124138
if (!this._prepareCommand || !this._prepareCommand.preparedTransaction) {
@@ -159,6 +173,10 @@ export class Transaction extends BaseTransaction {
159173
this.signerFingerprint = decoded.partySignatures.signatures[0].party.split('::')[1];
160174
this.signatures = decoded.partySignatures.signatures[0].signatures[0].signature;
161175
}
176+
} else {
177+
if (decoded.acknowledgeData) {
178+
this.acknowledgeData = decoded.acknowledgeData;
179+
}
162180
}
163181
} catch (e) {
164182
throw new InvalidTransactionError('Unable to parse raw transaction data');

0 commit comments

Comments
 (0)