@eosrio/node-abieos 3.3.2 → 3.3.4-a9d3362

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.
@@ -0,0 +1,2 @@
1
+ 0
2
+ 0
File without changes
@@ -0,0 +1,3 @@
1
+ 0
2
+ 0
3
+ 0
@@ -1 +1 @@
1
- (ssh://git@git.jetbrains.team/llvm/llvm-project.git eeb64a79f164f241d539c0a3f0491b50a854ead9 based on LLVM a01392cc95a03e97d8dc19cc3b3484daf9a4f19e revision)
1
+ (ssh://git@git.jetbrains.team/llvm/llvm-project.git f4157ca9dd49181f6d35eaf6d324ffa84a40f01b based on LLVM 31f1590e4fb324c43dc36199587c453e27b6f6fa revision)
package/.gitmodules CHANGED
@@ -1,3 +1,4 @@
1
- [submodule "abieos"]
2
- path = abieos
3
- url = https://github.com/AntelopeIO/abieos.git
1
+ [submodule "abieos"]
2
+ path = abieos
3
+ url = https://github.com/igorls/abieos.git
4
+ branch = main
package/README.md CHANGED
@@ -1,58 +1,59 @@
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
- ```
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/AntelopeIO/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 {Abieos} from "@eosrio/node-abieos";
36
+ const abieos = Abieos.getInstance();
37
+ ```
38
+
39
+ Check the [/examples](https://github.com/eosrio/node-abieos/tree/master/examples) folder for implementation examples
40
+
41
+ ### Building
42
+
43
+ Make sure you have Clang installed on your system:
44
+ We recommend using Clang 18 to build the `abieos` C++ library.
45
+
46
+ ```bash
47
+ wget https://apt.llvm.org/llvm.sh
48
+ chmod +x llvm.sh
49
+ sudo ./llvm.sh 18
50
+ ```
51
+
52
+ Clone and Build
53
+ ```shell script
54
+ git clone https://github.com/eosrio/node-abieos.git --recursive
55
+ cd node-abieos
56
+ npm install
57
+ npm run build:linux
58
+ npm run build
59
+ ```
@@ -1,9 +1,6 @@
1
- /// <reference types="node" />
2
- declare const abieos: any;
3
1
  export declare class Abieos {
4
2
  private static instance;
5
3
  static native: typeof abieos;
6
- private static instanceId;
7
4
  private constructor();
8
5
  static getInstance(): Abieos;
9
6
  stringToName(nameString: string): BigInteger;
@@ -16,5 +13,7 @@ export declare class Abieos {
16
13
  getTypeForTable(contractName: string, table_name: string): string;
17
14
  deleteContract(contractName: string): boolean;
18
15
  }
19
- export {};
20
- //# sourceMappingURL=abieos.d.ts.map
16
+
17
+ declare const abieos: any;
18
+
19
+ export { }
@@ -0,0 +1,19 @@
1
+ export declare class Abieos {
2
+ private static instance;
3
+ static native: typeof abieos;
4
+ private constructor();
5
+ static getInstance(): Abieos;
6
+ stringToName(nameString: string): BigInteger;
7
+ jsonToHex(contractName: string, type: string, json: string | object): string;
8
+ hexToJson(contractName: string, type: string, hex: string): any;
9
+ binToJson(contractName: string, type: string, buffer: Buffer): any;
10
+ loadAbi(contractName: string, abi: string | object): boolean;
11
+ loadAbiHex(contractName: string, abihex: string): boolean;
12
+ getTypeForAction(contractName: string, actionName: string): string;
13
+ getTypeForTable(contractName: string, table_name: string): string;
14
+ deleteContract(contractName: string): boolean;
15
+ }
16
+
17
+ declare const abieos: any;
18
+
19
+ export { }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // lib/abieos.ts
21
+ var abieos_exports = {};
22
+ __export(abieos_exports, {
23
+ Abieos: () => Abieos
24
+ });
25
+ module.exports = __toCommonJS(abieos_exports);
26
+
27
+ // node_modules/tsup/assets/cjs_shims.js
28
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
29
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
30
+
31
+ // lib/abieos.ts
32
+ var import_module = require("module");
33
+ var abieos = (0, import_module.createRequire)(importMetaUrl)("./abieos.node");
34
+ var Abieos = class _Abieos {
35
+ static instance;
36
+ static native;
37
+ constructor() {
38
+ if (_Abieos.instance) {
39
+ throw new Error("This class is a Singleton!");
40
+ }
41
+ _Abieos.native = abieos;
42
+ }
43
+ static getInstance() {
44
+ if (!_Abieos.instance) {
45
+ _Abieos.instance = new _Abieos();
46
+ }
47
+ return _Abieos.instance;
48
+ }
49
+ stringToName(nameString) {
50
+ return _Abieos.native.string_to_name(nameString);
51
+ }
52
+ jsonToHex(contractName, type, json) {
53
+ const jsonData = typeof json === "object" ? JSON.stringify(json) : json;
54
+ const data = _Abieos.native.json_to_hex(contractName, type, jsonData);
55
+ if (data === "PARSING_ERROR") {
56
+ throw new Error("failed to parse data");
57
+ } else {
58
+ return data;
59
+ }
60
+ }
61
+ hexToJson(contractName, type, hex) {
62
+ const data = _Abieos.native.hex_to_json(contractName, type, hex);
63
+ if (data) {
64
+ try {
65
+ return JSON.parse(data);
66
+ } catch (e) {
67
+ throw new Error("failed to parse json string: " + data);
68
+ }
69
+ } else {
70
+ throw new Error("failed to parse hex data");
71
+ }
72
+ }
73
+ binToJson(contractName, type, buffer) {
74
+ const data = _Abieos.native.bin_to_json(contractName, type, buffer);
75
+ if (data[0] === "{" || data[0] === "[") {
76
+ try {
77
+ return JSON.parse(data);
78
+ } catch (e) {
79
+ throw new Error("json parse error");
80
+ }
81
+ } else {
82
+ throw new Error(data);
83
+ }
84
+ }
85
+ loadAbi(contractName, abi) {
86
+ if (typeof abi === "string") {
87
+ return _Abieos.native.load_abi(contractName, abi);
88
+ } else {
89
+ if (typeof abi === "object") {
90
+ return _Abieos.native.load_abi(contractName, JSON.stringify(abi));
91
+ } else {
92
+ throw new Error("ABI must be a String or Object");
93
+ }
94
+ }
95
+ }
96
+ loadAbiHex(contractName, abihex) {
97
+ return _Abieos.native.load_abi_hex(contractName, abihex);
98
+ }
99
+ getTypeForAction(contractName, actionName) {
100
+ const result = _Abieos.native.get_type_for_action(contractName, actionName);
101
+ if (result === "NOT_FOUND") {
102
+ throw new Error(`[node-abieos] action ` + actionName + " not found on contract " + contractName);
103
+ } else {
104
+ return result;
105
+ }
106
+ }
107
+ getTypeForTable(contractName, table_name) {
108
+ const result = _Abieos.native.get_type_for_table(contractName, table_name);
109
+ if (result === "NOT_FOUND") {
110
+ throw new Error(`[node-abieos] table ` + table_name + " not found on contract " + contractName);
111
+ } else {
112
+ return result;
113
+ }
114
+ }
115
+ deleteContract(contractName) {
116
+ return _Abieos.native.delete_contract(contractName);
117
+ }
118
+ };
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ Abieos
122
+ });
@@ -0,0 +1 @@
1
+ export { Abieos } from './_tsup-dts-rollup.cjs';
@@ -0,0 +1 @@
1
+ export { Abieos } from './_tsup-dts-rollup.js';
package/dist/abieos.js ADDED
@@ -0,0 +1,91 @@
1
+ // lib/abieos.ts
2
+ import { createRequire } from "module";
3
+ var abieos = createRequire(import.meta.url)("./abieos.node");
4
+ var Abieos = class _Abieos {
5
+ static instance;
6
+ static native;
7
+ constructor() {
8
+ if (_Abieos.instance) {
9
+ throw new Error("This class is a Singleton!");
10
+ }
11
+ _Abieos.native = abieos;
12
+ }
13
+ static getInstance() {
14
+ if (!_Abieos.instance) {
15
+ _Abieos.instance = new _Abieos();
16
+ }
17
+ return _Abieos.instance;
18
+ }
19
+ stringToName(nameString) {
20
+ return _Abieos.native.string_to_name(nameString);
21
+ }
22
+ jsonToHex(contractName, type, json) {
23
+ const jsonData = typeof json === "object" ? JSON.stringify(json) : json;
24
+ const data = _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
+ hexToJson(contractName, type, hex) {
32
+ const data = _Abieos.native.hex_to_json(contractName, type, hex);
33
+ if (data) {
34
+ try {
35
+ return JSON.parse(data);
36
+ } catch (e) {
37
+ throw new Error("failed to parse json string: " + data);
38
+ }
39
+ } else {
40
+ throw new Error("failed to parse hex data");
41
+ }
42
+ }
43
+ binToJson(contractName, type, buffer) {
44
+ const data = _Abieos.native.bin_to_json(contractName, type, buffer);
45
+ if (data[0] === "{" || data[0] === "[") {
46
+ try {
47
+ return JSON.parse(data);
48
+ } catch (e) {
49
+ throw new Error("json parse error");
50
+ }
51
+ } else {
52
+ throw new Error(data);
53
+ }
54
+ }
55
+ loadAbi(contractName, abi) {
56
+ if (typeof abi === "string") {
57
+ return _Abieos.native.load_abi(contractName, abi);
58
+ } else {
59
+ if (typeof abi === "object") {
60
+ return _Abieos.native.load_abi(contractName, JSON.stringify(abi));
61
+ } else {
62
+ throw new Error("ABI must be a String or Object");
63
+ }
64
+ }
65
+ }
66
+ loadAbiHex(contractName, abihex) {
67
+ return _Abieos.native.load_abi_hex(contractName, abihex);
68
+ }
69
+ getTypeForAction(contractName, actionName) {
70
+ const result = _Abieos.native.get_type_for_action(contractName, actionName);
71
+ if (result === "NOT_FOUND") {
72
+ throw new Error(`[node-abieos] action ` + actionName + " not found on contract " + contractName);
73
+ } else {
74
+ return result;
75
+ }
76
+ }
77
+ getTypeForTable(contractName, table_name) {
78
+ const result = _Abieos.native.get_type_for_table(contractName, table_name);
79
+ if (result === "NOT_FOUND") {
80
+ throw new Error(`[node-abieos] table ` + table_name + " not found on contract " + contractName);
81
+ } else {
82
+ return result;
83
+ }
84
+ }
85
+ deleteContract(contractName) {
86
+ return _Abieos.native.delete_contract(contractName);
87
+ }
88
+ };
89
+ export {
90
+ Abieos
91
+ };
Binary file
package/dist/abieos.ts ADDED
@@ -0,0 +1,100 @@
1
+ import { createRequire } from "module";
2
+ const abieos = createRequire(import.meta.url)('./abieos.node');
3
+
4
+ export class Abieos {
5
+
6
+ private static instance: Abieos;
7
+ public static native: typeof abieos;
8
+
9
+ private constructor() {
10
+ if (Abieos.instance) {
11
+ throw new Error("This class is a Singleton!");
12
+ }
13
+ Abieos.native = abieos;
14
+ }
15
+
16
+ public static getInstance(): Abieos {
17
+ if (!Abieos.instance) {
18
+ Abieos.instance = new Abieos();
19
+ }
20
+ return Abieos.instance;
21
+ }
22
+
23
+ public stringToName(nameString: string): BigInteger {
24
+ return Abieos.native.string_to_name(nameString) as BigInteger;
25
+ }
26
+
27
+ public jsonToHex(contractName: string, type: string, json: string | object): string {
28
+ const jsonData = typeof json === 'object' ? JSON.stringify(json) : json
29
+ const data: string = Abieos.native.json_to_hex(contractName, type, jsonData);
30
+ if (data === 'PARSING_ERROR') {
31
+ throw new Error('failed to parse data');
32
+ } else {
33
+ return data;
34
+ }
35
+ }
36
+
37
+ public hexToJson(contractName: string, type: string, hex: string): any {
38
+ const data = Abieos.native.hex_to_json(contractName, type, hex);
39
+ if (data) {
40
+ try {
41
+ return JSON.parse(data);
42
+ } catch (e) {
43
+ throw new Error('failed to parse json string: ' + data);
44
+ }
45
+ } else {
46
+ throw new Error('failed to parse hex data');
47
+ }
48
+ }
49
+
50
+ public binToJson(contractName: string, type: string, buffer: Buffer): any {
51
+ const data = Abieos.native.bin_to_json(contractName, type, buffer);
52
+ if (data[0] === '{' || data[0] === '[') {
53
+ try {
54
+ return JSON.parse(data);
55
+ } catch (e) {
56
+ throw new Error('json parse error');
57
+ }
58
+ } else {
59
+ throw new Error(data);
60
+ }
61
+ }
62
+
63
+ public loadAbi(contractName: string, abi: string | object): boolean {
64
+ if (typeof abi === 'string') {
65
+ return Abieos.native.load_abi(contractName, abi) as boolean;
66
+ } else {
67
+ if (typeof abi === 'object') {
68
+ return Abieos.native.load_abi(contractName, JSON.stringify(abi)) as boolean;
69
+ } else {
70
+ throw new Error('ABI must be a String or Object');
71
+ }
72
+ }
73
+ }
74
+
75
+ public loadAbiHex(contractName: string, abihex: string): boolean {
76
+ return Abieos.native.load_abi_hex(contractName, abihex) as boolean;
77
+ }
78
+
79
+ public getTypeForAction(contractName: string, actionName: string): string {
80
+ const result = Abieos.native.get_type_for_action(contractName, actionName);
81
+ if (result === 'NOT_FOUND') {
82
+ throw new Error(`[node-abieos] action ` + actionName + ' not found on contract ' + contractName);
83
+ } else {
84
+ return result;
85
+ }
86
+ }
87
+
88
+ public getTypeForTable(contractName: string, table_name: string): string {
89
+ const result = Abieos.native.get_type_for_table(contractName, table_name);
90
+ if (result === 'NOT_FOUND') {
91
+ throw new Error(`[node-abieos] table ` + table_name + ' not found on contract ' + contractName);
92
+ } else {
93
+ return result;
94
+ }
95
+ }
96
+
97
+ public deleteContract(contractName: string): boolean {
98
+ return Abieos.native.delete_contract(contractName) as boolean;
99
+ }
100
+ }
package/lib/abieos.node CHANGED
Binary file
package/lib/abieos.ts CHANGED
@@ -1,101 +1,100 @@
1
- const abieos = require("./abieos.node");
2
- const {randomUUID} = require("node:crypto");
3
-
4
- export class Abieos {
5
- private static instance: Abieos;
6
- public static native: typeof abieos;
7
- private static instanceId: any;
8
-
9
- private constructor() {
10
- if (Abieos.instance) {
11
- throw new Error("This class is a Singleton!");
12
- }
13
- Abieos.native = abieos;
14
- Abieos.instanceId = randomUUID();
15
- }
16
-
17
- public static getInstance(): Abieos {
18
- if (!Abieos.instance) {
19
- Abieos.instance = new Abieos();
20
- }
21
- return Abieos.instance;
22
- }
23
-
24
- public stringToName(nameString: string): BigInteger {
25
- return Abieos.native.string_to_name(nameString) as BigInteger;
26
- }
27
-
28
- public jsonToHex(contractName: string, type: string, json: string | object): string {
29
- const jsonData = typeof json === 'object' ? JSON.stringify(json) : json
30
- const data: string = Abieos.native.json_to_hex(contractName, type, jsonData);
31
- if (data === 'PARSING_ERROR') {
32
- throw new Error('failed to parse data');
33
- } else {
34
- return data;
35
- }
36
- }
37
-
38
- public hexToJson(contractName: string, type: string, hex: string): any {
39
- const data = Abieos.native.hex_to_json(contractName, type, hex);
40
- if (data) {
41
- try {
42
- return JSON.parse(data);
43
- } catch (e) {
44
- throw new Error('failed to parse json string: ' + data);
45
- }
46
- } else {
47
- throw new Error('failed to parse hex data');
48
- }
49
- }
50
-
51
- public binToJson(contractName: string, type: string, buffer: Buffer): any {
52
- const data = Abieos.native.bin_to_json(contractName, type, buffer);
53
- if (data[0] === '{' || data[0] === '[') {
54
- try {
55
- return JSON.parse(data);
56
- } catch (e) {
57
- throw new Error('json parse error');
58
- }
59
- } else {
60
- throw new Error(data);
61
- }
62
- }
63
-
64
- public loadAbi(contractName: string, abi: string | object): boolean {
65
- if (typeof abi === 'string') {
66
- return Abieos.native.load_abi(contractName, abi) as boolean;
67
- } else {
68
- if (typeof abi === 'object') {
69
- return Abieos.native.load_abi(contractName, JSON.stringify(abi)) as boolean;
70
- } else {
71
- throw new Error('ABI must be a String or Object');
72
- }
73
- }
74
- }
75
-
76
- public loadAbiHex(contractName: string, abihex: string): boolean {
77
- return Abieos.native.load_abi_hex(contractName, abihex) as boolean;
78
- }
79
-
80
- public getTypeForAction(contractName: string, actionName: string): string {
81
- const result = Abieos.native.get_type_for_action(contractName, actionName);
82
- if (result === 'NOT_FOUND') {
83
- throw new Error(`[${Abieos.instanceId}] action ` + actionName + ' not found on contract ' + contractName);
84
- } else {
85
- return result;
86
- }
87
- }
88
-
89
- public getTypeForTable(contractName: string, table_name: string): string {
90
- const result = Abieos.native.get_type_for_table(contractName, table_name);
91
- if (result === 'NOT_FOUND') {
92
- throw new Error(`[${Abieos.instanceId}] table ` + table_name + ' not found on contract ' + contractName);
93
- } else {
94
- return result;
95
- }
96
- }
97
-
98
- public deleteContract(contractName: string): boolean {
99
- return Abieos.native.delete_contract(contractName) as boolean;
100
- }
1
+ import { createRequire } from "module";
2
+ const abieos = createRequire(import.meta.url)('./abieos.node');
3
+
4
+ export class Abieos {
5
+
6
+ private static instance: Abieos;
7
+ public static native: typeof abieos;
8
+
9
+ private constructor() {
10
+ if (Abieos.instance) {
11
+ throw new Error("This class is a Singleton!");
12
+ }
13
+ Abieos.native = abieos;
14
+ }
15
+
16
+ public static getInstance(): Abieos {
17
+ if (!Abieos.instance) {
18
+ Abieos.instance = new Abieos();
19
+ }
20
+ return Abieos.instance;
21
+ }
22
+
23
+ public stringToName(nameString: string): BigInteger {
24
+ return Abieos.native.string_to_name(nameString) as BigInteger;
25
+ }
26
+
27
+ public jsonToHex(contractName: string, type: string, json: string | object): string {
28
+ const jsonData = typeof json === 'object' ? JSON.stringify(json) : json
29
+ const data: string = Abieos.native.json_to_hex(contractName, type, jsonData);
30
+ if (data === 'PARSING_ERROR') {
31
+ throw new Error('failed to parse data');
32
+ } else {
33
+ return data;
34
+ }
35
+ }
36
+
37
+ public hexToJson(contractName: string, type: string, hex: string): any {
38
+ const data = Abieos.native.hex_to_json(contractName, type, hex);
39
+ if (data) {
40
+ try {
41
+ return JSON.parse(data);
42
+ } catch (e) {
43
+ throw new Error('failed to parse json string: ' + data);
44
+ }
45
+ } else {
46
+ throw new Error('failed to parse hex data');
47
+ }
48
+ }
49
+
50
+ public binToJson(contractName: string, type: string, buffer: Buffer): any {
51
+ const data = Abieos.native.bin_to_json(contractName, type, buffer);
52
+ if (data[0] === '{' || data[0] === '[') {
53
+ try {
54
+ return JSON.parse(data);
55
+ } catch (e) {
56
+ throw new Error('json parse error');
57
+ }
58
+ } else {
59
+ throw new Error(data);
60
+ }
61
+ }
62
+
63
+ public loadAbi(contractName: string, abi: string | object): boolean {
64
+ if (typeof abi === 'string') {
65
+ return Abieos.native.load_abi(contractName, abi) as boolean;
66
+ } else {
67
+ if (typeof abi === 'object') {
68
+ return Abieos.native.load_abi(contractName, JSON.stringify(abi)) as boolean;
69
+ } else {
70
+ throw new Error('ABI must be a String or Object');
71
+ }
72
+ }
73
+ }
74
+
75
+ public loadAbiHex(contractName: string, abihex: string): boolean {
76
+ return Abieos.native.load_abi_hex(contractName, abihex) as boolean;
77
+ }
78
+
79
+ public getTypeForAction(contractName: string, actionName: string): string {
80
+ const result = Abieos.native.get_type_for_action(contractName, actionName);
81
+ if (result === 'NOT_FOUND') {
82
+ throw new Error(`[node-abieos] action ` + actionName + ' not found on contract ' + contractName);
83
+ } else {
84
+ return result;
85
+ }
86
+ }
87
+
88
+ public getTypeForTable(contractName: string, table_name: string): string {
89
+ const result = Abieos.native.get_type_for_table(contractName, table_name);
90
+ if (result === 'NOT_FOUND') {
91
+ throw new Error(`[node-abieos] table ` + table_name + ' not found on contract ' + contractName);
92
+ } else {
93
+ return result;
94
+ }
95
+ }
96
+
97
+ public deleteContract(contractName: string): boolean {
98
+ return Abieos.native.delete_contract(contractName) as boolean;
99
+ }
101
100
  }
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@eosrio/node-abieos",
3
- "version": "3.3.2",
3
+ "version": "3.3.4-a9d3362",
4
4
  "description": "Node Bindings for abieos: Binary <> JSON conversion using ABIs.",
5
- "main": "./lib/abieos.js",
6
- "types": "./lib/abieos.d.ts",
5
+ "main": "./dist/abieos.js",
6
+ "types": "./dist/abieos.d.ts",
7
+ "type": "module",
7
8
  "exports": {
8
9
  ".": {
9
- "require": "./lib/abieos.js",
10
- "types": "./lib/abieos.d.ts"
10
+ "types": "./dist/abieos.d.ts",
11
+ "import": "./dist/abieos.js",
12
+ "require": "./dist/abieos.cjs"
11
13
  }
12
14
  },
13
15
  "scripts": {
@@ -15,11 +17,11 @@
15
17
  "test": "cd examples && node basic.mjs",
16
18
  "tsc:watch": "tsc --watch",
17
19
  "clean": "cmake-js clean",
18
- "bundle": "tsup lib/abieos.ts --format cjs,esm --dts --clean",
19
- "build:tsc": "tsc",
20
+ "build": "tsup",
20
21
  "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
22
  "build:linux:ci": "cmake-js compile && cp build/Release/node_abieos.node lib/abieos.node",
22
- "build:win": "cmake-js"
23
+ "build:win": "cmake-js",
24
+ "update_version": "node update-version.mjs"
23
25
  },
24
26
  "repository": {
25
27
  "type": "git",
@@ -32,11 +34,13 @@
32
34
  },
33
35
  "homepage": "https://github.com/eosrio/node-abieos#readme",
34
36
  "devDependencies": {
35
- "@types/node": "20.12.7",
37
+ "@microsoft/api-extractor": "7.47.11",
38
+ "@wharfkit/antelope": "^1.0.13",
39
+ "@types/node": "22.9.0",
36
40
  "cmake-js": "7.3.0",
37
- "node-addon-api": "8.0.0",
38
- "tsup": "^8.0.2",
39
- "typescript": "5.4.5"
41
+ "node-addon-api": "8.2.2",
42
+ "tsup": "^8.3.5",
43
+ "typescript": "5.6.3"
40
44
  },
41
45
  "binary": {
42
46
  "napi_versions": [
@@ -45,7 +49,7 @@
45
49
  },
46
50
  "cmake-js": {
47
51
  "runtime": "node",
48
- "runtimeVersion": "20.0.0",
52
+ "runtimeVersion": "22.0.0",
49
53
  "arch": "x64"
50
54
  }
51
- }
55
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: ["lib/abieos.ts"],
5
+ publicDir: "lib",
6
+ format: ["cjs", "esm"],
7
+ shims: true,
8
+ minify: false,
9
+ sourcemap: false,
10
+ clean: true,
11
+ experimentalDts: "lib/abieos.ts"
12
+ })
@@ -0,0 +1,31 @@
1
+ import {promises} from "node:fs";
2
+ import {exec} from "node:child_process";
3
+
4
+ const oldPackageJson = await promises.readFile('package.json', 'utf8');
5
+ if (!oldPackageJson) {
6
+ console.error('Failed to read package.json');
7
+ process.exit(1);
8
+ }
9
+
10
+ const parsed = JSON.parse(oldPackageJson.toString());
11
+ const [version, hash] = parsed.version.split('-');
12
+ console.log(`Old version: ${version}`);
13
+ console.log(`Old hash: ${hash}`);
14
+
15
+ exec('git rev-parse --short HEAD', {
16
+ cwd: './abieos',
17
+ }, (error, stdout) => {
18
+ if (error) {
19
+ console.error('Failed to get git hash');
20
+ process.exit(1);
21
+ }
22
+ console.log(`New hash: ${stdout.trim()}`);
23
+ const newVersion = `${version}-${stdout.trim()}`;
24
+ console.log(`New version: ${newVersion}`);
25
+ parsed.version = newVersion;
26
+ const newPackageJson = JSON.stringify(parsed, null, 2);
27
+ promises.writeFile('package.json', newPackageJson).catch((err) => {
28
+ console.error('Failed to write package.json');
29
+ process.exit(1);
30
+ });
31
+ });
@@ -1 +0,0 @@
1
- {"version":3,"file":"abieos.d.ts","sourceRoot":"","sources":["abieos.ts"],"names":[],"mappings":";AAAA,QAAA,MAAM,MAAM,KAA2B,CAAC;AAGxC,qBAAa,MAAM;IACf,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAS;IAChC,OAAc,MAAM,EAAE,OAAO,MAAM,CAAC;IACpC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAM;IAE/B,OAAO;WAQO,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 DELETED
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Abieos = void 0;
4
- const abieos = require("./abieos.node");
5
- const { randomUUID } = require("node:crypto");
6
- class Abieos {
7
- constructor() {
8
- if (Abieos.instance) {
9
- throw new Error("This class is a Singleton!");
10
- }
11
- Abieos.native = abieos;
12
- Abieos.instanceId = randomUUID();
13
- }
14
- static getInstance() {
15
- if (!Abieos.instance) {
16
- Abieos.instance = new Abieos();
17
- }
18
- return Abieos.instance;
19
- }
20
- stringToName(nameString) {
21
- return Abieos.native.string_to_name(nameString);
22
- }
23
- jsonToHex(contractName, type, json) {
24
- const jsonData = typeof json === 'object' ? JSON.stringify(json) : json;
25
- const data = Abieos.native.json_to_hex(contractName, type, jsonData);
26
- if (data === 'PARSING_ERROR') {
27
- throw new Error('failed to parse data');
28
- }
29
- else {
30
- return data;
31
- }
32
- }
33
- hexToJson(contractName, type, hex) {
34
- const data = Abieos.native.hex_to_json(contractName, type, hex);
35
- if (data) {
36
- try {
37
- return JSON.parse(data);
38
- }
39
- catch (e) {
40
- throw new Error('failed to parse json string: ' + data);
41
- }
42
- }
43
- else {
44
- throw new Error('failed to parse hex data');
45
- }
46
- }
47
- binToJson(contractName, type, buffer) {
48
- const data = Abieos.native.bin_to_json(contractName, type, buffer);
49
- if (data[0] === '{' || data[0] === '[') {
50
- try {
51
- return JSON.parse(data);
52
- }
53
- catch (e) {
54
- throw new Error('json parse error');
55
- }
56
- }
57
- else {
58
- throw new Error(data);
59
- }
60
- }
61
- loadAbi(contractName, abi) {
62
- if (typeof abi === 'string') {
63
- return Abieos.native.load_abi(contractName, abi);
64
- }
65
- else {
66
- if (typeof abi === 'object') {
67
- return Abieos.native.load_abi(contractName, JSON.stringify(abi));
68
- }
69
- else {
70
- throw new Error('ABI must be a String or Object');
71
- }
72
- }
73
- }
74
- loadAbiHex(contractName, abihex) {
75
- return Abieos.native.load_abi_hex(contractName, abihex);
76
- }
77
- getTypeForAction(contractName, actionName) {
78
- const result = Abieos.native.get_type_for_action(contractName, actionName);
79
- if (result === 'NOT_FOUND') {
80
- throw new Error(`[${Abieos.instanceId}] action ` + actionName + ' not found on contract ' + contractName);
81
- }
82
- else {
83
- return result;
84
- }
85
- }
86
- getTypeForTable(contractName, table_name) {
87
- const result = Abieos.native.get_type_for_table(contractName, table_name);
88
- if (result === 'NOT_FOUND') {
89
- throw new Error(`[${Abieos.instanceId}] table ` + table_name + ' not found on contract ' + contractName);
90
- }
91
- else {
92
- return result;
93
- }
94
- }
95
- deleteContract(contractName) {
96
- return Abieos.native.delete_contract(contractName);
97
- }
98
- }
99
- exports.Abieos = Abieos;