@0block.io/sdk 0.3.0 → 0.4.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/dist/blockhash.d.ts +16 -0
- package/dist/blockhash.js +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface FetchBlockhashOptions {
|
|
2
|
+
/** Injectable fetch (tests / non-standard runtimes). Defaults to global fetch. */
|
|
3
|
+
fetchImpl?: typeof fetch;
|
|
4
|
+
}
|
|
5
|
+
export interface RecentBlockhash {
|
|
6
|
+
/** The finalized blockhash to use as a transaction's recentBlockhash. */
|
|
7
|
+
blockhash: string;
|
|
8
|
+
/** Last block height at which this blockhash is still valid (0 if absent). */
|
|
9
|
+
lastValidBlockHeight: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetch the recent finalized blockhash from 0Block's cached public endpoint.
|
|
13
|
+
* `apiBaseUrl` is the 0Block API base (e.g. "https://<0block-host>"); the
|
|
14
|
+
* "/api/v1/blockhash" path is appended.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fetchRecentBlockhash(apiBaseUrl: string, opts?: FetchBlockhashOptions): Promise<RecentBlockhash>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// 0Block public API: recent blockhash. Lets clients build transactions without
|
|
2
|
+
// their own Solana read RPC — 0Block polls and caches getLatestBlockhash on the
|
|
3
|
+
// server and serves it at GET {apiBaseUrl}/api/v1/blockhash (public, no key).
|
|
4
|
+
/**
|
|
5
|
+
* Fetch the recent finalized blockhash from 0Block's cached public endpoint.
|
|
6
|
+
* `apiBaseUrl` is the 0Block API base (e.g. "https://<0block-host>"); the
|
|
7
|
+
* "/api/v1/blockhash" path is appended.
|
|
8
|
+
*/
|
|
9
|
+
export async function fetchRecentBlockhash(apiBaseUrl, opts) {
|
|
10
|
+
const fetchImpl = opts?.fetchImpl ?? fetch;
|
|
11
|
+
const base = apiBaseUrl.replace(/\/+$/, "");
|
|
12
|
+
const res = await fetchImpl(`${base}/api/v1/blockhash`);
|
|
13
|
+
if (!res.ok) {
|
|
14
|
+
throw new Error(`0Block blockhash unavailable (HTTP ${res.status})`);
|
|
15
|
+
}
|
|
16
|
+
const body = (await res.json());
|
|
17
|
+
if (!body.blockhash) {
|
|
18
|
+
throw new Error("0Block blockhash response missing blockhash");
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
blockhash: body.blockhash,
|
|
22
|
+
lastValidBlockHeight: body.lastValidBlockHeight ?? 0,
|
|
23
|
+
};
|
|
24
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./constants.js";
|
|
|
2
2
|
export * from "./types.js";
|
|
3
3
|
export { createContext, type CreateContextParams, type TenantInit, type ZeroBlockContext, } from "./context.js";
|
|
4
4
|
export { buildSendTransactionRequest, createLandingClient, withLandingTip, type LandingClient, type LandingServiceConfig, type SendTransactionOptions, } from "./landing.js";
|
|
5
|
+
export { fetchRecentBlockhash, type FetchBlockhashOptions, type RecentBlockhash, } from "./blockhash.js";
|
|
5
6
|
export { toPk, deriveAta, deriveOrderMarker, deriveWrapperConfig, deriveRouterGlobalConfig, deriveRouterTenantConfig, derivePumpfunGlobal, derivePumpfunBondingCurve, derivePumpfunBondingCurveV2, derivePumpfunEventAuthority, derivePumpfunCreatorVault, derivePumpfunGlobalVolumeAccumulator, derivePumpfunUserVolumeAccumulator, derivePumpfunFeeConfig, } from "./pda.js";
|
|
6
7
|
export { type AccountFetcher, connectionFetcher, resolveTokenProgram, resolvePumpfunMarketContext, fetchPumpfunGlobalFeeRecipient, fetchPumpfunBondingCurveCreator, fetchPumpfunBuybackFeeRecipients, } from "./fetch.js";
|
|
7
8
|
export { buildPumpfunRemainingAccounts, type PumpfunRemainingAccountsParams, } from "./venues/pumpfun.js";
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./constants.js";
|
|
|
15
15
|
export * from "./types.js";
|
|
16
16
|
export { createContext, } from "./context.js";
|
|
17
17
|
export { buildSendTransactionRequest, createLandingClient, withLandingTip, } from "./landing.js";
|
|
18
|
+
export { fetchRecentBlockhash, } from "./blockhash.js";
|
|
18
19
|
export { toPk, deriveAta, deriveOrderMarker, deriveWrapperConfig, deriveRouterGlobalConfig, deriveRouterTenantConfig, derivePumpfunGlobal, derivePumpfunBondingCurve, derivePumpfunBondingCurveV2, derivePumpfunEventAuthority, derivePumpfunCreatorVault, derivePumpfunGlobalVolumeAccumulator, derivePumpfunUserVolumeAccumulator, derivePumpfunFeeConfig, } from "./pda.js";
|
|
19
20
|
export { connectionFetcher, resolveTokenProgram, resolvePumpfunMarketContext, fetchPumpfunGlobalFeeRecipient, fetchPumpfunBondingCurveCreator, fetchPumpfunBuybackFeeRecipients, } from "./fetch.js";
|
|
20
21
|
export { buildPumpfunRemainingAccounts, } from "./venues/pumpfun.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0block.io/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Client-side transaction builder for the 0Block DEX router. Builds unsigned v0 swap transactions entirely offline \u2014 tenant-wrapped or direct \u2014 with shared address lookup tables, gateway tips, and on-chain fee-event decoding for accounting.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"solana",
|