Skip to content

Commit

Permalink
Kaia (#568)
Browse files Browse the repository at this point in the history
* add kaia

* some changes

* kaia

* kaia
  • Loading branch information
aarifkhamdi authored Sep 11, 2024
1 parent 2b7e819 commit 5fd26ac
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 5 deletions.
2 changes: 1 addition & 1 deletion emerald-grpc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,30 @@ class DefaultEthereumMethods(
"klay_getTransactionReceiptBySenderTxHash",
)

private val kaiaPossibleNotIndexedMethods = listOf(
"kaia_blockNumber",
"kaia_getBlockByHash",
"kaia_getBlockReceipts",
"kaia_getBlockTransactionCountByNumber",
"kaia_getBlockWithConsensusInfoByNumber",
"kaia_getBlockByNumber",
"kaia_getBlockTransactionCountByHash",
"kaia_getHeaderByNumber",
"kaia_getHeaderByHash",
"kaia_getBlockWithConsensusInfoByNumberRange",
"kaia_getBlockWithConsensusInfoByHash",
"kaia_getDecodedAnchoringTransactionByHash",
"kaia_getRawTransactionByBlockNumberAndIndex",
"kaia_getRawTransactionByBlockHashAndIndex",
"kaia_getRawTransactionByHash",
"kaia_getTransactionByBlockNumberAndIndex",
"kaia_getTransactionBySenderTxHash",
"kaia_getTransactionByBlockHashAndIndex",
"kaia_getTransactionByHash",
"kaia_getTransactionReceipt",
"kaia_getTransactionReceiptBySenderTxHash",
)

private val firstValueMethods = listOf(
"eth_call",
"eth_getStorageAt",
Expand Down Expand Up @@ -181,6 +205,11 @@ class DefaultEthereumMethods(
"klay_getTransactionCount",
)

private val kaiaSpecialMethods = listOf(
"kaia_sendRawTransaction",
"kaia_getTransactionCount",
)

private val headVerifiedMethods = listOf(
"eth_getBlockTransactionCountByNumber",
"eth_getUncleCountByBlockNumber",
Expand Down Expand Up @@ -420,6 +449,73 @@ class DefaultEthereumMethods(
// "klay_isParallelDBWrite"
// "klay_isSenderTxHashIndexingEnabled"
)

private val kaiaMethods = listOf(
"kaia_accountCreated",
"kaia_accounts",
"kaia_decodeAccountKey",
"kaia_getAccountKey",
"kaia_getCode",
"kaia_encodeAccountKey",
"kaia_getAccount",
"kaia_getAccount",
"kaia_sign",
"kaia_isContractAccount",

"kaia_getCommittee",
"kaia_getCommitteeSize",
"kaia_getCouncil",
"kaia_getCouncilSize",

"kaia_getRewards",
"kaia_getStorageAt",
"kaia_syncing",

"kaia_call",

"kaia_estimateGas",

"kaia_estimateComputationCost",
"kaia_pendingTransactions",
"kaia_createAccessList",

"kaia_resend",

"kaia_chainID",
"kaia_clientVersion",
"kaia_gasPriceAt",
"kaia_gasPrice",
"kaia_protocolVersion",
"kaia_getChainConfig",
"kaia_forkStatus",
"kaia_getFilterChanges",
"kaia_getFilterLogs",
"kaia_newBlockFilter",
"kaia_newPendingTransactionFilter",
"kaia_uninstallFilter",
"kaia_unsubscribe",
"kaia_getLogs",
"kaia_subscribe",
"kaia_newFilter",

"kaia_feeHistory",
"kaia_lowerBoundGasPrice",
"kaia_upperBoundGasPrice",
"kaia_maxPriorityFeePerGas",

"kaia_getStakingInfo",
"kaia_sha3",
"kaia_recoverFromTransaction",
"kaia_recoverFromMessage",
"kaia_getProof",
"kaia_nodeAddress",

// they exist, but i have doubts that we need to expose them
// "kaia_rewardbase"
// "kaia_isParallelDBWrite"
// "kaia_isSenderTxHashIndexingEnabled"
)

private val harmonyMethods = listOf(
"hmy_newFilter",
"hmy_newBlockFilter",
Expand Down Expand Up @@ -495,11 +591,11 @@ class DefaultEthereumMethods(

override fun createQuorumFor(method: String): CallQuorum {
return when {
possibleNotIndexedMethods.contains(method) || harmonyPossibleNotIndexedMethods.contains(method) || klayPossibleNotIndexedMethods.contains(method) -> NotNullQuorum()
specialMethods.contains(method) || harmonySpecialMethods.contains(method) || klaySpecialMethods.contains(method) -> {
possibleNotIndexedMethods.contains(method) || harmonyPossibleNotIndexedMethods.contains(method) || klayPossibleNotIndexedMethods.contains(method) || kaiaPossibleNotIndexedMethods.contains(method) -> NotNullQuorum()
specialMethods.contains(method) || harmonySpecialMethods.contains(method) || klaySpecialMethods.contains(method) || kaiaSpecialMethods.contains(method) -> {
when (method) {
"eth_getTransactionCount", "hmy_getTransactionCount", "klay_getTransactionCount" -> MaximumValueQuorum()
"eth_sendRawTransaction", "hmy_sendRawStakingTransaction", "hmy_sendRawTransaction", "klay_sendRawTransaction", "Filecoin.MpoolPush" -> BroadcastQuorum()
"eth_getTransactionCount", "hmy_getTransactionCount", "klay_getTransactionCount", "kaia_getTransactionCount" -> MaximumValueQuorum()
"eth_sendRawTransaction", "hmy_sendRawStakingTransaction", "hmy_sendRawTransaction", "klay_sendRawTransaction", "kaia_sendRawTransaction", "Filecoin.MpoolPush" -> BroadcastQuorum()
else -> AlwaysQuorum()
}
}
Expand Down Expand Up @@ -535,6 +631,9 @@ class DefaultEthereumMethods(
klayMethods
.plus(klaySpecialMethods)
.plus(klayPossibleNotIndexedMethods)
.plus(kaiaMethods)
.plus(kaiaSpecialMethods)
.plus(kaiaPossibleNotIndexedMethods)
Chain.MANTLE__MAINNET, Chain.MANTLE__SEPOLIA ->
listOf(
"rollup_gasPrices",
Expand Down

0 comments on commit 5fd26ac

Please sign in to comment.