wagmi-extended 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +43 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -22,6 +22,7 @@ Whether you're building a DeFi platform, a governance system, or any blockchain
22
22
  - [Non-hook functions setup](#non-hook-functions-setup)
23
23
  - [Error handling](#error-handling)
24
24
  - [fetchTokenX](#fetchTokenX)
25
+ - [fetchDeploymentBlockX](#fetchDeploymentBlockX)
25
26
  - [Contributing](#contributing)
26
27
  - [Donations](#support--donations)
27
28
  - [License](#license)
@@ -365,14 +366,48 @@ const tokensData = await Promise.all(tokenAddresses.map((token) =>
365
366
 
366
367
  > **Note:** : if you did not setup configs (queryClient and wagmi config) you can call by passing client and config as params: `fetchTokenX(token, queryClient, wagmiConfig)`.
367
368
 
369
+ ### fetchDeploymentBlockX
370
+
371
+ The `fetchDeploymentBlockX` function finds and caches the earliest block where a contract was deployed
372
+ (i.e., the first block containing bytecode at a given address).
373
+
374
+ It uses an **exponential descent** followed by a **binary search**, making it optimal for locating deployment blocks with minimal RPC calls.
375
+
376
+ - **Exponential descent**: quickly finds a safe lower bound with no code.
377
+ - **Binary search**: efficiently pinpoints the exact deployment block in logarithmic steps.
378
+
379
+ #### Example
380
+
381
+ ```ts
382
+ import { fetchDeploymentBlockX } from "wagmi-extended";
383
+
384
+ async function main() {
385
+ const deploymentBlock = await fetchDeploymentBlockX(
386
+ "0xYourContractAddress",
387
+ 0n
388
+ );
389
+
390
+ console.log("Contract was deployed at block:", deploymentBlock.toString());
391
+ }
392
+
393
+ main();
394
+ ```
395
+
396
+ Performance
397
+
398
+ Performs O(log N) RPC calls, where N is the distance between the latest block and the deployment block.
399
+
400
+ - Much more efficient than linear scanning.
401
+ - Automatically cached by React Query under the key:
402
+
368
403
  ## Contributing
369
404
 
370
405
  This project is open source and we welcome contributions from the community! If you have ideas, improvements, or bug fixes, please feel free to open pull requests or file issues. Your help makes this project better for everyone.
371
406
 
372
- - **Open Issues & PRs:**
407
+ - **Open Issues & PRs:**
373
408
  You can report bugs or request features by opening an issue on [GitHub Issues](https://github.com/WingsDevelopment/wagmi-extended/issues). Similarly, feel free to open a pull request (PR) with your changes.
374
409
 
375
- - **Star the Project:**
410
+ - **Star the Project:**
376
411
  If you like `wagmi-extended` or find it useful, please consider starring the repository on [GitHub](https://github.com/WingsDevelopment/wagmi-extended). It helps the project gain visibility and motivates further development.
377
412
 
378
413
  Thank you for your support and contributions!
@@ -381,10 +416,10 @@ Thank you for your support and contributions!
381
416
 
382
417
  If you enjoy this project and would like to support its ongoing development, please consider donating!
383
418
 
384
- - **Buy Me a Coffee:**
419
+ - **Buy Me a Coffee:**
385
420
  [buymeacoffee.com/srdjanr160N](https://buymeacoffee.com/srdjanr160N)
386
421
 
387
- - **Ethereum Donation Address:**
422
+ - **Ethereum Donation Address:**
388
423
  `0x410A11ed53a9a59094F24D2ae4ACbeF7f84955a1`
389
424
 
390
425
  Any donation, no matter how small, is greatly appreciated!
@@ -398,3 +433,7 @@ Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
398
433
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
399
434
 
400
435
  For more information, please refer to <http://unlicense.org/>
436
+
437
+ ```
438
+
439
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wagmi-extended",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "type": "module",
5
5
  "description": "A library providing extended hooks on top of Wagmi with additional hooks and features.",
6
6
  "main": "dist/index.cjs.js",