fix: add burnPercent field to FeeCalculator (#381)
This commit is contained in:
@ -34,9 +34,12 @@ declare module '@solana/web3.js' {
|
|||||||
|
|
||||||
// === src/fee-calculator.js ===
|
// === src/fee-calculator.js ===
|
||||||
declare export type FeeCalculator = {
|
declare export type FeeCalculator = {
|
||||||
|
burnPercent: number,
|
||||||
lamportsPerSignature: number,
|
lamportsPerSignature: number,
|
||||||
targetSignaturesPerSlot: number,
|
maxLamportsPerSignature: number,
|
||||||
|
minLamportsPerSignature: number,
|
||||||
targetLamportsPerSignature: number,
|
targetLamportsPerSignature: number,
|
||||||
|
targetSignaturesPerSlot: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
// === src/budget-program.js ===
|
// === src/budget-program.js ===
|
||||||
|
@ -225,6 +225,7 @@ const GetTotalSupplyRpcResult = jsonRpcResult('number');
|
|||||||
const GetRecentBlockhash = jsonRpcResult([
|
const GetRecentBlockhash = jsonRpcResult([
|
||||||
'string',
|
'string',
|
||||||
struct({
|
struct({
|
||||||
|
burnPercent: 'number',
|
||||||
lamportsPerSignature: 'number',
|
lamportsPerSignature: 'number',
|
||||||
maxLamportsPerSignature: 'number',
|
maxLamportsPerSignature: 'number',
|
||||||
minLamportsPerSignature: 'number',
|
minLamportsPerSignature: 'number',
|
||||||
@ -235,10 +236,14 @@ const GetRecentBlockhash = jsonRpcResult([
|
|||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
const GetRecentBlockhash_015 = jsonRpcResult([
|
const GetRecentBlockhash_016 = jsonRpcResult([
|
||||||
'string',
|
'string',
|
||||||
struct({
|
struct({
|
||||||
lamportsPerSignature: 'number',
|
lamportsPerSignature: 'number',
|
||||||
|
maxLamportsPerSignature: 'number',
|
||||||
|
minLamportsPerSignature: 'number',
|
||||||
|
targetLamportsPerSignature: 'number',
|
||||||
|
targetSignaturesPerSlot: 'number',
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -548,22 +553,19 @@ export class Connection {
|
|||||||
async getRecentBlockhash(): Promise<BlockhashAndFeeCalculator> {
|
async getRecentBlockhash(): Promise<BlockhashAndFeeCalculator> {
|
||||||
const unsafeRes = await this._rpcRequest('getRecentBlockhash', []);
|
const unsafeRes = await this._rpcRequest('getRecentBlockhash', []);
|
||||||
|
|
||||||
// Legacy v0.15 response. TODO: Remove in August 2019
|
// Legacy v0.16 response. TODO: Remove in September 2019
|
||||||
try {
|
try {
|
||||||
const res_015 = GetRecentBlockhash_015(unsafeRes);
|
const res_016 = GetRecentBlockhash_016(unsafeRes);
|
||||||
if (res_015.error) {
|
if (res_016.error) {
|
||||||
throw new Error(res_015.error.message);
|
throw new Error(res_016.error.message);
|
||||||
}
|
}
|
||||||
const [blockhash, feeCalculator] = res_015.result;
|
const [blockhash, feeCalculator] = res_016.result;
|
||||||
feeCalculator.targetSignaturesPerSlot = 42;
|
feeCalculator.burnPercent = 0;
|
||||||
feeCalculator.targetLamportsPerSignature =
|
|
||||||
feeCalculator.lamportsPerSignature;
|
|
||||||
|
|
||||||
return [blockhash, feeCalculator];
|
return [blockhash, feeCalculator];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Not legacy format
|
// Not legacy format
|
||||||
}
|
}
|
||||||
// End Legacy v0.15 response
|
// End Legacy v0.16 response
|
||||||
|
|
||||||
const res = GetRecentBlockhash(unsafeRes);
|
const res = GetRecentBlockhash(unsafeRes);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
|
@ -19,6 +19,11 @@ export function mockGetRecentBlockhash() {
|
|||||||
recentBlockhash.publicKey.toBase58(),
|
recentBlockhash.publicKey.toBase58(),
|
||||||
{
|
{
|
||||||
lamportsPerSignature: 42,
|
lamportsPerSignature: 42,
|
||||||
|
burnPercent: 50,
|
||||||
|
maxLamportsPerSignature: 42,
|
||||||
|
minLamportsPerSignature: 42,
|
||||||
|
targetLamportsPerSignature: 42,
|
||||||
|
targetSignaturesPerSlot: 42,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user