@cds.id/podoru-sdk 1.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/README.md +155 -0
- package/dist/cjs/client/PodoruClient.js +153 -0
- package/dist/cjs/client/PodoruClient.js.map +1 -0
- package/dist/cjs/client/WebSocketClient.js +193 -0
- package/dist/cjs/client/WebSocketClient.js.map +1 -0
- package/dist/cjs/client/index.js +8 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/errors/index.js +78 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/transaction/Signer.js +82 -0
- package/dist/cjs/transaction/Signer.js.map +1 -0
- package/dist/cjs/transaction/TransactionBuilder.js +127 -0
- package/dist/cjs/transaction/TransactionBuilder.js.map +1 -0
- package/dist/cjs/transaction/index.js +9 -0
- package/dist/cjs/transaction/index.js.map +1 -0
- package/dist/cjs/types/api.js +3 -0
- package/dist/cjs/types/api.js.map +1 -0
- package/dist/cjs/types/chain.js +3 -0
- package/dist/cjs/types/chain.js.map +1 -0
- package/dist/cjs/types/events.js +3 -0
- package/dist/cjs/types/events.js.map +1 -0
- package/dist/cjs/types/index.js +3 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/node.js +3 -0
- package/dist/cjs/types/node.js.map +1 -0
- package/dist/cjs/types/state.js +3 -0
- package/dist/cjs/types/state.js.map +1 -0
- package/dist/cjs/types/transaction.js +3 -0
- package/dist/cjs/types/transaction.js.map +1 -0
- package/dist/cjs/utils/address.js +36 -0
- package/dist/cjs/utils/address.js.map +1 -0
- package/dist/cjs/utils/encoding.js +49 -0
- package/dist/cjs/utils/encoding.js.map +1 -0
- package/dist/cjs/utils/hash.js +28 -0
- package/dist/cjs/utils/hash.js.map +1 -0
- package/dist/cjs/utils/index.js +17 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/client/PodoruClient.d.ts +79 -0
- package/dist/esm/client/PodoruClient.d.ts.map +1 -0
- package/dist/esm/client/PodoruClient.js +149 -0
- package/dist/esm/client/PodoruClient.js.map +1 -0
- package/dist/esm/client/WebSocketClient.d.ts +89 -0
- package/dist/esm/client/WebSocketClient.d.ts.map +1 -0
- package/dist/esm/client/WebSocketClient.js +189 -0
- package/dist/esm/client/WebSocketClient.js.map +1 -0
- package/dist/esm/client/index.d.ts +5 -0
- package/dist/esm/client/index.d.ts.map +1 -0
- package/dist/esm/client/index.js +3 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/errors/index.d.ts +41 -0
- package/dist/esm/errors/index.d.ts.map +1 -0
- package/dist/esm/errors/index.js +69 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/transaction/Signer.d.ts +48 -0
- package/dist/esm/transaction/Signer.d.ts.map +1 -0
- package/dist/esm/transaction/Signer.js +77 -0
- package/dist/esm/transaction/Signer.js.map +1 -0
- package/dist/esm/transaction/TransactionBuilder.d.ts +44 -0
- package/dist/esm/transaction/TransactionBuilder.d.ts.map +1 -0
- package/dist/esm/transaction/TransactionBuilder.js +123 -0
- package/dist/esm/transaction/TransactionBuilder.js.map +1 -0
- package/dist/esm/transaction/index.d.ts +4 -0
- package/dist/esm/transaction/index.d.ts.map +1 -0
- package/dist/esm/transaction/index.js +3 -0
- package/dist/esm/transaction/index.js.map +1 -0
- package/dist/esm/types/api.d.ts +16 -0
- package/dist/esm/types/api.d.ts.map +1 -0
- package/dist/esm/types/api.js +2 -0
- package/dist/esm/types/api.js.map +1 -0
- package/dist/esm/types/chain.d.ts +32 -0
- package/dist/esm/types/chain.d.ts.map +1 -0
- package/dist/esm/types/chain.js +2 -0
- package/dist/esm/types/chain.js.map +1 -0
- package/dist/esm/types/events.d.ts +58 -0
- package/dist/esm/types/events.d.ts.map +1 -0
- package/dist/esm/types/events.js +2 -0
- package/dist/esm/types/events.js.map +1 -0
- package/dist/esm/types/index.d.ts +7 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/node.d.ts +32 -0
- package/dist/esm/types/node.d.ts.map +1 -0
- package/dist/esm/types/node.js +2 -0
- package/dist/esm/types/node.js.map +1 -0
- package/dist/esm/types/state.d.ts +23 -0
- package/dist/esm/types/state.d.ts.map +1 -0
- package/dist/esm/types/state.js +2 -0
- package/dist/esm/types/state.js.map +1 -0
- package/dist/esm/types/transaction.d.ts +39 -0
- package/dist/esm/types/transaction.d.ts.map +1 -0
- package/dist/esm/types/transaction.js +2 -0
- package/dist/esm/types/transaction.js.map +1 -0
- package/dist/esm/utils/address.d.ts +14 -0
- package/dist/esm/utils/address.d.ts.map +1 -0
- package/dist/esm/utils/address.js +31 -0
- package/dist/esm/utils/address.js.map +1 -0
- package/dist/esm/utils/encoding.d.ts +21 -0
- package/dist/esm/utils/encoding.d.ts.map +1 -0
- package/dist/esm/utils/encoding.js +42 -0
- package/dist/esm/utils/encoding.js.map +1 -0
- package/dist/esm/utils/hash.d.ts +9 -0
- package/dist/esm/utils/hash.d.ts.map +1 -0
- package/dist/esm/utils/hash.js +24 -0
- package/dist/esm/utils/hash.js.map +1 -0
- package/dist/esm/utils/index.d.ts +4 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/client/PodoruClient.d.ts +79 -0
- package/dist/types/client/PodoruClient.d.ts.map +1 -0
- package/dist/types/client/WebSocketClient.d.ts +89 -0
- package/dist/types/client/WebSocketClient.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +41 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/transaction/Signer.d.ts +48 -0
- package/dist/types/transaction/Signer.d.ts.map +1 -0
- package/dist/types/transaction/TransactionBuilder.d.ts +44 -0
- package/dist/types/transaction/TransactionBuilder.d.ts.map +1 -0
- package/dist/types/transaction/index.d.ts +4 -0
- package/dist/types/transaction/index.d.ts.map +1 -0
- package/dist/types/types/api.d.ts +16 -0
- package/dist/types/types/api.d.ts.map +1 -0
- package/dist/types/types/chain.d.ts +32 -0
- package/dist/types/types/chain.d.ts.map +1 -0
- package/dist/types/types/events.d.ts +58 -0
- package/dist/types/types/events.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/node.d.ts +32 -0
- package/dist/types/types/node.d.ts.map +1 -0
- package/dist/types/types/state.d.ts +23 -0
- package/dist/types/types/state.d.ts.map +1 -0
- package/dist/types/types/transaction.d.ts +39 -0
- package/dist/types/types/transaction.d.ts.map +1 -0
- package/dist/types/utils/address.d.ts +14 -0
- package/dist/types/utils/address.d.ts.map +1 -0
- package/dist/types/utils/encoding.d.ts +21 -0
- package/dist/types/utils/encoding.d.ts.map +1 -0
- package/dist/types/utils/hash.d.ts +9 -0
- package/dist/types/utils/hash.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a string or Buffer to Base64
|
|
3
|
+
*/
|
|
4
|
+
export declare function base64Encode(data: string | Uint8Array): string;
|
|
5
|
+
/**
|
|
6
|
+
* Decode a Base64 string to UTF-8 string
|
|
7
|
+
*/
|
|
8
|
+
export declare function base64Decode(data: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Decode a Base64 string to Uint8Array
|
|
11
|
+
*/
|
|
12
|
+
export declare function base64DecodeBytes(data: string): Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a hex string to Uint8Array
|
|
15
|
+
*/
|
|
16
|
+
export declare function hexToBytes(hex: string): Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Convert Uint8Array to hex string
|
|
19
|
+
*/
|
|
20
|
+
export declare function bytesToHex(bytes: Uint8Array, prefix?: boolean): string;
|
|
21
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../../src/utils/encoding.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAK9D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAE1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAOlD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,UAAO,GAAG,MAAM,CAKnE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a string or Buffer to Base64
|
|
3
|
+
*/
|
|
4
|
+
export function base64Encode(data) {
|
|
5
|
+
if (typeof data === 'string') {
|
|
6
|
+
return Buffer.from(data, 'utf-8').toString('base64');
|
|
7
|
+
}
|
|
8
|
+
return Buffer.from(data).toString('base64');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Decode a Base64 string to UTF-8 string
|
|
12
|
+
*/
|
|
13
|
+
export function base64Decode(data) {
|
|
14
|
+
return Buffer.from(data, 'base64').toString('utf-8');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Decode a Base64 string to Uint8Array
|
|
18
|
+
*/
|
|
19
|
+
export function base64DecodeBytes(data) {
|
|
20
|
+
return new Uint8Array(Buffer.from(data, 'base64'));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Convert a hex string to Uint8Array
|
|
24
|
+
*/
|
|
25
|
+
export function hexToBytes(hex) {
|
|
26
|
+
const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
27
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
28
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
29
|
+
bytes[i] = parseInt(cleanHex.slice(i * 2, i * 2 + 2), 16);
|
|
30
|
+
}
|
|
31
|
+
return bytes;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert Uint8Array to hex string
|
|
35
|
+
*/
|
|
36
|
+
export function bytesToHex(bytes, prefix = true) {
|
|
37
|
+
const hex = Array.from(bytes)
|
|
38
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
39
|
+
.join('');
|
|
40
|
+
return prefix ? `0x${hex}` : hex;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../../src/utils/encoding.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAyB;IACpD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC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of data
|
|
3
|
+
*/
|
|
4
|
+
export declare function sha256(data: string | Uint8Array): Uint8Array;
|
|
5
|
+
/**
|
|
6
|
+
* Compute SHA256 hash and return as hex string
|
|
7
|
+
*/
|
|
8
|
+
export declare function sha256Hex(data: string | Uint8Array): string;
|
|
9
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/utils/hash.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAQ5D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAK3D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Compute SHA256 hash of data
|
|
4
|
+
*/
|
|
5
|
+
export function sha256(data) {
|
|
6
|
+
const hash = createHash('sha256');
|
|
7
|
+
if (typeof data === 'string') {
|
|
8
|
+
hash.update(data, 'utf-8');
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
hash.update(data);
|
|
12
|
+
}
|
|
13
|
+
return new Uint8Array(hash.digest());
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Compute SHA256 hash and return as hex string
|
|
17
|
+
*/
|
|
18
|
+
export function sha256Hex(data) {
|
|
19
|
+
const hash = sha256(data);
|
|
20
|
+
return Array.from(hash)
|
|
21
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
22
|
+
.join('');
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../src/utils/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,IAAyB;IAC9C,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAyB;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;SACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ChainInfo, Block } from '../types/chain.js';
|
|
2
|
+
import type { Transaction } from '../types/transaction.js';
|
|
3
|
+
import type { SubmitTransactionResponse } from '../types/api.js';
|
|
4
|
+
import type { StateValueResponse, PrefixQueryResult } from '../types/state.js';
|
|
5
|
+
import type { NodeInfo, Peer, MempoolInfo, HealthResponse } from '../types/node.js';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for PodoruClient
|
|
8
|
+
*/
|
|
9
|
+
export interface PodoruClientConfig {
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* REST API client for Podoru Chain
|
|
16
|
+
*/
|
|
17
|
+
export declare class PodoruClient {
|
|
18
|
+
private baseUrl;
|
|
19
|
+
private timeout;
|
|
20
|
+
private headers;
|
|
21
|
+
constructor(config: PodoruClientConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Internal fetch helper with error handling
|
|
24
|
+
*/
|
|
25
|
+
private fetch;
|
|
26
|
+
/**
|
|
27
|
+
* Get blockchain information
|
|
28
|
+
*/
|
|
29
|
+
getChainInfo(): Promise<ChainInfo>;
|
|
30
|
+
/**
|
|
31
|
+
* Get block by hash
|
|
32
|
+
*/
|
|
33
|
+
getBlockByHash(hash: string): Promise<Block>;
|
|
34
|
+
/**
|
|
35
|
+
* Get block by height
|
|
36
|
+
*/
|
|
37
|
+
getBlockByHeight(height: number): Promise<Block>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the latest block
|
|
40
|
+
*/
|
|
41
|
+
getLatestBlock(): Promise<Block>;
|
|
42
|
+
/**
|
|
43
|
+
* Get transaction by hash
|
|
44
|
+
*/
|
|
45
|
+
getTransaction(hash: string): Promise<Transaction>;
|
|
46
|
+
/**
|
|
47
|
+
* Submit a signed transaction
|
|
48
|
+
*/
|
|
49
|
+
submitTransaction(tx: Transaction): Promise<SubmitTransactionResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Get a single state value
|
|
52
|
+
*/
|
|
53
|
+
getState(key: string): Promise<StateValueResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Get multiple state values in a batch
|
|
56
|
+
*/
|
|
57
|
+
batchGetState(keys: string[]): Promise<Record<string, string | null>>;
|
|
58
|
+
/**
|
|
59
|
+
* Query state by key prefix
|
|
60
|
+
*/
|
|
61
|
+
queryByPrefix(prefix: string, limit?: number): Promise<PrefixQueryResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Get node information
|
|
64
|
+
*/
|
|
65
|
+
getNodeInfo(): Promise<NodeInfo>;
|
|
66
|
+
/**
|
|
67
|
+
* Get connected peers
|
|
68
|
+
*/
|
|
69
|
+
getPeers(): Promise<Peer[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Health check
|
|
72
|
+
*/
|
|
73
|
+
getHealth(): Promise<HealthResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Get mempool information and pending transactions
|
|
76
|
+
*/
|
|
77
|
+
getMempool(): Promise<MempoolInfo>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=PodoruClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PodoruClient.d.ts","sourceRoot":"","sources":["../../../src/client/PodoruClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,E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IAS/E;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAItC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAIjC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC;IAM1C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;CAGzC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { EventType, WebSocketEvent, BlockEvent, TransactionEvent, ChainUpdateEvent, MempoolUpdateEvent, EventDataMap } from '../types/events.js';
|
|
2
|
+
/**
|
|
3
|
+
* WebSocket close event (cross-platform)
|
|
4
|
+
*/
|
|
5
|
+
export interface WsCloseEvent {
|
|
6
|
+
code: number;
|
|
7
|
+
reason: string;
|
|
8
|
+
wasClean: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for WebSocketClient
|
|
12
|
+
*/
|
|
13
|
+
export interface WebSocketClientConfig {
|
|
14
|
+
url: string;
|
|
15
|
+
reconnectInterval?: number;
|
|
16
|
+
maxReconnectAttempts?: number;
|
|
17
|
+
}
|
|
18
|
+
type EventCallback<T> = (event: T) => void;
|
|
19
|
+
/**
|
|
20
|
+
* WebSocket client for real-time Podoru Chain events
|
|
21
|
+
*/
|
|
22
|
+
export declare class WebSocketClient {
|
|
23
|
+
private url;
|
|
24
|
+
private reconnectInterval;
|
|
25
|
+
private maxReconnectAttempts;
|
|
26
|
+
private ws;
|
|
27
|
+
private reconnectAttempts;
|
|
28
|
+
private subscriptions;
|
|
29
|
+
private listeners;
|
|
30
|
+
private shouldReconnect;
|
|
31
|
+
constructor(config: WebSocketClientConfig);
|
|
32
|
+
/**
|
|
33
|
+
* Check if connected
|
|
34
|
+
*/
|
|
35
|
+
get isConnected(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Connect to the WebSocket server
|
|
38
|
+
*/
|
|
39
|
+
connect(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Disconnect from the WebSocket server
|
|
42
|
+
*/
|
|
43
|
+
disconnect(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Subscribe to event types
|
|
46
|
+
*/
|
|
47
|
+
subscribe(events: EventType[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* Unsubscribe from event types
|
|
50
|
+
*/
|
|
51
|
+
unsubscribe(events: EventType[]): void;
|
|
52
|
+
private sendSubscription;
|
|
53
|
+
private sendUnsubscription;
|
|
54
|
+
/**
|
|
55
|
+
* Register event listener
|
|
56
|
+
*/
|
|
57
|
+
on<K extends EventType>(event: K, callback: EventCallback<WebSocketEvent<EventDataMap[K]>>): () => void;
|
|
58
|
+
/**
|
|
59
|
+
* Listen for new block events
|
|
60
|
+
*/
|
|
61
|
+
onBlock(callback: (event: BlockEvent) => void): () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Listen for new transaction events
|
|
64
|
+
*/
|
|
65
|
+
onTransaction(callback: (event: TransactionEvent) => void): () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Listen for chain update events
|
|
68
|
+
*/
|
|
69
|
+
onChainUpdate(callback: (event: ChainUpdateEvent) => void): () => void;
|
|
70
|
+
/**
|
|
71
|
+
* Listen for mempool update events
|
|
72
|
+
*/
|
|
73
|
+
onMempoolUpdate(callback: (event: MempoolUpdateEvent) => void): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Listen for connection events
|
|
76
|
+
*/
|
|
77
|
+
onConnect(callback: () => void): () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Listen for disconnect events
|
|
80
|
+
*/
|
|
81
|
+
onDisconnect(callback: (event: WsCloseEvent) => void): () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Listen for error events
|
|
84
|
+
*/
|
|
85
|
+
onError(callback: (error: Error) => void): () => void;
|
|
86
|
+
private emit;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=WebSocketClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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M1B;;OAEG;IACH,EAAE,CAAC,CAAC,SAAS,SAAS,EACpB,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GACvD,MAAM,IAAI;IAYb;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI;IAI1D;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI;IAItE;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI;IAItE;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAAG,MAAM,IAAI;IAI1E;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAU3C;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI;IAUjE;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,MAAM,IAAI;IAUrD,OAAO,CAAC,IAAI;CAMb"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { PodoruClient } from './PodoruClient.js';
|
|
2
|
+
export type { PodoruClientConfig } from './PodoruClient.js';
|
|
3
|
+
export { WebSocketClient } from './WebSocketClient.js';
|
|
4
|
+
export type { WebSocketClientConfig, WsCloseEvent } from './WebSocketClient.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for Podoru SDK
|
|
3
|
+
*/
|
|
4
|
+
export declare class PodoruError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Error from API requests
|
|
9
|
+
*/
|
|
10
|
+
export declare class ApiError extends PodoruError {
|
|
11
|
+
readonly statusCode: number;
|
|
12
|
+
readonly response?: unknown;
|
|
13
|
+
constructor(message: string, statusCode: number, response?: unknown);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error during transaction processing
|
|
17
|
+
*/
|
|
18
|
+
export declare class TransactionError extends PodoruError {
|
|
19
|
+
readonly transactionHash?: string;
|
|
20
|
+
constructor(message: string, transactionHash?: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error during transaction signing
|
|
24
|
+
*/
|
|
25
|
+
export declare class SigningError extends PodoruError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validation error for invalid inputs
|
|
30
|
+
*/
|
|
31
|
+
export declare class ValidationError extends PodoruError {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* WebSocket connection error
|
|
36
|
+
*/
|
|
37
|
+
export declare class WebSocketError extends PodoruError {
|
|
38
|
+
readonly code?: number;
|
|
39
|
+
constructor(message: string, code?: number);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,WAAW;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO;CAOpE;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;gBAEtB,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM;CAMtD;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,WAAW;gBAC/B,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,EAAE,MAAM;CAK5B;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAM3C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { PodoruClient, WebSocketClient } from './client/index.js';
|
|
2
|
+
export type { PodoruClientConfig, WebSocketClientConfig } from './client/index.js';
|
|
3
|
+
export { TransactionBuilder, WalletSigner, serializeSignature } from './transaction/index.js';
|
|
4
|
+
export type { Signer, SignatureResult } from './transaction/index.js';
|
|
5
|
+
export { PodoruError, ApiError, TransactionError, SigningError, ValidationError, WebSocketError, } from './errors/index.js';
|
|
6
|
+
export { base64Encode, base64Decode, base64DecodeBytes, hexToBytes, bytesToHex, sha256, sha256Hex, isValidAddress, normalizeAddress, addressEquals, } from './utils/index.js';
|
|
7
|
+
export type { ApiResponse, SubmitTransactionResponse, ChainInfo, BlockHeader, Block, OperationType, Operation, TransactionData, Transaction, UnsignedTransaction, StateEntry, PrefixQueryResult, StateValueResponse, NodeInfo, Peer, MempoolInfo, HealthResponse, EventType, BlockEvent, TransactionEvent, ChainUpdateEvent, MempoolUpdateEvent, WebSocketEvent, EventDataMap, } from './types/index.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAGnF,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EACL,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAEV,WAAW,EACX,yBAAyB,EAEzB,SAAS,EACT,WAAW,EACX,KAAK,EAEL,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,mBAAmB,EAEnB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAElB,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,cAAc,EAEd,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature result with r, s, v components
|
|
3
|
+
*/
|
|
4
|
+
export interface SignatureResult {
|
|
5
|
+
r: string;
|
|
6
|
+
s: string;
|
|
7
|
+
v: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Interface for transaction signers
|
|
11
|
+
*/
|
|
12
|
+
export interface Signer {
|
|
13
|
+
readonly address: string;
|
|
14
|
+
sign(hash: Uint8Array): Promise<SignatureResult>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Wallet-based signer using ethers.js
|
|
18
|
+
*/
|
|
19
|
+
export declare class WalletSigner implements Signer {
|
|
20
|
+
private wallet;
|
|
21
|
+
constructor(privateKey: string);
|
|
22
|
+
/**
|
|
23
|
+
* Create a signer from a mnemonic phrase
|
|
24
|
+
*/
|
|
25
|
+
static fromMnemonic(mnemonic: string, path?: string): WalletSigner;
|
|
26
|
+
/**
|
|
27
|
+
* Create a random signer (for testing)
|
|
28
|
+
*/
|
|
29
|
+
static createRandom(): WalletSigner;
|
|
30
|
+
/**
|
|
31
|
+
* Get the signer's address
|
|
32
|
+
*/
|
|
33
|
+
get address(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get the private key (use with caution)
|
|
36
|
+
*/
|
|
37
|
+
get privateKey(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Sign a hash and return the signature components
|
|
40
|
+
*/
|
|
41
|
+
sign(hash: Uint8Array): Promise<SignatureResult>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Serialize signature to 65-byte array (r + s + v)
|
|
45
|
+
* v is normalized to 0 or 1 (not 27/28)
|
|
46
|
+
*/
|
|
47
|
+
export declare function serializeSignature(sig: SignatureResult): number[];
|
|
48
|
+
//# sourceMappingURL=Signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Signer.d.ts","sourceRoot":"","sources":["../../../src/transaction/Signer.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAClD;AAED;;GAEG;AACH,qBAAa,YAAa,YAAW,MAAM;IACzC,OAAO,CAAC,MAAM,CAAwB;gBAE1B,UAAU,EAAE,MAAM;IAQ9B;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY;IAUlE;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,YAAY;IAKnC;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;OAEG;IACG,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;CAcvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,EAAE,CAMjE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Operation, Transaction, UnsignedTransaction } from '../types/transaction.js';
|
|
2
|
+
import { Signer } from './Signer.js';
|
|
3
|
+
/**
|
|
4
|
+
* Builder for creating and signing transactions
|
|
5
|
+
*/
|
|
6
|
+
export declare class TransactionBuilder {
|
|
7
|
+
private from;
|
|
8
|
+
private operations;
|
|
9
|
+
private _nonce?;
|
|
10
|
+
private _timestamp?;
|
|
11
|
+
constructor(from: string);
|
|
12
|
+
/**
|
|
13
|
+
* Add a SET operation
|
|
14
|
+
* @param key - The key to set
|
|
15
|
+
* @param value - The value (string or Buffer)
|
|
16
|
+
*/
|
|
17
|
+
set(key: string, value: string | Uint8Array): TransactionBuilder;
|
|
18
|
+
/**
|
|
19
|
+
* Add a DELETE operation
|
|
20
|
+
* @param key - The key to delete
|
|
21
|
+
*/
|
|
22
|
+
delete(key: string): TransactionBuilder;
|
|
23
|
+
/**
|
|
24
|
+
* Add a raw operation
|
|
25
|
+
*/
|
|
26
|
+
addOperation(op: Operation): TransactionBuilder;
|
|
27
|
+
/**
|
|
28
|
+
* Set a custom nonce (defaults to Date.now())
|
|
29
|
+
*/
|
|
30
|
+
withNonce(nonce: number): TransactionBuilder;
|
|
31
|
+
/**
|
|
32
|
+
* Set a custom timestamp (defaults to current Unix timestamp)
|
|
33
|
+
*/
|
|
34
|
+
withTimestamp(timestamp: number): TransactionBuilder;
|
|
35
|
+
/**
|
|
36
|
+
* Build an unsigned transaction
|
|
37
|
+
*/
|
|
38
|
+
build(): UnsignedTransaction;
|
|
39
|
+
/**
|
|
40
|
+
* Build and sign the transaction
|
|
41
|
+
*/
|
|
42
|
+
buildAndSign(signer: Signer): Promise<Transaction>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=TransactionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionBuilder.d.ts","sourceRoot":"","sources":["../../../src/transaction/TransactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAmB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAK5G,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AAEzD;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,UAAU,CAAC,CAAS;gBAEhB,IAAI,EAAE,MAAM;IAOxB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,kBAAkB;IAahE;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IAWvC;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,kBAAkB;IAK/C;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB;IAK5C;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB;IAKpD;;OAEG;IACH,KAAK,IAAI,mBAAmB;IAoB5B;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC/D,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard API response wrapper
|
|
3
|
+
*/
|
|
4
|
+
export interface ApiResponse<T> {
|
|
5
|
+
success: boolean;
|
|
6
|
+
data?: T;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Response from transaction submission
|
|
11
|
+
*/
|
|
12
|
+
export interface SubmitTransactionResponse {
|
|
13
|
+
transaction_hash: string;
|
|
14
|
+
status: 'submitted';
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/types/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC;CACrB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Transaction } from './transaction.js';
|
|
2
|
+
/**
|
|
3
|
+
* Blockchain metadata
|
|
4
|
+
*/
|
|
5
|
+
export interface ChainInfo {
|
|
6
|
+
height: number;
|
|
7
|
+
current_hash: string;
|
|
8
|
+
genesis_hash: string;
|
|
9
|
+
authorities: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Block header information
|
|
13
|
+
*/
|
|
14
|
+
export interface BlockHeader {
|
|
15
|
+
version: number;
|
|
16
|
+
height: number;
|
|
17
|
+
previous_hash: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
merkle_root: string;
|
|
20
|
+
state_root: string;
|
|
21
|
+
producer_addr: string;
|
|
22
|
+
nonce: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Complete block with transactions
|
|
26
|
+
*/
|
|
27
|
+
export interface Block {
|
|
28
|
+
header: BlockHeader;
|
|
29
|
+
transactions: Transaction[];
|
|
30
|
+
signature: string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/types/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket event types
|
|
3
|
+
*/
|
|
4
|
+
export type EventType = 'new_block' | 'new_transaction' | 'chain_update' | 'mempool_update';
|
|
5
|
+
/**
|
|
6
|
+
* New block event data
|
|
7
|
+
*/
|
|
8
|
+
export interface BlockEvent {
|
|
9
|
+
height: number;
|
|
10
|
+
hash: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
transaction_count: number;
|
|
13
|
+
producer: string;
|
|
14
|
+
previous_hash: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* New transaction event data
|
|
18
|
+
*/
|
|
19
|
+
export interface TransactionEvent {
|
|
20
|
+
hash: string;
|
|
21
|
+
from: string;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
status: 'pending' | 'confirmed';
|
|
24
|
+
nonce: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Chain update event data
|
|
28
|
+
*/
|
|
29
|
+
export interface ChainUpdateEvent {
|
|
30
|
+
height: number;
|
|
31
|
+
current_hash: string;
|
|
32
|
+
authorities: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Mempool update event data
|
|
36
|
+
*/
|
|
37
|
+
export interface MempoolUpdateEvent {
|
|
38
|
+
count: number;
|
|
39
|
+
recent_hashes: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generic WebSocket event wrapper
|
|
43
|
+
*/
|
|
44
|
+
export interface WebSocketEvent<T = unknown> {
|
|
45
|
+
type: EventType;
|
|
46
|
+
data: T;
|
|
47
|
+
timestamp: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Map event types to their data types
|
|
51
|
+
*/
|
|
52
|
+
export interface EventDataMap {
|
|
53
|
+
new_block: BlockEvent;
|
|
54
|
+
new_transaction: TransactionEvent;
|
|
55
|
+
chain_update: ChainUpdateEvent;
|
|
56
|
+
mempool_update: MempoolUpdateEvent;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,iBAAiB,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,UAAU,CAAC;IACtB,eAAe,EAAE,gBAAgB,CAAC;IAClC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,cAAc,EAAE,kBAAkB,CAAC;CACpC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ApiResponse, SubmitTransactionResponse } from './api.js';
|
|
2
|
+
export type { ChainInfo, BlockHeader, Block } from './chain.js';
|
|
3
|
+
export type { OperationType, Operation, TransactionData, Transaction, UnsignedTransaction, } from './transaction.js';
|
|
4
|
+
export type { StateEntry, PrefixQueryResult, StateValueResponse } from './state.js';
|
|
5
|
+
export type { NodeInfo, Peer, MempoolInfo, HealthResponse } from './node.js';
|
|
6
|
+
export type { EventType, BlockEvent, TransactionEvent, ChainUpdateEvent, MempoolUpdateEvent, WebSocketEvent, EventDataMap, } from './events.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAGvE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGhE,YAAY,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGpF,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG7E,YAAY,EACV,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,aAAa,CAAC"}
|