@molpha/sdk 0.2.0-dev-20260913100330 → 0.2.0-dev-20261001125531

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/dist/utils.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  export { Wallet } from '@anchor-lang/core';
2
- import { S as Signer, n as SolanaKeypair, M as MolphaWallet } from './wallet-DwdBZgl1.js';
2
+ import { r as SolanaKeypair, M as MolphaWallet } from './wallet-HfGXPpOp.js';
3
3
  import '@solana/kit';
4
4
 
5
5
  /** Load a Solana CLI keypair JSON file (array of 64 bytes) into a `Keypair`. */
6
6
  declare function loadKeypair(path: string): SolanaKeypair;
7
7
  /** Anchor `Wallet` backed by a keypair file (gateway auth derived from the same key). */
8
8
  declare function walletFromKeypairFile(path: string): MolphaWallet;
9
- /** @deprecated Use `walletFromKeypairFile`. */
10
- declare const nodeWalletFromFile: typeof walletFromKeypairFile;
11
- /** @deprecated Use `walletFromKeypairFile` — gateway auth is derived from the same keypair. */
12
- declare function keypairFileSigner(path: string): Signer;
13
9
 
14
- export { MolphaWallet, keypairFileSigner, loadKeypair, nodeWalletFromFile, walletFromKeypairFile };
10
+ export { MolphaWallet, loadKeypair, walletFromKeypairFile };
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { keypairFromSecretKey, signerFromKeypair } from './chunk-DT6IKCWB.js';
1
+ import { keypairFromSecretKey } from './chunk-2X22JY7Q.js';
2
2
  import { readFileSync } from 'fs';
3
3
  import { Wallet } from '@anchor-lang/core';
4
4
  export { Wallet } from '@anchor-lang/core';
@@ -10,11 +10,7 @@ function loadKeypair(path) {
10
10
  function walletFromKeypairFile(path) {
11
11
  return new Wallet(loadKeypair(path));
12
12
  }
13
- var nodeWalletFromFile = walletFromKeypairFile;
14
- function keypairFileSigner(path) {
15
- return signerFromKeypair(loadKeypair(path));
16
- }
17
13
 
18
- export { keypairFileSigner, loadKeypair, nodeWalletFromFile, walletFromKeypairFile };
14
+ export { loadKeypair, walletFromKeypairFile };
19
15
  //# sourceMappingURL=utils.js.map
20
16
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts"],"names":[],"mappings":";;;;;AAWO,SAAS,YAAY,IAAA,EAA6B;AACvD,EAAA,MAAM,MAAM,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,IAAA,EAAM,OAAO,CAAC,CAAA;AAClD,EAAA,OAAO,oBAAA,CAAqB,UAAA,CAAW,IAAA,CAAK,GAAG,CAAC,CAAA;AAClD;AAGO,SAAS,sBAAsB,IAAA,EAA4B;AAChE,EAAA,OAAO,IAAI,MAAA,CAAO,WAAA,CAAY,IAAI,CAAC,CAAA;AACrC;AAGO,IAAM,kBAAA,GAAqB;AAG3B,SAAS,kBAAkB,IAAA,EAAsB;AACtD,EAAA,OAAO,iBAAA,CAAkB,WAAA,CAAY,IAAI,CAAC,CAAA;AAC5C","file":"utils.js","sourcesContent":["/**\n * `@molpha/sdk/utils` — Node.js-only helpers (fs + keypair files). Kept out of the main\n * entry so browser bundles never pull in `fs`.\n */\nimport { readFileSync } from \"node:fs\";\nimport { Wallet } from \"@anchor-lang/core\";\nimport type { Signer } from \"./core/types.js\";\nimport { keypairFromSecretKey, type SolanaKeypair } from \"./solana/kit.js\";\nimport { signerFromKeypair, type MolphaWallet } from \"./wallet.js\";\n\n/** Load a Solana CLI keypair JSON file (array of 64 bytes) into a `Keypair`. */\nexport function loadKeypair(path: string): SolanaKeypair {\n const raw = JSON.parse(readFileSync(path, \"utf-8\")) as number[];\n return keypairFromSecretKey(Uint8Array.from(raw));\n}\n\n/** Anchor `Wallet` backed by a keypair file (gateway auth derived from the same key). */\nexport function walletFromKeypairFile(path: string): MolphaWallet {\n return new Wallet(loadKeypair(path));\n}\n\n/** @deprecated Use `walletFromKeypairFile`. */\nexport const nodeWalletFromFile = walletFromKeypairFile;\n\n/** @deprecated Use `walletFromKeypairFile` — gateway auth is derived from the same keypair. */\nexport function keypairFileSigner(path: string): Signer {\n return signerFromKeypair(loadKeypair(path));\n}\n\nexport { Wallet };\nexport type { MolphaWallet };\n"]}
1
+ {"version":3,"sources":["../src/utils.ts"],"names":[],"mappings":";;;;;AAUO,SAAS,YAAY,IAAA,EAA6B;AACvD,EAAA,MAAM,MAAM,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,IAAA,EAAM,OAAO,CAAC,CAAA;AAClD,EAAA,OAAO,oBAAA,CAAqB,UAAA,CAAW,IAAA,CAAK,GAAG,CAAC,CAAA;AAClD;AAGO,SAAS,sBAAsB,IAAA,EAA4B;AAChE,EAAA,OAAO,IAAI,MAAA,CAAO,WAAA,CAAY,IAAI,CAAC,CAAA;AACrC","file":"utils.js","sourcesContent":["/**\n * `@molpha/sdk/utils` — Node.js-only helpers (fs + keypair files). Kept out of the main\n * entry so browser bundles never pull in `fs`.\n */\nimport { readFileSync } from \"node:fs\";\nimport { Wallet } from \"@anchor-lang/core\";\nimport { keypairFromSecretKey, type SolanaKeypair } from \"./solana/kit.js\";\nimport type { MolphaWallet } from \"./wallet.js\";\n\n/** Load a Solana CLI keypair JSON file (array of 64 bytes) into a `Keypair`. */\nexport function loadKeypair(path: string): SolanaKeypair {\n const raw = JSON.parse(readFileSync(path, \"utf-8\")) as number[];\n return keypairFromSecretKey(Uint8Array.from(raw));\n}\n\n/** Anchor `Wallet` backed by a keypair file (gateway auth derived from the same key). */\nexport function walletFromKeypairFile(path: string): MolphaWallet {\n return new Wallet(loadKeypair(path));\n}\n\nexport { Wallet };\nexport type { MolphaWallet };\n"]}
@@ -44,6 +44,37 @@ interface APIConfig {
44
44
  responseParser: string;
45
45
  /** Optional expression applied to the parsed value before packing. */
46
46
  valueTransform?: string;
47
+ /**
48
+ * Median tolerance mode. Part of the `sourceId`; OMIT it for exact mode. See
49
+ * {@link AggregationConfig}.
50
+ */
51
+ aggregation?: AggregationConfig;
52
+ }
53
+ /** Numeric encoding of a tolerance-mode value: a signed `int256` scaled by `10^decimals`. */
54
+ interface NumericConfig {
55
+ type: "int256";
56
+ /** Fractional digits, `0..255` (u8). The parsed decimal is scaled by `10^decimals`, rounded half to even. */
57
+ decimals: number;
58
+ }
59
+ /**
60
+ * Median tolerance aggregation. Instead of requiring every signer to fetch the identical
61
+ * value, the selected nodes exchange signed observations, drop stale ones (`maxAgeMs`) and
62
+ * those further than `maxDeviationBps` from the lower median, and sign the lower median of
63
+ * `signaturesRequired` surviving observations. The signed value is a signed `int256`
64
+ * (`encodeInt256Decimal`, `decodeInt256`, `formatInt256Decimal`).
65
+ *
66
+ * The whole object is hashed into the `sourceId` in exactly this key order. Requires
67
+ * `signaturesRequired >= 3`. `mode: "exact"` is rejected: exact mode is expressed by
68
+ * omitting `aggregation`.
69
+ */
70
+ interface AggregationConfig {
71
+ mode: "tolerance";
72
+ rule: "median";
73
+ /** u32. Allowed deviation from the lower median, in basis points. */
74
+ maxDeviationBps: number;
75
+ /** Positive integer (u64 on the node, ≤ 2^53-1 here). Max observation age, in milliseconds. */
76
+ maxAgeMs: number;
77
+ numeric: NumericConfig;
47
78
  }
48
79
  /** ECDH-wrapped API config payload sent to selected nodes. */
49
80
  interface EncKeyBundle {
@@ -82,24 +113,27 @@ interface SchnorrSignature {
82
113
  /** 32-byte big-endian signers bitmap, hex. */
83
114
  signersBitmap: string;
84
115
  }
85
- /** A completed gateway round, ready to submit on-chain. */
86
- interface DataUpdateResult {
116
+ /** Signed oracle attestation payload (cross-VM `AttestationPayload`). */
117
+ interface AttestationPayload {
118
+ /** 32-byte packed value, hex — the bytes covered by the signature. */
119
+ value: string;
87
120
  /** 32-byte source id, hex (`deriveSourceId(apiConfig)`). */
88
121
  sourceId: string;
89
- /** Human-readable value. */
90
- value: string;
91
- /** 32-byte packed value, hex — the bytes covered by the signature. */
92
- valuePacked: string;
93
- /** canonicalTimestamp (seconds). */
94
- timestamp: number;
95
122
  registryVersion: number;
96
123
  signaturesRequired: number;
97
- /** 32-byte big-endian bitmap, hex. */
98
- signersBitmap: string;
99
- /** 32-byte scalar, hex. */
100
- s: string;
101
- /** 20-byte commitment address, hex. */
102
- commitmentAddr: string;
124
+ /** Unix seconds (u64). */
125
+ canonicalTimestamp: number;
126
+ }
127
+ /**
128
+ * Threshold-signed oracle attestation from a completed gateway round, ready to submit on-chain.
129
+ * Matches the cross-VM `Attestation` (`payload` + `signature`). `value` and `fresh` are gateway
130
+ * metadata and are not part of the signed struct.
131
+ */
132
+ interface Attestation {
133
+ payload: AttestationPayload;
134
+ signature: SchnorrSignature;
135
+ /** Human-readable value (not signed). */
136
+ value: string;
103
137
  /** Whether the value was freshly fetched this round. */
104
138
  fresh: boolean;
105
139
  }
@@ -206,4 +240,4 @@ declare function signerFromKeypair(keypair: SolanaKeypair): Signer;
206
240
  /** Resolve the gateway auth signer for a Molpha wallet, if available. */
207
241
  declare function gatewaySignerFromWallet(wallet: Wallet): Signer | undefined;
208
242
 
209
- export { type APIConfig as A, type DataUpdateResult as D, type EvmSigner as E, type MolphaWallet as M, type NodeKeyVerifier as N, type RegistrySelectionConfig as R, type Signer as S, type UpstreamQuote as U, type AssetDomain as a, type UpstreamTerms as b, type Node as c, type NodesInfo as d, type SourcePaymentOptions as e, type SolanaAccountMeta as f, type SolanaConnection as g, type SolanaAddress as h, type NodeKeyVerifierArgs as i, type EncKeyBundle as j, type RegistryInfo as k, type SchnorrSignature as l, gatewaySignerFromWallet as m, type SolanaKeypair as n, signerFromKeypair as s };
243
+ export { type APIConfig as A, type EvmSigner as E, type MolphaWallet as M, type NodeKeyVerifier as N, type RegistrySelectionConfig as R, type Signer as S, type UpstreamQuote as U, type AssetDomain as a, type UpstreamTerms as b, type Node as c, type NodesInfo as d, type SourcePaymentOptions as e, type Attestation as f, type SolanaAccountMeta as g, type SolanaConnection as h, type SolanaAddress as i, type NodeKeyVerifierArgs as j, type AggregationConfig as k, type AttestationPayload as l, type EncKeyBundle as m, type NumericConfig as n, type RegistryInfo as o, type SchnorrSignature as p, gatewaySignerFromWallet as q, type SolanaKeypair as r, signerFromKeypair as s };