Skip to content
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 Starknet 0.13 #129

Merged
merged 103 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
e620f49
Add simulation flags for fee estimate
DelevoXDG Jan 5, 2024
58b6e24
Add BigUInt.toNumAsHex extension
DelevoXDG Jan 9, 2024
d9e1040
Move numerical types from ../Hex/
DelevoXDG Jan 9, 2024
7321782
Add UInt64AsHex and UInt128AsHex
DelevoXDG Jan 9, 2024
c987bf4
Add NumbersTest; Add Felt-specific tests to FeltTests
DelevoXDG Jan 9, 2024
5ef6b81
Add StarknetDAMode
DelevoXDG Jan 9, 2024
84999c7
Add ResourceBounds
DelevoXDG Jan 9, 2024
312f84c
Move ExecutionResources.swift, TransactionStatus.swift, TransactionTy…
DelevoXDG Jan 9, 2024
12fa1d1
Merge branch 'main' into feat/124-starknet-0.13.0
DelevoXDG Jan 9, 2024
97127a7
Add public constructors to StarknetResourceBoundsMapping and Starknet…
DelevoXDG Jan 9, 2024
ec8ec91
Format
DelevoXDG Jan 9, 2024
a9cf3ea
Merge branch 'main' into feat/124-starknet-0.13.0
DelevoXDG Jan 10, 2024
ac4d8a0
Add new Transaction protocols
DelevoXDG Jan 10, 2024
ec4b583
Add StarknetPaymasterData, StarknetAccountDeploymentData typealiases
DelevoXDG Jan 10, 2024
984c44b
Add v3 transactions; Update old ones to conform to new protocols
DelevoXDG Jan 10, 2024
a77efa0
Support tx v3 hash calculations
DelevoXDG Jan 10, 2024
63ac9a4
Misc change
DelevoXDG Jan 10, 2024
f7b0f2d
Refactor StarknetDAMode
DelevoXDG Jan 10, 2024
db5ef92
Use StarknetExecutableTransaction instead StarknetTransaction as para…
DelevoXDG Jan 11, 2024
67b6700
Fix AddInvokeTransactionParams and Provider.AddInvokeTransaction
DelevoXDG Jan 11, 2024
fedbbd0
Update JsonRpcError to include data field
DelevoXDG Jan 11, 2024
b49e311
Format
DelevoXDG Jan 11, 2024
b6d9349
Fix StarknetAccount.verify
DelevoXDG Jan 11, 2024
7b0bd46
Bump devnet; Disable tests (#130)
DelevoXDG Jan 11, 2024
df506a2
Update estimateFee: add simulationFlags
DelevoXDG Jan 11, 2024
03c3cc5
Update est fee test
DelevoXDG Jan 11, 2024
924bccc
Format
DelevoXDG Jan 11, 2024
4833d6d
Change v3 field order
DelevoXDG Jan 11, 2024
b21e226
Add ExecutionParamsV3, rename ExecutionParams -> DeprecatedExecutionP…
DelevoXDG Jan 11, 2024
5a5c048
Add ExecutionParamsV3, rename ExecutionParams -> DeprecatedExecutionP…
DelevoXDG Jan 11, 2024
61d5ff6
Remove redundand StarknetAccountestimateVersion
DelevoXDG Jan 11, 2024
a2090b8
Add PriceUnit
DelevoXDG Jan 15, 2024
b881e8e
Add clamping initializer to NumAsHex and NumAsHexProtocol
DelevoXDG Jan 15, 2024
3def07c
Allow any StarknetExecutableInvokeTransaction in addInvokeTransaction
DelevoXDG Jan 15, 2024
2dcbdef
Support optional ExecutionParamsV3; Remove
DelevoXDG Jan 15, 2024
5b58e48
Add some extra BigUInt extensions
DelevoXDG Jan 15, 2024
5e8e508
Add StarknetFeeEstimate.toResourceBounds; Refactor FeeUtils
DelevoXDG Jan 15, 2024
b459fdc
Support executeV3
DelevoXDG Jan 15, 2024
96d5e4f
Fix poseidon (shouldnt use specific cases when list is passed)
DelevoXDG Jan 15, 2024
38ff479
Add accountDeploymentData to StarknetExecutionParamsV3
DelevoXDG Jan 15, 2024
5be6549
Provider: suppport deploy account v3
DelevoXDG Jan 15, 2024
2e9b05e
Support error data as a String
DelevoXDG Jan 15, 2024
8bbacc1
Account: support signDeployAccountV3, estimateDeployAccountV3Fee
DelevoXDG Jan 15, 2024
9998215
Devnet.prefundAccount: support passing unit (prefund with STRK)
DelevoXDG Jan 15, 2024
f34493a
Adjust tests
DelevoXDG Jan 15, 2024
15c89db
Add remaning Account methods
DelevoXDG Jan 16, 2024
aef79fe
Rename defaultSimulationFlags -> defaultSimulationFlagsForEstimateFee
DelevoXDG Jan 16, 2024
fa4e2a2
Adjust tests
DelevoXDG Jan 16, 2024
08721c5
Add l1_l2 contract
DelevoXDG Jan 16, 2024
18b8a2c
Fix estimate message fee test (#89)
DelevoXDG Jan 16, 2024
b3df9fd
Reenable spec version test
DelevoXDG Jan 16, 2024
09d2bd7
Add account to ProviderTests
DelevoXDG Jan 16, 2024
ce2a7aa
Re-enable estimate invoke v1; Add estimate tests (inv v3, deploy acc …
DelevoXDG Jan 16, 2024
9fabbe7
Fix testSimulateTransactionsV1
DelevoXDG Jan 16, 2024
16e854b
Remove redundand EstimateFeeTests (now tested on devnet)
DelevoXDG Jan 16, 2024
93542df
Adjust sim tx v1 tests; Add sim tx v3 tests
DelevoXDG Jan 16, 2024
5fb8d56
Simplify fee estimation mechanism in StarknetAccount
DelevoXDG Jan 16, 2024
24355f5
Add StarknetFeeEstimate.toMaxFee; Test new fee utils
DelevoXDG Jan 16, 2024
78339f3
Add StarknetFeePayment
DelevoXDG Jan 16, 2024
0f6fd68
Tx receipt: change `actualFee` type from `Felt` to `StarknetFeePayment`
DelevoXDG Jan 16, 2024
415c298
Use ints in StarknetExecutionResources
DelevoXDG Jan 16, 2024
5e415f5
Update provider tests; Add missing tests
DelevoXDG Jan 16, 2024
c7912d1
DevnetClient: cache deployed accounts
DelevoXDG Jan 16, 2024
f57d625
Add testExecuteV3CustomParams
DelevoXDG Jan 16, 2024
4272b1a
Test estimateFee w/ and w/o flags
DelevoXDG Jan 16, 2024
167501a
Refactor sim tx tests
DelevoXDG Jan 16, 2024
1eaca7e
Remove redundand testSimulateTransactionsResponseDecoding
DelevoXDG Jan 16, 2024
ec00b37
Fix tx receipt tests
DelevoXDG Jan 16, 2024
5ab72b8
Add v1 postfix to account methods
DelevoXDG Jan 17, 2024
bc0bbda
Clean up tests; Add strk contract address to devnet constants
DelevoXDG Jan 17, 2024
371d139
Fix tx receipt test
DelevoXDG Jan 17, 2024
877c3aa
Rename WrappedSequencerTransaction -> WrappedExecutableTransaction
DelevoXDG Jan 17, 2024
438157d
Refactor Account for consistency
DelevoXDG Jan 17, 2024
7c73ec0
Remove redundant parameter from doc description
DelevoXDG Jan 17, 2024
fce2d46
Format doc descriptions
DelevoXDG Jan 17, 2024
b11c88e
Use .toMaxFee method instead of estimatedFeeToMaxFee
DelevoXDG Jan 17, 2024
b9ce2f9
Move StarknetFeePayment and StarknetPriceUnit to better locations
DelevoXDG Jan 17, 2024
67e2b7d
Make StarknetDeployAccountTransaction and StarknetDeclareTransaction …
DelevoXDG Jan 17, 2024
92c69fc
Clean up docs comments in Provider
DelevoXDG Jan 17, 2024
7d07e02
Update attribution to l1_l2.cairo
DelevoXDG Jan 17, 2024
4db38a9
Review changes
DelevoXDG Jan 17, 2024
93f9524
Add missing compiledClassHash to declare v3 tx
DelevoXDG Jan 19, 2024
465df84
Update TransactionWrapper to handle v3s
DelevoXDG Jan 19, 2024
9ac6286
Test v3s in TransactionTests
DelevoXDG Jan 19, 2024
c6c3c4f
Rename computeCommonTransactionV3Fields -> prepareCommonTransactionV3…
DelevoXDG Jan 19, 2024
78d34f1
Account: Add skipValidate flag to estimate funcs (invoke and deploy)
DelevoXDG Jan 22, 2024
df72e66
Don't skip validate by default in Provider
DelevoXDG Jan 22, 2024
6a6c17a
Update estimate fee tests
DelevoXDG Jan 22, 2024
0936205
Add misssing params descriptions
DelevoXDG Jan 22, 2024
9aa4a52
Fix typos in Provider
DelevoXDG Jan 22, 2024
0c8b84b
Remove estimatedFeeToMaxFee in favor of StarknetFeeEstimate.toMaxFee
DelevoXDG Jan 22, 2024
ddd5d7d
Merge branch 'main' into feat/124-starknet-0.13.0
DelevoXDG Jan 22, 2024
c443ddd
Separate StarknetExecutionParamsV3 into invoke and deploy account var…
DelevoXDG Jan 22, 2024
9fac5b2
Account: Don't skipValidate by default in estimateFee methods
DelevoXDG Jan 23, 2024
acd1c7b
Add nonce=0 constructor for StarknetDeployAccountParamsV3
DelevoXDG Jan 23, 2024
f32c4aa
Remove unused StarknetOptionalDeployAccountParamsV3
DelevoXDG Jan 23, 2024
4914065
Add StarknetFeeEstimate.toMaxFee description
DelevoXDG Jan 23, 2024
0e95ff6
Fix minor inconsistency
DelevoXDG Jan 23, 2024
d749a6e
Format
DelevoXDG Jan 23, 2024
e6da91b
Add more error w/ data tests
DelevoXDG Jan 23, 2024
e257da3
Remove v3 postfix from v3 params
DelevoXDG Jan 23, 2024
02dc74d
Refactor params
DelevoXDG Jan 24, 2024
50d6515
Remove command printing in DevnetClient
DelevoXDG Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/Starknet/Accounts/StarknetAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public class StarknetAccount: StarknetAccountProtocol {
if errorMessage.contains("Signature"), errorMessage.contains("is invalid") {
return false
}
if let unwrappedData = data, unwrappedData.contains("Signature"), unwrappedData.contains("is invalid") {
return false
}

throw StarknetProviderError.jsonRpcError(code, errorMessage, data)
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Starknet/Data/Execution.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Foundation

public typealias StarknetCalldata = [Felt]
public typealias StarknetPaymasterData = [Felt]
public typealias StarknetAccountDeploymentData = [Felt]
public typealias StarknetSignature = [Felt]

public struct StarknetCall: Codable, Equatable {
Expand Down
45 changes: 45 additions & 0 deletions Sources/Starknet/Data/Numbers/UInt128AsHex.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import BigInt
import Foundation

public struct UInt128AsHex: NumAsHexProtocol {
public let value: BigUInt

public static let zero = UInt128AsHex(0)
public static let one = UInt128AsHex(1)

public static let min = UInt128AsHex.zero
public static let max = UInt128AsHex(maxValue)!
private static let maxValue = BigUInt(2).power(128) - 1

public init?(_ exactly: some BinaryInteger) {
let value = BigUInt(exactly: exactly)

guard let value, value <= UInt128AsHex.maxValue else {
return nil
}

self.value = value
}

public init(clamping: some BinaryInteger) {
let value = BigUInt(clamping: clamping)

self.value = value <= UInt128AsHex.maxValue ? value : UInt128AsHex.maxValue
}

public init?(fromHex hex: String) {
guard hex.hasPrefix("0x") else { return nil }

if let value = BigUInt(hex.dropFirst(2), radix: 16) {
self.init(value)
} else {
return nil
}
}
}

extension UInt128AsHex: CustomDebugStringConvertible {
public var debugDescription: String {
"UInt128AsHex: \(self.value)"
}
}
45 changes: 45 additions & 0 deletions Sources/Starknet/Data/Numbers/UInt64AsHex.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import BigInt
import Foundation

public struct UInt64AsHex: NumAsHexProtocol {
public let value: BigUInt

public static let zero = UInt64AsHex(0)
public static let one = UInt64AsHex(1)

public static let min = UInt64AsHex.zero
public static let max = UInt64AsHex(maxValue)!
private static let maxValue = BigUInt(2).power(64) - 1

public init?(_ exactly: some BinaryInteger) {
let value = BigUInt(exactly: exactly)

guard let value, value <= UInt64AsHex.maxValue else {
return nil
}

self.value = value
}

public init(clamping: some BinaryInteger) {
let value = BigUInt(clamping: clamping)

self.value = value <= UInt64AsHex.maxValue ? value : UInt64AsHex.maxValue
}

public init?(fromHex hex: String) {
guard hex.hasPrefix("0x") else { return nil }

if let value = BigUInt(hex.dropFirst(2), radix: 16) {
self.init(value)
} else {
return nil
}
}
}

extension UInt64AsHex: CustomDebugStringConvertible {
public var debugDescription: String {
"UInt64AsHex: \(self.value)"
}
}
16 changes: 16 additions & 0 deletions Sources/Starknet/Data/Transaction/Data/DAMode.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import BigInt
import Foundation

public enum StarknetDAMode: String, Codable {
case l1 = "L1"
case l2 = "L2"

public var value: BigUInt {
switch self {
case .l1:
return 0
case .l2:
return 1
}
}
}
36 changes: 36 additions & 0 deletions Sources/Starknet/Data/Transaction/Data/ResourceBounds.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Foundation

public struct StarknetResourceBounds: Codable, Equatable, Hashable {
public let maxAmount: UInt64AsHex
public let maxPricePerUnit: UInt128AsHex

public static let zero = StarknetResourceBounds(
maxAmount: .zero,
maxPricePerUnit: .zero
)

public init(maxAmount: UInt64AsHex, maxPricePerUnit: UInt128AsHex) {
self.maxAmount = maxAmount
self.maxPricePerUnit = maxPricePerUnit
}

enum CodingKeys: String, CodingKey {
case maxAmount = "max_amount"
case maxPricePerUnit = "max_price_per_unit"
}
}

public struct StarknetResourceBoundsMapping: Codable, Equatable, Hashable {
public let l1Gas: StarknetResourceBounds
public let l2Gas: StarknetResourceBounds

public init(l1Gas: StarknetResourceBounds) {
self.l1Gas = l1Gas
self.l2Gas = StarknetResourceBounds.zero
}

enum CodingKeys: String, CodingKey {
case l1Gas = "l1_gas"
case l2Gas = "l2_gas"
}
}
Loading
Loading