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

Merged
merged 7 commits into from Mar 14, 2018

Conversation

Projects
None yet
2 participants
@onbjerg
Contributor

onbjerg commented Mar 14, 2018

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

const token = app.external(address, jsonInterface)

// A call
// Returns an Observable that emits a single value (the return value, a Web3 `Result` object)
token.symbol()

// Events
// Returns an Observable that emits Web3-structured events over time
token.events()

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:

const Aragon = require('@aragon/client')

const app = new Aragon()
const token = app.external('0xdeadbeef', [
  {
    'constant': true,
    'inputs': [],
    'name': 'symbol',
    'outputs': [
      {
        'name': 'symbol',
        'type': 'string'
      }
    ],
    'payable': false,
    'type': 'function'
  }
])

token.symbol().subscribe(
  ({ symbol }) => app.identify(symbol)
)

Improvements

Some future improvements could include

  • Transactions to external contracts, possibly with "universal transaction pathing"
  • Convenience functions, such as an integration with store (see brief explanation in #75)

Closes #41 and partially adresses #43

onbjerg added some commits Mar 13, 2018

@onbjerg onbjerg requested review from bpierre and sohkai Mar 14, 2018

@onbjerg

This comment has been minimized.

Show comment
Hide comment
@onbjerg

onbjerg Mar 14, 2018

Contributor

Tested locally and working, need a go from either one of you @bpierre @sohkai

Contributor

onbjerg commented Mar 14, 2018

Tested locally and working, need a go from either one of you @bpierre @sohkai

@sohkai

sohkai approved these changes Mar 14, 2018

❤️❤️❤️ so excited to have this ❤️❤️❤️

Show outdated Hide outdated packages/aragon-client/src/index.js
[
address,
jsonInterface.filter(
(item) => item.type === 'event'

This comment has been minimized.

@sohkai

sohkai Mar 14, 2018

Member

Cool! I had no idea you could put in partial ABIs and everything would just work.

@sohkai

sohkai Mar 14, 2018

Member

Cool! I had no idea you could put in partial ABIs and everything would just work.

Show outdated Hide outdated packages/aragon-client/src/index.js

onbjerg added some commits Mar 14, 2018

@onbjerg onbjerg merged commit 35d6266 into master Mar 14, 2018

1 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
license/cla Contributor License Agreement is signed.
Details

@onbjerg onbjerg deleted the external-contracts branch Apr 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment