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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Transaction } from './transaction';
import { VetTransactionData } from '../iface';
import EthereumAbi from 'ethereumjs-abi';
import utils from '../utils';
import BigNumber from 'bignumber.js';

export class StakingTransaction extends Transaction {
private _stakingContractAddress: string;
Expand Down Expand Up @@ -129,7 +130,7 @@ export class StakingTransaction extends Transaction {
// Set recipients from clauses
this.recipients = body.clauses.map((clause) => ({
address: (clause.to || '0x0').toString().toLowerCase(),
amount: String(clause.value || '0'),
amount: new BigNumber(clause.value || 0).toString(),
}));
this.loadInputsAndOutputs();

Expand Down
3 changes: 3 additions & 0 deletions modules/sdk-coin-vet/test/resources/vet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export const SPONSORED_TOKEN_TRANSACTION =
export const SPONSORED_NFT_TRANSACTION =
'0xf9011a2788014ead140e77bbc140f87ef87c941ec1d168574603ec35b9d229843b7c2b44bcb77080b86423b872dd000000000000000000000000c0716f386a0a78361962d1f64ce2256a2c871bb50000000000000000000000007ca00e3bc8a836026c2917c6c7c6d049e52099dd000000000000000000000000000000000000000000000000000000000001872381808252088082faf8c101b882212d212effea03773f4228cd049efe42c3efe54f18378def52f0ad349637248d67d0eec6fd9bc7ddc5ab4d98f22c4fc8de485e2403f90a68b2613e214245c0a401758c9d00ada40ebc36890bbf8cf1c84070e0950dcbb6cad94a4c9a4c0ffe16c7486c5b674207c4d916f7ed7cb501c73daaafc49cfe7685cf1e0f8054a7fa460300';

export const STAKING_TRANSACTION =
'0xf8e22788015a07263f9d6fc140f845f843941ec1d168574603ec35b9d229843b7c2b44bcb770880de0b6b3a7640000a4a694fc3a0000000000000000000000000000000000000000000001000000000000000000818082b9cd808306da0dc101b882dfcfaea89c500ac28fff75a1fa83b84dc157f23021e81383518550bf69f626ca184d58060663e013e4dd6f73b64000c5133204ffa6948eaea51b4f1bfc371683019e7476b5df49d75d969894b38e4913767107ab3d0d12313f5c1c398bdaf31a2d1df47ac763a1de1d07008e5e800fe65c4e867cf7ca57fbaf709cddab2a648bca01';

export const VALID_TOKEN_SIGNABLE_PAYLOAD =
'f8762788014ead140e77bbc140f85ef85c940000000000000000000000000000456e6572677980b844a9059cbb000000000000000000000000e59f1cea4e0fef511e3d0f4eec44adf19c4cbeec000000000000000000000000000000000000000000000000016345785d8a000081808252088082faf8c101';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import should from 'should';
import { STAKING_METHOD_ID } from '../../src/lib/constants';
import EthereumAbi from 'ethereumjs-abi';
import { BN } from 'ethereumjs-util';
import * as testData from '../resources/vet';

describe('VET Staking Transaction', function () {
const factory = new TransactionBuilderFactory(coins.get('tvet'));
Expand Down Expand Up @@ -257,5 +258,19 @@ describe('VET Staking Transaction', function () {
// Verify recipients
stakingTx.recipients[0].amount.should.equal(largeAmount);
});

it('should build a signed tx and validate its toJson', async function () {
const txBuilder = factory.from(testData.STAKING_TRANSACTION);
const tx = txBuilder.transaction as StakingTransaction;
const toJson = tx.toJson();
toJson.id.should.equal('0x4fd543eb5ac4e4b1a3eeda7335cd8ba449e5aef6dff243a55d83daf480526e11');
toJson.stakingContractAddress?.should.equal('0x1ec1d168574603ec35b9d229843b7c2b44bcb770');
toJson.amountToStake?.should.equal('0xde0b6b3a7640000');
toJson.nonce.should.equal('449037');
toJson.gas.should.equal(47565);
toJson.gasPriceCoef.should.equal(128);
toJson.expiration.should.equal(64);
toJson.chainTag.should.equal(39);
});
});
});