@eosrio/node-abieos 2.2.0 → 3.1.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/dist/abieos.node CHANGED
Binary file
package/lib/abieos.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- /// <reference types="node" />
2
- declare let abieos: any | null;
3
- export declare class Abieos {
4
- private static instance;
5
- static native: typeof abieos;
6
- private constructor();
7
- static getInstance(): Abieos;
8
- stringToName(nameString: string): BigInteger;
9
- jsonToHex(contractName: string, type: string, json: string | object): string;
10
- hexToJson(contractName: string, type: string, hex: string): string;
11
- binToJson(contractName: string, type: string, buffer: Buffer): string;
12
- loadAbi(contractName: string, abi: string | object): boolean;
13
- loadAbiHex(contractName: string, abihex: string): boolean;
14
- getTypeForAction(contractName: string, actionName: string): string;
15
- getTypeForTable(contractName: string, table_name: string): string;
16
- deleteContract(contractName: string): boolean;
17
- }
18
- export {};
1
+ /// <reference types="node" />
2
+ declare let abieos: any | null;
3
+ export declare class Abieos {
4
+ private static instance;
5
+ static native: typeof abieos;
6
+ private constructor();
7
+ static getInstance(): Abieos;
8
+ stringToName(nameString: string): BigInteger;
9
+ jsonToHex(contractName: string, type: string, json: string | object): string;
10
+ hexToJson(contractName: string, type: string, hex: string): string;
11
+ binToJson(contractName: string, type: string, buffer: Buffer): string;
12
+ loadAbi(contractName: string, abi: string | object): boolean;
13
+ loadAbiHex(contractName: string, abihex: string): boolean;
14
+ getTypeForAction(contractName: string, actionName: string): string;
15
+ getTypeForTable(contractName: string, table_name: string): string;
16
+ deleteContract(contractName: string): boolean;
17
+ }
18
+ export {};
19
19
  //# sourceMappingURL=abieos.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abieos.d.ts","sourceRoot":"","sources":["abieos.ts"],"names":[],"mappings":";AAMA,QAAA,IAAI,MAAM,EAAE,GAAG,GAAG,IAAW,CAAC;AAQ9B,qBAAa,MAAM;IACf,OAAO,CAAC,MAAM,CAAC,QAA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E,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAalE,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAarE,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,100 +1,100 @@
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 {
13
- constructor() {
14
- Abieos.native = abieos;
15
- }
16
- static getInstance() {
17
- if (!Abieos.instance) {
18
- Abieos.instance = new Abieos();
19
- }
20
- return Abieos.instance;
21
- }
22
- stringToName(nameString) {
23
- return Abieos.native.string_to_name(nameString);
24
- }
25
- jsonToHex(contractName, type, json) {
26
- const jsonData = typeof json === 'object' ? JSON.stringify(json) : json;
27
- const data = Abieos.native.json_to_hex(contractName, type, jsonData);
28
- if (data === 'PARSING_ERROR') {
29
- throw new Error('failed to parse data');
30
- }
31
- else {
32
- return data;
33
- }
34
- }
35
- hexToJson(contractName, type, hex) {
36
- const data = Abieos.native.hex_to_json(contractName, type, hex);
37
- if (data) {
38
- try {
39
- return JSON.parse(data);
40
- }
41
- catch (e) {
42
- throw new Error('failed to parse json string: ' + data);
43
- }
44
- }
45
- else {
46
- throw new Error('failed to parse hex data');
47
- }
48
- }
49
- binToJson(contractName, type, buffer) {
50
- const data = Abieos.native.bin_to_json(contractName, type, buffer);
51
- if (data[0] === '{' || data[0] === '[') {
52
- try {
53
- return JSON.parse(data);
54
- }
55
- catch (e) {
56
- throw new Error('json parse error');
57
- }
58
- }
59
- else {
60
- throw new Error(data);
61
- }
62
- }
63
- loadAbi(contractName, abi) {
64
- if (typeof abi === 'string') {
65
- return Abieos.native.load_abi(contractName, abi);
66
- }
67
- else {
68
- if (typeof abi === 'object') {
69
- return Abieos.native.load_abi(contractName, JSON.stringify(abi));
70
- }
71
- else {
72
- throw new Error('ABI must be a String or Object');
73
- }
74
- }
75
- }
76
- loadAbiHex(contractName, abihex) {
77
- return Abieos.native.load_abi_hex(contractName, abihex);
78
- }
79
- getTypeForAction(contractName, actionName) {
80
- const result = Abieos.native.get_type_for_action(contractName, actionName);
81
- if (result === 'NOT_FOUND') {
82
- throw new Error('action ' + actionName + ' not found on contract ' + contractName);
83
- }
84
- else {
85
- return result;
86
- }
87
- }
88
- getTypeForTable(contractName, table_name) {
89
- const result = Abieos.native.get_type_for_table(contractName, table_name);
90
- if (result === 'NOT_FOUND') {
91
- throw new Error('table ' + table_name + ' not found on contract ' + contractName);
92
- }
93
- else {
94
- return result;
95
- }
96
- }
97
- deleteContract(contractName) {
98
- return Abieos.native.delete_contract(contractName);
99
- }
100
- }
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 {
13
+ constructor() {
14
+ Abieos.native = abieos;
15
+ }
16
+ static getInstance() {
17
+ if (!Abieos.instance) {
18
+ Abieos.instance = new Abieos();
19
+ }
20
+ return Abieos.instance;
21
+ }
22
+ stringToName(nameString) {
23
+ return Abieos.native.string_to_name(nameString);
24
+ }
25
+ jsonToHex(contractName, type, json) {
26
+ const jsonData = typeof json === 'object' ? JSON.stringify(json) : json;
27
+ const data = Abieos.native.json_to_hex(contractName, type, jsonData);
28
+ if (data === 'PARSING_ERROR') {
29
+ throw new Error('failed to parse data');
30
+ }
31
+ else {
32
+ return data;
33
+ }
34
+ }
35
+ hexToJson(contractName, type, hex) {
36
+ const data = Abieos.native.hex_to_json(contractName, type, hex);
37
+ if (data) {
38
+ try {
39
+ return JSON.parse(data);
40
+ }
41
+ catch (e) {
42
+ throw new Error('failed to parse json string: ' + data);
43
+ }
44
+ }
45
+ else {
46
+ throw new Error('failed to parse hex data');
47
+ }
48
+ }
49
+ binToJson(contractName, type, buffer) {
50
+ const data = Abieos.native.bin_to_json(contractName, type, buffer);
51
+ if (data[0] === '{' || data[0] === '[') {
52
+ try {
53
+ return JSON.parse(data);
54
+ }
55
+ catch (e) {
56
+ throw new Error('json parse error');
57
+ }
58
+ }
59
+ else {
60
+ throw new Error(data);
61
+ }
62
+ }
63
+ loadAbi(contractName, abi) {
64
+ if (typeof abi === 'string') {
65
+ return Abieos.native.load_abi(contractName, abi);
66
+ }
67
+ else {
68
+ if (typeof abi === 'object') {
69
+ return Abieos.native.load_abi(contractName, JSON.stringify(abi));
70
+ }
71
+ else {
72
+ throw new Error('ABI must be a String or Object');
73
+ }
74
+ }
75
+ }
76
+ loadAbiHex(contractName, abihex) {
77
+ return Abieos.native.load_abi_hex(contractName, abihex);
78
+ }
79
+ getTypeForAction(contractName, actionName) {
80
+ const result = Abieos.native.get_type_for_action(contractName, actionName);
81
+ if (result === 'NOT_FOUND') {
82
+ throw new Error('action ' + actionName + ' not found on contract ' + contractName);
83
+ }
84
+ else {
85
+ return result;
86
+ }
87
+ }
88
+ getTypeForTable(contractName, table_name) {
89
+ const result = Abieos.native.get_type_for_table(contractName, table_name);
90
+ if (result === 'NOT_FOUND') {
91
+ throw new Error('table ' + table_name + ' not found on contract ' + contractName);
92
+ }
93
+ else {
94
+ return result;
95
+ }
96
+ }
97
+ deleteContract(contractName) {
98
+ return Abieos.native.delete_contract(contractName);
99
+ }
100
+ }
package/lib/abieos.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import {createRequire} from 'module';
2
- import {type} from "os";
3
2
 
4
3
  const require = createRequire(import.meta.url);
5
4
 
@@ -8,7 +7,7 @@ let abieos: any | null = null;
8
7
  if (process.platform === 'linux') {
9
8
  abieos = require(modulePath);
10
9
  } else if (process.platform === 'win32') {
11
- throw new Error(`${process.platform} is not supported by node-abieos`);
10
+ // throw new Error(`${process.platform} is not supported by node-abieos`);
12
11
  abieos = null;
13
12
  }
14
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eosrio/node-abieos",
3
- "version": "2.2.0",
3
+ "version": "3.1.0",
4
4
  "description": "Node Bindings for abieos: Binary <> JSON conversion using ABIs.",
5
5
  "main": "./lib/abieos.js",
6
6
  "typings": "./lib/abieos.d.ts",