@eosrio/node-abieos 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1 @@
1
+ (ssh://git@git.jetbrains.team/llvm/llvm-project.git eeb64a79f164f241d539c0a3f0491b50a854ead9 based on LLVM a01392cc95a03e97d8dc19cc3b3484daf9a4f19e revision)
@@ -0,0 +1,34 @@
1
+ name: Node.js Addon with CMake
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master", "3.3-staging" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+
9
+ env:
10
+ BUILD_TYPE: Release
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ node-version: [20.x]
18
+
19
+ steps:
20
+ # Checkout repo and submodules
21
+ - uses: actions/checkout@v4
22
+ with:
23
+ submodules: recursive
24
+
25
+ # Setup Node.js
26
+ - name: Use Node.js ${{ matrix.node-version }}
27
+ uses: actions/setup-node@v4
28
+ with:
29
+ node-version: ${{ matrix.node-version }}
30
+ cache: 'npm'
31
+ - run: npm ci
32
+ - run: npm run build:linux:ci
33
+ - run: npm run build:tsc
34
+ - run: npm run test
package/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "abieos"]
2
+ path = abieos
3
+ url = https://github.com/igorls/abieos.git
package/README.md CHANGED
@@ -1,46 +1,58 @@
1
- # node-abieos
2
-
3
- Node.js native binding for [abieos](https://github.com/EOSIO/abieos), with some improvements:
4
-
5
- - Contracts can be directly updated on the map
6
- - Added `abieos_delete_contract`
7
-
8
- Made with ♥ by [EOS Rio](https://eosrio.io/)
9
-
10
- ----
11
- **Only Linux is supported for now, import will be null on others**
12
-
13
- - Typescript typings included
14
- - Prebuilt binary included (Clang 9.0.0 required to build)
15
-
16
- ### Install
17
-
18
- ```shell script
19
- npm i @eosrio/node-abieos --save
20
- ```
21
-
22
- ### Usage
23
-
24
- CommonJS
25
- ```js
26
- const nodeAbieos = require('@eosrio/node-abieos');
27
- ```
28
-
29
- ES Modules
30
- ```typescript
31
- import * as nodeAbieos from "@eosrio/node-abieos";
32
- ```
33
-
34
- Check the [/examples](https://github.com/eosrio/node-abieos/tree/master/examples) folder for implementation examples
35
-
36
- ### Building
37
-
38
- env setup instructions soon
39
- ```shell script
40
- git clone https://github.com/eosrio/node-abieos.git
41
- cd node-abieos
42
- # linux
43
- npm run build:linux
44
- # windows
45
- npm run build:win
46
- ```
1
+ # node-abieos
2
+
3
+ ![CI](https://github.com/eosrio/node-abieos/actions/workflows/build.yml/badge.svg)
4
+ ![Node-API v9 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v9%20Badge.svg)
5
+ [![NPM version](https://img.shields.io/npm/v/@eosrio/node-abieos.svg?style=flat)](https://www.npmjs.com/package/@eosrio/node-abieos)
6
+
7
+ Node.js native binding for [abieos](https://github.com/EOSIO/abieos), with some improvements:
8
+
9
+ - Contracts can be directly updated on the map
10
+ - Added `abieos_delete_contract`
11
+
12
+ Made with ♥ by [EOS Rio](https://eosrio.io/)
13
+
14
+ ----
15
+ **Only Linux is supported for now**
16
+
17
+ - Typescript typings included
18
+ - Prebuilt binary included (Clang 18 required to build)
19
+
20
+ ### Install
21
+
22
+ ```shell script
23
+ npm i @eosrio/node-abieos --save
24
+ ```
25
+
26
+ ### Usage
27
+
28
+ CommonJS
29
+ ```js
30
+ const nodeAbieos = require('@eosrio/node-abieos');
31
+ ```
32
+
33
+ ES Modules
34
+ ```typescript
35
+ import * as nodeAbieos from "@eosrio/node-abieos";
36
+ ```
37
+
38
+ Check the [/examples](https://github.com/eosrio/node-abieos/tree/master/examples) folder for implementation examples
39
+
40
+ ### Building
41
+
42
+ Make sure you have Clang installed on your system:
43
+ We recommend using Clang 18 to build the `abieos` C++ library.
44
+
45
+ ```bash
46
+ wget https://apt.llvm.org/llvm.sh
47
+ chmod +x llvm.sh
48
+ sudo ./llvm.sh 18
49
+ ```
50
+
51
+ Clone and Build
52
+ ```shell script
53
+ git clone https://github.com/eosrio/node-abieos.git
54
+ cd node-abieos
55
+ npm install
56
+ npm run build:linux
57
+ npm run build:tsc
58
+ ```
package/bun.lockb ADDED
Binary file
package/lib/abieos.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- declare let abieos: any | null;
2
+ declare const abieos: any;
3
3
  export declare class Abieos {
4
4
  private static instance;
5
5
  static native: typeof abieos;
@@ -1 +1 @@
1
- {"version":3,"file":"abieos.d.ts","sourceRoot":"","sources":["abieos.ts"],"names":[],"mappings":";AAKA,QAAA,IAAI,MAAM,EAAE,GAAG,GAAG,IAAW,CAAC;AAQ9B,qBAAa,MAAM;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAc,MAAM,EAAE,OAAO,MAAM,CAAC;IAEpC,OAAO;WAIO,WAAW,IAAI,MAAM;IAO5B,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAI5C,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAU5E,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG;IAa/D,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG;IAalE,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAY5D,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAIzD,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IASlE,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IASjE,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;CAGvD"}
1
+ {"version":3,"file":"abieos.d.ts","sourceRoot":"","sources":["abieos.ts"],"names":[],"mappings":";AAAA,QAAA,MAAM,MAAM,KAA2B,CAAC;AAExC,qBAAa,MAAM;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAc,MAAM,EAAE,OAAO,MAAM,CAAC;IAEpC,OAAO;WAIO,WAAW,IAAI,MAAM;IAO5B,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAI5C,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAU5E,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG;IAa/D,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG;IAalE,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAY5D,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAIzD,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IASlE,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IASjE,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;CAGvD"}
package/lib/abieos.js CHANGED
@@ -1,15 +1,8 @@
1
- import { createRequire } from 'module';
2
- const require = createRequire(import.meta.url);
3
- let modulePath = "../dist/abieos.node";
4
- let abieos = null;
5
- if (process.platform === 'linux') {
6
- abieos = require(modulePath);
7
- }
8
- else if (process.platform === 'win32') {
9
- // throw new Error(`${process.platform} is not supported by node-abieos`);
10
- abieos = null;
11
- }
12
- export class Abieos {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Abieos = void 0;
4
+ const abieos = require("./abieos.node");
5
+ class Abieos {
13
6
  constructor() {
14
7
  Abieos.native = abieos;
15
8
  }
@@ -98,3 +91,4 @@ export class Abieos {
98
91
  return Abieos.native.delete_contract(contractName);
99
92
  }
100
93
  }
94
+ exports.Abieos = Abieos;
Binary file
package/lib/abieos.ts CHANGED
@@ -1,106 +1,95 @@
1
- import {createRequire} from 'module';
2
-
3
- const require = createRequire(import.meta.url);
4
-
5
- let modulePath = "../dist/abieos.node";
6
- let abieos: any | null = null;
7
- if (process.platform === 'linux') {
8
- abieos = require(modulePath);
9
- } else if (process.platform === 'win32') {
10
- // throw new Error(`${process.platform} is not supported by node-abieos`);
11
- abieos = null;
12
- }
13
-
14
- export class Abieos {
15
- private static instance: Abieos;
16
- public static native: typeof abieos;
17
-
18
- private constructor() {
19
- Abieos.native = abieos;
20
- }
21
-
22
- public static getInstance(): Abieos {
23
- if (!Abieos.instance) {
24
- Abieos.instance = new Abieos();
25
- }
26
- return Abieos.instance;
27
- }
28
-
29
- public stringToName(nameString: string): BigInteger {
30
- return Abieos.native.string_to_name(nameString) as BigInteger;
31
- }
32
-
33
- public jsonToHex(contractName: string, type: string, json: string | object): string {
34
- const jsonData = typeof json === 'object' ? JSON.stringify(json) : json
35
- const data: string = Abieos.native.json_to_hex(contractName, type, jsonData);
36
- if (data === 'PARSING_ERROR') {
37
- throw new Error('failed to parse data');
38
- } else {
39
- return data;
40
- }
41
- }
42
-
43
- public hexToJson(contractName: string, type: string, hex: string): any {
44
- const data = Abieos.native.hex_to_json(contractName, type, hex);
45
- if (data) {
46
- try {
47
- return JSON.parse(data);
48
- } catch (e) {
49
- throw new Error('failed to parse json string: ' + data);
50
- }
51
- } else {
52
- throw new Error('failed to parse hex data');
53
- }
54
- }
55
-
56
- public binToJson(contractName: string, type: string, buffer: Buffer): any {
57
- const data = Abieos.native.bin_to_json(contractName, type, buffer);
58
- if (data[0] === '{' || data[0] === '[') {
59
- try {
60
- return JSON.parse(data);
61
- } catch (e) {
62
- throw new Error('json parse error');
63
- }
64
- } else {
65
- throw new Error(data);
66
- }
67
- }
68
-
69
- public loadAbi(contractName: string, abi: string | object): boolean {
70
- if (typeof abi === 'string') {
71
- return Abieos.native.load_abi(contractName, abi) as boolean;
72
- } else {
73
- if (typeof abi === 'object') {
74
- return Abieos.native.load_abi(contractName, JSON.stringify(abi)) as boolean;
75
- } else {
76
- throw new Error('ABI must be a String or Object');
77
- }
78
- }
79
- }
80
-
81
- public loadAbiHex(contractName: string, abihex: string): boolean {
82
- return Abieos.native.load_abi_hex(contractName, abihex) as boolean;
83
- }
84
-
85
- public getTypeForAction(contractName: string, actionName: string): string {
86
- const result = Abieos.native.get_type_for_action(contractName, actionName);
87
- if (result === 'NOT_FOUND') {
88
- throw new Error('action ' + actionName + ' not found on contract ' + contractName);
89
- } else {
90
- return result;
91
- }
92
- }
93
-
94
- public getTypeForTable(contractName: string, table_name: string): string {
95
- const result = Abieos.native.get_type_for_table(contractName, table_name);
96
- if (result === 'NOT_FOUND') {
97
- throw new Error('table ' + table_name + ' not found on contract ' + contractName);
98
- } else {
99
- return result;
100
- }
101
- }
102
-
103
- public deleteContract(contractName: string): boolean {
104
- return Abieos.native.delete_contract(contractName) as boolean;
105
- }
106
- }
1
+ const abieos = require("./abieos.node");
2
+
3
+ export class Abieos {
4
+ private static instance: Abieos;
5
+ public static native: typeof abieos;
6
+
7
+ private constructor() {
8
+ Abieos.native = abieos;
9
+ }
10
+
11
+ public static getInstance(): Abieos {
12
+ if (!Abieos.instance) {
13
+ Abieos.instance = new Abieos();
14
+ }
15
+ return Abieos.instance;
16
+ }
17
+
18
+ public stringToName(nameString: string): BigInteger {
19
+ return Abieos.native.string_to_name(nameString) as BigInteger;
20
+ }
21
+
22
+ public jsonToHex(contractName: string, type: string, json: string | object): string {
23
+ const jsonData = typeof json === 'object' ? JSON.stringify(json) : json
24
+ const data: string = Abieos.native.json_to_hex(contractName, type, jsonData);
25
+ if (data === 'PARSING_ERROR') {
26
+ throw new Error('failed to parse data');
27
+ } else {
28
+ return data;
29
+ }
30
+ }
31
+
32
+ public hexToJson(contractName: string, type: string, hex: string): any {
33
+ const data = Abieos.native.hex_to_json(contractName, type, hex);
34
+ if (data) {
35
+ try {
36
+ return JSON.parse(data);
37
+ } catch (e) {
38
+ throw new Error('failed to parse json string: ' + data);
39
+ }
40
+ } else {
41
+ throw new Error('failed to parse hex data');
42
+ }
43
+ }
44
+
45
+ public binToJson(contractName: string, type: string, buffer: Buffer): any {
46
+ const data = Abieos.native.bin_to_json(contractName, type, buffer);
47
+ if (data[0] === '{' || data[0] === '[') {
48
+ try {
49
+ return JSON.parse(data);
50
+ } catch (e) {
51
+ throw new Error('json parse error');
52
+ }
53
+ } else {
54
+ throw new Error(data);
55
+ }
56
+ }
57
+
58
+ public loadAbi(contractName: string, abi: string | object): boolean {
59
+ if (typeof abi === 'string') {
60
+ return Abieos.native.load_abi(contractName, abi) as boolean;
61
+ } else {
62
+ if (typeof abi === 'object') {
63
+ return Abieos.native.load_abi(contractName, JSON.stringify(abi)) as boolean;
64
+ } else {
65
+ throw new Error('ABI must be a String or Object');
66
+ }
67
+ }
68
+ }
69
+
70
+ public loadAbiHex(contractName: string, abihex: string): boolean {
71
+ return Abieos.native.load_abi_hex(contractName, abihex) as boolean;
72
+ }
73
+
74
+ public getTypeForAction(contractName: string, actionName: string): string {
75
+ const result = Abieos.native.get_type_for_action(contractName, actionName);
76
+ if (result === 'NOT_FOUND') {
77
+ throw new Error('action ' + actionName + ' not found on contract ' + contractName);
78
+ } else {
79
+ return result;
80
+ }
81
+ }
82
+
83
+ public getTypeForTable(contractName: string, table_name: string): string {
84
+ const result = Abieos.native.get_type_for_table(contractName, table_name);
85
+ if (result === 'NOT_FOUND') {
86
+ throw new Error('table ' + table_name + ' not found on contract ' + contractName);
87
+ } else {
88
+ return result;
89
+ }
90
+ }
91
+
92
+ public deleteContract(contractName: string): boolean {
93
+ return Abieos.native.delete_contract(contractName) as boolean;
94
+ }
95
+ }
package/package.json CHANGED
@@ -1,36 +1,51 @@
1
- {
2
- "name": "@eosrio/node-abieos",
3
- "version": "3.2.0",
4
- "description": "Node Bindings for abieos: Binary <> JSON conversion using ABIs.",
5
- "main": "./lib/abieos.js",
6
- "typings": "./lib/abieos.d.ts",
7
- "scripts": {
8
- "install": "node -e 'process.exit(0)'",
9
- "test": "cd examples && node basic.js",
10
- "tsc:watch": "tsc --watch",
11
- "build:linux": "cmake-js compile --cc /usr/bin/clang --cxx /usr/bin/clang++ && cp build/Release/node_abieos.node dist/abieos.node",
12
- "build:win": "cmake-js"
13
- },
14
- "type": "module",
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/eosrio/node-abieos.git"
18
- },
19
- "author": "EOS Rio",
20
- "license": "MIT",
21
- "bugs": {
22
- "url": "https://github.com/eosrio/node-abieos/issues"
23
- },
24
- "homepage": "https://github.com/eosrio/node-abieos#readme",
25
- "devDependencies": {
26
- "node-addon-api": "^5.0.0",
27
- "cmake-js": "^7.0.0",
28
- "@types/node": "^18.11.0",
29
- "typescript": "^4.8.4"
30
- },
31
- "cmake-js": {
32
- "runtime": "node",
33
- "runtimeVersion": "18.0.0",
34
- "arch": "x64"
35
- }
36
- }
1
+ {
2
+ "name": "@eosrio/node-abieos",
3
+ "version": "3.3.0",
4
+ "description": "Node Bindings for abieos: Binary <> JSON conversion using ABIs.",
5
+ "main": "./lib/abieos.js",
6
+ "types": "./lib/abieos.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./lib/abieos.js",
10
+ "types": "./lib/abieos.d.ts"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "install": "node -e 'process.exit(0)'",
15
+ "test": "cd examples && node basic.mjs",
16
+ "tsc:watch": "tsc --watch",
17
+ "clean": "cmake-js clean",
18
+ "bundle": "tsup lib/abieos.ts --format cjs,esm --dts --clean",
19
+ "build:tsc": "tsc",
20
+ "build:linux": "cmake-js compile --cc /usr/bin/clang-18 --cxx /usr/bin/clang++-18 && cp build/Release/node_abieos.node lib/abieos.node",
21
+ "build:linux:ci": "cmake-js compile && cp build/Release/node_abieos.node lib/abieos.node",
22
+ "build:win": "cmake-js"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/eosrio/node-abieos.git"
27
+ },
28
+ "author": "EOS Rio",
29
+ "license": "MIT",
30
+ "bugs": {
31
+ "url": "https://github.com/eosrio/node-abieos/issues"
32
+ },
33
+ "homepage": "https://github.com/eosrio/node-abieos#readme",
34
+ "devDependencies": {
35
+ "@types/node": "20.12.7",
36
+ "cmake-js": "7.3.0",
37
+ "node-addon-api": "8.0.0",
38
+ "tsup": "^8.0.2",
39
+ "typescript": "5.4.5"
40
+ },
41
+ "binary": {
42
+ "napi_versions": [
43
+ 9
44
+ ]
45
+ },
46
+ "cmake-js": {
47
+ "runtime": "node",
48
+ "runtimeVersion": "20.0.0",
49
+ "arch": "x64"
50
+ }
51
+ }
package/dist/abieos.node DELETED
Binary file