-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Readme and some tests to :erc961 (#157)
* Add EIP961 doc for :erc961 module * Add EIP961 extensions tests
- Loading branch information
Showing
9 changed files
with
131 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package org.kethereum.erc831 | ||
|
||
// as defined in http://eips.ethereum.org/EIPS/eip-831 | ||
|
||
/** | ||
* as defined in [EIP-831](https://eips.ethereum.org/EIPS/eip-831) | ||
*/ | ||
data class ERC831( | ||
var scheme: String? = null, | ||
var prefix: String? = null, | ||
var payload: String? = null | ||
var scheme: String? = null, | ||
var prefix: String? = null, | ||
var payload: String? = null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
This module provides and implements methods for working with [EIP-961](https://github.com/ethereum/EIPs/pull/961) | ||
|
||
### Installation | ||
[![](https://jitpack.io/v/komputing/kethereum.svg)](https://jitpack.io/#komputing/kethereum) | ||
```groovy | ||
implementation("com.github.komputing.kethereum:model:$KETHEREUM_VERSION") | ||
implementation("com.github.komputing.kethereum:erc961:$KETHEREUM_VERSION") | ||
``` | ||
|
||
### Usage | ||
#### Generating EIP-961 token URL | ||
```kotlin | ||
val address = Address(0x00AB42) | ||
val chainId = ChainId(4) | ||
val erc20Token = Token("TST", address, chainId) | ||
val eip651Url: String = erc20Token.generateURL() | ||
|
||
println(eip651Url) // ethereum:token_info-0x00AB42@4?symbol=TST | ||
``` | ||
|
||
#### Working with EIP-961 token URL | ||
```kotlin | ||
val exampleUrl = "ethereum:token_info-0x00AB42@4?symbol=TST" | ||
|
||
println(isEthereumTokenURI(exampleUri)) // true | ||
val tokenFromUrl: Token = parseTokenFromEthereumURI(exampleUrl) | ||
println(tokenFromUrl) // Token(symbol="TST", address=0x00AB42, chainId=4, decimals=18) | ||
|
||
// also there are extension methods for EthereumURI class | ||
val uri = EthereumURI(exampleUrl) | ||
println(uri.isTokenURI()) // true | ||
println(uri.parseToken()) // Token(symbol="TST", address=0x00AB42, chainId=4, decimals=18) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
model/src/main/kotlin/org/kethereum/model/SignedTransaction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package org.kethereum.model | ||
|
||
data class SignedTransaction( | ||
var transaction: Transaction, | ||
var signatureData: SignatureData | ||
var transaction: Transaction, | ||
var signatureData: SignatureData | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package org.kethereum.model | ||
|
||
data class Token(val symbol: String, | ||
val address: Address, | ||
val chain: ChainId, | ||
val decimals: Int = 18, | ||
val type: String? = null, | ||
val name: String? = null) | ||
data class Token( | ||
val symbol: String, | ||
val address: Address, | ||
val chain: ChainId, | ||
val decimals: Int = 18, | ||
val type: String? = null, | ||
val name: String? = null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters