Skip to content

Commit 7b3f3c9

Browse files
committed
fix(providers): remove fee estimation (for now)
1 parent 0edb91b commit 7b3f3c9

File tree

9 files changed

+41
-94
lines changed

9 files changed

+41
-94
lines changed

apps/docs/src/pages/connect/wallet-client.mdx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,6 @@ const client = createWalletClient({ account, network: "devnet" });
124124
const chainId = await client.getChainId();
125125
```
126126

127-
### Get estimated fees
128-
129-
Query the estimated fees of a transaction.
130-
131-
```ts twoslash
132-
import { toAccount } from "@mina-js/accounts";
133-
import { createWalletClient } from '@mina-js/connect'
134-
135-
const account = toAccount('B62qmWKtvNQTtUqo1LxfEEDLyWMg59cp6U7c4uDC7aqgaCEijSc3Hx5');
136-
const client = createWalletClient({ account, network: "devnet" });
137-
138-
const fees = await client.estimateFees();
139-
```
140-
141127
## Wallet commands
142128

143129
If you provide a local wallet, Wallet Client will sign with it, otherwise, it will use the injected wallet.

apps/klesia/src/index.spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,4 @@ describe("Mina Devnet RPC", () => {
5555
expect(BigInt(result.nonce)).toBeGreaterThanOrEqual(0);
5656
expect(BigInt(result.balance)).toBeGreaterThanOrEqual(0);
5757
});
58-
59-
it("returns result for mina_estimateFee", async () => {
60-
const response = await request({
61-
json: {
62-
method: "mina_estimateFees",
63-
},
64-
});
65-
const { result } = (await response.json()) as {
66-
result: { medium: string };
67-
};
68-
expect(result.medium.length).toBeGreaterThan(0);
69-
});
7058
});

apps/klesia/src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ export const klesiaRpcRoute = api.openapi(rpcRoute, async ({ req, json }) => {
123123
});
124124
return json(buildResponse({ result }), 200);
125125
})
126-
.with({ method: RpcMethod.enum.mina_estimateFees }, async () => {
127-
const result = await mina.estimateFees();
128-
return json(buildResponse({ result }), 200);
129-
})
130126
.exhaustive();
131127
});
132128

apps/klesia/src/methods/mina.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,3 @@ it("should get account info", async () => {
2828
expect(BigInt(result.nonce)).toBeGreaterThanOrEqual(0);
2929
expect(BigInt(result.balance)).toBeGreaterThanOrEqual(0);
3030
});
31-
32-
it("should estimate fee", async () => {
33-
const result = await mina.estimateFees();
34-
expect(result.medium.length).toBeGreaterThan(0);
35-
});

apps/klesia/src/methods/mina.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -175,43 +175,11 @@ const getAccount = async ({ publicKey }: { publicKey: string }) => {
175175
}
176176
};
177177

178-
const estimateFees = async () => {
179-
const client = getNodeClient();
180-
try {
181-
const { data } = await client.query(
182-
gql`
183-
query {
184-
snarkPool {
185-
fee
186-
}
187-
}
188-
`,
189-
{},
190-
);
191-
const fees = data.snarkPool
192-
.map((entry: { fee: string }) => entry.fee)
193-
.filter((entry: string) => entry !== "0")
194-
.map((entry: string) => BigInt(entry));
195-
return {
196-
low: String(calculateQuantile(fees, PRIORITY.low)),
197-
medium: String(calculateQuantile(fees, PRIORITY.medium)),
198-
high: String(calculateQuantile(fees, PRIORITY.high)),
199-
};
200-
} catch {
201-
return {
202-
low: "10000000",
203-
medium: "100000000",
204-
high: "200000000",
205-
};
206-
}
207-
};
208-
209178
export const mina = {
210179
getTransactionCount,
211180
getBalance,
212181
blockHash,
213182
chainId,
214183
sendTransaction,
215184
getAccount,
216-
estimateFees,
217185
};

apps/klesia/src/schema.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export const RpcMethod = z.enum([
4343
"mina_chainId",
4444
"mina_sendTransaction",
4545
"mina_getAccount",
46-
"mina_estimateFees",
4746
]);
4847
export type RpcMethodType = z.infer<typeof RpcMethod>;
4948

@@ -72,10 +71,6 @@ export const RpcMethodSchema = z.discriminatedUnion("method", [
7271
method: z.literal(RpcMethod.enum.mina_getAccount),
7372
params: PublicKeyParamsSchema,
7473
}),
75-
z.object({
76-
method: z.literal(RpcMethod.enum.mina_estimateFees),
77-
params: EmptyParamsSchema,
78-
}),
7974
]);
8075

8176
export const JsonRpcResponse = z.object({
@@ -122,14 +117,6 @@ export const RpcResponseSchema = z.union([
122117
balance: z.string(),
123118
}),
124119
}),
125-
JsonRpcResponse.extend({
126-
method: z.literal(RpcMethod.enum.mina_estimateFees),
127-
result: z.object({
128-
low: z.string(),
129-
medium: z.string(),
130-
high: z.string(),
131-
}),
132-
}),
133120
]),
134121
ErrorSchema,
135122
]);

packages/connect/src/__snapshots__/client.spec.ts.snap

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
exports[`matches snapshot of local source 1`] = `
44
{
55
"createNullifier": [Function: AsyncFunction],
6-
"estimateFees": [Function: AsyncFunction],
76
"getAccounts": [Function: AsyncFunction],
87
"getBalance": [Function: AsyncFunction],
98
"getChainId": [Function: AsyncFunction],
@@ -18,7 +17,34 @@ exports[`matches snapshot of local source 1`] = `
1817
exports[`matches snapshot of json-rpc source 1`] = `
1918
{
2019
"createNullifier": [Function: AsyncFunction],
21-
"estimateFees": [Function: AsyncFunction],
20+
"getAccounts": [Function: AsyncFunction],
21+
"getBalance": [Function: AsyncFunction],
22+
"getChainId": [Function: AsyncFunction],
23+
"getTransactionCount": [Function: AsyncFunction],
24+
"prepareTransactionRequest": [Function: AsyncFunction],
25+
"signFields": [Function: AsyncFunction],
26+
"signMessage": [Function: AsyncFunction],
27+
"signTransaction": [Function: AsyncFunction],
28+
}
29+
`;
30+
31+
exports[`matches snapshot of local source 2`] = `
32+
{
33+
"createNullifier": [Function: AsyncFunction],
34+
"getAccounts": [Function: AsyncFunction],
35+
"getBalance": [Function: AsyncFunction],
36+
"getChainId": [Function: AsyncFunction],
37+
"getTransactionCount": [Function: AsyncFunction],
38+
"prepareTransactionRequest": [Function: AsyncFunction],
39+
"signFields": [Function: AsyncFunction],
40+
"signMessage": [Function: AsyncFunction],
41+
"signTransaction": [Function: AsyncFunction],
42+
}
43+
`;
44+
45+
exports[`matches snapshot of json-rpc source 2`] = `
46+
{
47+
"createNullifier": [Function: AsyncFunction],
2248
"getAccounts": [Function: AsyncFunction],
2349
"getBalance": [Function: AsyncFunction],
2450
"getChainId": [Function: AsyncFunction],

packages/connect/src/__snapshots__/store.spec.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ exports[`should initialize the store 1`] = `
1111
"subscribe": [Function: subscribe],
1212
}
1313
`;
14+
15+
exports[`should initialize the store 2`] = `
16+
{
17+
"_listeners": [Function: _listeners],
18+
"clear": [Function: clear],
19+
"destroy": [Function: destroy],
20+
"findProvider": [Function: findProvider],
21+
"getProviders": [Function: getProviders],
22+
"reset": [Function: reset],
23+
"subscribe": [Function: subscribe],
24+
}
25+
`;

packages/connect/src/client.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ export const createWalletClient = ({
117117
if (account.type !== "local") throw new Error("Account type not supported");
118118
return account.createNullifier(params);
119119
};
120-
const estimateFees = async () => {
121-
const { result } = await klesiaClient.request<"mina_estimateFees">({
122-
method: "mina_estimateFees",
123-
});
124-
return {
125-
low: result.low,
126-
medium: result.medium,
127-
high: result.high,
128-
};
129-
};
130120
const prepareTransactionRequest = async (
131121
transaction: PartiallyFormedTransactionProperties,
132122
) => {
@@ -136,7 +126,7 @@ export const createWalletClient = ({
136126
nonce = await getTransactionCount();
137127
}
138128
if (!fee) {
139-
fee = (await estimateFees()).medium;
129+
fee = "0.01";
140130
}
141131
return {
142132
...transaction,
@@ -153,7 +143,6 @@ export const createWalletClient = ({
153143
signMessage,
154144
signFields,
155145
createNullifier,
156-
estimateFees,
157146
prepareTransactionRequest,
158147
};
159148
};

0 commit comments

Comments
 (0)