Skip to content

Commit

Permalink
refactor: chain utils exports
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Aug 9, 2023
1 parent 9d93953 commit 6df4308
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 70 deletions.
16 changes: 5 additions & 11 deletions .changeset/twenty-apples-pull.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@
"viem": minor
---

Added entrypoints for Celo (`viem/chains/celo`) & Optimism (`viem/chains/optimism`) chains with exports for their compatible chains, formatters, serializers, and types.
Added entrypoints for chain utilities (`viem/chains/utils`) with exports for chain-specific chains, formatters, serializers, and types.

Examples:

```ts
import {
base,
optimism,
zora,
import {
type CeloBlock,
type CeloTransaction,
type OptimismBlock,
type OptimismTransaction,
} from 'viem/chains/optimism'

import {
serializeTransactionCelo,
type CeloBlock,
type CeloTransaction,
} from 'viem/chains/celo'
} from 'viem/chains/utils'
```
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,10 @@
"import": "./dist/esm/chains/index.js",
"default": "./dist/cjs/chains/index.js"
},
"./chains/celo": {
"types": "./dist/types/chains/celo/index.d.ts",
"import": "./dist/esm/chains/celo/index.js",
"default": "./dist/cjs/chains/celo/index.js"
},
"./chains/optimism": {
"types": "./dist/types/chains/optimism/index.d.ts",
"import": "./dist/esm/chains/optimism/index.js",
"default": "./dist/cjs/chains/optimism/index.js"
"./chains/utils": {
"types": "./dist/types/chains/utils.d.ts",
"import": "./dist/esm/chains/utils.js",
"default": "./dist/cjs/chains/utils.js"
},
"./contract": {
"types": "./dist/types/contract.d.ts",
Expand Down
13 changes: 0 additions & 13 deletions src/chains/optimism/index.test.ts

This file was deleted.

25 changes: 0 additions & 25 deletions src/chains/optimism/index.ts

This file was deleted.

8 changes: 3 additions & 5 deletions src/chains/celo/index.test.ts → src/chains/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { expect, test } from 'vitest'

import * as actions from './index.js'
import * as utils from './utils.js'

test('exports', () => {
expect(Object.keys(actions)).toMatchInlineSnapshot(`
expect(Object.keys(utils)).toMatchInlineSnapshot(`
[
"celo",
"celoAlfajores",
"celoCannoli",
"formattersCelo",
"serializeTransactionCelo",
"serializersCelo",
"formattersOptimism",
]
`)
})
26 changes: 19 additions & 7 deletions src/chains/celo/index.ts → src/chains/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
export { celo, celoAlfajores, celoCannoli } from '../index.js'

export { formattersCelo } from './formatters.js'

export { formattersCelo } from './celo/formatters.js'
export {
type CeloTransactionSerializable,
type TransactionSerializableCIP42,
serializeTransactionCelo,
serializersCelo,
} from './serializers.js'

} from './celo/serializers.js'
export type {
CeloBlock,
CeloBlockOverrides,
Expand All @@ -26,4 +22,20 @@ export type {
CeloTransactionReceiptOverrides,
CeloTransactionRequest,
CeloTransactionRequestOverrides,
} from './types.js'
} from './celo/types.js'

export { formattersOptimism } from './optimism/formatters.js'
export type {
OptimismBlock,
OptimismBlockOverrides,
OptimismDepositTransaction,
OptimismRpcBlock,
OptimismRpcBlockOverrides,
OptimismRpcDepositTransaction,
OptimismRpcTransaction,
OptimismRpcTransactionReceipt,
OptimismRpcTransactionReceiptOverrides,
OptimismTransaction,
OptimismTransactionReceipt,
OptimismTransactionReceiptOverrides,
} from './optimism/types.js'

1 comment on commit 6df4308

@vercel
Copy link

@vercel vercel bot commented on 6df4308 Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.