Skip to content

Commit 836d814

Browse files
sammccordtopocount
andauthored
[BOOST-5262] feat(sdk): TransparentBudget implementation (#421)
Co-authored-by: Kevin Siegler <[email protected]>
1 parent 015e29e commit 836d814

File tree

13 files changed

+953
-37
lines changed

13 files changed

+953
-37
lines changed

.changeset/fifty-hotels-rhyme.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@boostxyz/sdk": minor
3+
---
4+
5+
TransparentBudget implementation

packages/cli/src/commands/seed.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,13 @@ async function fundBudget(
554554
await erc20.mint(options.account.address, amount);
555555

556556
await erc20.approve(budget.assertValidAddress(), amount);
557-
await budget.allocate({
558-
amount,
559-
asset: erc20.assertValidAddress(),
560-
target: options.account.address,
561-
});
557+
if ('allocate' in budget) {
558+
await budget.allocate({
559+
amount,
560+
asset: erc20.assertValidAddress(),
561+
target: options.account.address,
562+
});
563+
}
562564

563565
return { budget, erc20 };
564566
}

packages/evm/contracts/BoostCore.sol

+10-3
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ contract BoostCore is Ownable, ReentrancyGuard {
365365
{
366366
claimIncentiveFor(boostId_, incentiveId_, referrer_, data_, msg.sender);
367367
}
368+
368369
/// @notice Claim an incentive for a Boost on behalf of another user
369370
/// @param boostId_ The ID of the Boost
370371
/// @param incentiveId_ The ID of the AIncentive
@@ -385,7 +386,9 @@ contract BoostCore is Ownable, ReentrancyGuard {
385386
AIncentive incentiveContract = boost.incentives[incentiveId_];
386387

387388
// Validate the claimant against the allow list and the validator
388-
if (!boost.allowList.isAllowed(claimant, data_)) revert BoostError.Unauthorized();
389+
if (!boost.allowList.isAllowed(claimant, data_)) {
390+
revert BoostError.Unauthorized();
391+
}
389392

390393
// Call validate and pass along the value
391394
if (!boost.validator.validate{value: msg.value}(boostId_, incentiveId_, claimant, data_)) {
@@ -636,8 +639,12 @@ contract BoostCore is Ownable, ReentrancyGuard {
636639
bytes memory preflight = incentive.preflight(incentiveParams);
637640
if (preflight.length != 0) {
638641
(bytes memory disbursal, uint256 feeAmount) = _getFeeDisbursal(preflight, protocolFee_);
639-
if (!budget_.disburse(disbursal)) revert BoostError.InvalidInitialization();
640-
if (!budget_.disburse(preflight)) revert BoostError.InvalidInitialization();
642+
if (!budget_.disburse(disbursal)) {
643+
revert BoostError.InvalidInitialization();
644+
}
645+
if (!budget_.disburse(preflight)) {
646+
revert BoostError.InvalidInitialization();
647+
}
641648

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

packages/evm/script/solidity/ComponentInterface.s.sol

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {AManagedBudget} from "contracts/budgets/AManagedBudget.sol";
1212
import {AManagedBudgetWithFees} from "contracts/budgets/AManagedBudgetWithFees.sol";
1313
import {AManagedBudgetWithFeesV2} from "contracts/budgets/AManagedBudgetWithFeesV2.sol";
1414
import {AVestingBudget} from "contracts/budgets/AVestingBudget.sol";
15+
import {ATransparentBudget} from "contracts/budgets/ATransparentBudget.sol";
1516

1617
import {ASignerValidator} from "contracts/validators/ASignerValidator.sol";
1718
import {ALimitedSignerValidator} from "contracts/validators/ALimitedSignerValidator.sol";
@@ -46,6 +47,7 @@ contract LogComponentInterface is ScriptUtils {
4647
_getInterfaceAERC20PeggedVariableCriteriaIncentiveV2();
4748
_getInterfaceACloneable();
4849
_getInterfaceABudget();
50+
_getInterfaceATransparentBudget();
4951
_getInterfaceAManagedBudget();
5052
_getInterfaceAManagedBudgetWithFees();
5153
_getInterfaceAManagedBudgetWithFeesV2();
@@ -144,6 +146,16 @@ contract LogComponentInterface is ScriptUtils {
144146
componentJson = componentJsonKey.serialize("ABudget", interfaceId);
145147
}
146148

149+
function _getInterfaceATransparentBudget() internal {
150+
string memory interfaceId = uint256(
151+
uint32(type(ATransparentBudget).interfaceId)
152+
).toHexString(4);
153+
componentJson = componentJsonKey.serialize(
154+
"ATransparentBudget",
155+
interfaceId
156+
);
157+
}
158+
147159
function _getInterfaceAVestingBudget() internal {
148160
string memory interfaceId = uint256(
149161
uint32(type(AVestingBudget).interfaceId)

packages/evm/test/budgets/TransparentBudget.t.sol

+9
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ contract TransparentBudgetTest is Test, IERC1155Receiver {
214214
vm.assertEq(mockERC20.balanceOf(boostOwner), 110 ether);
215215
}
216216

217+
////////////////////////////////////
218+
// TransparentBudget.getComponentInterface //
219+
////////////////////////////////////
220+
221+
function testGetComponentInterface() public view {
222+
// Ensure the contract supports the ABudget interface
223+
console.logBytes4(budget.getComponentInterface());
224+
}
225+
217226
///////////////////////////
218227
// Test Helper Functions //
219228
///////////////////////////

packages/sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
}
217217
},
218218
"scripts": {
219-
"build": "mkdir -p dist && vite build && tsc -p ./tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
219+
"build": "mkdir -p dist && vite build && npx tsc -p ./tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
220220
"typecheck": "tsc -p ./tsconfig.build.json --noEmit",
221221
"lint:ci": "npx biome ci",
222222
"lint": "npx biome check",

0 commit comments

Comments
 (0)