-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
2,710 additions
and
1,059 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,41 @@ | ||
version = '0.1.0' | ||
|
||
dependencies { | ||
testImplementation 'foundation.icon:javaee-unittest:0.11.1' | ||
testImplementation project(':test-lib') | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
finalizedBy jacocoTestReport | ||
} | ||
|
||
optimizedJar { | ||
mainClassName = 'relay.aggregator.RelayAggregator' | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
from { | ||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } | ||
} | ||
} | ||
|
||
deployJar { | ||
endpoints { | ||
lisbon { | ||
uri = 'https://lisbon.net.solidwallet.io/api/v3' | ||
nid = 0x2 | ||
} | ||
local { | ||
uri = 'http://localhost:9082/api/v3' | ||
nid = 0x3 | ||
} | ||
mainnet { | ||
uri = 'https://ctz.solidwallet.io/api/v3' | ||
nid = 0x1 | ||
} | ||
} | ||
keystore = rootProject.hasProperty('keystoreName') ? "$keystoreName" : '' | ||
password = rootProject.hasProperty('keystorePass') ? "$keystorePass" : '' | ||
parameters { | ||
arg('_admin', "hxb6b5791be0b5ef67063b3c10b840fb81514db2fd") | ||
} | ||
} |
176 changes: 176 additions & 0 deletions
176
contracts/javascore/aggregator/src/main/java/relay/aggregator/Packet.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,176 @@ | ||
package relay.aggregator; | ||
|
||
import java.math.BigInteger; | ||
|
||
import score.Context; | ||
import score.ObjectReader; | ||
import score.ObjectWriter; | ||
|
||
public class Packet { | ||
|
||
/** | ||
* The ID of the source network (chain) from where the packet originated. | ||
*/ | ||
private final String srcNetwork; | ||
|
||
/** | ||
* The contract address on the source network (chain). | ||
*/ | ||
private final String srcContractAddress; | ||
|
||
/** | ||
* The sequence number of the packet in the source network (chain). | ||
*/ | ||
private final BigInteger srcSn; | ||
|
||
/** | ||
* The source height of the packet in the source network (chain). | ||
*/ | ||
private final BigInteger srcHeight; | ||
|
||
/** | ||
* The ID of the destination network (chain) where the packet is being sent. | ||
*/ | ||
private final String dstNetwork; | ||
|
||
/** | ||
* The contract address on the destination network (chain). | ||
*/ | ||
private final String dstContractAddress; | ||
|
||
/** | ||
* The payload data associated with this packet. | ||
*/ | ||
private final byte[] data; | ||
|
||
/** | ||
* Constructs a new {@code Packet} object with the specified {@code PacketID}, | ||
* destination network, and data. | ||
* All parameters must be non-null. | ||
* | ||
* @param id the unique identifier for the packet. | ||
* @param dstNetwork the ID of the destination network (chain). | ||
* @param data the payload data for this packet. | ||
* @throws IllegalArgumentException if {@code srcNetwork}, | ||
* {@code srcContractAddress}, {@code srcSn}, | ||
* {@code srcHeight}, | ||
* {@code dstNetwork}, | ||
* {@code dstContractAddress}, or {@code data} | ||
* is | ||
* {@code null}. | ||
*/ | ||
public Packet(String srcNetwork, String srcContractAddress, BigInteger srcSn, BigInteger srcHeight, | ||
String dstNetwork, String dstContractAddress, | ||
byte[] data) { | ||
Boolean isIllegalArg = srcNetwork == null || srcContractAddress == null || srcSn == null | ||
|| srcHeight == null || dstNetwork == null || dstContractAddress == null || data == null; | ||
Context.require(!isIllegalArg, | ||
"srcNetwork, contractAddress, srcSn, srcHeight, dstNetwork, and data cannot be null"); | ||
if (isIllegalArg) { | ||
} | ||
this.srcNetwork = srcNetwork; | ||
this.srcContractAddress = srcContractAddress; | ||
this.srcSn = srcSn; | ||
this.srcHeight = srcHeight; | ||
this.dstNetwork = dstNetwork; | ||
this.dstContractAddress = dstContractAddress; | ||
this.data = data; | ||
} | ||
|
||
public String getId() { | ||
return createId(this.srcNetwork, this.srcContractAddress, this.srcSn); | ||
} | ||
|
||
public static String createId(String srcNetwork, String contractAddress, BigInteger srcSn) { | ||
return srcNetwork + "/" + contractAddress + "/" + srcSn.toString(); | ||
} | ||
|
||
/** | ||
* Returns the source network (chain) from where the packet originated. | ||
* | ||
* @return the source network ID. | ||
*/ | ||
public String getSrcNetwork() { | ||
return srcNetwork; | ||
} | ||
|
||
/** | ||
* Returns the contract address on the source network (chain). | ||
* | ||
* @return the source contract address. | ||
*/ | ||
public String getSrcContractAddress() { | ||
return srcContractAddress; | ||
} | ||
|
||
/** | ||
* Returns the sequence number of the packet in the source network (chain). | ||
* | ||
* @return the sequence number. | ||
*/ | ||
public BigInteger getSrcSn() { | ||
return srcSn; | ||
} | ||
|
||
/** | ||
* Returns the height of the packet in the source network (chain). | ||
* | ||
* @return the source height. | ||
*/ | ||
public BigInteger getSrcHeight() { | ||
return srcHeight; | ||
} | ||
|
||
/** | ||
* Returns the destination network (chain) where the packet is being sent. | ||
* | ||
* @return the destination network ID. | ||
*/ | ||
public String getDstNetwork() { | ||
return dstNetwork; | ||
} | ||
|
||
/** | ||
* Returns the contract address on the destination network (chain). | ||
* | ||
* @return the destination contract address. | ||
*/ | ||
public String getDstContractAddress() { | ||
return dstContractAddress; | ||
} | ||
|
||
/** | ||
* Returns a copy of the data associated with this packet. | ||
* | ||
* @return a byte array containing the packet data. | ||
*/ | ||
public byte[] getData() { | ||
return data; | ||
} | ||
|
||
public static void writeObject(ObjectWriter w, Packet p) { | ||
w.beginList(7); | ||
w.write(p.srcNetwork); | ||
w.write(p.srcContractAddress); | ||
w.write(p.srcSn); | ||
w.write(p.srcHeight); | ||
w.write(p.dstNetwork); | ||
w.write(p.dstContractAddress); | ||
w.writeNullable(p.data); | ||
w.end(); | ||
} | ||
|
||
public static Packet readObject(ObjectReader r) { | ||
r.beginList(); | ||
Packet p = new Packet( | ||
r.readString(), | ||
r.readString(), | ||
r.readBigInteger(), | ||
r.readBigInteger(), | ||
r.readString(), | ||
r.readString(), | ||
r.readNullable(byte[].class)); | ||
r.end(); | ||
return p; | ||
} | ||
} |
Oops, something went wrong.