Skip to content

Commit

Permalink
Support treasury spend from scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
wliyongfeng committed Feb 3, 2024
1 parent ca9013d commit 23d0976
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,27 @@ function isSpendLocal(call = {}) {
return checkArgNames(call, ["amount", "beneficiary"]);
}

async function extractTreasuryCalls(call, indexer) {
function isScheduleNamed(call = {}) {
const { section, method } = call;
return "scheduler" === section && "scheduleNamedAfter" === method;
}

async function extractSpendCalls(call, indexer) {
const spendCalls = [];
await handleWrappedCall(call, null, indexer, [], innerCall => {
await handleWrappedCall(call, null, indexer, [], async innerCall => {
if (isSpendAmountCall(innerCall) || isSpendLocal(innerCall)) {
spendCalls.push(innerCall);
} else if (isScheduleNamed(innerCall)) {
const calls = await extractSpendCalls(innerCall.args[4], indexer);
spendCalls.push(...calls);
}
});

return spendCalls;
}

async function extractTreasuryCalls(call, indexer) {
const spendCalls = await extractSpendCalls(call, indexer);
if (spendCalls.length <= 0) {
return {};
}
Expand Down

0 comments on commit 23d0976

Please sign in to comment.