@@ -2,7 +2,6 @@ import { coins } from '@bitgo/statics';
22import { TransactionBuilderFactory , TransferTransaction } from '../../src' ;
33import * as testData from '../resources/apt' ;
44import utils from '../../src/lib/utils' ;
5-
65import { TransactionType } from '@bitgo/sdk-core' ;
76import should from 'should' ;
87
@@ -49,7 +48,7 @@ describe('Apt Transfer Transaction', () => {
4948 ) ;
5049 } ) ;
5150
52- it ( 'should build a transfer tx from a signed raw tx' , async function ( ) {
51+ it ( 'should build and send a signed tx' , async function ( ) {
5352 const txBuilder = factory . from ( testData . TRANSFER ) ;
5453 const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
5554 should . equal ( tx . type , TransactionType . Send ) ;
@@ -75,6 +74,66 @@ describe('Apt Transfer Transaction', () => {
7574 should . equal ( utils . isValidRawTransaction ( rawTx ) , true ) ;
7675 should . equal ( rawTx , testData . TRANSFER ) ;
7776 } ) ;
77+
78+ it ( 'should succeed to validate a valid signablePayload' , async function ( ) {
79+ const transaction = new TransferTransaction ( coins . get ( 'tapt' ) ) ;
80+ const txBuilder = factory . getTransferBuilder ( transaction ) ;
81+ txBuilder . sender ( testData . sender2 . address ) ;
82+ txBuilder . recipient ( testData . recipients [ 0 ] ) ;
83+ txBuilder . gasData ( {
84+ maxGasAmount : 200000 ,
85+ gasUnitPrice : 100 ,
86+ } ) ;
87+ txBuilder . sequenceNumber ( 14 ) ;
88+ txBuilder . expirationTime ( 1736246155 ) ;
89+ const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
90+ const signablePayload = tx . signablePayload ;
91+ should . equal (
92+ signablePayload . toString ( 'hex' ) ,
93+ 'b5e97db07fa0bd0e5598aa3643a9bc6f6693bddc1a9fec9e674a461eaa00b193c8f02d25aa698b3e9fbd8a08e8da4c8ee261832a25a4cde8731b5ec356537d090e0000000000000002000000000000000000000000000000000000000000000000000000000000000104636f696e087472616e73666572010700000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e000220f7405c28a02cf5bab4ea4498240bb3579db45951794eb1c843bef0534c093ad908e803000000000000400d03000000000064000000000000008b037d670000000002'
94+ ) ;
95+ } ) ;
96+
97+ it ( 'should build a unsigned tx and validate its toJson' , async function ( ) {
98+ const transaction = new TransferTransaction ( coins . get ( 'tapt' ) ) ;
99+ const txBuilder = factory . getTransferBuilder ( transaction ) ;
100+ txBuilder . sender ( testData . sender2 . address ) ;
101+ txBuilder . recipient ( testData . recipients [ 0 ] ) ;
102+ txBuilder . gasData ( {
103+ maxGasAmount : 200000 ,
104+ gasUnitPrice : 100 ,
105+ } ) ;
106+ txBuilder . sequenceNumber ( 14 ) ;
107+ txBuilder . expirationTime ( 1736246155 ) ;
108+ const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
109+ const toJson = tx . toJson ( ) ;
110+ should . equal ( toJson . id , 'UNAVAILABLE' ) ;
111+ should . equal ( toJson . sender , testData . sender2 . address ) ;
112+ should . deepEqual ( toJson . recipient , {
113+ address : testData . recipients [ 0 ] . address ,
114+ amount : testData . recipients [ 0 ] . amount ,
115+ } ) ;
116+ should . equal ( toJson . sequenceNumber , 14 ) ;
117+ should . equal ( toJson . maxGasAmount , 200000 ) ;
118+ should . equal ( toJson . gasUnitPrice , 100 ) ;
119+ should . equal ( toJson . expirationTime , 1736246155 ) ;
120+ } ) ;
121+
122+ it ( 'should build a signed tx and validate its toJson' , async function ( ) {
123+ const txBuilder = factory . from ( testData . TRANSFER ) ;
124+ const tx = ( await txBuilder . build ( ) ) as TransferTransaction ;
125+ const toJson = tx . toJson ( ) ;
126+ should . equal ( toJson . id , '0x43ea7697550d5effb68c47488fd32a7756ee418e8d2be7d6b7f634f3ac0d7766' ) ;
127+ should . equal ( toJson . sender , '0xc8f02d25aa698b3e9fbd8a08e8da4c8ee261832a25a4cde8731b5ec356537d09' ) ;
128+ should . deepEqual ( toJson . recipient , {
129+ address : '0xf7405c28a02cf5bab4ea4498240bb3579db45951794eb1c843bef0534c093ad9' ,
130+ amount : '1000' ,
131+ } ) ;
132+ should . equal ( toJson . sequenceNumber , 23 ) ;
133+ should . equal ( toJson . maxGasAmount , 200000 ) ;
134+ should . equal ( toJson . gasUnitPrice , 100 ) ;
135+ should . equal ( toJson . expirationTime , 1735818272 ) ;
136+ } ) ;
78137 } ) ;
79138
80139 describe ( 'Fail' , ( ) => {
0 commit comments