This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
method signature lookups, parameter decoding & management #2313
Merged
Merged
Changes from 38 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
1bb08f9
add owned & signaturereg abi
jacogr 9932603
add gpl headers
jacogr deec7ef
abi now maps both the method ids (baz(uint32,bool)) as well as signat…
jacogr 7d79ccc
allow build of signaturereg dapp
jacogr 62bf6d4
add signaturereg to hardcoded dapp list
jacogr ce76ab3
oops.
jacogr 1e271d6
basic registration is operational
jacogr f0ed0c5
styling updates
jacogr 35969bb
visual updates
jacogr e2e4994
Merge branch 'js' into jg-dapp-signaturereg
jacogr f06c2ef
fix merge issues
jacogr eaf81f7
add missing gpl headers (non-related)
jacogr 98e782d
adjust display, expand account names
jacogr a09b07b
remove debug log
jacogr 6b4b7a6
cleanup log filtering (pending vs. mined)
jacogr cefd529
debug info
jacogr 7d7419d
fix event pending/mined filtering (check for actual method match)
jacogr 7aa7e07
inverse button styling
jacogr f5a9b5b
show active address (needs selection)
jacogr 120ece0
allow setting of from account address
jacogr de929eb
allow setting of fromAccount
jacogr 146ca6e
Merge branch 'jg-abi-method-input-decode' into jg-dapp-signaturereg
jacogr 8fec76c
helpers for contracts, single source
jacogr 4a4766c
return empty when null supplied
jacogr 275acbb
don't fail on contract creation encoding
jacogr a1cd82c
add contracts context
jacogr cf24bb2
calls gets expanded in transaction list view
jacogr c6a5ead
Merge branch 'jg-abi-method-input-decode' into jg-dapp-signaturereg
jacogr 76e1591
add component for displaying decoded method inputs
jacogr aa5e216
split transaction row into own component
jacogr 496869b
transaction display is closer to what we have in Signer
jacogr 679cf09
small transaction list styling updates (align with Signer, non-shared…
jacogr 88915c8
Merge branch 'js' into jg-dapp-signaturereg
jacogr 24fd4ce
Merge branch 'js' into jg-dapp-signaturereg
jacogr abda702
small format display updates
jacogr 3cbf646
value & token formatting
jacogr ff6a1fc
methods with monospace
jacogr 6ead4ca
method decoding returns Natspec-like description of what is going on
jacogr a2b4823
show general value transfers as well (to contract or address)
jacogr a5d23dd
split between received/sent
jacogr a000c14
formatting updates
jacogr 1385efc
updated signaturereg to new play contract
jacogr d199282
expand decoding of human-readable transactions
jacogr efe4491
Merge branch 'js' into jg-dapp-signaturereg
jacogr 3b80451
Merge branch 'js' into jg-dapp-signaturereg
jacogr 64ccce3
use IdentityIcon where addresses are displayed
jacogr 63560e4
padding & spacing, IdentityIcon allows token transaltion everywhere
jacogr 901006a
slightly more subtle highlights
jacogr 16e4062
remove unused renderSimple
jacogr 5167462
small styling alignments
jacogr 26e5ca9
s/owner/creator/ (matching new contract interface)
jacogr 92b7cfb
TabBar invariant error
jacogr 6c915db
pending requests padding (unrelated, inconsequential)
jacogr 8f3e253
updated styling & gas display
jacogr 95ed3f7
Merge branch 'js' into jg-dapp-signaturereg
jacogr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// 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 from './registry'; | ||
import SignatureReg from './signaturereg'; | ||
import TokenReg from './tokenreg'; | ||
|
||
let instance = null; | ||
|
||
export default class Contracts { | ||
constructor (api) { | ||
instance = this; | ||
|
||
this._api = api; | ||
this._registry = new Registry(api); | ||
this._signaturereg = new SignatureReg(api, this._registry); | ||
this._tokenreg = new TokenReg(api, this._registry); | ||
} | ||
|
||
get registry () { | ||
return this._registry; | ||
} | ||
|
||
get signatureReg () { | ||
return this._signaturereg; | ||
} | ||
|
||
get tokenReg () { | ||
return this._tokenreg; | ||
} | ||
|
||
static create (api) { | ||
return new Contracts(api); | ||
} | ||
|
||
static get () { | ||
return instance; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default from './contracts'; |
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import * as abis from '../json'; | ||
|
||
export default class Registry { | ||
constructor (api) { | ||
this._api = api; | ||
this._contracts = []; | ||
this._instance = null; | ||
|
||
this.getInstance(); | ||
} | ||
|
||
getInstance () { | ||
return new Promise((resolve, reject) => { | ||
if (this._instance) { | ||
resolve(this._instance); | ||
return; | ||
} | ||
|
||
this._api.ethcore | ||
.registryAddress() | ||
.then((address) => { | ||
this._instance = this._api.newContract(abis.registry, address).instance; | ||
resolve(this._instance); | ||
}) | ||
.catch(reject); | ||
}); | ||
} | ||
|
||
getContractInstance (_name) { | ||
const name = _name.toLowerCase(); | ||
|
||
return new Promise((resolve, reject) => { | ||
if (this._contracts[name]) { | ||
resolve(this._contracts[name]); | ||
return; | ||
} | ||
|
||
this | ||
.lookupAddress(name) | ||
.then((address) => { | ||
this._contracts[name] = this._api.newContract(abis[name], address).instance; | ||
resolve(this._contracts[name]); | ||
}) | ||
.catch(reject); | ||
}); | ||
} | ||
|
||
lookupAddress (_name) { | ||
const name = _name.toLowerCase(); | ||
|
||
return this.getInstance().then((instance) => { | ||
if (name === 'signaturereg') { | ||
return '0xD1888764222dbE5BBa54F0cf9d493e43aba667Fb'; | ||
} | ||
return instance.getAddress.call({}, [this._api.util.sha3(name), 'A']); | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default class SignatureReg { | ||
constructor (api, registry) { | ||
this._api = api; | ||
this._registry = registry; | ||
|
||
this.getInstance(); | ||
} | ||
|
||
getInstance () { | ||
return this._registry.getContractInstance('signaturereg'); | ||
} | ||
|
||
lookup (signature) { | ||
return this.getInstance().then((instance) => { | ||
return instance.get.call({}, [signature]); | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2015, 2016 Ethcore (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default class TokenReg { | ||
constructor (api, registry) { | ||
this._api = api; | ||
this._registry = registry; | ||
this._instance = null; | ||
|
||
this.getInstance(); | ||
} | ||
|
||
getInstance () { | ||
return this._registry.getContractInstance('tokenreg'); | ||
} | ||
|
||
tokenCount () { | ||
return this.getInstance().then((instance) => { | ||
return instance.tokenCount.call(); | ||
}); | ||
} | ||
|
||
token (index) { | ||
return this.getInstance().then((instance) => { | ||
return instance.token.call({}, [index]); | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>Method Signature Registry</title> | ||
<link href="//fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet"> | ||
<link href="//fonts.googleapis.com/css?family=Roboto+Mono:300" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div id="container"></div> | ||
<script src="vendor.js"></script> | ||
<script src="commons.js"></script> | ||
<script src="parity.js"></script> | ||
<script src="signaturereg.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a
class
here? A simplefunction
returning an object withgetContractInstance
andlookupAddress
would have done the job and is conceptually a lot simpler than aclass
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same thing for
src/contracts/signaturereg.js
,src/contracts/tokenreg.js
andsrc/contracts/tokenreg.js
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On purpose, to lessen congnitive overload. Use classes everywhere, so didn't deviate. I actually realised that with the 3rdparty stuff where we don't, it takes a couple of mins to get into it when changes are to be made.