Skip to content
Open
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/abstract-cosmos/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ export class CosmosTransaction<CustomMessage = never> extends BaseTransaction {
}

/** @inheritDoc **/
get id(): string {
get id(): string | undefined {
if (this._id) {
return this._id;
} else if (this._cosmosLikeTransaction?.hash !== undefined) {
return this._cosmosLikeTransaction.hash;
}
return UNAVAILABLE_TEXT;
return undefined;
}

/** @inheritdoc */
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-ada/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface PledgeDetails {
* The transaction data returned from the toJson() function of a transaction
*/
export interface TxData {
id: string;
id: string | undefined;
type: TransactionType;
inputs: TransactionInput[];
outputs: TransactionOutput[];
Expand Down Expand Up @@ -387,7 +387,7 @@ export class Transaction extends BaseTransaction {
outputAmount: string;
fee: { fee: string };
displayOrder: string[];
id: string;
id: string | undefined;
changeAmount: string;
type: string;
withdrawals: Withdrawal[];
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-ada/test/unit/StakingActivateBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('ADA Staking Activate Transaction Builder', async () => {
txBuilder2.addSignature({ pub: keyPairPayment.getKeys().pub }, Buffer.from(signaturePayment));
txBuilder2.addSignature({ pub: keyPairStake.getKeys().pub }, Buffer.from(signatureStake));
const signedTransaction2 = await txBuilder2.build();
signedTransaction.id.should.equal(tx.id);
signedTransaction.id!.should.equal(tx.id);
const serializedTransaction2 = signedTransaction2.toBroadcastFormat();
serializedTransaction2.should.equal(serializedTransaction);
});
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('ADA Staking Activate Transaction Builder', async () => {
const signaturePayment = keyPairPayment.signMessage(signableHex2);
txBuilder2.addSignature({ pub: keyPairPayment.getKeys().pub }, Buffer.from(signaturePayment));
const signedTransaction2 = await txBuilder2.build();
signedTransaction.id.should.equal(tx.id);
signedTransaction.id!.should.equal(tx.id);
const serializedTransaction2 = signedTransaction2.toBroadcastFormat();
serializedTransaction2.should.equal(serializedTransaction);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('ADA Staking Deactivate Transaction Builder', async () => {
txBuilder2.addSignature({ pub: keyPairPayment.getKeys().pub }, Buffer.from(signaturePayment));
txBuilder2.addSignature({ pub: keyPairStake.getKeys().pub }, Buffer.from(signatureStake));
const signedTransaction2 = await txBuilder2.build();
signedTransaction.id.should.equal(tx.id);
signedTransaction.id!.should.equal(tx.id);
const serializedTransaction2 = signedTransaction2.toBroadcastFormat();
serializedTransaction2.should.equal(serializedTransaction);
});
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-ada/test/unit/stakingWithdrawBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('ADA Staking Withdraw Transaction Builder', async () => {
txBuilder2.addSignature({ pub: keyPairPayment.getKeys().pub }, Buffer.from(signaturePayment));
txBuilder2.addSignature({ pub: keyPairStake.getKeys().pub }, Buffer.from(signatureStake));
const signedTransaction2 = await txBuilder2.build();
signedTransaction.id.should.equal(tx.id);
signedTransaction.id!.should.equal(tx.id);
const serializedTransaction2 = signedTransaction2.toBroadcastFormat();
serializedTransaction2.should.equal(serializedTransaction);
});
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-ada/test/unit/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('ADA Transaction', () => {
it('a signed transfer transaction', async () => {
tx.fromRawTransaction(resources.rawTx.signedTx);
const explain = tx.explainTransaction();
explain.id.should.equal('1d0ac4a6496847341ddfd5087db6a687157cc6cc8ec9f999e72fbbc581a34523');
explain.id!.should.equal('1d0ac4a6496847341ddfd5087db6a687157cc6cc8ec9f999e72fbbc581a34523');
explain.outputAmount.should.equal('253329150');
explain.outputs[0].amount.should.equal(resources.rawTx.outputAddress1.value);
explain.outputs[0].address.should.equal(resources.rawTx.outputAddress1.address);
Expand All @@ -58,7 +58,7 @@ describe('ADA Transaction', () => {
it('an unsigned transfer transaction', async () => {
tx.fromRawTransaction(resources.rawTx.unsignedTx);
const explain = tx.explainTransaction();
explain.id.should.equal('c091e2a0ac5a8bc4f522e69b2986d3a9b2b5615e6fcb7b265d0b8d449c03e591');
explain.id!.should.equal('c091e2a0ac5a8bc4f522e69b2986d3a9b2b5615e6fcb7b265d0b8d449c03e591');
explain.outputAmount.should.equal('253329150');
explain.outputs[0].amount.should.equal(resources.rawTx.outputAddress1.value);
explain.outputs[0].address.should.equal(resources.rawTx.outputAddress1.address);
Expand Down
14 changes: 7 additions & 7 deletions modules/sdk-coin-ada/test/unit/transactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('ADA Transaction Builder', async () => {
const fee = tx.getFee;
txData.outputs[1].amount.should.equal((totalInput - outputAmount - Number(fee)).toString());
fee.should.equal('167437');
txData.id.should.equal(testData.rawTxByron.txHash2);
txData.id!.should.equal(testData.rawTxByron.txHash2);
const txBroadcast = tx.toBroadcastFormat();
should.equal(txBroadcast, testData.rawTxByron.unsignedTx2);
});
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('ADA Transaction Builder', async () => {
const fee = tx.getFee;
txData.outputs[1].amount.should.equal((totalInput - outputAmount - Number(fee)).toString());
fee.should.equal('167173');
txData.id.should.equal(testData.rawTx.txHash2);
txData.id!.should.equal(testData.rawTx.txHash2);
const txBroadcast = tx.toBroadcastFormat();
should.equal(txBroadcast, testData.rawTx.unsignedTx2);
});
Expand All @@ -93,7 +93,7 @@ describe('ADA Transaction Builder', async () => {
const fee = tx.getFee;
txData.outputs[0].amount.should.equal((totalInput - outputAmount - Number(fee)).toString());
fee.should.equal('165545');
txData.id.should.equal(testData.rawTx.txHash5);
txData.id!.should.equal(testData.rawTx.txHash5);
const txBroadcast = tx.toBroadcastFormat();
should.equal(txBroadcast, testData.rawTx.unsignedTx5);
});
Expand All @@ -116,7 +116,7 @@ describe('ADA Transaction Builder', async () => {
.get_asset(expectedPolicyId, expectedAssetName)
.to_str()
.should.equal(quantity);
txData.id.should.equal(testData.rawTx.txHash3);
txData.id!.should.equal(testData.rawTx.txHash3);
const txBroadcast = tx.toBroadcastFormat();
should.equal(txBroadcast, testData.rawTx.unsignedTx3);
});
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('ADA Transaction Builder', async () => {
(totalInput - minAmountForSingleAsset - outputAmount - Number(fee)).toString()
);
fee.should.equal('170253');
txData.id.should.equal(testData.rawTx.txHash3);
txData.id!.should.equal(testData.rawTx.txHash3);
const txBroadcast = tx.toBroadcastFormat();
should.equal(txBroadcast, testData.rawTx.unsignedTx3);
});
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('ADA Transaction Builder', async () => {
(totalInput - minAmountForSingleAsset * 2 - outputAmount - Number(fee)).toString()
);
fee.should.equal('175137');
txData.id.should.equal(testData.rawTx.txHash4);
txData.id!.should.equal(testData.rawTx.txHash4);
const txBroadcast = tx.toBroadcastFormat();
should.equal(txBroadcast, testData.rawTx.unsignedTx4);
});
Expand Down Expand Up @@ -293,7 +293,7 @@ describe('ADA Transaction Builder', async () => {
const fee = tx.getFee;
txData.outputs[1].amount.should.equal((totalInput - outputAmount - Number(fee)).toString());
fee.should.equal('167173');
txData.id.should.equal(testData.rawTx.txHash2);
txData.id!.should.equal(testData.rawTx.txHash2);
const txBroadcast = tx.toBroadcastFormat();
should.equal(txBroadcast, testData.rawTx.signedTx2);
});
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-apt/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface AptTransactionExplanation extends BaseTransactionExplanation {
* The transaction data returned from the toJson() function of a transaction
*/
export interface TxData {
id: string;
id: string | undefined;
sender: string;
/** @deprecated - use `recipients`. */
recipient?: TransactionRecipient;
Expand Down
6 changes: 3 additions & 3 deletions modules/sdk-coin-apt/src/lib/transaction/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
TransactionAuthenticatorFeePayer,
TransactionPayload,
} from '@aptos-labs/ts-sdk';
import { DEFAULT_GAS_UNIT_PRICE, UNAVAILABLE_TEXT } from '../constants';
import { DEFAULT_GAS_UNIT_PRICE } from '../constants';
import utils from '../utils';
import BigNumber from 'bignumber.js';
import { AptTransactionExplanation, TxData } from '../iface';
Expand Down Expand Up @@ -94,9 +94,9 @@ export abstract class Transaction extends BaseTransaction {
}

/** @inheritDoc **/
public override get id(): string {
public override get id(): string | undefined {
this.generateTxnId();
return this._id ?? UNAVAILABLE_TEXT;
return this._id;
}

get sender(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('AvaxP permissionlessValidatorTxBuilder', () => {
});

it('Should get a txid', async () => {
tx.id.should.equal(testData.ADD_VALIDATOR_ID_SAMPLE.txid);
tx.id!.should.equal(testData.ADD_VALIDATOR_ID_SAMPLE.txid);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('AvaxP Transaction Builder Factory', () => {
});

it('Should get a txid', async () => {
tx.id.should.equal(testData.ADD_VALIDATOR_ID_SAMPLE.txid);
tx.id!.should.equal(testData.ADD_VALIDATOR_ID_SAMPLE.txid);
});
});

Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-canton/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface PreparedTxnParsedInfo {
}

export interface WalletInitTxData {
id: string;
id: string | undefined;
type: TransactionType;
preparedParty: PreparedParty;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-dot/test/unit/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('Dot Transaction', () => {
tx.setTxJson(json);
tx.transactionType(TransactionType.Send);
const explain = tx.explainTransaction();
explain.id.should.equal('0xecb860905342cf985b39276a07d6e6696746de4623c07df863f69cba153f939a');
explain.id!.should.equal('0xecb860905342cf985b39276a07d6e6696746de4623c07df863f69cba153f939a');
explain.outputAmount.should.equal('1000000000000');
explain.outputs[0].amount.should.equal('1000000000000');
explain.outputs[0].address.should.equal(accounts.account2.address);
Expand Down
6 changes: 3 additions & 3 deletions modules/sdk-coin-flrp/test/unit/lib/exportInCTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('ExportInCTxBuilder', function () {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(testData.signedHex);
tx.id.should.equal(testData.txhash);
tx.id!.should.equal(testData.txhash);
});

it('should sign export tx built from scratch and produce valid signature', async () => {
Expand All @@ -162,7 +162,7 @@ describe('ExportInCTxBuilder', function () {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(testData.signedHex);
tx.id.should.equal(testData.txhash);
tx.id!.should.equal(testData.txhash);
});

it('should reject signing with key that does not match from address', () => {
Expand All @@ -185,7 +185,7 @@ describe('ExportInCTxBuilder', function () {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(signedExportHex);
tx.id.should.equal('3kXUsHix1bZRQ9hqUc24cp7sXFiy2LbPn6Eh2HQCAaMUi75s9');
tx.id!.should.equal('3kXUsHix1bZRQ9hqUc24cp7sXFiy2LbPn6Eh2HQCAaMUi75s9');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ describe('Flrp Export In P Tx Builder', () => {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();

tx.id.should.equal('nSBwNcgfLbk5S425b1qaYaqTTCiMCV75KU4Fbnq8SPUUqLq2');
tx.id!.should.equal('nSBwNcgfLbk5S425b1qaYaqTTCiMCV75KU4Fbnq8SPUUqLq2');

const hex = rawTx.replace('0x', '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe('Flrp Import In C Tx Builder', () => {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();

tx.id.should.equal('2t4gxEAdPLiiy9HsbjaQun1mVFewMoixNS64eZ56C38L4mpP1j');
tx.id!.should.equal('2t4gxEAdPLiiy9HsbjaQun1mVFewMoixNS64eZ56C38L4mpP1j');

const hex = rawTx.replace('0x', '');

Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Flrp Import In P Tx Builder', () => {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(signedImportHex);
tx.id.should.equal('2vwvuXp47dsUmqb4vkaMk7UsukrZNapKXT2ruZhVibbjMDpqr9');
tx.id!.should.equal('2vwvuXp47dsUmqb4vkaMk7UsukrZNapKXT2ruZhVibbjMDpqr9');
});

it('should build and sign import tx with correct sigIndices - on-chain verified', async () => {
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('Flrp Import In P Tx Builder', () => {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();

tx.id.should.equal('bgHnEJ64td8u31aZrGDaWcDqxZ8vDV5qGd7bmSifgvUnUW8v2');
tx.id!.should.equal('bgHnEJ64td8u31aZrGDaWcDqxZ8vDV5qGd7bmSifgvUnUW8v2');

const hex = rawTx.replace('0x', '');
const amountHex = parseInt(utxo.amount, 10).toString(16).padStart(16, '0');
Expand Down
8 changes: 4 additions & 4 deletions modules/sdk-coin-flrp/test/unit/lib/signFlowTestSuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function signFlowTestSuit(data: signFlowTestSuitArgs): void {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(data.fullSignedTxHex);
tx.id.should.equal(data.txHash);
tx.id!.should.equal(data.txHash);
});

it('Should full sign a tx for same values', async () => {
Expand All @@ -77,7 +77,7 @@ export default function signFlowTestSuit(data: signFlowTestSuitArgs): void {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(data.fullSignedTxHex);
tx.id.should.equal(data.txHash);
tx.id!.should.equal(data.txHash);
});

it('Should full sign a tx from half signed raw tx', async () => {
Expand All @@ -86,7 +86,7 @@ export default function signFlowTestSuit(data: signFlowTestSuitArgs): void {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(data.fullSignedTxHex);
tx.id.should.equal(data.txHash);
tx.id!.should.equal(data.txHash);
});

it('Should full sign a tx from unsigned raw tx', async () => {
Expand All @@ -96,7 +96,7 @@ export default function signFlowTestSuit(data: signFlowTestSuitArgs): void {
const tx = await txBuilder.build();
const rawTx = tx.toBroadcastFormat();
rawTx.should.equal(data.fullSignedTxHex);
tx.id.should.equal(data.txHash);
tx.id!.should.equal(data.txHash);
});
});
}
2 changes: 1 addition & 1 deletion modules/sdk-coin-icp/src/lib/iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export interface RecoveryOptions {
}

export interface RecoveryTransaction {
id: string;
id: string | undefined;
tx: string;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-near/test/unit/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Near Transaction', () => {
it('a signed transfer transaction', async () => {
tx.fromRawTransaction(NearResources.rawTx.transfer.signed);
const explain = tx.explainTransaction();
explain.id.should.equal('5jTEPuDcMCeEgp1iyEbNBKsnhYz4F4c1EPDtRmxm3wCw');
explain.id!.should.equal('5jTEPuDcMCeEgp1iyEbNBKsnhYz4F4c1EPDtRmxm3wCw');
/* TO-DO, fix amount calculation */
explain.outputAmount.should.equal('1000000000000000000000000');
explain.outputs[0].amount.should.equal('1000000000000000000000000');
Expand All @@ -79,7 +79,7 @@ describe('Near Transaction', () => {
it('an unsigned transfer transaction', async () => {
tx.fromRawTransaction(NearResources.rawTx.transfer.unsigned);
const explain = tx.explainTransaction();
explain.id.should.equal('5jTEPuDcMCeEgp1iyEbNBKsnhYz4F4c1EPDtRmxm3wCw');
explain.id!.should.equal('5jTEPuDcMCeEgp1iyEbNBKsnhYz4F4c1EPDtRmxm3wCw');
explain.outputAmount.should.equal('1000000000000000000000000');
explain.outputs[0].amount.should.equal('1000000000000000000000000');
explain.outputs[0].address.should.equal(NearResources.accounts.account2.address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('Near Staking Activate Builder', () => {
value: '1000000',
coin: 'tnear',
});
tx.id.should.equal('GpiLLaGs2Fk2bd7SQvhkJaZjj74UnPPdF7cUa9pw15je');
tx.id!.should.equal('GpiLLaGs2Fk2bd7SQvhkJaZjj74UnPPdF7cUa9pw15je');
});

it('build from an signed staking activate', async () => {
Expand All @@ -140,7 +140,7 @@ describe('Near Staking Activate Builder', () => {
value: '1000000',
coin: 'tnear',
});
tx.id.should.equal('GpiLLaGs2Fk2bd7SQvhkJaZjj74UnPPdF7cUa9pw15je');
tx.id!.should.equal('GpiLLaGs2Fk2bd7SQvhkJaZjj74UnPPdF7cUa9pw15je');
const txJson = tx.toJson();
txJson.should.have.properties(['id', 'signerId', 'publicKey', 'nonce', 'actions', 'signature']);
txJson.id.should.equal('GpiLLaGs2Fk2bd7SQvhkJaZjj74UnPPdF7cUa9pw15je');
Expand Down
4 changes: 2 additions & 2 deletions modules/sdk-coin-sol/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class Transaction extends BaseTransaction {
}

/** @inheritDoc **/
get id(): string {
get id(): string | undefined {
// Solana transaction ID === first signature: https://docs.solana.com/terminology#transaction-id
if (this._versionedTransaction) {
const sig = this._versionedTransaction.signatures?.[0];
Expand All @@ -107,7 +107,7 @@ export class Transaction extends BaseTransaction {
return base58.encode(this._solTransaction.signature);
}

return UNAVAILABLE_TEXT;
return undefined;
}

get lamportsPerSignature(): number | undefined {
Expand Down
Loading