@amadeus-protocol/sdk 1.0.8 → 1.1.1
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 +215 -30
- 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/contract.js
CHANGED
|
@@ -1,76 +1,103 @@
|
|
|
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
|
-
|
|
1
|
+
import { encode } from "../serialization.js";
|
|
2
|
+
import { validate } from "../validation.js";
|
|
3
|
+
import { BytecodeSchema, ContractKeySchema } from "../schemas.js";
|
|
4
|
+
//#region src/api/contract.ts
|
|
5
|
+
var ContractAPI = class {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validate contract bytecode
|
|
12
|
+
*
|
|
13
|
+
* @param bytecode - Contract bytecode as Uint8Array or ArrayBuffer
|
|
14
|
+
* @returns Promise resolving to validation result
|
|
15
|
+
* @throws {AmadeusSDKError} If bytecode is invalid or empty
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const result = await sdk.contract.validateBytecode(wasmBytecode)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
async validateBytecode(bytecode) {
|
|
23
|
+
validate(BytecodeSchema, bytecode);
|
|
24
|
+
const body = bytecode instanceof ArrayBuffer ? new Uint8Array(bytecode) : bytecode;
|
|
25
|
+
return this.client.post("/api/contract/validate_bytecode", body);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get contract data by key
|
|
29
|
+
*
|
|
30
|
+
* @param key - Contract key as Uint8Array or Base58 string
|
|
31
|
+
* @returns Promise resolving to contract data value (JSON-serializable)
|
|
32
|
+
* @throws {AmadeusSDKError} If key is invalid
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const data = await sdk.contract.get(keyBytes)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
async get(key) {
|
|
40
|
+
validate(ContractKeySchema, key);
|
|
41
|
+
return this.client.post("/api/contract/get", key);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get contract data by key prefix
|
|
45
|
+
*
|
|
46
|
+
* @param key - Contract key prefix as Uint8Array or Base58 string
|
|
47
|
+
* @returns Promise resolving to contract data matching the prefix (array of key-value pairs)
|
|
48
|
+
* @throws {AmadeusSDKError} If key is invalid
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const data = await sdk.contract.getPrefix(keyPrefix)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
async getPrefix(key) {
|
|
56
|
+
validate(ContractKeySchema, key);
|
|
57
|
+
return this.client.post("/api/contract/get_prefix", key);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get contract richlist (token holders)
|
|
61
|
+
*
|
|
62
|
+
* @returns Promise resolving to richlist entries
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const { richlist } = await sdk.contract.getRichlist()
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
async getRichlist() {
|
|
70
|
+
return this.client.get("/api/contract/richlist");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Execute a contract function in read-only (view) mode against the current chain tip.
|
|
74
|
+
*
|
|
75
|
+
* No transaction is created and no state is mutated. Useful for querying contract
|
|
76
|
+
* state through the contract's own logic (e.g. computed balances, vault status).
|
|
77
|
+
*
|
|
78
|
+
* @param params - Contract, function, args, and optional caller pk
|
|
79
|
+
* @returns Promise resolving to `{ success, result, logs }`
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const { success, result } = await sdk.contract.view({
|
|
84
|
+
* contract: 'LockupPrime',
|
|
85
|
+
* function: 'view_balance',
|
|
86
|
+
* args: ['my_vault']
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
async view(params) {
|
|
91
|
+
const body = {
|
|
92
|
+
contract: params.contract,
|
|
93
|
+
function: params.function,
|
|
94
|
+
args: params.args ?? []
|
|
95
|
+
};
|
|
96
|
+
if (params.pk) body.pk = params.pk;
|
|
97
|
+
return this.client.post("/api/contract/view", encode(body));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { ContractAPI };
|
|
102
|
+
|
|
76
103
|
//# sourceMappingURL=contract.js.map
|
package/dist/api/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","
|
|
1
|
+
{"version":3,"file":"contract.js","names":[],"sources":["../../src/api/contract.ts"],"sourcesContent":["/**\n * Contract API\n *\n * Provides methods for interacting with smart contracts\n */\n\nimport type { AmadeusClient } from '../client'\nimport type {\n\tValidateBytecodeResponse,\n\tGetRichlistResponse,\n\tContractDataValue,\n\tContractViewParams,\n\tContractViewResponse,\n\tSerializableValue\n} from '../types'\nimport { BytecodeSchema, ContractKeySchema } from '../schemas'\nimport { validate } from '../validation'\nimport { encode } from '../serialization'\n\nexport class ContractAPI {\n\tconstructor(private client: AmadeusClient) {}\n\n\t/**\n\t * Validate contract bytecode\n\t *\n\t * @param bytecode - Contract bytecode as Uint8Array or ArrayBuffer\n\t * @returns Promise resolving to validation result\n\t * @throws {AmadeusSDKError} If bytecode is invalid or empty\n\t *\n\t * @example\n\t * ```ts\n\t * const result = await sdk.contract.validateBytecode(wasmBytecode)\n\t * ```\n\t */\n\tasync validateBytecode(bytecode: Uint8Array | ArrayBuffer): Promise<ValidateBytecodeResponse> {\n\t\tvalidate(BytecodeSchema, bytecode)\n\t\tconst body = bytecode instanceof ArrayBuffer ? new Uint8Array(bytecode) : bytecode\n\t\treturn this.client.post<ValidateBytecodeResponse>('/api/contract/validate_bytecode', body)\n\t}\n\n\t/**\n\t * Get contract data by key\n\t *\n\t * @param key - Contract key as Uint8Array or Base58 string\n\t * @returns Promise resolving to contract data value (JSON-serializable)\n\t * @throws {AmadeusSDKError} If key is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const data = await sdk.contract.get(keyBytes)\n\t * ```\n\t */\n\tasync get(key: Uint8Array | string): Promise<ContractDataValue> {\n\t\tvalidate(ContractKeySchema, key)\n\t\treturn this.client.post<ContractDataValue>('/api/contract/get', key)\n\t}\n\n\t/**\n\t * Get contract data by key prefix\n\t *\n\t * @param key - Contract key prefix as Uint8Array or Base58 string\n\t * @returns Promise resolving to contract data matching the prefix (array of key-value pairs)\n\t * @throws {AmadeusSDKError} If key is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const data = await sdk.contract.getPrefix(keyPrefix)\n\t * ```\n\t */\n\tasync getPrefix(key: Uint8Array | string): Promise<ContractDataValue[]> {\n\t\tvalidate(ContractKeySchema, key)\n\t\treturn this.client.post<ContractDataValue[]>('/api/contract/get_prefix', key)\n\t}\n\n\t/**\n\t * Get contract richlist (token holders)\n\t *\n\t * @returns Promise resolving to richlist entries\n\t *\n\t * @example\n\t * ```ts\n\t * const { richlist } = await sdk.contract.getRichlist()\n\t * ```\n\t */\n\tasync getRichlist(): Promise<GetRichlistResponse> {\n\t\treturn this.client.get<GetRichlistResponse>('/api/contract/richlist')\n\t}\n\n\t/**\n\t * Execute a contract function in read-only (view) mode against the current chain tip.\n\t *\n\t * No transaction is created and no state is mutated. Useful for querying contract\n\t * state through the contract's own logic (e.g. computed balances, vault status).\n\t *\n\t * @param params - Contract, function, args, and optional caller pk\n\t * @returns Promise resolving to `{ success, result, logs }`\n\t *\n\t * @example\n\t * ```ts\n\t * const { success, result } = await sdk.contract.view({\n\t * contract: 'LockupPrime',\n\t * function: 'view_balance',\n\t * args: ['my_vault']\n\t * })\n\t * ```\n\t */\n\tasync view(params: ContractViewParams): Promise<ContractViewResponse> {\n\t\tconst body: Record<string, SerializableValue> = {\n\t\t\tcontract: params.contract,\n\t\t\tfunction: params.function,\n\t\t\targs: params.args ?? []\n\t\t}\n\t\tif (params.pk) body.pk = params.pk\n\t\treturn this.client.post<ContractViewResponse>('/api/contract/view', encode(body))\n\t}\n}\n"],"mappings":";;;;AAmBA,IAAa,cAAb,MAAyB;CACJ;CAApB,YAAY,QAA+B;EAAvB,KAAA,SAAA;;;;;;;;;;;;;;CAcpB,MAAM,iBAAiB,UAAuE;EAC7F,SAAS,gBAAgB,SAAS;EAClC,MAAM,OAAO,oBAAoB,cAAc,IAAI,WAAW,SAAS,GAAG;EAC1E,OAAO,KAAK,OAAO,KAA+B,mCAAmC,KAAK;;;;;;;;;;;;;;CAe3F,MAAM,IAAI,KAAsD;EAC/D,SAAS,mBAAmB,IAAI;EAChC,OAAO,KAAK,OAAO,KAAwB,qBAAqB,IAAI;;;;;;;;;;;;;;CAerE,MAAM,UAAU,KAAwD;EACvE,SAAS,mBAAmB,IAAI;EAChC,OAAO,KAAK,OAAO,KAA0B,4BAA4B,IAAI;;;;;;;;;;;;CAa9E,MAAM,cAA4C;EACjD,OAAO,KAAK,OAAO,IAAyB,yBAAyB;;;;;;;;;;;;;;;;;;;;CAqBtE,MAAM,KAAK,QAA2D;EACrE,MAAM,OAA0C;GAC/C,UAAU,OAAO;GACjB,UAAU,OAAO;GACjB,MAAM,OAAO,QAAQ,EAAE;GACvB;EACD,IAAI,OAAO,IAAI,KAAK,KAAK,OAAO;EAChC,OAAO,KAAK,OAAO,KAA2B,sBAAsB,OAAO,KAAK,CAAC"}
|
package/dist/api/epoch.d.ts
CHANGED
|
@@ -1,68 +1,67 @@
|
|
|
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
|
-
* Get top validators by score
|
|
65
|
-
*/
|
|
66
|
-
getTopValidators(limit?: number): Promise<[string, number][]>;
|
|
1
|
+
import { EpochScore, GetEmissionAddressResponse, GetSolInEpochResponse } from "../types.js";
|
|
2
|
+
import { AmadeusClient } from "../client.js";
|
|
3
|
+
|
|
4
|
+
//#region src/api/epoch.d.ts
|
|
5
|
+
declare class EpochAPI {
|
|
6
|
+
private client;
|
|
7
|
+
constructor(client: AmadeusClient);
|
|
8
|
+
/**
|
|
9
|
+
* Get epoch score for all validators or a specific validator
|
|
10
|
+
*
|
|
11
|
+
* @param publicKey - Optional validator public key (Base58 encoded)
|
|
12
|
+
* @returns Promise resolving to epoch score(s)
|
|
13
|
+
* @throws {Error} If public key is invalid
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // Get all scores
|
|
18
|
+
* const scores = await sdk.epoch.getScore()
|
|
19
|
+
*
|
|
20
|
+
* // Get specific validator score
|
|
21
|
+
* const score = await sdk.epoch.getScore('5Kd3N...')
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
getScore(publicKey?: string): Promise<EpochScore>;
|
|
25
|
+
/**
|
|
26
|
+
* Get emission address for a public key
|
|
27
|
+
*
|
|
28
|
+
* @param publicKey - Validator public key (Base58 encoded)
|
|
29
|
+
* @returns Promise resolving to emission address
|
|
30
|
+
* @throws {Error} If public key is invalid
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const { emission_address } = await sdk.epoch.getEmissionAddress('5Kd3N...')
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
getEmissionAddress(publicKey: string): Promise<GetEmissionAddressResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Get solution in epoch
|
|
40
|
+
*
|
|
41
|
+
* @param epoch - Epoch number (must be >= 0)
|
|
42
|
+
* @param solHash - Solution hash as string or Uint8Array
|
|
43
|
+
* @returns Promise resolving to solution data
|
|
44
|
+
* @throws {Error} If parameters are invalid
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const sol = await sdk.epoch.getSolInEpoch(100, '5Kd3N...')
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
getSolInEpoch(epoch: number, solHash: string | Uint8Array): Promise<GetSolInEpochResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Get all epoch scores as array of [pk, score] tuples
|
|
54
|
+
*/
|
|
55
|
+
getAllScores(): Promise<[string, number][]>;
|
|
56
|
+
/**
|
|
57
|
+
* Get epoch score for a specific validator
|
|
58
|
+
*/
|
|
59
|
+
getValidatorScore(publicKey: string): Promise<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Get top validators by score
|
|
62
|
+
*/
|
|
63
|
+
getTopValidators(limit?: number): Promise<[string, number][]>;
|
|
67
64
|
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { EpochAPI };
|
|
68
67
|
//# sourceMappingURL=epoch.d.ts.map
|
package/dist/api/epoch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch.d.ts","
|
|
1
|
+
{"version":3,"file":"epoch.d.ts","names":[],"sources":["../../src/api/epoch.ts"],"mappings":";;;;cAYa,QAAA;EAAA,QACQ,MAAA;cAAA,MAAA,EAAQ,aAAA;EAsCyB;;;;;;;;;;;;;;;;EApB/C,QAAA,CAAS,SAAA,YAAqB,OAAA,CAAQ,UAAA;EAAA;;;;;;;;;;;;EAoBtC,kBAAA,CAAmB,SAAA,WAAoB,OAAA,CAAQ,0BAAA;EA6C/C;;;;;;;;;;;;;EAzBA,aAAA,CACL,KAAA,UACA,OAAA,WAAkB,UAAA,GAChB,OAAA,CAAQ,qBAAA;;;;EAcL,YAAA,CAAA,GAAgB,OAAA;;;;EAQhB,iBAAA,CAAkB,SAAA,WAAoB,OAAA;;;;EAWtC,gBAAA,CAAiB,KAAA,YAAqB,OAAA;AAAA"}
|
package/dist/api/epoch.js
CHANGED
|
@@ -1,99 +1,91 @@
|
|
|
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
|
-
* Get top validators by score
|
|
93
|
-
*/
|
|
94
|
-
async getTopValidators(limit = 10) {
|
|
95
|
-
const scores = await this.getAllScores();
|
|
96
|
-
return scores.sort((a, b) => b[1] - a[1]).slice(0, limit);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
1
|
+
import { validate } from "../validation.js";
|
|
2
|
+
import { Base58PublicKeySchema } from "../schemas.js";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
//#region src/api/epoch.ts
|
|
5
|
+
var EpochAPI = class {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get epoch score for all validators or a specific validator
|
|
12
|
+
*
|
|
13
|
+
* @param publicKey - Optional validator public key (Base58 encoded)
|
|
14
|
+
* @returns Promise resolving to epoch score(s)
|
|
15
|
+
* @throws {Error} If public key is invalid
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Get all scores
|
|
20
|
+
* const scores = await sdk.epoch.getScore()
|
|
21
|
+
*
|
|
22
|
+
* // Get specific validator score
|
|
23
|
+
* const score = await sdk.epoch.getScore('5Kd3N...')
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
async getScore(publicKey) {
|
|
27
|
+
if (publicKey) validate(Base58PublicKeySchema, publicKey);
|
|
28
|
+
const url = publicKey ? `/api/epoch/score/${publicKey}` : "/api/epoch/score";
|
|
29
|
+
return this.client.get(url);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get emission address for a public key
|
|
33
|
+
*
|
|
34
|
+
* @param publicKey - Validator public key (Base58 encoded)
|
|
35
|
+
* @returns Promise resolving to emission address
|
|
36
|
+
* @throws {Error} If public key is invalid
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const { emission_address } = await sdk.epoch.getEmissionAddress('5Kd3N...')
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
async getEmissionAddress(publicKey) {
|
|
44
|
+
validate(Base58PublicKeySchema, publicKey);
|
|
45
|
+
return this.client.get(`/api/epoch/get_emission_address/${publicKey}`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get solution in epoch
|
|
49
|
+
*
|
|
50
|
+
* @param epoch - Epoch number (must be >= 0)
|
|
51
|
+
* @param solHash - Solution hash as string or Uint8Array
|
|
52
|
+
* @returns Promise resolving to solution data
|
|
53
|
+
* @throws {Error} If parameters are invalid
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const sol = await sdk.epoch.getSolInEpoch(100, '5Kd3N...')
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
async getSolInEpoch(epoch, solHash) {
|
|
61
|
+
validate(Schema.NonNegativeInt, epoch);
|
|
62
|
+
if (!solHash) throw new Error("Solution hash is required");
|
|
63
|
+
const hash = typeof solHash === "string" ? solHash : solHash.toString();
|
|
64
|
+
return this.client.get(`/api/epoch/sol_in_epoch/${epoch}/${hash}`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get all epoch scores as array of [pk, score] tuples
|
|
68
|
+
*/
|
|
69
|
+
async getAllScores() {
|
|
70
|
+
const result = await this.getScore();
|
|
71
|
+
return Array.isArray(result) ? result : [];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get epoch score for a specific validator
|
|
75
|
+
*/
|
|
76
|
+
async getValidatorScore(publicKey) {
|
|
77
|
+
const result = await this.getScore(publicKey);
|
|
78
|
+
if (Array.isArray(result)) throw new Error("Unexpected array response for single validator score");
|
|
79
|
+
return result.score;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get top validators by score
|
|
83
|
+
*/
|
|
84
|
+
async getTopValidators(limit = 10) {
|
|
85
|
+
return (await this.getAllScores()).sort((a, b) => b[1] - a[1]).slice(0, limit);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { EpochAPI };
|
|
90
|
+
|
|
99
91
|
//# sourceMappingURL=epoch.js.map
|
package/dist/api/epoch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch.js","
|
|
1
|
+
{"version":3,"file":"epoch.js","names":[],"sources":["../../src/api/epoch.ts"],"sourcesContent":["/**\n * Epoch API\n *\n * Provides methods for querying epoch and validator information\n */\n\nimport type { AmadeusClient } from '../client'\nimport type { EpochScore, GetEmissionAddressResponse, GetSolInEpochResponse } from '../types'\nimport { Base58PublicKeySchema } from '../schemas'\nimport { Schema } from 'effect'\nimport { validate } from '../validation'\n\nexport class EpochAPI {\n\tconstructor(private client: AmadeusClient) {}\n\n\t/**\n\t * Get epoch score for all validators or a specific validator\n\t *\n\t * @param publicKey - Optional validator public key (Base58 encoded)\n\t * @returns Promise resolving to epoch score(s)\n\t * @throws {Error} If public key is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * // Get all scores\n\t * const scores = await sdk.epoch.getScore()\n\t *\n\t * // Get specific validator score\n\t * const score = await sdk.epoch.getScore('5Kd3N...')\n\t * ```\n\t */\n\tasync getScore(publicKey?: string): Promise<EpochScore> {\n\t\tif (publicKey) {\n\t\t\tvalidate(Base58PublicKeySchema, publicKey)\n\t\t}\n\t\tconst url = publicKey ? `/api/epoch/score/${publicKey}` : '/api/epoch/score'\n\t\treturn this.client.get<EpochScore>(url)\n\t}\n\n\t/**\n\t * Get emission address for a public key\n\t *\n\t * @param publicKey - Validator public key (Base58 encoded)\n\t * @returns Promise resolving to emission address\n\t * @throws {Error} If public key is invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const { emission_address } = await sdk.epoch.getEmissionAddress('5Kd3N...')\n\t * ```\n\t */\n\tasync getEmissionAddress(publicKey: string): Promise<GetEmissionAddressResponse> {\n\t\tvalidate(Base58PublicKeySchema, publicKey)\n\t\treturn this.client.get<GetEmissionAddressResponse>(\n\t\t\t`/api/epoch/get_emission_address/${publicKey}`\n\t\t)\n\t}\n\n\t/**\n\t * Get solution in epoch\n\t *\n\t * @param epoch - Epoch number (must be >= 0)\n\t * @param solHash - Solution hash as string or Uint8Array\n\t * @returns Promise resolving to solution data\n\t * @throws {Error} If parameters are invalid\n\t *\n\t * @example\n\t * ```ts\n\t * const sol = await sdk.epoch.getSolInEpoch(100, '5Kd3N...')\n\t * ```\n\t */\n\tasync getSolInEpoch(\n\t\tepoch: number,\n\t\tsolHash: string | Uint8Array\n\t): Promise<GetSolInEpochResponse> {\n\t\tvalidate(Schema.NonNegativeInt, epoch)\n\n\t\tif (!solHash) {\n\t\t\tthrow new Error('Solution hash is required')\n\t\t}\n\n\t\tconst hash = typeof solHash === 'string' ? solHash : solHash.toString()\n\t\treturn this.client.get<GetSolInEpochResponse>(`/api/epoch/sol_in_epoch/${epoch}/${hash}`)\n\t}\n\n\t/**\n\t * Get all epoch scores as array of [pk, score] tuples\n\t */\n\tasync getAllScores(): Promise<[string, number][]> {\n\t\tconst result = await this.getScore()\n\t\treturn Array.isArray(result) ? result : []\n\t}\n\n\t/**\n\t * Get epoch score for a specific validator\n\t */\n\tasync getValidatorScore(publicKey: string): Promise<number> {\n\t\tconst result = await this.getScore(publicKey)\n\t\tif (Array.isArray(result)) {\n\t\t\tthrow new Error('Unexpected array response for single validator score')\n\t\t}\n\t\treturn result.score\n\t}\n\n\t/**\n\t * Get top validators by score\n\t */\n\tasync getTopValidators(limit: number = 10): Promise<[string, number][]> {\n\t\tconst scores = await this.getAllScores()\n\t\treturn scores.sort((a, b) => b[1] - a[1]).slice(0, limit)\n\t}\n}\n"],"mappings":";;;;AAYA,IAAa,WAAb,MAAsB;CACD;CAApB,YAAY,QAA+B;EAAvB,KAAA,SAAA;;;;;;;;;;;;;;;;;;CAkBpB,MAAM,SAAS,WAAyC;EACvD,IAAI,WACH,SAAS,uBAAuB,UAAU;EAE3C,MAAM,MAAM,YAAY,oBAAoB,cAAc;EAC1D,OAAO,KAAK,OAAO,IAAgB,IAAI;;;;;;;;;;;;;;CAexC,MAAM,mBAAmB,WAAwD;EAChF,SAAS,uBAAuB,UAAU;EAC1C,OAAO,KAAK,OAAO,IAClB,mCAAmC,YACnC;;;;;;;;;;;;;;;CAgBF,MAAM,cACL,OACA,SACiC;EACjC,SAAS,OAAO,gBAAgB,MAAM;EAEtC,IAAI,CAAC,SACJ,MAAM,IAAI,MAAM,4BAA4B;EAG7C,MAAM,OAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,UAAU;EACvE,OAAO,KAAK,OAAO,IAA2B,2BAA2B,MAAM,GAAG,OAAO;;;;;CAM1F,MAAM,eAA4C;EACjD,MAAM,SAAS,MAAM,KAAK,UAAU;EACpC,OAAO,MAAM,QAAQ,OAAO,GAAG,SAAS,EAAE;;;;;CAM3C,MAAM,kBAAkB,WAAoC;EAC3D,MAAM,SAAS,MAAM,KAAK,SAAS,UAAU;EAC7C,IAAI,MAAM,QAAQ,OAAO,EACxB,MAAM,IAAI,MAAM,uDAAuD;EAExE,OAAO,OAAO;;;;;CAMf,MAAM,iBAAiB,QAAgB,IAAiC;EAEvE,QAAO,MADc,KAAK,cAAc,EAC1B,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM"}
|