@boostxyz/sdk 0.0.0-alpha.16 → 0.0.0-alpha.18
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 +7 -7
- package/dist/Actions/ContractAction.d.ts +9 -9
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +12 -12
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +32 -49
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +13 -779
- 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 +82 -36
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +44 -80
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +192 -9
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +5 -5
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +18 -0
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BiPwp6SR.cjs +3 -0
- package/dist/BoostCore-BiPwp6SR.cjs.map +1 -0
- package/dist/BoostCore-C00iqvks.js +1477 -0
- package/dist/BoostCore-C00iqvks.js.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +80 -35
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1273
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +18 -18
- package/dist/BoostRegistry.js +36 -36
- package/dist/BoostRegistry.js.map +1 -1
- 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 +24 -174
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +76 -298
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +181 -77
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +1 -1
- package/dist/Deployable/Contract.cjs.map +1 -1
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +4 -5
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +1 -1
- package/dist/Deployable/Deployable.js +1 -1
- package/dist/Deployable/Deployable.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.d.ts +5 -5
- package/dist/Deployable/DeployableTarget.js +10 -10
- package/dist/Deployable/DeployableTarget.js.map +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/EventAction-BO5WI_5s.js +1355 -0
- package/dist/EventAction-BO5WI_5s.js.map +1 -0
- package/dist/EventAction-DBDRaG4A.cjs +2 -0
- package/dist/EventAction-DBDRaG4A.cjs.map +1 -0
- package/dist/{Incentive-CtuAJAjG.js → Incentive-CF7kaz_9.js} +67 -68
- package/dist/Incentive-CF7kaz_9.js.map +1 -0
- package/dist/{Incentive-CqX3fYEd.cjs → Incentive-Djnzseoj.cjs} +2 -2
- package/dist/Incentive-Djnzseoj.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +12 -12
- package/dist/Incentives/AllowListIncentive.js +26 -26
- 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 +15 -15
- package/dist/Incentives/CGDAIncentive.js +25 -25
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +30 -30
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +23 -23
- package/dist/Incentives/ERC20Incentive.js +45 -45
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +19 -19
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.d.ts +3 -3
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +3 -3
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +14 -14
- package/dist/Incentives/PointsIncentive.js +20 -20
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BwfNjRsg.cjs +2 -0
- package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
- package/dist/SimpleDenyList-D9i4rw_F.js +132 -0
- package/dist/SimpleDenyList-D9i4rw_F.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +14 -14
- package/dist/Validators/SignerValidator.js +25 -25
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +1 -1
- package/dist/Validators/Validator.js +6 -6
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/claiming.cjs.map +1 -1
- package/dist/claiming.d.ts +1 -1
- package/dist/claiming.js.map +1 -1
- package/dist/componentInterfaces-D09mhzxO.cjs +2 -0
- package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
- package/dist/componentInterfaces-RXBMI5yH.js +14 -0
- package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
- package/dist/deployments-BM42vImE.js +43 -0
- package/dist/deployments-BM42vImE.js.map +1 -0
- package/dist/deployments-CMdF5uEC.cjs +2 -0
- package/dist/deployments-CMdF5uEC.cjs.map +1 -0
- package/dist/deployments.json +15 -12
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +132 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +122 -36
- package/dist/errors.js.map +1 -1
- package/dist/generated-B0tk-c9b.cjs +3 -0
- package/dist/generated-B0tk-c9b.cjs.map +1 -0
- package/dist/{generated-DLMdMwD1.js → generated-B8VWObPa.js} +2350 -1290
- package/dist/generated-B8VWObPa.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +134 -122
- package/dist/index.js.map +1 -1
- package/dist/transfers.cjs.map +1 -1
- package/dist/transfers.d.ts +1 -1
- package/dist/transfers.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +12 -5
- package/src/Actions/ContractAction.ts +9 -10
- package/src/Actions/ERC721MintAction.ts +12 -13
- package/src/Actions/EventAction.test.ts +182 -53
- package/src/Actions/EventAction.ts +128 -107
- package/src/AllowLists/SimpleAllowList.ts +14 -59
- package/src/AllowLists/SimpleDenyList.ts +12 -9
- package/src/Boost.ts +19 -0
- package/src/BoostCore.test.ts +117 -1
- package/src/BoostCore.ts +113 -54
- package/src/BoostRegistry.ts +18 -18
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.ts +21 -295
- package/src/Budgets/VestingBudget.ts +26 -97
- package/src/Deployable/Contract.ts +4 -5
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +5 -5
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.ts +12 -12
- package/src/Incentives/CGDAIncentive.ts +15 -15
- package/src/Incentives/ERC1155Incentive.ts +26 -26
- package/src/Incentives/ERC20Incentive.ts +23 -23
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
- package/src/Incentives/ERC20VariableIncentive.ts +19 -19
- package/src/Incentives/Incentive.ts +6 -5
- package/src/Incentives/PointsIncentive.test.ts +21 -21
- package/src/Incentives/PointsIncentive.ts +14 -14
- package/src/Validators/SignerValidator.ts +14 -14
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +1 -1
- package/src/errors.ts +165 -0
- package/src/index.test.ts +3 -4
- package/src/index.ts +2 -0
- package/src/transfers.ts +1 -1
- package/src/utils.ts +1 -1
- package/dist/Budgets/SimpleBudget.d.ts +0 -824
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/Incentive-CqX3fYEd.cjs.map +0 -1
- package/dist/Incentive-CtuAJAjG.js.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 +0 -2
- 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/deployments-BvFcK_eR.js +0 -40
- package/dist/deployments-BvFcK_eR.js.map +0 -1
- package/dist/deployments-Ho4PnGCS.cjs +0 -2
- package/dist/deployments-Ho4PnGCS.cjs.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
|
@@ -61,7 +61,7 @@ export class Contract<ContractAbi extends Abi> {
|
|
|
61
61
|
*
|
|
62
62
|
* @public
|
|
63
63
|
* @readonly
|
|
64
|
-
* @type {
|
|
64
|
+
* @type {Address | undefined}
|
|
65
65
|
*/
|
|
66
66
|
public get address() {
|
|
67
67
|
return this._address;
|
|
@@ -174,7 +174,6 @@ export class Contract<ContractAbi extends Abi> {
|
|
|
174
174
|
* A typed wrapper for `wagmi.watchContractEvent`
|
|
175
175
|
*
|
|
176
176
|
* @public
|
|
177
|
-
* @async
|
|
178
177
|
* @template {ContractEvent} event
|
|
179
178
|
* @param {(
|
|
180
179
|
* log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],
|
|
@@ -182,9 +181,9 @@ export class Contract<ContractAbi extends Abi> {
|
|
|
182
181
|
* @param {?WatchParams<ContractAbi, event> & {
|
|
183
182
|
* eventName?: event;
|
|
184
183
|
* }} [params]
|
|
185
|
-
* @returns {
|
|
184
|
+
* @returns {() => void}
|
|
186
185
|
*/
|
|
187
|
-
public
|
|
186
|
+
public subscribe<event extends ContractEventName<ContractAbi>>(
|
|
188
187
|
cb: (
|
|
189
188
|
log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],
|
|
190
189
|
) => unknown,
|
|
@@ -218,7 +217,7 @@ export class Contract<ContractAbi extends Abi> {
|
|
|
218
217
|
* @template [Result=unknown]
|
|
219
218
|
* @param {Promise<HashAndSimulatedResult<Result>>} hashPromise
|
|
220
219
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
|
|
221
|
-
* @returns {
|
|
220
|
+
* @returns {Promise<Result>}
|
|
222
221
|
*/
|
|
223
222
|
protected async awaitResult<Result = unknown>(
|
|
224
223
|
hashPromise: Promise<HashAndSimulatedResult<Result>>,
|
|
@@ -149,7 +149,7 @@ export class Deployable<
|
|
|
149
149
|
* @param {?Payload} [_payload]
|
|
150
150
|
* @param {?DeployableOptions} [_options]
|
|
151
151
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
|
|
152
|
-
* @returns {
|
|
152
|
+
* @returns {Promise<this>}
|
|
153
153
|
*/
|
|
154
154
|
protected async deploy(
|
|
155
155
|
_payload?: Payload,
|
|
@@ -131,7 +131,7 @@ export class DeployableTarget<
|
|
|
131
131
|
* @param {?Payload} [payload]
|
|
132
132
|
* @param {?DeployableOptions} [options]
|
|
133
133
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
|
|
134
|
-
* @returns {
|
|
134
|
+
* @returns {Promise<this>}
|
|
135
135
|
*/
|
|
136
136
|
protected override async deploy(
|
|
137
137
|
payload?: Payload,
|
|
@@ -174,8 +174,8 @@ export class DeployableTarget<
|
|
|
174
174
|
* @public
|
|
175
175
|
* @async
|
|
176
176
|
* @param {Hex} interfaceId - The interface identifier
|
|
177
|
-
* @param {?ReadParams
|
|
178
|
-
* @returns {
|
|
177
|
+
* @param {?ReadParams} [params]
|
|
178
|
+
* @returns {Promise<boolean>} - True if the contract supports the interface
|
|
179
179
|
*/
|
|
180
180
|
public async supportsInterface(
|
|
181
181
|
interfaceId: Hex,
|
|
@@ -196,8 +196,8 @@ export class DeployableTarget<
|
|
|
196
196
|
*
|
|
197
197
|
* @public
|
|
198
198
|
* @async
|
|
199
|
-
* @param {?ReadParams
|
|
200
|
-
* @returns {
|
|
199
|
+
* @param {?ReadParams} [params]
|
|
200
|
+
* @returns {Promise<Hex>}
|
|
201
201
|
*/
|
|
202
202
|
public async getComponentInterface(
|
|
203
203
|
params?: ReadParams<typeof aCloneableAbi, 'getComponentInterface'>,
|
|
@@ -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} [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} [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} [params]
|
|
123
|
+
* @returns {Promise<void>}
|
|
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} [params]
|
|
145
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
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} [params]
|
|
179
|
+
* @returns {Promise<void>}
|
|
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} [params]
|
|
202
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
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} [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} [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} [params]
|
|
287
|
+
* @returns {Promise<boolean>}
|
|
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} [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
|
+
}
|
|
@@ -112,8 +112,8 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
112
112
|
*
|
|
113
113
|
* @public
|
|
114
114
|
* @async
|
|
115
|
-
* @param {?ReadParams
|
|
116
|
-
* @returns {
|
|
115
|
+
* @param {?ReadParams} [params]
|
|
116
|
+
* @returns {Promise<Address>}
|
|
117
117
|
*/
|
|
118
118
|
public async owner(
|
|
119
119
|
params?: ReadParams<typeof allowListIncentiveAbi, 'owner'>,
|
|
@@ -131,7 +131,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
131
131
|
*
|
|
132
132
|
* @public
|
|
133
133
|
* @async
|
|
134
|
-
* @param {?ReadParams
|
|
134
|
+
* @param {?ReadParams} [params]
|
|
135
135
|
* @returns {Promise<bigint>}
|
|
136
136
|
*/
|
|
137
137
|
public async claims(
|
|
@@ -150,7 +150,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
150
150
|
*
|
|
151
151
|
* @public
|
|
152
152
|
* @async
|
|
153
|
-
* @param {?ReadParams
|
|
153
|
+
* @param {?ReadParams} [params]
|
|
154
154
|
* @returns {Promise<bigint>}
|
|
155
155
|
*/
|
|
156
156
|
public async reward(
|
|
@@ -170,7 +170,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
170
170
|
* @public
|
|
171
171
|
* @async
|
|
172
172
|
* @param {Address} address
|
|
173
|
-
* @param {?ReadParams
|
|
173
|
+
* @param {?ReadParams} [params]
|
|
174
174
|
* @returns {Promise<boolean>}
|
|
175
175
|
*/
|
|
176
176
|
public async claimed(
|
|
@@ -190,7 +190,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
190
190
|
*
|
|
191
191
|
* @public
|
|
192
192
|
* @async
|
|
193
|
-
* @param {?ReadParams
|
|
193
|
+
* @param {?ReadParams} [params]
|
|
194
194
|
* @returns {Promise<SimpleAllowList>}
|
|
195
195
|
*/
|
|
196
196
|
public async allowList(
|
|
@@ -212,8 +212,8 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
212
212
|
*
|
|
213
213
|
* @public
|
|
214
214
|
* @async
|
|
215
|
-
* @param {?ReadParams
|
|
216
|
-
* @returns {
|
|
215
|
+
* @param {?ReadParams} [params]
|
|
216
|
+
* @returns {Promise<bigint>}
|
|
217
217
|
*/
|
|
218
218
|
public async limit(
|
|
219
219
|
params?: ReadParams<typeof allowListIncentiveAbi, 'limit'>,
|
|
@@ -231,7 +231,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
231
231
|
* @public
|
|
232
232
|
* @async
|
|
233
233
|
* @param {Pick<ClaimPayload, 'target'>} payload
|
|
234
|
-
* @param {?WriteParams
|
|
234
|
+
* @param {?WriteParams} [params]
|
|
235
235
|
* @returns {Promise<true>} - return true if successful, otherwise revert
|
|
236
236
|
*/
|
|
237
237
|
protected async claim(
|
|
@@ -247,8 +247,8 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
247
247
|
* @public
|
|
248
248
|
* @async
|
|
249
249
|
* @param {Pick<ClaimPayload, 'target'>} payload
|
|
250
|
-
* @param {?WriteParams
|
|
251
|
-
* @returns {Promise<
|
|
250
|
+
* @param {?WriteParams} [params]
|
|
251
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - return true if successful, otherwise revert
|
|
252
252
|
*/
|
|
253
253
|
protected async claimRaw(
|
|
254
254
|
payload: Pick<ClaimPayload, 'target'>,
|
|
@@ -274,7 +274,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
274
274
|
* @public
|
|
275
275
|
* @async
|
|
276
276
|
* @param {Pick<ClaimPayload, 'target'>} payload
|
|
277
|
-
* @param {?ReadParams
|
|
277
|
+
* @param {?ReadParams} [params]
|
|
278
278
|
* @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
|
|
279
279
|
*/
|
|
280
280
|
public async isClaimable(
|
|
@@ -164,8 +164,8 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
164
164
|
*
|
|
165
165
|
* @public
|
|
166
166
|
* @async
|
|
167
|
-
* @param {?ReadParams
|
|
168
|
-
* @returns {
|
|
167
|
+
* @param {?ReadParams} [params]
|
|
168
|
+
* @returns {Promise<Address>}
|
|
169
169
|
*/
|
|
170
170
|
public async owner(params?: ReadParams<typeof cgdaIncentiveAbi, 'owner'>) {
|
|
171
171
|
return await readCgdaIncentiveOwner(this._config, {
|
|
@@ -181,7 +181,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
181
181
|
*
|
|
182
182
|
* @public
|
|
183
183
|
* @async
|
|
184
|
-
* @param {?ReadParams
|
|
184
|
+
* @param {?ReadParams} [params]
|
|
185
185
|
* @returns {Promise<bigint>}
|
|
186
186
|
*/
|
|
187
187
|
public async claims(params?: ReadParams<typeof cgdaIncentiveAbi, 'claims'>) {
|
|
@@ -198,7 +198,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
198
198
|
*
|
|
199
199
|
* @public
|
|
200
200
|
* @async
|
|
201
|
-
* @param {?ReadParams
|
|
201
|
+
* @param {?ReadParams} [params]
|
|
202
202
|
* @returns {Promise<bigint>}
|
|
203
203
|
*/
|
|
204
204
|
public async reward(params?: ReadParams<typeof cgdaIncentiveAbi, 'reward'>) {
|
|
@@ -216,7 +216,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
216
216
|
* @public
|
|
217
217
|
* @async
|
|
218
218
|
* @param {Address} address
|
|
219
|
-
* @param {?ReadParams
|
|
219
|
+
* @param {?ReadParams} [params]
|
|
220
220
|
* @returns {Promise<boolean>}
|
|
221
221
|
*/
|
|
222
222
|
public async claimed(
|
|
@@ -236,8 +236,8 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
236
236
|
*
|
|
237
237
|
* @public
|
|
238
238
|
* @async
|
|
239
|
-
* @param {?ReadParams
|
|
240
|
-
* @returns {
|
|
239
|
+
* @param {?ReadParams} [params]
|
|
240
|
+
* @returns {Promise<Address>}
|
|
241
241
|
*/
|
|
242
242
|
public async asset(params?: ReadParams<typeof cgdaIncentiveAbi, 'asset'>) {
|
|
243
243
|
return await readCgdaIncentiveAsset(this._config, {
|
|
@@ -252,7 +252,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
252
252
|
*
|
|
253
253
|
* @public
|
|
254
254
|
* @async
|
|
255
|
-
* @param {?ReadParams
|
|
255
|
+
* @param {?ReadParams} [params]
|
|
256
256
|
* @returns {Promise<CGDAParameters>}
|
|
257
257
|
*/
|
|
258
258
|
public async cgdaParams(
|
|
@@ -277,7 +277,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
277
277
|
*
|
|
278
278
|
* @public
|
|
279
279
|
* @async
|
|
280
|
-
* @param {?ReadParams
|
|
280
|
+
* @param {?ReadParams} [params]
|
|
281
281
|
* @returns {Promise<bigint>}
|
|
282
282
|
*/
|
|
283
283
|
public async totalBudget(
|
|
@@ -296,7 +296,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
296
296
|
* @public
|
|
297
297
|
* @async
|
|
298
298
|
* @param {ClaimPayload} payload
|
|
299
|
-
* @param {?WriteParams
|
|
299
|
+
* @param {?WriteParams} [params]
|
|
300
300
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
301
301
|
*/
|
|
302
302
|
protected async claim(
|
|
@@ -312,7 +312,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
312
312
|
* @public
|
|
313
313
|
* @async
|
|
314
314
|
* @param {ClaimPayload} payload
|
|
315
|
-
* @param {?WriteParams
|
|
315
|
+
* @param {?WriteParams} [params]
|
|
316
316
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
317
317
|
*/
|
|
318
318
|
protected async claimRaw(
|
|
@@ -336,7 +336,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
336
336
|
* @public
|
|
337
337
|
* @async
|
|
338
338
|
* @param {ClaimPayload} payload
|
|
339
|
-
* @param {?WriteParams
|
|
339
|
+
* @param {?WriteParams} [params]
|
|
340
340
|
* @returns {Promise<boolean>} - True if the assets were successfully clawbacked
|
|
341
341
|
*/
|
|
342
342
|
public async clawback(
|
|
@@ -352,7 +352,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
352
352
|
* @public
|
|
353
353
|
* @async
|
|
354
354
|
* @param {ClaimPayload} payload
|
|
355
|
-
* @param {?WriteParams
|
|
355
|
+
* @param {?WriteParams} [params]
|
|
356
356
|
* @returns {Promise<boolean>} - True if the assets were successfully clawbacked
|
|
357
357
|
*/
|
|
358
358
|
public async clawbackRaw(
|
|
@@ -379,7 +379,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
379
379
|
* @public
|
|
380
380
|
* @async
|
|
381
381
|
* @param {ClaimPayload} payload
|
|
382
|
-
* @param {?ReadParams
|
|
382
|
+
* @param {?ReadParams} [params]
|
|
383
383
|
* @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
|
|
384
384
|
*/
|
|
385
385
|
public async isClaimable(
|
|
@@ -401,7 +401,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
401
401
|
*
|
|
402
402
|
* @public
|
|
403
403
|
* @async
|
|
404
|
-
* @param {?ReadParams
|
|
404
|
+
* @param {?ReadParams} [params]
|
|
405
405
|
* @returns {Promise<bigint>} - The current reward
|
|
406
406
|
*/
|
|
407
407
|
public async currentReward(
|