Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Aug 9, 2023
1 parent 148d26a commit 88047f4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/utils/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ChainNotFoundError,
} from '../errors/chain.js'
import type { Chain, ChainContract, ChainFormatters } from '../types/chain.js'
import type { Assign } from '../types/utils.js'

export type AssertCurrentChainParameters = {
chain?: Chain
Expand All @@ -22,16 +23,19 @@ export function assertCurrentChain({
export function defineChain<
chain extends Chain,
formatters extends ChainFormatters,
>(
chain: chain,
config?: Pick<Chain<formatters>, 'fees' | 'formatters' | 'serializers'>,
) {
config extends Pick<Chain<formatters>, 'fees' | 'formatters' | 'serializers'>,
>(chain: chain, config?: config): Assign<chain, config> {
const {
fees = chain.fees,
formatters = chain.formatters,
serializers = chain.serializers,
} = config || {}
return {
...chain,
fees: config?.fees,
formatters: config?.formatters,
serializers: config?.serializers,
}
fees,
formatters,
serializers,
} as unknown as Assign<chain, config>
}

export function getChainContractAddress({
Expand Down

0 comments on commit 88047f4

Please sign in to comment.