Skip to content

Commit

Permalink
Merge pull request #23 from orochi-network/feature/sei_testnet
Browse files Browse the repository at this point in the history
Feature/sei testnet
  • Loading branch information
dqtkien authored Mar 30, 2024
2 parents a169ba3 + b9ad251 commit 4a8f5d1
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 26 deletions.
File renamed without changes.
20 changes: 20 additions & 0 deletions backup-tasks/oroclev1-test-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-disable no-await-in-loop */
import '@nomicfoundation/hardhat-ethers';
import { task } from 'hardhat/config';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { HDNodeWallet, Wallet } from 'ethers';
import { env } from '../env';

task('wipe', 'Wipe token').setAction(async (_taskArgs: any, hre: HardhatRuntimeEnvironment) => {
let wallet = Wallet.fromPhrase(env.OROCHI_MNEMONIC).connect(hre.ethers.provider);
// m/44'/60'/0'/0/0/0 0xA0AA39fAAaCcB5927A4Ffed9fff2B8f0f73CE561
console.log(wallet.address);
let wallet2 = HDNodeWallet.fromPhrase(env.OROCHI_MNEMONIC, undefined, `m/44'/60'/0'/0`)
.deriveChild(0)
.connect(hre.ethers.provider);
console.log((await wallet.deriveChild(0)).address);
console.log('Wa', wallet2.address);
// await wallet.sendTransaction({ to: '0xA2096671D4A0939D4D50bd7AAB612883e98B4D47', value: parseEther('4.9959') });
});

export default {};
4 changes: 4 additions & 0 deletions env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export interface IEnvironment {
OROCHI_RPC: string;
OROCHI_FORK: boolean;
OROCHI_PUBLIC_KEY: string;
OROCHI_OWNER: string;
OROCHI_OPERATOR: string;
}

function clean(config: any): any {
Expand All @@ -29,6 +31,8 @@ export const env: IEnvironment = fs.existsSync(`${__dirname}/.env`)
OROCHI_FORK: false,
OROCHI_MNEMONIC: 'baby nose young alone sport inside grain rather undo donor void exotic',
OROCHI_RPC: 'http://localhost:8545',
OROCHI_OWNER: '0xA2096671D4A0939D4D50bd7AAB612883e98B4D47',
OROCHI_OPERATOR: '0x4d8Ebc5601683C5b50dADA3066940e234146C07E,0xc4fFb047C1C6600FC82c68376C502bAa72ea2074',
OROCHI_PUBLIC_KEY:
'0446b01e9550b56f3655dbca90cfe6b31dec3ff137f825561c563444096803531e9d4f6e8329d300483a919b63843174f1fca692fc6d2c07b985f72386e4edc846',
};
10 changes: 10 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ const config: HardhatUserConfig = {
chainId: 28122024,
accounts: { mnemonic: env.OROCHI_MNEMONIC },
},
seitest: {
url: 'https://evm-rpc-arctic-1.sei-apis.com',
chainId: 713715,
accounts: { mnemonic: env.OROCHI_MNEMONIC },
},
u2umain: {
url: 'https://rpc-mainnet.uniultra.xyz',
chainId: 39,
accounts: { mnemonic: env.OROCHI_MNEMONIC },
},
ethereum: {
url: 'https://eth-mainnet.public.blastapi.io',
chainId: 1,
Expand Down
35 changes: 35 additions & 0 deletions lazy-wallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import fs from 'fs';
import { ethers } from 'ethers';

(async () => {
const wallet = ethers.Wallet.createRandom();
const dataTable = [];

for (let i = 0; i < 5; i += 1) {
const newWallet = wallet.deriveChild(i);
dataTable.push({
path: newWallet.path,
address: await newWallet.getAddress(),
});
}
for (let i = 100; i < 105; i += 1) {
const newWallet = wallet.deriveChild(i);
dataTable.push({
path: newWallet.path,
address: await newWallet.getAddress(),
});
}
const walletList = dataTable.map(({ path, address }) => {
return `# ${path}\t${address}`;
});
const fileContent = fs.existsSync('.env') ? fs.readFileSync('.env', 'utf-8') : '';
if (fileContent.indexOf('OROCHI_MNEMONIC') === -1) {
fs.writeFileSync(
'.env',
`${fileContent}\n${walletList.join('\n')}\nOROCHI_MNEMONIC="${wallet.mnemonic?.phrase.trim()}"`,
);
console.table(dataTable);
} else {
console.log('Wallets existed');
}
})();
1 change: 1 addition & 0 deletions tasks/deploy-multicast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Multicast } from '../typechain-types';
task('deploy:multicast', 'Deploy Multicast contracts').setAction(
async (_taskArgs: any, hre: HardhatRuntimeEnvironment) => {
const accounts = await hre.ethers.getSigners();
//0x3ECb21f2c6A5a57C57634036777730bb6E87F281
const deployer: Deployer = Deployer.getInstance(hre).connect(accounts[0]);
await deployer.contractDeploy<Multicast>('orochi/Multicast', []);
await deployer.printReport();
Expand Down
41 changes: 35 additions & 6 deletions tasks/deploy-orochi-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import '@nomicfoundation/hardhat-ethers';
import { task } from 'hardhat/config';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { Deployer } from '../helpers';
import { DiceGame, OrocleV1, OrandECVRFV2, OrandProviderV2 } from '../typechain-types';
import { OrocleV1, OrandECVRFV2, OrandProviderV2 } from '../typechain-types';
import { env } from '../env';
import { getAddress, keccak256 } from 'ethers';
import { getAddress, isAddress, keccak256 } from 'ethers';

const affineToNumberish = (affine: string): [string, string] => {
const aff = affine.trim().replace(/^0x/gi, '').padStart(128, '0');
Expand All @@ -27,19 +27,35 @@ function stringToBytes(input: string, length: number) {
.padEnd(length * 2, '0');
}

const TESTNET_OPERATOR = ['0xc4fFb047C1C6600FC82c68376C502bAa72ea2074', '0x4d8Ebc5601683C5b50dADA3066940e234146C07E'];
const OWNER = env.OROCHI_OWNER.trim();
const OPERATORS = env.OROCHI_OPERATOR.split(',').map((op) => op.trim());

task('deploy:orochi', 'Deploy Orochi Network contracts').setAction(
async (_taskArgs: any, hre: HardhatRuntimeEnvironment) => {
let pk = env.OROCHI_PUBLIC_KEY.replace(/^0x/gi, '').trim();
let correspondingAddress = getAddress(`0x${keccak256(`0x${pk.substring(2, 130)}`).substring(26, 66)}`);
if (!isAddress(OWNER)) {
throw new Error('Invalid owner address');
}
for (let i = 0; i < OPERATORS.length; i += 1) {
if (!isAddress(OPERATORS[i])) {
throw new Error(`Invalid operator address ${i}: ${OPERATORS[i]}`);
}
console.log(`Operator [${i}]:`, OPERATORS[i]);
}
console.log('Owner:', OWNER);

//m/44'/60'/0'/0/0
//m/44'/60'/0'/0/0/0

// Setup deployer
const accounts = await hre.ethers.getSigners();
console.log('Deployer:', accounts[0].address);
const deployer: Deployer = Deployer.getInstance(hre).connect(accounts[0]);
// Deploy ECVRF
const orandECVRF = await deployer.contractDeploy<OrandECVRFV2>('OrandV2/OrandECVRFV2', []);
// Deploy Orocle
const OrocleV1 = await deployer.contractDeploy<OrocleV1>('OrocleV1/OrocleV1', [], TESTNET_OPERATOR);
const orocleV1 = await deployer.contractDeploy<OrocleV1>('OrocleV1/OrocleV1', [], OPERATORS);

/*
constructor(
Expand All @@ -58,16 +74,29 @@ task('deploy:orochi', 'Deploy Orochi Network contracts').setAction(
publicKeyToNumberish(pk),
correspondingAddress,
orandECVRF,
OrocleV1,
orocleV1,
200,
);
await deployer.contractDeploy<DiceGame>('examples/DiceGame', [], orandProviderV2);

await orocleV1.transferOwnership(OWNER);
await orandProviderV2.transferOwnership(OWNER);

console.log(
`Corresponding address: ${correspondingAddress} , is valid publicKey?:`,
correspondingAddress === (await orandProviderV2.getOperator()),
);

console.log('Is Oracle deployed correct?', (await orocleV1.getAddress()) === (await orandProviderV2.getOracle()));
console.log(
'Is ECVRF verifier deployed correct?',
(await orandECVRF.getAddress()) === (await orandProviderV2.getECVRFVerifier()),
);
console.log('Is orand service operator correct?', correspondingAddress === (await orandProviderV2.getOperator()));
console.log('Is OrocleV1 operator correct?', await orocleV1.isOperator(OPERATORS[0]));
console.log('Is OrocleV1 operator correct?', await orocleV1.isOperator(OPERATORS[1]));
console.log('Is OrocleV1 owner correct?', OWNER === (await orocleV1.owner()));
console.log('Is OrandProviderV2 owner correct?', OWNER === (await orandProviderV2.owner()));

await deployer.printReport();
},
);
Expand Down
20 changes: 0 additions & 20 deletions tasks/oroclev1-test-request.ts

This file was deleted.

0 comments on commit 4a8f5d1

Please sign in to comment.