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

Revert "GH-3441 Updated the assets" #3443

Merged
merged 1 commit into from
Aug 16, 2024
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
1 change: 0 additions & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
2.7.1

34 changes: 8 additions & 26 deletions Packages/Ethereum/Sources/SafeDeployments/SafeDeployments.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// SafeDeployments.swift
// File.swift
//
//
// Created by Dmitry Bespalov on 04.01.22.
Expand All @@ -11,22 +11,21 @@ import Solidity
public enum Safe {}

extension Safe {
// NOTE: after updating jsons, remember to patch the assets with the script in `bin/patch_safe_deployments.rb`
public struct Deployment: Codable {
public var defaultAddress: String
public var version: String
public var abi: Sol.Json.Contract
public var networkAddresses: [String: [String]]
public var networkAddresses: [String: String]
public var contractName: String
public var released: Bool
public var deployments: [String: [String: String]]

public init(version: String, abi: Sol.Json.Contract, networkAddresses: [String: [String]], contractName: String, released: Bool, deployments: [String: [String: String]]) {
public init(defaultAddress: String, version: String, abi: Sol.Json.Contract, networkAddresses: [String: String], contractName: String, released: Bool) {
self.defaultAddress = defaultAddress
self.version = version
self.abi = abi
self.networkAddresses = networkAddresses
self.contractName = contractName
self.released = released
self.deployments = deployments
}
}

Expand Down Expand Up @@ -101,26 +100,9 @@ extension Safe.Deployment {
}

public func address(for chainId: String) -> Sol.Address? {
guard let defaultAddress = deployments["canonical"]?["address"] else { return nil }
let defaultResult = Sol.Address(hex: defaultAddress)

guard let addressTypes = networkAddresses[chainId] else {
return defaultResult
}

// find and return an address corresponding to the search type
let searchTypes = ["canonical", "eip155", "zksync"]

for addressType in searchTypes {
if addressTypes.contains(addressType),
let address = deployments[addressType]?["address"] {
let result = Sol.Address(hex: address)
return result
}
}

// not found
return defaultResult
let networkAddress = networkAddresses[chainId] ?? defaultAddress
let result = Sol.Address(hex: networkAddress)
return result
}
}

Loading
Loading