mapArguments method
dynamic
mapArguments(
- dynamic fn(
- dynamic arg,
- dynamic command
Implementation
mapArguments(dynamic Function(dynamic arg, dynamic command) fn) {
for (final command in commands) {
if (command["MoveCall"] != null) {
command["MoveCall"]["arguments"] = command["MoveCall"]["arguments"].map((arg) => fn(arg, command)).toList();
} else if (command["TransferObjects"] != null) {
command["TransferObjects"]["objects"] = command["TransferObjects"]["objects"].map((arg) =>
fn(arg, command),
);
command["TransferObjects"]["address"] = fn(command["TransferObjects"]["address"], command);
} else if (command["SplitCoins"] != null) {
command["SplitCoins"]["coin"] = fn(command["SplitCoins"]["coin"], command);
command["SplitCoins"]["amounts"] = command["SplitCoins"]["amounts"].map((arg) => fn(arg, command));
} else if (command["MergeCoins"] != null) {
command["MergeCoins"]["destination"] = fn(command["MergeCoins"]["destination"], command);
command["MergeCoins"]["sources"] = command["MergeCoins"]["sources"].map((arg) => fn(arg, command));
} else if (command["MakeMoveVec"] != null) {
command["MakeMoveVec"]["elements"] = command["MakeMoveVec"]["elements"].map((arg) =>
fn(arg, command),
);
} else if (command["Upgrade"] != null) {
command["Upgrade"]["ticket"] = fn(command["Upgrade"]["ticket"], command);
} else if (command["\$Intent"] != null) {
final inputs = command["\$Intent"]["inputs"];
command["\$Intent"]["inputs"] = {};
for (final [key, value] in inputs) {
command["\$Intent"]["inputs"][key] = value is Iterable
? value.map((arg) => fn(arg, command))
: fn(value, command);
}
} else if (command["Publish"] != null) {
} else {
throw ArgumentError("Unexpected transaction kind: $command");
}
}
}