Skip to content

Commit c95775f

Browse files
committed
fix: add 'Assets' and 'Applications' to InnerTx
1 parent 2bcef8f commit c95775f

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

packages/runtime/src/lib/itxn.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,21 @@ const TxnTypeMap: { [key: string]: { version: number; field: string | number } }
2727
6: { version: 6, field: "appl" },
2828
};
2929

30+
// each value here is number but they come in array
31+
const arrayNumberFields = new Set(["Assets", "Applications"]);
3032
// requires their type as number
3133
const numberTxnFields: { [key: number]: Set<string> } = {
3234
1: new Set(),
3335
2: new Set(),
3436
3: new Set(),
3537
4: new Set(),
36-
5: new Set(["Fee", "FreezeAssetFrozen", "ConfigAssetDecimals", "ConfigAssetDefaultFrozen"]),
38+
5: new Set([
39+
"Fee",
40+
"FreezeAssetFrozen",
41+
"ConfigAssetDecimals",
42+
"ConfigAssetDefaultFrozen",
43+
...arrayNumberFields,
44+
]),
3745
};
3846
numberTxnFields[6] = cloneDeep(numberTxnFields[5]);
3947
["VoteFirst", "VoteLast", "VoteKeyDilution", "Nonparticipation", "ApplicationID"].forEach(
@@ -217,6 +225,7 @@ export function setInnerTxField(
217225
}
218226
break;
219227
}
228+
220229
case "ConfigAssetDecimals": {
221230
const assetDecimals = txValue as bigint;
222231
if (assetDecimals > 19n || assetDecimals < 0n) {
@@ -297,7 +306,7 @@ export function setInnerTxField(
297306
(subTxn as any).apar = (subTxn as any).apar ?? {};
298307
(subTxn as any).apar[encodedField] = txValue;
299308
} else {
300-
if (field === "ApplicationArgs") {
309+
if (field === "ApplicationArgs" || arrayNumberFields.has(field)) {
301310
if ((subTxn as any)[encodedField] === undefined) {
302311
(subTxn as any)[encodedField] = [];
303312
}

packages/runtime/test/fixtures/inner-transaction/assets/approval-payment.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ def approval_program():
1515
TxnField.type_enum: TxnType.Payment,
1616
TxnField.receiver: Txn.sender(),
1717
TxnField.amount: Int(1000000),
18-
}
18+
TxnField.assets: [
19+
Int(1)
20+
],
21+
},
1922
),
2023
InnerTxnBuilder.Submit(),
2124

@@ -26,6 +29,9 @@ def approval_program():
2629
TxnField.type_enum: TxnType.Payment,
2730
TxnField.receiver: Txn.accounts[1],
2831
TxnField.amount: Int(2000000),
32+
TxnField.applications: [
33+
Int(1)
34+
],
2935
}
3036
),
3137
InnerTxnBuilder.Submit(),

0 commit comments

Comments
 (0)