Skip to content

Commit

Permalink
refactor(sdk): make subscribe, getLogs generic
Browse files Browse the repository at this point in the history
  • Loading branch information
sammccord committed Aug 30, 2024
1 parent 3364242 commit 03f5f57
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
7 changes: 3 additions & 4 deletions packages/sdk/src/BoostCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ export class BoostCore extends Deployable<
[Address, Address],
typeof boostCoreAbi
> {
public override readonly abi = boostCoreAbi;
/**
* Creates an instance of BoostCore.
*
Expand All @@ -245,7 +244,6 @@ export class BoostCore extends Deployable<
*/
constructor({ config, account, ...options }: BoostCoreConfig) {
if (isBoostCoreDeployed(options) && options.address) {
// @ts-expect-error unsure why the abi property's existence causes this throws ts(2401) here...
super({ account, config }, options.address);
} else if (isBoostCoreDeployable(options)) {
super({ account, config }, [
Expand All @@ -255,8 +253,9 @@ export class BoostCore extends Deployable<
} else {
super({ account, config }, BOOST_CORE_ADDRESS);
}
}
/**
//@ts-expect-error I can't set this property on the class because for some reason it takes super out of constructor scope?
this.abi = boostCoreAbi;
} /**
* Create a new Boost.
*
* @public
Expand Down
17 changes: 9 additions & 8 deletions packages/sdk/src/BoostRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,13 @@ export class BoostRegistry extends Deployable<
* @param {Target} target - An instance of a target contract to clone and initialize
* @param {?WriteParams<typeof boostRegistryAbi, 'deployClone'>} [params]
* @returns {Target} - The provided instance, but with a new address attached.
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
*/
public async clone<
Target extends DeployableTarget<any, Abi> ? infer Target : unknown,
>(
public async clone<Target extends DeployableTarget<any, any>>(
displayName: string,
target: Target,
params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
): Target {
): Promise<Target> {
const instance = await this.deployClone(displayName, target, params);
return target.at(instance);
}
Expand All @@ -266,9 +265,10 @@ export class BoostRegistry extends Deployable<
* @param {string} displayName
* @param {Target} target
* @param {?WriteParams<typeof boostRegistryAbi, 'deployClone'>} [params]
* @returns {unknown}
* @returns {Target}
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
*/
public async deployClone<Target extends DeployableTarget>(
public async deployClone<Target extends DeployableTarget<any, any>>(
displayName: string,
target: Target,
params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
Expand All @@ -284,10 +284,11 @@ export class BoostRegistry extends Deployable<
* @param {DeployableTarget} target
* @param {?WriteParams<typeof boostRegistryAbi, 'deployClone'>} [params]
* @returns {unknown} - The transaction hash
* biome-ignore lint/suspicious/noExplicitAny: any deployable target will suffice
*/
public async deployCloneRaw(
public async deployCloneRaw<Target extends DeployableTarget<any, any>>(
displayName: string,
target: DeployableTarget,
target: Target,
params?: WriteParams<typeof boostRegistryAbi, 'deployClone'>,
): Promise<HashAndSimulatedResult<Address>> {
const payload = target.buildParameters(undefined, {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/MockERC1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../src';
import type { WriteParams } from './../src/utils';

export class MockERC1155 extends Deployable<never, typeof mockErc1155Abi> {
export class MockERC1155 extends Deployable<{}, typeof mockErc1155Abi> {
public async mint(
address: Address,
id: bigint,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/MockERC20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '../src';
import type { WriteParams } from './../src/utils';

export class MockERC20 extends Deployable<never, typeof mockErc20Abi> {
export class MockERC20 extends Deployable<{}, typeof mockErc20Abi> {
public async approve(
address: Address,
value: bigint,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/MockERC721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../src';
import type { WriteParams } from '../src/utils';

export class MockERC721 extends Deployable<never, typeof mockErc721Abi> {
export class MockERC721 extends Deployable<{}, typeof mockErc721Abi> {
public async mint(
address: Address,
params?: WriteParams<typeof mockErc721Abi, 'mint'>,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export function fundErc1155(
args: [options.account.address, tokenId],
});
if (balance !== amount)
throw new Error('Balance did not match', { cause: { balance, amount } });
throw new Error(`Balance did not match ${{ balance, amount }}`);
return erc1155;
};
}
Expand Down

0 comments on commit 03f5f57

Please sign in to comment.