From 53085e8e1b0bc7152691310ece363b21a700d1b5 Mon Sep 17 00:00:00 2001 From: kirill Date: Thu, 17 Sep 2026 17:21:39 +0400 Subject: [PATCH] Fix algorand spec --- docs/method-specs.md | 5 +- pkg/methods/methods_spec_test.go | 30 ++++ pkg/methods/specs/algorand-json-rpc.json | 89 +++++++++++ pkg/methods/specs/algorand-rest.json | 121 +++++++++++++++ pkg/methods/specs/algorand.json | 187 +---------------------- 5 files changed, 248 insertions(+), 184 deletions(-) create mode 100644 pkg/methods/specs/algorand-json-rpc.json create mode 100644 pkg/methods/specs/algorand-rest.json diff --git a/docs/method-specs.md b/docs/method-specs.md index e44463b..b8f4506 100644 --- a/docs/method-specs.md +++ b/docs/method-specs.md @@ -232,6 +232,7 @@ The `specs` package embeds the specs below (see [`pkg/methods/specs/`](../pkg/me | `hyperliquid` | `hyperliquid-eth`, `hyperliquid-rest-additional` | | `tron` | `tron-json-rpc`, `tron-rest`, `tron-rest-solidity` | | `bitcoin` | `bitcoin-json-rpc`, `bitcoin-esplora` | +| `algorand` | `algorand-json-rpc`, `algorand-rest` | | `near` | `near-json-rpc` | | `starknet` | `starknet-json-rpc` | | `stellar` | `stellar-json-rpc`, `stellar-horizon` | @@ -249,10 +250,10 @@ Grouped by the transports they declare: | `api-connectors` | Specs | | --- | --- | | `json-rpc`, `websocket` | `arbitrum`, `avail`, `cronos_zkevm`, `eth-json-rpc`, `fantom`, `filecoin`, `harmony_0`, `harmony_1`, `hyperliquid-eth`, `klaytn-json-rpc`, `linea`, `mantle`, `optimism`, `polkadot-json-rpc`, `polygon`, `polygon_zkevm`, `rootstock`, `scroll`, `sei`, `solana-json-rpc`, `viction`, `zk` | -| `json-rpc` | `algorand`, `aztec`, `bitcoin-json-rpc`, `celestia`, `near-json-rpc`, `starknet-json-rpc`, `stellar-json-rpc`, `tron-json-rpc` | +| `json-rpc` | `algorand-json-rpc`, `aztec`, `bitcoin-json-rpc`, `celestia`, `near-json-rpc`, `starknet-json-rpc`, `stellar-json-rpc`, `tron-json-rpc` | | `websocket` | `eth-websocket`, `klaytn-websocket`, `polkadot-websocket`, `solana-websocket` | | `tendermint` | `cosmos-tendermint` | -| `rest` | `aptos`, `cosmos-rest`, `eth-beacon-chain`, `stellar-horizon`, `ton-http-v2`, `tron-rest` | +| `rest` | `algorand-rest`, `aptos`, `cosmos-rest`, `eth-beacon-chain`, `stellar-horizon`, `ton-http-v2`, `tron-rest` | | `rest-indexer` | `ton-index-v3` | | `grpc` | `cosmos-grpc`, `sui-grpc` | | `rest-additional` | `bitcoin-esplora`, `hyperliquid-rest-additional`, `tron-rest-solidity` | diff --git a/pkg/methods/methods_spec_test.go b/pkg/methods/methods_spec_test.go index a8418d8..3ff9ae7 100644 --- a/pkg/methods/methods_spec_test.go +++ b/pkg/methods/methods_spec_test.go @@ -397,6 +397,36 @@ func TestStellarSpecLoads(t *testing.T) { assert.Empty(t, params) } +func TestAlgorandSpecLoads(t *testing.T) { + err := specs.NewMethodSpecLoader().Load() + assert.NoError(t, err) + + spec := specs.GetSpecMethod("algorand", "getBlock") + assert.NotNil(t, spec) + + spec = specs.GetSpecMethod("algorand", "GET#/v2/status") + assert.NotNil(t, spec) + + spec = specs.GetSpecMethod("algorand", "eth_call") + assert.Nil(t, spec) + + // each API's methods resolve only for upstreams that carry its connector + jsonRpcMethods := specs.GetSpecMethodsByConnectors("algorand", []specs.ApiConnectorType{specs.JsonRpcConnector}) + assert.Contains(t, jsonRpcMethods[specs.DefaultMethodGroup], "getHealth") + assert.Contains(t, jsonRpcMethods[specs.DefaultMethodGroup], "sendRawTransaction") + assert.NotContains(t, jsonRpcMethods[specs.DefaultMethodGroup], "GET#/health") + + restMethods := specs.GetSpecMethodsByConnectors("algorand", []specs.ApiConnectorType{specs.RestConnector}) + assert.Contains(t, restMethods[specs.DefaultMethodGroup], "GET#/health") + assert.Contains(t, restMethods[specs.DefaultMethodGroup], "POST#/v2/transactions") + assert.NotContains(t, restMethods[specs.DefaultMethodGroup], "getHealth") + + template, params, ok := specs.MatchRestMethod("algorand", "GET#/v2/blocks/12345/hash") + assert.True(t, ok) + assert.Equal(t, "GET#/v2/blocks/*/hash", template) + assert.Equal(t, []string{"12345"}, params) +} + func TestLoadSpecGrpcDefaults(t *testing.T) { err := specs.NewMethodSpecLoaderWithFs(os.DirFS("test_specs/grpc")).Load() assert.NoError(t, err) diff --git a/pkg/methods/specs/algorand-json-rpc.json b/pkg/methods/specs/algorand-json-rpc.json new file mode 100644 index 0000000..62ce292 --- /dev/null +++ b/pkg/methods/specs/algorand-json-rpc.json @@ -0,0 +1,89 @@ +{ + "openrpc": "1.0.0", + "info": { + "title": "Algorand JSON-RPC methods", + "version": "1.0.0" + }, + "spec": { + "name": "algorand-json-rpc", + "api-connectors": [ + "json-rpc" + ], + "type": "plain" + }, + "methods": [ + { + "name": "status", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "getBlock", + "params": [] + }, + { + "name": "getTransaction", + "params": [] + }, + { + "name": "getAccount", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "getAssetByID", + "params": [] + }, + { + "name": "getApplicationByID", + "params": [] + }, + { + "name": "sendRawTransaction", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "getTransactionParams", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "getPendingTransactions", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "getSupply", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "getVersions", + "params": [] + }, + { + "name": "getGenesis", + "params": [] + }, + { + "name": "getHealth", + "params": [], + "settings": { + "cacheable": false + } + } + ] +} diff --git a/pkg/methods/specs/algorand-rest.json b/pkg/methods/specs/algorand-rest.json new file mode 100644 index 0000000..4d42aa9 --- /dev/null +++ b/pkg/methods/specs/algorand-rest.json @@ -0,0 +1,121 @@ +{ + "openrpc": "1.0.0", + "info": { + "title": "Algorand REST methods", + "version": "1.0.0" + }, + "spec": { + "name": "algorand-rest", + "api-connectors": [ + "rest" + ], + "type": "plain" + }, + "methods": [ + { + "name": "GET#/v2/status", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/status/wait-for-block-after/*", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/blocks/*", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/blocks/*/hash", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/accounts/*", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/transactions/params", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/transactions/pending", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/transactions/pending/*", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "POST#/v2/transactions", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/applications/*", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/assets/*", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/v2/ledger/supply", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/genesis", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/versions", + "params": [], + "settings": { + "cacheable": false + } + }, + { + "name": "GET#/health", + "params": [], + "settings": { + "cacheable": false + } + } + ] +} diff --git a/pkg/methods/specs/algorand.json b/pkg/methods/specs/algorand.json index e0e43b5..da72d0a 100644 --- a/pkg/methods/specs/algorand.json +++ b/pkg/methods/specs/algorand.json @@ -1,192 +1,15 @@ { "openrpc": "1.0.0", "info": { - "title": "Algorand JSON-RPC methods", + "title": "Algorand methods", "version": "1.0.0" }, "spec": { - "api-connectors": ["json-rpc"], "name": "algorand", - "type": "plain" + "type": "bundle" }, - "methods": [ - { - "name": "status", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "getBlock", - "params": [] - }, - { - "name": "getTransaction", - "params": [] - }, - { - "name": "getAccount", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "getAssetByID", - "params": [] - }, - { - "name": "getApplicationByID", - "params": [] - }, - { - "name": "sendRawTransaction", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "getTransactionParams", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "getPendingTransactions", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "getSupply", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "getVersions", - "params": [] - }, - { - "name": "getGenesis", - "params": [] - }, - { - "name": "getHealth", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/status", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/status/wait-for-block-after/*", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/blocks/*", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/blocks/*/hash", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/accounts/*", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/transactions/params", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/transactions/pending", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/transactions/pending/*", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "POST#/v2/transactions", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/applications/*", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/assets/*", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/v2/ledger/supply", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/genesis", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/versions", - "params": [], - "settings": { - "cacheable": false - } - }, - { - "name": "GET#/health", - "params": [], - "settings": { - "cacheable": false - } - } + "spec-imports": [ + "algorand-json-rpc", + "algorand-rest" ] }