Skip to content

Commit

Permalink
[BOOST-4541] chore(types): generalize wagmi.Config, mark account opti…
Browse files Browse the repository at this point in the history
…onal in jsdoc, 2.x viem/wagmi peering (#34)
  • Loading branch information
sammccord authored Aug 28, 2024
2 parents 1a7bea0 + debf725 commit 0e1a04e
Show file tree
Hide file tree
Showing 13 changed files with 1,061 additions and 1,142 deletions.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//registry.npmjs.org/:_authToken=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
public-hoist-pattern[]=@boostxyz/*
public-hoist-pattern[]=vitest
4 changes: 2 additions & 2 deletions examples/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"react-dom": "18.3.0",
"react-jazzicon": "1.0.4",
"sharp": "0.33.3",
"viem": "2.9.27",
"wagmi": "2.5.22"
"viem": "^2.9.27",
"wagmi": "^2.5.22"
},
"devDependencies": {
"@types/node": "20.12.7",
Expand Down
8 changes: 7 additions & 1 deletion examples/next/src/components/MainPane/MainPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import type { FC } from 'react';

import { Box, Divider, Flex, Heading, useColorMode } from '@chakra-ui/react';
import { useAccount } from 'wagmi';
import { useAccount, useConfig } from 'wagmi';

import styles from '@/styles/mainPane.module.css';

import { BoostCore } from '@boostxyz/sdk';
import {
Address,
Balance,
Expand All @@ -19,6 +20,11 @@ import {
const MainPane: FC = () => {
const { isConnected } = useAccount();
const { colorMode } = useColorMode();
const config = useConfig();

const _core = new BoostCore({ config });

console.log(_core);

return (
<Box
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
"@types/node": "^20.11.24",
"@vitest/coverage-v8": "^1.6.0",
"@wagmi/connectors": "^5.0.19",
"@wagmi/core": "^2.11.2",
"@wagmi/core": "^2.13.4",
"arg": "^5.0.2",
"find-process": "^1.4.7",
"hardhat": "^2.22.5",
Expand All @@ -46,8 +45,14 @@
"typedoc": "^0.26.4",
"typedoc-material-theme": "^1.1.0",
"typescript": "^5.3.3",
"viem": "^2.9.9",
"viem": "^2.20.1",
"vite": "^5.2.13",
"vitest": "^1.6.0"
},
"pnpm": {
"overrides": {
"@wagmi/core": "2.13.0",
"viem": "2.9.27"
}
}
}
2 changes: 1 addition & 1 deletion packages/evm/artifacts/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createWriteContract,
createSimulateContract,
createWatchContractEvent,
} from 'wagmi/codegen'
} from '@wagmi/core/codegen'

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AAllowListIncentive
Expand Down
15 changes: 7 additions & 8 deletions packages/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,27 @@
"scripts": {
"build": "npm run clean && forge build --sizes && wagmi generate && vite build && tsc --build --emitDeclarationOnly --declaration --declarationMap --force",
"clean": "forge clean && hardhat clean && rm -rf cache",
"test": "forge test -vvv && npx hardhat test",
"test:ci": "forge test --summary --detailed -vvv && npx hardhat test"
"test": "forge test -vvv && hardhat test",
"test:ci": "forge test --summary --detailed -vvv && hardhat test"
},
"keywords": [],
"license": "GPL-3.0-or-later",
"dependencies": {
"@wagmi/core": "^2.11.5",
"wagmi": "^2.10.2"
"@wagmi/core": "2"
},
"devDependencies": {
"@nomicfoundation/hardhat-foundry": "^1.1.2",
"@nomicfoundation/hardhat-ignition": "^0.15.0",
"@nomicfoundation/hardhat-ignition": "^0.15.2",
"@nomicfoundation/hardhat-ignition-viem": "^0.15.0",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
"@nomicfoundation/hardhat-viem": "^2.0.2",
"@wagmi/cli": "^2.1.4",
"@wagmi/cli": "^2.1.15",
"abitype": "^1.0.2",
"hardhat": "^2.22.5",
"hardhat": "^2.22.9",
"solady": "^0.0.208",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"viem": "^2.9.9"
"viem": "^2.20.1"
}
}
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"@boostxyz/evm": "workspace:*"
},
"peerDependencies": {
"@wagmi/core": "^2.11.2",
"viem": "^2.9.9"
"@wagmi/core": "2",
"viem": "2"
}
}
10 changes: 7 additions & 3 deletions packages/sdk/src/BoostCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class BoostCore extends Deployable<[Address, Address]> {
* @constructor
* @param {BoostCoreConfig} param0
* @param {Config} param0.config
* @param {Account} param0.account
* @param {?Account} [param0.account]
* @param {({ address?: Address; } | { registryAddress: Address; protocolFeeReceiver: Address; })} param0....options
*/
constructor({ config, account, ...options }: BoostCoreConfig) {
Expand All @@ -229,7 +229,7 @@ export class BoostCore extends Deployable<[Address, Address]> {
* @async
* @param {CreateBoostPayload} _boostPayload
* @param {?DeployableOptions} [_options]
* @returns {unknown}
* @returns {Boost}
*/
public async createBoost(
_boostPayload: CreateBoostPayload,
Expand Down Expand Up @@ -628,7 +628,11 @@ export class BoostCore extends Deployable<[Address, Address]> {
address: Address,
params?: WriteParams<typeof boostCoreAbi, 'setProtocolFeeReceiver'>,
) {
return this.awaitResult(this.setProcolFeeReceiverRaw(address, params));
return this.awaitResult(
this.setProcolFeeReceiverRaw(address, {
...params,
}),
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/BoostRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class BoostRegistry extends Deployable<never[]> {
* @constructor
* @param {BoostRegistryConfig} param0
* @param {Config} param0.config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
* @param {Account} param0.account - [Viem Local Account](https://viem.sh/docs/accounts/local)
* @param {?Account} [param0.account] - [Viem Local Account](https://viem.sh/docs/accounts/local)
* @param {({ address?: Address; } | {})} param0....options
*/
constructor({ config, account, ...options }: BoostRegistryConfig) {
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/src/Deployable/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { type HashAndSimulatedResult, awaitResult } from '../utils';
*/
export class Contract {
/**
* @see [Wagmi Configuration](https://en.wikipedia.org/wiki/Factorial)
* @see [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
* @protected
* @type {Config}
* @type {WagmiConfig}
*/
protected _config: Config;
/**
Expand All @@ -31,6 +31,7 @@ export class Contract {
* @constructor
* @param {Config} config
* @param {(Address | undefined)} address
* biome-ignore lint/suspicious/noExplicitAny: ^
*/
constructor(config: Config, address: Address | undefined) {
this._config = config;
Expand Down
7 changes: 4 additions & 3 deletions packages/sdk/src/Deployable/Deployable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import { Contract } from './Contract';
*/
export type GenericDeployableParams = Omit<
Parameters<typeof deployContract>[1],
'args'
'args' | 'account'
> & {
args: [Hex, ...Array<Hex>];
account?: Account;
};

/**
Expand Down Expand Up @@ -53,7 +54,7 @@ export interface DeployableOptions {
*/
config: Config;
/**
* [Viem Local Account](https://viem.sh/docs/accounts/local), if in a Node environment
* [Viem Local Account](https://viem.sh/docs/accounts/local), required if in a Node environment
*
* @see {@link Account}
* @type {?Account}
Expand Down Expand Up @@ -90,7 +91,7 @@ export class Deployable<Payload = unknown> extends Contract {
*
* @constructor
* @param {DeployableOptions} param0
* @param {Account} param0.account
* @param {?Account} [param0.account]
* @param {Config} param0.config
* @param {DeployablePayloadOrAddress<Payload>} payload
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export type ReadParams<
*
* @export
* @param {string} input
* @returns {*}
* @returns {Hex}
*/
export function bytes4(input: string) {
return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);
Expand All @@ -85,7 +85,7 @@ export function bytes4(input: string) {
*
* @export
* @async
* @param {Config} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
* @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
* @param {Promise<Hash>} hash - A transaction hash promise
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}
* @returns {unknown}
Expand Down Expand Up @@ -120,7 +120,7 @@ export type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };
* @export
* @async
* @template [Result=unknown]
* @param {Config} config
* @param {WagmiConfig} config
* @param {Promise<HashAndSimulatedResult<Result>>} hashPromise
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
* @returns {Promise<Result>}
Expand Down
Loading

0 comments on commit 0e1a04e

Please sign in to comment.