@eosrio/node-abieos 3.1.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.
- package/.cache/jb/UpdateWork.dat +0 -0
- package/.cache/jb/version.txt +1 -0
- package/.github/workflows/build.yml +34 -0
- package/.gitmodules +3 -0
- package/README.md +58 -46
- package/bun.lockb +0 -0
- package/lib/abieos.d.ts +3 -3
- package/lib/abieos.d.ts.map +1 -1
- package/lib/abieos.js +6 -12
- package/lib/abieos.node +0 -0
- package/lib/abieos.ts +95 -106
- package/package.json +51 -36
- package/dist/abieos.node +0 -0
|
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
package/README.md
CHANGED
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
# node-abieos
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
# node-abieos
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](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
|
|
2
|
+
declare const abieos: any;
|
|
3
3
|
export declare class Abieos {
|
|
4
4
|
private static instance;
|
|
5
5
|
static native: typeof abieos;
|
|
@@ -7,8 +7,8 @@ export declare class Abieos {
|
|
|
7
7
|
static getInstance(): Abieos;
|
|
8
8
|
stringToName(nameString: string): BigInteger;
|
|
9
9
|
jsonToHex(contractName: string, type: string, json: string | object): string;
|
|
10
|
-
hexToJson(contractName: string, type: string, hex: string):
|
|
11
|
-
binToJson(contractName: string, type: string, buffer: Buffer):
|
|
10
|
+
hexToJson(contractName: string, type: string, hex: string): any;
|
|
11
|
+
binToJson(contractName: string, type: string, buffer: Buffer): any;
|
|
12
12
|
loadAbi(contractName: string, abi: string | object): boolean;
|
|
13
13
|
loadAbiHex(contractName: string, abihex: string): boolean;
|
|
14
14
|
getTypeForAction(contractName: string, actionName: string): string;
|
package/lib/abieos.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abieos.d.ts","sourceRoot":"","sources":["abieos.ts"],"names":[],"mappings":";
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
package/lib/abieos.node
ADDED
|
Binary file
|
package/lib/abieos.ts
CHANGED
|
@@ -1,106 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Abieos.native
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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.
|
|
4
|
-
"description": "Node Bindings for abieos: Binary <> JSON conversion using ABIs.",
|
|
5
|
-
"main": "./lib/abieos.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|