Skip to content

Commit

Permalink
Small UI updates; Adding Atlantis
Browse files Browse the repository at this point in the history
  • Loading branch information
radeknovis committed Oct 17, 2023
1 parent c8c2514 commit 08b17e1
Show file tree
Hide file tree
Showing 14 changed files with 351 additions and 55 deletions.
32 changes: 25 additions & 7 deletions Sample/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 60;
objectVersion = 56;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -14,6 +14,7 @@
CFA99B962AD054A600EB5331 /* secrets.sample.json in Resources */ = {isa = PBXBuildFile; fileRef = CFA99B942AD054A600EB5331 /* secrets.sample.json */; };
CFA99B972AD054A600EB5331 /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFA99B952AD054A600EB5331 /* Secrets.swift */; };
CFA99B992AD054CD00EB5331 /* secrets.json in Resources */ = {isa = PBXBuildFile; fileRef = CFA99B982AD054CD00EB5331 /* secrets.json */; };
CFD6A70F2ADE8DE2002B402C /* Atlantis in Frameworks */ = {isa = PBXBuildFile; productRef = CFD6A70E2ADE8DE2002B402C /* Atlantis */; };
CFD720782A9CC60600636CAF /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFD720772A9CC60600636CAF /* ExampleApp.swift */; };
CFD7207A2A9CC60600636CAF /* ComponentLibraryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFD720792A9CC60600636CAF /* ComponentLibraryView.swift */; };
CFD7207C2A9CC60700636CAF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CFD7207B2A9CC60700636CAF /* Assets.xcassets */; };
Expand All @@ -22,10 +23,12 @@

/* Begin PBXFileReference section */
CF0BCCE42AB0886400A2866C /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
CF533D032ADD411A00B3441C /* web3modal-swift */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "web3modal-swift"; path = ..; sourceTree = "<group>"; };
CFA99B912AD0549F00EB5331 /* WCSocketFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCSocketFactory.swift; sourceTree = "<group>"; };
CFA99B942AD054A600EB5331 /* secrets.sample.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = secrets.sample.json; sourceTree = "<group>"; };
CFA99B952AD054A600EB5331 /* Secrets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = "<group>"; };
CFA99B982AD054CD00EB5331 /* secrets.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = secrets.json; sourceTree = "<group>"; };
CFD6A7102ADE8E26002B402C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
CFD720742A9CC60600636CAF /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
CFD720772A9CC60600636CAF /* ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = "<group>"; };
CFD720792A9CC60600636CAF /* ComponentLibraryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentLibraryView.swift; sourceTree = "<group>"; };
Expand All @@ -40,6 +43,7 @@
buildActionMask = 2147483647;
files = (
CF3B9AD02ACDBA3A00984D53 /* Web3Modal in Frameworks */,
CFD6A70F2ADE8DE2002B402C /* Atlantis in Frameworks */,
CF3B9AD22ACDBA3A00984D53 /* Web3ModalUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -60,6 +64,7 @@
CFD7206B2A9CC60600636CAF = {
isa = PBXGroup;
children = (
CF533D032ADD411A00B3441C /* web3modal-swift */,
CFD720762A9CC60600636CAF /* Example */,
CFD720752A9CC60600636CAF /* Products */,
CFD720AF2A9CC71600636CAF /* Frameworks */,
Expand All @@ -77,6 +82,7 @@
CFD720762A9CC60600636CAF /* Example */ = {
isa = PBXGroup;
children = (
CFD6A7102ADE8E26002B402C /* Info.plist */,
CFA99B932AD054A600EB5331 /* Secrets */,
CFA99B912AD0549F00EB5331 /* WCSocketFactory.swift */,
CFD720772A9CC60600636CAF /* ExampleApp.swift */,
Expand Down Expand Up @@ -123,6 +129,7 @@
packageProductDependencies = (
CF3B9ACF2ACDBA3A00984D53 /* Web3Modal */,
CF3B9AD12ACDBA3A00984D53 /* Web3ModalUI */,
CFD6A70E2ADE8DE2002B402C /* Atlantis */,
);
productName = Example;
productReference = CFD720742A9CC60600636CAF /* Example.app */;
Expand Down Expand Up @@ -153,7 +160,7 @@
);
mainGroup = CFD7206B2A9CC60600636CAF;
packageReferences = (
CF3B9ACE2ACDBA3A00984D53 /* XCLocalSwiftPackageReference ".." */,
CFD6A70D2ADE8DE2002B402C /* XCRemoteSwiftPackageReference "atlantis" */,
);
productRefGroup = CFD720752A9CC60600636CAF /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -321,6 +328,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Example/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
Expand Down Expand Up @@ -360,6 +368,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Example/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
Expand Down Expand Up @@ -409,12 +418,16 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
CF3B9ACE2ACDBA3A00984D53 /* XCLocalSwiftPackageReference ".." */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ..;
/* Begin XCRemoteSwiftPackageReference section */
CFD6A70D2ADE8DE2002B402C /* XCRemoteSwiftPackageReference "atlantis" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ProxymanApp/atlantis";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.22.0;
};
};
/* End XCLocalSwiftPackageReference section */
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
CF3B9ACF2ACDBA3A00984D53 /* Web3Modal */ = {
Expand All @@ -425,6 +438,11 @@
isa = XCSwiftPackageProductDependency;
productName = Web3ModalUI;
};
CFD6A70E2ADE8DE2002B402C /* Atlantis */ = {
isa = XCSwiftPackageProductDependency;
package = CFD6A70D2ADE8DE2002B402C /* XCRemoteSwiftPackageReference "atlantis" */;
productName = Atlantis;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = CFD7206C2A9CC60600636CAF /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "atlantis",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ProxymanApp/atlantis",
"state" : {
"revision" : "cfa72085bce2600b28e47fdbbbfa2d5b96f0392b",
"version" : "1.22.0"
}
},
{
"identity" : "qrcode",
"kind" : "remoteSourceControl",
Expand All @@ -18,6 +27,24 @@
"version" : "1.0.3"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "bb0ea08db8e73324fe6c3727f755ca41a23ff2f4",
"version" : "1.14.2"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
}
},
{
"identity" : "swiftimagereadwrite",
"kind" : "remoteSourceControl",
Expand Down
6 changes: 6 additions & 0 deletions Sample/Example/ExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import SwiftUI
import Web3Modal
import WalletConnectSign

import Atlantis

@main
struct ExampleApp: App {
init() {

Atlantis.start()

let metadata = AppMetadata(
name: "Web3Modal Swift Dapp",
description: "Web3Modal DApp sample",
Expand All @@ -21,6 +26,7 @@ struct ExampleApp: App {

Web3Modal.configure(
projectId: projectId,
chainId: Blockchain("eip155:1")!,
metadata: metadata
)
}
Expand Down
12 changes: 12 additions & 0 deletions Sample/Example/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSBonjourServices</key>
<array>
<string>_Proxyman._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>Atlantis would use Bonjour Service to discover Proxyman app from your local network.</string>
</dict>
</plist>
194 changes: 194 additions & 0 deletions Sources/Web3Modal/Models/Chain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import Foundation

public struct Chain: Identifiable, Hashable {
struct Token: Hashable {
var name: String
var symbol: String
var decimal: Int
}

public var id: String {
"\(chainNamespace):\(chainReference)"
}

var chainName: String
var chainNamespace: String
var chainReference: String
var requiredMethods: [String]
var optionalMethods: [String]
var events: [String]
var token: Token
var rpcUrl: String
var blockExplorerUrl: String
var imageId: String
}

enum EthUtils {

static let walletSwitchEthChain = "wallet_switchEthereumChain"
static let walletAddEthChain = "wallet_addEthereumChain"

static let ethRequiredMethods = [
"personal_sign",
"eth_signTypedData",
"eth_sendTransaction",
]
static let ethOptionalMethods = [walletSwitchEthChain, walletAddEthChain]
static let ethMethods = ethRequiredMethods + ethOptionalMethods

static let chainChanged = "chainChanged"
static let accountsChanged = "accountsChanged"

static let ethEvents = [chainChanged, accountsChanged]
}

enum ChainsPresets {
static let ethToken = Chain.Token(name: "Ether", symbol: "ETH", decimal: 18)

static let ethChains: [Chain] = [
Chain(
chainName: "Ethereum",
chainNamespace: "eip155",
chainReference: "1",
requiredMethods: [],
optionalMethods: [],
events: [],
token: ethToken,
rpcUrl: "https://cloudflare-eth.com",
blockExplorerUrl: "https://etherscan.io",
imageId: "692ed6ba-e569-459a-556a-776476829e00"
),
Chain(
chainName: "Arbitrum One",
chainNamespace: "eip155",
chainReference: "42161",
requiredMethods: [],
optionalMethods: [],
events: [],
token: ethToken,
rpcUrl: "https://arb1.arbitrum.io/rpc",
blockExplorerUrl: "https://arbiscan.io",
imageId: "600a9a04-c1b9-42ca-6785-9b4b6ff85200"
),
Chain(
chainName: "Polygon",
chainNamespace: "eip155",
chainReference: "137",
requiredMethods: [],
optionalMethods: [],
events: [],
token: .init(name: "MATIC", symbol: "MATIC", decimal: 18),
rpcUrl: "https://polygon-rpc.com",
blockExplorerUrl: "https://polygonscan.com",
imageId: "41d04d42-da3b-4453-8506-668cc0727900"
),
Chain(
chainName: "Avalanche",
chainNamespace: "eip155",
chainReference: "43114",
requiredMethods: [],
optionalMethods: [],
events: [],
token: .init(name: "Avalanche", symbol: "AVAX", decimal: 18),
rpcUrl: "https://api.avax.network/ext/bc/C/rpc",
blockExplorerUrl: "https://snowtrace.io",
imageId: "30c46e53-e989-45fb-4549-be3bd4eb3b00"
),
Chain(
chainName: "BNB Smart Chain",
chainNamespace: "eip155",
chainReference: "56",
requiredMethods: EthUtils.ethRequiredMethods,
optionalMethods: EthUtils.ethOptionalMethods,
events: EthUtils.ethEvents,
token: .init(name: "BNB",symbol: "BNB",decimal: 18),
rpcUrl: "https://rpc.ankr.com/bsc",
blockExplorerUrl: "https://bscscan.com",
imageId: "93564157-2e8e-4ce7-81df-b264dbee9b00"
),
Chain(
chainName: "OP Mainnet",
chainNamespace: "eip155",
chainReference: "10",
requiredMethods: EthUtils.ethRequiredMethods,
optionalMethods: EthUtils.ethOptionalMethods,
events: EthUtils.ethEvents,
token: ethToken,
rpcUrl: "https://mainnet.optimism.io",
blockExplorerUrl: "https://explorer.optimism.io",
imageId: "ab9c186a-c52f-464b-2906-ca59d760a400"
),
Chain(
chainName: "Gnosis",
chainNamespace: "eip155",
chainReference: "100",
requiredMethods: EthUtils.ethRequiredMethods,
optionalMethods: EthUtils.ethOptionalMethods,
events: EthUtils.ethEvents,
token: .init(name: "Gnosis",symbol: "xDAI",decimal: 18),
rpcUrl: "https://rpc.gnosischain.com",
blockExplorerUrl: "https://blockscout.com/xdai/mainnet",
imageId: "02b53f6a-e3d4-479e-1cb4-21178987d100"
),
Chain(
chainName: "zkSync Era",
chainNamespace: "eip155",
chainReference: "324",
requiredMethods: EthUtils.ethRequiredMethods,
optionalMethods: EthUtils.ethOptionalMethods,
events: EthUtils.ethEvents,
token: ethToken,
rpcUrl: "https://mainnet.era.zksync.io",
blockExplorerUrl: "https://explorer.zksync.io",
imageId: "b310f07f-4ef7-49f3-7073-2a0a39685800"
),
Chain(
chainName: "Zora",
chainNamespace: "eip155",
chainReference: "7777777",
requiredMethods: EthUtils.ethRequiredMethods,
optionalMethods: EthUtils.ethOptionalMethods,
events: EthUtils.ethEvents,
token: ethToken,
rpcUrl: "https://rpc.zora.energy",
blockExplorerUrl: "https://explorer.zora.energy",
imageId: "845c60df-d429-4991-e687-91ae45791600"
),
Chain(
chainName: "Base",
chainNamespace: "eip155",
chainReference: "8453",
requiredMethods: EthUtils.ethRequiredMethods,
optionalMethods: EthUtils.ethOptionalMethods,
events: EthUtils.ethEvents,
token: ethToken,
rpcUrl: "https://mainnet.base.org",
blockExplorerUrl: "https://basescan.org",
imageId: "7289c336-3981-4081-c5f4-efc26ac64a00"
),
Chain(
chainName: "Celo",
chainNamespace: "eip155",
chainReference: "42220",
requiredMethods: EthUtils.ethRequiredMethods,
optionalMethods: EthUtils.ethOptionalMethods,
events: EthUtils.ethEvents,
token: .init(name: "CELO",symbol: "CELO",decimal: 18),
rpcUrl: "https://forno.celo.org",
blockExplorerUrl: "https://explorer.celo.org/mainnet",
imageId: "ab781bbc-ccc6-418d-d32d-789b15da1f00"
),
Chain(
chainName: "Aurora",
chainNamespace: "eip155",
chainReference: "1313161554",
requiredMethods: [],
optionalMethods: [],
events: [],
token: ethToken,
rpcUrl: "https://mainnet.aurora.dev",
blockExplorerUrl: "https://aurorascan.dev",
imageId: "3ff73439-a619-4894-9262-4470c773a100"
)
]
}
Loading

0 comments on commit 08b17e1

Please sign in to comment.