Abstract
This draft is to discuss the ethereum API, an object exposed by ethereum native browsers and tools like Mist, MetaMask and status.im.
The API should be small and clean and allow all kind of libraries to attach to it.
The class of the object should be EthereumProvider, the object name ethereum.
API
The ethereum should inherit from a EventEmitter type class, and provide add/removeListener, on/once/off etc.
// callback: a error first callback
ethereum.send(methodName, params, callback)
> undefined
// CALLBACK return
> err, result
// returns subscription notification,
ethereum.on(subscriptionType, handler)
subscriptionType = `eth_subscription`
// HANDLER return
> {
"subscription":"0x2acffa11d68280c2954daeb77cb849d9",
"result": {...}
}
// react on connection start
ethereum.on('connect', handler)
// HANDLER return
null
// react on connection end
ethereum.on('end', handler)
// HANDLER return
Error Object with message (timeout, error, drop, etc)