@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.
Files changed (126) hide show
  1. package/README.md +202 -105
  2. package/dist/api/index.d.ts +128 -0
  3. package/dist/api/methods.d.ts +9 -0
  4. package/dist/api/rpc-auth.d.ts +43 -0
  5. package/dist/api/transports/base.d.ts +13 -0
  6. package/dist/api/transports/http.d.ts +9 -0
  7. package/dist/api/transports/index.d.ts +9 -0
  8. package/dist/api/transports/types.d.ts +35 -0
  9. package/dist/api/transports/ws.d.ts +18 -0
  10. package/dist/auth/ecc/index.d.ts +9 -0
  11. package/dist/auth/ecc/src/address.d.ts +13 -0
  12. package/dist/auth/ecc/src/aes.d.ts +16 -0
  13. package/dist/auth/ecc/src/brain_key.d.ts +1 -0
  14. package/dist/auth/ecc/src/ecdsa.d.ts +28 -0
  15. package/dist/auth/ecc/src/ecsignature.d.ts +19 -0
  16. package/dist/auth/ecc/src/enforce_types.d.ts +5 -0
  17. package/dist/auth/ecc/src/hash.d.ts +25 -0
  18. package/dist/auth/ecc/src/index.d.ts +9 -0
  19. package/dist/auth/ecc/src/key_private.d.ts +38 -0
  20. package/dist/auth/ecc/src/key_public.d.ts +41 -0
  21. package/dist/auth/ecc/src/key_utils.d.ts +9 -0
  22. package/dist/auth/ecc/src/signature.d.ts +18 -0
  23. package/dist/auth/ecc.d.ts +3 -0
  24. package/dist/auth/index.d.ts +48 -0
  25. package/dist/auth/key_classes.d.ts +3 -0
  26. package/dist/auth/serializer.d.ts +19 -0
  27. package/dist/broadcast/helpers.d.ts +11 -0
  28. package/dist/broadcast/index.d.ts +43 -0
  29. package/dist/broadcast/operations.d.ts +6 -0
  30. package/dist/config.d.ts +25 -0
  31. package/dist/crypto/index.d.ts +25 -0
  32. package/dist/formatter/index.d.ts +92 -0
  33. package/dist/index.cjs +25848 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.js +25812 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/index.umd.js +57513 -0
  39. package/dist/index.umd.js.map +1 -0
  40. package/dist/memo/index.d.ts +11 -0
  41. package/dist/operations/index.d.ts +44 -0
  42. package/dist/serializer/convert.d.ts +12 -0
  43. package/dist/serializer/index.d.ts +11 -0
  44. package/dist/serializer/number_utils.d.ts +8 -0
  45. package/dist/serializer/precision.d.ts +5 -0
  46. package/dist/serializer/types.d.ts +36 -0
  47. package/dist/types/index.d.ts +131 -0
  48. package/dist/types.d.ts +34 -0
  49. package/dist/utils/index.d.ts +8 -0
  50. package/dist/utils.d.ts +2 -0
  51. package/package.json +68 -87
  52. package/.dockerignore +0 -12
  53. package/.editorconfig +0 -20
  54. package/.eslintrc +0 -27
  55. package/LICENSE +0 -21
  56. package/circle.yml +0 -3
  57. package/config.json +0 -10
  58. package/dist/steem-tests.min.js +0 -4097
  59. package/dist/steem.min.js +0 -2089
  60. package/docker-webpack.config.js +0 -44
  61. package/lib/api/index.js +0 -315
  62. package/lib/api/methods.js +0 -428
  63. package/lib/api/rpc-auth.js +0 -135
  64. package/lib/api/transports/base.js +0 -31
  65. package/lib/api/transports/http.js +0 -157
  66. package/lib/api/transports/index.js +0 -13
  67. package/lib/api/transports/ws.js +0 -128
  68. package/lib/auth/ecc/index.js +0 -13
  69. package/lib/auth/ecc/src/address.js +0 -54
  70. package/lib/auth/ecc/src/aes.js +0 -148
  71. package/lib/auth/ecc/src/brain_key.js +0 -13
  72. package/lib/auth/ecc/src/ecdsa.js +0 -193
  73. package/lib/auth/ecc/src/ecsignature.js +0 -102
  74. package/lib/auth/ecc/src/enforce_types.js +0 -42
  75. package/lib/auth/ecc/src/hash.js +0 -58
  76. package/lib/auth/ecc/src/key_private.js +0 -159
  77. package/lib/auth/ecc/src/key_public.js +0 -143
  78. package/lib/auth/ecc/src/key_utils.js +0 -70
  79. package/lib/auth/ecc/src/signature.js +0 -135
  80. package/lib/auth/index.js +0 -113
  81. package/lib/auth/memo.js +0 -119
  82. package/lib/auth/serializer/index.js +0 -15
  83. package/lib/auth/serializer/src/ChainTypes.js +0 -87
  84. package/lib/auth/serializer/src/convert.js +0 -34
  85. package/lib/auth/serializer/src/error_with_cause.js +0 -27
  86. package/lib/auth/serializer/src/fast_parser.js +0 -57
  87. package/lib/auth/serializer/src/number_utils.js +0 -43
  88. package/lib/auth/serializer/src/object_id.js +0 -43
  89. package/lib/auth/serializer/src/operations.js +0 -695
  90. package/lib/auth/serializer/src/precision.js +0 -77
  91. package/lib/auth/serializer/src/serializer.js +0 -165
  92. package/lib/auth/serializer/src/template.js +0 -22
  93. package/lib/auth/serializer/src/types.js +0 -1085
  94. package/lib/auth/serializer/src/validation.js +0 -300
  95. package/lib/broadcast/helpers.js +0 -140
  96. package/lib/broadcast/index.js +0 -106
  97. package/lib/broadcast/operations.js +0 -255
  98. package/lib/browser.js +0 -25
  99. package/lib/config.js +0 -23
  100. package/lib/formatter.js +0 -163
  101. package/lib/index.js +0 -21
  102. package/lib/utils.js +0 -50
  103. package/node-18.dockerfile +0 -28
  104. package/test/Crypto.js +0 -100
  105. package/test/KeyFormats.js +0 -105
  106. package/test/all_types.js +0 -115
  107. package/test/api.test.js +0 -363
  108. package/test/broadcast.test.js +0 -231
  109. package/test/browser/BrowserTests.js +0 -55
  110. package/test/comment.test.js +0 -83
  111. package/test/hf20-accounts.test.js +0 -76
  112. package/test/hf21-sps.test.js +0 -78
  113. package/test/memo.test.js +0 -37
  114. package/test/number_utils.js +0 -28
  115. package/test/operations_test.js +0 -39
  116. package/test/promise-broadcast.test.js +0 -86
  117. package/test/reputation.test.js +0 -68
  118. package/test/smt.test.js +0 -347
  119. package/test/test-post.json +0 -13
  120. package/test/test.html +0 -13
  121. package/test/test_helper.js +0 -19
  122. package/test/types_test.js +0 -139
  123. package/test-github-workflow.bat +0 -19
  124. package/test-github-workflow.sh +0 -15
  125. package/webpack/makeConfig.js +0 -113
  126. 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,5 @@
1
+ type TypeName = 'Array' | 'Boolean' | 'Buffer' | 'Number' | 'String' | {
2
+ new (...args: any[]): any;
3
+ };
4
+ export default function enforce(type: TypeName, value: any): void;
5
+ export {};
@@ -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,3 @@
1
+ export declare const hash: {
2
+ sha256: (data: Buffer | string) => Buffer;
3
+ };
@@ -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,3 @@
1
+ export { PrivateKey } from './ecc/src/key_private';
2
+ export { PublicKey } from './ecc/src/key_public';
3
+ export { Address } from './ecc/src/address';
@@ -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;
@@ -0,0 +1,6 @@
1
+ export interface Operation {
2
+ roles: string[];
3
+ operation: string;
4
+ params: string[];
5
+ }
6
+ export declare const operations: Operation[];
@@ -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;