@boostxyz/sdk 0.0.0-alpha.16 → 0.0.0-alpha.17
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 +8 -8
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +320 -137
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -1
- package/dist/AllowLists/AllowList.js +3 -3
- package/dist/AllowLists/OpenAllowList.d.ts +183 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +77 -31
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +34 -70
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +186 -3
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +4 -4
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.js +54 -54
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.js +10 -10
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.cjs.map +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/Budget.js.map +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +6 -156
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +60 -282
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +158 -54
- 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 +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/{Incentive-CtuAJAjG.js → Incentive-DJf-vdyL.js} +23 -23
- package/dist/{Incentive-CtuAJAjG.js.map → Incentive-DJf-vdyL.js.map} +1 -1
- package/dist/{Incentive-CqX3fYEd.cjs → Incentive-DNwROd1r.cjs} +2 -2
- package/dist/{Incentive-CqX3fYEd.cjs.map → Incentive-DNwROd1r.cjs.map} +1 -1
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.js +10 -10
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.js +9 -9
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.js +23 -23
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.js +3 -3
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.js +6 -6
- package/dist/SimpleDenyList-DMlUkmAn.cjs +2 -0
- package/dist/SimpleDenyList-DMlUkmAn.cjs.map +1 -0
- package/dist/SimpleDenyList-DvUvmOeE.js +132 -0
- package/dist/SimpleDenyList-DvUvmOeE.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.js +7 -7
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/componentInterfaces-BPVR_Ykd.js +13 -0
- package/dist/componentInterfaces-BPVR_Ykd.js.map +1 -0
- package/dist/{componentInterfaces-CKCBwG16.cjs → componentInterfaces-BfppSIl4.cjs} +2 -2
- package/dist/componentInterfaces-BfppSIl4.cjs.map +1 -0
- package/dist/generated-CMQ6ZC2_.cjs +3 -0
- package/dist/generated-CMQ6ZC2_.cjs.map +1 -0
- package/dist/{generated-DLMdMwD1.js → generated-C_7Jx3YG.js} +1654 -882
- package/dist/generated-C_7Jx3YG.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -96
- package/dist/index.js.map +1 -1
- package/package.json +10 -3
- package/src/Actions/EventAction.test.ts +138 -0
- package/src/Actions/EventAction.ts +28 -7
- package/src/AllowLists/SimpleAllowList.ts +9 -54
- package/src/AllowLists/SimpleDenyList.ts +6 -3
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.ts +3 -277
- package/src/Budgets/VestingBudget.ts +3 -74
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/index.test.ts +3 -4
- package/src/index.ts +1 -0
- package/dist/Budgets/SimpleBudget.d.ts +0 -824
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/SimpleDenyList-9UIxZZKP.cjs +0 -2
- package/dist/SimpleDenyList-9UIxZZKP.cjs.map +0 -1
- package/dist/SimpleDenyList-DGPNc7ov.js +0 -132
- package/dist/SimpleDenyList-DGPNc7ov.js.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-Cmg8tUxq.js +0 -13
- package/dist/componentInterfaces-Cmg8tUxq.js.map +0 -1
- package/dist/generated-BLg7yPgI.cjs +0 -3
- package/dist/generated-BLg7yPgI.cjs.map +0 -1
- package/dist/generated-DLMdMwD1.js.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -563
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rbacAbi,
|
|
3
|
+
readRbacHasAllRoles,
|
|
4
|
+
readRbacHasAnyRole,
|
|
5
|
+
readRbacIsAuthorized,
|
|
6
|
+
readRbacRolesOf,
|
|
7
|
+
simulateRbacGrantRoles,
|
|
8
|
+
simulateRbacRevokeRoles,
|
|
9
|
+
simulateRbacSetAuthorized,
|
|
10
|
+
writeRbacGrantRoles,
|
|
11
|
+
writeRbacRevokeRoles,
|
|
12
|
+
writeRbacSetAuthorized,
|
|
13
|
+
} from '@boostxyz/evm';
|
|
14
|
+
import type { Abi, Address, ContractEventName } from 'viem';
|
|
15
|
+
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
16
|
+
import type { GenericLog, ReadParams, WriteParams } from '../utils';
|
|
17
|
+
export { rbacAbi };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Enum representing available roles for use with the `RBAC` authorization scheme.
|
|
21
|
+
* `MANAGER` has lowest level of write permissions, for specific implementations, see Budgets and ALlowLists
|
|
22
|
+
* `ADMIN` can additionally manage authorized users on the contract.
|
|
23
|
+
*
|
|
24
|
+
* @export
|
|
25
|
+
* @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}
|
|
26
|
+
* @enum {bigint}
|
|
27
|
+
*/
|
|
28
|
+
export enum Roles {
|
|
29
|
+
//@ts-expect-error ts doesn't like bigint enum values
|
|
30
|
+
MANAGER = 1n,
|
|
31
|
+
//@ts-expect-error ts doesn't like bigint enum values
|
|
32
|
+
ADMIN = 2n,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A generic `viem.Log` event with support for `Rbac` event types.
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
* @typedef {RBACLog}
|
|
40
|
+
* @template {ContractEventName<typeof rbacAbi>} [event=ContractEventName<
|
|
41
|
+
* typeof rbacAbi
|
|
42
|
+
* >]
|
|
43
|
+
*/
|
|
44
|
+
export type RBACLog<
|
|
45
|
+
event extends ContractEventName<typeof rbacAbi> = ContractEventName<
|
|
46
|
+
typeof rbacAbi
|
|
47
|
+
>,
|
|
48
|
+
> = GenericLog<typeof rbacAbi, event>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A minimal RBAC implementation that offers MANAGER and ADMIN roles, and
|
|
52
|
+
* Budgets and allowlists support this auth scheme
|
|
53
|
+
*
|
|
54
|
+
* @export
|
|
55
|
+
* @class DeployableTargetWithRBAC
|
|
56
|
+
* @typedef {DeployableTargetWithRBAC}
|
|
57
|
+
* @extends {DeployableTarget<RbacPayload>}
|
|
58
|
+
*/
|
|
59
|
+
export class DeployableTargetWithRBAC<
|
|
60
|
+
Payload,
|
|
61
|
+
ABI extends Abi,
|
|
62
|
+
> extends DeployableTarget<Payload, ABI> {
|
|
63
|
+
/**
|
|
64
|
+
* Set the authorized status of the given accounts
|
|
65
|
+
* The mechanism for managing authorization is left to the implementing contract
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
* @async
|
|
69
|
+
* @param {Address[]} addresses - The accounts to authorize or deauthorize
|
|
70
|
+
* @param {boolean[]} allowed - The authorization status for the given accounts
|
|
71
|
+
* @param {?WriteParams<typeof rbacAbi, 'setAuthorized'>} [params]
|
|
72
|
+
* @returns {Promise<void>}
|
|
73
|
+
*/
|
|
74
|
+
public async setAuthorized(
|
|
75
|
+
addresses: Address[],
|
|
76
|
+
allowed: boolean[],
|
|
77
|
+
params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,
|
|
78
|
+
) {
|
|
79
|
+
return await this.awaitResult(
|
|
80
|
+
this.setAuthorizedRaw(addresses, allowed, params),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Set the authorized status of the given accounts
|
|
86
|
+
* The mechanism for managing authorization is left to the implementing contract
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
* @async
|
|
90
|
+
* @param {Address[]} addresses - The accounts to authorize or deauthorize
|
|
91
|
+
* @param {boolean[]} allowed - The authorization status for the given accounts
|
|
92
|
+
* @param {?WriteParams<typeof rbacAbi, 'setAuthorized'>} [params]
|
|
93
|
+
* @returns {Promise<void>}
|
|
94
|
+
*/
|
|
95
|
+
public async setAuthorizedRaw(
|
|
96
|
+
addresses: Address[],
|
|
97
|
+
allowed: boolean[],
|
|
98
|
+
params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,
|
|
99
|
+
) {
|
|
100
|
+
const { request, result } = await simulateRbacSetAuthorized(this._config, {
|
|
101
|
+
address: this.assertValidAddress(),
|
|
102
|
+
args: [addresses, allowed],
|
|
103
|
+
...this.optionallyAttachAccount(),
|
|
104
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
105
|
+
...(params as any),
|
|
106
|
+
});
|
|
107
|
+
const hash = await writeRbacSetAuthorized(this._config, request);
|
|
108
|
+
return { hash, result };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Grant many accounts permissions on the rbac.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* await rbac.grantRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
|
|
117
|
+
* ```
|
|
118
|
+
* @public
|
|
119
|
+
* @async
|
|
120
|
+
* @param {Address[]} addresses
|
|
121
|
+
* @param {RbacRoles[]} roles
|
|
122
|
+
* @param {?WriteParams<typeof rbacAbi, 'grantRoles'>} [params]
|
|
123
|
+
* @returns {unknown}
|
|
124
|
+
*/
|
|
125
|
+
public async grantRoles(
|
|
126
|
+
addresses: Address[],
|
|
127
|
+
roles: Roles[],
|
|
128
|
+
params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
|
|
129
|
+
) {
|
|
130
|
+
return await this.awaitResult(this.grantRolesRaw(addresses, roles, params));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Grant many accounts permissions on the rbac.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* await rbac.grantRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
141
|
+
* @async
|
|
142
|
+
* @param {Address[]} addresses
|
|
143
|
+
* @param {RbacRoles[]} roles
|
|
144
|
+
* @param {?WriteParams<typeof rbacAbi, 'grantRoles'>} [params]
|
|
145
|
+
* @returns {unknown}
|
|
146
|
+
*/
|
|
147
|
+
public async grantRolesRaw(
|
|
148
|
+
addresses: Address[],
|
|
149
|
+
roles: Roles[],
|
|
150
|
+
params?: WriteParams<typeof rbacAbi, 'grantRoles'>,
|
|
151
|
+
) {
|
|
152
|
+
const { request, result } = await simulateRbacGrantRoles(this._config, {
|
|
153
|
+
address: this.assertValidAddress(),
|
|
154
|
+
args: [addresses, roles],
|
|
155
|
+
...this.optionallyAttachAccount(),
|
|
156
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
157
|
+
...(params as any),
|
|
158
|
+
});
|
|
159
|
+
const hash = await writeRbacGrantRoles(
|
|
160
|
+
this._config,
|
|
161
|
+
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
162
|
+
request as any,
|
|
163
|
+
);
|
|
164
|
+
return { hash, result };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Revoke many accounts' permissions on the rbac.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
|
|
173
|
+
*
|
|
174
|
+
* @public
|
|
175
|
+
* @async
|
|
176
|
+
* @param {Address[]} addresses
|
|
177
|
+
* @param {RbacRoles[]} roles
|
|
178
|
+
* @param {?WriteParams<typeof rbacAbi, 'revokeRoles'>} [params]
|
|
179
|
+
* @returns {unknown}
|
|
180
|
+
*/
|
|
181
|
+
public async revokeRoles(
|
|
182
|
+
addresses: Address[],
|
|
183
|
+
roles: Roles[],
|
|
184
|
+
params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
|
|
185
|
+
) {
|
|
186
|
+
return await this.awaitResult(
|
|
187
|
+
this.revokeRolesRaw(addresses, roles, params),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Revoke many accounts' permissions on the rbac.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])
|
|
197
|
+
* @public
|
|
198
|
+
* @async
|
|
199
|
+
* @param {Address[]} addresses
|
|
200
|
+
* @param {RbacRoles[]} roles
|
|
201
|
+
* @param {?WriteParams<typeof rbacAbi, 'revokeRoles'>} [params]
|
|
202
|
+
* @returns {unknown}
|
|
203
|
+
*/
|
|
204
|
+
public async revokeRolesRaw(
|
|
205
|
+
addresses: Address[],
|
|
206
|
+
roles: Roles[],
|
|
207
|
+
params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,
|
|
208
|
+
) {
|
|
209
|
+
const { request, result } = await simulateRbacRevokeRoles(this._config, {
|
|
210
|
+
address: this.assertValidAddress(),
|
|
211
|
+
args: [addresses, roles],
|
|
212
|
+
...this.optionallyAttachAccount(),
|
|
213
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
214
|
+
...(params as any),
|
|
215
|
+
});
|
|
216
|
+
const hash = await writeRbacRevokeRoles(
|
|
217
|
+
this._config,
|
|
218
|
+
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
219
|
+
request as any,
|
|
220
|
+
);
|
|
221
|
+
return { hash, result };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Return an array of the roles assigned to the given account.
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* (await rbac.rolesOf(0xfoo)).includes(RbacRoles.ADMIN)
|
|
229
|
+
* @public
|
|
230
|
+
* @param {Address} account
|
|
231
|
+
* @param {?ReadParams<typeof rbacAbi, 'rolesOf'>} [params]
|
|
232
|
+
* @returns {Promise<Array<RbacRoles>>}
|
|
233
|
+
*/
|
|
234
|
+
public async rolesOf(
|
|
235
|
+
account: Address,
|
|
236
|
+
params?: ReadParams<typeof rbacAbi, 'rolesOf'>,
|
|
237
|
+
) {
|
|
238
|
+
const roles = await readRbacRolesOf(this._config, {
|
|
239
|
+
address: this.assertValidAddress(),
|
|
240
|
+
args: [account],
|
|
241
|
+
...this.optionallyAttachAccount(),
|
|
242
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
243
|
+
...(params as any),
|
|
244
|
+
});
|
|
245
|
+
return ([Roles.MANAGER, Roles.ADMIN] as unknown as Array<bigint>).filter(
|
|
246
|
+
(role) => (roles & role) === role,
|
|
247
|
+
) as unknown as Roles[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns whether given account has any of the provided roles bitmap.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* await rbac.hasAnyRole(0xfoo, RbacRoles.ADMIN | RbacRoles.MANAGER)
|
|
256
|
+
* @public
|
|
257
|
+
* @param {Address} account
|
|
258
|
+
* @param {RbacRoles} roles
|
|
259
|
+
* @param {?ReadParams<typeof rbacAbi, 'hasAnyRole'>} [params]
|
|
260
|
+
* @returns {Promise<boolean>}
|
|
261
|
+
*/
|
|
262
|
+
public hasAnyRole(
|
|
263
|
+
account: Address,
|
|
264
|
+
roles: Roles,
|
|
265
|
+
params?: ReadParams<typeof rbacAbi, 'hasAnyRole'>,
|
|
266
|
+
) {
|
|
267
|
+
return readRbacHasAnyRole(this._config, {
|
|
268
|
+
address: this.assertValidAddress(),
|
|
269
|
+
args: [account, roles],
|
|
270
|
+
...this.optionallyAttachAccount(),
|
|
271
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
272
|
+
...(params as any),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Returns whether given account has all of the provided roles bitmap.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* await rbac.hasAllRoles(0xfoo, RbacRoles.ADMIN & RbacRoles.MANAGER)
|
|
282
|
+
*
|
|
283
|
+
* @public
|
|
284
|
+
* @param {Address} account
|
|
285
|
+
* @param {RbacRoles} roles
|
|
286
|
+
* @param {?ReadParams<typeof rbacAbi, 'hasAllRoles'>} [params]
|
|
287
|
+
* @returns {*}
|
|
288
|
+
*/
|
|
289
|
+
public hasAllRoles(
|
|
290
|
+
account: Address,
|
|
291
|
+
roles: Roles,
|
|
292
|
+
params?: ReadParams<typeof rbacAbi, 'hasAllRoles'>,
|
|
293
|
+
) {
|
|
294
|
+
return readRbacHasAllRoles(this._config, {
|
|
295
|
+
address: this.assertValidAddress(),
|
|
296
|
+
args: [account, roles],
|
|
297
|
+
...this.optionallyAttachAccount(),
|
|
298
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
299
|
+
...(params as any),
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Check if the given account is authorized to use the rbac
|
|
305
|
+
*
|
|
306
|
+
* @public
|
|
307
|
+
* @param {Address} account
|
|
308
|
+
* @param {?ReadParams<typeof rbacAbi, 'isAuthorized'>} [params]
|
|
309
|
+
* @returns {Promise<boolean>} - True if the account is authorized
|
|
310
|
+
*/
|
|
311
|
+
public isAuthorized(
|
|
312
|
+
account: Address,
|
|
313
|
+
params?: ReadParams<typeof rbacAbi, 'isAuthorized'>,
|
|
314
|
+
) {
|
|
315
|
+
return readRbacIsAuthorized(this._config, {
|
|
316
|
+
address: this.assertValidAddress(),
|
|
317
|
+
args: [account],
|
|
318
|
+
...this.optionallyAttachAccount(),
|
|
319
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
320
|
+
...(params as any),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
package/src/index.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { describe, expect, test } from
|
|
2
|
-
import * as SDK from
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import * as SDK from "./index";
|
|
3
3
|
|
|
4
|
-
describe(
|
|
4
|
+
describe("sdk exports", () => {
|
|
5
5
|
test(`should export all public API`, () => {
|
|
6
6
|
expect(SDK.BoostRegistry).toBeDefined();
|
|
7
7
|
expect(SDK.BoostCore).toBeDefined();
|
|
@@ -14,7 +14,6 @@ describe('sdk exports', () => {
|
|
|
14
14
|
expect(SDK.SimpleAllowList).toBeDefined();
|
|
15
15
|
expect(SDK.SimpleDenyList).toBeDefined();
|
|
16
16
|
expect(SDK.ManagedBudget).toBeDefined();
|
|
17
|
-
// expect(SDK.SimpleBudget).toBeDefined();
|
|
18
17
|
// expect(SDK.VestingBudget).toBeDefined();
|
|
19
18
|
expect(SDK.AllowListIncentive).toBeDefined();
|
|
20
19
|
expect(SDK.CGDAIncentive).toBeDefined();
|
package/src/index.ts
CHANGED