Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support avail network #530

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading