Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CircleModularWalletsCore/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>1.0.8</string>
<string>1.0.9</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,23 @@
import Foundation
import BigInt

/// Response model for estimating gas usage for user operations.
/// Result for ``BundlerClient/estimateUserOperationGas(userOp:entryPoint:)``
public struct EstimateUserOperationGasResult: Codable {

/// Gas overhead of this UserOperation.
public let preVerificationGas: BigInt?

/// Estimation of gas limit required by the validation of this UserOperation.
public let verificationGasLimit: BigInt?

/// Estimation of gas limit required by the inner account execution.
public let callGasLimit: BigInt?

/// Estimation of gas limit required by the paymaster verification, if the UserOperation defines a Paymaster address.
public let paymasterVerificationGasLimit: BigInt?

/// The amount of gas to allocate for the paymaster post-operation code.
public let paymasterPostOpGasLimit: BigInt?

init(preVerificationGas: BigInt?, verificationGasLimit: BigInt?, callGasLimit: BigInt?, paymasterVerificationGasLimit: BigInt?, paymasterPostOpGasLimit: BigInt?) {
Expand Down Expand Up @@ -62,12 +73,23 @@ public struct EstimateUserOperationGasResult: Codable {
}
}

/// Response model for getting user operation details.
/// Result for ``BundlerClient/getUserOperation(userOpHash:)``
public struct GetUserOperationResult: Codable {

/// The block hash the User Operation was included on.
public let blockHash: String?

/// The block number the User Operation was included on.
public let blockNumber: BigInt?

/// The hash of the transaction which included the User Operation.
public let transactionHash: String?

/// The EntryPoint which handled the User Operation.
public let entryPoint: String?

/// The User Operation.
public let userOperation: UserOperationType?

enum CodingKeys: String, CodingKey {
Expand Down Expand Up @@ -105,16 +127,35 @@ public struct GetUserOperationResult: Codable {
}
}

/// Data structure representing the receipt of a user operation.
/// Result for ``BundlerClient/getUserOperationReceipt(userOpHash:)``
public struct GetUserOperationReceiptResult: Codable {

/// Hash of the user operation.
public let userOpHash: String?

/// Address of the sender.
public let sender: String?

/// Anti-replay parameter (nonce).
public let nonce: BigInt?

/// Actual gas cost.
public let actualGasCost: BigInt?

/// Actual gas used.
public let actualGasUsed: BigInt?

/// If the user operation execution was successful.
public let success: Bool?

/// Paymaster for the user operation.
public let paymaster: String?

/// Logs emitted during execution.
public let logs: [Log]?

/// Transaction receipt of the user operation execution.
public let receipt: UserOperationReceipt

enum CodingKeys: CodingKey {
Expand Down Expand Up @@ -155,32 +196,76 @@ public struct GetUserOperationReceiptResult: Codable {
self.receipt = try container.decode(GetUserOperationReceiptResult.UserOperationReceipt.self, forKey: .receipt)
}

/// Data structure representing the receipt of a transaction.
// https://github.com/wevm/viem/blob/e7431e88b0e8b83719c91f5a6a57da1a10076a1c/src/account-abstraction/types/userOperation.ts#L167
public struct UserOperationReceipt: Codable {

/// Hash of this transaction.
public let transactionHash: String?

/// Index of this transaction in the block.
public let transactionIndex: String?

/// Hash of the block containing this transaction.
public let blockHash: String?

/// Number of the block containing this transaction.
public let blockNumber: String?

/// Transaction sender.
public let from: String?

/// Transaction recipient or `nil` if deploying a contract.
public let to: String?

/// Gas used by this and all preceding transactions in this block.
public let cumulativeGasUsed: String?

/// Gas used by this transaction.
public let gasUsed: String?

/// List of log objects generated by this transaction.
public let logs: [Log]?

/// Logs bloom filter.
public let logsBloom: String?

/// `success` if this transaction was successful or `reverted` if it failed.
public let status: String?

/// Pre-London, it is equal to the transaction's gasPrice. Post-London, it is equal to the actual gas price paid for inclusion.
public let effectiveGasPrice: String?
}

/// Data structure representing a log entry.
// https://github.com/wevm/viem/blob/e7431e88b0e8b83719c91f5a6a57da1a10076a1c/src/types/log.ts#L15
public struct Log: Codable {

/// `true` if this filter has been destroyed and is invalid.
public let removed: Bool?

/// Index of this log within its block or `nil` if pending.
public let logIndex: String?

/// Index of the transaction that created this log or `nil` if pending.
public let transactionIndex: String?

/// Hash of the transaction that created this log or `nil` if pending.
public let transactionHash: String?

/// Hash of the block containing this log or `nil` if pending.
public let blockHash: String?

/// Number of the block containing this log or `nil` if pending.
public let blockNumber: String?

/// The address from which this log originated.
public let address: String?

/// Contains the non-indexed arguments of the log.
public let data: String?

/// List of topics associated with this log.
public let topics: [String]?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,39 @@ struct GetAddressReq: Encodable {
let metadata: Metadata
}

/// Represents the Circle modular wallet.
struct ModularWallet: Codable, Sendable {

/// The wallet id.
var id: String?

/// The wallet address.
var address: String?

/// The blockchain.
var blockchain: String?

/// The state.
var state: String?

/// The name of the wallet.
var name: String?

/// The SCA core.
var scaCore: String?

/// The SCA configuration.
var scaConfiguration: ScaConfiguration?

/// The create date.
var createDate: String?

/// The last update date.
var updateDate: String?

/// Gets the initialization code from the SCA configuration.
///
/// - Returns: The initialization code if present, `nil` otherwise.
func getInitCode() -> String? {
return scaConfiguration?.initCode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
import Foundation
import BigInt

/// Data structure representing the result of getting paymaster data.
public struct GetPaymasterDataResult: Codable {

/// Paymaster address (entrypoint v0.7)
/// Paymaster address (entrypoint v0.7).
public let paymaster: String?

/// Paymaster data (entrypoint v0.7)
/// Paymaster data (entrypoint v0.7).
public let paymasterData: String?

/// Paymaster post-op gas (entrypoint v0.7)
/// Combined paymaster and data (entrypoint v0.6).
public let paymasterAndData: String?

/// Gas limit for post-operation of paymaster (entrypoint v0.7).
public let paymasterPostOpGasLimit: BigInt?

/// Paymaster validation gas (entrypoint v0.7)
/// Gas limit for verification of paymaster (entrypoint v0.7).
public let paymasterVerificationGasLimit: BigInt?

/// Paymaster and data (entrypoint v0.6)
public let paymasterAndData: String?

enum CodingKeys: CodingKey {
case paymaster
case paymasterData
Expand Down Expand Up @@ -63,31 +64,37 @@ public struct GetPaymasterDataResult: Codable {
}
}

/// Data structure representing the result of getting paymaster stub data.
public struct GetPaymasterStubDataResult: Codable {

/// Paymaster address (entrypoint v0.7)
/// Paymaster address (entrypoint v0.7).
public let paymaster: String?

/// Paymaster data (entrypoint v0.7)
/// Paymaster data (entrypoint v0.7).
public let paymasterData: String?

/// Paymaster post-op gas (entrypoint v0.7)
/// Combined paymaster and data (entrypoint v0.6).
public let paymasterAndData: String?

/// Gas limit for post-operation of paymaster (entrypoint v0.7).
public let paymasterPostOpGasLimit: BigInt?

/// Paymaster validation gas (entrypoint v0.7)
/// Gas limit for verification of paymaster (entrypoint v0.7).
public let paymasterVerificationGasLimit: BigInt?

/// Paymaster and data (entrypoint v0.6)
public let paymasterAndData: String?

/// Indicates that the caller does not need to call pm_getPaymasterData
/// Indicates if the caller does not need to call `pm_getPaymasterData`.
public let isFinal: Bool?

/// Sponsor info
/// Sponsor information.
public let sponsor: SponsorInfo?

/// Data structure representing sponsor information.
public struct SponsorInfo: Codable {

/// Sponsor name.
public let name: String

/// Sponsor icon (optional).
public let icon: String?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ struct EthCallParams: Encodable {
}
}

/// Response model for estimating fees per gas.
/// Result for ``PublicRpcApi/estimateFeesPerGas(transport:feeValuesType:)``
public struct EstimateFeesPerGasResult: Encodable {

/// Total fee per gas in wei (gasPrice/baseFeePerGas + maxPriorityFeePerGas).
public let maxFeePerGas: BigInt? // eip1559

/// Max priority fee per gas (in wei).
public let maxPriorityFeePerGas: BigInt? // eip1559

/// Legacy gas price (optional, usually undefined for EIP-1559).
public let gasPrice: BigInt? // legacy

init(maxFeePerGas: BigInt?, maxPriorityFeePerGas: BigInt?, gasPrice: BigInt? = nil) {
Expand Down
27 changes: 27 additions & 0 deletions CircleModularWalletsCore/Sources/Accounts/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,37 @@

import Foundation

/// Protocol representing an account.
public protocol Account {
/// The type of the signed data.
associatedtype T: Decodable

/// Retrieves the address of the account.
///
/// - Returns: The address of the account.
func getAddress() -> String

/// Signs the given hex data.
///
/// - Parameters:
/// - hex: The hex data to sign.
///
/// - Returns: The signed data of type `T`.
func sign(hex: String) async throws -> T

/// Signs the given message.
///
/// - Parameters:
/// - message: The message to sign.
///
/// - Returns: The signed message of type `T`.
func signMessage(message: String) async throws -> T

/// Signs the given typed data.
///
/// - Parameters:
/// - typedData: The typed data to sign.
///
/// - Returns: The signed typed data of type `T`.
func signTypedData(typedData: String) async throws -> T
}
Loading