diff --git a/config.toml b/config.toml index d096ce8..35e061f 100644 --- a/config.toml +++ b/config.toml @@ -11,6 +11,7 @@ min_signal = 100 verbose = true num_reported_options = 2 execution_mode = "none" -opt_mode = "fast" +opt_mode = "optimal" network_subgraph_endpoint = "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet" protocol_network = "mainnet" +syncing_networks = ["mainnet", "gnosis"] diff --git a/docs/src/configuration.md b/docs/src/configuration.md index 93da2b9..c42891e 100644 --- a/docs/src/configuration.md +++ b/docs/src/configuration.md @@ -24,6 +24,7 @@ num_reported_options = 2 execution_mode = "none" opt_mode = "fast" protocol_network = "mainnet" +syncing_networks = ["mainnet"] ``` @@ -83,6 +84,9 @@ protocol_network = "mainnet" - `protocol_network::String`: Defines the protocol network that allocation transactions should be sent to. The current protocol network options are "mainnet", "goerli", "arbitrum", and "arbitrum-goerli". By default, `"mainnet"` +- `syncing_networks::Vector{String}`: The list of syncing networks to support when selecting + the set of possible subgraphs. This list should match the networks available to your + graph-node. By default, the list is a singleton of your protocol network ### Example Configurations @@ -107,6 +111,7 @@ num_reported_options = 2 execution_mode = "actionqueue" indexer_url = "https://localhost:8000" protocol_network = "arbitrum" +syncing_network = ["mainnet"] ``` #### Indexer Rules diff --git a/src/configuration.jl b/src/configuration.jl index c2f4a83..fbbeef1 100644 --- a/src/configuration.jl +++ b/src/configuration.jl @@ -59,6 +59,9 @@ Set default values for the config dictionary if the value was not specified in t - `protocol_network::String`: Defines the protocol network that allocation transactions should be sent to. The current protocol network options are "mainnet", "goerli", "arbitrum", and "arbitrum-goerli". By default, `"mainnet"` +- `syncing_networks::Vector{String}`: The list of syncing networks to support when selecting + the set of possible subgraphs. This list should match the networks available to your + graph-node. By default, the list is a singleton of your protocol network ```julia julia> using AllocationOpt @@ -80,6 +83,7 @@ Dict{String, Any} with 16 entries: "network_subgraph_endpoint" => "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet" "whitelist" => String[] "protocol_network" => "mainnet" + "syncing_networks" => String["mainnet"] ``` """ function configuredefaults!(config::AbstractDict) @@ -105,6 +109,7 @@ function configuredefaults!(config::AbstractDict) setdefault!(config, "verbose", false) setdefault!(config, "opt_mode", "optimal") setdefault!(config, "protocol_network", "mainnet") + setdefault!(config, "syncing_networks", String[config["protocol_network"]]) return config end @@ -152,6 +157,7 @@ Dict{String, Any} with 13 entries: "max_allocations" => 5 "frozenlist" => Union{}[] "protocol_network" => "mainnet" + "syncing_networks" => String["mainnet", "gnosis"] ``` """ readconfig(p::AbstractString) = p |> TOML.parsefile diff --git a/src/data.jl b/src/data.jl index f0a13f7..f12d606 100644 --- a/src/data.jl +++ b/src/data.jl @@ -2,7 +2,7 @@ # SPDX-Licen se-Identifier: MIT """ - squery() + squery(config::AbstractDict) Return the components of a GraphQL query for subgraphs. @@ -10,16 +10,19 @@ For use with the TheGraphData.jl package. ```julia julia> using AllocationOpt -julia> value, args, fields = AllocationOpt.squery() +julia> config = Dict("syncing_networking" => ["mainnet"]) +julia> value, args, fields = AllocationOpt.squery(config) ("subgraphDeployments", Dict{String, Union{Dict{String, String}, String}}(), ["ipfsHash", "signalledTokens", "stakedTokens"]) ``` # Extended Help You can find TheGraphData.jl at https://github.com/semiotic-ai/TheGraphData.jl """ -function squery() +function squery(config::AbstractDict) v = "subgraphDeployments" - a = Dict{String,Union{Dict{String,String},String}}() + a = Dict{String,Any}( + "where" => Dict{String,Any}("network_in" => config["syncing_networks"]) + ) f = ["ipfsHash", "signalledTokens", "stakedTokens", "deniedAt"] return v, a, f end @@ -180,7 +183,7 @@ function read(::Nothing, config::AbstractDict{String,Any}) flextable(d) end - s = flextable(@mock(paginated_query(squery()...))) + s = flextable(@mock(paginated_query(squery(config)...))) n = flextable(@mock(query(nquery()...))) # Convert string types to GRT diff --git a/test/configuration.jl b/test/configuration.jl index db59fa9..1970e54 100644 --- a/test/configuration.jl +++ b/test/configuration.jl @@ -26,6 +26,7 @@ @test !config["verbose"] @test config["opt_mode"] == "optimal" @test config["protocol_network"] == "mainnet" + @test config["syncing_networks"] == ["mainnet"] config = Dict{String,Any}("id" => "a", "gas" => 0) config = AllocationOpt.configuredefaults!(config) diff --git a/test/data.jl b/test/data.jl index b95cc96..2758f91 100644 --- a/test/data.jl +++ b/test/data.jl @@ -3,10 +3,13 @@ @testset "data" begin @testset "squery" begin - v, a, f = AllocationOpt.squery() + config = Dict("syncing_networks" => ["mainnet"]) + v, a, f = AllocationOpt.squery(config) @test v == "subgraphDeployments" @test f == ["ipfsHash", "signalledTokens", "stakedTokens", "deniedAt"] - @test a == Dict{String,Union{Dict{String,String},String}}() + @test a == Dict{String,Union{Dict{String,Vector{String}},String}}( + "where" => Dict("network_in" => ["mainnet"]) + ) end @testset "iquery" begin @@ -224,6 +227,7 @@ "verbose" => false, "network_subgraph_endpoint" => "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet", "readdir" => nothing, + "syncing_networks" => ["mainnet"], ) apply(paginated_query_success_patch) do apply(query_success_patch) do