Skip to content

Commit

Permalink
chore: add api_version (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
amilz authored Oct 29, 2024
1 parent 7035073 commit 1fdf7e1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions solana/priority-fees-addon/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { RequestPayload, ResponseData, EstimatePriorityFeesParams } from "./type
async function fetchEstimatePriorityFees({
last_n_blocks,
account,
api_version = 1,
endpoint
}: EstimatePriorityFeesParams): Promise<ResponseData> {
const params: any = {};
Expand All @@ -28,6 +29,9 @@ async function fetchEstimatePriorityFees({
if (account !== undefined) {
params.account = account;
}
if (api_version !== undefined) {
params.api_version = api_version;
}

const payload: RequestPayload = {
method: 'qn_estimatePriorityFees',
Expand Down Expand Up @@ -60,6 +64,7 @@ async function fetchEstimatePriorityFees({
const params: EstimatePriorityFeesParams = {
last_n_blocks: 100,
account: 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4',
api_version: 2,
endpoint: 'https://YOUR_QUICKNODE_ADDON_URL/'
};

Expand Down
3 changes: 3 additions & 0 deletions solana/priority-fees-addon/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface RequestPayload {
params: {
last_n_blocks: number;
account: string;
api_version: number;
};
id: number;
jsonrpc: string;
Expand Down Expand Up @@ -36,6 +37,8 @@ interface EstimatePriorityFeesParams {
last_n_blocks?: number;
// (Optional) The program account to use for fetching the local estimate (e.g., Jupiter: JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4)
account?: string;
// (optional) The API version to use for the request (default: 1)
api_version?: number;
// Your Add-on Endpoint (found in your QuickNode Dashboard - https://dashboard.quicknode.com/endpoints)
endpoint: string;
}
Expand Down
3 changes: 2 additions & 1 deletion solana/raydium-swap-ts/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ async function fetchPriorityFee(): Promise<number> {
method: 'qn_estimatePriorityFees',
params: {
last_n_blocks: 100,
account: '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8'
account: '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8',
api_version: 2
}
});

Expand Down
3 changes: 2 additions & 1 deletion solana/web3.js-2.0/quicknode-addons/guide1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ async function main() {

const priorityFees = await quickNodeRpc.qn_estimatePriorityFees({
account: 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4',
last_n_blocks: 100
last_n_blocks: 100,
api_version: 2,
}).send();

console.log(priorityFees);
Expand Down
3 changes: 2 additions & 1 deletion solana/web3.js-2.0/quicknode-addons/guide2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ async function main() {
try {
const priorityFees = await quickNodeRpc.qn_estimatePriorityFees({
account: 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4',
last_n_blocks: 100
last_n_blocks: 100,
api_version: 2
}).send();
console.log(`Priority Fees (Med Per CU): ${priorityFees.per_compute_unit.medium}`);
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions solana/web3.js-2.0/quicknode-addons/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface EstimatePriorityFeesResponse {
interface EstimatePriorityFeesParams {
last_n_blocks?: number;
account?: string;
api_version?: number;
}

/* -- METIS API -- */
Expand Down

0 comments on commit 1fdf7e1

Please sign in to comment.