@cofhe/sdk 0.2.0 → 0.3.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/CHANGELOG.md +36 -0
- package/chains/defineChain.ts +2 -2
- package/chains/types.ts +3 -3
- package/core/baseBuilder.ts +18 -18
- package/core/client.test.ts +155 -41
- package/core/client.ts +72 -32
- package/core/clientTypes.ts +28 -18
- package/core/config.test.ts +40 -33
- package/core/config.ts +56 -51
- package/core/consts.ts +22 -0
- package/core/decrypt/{MockQueryDecrypterAbi.ts → MockThresholdNetworkAbi.ts} +71 -21
- package/core/decrypt/cofheMocksDecryptForTx.ts +142 -0
- package/core/decrypt/{cofheMocksSealOutput.ts → cofheMocksDecryptForView.ts} +12 -14
- package/core/decrypt/decryptForTxBuilder.ts +340 -0
- package/core/decrypt/{decryptHandleBuilder.ts → decryptForViewBuilder.ts} +75 -42
- package/core/decrypt/tnDecrypt.ts +232 -0
- package/core/decrypt/tnSealOutputV1.ts +5 -5
- package/core/decrypt/tnSealOutputV2.ts +27 -27
- package/core/encrypt/cofheMocksZkVerifySign.ts +19 -26
- package/core/encrypt/encryptInputsBuilder.test.ts +57 -61
- package/core/encrypt/encryptInputsBuilder.ts +65 -42
- package/core/encrypt/zkPackProveVerify.ts +11 -11
- package/core/error.ts +18 -18
- package/core/fetchKeys.test.ts +3 -3
- package/core/fetchKeys.ts +3 -3
- package/core/index.ts +22 -11
- package/core/permits.test.ts +5 -6
- package/core/permits.ts +5 -4
- package/core/utils.ts +10 -10
- package/dist/chains.cjs +4 -7
- package/dist/chains.d.cts +12 -12
- package/dist/chains.d.ts +12 -12
- package/dist/chains.js +1 -1
- package/dist/{chunk-WGCRJCBR.js → chunk-2TPSCOW3.js} +820 -224
- package/dist/{chunk-UGBVZNRT.js → chunk-NWDKXBIP.js} +309 -189
- package/dist/{chunk-WEAZ25JO.js → chunk-TBLR7NNE.js} +4 -7
- package/dist/{clientTypes-5_1nwtUe.d.cts → clientTypes-6aTZPQ_4.d.ts} +233 -173
- package/dist/{clientTypes-Es7fyi65.d.ts → clientTypes-Bhq7pCSA.d.cts} +233 -173
- package/dist/core.cjs +1138 -418
- package/dist/core.d.cts +37 -24
- package/dist/core.d.ts +37 -24
- package/dist/core.js +3 -3
- package/dist/node.cjs +1082 -370
- package/dist/node.d.cts +12 -12
- package/dist/node.d.ts +12 -12
- package/dist/node.js +8 -8
- package/dist/{permit-fUSe6KKq.d.cts → permit-MZ502UBl.d.cts} +30 -33
- package/dist/{permit-fUSe6KKq.d.ts → permit-MZ502UBl.d.ts} +30 -33
- package/dist/permits.cjs +305 -187
- package/dist/permits.d.cts +111 -812
- package/dist/permits.d.ts +111 -812
- package/dist/permits.js +1 -1
- package/dist/types-YiAC4gig.d.cts +33 -0
- package/dist/types-YiAC4gig.d.ts +33 -0
- package/dist/web.cjs +1085 -373
- package/dist/web.d.cts +13 -13
- package/dist/web.d.ts +13 -13
- package/dist/web.js +10 -10
- package/node/client.test.ts +34 -34
- package/node/config.test.ts +11 -11
- package/node/encryptInputs.test.ts +29 -29
- package/node/index.ts +15 -15
- package/package.json +3 -3
- package/permits/localstorage.test.ts +9 -13
- package/permits/onchain-utils.ts +221 -0
- package/permits/permit.test.ts +51 -5
- package/permits/permit.ts +28 -74
- package/permits/store.test.ts +10 -50
- package/permits/store.ts +4 -14
- package/permits/test-utils.ts +10 -2
- package/permits/types.ts +22 -9
- package/permits/utils.ts +0 -4
- package/permits/validation.test.ts +29 -32
- package/permits/validation.ts +112 -194
- package/web/client.web.test.ts +34 -34
- package/web/config.web.test.ts +11 -11
- package/web/encryptInputs.web.test.ts +29 -29
- package/web/index.ts +19 -19
- package/web/worker.builder.web.test.ts +28 -28
- package/web/worker.config.web.test.ts +47 -47
- package/web/worker.output.web.test.ts +10 -10
- package/dist/types-KImPrEIe.d.cts +0 -48
- package/dist/types-KImPrEIe.d.ts +0 -48
package/core/error.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export enum
|
|
1
|
+
export enum CofheErrorCode {
|
|
2
2
|
InternalError = 'INTERNAL_ERROR',
|
|
3
3
|
UnknownEnvironment = 'UNKNOWN_ENVIRONMENT',
|
|
4
4
|
InitTfheFailed = 'INIT_TFHE_FAILED',
|
|
@@ -44,8 +44,8 @@ export enum CofhesdkErrorCode {
|
|
|
44
44
|
RehydrateKeysStoreFailed = 'REHYDRATE_KEYS_STORE_FAILED',
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export type
|
|
48
|
-
code:
|
|
47
|
+
export type CofheErrorParams = {
|
|
48
|
+
code: CofheErrorCode;
|
|
49
49
|
message: string;
|
|
50
50
|
cause?: Error;
|
|
51
51
|
hint?: string;
|
|
@@ -53,28 +53,28 @@ export type CofhesdkErrorParams = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* CofheError class
|
|
57
57
|
* This class is used to create errors that are specific to the CoFHE SDK
|
|
58
58
|
* It extends the Error class and adds a code, cause, hint, and context
|
|
59
59
|
* The code is used to identify the type of error
|
|
60
|
-
* The cause is used to indicate the inner error that caused the
|
|
60
|
+
* The cause is used to indicate the inner error that caused the CofheError
|
|
61
61
|
* The hint is used to provide a hint about how to fix the error
|
|
62
62
|
* The context is used to provide additional context about the state that caused the error
|
|
63
63
|
* The serialize method is used to serialize the error to a JSON string
|
|
64
64
|
* The toString method is used to provide a human-readable string representation of the error
|
|
65
65
|
*/
|
|
66
|
-
export class
|
|
67
|
-
public readonly code:
|
|
66
|
+
export class CofheError extends Error {
|
|
67
|
+
public readonly code: CofheErrorCode;
|
|
68
68
|
public readonly cause?: Error;
|
|
69
69
|
public readonly hint?: string;
|
|
70
70
|
public readonly context?: Record<string, unknown>;
|
|
71
71
|
|
|
72
|
-
constructor({ code, message, cause, hint, context }:
|
|
72
|
+
constructor({ code, message, cause, hint, context }: CofheErrorParams) {
|
|
73
73
|
// If there's a cause, append its message to provide full context
|
|
74
74
|
const fullMessage = cause ? `${message} | Caused by: ${cause.message}` : message;
|
|
75
75
|
|
|
76
76
|
super(fullMessage);
|
|
77
|
-
this.name = '
|
|
77
|
+
this.name = 'CofheError';
|
|
78
78
|
this.code = code;
|
|
79
79
|
this.cause = cause;
|
|
80
80
|
this.hint = hint;
|
|
@@ -82,22 +82,22 @@ export class CofhesdkError extends Error {
|
|
|
82
82
|
|
|
83
83
|
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
84
84
|
if (Error.captureStackTrace) {
|
|
85
|
-
Error.captureStackTrace(this,
|
|
85
|
+
Error.captureStackTrace(this, CofheError);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* Creates a
|
|
91
|
-
* If the error is a
|
|
92
|
-
* If a wrapperError is provided, it is used to create the new
|
|
90
|
+
* Creates a CofheError from an unknown error
|
|
91
|
+
* If the error is a CofheError, it is returned unchanged, else a new CofheError is created
|
|
92
|
+
* If a wrapperError is provided, it is used to create the new CofheError, else a default is used
|
|
93
93
|
*/
|
|
94
|
-
static fromError(error: unknown, wrapperError?:
|
|
95
|
-
if (
|
|
94
|
+
static fromError(error: unknown, wrapperError?: CofheErrorParams): CofheError {
|
|
95
|
+
if (isCofheError(error)) return error;
|
|
96
96
|
|
|
97
97
|
const cause = error instanceof Error ? error : new Error(`${error}`);
|
|
98
98
|
|
|
99
|
-
return new
|
|
100
|
-
code: wrapperError?.code ??
|
|
99
|
+
return new CofheError({
|
|
100
|
+
code: wrapperError?.code ?? CofheErrorCode.InternalError,
|
|
101
101
|
message: wrapperError?.message ?? 'An internal error occurred',
|
|
102
102
|
hint: wrapperError?.hint,
|
|
103
103
|
context: wrapperError?.context,
|
|
@@ -165,4 +165,4 @@ const bigintSafeJsonStringify = (value: unknown): string => {
|
|
|
165
165
|
});
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
export const
|
|
168
|
+
export const isCofheError = (error: unknown): error is CofheError => error instanceof CofheError;
|
package/core/fetchKeys.test.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { sepolia, arbSepolia } from '@/chains';
|
|
|
5
5
|
|
|
6
6
|
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
7
7
|
import { fetchKeys } from './fetchKeys.js';
|
|
8
|
-
import { type
|
|
8
|
+
import { type CofheConfig, createCofheConfigBase } from './config.js';
|
|
9
9
|
import { createKeysStore, type KeysStorage } from './keyStore.js';
|
|
10
10
|
|
|
11
11
|
describe('fetchKeys', () => {
|
|
12
|
-
let config:
|
|
12
|
+
let config: CofheConfig;
|
|
13
13
|
let mockTfhePublicKeyDeserializer: any;
|
|
14
14
|
let mockCompactPkeCrsDeserializer: any;
|
|
15
15
|
let keysStorage: KeysStorage;
|
|
@@ -19,7 +19,7 @@ describe('fetchKeys', () => {
|
|
|
19
19
|
vi.clearAllMocks();
|
|
20
20
|
|
|
21
21
|
// Setup config with real chains
|
|
22
|
-
config =
|
|
22
|
+
config = createCofheConfigBase({
|
|
23
23
|
supportedChains: [sepolia, arbSepolia],
|
|
24
24
|
});
|
|
25
25
|
|
package/core/fetchKeys.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hardhat } from '@/chains';
|
|
2
2
|
|
|
3
|
-
import { type
|
|
3
|
+
import { type CofheConfig, getCoFheUrlOrThrow } from './config.js';
|
|
4
4
|
import { type KeysStorage } from './keyStore.js';
|
|
5
5
|
|
|
6
6
|
const PUBLIC_KEY_LENGTH_MIN = 15_000;
|
|
@@ -118,7 +118,7 @@ const fetchCrs = async (
|
|
|
118
118
|
/**
|
|
119
119
|
* Retrieves the FHE public key and the CRS from the provider.
|
|
120
120
|
* If the key/crs already exists in the store it is returned, else it is fetched, stored, and returned
|
|
121
|
-
* @param {
|
|
121
|
+
* @param {CofheConfig} config - The configuration object for the CoFHE client
|
|
122
122
|
* @param {number} chainId - The chain to fetch the FHE key for, if no chainId provided, undefined is returned
|
|
123
123
|
* @param securityZone - The security zone for which to retrieve the key (default 0).
|
|
124
124
|
* @param tfhePublicKeyDeserializer - The serializer for the FHE public key (used for validation).
|
|
@@ -127,7 +127,7 @@ const fetchCrs = async (
|
|
|
127
127
|
* @returns {Promise<[[string, boolean], [string, boolean]]>} - A promise that resolves to [[fheKey, fheKeyFetchedFromCoFHE], [crs, crsFetchedFromCoFHE]]
|
|
128
128
|
*/
|
|
129
129
|
export const fetchKeys = async (
|
|
130
|
-
config:
|
|
130
|
+
config: CofheConfig,
|
|
131
131
|
chainId: number,
|
|
132
132
|
securityZone: number = 0,
|
|
133
133
|
tfhePublicKeyDeserializer: FheKeyDeserializer,
|
package/core/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// Client (base implementations)
|
|
2
|
-
export {
|
|
2
|
+
export { createCofheClientBase, InitialConnectStore as CONNECT_STORE_DEFAULTS } from './client.js';
|
|
3
3
|
|
|
4
4
|
// Configuration (base implementations)
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
5
|
+
export { createCofheConfigBase, getCofheConfigItem } from './config.js';
|
|
6
|
+
export type { CofheConfig, CofheInputConfig, CofheInternalConfig } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Types
|
|
9
9
|
export type {
|
|
10
10
|
// Client types
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
CofheClient as CofheClient,
|
|
12
|
+
CofheClientParams as CofheClientParams,
|
|
13
|
+
CofheClientConnectionState as CofheClientConnectionState,
|
|
14
|
+
CofheClientPermits as CofheClientPermits,
|
|
15
15
|
} from './clientTypes.js';
|
|
16
16
|
|
|
17
17
|
export type {
|
|
@@ -59,8 +59,8 @@ export {
|
|
|
59
59
|
} from './types.js';
|
|
60
60
|
|
|
61
61
|
// Error handling
|
|
62
|
-
export {
|
|
63
|
-
export type {
|
|
62
|
+
export { CofheError, CofheErrorCode, isCofheError } from './error.js';
|
|
63
|
+
export type { CofheErrorParams } from './error.js';
|
|
64
64
|
|
|
65
65
|
// Key fetching
|
|
66
66
|
export { fetchKeys } from './fetchKeys.js';
|
|
@@ -72,7 +72,9 @@ export type { KeysStorage, KeysStore } from './keyStore.js';
|
|
|
72
72
|
|
|
73
73
|
// Builders (exported via client, but can be imported directly for typing)
|
|
74
74
|
export { EncryptInputsBuilder } from './encrypt/encryptInputsBuilder.js';
|
|
75
|
-
export {
|
|
75
|
+
export { DecryptForViewBuilder } from './decrypt/decryptForViewBuilder.js';
|
|
76
|
+
export { DecryptForTxBuilder } from './decrypt/decryptForTxBuilder.js';
|
|
77
|
+
export type { DecryptForTxResult } from './decrypt/decryptForTxBuilder.js';
|
|
76
78
|
|
|
77
79
|
// ZK utilities
|
|
78
80
|
export type {
|
|
@@ -83,7 +85,16 @@ export type {
|
|
|
83
85
|
} from './encrypt/zkPackProveVerify.js';
|
|
84
86
|
export { zkProveWithWorker } from './encrypt/zkPackProveVerify.js';
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
// Contract addresses
|
|
89
|
+
export {
|
|
90
|
+
TASK_MANAGER_ADDRESS,
|
|
91
|
+
MOCKS_ZK_VERIFIER_ADDRESS,
|
|
92
|
+
MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,
|
|
93
|
+
MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,
|
|
94
|
+
MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY,
|
|
95
|
+
MOCKS_THRESHOLD_NETWORK_ADDRESS,
|
|
96
|
+
TEST_BED_ADDRESS,
|
|
97
|
+
} from './consts.js';
|
|
87
98
|
|
|
88
99
|
// Utils
|
|
89
100
|
export { fheTypeToString } from './utils.js';
|
package/core/permits.test.ts
CHANGED
|
@@ -151,7 +151,7 @@ describe('Core Permits Tests', () => {
|
|
|
151
151
|
publicClient,
|
|
152
152
|
bobWalletClient
|
|
153
153
|
);
|
|
154
|
-
permitHash =
|
|
154
|
+
permitHash = createdPermit.hash;
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
it('should get permit by hash', async () => {
|
|
@@ -195,9 +195,8 @@ describe('Core Permits Tests', () => {
|
|
|
195
195
|
const permitKeys = Object.keys(parsedData.state.permits[chainId][bobAddress]);
|
|
196
196
|
expect(permitKeys.length).toBeGreaterThan(0);
|
|
197
197
|
|
|
198
|
-
const permitHash = permits.getHash(createdPermit);
|
|
199
198
|
const serializedPermit = permits.serialize(createdPermit);
|
|
200
|
-
expect(parsedData.state.permits[chainId][bobAddress][
|
|
199
|
+
expect(parsedData.state.permits[chainId][bobAddress][createdPermit.hash]).toEqual(serializedPermit);
|
|
201
200
|
});
|
|
202
201
|
});
|
|
203
202
|
|
|
@@ -272,7 +271,7 @@ describe('Core Permits Tests', () => {
|
|
|
272
271
|
});
|
|
273
272
|
|
|
274
273
|
expect(permit.name).toBe('First Self Permit');
|
|
275
|
-
expect(
|
|
274
|
+
expect(permit.hash).toBe(firstPermit.hash);
|
|
276
275
|
|
|
277
276
|
// Verify no new permit was created
|
|
278
277
|
const allPermits = await permits.getPermits(chainId, bobAddress);
|
|
@@ -381,7 +380,7 @@ describe('Core Permits Tests', () => {
|
|
|
381
380
|
);
|
|
382
381
|
|
|
383
382
|
expect(permit.name).toBe('First Sharing Permit');
|
|
384
|
-
expect(
|
|
383
|
+
expect(permit.hash).toBe(firstPermit.hash);
|
|
385
384
|
|
|
386
385
|
// Verify no new permit was created
|
|
387
386
|
const allPermits = await permits.getPermits(chainId, bobAddress);
|
|
@@ -483,7 +482,7 @@ describe('Core Permits Tests', () => {
|
|
|
483
482
|
});
|
|
484
483
|
|
|
485
484
|
// Should be the same permit
|
|
486
|
-
expect(
|
|
485
|
+
expect(permit1.hash).toBe(permit2.hash);
|
|
487
486
|
expect(permit2.name).toBe('Permit 1'); // Original name
|
|
488
487
|
|
|
489
488
|
// Only one permit should exist
|
package/core/permits.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type SelfPermit,
|
|
10
10
|
type RecipientPermit,
|
|
11
11
|
type SharingPermit,
|
|
12
|
+
type PermitHashFields,
|
|
12
13
|
} from '@/permits';
|
|
13
14
|
|
|
14
15
|
import { type PublicClient, type WalletClient } from 'viem';
|
|
@@ -21,7 +22,7 @@ const storeActivePermit = async (permit: Permit, publicClient: any, walletClient
|
|
|
21
22
|
const account = walletClient.account!.address;
|
|
22
23
|
|
|
23
24
|
permitStore.setPermit(chainId, account, permit);
|
|
24
|
-
permitStore.setActivePermitHash(chainId, account,
|
|
25
|
+
permitStore.setActivePermitHash(chainId, account, permit.hash);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
// Generic function to handle permit creation with error handling
|
|
@@ -70,7 +71,7 @@ const importShared = async (
|
|
|
70
71
|
|
|
71
72
|
// PERMIT UTILS
|
|
72
73
|
|
|
73
|
-
const getHash = (permit:
|
|
74
|
+
const getHash = (permit: PermitHashFields) => {
|
|
74
75
|
return PermitUtils.getHash(permit);
|
|
75
76
|
};
|
|
76
77
|
|
|
@@ -167,8 +168,8 @@ const getOrCreateSharingPermit = async (
|
|
|
167
168
|
|
|
168
169
|
// REMOVE
|
|
169
170
|
|
|
170
|
-
const removePermit = async (chainId: number, account: string, hash: string
|
|
171
|
-
permitStore.removePermit(chainId, account, hash
|
|
171
|
+
const removePermit = async (chainId: number, account: string, hash: string): Promise<void> =>
|
|
172
|
+
permitStore.removePermit(chainId, account, hash);
|
|
172
173
|
|
|
173
174
|
const removeActivePermit = async (chainId: number, account: string): Promise<void> =>
|
|
174
175
|
permitStore.removeActivePermitHash(chainId, account);
|
package/core/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PublicClient, type WalletClient } from 'viem';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { CofheError, CofheErrorCode } from './error.js';
|
|
3
|
+
import { FheTypes } from './types.js';
|
|
4
4
|
|
|
5
5
|
export const toHexString = (bytes: Uint8Array) =>
|
|
6
6
|
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
|
|
@@ -50,15 +50,15 @@ export async function getPublicClientChainID(publicClient: PublicClient) {
|
|
|
50
50
|
try {
|
|
51
51
|
chainId = publicClient.chain?.id ?? (await publicClient.getChainId());
|
|
52
52
|
} catch (e) {
|
|
53
|
-
throw new
|
|
54
|
-
code:
|
|
53
|
+
throw new CofheError({
|
|
54
|
+
code: CofheErrorCode.PublicWalletGetChainIdFailed,
|
|
55
55
|
message: 'getting chain ID from public client failed',
|
|
56
56
|
cause: e instanceof Error ? e : undefined,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
if (chainId === null) {
|
|
60
|
-
throw new
|
|
61
|
-
code:
|
|
60
|
+
throw new CofheError({
|
|
61
|
+
code: CofheErrorCode.PublicWalletGetChainIdFailed,
|
|
62
62
|
message: 'chain ID from public client is null',
|
|
63
63
|
});
|
|
64
64
|
}
|
|
@@ -73,15 +73,15 @@ export async function getWalletClientAccount(walletClient: WalletClient) {
|
|
|
73
73
|
address = (await walletClient.getAddresses())?.[0];
|
|
74
74
|
}
|
|
75
75
|
} catch (e) {
|
|
76
|
-
throw new
|
|
77
|
-
code:
|
|
76
|
+
throw new CofheError({
|
|
77
|
+
code: CofheErrorCode.PublicWalletGetAddressesFailed,
|
|
78
78
|
message: 'getting address from wallet client failed',
|
|
79
79
|
cause: e instanceof Error ? e : undefined,
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
if (!address) {
|
|
83
|
-
throw new
|
|
84
|
-
code:
|
|
83
|
+
throw new CofheError({
|
|
84
|
+
code: CofheErrorCode.PublicWalletGetAddressesFailed,
|
|
85
85
|
message: 'address from wallet client is null',
|
|
86
86
|
});
|
|
87
87
|
}
|
package/dist/chains.cjs
CHANGED
|
@@ -12,21 +12,18 @@ var CofheChainSchema = zod.z.object({
|
|
|
12
12
|
/** Network identifier */
|
|
13
13
|
network: zod.z.string().min(1),
|
|
14
14
|
/** coFhe service URL */
|
|
15
|
-
coFheUrl: zod.z.
|
|
15
|
+
coFheUrl: zod.z.url(),
|
|
16
16
|
/** Verifier service URL */
|
|
17
|
-
verifierUrl: zod.z.
|
|
17
|
+
verifierUrl: zod.z.url(),
|
|
18
18
|
/** Threshold network service URL */
|
|
19
|
-
thresholdNetworkUrl: zod.z.
|
|
19
|
+
thresholdNetworkUrl: zod.z.url(),
|
|
20
20
|
/** Environment type */
|
|
21
21
|
environment: EnvironmentSchema
|
|
22
22
|
});
|
|
23
|
-
|
|
24
|
-
// chains/defineChain.ts
|
|
25
23
|
function defineChain(chainConfig) {
|
|
26
24
|
const result = CofheChainSchema.safeParse(chainConfig);
|
|
27
25
|
if (!result.success) {
|
|
28
|
-
|
|
29
|
-
throw new Error(`Invalid chain configuration: ${errorMessages.join(", ")}`);
|
|
26
|
+
throw new Error(`Invalid chain configuration: ${zod.z.prettifyError(result.error)}`, { cause: result.error });
|
|
30
27
|
}
|
|
31
28
|
return result.data;
|
|
32
29
|
}
|
package/dist/chains.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as CofheChain } from './types-
|
|
2
|
-
export { E as Environment } from './types-
|
|
1
|
+
import { C as CofheChain } from './types-YiAC4gig.cjs';
|
|
2
|
+
export { E as Environment } from './types-YiAC4gig.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Sepolia testnet chain configuration
|
|
7
7
|
*/
|
|
8
8
|
declare const sepolia: {
|
|
9
|
-
name: string;
|
|
10
9
|
id: number;
|
|
10
|
+
name: string;
|
|
11
11
|
network: string;
|
|
12
12
|
coFheUrl: string;
|
|
13
13
|
verifierUrl: string;
|
|
@@ -19,8 +19,8 @@ declare const sepolia: {
|
|
|
19
19
|
* Arbitrum Sepolia testnet chain configuration
|
|
20
20
|
*/
|
|
21
21
|
declare const arbSepolia: {
|
|
22
|
-
name: string;
|
|
23
22
|
id: number;
|
|
23
|
+
name: string;
|
|
24
24
|
network: string;
|
|
25
25
|
coFheUrl: string;
|
|
26
26
|
verifierUrl: string;
|
|
@@ -32,8 +32,8 @@ declare const arbSepolia: {
|
|
|
32
32
|
* Base Sepolia testnet chain configuration
|
|
33
33
|
*/
|
|
34
34
|
declare const baseSepolia: {
|
|
35
|
-
name: string;
|
|
36
35
|
id: number;
|
|
36
|
+
name: string;
|
|
37
37
|
network: string;
|
|
38
38
|
coFheUrl: string;
|
|
39
39
|
verifierUrl: string;
|
|
@@ -45,8 +45,8 @@ declare const baseSepolia: {
|
|
|
45
45
|
* Hardhat local development chain configuration
|
|
46
46
|
*/
|
|
47
47
|
declare const hardhat: {
|
|
48
|
-
name: string;
|
|
49
48
|
id: number;
|
|
49
|
+
name: string;
|
|
50
50
|
network: string;
|
|
51
51
|
coFheUrl: string;
|
|
52
52
|
verifierUrl: string;
|
|
@@ -58,8 +58,8 @@ declare const hardhat: {
|
|
|
58
58
|
* Localcofhe chain configuration
|
|
59
59
|
*/
|
|
60
60
|
declare const localcofhe: {
|
|
61
|
-
name: string;
|
|
62
61
|
id: number;
|
|
62
|
+
name: string;
|
|
63
63
|
network: string;
|
|
64
64
|
coFheUrl: string;
|
|
65
65
|
verifierUrl: string;
|
|
@@ -69,8 +69,8 @@ declare const localcofhe: {
|
|
|
69
69
|
|
|
70
70
|
declare const chains: {
|
|
71
71
|
readonly sepolia: {
|
|
72
|
-
name: string;
|
|
73
72
|
id: number;
|
|
73
|
+
name: string;
|
|
74
74
|
network: string;
|
|
75
75
|
coFheUrl: string;
|
|
76
76
|
verifierUrl: string;
|
|
@@ -78,8 +78,8 @@ declare const chains: {
|
|
|
78
78
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
79
79
|
};
|
|
80
80
|
readonly arbSepolia: {
|
|
81
|
-
name: string;
|
|
82
81
|
id: number;
|
|
82
|
+
name: string;
|
|
83
83
|
network: string;
|
|
84
84
|
coFheUrl: string;
|
|
85
85
|
verifierUrl: string;
|
|
@@ -87,8 +87,8 @@ declare const chains: {
|
|
|
87
87
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
88
88
|
};
|
|
89
89
|
readonly baseSepolia: {
|
|
90
|
-
name: string;
|
|
91
90
|
id: number;
|
|
91
|
+
name: string;
|
|
92
92
|
network: string;
|
|
93
93
|
coFheUrl: string;
|
|
94
94
|
verifierUrl: string;
|
|
@@ -96,8 +96,8 @@ declare const chains: {
|
|
|
96
96
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
97
97
|
};
|
|
98
98
|
readonly hardhat: {
|
|
99
|
-
name: string;
|
|
100
99
|
id: number;
|
|
100
|
+
name: string;
|
|
101
101
|
network: string;
|
|
102
102
|
coFheUrl: string;
|
|
103
103
|
verifierUrl: string;
|
|
@@ -105,8 +105,8 @@ declare const chains: {
|
|
|
105
105
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
106
106
|
};
|
|
107
107
|
readonly localcofhe: {
|
|
108
|
-
name: string;
|
|
109
108
|
id: number;
|
|
109
|
+
name: string;
|
|
110
110
|
network: string;
|
|
111
111
|
coFheUrl: string;
|
|
112
112
|
verifierUrl: string;
|
package/dist/chains.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as CofheChain } from './types-
|
|
2
|
-
export { E as Environment } from './types-
|
|
1
|
+
import { C as CofheChain } from './types-YiAC4gig.js';
|
|
2
|
+
export { E as Environment } from './types-YiAC4gig.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Sepolia testnet chain configuration
|
|
7
7
|
*/
|
|
8
8
|
declare const sepolia: {
|
|
9
|
-
name: string;
|
|
10
9
|
id: number;
|
|
10
|
+
name: string;
|
|
11
11
|
network: string;
|
|
12
12
|
coFheUrl: string;
|
|
13
13
|
verifierUrl: string;
|
|
@@ -19,8 +19,8 @@ declare const sepolia: {
|
|
|
19
19
|
* Arbitrum Sepolia testnet chain configuration
|
|
20
20
|
*/
|
|
21
21
|
declare const arbSepolia: {
|
|
22
|
-
name: string;
|
|
23
22
|
id: number;
|
|
23
|
+
name: string;
|
|
24
24
|
network: string;
|
|
25
25
|
coFheUrl: string;
|
|
26
26
|
verifierUrl: string;
|
|
@@ -32,8 +32,8 @@ declare const arbSepolia: {
|
|
|
32
32
|
* Base Sepolia testnet chain configuration
|
|
33
33
|
*/
|
|
34
34
|
declare const baseSepolia: {
|
|
35
|
-
name: string;
|
|
36
35
|
id: number;
|
|
36
|
+
name: string;
|
|
37
37
|
network: string;
|
|
38
38
|
coFheUrl: string;
|
|
39
39
|
verifierUrl: string;
|
|
@@ -45,8 +45,8 @@ declare const baseSepolia: {
|
|
|
45
45
|
* Hardhat local development chain configuration
|
|
46
46
|
*/
|
|
47
47
|
declare const hardhat: {
|
|
48
|
-
name: string;
|
|
49
48
|
id: number;
|
|
49
|
+
name: string;
|
|
50
50
|
network: string;
|
|
51
51
|
coFheUrl: string;
|
|
52
52
|
verifierUrl: string;
|
|
@@ -58,8 +58,8 @@ declare const hardhat: {
|
|
|
58
58
|
* Localcofhe chain configuration
|
|
59
59
|
*/
|
|
60
60
|
declare const localcofhe: {
|
|
61
|
-
name: string;
|
|
62
61
|
id: number;
|
|
62
|
+
name: string;
|
|
63
63
|
network: string;
|
|
64
64
|
coFheUrl: string;
|
|
65
65
|
verifierUrl: string;
|
|
@@ -69,8 +69,8 @@ declare const localcofhe: {
|
|
|
69
69
|
|
|
70
70
|
declare const chains: {
|
|
71
71
|
readonly sepolia: {
|
|
72
|
-
name: string;
|
|
73
72
|
id: number;
|
|
73
|
+
name: string;
|
|
74
74
|
network: string;
|
|
75
75
|
coFheUrl: string;
|
|
76
76
|
verifierUrl: string;
|
|
@@ -78,8 +78,8 @@ declare const chains: {
|
|
|
78
78
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
79
79
|
};
|
|
80
80
|
readonly arbSepolia: {
|
|
81
|
-
name: string;
|
|
82
81
|
id: number;
|
|
82
|
+
name: string;
|
|
83
83
|
network: string;
|
|
84
84
|
coFheUrl: string;
|
|
85
85
|
verifierUrl: string;
|
|
@@ -87,8 +87,8 @@ declare const chains: {
|
|
|
87
87
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
88
88
|
};
|
|
89
89
|
readonly baseSepolia: {
|
|
90
|
-
name: string;
|
|
91
90
|
id: number;
|
|
91
|
+
name: string;
|
|
92
92
|
network: string;
|
|
93
93
|
coFheUrl: string;
|
|
94
94
|
verifierUrl: string;
|
|
@@ -96,8 +96,8 @@ declare const chains: {
|
|
|
96
96
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
97
97
|
};
|
|
98
98
|
readonly hardhat: {
|
|
99
|
-
name: string;
|
|
100
99
|
id: number;
|
|
100
|
+
name: string;
|
|
101
101
|
network: string;
|
|
102
102
|
coFheUrl: string;
|
|
103
103
|
verifierUrl: string;
|
|
@@ -105,8 +105,8 @@ declare const chains: {
|
|
|
105
105
|
environment: "MOCK" | "TESTNET" | "MAINNET";
|
|
106
106
|
};
|
|
107
107
|
readonly localcofhe: {
|
|
108
|
-
name: string;
|
|
109
108
|
id: number;
|
|
109
|
+
name: string;
|
|
110
110
|
network: string;
|
|
111
111
|
coFheUrl: string;
|
|
112
112
|
verifierUrl: string;
|
package/dist/chains.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, localcofhe, sepolia } from './chunk-
|
|
1
|
+
export { arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, localcofhe, sepolia } from './chunk-TBLR7NNE.js';
|