Skip to content

Commit 54020df

Browse files
Seonpyo KimHoOngEe
authored andcommitted
Add RPC named getMinTransactionFee
1 parent ab69197 commit 54020df

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/rpc/chain.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,45 @@ export class ChainRpc {
10611061
});
10621062
}
10631063

1064+
/**
1065+
* Gets the minimum transaction fee of the given transaction type in the given block.
1066+
* @param transactionType
1067+
* @param blockNumber
1068+
* @returns The minimum transaction fee of the corresponding transactionType in the unit of CCC.
1069+
*/
1070+
public getMinTransactionFee(
1071+
transactionType: string,
1072+
blockNumber?: number | null
1073+
): Promise<number | null> {
1074+
const fallbackServers = this.fallbackServers;
1075+
if (blockNumber !== undefined && !isNonNegativeInterger(blockNumber)) {
1076+
throw Error(
1077+
`Expected the second argument of getMinTransactionFee to be non-negative integer but found ${blockNumber}`
1078+
);
1079+
}
1080+
1081+
return new Promise((resolve, reject) => {
1082+
this.rpc
1083+
.sendRpcRequest(
1084+
"chain_getMinTransactionFee",
1085+
[transactionType, blockNumber],
1086+
{ fallbackServers }
1087+
)
1088+
.then(result => {
1089+
if (result === null || typeof result === "number") {
1090+
resolve(result);
1091+
} else {
1092+
reject(
1093+
Error(
1094+
`Expected chain_getMinTransactionFee to return either null or a number but it returned ${result}`
1095+
)
1096+
);
1097+
}
1098+
})
1099+
.catch(reject);
1100+
});
1101+
}
1102+
10641103
/**
10651104
* Gets the network ID of the node.
10661105
* @returns A network ID, e.g. "tc".

0 commit comments

Comments
 (0)