aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-wrapper
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-08-15 05:21:47 +0800
committerFabio Berger <me@fabioberger.com>2018-08-15 05:21:47 +0800
commit2f2582a0da3095d61a99ef09744dc0995677558e (patch)
tree54989565919038c42d495dafb7426d4148605e84 /packages/web3-wrapper
parent8169155a6547fb0283cd0f5362aad3c0b173b00b (diff)
parentfadd292ecf367e42154856509d0ea0c20b23f2f1 (diff)
downloaddexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar
dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.gz
dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.bz2
dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.lz
dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.xz
dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.zst
dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.zip
Merge development
Diffstat (limited to 'packages/web3-wrapper')
-rw-r--r--packages/web3-wrapper/CHANGELOG.json14
-rw-r--r--packages/web3-wrapper/CHANGELOG.md11
-rw-r--r--packages/web3-wrapper/package.json22
-rw-r--r--packages/web3-wrapper/src/index.ts14
-rw-r--r--packages/web3-wrapper/src/marshaller.ts48
5 files changed, 94 insertions, 15 deletions
diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json
index 7bf28dfa8..422059cc0 100644
--- a/packages/web3-wrapper/CHANGELOG.json
+++ b/packages/web3-wrapper/CHANGELOG.json
@@ -1,5 +1,19 @@
[
{
+ "version": "1.2.0",
+ "changes": [
+ {
+ "note": "Export marshaller to convert between RPC and user-space data formats",
+ "pr": 938
+ },
+ {
+ "note": "Export RPC types",
+ "pr": 938
+ }
+ ],
+ "timestamp": 1534210131
+ },
+ {
"timestamp": 1532619515,
"version": "1.1.2",
"changes": [
diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md
index 4ebd92a75..0955993f4 100644
--- a/packages/web3-wrapper/CHANGELOG.md
+++ b/packages/web3-wrapper/CHANGELOG.md
@@ -5,6 +5,11 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.2.0 - _August 13, 2018_
+
+ * Export marshaller to convert between RPC and user-space data formats (#938)
+ * Export RPC types (#938)
+
## v1.1.2 - _July 26, 2018_
* Dependencies updated
@@ -21,7 +26,7 @@ CHANGELOG
* Dependencies updated
-## v1.0.0 - _July 20, 2018_
+## v1.0.0 - _July 19, 2018_
* Stop exporting `marshaller` utility file. (#902)
* Export `marshaller` utility file. (#829)
@@ -40,7 +45,7 @@ CHANGELOG
* Dependencies updated
-## v0.7.0 - _June 4, 2018_
+## v0.7.0 - _June 3, 2018_
* Add `web3Wrapper.getContractCodeAsync` (#675)
* Add `web3Wrapper.getTransactionTraceAsync` (#675)
@@ -55,7 +60,7 @@ CHANGELOG
* Dependencies updated
-## v0.6.3 - _May 5, 2018_
+## v0.6.3 - _May 4, 2018_
* Dependencies updated
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 42f17aaac..fc52f9dd9 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/web3-wrapper",
- "version": "1.1.2",
+ "version": "1.2.0",
"engines": {
"node": ">=6.12"
},
@@ -36,32 +36,32 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-wrapper/README.md",
"devDependencies": {
- "@0xproject/tslint-config": "^1.0.4",
+ "@0xproject/tslint-config": "^1.0.5",
"@types/lodash": "4.14.104",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
- "ganache-core": "0xProject/ganache-core",
+ "ganache-core": "0xProject/ganache-core#monorepo-dep",
"make-promises-safe": "^1.1.0",
- "mocha": "^4.0.1",
+ "mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typedoc": "0xProject/typedoc",
- "typescript": "2.7.1"
+ "typescript": "2.9.2"
},
"dependencies": {
- "@0xproject/assert": "^1.0.4",
- "@0xproject/json-schemas": "^1.0.1-rc.3",
- "@0xproject/typescript-typings": "^1.0.3",
- "@0xproject/utils": "^1.0.4",
- "ethereum-types": "^1.0.3",
+ "@0xproject/assert": "^1.0.5",
+ "@0xproject/json-schemas": "^1.0.1-rc.4",
+ "@0xproject/typescript-typings": "^1.0.4",
+ "@0xproject/utils": "^1.0.5",
+ "ethereum-types": "^1.0.4",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",
- "lodash": "^4.17.4"
+ "lodash": "^4.17.5"
},
"publishConfig": {
"access": "public"
diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts
index 89cf566db..dc708eb8c 100644
--- a/packages/web3-wrapper/src/index.ts
+++ b/packages/web3-wrapper/src/index.ts
@@ -1,5 +1,6 @@
export { Web3Wrapper } from './web3_wrapper';
-export { Web3WrapperErrors, NodeType } from './types';
+export { marshaller } from './marshaller';
+
export {
BlockParam,
TxData,
@@ -23,3 +24,14 @@ export {
JSONRPCErrorCallback,
BlockParamLiteral,
} from 'ethereum-types';
+export {
+ Web3WrapperErrors,
+ NodeType,
+ CallDataRPC,
+ CallTxDataBaseRPC,
+ AbstractBlockRPC,
+ BlockWithoutTransactionDataRPC,
+ BlockWithTransactionDataRPC,
+ TransactionRPC,
+ TxDataRPC,
+} from './types';
diff --git a/packages/web3-wrapper/src/marshaller.ts b/packages/web3-wrapper/src/marshaller.ts
index fed197822..572a322d6 100644
--- a/packages/web3-wrapper/src/marshaller.ts
+++ b/packages/web3-wrapper/src/marshaller.ts
@@ -25,7 +25,15 @@ import {
TxDataRPC,
} from './types';
+/**
+ * Utils to convert ethereum structures from user-space format to RPC format. (marshall/unmarshall)
+ */
export const marshaller = {
+ /**
+ * Unmarshall block without transaction data
+ * @param blockWithHexValues block to unmarshall
+ * @return unmarshalled block without transaction data
+ */
unmarshalIntoBlockWithoutTransactionData(
blockWithHexValues: BlockWithoutTransactionDataRPC,
): BlockWithoutTransactionData {
@@ -41,6 +49,11 @@ export const marshaller = {
};
return block;
},
+ /**
+ * Unmarshall block with transaction data
+ * @param blockWithHexValues block to unmarshall
+ * @return unmarshalled block with transaction data
+ */
unmarshalIntoBlockWithTransactionData(blockWithHexValues: BlockWithTransactionDataRPC): BlockWithTransactionData {
const block = {
...blockWithHexValues,
@@ -59,6 +72,11 @@ export const marshaller = {
});
return block;
},
+ /**
+ * Unmarshall transaction
+ * @param txRpc transaction to unmarshall
+ * @return unmarshalled transaction
+ */
unmarshalTransaction(txRpc: TransactionRPC): Transaction {
const tx = {
...txRpc,
@@ -73,6 +91,11 @@ export const marshaller = {
};
return tx;
},
+ /**
+ * Unmarshall transaction data
+ * @param txDataRpc transaction data to unmarshall
+ * @return unmarshalled transaction data
+ */
unmarshalTxData(txDataRpc: TxDataRPC): TxData {
if (_.isUndefined(txDataRpc.from)) {
throw new Error(`txData must include valid 'from' value.`);
@@ -86,6 +109,11 @@ export const marshaller = {
};
return txData;
},
+ /**
+ * Marshall transaction data
+ * @param txData transaction data to marshall
+ * @return marshalled transaction data
+ */
marshalTxData(txData: Partial<TxData>): Partial<TxDataRPC> {
if (_.isUndefined(txData.from)) {
throw new Error(`txData must include valid 'from' value.`);
@@ -107,6 +135,11 @@ export const marshaller = {
});
return txDataRPC;
},
+ /**
+ * Marshall call data
+ * @param callData call data to marshall
+ * @return marshalled call data
+ */
marshalCallData(callData: Partial<CallData>): Partial<CallDataRPC> {
const callTxDataBase = {
...callData,
@@ -119,12 +152,22 @@ export const marshaller = {
};
return callDataRPC;
},
+ /**
+ * Marshall address
+ * @param address address to marshall
+ * @return marshalled address
+ */
marshalAddress(address: string): string {
if (addressUtils.isAddress(address)) {
return ethUtil.addHexPrefix(address);
}
throw new Error(`Invalid address encountered: ${address}`);
},
+ /**
+ * Marshall block param
+ * @param blockParam block param to marshall
+ * @return marshalled block param
+ */
marshalBlockParam(blockParam: BlockParam | string | number | undefined): string | undefined {
if (_.isUndefined(blockParam)) {
return BlockParamLiteral.Latest;
@@ -132,6 +175,11 @@ export const marshaller = {
const encodedBlockParam = _.isNumber(blockParam) ? utils.numberToHex(blockParam) : blockParam;
return encodedBlockParam;
},
+ /**
+ * Unmarshall log
+ * @param rawLog log to unmarshall
+ * @return unmarshalled log
+ */
unmarshalLog(rawLog: RawLogEntry): LogEntry {
const formattedLog = {
...rawLog,