koilib 2.0.0 → 2.4.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
@@ -24,13 +24,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Signer = void 0;
26
26
  /* eslint-disable no-param-reassign */
27
- const js_sha256_1 = require("js-sha256");
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"));
27
+ const sha256_1 = require("@noble/hashes/lib/sha256");
28
+ const secp = __importStar(require("@noble/secp256k1"));
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
@@ -140,8 +154,8 @@ class Signer {
140
154
  * @returns Signer object
141
155
  */
142
156
  static fromSeed(seed, compressed) {
143
- const privateKey = js_sha256_1.sha256(seed);
144
- return new Signer(privateKey, compressed);
157
+ const privateKey = sha256_1.sha256(seed);
158
+ return new Signer({ privateKey, compressed });
145
159
  }
146
160
  /**
147
161
  * @param compressed - determines if the address should be
@@ -205,18 +219,17 @@ class Signer {
205
219
  async signTransaction(tx) {
206
220
  if (!tx.active)
207
221
  throw new Error("Active data is not defined");
208
- const hash = js_sha256_1.sha256(utils_1.decodeBase64(tx.active));
209
- const [hex, recovery] = await secp.sign(hash, this.privateKey, {
222
+ const hash = sha256_1.sha256(utils_1.decodeBase64(tx.active));
223
+ const [compSignature, recovery] = await secp.sign(hash, this.privateKey, {
210
224
  recovered: true,
211
225
  canonical: true,
226
+ der: false, // compact signature
212
227
  });
213
- // compact signature
214
- const { r, s } = secp.Signature.fromHex(hex);
215
- const rHex = r.toString(16).padStart(64, "0");
216
- const sHex = s.toString(16).padStart(64, "0");
217
- const recId = (recovery + 31).toString(16).padStart(2, "0");
218
- tx.signatureData = utils_1.encodeBase64(utils_1.toUint8Array(recId + rHex + sHex));
219
- const multihash = `0x1220${hash}`; // 12: code sha2-256. 20: length (32 bytes)
228
+ const compactSignature = new Uint8Array(65);
229
+ compactSignature.set([recovery + 31], 0);
230
+ compactSignature.set(compSignature, 1);
231
+ tx.signature_data = utils_1.encodeBase64(compactSignature);
232
+ const multihash = `0x1220${utils_1.toHexString(hash)}`; // 12: code sha2-256. 20: length (32 bytes)
220
233
  tx.id = multihash;
221
234
  return tx;
222
235
  }
@@ -230,32 +243,83 @@ class Signer {
230
243
  * @returns
231
244
  */
232
245
  async sendTransaction(tx, _abis) {
233
- if (!tx.signatureData || !tx.id)
246
+ if (!tx.signature_data || !tx.id)
234
247
  await this.signTransaction(tx);
235
248
  if (!this.provider)
236
249
  throw new Error("provider is undefined");
237
250
  return this.provider.sendTransaction(tx);
238
251
  }
239
252
  /**
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)
253
+ * Function to recover the public key from a signed
254
+ * transaction or block.
255
+ * The output format can be compressed (default) or uncompressed.
256
+ *
257
+ * @example
258
+ * ```ts
259
+ * const publicKey = await Signer.recoverPublicKey(tx);
260
+ * ```
261
+ *
262
+ * If the signature data contains more data, like in the
263
+ * blocks for PoW consensus, use the "transformSignature"
264
+ * function to extract the signature.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * const powDescriptorJson = {
269
+ * nested: {
270
+ * mypackage: {
271
+ * nested: {
272
+ * pow_signature_data: {
273
+ * fields: {
274
+ * nonce: {
275
+ * type: "bytes",
276
+ * id: 1,
277
+ * },
278
+ * recoverable_signature: {
279
+ * type: "bytes",
280
+ * id: 2,
281
+ * },
282
+ * },
283
+ * },
284
+ * },
285
+ * },
286
+ * },
287
+ * };
288
+ *
289
+ * const serializer = new Serializer(powDescriptorJson, {
290
+ * defaultTypeName: "pow_signature_data",
291
+ * });
292
+ *
293
+ * const signer = await Signer.recoverPublicKey(block, {
294
+ * transformSignature: async (signatureData) => {
295
+ * const powSignatureData = await serializer.deserialize(signatureData);
296
+ * return powSignatureData.recoverable_signature;
297
+ * },
298
+ * });
299
+ * ```
244
300
  */
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));
301
+ static async recoverPublicKey(txOrBlock, opts) {
302
+ if (!txOrBlock.active)
303
+ throw new Error("active is not defined");
304
+ if (!txOrBlock.signature_data)
305
+ throw new Error("signature_data is not defined");
306
+ let signatureData = txOrBlock.signature_data;
307
+ if (opts && typeof opts.transformSignature === "function") {
308
+ signatureData = await opts.transformSignature(txOrBlock.signature_data);
309
+ }
310
+ let compressed = true;
311
+ if (opts && typeof opts.compressed !== "undefined") {
312
+ compressed = opts.compressed;
313
+ }
314
+ const hash = sha256_1.sha256(utils_1.decodeBase64(txOrBlock.active));
315
+ const compactSignatureHex = utils_1.toHexString(utils_1.decodeBase64(signatureData));
252
316
  const recovery = Number(`0x${compactSignatureHex.slice(0, 2)}`) - 31;
253
317
  const rHex = compactSignatureHex.slice(2, 66);
254
318
  const sHex = compactSignatureHex.slice(66);
255
319
  const r = BigInt(`0x${rHex}`);
256
320
  const s = BigInt(`0x${sHex}`);
257
321
  const sig = new secp.Signature(r, s);
258
- const publicKey = secp.recoverPublicKey(hash, sig.toHex(), recovery);
322
+ const publicKey = secp.recoverPublicKey(utils_1.toHexString(hash), sig.toHex(), recovery);
259
323
  if (!publicKey)
260
324
  throw new Error("Public key cannot be recovered");
261
325
  if (!compressed)
@@ -263,20 +327,62 @@ class Signer {
263
327
  return secp.Point.fromHex(publicKey).toHex(true);
264
328
  }
265
329
  /**
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)
330
+ * Function to recover the signer address from a signed
331
+ * transaction or block.
332
+ * The output format can be compressed (default) or uncompressed.
333
+ * @example
334
+ * ```ts
335
+ * const publicKey = await Signer.recoverAddress(tx);
336
+ * ```
337
+ *
338
+ * If the signature data contains more data, like in the
339
+ * blocks for PoW consensus, use the "transformSignature"
340
+ * function to extract the signature.
341
+ *
342
+ * @example
343
+ * ```ts
344
+ * const powDescriptorJson = {
345
+ * nested: {
346
+ * mypackage: {
347
+ * nested: {
348
+ * pow_signature_data: {
349
+ * fields: {
350
+ * nonce: {
351
+ * type: "bytes",
352
+ * id: 1,
353
+ * },
354
+ * recoverable_signature: {
355
+ * type: "bytes",
356
+ * id: 2,
357
+ * },
358
+ * },
359
+ * },
360
+ * },
361
+ * },
362
+ * },
363
+ * };
364
+ *
365
+ * const serializer = new Serializer(powDescriptorJson, {
366
+ * defaultTypeName: "pow_signature_data",
367
+ * });
368
+ *
369
+ * const signer = await Signer.recoverAddress(block, {
370
+ * transformSignature: async (signatureData) => {
371
+ * const powSignatureData = await serializer.deserialize(signatureData);
372
+ * return powSignatureData.recoverable_signature;
373
+ * },
374
+ * });
375
+ * ```
270
376
  */
271
- static recoverAddress(tx, compressed = true) {
272
- const publicKey = Signer.recoverPublicKey(tx, compressed);
377
+ static async recoverAddress(txOrBlock, opts) {
378
+ const publicKey = await Signer.recoverPublicKey(txOrBlock, opts);
273
379
  return utils_1.bitcoinAddress(utils_1.toUint8Array(publicKey));
274
380
  }
275
381
  /**
276
382
  * Function to encode a transaction
277
- * @param activeData - Active data consists of nonce, rcLimit, and
383
+ * @param activeData - Active data consists of nonce, rc_limit, and
278
384
  * operations. Do not set the nonce to get it from the blockchain
279
- * using the provider. The rcLimit is 1000000 by default.
385
+ * using the provider. The rc_limit is 1000000 by default.
280
386
  * @returns A transaction encoded. The active field is encoded in
281
387
  * base64url
282
388
  */
@@ -289,15 +395,14 @@ class Signer {
289
395
  // this depends on the final architecture for names on Koinos
290
396
  nonce = await this.provider.getNonce(this.getAddress());
291
397
  }
292
- const rcLimit = activeData.rcLimit === undefined ? 1000000 : activeData.rcLimit;
398
+ const rcLimit = activeData.rc_limit === undefined ? 1000000 : activeData.rc_limit;
293
399
  const operations = activeData.operations ? activeData.operations : [];
294
400
  const activeData2 = {
295
- rcLimit,
401
+ rc_limit: rcLimit,
296
402
  nonce,
297
403
  operations,
298
404
  };
299
- const message = ActiveTxDataMsg.create(activeData2);
300
- const buffer = ActiveTxDataMsg.encode(message).finish();
405
+ const buffer = await this.serializer.serialize(activeData2);
301
406
  return {
302
407
  active: utils_1.encodeBase64(buffer),
303
408
  };
@@ -305,12 +410,10 @@ class Signer {
305
410
  /**
306
411
  * Function to decode a transaction
307
412
  */
308
- static decodeTransaction(tx) {
413
+ async decodeTransaction(tx) {
309
414
  if (!tx.active)
310
415
  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 });
416
+ return this.serializer.deserialize(tx.active);
314
417
  }
315
418
  }
316
419
  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,yCAAmC;AACnC,sDAAwC;AACxC,4CAAwC;AAGxC,gFAAiD;AACjD,mCAQiB;AAGjB,MAAM,IAAI,GAAG,YAAI,CAAC,QAAQ,CAAC,6BAAY,CAAC,CAAC;AACzC,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC;AAiBnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAa,MAAM;IAqBjB;;;;;;;;;;;;;;OAcG;IACH,YACE,UAAiD,EACjD,UAAU,GAAG,IA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ACzC,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;AAvYD,wBAuYC;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: (type?: "byTransactionId" | "byBlock") => 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
  }