Skip to content

Commit

Permalink
🔄 synced file(s) with circlefin/modularwallets-ios-sdk-internal (#6)
Browse files Browse the repository at this point in the history
synced local file(s) with
[circlefin/modularwallets-ios-sdk-internal](https://github.com/circlefin/modularwallets-ios-sdk-internal).



<details>
<summary>Changed files</summary>
<ul>
<li>synced local directory <code>CircleModularWalletsCore/</code> with
remote directory <code>CircleModularWalletsCore/</code></li><li>synced
local <code>./COPYRIGHT</code> with remote
<code>./COPYRIGHT</code></li><li>synced local <code>./LICENSE</code>
with remote <code>./LICENSE</code></li><li>synced local
<code>./Package.swift</code> with remote
<code>./Package.swift</code></li>
</ul>
</details>

---

This PR was created automatically by the
[repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action)
workflow run
[#12578337051](https://github.com/circlefin/modularwallets-ios-sdk-internal/actions/runs/12578337051)
  • Loading branch information
circle-github-action-bot authored Jan 2, 2025
1 parent c1bd6f8 commit 9f5eeab
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2024 Circle Internet Group, Inc. All rights reserved.
Copyright 2025 Circle Internet Group, Inc. All rights reserved.

SPDX-License-Identifier: Apache-2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public class CircleSmartAccount<A: Account>: SmartAccount where A.T == SignResul

public func signUserOperation(chainId: Int, userOp: UserOperationV07) async throws -> String {
userOp.sender = getAddress()
let userOpHash = Utils.getUserOperationHash(
let userOpHash = try Utils.getUserOperationHash(
chainId: chainId,
entryPointAddress: EntryPoint.v07.address,
userOp: userOp
Expand Down
24 changes: 24 additions & 0 deletions CircleModularWalletsCore/Sources/Errors/EncodingError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2025, Circle Internet Group, Inc. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

class IntegerOutOfRangeError: BaseError {
init(cause: BaseError? = nil) {
super.init(shortMessage: "The input value is out of range",
args: BaseErrorParameters(cause: cause, name: "IntegerOutOfRangeError"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension KeyedEncodingContainer {

mutating func encodeBigInt(_ value: BigInt?, forKey key: KeyedEncodingContainer<K>.Key) throws {
if let value {
let hexString = HexUtils.bigIntToHex(value)
let hexString = try HexUtils.bigIntToHex(value)
try self.encodeIfPresent(hexString, forKey: key)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ struct HexUtils {
return BigInt(hex.noHexPrefix, radix: 16)
}

static func bigIntToHex(_ bigInt: BigInt, withPrefix: Bool = true) -> String {
static func bigIntToHex(_ bigInt: BigInt, withPrefix: Bool = true) throws -> String {
if bigInt.sign == .minus {
throw IntegerOutOfRangeError()
}
let hex = BigUInt(bigInt).hexString
return withPrefix ? hex : hex.noHexPrefix
}
Expand Down
14 changes: 7 additions & 7 deletions CircleModularWalletsCore/Sources/Helpers/Utils/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ public struct Utils {
chainId: Int,
entryPointAddress: String = ENTRYPOINT_V07_ADDRESS,
userOp: UserOperationV07
) -> String {
) throws -> String {

var accountGasLimits = [UInt8]()
if let verificationGasLimit = userOp.verificationGasLimit,
let callGasLimit = userOp.callGasLimit {

let verificationGasLimitHex = HexUtils.bigIntToHex(verificationGasLimit, withPrefix: false)
let verificationGasLimitHex = try HexUtils.bigIntToHex(verificationGasLimit, withPrefix: false)
let verificationGasLimitHexWithPadding = verificationGasLimitHex.leftPadding(toLength: 32, withPad: "0")
let callGasLimitHex = HexUtils.bigIntToHex(callGasLimit, withPrefix: false)
let callGasLimitHex = try HexUtils.bigIntToHex(callGasLimit, withPrefix: false)
let callGasLimitHexWithPadding = callGasLimitHex.leftPadding(toLength: 32, withPad: "0")
let finalHex = verificationGasLimitHexWithPadding + callGasLimitHexWithPadding

Expand All @@ -134,9 +134,9 @@ public struct Utils {
if let maxPriorityFeePerGas = userOp.maxPriorityFeePerGas,
let maxFeePerGas = userOp.maxFeePerGas {

let maxPriorityFeePerGasHex = HexUtils.bigIntToHex(maxPriorityFeePerGas, withPrefix: false)
let maxPriorityFeePerGasHex = try HexUtils.bigIntToHex(maxPriorityFeePerGas, withPrefix: false)
let maxPriorityFeePerGasHexWithPadding = maxPriorityFeePerGasHex.leftPadding(toLength: 32, withPad: "0")
let maxFeePerGasHex = HexUtils.bigIntToHex(maxFeePerGas, withPrefix: false)
let maxFeePerGasHex = try HexUtils.bigIntToHex(maxFeePerGas, withPrefix: false)
let maxFeePerGasHexWithPadding = maxFeePerGasHex.leftPadding(toLength: 32, withPad: "0")
let finalHex = maxPriorityFeePerGasHexWithPadding + maxFeePerGasHexWithPadding

Expand All @@ -161,11 +161,11 @@ public struct Utils {
if let paymaster = userOp.paymaster {

let paymasterVerificationGasLimit = userOp.paymasterVerificationGasLimit ?? BigInt.zero
let verificationGasLimitHex = HexUtils.bigIntToHex(paymasterVerificationGasLimit, withPrefix: false)
let verificationGasLimitHex = try HexUtils.bigIntToHex(paymasterVerificationGasLimit, withPrefix: false)
let verificationGasLimitHexWithPadding = verificationGasLimitHex.leftPadding(toLength: 32, withPad: "0")

let paymasterPostOpGasLimit = userOp.paymasterPostOpGasLimit ?? BigInt.zero
let postOpGasLimitHex = HexUtils.bigIntToHex(paymasterPostOpGasLimit, withPrefix: false)
let postOpGasLimitHex = try HexUtils.bigIntToHex(paymasterPostOpGasLimit, withPrefix: false)
let postOpGasLimitHexWithPadding = postOpGasLimitHex.leftPadding(toLength: 32, withPad: "0")

let paymasterData = userOp.paymasterData?.noHexPrefix ?? ""
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@

END OF TERMS AND CONDITIONS

© 2024, Circle Internet Financial, LTD. All rights reserved.
© 2025, Circle Internet Financial, LTD. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// swift-tools-version: 5.7
//
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
// Copyright (c) 2025, Circle Internet Financial, LTD. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down

0 comments on commit 9f5eeab

Please sign in to comment.