@effect-blockchain/solana 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/SolanaAddress.d.ts +21 -0
- package/dist/SolanaAddress.d.ts.map +1 -0
- package/dist/SolanaAddress.js +33 -0
- package/dist/SolanaAddress.js.map +1 -0
- package/dist/SolanaIndexer.d.ts +156 -0
- package/dist/SolanaIndexer.d.ts.map +1 -0
- package/dist/SolanaIndexer.js +227 -0
- package/dist/SolanaIndexer.js.map +1 -0
- package/dist/SolanaNetwork.d.ts +64 -0
- package/dist/SolanaNetwork.d.ts.map +1 -0
- package/dist/SolanaNetwork.js +84 -0
- package/dist/SolanaNetwork.js.map +1 -0
- package/dist/SolanaRpc.d.ts +258 -0
- package/dist/SolanaRpc.d.ts.map +1 -0
- package/dist/SolanaRpc.js +154 -0
- package/dist/SolanaRpc.js.map +1 -0
- package/dist/SolanaTransactionHash.d.ts +14 -0
- package/dist/SolanaTransactionHash.d.ts.map +1 -0
- package/dist/SolanaTransactionHash.js +34 -0
- package/dist/SolanaTransactionHash.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/bigIntJson.d.ts +2 -0
- package/dist/internal/bigIntJson.d.ts.map +1 -0
- package/dist/internal/bigIntJson.js +9 -0
- package/dist/internal/bigIntJson.js.map +1 -0
- package/dist/internal/rpcMethods.d.ts +2 -0
- package/dist/internal/rpcMethods.d.ts.map +1 -0
- package/dist/internal/rpcMethods.js +105 -0
- package/dist/internal/rpcMethods.js.map +1 -0
- package/package.json +66 -3
- package/src/SolanaAddress.ts +40 -0
- package/src/SolanaIndexer.ts +376 -0
- package/src/SolanaNetwork.ts +105 -0
- package/src/SolanaRpc.ts +387 -0
- package/src/SolanaTransactionHash.ts +41 -0
- package/src/index.ts +30 -0
- package/src/internal/bigIntJson.ts +18 -0
- package/src/internal/rpcMethods.ts +143 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed, read-only Solana JSON-RPC methods over an ordered list of endpoints with fallback.
|
|
3
|
+
*
|
|
4
|
+
* A call starts at the first endpoint and moves to the next one on failure, except on `WrongNetwork`. Each endpoint
|
|
5
|
+
* is checked once to serve the configured network (`getGenesisHash`). Every method is a read, so retries and fallback
|
|
6
|
+
* are safe. Methods are named after the JSON-RPC method. Every JSON integer in a reply is read as an exact `bigint`,
|
|
7
|
+
* so lamport amounts above 2^53 are never rounded.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import type { SolanaAddress } from "@effect-blockchain/solana/SolanaAddress"
|
|
12
|
+
* import * as SolanaRpc from "@effect-blockchain/solana/SolanaRpc"
|
|
13
|
+
* import * as Effect from "effect/Effect"
|
|
14
|
+
*
|
|
15
|
+
* declare const address: SolanaAddress
|
|
16
|
+
*
|
|
17
|
+
* // the 10 latest finalized transactions touching `address`
|
|
18
|
+
* const latest = Effect.gen(function*() {
|
|
19
|
+
* const rpc = yield* SolanaRpc.SolanaRpc
|
|
20
|
+
* const signatures = yield* rpc.getSignaturesForAddress({ address, limit: 10, commitment: "finalized" })
|
|
21
|
+
* return yield* Effect.forEach(signatures, ({ signature }) =>
|
|
22
|
+
* rpc.getTransaction({ signature, commitment: "finalized" }))
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @since 0.1.0
|
|
27
|
+
*/
|
|
28
|
+
import * as JsonRpc from "@effect-blockchain/core/JsonRpc";
|
|
29
|
+
import type * as Arr from "effect/Array";
|
|
30
|
+
import * as Config from "effect/Config";
|
|
31
|
+
import * as Context from "effect/Context";
|
|
32
|
+
import type * as Duration from "effect/Duration";
|
|
33
|
+
import * as Effect from "effect/Effect";
|
|
34
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
35
|
+
import * as Layer from "effect/Layer";
|
|
36
|
+
import type * as Redacted from "effect/Redacted";
|
|
37
|
+
import * as Schema from "effect/Schema";
|
|
38
|
+
import type { SolanaAddress } from "./SolanaAddress.ts";
|
|
39
|
+
import { type SolanaGenesisHash, type SolanaNetwork } from "./SolanaNetwork.ts";
|
|
40
|
+
import type { SolanaTransactionHash } from "./SolanaTransactionHash.ts";
|
|
41
|
+
/**
|
|
42
|
+
* A JSON-RPC endpoint. The `name` is shown in errors and spans, the `url` is never logged.
|
|
43
|
+
*
|
|
44
|
+
* @since 0.1.0
|
|
45
|
+
* @category models
|
|
46
|
+
*/
|
|
47
|
+
export interface SolanaRpcEndpoint {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly url: Redacted.Redacted<string>;
|
|
50
|
+
}
|
|
51
|
+
declare const SolanaRpcError_base: Schema.Class<SolanaRpcError, Schema.TaggedStruct<"SolanaRpcError", {
|
|
52
|
+
readonly reason: Schema.Union<readonly [typeof JsonRpc.Unavailable, typeof JsonRpc.InvalidResponse, typeof JsonRpc.Lagging, typeof JsonRpc.Pruned, typeof JsonRpc.Rejected, typeof JsonRpc.WrongNetwork]>;
|
|
53
|
+
readonly method: Schema.String;
|
|
54
|
+
readonly endpoint: Schema.String;
|
|
55
|
+
readonly code: Schema.optional<Schema.Number>;
|
|
56
|
+
readonly cause: Schema.Defect;
|
|
57
|
+
}>, import("effect/Cause").YieldableError>;
|
|
58
|
+
/**
|
|
59
|
+
* A failed call: its `reason` (a {@link JsonRpc.Reason}, matched with `Effect.catchReason`), the JSON-RPC error code or
|
|
60
|
+
* HTTP status as `code`, and a `cause` without the endpoint URL. After several endpoints, the error is the last one
|
|
61
|
+
* and `cause` is an `AggregateError` of each endpoint's error, in order.
|
|
62
|
+
*
|
|
63
|
+
* On Solana, `Unavailable` includes the codes 429, -32603, -32005 and -32019, `Lagging` a `minContextSlot` not reached
|
|
64
|
+
* or a block not available yet, and `Pruned` a cleaned-up or skipped slot or a `getTransaction` returning `null`.
|
|
65
|
+
*
|
|
66
|
+
* @since 0.1.0
|
|
67
|
+
* @category errors
|
|
68
|
+
*/
|
|
69
|
+
export declare class SolanaRpcError extends SolanaRpcError_base {
|
|
70
|
+
/**
|
|
71
|
+
* @since 0.1.0
|
|
72
|
+
*/
|
|
73
|
+
get message(): string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The commitment a read waits for. `processed` is left out: a processed block can still be dropped.
|
|
77
|
+
*
|
|
78
|
+
* @since 0.1.0
|
|
79
|
+
* @category models
|
|
80
|
+
*/
|
|
81
|
+
export type SolanaCommitment = "confirmed" | "finalized";
|
|
82
|
+
/**
|
|
83
|
+
* One `getSignaturesForAddress` page: signatures touching `address`, newest first, older than `before` and newer than
|
|
84
|
+
* `until` when given, at most `limit` (the node's default and maximum is 1000).
|
|
85
|
+
*
|
|
86
|
+
* @since 0.1.0
|
|
87
|
+
* @category models
|
|
88
|
+
*/
|
|
89
|
+
export interface SolanaSignaturesQuery {
|
|
90
|
+
readonly address: SolanaAddress;
|
|
91
|
+
readonly before?: SolanaTransactionHash | undefined;
|
|
92
|
+
readonly until?: SolanaTransactionHash | undefined;
|
|
93
|
+
readonly limit?: number | undefined;
|
|
94
|
+
readonly commitment: SolanaCommitment;
|
|
95
|
+
/**
|
|
96
|
+
* An endpoint that honours it answers `Lagging` until it has reached this slot. Some providers ignore it and answer
|
|
97
|
+
* from wherever they are, so a caller that needs the guarantee checks the head itself, e.g. with `getSlot`.
|
|
98
|
+
*/
|
|
99
|
+
readonly minContextSlot?: bigint | undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A `getSignaturesForAddress` entry. `blockTime` is a Unix timestamp in seconds, `null` when the node does not know
|
|
103
|
+
* it. `err` is the raw transaction error as JSON (integers as decimal strings), `null` when the transaction succeeded.
|
|
104
|
+
*
|
|
105
|
+
* @since 0.1.0
|
|
106
|
+
* @category models
|
|
107
|
+
*/
|
|
108
|
+
export interface SolanaSignatureInfo {
|
|
109
|
+
readonly signature: SolanaTransactionHash;
|
|
110
|
+
readonly slot: bigint;
|
|
111
|
+
readonly blockTime: bigint | null;
|
|
112
|
+
readonly err: Schema.Json;
|
|
113
|
+
readonly memo: string | null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The `getTransaction` encodings. `base64` is the signed wire transaction, for the `@solana/kit` decoders (e.g.
|
|
117
|
+
* `getTransactionDecoder`) and for storing the exact bytes. `json` splits it into signatures, account keys and compiled
|
|
118
|
+
* instructions; `jsonParsed` is not offered, as its shape depends on the programs the node knows.
|
|
119
|
+
*
|
|
120
|
+
* @since 0.1.0
|
|
121
|
+
* @category models
|
|
122
|
+
*/
|
|
123
|
+
export type SolanaTransactionEncoding = "base64" | "json";
|
|
124
|
+
/**
|
|
125
|
+
* A compiled instruction of a `json` transaction: `programIdIndex` and `accounts` index the message's account keys,
|
|
126
|
+
* followed by the addresses loaded from the lookup tables (writable then readonly), and `data` is base58.
|
|
127
|
+
*
|
|
128
|
+
* @since 0.1.0
|
|
129
|
+
* @category models
|
|
130
|
+
*/
|
|
131
|
+
export interface SolanaCompiledInstruction {
|
|
132
|
+
readonly programIdIndex: number;
|
|
133
|
+
readonly accounts: ReadonlyArray<number>;
|
|
134
|
+
readonly data: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A `json` transaction. `addressTableLookups` is absent from legacy transactions.
|
|
138
|
+
*
|
|
139
|
+
* @since 0.1.0
|
|
140
|
+
* @category models
|
|
141
|
+
*/
|
|
142
|
+
export interface SolanaJsonTransaction {
|
|
143
|
+
readonly signatures: ReadonlyArray<SolanaTransactionHash>;
|
|
144
|
+
readonly message: {
|
|
145
|
+
readonly accountKeys: ReadonlyArray<SolanaAddress>;
|
|
146
|
+
readonly header: {
|
|
147
|
+
readonly numRequiredSignatures: number;
|
|
148
|
+
readonly numReadonlySignedAccounts: number;
|
|
149
|
+
readonly numReadonlyUnsignedAccounts: number;
|
|
150
|
+
};
|
|
151
|
+
readonly recentBlockhash: string;
|
|
152
|
+
readonly instructions: ReadonlyArray<SolanaCompiledInstruction>;
|
|
153
|
+
readonly addressTableLookups?: ReadonlyArray<{
|
|
154
|
+
readonly accountKey: SolanaAddress;
|
|
155
|
+
readonly writableIndexes: ReadonlyArray<number>;
|
|
156
|
+
readonly readonlyIndexes: ReadonlyArray<number>;
|
|
157
|
+
}>;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The `transaction` of a `getTransaction` result, by encoding: the base64 wire transaction or a
|
|
162
|
+
* {@link SolanaJsonTransaction}.
|
|
163
|
+
*
|
|
164
|
+
* @since 0.1.0
|
|
165
|
+
* @category models
|
|
166
|
+
*/
|
|
167
|
+
export interface SolanaEncodedTransaction {
|
|
168
|
+
readonly base64: string;
|
|
169
|
+
readonly json: SolanaJsonTransaction;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A `getTransaction` result. `transaction` follows the requested encoding (see {@link SolanaEncodedTransaction}).
|
|
173
|
+
* `meta` is the raw status meta (fee, balances, logs, inner instructions...) as JSON with every integer as a decimal
|
|
174
|
+
* string, so u64 values are exact and the value can be stored as is. It is `null` when the node does not have it.
|
|
175
|
+
*
|
|
176
|
+
* @since 0.1.0
|
|
177
|
+
* @category models
|
|
178
|
+
*/
|
|
179
|
+
export interface SolanaTransactionInfo<Encoding extends SolanaTransactionEncoding = "base64"> {
|
|
180
|
+
readonly slot: bigint;
|
|
181
|
+
readonly blockTime: bigint | null;
|
|
182
|
+
readonly transaction: SolanaEncodedTransaction[Encoding];
|
|
183
|
+
readonly meta: Schema.Json;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The `getTransaction` options.
|
|
187
|
+
*
|
|
188
|
+
* @since 0.1.0
|
|
189
|
+
* @category models
|
|
190
|
+
*/
|
|
191
|
+
export interface SolanaTransactionQuery {
|
|
192
|
+
readonly signature: SolanaTransactionHash;
|
|
193
|
+
readonly commitment: SolanaCommitment;
|
|
194
|
+
}
|
|
195
|
+
declare const SolanaRpc_base: Context.ServiceClass<SolanaRpc, "@effect-blockchain/solana/SolanaRpc", {
|
|
196
|
+
readonly network: SolanaNetwork;
|
|
197
|
+
/** `getGenesisHash`, verified against `network` once per endpoint then served from that check. */
|
|
198
|
+
readonly getGenesisHash: Effect.Effect<SolanaGenesisHash, SolanaRpcError>;
|
|
199
|
+
/** `getSlot` */
|
|
200
|
+
readonly getSlot: (options: {
|
|
201
|
+
readonly commitment: SolanaCommitment;
|
|
202
|
+
}) => Effect.Effect<bigint, SolanaRpcError>;
|
|
203
|
+
/** `getSignaturesForAddress`, one page. */
|
|
204
|
+
readonly getSignaturesForAddress: (query: SolanaSignaturesQuery) => Effect.Effect<ReadonlyArray<SolanaSignatureInfo>, SolanaRpcError>;
|
|
205
|
+
/**
|
|
206
|
+
* `getTransaction` in `encoding`, `base64` by default, versioned transactions included. A transaction the endpoint
|
|
207
|
+
* lacks fails `Pruned`.
|
|
208
|
+
*/
|
|
209
|
+
readonly getTransaction: {
|
|
210
|
+
(options: SolanaTransactionQuery & {
|
|
211
|
+
readonly encoding?: "base64" | undefined;
|
|
212
|
+
}): Effect.Effect<SolanaTransactionInfo, SolanaRpcError>;
|
|
213
|
+
<Encoding extends SolanaTransactionEncoding>(options: SolanaTransactionQuery & {
|
|
214
|
+
readonly encoding: Encoding;
|
|
215
|
+
}): Effect.Effect<SolanaTransactionInfo<Encoding>, SolanaRpcError>;
|
|
216
|
+
};
|
|
217
|
+
}>;
|
|
218
|
+
/**
|
|
219
|
+
* @since 0.1.0
|
|
220
|
+
* @category services
|
|
221
|
+
*/
|
|
222
|
+
export declare class SolanaRpc extends SolanaRpc_base {
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Builds a {@link SolanaRpc} over `endpoints`, tried in order, sending requests with the provided `HttpClient`
|
|
226
|
+
* (e.g. `FetchHttpClient.layer`). `timeout` (default 30 seconds) bounds each attempt, `retries` (default 3) and
|
|
227
|
+
* `retryDelay` (default 500 millis) set the backoff before falling back: see {@link JsonRpc.Unavailable}.
|
|
228
|
+
*
|
|
229
|
+
* @since 0.1.0
|
|
230
|
+
* @category layers
|
|
231
|
+
*/
|
|
232
|
+
export declare const layer: (options: {
|
|
233
|
+
readonly network: SolanaNetwork;
|
|
234
|
+
readonly endpoints: Arr.NonEmptyReadonlyArray<SolanaRpcEndpoint>;
|
|
235
|
+
readonly timeout?: Duration.Input | undefined;
|
|
236
|
+
readonly retries?: number | undefined;
|
|
237
|
+
readonly retryDelay?: Duration.Input | undefined;
|
|
238
|
+
}) => Layer.Layer<SolanaRpc, never, HttpClient.HttpClient>;
|
|
239
|
+
/**
|
|
240
|
+
* Builds an {@link SolanaRpc} like {@link layer}, reading the options from `Config`. Endpoint URLs stay `Redacted`.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* import * as SolanaRpc from "@effect-blockchain/solana/SolanaRpc"
|
|
245
|
+
* import * as Config from "effect/Config"
|
|
246
|
+
*
|
|
247
|
+
* const RpcLive = SolanaRpc.layerConfig({
|
|
248
|
+
* network: Config.succeed("Solana"),
|
|
249
|
+
* endpoints: Config.all([Config.all({ name: Config.succeed("main"), url: Config.Redacted("SOLANA_RPC_URL") })])
|
|
250
|
+
* })
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @since 0.1.0
|
|
254
|
+
* @category layers
|
|
255
|
+
*/
|
|
256
|
+
export declare const layerConfig: (options: Config.Wrap<Parameters<typeof layer>[0]>) => Layer.Layer<SolanaRpc, Config.ConfigError, HttpClient.HttpClient>;
|
|
257
|
+
export {};
|
|
258
|
+
//# sourceMappingURL=SolanaRpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolanaRpc.d.ts","sourceRoot":"","sources":["../src/SolanaRpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OA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points with fallback.
|
|
3
|
+
*
|
|
4
|
+
* A call starts at the first endpoint and moves to the next one on failure, except on `WrongNetwork`. Each endpoint
|
|
5
|
+
* is checked once to serve the configured network (`getGenesisHash`). Every method is a read, so retries and fallback
|
|
6
|
+
* are safe. Methods are named after the JSON-RPC method. Every JSON integer in a reply is read as an exact `bigint`,
|
|
7
|
+
* so lamport amounts above 2^53 are never rounded.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import type { SolanaAddress } from "@effect-blockchain/solana/SolanaAddress"
|
|
12
|
+
* import * as SolanaRpc from "@effect-blockchain/solana/SolanaRpc"
|
|
13
|
+
* import * as Effect from "effect/Effect"
|
|
14
|
+
*
|
|
15
|
+
* declare const address: SolanaAddress
|
|
16
|
+
*
|
|
17
|
+
* // the 10 latest finalized transactions touching `address`
|
|
18
|
+
* const latest = Effect.gen(function*() {
|
|
19
|
+
* const rpc = yield* SolanaRpc.SolanaRpc
|
|
20
|
+
* const signatures = yield* rpc.getSignaturesForAddress({ address, limit: 10, commitment: "finalized" })
|
|
21
|
+
* return yield* Effect.forEach(signatures, ({ signature }) =>
|
|
22
|
+
* rpc.getTransaction({ signature, commitment: "finalized" }))
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @since 0.1.0
|
|
27
|
+
*/
|
|
28
|
+
import * as JsonRpc from "@effect-blockchain/core/JsonRpc";
|
|
29
|
+
import { SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_UNREACHABLE, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED, SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE } from "@solana/kit";
|
|
30
|
+
import * as Config from "effect/Config";
|
|
31
|
+
import * as Context from "effect/Context";
|
|
32
|
+
import * as Effect from "effect/Effect";
|
|
33
|
+
import * as Layer from "effect/Layer";
|
|
34
|
+
import * as Schema from "effect/Schema";
|
|
35
|
+
import * as BigIntJson from "./internal/bigIntJson.js";
|
|
36
|
+
import * as RpcMethods from "./internal/rpcMethods.js";
|
|
37
|
+
import { toGenesisHash } from "./SolanaNetwork.js";
|
|
38
|
+
/**
|
|
39
|
+
* A failed call: its `reason` (a {@link JsonRpc.Reason}, matched with `Effect.catchReason`), the JSON-RPC error code or
|
|
40
|
+
* HTTP status as `code`, and a `cause` without the endpoint URL. After several endpoints, the error is the last one
|
|
41
|
+
* and `cause` is an `AggregateError` of each endpoint's error, in order.
|
|
42
|
+
*
|
|
43
|
+
* On Solana, `Unavailable` includes the codes 429, -32603, -32005 and -32019, `Lagging` a `minContextSlot` not reached
|
|
44
|
+
* or a block not available yet, and `Pruned` a cleaned-up or skipped slot or a `getTransaction` returning `null`.
|
|
45
|
+
*
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
* @category errors
|
|
48
|
+
*/
|
|
49
|
+
export class SolanaRpcError extends /*#__PURE__*/Schema.TaggedError()("SolanaRpcError", {
|
|
50
|
+
reason: JsonRpc.Reason,
|
|
51
|
+
method: Schema.String,
|
|
52
|
+
endpoint: Schema.String,
|
|
53
|
+
code: /*#__PURE__*/Schema.optional(Schema.Number),
|
|
54
|
+
cause: /*#__PURE__*/Schema.Defect()
|
|
55
|
+
}) {
|
|
56
|
+
/**
|
|
57
|
+
* @since 0.1.0
|
|
58
|
+
*/
|
|
59
|
+
get message() {
|
|
60
|
+
return `${this.method} failed on ${this.endpoint}: ${this.reason._tag}${this.code === undefined ? "" : ` (${this.code})`}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @since 0.1.0
|
|
65
|
+
* @category services
|
|
66
|
+
*/
|
|
67
|
+
export class SolanaRpc extends /*#__PURE__*/Context.Service()("@effect-blockchain/solana/SolanaRpc") {}
|
|
68
|
+
// JSON-RPC codes from @solana/errors, any other code is `Rejected`
|
|
69
|
+
const codes = /*#__PURE__*/new Map([[429, "Unavailable"], [SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR, "Unavailable"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_NODE_UNHEALTHY, "Unavailable"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_UNREACHABLE, "Unavailable"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED, "Lagging"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_NOT_AVAILABLE, "Lagging"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET, "Lagging"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_BLOCK_CLEANED_UP, "Pruned"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SLOT_SKIPPED, "Pruned"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED, "Pruned"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE, "Pruned"], [SOLANA_ERROR__JSON_RPC__SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX, "Pruned"]]);
|
|
70
|
+
/**
|
|
71
|
+
* Builds a {@link SolanaRpc} over `endpoints`, tried in order, sending requests with the provided `HttpClient`
|
|
72
|
+
* (e.g. `FetchHttpClient.layer`). `timeout` (default 30 seconds) bounds each attempt, `retries` (default 3) and
|
|
73
|
+
* `retryDelay` (default 500 millis) set the backoff before falling back: see {@link JsonRpc.Unavailable}.
|
|
74
|
+
*
|
|
75
|
+
* @since 0.1.0
|
|
76
|
+
* @category layers
|
|
77
|
+
*/
|
|
78
|
+
export const layer = options => Layer.effect(SolanaRpc, Effect.gen(function* () {
|
|
79
|
+
const {
|
|
80
|
+
network
|
|
81
|
+
} = options;
|
|
82
|
+
const expectedGenesisHash = toGenesisHash(network);
|
|
83
|
+
const rpc = yield* JsonRpc.make({
|
|
84
|
+
spanPrefix: "SolanaRpc",
|
|
85
|
+
network,
|
|
86
|
+
endpoints: options.endpoints,
|
|
87
|
+
timeout: options.timeout,
|
|
88
|
+
retries: options.retries,
|
|
89
|
+
retryDelay: options.retryDelay,
|
|
90
|
+
codes,
|
|
91
|
+
parseBody: BigIntJson.parse,
|
|
92
|
+
checkNetwork: (send, endpoint) => send(RpcMethods.getGenesisHash, []).pipe(Effect.flatMap(genesisHash => genesisHash === expectedGenesisHash ? Effect.succeed(expectedGenesisHash) : Effect.fail(new SolanaRpcError({
|
|
93
|
+
reason: new JsonRpc.WrongNetwork({
|
|
94
|
+
expected: expectedGenesisHash,
|
|
95
|
+
actual: genesisHash
|
|
96
|
+
}),
|
|
97
|
+
method: RpcMethods.getGenesisHash.name,
|
|
98
|
+
endpoint,
|
|
99
|
+
cause: new Error(`expected genesis hash ${expectedGenesisHash} for ${network}, got ${genesisHash}`)
|
|
100
|
+
})))),
|
|
101
|
+
makeError: fields => new SolanaRpcError(fields)
|
|
102
|
+
});
|
|
103
|
+
const getTransactionOn = (endpoint, {
|
|
104
|
+
commitment,
|
|
105
|
+
encoding,
|
|
106
|
+
signature
|
|
107
|
+
}) => rpc.call(endpoint, RpcMethods.getTransaction(encoding), [signature, {
|
|
108
|
+
commitment,
|
|
109
|
+
encoding,
|
|
110
|
+
maxSupportedTransactionVersion: 0
|
|
111
|
+
}]).pipe(Effect.flatMap(tx => tx === null ? Effect.fail(rpc.fail(endpoint, RpcMethods.getTransaction.name, new JsonRpc.Pruned(), new Error(`transaction ${signature} not found`))) : Effect.succeed(tx)));
|
|
112
|
+
function getTransaction({
|
|
113
|
+
encoding = "base64",
|
|
114
|
+
...options
|
|
115
|
+
}) {
|
|
116
|
+
return rpc.withFallback(endpoint => getTransactionOn(endpoint, {
|
|
117
|
+
...options,
|
|
118
|
+
encoding
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
return SolanaRpc.of({
|
|
122
|
+
network,
|
|
123
|
+
getGenesisHash: rpc.withFallback(rpc.checkNetwork),
|
|
124
|
+
getSlot: ({
|
|
125
|
+
commitment
|
|
126
|
+
}) => rpc.withFallback(endpoint => rpc.call(endpoint, RpcMethods.getSlot, [{
|
|
127
|
+
commitment
|
|
128
|
+
}])),
|
|
129
|
+
getSignaturesForAddress: ({
|
|
130
|
+
address,
|
|
131
|
+
...config
|
|
132
|
+
}) => rpc.withFallback(endpoint => rpc.call(endpoint, RpcMethods.getSignaturesForAddress, [address, config])),
|
|
133
|
+
getTransaction
|
|
134
|
+
});
|
|
135
|
+
}));
|
|
136
|
+
/**
|
|
137
|
+
* Builds an {@link SolanaRpc} like {@link layer}, reading the options from `Config`. Endpoint URLs stay `Redacted`.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* import * as SolanaRpc from "@effect-blockchain/solana/SolanaRpc"
|
|
142
|
+
* import * as Config from "effect/Config"
|
|
143
|
+
*
|
|
144
|
+
* const RpcLive = SolanaRpc.layerConfig({
|
|
145
|
+
* network: Config.succeed("Solana"),
|
|
146
|
+
* endpoints: Config.all([Config.all({ name: Config.succeed("main"), url: Config.Redacted("SOLANA_RPC_URL") })])
|
|
147
|
+
* })
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* @since 0.1.0
|
|
151
|
+
* @category layers
|
|
152
|
+
*/
|
|
153
|
+
export const layerConfig = options => Layer.unwrap(Effect.map(Config.unwrap(options), layer));
|
|
154
|
+
//# sourceMappingURL=SolanaRpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolanaRpc.js","names":[],"sources":["../src/SolanaRpc.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,OAAO,KAAK,OAAO,MAAM,iCAAiC;AAC1D,SACE,sCAAsC,EACtC,qDAAqD,EACrD,wDAAwD,EACxD,mEAAmE,EACnE,sEAAsE,EACtE,mEAAmE,EACnE,kEAAkE,EAClE,iEAAiE,EACjE,mDAAmD,EACnD,iDAAiD,EACjD,sEAAsE,QACjE,aAAa;AAEpB,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc;AAErC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,UAAU,MAAM,0BAA0B;AACtD,OAAO,KAAK,UAAU,MAAM,0BAA0B;AAEtD,SAAqD,aAAa,QAAQ,oBAAoB;AAc9F;;;;;;;;;;;AAWA,OAAM,MAAO,cAAe,sBAAQ,MAAM,CAAC,WAAW,EAAkB,CAAC,gBAAgB,EAAE;EACzF,MAAM,EAAE,OAAO,CAAC,MAAM;EACtB,MAAM,EAAE,MAAM,CAAC,MAAM;EACrB,QAAQ,EAAE,MAAM,CAAC,MAAM;EACvB,IAAI,eAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;EACpC,KAAK,eAAE,MAAM,CAAC,MAAM;CACrB,CAAC;EACA;;;EAGA,IAAa,OAAO;IAClB,OAAO,GAAG,IAAI,CAAC,MAAM,cAAc,I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H,SAAS,cAAc,CACrB;IAAE,QAAQ,GAAG,QAAQ;IAAE,GAAG;EAAO,CAEhC;IAED,OAAO,GAAG,CAAC,YAAY,CAAE,QAAQ,IAAK,gBAAgB,CAAC,QAAQ,EAAE;MAAE,GAAG,OAAO;MAAE;IAAQ,CAAE,CAAC,CAAC;EAC7F;EAEA,OAAO,SAAS,CAAC,EAAE,CAAC;IAClB,OAAO;IACP,cAAc,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC;IAClD,OAAO,EAAE,CAAC;MAAE;IAAU,CAAE,KACtB,GAAG,CAAC,YAAY,CAAE,QAAQ,IAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;MAAE;IAAU,CAAE,CAAC,CAAC,CAAC;IAC1F,uBAAuB,EAAE,CAAC;MAAE,OAAO;MAAE,GAAG;IAAM,CAAE,KAC9C,GAAG,CAAC,YAAY,CAAE,QAAQ,IAAK,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3G;GACD,CAAC;AACJ,CAAC,CAAC,CACH;AAEH;;;;;;;;;;;;;;;;;AAiBA,OAAO,MAAM,WAAW,GACtB,OAAiD,IAEjD,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/**
|
|
3
|
+
* A Solana transaction hash: a base58-encoded Ed25519 signature, validated with `@solana/kit`.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.1.0
|
|
6
|
+
* @category schemas
|
|
7
|
+
*/
|
|
8
|
+
export declare const SolanaTransactionHash: Schema.brand<Schema.String, "SolanaTransactionHash">;
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.1.0
|
|
11
|
+
* @category models
|
|
12
|
+
*/
|
|
13
|
+
export type SolanaTransactionHash = typeof SolanaTransactionHash.Type;
|
|
14
|
+
//# sourceMappingURL=SolanaTransactionHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolanaTransactionHash.d.ts","sourceRoot":"","sources":["../src/SolanaTransactionHash.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAavC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,sDAWjC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 0.1.0
|
|
3
|
+
*/
|
|
4
|
+
import { isSignature } from "@solana/kit";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
const solanaTransactionHashPattern = "^[1-9A-HJ-NP-Za-km-z]{87}$";
|
|
7
|
+
// `isSignature` from @solana/kit throws on non-base58 characters instead of returning false.
|
|
8
|
+
const isSolanaSignature = value => {
|
|
9
|
+
try {
|
|
10
|
+
return isSignature(value);
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A Solana transaction hash: a base58-encoded Ed25519 signature, validated with `@solana/kit`.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
* @category schemas
|
|
20
|
+
*/
|
|
21
|
+
export const SolanaTransactionHash = /*#__PURE__*/Schema.String.annotate({
|
|
22
|
+
title: "Solana transaction hash",
|
|
23
|
+
description: "a valid Solana transaction hash (base58-encoded Ed25519 signature)"
|
|
24
|
+
}).pipe(/*#__PURE__*/Schema.check(/*#__PURE__*/Schema.makeFilter(s => isSolanaSignature(s) || `${s} is not a valid Solana transaction hash`, {
|
|
25
|
+
arbitraryConstraint: {
|
|
26
|
+
patterns: [{
|
|
27
|
+
source: solanaTransactionHashPattern,
|
|
28
|
+
flags: ""
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
31
|
+
})), /*#__PURE__*/Schema.brand("SolanaTransactionHash"), /*#__PURE__*/Schema.annotate({
|
|
32
|
+
identifier: "SolanaTransactionHash"
|
|
33
|
+
}));
|
|
34
|
+
//# sourceMappingURL=SolanaTransactionHash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolanaTransactionHash.js","names":[],"sources":["../src/SolanaTransactionHash.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,SAAS,WAAW,QAAQ,aAAa;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe;AAEvC,MAAM,4BAA4B,GAAG,4BAA4B;AAEjE;AACA,MAAM,iBAAiB,GAAI,KAAa,IAAa;EACnD,IAAI;IACF,OAAO,WAAW,CAAC,KAAK,CAAC;EAC3B,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF,CAAC;AAED;;;;;;AAMA,OAAO,MAAM,qBAAqB,gBAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;EAC1D,KAAK,EAAE,yBAAyB;EAChC,WAAW,EAAE;CACd,CAAC,CAAC,IAAI,cACL,MAAM,CAAC,KAAK,cACV,MAAM,CAAC,UAAU,CAAE,CAAS,IAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,yCAAyC,EAAE;EACtG,mBAAmB,EAAE;IAAE,QAAQ,EAAE,CAAC;MAAE,MAAM,EAAE,4BAA4B;MAAE,KAAK,EAAE;IAAE,CAAE;EAAC;CACvF,CAAC,CACH,eACD,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,eACrC,MAAM,CAAC,QAAQ,CAAC;EAAE,UAAU,EAAE;AAAuB,CAAE,CAAC,CACzD","ignoreList":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 0.1.0
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @since 0.1.0
|
|
6
|
+
*/
|
|
7
|
+
export * as SolanaAddress from "./SolanaAddress.ts";
|
|
8
|
+
/**
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
*/
|
|
11
|
+
export * as SolanaIndexer from "./SolanaIndexer.ts";
|
|
12
|
+
/**
|
|
13
|
+
* @since 0.1.0
|
|
14
|
+
*/
|
|
15
|
+
export * as SolanaNetwork from "./SolanaNetwork.ts";
|
|
16
|
+
/**
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
export * as SolanaRpc from "./SolanaRpc.ts";
|
|
20
|
+
/**
|
|
21
|
+
* @since 0.1.0
|
|
22
|
+
*/
|
|
23
|
+
export * as SolanaTransactionHash from "./SolanaTransactionHash.ts";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;GAEG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;GAEG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;GAEG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;GAEG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 0.1.0
|
|
3
|
+
*/
|
|
4
|
+
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
|
+
/**
|
|
6
|
+
* @since 0.1.0
|
|
7
|
+
*/
|
|
8
|
+
export * as SolanaAddress from "./SolanaAddress.js";
|
|
9
|
+
/**
|
|
10
|
+
* @since 0.1.0
|
|
11
|
+
*/
|
|
12
|
+
export * as SolanaIndexer from "./SolanaIndexer.js";
|
|
13
|
+
/**
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
*/
|
|
16
|
+
export * as SolanaNetwork from "./SolanaNetwork.js";
|
|
17
|
+
/**
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
*/
|
|
20
|
+
export * as SolanaRpc from "./SolanaRpc.js";
|
|
21
|
+
/**
|
|
22
|
+
* @since 0.1.0
|
|
23
|
+
*/
|
|
24
|
+
export * as SolanaTransactionHash from "./SolanaTransactionHash.js";
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAK,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAK,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAK,aAAa,MAAM,oBAAoB;AAEnD;;;AAGA,OAAO,KAAK,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAK,qBAAqB,MAAM,4BAA4B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigIntJson.d.ts","sourceRoot":"","sources":["../../src/internal/bigIntJson.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const integer = /^-?\d+$/;
|
|
2
|
+
/**
|
|
3
|
+
* Parses JSON with every integer literal as an exact `bigint`, like `@solana/kit` does: u64 values above 2^53 are
|
|
4
|
+
* never rounded. Reads the literal's source text through the reviver's third argument (Node >= 24).
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export const parse = text => JSON.parse(text, (_key, value, context) => typeof value === "number" && context?.source !== undefined && integer.test(context.source) ? BigInt(context.source) : value);
|
|
9
|
+
//# sourceMappingURL=bigIntJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigIntJson.js","names":[],"sources":["../../src/internal/bigIntJson.ts"],"sourcesContent":[null],"mappings":"AAEA,MAAM,OAAO,GAAG,SAAS;AAEzB;;;;;;AAMA,OAAO,MAAM,KAAK,GAAI,IAAY,IAChC,IAAI,CAAC,KAAK,CACR,IAAI,EACJ,CAAC,IAAI,EAAE,KAAc,EAAE,OAAsC,KAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,EAAE,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GACtF,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GACtB,KAAK,CACZ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcMethods.d.ts","sourceRoot":"","sources":["../../src/internal/rpcMethods.ts"],"names":[],"mappings":""}
|