-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add hold token event for the EVM action - MEED-6663 - Meeds-io/…
- Loading branch information
1 parent
58729cb
commit ea85919
Showing
34 changed files
with
1,146 additions
and
363 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
gamification-evm-services/src/main/java/io/meeds/evm/gamification/dao/EvmTransactionDAO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.evm.gamification.dao; | ||
|
||
import io.meeds.evm.gamification.entity.EvmTransactionEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface EvmTransactionDAO extends JpaRepository<EvmTransactionEntity, Long> { | ||
|
||
List<EvmTransactionEntity> findByFromAddress(String fromAddress); | ||
|
||
List<EvmTransactionEntity> findByContractAddressAndNetworkIdAndIdGreaterThan(String contractAddress, Long networkId, Long id); | ||
|
||
EvmTransactionEntity findTopByContractAddressAndNetworkIdOrderByIdDesc(String contractAddress, Long networkId); | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...ion-evm-services/src/main/java/io/meeds/evm/gamification/entity/EvmTransactionEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.evm.gamification.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.math.BigInteger; | ||
|
||
@Entity(name = "EvmTransaction") | ||
@Table(name = "EVM_TRANSACTIONS") | ||
@Data | ||
public class EvmTransactionEntity implements Serializable { | ||
|
||
@Id | ||
@SequenceGenerator(name = "SEQ_EVM_TRANSACTIONS_ID", sequenceName = "SEQ_EVM_TRANSACTIONS_ID", allocationSize = 1) | ||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_EVM_TRANSACTIONS_ID") | ||
@Column(name = "ID", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "TRANSACTION_HASH", nullable = false) | ||
private String transactionHash; | ||
|
||
@Column(name = "NETWORK_ID", nullable = false) | ||
private Long networkId; | ||
|
||
@Column(name = "FROM_ADDRESS", nullable = false) | ||
private String fromAddress; | ||
|
||
@Column(name = "TO_ADDRESS", nullable = false) | ||
private String toAddress; | ||
|
||
@Column(name = "CONTRACT_ADDRESS", nullable = false) | ||
private String contractAddress; | ||
|
||
@Column(name = "SENT_DATE", nullable = false) | ||
private Long sentDate; | ||
|
||
@Column(name = "AMOUNT", nullable = false) | ||
private BigInteger amount; | ||
} |
72 changes: 72 additions & 0 deletions
72
...-evm-services/src/main/java/io/meeds/evm/gamification/listener/EvmRuleUpdateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.evm.gamification.listener; | ||
|
||
import io.meeds.evm.gamification.utils.Utils; | ||
import io.meeds.gamification.model.RuleDTO; | ||
import io.meeds.gamification.service.RuleService; | ||
import jakarta.annotation.PostConstruct; | ||
import org.exoplatform.commons.api.persistence.ExoTransactional; | ||
import org.exoplatform.commons.exception.ObjectNotFoundException; | ||
import org.exoplatform.services.listener.Event; | ||
import org.exoplatform.services.listener.Listener; | ||
|
||
import org.exoplatform.services.listener.ListenerService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.List; | ||
|
||
import static io.meeds.evm.gamification.utils.Utils.EVM_SAVE_ACTION_EVENT; | ||
|
||
@Component | ||
public class EvmRuleUpdateListener extends Listener<Map<String, String>, String> { | ||
|
||
private static final List<String> SUPPORTED_EVENTS = Arrays.asList(EVM_SAVE_ACTION_EVENT); | ||
|
||
@Autowired | ||
private RuleService ruleService; | ||
|
||
@Autowired | ||
private ListenerService listenerService; | ||
|
||
@PostConstruct | ||
public void init() { | ||
for (String eventName : SUPPORTED_EVENTS) { | ||
listenerService.addListener(eventName, this); | ||
} | ||
} | ||
|
||
@Override | ||
@ExoTransactional | ||
public void onEvent(Event<Map<String, String>, String> event) throws ObjectNotFoundException { | ||
Long lastIdToSave = Long.parseLong(event.getSource().get(Utils.TRANSACTION_ID)); | ||
Long ruleId = Long.parseLong(event.getSource().get(Utils.RULE_ID)); | ||
RuleDTO rule = ruleService.findRuleById(ruleId); | ||
if (rule == null) { | ||
throw new ObjectNotFoundException(String.format("Rule with id %s wasn't found", rule.getId())); | ||
} | ||
Map<String, String> map = rule.getEvent().getProperties(); | ||
map.put(Utils.LAST_ID_PROCCED, lastIdToSave.toString()); | ||
rule.getEvent().setProperties(map); | ||
ruleService.updateRule(rule); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ public class BlockchainNetwork { | |
|
||
private String providerUrl; | ||
|
||
private long networkId; | ||
private long networkId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
gamification-evm-services/src/main/java/io/meeds/evm/gamification/model/EvmTransaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of the Meeds project (https://meeds.io/). | ||
* | ||
* Copyright (C) 2020 - 2024 Meeds Association [email protected] | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package io.meeds.evm.gamification.model; | ||
|
||
import java.math.BigInteger; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class EvmTransaction { | ||
|
||
private Long id; | ||
|
||
private String transactionHash; | ||
|
||
private Long networkId; | ||
|
||
private String fromAddress; | ||
|
||
private String toAddress; | ||
|
||
private String contractAddress; | ||
|
||
private Long sentDate; | ||
|
||
private BigInteger amount; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
...cation-evm-services/src/main/java/io/meeds/evm/gamification/model/TokenTransferEvent.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.