Skip to content
This repository was archived by the owner on Mar 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions javascore/nativecoinIRC2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version = '0.1.0'

dependencies {
compileOnly 'foundation.icon:javaee-api:0.9.0'
compileOnly 'foundation.icon:javaee-rt:0.9.0'
compileOnly 'foundation.icon:icon-sdk:2.0.0'
compileOnly 'foundation.icon:javaee-tooling:0.8.7'

implementation project(':score-util')
implementation project(':lib')
implementation 'com.github.sink772:javaee-scorex:0.5.2'
implementation 'com.github.sink772:javaee-tokens:0.5.5'
implementation 'org.msgpack:msgpack-core:0.8.17'

testImplementation 'foundation.icon:javaee-api:0.9.0'
testImplementation 'foundation.icon:javaee-rt:0.9.0'
testImplementation 'foundation.icon:icon-sdk:2.0.0'
testImplementation 'foundation.icon:javaee-tooling:0.9.0'
testImplementation 'org.mockito:mockito-core:3.3.3'
testImplementation 'com.squareup.okhttp3:okhttp:3.11.0'
testImplementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.60'

testImplementation fileTree(dir: './lib', include: 'goloop-testsuite.jar')
testImplementation fileTree(dir: './lib', include: 'testsvc.jar')

testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}

optimizedJar {
mainClassName = 'foundation.icon.btp.bsh.NativeCoinService'
archivesBaseName = 'native-bsh'
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
logging.println("BMC Address :" + System.getProperty("BMC_ADDRESS"))
deployJar {
endpoints {
gangnam {
uri = 'https://gicon.net.solidwallet.io/api/v3'
nid = 7
}
Sejong {
uri = 'https://sejong.net.solidwallet.io/api/v3'
nid = 0x53
}
local {
uri = 'http://localhost:9082/api/v3'
nid = 3
}
BTPTestnet {
uri = 'https://btp.net.solidwallet.io/api/v3'
nid = 0x42
}
}
keystore = rootProject.hasProperty('keystoreName') ? "$keystoreName" : ''
password = rootProject.hasProperty('keystorePass') ? "$keystorePass" : ''

parameters {
arg('_bmc', System.getProperty("BMC_ADDRESS"))
}
}

test {
useJUnitPlatform()
}
Binary file not shown.
Binary file added javascore/nativecoinIRC2/lib/testsvc.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2021 ICON Foundation
*
* 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 foundation.icon.btp.nativecoinIRC2;

import score.ByteArrayObjectWriter;
import score.Context;
import score.ObjectReader;
import score.ObjectWriter;

import java.math.BigInteger;

public class Asset {
private String coinName;
private BigInteger amount;

public Asset() {}

public Asset(Asset asset) {
setCoinName(asset.getCoinName());
setAmount(asset.getAmount());
}

public Asset(String coinName, BigInteger amount) {
this.coinName = coinName;
this.amount = amount;
}

public String getCoinName() {
return coinName;
}

public void setCoinName(String coinName) {
this.coinName = coinName;
}

public BigInteger getAmount() {
return amount;
}

public void setAmount(BigInteger amount) {
this.amount = amount;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Asset{");
sb.append("coinName='").append(coinName).append('\'');
sb.append(", amount=").append(amount);
sb.append('}');
return sb.toString();
}

public static void writeObject(ObjectWriter writer, Asset obj) {
obj.writeObject(writer);
}

public static Asset readObject(ObjectReader reader) {
Asset obj = new Asset();
reader.beginList();
obj.setCoinName(reader.readNullable(String.class));
obj.setAmount(reader.readNullable(BigInteger.class));
reader.end();
return obj;
}


public void writeObject(ObjectWriter writer) {
writer.beginList(2);
writer.writeNullable(this.getCoinName());
writer.writeNullable(this.getAmount());
writer.end();
}

public static Asset fromBytes(byte[] bytes) {
ObjectReader reader = Context.newByteArrayObjectReader("RLPn", bytes);
return Asset.readObject(reader);
}

public byte[] toBytes() {
ByteArrayObjectWriter writer = Context.newByteArrayObjectWriter("RLPn");
Asset.writeObject(writer, this);
return writer.toByteArray();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2021 ICON Foundation
*
* 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 foundation.icon.btp.nativecoinIRC2;

import score.ByteArrayObjectWriter;
import score.Context;
import score.ObjectReader;
import score.ObjectWriter;

import java.math.BigInteger;

public class AssetTransferDetail extends Asset {
private BigInteger fee;

public BigInteger getFee() {
return fee;
}

public void setFee(BigInteger fee) {
this.fee = fee;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("AssetTransferDetail{");
sb.append("fee=").append(fee);
sb.append('}').append(super.toString());
return sb.toString();
}

public static void writeObject(ObjectWriter writer, AssetTransferDetail obj) {
obj.writeObject(writer);
}

public static AssetTransferDetail readObject(ObjectReader reader) {
AssetTransferDetail obj = new AssetTransferDetail();
reader.beginList();
obj.setCoinName(reader.readNullable(String.class));
obj.setAmount(reader.readNullable(BigInteger.class));
obj.setFee(reader.readNullable(BigInteger.class));
reader.end();
return obj;
}

public void writeObject(ObjectWriter writer) {
writer.beginList(3);
writer.writeNullable(this.getCoinName());
writer.writeNullable(this.getAmount());
writer.writeNullable(this.getFee());
writer.end();
}

public static AssetTransferDetail fromBytes(byte[] bytes) {
ObjectReader reader = Context.newByteArrayObjectReader("RLPn", bytes);
return AssetTransferDetail.readObject(reader);
}

public byte[] toBytes() {
ByteArrayObjectWriter writer = Context.newByteArrayObjectWriter("RLPn");
AssetTransferDetail.writeObject(writer, this);
return writer.toByteArray();
}

}
Loading