Skip to content

Commit

Permalink
Merge pull request #2 from zksync-sdk/mm/add-cocoapods-support
Browse files Browse the repository at this point in the history
Add CocoaPods support.
  • Loading branch information
MaximFischuk authored Dec 14, 2022
2 parents e0e1621 + 2c27452 commit 06dde99
Show file tree
Hide file tree
Showing 31 changed files with 146 additions and 33 deletions.
8 changes: 8 additions & 0 deletions Examples/CocoaPods/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
platform :ios, '13.0'
use_frameworks!

install! 'cocoapods', :warn_for_unused_master_specs_repo => false

target 'ZkSync2Example' do
pod 'web3swift-zksync', '2.6.5-zksync'
end
1 change: 1 addition & 0 deletions Examples/CocoaPods/ZkSync2Example/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import web3swift_zksync

struct ContentView: View {
var body: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
{
"identity" : "web3swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/MaximAlien/web3swift.git",
"location" : "https://github.com/zksync-sdk/web3swift.git",
"state" : {
"branch" : "2.6.5-patch",
"revision" : "c69d93c7f85f9c0b7252271e2883af6e9f390388"
"revision" : "57f8ff9ecba69be2d21d4ebadc1197b5f0614064",
"version" : "2.6.5-zksync"
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ let package = Package(
],
dependencies: [
.package(
url: "https://github.com/MaximAlien/web3swift.git",
branch: "2.6.5-patch"
url: "https://github.com/zksync-sdk/web3swift.git",
exact: "2.6.5-zksync"
),
.package(
url: "https://github.com/Alamofire/Alamofire.git",
Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Crypto/EIP712/EIP712Domain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import Foundation
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

public class EIP712Domain: Structurable {

Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Crypto/EIP712/EIP712Encoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import Foundation
import BigInt
import web3swift
import CryptoSwift
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

class EIP712Encoder {

Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Crypto/EIP712/Structurable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
//

import Foundation
import web3swift
import BigInt
import CryptoSwift
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

public protocol Structurable: EIP712Hashable {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Crypto/Signer/EthSigner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//

import Foundation
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

public protocol EthSigner {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Crypto/Signer/PrivateKeyEthSigner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import Foundation
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

public class PrivateKeyEthSigner: EthSigner {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Extensions/EthereumAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by Maxim Makhun on 9/27/22.
//

#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension EthereumAddress {

Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Extensions/EthereumKeystoreV3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//

import Foundation
import web3swift
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

public typealias Credentials = EthereumKeystoreV3

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Extensions/EthereumTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import Foundation
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension EthereumTransaction {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Extensions/JsonRpc2_0ZkSync+Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import Foundation
import BigInt
import PromiseKit
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension JsonRpc2_0ZkSync {

Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Extensions/Web3Eth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
// Created by Maxim Makhun on 9/29/22.
//

import web3swift
import BigInt
import PromiseKit
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension web3.Eth {

Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Protocol/JsonRpc2_0ZkSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//

import Foundation
import web3swift
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

class JsonRpc2_0ZkSync: ZkSync {

Expand Down
18 changes: 11 additions & 7 deletions Sources/ZkSync2/Protocol/Provider/DefaultEthereumProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import Foundation
import BigInt
import web3swift
import PromiseKit
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension DefaultEthereumProvider {

Expand Down Expand Up @@ -62,9 +66,9 @@ class DefaultEthereumProvider: EthereumProvider {
throw EthereumProviderError.invalidToken
}

let tokenContract = web3swift.ERC20(web3: web3,
provider: web3.provider,
address: tokenAddress)
let tokenContract = ERC20(web3: web3,
provider: web3.provider,
address: tokenAddress)

let maxApproveAmount = BigUInt.two.power(256) - 1
let amount = limit?.description ?? maxApproveAmount.description
Expand Down Expand Up @@ -252,9 +256,9 @@ class DefaultEthereumProvider: EthereumProvider {
throw EthereumProviderError.invalidToken
}

let tokenContract = web3swift.ERC20(web3: web3,
provider: web3.provider,
address: tokenAddress)
let tokenContract = ERC20(web3: web3,
provider: web3.provider,
address: tokenAddress)

let allowance = try tokenContract.getAllowance(originalOwner: ownerAddress,
delegate: spenderAddress)
Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Protocol/Provider/EthereumProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import Foundation
import BigInt
import web3swift
import PromiseKit
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

protocol EthereumProvider {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Protocol/ZkSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import Foundation
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

public typealias Result<T> = Swift.Result<T, Error>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
//

import Foundation
import web3swift
import BigInt
import PromiseKit
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

class DefaultTransactionFeeProvider: ZkTransactionFeeProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
//

import Foundation
import web3swift
import BigInt
import PromiseKit
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

protocol ZkTransactionFeeProvider: ContractGasProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//

import Foundation
import web3swift
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension EthereumTransaction: Structurable {

Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Utils/ContractDeployer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//

import Foundation
import web3swift
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

public class ContractDeployer {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Utils/ContractUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import Foundation
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

class ContractUtils {

Expand Down
6 changes: 5 additions & 1 deletion Sources/ZkSync2/Utils/Paymaster.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
//

import Foundation
import web3swift
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

class Paymaster {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Utils/ZkSyncABI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//

import Foundation
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension Web3.Utils {

Expand Down
8 changes: 6 additions & 2 deletions Sources/ZkSync2/Wrappers/ERC20.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
//

import Foundation
import web3swift
import BigInt
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

class ERC20 {
class ZkERC20 {

static func encodeTransfer(_ to: EthereumAddress,
value: BigUInt) -> Data {
Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Wrappers/IL1Bridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//

import Foundation
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension Web3.Utils {

Expand Down
4 changes: 4 additions & 0 deletions Sources/ZkSync2/Wrappers/IL2Bridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//

import Foundation
#if canImport(web3swift)
import web3swift
#else
import web3swift_zksync
#endif

extension Web3.Utils {

Expand Down
Loading

0 comments on commit 06dde99

Please sign in to comment.