@boostxyz/sdk 0.0.0-alpha.7 → 0.0.0-alpha.9

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 (191) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +1 -1
  3. package/dist/Actions/ContractAction.d.ts +46 -3
  4. package/dist/Actions/ContractAction.d.ts.map +1 -1
  5. package/dist/Actions/ERC721MintAction.d.ts +37 -10
  6. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  7. package/dist/Actions/EventAction.cjs +1 -1
  8. package/dist/Actions/EventAction.cjs.map +1 -1
  9. package/dist/Actions/EventAction.d.ts +257 -11
  10. package/dist/Actions/EventAction.d.ts.map +1 -1
  11. package/dist/Actions/EventAction.js +249 -82
  12. package/dist/Actions/EventAction.js.map +1 -1
  13. package/dist/AllowLists/AllowList.cjs +1 -1
  14. package/dist/AllowLists/AllowList.d.ts +2 -2
  15. package/dist/AllowLists/AllowList.js +1 -1
  16. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  17. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  18. package/dist/AllowLists/SimpleAllowList.d.ts +33 -4
  19. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  20. package/dist/AllowLists/SimpleAllowList.js +52 -37
  21. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  22. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  23. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
  24. package/dist/AllowLists/SimpleDenyList.d.ts +31 -2
  25. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  26. package/dist/AllowLists/SimpleDenyList.js +41 -129
  27. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  28. package/dist/Auth/PassthroughAuth.cjs +1 -1
  29. package/dist/Auth/PassthroughAuth.cjs.map +1 -1
  30. package/dist/Auth/PassthroughAuth.js +4 -4
  31. package/dist/Auth/PassthroughAuth.js.map +1 -1
  32. package/dist/Boost.cjs +1 -1
  33. package/dist/Boost.cjs.map +1 -1
  34. package/dist/Boost.d.ts +93 -1
  35. package/dist/Boost.d.ts.map +1 -1
  36. package/dist/Boost.js +151 -5
  37. package/dist/Boost.js.map +1 -1
  38. package/dist/BoostCore.cjs +2 -2
  39. package/dist/BoostCore.cjs.map +1 -1
  40. package/dist/BoostCore.d.ts +45 -7
  41. package/dist/BoostCore.d.ts.map +1 -1
  42. package/dist/BoostCore.js +352 -305
  43. package/dist/BoostCore.js.map +1 -1
  44. package/dist/BoostRegistry.cjs +1 -1
  45. package/dist/BoostRegistry.cjs.map +1 -1
  46. package/dist/BoostRegistry.d.ts +18 -4
  47. package/dist/BoostRegistry.d.ts.map +1 -1
  48. package/dist/BoostRegistry.js +36 -25
  49. package/dist/BoostRegistry.js.map +1 -1
  50. package/dist/Budgets/Budget.cjs +1 -1
  51. package/dist/Budgets/Budget.js +1 -1
  52. package/dist/Budgets/ManagedBudget.cjs +1 -1
  53. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  54. package/dist/Budgets/ManagedBudget.d.ts +40 -2
  55. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  56. package/dist/Budgets/ManagedBudget.js +53 -36
  57. package/dist/Budgets/ManagedBudget.js.map +1 -1
  58. package/dist/Budgets/SimpleBudget.d.ts +33 -2
  59. package/dist/Budgets/SimpleBudget.d.ts.map +1 -1
  60. package/dist/Budgets/VestingBudget.d.ts +54 -2
  61. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  62. package/dist/Deployable/Contract.cjs +1 -1
  63. package/dist/Deployable/Contract.cjs.map +1 -1
  64. package/dist/Deployable/Contract.js +1 -1
  65. package/dist/Deployable/Contract.js.map +1 -1
  66. package/dist/Deployable/Deployable.cjs.map +1 -1
  67. package/dist/Deployable/Deployable.d.ts +8 -2
  68. package/dist/Deployable/Deployable.d.ts.map +1 -1
  69. package/dist/Deployable/Deployable.js +6 -0
  70. package/dist/Deployable/Deployable.js.map +1 -1
  71. package/dist/Deployable/DeployableTarget.cjs +1 -1
  72. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  73. package/dist/Deployable/DeployableTarget.d.ts +4 -3
  74. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  75. package/dist/Deployable/DeployableTarget.js +31 -28
  76. package/dist/Deployable/DeployableTarget.js.map +1 -1
  77. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  78. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  79. package/dist/Incentives/AllowListIncentive.d.ts +35 -5
  80. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  81. package/dist/Incentives/AllowListIncentive.js +33 -21
  82. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  83. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  84. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  85. package/dist/Incentives/CGDAIncentive.d.ts +89 -5
  86. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  87. package/dist/Incentives/CGDAIncentive.js +44 -23
  88. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  89. package/dist/Incentives/ERC1155Incentive.d.ts +67 -6
  90. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  91. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  92. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  93. package/dist/Incentives/ERC20Incentive.d.ts +49 -5
  94. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  95. package/dist/Incentives/ERC20Incentive.js +46 -27
  96. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  97. package/dist/Incentives/ERC20VariableIncentive.d.ts +42 -5
  98. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  99. package/dist/Incentives/Incentive.cjs +1 -1
  100. package/dist/Incentives/Incentive.cjs.map +1 -1
  101. package/dist/Incentives/Incentive.js +48 -32
  102. package/dist/Incentives/Incentive.js.map +1 -1
  103. package/dist/Incentives/PointsIncentive.cjs +1 -1
  104. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  105. package/dist/Incentives/PointsIncentive.d.ts +49 -5
  106. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  107. package/dist/Incentives/PointsIncentive.js +38 -21
  108. package/dist/Incentives/PointsIncentive.js.map +1 -1
  109. package/dist/Validators/SignerValidator.cjs +1 -1
  110. package/dist/Validators/SignerValidator.cjs.map +1 -1
  111. package/dist/Validators/SignerValidator.d.ts +298 -5
  112. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  113. package/dist/Validators/SignerValidator.js +151 -26
  114. package/dist/Validators/SignerValidator.js.map +1 -1
  115. package/dist/Validators/Validator.cjs +1 -1
  116. package/dist/Validators/Validator.js +1 -1
  117. package/dist/claiming.cjs +2 -0
  118. package/dist/claiming.cjs.map +1 -0
  119. package/dist/claiming.d.ts +43 -0
  120. package/dist/claiming.d.ts.map +1 -0
  121. package/dist/claiming.js +17 -0
  122. package/dist/claiming.js.map +1 -0
  123. package/dist/errors.cjs +1 -1
  124. package/dist/errors.cjs.map +1 -1
  125. package/dist/errors.d.ts +15 -1
  126. package/dist/errors.d.ts.map +1 -1
  127. package/dist/errors.js +30 -21
  128. package/dist/errors.js.map +1 -1
  129. package/dist/{generated-DGpIVcv5.js → generated-57_Kffpz.js} +293 -282
  130. package/dist/generated-57_Kffpz.js.map +1 -0
  131. package/dist/{generated-Cd-Fe7W7.cjs → generated-wKBNvm48.cjs} +3 -3
  132. package/dist/generated-wKBNvm48.cjs.map +1 -0
  133. package/dist/index.cjs +1 -1
  134. package/dist/index.d.ts +4 -4
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +108 -124
  137. package/dist/transfers.cjs +2 -0
  138. package/dist/transfers.cjs.map +1 -0
  139. package/dist/transfers.d.ts +198 -0
  140. package/dist/transfers.d.ts.map +1 -0
  141. package/dist/transfers.js +84 -0
  142. package/dist/transfers.js.map +1 -0
  143. package/dist/utils.cjs +1 -1
  144. package/dist/utils.cjs.map +1 -1
  145. package/dist/utils.d.ts +2 -1371
  146. package/dist/utils.d.ts.map +1 -1
  147. package/dist/utils.js +26 -653
  148. package/dist/utils.js.map +1 -1
  149. package/package.json +17 -3
  150. package/src/Actions/Action.test.ts +5 -4
  151. package/src/Actions/ContractAction.test.ts +4 -6
  152. package/src/Actions/ContractAction.ts +73 -10
  153. package/src/Actions/ERC721MintAction.test.ts +2 -2
  154. package/src/Actions/ERC721MintAction.ts +70 -16
  155. package/src/Actions/EventAction.test.ts +43 -17
  156. package/src/Actions/EventAction.ts +451 -26
  157. package/src/AllowLists/SimpleAllowList.ts +51 -7
  158. package/src/AllowLists/SimpleDenyList.ts +47 -109
  159. package/src/Auth/PassthroughAuth.ts +1 -1
  160. package/src/Boost.ts +136 -1
  161. package/src/BoostCore.test.ts +4 -11
  162. package/src/BoostCore.ts +114 -45
  163. package/src/BoostRegistry.ts +39 -21
  164. package/src/Budgets/ManagedBudget.ts +69 -16
  165. package/src/Budgets/SimpleBudget.ts +57 -14
  166. package/src/Budgets/VestingBudget.ts +79 -9
  167. package/src/Deployable/Contract.ts +1 -1
  168. package/src/Deployable/Deployable.ts +8 -2
  169. package/src/Deployable/DeployableTarget.ts +19 -6
  170. package/src/Incentives/AllowListIncentive.test.ts +2 -5
  171. package/src/Incentives/AllowListIncentive.ts +59 -15
  172. package/src/Incentives/CGDAIncentive.test.ts +3 -7
  173. package/src/Incentives/CGDAIncentive.ts +123 -19
  174. package/src/Incentives/ERC1155Incentive.test.ts +2 -13
  175. package/src/Incentives/ERC1155Incentive.ts +104 -22
  176. package/src/Incentives/ERC20Incentive.test.ts +6 -17
  177. package/src/Incentives/ERC20Incentive.ts +86 -21
  178. package/src/Incentives/ERC20VariableIncentive.test.ts +4 -24
  179. package/src/Incentives/ERC20VariableIncentive.ts +71 -19
  180. package/src/Incentives/Incentive.test.ts +1 -1
  181. package/src/Incentives/PointsIncentive.test.ts +3 -6
  182. package/src/Incentives/PointsIncentive.ts +79 -17
  183. package/src/Validators/SignerValidator.test.ts +3 -7
  184. package/src/Validators/SignerValidator.ts +422 -13
  185. package/src/claiming.ts +56 -0
  186. package/src/errors.ts +19 -1
  187. package/src/index.ts +10 -7
  188. package/src/transfers.ts +284 -0
  189. package/src/utils.ts +3 -2052
  190. package/dist/generated-Cd-Fe7W7.cjs.map +0 -1
  191. package/dist/generated-DGpIVcv5.js.map +0 -1
package/src/BoostCore.ts CHANGED
@@ -9,10 +9,12 @@ import {
9
9
  readBoostCoreProtocolFeeReceiver,
10
10
  readIAuthIsAuthorized,
11
11
  simulateBoostCoreClaimIncentive,
12
+ simulateBoostCoreClaimIncentiveFor,
12
13
  simulateBoostCoreSetClaimFee,
13
14
  simulateBoostCoreSetCreateBoostAuth,
14
15
  simulateBoostCoreSetProtocolFeeReceiver,
15
16
  writeBoostCoreClaimIncentive,
17
+ writeBoostCoreClaimIncentiveFor,
16
18
  writeBoostCoreSetClaimFee,
17
19
  writeBoostCoreSetCreateBoostAuth,
18
20
  writeBoostCoreSetProtocolFeeReceiver,
@@ -24,12 +26,13 @@ import {
24
26
  type Address,
25
27
  type ContractEventName,
26
28
  type Hex,
29
+ parseEther,
27
30
  parseEventLogs,
28
31
  zeroAddress,
29
32
  zeroHash,
30
33
  } from 'viem';
31
34
  import { type Action, actionFromAddress } from './Actions/Action';
32
- import { EventAction } from './Actions/EventAction';
35
+ import { EventAction, type EventActionPayload } from './Actions/EventAction';
33
36
  import { type AllowList, allowListFromAddress } from './AllowLists/AllowList';
34
37
  import {
35
38
  SimpleAllowList,
@@ -40,7 +43,12 @@ import {
40
43
  type SimpleDenyListPayload,
41
44
  } from './AllowLists/SimpleDenyList';
42
45
  import { type Auth, PassthroughAuth } from './Auth/Auth';
43
- import { Boost } from './Boost';
46
+ import {
47
+ Boost,
48
+ type BoostPayload,
49
+ type Target,
50
+ prepareBoostPayload,
51
+ } from './Boost';
44
52
  import { type Budget, budgetFromAddress } from './Budgets/Budget';
45
53
  import {
46
54
  ManagedBudget,
@@ -64,6 +72,7 @@ import {
64
72
  ERC20Incentive,
65
73
  type ERC20IncentivePayload,
66
74
  } from './Incentives/ERC20Incentive';
75
+ import type { ERC20VariableIncentivePayload } from './Incentives/ERC20VariableIncentive';
67
76
  import {
68
77
  ERC20VariableIncentive,
69
78
  type Incentive,
@@ -82,21 +91,20 @@ import {
82
91
  BoostCoreNoIdentifierEmitted,
83
92
  BudgetMustAuthorizeBoostCore,
84
93
  DeployableUnknownOwnerProvidedError,
85
- NoContractAddressUponReceiptError,
94
+ IncentiveNotCloneableError,
95
+ MustInitializeBudgetError,
86
96
  } from './errors';
87
- import {
88
- type ERC20VariableIncentivePayload,
89
- type EventActionPayload,
90
- type GenericLog,
91
- type BoostPayload as OnChainBoostPayload,
92
- type ReadParams,
93
- type Target,
94
- type WriteParams,
95
- prepareBoostPayload,
96
- } from './utils';
97
+ import type { GenericLog, ReadParams, WriteParams } from './utils';
97
98
 
98
99
  export { boostCoreAbi };
99
100
 
101
+ /**
102
+ * The fee (in wei) required to claim each incentive, must be provided for the `claimIncentive` transaction
103
+ *
104
+ * @type {bigint}
105
+ */
106
+ export const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
107
+
100
108
  /**
101
109
  * The fixed address for the deployed Boost Core.
102
110
  * By default, `new BoostCore` will use this address if not otherwise provided.
@@ -245,7 +253,8 @@ export class BoostCore extends Deployable<
245
253
  }
246
254
  //@ts-expect-error I can't set this property on the class because for some reason it takes super out of constructor scope?
247
255
  this.abi = boostCoreAbi;
248
- } /**
256
+ }
257
+ /**
249
258
  * Create a new Boost.
250
259
  *
251
260
  * @public
@@ -293,30 +302,19 @@ export class BoostCore extends Deployable<
293
302
  }
294
303
  }
295
304
 
296
- let budgetPayload: OnChainBoostPayload['budget'] = zeroAddress;
305
+ let budgetPayload: BoostPayload['budget'] = zeroAddress;
297
306
  if (budget.address) {
298
307
  budgetPayload = budget.address;
299
308
  if (!(await budget.isAuthorized(coreAddress))) {
300
309
  throw new BudgetMustAuthorizeBoostCore(coreAddress);
301
310
  }
302
311
  } else {
303
- // budgets are either instantiated with an address or payload, so in this branch payload will exist
304
- const authorized = budget.payload?.authorized || [];
305
- if (!authorized.includes(coreAddress)) {
306
- throw new BudgetMustAuthorizeBoostCore(coreAddress);
307
- }
308
- const budgetHash = await budget.deployRaw(undefined, options);
309
- const receipt = await waitForTransactionReceipt(options.config, {
310
- hash: budgetHash,
311
- });
312
- if (!receipt.contractAddress)
313
- throw new NoContractAddressUponReceiptError(receipt);
314
- budgetPayload = receipt.contractAddress;
312
+ throw new MustInitializeBudgetError();
315
313
  }
316
314
 
317
315
  // if we're supplying an address, it could be a pre-initialized target
318
316
  // if base is explicitly set to false, then it will not be initialized, and it will be referenced as is if it implements interface correctly
319
- let actionPayload: OnChainBoostPayload['action'] = {
317
+ let actionPayload: BoostPayload['action'] = {
320
318
  instance: zeroAddress,
321
319
  isBase: true,
322
320
  parameters: zeroHash,
@@ -336,7 +334,7 @@ export class BoostCore extends Deployable<
336
334
  actionPayload.instance = action.base;
337
335
  }
338
336
 
339
- let validatorPayload: OnChainBoostPayload['validator'] = {
337
+ let validatorPayload: BoostPayload['validator'] = {
340
338
  instance: zeroAddress,
341
339
  isBase: true,
342
340
  parameters: zeroHash,
@@ -372,7 +370,7 @@ export class BoostCore extends Deployable<
372
370
  validatorPayload.instance = validator.base;
373
371
  }
374
372
 
375
- let allowListPayload: OnChainBoostPayload['allowList'] = {
373
+ let allowListPayload: BoostPayload['allowList'] = {
376
374
  instance: zeroAddress,
377
375
  isBase: true,
378
376
  parameters: zeroHash,
@@ -402,6 +400,7 @@ export class BoostCore extends Deployable<
402
400
  const incentive = incentives.at(i)!;
403
401
  if (incentive.address) {
404
402
  const isBase = incentive.address === incentive.base || incentive.isBase;
403
+ if (!isBase) throw new IncentiveNotCloneableError(incentive);
405
404
  incentivesPayloads[i] = {
406
405
  isBase: isBase,
407
406
  instance: incentive.address,
@@ -411,8 +410,10 @@ export class BoostCore extends Deployable<
411
410
  : zeroHash,
412
411
  };
413
412
  } else {
413
+ // biome-ignore lint/style/noNonNullAssertion: this will never be undefined
414
414
  incentivesPayloads[i]!.parameters =
415
415
  incentive.buildParameters(undefined, options).args.at(0) || zeroHash;
416
+ // biome-ignore lint/style/noNonNullAssertion: this will never be undefined
416
417
  incentivesPayloads[i]!.instance = incentive.base;
417
418
  }
418
419
  }
@@ -452,6 +453,7 @@ export class BoostCore extends Deployable<
452
453
  validator: validator.at(boost.validator),
453
454
  allowList: allowList.at(boost.allowList),
454
455
  incentives: incentives.map((incentive, i) =>
456
+ // biome-ignore lint/style/noNonNullAssertion: this will never be undefined
455
457
  incentive.at(boost.incentives.at(i)!),
456
458
  ),
457
459
  protocolFee: boost.protocolFee,
@@ -480,7 +482,7 @@ export class BoostCore extends Deployable<
480
482
  data: Hex,
481
483
  params?: WriteParams<typeof boostCoreAbi, 'claimIncentive'>,
482
484
  ) {
483
- return this.awaitResult(
485
+ return await this.awaitResult(
484
486
  this.claimIncentiveRaw(boostId, incentiveId, address, data, params),
485
487
  );
486
488
  }
@@ -492,7 +494,7 @@ export class BoostCore extends Deployable<
492
494
  * @async
493
495
  * @param {bigint} boostId - The ID of the Boost
494
496
  * @param {bigint} incentiveId - The ID of the Incentive
495
- * @param {Address} address - The address of the referrer (if any)
497
+ * @param {Address} referrer - The address of the referrer (if any)
496
498
  * @param {Hex} data- The data for the claim
497
499
  * @param {?WriteParams<typeof boostCoreAbi, 'claimIncentive'>} [params]
498
500
  * @returns {unknown}
@@ -500,7 +502,7 @@ export class BoostCore extends Deployable<
500
502
  public async claimIncentiveRaw(
501
503
  boostId: bigint,
502
504
  incentiveId: bigint,
503
- address: Address,
505
+ referrer: Address,
504
506
  data: Hex,
505
507
  params?: WriteParams<typeof boostCoreAbi, 'claimIncentive'>,
506
508
  ) {
@@ -508,7 +510,7 @@ export class BoostCore extends Deployable<
508
510
  this._config,
509
511
  {
510
512
  address: this.assertValidAddress(),
511
- args: [boostId, incentiveId, address, data],
513
+ args: [boostId, incentiveId, referrer, data],
512
514
  ...this.optionallyAttachAccount(),
513
515
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
514
516
  ...(params as any),
@@ -518,6 +520,74 @@ export class BoostCore extends Deployable<
518
520
  return { hash, result };
519
521
  }
520
522
 
523
+ /**
524
+ * Claims one incentive for a given `Boost` on behalf of another user by `boostId` and `incentiveId`
525
+ *
526
+ * @public
527
+ * @async
528
+ * @param {bigint} boostId
529
+ * @param {bigint} incentiveId
530
+ * @param {Address} referrer
531
+ * @param {Hex} data
532
+ * @param {Address} claimant
533
+ * @param {?WriteParams<typeof boostCoreAbi, 'claimIncentiveFor'>} [params]
534
+ * @returns {unknown}
535
+ */
536
+ public async claimIncentiveFor(
537
+ boostId: bigint,
538
+ incentiveId: bigint,
539
+ referrer: Address,
540
+ data: Hex,
541
+ claimant: Address,
542
+ params?: WriteParams<typeof boostCoreAbi, 'claimIncentiveFor'>,
543
+ ) {
544
+ return await this.awaitResult(
545
+ this.claimIncentiveForRaw(
546
+ boostId,
547
+ incentiveId,
548
+ referrer,
549
+ data,
550
+ claimant,
551
+ params,
552
+ ),
553
+ );
554
+ }
555
+
556
+ /**
557
+ * Claim an incentive for a Boost on behalf of another user
558
+ *
559
+ * @public
560
+ * @async
561
+ * @param {bigint} boostId - The ID of the Boost
562
+ * @param {bigint} incentiveId - The ID of the Incentive
563
+ * @param {Address} referrer - The address of the referrer (if any)
564
+ * @param {Hex} data - The data for the claim
565
+ * @param {Address} claimant - The address of the user eligible for the incentive payout
566
+ * @param {?WriteParams<typeof boostCoreAbi, 'claimIncentiveFor'>} [params]
567
+ * @returns {unknown}
568
+ */
569
+ public async claimIncentiveForRaw(
570
+ boostId: bigint,
571
+ incentiveId: bigint,
572
+ referrer: Address,
573
+ data: Hex,
574
+ claimant: Address,
575
+ params?: WriteParams<typeof boostCoreAbi, 'claimIncentiveFor'>,
576
+ ) {
577
+ const { request, result } = await simulateBoostCoreClaimIncentiveFor(
578
+ this._config,
579
+ {
580
+ address: this.assertValidAddress(),
581
+ args: [boostId, incentiveId, referrer, data, claimant],
582
+ ...this.optionallyAttachAccount(),
583
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
584
+ ...(params as any),
585
+ },
586
+ );
587
+ const hash = await writeBoostCoreClaimIncentiveFor(this._config, request);
588
+ return { hash, result };
589
+ }
590
+
521
591
  /**
522
592
  * Get a Boost by index, will return the raw on chain representation of a Boost.
523
593
  *
@@ -531,7 +601,7 @@ export class BoostCore extends Deployable<
531
601
  id: bigint,
532
602
  params?: ReadParams<typeof boostCoreAbi, 'getBoost'>,
533
603
  ) {
534
- return readBoostCoreGetBoost(this._config, {
604
+ return await readBoostCoreGetBoost(this._config, {
535
605
  address: this.assertValidAddress(),
536
606
  args: [id],
537
607
  ...this.optionallyAttachAccount(),
@@ -605,7 +675,7 @@ export class BoostCore extends Deployable<
605
675
  public async getBoostCount(
606
676
  params?: ReadParams<typeof boostCoreAbi, 'getBoostCount'>,
607
677
  ) {
608
- return readBoostCoreGetBoostCount(this._config, {
678
+ return await readBoostCoreGetBoostCount(this._config, {
609
679
  address: this.assertValidAddress(),
610
680
  args: [],
611
681
  ...this.optionallyAttachAccount(),
@@ -650,7 +720,7 @@ export class BoostCore extends Deployable<
650
720
  public async createBoostAuth(
651
721
  params?: ReadParams<typeof boostCoreAbi, 'createBoostAuth'>,
652
722
  ) {
653
- return readBoostCoreCreateBoostAuth(this._config, {
723
+ return await readBoostCoreCreateBoostAuth(this._config, {
654
724
  address: this.assertValidAddress(),
655
725
  args: [],
656
726
  ...this.optionallyAttachAccount(),
@@ -672,7 +742,7 @@ export class BoostCore extends Deployable<
672
742
  auth: Auth,
673
743
  params?: WriteParams<typeof boostCoreAbi, 'setCreateBoostAuth'>,
674
744
  ) {
675
- return this.awaitResult(
745
+ return await this.awaitResult(
676
746
  this.setCreateBoostAuthRaw(auth.assertValidAddress(), {
677
747
  ...params,
678
748
  }),
@@ -717,7 +787,7 @@ export class BoostCore extends Deployable<
717
787
  public async protocolFee(
718
788
  params?: ReadParams<typeof boostCoreAbi, 'protocolFee'>,
719
789
  ) {
720
- return readBoostCoreProtocolFee(this._config, {
790
+ return await readBoostCoreProtocolFee(this._config, {
721
791
  address: this.assertValidAddress(),
722
792
  args: [],
723
793
  ...this.optionallyAttachAccount(),
@@ -737,7 +807,7 @@ export class BoostCore extends Deployable<
737
807
  public async protocolFeeReceiver(
738
808
  params?: ReadParams<typeof boostCoreAbi, 'protocolFeeReceiver'>,
739
809
  ) {
740
- return readBoostCoreProtocolFeeReceiver(this._config, {
810
+ return await readBoostCoreProtocolFeeReceiver(this._config, {
741
811
  address: this.assertValidAddress(),
742
812
  args: [],
743
813
  ...this.optionallyAttachAccount(),
@@ -759,7 +829,7 @@ export class BoostCore extends Deployable<
759
829
  address: Address,
760
830
  params?: WriteParams<typeof boostCoreAbi, 'setProtocolFeeReceiver'>,
761
831
  ) {
762
- return this.awaitResult(
832
+ return await this.awaitResult(
763
833
  this.setProcolFeeReceiverRaw(address, {
764
834
  ...params,
765
835
  }),
@@ -805,7 +875,7 @@ export class BoostCore extends Deployable<
805
875
  * @returns {unknown}
806
876
  */
807
877
  public async claimFee(params?: ReadParams<typeof boostCoreAbi, 'claimFee'>) {
808
- return readBoostCoreClaimFee(this._config, {
878
+ return await readBoostCoreClaimFee(this._config, {
809
879
  address: this.assertValidAddress(),
810
880
  args: [],
811
881
  ...this.optionallyAttachAccount(),
@@ -827,7 +897,7 @@ export class BoostCore extends Deployable<
827
897
  claimFee: bigint,
828
898
  params?: WriteParams<typeof boostCoreAbi, 'setClaimFee'>,
829
899
  ) {
830
- return this.awaitResult(this.setClaimFeeRaw(claimFee, params));
900
+ return await this.awaitResult(this.setClaimFeeRaw(claimFee, params));
831
901
  }
832
902
 
833
903
  /**
@@ -865,8 +935,7 @@ export class BoostCore extends Deployable<
865
935
  * const auth = core.PassthroughAuth('0x') // is roughly equivalent to
866
936
  * const auth = new PassthroughAuth({ config: core._config, account: core._account }, '0x')
867
937
  * ```
868
- * @param {DeployablePayloadOrAddress<{}>} options
869
- * @param {?boolean} [isBase]
938
+ * @param {Address} address
870
939
  * @returns {PassthroughAuth}
871
940
  */
872
941
  PassthroughAuth(address?: Address) {
@@ -21,15 +21,15 @@ import {
21
21
  type GenericDeployableParams,
22
22
  } from './Deployable/Deployable';
23
23
  import type { DeployableTarget } from './Deployable/DeployableTarget';
24
- import {
25
- type GenericLog,
26
- type HashAndSimulatedResult,
27
- type ReadParams,
24
+ import type {
25
+ GenericLog,
26
+ HashAndSimulatedResult,
27
+ ReadParams,
28
28
  RegistryType,
29
- type WriteParams,
29
+ WriteParams,
30
30
  } from './utils';
31
31
 
32
- export { RegistryType, boostRegistryAbi };
32
+ export { boostRegistryAbi };
33
33
 
34
34
  /**
35
35
  * The fixed address for the Boost Registry.
@@ -192,7 +192,7 @@ export class BoostRegistry extends Deployable<
192
192
  implementation: Address,
193
193
  params?: WriteParams<typeof boostRegistryAbi, 'register'>,
194
194
  ) {
195
- return this.awaitResult(
195
+ return await this.awaitResult(
196
196
  this.registerRaw(registryType, name, implementation, params),
197
197
  );
198
198
  }
@@ -227,6 +227,27 @@ export class BoostRegistry extends Deployable<
227
227
  return { hash, result };
228
228
  }
229
229
 
230
+ /**
231
+ * Initialize a new instance of a registered base implementation, returning the provided target with a new address set on it.
232
+ * This method is the same as `clone`, but serves to make its function more obvious as to why you'd need to use it.
233
+ *
234
+ * @public
235
+ * @async
236
+ * @template {DeployableTarget} Target
237
+ * @param {string} displayName - The display name for the clone
238
+ * @param {Target} target - An instance of a target contract to clone and initialize
239
+ * @param {?WriteParams<typeof boostRegistryAbi, 'deployClone'>} [params]
240
+ * @returns {Target} - The provided instance, but with a new address attached.
241
+ * biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
242
+ */
243
+ public initialize<Target extends DeployableTarget<any, any>>(
244
+ displayName: string,
245
+ target: Target,
246
+ params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
247
+ ): Promise<Target> {
248
+ return this.clone(displayName, target, params);
249
+ }
250
+
230
251
  /**
231
252
  * Deploy a new instance of a registered base implementation, returning the provided target with a new address set on it.
232
253
  *
@@ -265,7 +286,9 @@ export class BoostRegistry extends Deployable<
265
286
  target: Target,
266
287
  params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
267
288
  ): Promise<Address> {
268
- return this.awaitResult(this.deployCloneRaw(displayName, target, params));
289
+ return await this.awaitResult(
290
+ this.deployCloneRaw(displayName, target, params),
291
+ );
269
292
  }
270
293
 
271
294
  /**
@@ -291,12 +314,7 @@ export class BoostRegistry extends Deployable<
291
314
  this._config,
292
315
  {
293
316
  address: this.assertValidAddress(),
294
- args: [
295
- target.registryType,
296
- target.base,
297
- displayName,
298
- payload.args.at(0)!,
299
- ],
317
+ args: [target.registryType, target.base, displayName, payload.args[0]],
300
318
  ...this.optionallyAttachAccount(),
301
319
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
302
320
  ...(params as any),
@@ -320,7 +338,7 @@ export class BoostRegistry extends Deployable<
320
338
  identifier: Hex,
321
339
  params?: ReadParams<typeof boostRegistryAbi, 'getBaseImplementation'>,
322
340
  ) {
323
- return readBoostRegistryGetBaseImplementation(this._config, {
341
+ return await readBoostRegistryGetBaseImplementation(this._config, {
324
342
  address: this.assertValidAddress(),
325
343
  args: [identifier],
326
344
  ...this.optionallyAttachAccount(),
@@ -330,7 +348,7 @@ export class BoostRegistry extends Deployable<
330
348
  }
331
349
 
332
350
  /**
333
- * Get the address of a deployed clone by its identifier (index in incentives array)
351
+ * Get the address of a deployed clone by its identifier
334
352
  *
335
353
  * @public
336
354
  * @async
@@ -342,7 +360,7 @@ export class BoostRegistry extends Deployable<
342
360
  identifier: Hex,
343
361
  params?: ReadParams<typeof boostRegistryAbi, 'getClone'>,
344
362
  ) {
345
- return readBoostRegistryGetBaseImplementation(this._config, {
363
+ return await readBoostRegistryGetBaseImplementation(this._config, {
346
364
  address: this.assertValidAddress(),
347
365
  args: [identifier],
348
366
  ...this.optionallyAttachAccount(),
@@ -358,13 +376,13 @@ export class BoostRegistry extends Deployable<
358
376
  * @async
359
377
  * @param {Address} deployer - The address of the deployer
360
378
  * @param {?ReadParams<typeof boostRegistryAbi, 'getClones'>} [params]
361
- * @returns {Promise<Address[]>} - The list of deployed clones for the given deployer
379
+ * @returns {Promise<Hex[]>} - The list of deployed clones for the given deployer
362
380
  */
363
381
  public async getClones(
364
382
  deployer: Address,
365
383
  params?: ReadParams<typeof boostRegistryAbi, 'getClones'>,
366
384
  ) {
367
- return readBoostRegistryGetClones(this._config, {
385
+ return await readBoostRegistryGetClones(this._config, {
368
386
  address: this.assertValidAddress(),
369
387
  args: [deployer],
370
388
  ...this.optionallyAttachAccount(),
@@ -392,7 +410,7 @@ export class BoostRegistry extends Deployable<
392
410
  displayName: string,
393
411
  params?: ReadParams<typeof boostRegistryAbi, 'getCloneIdentifier'>,
394
412
  ) {
395
- return readBoostRegistryGetCloneIdentifier(this._config, {
413
+ return await readBoostRegistryGetCloneIdentifier(this._config, {
396
414
  address: this.assertValidAddress(),
397
415
  args: [registryType, base, deployer, displayName],
398
416
  ...this.optionallyAttachAccount(),
@@ -416,7 +434,7 @@ export class BoostRegistry extends Deployable<
416
434
  displayName: string,
417
435
  params?: ReadParams<typeof boostRegistryAbi, 'getIdentifier'>,
418
436
  ) {
419
- return readBoostRegistryGetCloneIdentifier(this._config, {
437
+ return await readBoostRegistryGetCloneIdentifier(this._config, {
420
438
  address: this.assertValidAddress(),
421
439
  args: [registryType, displayName],
422
440
  ...this.optionallyAttachAccount(),
@@ -29,6 +29,8 @@ import {
29
29
  type Address,
30
30
  type ContractEventName,
31
31
  type Hex,
32
+ encodeAbiParameters,
33
+ parseAbiParameters,
32
34
  zeroAddress,
33
35
  } from 'viem';
34
36
  import type {
@@ -43,22 +45,46 @@ import {
43
45
  import {
44
46
  type ERC1155TransferPayload,
45
47
  type FungibleTransferPayload,
48
+ prepareERC1155Transfer,
49
+ prepareFungibleTransfer,
50
+ } from '../transfers';
51
+ import {
46
52
  type GenericLog,
47
- type ManagedBudgetPayload,
48
53
  type ReadParams,
49
54
  RegistryType,
50
55
  type WriteParams,
51
- prepareERC1155Transfer,
52
- prepareFungibleTransfer,
53
- prepareManagedBudgetPayload,
54
56
  } from '../utils';
55
57
 
56
58
  export { managedBudgetAbi };
57
- export type {
58
- ERC1155TransferPayload,
59
- FungibleTransferPayload,
60
- ManagedBudgetPayload,
61
- };
59
+ export type { ERC1155TransferPayload, FungibleTransferPayload };
60
+
61
+ /**
62
+ * The object representation of a `ManagedBudgetPayload.InitPayload`
63
+ *
64
+ * @export
65
+ * @interface ManagedBudgetPayload
66
+ * @typedef {ManagedBudgetPayload}
67
+ */
68
+ export interface ManagedBudgetPayload {
69
+ /**
70
+ * The budget's owner
71
+ *
72
+ * @type {Address}
73
+ */
74
+ owner: Address;
75
+ /**
76
+ * List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
77
+ *
78
+ * @type {Address[]}
79
+ */
80
+ authorized: Address[];
81
+ /**
82
+ * List of roles to assign to the corresponding account by index.
83
+ *
84
+ * @type {bigint[]}
85
+ */
86
+ roles: bigint[];
87
+ }
62
88
 
63
89
  /**
64
90
  * Enum representing available roles for use in the `ManagedBudget`.
@@ -185,7 +211,7 @@ export class ManagedBudget extends DeployableTarget<
185
211
  transfer: FungibleTransferPayload | ERC1155TransferPayload,
186
212
  params?: WriteParams<typeof managedBudgetAbi, 'allocate'>,
187
213
  ) {
188
- return this.awaitResult(this.allocateRaw(transfer, params));
214
+ return await this.awaitResult(this.allocateRaw(transfer, params));
189
215
  }
190
216
 
191
217
  /**
@@ -233,7 +259,7 @@ export class ManagedBudget extends DeployableTarget<
233
259
  transfer: FungibleTransferPayload | ERC1155TransferPayload,
234
260
  params?: WriteParams<typeof managedBudgetAbi, 'clawback'>,
235
261
  ) {
236
- return this.awaitResult(this.clawbackRaw(transfer, params));
262
+ return await this.awaitResult(this.clawbackRaw(transfer, params));
237
263
  }
238
264
 
239
265
  /**
@@ -280,7 +306,7 @@ export class ManagedBudget extends DeployableTarget<
280
306
  transfer: FungibleTransferPayload | ERC1155TransferPayload,
281
307
  params?: WriteParams<typeof managedBudgetAbi, 'disburse'>,
282
308
  ) {
283
- return this.awaitResult(this.disburseRaw(transfer, params));
309
+ return await this.awaitResult(this.disburseRaw(transfer, params));
284
310
  }
285
311
 
286
312
  /**
@@ -324,7 +350,7 @@ export class ManagedBudget extends DeployableTarget<
324
350
  transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
325
351
  params?: WriteParams<typeof managedBudgetAbi, 'disburseBatch'>,
326
352
  ) {
327
- return this.awaitResult(this.disburseBatchRaw(transfers, params));
353
+ return await this.awaitResult(this.disburseBatchRaw(transfers, params));
328
354
  }
329
355
 
330
356
  /**
@@ -370,7 +396,9 @@ export class ManagedBudget extends DeployableTarget<
370
396
  allowed: boolean[],
371
397
  params?: WriteParams<typeof managedBudgetAbi, 'setAuthorized'>,
372
398
  ) {
373
- return this.awaitResult(this.setAuthorizedRaw(addresses, allowed, params));
399
+ return await this.awaitResult(
400
+ this.setAuthorizedRaw(addresses, allowed, params),
401
+ );
374
402
  }
375
403
 
376
404
  /**
@@ -422,7 +450,7 @@ export class ManagedBudget extends DeployableTarget<
422
450
  roles: bigint[],
423
451
  params?: WriteParams<typeof managedBudgetAbi, 'grantRoles'>,
424
452
  ) {
425
- return this.awaitResult(this.grantRolesRaw(addresses, roles, params));
453
+ return await this.awaitResult(this.grantRolesRaw(addresses, roles, params));
426
454
  }
427
455
 
428
456
  /**
@@ -481,7 +509,9 @@ export class ManagedBudget extends DeployableTarget<
481
509
  roles: bigint[],
482
510
  params?: WriteParams<typeof managedBudgetAbi, 'revokeRoles'>,
483
511
  ) {
484
- return this.awaitResult(this.revokeRolesRaw(addresses, roles, params));
512
+ return await this.awaitResult(
513
+ this.revokeRolesRaw(addresses, roles, params),
514
+ );
485
515
  }
486
516
 
487
517
  /**
@@ -741,3 +771,26 @@ export class ManagedBudget extends DeployableTarget<
741
771
  };
742
772
  }
743
773
  }
774
+
775
+ /**
776
+ * Given a {@link ManagedBudgetPayload}, properly encode a `ManagedBudget.InitPayload` for use with {@link ManagedBudget} initialization.
777
+ *
778
+ * @param {ManagedBudgetPayload} param0
779
+ * @param {Address} param0.owner - The budget's owner
780
+ * @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
781
+ * @param {{}} param0.roles - List of roles to assign to the corresponding account by index.
782
+ * @returns {*}
783
+ */
784
+ export const prepareManagedBudgetPayload = ({
785
+ owner,
786
+ authorized,
787
+ roles,
788
+ }: ManagedBudgetPayload) => {
789
+ return encodeAbiParameters(
790
+ parseAbiParameters([
791
+ 'ManagedBudgetPayload payload',
792
+ 'struct ManagedBudgetPayload { address owner; address[] authorized; uint256[] roles; }',
793
+ ]),
794
+ [{ owner, authorized, roles }],
795
+ );
796
+ };