Skip to content

Commit 751c2ed

Browse files
committed
feat: use BigNumber for estimate fee amount
1 parent 806eb7d commit 751c2ed

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/provider/default.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
CompiledContract,
1111
DeployContractPayload,
1212
Endpoints,
13+
EstimateFeeResponse,
1314
GetBlockResponse,
1415
GetCodeResponse,
1516
GetContractAddressesResponse,
@@ -153,6 +154,17 @@ export class Provider implements ProviderInterface {
153154
try {
154155
const { data } = await axios.request<Endpoints[T]['RESPONSE']>({
155156
method,
157+
transformResponse:
158+
endpoint === 'estimate_fee'
159+
? (res): EstimateFeeResponse => {
160+
return parse(res, (_, v) => {
161+
if (v && typeof v === 'bigint') {
162+
return toBN(v.toString());
163+
}
164+
return v;
165+
});
166+
}
167+
: axios.defaults.transformResponse,
156168
url: urljoin(baseUrl, endpoint, queryString),
157169
data: stringify(request),
158170
headers,

src/types/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import BN from 'bn.js';
2+
13
import { BlockIdentifier } from '../provider/utils';
24
import { BigNumberish } from '../utils/number';
35
import {
@@ -235,7 +237,7 @@ export type TransactionReceiptResponse = {
235237
};
236238

237239
export type EstimateFeeResponse = {
238-
amount: number;
240+
amount: BN;
239241
unit: string;
240242
};
241243

0 commit comments

Comments
 (0)