@boostxyz/sdk 1.1.0-alpha.22 → 1.1.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.cjs.map +1 -1
- package/dist/Actions/Action.js +6 -6
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +9 -6
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +820 -15
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +2 -2
- package/dist/AllowLists/OpenAllowList.d.ts +28 -28
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +28 -28
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +11 -10
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +28 -28
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore-Btl5BdAs.cjs +3 -0
- package/dist/BoostCore-Btl5BdAs.cjs.map +1 -0
- package/dist/{BoostCore-BVZExPPu.js → BoostCore-CD56zbYX.js} +1678 -499
- package/dist/BoostCore-CD56zbYX.js.map +1 -0
- package/dist/BoostCore.cjs +1 -1
- package/dist/BoostCore.d.ts +7 -7
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +6 -6
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +6 -6
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +50 -50
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +28 -28
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +30 -29
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +28 -28
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +92 -23
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +145 -47
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -1
- package/dist/{Incentive-BhHaK3PZ.cjs → Incentive-CcnOIc8L.cjs} +2 -2
- package/dist/{Incentive-BhHaK3PZ.cjs.map → Incentive-CcnOIc8L.cjs.map} +1 -1
- package/dist/{Incentive-Cqg1w6wD.js → Incentive-rM5nKznp.js} +30 -29
- package/dist/{Incentive-Cqg1w6wD.js.map → Incentive-rM5nKznp.js.map} +1 -1
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +11 -10
- package/dist/Incentives/AllowListIncentive.js.map +1 -1
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
- package/dist/Incentives/CGDAIncentive.d.ts +28 -28
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +12 -11
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +28 -28
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +34 -31
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +30 -27
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +28 -28
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +28 -28
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.js +2 -2
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +12 -11
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/{SimpleDenyList-CGaWjuld.js → SimpleDenyList-BDXpY74P.js} +18 -17
- package/dist/SimpleDenyList-BDXpY74P.js.map +1 -0
- package/dist/{SimpleDenyList-BUR17Tt1.cjs → SimpleDenyList-DNj5qDWM.cjs} +2 -2
- package/dist/SimpleDenyList-DNj5qDWM.cjs.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +13 -12
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +1 -1
- package/dist/deployments-DF_6-7hH.cjs +2 -0
- package/dist/deployments-DF_6-7hH.cjs.map +1 -0
- package/dist/deployments-fJsWblwS.js +56 -0
- package/dist/deployments-fJsWblwS.js.map +1 -0
- package/dist/deployments.json +26 -12
- package/dist/{generated-CKt2yCQd.js → generated-CsNyWPKA.js} +458 -443
- package/dist/generated-CsNyWPKA.js.map +1 -0
- package/dist/generated-DHerxf1y.cjs +3 -0
- package/dist/generated-DHerxf1y.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +33 -33
- package/package.json +4 -4
- package/src/Actions/EventAction.test.ts +19 -13
- package/src/Actions/EventAction.ts +16 -35
- package/src/AllowLists/SimpleAllowList.ts +1 -0
- package/src/AllowLists/SimpleDenyList.ts +1 -0
- package/src/BoostCore.test.ts +78 -78
- package/src/BoostCore.ts +19 -13
- package/src/BoostRegistry.ts +10 -10
- package/src/Budgets/ManagedBudget.test.ts +41 -17
- package/src/Budgets/ManagedBudget.ts +1 -11
- package/src/Budgets/VestingBudget.ts +3 -1
- package/src/Deployable/DeployableTargetWithRBAC.test.ts +103 -0
- package/src/Deployable/DeployableTargetWithRBAC.ts +160 -36
- package/src/Incentives/AllowListIncentive.test.ts +7 -7
- package/src/Incentives/AllowListIncentive.ts +1 -0
- package/src/Incentives/CGDAIncentive.ts +1 -0
- package/src/Incentives/ERC1155Incentive.ts +3 -1
- package/src/Incentives/ERC20Incentive.ts +10 -3
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +1 -0
- package/src/Incentives/ERC20VariableIncentive.ts +1 -0
- package/src/Incentives/PointsIncentive.ts +1 -0
- package/src/Validators/SignerValidator.ts +1 -0
- package/dist/BoostCore-BVZExPPu.js.map +0 -1
- package/dist/BoostCore-D-E-cnGI.cjs +0 -3
- package/dist/BoostCore-D-E-cnGI.cjs.map +0 -1
- package/dist/EventAction-BZt5cjbe.cjs +0 -2
- package/dist/EventAction-BZt5cjbe.cjs.map +0 -1
- package/dist/EventAction-C_-hJXWm.js +0 -1541
- package/dist/EventAction-C_-hJXWm.js.map +0 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +0 -1
- package/dist/SimpleDenyList-CGaWjuld.js.map +0 -1
- package/dist/deployments-DVXioW2i.cjs +0 -2
- package/dist/deployments-DVXioW2i.cjs.map +0 -1
- package/dist/deployments-oykLv3_Z.js +0 -43
- package/dist/deployments-oykLv3_Z.js.map +0 -1
- package/dist/generated-CKt2yCQd.js.map +0 -1
- package/dist/generated-CyTNlOwM.cjs +0 -3
- package/dist/generated-CyTNlOwM.cjs.map +0 -1
|
@@ -63,80 +63,148 @@ export declare class DeployableTargetWithRBAC<Payload, ABI extends Abi> extends
|
|
|
63
63
|
hash: `0x${string}`;
|
|
64
64
|
result: void;
|
|
65
65
|
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Grant permissions for a user on the rbac.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* await rbac.grantRoles('0xfoo', Roles.MANAGER)
|
|
72
|
+
* ```
|
|
73
|
+
* @public
|
|
74
|
+
* @async
|
|
75
|
+
* @param {Address} address
|
|
76
|
+
* @param {Roles} role
|
|
77
|
+
* @param {?WriteParams<typeof rbacAbi, 'grantRoles'>} [params]
|
|
78
|
+
* @returns {Promise<void>}
|
|
79
|
+
*/
|
|
80
|
+
grantRoles(address: Address, role: Roles, params?: WriteParams<typeof rbacAbi, 'grantRoles'>): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Grant permissions for a user on the rbac.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* await rbac.grantRoles('0xfoo', Roles.MANAGER)
|
|
87
|
+
* ```
|
|
88
|
+
* @public
|
|
89
|
+
* @async
|
|
90
|
+
* @param {Address} address
|
|
91
|
+
* @param {Roles} role
|
|
92
|
+
* @param {?WriteParams} [params]
|
|
93
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
94
|
+
*/
|
|
95
|
+
grantRolesRaw(address: Address, role: Roles, params?: WriteParams<typeof rbacAbi, 'grantRoles'>): Promise<{
|
|
96
|
+
hash: `0x${string}`;
|
|
97
|
+
result: void;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Revoke permissions for a user on the rbac.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* await rbac.revokeRoles('0xfoo', Roles.MANAGER)
|
|
105
|
+
* ```
|
|
106
|
+
* @public
|
|
107
|
+
* @async
|
|
108
|
+
* @param {Address} address
|
|
109
|
+
* @param {Roles} role
|
|
110
|
+
* @param {?WriteParams} [params]
|
|
111
|
+
* @returns {Promise<void>}
|
|
112
|
+
*/
|
|
113
|
+
revokeRoles(address: Address, role: Roles, params?: WriteParams<typeof rbacAbi, 'revokeRoles'>): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Revoke permissions for a user on the rbac.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* await rbac.revokeRoles('0xfoo', Roles.MANAGER)
|
|
120
|
+
* ```
|
|
121
|
+
* @public
|
|
122
|
+
* @async
|
|
123
|
+
* @param {Address} address
|
|
124
|
+
* @param {Roles} role
|
|
125
|
+
* @param {?WriteParams} [params]
|
|
126
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
127
|
+
*/
|
|
128
|
+
revokeRolesRaw(address: Address, role: Roles, params?: WriteParams<typeof rbacAbi, 'revokeRoles'>): Promise<{
|
|
129
|
+
hash: `0x${string}`;
|
|
130
|
+
result: void;
|
|
131
|
+
}>;
|
|
66
132
|
/**
|
|
67
133
|
* Grant many accounts permissions on the rbac.
|
|
68
134
|
*
|
|
69
135
|
* @example
|
|
70
136
|
* ```ts
|
|
71
|
-
* await rbac.
|
|
137
|
+
* await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
72
138
|
* ```
|
|
73
139
|
* @public
|
|
74
140
|
* @async
|
|
75
141
|
* @param {Address[]} addresses
|
|
76
|
-
* @param {
|
|
142
|
+
* @param {Roles[]} roles
|
|
77
143
|
* @param {?WriteParams} [params]
|
|
78
144
|
* @returns {Promise<void>}
|
|
79
145
|
*/
|
|
80
|
-
|
|
146
|
+
grantManyRoles(addresses: Address[], roles: Roles[], params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>): Promise<void>;
|
|
81
147
|
/**
|
|
82
148
|
* Grant many accounts permissions on the rbac.
|
|
83
149
|
*
|
|
84
150
|
* @example
|
|
85
151
|
* ```ts
|
|
86
|
-
* await rbac.
|
|
87
|
-
*
|
|
152
|
+
* await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
153
|
+
* ```
|
|
88
154
|
* @public
|
|
89
155
|
* @async
|
|
90
156
|
* @param {Address[]} addresses
|
|
91
|
-
* @param {
|
|
157
|
+
* @param {Roles[]} roles
|
|
92
158
|
* @param {?WriteParams} [params]
|
|
93
159
|
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
94
160
|
*/
|
|
95
|
-
|
|
161
|
+
grantManyRolesRaw(addresses: Address[], roles: Roles[], params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>): Promise<{
|
|
96
162
|
hash: `0x${string}`;
|
|
97
|
-
result:
|
|
163
|
+
result: void;
|
|
98
164
|
}>;
|
|
99
165
|
/**
|
|
100
166
|
* Revoke many accounts' permissions on the rbac.
|
|
101
167
|
*
|
|
102
168
|
* @example
|
|
103
169
|
* ```ts
|
|
104
|
-
* await rbac.
|
|
105
|
-
*
|
|
170
|
+
* await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
171
|
+
* ```
|
|
106
172
|
* @public
|
|
107
173
|
* @async
|
|
108
174
|
* @param {Address[]} addresses
|
|
109
|
-
* @param {
|
|
175
|
+
* @param {Roles[]} roles
|
|
110
176
|
* @param {?WriteParams} [params]
|
|
111
177
|
* @returns {Promise<void>}
|
|
112
178
|
*/
|
|
113
|
-
|
|
179
|
+
revokeManyRoles(addresses: Address[], roles: Roles[], params?: WriteParams<typeof rbacAbi, 'revokeManyRoles'>): Promise<void>;
|
|
114
180
|
/**
|
|
115
181
|
* Revoke many accounts' permissions on the rbac.
|
|
116
182
|
*
|
|
117
183
|
* @example
|
|
118
184
|
* ```ts
|
|
119
|
-
* await rbac.
|
|
185
|
+
* await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
186
|
+
* ```
|
|
120
187
|
* @public
|
|
121
188
|
* @async
|
|
122
189
|
* @param {Address[]} addresses
|
|
123
|
-
* @param {
|
|
190
|
+
* @param {Roles[]} roles
|
|
124
191
|
* @param {?WriteParams} [params]
|
|
125
192
|
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
126
193
|
*/
|
|
127
|
-
|
|
194
|
+
revokeManyRolesRaw(addresses: Address[], roles: Roles[], params?: WriteParams<typeof rbacAbi, 'revokeManyRoles'>): Promise<{
|
|
128
195
|
hash: `0x${string}`;
|
|
129
|
-
result:
|
|
196
|
+
result: void;
|
|
130
197
|
}>;
|
|
131
198
|
/**
|
|
132
199
|
* Return an array of the roles assigned to the given account.
|
|
133
200
|
* @example
|
|
134
201
|
* ```ts
|
|
135
|
-
* (await rbac.rolesOf(0xfoo)).includes(
|
|
202
|
+
* (await rbac.rolesOf(0xfoo)).includes(Roles.ADMIN)
|
|
203
|
+
* ```
|
|
136
204
|
* @public
|
|
137
205
|
* @param {Address} account
|
|
138
206
|
* @param {?ReadParams} [params]
|
|
139
|
-
* @returns {Promise<Array<
|
|
207
|
+
* @returns {Promise<Array<Roles>>}
|
|
140
208
|
*/
|
|
141
209
|
rolesOf(account: Address, params?: ReadParams<typeof rbacAbi, 'rolesOf'>): Promise<Roles[]>;
|
|
142
210
|
/**
|
|
@@ -144,10 +212,11 @@ export declare class DeployableTargetWithRBAC<Payload, ABI extends Abi> extends
|
|
|
144
212
|
*
|
|
145
213
|
* @example
|
|
146
214
|
* ```ts
|
|
147
|
-
* await rbac.hasAnyRole(0xfoo,
|
|
215
|
+
* await rbac.hasAnyRole(0xfoo, Roles.ADMIN | Roles.MANAGER)
|
|
216
|
+
* ```
|
|
148
217
|
* @public
|
|
149
218
|
* @param {Address} account
|
|
150
|
-
* @param {
|
|
219
|
+
* @param {Roles} roles
|
|
151
220
|
* @param {?ReadParams} [params]
|
|
152
221
|
* @returns {Promise<boolean>}
|
|
153
222
|
*/
|
|
@@ -157,11 +226,11 @@ export declare class DeployableTargetWithRBAC<Payload, ABI extends Abi> extends
|
|
|
157
226
|
*
|
|
158
227
|
* @example
|
|
159
228
|
* ```ts
|
|
160
|
-
* await rbac.hasAllRoles(0xfoo,
|
|
161
|
-
*
|
|
229
|
+
* await rbac.hasAllRoles(0xfoo, Roles.ADMIN | Roles.MANAGER)
|
|
230
|
+
* ```
|
|
162
231
|
* @public
|
|
163
232
|
* @param {Address} account
|
|
164
|
-
* @param {
|
|
233
|
+
* @param {Roles} roles
|
|
165
234
|
* @param {?ReadParams} [params]
|
|
166
235
|
* @returns {Promise<boolean>}
|
|
167
236
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeployableTargetWithRBAC.d.ts","sourceRoot":"","sources":["../../src/Deployable/DeployableTargetWithRBAC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"DeployableTargetWithRBAC.d.ts","sourceRoot":"","sources":["../../src/Deployable/DeployableTargetWithRBAC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAeR,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAA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O,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,OAAO,EAAE,aAAa,CAAC;IAWpD;;;;;;;OAOG;IACI,YAAY,CACjB,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,OAAO,EAAE,cAAc,CAAC;CAUtD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DeployableTarget as
|
|
4
|
-
var o = /* @__PURE__ */ ((
|
|
5
|
-
class
|
|
1
|
+
import { e as h, j as c, I as l, u as d, k as A, m as u, A as R, p as g, M as w, l as y, n as f, o as p, Y as M, q as _ } from "../generated-CsNyWPKA.js";
|
|
2
|
+
import { R as b } from "../generated-CsNyWPKA.js";
|
|
3
|
+
import { DeployableTarget as V } from "./DeployableTarget.js";
|
|
4
|
+
var o = /* @__PURE__ */ ((r) => (r[r.MANAGER = 1n] = "MANAGER", r[r.ADMIN = 2n] = "ADMIN", r))(o || {});
|
|
5
|
+
class v extends V {
|
|
6
6
|
/**
|
|
7
7
|
* Set the authorized status of the given accounts
|
|
8
8
|
* The mechanism for managing authorization is left to the implementing contract
|
|
@@ -31,48 +31,48 @@ class _ extends M {
|
|
|
31
31
|
* @returns {Promise<void>}
|
|
32
32
|
*/
|
|
33
33
|
async setAuthorizedRaw(s, t, a) {
|
|
34
|
-
const { request:
|
|
34
|
+
const { request: e, result: i } = await h(this._config, {
|
|
35
35
|
address: this.assertValidAddress(),
|
|
36
36
|
args: [s, t],
|
|
37
37
|
...this.optionallyAttachAccount(),
|
|
38
38
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
39
39
|
...a
|
|
40
40
|
});
|
|
41
|
-
return { hash: await c(this._config,
|
|
41
|
+
return { hash: await c(this._config, e), result: i };
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Grant
|
|
44
|
+
* Grant permissions for a user on the rbac.
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
47
|
* ```ts
|
|
48
|
-
* await rbac.grantRoles(
|
|
48
|
+
* await rbac.grantRoles('0xfoo', Roles.MANAGER)
|
|
49
49
|
* ```
|
|
50
50
|
* @public
|
|
51
51
|
* @async
|
|
52
|
-
* @param {Address
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {?WriteParams} [params]
|
|
52
|
+
* @param {Address} address
|
|
53
|
+
* @param {Roles} role
|
|
54
|
+
* @param {?WriteParams<typeof rbacAbi, 'grantRoles'>} [params]
|
|
55
55
|
* @returns {Promise<void>}
|
|
56
56
|
*/
|
|
57
57
|
async grantRoles(s, t, a) {
|
|
58
58
|
return await this.awaitResult(this.grantRolesRaw(s, t, a));
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Grant
|
|
61
|
+
* Grant permissions for a user on the rbac.
|
|
62
62
|
*
|
|
63
63
|
* @example
|
|
64
64
|
* ```ts
|
|
65
|
-
* await rbac.grantRoles(
|
|
66
|
-
*
|
|
65
|
+
* await rbac.grantRoles('0xfoo', Roles.MANAGER)
|
|
66
|
+
* ```
|
|
67
67
|
* @public
|
|
68
68
|
* @async
|
|
69
|
-
* @param {Address
|
|
70
|
-
* @param {
|
|
69
|
+
* @param {Address} address
|
|
70
|
+
* @param {Roles} role
|
|
71
71
|
* @param {?WriteParams} [params]
|
|
72
72
|
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
73
73
|
*/
|
|
74
74
|
async grantRolesRaw(s, t, a) {
|
|
75
|
-
const { request:
|
|
75
|
+
const { request: e, result: i } = await l(this._config, {
|
|
76
76
|
address: this.assertValidAddress(),
|
|
77
77
|
args: [s, t],
|
|
78
78
|
...this.optionallyAttachAccount(),
|
|
@@ -82,67 +82,164 @@ class _ extends M {
|
|
|
82
82
|
return { hash: await d(
|
|
83
83
|
this._config,
|
|
84
84
|
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
85
|
-
|
|
86
|
-
), result:
|
|
85
|
+
e
|
|
86
|
+
), result: i };
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
* Revoke
|
|
89
|
+
* Revoke permissions for a user on the rbac.
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
92
|
* ```ts
|
|
93
|
-
* await rbac.revokeRoles(
|
|
93
|
+
* await rbac.revokeRoles('0xfoo', Roles.MANAGER)
|
|
94
|
+
* ```
|
|
95
|
+
* @public
|
|
96
|
+
* @async
|
|
97
|
+
* @param {Address} address
|
|
98
|
+
* @param {Roles} role
|
|
99
|
+
* @param {?WriteParams} [params]
|
|
100
|
+
* @returns {Promise<void>}
|
|
101
|
+
*/
|
|
102
|
+
async revokeRoles(s, t, a) {
|
|
103
|
+
return await this.awaitResult(this.revokeRolesRaw(s, t, a));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Revoke permissions for a user on the rbac.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* await rbac.revokeRoles('0xfoo', Roles.MANAGER)
|
|
111
|
+
* ```
|
|
112
|
+
* @public
|
|
113
|
+
* @async
|
|
114
|
+
* @param {Address} address
|
|
115
|
+
* @param {Roles} role
|
|
116
|
+
* @param {?WriteParams} [params]
|
|
117
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
118
|
+
*/
|
|
119
|
+
async revokeRolesRaw(s, t, a) {
|
|
120
|
+
const { request: e, result: i } = await A(this._config, {
|
|
121
|
+
address: this.assertValidAddress(),
|
|
122
|
+
args: [s, t],
|
|
123
|
+
...this.optionallyAttachAccount(),
|
|
124
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
125
|
+
...a
|
|
126
|
+
});
|
|
127
|
+
return { hash: await u(
|
|
128
|
+
this._config,
|
|
129
|
+
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
130
|
+
e
|
|
131
|
+
), result: i };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Grant many accounts permissions on the rbac.
|
|
94
135
|
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
139
|
+
* ```
|
|
95
140
|
* @public
|
|
96
141
|
* @async
|
|
97
142
|
* @param {Address[]} addresses
|
|
98
|
-
* @param {
|
|
143
|
+
* @param {Roles[]} roles
|
|
99
144
|
* @param {?WriteParams} [params]
|
|
100
145
|
* @returns {Promise<void>}
|
|
101
146
|
*/
|
|
102
|
-
async
|
|
147
|
+
async grantManyRoles(s, t, a) {
|
|
103
148
|
return await this.awaitResult(
|
|
104
|
-
this.
|
|
149
|
+
this.grantManyRolesRaw(s, t, a)
|
|
105
150
|
);
|
|
106
151
|
}
|
|
107
152
|
/**
|
|
108
|
-
*
|
|
153
|
+
* Grant many accounts permissions on the rbac.
|
|
109
154
|
*
|
|
110
155
|
* @example
|
|
111
156
|
* ```ts
|
|
112
|
-
* await rbac.
|
|
157
|
+
* await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
158
|
+
* ```
|
|
113
159
|
* @public
|
|
114
160
|
* @async
|
|
115
161
|
* @param {Address[]} addresses
|
|
116
|
-
* @param {
|
|
162
|
+
* @param {Roles[]} roles
|
|
117
163
|
* @param {?WriteParams} [params]
|
|
118
164
|
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
119
165
|
*/
|
|
120
|
-
async
|
|
121
|
-
const { request:
|
|
166
|
+
async grantManyRolesRaw(s, t, a) {
|
|
167
|
+
const { request: e, result: i } = await R(this._config, {
|
|
122
168
|
address: this.assertValidAddress(),
|
|
123
169
|
args: [s, t],
|
|
124
170
|
...this.optionallyAttachAccount(),
|
|
125
171
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
126
172
|
...a
|
|
127
173
|
});
|
|
128
|
-
return { hash: await
|
|
174
|
+
return { hash: await g(
|
|
175
|
+
this._config,
|
|
176
|
+
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
177
|
+
e
|
|
178
|
+
), result: i };
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Revoke many accounts' permissions on the rbac.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
186
|
+
* ```
|
|
187
|
+
* @public
|
|
188
|
+
* @async
|
|
189
|
+
* @param {Address[]} addresses
|
|
190
|
+
* @param {Roles[]} roles
|
|
191
|
+
* @param {?WriteParams} [params]
|
|
192
|
+
* @returns {Promise<void>}
|
|
193
|
+
*/
|
|
194
|
+
async revokeManyRoles(s, t, a) {
|
|
195
|
+
return await this.awaitResult(
|
|
196
|
+
this.revokeManyRolesRaw(s, t, a)
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Revoke many accounts' permissions on the rbac.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
205
|
+
* ```
|
|
206
|
+
* @public
|
|
207
|
+
* @async
|
|
208
|
+
* @param {Address[]} addresses
|
|
209
|
+
* @param {Roles[]} roles
|
|
210
|
+
* @param {?WriteParams} [params]
|
|
211
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
212
|
+
*/
|
|
213
|
+
async revokeManyRolesRaw(s, t, a) {
|
|
214
|
+
const { request: e, result: i } = await w(
|
|
215
|
+
this._config,
|
|
216
|
+
{
|
|
217
|
+
address: this.assertValidAddress(),
|
|
218
|
+
args: [s, t],
|
|
219
|
+
...this.optionallyAttachAccount(),
|
|
220
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
221
|
+
...a
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
return { hash: await y(
|
|
129
225
|
this._config,
|
|
130
226
|
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
131
|
-
|
|
132
|
-
), result:
|
|
227
|
+
e
|
|
228
|
+
), result: i };
|
|
133
229
|
}
|
|
134
230
|
/**
|
|
135
231
|
* Return an array of the roles assigned to the given account.
|
|
136
232
|
* @example
|
|
137
233
|
* ```ts
|
|
138
|
-
* (await rbac.rolesOf(0xfoo)).includes(
|
|
234
|
+
* (await rbac.rolesOf(0xfoo)).includes(Roles.ADMIN)
|
|
235
|
+
* ```
|
|
139
236
|
* @public
|
|
140
237
|
* @param {Address} account
|
|
141
238
|
* @param {?ReadParams} [params]
|
|
142
|
-
* @returns {Promise<Array<
|
|
239
|
+
* @returns {Promise<Array<Roles>>}
|
|
143
240
|
*/
|
|
144
241
|
async rolesOf(s, t) {
|
|
145
|
-
const a = await
|
|
242
|
+
const a = await f(this._config, {
|
|
146
243
|
address: this.assertValidAddress(),
|
|
147
244
|
args: [s],
|
|
148
245
|
...this.optionallyAttachAccount(),
|
|
@@ -150,7 +247,7 @@ class _ extends M {
|
|
|
150
247
|
...t
|
|
151
248
|
});
|
|
152
249
|
return [o.MANAGER, o.ADMIN].filter(
|
|
153
|
-
(
|
|
250
|
+
(e) => (a & e) === e
|
|
154
251
|
);
|
|
155
252
|
}
|
|
156
253
|
/**
|
|
@@ -158,15 +255,16 @@ class _ extends M {
|
|
|
158
255
|
*
|
|
159
256
|
* @example
|
|
160
257
|
* ```ts
|
|
161
|
-
* await rbac.hasAnyRole(0xfoo,
|
|
258
|
+
* await rbac.hasAnyRole(0xfoo, Roles.ADMIN | Roles.MANAGER)
|
|
259
|
+
* ```
|
|
162
260
|
* @public
|
|
163
261
|
* @param {Address} account
|
|
164
|
-
* @param {
|
|
262
|
+
* @param {Roles} roles
|
|
165
263
|
* @param {?ReadParams} [params]
|
|
166
264
|
* @returns {Promise<boolean>}
|
|
167
265
|
*/
|
|
168
266
|
hasAnyRole(s, t, a) {
|
|
169
|
-
return
|
|
267
|
+
return p(this._config, {
|
|
170
268
|
address: this.assertValidAddress(),
|
|
171
269
|
args: [s, t],
|
|
172
270
|
...this.optionallyAttachAccount(),
|
|
@@ -179,16 +277,16 @@ class _ extends M {
|
|
|
179
277
|
*
|
|
180
278
|
* @example
|
|
181
279
|
* ```ts
|
|
182
|
-
* await rbac.hasAllRoles(0xfoo,
|
|
183
|
-
*
|
|
280
|
+
* await rbac.hasAllRoles(0xfoo, Roles.ADMIN | Roles.MANAGER)
|
|
281
|
+
* ```
|
|
184
282
|
* @public
|
|
185
283
|
* @param {Address} account
|
|
186
|
-
* @param {
|
|
284
|
+
* @param {Roles} roles
|
|
187
285
|
* @param {?ReadParams} [params]
|
|
188
286
|
* @returns {Promise<boolean>}
|
|
189
287
|
*/
|
|
190
288
|
hasAllRoles(s, t, a) {
|
|
191
|
-
return
|
|
289
|
+
return M(this._config, {
|
|
192
290
|
address: this.assertValidAddress(),
|
|
193
291
|
args: [s, t],
|
|
194
292
|
...this.optionallyAttachAccount(),
|
|
@@ -205,7 +303,7 @@ class _ extends M {
|
|
|
205
303
|
* @returns {Promise<boolean>} - True if the account is authorized
|
|
206
304
|
*/
|
|
207
305
|
isAuthorized(s, t) {
|
|
208
|
-
return
|
|
306
|
+
return _(this._config, {
|
|
209
307
|
address: this.assertValidAddress(),
|
|
210
308
|
args: [s],
|
|
211
309
|
...this.optionallyAttachAccount(),
|
|
@@ -215,8 +313,8 @@ class _ extends M {
|
|
|
215
313
|
}
|
|
216
314
|
}
|
|
217
315
|
export {
|
|
218
|
-
|
|
316
|
+
v as DeployableTargetWithRBAC,
|
|
219
317
|
o as Roles,
|
|
220
|
-
|
|
318
|
+
b as rbacAbi
|
|
221
319
|
};
|
|
222
320
|
//# sourceMappingURL=DeployableTargetWithRBAC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeployableTargetWithRBAC.js","sources":["../../src/Deployable/DeployableTargetWithRBAC.ts"],"sourcesContent":["import {\n rbacAbi,\n readRbacHasAllRoles,\n readRbacHasAnyRole,\n readRbacIsAuthorized,\n readRbacRolesOf,\n simulateRbacGrantRoles,\n simulateRbacRevokeRoles,\n simulateRbacSetAuthorized,\n writeRbacGrantRoles,\n writeRbacRevokeRoles,\n writeRbacSetAuthorized,\n} from '@boostxyz/evm';\nimport type { Abi, Address, ContractEventName } from 'viem';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport type { GenericLog, ReadParams, WriteParams } from '../utils';\nexport { rbacAbi };\n\n/**\n * Enum representing available roles for use with the `RBAC` authorization scheme.\n * `MANAGER` has lowest level of write permissions, for specific implementations, see Budgets and ALlowLists\n * `ADMIN` can additionally manage authorized users on the contract.\n *\n * @export\n * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}\n * @enum {bigint}\n */\nexport enum Roles {\n //@ts-expect-error ts doesn't like bigint enum values\n MANAGER = 1n,\n //@ts-expect-error ts doesn't like bigint enum values\n ADMIN = 2n,\n}\n\n/**\n * A generic `viem.Log` event with support for `Rbac` event types.\n *\n * @export\n * @typedef {RBACLog}\n * @template {ContractEventName<typeof rbacAbi>} [event=ContractEventName<\n * typeof rbacAbi\n * >]\n */\nexport type RBACLog<\n event extends ContractEventName<typeof rbacAbi> = ContractEventName<\n typeof rbacAbi\n >,\n> = GenericLog<typeof rbacAbi, event>;\n\n/**\n * A minimal RBAC implementation that offers MANAGER and ADMIN roles, and\n * Budgets and allowlists support this auth scheme\n *\n * @export\n * @class DeployableTargetWithRBAC\n * @typedef {DeployableTargetWithRBAC}\n * @extends {DeployableTarget<RbacPayload>}\n */\nexport class DeployableTargetWithRBAC<\n Payload,\n ABI extends Abi,\n> extends DeployableTarget<Payload, ABI> {\n /**\n * Set the authorized status of the given accounts\n * The mechanism for managing authorization is left to the implementing contract\n *\n * @public\n * @async\n * @param {Address[]} addresses - The accounts to authorize or deauthorize\n * @param {boolean[]} allowed - The authorization status for the given accounts\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async setAuthorized(\n addresses: Address[],\n allowed: boolean[],\n params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,\n ) {\n return await this.awaitResult(\n this.setAuthorizedRaw(addresses, allowed, params),\n );\n }\n\n /**\n * Set the authorized status of the given accounts\n * The mechanism for managing authorization is left to the implementing contract\n *\n * @public\n * @async\n * @param {Address[]} addresses - The accounts to authorize or deauthorize\n * @param {boolean[]} allowed - The authorization status for the given accounts\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async setAuthorizedRaw(\n addresses: Address[],\n allowed: boolean[],\n params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,\n ) {\n const { request, result } = await simulateRbacSetAuthorized(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, allowed],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeRbacSetAuthorized(this._config, request);\n return { hash, result };\n }\n\n /**\n * Grant many accounts permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])\n * ```\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async grantRoles(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'grantRoles'>,\n ) {\n return await this.awaitResult(this.grantRolesRaw(addresses, roles, params));\n }\n\n /**\n * Grant many accounts permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])\n *\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async grantRolesRaw(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'grantRoles'>,\n ) {\n const { request, result } = await simulateRbacGrantRoles(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeRbacGrantRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Revoke many accounts' permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])\n *\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async revokeRoles(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,\n ) {\n return await this.awaitResult(\n this.revokeRolesRaw(addresses, roles, params),\n );\n }\n\n /**\n * Revoke many accounts' permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async revokeRolesRaw(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,\n ) {\n const { request, result } = await simulateRbacRevokeRoles(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeRbacRevokeRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Return an array of the roles assigned to the given account.\n * @example\n * ```ts\n * (await rbac.rolesOf(0xfoo)).includes(RbacRoles.ADMIN)\n * @public\n * @param {Address} account\n * @param {?ReadParams} [params]\n * @returns {Promise<Array<RbacRoles>>}\n */\n public async rolesOf(\n account: Address,\n params?: ReadParams<typeof rbacAbi, 'rolesOf'>,\n ) {\n const roles = await readRbacRolesOf(this._config, {\n address: this.assertValidAddress(),\n args: [account],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n return ([Roles.MANAGER, Roles.ADMIN] as unknown as Array<bigint>).filter(\n (role) => (roles & role) === role,\n ) as unknown as Roles[];\n }\n\n /**\n * Returns whether given account has any of the provided roles bitmap.\n *\n * @example\n * ```ts\n * await rbac.hasAnyRole(0xfoo, RbacRoles.ADMIN | RbacRoles.MANAGER)\n * @public\n * @param {Address} account\n * @param {RbacRoles} roles\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public hasAnyRole(\n account: Address,\n roles: Roles,\n params?: ReadParams<typeof rbacAbi, 'hasAnyRole'>,\n ) {\n return readRbacHasAnyRole(this._config, {\n address: this.assertValidAddress(),\n args: [account, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Returns whether given account has all of the provided roles bitmap.\n *\n * @example\n * ```ts\n * await rbac.hasAllRoles(0xfoo, RbacRoles.ADMIN & RbacRoles.MANAGER)\n *\n * @public\n * @param {Address} account\n * @param {RbacRoles} roles\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public hasAllRoles(\n account: Address,\n roles: Roles,\n params?: ReadParams<typeof rbacAbi, 'hasAllRoles'>,\n ) {\n return readRbacHasAllRoles(this._config, {\n address: this.assertValidAddress(),\n args: [account, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Check if the given account is authorized to use the rbac\n *\n * @public\n * @param {Address} account\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} - True if the account is authorized\n */\n public isAuthorized(\n account: Address,\n params?: ReadParams<typeof rbacAbi, 'isAuthorized'>,\n ) {\n return readRbacIsAuthorized(this._config, {\n address: this.assertValidAddress(),\n args: [account],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n}\n"],"names":["Roles","DeployableTargetWithRBAC","DeployableTarget","addresses","allowed","params","request","result","simulateRbacSetAuthorized","writeRbacSetAuthorized","roles","simulateRbacGrantRoles","writeRbacGrantRoles","simulateRbacRevokeRoles","writeRbacRevokeRoles","account","readRbacRolesOf","role","readRbacHasAnyRole","readRbacHasAllRoles","readRbacIsAuthorized"],"mappings":";;;AA2BY,IAAAA,sBAAAA,OAEVA,EAAAA,EAAA,UAAU,EAAV,IAAA,WAEAA,EAAAA,EAAA,QAAQ,EAAR,IAAA,SAJUA,IAAAA,KAAA,CAAA,CAAA;AA+BL,MAAMC,UAGHC,EAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYvC,MAAa,cACXC,GACAC,GACAC,GACA;AACA,WAAO,MAAM,KAAK;AAAA,MAChB,KAAK,iBAAiBF,GAAWC,GAASC,CAAM;AAAA,IAAA;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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YACLU,GACAL,GACAL,GACA;AACO,WAAAc,EAAoB,KAAK,SAAS;AAAA,MACvC,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAACJ,GAASL,CAAK;AAAA,MACrB,GAAG,KAAK,wBAAwB;AAAA;AAAA,MAEhC,GAAIL;AAAA,IAAA,CACL;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUO,aACLU,GACAV,GACA;AACO,WAAAe,EAAqB,KAAK,SAAS;AAAA,MACxC,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAACL,CAAO;AAAA,MACd,GAAG,KAAK,wBAAwB;AAAA;AAAA,MAEhC,GAAIV;AAAA,IAAA,CACL;AAAA,EACH;AACF;"}
|
|
1
|
+
{"version":3,"file":"DeployableTargetWithRBAC.js","sources":["../../src/Deployable/DeployableTargetWithRBAC.ts"],"sourcesContent":["import {\n rbacAbi,\n readRbacHasAllRoles,\n readRbacHasAnyRole,\n readRbacIsAuthorized,\n readRbacRolesOf,\n simulateRbacGrantManyRoles,\n simulateRbacGrantRoles,\n simulateRbacRevokeManyRoles,\n simulateRbacRevokeRoles,\n simulateRbacSetAuthorized,\n writeRbacGrantManyRoles,\n writeRbacGrantRoles,\n writeRbacRevokeManyRoles,\n writeRbacRevokeRoles,\n writeRbacSetAuthorized,\n} from '@boostxyz/evm';\nimport type { Abi, Address, ContractEventName } from 'viem';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport type { GenericLog, ReadParams, WriteParams } from '../utils';\nexport { rbacAbi };\n\n/**\n * Enum representing available roles for use with the `RBAC` authorization scheme.\n * `MANAGER` has lowest level of write permissions, for specific implementations, see Budgets and ALlowLists\n * `ADMIN` can additionally manage authorized users on the contract.\n *\n * @export\n * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}\n * @enum {bigint}\n */\nexport enum Roles {\n //@ts-expect-error ts doesn't like bigint enum values\n MANAGER = 1n,\n //@ts-expect-error ts doesn't like bigint enum values\n ADMIN = 2n,\n}\n\n/**\n * A generic `viem.Log` event with support for `Rbac` event types.\n *\n * @export\n * @typedef {RBACLog}\n * @template {ContractEventName<typeof rbacAbi>} [event=ContractEventName<\n * typeof rbacAbi\n * >]\n */\nexport type RBACLog<\n event extends ContractEventName<typeof rbacAbi> = ContractEventName<\n typeof rbacAbi\n >,\n> = GenericLog<typeof rbacAbi, event>;\n\n/**\n * A minimal RBAC implementation that offers MANAGER and ADMIN roles, and\n * Budgets and allowlists support this auth scheme\n *\n * @export\n * @class DeployableTargetWithRBAC\n * @typedef {DeployableTargetWithRBAC}\n * @extends {DeployableTarget<RbacPayload>}\n */\nexport class DeployableTargetWithRBAC<\n Payload,\n ABI extends Abi,\n> extends DeployableTarget<Payload, ABI> {\n /**\n * Set the authorized status of the given accounts\n * The mechanism for managing authorization is left to the implementing contract\n *\n * @public\n * @async\n * @param {Address[]} addresses - The accounts to authorize or deauthorize\n * @param {boolean[]} allowed - The authorization status for the given accounts\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async setAuthorized(\n addresses: Address[],\n allowed: boolean[],\n params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,\n ) {\n return await this.awaitResult(\n this.setAuthorizedRaw(addresses, allowed, params),\n );\n }\n\n /**\n * Set the authorized status of the given accounts\n * The mechanism for managing authorization is left to the implementing contract\n *\n * @public\n * @async\n * @param {Address[]} addresses - The accounts to authorize or deauthorize\n * @param {boolean[]} allowed - The authorization status for the given accounts\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async setAuthorizedRaw(\n addresses: Address[],\n allowed: boolean[],\n params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,\n ) {\n const { request, result } = await simulateRbacSetAuthorized(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, allowed],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeRbacSetAuthorized(this._config, request);\n return { hash, result };\n }\n\n /**\n * Grant permissions for a user on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantRoles('0xfoo', Roles.MANAGER)\n * ```\n * @public\n * @async\n * @param {Address} address\n * @param {Roles} role\n * @param {?WriteParams<typeof rbacAbi, 'grantRoles'>} [params]\n * @returns {Promise<void>}\n */\n public async grantRoles(\n address: Address,\n role: Roles,\n params?: WriteParams<typeof rbacAbi, 'grantRoles'>,\n ) {\n return await this.awaitResult(this.grantRolesRaw(address, role, params));\n }\n\n /**\n * Grant permissions for a user on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantRoles('0xfoo', Roles.MANAGER)\n * ```\n * @public\n * @async\n * @param {Address} address\n * @param {Roles} role\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async grantRolesRaw(\n address: Address,\n role: Roles,\n params?: WriteParams<typeof rbacAbi, 'grantRoles'>,\n ) {\n const { request, result } = await simulateRbacGrantRoles(this._config, {\n address: this.assertValidAddress(),\n args: [address, role],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeRbacGrantRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Revoke permissions for a user on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeRoles('0xfoo', Roles.MANAGER)\n * ```\n * @public\n * @async\n * @param {Address} address\n * @param {Roles} role\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async revokeRoles(\n address: Address,\n role: Roles,\n params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,\n ) {\n return await this.awaitResult(this.revokeRolesRaw(address, role, params));\n }\n\n /**\n * Revoke permissions for a user on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeRoles('0xfoo', Roles.MANAGER)\n * ```\n * @public\n * @async\n * @param {Address} address\n * @param {Roles} role\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async revokeRolesRaw(\n address: Address,\n role: Roles,\n params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,\n ) {\n const { request, result } = await simulateRbacRevokeRoles(this._config, {\n address: this.assertValidAddress(),\n args: [address, role],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeRbacRevokeRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Grant many accounts permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])\n * ```\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {Roles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async grantManyRoles(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>,\n ) {\n return await this.awaitResult(\n this.grantManyRolesRaw(addresses, roles, params),\n );\n }\n\n /**\n * Grant many accounts permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])\n * ```\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {Roles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async grantManyRolesRaw(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'grantManyRoles'>,\n ) {\n const { request, result } = await simulateRbacGrantManyRoles(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeRbacGrantManyRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Revoke many accounts' permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])\n * ```\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {Roles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async revokeManyRoles(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'revokeManyRoles'>,\n ) {\n return await this.awaitResult(\n this.revokeManyRolesRaw(addresses, roles, params),\n );\n }\n\n /**\n * Revoke many accounts' permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeManyRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])\n * ```\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {Roles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async revokeManyRolesRaw(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'revokeManyRoles'>,\n ) {\n const { request, result } = await simulateRbacRevokeManyRoles(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [addresses, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeRbacRevokeManyRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Return an array of the roles assigned to the given account.\n * @example\n * ```ts\n * (await rbac.rolesOf(0xfoo)).includes(Roles.ADMIN)\n * ```\n * @public\n * @param {Address} account\n * @param {?ReadParams} [params]\n * @returns {Promise<Array<Roles>>}\n */\n public async rolesOf(\n account: Address,\n params?: ReadParams<typeof rbacAbi, 'rolesOf'>,\n ) {\n const roles = await readRbacRolesOf(this._config, {\n address: this.assertValidAddress(),\n args: [account],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n return ([Roles.MANAGER, Roles.ADMIN] as unknown as Array<bigint>).filter(\n (role) => (roles & role) === role,\n ) as unknown as Roles[];\n }\n\n /**\n * Returns whether given account has any of the provided roles bitmap.\n *\n * @example\n * ```ts\n * await rbac.hasAnyRole(0xfoo, Roles.ADMIN | Roles.MANAGER)\n * ```\n * @public\n * @param {Address} account\n * @param {Roles} roles\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public hasAnyRole(\n account: Address,\n roles: Roles,\n params?: ReadParams<typeof rbacAbi, 'hasAnyRole'>,\n ) {\n return readRbacHasAnyRole(this._config, {\n address: this.assertValidAddress(),\n args: [account, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Returns whether given account has all of the provided roles bitmap.\n *\n * @example\n * ```ts\n * await rbac.hasAllRoles(0xfoo, Roles.ADMIN | Roles.MANAGER)\n * ```\n * @public\n * @param {Address} account\n * @param {Roles} roles\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public hasAllRoles(\n account: Address,\n roles: Roles,\n params?: ReadParams<typeof rbacAbi, 'hasAllRoles'>,\n ) {\n return readRbacHasAllRoles(this._config, {\n address: this.assertValidAddress(),\n args: [account, roles],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Check if the given account is authorized to use the rbac\n *\n * @public\n * @param {Address} account\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} - True if the account is authorized\n */\n public isAuthorized(\n account: Address,\n params?: ReadParams<typeof rbacAbi, 'isAuthorized'>,\n ) {\n return readRbacIsAuthorized(this._config, {\n address: this.assertValidAddress(),\n args: [account],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n}\n"],"names":["Roles","DeployableTargetWithRBAC","DeployableTarget","addresses","allowed","params","request","result","simulateRbacSetAuthorized","writeRbacSetAuthorized","address","role","simulateRbacGrantRoles","writeRbacGrantRoles","simulateRbacRevokeRoles","writeRbacRevokeRoles","roles","simulateRbacGrantManyRoles","writeRbacGrantManyRoles","simulateRbacRevokeManyRoles","writeRbacRevokeManyRoles","account","readRbacRolesOf","readRbacHasAnyRole","readRbacHasAllRoles","readRbacIsAuthorized"],"mappings":";;;AA+BY,IAAAA,sBAAAA,OAEVA,EAAAA,EAAA,UAAU,EAAV,IAAA,WAEAA,EAAAA,EAAA,QAAQ,EAAR,IAAA,SAJUA,IAAAA,KAAA,CAAA,CAAA;AA+BL,MAAMC,UAGHC,EAA+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYvC,MAAa,cACXC,GACAC,GACAC,GACA;AACA,WAAO,MAAM,KAAK;AAAA,MAChB,KAAK,iBAAiBF,GAAWC,GAASC,CAAM;AAAA,IAAA;AAAA,EAEpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAa,iBACXF,GACAC,GACAC,GACA;AACA,UAAM,EAAE,SAAAC,GAAS,QAAAC,EAAA,IAAW,MAAMC,EAA0B,KAAK,SAAS;AAAA,MACxE,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAACL,GAAWC,CAAO;AAAA,MACzB,GAAG,KAAK,wBAAwB;AAAA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