From c9cd38ab98747843a8cc6e83dc2d61d2e5e3a260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liviu=20D=C4=83nicel?= Date: Wed, 23 Nov 2022 15:33:41 +0100 Subject: [PATCH 1/3] Convert block explorer call to rpc call --- roles/validate_config_file/tasks/main.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/roles/validate_config_file/tasks/main.yml b/roles/validate_config_file/tasks/main.yml index bc37422..28cdc2e 100644 --- a/roles/validate_config_file/tasks/main.yml +++ b/roles/validate_config_file/tasks/main.yml @@ -16,20 +16,24 @@ - name: Defining node address request uri: - url: https://blockexplorer.bloxberg.org/api?module=account&action=balance&address={{ config_file_map.ADDRESS }} - method: GET + url: https://bloxberg.ethernity.cloud + method: POST headers: Content-Type: "application/json" + body_format: json + body: '{"method":"eth_getBalance","params":["{{ config_file_map.ADDRESS }}","latest"],"id":1,"jsonrpc":"2.0"}' register: addressbergs retries: 64 delay: 3 - name: Defining result address request uri: - url: https://blockexplorer.bloxberg.org/api?module=account&action=balance&address={{ config_file_map.RESULT_ADDRESS }} - method: GET + url: https://bloxberg.ethernity.cloud + method: POST headers: Content-Type: "application/json" + body_format: json + body: '{"method":"eth_getBalance","params":["{{ config_file_map.RESULT_ADDRESS }}","latest"],"id":1,"jsonrpc":"2.0"}' register: resultbergs retries: 64 delay: 3 From 4d2b78c0e7764e52658acf1af4562eb6b6d7f58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liviu=20D=C4=83nicel?= Date: Wed, 23 Nov 2022 16:28:57 +0100 Subject: [PATCH 2/3] Full RPC querying --- roles/validate_config_file/tasks/main.yml | 28 +++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/roles/validate_config_file/tasks/main.yml b/roles/validate_config_file/tasks/main.yml index 28cdc2e..4c6cba2 100644 --- a/roles/validate_config_file/tasks/main.yml +++ b/roles/validate_config_file/tasks/main.yml @@ -50,38 +50,36 @@ - name: Evaluate ADDRESS message debug: - msg: "{{ addressbergs.json.message }}" - failed_when: addressbergs.json.message != "OK" - when: addressbergs.json.message is defined + msg: "{{ addressbergs.json }}" + failed_when: addressbergs.json == "" - name: Evaluate RESULT ADDRESS message - debug: - msg: "{{ resultbergs.json.message }}" - failed_when: resultbergs.json.message != "OK" - when: resultbergs.json.message is defined + debug: + msg: "{{ resultbergs.json }}" + failed_when: resultbergs.json == "" - name: Get Node ADDRESS balance debug: - msg: - - "Node ADDRESS balance: '{{ addressbergs.json.result|int / 1000000000000000000 }}' bergs." + msg: + - "Node ADDRESS balance: '{{ addressbergs.json.result|int}}' bergs." - "Please get bergs on {{ config_file_map.ADDRESS }} from https://faucet.bloxberg.org/ and try again." failed_when: - - addressbergs.json.result|int == 0 - when: + - addressbergs.json.result|int == 0x0 + when: - addressbergs.json.result is defined - - addressbergs.json.result == '0' + - addressbergs.json.result == '0x0' - name: Get RESULT ADDRESS balance debug: - msg: - - "Node RESULT ADDRESS balance: '{{ resultbergs.json.result|int / 1000000000000000000 }}' bergs." + msg: + - "Node RESULT ADDRESS balance: '{{ resultbergs.json.result|int}}' bergs." - "Please get bergs on {{ config_file_map.RESULT_ADDRESS }} from https://faucet.bloxberg.org/ and try again." failed_when: - resultbergs.json.result|int == 0 when: - resultbergs.json.result is defined - - resultbergs.json.result == '0' + - resultbergs.json.result == '0x0' - meta: end_play when: (resultbergs.json.result is defined and resultbergs.json.result == '0') or (addressbergs.json.result is defined and addressbergs.json.result == '0') or (config_file_map.PRIVATE_KEY == config_file_map.RESULT_PRIVATE_KEY) or (config_file_map.ADDRESS == config_file_map.RESULT_ADDRESS) From 2962522ee48dd11e670f9eee7b5da1b2ebc15532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liviu=20D=C4=83nicel?= Date: Wed, 23 Nov 2022 18:24:05 +0100 Subject: [PATCH 3/3] Fix --- roles/validate_config_file/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/validate_config_file/tasks/main.yml b/roles/validate_config_file/tasks/main.yml index 4c6cba2..d852893 100644 --- a/roles/validate_config_file/tasks/main.yml +++ b/roles/validate_config_file/tasks/main.yml @@ -65,7 +65,7 @@ - "Node ADDRESS balance: '{{ addressbergs.json.result|int}}' bergs." - "Please get bergs on {{ config_file_map.ADDRESS }} from https://faucet.bloxberg.org/ and try again." failed_when: - - addressbergs.json.result|int == 0x0 + - addressbergs.json.result|int == 0 when: - addressbergs.json.result is defined - addressbergs.json.result == '0x0'