From 3590f2893992b06069902d4978ae64a771e75634 Mon Sep 17 00:00:00 2001 From: "moxey.eth" Date: Sat, 17 Dec 2022 16:06:50 +1100 Subject: [PATCH] docs: scaffold sidebar --- site/.vitepress/config.ts | 92 +--- site/.vitepress/sidebar.ts | 685 +++++++++++++++++++++++++++++ site/docs/utilities/formatEther.md | 32 ++ site/docs/utilities/formatGwei.md | 32 ++ site/docs/utilities/formatUnit.md | 38 ++ site/docs/utilities/parseEther.md | 32 ++ site/docs/utilities/parseGwei.md | 32 ++ site/docs/utilities/parseUnit.md | 38 ++ 8 files changed, 892 insertions(+), 89 deletions(-) create mode 100644 site/.vitepress/sidebar.ts create mode 100644 site/docs/utilities/formatEther.md create mode 100644 site/docs/utilities/formatGwei.md create mode 100644 site/docs/utilities/formatUnit.md create mode 100644 site/docs/utilities/parseEther.md create mode 100644 site/docs/utilities/parseGwei.md create mode 100644 site/docs/utilities/parseUnit.md diff --git a/site/.vitepress/config.ts b/site/.vitepress/config.ts index 1c8f7f12cc..7e9ebc27e9 100644 --- a/site/.vitepress/config.ts +++ b/site/.vitepress/config.ts @@ -1,5 +1,7 @@ import { defineConfig } from 'vitepress' +import { sidebar } from './sidebar' + export default defineConfig({ lang: 'en-US', @@ -42,95 +44,7 @@ export default defineConfig({ outline: [2, 3], - sidebar: { - '/docs/': [ - { - text: 'Introduction', - items: [ - { text: 'Why viem', link: '/docs/introduction' }, - { text: 'Getting Started', link: '/docs/getting-started' }, - ], - }, - { - text: 'Clients & Transports', - items: [ - { text: 'Introduction', link: '/docs/clients/intro' }, - { text: 'Public Client', link: '/docs/clients/public' }, - { text: 'Wallet Client', link: '/docs/clients/wallet' }, - { text: 'Test Client', link: '/docs/clients/test' }, - { - text: 'Transports', - items: [ - { - text: 'HTTP', - link: '/docs/clients/transports/http', - }, - { - text: 'WebSocket', - link: '/docs/clients/transports/websocket', - }, - { - text: 'Ethereum Provider (EIP-1193)', - link: '/docs/clients/transports/ethereum-provider', - }, - ], - }, - ], - }, - { - text: 'Public Actions', - items: [ - { text: 'Introduction', link: '/docs/actions/public/introduction' }, - { text: 'fetchBalance', link: '/docs/actions/public/fetchBalance' }, - { text: 'fetchBlock', link: '/docs/actions/public/fetchBlock' }, - { - text: 'fetchBlockNumber', - link: '/docs/actions/public/fetchBlockNumber', - }, - { - text: 'fetchTransaction', - link: '/docs/actions/public/fetchTransaction', - }, - { - text: 'watchBlockNumber', - link: '/docs/actions/public/watchBlockNumber', - }, - { text: 'watchBlocks', link: '/docs/actions/public/watchBlocks' }, - ], - }, - { - text: 'Wallet Actions', - items: [ - { text: 'Introduction', link: '/docs/actions/wallet/introduction' }, - { - text: 'requestAccounts', - link: '/docs/actions/wallet/requestAccounts', - }, - { - text: 'sendTransaction', - link: '/docs/actions/wallet/sendTransaction', - }, - ], - }, - { - text: 'Test Actions', - items: [ - { text: 'Introduction', link: '/docs/actions/test/introduction' }, - { text: 'mine', link: '/docs/actions/test/mine' }, - { text: 'setBalance', link: '/docs/actions/test/setBalance' }, - ], - }, - { - text: 'Middlewares', - items: [ - { - text: 'withConfirmations', - link: '/docs/middlewares/withConfirmations', - }, - ], - }, - ], - }, + sidebar, siteTitle: false, diff --git a/site/.vitepress/sidebar.ts b/site/.vitepress/sidebar.ts new file mode 100644 index 0000000000..02aadcc1f1 --- /dev/null +++ b/site/.vitepress/sidebar.ts @@ -0,0 +1,685 @@ +import { DefaultTheme } from 'vitepress' + +export const sidebar: DefaultTheme.Sidebar = { + '/docs/': [ + { + text: 'Introduction', + items: [ + { text: 'Why viem', link: '/docs/introduction' }, + { text: 'Getting Started', link: '/docs/getting-started' }, + ], + }, + { + text: 'Clients & Transports', + items: [ + { text: 'Introduction', link: '/docs/clients/intro' }, + { text: 'Public Client', link: '/docs/clients/public' }, + { text: 'Wallet Client', link: '/docs/clients/wallet' }, + { text: 'Test Client', link: '/docs/clients/test' }, + { + text: 'Transports', + items: [ + { + text: 'HTTP', + link: '/docs/clients/transports/http', + }, + { + text: 'WebSocket', + link: '/docs/clients/transports/websocket', + }, + { + text: 'Ethereum Provider (EIP-1193)', + link: '/docs/clients/transports/ethereum-provider', + }, + ], + }, + ], + }, + { + text: 'Public Actions', + collapsible: true, + collapsed: true, + items: [ + { text: 'Introduction', link: '/docs/actions/public/introduction' }, + { + text: 'Account', + items: [ + { + text: 'fetchBalance', + link: '/docs/actions/public/fetchBalance', + }, + ], + }, + { + text: 'Block', + items: [ + { text: 'fetchBlock', link: '/docs/actions/public/fetchBlock' }, + { + text: 'fetchBlockNumber', + link: '/docs/actions/public/fetchBlockNumber', + }, + { + text: 'fetchBlockTransactionCount', + link: '/docs/actions/public/fetchBlockTransactionCount', + }, + { + text: 'watchBlockNumber', + link: '/docs/actions/public/watchBlockNumber', + }, + { + text: 'watchBlocks', + link: '/docs/actions/public/watchBlocks', + }, + { + text: 'watchNewHeads', + link: '/docs/actions/public/watchNewHeads', + }, + ], + }, + { + text: 'Chain', + items: [ + { text: 'fetchChain', link: '/docs/actions/public/fetchChain' }, + ], + }, + { + text: 'Client', + items: [ + { + text: 'fetchClientVersion', + link: '/docs/actions/public/fetchClientVersion', + }, + { + text: 'fetchListeningStatus', + link: '/docs/actions/public/fetchListeningStatus', + }, + { + text: 'fetchPeerCount', + link: '/docs/actions/public/fetchPeerCount', + }, + ], + }, + { + text: 'Fee', + items: [ + { + text: 'fetchFeeHistory', + link: '/docs/actions/public/fetchFeeHistory', + }, + { + text: 'fetchGasEstimate', + link: '/docs/actions/public/fetchGasEstimate', + }, + { + text: 'fetchGasPrice', + link: '/docs/actions/public/fetchGasPrice', + }, + { + text: 'watchGasPrice', + link: '/docs/actions/public/watchGasPrice', + }, + ], + }, + { + text: 'Filters & Logs', + items: [ + { + text: 'createBlockFilter', + link: '/docs/actions/public/createBlockFilter', + }, + { + text: 'createFilter', + link: '/docs/actions/public/createFilter', + }, + { + text: 'createPendingTransactionFilter', + link: '/docs/actions/public/createPendingTransactionFilter', + }, + { + text: 'fetchFilterChanges', + link: '/docs/actions/public/fetchFilterChanges', + }, + { + text: 'fetchFilterLogs', + link: '/docs/actions/public/fetchFilterLogs', + }, + { text: 'fetchLogs', link: '/docs/actions/public/fetchLogs' }, + { + text: 'uninstallFilter', + link: '/docs/actions/public/uninstallFilter', + }, + ], + }, + { + text: 'Transaction', + items: [ + { text: 'call', link: '/docs/actions/public/call' }, + { + text: 'fetchTransaction', + link: '/docs/actions/public/fetchTransaction', + }, + { + text: 'fetchTransactionCount', + link: '/docs/actions/public/fetchTransactionCount', + }, + { + text: 'fetchTransactionReceipt', + link: '/docs/actions/public/fetchTransactionReceipt', + }, + { + text: 'sendRawTransaction', + link: '/docs/actions/public/sendRawTransaction', + }, + { + text: 'watchTransaction', + link: '/docs/actions/public/watchTransaction', + }, + { + text: 'watchTransactions', + link: '/docs/actions/public/watchTransactions', + }, + { + text: 'watchTransactionCount', + link: '/docs/actions/public/watchTransactionCount', + }, + ], + }, + ], + }, + { + text: 'Wallet Actions', + collapsible: true, + collapsed: true, + items: [ + { text: 'Introduction', link: '/docs/actions/wallet/introduction' }, + { + text: 'Account', + items: [ + { + text: 'fetchAccounts', + link: '/docs/actions/wallet/fetchAccounts', + }, + { + text: 'requestAccounts', + link: '/docs/actions/wallet/requestAccounts', + }, + ], + }, + { + text: 'Assets', + items: [ + { + text: 'watchAsset', + link: '/docs/actions/wallet/watchAsset', + }, + ], + }, + { + text: 'Chain', + items: [ + { + text: 'addChain', + link: '/docs/actions/wallet/addChain', + }, + { + text: 'switchChain', + link: '/docs/actions/wallet/switchChain', + }, + ], + }, + { + text: 'Data', + items: [ + { + text: 'signMessage', + link: '/docs/actions/wallet/signMessage', + }, + { + text: 'signTypedData', + link: '/docs/actions/wallet/signTypedData', + }, + ], + }, + { + text: 'Permissions', + items: [ + { + text: 'fetchPermissions', + link: '/docs/actions/wallet/fetchPermissions', + }, + { + text: 'requestPermissions', + link: '/docs/actions/wallet/requestPermissions', + }, + ], + }, + { + text: 'Transaction', + items: [ + { + text: 'sendTransaction', + link: '/docs/actions/wallet/sendTransaction', + }, + { + text: 'signTransaction', + link: '/docs/actions/wallet/signTransaction', + }, + ], + }, + ], + }, + { + text: 'Test Actions', + collapsible: true, + collapsed: true, + items: [ + { text: 'Introduction', link: '/docs/actions/test/introduction' }, + { + text: 'Account', + items: [ + { + text: 'impersonateAccount', + link: '/docs/actions/test/impersonateAccount', + }, + { text: 'setBalance', link: '/docs/actions/test/setBalance' }, + { text: 'setNonce', link: '/docs/actions/test/setNonce' }, + { + text: 'stopImpersonatingAccount', + link: '/docs/actions/test/stopImpersonatingAccount', + }, + ], + }, + { + text: 'Block', + items: [ + { + text: 'increaseTime', + link: '/docs/actions/test/increaseTime', + }, + { text: 'mine', link: '/docs/actions/test/mine' }, + { + text: 'removeBlockTimestampInterval', + link: '/docs/actions/test/removeBlockTimestampInterval', + }, + { + text: 'setNextBlockBaseFeePerGas', + link: '/docs/actions/test/setNextBlockBaseFeePerGas', + }, + { + text: 'setNextBlockTimestamp', + link: '/docs/actions/test/setNextBlockTimestamp', + }, + { + text: 'setBlockTimestampInterval', + link: '/docs/actions/test/setBlockTimestampInterval', + }, + { + text: 'setBlockGasLimit', + link: '/docs/actions/test/setBlockGasLimit', + }, + ], + }, + { + text: 'Contract', + items: [ + { text: 'setCode', link: '/docs/actions/test/setCode' }, + { + text: 'setStorageAt', + link: '/docs/actions/test/setStorageAt', + }, + ], + }, + { + text: 'Node', + items: [ + { text: 'nodeInfo', link: '/docs/actions/test/nodeInfo' }, + { text: 'setCoinbase', link: '/docs/actions/test/setCoinbase' }, + { + text: 'setMinGasPrice', + link: '/docs/actions/test/setMinGasPrice', + }, + ], + }, + { + text: 'Settings', + items: [ + { text: 'getAutomine', link: '/docs/actions/test/getAutomine' }, + { text: 'reset', link: '/docs/actions/test/reset' }, + { text: 'setAutomine', link: '/docs/actions/test/setAutomine' }, + { + text: 'setIntervalMining', + link: '/docs/actions/test/setIntervalMining', + }, + { + text: 'setLoggingEnabled', + link: '/docs/actions/test/setLoggingEnabled', + }, + { text: 'setRpcUrl', link: '/docs/actions/test/setRpcUrl' }, + ], + }, + { + text: 'State', + items: [ + { text: 'loadState', link: '/docs/actions/test/loadState' }, + { text: 'revert', link: '/docs/actions/test/revert' }, + { text: 'snapshot', link: '/docs/actions/test/snapshot' }, + ], + }, + { + text: 'Transaction', + items: [ + { + text: 'dropTransaction', + link: '/docs/actions/test/dropTransaction', + }, + { + text: 'enableTraces', + link: '/docs/actions/test/enableTraces', + }, + { + text: 'fetchTxpoolContent', + link: '/docs/actions/test/fetchTxpoolContent', + }, + { + text: 'fetchTxpoolStatus', + link: '/docs/actions/test/fetchTxpoolStatus', + }, + { + text: 'inspectTxpool', + link: '/docs/actions/test/inspectTxpool', + }, + { + text: 'sendUnsignedTransaction', + link: '/docs/actions/test/sendUnsignedTransaction', + }, + ], + }, + ], + }, + { + text: 'Middlewares', + collapsible: true, + collapsed: true, + items: [ + { + text: 'withConfirmations', + link: '/docs/middlewares/withConfirmations', + }, + ], + }, + { + text: 'Contract', + collapsible: true, + collapsed: true, + items: [ + { + text: 'deployContract', + link: '/docs/contract/deployContract', + }, + { + text: 'getContract', + link: '/docs/contract/getContract', + }, + { + text: 'Actions', + items: [ + { + text: 'callContract', + link: '/docs/contract/callContract', + }, + { + text: 'fetchContractCode', + link: '/docs/contract/fetchContractCode', + }, + { + text: 'fetchContractStorage', + link: '/docs/contract/fetchContractStorage', + }, + { + text: 'multicall', + link: '/docs/contract/multicall', + }, + { + text: 'readContract', + link: '/docs/contract/readContract', + }, + { + text: 'writeContract', + link: '/docs/contract/writeContract', + }, + { + text: 'watchContractEvent', + link: '/docs/contract/watchContractEvent', + }, + ], + }, + { + text: 'Encoding', + items: [ + { + text: 'decodeDeploy', + link: '/docs/abi/decodeDeploy', + }, + { + text: 'decodeEventLog', + link: '/docs/abi/decodeEventLog', + }, + { + text: 'decodeFunctionArgs', + link: '/docs/abi/decodeFunctionArgs', + }, + { + text: 'decodeFunctionError', + link: '/docs/abi/decodeFunctionError', + }, + { + text: 'decodeFunctionResult', + link: '/docs/abi/decodeFunctionResult', + }, + { + text: 'encodeDeploy', + link: '/docs/abi/encodeDeploy', + }, + { + text: 'encodeEventLog', + link: '/docs/abi/encodeEventLog', + }, + { + text: 'encodeFunctionArgs', + link: '/docs/abi/encodeFunctionArgs', + }, + { + text: 'encodeFunctionError', + link: '/docs/abi/encodeFunctionError', + }, + { + text: 'encodeFunctionResult', + link: '/docs/abi/encodeFunctionArgs', + }, + ], + }, + ], + }, + { + text: 'ENS', + collapsible: true, + collapsed: true, + items: [ + { + text: 'Actions', + items: [ + { text: 'fetchEnsAddress', link: '/docs/ens/fetchEnsAddress' }, + { text: 'fetchEnsAvatar', link: '/docs/ens/fetchEnsAvatar' }, + { + text: 'fetchEnsCoinAddress', + link: '/docs/ens/fetchEnsCoinAddress', + }, + { text: 'fetchEnsContent', link: '/docs/ens/fetchEnsContent' }, + { text: 'fetchEnsCover', link: '/docs/ens/fetchEnsCover' }, + { text: 'fetchEnsName', link: '/docs/ens/fetchEnsName' }, + { + text: 'fetchEnsResolver', + link: '/docs/ens/fetchEnsResolver', + }, + { + text: 'fetchEnsTextRecord', + link: '/docs/ens/fetchEnsTextRecord', + }, + ], + }, + { + text: 'Utilities', + items: [ + { text: 'namehash', link: '/docs/ens/namehash' }, + { text: 'labelhash', link: '/docs/ens/labelhash' }, + ], + }, + ], + }, + { + text: 'Utilities', + collapsible: true, + collapsed: true, + items: [ + { + text: 'Addresses', + items: [ + { + text: 'getAddress', + link: '/docs/utilities/getAddress', + }, + { + text: 'getContractAddress', + link: '/docs/utilities/getContractAddress', + }, + { + text: 'isAddress', + link: '/docs/utilities/isAddress', + }, + { + text: 'isAddressEqual', + link: '/docs/utilities/isAddressEqual', + }, + ], + }, + { + text: 'Encoding', + items: [ + { + text: 'decodeBase58', + link: '/docs/utilities/decodeBase58', + }, + { + text: 'decodeBase64', + link: '/docs/utilities/decodeBase64', + }, + { + text: 'decodeRlp', + link: '/docs/utilities/decodeRlp', + }, + { + text: 'encodeBase58', + link: '/docs/utilities/encodeBase58', + }, + { + text: 'encodeBase64', + link: '/docs/utilities/encodeBase64', + }, + { + text: 'encodeRlp', + link: '/docs/utilities/encodeRlp', + }, + ], + }, + { + text: 'Number', + items: [ + { + text: 'hexToNumber', + link: '/docs/utilities/hexToNumber', + }, + { + text: 'numberToHex', + link: '/docs/utilities/numberToHex', + }, + ], + }, + { + text: 'Hash', + items: [ + { + text: 'id', + link: '/docs/utilities/id', + }, + { + text: 'hashMessage', + link: '/docs/utilities/hashMessage', + }, + { + text: 'keccak256', + link: '/docs/utilities/keccak256', + }, + { + text: 'sha256', + link: '/docs/utilities/sha256', + }, + { + text: 'sha512', + link: '/docs/utilities/sha512', + }, + ], + }, + { + text: 'String', + items: [ + { + text: 'bytesToString', + link: '/docs/utilities/bytesToString', + }, + { + text: 'formatBytes32String', + link: '/docs/utilities/formatBytes32String', + }, + { + text: 'parseBytes32String', + link: '/docs/utilities/parseBytes32String', + }, + { + text: 'stringToBytes', + link: '/docs/utilities/stringToBytes', + }, + ], + }, + { + text: 'Units', + items: [ + { + text: 'formatEther', + link: '/docs/utilities/formatEther', + }, + { + text: 'formatGwei', + link: '/docs/utilities/formatGwei', + }, + { + text: 'formatUnit', + link: '/docs/utilities/formatUnit', + }, + { + text: 'parseEther', + link: '/docs/utilities/parseEther', + }, + { + text: 'parseGwei', + link: '/docs/utilities/parseGwei', + }, + { + text: 'parseUnit', + link: '/docs/utilities/parseUnit', + }, + ], + }, + ], + }, + ], +} diff --git a/site/docs/utilities/formatEther.md b/site/docs/utilities/formatEther.md new file mode 100644 index 0000000000..a6c2cdfc7e --- /dev/null +++ b/site/docs/utilities/formatEther.md @@ -0,0 +1,32 @@ + + +# formatEther + +Converts numerical wei to a string representation of ether. + +## Import + +```ts +import { formatEther } from 'viem' +``` + +## Usage + +```ts +import { formatEther } from 'viem' + +formatEther(1000000000000000000n) // [!code focus:2] +// '1' +``` + +## Returns + +`string` + +## Arguments + +### value + +- **Type:** `bigint` + +The wei value. \ No newline at end of file diff --git a/site/docs/utilities/formatGwei.md b/site/docs/utilities/formatGwei.md new file mode 100644 index 0000000000..ae3f7f31cb --- /dev/null +++ b/site/docs/utilities/formatGwei.md @@ -0,0 +1,32 @@ + + +# formatGwei + +Converts numerical wei to a string representation of gwei. + +## Import + +```ts +import { formatGwei } from 'viem' +``` + +## Usage + +```ts +import { formatGwei } from 'viem' + +formatGwei(1000000000n) // [!code focus:2] +// '1' +``` + +## Returns + +`string` + +## Arguments + +### value + +- **Type:** `bigint` + +The gwei value. \ No newline at end of file diff --git a/site/docs/utilities/formatUnit.md b/site/docs/utilities/formatUnit.md new file mode 100644 index 0000000000..4f2bdfd903 --- /dev/null +++ b/site/docs/utilities/formatUnit.md @@ -0,0 +1,38 @@ + + +# formatUnit + +Divides a number by a given exponent of base 10 (10exponent), and formats it into a string representation of the number. + +## Import + +```ts +import { formatUnit } from 'viem' +``` + +## Usage + +```ts +import { formatUnit } from 'viem' + +formatUnit(420000000000n, 9) // [!code focus:2] +// '420' +``` + +## Returns + +`string` + +## Arguments + +### value + +- **Type:** `bigint` + +The number to divide. + +### exponent + +- **Type:** `number` + +The exponent. \ No newline at end of file diff --git a/site/docs/utilities/parseEther.md b/site/docs/utilities/parseEther.md new file mode 100644 index 0000000000..0a8b640309 --- /dev/null +++ b/site/docs/utilities/parseEther.md @@ -0,0 +1,32 @@ + + +# parseEther + +Converts a string representation of ether to numerical wei. + +## Import + +```ts +import { parseEther } from 'viem' +``` + +## Usage + +```ts +import { parseEther } from 'viem' + +parseEther('420') // [!code focus:2] +// 420000000000000000000n +``` + +## Returns + +`bigint` + +## Arguments + +### value + +- **Type:** `string` + +The string representation of ether. \ No newline at end of file diff --git a/site/docs/utilities/parseGwei.md b/site/docs/utilities/parseGwei.md new file mode 100644 index 0000000000..bfbc76b04d --- /dev/null +++ b/site/docs/utilities/parseGwei.md @@ -0,0 +1,32 @@ + + +# parseGwei + +Converts a string representation of gwei to numerical wei. + +## Import + +```ts +import { parseGwei } from 'viem' +``` + +## Usage + +```ts +import { parseGwei } from 'viem' + +parseGwei('420') // [!code focus:2] +// 420000000000n +``` + +## Returns + +`bigint` + +## Arguments + +### value + +- **Type:** `string` + +The string representation of gwei. \ No newline at end of file diff --git a/site/docs/utilities/parseUnit.md b/site/docs/utilities/parseUnit.md new file mode 100644 index 0000000000..a8227a51e7 --- /dev/null +++ b/site/docs/utilities/parseUnit.md @@ -0,0 +1,38 @@ + + +# parseUnit + +Multiplies a string representation of a number by a given exponent of base 10 (10exponent). + +## Import + +```ts +import { parseUnit } from 'viem' +``` + +## Usage + +```ts +import { parseUnit } from 'viem' + +parseUnit('420', 9) // [!code focus:2] +// 420000000000n +``` + +## Returns + +`bigint` + +## Arguments + +### value + +- **Type:** `string` + +The string representation of the number to multiply. + +### exponent + +- **Type:** `number` + +The exponent. \ No newline at end of file