@hiveio/dhive 1.1.1 → 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.
- package/dist/dhive.d.ts +29 -1
- package/dist/dhive.js +1 -1
- package/dist/dhive.js.gz +0 -0
- package/dist/dhive.js.map +1 -1
- package/lib/client.d.ts +5 -0
- package/lib/client.js +2 -0
- package/lib/helpers/key.d.ts +1 -1
- package/lib/helpers/key.js +1 -1
- package/lib/helpers/transaction.d.ts +20 -0
- package/lib/helpers/transaction.js +41 -0
- package/lib/version.js +1 -1
- package/package.json +1 -1
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
|
*/
|
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.
|
package/lib/helpers/key.d.ts
CHANGED
package/lib/helpers/key.js
CHANGED
|
@@ -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(
|
|
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/version.js
CHANGED