diff --git a/packages/runtime/src/lib/itxn.ts b/packages/runtime/src/lib/itxn.ts index 3dff523a4..31ccfa756 100644 --- a/packages/runtime/src/lib/itxn.ts +++ b/packages/runtime/src/lib/itxn.ts @@ -26,13 +26,21 @@ const TxnTypeMap: { [key: string]: { version: number; field: string | number } } 6: { version: 6, field: "appl" }, }; +// each value here is number but they come in array +const arrayNumberFields = new Set(["Assets", "Applications"]); // requires their type as number const numberTxnFields: { [key: number]: Set } = { 1: new Set(), 2: new Set(), 3: new Set(), 4: new Set(), - 5: new Set(["Fee", "FreezeAssetFrozen", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen"]), + 5: new Set([ + "Fee", + "FreezeAssetFrozen", + "ConfigAssetDecimals", + "ConfigAssetDefaultFrozen", + ...arrayNumberFields, + ]), }; numberTxnFields[6] = cloneDeep(numberTxnFields[5]); ["VoteFirst", "VoteLast", "VoteKeyDilution", "Nonparticipation", "ApplicationID"].forEach( @@ -103,6 +111,8 @@ const acfgAddrTxnFields: { [key: number]: Set } = { acfgAddrTxnFields[6] = cloneDeep(acfgAddrTxnFields[5]); +// each value here is Addr but they come in array +const arrayAddrFields = new Set(["Accounts"]); const otherAddrTxnFields: { [key: number]: Set } = { 5: new Set([ "Sender", @@ -112,6 +122,7 @@ const otherAddrTxnFields: { [key: number]: Set } = { "AssetCloseTo", "AssetReceiver", "FreezeAssetAccount", + ...arrayAddrFields, ]), }; @@ -216,6 +227,7 @@ export function setInnerTxField( } break; } + case "ConfigAssetDecimals": { const assetDecimals = txValue as bigint; if (assetDecimals > 19n || assetDecimals < 0n) { @@ -296,7 +308,11 @@ export function setInnerTxField( (subTxn as any).apar = (subTxn as any).apar ?? {}; (subTxn as any).apar[encodedField] = txValue; } else { - if (field === "ApplicationArgs") { + if ( + field === "ApplicationArgs" || + arrayNumberFields.has(field) || + arrayAddrFields.has(field) + ) { if ((subTxn as any)[encodedField] === undefined) { (subTxn as any)[encodedField] = []; } diff --git a/packages/runtime/test/fixtures/inner-transaction/assets/approval-payment.py b/packages/runtime/test/fixtures/inner-transaction/assets/approval-payment.py index 89c82b608..df5fba307 100644 --- a/packages/runtime/test/fixtures/inner-transaction/assets/approval-payment.py +++ b/packages/runtime/test/fixtures/inner-transaction/assets/approval-payment.py @@ -15,7 +15,10 @@ def approval_program(): TxnField.type_enum: TxnType.Payment, TxnField.receiver: Txn.sender(), TxnField.amount: Int(1000000), - } + TxnField.assets: [ + Int(1) + ], + }, ), InnerTxnBuilder.Submit(), @@ -26,6 +29,12 @@ def approval_program(): TxnField.type_enum: TxnType.Payment, TxnField.receiver: Txn.accounts[1], TxnField.amount: Int(2000000), + TxnField.applications: [ + Int(1) + ], + TxnField.accounts: [ + Global.current_application_address() + ], } ), InnerTxnBuilder.Submit(),