@super-protocol/sdk-js 0.10.2-beta.3 → 0.10.6-beta.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.
@@ -6,6 +6,7 @@ declare class BlockchainConnector {
6
6
  private static logger;
7
7
  private static contract;
8
8
  private static provider?;
9
+ private static providerHttps?;
9
10
  static defaultActionAccount?: string;
10
11
  private static initContracts;
11
12
  static getContractInstance(transactionOptions?: TransactionOptions): Contract;
@@ -54,6 +55,7 @@ declare class BlockchainConnector {
54
55
  */
55
56
  static getTransactionCount(address: string, status?: string): Promise<number>;
56
57
  static getAddressByKey(pk: string): string;
58
+ private static executeBatchAsync;
57
59
  /**
58
60
  * Fetch transactions for specific addresses starting with specific block until last block
59
61
  * @param addresses - array of addresses to fetch transactions (from these addresses and to these addresses)
@@ -68,10 +70,10 @@ declare class BlockchainConnector {
68
70
  static getTransactions(addresses: string[], startBlock?: number, lastBlock?: number, batchSize?: number): Promise<BlockchainTransaction>;
69
71
  static disconnect(): void;
70
72
  }
71
- export declare type onNewBlockCallback = (blockInfo: BlockInfo) => void;
72
73
  export declare type Config = {
73
74
  contractAddress: string;
74
75
  blockchainUrl?: string;
76
+ blockchainHttpsUrl?: string;
75
77
  gasPrice?: string;
76
78
  gasLimit?: number;
77
79
  gasLimitMultiplier?: number;
@@ -52,6 +52,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var logger_1 = __importDefault(require("./logger"));
54
54
  var web3_1 = __importDefault(require("web3"));
55
+ var web3_core_helpers_1 = require("web3-core-helpers");
55
56
  var store_1 = __importDefault(require("./store"));
56
57
  var constants_1 = require("./constants");
57
58
  var utils_1 = require("./utils");
@@ -60,6 +61,7 @@ var SuperproToken_1 = __importDefault(require("./staticModels/SuperproToken"));
60
61
  var TxManager_1 = __importDefault(require("./utils/TxManager"));
61
62
  var app_json_1 = __importDefault(require("./contracts/app.json"));
62
63
  var ethers_1 = require("ethers");
64
+ var Jsonrpc = require('web3-core-requestmanager/src/jsonrpc');
63
65
  var BlockchainConnector = /** @class */ (function () {
64
66
  function BlockchainConnector() {
65
67
  }
@@ -90,6 +92,10 @@ var BlockchainConnector = /** @class */ (function () {
90
92
  switch (_b.label) {
91
93
  case 0:
92
94
  url = (config === null || config === void 0 ? void 0 : config.blockchainUrl) || constants_1.defaultBlockchainUrl;
95
+ if (config === null || config === void 0 ? void 0 : config.blockchainHttpsUrl) {
96
+ this.providerHttps = new web3_1.default.providers.HttpProvider(config === null || config === void 0 ? void 0 : config.blockchainHttpsUrl);
97
+ store_1.default.web3Https = new web3_1.default(this.providerHttps);
98
+ }
93
99
  if (this.provider) {
94
100
  if (this.provider instanceof web3_1.default.providers.WebsocketProvider) {
95
101
  this.provider.reset();
@@ -308,6 +314,32 @@ var BlockchainConnector = /** @class */ (function () {
308
314
  BlockchainConnector.getAddressByKey = function (pk) {
309
315
  return new ethers_1.Wallet(pk).address;
310
316
  };
317
+ BlockchainConnector.executeBatchAsync = function (batch) {
318
+ return __awaiter(this, void 0, void 0, function () {
319
+ return __generator(this, function (_a) {
320
+ return [2 /*return*/, new Promise(function (resolve, reject) {
321
+ var requests = batch.requests;
322
+ batch.requestManager.sendBatch(requests, function (error, results) {
323
+ if (error)
324
+ return reject(error);
325
+ results = results || [];
326
+ var response = requests.map(function (request, index) {
327
+ return results[index] || {};
328
+ }).map(function (result, index) {
329
+ if (result && result.error) {
330
+ return web3_core_helpers_1.errors.ErrorResponse(result);
331
+ }
332
+ if (!Jsonrpc.isValidResponse(result)) {
333
+ return web3_core_helpers_1.errors.InvalidResponse(result);
334
+ }
335
+ return requests[index].format ? requests[index].format(result.result) : result.result;
336
+ });
337
+ resolve(response);
338
+ });
339
+ })];
340
+ });
341
+ });
342
+ };
311
343
  /**
312
344
  * Fetch transactions for specific addresses starting with specific block until last block
313
345
  * @param addresses - array of addresses to fetch transactions (from these addresses and to these addresses)
@@ -322,69 +354,56 @@ var BlockchainConnector = /** @class */ (function () {
322
354
  BlockchainConnector.getTransactions = function (addresses, startBlock, lastBlock, batchSize) {
323
355
  if (batchSize === void 0) { batchSize = constants_1.BLOCK_SIZE_TO_FETCH_TRANSACTION; }
324
356
  return __awaiter(this, void 0, void 0, function () {
325
- var endBlock, _a, blocksNumbersToFetch, activeStep, i, transactionsByAddress, i;
326
- var _this = this;
327
- return __generator(this, function (_b) {
328
- switch (_b.label) {
357
+ var transactionsByAddress, batch, getBlock, batchLastBlock, blockNumber, blocks;
358
+ return __generator(this, function (_a) {
359
+ switch (_a.label) {
329
360
  case 0:
330
- if (!lastBlock) return [3 /*break*/, 1];
331
- _a = lastBlock;
332
- return [3 /*break*/, 3];
333
- case 1: return [4 /*yield*/, store_1.default.web3.eth.getBlockNumber()];
361
+ (0, utils_1.checkIfHttpsInitialized)();
362
+ if (!!lastBlock) return [3 /*break*/, 2];
363
+ return [4 /*yield*/, store_1.default.web3Https.eth.getBlockNumber()];
364
+ case 1:
365
+ lastBlock = _a.sent();
366
+ if (!lastBlock) {
367
+ lastBlock = 0;
368
+ }
369
+ _a.label = 2;
334
370
  case 2:
335
- _a = _b.sent();
336
- _b.label = 3;
337
- case 3:
338
- endBlock = _a;
339
- if (!startBlock)
340
- startBlock = Math.max(endBlock - 1000, 0);
341
- blocksNumbersToFetch = [[]];
342
- activeStep = blocksNumbersToFetch[0];
343
- for (i = startBlock; i <= endBlock; i++) {
344
- activeStep.push(i);
345
- if (activeStep.length >= batchSize) {
346
- blocksNumbersToFetch.push([]);
347
- activeStep = blocksNumbersToFetch[blocksNumbersToFetch.length - 1];
348
- }
371
+ if (!startBlock) {
372
+ startBlock = Math.max(lastBlock - 1000, 0);
349
373
  }
350
374
  transactionsByAddress = {};
351
375
  addresses.forEach(function (address) { return (transactionsByAddress[address] = []); });
352
- i = 0;
353
- _b.label = 4;
376
+ _a.label = 3;
377
+ case 3:
378
+ if (!(startBlock <= lastBlock)) return [3 /*break*/, 5];
379
+ batch = new store_1.default.web3Https.eth.BatchRequest();
380
+ getBlock = store_1.default.web3Https.eth.getBlock;
381
+ batchLastBlock = Math.min(startBlock + batchSize - 1, lastBlock);
382
+ for (blockNumber = startBlock; blockNumber <= batchLastBlock; blockNumber++) {
383
+ batch.add(getBlock.request(blockNumber, true));
384
+ }
385
+ return [4 /*yield*/, this.executeBatchAsync(batch)];
354
386
  case 4:
355
- if (!(i < blocksNumbersToFetch.length)) return [3 /*break*/, 7];
356
- return [4 /*yield*/, Promise.all(blocksNumbersToFetch[i].map(function (blockNumber) { return __awaiter(_this, void 0, void 0, function () {
357
- var block;
358
- return __generator(this, function (_a) {
359
- switch (_a.label) {
360
- case 0: return [4 /*yield*/, store_1.default.web3.eth.getBlock(blockNumber, true)];
361
- case 1:
362
- block = _a.sent();
363
- if (block && block.transactions) {
364
- block.transactions.forEach(function (transaction) {
365
- var address = null;
366
- if (addresses.includes(transaction.from))
367
- address = transaction.from;
368
- else if (transaction.to && addresses.includes(transaction.to))
369
- address = transaction.to;
370
- if (address) {
371
- transactionsByAddress[address].push(__assign(__assign({}, transaction), { timestamp: +block.timestamp * 1000, input: transaction.input }));
372
- }
373
- });
374
- }
375
- return [2 /*return*/];
376
- }
377
- });
378
- }); }))];
379
- case 5:
380
- _b.sent();
381
- _b.label = 6;
382
- case 6:
383
- i++;
384
- return [3 /*break*/, 4];
385
- case 7: return [2 /*return*/, {
387
+ blocks = _a.sent();
388
+ blocks.forEach(function (block) {
389
+ if (!block.transactions)
390
+ return;
391
+ block.transactions.forEach(function (transaction) {
392
+ var address = null;
393
+ if (addresses.includes(transaction.from))
394
+ address = transaction.from;
395
+ else if (transaction.to && addresses.includes(transaction.to))
396
+ address = transaction.to;
397
+ if (address) {
398
+ transactionsByAddress[address].push(__assign(__assign({}, transaction), { timestamp: +block.timestamp * 1000, input: transaction.input }));
399
+ }
400
+ });
401
+ });
402
+ startBlock = batchLastBlock + 1;
403
+ return [3 /*break*/, 3];
404
+ case 5: return [2 /*return*/, {
386
405
  transactionsByAddress: transactionsByAddress,
387
- lastBlock: endBlock,
406
+ lastBlock: lastBlock,
388
407
  }];
389
408
  }
390
409
  });
@@ -393,6 +412,8 @@ var BlockchainConnector = /** @class */ (function () {
393
412
  BlockchainConnector.disconnect = function () {
394
413
  var _a;
395
414
  (_a = this.provider) === null || _a === void 0 ? void 0 : _a.disconnect(0, "");
415
+ if (this.providerHttps)
416
+ this.providerHttps.disconnect();
396
417
  store_1.default.isInitialized = false;
397
418
  store_1.default.web3 = undefined;
398
419
  };
@@ -82,7 +82,7 @@ var TIIGenerator = /** @class */ (function () {
82
82
  mac = encryption.authTag || encryption.mac;
83
83
  rawTri = {
84
84
  solutionHashes: solutionHashes.map(function (hash) { return ({
85
- type: hash.algo,
85
+ algo: hash.algo,
86
86
  hash: Buffer.from(hash.hash, hash.encoding),
87
87
  }); }),
88
88
  mrenclave: Buffer.from(linkage.mrenclave, linkage.encoding),
@@ -49,7 +49,7 @@ var AES = /** @class */ (function () {
49
49
  var keyBuffer, encrypted;
50
50
  return __generator(this, function (_a) {
51
51
  if (!encryption.key)
52
- throw Error('Encryption key is not provided');
52
+ throw Error("Encryption key is not provided");
53
53
  encryption.cipher = encryption.cipher || dto_js_1.Cipher.AES_256_GCM;
54
54
  keyBuffer = Buffer.from(encryption.key, encryption.encoding);
55
55
  encrypted = NativeCrypto_1.default.encrypt(keyBuffer, content, encryption.cipher);
@@ -79,7 +79,7 @@ var AES = /** @class */ (function () {
79
79
  switch (_a.label) {
80
80
  case 0:
81
81
  if (!encryption.key)
82
- throw Error('Encryption key is not provided');
82
+ throw Error("Encryption key is not provided");
83
83
  encryption.cipher = encryption.cipher || dto_js_1.Cipher.AES_256_GCM;
84
84
  keyBuffer = Buffer.from(encryption.key, encryption.encoding);
85
85
  return [4 /*yield*/, NativeCrypto_1.default.encryptStream(keyBuffer, inputStream, outputStream, encryption.cipher)];
@@ -104,7 +104,7 @@ var AES = /** @class */ (function () {
104
104
  switch (_a.label) {
105
105
  case 0:
106
106
  if (!encryption.key)
107
- throw Error('Decryption key is not provided');
107
+ throw Error("Decryption key is not provided");
108
108
  key = Buffer.from(encryption.key, encryption.encoding);
109
109
  params = {
110
110
  iv: Buffer.from(encryption.iv, encryption.encoding),
@@ -131,7 +131,7 @@ var AES = /** @class */ (function () {
131
131
  switch (_a.label) {
132
132
  case 0:
133
133
  if (!encryption.key)
134
- throw Error('Decryption key is not provided');
134
+ throw Error("Decryption key is not provided");
135
135
  key = Buffer.from(encryption.key, encryption.encoding);
136
136
  params = {
137
137
  iv: Buffer.from(encryption.iv, encryption.encoding),
@@ -49,7 +49,7 @@ var ARIA = /** @class */ (function () {
49
49
  var keyBuffer, encrypted;
50
50
  return __generator(this, function (_a) {
51
51
  if (!encryption.key)
52
- throw Error('Encryption key is not provided');
52
+ throw Error("Encryption key is not provided");
53
53
  encryption.cipher = encryption.cipher || dto_js_1.Cipher.ARIA_256_GCM;
54
54
  keyBuffer = Buffer.from(encryption.key, encryption.encoding);
55
55
  encrypted = NativeCrypto_1.default.encrypt(keyBuffer, content, encryption.cipher);
@@ -79,7 +79,7 @@ var ARIA = /** @class */ (function () {
79
79
  switch (_a.label) {
80
80
  case 0:
81
81
  if (!encryption.key)
82
- throw Error('Encryption key is not provided');
82
+ throw Error("Encryption key is not provided");
83
83
  encryption.cipher = encryption.cipher || dto_js_1.Cipher.ARIA_256_GCM;
84
84
  keyBuffer = Buffer.from(encryption.key, encryption.encoding);
85
85
  return [4 /*yield*/, NativeCrypto_1.default.encryptStream(keyBuffer, inputStream, outputStream, encryption.cipher)];
@@ -103,7 +103,7 @@ var ARIA = /** @class */ (function () {
103
103
  switch (_a.label) {
104
104
  case 0:
105
105
  if (!encryption.key)
106
- throw Error('Decryption key is not provided');
106
+ throw Error("Decryption key is not provided");
107
107
  key = Buffer.from(encryption.key, encryption.encoding);
108
108
  params = {
109
109
  iv: Buffer.from(encryption.iv, encryption.encoding),
@@ -130,7 +130,7 @@ var ARIA = /** @class */ (function () {
130
130
  switch (_a.label) {
131
131
  case 0:
132
132
  if (!encryption.key)
133
- throw Error('Decryption key is not provided');
133
+ throw Error("Decryption key is not provided");
134
134
  key = Buffer.from(encryption.key, encryption.encoding);
135
135
  params = {
136
136
  iv: Buffer.from(encryption.iv, encryption.encoding),
@@ -51,7 +51,7 @@ var ECIES = /** @class */ (function () {
51
51
  switch (_a.label) {
52
52
  case 0:
53
53
  if (!encryption.key)
54
- throw Error('Encryption key is not provided');
54
+ throw Error("Encryption key is not provided");
55
55
  return [4 /*yield*/, eccrypto_1.default.encrypt(Buffer.from(encryption.key, encryption.encoding), Buffer.from(content, "binary"))];
56
56
  case 1:
57
57
  result = _a.sent();
@@ -74,7 +74,7 @@ var ECIES = /** @class */ (function () {
74
74
  switch (_a.label) {
75
75
  case 0:
76
76
  if (!encryption.key)
77
- throw Error('Decryption key is not provided');
77
+ throw Error("Decryption key is not provided");
78
78
  encryptedObject = {
79
79
  iv: Buffer.from(encryption.iv, encryption.encoding),
80
80
  ephemPublicKey: Buffer.from(encryption.ephemPublicKey, encryption.encoding),
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
- import { ReadStream, WriteStream } from 'fs';
5
- import { Cipher, Decipher } from 'crypto';
4
+ import { ReadStream, WriteStream } from "fs";
5
+ import { Cipher, Decipher } from "crypto";
6
6
  import { Encoding, EncryptionWithMacIV } from "@super-protocol/dto-js";
7
7
  /**
8
8
  *
@@ -56,12 +56,10 @@ var NativeCrypto = /** @class */ (function () {
56
56
  if (/256\-xts/.test(cipher)) {
57
57
  return 64;
58
58
  }
59
- if (/256|128\-xts|chacha20/.test(cipher)
60
- && cipher !== 'aes-128-cbc-hmac-sha256') {
59
+ if (/256|128\-xts|chacha20/.test(cipher) && cipher !== "aes-128-cbc-hmac-sha256") {
61
60
  return 32;
62
61
  }
63
- if (/192|des\-ede3|desx|des3$/.test(cipher) ||
64
- cipher === 'id-smime-alg-cms3deswrap') {
62
+ if (/192|des\-ede3|desx|des3$/.test(cipher) || cipher === "id-smime-alg-cms3deswrap") {
65
63
  return 24;
66
64
  }
67
65
  if (/128|des\-ede/.test(cipher)) {
@@ -134,7 +132,7 @@ var NativeCrypto = /** @class */ (function () {
134
132
  // TODO: replace BufferEncoding with Encoding
135
133
  inputEncoding) {
136
134
  if (outputEncoding === void 0) { outputEncoding = dto_js_1.Encoding.base64; }
137
- if (inputEncoding === void 0) { inputEncoding = 'binary'; }
135
+ if (inputEncoding === void 0) { inputEncoding = "binary"; }
138
136
  var iv = this.createIV(cipherName);
139
137
  var result = {};
140
138
  var cipher = this.createCipher(cipherName, key, iv);
@@ -175,7 +173,7 @@ var NativeCrypto = /** @class */ (function () {
175
173
  // TODO: replace BufferEncoding with Encoding
176
174
  outputEncoding) {
177
175
  if (inputEncoding === void 0) { inputEncoding = dto_js_1.Encoding.base64; }
178
- if (outputEncoding === void 0) { outputEncoding = 'binary'; }
176
+ if (outputEncoding === void 0) { outputEncoding = "binary"; }
179
177
  var decipher = this.createDecipher(cipherName, key, params === null || params === void 0 ? void 0 : params.iv, params === null || params === void 0 ? void 0 : params.mac);
180
178
  var decrypted = decipher.update(content, inputEncoding, outputEncoding);
181
179
  decrypted += decipher.final(outputEncoding);
@@ -204,10 +202,12 @@ var NativeCrypto = /** @class */ (function () {
204
202
  * ```
205
203
  * but it doesn't work in browser
206
204
  */
207
- NativeCrypto.isCCM = function (cipher) { return /ccm/i.test(cipher) || cipher === 'chacha20-poly1305'; };
205
+ NativeCrypto.isCCM = function (cipher) { return /ccm/i.test(cipher) || cipher === "chacha20-poly1305"; };
208
206
  NativeCrypto.isGCM = function (cipher) { return /gcm/i.test(cipher); };
209
207
  NativeCrypto.isOCB = function (cipher) { return /ocb/i.test(cipher); };
210
- NativeCrypto.isECB = function (cipher) { return /ecb/i.test(cipher) || cipher === 'des-ede' || cipher === 'des-ede3'; };
208
+ NativeCrypto.isECB = function (cipher) {
209
+ return /ecb/i.test(cipher) || cipher === "des-ede" || cipher === "des-ede3";
210
+ };
211
211
  NativeCrypto.isRC4 = function (cipher) { return /^rc4/i.test(cipher); };
212
212
  return NativeCrypto;
213
213
  }());
@@ -137,7 +137,7 @@ var Order = /** @class */ (function () {
137
137
  result[1] = orderInfoParams[2][0];
138
138
  else
139
139
  result[0] = orderInfoParams[2][0];
140
- return [2 /*return*/, this.orderResult = (0, utils_1.tupleToObject)(result, Order_1.OrderResultStructure)];
140
+ return [2 /*return*/, (this.orderResult = (0, utils_1.tupleToObject)(result, Order_1.OrderResultStructure))];
141
141
  }
142
142
  });
143
143
  });
@@ -420,7 +420,7 @@ var Order = /** @class */ (function () {
420
420
  * @returns {Promise<void>} - Does not return id of created sub order!
421
421
  */
422
422
  Order.prototype.createSubOrder = function (subOrderInfo, blocking, holdSum, transactionOptions) {
423
- if (holdSum === void 0) { holdSum = '0'; }
423
+ if (holdSum === void 0) { holdSum = "0"; }
424
424
  return __awaiter(this, void 0, void 0, function () {
425
425
  var preparedInfo, tupleSubOrder, params;
426
426
  return __generator(this, function (_a) {
@@ -501,7 +501,7 @@ var Order = /** @class */ (function () {
501
501
  return [4 /*yield*/, Order.contract.getPastEvents("SubOrderCreated", { filter: filter })];
502
502
  case 1:
503
503
  foundIds = _a.sent();
504
- notFound = { consumer: consumer, externalId: externalId, subOfferId: '-1', subOrderId: '-1', parentOrderId: '-1' };
504
+ notFound = { consumer: consumer, externalId: externalId, subOfferId: "-1", subOrderId: "-1", parentOrderId: "-1" };
505
505
  response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
506
506
  return [2 /*return*/, response];
507
507
  }
@@ -1,4 +1,4 @@
1
- import * as _m0 from "protobufjs/minimal";
1
+ import _m0 from "protobufjs/minimal";
2
2
  export declare const protobufPackage = "";
3
3
  export interface Compression {
4
4
  type: Compression_TYPE;
@@ -20,7 +20,7 @@ export declare const Compression: {
20
20
  } & {
21
21
  type?: Compression_TYPE | undefined;
22
22
  data?: Uint8Array | undefined;
23
- } & Record<Exclude<keyof I, keyof Compression>, never>>(object: I): Compression;
23
+ } & { [K in Exclude<keyof I, keyof Compression>]: never; }>(object: I): Compression;
24
24
  };
25
25
  declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
26
26
  export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
@@ -29,5 +29,7 @@ export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<inf
29
29
  declare type KeysOfUnion<T> = T extends T ? keyof T : never;
30
30
  export declare type Exact<P, I extends P> = P extends Builtin ? P : P & {
31
31
  [K in keyof P]: Exact<P[K], I[K]>;
32
- } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
32
+ } & {
33
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
34
+ };
33
35
  export {};
@@ -1,35 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.Compression = exports.compression_TYPEToJSON = exports.compression_TYPEFromJSON = exports.Compression_TYPE = exports.protobufPackage = void 0;
30
7
  /* eslint-disable */
31
- var long_1 = __importDefault(require("long"));
32
- var _m0 = __importStar(require("protobufjs/minimal"));
8
+ var minimal_1 = __importDefault(require("protobufjs/minimal"));
33
9
  exports.protobufPackage = "";
34
10
  var Compression_TYPE;
35
11
  (function (Compression_TYPE) {
@@ -59,7 +35,7 @@ function createBaseCompression() {
59
35
  }
60
36
  exports.Compression = {
61
37
  encode: function (message, writer) {
62
- if (writer === void 0) { writer = _m0.Writer.create(); }
38
+ if (writer === void 0) { writer = minimal_1.default.Writer.create(); }
63
39
  if (message.type !== 0) {
64
40
  writer.uint32(8).int32(message.type);
65
41
  }
@@ -69,7 +45,7 @@ exports.Compression = {
69
45
  return writer;
70
46
  },
71
47
  decode: function (input, length) {
72
- var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
48
+ var reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
73
49
  var end = length === undefined ? reader.len : reader.pos + length;
74
50
  var message = createBaseCompression();
75
51
  while (reader.pos < end) {
@@ -120,26 +96,30 @@ var globalThis = (function () {
120
96
  return global;
121
97
  throw "Unable to locate global object";
122
98
  })();
123
- var atob = globalThis.atob || (function (b64) { return globalThis.Buffer.from(b64, "base64").toString("binary"); });
124
99
  function bytesFromBase64(b64) {
125
- var bin = atob(b64);
126
- var arr = new Uint8Array(bin.length);
127
- for (var i = 0; i < bin.length; ++i) {
128
- arr[i] = bin.charCodeAt(i);
100
+ if (globalThis.Buffer) {
101
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
102
+ }
103
+ else {
104
+ var bin = globalThis.atob(b64);
105
+ var arr = new Uint8Array(bin.length);
106
+ for (var i = 0; i < bin.length; ++i) {
107
+ arr[i] = bin.charCodeAt(i);
108
+ }
109
+ return arr;
129
110
  }
130
- return arr;
131
111
  }
132
- var btoa = globalThis.btoa || (function (bin) { return globalThis.Buffer.from(bin, "binary").toString("base64"); });
133
112
  function base64FromBytes(arr) {
134
- var bin = [];
135
- arr.forEach(function (byte) {
136
- bin.push(String.fromCharCode(byte));
137
- });
138
- return btoa(bin.join(""));
139
- }
140
- if (_m0.util.Long !== long_1.default) {
141
- _m0.util.Long = long_1.default;
142
- _m0.configure();
113
+ if (globalThis.Buffer) {
114
+ return globalThis.Buffer.from(arr).toString("base64");
115
+ }
116
+ else {
117
+ var bin_1 = [];
118
+ arr.forEach(function (byte) {
119
+ bin_1.push(String.fromCharCode(byte));
120
+ });
121
+ return globalThis.btoa(bin_1.join(""));
122
+ }
143
123
  }
144
124
  function isSet(value) {
145
125
  return value !== null && value !== undefined;
@@ -1,4 +1,4 @@
1
- import * as _m0 from "protobufjs/minimal";
1
+ import _m0 from "protobufjs/minimal";
2
2
  export declare const protobufPackage = "";
3
3
  export interface Encryption {
4
4
  algo: string;
@@ -10,7 +10,7 @@ export interface Encryption {
10
10
  encoding: string;
11
11
  }
12
12
  export interface Hash {
13
- type: string;
13
+ algo: string;
14
14
  hash: Uint8Array;
15
15
  }
16
16
  export interface TRI {
@@ -40,7 +40,7 @@ export declare const Encryption: {
40
40
  iv?: Uint8Array | undefined;
41
41
  mac?: Uint8Array | undefined;
42
42
  encoding?: string | undefined;
43
- } & Record<Exclude<keyof I, keyof Encryption>, never>>(object: I): Encryption;
43
+ } & { [K in Exclude<keyof I, keyof Encryption>]: never; }>(object: I): Encryption;
44
44
  };
45
45
  export declare const Hash: {
46
46
  encode(message: Hash, writer?: _m0.Writer): _m0.Writer;
@@ -48,12 +48,12 @@ export declare const Hash: {
48
48
  fromJSON(object: any): Hash;
49
49
  toJSON(message: Hash): unknown;
50
50
  fromPartial<I extends {
51
- type?: string | undefined;
51
+ algo?: string | undefined;
52
52
  hash?: Uint8Array | undefined;
53
53
  } & {
54
- type?: string | undefined;
54
+ algo?: string | undefined;
55
55
  hash?: Uint8Array | undefined;
56
- } & Record<Exclude<keyof I, keyof Hash>, never>>(object: I): Hash;
56
+ } & { [K in Exclude<keyof I, keyof Hash>]: never; }>(object: I): Hash;
57
57
  };
58
58
  export declare const TRI: {
59
59
  encode(message: TRI, writer?: _m0.Writer): _m0.Writer;
@@ -62,7 +62,7 @@ export declare const TRI: {
62
62
  toJSON(message: TRI): unknown;
63
63
  fromPartial<I extends {
64
64
  solutionHashes?: {
65
- type?: string | undefined;
65
+ algo?: string | undefined;
66
66
  hash?: Uint8Array | undefined;
67
67
  }[] | undefined;
68
68
  mrenclave?: Uint8Array | undefined;
@@ -78,18 +78,18 @@ export declare const TRI: {
78
78
  } | undefined;
79
79
  } & {
80
80
  solutionHashes?: ({
81
- type?: string | undefined;
81
+ algo?: string | undefined;
82
82
  hash?: Uint8Array | undefined;
83
83
  }[] & ({
84
- type?: string | undefined;
84
+ algo?: string | undefined;
85
85
  hash?: Uint8Array | undefined;
86
86
  } & {
87
- type?: string | undefined;
87
+ algo?: string | undefined;
88
88
  hash?: Uint8Array | undefined;
89
- } & Record<Exclude<keyof I["solutionHashes"][number], keyof Hash>, never>)[] & Record<Exclude<keyof I["solutionHashes"], keyof {
90
- type?: string | undefined;
89
+ } & { [K in Exclude<keyof I["solutionHashes"][number], keyof Hash>]: never; })[] & { [K_1 in Exclude<keyof I["solutionHashes"], keyof {
90
+ algo?: string | undefined;
91
91
  hash?: Uint8Array | undefined;
92
- }[]>, never>) | undefined;
92
+ }[]>]: never; }) | undefined;
93
93
  mrenclave?: Uint8Array | undefined;
94
94
  args?: string | undefined;
95
95
  encryption?: ({
@@ -108,8 +108,8 @@ export declare const TRI: {
108
108
  iv?: Uint8Array | undefined;
109
109
  mac?: Uint8Array | undefined;
110
110
  encoding?: string | undefined;
111
- } & Record<Exclude<keyof I["encryption"], keyof Encryption>, never>) | undefined;
112
- } & Record<Exclude<keyof I, keyof TRI>, never>>(object: I): TRI;
111
+ } & { [K_2 in Exclude<keyof I["encryption"], keyof Encryption>]: never; }) | undefined;
112
+ } & { [K_3 in Exclude<keyof I, keyof TRI>]: never; }>(object: I): TRI;
113
113
  };
114
114
  declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
115
115
  export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
@@ -118,5 +118,7 @@ export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<inf
118
118
  declare type KeysOfUnion<T> = T extends T ? keyof T : never;
119
119
  export declare type Exact<P, I extends P> = P extends Builtin ? P : P & {
120
120
  [K in keyof P]: Exact<P[K], I[K]>;
121
- } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
121
+ } & {
122
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
123
+ };
122
124
  export {};