-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External contracts #76
Conversation
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.
❤️❤️❤️ so excited to have this ❤️❤️❤️
packages/aragon-client/src/index.js
Outdated
* @return {Object} | ||
*/ | ||
external (address, jsonInterface) { | ||
let contract = { |
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.
Could be const
?
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.
yeah that's something I missed while iterating a bit
[ | ||
address, | ||
jsonInterface.filter( | ||
(item) => item.type === 'event' |
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.
Cool! I had no idea you could put in partial ABIs and everything would just work.
packages/aragon-client/src/index.js
Outdated
const callMethods = jsonInterface.filter( | ||
(item) => item.type === 'function' && item.constant | ||
) | ||
for (let methodABI of callMethods) { |
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.
I do find it slightly odd this isn't a forEach
or reduce
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.
could be a forEach
, probably also a reduce but would feel a bit weird with reduce imo
This PR allows you to interact with external contracts (i.e. contracts that are assumed to not be an Aragon app), such as tokens.
It allows you to perform calls and filter for events, but provides no automatic caching or convenience functions.
Usage-ish
Note that you need to supply (at least a partial) JSON interface to interact with the contract.
Example
As a minimum viable example for getting the symbol of a token (conforming to Human Standard Token) and setting the app identifier to be that symbol, this would suffice:
Improvements
Some future improvements could include
store
(see brief explanation in Allow calls to arbitrary contracts #75)Closes #41 and partially adresses #43