@eosrio/node-abieos 4.0.2-2039717 → 4.0.3-f7d5b45
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/LICENSE +37 -0
- package/README.md +89 -65
- package/dist/_tsup-dts-rollup.d.cts +105 -105
- package/dist/_tsup-dts-rollup.d.ts +105 -105
- package/dist/abieos.cjs +261 -261
- package/dist/abieos.js +230 -230
- package/dist/abieos.node +0 -0
- package/dist/abieos.ts +268 -268
- package/package.json +56 -55
package/LICENSE
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 EOS Rio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
----
|
|
24
|
+
|
|
25
|
+
Portions of this project are derived from or bundle the `AntelopeIO/abieos`
|
|
26
|
+
library, which is licensed under the MIT License:
|
|
27
|
+
|
|
28
|
+
AntelopeIO/abieos
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2021-2022 EOS Network Foundation (ENF) and its
|
|
31
|
+
contributors. All rights reserved.
|
|
32
|
+
This ENF software is based upon:
|
|
33
|
+
|
|
34
|
+
EOSIO/abieos
|
|
35
|
+
|
|
36
|
+
Copyright (c) 2017-2019 block.one and its contributors. All rights
|
|
37
|
+
reserved.
|
package/README.md
CHANGED
|
@@ -1,65 +1,89 @@
|
|
|
1
|
-
# node-abieos
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-
[](https://www.npmjs.com/package/@eosrio/node-abieos)
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
# node-abieos
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://www.npmjs.com/package/@eosrio/node-abieos)
|
|
6
|
+
[](https://coveralls.io/github/eosrio/node-abieos?branch=master)
|
|
7
|
+
|
|
8
|
+
Node.js native binding for [abieos](https://github.com/AntelopeIO/abieos), with some improvements:
|
|
9
|
+
|
|
10
|
+
- Internal loaded contract map
|
|
11
|
+
- deleteContract: to remove the loaded contract from memory (now in vanilla abieos too)
|
|
12
|
+
|
|
13
|
+
Made with ♥ by [EOS Rio](https://eosrio.io/)
|
|
14
|
+
|
|
15
|
+
----
|
|
16
|
+
**Only Linux is supported for now**
|
|
17
|
+
|
|
18
|
+
- Typescript typings included
|
|
19
|
+
- Prebuilt binary included (Clang 18 required to build)
|
|
20
|
+
- Now supports NodeJS, Deno, and Bun runtimes.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```shell script
|
|
25
|
+
npm i @eosrio/node-abieos --save
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
CommonJS
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const nodeAbieos = require('@eosrio/node-abieos');
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
ES Modules (NodeJS, Bun)
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import {Abieos} from "@eosrio/node-abieos";
|
|
40
|
+
const abieos = Abieos.getInstance();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Deno
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# examples/basic.cjs can be run with:
|
|
47
|
+
deno run --allow-ffi --allow-read examples/basic.cjs
|
|
48
|
+
|
|
49
|
+
# For an example using the published npm package with Deno:
|
|
50
|
+
# Check the examples/deno-abieos-test folder
|
|
51
|
+
cd examples/deno-abieos-test
|
|
52
|
+
deno run --allow-ffi --allow-read main.ts
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Bun
|
|
56
|
+
|
|
57
|
+
```shell script
|
|
58
|
+
# examples/basic.mjs can be run with:
|
|
59
|
+
bun run examples/basic.mjs
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Check the [/examples](https://github.com/eosrio/node-abieos/tree/master/examples) folder for implementation examples
|
|
63
|
+
|
|
64
|
+
## Building
|
|
65
|
+
|
|
66
|
+
Make sure you have Clang installed on your system:
|
|
67
|
+
We recommend using Clang 18 to build the `abieos` C++ library.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
wget https://apt.llvm.org/llvm.sh
|
|
71
|
+
chmod +x llvm.sh
|
|
72
|
+
sudo ./llvm.sh 18
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Clone and Build
|
|
76
|
+
|
|
77
|
+
```shell script
|
|
78
|
+
git clone https://github.com/eosrio/node-abieos.git --recursive
|
|
79
|
+
cd node-abieos
|
|
80
|
+
npm install
|
|
81
|
+
npm run build:linux
|
|
82
|
+
npm run build
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Documentation
|
|
86
|
+
|
|
87
|
+
For detailed and user-friendly documentation, including installation, usage, API reference, error handling, debugging, and examples, please refer to the [documentation](docs/README.md).
|
|
88
|
+
|
|
89
|
+
For contribution guidelines and developer documentation, refer to the [contribution guidelines](docs/CONTRIBUTING.md).
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abieos class provides a singleton instance for interacting with the native abieos module.
|
|
3
|
-
* This pattern is used to ensure a single global context for the underlying C++ abieos library,
|
|
4
|
-
* which manages internal state and resources.
|
|
5
|
-
*/
|
|
6
|
-
export declare class Abieos {
|
|
7
|
-
static logTag: string;
|
|
8
|
-
private static instance;
|
|
9
|
-
static native: typeof abieos;
|
|
10
|
-
private static loadedContracts;
|
|
11
|
-
static debug: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Private constructor to enforce the Singleton pattern.
|
|
14
|
-
* Throws an error if an attempt is made to create a second instance.
|
|
15
|
-
*/
|
|
16
|
-
private constructor();
|
|
17
|
-
/**
|
|
18
|
-
* Returns the singleton instance of the Abieos class.
|
|
19
|
-
* If an instance does not already exist, it creates one.
|
|
20
|
-
* @returns {Abieos} The singleton instance of Abieos.
|
|
21
|
-
*/
|
|
22
|
-
static getInstance(): Abieos;
|
|
23
|
-
getLoadedAbis(): string[];
|
|
24
|
-
/**
|
|
25
|
-
* Cleans up all loaded contracts by deleting them from the native context.
|
|
26
|
-
* This is useful for freeing up resources and ensuring a clean state.
|
|
27
|
-
*/
|
|
28
|
-
cleanup(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Converts a string name to its corresponding 64-bit unsigned integer representation (BigInt).
|
|
31
|
-
* @param {string} nameString The string name to convert.
|
|
32
|
-
* @returns {BigInt} The BigInt representation of the name.
|
|
33
|
-
*/
|
|
34
|
-
stringToName(nameString: string): BigInt;
|
|
35
|
-
/**
|
|
36
|
-
* Converts a JSON string or object to its hexadecimal binary representation.
|
|
37
|
-
* @param {string} contractName The name of the contract.
|
|
38
|
-
* @param {string} type The type within the ABI to use for conversion.
|
|
39
|
-
* @param {string | object} json The JSON data as a string or object.
|
|
40
|
-
* @returns {string} The hexadecimal string representation of the binary data.
|
|
41
|
-
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
42
|
-
*/
|
|
43
|
-
jsonToHex(contractName: string, type: string, json: string | object): string;
|
|
44
|
-
/**
|
|
45
|
-
* Converts a hexadecimal binary string to its JSON representation.
|
|
46
|
-
* @param {string} contractName The name of the contract.
|
|
47
|
-
* @param {string} type The type within the ABI to use for conversion.
|
|
48
|
-
* @param {string} hex The hexadecimal string to convert.
|
|
49
|
-
* @returns {any} The parsed JSON object.
|
|
50
|
-
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
51
|
-
*/
|
|
52
|
-
hexToJson(contractName: string, type: string, hex: string): any;
|
|
53
|
-
/**
|
|
54
|
-
* Converts a binary buffer to its JSON representation.
|
|
55
|
-
* @param {string} contractName The name of the contract.
|
|
56
|
-
* @param {string} type The type within the ABI to use for conversion.
|
|
57
|
-
* @param {Buffer} buffer The binary data as a Buffer.
|
|
58
|
-
* @returns {any} The parsed JSON object.
|
|
59
|
-
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
60
|
-
*/
|
|
61
|
-
binToJson(contractName: string, type: string, buffer: Buffer): any;
|
|
62
|
-
/**
|
|
63
|
-
* Loads an ABI for a given contract.
|
|
64
|
-
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
65
|
-
* @param {string | object} abi The ABI as a JSON string or object.
|
|
66
|
-
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
67
|
-
* @throws {Error} If the ABI format is invalid or loading fails.
|
|
68
|
-
*/
|
|
69
|
-
loadAbi(contractName: string, abi: string | object): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Loads an ABI for a given contract from its hexadecimal representation.
|
|
72
|
-
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
73
|
-
* @param {string} abihex The ABI as a hexadecimal string.
|
|
74
|
-
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
75
|
-
* @throws {Error} If loading fails.
|
|
76
|
-
*/
|
|
77
|
-
loadAbiHex(contractName: string, abihex: string): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Retrieves the type name for a specific action within a contract's ABI.
|
|
80
|
-
* @param {string} contractName The name of the contract.
|
|
81
|
-
* @param {string} actionName The name of the action.
|
|
82
|
-
* @returns {string} The type name associated with the action.
|
|
83
|
-
* @throws {Error} If the contract or action is not found or another error occurs.
|
|
84
|
-
*/
|
|
85
|
-
getTypeForAction(contractName: string, actionName: string): string;
|
|
86
|
-
/**
|
|
87
|
-
* Retrieves the type name for a specific table within a contract's ABI.
|
|
88
|
-
* @param {string} contractName The name of the contract.
|
|
89
|
-
* @param {string} table_name The name of the table.
|
|
90
|
-
* @returns {string} The type name associated with the table.
|
|
91
|
-
* @throws {Error} If the contract or table is not found or another error occurs.
|
|
92
|
-
*/
|
|
93
|
-
getTypeForTable(contractName: string, table_name: string): string;
|
|
94
|
-
/**
|
|
95
|
-
* Deletes a contract's ABI from the abieos context.
|
|
96
|
-
* @param {string} contractName The name of the contract to delete.
|
|
97
|
-
* @returns {boolean} True if the contract was successfully deleted, false otherwise.
|
|
98
|
-
* @throws {Error} If deletion fails.
|
|
99
|
-
*/
|
|
100
|
-
deleteContract(contractName: string): boolean;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
declare const abieos: any;
|
|
104
|
-
|
|
105
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Abieos class provides a singleton instance for interacting with the native abieos module.
|
|
3
|
+
* This pattern is used to ensure a single global context for the underlying C++ abieos library,
|
|
4
|
+
* which manages internal state and resources.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Abieos {
|
|
7
|
+
static logTag: string;
|
|
8
|
+
private static instance;
|
|
9
|
+
static native: typeof abieos;
|
|
10
|
+
private static loadedContracts;
|
|
11
|
+
static debug: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Private constructor to enforce the Singleton pattern.
|
|
14
|
+
* Throws an error if an attempt is made to create a second instance.
|
|
15
|
+
*/
|
|
16
|
+
private constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Returns the singleton instance of the Abieos class.
|
|
19
|
+
* If an instance does not already exist, it creates one.
|
|
20
|
+
* @returns {Abieos} The singleton instance of Abieos.
|
|
21
|
+
*/
|
|
22
|
+
static getInstance(): Abieos;
|
|
23
|
+
getLoadedAbis(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Cleans up all loaded contracts by deleting them from the native context.
|
|
26
|
+
* This is useful for freeing up resources and ensuring a clean state.
|
|
27
|
+
*/
|
|
28
|
+
cleanup(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a string name to its corresponding 64-bit unsigned integer representation (BigInt).
|
|
31
|
+
* @param {string} nameString The string name to convert.
|
|
32
|
+
* @returns {BigInt} The BigInt representation of the name.
|
|
33
|
+
*/
|
|
34
|
+
stringToName(nameString: string): BigInt;
|
|
35
|
+
/**
|
|
36
|
+
* Converts a JSON string or object to its hexadecimal binary representation.
|
|
37
|
+
* @param {string} contractName The name of the contract.
|
|
38
|
+
* @param {string} type The type within the ABI to use for conversion.
|
|
39
|
+
* @param {string | object} json The JSON data as a string or object.
|
|
40
|
+
* @returns {string} The hexadecimal string representation of the binary data.
|
|
41
|
+
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
42
|
+
*/
|
|
43
|
+
jsonToHex(contractName: string, type: string, json: string | object): string;
|
|
44
|
+
/**
|
|
45
|
+
* Converts a hexadecimal binary string to its JSON representation.
|
|
46
|
+
* @param {string} contractName The name of the contract.
|
|
47
|
+
* @param {string} type The type within the ABI to use for conversion.
|
|
48
|
+
* @param {string} hex The hexadecimal string to convert.
|
|
49
|
+
* @returns {any} The parsed JSON object.
|
|
50
|
+
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
51
|
+
*/
|
|
52
|
+
hexToJson(contractName: string, type: string, hex: string): any;
|
|
53
|
+
/**
|
|
54
|
+
* Converts a binary buffer to its JSON representation.
|
|
55
|
+
* @param {string} contractName The name of the contract.
|
|
56
|
+
* @param {string} type The type within the ABI to use for conversion.
|
|
57
|
+
* @param {Buffer} buffer The binary data as a Buffer.
|
|
58
|
+
* @returns {any} The parsed JSON object.
|
|
59
|
+
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
60
|
+
*/
|
|
61
|
+
binToJson(contractName: string, type: string, buffer: Buffer): any;
|
|
62
|
+
/**
|
|
63
|
+
* Loads an ABI for a given contract.
|
|
64
|
+
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
65
|
+
* @param {string | object} abi The ABI as a JSON string or object.
|
|
66
|
+
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
67
|
+
* @throws {Error} If the ABI format is invalid or loading fails.
|
|
68
|
+
*/
|
|
69
|
+
loadAbi(contractName: string, abi: string | object): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Loads an ABI for a given contract from its hexadecimal representation.
|
|
72
|
+
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
73
|
+
* @param {string} abihex The ABI as a hexadecimal string.
|
|
74
|
+
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
75
|
+
* @throws {Error} If loading fails.
|
|
76
|
+
*/
|
|
77
|
+
loadAbiHex(contractName: string, abihex: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the type name for a specific action within a contract's ABI.
|
|
80
|
+
* @param {string} contractName The name of the contract.
|
|
81
|
+
* @param {string} actionName The name of the action.
|
|
82
|
+
* @returns {string} The type name associated with the action.
|
|
83
|
+
* @throws {Error} If the contract or action is not found or another error occurs.
|
|
84
|
+
*/
|
|
85
|
+
getTypeForAction(contractName: string, actionName: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves the type name for a specific table within a contract's ABI.
|
|
88
|
+
* @param {string} contractName The name of the contract.
|
|
89
|
+
* @param {string} table_name The name of the table.
|
|
90
|
+
* @returns {string} The type name associated with the table.
|
|
91
|
+
* @throws {Error} If the contract or table is not found or another error occurs.
|
|
92
|
+
*/
|
|
93
|
+
getTypeForTable(contractName: string, table_name: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Deletes a contract's ABI from the abieos context.
|
|
96
|
+
* @param {string} contractName The name of the contract to delete.
|
|
97
|
+
* @returns {boolean} True if the contract was successfully deleted, false otherwise.
|
|
98
|
+
* @throws {Error} If deletion fails.
|
|
99
|
+
*/
|
|
100
|
+
deleteContract(contractName: string): boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare const abieos: any;
|
|
104
|
+
|
|
105
|
+
export { }
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abieos class provides a singleton instance for interacting with the native abieos module.
|
|
3
|
-
* This pattern is used to ensure a single global context for the underlying C++ abieos library,
|
|
4
|
-
* which manages internal state and resources.
|
|
5
|
-
*/
|
|
6
|
-
export declare class Abieos {
|
|
7
|
-
static logTag: string;
|
|
8
|
-
private static instance;
|
|
9
|
-
static native: typeof abieos;
|
|
10
|
-
private static loadedContracts;
|
|
11
|
-
static debug: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Private constructor to enforce the Singleton pattern.
|
|
14
|
-
* Throws an error if an attempt is made to create a second instance.
|
|
15
|
-
*/
|
|
16
|
-
private constructor();
|
|
17
|
-
/**
|
|
18
|
-
* Returns the singleton instance of the Abieos class.
|
|
19
|
-
* If an instance does not already exist, it creates one.
|
|
20
|
-
* @returns {Abieos} The singleton instance of Abieos.
|
|
21
|
-
*/
|
|
22
|
-
static getInstance(): Abieos;
|
|
23
|
-
getLoadedAbis(): string[];
|
|
24
|
-
/**
|
|
25
|
-
* Cleans up all loaded contracts by deleting them from the native context.
|
|
26
|
-
* This is useful for freeing up resources and ensuring a clean state.
|
|
27
|
-
*/
|
|
28
|
-
cleanup(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Converts a string name to its corresponding 64-bit unsigned integer representation (BigInt).
|
|
31
|
-
* @param {string} nameString The string name to convert.
|
|
32
|
-
* @returns {BigInt} The BigInt representation of the name.
|
|
33
|
-
*/
|
|
34
|
-
stringToName(nameString: string): BigInt;
|
|
35
|
-
/**
|
|
36
|
-
* Converts a JSON string or object to its hexadecimal binary representation.
|
|
37
|
-
* @param {string} contractName The name of the contract.
|
|
38
|
-
* @param {string} type The type within the ABI to use for conversion.
|
|
39
|
-
* @param {string | object} json The JSON data as a string or object.
|
|
40
|
-
* @returns {string} The hexadecimal string representation of the binary data.
|
|
41
|
-
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
42
|
-
*/
|
|
43
|
-
jsonToHex(contractName: string, type: string, json: string | object): string;
|
|
44
|
-
/**
|
|
45
|
-
* Converts a hexadecimal binary string to its JSON representation.
|
|
46
|
-
* @param {string} contractName The name of the contract.
|
|
47
|
-
* @param {string} type The type within the ABI to use for conversion.
|
|
48
|
-
* @param {string} hex The hexadecimal string to convert.
|
|
49
|
-
* @returns {any} The parsed JSON object.
|
|
50
|
-
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
51
|
-
*/
|
|
52
|
-
hexToJson(contractName: string, type: string, hex: string): any;
|
|
53
|
-
/**
|
|
54
|
-
* Converts a binary buffer to its JSON representation.
|
|
55
|
-
* @param {string} contractName The name of the contract.
|
|
56
|
-
* @param {string} type The type within the ABI to use for conversion.
|
|
57
|
-
* @param {Buffer} buffer The binary data as a Buffer.
|
|
58
|
-
* @returns {any} The parsed JSON object.
|
|
59
|
-
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
60
|
-
*/
|
|
61
|
-
binToJson(contractName: string, type: string, buffer: Buffer): any;
|
|
62
|
-
/**
|
|
63
|
-
* Loads an ABI for a given contract.
|
|
64
|
-
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
65
|
-
* @param {string | object} abi The ABI as a JSON string or object.
|
|
66
|
-
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
67
|
-
* @throws {Error} If the ABI format is invalid or loading fails.
|
|
68
|
-
*/
|
|
69
|
-
loadAbi(contractName: string, abi: string | object): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Loads an ABI for a given contract from its hexadecimal representation.
|
|
72
|
-
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
73
|
-
* @param {string} abihex The ABI as a hexadecimal string.
|
|
74
|
-
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
75
|
-
* @throws {Error} If loading fails.
|
|
76
|
-
*/
|
|
77
|
-
loadAbiHex(contractName: string, abihex: string): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Retrieves the type name for a specific action within a contract's ABI.
|
|
80
|
-
* @param {string} contractName The name of the contract.
|
|
81
|
-
* @param {string} actionName The name of the action.
|
|
82
|
-
* @returns {string} The type name associated with the action.
|
|
83
|
-
* @throws {Error} If the contract or action is not found or another error occurs.
|
|
84
|
-
*/
|
|
85
|
-
getTypeForAction(contractName: string, actionName: string): string;
|
|
86
|
-
/**
|
|
87
|
-
* Retrieves the type name for a specific table within a contract's ABI.
|
|
88
|
-
* @param {string} contractName The name of the contract.
|
|
89
|
-
* @param {string} table_name The name of the table.
|
|
90
|
-
* @returns {string} The type name associated with the table.
|
|
91
|
-
* @throws {Error} If the contract or table is not found or another error occurs.
|
|
92
|
-
*/
|
|
93
|
-
getTypeForTable(contractName: string, table_name: string): string;
|
|
94
|
-
/**
|
|
95
|
-
* Deletes a contract's ABI from the abieos context.
|
|
96
|
-
* @param {string} contractName The name of the contract to delete.
|
|
97
|
-
* @returns {boolean} True if the contract was successfully deleted, false otherwise.
|
|
98
|
-
* @throws {Error} If deletion fails.
|
|
99
|
-
*/
|
|
100
|
-
deleteContract(contractName: string): boolean;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
declare const abieos: any;
|
|
104
|
-
|
|
105
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Abieos class provides a singleton instance for interacting with the native abieos module.
|
|
3
|
+
* This pattern is used to ensure a single global context for the underlying C++ abieos library,
|
|
4
|
+
* which manages internal state and resources.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Abieos {
|
|
7
|
+
static logTag: string;
|
|
8
|
+
private static instance;
|
|
9
|
+
static native: typeof abieos;
|
|
10
|
+
private static loadedContracts;
|
|
11
|
+
static debug: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Private constructor to enforce the Singleton pattern.
|
|
14
|
+
* Throws an error if an attempt is made to create a second instance.
|
|
15
|
+
*/
|
|
16
|
+
private constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Returns the singleton instance of the Abieos class.
|
|
19
|
+
* If an instance does not already exist, it creates one.
|
|
20
|
+
* @returns {Abieos} The singleton instance of Abieos.
|
|
21
|
+
*/
|
|
22
|
+
static getInstance(): Abieos;
|
|
23
|
+
getLoadedAbis(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Cleans up all loaded contracts by deleting them from the native context.
|
|
26
|
+
* This is useful for freeing up resources and ensuring a clean state.
|
|
27
|
+
*/
|
|
28
|
+
cleanup(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a string name to its corresponding 64-bit unsigned integer representation (BigInt).
|
|
31
|
+
* @param {string} nameString The string name to convert.
|
|
32
|
+
* @returns {BigInt} The BigInt representation of the name.
|
|
33
|
+
*/
|
|
34
|
+
stringToName(nameString: string): BigInt;
|
|
35
|
+
/**
|
|
36
|
+
* Converts a JSON string or object to its hexadecimal binary representation.
|
|
37
|
+
* @param {string} contractName The name of the contract.
|
|
38
|
+
* @param {string} type The type within the ABI to use for conversion.
|
|
39
|
+
* @param {string | object} json The JSON data as a string or object.
|
|
40
|
+
* @returns {string} The hexadecimal string representation of the binary data.
|
|
41
|
+
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
42
|
+
*/
|
|
43
|
+
jsonToHex(contractName: string, type: string, json: string | object): string;
|
|
44
|
+
/**
|
|
45
|
+
* Converts a hexadecimal binary string to its JSON representation.
|
|
46
|
+
* @param {string} contractName The name of the contract.
|
|
47
|
+
* @param {string} type The type within the ABI to use for conversion.
|
|
48
|
+
* @param {string} hex The hexadecimal string to convert.
|
|
49
|
+
* @returns {any} The parsed JSON object.
|
|
50
|
+
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
51
|
+
*/
|
|
52
|
+
hexToJson(contractName: string, type: string, hex: string): any;
|
|
53
|
+
/**
|
|
54
|
+
* Converts a binary buffer to its JSON representation.
|
|
55
|
+
* @param {string} contractName The name of the contract.
|
|
56
|
+
* @param {string} type The type within the ABI to use for conversion.
|
|
57
|
+
* @param {Buffer} buffer The binary data as a Buffer.
|
|
58
|
+
* @returns {any} The parsed JSON object.
|
|
59
|
+
* @throws {Error} If parsing fails or an error occurs in the native module.
|
|
60
|
+
*/
|
|
61
|
+
binToJson(contractName: string, type: string, buffer: Buffer): any;
|
|
62
|
+
/**
|
|
63
|
+
* Loads an ABI for a given contract.
|
|
64
|
+
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
65
|
+
* @param {string | object} abi The ABI as a JSON string or object.
|
|
66
|
+
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
67
|
+
* @throws {Error} If the ABI format is invalid or loading fails.
|
|
68
|
+
*/
|
|
69
|
+
loadAbi(contractName: string, abi: string | object): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Loads an ABI for a given contract from its hexadecimal representation.
|
|
72
|
+
* @param {string} contractName The name of the contract for which to load the ABI.
|
|
73
|
+
* @param {string} abihex The ABI as a hexadecimal string.
|
|
74
|
+
* @returns {boolean} True if the ABI was loaded successfully, false otherwise.
|
|
75
|
+
* @throws {Error} If loading fails.
|
|
76
|
+
*/
|
|
77
|
+
loadAbiHex(contractName: string, abihex: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the type name for a specific action within a contract's ABI.
|
|
80
|
+
* @param {string} contractName The name of the contract.
|
|
81
|
+
* @param {string} actionName The name of the action.
|
|
82
|
+
* @returns {string} The type name associated with the action.
|
|
83
|
+
* @throws {Error} If the contract or action is not found or another error occurs.
|
|
84
|
+
*/
|
|
85
|
+
getTypeForAction(contractName: string, actionName: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves the type name for a specific table within a contract's ABI.
|
|
88
|
+
* @param {string} contractName The name of the contract.
|
|
89
|
+
* @param {string} table_name The name of the table.
|
|
90
|
+
* @returns {string} The type name associated with the table.
|
|
91
|
+
* @throws {Error} If the contract or table is not found or another error occurs.
|
|
92
|
+
*/
|
|
93
|
+
getTypeForTable(contractName: string, table_name: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Deletes a contract's ABI from the abieos context.
|
|
96
|
+
* @param {string} contractName The name of the contract to delete.
|
|
97
|
+
* @returns {boolean} True if the contract was successfully deleted, false otherwise.
|
|
98
|
+
* @throws {Error} If deletion fails.
|
|
99
|
+
*/
|
|
100
|
+
deleteContract(contractName: string): boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare const abieos: any;
|
|
104
|
+
|
|
105
|
+
export { }
|