-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
506 additions
and
1,541 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
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,47 +1,45 @@ | ||
import { Contract, Wallet } from 'ethers'; | ||
import { EvmRpcProvider } from '@acala-network/eth-providers'; | ||
import { AcalaJsonRpcProvider } from '@acala-network/eth-providers'; | ||
|
||
import echoJson from './Echo.json'; | ||
|
||
const ECHO_ADDRESS = '0xe8669bfe6fe29dde37d670fbc1cf96365025c242'; | ||
const PRIVATE_KEY = '0x8d2d614677b99ee1809eec0967d538f43d3f410e20ee5f5b979dd21d5930d3fe'; | ||
const ETH_ADDRESS = '0xEE1b6e72FC5bC8738150B6bE7564DA887723cCA1'; | ||
const ECHO_ADDRESS = '0xCDD9460d5d59f059aE17b27ab7C3B45a2C2F1B4d'; | ||
const PRIVATE_KEY = 'a872f6cbd25a0e04a08b1e21098017a9e6194d101d75e13111f71410c59cd57f'; | ||
const ETH_ADDRESS = '0x75E480dB528101a381Ce68544611C169Ad7EB342'; // bound to Alice by chopsticks storage override | ||
|
||
const LOCAL_NODE_URL = 'ws://localhost:8000'; | ||
const MANDALA_NODE_URL = 'wss://mandala-rpc.aca-staging.network/ws'; | ||
const LOCAL_ETH_RPC = 'http://localhost:8545'; | ||
const ACALA_ETH_RPC = 'https://eth-rpc-acala.aca-api.network'; | ||
|
||
const main = async () => { | ||
const providerMandala = new EvmRpcProvider(MANDALA_NODE_URL); | ||
const providerLocal = new EvmRpcProvider(LOCAL_NODE_URL); | ||
const providerAcala = new AcalaJsonRpcProvider(ACALA_ETH_RPC); | ||
const providerLocal = new AcalaJsonRpcProvider(LOCAL_ETH_RPC); | ||
const signerLocal = new Wallet(PRIVATE_KEY, providerLocal); | ||
|
||
const echoMandala = new Contract(ECHO_ADDRESS, echoJson.abi, providerMandala); | ||
const echoAcala = new Contract(ECHO_ADDRESS, echoJson.abi, providerAcala); | ||
const echoLocal = new Contract(ECHO_ADDRESS, echoJson.abi, signerLocal); | ||
|
||
const _printState = async (stateName: string) => { | ||
const msgMandala = await echoMandala.callStatic.echo(); | ||
const msgLcoal = await echoLocal.callStatic.echo(); | ||
const balanceMandala = await providerMandala.getBalance(ETH_ADDRESS); | ||
const msgAcala = await echoAcala.echo(); | ||
const msgLcoal = await echoLocal.echo(); | ||
const balanceAcala = await providerAcala.getBalance(ETH_ADDRESS); | ||
const balanceLocal = await providerLocal.getBalance(ETH_ADDRESS); | ||
|
||
console.log(`------------------------ ${stateName} ------------------------`); | ||
console.log(`msg from public mandala: [${msgMandala}]`); | ||
console.log(`msg from local mandala fork: [${msgLcoal}]`); | ||
console.log(`balance on public mandala: [${balanceMandala.toBigInt()}]`); | ||
console.log(`balance on local mandala fork: [${balanceLocal.toBigInt()}]`); | ||
console.log(`msg from acala: [${msgAcala}]`); | ||
console.log(`msg from local acala fork: [${msgLcoal}]`); | ||
console.log(`balance on acala: [${balanceAcala.toBigInt()}]`); | ||
console.log(`balance on local acala fork: [${balanceLocal.toBigInt()}]`); | ||
console.log(`---------------------------------------------------------------`); | ||
console.log(''); | ||
}; | ||
|
||
await _printState('initial state'); | ||
|
||
console.log('calling scream() on local mandala fork ...'); | ||
console.log('calling scream() on local acala fork ...'); | ||
console.log(''); | ||
await echoLocal.scream('new msg from local mandala'); | ||
await (await echoLocal.scream('new msg from local acala')).wait(); | ||
|
||
await _printState('after calling scream()'); | ||
|
||
providerMandala.disconnect(); | ||
providerLocal.disconnect(); | ||
}; | ||
|
||
main(); |
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
Oops, something went wrong.