-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support RPC 0.6.0 #358
Support RPC 0.6.0 #358
Conversation
@@ -33,6 +33,15 @@ enum class TransactionType(val txPrefix: Felt) { | |||
L1_HANDLER(Felt.fromHex("0x6c315f68616e646c6572")), // encodeShortString('l1_handler') | |||
} | |||
|
|||
@Serializable | |||
enum class DAMode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's DA_MODE
in the spec, but naming this DAMode
seems very non-java, so maybe we should deviate from the spec a bit and rename it to DataAvailabilityMode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it as is
Blocked by #326 |
…tions to StandardAccount
fun toMaxFee(overhead: Double = 0.5): Felt { | ||
return addOverhead(overallFee.value, overhead).toFelt | ||
} | ||
|
||
fun toResourceBounds( | ||
amountOverhead: Double = 0.1, | ||
unitPriceOverhead: Double = 0.5, | ||
): ResourceBoundsMapping { | ||
val maxAmount = addOverhead(gasConsumed.value, amountOverhead).toUint64 | ||
val maxPricePerUnit = addOverhead(gasPrice.value, unitPriceOverhead).toUint128 | ||
|
||
// As of Starknet 0.13.0, the L2 gas is not supported | ||
// Because of this, the L2 gas values are hardcoded to 0 | ||
return ResourceBoundsMapping( | ||
l1Gas = ResourceBounds(maxAmount = maxAmount, maxPricePerUnit = maxPricePerUnit), | ||
l2Gas = ResourceBounds(maxAmount = Uint64.ZERO, maxPricePerUnit = Uint128.ZERO), | ||
) | ||
} | ||
private fun addOverhead(value: BigInteger, overhead: Double): BigInteger { | ||
val multiplier = ((1 + overhead) * 100).roundToInt().toBigInteger() | ||
return value.multiply(multiplier).divide(BigInteger.valueOf(100)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically don't define several methods inside files with just dataclasses.
However, I think the way it was done (just plain function), is sub-optimal, since we shouldn't really get max fee or resource bounds without having estimate response.
We could:
- move this particular response to separate file
- define those methods as extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make an issue and think about it at later date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, #375
companion object { | ||
@field:JvmField | ||
val ZERO = ResourceBounds(Uint64.ZERO, Uint128.ZERO) | ||
} | ||
|
||
fun toMaxFee(): Felt { | ||
return maxAmount.value.multiply(maxPricePerUnit.value).toFelt | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar as above, convenience methods that could be changed to extensions, moved to another file or left as is.
Co-authored-by: Wojciech Szymczyk <[email protected]>
Co-authored-by: Wojciech Szymczyk <[email protected]>
lib/src/main/kotlin/com/swmansion/starknet/data/serializers/NumAsHexSerializers.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll fix some of design issues etc in consecutive PRs
Describe your changes
instead of deploying one
InvokeTransactionPayload
->InvokeTransactionV1Payload
DeployAccountTransactionPayload
->DeployAccountTransactionV1Payload
Account
andStandardAccount
: add methods to support v3 transactionsParams.kt
ExecutionParams
to itParamsV3
ExecutionParamsV3
DeclareParamsV3
DeployAccountParamsV3
sign
variations for signing v3 invoke transactionssignDeployAccount
variations for signing v3 deploy account transactionssignDeclare
variations for signing v3 declare transactionsexecuteV3
for singing and sending v3 invoke transactionsestimateFeeV3
for estimating fee of v3 transactionsAccount
interface to make methods more coherentProvider
andStandardProvider
:SimulationFlagForEstimateFee
SKIP_VALIDATE
by defaultAccount
,Provider
)TransactionHashCalculator
NumAsHexBase
types:Uint64
,Uint128
NumAsHexSerializer
,FeltSerializer
, addUint128Serializer
andUint64Serializer
Uint256
conform toNumAsHex
baseTransactionPayloadSerilalizer
EstimateFeeResponse
ResourcePrice
:priceInStark
->princeInFri
PriceUnit
ResourceBounds
andResourceBoundsMapping
ExecutionResources
: all fields changed fromNumAsHex
toint
; addsegmentArenaApplications
FunctionInvocation
(trace API): addexecution_resources
DAMode
Linked issues
Closes #356
Breaking changes