Skip to content

Commit

Permalink
chore(sdk,LimitedSigner): backfill refs into more places for compat
Browse files Browse the repository at this point in the history
  • Loading branch information
sammccord authored and topocount committed Oct 24, 2024
1 parent b9ac73b commit c084cb9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
18 changes: 18 additions & 0 deletions packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ERC20VariableCriteriaIncentiveArtifact from '@boostxyz/evm/artifacts/cont
import ERC20VariableIncentiveArtifact from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableIncentive.sol/ERC20VariableIncentive.json';
import ERC1155IncentiveArtifact from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json';
import PointsIncentiveArtifact from '@boostxyz/evm/artifacts/contracts/incentives/PointsIncentive.sol/PointsIncentive.json';
import LimitedSignerValidatorArtifact from '@boostxyz/evm/artifacts/contracts/validators/LimitedSignerValidator.sol/LimitedSignerValidator.json';
import SignerValidatorArtifact from '@boostxyz/evm/artifacts/contracts/validators/SignerValidator.sol/SignerValidator.json';
import {
AllowListIncentive,
Expand All @@ -23,6 +24,7 @@ import {
ERC20VariableCriteriaIncentive,
ERC20VariableIncentive,
EventAction,
LimitedSignerValidator,
ManagedBudget,
PointsIncentive,
SignerValidator,
Expand Down Expand Up @@ -63,6 +65,7 @@ export type DeployResult = {
ERC1155_INCENTIVE_BASE: string;
POINTS_INCENTIVE_BASE: string;
SIGNER_VALIDATOR_BASE: string;
LIMITED_SIGNER_VALIDATOR_BASE: string;
};

export const deploy: Command<DeployResult> = async function deploy(opts) {
Expand Down Expand Up @@ -263,6 +266,15 @@ export const deploy: Command<DeployResult> = async function deploy(opts) {
}),
);

const limitedSignerValidatorBase = await getDeployedContractAddress(
config,
deployContract(config, {
abi: LimitedSignerValidatorArtifact.abi,
bytecode: LimitedSignerValidatorArtifact.bytecode as Hex,
account,
}),
);

const bases = {
// ContractAction: class TContractAction extends ContractAction {
// public static override base = contractActionBase;
Expand Down Expand Up @@ -331,6 +343,11 @@ export const deploy: Command<DeployResult> = async function deploy(opts) {
[chainId]: signerValidatorBase,
} as Record<number, Address>;
},
LimitedSignerValidator: class TLimitedSignerValidator extends LimitedSignerValidator {
public static override bases: Record<number, Address> = {
[chainId]: limitedSignerValidatorBase,
} as Record<number, Address>;
},
};

for (const [name, deployable] of Object.entries(bases)) {
Expand Down Expand Up @@ -359,5 +376,6 @@ export const deploy: Command<DeployResult> = async function deploy(opts) {
ERC1155_INCENTIVE_BASE: erc1155IncentiveBase,
POINTS_INCENTIVE_BASE: pointsIncentiveBase,
SIGNER_VALIDATOR_BASE: signerValidatorBase,
LIMITED_SIGNER_VALIDATOR_BASE: limitedSignerValidatorBase,
};
};
1 change: 1 addition & 0 deletions packages/sdk/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ VITE_ERC20_VARIABLE_INCENTIVE_BASE=
VITE_ERC1155_INCENTIVE_BASE=
VITE_POINTS_INCENTIVE_BASE=
VITE_SIGNER_VALIDATOR_BASE=
VITE_LIMITED_SIGNER_VALIDATOR_BASE=
VITE_BASE_MAINNET_RPC=
6 changes: 6 additions & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@
"import": "./dist/Validators/SignerValidator.js",
"node": "./dist/Validators/SignerValidator.js",
"types": "./dist/Validators/SignerValidator.d.ts"
},
"./Validators/LimitedSignerValidator": {
"require": "./dist/Validators/LimitedSignerValidator.cjs",
"import": "./dist/Validators/LimitedSignerValidator.js",
"node": "./dist/Validators/LimitedSignerValidator.js",
"types": "./dist/Validators/LimitedSignerValidator.d.ts"
}
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/Validators/LimitedSignerValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export class LimitedSignerValidator extends DeployableTarget<
* @type {Record<number, Address>}
*/
public static override bases: Record<number, Address> = {
31337: import.meta.env.VITE_LIMITED_SIGNER_VALIDATOR_BASE,
...(SignerValidatorBases as Record<number, Address>),
};
/**
Expand Down
13 changes: 10 additions & 3 deletions packages/sdk/src/Validators/Validator.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { aValidatorAbi } from '@boostxyz/evm';
import { ASignerValidator } from '@boostxyz/evm/deploys/componentInterfaces.json';
import {
ASignerValidator,
// TODO: bring this back in
// ALimitedSignerValidator,
} from '@boostxyz/evm/deploys/componentInterfaces.json';
import { readContract } from '@wagmi/core';
import type { Address, Hex } from 'viem';
import type { DeployableOptions } from '../Deployable/Deployable';
import { InvalidComponentInterfaceError } from '../errors';
import { LimitedSignerValidator } from './LimitedSignerValidator';
import { SignerValidator } from './SignerValidator';

export { SignerValidator };
export { SignerValidator, LimitedSignerValidator };

/**
* A union type representing all valid protocol Validator implementations
*
* @export
* @typedef {Validator}
*/
export type Validator = SignerValidator;
export type Validator = SignerValidator | LimitedSignerValidator;

/**
* A map of Validator component interfaces to their constructors.
Expand All @@ -23,6 +28,8 @@ export type Validator = SignerValidator;
*/
export const ValidatorByComponentInterface = {
[ASignerValidator as Hex]: SignerValidator,
// TODO bring this back in
// [ALimitedSignerValidator as Hex]: LimitedSignerValidator,
};

/**
Expand Down

0 comments on commit c084cb9

Please sign in to comment.