Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions packages/runtime/src/lib/itxn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> } = {
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(
Expand Down Expand Up @@ -103,6 +111,8 @@ const acfgAddrTxnFields: { [key: number]: Set<string> } = {

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<string> } = {
5: new Set([
"Sender",
Expand All @@ -112,6 +122,7 @@ const otherAddrTxnFields: { [key: number]: Set<string> } = {
"AssetCloseTo",
"AssetReceiver",
"FreezeAssetAccount",
...arrayAddrFields,
]),
};

Expand Down Expand Up @@ -216,6 +227,7 @@ export function setInnerTxField(
}
break;
}

case "ConfigAssetDecimals": {
const assetDecimals = txValue as bigint;
if (assetDecimals > 19n || assetDecimals < 0n) {
Expand Down Expand Up @@ -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] = [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),

Expand All @@ -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(),
Expand Down