@steemit/steem-js 0.0.8
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 +232 -0
- package/dist/api/index.d.ts +115 -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 +29 -0
- package/dist/api/transports/ws.d.ts +11 -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 +25766 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +25730 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +57431 -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 +28 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils.d.ts +2 -0
- package/package.json +85 -0
|
@@ -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;
|