Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement readability and cleanup #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/.idea
**/target
**/*.iml
**/.DS_Store
**/.project
/build
*.jar
!gradle/wrapper/gradle-wrapper.jar
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go to file menu — project structure — modules — click ‘+’ — select i

you can see the folder in your android project

Now we have to add Module Dependency in the application project builg.gradle file
Now we have to add Module Dependency in the application project build.gradle file

put “implementation project(":XDC3Java")“ in dependencies

Expand Down
16 changes: 0 additions & 16 deletions XDC3Java/.idea/gradle.xml

This file was deleted.

9 changes: 0 additions & 9 deletions XDC3Java/.idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions XDC3Java/.idea/modules.xml

This file was deleted.

18 changes: 0 additions & 18 deletions XDC3Java/.idea/modules/Xinfin.iml

This file was deleted.

6 changes: 0 additions & 6 deletions XDC3Java/.idea/vcs.xml

This file was deleted.

89 changes: 0 additions & 89 deletions XDC3Java/.idea/workspace.xml

This file was deleted.

6 changes: 1 addition & 5 deletions XDC3Java/src/main/java/com/XDCJava/AppConstants.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.XDCJava;


public class AppConstants {


public static final String BASE_URL = "https://rpc.apothem.network/";
public static final String hex_to_dec = "1000000000000000000";

// public static final String BASE_URL = "https://ropsten.infura.io/v3/b2f4b3f635d8425c96854c3d28ba6bb0";
public static final String hex_to_dec = "1000000000000000000";

}
47 changes: 2 additions & 45 deletions XDC3Java/src/main/java/com/XDCJava/XDC20Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public Boolean isWeb3jConnected() {
//Show Error
return false;
}
} catch (
Exception e) {
} catch (Exception e) {
//Show Error
return false;
}
Expand Down Expand Up @@ -99,24 +98,16 @@ public void generateWallet(File walletDirectory, String Password, CreateAccountC
walletData.setPublickeyKey(publickeyKey);
walletData.setSeedPhrase(seedPhrase);


createAccountCallback.success(walletData);





/*String seedPhrase = walletName.getMnemonic();
+
+ Credentials restoreCredentials = WalletUtils.loadBip39Credentials("1234567890",
+ seedPhrase);
+ ECKeyPair restoredPrivateKey = restoreCredentials.getEcKeyPair();
+ String restoredAccountAddress = restoreCredentials.getAddress();*/
} catch (IOException | CipherException e) {

} catch (IOException | CipherException e)
e.printStackTrace();
createAccountCallback.failure(e.getMessage());

} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -126,21 +117,16 @@ public void generateWallet(File walletDirectory, String Password, CreateAccountC
public void importWallet(String seedPhrase, String Password, CreateAccountCallback createAccountCallback) {

try {


Credentials restoreCredentials = WalletUtils.loadBip39Credentials(Password,
seedPhrase);
ECKeyPair restoredPrivateKey = restoreCredentials.getEcKeyPair();
String restoredAccountAddress = restoreCredentials.getAddress();


WalletData walletData = new WalletData();
restoredAccountAddress = restoredAccountAddress.replace("0x", "xdc");
walletData.setAccountAddress(restoredAccountAddress);
walletData.setPrivateKey(restoredPrivateKey.getPrivateKey().toString(16));
walletData.setPublickeyKey(restoredPrivateKey.getPublicKey().toString(16));
walletData.setSeedPhrase(seedPhrase);

createAccountCallback.success(walletData);
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -166,19 +152,15 @@ public String getContractAddress(String Privatekey) {
}
} catch (Exception e) {
return e.getMessage();

}

} else {
return "Please check your Connection";
}

}


public void getTokenoinfo(String token_address, TokenDetailCallback tokenDetailCallback) {


if (isWeb3jConnected()) {
ClientTransactionManager transactionManager = new ClientTransactionManager(web3,
token_address);
Expand All @@ -192,12 +174,9 @@ public void getTokenoinfo(String token_address, TokenDetailCallback tokenDetailC
}

} else {

//Show Error
tokenDetailCallback.failure("Connection has been failed");
}


}


Expand All @@ -222,13 +201,9 @@ public String getAllowance(String token_address, String owner_address, String sp
e.printStackTrace();
return e.getMessage();
}


} else {
return "check your connection";
}


}

/**
Expand All @@ -245,9 +220,6 @@ public String getBalance(String token_address, String owner_address) {
owner_address);
XRC20 javaToken = com.XDCJava.contracts.src.main.java.XRC20.load(token_address, web3, transactionManager, new DefaultGasProvider());




try {
BigInteger balance = javaToken.balanceOf(owner_address).send();
balance = converHexToDecimal(balance);
Expand All @@ -256,13 +228,9 @@ public String getBalance(String token_address, String owner_address) {
e.printStackTrace();
return e.getMessage();
}


} else {
return "check your connection";
}


}


Expand All @@ -277,19 +245,14 @@ public String getXdcBalance( String owner_address) {

try {
EthGetBalance balance = web3.ethGetBalance(owner_address,DefaultBlockParameterName.LATEST).send();

return String.valueOf(converHexToDecimal(balance.getBalance()));
} catch (IOException e) {
e.printStackTrace();
return String.valueOf(e.getMessage());
}


} else {
return "check your connection";
}


}

public void getinfo(XRC20 javaToken, String token_address, TokenDetailCallback tokenDetailCallback) {
Expand Down Expand Up @@ -457,12 +420,8 @@ public String approveXRC20Token(String token_address, String private_key, String
return "Failed";
}
} else {

return "Failed";

}


}


Expand Down Expand Up @@ -734,6 +693,4 @@ public BigInteger converHexToDecimal (BigInteger hexValue)
return hexValue.divide(hexvalue);

}


}
Loading