Skip to content

Commit

Permalink
revert: query the consensus nodes for the account balance, account in…
Browse files Browse the repository at this point in the history
…fo, and contract info data (#1840)

This reverts commits 8243cf6 769450a and part of 094eeb8 

Signed-off-by: Nikita Lebedev <nikita.lebedev@limechain.tech>
  • Loading branch information
thenswan authored Jun 11, 2024
1 parent dcd5020 commit 61292e5
Show file tree
Hide file tree
Showing 47 changed files with 164 additions and 779 deletions.
4 changes: 0 additions & 4 deletions examples/src/main/java/AccountAliasExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ public static void main(String[] args)
.execute(client)
.getReceipt(client);

// `AccountBalanceQuery` and `AccountInfoQuery` also query the mirror node.
// Wait until the mirror node is updated with the new data.
Thread.sleep(5000);

AccountBalance balance = new AccountBalanceQuery()
.setAccountId(aliasAccountId)
.execute(client);
Expand Down
9 changes: 2 additions & 7 deletions examples/src/main/java/AccountAllowanceExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ private AccountAllowanceExample()
printBalances();
}

private void printBalances() throws PrecheckStatusException, TimeoutException, InterruptedException {
// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

private void printBalances() throws PrecheckStatusException, TimeoutException {
System.out.println(
"Alice's balance: " +
new AccountBalanceQuery().setAccountId(aliceId).execute(client).hbars
Expand All @@ -130,8 +126,7 @@ private void printBalances() throws PrecheckStatusException, TimeoutException, I
);
}

private void demonstrateAllowances()
throws PrecheckStatusException, TimeoutException, ReceiptStatusException, InterruptedException {
private void demonstrateAllowances() throws PrecheckStatusException, TimeoutException, ReceiptStatusException {
System.out.println("Approving an allowance of 2 Hbar with owner Alice and spender Bob");

new AccountAllowanceApproveTransaction()
Expand Down
10 changes: 0 additions & 10 deletions examples/src/main/java/AccountCreateWithHtsExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ public static void main(String[] args) throws Exception {
System.out.println("Current owner account id: " + nftOwnerAccountId);

// Step 6 - Show the new account ID owns the NFT

// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

String accountId = new AccountInfoQuery()
.setAccountId(aliasAccountId)
.execute(client)
Expand Down Expand Up @@ -213,11 +208,6 @@ public static void main(String[] args) throws Exception {
tokenTransferSubmit.getReceipt(client);

// Step 4 - Return the new account ID in the child record

// `AccountBalanceQuery` and `AccountInfoQuery` also query the mirror node.
// Wait until the mirror node is updated with the new data.
Thread.sleep(5000);

String accountId2 = new AccountInfoQuery()
.setAccountId(aliasAccountId2)
.execute(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ public static void main(String[] args) throws Exception {
- The alias property of the account does not have the public address
- Referred to as a hollow account
*/
// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo accountInfo = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand Down
4 changes: 0 additions & 4 deletions examples/src/main/java/CreateAccountThresholdKeyExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ public static void main(String[] args)
// (important!) wait for the transfer to go to consensus
transferTransactionResponse.getReceipt(client);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Hbar balanceAfter = new AccountBalanceQuery()
.setAccountId(newAccountId)
.execute(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ public static void main(String[] args)
* Step 6
* Get the `AccountInfo` and show that the account has contractAccountId
*/
// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo accountInfo = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand Down
4 changes: 0 additions & 4 deletions examples/src/main/java/CreateAccountWithAliasExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public static void main(String[] args) throws Exception {
* Step 6
* Get the `AccountInfo` and show that the account has contractAccountId
*/
// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo accountInfo = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand Down
16 changes: 0 additions & 16 deletions examples/src/main/java/CustomFeesExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ public static void main(String[] args)
.execute(client)
.getReceipt(client);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Hbar aliceHbar1 = new AccountBalanceQuery()
.setAccountId(aliceId)
.execute(client)
Expand All @@ -197,10 +193,6 @@ public static void main(String[] args)
.execute(client)
.getRecord(client);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Hbar aliceHbar2 = new AccountBalanceQuery()
.setAccountId(aliceId)
.execute(client)
Expand Down Expand Up @@ -259,10 +251,6 @@ public static void main(String[] args)
.execute(client)
.getRecord(client);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Map<TokenId, Long> aliceTokens4 = new AccountBalanceQuery()
.setAccountId(aliceId)
.execute(client)
Expand Down Expand Up @@ -297,10 +285,6 @@ public static void main(String[] args)
.execute(client)
.getReceipt(client);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

// wipe token on created accounts
Map<TokenId, Long> charlieTokensBeforeWipe = new AccountBalanceQuery()
.setAccountId(charlieId)
Expand Down
4 changes: 0 additions & 4 deletions examples/src/main/java/ExemptCustomFeesExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ public static void main(String[] args) throws TimeoutException, PrecheckStatusEx
* of the token that was created was not charged a custom fee in the transfer
*/

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Long firstAccountBalanceAfter = new AccountBalanceQuery()
.setAccountId(firstAccountId)
.execute(client)
Expand Down
7 changes: 1 addition & 6 deletions examples/src/main/java/MultiAppTransferExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public final class MultiAppTransferExample {
private MultiAppTransferExample() {
}

public static void main(String[] args)
throws ReceiptStatusException, TimeoutException, PrecheckStatusException, InvalidProtocolBufferException, InterruptedException {
public static void main(String[] args) throws ReceiptStatusException, TimeoutException, PrecheckStatusException, InvalidProtocolBufferException {
// the exchange creates an account for the user to transfer funds to
AccountId exchangeAccountId = new AccountCreateTransaction()
// the exchange only accepts transfers that it validates through a side channel (e.g. REST API)
Expand Down Expand Up @@ -121,10 +120,6 @@ public static void main(String[] args)
// (important!) wait for consensus by querying for the receipt
transactionResponse.getReceipt(client);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Hbar senderBalanceAfter = new AccountBalanceQuery()
.setAccountId(userAccountId)
.execute(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ public static void main(String[] args)

System.out.println("3-of-4 multi-sig account ID: " + multiSigAccountId);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountBalance balance = new AccountBalanceQuery()
.setAccountId(multiSigAccountId)
.execute(client);
Expand Down
11 changes: 0 additions & 11 deletions examples/src/main/java/ScheduledTransferExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ public static void main(String[] args)
System.out.println("Alice's ID: " + client.getOperatorAccountId());
System.out.println("Bob's ID: " + bobsId);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountBalance bobsInitialBalance = new AccountBalanceQuery()
.setAccountId(bobsId)
.execute(client);
Expand Down Expand Up @@ -145,9 +141,6 @@ public static void main(String[] args)
* Bob's balance should be unchanged. The transfer has been scheduled, but it hasn't been executed yet
* because it requires Bob's signature.
*/
// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);
AccountBalance bobsBalanceAfterSchedule = new AccountBalanceQuery()
.setAccountId(bobsId)
.execute(client);
Expand Down Expand Up @@ -186,10 +179,6 @@ public static void main(String[] args)
.execute(client)
.getReceipt(client);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountBalance balanceAfterSigning = new AccountBalanceQuery()
.setAccountId(bobsId)
.execute(client);
Expand Down
5 changes: 0 additions & 5 deletions examples/src/main/java/StakingExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public static void main(String[] args)

// Query the account info, it should show the staked account ID
// to be 0.0.3 just like what we set it to

// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo info = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand Down
10 changes: 0 additions & 10 deletions examples/src/main/java/StakingWithUpdateExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ public static void main(String[] args)

// Query the account info, it should show the staked account ID
// to be 0.0.3 just like what we set it to

// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo info = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand All @@ -109,11 +104,6 @@ public static void main(String[] args)

// Query the account info, it should show the staked account ID
// to be 0.0.3 just like what we set it to

// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

info = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand Down
4 changes: 0 additions & 4 deletions examples/src/main/java/TransactionSerializationExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public static void main(String[] args) throws Exception {

System.out.println("transferred " + amount + "...");

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Hbar senderBalanceAfter = new AccountBalanceQuery()
.setAccountId(OPERATOR_ID)
.execute(client)
Expand Down
4 changes: 0 additions & 4 deletions examples/src/main/java/TransferCryptoExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public static void main(String[] args)

System.out.println("transferred " + amount + "...");

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

Hbar senderBalanceAfter = new AccountBalanceQuery()
.setAccountId(OPERATOR_ID)
.execute(client)
Expand Down
8 changes: 0 additions & 8 deletions examples/src/main/java/TransferUsingEvmAddressExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ public static void main(String[] args) throws PrecheckStatusException, TimeoutEx
* Step 6
* Get the `AccountInfo` on the new account and show it is a hollow account by not having a public key
*/
// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo accountInfo = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand Down Expand Up @@ -124,10 +120,6 @@ public static void main(String[] args) throws PrecheckStatusException, TimeoutEx
* Step 9
* Get the `AccountInfo` of the account and show the account is now a complete account by returning the public key on the account
*/
// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo accountInfo2 = new AccountInfoQuery()
.setAccountId(newAccountId)
.execute(client);
Expand Down
4 changes: 0 additions & 4 deletions examples/src/main/java/UpdateAccountPublicKeyExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ public static void main(String[] args)
// Now we fetch the account information to check if the key was changed
System.out.println(" :: getAccount and check our current key");

// `AccountInfoQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

AccountInfo info = new AccountInfoQuery()
.setAccountId(accountId)
.execute(client);
Expand Down
1 change: 0 additions & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ dependencies {
testImplementation "io.github.json-snapshot:json-snapshot:1.0.17"
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.10.0"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.10.0"
testImplementation "org.wiremock:wiremock-standalone:3.4.2"

testRuntimeOnly "org.slf4j:slf4j-simple:2.0.9"
testRuntimeOnly "io.grpc:grpc-netty-shaded:1.57.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,6 @@ void canFetchTokenBalancesForClientOperator() throws Exception {

var tokenId = Objects.requireNonNull(response.getReceipt(testEnv.client).tokenId);

// `AccountBalanceQuery` also queries the mirror node.
// Wait until the mirror node updates with the new data.
Thread.sleep(5000);

var query = new AccountBalanceQuery();
var balance = query
.setAccountId(testEnv.operatorId)
Expand Down
Loading

0 comments on commit 61292e5

Please sign in to comment.