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
4 changes: 2 additions & 2 deletions modules/sdk-coin-canton/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export interface TransactionBroadcastData {

export interface CantonOneStepEnablementRequest extends CantonPrepareCommandRequest {
receiverId: string;
token?: string;
tokenName?: string;
}

export interface CantonTransferAcceptRejectRequest extends CantonPrepareCommandRequest {
Expand All @@ -159,5 +159,5 @@ export interface CantonTransferRequest {
expiryEpoch: number;
sendViaOneStep: boolean;
memoId?: string;
token?: string;
tokenName?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import utils from './utils';
export class OneStepPreApprovalBuilder extends TransactionBuilder {
private _commandId: string;
private _receiverPartyId: string;
private _token: string;
private _tokenName: string;
constructor(_coinConfig: Readonly<CoinConfig>) {
super(_coinConfig);
}
Expand Down Expand Up @@ -80,11 +80,11 @@ export class OneStepPreApprovalBuilder extends TransactionBuilder {
* @returns The current builder for chaining
* @throws Error if name is invalid
*/
token(name: string): this {
tokenName(name: string): this {
if (!name || !name.trim()) {
throw new Error('token name must be a non-empty string');
}
this._token = name.trim();
this._tokenName = name.trim();
return this;
}

Expand All @@ -106,7 +106,7 @@ export class OneStepPreApprovalBuilder extends TransactionBuilder {
verboseHashing: false,
actAs: [this._receiverPartyId],
readAs: [],
token: this._token,
tokenName: this._tokenName,
};
}

Expand Down
10 changes: 5 additions & 5 deletions modules/sdk-coin-canton/src/lib/transferBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class TransferBuilder extends TransactionBuilder {
private _sendOneStep = false;
private _expiryEpoch: number;
private _memoId: string;
private _token: string;
private _tokenName: string;
constructor(_coinConfig: Readonly<CoinConfig>) {
super(_coinConfig);
}
Expand Down Expand Up @@ -152,11 +152,11 @@ export class TransferBuilder extends TransactionBuilder {
* @returns The current builder for chaining
* @throws Error if name is invalid
*/
token(name: string): this {
tokenName(name: string): this {
if (!name || !name.trim()) {
throw new Error('token name must be a non-empty string');
}
this._token = name.trim();
this._tokenName = name.trim();
return this;
}

Expand All @@ -178,8 +178,8 @@ export class TransferBuilder extends TransactionBuilder {
if (this._memoId) {
data.memoId = this._memoId;
}
if (this._token) {
data.token = this._token;
if (this._tokenName) {
data.tokenName = this._tokenName;
}
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ describe('Wallet Pre-approval Enablement Builder', () => {
const commandId = '7d99789d-2f22-49e1-85cb-79d2ce5a69c1';
const partyId = 'ravi-2-step-party-new::122092e7d33ac10c0f3d55976342f37555df05da5b742956d56a62ae2367769079d2';
const token = 'tcanton:testcoin1';
txBuilder.commandId(commandId).receiverPartyId(partyId).token(token);
txBuilder.commandId(commandId).receiverPartyId(partyId).tokenName(token);
const requestObj: CantonOneStepEnablementRequest = txBuilder.toRequestObject();
should.exist(requestObj);
assert.equal(requestObj.commandId, commandId);
assert.equal(requestObj.receiverId, partyId);
assert.equal(requestObj.token, token);
assert.equal(requestObj.tokenName, token);
assert.equal(requestObj.actAs.length, 1);
const actAs = requestObj.actAs[0];
assert.equal(actAs, partyId);
Expand Down