-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HIP-904 Add support for Token Airdrop (#8856)
* Add support for Token Airdrop Signed-off-by: Edwin Greene <[email protected]>
- Loading branch information
1 parent
86e35de
commit b990a26
Showing
36 changed files
with
1,605 additions
and
21 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
|
@@ -35,4 +35,3 @@ spec: | |
securityUpgrade: | ||
mode: InPlace | ||
``` | ||
83 changes: 83 additions & 0 deletions
83
...rror-common/src/main/java/com/hedera/mirror/common/domain/token/AbstractTokenAirdrop.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,83 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.mirror.common.domain.token; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.google.common.collect.Range; | ||
import com.hedera.mirror.common.domain.History; | ||
import com.hedera.mirror.common.domain.Upsertable; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.IdClass; | ||
import jakarta.persistence.MappedSuperclass; | ||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
import org.hibernate.annotations.JdbcTypeCode; | ||
import org.hibernate.type.SqlTypes; | ||
|
||
@Data | ||
@IdClass(AbstractTokenAirdrop.Id.class) | ||
@MappedSuperclass | ||
@NoArgsConstructor | ||
@SuperBuilder(toBuilder = true) | ||
@Upsertable(history = true) | ||
public class AbstractTokenAirdrop implements History { | ||
|
||
private Long amount; | ||
|
||
@jakarta.persistence.Id | ||
private long receiverAccountId; | ||
|
||
@jakarta.persistence.Id | ||
private long senderAccountId; | ||
|
||
@jakarta.persistence.Id | ||
private long serialNumber; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@JdbcTypeCode(SqlTypes.NAMED_ENUM) | ||
private TokenAirdropStateEnum state; | ||
|
||
private Range<Long> timestampRange; | ||
|
||
@jakarta.persistence.Id | ||
private long tokenId; | ||
|
||
@JsonIgnore | ||
public Id getId() { | ||
Id id = new Id(); | ||
id.setReceiverAccountId(receiverAccountId); | ||
id.setSenderAccountId(senderAccountId); | ||
id.setSerialNumber(serialNumber); | ||
id.setTokenId(tokenId); | ||
return id; | ||
} | ||
|
||
@Data | ||
public static class Id implements Serializable { | ||
@Serial | ||
private static final long serialVersionUID = -8165098238647325621L; | ||
|
||
private long receiverAccountId; | ||
private long senderAccountId; | ||
private long serialNumber; | ||
private long tokenId; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
hedera-mirror-common/src/main/java/com/hedera/mirror/common/domain/token/TokenAirdrop.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,30 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.mirror.common.domain.token; | ||
|
||
import jakarta.persistence.Entity; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@Entity | ||
@NoArgsConstructor | ||
@SuperBuilder(toBuilder = true) | ||
public class TokenAirdrop extends AbstractTokenAirdrop { | ||
// Only the parent class should contain fields so that they're shared with both the history and non-history tables. | ||
} |
30 changes: 30 additions & 0 deletions
30
...irror-common/src/main/java/com/hedera/mirror/common/domain/token/TokenAirdropHistory.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,30 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.mirror.common.domain.token; | ||
|
||
import jakarta.persistence.Entity; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@Entity | ||
@NoArgsConstructor | ||
@SuperBuilder(toBuilder = true) | ||
public class TokenAirdropHistory extends AbstractTokenAirdrop { | ||
// Only the parent class should contain fields so that they're shared with both the history and non-history tables. | ||
} |
30 changes: 30 additions & 0 deletions
30
...ror-common/src/main/java/com/hedera/mirror/common/domain/token/TokenAirdropStateEnum.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,30 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.mirror.common.domain.token; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum TokenAirdropStateEnum { | ||
CANCELLED(0), | ||
CLAIMED(1), | ||
PENDING(2); | ||
|
||
private final int id; | ||
} |
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
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
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
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
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.