Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOOST-5262] feat(sdk): TransparentBudget implementation #421

Merged
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
5 changes: 5 additions & 0 deletions .changeset/fifty-hotels-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@boostxyz/sdk": minor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we also want to open up a changeset against evm?

Copy link
Contributor Author

@sammccord sammccord Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't publish evm so it doesn't really matter, also this pr doesn't alter contract logic

---

TransparentBudget implementation
12 changes: 7 additions & 5 deletions packages/cli/src/commands/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,13 @@ async function fundBudget(
await erc20.mint(options.account.address, amount);

await erc20.approve(budget.assertValidAddress(), amount);
await budget.allocate({
amount,
asset: erc20.assertValidAddress(),
target: options.account.address,
});
if ('allocate' in budget) {
await budget.allocate({
amount,
asset: erc20.assertValidAddress(),
target: options.account.address,
});
}

return { budget, erc20 };
}
Expand Down
13 changes: 10 additions & 3 deletions packages/evm/contracts/BoostCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ contract BoostCore is Ownable, ReentrancyGuard {
{
claimIncentiveFor(boostId_, incentiveId_, referrer_, data_, msg.sender);
}

/// @notice Claim an incentive for a Boost on behalf of another user
/// @param boostId_ The ID of the Boost
/// @param incentiveId_ The ID of the AIncentive
Expand All @@ -385,7 +386,9 @@ contract BoostCore is Ownable, ReentrancyGuard {
AIncentive incentiveContract = boost.incentives[incentiveId_];

// Validate the claimant against the allow list and the validator
if (!boost.allowList.isAllowed(claimant, data_)) revert BoostError.Unauthorized();
if (!boost.allowList.isAllowed(claimant, data_)) {
revert BoostError.Unauthorized();
}

// Call validate and pass along the value
if (!boost.validator.validate{value: msg.value}(boostId_, incentiveId_, claimant, data_)) {
Expand Down Expand Up @@ -636,8 +639,12 @@ contract BoostCore is Ownable, ReentrancyGuard {
bytes memory preflight = incentive.preflight(incentiveParams);
if (preflight.length != 0) {
(bytes memory disbursal, uint256 feeAmount) = _getFeeDisbursal(preflight, protocolFee_);
if (!budget_.disburse(disbursal)) revert BoostError.InvalidInitialization();
if (!budget_.disburse(preflight)) revert BoostError.InvalidInitialization();
if (!budget_.disburse(disbursal)) {
revert BoostError.InvalidInitialization();
}
if (!budget_.disburse(preflight)) {
revert BoostError.InvalidInitialization();
}

ABudget.Transfer memory request = abi.decode(preflight, (ABudget.Transfer));

Expand Down
12 changes: 12 additions & 0 deletions packages/evm/script/solidity/ComponentInterface.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {AManagedBudget} from "contracts/budgets/AManagedBudget.sol";
import {AManagedBudgetWithFees} from "contracts/budgets/AManagedBudgetWithFees.sol";
import {AManagedBudgetWithFeesV2} from "contracts/budgets/AManagedBudgetWithFeesV2.sol";
import {AVestingBudget} from "contracts/budgets/AVestingBudget.sol";
import {ATransparentBudget} from "contracts/budgets/ATransparentBudget.sol";

import {ASignerValidator} from "contracts/validators/ASignerValidator.sol";
import {ALimitedSignerValidator} from "contracts/validators/ALimitedSignerValidator.sol";
Expand Down Expand Up @@ -46,6 +47,7 @@ contract LogComponentInterface is ScriptUtils {
_getInterfaceAERC20PeggedVariableCriteriaIncentiveV2();
_getInterfaceACloneable();
_getInterfaceABudget();
_getInterfaceATransparentBudget();
_getInterfaceAManagedBudget();
_getInterfaceAManagedBudgetWithFees();
_getInterfaceAManagedBudgetWithFeesV2();
Expand Down Expand Up @@ -144,6 +146,16 @@ contract LogComponentInterface is ScriptUtils {
componentJson = componentJsonKey.serialize("ABudget", interfaceId);
}

function _getInterfaceATransparentBudget() internal {
string memory interfaceId = uint256(
uint32(type(ATransparentBudget).interfaceId)
).toHexString(4);
componentJson = componentJsonKey.serialize(
"ATransparentBudget",
interfaceId
);
}

function _getInterfaceAVestingBudget() internal {
string memory interfaceId = uint256(
uint32(type(AVestingBudget).interfaceId)
Expand Down
9 changes: 9 additions & 0 deletions packages/evm/test/budgets/TransparentBudget.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ contract TransparentBudgetTest is Test, IERC1155Receiver {
vm.assertEq(mockERC20.balanceOf(boostOwner), 110 ether);
}

////////////////////////////////////
// TransparentBudget.getComponentInterface //
////////////////////////////////////

function testGetComponentInterface() public view {
// Ensure the contract supports the ABudget interface
console.logBytes4(budget.getComponentInterface());
}

///////////////////////////
// Test Helper Functions //
///////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
}
},
"scripts": {
"build": "mkdir -p dist && vite build && tsc -p ./tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
"build": "mkdir -p dist && vite build && npx tsc -p ./tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
"typecheck": "tsc -p ./tsconfig.build.json --noEmit",
"lint:ci": "npx biome ci",
"lint": "npx biome check",
Expand Down
Loading
Loading