2222 * MethodCallParams is an object that holds all parameters necessary to invoke {@link AtomicTransactionComposer#addMethodCall(MethodCallParams)}
2323 */
2424public class MethodCallParams {
25+
2526 // if the abi type argument number > 15, then the abi types after 14th should be wrapped in a tuple
2627 private static final int MAX_ABI_ARG_TYPE_LEN = 15 ;
2728
@@ -35,7 +36,8 @@ public class MethodCallParams {
3536 public final List <Address > foreignAccounts ;
3637 public final List <Long > foreignAssets ;
3738 public final List <Long > foreignApps ;
38-
39+ public final List <AppBoxReference > boxReferences ;
40+
3941 public final TEALProgram approvalProgram , clearProgram ;
4042 public final StateSchema globalStateSchema , localStateSchema ;
4143 public final Long extraPages ;
@@ -54,17 +56,13 @@ public class MethodCallParams {
5456 public final String genesisID ;
5557 public final Digest genesisHash ;
5658
57- /**
58- * NOTE: it's strongly suggested to use {@link com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder}
59- * instead of this constructor to create a new MethodCallParams object.
60- */
61- public MethodCallParams (Long appID , Method method , List <Object > methodArgs , Address sender ,
62- Transaction .OnCompletion onCompletion , byte [] note , byte [] lease , String genesisID , Digest genesisHash ,
63- BigInteger firstValid , BigInteger lastValid , BigInteger fee , BigInteger flatFee ,
64- Address rekeyTo , TxnSigner signer ,
65- List <Address > fAccounts , List <Long > fAssets , List <Long > fApps ,
66- TEALProgram approvalProgram , TEALProgram clearProgram ,
67- StateSchema globalStateSchema , StateSchema localStateSchema , Long extraPages ) {
59+ protected MethodCallParams (Long appID , Method method , List <Object > methodArgs , Address sender ,
60+ Transaction .OnCompletion onCompletion , byte [] note , byte [] lease , String genesisID , Digest genesisHash ,
61+ BigInteger firstValid , BigInteger lastValid , BigInteger fee , BigInteger flatFee ,
62+ Address rekeyTo , TxnSigner signer ,
63+ List <Address > fAccounts , List <Long > fAssets , List <Long > fApps , List <AppBoxReference > boxes ,
64+ TEALProgram approvalProgram , TEALProgram clearProgram ,
65+ StateSchema globalStateSchema , StateSchema localStateSchema , Long extraPages ) {
6866 if (appID == null || method == null || sender == null || onCompletion == null || signer == null || genesisID == null || genesisHash == null || firstValid == null || lastValid == null || (fee == null && flatFee == null ))
6967 throw new IllegalArgumentException ("Method call builder error: some required field not added" );
7068 if (fee != null && flatFee != null )
@@ -113,16 +111,38 @@ public MethodCallParams(Long appID, Method method, List<Object> methodArgs, Addr
113111 this .foreignAccounts = new ArrayList <>(fAccounts );
114112 this .foreignAssets = new ArrayList <>(fAssets );
115113 this .foreignApps = new ArrayList <>(fApps );
114+ this .boxReferences = new ArrayList <>(boxes );
116115 this .approvalProgram = approvalProgram ;
117116 this .clearProgram = clearProgram ;
118117 this .globalStateSchema = globalStateSchema ;
119118 this .localStateSchema = localStateSchema ;
120119 this .extraPages = extraPages ;
121120 }
122121
122+ /**
123+ * Deprecated - Use {@link com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder}
124+ * to create a new MethodCallParams object instead.
125+ */
126+ @ Deprecated
127+ public MethodCallParams (Long appID , Method method , List <Object > methodArgs , Address sender ,
128+ Transaction .OnCompletion onCompletion , byte [] note , byte [] lease , String genesisID , Digest genesisHash ,
129+ BigInteger firstValid , BigInteger lastValid , BigInteger fee , BigInteger flatFee ,
130+ Address rekeyTo , TxnSigner signer ,
131+ List <Address > fAccounts , List <Long > fAssets , List <Long > fApps ,
132+ TEALProgram approvalProgram , TEALProgram clearProgram ,
133+ StateSchema globalStateSchema , StateSchema localStateSchema , Long extraPages ) {
134+ this (appID , method , methodArgs , sender ,
135+ onCompletion , note , lease , genesisID , genesisHash ,
136+ firstValid , lastValid , fee , flatFee ,
137+ rekeyTo , signer ,
138+ fAccounts , fAssets , fApps , new ArrayList (),
139+ approvalProgram , clearProgram ,
140+ globalStateSchema , localStateSchema , extraPages );
141+ }
142+
123143 /**
124144 * Create the transactions which will carry out the specified method call.
125- *
145+ * <p>
126146 * The list of transactions returned by this function will have the same length as method.getTxnCallCount().
127147 */
128148 public List <TransactionWithSigner > createTransactions () {
@@ -136,6 +156,7 @@ public List<TransactionWithSigner> createTransactions() {
136156 List <Address > foreignAccounts = new ArrayList <>(this .foreignAccounts );
137157 List <Long > foreignAssets = new ArrayList <>(this .foreignAssets );
138158 List <Long > foreignApps = new ArrayList <>(this .foreignApps );
159+ List <AppBoxReference > boxReferences = new ArrayList <>(this .boxReferences );
139160
140161 for (int i = 0 ; i < this .method .args .size (); i ++) {
141162 Method .Arg argT = this .method .args .get (i );
@@ -199,21 +220,22 @@ public List<TransactionWithSigner> createTransactions() {
199220 ApplicationCallTransactionBuilder <?> txBuilder = ApplicationCallTransactionBuilder .Builder ();
200221
201222 txBuilder
202- .firstValid (this .firstValid )
203- .lastValid (this .lastValid )
204- .genesisHash (this .genesisHash )
205- .genesisID (this .genesisID )
206- .fee (this .fee )
207- .flatFee (this .flatFee )
208- .note (this .note )
209- .lease (this .lease )
210- .rekey (this .rekeyTo )
211- .sender (this .sender )
212- .applicationId (this .appID )
213- .args (encodedABIArgs )
214- .accounts (foreignAccounts )
215- .foreignApps (foreignApps )
216- .foreignAssets (foreignAssets );
223+ .firstValid (this .firstValid )
224+ .lastValid (this .lastValid )
225+ .genesisHash (this .genesisHash )
226+ .genesisID (this .genesisID )
227+ .fee (this .fee )
228+ .flatFee (this .flatFee )
229+ .note (this .note )
230+ .lease (this .lease )
231+ .rekey (this .rekeyTo )
232+ .sender (this .sender )
233+ .applicationId (this .appID )
234+ .args (encodedABIArgs )
235+ .accounts (foreignAccounts )
236+ .foreignApps (foreignApps )
237+ .foreignAssets (foreignAssets )
238+ .boxReferences (boxReferences );
217239
218240 Transaction tx = txBuilder .build ();
219241
@@ -228,7 +250,7 @@ public List<TransactionWithSigner> createTransactions() {
228250 tx .localStateSchema = this .localStateSchema ;
229251 if (this .extraPages != null )
230252 tx .extraPages = this .extraPages ;
231-
253+
232254 TransactionWithSigner methodCall = new TransactionWithSigner (tx , this .signer );
233255 transactionArgs .add (methodCall );
234256
@@ -245,12 +267,12 @@ private static boolean checkTransactionType(TransactionWithSigner tws, String tx
245267 * and this function will return an index that can be used to reference `objectToBeAdded` in `objectArray`.
246268 *
247269 * @param objectToBeAdded - The value to add to the array. If this value is already present in the array,
248- * it will not be added again. Instead, the existing index will be returned.
249- * @param objectArray - The existing foreign array. This input may be modified to append `valueToAdd`.
250- * @param zerothObject - If provided, this value indicated two things: the 0 value is special for this
251- * array, so all indexes into `objectArray` must start at 1; additionally, if `objectToBeAdded` equals
252- * `zerothValue`, then `objectToBeAdded` will not be added to the array, and instead the 0 indexes will
253- * be returned.
270+ * it will not be added again. Instead, the existing index will be returned.
271+ * @param objectArray - The existing foreign array. This input may be modified to append `valueToAdd`.
272+ * @param zerothObject - If provided, this value indicated two things: the 0 value is special for this
273+ * array, so all indexes into `objectArray` must start at 1; additionally, if `objectToBeAdded` equals
274+ * `zerothValue`, then `objectToBeAdded` will not be added to the array, and instead the 0 indexes will
275+ * be returned.
254276 * @return An index that can be used to reference `valueToAdd` in `array`.
255277 */
256278 private static <T > int populateForeignArrayIndex (T objectToBeAdded , List <T > objectArray , T zerothObject ) {
0 commit comments