@hiveio/dhive 1.0.0 → 1.2.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.
@@ -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
@@ -37,7 +37,9 @@ import { Blockchain } from './helpers/blockchain';
37
37
  import { BroadcastAPI } from './helpers/broadcast';
38
38
  import { DatabaseAPI } from './helpers/database';
39
39
  import { HivemindAPI } from './helpers/hivemind';
40
+ import { AccountByKeyAPI } from './helpers/key';
40
41
  import { RCAPI } from './helpers/rc';
42
+ import { TransactionStatusAPI } from './helpers/transaction';
41
43
  /**
42
44
  * Library version.
43
45
  */
@@ -133,13 +135,21 @@ export declare class Client {
133
135
  */
134
136
  readonly blockchain: Blockchain;
135
137
  /**
136
- * Blockchain helper.
138
+ * Hivemind helper.
137
139
  */
138
140
  readonly hivemind: HivemindAPI;
141
+ /**
142
+ * Accounts by key API helper.
143
+ */
144
+ readonly keys: AccountByKeyAPI;
145
+ /**
146
+ * Transaction status API helper.
147
+ */
148
+ readonly transaction: TransactionStatusAPI;
139
149
  /**
140
150
  * Chain ID for current network.
141
151
  */
142
- chainId: Buffer;
152
+ readonly chainId: Buffer;
143
153
  /**
144
154
  * Address prefix for current network.
145
155
  */
package/lib/client.js CHANGED
@@ -50,7 +50,9 @@ const blockchain_1 = require("./helpers/blockchain");
50
50
  const broadcast_1 = require("./helpers/broadcast");
51
51
  const database_1 = require("./helpers/database");
52
52
  const hivemind_1 = require("./helpers/hivemind");
53
+ const key_1 = require("./helpers/key");
53
54
  const rc_1 = require("./helpers/rc");
55
+ const transaction_1 = require("./helpers/transaction");
54
56
  const utils_1 = require("./utils");
55
57
  /**
56
58
  * Library version.
@@ -97,6 +99,8 @@ class Client {
97
99
  this.blockchain = new blockchain_1.Blockchain(this);
98
100
  this.rc = new rc_1.RCAPI(this);
99
101
  this.hivemind = new hivemind_1.HivemindAPI(this);
102
+ this.keys = new key_1.AccountByKeyAPI(this);
103
+ this.transaction = new transaction_1.TransactionStatusAPI(this);
100
104
  }
101
105
  /**
102
106
  * Create a new client instance configured for the testnet.
@@ -107,10 +111,8 @@ class Client {
107
111
  opts = utils_1.copy(options);
108
112
  opts.agent = options.agent;
109
113
  }
110
- // Testnet details: https://gitlab.syncad.com/hive/hive/-/issues/36
111
- opts.addressPrefix = 'STM';
112
- opts.chainId =
113
- 'beeab0de00000000000000000000000000000000000000000000000000000000';
114
+ opts.addressPrefix = 'TST';
115
+ opts.chainId = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e';
114
116
  return new Client('https://testnet.openhive.network', opts);
115
117
  }
116
118
  /**
package/lib/crypto.d.ts CHANGED
@@ -182,12 +182,12 @@ export declare const cryptoUtils: {
182
182
  doubleSha256: typeof doubleSha256;
183
183
  encodePrivate: typeof encodePrivate;
184
184
  encodePublic: typeof encodePublic;
185
+ generateTrxId: typeof generateTrxId;
185
186
  isCanonicalSignature: typeof isCanonicalSignature;
186
187
  isWif: typeof isWif;
187
188
  ripemd160: typeof ripemd160;
188
189
  sha256: typeof sha256;
189
190
  signTransaction: typeof signTransaction;
190
191
  transactionDigest: typeof transactionDigest;
191
- generateTrxId: typeof generateTrxId;
192
192
  };
193
193
  export {};
package/lib/crypto.js CHANGED
@@ -358,11 +358,11 @@ exports.cryptoUtils = {
358
358
  doubleSha256,
359
359
  encodePrivate,
360
360
  encodePublic,
361
+ generateTrxId,
361
362
  isCanonicalSignature,
362
363
  isWif,
363
364
  ripemd160,
364
365
  sha256,
365
366
  signTransaction,
366
- transactionDigest,
367
- generateTrxId
367
+ transactionDigest
368
368
  };
@@ -258,7 +258,8 @@ class BroadcastAPI {
258
258
  send(transaction) {
259
259
  return __awaiter(this, void 0, void 0, function* () {
260
260
  const trxId = crypto_1.cryptoUtils.generateTrxId(transaction);
261
- return Object.assign({ id: trxId }, this.call('broadcast_transaction', [transaction]));
261
+ const result = yield this.call('broadcast_transaction', [transaction]);
262
+ return Object.assign({ id: trxId }, result);
262
263
  });
263
264
  }
264
265
  /**
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @file Account by key API helpers.
3
+ * @author Bartłomiej (@engrave) Górnicki
4
+ */
5
+ import { PublicKey } from '../crypto';
6
+ import { Client } from './../client';
7
+ export interface AccountsByKey {
8
+ accounts: string[][];
9
+ }
10
+ export declare class AccountByKeyAPI {
11
+ readonly client: Client;
12
+ constructor(client: Client);
13
+ /**
14
+ * Convenience for calling `account_by_key_api`.
15
+ */
16
+ call(method: string, params?: any): Promise<any>;
17
+ /**
18
+ * Returns all accounts that have the key associated with their owner or active authorities.
19
+ */
20
+ getKeyReferences(keys: (PublicKey | string)[]): Promise<AccountsByKey>;
21
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * @file Account by key 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 AccountByKeyAPI {
17
+ constructor(client) {
18
+ this.client = client;
19
+ }
20
+ /**
21
+ * Convenience for calling `account_by_key_api`.
22
+ */
23
+ call(method, params) {
24
+ return this.client.call('account_by_key_api', method, params);
25
+ }
26
+ /**
27
+ * Returns all accounts that have the key associated with their owner or active authorities.
28
+ */
29
+ getKeyReferences(keys) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return this.call('get_key_references', { keys: keys.map(key => key.toString()) });
32
+ });
33
+ }
34
+ }
35
+ exports.AccountByKeyAPI = AccountByKeyAPI;
@@ -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/index.d.ts CHANGED
@@ -37,6 +37,8 @@ export { utils };
37
37
  export * from './helpers/blockchain';
38
38
  export * from './helpers/database';
39
39
  export * from './helpers/rc';
40
+ export * from './helpers/key';
41
+ export * from './helpers/hivemind';
40
42
  export * from './chain/account';
41
43
  export * from './chain/asset';
42
44
  export * from './chain/block';
package/lib/index.js CHANGED
@@ -42,6 +42,8 @@ exports.utils = utils;
42
42
  __export(require("./helpers/blockchain"));
43
43
  __export(require("./helpers/database"));
44
44
  __export(require("./helpers/rc"));
45
+ __export(require("./helpers/key"));
46
+ __export(require("./helpers/hivemind"));
45
47
  __export(require("./chain/account"));
46
48
  __export(require("./chain/asset"));
47
49
  __export(require("./chain/misc"));
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.0.0';
3
+ exports.default = '1.2.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiveio/dhive",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Hive blockchain RPC client library",
5
5
  "author": "hive-network",
6
6
  "license": "BSD-3-Clause",