Skip to content

Commit

Permalink
Merge pull request #290 from cheng521521/main
Browse files Browse the repository at this point in the history
redPacket
  • Loading branch information
cheng521521 authored Aug 18, 2024
2 parents 3d09c99 + 2aec934 commit 18d6f9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class RedPacketController {

@Autowired
private RedPacketRepository redPacketRepository;

@Autowired
private RedPacketService redPacketService;
public static final Logger logger = LoggerFactory.getLogger(MemberController.class);

@PostMapping("/create")
Expand Down
34 changes: 8 additions & 26 deletions src/main/java/com/dl/officialsite/redpacket/RedPacketService.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ private void updateRedpacketStatusByChainId(String chainId) throws IOException {
}
JsonObject jsonObject = JsonParser.parseString(jsonResponse).getAsJsonObject();
JsonObject data = jsonObject.getAsJsonObject("data");
JsonArray redpacketsArray = data.getAsJsonArray("redpackets");
JsonArray lastupdatesArray = data.getAsJsonArray("lastupdates");
JsonArray redpacketsArray = data.getAsJsonArray("Redpacket");
JsonArray lastupdatesArray = data.getAsJsonArray("Lastupdate");
log.debug("lastupdatesArray" + lastupdatesArray.toString());

List<RedPacket> redPacketList = redPacketRepository.findUnfinishedRedpacketByChainId(chainId);
Expand Down Expand Up @@ -131,8 +131,7 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException {
HttpPost request = null;
switch (chainId) {
case Constants.CHAIN_ID_OP: // op
request = new HttpPost(
"https://gateway-arbitrum.network.thegraph.com/api/4146067af3cd632fedc37eef1783bdb2/subgraphs/id/G7LuMuUuWUW8UknEx8x2aVSeFtqpNMEKHvka2aKiDzRm");
request = new HttpPost("https://indexer.bigdevenergy.link/f9489a8/v1/graphql");
break;
// case Constants.CHAIN_ID_SEPOLIA: //sepolia
// request = new HttpPost(
Expand All @@ -144,7 +143,7 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException {
// break;
case Constants.CHAIN_ID_ARBITRUM: //arbitrum
request = new HttpPost(
"http://103.99.179.200:8400/subgraphs/name/redpacket_arbitrum");
"https://indexer.bigdevenergy.link/40a09e1/v1/graphql\n");
break;
// case Constants.CHAIN_ID_ZKSYNC: //zksync
// request = new HttpPost(
Expand All @@ -168,29 +167,12 @@ private HttpEntity getHttpEntityFromChain(String chainId) throws IOException {
String creationTimeGtValue = String.valueOf(time);


String graphQL = "\" {" +
" redpackets (where: { creationTime_gt: " + creationTimeGtValue + " }) {" +
" id " +
" refunded " +
" lock " +
" name " +
" creationTime " +
" allClaimed " +
" claimers {" +
" claimer" +
" claimedValue " +
" }" +
" }" +
" lastupdates (orderBy : lastupdateTimestamp , orderDirection: desc) { lastupdateTimestamp } " +

"}\"";

String graphQL = "{\n"
+ " \"query\": \"{\\n Redpacket(\\n where: {creationTime: {_gt: \\\"" + creationTimeGtValue + "\\\"}}\\n order_by: {creationTime: desc}\\n ) {\\n id\\n refunded\\n lock\\n name\\n creationTime\\n allClaimed\\n claimers {\\n claimer\\n claimedValue\\n }\\n }\\n Lastupdate(order_by: {lastupdateTimestamp: asc}) {\\n lastupdateTimestamp\\n }\\n}\"\n"
+ "}";

String query = "{ \"query\": " +
graphQL +
" }";

request.setEntity(new StringEntity(query));
request.setEntity(new StringEntity(graphQL));
HttpResponse response = httpClient.execute(request);
// System.out.println("response" + response);
HttpEntity entity = response.getEntity();
Expand Down

0 comments on commit 18d6f9a

Please sign in to comment.