Support both V1 & V2 DataChanged events in registry (#4734)
* Add info on forks. * Add new registry ABI * Import registry2 & fix exports * Select ABI based on code hash * Render new event types (owner not available) * New registry. * Rename old chain. * Fix test. * Another fix. * Finish rename.
This commit is contained in:
parent
3a0c4b6539
commit
495e5790e9
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "Frontier/Homestead",
|
"name": "Foundation",
|
||||||
"dataDir": "ethereum",
|
"dataDir": "ethereum",
|
||||||
"engine": {
|
"engine": {
|
||||||
"Ethash": {
|
"Ethash": {
|
||||||
@ -9,7 +9,7 @@
|
|||||||
"difficultyBoundDivisor": "0x0800",
|
"difficultyBoundDivisor": "0x0800",
|
||||||
"durationLimit": "0x0d",
|
"durationLimit": "0x0d",
|
||||||
"blockReward": "0x4563918244F40000",
|
"blockReward": "0x4563918244F40000",
|
||||||
"registrar" : "0x3bb2bb5c6c9c9b7f4ef430b47dc7e026310042ea",
|
"registrar" : "0xe3389675d0338462dC76C6f9A3e432550c36A142",
|
||||||
"homesteadTransition": "0x118c30",
|
"homesteadTransition": "0x118c30",
|
||||||
"daoHardforkTransition": "0x1d4c00",
|
"daoHardforkTransition": "0x1d4c00",
|
||||||
"daoHardforkBeneficiary": "0xbf4ed7b27f1d666546e30d74d50d173d20bca754",
|
"daoHardforkBeneficiary": "0xbf4ed7b27f1d666546e30d74d50d173d20bca754",
|
@ -30,7 +30,7 @@ pub use self::denominations::*;
|
|||||||
use super::spec::*;
|
use super::spec::*;
|
||||||
|
|
||||||
/// Most recent fork block that we support on Mainnet.
|
/// Most recent fork block that we support on Mainnet.
|
||||||
pub const FORK_SUPPORTED_FRONTIER: u64 = 2675000;
|
pub const FORK_SUPPORTED_FOUNDATION: u64 = 2675000;
|
||||||
|
|
||||||
/// Most recent fork block that we support on Ropsten.
|
/// Most recent fork block that we support on Ropsten.
|
||||||
pub const FORK_SUPPORTED_ROPSTEN: u64 = 10;
|
pub const FORK_SUPPORTED_ROPSTEN: u64 = 10;
|
||||||
@ -46,7 +46,7 @@ fn load(b: &[u8]) -> Spec {
|
|||||||
pub fn new_olympic() -> Spec { load(include_bytes!("../../res/ethereum/olympic.json")) }
|
pub fn new_olympic() -> Spec { load(include_bytes!("../../res/ethereum/olympic.json")) }
|
||||||
|
|
||||||
/// Create a new Frontier mainnet chain spec.
|
/// Create a new Frontier mainnet chain spec.
|
||||||
pub fn new_frontier() -> Spec { load(include_bytes!("../../res/ethereum/frontier.json")) }
|
pub fn new_foundation() -> Spec { load(include_bytes!("../../res/ethereum/foundation.json")) }
|
||||||
|
|
||||||
/// Create a new Frontier mainnet chain spec without the DAO hardfork.
|
/// Create a new Frontier mainnet chain spec without the DAO hardfork.
|
||||||
pub fn new_classic() -> Spec { load(include_bytes!("../../res/ethereum/classic.json")) }
|
pub fn new_classic() -> Spec { load(include_bytes!("../../res/ethereum/classic.json")) }
|
||||||
@ -118,7 +118,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn frontier() {
|
fn frontier() {
|
||||||
let frontier = new_frontier();
|
let frontier = new_foundation();
|
||||||
|
|
||||||
assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into());
|
assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into());
|
||||||
let genesis = frontier.genesis_block();
|
let genesis = frontier.genesis_block();
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
//! use ethcore::miner::{Miner, MinerService};
|
//! use ethcore::miner::{Miner, MinerService};
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! let miner: Miner = Miner::with_spec(ðereum::new_frontier());
|
//! let miner: Miner = Miner::with_spec(ðereum::new_foundation());
|
||||||
//! // get status
|
//! // get status
|
||||||
//! assert_eq!(miner.status().transactions_in_pending_queue, 0);
|
//! assert_eq!(miner.status().transactions_in_pending_queue, 0);
|
||||||
//!
|
//!
|
||||||
|
@ -14,34 +14,18 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import badgereg from './badgereg.json';
|
export badgereg from './badgereg.json';
|
||||||
import basiccoin from './basiccoin.json';
|
export basiccoin from './basiccoin.json';
|
||||||
import basiccoinmanager from './basiccoinmanager.json';
|
export basiccoinmanager from './basiccoinmanager.json';
|
||||||
import dappreg from './dappreg.json';
|
export dappreg from './dappreg.json';
|
||||||
import eip20 from './eip20.json';
|
export eip20 from './eip20.json';
|
||||||
import emailverification from './email-verification.json';
|
export emailverification from './email-verification.json';
|
||||||
import gavcoin from './gavcoin.json';
|
export gavcoin from './gavcoin.json';
|
||||||
import githubhint from './githubhint.json';
|
export githubhint from './githubhint.json';
|
||||||
import owned from './owned.json';
|
export owned from './owned.json';
|
||||||
import registry from './registry.json';
|
export registry from './registry.json';
|
||||||
import signaturereg from './signaturereg.json';
|
export registry2 from './registry2.json';
|
||||||
import smsverification from './sms-verification.json';
|
export signaturereg from './signaturereg.json';
|
||||||
import tokenreg from './tokenreg.json';
|
export smsverification from './sms-verification.json';
|
||||||
import wallet from './wallet.json';
|
export tokenreg from './tokenreg.json';
|
||||||
|
export wallet from './wallet.json';
|
||||||
export {
|
|
||||||
badgereg,
|
|
||||||
basiccoin,
|
|
||||||
basiccoinmanager,
|
|
||||||
dappreg,
|
|
||||||
eip20,
|
|
||||||
emailverification,
|
|
||||||
gavcoin,
|
|
||||||
githubhint,
|
|
||||||
owned,
|
|
||||||
registry,
|
|
||||||
signaturereg,
|
|
||||||
smsverification,
|
|
||||||
tokenreg,
|
|
||||||
wallet
|
|
||||||
};
|
|
||||||
|
1
js/src/contracts/abi/registry2.json
Normal file
1
js/src/contracts/abi/registry2.json
Normal file
File diff suppressed because one or more lines are too long
@ -53,7 +53,13 @@ const renderEvent = (classNames, verb) => (e) => {
|
|||||||
return (
|
return (
|
||||||
<tr key={ e.key } className={ classes }>
|
<tr key={ e.key } className={ classes }>
|
||||||
<td>
|
<td>
|
||||||
<Address address={ e.parameters.owner.value } />
|
<Address
|
||||||
|
address={
|
||||||
|
e.parameters.owner
|
||||||
|
? e.parameters.owner.value
|
||||||
|
: e.from
|
||||||
|
}
|
||||||
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<abbr title={ e.transaction }>{ verb }</abbr>
|
<abbr title={ e.transaction }>{ verb }</abbr>
|
||||||
@ -80,17 +86,23 @@ const renderDataChanged = (e) => {
|
|||||||
return (
|
return (
|
||||||
<tr key={ e.key } className={ classNames }>
|
<tr key={ e.key } className={ classNames }>
|
||||||
<td>
|
<td>
|
||||||
<Address address={ e.parameters.owner.value } />
|
<Address
|
||||||
|
address={
|
||||||
|
e.parameters.owner
|
||||||
|
? e.parameters.owner.value
|
||||||
|
: e.from
|
||||||
|
}
|
||||||
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<abbr title={ e.transaction }>updated</abbr>
|
<abbr title={ e.transaction }>updated</abbr>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{ 'key ' }
|
key
|
||||||
<code>
|
<code>
|
||||||
{ new Buffer(e.parameters.plainKey.value).toString('utf8') }
|
{ new Buffer(e.parameters.plainKey.value).toString('utf8') }
|
||||||
</code>
|
</code>
|
||||||
{ 'of ' }
|
of
|
||||||
<code>
|
<code>
|
||||||
<Hash hash={ bytesToHex(e.parameters.name.value) } />
|
<Hash hash={ bytesToHex(e.parameters.name.value) } />
|
||||||
</code>
|
</code>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import { registry as registryAbi } from '~/contracts/abi';
|
import { registry as registryAbi, registry2 as registryAbi2 } from '~/contracts/abi';
|
||||||
|
|
||||||
import { api } from './parity.js';
|
import { api } from './parity.js';
|
||||||
import * as addresses from './addresses/actions.js';
|
import * as addresses from './addresses/actions.js';
|
||||||
@ -27,6 +27,11 @@ import * as reverse from './Reverse/actions.js';
|
|||||||
|
|
||||||
export { addresses, accounts, lookup, events, names, records, reverse };
|
export { addresses, accounts, lookup, events, names, records, reverse };
|
||||||
|
|
||||||
|
const REGISTRY_V1_HASHES = [
|
||||||
|
'0x34f7c51bbb1b1902fbdabfdf04811100f5c9f998f26dd535d2f6f977492c748e', // ropsten
|
||||||
|
'0x64c3ee34851517a9faecd995c102b339f03e564ad6772dc43a26f993238b20ec' // homestead
|
||||||
|
];
|
||||||
|
|
||||||
export const setIsTestnet = (isTestnet) => ({ type: 'set isTestnet', isTestnet });
|
export const setIsTestnet = (isTestnet) => ({ type: 'set isTestnet', isTestnet });
|
||||||
|
|
||||||
export const fetchIsTestnet = () => (dispatch) =>
|
export const fetchIsTestnet = () => (dispatch) =>
|
||||||
@ -47,13 +52,28 @@ export const fetchIsTestnet = () => (dispatch) =>
|
|||||||
export const setContract = (contract) => ({ type: 'set contract', contract });
|
export const setContract = (contract) => ({ type: 'set contract', contract });
|
||||||
|
|
||||||
export const fetchContract = () => (dispatch) =>
|
export const fetchContract = () => (dispatch) =>
|
||||||
api.parity.registryAddress()
|
api.parity
|
||||||
|
.registryAddress()
|
||||||
.then((address) => {
|
.then((address) => {
|
||||||
const contract = api.newContract(registryAbi, address);
|
return api.eth
|
||||||
|
.getCode(address)
|
||||||
|
.then((code) => {
|
||||||
|
const codeHash = api.util.sha3(code);
|
||||||
|
const isVersion1 = REGISTRY_V1_HASHES.includes(codeHash);
|
||||||
|
|
||||||
|
console.log(`registry at ${address}, code ${codeHash}, version ${isVersion1 ? 1 : 2}`);
|
||||||
|
|
||||||
|
const contract = api.newContract(
|
||||||
|
isVersion1
|
||||||
|
? registryAbi
|
||||||
|
: registryAbi2,
|
||||||
|
address
|
||||||
|
);
|
||||||
|
|
||||||
dispatch(setContract(contract));
|
dispatch(setContract(contract));
|
||||||
dispatch(fetchFee());
|
dispatch(fetchFee());
|
||||||
dispatch(fetchOwner());
|
dispatch(fetchOwner());
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error('could not fetch contract');
|
console.error('could not fetch contract');
|
||||||
|
@ -26,7 +26,7 @@ use user_defaults::UserDefaults;
|
|||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum SpecType {
|
pub enum SpecType {
|
||||||
Mainnet,
|
Foundation,
|
||||||
Morden,
|
Morden,
|
||||||
Ropsten,
|
Ropsten,
|
||||||
Kovan,
|
Kovan,
|
||||||
@ -39,7 +39,7 @@ pub enum SpecType {
|
|||||||
|
|
||||||
impl Default for SpecType {
|
impl Default for SpecType {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
SpecType::Mainnet
|
SpecType::Foundation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ impl str::FromStr for SpecType {
|
|||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let spec = match s {
|
let spec = match s {
|
||||||
"frontier" | "homestead" | "mainnet" => SpecType::Mainnet,
|
"foundation" | "frontier" | "homestead" | "mainnet" => SpecType::Foundation,
|
||||||
"frontier-dogmatic" | "homestead-dogmatic" | "classic" => SpecType::Classic,
|
"frontier-dogmatic" | "homestead-dogmatic" | "classic" => SpecType::Classic,
|
||||||
"morden" | "classic-testnet" => SpecType::Morden,
|
"morden" | "classic-testnet" => SpecType::Morden,
|
||||||
"ropsten" => SpecType::Ropsten,
|
"ropsten" => SpecType::Ropsten,
|
||||||
@ -65,7 +65,7 @@ impl str::FromStr for SpecType {
|
|||||||
impl fmt::Display for SpecType {
|
impl fmt::Display for SpecType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
f.write_str(match *self {
|
f.write_str(match *self {
|
||||||
SpecType::Mainnet => "homestead",
|
SpecType::Foundation => "foundation",
|
||||||
SpecType::Morden => "morden",
|
SpecType::Morden => "morden",
|
||||||
SpecType::Ropsten => "ropsten",
|
SpecType::Ropsten => "ropsten",
|
||||||
SpecType::Olympic => "olympic",
|
SpecType::Olympic => "olympic",
|
||||||
@ -81,7 +81,7 @@ impl fmt::Display for SpecType {
|
|||||||
impl SpecType {
|
impl SpecType {
|
||||||
pub fn spec(&self) -> Result<Spec, String> {
|
pub fn spec(&self) -> Result<Spec, String> {
|
||||||
match *self {
|
match *self {
|
||||||
SpecType::Mainnet => Ok(ethereum::new_frontier()),
|
SpecType::Foundation => Ok(ethereum::new_foundation()),
|
||||||
SpecType::Morden => Ok(ethereum::new_morden()),
|
SpecType::Morden => Ok(ethereum::new_morden()),
|
||||||
SpecType::Ropsten => Ok(ethereum::new_ropsten()),
|
SpecType::Ropsten => Ok(ethereum::new_ropsten()),
|
||||||
SpecType::Olympic => Ok(ethereum::new_olympic()),
|
SpecType::Olympic => Ok(ethereum::new_olympic()),
|
||||||
@ -321,9 +321,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_spec_type_parsing() {
|
fn test_spec_type_parsing() {
|
||||||
assert_eq!(SpecType::Mainnet, "frontier".parse().unwrap());
|
assert_eq!(SpecType::Foundation, "frontier".parse().unwrap());
|
||||||
assert_eq!(SpecType::Mainnet, "homestead".parse().unwrap());
|
assert_eq!(SpecType::Foundation, "homestead".parse().unwrap());
|
||||||
assert_eq!(SpecType::Mainnet, "mainnet".parse().unwrap());
|
assert_eq!(SpecType::Foundation, "mainnet".parse().unwrap());
|
||||||
|
assert_eq!(SpecType::Foundation, "foundation".parse().unwrap());
|
||||||
assert_eq!(SpecType::Kovan, "testnet".parse().unwrap());
|
assert_eq!(SpecType::Kovan, "testnet".parse().unwrap());
|
||||||
assert_eq!(SpecType::Kovan, "kovan".parse().unwrap());
|
assert_eq!(SpecType::Kovan, "kovan".parse().unwrap());
|
||||||
assert_eq!(SpecType::Morden, "morden".parse().unwrap());
|
assert_eq!(SpecType::Morden, "morden".parse().unwrap());
|
||||||
@ -335,12 +336,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_spec_type_default() {
|
fn test_spec_type_default() {
|
||||||
assert_eq!(SpecType::Mainnet, SpecType::default());
|
assert_eq!(SpecType::Foundation, SpecType::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_spec_type_display() {
|
fn test_spec_type_display() {
|
||||||
assert_eq!(format!("{}", SpecType::Mainnet), "homestead");
|
assert_eq!(format!("{}", SpecType::Foundation), "foundation");
|
||||||
assert_eq!(format!("{}", SpecType::Ropsten), "ropsten");
|
assert_eq!(format!("{}", SpecType::Ropsten), "ropsten");
|
||||||
assert_eq!(format!("{}", SpecType::Morden), "morden");
|
assert_eq!(format!("{}", SpecType::Morden), "morden");
|
||||||
assert_eq!(format!("{}", SpecType::Olympic), "olympic");
|
assert_eq!(format!("{}", SpecType::Olympic), "olympic");
|
||||||
|
Loading…
Reference in New Issue
Block a user