@molpha/sdk 0.2.0-dev-20261011134323 → 0.3.0-dev-20261022065307

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,5 +1,5 @@
1
1
  export { Wallet } from '@anchor-lang/core';
2
- import { r as SolanaKeypair, M as MolphaWallet } from './wallet-DGe_pi93.js';
2
+ import { o as SolanaKeypair, M as MolphaWallet } from './wallet-BAxBy7hR.js';
3
3
  import '@solana/kit';
4
4
 
5
5
  /** Load a Solana CLI keypair JSON file (array of 64 bytes) into a `Keypair`. */
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { keypairFromSecretKey } from './chunk-H77BBZOL.js';
1
+ import { keypairFromSecretKey } from './chunk-KLHORIAC.js';
2
2
  import { readFileSync } from 'fs';
3
3
  import { Wallet } from '@anchor-lang/core';
4
4
  export { Wallet } from '@anchor-lang/core';
@@ -37,48 +37,7 @@ interface NodeKeyVerifierArgs {
37
37
  * private API request before secrets are encrypted or posted.
38
38
  */
39
39
  type NodeKeyVerifier = (args: NodeKeyVerifierArgs) => void | Promise<void>;
40
- /** The off-chain API definition a source resolves. */
41
- interface APIConfig {
42
- url: string;
43
- method?: "GET" | "POST" | "PUT";
44
- headers?: Record<string, string>;
45
- /** Expression that extracts the value from the HTTP response. */
46
- responseParser: string;
47
- /** Optional expression applied to the parsed value before packing. */
48
- valueTransform?: string;
49
- /**
50
- * Median tolerance mode. Part of the `sourceId`; OMIT it for exact mode. See
51
- * {@link AggregationConfig}.
52
- */
53
- aggregation?: AggregationConfig;
54
- }
55
- /** Numeric encoding of a tolerance-mode value: a signed `int256` scaled by `10^decimals`. */
56
- interface NumericConfig {
57
- type: "int256";
58
- /** Fractional digits, `0..255` (u8). The parsed decimal is scaled by `10^decimals`, rounded half to even. */
59
- decimals: number;
60
- }
61
- /**
62
- * Median tolerance aggregation. Instead of requiring every signer to fetch the identical
63
- * value, the selected nodes exchange signed observations, drop stale ones (`maxAgeMs`) and
64
- * those further than `maxDeviationBps` from the lower median, and sign the lower median of
65
- * `signaturesRequired` surviving observations. The signed value is a signed `int256`
66
- * (`encodeInt256Decimal`, `decodeInt256`, `formatInt256Decimal`).
67
- *
68
- * The whole object is hashed into the `sourceId` in exactly this key order. Requires
69
- * `signaturesRequired >= 3`. `mode: "exact"` is rejected: exact mode is expressed by
70
- * omitting `aggregation`.
71
- */
72
- interface AggregationConfig {
73
- mode: "tolerance";
74
- rule: "median";
75
- /** u32. Allowed deviation from the lower median, in basis points. */
76
- maxDeviationBps: number;
77
- /** Positive integer (u64 on the node, ≤ 2^53-1 here). Max observation age, in milliseconds. */
78
- maxAgeMs: number;
79
- numeric: NumericConfig;
80
- }
81
- /** ECDH-wrapped API config payload sent to selected nodes. */
40
+ /** ECDH-wrapped private source sent to selected nodes. */
82
41
  interface EncKeyBundle {
83
42
  ephemeralPub: string;
84
43
  nonceSym: string;
@@ -119,7 +78,7 @@ interface SchnorrSignature {
119
78
  interface AttestationPayload {
120
79
  /** 32-byte packed value, hex — the bytes covered by the signature. */
121
80
  value: string;
122
- /** 32-byte source id, hex (`deriveSourceId(apiConfig)`). */
81
+ /** 32-byte source id, hex (`deriveSourceId(source)`): the keccak256 of the source's canonical bytes. */
123
82
  sourceId: string;
124
83
  registryVersion: number;
125
84
  signaturesRequired: number;
@@ -134,10 +93,16 @@ interface AttestationPayload {
134
93
  interface Attestation {
135
94
  payload: AttestationPayload;
136
95
  signature: SchnorrSignature;
137
- /** Human-readable value (not signed). */
96
+ /** Human-readable value, rendered from the signed value by the source's output (not signed). */
138
97
  value: string;
139
98
  /** Whether the value was freshly fetched this round. */
140
99
  fresh: boolean;
100
+ /**
101
+ * For a source with a `keccak256` output: the bytes that were hashed to `payload.value`, hex. The
102
+ * gateway does not store it, so this is its only copy; submitting the attestation to Solana passes
103
+ * it as the raw value (at most 256 bytes) so the feed stores the preimage's hash with its kind.
104
+ */
105
+ valuePreimage?: string;
141
106
  }
142
107
  /**
143
108
  * Registry selection policy as advertised by the gateway's `GET /v1/nodes`.
@@ -253,4 +218,5 @@ declare function signerFromKeypair(keypair: SolanaKeypair): Signer;
253
218
  /** Resolve the gateway auth signer for a Molpha wallet, if available. */
254
219
  declare function gatewaySignerFromWallet(wallet: Wallet): Signer | undefined;
255
220
 
256
- export { type APIConfig as A, type EvmSigner as E, type MolphaWallet as M, type Node as N, type RegistrySelectionConfig as R, type Signer as S, type UpstreamQuote as U, type AssetDomain as a, type UpstreamTerms as b, type SourcePaymentOptions as c, type NodeKeyVerifier as d, type NodesInfo 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 };
221
+ export { gatewaySignerFromWallet as n, signerFromKeypair as s };
222
+ export type { AssetDomain as A, EvmSigner as E, MolphaWallet as M, Node as N, RegistrySelectionConfig as R, Signer as S, UpstreamQuote as U, UpstreamTerms as a, SourcePaymentOptions as b, NodeKeyVerifier as c, NodesInfo as d, Attestation as e, SolanaAccountMeta as f, SolanaConnection as g, SolanaAddress as h, NodeKeyVerifierArgs as i, AttestationPayload as j, EncKeyBundle as k, RegistryInfo as l, SchnorrSignature as m, SolanaKeypair as o };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molpha/sdk",
3
- "version": "0.2.0-dev-20261011134323",
3
+ "version": "0.3.0-dev-20261022065307",
4
4
  "description": "Molpha Consumer SDK — subscribe, request signed data from the gateway, submit attestations and read on-chain feeds.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -49,6 +49,9 @@
49
49
  "test": "vitest run",
50
50
  "test:watch": "vitest",
51
51
  "clean": "rm -rf dist",
52
+ "lint": "eslint .",
53
+ "lint:fix": "eslint . --fix",
54
+ "format": "prettier --write \"src/**/*.ts\"",
52
55
  "changeset": "changeset",
53
56
  "changeset:add-empty": "changeset add --empty",
54
57
  "version-packages": "changeset version",
@@ -57,14 +60,14 @@
57
60
  "release:dev": "changeset version --snapshot dev && pnpm build && npm publish --tag dev"
58
61
  },
59
62
  "dependencies": {
60
- "@noble/ciphers": "^2.2.0",
61
- "@noble/curves": "^2.2.0",
62
- "@noble/hashes": "^2.2.0",
63
- "@solana/kit": "^7.0.0",
64
- "canonicalize": "^3.0.0"
63
+ "@noble/ciphers": "^2.4.0",
64
+ "@noble/curves": "^2.4.0",
65
+ "@noble/hashes": "^2.4.0",
66
+ "@solana/kit": "^8.5.0",
67
+ "canonicalize": "^5.1.0"
65
68
  },
66
69
  "peerDependencies": {
67
- "@anchor-lang/core": "^1.1.2",
70
+ "@anchor-lang/core": "^1.2.1",
68
71
  "bn.js": "^5.1.2"
69
72
  },
70
73
  "peerDependenciesMeta": {
@@ -76,15 +79,21 @@
76
79
  }
77
80
  },
78
81
  "devDependencies": {
79
- "@anchor-lang/core": "^1.1.2",
80
- "@changesets/cli": "^2.31.0",
82
+ "@anchor-lang/core": "^1.2.1",
83
+ "@changesets/cli": "^3.0.3",
84
+ "@eslint/js": "^10.0.1",
81
85
  "@types/bn.js": "^5.2.0",
82
86
  "bn.js": "^5.2.3",
83
- "tsup": "^8.5.1",
87
+ "eslint": "^10.0.1",
88
+ "eslint-config-prettier": "^10.1.8",
89
+ "globals": "^17.13.0",
90
+ "prettier": "^3.9.10",
91
+ "tsup": "^9.0.0",
84
92
  "tsx": "^4.22.4",
85
93
  "typescript": "^5.7.3",
94
+ "typescript-eslint": "^8.72.0",
86
95
  "viem": "^2.52.2",
87
- "vitest": "^3.0.5"
96
+ "vitest": "^5.0.5"
88
97
  },
89
98
  "pnpm": {
90
99
  "overrides": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/solana/kit.ts"],"names":[],"mappings":";;;;AAaO,IAAM,qBAAA,GAAwB,QAAQ,6CAA6C;A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AO,IAAA,CAAK,oBAAA,CAAqB,mBAAA,CAAoB,EAAE,eAAe,CAAA;AACxE;AAEO,SAAS,qBAAqB,SAAA,EAAsC;AACzE,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,SAAS,CAAA;AAC7C","file":"chunk-H77BBZOL.js","sourcesContent":["import { web3 } from \"@anchor-lang/core\";\nimport { address, getAddressDecoder, getAddressEncoder, type Address } from \"@solana/kit\";\n\nexport type SolanaAddress = Address | string | InstanceType<typeof web3.PublicKey>;\nexport type SolanaConnection = InstanceType<typeof web3.Connection>;\nexport type SolanaKeypair = InstanceType<typeof web3.Keypair>;\nexport type SolanaInstruction = InstanceType<typeof web3.TransactionInstruction>;\nexport type SolanaAccountMeta = {\n pubkey: InstanceType<typeof web3.PublicKey>;\n isSigner: boolean;\n isWritable: boolean;\n};\n\nexport const TOKEN_PROGRAM_ADDRESS = address(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\");\nexport const ASSOCIATED_TOKEN_PROGRAM_ADDRESS = address(\n \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\",\n);\nexport const SYSTEM_PROGRAM_ADDRESS = address(\"11111111111111111111111111111111\");\n\nconst addressEncoder = getAddressEncoder();\nconst addressDecoder = getAddressDecoder();\n\nexport function toSolanaAddress(value: SolanaAddress): Address {\n return address(typeof value === \"string\" ? value : value.toBase58());\n}\n\nexport function toPublicKey(value: SolanaAddress): InstanceType<typeof web3.PublicKey> {\n return value instanceof web3.PublicKey ? value : new web3.PublicKey(value);\n}\n\nexport function addressBytes(value: SolanaAddress): Uint8Array {\n return Uint8Array.from(addressEncoder.encode(toSolanaAddress(value)));\n}\n\n/** Base58 `Address` from 32 raw bytes (e.g. a `Registry.nodes[i]` entry). */\nexport function addressFromBytes(bytes: Uint8Array): Address {\n return addressDecoder.decode(bytes);\n}\n\nexport function findProgramAddressSync(\n seeds: Uint8Array[],\n programAddress: SolanaAddress,\n): Address {\n const [pda] = web3.PublicKey.findProgramAddressSync(seeds, toPublicKey(programAddress));\n return toSolanaAddress(pda);\n}\n\nexport function findProgramPublicKeySync(\n seeds: Uint8Array[],\n programAddress: SolanaAddress,\n): InstanceType<typeof web3.PublicKey> {\n const [pda] = web3.PublicKey.findProgramAddressSync(seeds, toPublicKey(programAddress));\n return pda;\n}\n\nexport function getAssociatedTokenAddressSync(\n mint: SolanaAddress,\n owner: SolanaAddress,\n tokenProgram: SolanaAddress = TOKEN_PROGRAM_ADDRESS,\n): Address {\n return findProgramAddressSync(\n [addressBytes(owner), addressBytes(tokenProgram), addressBytes(mint)],\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n );\n}\n\nexport function setComputeUnitLimit(units: number): SolanaInstruction {\n return web3.ComputeBudgetProgram.setComputeUnitLimit({ units });\n}\n\nexport function setComputeUnitPrice(microLamports: number): SolanaInstruction {\n return web3.ComputeBudgetProgram.setComputeUnitPrice({ microLamports });\n}\n\nexport function keypairFromSecretKey(secretKey: Uint8Array): SolanaKeypair {\n return web3.Keypair.fromSecretKey(secretKey);\n}\n\nexport function generateKeypair(): SolanaKeypair {\n return web3.Keypair.generate();\n}\n"]}