@primuslabs/fhetransform-sdk 0.4.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 +198 -0
- package/dist/abis/acl.abi.d.ts +379 -0
- package/dist/abis/acl.abi.js +495 -0
- package/dist/abis/acl.abi.js.map +1 -0
- package/dist/abis/alphatrion_reward.abi.d.ts +407 -0
- package/dist/abis/alphatrion_reward.abi.js +532 -0
- package/dist/abis/alphatrion_reward.abi.js.map +1 -0
- package/dist/abis/ciphertext_digests.abi.d.ts +336 -0
- package/dist/abis/ciphertext_digests.abi.js +444 -0
- package/dist/abis/ciphertext_digests.abi.js.map +1 -0
- package/dist/abis/ciphertext_verification.abi.d.ts +637 -0
- package/dist/abis/ciphertext_verification.abi.js +830 -0
- package/dist/abis/ciphertext_verification.abi.js.map +1 -0
- package/dist/abis/convert_token.abi.d.ts +922 -0
- package/dist/abis/convert_token.abi.js +1208 -0
- package/dist/abis/convert_token.abi.js.map +1 -0
- package/dist/abis/decryption.abi.d.ts +956 -0
- package/dist/abis/decryption.abi.js +1244 -0
- package/dist/abis/decryption.abi.js.map +1 -0
- package/dist/abis/erc20.abi.d.ts +265 -0
- package/dist/abis/erc20.abi.js +350 -0
- package/dist/abis/erc20.abi.js.map +1 -0
- package/dist/abis/fhe_executor.abi.d.ts +1535 -0
- package/dist/abis/fhe_executor.abi.js +1962 -0
- package/dist/abis/fhe_executor.abi.js.map +1 -0
- package/dist/abis/space_bridge_config.abi.d.ts +792 -0
- package/dist/abis/space_bridge_config.abi.js +1032 -0
- package/dist/abis/space_bridge_config.abi.js.map +1 -0
- package/dist/abis/token.abi.d.ts +630 -0
- package/dist/abis/token.abi.js +828 -0
- package/dist/abis/token.abi.js.map +1 -0
- package/dist/cli/eusdc.d.ts +2 -0
- package/dist/cli/eusdc.js +41 -0
- package/dist/cli/eusdc.js.map +1 -0
- package/dist/contract/callbacks.d.ts +59 -0
- package/dist/contract/callbacks.js +2 -0
- package/dist/contract/callbacks.js.map +1 -0
- package/dist/contract/convert-token.d.ts +107 -0
- package/dist/contract/convert-token.js +249 -0
- package/dist/contract/convert-token.js.map +1 -0
- package/dist/contract/token.d.ts +167 -0
- package/dist/contract/token.js +404 -0
- package/dist/contract/token.js.map +1 -0
- package/dist/contract/transaction.d.ts +29 -0
- package/dist/contract/transaction.js +2 -0
- package/dist/contract/transaction.js.map +1 -0
- package/dist/core/address.d.ts +118 -0
- package/dist/core/address.js +200 -0
- package/dist/core/address.js.map +1 -0
- package/dist/core/auth.d.ts +68 -0
- package/dist/core/auth.js +58 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/bytes.d.ts +48 -0
- package/dist/core/bytes.js +117 -0
- package/dist/core/bytes.js.map +1 -0
- package/dist/core/cache-manager.d.ts +138 -0
- package/dist/core/cache-manager.js +440 -0
- package/dist/core/cache-manager.js.map +1 -0
- package/dist/core/chain.d.ts +41 -0
- package/dist/core/chain.js +59 -0
- package/dist/core/chain.js.map +1 -0
- package/dist/core/constants.d.ts +24 -0
- package/dist/core/constants.js +25 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/error.d.ts +2 -0
- package/dist/core/error.js +14 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/errors/error-catalog.d.ts +29 -0
- package/dist/core/errors/error-catalog.js +84 -0
- package/dist/core/errors/error-catalog.js.map +1 -0
- package/dist/core/errors/error-codes.d.ts +52 -0
- package/dist/core/errors/error-codes.js +61 -0
- package/dist/core/errors/error-codes.js.map +1 -0
- package/dist/core/errors/error-utils.d.ts +27 -0
- package/dist/core/errors/error-utils.js +110 -0
- package/dist/core/errors/error-utils.js.map +1 -0
- package/dist/core/errors/fhe-error.d.ts +98 -0
- package/dist/core/errors/fhe-error.js +190 -0
- package/dist/core/errors/fhe-error.js.map +1 -0
- package/dist/core/errors/index.d.ts +4 -0
- package/dist/core/errors/index.js +5 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/estimate.d.ts +39 -0
- package/dist/core/estimate.js +111 -0
- package/dist/core/estimate.js.map +1 -0
- package/dist/core/event.d.ts +212 -0
- package/dist/core/event.js +42 -0
- package/dist/core/event.js.map +1 -0
- package/dist/core/fhe-type.d.ts +75 -0
- package/dist/core/fhe-type.js +115 -0
- package/dist/core/fhe-type.js.map +1 -0
- package/dist/core/fhe.d.ts +11 -0
- package/dist/core/fhe.js +23 -0
- package/dist/core/fhe.js.map +1 -0
- package/dist/core/handle.d.ts +42 -0
- package/dist/core/handle.js +99 -0
- package/dist/core/handle.js.map +1 -0
- package/dist/core/json-utils.d.ts +18 -0
- package/dist/core/json-utils.js +37 -0
- package/dist/core/json-utils.js.map +1 -0
- package/dist/core/kms.d.ts +42 -0
- package/dist/core/kms.js +70 -0
- package/dist/core/kms.js.map +1 -0
- package/dist/core/logger.d.ts +3 -0
- package/dist/core/logger.js +11 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/pretty-print.d.ts +18 -0
- package/dist/core/pretty-print.js +84 -0
- package/dist/core/pretty-print.js.map +1 -0
- package/dist/core/primitives.d.ts +22 -0
- package/dist/core/primitives.js +2 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/retryable-handler.d.ts +74 -0
- package/dist/core/retryable-handler.js +227 -0
- package/dist/core/retryable-handler.js.map +1 -0
- package/dist/core/signer-address-info.d.ts +15 -0
- package/dist/core/signer-address-info.js +33 -0
- package/dist/core/signer-address-info.js.map +1 -0
- package/dist/core/string.d.ts +28 -0
- package/dist/core/string.js +33 -0
- package/dist/core/string.js.map +1 -0
- package/dist/core/swallow.d.ts +23 -0
- package/dist/core/swallow.js +37 -0
- package/dist/core/swallow.js.map +1 -0
- package/dist/core/system-contract-info.d.ts +17 -0
- package/dist/core/system-contract-info.js +41 -0
- package/dist/core/system-contract-info.js.map +1 -0
- package/dist/core/ttl-cache.d.ts +81 -0
- package/dist/core/ttl-cache.js +113 -0
- package/dist/core/ttl-cache.js.map +1 -0
- package/dist/core/tx-error-parser.d.ts +40 -0
- package/dist/core/tx-error-parser.js +83 -0
- package/dist/core/tx-error-parser.js.map +1 -0
- package/dist/core/utils.d.ts +62 -0
- package/dist/core/utils.js +143 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/jazz/encrypt-key-p.d.ts +65 -0
- package/dist/jazz/encrypt-key-p.js +283 -0
- package/dist/jazz/encrypt-key-p.js.map +1 -0
- package/dist/jazz/encrypt-p.d.ts +82 -0
- package/dist/jazz/encrypt-p.js +139 -0
- package/dist/jazz/encrypt-p.js.map +1 -0
- package/dist/jazz/encrypt.d.ts +58 -0
- package/dist/jazz/encrypt.js +155 -0
- package/dist/jazz/encrypt.js.map +1 -0
- package/dist/jazz/input-proof-p.d.ts +122 -0
- package/dist/jazz/input-proof-p.js +265 -0
- package/dist/jazz/input-proof-p.js.map +1 -0
- package/dist/jazz/jazz-client-i.d.ts +16 -0
- package/dist/jazz/jazz-client-i.js +2 -0
- package/dist/jazz/jazz-client-i.js.map +1 -0
- package/dist/jazz/jazz-client.d.ts +18 -0
- package/dist/jazz/jazz-client.js +24 -0
- package/dist/jazz/jazz-client.js.map +1 -0
- package/dist/jazz/key-pair.d.ts +50 -0
- package/dist/jazz/key-pair.js +166 -0
- package/dist/jazz/key-pair.js.map +1 -0
- package/dist/jazz/mock/fake.d.ts +3 -0
- package/dist/jazz/mock/fake.js +23 -0
- package/dist/jazz/mock/fake.js.map +1 -0
- package/dist/jazz/mock/fetch-input-proof.d.ts +4 -0
- package/dist/jazz/mock/fetch-input-proof.js +63 -0
- package/dist/jazz/mock/fetch-input-proof.js.map +1 -0
- package/dist/jazz/mock/fetch-key-url.d.ts +3 -0
- package/dist/jazz/mock/fetch-key-url.js +15 -0
- package/dist/jazz/mock/fetch-key-url.js.map +1 -0
- package/dist/jazz/mock/fetch-public-decrypt.d.ts +3 -0
- package/dist/jazz/mock/fetch-public-decrypt.js +81 -0
- package/dist/jazz/mock/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/mock/fetch-user-decrypt.d.ts +4 -0
- package/dist/jazz/mock/fetch-user-decrypt.js +174 -0
- package/dist/jazz/mock/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-input-proof.d.ts +19 -0
- package/dist/jazz/module/fetch-input-proof.js +72 -0
- package/dist/jazz/module/fetch-input-proof.js.map +1 -0
- package/dist/jazz/module/fetch-key-url.d.ts +17 -0
- package/dist/jazz/module/fetch-key-url.js +46 -0
- package/dist/jazz/module/fetch-key-url.js.map +1 -0
- package/dist/jazz/module/fetch-public-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-public-decrypt.js +65 -0
- package/dist/jazz/module/fetch-public-decrypt.js.map +1 -0
- package/dist/jazz/module/fetch-user-decrypt.d.ts +19 -0
- package/dist/jazz/module/fetch-user-decrypt.js +109 -0
- package/dist/jazz/module/fetch-user-decrypt.js.map +1 -0
- package/dist/jazz/module/jazz-async-request.d.ts +102 -0
- package/dist/jazz/module/jazz-async-request.js +515 -0
- package/dist/jazz/module/jazz-async-request.js.map +1 -0
- package/dist/jazz/module/jazz-p.d.ts +61 -0
- package/dist/jazz/module/jazz-p.js +33 -0
- package/dist/jazz/module/jazz-p.js.map +1 -0
- package/dist/jazz/module/s3-download.d.ts +85 -0
- package/dist/jazz/module/s3-download.js +293 -0
- package/dist/jazz/module/s3-download.js.map +1 -0
- package/dist/jazz/permit.d.ts +200 -0
- package/dist/jazz/permit.js +319 -0
- package/dist/jazz/permit.js.map +1 -0
- package/dist/jazz/public-decrypt-p.d.ts +96 -0
- package/dist/jazz/public-decrypt-p.js +258 -0
- package/dist/jazz/public-decrypt-p.js.map +1 -0
- package/dist/jazz/public-decrypt.d.ts +48 -0
- package/dist/jazz/public-decrypt.js +156 -0
- package/dist/jazz/public-decrypt.js.map +1 -0
- package/dist/jazz/read-contract.d.ts +81 -0
- package/dist/jazz/read-contract.js +125 -0
- package/dist/jazz/read-contract.js.map +1 -0
- package/dist/jazz/types/common.d.ts +17 -0
- package/dist/jazz/types/common.js +2 -0
- package/dist/jazz/types/common.js.map +1 -0
- package/dist/jazz/types/input-proof.d.ts +76 -0
- package/dist/jazz/types/input-proof.js +2 -0
- package/dist/jazz/types/input-proof.js.map +1 -0
- package/dist/jazz/types/key-url.d.ts +68 -0
- package/dist/jazz/types/key-url.js +5 -0
- package/dist/jazz/types/key-url.js.map +1 -0
- package/dist/jazz/types/public-decrypt.d.ts +61 -0
- package/dist/jazz/types/public-decrypt.js +2 -0
- package/dist/jazz/types/public-decrypt.js.map +1 -0
- package/dist/jazz/types/user-decrypt.d.ts +123 -0
- package/dist/jazz/types/user-decrypt.js +2 -0
- package/dist/jazz/types/user-decrypt.js.map +1 -0
- package/dist/jazz/user-decrypt-p.d.ts +111 -0
- package/dist/jazz/user-decrypt-p.js +280 -0
- package/dist/jazz/user-decrypt-p.js.map +1 -0
- package/dist/jazz/user-decrypt.d.ts +74 -0
- package/dist/jazz/user-decrypt.js +143 -0
- package/dist/jazz/user-decrypt.js.map +1 -0
- package/dist/native/fhe-api.js +5959 -0
- package/dist/native/fhe-api.node.cjs +6167 -0
- package/dist/native/fhe-api.node.worker.cjs +210 -0
- package/dist/native/fhe-api.wasm +0 -0
- package/dist/native/fhe-api.worker.js +164 -0
- package/dist/native/kms/node/kms_lib.d.ts +38 -0
- package/dist/native/kms/node/kms_lib.js +356 -0
- package/dist/native/kms/node/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/node/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/node/package.json +11 -0
- package/dist/native/kms/web/kms_lib.d.ts +84 -0
- package/dist/native/kms/web/kms_lib.js +443 -0
- package/dist/native/kms/web/kms_lib_bg.wasm +0 -0
- package/dist/native/kms/web/kms_lib_bg.wasm.d.ts +21 -0
- package/dist/native/kms/web/package.json +15 -0
- package/dist/runtime/browser.d.ts +36 -0
- package/dist/runtime/browser.js +115 -0
- package/dist/runtime/browser.js.map +1 -0
- package/dist/runtime/node.d.ts +30 -0
- package/dist/runtime/node.js +95 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/sdk/fhetransform-sdk-b.d.ts +102 -0
- package/dist/sdk/fhetransform-sdk-b.js +294 -0
- package/dist/sdk/fhetransform-sdk-b.js.map +1 -0
- package/dist/sdk/fhetransform-sdk.d.ts +87 -0
- package/dist/sdk/fhetransform-sdk.js +135 -0
- package/dist/sdk/fhetransform-sdk.js.map +1 -0
- package/dist/sdk/jazz-service.d.ts +13 -0
- package/dist/sdk/jazz-service.js +58 -0
- package/dist/sdk/jazz-service.js.map +1 -0
- package/dist/sdk/permit-service.d.ts +45 -0
- package/dist/sdk/permit-service.js +144 -0
- package/dist/sdk/permit-service.js.map +1 -0
- package/dist/wasm/fhe-wasm-client.d.ts +19 -0
- package/dist/wasm/fhe-wasm-client.js +23 -0
- package/dist/wasm/fhe-wasm-client.js.map +1 -0
- package/dist/wasm/fhe-wasm-module.d.ts +24 -0
- package/dist/wasm/fhe-wasm-module.js +141 -0
- package/dist/wasm/fhe-wasm-module.js.map +1 -0
- package/dist/wasm/fhe-wasm-type.d.ts +59 -0
- package/dist/wasm/fhe-wasm-type.js +244 -0
- package/dist/wasm/fhe-wasm-type.js.map +1 -0
- package/dist/wasm/wasm-loader.browser.d.ts +21 -0
- package/dist/wasm/wasm-loader.browser.js +143 -0
- package/dist/wasm/wasm-loader.browser.js.map +1 -0
- package/dist/wasm/wasm-loader.node.d.ts +24 -0
- package/dist/wasm/wasm-loader.node.js +114 -0
- package/dist/wasm/wasm-loader.node.js.map +1 -0
- package/dist/wasm/worker-client.browser.d.ts +6 -0
- package/dist/wasm/worker-client.browser.js +21 -0
- package/dist/wasm/worker-client.browser.js.map +1 -0
- package/dist/wasm/worker-client.d.ts +34 -0
- package/dist/wasm/worker-client.js +160 -0
- package/dist/wasm/worker-client.js.map +1 -0
- package/dist/wasm/worker-client.node.d.ts +6 -0
- package/dist/wasm/worker-client.node.js +20 -0
- package/dist/wasm/worker-client.node.js.map +1 -0
- package/dist/wasm/worker-message.d.ts +61 -0
- package/dist/wasm/worker-message.js +2 -0
- package/dist/wasm/worker-message.js.map +1 -0
- package/dist/wasm/worker-transport.browser.d.ts +15 -0
- package/dist/wasm/worker-transport.browser.js +35 -0
- package/dist/wasm/worker-transport.browser.js.map +1 -0
- package/dist/wasm/worker-transport.d.ts +6 -0
- package/dist/wasm/worker-transport.js +2 -0
- package/dist/wasm/worker-transport.js.map +1 -0
- package/dist/wasm/worker-transport.node.d.ts +17 -0
- package/dist/wasm/worker-transport.node.js +39 -0
- package/dist/wasm/worker-transport.node.js.map +1 -0
- package/dist/wasm/worker.d.ts +1 -0
- package/dist/wasm/worker.js +69 -0
- package/dist/wasm/worker.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { bytesToHex } from "./bytes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Recursively formats values for human-readable display.
|
|
4
|
+
* - Truncates long strings (>132 chars) to show head and tail with length.
|
|
5
|
+
* - Converts BigInts to strings.
|
|
6
|
+
* - Recursively processes objects.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to format
|
|
9
|
+
* @returns The formatted value
|
|
10
|
+
*/
|
|
11
|
+
export function formatValue(value) {
|
|
12
|
+
// Truncate long strings (> 132 characters)
|
|
13
|
+
if (typeof value === "string" && value.length > 132) {
|
|
14
|
+
return `${value.slice(0, 20)}...${value.slice(-20)} (${value.length})`;
|
|
15
|
+
}
|
|
16
|
+
// Convert BigInts to strings for readable output
|
|
17
|
+
if (typeof value === "bigint") {
|
|
18
|
+
return value.toString();
|
|
19
|
+
}
|
|
20
|
+
// Convert Uint8Array to hex-strings for readable output
|
|
21
|
+
if (value instanceof Uint8Array) {
|
|
22
|
+
if (value.length > 32) {
|
|
23
|
+
return bytesToHex(value.subarray(0, 32)) + `... (${value.length})`;
|
|
24
|
+
}
|
|
25
|
+
return formatValue(bytesToHex(value));
|
|
26
|
+
}
|
|
27
|
+
// Recursively format object properties
|
|
28
|
+
if (value !== null && typeof value === "object") {
|
|
29
|
+
try {
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const [key, val] of Object.entries(value)) {
|
|
32
|
+
result[key] = formatValue(val);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// If recursion fails, return the original value
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Return all other values unchanged
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Truncates a long hex string for display purposes.
|
|
46
|
+
* @param value - The value to process (strings, bigints, or other types)
|
|
47
|
+
* @returns A shortened representation if the value is a long hex string, otherwise the original value
|
|
48
|
+
*/
|
|
49
|
+
function shortHex(value) {
|
|
50
|
+
// Truncate long hex strings (> 132 characters)
|
|
51
|
+
if (typeof value === "string" && value.length > 132) {
|
|
52
|
+
return `${value.slice(0, 20)}...${value.slice(-20)} (${value.length})`;
|
|
53
|
+
}
|
|
54
|
+
// Convert bigints to strings for serialization
|
|
55
|
+
if (typeof value === "bigint") {
|
|
56
|
+
return value.toString();
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Pretty-prints data to the console with hex string truncation.
|
|
62
|
+
* - In browser environments: uses console.log with JSON formatting
|
|
63
|
+
* - In Node.js environments: uses console.dir with detailed options
|
|
64
|
+
*
|
|
65
|
+
* @param data - The data to pretty-print
|
|
66
|
+
*/
|
|
67
|
+
export function prettyPrint(data) {
|
|
68
|
+
const replacer = (_, v) => shortHex(v);
|
|
69
|
+
if (typeof window !== "undefined") {
|
|
70
|
+
// Browser environment: log as formatted JSON
|
|
71
|
+
console.log(JSON.stringify(data, replacer, 2));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Node.js environment: use console.dir for better formatting
|
|
75
|
+
const serialized = JSON.parse(JSON.stringify(data, replacer));
|
|
76
|
+
console.dir(serialized, {
|
|
77
|
+
depth: null,
|
|
78
|
+
colors: true,
|
|
79
|
+
compact: false,
|
|
80
|
+
breakLength: Infinity,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=pretty-print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-print.js","sourceRoot":"","sources":["../../src/core/pretty-print.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAU;IACpC,2CAA2C;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACpD,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;IACzE,CAAC;IAED,iDAAiD;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,wDAAwD;IACxD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACtB,OAAO,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,QAAQ,KAAK,CAAC,MAAM,GAAG,CAAC;QACrE,CAAC;QACD,OAAO,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,uCAAuC;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,MAAM,GAAQ,EAAE,CAA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CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;YACtB,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,QAAQ;SACtB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const __hex0x: unique symbol;
|
|
2
|
+
declare const __hexNo0x: unique symbol;
|
|
3
|
+
declare const __evenLen: unique symbol;
|
|
4
|
+
export type Hex0xString = {
|
|
5
|
+
readonly [__hex0x]: never;
|
|
6
|
+
};
|
|
7
|
+
export type HexNo0xString = {
|
|
8
|
+
readonly [__hexNo0x]: never;
|
|
9
|
+
};
|
|
10
|
+
export type EvenLen = {
|
|
11
|
+
readonly [__evenLen]: never;
|
|
12
|
+
};
|
|
13
|
+
export type Hex0x = `0x${string}` & Hex0xString;
|
|
14
|
+
export type HexNo0x = string & HexNo0xString;
|
|
15
|
+
export type BytesHex = Hex0x & EvenLen;
|
|
16
|
+
export type BytesHexNo0x = HexNo0x & EvenLen;
|
|
17
|
+
export type Address = BytesHex;
|
|
18
|
+
export type Bytes32Hex = BytesHex;
|
|
19
|
+
export type Bytes65Hex = BytesHex;
|
|
20
|
+
export type Bytes65HexNo0x = HexNo0x;
|
|
21
|
+
export type Bytes = Uint8Array;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/core/primitives.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface RetryableOptions {
|
|
2
|
+
retryableStatusCodes?: number[];
|
|
3
|
+
retryableErrors?: string[];
|
|
4
|
+
/**
|
|
5
|
+
* If true, user values override defaults (replace behavior)
|
|
6
|
+
* If false, user values are appended to defaults (default behavior)
|
|
7
|
+
*/
|
|
8
|
+
overrideDefaults?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class RetryableHandler {
|
|
11
|
+
protected retryableStatusCodes: number[];
|
|
12
|
+
protected retryableErrors: string[];
|
|
13
|
+
constructor(options?: RetryableOptions);
|
|
14
|
+
/**
|
|
15
|
+
* Determine if an error should trigger a retry
|
|
16
|
+
* @param err - The error object
|
|
17
|
+
* @returns True if retry should be attempted
|
|
18
|
+
*/
|
|
19
|
+
protected shouldRetry(err: any): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Enhance error with additional context information
|
|
22
|
+
* @param err - Original error
|
|
23
|
+
* @param operationName - Name of the operation
|
|
24
|
+
* @param context - Optional context data
|
|
25
|
+
* @returns Enhanced error object
|
|
26
|
+
*/
|
|
27
|
+
protected enhanceError(err: any, operationName: string, context?: any): Error;
|
|
28
|
+
}
|
|
29
|
+
export interface CountRetryOptions extends RetryableOptions {
|
|
30
|
+
maxRetries?: number;
|
|
31
|
+
initialDelayMs?: number;
|
|
32
|
+
backoffFactor?: number;
|
|
33
|
+
maxDelayMs?: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class CountRetryHandler extends RetryableHandler {
|
|
36
|
+
private maxRetries;
|
|
37
|
+
private initialDelayMs;
|
|
38
|
+
private backoffFactor;
|
|
39
|
+
private maxDelayMs;
|
|
40
|
+
constructor(options?: CountRetryOptions);
|
|
41
|
+
/**
|
|
42
|
+
* Execute operation with count-based retry logic using exponential backoff
|
|
43
|
+
* @param operation - Async operation to execute
|
|
44
|
+
* @param operationName - Name of the operation for logging
|
|
45
|
+
* @param context - Optional context data for error enhancement
|
|
46
|
+
* @returns Promise resolving to the operation result
|
|
47
|
+
*/
|
|
48
|
+
withRetry<T>(operation: () => Promise<T>, operationName: string, context?: any): Promise<T>;
|
|
49
|
+
}
|
|
50
|
+
export interface TimeoutRetryOptions extends RetryableOptions {
|
|
51
|
+
maxRetryTimeMs?: number;
|
|
52
|
+
initialIntervalMs?: number;
|
|
53
|
+
adaptiveInterval?: boolean;
|
|
54
|
+
maxIntervalMs?: number;
|
|
55
|
+
}
|
|
56
|
+
export declare class TimeoutRetryHandler extends RetryableHandler {
|
|
57
|
+
private maxRetryTimeMs;
|
|
58
|
+
private initialIntervalMs;
|
|
59
|
+
private adaptiveInterval;
|
|
60
|
+
private maxIntervalMs;
|
|
61
|
+
constructor(options?: TimeoutRetryOptions);
|
|
62
|
+
/**
|
|
63
|
+
* Execute operation with timeout-based retry logic
|
|
64
|
+
* Timeout check is performed after each failure, before scheduling the next retry.
|
|
65
|
+
* This ensures the current attempt is never interrupted.
|
|
66
|
+
*
|
|
67
|
+
* @param operation - Async operation to execute
|
|
68
|
+
* @param operationName - Name of the operation for logging
|
|
69
|
+
* @param context - Optional context data for error enhancement
|
|
70
|
+
* @param errCallback - Optional callback to execute after failure
|
|
71
|
+
* @returns Promise resolving to the operation result
|
|
72
|
+
*/
|
|
73
|
+
withRetry<T>(operation: () => Promise<T>, operationName: string, context?: any, errCallback?: () => Promise<void>): Promise<T>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { logger } from "./logger.js";
|
|
2
|
+
import { sleepMs } from "./utils.js";
|
|
3
|
+
import { getErrorRetryPolicy, isFheError } from "./errors/error-utils.js";
|
|
4
|
+
import { FheErrorCode } from "./errors/error-codes.js";
|
|
5
|
+
import { FheError } from "./errors/fhe-error.js";
|
|
6
|
+
const MIN_RETRY_INTERVAL_MS = 500;
|
|
7
|
+
export class RetryableHandler {
|
|
8
|
+
retryableStatusCodes;
|
|
9
|
+
retryableErrors;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
const defaultStatusCodes = [404];
|
|
12
|
+
const defaultErrors = [
|
|
13
|
+
'UNAVAILABLE',
|
|
14
|
+
'DEADLINE_EXCEEDED',
|
|
15
|
+
'timeout',
|
|
16
|
+
'Failed to fetch',
|
|
17
|
+
'fetch failed',
|
|
18
|
+
'NetworkError',
|
|
19
|
+
];
|
|
20
|
+
if (options?.overrideDefaults) {
|
|
21
|
+
// Override mode: user values replace defaults
|
|
22
|
+
this.retryableStatusCodes = options.retryableStatusCodes ?? defaultStatusCodes;
|
|
23
|
+
this.retryableErrors = options.retryableErrors ?? defaultErrors;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Append mode (default): user values are added to defaults (deduplicated)
|
|
27
|
+
this.retryableStatusCodes = [
|
|
28
|
+
...defaultStatusCodes,
|
|
29
|
+
...(options?.retryableStatusCodes?.filter(code => !defaultStatusCodes.includes(code)) ?? []),
|
|
30
|
+
];
|
|
31
|
+
this.retryableErrors = [
|
|
32
|
+
...defaultErrors,
|
|
33
|
+
...(options?.retryableErrors?.filter(err => !defaultErrors.includes(err)) ?? []),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Determine if an error should trigger a retry
|
|
39
|
+
* @param err - The error object
|
|
40
|
+
* @returns True if retry should be attempted
|
|
41
|
+
*/
|
|
42
|
+
shouldRetry(err) {
|
|
43
|
+
const message = typeof err?.message === "string" ? err.message.toLowerCase() : "";
|
|
44
|
+
// Check retryable gRPC status codes
|
|
45
|
+
if (err.code && this.retryableStatusCodes.includes(err.code)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
// Check retryable error message patterns
|
|
49
|
+
if (message) {
|
|
50
|
+
for (const retryableError of this.retryableErrors) {
|
|
51
|
+
if (message.includes(retryableError.toLowerCase())) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Check for 404 error or gRPC code 5 (NOT_FOUND)
|
|
57
|
+
if (message.includes('404') || err.code === 5) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
// FheErrors carry their retry policy directly.
|
|
61
|
+
if (isFheError(err)) {
|
|
62
|
+
return getErrorRetryPolicy(err).retryable;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Enhance error with additional context information
|
|
68
|
+
* @param err - Original error
|
|
69
|
+
* @param operationName - Name of the operation
|
|
70
|
+
* @param context - Optional context data
|
|
71
|
+
* @returns Enhanced error object
|
|
72
|
+
*/
|
|
73
|
+
enhanceError(err, operationName, context) {
|
|
74
|
+
const enhancedError = new FheError({
|
|
75
|
+
code: FheErrorCode.Internal,
|
|
76
|
+
message: `[${operationName}] ${err.message}\n` +
|
|
77
|
+
`Context: ${JSON.stringify(context, null, 2)}`,
|
|
78
|
+
cause: err,
|
|
79
|
+
});
|
|
80
|
+
enhancedError.originalError = err;
|
|
81
|
+
enhancedError.operationName = operationName;
|
|
82
|
+
return enhancedError;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export class CountRetryHandler extends RetryableHandler {
|
|
86
|
+
maxRetries;
|
|
87
|
+
initialDelayMs;
|
|
88
|
+
backoffFactor;
|
|
89
|
+
maxDelayMs;
|
|
90
|
+
constructor(options) {
|
|
91
|
+
super(options);
|
|
92
|
+
this.maxRetries = options?.maxRetries ?? 3;
|
|
93
|
+
this.initialDelayMs = options?.initialDelayMs ?? 1000;
|
|
94
|
+
this.backoffFactor = options?.backoffFactor ?? 2;
|
|
95
|
+
this.maxDelayMs = options?.maxDelayMs ?? 30000;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Execute operation with count-based retry logic using exponential backoff
|
|
99
|
+
* @param operation - Async operation to execute
|
|
100
|
+
* @param operationName - Name of the operation for logging
|
|
101
|
+
* @param context - Optional context data for error enhancement
|
|
102
|
+
* @returns Promise resolving to the operation result
|
|
103
|
+
*/
|
|
104
|
+
async withRetry(operation, operationName, context) {
|
|
105
|
+
let lastError = null;
|
|
106
|
+
let delay = this.initialDelayMs;
|
|
107
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
108
|
+
try {
|
|
109
|
+
if (attempt > 0) {
|
|
110
|
+
logger.debug(`[${operationName}] Retry attempt ${attempt + 1}/${this.maxRetries + 1}`);
|
|
111
|
+
}
|
|
112
|
+
const result = await operation();
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
lastError = err;
|
|
117
|
+
const canRetry = this.shouldRetry(err);
|
|
118
|
+
const isLastAttempt = attempt >= this.maxRetries;
|
|
119
|
+
if (!canRetry || isLastAttempt) {
|
|
120
|
+
const reason = !canRetry ? 'non-retryable error' : 'max retries reached';
|
|
121
|
+
logger.error(`[${operationName}] Failed - ${reason}: ${err.message}`);
|
|
122
|
+
throw this.enhanceError(err, operationName, context);
|
|
123
|
+
}
|
|
124
|
+
logger.warn(`[${operationName}] Retry failed (${attempt + 1}/${this.maxRetries + 1}): ${err.message}. Waiting ${delay}ms...`);
|
|
125
|
+
await sleepMs(delay);
|
|
126
|
+
delay = Math.min(delay * this.backoffFactor, this.maxDelayMs);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
throw this.enhanceError(lastError, operationName, context);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export class TimeoutRetryHandler extends RetryableHandler {
|
|
133
|
+
maxRetryTimeMs;
|
|
134
|
+
initialIntervalMs;
|
|
135
|
+
adaptiveInterval;
|
|
136
|
+
maxIntervalMs;
|
|
137
|
+
constructor(options) {
|
|
138
|
+
super(options);
|
|
139
|
+
this.maxRetryTimeMs = options?.maxRetryTimeMs ?? 30000;
|
|
140
|
+
this.initialIntervalMs = options?.initialIntervalMs ?? 1000;
|
|
141
|
+
this.adaptiveInterval = options?.adaptiveInterval ?? false;
|
|
142
|
+
this.maxIntervalMs = options?.maxIntervalMs ?? 5000;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Execute operation with timeout-based retry logic
|
|
146
|
+
* Timeout check is performed after each failure, before scheduling the next retry.
|
|
147
|
+
* This ensures the current attempt is never interrupted.
|
|
148
|
+
*
|
|
149
|
+
* @param operation - Async operation to execute
|
|
150
|
+
* @param operationName - Name of the operation for logging
|
|
151
|
+
* @param context - Optional context data for error enhancement
|
|
152
|
+
* @param errCallback - Optional callback to execute after failure
|
|
153
|
+
* @returns Promise resolving to the operation result
|
|
154
|
+
*/
|
|
155
|
+
async withRetry(operation, operationName, context, errCallback) {
|
|
156
|
+
let lastError = null;
|
|
157
|
+
const startTime = Date.now();
|
|
158
|
+
let attempt = 0;
|
|
159
|
+
let currentInterval = this.initialIntervalMs;
|
|
160
|
+
while (true) {
|
|
161
|
+
try {
|
|
162
|
+
// Execute the operation
|
|
163
|
+
if (attempt > 0) {
|
|
164
|
+
const elapsedTime = Date.now() - startTime;
|
|
165
|
+
logger.debug(`[${operationName}] Retry attempt ${attempt}, elapsed ${elapsedTime}ms`);
|
|
166
|
+
}
|
|
167
|
+
const result = await operation();
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
lastError = err;
|
|
172
|
+
// Check if the error is retryable
|
|
173
|
+
const canRetry = context?.shouldRetry ? context.shouldRetry(err) : this.shouldRetry(err);
|
|
174
|
+
if (!canRetry) {
|
|
175
|
+
logger.error(`[${operationName}] Failed - non-retryable error: ${err.message}`);
|
|
176
|
+
throw this.enhanceError(err, operationName, context);
|
|
177
|
+
}
|
|
178
|
+
// Check timeout after failure, before scheduling next retry
|
|
179
|
+
const elapsedTime = Date.now() - startTime;
|
|
180
|
+
const remainingTime = this.maxRetryTimeMs - elapsedTime;
|
|
181
|
+
if (remainingTime <= 0) {
|
|
182
|
+
logger.error(`[${operationName}] Failed - timeout exceeded ${this.maxRetryTimeMs}ms after ${attempt} attempts`);
|
|
183
|
+
throw this.enhanceError(err, operationName, context);
|
|
184
|
+
}
|
|
185
|
+
// Calculate next interval
|
|
186
|
+
const retryAfterMs = err?.retryAfterMs;
|
|
187
|
+
const isValidRetryAfterMs = typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs > 0;
|
|
188
|
+
let nextInterval;
|
|
189
|
+
if (isValidRetryAfterMs) {
|
|
190
|
+
nextInterval = retryAfterMs;
|
|
191
|
+
}
|
|
192
|
+
else if (this.adaptiveInterval) {
|
|
193
|
+
nextInterval = Math.min(currentInterval * 1.5, this.maxIntervalMs);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
nextInterval = currentInterval;
|
|
197
|
+
}
|
|
198
|
+
// Verify sufficient time remains for another retry
|
|
199
|
+
if (nextInterval > remainingTime) {
|
|
200
|
+
logger.warn(`[${operationName}] Insufficient time for retry (need ${nextInterval}ms, have ${remainingTime}ms)`);
|
|
201
|
+
nextInterval = remainingTime;
|
|
202
|
+
}
|
|
203
|
+
nextInterval = Math.max(MIN_RETRY_INTERVAL_MS, nextInterval);
|
|
204
|
+
logger.warn(`[${operationName}] Retry failed (attempt ${attempt + 1}, elapsed ${elapsedTime}ms, nextInterval ${nextInterval}): ${err.message}`);
|
|
205
|
+
logger.debug(`[${operationName}] Waiting ${nextInterval}ms before next attempt...`);
|
|
206
|
+
// Start callback execution in parallel with sleep. A throwing callback
|
|
207
|
+
// must never mask the original operation error or break the retry flow.
|
|
208
|
+
let callbackPromise;
|
|
209
|
+
try {
|
|
210
|
+
callbackPromise = Promise.resolve(errCallback?.());
|
|
211
|
+
}
|
|
212
|
+
catch (callbackError) {
|
|
213
|
+
logger.warn(`[${operationName}] Retry callback failed`, { error: callbackError });
|
|
214
|
+
}
|
|
215
|
+
await Promise.all([
|
|
216
|
+
sleepMs(nextInterval),
|
|
217
|
+
callbackPromise?.catch((callbackError) => {
|
|
218
|
+
logger.warn(`[${operationName}] Retry callback failed`, { error: callbackError });
|
|
219
|
+
}),
|
|
220
|
+
]);
|
|
221
|
+
currentInterval = nextInterval;
|
|
222
|
+
attempt++;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=retryable-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryable-handler.js","sourceRoot":"","sources":["../../src/core/retryable-handler.ts"],"names":[],"mappings":"A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AAO,EAAE,CACnI,CAAC;gBACF,MAAM,CAAC,KAAK,CAAC,IAAI,aAAa,aAAa,YAAY,2BAA2B,CAAC,CAAC;gBAEpF,uEAAuE;gBACvE,wEAAwE;gBACxE,IAAI,eAA6C,CAAC;gBAClD,IAAI,CAAC;oBACH,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBACrD,CAAC;gBAAC,OAAO,aAAa,EAAE,CAAC;oBACvB,MAAM,CAAC,IAAI,CAAC,IAAI,aAAa,yBAAyB,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;gBACpF,CAAC;gBACD,MAAM,OAAO,CAAC,GAAG,CAAC;oBAChB,OAAO,CAAC,YAAY,CAAC;oBACrB,eAAe,EAAE,KAAK,CAAC,CAAC,aAAa,EAAE,EAAE;wBACvC,MAAM,CAAC,IAAI,CAAC,IAAI,aAAa,yBAAyB,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;oBACpF,CAAC,CAAC;iBACH,CAAC,CAAC;gBACH,eAAe,GAAG,YAAY,CAAC;gBAC/B,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Address } from "../core/primitives.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents the signer address information for KMS decryption operations.
|
|
4
|
+
* Currently only contains the TEE (Trusted Execution Environment) signer address.
|
|
5
|
+
*/
|
|
6
|
+
export type SignerAddressInfo = {
|
|
7
|
+
readonly kmsDecryptionSignerAddress: Address;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the signer address information for a given blockchain chain ID.
|
|
11
|
+
*
|
|
12
|
+
* @param chainId - The chain ID (as bigint) of the target blockchain network.
|
|
13
|
+
* @returns The signer address information for the specified chain.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSignerAddressInfo(chainId: bigint): SignerAddressInfo;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the signer address information for a given blockchain chain ID.
|
|
3
|
+
*
|
|
4
|
+
* @param chainId - The chain ID (as bigint) of the target blockchain network.
|
|
5
|
+
* @returns The signer address information for the specified chain.
|
|
6
|
+
*/
|
|
7
|
+
export function getSignerAddressInfo(chainId) {
|
|
8
|
+
let info;
|
|
9
|
+
switch (chainId) {
|
|
10
|
+
case 31337n: // Anvil / Hardhat local development network (default test accounts)
|
|
11
|
+
info = {
|
|
12
|
+
kmsDecryptionSignerAddress: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
13
|
+
};
|
|
14
|
+
break;
|
|
15
|
+
case 56n: // BNB Smart Chain Mainnet
|
|
16
|
+
info = {
|
|
17
|
+
kmsDecryptionSignerAddress: "0x7d8769999bEcBfB91a8c127515044e3888ac3184",
|
|
18
|
+
};
|
|
19
|
+
break;
|
|
20
|
+
case 97n: // BNB Smart Chain Testnet
|
|
21
|
+
info = {
|
|
22
|
+
kmsDecryptionSignerAddress: "0x0c900B88D258fA4c6c2ef7725Db0f7cA1522ABd0",
|
|
23
|
+
};
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
info = {
|
|
27
|
+
kmsDecryptionSignerAddress: "0x7d8769999bEcBfB91a8c127515044e3888ac3184",
|
|
28
|
+
};
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return info;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=signer-address-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer-address-info.js","sourceRoot":"","sources":["../../src/core/signer-address-info.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,IAAI,IAAuB,CAAC;IAE5B,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM,EAAE,oEAAoE;YAC/E,IAAI,GAAG;gBACL,0BAA0B,EAAE,4CAAuD;aACpF,CAAC;YACF,MAAM;QAER,KAAK,GAAG,EAAE,0BAA0B;YAClC,IAAI,GAAG;gBACL,0BAA0B,EAAE,4CAAuD;aACpF,CAAC;YACF,MAAM;QAER,KAAK,GAAG,EAAE,0BAA0B;YAClC,IAAI,GAAG;gBACL,0BAA0B,EAAE,4CAAuD;aACpF,CAAC;YACF,MAAM;QAER;YACE,IAAI,GAAG;gBACL,0BAA0B,EAAE,4CAAuD;aACpF,CAAC;YACF,MAAM;IACV,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BytesHex, BytesHexNo0x } from "./primitives.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ensures a hex string has the "0x" prefix.
|
|
4
|
+
* @param s - The hex string (with or without prefix)
|
|
5
|
+
* @returns The hex string with "0x" prefix
|
|
6
|
+
*/
|
|
7
|
+
export declare function ensure0x<T extends BytesHexNo0x>(s: T): BytesHex & Omit<T, keyof BytesHexNo0x>;
|
|
8
|
+
export declare function ensure0x(s: string): `0x${string}`;
|
|
9
|
+
/**
|
|
10
|
+
* Removes the "0x" prefix from a hex string.
|
|
11
|
+
* @param s - The hex string (with or without prefix)
|
|
12
|
+
* @returns The hex string without the "0x" prefix
|
|
13
|
+
*/
|
|
14
|
+
export declare function remove0x<T extends BytesHex>(s: T): BytesHexNo0x & Omit<T, keyof BytesHex>;
|
|
15
|
+
export declare function remove0x(s: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Removes a specified suffix from a string if present.
|
|
18
|
+
* @param s - The input string (or undefined)
|
|
19
|
+
* @param suffix - The suffix to remove
|
|
20
|
+
* @returns The string without the suffix, or empty string if input is undefined
|
|
21
|
+
*/
|
|
22
|
+
export declare function removeSuffix(s: string | undefined, suffix: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Type guard that checks if a value is a non-empty string.
|
|
25
|
+
* @param s - The value to check
|
|
26
|
+
* @returns True if the value is a string with length > 0
|
|
27
|
+
*/
|
|
28
|
+
export declare function isNonEmptyString(s: unknown): s is string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function ensure0x(s) {
|
|
2
|
+
return !s.startsWith("0x") ? `0x${s}` : s;
|
|
3
|
+
}
|
|
4
|
+
export function remove0x(s) {
|
|
5
|
+
return s.startsWith("0x") ? s.substring(2) : s;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Removes a specified suffix from a string if present.
|
|
9
|
+
* @param s - The input string (or undefined)
|
|
10
|
+
* @param suffix - The suffix to remove
|
|
11
|
+
* @returns The string without the suffix, or empty string if input is undefined
|
|
12
|
+
*/
|
|
13
|
+
export function removeSuffix(s, suffix) {
|
|
14
|
+
if (s === undefined) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
if (suffix.length === 0) {
|
|
18
|
+
return s;
|
|
19
|
+
}
|
|
20
|
+
return s.endsWith(suffix) ? s.slice(0, -suffix.length) : s;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Type guard that checks if a value is a non-empty string.
|
|
24
|
+
* @param s - The value to check
|
|
25
|
+
* @returns True if the value is a string with length > 0
|
|
26
|
+
*/
|
|
27
|
+
export function isNonEmptyString(s) {
|
|
28
|
+
if (s === undefined || s === null || typeof s !== "string") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return s.length > 0;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/core/string.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAmB,CAAC;AAC/D,CAAC;AASD,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,CAAqB,EAAE,MAAc;IAChE,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a function and swallows any errors that occur during execution.
|
|
3
|
+
*
|
|
4
|
+
* This utility is useful for non-critical operations that should not
|
|
5
|
+
* interrupt the main application flow even if they fail. Errors are
|
|
6
|
+
* logged as warnings for debugging purposes.
|
|
7
|
+
*
|
|
8
|
+
* @param label - A descriptive label for the operation (used in log messages)
|
|
9
|
+
* @param fn - The async or sync function to execute
|
|
10
|
+
* @returns A promise that resolves when the function completes (or fails)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Swallow errors from a non-critical operation
|
|
14
|
+
* await swallow('Cache cleanup', async () => {
|
|
15
|
+
* await cacheManager.clearExpired();
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Works with sync functions too
|
|
19
|
+
* await swallow('Log rotation', () => {
|
|
20
|
+
* rotateLogFiles();
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
23
|
+
export declare function swallow(label: string, fn: () => Promise<void> | void): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { logger } from "./logger.js";
|
|
2
|
+
/**
|
|
3
|
+
* Runs a function and swallows any errors that occur during execution.
|
|
4
|
+
*
|
|
5
|
+
* This utility is useful for non-critical operations that should not
|
|
6
|
+
* interrupt the main application flow even if they fail. Errors are
|
|
7
|
+
* logged as warnings for debugging purposes.
|
|
8
|
+
*
|
|
9
|
+
* @param label - A descriptive label for the operation (used in log messages)
|
|
10
|
+
* @param fn - The async or sync function to execute
|
|
11
|
+
* @returns A promise that resolves when the function completes (or fails)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Swallow errors from a non-critical operation
|
|
15
|
+
* await swallow('Cache cleanup', async () => {
|
|
16
|
+
* await cacheManager.clearExpired();
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Works with sync functions too
|
|
20
|
+
* await swallow('Log rotation', () => {
|
|
21
|
+
* rotateLogFiles();
|
|
22
|
+
* });
|
|
23
|
+
*/
|
|
24
|
+
export async function swallow(label, fn) {
|
|
25
|
+
try {
|
|
26
|
+
logger.debug(`[swallow] ${label} call`);
|
|
27
|
+
await fn();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// Log the error as a warning and swallow it
|
|
31
|
+
logger.warn(`[swallow] ${label} failed`, {
|
|
32
|
+
label,
|
|
33
|
+
error: error instanceof Error ? error.message : String(error)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=swallow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swallow.js","sourceRoot":"","sources":["../../src/core/swallow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,KAAa,EACb,EAA8B;IAG9B,IAAI,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,aAAa,KAAK,OAAO,CAAC,CAAC;QACxC,MAAM,EAAE,EAAE,CAAC;IACb,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4CAA4C;QAC5C,MAAM,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE;YACvC,KAAK;YACL,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Address } from "../core/primitives.js";
|
|
2
|
+
/**
|
|
3
|
+
* System contract addresses for FHE operations on supported chains.
|
|
4
|
+
*/
|
|
5
|
+
export type SystemContractInfo = {
|
|
6
|
+
readonly aclContractAddress: Address;
|
|
7
|
+
readonly spaceBridgeConfigAddress: Address;
|
|
8
|
+
readonly decryptionContractAddress: Address;
|
|
9
|
+
readonly ciphertextVerificationAddress: Address;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Returns the system contract addresses for a given blockchain chain ID.
|
|
13
|
+
* @param chainId - The blockchain chain ID
|
|
14
|
+
* @returns SystemContractInfo containing all required contract addresses
|
|
15
|
+
* @throws Error if the chain ID is not supported
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSystemContractInfo(chainId: bigint): SystemContractInfo;
|