@omegax/protocol-sdk 0.4.0 → 0.4.2

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 CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  TypeScript SDK for OmegaX protocol integrations on Solana.
4
4
 
5
+ ## Network status
6
+
7
+ - Current live network: **devnet beta**
8
+ - Mainnet support: **coming soon**
9
+ - Protocol UI: https://protocol.omegax.health
10
+ - Protocol repository: `omegaxhealth_protocol`
11
+ - Governance token:
12
+ - Mainnet CA: `4Aar9R14YMbEie6yh8WcH1gWXrBtfucoFjw6SpjXpump`
13
+ - Devnet: governance token distribution is via the protocol faucet
14
+
5
15
  It supports:
6
16
 
7
17
  - Oracle lifecycle, staking, attestation voting, and reward claims
@@ -39,6 +49,7 @@ npm install @omegax/protocol-sdk
39
49
  - Builders create **unsigned** transactions. Your app signs and submits them.
40
50
  - `programId` is explicit in SDK flows and should be passed from your runtime config.
41
51
  - Use `createProtocolClient(connection, programId)` for protocol operations.
52
+ - `createConnection({ network: 'mainnet' })` is available but warns that mainnet is coming soon.
42
53
 
43
54
  ## Quickstart
44
55
 
@@ -47,7 +58,11 @@ npm install @omegax/protocol-sdk
47
58
  ```ts
48
59
  import { createConnection, createProtocolClient, createRpcClient } from '@omegax/protocol-sdk';
49
60
 
50
- const connection = createConnection('https://api.mainnet-beta.solana.com', 'confirmed');
61
+ const connection = createConnection({
62
+ network: 'devnet',
63
+ rpcUrl: process.env.SOLANA_RPC_URL,
64
+ commitment: 'confirmed',
65
+ });
51
66
  const programId = 'Bn6eixac1QEEVErGBvBjxAd6pgB9e2q4XHvAkinQ5y1B';
52
67
 
53
68
  const protocol = createProtocolClient(connection, programId);
package/dist/protocol.js CHANGED
@@ -1172,7 +1172,7 @@ function encodeSubmitOutcomeAttestationData(params) {
1172
1172
  const outcomeHash = hashStringTo32(params.outcomeId);
1173
1173
  const replayHash = hashStringTo32(params.replayKey);
1174
1174
  const digest = params.attestationDigestHex
1175
- ? Buffer.from(params.attestationDigestHex.replace(/^0x/, ''), 'hex')
1175
+ ? Buffer.from(fromHex(params.attestationDigestHex, 32))
1176
1176
  : Buffer.from(hashStringTo32(`${params.cycleId}:${params.outcomeId}:${params.replayKey}`));
1177
1177
  if (digest.length !== 32) {
1178
1178
  throw new Error('attestation digest must be 32 bytes');
package/dist/rpc.d.ts CHANGED
@@ -1,4 +1,23 @@
1
1
  import { Connection, type Commitment } from '@solana/web3.js';
2
2
  import type { RpcClient } from './types.js';
3
+ export type OmegaXNetwork = 'devnet' | 'mainnet';
4
+ export type OmegaXNetworkInput = OmegaXNetwork | 'mainnet-beta';
5
+ export interface OmegaXConnectionOptions {
6
+ network?: OmegaXNetworkInput;
7
+ rpcUrl?: string;
8
+ commitment?: Commitment;
9
+ warnOnComingSoon?: boolean;
10
+ }
11
+ export interface OmegaXNetworkInfo {
12
+ network: OmegaXNetwork;
13
+ solanaCluster: 'devnet' | 'mainnet-beta';
14
+ defaultRpcUrl: string;
15
+ isAvailable: boolean;
16
+ status: 'live' | 'coming_soon';
17
+ statusMessage: string;
18
+ }
19
+ export declare const OMEGAX_NETWORKS: Record<OmegaXNetwork, OmegaXNetworkInfo>;
20
+ export declare function getOmegaXNetworkInfo(input?: OmegaXNetworkInput): OmegaXNetworkInfo;
3
21
  export declare function createConnection(rpcUrl: string, commitment?: Commitment): Connection;
22
+ export declare function createConnection(options?: OmegaXConnectionOptions): Connection;
4
23
  export declare function createRpcClient(connection: Connection): RpcClient;
package/dist/rpc.js CHANGED
@@ -1,7 +1,47 @@
1
1
  import { Connection, Transaction, } from '@solana/web3.js';
2
2
  import { normalizeClaimSimulationFailure } from './claims.js';
3
- export function createConnection(rpcUrl, commitment = 'confirmed') {
4
- return new Connection(rpcUrl, commitment);
3
+ export const OMEGAX_NETWORKS = {
4
+ devnet: {
5
+ network: 'devnet',
6
+ solanaCluster: 'devnet',
7
+ defaultRpcUrl: 'https://api.devnet.solana.com',
8
+ isAvailable: true,
9
+ status: 'live',
10
+ statusMessage: 'OmegaX devnet beta is live.',
11
+ },
12
+ mainnet: {
13
+ network: 'mainnet',
14
+ solanaCluster: 'mainnet-beta',
15
+ defaultRpcUrl: 'https://api.mainnet-beta.solana.com',
16
+ isAvailable: false,
17
+ status: 'coming_soon',
18
+ statusMessage: 'OmegaX mainnet support is coming soon. Please use devnet beta for now.',
19
+ },
20
+ };
21
+ function normalizeOmegaXNetwork(input) {
22
+ const normalized = String(input ?? 'devnet').trim().toLowerCase();
23
+ if (normalized === 'devnet')
24
+ return 'devnet';
25
+ if (normalized === 'mainnet' || normalized === 'mainnet-beta')
26
+ return 'mainnet';
27
+ throw new Error(`Unsupported OmegaX network "${String(input)}". Supported networks: "devnet", "mainnet".`);
28
+ }
29
+ export function getOmegaXNetworkInfo(input = 'devnet') {
30
+ const network = normalizeOmegaXNetwork(input);
31
+ return { ...OMEGAX_NETWORKS[network] };
32
+ }
33
+ export function createConnection(rpcUrlOrOptions = { network: 'devnet' }, commitment = 'confirmed') {
34
+ if (typeof rpcUrlOrOptions === 'string') {
35
+ return new Connection(rpcUrlOrOptions, commitment);
36
+ }
37
+ const options = rpcUrlOrOptions ?? {};
38
+ const resolvedCommitment = options.commitment ?? 'confirmed';
39
+ const networkInfo = getOmegaXNetworkInfo(options.network);
40
+ if (!networkInfo.isAvailable && (options.warnOnComingSoon ?? true)) {
41
+ console.warn(`[omegax-sdk] ${networkInfo.statusMessage}`);
42
+ }
43
+ const rpcUrl = options.rpcUrl ?? networkInfo.defaultRpcUrl;
44
+ return new Connection(rpcUrl, resolvedCommitment);
5
45
  }
6
46
  export function createRpcClient(connection) {
7
47
  return {
package/dist/utils.js CHANGED
@@ -86,7 +86,13 @@ export function toHex(bytes) {
86
86
  return Buffer.from(bytes).toString('hex');
87
87
  }
88
88
  export function fromHex(value, expectedLength) {
89
- const normalized = value.trim().toLowerCase().replace(/^0x/, '');
89
+ const normalized = value.trim().replace(/^0x/i, '');
90
+ if (normalized.length % 2 !== 0) {
91
+ throw new Error('invalid hex string: expected an even number of characters');
92
+ }
93
+ if (!/^[0-9a-fA-F]*$/.test(normalized)) {
94
+ throw new Error('invalid hex string: contains non-hex characters');
95
+ }
90
96
  const bytes = Buffer.from(normalized, 'hex');
91
97
  if (typeof expectedLength === 'number' && bytes.length !== expectedLength) {
92
98
  throw new Error(`invalid hex length: expected ${expectedLength}, got ${bytes.length}`);
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@omegax/protocol-sdk",
3
- "version": "0.4.0",
4
- "description": "TypeScript SDK for OmegaX protocol oracle, reward, and coverage integrations on Solana.",
3
+ "version": "0.4.2",
4
+ "description": "TypeScript SDK for OmegaX protocol integrations on Solana devnet beta (mainnet coming soon).",
5
5
  "keywords": [
6
6
  "omegax",
7
7
  "solana",
8
8
  "protocol",
9
9
  "oracle",
10
10
  "sdk",
11
- "health"
11
+ "health",
12
+ "devnet"
12
13
  ],
13
14
  "license": "Apache-2.0",
14
15
  "private": false,