From 78097d69da950840a795be4555dbf5300aa98b91 Mon Sep 17 00:00:00 2001 From: William Cory Date: Wed, 29 Jul 2026 17:35:08 -0700 Subject: [PATCH] chore: harden contract package for production --- .github/workflows/ci.yml | 13 +- .github/workflows/docs.yml | 26 +- .github/workflows/release.yml | 24 +- README.md | 6 +- biome.json | 5 +- docs/README.md | 45 +- docs/_media/LICENSE | 22 - docs/functions/createContract.md | 62 +-- docs/globals.md | 28 -- docs/type-aliases/Contract.md | 59 ++- docs/type-aliases/CreateContractFn.md | 64 ++- docs/type-aliases/CreateContractParams.md | 19 +- docs/type-aliases/EventActionCreator.md | 24 +- .../MaybeExtractEventArgsFromAbi.md | 16 +- docs/type-aliases/ReadActionCreator.md | 18 +- docs/type-aliases/ValueOf.md | 13 +- docs/type-aliases/WriteActionCreator.md | 19 +- docs/variables/AdvancedContract.md | 42 +- docs/variables/ERC20.md | 42 +- docs/variables/ERC721.md | 44 +- docs/variables/ErrorContract.md | 51 ++- docs/variables/SimpleContract.md | 44 +- package.json | 3 + pnpm-lock.yaml | 403 +++++++++++++++++- site/package.json | 2 +- site/src/components/EcosystemGrid.tsx | 2 +- site/src/pages/ecosystem.mdx | 7 +- site/src/pages/getting-started.mdx | 17 +- site/src/pages/index.mdx | 2 +- site/vocs.config.ts | 4 +- src/Contract.ts | 66 +-- src/CreateContractFn.ts | 52 +-- src/CreateContractParams.ts | 10 +- src/contract-lib/AdvancedContract.s.sol.ts | 2 +- src/contract-lib/ERC20.ts | 37 +- src/contract-lib/ERC721.ts | 38 +- src/contract-lib/SimpleContract.s.sol.ts | 40 +- src/contract-lib/index.spec.ts | 36 ++ src/createContract.js | 48 +-- src/event/EventActionCreator.ts | 39 +- src/event/eventFactory.js | 10 +- src/read/ReadActionCreator.ts | 14 +- src/read/readFactory.js | 14 +- src/write/WriteActionCreator.ts | 15 +- src/write/writeFactory.js | 15 +- typedoc.json | 1 + vitest.config.ts | 3 +- 47 files changed, 1034 insertions(+), 532 deletions(-) delete mode 100644 docs/_media/LICENSE delete mode 100644 docs/globals.md create mode 100644 src/contract-lib/index.spec.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f02e33e..d617f27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,15 +14,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Set up pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 with: version: 9.15.9 - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v7 with: node-version: 24 cache: pnpm @@ -39,5 +39,8 @@ jobs: - name: Build run: pnpm build - - name: Test - run: pnpm test + - name: Validate published package + run: pnpm check:package + + - name: Test with coverage + run: pnpm test:coverage diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e26cd33..f5bf2d5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -28,15 +28,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Set up pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 with: version: 9.15.9 - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v7 with: node-version: 24 cache: pnpm @@ -48,7 +48,7 @@ jobs: run: pnpm docs:build - name: Upload build output - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: docs-dist path: site/dist/public @@ -66,15 +66,15 @@ jobs: url: https://contract.tevm.sh steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Set up pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 with: version: 9.15.9 - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v7 with: node-version: 24 cache: pnpm @@ -85,10 +85,10 @@ jobs: VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} run: | - if [ -z "$VERCEL_TOKEN" ]; then - echo "::warning::VERCEL_TOKEN is not set; skipping deploy." - exit 0 + if [ -z "$VERCEL_ORG_ID" ] || [ -z "$VERCEL_PROJECT_ID" ] || [ -z "$VERCEL_TOKEN" ]; then + echo "::error::VERCEL_ORG_ID, VERCEL_PROJECT_ID, and VERCEL_TOKEN are required." + exit 1 fi - npx --yes vercel@latest pull --yes --environment=production --token="$VERCEL_TOKEN" --cwd site - npx --yes vercel@latest build --prod --token="$VERCEL_TOKEN" --cwd site - npx --yes vercel@latest deploy --prebuilt --prod --token="$VERCEL_TOKEN" --cwd site + npx --yes vercel@58.4.0 pull --yes --environment=production --token="$VERCEL_TOKEN" --cwd site + npx --yes vercel@58.4.0 build --prod --token="$VERCEL_TOKEN" --cwd site + npx --yes vercel@58.4.0 deploy --prebuilt --prod --token="$VERCEL_TOKEN" --cwd site diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b6b549..f45268b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,21 +19,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Set up pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 with: version: 9.15.9 - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v7 with: node-version: 24 cache: pnpm - registry-url: https://registry.npmjs.org - name: Ensure npm supports provenance run: npm install --global npm@latest @@ -41,6 +40,21 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile + - name: Lint + run: pnpm lint + + - name: Typecheck + run: pnpm typecheck + + - name: Build + run: pnpm build + + - name: Validate published package + run: pnpm check:package + + - name: Test with coverage + run: pnpm test:coverage + - name: Create release PR or publish uses: changesets/action@v1 with: @@ -50,5 +64,3 @@ jobs: title: "chore: version packages" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 93171eb..e527f34 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # @tevm/contract `@tevm/contract` is Tevm's shared, type-safe contract kernel. It defines the contract surface used by both the -[Tevm core node](https://github.com/evmts/tevm-monorepo) and Tevm's bundler packages, so contract descriptions and +[Tevm core node](https://github.com/evmts/tevm) and Tevm's bundler packages, so contract descriptions and generated actions have one stable representation across the ecosystem. This repository is the standalone home of the package formerly maintained at `packages/contract` in the Tevm @@ -16,6 +16,10 @@ pnpm add @tevm/contract The package does not require a Tevm node at runtime. Consumers that execute the actions produced here should install the appropriate Tevm client separately. +The package temporarily consumes the published `@tevm/utils` compatibility package from Tevm core. That dependency +will be replaced by [Voltaire](https://github.com/evmts/voltaire); there is intentionally no standalone +`tevm-utils` repository. + ## Usage ```ts diff --git a/biome.json b/biome.json index cd8acc3..3e38d19 100644 --- a/biome.json +++ b/biome.json @@ -87,7 +87,7 @@ "linter": { "enabled": true, "rules": { - "recommended": true, + "preset": "recommended", "style": { "useImportType": "off", "noNonNullAssertion": "off" @@ -99,7 +99,8 @@ "complexity": { "noForEach": "off", "noBannedTypes": "off", - "useLiteralKeys": "off" + "useLiteralKeys": "off", + "noImportantStyles": "off" }, "suspicious": { "noExplicitAny": "off", diff --git a/docs/README.md b/docs/README.md index ab01c01..213d0d9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,36 +2,27 @@ *** -

- - - - wagmi logo - - -

+# @tevm/contract -

- Execute solidity scripts in browser -

+## Type Aliases -[![CI](https://github.com/evmts/tevm-monorepo/actions/workflows/e2e.yml/badge.svg)](https://github.com/evmts/tevm-monorepo/actions/workflows/e2e.yml) -[![CI](https://github.com/evmts/tevm-monorepo/actions/workflows/unit.yml/badge.svg)](https://github.com/evmts/tevm-monorepo/actions/workflows/unit.yml) - - - - - - +- [Contract](type-aliases/Contract.md) +- [CreateContractFn](type-aliases/CreateContractFn.md) +- [CreateContractParams](type-aliases/CreateContractParams.md) +- [EventActionCreator](type-aliases/EventActionCreator.md) +- [MaybeExtractEventArgsFromAbi](type-aliases/MaybeExtractEventArgsFromAbi.md) +- [ReadActionCreator](type-aliases/ReadActionCreator.md) +- [ValueOf](type-aliases/ValueOf.md) +- [WriteActionCreator](type-aliases/WriteActionCreator.md) -# tevm-monorepo +## Variables -tevm enables direct evm execution clientside with forge cheat codes and direct solidity file imports. +- [AdvancedContract](variables/AdvancedContract.md) +- [ERC20](variables/ERC20.md) +- [ERC721](variables/ERC721.md) +- [ErrorContract](variables/ErrorContract.md) +- [SimpleContract](variables/SimpleContract.md) -## Visit [Docs](https://tevm.sh/) for docs, guides, API and more! +## Functions -## See [Tevm Beta project board](https://github.com/orgs/tevm/projects/1) for progress on the upcoming beta release - -## License ๐Ÿ“„ - - +- [createContract](functions/createContract.md) diff --git a/docs/_media/LICENSE b/docs/_media/LICENSE deleted file mode 100644 index b5a4fa7..0000000 --- a/docs/_media/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -(The MIT License) - -Copyright 2020-2022 - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/docs/functions/createContract.md b/docs/functions/createContract.md index 6c7bc57..513534e 100644 --- a/docs/functions/createContract.md +++ b/docs/functions/createContract.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / createContract +[@tevm/contract](../README.md) / createContract # Function: createContract() > **createContract**\<`TName`, `TAbi`, `TAddress`, `TBytecode`, `TDeployedBytecode`, `TCode`, `THumanReadableAbi`\>(`__namedParameters`): [`Contract`](../type-aliases/Contract.md)\<`TName`, `THumanReadableAbi`, `TAddress`, `TBytecode`, `TDeployedBytecode`, `TCode`\> -Defined in: [createContract.js:73](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/createContract.js#L73) +Defined in: [createContract.js:73](https://github.com/evmts/tevm-contract/blob/main/src/createContract.js#L73) Creates a Tevm Contract instance from a human-readable ABI or JSON ABI. This function is the core of Tevm's contract interaction capabilities, @@ -40,11 +40,19 @@ allowing for type-safe and easy-to-use contract interfaces. If neither humanReadableAbi nor abi is provided. +## Throws + +If `address` is not a valid Ethereum address. + +## Throws + +If a human-readable ABI item cannot be parsed. + ## Examples Using a human-readable ABI: ```typescript -import { createContract } from 'tevm/contract' +import { createContract } from '@tevm/contract' const contract = createContract({ name: 'ERC20', @@ -56,46 +64,44 @@ const contract = createContract({ address: '0x6B175474E89094C44Da98b954EedeAC495271d0F' // DAI token address }) -// Read contract state -const balanceAction = contract.read.balanceOf('0x1234...') -const balance = await tevm.contract(balanceAction) - -// Write to contract -const transferAction = contract.write.transfer('0x5678...', 1000n) -const result = await tevm.contract(transferAction) - -// Create event filter -const transferFilter = contract.events.Transfer({ fromBlock: 'latest' }) -const logs = await tevm.eth.getLogs(transferFilter) +const balanceAction = contract.read.balanceOf( + '0x0000000000000000000000000000000000000001', +) +const transferAction = contract.write.transfer( + '0x0000000000000000000000000000000000000002', + 1000n, +) +const transferFilter = contract.events.Transfer({ + fromBlock: 'latest', + args: { from: contract.address }, +}) ``` Using a JSON ABI: ```typescript -import { createContract } from 'tevm/contract' +import { createContract } from '@tevm/contract' const contract = createContract({ name: 'ERC20', abi: [ { - "inputs": [{"name": "account", "type": "address"}], - "name": "balanceOf", - "outputs": [{"type": "uint256"}], - "stateMutability": "view", - "type": "function" + inputs: [{ name: 'account', type: 'address' }], + name: 'balanceOf', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', }, - // ... other ABI entries - ], + ] as const, address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', - bytecode: '0x60806040...', // Optional: Creation bytecode - deployedBytecode: '0x608060405...', // Optional: Deployed bytecode - code: '0x608060405...' // Optional: Runtime bytecode }) -// Use the contract as in the previous example +const action = contract.read.balanceOf( + '0x0000000000000000000000000000000000000001', +) ``` ## See - [Contract](../type-aliases/Contract.md) for the full API of the returned Contract instance. - - [https://tevm.sh/learn/contracts/](https://tevm.sh/learn/contracts/) for more information on working with contracts in Tevm. - - [https://tevm.sh/reference/tevm/contract/types/Contract/](https://tevm.sh/reference/tevm/contract/types/Contract/) for detailed Contract type documentation. + - [https://contract.tevm.sh/guides/creating-contracts](https://contract.tevm.sh/guides/creating-contracts) for more information on working with contracts in Tevm. + - [https://contract.tevm.sh/api/contract](https://contract.tevm.sh/api/contract) for detailed Contract type documentation. diff --git a/docs/globals.md b/docs/globals.md deleted file mode 100644 index f89582e..0000000 --- a/docs/globals.md +++ /dev/null @@ -1,28 +0,0 @@ -[**@tevm/contract**](README.md) - -*** - -# @tevm/contract - -## Type Aliases - -- [Contract](type-aliases/Contract.md) -- [CreateContractFn](type-aliases/CreateContractFn.md) -- [CreateContractParams](type-aliases/CreateContractParams.md) -- [EventActionCreator](type-aliases/EventActionCreator.md) -- [MaybeExtractEventArgsFromAbi](type-aliases/MaybeExtractEventArgsFromAbi.md) -- [ReadActionCreator](type-aliases/ReadActionCreator.md) -- [ValueOf](type-aliases/ValueOf.md) -- [WriteActionCreator](type-aliases/WriteActionCreator.md) - -## Variables - -- [AdvancedContract](variables/AdvancedContract.md) -- [ERC20](variables/ERC20.md) -- [ERC721](variables/ERC721.md) -- [ErrorContract](variables/ErrorContract.md) -- [SimpleContract](variables/SimpleContract.md) - -## Functions - -- [createContract](functions/createContract.md) diff --git a/docs/type-aliases/Contract.md b/docs/type-aliases/Contract.md index 05a792d..e2f6c2d 100644 --- a/docs/type-aliases/Contract.md +++ b/docs/type-aliases/Contract.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / Contract +[@tevm/contract](../README.md) / Contract # Type Alias: Contract\ > **Contract**\<`TName`, `THumanReadableAbi`, `TAddress`, `TBytecode`, `TDeployedBytecode`, `TCode`\> = `object` -Defined in: [Contract.ts:62](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L62) +Defined in: [Contract.ts:75](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L75) Represents a specific contract with its ABI and optional bytecode. Contracts provide type-safe interfaces for interacting with smart contracts, @@ -18,7 +18,11 @@ including read and write methods, event filtering, and deployment. Creating and using a Contract instance: ```typescript -import { createContract } from 'tevm/contract' +import { createContract } from '@tevm/contract' +import { createMemoryClient } from 'tevm' + +const client = createMemoryClient() +await client.tevmReady() const MyContract = createContract({ name: 'MyToken', @@ -31,30 +35,39 @@ const MyContract = createContract({ }) // Read contract state -const balanceAction = MyContract.read.balanceOf('0xabcdef...') -const balance = await tevm.contract(balanceAction) +const { data: balance } = await client.tevmContract( + MyContract.read.balanceOf('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045') +) // Write to contract -const transferAction = MyContract.write.transfer('0xfedcba...', 1000n) -const result = await tevm.contract(transferAction) +const result = await client.tevmContract( + MyContract.write.transfer('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 1000n) +) // Create event filter -const transferFilter = MyContract.events.Transfer({ fromBlock: 'latest' }) -const logs = await tevm.eth.getLogs(transferFilter) +const logs = await client.getLogs( + MyContract.events.Transfer({ fromBlock: 'latest' }) +) ``` Using with other libraries: ```typescript +import { createContract } from '@tevm/contract' import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' +const MyContract = createContract({ + humanReadableAbi: ['function balanceOf(address account) view returns (uint256)'], + address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', +}) + const client = createPublicClient({ chain: mainnet, transport: http() }) const balance = await client.readContract( - MyContract.read.balanceOf('0xabcdef...') + MyContract.read.balanceOf('0x0000000000000000000000000000000000000001') ) ``` @@ -73,16 +86,16 @@ const balance = await client.readContract( | Property | Type | Description | Defined in | | ------ | ------ | ------ | ------ | -| `abi` | `ParseAbi`\<`THumanReadableAbi`\> | The JSON ABI of the contract. **Example** `console.log(MyContract.abi) // [{name: 'balanceOf', inputs: [...], outputs: [...], ...}]` | [Contract.ts:84](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L84) | -| `address` | `TAddress` | The configured address of the contract. If not set, it will be undefined. Use the `withAddress` method to set or change the address. | [Contract.ts:74](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L74) | -| `bytecode` | `TBytecode` | The creation bytecode of the contract. | [Contract.ts:94](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L94) | -| `code` | `TCode` | The runtime bytecode of the contract, encoded with constructor arguments. | [Contract.ts:89](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L89) | -| `deploy` | (...`args`) => `EncodeDeployDataParameters`\<`ParseAbi`\<`THumanReadableAbi`\>\> | Action creator for deploying the contract. **Example** `const deployAction = MyContract.deploy('Constructor', 'Args') const deployedContract = await tevm.contract(deployAction)` | [Contract.ts:154](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L154) | -| `deployedBytecode` | `TDeployedBytecode` | The deployed bytecode of the contract. | [Contract.ts:99](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L99) | -| `events` | [`EventActionCreator`](EventActionCreator.md)\<`THumanReadableAbi`, `TBytecode`, `TDeployedBytecode`, `TAddress`\> | Action creators for events. Used to create event filters in a type-safe way. **Example** `const transferFilter = MyContract.events.Transfer({ from: '0x1234...' }) const logs = await tevm.eth.getLogs(transferFilter)` | [Contract.ts:124](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L124) | -| `humanReadableAbi` | `THumanReadableAbi` | The human-readable ABI of the contract. **Example** `console.log(MyContract.humanReadableAbi) // ['function balanceOf(address): uint256', ...]` | [Contract.ts:109](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L109) | -| `name?` | `TName` | The name of the contract. If imported, this will match the name of the contract import. | [Contract.ts:114](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L114) | -| `read` | [`ReadActionCreator`](ReadActionCreator.md)\<`THumanReadableAbi`, `TAddress`, `TCode`\> | Action creators for contract view and pure functions. **Example** `const balanceAction = MyContract.read.balanceOf('0x1234...') const balance = await tevm.contract(balanceAction)` | [Contract.ts:134](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L134) | -| `withAddress` | \<`TNewAddress`\>(`address`) => `Contract`\<`TName`, `THumanReadableAbi`, `TNewAddress`, `TBytecode`, `TDeployedBytecode`, `TCode`\> | Adds an address to the contract. All action creators will include the address property if added. This method returns a new contract; it does not modify the existing contract. **Example** `const MyContractWithAddress = MyContract.withAddress('0x1234...')` | [Contract.ts:171](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L171) | -| `withCode` | (`encodedBytecode`) => `Contract`\<`TName`, `THumanReadableAbi`, `TAddress`, `TBytecode`, `TDeployedBytecode`, `Hex`\> | Updates the bytecode of the contract. Returns a new contract instance with the updated code. **Example** `import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http() }) const ADDRESS = '0x6B175474E89094C44Da98b954EedeAC495271d0F' const UpdatedContract = Contract.withCode('0x60806040...') const {data, abi, code, args} = UpdatedContract.read.balanceOf('0x1234567890123456789012345678901234567890') const balance = await client.call({ to: ADDRESS, data, abi, code, args })` | [Contract.ts:202](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L202) | -| `write` | [`WriteActionCreator`](WriteActionCreator.md)\<`THumanReadableAbi`, `TAddress`, `TCode`\> | Action creators for contract payable and nonpayable functions. **Example** `const transferAction = MyContract.write.transfer('0x5678...', 1000n) const result = await tevm.contract(transferAction)` | [Contract.ts:144](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/Contract.ts#L144) | +| `abi` | `ParseAbi`\<`THumanReadableAbi`\> | The JSON ABI of the contract. **Example** `import { ERC20 } from '@tevm/contract' console.log(ERC20.abi.find((item) => item.type === 'function' && item.name === 'balanceOf')) // { name: 'balanceOf', inputs: [...], outputs: [...], ... }` | [Contract.ts:99](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L99) | +| `address` | `TAddress` | The configured address of the contract. If not set, it will be undefined. Use the `withAddress` method to set or change the address. | [Contract.ts:87](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L87) | +| `bytecode` | `TBytecode` | The creation bytecode of the contract. | [Contract.ts:109](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L109) | +| `code` | `TCode` | The runtime bytecode of the contract, encoded with constructor arguments. | [Contract.ts:104](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L104) | +| `deploy` | (...`args`) => `EncodeDeployDataParameters`\<`ParseAbi`\<`THumanReadableAbi`\>\> | Builds the parameters needed to deploy the contract. Returns `{ abi, bytecode }`, plus `args` when the constructor takes arguments. Constructor argument types are inferred from the `constructor` entry in the ABI. Requires the contract to have been created with `bytecode`. **Throws** `Bytecode is required to generate deploy data` if the contract has no `bytecode`. This is a runtime check with no type-level guard, so check `contract.bytecode` first when building contracts dynamically. **Example** `import { SimpleContract } from '@tevm/contract' import { createMemoryClient, PREFUNDED_ACCOUNTS } from 'tevm' const client = createMemoryClient() await client.tevmReady() const result = await client.tevmDeploy({ from: PREFUNDED_ACCOUNTS[0].address, ...SimpleContract.deploy(42n), addToMempool: true, }) await client.tevmMine({ blockCount: 1 }) if (!result.createdAddress) throw new Error('deployment failed') const counter = SimpleContract.withAddress(result.createdAddress)` | [Contract.ts:205](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L205) | +| `deployedBytecode` | `TDeployedBytecode` | The deployed bytecode of the contract. | [Contract.ts:114](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L114) | +| `events` | [`EventActionCreator`](EventActionCreator.md)\<`THumanReadableAbi`, `TBytecode`, `TDeployedBytecode`, `TAddress`\> | Action creators for events. Used to create event filters in a type-safe way. **Example** `import { ERC20 } from '@tevm/contract' const transferFilter = ERC20.events.Transfer({ args: { from: '0x0000000000000000000000000000000000000001' }, })` | [Contract.ts:144](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L144) | +| `humanReadableAbi` | `THumanReadableAbi` | The human-readable ABI of the contract. **Example** `import { ERC20 } from '@tevm/contract' console.log(ERC20.humanReadableAbi) // ['constructor(string name, string symbol)', ...]` | [Contract.ts:126](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L126) | +| `name?` | `TName` | The name of the contract. If imported, this will match the name of the contract import. | [Contract.ts:131](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L131) | +| `read` | [`ReadActionCreator`](ReadActionCreator.md)\<`THumanReadableAbi`, `TAddress`, `TCode`\> | Action creators for contract view and pure functions. **Example** `import { ERC20 } from '@tevm/contract' const token = ERC20.withAddress('0x6B175474E89094C44Da98b954EedeAC495271d0F') const balanceAction = token.read.balanceOf( '0x0000000000000000000000000000000000000001', )` | [Contract.ts:158](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L158) | +| `withAddress` | \<`TNewAddress`\>(`address`) => `Contract`\<`TName`, `THumanReadableAbi`, `TNewAddress`, `TBytecode`, `TDeployedBytecode`, `TCode`\> | Adds an address to the contract. All action creators will include the `address` and `to` properties once added. This method returns a new contract; it does not modify the existing contract. The address is checksummed with `getAddress` before being stored, so `contract.address` is always EIP-55 regardless of the casing passed in. **Throws** If the address is not a valid Ethereum address. **Example** `import { ERC20 } from '@tevm/contract' const Dai = ERC20.withAddress('0x6b175474e89094c44da98b954eedeac495271d0f') console.log(Dai.address) // '0x6B175474E89094C44Da98b954EedeAC495271d0F' โ€” checksummed console.log(ERC20.address) // undefined โ€” the original is untouched` | [Contract.ts:234](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L234) | +| `withCode` | (`encodedBytecode`) => `Contract`\<`TName`, `THumanReadableAbi`, `TAddress`, `TBytecode`, `TDeployedBytecode`, `Hex`\> | Updates the bytecode of the contract. Returns a new contract instance with the updated code. **Example** `import { SimpleContract } from '@tevm/contract' const local = SimpleContract.withCode('0x6000') const action = local.read.get() console.log(action.code) // '0x6000'` | [Contract.ts:252](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L252) | +| `write` | [`WriteActionCreator`](WriteActionCreator.md)\<`THumanReadableAbi`, `TAddress`, `TCode`\> | Action creators for contract payable and nonpayable functions. **Example** `import { ERC20 } from '@tevm/contract' const token = ERC20.withAddress('0x6B175474E89094C44Da98b954EedeAC495271d0F') const transferAction = token.write.transfer( '0x0000000000000000000000000000000000000001', 1000n, )` | [Contract.ts:173](https://github.com/evmts/tevm-contract/blob/main/src/Contract.ts#L173) | diff --git a/docs/type-aliases/CreateContractFn.md b/docs/type-aliases/CreateContractFn.md index 56c3a21..a380c95 100644 --- a/docs/type-aliases/CreateContractFn.md +++ b/docs/type-aliases/CreateContractFn.md @@ -2,7 +2,7 @@ *** -[@tevm/contract](../globals.md) / CreateContractFn +[@tevm/contract](../README.md) / CreateContractFn # Type Alias: CreateContractFn @@ -14,7 +14,7 @@ code, }`) => [`Contract`](Contract.md)\<`TName`, `THumanReadableAbi`, `TAddress`, `TBytecode`, `TDeployedBytecode`, `TCode`\> -Defined in: [CreateContractFn.ts:77](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/CreateContractFn.ts#L77) +Defined in: [CreateContractFn.ts:59](https://github.com/evmts/tevm-contract/blob/main/src/CreateContractFn.ts#L59) Type of `createContract` factory function. Creates a tevm Contract instance from a human readable ABI or JSON ABI. @@ -45,9 +45,9 @@ Creates a tevm Contract instance from a human readable ABI or JSON ABI. Using a human readable ABI: ```typescript -import { type Contract, createContract } from 'tevm/contract' +import { createContract } from '@tevm/contract' -const contract: Contract = createContract({ +const contract = createContract({ name: 'ERC20', humanReadableAbi: [ 'function balanceOf(address owner) view returns (uint256)', @@ -57,47 +57,37 @@ const contract: Contract = createContract({ }) ``` -Using a JSON ABI (needs to be formatted): +Using a JSON ABI: ```typescript -import { type Contract, createContract } from 'tevm/contract' -import { formatAbi } from '@tevm/utils' +import { createContract } from '@tevm/contract' const jsonAbi = [ { - "inputs": [{"name": "owner", "type": "address"}], - "name": "balanceOf", - "outputs": [{"type": "uint256"}], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - {"name": "to", "type": "address"}, - {"name": "amount", "type": "uint256"} - ], - "name": "transfer", - "outputs": [{"type": "bool"}], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "anonymous": false, - "inputs": [ - {"indexed": true, "name": "from", "type": "address"}, - {"indexed": true, "name": "to", "type": "address"}, - {"indexed": false, "name": "value", "type": "uint256"} - ], - "name": "Transfer", - "type": "event" + inputs: [{ name: 'owner', type: 'address' }], + name: 'balanceOf', + outputs: [{ type: 'uint256' }], + stateMutability: 'view', + type: 'function', } -] +] as const const contract = createContract({ name: 'ERC20', - abi: formatAbi(jsonAbi), + abi: jsonAbi, address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', // DAI token address on Ethereum mainnet - bytecode: '0x60806040526000805534801561001457600080fd5b50610771806100246000396000f3fe', // Example bytecode (truncated) - deployedBytecode: '0x608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101bc', // Example deployed bytecode (truncated) - code: '0x608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101bc', // Example runtime code (truncated) }) + +const action = contract.read.balanceOf('0x0000000000000000000000000000000000000001') ``` + +## Throws + +If neither `humanReadableAbi` nor `abi` is supplied at runtime. + +## Throws + +If `address` is not a valid Ethereum address. + +## Throws + +If a human-readable ABI item cannot be parsed. diff --git a/docs/type-aliases/CreateContractParams.md b/docs/type-aliases/CreateContractParams.md index 9936da4..9f826f0 100644 --- a/docs/type-aliases/CreateContractParams.md +++ b/docs/type-aliases/CreateContractParams.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / CreateContractParams +[@tevm/contract](../README.md) / CreateContractParams # Type Alias: CreateContractParams\ > **CreateContractParams**\<`TName`, `TAbi`, `TAddress`, `TBytecode`, `TDeployedBytecode`, `TCode`\> = \{ `abi?`: `never`; `address?`: `TAddress`; `bytecode?`: `TBytecode`; `code?`: `TCode`; `deployedBytecode?`: `TDeployedBytecode`; `humanReadableAbi`: `TAbi` *extends* readonly `string`[] ? `TAbi` : `FormatAbi`\<`TAbi`\>; `name?`: `TName`; \} \| \{ `abi`: `TAbi` *extends* readonly `string`[] ? `ParseAbi`\<`TAbi`\> : `TAbi` *extends* `Abi` ? `TAbi` : `never`; `address?`: `TAddress`; `bytecode?`: `TBytecode`; `code?`: `TCode`; `deployedBytecode?`: `TDeployedBytecode`; `humanReadableAbi?`: `never`; `name?`: `TName`; \} -Defined in: [CreateContractParams.ts:49](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/CreateContractParams.ts#L49) +Defined in: [CreateContractParams.ts:57](https://github.com/evmts/tevm-contract/blob/main/src/CreateContractParams.ts#L57) Parameters for creating a [Contract](Contract.md) instance. This type allows for two mutually exclusive ways of specifying the ABI: @@ -119,12 +119,14 @@ Optional name of the contract ## See -CreateContract +[createContract](../functions/createContract.md) ## Examples Using human-readable ABI: ```typescript +import type { CreateContractParams } from '@tevm/contract' + const params: CreateContractParams = { name: 'ERC20', humanReadableAbi: [ @@ -137,6 +139,8 @@ const params: CreateContractParams = { Using JSON ABI: ```typescript +import type { CreateContractParams } from '@tevm/contract' + const params: CreateContractParams = { name: 'ERC20', abi: [ @@ -151,3 +155,12 @@ const params: CreateContractParams = { address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', } ``` + +## Throws + +The `createContract` implementation throws if neither ABI form +is supplied by untyped JavaScript. + +## Throws + +The `createContract` implementation throws if `address` is invalid. diff --git a/docs/type-aliases/EventActionCreator.md b/docs/type-aliases/EventActionCreator.md index 3c675af..68a3cde 100644 --- a/docs/type-aliases/EventActionCreator.md +++ b/docs/type-aliases/EventActionCreator.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / EventActionCreator +[@tevm/contract](../README.md) / EventActionCreator # Type Alias: EventActionCreator\ > **EventActionCreator**\<`THumanReadableAbi`, `TBytecode`, `TDeployedBytecode`, `TAddress`, `TAddressArgs`\> = \{ \[TEventName in ExtractAbiEventNames\\>\]: (params: Pick\, TEventName\>, ParseAbi\, TStrict, TFromBlock, TToBlock, TEventName, MaybeExtractEventArgsFromAbi\, TEventName\>\>, "fromBlock" \| "toBlock" \| "args" \| "strict"\>) =\> CreateEventFilterParameters\, TEventName\>, ParseAbi\, TStrict, TFromBlock, TToBlock, TEventName, MaybeExtractEventArgsFromAbi\, TEventName\>\> & \{ abi: \[ExtractAbiEvent\, TEventName\>\]; bytecode: TBytecode; deployedBytecode: TDeployedBytecode; eventName: TEventName \} & \{ abi: \[ExtractAbiEvent\, TEventName\>\]; bytecode: TBytecode; deployedBytecode: TDeployedBytecode; eventName: TEventName; humanReadableAbi: FormatAbi\<\[ExtractAbiEvent\, TEventName\>\]\> \} & TAddressArgs \} -Defined in: [event/EventActionCreator.ts:56](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/event/EventActionCreator.ts#L56) +Defined in: [event/EventActionCreator.ts:83](https://github.com/evmts/tevm-contract/blob/main/src/event/EventActionCreator.ts#L83) A mapping of event names to action creators for events. Can be used to create event filters in a typesafe way. @@ -25,13 +25,21 @@ A mapping of event names to action creators for events. Can be used to create ev ## Example ```typescript -// Creating an event filter for a Transfer event -const filter = MyContract.events.Transfer({ +import { createContract } from '@tevm/contract' + +const Token = createContract({ + humanReadableAbi: [ + 'event Transfer(address indexed from, address indexed to, uint256 value)', + ], + address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', +}) + +const filter = Token.events.Transfer({ fromBlock: 'latest', toBlock: 'latest', - args: { from: '0x1234...', to: '0x5678...' } + args: { + from: '0x0000000000000000000000000000000000000001', + to: '0x0000000000000000000000000000000000000002', + }, }) - -// Using the filter with tevm -const logs = await tevm.eth.getLogs(filter) ``` diff --git a/docs/type-aliases/MaybeExtractEventArgsFromAbi.md b/docs/type-aliases/MaybeExtractEventArgsFromAbi.md index 2facd15..d1f7ad1 100644 --- a/docs/type-aliases/MaybeExtractEventArgsFromAbi.md +++ b/docs/type-aliases/MaybeExtractEventArgsFromAbi.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / MaybeExtractEventArgsFromAbi +[@tevm/contract](../README.md) / MaybeExtractEventArgsFromAbi # Type Alias: MaybeExtractEventArgsFromAbi\ > **MaybeExtractEventArgsFromAbi**\<`TAbi`, `TEventName`\> = `TAbi` *extends* `Abi` \| readonly `unknown`[] ? `TEventName` *extends* `string` ? `GetEventArgs`\<`TAbi`, `TEventName`\> : `undefined` : `undefined` -Defined in: [event/EventActionCreator.ts:20](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/event/EventActionCreator.ts#L20) +Defined in: [event/EventActionCreator.ts:31](https://github.com/evmts/tevm-contract/blob/main/src/event/EventActionCreator.ts#L31) Extracts event arguments from an ABI. @@ -18,3 +18,15 @@ Extracts event arguments from an ABI. | ------ | ------ | | `TAbi` *extends* `Abi` \| readonly `unknown`[] \| `undefined` | The ABI type, can be an Abi, readonly unknown[], or undefined. | | `TEventName` *extends* `string` \| `undefined` | The name of the event, can be a string or undefined. | + +## Example + +```typescript +import type { MaybeExtractEventArgsFromAbi } from '@tevm/contract' +import type { ParseAbi } from '@tevm/utils' + +type TransferArgs = MaybeExtractEventArgsFromAbi< + ParseAbi<['event Transfer(address indexed from, address indexed to, uint256 value)']>, + 'Transfer' +> +``` diff --git a/docs/type-aliases/ReadActionCreator.md b/docs/type-aliases/ReadActionCreator.md index da85874..6f1826e 100644 --- a/docs/type-aliases/ReadActionCreator.md +++ b/docs/type-aliases/ReadActionCreator.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / ReadActionCreator +[@tevm/contract](../README.md) / ReadActionCreator # Type Alias: ReadActionCreator\ > **ReadActionCreator**\<`THumanReadableAbi`, `TAddress`, `TCode`, `TAddressArgs`\> = \{ \[TFunctionName in ExtractAbiFunctionNames\, "pure" \| "view"\>\]: (args: TArgs) =\> \{ abi: \[ExtractAbiFunction\, TFunctionName\>\]; functionName: TFunctionName; humanReadableAbi: FormatAbi\<\[ExtractAbiFunction\, TFunctionName\>\]\> \} & (TCode extends undefined ? \{\} : \{ code: TCode \}) & (TArgs\["length"\] extends 0 ? \{\} : \{ args: TArgs \}) & TAddressArgs & \{ abi: \[ExtractAbiFunction\, TFunctionName\>\]; functionName: TFunctionName; humanReadableAbi: FormatAbi\<\[ExtractAbiFunction\, TFunctionName\>\]\> \} & (TCode extends undefined ? \{\} : \{ code: TCode \}) & TAddressArgs \} -Defined in: [read/ReadActionCreator.ts:36](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/read/ReadActionCreator.ts#L36) +Defined in: [read/ReadActionCreator.ts:40](https://github.com/evmts/tevm-contract/blob/main/src/read/ReadActionCreator.ts#L40) A mapping of view and pure contract methods to action creators. This type provides a way to create type-safe read actions for contract methods. @@ -25,10 +25,14 @@ This type provides a way to create type-safe read actions for contract methods. ## Example ```typescript -// Assuming we have a contract with a 'balanceOf' method -const balanceAction = MyContract.read.balanceOf('0x1234...') +import { createContract } from '@tevm/contract' -// Use the action with tevm -const balance = await tevm.contract(balanceAction) -console.log('Balance:', balance) +const Token = createContract({ + humanReadableAbi: ['function balanceOf(address account) view returns (uint256)'], + address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', +}) + +const balanceAction = Token.read.balanceOf( + '0x0000000000000000000000000000000000000001', +) ``` diff --git a/docs/type-aliases/ValueOf.md b/docs/type-aliases/ValueOf.md index 3319243..fe38d6f 100644 --- a/docs/type-aliases/ValueOf.md +++ b/docs/type-aliases/ValueOf.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / ValueOf +[@tevm/contract](../README.md) / ValueOf # Type Alias: ValueOf\ > **ValueOf**\<`T`\> = `T`\[keyof `T`\] -Defined in: [event/EventActionCreator.ts:33](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/event/EventActionCreator.ts#L33) +Defined in: [event/EventActionCreator.ts:52](https://github.com/evmts/tevm-contract/blob/main/src/event/EventActionCreator.ts#L52) Utility type to get the value type of an object. @@ -17,3 +17,12 @@ Utility type to get the value type of an object. | Type Parameter | Description | | ------ | ------ | | `T` | The object type. | + +## Example + +```typescript +import type { ValueOf } from '@tevm/contract' + +type Status = ValueOf<{ ready: 'ready'; failed: 'failed' }> +// 'ready' | 'failed' +``` diff --git a/docs/type-aliases/WriteActionCreator.md b/docs/type-aliases/WriteActionCreator.md index 492e66c..429848b 100644 --- a/docs/type-aliases/WriteActionCreator.md +++ b/docs/type-aliases/WriteActionCreator.md @@ -2,13 +2,13 @@ *** -[@tevm/contract](../globals.md) / WriteActionCreator +[@tevm/contract](../README.md) / WriteActionCreator # Type Alias: WriteActionCreator\ > **WriteActionCreator**\<`THumanReadableAbi`, `TAddress`, `TCode`, `TAddressArgs`\> = \{ \[TFunctionName in ExtractAbiFunctionNames\, "payable" \| "nonpayable"\>\]: (args: TArgs) =\> \{ abi: \[ExtractAbiFunction\, TFunctionName\>\]; address: TAddress; functionName: TFunctionName; humanReadableAbi: FormatAbi\<\[ExtractAbiFunction\, TFunctionName\>\]\>; to: TAddress \} & (TCode extends undefined ? \{\} : \{ code: TCode \}) & (TArgs\["length"\] extends 0 ? \{\} : \{ args: TArgs \}) & TAddressArgs & \{ abi: \[ExtractAbiFunction\, TFunctionName\>\]; functionName: TFunctionName; humanReadableAbi: FormatAbi\<\[ExtractAbiFunction\, TFunctionName\>\]\> \} & (TCode extends undefined ? \{\} : \{ code: TCode \}) & TAddressArgs \} -Defined in: [write/WriteActionCreator.ts:36](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/write/WriteActionCreator.ts#L36) +Defined in: [write/WriteActionCreator.ts:41](https://github.com/evmts/tevm-contract/blob/main/src/write/WriteActionCreator.ts#L41) A mapping of payable and nonpayable contract methods to action creators. This type provides a way to create type-safe write actions for contract methods. @@ -25,10 +25,15 @@ This type provides a way to create type-safe write actions for contract methods. ## Example ```typescript -// Assuming we have a contract with a 'transfer' method -const transferAction = MyContract.write.transfer('0x1234...', 1000n) +import { createContract } from '@tevm/contract' -// Use the action with tevm -const result = await tevm.contract(transferAction) -console.log('Transaction hash:', result.transactionHash) +const Token = createContract({ + humanReadableAbi: ['function transfer(address to, uint256 amount) returns (bool)'], + address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', +}) + +const transferAction = Token.write.transfer( + '0x0000000000000000000000000000000000000001', + 1000n, +) ``` diff --git a/docs/variables/AdvancedContract.md b/docs/variables/AdvancedContract.md index 0527646..94e77b3 100644 --- a/docs/variables/AdvancedContract.md +++ b/docs/variables/AdvancedContract.md @@ -2,14 +2,50 @@ *** -[@tevm/contract](../globals.md) / AdvancedContract +[@tevm/contract](../README.md) / AdvancedContract # Variable: AdvancedContract > `const` **AdvancedContract**: [`Contract`](../type-aliases/Contract.md)\<`"AdvancedContract"`, readonly \[`"constructor(uint256 initialNumber, bool initialBool, string initialString, address initialAddress)"`, `"event AddressSet(address newValue)"`, `"event AllValuesSet(uint256 number, bool boolean, string str, address addr)"`, `"event BoolSet(bool newValue)"`, `"event DelegateCallResult(uint256 result)"`, `"event ExternalCallResult(uint256 result)"`, `"event NumberSet(uint256 newValue)"`, `"event StringSet(string newValue)"`, `"function callMathHelper(uint256 value) returns (uint256)"`, `"function delegateCallMathHelper(uint256 value) returns (uint256)"`, `"function getAddress() view returns (address)"`, `"function getAllValues() view returns (uint256, bool, string, address)"`, `"function getBool() view returns (bool)"`, `"function getNumber() view returns (uint256)"`, `"function getString() view returns (string)"`, `"function mathHelperAddress() view returns (address)"`, `"function setAddress(address newValue)"`, `"function setAllValues(uint256 newNumber, bool newBool, string newString, address newAddress)"`, `"function setBool(bool newValue)"`, `"function setMathHelperAddress(address newAddress)"`, `"function setNumber(uint256 newValue)"`, `"function setString(string newValue)"`\], `undefined`, `"0x608060405234801561000f575f5ffd5b50604051611c53380380611c538339818101604052810190610031919061032a565b835f819055508260015f6101000a81548160ff021916908315150217905550816002908161005f91906105b1565b508060035f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506040516100ac9061010e565b604051809103905ff0801580156100c5573d5f5f3e3d5ffd5b5060045f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050610680565b6103448061190f83390190565b5f604051905090565b5f5ffd5b5f5ffd5b5f819050919050565b61013e8161012c565b8114610148575f5ffd5b50565b5f8151905061015981610135565b92915050565b5f8115159050919050565b6101738161015f565b811461017d575f5ffd5b50565b5f8151905061018e8161016a565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6101e28261019c565b810181811067ffffffffffffffff82111715610201576102006101ac565b5b80604052505050565b5f61021361011b565b905061021f82826101d9565b919050565b5f67ffffffffffffffff82111561023e5761023d6101ac565b5b6102478261019c565b9050602081019050919050565b8281835e5f83830152505050565b5f61027461026f84610224565b61020a565b9050828152602081018484840111156102905761028f610198565b5b61029b848285610254565b509392505050565b5f82601f8301126102b7576102b6610194565b5b81516102c7848260208601610262565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102f9826102d0565b9050919050565b610309816102ef565b8114610313575f5ffd5b50565b5f8151905061032481610300565b92915050565b5f5f5f5f6080858703121561034257610341610124565b5b5f61034f8782880161014b565b945050602061036087828801610180565b935050604085015167ffffffffffffffff81111561038157610380610128565b5b61038d878288016102a3565b925050606061039e87828801610316565b91505092959194509250565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806103f857607f821691505b60208210810361040b5761040a6103b4565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830261046d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610432565b6104778683610432565b95508019841693508086168417925050509392505050565b5f819050919050565b5f6104b26104ad6104a88461012c565b61048f565b61012c565b9050919050565b5f819050919050565b6104cb83610498565b6104df6104d7826104b9565b84845461043e565b825550505050565b5f5f905090565b6104f66104e7565b6105018184846104c2565b505050565b5b81811015610524576105195f826104ee565b600181019050610507565b5050565b601f8211156105695761053a81610411565b61054384610423565b81016020851015610552578190505b61056661055e85610423565b830182610506565b50505b505050565b5f82821c905092915050565b5f6105895f198460080261056e565b1980831691505092915050565b5f6105a1838361057a565b9150826002028217905092915050565b6105ba826103aa565b67ffffffffffffffff8111156105d3576105d26101ac565b5b6105dd82546103e1565b6105e8828285610528565b5f60209050601f831160018114610619575f8415610607578287015190505b6106118582610596565b865550610678565b601f19841661062786610411565b5f5b8281101561064e57848901518255600182019150602085019450602081019050610629565b8683101561066b5784890151610667601f89168261057a565b8355505b6001600288020188555050505b505050505050565b6112828061068d5f395ff3fe608060405234801561000f575f5ffd5b50600436106100e8575f3560e01c80637fcaf6661161008a578063981f549911610064578063981f549914610220578063d0da9af514610241578063e30081a014610271578063f2c9ecd81461028d576100e8565b80637fcaf666146101c857806389ea642f146101e45780638d5d4de714610202576100e8565b8063349a0054116100c6578063349a00541461014257806338cc48311461015e5780633fb5c1cb1461017c578063575f450514610198576100e8565b806301ef8faa146100ec57806312a7b914146101085780631e26fd3314610126575b5f5ffd5b61010660048036038101906101019190610a51565b6102ab565b005b6101106102ee565b60405161011d9190610a96565b60405180910390f35b610140600480360381019061013b9190610ad9565b610303565b005b61015c60048036038101906101579190610c73565b610356565b005b610166610531565b6040516101739190610d02565b60405180910390f35b61019660048036038101906101919190610d1b565b610559565b005b6101b260048036038101906101ad9190610d1b565b610599565b6040516101bf9190610d55565b60405180910390f35b6101e260048036038101906101dd9190610d6e565b61067c565b005b6101ec6106c6565b6040516101f99190610e15565b60405180910390f35b61020a610756565b6040516102179190610d02565b60405180910390f35b61022861077b565b6040516102389493929190610e35565b60405180910390f35b61025b60048036038101906102569190610d1b565b6107ae565b6040516102689190610d55565b60405180910390f35b61028b60048036038101906102869190610a51565b610964565b005b6102956109de565b6040516102a29190610d55565b60405180910390f35b8060045f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f60015f9054906101000a900460ff16905090565b8060015f6101000a81548160ff0219169083151502179055507fd31368d67652afe87682ed73c60ba1c2f499ae414a86d618c275326b0d6739968160405161034b9190610a96565b60405180910390a150565b3073ffffffffffffffffffffffffffffffffffffffff16633fb5c1cb856040518263ffffffff1660e01b815260040161038f9190610d55565b5f604051808303815f87803b1580156103a6575f5ffd5b505af11580156103b8573d5f5f3e3d5ffd5b505050503073ffffffffffffffffffffffffffffffffffffffff16631e26fd33846040518263ffffffff1660e01b81526004016103f59190610a96565b5f604051808303815f87803b15801561040c575f5ffd5b505af115801561041e573d5f5f3e3d5ffd5b505050503073ffffffffffffffffffffffffffffffffffffffff16637fcaf666836040518263ffffffff1660e01b815260040161045b9190610e15565b5f604051808303815f87803b158015610472575f5ffd5b505af1158015610484573d5f5f3e3d5ffd5b505050503073ffffffffffffffffffffffffffffffffffffffff1663e30081a0826040518263ffffffff1660e01b81526004016104c19190610d02565b5f604051808303815f87803b1580156104d8575f5ffd5b505af11580156104ea573d5f5f3e3d5ffd5b505050507fc3e1073869e2f3735605599cbfd67bc84b7ce8f34226501a7c84f1bea115cb0c848484846040516105239493929190610e35565b60405180910390a150505050565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b805f819055507f9ec8254969d1974eac8c74afb0c03595b4ffe0a1d7ad8a7f82ed31b9c85425918160405161058e9190610d55565b60405180910390a150565b5f5f60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505f8173ffffffffffffffffffffffffffffffffffffffff1663c6888fa1856040518263ffffffff1660e01b81526004016105f99190610d55565b6020604051808303815f875af1158015610615573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106399190610e93565b90507f9d164645d2740a65754f47c13dc8efcc8a63d0f41785c4d3cd1dfd289e64a3bc8160405161066a9190610d55565b60405180910390a18092505050919050565b806002908161068b91906110bb565b507fd824731128b3439672eb2a63774a112947e43a4102ef25ba8fe18ad8930a9188816040516106bb9190610e15565b60405180910390a150565b6060600280546106d590610eeb565b80601f016020809104026020016040519081016040528092919081815260200182805461070190610eeb565b801561074c5780601f106107235761010080835404028352916020019161074c565b820191905f5260205f20905b81548152906001019060200180831161072f57829003601f168201915b5050505050905090565b60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f5f60605f6107886109de565b6107906102ee565b6107986106c6565b6107a0610531565b935093509350935090919293565b5f5f826040516024016107c19190610d55565b6040516020818303038152906040527fc6888fa1000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360405161088891906111ce565b5f60405180830381855af49150503d805f81146108c0576040519150601f19603f3d011682016040523d82523d5f602084013e6108c5565b606091505b50915091508161090a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109019061122e565b60405180910390fd5b5f8180602001905181019061091f9190610e93565b90507fb26b3b59a9756bf7416fe9326c05726fbfe955ce9e948f70da7a91f4978fb4d2816040516109509190610d55565b60405180910390a180945050505050919050565b8060035f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f88749aed52403b3a8ec7763273d5665190617f46de93b08aab1cc6ec80dc2fb4816040516109d39190610d02565b60405180910390a150565b5f5f54905090565b5f604051905090565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a20826109f7565b9050919050565b610a3081610a16565b8114610a3a575f5ffd5b50565b5f81359050610a4b81610a27565b92915050565b5f60208284031215610a6657610a656109ef565b5b5f610a7384828501610a3d565b91505092915050565b5f8115159050919050565b610a9081610a7c565b82525050565b5f602082019050610aa95f830184610a87565b92915050565b610ab881610a7c565b8114610ac2575f5ffd5b50565b5f81359050610ad381610aaf565b92915050565b5f60208284031215610aee57610aed6109ef565b5b5f610afb84828501610ac5565b91505092915050565b5f819050919050565b610b1681610b04565b8114610b20575f5ffd5b50565b5f81359050610b3181610b0d565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610b8582610b3f565b810181811067ffffffffffffffff82111715610ba457610ba3610b4f565b5b80604052505050565b5f610bb66109e6565b9050610bc28282610b7c565b919050565b5f67ffffffffffffffff821115610be157610be0610b4f565b5b610bea82610b3f565b9050602081019050919050565b828183375f83830152505050565b5f610c17610c1284610bc7565b610bad565b905082815260208101848484011115610c3357610c32610b3b565b5b610c3e848285610bf7565b509392505050565b5f82601f830112610c5a57610c59610b37565b5b8135610c6a848260208601610c05565b91505092915050565b5f5f5f5f60808587031215610c8b57610c8a6109ef565b5b5f610c9887828801610b23565b9450506020610ca987828801610ac5565b935050604085013567ffffffffffffffff811115610cca57610cc96109f3565b5b610cd687828801610c46565b9250506060610ce787828801610a3d565b91505092959194509250565b610cfc81610a16565b82525050565b5f602082019050610d155f830184610cf3565b92915050565b5f60208284031215610d3057610d2f6109ef565b5b5f610d3d84828501610b23565b91505092915050565b610d4f81610b04565b82525050565b5f602082019050610d685f830184610d46565b92915050565b5f60208284031215610d8357610d826109ef565b5b5f82013567ffffffffffffffff811115610da057610d9f6109f3565b5b610dac84828501610c46565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610de782610db5565b610df18185610dbf565b9350610e01818560208601610dcf565b610e0a81610b3f565b840191505092915050565b5f6020820190508181035f830152610e2d8184610ddd565b905092915050565b5f608082019050610e485f830187610d46565b610e556020830186610a87565b8181036040830152610e678185610ddd565b9050610e766060830184610cf3565b95945050505050565b5f81519050610e8d81610b0d565b92915050565b5f60208284031215610ea857610ea76109ef565b5b5f610eb584828501610e7f565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680610f0257607f821691505b602082108103610f1557610f14610ebe565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302610f777fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610f3c565b610f818683610f3c565b95508019841693508086168417925050509392505050565b5f819050919050565b5f610fbc610fb7610fb284610b04565b610f99565b610b04565b9050919050565b5f819050919050565b610fd583610fa2565b610fe9610fe182610fc3565b848454610f48565b825550505050565b5f5f905090565b611000610ff1565b61100b818484610fcc565b505050565b5b8181101561102e576110235f82610ff8565b600181019050611011565b5050565b601f8211156110735761104481610f1b565b61104d84610f2d565b8101602085101561105c578190505b61107061106885610f2d565b830182611010565b50505b505050565b5f82821c905092915050565b5f6110935f1984600802611078565b1980831691505092915050565b5f6110ab8383611084565b9150826002028217905092915050565b6110c482610db5565b67ffffffffffffffff8111156110dd576110dc610b4f565b5b6110e78254610eeb565b6110f2828285611032565b5f60209050601f831160018114611123575f8415611111578287015190505b61111b85826110a0565b865550611182565b601f19841661113186610f1b565b5f5b8281101561115857848901518255600182019150602085019450602081019050611133565b868310156111755784890151611171601f891682611084565b8355505b6001600288020188555050505b505050505050565b5f81519050919050565b5f81905092915050565b5f6111a88261118a565b6111b28185611194565b93506111c2818560208601610dcf565b80840191505092915050565b5f6111d9828461119e565b915081905092915050565b7f44656c65676174652063616c6c206661696c65640000000000000000000000005f82015250565b5f611218601483610dbf565b9150611223826111e4565b602082019050919050565b5f6020820190508181035f8301526112458161120c565b905091905056fea26469706673582212209e4119ae941cd4b0ff3660322af903429bb0e7a1821fe73463142ee61f41263064736f6c634300081e0033608060405260025f553480156012575f5ffd5b50610324806100205f395ff3fe608060405234801561000f575f5ffd5b506004361061004a575f3560e01c80631b3ed7221461004e578063641579a61461006c578063771602f714610088578063c6888fa1146100b8575b5f5ffd5b6100566100e8565b6040516100639190610176565b60405180910390f35b610086600480360381019061008191906101bd565b6100ed565b005b6100a2600480360381019061009d91906101e8565b6100f6565b6040516100af9190610176565b60405180910390f35b6100d260048036038101906100cd91906101bd565b61010b565b6040516100df9190610176565b60405180910390f35b5f5481565b805f8190555050565b5f81836101039190610253565b905092915050565b5f5f5f548361011a9190610286565b90507fc6d3a874561afb85c1bb3c6a732cdb68de81773583e3a3ae43144ac3fb2c06e5838260405161014d9291906102c7565b60405180910390a180915050919050565b5f819050919050565b6101708161015e565b82525050565b5f6020820190506101895f830184610167565b92915050565b5f5ffd5b61019c8161015e565b81146101a6575f5ffd5b50565b5f813590506101b781610193565b92915050565b5f602082840312156101d2576101d161018f565b5b5f6101df848285016101a9565b91505092915050565b5f5f604083850312156101fe576101fd61018f565b5b5f61020b858286016101a9565b925050602061021c858286016101a9565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61025d8261015e565b91506102688361015e565b92508282019050808211156102805761027f610226565b5b92915050565b5f6102908261015e565b915061029b8361015e565b92508282026102a98161015e565b915082820484148315176102c0576102bf610226565b5b5092915050565b5f6040820190506102da5f830185610167565b6102e76020830184610167565b939250505056fea264697066735822122021376062f207d413d5af15b0a511cd14380b043550a9497df2003c089edd705a64736f6c634300081e0033"`, `"0x608060405234801561000f575f5ffd5b50600436106100e8575f3560e01c80637fcaf6661161008a578063981f549911610064578063981f549914610220578063d0da9af514610241578063e30081a014610271578063f2c9ecd81461028d576100e8565b80637fcaf666146101c857806389ea642f146101e45780638d5d4de714610202576100e8565b8063349a0054116100c6578063349a00541461014257806338cc48311461015e5780633fb5c1cb1461017c578063575f450514610198576100e8565b806301ef8faa146100ec57806312a7b914146101085780631e26fd3314610126575b5f5ffd5b61010660048036038101906101019190610a51565b6102ab565b005b6101106102ee565b60405161011d9190610a96565b60405180910390f35b610140600480360381019061013b9190610ad9565b610303565b005b61015c60048036038101906101579190610c73565b610356565b005b610166610531565b6040516101739190610d02565b60405180910390f35b61019660048036038101906101919190610d1b565b610559565b005b6101b260048036038101906101ad9190610d1b565b610599565b6040516101bf9190610d55565b60405180910390f35b6101e260048036038101906101dd9190610d6e565b61067c565b005b6101ec6106c6565b6040516101f99190610e15565b60405180910390f35b61020a610756565b6040516102179190610d02565b60405180910390f35b61022861077b565b6040516102389493929190610e35565b60405180910390f35b61025b60048036038101906102569190610d1b565b6107ae565b6040516102689190610d55565b60405180910390f35b61028b60048036038101906102869190610a51565b610964565b005b6102956109de565b6040516102a29190610d55565b60405180910390f35b8060045f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f60015f9054906101000a900460ff16905090565b8060015f6101000a81548160ff0219169083151502179055507fd31368d67652afe87682ed73c60ba1c2f499ae414a86d618c275326b0d6739968160405161034b9190610a96565b60405180910390a150565b3073ffffffffffffffffffffffffffffffffffffffff16633fb5c1cb856040518263ffffffff1660e01b815260040161038f9190610d55565b5f604051808303815f87803b1580156103a6575f5ffd5b505af11580156103b8573d5f5f3e3d5ffd5b505050503073ffffffffffffffffffffffffffffffffffffffff16631e26fd33846040518263ffffffff1660e01b81526004016103f59190610a96565b5f604051808303815f87803b15801561040c575f5ffd5b505af115801561041e573d5f5f3e3d5ffd5b505050503073ffffffffffffffffffffffffffffffffffffffff16637fcaf666836040518263ffffffff1660e01b815260040161045b9190610e15565b5f604051808303815f87803b158015610472575f5ffd5b505af1158015610484573d5f5f3e3d5ffd5b505050503073ffffffffffffffffffffffffffffffffffffffff1663e30081a0826040518263ffffffff1660e01b81526004016104c19190610d02565b5f604051808303815f87803b1580156104d8575f5ffd5b505af11580156104ea573d5f5f3e3d5ffd5b505050507fc3e1073869e2f3735605599cbfd67bc84b7ce8f34226501a7c84f1bea115cb0c848484846040516105239493929190610e35565b60405180910390a150505050565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b805f819055507f9ec8254969d1974eac8c74afb0c03595b4ffe0a1d7ad8a7f82ed31b9c85425918160405161058e9190610d55565b60405180910390a150565b5f5f60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505f8173ffffffffffffffffffffffffffffffffffffffff1663c6888fa1856040518263ffffffff1660e01b81526004016105f99190610d55565b6020604051808303815f875af1158015610615573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106399190610e93565b90507f9d164645d2740a65754f47c13dc8efcc8a63d0f41785c4d3cd1dfd289e64a3bc8160405161066a9190610d55565b60405180910390a18092505050919050565b806002908161068b91906110bb565b507fd824731128b3439672eb2a63774a112947e43a4102ef25ba8fe18ad8930a9188816040516106bb9190610e15565b60405180910390a150565b6060600280546106d590610eeb565b80601f016020809104026020016040519081016040528092919081815260200182805461070190610eeb565b801561074c5780601f106107235761010080835404028352916020019161074c565b820191905f5260205f20905b81548152906001019060200180831161072f57829003601f168201915b5050505050905090565b60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f5f60605f6107886109de565b6107906102ee565b6107986106c6565b6107a0610531565b935093509350935090919293565b5f5f826040516024016107c19190610d55565b6040516020818303038152906040527fc6888fa1000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090505f5f60045f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360405161088891906111ce565b5f60405180830381855af49150503d805f81146108c0576040519150601f19603f3d011682016040523d82523d5f602084013e6108c5565b606091505b50915091508161090a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109019061122e565b60405180910390fd5b5f8180602001905181019061091f9190610e93565b90507fb26b3b59a9756bf7416fe9326c05726fbfe955ce9e948f70da7a91f4978fb4d2816040516109509190610d55565b60405180910390a180945050505050919050565b8060035f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f88749aed52403b3a8ec7763273d5665190617f46de93b08aab1cc6ec80dc2fb4816040516109d39190610d02565b60405180910390a150565b5f5f54905090565b5f604051905090565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a20826109f7565b9050919050565b610a3081610a16565b8114610a3a575f5ffd5b50565b5f81359050610a4b81610a27565b92915050565b5f60208284031215610a6657610a656109ef565b5b5f610a7384828501610a3d565b91505092915050565b5f8115159050919050565b610a9081610a7c565b82525050565b5f602082019050610aa95f830184610a87565b92915050565b610ab881610a7c565b8114610ac2575f5ffd5b50565b5f81359050610ad381610aaf565b92915050565b5f60208284031215610aee57610aed6109ef565b5b5f610afb84828501610ac5565b91505092915050565b5f819050919050565b610b1681610b04565b8114610b20575f5ffd5b50565b5f81359050610b3181610b0d565b92915050565b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610b8582610b3f565b810181811067ffffffffffffffff82111715610ba457610ba3610b4f565b5b80604052505050565b5f610bb66109e6565b9050610bc28282610b7c565b919050565b5f67ffffffffffffffff821115610be157610be0610b4f565b5b610bea82610b3f565b9050602081019050919050565b828183375f83830152505050565b5f610c17610c1284610bc7565b610bad565b905082815260208101848484011115610c3357610c32610b3b565b5b610c3e848285610bf7565b509392505050565b5f82601f830112610c5a57610c59610b37565b5b8135610c6a848260208601610c05565b91505092915050565b5f5f5f5f60808587031215610c8b57610c8a6109ef565b5b5f610c9887828801610b23565b9450506020610ca987828801610ac5565b935050604085013567ffffffffffffffff811115610cca57610cc96109f3565b5b610cd687828801610c46565b9250506060610ce787828801610a3d565b91505092959194509250565b610cfc81610a16565b82525050565b5f602082019050610d155f830184610cf3565b92915050565b5f60208284031215610d3057610d2f6109ef565b5b5f610d3d84828501610b23565b91505092915050565b610d4f81610b04565b82525050565b5f602082019050610d685f830184610d46565b92915050565b5f60208284031215610d8357610d826109ef565b5b5f82013567ffffffffffffffff811115610da057610d9f6109f3565b5b610dac84828501610c46565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f610de782610db5565b610df18185610dbf565b9350610e01818560208601610dcf565b610e0a81610b3f565b840191505092915050565b5f6020820190508181035f830152610e2d8184610ddd565b905092915050565b5f608082019050610e485f830187610d46565b610e556020830186610a87565b8181036040830152610e678185610ddd565b9050610e766060830184610cf3565b95945050505050565b5f81519050610e8d81610b0d565b92915050565b5f60208284031215610ea857610ea76109ef565b5b5f610eb584828501610e7f565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680610f0257607f821691505b602082108103610f1557610f14610ebe565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302610f777fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610f3c565b610f818683610f3c565b95508019841693508086168417925050509392505050565b5f819050919050565b5f610fbc610fb7610fb284610b04565b610f99565b610b04565b9050919050565b5f819050919050565b610fd583610fa2565b610fe9610fe182610fc3565b848454610f48565b825550505050565b5f5f905090565b611000610ff1565b61100b818484610fcc565b505050565b5b8181101561102e576110235f82610ff8565b600181019050611011565b5050565b601f8211156110735761104481610f1b565b61104d84610f2d565b8101602085101561105c578190505b61107061106885610f2d565b830182611010565b50505b505050565b5f82821c905092915050565b5f6110935f1984600802611078565b1980831691505092915050565b5f6110ab8383611084565b9150826002028217905092915050565b6110c482610db5565b67ffffffffffffffff8111156110dd576110dc610b4f565b5b6110e78254610eeb565b6110f2828285611032565b5f60209050601f831160018114611123575f8415611111578287015190505b61111b85826110a0565b865550611182565b601f19841661113186610f1b565b5f5b8281101561115857848901518255600182019150602085019450602081019050611133565b868310156111755784890151611171601f891682611084565b8355505b6001600288020188555050505b505050505050565b5f81519050919050565b5f81905092915050565b5f6111a88261118a565b6111b28185611194565b93506111c2818560208601610dcf565b80840191505092915050565b5f6111d9828461119e565b915081905092915050565b7f44656c65676174652063616c6c206661696c65640000000000000000000000005f82015250565b5f611218601483610dbf565b9150611223826111e4565b602082019050919050565b5f6020820190508181035f8301526112458161120c565b905091905056fea26469706673582212209e4119ae941cd4b0ff3660322af903429bb0e7a1821fe73463142ee61f41263064736f6c634300081e0033"`, `undefined`\> -Defined in: [contract-lib/AdvancedContract.s.sol.ts:37](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/contract-lib/AdvancedContract.s.sol.ts#L37) +Defined in: [contract-lib/AdvancedContract.s.sol.ts:72](https://github.com/evmts/tevm-contract/blob/main/src/contract-lib/AdvancedContract.s.sol.ts#L72) + +A prebuilt contract exercising the harder parts of the EVM: several storage types, an +external call, and a `delegatecall`. Useful for testing call tracing, opcode hooks, and +multi-type ABI encoding without needing a Solidity toolchain. + +Its constructor deploys an internal `MathHelper` as a side effect, so it also covers +contract-creation-during-construction. + +Ships with real compiled `bytecode` and `deployedBytecode` but no `address` โ€” call +`withAddress` after deploying. + +Note that `callMathHelper` and `delegateCallMathHelper` are `nonpayable` despite reading like +getters, so they live on `.write`, not `.read`. + +## Example + +```typescript +import { AdvancedContract } from '@tevm/contract' +import { createMemoryClient, PREFUNDED_ACCOUNTS } from 'tevm' + +const client = createMemoryClient() +await client.tevmReady() + +const result = await client.tevmDeploy({ + from: PREFUNDED_ACCOUNTS[0].address, + ...AdvancedContract.deploy(1n, true, 'hello', PREFUNDED_ACCOUNTS[0].address), + addToMempool: true, +}) +await client.tevmMine({ blockCount: 1 }) + +if (!result.createdAddress) throw new Error('deployment failed') +const advanced = AdvancedContract.withAddress(result.createdAddress) + +const { data } = await client.tevmContract(advanced.read.getAllValues()) +console.log(data) // [1n, true, 'hello', '0xf39Fโ€ฆ2266'] +``` ## See -[contract docs](https://tevm.sh/learn/contracts/) for more documentation +[prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) for more documentation diff --git a/docs/variables/ERC20.md b/docs/variables/ERC20.md index 1677b4d..8999387 100644 --- a/docs/variables/ERC20.md +++ b/docs/variables/ERC20.md @@ -2,42 +2,34 @@ *** -[@tevm/contract](../globals.md) / ERC20 +[@tevm/contract](../README.md) / ERC20 # Variable: ERC20 > `const` **ERC20**: [`Contract`](../type-aliases/Contract.md)\<`"OzERC20"`, readonly \[`"constructor(string name, string symbol)"`, `"error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed)"`, `"error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed)"`, `"error ERC20InvalidApprover(address approver)"`, `"error ERC20InvalidReceiver(address receiver)"`, `"error ERC20InvalidSender(address sender)"`, `"error ERC20InvalidSpender(address spender)"`, `"event Approval(address indexed owner, address indexed spender, uint256 value)"`, `"event Transfer(address indexed from, address indexed to, uint256 value)"`, `"function allowance(address owner, address spender) view returns (uint256)"`, `"function approve(address spender, uint256 value) returns (bool)"`, `"function balanceOf(address account) view returns (uint256)"`, `"function decimals() view returns (uint8)"`, `"function name() view returns (string)"`, `"function symbol() view returns (string)"`, `"function totalSupply() view returns (uint256)"`, `"function transfer(address to, uint256 value) returns (bool)"`, `"function transferFrom(address from, address to, uint256 value) returns (bool)"`\], `undefined`, `"0x608060405234801562000010575f80fd5b5060405162001392380380620013928339818101604052810190620000369190620001eb565b81818160039081620000499190620004a5565b5080600490816200005b9190620004a5565b505050505062000589565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620000c7826200007f565b810181811067ffffffffffffffff82111715620000e957620000e86200008f565b5b80604052505050565b5f620000fd62000066565b90506200010b8282620000bc565b919050565b5f67ffffffffffffffff8211156200012d576200012c6200008f565b5b62000138826200007f565b9050602081019050919050565b5f5b838110156200016457808201518184015260208101905062000147565b5f8484015250505050565b5f620001856200017f8462000110565b620000f2565b905082815260208101848484011115620001a457620001a36200007b565b5b620001b184828562000145565b509392505050565b5f82601f830112620001d057620001cf62000077565b5b8151620001e28482602086016200016f565b91505092915050565b5f80604083850312156200020457620002036200006f565b5b5f83015167ffffffffffffffff81111562000224576200022362000073565b5b6200023285828601620001b9565b925050602083015167ffffffffffffffff81111562000256576200025562000073565b5b6200026485828601620001b9565b9150509250929050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680620002bd57607f821691505b602082108103620002d357620002d262000278565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620003377fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002fa565b620003438683620002fa565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f6200038d6200038762000381846200035b565b62000364565b6200035b565b9050919050565b5f819050919050565b620003a8836200036d565b620003c0620003b78262000394565b84845462000306565b825550505050565b5f90565b620003d6620003c8565b620003e38184846200039d565b505050565b5b818110156200040a57620003fe5f82620003cc565b600181019050620003e9565b5050565b601f82111562000459576200042381620002d9565b6200042e84620002eb565b810160208510156200043e578190505b620004566200044d85620002eb565b830182620003e8565b50505b505050565b5f82821c905092915050565b5f6200047b5f19846008026200045e565b1980831691505092915050565b5f6200049583836200046a565b9150826002028217905092915050565b620004b0826200026e565b67ffffffffffffffff811115620004cc57620004cb6200008f565b5b620004d88254620002a5565b620004e58282856200040e565b5f60209050601f8311600181146200051b575f841562000506578287015190505b62000512858262000488565b86555062000581565b601f1984166200052b86620002d9565b5f5b8281101562000554578489015182556001820191506020850194506020810190506200052d565b8683101562000574578489015162000570601f8916826200046a565b8355505b6001600288020188555050505b505050505050565b610dfb80620005975f395ff3fe608060405234801561000f575f80fd5b5060043610610091575f3560e01c8063313ce56711610064578063313ce5671461013157806370a082311461014f57806395d89b411461017f578063a9059cbb1461019d578063dd62ed3e146101cd57610091565b806306fdde0314610095578063095ea7b3146100b357806318160ddd146100e357806323b872dd14610101575b5f80fd5b61009d6101fd565b6040516100aa9190610a74565b60405180910390f35b6100cd60048036038101906100c89190610b25565b61028d565b6040516100da9190610b7d565b60405180910390f35b6100eb6102af565b6040516100f89190610ba5565b60405180910390f35b61011b60048036038101906101169190610bbe565b6102b8565b6040516101289190610b7d565b60405180910390f35b6101396102e6565b6040516101469190610c29565b60405180910390f35b61016960048036038101906101649190610c42565b6102ee565b6040516101769190610ba5565b60405180910390f35b610187610333565b6040516101949190610a74565b60405180910390f35b6101b760048036038101906101b29190610b25565b6103c3565b6040516101c49190610b7d565b60405180910390f35b6101e760048036038101906101e29190610c6d565b6103e5565b6040516101f49190610ba5565b60405180910390f35b60606003805461020c90610cd8565b80601f016020809104026020016040519081016040528092919081815260200182805461023890610cd8565b80156102835780601f1061025a57610100808354040283529160200191610283565b820191905f5260205f20905b81548152906001019060200180831161026657829003601f168201915b5050505050905090565b5f80610297610467565b90506102a481858561046e565b600191505092915050565b5f600254905090565b5f806102c2610467565b90506102cf858285610480565b6102da858585610512565b60019150509392505050565b5f6012905090565b5f805f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b60606004805461034290610cd8565b80601f016020809104026020016040519081016040528092919081815260200182805461036e90610cd8565b80156103b95780601f10610390576101008083540402835291602001916103b9565b820191905f5260205f20905b81548152906001019060200180831161039c57829003601f168201915b5050505050905090565b5f806103cd610467565b90506103da818585610512565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f33905090565b61047b8383836001610602565b505050565b5f61048b84846103e5565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461050c57818110156104fd578281836040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526004016104f493929190610d17565b60405180910390fd5b61050b84848484035f610602565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610582575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016105799190610d4c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036105f2575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016105e99190610d4c565b60405180910390fd5b6105fd8383836107d1565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610672575f6040517fe602df050000000000000000000000000000000000000000000000000000000081526004016106699190610d4c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106e2575f6040517f94280d620000000000000000000000000000000000000000000000000000000081526004016106d99190610d4c565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208190555080156107cb578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516107c29190610ba5565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610821578060025f8282546108159190610d92565b925050819055506108ef565b5f805f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050818110156108aa578381836040517fe450d38c0000000000000000000000000000000000000000000000000000000081526004016108a193929190610d17565b60405180910390fd5b8181035f808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610936578060025f8282540392505081905550610980565b805f808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516109dd9190610ba5565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015610a21578082015181840152602081019050610a06565b5f8484015250505050565b5f601f19601f8301169050919050565b5f610a46826109ea565b610a5081856109f4565b9350610a60818560208601610a04565b610a6981610a2c565b840191505092915050565b5f6020820190508181035f830152610a8c8184610a3c565b905092915050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610ac182610a98565b9050919050565b610ad181610ab7565b8114610adb575f80fd5b50565b5f81359050610aec81610ac8565b92915050565b5f819050919050565b610b0481610af2565b8114610b0e575f80fd5b50565b5f81359050610b1f81610afb565b92915050565b5f8060408385031215610b3b57610b3a610a94565b5b5f610b4885828601610ade565b9250506020610b5985828601610b11565b9150509250929050565b5f8115159050919050565b610b7781610b63565b82525050565b5f602082019050610b905f830184610b6e565b92915050565b610b9f81610af2565b82525050565b5f602082019050610bb85f830184610b96565b92915050565b5f805f60608486031215610bd557610bd4610a94565b5b5f610be286828701610ade565b9350506020610bf386828701610ade565b9250506040610c0486828701610b11565b9150509250925092565b5f60ff82169050919050565b610c2381610c0e565b82525050565b5f602082019050610c3c5f830184610c1a565b92915050565b5f60208284031215610c5757610c56610a94565b5b5f610c6484828501610ade565b91505092915050565b5f8060408385031215610c8357610c82610a94565b5b5f610c9085828601610ade565b9250506020610ca185828601610ade565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680610cef57607f821691505b602082108103610d0257610d01610cab565b5b50919050565b610d1181610ab7565b82525050565b5f606082019050610d2a5f830186610d08565b610d376020830185610b96565b610d446040830184610b96565b949350505050565b5f602082019050610d5f5f830184610d08565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610d9c82610af2565b9150610da783610af2565b9250828201905080821115610dbf57610dbe610d65565b5b9291505056fea264697066735822122055b5ce6d6026c56b28a641568d3e9a6c81fb1079127f85ede16ed31d67d3eff464736f6c63430008160033"`, `"0x608060405234801561000f575f80fd5b5060043610610091575f3560e01c8063313ce56711610064578063313ce5671461013157806370a082311461014f57806395d89b411461017f578063a9059cbb1461019d578063dd62ed3e146101cd57610091565b806306fdde0314610095578063095ea7b3146100b357806318160ddd146100e357806323b872dd14610101575b5f80fd5b61009d6101fd565b6040516100aa9190610a74565b60405180910390f35b6100cd60048036038101906100c89190610b25565b61028d565b6040516100da9190610b7d565b60405180910390f35b6100eb6102af565b6040516100f89190610ba5565b60405180910390f35b61011b60048036038101906101169190610bbe565b6102b8565b6040516101289190610b7d565b60405180910390f35b6101396102e6565b6040516101469190610c29565b60405180910390f35b61016960048036038101906101649190610c42565b6102ee565b6040516101769190610ba5565b60405180910390f35b610187610333565b6040516101949190610a74565b60405180910390f35b6101b760048036038101906101b29190610b25565b6103c3565b6040516101c49190610b7d565b60405180910390f35b6101e760048036038101906101e29190610c6d565b6103e5565b6040516101f49190610ba5565b60405180910390f35b60606003805461020c90610cd8565b80601f016020809104026020016040519081016040528092919081815260200182805461023890610cd8565b80156102835780601f1061025a57610100808354040283529160200191610283565b820191905f5260205f20905b81548152906001019060200180831161026657829003601f168201915b5050505050905090565b5f80610297610467565b90506102a481858561046e565b600191505092915050565b5f600254905090565b5f806102c2610467565b90506102cf858285610480565b6102da858585610512565b60019150509392505050565b5f6012905090565b5f805f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b60606004805461034290610cd8565b80601f016020809104026020016040519081016040528092919081815260200182805461036e90610cd8565b80156103b95780601f10610390576101008083540402835291602001916103b9565b820191905f5260205f20905b81548152906001019060200180831161039c57829003601f168201915b5050505050905090565b5f806103cd610467565b90506103da818585610512565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f33905090565b61047b8383836001610602565b505050565b5f61048b84846103e5565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461050c57818110156104fd578281836040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526004016104f493929190610d17565b60405180910390fd5b61050b84848484035f610602565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610582575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016105799190610d4c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036105f2575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016105e99190610d4c565b60405180910390fd5b6105fd8383836107d1565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610672575f6040517fe602df050000000000000000000000000000000000000000000000000000000081526004016106699190610d4c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106e2575f6040517f94280d620000000000000000000000000000000000000000000000000000000081526004016106d99190610d4c565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208190555080156107cb578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516107c29190610ba5565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610821578060025f8282546108159190610d92565b925050819055506108ef565b5f805f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050818110156108aa578381836040517fe450d38c0000000000000000000000000000000000000000000000000000000081526004016108a193929190610d17565b60405180910390fd5b8181035f808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610936578060025f8282540392505081905550610980565b805f808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516109dd9190610ba5565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015610a21578082015181840152602081019050610a06565b5f8484015250505050565b5f601f19601f8301169050919050565b5f610a46826109ea565b610a5081856109f4565b9350610a60818560208601610a04565b610a6981610a2c565b840191505092915050565b5f6020820190508181035f830152610a8c8184610a3c565b905092915050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610ac182610a98565b9050919050565b610ad181610ab7565b8114610adb575f80fd5b50565b5f81359050610aec81610ac8565b92915050565b5f819050919050565b610b0481610af2565b8114610b0e575f80fd5b50565b5f81359050610b1f81610afb565b92915050565b5f8060408385031215610b3b57610b3a610a94565b5b5f610b4885828601610ade565b9250506020610b5985828601610b11565b9150509250929050565b5f8115159050919050565b610b7781610b63565b82525050565b5f602082019050610b905f830184610b6e565b92915050565b610b9f81610af2565b82525050565b5f602082019050610bb85f830184610b96565b92915050565b5f805f60608486031215610bd557610bd4610a94565b5b5f610be286828701610ade565b9350506020610bf386828701610ade565b9250506040610c0486828701610b11565b9150509250925092565b5f60ff82169050919050565b610c2381610c0e565b82525050565b5f602082019050610c3c5f830184610c1a565b92915050565b5f60208284031215610c5757610c56610a94565b5b5f610c6484828501610ade565b91505092915050565b5f8060408385031215610c8357610c82610a94565b5b5f610c9085828601610ade565b9250506020610ca185828601610ade565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680610cef57607f821691505b602082108103610d0257610d01610cab565b5b50919050565b610d1181610ab7565b82525050565b5f606082019050610d2a5f830186610d08565b610d376020830185610b96565b610d446040830184610b96565b949350505050565b5f602082019050610d5f5f830184610d08565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610d9c82610af2565b9150610da783610af2565b9250828201905080821115610dbf57610dbe610d65565b5b9291505056fea264697066735822122055b5ce6d6026c56b28a641568d3e9a6c81fb1079127f85ede16ed31d67d3eff464736f6c63430008160033"`, `undefined`\> -Defined in: [contract-lib/ERC20.ts:63](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/contract-lib/ERC20.ts#L63) +Defined in: [contract-lib/ERC20.ts:52](https://github.com/evmts/tevm-contract/blob/main/src/contract-lib/ERC20.ts#L52) -Bytecode and ABI for the ERC20 contract from OpenZeppelin. -This constant represents a standard ERC20 token implementation. +A deployable OpenZeppelin ERC20 contract with compiled creation and runtime bytecode. -## Examples +The constructor accepts a token name and symbol. This fixture does not expose a public mint +function, so its initial total supply is zero. + +## Example -Using the ERC20 contract in a deployment script: ```typescript -import { ERC20 } from 'tevm/contract' +import { ERC20 } from '@tevm/contract' -// Deploy the ERC20 contract -const deployedERC20 = await tevm.deployContract(ERC20.deploy('MyToken', 'MTK')) -console.log('ERC20 deployed at:', deployedERC20.address) +const deployment = ERC20.deploy('My Token', 'MTK') +const token = ERC20.withAddress('0x0000000000000000000000000000000000000001') -// Interact with the deployed contract -const balance = await tevm.contract(ERC20.read.balanceOf(deployedERC20.address, '0x1234...')) -console.log('Balance:', balance) +const nameAction = token.read.name() +const transferAction = token.write.transfer( + '0x0000000000000000000000000000000000000002', + 1000n, +) ``` -Using the ERC20 contract with an existing deployment: -```typescript -import { ERC20 } from 'tevm/contract' - -const existingERC20 = ERC20.withAddress('0x1234...') +## See -// Read token name -const name = await tevm.contract(existingERC20.read.name()) -console.log('Token name:', name) - -// Transfer tokens -await tevm.contract(existingERC20.write.transfer('0x5678...', 1000n)) -``` +[prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) diff --git a/docs/variables/ERC721.md b/docs/variables/ERC721.md index e8e1804..33e735f 100644 --- a/docs/variables/ERC721.md +++ b/docs/variables/ERC721.md @@ -2,43 +2,35 @@ *** -[@tevm/contract](../globals.md) / ERC721 +[@tevm/contract](../README.md) / ERC721 # Variable: ERC721 > `const` **ERC721**: [`Contract`](../type-aliases/Contract.md)\<`"OzERC721"`, readonly \[`"constructor(string name, string symbol)"`, `"error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner)"`, `"error ERC721InsufficientApproval(address operator, uint256 tokenId)"`, `"error ERC721InvalidApprover(address approver)"`, `"error ERC721InvalidOperator(address operator)"`, `"error ERC721InvalidOwner(address owner)"`, `"error ERC721InvalidReceiver(address receiver)"`, `"error ERC721InvalidSender(address sender)"`, `"error ERC721NonexistentToken(uint256 tokenId)"`, `"event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)"`, `"event ApprovalForAll(address indexed owner, address indexed operator, bool approved)"`, `"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"`, `"function approve(address to, uint256 tokenId)"`, `"function balanceOf(address owner) view returns (uint256)"`, `"function getApproved(uint256 tokenId) view returns (address)"`, `"function isApprovedForAll(address owner, address operator) view returns (bool)"`, `"function name() view returns (string)"`, `"function ownerOf(uint256 tokenId) view returns (address)"`, `"function safeTransferFrom(address from, address to, uint256 tokenId)"`, `"function safeTransferFrom(address from, address to, uint256 tokenId, bytes data)"`, `"function setApprovalForAll(address operator, bool approved)"`, `"function supportsInterface(bytes4 interfaceId) view returns (bool)"`, `"function symbol() view returns (string)"`, `"function tokenURI(uint256 tokenId) view returns (string)"`, `"function transferFrom(address from, address to, uint256 tokenId)"`\], `undefined`, `"0x608060405234801562000010575f80fd5b5060405162002174380380620021748339818101604052810190620000369190620001ea565b8181815f9081620000489190620004a4565b5080600190816200005a9190620004a4565b505050505062000588565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620000c6826200007e565b810181811067ffffffffffffffff82111715620000e857620000e76200008e565b5b80604052505050565b5f620000fc62000065565b90506200010a8282620000bb565b919050565b5f67ffffffffffffffff8211156200012c576200012b6200008e565b5b62000137826200007e565b9050602081019050919050565b5f5b838110156200016357808201518184015260208101905062000146565b5f8484015250505050565b5f620001846200017e846200010f565b620000f1565b905082815260208101848484011115620001a357620001a26200007a565b5b620001b084828562000144565b509392505050565b5f82601f830112620001cf57620001ce62000076565b5b8151620001e18482602086016200016e565b91505092915050565b5f80604083850312156200020357620002026200006e565b5b5f83015167ffffffffffffffff81111562000223576200022262000072565b5b6200023185828601620001b8565b925050602083015167ffffffffffffffff81111562000255576200025462000072565b5b6200026385828601620001b8565b9150509250929050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680620002bc57607f821691505b602082108103620002d257620002d162000277565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620003367fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002f9565b620003428683620002f9565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f6200038c6200038662000380846200035a565b62000363565b6200035a565b9050919050565b5f819050919050565b620003a7836200036c565b620003bf620003b68262000393565b84845462000305565b825550505050565b5f90565b620003d5620003c7565b620003e28184846200039c565b505050565b5b818110156200040957620003fd5f82620003cb565b600181019050620003e8565b5050565b601f82111562000458576200042281620002d8565b6200042d84620002ea565b810160208510156200043d578190505b620004556200044c85620002ea565b830182620003e7565b50505b505050565b5f82821c905092915050565b5f6200047a5f19846008026200045d565b1980831691505092915050565b5f62000494838362000469565b9150826002028217905092915050565b620004af826200026d565b67ffffffffffffffff811115620004cb57620004ca6200008e565b5b620004d78254620002a4565b620004e48282856200040d565b5f60209050601f8311600181146200051a575f841562000505578287015190505b62000511858262000487565b86555062000580565b601f1984166200052a86620002d8565b5f5b8281101562000553578489015182556001820191506020850194506020810190506200052c565b868310156200057357848901516200056f601f89168262000469565b8355505b6001600288020188555050505b505050505050565b611bde80620005965f395ff3fe608060405234801561000f575f80fd5b50600436106100cd575f3560e01c80636352211e1161008a578063a22cb46511610064578063a22cb46514610221578063b88d4fde1461023d578063c87b56dd14610259578063e985e9c514610289576100cd565b80636352211e146101a357806370a08231146101d357806395d89b4114610203576100cd565b806301ffc9a7146100d157806306fdde0314610101578063081812fc1461011f578063095ea7b31461014f57806323b872dd1461016b57806342842e0e14610187575b5f80fd5b6100eb60048036038101906100e6919061146f565b6102b9565b6040516100f891906114b4565b60405180910390f35b61010961039a565b6040516101169190611557565b60405180910390f35b610139600480360381019061013491906115aa565b610429565b6040516101469190611614565b60405180910390f35b61016960048036038101906101649190611657565b610444565b005b61018560048036038101906101809190611695565b61045a565b005b6101a1600480360381019061019c9190611695565b610559565b005b6101bd60048036038101906101b891906115aa565b610578565b6040516101ca9190611614565b60405180910390f35b6101ed60048036038101906101e891906116e5565b610589565b6040516101fa919061171f565b60405180910390f35b61020b61063f565b6040516102189190611557565b60405180910390f35b61023b60048036038101906102369190611762565b6106cf565b005b610257600480360381019061025291906118cc565b6106e5565b005b610273600480360381019061026e91906115aa565b610702565b6040516102809190611557565b60405180910390f35b6102a3600480360381019061029e919061194c565b610768565b6040516102b091906114b4565b60405180910390f35b5f7f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061038357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806103935750610392826107f6565b5b9050919050565b60605f80546103a8906119b7565b80601f01602080910402602001604051908101604052809291908181526020018280546103d4906119b7565b801561041f5780601f106103f65761010080835404028352916020019161041f565b820191905f5260205f20905b81548152906001019060200180831161040257829003601f168201915b5050505050905090565b5f6104338261085f565b5061043d826108e5565b9050919050565b610456828261045161091e565b610925565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036104ca575f6040517f64a0ae920000000000000000000000000000000000000000000000000000000081526004016104c19190611614565b60405180910390fd5b5f6104dd83836104d861091e565b610937565b90508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610553578382826040517f64283d7b00000000000000000000000000000000000000000000000000000000815260040161054a939291906119e7565b60405180910390fd5b50505050565b61057383838360405180602001604052805f8152506106e5565b505050565b5f6105828261085f565b9050919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036105fa575f6040517f89c62b640000000000000000000000000000000000000000000000000000000081526004016105f19190611614565b60405180910390fd5b60035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b60606001805461064e906119b7565b80601f016020809104026020016040519081016040528092919081815260200182805461067a906119b7565b80156106c55780601f1061069c576101008083540402835291602001916106c5565b820191905f5260205f20905b8154815290600101906020018083116106a857829003601f168201915b5050505050905090565b6106e16106da61091e565b8383610b42565b5050565b6106f084848461045a565b6106fc84848484610cab565b50505050565b606061070d8261085f565b505f610717610e5d565b90505f8151116107355760405180602001604052805f815250610760565b8061073f84610e73565b604051602001610750929190611a56565b6040516020818303038152906040525b915050919050565b5f60055f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905092915050565b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b5f8061086a83610f3d565b90505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036108dc57826040517f7e2732890000000000000000000000000000000000000000000000000000000081526004016108d3919061171f565b60405180910390fd5b80915050919050565b5f60045f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b5f33905090565b6109328383836001610f76565b505050565b5f8061094284610f3d565b90505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461098357610982818486611135565b5b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610a0e576109c25f855f80610f76565b600160035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825403925050819055505b5f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614610a8d57600160035f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8460025f8681526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4809150509392505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610bb257816040517f5b08ba18000000000000000000000000000000000000000000000000000000008152600401610ba99190611614565b60405180910390fd5b8060055f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c9e91906114b4565b60405180910390a3505050565b5f8373ffffffffffffffffffffffffffffffffffffffff163b1115610e57578273ffffffffffffffffffffffffffffffffffffffff1663150b7a02610cee61091e565b8685856040518563ffffffff1660e01b8152600401610d109493929190611acb565b6020604051808303815f875af1925050508015610d4b57506040513d601f19601f82011682018060405250810190610d489190611b29565b60015b610dcc573d805f8114610d79576040519150601f19603f3d011682016040523d82523d5f602084013e610d7e565b606091505b505f815103610dc457836040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600401610dbb9190611614565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614610e5557836040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600401610e4c9190611614565b60405180910390fd5b505b50505050565b606060405180602001604052805f815250905090565b60605f6001610e81846111f8565b0190505f8167ffffffffffffffff811115610e9f57610e9e6117a8565b5b6040519080825280601f01601f191660200182016040528015610ed15781602001600182028036833780820191505090505b5090505f82602001820190505b600115610f32578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581610f2757610f26611b54565b5b0494505f8503610ede575b819350505050919050565b5f60025f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b8080610fae57505f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156110e0575f610fbd8461085f565b90505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561102757508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b801561103a57506110388184610768565b155b1561107c57826040517fa9fbf51f0000000000000000000000000000000000000000000000000000000081526004016110739190611614565b60405180910390fd5b81156110de57838573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b8360045f8581526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b611140838383611349565b6111f3575f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036111b457806040517f7e2732890000000000000000000000000000000000000000000000000000000081526004016111ab919061171f565b60405180910390fd5b81816040517f177e802f0000000000000000000000000000000000000000000000000000000081526004016111ea929190611b81565b60405180910390fd5b505050565b5f805f90507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611254577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161124a57611249611b54565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310611291576d04ee2d6d415b85acef8100000000838161128757611286611b54565b5b0492506020810190505b662386f26fc1000083106112c057662386f26fc1000083816112b6576112b5611b54565b5b0492506010810190505b6305f5e10083106112e9576305f5e10083816112df576112de611b54565b5b0492506008810190505b612710831061130e57612710838161130457611303611b54565b5b0492506004810190505b60648310611331576064838161132757611326611b54565b5b0492506002810190505b600a8310611340576001810190505b80915050919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561140057508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806113c157506113c08484610768565b5b806113ff57508273ffffffffffffffffffffffffffffffffffffffff166113e7836108e5565b73ffffffffffffffffffffffffffffffffffffffff16145b5b90509392505050565b5f604051905090565b5f80fd5b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61144e8161141a565b8114611458575f80fd5b50565b5f8135905061146981611445565b92915050565b5f6020828403121561148457611483611412565b5b5f6114918482850161145b565b91505092915050565b5f8115159050919050565b6114ae8161149a565b82525050565b5f6020820190506114c75f8301846114a5565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156115045780820151818401526020810190506114e9565b5f8484015250505050565b5f601f19601f8301169050919050565b5f611529826114cd565b61153381856114d7565b93506115438185602086016114e7565b61154c8161150f565b840191505092915050565b5f6020820190508181035f83015261156f818461151f565b905092915050565b5f819050919050565b61158981611577565b8114611593575f80fd5b50565b5f813590506115a481611580565b92915050565b5f602082840312156115bf576115be611412565b5b5f6115cc84828501611596565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6115fe826115d5565b9050919050565b61160e816115f4565b82525050565b5f6020820190506116275f830184611605565b92915050565b611636816115f4565b8114611640575f80fd5b50565b5f813590506116518161162d565b92915050565b5f806040838503121561166d5761166c611412565b5b5f61167a85828601611643565b925050602061168b85828601611596565b9150509250929050565b5f805f606084860312156116ac576116ab611412565b5b5f6116b986828701611643565b93505060206116ca86828701611643565b92505060406116db86828701611596565b9150509250925092565b5f602082840312156116fa576116f9611412565b5b5f61170784828501611643565b91505092915050565b61171981611577565b82525050565b5f6020820190506117325f830184611710565b92915050565b6117418161149a565b811461174b575f80fd5b50565b5f8135905061175c81611738565b92915050565b5f806040838503121561177857611777611412565b5b5f61178585828601611643565b92505060206117968582860161174e565b9150509250929050565b5f80fd5b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6117de8261150f565b810181811067ffffffffffffffff821117156117fd576117fc6117a8565b5b80604052505050565b5f61180f611409565b905061181b82826117d5565b919050565b5f67ffffffffffffffff82111561183a576118396117a8565b5b6118438261150f565b9050602081019050919050565b828183375f83830152505050565b5f61187061186b84611820565b611806565b90508281526020810184848401111561188c5761188b6117a4565b5b611897848285611850565b509392505050565b5f82601f8301126118b3576118b26117a0565b5b81356118c384826020860161185e565b91505092915050565b5f805f80608085870312156118e4576118e3611412565b5b5f6118f187828801611643565b945050602061190287828801611643565b935050604061191387828801611596565b925050606085013567ffffffffffffffff81111561193457611933611416565b5b6119408782880161189f565b91505092959194509250565b5f806040838503121561196257611961611412565b5b5f61196f85828601611643565b925050602061198085828601611643565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806119ce57607f821691505b6020821081036119e1576119e061198a565b5b50919050565b5f6060820190506119fa5f830186611605565b611a076020830185611710565b611a146040830184611605565b949350505050565b5f81905092915050565b5f611a30826114cd565b611a3a8185611a1c565b9350611a4a8185602086016114e7565b80840191505092915050565b5f611a618285611a26565b9150611a6d8284611a26565b91508190509392505050565b5f81519050919050565b5f82825260208201905092915050565b5f611a9d82611a79565b611aa78185611a83565b9350611ab78185602086016114e7565b611ac08161150f565b840191505092915050565b5f608082019050611ade5f830187611605565b611aeb6020830186611605565b611af86040830185611710565b8181036060830152611b0a8184611a93565b905095945050505050565b5f81519050611b2381611445565b92915050565b5f60208284031215611b3e57611b3d611412565b5b5f611b4b84828501611b15565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f604082019050611b945f830185611605565b611ba16020830184611710565b939250505056fea2646970667358221220660c47cef4875784ced30d2987fb0203ddda8f97b11c21c4a3205a82e611b4d064736f6c63430008160033"`, `"0x608060405234801561000f575f80fd5b50600436106100cd575f3560e01c80636352211e1161008a578063a22cb46511610064578063a22cb46514610221578063b88d4fde1461023d578063c87b56dd14610259578063e985e9c514610289576100cd565b80636352211e146101a357806370a08231146101d357806395d89b4114610203576100cd565b806301ffc9a7146100d157806306fdde0314610101578063081812fc1461011f578063095ea7b31461014f57806323b872dd1461016b57806342842e0e14610187575b5f80fd5b6100eb60048036038101906100e6919061146f565b6102b9565b6040516100f891906114b4565b60405180910390f35b61010961039a565b6040516101169190611557565b60405180910390f35b610139600480360381019061013491906115aa565b610429565b6040516101469190611614565b60405180910390f35b61016960048036038101906101649190611657565b610444565b005b61018560048036038101906101809190611695565b61045a565b005b6101a1600480360381019061019c9190611695565b610559565b005b6101bd60048036038101906101b891906115aa565b610578565b6040516101ca9190611614565b60405180910390f35b6101ed60048036038101906101e891906116e5565b610589565b6040516101fa919061171f565b60405180910390f35b61020b61063f565b6040516102189190611557565b60405180910390f35b61023b60048036038101906102369190611762565b6106cf565b005b610257600480360381019061025291906118cc565b6106e5565b005b610273600480360381019061026e91906115aa565b610702565b6040516102809190611557565b60405180910390f35b6102a3600480360381019061029e919061194c565b610768565b6040516102b091906114b4565b60405180910390f35b5f7f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061038357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806103935750610392826107f6565b5b9050919050565b60605f80546103a8906119b7565b80601f01602080910402602001604051908101604052809291908181526020018280546103d4906119b7565b801561041f5780601f106103f65761010080835404028352916020019161041f565b820191905f5260205f20905b81548152906001019060200180831161040257829003601f168201915b5050505050905090565b5f6104338261085f565b5061043d826108e5565b9050919050565b610456828261045161091e565b610925565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036104ca575f6040517f64a0ae920000000000000000000000000000000000000000000000000000000081526004016104c19190611614565b60405180910390fd5b5f6104dd83836104d861091e565b610937565b90508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610553578382826040517f64283d7b00000000000000000000000000000000000000000000000000000000815260040161054a939291906119e7565b60405180910390fd5b50505050565b61057383838360405180602001604052805f8152506106e5565b505050565b5f6105828261085f565b9050919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036105fa575f6040517f89c62b640000000000000000000000000000000000000000000000000000000081526004016105f19190611614565b60405180910390fd5b60035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b60606001805461064e906119b7565b80601f016020809104026020016040519081016040528092919081815260200182805461067a906119b7565b80156106c55780601f1061069c576101008083540402835291602001916106c5565b820191905f5260205f20905b8154815290600101906020018083116106a857829003601f168201915b5050505050905090565b6106e16106da61091e565b8383610b42565b5050565b6106f084848461045a565b6106fc84848484610cab565b50505050565b606061070d8261085f565b505f610717610e5d565b90505f8151116107355760405180602001604052805f815250610760565b8061073f84610e73565b604051602001610750929190611a56565b6040516020818303038152906040525b915050919050565b5f60055f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905092915050565b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b5f8061086a83610f3d565b90505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036108dc57826040517f7e2732890000000000000000000000000000000000000000000000000000000081526004016108d3919061171f565b60405180910390fd5b80915050919050565b5f60045f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b5f33905090565b6109328383836001610f76565b505050565b5f8061094284610f3d565b90505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461098357610982818486611135565b5b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610a0e576109c25f855f80610f76565b600160035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825403925050819055505b5f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614610a8d57600160035f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8460025f8681526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4809150509392505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610bb257816040517f5b08ba18000000000000000000000000000000000000000000000000000000008152600401610ba99190611614565b60405180910390fd5b8060055f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c9e91906114b4565b60405180910390a3505050565b5f8373ffffffffffffffffffffffffffffffffffffffff163b1115610e57578273ffffffffffffffffffffffffffffffffffffffff1663150b7a02610cee61091e565b8685856040518563ffffffff1660e01b8152600401610d109493929190611acb565b6020604051808303815f875af1925050508015610d4b57506040513d601f19601f82011682018060405250810190610d489190611b29565b60015b610dcc573d805f8114610d79576040519150601f19603f3d011682016040523d82523d5f602084013e610d7e565b606091505b505f815103610dc457836040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600401610dbb9190611614565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614610e5557836040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600401610e4c9190611614565b60405180910390fd5b505b50505050565b606060405180602001604052805f815250905090565b60605f6001610e81846111f8565b0190505f8167ffffffffffffffff811115610e9f57610e9e6117a8565b5b6040519080825280601f01601f191660200182016040528015610ed15781602001600182028036833780820191505090505b5090505f82602001820190505b600115610f32578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581610f2757610f26611b54565b5b0494505f8503610ede575b819350505050919050565b5f60025f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b8080610fae57505f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156110e0575f610fbd8461085f565b90505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561102757508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b801561103a57506110388184610768565b155b1561107c57826040517fa9fbf51f0000000000000000000000000000000000000000000000000000000081526004016110739190611614565b60405180910390fd5b81156110de57838573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b8360045f8581526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b611140838383611349565b6111f3575f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036111b457806040517f7e2732890000000000000000000000000000000000000000000000000000000081526004016111ab919061171f565b60405180910390fd5b81816040517f177e802f0000000000000000000000000000000000000000000000000000000081526004016111ea929190611b81565b60405180910390fd5b505050565b5f805f90507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611254577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161124a57611249611b54565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310611291576d04ee2d6d415b85acef8100000000838161128757611286611b54565b5b0492506020810190505b662386f26fc1000083106112c057662386f26fc1000083816112b6576112b5611b54565b5b0492506010810190505b6305f5e10083106112e9576305f5e10083816112df576112de611b54565b5b0492506008810190505b612710831061130e57612710838161130457611303611b54565b5b0492506004810190505b60648310611331576064838161132757611326611b54565b5b0492506002810190505b600a8310611340576001810190505b80915050919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561140057508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806113c157506113c08484610768565b5b806113ff57508273ffffffffffffffffffffffffffffffffffffffff166113e7836108e5565b73ffffffffffffffffffffffffffffffffffffffff16145b5b90509392505050565b5f604051905090565b5f80fd5b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61144e8161141a565b8114611458575f80fd5b50565b5f8135905061146981611445565b92915050565b5f6020828403121561148457611483611412565b5b5f6114918482850161145b565b91505092915050565b5f8115159050919050565b6114ae8161149a565b82525050565b5f6020820190506114c75f8301846114a5565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156115045780820151818401526020810190506114e9565b5f8484015250505050565b5f601f19601f8301169050919050565b5f611529826114cd565b61153381856114d7565b93506115438185602086016114e7565b61154c8161150f565b840191505092915050565b5f6020820190508181035f83015261156f818461151f565b905092915050565b5f819050919050565b61158981611577565b8114611593575f80fd5b50565b5f813590506115a481611580565b92915050565b5f602082840312156115bf576115be611412565b5b5f6115cc84828501611596565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6115fe826115d5565b9050919050565b61160e816115f4565b82525050565b5f6020820190506116275f830184611605565b92915050565b611636816115f4565b8114611640575f80fd5b50565b5f813590506116518161162d565b92915050565b5f806040838503121561166d5761166c611412565b5b5f61167a85828601611643565b925050602061168b85828601611596565b9150509250929050565b5f805f606084860312156116ac576116ab611412565b5b5f6116b986828701611643565b93505060206116ca86828701611643565b92505060406116db86828701611596565b9150509250925092565b5f602082840312156116fa576116f9611412565b5b5f61170784828501611643565b91505092915050565b61171981611577565b82525050565b5f6020820190506117325f830184611710565b92915050565b6117418161149a565b811461174b575f80fd5b50565b5f8135905061175c81611738565b92915050565b5f806040838503121561177857611777611412565b5b5f61178585828601611643565b92505060206117968582860161174e565b9150509250929050565b5f80fd5b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6117de8261150f565b810181811067ffffffffffffffff821117156117fd576117fc6117a8565b5b80604052505050565b5f61180f611409565b905061181b82826117d5565b919050565b5f67ffffffffffffffff82111561183a576118396117a8565b5b6118438261150f565b9050602081019050919050565b828183375f83830152505050565b5f61187061186b84611820565b611806565b90508281526020810184848401111561188c5761188b6117a4565b5b611897848285611850565b509392505050565b5f82601f8301126118b3576118b26117a0565b5b81356118c384826020860161185e565b91505092915050565b5f805f80608085870312156118e4576118e3611412565b5b5f6118f187828801611643565b945050602061190287828801611643565b935050604061191387828801611596565b925050606085013567ffffffffffffffff81111561193457611933611416565b5b6119408782880161189f565b91505092959194509250565b5f806040838503121561196257611961611412565b5b5f61196f85828601611643565b925050602061198085828601611643565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806119ce57607f821691505b6020821081036119e1576119e061198a565b5b50919050565b5f6060820190506119fa5f830186611605565b611a076020830185611710565b611a146040830184611605565b949350505050565b5f81905092915050565b5f611a30826114cd565b611a3a8185611a1c565b9350611a4a8185602086016114e7565b80840191505092915050565b5f611a618285611a26565b9150611a6d8284611a26565b91508190509392505050565b5f81519050919050565b5f82825260208201905092915050565b5f611a9d82611a79565b611aa78185611a83565b9350611ab78185602086016114e7565b611ac08161150f565b840191505092915050565b5f608082019050611ade5f830187611605565b611aeb6020830186611605565b611af86040830185611710565b8181036060830152611b0a8184611a93565b905095945050505050565b5f81519050611b2381611445565b92915050565b5f60208284031215611b3e57611b3d611412565b5b5f611b4b84828501611b15565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f604082019050611b945f830185611605565b611ba16020830184611710565b939250505056fea2646970667358221220660c47cef4875784ced30d2987fb0203ddda8f97b11c21c4a3205a82e611b4d064736f6c63430008160033"`, `undefined`\> -Defined in: [contract-lib/ERC721.ts:72](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/contract-lib/ERC721.ts#L72) +Defined in: [contract-lib/ERC721.ts:60](https://github.com/evmts/tevm-contract/blob/main/src/contract-lib/ERC721.ts#L60) -Bytecode and ABI for the ERC721 contract from OpenZeppelin. -This constant represents a standard ERC721 token implementation for non-fungible tokens (NFTs). -For more details, see the [OpenZeppelin ERC721 documentation](https://docs.openzeppelin.com/contracts/4.x/erc721). +A deployable OpenZeppelin ERC721 contract with compiled creation and runtime bytecode. -## Examples +The constructor accepts a collection name and symbol. This fixture does not expose a public +mint function; it is intended for ABI, deployment, and interoperability tests. + +## Example -Using the ERC721 contract in a deployment script: ```typescript -import { ERC721 } from 'tevm/contract' +import { ERC721 } from '@tevm/contract' -// Deploy the ERC721 contract -const deployedERC721 = await tevm.deployContract(ERC721.deploy('MyNFT', 'MNFT')) -console.log('ERC721 deployed at:', deployedERC721.address) +const deployment = ERC721.deploy('My Collection', 'NFT') +const collection = ERC721.withAddress('0x0000000000000000000000000000000000000001') -// Interact with the deployed contract -const owner = await tevm.contract(ERC721.read.ownerOf(deployedERC721.address, 1n)) -console.log('Owner of token 1:', owner) +const ownerAction = collection.read.ownerOf(1n) +const approvalAction = collection.write.setApprovalForAll( + '0x0000000000000000000000000000000000000002', + true, +) ``` -Using the ERC721 contract with an existing deployment: -```typescript -import { ERC721 } from 'tevm/contract' - -const existingERC721 = ERC721.withAddress('0x1234...') +## See -// Read token name -const name = await tevm.contract(existingERC721.read.name()) -console.log('Token name:', name) - -// Transfer token -await tevm.contract(existingERC721.write.transferFrom('0xabcd...', '0x5678...', 1n)) -``` + - [OpenZeppelin ERC721](https://docs.openzeppelin.com/contracts/4.x/erc721) + - [prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) diff --git a/docs/variables/ErrorContract.md b/docs/variables/ErrorContract.md index 84fc6d1..02021c7 100644 --- a/docs/variables/ErrorContract.md +++ b/docs/variables/ErrorContract.md @@ -2,14 +2,59 @@ *** -[@tevm/contract](../globals.md) / ErrorContract +[@tevm/contract](../README.md) / ErrorContract # Variable: ErrorContract > `const` **ErrorContract**: [`Contract`](../type-aliases/Contract.md)\<`"ErrorContract"`, readonly \[`"error ErrorWithMultipleParams(string message, bytes32 hash, address[] users)"`, `"error ErrorWithSingleParam(uint256 amount)"`, `"error SimpleError()"`, `"function errorOutOfGas()"`, `"function errorWithInvalidOpcode()"`, `"function panicWithArithmeticOverflow()"`, `"function panicWithArrayOutOfBounds()"`, `"function panicWithAssertFailure()"`, `"function panicWithDivisionByZero()"`, `"function revertWithCustomErrorMultipleParams()"`, `"function revertWithCustomErrorSingleParam()"`, `"function revertWithRequireAndMessage()"`, `"function revertWithRequireNoMessage()"`, `"function revertWithSimpleCustomError()"`, `"function revertWithStringError()"`, `"function revertWithoutMessage()"`\], `undefined`, `"0x60806040526040518060400160405280600160ff168152602001600260ff168152505f906002602e929190603e565b503480156039575f5ffd5b5060a2565b828054828255905f5260205f20908101928215607a579160200282015b828111156079578251829060ff16905591602001919060010190605b565b5b509050608591906089565b5090565b5b80821115609e575f815f905550600101608a565b5090565b61086b806100af5f395ff3fe608060405234801561000f575f5ffd5b50600436106100cd575f3560e01c8063900a9c451161008a578063be8cdacd11610064578063be8cdacd1461012b578063c06a97cb14610135578063eca9a83d1461013f578063f5ba831514610149576100cd565b8063900a9c451461010d578063b3456cd614610117578063b641db8314610121576100cd565b806358df7f77146100d15780636ab639f2146100db5780636e798b85146100e5578063728b2fc4146100ef5780637b41bf2f146100f95780638f05ba6714610103575b5f5ffd5b6100d9610153565b005b6100e3610177565b005b6100ed610182565b005b6100f7610192565b005b610101610194565b005b61010b6101a9565b005b6101156101eb565b005b61011f61021d565b005b610129610368565b005b610133610371565b005b61013d6103ac565b005b6101476103b0565b005b6101516103e5565b005b5f600590505f818154811061016b5761016a610423565b5b905f5260205f20505050565b5f610180575f5ffd5b565b5f6101905761018f610450565b5b565bfe5b5f600a90505f816101a591906104e0565b5050565b5f6101e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e09061056a565b60405180910390fd5b565b6040517fc2bb947c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f600267ffffffffffffffff81111561023957610238610588565b5b6040519080825280602002602001820160405280156102675781602001602082028036833780820191505090505b5090506001815f8151811061027f5761027e610423565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506002816001815181106102cf576102ce610423565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658816040517fae6e59ae00000000000000000000000000000000000000000000000000000000815260040161035f9291906106fe565b60405180910390fd5b5b600161036957565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a390610789565b60405180910390fd5b5f5ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90506001816103e191906107a7565b5050565b60646040517ff052b72100000000000000000000000000000000000000000000000000000000815260040161041a919061081c565b60405180910390fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f819050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6104ea8261047d565b91506104f58361047d565b92508261050557610504610486565b5b828204905092915050565b5f82825260208201905092915050565b7f52657175697265206661696c65642077697468206d65737361676500000000005f82015250565b5f610554601b83610510565b915061055f82610520565b602082019050919050565b5f6020820190508181035f83015261058181610548565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f536f6d657468696e672077656e742077726f6e670000000000000000000000005f82015250565b5f6105e9601483610510565b91506105f4826105b5565b602082019050919050565b5f819050919050565b610611816105ff565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61066982610640565b9050919050565b6106798161065f565b82525050565b5f61068a8383610670565b60208301905092915050565b5f602082019050919050565b5f6106ac82610617565b6106b68185610621565b93506106c183610631565b805f5b838110156106f15781516106d8888261067f565b97506106e383610696565b9250506001810190506106c4565b5085935050505092915050565b5f6060820190508181035f830152610715816105dd565b90506107246020830185610608565b818103604083015261073681846106a2565b90509392505050565b7f54686973206973206120737472696e67206572726f72206d65737361676500005f82015250565b5f610773601e83610510565b915061077e8261073f565b602082019050919050565b5f6020820190508181035f8301526107a081610767565b9050919050565b5f6107b18261047d565b91506107bc8361047d565b92508282019050808211156107d4576107d36104b3565b5b92915050565b5f819050919050565b5f819050919050565b5f6108066108016107fc846107da565b6107e3565b61047d565b9050919050565b610816816107ec565b82525050565b5f60208201905061082f5f83018461080d565b9291505056fea2646970667358221220cd052e18e7a3cd3755fb94f707c95aba503ac6cd048934d30675b650d603fa9164736f6c634300081e0033"`, `"0x608060405234801561000f575f5ffd5b50600436106100cd575f3560e01c8063900a9c451161008a578063be8cdacd11610064578063be8cdacd1461012b578063c06a97cb14610135578063eca9a83d1461013f578063f5ba831514610149576100cd565b8063900a9c451461010d578063b3456cd614610117578063b641db8314610121576100cd565b806358df7f77146100d15780636ab639f2146100db5780636e798b85146100e5578063728b2fc4146100ef5780637b41bf2f146100f95780638f05ba6714610103575b5f5ffd5b6100d9610153565b005b6100e3610177565b005b6100ed610182565b005b6100f7610192565b005b610101610194565b005b61010b6101a9565b005b6101156101eb565b005b61011f61021d565b005b610129610368565b005b610133610371565b005b61013d6103ac565b005b6101476103b0565b005b6101516103e5565b005b5f600590505f818154811061016b5761016a610423565b5b905f5260205f20505050565b5f610180575f5ffd5b565b5f6101905761018f610450565b5b565bfe5b5f600a90505f816101a591906104e0565b5050565b5f6101e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e09061056a565b60405180910390fd5b565b6040517fc2bb947c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f600267ffffffffffffffff81111561023957610238610588565b5b6040519080825280602002602001820160405280156102675781602001602082028036833780820191505090505b5090506001815f8151811061027f5761027e610423565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506002816001815181106102cf576102ce610423565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658816040517fae6e59ae00000000000000000000000000000000000000000000000000000000815260040161035f9291906106fe565b60405180910390fd5b5b600161036957565b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a390610789565b60405180910390fd5b5f5ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90506001816103e191906107a7565b5050565b60646040517ff052b72100000000000000000000000000000000000000000000000000000000815260040161041a919061081c565b60405180910390fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b5f819050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6104ea8261047d565b91506104f58361047d565b92508261050557610504610486565b5b828204905092915050565b5f82825260208201905092915050565b7f52657175697265206661696c65642077697468206d65737361676500000000005f82015250565b5f610554601b83610510565b915061055f82610520565b602082019050919050565b5f6020820190508181035f83015261058181610548565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f536f6d657468696e672077656e742077726f6e670000000000000000000000005f82015250565b5f6105e9601483610510565b91506105f4826105b5565b602082019050919050565b5f819050919050565b610611816105ff565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61066982610640565b9050919050565b6106798161065f565b82525050565b5f61068a8383610670565b60208301905092915050565b5f602082019050919050565b5f6106ac82610617565b6106b68185610621565b93506106c183610631565b805f5b838110156106f15781516106d8888261067f565b97506106e383610696565b9250506001810190506106c4565b5085935050505092915050565b5f6060820190508181035f830152610715816105dd565b90506107246020830185610608565b818103604083015261073681846106a2565b90509392505050565b7f54686973206973206120737472696e67206572726f72206d65737361676500005f82015250565b5f610773601e83610510565b915061077e8261073f565b602082019050919050565b5f6020820190508181035f8301526107a081610767565b9050919050565b5f6107b18261047d565b91506107bc8361047d565b92508282019050808211156107d4576107d36104b3565b5b92915050565b5f819050919050565b5f819050919050565b5f6108066108016107fc846107da565b6107e3565b61047d565b9050919050565b610816816107ec565b82525050565b5f60208201905061082f5f83018461080d565b9291505056fea2646970667358221220cd052e18e7a3cd3755fb94f707c95aba503ac6cd048934d30675b650d603fa9164736f6c634300081e0033"`, `undefined`\> -Defined in: [contract-lib/ErrorContract.s.sol.ts:31](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/contract-lib/ErrorContract.s.sol.ts#L31) +Defined in: [contract-lib/ErrorContract.s.sol.ts:75](https://github.com/evmts/tevm-contract/blob/main/src/contract-lib/ErrorContract.s.sol.ts#L75) + +A prebuilt contract that can fail in every way the EVM allows, each behind a zero-argument +function. Use it to exercise revert decoding and error-handling paths without needing a +Solidity toolchain. + +- Custom errors: `revertWithSimpleCustomError`, `revertWithCustomErrorSingleParam`, + `revertWithCustomErrorMultipleParams` +- String and bare reverts: `revertWithStringError`, `revertWithRequireAndMessage`, + `revertWithRequireNoMessage`, `revertWithoutMessage` +- Panics: `panicWithAssertFailure`, `panicWithArithmeticOverflow`, `panicWithDivisionByZero`, + `panicWithArrayOutOfBounds` +- Low-level failures: `errorOutOfGas`, `errorWithInvalidOpcode` + +The custom error definitions are in the ABI, so they are attached to every action this +contract produces and a revert decodes to a named error rather than raw bytes. + +Ships with real compiled `bytecode` and `deployedBytecode` but no `address` โ€” call +`withAddress` after deploying. Takes no constructor arguments. + +## Example + +```typescript +import { ErrorContract } from '@tevm/contract' +import { createMemoryClient, PREFUNDED_ACCOUNTS } from 'tevm' + +const client = createMemoryClient() +await client.tevmReady() + +const result = await client.tevmDeploy({ + from: PREFUNDED_ACCOUNTS[0].address, + ...ErrorContract.deploy(), + addToMempool: true, +}) +await client.tevmMine({ blockCount: 1 }) + +if (!result.createdAddress) throw new Error('deployment failed') +const errors = ErrorContract.withAddress(result.createdAddress) + +const failed = await client.tevmContract({ + ...errors.write.revertWithCustomErrorSingleParam(), + from: PREFUNDED_ACCOUNTS[0].address, + throwOnFail: false, +}) +console.log(failed.errors?.[0]?.message) +``` ## See -[contract docs](https://tevm.sh/learn/contracts/) for more documentation +[prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) for more documentation diff --git a/docs/variables/SimpleContract.md b/docs/variables/SimpleContract.md index dad800f..8973968 100644 --- a/docs/variables/SimpleContract.md +++ b/docs/variables/SimpleContract.md @@ -2,43 +2,31 @@ *** -[@tevm/contract](../globals.md) / SimpleContract +[@tevm/contract](../README.md) / SimpleContract # Variable: SimpleContract > `const` **SimpleContract**: [`Contract`](../type-aliases/Contract.md)\<`"SimpleContract"`, readonly \[`"constructor(uint256 initialValue)"`, `"event ValueSet(uint256 newValue)"`, `"function get() view returns (uint256)"`, `"function set(uint256 newValue)"`\], `undefined`, `"0x608060405234801561000f575f80fd5b5060405161022638038061022683398181016040528101906100319190610074565b805f819055505061009f565b5f80fd5b5f819050919050565b61005381610041565b811461005d575f80fd5b50565b5f8151905061006e8161004a565b92915050565b5f602082840312156100895761008861003d565b5b5f61009684828501610060565b91505092915050565b61017a806100ac5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c806360fe47b1146100385780636d4ce63c14610054575b5f80fd5b610052600480360381019061004d91906100f1565b610072565b005b61005c6100b2565b604051610069919061012b565b60405180910390f35b805f819055507f012c78e2b84325878b1bd9d250d772cfe5bda7722d795f45036fa5e1e6e303fc816040516100a7919061012b565b60405180910390a150565b5f8054905090565b5f80fd5b5f819050919050565b6100d0816100be565b81146100da575f80fd5b50565b5f813590506100eb816100c7565b92915050565b5f60208284031215610106576101056100ba565b5b5f610113848285016100dd565b91505092915050565b610125816100be565b82525050565b5f60208201905061013e5f83018461011c565b9291505056fea2646970667358221220792d4ee4a770b6a319a0ec659b77ea24497824649e20dcdea1dd7acf6118a5fe64736f6c63430008160033"`, `"0x608060405234801561000f575f80fd5b5060043610610034575f3560e01c806360fe47b1146100385780636d4ce63c14610054575b5f80fd5b610052600480360381019061004d91906100f1565b610072565b005b61005c6100b2565b604051610069919061012b565b60405180910390f35b805f819055507f012c78e2b84325878b1bd9d250d772cfe5bda7722d795f45036fa5e1e6e303fc816040516100a7919061012b565b60405180910390a150565b5f8054905090565b5f80fd5b5f819050919050565b6100d0816100be565b81146100da575f80fd5b50565b5f813590506100eb816100c7565b92915050565b5f60208284031215610106576101056100ba565b5b5f610113848285016100dd565b91505092915050565b610125816100be565b82525050565b5f60208201905061013e5f83018461011c565b9291505056fea2646970667358221220792d4ee4a770b6a319a0ec659b77ea24497824649e20dcdea1dd7acf6118a5fe64736f6c63430008160033"`, `undefined`\> -Defined in: [contract-lib/SimpleContract.s.sol.ts:51](https://github.com/evmts/tevm-monorepo/blob/main/packages/contract/src/contract-lib/SimpleContract.s.sol.ts#L51) +Defined in: [contract-lib/SimpleContract.s.sol.ts:35](https://github.com/evmts/tevm-contract/blob/main/src/contract-lib/SimpleContract.s.sol.ts#L35) -Bytecode and ABI for a simple contract with a single state variable. -This constant represents a basic contract that can get and set a uint256 value. +A deployable counter contract with a `uint256` value, a getter, a setter, and a `ValueSet` +event. It ships with compiled creation and runtime bytecode. -## Examples +## Example -Using the SimpleContract in a deployment script: ```typescript -import { SimpleContract } from 'tevm/contract' - -// Deploy the SimpleContract with an initial value -const deployedSimpleContract = await tevm.deployContract(SimpleContract.deploy(42n)) -console.log('SimpleContract deployed at:', deployedSimpleContract.address) - -// Interact with the deployed contract -const value = await tevm.contract(SimpleContract.read.get()) -console.log('Current value:', value) +import { SimpleContract } from '@tevm/contract' + +const deployment = SimpleContract.deploy(42n) +const counter = SimpleContract.withAddress( + '0x0000000000000000000000000000000000000001', +) +const readAction = counter.read.get() +const writeAction = counter.write.set(100n) +const eventFilter = counter.events.ValueSet({ fromBlock: 'latest' }) ``` -Using the SimpleContract with an existing deployment: -```typescript -import { SimpleContract } from 'tevm/contract' - -const existingSimpleContract = SimpleContract.withAddress('0x1234...') - -// Read current value -const currentValue = await tevm.contract(existingSimpleContract.read.get()) -console.log('Current value:', currentValue) +## See -// Set a new value -await tevm.contract(existingSimpleContract.write.set(100n)) -console.log('New value set') -``` +[prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) diff --git a/package.json b/package.json index 00dacea..2f0d8ba 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "build": "pnpm run clean:build && pnpm run build:dist && pnpm run build:types", "build:dist": "tsup", "build:types": "tsup --dts-only && tsc --project tsconfig.build.json --emitDeclarationOnly", + "check:package": "publint && attw --pack .", "changeset": "changeset", "clean:build": "rm -rf dist types", "docs": "typedoc", @@ -69,10 +70,12 @@ "@tevm/utils": "^1.0.0-next.148" }, "devDependencies": { + "@arethetypeswrong/cli": "^0.18.5", "@biomejs/biome": "^2.4.15", "@changesets/changelog-github": "^0.7.0", "@changesets/cli": "^2.31.0", "@vitest/coverage-v8": "^4.1.6", + "publint": "^0.3.22", "tsup": "^8.5.1", "typedoc": "^0.28.19", "typedoc-plugin-markdown": "^4.11.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c2aed9..63f719c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,6 +15,9 @@ importers: specifier: ^1.0.0-next.148 version: 1.0.0-next.148(typescript@6.0.3)(viem@2.55.10(typescript@6.0.3)(zod@4.4.3))(zod@4.4.3) devDependencies: + '@arethetypeswrong/cli': + specifier: ^0.18.5 + version: 0.18.5 '@biomejs/biome': specifier: ^2.4.15 version: 2.5.6 @@ -27,6 +30,9 @@ importers: '@vitest/coverage-v8': specifier: ^4.1.6 version: 4.1.10(vitest@4.1.10) + publint: + specifier: ^0.3.22 + version: 0.3.22 tsup: specifier: ^8.5.1 version: 8.5.1(jiti@2.7.0)(postcss@8.5.24)(tsx@4.23.1)(typescript@6.0.3)(yaml@2.9.0) @@ -41,7 +47,7 @@ importers: version: 6.0.3 vitest: specifier: ^4.1.6 - version: 4.1.10(@types/node@24.13.3)(@vitest/coverage-v8@4.1.10)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0)) + version: 4.1.10(@edge-runtime/vm@3.2.0)(@types/node@24.13.3)(@vitest/coverage-v8@4.1.10)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0)) site: dependencies: @@ -55,8 +61,8 @@ importers: specifier: ^8.0.0 version: 8.1.5(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0) vocs: - specifier: 2.7.0 - version: 2.7.0(@types/react@19.2.17)(@vue/compiler-sfc@3.5.40)(esbuild@0.28.1)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(rolldown@1.1.5)(rollup@4.62.3)(typescript@6.0.3)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(waku@1.0.0-beta.8(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)) + specifier: 2.7.2 + version: 2.7.2(@types/react@19.2.17)(@vue/compiler-sfc@3.5.40)(esbuild@0.28.1)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(rolldown@1.1.5)(rollup@4.62.3)(typescript@6.0.3)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(waku@1.0.0-beta.8(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)) waku: specifier: ^1.0.0-beta.6 version: 1.0.0-beta.8(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0) @@ -76,9 +82,21 @@ packages: '@adraffy/ens-normalize@1.11.1': resolution: {integrity: sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==} + '@andrewbranch/untar.js@1.0.3': + resolution: {integrity: sha512-Jh15/qVmrLGhkKJBdXlK1+9tY4lZruYjsgkDFj08ZmDiWVBLJcqkok7Z0/R0In+i1rScBpJlSvrTS2Lm41Pbnw==} + '@antfu/install-pkg@1.1.0': resolution: {integrity: sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ==} + '@arethetypeswrong/cli@0.18.5': + resolution: {integrity: sha512-gM+8vRsQOD/Uc7EnBedUhkG5OCsDWE4uoak5QvomGpMpaky0Eh41p04nIMgrWb8EOmqZUJGc6zz9hsP6E56R7g==} + engines: {node: '>=20'} + hasBin: true + + '@arethetypeswrong/core@0.18.5': + resolution: {integrity: sha512-9ytjzGwxjm9Uz7I9avfbt5vlQt6uk9uRRESzJjqrznl6WKvI6dwYTo+vJ3U02Wrq/mR3iql/PzhvHhKdJIAjDQ==} + engines: {node: '>=20'} + '@babel/code-frame@7.29.7': resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==} engines: {node: '>=6.9.0'} @@ -234,6 +252,9 @@ packages: cpu: [x64] os: [win32] + '@braidai/lang@1.1.2': + resolution: {integrity: sha512-qBcknbBufNHlui137Hft8xauQMTZDKdophmLFv05r2eNmdIv/MlPuP4TdUknHG68UdWLgVZwgxVe735HzJNIwA==} + '@changesets/apply-release-plan@7.1.1': resolution: {integrity: sha512-9qPCm/rLx/xoOFXIHGB229+4GOL76S4MC+7tyOuTsR6+1jYlfFDQORdvwR5hDA6y4FL2BPt3qpbcQIS+dW85LA==} @@ -343,6 +364,18 @@ packages: react: ^16.8.0 || ^17 || ^18 || ^19 react-dom: ^16.8.0 || ^17 || ^18 || ^19 + '@colors/colors@1.5.0': + resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} + engines: {node: '>=0.1.90'} + + '@edge-runtime/primitives@4.1.0': + resolution: {integrity: sha512-Vw0lbJ2lvRUqc7/soqygUX216Xb8T3WBZ987oywz6aJqRxcwSVWwr9e+Nqo2m9bxobA9mdbWNNoRY6S9eko1EQ==} + engines: {node: '>=16'} + + '@edge-runtime/vm@3.2.0': + resolution: {integrity: sha512-0dEVyRLM/lG4gp1R/Ik5bfPl/1wX00xFwd5KcNH602tzBa09oF7pbTKETEhR1GjZ75K6OJnYFu8II2dyMhONMw==} + engines: {node: '>=16'} + '@emnapi/core@1.11.1': resolution: {integrity: sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==} @@ -818,6 +851,9 @@ packages: '@lezer/yaml@1.0.4': resolution: {integrity: sha512-2lrrHqxalACEbxIbsjhqGpSW8kWpUKuY6RHgnSAFZa6qK62wvnPxA8hGOwOoDbwHcOFs5M4o27mjGu+P7TvBmw==} + '@loaderkit/resolve@1.0.6': + resolution: {integrity: sha512-G8FdIoF5CypfwmD9rl8BXod5HDn8JqB0CCNBXDTaRZ+yRYhARrrSToX1zg1zy9jX3zLqigsELwhT4gNtkdQAUg==} + '@manypkg/find-root@1.1.0': resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} @@ -899,6 +935,10 @@ packages: '@phosphor-icons/core@2.1.1': resolution: {integrity: sha512-v4ARvrip4qBCImOE5rmPUylOEK4iiED9ZyKjcvzuezqMaiRASCHKcRIuvvxL/twvLpkfnEODCOJp5dM4eZilxQ==} + '@publint/pack@0.1.6': + resolution: {integrity: sha512-3uVNyGcVplhPZSLVyeIpL7+cIRn1YCSNHLG/rUIlBQMVH8YuN9++YF+5+UDIIO9RW98dujiUoTltO7RDB5bFJA==} + engines: {node: '>=18'} + '@react-hook/intersection-observer@3.1.2': resolution: {integrity: sha512-mWU3BMkmmzyYMSuhO9wu3eJVP21N8TcgYm9bZnTrMwuM818bEk+0NRM3hP+c/TqA9Ln5C7qE53p1H0QMtzYdvQ==} peerDependencies: @@ -1313,6 +1353,10 @@ packages: '@shikijs/vscode-textmate@10.0.2': resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==} + '@sindresorhus/is@4.6.0': + resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} + engines: {node: '>=10'} + '@standard-schema/spec@1.1.0': resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} @@ -1912,10 +1956,22 @@ packages: resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} + ansi-escapes@7.3.0: + resolution: {integrity: sha512-BvU8nYgGQBxcmMuEeUEmNTvrMVjJNSH7RgW24vXexN4Ven6qCvy4TntnvlnwnMLTVlcRQQdbRY8NKnaIoeWDNg==} + engines: {node: '>=18'} + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} + ansi-regex@6.2.2: + resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==} + engines: {node: '>=12'} + + ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} @@ -2026,10 +2082,18 @@ packages: resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==} engines: {node: '>=18'} + chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + chalk@5.6.2: resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + char-regex@1.0.2: + resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} + engines: {node: '>=10'} + character-entities-html4@2.1.0: resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==} @@ -2053,12 +2117,27 @@ packages: resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==} engines: {node: '>=6.0'} + cjs-module-lexer@1.4.3: + resolution: {integrity: sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==} + class-variance-authority@0.7.1: resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==} clean-set@1.1.2: resolution: {integrity: sha512-cA8uCj0qSoG9e0kevyOWXwPaELRPVg5Pxp6WskLMwerx257Zfnh8Nl0JBH59d7wQzij2CK7qEfJQK3RjuKKIug==} + cli-highlight@2.1.11: + resolution: {integrity: sha512-9KDcoEVwyUXrjcJNvHD0NFc/hiwe/WPVYIleQh2O1N2Zro5gWJZ/K+3DGn8w8P/F6FxOgzyC5bxDyHIgCSPhGg==} + engines: {node: '>=8.0.0', npm: '>=5.0.0'} + hasBin: true + + cli-table3@0.6.5: + resolution: {integrity: sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==} + engines: {node: 10.* || >= 12.*} + + cliui@7.0.4: + resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} + clsx@2.1.1: resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} engines: {node: '>=6'} @@ -2066,9 +2145,20 @@ packages: collapse-white-space@2.1.0: resolution: {integrity: sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw==} + color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + + color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + comma-separated-tokens@2.0.3: resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} + commander@10.0.1: + resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} + engines: {node: '>=14'} + commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} @@ -2214,6 +2304,12 @@ packages: electron-to-chromium@1.5.398: resolution: {integrity: sha512-AsvhAxopJGh6museTDMIjn6JpDYOfgu4RLlygomt87MUwBUqTfd/1EiPtx10/LZE8xpTvkP2E9Gafq7lkLtodQ==} + emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + + emojilib@2.4.0: + resolution: {integrity: sha512-5U0rVMU5Y2n2+ykNLQqMoqklN9ICBT/KsvC1Gz6vqHbz2AXXGkG+Pm5rMWk/8Vjrr/mY9985Hi8DYzn1F09Nyw==} + encodeurl@2.0.0: resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==} engines: {node: '>= 0.8'} @@ -2238,6 +2334,10 @@ packages: resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==} engines: {node: '>=0.12'} + environment@1.1.0: + resolution: {integrity: sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==} + engines: {node: '>=18'} + error-ex@1.3.4: resolution: {integrity: sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==} @@ -2425,6 +2525,9 @@ packages: picomatch: optional: true + fflate@0.8.3: + resolution: {integrity: sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==} + fill-range@7.1.1: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} @@ -2486,6 +2589,10 @@ packages: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} + get-caller-file@2.0.5: + resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} + engines: {node: 6.* || 8.* || >= 10.*} + get-intrinsic@1.3.0: resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} engines: {node: '>= 0.4'} @@ -2591,6 +2698,9 @@ packages: hastscript@9.0.1: resolution: {integrity: sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w==} + highlight.js@10.7.3: + resolution: {integrity: sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==} + highlight.js@11.11.1: resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==} engines: {node: '>=12.0.0'} @@ -2684,6 +2794,10 @@ packages: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} + is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -3026,6 +3140,17 @@ packages: markdown-table@3.0.4: resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==} + marked-terminal@7.3.0: + resolution: {integrity: sha512-t4rBvPsHc57uE/2nJOLmMbZCQ4tgAccAED3ngXQqW6g+TxA488JzJ+FK3lQkzBQOI1mRV/r/Kq+1ZlJ4D0owQw==} + engines: {node: '>=16.0.0'} + peerDependencies: + marked: '>=1 <16' + + marked@9.1.6: + resolution: {integrity: sha512-jcByLnIFkd5gSXZmjNvS1TlmRhCXZjIzHYlaGkPlLIekG55JDR2Z4va9tZwCiP+/RDERiNhMOFu01xd6O5ct1Q==} + engines: {node: '>= 16'} + hasBin: true + math-intrinsics@1.1.0: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} @@ -3311,6 +3436,10 @@ packages: no-case@3.0.4: resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} + node-emoji@2.2.0: + resolution: {integrity: sha512-Z3lTE9pLaJF47NyMhd4ww1yFTAP8YhYI8SleJiHzM46Fgpm5cnNzSl9XfzFNqbaz+VlJrIj3fXQ4DeN1Rjm6cw==} + engines: {node: '>=18'} + node-fetch@2.7.0: resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} engines: {node: 4.x || >=6.0.0} @@ -3433,6 +3562,15 @@ packages: resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} engines: {node: '>=18'} + parse5-htmlparser2-tree-adapter@6.0.1: + resolution: {integrity: sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==} + + parse5@5.1.1: + resolution: {integrity: sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==} + + parse5@6.0.1: + resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} + parse5@7.3.0: resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==} @@ -3525,6 +3663,11 @@ packages: resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} engines: {node: '>= 0.10'} + publint@0.3.22: + resolution: {integrity: sha512-6Z/scsr5CA7APdwyF35EY88CqgDj1textWuY788DVTJYPCWVv/Wn9G6KmLnrVRnStgYcahqN4wCDLZGSbQJ69w==} + engines: {node: '>=18'} + hasBin: true + punycode.js@2.3.1: resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==} engines: {node: '>=6'} @@ -3662,6 +3805,10 @@ packages: remark-stringify@11.0.0: resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==} + require-directory@2.1.1: + resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} + engines: {node: '>=0.10.0'} + require-from-string@2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} @@ -3705,6 +3852,10 @@ packages: run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + sade@1.8.1: + resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} + engines: {node: '>=6'} + safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} @@ -3772,6 +3923,10 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + skin-tone@2.0.0: + resolution: {integrity: sha512-kUMbT1oBJCpgrnKoSr0o6wPtvRWT9W9UKvGLwfJYO2WuahZRHOpEyL1ckyMGgMWh0UdpmaoFqKKD29WTomNEGA==} + engines: {node: '>=8'} + slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -3824,6 +3979,10 @@ packages: strict-event-emitter@0.4.6: resolution: {integrity: sha512-12KWeb+wixJohmnwNFerbyiBrAlq5qJLwIt38etRtKtmmHyDSoGlIqFE9wx+4IwG0aDjI7GV8tc8ZccjWZZtTg==} + string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + stringify-entities@4.0.4: resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==} @@ -3868,6 +4027,10 @@ packages: resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} engines: {node: '>=10'} + supports-hyperlinks@3.2.0: + resolution: {integrity: sha512-zFObLMyZeEwzAoKCyu1B91U79K2t7ApXuQfo8OuxwXLDgcKxuwM+YvcbIhm6QWqz7mHUH1TVytR1PwVVjEuMig==} + engines: {node: '>=14.18'} + svg-parser@2.0.4: resolution: {integrity: sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ==} @@ -4024,6 +4187,11 @@ packages: peerDependencies: typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x || 5.9.x || 6.0.x + typescript@5.6.1-rc: + resolution: {integrity: sha512-E3b2+1zEFu84jB0YQi9BORDjz9+jGbwwy1Zi3G0LUNw7a7cePUrHMRNy8aPh53nXpkFGVHSxIZo5vKTfYaFiBQ==} + engines: {node: '>=14.17'} + hasBin: true + typescript@6.0.3: resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==} engines: {node: '>=14.17'} @@ -4046,6 +4214,10 @@ packages: vite: optional: true + unicode-emoji-modifier-base@1.0.0: + resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==} + engines: {node: '>=4'} + unified@11.0.5: resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==} @@ -4155,6 +4327,10 @@ packages: peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + validate-npm-package-name@5.0.1: + resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} @@ -4276,8 +4452,8 @@ packages: jsdom: optional: true - vocs@2.7.0: - resolution: {integrity: sha512-SZvExPIaowjDosBh1b46joJYoxJh35YklHZivScknFMLjxQ9JNEc6s432fmm83HkmVrT7h+cDJo2W9/Tn319GA==} + vocs@2.7.2: + resolution: {integrity: sha512-Sppu2STAa37Aon2rR/oXAktzW8dTlPcvxNPdfb0PMGL1FRaJlXfYe1EgFLfQzqtorwWk98iCtedtRmuI9IzhZg==} hasBin: true peerDependencies: '@vocs/twoslash-rust': ^0.1.0 @@ -4376,6 +4552,10 @@ packages: engines: {node: '>=8'} hasBin: true + wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} @@ -4391,6 +4571,10 @@ packages: utf-8-validate: optional: true + y18n@5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} + yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -4399,6 +4583,14 @@ packages: engines: {node: '>= 14.6'} hasBin: true + yargs-parser@20.2.9: + resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} + engines: {node: '>=10'} + + yargs@16.2.2: + resolution: {integrity: sha512-Nt9ZJjXTv5R8MHbqby/wXQ6Gi0Bb3TcYZkR1bzuL4yB2OxWPkXknz513gEF0GoA6tn00UpbPvERW8rzCuWCA6w==} + engines: {node: '>=10'} + zod-to-json-schema@3.25.2: resolution: {integrity: sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==} peerDependencies: @@ -4414,11 +4606,34 @@ snapshots: '@adraffy/ens-normalize@1.11.1': {} + '@andrewbranch/untar.js@1.0.3': {} + '@antfu/install-pkg@1.1.0': dependencies: package-manager-detector: 1.8.0 tinyexec: 1.2.4 + '@arethetypeswrong/cli@0.18.5': + dependencies: + '@arethetypeswrong/core': 0.18.5 + chalk: 4.1.2 + cli-table3: 0.6.5 + commander: 10.0.1 + marked: 9.1.6 + marked-terminal: 7.3.0(marked@9.1.6) + semver: 7.8.5 + + '@arethetypeswrong/core@0.18.5': + dependencies: + '@andrewbranch/untar.js': 1.0.3 + '@loaderkit/resolve': 1.0.6 + cjs-module-lexer: 1.4.3 + fflate: 0.8.3 + lru-cache: 11.0.2 + semver: 7.8.5 + typescript: 5.6.1-rc + validate-npm-package-name: 5.0.1 + '@babel/code-frame@7.29.7': dependencies: '@babel/helper-validator-identifier': 7.29.7 @@ -4581,6 +4796,8 @@ snapshots: '@biomejs/cli-win32-x64@2.5.6': optional: true + '@braidai/lang@1.1.2': {} + '@changesets/apply-release-plan@7.1.1': dependencies: '@changesets/config': 3.1.4 @@ -4871,6 +5088,17 @@ snapshots: react-dom: 19.2.8(react@19.2.8) react-is: 17.0.2 + '@colors/colors@1.5.0': + optional: true + + '@edge-runtime/primitives@4.1.0': + optional: true + + '@edge-runtime/vm@3.2.0': + dependencies: + '@edge-runtime/primitives': 4.1.0 + optional: true + '@emnapi/core@1.11.1': dependencies: '@emnapi/wasi-threads': 1.2.2 @@ -5134,7 +5362,7 @@ snapshots: '@floating-ui/vue@1.1.9(vue@3.5.40(typescript@6.0.3))': dependencies: '@floating-ui/dom': 1.8.0 - '@floating-ui/utils': 0.2.10 + '@floating-ui/utils': 0.2.12 vue-demi: 0.14.10(vue@3.5.40(typescript@6.0.3)) transitivePeerDependencies: - '@vue/composition-api' @@ -5272,6 +5500,10 @@ snapshots: '@lezer/highlight': 1.2.3 '@lezer/lr': 1.4.10 + '@loaderkit/resolve@1.0.6': + dependencies: + '@braidai/lang': 1.1.2 + '@manypkg/find-root@1.1.0': dependencies: '@babel/runtime': 7.29.7 @@ -5397,6 +5629,10 @@ snapshots: '@phosphor-icons/core@2.1.1': {} + '@publint/pack@0.1.6': + dependencies: + tinyexec: 1.2.4 + '@react-hook/intersection-observer@3.1.2(react@19.2.8)': dependencies: '@react-hook/passive-layout-effect': 1.2.1(react@19.2.8) @@ -5928,6 +6164,8 @@ snapshots: '@shikijs/vscode-textmate@10.0.2': {} + '@sindresorhus/is@4.6.0': {} + '@standard-schema/spec@1.1.0': {} '@stitches/core@1.2.8': {} @@ -6247,7 +6485,7 @@ snapshots: obug: 2.1.4 std-env: 4.2.0 tinyrainbow: 3.1.1 - vitest: 4.1.10(@types/node@24.13.3)(@vitest/coverage-v8@4.1.10)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0)) + vitest: 4.1.10(@edge-runtime/vm@3.2.0)(@types/node@24.13.3)(@vitest/coverage-v8@4.1.10)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0)) '@vitest/expect@4.1.10': dependencies: @@ -6518,8 +6756,18 @@ snapshots: ansi-colors@4.1.3: {} + ansi-escapes@7.3.0: + dependencies: + environment: 1.1.0 + ansi-regex@5.0.1: {} + ansi-regex@6.2.2: {} + + ansi-styles@4.3.0: + dependencies: + color-convert: 2.0.1 + any-promise@1.3.0: {} argparse@1.0.10: @@ -6622,8 +6870,15 @@ snapshots: chai@6.2.2: {} + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + chalk@5.6.2: {} + char-regex@1.0.2: {} + character-entities-html4@2.1.0: {} character-entities-legacy@3.0.0: {} @@ -6640,18 +6895,49 @@ snapshots: chrome-trace-event@1.0.4: {} + cjs-module-lexer@1.4.3: {} + class-variance-authority@0.7.1: dependencies: clsx: 2.1.1 clean-set@1.1.2: {} + cli-highlight@2.1.11: + dependencies: + chalk: 4.1.2 + highlight.js: 10.7.3 + mz: 2.7.0 + parse5: 5.1.1 + parse5-htmlparser2-tree-adapter: 6.0.1 + yargs: 16.2.2 + + cli-table3@0.6.5: + dependencies: + string-width: 4.2.3 + optionalDependencies: + '@colors/colors': 1.5.0 + + cliui@7.0.4: + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + clsx@2.1.1: {} collapse-white-space@2.1.0: {} + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.4: {} + comma-separated-tokens@2.0.3: {} + commander@10.0.1: {} + commander@2.20.3: {} commander@4.1.1: {} @@ -6760,6 +7046,10 @@ snapshots: electron-to-chromium@1.5.398: {} + emoji-regex@8.0.0: {} + + emojilib@2.4.0: {} + encodeurl@2.0.0: {} enhanced-resolve@5.24.4: @@ -6778,6 +7068,8 @@ snapshots: entities@7.0.1: {} + environment@1.1.0: {} + error-ex@1.3.4: dependencies: is-arrayish: 0.2.1 @@ -7047,6 +7339,8 @@ snapshots: optionalDependencies: picomatch: 4.0.5 + fflate@0.8.3: {} + fill-range@7.1.1: dependencies: to-regex-range: 5.0.1 @@ -7108,6 +7402,8 @@ snapshots: gensync@1.0.0-beta.2: {} + get-caller-file@2.0.5: {} + get-intrinsic@1.3.0: dependencies: call-bind-apply-helpers: 1.0.2 @@ -7336,6 +7632,8 @@ snapshots: property-information: 7.2.0 space-separated-tokens: 2.0.2 + highlight.js@10.7.3: {} + highlight.js@11.11.1: {} hono@4.12.32: {} @@ -7404,6 +7702,8 @@ snapshots: is-extglob@2.1.1: {} + is-fullwidth-code-point@3.0.0: {} + is-glob@4.0.3: dependencies: is-extglob: 2.1.1 @@ -7452,7 +7752,7 @@ snapshots: jest-worker@27.5.1: dependencies: - '@types/node': 12.20.55 + '@types/node': 24.13.3 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -7678,6 +7978,19 @@ snapshots: markdown-table@3.0.4: {} + marked-terminal@7.3.0(marked@9.1.6): + dependencies: + ansi-escapes: 7.3.0 + ansi-regex: 6.2.2 + chalk: 5.6.2 + cli-highlight: 2.1.11 + cli-table3: 0.6.5 + marked: 9.1.6 + node-emoji: 2.2.0 + supports-hyperlinks: 3.2.0 + + marked@9.1.6: {} + math-intrinsics@1.1.0: {} mdast-util-directive@3.1.0: @@ -8219,6 +8532,13 @@ snapshots: lower-case: 2.0.2 tslib: 2.8.1 + node-emoji@2.2.0: + dependencies: + '@sindresorhus/is': 4.6.0 + char-regex: 1.0.2 + emojilib: 2.4.0 + skin-tone: 2.0.0 + node-fetch@2.7.0: dependencies: whatwg-url: 5.0.0 @@ -8322,6 +8642,14 @@ snapshots: parse-ms@4.0.0: {} + parse5-htmlparser2-tree-adapter@6.0.1: + dependencies: + parse5: 6.0.1 + + parse5@5.1.1: {} + + parse5@6.0.1: {} + parse5@7.3.0: dependencies: entities: 6.0.1 @@ -8390,6 +8718,13 @@ snapshots: forwarded: 0.2.0 ipaddr.js: 1.9.1 + publint@0.3.22: + dependencies: + '@publint/pack': 0.1.6 + package-manager-detector: 1.8.0 + picocolors: 1.1.1 + sade: 1.8.1 + punycode.js@2.3.1: {} qs@6.15.3: @@ -8631,6 +8966,8 @@ snapshots: mdast-util-to-markdown: 2.1.2 unified: 11.0.5 + require-directory@2.1.1: {} + require-from-string@2.0.2: {} reselect@5.2.0: {} @@ -8711,6 +9048,10 @@ snapshots: dependencies: queue-microtask: 1.2.3 + sade@1.8.1: + dependencies: + mri: 1.2.0 + safer-buffer@2.1.2: {} scheduler@0.27.0: {} @@ -8804,6 +9145,10 @@ snapshots: signal-exit@4.1.0: {} + skin-tone@2.0.0: + dependencies: + unicode-emoji-modifier-base: 1.0.0 + slash@3.0.0: {} snake-case@3.0.4: @@ -8848,6 +9193,12 @@ snapshots: strict-event-emitter@0.4.6: {} + string-width@4.2.3: + dependencies: + emoji-regex: 8.0.0 + is-fullwidth-code-point: 3.0.0 + strip-ansi: 6.0.1 + stringify-entities@4.0.4: dependencies: character-entities-html4: 2.1.0 @@ -8904,6 +9255,11 @@ snapshots: dependencies: has-flag: 4.0.0 + supports-hyperlinks@3.2.0: + dependencies: + has-flag: 4.0.0 + supports-color: 7.2.0 + svg-parser@2.0.4: {} tabbable@6.5.0: {} @@ -9047,6 +9403,8 @@ snapshots: typescript: 6.0.3 yaml: 2.9.0 + typescript@5.6.1-rc: {} + typescript@6.0.3: {} uc.micro@2.1.0: {} @@ -9071,6 +9429,8 @@ snapshots: - unloader - webpack + unicode-emoji-modifier-base@1.0.0: {} + unified@11.0.5: dependencies: '@types/unist': 3.0.3 @@ -9171,6 +9531,8 @@ snapshots: dependencies: react: 19.2.8 + validate-npm-package-name@5.0.1: {} + vary@1.1.2: {} vfile-location@5.0.3: @@ -9247,7 +9609,7 @@ snapshots: optionalDependencies: vite: 8.1.5(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0) - vitest@4.1.10(@types/node@24.13.3)(@vitest/coverage-v8@4.1.10)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0)): + vitest@4.1.10(@edge-runtime/vm@3.2.0)(@types/node@24.13.3)(@vitest/coverage-v8@4.1.10)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0)): dependencies: '@vitest/expect': 4.1.10 '@vitest/mocker': 4.1.10(vite@8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0)) @@ -9270,12 +9632,13 @@ snapshots: vite: 8.1.5(@types/node@24.13.3)(esbuild@0.27.7)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0) why-is-node-running: 2.3.0 optionalDependencies: + '@edge-runtime/vm': 3.2.0 '@types/node': 24.13.3 '@vitest/coverage-v8': 4.1.10(vitest@4.1.10) transitivePeerDependencies: - msw - vocs@2.7.0(@types/react@19.2.17)(@vue/compiler-sfc@3.5.40)(esbuild@0.28.1)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(rolldown@1.1.5)(rollup@4.62.3)(typescript@6.0.3)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(waku@1.0.0-beta.8(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)): + vocs@2.7.2(@types/react@19.2.17)(@vue/compiler-sfc@3.5.40)(esbuild@0.28.1)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(rolldown@1.1.5)(rollup@4.62.3)(typescript@6.0.3)(vite@8.1.5(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(waku@1.0.0-beta.8(@types/node@24.13.3)(esbuild@0.28.1)(jiti@2.7.0)(react-dom@19.2.8(react@19.2.8))(react-server-dom-webpack@19.2.8(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)))(react@19.2.8)(terser@5.49.0)(tsx@4.23.1)(yaml@2.9.0))(webpack@5.109.2(esbuild@0.28.1)(postcss@8.5.24)): dependencies: '@base-ui/react': 1.6.0(@types/react@19.2.17)(react-dom@19.2.8(react@19.2.8))(react@19.2.8) '@codesandbox/sandpack-react': 2.20.0(react-dom@19.2.8(react@19.2.8))(react@19.2.8) @@ -9515,14 +9878,34 @@ snapshots: siginfo: 2.0.0 stackback: 0.0.2 + wrap-ansi@7.0.0: + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrappy@1.0.2: {} ws@8.21.0: {} + y18n@5.0.8: {} + yallist@3.1.1: {} yaml@2.9.0: {} + yargs-parser@20.2.9: {} + + yargs@16.2.2: + dependencies: + cliui: 7.0.4 + escalade: 3.2.0 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 20.2.9 + zod-to-json-schema@3.25.2(zod@4.4.3): dependencies: zod: 4.4.3 diff --git a/site/package.json b/site/package.json index 6fb6888..e050314 100644 --- a/site/package.json +++ b/site/package.json @@ -13,7 +13,7 @@ "react": "^19.2.6", "react-dom": "^19.2.6", "vite": "^8.0.0", - "vocs": "2.7.0", + "vocs": "2.7.2", "waku": "^1.0.0-beta.6" }, "devDependencies": { diff --git a/site/src/components/EcosystemGrid.tsx b/site/src/components/EcosystemGrid.tsx index a30af3e..3db8a44 100644 --- a/site/src/components/EcosystemGrid.tsx +++ b/site/src/components/EcosystemGrid.tsx @@ -10,7 +10,7 @@ const SITES: Site[] = [ { name: 'Node', host: 'node.tevm.sh', desc: 'EVM node, memory client & actions' }, { name: 'Contract', host: 'contract.tevm.sh', desc: 'Typed contract kernel', current: true }, { name: 'Bundler', host: 'bundler.tevm.sh', desc: 'Import .sol files in TypeScript' }, - { name: 'Utils', host: 'utils.tevm.sh', desc: 'EVM primitives: addresses, hex, ABI' }, + { name: 'Voltaire', host: 'voltaire.tevm.sh', desc: 'Ethereum primitives and cryptography' }, { name: 'Logger', host: 'logger.tevm.sh', desc: 'Structured logging for Tevm' }, { name: 'Test', host: 'test.tevm.sh', desc: 'Matchers & fixtures for EVM tests' }, { name: 'Ethers', host: 'ethers.tevm.sh', desc: 'ethers.js adapter for Tevm' }, diff --git a/site/src/pages/ecosystem.mdx b/site/src/pages/ecosystem.mdx index c8436d7..8aa664f 100644 --- a/site/src/pages/ecosystem.mdx +++ b/site/src/pages/ecosystem.mdx @@ -29,7 +29,11 @@ Tevm is developed as several independent repositories rather than one monolith. โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` -`@tevm/contract` depends only on `@tevm/utils` (abitype/viem re-exports) and `@tevm/errors`. +`@tevm/contract` depends only on the published `@tevm/utils` compatibility package from Tevm +core (abitype/viem re-exports) and `@tevm/errors`. `@tevm/utils` is being retired in favour of +[Voltaire](https://github.com/evmts/voltaire); there is intentionally no standalone +`tevm-utils` repository. This package will move to Voltaire once that migration is ready. + It deliberately does **not** depend on the EVM, on a node, or on a Solidity compiler. Neither the node nor the bundler depends on the other. @@ -97,6 +101,7 @@ surface, and changes rarely โ€” the properties you want in a kernel. | [`evmts/tevm-contract`](https://github.com/evmts/tevm-contract) | `@tevm/contract` | This repo. The shared contract kernel. | | [`evmts/tevm`](https://github.com/evmts/tevm) | `tevm`, `@tevm/memory-client`, `@tevm/actions`, `@tevm/node` | The EVM node. Docs at [node.tevm.sh](https://node.tevm.sh). | | [`evmts/tevm`](https://github.com/evmts/tevm) (bundler packages) | `@tevm/bundler`, `@tevm/ts-plugin`, `@tevm/compiler` | Solidity-import tooling for TypeScript. | +| [`evmts/voltaire`](https://github.com/evmts/voltaire) | Voltaire packages | Ethereum primitives and cryptography replacing `@tevm/utils`. | ## Versioning diff --git a/site/src/pages/getting-started.mdx b/site/src/pages/getting-started.mdx index 66d5579..09dff69 100644 --- a/site/src/pages/getting-started.mdx +++ b/site/src/pages/getting-started.mdx @@ -8,31 +8,32 @@ description: Install @tevm/contract and build your first type-safe contract. ## Install `@tevm/contract` is published to npm as [`@tevm/contract`](https://www.npmjs.com/package/@tevm/contract). -The 1.0 line is currently a release candidate. :::code-group ```bash [npm] -npm install @tevm/contract@^1.0.0-rc.151 +npm install @tevm/contract ``` ```bash [pnpm] -pnpm add @tevm/contract@^1.0.0-rc.151 +pnpm add @tevm/contract ``` ```bash [bun] -bun add @tevm/contract@^1.0.0-rc.151 +bun add @tevm/contract ``` ```bash [yarn] -yarn add @tevm/contract@^1.0.0-rc.151 +yarn add @tevm/contract ``` ::: -`@tevm/utils` and `@tevm/errors` are installed automatically as dependencies โ€” you do not need -to add them yourself, though importing types from `@tevm/utils` (`Address`, `Hex`, `Abi`) is -supported and common. +`@tevm/utils` and `@tevm/errors` are installed automatically as published dependencies โ€” you +do not need to add them yourself. `@tevm/utils` currently supplies compatibility types such as +`Address`, `Hex`, and `Abi`, but is being retired in favour of +[Voltaire](https://voltaire.tevm.sh). Do not depend on a standalone `tevm-utils` repository; +none is maintained. :::note If you already depend on the `tevm` meta-package, this package is re-exported from it as diff --git a/site/src/pages/index.mdx b/site/src/pages/index.mdx index 3a5f2d8..446374c 100644 --- a/site/src/pages/index.mdx +++ b/site/src/pages/index.mdx @@ -102,7 +102,7 @@ method to see the exact object it returns and the APIs that accept it. ## The Tevm family -`@tevm/contract` is one package in the Tevm monorepo. Each package has its own docs site: +`@tevm/contract` is one of Tevm's independently versioned packages. Each repository has its own docs site: diff --git a/site/vocs.config.ts b/site/vocs.config.ts index cc0c24a..625e1d4 100644 --- a/site/vocs.config.ts +++ b/site/vocs.config.ts @@ -4,7 +4,7 @@ export default defineConfig({ title: 'Tevm Contract', titleTemplate: '%s ยท Tevm Contract', description: 'The type-safe contract kernel shared by the Tevm node and the Tevm bundler.', - baseUrl: process.env['VERCEL_ENV'] === 'production' ? 'https://contract.tevm.sh' : process.env['VERCEL_URL'], + baseUrl: 'https://contract.tevm.sh', rootDir: '.', // vocs 2.x renders with Waku/RSC by default. This site is pure content, so // pre-render everything and ship it as static files. @@ -36,7 +36,7 @@ export default defineConfig({ { text: 'Node', link: 'https://node.tevm.sh' }, { text: 'Contract', link: 'https://contract.tevm.sh' }, { text: 'Bundler', link: 'https://bundler.tevm.sh' }, - { text: 'Utils', link: 'https://utils.tevm.sh' }, + { text: 'Voltaire', link: 'https://voltaire.tevm.sh' }, { text: 'Logger', link: 'https://logger.tevm.sh' }, { text: 'Test', link: 'https://test.tevm.sh' }, { text: 'Ethers', link: 'https://ethers.tevm.sh' }, diff --git a/src/Contract.ts b/src/Contract.ts index ebbcfc8..8ccc9c4 100644 --- a/src/Contract.ts +++ b/src/Contract.ts @@ -53,16 +53,22 @@ import type { WriteActionCreator } from './write/WriteActionCreator.js' * @example * Using with other libraries: * ```typescript + * import { createContract } from '@tevm/contract' * import { createPublicClient, http } from 'viem' * import { mainnet } from 'viem/chains' * + * const MyContract = createContract({ + * humanReadableAbi: ['function balanceOf(address account) view returns (uint256)'], + * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', + * }) + * * const client = createPublicClient({ * chain: mainnet, * transport: http() * }) * * const balance = await client.readContract( - * MyContract.read.balanceOf('0xabcdef...') + * MyContract.read.balanceOf('0x0000000000000000000000000000000000000001') * ) * ``` */ @@ -84,8 +90,10 @@ export type Contract< * The JSON ABI of the contract. * @example * ```typescript - * console.log(MyContract.abi) - * // [{name: 'balanceOf', inputs: [...], outputs: [...], ...}] + * import { ERC20 } from '@tevm/contract' + * + * console.log(ERC20.abi.find((item) => item.type === 'function' && item.name === 'balanceOf')) + * // { name: 'balanceOf', inputs: [...], outputs: [...], ... } * ``` */ abi: ParseAbi @@ -109,8 +117,10 @@ export type Contract< * The human-readable ABI of the contract. * @example * ```typescript - * console.log(MyContract.humanReadableAbi) - * // ['function balanceOf(address): uint256', ...] + * import { ERC20 } from '@tevm/contract' + * + * console.log(ERC20.humanReadableAbi) + * // ['constructor(string name, string symbol)', ...] * ``` */ humanReadableAbi: THumanReadableAbi @@ -124,8 +134,11 @@ export type Contract< * Action creators for events. Used to create event filters in a type-safe way. * @example * ```typescript - * const transferFilter = MyContract.events.Transfer({ from: '0x1234...' }) - * const logs = await tevm.eth.getLogs(transferFilter) + * import { ERC20 } from '@tevm/contract' + * + * const transferFilter = ERC20.events.Transfer({ + * args: { from: '0x0000000000000000000000000000000000000001' }, + * }) * ``` */ events: EventActionCreator @@ -134,8 +147,12 @@ export type Contract< * Action creators for contract view and pure functions. * @example * ```typescript - * const balanceAction = MyContract.read.balanceOf('0x1234...') - * const balance = await tevm.contract(balanceAction) + * import { ERC20 } from '@tevm/contract' + * + * const token = ERC20.withAddress('0x6B175474E89094C44Da98b954EedeAC495271d0F') + * const balanceAction = token.read.balanceOf( + * '0x0000000000000000000000000000000000000001', + * ) * ``` */ read: ReadActionCreator @@ -144,8 +161,13 @@ export type Contract< * Action creators for contract payable and nonpayable functions. * @example * ```typescript - * const transferAction = MyContract.write.transfer('0x5678...', 1000n) - * const result = await tevm.contract(transferAction) + * import { ERC20 } from '@tevm/contract' + * + * const token = ERC20.withAddress('0x6B175474E89094C44Da98b954EedeAC495271d0F') + * const transferAction = token.write.transfer( + * '0x0000000000000000000000000000000000000001', + * 1000n, + * ) * ``` */ write: WriteActionCreator @@ -176,6 +198,7 @@ export type Contract< * }) * await client.tevmMine({ blockCount: 1 }) * + * if (!result.createdAddress) throw new Error('deployment failed') * const counter = SimpleContract.withAddress(result.createdAddress) * ``` */ @@ -219,24 +242,11 @@ export type Contract< * @returns {Contract} A new contract instance with updated code * @example * ```typescript - * import { createPublicClient, http } from 'viem' - * import { mainnet } from 'viem/chains' - * - * const client = createPublicClient({ - * chain: mainnet, - * transport: http() - * }) + * import { SimpleContract } from '@tevm/contract' * - * const ADDRESS = '0x6B175474E89094C44Da98b954EedeAC495271d0F' - * const UpdatedContract = Contract.withCode('0x60806040...') - * const {data, abi, code, args} = UpdatedContract.read.balanceOf('0x1234567890123456789012345678901234567890') - * const balance = await client.call({ - * to: ADDRESS, - * data, - * abi, - * code, - * args - * }) + * const local = SimpleContract.withCode('0x6000') + * const action = local.read.get() + * console.log(action.code) // '0x6000' * ``` */ withCode: (encodedBytecode: Hex) => Contract diff --git a/src/CreateContractFn.ts b/src/CreateContractFn.ts index 90717b3..a59e35c 100644 --- a/src/CreateContractFn.ts +++ b/src/CreateContractFn.ts @@ -16,9 +16,9 @@ import type { CreateContractParams } from './CreateContractParams.js' * @example * Using a human readable ABI: * ```typescript - * import { type Contract, createContract } from 'tevm/contract' + * import { createContract } from '@tevm/contract' * - * const contract: Contract = createContract({ + * const contract = createContract({ * name: 'ERC20', * humanReadableAbi: [ * 'function balanceOf(address owner) view returns (uint256)', @@ -29,50 +29,32 @@ import type { CreateContractParams } from './CreateContractParams.js' * ``` * * @example - * Using a JSON ABI (needs to be formatted): + * Using a JSON ABI: * ```typescript - * import { type Contract, createContract } from 'tevm/contract' - * import { formatAbi } from '@tevm/utils' + * import { createContract } from '@tevm/contract' * * const jsonAbi = [ * { - * "inputs": [{"name": "owner", "type": "address"}], - * "name": "balanceOf", - * "outputs": [{"type": "uint256"}], - * "stateMutability": "view", - * "type": "function" - * }, - * { - * "inputs": [ - * {"name": "to", "type": "address"}, - * {"name": "amount", "type": "uint256"} - * ], - * "name": "transfer", - * "outputs": [{"type": "bool"}], - * "stateMutability": "nonpayable", - * "type": "function" - * }, - * { - * "anonymous": false, - * "inputs": [ - * {"indexed": true, "name": "from", "type": "address"}, - * {"indexed": true, "name": "to", "type": "address"}, - * {"indexed": false, "name": "value", "type": "uint256"} - * ], - * "name": "Transfer", - * "type": "event" + * inputs: [{ name: 'owner', type: 'address' }], + * name: 'balanceOf', + * outputs: [{ type: 'uint256' }], + * stateMutability: 'view', + * type: 'function', * } - * ] + * ] as const * * const contract = createContract({ * name: 'ERC20', - * abi: formatAbi(jsonAbi), + * abi: jsonAbi, * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', // DAI token address on Ethereum mainnet - * bytecode: '0x60806040526000805534801561001457600080fd5b50610771806100246000396000f3fe', // Example bytecode (truncated) - * deployedBytecode: '0x608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101bc', // Example deployed bytecode (truncated) - * code: '0x608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101bc', // Example runtime code (truncated) * }) + * + * const action = contract.read.balanceOf('0x0000000000000000000000000000000000000001') * ``` + * + * @throws {InvalidParamsError} If neither `humanReadableAbi` nor `abi` is supplied at runtime. + * @throws {InvalidAddressError} If `address` is not a valid Ethereum address. + * @throws {Error} If a human-readable ABI item cannot be parsed. */ export type CreateContractFn = < TName extends string, diff --git a/src/CreateContractParams.ts b/src/CreateContractParams.ts index 330654a..0b8e1c8 100644 --- a/src/CreateContractParams.ts +++ b/src/CreateContractParams.ts @@ -13,11 +13,13 @@ import type { Contract } from './Contract.js' * @typeParam TDeployedBytecode - The deployed bytecode type (optional) * @typeParam TCode - The runtime bytecode type (optional) * - * @see {@link CreateContract} + * @see {@link createContract} * * @example * Using human-readable ABI: * ```typescript + * import type { CreateContractParams } from '@tevm/contract' + * * const params: CreateContractParams = { * name: 'ERC20', * humanReadableAbi: [ @@ -31,6 +33,8 @@ import type { Contract } from './Contract.js' * @example * Using JSON ABI: * ```typescript + * import type { CreateContractParams } from '@tevm/contract' + * * const params: CreateContractParams = { * name: 'ERC20', * abi: [ @@ -45,6 +49,10 @@ import type { Contract } from './Contract.js' * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', * } * ``` + * + * @throws {InvalidParamsError} The `createContract` implementation throws if neither ABI form + * is supplied by untyped JavaScript. + * @throws {InvalidAddressError} The `createContract` implementation throws if `address` is invalid. */ export type CreateContractParams< TName extends string | undefined | never, diff --git a/src/contract-lib/AdvancedContract.s.sol.ts b/src/contract-lib/AdvancedContract.s.sol.ts index 83ea10b..c3e6790 100644 --- a/src/contract-lib/AdvancedContract.s.sol.ts +++ b/src/contract-lib/AdvancedContract.s.sol.ts @@ -36,7 +36,7 @@ const _AdvancedContract = { * external call, and a `delegatecall`. Useful for testing call tracing, opcode hooks, and * multi-type ABI encoding without needing a Solidity toolchain. * - * Its constructor deploys a {@link MathHelper} as a side effect, so it also covers + * Its constructor deploys an internal `MathHelper` as a side effect, so it also covers * contract-creation-during-construction. * * Ships with real compiled `bytecode` and `deployedBytecode` but no `address` โ€” call diff --git a/src/contract-lib/ERC20.ts b/src/contract-lib/ERC20.ts index e906e89..71ceae0 100644 --- a/src/contract-lib/ERC20.ts +++ b/src/contract-lib/ERC20.ts @@ -28,36 +28,25 @@ const _OzERC20 = { '0x608060405234801561000f575f80fd5b5060043610610091575f3560e01c8063313ce56711610064578063313ce5671461013157806370a082311461014f57806395d89b411461017f578063a9059cbb1461019d578063dd62ed3e146101cd57610091565b806306fdde0314610095578063095ea7b3146100b357806318160ddd146100e357806323b872dd14610101575b5f80fd5b61009d6101fd565b6040516100aa9190610a74565b60405180910390f35b6100cd60048036038101906100c89190610b25565b61028d565b6040516100da9190610b7d565b60405180910390f35b6100eb6102af565b6040516100f89190610ba5565b60405180910390f35b61011b60048036038101906101169190610bbe565b6102b8565b6040516101289190610b7d565b60405180910390f35b6101396102e6565b6040516101469190610c29565b60405180910390f35b61016960048036038101906101649190610c42565b6102ee565b6040516101769190610ba5565b60405180910390f35b610187610333565b6040516101949190610a74565b60405180910390f35b6101b760048036038101906101b29190610b25565b6103c3565b6040516101c49190610b7d565b60405180910390f35b6101e760048036038101906101e29190610c6d565b6103e5565b6040516101f49190610ba5565b60405180910390f35b60606003805461020c90610cd8565b80601f016020809104026020016040519081016040528092919081815260200182805461023890610cd8565b80156102835780601f1061025a57610100808354040283529160200191610283565b820191905f5260205f20905b81548152906001019060200180831161026657829003601f168201915b5050505050905090565b5f80610297610467565b90506102a481858561046e565b600191505092915050565b5f600254905090565b5f806102c2610467565b90506102cf858285610480565b6102da858585610512565b60019150509392505050565b5f6012905090565b5f805f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b60606004805461034290610cd8565b80601f016020809104026020016040519081016040528092919081815260200182805461036e90610cd8565b80156103b95780601f10610390576101008083540402835291602001916103b9565b820191905f5260205f20905b81548152906001019060200180831161039c57829003601f168201915b5050505050905090565b5f806103cd610467565b90506103da818585610512565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f33905090565b61047b8383836001610602565b505050565b5f61048b84846103e5565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461050c57818110156104fd578281836040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526004016104f493929190610d17565b60405180910390fd5b61050b84848484035f610602565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610582575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016105799190610d4c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036105f2575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016105e99190610d4c565b60405180910390fd5b6105fd8383836107d1565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610672575f6040517fe602df050000000000000000000000000000000000000000000000000000000081526004016106699190610d4c565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036106e2575f6040517f94280d620000000000000000000000000000000000000000000000000000000081526004016106d99190610d4c565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208190555080156107cb578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516107c29190610ba5565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610821578060025f8282546108159190610d92565b925050819055506108ef565b5f805f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050818110156108aa578381836040517fe450d38c0000000000000000000000000000000000000000000000000000000081526004016108a193929190610d17565b60405180910390fd5b8181035f808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610936578060025f8282540392505081905550610980565b805f808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516109dd9190610ba5565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015610a21578082015181840152602081019050610a06565b5f8484015250505050565b5f601f19601f8301169050919050565b5f610a46826109ea565b610a5081856109f4565b9350610a60818560208601610a04565b610a6981610a2c565b840191505092915050565b5f6020820190508181035f830152610a8c8184610a3c565b905092915050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610ac182610a98565b9050919050565b610ad181610ab7565b8114610adb575f80fd5b50565b5f81359050610aec81610ac8565b92915050565b5f819050919050565b610b0481610af2565b8114610b0e575f80fd5b50565b5f81359050610b1f81610afb565b92915050565b5f8060408385031215610b3b57610b3a610a94565b5b5f610b4885828601610ade565b9250506020610b5985828601610b11565b9150509250929050565b5f8115159050919050565b610b7781610b63565b82525050565b5f602082019050610b905f830184610b6e565b92915050565b610b9f81610af2565b82525050565b5f602082019050610bb85f830184610b96565b92915050565b5f805f60608486031215610bd557610bd4610a94565b5b5f610be286828701610ade565b9350506020610bf386828701610ade565b9250506040610c0486828701610b11565b9150509250925092565b5f60ff82169050919050565b610c2381610c0e565b82525050565b5f602082019050610c3c5f830184610c1a565b92915050565b5f60208284031215610c5757610c56610a94565b5b5f610c6484828501610ade565b91505092915050565b5f8060408385031215610c8357610c82610a94565b5b5f610c9085828601610ade565b9250506020610ca185828601610ade565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680610cef57607f821691505b602082108103610d0257610d01610cab565b5b50919050565b610d1181610ab7565b82525050565b5f606082019050610d2a5f830186610d08565b610d376020830185610b96565b610d446040830184610b96565b949350505050565b5f602082019050610d5f5f830184610d08565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610d9c82610af2565b9150610da783610af2565b9250828201905080821115610dbf57610dbe610d65565b5b9291505056fea264697066735822122055b5ce6d6026c56b28a641568d3e9a6c81fb1079127f85ede16ed31d67d3eff464736f6c63430008160033', } as const /** - * Bytecode and ABI for the ERC20 contract from OpenZeppelin. - * This constant represents a standard ERC20 token implementation. + * A deployable OpenZeppelin ERC20 contract with compiled creation and runtime bytecode. * - * @example - * Using the ERC20 contract in a deployment script: - * ```typescript - * import { ERC20 } from 'tevm/contract' - * - * // Deploy the ERC20 contract - * const deployedERC20 = await tevm.deployContract(ERC20.deploy('MyToken', 'MTK')) - * console.log('ERC20 deployed at:', deployedERC20.address) - * - * // Interact with the deployed contract - * const balance = await tevm.contract(ERC20.read.balanceOf(deployedERC20.address, '0x1234...')) - * console.log('Balance:', balance) - * ``` + * The constructor accepts a token name and symbol. This fixture does not expose a public mint + * function, so its initial total supply is zero. * * @example - * Using the ERC20 contract with an existing deployment: * ```typescript - * import { ERC20 } from 'tevm/contract' - * - * const existingERC20 = ERC20.withAddress('0x1234...') + * import { ERC20 } from '@tevm/contract' * - * // Read token name - * const name = await tevm.contract(existingERC20.read.name()) - * console.log('Token name:', name) + * const deployment = ERC20.deploy('My Token', 'MTK') + * const token = ERC20.withAddress('0x0000000000000000000000000000000000000001') * - * // Transfer tokens - * await tevm.contract(existingERC20.write.transfer('0x5678...', 1000n)) + * const nameAction = token.read.name() + * const transferAction = token.write.transfer( + * '0x0000000000000000000000000000000000000002', + * 1000n, + * ) * ``` + * + * @see [prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) */ export const ERC20 = createContract(_OzERC20) diff --git a/src/contract-lib/ERC721.ts b/src/contract-lib/ERC721.ts index 7eaff8c..3fca3c0 100644 --- a/src/contract-lib/ERC721.ts +++ b/src/contract-lib/ERC721.ts @@ -35,38 +35,26 @@ const _OzERC721 = { '0x608060405234801561000f575f80fd5b50600436106100cd575f3560e01c80636352211e1161008a578063a22cb46511610064578063a22cb46514610221578063b88d4fde1461023d578063c87b56dd14610259578063e985e9c514610289576100cd565b80636352211e146101a357806370a08231146101d357806395d89b4114610203576100cd565b806301ffc9a7146100d157806306fdde0314610101578063081812fc1461011f578063095ea7b31461014f57806323b872dd1461016b57806342842e0e14610187575b5f80fd5b6100eb60048036038101906100e6919061146f565b6102b9565b6040516100f891906114b4565b60405180910390f35b61010961039a565b6040516101169190611557565b60405180910390f35b610139600480360381019061013491906115aa565b610429565b6040516101469190611614565b60405180910390f35b61016960048036038101906101649190611657565b610444565b005b61018560048036038101906101809190611695565b61045a565b005b6101a1600480360381019061019c9190611695565b610559565b005b6101bd60048036038101906101b891906115aa565b610578565b6040516101ca9190611614565b60405180910390f35b6101ed60048036038101906101e891906116e5565b610589565b6040516101fa919061171f565b60405180910390f35b61020b61063f565b6040516102189190611557565b60405180910390f35b61023b60048036038101906102369190611762565b6106cf565b005b610257600480360381019061025291906118cc565b6106e5565b005b610273600480360381019061026e91906115aa565b610702565b6040516102809190611557565b60405180910390f35b6102a3600480360381019061029e919061194c565b610768565b6040516102b091906114b4565b60405180910390f35b5f7f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061038357507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806103935750610392826107f6565b5b9050919050565b60605f80546103a8906119b7565b80601f01602080910402602001604051908101604052809291908181526020018280546103d4906119b7565b801561041f5780601f106103f65761010080835404028352916020019161041f565b820191905f5260205f20905b81548152906001019060200180831161040257829003601f168201915b5050505050905090565b5f6104338261085f565b5061043d826108e5565b9050919050565b610456828261045161091e565b610925565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036104ca575f6040517f64a0ae920000000000000000000000000000000000000000000000000000000081526004016104c19190611614565b60405180910390fd5b5f6104dd83836104d861091e565b610937565b90508373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610553578382826040517f64283d7b00000000000000000000000000000000000000000000000000000000815260040161054a939291906119e7565b60405180910390fd5b50505050565b61057383838360405180602001604052805f8152506106e5565b505050565b5f6105828261085f565b9050919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036105fa575f6040517f89c62b640000000000000000000000000000000000000000000000000000000081526004016105f19190611614565b60405180910390fd5b60035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b60606001805461064e906119b7565b80601f016020809104026020016040519081016040528092919081815260200182805461067a906119b7565b80156106c55780601f1061069c576101008083540402835291602001916106c5565b820191905f5260205f20905b8154815290600101906020018083116106a857829003601f168201915b5050505050905090565b6106e16106da61091e565b8383610b42565b5050565b6106f084848461045a565b6106fc84848484610cab565b50505050565b606061070d8261085f565b505f610717610e5d565b90505f8151116107355760405180602001604052805f815250610760565b8061073f84610e73565b604051602001610750929190611a56565b6040516020818303038152906040525b915050919050565b5f60055f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905092915050565b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b5f8061086a83610f3d565b90505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036108dc57826040517f7e2732890000000000000000000000000000000000000000000000000000000081526004016108d3919061171f565b60405180910390fd5b80915050919050565b5f60045f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b5f33905090565b6109328383836001610f76565b505050565b5f8061094284610f3d565b90505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461098357610982818486611135565b5b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610a0e576109c25f855f80610f76565b600160035f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825403925050819055505b5f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614610a8d57600160035f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8460025f8681526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550838573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4809150509392505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610bb257816040517f5b08ba18000000000000000000000000000000000000000000000000000000008152600401610ba99190611614565b60405180910390fd5b8060055f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c9e91906114b4565b60405180910390a3505050565b5f8373ffffffffffffffffffffffffffffffffffffffff163b1115610e57578273ffffffffffffffffffffffffffffffffffffffff1663150b7a02610cee61091e565b8685856040518563ffffffff1660e01b8152600401610d109493929190611acb565b6020604051808303815f875af1925050508015610d4b57506040513d601f19601f82011682018060405250810190610d489190611b29565b60015b610dcc573d805f8114610d79576040519150601f19603f3d011682016040523d82523d5f602084013e610d7e565b606091505b505f815103610dc457836040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600401610dbb9190611614565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614610e5557836040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600401610e4c9190611614565b60405180910390fd5b505b50505050565b606060405180602001604052805f815250905090565b60605f6001610e81846111f8565b0190505f8167ffffffffffffffff811115610e9f57610e9e6117a8565b5b6040519080825280601f01601f191660200182016040528015610ed15781602001600182028036833780820191505090505b5090505f82602001820190505b600115610f32578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581610f2757610f26611b54565b5b0494505f8503610ede575b819350505050919050565b5f60025f8381526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b8080610fae57505f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156110e0575f610fbd8461085f565b90505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561102757508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b801561103a57506110388184610768565b155b1561107c57826040517fa9fbf51f0000000000000000000000000000000000000000000000000000000081526004016110739190611614565b60405180910390fd5b81156110de57838573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b8360045f8581526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b611140838383611349565b6111f3575f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036111b457806040517f7e2732890000000000000000000000000000000000000000000000000000000081526004016111ab919061171f565b60405180910390fd5b81816040517f177e802f0000000000000000000000000000000000000000000000000000000081526004016111ea929190611b81565b60405180910390fd5b505050565b5f805f90507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611254577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161124a57611249611b54565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310611291576d04ee2d6d415b85acef8100000000838161128757611286611b54565b5b0492506020810190505b662386f26fc1000083106112c057662386f26fc1000083816112b6576112b5611b54565b5b0492506010810190505b6305f5e10083106112e9576305f5e10083816112df576112de611b54565b5b0492506008810190505b612710831061130e57612710838161130457611303611b54565b5b0492506004810190505b60648310611331576064838161132757611326611b54565b5b0492506002810190505b600a8310611340576001810190505b80915050919050565b5f8073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561140057508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806113c157506113c08484610768565b5b806113ff57508273ffffffffffffffffffffffffffffffffffffffff166113e7836108e5565b73ffffffffffffffffffffffffffffffffffffffff16145b5b90509392505050565b5f604051905090565b5f80fd5b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61144e8161141a565b8114611458575f80fd5b50565b5f8135905061146981611445565b92915050565b5f6020828403121561148457611483611412565b5b5f6114918482850161145b565b91505092915050565b5f8115159050919050565b6114ae8161149a565b82525050565b5f6020820190506114c75f8301846114a5565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156115045780820151818401526020810190506114e9565b5f8484015250505050565b5f601f19601f8301169050919050565b5f611529826114cd565b61153381856114d7565b93506115438185602086016114e7565b61154c8161150f565b840191505092915050565b5f6020820190508181035f83015261156f818461151f565b905092915050565b5f819050919050565b61158981611577565b8114611593575f80fd5b50565b5f813590506115a481611580565b92915050565b5f602082840312156115bf576115be611412565b5b5f6115cc84828501611596565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6115fe826115d5565b9050919050565b61160e816115f4565b82525050565b5f6020820190506116275f830184611605565b92915050565b611636816115f4565b8114611640575f80fd5b50565b5f813590506116518161162d565b92915050565b5f806040838503121561166d5761166c611412565b5b5f61167a85828601611643565b925050602061168b85828601611596565b9150509250929050565b5f805f606084860312156116ac576116ab611412565b5b5f6116b986828701611643565b93505060206116ca86828701611643565b92505060406116db86828701611596565b9150509250925092565b5f602082840312156116fa576116f9611412565b5b5f61170784828501611643565b91505092915050565b61171981611577565b82525050565b5f6020820190506117325f830184611710565b92915050565b6117418161149a565b811461174b575f80fd5b50565b5f8135905061175c81611738565b92915050565b5f806040838503121561177857611777611412565b5b5f61178585828601611643565b92505060206117968582860161174e565b9150509250929050565b5f80fd5b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6117de8261150f565b810181811067ffffffffffffffff821117156117fd576117fc6117a8565b5b80604052505050565b5f61180f611409565b905061181b82826117d5565b919050565b5f67ffffffffffffffff82111561183a576118396117a8565b5b6118438261150f565b9050602081019050919050565b828183375f83830152505050565b5f61187061186b84611820565b611806565b90508281526020810184848401111561188c5761188b6117a4565b5b611897848285611850565b509392505050565b5f82601f8301126118b3576118b26117a0565b5b81356118c384826020860161185e565b91505092915050565b5f805f80608085870312156118e4576118e3611412565b5b5f6118f187828801611643565b945050602061190287828801611643565b935050604061191387828801611596565b925050606085013567ffffffffffffffff81111561193457611933611416565b5b6119408782880161189f565b91505092959194509250565b5f806040838503121561196257611961611412565b5b5f61196f85828601611643565b925050602061198085828601611643565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806119ce57607f821691505b6020821081036119e1576119e061198a565b5b50919050565b5f6060820190506119fa5f830186611605565b611a076020830185611710565b611a146040830184611605565b949350505050565b5f81905092915050565b5f611a30826114cd565b611a3a8185611a1c565b9350611a4a8185602086016114e7565b80840191505092915050565b5f611a618285611a26565b9150611a6d8284611a26565b91508190509392505050565b5f81519050919050565b5f82825260208201905092915050565b5f611a9d82611a79565b611aa78185611a83565b9350611ab78185602086016114e7565b611ac08161150f565b840191505092915050565b5f608082019050611ade5f830187611605565b611aeb6020830186611605565b611af86040830185611710565b8181036060830152611b0a8184611a93565b905095945050505050565b5f81519050611b2381611445565b92915050565b5f60208284031215611b3e57611b3d611412565b5b5f611b4b84828501611b15565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f604082019050611b945f830185611605565b611ba16020830184611710565b939250505056fea2646970667358221220660c47cef4875784ced30d2987fb0203ddda8f97b11c21c4a3205a82e611b4d064736f6c63430008160033', } as const /** - * Bytecode and ABI for the ERC721 contract from OpenZeppelin. - * This constant represents a standard ERC721 token implementation for non-fungible tokens (NFTs). - * For more details, see the [OpenZeppelin ERC721 documentation](https://docs.openzeppelin.com/contracts/4.x/erc721). + * A deployable OpenZeppelin ERC721 contract with compiled creation and runtime bytecode. * - * @example - * Using the ERC721 contract in a deployment script: - * ```typescript - * import { ERC721 } from 'tevm/contract' - * - * // Deploy the ERC721 contract - * const deployedERC721 = await tevm.deployContract(ERC721.deploy('MyNFT', 'MNFT')) - * console.log('ERC721 deployed at:', deployedERC721.address) - * - * // Interact with the deployed contract - * const owner = await tevm.contract(ERC721.read.ownerOf(deployedERC721.address, 1n)) - * console.log('Owner of token 1:', owner) - * ``` + * The constructor accepts a collection name and symbol. This fixture does not expose a public + * mint function; it is intended for ABI, deployment, and interoperability tests. * * @example - * Using the ERC721 contract with an existing deployment: * ```typescript - * import { ERC721 } from 'tevm/contract' - * - * const existingERC721 = ERC721.withAddress('0x1234...') + * import { ERC721 } from '@tevm/contract' * - * // Read token name - * const name = await tevm.contract(existingERC721.read.name()) - * console.log('Token name:', name) + * const deployment = ERC721.deploy('My Collection', 'NFT') + * const collection = ERC721.withAddress('0x0000000000000000000000000000000000000001') * - * // Transfer token - * await tevm.contract(existingERC721.write.transferFrom('0xabcd...', '0x5678...', 1n)) + * const ownerAction = collection.read.ownerOf(1n) + * const approvalAction = collection.write.setApprovalForAll( + * '0x0000000000000000000000000000000000000002', + * true, + * ) * ``` * + * @see [OpenZeppelin ERC721](https://docs.openzeppelin.com/contracts/4.x/erc721) + * @see [prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) */ export const ERC721 = createContract(_OzERC721) diff --git a/src/contract-lib/SimpleContract.s.sol.ts b/src/contract-lib/SimpleContract.s.sol.ts index 9a3b9e4..383e162 100644 --- a/src/contract-lib/SimpleContract.s.sol.ts +++ b/src/contract-lib/SimpleContract.s.sol.ts @@ -14,38 +14,22 @@ const _SimpleContract = { '0x608060405234801561000f575f80fd5b5060043610610034575f3560e01c806360fe47b1146100385780636d4ce63c14610054575b5f80fd5b610052600480360381019061004d91906100f1565b610072565b005b61005c6100b2565b604051610069919061012b565b60405180910390f35b805f819055507f012c78e2b84325878b1bd9d250d772cfe5bda7722d795f45036fa5e1e6e303fc816040516100a7919061012b565b60405180910390a150565b5f8054905090565b5f80fd5b5f819050919050565b6100d0816100be565b81146100da575f80fd5b50565b5f813590506100eb816100c7565b92915050565b5f60208284031215610106576101056100ba565b5b5f610113848285016100dd565b91505092915050565b610125816100be565b82525050565b5f60208201905061013e5f83018461011c565b9291505056fea2646970667358221220792d4ee4a770b6a319a0ec659b77ea24497824649e20dcdea1dd7acf6118a5fe64736f6c63430008160033', } as const /** - * Bytecode and ABI for a simple contract with a single state variable. - * This constant represents a basic contract that can get and set a uint256 value. + * A deployable counter contract with a `uint256` value, a getter, a setter, and a `ValueSet` + * event. It ships with compiled creation and runtime bytecode. * * @example - * Using the SimpleContract in a deployment script: * ```typescript - * import { SimpleContract } from 'tevm/contract' - * - * // Deploy the SimpleContract with an initial value - * const deployedSimpleContract = await tevm.deployContract(SimpleContract.deploy(42n)) - * console.log('SimpleContract deployed at:', deployedSimpleContract.address) - * - * // Interact with the deployed contract - * const value = await tevm.contract(SimpleContract.read.get()) - * console.log('Current value:', value) - * ``` - * - * @example - * Using the SimpleContract with an existing deployment: - * ```typescript - * import { SimpleContract } from 'tevm/contract' - * - * const existingSimpleContract = SimpleContract.withAddress('0x1234...') - * - * // Read current value - * const currentValue = await tevm.contract(existingSimpleContract.read.get()) - * console.log('Current value:', currentValue) - * - * // Set a new value - * await tevm.contract(existingSimpleContract.write.set(100n)) - * console.log('New value set') + * import { SimpleContract } from '@tevm/contract' + * + * const deployment = SimpleContract.deploy(42n) + * const counter = SimpleContract.withAddress( + * '0x0000000000000000000000000000000000000001', + * ) + * const readAction = counter.read.get() + * const writeAction = counter.write.set(100n) + * const eventFilter = counter.events.ValueSet({ fromBlock: 'latest' }) * ``` * + * @see [prebuilt contracts](https://contract.tevm.sh/guides/prebuilt-contracts) */ export const SimpleContract = createContract(_SimpleContract) diff --git a/src/contract-lib/index.spec.ts b/src/contract-lib/index.spec.ts new file mode 100644 index 0000000..63ba9a6 --- /dev/null +++ b/src/contract-lib/index.spec.ts @@ -0,0 +1,36 @@ +import { describe, expect, it } from 'vitest' +import { AdvancedContract, ERC20, ERC721, ErrorContract, SimpleContract } from '../index.js' + +const prebuiltContracts = [AdvancedContract, ERC20, ERC721, ErrorContract, SimpleContract] + +describe('prebuilt contract exports', () => { + it.each(prebuiltContracts)('$name ships a parsed ABI and deployable bytecode', (contract) => { + expect(contract.abi.length).toBeGreaterThan(0) + expect(contract.humanReadableAbi.length).toBe(contract.abi.length) + expect(contract.bytecode).toMatch(/^0x[0-9a-f]+$/i) + expect(contract.deployedBytecode).toMatch(/^0x[0-9a-f]+$/i) + }) + + it('creates deploy actions with each contract constructor signature', () => { + expect(SimpleContract.deploy(42n).args).toEqual([42n]) + expect(ERC20.deploy('Token', 'TKN').args).toEqual(['Token', 'TKN']) + expect(ERC721.deploy('Collectible', 'NFT').args).toEqual(['Collectible', 'NFT']) + expect(AdvancedContract.deploy(1n, true, 'hello', '0x0000000000000000000000000000000000000001').args).toEqual([ + 1n, + true, + 'hello', + '0x0000000000000000000000000000000000000001', + ]) + expect(ErrorContract.deploy()).not.toHaveProperty('args') + }) + + it('exposes representative read, write, and event creators from the package root', () => { + expect(SimpleContract.read.get.functionName).toBe('get') + expect(SimpleContract.write.set.functionName).toBe('set') + expect(SimpleContract.events.ValueSet.eventName).toBe('ValueSet') + expect(ERC20.read.balanceOf.functionName).toBe('balanceOf') + expect(ERC721.write.transferFrom.functionName).toBe('transferFrom') + expect(AdvancedContract.read.getAllValues.functionName).toBe('getAllValues') + expect(ErrorContract.write.revertWithSimpleCustomError.functionName).toBe('revertWithSimpleCustomError') + }) +}) diff --git a/src/createContract.js b/src/createContract.js index c6aef70..d0a5577 100644 --- a/src/createContract.js +++ b/src/createContract.js @@ -11,11 +11,13 @@ import { writeFactory } from './write/writeFactory.js' * * @type {import('./CreateContractFn.js').CreateContractFn} * @throws {InvalidParamsError} If neither humanReadableAbi nor abi is provided. + * @throws {InvalidAddressError} If `address` is not a valid Ethereum address. + * @throws {Error} If a human-readable ABI item cannot be parsed. * * @example * Using a human-readable ABI: * ```typescript - * import { createContract } from 'tevm/contract' + * import { createContract } from '@tevm/contract' * * const contract = createContract({ * name: 'ERC20', @@ -27,43 +29,41 @@ import { writeFactory } from './write/writeFactory.js' * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F' // DAI token address * }) * - * // Read contract state - * const balanceAction = contract.read.balanceOf('0x1234...') - * const balance = await tevm.contract(balanceAction) - * - * // Write to contract - * const transferAction = contract.write.transfer('0x5678...', 1000n) - * const result = await tevm.contract(transferAction) - * - * // Create event filter - * const transferFilter = contract.events.Transfer({ fromBlock: 'latest' }) - * const logs = await tevm.eth.getLogs(transferFilter) + * const balanceAction = contract.read.balanceOf( + * '0x0000000000000000000000000000000000000001', + * ) + * const transferAction = contract.write.transfer( + * '0x0000000000000000000000000000000000000002', + * 1000n, + * ) + * const transferFilter = contract.events.Transfer({ + * fromBlock: 'latest', + * args: { from: contract.address }, + * }) * ``` * * @example * Using a JSON ABI: * ```typescript - * import { createContract } from 'tevm/contract' + * import { createContract } from '@tevm/contract' * * const contract = createContract({ * name: 'ERC20', * abi: [ * { - * "inputs": [{"name": "account", "type": "address"}], - * "name": "balanceOf", - * "outputs": [{"type": "uint256"}], - * "stateMutability": "view", - * "type": "function" + * inputs: [{ name: 'account', type: 'address' }], + * name: 'balanceOf', + * outputs: [{ type: 'uint256' }], + * stateMutability: 'view', + * type: 'function', * }, - * // ... other ABI entries - * ], + * ] as const, * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', - * bytecode: '0x60806040...', // Optional: Creation bytecode - * deployedBytecode: '0x608060405...', // Optional: Deployed bytecode - * code: '0x608060405...' // Optional: Runtime bytecode * }) * - * // Use the contract as in the previous example + * const action = contract.read.balanceOf( + * '0x0000000000000000000000000000000000000001', + * ) * ``` * * @see {@link Contract} for the full API of the returned Contract instance. diff --git a/src/event/EventActionCreator.ts b/src/event/EventActionCreator.ts index c8684f8..05800fc 100644 --- a/src/event/EventActionCreator.ts +++ b/src/event/EventActionCreator.ts @@ -16,6 +16,17 @@ import type { * Extracts event arguments from an ABI. * @template TAbi - The ABI type, can be an Abi, readonly unknown[], or undefined. * @template TEventName - The name of the event, can be a string or undefined. + * + * @example + * ```typescript + * import type { MaybeExtractEventArgsFromAbi } from '@tevm/contract' + * import type { ParseAbi } from '@tevm/utils' + * + * type TransferArgs = MaybeExtractEventArgsFromAbi< + * ParseAbi<['event Transfer(address indexed from, address indexed to, uint256 value)']>, + * 'Transfer' + * > + * ``` */ export type MaybeExtractEventArgsFromAbi< TAbi extends Abi | readonly unknown[] | undefined, @@ -29,6 +40,14 @@ export type MaybeExtractEventArgsFromAbi< /** * Utility type to get the value type of an object. * @template T - The object type. + * + * @example + * ```typescript + * import type { ValueOf } from '@tevm/contract' + * + * type Status = ValueOf<{ ready: 'ready'; failed: 'failed' }> + * // 'ready' | 'failed' + * ``` */ export type ValueOf = T[keyof T] @@ -42,15 +61,23 @@ export type ValueOf = T[keyof T] * * @example * ```typescript - * // Creating an event filter for a Transfer event - * const filter = MyContract.events.Transfer({ + * import { createContract } from '@tevm/contract' + * + * const Token = createContract({ + * humanReadableAbi: [ + * 'event Transfer(address indexed from, address indexed to, uint256 value)', + * ], + * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', + * }) + * + * const filter = Token.events.Transfer({ * fromBlock: 'latest', * toBlock: 'latest', - * args: { from: '0x1234...', to: '0x5678...' } + * args: { + * from: '0x0000000000000000000000000000000000000001', + * to: '0x0000000000000000000000000000000000000002', + * }, * }) - * - * // Using the filter with tevm - * const logs = await tevm.eth.getLogs(filter) * ``` */ export type EventActionCreator< diff --git a/src/event/eventFactory.js b/src/event/eventFactory.js index 84f26f4..bc405db 100644 --- a/src/event/eventFactory.js +++ b/src/event/eventFactory.js @@ -28,17 +28,17 @@ import { formatAbi } from '@tevm/utils' * } * ] * - * const events = eventsFactory({ abi }) + * const events = eventsFactory({ events: abi }) * * // Create a filter for the Transfer event * const transferFilter = events.Transfer({ * fromBlock: 'latest', * toBlock: 'latest', - * args: { from: '0x1234...', to: '0x5678...' } + * args: { + * from: '0x0000000000000000000000000000000000000001', + * to: '0x0000000000000000000000000000000000000002' + * } * }) - * - * // Use the filter with tevm - * const logs = await tevm.eth.getLogs(transferFilter) * ``` */ export const eventsFactory = ({ events, bytecode, deployedBytecode, address }) => diff --git a/src/read/ReadActionCreator.ts b/src/read/ReadActionCreator.ts index f107a16..0678090 100644 --- a/src/read/ReadActionCreator.ts +++ b/src/read/ReadActionCreator.ts @@ -25,12 +25,16 @@ export type ValueOf = T[keyof T] * * @example * ```typescript - * // Assuming we have a contract with a 'balanceOf' method - * const balanceAction = MyContract.read.balanceOf('0x1234...') + * import { createContract } from '@tevm/contract' * - * // Use the action with tevm - * const balance = await tevm.contract(balanceAction) - * console.log('Balance:', balance) + * const Token = createContract({ + * humanReadableAbi: ['function balanceOf(address account) view returns (uint256)'], + * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', + * }) + * + * const balanceAction = Token.read.balanceOf( + * '0x0000000000000000000000000000000000000001', + * ) * ``` */ export type ReadActionCreator< diff --git a/src/read/readFactory.js b/src/read/readFactory.js index b09d98a..baee74d 100644 --- a/src/read/readFactory.js +++ b/src/read/readFactory.js @@ -28,16 +28,15 @@ import { formatAbi } from '@tevm/utils' * * const readActions = readFactory({ * methods: abi, - * address: '0x1234...', - * code: '0x60806040...' + * errors: [], + * address: '0x0000000000000000000000000000000000000001', + * code: '0x6000' * }) * * // Create a read action for the balanceOf function - * const balanceAction = readActions.balanceOf('0x5678...') - * - * // Use the action with tevm - * const balance = await tevm.contract(balanceAction) - * console.log('Balance:', balance) + * const balanceAction = readActions.balanceOf( + * '0x0000000000000000000000000000000000000002' + * ) * ``` */ export const readFactory = ({ methods, errors, address, code }) => @@ -75,6 +74,7 @@ export const readFactory = ({ methods, errors, address, code }) => } } creator.abi = [method] + creator.functionName = /** @type {import('@tevm/utils').AbiFunction} */ (method).name creator.humanReadableAbi = formatAbi([method]) creator.code = code creator.address = address diff --git a/src/write/WriteActionCreator.ts b/src/write/WriteActionCreator.ts index 4e4f403..8d45e7d 100644 --- a/src/write/WriteActionCreator.ts +++ b/src/write/WriteActionCreator.ts @@ -25,12 +25,17 @@ export type ValueOf = T[keyof T] * * @example * ```typescript - * // Assuming we have a contract with a 'transfer' method - * const transferAction = MyContract.write.transfer('0x1234...', 1000n) + * import { createContract } from '@tevm/contract' * - * // Use the action with tevm - * const result = await tevm.contract(transferAction) - * console.log('Transaction hash:', result.transactionHash) + * const Token = createContract({ + * humanReadableAbi: ['function transfer(address to, uint256 amount) returns (bool)'], + * address: '0x6B175474E89094C44Da98b954EedeAC495271d0F', + * }) + * + * const transferAction = Token.write.transfer( + * '0x0000000000000000000000000000000000000001', + * 1000n, + * ) * ``` */ export type WriteActionCreator< diff --git a/src/write/writeFactory.js b/src/write/writeFactory.js index bbd36f1..c8f9787 100644 --- a/src/write/writeFactory.js +++ b/src/write/writeFactory.js @@ -31,16 +31,16 @@ import { formatAbi } from '@tevm/utils' * * const writeActions = writeFactory({ * methods: abi, - * address: '0x1234...', - * code: '0x60806040...' + * errors: [], + * address: '0x0000000000000000000000000000000000000001', + * code: '0x6000' * }) * * // Create a write action for the transfer function - * const transferAction = writeActions.transfer('0x5678...', 1000n) - * - * // Use the action with tevm - * const result = await tevm.contract(transferAction) - * console.log('Transaction hash:', result.transactionHash) + * const transferAction = writeActions.transfer( + * '0x0000000000000000000000000000000000000002', + * 1000n + * ) * ``` */ export const writeFactory = ({ methods, errors, address, code }) => @@ -79,6 +79,7 @@ export const writeFactory = ({ methods, errors, address, code }) => } } creator.abi = [method] + creator.functionName = /** @type {import('@tevm/utils').AbiFunction} */ (method).name creator.humanReadableAbi = formatAbi([method]) creator.code = code creator.address = address diff --git a/typedoc.json b/typedoc.json index fdf00b9..13d14b2 100644 --- a/typedoc.json +++ b/typedoc.json @@ -3,6 +3,7 @@ "out": "./docs", "entryPoints": ["./src/index.ts"], "plugin": ["typedoc-plugin-markdown"], + "readme": "none", "gitRevision": "main", "parametersFormat": "table", "propertiesFormat": "table" diff --git a/vitest.config.ts b/vitest.config.ts index 4866ba7..cb8a57f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,7 +5,8 @@ export default defineConfig({ include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], environment: 'node', coverage: { - include: ['src/**/*.js'], + exclude: ['src/**/*.spec.ts', 'src/test/**'], + include: ['src/**/*.{js,ts}'], provider: 'v8', reporter: ['text', 'json-summary', 'json'], thresholds: {