Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
As of last week, v2 release candidate was dropped and is no longer experimental. Ref: https://github.com/solana-labs/solana-web3.js/releases
Looks like with the release, a function was renamed. We are replacing the `createRpcApi` import with `createJsonRpcApi` and associated uses. Also one of the params changed as well.
  • Loading branch information
amilz committed Nov 13, 2024
1 parent 88e761c commit 1584b46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions solana/web3.js-2.0/jito-bundles/lilJit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Rpc,
createDefaultRpcTransport,
createRpc,
createRpcApi,
createJsonRpcApi, // note: in older versions of this library, this function was called: createRpcApi
Address,
mainnet,
Base58EncodedBytes,
Expand Down Expand Up @@ -83,7 +83,7 @@ type LilJitAddon = {
}

function createJitoBundlesRpc({ endpoint }: { endpoint: string }): Rpc<LilJitAddon> {
const api = createRpcApi<LilJitAddon>({
const api = createJsonRpcApi<LilJitAddon>({
// parametersTransformer: (params: any[]) => params[0],
responseTransformer: (response: any) => response.result,
});
Expand Down
7 changes: 4 additions & 3 deletions solana/web3.js-2.0/optimized-tx/src/QuickNodeSolana.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
Rpc,
createRpc,
createRpcApi,
createJsonRpcApi, // note: in older versions of this library, this function was called: createRpcApi
RpcRequest,
pipe,
createTransactionMessage,
setTransactionMessageLifetimeUsingBlockhash,
Expand Down Expand Up @@ -56,8 +57,8 @@ export class QuickNodeSolana {
}

private createPriorityFeeApi(endpoint: string): Rpc<PriorityFeeApi> {
const api = createRpcApi<PriorityFeeApi>({
parametersTransformer: (params: any[]) => params[0],
const api = createJsonRpcApi<PriorityFeeApi>({
requestTransformer: (request: RpcRequest<any>) => request.params[0],
responseTransformer: (response: any) => response.result,
});
const transport = createQuickNodeTransport(endpoint);
Expand Down
7 changes: 4 additions & 3 deletions solana/web3.js-2.0/quicknode-addons/guide1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
createDefaultRpcTransport,
createRpc,
RpcTransport,
createRpcApi,
createJsonRpcApi, // note: in older versions of this library, this function was called: createRpcApi
RpcRequest,
createSolanaRpcApi,
} from "@solana/web3.js";
import {
Expand Down Expand Up @@ -41,8 +42,8 @@ function createQuickNodeTransport({ endpoint }: createQuickNodeTransportParams):
*/
export function createPriorityFeeApi(endpoint: string): Rpc<PriorityFeeApi> {
const api0 = createSolanaRpcApi();
const api = createRpcApi<PriorityFeeApi>({
parametersTransformer: (params: any[]) => params[0],
const api = createJsonRpcApi<PriorityFeeApi>({
requestTransformer: (request: RpcRequest<any>) => request.params[0],
responseTransformer: (response: any) => response.result,
});
const transport = createQuickNodeTransport({
Expand Down
7 changes: 4 additions & 3 deletions solana/web3.js-2.0/quicknode-addons/guide2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
createDefaultRpcTransport,
createRpc,
RpcTransport,
createRpcApi,
createJsonRpcApi, // note: in older versions of this library, this function was called: createRpcApi,
RpcRequest
} from "@solana/web3.js";
import {
EstimatePriorityFeesResponse,
Expand Down Expand Up @@ -133,8 +134,8 @@ interface CreateAddonsApiParams {


export function createAddonsApi(params: CreateAddonsApiParams): Rpc<QuickNodeAddons> {
const api = createRpcApi<QuickNodeAddons>({
parametersTransformer: (params: unknown[]) => params[0],
const api = createJsonRpcApi<QuickNodeAddons>({
requestTransformer: (request: RpcRequest<any>) => request.params[0],
responseTransformer: (response: any) => response.result,
});

Expand Down

0 comments on commit 1584b46

Please sign in to comment.