@molpha/sdk 0.2.0-dev-20260911175245 → 0.2.0-dev-20260913100330
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 +147 -17
- package/dist/index.d.ts +228 -12
- package/dist/index.js +506 -11
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/{wallet-udLZ5Iy0.d.ts → wallet-DwdBZgl1.d.ts} +78 -2
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Wallet } from '@anchor-lang/core';
|
|
2
|
-
import { S as Signer,
|
|
2
|
+
import { S as Signer, n as SolanaKeypair, M as MolphaWallet } from './wallet-DwdBZgl1.js';
|
|
3
3
|
import '@solana/kit';
|
|
4
4
|
|
|
5
5
|
/** Load a Solana CLI keypair JSON file (array of 64 bytes) into a `Keypair`. */
|
|
@@ -77,7 +77,7 @@ interface RegistrySelectionConfig {
|
|
|
77
77
|
interface SchnorrSignature {
|
|
78
78
|
/** 32-byte scalar, hex. */
|
|
79
79
|
s: string;
|
|
80
|
-
/** 20-
|
|
80
|
+
/** 20-bytecommitment address, hex. */
|
|
81
81
|
commitmentAddr: string;
|
|
82
82
|
/** 32-byte big-endian signers bitmap, hex. */
|
|
83
83
|
signersBitmap: string;
|
|
@@ -103,6 +103,82 @@ interface DataUpdateResult {
|
|
|
103
103
|
/** Whether the value was freshly fetched this round. */
|
|
104
104
|
fresh: boolean;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Registry selection policy as advertised by the gateway's `GET /v1/nodes`.
|
|
108
|
+
*
|
|
109
|
+
* Advisory only — the authoritative values come from the on-chain registry read
|
|
110
|
+
* ({@link RegistrySelectionConfig}). Useful to gateway-only callers with no Solana
|
|
111
|
+
* connection, who otherwise cannot size a paid source's eligible set.
|
|
112
|
+
*/
|
|
113
|
+
interface RegistryInfo {
|
|
114
|
+
/** `RegistryState.current_version`. */
|
|
115
|
+
version: number;
|
|
116
|
+
nodeCount: number;
|
|
117
|
+
redundancyBuffer: number;
|
|
118
|
+
}
|
|
119
|
+
/** `GET /v1/nodes` payload: the peer set plus the advisory registry policy. */
|
|
120
|
+
interface NodesInfo {
|
|
121
|
+
nodes: Node[];
|
|
122
|
+
/** Absent when the gateway could not read the chain. */
|
|
123
|
+
registry?: RegistryInfo;
|
|
124
|
+
}
|
|
125
|
+
/** EIP-712 domain fields of the token contract that settles a source payment. */
|
|
126
|
+
interface AssetDomain {
|
|
127
|
+
name: string;
|
|
128
|
+
version: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Signs a 32-byte EIP-712 digest, returning a 65-byte `r || s || v` signature.
|
|
132
|
+
* Private keys never leave the caller's process.
|
|
133
|
+
*/
|
|
134
|
+
interface EvmSigner {
|
|
135
|
+
/** 0x-prefixed 20-byte address that funds the authorizations. */
|
|
136
|
+
address: string;
|
|
137
|
+
signDigest(digest: Uint8Array): Promise<Uint8Array>;
|
|
138
|
+
}
|
|
139
|
+
/** A paywalled API source's own payment terms, read from its HTTP 402. */
|
|
140
|
+
interface UpstreamTerms {
|
|
141
|
+
x402Version: 1 | 2;
|
|
142
|
+
/** The source's `accepts` entry, echoed verbatim in the signed payload. */
|
|
143
|
+
requirements: Record<string, unknown>;
|
|
144
|
+
/** The source's network id, as it wrote it (CAIP-2 or an x402 v1 name). */
|
|
145
|
+
network: string;
|
|
146
|
+
chainId: number;
|
|
147
|
+
/** Token contract, 0x-prefixed — the EIP-712 verifying contract. */
|
|
148
|
+
asset: string;
|
|
149
|
+
payTo: string;
|
|
150
|
+
/** Price per source call, in token base units. */
|
|
151
|
+
amount: string;
|
|
152
|
+
maxTimeoutSeconds: number;
|
|
153
|
+
domain: AssetDomain;
|
|
154
|
+
/** The source URL these terms were read from. */
|
|
155
|
+
resource: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The gateway's relayed quote for a paywalled source, from `extensions.upstream`
|
|
159
|
+
* of a 402 response. It carries no payment terms of its own: the price, recipient
|
|
160
|
+
* and network come from the source's own 402, which the caller reads directly.
|
|
161
|
+
*/
|
|
162
|
+
interface UpstreamQuote {
|
|
163
|
+
resource: string;
|
|
164
|
+
signaturesRequired: number;
|
|
165
|
+
redundancyBuffer: number;
|
|
166
|
+
nodeCount: number;
|
|
167
|
+
/** Source fetches this round may perform, and so authorizations to sign. */
|
|
168
|
+
eligibleSetSize: number;
|
|
169
|
+
supportedX402Versions: number[];
|
|
170
|
+
/** The source's own rejection detail, when a round hit the paywall the hard way. */
|
|
171
|
+
error?: string;
|
|
172
|
+
}
|
|
173
|
+
/** Pays an API source that is itself x402-paywalled. */
|
|
174
|
+
interface SourcePaymentOptions {
|
|
175
|
+
/** Wallet that funds the source calls (see `createEvmSignerFromPrivateKey`). */
|
|
176
|
+
signer: EvmSigner;
|
|
177
|
+
/** Terms to use instead of probing the source for its 402. */
|
|
178
|
+
terms?: UpstreamTerms;
|
|
179
|
+
/** EIP-712 domain override for sources that omit `extra.name` / `extra.version`. */
|
|
180
|
+
assetDomain?: AssetDomain;
|
|
181
|
+
}
|
|
106
182
|
|
|
107
183
|
type SolanaAddress = Address | string | InstanceType<typeof web3.PublicKey>;
|
|
108
184
|
type SolanaConnection = InstanceType<typeof web3.Connection>;
|
|
@@ -130,4 +206,4 @@ declare function signerFromKeypair(keypair: SolanaKeypair): Signer;
|
|
|
130
206
|
/** Resolve the gateway auth signer for a Molpha wallet, if available. */
|
|
131
207
|
declare function gatewaySignerFromWallet(wallet: Wallet): Signer | undefined;
|
|
132
208
|
|
|
133
|
-
export { type APIConfig as A, type DataUpdateResult as D, type
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molpha/sdk",
|
|
3
|
-
"version": "0.2.0-dev-
|
|
3
|
+
"version": "0.2.0-dev-20260913100330",
|
|
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": {
|