Skip to content

Commit

Permalink
transaction to claim x algo fees
Browse files Browse the repository at this point in the history
  • Loading branch information
gidonkatten committed Jan 14, 2025
1 parent 3b458bc commit 41fa686
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/xalgo/consensus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,44 @@ function prepareUnstakeTransactions(
return getTxnsAfterResourceAllocation(consensusConfig, consensusState, txns, [receiverAddr], senderAddr, params);
}

/**
*
* Returns a group transaction to claim xALGO fees.
*
* @param consensusConfig - consensus application and xALGO config
* @param consensusState - current state of the consensus application
* @param senderAddr - account address for the sender
* @param receiverAddr - account address to receive the ALGO fees
* @param params - suggested params for the transactions with the fees overwritten
* @returns Transaction[] claim fees transactions
*/
function prepareClaimFeesTransactions(
consensusConfig: ConsensusConfig,
consensusState: ConsensusState,
senderAddr: string,
receiverAddr: string,
params: SuggestedParams,
): Transaction[] {
const { consensusAppId } = consensusConfig;

const atc = new AtomicTransactionComposer();
atc.addMethodCall({
sender: senderAddr,
signer,
appID: consensusAppId,
method: getMethodByName(xAlgoABIContract.methods, "claim_fee"),
methodArgs: [],
suggestedParams: { ...params, flatFee: true, fee: 2000 },
});

// allocate resources
const txns = atc.buildGroup().map(({ txn }) => {
txn.group = undefined;
return txn;
});
return getTxnsAfterResourceAllocation(consensusConfig, consensusState, txns, [receiverAddr], senderAddr, params);
}

/**
*
* Only for third-party node runners.
Expand Down Expand Up @@ -649,6 +687,7 @@ export {
prepareDelayedStakeTransactions,
prepareClaimDelayedStakeTransactions,
prepareUnstakeTransactions,
prepareClaimFeesTransactions,
prepareSetProposerAdminTransaction,
prepareRegisterProposerOnlineTransactions,
prepareRegisterProposerOfflineTransaction,
Expand Down

0 comments on commit 41fa686

Please sign in to comment.