@steemit/steem-js 0.8.0 → 1.0.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/README.md +202 -105
- package/dist/api/index.d.ts +128 -0
- package/dist/api/methods.d.ts +9 -0
- package/dist/api/rpc-auth.d.ts +43 -0
- package/dist/api/transports/base.d.ts +13 -0
- package/dist/api/transports/http.d.ts +9 -0
- package/dist/api/transports/index.d.ts +9 -0
- package/dist/api/transports/types.d.ts +35 -0
- package/dist/api/transports/ws.d.ts +18 -0
- package/dist/auth/ecc/index.d.ts +9 -0
- package/dist/auth/ecc/src/address.d.ts +13 -0
- package/dist/auth/ecc/src/aes.d.ts +16 -0
- package/dist/auth/ecc/src/brain_key.d.ts +1 -0
- package/dist/auth/ecc/src/ecdsa.d.ts +28 -0
- package/dist/auth/ecc/src/ecsignature.d.ts +19 -0
- package/dist/auth/ecc/src/enforce_types.d.ts +5 -0
- package/dist/auth/ecc/src/hash.d.ts +25 -0
- package/dist/auth/ecc/src/index.d.ts +9 -0
- package/dist/auth/ecc/src/key_private.d.ts +38 -0
- package/dist/auth/ecc/src/key_public.d.ts +41 -0
- package/dist/auth/ecc/src/key_utils.d.ts +9 -0
- package/dist/auth/ecc/src/signature.d.ts +18 -0
- package/dist/auth/ecc.d.ts +3 -0
- package/dist/auth/index.d.ts +48 -0
- package/dist/auth/key_classes.d.ts +3 -0
- package/dist/auth/serializer.d.ts +19 -0
- package/dist/broadcast/helpers.d.ts +11 -0
- package/dist/broadcast/index.d.ts +43 -0
- package/dist/broadcast/operations.d.ts +6 -0
- package/dist/config.d.ts +25 -0
- package/dist/crypto/index.d.ts +25 -0
- package/dist/formatter/index.d.ts +92 -0
- package/dist/index.cjs +25848 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +25812 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +57513 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/memo/index.d.ts +11 -0
- package/dist/operations/index.d.ts +44 -0
- package/dist/serializer/convert.d.ts +12 -0
- package/dist/serializer/index.d.ts +11 -0
- package/dist/serializer/number_utils.d.ts +8 -0
- package/dist/serializer/precision.d.ts +5 -0
- package/dist/serializer/types.d.ts +36 -0
- package/dist/types/index.d.ts +131 -0
- package/dist/types.d.ts +34 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils.d.ts +2 -0
- package/package.json +68 -87
- package/.dockerignore +0 -12
- package/.editorconfig +0 -20
- package/.eslintrc +0 -27
- package/LICENSE +0 -21
- package/circle.yml +0 -3
- package/config.json +0 -10
- package/dist/steem-tests.min.js +0 -4097
- package/dist/steem.min.js +0 -2089
- package/docker-webpack.config.js +0 -44
- package/lib/api/index.js +0 -315
- package/lib/api/methods.js +0 -428
- package/lib/api/rpc-auth.js +0 -135
- package/lib/api/transports/base.js +0 -31
- package/lib/api/transports/http.js +0 -157
- package/lib/api/transports/index.js +0 -13
- package/lib/api/transports/ws.js +0 -128
- package/lib/auth/ecc/index.js +0 -13
- package/lib/auth/ecc/src/address.js +0 -54
- package/lib/auth/ecc/src/aes.js +0 -148
- package/lib/auth/ecc/src/brain_key.js +0 -13
- package/lib/auth/ecc/src/ecdsa.js +0 -193
- package/lib/auth/ecc/src/ecsignature.js +0 -102
- package/lib/auth/ecc/src/enforce_types.js +0 -42
- package/lib/auth/ecc/src/hash.js +0 -58
- package/lib/auth/ecc/src/key_private.js +0 -159
- package/lib/auth/ecc/src/key_public.js +0 -143
- package/lib/auth/ecc/src/key_utils.js +0 -70
- package/lib/auth/ecc/src/signature.js +0 -135
- package/lib/auth/index.js +0 -113
- package/lib/auth/memo.js +0 -119
- package/lib/auth/serializer/index.js +0 -15
- package/lib/auth/serializer/src/ChainTypes.js +0 -87
- package/lib/auth/serializer/src/convert.js +0 -34
- package/lib/auth/serializer/src/error_with_cause.js +0 -27
- package/lib/auth/serializer/src/fast_parser.js +0 -57
- package/lib/auth/serializer/src/number_utils.js +0 -43
- package/lib/auth/serializer/src/object_id.js +0 -43
- package/lib/auth/serializer/src/operations.js +0 -695
- package/lib/auth/serializer/src/precision.js +0 -77
- package/lib/auth/serializer/src/serializer.js +0 -165
- package/lib/auth/serializer/src/template.js +0 -22
- package/lib/auth/serializer/src/types.js +0 -1085
- package/lib/auth/serializer/src/validation.js +0 -300
- package/lib/broadcast/helpers.js +0 -140
- package/lib/broadcast/index.js +0 -106
- package/lib/broadcast/operations.js +0 -255
- package/lib/browser.js +0 -25
- package/lib/config.js +0 -23
- package/lib/formatter.js +0 -163
- package/lib/index.js +0 -21
- package/lib/utils.js +0 -50
- package/node-18.dockerfile +0 -28
- package/test/Crypto.js +0 -100
- package/test/KeyFormats.js +0 -105
- package/test/all_types.js +0 -115
- package/test/api.test.js +0 -363
- package/test/broadcast.test.js +0 -231
- package/test/browser/BrowserTests.js +0 -55
- package/test/comment.test.js +0 -83
- package/test/hf20-accounts.test.js +0 -76
- package/test/hf21-sps.test.js +0 -78
- package/test/memo.test.js +0 -37
- package/test/number_utils.js +0 -28
- package/test/operations_test.js +0 -39
- package/test/promise-broadcast.test.js +0 -86
- package/test/reputation.test.js +0 -68
- package/test/smt.test.js +0 -347
- package/test/test-post.json +0 -13
- package/test/test.html +0 -13
- package/test/test_helper.js +0 -19
- package/test/types_test.js +0 -139
- package/test-github-workflow.bat +0 -19
- package/test-github-workflow.sh +0 -15
- package/webpack/makeConfig.js +0 -113
- package/webpack.config.js +0 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import BigInteger from 'bigi';
|
|
2
|
+
import ECSignature from './ecsignature';
|
|
3
|
+
type Curve = any;
|
|
4
|
+
type Point = any;
|
|
5
|
+
export declare function sign(curve: Curve, hash: Buffer, d: BigInteger, nonce?: number): ECSignature;
|
|
6
|
+
export declare function verify(curve: Curve, hash: Buffer, signature: ECSignature, Q: Point): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Recover a public key from a signature.
|
|
9
|
+
*
|
|
10
|
+
* See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
|
|
11
|
+
* Key Recovery Operation".
|
|
12
|
+
*
|
|
13
|
+
* http://www.secg.org/download/aid-780/sec1-v2.pdf
|
|
14
|
+
*/
|
|
15
|
+
export declare function recoverPubKey(curve: Curve, e: BigInteger, signature: ECSignature, i: number): Point;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate pubkey extraction parameter.
|
|
18
|
+
*
|
|
19
|
+
* When extracting a pubkey from a signature, we have to
|
|
20
|
+
* distinguish four different cases. Rather than putting this
|
|
21
|
+
* burden on the verifier, Bitcoin includes a 2-bit value with the
|
|
22
|
+
* signature.
|
|
23
|
+
*
|
|
24
|
+
* This function simply tries all four cases and returns the value
|
|
25
|
+
* that resulted in a successful pubkey recovery.
|
|
26
|
+
*/
|
|
27
|
+
export declare function calcPubKeyRecoveryParam(curve: Curve, e: BigInteger, signature: ECSignature, Q: Point): number;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import BigInteger from 'bigi';
|
|
2
|
+
export default class ECSignature {
|
|
3
|
+
r: BigInteger;
|
|
4
|
+
s: BigInteger;
|
|
5
|
+
constructor(r: BigInteger, s: BigInteger);
|
|
6
|
+
static parseCompact(buffer: Buffer): {
|
|
7
|
+
compressed: boolean;
|
|
8
|
+
i: number;
|
|
9
|
+
signature: ECSignature;
|
|
10
|
+
};
|
|
11
|
+
static fromDER(buffer: Buffer): ECSignature;
|
|
12
|
+
static parseScriptSignature(buffer: Buffer): {
|
|
13
|
+
signature: ECSignature;
|
|
14
|
+
hashType: number;
|
|
15
|
+
};
|
|
16
|
+
toCompact(i: number, compressed: boolean): Buffer;
|
|
17
|
+
toDER(): Buffer;
|
|
18
|
+
toScriptSignature(hashType: number): Buffer;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @arg {string|Buffer} data
|
|
2
|
+
@arg {string} [digest = null] - 'hex', 'binary' or 'base64'
|
|
3
|
+
@return {string|Buffer} - Buffer when digest is null, or string
|
|
4
|
+
*/
|
|
5
|
+
export declare function sha1(data: string | Buffer, encoding?: BufferEncoding): string | Buffer;
|
|
6
|
+
/** @arg {string|Buffer} data
|
|
7
|
+
@arg {string} [digest = null] - 'hex', 'binary' or 'base64'
|
|
8
|
+
@return {string|Buffer} - Buffer when digest is null, or string
|
|
9
|
+
*/
|
|
10
|
+
export declare function sha256(data: string | Buffer, encoding?: BufferEncoding): Buffer;
|
|
11
|
+
/** @arg {string|Buffer} data
|
|
12
|
+
@arg {string} [digest = null] - 'hex', 'binary' or 'base64'
|
|
13
|
+
@return {string|Buffer} - Buffer when digest is null, or string
|
|
14
|
+
*/
|
|
15
|
+
export declare function sha512(data: string | Buffer, encoding?: BufferEncoding): Buffer;
|
|
16
|
+
export declare function HmacSHA256(buffer: Buffer, secret: Buffer): Buffer;
|
|
17
|
+
export declare function ripemd160(data: string | Buffer): Buffer;
|
|
18
|
+
declare const _default: {
|
|
19
|
+
sha1: typeof sha1;
|
|
20
|
+
sha256: typeof sha256;
|
|
21
|
+
sha512: typeof sha512;
|
|
22
|
+
HmacSHA256: typeof HmacSHA256;
|
|
23
|
+
ripemd160: typeof ripemd160;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Address } from './address';
|
|
2
|
+
export { Aes } from './aes';
|
|
3
|
+
export { PrivateKey } from './key_private';
|
|
4
|
+
export { PublicKey } from './key_public';
|
|
5
|
+
export { Signature } from './signature';
|
|
6
|
+
export { normalize as brainKey } from './brain_key';
|
|
7
|
+
export * as key_utils from './key_utils';
|
|
8
|
+
export * as hash from './hash';
|
|
9
|
+
export { Config as ecc_config } from '../../../config';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import BigInteger from 'bigi';
|
|
2
|
+
import { PublicKey } from './key_public';
|
|
3
|
+
type Point = any;
|
|
4
|
+
export declare class PrivateKey {
|
|
5
|
+
d: BigInteger;
|
|
6
|
+
public_key?: PublicKey;
|
|
7
|
+
/**
|
|
8
|
+
* @private see static functions
|
|
9
|
+
* @param {BigInteger} d
|
|
10
|
+
*/
|
|
11
|
+
constructor(d: BigInteger);
|
|
12
|
+
static fromBuffer(buf: Buffer): PrivateKey;
|
|
13
|
+
/** @arg {string} seed - any length string. This is private, the same seed produces the same private key every time. */
|
|
14
|
+
static fromSeed(seed: string): PrivateKey;
|
|
15
|
+
static isWif(text: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @throws {AssertError|Error} parsing key
|
|
18
|
+
* @return {string} Wallet Import Format (still a secret, Not encrypted)
|
|
19
|
+
*/
|
|
20
|
+
static fromWif(private_wif: string): PrivateKey;
|
|
21
|
+
toWif(): string;
|
|
22
|
+
/** Alias for {@link toWif} */
|
|
23
|
+
toString(): string;
|
|
24
|
+
/**
|
|
25
|
+
* @return {Point}
|
|
26
|
+
*/
|
|
27
|
+
toPublicKeyPoint(): Point;
|
|
28
|
+
toPublic(): PublicKey;
|
|
29
|
+
toBuffer(): Buffer;
|
|
30
|
+
/** ECIES */
|
|
31
|
+
get_shared_secret(public_key: PublicKey | string): Buffer;
|
|
32
|
+
/** @throws {Error} - overflow of the key could not be derived */
|
|
33
|
+
child(offset: Buffer): PrivateKey;
|
|
34
|
+
static fromHex(hex: string): PrivateKey;
|
|
35
|
+
toHex(): string;
|
|
36
|
+
toPublicKey(): PublicKey;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type Point = any;
|
|
2
|
+
export declare class PublicKey {
|
|
3
|
+
Q: Point | null;
|
|
4
|
+
pubdata?: string;
|
|
5
|
+
/** @param {Point} public key */
|
|
6
|
+
constructor(Q: Point | null);
|
|
7
|
+
static fromBinary(bin: string): PublicKey;
|
|
8
|
+
static fromBuffer(buffer: Buffer): PublicKey;
|
|
9
|
+
toBuffer(compressed?: any): Buffer;
|
|
10
|
+
static fromPoint(point: Point): PublicKey;
|
|
11
|
+
toUncompressed(): PublicKey;
|
|
12
|
+
/** bts::blockchain::address (unique but not a full public key) */
|
|
13
|
+
toBlockchainAddress(): Buffer;
|
|
14
|
+
toString(address_prefix?: any): string;
|
|
15
|
+
/**
|
|
16
|
+
* Full public key
|
|
17
|
+
* {return} string
|
|
18
|
+
*/
|
|
19
|
+
toPublicKeyString(address_prefix?: any): string;
|
|
20
|
+
/**
|
|
21
|
+
* @arg {string} public_key - like STMXyz...
|
|
22
|
+
* @arg {string} address_prefix - like STM
|
|
23
|
+
* @return PublicKey or `null` (if the public_key string is invalid)
|
|
24
|
+
* @deprecated fromPublicKeyString (use fromString instead)
|
|
25
|
+
*/
|
|
26
|
+
static fromString(public_key: string, address_prefix?: any): PublicKey | null;
|
|
27
|
+
/**
|
|
28
|
+
* @arg {string} public_key - like STMXyz...
|
|
29
|
+
* @arg {string} address_prefix - like STM
|
|
30
|
+
* @throws {Error} if public key is invalid
|
|
31
|
+
* @return PublicKey
|
|
32
|
+
*/
|
|
33
|
+
static fromStringOrThrow(public_key: string, address_prefix?: any): PublicKey;
|
|
34
|
+
toAddressString(address_prefix?: any): string;
|
|
35
|
+
toPtsAddy(): string;
|
|
36
|
+
child(offset: Buffer): PublicKey;
|
|
37
|
+
static fromHex(hex: string): PublicKey;
|
|
38
|
+
toHex(): string;
|
|
39
|
+
static fromStringHex(hex: string): PublicKey;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PrivateKey } from './key_private';
|
|
2
|
+
export declare function addEntropy(...ints: number[]): void;
|
|
3
|
+
/**
|
|
4
|
+
* A weak random number generator can run out of entropy. This should ensure even the worst random number implementation will be reasonably safe.
|
|
5
|
+
* @param entropy string entropy of at least 32 bytes
|
|
6
|
+
*/
|
|
7
|
+
export declare function random32ByteBuffer(entropy?: string): Buffer;
|
|
8
|
+
export declare function get_random_key(entropy?: string): PrivateKey;
|
|
9
|
+
export declare function browserEntropy(): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import bigi from 'bigi';
|
|
2
|
+
import { PrivateKey } from './key_private';
|
|
3
|
+
import { PublicKey } from './key_public';
|
|
4
|
+
export declare class Signature {
|
|
5
|
+
r: bigi;
|
|
6
|
+
s: bigi;
|
|
7
|
+
i: number;
|
|
8
|
+
constructor(r: bigi, s: bigi, i: number);
|
|
9
|
+
static fromBuffer(buffer: Buffer): Signature;
|
|
10
|
+
toBuffer(): Buffer;
|
|
11
|
+
static signBuffer(buf: Buffer, private_key: PrivateKey | string): Signature;
|
|
12
|
+
static signBufferSha256(buf_sha256: Buffer, private_key: PrivateKey | string): Signature;
|
|
13
|
+
static sign(string: string, private_key: PrivateKey | string): Signature;
|
|
14
|
+
verifyBuffer(buf: Buffer, public_key: PublicKey): boolean;
|
|
15
|
+
verifyHash(hash: Buffer, public_key: PublicKey): boolean;
|
|
16
|
+
static fromHex(hex: string): Signature;
|
|
17
|
+
toHex(): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface KeyPair {
|
|
2
|
+
privateKey: string;
|
|
3
|
+
publicKey: string;
|
|
4
|
+
}
|
|
5
|
+
export interface KeyPairs {
|
|
6
|
+
[role: string]: KeyPair;
|
|
7
|
+
}
|
|
8
|
+
export interface Authority {
|
|
9
|
+
key_auths: [string, number][];
|
|
10
|
+
}
|
|
11
|
+
export interface Auth {
|
|
12
|
+
verify(name: string, password: string, auths: any): boolean;
|
|
13
|
+
generateKeys(name: string, password: string, roles: string[]): {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
getPrivateKeys(name: string, password: string, roles?: string[]): {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
isWif(privWif: string): boolean;
|
|
20
|
+
toWif(name: string, password: string, role: string): string;
|
|
21
|
+
wifIsValid(privWif: string, pubWif: string): boolean;
|
|
22
|
+
wifToPublic(privWif: string): string;
|
|
23
|
+
isPubkey(pubkey: string, address_prefix?: string): boolean;
|
|
24
|
+
signTransaction(trx: any, keys: string[]): any;
|
|
25
|
+
}
|
|
26
|
+
export declare const Auth: Auth;
|
|
27
|
+
export default Auth;
|
|
28
|
+
export declare const verify: (name: string, password: string, auths: any) => boolean;
|
|
29
|
+
export declare const generateKeys: (name: string, password: string, roles: string[]) => {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const getPrivateKeys: (name: string, password: string, roles?: string[]) => {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
};
|
|
35
|
+
export declare const isWif: (privWif: string) => boolean;
|
|
36
|
+
export declare const toWif: (name: string, password: string, role: string) => string;
|
|
37
|
+
export declare const wifIsValid: (privWif: string, pubWif: string) => boolean;
|
|
38
|
+
export declare const wifToPublic: (privWif: string) => string;
|
|
39
|
+
export declare const isPubkey: (pubkey: string, address_prefix?: string) => boolean;
|
|
40
|
+
export { PrivateKey } from './ecc/src/key_private';
|
|
41
|
+
export { PublicKey } from './ecc/src/key_public';
|
|
42
|
+
export { Address } from './ecc/src/address';
|
|
43
|
+
export declare const sign: (message: string, privateKey: string) => string;
|
|
44
|
+
export declare const verifySignature: (message: string, signature: string, publicKey: string) => boolean;
|
|
45
|
+
export declare const verifyTransaction: (transaction: any, publicKey: string) => boolean;
|
|
46
|
+
export declare const getPublicKey: (privateKey: string) => string;
|
|
47
|
+
export declare const getPrivateKey: (seed: string) => string;
|
|
48
|
+
export declare const signTransaction: (trx: any, keys: string[]) => any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PublicKey } from './ecc/src/key_public';
|
|
2
|
+
export interface EncryptedMemo {
|
|
3
|
+
from: PublicKey;
|
|
4
|
+
to: PublicKey;
|
|
5
|
+
nonce: string;
|
|
6
|
+
check: number;
|
|
7
|
+
encrypted: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class Serializer {
|
|
10
|
+
static fromBuffer(buffer: Buffer): EncryptedMemo;
|
|
11
|
+
static toBuffer(memo: EncryptedMemo): Buffer;
|
|
12
|
+
}
|
|
13
|
+
export declare const transaction: {
|
|
14
|
+
toBuffer(trx: any): Buffer;
|
|
15
|
+
};
|
|
16
|
+
export declare const signed_transaction: {
|
|
17
|
+
toObject(trx: any): any;
|
|
18
|
+
toBuffer(trx: any): Buffer;
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Operation } from './operations';
|
|
2
|
+
export interface BroadcastOptions {
|
|
3
|
+
roles: string[];
|
|
4
|
+
operation: string;
|
|
5
|
+
params: any[];
|
|
6
|
+
}
|
|
7
|
+
export declare function getOperation(operation: string): Operation | undefined;
|
|
8
|
+
export declare function validateOperation(options: BroadcastOptions): void;
|
|
9
|
+
export declare function createOperation(options: BroadcastOptions): [string, any[]];
|
|
10
|
+
export declare function createTransaction(operations: [string, any[]][]): any;
|
|
11
|
+
export declare function createSignedTransaction(transaction: any, signatures: string[]): any;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Api } from '../api';
|
|
2
|
+
import Auth from '../auth';
|
|
3
|
+
import { BroadcastOptions } from './helpers';
|
|
4
|
+
export interface BroadcastConfig {
|
|
5
|
+
api: Api;
|
|
6
|
+
auth: Auth;
|
|
7
|
+
}
|
|
8
|
+
export declare class Broadcast {
|
|
9
|
+
private api;
|
|
10
|
+
private auth;
|
|
11
|
+
constructor(config: BroadcastConfig);
|
|
12
|
+
send(tx: {
|
|
13
|
+
operations: any[];
|
|
14
|
+
extensions?: any[];
|
|
15
|
+
}, privKeys: any, callback?: (err: any, result?: any) => void): Promise<any>;
|
|
16
|
+
sendOperations(operations: BroadcastOptions[]): Promise<any>;
|
|
17
|
+
sendTransaction(transaction: any): Promise<any>;
|
|
18
|
+
sendSignedTransaction(signedTransaction: any): Promise<any>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Top-level broadcast function for compatibility with tests and original API.
|
|
22
|
+
*/
|
|
23
|
+
export declare function broadcast(api: any, transaction: any): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Set the API reference for the broadcast module
|
|
26
|
+
*/
|
|
27
|
+
export declare function setApi(api: any): void;
|
|
28
|
+
export declare const _prepareTransaction: any, claimAccount: any, claimAccountAsync: any, createClaimedAccount: any, createClaimedAccountAsync: any, createProposal: any, createProposalAsync: any, updateProposalVotes: any, updateProposalVotesAsync: any, removeProposal: any, removeProposalAsync: any, generated: {
|
|
29
|
+
[x: string]: any;
|
|
30
|
+
};
|
|
31
|
+
export declare const vote: any;
|
|
32
|
+
export declare const voteAsync: any;
|
|
33
|
+
export declare const voteWith: any;
|
|
34
|
+
export declare const comment: any;
|
|
35
|
+
export declare const transfer: any;
|
|
36
|
+
export declare const transferAsync: any;
|
|
37
|
+
export declare const sendAsync: Function;
|
|
38
|
+
export declare const send: (tx: {
|
|
39
|
+
operations: any[];
|
|
40
|
+
extensions?: any[];
|
|
41
|
+
}, privKeys: any, callback?: (err: any, result?: any) => void) => Promise<any>;
|
|
42
|
+
export declare const customJson: any;
|
|
43
|
+
export declare const customJsonAsync: any;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface SteemConfig {
|
|
2
|
+
node?: string;
|
|
3
|
+
nodes?: string[];
|
|
4
|
+
uri?: string;
|
|
5
|
+
websocket?: string;
|
|
6
|
+
address_prefix?: string;
|
|
7
|
+
chain_id?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class Config {
|
|
10
|
+
private config;
|
|
11
|
+
get(key: string): any;
|
|
12
|
+
getBoolean(key: string): boolean;
|
|
13
|
+
getNumber(key: string): number;
|
|
14
|
+
getString(key: string): string;
|
|
15
|
+
set(key: string, value: any): void;
|
|
16
|
+
all(): {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare const getConfig: () => Config;
|
|
21
|
+
export declare const setConfig: (newConfig: Partial<SteemConfig>) => void;
|
|
22
|
+
export declare const resetConfig: () => void;
|
|
23
|
+
export declare const setOptions: (newConfig: Partial<SteemConfig>) => void;
|
|
24
|
+
export declare function get(key: string): any;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { KeyPair } from '../auth';
|
|
2
|
+
export declare const sha256: (data: string | Buffer) => Buffer;
|
|
3
|
+
export declare const ripemd160: (data: string | Buffer) => Buffer;
|
|
4
|
+
export declare const doubleSha256: (data: string | Buffer) => Buffer;
|
|
5
|
+
export declare const hmacSha256: (key: string | Buffer, data: string | Buffer) => Buffer;
|
|
6
|
+
/**
|
|
7
|
+
* Generate a cryptographically secure key pair using ECC secp256k1
|
|
8
|
+
* @returns A key pair with private key in WIF format and public key in Steem format
|
|
9
|
+
*/
|
|
10
|
+
export declare const generateKeyPair: () => KeyPair;
|
|
11
|
+
/**
|
|
12
|
+
* Sign a message with a private key using ECC secp256k1
|
|
13
|
+
* @param message - The message to sign (string or Buffer)
|
|
14
|
+
* @param privateKey - Private key in WIF format
|
|
15
|
+
* @returns Hexadecimal signature string
|
|
16
|
+
*/
|
|
17
|
+
export declare const sign: (message: string | Buffer, privateKey: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Verify a message signature with a public key
|
|
20
|
+
* @param message - The message that was signed (string or Buffer)
|
|
21
|
+
* @param signature - Hexadecimal signature string
|
|
22
|
+
* @param publicKey - Public key in Steem format (e.g., "STM...")
|
|
23
|
+
* @returns True if signature is valid, false otherwise
|
|
24
|
+
*/
|
|
25
|
+
export declare const verify: (message: string | Buffer, signature: string, publicKey: string) => boolean;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Api } from '../api';
|
|
2
|
+
export interface Account {
|
|
3
|
+
name: string;
|
|
4
|
+
vesting_shares: string;
|
|
5
|
+
balance: string;
|
|
6
|
+
savings_balance: string;
|
|
7
|
+
savings_sbd_balance: string;
|
|
8
|
+
sbd_balance: string;
|
|
9
|
+
other_history?: any[];
|
|
10
|
+
}
|
|
11
|
+
export interface GlobalProperties {
|
|
12
|
+
total_vesting_shares: string;
|
|
13
|
+
total_vesting_fund_steem: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FeedPrice {
|
|
16
|
+
base: string;
|
|
17
|
+
quote: string;
|
|
18
|
+
}
|
|
19
|
+
export interface OpenOrder {
|
|
20
|
+
sell_price: {
|
|
21
|
+
base: string;
|
|
22
|
+
};
|
|
23
|
+
for_sale: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SavingsWithdraw {
|
|
26
|
+
amount: string;
|
|
27
|
+
}
|
|
28
|
+
export interface AccountValueOptions {
|
|
29
|
+
gprops?: GlobalProperties;
|
|
30
|
+
feed_price?: FeedPrice;
|
|
31
|
+
open_orders?: OpenOrder[];
|
|
32
|
+
savings_withdraws?: SavingsWithdraw[];
|
|
33
|
+
vesting_steem?: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function formatAmount(amount: number | string, symbol?: string): string;
|
|
36
|
+
export declare function formatVests(vests: number | string): string;
|
|
37
|
+
export declare function formatReputation(reputation: number | string | null | undefined, decimal_places?: number): string;
|
|
38
|
+
export declare function formatPercent(value: number | string): string;
|
|
39
|
+
export declare function formatTime(time: Date | number | string): string;
|
|
40
|
+
export declare function formatNumber(value: number | string, decimals?: number): string;
|
|
41
|
+
export declare class Formatter {
|
|
42
|
+
private api;
|
|
43
|
+
constructor(api: Api);
|
|
44
|
+
private vestingSteem;
|
|
45
|
+
private processOrders;
|
|
46
|
+
private calculateSaving;
|
|
47
|
+
private pricePerSteem;
|
|
48
|
+
estimateAccountValue(account: Account, options?: AccountValueOptions): Promise<string>;
|
|
49
|
+
createSuggestedPassword(): string;
|
|
50
|
+
reputation(reputation: number | null | undefined, decimal_places?: number): number | null | undefined;
|
|
51
|
+
vestToSteem(vestingShares: string, totalVestingShares: string, totalVestingFundSteem: string): number;
|
|
52
|
+
commentPermlink(parentAuthor: string, parentPermlink: string): string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Calculate vesting STEEM from vesting shares and global properties.
|
|
56
|
+
* @param account Account object
|
|
57
|
+
* @param gprops GlobalProperties object
|
|
58
|
+
* @returns Number of STEEM
|
|
59
|
+
*/
|
|
60
|
+
export declare function vestingSteem(account: Account, gprops: GlobalProperties): number;
|
|
61
|
+
/**
|
|
62
|
+
* Calculate price per STEEM from feed price.
|
|
63
|
+
* @param feed_price FeedPrice object
|
|
64
|
+
* @returns Price per STEEM or undefined
|
|
65
|
+
*/
|
|
66
|
+
export declare function pricePerSteem(feed_price: FeedPrice): number | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Alias for formatAmount for backward compatibility.
|
|
69
|
+
*/
|
|
70
|
+
export declare const amount: typeof formatAmount;
|
|
71
|
+
/**
|
|
72
|
+
* Convert vesting shares to STEEM.
|
|
73
|
+
* @param vestingShares Vesting shares string
|
|
74
|
+
* @param totalVestingShares Total vesting shares string
|
|
75
|
+
* @param totalVestingFundSteem Total vesting fund STEEM string
|
|
76
|
+
* @returns Number of STEEM
|
|
77
|
+
*/
|
|
78
|
+
export declare function vestToSteem(vestingShares: string, totalVestingShares: string, totalVestingFundSteem: string): number;
|
|
79
|
+
/**
|
|
80
|
+
* Generate a comment permlink based on parent author and permlink.
|
|
81
|
+
* @param parentAuthor Parent author string
|
|
82
|
+
* @param parentPermlink Parent permlink string
|
|
83
|
+
* @returns Generated permlink string
|
|
84
|
+
*/
|
|
85
|
+
export declare function commentPermlink(parentAuthor: string, parentPermlink: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Calculate Steem reputation score as a number, matching the original implementation.
|
|
88
|
+
* @param reputation Raw reputation value
|
|
89
|
+
* @param decimal_places Number of decimal places (optional)
|
|
90
|
+
* @returns Reputation score as number, or null/undefined if input is null/undefined
|
|
91
|
+
*/
|
|
92
|
+
export declare function reputation(reputation: number | null | undefined, decimal_places?: number): number | null | undefined;
|