Skip to content

Commit

Permalink
fixing wrong migration from helper to indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
oak committed May 20, 2022
1 parent e6fc3fc commit 81ab023
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 139 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package com.syntifi.near.api.helper.json.deserializer;
package com.syntifi.near.api.indexer.json.deserializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.syntifi.near.api.common.model.key.PublicKey;
import com.syntifi.near.api.helper.model.RecentActivityAccessKey;
import com.syntifi.near.api.helper.model.RecentActivityArgAddKey;
import com.syntifi.near.api.helper.model.RecentActivityArgCreateAccount;
import com.syntifi.near.api.helper.model.RecentActivityArgDeleteAccount;
import com.syntifi.near.api.helper.model.RecentActivityArgDeleteKey;
import com.syntifi.near.api.helper.model.RecentActivityArgDeployContract;
import com.syntifi.near.api.helper.model.RecentActivityArgFunctionCall;
import com.syntifi.near.api.helper.model.RecentActivityArgStake;
import com.syntifi.near.api.helper.model.RecentActivityArgTransfer;
import com.syntifi.near.api.helper.model.RecentActivityItem;
import com.syntifi.near.api.helper.model.RecentActivityPermission;
import com.syntifi.near.api.helper.service.exception.NearHelperServiceException;
import com.syntifi.near.api.indexer.model.RecentActivityAccessKey;
import com.syntifi.near.api.indexer.model.RecentActivityArgAddKey;
import com.syntifi.near.api.indexer.model.RecentActivityArgCreateAccount;
import com.syntifi.near.api.indexer.model.RecentActivityArgDeleteAccount;
import com.syntifi.near.api.indexer.model.RecentActivityArgDeleteKey;
import com.syntifi.near.api.indexer.model.RecentActivityArgDeployContract;
import com.syntifi.near.api.indexer.model.RecentActivityArgFunctionCall;
import com.syntifi.near.api.indexer.model.RecentActivityArgStake;
import com.syntifi.near.api.indexer.model.RecentActivityArgTransfer;
import com.syntifi.near.api.indexer.model.RecentActivityItem;
import com.syntifi.near.api.indexer.model.RecentActivityPermission;
import com.syntifi.near.api.indexer.service.exception.NearIndexerServiceException;

import java.io.IOException;
import java.math.BigInteger;
Expand Down Expand Up @@ -90,7 +90,7 @@ public RecentActivityItem deserialize(JsonParser p, DeserializationContext ctxt)
.beneficiaryId(argsNode.get("beneficiary_id").asText())
.build());
} else {
throw new NearHelperServiceException(
throw new NearIndexerServiceException(
String.format("Action %s not mapped for deserialization", recentActivityItem.getActionKind()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import java.util.ArrayList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

/**
* RecentActivityArg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.syntifi.near.api.common.model.key.PublicKey;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.syntifi.near.api.common.model.key.PublicKey;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.syntifi.near.api.helper.json.deserializer.RecentActivityItemDeserializer;
import com.syntifi.near.api.indexer.json.deserializer.RecentActivityItemDeserializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.syntifi.near.api.helper.model;
package com.syntifi.near.api.indexer.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.syntifi.near.api.common.service.NearObjectMapper;
import com.syntifi.near.api.indexer.model.AccountIdList;
import com.syntifi.near.api.indexer.model.RecentActivity;
import com.syntifi.near.api.indexer.model.StakingDeposit;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
Expand Down Expand Up @@ -49,6 +50,15 @@ public interface NearIndexerService {
@GET("staking-deposits/{accountId}")
Call<List<StakingDeposit>> getStakingDeposits(@Path("accountId") String accountId);

/**
* Fetches a list of recent activities for one account
*
* @param accountId the account to fetch activity
* @return list of recent activity for the account
*/
@GET("account/{accountId}/activity")
Call<RecentActivity> getNearRecentActivity(@Path("accountId") String accountId);

/**
* NearIndexerService builder
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.syntifi.near.api.indexer.service.exception;


/**
* Thrown on Near helper service error
*
* @author Alexandre Carvalho
* @author Andre Bertolace
* @since 0.2.0
*/
public class NearIndexerServiceException extends RuntimeException {
public NearIndexerServiceException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.syntifi.near.api.indexer.service;

import com.syntifi.near.api.indexer.model.AccountIdList;
import com.syntifi.near.api.indexer.model.RecentActivity;
import com.syntifi.near.api.indexer.model.StakingDeposit;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -63,4 +64,21 @@ void getStakingDeposits_valid() throws IOException {

stakingDeposits.forEach(i -> LOGGER.debug("deposit: {} validator: {}", i.getDeposit(), i.getValidator()));
}

@Test
void getNearRecentActivity_valid() throws IOException {
Response<RecentActivity> value = nearIndexerService.getNearRecentActivity("wallet-test.testnet").execute();

assertTrue(value.isSuccessful());

RecentActivity nearValue = value.body();

assertNotNull(nearValue);

nearValue.forEach(item -> LOGGER.debug("Item kind: {}", item.getActionKind()));

LOGGER.debug("Response {}", nearValue.size());

assertNotNull(nearValue);
}
}

0 comments on commit 81ab023

Please sign in to comment.