├── eos-core ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties └── src │ ├── test │ └── kotlin │ │ └── com │ │ └── memtrip │ │ └── eos │ │ └── core │ │ ├── block │ │ └── BlockIdDetailsTest.kt │ │ ├── hex │ │ └── HexWriterTests.kt │ │ ├── crypto │ │ └── EosKeyTests.kt │ │ └── hash │ │ └── HmacTests.kt │ └── main │ └── kotlin │ └── com │ └── memtrip │ └── eos │ └── core │ ├── utils │ └── BytesWithChecksum.kt │ ├── crypto │ └── signature │ │ ├── ECSignatureResult.kt │ │ ├── KeyCurve.kt │ │ └── SecP256K1KeyCurve.kt │ ├── hex │ └── HexWriter.kt │ ├── hash │ └── RIPEMD160Digest.kt │ ├── block │ └── BlockIdDetails.kt │ └── base58 │ └── Base58Decode.kt ├── eos-http-rpc ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── test │ │ └── kotlin │ │ │ └── com │ │ │ └── memtrip │ │ │ └── eos │ │ │ └── http │ │ │ └── rpc │ │ │ ├── utils │ │ │ ├── testabi │ │ │ │ ├── TransferWriter.kt │ │ │ │ ├── TransferBody.kt │ │ │ │ └── TransferArgs.kt │ │ │ ├── testjson │ │ │ │ ├── TransferBodyJson.kt │ │ │ │ └── TransferArgsJson.kt │ │ │ └── utils.kt │ │ │ └── chain │ │ │ ├── ChainGetInfoTest.kt │ │ │ ├── ChainGetAbiTest.kt │ │ │ ├── GetBlockHeaderStateTest.kt │ │ │ ├── ChainGetBlockTest.kt │ │ │ ├── ChainGetProducerTest.kt │ │ │ ├── ChainGetCodeTest.kt │ │ │ ├── ChainGetCurrencyStatsTest.kt │ │ │ └── ChainGetCurrencyBalanceTest.kt │ └── main │ │ └── kotlin │ │ └── com │ │ └── memtrip │ │ └── eos │ │ └── http │ │ └── rpc │ │ ├── model │ │ ├── account │ │ │ ├── response │ │ │ │ ├── AccountAuthWait.kt │ │ │ │ ├── AccountAuth.kt │ │ │ │ ├── AccountAuthPermission.kt │ │ │ │ ├── RefundRequest.kt │ │ │ │ ├── AccountKey.kt │ │ │ │ ├── AccountResourceLimit.kt │ │ │ │ ├── AccountPermission.kt │ │ │ │ ├── TotalResources.kt │ │ │ │ ├── SelfDelegatedBandwidth.kt │ │ │ │ ├── AccountRequiredAuth.kt │ │ │ │ ├── VoterInfo.kt │ │ │ │ └── Account.kt │ │ │ └── request │ │ │ │ └── AccountName.kt │ │ ├── block │ │ │ ├── request │ │ │ │ └── BlockNumOrId.kt │ │ │ └── response │ │ │ │ ├── Region.kt │ │ │ │ ├── BlockHeaderProducer.kt │ │ │ │ ├── BlockHeaderRootMerkle.kt │ │ │ │ ├── BlockHeaderSchedule.kt │ │ │ │ ├── CycleSummaryTransaction.kt │ │ │ │ ├── CycleSummary.kt │ │ │ │ ├── BlockHeaderStateHeader.kt │ │ │ │ └── BlockHeaderState.kt │ │ ├── history │ │ │ ├── request │ │ │ │ ├── GetTransaction.kt │ │ │ │ ├── GetKeyAccounts.kt │ │ │ │ ├── GetControlledAccounts.kt │ │ │ │ └── GetActions.kt │ │ │ └── response │ │ │ │ ├── Accounts.kt │ │ │ │ ├── ExecutedTransactionParent.kt │ │ │ │ ├── HistoricAccountActionParent.kt │ │ │ │ ├── ExecutedTransactionReceipt.kt │ │ │ │ ├── HistoricAccountAction.kt │ │ │ │ ├── HistoricTransaction.kt │ │ │ │ └── ExecutedTransaction.kt │ │ ├── signing │ │ │ ├── RequiredKeys.kt │ │ │ ├── PushTransaction.kt │ │ │ └── GetRequiredKeysBody.kt │ │ ├── contract │ │ │ ├── response │ │ │ │ ├── AbiField.kt │ │ │ │ ├── AbiType.kt │ │ │ │ ├── AbiForAccount.kt │ │ │ │ ├── ContractTableRows.kt │ │ │ │ ├── AbiAction.kt │ │ │ │ ├── AbiStruct.kt │ │ │ │ ├── RawCodeForAccount.kt │ │ │ │ ├── BinaryHex.kt │ │ │ │ ├── CodeForAccount.kt │ │ │ │ ├── AbiTable.kt │ │ │ │ └── AbiContract.kt │ │ │ └── request │ │ │ │ ├── GetCurrencyStats.kt │ │ │ │ ├── AbiBinToJson.kt │ │ │ │ ├── GetCodeByAccountName.kt │ │ │ │ ├── GetCurrencyBalance.kt │ │ │ │ └── GetTableRows.kt │ │ ├── transaction │ │ │ ├── TransactionAuthorization.kt │ │ │ ├── response │ │ │ │ ├── TransactionCommitted.kt │ │ │ │ ├── TransactionParentReceipt.kt │ │ │ │ ├── TransactionActionTrace.kt │ │ │ │ ├── TransactionReceipt.kt │ │ │ │ ├── TransactionAct.kt │ │ │ │ └── TransactionProcessed.kt │ │ │ ├── Action.kt │ │ │ └── Transaction.kt │ │ ├── producer │ │ │ ├── request │ │ │ │ └── GetProducers.kt │ │ │ └── response │ │ │ │ ├── ProducerList.kt │ │ │ │ └── Producer.kt │ │ └── info │ │ │ └── Info.kt │ │ ├── utils │ │ └── DateAdapter.kt │ │ └── Api.kt └── proguard-rules.pro ├── eos-abi-writer ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .editorconfig └── src │ ├── test │ └── kotlin │ │ └── com │ │ └── memtrip │ │ └── eos │ │ └── abi │ │ └── writer │ │ ├── BlockNumTests.kt │ │ ├── BlockPrefixTests.kt │ │ ├── TimestampTests.kt │ │ ├── ChainIdTests.kt │ │ ├── PublicKeyWriterTests.kt │ │ ├── HexCollectionTests.kt │ │ ├── ShortTests.kt │ │ ├── FloatTests.kt │ │ ├── LongTests.kt │ │ └── AccountNameTests.kt │ └── main │ └── kotlin │ └── com │ └── memtrip │ └── eos │ └── abi │ └── writer │ ├── compression │ ├── CompressionType.kt │ ├── Compression.kt │ ├── NoCompression.kt │ └── CompressionFactory.kt │ ├── Squishable.kt │ ├── bytewriter │ ├── AccountNameWriter.kt │ ├── ChainIdWriter.kt │ ├── PublicKeyWriter.kt │ ├── CurrencySymbolWriter.kt │ └── AssetWriter.kt │ └── ByteWriter.kt ├── eos-chain-actions ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ └── kotlin │ │ │ └── com │ │ │ └── memtrip │ │ │ └── eos │ │ │ └── chain │ │ │ └── actions │ │ │ ├── query │ │ │ ├── bandwidth │ │ │ │ ├── BandwidthJson.kt │ │ │ │ └── GetDelegatedBandwidth.kt │ │ │ ├── proxy │ │ │ │ └── ProxyJson.kt │ │ │ ├── producer │ │ │ │ ├── BlockProducer.kt │ │ │ │ └── bpjson │ │ │ │ │ ├── BpBranding.kt │ │ │ │ │ ├── BpParent.kt │ │ │ │ │ ├── BpLocation.kt │ │ │ │ │ ├── BpNode.kt │ │ │ │ │ ├── BpSocial.kt │ │ │ │ │ └── BpOrg.kt │ │ │ ├── accountname │ │ │ │ └── CheckAccountNameExists.kt │ │ │ └── ramprice │ │ │ │ └── GetRamPrice.kt │ │ │ ├── transaction │ │ │ ├── account │ │ │ │ └── actions │ │ │ │ │ ├── refund │ │ │ │ │ ├── RefundBody.kt │ │ │ │ │ └── RefundArgs.kt │ │ │ │ │ ├── buyram │ │ │ │ │ ├── BuyRamBody.kt │ │ │ │ │ ├── BuyRamBytesBody.kt │ │ │ │ │ ├── BuyRamArgs.kt │ │ │ │ │ └── BuyRamBytesArgs.kt │ │ │ │ │ ├── sellram │ │ │ │ │ ├── SellRamBody.kt │ │ │ │ │ └── SellRamArgs.kt │ │ │ │ │ ├── newaccount │ │ │ │ │ ├── NewAccountBody.kt │ │ │ │ │ ├── AccountKeyAbi.kt │ │ │ │ │ ├── NewAccountArgs.kt │ │ │ │ │ └── AccountRequiredAuthAbi.kt │ │ │ │ │ ├── delegatebw │ │ │ │ │ ├── DelegateBandwidthBody.kt │ │ │ │ │ └── DelegateBandwidthArgs.kt │ │ │ │ │ └── undelegatebw │ │ │ │ │ ├── UnDelegateBandwidthBody.kt │ │ │ │ │ └── UnDelegateBandwidthArgs.kt │ │ │ ├── TransactionWriter.kt │ │ │ ├── TransactionContext.kt │ │ │ ├── vote │ │ │ │ └── actions │ │ │ │ │ ├── VoteBody.kt │ │ │ │ │ └── VoteArgs.kt │ │ │ ├── transfer │ │ │ │ └── actions │ │ │ │ │ ├── TransferBody.kt │ │ │ │ │ └── TransferArgs.kt │ │ │ └── abi │ │ │ │ ├── TransactionAuthorizationAbi.kt │ │ │ │ ├── SignedTransactionAbi.kt │ │ │ │ └── ActionAbi.kt │ │ │ └── ChainResponse.kt │ └── test │ │ └── kotlin │ │ └── com │ │ └── memtrip │ │ └── eos │ │ └── chain │ │ └── actions │ │ ├── utils.kt │ │ ├── abihex │ │ ├── RefundArgsTest.kt │ │ ├── SellRamArgsTest.kt │ │ ├── BuyRamArgsTest.kt │ │ ├── BuyRamBytesArgsTest.kt │ │ ├── UnDelegateBandwidthArgsTest.kt │ │ └── DelegateBandwidthArgsTest.kt │ │ └── query │ │ └── CalculateRamPriceTest.kt ├── README.md └── proguard-rules.pro ├── eos-abi-writer-preprocessor └── src │ ├── test │ └── java │ │ └── com │ │ └── memtrip │ │ └── eos │ │ └── abi │ │ └── writer │ │ └── preprocessor │ │ ├── model │ │ ├── TestWriter.java │ │ ├── Runner.java │ │ ├── PackedTransactionAuthorization.java │ │ └── PackedAction.java │ │ └── template │ │ ├── PackedTransactionAuthorizationSquishable.java │ │ └── PackedActionSquishable.java │ └── main │ └── java │ └── com │ └── memtrip │ └── eos │ └── abi │ └── writer │ └── preprocessor │ ├── gen │ ├── DataMap.java │ ├── RootMap.java │ ├── Gen.java │ └── RootGen.java │ └── model │ ├── CompressType.java │ ├── AbiWriterModel.java │ └── AbiModel.java ├── .gitignore ├── .travis.yml └── README.md /eos-core/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'eos-core' 2 | 3 | -------------------------------------------------------------------------------- /eos-http-rpc/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'eos-http-rpc' 2 | 3 | -------------------------------------------------------------------------------- /eos-abi-writer/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'eos-abi-writer' 2 | 3 | -------------------------------------------------------------------------------- /eos-chain-actions/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'eos-chain-actions' 2 | -------------------------------------------------------------------------------- /eos-core/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memtrip/eos-jvm/HEAD/eos-core/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /eos-http-rpc/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memtrip/eos-jvm/HEAD/eos-http-rpc/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /eos-abi-writer/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memtrip/eos-jvm/HEAD/eos-abi-writer/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /eos-chain-actions/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/memtrip/eos-jvm/HEAD/eos-chain-actions/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/utils/testabi/TransferWriter.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.utils.testabi 2 | 3 | import com.memtrip.eos.abi.writer.AbiWriter 4 | 5 | @AbiWriter 6 | interface TransferWriter -------------------------------------------------------------------------------- /eos-http-rpc/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /eos-chain-actions/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/test/java/com/memtrip/eos/abi/writer/preprocessor/model/TestWriter.java: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer.preprocessor.model; 2 | 3 | import com.memtrip.eos.abi.writer.AbiWriter; 4 | 5 | @AbiWriter 6 | public interface TestWriter { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/bandwidth/BandwidthJson.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.query.bandwidth 2 | 3 | data class BandwidthJson( 4 | val from: String, 5 | val to: String, 6 | val net_weight: String, 7 | val cpu_weight: String 8 | ) -------------------------------------------------------------------------------- /eos-core/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Sep 19 20:35:55 BST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip 7 | -------------------------------------------------------------------------------- /eos-abi-writer/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 13 13:26:46 BST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip 7 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/AccountAuthWait.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.model.account.response 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | @JsonClass(generateAdapter = true) 6 | data class AccountAuthWait( 7 | val wait_sec: Long, 8 | val weight: Int 9 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/AccountAuth.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.model.account.response 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | @JsonClass(generateAdapter = true) 6 | data class AccountAuth( 7 | val permission: AccountAuthPermission, 8 | val weight: Int 9 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/AccountAuthPermission.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.model.account.response 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | @JsonClass(generateAdapter = true) 6 | data class AccountAuthPermission( 7 | val actor: String, 8 | val permission: String 9 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/utils/testjson/TransferBodyJson.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.utils.testjson 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | @JsonClass(generateAdapter = true) 6 | data class TransferBodyJson( 7 | val code: String, 8 | val action: String, 9 | val args: TransferArgsJson 10 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/utils/testjson/TransferArgsJson.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.utils.testjson 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | @JsonClass(generateAdapter = true) 6 | data class TransferArgsJson( 7 | val from: String, 8 | val to: String, 9 | val quantity: String, 10 | val memo: String 11 | ) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/test/java/com/memtrip/eos/abi/writer/preprocessor/model/Runner.java: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer.preprocessor.model; 2 | 3 | import org.junit.Test; 4 | 5 | public class Runner { 6 | 7 | @Test 8 | public void run() { 9 | // used to trigger the annotation processor from remote debugging (mvnDebug test) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/utils/testabi/TransferBody.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.utils.testabi 2 | 3 | import com.memtrip.eos.abi.writer.Abi 4 | import com.memtrip.eos.abi.writer.ChildCompress 5 | 6 | @Abi 7 | data class TransferBody( 8 | val args: TransferArgs 9 | ) { 10 | 11 | val getArgs: TransferArgs 12 | @ChildCompress get() = args 13 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/RefundRequest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.model.account.response 2 | 3 | import com.squareup.moshi.JsonClass 4 | import java.util.Date 5 | 6 | @JsonClass(generateAdapter = true) 7 | data class RefundRequest( 8 | val owner: String, 9 | val request_time: Date, 10 | val net_amount: String, 11 | val cpu_amount: String 12 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/refund/RefundBody.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.transaction.account.actions.refund 2 | 3 | import com.memtrip.eos.abi.writer.Abi 4 | import com.memtrip.eos.abi.writer.ChildCompress 5 | 6 | @Abi 7 | data class RefundBody( 8 | val args: RefundArgs 9 | ) { 10 | 11 | val getArgs: RefundArgs 12 | @ChildCompress get() = args 13 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/refund/RefundArgs.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.transaction.account.actions.refund 2 | 3 | import com.memtrip.eos.abi.writer.Abi 4 | import com.memtrip.eos.abi.writer.AccountNameCompress 5 | 6 | @Abi 7 | data class RefundArgs( 8 | val owner: String 9 | ) { 10 | 11 | val getOwner: String 12 | @AccountNameCompress get() = owner 13 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/proxy/ProxyJson.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.query.proxy 2 | 3 | data class ProxyJson( 4 | val owner: String, 5 | val name: String, 6 | val website: String, 7 | val slogan: String, 8 | val philosophy: String, 9 | val background: String, 10 | val logo_256: String, 11 | val telegram: String, 12 | val steemit: String, 13 | val twitter: String, 14 | val wechat: String 15 | ) -------------------------------------------------------------------------------- /eos-abi-writer/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{kt,kts}] 2 | # possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely) 3 | indent_size=4 4 | # possible values: number (e.g. 2), "unset" 5 | continuation_indent_size=4 6 | # true (recommended) / false 7 | insert_final_newline=unset 8 | # possible values: number (e.g. 120) (package name, imports & comments are ignored), "off" 9 | # it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide) 10 | max_line_length=off -------------------------------------------------------------------------------- /eos-core/src/test/kotlin/com/memtrip/eos/core/block/BlockIdDetailsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.core.block 2 | 3 | import org.junit.Assert.assertEquals 4 | import org.junit.Test 5 | 6 | class BlockIdDetailsTest { 7 | 8 | @Test 9 | fun blockIdDetails() { 10 | val blockIdDetails = BlockIdDetails("0000000ac7619ca01df1e0b4964921020e772ceb7343ec51f65537cdbce192d3") 11 | assertEquals(blockIdDetails.blockNum, 10) 12 | assertEquals(blockIdDetails.blockPrefix, 3034640669L) 13 | } 14 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/utils/utils.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.utils 2 | 3 | import java.util.Date 4 | import java.util.Calendar 5 | 6 | class Config { 7 | companion object { 8 | const val CHAIN_API_BASE_URL = "https://api.jungle.alohaeos.com:443/" 9 | const val MAINNET_API_BASE_URL = "https://eos.greymass.com/" 10 | } 11 | } 12 | 13 | fun transactionDefaultExpiry(): Date = with(Calendar.getInstance()) { 14 | set(Calendar.MINUTE, get(Calendar.MINUTE) + 2) 15 | this 16 | }.time -------------------------------------------------------------------------------- /eos-core/src/test/kotlin/com/memtrip/eos/core/hex/HexWriterTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.core.hex 2 | 3 | import org.junit.Assert.assertEquals 4 | 5 | import org.junit.Test 6 | 7 | class HexWriterTests { 8 | 9 | @Test 10 | fun bytesToHex() { 11 | 12 | val hexWriter: HexWriter = DefaultHexWriter() 13 | 14 | val testString = "These are some bytes that should be written to a hexadecimal string representation." 15 | val testAsHex = hexWriter.bytesToHex(testString.toByteArray()) 16 | val testAsBytes = hexWriter.hexToBytes(testAsHex) 17 | 18 | assertEquals(testString, String(testAsBytes)) 19 | } 20 | } -------------------------------------------------------------------------------- /eos-chain-actions/README.md: -------------------------------------------------------------------------------- 1 | # eos-chain-actions 2 | 3 | An EOS SDK for pushing actions to the EOS system contracts. This high level abstraction composes the other eos-jvm modules to seamlessly handle transaction signing, byte writing and api requests. 4 | 5 | ## Gradle 6 | 7 | ``` 8 | implementation ("com.memtrip.eos-jvm:eos-chain-actions:1.0.0-beta04") { 9 | exclude group: "com.lambdaworks", module: "scrypt" 10 | } 11 | ``` 12 | 13 | ## Supported actions 14 | 15 | - CreateAccount 16 | - BuyRam 17 | - SellRam 18 | - DelegateBandwidth 19 | - UndelegateBandwidth 20 | - Transfer 21 | - Vote 22 | - Refund 23 | 24 | ## Examples 25 | 26 | See src/test for a full suite of integration tests. 27 | -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/BlockNumTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | import org.junit.Assert 7 | import org.junit.Test 8 | 9 | class BlockNumTests { 10 | 11 | private val hexWriter: HexWriter = DefaultHexWriter() 12 | 13 | @Test 14 | fun testBlockNum() { 15 | 16 | // given 17 | val byteWriter = DefaultByteWriter(500) 18 | 19 | // when 20 | byteWriter.putBlockNum(12818018) 21 | 22 | // then 23 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 24 | Assert.assertEquals(hex, "6296") 25 | } 26 | } -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/BlockPrefixTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | import org.junit.Assert 7 | import org.junit.Test 8 | 9 | class BlockPrefixTests { 10 | 11 | private val hexWriter: HexWriter = DefaultHexWriter() 12 | 13 | @Test 14 | fun testBlockPrefix() { 15 | 16 | // given 17 | val byteWriter = DefaultByteWriter(500) 18 | 19 | // when 20 | byteWriter.putBlockPrefix(1992007324) 21 | 22 | // then 23 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 24 | Assert.assertEquals(hex, "9c9ebb76") 25 | } 26 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | abi-binary-compressor/.idea 3 | abi-binary-compressor/.gradle 4 | abi-binary-compressor/build 5 | *.iml 6 | abi-binary-preprocessor-kotlin/.idea 7 | abi-binary-preprocessor/.idea 8 | abi-binary-preprocessor/target 9 | abi-binary-compressor/out 10 | eos-core/.idea 11 | eos-core/.gradle 12 | gradlew.bat 13 | eos-core/build 14 | eos-core/out 15 | eos-abi-writer/out 16 | eos-abi-writer/.idea 17 | eos-abi-writer/build 18 | eos-abi-writer/.gradle 19 | eos-abi-writer-preprocessor/target 20 | eos-abi-writer-preprocessor/.idea 21 | eos-http-rpc/.gradle 22 | eos-http-rpc/.idea 23 | eos-http-rpc/build 24 | dev_env_setup/session 25 | eos-http-rpc/out 26 | eos-chain-actions/.gradle 27 | eos-chain-actions/.idea 28 | eos-chain-actions/build 29 | eos-chain-actions/out 30 | eos-dev-env/session 31 | -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/TimestampTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | import org.junit.Assert.assertEquals 7 | import org.junit.Test 8 | 9 | class TimestampTests { 10 | 11 | private val hexWriter: HexWriter = DefaultHexWriter() 12 | 13 | @Test 14 | fun testTimestamp() { 15 | 16 | // given 17 | val byteWriter = DefaultByteWriter(500) 18 | 19 | // when 20 | byteWriter.putTimestampMs(1549648892253) 21 | 22 | // then 23 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 24 | assertEquals(hex, "fcc35d5c") 25 | } 26 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/utils/testabi/TransferArgs.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.utils.testabi 2 | 3 | import com.memtrip.eos.abi.writer.Abi 4 | import com.memtrip.eos.abi.writer.AccountNameCompress 5 | import com.memtrip.eos.abi.writer.AssetCompress 6 | import com.memtrip.eos.abi.writer.StringCompress 7 | 8 | @Abi 9 | data class TransferArgs( 10 | val from: String, 11 | val to: String, 12 | val quantity: String, 13 | val memo: String 14 | ) { 15 | 16 | val getFrom: String 17 | @AccountNameCompress get() = from 18 | 19 | val getTo: String 20 | @AccountNameCompress get() = to 21 | 22 | val getQuantity: String 23 | @AssetCompress get() = quantity 24 | 25 | val getMemo: String 26 | @StringCompress get() = memo 27 | } -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/test/java/com/memtrip/eos/abi/writer/preprocessor/model/PackedTransactionAuthorization.java: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer.preprocessor.model; 2 | 3 | import com.memtrip.eos.abi.writer.Abi; 4 | import com.memtrip.eos.abi.writer.AccountNameCompress; 5 | 6 | @Abi 7 | public class PackedTransactionAuthorization { 8 | 9 | private final String actor; 10 | private final String permission; 11 | 12 | @AccountNameCompress 13 | public String actor() { 14 | return actor; 15 | } 16 | 17 | @AccountNameCompress 18 | public String permission() { 19 | return permission; 20 | } 21 | 22 | public PackedTransactionAuthorization(String actor, String permission) { 23 | this.actor = actor; 24 | this.permission = permission; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/utils/BytesWithChecksum.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.utils 17 | 18 | class BytesWithChecksum(val bytes: ByteArray, val checkSum: Long) -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/compression/CompressionType.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.compression 17 | 18 | enum class CompressionType { NONE, ZLIB } -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/Squishable.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer 17 | 18 | interface Squishable { 19 | fun squish(obj: T, writer: ByteWriter) 20 | } -------------------------------------------------------------------------------- /eos-http-rpc/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 | -------------------------------------------------------------------------------- /eos-chain-actions/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 | -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/utils.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions 2 | 3 | import java.util.Date 4 | import java.util.Random 5 | import java.util.Calendar 6 | import kotlin.streams.asSequence 7 | 8 | fun generateUniqueAccountName(): String { 9 | val source = "abcdefghijklmnopqrstuvwxyz" 10 | return Random().ints(12, 0, source.length) 11 | .asSequence() 12 | .map(source::get) 13 | .joinToString("") 14 | } 15 | 16 | class Config { 17 | companion object { 18 | const val CHAIN_API_BASE_URL = "https://api.jungle.alohaeos.com:443/" 19 | const val MAINNET_API_BASE_URL = "https://eos.greymass.com/" 20 | } 21 | } 22 | 23 | fun transactionDefaultExpiry(): Date = with(Calendar.getInstance()) { 24 | set(Calendar.MINUTE, get(Calendar.MINUTE) + 2) 25 | this 26 | }.time -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/ChainIdTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | 7 | import org.junit.Assert.assertEquals 8 | import org.junit.Test 9 | 10 | class ChainIdTests { 11 | 12 | private val hexWriter: HexWriter = DefaultHexWriter() 13 | 14 | @Test 15 | fun testChainId() { 16 | 17 | // given 18 | val byteWriter = DefaultByteWriter(500) 19 | 20 | // when 21 | byteWriter.putChainId("aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906") 22 | 23 | // then 24 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 25 | assertEquals(hex, "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906") 26 | } 27 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/TransactionWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction 17 | 18 | import com.memtrip.eos.abi.writer.AbiWriter 19 | 20 | @AbiWriter 21 | interface TransactionWriter -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/main/java/com/memtrip/eos/abi/writer/preprocessor/gen/DataMap.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.preprocessor.gen; 17 | 18 | import java.util.Map; 19 | 20 | public interface DataMap { 21 | Map map(); 22 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/request/AccountName.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AccountName(val account_name: String) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/request/BlockNumOrId.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BlockNumOrId(val block_num_or_id: String) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/request/GetTransaction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetTransaction( 22 | val id: String 23 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/signing/RequiredKeys.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.signing 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class RequiredKeys( 22 | val required_keys: List 23 | ) -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/compression/Compression.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.compression 17 | 18 | interface Compression { 19 | 20 | fun compress(uncompressedBytes: ByteArray): ByteArray 21 | 22 | fun decompress(compressedBytes: ByteArray): ByteArray 23 | } -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/crypto/signature/ECSignatureResult.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.crypto.signature 17 | 18 | import org.bitcoinj.core.ECKey 19 | 20 | data class ECSignatureResult internal constructor( 21 | val signature: ECKey.ECDSASignature, 22 | val recId: Int 23 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/request/GetKeyAccounts.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetKeyAccounts( 22 | val public_key: String 23 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/response/Accounts.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class Accounts( 22 | val account_names: List 23 | ) -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/PublicKeyWriterTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.crypto.EosPublicKey 5 | import com.memtrip.eos.core.hex.DefaultHexWriter 6 | import com.memtrip.eos.core.hex.HexWriter 7 | import org.junit.Assert.assertEquals 8 | import org.junit.Test 9 | 10 | class PublicKeyWriterTests { 11 | 12 | private val hexWriter: HexWriter = DefaultHexWriter() 13 | 14 | @Test 15 | fun testPublicKey() { 16 | 17 | // given 18 | val byteWriter = DefaultByteWriter(500) 19 | 20 | // when 21 | byteWriter.putPublicKey(EosPublicKey("EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV")) 22 | 23 | // then 24 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 25 | assertEquals(hex, "0002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf") 26 | } 27 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/AccountKey.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AccountKey( 22 | val key: String, 23 | val weight: Short 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/AbiField.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiField( 22 | val name: String, 23 | val type: String 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/AbiType.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiType( 22 | val new_type_name: String, 23 | val type: String 24 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/producer/BlockProducer.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.producer 17 | 18 | import com.memtrip.eos.chain.actions.query.producer.bpjson.BpParent 19 | 20 | data class BlockProducer( 21 | val bpJson: BpParent, 22 | val apiEndpoint: String 23 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/request/GetControlledAccounts.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetControlledAccounts( 22 | val controlling_account: String 23 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/Region.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class Region( 22 | val region: Int, 23 | val cycles_summary: List 24 | ) 25 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/request/GetCurrencyStats.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetCurrencyStats( 22 | val code: String, 23 | val symbol: String 24 | ) -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/hex/HexWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.hex 17 | 18 | interface HexWriter { 19 | 20 | fun bytesToHex(bytes: ByteArray): String 21 | 22 | fun bytesToHex(bytes: ByteArray, offset: Int, length: Int, separator: String?): String 23 | 24 | fun hexToBytes(hex: String): ByteArray 25 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/AbiForAccount.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiForAccount( 22 | val account_name: String, 23 | val abi: AbiContract 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/TransactionAuthorization.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class TransactionAuthorization( 22 | val actor: String, 23 | val permission: String 24 | ) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/test/java/com/memtrip/eos/abi/writer/preprocessor/template/PackedTransactionAuthorizationSquishable.java: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer.preprocessor.template; 2 | 3 | import com.memtrip.eos.abi.writer.ByteWriter; 4 | import com.memtrip.eos.abi.writer.Squishable; 5 | import com.memtrip.eos.abi.writer.preprocessor.model.PackedTransactionAuthorization; 6 | 7 | public class PackedTransactionAuthorizationSquishable implements Squishable { 8 | 9 | private final AbiBinaryGen abiBinaryGen; 10 | 11 | PackedTransactionAuthorizationSquishable(AbiBinaryGen abiBinaryGen) { 12 | this.abiBinaryGen = abiBinaryGen; 13 | } 14 | 15 | @Override 16 | public void squish(PackedTransactionAuthorization packedTransactionAuthorization, ByteWriter byteWriter) { 17 | byteWriter.putAccountName(packedTransactionAuthorization.actor()); 18 | byteWriter.putName(packedTransactionAuthorization.permission()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/BlockHeaderProducer.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BlockHeaderProducer( 22 | val producer_name: String, 23 | val block_signing_key: String 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/BlockHeaderRootMerkle.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BlockHeaderRootMerkle( 22 | val _active_nodes: List, 23 | val _node_count: Int 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/request/AbiBinToJson.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiBinToJson( 22 | val code: String, 23 | val action: String, 24 | val binargs: String 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/ContractTableRows.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class ContractTableRows( 22 | val rows: List>, 23 | val more: Boolean 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/producer/request/GetProducers.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.producer.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetProducers( 22 | val json: Boolean, 23 | val lower_bound: String, 24 | val limit: Int 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/BlockHeaderSchedule.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BlockHeaderSchedule( 22 | val version: Int, 23 | val producers: List 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/AbiAction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiAction( 22 | val name: String, 23 | val type: String, 24 | val ricardian_contract: String 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/request/GetCodeByAccountName.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetCodeByAccountName( 22 | val account_name: String, 23 | val code_as_wasm: Boolean 24 | ) 25 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/AbiStruct.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiStruct( 22 | val name: String, 23 | val base: String, 24 | val fields: List 25 | ) 26 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/request/GetActions.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetActions( 22 | val account_name: String, 23 | val pos: Long? = null, 24 | val offset: Long? = null 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/AccountResourceLimit.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AccountResourceLimit( 22 | val used: Long, 23 | val available: Long, 24 | val max: Long 25 | ) 26 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/RawCodeForAccount.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class RawCodeForAccount( 22 | val account_name: String, 23 | val wasm: String, 24 | val abi: String 25 | ) -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/HexCollectionTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | import org.junit.Assert.assertEquals 7 | import org.junit.Test 8 | 9 | class HexCollectionTests { 10 | 11 | private val hexWriter: HexWriter = DefaultHexWriter() 12 | 13 | @Test 14 | fun testHexCollection() { 15 | 16 | // given 17 | val byteWriter = DefaultByteWriter(500) 18 | 19 | // when 20 | byteWriter.putHexCollection(listOf( 21 | "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906", 22 | "027a395bebe608bda318c38e9ff005fa48a77c83f39c07c55734da416e67e609")) 23 | 24 | // then 25 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 26 | assertEquals(hex, "e9d8fece02c013d7299ba233124832858d96c599b490add7d672bd05b42b7571") 27 | } 28 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/request/GetCurrencyBalance.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetCurrencyBalance( 22 | val code: String, 23 | val account: String, 24 | val symbol: String? = null 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/response/TransactionCommitted.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class TransactionCommitted( 22 | val transaction_id: String, 23 | val processed: TransactionProcessed 24 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/producer/bpjson/BpBranding.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.producer.bpjson 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BpBranding( 22 | val logo_256: String?, 23 | val logo_1024: String?, 24 | val logo_svg: String? 25 | ) 26 | -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/producer/bpjson/BpParent.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.producer.bpjson 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BpParent( 22 | val producer_account_name: String, 23 | val org: BpOrg, 24 | val nodes: List 25 | ) -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/compression/NoCompression.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.compression 17 | 18 | internal class NoCompression : Compression { 19 | 20 | override fun compress(uncompressedBytes: ByteArray): ByteArray = uncompressedBytes 21 | 22 | override fun decompress(compressedBytes: ByteArray): ByteArray = compressedBytes 23 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/BinaryHex.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BinaryHex( 22 | val binargs: String, 23 | val required_scope: List?, 24 | val required_auth: List? 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/response/ExecutedTransactionParent.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class ExecutedTransactionParent( 22 | val receipt: ExecutedTransactionReceipt, 23 | val trx: ExecutedTransaction 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/producer/response/ProducerList.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.producer.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class ProducerList( 22 | val rows: List, 23 | val total_producer_vote_weight: String, 24 | val more: String 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/AccountPermission.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AccountPermission( 22 | val perm_name: String, 23 | val parent: String, 24 | val required_auth: AccountRequiredAuth 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/response/HistoricAccountActionParent.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class HistoricAccountActionParent( 22 | val actions: List, 23 | val last_irreversible_block: Int 24 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/Action.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class Action( 22 | val account: String, 23 | val name: String, 24 | val authorization: List, 25 | val data: String? 26 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/producer/bpjson/BpLocation.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.producer.bpjson 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BpLocation( 22 | val name: String, 23 | val country: String, 24 | val latitude: Double, 25 | val longitude: Double 26 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/TotalResources.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class TotalResources( 22 | val owner: String, 23 | val net_weight: String, 24 | val cpu_weight: String, 25 | val ram_bytes: Long 26 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/response/TransactionParentReceipt.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class TransactionParentReceipt( 22 | val status: String, 23 | val cpu_usage_us: Int, 24 | val net_usage_words: Int 25 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/TransactionContext.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction 17 | 18 | import com.memtrip.eos.core.crypto.EosPrivateKey 19 | import java.util.Date 20 | 21 | data class TransactionContext( 22 | val authorizingAccountName: String, 23 | val authorizingPrivateKey: EosPrivateKey, 24 | val expirationDate: Date 25 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/CycleSummaryTransaction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class CycleSummaryTransaction( 22 | val id: String, 23 | val status: String, 24 | val kcpu_usage: Int, 25 | val net_usage_words: Int 26 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/CodeForAccount.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class CodeForAccount( 22 | val account_name: String, 23 | val code_hash: String, 24 | val wast: String, 25 | val wasm: String 26 | ) 27 | -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/compression/CompressionFactory.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.compression 17 | 18 | class CompressionFactory(private val compressionType: CompressionType) { 19 | 20 | fun create(): Compression = when (compressionType) { 21 | CompressionType.NONE -> NoCompression() 22 | CompressionType.ZLIB -> ZLIBCompression() 23 | } 24 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/SelfDelegatedBandwidth.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class SelfDelegatedBandwidth( 22 | val from: String, 23 | val to: String, 24 | val net_weight: String, 25 | val cpu_weight: String 26 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/signing/PushTransaction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.signing 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class PushTransaction( 22 | val signatures: List, 23 | val compression: String, 24 | val packed_context_free_data: String, 25 | val packed_trx: String 26 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/vote/actions/VoteBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.vote.actions 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class VoteBody( 23 | val args: VoteArgs 24 | ) { 25 | 26 | val getArgs: VoteArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/signing/GetRequiredKeysBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.signing 17 | 18 | import com.memtrip.eos.http.rpc.model.transaction.Transaction 19 | 20 | import com.squareup.moshi.JsonClass 21 | 22 | @JsonClass(generateAdapter = true) 23 | data class GetRequiredKeysBody( 24 | val transaction: Transaction, 25 | val available_keys: List 26 | ) -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/crypto/signature/KeyCurve.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.crypto.signature 17 | 18 | import org.spongycastle.math.ec.ECCurve 19 | import org.spongycastle.math.ec.ECPoint 20 | import java.math.BigInteger 21 | 22 | interface KeyCurve { 23 | 24 | fun curve(): T 25 | 26 | fun G(): ECPoint 27 | 28 | fun n(): BigInteger 29 | 30 | fun h(): BigInteger 31 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/AbiTable.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiTable( 22 | val name: String, 23 | val index_type: String, 24 | val key_names: List, 25 | val key_types: List, 26 | val type: String 27 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/response/ExecutedTransactionReceipt.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class ExecutedTransactionReceipt( 22 | val status: String, 23 | val cpu_usage_us: Int, 24 | val net_usage_words: Int, 25 | val trx: List 26 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/AccountRequiredAuth.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AccountRequiredAuth( 22 | val threshold: Int, 23 | val keys: List, 24 | val accounts: List, 25 | val waits: List 26 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/CycleSummary.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class CycleSummary( 22 | val read_locks: List, /* TODO: clarify */ 23 | val write_locks: List, /* TODO: clarify */ 24 | val transactions: List 25 | ) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/test/java/com/memtrip/eos/abi/writer/preprocessor/template/PackedActionSquishable.java: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer.preprocessor.template; 2 | 3 | import com.memtrip.eos.abi.writer.ByteWriter; 4 | import com.memtrip.eos.abi.writer.Squishable; 5 | import com.memtrip.eos.abi.writer.preprocessor.model.PackedAction; 6 | 7 | public class PackedActionSquishable implements Squishable { 8 | 9 | private final AbiBinaryGen abiBinaryGen; 10 | 11 | PackedActionSquishable(AbiBinaryGen abiBinaryGen) { 12 | this.abiBinaryGen = abiBinaryGen; 13 | } 14 | 15 | @Override 16 | public void squish(PackedAction packedAction, ByteWriter byteWriter) { 17 | byteWriter.putAccountName(packedAction.account()); 18 | byteWriter.putName(packedAction.name()); 19 | byteWriter.putAccountNameCollection(packedAction.producers()); 20 | 21 | abiBinaryGen.compressCollectionPackedTransactionAuthorization(packedAction.authorization(), byteWriter); 22 | 23 | byteWriter.putData(packedAction.data()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/producer/bpjson/BpNode.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.producer.bpjson 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BpNode( 22 | val location: BpLocation, 23 | val node_type: String, 24 | val api_endpoint: String?, 25 | val ssl_endpoint: String?, 26 | val p2p_endpoint: String? 27 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/transfer/actions/TransferBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.transfer.actions 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class TransferBody( 23 | val args: TransferArgs 24 | ) { 25 | 26 | val getArgs: TransferArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/buyram/BuyRamBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.buyram 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class BuyRamBody( 23 | val args: BuyRamArgs 24 | ) { 25 | 26 | val getArgs: BuyRamArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/sellram/SellRamBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.sellram 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class SellRamBody( 23 | val args: SellRamArgs 24 | ) { 25 | 26 | val getArgs: SellRamArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/response/TransactionActionTrace.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class TransactionActionTrace( 22 | val receipt: TransactionReceipt, 23 | val act: TransactionAct, 24 | val elapsed: Int, 25 | val console: String, 26 | val trx_id: String 27 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/buyram/BuyRamBytesBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.buyram 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class BuyRamBytesBody( 23 | val args: BuyRamBytesArgs 24 | ) { 25 | 26 | val getArgs: BuyRamBytesArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/newaccount/NewAccountBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.newaccount 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class NewAccountBody( 23 | val args: NewAccountArgs 24 | ) { 25 | 26 | val getArgs: NewAccountArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/ShortTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | import org.junit.Assert 7 | import org.junit.Test 8 | 9 | class ShortTests { 10 | 11 | private val hexWriter: HexWriter = DefaultHexWriter() 12 | 13 | @Test 14 | fun `put max short`() { 15 | 16 | // given 17 | val byteWriter = DefaultByteWriter(500) 18 | 19 | // when 20 | byteWriter.putShort(Short.MAX_VALUE) 21 | 22 | // then 23 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 24 | Assert.assertEquals(hex, "ff7f") 25 | } 26 | 27 | @Test 28 | fun `put min short`() { 29 | 30 | // given 31 | val byteWriter = DefaultByteWriter(500) 32 | 33 | // when 34 | byteWriter.putShort(Short.MIN_VALUE) 35 | 36 | // then 37 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 38 | Assert.assertEquals(hex, "0080") 39 | } 40 | } -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/hash/RIPEMD160Digest.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.hash 17 | 18 | class RIPEMD160Digest { 19 | 20 | companion object { 21 | fun hash(data: ByteArray): ByteArray { 22 | val digest = org.spongycastle.crypto.digests.RIPEMD160Digest() 23 | digest.update(data, 0, data.size) 24 | val out = ByteArray(20) 25 | digest.doFinal(out, 0) 26 | return out 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/VoterInfo.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class VoterInfo( 22 | val owner: String, 23 | val proxy: String, 24 | val producers: List, 25 | val staked: Double, 26 | val last_vote_weight: Double, 27 | val proxied_vote_weight: Double, 28 | val is_proxy: Int 29 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/info/Info.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.info 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class Info( 22 | val server_version: String, 23 | val chain_id: String, 24 | val head_block_num: Int, 25 | val last_irreversible_block_num: Int, 26 | val head_block_id: String, 27 | val head_block_time: String, 28 | val head_block_producer: String 29 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/delegatebw/DelegateBandwidthBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.delegatebw 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class DelegateBandwidthBody( 23 | val args: DelegateBandwidthArgs 24 | ) { 25 | 26 | val getArgs: DelegateBandwidthArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/undelegatebw/UnDelegateBandwidthBody.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.undelegatebw 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChildCompress 20 | 21 | @Abi 22 | data class UnDelegateBandwidthBody( 23 | val args: UnDelegateBandwidthArgs 24 | ) { 25 | 26 | val getArgs: UnDelegateBandwidthArgs 27 | @ChildCompress get() = args 28 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/producer/response/Producer.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.producer.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class Producer( 22 | val owner: String, 23 | val total_votes: String, 24 | val producer_key: String, 25 | val is_active: Int, 26 | val url: String, 27 | val unpaid_blocks: Int, 28 | val last_claim_time: String, 29 | val location: Int 30 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/producer/bpjson/BpSocial.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.producer.bpjson 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BpSocial( 22 | val steemit: String?, 23 | val twitter: String?, 24 | val youtube: String?, 25 | val facebook: String?, 26 | val github: String?, 27 | val reddit: String?, 28 | val telegram: String?, 29 | val wechat: String? 30 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/response/TransactionReceipt.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class TransactionReceipt( 22 | val receiver: String, 23 | val act_digest: String, 24 | val global_sequence: Long, 25 | val recv_sequence: Long, 26 | val auth_sequence: List, 27 | val code_sequence: Long, 28 | val abi_sequence: Long 29 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/response/TransactionAct.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction.response 17 | 18 | import com.memtrip.eos.http.rpc.model.transaction.TransactionAuthorization 19 | import com.squareup.moshi.JsonClass 20 | 21 | @JsonClass(generateAdapter = true) 22 | data class TransactionAct( 23 | val account: String, 24 | val name: String, 25 | val authorization: List, 26 | val data: Any, 27 | val hex_data: String? 28 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/producer/bpjson/BpOrg.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.producer.bpjson 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BpOrg( 22 | val candidate_name: String, 23 | val website: String, 24 | val code_of_conduct: String, 25 | val ownership_disclosure: String, 26 | val email: String, 27 | val branding: BpBranding, 28 | val location: BpLocation, 29 | val social: BpSocial 30 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/response/TransactionProcessed.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class TransactionProcessed( 22 | val id: String, 23 | val receipt: TransactionParentReceipt, 24 | val elapsed: Int, 25 | val net_usage: Int, 26 | val scheduled: Boolean, 27 | val action_traces: List, 28 | val except: Any?, 29 | val block_num: Int? 30 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/abi/TransactionAuthorizationAbi.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.abi 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | 21 | @Abi 22 | data class TransactionAuthorizationAbi( 23 | val actor: String, 24 | val permission: String 25 | ) { 26 | 27 | val getActor: String 28 | @AccountNameCompress get() = actor 29 | 30 | val getPermission: String 31 | @AccountNameCompress get() = permission 32 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/response/AbiContract.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class AbiContract( 22 | val version: String, 23 | val types: List, 24 | val structs: List, 25 | val actions: List, 26 | val tables: List, 27 | val ricardian_clauses: List, 28 | val error_messages: List, 29 | val abi_extensions: List 30 | ) 31 | -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/accountname/CheckAccountNameExists.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.query.accountname 17 | 18 | import com.memtrip.eos.http.rpc.ChainApi 19 | import com.memtrip.eos.http.rpc.model.account.request.AccountName 20 | import io.reactivex.Single 21 | 22 | class CheckAccountNameExists( 23 | private val chainApi: ChainApi 24 | ) { 25 | 26 | fun checkAccountNameExists(accountName: String): Single { 27 | return chainApi.getAccount(AccountName(accountName)).map { it.isSuccessful } 28 | } 29 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/response/HistoricAccountAction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.response 17 | 18 | import com.memtrip.eos.http.rpc.model.transaction.response.TransactionActionTrace 19 | import com.squareup.moshi.JsonClass 20 | import java.util.Date 21 | 22 | @JsonClass(generateAdapter = true) 23 | data class HistoricAccountAction( 24 | val global_action_seq: Long, 25 | val account_action_seq: Long, 26 | val block_num: Int, 27 | val block_time: Date, 28 | val action_trace: TransactionActionTrace 29 | ) -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/bytewriter/AccountNameWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.bytewriter 17 | 18 | import com.memtrip.eos.abi.writer.ByteWriter 19 | 20 | class AccountNameWriter { 21 | 22 | fun put(name: String, writer: ByteWriter) { 23 | 24 | if (name.length > MAX_LENGTH) { 25 | throw IllegalArgumentException("Account name cannot be more than 12 characters. => $name") 26 | } 27 | 28 | writer.putName(name) 29 | } 30 | 31 | companion object { 32 | const val MAX_LENGTH = 12 33 | } 34 | } -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/block/BlockIdDetails.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.block 17 | 18 | import com.memtrip.eos.core.hex.DefaultHexWriter 19 | import com.memtrip.eos.core.hex.HexWriter 20 | 21 | import org.bitcoinj.core.Utils 22 | import java.math.BigInteger 23 | 24 | data class BlockIdDetails( 25 | val blockId: String, 26 | val hexWriter: HexWriter = DefaultHexWriter(), 27 | val blockNum: Int = BigInteger(1, hexWriter.hexToBytes(blockId.substring(0, 8))).toInt(), 28 | val blockPrefix: Long = Utils.readUint32(hexWriter.hexToBytes(blockId.substring(16, 24)), 0) 29 | ) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/contract/request/GetTableRows.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.contract.request 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class GetTableRows( 22 | val scope: String, 23 | val code: String, 24 | val table: String, 25 | val table_key: String, 26 | val json: Boolean, 27 | val limit: Int, 28 | val lower_bound: String, 29 | val upper_bound: String, 30 | val key_type: String, 31 | val index_position: String, 32 | val encode_type: String 33 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/sellram/SellRamArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.sellram 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.LongCompress 21 | 22 | @Abi 23 | data class SellRamArgs( 24 | val account: String, 25 | val bytes: Long 26 | ) { 27 | 28 | val getAccount: String 29 | @AccountNameCompress get() = account 30 | 31 | val getBytes: Long 32 | @LongCompress get() = bytes 33 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/response/HistoricTransaction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.response 17 | 18 | import com.memtrip.eos.http.rpc.model.transaction.response.TransactionActionTrace 19 | import com.squareup.moshi.JsonClass 20 | import java.util.Date 21 | 22 | @JsonClass(generateAdapter = true) 23 | data class HistoricTransaction( 24 | val id: String, 25 | val trx: ExecutedTransactionParent, 26 | val block_time: Date, 27 | val block_num: Int, 28 | val last_irreversible_block: Int, 29 | val traces: List 30 | ) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/main/java/com/memtrip/eos/abi/writer/preprocessor/model/CompressType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.preprocessor.model; 17 | 18 | public enum CompressType { 19 | NAME, 20 | ACCOUNT_NAME, 21 | BLOCK_NUM, 22 | BLOCK_PREFIX, 23 | PUBLIC_KEY, 24 | ASSET, 25 | CHAIN_ID, 26 | HEX_COLLECTION, 27 | DATA, 28 | TIMESTAMP, 29 | BYTE, 30 | SHORT, 31 | INT, 32 | VARIABLE_UINT, 33 | LONG, 34 | FLOAT, 35 | BYTES, 36 | STRING, 37 | STRING_COLLECTION, 38 | COLLECTION, 39 | ACCOUNT_NAME_COLLECTION, 40 | CHILD 41 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/newaccount/AccountKeyAbi.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.newaccount 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.PublicKeyCompress 20 | import com.memtrip.eos.abi.writer.ShortCompress 21 | 22 | @Abi 23 | data class AccountKeyAbi( 24 | val key: String, 25 | val weight: Short 26 | ) { 27 | 28 | val getKey: String 29 | @PublicKeyCompress get() = key 30 | 31 | val getWeight: Short 32 | @ShortCompress get() = weight 33 | } 34 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/BlockHeaderStateHeader.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | import java.util.Date 20 | 21 | @JsonClass(generateAdapter = true) 22 | data class BlockHeaderStateHeader( 23 | val timestamp: Date, 24 | val producer: String, 25 | val confirmed: Int, 26 | val previous: String, 27 | val transaction_mroot: String, 28 | val action_mroot: String, 29 | val schedule_version: Int, 30 | val header_extensions: List, 31 | val producer_signature: String 32 | ) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/main/java/com/memtrip/eos/abi/writer/preprocessor/model/AbiWriterModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.preprocessor.model; 17 | 18 | public class AbiWriterModel { 19 | 20 | private final String className; 21 | private final String classPackage; 22 | 23 | public String getClassName() { 24 | return className; 25 | } 26 | 27 | public String getClassPackage() { 28 | return classPackage; 29 | } 30 | 31 | public AbiWriterModel(String className, String classPackage) { 32 | this.className = className; 33 | this.classPackage = classPackage; 34 | } 35 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/utils/DateAdapter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.utils 17 | 18 | import com.squareup.moshi.FromJson 19 | import com.squareup.moshi.ToJson 20 | import java.text.SimpleDateFormat 21 | import java.util.Date 22 | 23 | class DateAdapter { 24 | 25 | private val dateFormatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss") 26 | 27 | @FromJson 28 | internal fun fromJson(timestamp: String): Date { 29 | return dateFormatter.parse(timestamp) 30 | } 31 | 32 | @ToJson 33 | internal fun toJson(date: Date): String { 34 | return dateFormatter.format(date) 35 | } 36 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/transaction/Transaction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.transaction 17 | 18 | import com.squareup.moshi.JsonClass 19 | import java.util.Date 20 | 21 | @JsonClass(generateAdapter = true) 22 | class Transaction( 23 | val expiration: Date, 24 | val ref_block_num: Int, 25 | val ref_block_prefix: Long, 26 | val max_net_usage_words: Long, 27 | val max_cpu_usage_ms: Long, 28 | val delay_sec: Long, 29 | val context_free_actions: List, 30 | val actions: List, 31 | val transaction_extensions: List, 32 | val signatures: List, 33 | val context_free_data: List 34 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/buyram/BuyRamArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.buyram 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.AssetCompress 21 | 22 | @Abi 23 | data class BuyRamArgs( 24 | val payer: String, 25 | val receiver: String, 26 | val quant: String 27 | ) { 28 | 29 | val getCreator: String 30 | @AccountNameCompress get() = payer 31 | 32 | val getName: String 33 | @AccountNameCompress get() = receiver 34 | 35 | val getQuant: String 36 | @AssetCompress get() = quant 37 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/buyram/BuyRamBytesArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.buyram 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.LongCompress 21 | 22 | @Abi 23 | data class BuyRamBytesArgs( 24 | val payer: String, 25 | val receiver: String, 26 | val bytes: Long 27 | ) { 28 | 29 | val getCreator: String 30 | @AccountNameCompress get() = payer 31 | 32 | val getName: String 33 | @AccountNameCompress get() = receiver 34 | 35 | val getBytes: Long 36 | @LongCompress get() = bytes 37 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/history/response/ExecutedTransaction.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.history.response 17 | 18 | import com.memtrip.eos.http.rpc.model.transaction.Action 19 | import com.squareup.moshi.JsonClass 20 | import java.util.Date 21 | 22 | @JsonClass(generateAdapter = true) 23 | class ExecutedTransaction( 24 | val expiration: Date, 25 | val ref_block_num: Int, 26 | val ref_block_prefix: Long, 27 | val max_net_usage_words: Long, 28 | val max_cpu_usage_ms: Long, 29 | val delay_sec: Long, 30 | val context_free_actions: List, 31 | val actions: List, 32 | val signatures: List, 33 | val context_free_data: List 34 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/abihex/RefundArgsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.abihex 2 | 3 | import com.memtrip.eos.abi.writer.compression.CompressionType 4 | import com.memtrip.eos.chain.actions.transaction.AbiBinaryGenTransactionWriter 5 | import com.memtrip.eos.chain.actions.transaction.account.actions.refund.RefundArgs 6 | import com.memtrip.eos.chain.actions.transaction.account.actions.refund.RefundBody 7 | import junit.framework.TestCase 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.platform.runner.JUnitPlatform 13 | import org.junit.runner.RunWith 14 | 15 | @RunWith(JUnitPlatform::class) 16 | class RefundArgsTest : Spek({ 17 | 18 | given("a transaction writer") { 19 | 20 | val transactionWriter by memoized { AbiBinaryGenTransactionWriter(CompressionType.NONE) } 21 | 22 | on("squish the refund abi model") { 23 | 24 | val refundArgs = RefundArgs("memtripissue") 25 | val refundBody = RefundBody(refundArgs) 26 | 27 | val output = transactionWriter.squishRefundBody(refundBody).toHex() 28 | 29 | it("should encode bytes as hex") { 30 | TestCase.assertEquals("a034c6aeba9ba592", output) 31 | } 32 | } 33 | } 34 | }) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/vote/actions/VoteArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.vote.actions 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCollectionCompress 20 | 21 | import com.memtrip.eos.abi.writer.AccountNameCompress 22 | 23 | @Abi 24 | data class VoteArgs( 25 | val voter: String, 26 | val proxy: String, 27 | val producers: List 28 | ) { 29 | 30 | val getVoter: String 31 | @AccountNameCompress get() = voter 32 | 33 | val getProxy: String 34 | @AccountNameCompress get() = proxy 35 | 36 | val getProducers: List 37 | @AccountNameCollectionCompress get() = producers 38 | } -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/bytewriter/ChainIdWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.bytewriter 17 | 18 | import com.memtrip.eos.abi.writer.ByteWriter 19 | 20 | class ChainIdWriter { 21 | 22 | fun put(chainId: String, writer: ByteWriter) { 23 | writer.putBytes(getSha256FromHexStr(chainId)) 24 | } 25 | 26 | private fun getSha256FromHexStr(str: String): ByteArray { 27 | val len = str.length 28 | val bytes = ByteArray(32) 29 | var i = 0 30 | while (i < len) { 31 | val strIte = str.substring(i, i + 2) 32 | val n = Integer.parseInt(strIte, 16) and 0xFF 33 | bytes[i / 2] = n.toByte() 34 | i += 2 35 | } 36 | return bytes 37 | } 38 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/bandwidth/GetDelegatedBandwidth.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.query.bandwidth 2 | 3 | import com.memtrip.eos.http.rpc.ChainApi 4 | import com.memtrip.eos.http.rpc.model.contract.request.GetTableRows 5 | import io.reactivex.Single 6 | 7 | class GetDelegatedBandwidth(private val chainApi: ChainApi) { 8 | 9 | fun getBandwidth(accountName: String): Single> { 10 | return chainApi.getTableRows(GetTableRows( 11 | accountName, 12 | "eosio", 13 | "delband", 14 | "", 15 | true, 16 | 100, 17 | "", 18 | "", 19 | "", 20 | "", 21 | "dec" 22 | )).map { response -> 23 | if (response.isSuccessful && response.body() != null) { 24 | val rows = response.body()!!.rows 25 | rows.map { row -> 26 | BandwidthJson( 27 | row["from"].toString(), 28 | row["to"].toString(), 29 | row["net_weight"].toString(), 30 | row["cpu_weight"].toString()) 31 | } 32 | } else { 33 | throw FailedToFetchDelegatedBandwidth() 34 | } 35 | } 36 | } 37 | 38 | class FailedToFetchDelegatedBandwidth : Exception() 39 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | language: java 3 | 4 | jdk: 5 | - oraclejdk8 6 | 7 | os: 8 | - linux 9 | 10 | before_cache: 11 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 12 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 13 | cache: 14 | directories: 15 | - $HOME/.gradle/caches/ 16 | - $HOME/.gradle/wrapper/ 17 | 18 | jobs: 19 | include: 20 | - stage: "Core" 21 | before_script: cd eos-core 22 | script: 23 | - ./gradlew ktlintcheck 24 | - ./gradlew test 25 | - ./gradlew assemble 26 | - stage: "Chain actions" 27 | before_script: cd eos-chain-actions 28 | script: 29 | - ./gradlew ktlintcheck 30 | - ./gradlew test 31 | - ./gradlew assemble 32 | - stage: "Abi writer - annotation preprocessor" 33 | before_script: cd eos-abi-writer-preprocessor 34 | script: 35 | - mvn clean test 36 | - stage: "Abi writer" 37 | before_script: cd eos-abi-writer 38 | script: 39 | - ./gradlew ktlintcheck 40 | - ./gradlew test 41 | - ./gradlew assemble 42 | - stage: "Http RPC" 43 | before_script: cd eos-http-rpc 44 | script: 45 | - ./gradlew ktlintcheck 46 | - ./gradlew test 47 | - ./gradlew assemble 48 | - stage: "Chain actions" 49 | before_script: cd eos-chain-actions 50 | script: 51 | - ./gradlew ktlintcheck 52 | - ./gradlew assemble 53 | -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/abi/SignedTransactionAbi.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.abi 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.ChainIdCompress 20 | import com.memtrip.eos.abi.writer.ChildCompress 21 | import com.memtrip.eos.abi.writer.HexCollectionCompress 22 | 23 | @Abi 24 | data class SignedTransactionAbi( 25 | val chainId: String, 26 | val transaction: TransactionAbi, 27 | val context_free_data: List 28 | ) { 29 | val getChainId: String 30 | @ChainIdCompress get() = chainId 31 | 32 | val getTransaction: TransactionAbi 33 | @ChildCompress get() = transaction 34 | 35 | val getContextFreeData: List 36 | @HexCollectionCompress get() = context_free_data 37 | } -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/bytewriter/PublicKeyWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.bytewriter 17 | 18 | import com.memtrip.eos.abi.writer.ByteWriter 19 | import com.memtrip.eos.core.crypto.EosPublicKey 20 | 21 | class PublicKeyWriter { 22 | 23 | fun put(publicKey: EosPublicKey, writer: ByteWriter) { 24 | writer.putVariableUInt(type(publicKey)) 25 | writer.putBytes(publicKey.bytes) 26 | } 27 | 28 | private fun type(publicKey: EosPublicKey): Long = if (publicKey.isCurveParamK1) { 29 | PACK_VAL_CURVE_PARAM_TYPE_K1.toLong() 30 | } else { 31 | PACK_VAL_CURVE_PARAM_TYPE_R1.toLong() 32 | } 33 | 34 | companion object { 35 | private const val PACK_VAL_CURVE_PARAM_TYPE_K1: Byte = 0 36 | private const val PACK_VAL_CURVE_PARAM_TYPE_R1: Byte = 1 37 | } 38 | } -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/FloatTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | import org.junit.Assert.assertEquals 7 | import org.junit.Test 8 | 9 | class FloatTests { 10 | 11 | private val hexWriter: HexWriter = DefaultHexWriter() 12 | 13 | @Test 14 | fun `put max float value`() { 15 | 16 | // given 17 | val byteWriter = DefaultByteWriter(500) 18 | 19 | // when 20 | byteWriter.putFloat(Float.MAX_VALUE) 21 | 22 | // then 23 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 24 | assertEquals(hex, "ffff7f7f") 25 | } 26 | 27 | @Test 28 | fun `put float value`() { 29 | 30 | // given 31 | val byteWriter = DefaultByteWriter(500) 32 | 33 | // when 34 | byteWriter.putFloat(kotlin.math.PI.toFloat()) 35 | 36 | // then 37 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 38 | assertEquals(hex, "db0f4940") 39 | } 40 | 41 | @Test 42 | fun `put min float value`() { 43 | 44 | // given 45 | val byteWriter = DefaultByteWriter(500) 46 | 47 | // when 48 | byteWriter.putFloat(Float.MIN_VALUE) 49 | 50 | // then 51 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 52 | assertEquals(hex, "01000000") 53 | } 54 | } -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/main/java/com/memtrip/eos/abi/writer/preprocessor/model/AbiModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.preprocessor.model; 17 | 18 | import java.util.List; 19 | 20 | public class AbiModel { 21 | 22 | private final String className; 23 | private final String classPackage; 24 | private final List fields; 25 | 26 | public String getClassName() { 27 | return className; 28 | } 29 | 30 | public String getClassPackage() { 31 | return classPackage; 32 | } 33 | 34 | public List getFields() { 35 | return fields; 36 | } 37 | 38 | public AbiModel(String className, String classPackage, List fields) { 39 | this.className = className; 40 | this.classPackage = classPackage; 41 | this.fields = fields; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/LongTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | import org.junit.Assert.assertEquals 7 | import org.junit.Test 8 | 9 | class LongTests { 10 | 11 | private val hexWriter: HexWriter = DefaultHexWriter() 12 | 13 | @Test 14 | fun `put max long value`() { 15 | 16 | // given 17 | val byteWriter = DefaultByteWriter(500) 18 | 19 | // when 20 | byteWriter.putLong(Long.MAX_VALUE) 21 | 22 | // then 23 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 24 | assertEquals(hex, "ffffffffffffff7f") 25 | } 26 | 27 | @Test 28 | fun `put long value`() { 29 | 30 | // given 31 | val byteWriter = DefaultByteWriter(500) 32 | 33 | // when 34 | byteWriter.putLong(1549654354968L) 35 | 36 | // then 37 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 38 | assertEquals(hex, "18ec98ce68010000") 39 | } 40 | 41 | @Test 42 | fun `put min long value`() { 43 | 44 | // given 45 | val byteWriter = DefaultByteWriter(500) 46 | 47 | // when 48 | byteWriter.putLong(Long.MIN_VALUE) 49 | 50 | // then 51 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 52 | assertEquals(hex, "0000000000000080") 53 | } 54 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/transfer/actions/TransferArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.transfer.actions 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.AssetCompress 21 | import com.memtrip.eos.abi.writer.StringCompress 22 | 23 | @Abi 24 | data class TransferArgs( 25 | val from: String, 26 | val to: String, 27 | val quantity: String, 28 | val memo: String 29 | ) { 30 | 31 | val getFrom: String 32 | @AccountNameCompress get() = from 33 | 34 | val getTo: String 35 | @AccountNameCompress get() = to 36 | 37 | val getQuantity: String 38 | @AssetCompress get() = quantity 39 | 40 | val getMemo: String 41 | @StringCompress get() = memo 42 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/abihex/SellRamArgsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.abihex 2 | 3 | import com.memtrip.eos.abi.writer.compression.CompressionType 4 | import com.memtrip.eos.chain.actions.transaction.AbiBinaryGenTransactionWriter 5 | import com.memtrip.eos.chain.actions.transaction.account.actions.sellram.SellRamArgs 6 | import com.memtrip.eos.chain.actions.transaction.account.actions.sellram.SellRamBody 7 | import junit.framework.TestCase.assertEquals 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.platform.runner.JUnitPlatform 13 | import org.junit.runner.RunWith 14 | 15 | @RunWith(JUnitPlatform::class) 16 | class SellRamArgsTest : Spek({ 17 | 18 | given("a transaction writer") { 19 | 20 | val transactionWriter by memoized { AbiBinaryGenTransactionWriter(CompressionType.NONE) } 21 | 22 | on("squish the undelegate bandwidth abi model") { 23 | 24 | val sellRamArgs = SellRamArgs( 25 | "memtripissue", 26 | 4018 27 | ) 28 | val sellRamBody = SellRamBody(sellRamArgs) 29 | 30 | val output = transactionWriter.squishSellRamBody(sellRamBody).toHex() 31 | 32 | it("should encode bytes as hex") { 33 | assertEquals("a034c6aeba9ba592b20f000000000000", output) 34 | } 35 | } 36 | } 37 | }) 38 | -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/ChainResponse.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions 17 | 18 | data class ChainResponse ( 19 | val isSuccessful: Boolean, 20 | val statusCode: Int, 21 | val body: T?, 22 | val errorBody: ChainError? 23 | ) { 24 | 25 | companion object { 26 | fun error(): ChainResponse { 27 | return ChainResponse( 28 | false, 29 | 400, 30 | null, 31 | null) 32 | } 33 | } 34 | } 35 | 36 | data class ChainError( 37 | val code: Long, 38 | val message: String, 39 | val error: Error 40 | ) 41 | 42 | data class Error( 43 | val code: Long, 44 | val name: String, 45 | val what: String, 46 | val details: List
47 | ) 48 | 49 | data class Details( 50 | val message: String, 51 | val method: String 52 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/newaccount/NewAccountArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.newaccount 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.ChildCompress 21 | 22 | @Abi 23 | data class NewAccountArgs( 24 | val creator: String, 25 | val name: String, 26 | val owner: AccountRequiredAuthAbi, 27 | val active: AccountRequiredAuthAbi 28 | ) { 29 | 30 | val getCreator: String 31 | @AccountNameCompress get() = creator 32 | 33 | val getName: String 34 | @AccountNameCompress get() = name 35 | 36 | val getOwner: AccountRequiredAuthAbi 37 | @ChildCompress get() = owner 38 | 39 | val getActive: AccountRequiredAuthAbi 40 | @ChildCompress get() = active 41 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/abihex/BuyRamArgsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.abihex 2 | 3 | import com.memtrip.eos.abi.writer.compression.CompressionType 4 | import com.memtrip.eos.chain.actions.transaction.AbiBinaryGenTransactionWriter 5 | import com.memtrip.eos.chain.actions.transaction.account.actions.buyram.BuyRamArgs 6 | import com.memtrip.eos.chain.actions.transaction.account.actions.buyram.BuyRamBody 7 | import junit.framework.TestCase.assertEquals 8 | 9 | import org.jetbrains.spek.api.Spek 10 | import org.jetbrains.spek.api.dsl.given 11 | import org.jetbrains.spek.api.dsl.it 12 | import org.jetbrains.spek.api.dsl.on 13 | import org.junit.platform.runner.JUnitPlatform 14 | import org.junit.runner.RunWith 15 | 16 | @RunWith(JUnitPlatform::class) 17 | class BuyRamArgsTest : Spek({ 18 | 19 | given("a transaction writer") { 20 | 21 | val transactionWriter by memoized { AbiBinaryGenTransactionWriter(CompressionType.NONE) } 22 | 23 | on("squish the buy ram abi model") { 24 | 25 | val buyRamArgs = BuyRamArgs( 26 | "memtripissue", 27 | "memtripproxy", 28 | "51.2345 EOS" 29 | ) 30 | val buyRamBody = BuyRamBody(buyRamArgs) 31 | 32 | val output = transactionWriter.squishBuyRamBody(buyRamBody).toHex() 33 | 34 | it("should encode bytes as hex") { 35 | assertEquals("a034c6aeba9ba592e03bbdb5ba9ba59259d107000000000004454f5300000000", output) 36 | } 37 | } 38 | } 39 | }) -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/ChainGetInfoTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.utils.Config 5 | import okhttp3.OkHttpClient 6 | import okhttp3.logging.HttpLoggingInterceptor 7 | import org.jetbrains.spek.api.Spek 8 | import org.jetbrains.spek.api.dsl.given 9 | import org.jetbrains.spek.api.dsl.it 10 | import org.jetbrains.spek.api.dsl.on 11 | import org.junit.Assert.assertNotNull 12 | import org.junit.Assert.assertTrue 13 | import org.junit.platform.runner.JUnitPlatform 14 | import org.junit.runner.RunWith 15 | import java.util.concurrent.TimeUnit 16 | 17 | @RunWith(JUnitPlatform::class) 18 | class ChainGetInfoTest : Spek({ 19 | 20 | given("an Api") { 21 | 22 | val okHttpClient by memoized { 23 | OkHttpClient.Builder() 24 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 25 | .connectTimeout(10, TimeUnit.SECONDS) 26 | .readTimeout(10, TimeUnit.SECONDS) 27 | .writeTimeout(10, TimeUnit.SECONDS) 28 | .build() 29 | } 30 | 31 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 32 | 33 | on("v1/chain/get_info") { 34 | 35 | val info = chainApi.getInfo().blockingGet() 36 | 37 | it("should return info") { 38 | assertTrue(info.isSuccessful) 39 | assertNotNull(info.body()) 40 | } 41 | } 42 | } 43 | }) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/undelegatebw/UnDelegateBandwidthArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.undelegatebw 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.AssetCompress 21 | 22 | @Abi 23 | data class UnDelegateBandwidthArgs( 24 | val from: String, 25 | val receiver: String, 26 | val stake_net_quantity: String, 27 | val stake_cpu_quantity: String 28 | ) { 29 | 30 | val getFrom: String 31 | @AccountNameCompress get() = from 32 | 33 | val getReceiver: String 34 | @AccountNameCompress get() = receiver 35 | 36 | val getStakeNetQuantity: String 37 | @AssetCompress get() = stake_net_quantity 38 | 39 | val getStakeCpuQuantity: String 40 | @AssetCompress get() = stake_cpu_quantity 41 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## eos-jvm 2 | EOS libraries for the JVM, designed primarily for Android development. Our open source Android wallet app 3 | [EOS REACH](https://github.com/memtrip/eosreach) serves as a blueprint for how other developers might want to utilise this SDK. 4 | 5 | [![Travis ci](https://travis-ci.com/memtrip/eos-jvm.svg?branch=master)](https://travis-ci.com/memtrip/eos-jvm) 6 | 7 | ### [eos-chain-actions](https://github.com/memtrip/eos-jvm/tree/master/eos-chain-actions) 8 | An EOS SDK for pushing actions to the EOS system contracts. This high level abstraction composes the other eos-jvm modules to seamlessly handle transaction signing, byte writing and api requests. 9 | 10 | ### [eos-core](https://github.com/memtrip/eos-jvm/tree/master/eos-core) 11 | An EOS client library containing the core building blocks required to interact with the EOS network. 12 | 13 | ### [eos-http-rpc](https://github.com/memtrip/eos-jvm/tree/master/eos-http-rpc) 14 | An EOS client library that uses an OkHttpClient to make requests to the nodeos RPC HTTP API. 15 | 16 | ### [eos-abi-writer](https://github.com/memtrip/eos-jvm/tree/master/eos-abi-writer) 17 | A local replacement of `abi_json_to_bin`, annotation processing is used to generate reliable Abi byte writing boilerplate code. 18 | 19 | ### Credits 20 | - [Join us on telegram](http://t.me/joinchat/JcIXl0x7wC9cRI5uF_EiQA) 21 | - [Developed by memtrip.com](http://memtrip.com) 22 | - Thank you to [swapnibble](https://github.com/swapnibble) for [EosCommander](https://github.com/playerone-id/EosCommander), an invaluable resource for anyone experimenting with EOS. 23 | -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/abihex/BuyRamBytesArgsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.abihex 2 | 3 | import com.memtrip.eos.abi.writer.compression.CompressionType 4 | import com.memtrip.eos.chain.actions.transaction.AbiBinaryGenTransactionWriter 5 | import com.memtrip.eos.chain.actions.transaction.account.actions.buyram.BuyRamBytesArgs 6 | import com.memtrip.eos.chain.actions.transaction.account.actions.buyram.BuyRamBytesBody 7 | import junit.framework.TestCase.assertEquals 8 | 9 | import org.jetbrains.spek.api.Spek 10 | import org.jetbrains.spek.api.dsl.given 11 | import org.jetbrains.spek.api.dsl.it 12 | import org.jetbrains.spek.api.dsl.on 13 | import org.junit.platform.runner.JUnitPlatform 14 | import org.junit.runner.RunWith 15 | 16 | @RunWith(JUnitPlatform::class) 17 | class BuyRamBytesArgsTest : Spek({ 18 | 19 | given("a transaction writer") { 20 | 21 | val transactionWriter by memoized { AbiBinaryGenTransactionWriter(CompressionType.NONE) } 22 | 23 | on("squish the buy ram bytes abi model") { 24 | 25 | val buyRamBytesArgs = BuyRamBytesArgs( 26 | "memtripissue", 27 | "memtripproxy", 28 | 4096 29 | ) 30 | val buyRamBytesBody = BuyRamBytesBody(buyRamBytesArgs) 31 | 32 | val output = transactionWriter.squishBuyRamBytesBody(buyRamBytesBody).toHex() 33 | 34 | it("should encode bytes as hex") { 35 | assertEquals("a034c6aeba9ba592e03bbdb5ba9ba5920010000000000000", output) 36 | } 37 | } 38 | } 39 | }) -------------------------------------------------------------------------------- /eos-abi-writer/src/test/kotlin/com/memtrip/eos/abi/writer/AccountNameTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer 2 | 3 | import com.memtrip.eos.abi.writer.bytewriter.DefaultByteWriter 4 | import com.memtrip.eos.core.hex.DefaultHexWriter 5 | import com.memtrip.eos.core.hex.HexWriter 6 | 7 | import org.junit.Assert.assertEquals 8 | import org.junit.Test 9 | 10 | class AccountNameTests { 11 | 12 | private val hexWriter: HexWriter = DefaultHexWriter() 13 | 14 | @Test 15 | fun testAccountName() { 16 | 17 | // given 18 | val byteWriter = DefaultByteWriter(500) 19 | 20 | // when 21 | byteWriter.putAccountName("memtripissue") 22 | 23 | // then 24 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 25 | assertEquals(hex, "a034c6aeba9ba592") 26 | } 27 | 28 | @Test 29 | fun testName() { 30 | 31 | // given 32 | val byteWriter = DefaultByteWriter(500) 33 | 34 | // when 35 | byteWriter.putName("memtripblock") 36 | 37 | // then 38 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 39 | assertEquals(hex, "00118da7ba9ba592") 40 | } 41 | 42 | @Test 43 | fun testAccountNameCollection() { 44 | 45 | // given 46 | val byteWriter = DefaultByteWriter(500) 47 | 48 | // when 49 | byteWriter.putAccountNameCollection(listOf( 50 | "memtripissue", 51 | "memtripblock")) 52 | 53 | // then 54 | val hex = hexWriter.bytesToHex(byteWriter.toBytes()) 55 | assertEquals(hex, "02a034c6aeba9ba59200118da7ba9ba592") 56 | } 57 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/abi/ActionAbi.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.abi 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.CollectionCompress 21 | import com.memtrip.eos.abi.writer.DataCompress 22 | import com.memtrip.eos.abi.writer.NameCompress 23 | 24 | @Abi 25 | data class ActionAbi( 26 | val account: String, 27 | val name: String, 28 | val authorization: List, 29 | val data: String? 30 | ) { 31 | 32 | val getAccount: String 33 | @AccountNameCompress get() = account 34 | 35 | val getName: String 36 | @NameCompress get() = name 37 | 38 | val getAuthorization: List 39 | @CollectionCompress get() = authorization 40 | 41 | val getData: String? 42 | @DataCompress get() = data 43 | } 44 | -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/query/CalculateRamPriceTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.query 2 | 3 | import com.memtrip.eos.chain.actions.Config 4 | import com.memtrip.eos.chain.actions.query.ramprice.GetRamPrice 5 | import com.memtrip.eos.http.rpc.Api 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert.assertTrue 13 | import org.junit.platform.runner.JUnitPlatform 14 | import org.junit.runner.RunWith 15 | import java.util.concurrent.TimeUnit 16 | 17 | @RunWith(JUnitPlatform::class) 18 | class CalculateRamPriceTest : Spek({ 19 | 20 | given("an Api") { 21 | 22 | val okHttpClient by memoized { 23 | OkHttpClient.Builder() 24 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 25 | .connectTimeout(10, TimeUnit.SECONDS) 26 | .readTimeout(10, TimeUnit.SECONDS) 27 | .writeTimeout(10, TimeUnit.SECONDS) 28 | .build() 29 | } 30 | 31 | val chainApi by memoized { Api(Config.MAINNET_API_BASE_URL, okHttpClient).chain } 32 | 33 | on("get ram price per byte") { 34 | 35 | val response = GetRamPrice(chainApi).getPricePerKilobyte().blockingGet() 36 | 37 | it("should return a ram price per byte") { 38 | assertTrue(response > 0) 39 | } 40 | } 41 | } 42 | }) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/account/response/Account.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.account.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | import java.util.Date 20 | 21 | @JsonClass(generateAdapter = true) 22 | data class Account( 23 | val account_name: String, 24 | val head_block_num: Int, 25 | val head_block_time: Date, 26 | val privileged: Boolean, 27 | val last_code_update: Date, 28 | val created: Date, 29 | val core_liquid_balance: String?, 30 | val ram_quota: Long, 31 | val net_weight: Long, 32 | val cpu_weight: Long, 33 | val net_limit: AccountResourceLimit, 34 | val cpu_limit: AccountResourceLimit, 35 | val ram_usage: Long, 36 | val permissions: List, 37 | val total_resources: TotalResources?, 38 | val self_delegated_bandwidth: SelfDelegatedBandwidth?, 39 | val refund_request: RefundRequest?, 40 | val voter_info: VoterInfo? 41 | ) -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/newaccount/AccountRequiredAuthAbi.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.newaccount 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.CollectionCompress 20 | import com.memtrip.eos.abi.writer.IntCompress 21 | import com.memtrip.eos.abi.writer.StringCollectionCompress 22 | 23 | @Abi 24 | data class AccountRequiredAuthAbi( 25 | val threshold: Int, 26 | val keys: List, 27 | val accounts: List, 28 | val waits: List 29 | ) { 30 | val getThreshold: Int 31 | @IntCompress get() = threshold 32 | 33 | val getKeys: List 34 | @CollectionCompress get() = keys 35 | 36 | val getAccounts: List 37 | @StringCollectionCompress get() = accounts 38 | 39 | val getWaits: List 40 | @StringCollectionCompress get() = waits 41 | } 42 | -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/model/block/response/BlockHeaderState.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc.model.block.response 17 | 18 | import com.squareup.moshi.JsonClass 19 | 20 | @JsonClass(generateAdapter = true) 21 | data class BlockHeaderState( 22 | val id: String, 23 | val block_num: Int, 24 | val header: BlockHeaderStateHeader, 25 | val dpos_proposed_irreversible_blocknum: Int, 26 | val dpos_irreversible_blocknum: Int, 27 | val bft_irreversible_blocknum: Int, 28 | val pending_schedule_lib_num: Int, 29 | val pending_schedule_hash: String, 30 | val pending_schedule: BlockHeaderSchedule, 31 | val active_schedule: BlockHeaderSchedule, 32 | val blockroot_merkle: BlockHeaderRootMerkle, 33 | val producer_to_last_produced: List>, 34 | val producer_to_last_implied_irb: List>, 35 | val block_signing_key: String, 36 | val confirm_count: List, 37 | val confirmations: List 38 | ) 39 | -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/bytewriter/CurrencySymbolWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.bytewriter 17 | 18 | import com.memtrip.eos.abi.writer.ByteWriter 19 | 20 | class CurrencySymbolWriter { 21 | 22 | fun put(precision: Int, symbol: CharSequence, writer: ByteWriter) { 23 | 24 | var result: Long = 0 25 | 26 | if (symbol.isEmpty()) { 27 | throw IllegalArgumentException("empty currency symbol string") 28 | } 29 | 30 | for (index in 0 until symbol.length) { 31 | val value = symbol[index].toLong() 32 | 33 | // check range 'A' to 'Z' 34 | if (value < 65 || value > 90) { 35 | throw IllegalArgumentException("invalid currency symbol string: $symbol") 36 | } 37 | 38 | result = result or (value shl 8 * (1 + index)) 39 | } 40 | 41 | result = result or precision.toLong() 42 | 43 | writer.putLong(result) 44 | } 45 | } -------------------------------------------------------------------------------- /eos-core/src/test/kotlin/com/memtrip/eos/core/crypto/EosKeyTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.core.crypto 2 | 3 | import org.junit.Assert.assertEquals 4 | import org.junit.Assert.assertNotNull 5 | import org.junit.Test 6 | 7 | class EosKeyTests { 8 | 9 | @Test 10 | fun testPublicKeyIsResolvedFromPrivateKey() { 11 | val privateKey = EosPrivateKey("5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3") 12 | assertEquals("EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", privateKey.publicKey.toString()) 13 | } 14 | 15 | @Test 16 | fun testGenerateEosPrivateKey() { 17 | val privateKey = EosPrivateKey() 18 | val publicKey = privateKey.publicKey 19 | assertNotNull(privateKey.toString()) 20 | assertNotNull(publicKey.toString()) 21 | } 22 | 23 | @Test 24 | fun testCreateEosPrivateKeyFromBytes() { 25 | val existingPrivateKey = EosPrivateKey("5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3") 26 | val bytes = existingPrivateKey.bytes 27 | val privateKey = EosPrivateKey(bytes) 28 | assertNotNull(privateKey.toString()) 29 | assertEquals(privateKey.toString(), "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3") 30 | } 31 | 32 | @Test 33 | fun testPublicKeyFormat() { 34 | val publicKey = EosPublicKey("EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV") 35 | assertEquals("EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", publicKey.toString()) 36 | val publicKeyFromBytes = EosPublicKey(publicKey.bytes) 37 | assertEquals(publicKeyFromBytes.toString(), publicKey.toString()) 38 | } 39 | } -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/ByteWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer 17 | 18 | import com.memtrip.eos.core.crypto.EosPublicKey 19 | 20 | interface ByteWriter { 21 | fun putName(value: String) 22 | fun putAccountName(value: String) 23 | fun putBlockNum(value: Int) 24 | fun putBlockPrefix(value: Long) 25 | fun putPublicKey(value: EosPublicKey) 26 | fun putAsset(value: String) 27 | fun putChainId(value: String) 28 | fun putData(value: String) 29 | fun putTimestampMs(value: Long) 30 | fun putShort(value: Short) 31 | fun putInt(value: Int) 32 | fun putVariableUInt(value: Long) 33 | fun putLong(value: Long) 34 | fun putFloat(value: Float) 35 | fun putBytes(value: ByteArray) 36 | fun putString(value: String) 37 | fun putStringCollection(stringList: List) 38 | fun putHexCollection(stringList: List) 39 | fun putAccountNameCollection(accountNameList: List) 40 | 41 | fun toBytes(): ByteArray 42 | fun length(): Int 43 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/ChainGetAbiTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.model.account.request.AccountName 5 | import com.memtrip.eos.http.rpc.utils.Config 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert.assertNotNull 13 | import org.junit.Assert.assertTrue 14 | import org.junit.platform.runner.JUnitPlatform 15 | import org.junit.runner.RunWith 16 | import java.util.concurrent.TimeUnit 17 | 18 | @RunWith(JUnitPlatform::class) 19 | class ChainGetAbiTest : Spek({ 20 | 21 | given("an Api") { 22 | 23 | val okHttpClient by memoized { 24 | OkHttpClient.Builder() 25 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 26 | .connectTimeout(10, TimeUnit.SECONDS) 27 | .readTimeout(10, TimeUnit.SECONDS) 28 | .writeTimeout(10, TimeUnit.SECONDS) 29 | .build() 30 | } 31 | 32 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 33 | 34 | on("v1/chain/get_abi") { 35 | 36 | val abi = chainApi.getAbi(AccountName("eosio.token")).blockingGet() 37 | 38 | it("should return the abi of the contract deployed by the account") { 39 | assertTrue(abi.isSuccessful) 40 | assertNotNull(abi.body()) 41 | } 42 | } 43 | } 44 | }) -------------------------------------------------------------------------------- /eos-http-rpc/src/main/kotlin/com/memtrip/eos/http/rpc/Api.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.http.rpc 17 | 18 | import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory 19 | import com.memtrip.eos.http.rpc.utils.DateAdapter 20 | import com.squareup.moshi.Moshi 21 | import okhttp3.OkHttpClient 22 | import retrofit2.Converter 23 | import retrofit2.Retrofit 24 | import retrofit2.converter.moshi.MoshiConverterFactory 25 | 26 | class Api( 27 | baseUrl: String, 28 | okHttpClient: OkHttpClient, 29 | moshi: Moshi = Moshi.Builder().add(DateAdapter()).build(), 30 | converterFactory: Converter.Factory = MoshiConverterFactory.create(moshi), 31 | private val retrofit: Retrofit = Retrofit.Builder() 32 | .baseUrl(baseUrl) 33 | .client(okHttpClient) 34 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 35 | .addConverterFactory(converterFactory) 36 | .build(), 37 | val chain: ChainApi = retrofit.create(ChainApi::class.java), 38 | val history: HistoryApi = retrofit.create(HistoryApi::class.java) 39 | ) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/main/java/com/memtrip/eos/abi/writer/preprocessor/gen/RootMap.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.preprocessor.gen; 17 | 18 | import com.memtrip.eos.abi.writer.preprocessor.model.AbiModel; 19 | import com.memtrip.eos.abi.writer.preprocessor.model.AbiWriterModel; 20 | 21 | import java.util.HashMap; 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | class RootMap implements DataMap { 26 | 27 | private final AbiWriterModel abiWriterModel; 28 | private final List abiModelList; 29 | 30 | RootMap(AbiWriterModel abiWriterModel, List abiModelList) { 31 | this.abiWriterModel = abiWriterModel; 32 | this.abiModelList = abiModelList; 33 | } 34 | 35 | @Override 36 | public Map map() { 37 | Map map = new HashMap<>(); 38 | map.put("class_postfix", abiWriterModel.getClassName()); 39 | map.put("package_name", abiWriterModel.getClassPackage()); 40 | map.put("abi_list", abiModelList); 41 | return map; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/transaction/account/actions/delegatebw/DelegateBandwidthArgs.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.chain.actions.transaction.account.actions.delegatebw 17 | 18 | import com.memtrip.eos.abi.writer.Abi 19 | import com.memtrip.eos.abi.writer.AccountNameCompress 20 | import com.memtrip.eos.abi.writer.AssetCompress 21 | import com.memtrip.eos.abi.writer.IntCompress 22 | 23 | @Abi 24 | data class DelegateBandwidthArgs( 25 | val from: String, 26 | val receiver: String, 27 | val stake_net_quantity: String, 28 | val stake_cpu_quantity: String, 29 | val transfer: Int 30 | ) { 31 | 32 | val getFrom: String 33 | @AccountNameCompress get() = from 34 | 35 | val getReceiver: String 36 | @AccountNameCompress get() = receiver 37 | 38 | val getStakeNetQuantity: String 39 | @AssetCompress get() = stake_net_quantity 40 | 41 | val getStakeCpuQuantity: String 42 | @AssetCompress get() = stake_cpu_quantity 43 | 44 | val getTransfer: Int 45 | @IntCompress get() = transfer 46 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/GetBlockHeaderStateTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.model.block.request.BlockNumOrId 5 | import com.memtrip.eos.http.rpc.utils.Config 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert.assertNotNull 13 | import org.junit.Assert.assertTrue 14 | import java.util.concurrent.TimeUnit 15 | 16 | // @RunWith(JUnitPlatform::class) 17 | class GetBlockHeaderStateTest : Spek({ 18 | 19 | given("an Api") { 20 | 21 | val okHttpClient by memoized { 22 | OkHttpClient.Builder() 23 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 24 | .connectTimeout(10, TimeUnit.SECONDS) 25 | .readTimeout(10, TimeUnit.SECONDS) 26 | .writeTimeout(10, TimeUnit.SECONDS) 27 | .build() 28 | } 29 | 30 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 31 | 32 | on("v1/chain/get_block_header_state") { 33 | 34 | val info = chainApi.getInfo().blockingGet() 35 | 36 | val block = chainApi.getBlockHeaderState(BlockNumOrId(info.body()!!.last_irreversible_block_num.toString())).blockingGet() 37 | 38 | it("should return block header state") { 39 | assertTrue(block.isSuccessful) 40 | assertNotNull(block.body()) 41 | } 42 | } 43 | } 44 | }) -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/ChainGetBlockTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.model.block.request.BlockNumOrId 5 | import com.memtrip.eos.http.rpc.utils.Config 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert.assertNotNull 13 | import org.junit.Assert.assertTrue 14 | import org.junit.platform.runner.JUnitPlatform 15 | import org.junit.runner.RunWith 16 | import java.util.concurrent.TimeUnit 17 | 18 | @RunWith(JUnitPlatform::class) 19 | class ChainGetBlockTest : Spek({ 20 | 21 | given("an Api") { 22 | 23 | val okHttpClient by memoized { 24 | OkHttpClient.Builder() 25 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 26 | .connectTimeout(10, TimeUnit.SECONDS) 27 | .readTimeout(10, TimeUnit.SECONDS) 28 | .writeTimeout(10, TimeUnit.SECONDS) 29 | .build() 30 | } 31 | 32 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 33 | 34 | on("v1/chain/get_block") { 35 | 36 | val info = chainApi.getInfo().blockingGet() 37 | 38 | val block = chainApi.getBlock(BlockNumOrId(info.body()!!.head_block_id)).blockingGet() 39 | 40 | it("should return block") { 41 | assertTrue(block.isSuccessful) 42 | assertNotNull(block.body()) 43 | } 44 | } 45 | } 46 | }) -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/abihex/UnDelegateBandwidthArgsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.abihex 2 | 3 | import com.memtrip.eos.abi.writer.compression.CompressionType 4 | import com.memtrip.eos.chain.actions.transaction.AbiBinaryGenTransactionWriter 5 | import com.memtrip.eos.chain.actions.transaction.account.actions.undelegatebw.UnDelegateBandwidthArgs 6 | import com.memtrip.eos.chain.actions.transaction.account.actions.undelegatebw.UnDelegateBandwidthBody 7 | import junit.framework.TestCase.assertEquals 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.platform.runner.JUnitPlatform 13 | import org.junit.runner.RunWith 14 | 15 | @RunWith(JUnitPlatform::class) 16 | class UnDelegateBandwidthArgsTest : Spek({ 17 | 18 | given("a transaction writer") { 19 | 20 | val transactionWriter by memoized { AbiBinaryGenTransactionWriter(CompressionType.NONE) } 21 | 22 | on("squish the undelegate bandwidth abi model") { 23 | 24 | val undelegateBandwidthArgs = UnDelegateBandwidthArgs( 25 | "memtripissue", 26 | "memtripproxy", 27 | "51.2345 EOS", 28 | "171.2345 EOS" 29 | ) 30 | val unDelegateBandwidthBody = UnDelegateBandwidthBody(undelegateBandwidthArgs) 31 | 32 | val output = transactionWriter.squishUnDelegateBandwidthBody(unDelegateBandwidthBody).toHex() 33 | 34 | it("should encode bytes as hex") { 35 | assertEquals("a034c6aeba9ba592e03bbdb5ba9ba59259d107000000000004454f5300000000d9201a000000000004454f5300000000", output) 36 | } 37 | } 38 | } 39 | }) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/test/java/com/memtrip/eos/abi/writer/preprocessor/model/PackedAction.java: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.abi.writer.preprocessor.model; 2 | 3 | import com.memtrip.eos.abi.writer.Abi; 4 | import com.memtrip.eos.abi.writer.AccountNameCollectionCompress; 5 | import com.memtrip.eos.abi.writer.AccountNameCompress; 6 | import com.memtrip.eos.abi.writer.CollectionCompress; 7 | import com.memtrip.eos.abi.writer.DataCompress; 8 | import com.memtrip.eos.abi.writer.NameCompress; 9 | 10 | import java.util.List; 11 | 12 | @Abi 13 | public class PackedAction { 14 | 15 | private final String account; 16 | private final String name; 17 | private final List authorization; 18 | private final String data; 19 | private final List producers; 20 | 21 | @AccountNameCompress 22 | public String account() { 23 | return account; 24 | } 25 | 26 | @NameCompress 27 | public String name() { 28 | return name; 29 | } 30 | 31 | @CollectionCompress 32 | public List authorization() { 33 | return authorization; 34 | } 35 | 36 | @DataCompress 37 | public String data() { 38 | return data; 39 | } 40 | 41 | @AccountNameCollectionCompress 42 | public List producers() { 43 | return producers; 44 | } 45 | 46 | public PackedAction( 47 | String account, 48 | String name, 49 | List authorization, 50 | String data, 51 | List producers 52 | ) { 53 | this.account = account; 54 | this.name = name; 55 | this.authorization = authorization; 56 | this.data = data; 57 | this.producers = producers; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /eos-chain-actions/src/test/kotlin/com/memtrip/eos/chain/actions/abihex/DelegateBandwidthArgsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.abihex 2 | 3 | import com.memtrip.eos.abi.writer.compression.CompressionType 4 | import com.memtrip.eos.chain.actions.transaction.AbiBinaryGenTransactionWriter 5 | import com.memtrip.eos.chain.actions.transaction.account.actions.delegatebw.DelegateBandwidthArgs 6 | import com.memtrip.eos.chain.actions.transaction.account.actions.delegatebw.DelegateBandwidthBody 7 | import junit.framework.TestCase.assertEquals 8 | 9 | import org.jetbrains.spek.api.Spek 10 | import org.jetbrains.spek.api.dsl.given 11 | import org.jetbrains.spek.api.dsl.it 12 | import org.jetbrains.spek.api.dsl.on 13 | import org.junit.platform.runner.JUnitPlatform 14 | import org.junit.runner.RunWith 15 | 16 | @RunWith(JUnitPlatform::class) 17 | class DelegateBandwidthArgsTest : Spek({ 18 | 19 | given("a transaction writer") { 20 | 21 | val transactionWriter by memoized { AbiBinaryGenTransactionWriter(CompressionType.NONE) } 22 | 23 | on("squish the delegate bandwidth abi model") { 24 | 25 | val delegateBandwidthArgs = DelegateBandwidthArgs( 26 | "memtripissue", 27 | "memtripproxy", 28 | "51.2345 EOS", 29 | "171.2345 EOS", 30 | 1 31 | ) 32 | val delegateBandwidthBody = DelegateBandwidthBody(delegateBandwidthArgs) 33 | 34 | val output = transactionWriter.squishDelegateBandwidthBody(delegateBandwidthBody).toHex() 35 | 36 | it("should encode bytes as hex") { 37 | assertEquals("a034c6aeba9ba592e03bbdb5ba9ba59259d107000000000004454f5300000000d9201a000000000004454f530000000001000000", output) 38 | } 39 | } 40 | } 41 | }) -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/base58/Base58Decode.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.base58 17 | 18 | import com.memtrip.eos.core.hash.RIPEMD160Digest 19 | import com.memtrip.eos.core.utils.BytesWithChecksum 20 | 21 | import org.bitcoinj.core.Base58 22 | import org.bitcoinj.core.Utils 23 | import java.util.Arrays 24 | 25 | class Base58Decode { 26 | 27 | fun decode(base58Data: String): BytesWithChecksum { 28 | val data = Base58.decode(base58Data) 29 | val checksum = decodeChecksum(data) 30 | return BytesWithChecksum(Arrays.copyOfRange(data, 0, data.size - 4), checksum) 31 | } 32 | 33 | private fun decodeChecksum(data: ByteArray): Long { 34 | val hashData = ByteArray(data.size - 4) 35 | System.arraycopy(data, 0, hashData, 0, data.size - 4) 36 | 37 | val hashChecksum = Utils.readUint32(RIPEMD160Digest.hash(hashData), 0) 38 | val dataChecksum = Utils.readUint32(data, data.size - 4) 39 | 40 | if (hashChecksum != dataChecksum) { 41 | throw IllegalArgumentException("Invalid format, checksum mismatch") 42 | } 43 | 44 | return dataChecksum 45 | } 46 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/ChainGetProducerTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.model.producer.request.GetProducers 5 | import com.memtrip.eos.http.rpc.utils.Config 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert 13 | import org.junit.platform.runner.JUnitPlatform 14 | import org.junit.runner.RunWith 15 | import java.util.concurrent.TimeUnit 16 | 17 | @RunWith(JUnitPlatform::class) 18 | class ChainGetProducerTest : Spek({ 19 | 20 | given("an Api") { 21 | 22 | val okHttpClient by memoized { 23 | OkHttpClient.Builder() 24 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 25 | .connectTimeout(10, TimeUnit.SECONDS) 26 | .readTimeout(10, TimeUnit.SECONDS) 27 | .writeTimeout(10, TimeUnit.SECONDS) 28 | .build() 29 | } 30 | 31 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 32 | 33 | on("v1/chain/get_producers") { 34 | 35 | val producers = chainApi.getProducers( 36 | GetProducers( 37 | true, 38 | "", 39 | 10 40 | ) 41 | ).blockingGet() 42 | 43 | it("should return a list of producers") { 44 | Assert.assertTrue(producers.isSuccessful) 45 | Assert.assertNotNull(producers.body()) 46 | } 47 | } 48 | } 49 | }) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/main/java/com/memtrip/eos/abi/writer/preprocessor/gen/Gen.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.preprocessor.gen; 17 | 18 | import com.google.googlejavaformat.java.FormatterException; 19 | import com.memtrip.eos.abi.writer.preprocessor.FreeMarker; 20 | import com.memtrip.eos.abi.writer.preprocessor.SourceFileGenerator; 21 | 22 | import java.io.IOException; 23 | 24 | abstract class Gen { 25 | 26 | private final FreeMarker freeMarker; 27 | private final SourceFileGenerator sourceFileGenerator; 28 | 29 | Gen(FreeMarker freeMarker, SourceFileGenerator sourceFileGenerator) { 30 | this.freeMarker = freeMarker; 31 | this.sourceFileGenerator = sourceFileGenerator; 32 | } 33 | 34 | void write( 35 | String templateFilePath, 36 | T templateData, 37 | String outputFilePackage, 38 | String outputFileNameWithoutExtension 39 | ) throws IOException, FormatterException { 40 | String body = freeMarker.generate(templateFilePath, templateData); 41 | sourceFileGenerator.create(outputFilePackage, outputFileNameWithoutExtension, body); 42 | } 43 | } -------------------------------------------------------------------------------- /eos-core/src/main/kotlin/com/memtrip/eos/core/crypto/signature/SecP256K1KeyCurve.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.core.crypto.signature 17 | 18 | import com.memtrip.eos.core.hex.DefaultHexWriter 19 | 20 | import org.spongycastle.math.ec.ECPoint 21 | import org.spongycastle.math.ec.custom.sec.SecP256K1Curve 22 | 23 | import java.math.BigInteger 24 | 25 | class SecP256K1KeyCurve constructor( 26 | GxInHex: String = "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", 27 | GyInHex: String = "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8", 28 | nInHex: String = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", 29 | private val curve: SecP256K1Curve = SecP256K1Curve(), 30 | private val G: ECPoint = curve.decodePoint(DefaultHexWriter().hexToBytes("04$GxInHex$GyInHex")), 31 | private val n: BigInteger = BigInteger(nInHex, 16), 32 | private val h: BigInteger = n.shiftRight(1) 33 | ) : KeyCurve { 34 | 35 | override fun curve(): SecP256K1Curve = curve 36 | 37 | override fun G(): ECPoint = G 38 | 39 | override fun n(): BigInteger = n 40 | 41 | override fun h(): BigInteger = h 42 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/ChainGetCodeTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.model.contract.request.GetCodeByAccountName 5 | import com.memtrip.eos.http.rpc.utils.Config 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert.assertNotEquals 13 | import org.junit.Assert.assertNotNull 14 | import org.junit.Assert.assertTrue 15 | import org.junit.platform.runner.JUnitPlatform 16 | import org.junit.runner.RunWith 17 | import java.util.concurrent.TimeUnit 18 | 19 | @RunWith(JUnitPlatform::class) 20 | class ChainGetCodeTest : Spek({ 21 | 22 | given("an Api") { 23 | 24 | val okHttpClient by memoized { 25 | OkHttpClient.Builder() 26 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 27 | .connectTimeout(10, TimeUnit.SECONDS) 28 | .readTimeout(10, TimeUnit.SECONDS) 29 | .writeTimeout(10, TimeUnit.SECONDS) 30 | .build() 31 | } 32 | 33 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 34 | 35 | on("v1/chain/get_code as wasm") { 36 | 37 | val code = chainApi.getCode(GetCodeByAccountName("eosio.token", true)).blockingGet() 38 | 39 | it("should return the code deployed by the account") { 40 | assertTrue(code.isSuccessful) 41 | assertNotNull(code.body()) 42 | assertNotEquals(code.body()!!.wasm, "") 43 | } 44 | } 45 | } 46 | }) -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/ChainGetCurrencyStatsTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.model.contract.request.GetCurrencyStats 5 | import com.memtrip.eos.http.rpc.utils.Config 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert.assertNotNull 13 | import org.junit.Assert.assertTrue 14 | import org.junit.platform.runner.JUnitPlatform 15 | import org.junit.runner.RunWith 16 | import java.util.concurrent.TimeUnit 17 | 18 | @RunWith(JUnitPlatform::class) 19 | class ChainGetCurrencyStatsTest : Spek({ 20 | 21 | given("an Api") { 22 | 23 | val okHttpClient by memoized { 24 | OkHttpClient.Builder() 25 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 26 | .connectTimeout(10, TimeUnit.SECONDS) 27 | .readTimeout(10, TimeUnit.SECONDS) 28 | .writeTimeout(10, TimeUnit.SECONDS) 29 | .build() 30 | } 31 | 32 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 33 | 34 | on("v1/chain/get_currency_stats") { 35 | 36 | val currencyBalance = chainApi.getCurrencyStats(GetCurrencyStats( 37 | "eosio.token", 38 | "EOS" 39 | )).blockingGet() 40 | 41 | it("should return currency balances for the account") { 42 | assertTrue(currencyBalance.isSuccessful) 43 | assertNotNull(currencyBalance.body()!!) 44 | } 45 | } 46 | } 47 | }) -------------------------------------------------------------------------------- /eos-core/src/test/kotlin/com/memtrip/eos/core/hash/HmacTests.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.core.hash 2 | 3 | import com.memtrip.eos.core.hex.DefaultHexWriter 4 | 5 | import org.junit.Assert.assertTrue 6 | import org.junit.Test 7 | 8 | class HmacTests { 9 | 10 | @Test 11 | fun testVector1() { 12 | 13 | val hexWriter = DefaultHexWriter() 14 | 15 | val key = hexWriter.hexToBytes("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b") 16 | val data = hexWriter.hexToBytes("4869205468657265") 17 | val expected_256 = hexWriter.hexToBytes("b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7") 18 | val result_256 = HMac.hash(key, data) 19 | 20 | assertTrue(result_256.contentEquals(expected_256)) 21 | } 22 | 23 | @Test 24 | fun testVector2() { 25 | 26 | val hexWriter = DefaultHexWriter() 27 | 28 | val key = hexWriter.hexToBytes("4a656665") 29 | val data = hexWriter.hexToBytes("7768617420646f2079612077616e7420666f72206e6f7468696e673f") 30 | val expected_256 = hexWriter.hexToBytes("5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843") 31 | val result_256 = HMac.hash(key, data) 32 | 33 | assertTrue(result_256.contentEquals(expected_256)) 34 | } 35 | 36 | @Test 37 | fun testVector3() { 38 | 39 | val hexWriter = DefaultHexWriter() 40 | 41 | val key = hexWriter.hexToBytes("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") 42 | val data = hexWriter.hexToBytes("dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd") 43 | val expected_256 = hexWriter.hexToBytes("773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe") 44 | val result_256 = HMac.hash(key, data) 45 | 46 | assertTrue(result_256.contentEquals(expected_256)) 47 | } 48 | } -------------------------------------------------------------------------------- /eos-chain-actions/src/main/kotlin/com/memtrip/eos/chain/actions/query/ramprice/GetRamPrice.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.chain.actions.query.ramprice 2 | 3 | import com.memtrip.eos.http.rpc.ChainApi 4 | import com.memtrip.eos.http.rpc.model.contract.request.GetTableRows 5 | import io.reactivex.Single 6 | import java.math.BigDecimal 7 | 8 | class GetRamPrice( 9 | private val chainApi: ChainApi 10 | ) { 11 | 12 | fun getPricePerKilobyte(): Single { 13 | return chainApi.getTableRows(GetTableRows( 14 | "eosio", 15 | "eosio", 16 | "rammarket", 17 | "", 18 | true, 19 | 1, 20 | "", 21 | "", 22 | "", 23 | "", 24 | "dec" 25 | )).map { response -> 26 | if (response.isSuccessful) { 27 | val tableRows = response.body()!!.rows 28 | if (tableRows.isNotEmpty()) { 29 | calculateRamPerKiloByte(tableRows[0]) 30 | } else { 31 | throw FailedToGetRamPrice() 32 | } 33 | } else { 34 | throw FailedToGetRamPrice() 35 | } 36 | } 37 | } 38 | 39 | @Suppress("UNCHECKED_CAST") 40 | private fun calculateRamPerKiloByte(row: Map): Double { 41 | val quote = row["quote"] as Map 42 | val base = row["base"] as Map 43 | 44 | val quoteBalance = value(quote["balance"]!!) 45 | val baseBalance = value(base["balance"]!!) 46 | 47 | return (quoteBalance.toDouble() / (baseBalance.toDouble()) * 1024) 48 | } 49 | 50 | private fun value(balance: String): BigDecimal { 51 | val split = balance.split(" ")[0] 52 | return BigDecimal(split) 53 | } 54 | 55 | class FailedToGetRamPrice : Exception() 56 | } -------------------------------------------------------------------------------- /eos-http-rpc/src/test/kotlin/com/memtrip/eos/http/rpc/chain/ChainGetCurrencyBalanceTest.kt: -------------------------------------------------------------------------------- 1 | package com.memtrip.eos.http.rpc.chain 2 | 3 | import com.memtrip.eos.http.rpc.Api 4 | import com.memtrip.eos.http.rpc.model.contract.request.GetCurrencyBalance 5 | import com.memtrip.eos.http.rpc.utils.Config 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import org.jetbrains.spek.api.Spek 9 | import org.jetbrains.spek.api.dsl.given 10 | import org.jetbrains.spek.api.dsl.it 11 | import org.jetbrains.spek.api.dsl.on 12 | import org.junit.Assert.assertNotNull 13 | import org.junit.Assert.assertTrue 14 | import org.junit.platform.runner.JUnitPlatform 15 | import org.junit.runner.RunWith 16 | import java.util.concurrent.TimeUnit 17 | 18 | @RunWith(JUnitPlatform::class) 19 | class ChainGetCurrencyBalanceTest : Spek({ 20 | 21 | given("an Api") { 22 | 23 | val okHttpClient by memoized { 24 | OkHttpClient.Builder() 25 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) 26 | .connectTimeout(10, TimeUnit.SECONDS) 27 | .readTimeout(10, TimeUnit.SECONDS) 28 | .writeTimeout(10, TimeUnit.SECONDS) 29 | .build() 30 | } 31 | 32 | val chainApi by memoized { Api(Config.CHAIN_API_BASE_URL, okHttpClient).chain } 33 | 34 | on("v1/chain/get_currency_balance") { 35 | 36 | val currencyBalance = chainApi.getCurrencyBalance(GetCurrencyBalance( 37 | "eosio.token", 38 | "memtripissue", 39 | "EOS" 40 | )).blockingGet() 41 | 42 | it("should return currency balances for the account") { 43 | assertTrue(currencyBalance.isSuccessful) 44 | assertNotNull(currencyBalance.body()!![0]) 45 | } 46 | } 47 | } 48 | }) -------------------------------------------------------------------------------- /eos-abi-writer-preprocessor/src/main/java/com/memtrip/eos/abi/writer/preprocessor/gen/RootGen.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.preprocessor.gen; 17 | 18 | import com.google.googlejavaformat.java.FormatterException; 19 | import com.memtrip.eos.abi.writer.preprocessor.FreeMarker; 20 | import com.memtrip.eos.abi.writer.preprocessor.SourceFileGenerator; 21 | import com.memtrip.eos.abi.writer.preprocessor.model.AbiWriterModel; 22 | 23 | import java.io.IOException; 24 | 25 | class RootGen extends Gen { 26 | 27 | private final AbiWriterModel abiWriterModel; 28 | private final RootMap rootMap; 29 | 30 | RootGen( 31 | AbiWriterModel abiWriterModel, 32 | RootMap rootMap, 33 | FreeMarker freeMarker, 34 | SourceFileGenerator sourceFileGenerator 35 | ) { 36 | 37 | super(freeMarker, sourceFileGenerator); 38 | 39 | this.abiWriterModel = abiWriterModel; 40 | this.rootMap = rootMap; 41 | } 42 | 43 | void write() throws IOException, FormatterException { 44 | super.write( 45 | "AbiBinaryGen.template", 46 | rootMap, 47 | abiWriterModel.getClassPackage(), 48 | "AbiBinaryGen" + abiWriterModel.getClassName()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /eos-abi-writer/src/main/kotlin/com/memtrip/eos/abi/writer/bytewriter/AssetWriter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2013-present memtrip LTD. 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 | package com.memtrip.eos.abi.writer.bytewriter 17 | 18 | import com.memtrip.eos.abi.writer.ByteWriter 19 | import java.util.regex.Pattern 20 | 21 | class AssetWriter( 22 | private val currencySymbolWriter: CurrencySymbolWriter = CurrencySymbolWriter() 23 | ) { 24 | 25 | fun put(asset: String, writer: ByteWriter) { 26 | 27 | val value = asset.trim() 28 | 29 | val pattern = Pattern.compile("^([0-9]+)\\.?([0-9]*)([ ][a-zA-Z0-9]{1,7})?$") 30 | val matcher = pattern.matcher(value) 31 | 32 | if (matcher.find()) { 33 | val beforeDotVal = matcher.group(1) 34 | val afterDotVal = matcher.group(2) 35 | 36 | val symbol = if (matcher.group(3).isEmpty()) null else matcher.group(3).trim() 37 | 38 | val amount = (beforeDotVal + afterDotVal).toLong() 39 | 40 | writer.putLong(amount) 41 | 42 | if (symbol != null) { 43 | currencySymbolWriter.put(afterDotVal.length, symbol, writer) 44 | } else { 45 | writer.putLong(0) 46 | } 47 | } else { 48 | throw IllegalArgumentException("invalid asset format") 49 | } 50 | } 51 | } --------------------------------------------------------------------------------