@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.21
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 +14 -12
- package/dist/Actions/Action.js.map +1 -0
- package/dist/Actions/ContractAction.d.ts +57 -14
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +50 -23
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +2 -1
- package/dist/Actions/EventAction.cjs.map +1 -0
- package/dist/Actions/EventAction.d.ts +405 -36
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -209
- 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 +6 -5
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +46 -22
- package/dist/AllowLists/AllowList.js.map +1 -0
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +2 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
- package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +76 -76
- package/dist/AllowLists/SimpleAllowList.js.map +1 -0
- package/dist/AllowLists/SimpleDenyList.cjs +2 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +12 -200
- 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 +2 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -0
- package/dist/Auth/PassthroughAuth.js +5 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -0
- package/dist/Boost.cjs +2 -1
- package/dist/Boost.cjs.map +1 -0
- package/dist/Boost.d.ts +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +138 -5
- package/dist/Boost.js.map +1 -0
- package/dist/BoostCore-DolmDuXW.cjs +3 -0
- package/dist/BoostCore-DolmDuXW.cjs.map +1 -0
- package/dist/BoostCore-Z97KVu4V.js +1448 -0
- package/dist/BoostCore-Z97KVu4V.js.map +1 -0
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -0
- package/dist/BoostCore.d.ts +788 -79
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +30 -1103
- package/dist/BoostCore.js.map +1 -0
- package/dist/BoostRegistry.cjs +2 -1
- package/dist/BoostRegistry.cjs.map +1 -0
- package/dist/BoostRegistry.d.ts +95 -26
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +183 -89
- 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 +15 -13
- package/dist/Budgets/Budget.js.map +1 -0
- package/dist/Budgets/ManagedBudget.cjs +2 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -0
- package/dist/Budgets/ManagedBudget.d.ts +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +91 -291
- package/dist/Budgets/ManagedBudget.js.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +2 -1
- package/dist/Deployable/Contract.cjs.map +1 -0
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +7 -8
- 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.d.ts +9 -3
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +10 -5
- package/dist/Deployable/Deployable.js.map +1 -0
- package/dist/Deployable/DeployableTarget.cjs +2 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -0
- package/dist/Deployable/DeployableTarget.d.ts +16 -15
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +49 -42
- package/dist/Deployable/DeployableTarget.js.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/EventAction-CBKzuNoN.cjs +2 -0
- package/dist/EventAction-CBKzuNoN.cjs.map +1 -0
- package/dist/EventAction-DWuuc_Qy.js +1528 -0
- package/dist/EventAction-DWuuc_Qy.js.map +1 -0
- package/dist/Incentive-BxzEtN26.js +298 -0
- package/dist/Incentive-BxzEtN26.js.map +1 -0
- package/dist/Incentive-CrF3-ayL.cjs +2 -0
- package/dist/Incentive-CrF3-ayL.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +2 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.d.ts +65 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +52 -36
- package/dist/Incentives/AllowListIncentive.js.map +1 -0
- package/dist/Incentives/CGDAIncentive.cjs +2 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
- package/dist/Incentives/CGDAIncentive.d.ts +315 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +64 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -0
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +2 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
- package/dist/Incentives/ERC20Incentive.d.ts +270 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +69 -46
- package/dist/Incentives/ERC20Incentive.js.map +1 -0
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +338 -421
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +262 -32
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +2 -1
- package/dist/Incentives/Incentive.cjs.map +1 -0
- package/dist/Incentives/Incentive.d.ts +5 -8
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +17 -278
- package/dist/Incentives/Incentive.js.map +1 -0
- package/dist/Incentives/PointsIncentive.cjs +2 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -0
- package/dist/Incentives/PointsIncentive.d.ts +81 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +57 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +2 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -0
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +165 -36
- 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 +2 -2
- package/dist/Validators/Validator.d.ts.map +1 -1
- package/dist/Validators/Validator.js +10 -8
- package/dist/Validators/Validator.js.map +1 -0
- package/dist/claiming.cjs +2 -0
- package/dist/claiming.cjs.map +1 -0
- package/dist/claiming.d.ts +43 -0
- package/dist/claiming.d.ts.map +1 -0
- package/dist/claiming.js +17 -0
- package/dist/claiming.js.map +1 -0
- package/dist/componentInterfaces-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +2 -1
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +421 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +297 -39
- package/dist/errors.js.map +1 -0
- package/dist/{generated-x_abr3Yv.js → generated-CKt2yCQd.js} +3143 -3002
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -1353
- package/dist/index.js.map +1 -0
- package/dist/transfers.cjs +2 -0
- package/dist/transfers.cjs.map +1 -0
- package/dist/transfers.d.ts +198 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +84 -0
- package/dist/transfers.js.map +1 -0
- package/dist/utils.cjs +2 -1
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +26 -1350
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -636
- package/dist/utils.js.map +1 -0
- package/package.json +37 -11
- package/src/Actions/Action.test.ts +79 -0
- package/src/Actions/Action.ts +61 -0
- package/src/Actions/ContractAction.test.ts +197 -0
- package/src/Actions/ContractAction.ts +300 -0
- package/src/Actions/ERC721MintAction.test.ts +112 -0
- package/src/Actions/ERC721MintAction.ts +291 -0
- package/src/Actions/EventAction.test.ts +787 -0
- package/src/Actions/EventAction.ts +1218 -0
- package/src/AllowLists/AllowList.test.ts +64 -0
- package/src/AllowLists/AllowList.ts +62 -0
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +52 -0
- package/src/AllowLists/SimpleAllowList.ts +262 -0
- package/src/AllowLists/SimpleDenyList.test.ts +52 -0
- package/src/AllowLists/SimpleDenyList.ts +250 -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 +287 -0
- package/src/BoostCore.test.ts +894 -0
- package/src/BoostCore.ts +1438 -0
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +588 -0
- package/src/Budgets/Budget.test.ts +27 -0
- package/src/Budgets/Budget.ts +60 -0
- package/src/Budgets/ManagedBudget.test.ts +217 -0
- package/src/Budgets/ManagedBudget.ts +534 -0
- package/src/Budgets/VestingBudget.test.ts +123 -0
- package/src/Budgets/VestingBudget.ts +530 -0
- package/src/Deployable/Contract.ts +228 -0
- package/src/Deployable/Deployable.ts +250 -0
- package/src/Deployable/DeployableTarget.ts +234 -0
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +143 -0
- package/src/Incentives/AllowListIncentive.ts +336 -0
- package/src/Incentives/CGDAIncentive.test.ts +135 -0
- package/src/Incentives/CGDAIncentive.ts +476 -0
- package/src/Incentives/ERC1155Incentive.test.ts +87 -0
- package/src/Incentives/ERC1155Incentive.ts +465 -0
- package/src/Incentives/ERC20Incentive.test.ts +133 -0
- package/src/Incentives/ERC20Incentive.ts +490 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +139 -0
- package/src/Incentives/ERC20VariableIncentive.ts +428 -0
- package/src/Incentives/Incentive.test.ts +95 -0
- package/src/Incentives/Incentive.ts +86 -0
- package/src/Incentives/PointsIncentive.test.ts +138 -0
- package/src/Incentives/PointsIncentive.ts +367 -0
- package/src/Validators/SignerValidator.test.ts +159 -0
- package/src/Validators/SignerValidator.ts +683 -0
- package/src/Validators/Validator.test.ts +21 -0
- package/src/Validators/Validator.ts +55 -0
- package/src/claiming.ts +56 -0
- package/src/errors.ts +866 -0
- package/src/index.test.ts +122 -0
- package/src/index.ts +58 -0
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +44 -0
- package/src/utils.ts +247 -0
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/generated-BaaleHW-.cjs +0 -2
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readSimpleAllowListOwner,
|
|
3
|
+
readSimpleDenyListIsAllowed,
|
|
4
|
+
simpleDenyListAbi,
|
|
5
|
+
simulateSimpleDenyListSetDenied,
|
|
6
|
+
writeSimpleDenyListSetDenied,
|
|
7
|
+
} from '@boostxyz/evm';
|
|
8
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleDenyList.sol/SimpleDenyList.json';
|
|
9
|
+
import { getAccount } from '@wagmi/core';
|
|
10
|
+
import {
|
|
11
|
+
type Address,
|
|
12
|
+
type ContractEventName,
|
|
13
|
+
type Hex,
|
|
14
|
+
encodeAbiParameters,
|
|
15
|
+
zeroAddress,
|
|
16
|
+
zeroHash,
|
|
17
|
+
} from 'viem';
|
|
18
|
+
import { SimpleDenyList as SimpleDenyListBases } from '../../dist/deployments.json';
|
|
19
|
+
import type {
|
|
20
|
+
DeployableOptions,
|
|
21
|
+
GenericDeployableParams,
|
|
22
|
+
} from '../Deployable/Deployable';
|
|
23
|
+
import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
|
|
24
|
+
import { DeployableUnknownOwnerProvidedError } from '../errors';
|
|
25
|
+
import {
|
|
26
|
+
type GenericLog,
|
|
27
|
+
type ReadParams,
|
|
28
|
+
RegistryType,
|
|
29
|
+
type WriteParams,
|
|
30
|
+
} from '../utils';
|
|
31
|
+
|
|
32
|
+
export { simpleDenyListAbi };
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Object representation of a {@link SimpleDenyList} initialization payload.
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @interface SimpleDenyListPayload
|
|
39
|
+
* @typedef {SimpleDenyListPayload}
|
|
40
|
+
*/
|
|
41
|
+
export interface SimpleDenyListPayload {
|
|
42
|
+
/**
|
|
43
|
+
* The allow list's owner
|
|
44
|
+
*
|
|
45
|
+
* @type {Address}
|
|
46
|
+
*/
|
|
47
|
+
owner: Address;
|
|
48
|
+
/**
|
|
49
|
+
* List of denied addresses.
|
|
50
|
+
*
|
|
51
|
+
* @type {Address[]}
|
|
52
|
+
*/
|
|
53
|
+
denied: Address[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A generic `viem.Log` event with support for `SimpleDenyList` event types.
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
* @typedef {SimpleDenyListLog}
|
|
61
|
+
* @template {ContractEventName<typeof simpleDenyListAbi>} [event=ContractEventName<
|
|
62
|
+
* typeof simpleDenyListAbi
|
|
63
|
+
* >]
|
|
64
|
+
*/
|
|
65
|
+
export type SimpleDenyListLog<
|
|
66
|
+
event extends ContractEventName<typeof simpleDenyListAbi> = ContractEventName<
|
|
67
|
+
typeof simpleDenyListAbi
|
|
68
|
+
>,
|
|
69
|
+
> = GenericLog<typeof simpleDenyListAbi, event>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A simple implementation of an AllowList that implicitly allows all addresses except those explicitly added to the deny list
|
|
73
|
+
*
|
|
74
|
+
* @export
|
|
75
|
+
* @class SimpleDenyList
|
|
76
|
+
* @typedef {SimpleDenyList}
|
|
77
|
+
* @extends {DeployableTargetWithRBAC<SimpleDenyListPayload>}
|
|
78
|
+
*/
|
|
79
|
+
export class SimpleDenyList<
|
|
80
|
+
Payload = SimpleDenyListPayload,
|
|
81
|
+
> extends DeployableTargetWithRBAC<
|
|
82
|
+
Payload | undefined,
|
|
83
|
+
typeof simpleDenyListAbi
|
|
84
|
+
> {
|
|
85
|
+
public override readonly abi = simpleDenyListAbi;
|
|
86
|
+
/**
|
|
87
|
+
* @inheritdoc
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
* @static
|
|
91
|
+
* @type {Record<number, Address>}
|
|
92
|
+
*/
|
|
93
|
+
public static override bases: Record<number, Address> = {
|
|
94
|
+
...(SimpleDenyListBases as Record<number, Address>),
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* @inheritdoc
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
* @static
|
|
101
|
+
* @type {RegistryType}
|
|
102
|
+
*/
|
|
103
|
+
public static override registryType: RegistryType = RegistryType.ALLOW_LIST;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Retrieves the owner
|
|
107
|
+
*
|
|
108
|
+
* @public
|
|
109
|
+
* @async
|
|
110
|
+
* @param {?ReadParams} [params]
|
|
111
|
+
* @returns {Promise<Address>} - The address of the owner
|
|
112
|
+
*/
|
|
113
|
+
public async owner(
|
|
114
|
+
params?: ReadParams<typeof simpleDenyListAbi, 'owner'>,
|
|
115
|
+
): Promise<Address> {
|
|
116
|
+
return await readSimpleAllowListOwner(this._config, {
|
|
117
|
+
...this.optionallyAttachAccount(),
|
|
118
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
119
|
+
...(params as any),
|
|
120
|
+
address: this.assertValidAddress(),
|
|
121
|
+
args: [],
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Check if a user is authorized (i.e. not denied)
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @async
|
|
130
|
+
* @param {Address} address - The address of the user
|
|
131
|
+
* @param {?ReadParams} [params]
|
|
132
|
+
* @returns {Promise<boolean>} - True if the user is authorized
|
|
133
|
+
*/
|
|
134
|
+
public async isAllowed(
|
|
135
|
+
address: Address,
|
|
136
|
+
params?: ReadParams<typeof simpleDenyListAbi, 'isAllowed'>,
|
|
137
|
+
): Promise<boolean> {
|
|
138
|
+
return await readSimpleDenyListIsAllowed(this._config, {
|
|
139
|
+
address: this.assertValidAddress(),
|
|
140
|
+
args: [address, zeroHash],
|
|
141
|
+
...this.optionallyAttachAccount(),
|
|
142
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
143
|
+
...(params as any),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Set the denied status of a user. The length of the `users_` and `denied_` arrays must be the same. This function can only be called by the owner
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
* @async
|
|
152
|
+
* @param {Address[]} addresses - The list of users to update
|
|
153
|
+
* @param {boolean[]} allowed - The denied status of each user
|
|
154
|
+
* @param {?WriteParams} [params]
|
|
155
|
+
* @returns {Promise<void>}
|
|
156
|
+
*/
|
|
157
|
+
public async setDenied(
|
|
158
|
+
addresses: Address[],
|
|
159
|
+
allowed: boolean[],
|
|
160
|
+
params?: WriteParams<typeof simpleDenyListAbi, 'setDenied'>,
|
|
161
|
+
) {
|
|
162
|
+
return await this.awaitResult(
|
|
163
|
+
this.setDeniedRaw(addresses, allowed, params),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Set the denied status of a user. The length of the `users_` and `denied_` arrays must be the same. This function can only be called by the owner
|
|
169
|
+
*
|
|
170
|
+
* @public
|
|
171
|
+
* @async
|
|
172
|
+
* @param {Address[]} addresses - The list of users to update
|
|
173
|
+
* @param {boolean[]} allowed - The denied status of each user
|
|
174
|
+
* @param {?WriteParams} [params]
|
|
175
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
176
|
+
*/
|
|
177
|
+
public async setDeniedRaw(
|
|
178
|
+
addresses: Address[],
|
|
179
|
+
allowed: boolean[],
|
|
180
|
+
params?: WriteParams<typeof simpleDenyListAbi, 'setDenied'>,
|
|
181
|
+
) {
|
|
182
|
+
const { request, result } = await simulateSimpleDenyListSetDenied(
|
|
183
|
+
this._config,
|
|
184
|
+
{
|
|
185
|
+
address: this.assertValidAddress(),
|
|
186
|
+
args: [addresses, allowed],
|
|
187
|
+
...this.optionallyAttachAccount(),
|
|
188
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
189
|
+
...(params as any),
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
const hash = await writeSimpleDenyListSetDenied(this._config, request);
|
|
193
|
+
return { hash, result };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @inheritdoc
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
* @param {?SimpleDenyListPayload} [_payload]
|
|
201
|
+
* @param {?DeployableOptions} [_options]
|
|
202
|
+
* @returns {GenericDeployableParams}
|
|
203
|
+
*/
|
|
204
|
+
public override buildParameters(
|
|
205
|
+
_payload?: Payload,
|
|
206
|
+
_options?: DeployableOptions,
|
|
207
|
+
): GenericDeployableParams {
|
|
208
|
+
const [p, options] = this.validateDeploymentConfig(_payload, _options);
|
|
209
|
+
const payload = p as SimpleDenyListPayload;
|
|
210
|
+
if (!payload.owner || payload.owner === zeroAddress) {
|
|
211
|
+
const owner = options.account
|
|
212
|
+
? options.account.address
|
|
213
|
+
: options.config
|
|
214
|
+
? getAccount(options.config).address
|
|
215
|
+
: this._account?.address;
|
|
216
|
+
if (owner) {
|
|
217
|
+
payload.owner = owner;
|
|
218
|
+
} else {
|
|
219
|
+
throw new DeployableUnknownOwnerProvidedError();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
abi: simpleDenyListAbi,
|
|
224
|
+
bytecode: bytecode as Hex,
|
|
225
|
+
args: [prepareSimpleDenyListPayload(payload)],
|
|
226
|
+
...this.optionallyAttachAccount(options.account),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Given a {@link SimpleDenyListPayload}, properly encode the initialization payload.
|
|
233
|
+
*
|
|
234
|
+
* @param {SimpleDenyListPayload} param0
|
|
235
|
+
* @param {Address} param0.owner - The allow list's owner
|
|
236
|
+
* @param {Address[]} param0.denied - List of denied addresses.
|
|
237
|
+
* @returns {Hex}
|
|
238
|
+
*/
|
|
239
|
+
export function prepareSimpleDenyListPayload({
|
|
240
|
+
owner,
|
|
241
|
+
denied,
|
|
242
|
+
}: SimpleDenyListPayload) {
|
|
243
|
+
return encodeAbiParameters(
|
|
244
|
+
[
|
|
245
|
+
{ type: 'address', name: 'owner' },
|
|
246
|
+
{ type: 'address[]', name: 'denied' },
|
|
247
|
+
],
|
|
248
|
+
[owner, denied],
|
|
249
|
+
);
|
|
250
|
+
}
|
package/src/Auth/Auth.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { zeroAddress } from 'viem';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { defaultOptions } from '@boostxyz/test/helpers';
|
|
4
|
+
import { PassthroughAuth } from './PassthroughAuth';
|
|
5
|
+
|
|
6
|
+
describe('PassthroughAuth', () => {
|
|
7
|
+
test('can successfully be deployed', async () => {
|
|
8
|
+
const auth = new PassthroughAuth(defaultOptions);
|
|
9
|
+
await auth.deploy();
|
|
10
|
+
expect(await auth.isAuthorized(zeroAddress)).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
passthroughAuthAbi,
|
|
3
|
+
readPassthroughAuthIsAuthorized,
|
|
4
|
+
} from '@boostxyz/evm';
|
|
5
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/auth/PassthroughAuth.sol/PassthroughAuth.json';
|
|
6
|
+
import type { Address, ContractEventName, Hex } from 'viem';
|
|
7
|
+
import {
|
|
8
|
+
Deployable,
|
|
9
|
+
type DeployableOptions,
|
|
10
|
+
type GenericDeployableParams,
|
|
11
|
+
} from '../Deployable/Deployable';
|
|
12
|
+
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
13
|
+
import type { GenericLog, ReadParams } from '../utils';
|
|
14
|
+
|
|
15
|
+
export { passthroughAuthAbi };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A generic `viem.Log` event with support for `PassthroughAuth` event types.
|
|
19
|
+
*
|
|
20
|
+
* @export
|
|
21
|
+
* @typedef {PassthroughAuthLog}
|
|
22
|
+
* @template {ContractEventName<
|
|
23
|
+
* typeof passthroughAuthAbi
|
|
24
|
+
* >} [event=ContractEventName<typeof passthroughAuthAbi>]
|
|
25
|
+
*/
|
|
26
|
+
export type PassthroughAuthLog<
|
|
27
|
+
event extends ContractEventName<
|
|
28
|
+
typeof passthroughAuthAbi
|
|
29
|
+
> = ContractEventName<typeof passthroughAuthAbi>,
|
|
30
|
+
> = GenericLog<typeof passthroughAuthAbi, event>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A simple implementation of a Validator that verifies a given signature and checks the recovered address against a set of authorized signers
|
|
34
|
+
*
|
|
35
|
+
* @export
|
|
36
|
+
* @class PassthroughAuth
|
|
37
|
+
* @typedef {PassthroughAuth}
|
|
38
|
+
* @extends {DeployableTarget<PassthroughAuthPayload>}
|
|
39
|
+
*/
|
|
40
|
+
export class PassthroughAuth extends Deployable<
|
|
41
|
+
// biome-ignore lint/suspicious/noExplicitAny: takes no parameters
|
|
42
|
+
any,
|
|
43
|
+
typeof passthroughAuthAbi
|
|
44
|
+
> {
|
|
45
|
+
public override readonly abi = passthroughAuthAbi;
|
|
46
|
+
|
|
47
|
+
public async isAuthorized(
|
|
48
|
+
address: Address,
|
|
49
|
+
params?: ReadParams<typeof passthroughAuthAbi, 'isAuthorized'>,
|
|
50
|
+
) {
|
|
51
|
+
return await readPassthroughAuthIsAuthorized(this._config, {
|
|
52
|
+
address: this.assertValidAddress(),
|
|
53
|
+
args: [address],
|
|
54
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
55
|
+
...(params as any),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @inheritdoc
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @param {?PassthroughAuthPayload} [_payload]
|
|
64
|
+
* @param {?DeployableOptions} [_options]
|
|
65
|
+
* @returns {GenericDeployableParams}
|
|
66
|
+
*/
|
|
67
|
+
public override buildParameters(
|
|
68
|
+
_payload?: never,
|
|
69
|
+
_options?: DeployableOptions,
|
|
70
|
+
): GenericDeployableParams {
|
|
71
|
+
const [_, options] = this.validateDeploymentConfig({}, _options);
|
|
72
|
+
return {
|
|
73
|
+
abi: passthroughAuthAbi,
|
|
74
|
+
bytecode: bytecode as Hex,
|
|
75
|
+
// biome-ignore lint/suspicious/noExplicitAny: <takes no payload>
|
|
76
|
+
args: [] as any,
|
|
77
|
+
...this.optionallyAttachAccount(options.account),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/Boost.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { LibZip } from 'solady';
|
|
2
|
+
import {
|
|
3
|
+
type Address,
|
|
4
|
+
type Hex,
|
|
5
|
+
encodeAbiParameters,
|
|
6
|
+
parseAbiParameters,
|
|
7
|
+
zeroAddress,
|
|
8
|
+
} from 'viem';
|
|
9
|
+
import type { Action } from './Actions/Action';
|
|
10
|
+
import type { AllowList } from './AllowLists/AllowList';
|
|
11
|
+
import type { Budget } from './Budgets/Budget';
|
|
12
|
+
import type { Incentive } from './Incentives/Incentive';
|
|
13
|
+
import type { Validator } from './Validators/Validator';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Interface representing a `BoostLib.Boost` on-chain struct
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
* @interface RawBoost
|
|
20
|
+
* @typedef {RawBoost}
|
|
21
|
+
*/
|
|
22
|
+
export interface RawBoost {
|
|
23
|
+
action: Address;
|
|
24
|
+
validator: Address;
|
|
25
|
+
allowList: Address;
|
|
26
|
+
budget: Address;
|
|
27
|
+
incentives: readonly Address[];
|
|
28
|
+
protocolFee: bigint;
|
|
29
|
+
maxParticipants: bigint;
|
|
30
|
+
owner: Address;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Configuration used to instantiate a `Boost` instance.
|
|
35
|
+
*
|
|
36
|
+
* @export
|
|
37
|
+
* @interface BoostConfig
|
|
38
|
+
* @typedef {BoostConfig}
|
|
39
|
+
*/
|
|
40
|
+
export interface BoostConfig {
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @type {bigint}
|
|
44
|
+
*/
|
|
45
|
+
id: bigint;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @type {Budget}
|
|
49
|
+
*/
|
|
50
|
+
budget: Budget;
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @type {Action}
|
|
54
|
+
*/
|
|
55
|
+
action: Action;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @type {Validator}
|
|
59
|
+
*/
|
|
60
|
+
validator: Validator;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @type {AllowList}
|
|
64
|
+
*/
|
|
65
|
+
allowList: AllowList;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @type {Array<Incentive>}
|
|
69
|
+
*/
|
|
70
|
+
incentives: Array<Incentive>;
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @type {?bigint}
|
|
74
|
+
*/
|
|
75
|
+
protocolFee?: bigint;
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @type {?bigint}
|
|
79
|
+
*/
|
|
80
|
+
maxParticipants?: bigint;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @type {?Address}
|
|
84
|
+
*/
|
|
85
|
+
owner?: Address;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A struct representing a single Boost. Typically you would not construct this directly, rather get an instance from `BoostCore.createBoost` or `BoostCore.getBoost`
|
|
90
|
+
*
|
|
91
|
+
* @export
|
|
92
|
+
* @class Boost
|
|
93
|
+
* @typedef {Boost}
|
|
94
|
+
*/
|
|
95
|
+
export class Boost {
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @readonly
|
|
99
|
+
* @type {bigint}
|
|
100
|
+
*/
|
|
101
|
+
readonly id: bigint;
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @readonly
|
|
105
|
+
* @type {Budget}
|
|
106
|
+
*/
|
|
107
|
+
readonly budget: Budget;
|
|
108
|
+
/**
|
|
109
|
+
*
|
|
110
|
+
* @readonly
|
|
111
|
+
* @type {Action}
|
|
112
|
+
*/
|
|
113
|
+
readonly action: Action;
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @readonly
|
|
117
|
+
* @type {Validator}
|
|
118
|
+
*/
|
|
119
|
+
readonly validator: Validator;
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @readonly
|
|
123
|
+
* @type {AllowList}
|
|
124
|
+
*/
|
|
125
|
+
readonly allowList: AllowList;
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
* @readonly
|
|
129
|
+
* @type {Array<Incentive>}
|
|
130
|
+
*/
|
|
131
|
+
readonly incentives: Array<Incentive>;
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
* @readonly
|
|
135
|
+
* @type {bigint}
|
|
136
|
+
*/
|
|
137
|
+
readonly protocolFee: bigint;
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @readonly
|
|
141
|
+
* @type {bigint}
|
|
142
|
+
*/
|
|
143
|
+
readonly maxParticipants: bigint;
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @readonly
|
|
147
|
+
* @type {Address}
|
|
148
|
+
*/
|
|
149
|
+
readonly owner: Address;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Creates an instance of Boost.
|
|
153
|
+
*
|
|
154
|
+
* @constructor
|
|
155
|
+
* @param {BoostConfig} config
|
|
156
|
+
*/
|
|
157
|
+
constructor(config: BoostConfig) {
|
|
158
|
+
this.id = config.id;
|
|
159
|
+
this.budget = config.budget;
|
|
160
|
+
this.action = config.action;
|
|
161
|
+
this.validator = config.validator;
|
|
162
|
+
this.allowList = config.allowList;
|
|
163
|
+
this.incentives = config.incentives;
|
|
164
|
+
this.protocolFee = config.protocolFee || 0n;
|
|
165
|
+
this.maxParticipants = config.maxParticipants || 0n;
|
|
166
|
+
this.owner = config.owner || zeroAddress;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Object representation of `BoostLib.Target` struct. Used for low level Boost creation operations.
|
|
172
|
+
* This is used to pass the base contract and its initialization parameters in an efficient manner
|
|
173
|
+
*
|
|
174
|
+
* @export
|
|
175
|
+
* @typedef {Target}
|
|
176
|
+
*/
|
|
177
|
+
export type Target = {
|
|
178
|
+
isBase: boolean;
|
|
179
|
+
instance: Address;
|
|
180
|
+
parameters: Hex;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Object representation of `BoostCore.InitPayload` struct.
|
|
185
|
+
*
|
|
186
|
+
* @export
|
|
187
|
+
* @interface BoostPayload
|
|
188
|
+
* @typedef {BoostPayload}
|
|
189
|
+
*/
|
|
190
|
+
export interface BoostPayload {
|
|
191
|
+
/**
|
|
192
|
+
* Address to valid budget.
|
|
193
|
+
*
|
|
194
|
+
* @type {Address}
|
|
195
|
+
*/
|
|
196
|
+
budget: Address;
|
|
197
|
+
/**
|
|
198
|
+
* Target for existing action, or base with initialization payload.
|
|
199
|
+
*
|
|
200
|
+
* @type {Target}
|
|
201
|
+
*/
|
|
202
|
+
action: Target;
|
|
203
|
+
/**
|
|
204
|
+
* Target for existing validator, or base with initialization payload.
|
|
205
|
+
*
|
|
206
|
+
* @type {Target}
|
|
207
|
+
*/
|
|
208
|
+
validator: Target;
|
|
209
|
+
/**
|
|
210
|
+
* Target for existing allowList, or base with initialization payload.
|
|
211
|
+
*
|
|
212
|
+
* @type {Target}
|
|
213
|
+
*/
|
|
214
|
+
allowList: Target;
|
|
215
|
+
/**
|
|
216
|
+
* Targets for new incentives, with initialization payloads.
|
|
217
|
+
*
|
|
218
|
+
* @type {Target[]}
|
|
219
|
+
*/
|
|
220
|
+
incentives: Target[];
|
|
221
|
+
/**
|
|
222
|
+
* The base protocol fee (in bps)
|
|
223
|
+
*
|
|
224
|
+
* @type {?bigint}
|
|
225
|
+
*/
|
|
226
|
+
protocolFee?: bigint;
|
|
227
|
+
/**
|
|
228
|
+
* Optional maximum amount of participants in the Boost.
|
|
229
|
+
*
|
|
230
|
+
* @type {?bigint}
|
|
231
|
+
*/
|
|
232
|
+
maxParticipants?: bigint;
|
|
233
|
+
/**
|
|
234
|
+
* The owner of the Boost.
|
|
235
|
+
*
|
|
236
|
+
* @type {Address}
|
|
237
|
+
*/
|
|
238
|
+
owner: Address;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Given a valid {@link BoostPayload}, properly encode and compress the payload for use with `createBoost`
|
|
243
|
+
*
|
|
244
|
+
* @export
|
|
245
|
+
* @param {BoostPayload} param0
|
|
246
|
+
* @param {Address} param0.budget - Address to valid budget.
|
|
247
|
+
* @param {Target} param0.action - Target for existing action, or base with initialization payload.
|
|
248
|
+
* @param {Target} param0.validator - Target for existing validator, or base with initialization payload.
|
|
249
|
+
* @param {Target} param0.allowList - Target for existing allowList, or base with initialization payload.
|
|
250
|
+
* @param {Target[]} param0.incentives - Targets for new incentives, with initialization payloads.
|
|
251
|
+
* @param {bigint} [param0.protocolFee=0n] - The base protocol fee (in bps)
|
|
252
|
+
* @param {bigint} [param0.maxParticipants=0n] - Optional maximum amount of participants in the Boost.
|
|
253
|
+
* @param {Address} param0.owner - The owner of the Boost.
|
|
254
|
+
* @returns {Hex}
|
|
255
|
+
*/
|
|
256
|
+
export function prepareBoostPayload({
|
|
257
|
+
budget,
|
|
258
|
+
action,
|
|
259
|
+
validator,
|
|
260
|
+
allowList,
|
|
261
|
+
incentives,
|
|
262
|
+
protocolFee = 0n,
|
|
263
|
+
maxParticipants = 0n,
|
|
264
|
+
owner,
|
|
265
|
+
}: BoostPayload): Hex {
|
|
266
|
+
return LibZip.cdCompress(
|
|
267
|
+
encodeAbiParameters(
|
|
268
|
+
parseAbiParameters([
|
|
269
|
+
'BoostPayload payload',
|
|
270
|
+
'struct BoostPayload { address budget; Target action; Target validator; Target allowList; Target[] incentives; uint64 protocolFee; uint256 maxParticipants; address owner; }',
|
|
271
|
+
'struct Target { bool isBase; address instance; bytes parameters; }',
|
|
272
|
+
]),
|
|
273
|
+
[
|
|
274
|
+
{
|
|
275
|
+
budget,
|
|
276
|
+
action,
|
|
277
|
+
validator,
|
|
278
|
+
allowList,
|
|
279
|
+
incentives,
|
|
280
|
+
protocolFee,
|
|
281
|
+
maxParticipants,
|
|
282
|
+
owner,
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
),
|
|
286
|
+
) as Hex;
|
|
287
|
+
}
|