Skip to content

Commit

Permalink
Merge pull request #103 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.17.2
  • Loading branch information
anton6tak authored Jan 20, 2022
2 parents 7570741 + 0a88a67 commit d7b8df2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {
project build.gradle
```groovy
dependencies {
commonMainApi("dev.icerock.moko:web3:0.17.1")
commonMainApi("dev.icerock.moko:web3:0.17.2")
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ kbignumVersion = "2.2.0"
klockVersion = "2.2.2"
ktorClientVersion = "1.6.1"
mokoTestVersion = "0.4.0"
mokoWeb3Version = "0.17.1"
mokoWeb3Version = "0.17.2"
multidexVersion = "2.0.1"

[libraries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ suspend fun Web3Executor.getEstimateGas(gasPrice: BigInt, to: EthereumAddress =
executeBatch(Web3Requests.getEstimateGas(gasPrice, to)).first()

suspend fun Web3Executor.getEstimateGas(
from: EthereumAddress,
gasPrice: BigInt,
from: EthereumAddress? = null,
gasPrice: BigInt? = null,
to: EthereumAddress,
callData: HexString,
value: BigInt = 0.bi
callData: HexString? = null,
value: BigInt? = null
): BigInt =
executeBatch(
Web3Requests.getEstimateGas(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package dev.icerock.moko.web3.requests

import com.soywiz.kbignum.BigInt
import com.soywiz.kbignum.bi
import dev.icerock.moko.web3.BlockHash
import dev.icerock.moko.web3.BlockInfo
import dev.icerock.moko.web3.BlockState
Expand Down Expand Up @@ -126,22 +125,22 @@ object Web3Requests {

@Serializable
private data class GetExtendedEstimateGasObject(
val from: EthereumAddress,
val from: EthereumAddress?,
val to: EthereumAddress,
@Serializable(with = BigIntSerializer::class)
val gasPrice: BigInt,
val gasPrice: BigInt?,
@SerialName("data")
val callData: HexString,
val callData: HexString?,
@Serializable(with = BigIntSerializer::class)
val value: BigInt
val value: BigInt?
)

fun getEstimateGas(
from: EthereumAddress,
gasPrice: BigInt,
from: EthereumAddress?,
gasPrice: BigInt?,
to: EthereumAddress,
callData: HexString,
value: BigInt = 0.bi
callData: HexString?,
value: BigInt?
): Web3RpcRequest<*, BigInt> = Web3RpcRequest(
method = "eth_estimateGas",
params = listOf(
Expand Down
8 changes: 4 additions & 4 deletions web3/src/commonTest/kotlin/dev.icerock.moko.web3/Web3Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,11 @@ class Web3Test {
val web3 = Web3("https://bsc.getblock.io/testnet/?api_key=94c96d69-74f0-40e7-8202-eac4b49e6bfc")
val price = web3.getGasPrice()
val callData =
HexString("0x38ed17390000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000000000019bc096da353600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000140e21fcfb1e602a1626198d3dbbb58087b59b4e0000000000000000000000000000000000000000000000000000000061e7e45100000000000000000000000000000000000000000000000000000000000000030000000000000000000000009a01bf917477dd9f5d715d188618fc8b7350cd22000000000000000000000000ae13d989dac2f0debff460ac112a837c89baa7cd00000000000000000000000041b5984f45afb2560a0ed72bb69a98e8b32b3cca")
val to = ContractAddress("0xd99d1c33f9fc3444f8101754abc46c52416550d1")
val from = EthereumAddress("0x140e21FcFB1E602A1626198d3DbBB58087b59b4E")
HexString("0x38ed17390000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000002e57839a043800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000140e21fcfb1e602a1626198d3dbbb58087b59b4e0000000000000000000000000000000000000000000000000000000061e8f26700000000000000000000000000000000000000000000000000000000000000030000000000000000000000009a01bf917477dd9f5d715d188618fc8b7350cd22000000000000000000000000ae13d989dac2f0debff460ac112a837c89baa7cd00000000000000000000000041b5984f45afb2560a0ed72bb69a98e8b32b3cca")
val to = ContractAddress("0xc43d2c472cf882e0b190063d66ee8ce78bf54da1")
val from = EthereumAddress("0x140e21fcfb1e602a1626198d3dbbb58087b59b4e")
println("GAS Price: $price")
println("GAS Limit: ${web3.getEstimateGas(from, price, to, callData).toBigNum().times(1.1.bn)}")
println("GAS Limit: ${web3.getEstimateGas(to = to, from = from).toBigNum().times(1.1.bn)}")
}
}
}
Expand Down

0 comments on commit d7b8df2

Please sign in to comment.