@boostxyz/sdk 0.0.0-alpha.8 → 1.1.0-alpha.22
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 +57 -14
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +50 -23
- 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 +420 -45
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -225
- 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.d.ts +6 -4
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +45 -23
- package/dist/AllowLists/AllowList.js.map +1 -1
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +123 -39
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +75 -76
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -200
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -1
- package/dist/Auth/PassthroughAuth.js +4 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +137 -5
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BVZExPPu.js +1462 -0
- package/dist/BoostCore-BVZExPPu.js.map +1 -0
- package/dist/BoostCore-D-E-cnGI.cjs +3 -0
- package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +759 -82
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1148
- 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 +83 -28
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +170 -93
- 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 +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +89 -290
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- 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 +6 -8
- 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.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +3 -5
- 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 +13 -13
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +30 -27
- 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-BZt5cjbe.cjs +2 -0
- package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
- package/dist/EventAction-C_-hJXWm.js +1541 -0
- package/dist/EventAction-C_-hJXWm.js.map +1 -0
- package/dist/Incentive-BhHaK3PZ.cjs +2 -0
- package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
- package/dist/Incentive-Cqg1w6wD.js +312 -0
- package/dist/Incentive-Cqg1w6wD.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +73 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +61 -36
- 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 +323 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +73 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- 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 +278 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +79 -47
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +346 -420
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +271 -32
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.d.ts +4 -4
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +16 -280
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +89 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +66 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.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 +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +164 -36
- 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 +2 -2
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/claiming.cjs +2 -0
- package/dist/claiming.cjs.map +1 -0
- package/dist/claiming.d.ts +43 -0
- package/dist/claiming.d.ts.map +1 -0
- package/dist/claiming.js +17 -0
- package/dist/claiming.js.map +1 -0
- package/dist/componentInterfaces-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +257 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-Cbv8zFkf.js → generated-CKt2yCQd.js} +3615 -1868
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -126
- package/dist/index.js.map +1 -1
- package/dist/transfers.cjs +2 -0
- package/dist/transfers.cjs.map +1 -0
- package/dist/transfers.d.ts +198 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +84 -0
- package/dist/transfers.js.map +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +25 -1380
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +36 -648
- package/dist/utils.js.map +1 -1
- package/package.json +34 -10
- package/src/Actions/Action.test.ts +19 -17
- package/src/Actions/ContractAction.test.ts +14 -16
- package/src/Actions/ContractAction.ts +84 -22
- package/src/Actions/ERC721MintAction.test.ts +8 -8
- package/src/Actions/ERC721MintAction.ts +83 -30
- package/src/Actions/EventAction.test.ts +759 -113
- package/src/Actions/EventAction.ts +991 -116
- package/src/AllowLists/AllowList.test.ts +7 -7
- package/src/AllowLists/AllowList.ts +5 -3
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +4 -4
- package/src/AllowLists/SimpleAllowList.ts +86 -65
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +87 -126
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Auth/PassthroughAuth.ts +1 -1
- package/src/Boost.ts +147 -15
- package/src/BoostCore.test.ts +326 -278
- package/src/BoostCore.ts +425 -242
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +168 -50
- package/src/Budgets/Budget.test.ts +2 -2
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.test.ts +82 -19
- package/src/Budgets/ManagedBudget.ts +106 -315
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +110 -112
- package/src/Deployable/Contract.ts +5 -6
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +32 -21
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +7 -10
- package/src/Incentives/AllowListIncentive.ts +88 -30
- package/src/Incentives/CGDAIncentive.test.ts +11 -12
- package/src/Incentives/CGDAIncentive.ts +161 -37
- package/src/Incentives/ERC1155Incentive.test.ts +5 -16
- package/src/Incentives/ERC1155Incentive.ts +132 -51
- package/src/Incentives/ERC20Incentive.test.ts +15 -23
- package/src/Incentives/ERC20Incentive.ts +131 -46
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +12 -35
- package/src/Incentives/ERC20VariableIncentive.ts +118 -43
- package/src/Incentives/Incentive.test.ts +5 -2
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +26 -30
- package/src/Incentives/PointsIncentive.ts +110 -34
- package/src/Validators/SignerValidator.test.ts +9 -13
- package/src/Validators/SignerValidator.ts +437 -26
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +56 -0
- package/src/errors.ts +346 -22
- package/src/index.test.ts +118 -36
- package/src/index.ts +15 -7
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -2061
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-DYkaxBda.js +0 -13
- package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
- package/dist/generated-BzszviNp.cjs +0 -3
- package/dist/generated-BzszviNp.cjs.map +0 -1
- package/dist/generated-Cbv8zFkf.js.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -521
|
@@ -29,13 +29,17 @@ import {
|
|
|
29
29
|
type Address,
|
|
30
30
|
type ContractEventName,
|
|
31
31
|
type Hex,
|
|
32
|
+
encodeAbiParameters,
|
|
33
|
+
parseAbiParameters,
|
|
32
34
|
zeroAddress,
|
|
33
35
|
} from 'viem';
|
|
36
|
+
import { ManagedBudget as ManagedBudgetBases } from '../../dist/deployments.json';
|
|
34
37
|
import type {
|
|
35
38
|
DeployableOptions,
|
|
36
39
|
GenericDeployableParams,
|
|
37
40
|
} from '../Deployable/Deployable';
|
|
38
41
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
42
|
+
import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
|
|
39
43
|
import {
|
|
40
44
|
DeployableUnknownOwnerProvidedError,
|
|
41
45
|
UnknownTransferPayloadSupplied,
|
|
@@ -43,34 +47,61 @@ import {
|
|
|
43
47
|
import {
|
|
44
48
|
type ERC1155TransferPayload,
|
|
45
49
|
type FungibleTransferPayload,
|
|
50
|
+
prepareERC1155Transfer,
|
|
51
|
+
prepareFungibleTransfer,
|
|
52
|
+
} from '../transfers';
|
|
53
|
+
import {
|
|
46
54
|
type GenericLog,
|
|
47
|
-
type ManagedBudgetPayload,
|
|
48
55
|
type ReadParams,
|
|
49
56
|
RegistryType,
|
|
50
57
|
type WriteParams,
|
|
51
|
-
prepareERC1155Transfer,
|
|
52
|
-
prepareFungibleTransfer,
|
|
53
|
-
prepareManagedBudgetPayload,
|
|
54
58
|
} from '../utils';
|
|
55
|
-
|
|
56
59
|
export { managedBudgetAbi };
|
|
57
|
-
export type {
|
|
58
|
-
ERC1155TransferPayload,
|
|
59
|
-
FungibleTransferPayload,
|
|
60
|
-
ManagedBudgetPayload,
|
|
61
|
-
};
|
|
60
|
+
export type { ERC1155TransferPayload, FungibleTransferPayload };
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
|
-
*
|
|
63
|
+
* The object representation of a `ManagedBudgetPayload.InitPayload`
|
|
64
|
+
*
|
|
65
|
+
* @export
|
|
66
|
+
* @interface ManagedBudgetPayload
|
|
67
|
+
* @typedef {ManagedBudgetPayload}
|
|
68
|
+
*/
|
|
69
|
+
export interface ManagedBudgetPayload {
|
|
70
|
+
/**
|
|
71
|
+
* The budget's owner
|
|
72
|
+
*
|
|
73
|
+
* @type {Address}
|
|
74
|
+
*/
|
|
75
|
+
owner: Address;
|
|
76
|
+
/**
|
|
77
|
+
* List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
78
|
+
*
|
|
79
|
+
* @type {Address[]}
|
|
80
|
+
*/
|
|
81
|
+
authorized: Address[];
|
|
82
|
+
/**
|
|
83
|
+
* List of roles to assign to the corresponding account by index.
|
|
84
|
+
*
|
|
85
|
+
* @type {ManagedBudgetRoles[]}
|
|
86
|
+
*/
|
|
87
|
+
roles: ManagedBudgetRoles[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Enum representing available roles for use in the `ManagedBudget`.
|
|
65
92
|
* `MANAGER` can disburse funds.
|
|
66
93
|
* `ADMIN` can additionally manage authorized users on the budget.
|
|
67
94
|
*
|
|
95
|
+
* @export
|
|
68
96
|
* @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}
|
|
97
|
+
* @enum {bigint}
|
|
69
98
|
*/
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
99
|
+
export enum ManagedBudgetRoles {
|
|
100
|
+
//@ts-expect-error ts doesn't like bigint enum values
|
|
101
|
+
MANAGER = 1n,
|
|
102
|
+
//@ts-expect-error ts doesn't like bigint enum values
|
|
103
|
+
ADMIN = 2n,
|
|
104
|
+
}
|
|
74
105
|
|
|
75
106
|
/**
|
|
76
107
|
* A generic `viem.Log` event with support for `ManagedBudget` event types.
|
|
@@ -118,7 +149,7 @@ export function isERC1155TransferPayload(
|
|
|
118
149
|
*
|
|
119
150
|
* @export
|
|
120
151
|
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
121
|
-
* @returns {
|
|
152
|
+
* @returns {Hex}
|
|
122
153
|
* @throws {@link UnknownTransferPayloadSupplied}
|
|
123
154
|
*/
|
|
124
155
|
export function prepareTransfer(
|
|
@@ -126,9 +157,11 @@ export function prepareTransfer(
|
|
|
126
157
|
) {
|
|
127
158
|
if (isFungibleTransfer(transfer)) {
|
|
128
159
|
return prepareFungibleTransfer(transfer);
|
|
129
|
-
}
|
|
160
|
+
}
|
|
161
|
+
if (isERC1155TransferPayload(transfer)) {
|
|
130
162
|
return prepareERC1155Transfer(transfer);
|
|
131
|
-
}
|
|
163
|
+
}
|
|
164
|
+
throw new UnknownTransferPayloadSupplied(transfer);
|
|
132
165
|
}
|
|
133
166
|
|
|
134
167
|
/**
|
|
@@ -138,9 +171,9 @@ export function prepareTransfer(
|
|
|
138
171
|
* @export
|
|
139
172
|
* @class ManagedBudget
|
|
140
173
|
* @typedef {ManagedBudget}
|
|
141
|
-
* @extends {
|
|
174
|
+
* @extends {DeployableTargetWithRBAC<ManagedBudgetPayload>}
|
|
142
175
|
*/
|
|
143
|
-
export class ManagedBudget extends
|
|
176
|
+
export class ManagedBudget extends DeployableTargetWithRBAC<
|
|
144
177
|
ManagedBudgetPayload,
|
|
145
178
|
typeof managedBudgetAbi
|
|
146
179
|
> {
|
|
@@ -157,10 +190,11 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
157
190
|
*
|
|
158
191
|
* @public
|
|
159
192
|
* @static
|
|
160
|
-
* @type {Address}
|
|
193
|
+
* @type {Record<number, Address>}
|
|
161
194
|
*/
|
|
162
|
-
public static override
|
|
163
|
-
|
|
195
|
+
public static override bases: Record<number, Address> = {
|
|
196
|
+
...(ManagedBudgetBases as Record<number, Address>),
|
|
197
|
+
};
|
|
164
198
|
/**
|
|
165
199
|
* @inheritdoc
|
|
166
200
|
*
|
|
@@ -178,14 +212,14 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
178
212
|
* @public
|
|
179
213
|
* @async
|
|
180
214
|
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
181
|
-
* @param {?WriteParams
|
|
215
|
+
* @param {?WriteParams} [params]
|
|
182
216
|
* @returns {Promise<boolean>} - True if the allocation was successful
|
|
183
217
|
*/
|
|
184
218
|
public async allocate(
|
|
185
219
|
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
186
220
|
params?: WriteParams<typeof managedBudgetAbi, 'allocate'>,
|
|
187
221
|
) {
|
|
188
|
-
return this.awaitResult(this.allocateRaw(transfer, params));
|
|
222
|
+
return await this.awaitResult(this.allocateRaw(transfer, params));
|
|
189
223
|
}
|
|
190
224
|
|
|
191
225
|
/**
|
|
@@ -196,8 +230,8 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
196
230
|
* @public
|
|
197
231
|
* @async
|
|
198
232
|
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
199
|
-
* @param {?WriteParams
|
|
200
|
-
* @returns {Promise<boolean>} - True if the allocation was successful
|
|
233
|
+
* @param {?WriteParams} [params]
|
|
234
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the allocation was successful
|
|
201
235
|
*/
|
|
202
236
|
public async allocateRaw(
|
|
203
237
|
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
@@ -226,14 +260,14 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
226
260
|
* @public
|
|
227
261
|
* @async
|
|
228
262
|
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
229
|
-
* @param {?WriteParams
|
|
263
|
+
* @param {?WriteParams} [params]
|
|
230
264
|
* @returns {Promise<boolean>} - True if the request was successful
|
|
231
265
|
*/
|
|
232
266
|
public async clawback(
|
|
233
267
|
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
234
268
|
params?: WriteParams<typeof managedBudgetAbi, 'clawback'>,
|
|
235
269
|
) {
|
|
236
|
-
return this.awaitResult(this.clawbackRaw(transfer, params));
|
|
270
|
+
return await this.awaitResult(this.clawbackRaw(transfer, params));
|
|
237
271
|
}
|
|
238
272
|
|
|
239
273
|
/**
|
|
@@ -245,8 +279,8 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
245
279
|
* @public
|
|
246
280
|
* @async
|
|
247
281
|
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
248
|
-
* @param {?WriteParams
|
|
249
|
-
* @returns {Promise<boolean>} - True if the request was successful
|
|
282
|
+
* @param {?WriteParams} [params]
|
|
283
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the request was successful
|
|
250
284
|
*/
|
|
251
285
|
public async clawbackRaw(
|
|
252
286
|
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
@@ -273,14 +307,14 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
273
307
|
* @public
|
|
274
308
|
* @async
|
|
275
309
|
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
276
|
-
* @param {?WriteParams
|
|
310
|
+
* @param {?WriteParams} [params]
|
|
277
311
|
* @returns {Promise<boolean>} - True if the disbursement was successful
|
|
278
312
|
*/
|
|
279
313
|
public async disburse(
|
|
280
314
|
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
281
315
|
params?: WriteParams<typeof managedBudgetAbi, 'disburse'>,
|
|
282
316
|
) {
|
|
283
|
-
return this.awaitResult(this.disburseRaw(transfer, params));
|
|
317
|
+
return await this.awaitResult(this.disburseRaw(transfer, params));
|
|
284
318
|
}
|
|
285
319
|
|
|
286
320
|
/**
|
|
@@ -290,8 +324,8 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
290
324
|
* @public
|
|
291
325
|
* @async
|
|
292
326
|
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
293
|
-
* @param {?WriteParams
|
|
294
|
-
* @returns {Promise<boolean>} - True if the disbursement was successful
|
|
327
|
+
* @param {?WriteParams} [params]
|
|
328
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the disbursement was successful
|
|
295
329
|
*/
|
|
296
330
|
public async disburseRaw(
|
|
297
331
|
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
@@ -317,14 +351,14 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
317
351
|
* @public
|
|
318
352
|
* @async
|
|
319
353
|
* @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
|
|
320
|
-
* @param {?WriteParams
|
|
354
|
+
* @param {?WriteParams} [params]
|
|
321
355
|
* @returns {Promise<boolean>} - True if all disbursements were successful
|
|
322
356
|
*/
|
|
323
357
|
public async disburseBatch(
|
|
324
358
|
transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
|
|
325
359
|
params?: WriteParams<typeof managedBudgetAbi, 'disburseBatch'>,
|
|
326
360
|
) {
|
|
327
|
-
return this.awaitResult(this.disburseBatchRaw(transfers, params));
|
|
361
|
+
return await this.awaitResult(this.disburseBatchRaw(transfers, params));
|
|
328
362
|
}
|
|
329
363
|
|
|
330
364
|
/**
|
|
@@ -333,8 +367,8 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
333
367
|
* @public
|
|
334
368
|
* @async
|
|
335
369
|
* @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
|
|
336
|
-
* @param {?WriteParams
|
|
337
|
-
* @returns {Promise<boolean>} - True if all disbursements were successful
|
|
370
|
+
* @param {?WriteParams} [params]
|
|
371
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if all disbursements were successful
|
|
338
372
|
*/
|
|
339
373
|
public async disburseBatchRaw(
|
|
340
374
|
transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
|
|
@@ -354,277 +388,11 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
354
388
|
return { hash, result };
|
|
355
389
|
}
|
|
356
390
|
|
|
357
|
-
/**
|
|
358
|
-
* Set the authorized status of the given accounts
|
|
359
|
-
* The mechanism for managing authorization is left to the implementing contract
|
|
360
|
-
*
|
|
361
|
-
* @public
|
|
362
|
-
* @async
|
|
363
|
-
* @param {Address[]} addresses - The accounts to authorize or deauthorize
|
|
364
|
-
* @param {boolean[]} allowed - The authorization status for the given accounts
|
|
365
|
-
* @param {?WriteParams<typeof managedBudgetAbi, 'setAuthorized'>} [params]
|
|
366
|
-
* @returns {Promise<void>}
|
|
367
|
-
*/
|
|
368
|
-
public async setAuthorized(
|
|
369
|
-
addresses: Address[],
|
|
370
|
-
allowed: boolean[],
|
|
371
|
-
params?: WriteParams<typeof managedBudgetAbi, 'setAuthorized'>,
|
|
372
|
-
) {
|
|
373
|
-
return this.awaitResult(this.setAuthorizedRaw(addresses, allowed, params));
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Set the authorized status of the given accounts
|
|
378
|
-
* The mechanism for managing authorization is left to the implementing contract
|
|
379
|
-
*
|
|
380
|
-
* @public
|
|
381
|
-
* @async
|
|
382
|
-
* @param {Address[]} addresses - The accounts to authorize or deauthorize
|
|
383
|
-
* @param {boolean[]} allowed - The authorization status for the given accounts
|
|
384
|
-
* @param {?WriteParams<typeof managedBudgetAbi, 'setAuthorized'>} [params]
|
|
385
|
-
* @returns {Promise<void>}
|
|
386
|
-
*/
|
|
387
|
-
public async setAuthorizedRaw(
|
|
388
|
-
addresses: Address[],
|
|
389
|
-
allowed: boolean[],
|
|
390
|
-
params?: WriteParams<typeof managedBudgetAbi, 'setAuthorized'>,
|
|
391
|
-
) {
|
|
392
|
-
const { request, result } = await simulateManagedBudgetSetAuthorized(
|
|
393
|
-
this._config,
|
|
394
|
-
{
|
|
395
|
-
address: this.assertValidAddress(),
|
|
396
|
-
args: [addresses, allowed],
|
|
397
|
-
...this.optionallyAttachAccount(),
|
|
398
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
399
|
-
...(params as any),
|
|
400
|
-
},
|
|
401
|
-
);
|
|
402
|
-
const hash = await writeManagedBudgetSetAuthorized(this._config, request);
|
|
403
|
-
return { hash, result };
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Grant many accounts permissions on the budget.
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* ```ts
|
|
411
|
-
* await budget.grantRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
|
|
412
|
-
* ```
|
|
413
|
-
* @public
|
|
414
|
-
* @async
|
|
415
|
-
* @param {Address[]} addresses
|
|
416
|
-
* @param {bigint[]} roles
|
|
417
|
-
* @param {?WriteParams<typeof managedBudgetAbi, 'grantRoles'>} [params]
|
|
418
|
-
* @returns {unknown}
|
|
419
|
-
*/
|
|
420
|
-
public async grantRoles(
|
|
421
|
-
addresses: Address[],
|
|
422
|
-
roles: bigint[],
|
|
423
|
-
params?: WriteParams<typeof managedBudgetAbi, 'grantRoles'>,
|
|
424
|
-
) {
|
|
425
|
-
return this.awaitResult(this.grantRolesRaw(addresses, roles, params));
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Grant many accounts permissions on the budget.
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
* ```ts
|
|
433
|
-
* await budget.grantRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
|
|
434
|
-
*
|
|
435
|
-
* @public
|
|
436
|
-
* @async
|
|
437
|
-
* @param {Address[]} addresses
|
|
438
|
-
* @param {bigint[]} roles
|
|
439
|
-
* @param {?WriteParams<typeof managedBudgetAbi, 'grantRoles'>} [params]
|
|
440
|
-
* @returns {unknown}
|
|
441
|
-
*/
|
|
442
|
-
public async grantRolesRaw(
|
|
443
|
-
addresses: Address[],
|
|
444
|
-
roles: bigint[],
|
|
445
|
-
params?: WriteParams<typeof managedBudgetAbi, 'grantRoles'>,
|
|
446
|
-
) {
|
|
447
|
-
const { request, result } = await simulateManagedBudgetGrantRoles(
|
|
448
|
-
this._config,
|
|
449
|
-
{
|
|
450
|
-
address: this.assertValidAddress(),
|
|
451
|
-
args: [addresses, roles],
|
|
452
|
-
...this.optionallyAttachAccount(),
|
|
453
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
454
|
-
...(params as any),
|
|
455
|
-
},
|
|
456
|
-
);
|
|
457
|
-
const hash = await writeManagedBudgetGrantRoles(
|
|
458
|
-
this._config,
|
|
459
|
-
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
460
|
-
request as any,
|
|
461
|
-
);
|
|
462
|
-
return { hash, result };
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Revoke many accounts' permissions on the budget.
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* ```ts
|
|
470
|
-
* await budget.revokeRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
|
|
471
|
-
*
|
|
472
|
-
* @public
|
|
473
|
-
* @async
|
|
474
|
-
* @param {Address[]} addresses
|
|
475
|
-
* @param {bigint[]} roles
|
|
476
|
-
* @param {?WriteParams<typeof managedBudgetAbi, 'revokeRoles'>} [params]
|
|
477
|
-
* @returns {unknown}
|
|
478
|
-
*/
|
|
479
|
-
public async revokeRoles(
|
|
480
|
-
addresses: Address[],
|
|
481
|
-
roles: bigint[],
|
|
482
|
-
params?: WriteParams<typeof managedBudgetAbi, 'revokeRoles'>,
|
|
483
|
-
) {
|
|
484
|
-
return this.awaitResult(this.revokeRolesRaw(addresses, roles, params));
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Revoke many accounts' permissions on the budget.
|
|
489
|
-
*
|
|
490
|
-
* @example
|
|
491
|
-
* ```ts
|
|
492
|
-
* await budget.revokeRoles(['0xfoo', '0xbar], [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN])
|
|
493
|
-
* @public
|
|
494
|
-
* @async
|
|
495
|
-
* @param {Address[]} addresses
|
|
496
|
-
* @param {bigint[]} roles
|
|
497
|
-
* @param {?WriteParams<typeof managedBudgetAbi, 'revokeRoles'>} [params]
|
|
498
|
-
* @returns {unknown}
|
|
499
|
-
*/
|
|
500
|
-
public async revokeRolesRaw(
|
|
501
|
-
addresses: Address[],
|
|
502
|
-
roles: bigint[],
|
|
503
|
-
params?: WriteParams<typeof managedBudgetAbi, 'revokeRoles'>,
|
|
504
|
-
) {
|
|
505
|
-
const { request, result } = await simulateManagedBudgetRevokeRoles(
|
|
506
|
-
this._config,
|
|
507
|
-
{
|
|
508
|
-
address: this.assertValidAddress(),
|
|
509
|
-
args: [addresses, roles],
|
|
510
|
-
...this.optionallyAttachAccount(),
|
|
511
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
512
|
-
...(params as any),
|
|
513
|
-
},
|
|
514
|
-
);
|
|
515
|
-
const hash = await writeManagedBudgetRevokeRoles(
|
|
516
|
-
this._config,
|
|
517
|
-
// biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection
|
|
518
|
-
request as any,
|
|
519
|
-
);
|
|
520
|
-
return { hash, result };
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Return an array of the roles assigned to the given account.
|
|
525
|
-
* @example
|
|
526
|
-
* ```ts
|
|
527
|
-
* (await budget.rolesOf(0xfoo)).includes(ManagedBudgetRoles.ADMIN)
|
|
528
|
-
* @public
|
|
529
|
-
* @param {Address} account
|
|
530
|
-
* @param {?ReadParams<typeof managedBudgetAbi, 'rolesOf'>} [params]
|
|
531
|
-
* @returns {Promise<Array<bigint>>}
|
|
532
|
-
*/
|
|
533
|
-
public async rolesOf(
|
|
534
|
-
account: Address,
|
|
535
|
-
params?: ReadParams<typeof managedBudgetAbi, 'rolesOf'>,
|
|
536
|
-
) {
|
|
537
|
-
const roles = await readManagedBudgetRolesOf(this._config, {
|
|
538
|
-
address: this.assertValidAddress(),
|
|
539
|
-
args: [account],
|
|
540
|
-
...this.optionallyAttachAccount(),
|
|
541
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
542
|
-
...(params as any),
|
|
543
|
-
});
|
|
544
|
-
return [ManagedBudgetRoles.MANAGER, ManagedBudgetRoles.ADMIN].filter(
|
|
545
|
-
(role) => (roles & role) === role,
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Returns whether given account has any of the provided roles bitmap.
|
|
551
|
-
*
|
|
552
|
-
* @example
|
|
553
|
-
* ```ts
|
|
554
|
-
* await budget.hasAnyRole(0xfoo, ManagedBudgetRoles.ADMIN | ManagedBudgetRoles.MANAGER)
|
|
555
|
-
* @public
|
|
556
|
-
* @param {Address} account
|
|
557
|
-
* @param {bigint} roles
|
|
558
|
-
* @param {?ReadParams<typeof managedBudgetAbi, 'hasAnyRole'>} [params]
|
|
559
|
-
* @returns {Promise<boolean>}
|
|
560
|
-
*/
|
|
561
|
-
public hasAnyRole(
|
|
562
|
-
account: Address,
|
|
563
|
-
roles: bigint,
|
|
564
|
-
params?: ReadParams<typeof managedBudgetAbi, 'hasAnyRole'>,
|
|
565
|
-
) {
|
|
566
|
-
return readManagedBudgetHasAnyRole(this._config, {
|
|
567
|
-
address: this.assertValidAddress(),
|
|
568
|
-
args: [account, roles],
|
|
569
|
-
...this.optionallyAttachAccount(),
|
|
570
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
571
|
-
...(params as any),
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Returns whether given account has all of the provided roles bitmap.
|
|
577
|
-
*
|
|
578
|
-
* @example
|
|
579
|
-
* ```ts
|
|
580
|
-
* await budget.hasAllRoles(0xfoo, ManagedBudgetRoles.ADMIN & ManagedBudgetRoles.MANAGER)
|
|
581
|
-
*
|
|
582
|
-
* @public
|
|
583
|
-
* @param {Address} account
|
|
584
|
-
* @param {bigint} roles
|
|
585
|
-
* @param {?ReadParams<typeof managedBudgetAbi, 'hasAllRoles'>} [params]
|
|
586
|
-
* @returns {*}
|
|
587
|
-
*/
|
|
588
|
-
public hasAllRoles(
|
|
589
|
-
account: Address,
|
|
590
|
-
roles: bigint,
|
|
591
|
-
params?: ReadParams<typeof managedBudgetAbi, 'hasAllRoles'>,
|
|
592
|
-
) {
|
|
593
|
-
return readManagedBudgetHasAllRoles(this._config, {
|
|
594
|
-
address: this.assertValidAddress(),
|
|
595
|
-
args: [account, roles],
|
|
596
|
-
...this.optionallyAttachAccount(),
|
|
597
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
598
|
-
...(params as any),
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* Check if the given account is authorized to use the budget
|
|
604
|
-
*
|
|
605
|
-
* @public
|
|
606
|
-
* @param {Address} account
|
|
607
|
-
* @param {?ReadParams<typeof managedBudgetAbi, 'isAuthorized'>} [params]
|
|
608
|
-
* @returns {Promise<boolean>} - True if the account is authorized
|
|
609
|
-
*/
|
|
610
|
-
public isAuthorized(
|
|
611
|
-
account: Address,
|
|
612
|
-
params?: ReadParams<typeof managedBudgetAbi, 'isAuthorized'>,
|
|
613
|
-
) {
|
|
614
|
-
return readManagedBudgetIsAuthorized(this._config, {
|
|
615
|
-
address: this.assertValidAddress(),
|
|
616
|
-
args: [account],
|
|
617
|
-
...this.optionallyAttachAccount(),
|
|
618
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
619
|
-
...(params as any),
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
|
|
623
391
|
/**
|
|
624
392
|
* Get the owner of the budget
|
|
625
393
|
*
|
|
626
394
|
* @public
|
|
627
|
-
* @param {?ReadParams
|
|
395
|
+
* @param {?ReadParams} [params]
|
|
628
396
|
* @returns {Promise<Address>}
|
|
629
397
|
*/
|
|
630
398
|
public owner(params?: ReadParams<typeof managedBudgetAbi, 'owner'>) {
|
|
@@ -641,13 +409,13 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
641
409
|
* If a tokenId is provided, get the total amount of ERC1155 assets allocated to the budget, including any that have been distributed
|
|
642
410
|
*
|
|
643
411
|
* @public
|
|
644
|
-
* @param {Address} asset - The address of the asset
|
|
412
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset
|
|
645
413
|
* @param {?(bigint | undefined)} [tokenId] - The ID of the token
|
|
646
|
-
* @param {?ReadParams
|
|
414
|
+
* @param {?ReadParams} [params]
|
|
647
415
|
* @returns {Promise<bigint>} - The total amount of assets
|
|
648
416
|
*/
|
|
649
417
|
public total(
|
|
650
|
-
asset: Address,
|
|
418
|
+
asset: Address = zeroAddress,
|
|
651
419
|
tokenId?: bigint | undefined,
|
|
652
420
|
params?: ReadParams<typeof managedBudgetAbi, 'total'>,
|
|
653
421
|
) {
|
|
@@ -664,13 +432,13 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
664
432
|
* If a tokenId is provided, get the amount of ERC1155 assets available for distribution from the budget
|
|
665
433
|
*
|
|
666
434
|
* @public
|
|
667
|
-
* @param {Address} asset
|
|
435
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"]
|
|
668
436
|
* @param {?(bigint | undefined)} [tokenId]
|
|
669
|
-
* @param {?ReadParams
|
|
437
|
+
* @param {?ReadParams} [params]
|
|
670
438
|
* @returns {Promise<bigint>} - The amount of assets available
|
|
671
439
|
*/
|
|
672
440
|
public available(
|
|
673
|
-
asset: Address,
|
|
441
|
+
asset: Address = zeroAddress,
|
|
674
442
|
tokenId?: bigint | undefined,
|
|
675
443
|
params?: ReadParams<typeof managedBudgetAbi, 'available'>,
|
|
676
444
|
) {
|
|
@@ -687,13 +455,13 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
687
455
|
* If a tokenId is provided, get the amount of ERC1155 assets that have been distributed from the budget
|
|
688
456
|
*
|
|
689
457
|
* @public
|
|
690
|
-
* @param {Address} asset
|
|
458
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"]
|
|
691
459
|
* @param {?(bigint | undefined)} [tokenId]
|
|
692
|
-
* @param {?ReadParams
|
|
460
|
+
* @param {?ReadParams} [params]
|
|
693
461
|
* @returns {Promise<bigint>} - The amount of assets distributed
|
|
694
462
|
*/
|
|
695
463
|
public distributed(
|
|
696
|
-
asset: Address,
|
|
464
|
+
asset: Address = zeroAddress,
|
|
697
465
|
tokenId?: bigint | undefined,
|
|
698
466
|
params?: ReadParams<typeof managedBudgetAbi, 'distributed'>,
|
|
699
467
|
) {
|
|
@@ -741,3 +509,26 @@ export class ManagedBudget extends DeployableTarget<
|
|
|
741
509
|
};
|
|
742
510
|
}
|
|
743
511
|
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Given a {@link ManagedBudgetPayload}, properly encode a `ManagedBudget.InitPayload` for use with {@link ManagedBudget} initialization.
|
|
515
|
+
*
|
|
516
|
+
* @param {ManagedBudgetPayload} param0
|
|
517
|
+
* @param {Address} param0.owner - The budget's owner
|
|
518
|
+
* @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
519
|
+
* @param {{}} param0.roles - List of roles to assign to the corresponding account by index.
|
|
520
|
+
* @returns {Hex}
|
|
521
|
+
*/
|
|
522
|
+
export const prepareManagedBudgetPayload = ({
|
|
523
|
+
owner,
|
|
524
|
+
authorized,
|
|
525
|
+
roles,
|
|
526
|
+
}: ManagedBudgetPayload) => {
|
|
527
|
+
return encodeAbiParameters(
|
|
528
|
+
parseAbiParameters([
|
|
529
|
+
'ManagedBudgetPayload payload',
|
|
530
|
+
'struct ManagedBudgetPayload { address owner; address[] authorized; uint256[] roles; }',
|
|
531
|
+
]),
|
|
532
|
+
[{ owner, authorized, roles: roles as unknown as Array<bigint> }],
|
|
533
|
+
);
|
|
534
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
2
2
|
import { isAddress, parseEther, zeroAddress } from 'viem';
|
|
3
3
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
4
|
-
import type { MockERC20 } from '
|
|
4
|
+
import type { MockERC20 } from '@boostxyz/test/MockERC20';
|
|
5
5
|
import {
|
|
6
6
|
type Fixtures,
|
|
7
7
|
defaultOptions,
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
freshVestingBudget,
|
|
10
10
|
fundErc20,
|
|
11
11
|
fundVestingBudget,
|
|
12
|
-
} from '
|
|
13
|
-
import { testAccount } from '
|
|
12
|
+
} from '@boostxyz/test/helpers';
|
|
13
|
+
import { testAccount } from '@boostxyz/test/viem';
|
|
14
14
|
import { VestingBudget } from './VestingBudget';
|
|
15
15
|
|
|
16
16
|
let fixtures: Fixtures, budget: VestingBudget, erc20: MockERC20;
|
|
17
17
|
|
|
18
18
|
beforeAll(async () => {
|
|
19
|
-
fixtures = await loadFixture(deployFixtures);
|
|
19
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
describe.skip('VestingBudget', () => {
|
|
@@ -53,7 +53,7 @@ describe.skip('VestingBudget', () => {
|
|
|
53
53
|
const budget = await loadFixture(
|
|
54
54
|
freshVestingBudget(defaultOptions, fixtures),
|
|
55
55
|
);
|
|
56
|
-
expect(await budget.available(
|
|
56
|
+
expect(await budget.available()).toBe(0n);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
describe('can allocate', () => {
|
|
@@ -73,7 +73,7 @@ describe.skip('VestingBudget', () => {
|
|
|
73
73
|
value: parseEther('1.0'),
|
|
74
74
|
},
|
|
75
75
|
);
|
|
76
|
-
expect(await budget.available(
|
|
76
|
+
expect(await budget.available()).toBe(parseEther('1.0'));
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
test('erc20', async () => {
|
|
@@ -105,7 +105,7 @@ describe.skip('VestingBudget', () => {
|
|
|
105
105
|
target: defaultOptions.account.address,
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
expect(await budget.available(
|
|
108
|
+
expect(await budget.available()).toBe(0n);
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
test('erc20 assets', async () => {
|