diff --git a/.changeset/pre.json b/.changeset/pre.json index 89a346f7..2ac1a1b2 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -3,11 +3,13 @@ "tag": "alpha", "initialVersions": { "@boostxyz/evm": "0.0.0-alpha.0", - "@boostxyz/sdk": "0.0.0-alpha.0" + "@boostxyz/sdk": "0.0.0-alpha.0", + "@boostxyz/signatures": "0.0.0-alpha.0" }, "changesets": [ "mighty-pans-provide", "polite-jars-lie", - "silent-ants-impress" + "silent-ants-impress", + "witty-beers-melt" ] } diff --git a/.changeset/witty-beers-melt.md b/.changeset/witty-beers-melt.md new file mode 100644 index 00000000..155f4564 --- /dev/null +++ b/.changeset/witty-beers-melt.md @@ -0,0 +1,6 @@ +--- +"@boostxyz/sdk": patch +"@boostxyz/signatures": patch +--- + +initial sepolia release, omit unused, unaudited interfaces, release @boostxyz/signatures diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 601095b3..b3098d63 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -2,7 +2,6 @@ "name": "@boostxyz/sdk", "version": "0.0.0-alpha.2", "license": "GPL-3.0-or-later", - "private": true, "type": "module", "files": ["dist"], "repository": "https://github.com/rabbitholegg/boost-protocol", @@ -93,18 +92,6 @@ "node": "./dist/Actions/Action.js", "types": "./dist/Actions/Action.d.ts" }, - "./Actions/ContractAction": { - "require": "./dist/Actions/ContractAction.cjs", - "import": "./dist/Actions/ContractAction.js", - "node": "./dist/Actions/ContractAction.js", - "types": "./dist/Actions/ContractAction.d.ts" - }, - "./Actions/ERC721MintAction": { - "require": "./dist/Actions/ERC721MintAction.cjs", - "import": "./dist/Actions/ERC721MintAction.js", - "node": "./dist/Actions/ERC721MintAction.js", - "types": "./dist/Actions/ERC721MintAction.d.ts" - }, "./Actions/EventAction": { "require": "./dist/Actions/EventAction.cjs", "import": "./dist/Actions/EventAction.js", @@ -135,17 +122,11 @@ "node": "./dist/Budgets/Budget.js", "types": "./dist/Budgets/Budget.d.ts" }, - "./Budgets/SimpleBudget": { - "require": "./dist/Budgets/SimpleBudget.cjs", - "import": "./dist/Budgets/SimpleBudget.js", - "node": "./dist/Budgets/SimpleBudget.js", - "types": "./dist/Budgets/SimpleBudget.d.ts" - }, - "./Budgets/VestingBudget": { - "require": "./dist/Budgets/VestingBudget.cjs", - "import": "./dist/Budgets/VestingBudget.js", - "node": "./dist/Budgets/VestingBudget.js", - "types": "./dist/Budgets/VestingBudget.d.ts" + "./Budgets/ManagedBudget": { + "require": "./dist/Budgets/ManagedBudget.cjs", + "import": "./dist/Budgets/ManagedBudget.js", + "node": "./dist/Budgets/ManagedBudget.js", + "types": "./dist/Budgets/ManagedBudget.d.ts" }, "./Incentives/AllowListIncentive": { "require": "./dist/Incentives/AllowListIncentive.cjs", @@ -165,12 +146,6 @@ "node": "./dist/Incentives/ERC20Incentive.js", "types": "./dist/Incentives/ERC20Incentive.d.ts" }, - "./Incentives/ERC1155Incentive": { - "require": "./dist/Incentives/ERC1155Incentive.cjs", - "import": "./dist/Incentives/ERC1155Incentive.js", - "node": "./dist/Incentives/ERC1155Incentive.js", - "types": "./dist/Incentives/ERC1155Incentive.d.ts" - }, "./Incentives/Incentive": { "require": "./dist/Incentives/Incentive.cjs", "import": "./dist/Incentives/Incentive.js", diff --git a/packages/sdk/src/Actions/Action.ts b/packages/sdk/src/Actions/Action.ts index b50f766e..c68ef1f2 100644 --- a/packages/sdk/src/Actions/Action.ts +++ b/packages/sdk/src/Actions/Action.ts @@ -3,11 +3,13 @@ import { readContract } from '@wagmi/core'; import type { Address, Hex } from 'viem'; import type { DeployableOptions } from '../Deployable/Deployable'; import { InvalidComponentInterfaceError } from '../errors'; -import { ContractAction } from './ContractAction'; -import { ERC721MintAction } from './ERC721MintAction'; import { EventAction } from './EventAction'; -export { ContractAction, ERC721MintAction }; +export { + // ContractAction, + // ERC721MintAction, + EventAction, +}; /** * A union type representing all valid protocol Action implementations @@ -15,17 +17,17 @@ export { ContractAction, ERC721MintAction }; * @export * @typedef {Action} */ -export type Action = ContractAction | ERC721MintAction | EventAction; +export type Action = EventAction; // | ContractAction | ERC721MintAction /** * A map of Action component interfaces to their constructors. * - * @type {{ "0x2fae823b": ContractAction; "0xcba21e6c": ERC721MintAction; "0x916b9f6d": EventAction; }} + * @type {{ "0x7687b0ed": EventAction; }} */ export const ActionByComponentInterface = { - ['0x2fae823b']: ContractAction, - ['0xcba21e6c']: ERC721MintAction, - ['0x916b9f6d']: EventAction, + // ['0x6c3129aa']: ContractAction, + // ['0x97e083eb']: ERC721MintAction, + ['0x7687b0ed']: EventAction, }; /** @@ -35,7 +37,7 @@ export const ActionByComponentInterface = { * @async * @param {DeployableOptions} options * @param {Address} address - * @returns {Promise} + * @returns {Promise} * @throws {@link InvalidComponentInterfaceError} */ export async function actionFromAddress( @@ -54,8 +56,5 @@ export async function actionFromAddress( interfaceId, ); } - return new Ctor(options, address) as - | ContractAction - | ERC721MintAction - | EventAction; + return new Ctor(options, address); } diff --git a/packages/sdk/src/Actions/ContractAction.test.ts b/packages/sdk/src/Actions/ContractAction.test.ts index 79c89fe4..70295cf7 100644 --- a/packages/sdk/src/Actions/ContractAction.test.ts +++ b/packages/sdk/src/Actions/ContractAction.test.ts @@ -78,7 +78,7 @@ function otherAction(fixtures: Fixtures, erc20: MockERC20) { }; } -describe('ContractAction', () => { +describe.skip('ContractAction', () => { beforeEach(async () => { erc20 = await loadFixture(fundErc20(defaultOptions)); }); diff --git a/packages/sdk/src/Actions/ERC721MintAction.test.ts b/packages/sdk/src/Actions/ERC721MintAction.test.ts index 0c2d5280..c37cbed1 100644 --- a/packages/sdk/src/Actions/ERC721MintAction.test.ts +++ b/packages/sdk/src/Actions/ERC721MintAction.test.ts @@ -41,7 +41,7 @@ function nonPayableAction(fixtures: Fixtures, erc721: MockERC721) { }; } -describe('ERC721MintAction', () => { +describe.skip('ERC721MintAction', () => { beforeEach(async () => { erc721 = await loadFixture(fundErc721(defaultOptions)); }); diff --git a/packages/sdk/src/AllowLists/AllowList.ts b/packages/sdk/src/AllowLists/AllowList.ts index e5872edb..7c99f095 100644 --- a/packages/sdk/src/AllowLists/AllowList.ts +++ b/packages/sdk/src/AllowLists/AllowList.ts @@ -22,8 +22,8 @@ export type AllowList = SimpleAllowList | SimpleDenyList; * @type {{ "0x2bc9016b": SimpleAllowList; "0x9d585f63": SimpleDenyList; }} */ export const AllowListByComponentInterface = { - ['0x2bc9016b']: SimpleAllowList, - ['0x9d585f63']: SimpleDenyList, + ['0x8ba1fc24']: SimpleAllowList, + ['0x3d30a22c']: SimpleDenyList, }; /** diff --git a/packages/sdk/src/BoostCore.test.ts b/packages/sdk/src/BoostCore.test.ts index d3cb1504..3f3e96b7 100644 --- a/packages/sdk/src/BoostCore.test.ts +++ b/packages/sdk/src/BoostCore.test.ts @@ -7,13 +7,22 @@ import { defaultOptions, deployFixtures, fundBudget, + makeMockEventActionPayload, } from '../test/helpers'; import { ContractAction } from './Actions/ContractAction'; import { PassthroughAuth } from './Auth/PassthroughAuth'; import { BoostCore } from './BoostCore'; import type { ERC20Incentive } from './Incentives/ERC20Incentive'; import { IncentiveNotCloneableError } from './errors'; -import { ERC1155StrategyType, StrategyType, bytes4 } from './utils'; +import { + ActionStep, + ERC1155StrategyType, + FilterType, + PrimitiveType, + SignatureType, + StrategyType, + bytes4, +} from './utils'; let fixtures: Fixtures, budgets: BudgetFixtures; @@ -42,12 +51,13 @@ describe('BoostCore', () => { referralFee: 2n, maxParticipants: 100n, budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -85,12 +95,13 @@ describe('BoostCore', () => { referralFee: 2n, maxParticipants: 100n, budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -177,12 +188,13 @@ describe('BoostCore', () => { referralFee: 2n, maxParticipants: 100n, budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -237,12 +249,13 @@ describe('BoostCore', () => { const _boost = await client.createBoost({ budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -262,7 +275,7 @@ describe('BoostCore', () => { }); const boost = await client.createBoost({ budget: budget, - action: new bases.ContractAction( + action: new bases.EventAction( defaultOptions, _boost.action.assertValidAddress(), false, @@ -312,12 +325,13 @@ describe('BoostCore', () => { const _boost = await client.createBoost({ budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -337,12 +351,13 @@ describe('BoostCore', () => { }); const boost = await client.createBoost({ budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator( defaultOptions, _boost.validator.assertValidAddress(), @@ -389,12 +404,13 @@ describe('BoostCore', () => { const _boost = await client.createBoost({ budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -414,12 +430,13 @@ describe('BoostCore', () => { }); const boost = await client.createBoost({ budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -472,12 +489,13 @@ describe('BoostCore', () => { }); const _boost = await client.createBoost({ budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -491,12 +509,13 @@ describe('BoostCore', () => { try { await client.createBoost({ budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -568,12 +587,13 @@ describe('BoostCore', () => { referralFee: 2n, maxParticipants: 100n, budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -666,13 +686,17 @@ describe('BoostCore', () => { test('binds all actions, budgets, allowlists, incentives, and validators to reuse core options and account', async () => { const { core } = fixtures; - const contractAction = core.ContractAction(zeroAddress); - expect(contractAction._config).toEqual(defaultOptions.config); - expect(contractAction._account).toEqual(defaultOptions.account); + // const contractAction = core.ContractAction(zeroAddress); + // expect(contractAction._config).toEqual(defaultOptions.config); + // expect(contractAction._account).toEqual(defaultOptions.account); - const erc721MintAction = core.ERC721MintAction(zeroAddress); - expect(erc721MintAction._config).toEqual(defaultOptions.config); - expect(erc721MintAction._account).toEqual(defaultOptions.account); + // const erc721MintAction = core.ERC721MintAction(zeroAddress); + // expect(erc721MintAction._config).toEqual(defaultOptions.config); + // expect(erc721MintAction._account).toEqual(defaultOptions.account); + + const eventAction = core.EventAction(zeroAddress); + expect(eventAction._config).toEqual(defaultOptions.config); + expect(eventAction._account).toEqual(defaultOptions.account); const allowList = core.SimpleAllowList(zeroAddress); expect(allowList._config).toEqual(defaultOptions.config); @@ -682,13 +706,17 @@ describe('BoostCore', () => { expect(denyList._config).toEqual(defaultOptions.config); expect(denyList._account).toEqual(defaultOptions.account); - const simpleBudget = core.SimpleBudget(zeroAddress); - expect(simpleBudget._config).toEqual(defaultOptions.config); - expect(simpleBudget._account).toEqual(defaultOptions.account); + const managedBudget = core.ManagedBudget(zeroAddress); + expect(managedBudget._config).toEqual(defaultOptions.config); + expect(managedBudget._account).toEqual(defaultOptions.account); + + // const simpleBudget = core.SimpleBudget(zeroAddress); + // expect(simpleBudget._config).toEqual(defaultOptions.config); + // expect(simpleBudget._account).toEqual(defaultOptions.account); - const vestingBudget = core.VestingBudget(zeroAddress); - expect(vestingBudget._config).toEqual(defaultOptions.config); - expect(vestingBudget._account).toEqual(defaultOptions.account); + // const vestingBudget = core.VestingBudget(zeroAddress); + // expect(vestingBudget._config).toEqual(defaultOptions.config); + // expect(vestingBudget._account).toEqual(defaultOptions.account); const allowListIncentive = core.AllowListIncentive({ allowList: zeroAddress, @@ -716,15 +744,23 @@ describe('BoostCore', () => { expect(erc20Incentive._config).toEqual(defaultOptions.config); expect(erc20Incentive._account).toEqual(defaultOptions.account); - const erc1155Incentive = core.ERC1155Incentive({ + const erc20VariableIncentive = core.ERC20VariableIncentive({ asset: zeroAddress, - strategy: 0, - tokenId: 1n, + reward: 0n, limit: 0n, - extraData: '0x', }); - expect(erc1155Incentive._config).toEqual(defaultOptions.config); - expect(erc1155Incentive._account).toEqual(defaultOptions.account); + expect(erc20VariableIncentive._config).toEqual(defaultOptions.config); + expect(erc20VariableIncentive._account).toEqual(defaultOptions.account); + + // const erc1155Incentive = core.ERC1155Incentive({ + // asset: zeroAddress, + // strategy: 0, + // tokenId: 1n, + // limit: 0n, + // extraData: '0x', + // }); + // expect(erc1155Incentive._config).toEqual(defaultOptions.config); + // expect(erc1155Incentive._account).toEqual(defaultOptions.account); const pointsIncentive = core.PointsIncentive({ venue: zeroAddress, @@ -760,12 +796,13 @@ describe('BoostCore', () => { referralFee: 2n, maxParticipants: 100n, budget: budget, - action: new bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + action: new bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: new bases.SignerValidator(defaultOptions, { signers: [defaultOptions.account.address], validatorCaller: defaultOptions.account.address, @@ -791,7 +828,7 @@ describe('BoostCore', () => { expect(subscription).toHaveBeenCalledTimes(1); }); - test('can set a passthrough auth sceme', async () => { + test('can set a passthrough auth scheme', async () => { const { core } = fixtures; const client = new BoostCore({ ...defaultOptions, diff --git a/packages/sdk/src/BoostCore.ts b/packages/sdk/src/BoostCore.ts index 2d4d2039..90cd8597 100644 --- a/packages/sdk/src/BoostCore.ts +++ b/packages/sdk/src/BoostCore.ts @@ -29,14 +29,6 @@ import { zeroHash, } from 'viem'; import { type Action, actionFromAddress } from './Actions/Action'; -import { - ContractAction, - type ContractActionPayload, -} from './Actions/ContractAction'; -import { - ERC721MintAction, - type ERC721MintActionPayload, -} from './Actions/ERC721MintAction'; import { EventAction } from './Actions/EventAction'; import { type AllowList, allowListFromAddress } from './AllowLists/AllowList'; import { @@ -54,11 +46,6 @@ import { ManagedBudget, type ManagedBudgetPayload, } from './Budgets/ManagedBudget'; -import { SimpleBudget, type SimpleBudgetPayload } from './Budgets/SimpleBudget'; -import { - VestingBudget, - type VestingBudgetPayload, -} from './Budgets/VestingBudget'; import { Deployable, type DeployableOptions, @@ -77,10 +64,6 @@ import { ERC20Incentive, type ERC20IncentivePayload, } from './Incentives/ERC20Incentive'; -import { - ERC1155Incentive, - type ERC1155IncentivePayload, -} from './Incentives/ERC1155Incentive'; import { ERC20VariableIncentive, type Incentive, @@ -879,12 +862,12 @@ export class BoostCore extends Deployable< * * @example * ```ts - * const action = core.ContractAction('0x') // is roughly equivalent to - * const action = new ContractAction({ config: core._config, account: core._account }, '0x') + * const auth = core.PassthroughAuth('0x') // is roughly equivalent to + * const auth = new PassthroughAuth({ config: core._config, account: core._account }, '0x') * ``` * @param {DeployablePayloadOrAddress<{}>} options * @param {?boolean} [isBase] - * @returns {ContractAction} + * @returns {PassthroughAuth} */ PassthroughAuth(address?: Address) { return new PassthroughAuth( @@ -893,28 +876,28 @@ export class BoostCore extends Deployable< ); } - /** - * Bound {@link ContractAction} constructor that reuses the same configuration as the Boost Core instance. - * - * @example - * ```ts - * const action = core.ContractAction('0x') // is roughly equivalent to - * const action = new ContractAction({ config: core._config, account: core._account }, '0x') - * ``` - * @param {DeployablePayloadOrAddress} options - * @param {?boolean} [isBase] - * @returns {ContractAction} - */ - ContractAction( - options: DeployablePayloadOrAddress, - isBase?: boolean, - ) { - return new ContractAction( - { config: this._config, account: this._account }, - options, - isBase, - ); - } + // /** + // * Bound {@link ContractAction} constructor that reuses the same configuration as the Boost Core instance. + // * + // * @example + // * ```ts + // * const action = core.ContractAction('0x') // is roughly equivalent to + // * const action = new ContractAction({ config: core._config, account: core._account }, '0x') + // * ``` + // * @param {DeployablePayloadOrAddress} options + // * @param {?boolean} [isBase] + // * @returns {ContractAction} + // */ + // ContractAction( + // options: DeployablePayloadOrAddress, + // isBase?: boolean, + // ) { + // return new ContractAction( + // { config: this._config, account: this._account }, + // options, + // isBase, + // ); + // } /** * Bound {@link EventAction} constructor that reuses the same configuration as the Boost Core instance. @@ -934,28 +917,28 @@ export class BoostCore extends Deployable< isBase, ); } - /** - * Bound {@link ERC721MintAction} constructor that reuses the same configuration as the Boost Core instance. - * - * @example - * ```ts - * const action = core.ERC721MintAction('0x') // is roughly equivalent to - * const action = new ERC721MintAction({ config: core._config, account: core._account }, '0x') - * ``` - * @param {DeployablePayloadOrAddress} options - * @param {?boolean} [isBase] - * @returns {ERC721MintAction} - */ - ERC721MintAction( - options: DeployablePayloadOrAddress, - isBase?: boolean, - ) { - return new ERC721MintAction( - { config: this._config, account: this._account }, - options, - isBase, - ); - } + // /** + // * Bound {@link ERC721MintAction} constructor that reuses the same configuration as the Boost Core instance. + // * + // * @example + // * ```ts + // * const action = core.ERC721MintAction('0x') // is roughly equivalent to + // * const action = new ERC721MintAction({ config: core._config, account: core._account }, '0x') + // * ``` + // * @param {DeployablePayloadOrAddress} options + // * @param {?boolean} [isBase] + // * @returns {ERC721MintAction} + // */ + // ERC721MintAction( + // options: DeployablePayloadOrAddress, + // isBase?: boolean, + // ) { + // return new ERC721MintAction( + // { config: this._config, account: this._account }, + // options, + // isBase, + // ); + // } /** * Bound {@link SimpleAllowList} constructor that reuses the same configuration as the Boost Core instance. * @@ -1000,23 +983,23 @@ export class BoostCore extends Deployable< isBase, ); } - /** - * Bound {@link SimpleBudget} constructor that reuses the same configuration as the Boost Core instance. - * - * @example - * ```ts - * const budget = core.SimpleBudget('0x') // is roughly equivalent to - * const budget = new SimpleBudget({ config: core._config, account: core._account }, '0x') - * ``` - * @param {DeployablePayloadOrAddress} options - * @returns {SimpleBudget} - */ - SimpleBudget(options: DeployablePayloadOrAddress) { - return new SimpleBudget( - { config: this._config, account: this._account }, - options, - ); - } + // /** + // * Bound {@link SimpleBudget} constructor that reuses the same configuration as the Boost Core instance. + // * + // * @example + // * ```ts + // * const budget = core.SimpleBudget('0x') // is roughly equivalent to + // * const budget = new SimpleBudget({ config: core._config, account: core._account }, '0x') + // * ``` + // * @param {DeployablePayloadOrAddress} options + // * @returns {SimpleBudget} + // */ + // SimpleBudget(options: DeployablePayloadOrAddress) { + // return new SimpleBudget( + // { config: this._config, account: this._account }, + // options, + // ); + // } /** * Bound {@link ManagedBudget} constructor that reuses the same configuration as the Boost Core instance. * @@ -1034,23 +1017,23 @@ export class BoostCore extends Deployable< options, ); } - /** - * Bound {@link VestingBudget} constructor that reuses the same configuration as the Boost Core instance. - * - * @example - * ```ts - * const budget = core.VestingBudget('0x') // is roughly equivalent to - * const budget = new VestingBudget({ config: core._config, account: core._account }, '0x') - * ``` - * @param {DeployablePayloadOrAddress} options - * @returns {VestingBudget} - */ - VestingBudget(options: DeployablePayloadOrAddress) { - return new VestingBudget( - { config: this._config, account: this._account }, - options, - ); - } + // /** + // * Bound {@link VestingBudget} constructor that reuses the same configuration as the Boost Core instance. + // * + // * @example + // * ```ts + // * const budget = core.VestingBudget('0x') // is roughly equivalent to + // * const budget = new VestingBudget({ config: core._config, account: core._account }, '0x') + // * ``` + // * @param {DeployablePayloadOrAddress} options + // * @returns {VestingBudget} + // */ + // VestingBudget(options: DeployablePayloadOrAddress) { + // return new VestingBudget( + // { config: this._config, account: this._account }, + // options, + // ); + // } /** * Bound {@link AllowListIncentive} constructor that reuses the same configuration as the Boost Core instance. * @@ -1102,25 +1085,25 @@ export class BoostCore extends Deployable< options, ); } - /** - * Temporarily disabled until low level ABI encoding bugs are resolved - * Bound {@link ERC1155Incentive} constructor that reuses the same configuration as the Boost Core instance. - * - * @experimental - * @example - * ```ts - * const incentive = core.ERC1155Incentive({ ... }) // is roughly equivalent to - * const incentive = new ERC1155Incentive({ config: core._config, account: core._account }, { ... }) - * ``` - * @param {ERC1155IncentivePayload} options - * @returns {ERC1155Incentive} - */ - ERC1155Incentive(options: ERC1155IncentivePayload) { - return new ERC1155Incentive( - { config: this._config, account: this._account }, - options, - ); - } + // /** + // * Temporarily disabled until low level ABI encoding bugs are resolved + // * Bound {@link ERC1155Incentive} constructor that reuses the same configuration as the Boost Core instance. + // * + // * @experimental + // * @example + // * ```ts + // * const incentive = core.ERC1155Incentive({ ... }) // is roughly equivalent to + // * const incentive = new ERC1155Incentive({ config: core._config, account: core._account }, { ... }) + // * ``` + // * @param {ERC1155IncentivePayload} options + // * @returns {ERC1155Incentive} + // */ + // ERC1155Incentive(options: ERC1155IncentivePayload) { + // return new ERC1155Incentive( + // { config: this._config, account: this._account }, + // options, + // ); + // } /** * Bound {@link PointsIncentive} constructor that reuses the same configuration as the Boost Core instance. * diff --git a/packages/sdk/src/Budgets/Budget.ts b/packages/sdk/src/Budgets/Budget.ts index 3c8b407a..f6d904c8 100644 --- a/packages/sdk/src/Budgets/Budget.ts +++ b/packages/sdk/src/Budgets/Budget.ts @@ -4,10 +4,12 @@ import type { Address, Hex } from 'viem'; import type { DeployableOptions } from '../Deployable/Deployable'; import { InvalidComponentInterfaceError } from '../errors'; import { ManagedBudget } from './ManagedBudget'; -import { SimpleBudget } from './SimpleBudget'; -import { VestingBudget } from './VestingBudget'; -export { SimpleBudget, VestingBudget, ManagedBudget }; +export { + // SimpleBudget, + // VestingBudget, + ManagedBudget, +}; /** * A union type representing all valid protocol Budget implementations @@ -15,17 +17,17 @@ export { SimpleBudget, VestingBudget, ManagedBudget }; * @export * @typedef {Budget} */ -export type Budget = SimpleBudget | VestingBudget | ManagedBudget; +export type Budget = ManagedBudget; // | SimpleBudget | VestingBudget /** * A map of Budget component interfaces to their constructors. * - * @type {{ "0x7aded85d": typeof VestingBudget; "0x0f2a5d52": typeof SimpleBudget; "0x0596908b": typeof SimpleBudget; }} + * @type {{ "0xa0109882": typeof ManagedBudget; }} */ export const BudgetByComponentInterface = { - ['0x7aded85d']: VestingBudget, - ['0x0f2a5d52']: SimpleBudget, - ['0x0596908b']: ManagedBudget, + // ['0x64683da1']: VestingBudget, + // ['0x2929d19c']: SimpleBudget, + ['0xa0109882']: ManagedBudget, }; /** @@ -35,7 +37,7 @@ export const BudgetByComponentInterface = { * @async * @param {DeployableOptions} options * @param {Address} address - * @returns {Promise} + * @returns {Promise} * @throws {@link InvalidComponentInterfaceError} */ export async function budgetFromAddress( diff --git a/packages/sdk/src/Budgets/SimpleBudget.test.ts b/packages/sdk/src/Budgets/SimpleBudget.test.ts index bfb197c7..b9b339a7 100644 --- a/packages/sdk/src/Budgets/SimpleBudget.test.ts +++ b/packages/sdk/src/Budgets/SimpleBudget.test.ts @@ -25,7 +25,7 @@ beforeAll(async () => { fixtures = await loadFixture(deployFixtures); }); -describe('SimpleBudget', () => { +describe.skip('SimpleBudget', () => { test('can successfully be deployed', async () => { const action = new SimpleBudget(defaultOptions, { owner: testAccount.address, diff --git a/packages/sdk/src/Budgets/VestingBudget.test.ts b/packages/sdk/src/Budgets/VestingBudget.test.ts index 323da66f..ef237e4a 100644 --- a/packages/sdk/src/Budgets/VestingBudget.test.ts +++ b/packages/sdk/src/Budgets/VestingBudget.test.ts @@ -19,7 +19,7 @@ beforeAll(async () => { fixtures = await loadFixture(deployFixtures); }); -describe('VestingBudget', () => { +describe.skip('VestingBudget', () => { test('can successfully be deployed', async () => { const budget = new VestingBudget(defaultOptions, { owner: testAccount.address, diff --git a/packages/sdk/src/Incentives/ERC1155Incentive.test.ts b/packages/sdk/src/Incentives/ERC1155Incentive.test.ts index 4df3306c..dad485dd 100644 --- a/packages/sdk/src/Incentives/ERC1155Incentive.test.ts +++ b/packages/sdk/src/Incentives/ERC1155Incentive.test.ts @@ -27,7 +27,7 @@ const BOOST_CORE_CLAIM_FEE = parseEther('0.000075'); let fixtures: Fixtures, budgets: BudgetFixtures; -describe('ERC1155Incentive', () => { +describe.skip('ERC1155Incentive', () => { beforeAll(async () => { fixtures = await loadFixture(deployFixtures); }); diff --git a/packages/sdk/src/Incentives/Incentive.ts b/packages/sdk/src/Incentives/Incentive.ts index bd5979c2..2692d0b4 100644 --- a/packages/sdk/src/Incentives/Incentive.ts +++ b/packages/sdk/src/Incentives/Incentive.ts @@ -7,13 +7,13 @@ import { AllowListIncentive } from './AllowListIncentive'; import { CGDAIncentive } from './CGDAIncentive'; import { ERC20Incentive } from './ERC20Incentive'; import { ERC20VariableIncentive } from './ERC20VariableIncentive'; -import { ERC1155Incentive } from './ERC1155Incentive'; +// import { ERC1155Incentive } from './ERC1155Incentive'; import { PointsIncentive } from './PointsIncentive'; export { AllowListIncentive, CGDAIncentive, - ERC1155Incentive, + // ERC1155Incentive, ERC20Incentive, PointsIncentive, ERC20VariableIncentive, @@ -29,22 +29,22 @@ export type Incentive = | AllowListIncentive | CGDAIncentive | ERC20Incentive - | ERC1155Incentive + // | ERC1155Incentive | PointsIncentive | ERC20VariableIncentive; /** * A map of Incentive component interfaces to their constructors. * - * @type {{ "0x1e2e16a8": typeof PointsIncentive; "0x197d2cb3": typeof ERC20Incentive; "0xd1da3349": typeof AllowListIncentive; "0xb168aa66": typeof ERC1155Incentive; "0x31116297": typeof CGDAIncentive; }} + * @type {{ "0xc5b24b8e": typeof PointsIncentive; "0x8c901437": typeof ERC20Incentive; "0x0a466e6f": typeof AllowListIncentive; "0xa39e44d9": typeof CGDAIncentive; "0x6060409d": typeof ERC20VariableIncentive }} */ export const IncentiveByComponentInterface = { - ['0x1e2e16a8']: PointsIncentive, - ['0x197d2cb3']: ERC20Incentive, - ['0xd1da3349']: AllowListIncentive, - ['0xb168aa66']: ERC1155Incentive, - ['0x31116297']: CGDAIncentive, - ['0x47319704']: ERC20VariableIncentive, + ['0xc5b24b8e']: PointsIncentive, + ['0x8c901437']: ERC20Incentive, + ['0x0a466e6f']: AllowListIncentive, + // ['0x6aa68002']: ERC1155Incentive, + ['0xa39e44d9']: CGDAIncentive, + ['0x6060409d']: ERC20VariableIncentive, }; /** diff --git a/packages/sdk/src/Validators/Validator.ts b/packages/sdk/src/Validators/Validator.ts index 16237adf..235d30af 100644 --- a/packages/sdk/src/Validators/Validator.ts +++ b/packages/sdk/src/Validators/Validator.ts @@ -21,7 +21,7 @@ export type Validator = SignerValidator; * @type {{ "0xd8725ea2": typeof SignerValidator; }} */ export const ValidatorByComponentInterface = { - ['0xd8725ea2']: SignerValidator, + ['0xb8ce7b22']: SignerValidator, }; /** diff --git a/packages/sdk/src/utils.ts b/packages/sdk/src/utils.ts index e435ee65..9cb06f3d 100644 --- a/packages/sdk/src/utils.ts +++ b/packages/sdk/src/utils.ts @@ -465,97 +465,109 @@ export const prepareEventActionPayload = ({ [ { type: 'tuple', - name: 'actionClaimant', + name: 'initPayload', components: [ - { type: 'uint8', name: 'signatureType' }, - { type: 'bytes4', name: 'signature' }, - { type: 'uint8', name: 'fieldIndex' }, - { type: 'address', name: 'targetContract' }, - ], - }, - { - type: 'tuple', - name: 'actionStepOne', - components: [ - { type: 'bytes4', name: 'signature' }, - { type: 'uint8', name: 'actionType' }, - { type: 'address', name: 'targetContract' }, { type: 'tuple', - name: 'actionParameter', + name: 'actionClaimant', components: [ - { type: 'uint8', name: 'filterType' }, - { type: 'uint8', name: 'fieldType' }, + { type: 'uint8', name: 'signatureType' }, + { type: 'bytes4', name: 'signature' }, { type: 'uint8', name: 'fieldIndex' }, - { type: 'bytes', name: 'filterData' }, + { type: 'address', name: 'targetContract' }, ], }, - ], - }, - { - type: 'tuple', - name: 'actionStepTwo', - components: [ - { type: 'bytes4', name: 'signature' }, - { type: 'uint8', name: 'actionType' }, - { type: 'address', name: 'targetContract' }, { type: 'tuple', - name: 'actionParameter', + name: 'actionStepOne', components: [ - { type: 'uint8', name: 'filterType' }, - { type: 'uint8', name: 'fieldType' }, - { type: 'uint8', name: 'fieldIndex' }, - { type: 'bytes', name: 'filterData' }, + { type: 'bytes4', name: 'signature' }, + { type: 'uint8', name: 'signatureType' }, + { type: 'uint8', name: 'actionType' }, + { type: 'address', name: 'targetContract' }, + { + type: 'tuple', + name: 'actionParameter', + components: [ + { type: 'uint8', name: 'filterType' }, + { type: 'uint8', name: 'fieldType' }, + { type: 'uint8', name: 'fieldIndex' }, + { type: 'bytes', name: 'filterData' }, + ], + }, ], }, - ], - }, - { - type: 'tuple', - name: 'actionStepThree', - components: [ - { type: 'bytes4', name: 'signature' }, - { type: 'uint8', name: 'actionType' }, - { type: 'address', name: 'targetContract' }, { type: 'tuple', - name: 'actionParameter', + name: 'actionStepTwo', components: [ - { type: 'uint8', name: 'filterType' }, - { type: 'uint8', name: 'fieldType' }, - { type: 'uint8', name: 'fieldIndex' }, - { type: 'bytes', name: 'filterData' }, + { type: 'bytes4', name: 'signature' }, + { type: 'uint8', name: 'signatureType' }, + { type: 'uint8', name: 'actionType' }, + { type: 'address', name: 'targetContract' }, + { + type: 'tuple', + name: 'actionParameter', + components: [ + { type: 'uint8', name: 'filterType' }, + { type: 'uint8', name: 'fieldType' }, + { type: 'uint8', name: 'fieldIndex' }, + { type: 'bytes', name: 'filterData' }, + ], + }, ], }, - ], - }, - { - type: 'tuple', - name: 'actionStepFour', - components: [ - { type: 'bytes4', name: 'signature' }, - { type: 'uint8', name: 'actionType' }, - { type: 'address', name: 'targetContract' }, { type: 'tuple', - name: 'actionParameter', + name: 'actionStepThree', components: [ - { type: 'uint8', name: 'filterType' }, - { type: 'uint8', name: 'fieldType' }, - { type: 'uint8', name: 'fieldIndex' }, - { type: 'bytes', name: 'filterData' }, + { type: 'bytes4', name: 'signature' }, + { type: 'uint8', name: 'signatureType' }, + { type: 'uint8', name: 'actionType' }, + { type: 'address', name: 'targetContract' }, + { + type: 'tuple', + name: 'actionParameter', + components: [ + { type: 'uint8', name: 'filterType' }, + { type: 'uint8', name: 'fieldType' }, + { type: 'uint8', name: 'fieldIndex' }, + { type: 'bytes', name: 'filterData' }, + ], + }, + ], + }, + { + type: 'tuple', + name: 'actionStepFour', + components: [ + { type: 'bytes4', name: 'signature' }, + { type: 'uint8', name: 'signatureType' }, + { type: 'uint8', name: 'actionType' }, + { type: 'address', name: 'targetContract' }, + { + type: 'tuple', + name: 'actionParameter', + components: [ + { type: 'uint8', name: 'filterType' }, + { type: 'uint8', name: 'fieldType' }, + { type: 'uint8', name: 'fieldIndex' }, + { type: 'bytes', name: 'filterData' }, + ], + }, ], }, ], }, ], [ - actionClaimant, - actionStepOne, - actionStepTwo, - actionStepThree, - actionStepFour, + { + actionClaimant, + actionStepOne, + actionStepTwo, + actionStepThree, + actionStepFour, + }, ], ); }; diff --git a/packages/sdk/test/helpers.ts b/packages/sdk/test/helpers.ts index a3b3c800..92fb0a8d 100644 --- a/packages/sdk/test/helpers.ts +++ b/packages/sdk/test/helpers.ts @@ -46,7 +46,14 @@ import { import { BoostRegistry } from '../src/BoostRegistry'; import { ManagedBudgetRoles } from '../src/Budgets/ManagedBudget'; import { ERC1155Incentive } from '../src/Incentives/ERC1155Incentive'; -import { getDeployedContractAddress } from '../src/utils'; +import { + type ActionStep, + type EventActionPayload, + FilterType, + PrimitiveType, + SignatureType, + getDeployedContractAddress, +} from '../src/utils'; import type { DeployableOptions } from './../src/Deployable/Deployable'; import { MockERC20 } from './MockERC20'; import { MockERC721 } from './MockERC721'; @@ -64,7 +71,7 @@ export const defaultOptions: DeployableTestOptions = { export type Fixtures = Awaited>; export type BudgetFixtures = { - budget: SimpleBudget; + budget: ManagedBudget; erc20: MockERC20; erc1155: MockERC1155; points: MockPoints; @@ -78,21 +85,23 @@ export async function freshBoost( ...defaultOptions, address: fixtures.core.assertValidAddress(), }); + const { budget, erc20 } = await loadFixture( + fundBudget(defaultOptions, fixtures), + ); return core.createBoost({ protocolFee: options.protocolFee || 1n, referralFee: options.protocolFee || 2n, maxParticipants: options.protocolFee || 100n, - budget: - options.budget || - (await loadFixture(fundBudget(defaultOptions, fixtures))).budget, + budget: options.budget || budget, action: options.action || - new fixtures.bases.ContractAction(defaultOptions, { - chainId: BigInt(31_337), - target: core.assertValidAddress(), - selector: '0xdeadbeef', - value: 0n, - }), + new fixtures.bases.EventAction( + defaultOptions, + makeMockEventActionPayload( + core.assertValidAddress(), + erc20.assertValidAddress(), + ), + ), validator: options.validator || new fixtures.bases.SignerValidator(defaultOptions, { @@ -499,7 +508,8 @@ export function fundBudget( ) { return async function fundBudget() { { - if (!budget) budget = await loadFixture(freshBudget(options, fixtures)); + if (!budget) + budget = await loadFixture(freshManagedBudget(options, fixtures)); // await loadFixture(freshBudget(options, fixtures)); if (!erc20) erc20 = await loadFixture(fundErc20(options)); if (!erc1155) erc1155 = await loadFixture(fundErc1155(options)); if (!points) points = await loadFixture(fundPoints(options)); @@ -599,7 +609,7 @@ export function fundVestingBudget( return async function fundVestingBudget() { { if (!budget) - budget = await loadFixture(freshVestingBudget(options, fixtures)); + budget = await loadFixture(freshManagedBudget(options, fixtures)); if (!erc20) erc20 = await loadFixture(fundErc20(options)); if (!erc1155) erc1155 = await loadFixture(fundErc1155(options)); if (!points) points = await loadFixture(fundPoints(options)); @@ -620,9 +630,38 @@ export function fundVestingBudget( target: options.account.address, }); - return { budget, erc20, erc1155, points } as BudgetFixtures & { - budget: VestingBudget; - }; + return { budget, erc20, erc1155, points } as BudgetFixtures; } }; } + +export function makeMockEventActionPayload( + coreAddress: Address, + erc20Address: Address, +) { + const step: ActionStep = { + signature: '0xddf252ad', + signatureType: SignatureType.EVENT, + actionType: 0, + targetContract: erc20Address, + actionParameter: { + filterType: FilterType.EQUAL, + fieldType: PrimitiveType.ADDRESS, + fieldIndex: 0, // Assume the first field in the log is the 'from' address + filterData: coreAddress, + }, + }; + + return { + actionClaimant: { + signatureType: SignatureType.EVENT, + signature: '0xddf252ad', + fieldIndex: 0, + targetContract: erc20Address, + }, + actionStepOne: step, + actionStepTwo: step, + actionStepThree: step, + actionStepFour: step, + } as EventActionPayload; +} diff --git a/packages/signatures/package.json b/packages/signatures/package.json index 7781b38e..5574a349 100644 --- a/packages/signatures/package.json +++ b/packages/signatures/package.json @@ -3,7 +3,6 @@ "version": "0.0.0-alpha.0", "description": "An offline database of builtin bytes4 selectors and their corresponding abi items", "repository": "https://github.com/rabbitholegg/boost-protocol", - "private": true, "author": "Boost Team", "type": "module", "files": ["dist"],