koilib 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -8
- package/dist/koinos.js +2495 -2298
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +47 -152
- package/lib/Contract.js +61 -148
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +1 -4
- package/lib/Provider.js +1 -1
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +81 -0
- package/lib/Serializer.js +169 -0
- package/lib/Serializer.js.map +1 -0
- package/lib/Signer.d.ts +130 -24
- package/lib/Signer.js +151 -47
- package/lib/Signer.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index2.js +2 -0
- package/lib/index2.js.map +1 -1
- package/lib/interface.d.ts +161 -24
- package/lib/{krc20-proto.json → jsonDescriptors/krc20-proto.json} +1 -1
- package/lib/{protocol-proto.json → jsonDescriptors/protocol-proto.json} +22 -18
- package/lib/utils.d.ts +249 -1
- package/lib/utils.js +4 -2
- package/lib/utils.js.map +1 -1
- package/package.json +2 -4
package/lib/Contract.d.ts
CHANGED
|
@@ -1,124 +1,7 @@
|
|
|
1
|
-
import { Root, INamespace } from "protobufjs/light";
|
|
2
1
|
import { Signer, SignerInterface } from "./Signer";
|
|
3
|
-
import { Provider
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
* Application Binary Interface (ABI)
|
|
7
|
-
*
|
|
8
|
-
* ABIs are composed of 2 elements: methods and types.
|
|
9
|
-
* - The methods define the names of the entries of the smart contract,
|
|
10
|
-
* the corresponding endpoints and the name of the types used.
|
|
11
|
-
* - The types all the description to serialize and deserialize
|
|
12
|
-
* using proto buffers.
|
|
13
|
-
*
|
|
14
|
-
* To generate the types is necessary to use the dependency
|
|
15
|
-
* protobufjs. The following example shows how to generate the
|
|
16
|
-
* protobuf descriptor from a .proto file.
|
|
17
|
-
*
|
|
18
|
-
* ```js
|
|
19
|
-
* const fs = require("fs");
|
|
20
|
-
* const pbjs = require("protobufjs/cli/pbjs");
|
|
21
|
-
*
|
|
22
|
-
* pbjs.main(
|
|
23
|
-
* ["--target", "json", "./token.proto"],
|
|
24
|
-
* (err, output) => {
|
|
25
|
-
* if (err) throw err;
|
|
26
|
-
* fs.writeFileSync("./token-proto.json", output);
|
|
27
|
-
* }
|
|
28
|
-
* );
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* Then this descriptor can be loaded to define the ABI:
|
|
32
|
-
* ```js
|
|
33
|
-
* const tokenJson = require("./token-proto.json");
|
|
34
|
-
* const abiToken = {
|
|
35
|
-
* methods: {
|
|
36
|
-
* balanceOf: {
|
|
37
|
-
* entryPoint: 0x15619248,
|
|
38
|
-
* inputs: "balance_of_arguments",
|
|
39
|
-
* outputs: "balance_of_result",
|
|
40
|
-
* readOnly: true,
|
|
41
|
-
* defaultOutput: { value: "0" },
|
|
42
|
-
* },
|
|
43
|
-
* transfer: {
|
|
44
|
-
* entryPoint: 0x62efa292,
|
|
45
|
-
* inputs: "transfer_arguments",
|
|
46
|
-
* outputs: "transfer_result",
|
|
47
|
-
* },
|
|
48
|
-
* mint: {
|
|
49
|
-
* entryPoint: 0xc2f82bdc,
|
|
50
|
-
* inputs: "mint_argumnets",
|
|
51
|
-
* outputs: "mint_result",
|
|
52
|
-
* },
|
|
53
|
-
* },
|
|
54
|
-
* types: tokenJson,
|
|
55
|
-
* };
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* Note that this example uses "defaultOutput" for the method
|
|
59
|
-
* "balanceOf". This is used when the smart contract returns an
|
|
60
|
-
* empty response (for instance when there are no balance records
|
|
61
|
-
* for a specific address) and you require a default output in
|
|
62
|
-
* such cases.
|
|
63
|
-
*/
|
|
64
|
-
export interface Abi {
|
|
65
|
-
methods: {
|
|
66
|
-
/** Name of the method */
|
|
67
|
-
[x: string]: {
|
|
68
|
-
/** Entry point ID */
|
|
69
|
-
entryPoint: number;
|
|
70
|
-
/** Protobuffer type for input */
|
|
71
|
-
input?: string;
|
|
72
|
-
/** Protobuffer type for output */
|
|
73
|
-
output?: string;
|
|
74
|
-
/** Boolean to differentiate write methods
|
|
75
|
-
* (using transactions) from read methods
|
|
76
|
-
* (query the contract)
|
|
77
|
-
*/
|
|
78
|
-
readOnly?: boolean;
|
|
79
|
-
/** Default value when the output is undefined */
|
|
80
|
-
defaultOutput?: unknown;
|
|
81
|
-
/** Optional function to preformat the input */
|
|
82
|
-
preformatInput?: (input: unknown) => Record<string, unknown>;
|
|
83
|
-
/** Optional function to preformat the output */
|
|
84
|
-
preformatOutput?: (output: Record<string, unknown>) => unknown;
|
|
85
|
-
/** Description of the method */
|
|
86
|
-
description?: string;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Protobuffers descriptor in JSON format.
|
|
91
|
-
* See https://www.npmjs.com/package/protobufjs#using-json-descriptors
|
|
92
|
-
*/
|
|
93
|
-
types: INamespace;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Human readable format operation
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* const opDecoded = {
|
|
101
|
-
* name: "transfer",
|
|
102
|
-
* args: {
|
|
103
|
-
* from: "1Krs7v1rtpgRyfwEZncuKMQQnY5JhqXVSx",
|
|
104
|
-
* to: "1BqtgWBcqm9cSZ97avLGZGJdgso7wx6pCA",
|
|
105
|
-
* value: 1000,
|
|
106
|
-
* },
|
|
107
|
-
* };
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
export interface DecodedOperationJson {
|
|
111
|
-
/** Operation name */
|
|
112
|
-
name: string;
|
|
113
|
-
/** Arguments decoded. See [[Abi]] */
|
|
114
|
-
args?: Record<string, unknown>;
|
|
115
|
-
}
|
|
116
|
-
export interface TransactionOptions {
|
|
117
|
-
rcLimit?: number | bigint | string;
|
|
118
|
-
nonce?: number;
|
|
119
|
-
sendTransaction?: boolean;
|
|
120
|
-
sendAbis?: boolean;
|
|
121
|
-
}
|
|
2
|
+
import { Provider } from "./Provider";
|
|
3
|
+
import { Serializer } from "./Serializer";
|
|
4
|
+
import { CallContractOperationNested, UploadContractOperationNested, TransactionJson, Abi, TransactionOptions, DecodedOperationJson, SendTransactionResponse } from "./interface";
|
|
122
5
|
/**
|
|
123
6
|
* The contract class contains the contract ID and contract entries
|
|
124
7
|
* definition needed to encode/decode operations during the
|
|
@@ -129,9 +12,9 @@ export interface TransactionOptions {
|
|
|
129
12
|
* ```ts
|
|
130
13
|
* const { Contract, Provider, Signer, utils } = require("koilib");
|
|
131
14
|
* const rpcNodes = ["http://api.koinos.io:8080"];
|
|
132
|
-
* const
|
|
15
|
+
* const privateKey = "f186a5de49797bfd52dc42505c33d75a46822ed5b60046e09d7c336242e20200";
|
|
133
16
|
* const provider = new Provider(rpcNodes);
|
|
134
|
-
* const signer = new Signer(
|
|
17
|
+
* const signer = new Signer({ privateKey, provider });
|
|
135
18
|
* const koinContract = new Contract({
|
|
136
19
|
* id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
137
20
|
* abi: utils.Krc20Abi,
|
|
@@ -140,18 +23,26 @@ export interface TransactionOptions {
|
|
|
140
23
|
* });
|
|
141
24
|
* const koin = koinContract.functions;
|
|
142
25
|
*
|
|
26
|
+
* // optional: preformat input/output
|
|
27
|
+
* koinContract.abi.methods.balanceOf.preformatInput = (owner) =>
|
|
28
|
+
* ({ owner });
|
|
29
|
+
* koinContract.abi.methods.balanceOf.preformatOutput = (res) =>
|
|
30
|
+
* utils.formatUnits(res.value, 8);
|
|
31
|
+
* koinContract.abi.methods.transfer.preformatInput = (input) => ({
|
|
32
|
+
* from: signer.getAddress(),
|
|
33
|
+
* to: input.to,
|
|
34
|
+
* value: utils.parseUnits(input.value, 8),
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
143
37
|
* async funtion main() {
|
|
144
38
|
* // Get balance
|
|
145
|
-
* const { result } = await koin.balanceOf(
|
|
146
|
-
*
|
|
147
|
-
* });
|
|
148
|
-
* console.log(balance.result)
|
|
39
|
+
* const { result } = await koin.balanceOf("12fN2CQnuJM8cMnWZ1hPtM4knjLME8E4PD");
|
|
40
|
+
* console.log(result)
|
|
149
41
|
*
|
|
150
42
|
* // Transfer
|
|
151
43
|
* const { transaction, transactionResponse } = await koin.transfer({
|
|
152
|
-
* from: "12fN2CQnuJM8cMnWZ1hPtM4knjLME8E4PD",
|
|
153
44
|
* to: "172AB1FgCsYrRAW5cwQ8KjadgxofvgPFd6",
|
|
154
|
-
* value: "
|
|
45
|
+
* value: "10.0001",
|
|
155
46
|
* });
|
|
156
47
|
* console.log(`Transaction id ${transaction.id} submitted`);
|
|
157
48
|
*
|
|
@@ -168,14 +59,16 @@ export declare class Contract {
|
|
|
168
59
|
* Contract ID
|
|
169
60
|
*/
|
|
170
61
|
id?: Uint8Array;
|
|
171
|
-
/**
|
|
172
|
-
* Protobuffer definitions
|
|
173
|
-
*/
|
|
174
|
-
protobuffers?: Root;
|
|
175
62
|
/**
|
|
176
63
|
* Set of functions to interact with the smart
|
|
177
64
|
* contract. These functions are automatically generated
|
|
178
65
|
* in the constructor of the class
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const owner = "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb";
|
|
70
|
+
* await koinContract.functions.balanceOf({ owner });
|
|
71
|
+
* ```
|
|
179
72
|
*/
|
|
180
73
|
functions: {
|
|
181
74
|
[x: string]: <T = Record<string, unknown>>(args?: unknown, opts?: TransactionOptions) => Promise<{
|
|
@@ -197,13 +90,17 @@ export declare class Contract {
|
|
|
197
90
|
* Provider to connect with the blockchain
|
|
198
91
|
*/
|
|
199
92
|
provider?: Provider;
|
|
93
|
+
/**
|
|
94
|
+
* Serializer to serialize/deserialize data types
|
|
95
|
+
*/
|
|
96
|
+
serializer?: Serializer;
|
|
200
97
|
/**
|
|
201
98
|
* Bytecode. Needed to deploy the smart contract.
|
|
202
99
|
*/
|
|
203
100
|
bytecode?: Uint8Array;
|
|
204
101
|
/**
|
|
205
102
|
* Options to apply when creating transactions.
|
|
206
|
-
* By default it set
|
|
103
|
+
* By default it set rc_limit to 1e8, sendTransaction true,
|
|
207
104
|
* sendAbis true, and nonce undefined (to get it from the blockchain)
|
|
208
105
|
*/
|
|
209
106
|
options: TransactionOptions;
|
|
@@ -214,6 +111,13 @@ export declare class Contract {
|
|
|
214
111
|
options?: TransactionOptions;
|
|
215
112
|
signer?: Signer;
|
|
216
113
|
provider?: Provider;
|
|
114
|
+
/**
|
|
115
|
+
* Set this option if you can not use _eval_ functions
|
|
116
|
+
* in the current environment. In such cases, the
|
|
117
|
+
* serializer must come from an environment where it
|
|
118
|
+
* is able to use those functions.
|
|
119
|
+
*/
|
|
120
|
+
serializer?: Serializer;
|
|
217
121
|
});
|
|
218
122
|
/**
|
|
219
123
|
* Compute contract Id
|
|
@@ -228,8 +132,9 @@ export declare class Contract {
|
|
|
228
132
|
* The Bytecode must be defined in the constructor of the class
|
|
229
133
|
* @example
|
|
230
134
|
* ```ts
|
|
231
|
-
* const
|
|
135
|
+
* const privateKey = "f186a5de49797bfd52dc42505c33d75a46822ed5b60046e09d7c336242e20200";
|
|
232
136
|
* const provider = new Provider(["http://api.koinos.io:8080"]);
|
|
137
|
+
* const signer = new Signer({ privateKey, provider });
|
|
233
138
|
* const bytecode = new Uint8Array([1, 2, 3, 4]);
|
|
234
139
|
* const contract = new Contract({ signer, provider, bytecode });
|
|
235
140
|
* const { transactionResponse } = await contract.deploy();
|
|
@@ -261,23 +166,23 @@ export declare class Contract {
|
|
|
261
166
|
*
|
|
262
167
|
* console.log(opEncoded);
|
|
263
168
|
* // {
|
|
264
|
-
* //
|
|
265
|
-
* //
|
|
266
|
-
* //
|
|
169
|
+
* // call_contract: {
|
|
170
|
+
* // contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
171
|
+
* // entry_point: 0x62efa292,
|
|
267
172
|
* // args: "MBWFsaWNlA2JvYgAAAAAAAAPo",
|
|
268
173
|
* // }
|
|
269
174
|
* // }
|
|
270
175
|
* ```
|
|
271
176
|
*/
|
|
272
|
-
encodeOperation(op: DecodedOperationJson): CallContractOperationNested
|
|
177
|
+
encodeOperation(op: DecodedOperationJson): Promise<CallContractOperationNested>;
|
|
273
178
|
/**
|
|
274
179
|
* Decodes a contract operation to be human readable
|
|
275
180
|
* @example
|
|
276
181
|
* ```ts
|
|
277
182
|
* const opDecoded = contract.decodeOperation({
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
183
|
+
* call_contract: {
|
|
184
|
+
* contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
185
|
+
* entry_point: 0x62efa292,
|
|
281
186
|
* args: "MBWFsaWNlA2JvYgAAAAAAAAPo",
|
|
282
187
|
* }
|
|
283
188
|
* });
|
|
@@ -292,16 +197,6 @@ export declare class Contract {
|
|
|
292
197
|
* // }
|
|
293
198
|
* ```
|
|
294
199
|
*/
|
|
295
|
-
decodeOperation(op: CallContractOperationNested): DecodedOperationJson
|
|
296
|
-
/**
|
|
297
|
-
* Function to encode a type using the protobuffer definitions
|
|
298
|
-
* It also prepares the bytes for special cases (base58, hex string)
|
|
299
|
-
*/
|
|
300
|
-
encodeType(valueDecoded: Record<string, unknown>, typeName: string): Uint8Array;
|
|
301
|
-
/**
|
|
302
|
-
* Function to decode bytes using the protobuffer definitions
|
|
303
|
-
* It also encodes the bytes for special cases (base58, hex string)
|
|
304
|
-
*/
|
|
305
|
-
decodeType<T = Record<string, unknown>>(valueEncoded: string | Uint8Array, typeName: string): T;
|
|
200
|
+
decodeOperation(op: CallContractOperationNested): Promise<DecodedOperationJson>;
|
|
306
201
|
}
|
|
307
202
|
export default Contract;
|
package/lib/Contract.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Contract = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Serializer_1 = require("./Serializer");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
-
const OP_BYTES = "(koinos_bytes_type)";
|
|
7
|
-
/**
|
|
8
|
-
* Makes a copy of a value. The returned value can be modified
|
|
9
|
-
* without altering the original one. Although this is not needed
|
|
10
|
-
* for strings or numbers and only needed for objects and arrays,
|
|
11
|
-
* all these options are covered in a single function
|
|
12
|
-
*
|
|
13
|
-
* It is assumed that the argument is number, string, or contructions
|
|
14
|
-
* of these types inside objects or arrays.
|
|
15
|
-
*/
|
|
16
|
-
function copyValue(value) {
|
|
17
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
return JSON.parse(JSON.stringify(value));
|
|
21
|
-
}
|
|
22
6
|
/**
|
|
23
7
|
* The contract class contains the contract ID and contract entries
|
|
24
8
|
* definition needed to encode/decode operations during the
|
|
@@ -29,9 +13,9 @@ function copyValue(value) {
|
|
|
29
13
|
* ```ts
|
|
30
14
|
* const { Contract, Provider, Signer, utils } = require("koilib");
|
|
31
15
|
* const rpcNodes = ["http://api.koinos.io:8080"];
|
|
32
|
-
* const
|
|
16
|
+
* const privateKey = "f186a5de49797bfd52dc42505c33d75a46822ed5b60046e09d7c336242e20200";
|
|
33
17
|
* const provider = new Provider(rpcNodes);
|
|
34
|
-
* const signer = new Signer(
|
|
18
|
+
* const signer = new Signer({ privateKey, provider });
|
|
35
19
|
* const koinContract = new Contract({
|
|
36
20
|
* id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
37
21
|
* abi: utils.Krc20Abi,
|
|
@@ -40,18 +24,26 @@ function copyValue(value) {
|
|
|
40
24
|
* });
|
|
41
25
|
* const koin = koinContract.functions;
|
|
42
26
|
*
|
|
27
|
+
* // optional: preformat input/output
|
|
28
|
+
* koinContract.abi.methods.balanceOf.preformatInput = (owner) =>
|
|
29
|
+
* ({ owner });
|
|
30
|
+
* koinContract.abi.methods.balanceOf.preformatOutput = (res) =>
|
|
31
|
+
* utils.formatUnits(res.value, 8);
|
|
32
|
+
* koinContract.abi.methods.transfer.preformatInput = (input) => ({
|
|
33
|
+
* from: signer.getAddress(),
|
|
34
|
+
* to: input.to,
|
|
35
|
+
* value: utils.parseUnits(input.value, 8),
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
43
38
|
* async funtion main() {
|
|
44
39
|
* // Get balance
|
|
45
|
-
* const { result } = await koin.balanceOf(
|
|
46
|
-
*
|
|
47
|
-
* });
|
|
48
|
-
* console.log(balance.result)
|
|
40
|
+
* const { result } = await koin.balanceOf("12fN2CQnuJM8cMnWZ1hPtM4knjLME8E4PD");
|
|
41
|
+
* console.log(result)
|
|
49
42
|
*
|
|
50
43
|
* // Transfer
|
|
51
44
|
* const { transaction, transactionResponse } = await koin.transfer({
|
|
52
|
-
* from: "12fN2CQnuJM8cMnWZ1hPtM4knjLME8E4PD",
|
|
53
45
|
* to: "172AB1FgCsYrRAW5cwQ8KjadgxofvgPFd6",
|
|
54
|
-
* value: "
|
|
46
|
+
* value: "10.0001",
|
|
55
47
|
* });
|
|
56
48
|
* console.log(`Transaction id ${transaction.id} submitted`);
|
|
57
49
|
*
|
|
@@ -65,23 +57,31 @@ function copyValue(value) {
|
|
|
65
57
|
*/
|
|
66
58
|
class Contract {
|
|
67
59
|
constructor(c) {
|
|
68
|
-
var _a
|
|
60
|
+
var _a;
|
|
69
61
|
if (c.id)
|
|
70
62
|
this.id = utils_1.decodeBase58(c.id);
|
|
71
63
|
this.signer = c.signer;
|
|
72
64
|
this.provider = c.provider || ((_a = c.signer) === null || _a === void 0 ? void 0 : _a.provider);
|
|
73
65
|
this.abi = c.abi;
|
|
74
66
|
this.bytecode = c.bytecode;
|
|
75
|
-
if (
|
|
76
|
-
this.
|
|
67
|
+
if (c.serializer) {
|
|
68
|
+
this.serializer = c.serializer;
|
|
69
|
+
}
|
|
70
|
+
else if (c.abi && c.abi.types) {
|
|
71
|
+
this.serializer = new Serializer_1.Serializer(c.abi.types);
|
|
72
|
+
}
|
|
77
73
|
this.options = {
|
|
78
|
-
|
|
74
|
+
rc_limit: 1e8,
|
|
79
75
|
sendTransaction: true,
|
|
80
76
|
sendAbis: true,
|
|
81
77
|
...c.options,
|
|
82
78
|
};
|
|
83
79
|
this.functions = {};
|
|
84
|
-
if (this.signer &&
|
|
80
|
+
if (this.signer &&
|
|
81
|
+
this.provider &&
|
|
82
|
+
this.abi &&
|
|
83
|
+
this.abi.methods &&
|
|
84
|
+
this.serializer) {
|
|
85
85
|
Object.keys(this.abi.methods).forEach((name) => {
|
|
86
86
|
this.functions[name] = async (argu = {}, options) => {
|
|
87
87
|
if (!this.provider)
|
|
@@ -102,19 +102,19 @@ class Contract {
|
|
|
102
102
|
else {
|
|
103
103
|
args = argu;
|
|
104
104
|
}
|
|
105
|
-
const operation = this.encodeOperation({ name, args });
|
|
105
|
+
const operation = await this.encodeOperation({ name, args });
|
|
106
106
|
if (readOnly) {
|
|
107
107
|
if (!output)
|
|
108
108
|
throw new Error(`No output defined for ${name}`);
|
|
109
109
|
// read contract
|
|
110
110
|
const { result: resultEncoded } = await this.provider.readContract({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
args: utils_1.encodeBase64(operation.
|
|
111
|
+
contract_id: utils_1.encodeBase58(operation.call_contract.contract_id),
|
|
112
|
+
entry_point: operation.call_contract.entry_point,
|
|
113
|
+
args: utils_1.encodeBase64(operation.call_contract.args),
|
|
114
114
|
});
|
|
115
115
|
let result = defaultOutput;
|
|
116
116
|
if (resultEncoded) {
|
|
117
|
-
result = this.
|
|
117
|
+
result = await this.serializer.deserialize(resultEncoded, output);
|
|
118
118
|
}
|
|
119
119
|
if (typeof preformatOutput === "function") {
|
|
120
120
|
result = preformatOutput(result);
|
|
@@ -161,8 +161,9 @@ class Contract {
|
|
|
161
161
|
* The Bytecode must be defined in the constructor of the class
|
|
162
162
|
* @example
|
|
163
163
|
* ```ts
|
|
164
|
-
* const
|
|
164
|
+
* const privateKey = "f186a5de49797bfd52dc42505c33d75a46822ed5b60046e09d7c336242e20200";
|
|
165
165
|
* const provider = new Provider(["http://api.koinos.io:8080"]);
|
|
166
|
+
* const signer = new Signer({ privateKey, provider });
|
|
166
167
|
* const bytecode = new Uint8Array([1, 2, 3, 4]);
|
|
167
168
|
* const contract = new Contract({ signer, provider, bytecode });
|
|
168
169
|
* const { transactionResponse } = await contract.deploy();
|
|
@@ -181,8 +182,8 @@ class Contract {
|
|
|
181
182
|
...options,
|
|
182
183
|
};
|
|
183
184
|
const operation = {
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
upload_contract: {
|
|
186
|
+
contract_id: Contract.computeContractId(this.signer.getAddress()),
|
|
186
187
|
bytecode: this.bytecode,
|
|
187
188
|
},
|
|
188
189
|
};
|
|
@@ -214,19 +215,19 @@ class Contract {
|
|
|
214
215
|
*
|
|
215
216
|
* console.log(opEncoded);
|
|
216
217
|
* // {
|
|
217
|
-
* //
|
|
218
|
-
* //
|
|
219
|
-
* //
|
|
218
|
+
* // call_contract: {
|
|
219
|
+
* // contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
220
|
+
* // entry_point: 0x62efa292,
|
|
220
221
|
* // args: "MBWFsaWNlA2JvYgAAAAAAAAPo",
|
|
221
222
|
* // }
|
|
222
223
|
* // }
|
|
223
224
|
* ```
|
|
224
225
|
*/
|
|
225
|
-
encodeOperation(op) {
|
|
226
|
+
async encodeOperation(op) {
|
|
226
227
|
if (!this.abi || !this.abi.methods || !this.abi.methods[op.name])
|
|
227
228
|
throw new Error(`Operation ${op.name} unknown`);
|
|
228
|
-
if (!this.
|
|
229
|
-
throw new Error("
|
|
229
|
+
if (!this.serializer)
|
|
230
|
+
throw new Error("Serializer is not defined");
|
|
230
231
|
if (!this.id)
|
|
231
232
|
throw new Error("Contract id is not defined");
|
|
232
233
|
const method = this.abi.methods[op.name];
|
|
@@ -234,12 +235,12 @@ class Contract {
|
|
|
234
235
|
if (method.input) {
|
|
235
236
|
if (!op.args)
|
|
236
237
|
throw new Error(`No arguments defined for type '${method.input}'`);
|
|
237
|
-
bufferInputs = this.
|
|
238
|
+
bufferInputs = await this.serializer.serialize(op.args, method.input);
|
|
238
239
|
}
|
|
239
240
|
return {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
call_contract: {
|
|
242
|
+
contract_id: this.id,
|
|
243
|
+
entry_point: method.entryPoint,
|
|
243
244
|
args: bufferInputs,
|
|
244
245
|
},
|
|
245
246
|
};
|
|
@@ -249,9 +250,9 @@ class Contract {
|
|
|
249
250
|
* @example
|
|
250
251
|
* ```ts
|
|
251
252
|
* const opDecoded = contract.decodeOperation({
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
253
|
+
* call_contract: {
|
|
254
|
+
* contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
|
|
255
|
+
* entry_point: 0x62efa292,
|
|
255
256
|
* args: "MBWFsaWNlA2JvYgAAAAAAAAPo",
|
|
256
257
|
* }
|
|
257
258
|
* });
|
|
@@ -266,118 +267,30 @@ class Contract {
|
|
|
266
267
|
* // }
|
|
267
268
|
* ```
|
|
268
269
|
*/
|
|
269
|
-
decodeOperation(op) {
|
|
270
|
+
async decodeOperation(op) {
|
|
270
271
|
if (!this.id)
|
|
271
272
|
throw new Error("Contract id is not defined");
|
|
272
273
|
if (!this.abi || !this.abi.methods)
|
|
273
274
|
throw new Error("Methods are not defined");
|
|
274
|
-
if (!
|
|
275
|
+
if (!this.serializer)
|
|
276
|
+
throw new Error("Serializer is not defined");
|
|
277
|
+
if (!op.call_contract)
|
|
275
278
|
throw new Error("Operation is not CallContractOperation");
|
|
276
|
-
if (op.
|
|
277
|
-
throw new Error(`Invalid contract id. Expected: ${utils_1.encodeBase58(this.id)}. Received: ${utils_1.encodeBase58(op.
|
|
279
|
+
if (op.call_contract.contract_id !== this.id)
|
|
280
|
+
throw new Error(`Invalid contract id. Expected: ${utils_1.encodeBase58(this.id)}. Received: ${utils_1.encodeBase58(op.call_contract.contract_id)}`);
|
|
278
281
|
for (let i = 0; i < Object.keys(this.abi.methods).length; i += 1) {
|
|
279
282
|
const opName = Object.keys(this.abi.methods)[i];
|
|
280
283
|
const method = this.abi.methods[opName];
|
|
281
|
-
if (op.
|
|
284
|
+
if (op.call_contract.entry_point === method.entryPoint) {
|
|
282
285
|
if (!method.input)
|
|
283
286
|
return { name: opName };
|
|
284
287
|
return {
|
|
285
288
|
name: opName,
|
|
286
|
-
args: this.
|
|
289
|
+
args: await this.serializer.deserialize(op.call_contract.args, method.input),
|
|
287
290
|
};
|
|
288
291
|
}
|
|
289
292
|
}
|
|
290
|
-
throw new Error(`Unknown method id ${op.
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Function to encode a type using the protobuffer definitions
|
|
294
|
-
* It also prepares the bytes for special cases (base58, hex string)
|
|
295
|
-
*/
|
|
296
|
-
encodeType(valueDecoded, typeName) {
|
|
297
|
-
if (!this.protobuffers)
|
|
298
|
-
throw new Error("Protobuffers are not defined");
|
|
299
|
-
const protobufType = this.protobuffers.lookupType(typeName);
|
|
300
|
-
const object = {};
|
|
301
|
-
// TODO: format from Buffer to base58/base64 for nested fields
|
|
302
|
-
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
303
|
-
const { options, name, type } = protobufType.fields[fieldName];
|
|
304
|
-
// No byte conversion
|
|
305
|
-
if (type !== "bytes") {
|
|
306
|
-
object[name] = copyValue(valueDecoded[name]);
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
// Default byte conversion
|
|
310
|
-
if (!options || !options[OP_BYTES]) {
|
|
311
|
-
object[name] = utils_1.decodeBase64(valueDecoded[name]);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
// Specific byte conversion
|
|
315
|
-
switch (options[OP_BYTES]) {
|
|
316
|
-
case "BASE58":
|
|
317
|
-
case "CONTRACT_ID":
|
|
318
|
-
case "ADDRESS":
|
|
319
|
-
object[name] = utils_1.decodeBase58(valueDecoded[name]);
|
|
320
|
-
break;
|
|
321
|
-
case "BASE64":
|
|
322
|
-
object[name] = utils_1.decodeBase64(valueDecoded[name]);
|
|
323
|
-
break;
|
|
324
|
-
case "HEX":
|
|
325
|
-
case "BLOCK_ID":
|
|
326
|
-
case "TRANSACTION_ID":
|
|
327
|
-
object[name] = utils_1.toUint8Array(valueDecoded[name].replace("0x", ""));
|
|
328
|
-
break;
|
|
329
|
-
default:
|
|
330
|
-
throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
const message = protobufType.create(object);
|
|
334
|
-
const buffer = protobufType.encode(message).finish();
|
|
335
|
-
return buffer;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Function to decode bytes using the protobuffer definitions
|
|
339
|
-
* It also encodes the bytes for special cases (base58, hex string)
|
|
340
|
-
*/
|
|
341
|
-
decodeType(valueEncoded, typeName) {
|
|
342
|
-
if (!this.protobuffers)
|
|
343
|
-
throw new Error("Protobuffers are not defined");
|
|
344
|
-
const valueBuffer = typeof valueEncoded === "string"
|
|
345
|
-
? utils_1.decodeBase64(valueEncoded)
|
|
346
|
-
: valueEncoded;
|
|
347
|
-
const protobufType = this.protobuffers.lookupType(typeName);
|
|
348
|
-
const message = protobufType.decode(valueBuffer);
|
|
349
|
-
const object = protobufType.toObject(message, { longs: String });
|
|
350
|
-
// TODO: format from Buffer to base58/base64 for nested fields
|
|
351
|
-
Object.keys(protobufType.fields).forEach((fieldName) => {
|
|
352
|
-
const { options, name, type } = protobufType.fields[fieldName];
|
|
353
|
-
// No byte conversion
|
|
354
|
-
if (type !== "bytes")
|
|
355
|
-
return;
|
|
356
|
-
// Default byte conversion
|
|
357
|
-
if (!options || !options[OP_BYTES]) {
|
|
358
|
-
object[name] = utils_1.encodeBase64(object[name]);
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
// Specific byte conversion
|
|
362
|
-
switch (options[OP_BYTES]) {
|
|
363
|
-
case "BASE58":
|
|
364
|
-
case "CONTRACT_ID":
|
|
365
|
-
case "ADDRESS":
|
|
366
|
-
object[name] = utils_1.encodeBase58(object[name]);
|
|
367
|
-
break;
|
|
368
|
-
case "BASE64":
|
|
369
|
-
object[name] = utils_1.encodeBase64(object[name]);
|
|
370
|
-
break;
|
|
371
|
-
case "HEX":
|
|
372
|
-
case "BLOCK_ID":
|
|
373
|
-
case "TRANSACTION_ID":
|
|
374
|
-
object[name] = `0x${utils_1.toHexString(object[name])}`;
|
|
375
|
-
break;
|
|
376
|
-
default:
|
|
377
|
-
throw new Error(`unknown koinos_byte_type ${options[OP_BYTES]}`);
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
return object;
|
|
293
|
+
throw new Error(`Unknown method id ${op.call_contract.entry_point}`);
|
|
381
294
|
}
|
|
382
295
|
}
|
|
383
296
|
exports.Contract = Contract;
|
package/lib/Contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contract.js","sourceRoot":"","sources":["../src/Contract.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Contract.js","sourceRoot":"","sources":["../src/Contract.ts"],"names":[],"mappings":";;;AAGA,6CAA0C;AAU1C,mCAAmE;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAa,QAAQ;IA6DnB,YAAY,CAcX;;QACC,IAAI,CAAC,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,GAAG,oBAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,C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QAC5D,IAAI,EAAE,CAAC,aAAa,CAAC,WAAW,KAAK,IAAI,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CACb,kCAAkC,oBAAY,CAC5C,IAAI,CAAC,EAAE,CACR,eAAe,oBAAY,CAAC,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAC7D,CAAC;QACJ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YAChE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,EAAE,CAAC,aAAa,CAAC,WAAW,KAAK,MAAM,CAAC,UAAU,EAAE;gBACtD,IAAI,CAAC,MAAM,CAAC,KAAK;oBAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBAC3C,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CACrC,EAAE,CAAC,aAAa,CAAC,IAAI,EACrB,MAAM,CAAC,KAAK,CACb;iBACF,CAAC;aACH;SACF;QACD,MAAM,IAAI,KAAK,CAAC,qBAAqB,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACvE,CAAC;CACF;AA3VD,4BA2VC;AAED,kBAAe,QAAQ,CAAC"}
|
package/lib/Provider.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { BlockJson, TransactionJson, CallContractOperationJson } from "./interface";
|
|
2
|
-
export interface SendTransactionResponse {
|
|
3
|
-
wait: () => Promise<string>;
|
|
4
|
-
}
|
|
1
|
+
import { BlockJson, TransactionJson, CallContractOperationJson, SendTransactionResponse } from "./interface";
|
|
5
2
|
/**
|
|
6
3
|
* Class to connect with the RPC node
|
|
7
4
|
*/
|