File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Transaction } from './transaction';
55import { VetTransactionData } from '../iface' ;
66import EthereumAbi from 'ethereumjs-abi' ;
77import utils from '../utils' ;
8+ import BigNumber from 'bignumber.js' ;
89
910export class StakingTransaction extends Transaction {
1011 private _stakingContractAddress : string ;
@@ -129,7 +130,7 @@ export class StakingTransaction extends Transaction {
129130 // Set recipients from clauses
130131 this . recipients = body . clauses . map ( ( clause ) => ( {
131132 address : ( clause . to || '0x0' ) . toString ( ) . toLowerCase ( ) ,
132- amount : String ( clause . value || '0' ) ,
133+ amount : new BigNumber ( clause . value || 0 ) . toString ( ) ,
133134 } ) ) ;
134135 this . loadInputsAndOutputs ( ) ;
135136
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ export const SPONSORED_TOKEN_TRANSACTION =
1111export const SPONSORED_NFT_TRANSACTION =
1212 '0xf9011a2788014ead140e77bbc140f87ef87c941ec1d168574603ec35b9d229843b7c2b44bcb77080b86423b872dd000000000000000000000000c0716f386a0a78361962d1f64ce2256a2c871bb50000000000000000000000007ca00e3bc8a836026c2917c6c7c6d049e52099dd000000000000000000000000000000000000000000000000000000000001872381808252088082faf8c101b882212d212effea03773f4228cd049efe42c3efe54f18378def52f0ad349637248d67d0eec6fd9bc7ddc5ab4d98f22c4fc8de485e2403f90a68b2613e214245c0a401758c9d00ada40ebc36890bbf8cf1c84070e0950dcbb6cad94a4c9a4c0ffe16c7486c5b674207c4d916f7ed7cb501c73daaafc49cfe7685cf1e0f8054a7fa460300' ;
1313
14+ export const STAKING_TRANSACTION =
15+ '0xf8e22788015a07263f9d6fc140f845f843941ec1d168574603ec35b9d229843b7c2b44bcb770880de0b6b3a7640000a4a694fc3a0000000000000000000000000000000000000000000001000000000000000000818082b9cd808306da0dc101b882dfcfaea89c500ac28fff75a1fa83b84dc157f23021e81383518550bf69f626ca184d58060663e013e4dd6f73b64000c5133204ffa6948eaea51b4f1bfc371683019e7476b5df49d75d969894b38e4913767107ab3d0d12313f5c1c398bdaf31a2d1df47ac763a1de1d07008e5e800fe65c4e867cf7ca57fbaf709cddab2a648bca01' ;
16+
1417export const VALID_TOKEN_SIGNABLE_PAYLOAD =
1518 'f8762788014ead140e77bbc140f85ef85c940000000000000000000000000000456e6572677980b844a9059cbb000000000000000000000000e59f1cea4e0fef511e3d0f4eec44adf19c4cbeec000000000000000000000000000000000000000000000000016345785d8a000081808252088082faf8c101' ;
1619
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import should from 'should';
44import { STAKING_METHOD_ID } from '../../src/lib/constants' ;
55import EthereumAbi from 'ethereumjs-abi' ;
66import { BN } from 'ethereumjs-util' ;
7+ import * as testData from '../resources/vet' ;
78
89describe ( 'VET Staking Transaction' , function ( ) {
910 const factory = new TransactionBuilderFactory ( coins . get ( 'tvet' ) ) ;
@@ -257,5 +258,19 @@ describe('VET Staking Transaction', function () {
257258 // Verify recipients
258259 stakingTx . recipients [ 0 ] . amount . should . equal ( largeAmount ) ;
259260 } ) ;
261+
262+ it ( 'should build a signed tx and validate its toJson' , async function ( ) {
263+ const txBuilder = factory . from ( testData . STAKING_TRANSACTION ) ;
264+ const tx = txBuilder . transaction as StakingTransaction ;
265+ const toJson = tx . toJson ( ) ;
266+ toJson . id . should . equal ( '0x4fd543eb5ac4e4b1a3eeda7335cd8ba449e5aef6dff243a55d83daf480526e11' ) ;
267+ toJson . stakingContractAddress ?. should . equal ( '0x1ec1d168574603ec35b9d229843b7c2b44bcb770' ) ;
268+ toJson . amountToStake ?. should . equal ( '0xde0b6b3a7640000' ) ;
269+ toJson . nonce . should . equal ( '449037' ) ;
270+ toJson . gas . should . equal ( 47565 ) ;
271+ toJson . gasPriceCoef . should . equal ( 128 ) ;
272+ toJson . expiration . should . equal ( 64 ) ;
273+ toJson . chainTag . should . equal ( 39 ) ;
274+ } ) ;
260275 } ) ;
261276} ) ;
You can’t perform that action at this time.
0 commit comments