@amadeus-protocol/sdk 1.0.8 → 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/dist/api/chain.d.ts +144 -117
- package/dist/api/chain.d.ts.map +1 -1
- package/dist/api/chain.js +175 -146
- package/dist/api/chain.js.map +1 -1
- package/dist/api/contract.d.ts +78 -60
- package/dist/api/contract.d.ts.map +1 -1
- package/dist/api/contract.js +102 -75
- package/dist/api/contract.js.map +1 -1
- package/dist/api/epoch.d.ts +65 -66
- package/dist/api/epoch.d.ts.map +1 -1
- package/dist/api/epoch.js +90 -98
- package/dist/api/epoch.js.map +1 -1
- package/dist/api/peer.d.ts +77 -78
- package/dist/api/peer.d.ts.map +1 -1
- package/dist/api/peer.js +93 -94
- package/dist/api/peer.js.map +1 -1
- package/dist/api/proof.d.ts +44 -23
- package/dist/api/proof.d.ts.map +1 -1
- package/dist/api/proof.js +56 -29
- package/dist/api/proof.js.map +1 -1
- package/dist/api/transaction.d.ts +68 -69
- package/dist/api/transaction.d.ts.map +1 -1
- package/dist/api/transaction.js +84 -84
- package/dist/api/transaction.js.map +1 -1
- package/dist/api/wallet.d.ts +36 -37
- package/dist/api/wallet.d.ts.map +1 -1
- package/dist/api/wallet.js +47 -50
- package/dist/api/wallet.js.map +1 -1
- package/dist/client.d.ts +66 -68
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +231 -276
- package/dist/client.js.map +1 -1
- package/dist/constants.d.ts +13 -10
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +49 -45
- package/dist/constants.js.map +1 -1
- package/dist/contract-state.d.ts +6 -3
- package/dist/contract-state.d.ts.map +1 -1
- package/dist/contract-state.js +88 -106
- package/dist/contract-state.js.map +1 -1
- package/dist/contracts/abi-types.d.ts +32 -32
- package/dist/contracts/abi-types.d.ts.map +1 -1
- package/dist/contracts/coin.d.ts +13 -20
- package/dist/contracts/coin.d.ts.map +1 -1
- package/dist/contracts/coin.js +42 -38
- package/dist/contracts/coin.js.map +1 -1
- package/dist/contracts/contract-call.d.ts +14 -16
- package/dist/contracts/contract-call.d.ts.map +1 -1
- package/dist/contracts/contract-call.js +45 -54
- package/dist/contracts/contract-call.js.map +1 -1
- package/dist/contracts/contract.d.ts +24 -55
- package/dist/contracts/contract.d.ts.map +1 -1
- package/dist/contracts/contract.js +63 -101
- package/dist/contracts/contract.js.map +1 -1
- package/dist/contracts/lockup/abi.d.ts +54 -51
- package/dist/contracts/lockup/abi.d.ts.map +1 -1
- package/dist/contracts/lockup/abi.js +65 -74
- package/dist/contracts/lockup/abi.js.map +1 -1
- package/dist/contracts/lockup/helpers.d.ts +22 -18
- package/dist/contracts/lockup/helpers.d.ts.map +1 -1
- package/dist/contracts/lockup/helpers.js +44 -47
- package/dist/contracts/lockup/helpers.js.map +1 -1
- package/dist/contracts/lockup/parsers.d.ts +7 -3
- package/dist/contracts/lockup/parsers.d.ts.map +1 -1
- package/dist/contracts/lockup/parsers.js +51 -55
- package/dist/contracts/lockup/parsers.js.map +1 -1
- package/dist/contracts/lockup/storage-keys.d.ts +5 -2
- package/dist/contracts/lockup/storage-keys.d.ts.map +1 -1
- package/dist/contracts/lockup/storage-keys.js +54 -70
- package/dist/contracts/lockup/storage-keys.js.map +1 -1
- package/dist/contracts/lockup/types.d.ts +73 -70
- package/dist/contracts/lockup/types.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/abi.d.ts +328 -325
- package/dist/contracts/lockup-prime/abi.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/abi.js +397 -417
- package/dist/contracts/lockup-prime/abi.js.map +1 -1
- package/dist/contracts/lockup-prime/helpers.d.ts +35 -31
- package/dist/contracts/lockup-prime/helpers.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/helpers.js +131 -137
- package/dist/contracts/lockup-prime/helpers.js.map +1 -1
- package/dist/contracts/lockup-prime/parsers.d.ts +9 -5
- package/dist/contracts/lockup-prime/parsers.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/parsers.js +61 -61
- package/dist/contracts/lockup-prime/parsers.js.map +1 -1
- package/dist/contracts/lockup-prime/storage-keys.d.ts +7 -4
- package/dist/contracts/lockup-prime/storage-keys.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/storage-keys.js +64 -80
- package/dist/contracts/lockup-prime/storage-keys.js.map +1 -1
- package/dist/contracts/lockup-prime/types.d.ts +92 -89
- package/dist/contracts/lockup-prime/types.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/types.js +12 -13
- package/dist/contracts/lockup-prime/types.js.map +1 -1
- package/dist/contracts/nft/abi.d.ts +104 -0
- package/dist/contracts/nft/abi.d.ts.map +1 -0
- package/dist/contracts/nft/abi.js +135 -0
- package/dist/contracts/nft/abi.js.map +1 -0
- package/dist/contracts/nft/helpers.d.ts +21 -0
- package/dist/contracts/nft/helpers.d.ts.map +1 -0
- package/dist/contracts/nft/helpers.js +61 -0
- package/dist/contracts/nft/helpers.js.map +1 -0
- package/dist/contracts/nft/types.d.ts +47 -0
- package/dist/contracts/nft/types.d.ts.map +1 -0
- package/dist/conversion.d.ts +5 -2
- package/dist/conversion.d.ts.map +1 -1
- package/dist/conversion.js +45 -50
- package/dist/conversion.js.map +1 -1
- package/dist/crypto.d.ts +14 -16
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +121 -140
- package/dist/crypto.js.map +1 -1
- package/dist/encoding.d.ts +11 -8
- package/dist/encoding.d.ts.map +1 -1
- package/dist/encoding.js +123 -144
- package/dist/encoding.js.map +1 -1
- package/dist/encryption.d.ts +15 -12
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +119 -117
- package/dist/encryption.js.map +1 -1
- package/dist/explorer.d.ts +10 -7
- package/dist/explorer.d.ts.map +1 -1
- package/dist/explorer.js +51 -48
- package/dist/explorer.js.map +1 -1
- package/dist/formatters.d.ts +8 -5
- package/dist/formatters.d.ts.map +1 -1
- package/dist/formatters.js +67 -68
- package/dist/formatters.js.map +1 -1
- package/dist/index.d.ts +42 -55
- package/dist/index.js +39 -55
- package/dist/mnemonic.d.ts +12 -9
- package/dist/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic.js +105 -114
- package/dist/mnemonic.js.map +1 -1
- package/dist/networks.d.ts +14 -17
- package/dist/networks.d.ts.map +1 -1
- package/dist/networks.js +40 -36
- package/dist/networks.js.map +1 -1
- package/dist/schemas.js +75 -79
- package/dist/schemas.js.map +1 -1
- package/dist/sdk.d.ts +69 -65
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +126 -117
- package/dist/sdk.js.map +1 -1
- package/dist/serialization.d.ts +8 -18
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +207 -260
- package/dist/serialization.js.map +1 -1
- package/dist/signing.js +67 -67
- package/dist/signing.js.map +1 -1
- package/dist/transaction-builder.d.ts +175 -184
- package/dist/transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder.js +295 -344
- package/dist/transaction-builder.js.map +1 -1
- package/dist/transaction-errors.d.ts +10 -12
- package/dist/transaction-errors.d.ts.map +1 -1
- package/dist/transaction-errors.js +145 -166
- package/dist/transaction-errors.js.map +1 -1
- package/dist/types.d.ts +530 -450
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +169 -183
- package/dist/types.js.map +1 -1
- package/dist/validation.d.ts +24 -26
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +194 -192
- package/dist/validation.js.map +1 -1
- package/package.json +4 -3
- package/dist/api/index.d.ts +0 -8
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -8
- package/dist/api/index.js.map +0 -1
- package/dist/contracts/abi-types.js +0 -8
- package/dist/contracts/abi-types.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -7
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -7
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/lockup/calls.d.ts +0 -23
- package/dist/contracts/lockup/calls.d.ts.map +0 -1
- package/dist/contracts/lockup/calls.js +0 -25
- package/dist/contracts/lockup/calls.js.map +0 -1
- package/dist/contracts/lockup/index.d.ts +0 -6
- package/dist/contracts/lockup/index.d.ts.map +0 -1
- package/dist/contracts/lockup/index.js +0 -6
- package/dist/contracts/lockup/index.js.map +0 -1
- package/dist/contracts/lockup/types.js +0 -7
- package/dist/contracts/lockup/types.js.map +0 -1
- package/dist/contracts/lockup-prime/calls.d.ts +0 -53
- package/dist/contracts/lockup-prime/calls.d.ts.map +0 -1
- package/dist/contracts/lockup-prime/calls.js +0 -60
- package/dist/contracts/lockup-prime/calls.js.map +0 -1
- package/dist/contracts/lockup-prime/index.d.ts +0 -6
- package/dist/contracts/lockup-prime/index.d.ts.map +0 -1
- package/dist/contracts/lockup-prime/index.js +0 -6
- package/dist/contracts/lockup-prime/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/schemas.d.ts +0 -67
- package/dist/schemas.d.ts.map +0 -1
- package/dist/signing.d.ts +0 -39
- package/dist/signing.d.ts.map +0 -1
package/dist/api/chain.d.ts
CHANGED
|
@@ -1,119 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
import { GetByHashResponse, GetByHeightResponse, GetKpiResponse, GetStatsResponse, GetTipResponse, GetTransactionEventsByAccountResponse, GetTransactionsInEntryResponse, Transaction, TransactionFilters, TxByFilterParams, TxByFilterResponse } from "../types.js";
|
|
2
|
+
import { AmadeusClient } from "../client.js";
|
|
3
|
+
|
|
4
|
+
//#region src/api/chain.d.ts
|
|
5
|
+
declare class ChainAPI {
|
|
6
|
+
private client;
|
|
7
|
+
constructor(client: AmadeusClient);
|
|
8
|
+
/**
|
|
9
|
+
* Get the current chain tip (latest entry)
|
|
10
|
+
*
|
|
11
|
+
* @returns Promise resolving to the latest chain entry
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const { entry } = await sdk.chain.getTip()
|
|
16
|
+
* console.log('Current height:', entry.height)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
getTip(): Promise<GetTipResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Get chain statistics
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise resolving to chain statistics
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const { stats } = await sdk.chain.getStats()
|
|
28
|
+
* console.log('Total entries:', stats.total_entries)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
getStats(): Promise<GetStatsResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Get entry by hash
|
|
34
|
+
*
|
|
35
|
+
* @param hash - Entry hash (Base58 encoded)
|
|
36
|
+
* @param filterOnFunction - Optional function filter
|
|
37
|
+
* @returns Promise resolving to chain entry
|
|
38
|
+
* @throws {Error} If hash is invalid
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const { entry } = await sdk.chain.getByHash('5Kd3N...')
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
getByHash(hash: string, filterOnFunction?: string): Promise<GetByHashResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Get entries by height
|
|
48
|
+
*
|
|
49
|
+
* @param height - Block height (must be >= 0)
|
|
50
|
+
* @returns Promise resolving to chain entries at the specified height
|
|
51
|
+
* @throws {Error} If height is invalid
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const { entries } = await sdk.chain.getByHeight(1000)
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
getByHeight(height: number): Promise<GetByHeightResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Get entries by height with transactions
|
|
61
|
+
*
|
|
62
|
+
* @param height - Block height (must be >= 0)
|
|
63
|
+
* @returns Promise resolving to chain entries with transactions at the specified height
|
|
64
|
+
* @throws {Error} If height is invalid
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const { entries } = await sdk.chain.getByHeightWithTxs(1000)
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
getByHeightWithTxs(height: number): Promise<GetByHeightResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* Get a specific transaction by ID
|
|
74
|
+
*
|
|
75
|
+
* @param txid - Transaction ID (Base58 encoded)
|
|
76
|
+
* @returns Promise resolving to transaction data
|
|
77
|
+
* @throws {Error} If transaction ID is invalid
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const tx = await sdk.chain.getTransaction('5Kd3N...')
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
getTransaction(txid: string): Promise<Transaction>;
|
|
85
|
+
/**
|
|
86
|
+
* Get transactions in a specific entry
|
|
87
|
+
*
|
|
88
|
+
* @param entryHash - Entry hash (Base58 encoded)
|
|
89
|
+
* @returns Promise resolving to transactions in the entry
|
|
90
|
+
* @throws {Error} If entry hash is invalid
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const { txs } = await sdk.chain.getTransactionsInEntry('5Kd3N...')
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
getTransactionsInEntry(entryHash: string): Promise<GetTransactionsInEntryResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* Get transaction events by account with filtering
|
|
100
|
+
*
|
|
101
|
+
* @param account - Account address (Base58 encoded)
|
|
102
|
+
* @param filters - Optional filters for transactions
|
|
103
|
+
* @returns Promise resolving to transaction events
|
|
104
|
+
* @throws {Error} If account address is invalid
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const { txs, cursor } = await sdk.chain.getTransactionEventsByAccount('5Kd3N...', {
|
|
109
|
+
* limit: 10,
|
|
110
|
+
* sort: 'desc'
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
getTransactionEventsByAccount(account: string, filters?: TransactionFilters): Promise<GetTransactionEventsByAccountResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Query transactions by arbitrary filter (signer, receiver, contract, function).
|
|
117
|
+
*
|
|
118
|
+
* All filter fields are optional; provide only the ones you want to constrain.
|
|
119
|
+
* Returns a cursor for pagination — pass it back as `cursor` in a subsequent call.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const { txs, cursor } = await sdk.chain.getByFilter({
|
|
124
|
+
* signer: '5Kd3N...',
|
|
125
|
+
* contract: 'Coin',
|
|
126
|
+
* function: 'transfer',
|
|
127
|
+
* limit: 50,
|
|
128
|
+
* sort: 'desc'
|
|
129
|
+
* })
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
getByFilter(filters?: TxByFilterParams): Promise<TxByFilterResponse>;
|
|
133
|
+
/**
|
|
134
|
+
* Get protocol-level KPIs (burned, fees, active validators/peers, total tx, UAW, etc.).
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const { kpi } = await sdk.chain.getKpi()
|
|
139
|
+
* console.log('Total tx:', kpi.total_tx)
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
getKpi(): Promise<GetKpiResponse>;
|
|
118
143
|
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { ChainAPI };
|
|
119
146
|
//# sourceMappingURL=chain.d.ts.map
|
package/dist/api/chain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","
|
|
1
|
+
{"version":3,"file":"chain.d.ts","names":[],"sources":["../../src/api/chain.ts"],"mappings":";;;;cAwBa,QAAA;EAAA,QACQ,MAAA;cAAA,MAAA,EAAQ,aAAA;EA4BF;;;;;;;;;;;EAfpB,MAAA,CAAA,GAAU,OAAA,CAAQ,cAAA;EA+Hd;;;;;;;;;;;EAhHJ,QAAA,CAAA,GAAY,OAAA,CAAQ,gBAAA;EA5BE;;;;;;;;;;;;;EA6CtB,SAAA,CAAU,IAAA,UAAc,gBAAA,YAA4B,OAAA,CAAQ,iBAAA;EAmBhD;;;;;;;;;;;;EAAZ,WAAA,CAAY,MAAA,WAAiB,OAAA,CAAQ,mBAAA;EAmDM;;;;;;;;;;;;EAlC3C,kBAAA,CAAmB,MAAA,WAAiB,OAAA,CAAQ,mBAAA;EAuG5C;;;;;;;;;;;;EAtFA,cAAA,CAAe,IAAA,WAAe,OAAA,CAAQ,WAAA;;;;;;;;;;;;;EAiBtC,sBAAA,CAAuB,SAAA,WAAoB,OAAA,CAAQ,8BAAA;;;;;;;;;;;;;;;;;EAuBnD,6BAAA,CACL,OAAA,UACA,OAAA,GAAS,kBAAA,GACP,OAAA,CAAQ,qCAAA;;;;;;;;;;;;;;;;;;EA2BL,WAAA,CAAY,OAAA,GAAS,gBAAA,GAAwB,OAAA,CAAQ,kBAAA;;;;;;;;;;EAgBrD,MAAA,CAAA,GAAU,OAAA,CAAQ,cAAA;AAAA"}
|
package/dist/api/chain.js
CHANGED
|
@@ -1,147 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
import { validate } from "../validation.js";
|
|
2
|
+
import { Base58HashSchema, TransactionFiltersSchema } from "../schemas.js";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
//#region src/api/chain.ts
|
|
5
|
+
var ChainAPI = class {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get the current chain tip (latest entry)
|
|
12
|
+
*
|
|
13
|
+
* @returns Promise resolving to the latest chain entry
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const { entry } = await sdk.chain.getTip()
|
|
18
|
+
* console.log('Current height:', entry.height)
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
async getTip() {
|
|
22
|
+
return this.client.get("/api/chain/tip");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get chain statistics
|
|
26
|
+
*
|
|
27
|
+
* @returns Promise resolving to chain statistics
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const { stats } = await sdk.chain.getStats()
|
|
32
|
+
* console.log('Total entries:', stats.total_entries)
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
async getStats() {
|
|
36
|
+
return this.client.get("/api/chain/stats");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get entry by hash
|
|
40
|
+
*
|
|
41
|
+
* @param hash - Entry hash (Base58 encoded)
|
|
42
|
+
* @param filterOnFunction - Optional function filter
|
|
43
|
+
* @returns Promise resolving to chain entry
|
|
44
|
+
* @throws {Error} If hash is invalid
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const { entry } = await sdk.chain.getByHash('5Kd3N...')
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
async getByHash(hash, filterOnFunction) {
|
|
52
|
+
validate(Base58HashSchema, hash);
|
|
53
|
+
return this.client.get(`/api/chain/hash/${hash}`, { filter_on_function: filterOnFunction });
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get entries by height
|
|
57
|
+
*
|
|
58
|
+
* @param height - Block height (must be >= 0)
|
|
59
|
+
* @returns Promise resolving to chain entries at the specified height
|
|
60
|
+
* @throws {Error} If height is invalid
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const { entries } = await sdk.chain.getByHeight(1000)
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
async getByHeight(height) {
|
|
68
|
+
validate(Schema.NonNegativeInt, height);
|
|
69
|
+
return this.client.get(`/api/chain/height/${height}`);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get entries by height with transactions
|
|
73
|
+
*
|
|
74
|
+
* @param height - Block height (must be >= 0)
|
|
75
|
+
* @returns Promise resolving to chain entries with transactions at the specified height
|
|
76
|
+
* @throws {Error} If height is invalid
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const { entries } = await sdk.chain.getByHeightWithTxs(1000)
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
async getByHeightWithTxs(height) {
|
|
84
|
+
validate(Schema.NonNegativeInt, height);
|
|
85
|
+
return this.client.get(`/api/chain/height_with_txs/${height}`);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get a specific transaction by ID
|
|
89
|
+
*
|
|
90
|
+
* @param txid - Transaction ID (Base58 encoded)
|
|
91
|
+
* @returns Promise resolving to transaction data
|
|
92
|
+
* @throws {Error} If transaction ID is invalid
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const tx = await sdk.chain.getTransaction('5Kd3N...')
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
async getTransaction(txid) {
|
|
100
|
+
validate(Base58HashSchema, txid);
|
|
101
|
+
return this.client.get(`/api/chain/tx/${txid}`);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get transactions in a specific entry
|
|
105
|
+
*
|
|
106
|
+
* @param entryHash - Entry hash (Base58 encoded)
|
|
107
|
+
* @returns Promise resolving to transactions in the entry
|
|
108
|
+
* @throws {Error} If entry hash is invalid
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const { txs } = await sdk.chain.getTransactionsInEntry('5Kd3N...')
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
async getTransactionsInEntry(entryHash) {
|
|
116
|
+
validate(Base58HashSchema, entryHash);
|
|
117
|
+
return this.client.get(`/api/chain/txs_in_entry/${entryHash}`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get transaction events by account with filtering
|
|
121
|
+
*
|
|
122
|
+
* @param account - Account address (Base58 encoded)
|
|
123
|
+
* @param filters - Optional filters for transactions
|
|
124
|
+
* @returns Promise resolving to transaction events
|
|
125
|
+
* @throws {Error} If account address is invalid
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* const { txs, cursor } = await sdk.chain.getTransactionEventsByAccount('5Kd3N...', {
|
|
130
|
+
* limit: 10,
|
|
131
|
+
* sort: 'desc'
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
async getTransactionEventsByAccount(account, filters = {}) {
|
|
136
|
+
validate(Base58HashSchema, account);
|
|
137
|
+
validate(TransactionFiltersSchema, filters);
|
|
138
|
+
return this.client.get(`/api/chain/tx_events_by_account/${account}`, filters);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Query transactions by arbitrary filter (signer, receiver, contract, function).
|
|
142
|
+
*
|
|
143
|
+
* All filter fields are optional; provide only the ones you want to constrain.
|
|
144
|
+
* Returns a cursor for pagination — pass it back as `cursor` in a subsequent call.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* const { txs, cursor } = await sdk.chain.getByFilter({
|
|
149
|
+
* signer: '5Kd3N...',
|
|
150
|
+
* contract: 'Coin',
|
|
151
|
+
* function: 'transfer',
|
|
152
|
+
* limit: 50,
|
|
153
|
+
* sort: 'desc'
|
|
154
|
+
* })
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
async getByFilter(filters = {}) {
|
|
158
|
+
return this.client.get("/api/chain/tx_by_filter", filters);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get protocol-level KPIs (burned, fees, active validators/peers, total tx, UAW, etc.).
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* const { kpi } = await sdk.chain.getKpi()
|
|
166
|
+
* console.log('Total tx:', kpi.total_tx)
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
async getKpi() {
|
|
170
|
+
return this.client.get("/api/chain/kpi");
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
export { ChainAPI };
|
|
175
|
+
|
|
147
176
|
//# sourceMappingURL=chain.js.map
|
package/dist/api/chain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","
|
|
1
|
+
{"version":3,"file":"chain.js","names":[],"sources":["../../src/api/chain.ts"],"sourcesContent":["/**\n * Chain API\n *\n * Provides methods for querying blockchain data\n */\n\nimport type { AmadeusClient } from '../client'\nimport type {\n\tTransactionFilters,\n\tGetTipResponse,\n\tGetStatsResponse,\n\tGetByHashResponse,\n\tGetByHeightResponse,\n\tGetTransactionsInEntryResponse,\n\tGetTransactionEventsByAccountResponse,\n\tTransaction,\n\tTxByFilterParams,\n\tTxByFilterResponse,\n\tGetKpiResponse\n} from '../types'\nimport { Base58HashSchema, TransactionFiltersSchema } from '../schemas'\nimport { Schema } from 'effect'\nimport { validate } from '../validation'\n\nexport class ChainAPI {\n\tconstructor(private client: AmadeusClient) {}\n\n\t/**\n\t * Get the current chain tip (latest entry)\n\t *\n\t * @returns Promise resolving to the latest chain entry\n\t *\n\t * @example\n\t * ```ts\n\t * const { entry } = await sdk.chain.getTip()\n\t * console.log('Current height:', entry.height)\n\t * ```\n\t */\n\tasync getTip(): Promise<GetTipResponse> {\n\t\treturn this.client.get<GetTipResponse>('/api/chain/tip')\n\t}\n\n\t/**\n\t * Get chain statistics\n\t *\n\t * @returns Promise resolving to chain statistics\n\t *\n\t * @example\n\t * ```ts\n\t * const { stats } = await sdk.chain.getStats()\n\t * console.log('Total entries:', stats.total_entries)\n\t * ```\n\t */\n\tasync getStats(): Promise<GetStatsResponse> {\n\t\treturn this.client.get<GetStatsResponse>('/api/chain/stats')\n\t}\n\n\t/**\n\t * Get entry by hash\n\t *\n\t * @param hash - Entry hash (Base58 encoded)\n\t * @param filterOnFunction - Optional function filter\n\t * @returns Promise resolving to chain entry\n\t * @throws {Error} If hash is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const { entry } = await sdk.chain.getByHash('5Kd3N...')\n\t * ```\n\t */\n\tasync getByHash(hash: string, filterOnFunction?: string): Promise<GetByHashResponse> {\n\t\tvalidate(Base58HashSchema, hash)\n\t\treturn this.client.get<GetByHashResponse>(`/api/chain/hash/${hash}`, {\n\t\t\tfilter_on_function: filterOnFunction\n\t\t})\n\t}\n\n\t/**\n\t * Get entries by height\n\t *\n\t * @param height - Block height (must be >= 0)\n\t * @returns Promise resolving to chain entries at the specified height\n\t * @throws {Error} If height is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const { entries } = await sdk.chain.getByHeight(1000)\n\t * ```\n\t */\n\tasync getByHeight(height: number): Promise<GetByHeightResponse> {\n\t\tvalidate(Schema.NonNegativeInt, height)\n\t\treturn this.client.get<GetByHeightResponse>(`/api/chain/height/${height}`)\n\t}\n\n\t/**\n\t * Get entries by height with transactions\n\t *\n\t * @param height - Block height (must be >= 0)\n\t * @returns Promise resolving to chain entries with transactions at the specified height\n\t * @throws {Error} If height is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const { entries } = await sdk.chain.getByHeightWithTxs(1000)\n\t * ```\n\t */\n\tasync getByHeightWithTxs(height: number): Promise<GetByHeightResponse> {\n\t\tvalidate(Schema.NonNegativeInt, height)\n\t\treturn this.client.get<GetByHeightResponse>(`/api/chain/height_with_txs/${height}`)\n\t}\n\n\t/**\n\t * Get a specific transaction by ID\n\t *\n\t * @param txid - Transaction ID (Base58 encoded)\n\t * @returns Promise resolving to transaction data\n\t * @throws {Error} If transaction ID is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const tx = await sdk.chain.getTransaction('5Kd3N...')\n\t * ```\n\t */\n\tasync getTransaction(txid: string): Promise<Transaction> {\n\t\tvalidate(Base58HashSchema, txid)\n\t\treturn this.client.get<Transaction>(`/api/chain/tx/${txid}`)\n\t}\n\n\t/**\n\t * Get transactions in a specific entry\n\t *\n\t * @param entryHash - Entry hash (Base58 encoded)\n\t * @returns Promise resolving to transactions in the entry\n\t * @throws {Error} If entry hash is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const { txs } = await sdk.chain.getTransactionsInEntry('5Kd3N...')\n\t * ```\n\t */\n\tasync getTransactionsInEntry(entryHash: string): Promise<GetTransactionsInEntryResponse> {\n\t\tvalidate(Base58HashSchema, entryHash)\n\t\treturn this.client.get<GetTransactionsInEntryResponse>(\n\t\t\t`/api/chain/txs_in_entry/${entryHash}`\n\t\t)\n\t}\n\n\t/**\n\t * Get transaction events by account with filtering\n\t *\n\t * @param account - Account address (Base58 encoded)\n\t * @param filters - Optional filters for transactions\n\t * @returns Promise resolving to transaction events\n\t * @throws {Error} If account address is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const { txs, cursor } = await sdk.chain.getTransactionEventsByAccount('5Kd3N...', {\n\t * limit: 10,\n\t * sort: 'desc'\n\t * })\n\t * ```\n\t */\n\tasync getTransactionEventsByAccount(\n\t\taccount: string,\n\t\tfilters: TransactionFilters = {}\n\t): Promise<GetTransactionEventsByAccountResponse> {\n\t\tvalidate(Base58HashSchema, account)\n\t\tvalidate(TransactionFiltersSchema, filters)\n\n\t\treturn this.client.get<GetTransactionEventsByAccountResponse>(\n\t\t\t`/api/chain/tx_events_by_account/${account}`,\n\t\t\tfilters as Record<string, unknown>\n\t\t)\n\t}\n\n\t/**\n\t * Query transactions by arbitrary filter (signer, receiver, contract, function).\n\t *\n\t * All filter fields are optional; provide only the ones you want to constrain.\n\t * Returns a cursor for pagination — pass it back as `cursor` in a subsequent call.\n\t *\n\t * @example\n\t * ```ts\n\t * const { txs, cursor } = await sdk.chain.getByFilter({\n\t * signer: '5Kd3N...',\n\t * contract: 'Coin',\n\t * function: 'transfer',\n\t * limit: 50,\n\t * sort: 'desc'\n\t * })\n\t * ```\n\t */\n\tasync getByFilter(filters: TxByFilterParams = {}): Promise<TxByFilterResponse> {\n\t\treturn this.client.get<TxByFilterResponse>(\n\t\t\t'/api/chain/tx_by_filter',\n\t\t\tfilters as Record<string, unknown>\n\t\t)\n\t}\n\n\t/**\n\t * Get protocol-level KPIs (burned, fees, active validators/peers, total tx, UAW, etc.).\n\t *\n\t * @example\n\t * ```ts\n\t * const { kpi } = await sdk.chain.getKpi()\n\t * console.log('Total tx:', kpi.total_tx)\n\t * ```\n\t */\n\tasync getKpi(): Promise<GetKpiResponse> {\n\t\treturn this.client.get<GetKpiResponse>('/api/chain/kpi')\n\t}\n}\n"],"mappings":";;;;AAwBA,IAAa,WAAb,MAAsB;CACD;CAApB,YAAY,QAA+B;EAAvB,KAAA,SAAA;;;;;;;;;;;;;CAapB,MAAM,SAAkC;EACvC,OAAO,KAAK,OAAO,IAAoB,iBAAiB;;;;;;;;;;;;;CAczD,MAAM,WAAsC;EAC3C,OAAO,KAAK,OAAO,IAAsB,mBAAmB;;;;;;;;;;;;;;;CAgB7D,MAAM,UAAU,MAAc,kBAAuD;EACpF,SAAS,kBAAkB,KAAK;EAChC,OAAO,KAAK,OAAO,IAAuB,mBAAmB,QAAQ,EACpE,oBAAoB,kBACpB,CAAC;;;;;;;;;;;;;;CAeH,MAAM,YAAY,QAA8C;EAC/D,SAAS,OAAO,gBAAgB,OAAO;EACvC,OAAO,KAAK,OAAO,IAAyB,qBAAqB,SAAS;;;;;;;;;;;;;;CAe3E,MAAM,mBAAmB,QAA8C;EACtE,SAAS,OAAO,gBAAgB,OAAO;EACvC,OAAO,KAAK,OAAO,IAAyB,8BAA8B,SAAS;;;;;;;;;;;;;;CAepF,MAAM,eAAe,MAAoC;EACxD,SAAS,kBAAkB,KAAK;EAChC,OAAO,KAAK,OAAO,IAAiB,iBAAiB,OAAO;;;;;;;;;;;;;;CAe7D,MAAM,uBAAuB,WAA4D;EACxF,SAAS,kBAAkB,UAAU;EACrC,OAAO,KAAK,OAAO,IAClB,2BAA2B,YAC3B;;;;;;;;;;;;;;;;;;CAmBF,MAAM,8BACL,SACA,UAA8B,EAAE,EACiB;EACjD,SAAS,kBAAkB,QAAQ;EACnC,SAAS,0BAA0B,QAAQ;EAE3C,OAAO,KAAK,OAAO,IAClB,mCAAmC,WACnC,QACA;;;;;;;;;;;;;;;;;;;CAoBF,MAAM,YAAY,UAA4B,EAAE,EAA+B;EAC9E,OAAO,KAAK,OAAO,IAClB,2BACA,QACA;;;;;;;;;;;CAYF,MAAM,SAAkC;EACvC,OAAO,KAAK,OAAO,IAAoB,iBAAiB"}
|