spb/os-vault Public
Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.
Swift 96%
Shell 3.4%
Makefile 0.6%
1import WalletCoreC2import Foundation3// SPDX-License-Identifier: Apache-2.04//5// Copyright © 2017 Trust Wallet.6//7// This is a GENERATED FILE, changes made here WILL BE LOST.8//910import Foundation111213public final class Eip7702 {1415 /// Signs an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702)16 /// 17 /// - Parameter chain_id: The chain ID of the user.18 /// - Parameter contract_address: The address of the smart contract wallet.19 /// - Parameter nonce: The nonce of the user.20 /// - Parameter private_key: The private key of the user.21 /// - Returns: The signed authorization.22 public static func signAuthorization(chainId: Data, contractAddress: String, nonce: Data, privateKey: String) -> String? {23 let chainIdData = TWDataCreateWithNSData(chainId)24 defer {25 TWDataDelete(chainIdData)26 }27 let contractAddressString = TWStringCreateWithNSString(contractAddress)28 defer {29 TWStringDelete(contractAddressString)30 }31 let nonceData = TWDataCreateWithNSData(nonce)32 defer {33 TWDataDelete(nonceData)34 }35 let privateKeyString = TWStringCreateWithNSString(privateKey)36 defer {37 TWStringDelete(privateKeyString)38 }39 guard let result = TWEip7702SignAuthorization(chainIdData, contractAddressString, nonceData, privateKeyString) else {40 return nil41 }42 return TWStringNSString(result)43 }4445 /// Computes an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702)46 /// `keccak256('0x05' || rlp([chain_id, address, nonce]))`.47 /// 48 /// - Parameter chain_id: The chain ID of the user.49 /// - Parameter contract_address: The address of the smart contract wallet.50 /// - Parameter nonce: The nonce of the user.51 /// - Returns: The authorization hash.52 public static func getAuthorizationHash(chainId: Data, contractAddress: String, nonce: Data) -> Data? {53 let chainIdData = TWDataCreateWithNSData(chainId)54 defer {55 TWDataDelete(chainIdData)56 }57 let contractAddressString = TWStringCreateWithNSString(contractAddress)58 defer {59 TWStringDelete(contractAddressString)60 }61 let nonceData = TWDataCreateWithNSData(nonce)62 defer {63 TWDataDelete(nonceData)64 }65 guard let result = TWEip7702GetAuthorizationHash(chainIdData, contractAddressString, nonceData) else {66 return nil67 }68 return TWDataNSData(result)69 }7071 let rawValue: OpaquePointer7273 init(rawValue: OpaquePointer) {74 self.rawValue = rawValue75 }767778}79