Skip to content

Commit

Permalink
support avail network
Browse files Browse the repository at this point in the history
  • Loading branch information
a10zn8 authored and Кирилл committed Jul 23, 2024
1 parent 35c87d6 commit 2b3746a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CallTargetsHolder {
BITCOIN -> DefaultBitcoinMethods()
ETHEREUM -> DefaultEthereumMethods(chain, hasLogsOracle)
STARKNET -> DefaultStarknetMethods(chain)
POLKADOT -> DefaultPolkadotMethods()
POLKADOT -> DefaultPolkadotMethods(chain)
SOLANA -> DefaultSolanaMethods()
NEAR -> DefaultNearMethods()
ETHEREUM_BEACON_CHAIN -> DefaultBeaconChainMethods()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package io.emeraldpay.dshackle.upstream.calls

import io.emeraldpay.dshackle.Chain
import io.emeraldpay.dshackle.quorum.AlwaysQuorum
import io.emeraldpay.dshackle.quorum.BroadcastQuorum
import io.emeraldpay.dshackle.quorum.CallQuorum
Expand All @@ -25,7 +26,9 @@ import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
* Default configuration for Ethereum based RPC. Defines optimal Quorum strategies for different methods, and provides
* hardcoded results for base methods, such as `net_version`, `web3_clientVersion` and similar
*/
class DefaultPolkadotMethods : CallMethods {
class DefaultPolkadotMethods(
val chain: Chain,
) : CallMethods {

companion object {
val subs = setOf(
Expand Down Expand Up @@ -142,11 +145,33 @@ class DefaultPolkadotMethods : CallMethods {
"system_version",
)

private val availMethods = setOf(
"chainSpec_v1_chainName",
"chainSpec_v1_genesisHash",
"chainSpec_v1_properties",
"kate_blockLength",
"kate_queryDataProof",
"kate_queryProof",
"kate_queryRows",
"mmr_generateProof",
"mmr_root",
"mmr_verifyProof",
"mmr_verifyProofStateless",
)

private val add = setOf(
"author_submitExtrinsic",
)

private val allowedMethods: Set<String> = all + add
private val allowedMethods: Set<String> = all + add + specificMethods()

private fun specificMethods(): Set<String> {
return if (chain == Chain.AVAIL__MAINNET || chain == Chain.AVAIL__TESTNET) {
availMethods
} else {
emptySet()
}
}

override fun createQuorumFor(method: String): CallQuorum {
return when {
Expand Down

0 comments on commit 2b3746a

Please sign in to comment.