@hiveio/dhive 1.1.0 → 1.2.1

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.
@@ -453,8 +453,8 @@ export interface LimitOrderCreate2Operation extends Operation {
453
453
  owner: string;
454
454
  orderid: number;
455
455
  amount_to_sell: Asset | string;
456
- fill_or_kill: boolean;
457
456
  exchange_rate: PriceType;
457
+ fill_or_kill: boolean;
458
458
  expiration: string;
459
459
  };
460
460
  }
@@ -374,8 +374,8 @@ OperationSerializers.limit_order_create2 = OperationDataSerializer(21, [
374
374
  ['owner', StringSerializer],
375
375
  ['orderid', UInt32Serializer],
376
376
  ['amount_to_sell', AssetSerializer],
377
- ['fill_or_kill', BooleanSerializer],
378
377
  ['exchange_rate', PriceSerializer],
378
+ ['fill_or_kill', BooleanSerializer],
379
379
  ['expiration', DateSerializer]
380
380
  ]);
381
381
  OperationSerializers.recover_account = OperationDataSerializer(25, [
package/lib/client.d.ts CHANGED
@@ -39,6 +39,7 @@ import { DatabaseAPI } from './helpers/database';
39
39
  import { HivemindAPI } from './helpers/hivemind';
40
40
  import { AccountByKeyAPI } from './helpers/key';
41
41
  import { RCAPI } from './helpers/rc';
42
+ import { TransactionStatusAPI } from './helpers/transaction';
42
43
  /**
43
44
  * Library version.
44
45
  */
@@ -141,6 +142,10 @@ export declare class Client {
141
142
  * Accounts by key API helper.
142
143
  */
143
144
  readonly keys: AccountByKeyAPI;
145
+ /**
146
+ * Transaction status API helper.
147
+ */
148
+ readonly transaction: TransactionStatusAPI;
144
149
  /**
145
150
  * Chain ID for current network.
146
151
  */
@@ -153,7 +158,7 @@ export declare class Client {
153
158
  private backoff;
154
159
  private failoverThreshold;
155
160
  private consoleOnFailover;
156
- private currentAddress;
161
+ currentAddress: string;
157
162
  /**
158
163
  * @param address The address to the Hive RPC server,
159
164
  * e.g. `https://api.hive.blog`. or [`https://api.hive.blog`, `https://another.api.com`]
package/lib/client.js CHANGED
@@ -52,6 +52,7 @@ const database_1 = require("./helpers/database");
52
52
  const hivemind_1 = require("./helpers/hivemind");
53
53
  const key_1 = require("./helpers/key");
54
54
  const rc_1 = require("./helpers/rc");
55
+ const transaction_1 = require("./helpers/transaction");
55
56
  const utils_1 = require("./utils");
56
57
  /**
57
58
  * Library version.
@@ -99,6 +100,7 @@ class Client {
99
100
  this.rc = new rc_1.RCAPI(this);
100
101
  this.hivemind = new hivemind_1.HivemindAPI(this);
101
102
  this.keys = new key_1.AccountByKeyAPI(this);
103
+ this.transaction = new transaction_1.TransactionStatusAPI(this);
102
104
  }
103
105
  /**
104
106
  * Create a new client instance configured for the testnet.
@@ -5,7 +5,7 @@
5
5
  import { PublicKey } from '../crypto';
6
6
  import { Client } from './../client';
7
7
  export interface AccountsByKey {
8
- accounts: [string[]];
8
+ accounts: string[][];
9
9
  }
10
10
  export declare class AccountByKeyAPI {
11
11
  readonly client: Client;
@@ -28,7 +28,7 @@ class AccountByKeyAPI {
28
28
  */
29
29
  getKeyReferences(keys) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- return this.call('get_key_references', { keys: keys.map((key) => key.toString()) });
31
+ return this.call('get_key_references', { keys: keys.map(key => key.toString()) });
32
32
  });
33
33
  }
34
34
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @file Transaction status API helpers.
3
+ * @author Bartłomiej (@engrave) Górnicki
4
+ */
5
+ import { Client } from './../client';
6
+ export declare type TransactionStatus = 'unknown' | 'within_mempool' | 'within_reversible_block' | 'within_irreversible_block' | 'expired_reversible' | 'expired_irreversible' | 'too_old';
7
+ export declare class TransactionStatusAPI {
8
+ readonly client: Client;
9
+ constructor(client: Client);
10
+ /**
11
+ * Convenience for calling `transaction_status_api`.
12
+ */
13
+ call(method: string, params?: any): Promise<any>;
14
+ /**
15
+ * Returns the status of a given transaction id
16
+ */
17
+ findTransaction(transaction_id: string, expiration?: string): Promise<{
18
+ status: TransactionStatus;
19
+ }>;
20
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * @file Transaction status API helpers.
4
+ * @author Bartłomiej (@engrave) Górnicki
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ class TransactionStatusAPI {
17
+ constructor(client) {
18
+ this.client = client;
19
+ }
20
+ /**
21
+ * Convenience for calling `transaction_status_api`.
22
+ */
23
+ call(method, params) {
24
+ return this.client.call('transaction_status_api', method, params);
25
+ }
26
+ /**
27
+ * Returns the status of a given transaction id
28
+ */
29
+ findTransaction(transaction_id, expiration) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const params = {
32
+ transaction_id
33
+ };
34
+ if (expiration) {
35
+ params.expiration = expiration;
36
+ }
37
+ return this.call('find_transaction', params);
38
+ });
39
+ }
40
+ }
41
+ exports.TransactionStatusAPI = TransactionStatusAPI;
package/lib/utils.js CHANGED
@@ -53,7 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
53
  const cross_fetch_1 = require("cross-fetch");
54
54
  const stream_1 = require("stream");
55
55
  // TODO: Add more errors that should trigger a failover
56
- const timeoutErrors = ['timeout', 'ENOTFOUND', 'ECONNREFUSED', 'database lock'];
56
+ const timeoutErrors = ['timeout', 'ENOTFOUND', 'ECONNREFUSED', 'database lock', 'CERT_HAS_EXPIRED'];
57
57
  /**
58
58
  * Return a promise that will resove when a specific event is emitted.
59
59
  */
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.1.0';
3
+ exports.default = '1.2.1';
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@hiveio/dhive",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Hive blockchain RPC client library",
5
5
  "author": "hive-network",
6
- "license": "BSD-3-Clause",
6
+ "license": "BSD-3-Clause-No-Military-License",
7
7
  "main": "./lib/index-node",
8
8
  "typings": "./lib/index",
9
9
  "browser": {
@@ -36,6 +36,7 @@
36
36
  "bytebuffer": "^5.0.1",
37
37
  "core-js": "^3.6.4",
38
38
  "cross-fetch": "^3.0.4",
39
+ "https": "^1.0.0",
39
40
  "jsbi": "^3.1.4",
40
41
  "node-fetch": "^2.6.0",
41
42
  "secp256k1": "^3.8.0",