@@ -30,6 +30,8 @@ import {
3030 BaseTssUtils ,
3131 KeyType ,
3232 SendManyOptions ,
33+ PopulatedIntent ,
34+ TxRequestVersion ,
3335} from '@bitgo/sdk-core' ;
3436
3537import { TestBitGo } from '@bitgo/sdk-test' ;
@@ -46,6 +48,12 @@ require('should-sinon');
4648
4749nock . disableNetConnect ( ) ;
4850
51+ type CreateTxRequestBody = {
52+ intent : PopulatedIntent ;
53+ apiversion : TxRequestVersion ;
54+ preview ?: boolean ;
55+ } ;
56+
4957describe ( 'V2 Wallet:' , function ( ) {
5058 const reqId = new RequestTracer ( ) ;
5159 const bitgo = TestBitGo . decorate ( BitGo , { env : 'test' } ) ;
@@ -4387,5 +4395,46 @@ describe('V2 Wallet:', function () {
43874395 sinon . stub ( BaseTssUtils . default . prototype , 'sendTxRequest' ) . resolves ( 'sendTxResponse' ) ;
43884396 await adaWallet . sendMany ( sendManyParams ) ;
43894397 } ) ;
4398+
4399+ it ( 'Should send senderAddress in payment intent when using sendmany' , async function ( ) {
4400+ const sendManyParams = {
4401+ type : 'transfer' ,
4402+ recipients : [
4403+ {
4404+ address : 'address' ,
4405+ amount : '1000' ,
4406+ } ,
4407+ ] ,
4408+ senderAddress : 'senderAddr1' ,
4409+ } ;
4410+
4411+ nock ( bgUrl )
4412+ . post ( `/api/v2/wallet/${ adaWallet . id ( ) } /txrequests` )
4413+ . reply ( ( url , body : nock . Body ) => {
4414+ const createTxRequestBody = body as CreateTxRequestBody ;
4415+ createTxRequestBody . intent . intentType . should . equal ( 'payment' ) ;
4416+ createTxRequestBody . intent . senderAddress ?. should . equal ( 'senderAddr1' ) ;
4417+
4418+ return [
4419+ 200 ,
4420+ {
4421+ apiVersion : 'lite' ,
4422+ unsignedTxs : [
4423+ {
4424+ unsignedTx : {
4425+ serializedTxHex : 'serializedTxHex' ,
4426+ feeInfo : 'fee info' ,
4427+ } ,
4428+ } ,
4429+ ] ,
4430+ } ,
4431+ ] ;
4432+ } ) ;
4433+
4434+ sinon . stub ( adaWallet . baseCoin , 'verifyTransaction' ) . resolves ( true ) ;
4435+ sinon . stub ( adaWallet , 'signTransaction' ) . resolves ( { txRequestId : 'txRequestId' } ) ;
4436+ sinon . stub ( BaseTssUtils . default . prototype , 'sendTxRequest' ) . resolves ( 'sendTxResponse' ) ;
4437+ await adaWallet . sendMany ( sendManyParams ) . should . be . resolved ( ) ;
4438+ } ) ;
43904439 } ) ;
43914440} ) ;
0 commit comments