Skip to content

Commit 419a1f0

Browse files
authored
Merge pull request #7 from Cygnus-Wealth/merge/refinery/da-a22a
feat: add decentralized RPC provider and privacy types
2 parents d4ea021 + d5e9984 commit 419a1f0

9 files changed

Lines changed: 470 additions & 6 deletions

File tree

etc/data-models.api.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@ export interface Price {
510510
value?: number;
511511
}
512512

513+
// @public
514+
export interface PrivacyConfig {
515+
privacyMode: boolean;
516+
queryJitterMs: number;
517+
rotateWithinTier: boolean;
518+
}
519+
513520
// @public
514521
export interface RetryConfig {
515522
baseDelayMs: number;
@@ -534,7 +541,9 @@ export interface RpcProviderConfig {
534541
chains: Record<string, ChainRpcConfig>;
535542
circuitBreaker: CircuitBreakerConfig;
536543
healthCheck: HealthCheckConfig;
544+
privacy: PrivacyConfig;
537545
retry: RetryConfig;
546+
userOverrides?: UserRpcConfig;
538547
}
539548

540549
// @public
@@ -548,8 +557,10 @@ export enum RpcProviderRole {
548557
// @public
549558
export enum RpcProviderType {
550559
COMMUNITY = "COMMUNITY",
560+
DECENTRALIZED = "DECENTRALIZED",
551561
MANAGED = "MANAGED",
552-
PUBLIC = "PUBLIC"
562+
PUBLIC = "PUBLIC",
563+
USER = "USER"
553564
}
554565

555566
// @public
@@ -656,6 +667,20 @@ export enum TransactionType {
656667
UNSTAKE = "UNSTAKE"
657668
}
658669

670+
// @public
671+
export interface UserRpcConfig {
672+
endpoints: UserRpcEndpoint[];
673+
mode: 'override' | 'prepend';
674+
}
675+
676+
// @public
677+
export interface UserRpcEndpoint {
678+
chainId: string;
679+
label?: string;
680+
url: string;
681+
wsUrl?: string;
682+
}
683+
659684
// @public
660685
export interface VaultPosition {
661686
apy?: number;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cygnus-wealth/data-models",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Shared TypeScript data models for CygnusWealth project",
55
"main": "dist/cjs/index.js",
66
"module": "dist/index.js",

src/enums/RpcProviderType.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ export enum RpcProviderType {
2828
PUBLIC = 'PUBLIC',
2929

3030
/** Community-run node (POKT, Llama Nodes) — variable reliability */
31-
COMMUNITY = 'COMMUNITY'
31+
COMMUNITY = 'COMMUNITY',
32+
33+
/** Decentralized RPC network (POKT Gateway, Lava Network) — censorship-resistant */
34+
DECENTRALIZED = 'DECENTRALIZED',
35+
36+
/** User-provided custom endpoint — unverified, user-managed */
37+
USER = 'USER'
3238
}

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export { CircuitBreakerConfig } from './interfaces/CircuitBreakerConfig';
8787
export { RetryConfig } from './interfaces/RetryConfig';
8888
export { HealthCheckConfig } from './interfaces/HealthCheckConfig';
8989
export { RpcProviderConfig } from './interfaces/RpcProviderConfig';
90+
export type { UserRpcEndpoint } from './interfaces/UserRpcEndpoint';
91+
export type { UserRpcConfig } from './interfaces/UserRpcConfig';
92+
export type { PrivacyConfig } from './interfaces/PrivacyConfig';
9093

9194
// Network Environment
9295
export { NetworkEnvironment, EnvironmentConfig } from './types/NetworkEnvironment';

src/interfaces/PrivacyConfig.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Privacy-related configuration for RPC request handling.
3+
*
4+
* Controls endpoint rotation and query obfuscation strategies to
5+
* reduce correlation of user activity across RPC providers.
6+
*
7+
* @example
8+
* ```typescript
9+
* import type { PrivacyConfig } from '@cygnus-wealth/data-models';
10+
*
11+
* const privacy: PrivacyConfig = {
12+
* rotateWithinTier: true,
13+
* privacyMode: true,
14+
* queryJitterMs: 150
15+
* };
16+
* ```
17+
*
18+
* @since 1.3.0
19+
* @stability extended
20+
*
21+
* @see {@link RpcProviderConfig} for top-level usage
22+
*/
23+
export interface PrivacyConfig {
24+
/** Rotate between endpoints of the same tier/role to avoid fingerprinting */
25+
rotateWithinTier: boolean;
26+
27+
/** Enable full privacy mode (distributes queries across providers) */
28+
privacyMode: boolean;
29+
30+
/** Random jitter added to query timing to resist timing analysis (in milliseconds) */
31+
queryJitterMs: number;
32+
}

src/interfaces/RpcProviderConfig.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { ChainRpcConfig } from './ChainRpcConfig';
22
import { CircuitBreakerConfig } from './CircuitBreakerConfig';
33
import { RetryConfig } from './RetryConfig';
44
import { HealthCheckConfig } from './HealthCheckConfig';
5+
import { PrivacyConfig } from './PrivacyConfig';
6+
import { UserRpcConfig } from './UserRpcConfig';
57

68
/**
79
* Top-level RPC provider configuration for multi-chain operations.
@@ -57,6 +59,8 @@ import { HealthCheckConfig } from './HealthCheckConfig';
5759
* @see {@link CircuitBreakerConfig} for failure isolation policy
5860
* @see {@link RetryConfig} for retry strategy
5961
* @see {@link HealthCheckConfig} for endpoint monitoring
62+
* @see {@link PrivacyConfig} for privacy and rotation policy
63+
* @see {@link UserRpcConfig} for user-provided endpoint overrides
6064
*/
6165
export interface RpcProviderConfig {
6266
/** Per-chain RPC configurations, keyed by chain ID string (e.g. "1", "137") */
@@ -70,4 +74,10 @@ export interface RpcProviderConfig {
7074

7175
/** Health check policy for endpoint monitoring */
7276
healthCheck: HealthCheckConfig;
77+
78+
/** Privacy and endpoint rotation policy */
79+
privacy: PrivacyConfig;
80+
81+
/** Optional user-provided RPC endpoint overrides */
82+
userOverrides?: UserRpcConfig;
7383
}

src/interfaces/UserRpcConfig.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { UserRpcEndpoint } from './UserRpcEndpoint';
2+
3+
/**
4+
* Configuration for user-provided RPC endpoint overrides.
5+
*
6+
* Determines how user-supplied endpoints interact with the
7+
* platform-managed endpoint list. In 'override' mode, user endpoints
8+
* completely replace managed endpoints for the given chains. In
9+
* 'prepend' mode, user endpoints are tried first before falling back
10+
* to managed endpoints.
11+
*
12+
* @example
13+
* ```typescript
14+
* import type { UserRpcConfig } from '@cygnus-wealth/data-models';
15+
*
16+
* const userConfig: UserRpcConfig = {
17+
* endpoints: [
18+
* { chainId: '1', url: 'https://my-eth.example.com/rpc', label: 'My ETH' }
19+
* ],
20+
* mode: 'prepend'
21+
* };
22+
* ```
23+
*
24+
* @since 1.3.0
25+
* @stability extended
26+
*
27+
* @see {@link UserRpcEndpoint} for individual endpoint definition
28+
* @see {@link RpcProviderConfig} for top-level usage
29+
*/
30+
export interface UserRpcConfig {
31+
/** List of user-provided RPC endpoints */
32+
endpoints: UserRpcEndpoint[];
33+
34+
/** How user endpoints interact with managed endpoints: 'override' replaces, 'prepend' adds before */
35+
mode: 'override' | 'prepend';
36+
}

src/interfaces/UserRpcEndpoint.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* A user-provided custom RPC endpoint configuration.
3+
*
4+
* Represents an RPC endpoint supplied by the end user, enabling
5+
* self-sovereign infrastructure choices. These endpoints are not
6+
* managed or verified by the platform.
7+
*
8+
* @example
9+
* ```typescript
10+
* import type { UserRpcEndpoint } from '@cygnus-wealth/data-models';
11+
*
12+
* const myNode: UserRpcEndpoint = {
13+
* chainId: '1',
14+
* url: 'https://my-private-node.example.com/rpc',
15+
* wsUrl: 'wss://my-private-node.example.com/ws',
16+
* label: 'My Private Ethereum Node'
17+
* };
18+
* ```
19+
*
20+
* @since 1.3.0
21+
* @stability extended
22+
*
23+
* @see {@link UserRpcConfig} for aggregating user endpoints
24+
*/
25+
export interface UserRpcEndpoint {
26+
/** Target chain ID as a string (e.g. "1", "137") */
27+
chainId: string;
28+
29+
/** HTTP(S) RPC endpoint URL */
30+
url: string;
31+
32+
/** Optional WebSocket endpoint URL for subscriptions */
33+
wsUrl?: string;
34+
35+
/** Optional human-readable label for the endpoint */
36+
label?: string;
37+
}

0 commit comments

Comments
 (0)