aragon / aragon.js

(Aragon 1) A monorepo of JavaScript libraries for interacting with Aragon
https://aragon.org
GNU Affero General Public License v3.0
82 stars 58 forks source link

API: provide support for overloaded functions in `external` handlers #186

Open ewingrj opened 5 years ago

ewingrj commented 5 years ago

Currently, there is no support for overloaded functions in a smart contract. The functions are accessed via name only, which will only provide access to the last overloaded function in the abi.

This appears to be true for both the AragonApp and AragonApp.external(...) contract objects.

The first donate function in the contract below will not be accessible via the aragon-client:

contract Test {
    public function donate() {
        // do something w/ msg.value
    }

    public function donate(address token, uint amt) {
        // do something w/ a token    
    }
}
sohkai commented 5 years ago

I thought this was true as well, but looking at how the RPC handlers work, I think this is only impossible for AragonApp.external calls.

You can access overridden intents on the AragonApp instance like you would via web3.js's name + parameter or function signature accessors:

const api = new AragonApp()
return await api['donate(address,uint256)'](<address>, <value>)

This is also possible for AragonApp.call().


We probably want to create a similar proxy handler for AragonApp.external objects to handle the calls transparently as AragonApp does.

sohkai commented 4 years ago

Actually this was only fixed for intents in https://github.com/aragon/aragon.js/pull/401