@boostxyz/sdk 0.0.0-alpha.3 → 0.0.0-alpha.6

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.
Files changed (176) hide show
  1. package/dist/Actions/Action.cjs +2 -1
  2. package/dist/Actions/Action.cjs.map +1 -0
  3. package/dist/Actions/Action.d.ts +1 -1
  4. package/dist/Actions/Action.d.ts.map +1 -1
  5. package/dist/Actions/Action.js +15 -13
  6. package/dist/Actions/Action.js.map +1 -0
  7. package/dist/Actions/EventAction.cjs +1 -0
  8. package/dist/Actions/EventAction.cjs.map +1 -0
  9. package/dist/Actions/EventAction.js +1 -0
  10. package/dist/Actions/EventAction.js.map +1 -0
  11. package/dist/AllowLists/AllowList.cjs +2 -1
  12. package/dist/AllowLists/AllowList.cjs.map +1 -0
  13. package/dist/AllowLists/AllowList.d.ts +1 -2
  14. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  15. package/dist/AllowLists/AllowList.js +16 -14
  16. package/dist/AllowLists/AllowList.js.map +1 -0
  17. package/dist/AllowLists/SimpleAllowList.cjs +1 -0
  18. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  19. package/dist/AllowLists/SimpleAllowList.js +1 -0
  20. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  21. package/dist/AllowLists/SimpleDenyList.cjs +1 -0
  22. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  23. package/dist/AllowLists/SimpleDenyList.js +1 -0
  24. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  25. package/dist/Auth/Auth.cjs +1 -0
  26. package/dist/Auth/Auth.cjs.map +1 -0
  27. package/dist/Auth/Auth.js +1 -0
  28. package/dist/Auth/Auth.js.map +1 -0
  29. package/dist/Auth/PassthroughAuth.cjs +1 -0
  30. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  31. package/dist/Auth/PassthroughAuth.js +1 -0
  32. package/dist/Auth/PassthroughAuth.js.map +1 -0
  33. package/dist/Boost.cjs +1 -0
  34. package/dist/Boost.cjs.map +1 -0
  35. package/dist/Boost.js +1 -0
  36. package/dist/Boost.js.map +1 -0
  37. package/dist/BoostCore.cjs +1 -0
  38. package/dist/BoostCore.cjs.map +1 -0
  39. package/dist/BoostCore.js +1 -0
  40. package/dist/BoostCore.js.map +1 -0
  41. package/dist/BoostRegistry.cjs +1 -0
  42. package/dist/BoostRegistry.cjs.map +1 -0
  43. package/dist/BoostRegistry.js +1 -0
  44. package/dist/BoostRegistry.js.map +1 -0
  45. package/dist/Budgets/Budget.cjs +2 -1
  46. package/dist/Budgets/Budget.cjs.map +1 -0
  47. package/dist/Budgets/Budget.d.ts +1 -1
  48. package/dist/Budgets/Budget.d.ts.map +1 -1
  49. package/dist/Budgets/Budget.js +14 -12
  50. package/dist/Budgets/Budget.js.map +1 -0
  51. package/dist/Budgets/ManagedBudget.cjs +1 -0
  52. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  53. package/dist/Budgets/ManagedBudget.js +1 -0
  54. package/dist/Budgets/ManagedBudget.js.map +1 -0
  55. package/dist/Deployable/Contract.cjs +1 -0
  56. package/dist/Deployable/Contract.cjs.map +1 -0
  57. package/dist/Deployable/Contract.js +1 -0
  58. package/dist/Deployable/Contract.js.map +1 -0
  59. package/dist/Deployable/Deployable.cjs +1 -0
  60. package/dist/Deployable/Deployable.cjs.map +1 -0
  61. package/dist/Deployable/Deployable.js +1 -0
  62. package/dist/Deployable/Deployable.js.map +1 -0
  63. package/dist/Deployable/DeployableTarget.cjs +1 -0
  64. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  65. package/dist/Deployable/DeployableTarget.js +1 -0
  66. package/dist/Deployable/DeployableTarget.js.map +1 -0
  67. package/dist/Incentives/AllowListIncentive.cjs +1 -0
  68. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  69. package/dist/Incentives/AllowListIncentive.js +1 -0
  70. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  71. package/dist/Incentives/CGDAIncentive.cjs +1 -0
  72. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  73. package/dist/Incentives/CGDAIncentive.js +1 -0
  74. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  75. package/dist/Incentives/ERC20Incentive.cjs +1 -0
  76. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  77. package/dist/Incentives/ERC20Incentive.js +1 -0
  78. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  79. package/dist/Incentives/Incentive.cjs +2 -1
  80. package/dist/Incentives/Incentive.cjs.map +1 -0
  81. package/dist/Incentives/Incentive.d.ts +1 -4
  82. package/dist/Incentives/Incentive.d.ts.map +1 -1
  83. package/dist/Incentives/Incentive.js +39 -36
  84. package/dist/Incentives/Incentive.js.map +1 -0
  85. package/dist/Incentives/PointsIncentive.cjs +1 -0
  86. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  87. package/dist/Incentives/PointsIncentive.js +1 -0
  88. package/dist/Incentives/PointsIncentive.js.map +1 -0
  89. package/dist/Validators/SignerValidator.cjs +1 -0
  90. package/dist/Validators/SignerValidator.cjs.map +1 -0
  91. package/dist/Validators/SignerValidator.js +1 -0
  92. package/dist/Validators/SignerValidator.js.map +1 -0
  93. package/dist/Validators/Validator.cjs +2 -1
  94. package/dist/Validators/Validator.cjs.map +1 -0
  95. package/dist/Validators/Validator.d.ts +1 -1
  96. package/dist/Validators/Validator.d.ts.map +1 -1
  97. package/dist/Validators/Validator.js +9 -7
  98. package/dist/Validators/Validator.js.map +1 -0
  99. package/dist/componentInterfaces-CKCBwG16.cjs +2 -0
  100. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  101. package/dist/componentInterfaces-DYkaxBda.js +13 -0
  102. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  103. package/dist/errors.cjs +1 -0
  104. package/dist/errors.cjs.map +1 -0
  105. package/dist/errors.js +1 -0
  106. package/dist/errors.js.map +1 -0
  107. package/dist/generated-Cd-Fe7W7.cjs +1 -0
  108. package/dist/generated-Cd-Fe7W7.cjs.map +1 -0
  109. package/dist/generated-DGpIVcv5.js +1 -0
  110. package/dist/generated-DGpIVcv5.js.map +1 -0
  111. package/dist/index.cjs +1 -0
  112. package/dist/index.cjs.map +1 -0
  113. package/dist/index.js +1 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/utils.cjs +1 -0
  116. package/dist/utils.cjs.map +1 -0
  117. package/dist/utils.d.ts +1 -1
  118. package/dist/utils.d.ts.map +1 -1
  119. package/dist/utils.js +1 -0
  120. package/dist/utils.js.map +1 -0
  121. package/package.json +5 -3
  122. package/src/Actions/Action.test.ts +77 -0
  123. package/src/Actions/Action.ts +61 -0
  124. package/src/Actions/ContractAction.test.ts +199 -0
  125. package/src/Actions/ContractAction.ts +238 -0
  126. package/src/Actions/ERC721MintAction.test.ts +112 -0
  127. package/src/Actions/ERC721MintAction.ts +238 -0
  128. package/src/Actions/EventAction.test.ts +182 -0
  129. package/src/Actions/EventAction.ts +382 -0
  130. package/src/AllowLists/AllowList.test.ts +64 -0
  131. package/src/AllowLists/AllowList.ts +60 -0
  132. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  133. package/src/AllowLists/SimpleAllowList.ts +240 -0
  134. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  135. package/src/AllowLists/SimpleDenyList.ts +289 -0
  136. package/src/Auth/Auth.ts +11 -0
  137. package/src/Auth/PassthroughAuth.test.ts +12 -0
  138. package/src/Auth/PassthroughAuth.ts +80 -0
  139. package/src/Boost.ts +155 -0
  140. package/src/BoostCore.test.ts +846 -0
  141. package/src/BoostCore.ts +1192 -0
  142. package/src/BoostRegistry.ts +449 -0
  143. package/src/Budgets/Budget.test.ts +27 -0
  144. package/src/Budgets/Budget.ts +61 -0
  145. package/src/Budgets/ManagedBudget.test.ts +154 -0
  146. package/src/Budgets/ManagedBudget.ts +743 -0
  147. package/src/Budgets/SimpleBudget.test.ts +152 -0
  148. package/src/Budgets/SimpleBudget.ts +521 -0
  149. package/src/Budgets/VestingBudget.test.ts +123 -0
  150. package/src/Budgets/VestingBudget.ts +532 -0
  151. package/src/Deployable/Contract.ts +229 -0
  152. package/src/Deployable/Deployable.ts +244 -0
  153. package/src/Deployable/DeployableTarget.ts +210 -0
  154. package/src/Incentives/AllowListIncentive.test.ts +146 -0
  155. package/src/Incentives/AllowListIncentive.ts +290 -0
  156. package/src/Incentives/CGDAIncentive.test.ts +136 -0
  157. package/src/Incentives/CGDAIncentive.ts +364 -0
  158. package/src/Incentives/ERC1155Incentive.test.ts +98 -0
  159. package/src/Incentives/ERC1155Incentive.ts +384 -0
  160. package/src/Incentives/ERC20Incentive.test.ts +141 -0
  161. package/src/Incentives/ERC20Incentive.ts +417 -0
  162. package/src/Incentives/ERC20VariableIncentive.test.ts +156 -0
  163. package/src/Incentives/ERC20VariableIncentive.ts +368 -0
  164. package/src/Incentives/Incentive.test.ts +92 -0
  165. package/src/Incentives/Incentive.ts +85 -0
  166. package/src/Incentives/PointsIncentive.test.ts +142 -0
  167. package/src/Incentives/PointsIncentive.ts +303 -0
  168. package/src/Validators/SignerValidator.test.ts +163 -0
  169. package/src/Validators/SignerValidator.ts +272 -0
  170. package/src/Validators/Validator.test.ts +21 -0
  171. package/src/Validators/Validator.ts +55 -0
  172. package/src/errors.ts +524 -0
  173. package/src/index.test.ts +40 -0
  174. package/src/index.ts +50 -0
  175. package/src/utils.test.ts +44 -0
  176. package/src/utils.ts +2247 -0
@@ -0,0 +1,152 @@
1
+ import { writeMockErc1155SetApprovalForAll } from '@boostxyz/evm';
2
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
+ import { isAddress, parseEther, zeroAddress } from 'viem';
4
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
5
+ import type { MockERC20 } from '../../test/MockERC20';
6
+ import type { MockERC1155 } from '../../test/MockERC1155';
7
+ import {
8
+ type Fixtures,
9
+ defaultOptions,
10
+ deployFixtures,
11
+ freshBudget,
12
+ fundBudget,
13
+ fundErc20,
14
+ fundErc1155,
15
+ } from '../../test/helpers';
16
+ import { testAccount } from '../../test/viem';
17
+ import { SimpleBudget } from './SimpleBudget';
18
+
19
+ let fixtures: Fixtures,
20
+ budget: SimpleBudget,
21
+ erc20: MockERC20,
22
+ erc1155: MockERC1155;
23
+
24
+ beforeAll(async () => {
25
+ fixtures = await loadFixture(deployFixtures);
26
+ });
27
+
28
+ describe.skip('SimpleBudget', () => {
29
+ test('can successfully be deployed', async () => {
30
+ const action = new SimpleBudget(defaultOptions, {
31
+ owner: testAccount.address,
32
+ authorized: [],
33
+ });
34
+ await action.deploy();
35
+ expect(isAddress(action.assertValidAddress())).toBe(true);
36
+ });
37
+
38
+ test('can be owned', async () => {
39
+ const budget = await loadFixture(freshBudget(defaultOptions, fixtures));
40
+ expect(await budget.owner()).toBe(defaultOptions.account.address);
41
+ });
42
+
43
+ test('can have authorized users', async () => {
44
+ const budget = await loadFixture(freshBudget(defaultOptions, fixtures));
45
+ expect(await budget.isAuthorized(defaultOptions.account.address)).toBe(
46
+ true,
47
+ );
48
+ expect(await budget.isAuthorized(zeroAddress)).toBe(false);
49
+ });
50
+
51
+ test('can have no initial balance', async () => {
52
+ const budget = await loadFixture(freshBudget(defaultOptions, fixtures));
53
+ expect(await budget.available(zeroAddress)).toBe(0n);
54
+ });
55
+
56
+ describe('can allocate', () => {
57
+ beforeEach(async () => {
58
+ budget = await loadFixture(freshBudget(defaultOptions, fixtures));
59
+ erc20 = await loadFixture(fundErc20(defaultOptions));
60
+ erc1155 = await loadFixture(fundErc1155(defaultOptions));
61
+ });
62
+
63
+ test('native assets', async () => {
64
+ await budget.allocate(
65
+ {
66
+ amount: parseEther('1.0'),
67
+ asset: zeroAddress,
68
+ target: defaultOptions.account.address,
69
+ },
70
+ {
71
+ value: parseEther('1.0'),
72
+ },
73
+ );
74
+ expect(await budget.available(zeroAddress)).toBe(parseEther('1.0'));
75
+ });
76
+
77
+ test('erc20', async () => {
78
+ await erc20.approve(budget.assertValidAddress(), parseEther('100'));
79
+ await budget.allocate({
80
+ amount: parseEther('100'),
81
+ asset: erc20.assertValidAddress(),
82
+ target: defaultOptions.account.address,
83
+ });
84
+ expect(await budget.available(erc20.assertValidAddress())).toBe(
85
+ parseEther('100'),
86
+ );
87
+ });
88
+
89
+ test('erc1155', async () => {
90
+ await writeMockErc1155SetApprovalForAll(defaultOptions.config, {
91
+ args: [budget.assertValidAddress(), true],
92
+ address: erc1155.assertValidAddress(),
93
+ account: defaultOptions.account,
94
+ });
95
+ await budget.allocate({
96
+ tokenId: 1n,
97
+ amount: 100n,
98
+ asset: erc1155.assertValidAddress(),
99
+ target: defaultOptions.account.address,
100
+ });
101
+ expect(await budget.available(erc1155.assertValidAddress(), 1n)).toBe(
102
+ 100n,
103
+ );
104
+ });
105
+ });
106
+
107
+ describe('can disburse', () => {
108
+ beforeEach(async () => {
109
+ const budgetFixtures = await loadFixture(
110
+ fundBudget(defaultOptions, fixtures),
111
+ );
112
+ budget = budgetFixtures.budget;
113
+ erc20 = budgetFixtures.erc20;
114
+ erc1155 = budgetFixtures.erc1155;
115
+ });
116
+
117
+ test('native assets', async () => {
118
+ await budget.disburse({
119
+ amount: parseEther('1.0'),
120
+ asset: zeroAddress,
121
+ target: defaultOptions.account.address,
122
+ });
123
+
124
+ expect(await budget.available(zeroAddress)).toBe(0n);
125
+ });
126
+
127
+ test('erc20 assets', async () => {
128
+ await budget.disburse({
129
+ amount: parseEther('10'),
130
+ asset: erc20.assertValidAddress(),
131
+ target: defaultOptions.account.address,
132
+ });
133
+
134
+ expect(await budget.available(erc20.assertValidAddress())).toBe(
135
+ parseEther('90'),
136
+ );
137
+ });
138
+
139
+ test('erc1155 assets', async () => {
140
+ await budget.disburse({
141
+ tokenId: 1n,
142
+ amount: 5n,
143
+ asset: erc1155.assertValidAddress(),
144
+ target: defaultOptions.account.address,
145
+ });
146
+
147
+ expect(await budget.available(erc1155.assertValidAddress(), 1n)).to.equal(
148
+ 95n,
149
+ );
150
+ });
151
+ });
152
+ });
@@ -0,0 +1,521 @@
1
+ import {
2
+ readSimpleBudgetAvailable,
3
+ readSimpleBudgetDistributed,
4
+ readSimpleBudgetIsAuthorized,
5
+ readSimpleBudgetOwner,
6
+ readSimpleBudgetTotal,
7
+ simpleBudgetAbi,
8
+ simulateSimpleBudgetAllocate,
9
+ simulateSimpleBudgetClawback,
10
+ simulateSimpleBudgetDisburse,
11
+ simulateSimpleBudgetDisburseBatch,
12
+ simulateSimpleBudgetSetAuthorized,
13
+ writeSimpleBudgetAllocate,
14
+ writeSimpleBudgetClawback,
15
+ writeSimpleBudgetDisburse,
16
+ writeSimpleBudgetDisburseBatch,
17
+ writeSimpleBudgetSetAuthorized,
18
+ } from '@boostxyz/evm';
19
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/SimpleBudget.sol/SimpleBudget.json';
20
+ import { getAccount } from '@wagmi/core';
21
+ import {
22
+ type Address,
23
+ type ContractEventName,
24
+ type Hex,
25
+ zeroAddress,
26
+ } from 'viem';
27
+ import type {
28
+ DeployableOptions,
29
+ GenericDeployableParams,
30
+ } from '../Deployable/Deployable';
31
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
32
+ import {
33
+ DeployableUnknownOwnerProvidedError,
34
+ UnknownTransferPayloadSupplied,
35
+ } from '../errors';
36
+ import {
37
+ type ERC1155TransferPayload,
38
+ type FungibleTransferPayload,
39
+ type GenericLog,
40
+ type ReadParams,
41
+ RegistryType,
42
+ type SimpleBudgetPayload,
43
+ type WriteParams,
44
+ prepareERC1155Transfer,
45
+ prepareFungibleTransfer,
46
+ prepareSimpleBudgetPayload,
47
+ } from '../utils';
48
+
49
+ export { simpleBudgetAbi };
50
+ export type {
51
+ ERC1155TransferPayload,
52
+ FungibleTransferPayload,
53
+ SimpleBudgetPayload,
54
+ };
55
+
56
+ /**
57
+ * A generic `viem.Log` event with support for `SimpleBudget` event types.
58
+ *
59
+ * @export
60
+ * @typedef {SimpleBudgetLog}
61
+ * @template {ContractEventName<typeof simpleBudgetAbi>} [event=ContractEventName<
62
+ * typeof simpleBudgetAbi
63
+ * >]
64
+ */
65
+ export type SimpleBudgetLog<
66
+ event extends ContractEventName<typeof simpleBudgetAbi> = ContractEventName<
67
+ typeof simpleBudgetAbi
68
+ >,
69
+ > = GenericLog<typeof simpleBudgetAbi, event>;
70
+
71
+ /**
72
+ * Typeguard to determine if a transfer payload is a Fungible Transfer
73
+ *
74
+ * @export
75
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
76
+ * @returns {transfer is FungibleTransferPayload}
77
+ */
78
+ export function isFungibleTransfer(
79
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
80
+ ): transfer is FungibleTransferPayload {
81
+ return (transfer as ERC1155TransferPayload).tokenId === undefined;
82
+ }
83
+
84
+ /**
85
+ * Typeguard to determine if a transfer payload is an ERC1155 Transfer
86
+ *
87
+ * @export
88
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
89
+ * @returns {transfer is ERC1155TransferPayload}
90
+ */
91
+ export function isERC1155TransferPayload(
92
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
93
+ ): transfer is ERC1155TransferPayload {
94
+ return (transfer as ERC1155TransferPayload).tokenId !== undefined;
95
+ }
96
+
97
+ /**
98
+ * Given either a Fungible transfer, or ERC1155 transfer, will properly encode parameters for transfers, claims, disbursements, allocations, etc.
99
+ *
100
+ * @export
101
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
102
+ * @returns {*}
103
+ * @throws {@link UnknownTransferPayloadSupplied}
104
+ */
105
+ export function prepareTransfer(
106
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
107
+ ) {
108
+ if (isFungibleTransfer(transfer)) {
109
+ return prepareFungibleTransfer(transfer);
110
+ } else if (isERC1155TransferPayload(transfer)) {
111
+ return prepareERC1155Transfer(transfer);
112
+ } else throw new UnknownTransferPayloadSupplied(transfer);
113
+ }
114
+
115
+ /**
116
+ * A minimal budget implementation that simply holds and distributes tokens (ERC20-like and native)
117
+ * This type of budget supports ETH, ERC20, and ERC1155 assets only
118
+ *
119
+ * @export
120
+ * @class SimpleBudget
121
+ * @typedef {SimpleBudget}
122
+ * @extends {DeployableTarget<SimpleBudgetPayload>}
123
+ */
124
+ export class SimpleBudget extends DeployableTarget<
125
+ SimpleBudgetPayload,
126
+ typeof simpleBudgetAbi
127
+ > {
128
+ public override readonly abi = simpleBudgetAbi;
129
+ /**
130
+ * @inheritdoc
131
+ *
132
+ * @public
133
+ * @static
134
+ * @type {Address}
135
+ */
136
+ public static override base: Address = import.meta.env
137
+ .VITE_SIMPLE_BUDGET_BASE;
138
+ /**
139
+ * @inheritdoc
140
+ *
141
+ * @public
142
+ * @static
143
+ * @type {RegistryType}
144
+ */
145
+ public static override registryType: RegistryType = RegistryType.BUDGET;
146
+
147
+ /**
148
+ * Allocates assets to the budget.
149
+ * The caller must have already approved the contract to transfer the asset
150
+ * If the asset transfer fails, the allocation will revert
151
+ *
152
+ * @public
153
+ * @async
154
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
155
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'allocate'>} [params]
156
+ * @returns {Promise<boolean>} - True if the allocation was successful
157
+ */
158
+ public async allocate(
159
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
160
+ params?: WriteParams<typeof simpleBudgetAbi, 'allocate'>,
161
+ ) {
162
+ return this.awaitResult(this.allocateRaw(transfer, params));
163
+ }
164
+
165
+ /**
166
+ * Allocates assets to the budget.
167
+ * The caller must have already approved the contract to transfer the asset
168
+ * If the asset transfer fails, the allocation will revert
169
+ *
170
+ * @public
171
+ * @async
172
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
173
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'allocate'>} [params]
174
+ * @returns {Promise<boolean>} - True if the allocation was successful
175
+ */
176
+ public async allocateRaw(
177
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
178
+ params?: WriteParams<typeof simpleBudgetAbi, 'allocate'>,
179
+ ) {
180
+ const { request, result } = await simulateSimpleBudgetAllocate(
181
+ this._config,
182
+ {
183
+ address: this.assertValidAddress(),
184
+ args: [prepareTransfer(transfer)],
185
+ ...this.optionallyAttachAccount(),
186
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
187
+ ...(params as any),
188
+ },
189
+ );
190
+ const hash = await writeSimpleBudgetAllocate(this._config, request);
191
+ return { hash, result };
192
+ }
193
+
194
+ /**
195
+ * Clawbacks assets from the budget.
196
+ * Only the owner can directly clawback assets from the budget
197
+ * If the amount is zero, the entire balance of the asset will be transferred to the receiver
198
+ * If the asset transfer fails, the reclamation will revert
199
+ *
200
+ * @public
201
+ * @async
202
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
203
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'clawback'>} [params]
204
+ * @returns {Promise<boolean>} - True if the request was successful
205
+ */
206
+ public async clawback(
207
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
208
+ params?: WriteParams<typeof simpleBudgetAbi, 'clawback'>,
209
+ ) {
210
+ return this.awaitResult(this.clawbackRaw(transfer, params));
211
+ }
212
+
213
+ /**
214
+ * Clawbacks assets from the budget.
215
+ * Only the owner can directly clawback assets from the budget
216
+ * If the amount is zero, the entire balance of the asset will be transferred to the receiver
217
+ * If the asset transfer fails, the reclamation will revert
218
+ *
219
+ * @public
220
+ * @async
221
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
222
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'clawback'>} [params]
223
+ * @returns {Promise<boolean>} - True if the request was successful
224
+ */
225
+ public async clawbackRaw(
226
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
227
+ params?: WriteParams<typeof simpleBudgetAbi, 'clawback'>,
228
+ ) {
229
+ const { request, result } = await simulateSimpleBudgetClawback(
230
+ this._config,
231
+ {
232
+ address: this.assertValidAddress(),
233
+ args: [prepareTransfer(transfer)],
234
+ ...this.optionallyAttachAccount(),
235
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
236
+ ...(params as any),
237
+ },
238
+ );
239
+ const hash = await writeSimpleBudgetClawback(this._config, request);
240
+ return { hash, result };
241
+ }
242
+
243
+ /**
244
+ * Disburses assets from the budget to a single recipient
245
+ * If the asset transfer fails, the disbursement will revert
246
+ *
247
+ * @public
248
+ * @async
249
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
250
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'disburse'>} [params]
251
+ * @returns {Promise<boolean>} - True if the disbursement was successful
252
+ */
253
+ public async disburse(
254
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
255
+ params?: WriteParams<typeof simpleBudgetAbi, 'disburse'>,
256
+ ) {
257
+ return this.awaitResult(this.disburseRaw(transfer, params));
258
+ }
259
+
260
+ /**
261
+ * Disburses assets from the budget to a single recipient
262
+ * If the asset transfer fails, the disbursement will revert
263
+ *
264
+ * @public
265
+ * @async
266
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
267
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'disburse'>} [params]
268
+ * @returns {Promise<boolean>} - True if the disbursement was successful
269
+ */
270
+ public async disburseRaw(
271
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
272
+ params?: WriteParams<typeof simpleBudgetAbi, 'disburse'>,
273
+ ) {
274
+ const { request, result } = await simulateSimpleBudgetDisburse(
275
+ this._config,
276
+ {
277
+ address: this.assertValidAddress(),
278
+ args: [prepareTransfer(transfer)],
279
+ ...this.optionallyAttachAccount(),
280
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
281
+ ...(params as any),
282
+ },
283
+ );
284
+ const hash = await writeSimpleBudgetDisburse(this._config, request);
285
+ return { hash, result };
286
+ }
287
+
288
+ /**
289
+ * Disburses assets from the budget to multiple recipients
290
+ *
291
+ * @public
292
+ * @async
293
+ * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
294
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'disburseBatch'>} [params]
295
+ * @returns {Promise<boolean>} - True if all disbursements were successful
296
+ */
297
+ public async disburseBatch(
298
+ transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
299
+ params?: WriteParams<typeof simpleBudgetAbi, 'disburseBatch'>,
300
+ ) {
301
+ return this.awaitResult(this.disburseBatchRaw(transfers, params));
302
+ }
303
+
304
+ /**
305
+ * Disburses assets from the budget to multiple recipients
306
+ *
307
+ * @public
308
+ * @async
309
+ * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
310
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'disburseBatch'>} [params]
311
+ * @returns {Promise<boolean>} - True if all disbursements were successful
312
+ */
313
+ public async disburseBatchRaw(
314
+ transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
315
+ params?: WriteParams<typeof simpleBudgetAbi, 'disburseBatch'>,
316
+ ) {
317
+ const { request, result } = await simulateSimpleBudgetDisburseBatch(
318
+ this._config,
319
+ {
320
+ address: this.assertValidAddress(),
321
+ args: [transfers.map(prepareTransfer)],
322
+ ...this.optionallyAttachAccount(),
323
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
324
+ ...(params as any),
325
+ },
326
+ );
327
+ const hash = await writeSimpleBudgetDisburseBatch(this._config, request);
328
+ return { hash, result };
329
+ }
330
+
331
+ /**
332
+ * Set the authorized status of the given accounts
333
+ * The mechanism for managing authorization is left to the implementing contract
334
+ *
335
+ * @public
336
+ * @async
337
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
338
+ * @param {boolean[]} allowed - The authorization status for the given accounts
339
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'setAuthorized'>} [params]
340
+ * @returns {Promise<void>}
341
+ */
342
+ public async setAuthorized(
343
+ addresses: Address[],
344
+ allowed: boolean[],
345
+ params?: WriteParams<typeof simpleBudgetAbi, 'setAuthorized'>,
346
+ ) {
347
+ return this.awaitResult(this.setAuthorizedRaw(addresses, allowed, params));
348
+ }
349
+
350
+ /**
351
+ * Set the authorized status of the given accounts
352
+ * The mechanism for managing authorization is left to the implementing contract
353
+ *
354
+ * @public
355
+ * @async
356
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
357
+ * @param {boolean[]} allowed - The authorization status for the given accounts
358
+ * @param {?WriteParams<typeof simpleBudgetAbi, 'setAuthorized'>} [params]
359
+ * @returns {Promise<void>}
360
+ */
361
+ public async setAuthorizedRaw(
362
+ addresses: Address[],
363
+ allowed: boolean[],
364
+ params?: WriteParams<typeof simpleBudgetAbi, 'setAuthorized'>,
365
+ ) {
366
+ const { request, result } = await simulateSimpleBudgetSetAuthorized(
367
+ this._config,
368
+ {
369
+ address: this.assertValidAddress(),
370
+ args: [addresses, allowed],
371
+ ...this.optionallyAttachAccount(),
372
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
373
+ ...(params as any),
374
+ },
375
+ );
376
+ const hash = await writeSimpleBudgetSetAuthorized(this._config, request);
377
+ return { hash, result };
378
+ }
379
+
380
+ /**
381
+ * Check if the given account is authorized to use the budget
382
+ *
383
+ * @public
384
+ * @param {Address} account
385
+ * @param {?ReadParams<typeof simpleBudgetAbi, 'isAuthorized'>} [params]
386
+ * @returns {Promise<boolean>} - True if the account is authorized
387
+ */
388
+ public isAuthorized(
389
+ account: Address,
390
+ params?: ReadParams<typeof simpleBudgetAbi, 'isAuthorized'>,
391
+ ) {
392
+ return readSimpleBudgetIsAuthorized(this._config, {
393
+ address: this.assertValidAddress(),
394
+ args: [account],
395
+ ...this.optionallyAttachAccount(),
396
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
397
+ ...(params as any),
398
+ });
399
+ }
400
+
401
+ /**
402
+ * Get the owner of the budget
403
+ *
404
+ * @public
405
+ * @param {?ReadParams<typeof simpleBudgetAbi, 'owner'>} [params]
406
+ * @returns {Promise<Address>}
407
+ */
408
+ public owner(params?: ReadParams<typeof simpleBudgetAbi, 'owner'>) {
409
+ return readSimpleBudgetOwner(this._config, {
410
+ address: this.assertValidAddress(),
411
+ args: [],
412
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
413
+ ...(params as any),
414
+ });
415
+ }
416
+
417
+ /**
418
+ * Get the total amount of assets allocated to the budget, including any that have been distributed
419
+ * If a tokenId is provided, get the total amount of ERC1155 assets allocated to the budget, including any that have been distributed
420
+ *
421
+ * @public
422
+ * @param {Address} asset - The address of the asset
423
+ * @param {?(bigint | undefined)} [tokenId] - The ID of the token
424
+ * @param {?ReadParams<typeof simpleBudgetAbi, 'total'>} [params]
425
+ * @returns {Promise<bigint>} - The total amount of assets
426
+ */
427
+ public total(
428
+ asset: Address,
429
+ tokenId?: bigint | undefined,
430
+ params?: ReadParams<typeof simpleBudgetAbi, 'total'>,
431
+ ) {
432
+ return readSimpleBudgetTotal(this._config, {
433
+ address: this.assertValidAddress(),
434
+ args: tokenId ? [asset, tokenId] : [asset],
435
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
436
+ ...(params as any),
437
+ });
438
+ }
439
+
440
+ /**
441
+ * Get the amount of assets available for distribution from the budget.
442
+ * If a tokenId is provided, get the amount of ERC1155 assets available for distribution from the budget
443
+ *
444
+ * @public
445
+ * @param {Address} asset
446
+ * @param {?(bigint | undefined)} [tokenId]
447
+ * @param {?ReadParams<typeof simpleBudgetAbi, 'available'>} [params]
448
+ * @returns {Promise<bigint>} - The amount of assets available
449
+ */
450
+ public available(
451
+ asset: Address,
452
+ tokenId?: bigint | undefined,
453
+ params?: ReadParams<typeof simpleBudgetAbi, 'available'>,
454
+ ) {
455
+ return readSimpleBudgetAvailable(this._config, {
456
+ address: this.assertValidAddress(),
457
+ args: tokenId ? [asset, tokenId] : [asset],
458
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
459
+ ...(params as any),
460
+ });
461
+ }
462
+
463
+ /**
464
+ * Get the amount of assets that have been distributed from the budget.
465
+ * If a tokenId is provided, get the amount of ERC1155 assets that have been distributed from the budget
466
+ *
467
+ * @public
468
+ * @param {Address} asset
469
+ * @param {?(bigint | undefined)} [tokenId]
470
+ * @param {?ReadParams<typeof simpleBudgetAbi, 'distributed'>} [params]
471
+ * @returns {Promise<bigint>} - The amount of assets distributed
472
+ */
473
+ public distributed(
474
+ asset: Address,
475
+ tokenId?: bigint | undefined,
476
+ params?: ReadParams<typeof simpleBudgetAbi, 'distributed'>,
477
+ ) {
478
+ return readSimpleBudgetDistributed(this._config, {
479
+ address: this.assertValidAddress(),
480
+ args: tokenId ? [asset, tokenId] : [asset],
481
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
482
+ ...(params as any),
483
+ });
484
+ }
485
+
486
+ /**
487
+ * @inheritdoc
488
+ *
489
+ * @public
490
+ * @param {?SimpleBudgetPayload} [_payload]
491
+ * @param {?DeployableOptions} [_options]
492
+ * @returns {GenericDeployableParams}
493
+ */
494
+ public override buildParameters(
495
+ _payload?: SimpleBudgetPayload,
496
+ _options?: DeployableOptions,
497
+ ): GenericDeployableParams {
498
+ const [payload, options] = this.validateDeploymentConfig(
499
+ _payload,
500
+ _options,
501
+ );
502
+ if (!payload.owner || payload.owner === zeroAddress) {
503
+ const owner = options.account
504
+ ? options.account.address
505
+ : options.config
506
+ ? getAccount(options.config).address
507
+ : this._account?.address;
508
+ if (owner) {
509
+ payload.owner = owner;
510
+ } else {
511
+ throw new DeployableUnknownOwnerProvidedError();
512
+ }
513
+ }
514
+ return {
515
+ abi: simpleBudgetAbi,
516
+ bytecode: bytecode as Hex,
517
+ args: [prepareSimpleBudgetPayload(payload)],
518
+ ...this.optionallyAttachAccount(options.account),
519
+ };
520
+ }
521
+ }