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/lib/Signer.js CHANGED
@@ -26,11 +26,9 @@ exports.Signer = void 0;
26
26
  /* eslint-disable no-param-reassign */
27
27
  const js_sha256_1 = require("js-sha256");
28
28
  const secp = __importStar(require("noble-secp256k1"));
29
- const light_1 = require("protobufjs/light");
30
- const protocol_proto_json_1 = __importDefault(require("./protocol-proto.json"));
29
+ const protocol_proto_json_1 = __importDefault(require("./jsonDescriptors/protocol-proto.json"));
31
30
  const utils_1 = require("./utils");
32
- const root = light_1.Root.fromJSON(protocol_proto_json_1.default);
33
- const ActiveTxDataMsg = root.lookupType("active_transaction_data");
31
+ const Serializer_1 = require("./Serializer");
34
32
  /**
35
33
  * The Signer Class contains the private key needed to sign transactions.
36
34
  * It can be created using the seed, wif, or private key
@@ -38,7 +36,8 @@ const ActiveTxDataMsg = root.lookupType("active_transaction_data");
38
36
  * @example
39
37
  * using private key as hex string
40
38
  * ```ts
41
- * var signer = new Signer("ec8601a24f81decd57f4b611b5ac6eb801cb3780bb02c0f9cdfe9d09daaddf9c");
39
+ * var privateKey = "ec8601a24f81decd57f4b611b5ac6eb801cb3780bb02c0f9cdfe9d09daaddf9c";
40
+ * var signer = new Signer({ privateKey });
42
41
  * ```
43
42
  * <br>
44
43
  *
@@ -50,14 +49,15 @@ const ActiveTxDataMsg = root.lookupType("active_transaction_data");
50
49
  * 1, 203, 55, 128, 187, 2, 192, 249,
51
50
  * 205, 254, 157, 9, 218, 173, 223, 156
52
51
  * ]);
53
- * var signer = new Signer(buffer);
52
+ * var signer = new Signer({ privateKey: buffer });
54
53
  * ```
55
54
  *
56
55
  * <br>
57
56
  *
58
57
  * using private key as bigint
59
58
  * ```ts
60
- * var signer = new Signer(106982601049961974618234078204952280507266494766432547312316920283818886029212n);
59
+ * var privateKey = 106982601049961974618234078204952280507266494766432547312316920283818886029212n;
60
+ * var signer = new Signer({ privateKey });
61
61
  * ```
62
62
  *
63
63
  * <br>
@@ -79,7 +79,8 @@ const ActiveTxDataMsg = root.lookupType("active_transaction_data");
79
79
  * defining a provider
80
80
  * ```ts
81
81
  * var provider = new Provider(["https://example.com/jsonrpc"]);
82
- * var signer = new Signer("ec8601a24f81decd57f4b611b5ac6eb801cb3780bb02c0f9cdfe9d09daaddf9c", true, provider);
82
+ * var privateKey = "ec8601a24f81decd57f4b611b5ac6eb801cb3780bb02c0f9cdfe9d09daaddf9c";
83
+ * var signer = new Signer({ privateKey, provider });
83
84
  * ```
84
85
  */
85
86
  class Signer {
@@ -93,21 +94,31 @@ class Signer {
93
94
  * @param provider - provider to connect with the blockchain
94
95
  * @example
95
96
  * ```ts
96
- * cons signer = new Signer("ec8601a24f81decd57f4b611b5ac6eb801cb3780bb02c0f9cdfe9d09daaddf9c");
97
+ * const privateKey = "ec8601a24f81decd57f4b611b5ac6eb801cb3780bb02c0f9cdfe9d09daaddf9c";
98
+ * cons signer = new Signer({ privateKey });
97
99
  * console.log(signer.getAddress());
98
100
  * // 1MbL6mG8ASAvSYdoMnGUfG3ZXkmQ2dpL5b
99
101
  * ```
100
102
  */
101
- constructor(privateKey, compressed = true, provider) {
102
- this.compressed = compressed;
103
- this.privateKey = privateKey;
104
- this.provider = provider;
105
- if (typeof privateKey === "string") {
106
- this.publicKey = secp.getPublicKey(privateKey, this.compressed);
103
+ constructor(c) {
104
+ this.compressed = typeof c.compressed === "undefined" ? true : c.compressed;
105
+ this.privateKey = c.privateKey;
106
+ this.provider = c.provider;
107
+ if (c.serializer) {
108
+ this.serializer = c.serializer;
109
+ }
110
+ else {
111
+ this.serializer = new Serializer_1.Serializer(protocol_proto_json_1.default, {
112
+ defaultTypeName: "active_transaction_data",
113
+ bytesConversion: false,
114
+ });
115
+ }
116
+ if (typeof c.privateKey === "string") {
117
+ this.publicKey = secp.getPublicKey(c.privateKey, this.compressed);
107
118
  this.address = utils_1.bitcoinAddress(utils_1.toUint8Array(this.publicKey));
108
119
  }
109
120
  else {
110
- this.publicKey = secp.getPublicKey(privateKey, this.compressed);
121
+ this.publicKey = secp.getPublicKey(c.privateKey, this.compressed);
111
122
  this.address = utils_1.bitcoinAddress(this.publicKey);
112
123
  }
113
124
  }
@@ -125,7 +136,10 @@ class Signer {
125
136
  static fromWif(wif) {
126
137
  const compressed = wif[0] !== "5";
127
138
  const privateKey = utils_1.bitcoinDecode(wif);
128
- return new Signer(utils_1.toHexString(privateKey), compressed);
139
+ return new Signer({
140
+ privateKey: utils_1.toHexString(privateKey),
141
+ compressed,
142
+ });
129
143
  }
130
144
  /**
131
145
  * Function to import a private key from the seed
@@ -141,7 +155,7 @@ class Signer {
141
155
  */
142
156
  static fromSeed(seed, compressed) {
143
157
  const privateKey = js_sha256_1.sha256(seed);
144
- return new Signer(privateKey, compressed);
158
+ return new Signer({ privateKey, compressed });
145
159
  }
146
160
  /**
147
161
  * @param compressed - determines if the address should be
@@ -215,7 +229,7 @@ class Signer {
215
229
  const rHex = r.toString(16).padStart(64, "0");
216
230
  const sHex = s.toString(16).padStart(64, "0");
217
231
  const recId = (recovery + 31).toString(16).padStart(2, "0");
218
- tx.signatureData = utils_1.encodeBase64(utils_1.toUint8Array(recId + rHex + sHex));
232
+ tx.signature_data = utils_1.encodeBase64(utils_1.toUint8Array(recId + rHex + sHex));
219
233
  const multihash = `0x1220${hash}`; // 12: code sha2-256. 20: length (32 bytes)
220
234
  tx.id = multihash;
221
235
  return tx;
@@ -230,25 +244,76 @@ class Signer {
230
244
  * @returns
231
245
  */
232
246
  async sendTransaction(tx, _abis) {
233
- if (!tx.signatureData || !tx.id)
247
+ if (!tx.signature_data || !tx.id)
234
248
  await this.signTransaction(tx);
235
249
  if (!this.provider)
236
250
  throw new Error("provider is undefined");
237
251
  return this.provider.sendTransaction(tx);
238
252
  }
239
253
  /**
240
- * Function to recover the public key from a signed transaction.
241
- * The output format can be compressed or uncompressed.
242
- * @param tx - signed transaction
243
- * @param compressed - output format (compressed by default)
254
+ * Function to recover the public key from a signed
255
+ * transaction or block.
256
+ * The output format can be compressed (default) or uncompressed.
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * const publicKey = await Signer.recoverPublicKey(tx);
261
+ * ```
262
+ *
263
+ * If the signature data contains more data, like in the
264
+ * blocks for PoW consensus, use the "transformSignature"
265
+ * function to extract the signature.
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * const powDescriptorJson = {
270
+ * nested: {
271
+ * mypackage: {
272
+ * nested: {
273
+ * pow_signature_data: {
274
+ * fields: {
275
+ * nonce: {
276
+ * type: "bytes",
277
+ * id: 1,
278
+ * },
279
+ * recoverable_signature: {
280
+ * type: "bytes",
281
+ * id: 2,
282
+ * },
283
+ * },
284
+ * },
285
+ * },
286
+ * },
287
+ * },
288
+ * };
289
+ *
290
+ * const serializer = new Serializer(powDescriptorJson, {
291
+ * defaultTypeName: "pow_signature_data",
292
+ * });
293
+ *
294
+ * const signer = await Signer.recoverPublicKey(block, {
295
+ * transformSignature: async (signatureData) => {
296
+ * const powSignatureData = await serializer.deserialize(signatureData);
297
+ * return powSignatureData.recoverable_signature;
298
+ * },
299
+ * });
300
+ * ```
244
301
  */
245
- static recoverPublicKey(tx, compressed = true) {
246
- if (!tx.active)
247
- throw new Error("activeData is not defined");
248
- if (!tx.signatureData)
249
- throw new Error("signatureData is not defined");
250
- const hash = js_sha256_1.sha256(utils_1.decodeBase64(tx.active));
251
- const compactSignatureHex = utils_1.toHexString(utils_1.decodeBase64(tx.signatureData));
302
+ static async recoverPublicKey(txOrBlock, opts) {
303
+ if (!txOrBlock.active)
304
+ throw new Error("active is not defined");
305
+ if (!txOrBlock.signature_data)
306
+ throw new Error("signature_data is not defined");
307
+ let signatureData = txOrBlock.signature_data;
308
+ if (opts && typeof opts.transformSignature === "function") {
309
+ signatureData = await opts.transformSignature(txOrBlock.signature_data);
310
+ }
311
+ let compressed = true;
312
+ if (opts && typeof opts.compressed !== "undefined") {
313
+ compressed = opts.compressed;
314
+ }
315
+ const hash = js_sha256_1.sha256(utils_1.decodeBase64(txOrBlock.active));
316
+ const compactSignatureHex = utils_1.toHexString(utils_1.decodeBase64(signatureData));
252
317
  const recovery = Number(`0x${compactSignatureHex.slice(0, 2)}`) - 31;
253
318
  const rHex = compactSignatureHex.slice(2, 66);
254
319
  const sHex = compactSignatureHex.slice(66);
@@ -263,20 +328,62 @@ class Signer {
263
328
  return secp.Point.fromHex(publicKey).toHex(true);
264
329
  }
265
330
  /**
266
- * Function to recover the signer address from a signed transaction.
267
- * The output format can be compressed or uncompressed.
268
- * @param tx - signed transaction
269
- * @param compressed - output format (compressed by default)
331
+ * Function to recover the signer address from a signed
332
+ * transaction or block.
333
+ * The output format can be compressed (default) or uncompressed.
334
+ * @example
335
+ * ```ts
336
+ * const publicKey = await Signer.recoverAddress(tx);
337
+ * ```
338
+ *
339
+ * If the signature data contains more data, like in the
340
+ * blocks for PoW consensus, use the "transformSignature"
341
+ * function to extract the signature.
342
+ *
343
+ * @example
344
+ * ```ts
345
+ * const powDescriptorJson = {
346
+ * nested: {
347
+ * mypackage: {
348
+ * nested: {
349
+ * pow_signature_data: {
350
+ * fields: {
351
+ * nonce: {
352
+ * type: "bytes",
353
+ * id: 1,
354
+ * },
355
+ * recoverable_signature: {
356
+ * type: "bytes",
357
+ * id: 2,
358
+ * },
359
+ * },
360
+ * },
361
+ * },
362
+ * },
363
+ * },
364
+ * };
365
+ *
366
+ * const serializer = new Serializer(powDescriptorJson, {
367
+ * defaultTypeName: "pow_signature_data",
368
+ * });
369
+ *
370
+ * const signer = await Signer.recoverAddress(block, {
371
+ * transformSignature: async (signatureData) => {
372
+ * const powSignatureData = await serializer.deserialize(signatureData);
373
+ * return powSignatureData.recoverable_signature;
374
+ * },
375
+ * });
376
+ * ```
270
377
  */
271
- static recoverAddress(tx, compressed = true) {
272
- const publicKey = Signer.recoverPublicKey(tx, compressed);
378
+ static async recoverAddress(txOrBlock, opts) {
379
+ const publicKey = await Signer.recoverPublicKey(txOrBlock, opts);
273
380
  return utils_1.bitcoinAddress(utils_1.toUint8Array(publicKey));
274
381
  }
275
382
  /**
276
383
  * Function to encode a transaction
277
- * @param activeData - Active data consists of nonce, rcLimit, and
384
+ * @param activeData - Active data consists of nonce, rc_limit, and
278
385
  * operations. Do not set the nonce to get it from the blockchain
279
- * using the provider. The rcLimit is 1000000 by default.
386
+ * using the provider. The rc_limit is 1000000 by default.
280
387
  * @returns A transaction encoded. The active field is encoded in
281
388
  * base64url
282
389
  */
@@ -289,15 +396,14 @@ class Signer {
289
396
  // this depends on the final architecture for names on Koinos
290
397
  nonce = await this.provider.getNonce(this.getAddress());
291
398
  }
292
- const rcLimit = activeData.rcLimit === undefined ? 1000000 : activeData.rcLimit;
399
+ const rcLimit = activeData.rc_limit === undefined ? 1000000 : activeData.rc_limit;
293
400
  const operations = activeData.operations ? activeData.operations : [];
294
401
  const activeData2 = {
295
- rcLimit,
402
+ rc_limit: rcLimit,
296
403
  nonce,
297
404
  operations,
298
405
  };
299
- const message = ActiveTxDataMsg.create(activeData2);
300
- const buffer = ActiveTxDataMsg.encode(message).finish();
406
+ const buffer = await this.serializer.serialize(activeData2);
301
407
  return {
302
408
  active: utils_1.encodeBase64(buffer),
303
409
  };
@@ -305,12 +411,10 @@ class Signer {
305
411
  /**
306
412
  * Function to decode a transaction
307
413
  */
308
- static decodeTransaction(tx) {
414
+ async decodeTransaction(tx) {
309
415
  if (!tx.active)
310
416
  throw new Error("Active data is not defined");
311
- const buffer = utils_1.decodeBase64(tx.active);
312
- const message = ActiveTxDataMsg.decode(buffer);
313
- return ActiveTxDataMsg.toObject(message, { longs: String });
417
+ return this.serializer.deserialize(tx.active);
314
418
  }
315
419
  }
316
420
  exports.Signer = Signer;
package/lib/Signer.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Signer.js","sourceRoot":"","sources":["../src/Signer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,yCAA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iBAAiB,CACrB,UAAiC;QAEjC,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;QAC3B,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YAClC,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAChB,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;YACJ,gCAAgC;YAChC,6DAA6D;YAC7D,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;SACzD;QACD,MAAM,OAAO,GACX,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;QACpE,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QAEtE,MAAM,WAAW,GAA0B;YACzC,QAAQ,EAAE,OAAO;YACjB,KAAK;YACL,UAAU;SACX,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAE7D,OAAO;YACL,MAAM,EAAE,oBAAY,CAAC,MAAM,CAAC;SACV,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAC,EAAmB;QACzC,IAAI,CAAC,EAAE,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,UAAW,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACF;AArYD,wBAqYC;AAED,kBAAe,MAAM,CAAC"}
package/lib/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * as interfaces from "./interface";
4
4
  export * from "./Contract";
5
5
  export * from "./Signer";
6
6
  export * from "./Provider";
7
+ export * from "./Serializer";
package/lib/index.js CHANGED
@@ -30,4 +30,5 @@ exports.interfaces = __importStar(require("./interface"));
30
30
  __exportStar(require("./Contract"), exports);
31
31
  __exportStar(require("./Signer"), exports);
32
32
  __exportStar(require("./Provider"), exports);
33
+ __exportStar(require("./Serializer"), exports);
33
34
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAAwE;AACxE,iCAAiC;AACjC,iDAAiC;AACjC,0DAA0C;AAC1C,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAAwE;AACxE,iCAAiC;AACjC,iDAAiC;AACjC,0DAA0C;AAC1C,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B;AAC3B,+CAA6B"}
package/lib/index2.js CHANGED
@@ -24,8 +24,10 @@ const utils = __importStar(require("./utils"));
24
24
  const Contract_1 = require("./Contract");
25
25
  const Signer_1 = require("./Signer");
26
26
  const Provider_1 = require("./Provider");
27
+ const Serializer_1 = require("./Serializer");
27
28
  window.utils = utils;
28
29
  window.Contract = Contract_1.Contract;
29
30
  window.Signer = Signer_1.Signer;
30
31
  window.Provider = Provider_1.Provider;
32
+ window.Serializer = Serializer_1.Serializer;
31
33
  //# sourceMappingURL=index2.js.map
package/lib/index2.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index2.js","sourceRoot":"","sources":["../src/index2.ts"],"names":[],"mappings":";AAAA,wEAAwE;;;;;;;;;;;;;;;;;;;;;AAExE,+CAAiC;AACjC,yCAAsC;AACtC,qCAAkC;AAClC,yCAAsC;AAItC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;AACrB,MAAM,CAAC,QAAQ,GAAG,mBAAQ,CAAC;AAC3B,MAAM,CAAC,MAAM,GAAG,eAAM,CAAC;AACvB,MAAM,CAAC,QAAQ,GAAG,mBAAQ,CAAC"}
1
+ {"version":3,"file":"index2.js","sourceRoot":"","sources":["../src/index2.ts"],"names":[],"mappings":";AAAA,wEAAwE;;;;;;;;;;;;;;;;;;;;;AAExE,+CAAiC;AACjC,yCAAsC;AACtC,qCAAkC;AAClC,yCAAsC;AACtC,6CAA0C;AAI1C,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;AACrB,MAAM,CAAC,QAAQ,GAAG,mBAAQ,CAAC;AAC3B,MAAM,CAAC,MAAM,GAAG,eAAM,CAAC;AACvB,MAAM,CAAC,QAAQ,GAAG,mBAAQ,CAAC;AAC3B,MAAM,CAAC,UAAU,GAAG,uBAAU,CAAC"}
@@ -1,65 +1,202 @@
1
+ import { INamespace } from "protobufjs/light";
2
+ /**
3
+ * Application Binary Interface (ABI)
4
+ *
5
+ * ABIs are composed of 2 elements: methods and types.
6
+ * - The methods define the names of the entries of the smart contract,
7
+ * the corresponding endpoints and the name of the types used.
8
+ * - The types all the description to serialize and deserialize
9
+ * using proto buffers.
10
+ *
11
+ * To generate the types is necessary to use the dependency
12
+ * protobufjs. The following example shows how to generate the
13
+ * protobuf descriptor from a .proto file.
14
+ *
15
+ * ```js
16
+ * const fs = require("fs");
17
+ * const pbjs = require("protobufjs/cli/pbjs");
18
+ *
19
+ * pbjs.main(
20
+ * ["--target", "json", "./token.proto"],
21
+ * (err, output) => {
22
+ * if (err) throw err;
23
+ * fs.writeFileSync("./token-proto.json", output);
24
+ * }
25
+ * );
26
+ * ```
27
+ *
28
+ * Then this descriptor can be loaded to define the ABI:
29
+ * ```js
30
+ * const tokenJson = require("./token-proto.json");
31
+ * const abiToken = {
32
+ * methods: {
33
+ * balanceOf: {
34
+ * entryPoint: 0x15619248,
35
+ * inputs: "balance_of_arguments",
36
+ * outputs: "balance_of_result",
37
+ * readOnly: true,
38
+ * defaultOutput: { value: "0" },
39
+ * },
40
+ * transfer: {
41
+ * entryPoint: 0x62efa292,
42
+ * inputs: "transfer_arguments",
43
+ * outputs: "transfer_result",
44
+ * },
45
+ * mint: {
46
+ * entryPoint: 0xc2f82bdc,
47
+ * inputs: "mint_argumnets",
48
+ * outputs: "mint_result",
49
+ * },
50
+ * },
51
+ * types: tokenJson,
52
+ * };
53
+ * ```
54
+ *
55
+ * Note that this example uses "defaultOutput" for the method
56
+ * "balanceOf". This is used when the smart contract returns an
57
+ * empty response (for instance when there are no balance records
58
+ * for a specific address) and you require a default output in
59
+ * such cases.
60
+ */
61
+ export interface Abi {
62
+ methods: {
63
+ /** Name of the method */
64
+ [x: string]: {
65
+ /** Entry point ID */
66
+ entryPoint: number;
67
+ /** Protobuffer type for input */
68
+ input?: string;
69
+ /** Protobuffer type for output */
70
+ output?: string;
71
+ /** Boolean to differentiate write methods
72
+ * (using transactions) from read methods
73
+ * (query the contract)
74
+ */
75
+ readOnly?: boolean;
76
+ /** Default value when the output is undefined */
77
+ defaultOutput?: unknown;
78
+ /** Optional function to preformat the input */
79
+ preformatInput?: (input: unknown) => Record<string, unknown>;
80
+ /** Optional function to preformat the output */
81
+ preformatOutput?: (output: Record<string, unknown>) => unknown;
82
+ /** Description of the method */
83
+ description?: string;
84
+ };
85
+ };
86
+ /**
87
+ * Protobuffers descriptor in JSON format.
88
+ * See https://www.npmjs.com/package/protobufjs#using-json-descriptors
89
+ */
90
+ types: INamespace;
91
+ }
92
+ /**
93
+ * Human readable format operation
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const opDecoded = {
98
+ * name: "transfer",
99
+ * args: {
100
+ * from: "1Krs7v1rtpgRyfwEZncuKMQQnY5JhqXVSx",
101
+ * to: "1BqtgWBcqm9cSZ97avLGZGJdgso7wx6pCA",
102
+ * value: 1000,
103
+ * },
104
+ * };
105
+ * ```
106
+ */
107
+ export interface DecodedOperationJson {
108
+ /** Operation name */
109
+ name: string;
110
+ /** Arguments decoded. See [[Abi]] */
111
+ args?: Record<string, unknown>;
112
+ }
113
+ export interface TransactionOptions {
114
+ rc_limit?: number | bigint | string;
115
+ nonce?: number;
116
+ sendTransaction?: boolean;
117
+ sendAbis?: boolean;
118
+ }
119
+ export interface RecoverPublicKeyOptions {
120
+ /**
121
+ * Boolean to define if the public key should
122
+ * be compressed or not. It is true by default
123
+ */
124
+ compressed?: boolean;
125
+ /**
126
+ * Asynchronous function to transform the signature
127
+ * before calculating the public key associated.
128
+ * This transformation is useful in cases were the
129
+ * signature contains additional data. For instance,
130
+ * the signatures for blocks in the PoW consensus
131
+ * algorithm contain the nonce.
132
+ */
133
+ transformSignature?: (signatureData: string) => Promise<string>;
134
+ }
135
+ export interface SendTransactionResponse {
136
+ wait: () => Promise<string>;
137
+ }
1
138
  declare type NumberLike = number | bigint | string;
2
139
  export interface UploadContractOperation {
3
- contractId?: Uint8Array;
140
+ contract_id?: Uint8Array;
4
141
  bytecode?: Uint8Array;
5
142
  }
6
143
  export interface UploadContractOperationJson {
7
- contractId?: string;
144
+ contract_id?: string;
8
145
  bytecode?: string;
9
146
  }
10
147
  export interface CallContractOperation {
11
- contractId: Uint8Array;
12
- entryPoint: number;
148
+ contract_id: Uint8Array;
149
+ entry_point: number;
13
150
  args: Uint8Array;
14
151
  }
15
152
  export interface CallContractOperationJson {
16
- contractId: string;
17
- entryPoint: number;
153
+ contract_id: string;
154
+ entry_point: number;
18
155
  args: string;
19
156
  }
20
157
  export interface ContractCallBundle {
21
- contractId: Uint8Array;
22
- entryPoint: number;
158
+ contract_id: Uint8Array;
159
+ entry_point: number;
23
160
  }
24
161
  export interface ContractCallBundleJson {
25
- contractId: string;
26
- entryPoint: number;
162
+ contract_id: string;
163
+ entry_point: number;
27
164
  }
28
165
  export interface ThunkIdNested {
29
- thunkId: number;
166
+ thunk_id: number;
30
167
  }
31
168
  export interface ContractCallBundleNested {
32
- systemCallBundle: ContractCallBundle;
169
+ system_call_bundle: ContractCallBundle;
33
170
  }
34
171
  export declare type SystemCallTarget = ThunkIdNested | ContractCallBundleNested;
35
172
  export interface SetSystemCallOperation {
36
- callId: number;
173
+ call_id: number;
37
174
  target: SystemCallTarget;
38
175
  }
39
176
  export interface SetSystemCallOperationJson {
40
- callId: number;
177
+ call_id: number;
41
178
  target: number | ContractCallBundleJson;
42
179
  }
43
180
  export interface UploadContractOperationNested {
44
- uploadContract: UploadContractOperation;
181
+ upload_contract: UploadContractOperation;
45
182
  }
46
183
  export interface CallContractOperationNested {
47
- callContract: CallContractOperation;
184
+ call_contract: CallContractOperation;
48
185
  }
49
186
  export interface SetSystemCallOperationNested {
50
- setSystemCall: SetSystemCallOperation;
187
+ set_system_call: SetSystemCallOperation;
51
188
  }
52
189
  export declare type Operation = UploadContractOperationNested | CallContractOperationNested | SetSystemCallOperationNested;
53
190
  export declare type OperationJson = {
54
- uploadContract?: UploadContractOperationJson;
55
- callContract?: CallContractOperationJson;
56
- setSystemCall?: SetSystemCallOperationJson;
191
+ upload_contract?: UploadContractOperationJson;
192
+ call_contract?: CallContractOperationJson;
193
+ set_system_call?: SetSystemCallOperationJson;
57
194
  };
58
195
  export interface ActiveTransactionData {
59
196
  /**
60
197
  * Resource credits limit
61
198
  */
62
- rcLimit?: string | number | bigint;
199
+ rc_limit?: string | number | bigint;
63
200
  /**
64
201
  * Account nonce
65
202
  */
@@ -74,7 +211,7 @@ export interface ActiveTransactionDataJson {
74
211
  /**
75
212
  * Resource credits limit
76
213
  */
77
- rcLimit?: string | number | bigint;
214
+ rc_limit?: string | number | bigint;
78
215
  /**
79
216
  * Account nonce
80
217
  */
@@ -105,7 +242,7 @@ export interface TransactionJson {
105
242
  /**
106
243
  * Signature in compact format enconded in multi base64
107
244
  */
108
- signatureData?: string;
245
+ signature_data?: string;
109
246
  }
110
247
  export interface BlockHeaderJson {
111
248
  previous?: string;
@@ -118,7 +255,7 @@ export interface BlockJson {
118
255
  header?: BlockHeaderJson;
119
256
  active?: string;
120
257
  passive?: string;
121
- signatureData?: string;
258
+ signature_data?: string;
122
259
  transactions?: TransactionJson[];
123
260
  [x: string]: unknown;
124
261
  }
@@ -164,7 +164,7 @@
164
164
  "jstype": "JS_STRING"
165
165
  }
166
166
  },
167
- "lastManaUpdate": {
167
+ "last_mana_update": {
168
168
  "type": "uint64",
169
169
  "id": 3,
170
170
  "options": {