Skip to content

Commit

Permalink
Add atlantic-2 chain info (#161)
Browse files Browse the repository at this point in the history
* Add atlantic-2 chain info

* minor edit

* update to just say precompile

* add changeset

* update chain id

* update rpc url

* update changeset

* hardcode precompile addresses in readme
  • Loading branch information
mj850 authored Apr 29, 2024
1 parent ecc4007 commit d79f2a1
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 115 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-lizards-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sei-js/evm": patch
---

Update with Atlantic-2 chain info
24 changes: 13 additions & 11 deletions packages/evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ export const WalletProvider = ({ children }: { children: ReactNode }) => {
### Connection with ethers v6
The 'ethers' package is a popular library for interacting with the Ethereum blockchain. This package provides a helper function for creating an ethers provider that is connected to the Sei EVM.
```tsx
import { ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS } from '@sei-js/evm';
import { ADDRESS_PRECOMPILE_ADDRESS } from '@sei-js/evm';
import { ethers } from 'ethers';

const provider = new ethers.BrowserProvider(window.ethereum); // or any other provider
const signer = await provider.getSigner();

const accounts = await provider.send('eth_requestAccounts', []);

const contract = getAddressPrecompileEthersV6Contract(ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, signer);
const contract = getAddressPrecompileEthersV6Contract(ADDRESS_PRECOMPILE_ADDRESS, signer);

const cosmosAddress = await contract.getSeiAddr(accounts[0]);
```
Expand Down Expand Up @@ -112,8 +112,8 @@ The Address precompile contract enables the retrieval of associated EVM addresse
| [`getEvmAddr`](/sei-js/docs/interfaces/evm.AddressPrecompileFunctions.html#getEvmAddr) | `addr: ` `string` | `{ response: string }` | Retrieves the associated EVM address for a given Cosmos address. |
| [`getSeiAddr`](/sei-js/docs/interfaces/evm.AddressPrecompileFunctions.html#getSeiAddr) | `addr: ` `string` | `{ response: string }` | Retrieves the associated Cosmos address for a given EVM address. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS.html)
#### Precompile Address
0x0000000000000000000000000000000000001004

<br>
<br>
Expand All @@ -134,7 +134,7 @@ The Bank precompile contract provides functionalities for managing balances, sup
| [`sendNative`](/sei-js/docs/interfaces/evm.BankPrecompileFunctions.html#sendNative) | `toNativeAddress: ` `string`, `value: ` `string` | `{ success: boolean }` | Sends native tokens to a specified address. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_BANK_PRECOMPILE_ADDRESS.html)
0x0000000000000000000000000000000000001001

<br>
<br>
Expand All @@ -151,7 +151,7 @@ The Distribution precompile contract facilitates operations related to rewards w
| [`withdrawDelegationRewards`](/sei-js/docs/interfaces/evm.DistributionPrecompileFunctions.html#withdrawDelegationRewards) | `validator: ` `string` | `{ success: boolean }` | Withdraws delegation rewards for a given validator. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_DISTRIBUTION_PRECOMPILE_ADDRESS.html)
0x0000000000000000000000000000000000001007

<br>
<br>
Expand All @@ -167,7 +167,7 @@ The Governance precompile contract supports actions to deposit funds into propos
| [`vote`](/sei-js/docs/interfaces/evm.GovernancePrecompileFunctions.html#vote) | `proposalID: ` `string`, `option: ` `string` | `{ success: boolean }` | Votes on a governance proposal. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_GOVERNANCE_PRECOMPILE_ADDRESS.html)
0x0000000000000000000000000000000000001006

<br>
<br>
Expand All @@ -184,7 +184,7 @@ The JSON precompile contract facilitates interoperability between the EVM and Co
| [`extractAsUint256`](/sei-js/docs/interfaces/evm.JSONPrecompileFunctions.html#extractAsUint256) | `input: ` `string`, `key: ` `string` | `{ response: string }` | Extracts data as a uint256 from the input using the specified key. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_JSON_PRECOMPILE_ADDRESS.html)
- [arctic-1](/sei-js/docs/variables/evm.JSON_PRECOMPILE_ADDRESS.html)

<br>
<br>
Expand All @@ -202,7 +202,7 @@ The Staking precompile contract provides functions for delegation, re-delegation
| [`undelegate`](/sei-js/docs/interfaces/evm.StakingPrecompileFunctions.html#undelegate) | `valAddress: ` `string`, `amount: ` `string` | `{ success: boolean }` | Undelegates tokens from the specified validator. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_STAKING_PRECOMPILE_ADDRESS.html)
0x0000000000000000000000000000000000001005

<br>
<br>
Expand All @@ -219,7 +219,8 @@ The WASM precompile contract facilitates execution, instantiation, and querying
| [`query`](/sei-js/docs/interfaces/evm.WasmPrecompileFunctions.html#query) | `contractAddress: ` `string`, `req: ` `Uint8Array` | `{ response: Uint8Array }` | Queries the specified contract with the provided request. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_WASM_PRECOMPILE_ADDRESS.html)
0x0000000000000000000000000000000000001002


<br>
<br>
Expand All @@ -234,4 +235,5 @@ The IBC precompile contract facilitates messages exchange between Sei and other
| [`transfer`](/sei-js/docs/interfaces/evm.IbcPrecompileFunctions.html#transfer) | `toAddress: ` `string`, `port: ` `string`, `channel: ` `string`, `denom: ` `string`, `amount: ` `ethers.BigNumberish`, `revisionNumber: ` `BigInt`, `revisionHeight: ` `BigInt`, `timeoutTimestamp: ` `BigInt` | `{ success: boolean }` | Transfers tokens from the caller's address to another on a different (IBC compatible) chain. |

#### Precompile Addresses
- [arctic-1](/sei-js/docs/variables/evm.ARCTIC_1_IBC_PRECOMPILE_ADDRESS.html)
0x0000000000000000000000000000000000001009

4 changes: 4 additions & 0 deletions packages/evm/src/chainInfo/chainInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ export const SeiChainInfo = {
devnet: {
chainId: 713715,
defaultRpc: 'https://evm-rpc-arctic-1.sei-apis.com'
},
testnet: {
chainId: 1328,
defaultRpc: 'https://evm-rpc-testnet.sei-apis.com/'
}
};
22 changes: 11 additions & 11 deletions packages/evm/src/precompiles/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,34 @@ export type AddressPrecompileContract = ethers.Contract & AddressPrecompileFunct
* @example
* Wagmi: Use the `useReadContract` hook to read the associated Cosmos address for the connected account.
* ```tsx
* import { ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI } from '@sei-js/evm';
* import { ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI } from '@sei-js/evm';
* import { useReadContract } from 'wagmi';
*
* // Make sure your component is wrapped in a WagmiProvider
* const { address } = useAccount();
*
* const associatedSeiAddress = useReadContract({ abi: ADDRESS_PRECOMPILE_ABI, address: ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, functionName: 'getSeiAddr', args: [address] });
* const associatedSeiAddress = useReadContract({ abi: ADDRESS_PRECOMPILE_ABI, address: ADDRESS_PRECOMPILE_ADDRESS, functionName: 'getSeiAddr', args: [address] });
* ```
*
* @example
* ethers v6: Use the `ethers` library and precompiles to read the associated Cosmos address for the connected account.
* ```tsx
* import { ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { ADDRESS_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { ethers } from 'ethers';
*
* const provider = new ethers.BrowserProvider(window.ethereum); // or any other provider
* const signer = await provider.getSigner();
*
* const accounts = await provider.send('eth_requestAccounts', []);
*
* const addressPrecompileContract = getAddressPrecompileEthersV6Contract(ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, signer);
* const addressPrecompileContract = getAddressPrecompileEthersV6Contract(ADDRESS_PRECOMPILE_ADDRESS, signer);
*
* const associatedSeiAddress = await addressPrecompileContract.getSeiAddr(accounts[0]);
* ```
*
* @category Cosmos Interoperability
*/
export const ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS: `0x${string}` = '0x0000000000000000000000000000000000001004';
export const ADDRESS_PRECOMPILE_ADDRESS: `0x${string}` = '0x0000000000000000000000000000000000001004';

/**
* The ABI for the precompile contract which can be used for interoperability between the EVM and Cosmos.
Expand All @@ -70,27 +70,27 @@ export const ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS: `0x${string}` = '0x00000000000
* @example
* Wagmi: Use the `useReadContract` hook to read the associated Cosmos address for the connected account.
* ```tsx
* import { ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI } from '@sei-js/evm';
* import { ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI } from '@sei-js/evm';
* import { useReadContract } from 'wagmi';
*
* // Make sure your component is wrapped in a WagmiProvider
* const { address } = useAccount();
*
* const associatedSeiAddress = useReadContract({ abi: ADDRESS_PRECOMPILE_ABI, address: ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, functionName: 'getSeiAddr', args: [address] });
* const associatedSeiAddress = useReadContract({ abi: ADDRESS_PRECOMPILE_ABI, address: ADDRESS_PRECOMPILE_ADDRESS, functionName: 'getSeiAddr', args: [address] });
* ```
*
* @example
* ethers v6: Use the `ethers` library and precompiles to read the associated Cosmos address for the connected account.
* ```tsx
* import { ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, AddressPrecompileContract } from '@sei-js/evm';
* import { ADDRESS_PRECOMPILE_ADDRESS, AddressPrecompileContract } from '@sei-js/evm';
* import { ethers } from 'ethers';
*
* const provider = new ethers.BrowserProvider(window.ethereum); // or any other provider
* const signer = await provider.getSigner();
*
* const accounts = await provider.send('eth_requestAccounts', []);
*
* const addressPrecompileContract = new ethers.Contract(ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI, signer) as AddressPrecompileContract;
* const addressPrecompileContract = new ethers.Contract(ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI, signer) as AddressPrecompileContract;
*
* const associatedSeiAddress = await addressPrecompileContract.getSeiAddr(accounts[0]);
* ```
Expand Down Expand Up @@ -121,15 +121,15 @@ export const ADDRESS_PRECOMPILE_ABI: Abi = [
* @example
* ethers v6: Use the `ethers` library and precompiles to read the associated Cosmos address for the connected account.
* ```tsx
* import { ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { ADDRESS_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { ethers } from 'ethers';
*
* const provider = new ethers.BrowserProvider(window.ethereum); // or any other provider
* const signer = await provider.getSigner();
*
* const accounts = await provider.send('eth_requestAccounts', []);
*
* const addressPrecompileContract = getAddressPrecompileEthersV6Contract(ARCTIC_1_ADDRESS_PRECOMPILE_ADDRESS, signer);
* const addressPrecompileContract = getAddressPrecompileEthersV6Contract(ADDRESS_PRECOMPILE_ADDRESS, signer);
*
* const associatedSeiAddress = await addressPrecompileContract.connect().getSeiAddr(accounts[0]);
* ```
Expand Down
22 changes: 11 additions & 11 deletions packages/evm/src/precompiles/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export type BankPrecompileContract = ethers.Contract & BankPrecompileFunctions;
* @example
* Wagmi: Use the `useReadContract` hook to read the balance of the connected account.
* ```tsx
* import { ARCTIC_1_BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI } from '@sei-js/evm';
* import { BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI } from '@sei-js/evm';
* import { useReadContract } from 'wagmi';
*
* // Make sure your component is wrapped in a WagmiProvider
* const { address } = useAccount();
*
* const { data } = useReadContract({
* abi: BANK_PRECOMPILE_ABI,
* address: ARCTIC_1_BANK_PRECOMPILE_ADDRESS,
* address: BANK_PRECOMPILE_ADDRESS,
* functionName: 'balance',
* args: [address, 'usei']
* });
Expand All @@ -93,38 +93,38 @@ export type BankPrecompileContract = ethers.Contract & BankPrecompileFunctions;
* @example
* ethers v6: Use the `ethers` library and precompiles to read the balance of the connected account.
* ```tsx
* import { ARCTIC_1_BANK_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { BANK_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { ethers } from 'ethers';
*
* const provider = new ethers.BrowserProvider(window.ethereum); // or any other provider
* const signer = await provider.getSigner();
*
* const accounts = await provider.send('eth_requestAccounts', []);
*
* const bankPrecompileContract = getBankPrecompileEthersV6Contract(ARCTIC_1_BANK_PRECOMPILE_ADDRESS, signer);
* const bankPrecompileContract = getBankPrecompileEthersV6Contract(BANK_PRECOMPILE_ADDRESS, signer);
*
* const balance = await bankPrecompileContract.balance(accounts[0], 'usei');
* ```
*
* @category Cosmos Interoperability
*/
export const ARCTIC_1_BANK_PRECOMPILE_ADDRESS: `0x${string}` = '0x0000000000000000000000000000000000001001';
export const BANK_PRECOMPILE_ADDRESS: `0x${string}` = '0x0000000000000000000000000000000000001001';

/**
* The ABI for the precompile contract, which can be used for interoperability between the EVM and Cosmos.
*
* @example
* Wagmi: Use the `useReadContract` hook to read the balance of the connected account.
* ```tsx
* import { ARCTIC_1_BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI } from '@sei-js/evm';
* import { BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI } from '@sei-js/evm';
* import { useReadContract } from 'wagmi';
*
* // Make sure your component is wrapped in a WagmiProvider
* const { address } = useAccount();
*
* const { data } = useReadContract({
* abi: BANK_PRECOMPILE_ABI,
* address: ARCTIC_1_BANK_PRECOMPILE_ADDRESS,
* address: BANK_PRECOMPILE_ADDRESS,
* functionName: 'balance',
* args: [address, 'usei']
* });
Expand All @@ -135,15 +135,15 @@ export const ARCTIC_1_BANK_PRECOMPILE_ADDRESS: `0x${string}` = '0x00000000000000
* @example
* ethers v6: Use the `ethers` library and precompiles to read the balance of the connected account.
* ```tsx
* import { ARCTIC_1_BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI, BankPrecompileContract } from '@sei-js/evm';
* import { BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI, BankPrecompileContract } from '@sei-js/evm';
* import { ethers } from 'ethers';
*
* const provider = new ethers.BrowserProvider(window.ethereum); // or any other provider
* const signer = await provider.getSigner();
*
* const accounts = await provider.send('eth_requestAccounts', []);
*
* const bankPrecompileContract = new ethers.Contract(ARCTIC_1_BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI, signer) as BankPrecompileContract;
* const bankPrecompileContract = new ethers.Contract(BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI, signer) as BankPrecompileContract;
*
* const balance = await bankPrecompileContract.balance(accounts[0], 'usei');
* ```
Expand Down Expand Up @@ -215,15 +215,15 @@ export const BANK_PRECOMPILE_ABI: Abi = [
*
* @example
* ```tsx
* import { ARCTIC_1_BANK_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { BANK_PRECOMPILE_ADDRESS } from '@sei-js/evm';
* import { ethers } from 'ethers';
*
* const provider = new ethers.BrowserProvider(window.ethereum); // or any other provider
* const signer = await provider.getSigner();
*
* const accounts = await provider.send('eth_requestAccounts', []);
*
* const bankPrecompileContract = getBankPrecompileEthersV6Contract(ARCTIC_1_BANK_PRECOMPILE_ADDRESS, signer);
* const bankPrecompileContract = getBankPrecompileEthersV6Contract(BANK_PRECOMPILE_ADDRESS, signer);
*
* const balance = await bankPrecompileContract.balance(accounts[0], 'usei');
* ```
Expand Down
Loading

0 comments on commit d79f2a1

Please sign in to comment.