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:
committed by
Arkadiy Paronyan
parent
3a0c4b6539
commit
495e5790e9
@@ -14,34 +14,18 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import badgereg from './badgereg.json';
|
||||
import basiccoin from './basiccoin.json';
|
||||
import basiccoinmanager from './basiccoinmanager.json';
|
||||
import dappreg from './dappreg.json';
|
||||
import eip20 from './eip20.json';
|
||||
import emailverification from './email-verification.json';
|
||||
import gavcoin from './gavcoin.json';
|
||||
import githubhint from './githubhint.json';
|
||||
import owned from './owned.json';
|
||||
import registry from './registry.json';
|
||||
import signaturereg from './signaturereg.json';
|
||||
import smsverification from './sms-verification.json';
|
||||
import tokenreg from './tokenreg.json';
|
||||
import wallet from './wallet.json';
|
||||
|
||||
export {
|
||||
badgereg,
|
||||
basiccoin,
|
||||
basiccoinmanager,
|
||||
dappreg,
|
||||
eip20,
|
||||
emailverification,
|
||||
gavcoin,
|
||||
githubhint,
|
||||
owned,
|
||||
registry,
|
||||
signaturereg,
|
||||
smsverification,
|
||||
tokenreg,
|
||||
wallet
|
||||
};
|
||||
export badgereg from './badgereg.json';
|
||||
export basiccoin from './basiccoin.json';
|
||||
export basiccoinmanager from './basiccoinmanager.json';
|
||||
export dappreg from './dappreg.json';
|
||||
export eip20 from './eip20.json';
|
||||
export emailverification from './email-verification.json';
|
||||
export gavcoin from './gavcoin.json';
|
||||
export githubhint from './githubhint.json';
|
||||
export owned from './owned.json';
|
||||
export registry from './registry.json';
|
||||
export registry2 from './registry2.json';
|
||||
export signaturereg from './signaturereg.json';
|
||||
export smsverification from './sms-verification.json';
|
||||
export tokenreg from './tokenreg.json';
|
||||
export wallet from './wallet.json';
|
||||
|
||||
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 (
|
||||
<tr key={ e.key } className={ classes }>
|
||||
<td>
|
||||
<Address address={ e.parameters.owner.value } />
|
||||
<Address
|
||||
address={
|
||||
e.parameters.owner
|
||||
? e.parameters.owner.value
|
||||
: e.from
|
||||
}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<abbr title={ e.transaction }>{ verb }</abbr>
|
||||
@@ -80,17 +86,23 @@ const renderDataChanged = (e) => {
|
||||
return (
|
||||
<tr key={ e.key } className={ classNames }>
|
||||
<td>
|
||||
<Address address={ e.parameters.owner.value } />
|
||||
<Address
|
||||
address={
|
||||
e.parameters.owner
|
||||
? e.parameters.owner.value
|
||||
: e.from
|
||||
}
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<abbr title={ e.transaction }>updated</abbr>
|
||||
</td>
|
||||
<td>
|
||||
{ 'key ' }
|
||||
key
|
||||
<code>
|
||||
{ new Buffer(e.parameters.plainKey.value).toString('utf8') }
|
||||
</code>
|
||||
{ 'of ' }
|
||||
of
|
||||
<code>
|
||||
<Hash hash={ bytesToHex(e.parameters.name.value) } />
|
||||
</code>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// 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 * 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 };
|
||||
|
||||
const REGISTRY_V1_HASHES = [
|
||||
'0x34f7c51bbb1b1902fbdabfdf04811100f5c9f998f26dd535d2f6f977492c748e', // ropsten
|
||||
'0x64c3ee34851517a9faecd995c102b339f03e564ad6772dc43a26f993238b20ec' // homestead
|
||||
];
|
||||
|
||||
export const setIsTestnet = (isTestnet) => ({ type: 'set isTestnet', isTestnet });
|
||||
|
||||
export const fetchIsTestnet = () => (dispatch) =>
|
||||
@@ -47,13 +52,28 @@ export const fetchIsTestnet = () => (dispatch) =>
|
||||
export const setContract = (contract) => ({ type: 'set contract', contract });
|
||||
|
||||
export const fetchContract = () => (dispatch) =>
|
||||
api.parity.registryAddress()
|
||||
api.parity
|
||||
.registryAddress()
|
||||
.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);
|
||||
|
||||
dispatch(setContract(contract));
|
||||
dispatch(fetchFee());
|
||||
dispatch(fetchOwner());
|
||||
console.log(`registry at ${address}, code ${codeHash}, version ${isVersion1 ? 1 : 2}`);
|
||||
|
||||
const contract = api.newContract(
|
||||
isVersion1
|
||||
? registryAbi
|
||||
: registryAbi2,
|
||||
address
|
||||
);
|
||||
|
||||
dispatch(setContract(contract));
|
||||
dispatch(fetchFee());
|
||||
dispatch(fetchOwner());
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('could not fetch contract');
|
||||
|
||||
Reference in New Issue
Block a user