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