Skip to content

Commit 484f67d

Browse files
authored
Merge pull request #6208 from BitGo/WIN-5535
fix(sdk-coin-polyx): fix toJson method in polyx transaction
2 parents 1667bb6 + 8f8ef0b commit 484f67d

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

modules/abstract-substrate/src/lib/transaction.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ export class Transaction extends BaseTransaction {
128128

129129
/** @inheritdoc */
130130
toJson(): TxData {
131-
console.log('Transaction toJson called in substrate Transaction class');
132131
if (!this._substrateTransaction) {
133132
throw new InvalidTransactionError('Empty transaction');
134133
}

modules/sdk-coin-polyx/src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ export {
1111
export { TransactionBuilderFactory } from './transactionBuilderFactory';
1212
export { TransferBuilder } from './transferBuilder';
1313
export { RegisterDidWithCDDBuilder } from './registerDidWithCDDBuilder';
14+
export { Transaction as PolyxTransaction } from './transaction';
1415
export { Utils, default as utils } from './utils';
1516
export * from './iface';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { DecodedTx, RegisterDidWithCDDArgs } from './iface';
77
export class Transaction extends SubstrateTransaction {
88
/** @inheritdoc */
99
toJson(): Interface.TxData {
10-
console.log('Transaction toJson called in polyx Transaction class');
1110
if (!this._substrateTransaction) {
1211
throw new InvalidTransactionError('Empty transaction');
1312
}
@@ -39,6 +38,7 @@ export class Transaction extends SubstrateTransaction {
3938
pub: Buffer.from(decodeAddress(targetAccount)).toString('hex'),
4039
});
4140
result.to = keypairDest.getAddress(this.getAddressFormat());
41+
result.amount = '0'; // RegisterDidWithCDD does not transfer any value
4242
} else {
4343
super.toJson();
4444
}

modules/sdk-coin-polyx/src/lib/transferBuilder.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ export class TransferBuilder extends TransactionBuilder {
8585
const to = txMethod.dest.id;
8686
const memo = txMethod.memo;
8787

88-
console.log(`Validating TransferWithMemo transaction: amount=${amount}, to=${to}, memo=${memo}`);
89-
9088
const validationResult = Schema.TransferWithMemoTransactionSchema.validate({ amount, to, memo });
9189
if (validationResult.error) {
9290
throw new InvalidTransactionError(`Invalid transaction: ${validationResult.error.message}`);

modules/sdk-coin-polyx/test/unit/transactionBuilder/registerDidWithCDDBuilder.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe('Polyx Register DID with CDD builder Builder', () => {
4343
builder.addSignature({ pub: sender.publicKey }, Buffer.from(mockTssSignature, 'hex'));
4444
const tx = await builder.build();
4545
const txJson = tx.toJson();
46+
should.deepEqual(txJson.amount, '0');
4647
should.deepEqual(txJson.to, receiver.address);
4748
should.deepEqual(txJson.sender, sender.address);
4849
should.deepEqual(txJson.blockNumber, 3933);
@@ -75,6 +76,7 @@ describe('Polyx Register DID with CDD builder Builder', () => {
7576
builder.addSignature({ pub: sender.publicKey }, Buffer.from(mockTssSignature, 'hex'));
7677
const tx = await builder.build();
7778
const txJson = tx.toJson();
79+
should.deepEqual(txJson.amount, '0');
7880
should.deepEqual(txJson.to, receiver.address);
7981
should.deepEqual(txJson.sender, sender.address);
8082
should.deepEqual(txJson.blockNumber, 3933);
@@ -106,6 +108,7 @@ describe('Polyx Register DID with CDD builder Builder', () => {
106108
.fee({ amount: 0, type: 'tip' });
107109
const tx = await builder.build();
108110
const txJson = tx.toJson();
111+
should.deepEqual(txJson.amount, '0');
109112
should.deepEqual(txJson.to, receiver.address);
110113
should.deepEqual(txJson.sender, sender.address);
111114
should.deepEqual(txJson.blockNumber, 3933);
@@ -126,6 +129,7 @@ describe('Polyx Register DID with CDD builder Builder', () => {
126129
.referenceBlock('0x149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d');
127130
const tx = await builder.build();
128131
const txJson = tx.toJson();
132+
should.deepEqual(txJson.amount, '0');
129133
should.deepEqual(txJson.to, '5EFWg5wKTgkFE9XCxigBYPYKQg173djwSmRbkALCdL1jFVUU');
130134
should.deepEqual(txJson.sender, '5E7XWJRysj27EzibT4duRxrBQT9Qfa7Z5nAAvJmvd32nhkjH');
131135
should.deepEqual(txJson.blockNumber, 3933);
@@ -149,6 +153,7 @@ describe('Polyx Register DID with CDD builder Builder', () => {
149153

150154
const tx = await builder.build();
151155
const txJson = tx.toJson();
156+
should.deepEqual(txJson.amount, '0');
152157
should.deepEqual(txJson.to, '5EFWg5wKTgkFE9XCxigBYPYKQg173djwSmRbkALCdL1jFVUU');
153158
should.deepEqual(txJson.sender, sender.address);
154159
should.deepEqual(txJson.blockNumber, 3933);

0 commit comments

Comments
 (0)