Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion modules/evm/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
AWS_REGION=your-region
AWS_APP_CONFIG_APP=app-id
AWS_APP_CONFIG_ENV=env-id
AWS_APP_CONFIG_PROFILE=profile-id
AWS_APP_CONFIG_PROFILE=profile-id

# Testnet RPC Credentials
XRPLEVM_TESTNET_RPC_USERNAME=your_testnet_username
XRPLEVM_TESTNET_RPC_PASSWORD=your_testnet_password

# Devnet RPC Credentials (optional)
XRPLEVM_DEVNET_RPC_USERNAME=your_devnet_username
XRPLEVM_DEVNET_RPC_PASSWORD=your_devnet_password

# Mainnet RPC Credentials (optional)
XRPLEVM_MAINNET_RPC_USERNAME=your_mainnet_username
XRPLEVM_MAINNET_RPC_PASSWORD=your_mainnet_password

# Localnet RPC Credentials (optional)
XRPLEVM_LOCALNET_RPC_USERNAME=your_localnet_username
XRPLEVM_LOCALNET_RPC_PASSWORD=your_localnet_password
39 changes: 38 additions & 1 deletion modules/evm/configs/devnet.module.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,44 @@
"amount": "1",
"burnAmount": "1",
"faucetFund": "10000000000000000000"
}
},
"rpc": [
{
"label": "v9.0.0",
"block": {
"number": 21158660,
"hash": "0x90864febaf829431f133302877128e3e4c7c214a4d050b29d5dcd3d8b50c07d6"
},
"transaction": {
"hash": "0x19f98122077c54ea8be201c987a5772565214da43d4ec806cd371772db7bd3e0",
"index": 0
},
"disabledCalls": []
},
{
"label": "v8.0.0",
"block": {
"number": 16601480,
"hash": "0x0a8aa9d2f91d6e5a26793801de3d213eace28afda78d61dcaf35e67a2681a844"
},
"transaction": {
"hash": "0xf7f5f3819ef820f869720986d6441f40d2d3b2a18ca08dbe18faecbed06d063d",
"index": 0
},
"disabledCalls": [
"eth_getBlockByNumber",
"eth_getBlockByHash",
"eth_getTransactionByHash",
"eth_getTransactionReceipt",
"eth_getBlockReceipts",
"eth_getTransactionByBlockHashAndIndex",
"eth_getTransactionByBlockNumberAndIndex",
"eth_getBlockTransactionCountByHash",
"eth_getBlockTransactionCountByNumber",
"eth_getTransactionCount"
]
}
]
},
"chain": {
"id": "xrpl-evm-devnet",
Expand Down
33 changes: 32 additions & 1 deletion modules/evm/configs/localnet.module.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,38 @@
"amount": "1",
"burnAmount": "1",
"faucetFund": "10000000000000000000"
}
},
"rpc": [
{
"label": "v9.0.0",
"block": {
"number": 504,
"hash": "0x9571f62a6e9bdb4dbc87f2aeec9214d416dcc1332c86475ed9b554d363858fc3"
},
"transaction": {
"hash": "0x02258daf4eff825687c71676469bb66bbf384d35cbf13863738f8a9185c079cc",
"index": 0
},
"disabledCalls": [
"eth_gasPrice",
"eth_feeHistory"
]
},
{
"label": "v8.0.0",
"block": {
"number": 84,
"hash": "0x25b60b46dd51369334124938cf4190a315bcbf21cacd65ec60605d5ccb86f83b"
},
"transaction": {
"hash": "0x4e73cb2059b1578d684a5781397854f86aadc1e340c8bb132ac2af1e60dd90e0",
"index": 0
},
"disabledCalls": [
"eth_gasPrice"
]
}
]
},
"chain": {
"id": "xrplevm_localnet",
Expand Down
18 changes: 17 additions & 1 deletion modules/evm/configs/mainnet.module.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,23 @@
"amount": "1",
"burnAmount": "1",
"faucetFund": "10000000000000000000"
}
},
"rpc": [
{
"label": "v8.0.0",
"block": {
"number": 3521556,
"hash": "0x856632b7be8d89337f9675e5828e7d4ffb286b541d3e3f1dbb5d2bd2d42e3161"
},
"transaction": {
"hash": "0xd1d82250ce64b2076c9c02b87539c3306bb4872d733de82c0a765de3c36cf8ce",
"index": 0
},
"disabledCalls": [
"eth_getBlockReceipts"
]
}
]
},
"chain": {
"id": "xrpl-evm",
Expand Down
29 changes: 28 additions & 1 deletion modules/evm/configs/testnet.module.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"networks": {
"xrplevm_testnet": {
"url": "https://rpc.testnet.xrplevm.org",
"archivalUrl": "https://full-history-0.testnet.xrplevm.org",
"accounts": [
"f81159b8509dbabec1fb48fbbae0bd51153105bb5d39f061192096c40274d100",
"25ed64e00aefb0081cc5c799e4abc916b16961a54a7c97138f7e98b357a60161"
Expand Down Expand Up @@ -39,7 +40,33 @@
"amount": "1",
"burnAmount": "1",
"faucetFund": "10000000000000000000"
}
},
"rpc": [
{
"label": "v9.0.0",
"block": {
"number": 4471781,
"hash": "0xdcf1d3b001fffa8e1825865e5c3a7e425eaa2a936e795833bb904041938317e0"
},
"transaction": {
"hash": "0xe59812bc92cda88de7a88ee565c1f28aed9b3747d7e0d7df73d436e749126509",
"index": 2
},
"disabledCalls": []
},
{
"label": "v8.0.0",
"block": {
"number": 3826800,
"hash": "0x7d4f9d8fb36ca91a9c618b76bba5039cecbbafd7ee6efe8163e4b87ee1fde083"
},
"transaction": {
"hash": "0x5c995ca814cce1043928b1901efebcc67a364ba819428ea709c27c1ac1fef0d7",
"index": 0
},
"disabledCalls": []
}
]
},
"chain": {
"id": "xrpl-evm",
Expand Down
3 changes: 3 additions & 0 deletions modules/evm/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as dotenv from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import moduleConfig from "./module.config.json";

dotenv.config();

const config: HardhatUserConfig = {
...moduleConfig.hardhat,
mocha: {
Expand Down
52 changes: 41 additions & 11 deletions modules/evm/module.config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"hardhat": {
"defaultNetwork": "xrplevm_localnet",
"defaultNetwork": "xrplevm_testnet",
"solidity": "0.8.20",
"networks": {
"xrplevm_localnet": {
"url": "http://localhost:8545",
"xrplevm_testnet": {
"url": "https://rpc.testnet.xrplevm.org",
"archivalUrl": "https://full-history-0.testnet.xrplevm.org",
"accounts": [
"f81159b8509dbabec1fb48fbbae0bd51153105bb5d39f061192096c40274d100",
"25ed64e00aefb0081cc5c799e4abc916b16961a54a7c97138f7e98b357a60161"
Expand Down Expand Up @@ -34,22 +35,51 @@
"event Transfer(address indexed from, address indexed to, uint256 value)",
"event Approval(address indexed owner, address indexed spender, uint256 value)"
],
"contractAddress": "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517",
"owner": "0x10CDF544aeeEbadA19198a21a38D653A95e32272",
"contractAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"owner": "0xdb0a778c57Bd31E401D52ba6cf936D06E1324aE8",
"amount": "1",
"burnAmount": "1",
"faucetFund": "10000000000000000000"
}
},
"rpc": [
{
"label": "v9.0.0",
"block": {
"number": 4471781,
"hash": "0xdcf1d3b001fffa8e1825865e5c3a7e425eaa2a936e795833bb904041938317e0"
},
"transaction": {
"hash": "0xe59812bc92cda88de7a88ee565c1f28aed9b3747d7e0d7df73d436e749126509",
"index": 2
},
"disabledCalls": []
},
{
"label": "v8.0.0",
"block": {
"number": 3826800,
"hash": "0x7d4f9d8fb36ca91a9c618b76bba5039cecbbafd7ee6efe8163e4b87ee1fde083"
},
"transaction": {
"hash": "0x5c995ca814cce1043928b1901efebcc67a364ba819428ea709c27c1ac1fef0d7",
"index": 0
},
"disabledCalls": []
}
]
},
"chain": {
"id": "xrplevm_localnet",
"name": "xrplevm_localnet",
"chainId": 100,
"env": "localnet",
"id": "xrpl-evm",
"name": "xrpl-evm",
"chainId": 1449000,
"env": "testnet",
"type": "evm",
"symbol": "XRP",
"nativeToken": {
"address": "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517"
"symbol": "XRP",
"decimals": 18,
"name": "XRP",
"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
}
}
}
3 changes: 2 additions & 1 deletion modules/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@testing/mocha": "workspace:*",
"@testing/hardhat": "workspace:*",
"@firewatch/core": "workspace:*",
"@types/chai": "^5.0.1"
"@types/chai": "^5.0.1",
"dotenv": "^16.4.7"
}
}
2 changes: 2 additions & 0 deletions modules/evm/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { ERC20PrecompileConfig } from "../precompiles/erc20/config/config";
import { HardhatModuleConfig } from "@testing/hardhat/config";
import { Chain } from "@firewatch/core/chain";
import { Account } from "@firewatch/core/account";
import { RPCConfig } from "../rpc/config/config";

export interface EVMModuleConfig extends Omit<HardhatModuleConfig<Chain, Account>, "network" | "accounts"> {
erc20: ERC20PrecompileConfig;
rpc: RPCConfig;
}
13 changes: 13 additions & 0 deletions modules/evm/src/rpc/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Block } from "../types/block.types";
import { Transaction } from "../types/transaction.types";

export type RPCConfig = {
rpc: RPCFixtureConfig[];
};

export type RPCFixtureConfig = {
label: string;
block: Block;
transaction: Transaction;
disabledCalls: string[];
};
17 changes: 17 additions & 0 deletions modules/evm/src/rpc/providers/authenticated-jsonrpc-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { JsonRpcProvider, FetchRequest } from "ethers";

/**
* Custom JsonRpcProvider that supports Basic Authentication with username and password.
*/
export class AuthenticatedJsonRpcProvider extends JsonRpcProvider {
constructor(url: string, username?: string, password?: string) {
const fetchRequest = new FetchRequest(url);

// Add Basic Authentication credentials if username and password are provided
if (username && password) {
fetchRequest.setCredentials(username, password);
}

super(fetchRequest);
}
}
4 changes: 4 additions & 0 deletions modules/evm/src/rpc/types/block.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type Block = {
number: number;
hash: string;
};
4 changes: 4 additions & 0 deletions modules/evm/src/rpc/types/transaction.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type Transaction = {
hash: string;
index: number;
};
9 changes: 9 additions & 0 deletions modules/evm/src/rpc/utils/disabled-calls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Checks if a call is disabled by the given disabled calls.
* @param call The call to check.
* @param disabledCalls The disabled calls.
* @returns Whether the call is disabled.
*/
export function isDisabledCall(call: string, disabledCalls: string[]): boolean {
return disabledCalls.includes(call);
}
39 changes: 39 additions & 0 deletions modules/evm/src/rpc/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Gets RPC username from environment variable.
* @param networkName The network name (e.g., 'xrplevm_testnet', 'xrplevm_devnet')
* @returns The username if set, undefined otherwise
*/
export function getRpcUsername(networkName: string): string | undefined {
// Convert network name to uppercase and replace hyphens with underscores
// e.g., 'xrplevm_testnet' -> 'XRPLEVM_TESTNET'
const envKey = `${networkName.toUpperCase().replace(/-/g, "_")}_RPC_USERNAME`;
return process.env[envKey];
}

/**
* Gets RPC password from environment variable.
* @param networkName The network name (e.g., 'xrplevm_testnet', 'xrplevm_devnet')
* @returns The password if set, undefined otherwise
*/
export function getRpcPassword(networkName: string): string | undefined {
// Convert network name to uppercase and replace hyphens with underscores
// e.g., 'xrplevm_testnet' -> 'XRPLEVM_TESTNET'
const envKey = `${networkName.toUpperCase().replace(/-/g, "_")}_RPC_PASSWORD`;
return process.env[envKey];
}

/**
* Gets RPC credentials from environment variables.
* @param networkName The network name (e.g., 'xrplevm_testnet', 'xrplevm_devnet')
* @returns An object with username and password, or undefined if not set
*/
export function getRpcCredentials(networkName: string): { username: string; password: string } | undefined {
const username = getRpcUsername(networkName);
const password = getRpcPassword(networkName);

if (username && password) {
return { username, password };
}

return undefined;
}
Loading