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
18 changes: 13 additions & 5 deletions modules/sdk-coin-canton/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,25 @@ export interface UTXOInfo {
value: string;
}

export interface CantonMinLedgerTime {
time: { Empty: Record<string, never> } | { MinLedgerTimeAbs: { value: string } };
}

export interface CantonCustodialTiming {
minLedgerTime: { time: { MinLedgerTimeAbs: { value: string } } };
broadcastNotBefore: string;
broadcastTarget: string;
broadcastExpiresAt: string;
}

export interface CantonPrepareCommandResponse {
preparedTransaction?: string;
preparedTransactionHash: string;
hashingSchemeVersion: string;
hashingDetails?: string | null;
utxoInfo?: UTXOInfo[];
isOneStepTransfer?: boolean;
custodialTiming?: CantonCustodialTiming;
}

export interface PreparedParty {
Expand Down Expand Up @@ -262,11 +274,7 @@ export interface TransactionBroadcastData {
};
submissionId: string;
hashingSchemeVersion?: string;
minLedgerTime?: {
time: {
Empty: Record<string, never>;
};
};
minLedgerTime?: CantonMinLedgerTime;
}

export interface CantonOneStepEnablementRequest extends CantonPrepareCommandRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class Transaction extends BaseTransaction {
},
submissionId: this.id,
hashingSchemeVersion: HASHING_SCHEME_VERSION,
minLedgerTime: {
minLedgerTime: this._prepareCommand.custodialTiming?.minLedgerTime ?? {
time: {
Empty: {},
},
Expand Down
32 changes: 32 additions & 0 deletions modules/sdk-coin-canton/test/unit/canton.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assert from 'assert';
import 'should';
import { BitGoAPI } from '@bitgo/sdk-api';
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
Expand Down Expand Up @@ -81,6 +82,37 @@ describe('Canton coin:', function () {
});
});

describe('Canton custodial timing serialization:', function () {
it('serializes and round-trips absolute minLedgerTime metadata', function () {
const timing = {
minLedgerTime: {
time: { MinLedgerTimeAbs: { value: '2026-10-27T12:10:00.000Z' } },
},
broadcastNotBefore: '2026-10-27T12:09:00.000Z',
broadcastTarget: '2026-10-27T12:09:30.000Z',
broadcastExpiresAt: '2026-10-27T12:11:00.000Z',
};
const tx = new Transaction(coins.get('tcanton'));
tx.id = 'custodial-accept-command';
tx.transactionType = TransactionType.OneStepPreApproval;
tx.prepareCommand = {
...OneStepPreApprovalPrepareResponse,
custodialTiming: timing,
};

const serialized = tx.toBroadcastFormat();
const payload = JSON.parse(Buffer.from(serialized, 'base64').toString('utf8'));
assert.deepStrictEqual(payload.minLedgerTime, timing.minLedgerTime);
assert.deepStrictEqual(payload.prepareCommandResponse.custodialTiming, timing);

const parsed = new Transaction(coins.get('tcanton'));
parsed.fromRawTransaction(serialized);
assert.deepStrictEqual(parsed.prepareCommand.custodialTiming, timing);
const roundTrip = JSON.parse(Buffer.from(parsed.toBroadcastFormat(), 'base64').toString('utf8'));
assert.deepStrictEqual(roundTrip.minLedgerTime, timing.minLedgerTime);
});
});

describe('Canton verifyTransaction:', function () {
let bitgo: TestBitGoAPI;
let basecoin: Canton;
Expand Down
Loading