@boostxyz/sdk 8.0.0-canary.3 → 8.0.0-canary.4
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 +1 -1
- package/dist/Actions/Action.js +2 -2
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.js +45 -45
- package/dist/{AllowList-DQf-8HQC.js → AllowList-CTRuUBCQ.js} +41 -41
- package/dist/{AllowList-DQf-8HQC.js.map → AllowList-CTRuUBCQ.js.map} +1 -1
- package/dist/{AllowList-DaX239DR.cjs → AllowList-GEmUfOR1.cjs} +2 -2
- package/dist/{AllowList-DaX239DR.cjs.map → AllowList-GEmUfOR1.cjs.map} +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +4 -4
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.js +7 -7
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +2 -2
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +137 -2
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +336 -206
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.js +21 -21
- package/dist/{Budget-LnAQ_Slw.js → Budget-BH0s7Bxu.js} +52 -52
- package/dist/{Budget-LnAQ_Slw.js.map → Budget-BH0s7Bxu.js.map} +1 -1
- package/dist/{Budget-WIB8IJoM.cjs → Budget-CwNhsa3m.cjs} +2 -2
- package/dist/{Budget-WIB8IJoM.cjs.map → Budget-CwNhsa3m.cjs.map} +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +3 -3
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.js +26 -26
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +17 -17
- package/dist/{Incentive-gT7z-4v3.cjs → Incentive-B2ZBE5LU.cjs} +2 -2
- package/dist/{Incentive-gT7z-4v3.cjs.map → Incentive-B2ZBE5LU.cjs.map} +1 -1
- package/dist/{Incentive-D_IBex5V.js → Incentive-BCSV7OtF.js} +41 -41
- package/dist/{Incentive-D_IBex5V.js.map → Incentive-BCSV7OtF.js.map} +1 -1
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.js +17 -17
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.js +14 -14
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.js +13 -13
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs +1 -1
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js +71 -71
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs +1 -1
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js +35 -35
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js +9 -9
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js +12 -12
- package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
- package/dist/Incentives/ERC20VariableIncentive.js +8 -8
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.js +3 -3
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.js +28 -28
- package/dist/{SimpleDenyList-D5AoBdVi.cjs → SimpleDenyList-6_sxnZB0.cjs} +2 -2
- package/dist/{SimpleDenyList-D5AoBdVi.cjs.map → SimpleDenyList-6_sxnZB0.cjs.map} +1 -1
- package/dist/{SimpleDenyList-CtdXM49y.js → SimpleDenyList-CrjjFnn5.js} +17 -17
- package/dist/{SimpleDenyList-CtdXM49y.js.map → SimpleDenyList-CrjjFnn5.js.map} +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs.map +1 -1
- package/dist/Validators/LimitedSignerValidator.d.ts +9 -9
- package/dist/Validators/LimitedSignerValidator.d.ts.map +1 -1
- package/dist/Validators/LimitedSignerValidator.js +19 -19
- package/dist/Validators/LimitedSignerValidator.js.map +1 -1
- package/dist/Validators/LimitedSignerValidatorV2.cjs +2 -0
- package/dist/Validators/LimitedSignerValidatorV2.cjs.map +1 -0
- package/dist/Validators/LimitedSignerValidatorV2.d.ts +842 -0
- package/dist/Validators/LimitedSignerValidatorV2.d.ts.map +1 -0
- package/dist/Validators/LimitedSignerValidatorV2.js +301 -0
- package/dist/Validators/LimitedSignerValidatorV2.js.map +1 -0
- package/dist/Validators/PayableLimitedSignerValidator.cjs +2 -0
- package/dist/Validators/PayableLimitedSignerValidator.cjs.map +1 -0
- package/dist/Validators/PayableLimitedSignerValidator.d.ts.map +1 -1
- package/dist/{Validator-BEUqV28V.js → Validators/PayableLimitedSignerValidator.js} +56 -102
- package/dist/Validators/PayableLimitedSignerValidator.js.map +1 -0
- package/dist/Validators/PayableLimitedSignerValidatorV2.cjs +2 -0
- package/dist/Validators/PayableLimitedSignerValidatorV2.cjs.map +1 -0
- package/dist/Validators/PayableLimitedSignerValidatorV2.d.ts +855 -0
- package/dist/Validators/PayableLimitedSignerValidatorV2.d.ts.map +1 -0
- package/dist/Validators/PayableLimitedSignerValidatorV2.js +372 -0
- package/dist/Validators/PayableLimitedSignerValidatorV2.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +4 -2
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +12 -12
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/SignerValidatorV2.cjs +2 -0
- package/dist/Validators/SignerValidatorV2.cjs.map +1 -0
- package/dist/Validators/SignerValidatorV2.d.ts +728 -0
- package/dist/Validators/SignerValidatorV2.d.ts.map +1 -0
- package/dist/Validators/SignerValidatorV2.js +299 -0
- package/dist/Validators/SignerValidatorV2.js.map +1 -0
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +19 -4
- package/dist/Validators/Validator.d.ts.map +1 -1
- package/dist/Validators/Validator.js +79 -14
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/componentInterfaces-43ygGrVO.js +28 -0
- package/dist/componentInterfaces-43ygGrVO.js.map +1 -0
- package/dist/componentInterfaces-JU4NBkEc.cjs +2 -0
- package/dist/componentInterfaces-JU4NBkEc.cjs.map +1 -0
- package/dist/{deployments-Dw5Suk_D.js → deployments-COm00j8v.js} +48 -39
- package/dist/{deployments-Dw5Suk_D.js.map → deployments-COm00j8v.js.map} +1 -1
- package/dist/deployments-uLDgrxCp.cjs +2 -0
- package/dist/deployments-uLDgrxCp.cjs.map +1 -0
- package/dist/deployments.json +30 -21
- package/dist/generated-CkZm1EVH.cjs +3 -0
- package/dist/generated-CkZm1EVH.cjs.map +1 -0
- package/dist/{generated-krkFnwbV.js → generated-DRbljODL.js} +2314 -1284
- package/dist/generated-DRbljODL.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +185 -165
- package/dist/index.js.map +1 -1
- package/package.json +25 -1
- package/src/BoostCore.test.ts +77 -11
- package/src/BoostCore.ts +165 -4
- package/src/Budgets/ManagedBudgetWithFees.test.ts +14 -14
- package/src/Budgets/ManagedBudgetWithFeesV2.test.ts +3 -3
- package/src/Incentives/AllowListIncentive.test.ts +5 -5
- package/src/Incentives/CGDAIncentive.test.ts +6 -6
- package/src/Incentives/ERC1155Incentive.test.ts +2 -2
- package/src/Incentives/ERC20Incentive.test.ts +6 -6
- package/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.test.ts +5 -5
- package/src/Incentives/ERC20VariableCriteriaIncentiveV2.test.ts +5 -5
- package/src/Incentives/ERC20VariableIncentive.test.ts +7 -8
- package/src/Incentives/PointsIncentive.test.ts +5 -5
- package/src/Validators/LimitedSignerValidator.test.ts +1 -1
- package/src/Validators/LimitedSignerValidator.ts +9 -10
- package/src/Validators/LimitedSignerValidatorV2.test.ts +231 -0
- package/src/Validators/LimitedSignerValidatorV2.ts +707 -0
- package/src/Validators/PayableLimitedSignerValidator.test.ts +1 -1
- package/src/Validators/PayableLimitedSignerValidator.ts +0 -1
- package/src/Validators/PayableLimitedSignerValidatorV2.test.ts +202 -0
- package/src/Validators/PayableLimitedSignerValidatorV2.ts +688 -0
- package/src/Validators/SignerValidator.ts +4 -2
- package/src/Validators/SignerValidatorV2.test.ts +163 -0
- package/src/Validators/SignerValidatorV2.ts +635 -0
- package/src/Validators/Validator.ts +45 -2
- package/src/index.ts +3 -0
- package/dist/Validator-BEUqV28V.js.map +0 -1
- package/dist/Validator-FxcxYKhR.cjs +0 -2
- package/dist/Validator-FxcxYKhR.cjs.map +0 -1
- package/dist/componentInterfaces-BZ3fSNkT.cjs +0 -2
- package/dist/componentInterfaces-BZ3fSNkT.cjs.map +0 -1
- package/dist/componentInterfaces-D2s6AXlV.js +0 -25
- package/dist/componentInterfaces-D2s6AXlV.js.map +0 -1
- package/dist/deployments-DimWVnA4.cjs +0 -2
- package/dist/deployments-DimWVnA4.cjs.map +0 -1
- package/dist/generated-Cf82M-QP.cjs +0 -3
- package/dist/generated-Cf82M-QP.cjs.map +0 -1
- package/dist/generated-krkFnwbV.js.map +0 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
|
2
|
+
import { isAddress, pad } from "viem";
|
|
3
|
+
import { beforeAll, describe, expect, test } from "vitest";
|
|
4
|
+
import { accounts } from "@boostxyz/test/accounts";
|
|
5
|
+
import {
|
|
6
|
+
type Fixtures,
|
|
7
|
+
defaultOptions,
|
|
8
|
+
deployFixtures,
|
|
9
|
+
} from "@boostxyz/test/helpers";
|
|
10
|
+
import { testAccount } from "@boostxyz/test/viem";
|
|
11
|
+
import { SignerValidatorV2 } from "./SignerValidatorV2";
|
|
12
|
+
|
|
13
|
+
let fixtures: Fixtures;
|
|
14
|
+
|
|
15
|
+
function freshValidator(fixtures: Fixtures) {
|
|
16
|
+
return function freshValidator() {
|
|
17
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
18
|
+
const account = accounts.at(1)!.account;
|
|
19
|
+
return fixtures.registry.initialize(
|
|
20
|
+
crypto.randomUUID(),
|
|
21
|
+
fixtures.core.SignerValidatorV2({
|
|
22
|
+
signers: [defaultOptions.account.address, account],
|
|
23
|
+
validatorCaller: testAccount.address,
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe("SignerValidatorV2", () => {
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("can successfully be deployed", async () => {
|
|
35
|
+
const action = new SignerValidatorV2(defaultOptions, {
|
|
36
|
+
signers: [testAccount.address],
|
|
37
|
+
validatorCaller: testAccount.address,
|
|
38
|
+
});
|
|
39
|
+
await action.deploy();
|
|
40
|
+
expect(isAddress(action.assertValidAddress())).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("initializes successfully", async () => {
|
|
44
|
+
const validator = await loadFixture(freshValidator(fixtures));
|
|
45
|
+
expect(await validator.signers(defaultOptions.account.address)).toBe(true);
|
|
46
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
47
|
+
expect(await validator.signers(accounts.at(1)!.account)).toBe(true);
|
|
48
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
49
|
+
expect(await validator.signers(accounts.at(2)!.account)).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("can validate hashes", async () => {
|
|
53
|
+
const validator = await loadFixture(freshValidator(fixtures));
|
|
54
|
+
|
|
55
|
+
// Define the input data
|
|
56
|
+
const boostId = 5n;
|
|
57
|
+
const incentiveId = 0n;
|
|
58
|
+
const claimant = "0x24582544C98a86eE59687c4D5B55D78f4FffA666";
|
|
59
|
+
const referrer = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
|
|
60
|
+
const incentiveData = pad("0xdef456232173821931823712381232131391321934");
|
|
61
|
+
|
|
62
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
63
|
+
const trustedSigner = accounts.at(0)!;
|
|
64
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
65
|
+
const untrustedSigner = accounts.at(2)!;
|
|
66
|
+
|
|
67
|
+
const claimDataPayload = await validator.encodeClaimData({
|
|
68
|
+
signer: trustedSigner,
|
|
69
|
+
incentiveData,
|
|
70
|
+
chainId: defaultOptions.config.chains[0].id,
|
|
71
|
+
incentiveQuantity: 1,
|
|
72
|
+
claimant,
|
|
73
|
+
boostId: boostId,
|
|
74
|
+
referrer,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const badClaimDataPayload = await validator.encodeClaimData({
|
|
78
|
+
signer: untrustedSigner,
|
|
79
|
+
incentiveData,
|
|
80
|
+
chainId: defaultOptions.config.chains[0].id,
|
|
81
|
+
incentiveQuantity: 1,
|
|
82
|
+
claimant,
|
|
83
|
+
boostId: boostId,
|
|
84
|
+
referrer
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Validation using trusted signer
|
|
88
|
+
expect(
|
|
89
|
+
await validator.validate({
|
|
90
|
+
boostId: boostId,
|
|
91
|
+
incentiveId: incentiveId,
|
|
92
|
+
claimData: claimDataPayload,
|
|
93
|
+
claimant: claimant,
|
|
94
|
+
}),
|
|
95
|
+
).toBe(true);
|
|
96
|
+
|
|
97
|
+
// Validation using untrusted signer should throw an error
|
|
98
|
+
try {
|
|
99
|
+
await validator.validate({
|
|
100
|
+
boostId: boostId,
|
|
101
|
+
incentiveId: incentiveId,
|
|
102
|
+
claimData: badClaimDataPayload,
|
|
103
|
+
claimant: claimant,
|
|
104
|
+
});
|
|
105
|
+
} catch (e) {
|
|
106
|
+
expect(e).toBeInstanceOf(Error);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("will not revalidate the same hash", async () => {
|
|
111
|
+
const validator = await loadFixture(freshValidator(fixtures));
|
|
112
|
+
|
|
113
|
+
// Define the input data
|
|
114
|
+
const boostId = 5n;
|
|
115
|
+
const incentiveId = 0n;
|
|
116
|
+
const claimant = "0x24582544C98a86eE59687c4D5B55D78f4FffA666";
|
|
117
|
+
const referrer = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
|
|
118
|
+
const incentiveData = pad("0xdef456232173821931823712381232131391321934");
|
|
119
|
+
|
|
120
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
121
|
+
const trustedSigner = accounts.at(0)!;
|
|
122
|
+
|
|
123
|
+
const claimDataPayload = await validator.encodeClaimData({
|
|
124
|
+
signer: trustedSigner,
|
|
125
|
+
incentiveData,
|
|
126
|
+
chainId: defaultOptions.config.chains[0].id,
|
|
127
|
+
incentiveQuantity: 1,
|
|
128
|
+
claimant,
|
|
129
|
+
boostId: boostId,
|
|
130
|
+
referrer,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(
|
|
134
|
+
await validator.validate({
|
|
135
|
+
boostId,
|
|
136
|
+
incentiveId,
|
|
137
|
+
claimant,
|
|
138
|
+
claimData: claimDataPayload,
|
|
139
|
+
}),
|
|
140
|
+
).toBe(true);
|
|
141
|
+
|
|
142
|
+
// Attempt to validate the same hash again (should throw an error)
|
|
143
|
+
try {
|
|
144
|
+
await validator.validate({
|
|
145
|
+
boostId,
|
|
146
|
+
incentiveId,
|
|
147
|
+
claimData: claimDataPayload,
|
|
148
|
+
claimant,
|
|
149
|
+
});
|
|
150
|
+
} catch (e) {
|
|
151
|
+
expect(e).toBeInstanceOf(Error);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("can set authorized", async () => {
|
|
156
|
+
const validator = await loadFixture(freshValidator(fixtures));
|
|
157
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
158
|
+
const newSigner = accounts.at(2)!.account;
|
|
159
|
+
expect(await validator.signers(newSigner)).toBe(false);
|
|
160
|
+
await validator.setAuthorized([newSigner], [true]);
|
|
161
|
+
expect(await validator.signers(newSigner)).toBe(true);
|
|
162
|
+
});
|
|
163
|
+
});
|