From f11db5c0bcda75bb88727dd2100b6212133285e3 Mon Sep 17 00:00:00 2001 From: Corey Soreff Date: Tue, 12 Apr 2022 14:10:12 +0900 Subject: [PATCH] Update HEAD to HEAD~2 according to changes in Tenderbake to follow the correct final branch included in consensus. --- .../milfont/com/tezosj/data/TezosGateway.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/milfont/com/tezosj/data/TezosGateway.java b/src/main/java/milfont/com/tezosj/data/TezosGateway.java index 6503eac..9a56dc4 100644 --- a/src/main/java/milfont/com/tezosj/data/TezosGateway.java +++ b/src/main/java/milfont/com/tezosj/data/TezosGateway.java @@ -181,7 +181,7 @@ public X509Certificate[] getAcceptedIssuers() public JSONObject getHead() throws Exception { - return (JSONObject) query("/chains/main/blocks/head", null); + return (JSONObject) query("/chains/main/blocks/head~2", null); } public JSONObject getAccountManagerForBlock(String blockHash, String accountID) throws Exception @@ -195,7 +195,7 @@ public JSONObject getAccountManagerForBlock(String blockHash, String accountID) // Gets the balance for a given address. public JSONObject getBalance(String address) throws Exception { - return (JSONObject) query("/chains/main/blocks/head/context/contracts/" + address + "/balance", null); + return (JSONObject) query("/chains/main/blocks/head~2/context/contracts/" + address + "/balance", null); } // Prepares and sends an operation to the Tezos node. @@ -205,7 +205,7 @@ private JSONObject sendOperation(JSONArray operations, EncKeys encKeys) throws E JSONObject head = new JSONObject(); String forgedOperationGroup = ""; - head = (JSONObject) query("/chains/main/blocks/head/header", null); + head = (JSONObject) query("/chains/main/blocks/head~2/header", null); forgedOperationGroup = forgeOperations(head, operations); // Check for errors. @@ -321,7 +321,7 @@ private JSONObject callRunOperation(JSONArray operations, EncKeys encKeys) throw JSONObject head = new JSONObject(); String forgedOperationGroup = ""; - head = (JSONObject) query("/chains/main/blocks/head/header", null); + head = (JSONObject) query("/chains/main/blocks/head~2/header", null); forgedOperationGroup = forgeOperations(head, operations); // Check for errors. @@ -414,7 +414,7 @@ public JSONObject sendTransaction(String from, String to, BigDecimal amount, Big } } - head = new JSONObject(query("/chains/main/blocks/head/header", null).toString()); + head = new JSONObject(query("/chains/main/blocks/head~2/header", null).toString()); account = getAccountForBlock(head.get("hash").toString(), from); counter = Integer.parseInt(account.get("counter").toString()); @@ -498,7 +498,7 @@ public JSONObject reveal(String publicKeyHash, String publicKey, EncKeys encKeys JSONObject account = new JSONObject(); Integer counter = 0; - head = new JSONObject(query("/chains/main/blocks/head/header", null).toString()); + head = new JSONObject(query("/chains/main/blocks/head~2/header", null).toString()); account = getAccountForBlock(head.get("hash").toString(), publicKeyHash); counter = Integer.parseInt(account.get("counter").toString()); @@ -583,7 +583,7 @@ private String forgeOperations(JSONObject blockHead, JSONArray operations) throw private String nodeForgeOperations(String opGroup) throws Exception { - JSONObject response = (JSONObject) query("/chains/main/blocks/head/helpers/forge/operations", opGroup); + JSONObject response = (JSONObject) query("/chains/main/blocks/head~2/helpers/forge/operations", opGroup); String forgedOperation = (String) response.get("result"); return ((forgedOperation.replaceAll("\\n", "")).replaceAll("\"", "").replaceAll("'", "")); @@ -610,7 +610,7 @@ private String computeOperationHash(SignedOperationGroup signedOpGroup) throws E private JSONObject nodeApplyOperation(JSONArray payload) throws Exception { - return (JSONObject) query("/chains/main/blocks/head/helpers/preapply/operations", payload.toString()); + return (JSONObject) query("/chains/main/blocks/head~2/helpers/preapply/operations", payload.toString()); } private JSONObject nodeRunOperation(JSONArray payload, String chainId) throws Exception @@ -619,7 +619,7 @@ private JSONObject nodeRunOperation(JSONArray payload, String chainId) throws Ex operation.put("operation", payload.get(0)); operation.put("chain_id", chainId); - return (JSONObject) query("/chains/main/blocks/head/helpers/scripts/run_operation", operation.toString()); + return (JSONObject) query("/chains/main/blocks/head~2/helpers/scripts/run_operation", operation.toString()); } private JSONObject applyOperation(JSONObject head, JSONArray operations, String operationGroupHash, @@ -998,7 +998,7 @@ public JSONObject sendDelegationOperation(String delegator, String delegate, Big } } - head = new JSONObject(query("/chains/main/blocks/head/header", null).toString()); + head = new JSONObject(query("/chains/main/blocks/head~2/header", null).toString()); account = getAccountForBlock(head.get("hash").toString(), delegator); counter = Integer.parseInt(account.get("counter").toString()); @@ -1071,7 +1071,7 @@ public JSONObject sendOriginationOperation(String from, Boolean spendable, Boole } } - head = new JSONObject(query("/chains/main/blocks/head/header", null).toString()); + head = new JSONObject(query("/chains/main/blocks/head~2/header", null).toString()); account = getAccountForBlock(head.get("hash").toString(), from); counter = Integer.parseInt(account.get("counter").toString()); @@ -1194,7 +1194,7 @@ public JSONObject sendBatchTransactions(ArrayList transact roundedFee = item.getFee().setScale(6, BigDecimal.ROUND_HALF_UP); // Get address counter. - head = new JSONObject(query("/chains/main/blocks/head/header", null).toString()); + head = new JSONObject(query("/chains/main/blocks/head~2/header", null).toString()); account = getAccountForBlock(head.get("hash").toString(), item.getFrom()); counter = Integer.parseInt(account.get("counter").toString()); @@ -1266,7 +1266,7 @@ public Boolean waitForResult(String operationHash, Integer numberOfBlocksToWait) { // Get blockchain header. - response = (JSONObject) query("/chains/main/blocks/head/header", null); + response = (JSONObject) query("/chains/main/blocks/head~2/header", null); // Acquaire current blockchain block (level) if it is zero yet. if(currentBlockNumber == 0) @@ -1444,7 +1444,7 @@ public JSONObject callContractEntryPoint(String from, String contract, BigDecima } } - head = new JSONObject(query("/chains/main/blocks/head/header", null).toString()); + head = new JSONObject(query("/chains/main/blocks/head~2/header", null).toString()); account = getAccountForBlock(head.get("hash").toString(), from); counter = Integer.parseInt(account.get("counter").toString()); @@ -1917,7 +1917,7 @@ private Pair buildParameterPairs(JSONObject jsonObj, Pair pair, List par private String[] getContractEntryPoints(String contractAddress) throws Exception { JSONObject response = (JSONObject) query( - "/chains/main/blocks/head/context/contracts/" + contractAddress + "/entrypoints", null); + "/chains/main/blocks/head~2/context/contracts/" + contractAddress + "/entrypoints", null); JSONObject entryPointsJson = (JSONObject) response.get("entrypoints"); @@ -1956,7 +1956,7 @@ private String[] getContractEntryPointsParameters(String contractAddress, String } JSONObject response = (JSONObject) query( - "/chains/main/blocks/head/context/contracts/" + contractAddress + "/entrypoints/" + entrypoint, null); + "/chains/main/blocks/head~2/context/contracts/" + contractAddress + "/entrypoints/" + entrypoint, null); JSONArray paramArray = decodeParameters(response, null); @@ -2041,7 +2041,7 @@ public ArrayList getContractStorage(String contractAddress) throws Exceptio ArrayList items = new ArrayList(); - JSONObject response = (JSONObject) query("/chains/main/blocks/head/context/contracts/" + contractAddress + "/storage/", null); + JSONObject response = (JSONObject) query("/chains/main/blocks/head~2/context/contracts/" + contractAddress + "/storage/", null); JSONArray storageArray = decodeParameters(response, null); @@ -2116,7 +2116,7 @@ public Boolean waitForAndCheckResult(String operationHash, Integer numberOfBlock { // Get blockchain header. - response = (JSONObject) query("/chains/main/blocks/head/header", null); + response = (JSONObject) query("/chains/main/blocks/head~2/header", null); // Acquaire current blockchain block (level) if it is zero yet. if(currentBlockNumber == 0) @@ -2281,7 +2281,7 @@ public JSONObject waitForAndCheckResultByDestinationAddress(String address, Inte { // Get blockchain header. - response = (JSONObject) query("/chains/main/blocks/head/header", null); + response = (JSONObject) query("/chains/main/blocks/head~2/header", null); // Acquaire current blockchain block (level) if it is zero yet. if(currentBlockNumber == 0)