Skip to content

Commit 0f68e26

Browse files
committed
chore: up
1 parent 41f3fcd commit 0f68e26

11 files changed

+94
-11
lines changed

src/actions/public/multicall.bench-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ test('return type', () => {
2828
},
2929
],
3030
})
31-
attest.instantiations([96782, 'instantiations'])
31+
attest.instantiations([46542, 'instantiations'])
3232
attest<Promise<[bigint, bigint, string]>>(res)
3333
})

src/actions/public/readContract.bench-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ test('return type', () => {
1515
functionName: 'balanceOf',
1616
args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
1717
})
18-
attest.instantiations([53192, 'instantiations'])
18+
attest.instantiations([21379, 'instantiations'])
1919
attest<Promise<bigint>>(res)
2020
})

src/clients/createPublicClient.bench-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ test('createPublicClient', () => {
1010
createPublicClient({
1111
transport: http('https://cloudflare-eth.com'),
1212
})
13-
attest.instantiations([18000, 'instantiations'])
13+
attest.instantiations([15172, 'instantiations'])
1414
})
1515

1616
test('createClient.extend + publicActions', () => {
1717
createClient({
1818
transport: http('https://cloudflare-eth.com'),
1919
}).extend(publicActions)
20-
attest.instantiations([328328, 'instantiations'])
20+
attest.instantiations([60082, 'instantiations'])
2121
})

src/clients/createTestClient.bench-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ test('createTestClient', () => {
1111
mode: 'anvil',
1212
transport: http('https://cloudflare-eth.com'),
1313
})
14-
attest.instantiations([3155, 'instantiations'])
14+
attest.instantiations([2823, 'instantiations'])
1515
})
1616

1717
test('createClient.extend + testActions', () => {
1818
createClient({
1919
transport: http('https://cloudflare-eth.com'),
2020
}).extend(testActions({ mode: 'anvil' }))
21-
attest.instantiations([9142, 'instantiations'])
21+
attest.instantiations([6071, 'instantiations'])
2222
})

src/clients/createWalletClient.bench-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ test('createWalletClient', () => {
1010
createWalletClient({
1111
transport: http('https://cloudflare-eth.com'),
1212
})
13-
attest.instantiations([3000, 'instantiations'])
13+
attest.instantiations([3042, 'instantiations'])
1414
})
1515

1616
test('createClient.extend + walletActions', () => {
1717
createClient({
1818
transport: http('https://cloudflare-eth.com'),
1919
}).extend(walletActions)
20-
attest.instantiations([179759, 'instantiations'])
20+
attest.instantiations([115528, 'instantiations'])
2121
})

src/tempo/Decorator.bench-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ test('decorator', () => {
77
createClient({
88
transport: http('https://cloudflare-eth.com'),
99
}).extend(decorator())
10-
attest.instantiations([40758, 'instantiations'])
10+
attest.instantiations([41119, 'instantiations'])
1111
})

src/tempo/chainConfig.bench-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ test('decorator', () => {
88
chain: tempoTestnet,
99
transport: http('https://cloudflare-eth.com'),
1010
})
11-
attest.instantiations([62236, 'instantiations'])
11+
attest.instantiations([79013, 'instantiations'])
1212
})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { attest } from '@ark/attest'
2+
import { test } from 'vitest'
3+
4+
import { defineChain } from './defineChain.js'
5+
6+
test('default', () => {
7+
defineChain({
8+
id: 1,
9+
name: 'Test',
10+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
11+
rpcUrls: { default: { http: ['https://localhost:8545'] } },
12+
})
13+
attest.instantiations([392, 'instantiations'])
14+
})
15+
16+
test('behavior: extend', () => {
17+
defineChain({
18+
id: 1,
19+
name: 'Test',
20+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
21+
rpcUrls: { default: { http: ['https://localhost:8545'] } },
22+
}).extend({
23+
foo: 'bar',
24+
})
25+
attest.instantiations([658, 'instantiations'])
26+
})
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { expectTypeOf, test } from 'vitest'
2+
import type { Chain } from '../../index.js'
3+
import { defineChain, extendSchema } from './defineChain.js'
4+
5+
test('default', () => {
6+
const chain = defineChain({
7+
id: 1,
8+
name: 'Test',
9+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
10+
rpcUrls: { default: { http: ['https://localhost:8545'] } },
11+
})
12+
13+
expectTypeOf(chain).toExtend<Chain>()
14+
expectTypeOf(chain.id).toEqualTypeOf<1>()
15+
expectTypeOf(chain.name).toEqualTypeOf<'Test'>()
16+
})
17+
18+
test('behavior: extend', () => {
19+
const chain = defineChain({
20+
id: 1,
21+
name: 'Test',
22+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
23+
rpcUrls: { default: { http: ['https://localhost:8545'] } },
24+
})
25+
26+
const extended = chain.extend({
27+
foo: 'bar' as const,
28+
})
29+
30+
expectTypeOf(extended).toExtend<Chain>()
31+
expectTypeOf(extended.foo).toEqualTypeOf<'bar'>()
32+
expectTypeOf(extended.id).toEqualTypeOf<1>()
33+
})
34+
35+
test('behavior: schema', () => {
36+
const chain = defineChain({
37+
extendSchema: extendSchema<{ foo: string }>(),
38+
id: 1,
39+
name: 'Test',
40+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
41+
rpcUrls: { default: { http: ['https://localhost:8545'] } },
42+
})
43+
44+
const extended = chain.extend({
45+
foo: 'bar',
46+
})
47+
48+
expectTypeOf(extended).toExtend<Chain>()
49+
expectTypeOf(extended.foo).toEqualTypeOf<'bar'>()
50+
expectTypeOf(extended.id).toEqualTypeOf<1>()
51+
52+
// @ts-expect-error - missing required property
53+
chain.extend({})
54+
55+
// @ts-expect-error - wrong type
56+
chain.extend({ foo: 123 })
57+
})

src/utils/chain/defineChain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type DefineChainReturnType<chain extends Chain = Chain> = Prettify<
1212
extend: <
1313
const extended extends ExtendedProperties<chain> & ExactPartial<Chain>,
1414
>(
15-
fnOrProperties: ((chain: chain) => extended) | extended,
15+
extended: extended,
1616
) => Assign<chain, extended>
1717
}
1818
>

0 commit comments

Comments
 (0)