Skip to content

Commit

Permalink
Merge pull request #15 from lidofinance/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
avsetsin authored Oct 12, 2023
2 parents 72585e6 + db7005e commit 47a0b13
Show file tree
Hide file tree
Showing 48 changed files with 431 additions and 313 deletions.
1 change: 1 addition & 0 deletions abi/MiniMeToken.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"creationBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_blockNumber","type":"uint256"}],"name":"balanceOfAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_cloneTokenName","type":"string"},{"name":"_cloneDecimalUnits","type":"uint8"},{"name":"_cloneTokenSymbol","type":"string"},{"name":"_snapshotBlock","type":"uint256"},{"name":"_transfersEnabled","type":"bool"}],"name":"createCloneToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"parentToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"generateTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_blockNumber","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"transfersEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"parentSnapShotBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"destroyTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tokenFactory","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_transfersEnabled","type":"bool"}],"name":"enableTransfers","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_tokenFactory","type":"address"},{"name":"_parentToken","type":"address"},{"name":"_parentSnapShotBlock","type":"uint256"},{"name":"_tokenName","type":"string"},{"name":"_decimalUnits","type":"uint8"},{"name":"_tokenSymbol","type":"string"},{"name":"_transfersEnabled","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_token","type":"address"},{"indexed":true,"name":"_controller","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_cloneToken","type":"address"},{"indexed":false,"name":"_snapshotBlock","type":"uint256"}],"name":"NewCloneToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Approval","type":"event"}]
1 change: 1 addition & 0 deletions contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './burner';
export * from './deposit-contract';
export * from './dsm';
export * from './ens';
export * from './ldo';
export * from './lido';
export * from './locator';
export * from './nor';
Expand Down
7 changes: 7 additions & 0 deletions contracts/ldo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Contract } from 'ethers';
import { wallet } from '@providers';
import { getDeployedAddress } from '@configs';
import abi from 'abi/MiniMeToken.json';

export const ldoAddress = getDeployedAddress('ldo');
export const ldoContract = new Contract(ldoAddress, abi, wallet);
7 changes: 4 additions & 3 deletions programs/accounting-oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
addOssifiableProxyCommands,
addParsingCommands,
} from './common';
import { logger } from '@utils';

const oracle = program.command('accounting-oracle').description('interact with accounting oracle contract');
addAccessControlSubCommands(oracle, accountingOracleContract);
Expand All @@ -20,21 +21,21 @@ oracle
.description('returns extra data format')
.action(async () => {
const format = await accountingOracleContract.EXTRA_DATA_FORMAT_LIST();
console.log('extra data format', format);
logger.log('Extra data format', format);
});

oracle
.command('extra-data-type-stuck')
.description('returns extra type for stuck validators')
.action(async () => {
const format = await accountingOracleContract.EXTRA_DATA_TYPE_STUCK_VALIDATORS();
console.log('type stuck', format);
logger.log('Type stuck', format);
});

oracle
.command('extra-data-type-exited')
.description('returns extra type for exited validators')
.action(async () => {
const format = await accountingOracleContract.EXTRA_DATA_TYPE_EXITED_VALIDATORS();
console.log('type exited', format);
logger.log('Type exited', format);
});
10 changes: 5 additions & 5 deletions programs/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { program } from '@command';
import { wallet } from '@providers';
import { join } from 'path';
import { Wallet } from 'ethers';
import { writeToFile } from '@utils';
import { logger, writeToFile } from '@utils';

const accounts = program.command('accounts').description('accounts utils');

Expand All @@ -12,17 +12,17 @@ accounts
.action(async () => {
const wallet = Wallet.createRandom();

console.table({
address: wallet.address,
'private key': wallet.privateKey,
logger.table({
Address: wallet.address,
'Private key': wallet.privateKey,
});
});

accounts
.command('address')
.description('returns address from private key')
.action(async () => {
console.log(wallet.address);
logger.log('Address', wallet.address);
});

accounts
Expand Down
10 changes: 5 additions & 5 deletions programs/common/access-control.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from 'commander';
import { Contract } from 'ethers';
import { authorizedCall, getRoleHash } from '@utils';
import { authorizedCall, getRoleHash, logger } from '@utils';
import { wallet } from '@providers';

export const addAccessControlSubCommands = (command: Command, contract: Contract) => {
Expand All @@ -10,7 +10,7 @@ export const addAccessControlSubCommands = (command: Command, contract: Contract
.argument('<role>', 'role name')
.action(async (role) => {
const roleHash = await getRoleHash(contract, role);
console.log('role hash', roleHash);
logger.log('Role hash', roleHash);
});

command
Expand All @@ -20,7 +20,7 @@ export const addAccessControlSubCommands = (command: Command, contract: Contract
.action(async (role) => {
const roleHash = await getRoleHash(contract, role);
const roleAdmin = await contract.getRoleAdmin(roleHash);
console.log('role admin', roleAdmin);
logger.log('Role admin', roleAdmin);
});

command
Expand All @@ -33,7 +33,7 @@ export const addAccessControlSubCommands = (command: Command, contract: Contract

for (let i = 0; i < count; i++) {
const count = await contract.getRoleMember(roleHash, i);
console.log(`role member at ${i}`, count);
logger.log(`Role member at ${i}`, count);
}
});

Expand All @@ -46,7 +46,7 @@ export const addAccessControlSubCommands = (command: Command, contract: Contract
const { address } = options;
const roleHash = await getRoleHash(contract, role);
const result = await contract.hasRole(roleHash, address);
console.log('can perform', result);
logger.log('Can perform', result);
});

command
Expand Down
16 changes: 8 additions & 8 deletions programs/common/aragon-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getPublicResolverContract,
getRepoContract,
} from '@contracts';
import { authorizedCall, forwardVoteFromTm, getRoleHash } from '@utils';
import { authorizedCall, forwardVoteFromTm, getRoleHash, logger } from '@utils';
import { wallet } from '@providers';
import { updateAragonApp, votingForward } from '@scripts';

Expand All @@ -23,7 +23,7 @@ export const addAragonAppSubCommands = (command: Command, contract: Contract) =>
.argument('<role>', 'role name')
.action(async (role) => {
const roleHash = await getRoleHash(contract, role);
console.log('role hash', roleHash);
logger.log('Role hash', roleHash);
});

command
Expand All @@ -35,7 +35,7 @@ export const addAragonAppSubCommands = (command: Command, contract: Contract) =>
const { address } = options;
const roleHash = await getRoleHash(contract, role);
const result = await contract.canPerform(address, roleHash, []);
console.log('can perform', result);
logger.log('Can perform', result);
});

command
Expand All @@ -49,7 +49,7 @@ export const addAragonAppSubCommands = (command: Command, contract: Contract) =>
const appAddress = await contract.getAddress();

const result = await kernelContract.hasPermission(address, appAddress, roleHash, '0x');
console.log('has permission', result);
logger.log('Has permission', result);
});

command
Expand All @@ -63,7 +63,7 @@ export const addAragonAppSubCommands = (command: Command, contract: Contract) =>
const appAddress = await contract.getAddress();

const result = await aclContract.hasPermission(address, appAddress, roleHash);
console.log('has permission', result);
logger.log('Has permission', result);
});

command
Expand All @@ -75,7 +75,7 @@ export const addAragonAppSubCommands = (command: Command, contract: Contract) =>
const appAddress = await contract.getAddress();

const manager = await aclContract.getPermissionManager(appAddress, roleHash);
console.log('manager', manager);
logger.log('Manager', manager);
});

command
Expand Down Expand Up @@ -123,7 +123,7 @@ export const addAragonAppSubCommands = (command: Command, contract: Contract) =>
.description('returns proxy implementation address')
.action(async () => {
const implementation = await proxyContract.implementation();
console.log('implementation', implementation);
logger.log('Implementation', implementation);
});

command
Expand All @@ -139,7 +139,7 @@ export const addAragonAppSubCommands = (command: Command, contract: Contract) =>
const repoContract = getRepoContract(getRepoAddress);

const version = await repoContract.getLatest();
console.log('version', version.toObject());
logger.log('Version', version.toObject());
});

command
Expand Down
16 changes: 8 additions & 8 deletions programs/common/base-oracle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { authorizedCall } from '@utils';
import { authorizedCall, logger } from '@utils';
import { Command } from 'commander';
import { Contract } from 'ethers';

Expand All @@ -8,7 +8,7 @@ export const addBaseOracleCommands = (command: Command, contract: Contract) => {
.description('returns genesis time')
.action(async () => {
const genesisTime = await contract.GENESIS_TIME();
console.log('genesis time', genesisTime);
logger.log('Genesis time', genesisTime);
});

command
Expand All @@ -21,23 +21,23 @@ export const addBaseOracleCommands = (command: Command, contract: Contract) => {

command.command('processing-state').action(async () => {
const result = await contract.getProcessingState();
console.log('result', result.toObject());
logger.log('Result', result.toObject());
});

command
.command('seconds-per-slot')
.description('returns seconds per slot')
.action(async () => {
const secondsPerSlot = await contract.SECONDS_PER_SLOT();
console.log('seconds per slots', secondsPerSlot);
logger.log('Seconds per slots', secondsPerSlot);
});

command
.command('consensus-version')
.description('returns consensus version')
.action(async () => {
const version = await contract.getConsensusVersion();
console.log('version', version);
logger.log('Version', version);
});

command
Expand All @@ -53,22 +53,22 @@ export const addBaseOracleCommands = (command: Command, contract: Contract) => {
.description('returns consensus contract')
.action(async () => {
const consensusContract = await contract.getConsensusContract();
console.log('consensus contract', consensusContract);
logger.log('Consensus contract', consensusContract);
});

command
.command('consensus-report')
.description('returns consensus report')
.action(async () => {
const consensusReport = await contract.getConsensusReport();
console.log('consensus report', consensusReport);
logger.log('Consensus report', consensusReport);
});

command
.command('last-processing-ref-slot')
.description('returns last processing ref slot')
.action(async () => {
const refSlot = await contract.getLastProcessingRefSlot();
console.log('last processing ref slot', refSlot);
logger.log('Last processing ref slot', refSlot);
});
};
36 changes: 18 additions & 18 deletions programs/common/consensus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { authorizedCall, getLatestBlock, getProvider } from '@utils';
import { authorizedCall, getLatestBlock, getProvider, logger } from '@utils';
import { Command } from 'commander';
import { Contract, EventLog, formatEther } from 'ethers';

Expand All @@ -24,15 +24,15 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
}),
);

console.table(table.sort((a, b) => b.lastReportedSlot - a.lastReportedSlot));
logger.table(table.sort((a, b) => b.lastReportedSlot - a.lastReportedSlot));
});

command
.command('quorum')
.description('returns the quorum number')
.action(async () => {
const quorum = await contract.getQuorum();
console.log('quorum', Number(quorum));
logger.log('Quorum', Number(quorum));
});

command
Expand All @@ -50,7 +50,7 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
.action(async (options) => {
const { address } = options;
const state = await contract.getConsensusStateForMember(address);
console.log('state', state.toObject());
logger.log('State', state.toObject());
});

command
Expand Down Expand Up @@ -78,23 +78,23 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
.description('returns the current frame')
.action(async () => {
const frame = await contract.getCurrentFrame();
console.log('frame', frame.toObject());
logger.log('Frame', frame.toObject());
});

command
.command('chain-config')
.description('returns the chain config')
.action(async () => {
const config = await contract.getChainConfig();
console.log('config', config.toObject());
logger.log('Config', config.toObject());
});

command
.command('frame-config')
.description('returns the frame config')
.action(async () => {
const config = await contract.getFrameConfig();
console.log('config', config.toObject());
logger.log('Config', config.toObject());
});

command
Expand All @@ -121,7 +121,7 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
.argument('<address>', 'member address')
.action(async (address) => {
const state = await contract.getConsensusStateForMember(address);
console.log('member state', state);
logger.log('Member state', state);
});

command
Expand Down Expand Up @@ -195,22 +195,22 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
];
};

console.log('current slot');
console.table([
logger.log('Current slot');
logger.table([
{
value: 'current slot',
slot: currentSlot,
time: slotToTime(currentSlot),
},
]);

console.log();
console.log('current report frame');
console.table(getFrameSlots(currentFrame));
logger.log();
logger.log('Current report frame');
logger.table(getFrameSlots(currentFrame));

console.log();
console.log('next report frame');
console.table(getFrameSlots(nextFrame));
logger.log();
logger.log('Next report frame');
logger.table(getFrameSlots(nextFrame));
});

command
Expand Down Expand Up @@ -241,7 +241,7 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
const groupedByRefSlot = events.reduce(
(acc, event) => {
if (!(event instanceof EventLog)) {
console.warn('log is not parsed');
logger.warn('Log is not parsed');
return acc;
}

Expand All @@ -258,6 +258,6 @@ export const addConsensusCommands = (command: Command, contract: Contract) => {
{} as Record<number, Record<string, string>>,
);

console.table(groupedByRefSlot);
logger.table(groupedByRefSlot);
});
};
Loading

0 comments on commit 47a0b13

Please sign in to comment.