@eosrio/node-abieos 2.1.1 → 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.
Files changed (99) hide show
  1. package/README.md +4 -1
  2. package/dist/abieos.node +0 -0
  3. package/lib/abieos.d.ts +19 -0
  4. package/lib/abieos.d.ts.map +1 -0
  5. package/lib/abieos.js +100 -0
  6. package/lib/abieos.ts +106 -0
  7. package/package.json +13 -8
  8. package/.idea/modules.xml +0 -8
  9. package/.idea/node-abieos.iml +0 -12
  10. package/.idea/vcs.xml +0 -9
  11. package/.idea/workspace.xml +0 -66
  12. package/CMakeLists.txt +0 -35
  13. package/abieos.d.ts +0 -21
  14. package/abieos.js +0 -59
  15. package/eosio.json +0 -1596
  16. package/include/.clang-format +0 -76
  17. package/include/eosio/abi.hpp +0 -393
  18. package/include/eosio/asset.hpp +0 -458
  19. package/include/eosio/bytes.hpp +0 -27
  20. package/include/eosio/chain_conversions.hpp +0 -450
  21. package/include/eosio/chain_types.hpp +0 -14
  22. package/include/eosio/check.hpp +0 -178
  23. package/include/eosio/convert.hpp +0 -95
  24. package/include/eosio/crypto.hpp +0 -148
  25. package/include/eosio/eosio_outcome.hpp +0 -41
  26. package/include/eosio/fixed_bytes.hpp +0 -250
  27. package/include/eosio/float.hpp +0 -35
  28. package/include/eosio/for_each_field.hpp +0 -48
  29. package/include/eosio/fpconv.c +0 -336
  30. package/include/eosio/fpconv.h +0 -41
  31. package/include/eosio/fpconv.license +0 -23
  32. package/include/eosio/from_bin.hpp +0 -272
  33. package/include/eosio/from_json.hpp +0 -749
  34. package/include/eosio/from_string.hpp +0 -28
  35. package/include/eosio/map_macro.h +0 -64
  36. package/include/eosio/murmur.hpp +0 -55
  37. package/include/eosio/name.hpp +0 -178
  38. package/include/eosio/opaque.hpp +0 -184
  39. package/include/eosio/operators.hpp +0 -71
  40. package/include/eosio/powers.h +0 -76
  41. package/include/eosio/reflection.hpp +0 -61
  42. package/include/eosio/ship_protocol.hpp +0 -971
  43. package/include/eosio/stream.hpp +0 -235
  44. package/include/eosio/symbol.hpp +0 -300
  45. package/include/eosio/time.hpp +0 -264
  46. package/include/eosio/to_bin.hpp +0 -189
  47. package/include/eosio/to_json.hpp +0 -334
  48. package/include/eosio/to_key.hpp +0 -305
  49. package/include/eosio/types.hpp +0 -103
  50. package/include/eosio/varint.hpp +0 -452
  51. package/include/outcome-basic.hpp +0 -6836
  52. package/include/rapidjson/allocators.h +0 -284
  53. package/include/rapidjson/cursorstreamwrapper.h +0 -78
  54. package/include/rapidjson/document.h +0 -2646
  55. package/include/rapidjson/encodedstream.h +0 -299
  56. package/include/rapidjson/encodings.h +0 -716
  57. package/include/rapidjson/error/en.h +0 -74
  58. package/include/rapidjson/error/error.h +0 -161
  59. package/include/rapidjson/filereadstream.h +0 -99
  60. package/include/rapidjson/filewritestream.h +0 -104
  61. package/include/rapidjson/fwd.h +0 -151
  62. package/include/rapidjson/internal/biginteger.h +0 -290
  63. package/include/rapidjson/internal/diyfp.h +0 -271
  64. package/include/rapidjson/internal/dtoa.h +0 -245
  65. package/include/rapidjson/internal/ieee754.h +0 -78
  66. package/include/rapidjson/internal/itoa.h +0 -308
  67. package/include/rapidjson/internal/meta.h +0 -186
  68. package/include/rapidjson/internal/pow10.h +0 -55
  69. package/include/rapidjson/internal/regex.h +0 -732
  70. package/include/rapidjson/internal/stack.h +0 -231
  71. package/include/rapidjson/internal/strfunc.h +0 -69
  72. package/include/rapidjson/internal/strtod.h +0 -290
  73. package/include/rapidjson/internal/swap.h +0 -46
  74. package/include/rapidjson/istreamwrapper.h +0 -113
  75. package/include/rapidjson/memorybuffer.h +0 -70
  76. package/include/rapidjson/memorystream.h +0 -71
  77. package/include/rapidjson/msinttypes/inttypes.h +0 -316
  78. package/include/rapidjson/msinttypes/stdint.h +0 -300
  79. package/include/rapidjson/ostreamwrapper.h +0 -81
  80. package/include/rapidjson/pointer.h +0 -1357
  81. package/include/rapidjson/prettywriter.h +0 -277
  82. package/include/rapidjson/rapidjson.h +0 -654
  83. package/include/rapidjson/reader.h +0 -2230
  84. package/include/rapidjson/schema.h +0 -2494
  85. package/include/rapidjson/stream.h +0 -223
  86. package/include/rapidjson/stringbuffer.h +0 -121
  87. package/include/rapidjson/writer.h +0 -710
  88. package/src/abi.cpp +0 -274
  89. package/src/abieos.cpp +0 -334
  90. package/src/abieos.h +0 -91
  91. package/src/abieos.hpp +0 -1011
  92. package/src/abieos_exception.hpp +0 -89
  93. package/src/abieos_numeric.hpp +0 -94
  94. package/src/abieos_ripemd160.hpp +0 -417
  95. package/src/crypto.cpp +0 -215
  96. package/src/main.cpp +0 -242
  97. package/src/ship.abi.cpp +0 -695
  98. package/tools/CMakeLists.txt +0 -9
  99. package/tools/name.cpp +0 -86
package/README.md CHANGED
@@ -39,5 +39,8 @@ env setup instructions soon
39
39
  ```shell script
40
40
  git clone https://github.com/eosrio/node-abieos.git
41
41
  cd node-abieos
42
- npm run build
42
+ # linux
43
+ npm run build:linux
44
+ # windows
45
+ npm run build:win
43
46
  ```
package/dist/abieos.node CHANGED
Binary file
@@ -0,0 +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 {};
19
+ //# sourceMappingURL=abieos.d.ts.map
@@ -0,0 +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,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 ADDED
@@ -0,0 +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
+ }
package/lib/abieos.ts ADDED
@@ -0,0 +1,106 @@
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): string {
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): string {
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
+ }
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@eosrio/node-abieos",
3
- "version": "2.1.1",
3
+ "version": "3.1.0",
4
4
  "description": "Node Bindings for abieos: Binary <> JSON conversion using ABIs.",
5
- "main": "abieos.js",
6
- "typings": "abieos.d.ts",
5
+ "main": "./lib/abieos.js",
6
+ "typings": "./lib/abieos.d.ts",
7
7
  "scripts": {
8
8
  "install": "node -e 'process.exit(0)'",
9
- "build": "cmake-js compile --cc /usr/bin/clang --cxx /usr/bin/clang++ && cp build/Release/node_abieos.node dist/abieos.node"
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"
10
13
  },
14
+ "type": "module",
11
15
  "repository": {
12
16
  "type": "git",
13
17
  "url": "git+https://github.com/eosrio/node-abieos.git"
@@ -19,13 +23,14 @@
19
23
  },
20
24
  "homepage": "https://github.com/eosrio/node-abieos#readme",
21
25
  "devDependencies": {
22
- "node-addon-api": "^3.2.1",
23
- "cmake-js": "^6.1.0",
24
- "@types/node": "^15.12.2"
26
+ "node-addon-api": "^5.0.0",
27
+ "cmake-js": "^7.0.0",
28
+ "@types/node": "^18.11.0",
29
+ "typescript": "^4.8.4"
25
30
  },
26
31
  "cmake-js": {
27
32
  "runtime": "node",
28
- "runtimeVersion": "16.0.0",
33
+ "runtimeVersion": "18.0.0",
29
34
  "arch": "x64"
30
35
  }
31
36
  }
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/node-abieos.iml" filepath="$PROJECT_DIR$/.idea/node-abieos.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/temp" />
6
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- </content>
9
- <orderEntry type="inheritedJdk" />
10
- <orderEntry type="sourceFolder" forTests="false" />
11
- </component>
12
- </module>
package/.idea/vcs.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- <mapping directory="$PROJECT_DIR$/external/date" vcs="Git" />
6
- <mapping directory="$PROJECT_DIR$/external/rapidjson" vcs="Git" />
7
- <mapping directory="$PROJECT_DIR$/external/rapidjson/thirdparty/gtest" vcs="Git" />
8
- </component>
9
- </project>
@@ -1,66 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ChangeListManager">
4
- <list default="true" id="24cd1727-69ec-448f-8093-325f7373674c" name="Changes" comment="">
5
- <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
6
- </list>
7
- <option name="SHOW_DIALOG" value="false" />
8
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
9
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
10
- <option name="LAST_RESOLUTION" value="IGNORE" />
11
- </component>
12
- <component name="Git.Settings">
13
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
14
- <option name="ROOT_SYNC" value="DONT_SYNC" />
15
- </component>
16
- <component name="MacroExpansionManager">
17
- <option name="directoryName" value="p126c0rw" />
18
- </component>
19
- <component name="ProjectId" id="1tcablyCLJIu0scVOq9ZAxLEPB7" />
20
- <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
21
- <component name="ProjectViewState">
22
- <option name="hideEmptyMiddlePackages" value="true" />
23
- <option name="showLibraryContents" value="true" />
24
- </component>
25
- <component name="PropertiesComponent">
26
- <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
27
- <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
28
- <property name="WebServerToolWindowFactoryState" value="false" />
29
- <property name="last_opened_file_path" value="$PROJECT_DIR$/external/rapid_json" />
30
- <property name="node.js.detected.package.eslint" value="true" />
31
- <property name="node.js.detected.package.tslint" value="true" />
32
- <property name="node.js.selected.package.eslint" value="(autodetect)" />
33
- <property name="node.js.selected.package.tslint" value="(autodetect)" />
34
- <property name="nodejs_package_manager_path" value="npm" />
35
- <property name="vue.rearranger.settings.migration" value="true" />
36
- </component>
37
- <component name="RecentsManager">
38
- <key name="CopyFile.RECENT_KEYS">
39
- <recent name="C:\GitHub\node-abieos\external\rapid_json" />
40
- <recent name="C:\GitHub\node-abieos\src" />
41
- <recent name="C:\GitHub\node-abieos" />
42
- </key>
43
- <key name="MoveFile.RECENT_KEYS">
44
- <recent name="C:\GitHub\node-abieos\include" />
45
- <recent name="C:\GitHub\node-abieos\external_includes" />
46
- </key>
47
- </component>
48
- <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
49
- <component name="TaskManager">
50
- <task active="true" id="Default" summary="Default task">
51
- <changelist id="24cd1727-69ec-448f-8093-325f7373674c" name="Changes" comment="" />
52
- <created>1623070905388</created>
53
- <option name="number" value="Default" />
54
- <option name="presentableId" value="Default" />
55
- <updated>1623070905388</updated>
56
- <workItem from="1623070906565" duration="179000" />
57
- <workItem from="1623071181018" duration="5026000" />
58
- <workItem from="1623138029252" duration="11000" />
59
- <workItem from="1623321973087" duration="130000" />
60
- </task>
61
- <servers />
62
- </component>
63
- <component name="TypeScriptGeneratedFilesManager">
64
- <option name="version" value="3" />
65
- </component>
66
- </project>
package/CMakeLists.txt DELETED
@@ -1,35 +0,0 @@
1
- cmake_minimum_required (VERSION 3.11)
2
- project(node_abieos VERSION 2.1 LANGUAGES CXX C)
3
-
4
- add_definitions(-DNAPI_VERSION=6)
5
- add_definitions(-DNAPI_EXPERIMENTAL)
6
-
7
- include_directories(${CMAKE_JS_INC})
8
-
9
- set(default_build_type "Release")
10
- set(CMAKE_CXX_STANDARD 17)
11
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
12
- set(CMAKE_CXX_EXTENSIONS ON)
13
-
14
- option(ABIEOS_NO_INT128 "disable use of __int128" OFF)
15
-
16
- find_package(Threads)
17
-
18
- add_library(abieos STATIC src/abi.cpp src/crypto.cpp include/eosio/fpconv.c)
19
- target_include_directories(abieos PUBLIC include)
20
-
21
- if(ABIEOS_NO_INT128)
22
- target_compile_definitions(abieos PUBLIC ABIEOS_NO_INT128)
23
- endif()
24
-
25
- set_target_properties(abieos PROPERTIES POSITION_INDEPENDENT_CODE ON)
26
-
27
- add_library(${PROJECT_NAME} SHARED src/main.cpp src/abieos.cpp)
28
- set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
29
- target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB};abieos;${CMAKE_THREAD_LIBS_INIT})
30
- target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-unused-parameter -fcolor-diagnostics)
31
-
32
- execute_process(COMMAND node -p "require('node-addon-api').include" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE NODE_ADDON_API_DIR)
33
- string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
34
- string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
35
- target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
package/abieos.d.ts DELETED
@@ -1,21 +0,0 @@
1
- declare namespace abieos {
2
- function string_to_name(name_string: string): BigInteger;
3
-
4
- function json_to_hex(contract_name: string, type: string, json: string | object): string;
5
-
6
- function hex_to_json(contract_name: string, type: string, hex: string): string;
7
-
8
- function bin_to_json(contract_name: string, type: string, buffer: Buffer): string;
9
-
10
- function load_abi(contract_name: string, abi: string): boolean;
11
-
12
- function load_abi_hex(contract_name: string, abihex: string): boolean;
13
-
14
- function get_type_for_action(contract_name: string, action_name: string): string;
15
-
16
- function get_type_for_table(contract_name: string, table_name: string): string;
17
-
18
- function delete_contract(contract_name: string): boolean;
19
- }
20
-
21
- export = abieos;
package/abieos.js DELETED
@@ -1,59 +0,0 @@
1
- if (process.platform === 'linux') {
2
- const abieos = require('./dist/abieos.node');
3
- module.exports = {
4
- json_to_hex: (contract_name, type, json) => {
5
- const data = abieos.json_to_hex(contract_name, type, typeof json === 'object' ? JSON.stringify(json) : json);
6
- if (data === 'PARSING_ERROR') {
7
- throw new Error('failed to parse data');
8
- } else {
9
- return data;
10
- }
11
- },
12
- string_to_name: abieos.string_to_name,
13
- hex_to_json: (contract_name, type, hex) => {
14
- const data = abieos.hex_to_json(contract_name, type, hex);
15
- if (data) {
16
- try {
17
- return JSON.parse(data);
18
- } catch (e) {
19
- throw new Error('failed to parse json string: ' + data);
20
- }
21
- } else {
22
- throw new Error('failed to parse hex data');
23
- }
24
- },
25
- bin_to_json: (contract_name, type, buffer) => {
26
- const data = abieos.bin_to_json(contract_name, type, buffer);
27
- if (data[0] === '{' || data[0] === '[') {
28
- try {
29
- return JSON.parse(data);
30
- } catch (e) {
31
- throw new Error('json parse error');
32
- }
33
- } else {
34
- throw new Error(data);
35
- }
36
- },
37
- load_abi: abieos.load_abi,
38
- load_abi_hex: abieos.load_abi_hex,
39
- get_type_for_action: (contract_name, action_name) => {
40
- const result = abieos.get_type_for_action(contract_name, action_name);
41
- if (result === 'NOT_FOUND') {
42
- throw new Error('action ' + action_name + ' not found on contract ' + contract_name);
43
- } else {
44
- return result;
45
- }
46
- },
47
- get_type_for_table: (contract_name, table_name) => {
48
- const result = abieos.get_type_for_table(contract_name, table_name);
49
- if (result === 'NOT_FOUND') {
50
- throw new Error('table ' + table_name + ' not found on contract ' + contract_name);
51
- } else {
52
- return result;
53
- }
54
- },
55
- delete_contract: abieos.delete_contract,
56
- };
57
- } else {
58
- module.exports = null;
59
- }