Skip to content

Commit

Permalink
Merge pull request #2122 from joshstevens19/web3-eth
Browse files Browse the repository at this point in the history
web3-eth typings
  • Loading branch information
nivida authored Dec 14, 2018
2 parents 6517f4f + f770888 commit df375c2
Show file tree
Hide file tree
Showing 8 changed files with 698 additions and 88 deletions.
79 changes: 0 additions & 79 deletions docs/include_package-core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,82 +206,3 @@ Example
------------------------------------------------------------------------------

extend
=====================

.. code-block:: javascript
web3.extend(methods)
web3.eth.extend(methods)
web3.shh.extend(methods)
web3.bzz.extend(methods)
...
Allows extending the web3 modules.

.. note:: You also have ``*.extend.formatters`` as additional formatter functions to be used for in and output formatting. Please see the `source file <https://github.com/ethereum/web3.js/blob/master/packages/web3-core-helpers/src/Formatters.js>`_ for function details.

----------
Parameters
----------

1. ``methods`` - ``Object``: Extension object with array of methods description objects as follows:
- ``property`` - ``String``: (optional) The name of the property to add to the module. If no property is set it will be added to the module directly.
- ``methods`` - ``Array``: The array of method descriptions:
- ``name`` - ``String``: Name of the method to add.
- ``call`` - ``String``: The RPC method name.
- ``params`` - ``Number``: (optional) The number of parameters for that function. Default 0.
- ``inputFormatter`` - ``Array``: (optional) Array of inputformatter functions. Each array item responds to a function parameter, so if you want some parameters not to be formatted, add a ``null`` instead.
- ``outputFormatter - ``Function``: (optional) Can be used to format the output of the method.


----------
Returns
----------

``Object``: The extended module.

-------
Example
-------

.. code-block:: javascript
web3.extend({
property: 'myModule',
methods: [{
name: 'getBalance',
call: 'eth_getBalance',
params: 2,
inputFormatter: [web3.extend.formatters.inputAddressFormatter, web3.extend.formatters.inputDefaultBlockNumberFormatter],
outputFormatter: web3.utils.hexToNumberString
},{
name: 'getGasPriceSuperFunction',
call: 'eth_gasPriceSuper',
params: 2,
inputFormatter: [null, web3.utils.numberToHex]
}]
});
web3.extend({
methods: [{
name: 'directCall',
call: 'eth_callForFun',
}]
});
console.log(web3);
> Web3 {
myModule: {
getBalance: function(){},
getGasPriceSuperFunction: function(){}
},
directCall: function(){},
eth: Eth {...},
bzz: Bzz {...},
...
}
------------------------------------------------------------------------------
4 changes: 2 additions & 2 deletions docs/web3-eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ signTransaction

.. code-block:: javascript
web3.eth.signTransaction(transactionObject, address [, callback])
web3.eth.signTransaction(transactionObject [, address] [, callback])
Signs a transaction. This account needs to be unlocked.

Expand All @@ -1188,7 +1188,7 @@ Parameters


1. ``Object`` - The transaction data to sign :ref:`web3.eth.sendTransaction() <eth-sendtransaction>` for more.
2. ``String`` - Address to sign transaction with.
2. ``String`` - (optional) Address to sign transaction with.
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.


Expand Down
9 changes: 4 additions & 5 deletions packages/web3-eth-accounts/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,13 @@ export interface EncryptedKeystoreV3Json {
}
}

/** MOVE ALL BELOW TO WEB3-CORE !!! */
/** MOVE ALL BELOW TO WEB3-CORE ONCE TYPES COMPLETE FOR CLEAR UP !!! */
export interface Transaction {
from?: string | number;
to: string;
to?: string;
gasPrice?: string;
gas: number;
// value: number | string | BN | BigNumber; should be this
value: number | string;
gas?: number | string;
value?: number | string;
chainId?: number;
data?: string;
nonce?: number;
Expand Down
10 changes: 8 additions & 2 deletions packages/web3-eth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"test": "jest"
"test": "jest",
"dtslint": "dtslint types"
},
"types": "types",
"dependencies": {
"web3-core": "1.0.0-beta.36",
"web3-core-helpers": "1.0.0-beta.36",
Expand All @@ -28,7 +30,11 @@
"web3-providers": "1.0.0-beta.36",
"web3-utils": "1.0.0-beta.36"
},
"devDependencies": {
"dtslint": "^0.3.0"
},
"files": [
"dist"
"dist",
"types/index.d.ts"
]
}
Loading

0 comments on commit df375c2

Please sign in to comment.