From 059f855b9227a416c4b7545ce0a4c747a4de7e1b Mon Sep 17 00:00:00 2001 From: Ravi Hegde Date: Tue, 19 May 2026 15:25:16 +0530 Subject: [PATCH] feat(sdk-coin-canton): added allocation allocate builder Ticket: CHALO-469 --- .../src/lib/allocationAllocateBuilder.ts | 267 ++++++++++++++ modules/sdk-coin-canton/src/lib/iface.ts | 15 + modules/sdk-coin-canton/src/lib/index.ts | 1 + .../src/lib/transactionBuilderFactory.ts | 8 + .../allocationAllocateBuilder.ts | 333 ++++++++++++++++++ .../sdk-core/src/account-lib/baseCoin/enum.ts | 2 + 6 files changed, 626 insertions(+) create mode 100644 modules/sdk-coin-canton/src/lib/allocationAllocateBuilder.ts create mode 100644 modules/sdk-coin-canton/test/unit/builder/allocationAllocate/allocationAllocateBuilder.ts diff --git a/modules/sdk-coin-canton/src/lib/allocationAllocateBuilder.ts b/modules/sdk-coin-canton/src/lib/allocationAllocateBuilder.ts new file mode 100644 index 0000000000..1797db039a --- /dev/null +++ b/modules/sdk-coin-canton/src/lib/allocationAllocateBuilder.ts @@ -0,0 +1,267 @@ +import { InvalidTransactionError, PublicKey, TransactionType } from '@bitgo/sdk-core'; +import { BaseCoin as CoinConfig } from '@bitgo/statics'; +import { TransactionBuilder } from './transactionBuilder'; +import { Transaction } from './transaction/transaction'; +import { CantonAllocationAllocateRequest, CantonPrepareCommandResponse } from './iface'; +import utils from './utils'; + +export class AllocationAllocateBuilder extends TransactionBuilder { + private _commandId: string; + private _amount: number; + private _token: string; + private _operatorId: string; + private _contractId: string; + private _tradeId: string; + private _transferLegId: string; + private _allocateBefore: string; + private _settleBefore: string; + private _receiverPartyId: string; + private _senderPartyId: string; + private _comment?: string; + + constructor(_coinConfig: Readonly) { + super(_coinConfig); + } + + initBuilder(tx: Transaction): void { + super.initBuilder(tx); + this.setTransactionType(); + } + + get transactionType(): TransactionType { + return TransactionType.AllocationAllocate; + } + + setTransactionType(): void { + this.transaction.transactionType = TransactionType.AllocationAllocate; + } + + setTransaction(transaction: CantonPrepareCommandResponse): void { + this.transaction.prepareCommand = transaction; + } + + /** @inheritDoc */ + addSignature(publicKey: PublicKey, signature: Buffer): void { + if (!this.transaction) { + throw new InvalidTransactionError('transaction is empty!'); + } + this._signatures.push({ publicKey, signature }); + const pubKeyBase64 = utils.getBase64FromHex(publicKey.pub); + this.transaction.signerFingerprint = utils.getAddressFromPublicKey(pubKeyBase64); + this.transaction.signatures = signature.toString('base64'); + } + + /** + * Sets the unique command id for the allocation + * Also sets the _id of the transaction + * + * @param id - A uuid + * @returns The current builder instance for chaining. + * @throws Error if id is empty. + */ + commandId(id: string): this { + if (!id || !id.trim()) { + throw new Error('commandId must be a non-empty string'); + } + this._commandId = id.trim(); + this.transaction.id = id.trim(); + return this; + } + + /** + * Sets the allocation amount + * @param amount - allocation amount + * @returns The current builder instance for chaining. + * @throws Error if amount is not positive + */ + amount(amount: number): this { + if (!amount || amount < 0) { + throw new Error('amount must be a positive number'); + } + this._amount = amount; + return this; + } + + /** + * Sets the token for the allocation + * @param token - token identifier + * @returns The current builder instance for chaining. + * @throws Error if token is empty. + */ + token(token: string): this { + if (!token || !token.trim()) { + throw new Error('token must be a non-empty string'); + } + this._token = token.trim(); + return this; + } + + /** + * Sets the operator party id + * @param id - operator party id + * @returns The current builder instance for chaining. + * @throws Error if id is empty. + */ + operatorId(id: string): this { + if (!id || !id.trim()) { + throw new Error('operatorId must be a non-empty string'); + } + this._operatorId = id.trim(); + return this; + } + + /** + * Sets the contract id + * @param id - canton contract id + * @returns The current builder instance for chaining. + * @throws Error if id is empty. + */ + contractId(id: string): this { + if (!id || !id.trim()) { + throw new Error('contractId must be a non-empty string'); + } + this._contractId = id.trim(); + return this; + } + + /** + * Sets the trade id + * @param id - trade id + * @returns The current builder instance for chaining. + * @throws Error if id is empty. + */ + tradeId(id: string): this { + if (!id || !id.trim()) { + throw new Error('tradeId must be a non-empty string'); + } + this._tradeId = id.trim(); + return this; + } + + /** + * Sets the transfer leg id (e.g. `${tradeId}-security-leg` or `${tradeId}-cash-leg`) + * @param id - transfer leg id + * @returns The current builder instance for chaining. + * @throws Error if id is empty. + */ + transferLegId(id: string): this { + if (!id || !id.trim()) { + throw new Error('transferLegId must be a non-empty string'); + } + this._transferLegId = id.trim(); + return this; + } + + /** + * Sets the allocate-before deadline (ISO 8601) + * @param deadline - allocation deadline + * @returns The current builder instance for chaining. + * @throws Error if deadline is empty. + */ + allocateBefore(deadline: string): this { + if (!deadline || !deadline.trim()) { + throw new Error('allocateBefore must be a non-empty string'); + } + this._allocateBefore = deadline.trim(); + return this; + } + + /** + * Sets the settle-before deadline (ISO 8601) + * @param deadline - settlement deadline + * @returns The current builder instance for chaining. + * @throws Error if deadline is empty. + */ + settleBefore(deadline: string): this { + if (!deadline || !deadline.trim()) { + throw new Error('settleBefore must be a non-empty string'); + } + this._settleBefore = deadline.trim(); + return this; + } + + /** + * Sets the sender party id + * @param id - sender party id + * @returns The current builder instance for chaining. + * @throws Error if id is empty. + */ + senderPartyId(id: string): this { + if (!id || !id.trim()) { + throw new Error('senderPartyId must be a non-empty string'); + } + this._senderPartyId = id.trim(); + return this; + } + + /** + * Sets the receiver party id + * @param id - receiver party id + * @returns The current builder instance for chaining. + * @throws Error if id is empty. + */ + receiverPartyId(id: string): this { + if (!id || !id.trim()) { + throw new Error('receiverPartyId must be a non-empty string'); + } + this._receiverPartyId = id.trim(); + return this; + } + + /** + * Sets the optional comment + * @param comment - free-form comment + * @returns The current builder instance for chaining. + */ + comment(comment: string): this { + this._comment = comment; + return this; + } + + /** + * Builds and returns the CantonAllocationAllocateRequest object from the builder's internal state. + * + * @returns {CantonAllocationAllocateRequest} - A fully constructed and validated request object. + * @throws {Error} If any required field is missing or fails validation. + */ + toRequestObject(): CantonAllocationAllocateRequest { + this.validate(); + const result: CantonAllocationAllocateRequest = { + commandId: this._commandId, + amount: this._amount, + token: this._token, + operatorId: this._operatorId, + contractId: this._contractId, + tradeId: this._tradeId, + transferLegId: this._transferLegId, + allocateBefore: this._allocateBefore, + settleBefore: this._settleBefore, + receiverPartyId: this._receiverPartyId, + senderPartyId: this._senderPartyId, + }; + if (this._comment !== undefined) { + result.comment = this._comment; + } + return result; + } + + /** + * Validates the internal state of the builder before building the request object. + * + * @private + * @throws {Error} If any required field is missing. + */ + private validate(): void { + if (!this._commandId) throw new Error('commandId is missing'); + if (!this._amount) throw new Error('amount is missing'); + if (!this._token) throw new Error('token is missing'); + if (!this._operatorId) throw new Error('operatorId is missing'); + if (!this._contractId) throw new Error('contractId is missing'); + if (!this._tradeId) throw new Error('tradeId is missing'); + if (!this._transferLegId) throw new Error('transferLegId is missing'); + if (!this._allocateBefore) throw new Error('allocateBefore is missing'); + if (!this._settleBefore) throw new Error('settleBefore is missing'); + if (!this._receiverPartyId) throw new Error('receiverPartyId is missing'); + if (!this._senderPartyId) throw new Error('senderPartyId is missing'); + } +} diff --git a/modules/sdk-coin-canton/src/lib/iface.ts b/modules/sdk-coin-canton/src/lib/iface.ts index 8d40f0079b..68275dd71b 100644 --- a/modules/sdk-coin-canton/src/lib/iface.ts +++ b/modules/sdk-coin-canton/src/lib/iface.ts @@ -170,3 +170,18 @@ export interface CantonTransferRequest { memoId?: string; tokenName?: string; } + +export interface CantonAllocationAllocateRequest { + commandId: string; + amount: number; + token: string; + operatorId: string; + contractId: string; + tradeId: string; + transferLegId: string; + allocateBefore: string; + settleBefore: string; + receiverPartyId: string; + senderPartyId: string; + comment?: string; +} diff --git a/modules/sdk-coin-canton/src/lib/index.ts b/modules/sdk-coin-canton/src/lib/index.ts index a26b20b1df..4c4954f5e4 100644 --- a/modules/sdk-coin-canton/src/lib/index.ts +++ b/modules/sdk-coin-canton/src/lib/index.ts @@ -1,6 +1,7 @@ import * as Utils from './utils'; import * as Interface from './iface'; +export { AllocationAllocateBuilder } from './allocationAllocateBuilder'; export { CosignDelegationAcceptBuilder } from './cosignDelegationAcceptBuilder'; export { CosignDelegationProposalBuilder } from './cosignDelegationProposalBuilder'; export { KeyPair } from './keyPair'; diff --git a/modules/sdk-coin-canton/src/lib/transactionBuilderFactory.ts b/modules/sdk-coin-canton/src/lib/transactionBuilderFactory.ts index e2b1fe06ba..143b7f3d66 100644 --- a/modules/sdk-coin-canton/src/lib/transactionBuilderFactory.ts +++ b/modules/sdk-coin-canton/src/lib/transactionBuilderFactory.ts @@ -5,6 +5,7 @@ import { TransactionType, } from '@bitgo/sdk-core'; import { BaseCoin as CoinConfig } from '@bitgo/statics'; +import { AllocationAllocateBuilder } from './allocationAllocateBuilder'; import { CosignDelegationAcceptBuilder } from './cosignDelegationAcceptBuilder'; import { CosignDelegationProposalBuilder } from './cosignDelegationProposalBuilder'; import { OneStepPreApprovalBuilder } from './oneStepPreApprovalBuilder'; @@ -56,6 +57,9 @@ export class TransactionBuilderFactory extends BaseTransactionBuilderFactory { case TransactionType.TransferReject: { return this.getTransferRejectBuilder(tx); } + case TransactionType.AllocationAllocate: { + return this.getAllocationAllocateBuilder(tx); + } default: { throw new InvalidTransactionError('unsupported transaction'); } @@ -63,6 +67,10 @@ export class TransactionBuilderFactory extends BaseTransactionBuilderFactory { } } + getAllocationAllocateBuilder(tx?: Transaction): AllocationAllocateBuilder { + return TransactionBuilderFactory.initializeBuilder(tx, new AllocationAllocateBuilder(this._coinConfig)); + } + getOneStepPreapprovalBuilder(tx?: Transaction): OneStepPreApprovalBuilder { return TransactionBuilderFactory.initializeBuilder(tx, new OneStepPreApprovalBuilder(this._coinConfig)); } diff --git a/modules/sdk-coin-canton/test/unit/builder/allocationAllocate/allocationAllocateBuilder.ts b/modules/sdk-coin-canton/test/unit/builder/allocationAllocate/allocationAllocateBuilder.ts new file mode 100644 index 0000000000..587fa3e35c --- /dev/null +++ b/modules/sdk-coin-canton/test/unit/builder/allocationAllocate/allocationAllocateBuilder.ts @@ -0,0 +1,333 @@ +import assert from 'assert'; +import should from 'should'; + +import { coins } from '@bitgo/statics'; + +import { AllocationAllocateBuilder, Transaction } from '../../../../src'; +import { CantonAllocationAllocateRequest } from '../../../../src/lib/iface'; + +const commandId = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'; +const amount = 100; +const token = 'canton:amulet-usd'; +const operatorId = '12205::12205b4e3537a95126d90604592344d8ad3c3ddccda4f79901954280ee19c576714d'; +const contractId = + '001b549bfa833bab661ab30e4d0a3ab0ec01fcc4a2bef5369795f4928147706353ca1112205a8d0e780cf3b3115cf8be0d6315f4aed6a1c25b67e8c5d64cf9848d0458fd17'; +const tradeId = 'trade-9988776655'; +const transferLegId = 'trade-9988776655-security-leg'; +const allocateBefore = '2026-05-06T16:46:17.184609Z'; +const settleBefore = '2026-05-07T16:46:17.184609Z'; +const receiverPartyId = '12206::12206a4e3537a95126d90604592344d8ad3c3ddccda4f79901954280ee19c576714d'; +const senderPartyId = '12207::12207a4e3537a95126d90604592344d8ad3c3ddccda4f79901954280ee19c576714d'; +const comment = 'test allocation comment'; + +// Helper to build with all required fields set +function buildWithAllRequired(txBuilder: AllocationAllocateBuilder): AllocationAllocateBuilder { + return txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); +} + +describe('AllocationAllocate Builder', () => { + it('should build the allocation allocate request object with all fields', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + buildWithAllRequired(txBuilder).comment(comment); + const requestObj: CantonAllocationAllocateRequest = txBuilder.toRequestObject(); + should.exist(requestObj); + assert.equal(requestObj.commandId, commandId); + assert.equal(requestObj.amount, amount); + assert.equal(requestObj.token, token); + assert.equal(requestObj.operatorId, operatorId); + assert.equal(requestObj.contractId, contractId); + assert.equal(requestObj.tradeId, tradeId); + assert.equal(requestObj.transferLegId, transferLegId); + assert.equal(requestObj.allocateBefore, allocateBefore); + assert.equal(requestObj.settleBefore, settleBefore); + assert.equal(requestObj.receiverPartyId, receiverPartyId); + assert.equal(requestObj.senderPartyId, senderPartyId); + assert.equal(requestObj.comment, comment); + }); + + it('should build the allocation allocate request object without optional comment', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + buildWithAllRequired(txBuilder); + const requestObj: CantonAllocationAllocateRequest = txBuilder.toRequestObject(); + should.exist(requestObj); + assert.equal(requestObj.comment, undefined); + }); + + it('should set the transaction id to the commandId', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder.commandId(commandId); + assert.equal(tx.id, commandId); + }); + + it('should throw if commandId is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /commandId is missing/); + }); + + it('should throw if amount is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /amount is missing/); + }); + + it('should throw if token is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /token is missing/); + }); + + it('should throw if operatorId is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /operatorId is missing/); + }); + + it('should throw if contractId is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /contractId is missing/); + }); + + it('should throw if tradeId is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /tradeId is missing/); + }); + + it('should throw if transferLegId is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /transferLegId is missing/); + }); + + it('should throw if allocateBefore is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /allocateBefore is missing/); + }); + + it('should throw if settleBefore is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .receiverPartyId(receiverPartyId) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /settleBefore is missing/); + }); + + it('should throw if receiverPartyId is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .senderPartyId(senderPartyId); + assert.throws(() => txBuilder.toRequestObject(), /receiverPartyId is missing/); + }); + + it('should throw if senderPartyId is missing', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + txBuilder + .commandId(commandId) + .amount(amount) + .token(token) + .operatorId(operatorId) + .contractId(contractId) + .tradeId(tradeId) + .transferLegId(transferLegId) + .allocateBefore(allocateBefore) + .settleBefore(settleBefore) + .receiverPartyId(receiverPartyId); + assert.throws(() => txBuilder.toRequestObject(), /senderPartyId is missing/); + }); + + it('should throw if commandId is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.commandId(''), /commandId must be a non-empty string/); + }); + + it('should throw if token is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.token(''), /token must be a non-empty string/); + }); + + it('should throw if operatorId is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.operatorId(''), /operatorId must be a non-empty string/); + }); + + it('should throw if contractId is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.contractId(''), /contractId must be a non-empty string/); + }); + + it('should throw if tradeId is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.tradeId(''), /tradeId must be a non-empty string/); + }); + + it('should throw if transferLegId is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.transferLegId(''), /transferLegId must be a non-empty string/); + }); + + it('should throw if allocateBefore is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.allocateBefore(''), /allocateBefore must be a non-empty string/); + }); + + it('should throw if settleBefore is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.settleBefore(''), /settleBefore must be a non-empty string/); + }); + + it('should throw if receiverPartyId is an empty string', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + assert.throws(() => txBuilder.receiverPartyId(''), /receiverPartyId must be a non-empty string/); + }); + + it('should set the prepareCommand via setTransaction', function () { + const txBuilder = new AllocationAllocateBuilder(coins.get('tcanton')); + const tx = new Transaction(coins.get('tcanton')); + txBuilder.initBuilder(tx); + const prepareCommandResponse = { + preparedTransactionHash: 'abc123', + hashingSchemeVersion: 'HASHING_SCHEME_VERSION_V2', + }; + txBuilder.setTransaction(prepareCommandResponse); + assert.deepEqual(tx.prepareCommand, prepareCommandResponse); + }); +}); diff --git a/modules/sdk-core/src/account-lib/baseCoin/enum.ts b/modules/sdk-core/src/account-lib/baseCoin/enum.ts index a4a8641475..8fbf598799 100644 --- a/modules/sdk-core/src/account-lib/baseCoin/enum.ts +++ b/modules/sdk-core/src/account-lib/baseCoin/enum.ts @@ -101,6 +101,8 @@ export enum TransactionType { CosignDelegationProposal, // canton cosign delegation accept CosignDelegationAccept, + // canton allocation allocate + AllocationAllocate, // trx FREEZE,