Skip to content

Commit

Permalink
Revert "GH-3441 Updated the assets"
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBespalov authored Aug 16, 2024
1 parent c2f63af commit bb1554a
Show file tree
Hide file tree
Showing 31 changed files with 2,370 additions and 14,856 deletions.
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

0 comments on commit bb1554a

Please sign in to comment.