@boostxyz/sdk 0.0.0-alpha.10

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 (242) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +7 -0
  3. package/dist/Actions/Action.cjs +2 -0
  4. package/dist/Actions/Action.cjs.map +1 -0
  5. package/dist/Actions/Action.d.ts +31 -0
  6. package/dist/Actions/Action.d.ts.map +1 -0
  7. package/dist/Actions/Action.js +29 -0
  8. package/dist/Actions/Action.js.map +1 -0
  9. package/dist/Actions/ContractAction.d.ts +370 -0
  10. package/dist/Actions/ContractAction.d.ts.map +1 -0
  11. package/dist/Actions/ERC721MintAction.d.ts +513 -0
  12. package/dist/Actions/ERC721MintAction.d.ts.map +1 -0
  13. package/dist/Actions/EventAction.cjs +2 -0
  14. package/dist/Actions/EventAction.cjs.map +1 -0
  15. package/dist/Actions/EventAction.d.ts +694 -0
  16. package/dist/Actions/EventAction.d.ts.map +1 -0
  17. package/dist/Actions/EventAction.js +491 -0
  18. package/dist/Actions/EventAction.js.map +1 -0
  19. package/dist/AllowLists/AllowList.cjs +2 -0
  20. package/dist/AllowLists/AllowList.cjs.map +1 -0
  21. package/dist/AllowLists/AllowList.d.ts +32 -0
  22. package/dist/AllowLists/AllowList.d.ts.map +1 -0
  23. package/dist/AllowLists/AllowList.js +30 -0
  24. package/dist/AllowLists/AllowList.js.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -0
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +481 -0
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -0
  29. package/dist/AllowLists/SimpleAllowList.js +154 -0
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -0
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +335 -0
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -0
  35. package/dist/AllowLists/SimpleDenyList.js +115 -0
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +2 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.d.ts +10 -0
  40. package/dist/Auth/Auth.d.ts.map +1 -0
  41. package/dist/Auth/Auth.js +5 -0
  42. package/dist/Auth/Auth.js.map +1 -0
  43. package/dist/Auth/PassthroughAuth.cjs +2 -0
  44. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  45. package/dist/Auth/PassthroughAuth.d.ts +51 -0
  46. package/dist/Auth/PassthroughAuth.d.ts.map +1 -0
  47. package/dist/Auth/PassthroughAuth.js +39 -0
  48. package/dist/Auth/PassthroughAuth.js.map +1 -0
  49. package/dist/Boost.cjs +2 -0
  50. package/dist/Boost.cjs.map +1 -0
  51. package/dist/Boost.d.ts +234 -0
  52. package/dist/Boost.d.ts.map +1 -0
  53. package/dist/Boost.js +162 -0
  54. package/dist/Boost.js.map +1 -0
  55. package/dist/BoostCore.cjs +3 -0
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +498 -0
  58. package/dist/BoostCore.d.ts.map +1 -0
  59. package/dist/BoostCore.js +1153 -0
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -0
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +243 -0
  64. package/dist/BoostRegistry.d.ts.map +1 -0
  65. package/dist/BoostRegistry.js +262 -0
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -0
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +31 -0
  70. package/dist/Budgets/Budget.d.ts.map +1 -0
  71. package/dist/Budgets/Budget.js +29 -0
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -0
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +1103 -0
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -0
  77. package/dist/Budgets/ManagedBudget.js +516 -0
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/SimpleBudget.d.ts +824 -0
  80. package/dist/Budgets/SimpleBudget.d.ts.map +1 -0
  81. package/dist/Budgets/VestingBudget.d.ts +778 -0
  82. package/dist/Budgets/VestingBudget.d.ts.map +1 -0
  83. package/dist/Deployable/Contract.cjs +2 -0
  84. package/dist/Deployable/Contract.cjs.map +1 -0
  85. package/dist/Deployable/Contract.d.ts +125 -0
  86. package/dist/Deployable/Contract.d.ts.map +1 -0
  87. package/dist/Deployable/Contract.js +150 -0
  88. package/dist/Deployable/Contract.js.map +1 -0
  89. package/dist/Deployable/Deployable.cjs +2 -0
  90. package/dist/Deployable/Deployable.cjs.map +1 -0
  91. package/dist/Deployable/Deployable.d.ts +161 -0
  92. package/dist/Deployable/Deployable.d.ts.map +1 -0
  93. package/dist/Deployable/Deployable.js +131 -0
  94. package/dist/Deployable/Deployable.js.map +1 -0
  95. package/dist/Deployable/DeployableTarget.cjs +2 -0
  96. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  97. package/dist/Deployable/DeployableTarget.d.ts +116 -0
  98. package/dist/Deployable/DeployableTarget.d.ts.map +1 -0
  99. package/dist/Deployable/DeployableTarget.js +132 -0
  100. package/dist/Deployable/DeployableTarget.js.map +1 -0
  101. package/dist/Incentives/AllowListIncentive.cjs +2 -0
  102. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  103. package/dist/Incentives/AllowListIncentive.d.ts +513 -0
  104. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -0
  105. package/dist/Incentives/AllowListIncentive.js +201 -0
  106. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  107. package/dist/Incentives/CGDAIncentive.cjs +2 -0
  108. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  109. package/dist/Incentives/CGDAIncentive.d.ts +644 -0
  110. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -0
  111. package/dist/Incentives/CGDAIncentive.js +271 -0
  112. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  113. package/dist/Incentives/ERC1155Incentive.d.ts +713 -0
  114. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -0
  115. package/dist/Incentives/ERC20Incentive.cjs +2 -0
  116. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  117. package/dist/Incentives/ERC20Incentive.d.ts +666 -0
  118. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -0
  119. package/dist/Incentives/ERC20Incentive.js +312 -0
  120. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  121. package/dist/Incentives/ERC20VariableIncentive.d.ts +582 -0
  122. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -0
  123. package/dist/Incentives/Incentive.cjs +2 -0
  124. package/dist/Incentives/Incentive.cjs.map +1 -0
  125. package/dist/Incentives/Incentive.d.ts +36 -0
  126. package/dist/Incentives/Incentive.d.ts.map +1 -0
  127. package/dist/Incentives/Incentive.js +299 -0
  128. package/dist/Incentives/Incentive.js.map +1 -0
  129. package/dist/Incentives/PointsIncentive.cjs +2 -0
  130. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  131. package/dist/Incentives/PointsIncentive.d.ts +659 -0
  132. package/dist/Incentives/PointsIncentive.d.ts.map +1 -0
  133. package/dist/Incentives/PointsIncentive.js +215 -0
  134. package/dist/Incentives/PointsIncentive.js.map +1 -0
  135. package/dist/Validators/SignerValidator.cjs +2 -0
  136. package/dist/Validators/SignerValidator.cjs.map +1 -0
  137. package/dist/Validators/SignerValidator.d.ts +745 -0
  138. package/dist/Validators/SignerValidator.d.ts.map +1 -0
  139. package/dist/Validators/SignerValidator.js +293 -0
  140. package/dist/Validators/SignerValidator.js.map +1 -0
  141. package/dist/Validators/Validator.cjs +2 -0
  142. package/dist/Validators/Validator.cjs.map +1 -0
  143. package/dist/Validators/Validator.d.ts +31 -0
  144. package/dist/Validators/Validator.d.ts.map +1 -0
  145. package/dist/Validators/Validator.js +27 -0
  146. package/dist/Validators/Validator.js.map +1 -0
  147. package/dist/claiming.cjs +2 -0
  148. package/dist/claiming.cjs.map +1 -0
  149. package/dist/claiming.d.ts +43 -0
  150. package/dist/claiming.d.ts.map +1 -0
  151. package/dist/claiming.js +17 -0
  152. package/dist/claiming.js.map +1 -0
  153. package/dist/componentInterfaces-CKCBwG16.cjs +2 -0
  154. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  155. package/dist/componentInterfaces-DYkaxBda.js +13 -0
  156. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  157. package/dist/errors.cjs +2 -0
  158. package/dist/errors.cjs.map +1 -0
  159. package/dist/errors.d.ts +441 -0
  160. package/dist/errors.d.ts.map +1 -0
  161. package/dist/errors.js +262 -0
  162. package/dist/errors.js.map +1 -0
  163. package/dist/generated-BDeDiaCK.js +4625 -0
  164. package/dist/generated-BDeDiaCK.js.map +1 -0
  165. package/dist/generated-wKBNvm48.cjs +3 -0
  166. package/dist/generated-wKBNvm48.cjs.map +1 -0
  167. package/dist/index.cjs +2 -0
  168. package/dist/index.cjs.map +1 -0
  169. package/dist/index.d.ts +25 -0
  170. package/dist/index.d.ts.map +1 -0
  171. package/dist/index.js +113 -0
  172. package/dist/index.js.map +1 -0
  173. package/dist/transfers.cjs +2 -0
  174. package/dist/transfers.cjs.map +1 -0
  175. package/dist/transfers.d.ts +198 -0
  176. package/dist/transfers.d.ts.map +1 -0
  177. package/dist/transfers.js +84 -0
  178. package/dist/transfers.js.map +1 -0
  179. package/dist/utils.cjs +2 -0
  180. package/dist/utils.cjs.map +1 -0
  181. package/dist/utils.d.ts +116 -0
  182. package/dist/utils.d.ts.map +1 -0
  183. package/dist/utils.js +30 -0
  184. package/dist/utils.js.map +1 -0
  185. package/package.json +211 -0
  186. package/src/Actions/Action.test.ts +75 -0
  187. package/src/Actions/Action.ts +61 -0
  188. package/src/Actions/ContractAction.test.ts +197 -0
  189. package/src/Actions/ContractAction.ts +301 -0
  190. package/src/Actions/ERC721MintAction.test.ts +112 -0
  191. package/src/Actions/ERC721MintAction.ts +292 -0
  192. package/src/Actions/EventAction.test.ts +205 -0
  193. package/src/Actions/EventAction.ts +811 -0
  194. package/src/AllowLists/AllowList.test.ts +64 -0
  195. package/src/AllowLists/AllowList.ts +60 -0
  196. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  197. package/src/AllowLists/SimpleAllowList.ts +284 -0
  198. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  199. package/src/AllowLists/SimpleDenyList.ts +227 -0
  200. package/src/Auth/Auth.ts +11 -0
  201. package/src/Auth/PassthroughAuth.test.ts +12 -0
  202. package/src/Auth/PassthroughAuth.ts +80 -0
  203. package/src/Boost.ts +290 -0
  204. package/src/BoostCore.test.ts +773 -0
  205. package/src/BoostCore.ts +1261 -0
  206. package/src/BoostRegistry.ts +467 -0
  207. package/src/Budgets/Budget.test.ts +27 -0
  208. package/src/Budgets/Budget.ts +61 -0
  209. package/src/Budgets/ManagedBudget.test.ts +154 -0
  210. package/src/Budgets/ManagedBudget.ts +796 -0
  211. package/src/Budgets/SimpleBudget.test.ts +152 -0
  212. package/src/Budgets/SimpleBudget.ts +564 -0
  213. package/src/Budgets/VestingBudget.test.ts +123 -0
  214. package/src/Budgets/VestingBudget.ts +602 -0
  215. package/src/Deployable/Contract.ts +229 -0
  216. package/src/Deployable/Deployable.ts +250 -0
  217. package/src/Deployable/DeployableTarget.ts +223 -0
  218. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  219. package/src/Incentives/AllowListIncentive.ts +334 -0
  220. package/src/Incentives/CGDAIncentive.test.ts +132 -0
  221. package/src/Incentives/CGDAIncentive.ts +468 -0
  222. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  223. package/src/Incentives/ERC1155Incentive.ts +466 -0
  224. package/src/Incentives/ERC20Incentive.test.ts +130 -0
  225. package/src/Incentives/ERC20Incentive.ts +482 -0
  226. package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
  227. package/src/Incentives/ERC20VariableIncentive.ts +420 -0
  228. package/src/Incentives/Incentive.test.ts +92 -0
  229. package/src/Incentives/Incentive.ts +85 -0
  230. package/src/Incentives/PointsIncentive.test.ts +139 -0
  231. package/src/Incentives/PointsIncentive.ts +365 -0
  232. package/src/Validators/SignerValidator.test.ts +159 -0
  233. package/src/Validators/SignerValidator.ts +681 -0
  234. package/src/Validators/Validator.test.ts +21 -0
  235. package/src/Validators/Validator.ts +55 -0
  236. package/src/claiming.ts +56 -0
  237. package/src/errors.ts +542 -0
  238. package/src/index.test.ts +40 -0
  239. package/src/index.ts +53 -0
  240. package/src/transfers.ts +284 -0
  241. package/src/utils.test.ts +44 -0
  242. package/src/utils.ts +198 -0
@@ -0,0 +1,55 @@
1
+ import { aValidatorAbi } from '@boostxyz/evm';
2
+ import { ASignerValidator } from '@boostxyz/evm/deploys/componentInterfaces.json';
3
+ import { readContract } from '@wagmi/core';
4
+ import type { Address, Hex } from 'viem';
5
+ import type { DeployableOptions } from '../Deployable/Deployable';
6
+ import { InvalidComponentInterfaceError } from '../errors';
7
+ import { SignerValidator } from './SignerValidator';
8
+
9
+ export { SignerValidator };
10
+
11
+ /**
12
+ * A union type representing all valid protocol Validator implementations
13
+ *
14
+ * @export
15
+ * @typedef {Validator}
16
+ */
17
+ export type Validator = SignerValidator;
18
+
19
+ /**
20
+ * A map of Validator component interfaces to their constructors.
21
+ *
22
+ * @type {{ "0xd8725ea2": typeof SignerValidator; }}
23
+ */
24
+ export const ValidatorByComponentInterface = {
25
+ [ASignerValidator as Hex]: SignerValidator,
26
+ };
27
+
28
+ /**
29
+ * A function that will read a contract's component interface using `getComponentInterface` and return the correct instantiated instance.
30
+ *
31
+ * @export
32
+ * @async
33
+ * @param {DeployableOptions} options
34
+ * @param {Address} address
35
+ * @returns {unknown}
36
+ * @throws {@link InvalidComponentInterfaceError}
37
+ */
38
+ export async function validatorFromAddress(
39
+ options: DeployableOptions,
40
+ address: Address,
41
+ ) {
42
+ const interfaceId = (await readContract(options.config, {
43
+ abi: aValidatorAbi,
44
+ functionName: 'getComponentInterface',
45
+ address,
46
+ })) as keyof typeof ValidatorByComponentInterface;
47
+ const Ctor = ValidatorByComponentInterface[interfaceId];
48
+ if (!Ctor) {
49
+ throw new InvalidComponentInterfaceError(
50
+ Object.keys(ValidatorByComponentInterface) as Hex[],
51
+ interfaceId as Hex,
52
+ );
53
+ }
54
+ return new Ctor(options, address);
55
+ }
@@ -0,0 +1,56 @@
1
+ import { type Address, type Hex, encodeAbiParameters, zeroHash } from 'viem';
2
+
3
+ /**
4
+ * Enum representing incentive disbursement strategies.
5
+ *
6
+ * @export
7
+ * @enum {number}
8
+ */
9
+ export enum StrategyType {
10
+ POOL = 0,
11
+ MINT = 1,
12
+ RAFFLE = 2,
13
+ }
14
+
15
+ /**
16
+ * The object representation of an `Incentive.ClaimPayload`
17
+ *
18
+ * @export
19
+ * @interface ClaimPayload
20
+ * @typedef {ClaimPayload}
21
+ */
22
+ export interface ClaimPayload {
23
+ /**
24
+ * The address of the recipient
25
+ *
26
+ * @type {Address}
27
+ */
28
+ target: Address;
29
+ /**
30
+ * The implementation-specific data for the claim, if needed
31
+ *
32
+ * @type {?Hex}
33
+ */
34
+ data?: Hex;
35
+ }
36
+
37
+ /**
38
+ * Given a valid {@link ClaimPayload}, encode the payload for use with Incentive operations.
39
+ *
40
+ * @param {ClaimPayload} param0
41
+ * @param {Address} param0.target - The address of the recipient
42
+ * @param {Hex} [param0.data=zeroHash] - The implementation-specific data for the claim, if needed
43
+ * @returns {*}
44
+ */
45
+ export const prepareClaimPayload = ({
46
+ target,
47
+ data = zeroHash,
48
+ }: ClaimPayload) => {
49
+ return encodeAbiParameters(
50
+ [
51
+ { type: 'address', name: 'target' },
52
+ { type: 'bytes', name: 'data' },
53
+ ],
54
+ [target, data],
55
+ );
56
+ };
package/src/errors.ts ADDED
@@ -0,0 +1,542 @@
1
+ import {
2
+ type Hex,
3
+ type Log,
4
+ type WaitForTransactionReceiptReturnType,
5
+ zeroHash,
6
+ } from 'viem';
7
+ import type { Criteria } from './Actions/EventAction';
8
+ import type { BoostRegistry } from './BoostRegistry';
9
+ import type { Incentive } from './Incentives/Incentive';
10
+
11
+ /**
12
+ * This error is thrown during Boost creation if no `BoostCreated` event was emitted.
13
+ *
14
+ * @export
15
+ * @class BoostCoreNoIdentifierEmitted
16
+ * @typedef {BoostCoreNoIdentifierEmitted}
17
+ * @extends {Error}
18
+ * @example
19
+ * ```ts
20
+ * try {
21
+ * await boostCore.createBoost(...)
22
+ * } catch(e) {
23
+ * if(e instanceof BoostCoreNoIdentifierEmitted) {}
24
+ * }
25
+ * ```
26
+ */
27
+ export class BoostCoreNoIdentifierEmitted extends Error {
28
+ /**
29
+ * Creates an instance of BoostCoreNoIdentifierEmitted.
30
+ *
31
+ * @constructor
32
+ */
33
+ constructor() {
34
+ super(`No "BoostCreated" log was emitted from which to extract boostId`);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * This error is thrown when `assertValidAddress` is called, usually because a contract call expects the class to have a valid address attached.
40
+ *
41
+ * @export
42
+ * @class ContractAddressRequiredError
43
+ * @typedef {ContractAddressRequiredError}
44
+ * @extends {Error}
45
+ * @example
46
+ * ```ts
47
+ * try {
48
+ * target.assertValidAddress()
49
+ * } catch(e) {
50
+ * if(e instanceof ContractAddressRequiredError) {}
51
+ * }
52
+ */
53
+ export class ContractAddressRequiredError extends Error {
54
+ /**
55
+ * Creates an instance of ContractAddressRequiredError.
56
+ *
57
+ * @constructor
58
+ */
59
+ constructor() {
60
+ super('Attempted to call contract method without providing an address');
61
+ }
62
+ }
63
+
64
+ /**
65
+ * This error is thrown when attempting to deploy a contract that has already been deployed, or has an address attached.
66
+ *
67
+ * @export
68
+ * @class DeployableAlreadyDeployedError
69
+ * @typedef {DeployableAlreadyDeployedError}
70
+ * @extends {Error}
71
+ */
72
+ export class DeployableAlreadyDeployedError extends Error {
73
+ /**
74
+ * The address already attached to the target.
75
+ *
76
+ * @type {string}
77
+ */
78
+ address: string;
79
+ /**
80
+ * Creates an instance of DeployableAlreadyDeployedError.
81
+ *
82
+ * @constructor
83
+ * @param {string} address
84
+ */
85
+ constructor(address: string) {
86
+ super(
87
+ `Attempted to deploy a contract that already has an address configured`,
88
+ );
89
+ this.address = address;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * You should never see this error if we did our jobs and every target overrides the `buildParameters` method.
95
+ *
96
+ * @export
97
+ * @class DeployableBuildParametersUnspecifiedError
98
+ * @typedef {DeployableBuildParametersUnspecifiedError}
99
+ * @extends {Error}
100
+ */
101
+ export class DeployableBuildParametersUnspecifiedError extends Error {
102
+ /**
103
+ * Creates an instance of DeployableBuildParametersUnspecifiedError.
104
+ *
105
+ * @constructor
106
+ */
107
+ constructor() {
108
+ super(
109
+ 'Implementing class did not properly override the `buildParameters` method',
110
+ );
111
+ }
112
+ }
113
+
114
+ /**
115
+ * This error is thrown when attempting to deploy an `ownable` contract and the owner cannot be ascertained from the initialization payload or configured account.
116
+ *
117
+ * @export
118
+ * @class DeployableUnknownOwnerProvidedError
119
+ * @typedef {DeployableUnknownOwnerProvidedError}
120
+ * @extends {Error}
121
+ */
122
+ export class DeployableUnknownOwnerProvidedError extends Error {
123
+ /**
124
+ * Creates an instance of DeployableUnknownOwnerProvidedError.
125
+ *
126
+ * @constructor
127
+ */
128
+ constructor() {
129
+ super(
130
+ 'Expected an an owner to be provided in configuration or an account to exist on Wagmi config.',
131
+ );
132
+ }
133
+ }
134
+
135
+ /**
136
+ * This error is thrown when deploying a contract with no valid Wagmi configuration on the instance.
137
+ *
138
+ * @export
139
+ * @class DeployableWagmiConfigurationRequiredError
140
+ * @typedef {DeployableWagmiConfigurationRequiredError}
141
+ * @extends {Error}
142
+ */
143
+ export class DeployableWagmiConfigurationRequiredError extends Error {
144
+ /**
145
+ * Creates an instance of DeployableWagmiConfigurationRequiredError.
146
+ *
147
+ * @constructor
148
+ */
149
+ constructor() {
150
+ super(
151
+ 'Expected a valid Wagmi configuration to be available either on Deployable, or as argument to deploy.',
152
+ );
153
+ }
154
+ }
155
+
156
+ /**
157
+ * This error is thrown when deploying a contract with no valid initialization payload.
158
+ *
159
+ * @export
160
+ * @class DeployableMissingPayloadError
161
+ * @typedef {DeployableMissingPayloadError}
162
+ * @extends {Error}
163
+ */
164
+ export class DeployableMissingPayloadError extends Error {
165
+ /**
166
+ * Creates an instance of DeployableMissingPayloadError.
167
+ *
168
+ * @constructor
169
+ */
170
+ constructor() {
171
+ super(
172
+ 'Expected a valid payload to be available either on Deployable or as argument to deploy.',
173
+ );
174
+ }
175
+ }
176
+
177
+ /**
178
+ * This error is thrown when we receive a transaction receipt for a contract deployment without a contract address on it.
179
+ *
180
+ * @export
181
+ * @class NoContractAddressUponReceiptError
182
+ * @typedef {NoContractAddressUponReceiptError}
183
+ * @extends {Error}
184
+ */
185
+ export class NoContractAddressUponReceiptError extends Error {
186
+ /**
187
+ * The raw receipt we receive from [waitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
188
+ *
189
+ * @public
190
+ * @readonly
191
+ * @type {WaitForTransactionReceiptReturnType}
192
+ */
193
+ public readonly receipt: WaitForTransactionReceiptReturnType;
194
+ /**
195
+ * Creates an instance of NoContractAddressUponReceiptError.
196
+ *
197
+ * @constructor
198
+ * @param {WaitForTransactionReceiptReturnType} receipt
199
+ */
200
+ constructor(receipt: WaitForTransactionReceiptReturnType) {
201
+ super(`Expected a contract address to exist on receipt.`, {
202
+ cause: receipt,
203
+ });
204
+ this.receipt = receipt;
205
+ }
206
+ }
207
+
208
+ /**
209
+ * This error is thrown when a target address was provided that doesn't match any supported interface for the given registry type.
210
+ * For example, if you try to do `incentiveFromAddress()` with the address of a deployed `SimpleBudget`
211
+ *
212
+ * @export
213
+ * @class InvalidComponentInterfaceError
214
+ * @typedef {InvalidComponentInterfaceError}
215
+ * @extends {Error}
216
+ */
217
+ export class InvalidComponentInterfaceError extends Error {
218
+ /**
219
+ * Expected interface hashes.
220
+ *
221
+ * @public
222
+ * @readonly
223
+ * @type {Hex[]}
224
+ */
225
+ public readonly expected: Hex[] = [];
226
+ /**
227
+ * The actual interface hash.
228
+ *
229
+ * @public
230
+ * @readonly
231
+ * @type {Hex}
232
+ */
233
+ public readonly received: Hex = zeroHash;
234
+
235
+ /**
236
+ * Creates an instance of InvalidComponentInterfaceError.
237
+ *
238
+ * @constructor
239
+ * @param {Hex[]} expected
240
+ * @param {Hex} received
241
+ */
242
+ constructor(expected: Hex[], received: Hex) {
243
+ super(`Address provided does not match any expected protocol interface`, {
244
+ cause: { expected, received },
245
+ });
246
+ this.expected = expected;
247
+ this.received = received;
248
+ }
249
+ }
250
+
251
+ /**
252
+ * This error is thrown when attempting a Budget transfer and arguments aren't of the type `FungibleTransferPayload` or `ERC1155TransferPayload`
253
+ *
254
+ * @see {@link FungibleTransferPayload}
255
+ * @see {@link ERC1155TransferPayload}
256
+ * @export
257
+ * @class UnknownTransferPayloadSupplied
258
+ * @typedef {UnknownTransferPayloadSupplied}
259
+ * @extends {Error}
260
+ */
261
+ export class UnknownTransferPayloadSupplied extends Error {
262
+ /**
263
+ * The given payload that does not conform to the correct payload shape.
264
+ *
265
+ * @type {unknown}
266
+ */
267
+ received: unknown;
268
+ /**
269
+ * Creates an instance of UnknownTransferPayloadSupplied.
270
+ *
271
+ * @constructor
272
+ * @param {unknown} received
273
+ */
274
+ constructor(received: unknown) {
275
+ super(
276
+ `Did not provide a valid FungibleTransferPayload or ERC1155 transfer payload.`,
277
+ { cause: received },
278
+ );
279
+ this.received = received;
280
+ }
281
+ }
282
+
283
+ /**
284
+ * This error is thrown during Boost creation when the budget doesn't authorize the Boost Core address.
285
+ *
286
+ * @export
287
+ * @class BudgetMustAuthorizeBoostCore
288
+ * @typedef {BudgetMustAuthorizeBoostCore}
289
+ * @extends {Error}
290
+ */
291
+ export class BudgetMustAuthorizeBoostCore extends Error {
292
+ /**
293
+ * Creates an instance of BudgetMustAuthorizeBoostCore.
294
+ *
295
+ * @constructor
296
+ * @param {string} boostCoreAddress
297
+ */
298
+ constructor(boostCoreAddress: string) {
299
+ super(
300
+ `Budget needs to explicitly authorize ${boostCoreAddress}. You can retrieve this value from BoostCore.address`,
301
+ );
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Because this contract is a base implementation, it should not be initialized through the constructor. Instead, it should be cloned and initialized using the {@link BoostRegistry}
307
+ *
308
+ * @export
309
+ * @class MustInitializeBudgetError
310
+ * @typedef {MustInitializeBudgetError}
311
+ * @extends {Error}
312
+ */
313
+ export class MustInitializeBudgetError extends Error {
314
+ /**
315
+ * Creates an instance of MustInitializeBudgetError.
316
+ */
317
+ constructor() {
318
+ super(`Budgets must be preinitialized before being used with a new Boost`);
319
+ }
320
+ }
321
+
322
+ /**
323
+ * The error is thrown when trying to reuse an existing deployed Incentive that isn't a base implementation.
324
+ * The protocol doesn't allow this.
325
+ *
326
+ * @export
327
+ * @class IncentiveNotCloneableError
328
+ * @typedef {IncentiveNotCloneableError}
329
+ * @extends {Error}
330
+ */
331
+ export class IncentiveNotCloneableError extends Error {
332
+ /**
333
+ * Creates an instance of IncentiveNotCloneableError.
334
+ *
335
+ * @constructor
336
+ * @param {Incentive} incentive
337
+ */
338
+ constructor(incentive: Incentive) {
339
+ super(`Incentive not cloneable: ${incentive.constructor.name}`);
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Thrown when encoding an EventAction payload and no action steps are provided
345
+ *
346
+ * @export
347
+ * @class NoEventActionStepsProvidedError
348
+ * @typedef {NoEventActionStepsProvidedError}
349
+ * @extends {Error}
350
+ */
351
+ export class NoEventActionStepsProvidedError extends Error {
352
+ /**
353
+ * Creates an instance of NoEventActionStepsProvidedError.
354
+ *
355
+ * @constructor
356
+ */
357
+ constructor() {
358
+ super('Must supply at least one action step');
359
+ }
360
+ }
361
+
362
+ /**
363
+ * Thrown when encoding an EventAction payload and > 4 steps are provided
364
+ *
365
+ * @export
366
+ * @class TooManyEventActionStepsProvidedError
367
+ * @typedef {TooManyEventActionStepsProvidedError}
368
+ * @extends {Error}
369
+ */
370
+ export class TooManyEventActionStepsProvidedError extends Error {
371
+ /**
372
+ * Creates an instance of TooManyEventActionStepsProvidedError.
373
+ *
374
+ * @constructor
375
+ */
376
+ constructor() {
377
+ super(
378
+ 'Cannot supply more than 4 action steps with current protocol version',
379
+ );
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Event action validation context to help debug other validation errors
385
+ *
386
+ * @interface EventActionValidationMeta
387
+ * @typedef {EventActionValidationMeta}
388
+ */
389
+ interface EventActionValidationMeta {
390
+ /**
391
+ * The viem log being validated against
392
+ *
393
+ * @type {Log}
394
+ */
395
+ log: Log;
396
+ /**
397
+ * The value pulled off the log being validated against
398
+ *
399
+ * @type {*}
400
+ * biome-ignore lint/suspicious/noExplicitAny: this can be a few different types based on what the log emits
401
+ */
402
+ fieldValue: any;
403
+ /**
404
+ * The criteria being used to compare during validation
405
+ *
406
+ * @type {Criteria}
407
+ */
408
+ criteria: Criteria;
409
+ }
410
+
411
+ /**
412
+ * The base error thrown during event action validation extended by more specific validation errors.
413
+ * Instantiated with relevent context data for more in depth debugging.
414
+ *
415
+ * @export
416
+ * @class EventActionValidationError
417
+ * @typedef {EventActionValidationError}
418
+ * @extends {Error}
419
+ */
420
+ export class EventActionValidationError extends Error {
421
+ /**
422
+ * The viem log being validated against
423
+ *
424
+ * @type {Log}
425
+ */
426
+ log: Log;
427
+ /**
428
+ * The value pulled off the log being validated against
429
+ *
430
+ * @type {*}
431
+ * biome-ignore lint/suspicious/noExplicitAny: this can be a few different types based on what the log emits
432
+ */
433
+ fieldValue: any;
434
+ /**
435
+ * The criteria being used to compare during validation
436
+ *
437
+ * @type {Criteria}
438
+ */
439
+ criteria: Criteria;
440
+ /**
441
+ * Creates an instance of EventActionValidationError.
442
+ *
443
+ * @constructor
444
+ * @param {string} message
445
+ * @param {EventActionValidationMeta} param0
446
+ * @param {*} param0.fieldValue
447
+ * @param {Criteria} param0.criteria
448
+ * @param {Log} param0.log
449
+ */
450
+ constructor(
451
+ message: string,
452
+ { fieldValue, criteria, log }: EventActionValidationMeta,
453
+ ) {
454
+ super(message);
455
+ this.fieldValue = fieldValue;
456
+ this.criteria = criteria;
457
+ this.log = log;
458
+ }
459
+ }
460
+
461
+ /**
462
+ * Thrown when field value on log is undefined
463
+ *
464
+ * @export
465
+ * @class FieldValueUndefinedError
466
+ * @typedef {FieldValueUndefinedError}
467
+ * @extends {EventActionValidationError}
468
+ */
469
+ export class FieldValueUndefinedError extends EventActionValidationError {
470
+ /**
471
+ * Creates an instance of FieldValueUndefinedError.
472
+ *
473
+ * @constructor
474
+ * @param {EventActionValidationMeta} metadata
475
+ */
476
+ constructor(metadata: EventActionValidationMeta) {
477
+ super('Field value is undefined', metadata);
478
+ }
479
+ }
480
+
481
+ /**
482
+ * Thrown when a filter type is using a numerical operator but field type is not numerical
483
+ *
484
+ * @export
485
+ * @class InvalidNumericalCriteriaError
486
+ * @typedef {InvalidNumericalCriteriaError}
487
+ * @extends {EventActionValidationError}
488
+ */
489
+ export class InvalidNumericalCriteriaError extends EventActionValidationError {
490
+ /**
491
+ * Creates an instance of InvalidNumericalCriteria.
492
+ *
493
+ * @constructor
494
+ * @param {EventActionValidationMeta} metadata
495
+ */
496
+ constructor(metadata: EventActionValidationMeta) {
497
+ super(
498
+ 'Numerical comparisons cannot be used with non-numerical criteria',
499
+ metadata,
500
+ );
501
+ }
502
+ }
503
+
504
+ /**
505
+ * Thrown when an the log's field value is being compared a field type that isn't bytes or string during event action validation
506
+ *
507
+ * @export
508
+ * @class FieldValueNotComparableError
509
+ * @typedef {FieldValueNotComparableError}
510
+ * @extends {EventActionValidationError}
511
+ */
512
+ export class FieldValueNotComparableError extends EventActionValidationError {
513
+ /**
514
+ * Creates an instance of FieldValueNotComparableError.
515
+ *
516
+ * @constructor
517
+ * @param {EventActionValidationMeta} metadata
518
+ */
519
+ constructor(metadata: EventActionValidationMeta) {
520
+ super('Filter can only be used with bytes or string field type', metadata);
521
+ }
522
+ }
523
+
524
+ /**
525
+ * Thrown when an invalid filter type enum was provided event action validation.
526
+ *
527
+ * @export
528
+ * @class UnrecognizedFilterTypeError
529
+ * @typedef {UnrecognizedFilterTypeError}
530
+ * @extends {EventActionValidationError}
531
+ */
532
+ export class UnrecognizedFilterTypeError extends EventActionValidationError {
533
+ /**
534
+ * Creates an instance of UnrecognizedFilterTypeError.
535
+ *
536
+ * @constructor
537
+ * @param {EventActionValidationMeta} metadata
538
+ */
539
+ constructor(metadata: EventActionValidationMeta) {
540
+ super('Invalid FilterType provided', metadata);
541
+ }
542
+ }
@@ -0,0 +1,40 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import * as SDK from './index';
3
+
4
+ describe('sdk exports', () => {
5
+ test(`should export all public API`, () => {
6
+ expect(SDK.BoostRegistry).toBeDefined();
7
+ expect(SDK.BoostCore).toBeDefined();
8
+ expect(SDK.Boost).toBeDefined();
9
+
10
+ // interfaces
11
+ expect(SDK.PassthroughAuth).toBeDefined();
12
+ // expect(SDK.ContractAction).toBeDefined();
13
+ // expect(SDK.ERC721MintAction).toBeDefined();
14
+ expect(SDK.SimpleAllowList).toBeDefined();
15
+ expect(SDK.SimpleDenyList).toBeDefined();
16
+ expect(SDK.ManagedBudget).toBeDefined();
17
+ // expect(SDK.SimpleBudget).toBeDefined();
18
+ // expect(SDK.VestingBudget).toBeDefined();
19
+ expect(SDK.AllowListIncentive).toBeDefined();
20
+ expect(SDK.CGDAIncentive).toBeDefined();
21
+ expect(SDK.ERC20Incentive).toBeDefined();
22
+ // expect(SDK.ERC1155Incentive).toBeDefined();
23
+ expect(SDK.PointsIncentive).toBeDefined();
24
+ expect(SDK.SignerValidator).toBeDefined();
25
+
26
+ // errors
27
+ expect(SDK.BoostCoreNoIdentifierEmitted).toBeDefined();
28
+ expect(SDK.ContractAddressRequiredError).toBeDefined();
29
+ expect(SDK.DeployableAlreadyDeployedError).toBeDefined();
30
+ expect(SDK.DeployableBuildParametersUnspecifiedError).toBeDefined();
31
+ expect(SDK.DeployableUnknownOwnerProvidedError).toBeDefined();
32
+ expect(SDK.DeployableWagmiConfigurationRequiredError).toBeDefined();
33
+ expect(SDK.DeployableMissingPayloadError).toBeDefined();
34
+ expect(SDK.NoContractAddressUponReceiptError).toBeDefined();
35
+ expect(SDK.InvalidComponentInterfaceError).toBeDefined();
36
+ expect(SDK.UnknownTransferPayloadSupplied).toBeDefined();
37
+ expect(SDK.BudgetMustAuthorizeBoostCore).toBeDefined();
38
+ expect(SDK.IncentiveNotCloneableError).toBeDefined();
39
+ });
40
+ });