From 249c868e992501d6f5fe5b48e8190ad10741d065 Mon Sep 17 00:00:00 2001 From: Sotatek-TanHoang Date: Wed, 2 Oct 2024 16:42:36 +0700 Subject: [PATCH 1/3] feat: update readme --- ethers-ext/README.md | 128 ++++++++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 39 deletions(-) diff --git a/ethers-ext/README.md b/ethers-ext/README.md index 32ebd3f78..aa3652a2e 100644 --- a/ethers-ext/README.md +++ b/ethers-ext/README.md @@ -10,61 +10,112 @@ Ethers.js Extension for Klaytn offers: ## Note for ethers v6 -`@kaiachain/ethers-ext` was developed based on ethers v5. As a result, ethers v6 classes are incompatible with ethers-ext classes. If you are using ethers v6 in your codebase, do not mix ethers v6 classes and ethers-ext classes. e.g. ethers v6 JsonRpcProvider cannot be supplied to ethers-ext Wallet. - -- **Don't**: mix ethers v6 and ethers-ext - ```js - const ethers = require("ethers"); - const { Wallet } = require("@kaiachain/ethers-ext"); - - const provider = new ethers.JsonRpcProvider("https://public-en-kairos.node.kaia.io"); - const wallet = new Wallet("", provider); - ``` -- **Do**: mix ethers v5 and ethers-ext - ```js - const ethers = require("ethers"); - const { Wallet } = require("@kaiachain/ethers-ext"); - - const provider = new ethers.providers.JsonRpcProvider("https://public-en-kairos.node.kaia.io"); - const wallet = new Wallet("", provider); - ``` +`@kaiachain/ethers-ext` supports both ethers v5 and v6. However, you need to use the right packages which are specified for each `ethers` version. So ethers v5 must be used with packages from `@kaiachain/ethers-ext/v5` and ethers v6 is only compatible with `@kaiachain/ethers-ext/v6`. + +> **_NOTE:_** +> If the import path has no version sub-path (`@kaiachain/ethers-ext`) ethers v5 is used by default. + +- **Don't**: mix ethers v6 and ethers-ext for ethers v5 + + ```js + const ethers = require("ethers"); // ethers v6 + const { Wallet } = require("@kaiachain/ethers-ext/v5"); + + const provider = new ethers.JsonRpcProvider( + "https://public-en-kairos.node.kaia.io" + ); + const wallet = new Wallet("", provider); + ``` + +- **Do**: Using with ethers v5 + + ```js + const ethers = require("ethers"); // ethers v5 + const { Wallet } = require("@klaytn/ethers-ext/v5"); + + const provider = new ethers.providers.JsonRpcProvider( + "https://public-en-kairos.node.kaia.io" + ); + const wallet = new Wallet("", provider); + ``` + +- **Do**: Using with ethers v6 + + ```js + const ethers = require("ethers"); // ethers v6 + const { Wallet } = require("@klaytn/ethers-ext/v6"); + + const provider = new ethers.JsonRpcProvider( + "https://public-en-kairos.node.kaia.io" + ); + const wallet = new Wallet("", provider); + ``` + - **Do**: ethers-ext only - ```js - const { Wallet, JsonRpcProvider } = require("@kaiachain/ethers-ext"); - const provider = new JsonRpcProvider("https://public-en-kairos.node.kaia.io"); - const wallet = new Wallet("", provider); - ``` + ```js + const { Wallet, JsonRpcProvider } = require("@kaiachain/ethers-ext/v5"); + // or + const { Wallet, JsonRpcProvider } = require("@kaiachain/ethers-ext/v6"); + + const provider = new JsonRpcProvider("https://public-en-kairos.node.kaia.io"); + const wallet = new Wallet("", provider); + ``` ## Install ### Node.js - Install - ```sh - npm install --save @kaiachain/ethers-ext ethers@5 - ``` + ```sh + npm install --save @kaiachain/ethers-ext ethers@5 # or ethers@6 + ``` - ESM or TypeScript - ```ts - import { Wallet, JsonRpcProvider } from "@kaiachain/ethers-ext"; - const provider = new JsonRpcProvider("https://public-en-kairos.node.kaia.io"); - const wallet = new Wallet("", provider); - ``` + + ```ts + import { Wallet, JsonRpcProvider } from "@klaytn/ethers-ext"; + + // esm + // v5 + import { v5 } from "@klaytn/ethers-ext"; + const { Wallet, JsonRpcProvider } = v5; + // v6 + import { v6 } from "@klaytn/ethers-ext"; + const { Wallet, JsonRpcProvider } = v6; + + // esm subpath import. If using typescript, add "moduleResolution": "nodenext" to tsconfig.json + // v5 + import { Wallet, JsonRpcProvider } from "@klaytn/ethers-ext/v5"; + // v6 + import { Wallet, JsonRpcProvider } from "@klaytn/ethers-ext/v6"; + + const provider = new JsonRpcProvider("https://public-en-kairos.node.kaia.io"); + const wallet = new Wallet("", provider); + ``` + - CommonJS - ```js - const { Wallet, JsonRpcProvider } = require("@kaiachain/ethers-ext"); - const provider = new JsonRpcProvider("https://public-en-kairos.node.kaia.io"); - const wallet = new Wallet("", provider); - ``` + + ```js + // v5 + const { Wallet, JsonRpcProvider } = require("@klaytn/ethers-ext"); + const { Wallet, JsonRpcProvider } = require("@klaytn/ethers-ext").v5; + const { Wallet, JsonRpcProvider } = require("@klaytn/ethers-ext/v5"); + // v6 + const { Wallet, JsonRpcProvider } = require("@klaytn/ethers-ext").v6; + const { Wallet, JsonRpcProvider } = require("@klaytn/ethers-ext/v6"); + + const provider = new JsonRpcProvider("https://public-en-kairos.node.kaia.io"); + const wallet = new Wallet("", provider); + ``` ### Browser -It is not recommended to use CDNs in production, But you can use below for quick prototyping. +It is not recommended to use CDNs in production, But you can use below for quick prototyping. using `ethers-ext.buldle.js` for ethers v5 and `ethers-ext.v6.bundle.js` for ethers v6 ```html ``` @@ -72,7 +123,6 @@ const provider = new ethers_ext.providers.Web3Provider(window.klaytn); See [example](./example) and [test](./test). - ## Class extension design ```mermaid From f67406d2b9ba33626fd35a9124d8df4ec51f4ab7 Mon Sep 17 00:00:00 2001 From: Sotatek-TanHoang Date: Wed, 2 Oct 2024 16:44:21 +0700 Subject: [PATCH 2/3] fix: typo --- ethers-ext/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethers-ext/README.md b/ethers-ext/README.md index aa3652a2e..1fbf370b2 100644 --- a/ethers-ext/README.md +++ b/ethers-ext/README.md @@ -13,7 +13,7 @@ Ethers.js Extension for Klaytn offers: `@kaiachain/ethers-ext` supports both ethers v5 and v6. However, you need to use the right packages which are specified for each `ethers` version. So ethers v5 must be used with packages from `@kaiachain/ethers-ext/v5` and ethers v6 is only compatible with `@kaiachain/ethers-ext/v6`. > **_NOTE:_** -> If the import path has no version sub-path (`@kaiachain/ethers-ext`) ethers v5 is used by default. +> If the import path has no version sub-path (`@kaiachain/ethers-ext`), ethers v5 will be used by default. - **Don't**: mix ethers v6 and ethers-ext for ethers v5 From 977a2c3884d55046d7955199bc1d3d46e057b035 Mon Sep 17 00:00:00 2001 From: Sotatek-TanHoang Date: Wed, 2 Oct 2024 16:47:31 +0700 Subject: [PATCH 3/3] fix: text casing --- ethers-ext/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethers-ext/README.md b/ethers-ext/README.md index 1fbf370b2..ed116de22 100644 --- a/ethers-ext/README.md +++ b/ethers-ext/README.md @@ -15,7 +15,7 @@ Ethers.js Extension for Klaytn offers: > **_NOTE:_** > If the import path has no version sub-path (`@kaiachain/ethers-ext`), ethers v5 will be used by default. -- **Don't**: mix ethers v6 and ethers-ext for ethers v5 +- **Don't**: Mixing ethers v6 and ethers-ext for ethers v5 ```js const ethers = require("ethers"); // ethers v6 @@ -51,7 +51,7 @@ Ethers.js Extension for Klaytn offers: const wallet = new Wallet("", provider); ``` -- **Do**: ethers-ext only +- **Do**: Using ethers-ext only ```js const { Wallet, JsonRpcProvider } = require("@kaiachain/ethers-ext/v5");