@@ -18,16 +18,17 @@ import {
1818 Stringifier ,
1919 throwReceiptErrorsFromOutcomes ,
2020 endless ,
21- parseOutcomeValue ,
21+ parseOutcome ,
2222 BlockQuery ,
2323} from '../utils' ;
2424import { MultiSendWalletSelectorSendOptions } from '../types' ;
2525import { BigNumber } from 'bignumber.js' ;
26+ import { SendError } from '../errors' ;
2627
2728let multiSendWalletSelector : MultiSendWalletSelector | null = null ;
2829
2930export async function setupMultiSendWalletSelector (
30- options : MultiSendWalletSelectorOptions
31+ options : MultiSendWalletSelectorOptions ,
3132) : Promise < MultiSendWalletSelector > {
3233 if ( ! multiSendWalletSelector ) {
3334 let selector : WalletSelector ;
@@ -54,7 +55,7 @@ export async function setupMultiSendWalletSelector(
5455
5556 async isLoginAccessKeyActive (
5657 accountId ?: string ,
57- requiredMinAllowance = Amount . parse ( '0.01' , 'NEAR' )
58+ requiredMinAllowance = Amount . parse ( '0.01' , 'NEAR' ) ,
5859 ) : Promise < boolean > {
5960 accountId = accountId ?? this . getActiveAccountId ( ) ;
6061 if ( ! accountId ) {
@@ -73,7 +74,7 @@ export async function setupMultiSendWalletSelector(
7374 const accessKeys = await this . near . account ( accountId ) . then ( ( account ) => account . getAccessKeys ( ) ) ;
7475 const loginAccessKey = accessKeys . find (
7576 ( accessKey ) =>
76- PublicKey . fromString ( accessKey . public_key ) . toString ( ) === PublicKey . fromString ( loginPublicKey ) . toString ( )
77+ PublicKey . fromString ( accessKey . public_key ) . toString ( ) === PublicKey . fromString ( loginPublicKey ) . toString ( ) ,
7778 ) ;
7879
7980 if ( ! loginAccessKey ) {
@@ -115,7 +116,7 @@ export async function setupMultiSendWalletSelector(
115116
116117 async call < Value , Args = EmptyArgs > ( options : MultiSendWalletSelectorCallOptions < Value , Args > ) : Promise < Value > {
117118 const outcome = await this . callRaw ( options ) ;
118- return parseOutcomeValue ( outcome , options . parser ) ;
119+ return parseOutcome ( outcome , options . parser ) ;
119120 } ,
120121
121122 async callRaw < Args = EmptyArgs > ( {
@@ -127,7 +128,7 @@ export async function setupMultiSendWalletSelector(
127128 stringifier,
128129 ...options
129130 } : MultiSendWalletSelectorCallRawOptions < Args > ) : Promise < FinalExecutionOutcome > {
130- const mTx = MultiTransaction . batch ( contractId ) . functionCall ( {
131+ const mTx = MultiTransaction . batch ( { receiverId : contractId } ) . functionCall ( {
131132 methodName,
132133 args,
133134 attachedDeposit,
@@ -141,20 +142,24 @@ export async function setupMultiSendWalletSelector(
141142 async send < Value > ( mTx : MultiTransaction , options ?: MultiSendWalletSelectorSendOptions < Value > ) : Promise < Value > {
142143 const outcomes = await this . sendRaw ( mTx , options ) ;
143144 const outcome = outcomes ?. [ outcomes . length - 1 ] ;
144- return parseOutcomeValue ( outcome , options ?. parser ) ;
145+ return parseOutcome ( outcome , options ?. parser ) ;
145146 } ,
146147
147148 async sendRaw (
148149 mTx : MultiTransaction ,
149- options ?: MultiSendWalletSelectorSendRawOptions
150+ options ?: MultiSendWalletSelectorSendRawOptions ,
150151 ) : Promise < FinalExecutionOutcome [ ] > {
151- const wallet = await this . wallet ( options ?. walletId ) ;
152152 const transactions = parseNearWalletSelectorTransactions ( mTx ) ;
153- let outcomes : FinalExecutionOutcome [ ] | undefined ;
154153
155154 if ( transactions . length === 0 ) {
156- throw Error ( `Transaction not found.` ) ;
157- } else if ( transactions . length === 1 ) {
155+ throw new SendError ( 'Transaction not found.' ) ;
156+ }
157+
158+ const wallet = await this . wallet ( options ?. walletId ) ;
159+
160+ let outcomes : FinalExecutionOutcome [ ] | undefined ;
161+
162+ if ( transactions . length === 1 ) {
158163 const outcome = await wallet . signAndSendTransaction ( {
159164 ...transactions [ 0 ] ,
160165 callbackUrl : options ?. callbackUrl ,
0 commit comments