Skip to content

Commit

Permalink
fix(sdk): auto-add boostcore as ManagedBudget manager
Browse files Browse the repository at this point in the history
Deploying a budget from `core` should auto-add that core instance as a
manager, or the user will get an error if they don't add it themselves.
This might be address in boostxyz/boost, but it's probably better if
this affordance lives in the sdk.
  • Loading branch information
topocount committed Dec 18, 2024
1 parent d32f677 commit 5c1ea17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/few-pugs-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@boostxyz/sdk": minor
---

auto-add boostcore as a manager in ManagedBudget
12 changes: 11 additions & 1 deletion packages/sdk/src/BoostCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,13 @@ export class BoostCore extends Deployable<
* @returns {ManagedBudget}
*/
ManagedBudget(options: DeployablePayloadOrAddress<ManagedBudgetPayload>) {
if (
typeof options !== 'string' &&
!options.authorized.includes(this.assertValidAddress())
) {
options.authorized = [this.assertValidAddress(), ...options.authorized];
options.roles = [Roles.MANAGER, ...options.roles];
}
return new ManagedBudget(
{ config: this._config, account: this._account },
options,
Expand All @@ -1301,7 +1308,10 @@ export class BoostCore extends Deployable<
ManagedBudgetWithFees(
options: DeployablePayloadOrAddress<ManagedBudgetWithFeesPayload>,
) {
if (typeof options !== 'string') {
if (
typeof options !== 'string' &&
!options.authorized.includes(this.assertValidAddress())
) {
options.authorized = [this.assertValidAddress(), ...options.authorized];
options.roles = [Roles.MANAGER, ...options.roles];
}
Expand Down

0 comments on commit 5c1ea17

Please sign in to comment.