From ae098a58e61f9f1fdb83f76d16302b013fd7dbad Mon Sep 17 00:00:00 2001 From: Niccolo Raspa Date: Tue, 11 Apr 2023 16:10:46 +0200 Subject: [PATCH 1/3] Enable CORS on localosmosis --- tests/localosmosis/scripts/setup.sh | 23 +++++++++++++++++++ .../state_export/scripts/start.sh | 19 +++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tests/localosmosis/scripts/setup.sh b/tests/localosmosis/scripts/setup.sh index 2646f7fdde3..7ff20f1dbb6 100755 --- a/tests/localosmosis/scripts/setup.sh +++ b/tests/localosmosis/scripts/setup.sh @@ -105,11 +105,33 @@ add_genesis_accounts () { } edit_config () { + # Remove seeds dasel put string -f $CONFIG_FOLDER/config.toml '.p2p.seeds' '' # Expose the rpc dasel put string -f $CONFIG_FOLDER/config.toml '.rpc.laddr' "tcp://0.0.0.0:26657" + + # Disable fast_sync + dasel put bool -f $CONFIG_FOLDER/config.toml '.fast_sync' 'false' +} + +enable_cors () { + + # Enable cors on RPC + dasel put string -f $CONFIG_FOLDER/config.toml -v "*" '.rpc.cors_allowed_origins.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "Accept-Encoding" '.rpc.cors_allowed_headers.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "DELETE" '.rpc.cors_allowed_methods.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "OPTIONS" '.rpc.cors_allowed_methods.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "PATCH" '.rpc.cors_allowed_methods.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "PUT" '.rpc.cors_allowed_methods.[]' + + # Enable unsafe cors and swagger on the api + dasel put bool -f $CONFIG_FOLDER/app.toml -v "true" '.api.swagger' + dasel put bool -f $CONFIG_FOLDER/app.toml -v "true" '.api.enabled-unsafe-cors' + + # Enable cors on gRPC Web + dasel put bool -f $CONFIG_FOLDER/app.toml -v "true" '.grpc-web.enable-unsafe-cors' } run_with_retries() { @@ -165,6 +187,7 @@ then edit_genesis add_genesis_accounts edit_config + enable_cors fi osmosisd start --home $OSMOSIS_HOME & diff --git a/tests/localosmosis/state_export/scripts/start.sh b/tests/localosmosis/state_export/scripts/start.sh index ffcade0f681..bbf826788d4 100755 --- a/tests/localosmosis/state_export/scripts/start.sh +++ b/tests/localosmosis/state_export/scripts/start.sh @@ -33,6 +33,24 @@ edit_config () { dasel put string -f $CONFIG_FOLDER/config.toml '.rpc.laddr' "tcp://0.0.0.0:26657" } +enable_cors () { + + # Enable cors on RPC + dasel put string -f $CONFIG_FOLDER/config.toml -v "*" '.rpc.cors_allowed_origins.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "Accept-Encoding" '.rpc.cors_allowed_headers.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "DELETE" '.rpc.cors_allowed_methods.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "OPTIONS" '.rpc.cors_allowed_methods.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "PATCH" '.rpc.cors_allowed_methods.[]' + dasel put string -f $CONFIG_FOLDER/config.toml -v "PUT" '.rpc.cors_allowed_methods.[]' + + # Enable unsafe cors and swagger on the api + dasel put bool -f $CONFIG_FOLDER/app.toml -v "true" '.api.swagger' + dasel put bool -f $CONFIG_FOLDER/app.toml -v "true" '.api.enabled-unsafe-cors' + + # Enable cors on gRPC Web + dasel put bool -f $CONFIG_FOLDER/app.toml -v "true" '.grpc-web.enable-unsafe-cors' +} + if [[ ! -d $CONFIG_FOLDER ]] then @@ -67,6 +85,7 @@ then --prune-ibc edit_config + enable_cors fi osmosisd start --home $OSMOSIS_HOME --x-crisis-skip-assert-invariants From f0d2f4dc54c98b44d05dce99fc7615dcfea44bcb Mon Sep 17 00:00:00 2001 From: Niccolo Raspa <6024049+niccoloraspa@users.noreply.github.com> Date: Tue, 11 Apr 2023 16:18:02 +0200 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa6001fa312..56eff339aab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#4582](https://github.com/osmosis-labs/osmosis/pull/4582) Consistently generate build tags metadata, to return a comma-separated list without stray quotes. This affects the output from `version` CLI subcommand and server info API calls. * [#4549](https://github.com/osmosis-labs/osmosis/pull/4549) Add single pool price estimate queries * [#4767](https://github.com/osmosis-labs/osmosis/pull/4767) Disable create pool with non-zero exit fee + * [#4891](https://github.com/osmosis-labs/osmosis/pull/4891) Enable CORS by default on localosmosis ### API Breaks From c0a85370203263f76039588351d13310fb3a6fab Mon Sep 17 00:00:00 2001 From: Niccolo Raspa <6024049+niccoloraspa@users.noreply.github.com> Date: Tue, 11 Apr 2023 16:18:50 +0200 Subject: [PATCH 3/3] Update setup.sh --- tests/localosmosis/scripts/setup.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/localosmosis/scripts/setup.sh b/tests/localosmosis/scripts/setup.sh index 7ff20f1dbb6..579df3a1427 100755 --- a/tests/localosmosis/scripts/setup.sh +++ b/tests/localosmosis/scripts/setup.sh @@ -111,9 +111,6 @@ edit_config () { # Expose the rpc dasel put string -f $CONFIG_FOLDER/config.toml '.rpc.laddr' "tcp://0.0.0.0:26657" - - # Disable fast_sync - dasel put bool -f $CONFIG_FOLDER/config.toml '.fast_sync' 'false' } enable_cors () {