zattera-js 0.1.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/LICENSE +21 -0
- package/README.md +694 -0
- package/dist/browser/index.js +2466 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/node/auth/index.js +188 -0
- package/dist/node/auth/index.js.map +1 -0
- package/dist/node/auth/keys.js +264 -0
- package/dist/node/auth/keys.js.map +1 -0
- package/dist/node/auth/memo.js +79 -0
- package/dist/node/auth/memo.js.map +1 -0
- package/dist/node/auth/serializer.js +162 -0
- package/dist/node/auth/serializer.js.map +1 -0
- package/dist/node/client/index.js +838 -0
- package/dist/node/client/index.js.map +1 -0
- package/dist/node/index.js +30 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/node_modules/@noble/ciphers/aes.js +254 -0
- package/dist/node/node_modules/@noble/ciphers/aes.js.map +1 -0
- package/dist/node/node_modules/@noble/ciphers/utils.js +113 -0
- package/dist/node/node_modules/@noble/ciphers/utils.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/_md.js +146 -0
- package/dist/node/node_modules/@noble/hashes/esm/_md.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/_u64.js +51 -0
- package/dist/node/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/legacy.js +123 -0
- package/dist/node/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/sha2.js +346 -0
- package/dist/node/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/utils.js +73 -0
- package/dist/node/node_modules/@noble/hashes/esm/utils.js.map +1 -0
- package/dist/node/node_modules/@noble/secp256k1/index.js +578 -0
- package/dist/node/node_modules/@noble/secp256k1/index.js.map +1 -0
- package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js +132 -0
- package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js.map +1 -0
- package/dist/node/node_modules/bs58/src/esm/index.js +7 -0
- package/dist/node/node_modules/bs58/src/esm/index.js.map +1 -0
- package/dist/node/types/index.js +48 -0
- package/dist/node/types/index.js.map +1 -0
- package/dist/node/utils/chain-id.js +9 -0
- package/dist/node/utils/chain-id.js.map +1 -0
- package/dist/types/auth/index.d.ts +134 -0
- package/dist/types/auth/index.d.ts.map +1 -0
- package/dist/types/auth/keys.d.ts +112 -0
- package/dist/types/auth/keys.d.ts.map +1 -0
- package/dist/types/auth/memo.d.ts +51 -0
- package/dist/types/auth/memo.d.ts.map +1 -0
- package/dist/types/auth/serializer.d.ts +57 -0
- package/dist/types/auth/serializer.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +360 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +593 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/chain-id.d.ts +10 -0
- package/dist/types/utils/chain-id.d.ts.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
function base(ALPHABET) {
|
|
2
|
+
if (ALPHABET.length >= 255) {
|
|
3
|
+
throw new TypeError("Alphabet too long");
|
|
4
|
+
}
|
|
5
|
+
const BASE_MAP = new Uint8Array(256);
|
|
6
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
7
|
+
BASE_MAP[j] = 255;
|
|
8
|
+
}
|
|
9
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
10
|
+
const x = ALPHABET.charAt(i);
|
|
11
|
+
const xc = x.charCodeAt(0);
|
|
12
|
+
if (BASE_MAP[xc] !== 255) {
|
|
13
|
+
throw new TypeError(x + " is ambiguous");
|
|
14
|
+
}
|
|
15
|
+
BASE_MAP[xc] = i;
|
|
16
|
+
}
|
|
17
|
+
const BASE = ALPHABET.length;
|
|
18
|
+
const LEADER = ALPHABET.charAt(0);
|
|
19
|
+
const FACTOR = Math.log(BASE) / Math.log(256);
|
|
20
|
+
const iFACTOR = Math.log(256) / Math.log(BASE);
|
|
21
|
+
function encode(source) {
|
|
22
|
+
if (source instanceof Uint8Array) ;
|
|
23
|
+
else if (ArrayBuffer.isView(source)) {
|
|
24
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
25
|
+
} else if (Array.isArray(source)) {
|
|
26
|
+
source = Uint8Array.from(source);
|
|
27
|
+
}
|
|
28
|
+
if (!(source instanceof Uint8Array)) {
|
|
29
|
+
throw new TypeError("Expected Uint8Array");
|
|
30
|
+
}
|
|
31
|
+
if (source.length === 0) {
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
let zeroes = 0;
|
|
35
|
+
let length = 0;
|
|
36
|
+
let pbegin = 0;
|
|
37
|
+
const pend = source.length;
|
|
38
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
39
|
+
pbegin++;
|
|
40
|
+
zeroes++;
|
|
41
|
+
}
|
|
42
|
+
const size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
43
|
+
const b58 = new Uint8Array(size);
|
|
44
|
+
while (pbegin !== pend) {
|
|
45
|
+
let carry = source[pbegin];
|
|
46
|
+
let i = 0;
|
|
47
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++) {
|
|
48
|
+
carry += 256 * b58[it1] >>> 0;
|
|
49
|
+
b58[it1] = carry % BASE >>> 0;
|
|
50
|
+
carry = carry / BASE >>> 0;
|
|
51
|
+
}
|
|
52
|
+
if (carry !== 0) {
|
|
53
|
+
throw new Error("Non-zero carry");
|
|
54
|
+
}
|
|
55
|
+
length = i;
|
|
56
|
+
pbegin++;
|
|
57
|
+
}
|
|
58
|
+
let it2 = size - length;
|
|
59
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
60
|
+
it2++;
|
|
61
|
+
}
|
|
62
|
+
let str = LEADER.repeat(zeroes);
|
|
63
|
+
for (; it2 < size; ++it2) {
|
|
64
|
+
str += ALPHABET.charAt(b58[it2]);
|
|
65
|
+
}
|
|
66
|
+
return str;
|
|
67
|
+
}
|
|
68
|
+
function decodeUnsafe(source) {
|
|
69
|
+
if (typeof source !== "string") {
|
|
70
|
+
throw new TypeError("Expected String");
|
|
71
|
+
}
|
|
72
|
+
if (source.length === 0) {
|
|
73
|
+
return new Uint8Array();
|
|
74
|
+
}
|
|
75
|
+
let psz = 0;
|
|
76
|
+
let zeroes = 0;
|
|
77
|
+
let length = 0;
|
|
78
|
+
while (source[psz] === LEADER) {
|
|
79
|
+
zeroes++;
|
|
80
|
+
psz++;
|
|
81
|
+
}
|
|
82
|
+
const size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
83
|
+
const b256 = new Uint8Array(size);
|
|
84
|
+
while (psz < source.length) {
|
|
85
|
+
const charCode = source.charCodeAt(psz);
|
|
86
|
+
if (charCode > 255) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
let carry = BASE_MAP[charCode];
|
|
90
|
+
if (carry === 255) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let i = 0;
|
|
94
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++) {
|
|
95
|
+
carry += BASE * b256[it3] >>> 0;
|
|
96
|
+
b256[it3] = carry % 256 >>> 0;
|
|
97
|
+
carry = carry / 256 >>> 0;
|
|
98
|
+
}
|
|
99
|
+
if (carry !== 0) {
|
|
100
|
+
throw new Error("Non-zero carry");
|
|
101
|
+
}
|
|
102
|
+
length = i;
|
|
103
|
+
psz++;
|
|
104
|
+
}
|
|
105
|
+
let it4 = size - length;
|
|
106
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
107
|
+
it4++;
|
|
108
|
+
}
|
|
109
|
+
const vch = new Uint8Array(zeroes + (size - it4));
|
|
110
|
+
let j = zeroes;
|
|
111
|
+
while (it4 !== size) {
|
|
112
|
+
vch[j++] = b256[it4++];
|
|
113
|
+
}
|
|
114
|
+
return vch;
|
|
115
|
+
}
|
|
116
|
+
function decode(string) {
|
|
117
|
+
const buffer = decodeUnsafe(string);
|
|
118
|
+
if (buffer) {
|
|
119
|
+
return buffer;
|
|
120
|
+
}
|
|
121
|
+
throw new Error("Non-base" + BASE + " character");
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
encode,
|
|
125
|
+
decodeUnsafe,
|
|
126
|
+
decode
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
base as default
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/bs58/node_modules/base-x/src/esm/index.js"],"sourcesContent":["// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\nfunction base (ALPHABET) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n const BASE_MAP = new Uint8Array(256)\n for (let j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255\n }\n for (let i = 0; i < ALPHABET.length; i++) {\n const x = ALPHABET.charAt(i)\n const xc = x.charCodeAt(0)\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i\n }\n const BASE = ALPHABET.length\n const LEADER = ALPHABET.charAt(0)\n const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up\n const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up\n function encode (source) {\n // eslint-disable-next-line no-empty\n if (source instanceof Uint8Array) { } else if (ArrayBuffer.isView(source)) {\n source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength)\n } else if (Array.isArray(source)) {\n source = Uint8Array.from(source)\n }\n if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n let zeroes = 0\n let length = 0\n let pbegin = 0\n const pend = source.length\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++\n zeroes++\n }\n // Allocate enough space in big-endian base58 representation.\n const size = ((pend - pbegin) * iFACTOR + 1) >>> 0\n const b58 = new Uint8Array(size)\n // Process the bytes.\n while (pbegin !== pend) {\n let carry = source[pbegin]\n // Apply \"b58 = b58 * 256 + ch\".\n let i = 0\n for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0\n b58[it1] = (carry % BASE) >>> 0\n carry = (carry / BASE) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n pbegin++\n }\n // Skip leading zeroes in base58 result.\n let it2 = size - length\n while (it2 !== size && b58[it2] === 0) {\n it2++\n }\n // Translate the result into a string.\n let str = LEADER.repeat(zeroes)\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return new Uint8Array() }\n let psz = 0\n // Skip and count leading '1's.\n let zeroes = 0\n let length = 0\n while (source[psz] === LEADER) {\n zeroes++\n psz++\n }\n // Allocate enough space in big-endian base256 representation.\n const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.\n const b256 = new Uint8Array(size)\n // Process the characters.\n while (psz < source.length) {\n // Find code of next character\n const charCode = source.charCodeAt(psz)\n // Base map can not be indexed using char code\n if (charCode > 255) { return }\n // Decode character\n let carry = BASE_MAP[charCode]\n // Invalid character\n if (carry === 255) { return }\n let i = 0\n for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0\n b256[it3] = (carry % 256) >>> 0\n carry = (carry / 256) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n psz++\n }\n // Skip leading zeroes in b256.\n let it4 = size - length\n while (it4 !== size && b256[it4] === 0) {\n it4++\n }\n const vch = new Uint8Array(zeroes + (size - it4))\n let j = zeroes\n while (it4 !== size) {\n vch[j++] = b256[it4++]\n }\n return vch\n }\n function decode (string) {\n const buffer = decodeUnsafe(string)\n if (buffer) { return buffer }\n throw new Error('Non-base' + BASE + ' character')\n }\n return {\n encode,\n decodeUnsafe,\n decode\n }\n}\nexport default base\n"],"names":[],"mappings":"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","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/bs58/src/esm/index.js"],"sourcesContent":["import basex from 'base-x';\nvar ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nexport default basex(ALPHABET);\n"],"names":["basex"],"mappings":";AACA,IAAI,WAAW;AACf,MAAA,OAAeA,KAAM,QAAQ;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var JsonRpcErrorCode = /* @__PURE__ */ ((JsonRpcErrorCode2) => {
|
|
2
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
3
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
4
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
5
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
6
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
7
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["SERVER_ERROR"] = -32e3] = "SERVER_ERROR";
|
|
8
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["NO_PARAMS"] = -32001] = "NO_PARAMS";
|
|
9
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["PARSE_PARAMS_ERROR"] = -32002] = "PARSE_PARAMS_ERROR";
|
|
10
|
+
JsonRpcErrorCode2[JsonRpcErrorCode2["ERROR_DURING_CALL"] = -32003] = "ERROR_DURING_CALL";
|
|
11
|
+
return JsonRpcErrorCode2;
|
|
12
|
+
})(JsonRpcErrorCode || {});
|
|
13
|
+
var ListOrder = /* @__PURE__ */ ((ListOrder2) => {
|
|
14
|
+
ListOrder2["BY_NAME"] = "by_name";
|
|
15
|
+
ListOrder2["BY_PROXY"] = "by_proxy";
|
|
16
|
+
ListOrder2["BY_NEXT_VESTING_WITHDRAWAL"] = "by_next_vesting_withdrawal";
|
|
17
|
+
ListOrder2["BY_ACCOUNT"] = "by_account";
|
|
18
|
+
ListOrder2["BY_EXPIRATION"] = "by_expiration";
|
|
19
|
+
ListOrder2["BY_EFFECTIVE_DATE"] = "by_effective_date";
|
|
20
|
+
ListOrder2["BY_VOTE"] = "by_vote";
|
|
21
|
+
ListOrder2["BY_ACCOUNT_WITNESS"] = "by_account_witness";
|
|
22
|
+
ListOrder2["BY_WITNESS_ACCOUNT"] = "by_witness_account";
|
|
23
|
+
ListOrder2["BY_FROM_ID"] = "by_from_id";
|
|
24
|
+
ListOrder2["BY_RATIFICATION_DEADLINE"] = "by_ratification_deadline";
|
|
25
|
+
ListOrder2["BY_WITHDRAW_ROUTE"] = "by_withdraw_route";
|
|
26
|
+
ListOrder2["BY_DESTINATION"] = "by_destination";
|
|
27
|
+
ListOrder2["BY_COMPLETE_FROM_ID"] = "by_complete_from_id";
|
|
28
|
+
ListOrder2["BY_TO_COMPLETE"] = "by_to_complete";
|
|
29
|
+
ListOrder2["BY_DELEGATION"] = "by_delegation";
|
|
30
|
+
ListOrder2["BY_ACCOUNT_EXPIRATION"] = "by_account_expiration";
|
|
31
|
+
ListOrder2["BY_CONVERSION_DATE"] = "by_conversion_date";
|
|
32
|
+
ListOrder2["BY_CASHOUT_TIME"] = "by_cashout_time";
|
|
33
|
+
ListOrder2["BY_PERMLINK"] = "by_permlink";
|
|
34
|
+
ListOrder2["BY_ROOT"] = "by_root";
|
|
35
|
+
ListOrder2["BY_PARENT"] = "by_parent";
|
|
36
|
+
ListOrder2["BY_LAST_UPDATE"] = "by_last_update";
|
|
37
|
+
ListOrder2["BY_AUTHOR_LAST_UPDATE"] = "by_author_last_update";
|
|
38
|
+
ListOrder2["BY_COMMENT_VOTER"] = "by_comment_voter";
|
|
39
|
+
ListOrder2["BY_VOTER_COMMENT"] = "by_voter_comment";
|
|
40
|
+
ListOrder2["BY_PRICE"] = "by_price";
|
|
41
|
+
ListOrder2["BY_ACCOUNT_CREATION"] = "by_account_creation";
|
|
42
|
+
return ListOrder2;
|
|
43
|
+
})(ListOrder || {});
|
|
44
|
+
export {
|
|
45
|
+
JsonRpcErrorCode,
|
|
46
|
+
ListOrder
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["/**\n * Zattera RPC Types\n */\n\n// ============================================================================\n// Client Configuration\n// ============================================================================\n\n/**\n * Supported network names for chain ID computation\n */\nexport type NetworkName = 'zattera' | 'testnet';\n\nexport interface ZatteraClientConfig {\n endpoint: string;\n networkName?: NetworkName;\n timeout?: number;\n retries?: number;\n}\n\n// ============================================================================\n// JSON-RPC 2.0 Protocol Types\n// ============================================================================\n\nexport interface JsonRpcRequest {\n jsonrpc: '2.0';\n method: string;\n params?: unknown[] | Record<string, unknown>;\n id: string | number;\n}\n\nexport interface JsonRpcResponse<T = unknown> {\n jsonrpc: '2.0';\n result?: T;\n error?: JsonRpcError;\n id: string | number | null;\n}\n\nexport interface JsonRpcError {\n code: number;\n message: string;\n data?: unknown;\n}\n\nexport type RpcMethod = string;\nexport type RpcParams = unknown[];\n\n// JSON-RPC Error Codes\nexport enum JsonRpcErrorCode {\n PARSE_ERROR = -32700,\n INVALID_REQUEST = -32600,\n METHOD_NOT_FOUND = -32601,\n INVALID_PARAMS = -32602,\n INTERNAL_ERROR = -32603,\n SERVER_ERROR = -32000,\n NO_PARAMS = -32001,\n PARSE_PARAMS_ERROR = -32002,\n ERROR_DURING_CALL = -32003,\n}\n\n// ============================================================================\n// Core Protocol Types\n// ============================================================================\n\nexport type AccountName = string;\nexport type BlockId = string;\nexport type TransactionId = string;\nexport type Signature = string;\nexport type PublicKey = string;\nexport type PrivateKey = string;\nexport type ShareType = string; // int64 as string to avoid precision loss\nexport type AssetSymbol = string;\n\nexport interface Asset {\n amount: ShareType;\n symbol: AssetSymbol;\n precision: number;\n}\n\nexport interface Price {\n base: Asset;\n quote: Asset;\n}\n\n// ============================================================================\n// Transaction Types\n// ============================================================================\n\nexport interface Transaction {\n ref_block_num: number;\n ref_block_prefix: number;\n expiration: string; // ISO 8601 datetime\n operations: Operation[];\n extensions: unknown[];\n}\n\nexport interface SignedTransaction extends Transaction {\n signatures: Signature[];\n}\n\nexport type Operation = unknown[]; // [operation_type, operation_data]\n\n// ============================================================================\n// Block Types\n// ============================================================================\n\nexport interface BlockHeader {\n previous: BlockId;\n timestamp: string;\n witness: AccountName;\n transaction_merkle_root: string;\n extensions: unknown[];\n}\n\nexport interface SignedBlockHeader extends BlockHeader {\n witness_signature: Signature;\n}\n\nexport interface SignedBlock extends SignedBlockHeader {\n transactions: SignedTransaction[];\n block_id?: BlockId;\n signing_key?: PublicKey;\n transaction_ids?: TransactionId[];\n}\n\n// ============================================================================\n// Database API Types\n// ============================================================================\n\nexport interface DynamicGlobalProperties {\n id: number;\n head_block_number: number;\n head_block_id: BlockId;\n time: string;\n current_witness: AccountName;\n total_pow: number;\n num_pow_witnesses: number;\n virtual_supply: Asset;\n current_supply: Asset;\n init_sbd_supply: Asset;\n current_sbd_supply: Asset;\n total_vesting_fund_steem: Asset;\n total_vesting_shares: Asset;\n total_reward_fund_steem: Asset;\n total_reward_shares2: string;\n pending_rewarded_vesting_shares: Asset;\n pending_rewarded_vesting_steem: Asset;\n sbd_interest_rate: number;\n sbd_print_rate: number;\n maximum_block_size: number;\n required_actions_partition_percent: number;\n current_aslot: number;\n recent_slots_filled: string;\n participation_count: number;\n last_irreversible_block_num: number;\n vote_power_reserve_rate: number;\n delegation_return_period: number;\n reverse_auction_seconds: number;\n available_account_subsidies: number;\n sbd_stop_percent: number;\n sbd_start_percent: number;\n next_maintenance_time: string;\n last_budget_time: string;\n content_reward_percent: number;\n vesting_reward_percent: number;\n sps_fund_percent: number;\n sps_interval_ledger: Asset;\n downvote_pool_percent: number;\n}\n\nexport interface ChainConfig {\n ZATTERA_CHAIN_ID: string;\n ZATTERA_ADDRESS_PREFIX: string;\n ZATTERA_GENESIS_TIME: string;\n ZATTERA_MINING_TIME: string;\n ZATTERA_MIN_ACCOUNT_NAME_LENGTH: number;\n ZATTERA_MAX_ACCOUNT_NAME_LENGTH: number;\n ZATTERA_MIN_PERMLINK_LENGTH: number;\n ZATTERA_MAX_PERMLINK_LENGTH: number;\n ZATTERA_BLOCK_INTERVAL: number;\n ZATTERA_BLOCKS_PER_YEAR: number;\n ZATTERA_BLOCKS_PER_DAY: number;\n ZATTERA_START_VESTING_BLOCK: number;\n ZATTERA_INIT_MINER_NAME: string;\n ZATTERA_NUM_INIT_MINERS: number;\n ZATTERA_INIT_TIME: string;\n ZATTERA_MAX_WITNESSES: number;\n ZATTERA_MAX_VOTED_WITNESSES_HF0: number;\n ZATTERA_MAX_MINER_WITNESSES_HF0: number;\n ZATTERA_MAX_RUNNER_WITNESSES_HF0: number;\n [key: string]: unknown;\n}\n\nexport interface WitnessSchedule {\n id: number;\n current_virtual_time: string;\n next_shuffle_block_num: number;\n current_shuffled_witnesses: AccountName[];\n num_scheduled_witnesses: number;\n elected_weight: number;\n timeshare_weight: number;\n miner_weight: number;\n witness_pay_normalization_factor: number;\n median_props: {\n account_creation_fee: Asset;\n maximum_block_size: number;\n sbd_interest_rate: number;\n };\n majority_version: string;\n max_voted_witnesses: number;\n max_miner_witnesses: number;\n max_runner_witnesses: number;\n hardfork_required_witnesses: number;\n account_subsidy_budget: number;\n account_subsidy_decay: number;\n}\n\nexport interface HardforkProperties {\n id: number;\n processed_hardforks: string[];\n last_hardfork: number;\n current_hardfork_version: string;\n next_hardfork: string;\n next_hardfork_time: string;\n}\n\nexport interface RewardFund {\n id: number;\n name: string;\n reward_balance: Asset;\n recent_claims: string;\n last_update: string;\n content_constant: string;\n percent_curation_rewards: number;\n percent_content_rewards: number;\n author_reward_curve: string;\n curation_reward_curve: string;\n}\n\nexport interface PriceFeed {\n base: Asset;\n quote: Asset;\n}\n\nexport interface FeedHistory {\n id: number;\n current_median_history: Price;\n market_median_history: Price;\n current_min_history: Price;\n current_max_history: Price;\n price_history: Price[];\n}\n\n// ============================================================================\n// Account Types\n// ============================================================================\n\nexport interface Account {\n id: number;\n name: AccountName;\n owner: Authority;\n active: Authority;\n posting: Authority;\n memo_key: PublicKey;\n json_metadata: string;\n posting_json_metadata: string;\n proxy: AccountName;\n last_owner_update: string;\n last_account_update: string;\n created: string;\n mined: boolean;\n recovery_account: AccountName;\n reset_account: AccountName;\n last_account_recovery: string;\n comment_count: number;\n lifetime_vote_count: number;\n post_count: number;\n can_vote: boolean;\n voting_manabar: {\n current_mana: string;\n last_update_time: number;\n };\n downvote_manabar: {\n current_mana: string;\n last_update_time: number;\n };\n balance: Asset;\n savings_balance: Asset;\n sbd_balance: Asset;\n sbd_seconds: string;\n sbd_seconds_last_update: string;\n sbd_last_interest_payment: string;\n savings_sbd_balance: Asset;\n savings_sbd_seconds: string;\n savings_sbd_seconds_last_update: string;\n savings_sbd_last_interest_payment: string;\n savings_withdraw_requests: number;\n reward_sbd_balance: Asset;\n reward_steem_balance: Asset;\n reward_vesting_balance: Asset;\n reward_vesting_steem: Asset;\n vesting_shares: Asset;\n delegated_vesting_shares: Asset;\n received_vesting_shares: Asset;\n vesting_withdraw_rate: Asset;\n post_voting_power: Asset;\n next_vesting_withdrawal: string;\n withdrawn: number;\n to_withdraw: number;\n withdraw_routes: number;\n pending_transfers: number;\n curation_rewards: number;\n posting_rewards: number;\n proxied_vsf_votes: number[];\n witnesses_voted_for: number;\n last_post: string;\n last_root_post: string;\n last_vote_time: string;\n post_bandwidth: number;\n pending_claimed_accounts: number;\n delayed_votes: unknown[];\n open_recurrent_transfers: number;\n vesting_balance: Asset;\n reputation: string;\n transfer_history: unknown[];\n market_history: unknown[];\n post_history: unknown[];\n vote_history: unknown[];\n other_history: unknown[];\n witness_votes: AccountName[];\n tags_usage: unknown[];\n guest_bloggers: AccountName[];\n}\n\nexport interface Authority {\n weight_threshold: number;\n account_auths: [AccountName, number][];\n key_auths: [PublicKey, number][];\n}\n\nexport interface OwnerHistory {\n id: number;\n account: AccountName;\n previous_owner_authority: Authority;\n last_valid_time: string;\n}\n\nexport interface AccountRecoveryRequest {\n id: number;\n account_to_recover: AccountName;\n new_owner_authority: Authority;\n expires: string;\n}\n\nexport interface Escrow {\n id: number;\n escrow_id: number;\n from: AccountName;\n to: AccountName;\n agent: AccountName;\n ratification_deadline: string;\n escrow_expiration: string;\n sbd_balance: Asset;\n steem_balance: Asset;\n pending_fee: Asset;\n to_approved: boolean;\n agent_approved: boolean;\n disputed: boolean;\n}\n\nexport interface VestingDelegation {\n id: number;\n delegator: AccountName;\n delegatee: AccountName;\n vesting_shares: Asset;\n min_delegation_time: string;\n}\n\nexport interface ConversionRequest {\n id: number;\n owner: AccountName;\n requestid: number;\n amount: Asset;\n conversion_date: string;\n}\n\n// ============================================================================\n// Comment/Discussion Types\n// ============================================================================\n\nexport interface Comment {\n id: number;\n author: AccountName;\n permlink: string;\n category: string;\n parent_author: AccountName;\n parent_permlink: string;\n title: string;\n body: string;\n json_metadata: string;\n last_update: string;\n created: string;\n active: string;\n last_payout: string;\n depth: number;\n children: number;\n net_rshares: string;\n abs_rshares: string;\n vote_rshares: string;\n children_abs_rshares: string;\n cashout_time: string;\n max_cashout_time: string;\n total_vote_weight: number;\n reward_weight: number;\n total_payout_value: Asset;\n curator_payout_value: Asset;\n author_rewards: number;\n net_votes: number;\n root_author: AccountName;\n root_permlink: string;\n max_accepted_payout: Asset;\n percent_steem_dollars: number;\n allow_replies: boolean;\n allow_votes: boolean;\n allow_curation_rewards: boolean;\n beneficiaries: Beneficiary[];\n url: string;\n root_title: string;\n pending_payout_value: Asset;\n total_pending_payout_value: Asset;\n active_votes: ActiveVote[];\n replies: string[];\n author_reputation: string;\n promoted: Asset;\n body_length: number;\n reblogged_by: AccountName[];\n}\n\nexport interface Beneficiary {\n account: AccountName;\n weight: number;\n}\n\nexport interface ActiveVote {\n voter: AccountName;\n weight: number;\n rshares: string;\n percent: number;\n reputation: string;\n time: string;\n}\n\nexport interface Vote {\n id: number;\n voter: AccountName;\n author: AccountName;\n permlink: string;\n weight: number;\n rshares: string;\n vote_percent: number;\n last_update: string;\n num_changes: number;\n}\n\n// ============================================================================\n// Witness Types\n// ============================================================================\n\nexport interface Witness {\n id: number;\n owner: AccountName;\n created: string;\n url: string;\n votes: string;\n virtual_last_update: string;\n virtual_position: string;\n virtual_scheduled_time: string;\n total_missed: number;\n last_aslot: number;\n last_confirmed_block_num: number;\n pow_worker: number;\n signing_key: PublicKey;\n props: {\n account_creation_fee: Asset;\n maximum_block_size: number;\n sbd_interest_rate: number;\n account_subsidy_budget: number;\n account_subsidy_decay: number;\n };\n sbd_exchange_rate: Price;\n last_sbd_exchange_update: string;\n last_work: string;\n running_version: string;\n hardfork_version_vote: string;\n hardfork_time_vote: string;\n available_witness_account_subsidies: number;\n}\n\nexport interface WitnessVote {\n id: number;\n witness: AccountName;\n account: AccountName;\n}\n\n// ============================================================================\n// Market Types\n// ============================================================================\n\nexport interface LimitOrder {\n id: number;\n created: string;\n expiration: string;\n seller: AccountName;\n orderid: number;\n for_sale: number;\n sell_price: Price;\n}\n\nexport interface OrderBook {\n bids: Order[];\n asks: Order[];\n}\n\nexport interface Order {\n order_price: Price;\n real_price: string;\n steem: number;\n sbd: number;\n created: string;\n}\n\n// ============================================================================\n// List/Find Query Types\n// ============================================================================\n\nexport enum ListOrder {\n BY_NAME = 'by_name',\n BY_PROXY = 'by_proxy',\n BY_NEXT_VESTING_WITHDRAWAL = 'by_next_vesting_withdrawal',\n BY_ACCOUNT = 'by_account',\n BY_EXPIRATION = 'by_expiration',\n BY_EFFECTIVE_DATE = 'by_effective_date',\n BY_VOTE = 'by_vote',\n BY_ACCOUNT_WITNESS = 'by_account_witness',\n BY_WITNESS_ACCOUNT = 'by_witness_account',\n BY_FROM_ID = 'by_from_id',\n BY_RATIFICATION_DEADLINE = 'by_ratification_deadline',\n BY_WITHDRAW_ROUTE = 'by_withdraw_route',\n BY_DESTINATION = 'by_destination',\n BY_COMPLETE_FROM_ID = 'by_complete_from_id',\n BY_TO_COMPLETE = 'by_to_complete',\n BY_DELEGATION = 'by_delegation',\n BY_ACCOUNT_EXPIRATION = 'by_account_expiration',\n BY_CONVERSION_DATE = 'by_conversion_date',\n BY_CASHOUT_TIME = 'by_cashout_time',\n BY_PERMLINK = 'by_permlink',\n BY_ROOT = 'by_root',\n BY_PARENT = 'by_parent',\n BY_LAST_UPDATE = 'by_last_update',\n BY_AUTHOR_LAST_UPDATE = 'by_author_last_update',\n BY_COMMENT_VOTER = 'by_comment_voter',\n BY_VOTER_COMMENT = 'by_voter_comment',\n BY_PRICE = 'by_price',\n BY_ACCOUNT_CREATION = 'by_account_creation',\n}\n\n// ============================================================================\n// API Method Parameters\n// ============================================================================\n\nexport interface ListAccountsParams {\n start?: AccountName | null;\n limit: number;\n order: ListOrder;\n [key: string]: unknown;\n}\n\nexport interface FindAccountsParams {\n accounts: AccountName[];\n [key: string]: unknown;\n}\n\nexport interface ListWitnessesParams {\n start?: AccountName | null;\n limit: number;\n order: ListOrder;\n [key: string]: unknown;\n}\n\nexport interface GetAccountHistoryParams {\n account: AccountName;\n start: number;\n limit: number;\n [key: string]: unknown;\n}\n\nexport interface GetOpsInBlockParams {\n block_num: number;\n only_virtual: boolean;\n [key: string]: unknown;\n}\n\nexport interface DiscussionQuery {\n tag?: string;\n limit?: number;\n filter_tags?: string[];\n select_authors?: AccountName[];\n select_tags?: string[];\n truncate_body?: number;\n start_author?: AccountName;\n start_permlink?: string;\n parent_author?: AccountName;\n parent_permlink?: string;\n [key: string]: unknown;\n}\n\nexport interface GetFollowersParams {\n account: AccountName;\n start: AccountName | null;\n type: string;\n limit: number;\n [key: string]: unknown;\n}\n\nexport interface GetFollowingParams {\n account: AccountName;\n start: AccountName | null;\n type: string;\n limit: number;\n [key: string]: unknown;\n}\n\n// ============================================================================\n// API Method Return Types\n// ============================================================================\n\nexport interface BroadcastTransactionResult {\n id: TransactionId;\n block_num: number;\n trx_num: number;\n expired: boolean;\n}\n\nexport interface VerifyAuthorityResult {\n valid: boolean;\n}\n\nexport interface GetTransactionResult {\n ref_block_num: number;\n ref_block_prefix: number;\n expiration: string;\n operations: Operation[];\n extensions: unknown[];\n signatures: Signature[];\n transaction_id: TransactionId;\n block_num: number;\n transaction_num: number;\n}\n\nexport interface AccountHistoryEntry {\n trx_id: TransactionId;\n block: number;\n trx_in_block: number;\n op_in_trx: number;\n virtual_op: number;\n timestamp: string;\n op: Operation;\n}\n\nexport interface Ticker {\n latest: string;\n lowest_ask: string;\n highest_bid: string;\n percent_change: string;\n steem_volume: Asset;\n sbd_volume: Asset;\n}\n\nexport interface Volume {\n steem_volume: Asset;\n sbd_volume: Asset;\n}\n\nexport interface TradeHistory {\n date: string;\n current_pays: Asset;\n open_pays: Asset;\n}\n\nexport interface MarketHistory {\n id: number;\n open: string;\n high: string;\n low: string;\n close: string;\n steem_volume: Asset;\n sbd_volume: Asset;\n}\n\nexport interface Bucket {\n bucket_size: number;\n}\n"],"names":["JsonRpcErrorCode","ListOrder"],"mappings":"AAgDO,IAAK,qCAAAA,sBAAL;AACLA,oBAAAA,kBAAA,iBAAc,MAAA,IAAd;AACAA,oBAAAA,kBAAA,qBAAkB,MAAA,IAAlB;AACAA,oBAAAA,kBAAA,sBAAmB,MAAA,IAAnB;AACAA,oBAAAA,kBAAA,oBAAiB,MAAA,IAAjB;AACAA,oBAAAA,kBAAA,oBAAiB,MAAA,IAAjB;AACAA,oBAAAA,kBAAA,kBAAe,KAAA,IAAf;AACAA,oBAAAA,kBAAA,eAAY,MAAA,IAAZ;AACAA,oBAAAA,kBAAA,wBAAqB,MAAA,IAArB;AACAA,oBAAAA,kBAAA,uBAAoB,MAAA,IAApB;AATU,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAueL,IAAK,8BAAAC,eAAL;AACLA,aAAA,SAAA,IAAU;AACVA,aAAA,UAAA,IAAW;AACXA,aAAA,4BAAA,IAA6B;AAC7BA,aAAA,YAAA,IAAa;AACbA,aAAA,eAAA,IAAgB;AAChBA,aAAA,mBAAA,IAAoB;AACpBA,aAAA,SAAA,IAAU;AACVA,aAAA,oBAAA,IAAqB;AACrBA,aAAA,oBAAA,IAAqB;AACrBA,aAAA,YAAA,IAAa;AACbA,aAAA,0BAAA,IAA2B;AAC3BA,aAAA,mBAAA,IAAoB;AACpBA,aAAA,gBAAA,IAAiB;AACjBA,aAAA,qBAAA,IAAsB;AACtBA,aAAA,gBAAA,IAAiB;AACjBA,aAAA,eAAA,IAAgB;AAChBA,aAAA,uBAAA,IAAwB;AACxBA,aAAA,oBAAA,IAAqB;AACrBA,aAAA,iBAAA,IAAkB;AAClBA,aAAA,aAAA,IAAc;AACdA,aAAA,SAAA,IAAU;AACVA,aAAA,WAAA,IAAY;AACZA,aAAA,gBAAA,IAAiB;AACjBA,aAAA,uBAAA,IAAwB;AACxBA,aAAA,kBAAA,IAAmB;AACnBA,aAAA,kBAAA,IAAmB;AACnBA,aAAA,UAAA,IAAW;AACXA,aAAA,qBAAA,IAAsB;AA5BZ,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { sha256 } from "../node_modules/@noble/hashes/esm/sha2.js";
|
|
2
|
+
function generateChainId(networkName) {
|
|
3
|
+
const hash = sha256(new TextEncoder().encode(networkName));
|
|
4
|
+
return Array.from(hash).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
generateChainId
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chain-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-id.js","sources":["../../../src/utils/chain-id.ts"],"sourcesContent":["import { sha256 } from '@noble/hashes/sha2';\nimport type { NetworkName } from '../types/index.js';\n\n/**\n * Generate chain ID from network name using SHA256 hash\n * Follows the formula: fc::sha256::hash(chain_id_name)\n *\n * @param networkName - Network name to hash\n * @returns Hex string of the chain ID (without 0x prefix)\n */\nexport function generateChainId(networkName: NetworkName): string {\n const hash = sha256(new TextEncoder().encode(networkName));\n return Array.from(hash)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n}\n"],"names":[],"mappings":";AAUO,SAAS,gBAAgB,aAAkC;AAChE,QAAM,OAAO,OAAO,IAAI,cAAc,OAAO,WAAW,CAAC;AACzD,SAAO,MAAM,KAAK,IAAI,EACnB,IAAI,OAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EACxC,KAAK,EAAE;AACZ;"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication and transaction signing for Zattera blockchain
|
|
3
|
+
*/
|
|
4
|
+
import { PrivateKey, PublicKey } from './keys.js';
|
|
5
|
+
import type { Transaction, SignedTransaction } from '../types/index.js';
|
|
6
|
+
export * from './keys.js';
|
|
7
|
+
export * from './serializer.js';
|
|
8
|
+
export * from './memo.js';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for signing
|
|
11
|
+
*/
|
|
12
|
+
export interface SignConfig {
|
|
13
|
+
chainId: string;
|
|
14
|
+
addressPrefix?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sign a transaction with one or more private keys
|
|
18
|
+
*
|
|
19
|
+
* @param transaction The transaction to sign
|
|
20
|
+
* @param privateKeys Array of private keys (WIF format) or PrivateKey instances
|
|
21
|
+
* @param chainId Chain ID (hex string without 0x prefix)
|
|
22
|
+
* @returns Signed transaction with signatures
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const signedTx = await signTransaction(
|
|
27
|
+
* transaction,
|
|
28
|
+
* ['5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'],
|
|
29
|
+
* '0000000000000000000000000000000000000000000000000000000000000000'
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function signTransaction(transaction: Transaction, privateKeys: (string | PrivateKey)[], chainId: string): Promise<SignedTransaction>;
|
|
34
|
+
/**
|
|
35
|
+
* Verify a transaction signature
|
|
36
|
+
*
|
|
37
|
+
* @param transaction The signed transaction
|
|
38
|
+
* @param chainId Chain ID (hex string without 0x prefix)
|
|
39
|
+
* @returns Array of public keys that signed the transaction
|
|
40
|
+
*/
|
|
41
|
+
export declare function verifyTransactionSignatures(transaction: SignedTransaction, chainId: string): Promise<PublicKey[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Create a transaction ready for signing
|
|
44
|
+
*
|
|
45
|
+
* @param refBlockNum Reference block number (from head_block_number & 0xFFFF)
|
|
46
|
+
* @param refBlockPrefix Reference block prefix (from block header)
|
|
47
|
+
* @param expiration Expiration date (ISO 8601 string or Date)
|
|
48
|
+
* @param operations Array of operations
|
|
49
|
+
* @returns Transaction object ready for signing
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const tx = createTransaction(
|
|
54
|
+
* 12345,
|
|
55
|
+
* 4567890,
|
|
56
|
+
* new Date(Date.now() + 60000),
|
|
57
|
+
* [
|
|
58
|
+
* ['vote', { voter: 'alice', author: 'bob', permlink: 'test', weight: 10000 }]
|
|
59
|
+
* ]
|
|
60
|
+
* );
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function createTransaction(refBlockNum: number, refBlockPrefix: number, expiration: string | Date, operations: unknown[]): Transaction;
|
|
64
|
+
/**
|
|
65
|
+
* Auth API - Comprehensive authentication utilities
|
|
66
|
+
*/
|
|
67
|
+
export declare const Auth: {
|
|
68
|
+
/**
|
|
69
|
+
* Generate all role keys from account name and password
|
|
70
|
+
* @param name Account name
|
|
71
|
+
* @param password Password
|
|
72
|
+
* @param roles Array of role names (default: ['owner', 'active', 'posting', 'memo'])
|
|
73
|
+
* @returns Object mapping roles to private WIF keys and public keys
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const keys = Auth.getPrivateKeys('alice', 'password123');
|
|
78
|
+
* console.log(keys.active); // WIF private key
|
|
79
|
+
* console.log(keys.activePubkey); // ZTR... public key
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
getPrivateKeys(name: string, password: string, roles?: string[]): Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* Generate public keys only from account name and password
|
|
85
|
+
* @param name Account name
|
|
86
|
+
* @param password Password
|
|
87
|
+
* @param roles Array of role names
|
|
88
|
+
* @returns Object mapping roles to public keys
|
|
89
|
+
*/
|
|
90
|
+
generateKeys(name: string, password: string, roles?: string[]): Record<string, string>;
|
|
91
|
+
/**
|
|
92
|
+
* Convert account credentials to WIF format for a specific role
|
|
93
|
+
* @param name Account name
|
|
94
|
+
* @param password Password
|
|
95
|
+
* @param role Role name (e.g., 'active', 'posting')
|
|
96
|
+
* @returns WIF private key
|
|
97
|
+
*/
|
|
98
|
+
toWif(name: string, password: string, role?: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Convert WIF private key to public key
|
|
101
|
+
* @param privateWif WIF format private key
|
|
102
|
+
* @param addressPrefix Address prefix (default: 'ZTR')
|
|
103
|
+
* @returns Public key string
|
|
104
|
+
*/
|
|
105
|
+
wifToPublic(privateWif: string, addressPrefix?: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Check if a WIF key is valid
|
|
108
|
+
* @param privateWif WIF format private key
|
|
109
|
+
* @returns true if valid, false otherwise
|
|
110
|
+
*/
|
|
111
|
+
isWif(privateWif: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Sign a transaction with private keys
|
|
114
|
+
* @param tx Transaction to sign
|
|
115
|
+
* @param keys Array of WIF private keys
|
|
116
|
+
* @param chainId Chain ID
|
|
117
|
+
* @returns Signed transaction
|
|
118
|
+
*/
|
|
119
|
+
signTransaction(tx: Transaction, keys: string[], chainId: string): Promise<SignedTransaction>;
|
|
120
|
+
/**
|
|
121
|
+
* Verify account credentials against authorities
|
|
122
|
+
* @param name Account name
|
|
123
|
+
* @param password Password
|
|
124
|
+
* @param auths Authority public keys to verify against
|
|
125
|
+
* @param role Role to check (default: 'active')
|
|
126
|
+
* @returns true if credentials match, false otherwise
|
|
127
|
+
*/
|
|
128
|
+
verify(name: string, password: string, auths: {
|
|
129
|
+
owner?: string[];
|
|
130
|
+
active?: string[];
|
|
131
|
+
posting?: string[];
|
|
132
|
+
}, role?: string): boolean;
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAsC,MAAM,WAAW,CAAC;AAEtF,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAa,MAAM,mBAAmB,CAAC;AAEnF,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,EACpC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC,CA6B5B;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,EAAE,CAAC,CAyBtB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,UAAU,EAAE,OAAO,EAAE,GACpB,WAAW,CAYb;AAyBD;;GAEG;AACH,eAAO,MAAM,IAAI;IACf;;;;;;;;;;;;;OAaG;yBAEK,MAAM,YACF,MAAM,UACT,MAAM,EAAE,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAezB;;;;;;OAMG;uBAEK,MAAM,YACF,MAAM,UACT,MAAM,EAAE,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAczB;;;;;;OAMG;gBACS,MAAM,YAAY,MAAM,SAAQ,MAAM,GAAc,MAAM;IAKtE;;;;;OAKG;4BACqB,MAAM,kBAAiB,MAAM,GAAW,MAAM;IAMtE;;;;OAIG;sBACe,MAAM,GAAG,OAAO;IASlC;;;;;;OAMG;wBAEG,WAAW,QACT,MAAM,EAAE,WACL,MAAM,GACd,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;;;;;OAOG;iBAEK,MAAM,YACF,MAAM,SACT;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,SAC5D,MAAM,GACX,OAAO;CAWX,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic key utilities for Zattera blockchain
|
|
3
|
+
*/
|
|
4
|
+
export declare class PrivateKey {
|
|
5
|
+
private key;
|
|
6
|
+
constructor(key: Uint8Array);
|
|
7
|
+
/**
|
|
8
|
+
* Create PrivateKey from WIF (Wallet Import Format) string
|
|
9
|
+
*/
|
|
10
|
+
static fromWif(wif: string): PrivateKey;
|
|
11
|
+
/**
|
|
12
|
+
* Create PrivateKey from seed string
|
|
13
|
+
*/
|
|
14
|
+
static fromSeed(seed: string): PrivateKey;
|
|
15
|
+
/**
|
|
16
|
+
* Generate PrivateKey from account name, password and role
|
|
17
|
+
*/
|
|
18
|
+
static fromLogin(accountName: string, password: string, role?: string): PrivateKey;
|
|
19
|
+
/**
|
|
20
|
+
* Convert to WIF format
|
|
21
|
+
*/
|
|
22
|
+
toWif(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get the public key
|
|
25
|
+
*/
|
|
26
|
+
toPublic(): PublicKey;
|
|
27
|
+
/**
|
|
28
|
+
* Get raw bytes
|
|
29
|
+
*/
|
|
30
|
+
toBytes(): Uint8Array;
|
|
31
|
+
/**
|
|
32
|
+
* Sign a message hash
|
|
33
|
+
* @param messageHash The message hash to sign
|
|
34
|
+
* @returns Signature with recovery parameter
|
|
35
|
+
*/
|
|
36
|
+
sign(messageHash: Uint8Array): Promise<Signature>;
|
|
37
|
+
/**
|
|
38
|
+
* Get shared secret with a public key (for ECIES encryption)
|
|
39
|
+
* @param publicKey The public key to generate shared secret with
|
|
40
|
+
* @returns Shared secret as Uint8Array
|
|
41
|
+
*/
|
|
42
|
+
getSharedSecret(publicKey: PublicKey): Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
* Derive child key from offset (hierarchical key derivation)
|
|
45
|
+
* @param offset Offset string for derivation
|
|
46
|
+
* @returns New derived PrivateKey
|
|
47
|
+
*/
|
|
48
|
+
child(offset: string): PrivateKey;
|
|
49
|
+
}
|
|
50
|
+
export declare class PublicKey {
|
|
51
|
+
private key;
|
|
52
|
+
constructor(key: Uint8Array);
|
|
53
|
+
/**
|
|
54
|
+
* Create PublicKey from string (e.g., "ZTR...")
|
|
55
|
+
*/
|
|
56
|
+
static fromString(publicKeyString: string, prefix?: string): PublicKey;
|
|
57
|
+
/**
|
|
58
|
+
* Convert to string format (e.g., "ZTR...")
|
|
59
|
+
*/
|
|
60
|
+
toString(prefix?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Get raw bytes
|
|
63
|
+
*/
|
|
64
|
+
toBytes(): Uint8Array;
|
|
65
|
+
/**
|
|
66
|
+
* Verify a signature
|
|
67
|
+
*/
|
|
68
|
+
verify(messageHash: Uint8Array, signature: Signature): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Derive child key from offset (hierarchical key derivation)
|
|
71
|
+
* Note: This is not implemented for public keys alone, derive from private key instead
|
|
72
|
+
* @param _offset Offset string for derivation (unused)
|
|
73
|
+
* @returns Never - throws error
|
|
74
|
+
*/
|
|
75
|
+
child(_offset: string): PublicKey;
|
|
76
|
+
}
|
|
77
|
+
export declare class Signature {
|
|
78
|
+
private sig;
|
|
79
|
+
private recovery;
|
|
80
|
+
constructor(sig: Uint8Array | {
|
|
81
|
+
signature: Uint8Array;
|
|
82
|
+
recovery: number;
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Get compact signature (65 bytes: recovery + r + s)
|
|
86
|
+
*/
|
|
87
|
+
toCompact(): Uint8Array;
|
|
88
|
+
/**
|
|
89
|
+
* Get full signature with recovery parameter (65 bytes)
|
|
90
|
+
*/
|
|
91
|
+
toBuffer(): Uint8Array;
|
|
92
|
+
/**
|
|
93
|
+
* Recover public key from signature and message hash
|
|
94
|
+
*/
|
|
95
|
+
recoverPublicKey(messageHash: Uint8Array): Promise<PublicKey>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generate all account keys from account name and password
|
|
99
|
+
*/
|
|
100
|
+
export declare function generateKeys(accountName: string, password: string, roles?: string[]): Record<string, {
|
|
101
|
+
private: string;
|
|
102
|
+
public: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Check if a string is a valid WIF private key
|
|
106
|
+
*/
|
|
107
|
+
export declare function isWif(wif: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Check if a string is a valid public key
|
|
110
|
+
*/
|
|
111
|
+
export declare function isPublicKey(publicKey: string, prefix?: string): boolean;
|
|
112
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/auth/keys.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAa;gBAEZ,GAAG,EAAE,UAAU;IAO3B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAwBvC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAKzC;;OAEG;IACH,MAAM,CAAC,SAAS,CACd,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAiB,GACtB,UAAU;IAMb;;OAEG;IACH,KAAK,IAAI,MAAM;IAmBf;;OAEG;IACH,QAAQ,IAAI,SAAS;IAKrB;;OAEG;IACH,OAAO,IAAI,UAAU;IAIrB;;;;OAIG;IACG,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IASvD;;;;OAIG;IACH,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU;IAMjD;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;CAkBlC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAa;gBAEZ,GAAG,EAAE,UAAU;IAO3B;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,GAAE,MAAc,GAAG,SAAS;IAuB7E;;OAEG;IACH,QAAQ,CAAC,MAAM,GAAE,MAAc,GAAG,MAAM;IASxC;;OAEG;IACH,OAAO,IAAI,UAAU;IAIrB;;OAEG;IACG,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ7E;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;CAKlC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,QAAQ,CAAS;gBAEb,GAAG,EAAE,UAAU,GAAG;QAAE,SAAS,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAmBzE;;OAEG;IACH,SAAS,IAAI,UAAU;IAIvB;;OAEG;IACH,QAAQ,IAAI,UAAU;IAOtB;;OAEG;IACG,gBAAgB,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;CAepE;AAaD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAM,EAA2C,GACvD,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAcrD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO1C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAc,GAAG,OAAO,CAO9E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memo encryption/decryption for Zattera blockchain
|
|
3
|
+
* Based on ECIES (Elliptic Curve Integrated Encryption Scheme)
|
|
4
|
+
*/
|
|
5
|
+
import { PrivateKey, PublicKey } from './keys.js';
|
|
6
|
+
/**
|
|
7
|
+
* Encode a memo for encryption
|
|
8
|
+
* @param privateKey Sender's private key
|
|
9
|
+
* @param publicKey Recipient's public key
|
|
10
|
+
* @param memo Memo text (will be prefixed with # if not already)
|
|
11
|
+
* @param nonce Optional nonce for testing (default: random)
|
|
12
|
+
* @returns Encrypted memo string with # prefix
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const senderKey = PrivateKey.fromSeed('sender seed');
|
|
17
|
+
* const recipientPubKey = PrivateKey.fromSeed('recipient seed').toPublic();
|
|
18
|
+
* const encrypted = await encodeMemo(senderKey, recipientPubKey, 'Hello!');
|
|
19
|
+
* // Returns: "#<base58_encoded_encrypted_data>"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function encodeMemo(privateKey: PrivateKey, publicKey: PublicKey, memo: string, nonce?: Uint8Array): string;
|
|
23
|
+
/**
|
|
24
|
+
* Decode an encrypted memo
|
|
25
|
+
*
|
|
26
|
+
* Note: This function is deprecated. Use decodeMemoWithKey instead, as it requires
|
|
27
|
+
* the sender's public key to properly decrypt the memo.
|
|
28
|
+
*
|
|
29
|
+
* @param _privateKey Recipient's private key (unused)
|
|
30
|
+
* @param memo Encrypted memo string (must start with #)
|
|
31
|
+
* @returns Never - throws error directing to use decodeMemoWithKey
|
|
32
|
+
* @deprecated Use decodeMemoWithKey instead
|
|
33
|
+
*/
|
|
34
|
+
export declare function decodeMemo(_privateKey: PrivateKey, memo: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Decode an encrypted memo with explicit public key
|
|
37
|
+
* @param privateKey Recipient's private key
|
|
38
|
+
* @param publicKey Sender's public key
|
|
39
|
+
* @param memo Encrypted memo string (must start with #)
|
|
40
|
+
* @returns Decrypted memo text (with # prefix)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const recipientKey = PrivateKey.fromSeed('recipient seed');
|
|
45
|
+
* const senderPubKey = PrivateKey.fromSeed('sender seed').toPublic();
|
|
46
|
+
* const decrypted = await decodeMemoWithKey(recipientKey, senderPubKey, encryptedMemo);
|
|
47
|
+
* // Returns: "#Hello!"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function decodeMemoWithKey(privateKey: PrivateKey, publicKey: PublicKey, memo: string): string;
|
|
51
|
+
//# sourceMappingURL=memo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../../src/auth/memo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAWlD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,UAAU,GACjB,MAAM,CA4CR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,GACX,MAAM,CAqDR"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction serialization for Zattera blockchain
|
|
3
|
+
*/
|
|
4
|
+
import type { Transaction } from '../types/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Simple binary serializer for transactions
|
|
7
|
+
*/
|
|
8
|
+
export declare class TransactionSerializer {
|
|
9
|
+
private buffer;
|
|
10
|
+
/**
|
|
11
|
+
* Write a uint8 (1 byte)
|
|
12
|
+
*/
|
|
13
|
+
writeUInt8(value: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Write a uint16 (2 bytes, little-endian)
|
|
16
|
+
*/
|
|
17
|
+
writeUInt16(value: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Write a uint32 (4 bytes, little-endian)
|
|
20
|
+
*/
|
|
21
|
+
writeUInt32(value: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Write a uint64 (8 bytes, little-endian)
|
|
24
|
+
*/
|
|
25
|
+
writeUInt64(value: number | bigint): void;
|
|
26
|
+
/**
|
|
27
|
+
* Write variable-length integer
|
|
28
|
+
*/
|
|
29
|
+
writeVarint32(value: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Write a string
|
|
32
|
+
*/
|
|
33
|
+
writeString(value: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Write bytes
|
|
36
|
+
*/
|
|
37
|
+
writeBytes(bytes: Uint8Array): void;
|
|
38
|
+
/**
|
|
39
|
+
* Write array with length prefix
|
|
40
|
+
*/
|
|
41
|
+
writeArray<T>(arr: T[], writeItem: (item: T) => void): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get the serialized buffer
|
|
44
|
+
*/
|
|
45
|
+
toBuffer(): Uint8Array;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Serialize a transaction (without signatures)
|
|
49
|
+
*/
|
|
50
|
+
export declare function serializeTransaction(tx: Transaction): Uint8Array;
|
|
51
|
+
/**
|
|
52
|
+
* Serialize a signed transaction (with signatures)
|
|
53
|
+
*/
|
|
54
|
+
export declare function serializeSignedTransaction(tx: Transaction & {
|
|
55
|
+
signatures?: Uint8Array[];
|
|
56
|
+
}): Uint8Array;
|
|
57
|
+
//# sourceMappingURL=serializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../../src/auth/serializer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAEhE;;GAEG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAgB;IAE9B;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhC;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOhC;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAOzC;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQlC;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQhC;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAMnC;;OAEG;IACH,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAO3D;;OAEG;IACH,QAAQ,IAAI,UAAU;CAGvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,WAAW,GAAG,UAAU,CA6BhE;AA8ED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,WAAW,GAAG;IAAE,UAAU,CAAC,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG,UAAU,CAiBtG"}
|