@hiveio/dhive 1.0.0-beta.0 → 1.1.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.
- package/dist/dhive.d.ts +35 -4
- package/dist/dhive.js +1 -1
- package/dist/dhive.js.gz +0 -0
- package/dist/dhive.js.map +1 -1
- package/lib/chain/operation.d.ts +1 -1
- package/lib/chain/serializer.js +1 -1
- package/lib/client.d.ts +7 -2
- package/lib/client.js +4 -4
- package/lib/crypto.d.ts +1 -1
- package/lib/crypto.js +2 -2
- package/lib/helpers/broadcast.js +2 -1
- package/lib/helpers/key.d.ts +21 -0
- package/lib/helpers/key.js +35 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/chain/operation.d.ts
CHANGED
|
@@ -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
|
}
|
package/lib/chain/serializer.js
CHANGED
|
@@ -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,6 +37,7 @@ 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';
|
|
41
42
|
/**
|
|
42
43
|
* Library version.
|
|
@@ -133,13 +134,17 @@ export declare class Client {
|
|
|
133
134
|
*/
|
|
134
135
|
readonly blockchain: Blockchain;
|
|
135
136
|
/**
|
|
136
|
-
*
|
|
137
|
+
* Hivemind helper.
|
|
137
138
|
*/
|
|
138
139
|
readonly hivemind: HivemindAPI;
|
|
140
|
+
/**
|
|
141
|
+
* Accounts by key API helper.
|
|
142
|
+
*/
|
|
143
|
+
readonly keys: AccountByKeyAPI;
|
|
139
144
|
/**
|
|
140
145
|
* Chain ID for current network.
|
|
141
146
|
*/
|
|
142
|
-
chainId: Buffer;
|
|
147
|
+
readonly chainId: Buffer;
|
|
143
148
|
/**
|
|
144
149
|
* Address prefix for current network.
|
|
145
150
|
*/
|
package/lib/client.js
CHANGED
|
@@ -50,6 +50,7 @@ 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");
|
|
54
55
|
const utils_1 = require("./utils");
|
|
55
56
|
/**
|
|
@@ -97,6 +98,7 @@ class Client {
|
|
|
97
98
|
this.blockchain = new blockchain_1.Blockchain(this);
|
|
98
99
|
this.rc = new rc_1.RCAPI(this);
|
|
99
100
|
this.hivemind = new hivemind_1.HivemindAPI(this);
|
|
101
|
+
this.keys = new key_1.AccountByKeyAPI(this);
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
104
|
* Create a new client instance configured for the testnet.
|
|
@@ -107,10 +109,8 @@ class Client {
|
|
|
107
109
|
opts = utils_1.copy(options);
|
|
108
110
|
opts.agent = options.agent;
|
|
109
111
|
}
|
|
110
|
-
|
|
111
|
-
opts.
|
|
112
|
-
opts.chainId =
|
|
113
|
-
'beeab0de00000000000000000000000000000000000000000000000000000000';
|
|
112
|
+
opts.addressPrefix = 'TST';
|
|
113
|
+
opts.chainId = '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e';
|
|
114
114
|
return new Client('https://testnet.openhive.network', opts);
|
|
115
115
|
}
|
|
116
116
|
/**
|
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
|
};
|
package/lib/helpers/broadcast.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
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