forked from Vero-protocol/vero-core-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtx-sender.ts
More file actions
35 lines (31 loc) · 1.1 KB
/
Copy pathtx-sender.ts
File metadata and controls
35 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { RpcClient } from "./rpc-client";
import { GasOracle, FeeResolutionOptions, ResolvedFee } from "./gas-oracle";
/**
* tx-sender.ts — Fee resolution entrypoint for transaction submission.
*
* The repo currently doesn’t include a full transaction builder/submitter.
* This module provides the *protocol-grade* fee oracle integration so any
* future tx construction/submission code can:
* 1) fetch current base fee (fail closed)
* 2) compute deterministic maxFee
* 3) apply/return fee parameters consistently.
*/
export interface FeePlan {
/** Final fee in stroops that callers should set on their tx. */
maxFee: string;
/** Raw resolution details for audit/logging. */
resolution: ResolvedFee;
}
export async function resolveFeePlan(
rpc: RpcClient,
gasOracle: GasOracle,
opts: FeeResolutionOptions,
): Promise<FeePlan> {
const resolution = await gasOracle.resolveFee(rpc, opts);
return {
// stellar-sdk typically expects fee as string/number depending on tx type.
// We return string to avoid bigint/float issues.
maxFee: String(resolution.maxFee),
resolution,
};
}