├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── release │ ├── app-release.apk │ └── output.json └── src │ ├── androidTest │ └── java │ │ └── bctest │ │ └── maods │ │ └── com │ │ └── bctest │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ ├── com │ │ │ └── maods │ │ │ │ └── bctest │ │ │ │ ├── BCTestApp.java │ │ │ │ ├── ChainCommonOperations.java │ │ │ │ ├── EOS │ │ │ │ ├── Action.java │ │ │ │ ├── BOSMainNet.java │ │ │ │ ├── BOSTestNet.java │ │ │ │ ├── ContextFreeAction.java │ │ │ │ ├── EOSAbiHelper.java │ │ │ │ ├── EOSKylinTestNet.java │ │ │ │ ├── EOSMainNet.java │ │ │ │ ├── EOSOperations.java │ │ │ │ ├── EOSUtils.java │ │ │ │ ├── ForgroundSevice.java │ │ │ │ ├── MEETONEMainNet.java │ │ │ │ └── Transaction.java │ │ │ │ ├── GlobalConstants.java │ │ │ │ ├── GlobalUtils.java │ │ │ │ └── UI │ │ │ │ ├── ChainHomeActivity.java │ │ │ │ ├── EOSBrowser.java │ │ │ │ ├── EOSInfoActivity.java │ │ │ │ ├── EOSListActivity.java │ │ │ │ ├── EOSRamTradeActivity.java │ │ │ │ ├── EOSWalletManagerActivity.java │ │ │ │ └── MainActivity.java │ │ └── io │ │ │ └── plactal │ │ │ └── eoscommander │ │ │ ├── crypto │ │ │ ├── Hmac.java │ │ │ ├── digest │ │ │ │ ├── GeneralDigest.java │ │ │ │ ├── Ripemd160.java │ │ │ │ ├── Sha256.java │ │ │ │ └── Sha512.java │ │ │ ├── ec │ │ │ │ ├── CurveParam.java │ │ │ │ ├── EcCurve.java │ │ │ │ ├── EcDsa.java │ │ │ │ ├── EcFieldElement.java │ │ │ │ ├── EcPoint.java │ │ │ │ ├── EcSignature.java │ │ │ │ ├── EcTools.java │ │ │ │ ├── EosEcUtil.java │ │ │ │ ├── EosPrivateKey.java │ │ │ │ └── EosPublicKey.java │ │ │ └── util │ │ │ │ ├── Base58.java │ │ │ │ ├── BitUtils.java │ │ │ │ ├── CryptUtil.java │ │ │ │ └── HexUtils.java │ │ │ ├── data │ │ │ ├── EoscDataManager.java │ │ │ ├── local │ │ │ │ ├── db │ │ │ │ │ ├── AppDatabase.java │ │ │ │ │ ├── EosAccount.java │ │ │ │ │ └── EosAccountDao.java │ │ │ │ └── repository │ │ │ │ │ ├── EosAccountRepository.java │ │ │ │ │ └── EosAccountRepositoryImpl.java │ │ │ ├── prefs │ │ │ │ └── PreferencesHelper.java │ │ │ ├── remote │ │ │ │ ├── HostInterceptor.java │ │ │ │ ├── NodeosApi.java │ │ │ │ └── model │ │ │ │ │ ├── abi │ │ │ │ │ ├── EosAbiAction.java │ │ │ │ │ ├── EosAbiField.java │ │ │ │ │ ├── EosAbiMain.java │ │ │ │ │ ├── EosAbiStruct.java │ │ │ │ │ ├── EosAbiTable.java │ │ │ │ │ └── EosAbiTypeDef.java │ │ │ │ │ ├── api │ │ │ │ │ ├── AccountInfoRequest.java │ │ │ │ │ ├── EosChainInfo.java │ │ │ │ │ ├── GetBalanceRequest.java │ │ │ │ │ ├── GetCodeRequest.java │ │ │ │ │ ├── GetCodeResponse.java │ │ │ │ │ ├── GetRequestForCurrency.java │ │ │ │ │ ├── GetRequiredKeys.java │ │ │ │ │ ├── GetTableRequest.java │ │ │ │ │ ├── JsonToBinRequest.java │ │ │ │ │ ├── JsonToBinResponse.java │ │ │ │ │ ├── Key.java │ │ │ │ │ ├── Permission.java │ │ │ │ │ ├── PushTxnResponse.java │ │ │ │ │ ├── RequiredAuth.java │ │ │ │ │ └── RequiredKeysResponse.java │ │ │ │ │ ├── chain │ │ │ │ │ ├── Action.java │ │ │ │ │ ├── ActionTrace.java │ │ │ │ │ ├── DataAccessInfo.java │ │ │ │ │ ├── PackedTransaction.java │ │ │ │ │ ├── SignedTransaction.java │ │ │ │ │ ├── Transaction.java │ │ │ │ │ ├── TransactionHeader.java │ │ │ │ │ ├── TransactionReceiptHeader.java │ │ │ │ │ └── TransactionTrace.java │ │ │ │ │ └── types │ │ │ │ │ ├── EosByteReader.java │ │ │ │ │ ├── EosByteWriter.java │ │ │ │ │ ├── EosNewAccount.java │ │ │ │ │ ├── EosTransfer.java │ │ │ │ │ ├── EosType.java │ │ │ │ │ ├── TypeAccountName.java │ │ │ │ │ ├── TypeActionName.java │ │ │ │ │ ├── TypeAsset.java │ │ │ │ │ ├── TypeAuthority.java │ │ │ │ │ ├── TypeChainId.java │ │ │ │ │ ├── TypeExtension.java │ │ │ │ │ ├── TypeKeyWeight.java │ │ │ │ │ ├── TypeName.java │ │ │ │ │ ├── TypePermissionLevel.java │ │ │ │ │ ├── TypePermissionLevelWeight.java │ │ │ │ │ ├── TypePermissionName.java │ │ │ │ │ ├── TypePublicKey.java │ │ │ │ │ ├── TypeScopeName.java │ │ │ │ │ ├── TypeSharedLock.java │ │ │ │ │ ├── TypeSymbol.java │ │ │ │ │ └── TypeWaitWeight.java │ │ │ ├── util │ │ │ │ └── GsonEosTypeAdapterFactory.java │ │ │ └── wallet │ │ │ │ ├── EosWallet.java │ │ │ │ └── EosWalletManager.java │ │ │ └── util │ │ │ ├── Consts.java │ │ │ ├── RefValue.java │ │ │ ├── StringUtils.java │ │ │ ├── Utils.java │ │ │ └── rx │ │ │ ├── EoscSchedulerProvider.java │ │ │ └── SchedulerProvider.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── chain_home.xml │ │ ├── choose_net.xml │ │ ├── content_main.xml │ │ ├── eos_browser.xml │ │ ├── eos_execute_item.xml │ │ ├── eos_info.xml │ │ ├── eos_list.xml │ │ ├── list_item_2.xml │ │ ├── manage_wallet.xml │ │ └── ram_trade.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── bctest │ └── maods │ └── com │ └── bctest │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bctest 2 | This's an android app for learning purpose. 3 | It's for EOS test. 4 | Welcome anybody to clone or contribute to it. 5 | You can just copy it for your develop and test purpose. 6 | The only thing need to pay attention: 7 | In this project, I used many code from EosCommander(https://github.com/plactal/EosCommander), including wallet and transaction related. 8 | you need to comply with EosCommander 's requirements of using the code. 9 | Thanks EosCommander! 10 | 11 | If you wish to use it in your product, you need to copy below folders: 12 | bctest\app\src\main\java\io (this's from EosCommander) 13 | bctest\app\src\main\java\com\maods\bctest\EOS 14 | and the files under bctest\app\src\main\java\com\maods\bctest (not too much ,just for common utilities) 15 | 16 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "bctest.maods.com.bctest" 7 | minSdkVersion 25 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | compileOptions { 13 | sourceCompatibility JavaVersion.VERSION_1_8 14 | targetCompatibility JavaVersion.VERSION_1_8 15 | } 16 | lintOptions { 17 | abortOnError false 18 | } 19 | configurations.all { 20 | resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9' 21 | } 22 | } 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | } 30 | 31 | //from EosCommander begin 32 | ext{ 33 | espressoVer = '2.2.2' 34 | supportLibVer = '27.0.2' 35 | constraintLayoutVer = '1.0.2' 36 | roomVer = '1.0.0' 37 | 38 | rxJavaVer = '2.1.2' 39 | rxAndroidVer='2.0.1' 40 | 41 | retrofitVer = '2.3.0' 42 | okHttpVer = '3.9.0' 43 | 44 | gsonVer = '2.8.1' 45 | 46 | dagger2Ver = '2.11' 47 | 48 | timberVer = '4.5.1' 49 | 50 | fileChooserrVer = '1.3' 51 | singleDateTimePickerVer = '1.2.2' 52 | 53 | consoleViewVer = '0.4.3' 54 | 55 | junitVer = '4.12' 56 | } 57 | //from EosCommander end 58 | 59 | dependencies { 60 | implementation fileTree(dir: 'libs', include: ['*.jar']) 61 | implementation 'com.android.support:appcompat-v7:27.1.1' 62 | implementation 'com.android.support.constraint:constraint-layout:1.1.2' 63 | implementation 'com.android.support:design:27.1.1' 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 67 | 68 | //below is from EosCommander 69 | // ReactiveX 설정 70 | implementation "io.reactivex.rxjava2:rxandroid:${rxAndroidVer}" 71 | implementation "io.reactivex.rxjava2:rxjava:${rxJavaVer}" 72 | 73 | // retrofit 74 | implementation "com.squareup.retrofit2:retrofit:${retrofitVer}" 75 | implementation "com.squareup.retrofit2:adapter-rxjava2:${retrofitVer}" 76 | implementation "com.squareup.retrofit2:converter-gson:${retrofitVer}" 77 | 78 | implementation "com.google.code.gson:gson:${gsonVer}" 79 | 80 | // okHttp 81 | implementation "com.squareup.okhttp3:okhttp:${okHttpVer}" 82 | implementation "com.squareup.okhttp3:logging-interceptor:${okHttpVer}" 83 | 84 | // room 85 | implementation "android.arch.persistence.room:runtime:${roomVer}" 86 | annotationProcessor "android.arch.persistence.room:compiler:${roomVer}" 87 | implementation "android.arch.persistence.room:rxjava2:${roomVer}" 88 | 89 | 90 | // Dagger dependencies 91 | implementation "com.google.dagger:dagger:${dagger2Ver}" 92 | implementation "com.google.dagger:dagger-android-support:${dagger2Ver}" 93 | annotationProcessor "com.google.dagger:dagger-android-processor:${dagger2Ver}" 94 | annotationProcessor "com.google.dagger:dagger-compiler:${dagger2Ver}" 95 | 96 | // Timber 97 | implementation "com.jakewharton.timber:timber:${timberVer}" 98 | 99 | // file chooser, https://github.com/MostafaNasiri/AndroidFileChooser 100 | implementation "ir.sohreco.androidfilechooser:android-file-chooser:${fileChooserrVer}" 101 | 102 | // single date time picker 103 | implementation "com.github.florent37:singledateandtimepicker:${singleDateTimePickerVer}" 104 | 105 | implementation "com.jraska:console:${consoleViewVer}" 106 | 107 | // 구글 guava 108 | implementation 'com.google.guava:guava:23.0-android' 109 | 110 | testImplementation "junit:junit:${junitVer}" 111 | } 112 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/release/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maodaishan/bctest/eb303507b8dad46a557f99c9e368b0808db59ca0/app/release/app-release.apk -------------------------------------------------------------------------------- /app/release/output.json: -------------------------------------------------------------------------------- 1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"bctest.maods.com.bctest","split":"","minSdkVersion":"27"}}] -------------------------------------------------------------------------------- /app/src/androidTest/java/bctest/maods/com/bctest/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package bctest.maods.com.bctest; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("bctest.maods.com.bctest", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 18 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 38 | 41 | 44 | 47 | 48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/maods/bctest/BCTestApp.java: -------------------------------------------------------------------------------- 1 | package com.maods.bctest; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | /** 7 | * Created by MAODS on 2019/1/15. 8 | */ 9 | 10 | public class BCTestApp extends Application { 11 | private static Context instance; 12 | 13 | @Override 14 | public void onCreate() 15 | { 16 | super.onCreate(); 17 | instance = getApplicationContext(); 18 | } 19 | 20 | public static Context getContext() 21 | { 22 | return instance; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/maods/bctest/ChainCommonOperations.java: -------------------------------------------------------------------------------- 1 | package com.maods.bctest; 2 | 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * Created by MAODS on 2018/7/19. 8 | */ 9 | 10 | public interface ChainCommonOperations{ 11 | public List getServerNode(); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/maods/bctest/EOS/Action.java: -------------------------------------------------------------------------------- 1 | package com.maods.bctest.EOS; 2 | 3 | import org.json.JSONArray; 4 | import org.json.JSONException; 5 | import org.json.JSONObject; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Map; 10 | import java.util.Map.Entry; 11 | import java.util.Set; 12 | 13 | /** 14 | * Created by MAODS on 2018/8/14. 15 | */ 16 | 17 | public class Action { 18 | private static final String ACCOUNT="account"; 19 | private static final String NAME="name"; 20 | private static final String AUTHORIZATION="authorization"; 21 | private static final String DATA="data"; 22 | //private static final String HEX_DATA="hex_data"; 23 | private static final String ACTOR="actor"; 24 | private static final String PERMISSION="permission"; 25 | 26 | public String mAccount; 27 | public String mName; 28 | public List mAuth; 29 | public String mData; 30 | //public String mHexData; 31 | 32 | public class Authorization{ 33 | public String mActor; 34 | public String mPermission; 35 | } 36 | 37 | public Action(String account,String name,String data,/*String hexData,*/List> authorizations){ 38 | mAccount=account; 39 | mName=name; 40 | mData=data; 41 | //mHexData=data; 42 | mAuth=new ArrayList(); 43 | if(authorizations!=null) { 44 | for (int i = 0; i < authorizations.size(); i++) { 45 | Map oneAuth = authorizations.get(i); 46 | Authorization auth = new Authorization(); 47 | auth.mActor = oneAuth.get(ACTOR); 48 | auth.mPermission = oneAuth.get(PERMISSION); 49 | mAuth.add(auth); 50 | } 51 | } 52 | } 53 | 54 | @Override 55 | public String toString(){ 56 | JSONObject json=toJson(); 57 | return json.toString(); 58 | } 59 | 60 | public JSONObject toJson(){ 61 | JSONObject json=new JSONObject(); 62 | try { 63 | json.put(ACCOUNT,mAccount); 64 | json.put(NAME,mName); 65 | json.put(DATA,mData); 66 | //json.put(HEX_DATA,mHexData); 67 | JSONArray auth=new JSONArray(); 68 | for(int i=0;i> authorization) { 12 | super(account, name, /*data, */hexData, authorization); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/maods/bctest/EOS/EOSAbiHelper.java: -------------------------------------------------------------------------------- 1 | package com.maods.bctest.EOS; 2 | 3 | import android.text.TextUtils; 4 | 5 | import org.json.JSONArray; 6 | import org.json.JSONException; 7 | import org.json.JSONObject; 8 | 9 | /** 10 | * Created by MAODS on 2018/8/23. 11 | */ 12 | 13 | public class EOSAbiHelper { 14 | private JSONObject mMain; 15 | private String mAccount; 16 | private String mVersion; 17 | private JSONArray mTypes; 18 | private JSONArray mStructs; 19 | private JSONArray mActions; 20 | private JSONArray mTables; 21 | private JSONArray mRicardianClauses; 22 | private JSONArray mErrMsgs; 23 | private JSONArray mAbiExtensions; 24 | public EOSAbiHelper(String abi) throws JSONException{ 25 | if(TextUtils.isEmpty(abi)){ 26 | return; 27 | } 28 | JSONObject json=new JSONObject(abi); 29 | mMain=json.getJSONObject("abi"); 30 | mAccount=json.getString("account_name"); 31 | if(mMain!=null){ 32 | mVersion=mMain.getString("version"); 33 | mTypes=mMain.getJSONArray("types"); 34 | mStructs=mMain.getJSONArray("structs"); 35 | mActions=mMain.getJSONArray("actions"); 36 | mTables=mMain.getJSONArray("tables"); 37 | mRicardianClauses=mMain.getJSONArray("ricardian_clauses"); 38 | mErrMsgs=mMain.getJSONArray("error_messages"); 39 | mAbiExtensions=mMain.getJSONArray("abi_extensions"); 40 | } 41 | } 42 | 43 | public JSONArray getActions(){ 44 | return mActions; 45 | } 46 | 47 | public JSONObject getStructByName(String name){ 48 | if(TextUtils.isEmpty(name) || mStructs==null){ 49 | return null; 50 | } 51 | JSONObject struct=null; 52 | for(int i=0;i mActions; 34 | public String[] mScopes=new String[0]; 35 | public List mContextFreeActions=new ArrayList(); 36 | public List mTransactionExtensions=new ArrayList(); 37 | public List mSignatures=new ArrayList(); 38 | public List mContextFreeData=new ArrayList(); 39 | public List mAuthorizations=new ArrayList<>(); 40 | 41 | public Transaction(String expiration,int refBlockNum,String refBlockPrefix,Listactions){ 42 | mExpiration=expiration; 43 | mRefBlockNum=refBlockNum; 44 | mRefBlockPrefix=refBlockPrefix; 45 | mActions=actions; 46 | mMaxNetUsageWords=0; 47 | mMaxCpuUsageMS=0; 48 | mDelaySec=0; 49 | } 50 | 51 | public void setScopes(String[] scopes){ 52 | mScopes=scopes; 53 | } 54 | public void setMaxNetUsageWords(int net){ 55 | mMaxNetUsageWords=net; 56 | } 57 | public void setMaxCpuUsageMS(int cpu){ 58 | mMaxCpuUsageMS=cpu; 59 | } 60 | public void setDelaySec(int delay){ 61 | mDelaySec=delay; 62 | } 63 | public void setmContextFreeActions(List contextFreeActions){ 64 | mContextFreeActions=contextFreeActions; 65 | } 66 | public void setTransactionExtensions(Listextensions){ 67 | mTransactionExtensions=extensions; 68 | } 69 | public void setSignatures(Listsig){ 70 | mSignatures=sig; 71 | } 72 | public void setContextFreeData(ListcontextFreeData){ 73 | mContextFreeData=contextFreeData; 74 | } 75 | public void setAuthorizations(Listauthorizations){ 76 | mAuthorizations=authorizations; 77 | } 78 | @Override 79 | public String toString(){ 80 | JSONObject json=toJson(); 81 | return json.toString(); 82 | } 83 | 84 | public JSONObject toJson(){ 85 | JSONObject json=new JSONObject(); 86 | try { 87 | json.put(REF_BLOCK_NUM, mRefBlockNum); 88 | json.put(REF_BLOCK_PREFIX,mRefBlockPrefix); 89 | json.put(EXPIRATION,mExpiration); 90 | if(mScopes.length>0) { 91 | JSONArray scopes = new JSONArray(); 92 | for (String scope : mScopes) { 93 | scopes.put(scope); 94 | } 95 | json.put(SCOPE,scopes); 96 | } 97 | if(mActions.size()>0){ 98 | JSONArray actions=new JSONArray(); 99 | for(Action action:mActions){ 100 | JSONObject actionJson=action.toJson(); 101 | actions.put(actionJson); 102 | } 103 | json.put(ACTIONS,actions); 104 | } 105 | if(mSignatures.size()>0){ 106 | JSONArray sigs=new JSONArray(); 107 | for(String sig:mSignatures){ 108 | sigs.put(sig); 109 | } 110 | json.put(SIGNATURES,sigs); 111 | } 112 | if(mAuthorizations.size()>0){ 113 | JSONArray auths=new JSONArray(); 114 | for(String auth:mAuthorizations){ 115 | auths.put(auth); 116 | } 117 | json.put(AUTHORIZATIONS,auths); 118 | } 119 | }catch(JSONException e){ 120 | Log.i(TAG,"Exception in toJson,e:"+e); 121 | e.printStackTrace(); 122 | } 123 | return json; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /app/src/main/java/com/maods/bctest/GlobalConstants.java: -------------------------------------------------------------------------------- 1 | package com.maods.bctest; 2 | 3 | /** 4 | * Created by MAODS on 2018/7/17. 5 | */ 6 | 7 | public class GlobalConstants { 8 | public static final String BTC="BTC"; 9 | public static final String ETH="ETH"; 10 | public static final String EOS="EOS"; 11 | public static final String FABRIC="Fabric"; 12 | 13 | //Name for extras passed in intent. 14 | public static final String EXTRA_KEY_CHAIN="chain"; 15 | public static final String EXTRA_KEY_ACTION="action"; 16 | public static final String EXTRA_KEY_NAME="name"; 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/maods/bctest/UI/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.maods.bctest.UI; 2 | 3 | import android.content.Intent; 4 | import android.content.pm.ComponentInfo; 5 | import android.os.Bundle; 6 | import android.support.design.widget.FloatingActionButton; 7 | import android.support.design.widget.Snackbar; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.support.v7.widget.Toolbar; 10 | import android.view.View; 11 | import android.view.Menu; 12 | import android.view.MenuItem; 13 | import android.widget.AdapterView; 14 | import android.widget.ArrayAdapter; 15 | import android.widget.ListView; 16 | import android.widget.TextView; 17 | 18 | import com.maods.bctest.GlobalConstants; 19 | import com.maods.bctest.R; 20 | 21 | 22 | public class MainActivity extends AppCompatActivity { 23 | private static final String TAG="MainActivity"; 24 | 25 | private String[] mChains=new String[]{ 26 | GlobalConstants.BTC, 27 | GlobalConstants.ETH, 28 | GlobalConstants.EOS, 29 | GlobalConstants.FABRIC 30 | }; 31 | private ListView mList; 32 | private ArrayAdapter mAdapter; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.activity_main); 38 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 39 | setSupportActionBar(toolbar); 40 | 41 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 42 | fab.setOnClickListener(new View.OnClickListener() { 43 | @Override 44 | public void onClick(View view) { 45 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 46 | .setAction("Action", null).show(); 47 | } 48 | }); 49 | 50 | mList=findViewById(R.id.list); 51 | mAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1,mChains); 52 | mList.setAdapter(mAdapter); 53 | mList.setOnItemClickListener(new AdapterView.OnItemClickListener() { 54 | @Override 55 | public void onItemClick(AdapterView parent, View view, int position, long id) { 56 | TextView t=(TextView)view; 57 | String target=t.getText().toString(); 58 | Intent intent=new Intent(); 59 | intent.setClass(MainActivity.this,ChainHomeActivity.class); 60 | intent.putExtra(GlobalConstants.EXTRA_KEY_CHAIN,target); 61 | startActivity(intent); 62 | } 63 | } 64 | ); 65 | } 66 | 67 | @Override 68 | public boolean onCreateOptionsMenu(Menu menu) { 69 | // Inflate the menu; this adds items to the action bar if it is present. 70 | getMenuInflater().inflate(R.menu.menu_main, menu); 71 | return true; 72 | } 73 | 74 | @Override 75 | public boolean onOptionsItemSelected(MenuItem item) { 76 | // Handle action bar item clicks here. The action bar will 77 | // automatically handle clicks on the Home/Up button, so long 78 | // as you specify a parent activity in AndroidManifest.xml. 79 | int id = item.getItemId(); 80 | 81 | //noinspection SimplifiableIfStatement 82 | if (id == R.id.action_settings) { 83 | return true; 84 | } 85 | 86 | return super.onOptionsItemSelected(item); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/crypto/digest/GeneralDigest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013, 2014 Megion Research & Development GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.plactal.eoscommander.crypto.digest; 18 | 19 | /** 20 | * base implementation of MD4 family style digest as outlined in 21 | * "Handbook of Applied Cryptography", pages 344 - 347. 22 | */ 23 | public abstract class GeneralDigest { 24 | private static final int BYTE_LENGTH = 64; 25 | private byte[] xBuf; 26 | private int xBufOff; 27 | 28 | private long byteCount; 29 | 30 | /** 31 | * Standard constructor 32 | */ 33 | protected GeneralDigest() { 34 | xBuf = new byte[4]; 35 | xBufOff = 0; 36 | } 37 | 38 | /** 39 | * Copy constructor. We are using copy constructors in place of the 40 | * Object.clone() interface as this interface is not supported by J2ME. 41 | */ 42 | protected GeneralDigest(GeneralDigest t) { 43 | xBuf = new byte[t.xBuf.length]; 44 | System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length); 45 | 46 | xBufOff = t.xBufOff; 47 | byteCount = t.byteCount; 48 | } 49 | 50 | public void update(byte in) { 51 | xBuf[xBufOff++] = in; 52 | 53 | if (xBufOff == xBuf.length) { 54 | processWord(xBuf, 0); 55 | xBufOff = 0; 56 | } 57 | 58 | byteCount++; 59 | } 60 | 61 | public void update(byte[] in, int inOff, int len) { 62 | // 63 | // fill the current word 64 | // 65 | while ((xBufOff != 0) && (len > 0)) { 66 | update(in[inOff]); 67 | 68 | inOff++; 69 | len--; 70 | } 71 | 72 | // 73 | // process whole words. 74 | // 75 | while (len > xBuf.length) { 76 | processWord(in, inOff); 77 | 78 | inOff += xBuf.length; 79 | len -= xBuf.length; 80 | byteCount += xBuf.length; 81 | } 82 | 83 | // 84 | // load in the remainder. 85 | // 86 | while (len > 0) { 87 | update(in[inOff]); 88 | 89 | inOff++; 90 | len--; 91 | } 92 | } 93 | 94 | public void finish() { 95 | long bitLength = (byteCount << 3); 96 | 97 | // 98 | // add the pad bytes. 99 | // 100 | update((byte) 128); 101 | 102 | while (xBufOff != 0) { 103 | update((byte) 0); 104 | } 105 | 106 | processLength(bitLength); 107 | 108 | processBlock(); 109 | } 110 | 111 | public void reset() { 112 | byteCount = 0; 113 | 114 | xBufOff = 0; 115 | for (int i = 0; i < xBuf.length; i++) { 116 | xBuf[i] = 0; 117 | } 118 | } 119 | 120 | public int getByteLength() { 121 | return BYTE_LENGTH; 122 | } 123 | 124 | protected abstract void processWord(byte[] in, int inOff); 125 | 126 | protected abstract void processLength(long bitLength); 127 | 128 | protected abstract void processBlock(); 129 | } 130 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/crypto/digest/Sha256.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.crypto.digest; 2 | 3 | 4 | import com.google.common.base.Preconditions; 5 | 6 | import java.security.MessageDigest; 7 | import java.security.NoSuchAlgorithmException; 8 | import java.util.Arrays; 9 | 10 | import io.plactal.eoscommander.crypto.util.HexUtils; 11 | 12 | /** 13 | * represents the result of a SHA256 hashing operation prefer to use the static 14 | * factory methods. 15 | */ 16 | public class Sha256 { 17 | 18 | public static final int HASH_LENGTH = 32; 19 | public static final Sha256 ZERO_HASH = new Sha256(new byte[HASH_LENGTH]); 20 | 21 | final private byte[] mHashBytes; 22 | 23 | /** 24 | * create Sha256 from raw hash bytes. 25 | * @param bytes 26 | */ 27 | public Sha256(byte[] bytes) { 28 | Preconditions.checkArgument(bytes.length == HASH_LENGTH); 29 | this.mHashBytes = bytes; 30 | } 31 | 32 | public static MessageDigest getSha256Digest() { 33 | try { 34 | return MessageDigest.getInstance( "SHA-256" ); 35 | } catch (NoSuchAlgorithmException e) { 36 | throw new RuntimeException(e); //cannot happen 37 | } 38 | } 39 | 40 | public static Sha256 from(byte[] data) { 41 | MessageDigest digest; 42 | digest = getSha256Digest(); 43 | digest.update(data, 0, data.length); 44 | return new Sha256(digest.digest()); 45 | } 46 | 47 | public static Sha256 from(byte[] data, int offset, int length) { 48 | MessageDigest digest; 49 | digest = getSha256Digest(); 50 | digest.update(data, offset, length); 51 | return new Sha256(digest.digest()); 52 | } 53 | 54 | public static Sha256 from(byte[] data1, byte[] data2) { 55 | MessageDigest digest; 56 | digest = getSha256Digest(); 57 | digest.update(data1, 0, data1.length); 58 | digest.update(data2, 0, data2.length); 59 | return new Sha256(digest.digest()); 60 | 61 | } 62 | 63 | public static Sha256 doubleHash(byte[] data, int offset, int length) { 64 | MessageDigest digest; 65 | digest = getSha256Digest(); 66 | digest.update(data, offset, length); 67 | return new Sha256(digest.digest(digest.digest())); 68 | } 69 | 70 | 71 | 72 | @Override 73 | public boolean equals(Object other) { 74 | if (other == this) { 75 | return true; 76 | } 77 | if (!(other instanceof Sha256)) 78 | return false; 79 | return Arrays.equals(mHashBytes, ((Sha256) other).mHashBytes); 80 | } 81 | 82 | 83 | @Override 84 | public String toString() { 85 | return HexUtils.toHex(mHashBytes); 86 | } 87 | 88 | public byte[] getBytes() { 89 | return mHashBytes; 90 | } 91 | 92 | public boolean equalsFromOffset(byte[] toCompareData, int offsetInCompareData, int len ) { 93 | if ( ( null == toCompareData) || ( offsetInCompareData < 0) 94 | || ( len < 0) || ( mHashBytes.length <= len ) 95 | || ( toCompareData.length <= offsetInCompareData) ) { 96 | return false; 97 | } 98 | 99 | for (int i = 0; i < len; i++) { 100 | 101 | if ( mHashBytes[i] != toCompareData[ offsetInCompareData + i] ) { 102 | return false; 103 | } 104 | } 105 | 106 | return true; 107 | } 108 | 109 | public int length() { 110 | return HASH_LENGTH; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/crypto/digest/Sha512.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.crypto.digest; 2 | 3 | import com.google.common.base.Preconditions; 4 | import com.google.common.primitives.Ints; 5 | 6 | import java.security.MessageDigest; 7 | import java.security.NoSuchAlgorithmException; 8 | import java.util.Arrays; 9 | 10 | import io.plactal.eoscommander.crypto.util.HexUtils; 11 | 12 | public class Sha512 implements Comparable { 13 | 14 | public static final int HASH_LENGTH = 64; 15 | public static final Sha512 ZERO_HASH = new Sha512(new byte[HASH_LENGTH]); 16 | 17 | final private byte[] mHashBytes; 18 | 19 | public Sha512(byte[] bytes) { 20 | Preconditions.checkArgument(bytes.length == HASH_LENGTH); 21 | this.mHashBytes = bytes; 22 | } 23 | 24 | public static Sha512 from(byte[] data) { 25 | MessageDigest digest; 26 | try { 27 | digest = MessageDigest.getInstance("SHA-512"); 28 | } catch (NoSuchAlgorithmException e) { 29 | throw new RuntimeException(e); //cannot happen 30 | } 31 | 32 | digest.update(data, 0, data.length); 33 | 34 | return new Sha512(digest.digest()); 35 | } 36 | 37 | 38 | private Sha512(byte[] bytes, int offset) { 39 | //defensive copy, since incoming bytes is of arbitrary length 40 | mHashBytes = new byte[HASH_LENGTH]; 41 | System.arraycopy(bytes, offset, mHashBytes, 0, HASH_LENGTH); 42 | } 43 | 44 | @Override 45 | public boolean equals(Object other) { 46 | if (other == this) { 47 | return true; 48 | } 49 | if (!(other instanceof Sha512)) 50 | return false; 51 | return Arrays.equals(mHashBytes, ((Sha512) other).mHashBytes); 52 | } 53 | 54 | 55 | @Override 56 | public String toString() { 57 | return HexUtils.toHex(mHashBytes); 58 | } 59 | 60 | public byte[] getBytes() { 61 | return mHashBytes; 62 | } 63 | 64 | @Override 65 | public int compareTo(Sha512 o) { 66 | for (int i = 0; i < HASH_LENGTH; i++) { 67 | byte myByte = mHashBytes[i]; 68 | byte otherByte = o.mHashBytes[i]; 69 | 70 | final int compare = Ints.compare(myByte, otherByte); 71 | if (compare != 0) 72 | return compare; 73 | } 74 | return 0; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/crypto/ec/CurveParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package io.plactal.eoscommander.crypto.ec; 26 | 27 | import java.math.BigInteger; 28 | 29 | import io.plactal.eoscommander.crypto.util.HexUtils; 30 | 31 | /** 32 | * Created by swapnibble on 2018-02-02. 33 | */ 34 | 35 | public class CurveParam { 36 | public static final int SECP256_K1 = 0; 37 | public static final int SECP256_R1 = 1; 38 | 39 | private final int curveParamType; 40 | private final EcCurve curve; 41 | private final EcPoint G; 42 | private final BigInteger n; 43 | //private final BigInteger h; 44 | 45 | private final BigInteger HALF_CURVE_ORDER; 46 | 47 | public CurveParam( int curveParamType, String pInHex, String aInHex, String bInHex, String GxInHex, String GyInHex, String nInHex ){ 48 | this.curveParamType = curveParamType; 49 | BigInteger p = new BigInteger(pInHex, 16); //p 50 | BigInteger b = new BigInteger(bInHex , 16); 51 | BigInteger a = new BigInteger( aInHex, 16); 52 | curve = new EcCurve(p, a, b); 53 | 54 | G = curve.decodePoint( HexUtils.toBytes("04" + GxInHex + GyInHex) ); 55 | n = new BigInteger(nInHex, 16); 56 | //h = BigInteger.ONE; 57 | 58 | HALF_CURVE_ORDER = n.shiftRight(1); 59 | } 60 | 61 | public int getCurveParamType() { 62 | return curveParamType; 63 | } 64 | 65 | public boolean isType(int paramType ) { 66 | return curveParamType == paramType; 67 | } 68 | 69 | 70 | public EcPoint G() { 71 | return this.G; 72 | } 73 | 74 | public BigInteger n() { 75 | return this.n; 76 | } 77 | 78 | public BigInteger halfCurveOrder() { 79 | return HALF_CURVE_ORDER; 80 | } 81 | 82 | public EcCurve getCurve() { 83 | return curve; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/crypto/ec/EcCurve.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013, 2014 Megion Research & Development GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * modified by swapnibble from plactal.io 19 | * This code was extracted from the Java cryptography library from 20 | * www.bouncycastle.org. The code has been formatted to comply with the rest of 21 | * the formatting in this library. 22 | */ 23 | package io.plactal.eoscommander.crypto.ec; 24 | 25 | import java.math.BigInteger; 26 | 27 | /** 28 | * An elliptic curve 29 | */ 30 | public class EcCurve { 31 | 32 | private EcFieldElement _a; 33 | private EcFieldElement _b; 34 | private BigInteger _q; 35 | private EcPoint _infinity; 36 | 37 | public EcCurve(BigInteger q, BigInteger a, BigInteger b) { 38 | this._q = q; 39 | this._a = fromBigInteger(a); 40 | this._b = fromBigInteger(b); 41 | this._infinity = new EcPoint(this, null, null); 42 | } 43 | 44 | public EcFieldElement getA() { 45 | return _a; 46 | } 47 | 48 | public EcFieldElement getB() { 49 | return _b; 50 | } 51 | 52 | public BigInteger getQ() { 53 | return _q; 54 | } 55 | 56 | public EcPoint getInfinity() { 57 | return _infinity; 58 | } 59 | 60 | public int getFieldSize() { 61 | return _q.bitLength(); 62 | } 63 | 64 | public EcFieldElement fromBigInteger(BigInteger x) { 65 | return new EcFieldElement(this._q, x); 66 | } 67 | 68 | 69 | public EcPoint decodePoint(byte[] encodedPoint) { 70 | EcPoint p = null; 71 | // Switch on encoding type 72 | switch (encodedPoint[0]) { 73 | case 0x00: 74 | p = getInfinity(); 75 | break; 76 | case 0x02: 77 | case 0x03: 78 | int ytilde = encodedPoint[0] & 1; 79 | byte[] i = new byte[encodedPoint.length - 1]; 80 | System.arraycopy(encodedPoint, 1, i, 0, i.length); 81 | EcFieldElement x = new EcFieldElement(this._q, new BigInteger(1, i)); 82 | EcFieldElement alpha = x.multiply(x.square().add(_a)).add(_b); 83 | EcFieldElement beta = alpha.sqrt(); 84 | if (beta == null) { 85 | throw new RuntimeException("Invalid compression"); 86 | } 87 | int bit0 = (beta.toBigInteger().testBit(0) ? 1 : 0); 88 | if (bit0 == ytilde) { 89 | p = new EcPoint(this, x, beta, true); 90 | } else { 91 | p = new EcPoint(this, x, new EcFieldElement(this._q, _q.subtract(beta.toBigInteger())), true); 92 | } 93 | break; 94 | case 0x04: 95 | case 0x06: 96 | case 0x07: 97 | byte[] xEnc = new byte[(encodedPoint.length - 1) / 2]; 98 | byte[] yEnc = new byte[(encodedPoint.length - 1) / 2]; 99 | System.arraycopy(encodedPoint, 1, xEnc, 0, xEnc.length); 100 | System.arraycopy(encodedPoint, xEnc.length + 1, yEnc, 0, yEnc.length); 101 | p = new EcPoint(this, new EcFieldElement(this._q, new BigInteger(1, xEnc)), new EcFieldElement(this._q, 102 | new BigInteger(1, yEnc))); 103 | break; 104 | default: 105 | throw new RuntimeException("Invalid encoding 0x" + Integer.toString(encodedPoint[0], 16)); 106 | } 107 | return p; 108 | } 109 | 110 | @Override 111 | public boolean equals(Object obj) { 112 | if (obj == this) { 113 | return true; 114 | } 115 | if (!(obj instanceof EcCurve)) { 116 | return false; 117 | } 118 | EcCurve other = (EcCurve) obj; 119 | return this._q.equals(other._q) && _a.equals(other._a) && _b.equals(other._b); 120 | } 121 | 122 | @Override 123 | public int hashCode() { 124 | return _a.hashCode() ^ _b.hashCode() ^ _q.hashCode(); 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/crypto/util/CryptUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.crypto.util; 25 | 26 | import java.security.InvalidAlgorithmParameterException; 27 | import java.security.InvalidKeyException; 28 | import java.security.NoSuchAlgorithmException; 29 | import java.util.Arrays; 30 | 31 | import javax.crypto.BadPaddingException; 32 | import javax.crypto.Cipher; 33 | import javax.crypto.IllegalBlockSizeException; 34 | import javax.crypto.NoSuchPaddingException; 35 | import javax.crypto.SecretKey; 36 | import javax.crypto.spec.IvParameterSpec; 37 | import javax.crypto.spec.SecretKeySpec; 38 | 39 | 40 | /** 41 | * Created by swapnibble on 2017-08-09. 42 | */ 43 | 44 | public class CryptUtil { 45 | 46 | public static byte[] aesEncrypt( byte[] key, byte[] data, byte[] iv ) { 47 | 48 | byte[] encrypted = null; 49 | 50 | try { 51 | 52 | SecretKey secureKey = new SecretKeySpec(key, "AES"); 53 | Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); 54 | 55 | c.init(Cipher.ENCRYPT_MODE, secureKey, new IvParameterSpec(iv)); 56 | 57 | encrypted = c.doFinal(data); 58 | 59 | } catch (NoSuchPaddingException e) { 60 | e.printStackTrace(); 61 | } catch (InvalidAlgorithmParameterException e) { 62 | e.printStackTrace(); 63 | } catch (NoSuchAlgorithmException e) { 64 | e.printStackTrace(); 65 | } catch (InvalidKeyException e) { 66 | e.printStackTrace(); 67 | } catch (BadPaddingException e) { 68 | e.printStackTrace(); 69 | } catch (IllegalBlockSizeException e) { 70 | e.printStackTrace(); 71 | } 72 | 73 | return encrypted; 74 | } 75 | 76 | public static byte[] aesDecrypt( byte[] key, byte[] data, byte[] iv) { 77 | byte[] decrypted = null; 78 | try { 79 | SecretKey secureKey = new SecretKeySpec(key, "AES"); 80 | Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); 81 | 82 | if ( iv.length > 16 ) { 83 | iv = Arrays.copyOf( iv, 16 ); // aes/cbc 에선 iv 는 16-byte ! 84 | } 85 | 86 | c.init(Cipher.DECRYPT_MODE, secureKey, new IvParameterSpec(iv)); 87 | 88 | decrypted = c.doFinal(data); 89 | 90 | } catch (NoSuchPaddingException e) { 91 | e.printStackTrace(); 92 | } catch (InvalidAlgorithmParameterException e) { 93 | e.printStackTrace(); 94 | } catch (NoSuchAlgorithmException e) { 95 | e.printStackTrace(); 96 | } catch (InvalidKeyException e) { 97 | e.printStackTrace(); 98 | } catch (BadPaddingException e) { 99 | e.printStackTrace(); 100 | } catch (IllegalBlockSizeException e) { 101 | e.printStackTrace(); 102 | } 103 | 104 | return decrypted; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/local/db/AppDatabase.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.local.db; 2 | 3 | import android.arch.persistence.room.Database; 4 | import android.arch.persistence.room.RoomDatabase; 5 | 6 | /** 7 | * Created by swapnibble on 2017-12-11. 8 | */ 9 | @Database( entities = {EosAccount.class}, version = AppDatabase.VERSION) 10 | public abstract class AppDatabase extends RoomDatabase { 11 | 12 | static final int VERSION = 1; 13 | 14 | public abstract EosAccountDao eosAccountDao(); 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/local/db/EosAccount.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.local.db; 2 | 3 | import android.arch.persistence.room.ColumnInfo; 4 | import android.arch.persistence.room.Entity; 5 | import android.arch.persistence.room.Index; 6 | import android.arch.persistence.room.PrimaryKey; 7 | import android.support.annotation.NonNull; 8 | 9 | /** 10 | * Created by swapnibble on 2017-12-08. 11 | */ 12 | @Entity( tableName = "eos_account", indices={@Index(value = "account_name", unique = true)}) 13 | public class EosAccount { 14 | public static final int TYPE_ACCOUNT_ALL = 0; 15 | public static final int TYPE_ACCOUNT_USER = 1; 16 | public static final int TYPE_ACCOUNT_CONTRACT = 2; 17 | 18 | @PrimaryKey 19 | @ColumnInfo( name = "account_name") 20 | @NonNull 21 | public String name; 22 | 23 | @ColumnInfo( name = "type") 24 | public Integer type; 25 | 26 | public static EosAccount from( String name){ 27 | return new EosAccount(name, TYPE_ACCOUNT_ALL ); 28 | } 29 | 30 | public EosAccount( String name, Integer type){ 31 | this.name = name; 32 | this.type = type; 33 | } 34 | 35 | @Override 36 | public int hashCode(){ 37 | int result = 0; 38 | 39 | result = 31 * result + (name != null ? name.hashCode() : 0); 40 | result = 31 * result + (type != null ? type : 0); 41 | 42 | return result; 43 | } 44 | 45 | @Override 46 | public String toString(){ 47 | return name; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/local/db/EosAccountDao.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.local.db; 2 | 3 | import android.arch.persistence.room.Dao; 4 | import android.arch.persistence.room.Delete; 5 | import android.arch.persistence.room.Insert; 6 | import android.arch.persistence.room.OnConflictStrategy; 7 | import android.arch.persistence.room.Query; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by swapnibble on 2017-12-11. 13 | */ 14 | @Dao 15 | public interface EosAccountDao { 16 | @Query("SELECT account_name FROM eos_account ORDER BY account_name") 17 | List getAll(); 18 | 19 | @Query("SELECT account_name FROM eos_account WHERE account_name like :nameStarts ORDER BY account_name") 20 | List getAll(String nameStarts); 21 | 22 | @Query("SELECT account_name FROM eos_account WHERE account_name like :nameStarts AND type=:account_type ORDER BY account_name") 23 | List getAllWithType(String nameStarts, Integer account_type); 24 | 25 | @Insert (onConflict = OnConflictStrategy.REPLACE) 26 | void insertAll( List accounts); 27 | 28 | @Insert (onConflict = OnConflictStrategy.REPLACE) 29 | void insertAll( EosAccount... accounts); 30 | 31 | @Insert (onConflict = OnConflictStrategy.REPLACE) 32 | void insert( EosAccount account); 33 | 34 | @Delete 35 | void delete( EosAccount account); 36 | 37 | @Query("DELETE FROM eos_account") 38 | void deleteAll(); 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/local/repository/EosAccountRepository.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.local.repository; 2 | 3 | import java.util.List; 4 | 5 | import io.plactal.eoscommander.util.RefValue; 6 | 7 | /** 8 | * Created by swapnibble on 2017-12-14. 9 | */ 10 | 11 | public interface EosAccountRepository { 12 | void addAll(String... accountNames); 13 | void addAll(List accountNames); 14 | void addAccount(String accountName); 15 | void deleteAll(); 16 | void delete(String accountName); 17 | 18 | /** 19 | * get account list 20 | * @return 21 | */ 22 | List getAll( ); 23 | 24 | List searchName( String nameStarts); 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/local/repository/EosAccountRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.local.repository; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | import java.util.Set; 7 | import java.util.TreeSet; 8 | 9 | import io.plactal.eoscommander.data.local.db.AppDatabase; 10 | import io.plactal.eoscommander.data.local.db.EosAccount; 11 | import io.plactal.eoscommander.util.RefValue; 12 | 13 | /** 14 | * Created by swapnibble on 2017-12-14. 15 | */ 16 | 17 | public class EosAccountRepositoryImpl implements EosAccountRepository { 18 | 19 | private AppDatabase mAppDatabase; 20 | 21 | public EosAccountRepositoryImpl( AppDatabase appDatabase ) { 22 | mAppDatabase = appDatabase; 23 | } 24 | 25 | 26 | @Override 27 | public void addAll(String... accountNames) { 28 | 29 | ArrayList eosAccounts = new ArrayList<>(accountNames.length); 30 | 31 | for ( String name : accountNames ) { 32 | eosAccounts.add( EosAccount.from(name ) ); 33 | } 34 | 35 | mAppDatabase.eosAccountDao().insertAll(eosAccounts); 36 | } 37 | 38 | @Override 39 | public void addAll(List accountNames){ 40 | ArrayList eosAccounts = new ArrayList<>(accountNames.size()); 41 | 42 | for ( String name : accountNames ) { 43 | eosAccounts.add( EosAccount.from(name ) ); 44 | } 45 | 46 | mAppDatabase.eosAccountDao().insertAll(eosAccounts); 47 | } 48 | 49 | @Override 50 | public void addAccount(String accountName) { 51 | mAppDatabase.eosAccountDao().insert( EosAccount.from(accountName) ); 52 | } 53 | 54 | @Override 55 | public void deleteAll() { 56 | mAppDatabase.eosAccountDao().deleteAll(); 57 | } 58 | 59 | @Override 60 | public void delete(String accountName) { 61 | mAppDatabase.eosAccountDao().delete( EosAccount.from(accountName)); 62 | } 63 | 64 | @Override 65 | public List getAll() { 66 | return mAppDatabase.eosAccountDao().getAll(); // get accounts from db 67 | } 68 | 69 | @Override 70 | public List searchName( String nameStarts) { 71 | return mAppDatabase.eosAccountDao().getAll( nameStarts + "%%"); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/HostInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote; 25 | 26 | 27 | import java.io.IOException; 28 | 29 | import io.plactal.eoscommander.util.StringUtils; 30 | import okhttp3.HttpUrl; 31 | import okhttp3.Interceptor; 32 | import okhttp3.Request; 33 | import okhttp3.Response; 34 | 35 | /** 36 | * Created by swapnibble on 2017-11-03. 37 | */ 38 | public class HostInterceptor implements Interceptor { 39 | 40 | private String mHost; 41 | private String mScheme; 42 | private int mPort; 43 | 44 | public HostInterceptor(){ 45 | } 46 | 47 | public void setInterceptor(String scheme, String host, int port) { 48 | mScheme = scheme; 49 | mHost = host; 50 | mPort = port; 51 | } 52 | 53 | @Override 54 | public Response intercept(Chain chain) throws IOException { 55 | 56 | Request original = chain.request(); 57 | 58 | // If new Base URL is properly formatted then replace the old one 59 | if ( !StringUtils.isEmpty(mScheme) && !StringUtils.isEmpty(mHost) ) { 60 | HttpUrl newUrl = original.url().newBuilder() 61 | .scheme(mScheme) 62 | .host(mHost) 63 | .port( mPort ) 64 | .build(); 65 | original = original.newBuilder() 66 | .url(newUrl) 67 | .build(); 68 | } 69 | 70 | 71 | return chain.proceed(original); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/NodeosApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote; 25 | 26 | 27 | import com.google.gson.JsonArray; 28 | import com.google.gson.JsonObject; 29 | 30 | import io.plactal.eoscommander.data.remote.model.api.GetBalanceRequest; 31 | import io.plactal.eoscommander.data.remote.model.api.GetRequestForCurrency; 32 | import io.plactal.eoscommander.data.remote.model.api.JsonToBinRequest; 33 | import io.plactal.eoscommander.data.remote.model.api.JsonToBinResponse; 34 | import io.plactal.eoscommander.data.remote.model.api.GetCodeRequest; 35 | import io.plactal.eoscommander.data.remote.model.api.GetCodeResponse; 36 | import io.plactal.eoscommander.data.remote.model.api.GetRequiredKeys; 37 | import io.plactal.eoscommander.data.remote.model.chain.PackedTransaction; 38 | import io.plactal.eoscommander.data.remote.model.api.RequiredKeysResponse; 39 | import io.plactal.eoscommander.data.remote.model.api.AccountInfoRequest; 40 | import io.plactal.eoscommander.data.remote.model.api.EosChainInfo; 41 | import io.plactal.eoscommander.data.remote.model.api.GetTableRequest; 42 | import io.plactal.eoscommander.data.remote.model.api.PushTxnResponse; 43 | import io.reactivex.Observable; 44 | import retrofit2.http.Body; 45 | import retrofit2.http.POST; 46 | import retrofit2.http.Path; 47 | 48 | /** 49 | * Created by swapnibble on 2017-09-08. 50 | */ 51 | 52 | public interface NodeosApi { 53 | 54 | @POST("/v1/chain/{infoType}") 55 | Observable readInfo(@Path("infoType") String infoType); 56 | 57 | @POST("/v1/chain/get_account") 58 | Observable getAccountInfo(@Body AccountInfoRequest body); 59 | 60 | @POST("/v1/chain/get_table_rows") 61 | Observable getTable(@Body GetTableRequest body); 62 | 63 | @POST("/v1/chain/push_transaction") 64 | Observable pushTransaction(@Body PackedTransaction body); 65 | 66 | @POST("/v1/chain/push_transaction") 67 | Observable pushTransactionRetJson(@Body PackedTransaction body); 68 | 69 | @POST("/v1/chain/get_required_keys") 70 | Observable getRequiredKeys(@Body GetRequiredKeys body); 71 | 72 | 73 | 74 | @POST("/v1/chain/get_currency_balance") 75 | Observable getCurrencyBalance(@Body GetBalanceRequest body); 76 | 77 | @POST("/v1/chain/get_currency_stats") 78 | Observable getCurrencyStats(@Body GetRequestForCurrency body); 79 | 80 | 81 | 82 | @POST("/v1/chain/abi_json_to_bin") 83 | Observable jsonToBin(@Body JsonToBinRequest body); 84 | 85 | @POST("/v1/chain/get_code") 86 | Observable getCode(@Body GetCodeRequest body); 87 | 88 | @POST("/v1/history/get_controlled_accounts") 89 | Observable getServants(@Body JsonObject body); 90 | 91 | @POST("/v1/history/get_actions") 92 | Observable getActions(@Body JsonObject body); 93 | 94 | String GET_SERVANTS_KEY = "controlling_account"; 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/abi/EosAbiAction.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.abi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | /** 6 | * Created by swapnibble on 2017-12-22. 7 | */ 8 | 9 | public class EosAbiAction { 10 | @Expose 11 | public String name; 12 | 13 | @Expose 14 | public String type; 15 | 16 | @Override 17 | public String toString(){ 18 | return "EosAction: " + name + ", type: "+ type ; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/abi/EosAbiField.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.abi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | /** 6 | * Created by swapnibble on 2018-03-19. 7 | */ 8 | 9 | public class EosAbiField { 10 | @Expose 11 | public String name; 12 | 13 | @Expose 14 | public String type; 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/abi/EosAbiMain.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.abi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.util.ArrayList; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * Created by swapnibble on 2017-12-22. 12 | */ 13 | 14 | public class EosAbiMain { 15 | 16 | @Expose 17 | public List types; 18 | 19 | @Expose 20 | public List actions; 21 | 22 | @Expose 23 | public List structs; 24 | 25 | @Expose 26 | public List tables; 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/abi/EosAbiStruct.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.abi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * Created by swapnibble on 2017-12-22. 10 | */ 11 | 12 | public class EosAbiStruct { 13 | 14 | @Expose 15 | public String name; 16 | 17 | @Expose 18 | public String base; 19 | 20 | @Expose 21 | public List fields; 22 | 23 | @Override 24 | public String toString() { 25 | return "Struct name: " + name + ", base: " + base ; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/abi/EosAbiTable.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.abi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by swapnibble on 2017-12-26. 9 | */ 10 | 11 | public class EosAbiTable { 12 | 13 | @Expose 14 | public String name; 15 | 16 | @Expose 17 | public String type; 18 | 19 | @Expose 20 | public String index_type; 21 | 22 | @Expose 23 | public List key_names; 24 | 25 | @Expose 26 | public List key_types; 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/abi/EosAbiTypeDef.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.abi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by swapnibble on 2018-01-03. 9 | */ 10 | 11 | public class EosAbiTypeDef { 12 | @Expose 13 | public String new_type_name; // fixed_string32 14 | 15 | @Expose 16 | public String type; 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/AccountInfoRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | import com.google.gson.annotations.Expose; 27 | import com.google.gson.annotations.SerializedName; 28 | 29 | /** 30 | * Created by swapnibble on 2017-09-14. 31 | */ 32 | 33 | public class AccountInfoRequest { 34 | 35 | @Expose 36 | private String account_name; 37 | 38 | public AccountInfoRequest(String name) { 39 | setName(name); 40 | } 41 | 42 | public String getName() { 43 | return account_name; 44 | } 45 | 46 | public void setName(String name) { 47 | this.account_name = name; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/EosChainInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-08. 28 | */ 29 | 30 | import com.google.gson.annotations.Expose; 31 | 32 | import java.text.DateFormat; 33 | import java.text.ParseException; 34 | import java.text.SimpleDateFormat; 35 | import java.util.Calendar; 36 | import java.util.Date; 37 | 38 | public class EosChainInfo { 39 | 40 | @Expose 41 | private String server_version; 42 | 43 | @Expose 44 | private Integer head_block_num; 45 | 46 | @Expose 47 | private Integer last_irreversible_block_num; 48 | 49 | @Expose 50 | private String head_block_id; 51 | 52 | @Expose 53 | private String head_block_time; 54 | 55 | @Expose 56 | private String head_block_producer; 57 | 58 | @Expose 59 | private String chain_id; 60 | 61 | @Expose 62 | private long virtual_block_cpu_limit; 63 | 64 | @Expose 65 | private long virtual_block_net_limit; 66 | 67 | @Expose 68 | private long block_cpu_limit; 69 | 70 | @Expose 71 | private long block_net_limit; 72 | 73 | 74 | public Integer getHeadBlockNum() { 75 | return head_block_num; 76 | } 77 | 78 | public void setHeadBlockNum(Integer headBlockNum) { 79 | this.head_block_num = headBlockNum; 80 | } 81 | 82 | public Integer getLastIrreversibleBlockNum() { 83 | return last_irreversible_block_num; 84 | } 85 | 86 | public void setLastIrreversibleBlockNum(Integer lastIrreversibleBlockNum) { 87 | this.last_irreversible_block_num = lastIrreversibleBlockNum; 88 | } 89 | 90 | public String getHeadBlockId() { 91 | return head_block_id; 92 | } 93 | 94 | public void setHeadBlockId(String headBlockId) { 95 | this.head_block_id = headBlockId; 96 | } 97 | 98 | public String getHeadBlockTime() { 99 | return head_block_time; 100 | } 101 | 102 | public void setHeadBlockTime(String headBlockTime) { 103 | this.head_block_time = headBlockTime; 104 | } 105 | 106 | public String getTimeAfterHeadBlockTime(int diffInMilSec) { 107 | DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 108 | try { 109 | Date date = sdf.parse( this.head_block_time); 110 | 111 | Calendar c = Calendar.getInstance(); 112 | c.setTime(date); 113 | c.add( Calendar.MILLISECOND, diffInMilSec); 114 | date = c.getTime(); 115 | 116 | return sdf.format(date); 117 | 118 | } catch (ParseException e) { 119 | e.printStackTrace(); 120 | return this.head_block_time; 121 | } 122 | } 123 | 124 | public String getHeadBlockProducer() { 125 | return head_block_producer; 126 | } 127 | 128 | public void setHeadBlockProducer(String headBlockProducer) { 129 | this.head_block_producer = headBlockProducer; 130 | } 131 | 132 | 133 | public String getBrief(){ 134 | return "server_version: " + server_version 135 | + "\nhead block num: " + head_block_num 136 | + "\nlast irreversible block: " + last_irreversible_block_num 137 | + "\nhead block time: " + head_block_time 138 | + "\nhead block producer: " + head_block_producer ; 139 | } 140 | 141 | public String getChain_id() { 142 | return chain_id; 143 | } 144 | 145 | public void setChain_id(String chain_id) { 146 | this.chain_id = chain_id; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/GetBalanceRequest.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.api; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import io.plactal.eoscommander.data.remote.model.types.TypeAccountName; 6 | 7 | /** 8 | * Created by swapnibble on 2018-04-16. 9 | */ 10 | public class GetBalanceRequest extends GetRequestForCurrency{ 11 | 12 | @Expose 13 | private TypeAccountName account; 14 | 15 | public GetBalanceRequest(String tokenContract, String account, String symbol){ 16 | super( tokenContract, symbol ); 17 | this.account = new TypeAccountName(account); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/GetCodeRequest.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.api; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | /** 7 | * Created by swapnibble on 2018-01-10. 8 | */ 9 | 10 | public class GetCodeRequest { 11 | @SerializedName("account_name") 12 | @Expose 13 | private String name; 14 | 15 | public GetCodeRequest(String accountName){ 16 | name = accountName; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/GetCodeResponse.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.api; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.google.gson.annotations.Expose; 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | import io.plactal.eoscommander.crypto.digest.Sha256; 8 | import io.plactal.eoscommander.util.StringUtils; 9 | 10 | /** 11 | * Created by swapnibble on 2018-01-10. 12 | */ 13 | 14 | public class GetCodeResponse { 15 | @Expose 16 | private String account_name; 17 | 18 | @Expose 19 | private String wast; 20 | 21 | @Expose 22 | private String code_hash; 23 | 24 | @Expose 25 | private JsonObject abi; 26 | 27 | public JsonObject getAbi() { return abi; } 28 | 29 | public boolean isValidCode() { 30 | return ! ( StringUtils.isEmpty(code_hash) || Sha256.ZERO_HASH.toString().equals( code_hash )); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/GetRequestForCurrency.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.api; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import io.plactal.eoscommander.data.remote.model.types.TypeName; 5 | import io.plactal.eoscommander.util.StringUtils; 6 | 7 | /** 8 | * Created by swapnibble on 2018-04-16. 9 | */ 10 | public class GetRequestForCurrency { 11 | @Expose 12 | protected boolean json = false; 13 | 14 | @Expose 15 | protected TypeName code; 16 | 17 | @Expose 18 | protected String symbol; 19 | 20 | public GetRequestForCurrency(String tokenContract, String symbol){ 21 | this.code = new TypeName(tokenContract); 22 | this.symbol = StringUtils.isEmpty(symbol) ? null : symbol; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/GetRequiredKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | import com.google.gson.annotations.Expose; 27 | import com.google.gson.annotations.SerializedName; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | import io.plactal.eoscommander.data.remote.model.chain.SignedTransaction; 33 | 34 | 35 | /** 36 | * Created by swapnibble on 2017-11-15. 37 | */ 38 | 39 | public class GetRequiredKeys { 40 | @Expose 41 | private SignedTransaction transaction; 42 | 43 | @Expose 44 | private List available_keys ; 45 | 46 | public GetRequiredKeys(SignedTransaction transaction, List keys ) { 47 | this.transaction = transaction; 48 | 49 | if ( null != keys ) { 50 | available_keys = new ArrayList<>(keys); 51 | } 52 | else { 53 | available_keys = new ArrayList<>(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/GetTableRequest.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.api; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | import io.plactal.eoscommander.util.StringUtils; 7 | 8 | /** 9 | * Created by swapnibble on 2017-09-15. 10 | */ 11 | 12 | public class GetTableRequest { 13 | private static final int DEFAULT_FETCH_LIMIT = 10; 14 | 15 | @Expose 16 | private boolean json = true; 17 | 18 | @Expose 19 | private String code; 20 | 21 | @Expose 22 | private String scope; 23 | 24 | @Expose 25 | private String table; 26 | 27 | @Expose 28 | private String table_key = ""; 29 | 30 | @Expose 31 | private String lower_bound= ""; 32 | 33 | @Expose 34 | private String upper_bound= ""; 35 | 36 | @Expose 37 | private int limit ; 38 | 39 | 40 | 41 | public GetTableRequest( String scope, String code, String table, String tableKey, String lowerBound, String upperBound, int limit ) { 42 | this.scope = scope; 43 | this.code = code; 44 | this.table = table; 45 | 46 | this.table_key = StringUtils.isEmpty( tableKey ) ? "" : tableKey; 47 | this.lower_bound = StringUtils.isEmpty( lowerBound) ? "" : lowerBound; 48 | this.upper_bound = StringUtils.isEmpty( upperBound) ? "" : upperBound; 49 | this.limit = limit <= 0 ? DEFAULT_FETCH_LIMIT : limit; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/JsonToBinRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | import com.google.gson.JsonElement; 27 | import com.google.gson.JsonParser; 28 | import com.google.gson.annotations.Expose; 29 | import com.google.gson.annotations.SerializedName; 30 | 31 | /** 32 | * Created by swapnibble on 2017-11-17. 33 | */ 34 | 35 | public class JsonToBinRequest { 36 | @Expose 37 | private String code; 38 | 39 | @Expose 40 | private String action; 41 | 42 | @Expose 43 | private JsonElement args; 44 | 45 | public JsonToBinRequest( String code, String action, String args ) { 46 | this.code = code; 47 | this.action = action; 48 | this.args = new JsonParser().parse( args ); 49 | } 50 | 51 | public String getArgsString() {return args.getAsString();} 52 | 53 | public void putArgs(String args) { 54 | this.args = new JsonParser().parse(args); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/JsonToBinResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | import com.google.gson.annotations.Expose; 27 | import com.google.gson.annotations.SerializedName; 28 | 29 | import java.util.List; 30 | 31 | /** 32 | * Created by swapnibble on 2017-11-17. 33 | */ 34 | 35 | public class JsonToBinResponse { 36 | @Expose 37 | private String binargs; 38 | 39 | @Expose 40 | private List required_scope; 41 | 42 | @Expose 43 | private List required_auth; 44 | 45 | public String getBinargs() { 46 | return binargs; 47 | } 48 | 49 | public List getRequiredScope(){ 50 | return required_scope; 51 | } 52 | 53 | public List getRequiredAuth(){ 54 | return required_auth; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/Key.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-14. 28 | */ 29 | 30 | import com.google.gson.annotations.Expose; 31 | import com.google.gson.annotations.SerializedName; 32 | 33 | public class Key { 34 | 35 | @Expose 36 | private String key; 37 | 38 | @Expose 39 | private Integer weight; 40 | 41 | public String getKey() { 42 | return key; 43 | } 44 | 45 | public void setKey(String key) { 46 | this.key = key; 47 | } 48 | 49 | public Integer getWeight() { 50 | return weight; 51 | } 52 | 53 | public void setWeight(Integer weight) { 54 | this.weight = weight; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/Permission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-14. 28 | */ 29 | 30 | import com.google.gson.annotations.Expose; 31 | import com.google.gson.annotations.SerializedName; 32 | 33 | public class Permission { 34 | 35 | @Expose 36 | private String name; 37 | 38 | @Expose 39 | private String parent; 40 | 41 | @Expose 42 | private RequiredAuth required_auth; 43 | 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | 53 | public String getParent() { 54 | return parent; 55 | } 56 | 57 | public void setParent(String parent) { 58 | this.parent = parent; 59 | } 60 | 61 | public RequiredAuth getRequiredAuth() { 62 | return required_auth; 63 | } 64 | 65 | public void setRequiredAuth(RequiredAuth requiredAuth) { 66 | this.required_auth = requiredAuth; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/PushTxnResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-11. 28 | */ 29 | 30 | import com.google.gson.annotations.Expose; 31 | 32 | import io.plactal.eoscommander.data.remote.model.chain.TransactionTrace; 33 | import io.plactal.eoscommander.util.StringUtils; 34 | 35 | public class PushTxnResponse { 36 | 37 | @Expose 38 | private String transaction_id; 39 | 40 | @Expose 41 | private TransactionTrace processed; 42 | 43 | public String getTransactionId() { 44 | return transaction_id; 45 | } 46 | 47 | public void setTransactionId(String transactionId) { 48 | this.transaction_id = transactionId; 49 | } 50 | 51 | public TransactionTrace getProcessed() { 52 | return processed; 53 | } 54 | 55 | public void setProcessed(TransactionTrace processed) { 56 | this.processed = processed; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | if (StringUtils.isEmpty(transaction_id) || (processed == null )) return ""; 62 | 63 | return "transaction: " + transaction_id + "\n" + processed.toString(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/RequiredAuth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-14. 28 | */ 29 | 30 | import com.google.gson.annotations.Expose; 31 | import com.google.gson.annotations.SerializedName; 32 | 33 | import java.util.List; 34 | 35 | public class RequiredAuth { 36 | 37 | @Expose 38 | private Integer threshold; 39 | 40 | @Expose 41 | private List keys = null; 42 | 43 | @Expose 44 | private List accounts = null; 45 | 46 | public Integer getThreshold() { 47 | return threshold; 48 | } 49 | 50 | public void setThreshold(Integer threshold) { 51 | this.threshold = threshold; 52 | } 53 | 54 | public List getKeys() { 55 | return keys; 56 | } 57 | 58 | public void setKeys(List keys) { 59 | this.keys = keys; 60 | } 61 | 62 | public List getAccounts() { 63 | return accounts; 64 | } 65 | 66 | public void setAccounts(List accounts) { 67 | this.accounts = accounts; 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/api/RequiredKeysResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.api; 25 | 26 | import com.google.gson.annotations.Expose; 27 | import com.google.gson.annotations.SerializedName; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | import io.plactal.eoscommander.crypto.ec.EosPublicKey; 33 | 34 | /** 35 | * Created by swapnibble on 2017-11-15. 36 | */ 37 | 38 | public class RequiredKeysResponse { 39 | 40 | @Expose 41 | private List required_keys ; 42 | 43 | public List getKeys() { 44 | if ( null == required_keys ){ 45 | return new ArrayList<>(); 46 | } 47 | 48 | ArrayList retKeys = new ArrayList<>(required_keys.size()); 49 | for ( String pubKey: required_keys ){ 50 | retKeys.add( new EosPublicKey( pubKey)); 51 | } 52 | 53 | return retKeys; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/ActionTrace.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.chain; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by swapnibble on 2018-03-20. 9 | */ 10 | 11 | public class ActionTrace { 12 | @Expose 13 | public String receiver; 14 | 15 | @Expose 16 | public boolean context_free; 17 | 18 | @Expose 19 | public long cpu_usage; 20 | 21 | @Expose 22 | public Action act; 23 | 24 | @Expose 25 | public String console; 26 | 27 | @Expose 28 | public List data_access; 29 | 30 | @Expose 31 | public long auths_used; // uint32_t 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/DataAccessInfo.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.chain; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import io.plactal.eoscommander.data.remote.model.types.TypeAccountName; 6 | import io.plactal.eoscommander.data.remote.model.types.TypeScopeName; 7 | 8 | 9 | /** 10 | * Created by swapnibble on 2018-03-20. 11 | */ 12 | 13 | public class DataAccessInfo { 14 | //public enum Type { read, write }; 15 | 16 | @Expose 17 | private String type; // access type 18 | 19 | @Expose 20 | private TypeAccountName code; 21 | 22 | @Expose 23 | private TypeScopeName scope; 24 | 25 | @Expose 26 | private long sequence; // uint64_t 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/PackedTransaction.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.chain; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.io.ByteArrayOutputStream; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.zip.DataFormatException; 10 | import java.util.zip.Deflater; 11 | import java.util.zip.Inflater; 12 | 13 | import io.plactal.eoscommander.crypto.util.HexUtils; 14 | import io.plactal.eoscommander.data.remote.model.types.EosByteWriter; 15 | import io.plactal.eoscommander.util.Utils; 16 | 17 | /** 18 | * Created by swapnibble on 2018-03-19. 19 | */ 20 | 21 | public class PackedTransaction { 22 | public enum CompressType{ none, zlib } 23 | 24 | @Expose 25 | final List signatures ; 26 | 27 | @Expose 28 | final String compression; 29 | 30 | @Expose 31 | private String packed_context_free_data; 32 | 33 | @Expose 34 | private String packed_trx; 35 | 36 | public PackedTransaction(SignedTransaction stxn, CompressType compressType){ 37 | compression = compressType.name(); 38 | signatures = stxn.getSignatures(); 39 | 40 | packed_trx = HexUtils.toHex( packTransaction( stxn, compressType) ); 41 | 42 | byte[] packed_ctx_free_bytes = packContextFreeData( stxn.getCtxFreeData(), compressType ); 43 | packed_context_free_data = ( packed_ctx_free_bytes.length == 0 ) ? "" : HexUtils.toHex( packed_ctx_free_bytes ); 44 | } 45 | 46 | private byte[] packTransaction( Transaction transaction, CompressType compressType ) { 47 | EosByteWriter byteWriter = new EosByteWriter(512); 48 | transaction.pack(byteWriter); 49 | 50 | // pack -> compress 51 | return compress( byteWriter.toBytes(), compressType ) ; 52 | } 53 | 54 | 55 | private byte[] packContextFreeData( List ctxFreeData, CompressType compressType ){ 56 | EosByteWriter byteWriter = new EosByteWriter(64); 57 | 58 | int ctxFreeDataCount = ( ctxFreeData == null ) ? 0 : ctxFreeData.size(); 59 | if ( ctxFreeDataCount == 0 ){ 60 | return byteWriter.toBytes(); 61 | } 62 | 63 | byteWriter.putVariableUInt( ctxFreeDataCount); 64 | 65 | for ( String hexData : ctxFreeData ) { 66 | byteWriter.putBytes( HexUtils.toBytes( hexData)); 67 | } 68 | 69 | return compress( byteWriter.toBytes(), compressType ) ; 70 | } 71 | 72 | 73 | public PackedTransaction(SignedTransaction stxn){ 74 | this( stxn, CompressType.none); 75 | } 76 | 77 | // public long getDataSize() { 78 | // return data.length() / 2; // hex -> raw bytes 79 | // } 80 | 81 | private byte[] compress( byte[] uncompressedBytes, CompressType compressType) { 82 | if ( compressType == null || !CompressType.zlib.equals( compressType)) { 83 | return uncompressedBytes; 84 | } 85 | 86 | // zip! 87 | Deflater deflater = new Deflater( Deflater.BEST_COMPRESSION ); 88 | deflater.setInput( uncompressedBytes ); 89 | 90 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream( uncompressedBytes.length); 91 | deflater.finish(); 92 | byte[] buffer = new byte[1024]; 93 | while (!deflater.finished()) { 94 | int count = deflater.deflate(buffer); // returns the generated code... index 95 | outputStream.write(buffer, 0, count); 96 | } 97 | 98 | try { 99 | outputStream.close(); 100 | } 101 | catch (IOException e) { 102 | e.printStackTrace(); 103 | return uncompressedBytes; 104 | } 105 | 106 | return outputStream.toByteArray(); 107 | } 108 | 109 | private byte[] decompress( byte [] compressedBytes ) { 110 | Inflater inflater = new Inflater(); 111 | inflater.setInput( compressedBytes ); 112 | 113 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream( compressedBytes.length); 114 | byte[] buffer = new byte[1024]; 115 | 116 | try { 117 | while (!inflater.finished()) { 118 | int count = inflater.inflate(buffer); 119 | outputStream.write(buffer, 0, count); 120 | } 121 | outputStream.close(); 122 | } 123 | catch (DataFormatException | IOException e) { 124 | e.printStackTrace(); 125 | return compressedBytes; 126 | } 127 | 128 | 129 | return outputStream.toByteArray(); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/SignedTransaction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.chain; 25 | 26 | import com.google.gson.annotations.Expose; 27 | 28 | import java.security.MessageDigest; 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | import io.plactal.eoscommander.crypto.util.HexUtils; 33 | import io.plactal.eoscommander.data.remote.model.types.EosByteWriter; 34 | import io.plactal.eoscommander.crypto.digest.Sha256; 35 | import io.plactal.eoscommander.crypto.ec.EcDsa; 36 | import io.plactal.eoscommander.crypto.ec.EcSignature; 37 | import io.plactal.eoscommander.crypto.ec.EosPrivateKey; 38 | import io.plactal.eoscommander.data.remote.model.types.TypeChainId; 39 | 40 | /** 41 | * Created by swapnibble on 2017-09-11. 42 | */ 43 | 44 | public class SignedTransaction extends Transaction { 45 | 46 | @Expose 47 | private List signatures = null; 48 | 49 | @Expose 50 | private List context_free_data = new ArrayList<>(); 51 | 52 | 53 | public SignedTransaction(){ 54 | super(); 55 | } 56 | 57 | public SignedTransaction( SignedTransaction anotherTxn){ 58 | super(anotherTxn); 59 | this.signatures = deepCopyOnlyContainer( anotherTxn.signatures ); 60 | this.context_free_data = deepCopyOnlyContainer(anotherTxn.context_free_data); 61 | } 62 | 63 | public List getSignatures() { 64 | return signatures; 65 | } 66 | 67 | public void putSignatures(List signatures) { 68 | this.signatures = signatures; 69 | } 70 | 71 | public int getCtxFreeDataCount() { 72 | return ( context_free_data == null ) ? 0 : context_free_data.size(); 73 | } 74 | 75 | public List getCtxFreeData() { 76 | return context_free_data; 77 | } 78 | 79 | private byte[] getCfdHash() { 80 | if (context_free_data.size() <= 0 ) { 81 | return Sha256.ZERO_HASH.getBytes(); 82 | } 83 | 84 | EosByteWriter writer = new EosByteWriter(255); 85 | 86 | writer.putVariableUInt( context_free_data.size()); 87 | 88 | for ( String hexData : context_free_data) { 89 | byte[] rawData = HexUtils.toBytes( hexData); 90 | writer.putVariableUInt( rawData.length); 91 | writer.putBytes( rawData); 92 | } 93 | 94 | return Sha256.from( writer.toBytes()).getBytes(); 95 | } 96 | 97 | 98 | private Sha256 getDigestForSignature(TypeChainId chainId) { 99 | EosByteWriter writer = new EosByteWriter(255); 100 | 101 | // data layout to sign : 102 | // [ {chainId}, {Transaction( parent class )}, {hash of context_free_data} ] 103 | 104 | writer.putBytes(chainId.getBytes()); 105 | pack( writer); 106 | writer.putBytes( getCfdHash()); 107 | 108 | return Sha256.from(writer.toBytes()); 109 | } 110 | 111 | public void sign(EosPrivateKey privateKey, TypeChainId chainId) { 112 | if ( null == this.signatures){ 113 | this.signatures = new ArrayList<>(); 114 | } 115 | 116 | EcSignature signature = EcDsa.sign(getDigestForSignature( chainId ), privateKey); 117 | this.signatures.add( signature.toString()); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/Transaction.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.chain; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.annotations.Expose; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | import io.plactal.eoscommander.data.remote.model.types.EosType; 10 | 11 | /** 12 | * Created by swapnibble on 2018-03-19. 13 | */ 14 | 15 | public class Transaction extends TransactionHeader { 16 | @Expose 17 | private List context_free_actions = new ArrayList<>(); 18 | 19 | @Expose 20 | private List actions = null; 21 | 22 | // Extentions are prefixed with type and are a buffer that can be interpreted by code that is aware and ignored by unaware code. 23 | @Expose 24 | private List transaction_extensions = new ArrayList<>(); 25 | 26 | public Transaction(){ 27 | super(); 28 | } 29 | 30 | 31 | public Transaction( Transaction other) { 32 | super(other); 33 | this.context_free_actions = deepCopyOnlyContainer( other.context_free_actions ); 34 | this.actions = deepCopyOnlyContainer( other.actions ); 35 | this.transaction_extensions = other.transaction_extensions; 36 | } 37 | 38 | public void addAction(Action msg ){ 39 | if ( null == actions) { 40 | actions = new ArrayList<>(1); 41 | } 42 | 43 | actions.add( msg); 44 | } 45 | 46 | 47 | public List getActions() { 48 | return actions; 49 | } 50 | 51 | public void setActions(List actions) { 52 | this.actions = actions; 53 | } 54 | 55 | public int getContextFreeActionCount(){ return ( context_free_actions == null ? 0 : context_free_actions.size());} 56 | 57 | 58 | List deepCopyOnlyContainer(List srcList){ 59 | if ( null == srcList ){ 60 | return null; 61 | } 62 | 63 | List newList = new ArrayList<>( srcList.size() ); 64 | newList.addAll( srcList); 65 | 66 | return newList; 67 | } 68 | 69 | @Override 70 | public void pack(EosType.Writer writer) { 71 | super.pack(writer); 72 | 73 | writer.putCollection(context_free_actions); 74 | writer.putCollection(actions); 75 | //writer.putCollection(transaction_extensions); 76 | writer.putVariableUInt( transaction_extensions.size()); 77 | if ( transaction_extensions.size() > 0 ){ 78 | // TODO 구체적 코드가 나오면 확인후 구현할 것. 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/TransactionHeader.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.chain; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.math.BigInteger; 6 | import java.text.DateFormat; 7 | import java.text.ParseException; 8 | import java.text.SimpleDateFormat; 9 | import java.util.Date; 10 | import java.util.TimeZone; 11 | 12 | import io.plactal.eoscommander.crypto.util.BitUtils; 13 | import io.plactal.eoscommander.crypto.util.HexUtils; 14 | import io.plactal.eoscommander.data.remote.model.types.EosType; 15 | 16 | /** 17 | * Created by swapnibble on 2018-03-19. 18 | */ 19 | 20 | public class TransactionHeader implements EosType.Packer { 21 | @Expose 22 | private String expiration; 23 | 24 | @Expose 25 | private int ref_block_num = 0; // uint16_t 26 | 27 | @Expose 28 | private long ref_block_prefix= 0;// uint32_t 29 | 30 | @Expose 31 | private long max_net_usage_words; // fc::unsigned_int 32 | 33 | @Expose 34 | private long max_cpu_usage_ms; // fc::unsigned_int 35 | 36 | @Expose 37 | private long delay_sec; // fc::unsigned_int 38 | 39 | public TransactionHeader(){ 40 | } 41 | 42 | public TransactionHeader( TransactionHeader other ){ 43 | this.expiration = other.expiration; 44 | this.ref_block_num = other.ref_block_num; 45 | this.ref_block_prefix = other.ref_block_prefix; 46 | this.max_net_usage_words = other.max_net_usage_words; 47 | this.max_cpu_usage_ms = other.max_cpu_usage_ms; 48 | this.delay_sec = other.delay_sec; 49 | } 50 | 51 | public String getExpiration() { 52 | return expiration; 53 | } 54 | 55 | public void setExpiration(String expiration) { 56 | this.expiration = expiration; 57 | } 58 | 59 | public void setReferenceBlock( String refBlockIdAsSha256 ) { 60 | ref_block_num = new BigInteger( 1, HexUtils.toBytes(refBlockIdAsSha256.substring(0,8))).intValue(); 61 | 62 | ref_block_prefix = //new BigInteger( 1, HexUtils.toBytesReversed( refBlockIdAsSha256.substring(16,24))).longValue(); 63 | BitUtils.uint32ToLong(HexUtils.toBytes(refBlockIdAsSha256.substring(16,24)), 0); // BitUtils treats bytes in little endian. 64 | // so, no need to reverse bytes. 65 | } 66 | 67 | public int getRefBlockNum() { 68 | return ref_block_num; 69 | } 70 | public long getRefBlockPrefix() { 71 | return ref_block_prefix; 72 | } 73 | 74 | 75 | private Date getExpirationAsDate(String dateStr) { 76 | DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 77 | try { 78 | sdf.setTimeZone(TimeZone.getTimeZone("UTC")); 79 | return sdf.parse( dateStr); 80 | 81 | } catch (ParseException e) { 82 | e.printStackTrace(); 83 | return new Date(); 84 | } 85 | } 86 | 87 | public void putNetUsageWords(long netUsage) { 88 | this.max_net_usage_words = netUsage; 89 | } 90 | 91 | public void putKcpuUsage(long kCpuUsage) { 92 | this.max_cpu_usage_ms = kCpuUsage; 93 | } 94 | 95 | @Override 96 | public void pack(EosType.Writer writer) { 97 | writer.putIntLE( (int)(getExpirationAsDate(expiration).getTime() / 1000) ); // ms -> sec 98 | 99 | writer.putShortLE( (short)(ref_block_num & 0xFFFF) ); // uint16 100 | writer.putIntLE( (int)( ref_block_prefix & 0xFFFFFFFF) );// uint32 101 | 102 | // fc::unsigned_int 103 | writer.putVariableUInt(max_net_usage_words); 104 | writer.putVariableUInt( max_cpu_usage_ms); 105 | writer.putVariableUInt( delay_sec); 106 | } 107 | 108 | //Mao Daishan added for easy use. 109 | public void setRefBlockNum(int refBlockNum){ 110 | ref_block_num=refBlockNum; 111 | } 112 | public void setRefBlockPrefix(long refBlockPrefix){ 113 | ref_block_prefix=refBlockPrefix; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/TransactionReceiptHeader.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.remote.model.chain; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import io.plactal.eoscommander.util.StringUtils; 6 | 7 | /** 8 | * Created by swapnibble on 2018-04-04. 9 | */ 10 | 11 | public class TransactionReceiptHeader { 12 | 13 | // enum status_enum { 14 | // executed = 0, ///< succeed, no error handler executed 15 | // soft_fail = 1, ///< objectively failed (not executed), error handler executed 16 | // hard_fail = 2, ///< objectively failed and error handler objectively failed thus no state change 17 | // delayed = 3 ///< transaction delayed 18 | // }; 19 | 20 | @Expose 21 | public String status ; 22 | 23 | @Expose 24 | public long cpu_usage_us; ///< total billed CPU usage (microseconds) 25 | 26 | @Expose 27 | public long net_usage_words;///< total billed NET usage, so we can reconstruct resource state when skipping context free data... hard failures... 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/chain/TransactionTrace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.chain; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-11. 28 | */ 29 | 30 | import com.google.gson.JsonElement; 31 | import com.google.gson.annotations.Expose; 32 | 33 | import java.util.List; 34 | 35 | import io.plactal.eoscommander.util.StringUtils; 36 | 37 | public class TransactionTrace { 38 | 39 | @Expose 40 | private String id; 41 | 42 | @Expose 43 | private TransactionReceiptHeader receipt; 44 | 45 | @Expose 46 | private long elapsed; 47 | 48 | @Expose 49 | private long net_usage; // uint64_t 50 | 51 | @Expose 52 | private boolean scheduled = false; 53 | 54 | @Expose 55 | private List action_traces; 56 | 57 | @Expose 58 | private JsonElement failed_dtrx_trace; 59 | 60 | @Expose 61 | private JsonElement except; 62 | 63 | @Override 64 | public String toString(){ 65 | if ( receipt == null) { 66 | return "empty receipt"; 67 | } 68 | 69 | String result = ": " + receipt.status; 70 | 71 | if ( receipt.net_usage_words < 0 ) { 72 | result += ""; 73 | } 74 | else { 75 | result += (receipt.net_usage_words * 8 ); 76 | } 77 | result += " bytes "; 78 | 79 | 80 | if ( receipt.cpu_usage_us < 0 ) { 81 | result += ""; 82 | } 83 | else { 84 | result += (receipt.net_usage_words * 8 ); 85 | } 86 | result += " us\n"; 87 | 88 | return result; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/EosByteReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | public class EosByteReader implements EosType.Reader{ 27 | 28 | private byte[] _buf; 29 | private int _index; 30 | 31 | public EosByteReader(byte[] buf) { 32 | _buf = buf; 33 | _index = 0; 34 | } 35 | 36 | public EosByteReader(byte[] buf, int index) { 37 | _buf = buf; 38 | _index = index; 39 | } 40 | 41 | @Override 42 | public byte get() throws EosType.InsufficientBytesException { 43 | checkAvailable(1); 44 | return _buf[_index++]; 45 | } 46 | 47 | 48 | @Override 49 | public int getShortLE() throws EosType.InsufficientBytesException { 50 | checkAvailable(2); 51 | return (((_buf[_index++] & 0xFF)) | ((_buf[_index++] & 0xFF) << 8)) & 0xFFFF; 52 | } 53 | 54 | @Override 55 | public int getIntLE() throws EosType.InsufficientBytesException { 56 | checkAvailable(4); 57 | return ((_buf[_index++] & 0xFF)) | ((_buf[_index++] & 0xFF) << 8) | ((_buf[_index++] & 0xFF) << 16) 58 | | ((_buf[_index++] & 0xFF) << 24); 59 | } 60 | 61 | 62 | @Override 63 | public long getLongLE() throws EosType.InsufficientBytesException { 64 | checkAvailable(8); 65 | return ((_buf[_index++] & 0xFFL)) | ((_buf[_index++] & 0xFFL) << 8) | ((_buf[_index++] & 0xFFL) << 16) 66 | | ((_buf[_index++] & 0xFFL) << 24) | ((_buf[_index++] & 0xFFL) << 32) | ((_buf[_index++] & 0xFFL) << 40) 67 | | ((_buf[_index++] & 0xFFL) << 48) | ((_buf[_index++] & 0xFFL) << 56); 68 | } 69 | 70 | @Override 71 | public byte[] getBytes(int size) throws EosType.InsufficientBytesException { 72 | checkAvailable(size); 73 | byte[] bytes = new byte[size]; 74 | System.arraycopy(_buf, _index, bytes, 0, size); 75 | _index += size; 76 | return bytes; 77 | } 78 | 79 | @Override 80 | public String getString() throws EosType.InsufficientBytesException { 81 | int size = (int)(getVariableUint() & 0x7FFFFFFF); // put 에서 variable uint 로 넣음. 82 | byte[] bytes = getBytes(size); 83 | return new String(bytes); 84 | } 85 | 86 | @Override 87 | public long getVariableUint() throws EosType.InsufficientBytesException { 88 | 89 | long v = 0; 90 | byte b, by = 0; 91 | do { 92 | b = get(); 93 | v |= ( b & 0x7F) << by; 94 | by +=7; 95 | } 96 | while ( (b & 0x80) != 0 ); 97 | 98 | return v; 99 | } 100 | 101 | 102 | private void checkAvailable(int num) throws EosType.InsufficientBytesException { 103 | if (_buf.length - _index < num) { 104 | throw new EosType.InsufficientBytesException(); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/EosNewAccount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import io.plactal.eoscommander.crypto.util.HexUtils; 27 | 28 | /** 29 | * Created by swapnibble on 2017-09-12. 30 | */ 31 | 32 | public class EosNewAccount implements EosType.Packer { 33 | private TypeAccountName mCreator; 34 | private TypeAccountName mNewName; 35 | private TypeAuthority mOwner; 36 | private TypeAuthority mActive; 37 | 38 | public String getActionName() { 39 | return "newaccount"; 40 | } 41 | 42 | public EosNewAccount(String creator, String newName, 43 | TypeAuthority owner, TypeAuthority active ) { 44 | 45 | this( new TypeAccountName(creator), new TypeAccountName(newName), owner, active); 46 | } 47 | 48 | public EosNewAccount( String creator, String newName, 49 | TypePublicKey ownerPubKey, TypePublicKey activePubKey) { 50 | 51 | this( new TypeAccountName(creator), new TypeAccountName(newName) 52 | , new TypeAuthority(1, ownerPubKey, null) 53 | , new TypeAuthority(1, activePubKey, null) ); 54 | } 55 | 56 | public EosNewAccount(TypeAccountName creator, TypeAccountName newName, 57 | TypeAuthority owner, TypeAuthority active) { 58 | 59 | mCreator = creator; 60 | mNewName = newName; 61 | mOwner = owner; 62 | mActive = active; 63 | } 64 | 65 | public String getCreatorName(){ 66 | return mCreator.toString(); 67 | } 68 | 69 | @Override 70 | public void pack(EosType.Writer writer) { 71 | 72 | mCreator.pack(writer); 73 | mNewName.pack(writer); 74 | mOwner.pack(writer); 75 | mActive.pack(writer); 76 | } 77 | 78 | public String getAsHex() { 79 | EosType.Writer writer = new EosByteWriter(256); 80 | 81 | pack(writer); 82 | return HexUtils.toHex( writer.toBytes() ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/EosTransfer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | 27 | import com.google.gson.annotations.Expose; 28 | 29 | import io.plactal.eoscommander.crypto.util.HexUtils; 30 | 31 | /** 32 | * Created by swapnibble on 2017-09-15. 33 | */ 34 | 35 | public class EosTransfer implements EosType.Packer { 36 | @Expose 37 | private TypeAccountName from; 38 | 39 | @Expose 40 | private TypeAccountName to; 41 | 42 | @Expose 43 | private TypeAsset quantity; 44 | 45 | @Expose 46 | private String memo; 47 | 48 | public EosTransfer(String from, String to, long quantity, String memo ) { 49 | this( new TypeAccountName(from), new TypeAccountName(to), quantity, memo ); 50 | } 51 | 52 | public EosTransfer(TypeAccountName from, TypeAccountName to, long quantity, String memo ) { 53 | this.from = from; 54 | this.to = to; 55 | this.quantity = new TypeAsset(quantity); 56 | this.memo = memo != null ? memo : ""; 57 | } 58 | 59 | public String getActionName() { 60 | return "transfer"; 61 | } 62 | 63 | 64 | @Override 65 | public void pack(EosType.Writer writer) { 66 | 67 | from.pack(writer); 68 | to.pack(writer); 69 | 70 | writer.putLongLE(quantity.getAmount()); 71 | 72 | writer.putString(memo); 73 | } 74 | 75 | public String getAsHex() { 76 | EosType.Writer writer = new EosByteWriter(128); 77 | pack(writer); 78 | 79 | return HexUtils.toHex( writer.toBytes() ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/EosType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import java.util.Collection; 27 | 28 | /** 29 | * Created by swapnibble on 2017-09-12. 30 | */ 31 | 32 | public interface EosType { 33 | class InsufficientBytesException extends Exception { 34 | 35 | private static final long serialVersionUID = 1L; 36 | } 37 | 38 | interface Packer { 39 | void pack(EosType.Writer writer); 40 | } 41 | 42 | interface Unpacker { 43 | void unpack(EosType.Reader reader) throws EosType.InsufficientBytesException; 44 | } 45 | 46 | interface Reader { 47 | byte get() throws EosType.InsufficientBytesException; 48 | int getShortLE() throws EosType.InsufficientBytesException; 49 | int getIntLE() throws EosType.InsufficientBytesException; 50 | long getLongLE() throws EosType.InsufficientBytesException; 51 | byte[] getBytes(int size) throws EosType.InsufficientBytesException; 52 | String getString() throws EosType.InsufficientBytesException; 53 | 54 | long getVariableUint() throws EosType.InsufficientBytesException; 55 | } 56 | 57 | interface Writer { 58 | void put(byte b); 59 | void putShortLE(short value); 60 | void putIntLE(int value); 61 | void putLongLE(long value); 62 | void putBytes(byte[] value); 63 | void putString(String value); 64 | byte[] toBytes(); 65 | int length(); 66 | 67 | void putCollection(Collection collection); 68 | 69 | void putVariableUInt(long val); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeAccountName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import io.plactal.eoscommander.util.StringUtils; 27 | 28 | /** 29 | * Created by swapnibble on 2017-09-12. 30 | */ 31 | 32 | public class TypeAccountName extends TypeName { 33 | private static final int MAX_ACCOUNT_NAME_LEN = 12; 34 | 35 | private static final char CHAR_NOT_ALLOWED = '.'; 36 | 37 | public TypeAccountName(String name) { 38 | super(name); 39 | 40 | if (! StringUtils.isEmpty( name )) { 41 | if (name.length() > MAX_ACCOUNT_NAME_LEN ) { 42 | throw new IllegalArgumentException("account name can only be 12 chars long: " + name) ; // changed from dawn3 43 | } 44 | 45 | if ( (name.indexOf( CHAR_NOT_ALLOWED) >= 0) && !(name.startsWith("eosio.") || name.endsWith(".m")) ){ 46 | throw new IllegalArgumentException("account name must not contain '.': " + name); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeActionName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | 27 | 28 | /** 29 | * Created by swapnibble on 2017-09-12. 30 | */ 31 | public class TypeActionName extends TypeName { 32 | public TypeActionName(long nameAsLong) { 33 | super(nameAsLong); 34 | } 35 | 36 | public TypeActionName(String name) { 37 | super(name); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeAsset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import java.util.regex.Matcher; 27 | import java.util.regex.Pattern; 28 | 29 | import io.plactal.eoscommander.util.StringUtils; 30 | 31 | 32 | /** 33 | * Created by swapnibble on 2017-09-12. 34 | */ 35 | 36 | public class TypeAsset implements EosType.Packer { 37 | 38 | public static final long MAX_AMOUNT = ( 1 << 62 ) - 1; 39 | 40 | private long mAmount; 41 | private TypeSymbol mSymbol; 42 | 43 | public TypeAsset(String value) { 44 | 45 | value = value.trim(); 46 | 47 | Pattern pattern = Pattern.compile("^([0-9]+)\\.?([0-9]*)([ ][a-zA-Z0-9]{1,7})?$");//\\s(\\w)$"); 48 | Matcher matcher = pattern.matcher(value); 49 | 50 | if ( matcher.find()) { 51 | String beforeDotVal = matcher.group(1), afterDotVal = matcher.group(2) ; 52 | 53 | String symbolStr = StringUtils.isEmpty(matcher.group(3)) ? null : matcher.group(3).trim(); 54 | 55 | mAmount = Long.valueOf( beforeDotVal + afterDotVal); 56 | mSymbol = new TypeSymbol( afterDotVal.length(), symbolStr ); 57 | } 58 | else { 59 | this.mAmount = 0; 60 | this.mSymbol = new TypeSymbol(); 61 | } 62 | } 63 | 64 | public TypeAsset(long amount) { 65 | this( amount, new TypeSymbol() ); 66 | } 67 | 68 | public TypeAsset( long amount, TypeSymbol symbol ){ 69 | this.mAmount = amount; 70 | this.mSymbol = symbol ; 71 | } 72 | 73 | public boolean isAmountInRange(){ 74 | return -MAX_AMOUNT <= mAmount && mAmount <= MAX_AMOUNT; 75 | } 76 | 77 | public boolean isValid(){ 78 | return isAmountInRange() && ( mSymbol != null ) && mSymbol.valid(); 79 | } 80 | 81 | 82 | 83 | public short decimals(){ 84 | return ( mSymbol != null ) ? mSymbol.decimals() : 0 ; 85 | } 86 | 87 | public long precision() { 88 | return ( mSymbol != null ) ? mSymbol.precision() : 0; 89 | } 90 | 91 | 92 | public String symbolName() { 93 | if ( mSymbol != null ){ 94 | return mSymbol.name(); 95 | } 96 | 97 | return ""; 98 | } 99 | 100 | 101 | public long getAmount(){ return mAmount;} 102 | 103 | @Override 104 | public String toString() { 105 | long precisionVal = precision(); 106 | String result = String.valueOf( mAmount / precisionVal); 107 | 108 | if ( decimals() > 0 ) { 109 | long fract = mAmount % precisionVal; 110 | result += "." + String.valueOf( precisionVal + fract).substring(1); 111 | } 112 | 113 | return result + " "+ symbolName(); 114 | } 115 | 116 | @Override 117 | public void pack(EosType.Writer writer) { 118 | 119 | writer.putLongLE(mAmount); 120 | 121 | if ( mSymbol != null ) { 122 | mSymbol.pack( writer ); 123 | } 124 | else { 125 | writer.putLongLE( 0 ); 126 | } 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeAuthority.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | 29 | /** 30 | * Created by swapnibble on 2017-09-12. 31 | */ 32 | 33 | public class TypeAuthority implements EosType.Packer { 34 | 35 | private int mThreshold; 36 | private List mKeys; 37 | private List mAccounts; 38 | private List mWaits; 39 | 40 | public TypeAuthority(int threshold, List keyWeight, 41 | List permissionLevelWeight, List waitWeight) { 42 | mThreshold = threshold; 43 | mKeys = keyWeight; 44 | 45 | mAccounts = permissionLevelWeight; 46 | mWaits = waitWeight; 47 | } 48 | 49 | private static List createList(T item ) { 50 | ArrayList retList = new ArrayList<>(); 51 | retList.add( item ); 52 | 53 | return retList; 54 | } 55 | 56 | 57 | public TypeAuthority(TypeKeyWeight oneKey, long uint32DelaySec) { 58 | this( 1, createList(oneKey), null, null); 59 | 60 | if ( uint32DelaySec > 0 ) { 61 | mThreshold = 2; 62 | mWaits = createList( new TypeWaitWeight(uint32DelaySec, 1)); 63 | } 64 | } 65 | 66 | public TypeAuthority(int threshold, TypePublicKey pubKey, String permission) { 67 | this( threshold 68 | ,( null == pubKey ? null: createList(new TypeKeyWeight( pubKey, (short)1)) ) 69 | ,( null == permission ? null : createList(new TypePermissionLevelWeight(permission))), null ); 70 | } 71 | 72 | @Override 73 | public void pack(EosType.Writer writer) { 74 | 75 | writer.putIntLE( mThreshold); 76 | 77 | // keys 78 | writer.putCollection( mKeys ); 79 | 80 | // accounts 81 | writer.putCollection( mAccounts ); 82 | 83 | // waits 84 | writer.putCollection( mWaits ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeChainId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | 27 | import io.plactal.eoscommander.crypto.digest.Sha256; 28 | 29 | /** 30 | * Created by swapnibble on 2017-10-30. 31 | */ 32 | 33 | public class TypeChainId { 34 | private final Sha256 mId; 35 | 36 | public TypeChainId() { 37 | mId = Sha256.ZERO_HASH; 38 | } 39 | 40 | byte [] getSha256FromHexStr(String str){ 41 | int len = str.length(); 42 | byte [] bytes = new byte[32]; 43 | for(int i=0;i= 'a' && c <= 'z' ) 40 | return (byte)((c - 'a') + 6); 41 | if( c >= '1' && c <= '5' ) 42 | return (byte)((c - '1') + 1); 43 | 44 | return (byte)0; 45 | } 46 | 47 | static public long string_to_name( String str ) { 48 | if ( null == str ) { 49 | return 0L; 50 | } 51 | 52 | int len = str.length(); 53 | long value = 0; 54 | 55 | for (int i = 0; i <= MAX_NAME_IDX; i++) { 56 | long c = 0; 57 | 58 | if( i < len && i <= MAX_NAME_IDX) c = char_to_symbol( str.charAt(i) ); 59 | 60 | if( i < MAX_NAME_IDX) { 61 | c &= 0x1f; 62 | c <<= 64-5*(i+1); 63 | } 64 | else { 65 | c &= 0x0f; 66 | } 67 | 68 | value |= c; 69 | } 70 | 71 | return value; 72 | } 73 | 74 | static public String name_to_string( long nameAsLong ) { 75 | long tmp = nameAsLong; 76 | 77 | char[] result = new char[MAX_NAME_IDX + 1]; 78 | Arrays.fill( result, ' '); 79 | 80 | for( int i = 0; i <= MAX_NAME_IDX; ++i ) { 81 | char c = CHAR_MAP.charAt( (int)(tmp & (i == 0 ? 0x0f : 0x1f)) ); 82 | result[MAX_NAME_IDX-i] = c; 83 | tmp >>= (i == 0 ? 4 : 5); 84 | } 85 | 86 | return String.valueOf( result ).replaceAll("[.]+$", ""); // remove trailing dot 87 | } 88 | 89 | public TypeName(long nameAsLong) { 90 | mValue = nameAsLong; 91 | } 92 | 93 | public TypeName(String name) { 94 | mValue = string_to_name( name); 95 | } 96 | 97 | @Override 98 | public void pack(EosType.Writer writer) { 99 | writer.putLongLE( mValue); 100 | } 101 | 102 | @Override 103 | public String toString(){ 104 | return name_to_string( mValue ); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypePermissionLevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import com.google.gson.annotations.Expose; 27 | import com.google.gson.annotations.SerializedName; 28 | 29 | 30 | /** 31 | * Created by swapnibble on 2017-09-12. 32 | */ 33 | 34 | public class TypePermissionLevel implements EosType.Packer { 35 | 36 | @Expose 37 | private TypeAccountName actor; 38 | 39 | @Expose 40 | private TypePermissionName permission; 41 | 42 | public TypePermissionLevel(String accountName, String permissionName) { 43 | actor = new TypeAccountName(accountName); 44 | permission = new TypePermissionName(permissionName); 45 | } 46 | 47 | public String getAccount(){ 48 | return actor.toString(); 49 | } 50 | 51 | public void setAccount(String accountName ){ 52 | actor = new TypeAccountName(accountName); 53 | } 54 | 55 | public String getPermission(){ 56 | return permission.toString(); 57 | } 58 | 59 | public void setPermission(String permissionName ){ 60 | permission = new TypePermissionName(permissionName); 61 | } 62 | 63 | @Override 64 | public void pack(EosType.Writer writer) { 65 | 66 | actor.pack(writer); 67 | permission.pack(writer); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypePermissionLevelWeight.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-12. 28 | */ 29 | 30 | public class TypePermissionLevelWeight implements EosType.Packer { 31 | private TypePermissionLevel mPermission; 32 | private short mWeight; 33 | 34 | /** 35 | * single active permissin 용 생성자 36 | * @param nameForActive 37 | */ 38 | TypePermissionLevelWeight(String nameForActive ) { 39 | this( nameForActive, (short)1); 40 | } 41 | 42 | TypePermissionLevelWeight(String nameForActive, short weight ) { 43 | mPermission = new TypePermissionLevel( nameForActive, "active"); 44 | mWeight = weight; 45 | } 46 | 47 | @Override 48 | public void pack(EosType.Writer writer) { 49 | 50 | mPermission.pack(writer); 51 | 52 | writer.putShortLE( mWeight); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypePermissionName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-12. 28 | */ 29 | 30 | public class TypePermissionName extends TypeName { 31 | public TypePermissionName(String name) { 32 | super(name); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypePublicKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import io.plactal.eoscommander.crypto.ec.EosPublicKey; 27 | 28 | /** 29 | * Created by swapnibble on 2018-03-20. 30 | */ 31 | 32 | public class TypePublicKey implements EosType.Packer { 33 | private static final byte PACK_VAL_CURVE_PARAM_TYPE_K1 = 0; 34 | private static final byte PACK_VAL_CURVE_PARAM_TYPE_R1 = 1; 35 | 36 | private final EosPublicKey mPubKey; 37 | 38 | public static TypePublicKey from(EosPublicKey publicKey) { 39 | return new TypePublicKey(publicKey); 40 | } 41 | 42 | public TypePublicKey( EosPublicKey publicKey ) { 43 | mPubKey = publicKey; 44 | } 45 | 46 | 47 | @Override 48 | public void pack(EosType.Writer writer) { 49 | writer.putVariableUInt( mPubKey.isCurveParamK1() ? PACK_VAL_CURVE_PARAM_TYPE_K1 : PACK_VAL_CURVE_PARAM_TYPE_R1 ); 50 | 51 | writer.putBytes( mPubKey.getBytes()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeScopeName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | /** 27 | * Created by swapnibble on 2018-04-04. 28 | */ 29 | 30 | public class TypeScopeName extends TypeName { 31 | public TypeScopeName(String name) { 32 | super(name); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeSharedLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | import com.google.gson.annotations.Expose; 27 | 28 | /** 29 | * Created by swapnibble on 2018-04-04. 30 | */ 31 | 32 | public class TypeSharedLock { 33 | @Expose 34 | private TypeAccountName account; 35 | 36 | @Expose 37 | private TypeScopeName scope; 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/remote/model/types/TypeWaitWeight.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.data.remote.model.types; 25 | 26 | /** 27 | * Created by swapnibble on 2018-05-17. 28 | */ 29 | public class TypeWaitWeight implements EosType.Packer { 30 | private int mWaitSec; // uint32_t 31 | private short mWeight; 32 | 33 | public TypeWaitWeight( long uint32WaitSec, int uint16Weight){ 34 | mWaitSec= (int)( uint32WaitSec & 0xFFFFFFFF ); 35 | mWeight = (short)( uint16Weight & 0xFFFF ); 36 | } 37 | 38 | @Override 39 | public void pack(EosType.Writer writer) { 40 | writer.putIntLE( mWaitSec ); 41 | writer.putShortLE( mWeight); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/data/util/GsonEosTypeAdapterFactory.java: -------------------------------------------------------------------------------- 1 | package io.plactal.eoscommander.data.util; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.TypeAdapter; 5 | import com.google.gson.TypeAdapterFactory; 6 | import com.google.gson.reflect.TypeToken; 7 | import com.google.gson.stream.JsonReader; 8 | import com.google.gson.stream.JsonToken; 9 | import com.google.gson.stream.JsonWriter; 10 | 11 | import java.io.IOException; 12 | import java.lang.reflect.Constructor; 13 | import java.lang.reflect.InvocationTargetException; 14 | import java.util.LinkedHashMap; 15 | import java.util.Map; 16 | 17 | import io.plactal.eoscommander.data.remote.model.types.TypeAccountName; 18 | import io.plactal.eoscommander.data.remote.model.types.TypeActionName; 19 | import io.plactal.eoscommander.data.remote.model.types.TypeAsset; 20 | import io.plactal.eoscommander.data.remote.model.types.TypeName; 21 | import io.plactal.eoscommander.data.remote.model.types.TypePermissionName; 22 | import io.plactal.eoscommander.data.remote.model.types.TypeScopeName; 23 | 24 | /** 25 | * Created by swapnibble on 2018-04-04. 26 | */ 27 | 28 | public class GsonEosTypeAdapterFactory implements TypeAdapterFactory { 29 | 30 | private Map, TypeAdapter> adapters = new LinkedHashMap<>(); 31 | 32 | { 33 | adapters.put(TypeName.class, new TypeNameAdapter<>( TypeName.class)); 34 | adapters.put(TypeAccountName.class, new TypeNameAdapter<>( TypeAccountName.class)); 35 | adapters.put(TypeActionName.class, new TypeNameAdapter<>( TypeActionName.class)); 36 | adapters.put(TypePermissionName.class, new TypeNameAdapter<>( TypePermissionName.class)); 37 | adapters.put(TypeScopeName.class, new TypeNameAdapter<>( TypeScopeName.class)); 38 | 39 | adapters.put( TypeAsset.class, new TypeNameAdapter<>(TypeAsset.class)); 40 | } 41 | 42 | @Override 43 | public TypeAdapter create(Gson gson, TypeToken typeToken) { 44 | TypeAdapter typeAdapter = null; 45 | Class currentType = Object.class; 46 | for (Class type : adapters.keySet()) { 47 | if (type.isAssignableFrom(typeToken.getRawType())) { 48 | if (currentType.isAssignableFrom(type)) { 49 | currentType = type; 50 | typeAdapter = (TypeAdapter)adapters.get(type); 51 | } 52 | } 53 | } 54 | return typeAdapter; 55 | } 56 | 57 | public static class TypeNameAdapter extends TypeAdapter { 58 | 59 | private Class clazz; 60 | 61 | public TypeNameAdapter(Class clazz){ 62 | this.clazz = clazz; 63 | } 64 | 65 | @Override 66 | public C read(JsonReader in) throws IOException { 67 | if (in.peek() == JsonToken.NULL) { 68 | in.nextNull(); 69 | return null; 70 | } 71 | 72 | try { 73 | Constructor constructor = clazz.getConstructor( String.class ); 74 | return constructor.newInstance( in.nextString()); 75 | } catch (NoSuchMethodException e) { 76 | e.printStackTrace(); 77 | } catch (IllegalAccessException e) { 78 | e.printStackTrace(); 79 | } catch (InstantiationException e) { 80 | e.printStackTrace(); 81 | } catch (InvocationTargetException e) { 82 | e.printStackTrace(); 83 | } 84 | 85 | return null; 86 | } 87 | 88 | @Override 89 | public void write(JsonWriter out, C value) throws IOException { 90 | if (value == null) { 91 | out.nullValue(); 92 | return; 93 | } 94 | 95 | out.value(value.toString()); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/util/Consts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.util; 25 | 26 | 27 | /** 28 | * Created by swapnibble on 2017-11-10. 29 | */ 30 | 31 | public final class Consts { 32 | public static final boolean DEFAULT_SKIP_SIGNING = true; 33 | 34 | public static final String DEFAULT_SERVANT_ACCOUNT = "eosio"; 35 | 36 | public static final String DEFAULT_WALLET_NAME = "default"; 37 | public static final boolean DEFAULT_SAVE_PASSWORD= true; 38 | 39 | public static final String SAMPLE_PRIV_KEY_FOR_TEST = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"; 40 | 41 | public static final String EOSIO_SYSTEM_ACCOUNT = "eosio"; 42 | public static final String EOSIO_TOKEN_CONTRACT = "eosio.token"; 43 | public static final int TX_EXPIRATION_IN_MILSEC = 30000; 44 | 45 | public static final String DEFAULT_SYMBOL_STRING = "SYS"; 46 | public static final int DEFAULT_SYMBOL_PRECISION = 4; 47 | 48 | public static final String EOS_SYMBOL_STRING = "EOS"; 49 | 50 | 51 | // constants from /libraries/include/eosio/chain/config.hpp 52 | public static final int DEFAULT_BASE_PER_TRANSACTION_NET_USAGE = 100; 53 | public static final int DEFAULT_BASE_PER_TRANSACTION_CPU_USAGE = 500; 54 | public static final int DEFAULT_BASE_PER_ACTION_CPU_USAGE = 1000; 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/util/RefValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.util; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-28. 28 | */ 29 | 30 | public class RefValue { 31 | public T data; 32 | 33 | public RefValue(){ 34 | data = null; 35 | } 36 | 37 | public RefValue(T initialVal ){ 38 | data = initialVal; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/util/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.util; 25 | 26 | 27 | public class StringUtils { 28 | public static boolean isEmpty( CharSequence data ) { 29 | return ( null == data ) || ( data.length() <= 0); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/util/rx/EoscSchedulerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.util.rx; 25 | 26 | import io.reactivex.Scheduler; 27 | import io.reactivex.android.schedulers.AndroidSchedulers; 28 | import io.reactivex.schedulers.Schedulers; 29 | 30 | /** 31 | * Created by swapnibble on 2017-08-24. 32 | */ 33 | 34 | public class EoscSchedulerProvider implements SchedulerProvider { 35 | 36 | @Override 37 | public Scheduler ui() { 38 | return AndroidSchedulers.mainThread(); 39 | } 40 | 41 | @Override 42 | public Scheduler computation() { 43 | return Schedulers.computation(); 44 | } 45 | 46 | @Override 47 | public Scheduler io() { 48 | return Schedulers.io(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/io/plactal/eoscommander/util/rx/SchedulerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package io.plactal.eoscommander.util.rx; 25 | 26 | import io.reactivex.Scheduler; 27 | 28 | /** 29 | * Created by swapnibble on 2017-08-24. 30 | */ 31 | 32 | public interface SchedulerProvider { 33 | 34 | Scheduler ui(); 35 | 36 | Scheduler computation(); 37 | 38 | Scheduler io(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/chain_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 10 | 15 | 19 | 23 | 27 |