Skip to content

Commit

Permalink
chore: update viem
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jul 6, 2024
1 parent 4e9493a commit b4033a0
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
strategy:
matrix:
typescript-version: ['5.0.4', '5.1.6', '5.2.2', '5.3.3', '5.4.5', '5.5.2']
viem-version: ['2.9.31', 'latest']
viem-version: ['2.17.0', 'latest']

steps:
- name: Clone repository
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"sherif": "^0.8.4",
"simple-git-hooks": "^2.11.1",
"typescript": "5.5.2",
"viem": "2.9.31",
"viem": "2.17.0",
"vitest": "^1.6.0"
},
"packageManager": "pnpm@9.4.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/actions/call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test('nonce too low', async () => {
nonce: 0
Details: nonce too low
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
})

Expand Down Expand Up @@ -104,7 +104,7 @@ test('insufficient funds', async () => {
value: 100000 ETH
Details: Insufficient funds for gas * price + value
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
})

Expand All @@ -127,7 +127,7 @@ test('maxFeePerGas less than maxPriorityFeePerGas', async () => {
maxFeePerGas: 20 gwei
maxPriorityFeePerGas: 22 gwei
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
})

Expand All @@ -147,7 +147,7 @@ test('contract revert (contract error)', async () => {
data: 0xa0712d6800000000000000000000000000000000000000000000000000000000000001a4
Details: execution reverted: revert: Token ID is taken
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
})

Expand All @@ -167,6 +167,6 @@ test('contract revert (insufficient params)', async () => {
data: 0xa0712d68
Details: execution reverted
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
})
2 changes: 1 addition & 1 deletion packages/core/src/actions/connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test('behavior: user rejected request', async () => {
[UserRejectedRequestError: User rejected the request.
Details: Failed to connect.
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
})

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/deployContract.test.ts

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions packages/core/src/actions/getBlock.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ test('chain formatters', async () => {
})
const result = await getBlock(config)
if (result.chainId === celo.id) {
expectTypeOf(result.difficulty).toEqualTypeOf<never>()
expectTypeOf(result.gasLimit).toEqualTypeOf<never>()
expectTypeOf(result.mixHash).toEqualTypeOf<never>()
expectTypeOf(result.nonce).toEqualTypeOf<never>()
expectTypeOf(result.uncles).toEqualTypeOf<never>()
expectTypeOf(result.randomness).toEqualTypeOf<{
committed: `0x${string}`
revealed: `0x${string}`
}>()
expectTypeOf(result.difficulty).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result.gasLimit).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result.mixHash).toEqualTypeOf<undefined>()
expectTypeOf(result.nonce).toEqualTypeOf<`0x${string}`>()
expectTypeOf(result.uncles).toEqualTypeOf<undefined>()
expectTypeOf(result.randomness).toEqualTypeOf<
| {
committed: `0x${string}`
revealed: `0x${string}`
}
| undefined
>()
}
})

Expand All @@ -32,13 +35,16 @@ test('chainId', async () => {
const result = await getBlock(config, {
chainId: celo.id,
})
expectTypeOf(result.difficulty).toEqualTypeOf<never>()
expectTypeOf(result.gasLimit).toEqualTypeOf<never>()
expectTypeOf(result.mixHash).toEqualTypeOf<never>()
expectTypeOf(result.nonce).toEqualTypeOf<never>()
expectTypeOf(result.uncles).toEqualTypeOf<never>()
expectTypeOf(result.randomness).toEqualTypeOf<{
committed: `0x${string}`
revealed: `0x${string}`
}>()
expectTypeOf(result.difficulty).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result.gasLimit).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result.mixHash).toEqualTypeOf<undefined>()
expectTypeOf(result.nonce).toEqualTypeOf<`0x${string}`>()
expectTypeOf(result.uncles).toEqualTypeOf<undefined>()
expectTypeOf(result.randomness).toEqualTypeOf<
| {
committed: `0x${string}`
revealed: `0x${string}`
}
| undefined
>()
})
2 changes: 1 addition & 1 deletion packages/core/src/actions/getToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ test('behavior: bogus token', async () => {
function: decimals()
Docs: https://viem.sh/docs/contract/multicall
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ test('behavior: local account', async () => {
{
"account": {
"address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"experimental_signAuthMessage": [Function],
"nonceManager": undefined,
"publicKey": "0x048318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5",
"signMessage": [Function],
"signTransaction": [Function],
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/actions/readContracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ test('throws if allowFailure=false & a contract method fails', async () => {
args: (0xA0Cf798816D4b9b9866b5330EEa46a18382f251e, 69420)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31]
Version: viem@2.17.0]
`,
)
})
Expand Down Expand Up @@ -450,7 +450,7 @@ test('allowFailure=true & a contract method fails', async () => {
args: (0xA0Cf798816D4b9b9866b5330EEa46a18382f251e, 69420)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31],
Version: viem@2.17.0],
"result": undefined,
"status": "failure",
},
Expand All @@ -464,7 +464,7 @@ test('allowFailure=true & a contract method fails', async () => {
args: (0xA0Cf798816D4b9b9866b5330EEa46a18382f251e, 69421)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31],
Version: viem@2.17.0],
"result": undefined,
"status": "failure",
},
Expand Down Expand Up @@ -502,7 +502,7 @@ test('throws if allowFailure=false & encoding contract function data fails', asy
args: (1e+31)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31]
Version: viem@2.17.0]
`,
)
})
Expand Down Expand Up @@ -561,7 +561,7 @@ test('allowFailure=true & encoding contract function data fails', async () => {
args: (1e+31)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31],
Version: viem@2.17.0],
"result": undefined,
"status": "failure",
},
Expand All @@ -579,7 +579,7 @@ test('allowFailure=true & encoding contract function data fails', async () => {
args: (1e+31)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31],
Version: viem@2.17.0],
"result": undefined,
"status": "failure",
},
Expand Down Expand Up @@ -617,7 +617,7 @@ test('should throw if allowFailure=false & a contract has no response', async ()
args: (0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31]
Version: viem@2.17.0]
`,
)
})
Expand Down Expand Up @@ -669,7 +669,7 @@ test('allowFailure=true & a contract has no response', async () => {
args: (0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC)
Docs: https://viem.sh/docs/contract/readContract
Version: viem@2.9.31],
Version: viem@2.17.0],
"result": undefined,
"status": "failure",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/sendTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test('behavior: value exceeds balance', async () => {
value: 99999 ETH
Details: Insufficient funds for gas * price + value
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
await disconnect(config, { connector })
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/signMessage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test('behavior: user rejected request', async () => {
[UserRejectedRequestError: User rejected the request.
Details: Failed to sign message.
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
await disconnect(config, { connector: connector_ })
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/signTypedData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test('behavior: user rejected request', async () => {
[UserRejectedRequestError: User rejected the request.
Details: Failed to sign typed data.
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
await disconnect(config, { connector: connector_ })
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/switchChain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test('behavior: user rejected request', async () => {
[UserRejectedRequestError: User rejected the request.
Details: Failed to switch chain.
Version: viem@2.9.31]
Version: viem@2.17.0]
`)
await disconnect(config, { connector: connector_ })
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/query/prepareTransactionRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('parameters: account', () => {
{
"account": {
"address": "0x14791697260E4c9A71f18484C9f997B308e59325",
"experimental_signAuthMessage": [Function],
"nonceManager": undefined,
"publicKey": "0x046655feed4d214c261e0a6b554395596f1f1476a77d999560e5a8df9b8a1a3515217e88dd05e938efdd71b2cce322bf01da96cd42087b236e8f5043157a9c068e",
"signMessage": [Function],
"signTransaction": [Function],
Expand Down
45 changes: 26 additions & 19 deletions packages/register-tests/react/src/useBlock.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ import { celo } from 'wagmi/chains'
test('chain formatters', () => {
const result = useBlock()

if (result.data) expectTypeOf(result.data.difficulty).toEqualTypeOf<bigint>()
if (result.data)
expectTypeOf(result.data.difficulty).toEqualTypeOf<bigint | undefined>()

if (result.data?.chainId === celo.id) {
expectTypeOf(result.data.difficulty).toEqualTypeOf<never>()
expectTypeOf(result.data.gasLimit).toEqualTypeOf<never>()
expectTypeOf(result.data.mixHash).toEqualTypeOf<never>()
expectTypeOf(result.data.nonce).toEqualTypeOf<never>()
expectTypeOf(result.data.uncles).toEqualTypeOf<never>()
expectTypeOf(result.data.randomness).toEqualTypeOf<{
committed: `0x${string}`
revealed: `0x${string}`
}>()
expectTypeOf(result.data.difficulty).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result.data.gasLimit).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result.data.mixHash).toEqualTypeOf<undefined>()
expectTypeOf(result.data.nonce).toEqualTypeOf<`0x${string}`>()
expectTypeOf(result.data.uncles).toEqualTypeOf<undefined>()
expectTypeOf(result.data.randomness).toEqualTypeOf<
| {
committed: `0x${string}`
revealed: `0x${string}`
}
| undefined
>()
}

const result2 = useBlock({ chainId: celo.id })
if (result2.data) {
expectTypeOf(result2.data.difficulty).toEqualTypeOf<never>()
expectTypeOf(result2.data.gasLimit).toEqualTypeOf<never>()
expectTypeOf(result2.data.mixHash).toEqualTypeOf<never>()
expectTypeOf(result2.data.nonce).toEqualTypeOf<never>()
expectTypeOf(result2.data.uncles).toEqualTypeOf<never>()
expectTypeOf(result2.data.randomness).toEqualTypeOf<{
committed: `0x${string}`
revealed: `0x${string}`
}>()
expectTypeOf(result2.data.difficulty).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result2.data.gasLimit).toEqualTypeOf<bigint | undefined>()
expectTypeOf(result2.data.mixHash).toEqualTypeOf<undefined>()
expectTypeOf(result2.data.nonce).toEqualTypeOf<`0x${string}`>()
expectTypeOf(result2.data.uncles).toEqualTypeOf<undefined>()
expectTypeOf(result2.data.randomness).toEqualTypeOf<
| {
committed: `0x${string}`
revealed: `0x${string}`
}
| undefined
>()
}
})
Loading

0 comments on commit b4033a0

Please sign in to comment.