@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.
- package/LICENSE +674 -0
- package/README.md +7 -0
- package/dist/Actions/Action.cjs +2 -0
- package/dist/Actions/Action.cjs.map +1 -0
- package/dist/Actions/Action.d.ts +31 -0
- package/dist/Actions/Action.d.ts.map +1 -0
- package/dist/Actions/Action.js +29 -0
- package/dist/Actions/Action.js.map +1 -0
- package/dist/Actions/ContractAction.d.ts +370 -0
- package/dist/Actions/ContractAction.d.ts.map +1 -0
- package/dist/Actions/ERC721MintAction.d.ts +513 -0
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -0
- package/dist/Actions/EventAction.cjs +2 -0
- package/dist/Actions/EventAction.cjs.map +1 -0
- package/dist/Actions/EventAction.d.ts +694 -0
- package/dist/Actions/EventAction.d.ts.map +1 -0
- package/dist/Actions/EventAction.js +491 -0
- package/dist/Actions/EventAction.js.map +1 -0
- package/dist/AllowLists/AllowList.cjs +2 -0
- package/dist/AllowLists/AllowList.cjs.map +1 -0
- package/dist/AllowLists/AllowList.d.ts +32 -0
- package/dist/AllowLists/AllowList.d.ts.map +1 -0
- package/dist/AllowLists/AllowList.js +30 -0
- package/dist/AllowLists/AllowList.js.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +2 -0
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
- package/dist/AllowLists/SimpleAllowList.d.ts +481 -0
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.js +154 -0
- package/dist/AllowLists/SimpleAllowList.js.map +1 -0
- package/dist/AllowLists/SimpleDenyList.cjs +2 -0
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
- package/dist/AllowLists/SimpleDenyList.d.ts +335 -0
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleDenyList.js +115 -0
- package/dist/AllowLists/SimpleDenyList.js.map +1 -0
- package/dist/Auth/Auth.cjs +2 -0
- package/dist/Auth/Auth.cjs.map +1 -0
- package/dist/Auth/Auth.d.ts +10 -0
- package/dist/Auth/Auth.d.ts.map +1 -0
- package/dist/Auth/Auth.js +5 -0
- package/dist/Auth/Auth.js.map +1 -0
- package/dist/Auth/PassthroughAuth.cjs +2 -0
- package/dist/Auth/PassthroughAuth.cjs.map +1 -0
- package/dist/Auth/PassthroughAuth.d.ts +51 -0
- package/dist/Auth/PassthroughAuth.d.ts.map +1 -0
- package/dist/Auth/PassthroughAuth.js +39 -0
- package/dist/Auth/PassthroughAuth.js.map +1 -0
- package/dist/Boost.cjs +2 -0
- package/dist/Boost.cjs.map +1 -0
- package/dist/Boost.d.ts +234 -0
- package/dist/Boost.d.ts.map +1 -0
- package/dist/Boost.js +162 -0
- package/dist/Boost.js.map +1 -0
- package/dist/BoostCore.cjs +3 -0
- package/dist/BoostCore.cjs.map +1 -0
- package/dist/BoostCore.d.ts +498 -0
- package/dist/BoostCore.d.ts.map +1 -0
- package/dist/BoostCore.js +1153 -0
- package/dist/BoostCore.js.map +1 -0
- package/dist/BoostRegistry.cjs +2 -0
- package/dist/BoostRegistry.cjs.map +1 -0
- package/dist/BoostRegistry.d.ts +243 -0
- package/dist/BoostRegistry.d.ts.map +1 -0
- package/dist/BoostRegistry.js +262 -0
- package/dist/BoostRegistry.js.map +1 -0
- package/dist/Budgets/Budget.cjs +2 -0
- package/dist/Budgets/Budget.cjs.map +1 -0
- package/dist/Budgets/Budget.d.ts +31 -0
- package/dist/Budgets/Budget.d.ts.map +1 -0
- package/dist/Budgets/Budget.js +29 -0
- package/dist/Budgets/Budget.js.map +1 -0
- package/dist/Budgets/ManagedBudget.cjs +2 -0
- package/dist/Budgets/ManagedBudget.cjs.map +1 -0
- package/dist/Budgets/ManagedBudget.d.ts +1103 -0
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -0
- package/dist/Budgets/ManagedBudget.js +516 -0
- package/dist/Budgets/ManagedBudget.js.map +1 -0
- package/dist/Budgets/SimpleBudget.d.ts +824 -0
- package/dist/Budgets/SimpleBudget.d.ts.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +778 -0
- package/dist/Budgets/VestingBudget.d.ts.map +1 -0
- package/dist/Deployable/Contract.cjs +2 -0
- package/dist/Deployable/Contract.cjs.map +1 -0
- package/dist/Deployable/Contract.d.ts +125 -0
- package/dist/Deployable/Contract.d.ts.map +1 -0
- package/dist/Deployable/Contract.js +150 -0
- package/dist/Deployable/Contract.js.map +1 -0
- package/dist/Deployable/Deployable.cjs +2 -0
- package/dist/Deployable/Deployable.cjs.map +1 -0
- package/dist/Deployable/Deployable.d.ts +161 -0
- package/dist/Deployable/Deployable.d.ts.map +1 -0
- package/dist/Deployable/Deployable.js +131 -0
- package/dist/Deployable/Deployable.js.map +1 -0
- package/dist/Deployable/DeployableTarget.cjs +2 -0
- package/dist/Deployable/DeployableTarget.cjs.map +1 -0
- package/dist/Deployable/DeployableTarget.d.ts +116 -0
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -0
- package/dist/Deployable/DeployableTarget.js +132 -0
- package/dist/Deployable/DeployableTarget.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +2 -0
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.d.ts +513 -0
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -0
- package/dist/Incentives/AllowListIncentive.js +201 -0
- package/dist/Incentives/AllowListIncentive.js.map +1 -0
- package/dist/Incentives/CGDAIncentive.cjs +2 -0
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
- package/dist/Incentives/CGDAIncentive.d.ts +644 -0
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -0
- package/dist/Incentives/CGDAIncentive.js +271 -0
- package/dist/Incentives/CGDAIncentive.js.map +1 -0
- package/dist/Incentives/ERC1155Incentive.d.ts +713 -0
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20Incentive.cjs +2 -0
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
- package/dist/Incentives/ERC20Incentive.d.ts +666 -0
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20Incentive.js +312 -0
- package/dist/Incentives/ERC20Incentive.js.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +582 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -0
- package/dist/Incentives/Incentive.cjs +2 -0
- package/dist/Incentives/Incentive.cjs.map +1 -0
- package/dist/Incentives/Incentive.d.ts +36 -0
- package/dist/Incentives/Incentive.d.ts.map +1 -0
- package/dist/Incentives/Incentive.js +299 -0
- package/dist/Incentives/Incentive.js.map +1 -0
- package/dist/Incentives/PointsIncentive.cjs +2 -0
- package/dist/Incentives/PointsIncentive.cjs.map +1 -0
- package/dist/Incentives/PointsIncentive.d.ts +659 -0
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -0
- package/dist/Incentives/PointsIncentive.js +215 -0
- package/dist/Incentives/PointsIncentive.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +2 -0
- package/dist/Validators/SignerValidator.cjs.map +1 -0
- package/dist/Validators/SignerValidator.d.ts +745 -0
- package/dist/Validators/SignerValidator.d.ts.map +1 -0
- package/dist/Validators/SignerValidator.js +293 -0
- package/dist/Validators/SignerValidator.js.map +1 -0
- package/dist/Validators/Validator.cjs +2 -0
- package/dist/Validators/Validator.cjs.map +1 -0
- package/dist/Validators/Validator.d.ts +31 -0
- package/dist/Validators/Validator.d.ts.map +1 -0
- package/dist/Validators/Validator.js +27 -0
- 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-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 +2 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +441 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +262 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated-BDeDiaCK.js +4625 -0
- package/dist/generated-BDeDiaCK.js.map +1 -0
- package/dist/generated-wKBNvm48.cjs +3 -0
- package/dist/generated-wKBNvm48.cjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +113 -0
- 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 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +116 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +30 -0
- package/dist/utils.js.map +1 -0
- package/package.json +211 -0
- package/src/Actions/Action.test.ts +75 -0
- package/src/Actions/Action.ts +61 -0
- package/src/Actions/ContractAction.test.ts +197 -0
- package/src/Actions/ContractAction.ts +301 -0
- package/src/Actions/ERC721MintAction.test.ts +112 -0
- package/src/Actions/ERC721MintAction.ts +292 -0
- package/src/Actions/EventAction.test.ts +205 -0
- package/src/Actions/EventAction.ts +811 -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 +284 -0
- package/src/AllowLists/SimpleDenyList.test.ts +52 -0
- package/src/AllowLists/SimpleDenyList.ts +227 -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 +290 -0
- package/src/BoostCore.test.ts +773 -0
- package/src/BoostCore.ts +1261 -0
- package/src/BoostRegistry.ts +467 -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 +796 -0
- package/src/Budgets/SimpleBudget.test.ts +152 -0
- package/src/Budgets/SimpleBudget.ts +564 -0
- package/src/Budgets/VestingBudget.test.ts +123 -0
- package/src/Budgets/VestingBudget.ts +602 -0
- package/src/Deployable/Contract.ts +229 -0
- package/src/Deployable/Deployable.ts +250 -0
- package/src/Deployable/DeployableTarget.ts +223 -0
- package/src/Incentives/AllowListIncentive.test.ts +143 -0
- package/src/Incentives/AllowListIncentive.ts +334 -0
- package/src/Incentives/CGDAIncentive.test.ts +132 -0
- package/src/Incentives/CGDAIncentive.ts +468 -0
- package/src/Incentives/ERC1155Incentive.test.ts +87 -0
- package/src/Incentives/ERC1155Incentive.ts +466 -0
- package/src/Incentives/ERC20Incentive.test.ts +130 -0
- package/src/Incentives/ERC20Incentive.ts +482 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
- package/src/Incentives/ERC20VariableIncentive.ts +420 -0
- package/src/Incentives/Incentive.test.ts +92 -0
- package/src/Incentives/Incentive.ts +85 -0
- package/src/Incentives/PointsIncentive.test.ts +139 -0
- package/src/Incentives/PointsIncentive.ts +365 -0
- package/src/Validators/SignerValidator.test.ts +159 -0
- package/src/Validators/SignerValidator.ts +681 -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 +542 -0
- package/src/index.test.ts +40 -0
- package/src/index.ts +53 -0
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +44 -0
- package/src/utils.ts +198 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import {
|
|
2
|
+
erc1155IncentiveAbi,
|
|
3
|
+
readErc1155IncentiveAsset,
|
|
4
|
+
readErc1155IncentiveClaimed,
|
|
5
|
+
readErc1155IncentiveClaims,
|
|
6
|
+
readErc1155IncentiveExtraData,
|
|
7
|
+
readErc1155IncentiveIsClaimable,
|
|
8
|
+
readErc1155IncentiveLimit,
|
|
9
|
+
readErc1155IncentivePreflight,
|
|
10
|
+
readErc1155IncentiveReward,
|
|
11
|
+
readErc1155IncentiveStrategy,
|
|
12
|
+
readErc1155IncentiveTokenId,
|
|
13
|
+
simulateErc1155IncentiveClaim,
|
|
14
|
+
simulateErc1155IncentiveClawback,
|
|
15
|
+
writeErc1155IncentiveClaim,
|
|
16
|
+
writeErc1155IncentiveClawback,
|
|
17
|
+
} from '@boostxyz/evm';
|
|
18
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json';
|
|
19
|
+
import {
|
|
20
|
+
type Address,
|
|
21
|
+
type ContractEventName,
|
|
22
|
+
type Hex,
|
|
23
|
+
encodeAbiParameters,
|
|
24
|
+
parseAbiParameters,
|
|
25
|
+
} from 'viem';
|
|
26
|
+
import type {
|
|
27
|
+
DeployableOptions,
|
|
28
|
+
GenericDeployableParams,
|
|
29
|
+
} from '../Deployable/Deployable';
|
|
30
|
+
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
31
|
+
import {
|
|
32
|
+
type ClaimPayload,
|
|
33
|
+
type StrategyType,
|
|
34
|
+
prepareClaimPayload,
|
|
35
|
+
} from '../claiming';
|
|
36
|
+
import {
|
|
37
|
+
type GenericLog,
|
|
38
|
+
type ReadParams,
|
|
39
|
+
RegistryType,
|
|
40
|
+
type WriteParams,
|
|
41
|
+
} from '../utils';
|
|
42
|
+
|
|
43
|
+
export { erc1155IncentiveAbi };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Enum representing inventive disbursement strategies for {@link ERC1155Incentive}
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @enum {number}
|
|
50
|
+
*/
|
|
51
|
+
export enum ERC1155StrategyType {
|
|
52
|
+
POOL = 0,
|
|
53
|
+
MINT = 1,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The object representation of a `ERC1155Incentive.InitPayload`
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
* @interface ERC1155IncentivePayload
|
|
61
|
+
* @typedef {ERC1155IncentivePayload}
|
|
62
|
+
*/
|
|
63
|
+
export interface ERC1155IncentivePayload {
|
|
64
|
+
/**
|
|
65
|
+
* The address of the `ERC1155` asset
|
|
66
|
+
*
|
|
67
|
+
* @type {Address}
|
|
68
|
+
*/
|
|
69
|
+
asset: Address;
|
|
70
|
+
/**
|
|
71
|
+
* Should be `Strategy.POOL`
|
|
72
|
+
*
|
|
73
|
+
* @type {ERC1155StrategyType}
|
|
74
|
+
*/
|
|
75
|
+
strategy: ERC1155StrategyType;
|
|
76
|
+
/**
|
|
77
|
+
* The token ID to target
|
|
78
|
+
*
|
|
79
|
+
* @type {bigint}
|
|
80
|
+
*/
|
|
81
|
+
tokenId: bigint;
|
|
82
|
+
/**
|
|
83
|
+
* The maximum number of claims that can be made (one per address)
|
|
84
|
+
*
|
|
85
|
+
* @type {bigint}
|
|
86
|
+
*/
|
|
87
|
+
limit: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Any extra data to accompany the claim, if applicable.
|
|
90
|
+
*
|
|
91
|
+
* @type {Hex}
|
|
92
|
+
*/
|
|
93
|
+
extraData: Hex;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A generic `viem.Log` event with support for `ERC1155Incentive` event types.
|
|
98
|
+
*
|
|
99
|
+
* @export
|
|
100
|
+
* @typedef {ERC1155IncentiveLog}
|
|
101
|
+
* @template {ContractEventName<
|
|
102
|
+
* typeof erc1155IncentiveAbi
|
|
103
|
+
* >} [event=ContractEventName<typeof erc1155IncentiveAbi>]
|
|
104
|
+
*/
|
|
105
|
+
export type ERC1155IncentiveLog<
|
|
106
|
+
event extends ContractEventName<
|
|
107
|
+
typeof erc1155IncentiveAbi
|
|
108
|
+
> = ContractEventName<typeof erc1155IncentiveAbi>,
|
|
109
|
+
> = GenericLog<typeof erc1155IncentiveAbi, event>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This is currently not exported due to a mysterious abi encoding issue
|
|
113
|
+
*
|
|
114
|
+
* @experimental
|
|
115
|
+
* @export
|
|
116
|
+
* @class ERC1155Incentive
|
|
117
|
+
* @typedef {ERC1155Incentive}
|
|
118
|
+
* @extends {DeployableTarget<ERC1155IncentivePayload>}
|
|
119
|
+
*/
|
|
120
|
+
export class ERC1155Incentive extends DeployableTarget<
|
|
121
|
+
ERC1155IncentivePayload,
|
|
122
|
+
typeof erc1155IncentiveAbi
|
|
123
|
+
> {
|
|
124
|
+
public override readonly abi = erc1155IncentiveAbi;
|
|
125
|
+
/**
|
|
126
|
+
* @inheritdoc
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @static
|
|
130
|
+
* @type {Address}
|
|
131
|
+
*/
|
|
132
|
+
public static override base: Address = import.meta.env
|
|
133
|
+
.VITE_ERC1155_INCENTIVE_BASE;
|
|
134
|
+
/**
|
|
135
|
+
* @inheritdoc
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
* @static
|
|
139
|
+
* @type {RegistryType}
|
|
140
|
+
*/
|
|
141
|
+
public static override registryType: RegistryType = RegistryType.INCENTIVE;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Description placeholder
|
|
145
|
+
*
|
|
146
|
+
* @public
|
|
147
|
+
* @async
|
|
148
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'claims'>} [params]
|
|
149
|
+
* @returns {unknown}
|
|
150
|
+
*/
|
|
151
|
+
public async claims(
|
|
152
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'claims'>,
|
|
153
|
+
) {
|
|
154
|
+
return await readErc1155IncentiveClaims(this._config, {
|
|
155
|
+
address: this.assertValidAddress(),
|
|
156
|
+
args: [],
|
|
157
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
158
|
+
...(params as any),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Description placeholder
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
* @async
|
|
167
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'reward'>} [params]
|
|
168
|
+
* @returns {unknown}
|
|
169
|
+
*/
|
|
170
|
+
public async reward(
|
|
171
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'reward'>,
|
|
172
|
+
) {
|
|
173
|
+
return await readErc1155IncentiveReward(this._config, {
|
|
174
|
+
address: this.assertValidAddress(),
|
|
175
|
+
args: [],
|
|
176
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
177
|
+
...(params as any),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Description placeholder
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
* @async
|
|
186
|
+
* @param {Address} address
|
|
187
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'claimed'>} [params]
|
|
188
|
+
* @returns {unknown}
|
|
189
|
+
*/
|
|
190
|
+
public async claimed(
|
|
191
|
+
address: Address,
|
|
192
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'claimed'>,
|
|
193
|
+
) {
|
|
194
|
+
return await readErc1155IncentiveClaimed(this._config, {
|
|
195
|
+
address: this.assertValidAddress(),
|
|
196
|
+
args: [address],
|
|
197
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
198
|
+
...(params as any),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Description placeholder
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
* @async
|
|
207
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'asset'>} [params]
|
|
208
|
+
* @returns {unknown}
|
|
209
|
+
*/
|
|
210
|
+
public async asset(params?: ReadParams<typeof erc1155IncentiveAbi, 'asset'>) {
|
|
211
|
+
return await readErc1155IncentiveAsset(this._config, {
|
|
212
|
+
address: this.assertValidAddress(),
|
|
213
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
214
|
+
...(params as any),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Description placeholder
|
|
220
|
+
*
|
|
221
|
+
* @public
|
|
222
|
+
* @async
|
|
223
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'strategy'>} [params]
|
|
224
|
+
* @returns {Promise<StrategyType>}
|
|
225
|
+
*/
|
|
226
|
+
public strategy(
|
|
227
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'strategy'>,
|
|
228
|
+
): Promise<StrategyType> {
|
|
229
|
+
return readErc1155IncentiveStrategy(this._config, {
|
|
230
|
+
address: this.assertValidAddress(),
|
|
231
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
232
|
+
...(params as any),
|
|
233
|
+
}) as Promise<StrategyType>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Description placeholder
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
* @async
|
|
241
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'limit'>} [params]
|
|
242
|
+
* @returns {unknown}
|
|
243
|
+
*/
|
|
244
|
+
public async limit(params?: ReadParams<typeof erc1155IncentiveAbi, 'limit'>) {
|
|
245
|
+
return await readErc1155IncentiveLimit(this._config, {
|
|
246
|
+
address: this.assertValidAddress(),
|
|
247
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
248
|
+
...(params as any),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Description placeholder
|
|
254
|
+
*
|
|
255
|
+
* @public
|
|
256
|
+
* @async
|
|
257
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>} [params]
|
|
258
|
+
* @returns {unknown}
|
|
259
|
+
*/
|
|
260
|
+
public async tokenId(
|
|
261
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>,
|
|
262
|
+
) {
|
|
263
|
+
return await readErc1155IncentiveTokenId(this._config, {
|
|
264
|
+
address: this.assertValidAddress(),
|
|
265
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
266
|
+
...(params as any),
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Description placeholder
|
|
272
|
+
*
|
|
273
|
+
* @public
|
|
274
|
+
* @async
|
|
275
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'extraData'>} [params]
|
|
276
|
+
* @returns {unknown}
|
|
277
|
+
*/
|
|
278
|
+
public async extraData(
|
|
279
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'extraData'>,
|
|
280
|
+
) {
|
|
281
|
+
return await readErc1155IncentiveExtraData(this._config, {
|
|
282
|
+
address: this.assertValidAddress(),
|
|
283
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
284
|
+
...(params as any),
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Description placeholder
|
|
290
|
+
*
|
|
291
|
+
* @public
|
|
292
|
+
* @async
|
|
293
|
+
* @param {ClaimPayload} payload
|
|
294
|
+
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
|
|
295
|
+
* @returns {unknown}
|
|
296
|
+
*/
|
|
297
|
+
protected async claim(
|
|
298
|
+
payload: ClaimPayload,
|
|
299
|
+
params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
|
|
300
|
+
) {
|
|
301
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Description placeholder
|
|
306
|
+
*
|
|
307
|
+
* @public
|
|
308
|
+
* @async
|
|
309
|
+
* @param {ClaimPayload} payload
|
|
310
|
+
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
|
|
311
|
+
* @returns {unknown}
|
|
312
|
+
*/
|
|
313
|
+
protected async claimRaw(
|
|
314
|
+
payload: ClaimPayload,
|
|
315
|
+
params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
|
|
316
|
+
) {
|
|
317
|
+
const { request, result } = await simulateErc1155IncentiveClaim(
|
|
318
|
+
this._config,
|
|
319
|
+
{
|
|
320
|
+
address: this.assertValidAddress(),
|
|
321
|
+
args: [prepareClaimPayload(payload)],
|
|
322
|
+
...this.optionallyAttachAccount(),
|
|
323
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
324
|
+
...(params as any),
|
|
325
|
+
},
|
|
326
|
+
);
|
|
327
|
+
const hash = await writeErc1155IncentiveClaim(this._config, request);
|
|
328
|
+
return { hash, result };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Description placeholder
|
|
333
|
+
*
|
|
334
|
+
* @public
|
|
335
|
+
* @async
|
|
336
|
+
* @param {ClaimPayload} payload
|
|
337
|
+
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'clawback'>} [params]
|
|
338
|
+
* @returns {unknown}
|
|
339
|
+
*/
|
|
340
|
+
public async clawback(
|
|
341
|
+
payload: ClaimPayload,
|
|
342
|
+
params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
|
|
343
|
+
) {
|
|
344
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Description placeholder
|
|
349
|
+
*
|
|
350
|
+
* @public
|
|
351
|
+
* @async
|
|
352
|
+
* @param {ClaimPayload} payload
|
|
353
|
+
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'clawback'>} [params]
|
|
354
|
+
* @returns {unknown}
|
|
355
|
+
*/
|
|
356
|
+
public async clawbackRaw(
|
|
357
|
+
payload: ClaimPayload,
|
|
358
|
+
params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
|
|
359
|
+
) {
|
|
360
|
+
const { request, result } = await simulateErc1155IncentiveClawback(
|
|
361
|
+
this._config,
|
|
362
|
+
{
|
|
363
|
+
address: this.assertValidAddress(),
|
|
364
|
+
args: [prepareClaimPayload(payload)],
|
|
365
|
+
...this.optionallyAttachAccount(),
|
|
366
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
367
|
+
...(params as any),
|
|
368
|
+
},
|
|
369
|
+
);
|
|
370
|
+
const hash = await writeErc1155IncentiveClawback(this._config, request);
|
|
371
|
+
return { hash, result };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Description placeholder
|
|
376
|
+
*
|
|
377
|
+
* @public
|
|
378
|
+
* @async
|
|
379
|
+
* @param {ClaimPayload} payload
|
|
380
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>} [params]
|
|
381
|
+
* @returns {unknown}
|
|
382
|
+
*/
|
|
383
|
+
public async isClaimable(
|
|
384
|
+
payload: ClaimPayload,
|
|
385
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>,
|
|
386
|
+
) {
|
|
387
|
+
return await readErc1155IncentiveIsClaimable(this._config, {
|
|
388
|
+
address: this.assertValidAddress(),
|
|
389
|
+
args: [prepareClaimPayload(payload)],
|
|
390
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
391
|
+
...(params as any),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Description placeholder
|
|
397
|
+
*
|
|
398
|
+
* @public
|
|
399
|
+
* @async
|
|
400
|
+
* @param {ERC1155IncentivePayload} data
|
|
401
|
+
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'preflight'>} [params]
|
|
402
|
+
* @returns {unknown}
|
|
403
|
+
*/
|
|
404
|
+
public async preflight(
|
|
405
|
+
data: ERC1155IncentivePayload,
|
|
406
|
+
params?: ReadParams<typeof erc1155IncentiveAbi, 'preflight'>,
|
|
407
|
+
) {
|
|
408
|
+
return await readErc1155IncentivePreflight(this._config, {
|
|
409
|
+
address: this.assertValidAddress(),
|
|
410
|
+
args: [prepareERC1155IncentivePayload(data)],
|
|
411
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
412
|
+
...(params as any),
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @inheritdoc
|
|
418
|
+
*
|
|
419
|
+
* @public
|
|
420
|
+
* @param {?ERC1155IncentivePayload} [_payload]
|
|
421
|
+
* @param {?DeployableOptions} [_options]
|
|
422
|
+
* @returns {GenericDeployableParams}
|
|
423
|
+
*/
|
|
424
|
+
public override buildParameters(
|
|
425
|
+
_payload?: ERC1155IncentivePayload,
|
|
426
|
+
_options?: DeployableOptions,
|
|
427
|
+
): GenericDeployableParams {
|
|
428
|
+
const [payload, options] = this.validateDeploymentConfig(
|
|
429
|
+
_payload,
|
|
430
|
+
_options,
|
|
431
|
+
);
|
|
432
|
+
return {
|
|
433
|
+
abi: erc1155IncentiveAbi,
|
|
434
|
+
bytecode: bytecode as Hex,
|
|
435
|
+
args: [prepareERC1155IncentivePayload(payload)],
|
|
436
|
+
...this.optionallyAttachAccount(options.account),
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Given a {@link ERC1155IncentivePayload}, properly encode a `ERC1155Incentive.InitPayload` for use with {@link ERC1155Incentive} initialization.
|
|
443
|
+
*
|
|
444
|
+
* @param {ERC1155IncentivePayload} param0
|
|
445
|
+
* @param {Address} param0.asset - The address of the `ERC1155` asset
|
|
446
|
+
* @param {ERC1155StrategyType} param0.strategy - Should be `Strategy.POOL`
|
|
447
|
+
* @param {bigint} param0.tokenId - The token ID to target
|
|
448
|
+
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
449
|
+
* @param {Hex} param0.extraData - Any extra data to accompany the claim, if applicable.
|
|
450
|
+
* @returns {Hex}
|
|
451
|
+
*/
|
|
452
|
+
export const prepareERC1155IncentivePayload = ({
|
|
453
|
+
asset,
|
|
454
|
+
strategy,
|
|
455
|
+
tokenId,
|
|
456
|
+
limit,
|
|
457
|
+
extraData,
|
|
458
|
+
}: ERC1155IncentivePayload) => {
|
|
459
|
+
return encodeAbiParameters(
|
|
460
|
+
parseAbiParameters([
|
|
461
|
+
'InitPayload payload',
|
|
462
|
+
'struct InitPayload { address asset; uint8 strategy; uint256 tokenId; uint256 limit; bytes extraData; }',
|
|
463
|
+
]),
|
|
464
|
+
[{ asset, strategy, tokenId, limit, extraData }],
|
|
465
|
+
);
|
|
466
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { readMockErc20BalanceOf } from '@boostxyz/evm';
|
|
2
|
+
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
|
+
import { isAddress, pad, parseEther, zeroAddress } from 'viem';
|
|
4
|
+
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
5
|
+
import { accounts } from '../../test/accounts';
|
|
6
|
+
import {
|
|
7
|
+
type BudgetFixtures,
|
|
8
|
+
type Fixtures,
|
|
9
|
+
defaultOptions,
|
|
10
|
+
deployFixtures,
|
|
11
|
+
freshBoost,
|
|
12
|
+
fundBudget,
|
|
13
|
+
} from '../../test/helpers';
|
|
14
|
+
import { BOOST_CORE_CLAIM_FEE } from '../BoostCore';
|
|
15
|
+
import { StrategyType } from '../claiming';
|
|
16
|
+
import { ERC20Incentive } from './ERC20Incentive';
|
|
17
|
+
|
|
18
|
+
let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
19
|
+
|
|
20
|
+
describe('ERC20Incentive', () => {
|
|
21
|
+
beforeAll(async () => {
|
|
22
|
+
fixtures = await loadFixture(deployFixtures);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('can successfully be deployed', async () => {
|
|
30
|
+
const action = new ERC20Incentive(defaultOptions, {
|
|
31
|
+
asset: zeroAddress,
|
|
32
|
+
strategy: StrategyType.POOL,
|
|
33
|
+
reward: 1n,
|
|
34
|
+
limit: 1n,
|
|
35
|
+
});
|
|
36
|
+
await action.deploy();
|
|
37
|
+
expect(isAddress(action.assertValidAddress())).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('can claim', async () => {
|
|
41
|
+
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
42
|
+
const referrer = accounts.at(1)!.account!,
|
|
43
|
+
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
44
|
+
trustedSigner = accounts.at(0)!;
|
|
45
|
+
const erc20Incentive = fixtures.core.ERC20Incentive({
|
|
46
|
+
asset: budgets.erc20.assertValidAddress(),
|
|
47
|
+
strategy: StrategyType.POOL,
|
|
48
|
+
reward: 1n,
|
|
49
|
+
limit: 1n,
|
|
50
|
+
});
|
|
51
|
+
const boost = await freshBoost(fixtures, {
|
|
52
|
+
budget: budgets.budget,
|
|
53
|
+
incentives: [erc20Incentive],
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const claimant = trustedSigner.account;
|
|
57
|
+
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
58
|
+
const incentiveQuantity = 1;
|
|
59
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
60
|
+
signer: trustedSigner,
|
|
61
|
+
incentiveData,
|
|
62
|
+
chainId: defaultOptions.config.chains[0].id,
|
|
63
|
+
incentiveQuantity,
|
|
64
|
+
claimant,
|
|
65
|
+
boostId: boost.id,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await fixtures.core.claimIncentive(
|
|
69
|
+
boost.id,
|
|
70
|
+
0n,
|
|
71
|
+
referrer,
|
|
72
|
+
claimDataPayload,
|
|
73
|
+
{ value: BOOST_CORE_CLAIM_FEE },
|
|
74
|
+
);
|
|
75
|
+
expect(
|
|
76
|
+
await readMockErc20BalanceOf(defaultOptions.config, {
|
|
77
|
+
address: budgets.erc20.assertValidAddress(),
|
|
78
|
+
args: [defaultOptions.account.address],
|
|
79
|
+
}),
|
|
80
|
+
).toBe(1n);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('cannot claim twice', async () => {
|
|
84
|
+
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
85
|
+
const referrer = accounts.at(1)!.account!;
|
|
86
|
+
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
87
|
+
const trustedSigner = accounts.at(0)!;
|
|
88
|
+
const erc20Incentive = fixtures.core.ERC20Incentive({
|
|
89
|
+
asset: budgets.erc20.assertValidAddress(),
|
|
90
|
+
strategy: StrategyType.POOL,
|
|
91
|
+
reward: 1n,
|
|
92
|
+
limit: 1n,
|
|
93
|
+
});
|
|
94
|
+
const boost = await freshBoost(fixtures, {
|
|
95
|
+
budget: budgets.budget,
|
|
96
|
+
incentives: [erc20Incentive],
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const claimant = trustedSigner.account;
|
|
100
|
+
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
101
|
+
const incentiveQuantity = 1;
|
|
102
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
103
|
+
signer: trustedSigner,
|
|
104
|
+
incentiveData,
|
|
105
|
+
chainId: defaultOptions.config.chains[0].id,
|
|
106
|
+
incentiveQuantity,
|
|
107
|
+
claimant,
|
|
108
|
+
boostId: boost.id,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
await fixtures.core.claimIncentive(
|
|
112
|
+
boost.id,
|
|
113
|
+
0n,
|
|
114
|
+
referrer,
|
|
115
|
+
claimDataPayload,
|
|
116
|
+
{ value: BOOST_CORE_CLAIM_FEE },
|
|
117
|
+
);
|
|
118
|
+
try {
|
|
119
|
+
await fixtures.core.claimIncentive(
|
|
120
|
+
boost.id,
|
|
121
|
+
0n,
|
|
122
|
+
referrer,
|
|
123
|
+
claimDataPayload,
|
|
124
|
+
{ value: parseEther('0.000075') },
|
|
125
|
+
);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
expect(e).toBeInstanceOf(Error);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|