From c04ba4e28aee279a2f4a05a0e9459b66bf6ea0fd Mon Sep 17 00:00:00 2001 From: Trevor Wessel Date: Tue, 24 Sep 2019 14:36:09 -0600 Subject: [PATCH 1/8] eosjs-ecc version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 438db7756..59c29d1b6 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "babel-runtime": "6.26.0", - "eosjs-ecc": "4.0.4", + "eosjs-ecc": "4.0.7", "text-encoding": "0.7.0" }, "devDependencies": { From 37c20e1ac558c13bfcb06027f0b57293d030039d Mon Sep 17 00:00:00 2001 From: Trevor Wessel Date: Fri, 4 Oct 2019 14:09:56 -0600 Subject: [PATCH 2/8] eosjs version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 59c29d1b6..6fc0adde8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eosjs", - "version": "20.0.0", + "version": "20.0.1", "description": "Talk to eos API", "main": "dist/index.js", "scripts": { From c83f82d466f45fda264632f5412221808e3420e7 Mon Sep 17 00:00:00 2001 From: Stuyk Date: Wed, 9 Oct 2019 12:40:14 -0600 Subject: [PATCH 3/8] Fix Copying RipeMD on Windows --- package.json | 4 ++-- scripts/copy-ripe-md.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 scripts/copy-ripe-md.js diff --git a/package.json b/package.json index 6fc0adde8..60708892e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eosjs", - "version": "20.0.1", + "version": "20.0.2", "description": "Talk to eos API", "main": "dist/index.js", "scripts": { @@ -12,7 +12,7 @@ "test": "jest src/tests/*eosjs*", "test-node": "jest src/tests/*node*", "test-all": "yarn test && yarn test-node && yarn cypress", - "build": "tsc -p ./tsconfig.json && cp src/ripemd.es5.js dist/ripemd.js", + "build": "tsc -p ./tsconfig.json && node scripts/copy-ripe-md.js", "build-web": "webpack --config webpack.prod.js && webpack --config webpack.debug.js", "build-production": "yarn build && yarn build-web && yarn test-all", "clean": "rm -rf dist", diff --git a/scripts/copy-ripe-md.js b/scripts/copy-ripe-md.js new file mode 100644 index 000000000..12770175f --- /dev/null +++ b/scripts/copy-ripe-md.js @@ -0,0 +1,3 @@ +var fs = require('fs'); +var root = __dirname + '\\..\\'; +fs.copyFileSync(root + 'src\\ripemd.es5.js', root + 'dist\\ripemd.js'); \ No newline at end of file From 27234892833465bc87f1dbfe2d20d24e77fc023b Mon Sep 17 00:00:00 2001 From: Stuyk Date: Wed, 9 Oct 2019 12:59:11 -0600 Subject: [PATCH 4/8] Fix Copy File Pathing --- scripts/copy-ripe-md.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/copy-ripe-md.js b/scripts/copy-ripe-md.js index 12770175f..c06c6c104 100644 --- a/scripts/copy-ripe-md.js +++ b/scripts/copy-ripe-md.js @@ -1,3 +1,7 @@ var fs = require('fs'); -var root = __dirname + '\\..\\'; +var root = __dirname.replace('scripts', ''); + +if(!fs.existsSync(root + 'dist')) + fs.mkdirSync(root + 'dist'); + fs.copyFileSync(root + 'src\\ripemd.es5.js', root + 'dist\\ripemd.js'); \ No newline at end of file From a95338d499e8451938c3ec4a04cbee6ea5d2a974 Mon Sep 17 00:00:00 2001 From: Stuyk Date: Wed, 9 Oct 2019 13:16:19 -0600 Subject: [PATCH 5/8] Use path.join for path resolving --- scripts/copy-ripe-md.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/copy-ripe-md.js b/scripts/copy-ripe-md.js index c06c6c104..c047379c7 100644 --- a/scripts/copy-ripe-md.js +++ b/scripts/copy-ripe-md.js @@ -1,7 +1,8 @@ var fs = require('fs'); +var path = require('path'); var root = __dirname.replace('scripts', ''); -if(!fs.existsSync(root + 'dist')) - fs.mkdirSync(root + 'dist'); +if(!fs.existsSync(path.join(root + 'dist'))) + fs.mkdirSync(path.join(root + 'dist')); -fs.copyFileSync(root + 'src\\ripemd.es5.js', root + 'dist\\ripemd.js'); \ No newline at end of file +fs.copyFileSync(path.join(root + 'src/ripemd.es5.js'), path.join(root + 'dist/ripemd.js')); \ No newline at end of file From 2c68093fa28a1f56511800b2ee9ebaddb062dcf5 Mon Sep 17 00:00:00 2001 From: Alexandre GOMES Date: Mon, 14 Oct 2019 15:50:39 +0200 Subject: [PATCH 6/8] Update README.md Add up-to-date instructions on using ESModules, and fixed case from `NodeJS` to `Node.js` --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8617d5823..b0c6b6d60 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Documentation can be found [here](https://eosio.github.io/eosjs) The official distribution package can be found at [npm](https://www.npmjs.com/package/eosjs). -### NodeJS Dependency +### Add dependency to your project `yarn add eosjs` @@ -22,7 +22,7 @@ Clone this repository locally then run `yarn build-web`. The browser distributi ### ES Modules -Importing using ES6 module syntax in the browser is supported if you have a transpiler, such as Babel. +Importing using ESM syntax is supported using TypeScript, [webpack](https://webpack.js.org/api/module-methods), or [Node.js with `--experimental-modules` flag](https://nodejs.org/api/esm.html) ```js import { Api, JsonRpc, RpcError } from 'eosjs'; import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig'; // development only @@ -30,7 +30,7 @@ import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig'; // devel ### CommonJS -Importing using commonJS syntax is supported by NodeJS out of the box. +Importing using commonJS syntax is supported by Node.js out of the box. ```js const { Api, JsonRpc, RpcError } = require('eosjs'); const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig'); // development only @@ -54,7 +54,7 @@ const signatureProvider = new JsSignatureProvider([defaultPrivateKey]); ### JSON-RPC -Open a connection to JSON-RPC, include `fetch` when on NodeJS. +Open a connection to JSON-RPC, include `fetch` when on Node.js. ```js const rpc = new JsonRpc('http://127.0.0.1:8888', { fetch }); ``` From f514726eb338c8553425965e71d6cd0f201d8cd8 Mon Sep 17 00:00:00 2001 From: Jeffrey Smith II Date: Thu, 16 Jan 2020 12:18:07 -0500 Subject: [PATCH 7/8] Bump to 20.0.3 to fix CI/CD deployment issue --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 60708892e..1fdbc7675 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eosjs", - "version": "20.0.2", + "version": "20.0.3", "description": "Talk to eos API", "main": "dist/index.js", "scripts": { From dda4407b12e793cf10d5f979e3db80c95ff91740 Mon Sep 17 00:00:00 2001 From: emperorhan Date: Mon, 13 Apr 2020 15:53:41 +0900 Subject: [PATCH 8/8] Add deserialize struct type --- src/eosjs-serialize.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/eosjs-serialize.ts b/src/eosjs-serialize.ts index da4a1033b..0989903a9 100644 --- a/src/eosjs-serialize.ts +++ b/src/eosjs-serialize.ts @@ -1108,3 +1108,17 @@ export function deserializeAction(contract: Contract, account: string, name: str data: deserializeActionData(contract, account, name, data, textEncoder, textDecoder), }; } + +/** Deserialize struct type. If `data` is a `string`, then it's assumed to be in hex. */ +export function deserializeTypeData(contract: Contract, account: string, structName: string, data: string | Uint8Array, textEncoder: TextEncoder, textDecoder: TextDecoder): any { + const type = contract.types.get(structName); + if (typeof data === "string") { + data = hexToUint8Array(data); + } + if(!type) { + throw new Error(`Unknown type ${structName} in contract ${account}`); + } + const buffer = new SerialBuffer({textDecoder, textEncoder}); + buffer.pushArray(data); + return type.deserialize(buffer); +} \ No newline at end of file