diff --git a/packages/sdk/src/Actions/ContractAction.ts b/packages/sdk/src/Actions/ContractAction.ts index 1f35ac4f..b5924e3f 100644 --- a/packages/sdk/src/Actions/ContractAction.ts +++ b/packages/sdk/src/Actions/ContractAction.ts @@ -1,5 +1,6 @@ import { type ContractActionPayload, + contractActionAbi, prepareContractActionPayload, readContractActionChainId, readContractActionPrepare, @@ -9,7 +10,7 @@ import { simulateContractActionExecute, writeContractActionExecute, } from '@boostxyz/evm'; -import ContractActionArtifact from '@boostxyz/evm/artifacts/contracts/actions/ContractAction.sol/ContractAction.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/ContractAction.sol/ContractAction.json'; import { getTransaction, waitForTransactionReceipt } from '@wagmi/core'; import { type Hex, decodeFunctionData } from 'viem'; import type { @@ -64,24 +65,11 @@ export class ContractAction extends DeployableTarget { data: Hex, params: CallParams = {}, ) { - const hash = await this.executeRaw(data, params); - const receipt = await waitForTransactionReceipt(this._config, { - hash, - }); - const tx = await getTransaction(this._config, { hash }); - const { args } = decodeFunctionData({ - abi: ContractActionArtifact.abi, - data: tx.input, - }); - const { result } = await simulateContractActionExecute(this._config, { - account: tx.from, - address: tx.to!, - args: args as [Hex], - // value: tx.value, // TS doesn't like me to including this - blockNumber: receipt.blockNumber, - // do we need to include nonce, gas price, etc. to properly simulate? - }); - return result; + return this.awaitResult( + this.executeRaw(data, params), + contractActionAbi, + simulateContractActionExecute, + ); } public async executeRaw( @@ -117,8 +105,8 @@ export class ContractAction extends DeployableTarget { _options, ); return { - abi: ContractActionArtifact.abi, - bytecode: ContractActionArtifact.bytecode as Hex, + abi: contractActionAbi, + bytecode: bytecode as Hex, args: [prepareContractActionPayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Actions/ERC721MintAction.ts b/packages/sdk/src/Actions/ERC721MintAction.ts index 7c341488..e2aefa01 100644 --- a/packages/sdk/src/Actions/ERC721MintAction.ts +++ b/packages/sdk/src/Actions/ERC721MintAction.ts @@ -4,19 +4,15 @@ import { prepareERC721MintActionPayload, readErc721MintActionPrepare, simulateErc721MintActionExecute, + simulateErc721MintActionValidate, writeErc721MintActionExecute, writeErc721MintActionValidate, } from '@boostxyz/evm'; -import { - type Config, - getTransaction, - waitForTransactionReceipt, -} from '@wagmi/core'; -import { type Hex, decodeFunctionData } from 'viem'; -import { - Deployable, - type DeployableOptions, - type GenericDeployableParams, +import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/ERC721MintAction.sol/ERC721MintAction.json'; +import type { Hex } from 'viem'; +import type { + DeployableOptions, + GenericDeployableParams, } from '../Deployable/Deployable'; import type { CallParams } from '../utils'; import { ContractAction } from './ContractAction'; @@ -28,7 +24,7 @@ export class ERC721MintAction extends ContractAction { data: Hex, params: CallParams = {}, ) { - return this.awaitResult( + return this.awaitResult( this.executeRaw(data, params), erc721MintActionAbi, simulateErc721MintActionExecute, @@ -62,6 +58,17 @@ export class ERC721MintAction extends ContractAction { public async validate( data: Hex, params: CallParams = {}, + ) { + return this.awaitResult( + this.validateRaw(data, params), + erc721MintActionAbi, + simulateErc721MintActionValidate, + ); + } + + public async validateRaw( + data: Hex, + params: CallParams = {}, ) { return writeErc721MintActionValidate(this._config, { address: this.assertValidAddress(), @@ -80,8 +87,8 @@ export class ERC721MintAction extends ContractAction { _options, ); return { - abi: ERC721MintActionArtifact.abi, - bytecode: ERC721MintActionArtifact.bytecode as Hex, + abi: erc721MintActionAbi, + bytecode: bytecode as Hex, args: [prepareERC721MintActionPayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/AllowLists/SimpleAllowList.ts b/packages/sdk/src/AllowLists/SimpleAllowList.ts index 8c9d0807..4ee0f97c 100644 --- a/packages/sdk/src/AllowLists/SimpleAllowList.ts +++ b/packages/sdk/src/AllowLists/SimpleAllowList.ts @@ -2,9 +2,11 @@ import { type SimpleAllowListPayload, prepareSimpleAllowListPayload, readSimpleAllowListIsAllowed, + simpleAllowListAbi, + simulateSimpleAllowListSetAllowed, writeSimpleAllowListSetAllowed, } from '@boostxyz/evm'; -import SimpleAllowListArtifact from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleAllowList.sol/SimpleAllowList.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleAllowList.sol/SimpleAllowList.json'; import { getAccount } from '@wagmi/core'; import { type Address, type Hex, zeroAddress, zeroHash } from 'viem'; import type { @@ -33,7 +35,19 @@ export class SimpleAllowList extends DeployableTarget { public async setAllowed( addresses: Address[], allowed: boolean[], - params: CallParams = {}, + params: CallParams = {}, + ) { + return this.awaitResult( + this.setAllowedRaw(addresses, allowed, params), + simpleAllowListAbi, + simulateSimpleAllowListSetAllowed, + ); + } + + public async setAllowedRaw( + addresses: Address[], + allowed: boolean[], + params: CallParams = {}, ) { return await writeSimpleAllowListSetAllowed(this._config, { address: this.assertValidAddress(), @@ -41,6 +55,7 @@ export class SimpleAllowList extends DeployableTarget { ...params, }); } + public override buildParameters( _payload?: SimpleAllowListPayload, _options?: DeployableOptions, @@ -62,8 +77,8 @@ export class SimpleAllowList extends DeployableTarget { } } return { - abi: SimpleAllowListArtifact.abi, - bytecode: SimpleAllowListArtifact.bytecode as Hex, + abi: simpleAllowListAbi, + bytecode: bytecode as Hex, args: [prepareSimpleAllowListPayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/AllowLists/SimpleDenyList.ts b/packages/sdk/src/AllowLists/SimpleDenyList.ts index 7ee22aa3..7c89d869 100644 --- a/packages/sdk/src/AllowLists/SimpleDenyList.ts +++ b/packages/sdk/src/AllowLists/SimpleDenyList.ts @@ -2,9 +2,11 @@ import { type SimpleDenyListPayload, prepareSimpleDenyListPayload, readSimpleDenyListIsAllowed, + simpleDenyListAbi, + simulateSimpleDenyListSetDenied, writeSimpleDenyListSetDenied, } from '@boostxyz/evm'; -import SimpleDenyListArtifact from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleDenyList.sol/SimpleDenyList.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleDenyList.sol/SimpleDenyList.json'; import { getAccount } from '@wagmi/core'; import { type Address, type Hex, zeroAddress, zeroHash } from 'viem'; import type { @@ -33,6 +35,18 @@ export class SimpleDenyList extends DeployableTarget { addresses: Address[], allowed: boolean[], params: CallParams = {}, + ) { + return this.awaitResult( + this.setAllowedRaw(addresses, allowed, params), + simpleDenyListAbi, + simulateSimpleDenyListSetDenied, + ); + } + + public async setAllowedRaw( + addresses: Address[], + allowed: boolean[], + params: CallParams = {}, ) { return await writeSimpleDenyListSetDenied(this._config, { address: this.assertValidAddress(), @@ -62,8 +76,8 @@ export class SimpleDenyList extends DeployableTarget { } } return { - abi: SimpleDenyListArtifact.abi, - bytecode: SimpleDenyListArtifact.bytecode as Hex, + abi: simpleDenyListAbi, + bytecode: bytecode as Hex, args: [prepareSimpleDenyListPayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Budgets/SimpleBudget.ts b/packages/sdk/src/Budgets/SimpleBudget.ts index 8c909150..fc1da5be 100644 --- a/packages/sdk/src/Budgets/SimpleBudget.ts +++ b/packages/sdk/src/Budgets/SimpleBudget.ts @@ -8,13 +8,19 @@ import { readSimpleBudgetIsAuthorized, readSimpleBudgetTotal, readVestingBudgetStart, + simpleAllowListAbi, + simulateSimpleBudgetAllocate, + simulateSimpleBudgetDisburse, + simulateSimpleBudgetDisburseBatch, + simulateSimpleBudgetReclaim, + simulateSimpleBudgetSetAuthorized, writeSimpleBudgetAllocate, writeSimpleBudgetDisburse, writeSimpleBudgetDisburseBatch, writeSimpleBudgetReclaim, writeSimpleBudgetSetAuthorized, } from '@boostxyz/evm'; -import SimpleBudgetArtifact from '@boostxyz/evm/artifacts/contracts/budgets/SimpleBudget.sol/SimpleBudget.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/SimpleBudget.sol/SimpleBudget.json'; import { getAccount } from '@wagmi/core'; import { type Address, type Hex, zeroAddress } from 'viem'; import { @@ -35,7 +41,18 @@ export class SimpleBudget extends Deployable { }); } - public allocate( + public async allocate( + transfer: TransferPayload, + params: CallParams = {}, + ) { + return this.awaitResult( + this.allocateRaw(transfer, params), + simpleAllowListAbi, + simulateSimpleBudgetAllocate, + ); + } + + public allocateRaw( transfer: TransferPayload, params: CallParams = {}, ) { @@ -46,7 +63,18 @@ export class SimpleBudget extends Deployable { }); } - public reclaim( + public async reclaim( + transfer: TransferPayload, + params: CallParams = {}, + ) { + return this.awaitResult( + this.reclaimRaw(transfer, params), + simpleAllowListAbi, + simulateSimpleBudgetReclaim, + ); + } + + public reclaimRaw( transfer: TransferPayload, params: CallParams = {}, ) { @@ -57,7 +85,18 @@ export class SimpleBudget extends Deployable { }); } - public disburse( + public async disburse( + transfer: TransferPayload, + params: CallParams = {}, + ) { + return this.awaitResult( + this.disburseRaw(transfer, params), + simpleAllowListAbi, + simulateSimpleBudgetDisburse, + ); + } + + public disburseRaw( transfer: TransferPayload, params: CallParams = {}, ) { @@ -68,9 +107,20 @@ export class SimpleBudget extends Deployable { }); } + public async disburseBatch( + transfers: TransferPayload[], + params: CallParams = {}, + ) { + return this.awaitResult( + this.disburseBatchRaw(transfers, params), + simpleAllowListAbi, + simulateSimpleBudgetDisburseBatch, + ); + } + // use prepareFungibleTransfer or prepareERC1155Transfer // TODO use data structure - public disburseBatch( + public disburseBatchRaw( transfers: TransferPayload[], params: CallParams = {}, ) { @@ -85,6 +135,18 @@ export class SimpleBudget extends Deployable { addresses: Address[], allowed: boolean[], params: CallParams = {}, + ) { + return this.awaitResult( + this.setAuthorizedRaw(addresses, allowed, params), + simpleAllowListAbi, + simulateSimpleBudgetSetAuthorized, + ); + } + + public async setAuthorizedRaw( + addresses: Address[], + allowed: boolean[], + params: CallParams = {}, ) { return await writeSimpleBudgetSetAuthorized(this._config, { address: this.assertValidAddress(), @@ -161,8 +223,8 @@ export class SimpleBudget extends Deployable { } } return { - abi: SimpleBudgetArtifact.abi, - bytecode: SimpleBudgetArtifact.bytecode as Hex, + abi: simpleAllowListAbi, + bytecode: bytecode as Hex, args: [prepareSimpleBudgetPayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Budgets/VestingBudget.ts b/packages/sdk/src/Budgets/VestingBudget.ts index abd82673..47a4a954 100644 --- a/packages/sdk/src/Budgets/VestingBudget.ts +++ b/packages/sdk/src/Budgets/VestingBudget.ts @@ -8,14 +8,20 @@ import { readVestingBudgetEnd, readVestingBudgetIsAuthorized, readVestingBudgetTotal, + simulateVestingBudgetAllocate, + simulateVestingBudgetDisburse, + simulateVestingBudgetDisburseBatch, + simulateVestingBudgetReclaim, + simulateVestingBudgetSetAuthorized, + vestingBudgetAbi, writeVestingBudgetAllocate, writeVestingBudgetDisburse, writeVestingBudgetDisburseBatch, writeVestingBudgetReclaim, writeVestingBudgetSetAuthorized, } from '@boostxyz/evm'; -import VestingBudgetArtifact from '@boostxyz/evm/artifacts/contracts/budgets/VestingBudget.sol/VestingBudget.json'; -import { type Config, getAccount } from '@wagmi/core'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/VestingBudget.sol/VestingBudget.json'; +import { getAccount } from '@wagmi/core'; import { type Address, type Hex, zeroAddress } from 'viem'; import { Deployable, @@ -28,7 +34,18 @@ import type { CallParams } from '../utils'; export type { VestingBudgetPayload }; export class VestingBudget extends Deployable { - public allocate( + public async allocate( + transfer: TransferPayload, + params: CallParams = {}, + ) { + return this.awaitResult( + this.allocateRaw(transfer, params), + vestingBudgetAbi, + simulateVestingBudgetAllocate, + ); + } + + public allocateRaw( transfer: TransferPayload, params: CallParams = {}, ) { @@ -39,9 +56,18 @@ export class VestingBudget extends Deployable { }); } - // use prepareFungibleTransfer or prepareERC1155Transfer - // TODO use data structure - public reclaim( + public async reclaim( + transfer: TransferPayload, + params: CallParams = {}, + ) { + return this.awaitResult( + this.reclaimRaw(transfer, params), + vestingBudgetAbi, + simulateVestingBudgetReclaim, + ); + } + + public reclaimRaw( transfer: TransferPayload, params: CallParams = {}, ) { @@ -52,9 +78,18 @@ export class VestingBudget extends Deployable { }); } - // use prepareFungibleTransfer or prepareERC1155Transfer - // TODO use data structure - public disburse( + public async disburse( + transfer: TransferPayload, + params: CallParams = {}, + ) { + return this.awaitResult( + this.disburseRaw(transfer, params), + vestingBudgetAbi, + simulateVestingBudgetDisburse, + ); + } + + public disburseRaw( transfer: TransferPayload, params: CallParams = {}, ) { @@ -65,9 +100,18 @@ export class VestingBudget extends Deployable { }); } - // use prepareFungibleTransfer or prepareERC1155Transfer - // TODO use data structure - public disburseBatch( + public async disburseBatch( + transfers: TransferPayload[], + params: CallParams = {}, + ) { + return this.awaitResult( + this.disburseBatchRaw(transfers, params), + vestingBudgetAbi, + simulateVestingBudgetDisburseBatch, + ); + } + + public disburseBatchRaw( transfers: TransferPayload[], params: CallParams = {}, ) { @@ -82,6 +126,18 @@ export class VestingBudget extends Deployable { addresses: Address[], allowed: boolean[], params: CallParams = {}, + ) { + return this.awaitResult( + this.setAuthorizedRaw(addresses, allowed, params), + vestingBudgetAbi, + simulateVestingBudgetSetAuthorized, + ); + } + + public async setAuthorizedRaw( + addresses: Address[], + allowed: boolean[], + params: CallParams = {}, ) { return await writeVestingBudgetSetAuthorized(this._config, { address: this.assertValidAddress(), @@ -163,8 +219,8 @@ export class VestingBudget extends Deployable { } } return { - abi: VestingBudgetArtifact.abi, - bytecode: VestingBudgetArtifact.bytecode as Hex, + abi: vestingBudgetAbi, + bytecode: bytecode as Hex, args: [prepareVestingBudgetPayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Deployable/Contract.ts b/packages/sdk/src/Deployable/Contract.ts index a5bb1ea2..da2c5bc7 100644 --- a/packages/sdk/src/Deployable/Contract.ts +++ b/packages/sdk/src/Deployable/Contract.ts @@ -4,7 +4,15 @@ import { waitForTransactionReceipt, } from '@wagmi/core'; import type { CreateSimulateContractReturnType } from '@wagmi/core/codegen'; -import { type Abi, type Address, type Hash, decodeFunctionData } from 'viem'; +import { + type Abi, + type AbiStateMutability, + type Address, + type ContractFunctionArgs, + type ContractFunctionName, + type Hash, + decodeFunctionData, +} from 'viem'; import { ContractAddressRequiredError } from '../errors'; export class Contract { @@ -36,10 +44,13 @@ export class Contract { return address; } - protected async awaitResult( + protected async awaitResult< + const abi extends Abi | readonly unknown[], + functionName extends ContractFunctionName, + >( hashPromise: Promise, - abi: A, - fn: CreateSimulateContractReturnType, + abi: abi, + fn: CreateSimulateContractReturnType, ) { const hash = await hashPromise; const receipt = await waitForTransactionReceipt(this._config, { @@ -52,10 +63,11 @@ export class Contract { }); const { result } = await fn(this._config, { account: tx.from, - address: tx.to!, - args, + address: tx.to, + args: args as ContractFunctionArgs, blockNumber: receipt.blockNumber, - }); + // biome-ignore lint/suspicious/noExplicitAny: TODO this is an extremely complex type, but this method is intended for internal use and as such is alright for now + } as any); return result; } } diff --git a/packages/sdk/src/Incentives/AllowListIncentive.ts b/packages/sdk/src/Incentives/AllowListIncentive.ts index 16294863..c448f28e 100644 --- a/packages/sdk/src/Incentives/AllowListIncentive.ts +++ b/packages/sdk/src/Incentives/AllowListIncentive.ts @@ -1,14 +1,16 @@ import { type AllowListIncentivePayload, type ClaimPayload, + allowListIncentiveAbi, prepareAllowListIncentivePayload, prepareClaimPayload, readAllowListIncentiveAllowList, readAllowListIncentiveIsClaimable, readAllowListIncentiveLimit, + simulateAllowListIncentiveClaim, writeAllowListIncentiveClaim, } from '@boostxyz/evm'; -import AllowListIncentiveArtifact from '@boostxyz/evm/artifacts/contracts/incentives/AllowListIncentive.sol/AllowListIncentive.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/AllowListIncentive.sol/AllowListIncentive.json'; import type { Hex } from 'viem'; import { SimpleAllowList } from '../AllowLists/AllowList'; import type { @@ -43,10 +45,20 @@ export class AllowListIncentive extends DeployableTarget = {}, + ) { + return this.awaitResult( + this.claimRaw(payload, params), + allowListIncentiveAbi, + simulateAllowListIncentiveClaim, + ); + } + + public async claimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writeAllowListIncentiveClaim(this._config, { address: this.assertValidAddress(), @@ -76,8 +88,8 @@ export class AllowListIncentive extends DeployableTarget { }); } - //prepareClaimPayload public async claim( payload: ClaimPayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.claimRaw(payload, params), + cgdaIncentiveAbi, + simulateCgdaIncentiveClaim, + ); + } + + public async claimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writeCgdaIncentiveClaim(this._config, { address: this.assertValidAddress(), @@ -68,10 +81,20 @@ export class CGDAIncentive extends DeployableTarget { }); } - //prepareClaimPayload public async reclaim( payload: ClaimPayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.reclaimRaw(payload, params), + cgdaIncentiveAbi, + simulateCgdaIncentiveReclaim, + ); + } + + public async reclaimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writeCgdaIncentiveReclaim(this._config, { address: this.assertValidAddress(), @@ -120,8 +143,8 @@ export class CGDAIncentive extends DeployableTarget { _options, ); return { - abi: CGDAIncentiveArtifact.abi, - bytecode: CGDAIncentiveArtifact.bytecode as Hex, + abi: cgdaIncentiveAbi, + bytecode: bytecode as Hex, args: [prepareCGDAIncentivePayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Incentives/ERC1155Incentive.ts b/packages/sdk/src/Incentives/ERC1155Incentive.ts index 550e0bae..d6ab3b3c 100644 --- a/packages/sdk/src/Incentives/ERC1155Incentive.ts +++ b/packages/sdk/src/Incentives/ERC1155Incentive.ts @@ -2,6 +2,7 @@ import { type ClaimPayload, type ERC1155IncentivePayload, type StrategyType, + erc1155IncentiveAbi, prepareClaimPayload, prepareERC1155IncentivePayload, readErc1155IncentiveAsset, @@ -12,10 +13,12 @@ import { readErc1155IncentiveStrategy, readErc1155IncentiveTokenId, readErc1155SupportsInterface, + simulateErc1155IncentiveClaim, + simulateErc1155IncentiveReclaim, writeErc1155IncentiveClaim, writeErc1155IncentiveReclaim, } from '@boostxyz/evm'; -import ERC1155IncentiveArtifact from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json'; import type { Hex } from 'viem'; import type { DeployableOptions, @@ -75,6 +78,17 @@ export class ERC1155Incentive extends DeployableTarget public async claim( payload: ClaimPayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.claimRaw(payload, params), + erc1155IncentiveAbi, + simulateErc1155IncentiveClaim, + ); + } + + public async claimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writeErc1155IncentiveClaim(this._config, { address: this.assertValidAddress(), @@ -86,6 +100,17 @@ export class ERC1155Incentive extends DeployableTarget public async reclaim( payload: ClaimPayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.reclaimRaw(payload, params), + erc1155IncentiveAbi, + simulateErc1155IncentiveReclaim, + ); + } + + public async reclaimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writeErc1155IncentiveReclaim(this._config, { address: this.assertValidAddress(), @@ -136,8 +161,8 @@ export class ERC1155Incentive extends DeployableTarget _options, ); return { - abi: ERC1155IncentiveArtifact.abi, - bytecode: ERC1155IncentiveArtifact.bytecode as Hex, + abi: erc1155IncentiveAbi, + bytecode: bytecode as Hex, args: [prepareERC1155IncentivePayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Incentives/ERC20Incentive.ts b/packages/sdk/src/Incentives/ERC20Incentive.ts index 7bc01703..a5f8f138 100644 --- a/packages/sdk/src/Incentives/ERC20Incentive.ts +++ b/packages/sdk/src/Incentives/ERC20Incentive.ts @@ -2,6 +2,7 @@ import { type ClaimPayload, type ERC20IncentivePayload, type StrategyType, + erc20IncentiveAbi, prepareClaimPayload, prepareERC20IncentivePayload, readErc20IncentiveAsset, @@ -11,11 +12,14 @@ import { readErc20IncentivePreflight, readErc20IncentiveReward, readErc20IncentiveStrategy, + simulateErc20IncentiveClaim, + simulateErc20IncentiveDrawRaffle, + simulateErc20IncentiveReclaim, writeErc20IncentiveClaim, writeErc20IncentiveDrawRaffle, writeErc20IncentiveReclaim, } from '@boostxyz/evm'; -import ERC20IncentiveArtifact from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json'; import type { Hex } from 'viem'; import { Deployable, @@ -74,6 +78,17 @@ export class ERC20Incentive extends DeployableTarget { public async claim( payload: ClaimPayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.claimRaw(payload, params), + erc20IncentiveAbi, + simulateErc20IncentiveClaim, + ); + } + + public async claimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writeErc20IncentiveClaim(this._config, { address: this.assertValidAddress(), @@ -82,10 +97,20 @@ export class ERC20Incentive extends DeployableTarget { }); } - //prepareClaimPayload public async reclaim( payload: ClaimPayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.reclaimRaw(payload, params), + erc20IncentiveAbi, + simulateErc20IncentiveReclaim, + ); + } + + public async reclaimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writeErc20IncentiveReclaim(this._config, { address: this.assertValidAddress(), @@ -94,7 +119,6 @@ export class ERC20Incentive extends DeployableTarget { }); } - //prepareClaimPayload public async isClaimable( payload: ClaimPayload, params: CallParams = {}, @@ -119,6 +143,16 @@ export class ERC20Incentive extends DeployableTarget { public async drawRaffle( params: CallParams = {}, + ) { + return this.awaitResult( + this.drawRaffleRaw(params), + erc20IncentiveAbi, + simulateErc20IncentiveDrawRaffle, + ); + } + + public async drawRaffleRaw( + params: CallParams = {}, ) { return writeErc20IncentiveDrawRaffle(this._config, { address: this.assertValidAddress(), @@ -135,8 +169,8 @@ export class ERC20Incentive extends DeployableTarget { _options, ); return { - abi: ERC20IncentiveArtifact.abi, - bytecode: ERC20IncentiveArtifact.bytecode as Hex, + abi: erc20IncentiveAbi, + bytecode: bytecode as Hex, args: [prepareERC20IncentivePayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Incentives/PointsIncentive.ts b/packages/sdk/src/Incentives/PointsIncentive.ts index ccb43c16..20d9a59b 100644 --- a/packages/sdk/src/Incentives/PointsIncentive.ts +++ b/packages/sdk/src/Incentives/PointsIncentive.ts @@ -1,6 +1,7 @@ import { type ClaimPayload, type PointsIncentivePayload, + pointsIncentiveAbi, prepareClaimPayload, preparePointsIncentivePayload, readPointsIncentiveIsClaimable, @@ -8,9 +9,10 @@ import { readPointsIncentiveQuantity, readPointsIncentiveSelector, readPointsIncentiveVenue, + simulatePointsIncentiveClaim, writePointsIncentiveClaim, } from '@boostxyz/evm'; -import PointsIncentiveArtifact from '@boostxyz/evm/artifacts/contracts/incentives/PointsIncentive.sol/PointsIncentive.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/PointsIncentive.sol/PointsIncentive.json'; import type { Hex } from 'viem'; import type { DeployableOptions, @@ -54,10 +56,20 @@ export class PointsIncentive extends DeployableTarget { }); } - //prepareClaimPayload public async claim( payload: ClaimPayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.claimRaw(payload, params), + pointsIncentiveAbi, + simulatePointsIncentiveClaim, + ); + } + + public async claimRaw( + payload: ClaimPayload, + params: CallParams = {}, ) { return writePointsIncentiveClaim(this._config, { address: this.assertValidAddress(), @@ -87,8 +99,8 @@ export class PointsIncentive extends DeployableTarget { _options, ); return { - abi: PointsIncentiveArtifact.abi, - bytecode: PointsIncentiveArtifact.bytecode as Hex, + abi: pointsIncentiveAbi, + bytecode: bytecode as Hex, args: [preparePointsIncentivePayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/Validators/SignerValidator.ts b/packages/sdk/src/Validators/SignerValidator.ts index 76ba1f59..02dc17c1 100644 --- a/packages/sdk/src/Validators/SignerValidator.ts +++ b/packages/sdk/src/Validators/SignerValidator.ts @@ -4,10 +4,13 @@ import { prepareSignerValidatorPayload, prepareSignerValidatorValidatePayload, readSignerValidatorSigners, + signerValidatorAbi, + simulateSignerValidatorSetAuthorized, + simulateSignerValidatorValidate, writeSignerValidatorSetAuthorized, writeSignerValidatorValidate, } from '@boostxyz/evm'; -import SignerValidatorArtifact from '@boostxyz/evm/artifacts/contracts/validators/SignerValidator.sol/SignerValidator.json'; +import { bytecode } from '@boostxyz/evm/artifacts/contracts/validators/SignerValidator.sol/SignerValidator.json'; import type { Address, Hex } from 'viem'; import type { DeployableOptions, @@ -33,6 +36,17 @@ export class SignerValidator extends DeployableTarget { public async validate( payload: SignerValidatorValidatePayload, params: CallParams = {}, + ) { + return this.awaitResult( + this.validateRaw(payload, params), + signerValidatorAbi, + simulateSignerValidatorValidate, + ); + } + + public async validateRaw( + payload: SignerValidatorValidatePayload, + params: CallParams = {}, ) { return writeSignerValidatorValidate(this._config, { address: this.assertValidAddress(), @@ -45,6 +59,18 @@ export class SignerValidator extends DeployableTarget { addresses: Address[], allowed: boolean[], params: CallParams = {}, + ) { + return this.awaitResult( + this.setAuthorizedRaw(addresses, allowed, params), + signerValidatorAbi, + simulateSignerValidatorSetAuthorized, + ); + } + + public async setAuthorizedRaw( + addresses: Address[], + allowed: boolean[], + params: CallParams = {}, ) { return await writeSignerValidatorSetAuthorized(this._config, { address: this.assertValidAddress(), @@ -62,8 +88,8 @@ export class SignerValidator extends DeployableTarget { _options, ); return { - abi: SignerValidatorArtifact.abi, - bytecode: SignerValidatorArtifact.bytecode as Hex, + abi: signerValidatorAbi, + bytecode: bytecode as Hex, args: [prepareSignerValidatorPayload(payload)], ...this.optionallyAttachAccount(options.account), }; diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index fe80af53..4b5b3e6f 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -23,6 +23,8 @@ export * from './Budgets/VestingBudget'; // Deployable export * from './Deployable/Deployable'; +export * from './Deployable/Contract'; +export * from './Deployable/DeployableTarget'; // Incentives