-
-
Notifications
You must be signed in to change notification settings - Fork 968
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add timeout as config to transport * chore: changeset * feat: decode log `topics` + `data` & infer types for logs (#75) * feat: decode event log topics & data * docs: createContractEventFilter * pr review * feat: fall back to `getLogs` if filters are not supported (#76) * feat: fall back to getLogs if filters are not supported * Update src/actions/public/watchContractEvent.test.ts Co-authored-by: awkweb <[email protected]> * pr review --------- Co-authored-by: awkweb <[email protected]> * feat: decorate clients with actions (#77) * feat: fall back to getLogs if filters are not supported * Update src/actions/public/watchContractEvent.test.ts Co-authored-by: awkweb <[email protected]> * pr review * feat: decode event log topics & data * wip: public * wip: add ens * docs: public actions * wip: wallet actions * docs: wallet actions * wip: test actions * wip: add utils to main entrypoint * tests: add tests * playgrounds: update * chore: changeset * test * refactor: wire up decorator generics * fix conflicts * format --------- Co-authored-by: awkweb <[email protected]> --------- Co-authored-by: awkweb <[email protected]>
- Loading branch information
Showing
16 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"viem": patch | ||
--- | ||
|
||
Added `timeout` as a config option to the `http` and `webSocket` Transports. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { assertType, describe, expect, test } from 'vitest' | ||
|
||
import { localhost } from '../../chains' | ||
import { wait } from '../../utils/wait' | ||
import { createHttpServer } from '../../_test' | ||
|
||
import type { HttpTransport } from './http' | ||
|
@@ -20,6 +21,7 @@ test('default', () => { | |
"request": [Function], | ||
"retryCount": 3, | ||
"retryDelay": 150, | ||
"timeout": 10000, | ||
"type": "http", | ||
}, | ||
"request": [Function], | ||
|
@@ -44,6 +46,7 @@ describe('config', () => { | |
"request": [Function], | ||
"retryCount": 3, | ||
"retryDelay": 150, | ||
"timeout": 10000, | ||
"type": "http", | ||
}, | ||
"request": [Function], | ||
|
@@ -67,6 +70,7 @@ describe('config', () => { | |
"request": [Function], | ||
"retryCount": 3, | ||
"retryDelay": 150, | ||
"timeout": 10000, | ||
"type": "http", | ||
}, | ||
"request": [Function], | ||
|
@@ -88,6 +92,7 @@ describe('config', () => { | |
"request": [Function], | ||
"retryCount": 3, | ||
"retryDelay": 150, | ||
"timeout": 10000, | ||
"type": "http", | ||
}, | ||
"request": [Function], | ||
|
@@ -172,6 +177,34 @@ describe('request', () => { | |
`) | ||
expect(end > 500 && end < 520).toBeTruthy() | ||
}) | ||
|
||
test('behavior: timeout', async () => { | ||
const server = await createHttpServer(async (req, res) => { | ||
await wait(5000) | ||
res.writeHead(500, { | ||
'Content-Type': 'application/json', | ||
}) | ||
res.end(JSON.stringify({})) | ||
}) | ||
|
||
const transport = http(server.url, { | ||
key: 'jsonRpc', | ||
name: 'JSON RPC', | ||
timeout: 100, | ||
})({ chain: localhost }) | ||
|
||
await expect(() => | ||
transport.request({ method: 'eth_blockNumber' }), | ||
).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
"The request took too long to respond. | ||
URL: http://localhost | ||
Request body: {\\"method\\":\\"eth_blockNumber\\"} | ||
Details: The request timed out. | ||
Version: [email protected]" | ||
`) | ||
}) | ||
}) | ||
|
||
test('no url', () => { | ||
|
Oops, something went wrong.
db9caa9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viem-site – ./site
viem-site.vercel.app
viem-site-git-main-wagmi-dev.vercel.app
viem-site-wagmi-dev.vercel.app
db9caa9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viem-playground – ./playgrounds/browser
viem-playground.vercel.app
viem-playground-git-main-wagmi-dev.vercel.app
viem-playground-wagmi-dev.vercel.app