Skip to content

Commit 1d5be24

Browse files
authored
Merge pull request #1954 from MixinNetwork/feature/web3
Support Avalanche C-Chain
2 parents 6582bce + 0ae583f commit 1d5be24

File tree

13 files changed

+76
-35
lines changed

13 files changed

+76
-35
lines changed

Mixin.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@
10931093
946CB9DC2E9F73320099FFCB /* UserNavigationTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946CB9DB2E9F73310099FFCB /* UserNavigationTitleView.swift */; };
10941094
946CBA062E9F7A950099FFCB /* CommonWalletReceiverCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946CBA042E9F7A950099FFCB /* CommonWalletReceiverCell.swift */; };
10951095
946CBA072E9F7A950099FFCB /* CommonWalletReceiverCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 946CBA052E9F7A950099FFCB /* CommonWalletReceiverCell.xib */; };
1096+
946D1B362EF29FA600E572F2 /* SyncWeb3AddressJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946D1B352EF29FA600E572F2 /* SyncWeb3AddressJob.swift */; };
10961097
946E055A2CBE52FF004B264E /* ExploreRecentSearchCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946E05582CBE52FF004B264E /* ExploreRecentSearchCell.swift */; };
10971098
946E055B2CBE52FF004B264E /* ExploreRecentSearchCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 946E05592CBE52FF004B264E /* ExploreRecentSearchCell.xib */; };
10981099
946E05732CBE7CFB004B264E /* MarketCoinCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946E05712CBE7CFB004B264E /* MarketCoinCell.swift */; };
@@ -2883,6 +2884,7 @@
28832884
946CB9DB2E9F73310099FFCB /* UserNavigationTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNavigationTitleView.swift; sourceTree = "<group>"; };
28842885
946CBA042E9F7A950099FFCB /* CommonWalletReceiverCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonWalletReceiverCell.swift; sourceTree = "<group>"; };
28852886
946CBA052E9F7A950099FFCB /* CommonWalletReceiverCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CommonWalletReceiverCell.xib; sourceTree = "<group>"; };
2887+
946D1B352EF29FA600E572F2 /* SyncWeb3AddressJob.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncWeb3AddressJob.swift; sourceTree = "<group>"; };
28862888
946E05582CBE52FF004B264E /* ExploreRecentSearchCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreRecentSearchCell.swift; sourceTree = "<group>"; };
28872889
946E05592CBE52FF004B264E /* ExploreRecentSearchCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ExploreRecentSearchCell.xib; sourceTree = "<group>"; };
28882890
946E05712CBE7CFB004B264E /* MarketCoinCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketCoinCell.swift; sourceTree = "<group>"; };
@@ -6175,6 +6177,7 @@
61756177
946E9F192AEF88DF0077CD7A /* RecoverRawTransactionJob.swift */,
61766178
7C104A8027D83A51004D0530 /* RefreshExternalSchemeJob.swift */,
61776179
94BFA9892B98546000200FC4 /* SyncSafeSnapshotJob.swift */,
6180+
946D1B352EF29FA600E572F2 /* SyncWeb3AddressJob.swift */,
61786181
942C647A2D7A0C38003B3A5F /* SyncWeb3TransactionJob.swift */,
61796182
94F7E8682D9C0BF6006AA6CD /* ReviewPendingWeb3RawTransactionJob.swift */,
61806183
947BE3E82DBA957100A98677 /* ReviewPendingWeb3TransactionJob.swift */,
@@ -7389,6 +7392,7 @@
73897392
945AA6582567B18200B39415 /* Country.swift in Sources */,
73907393
949B5E0C2EBCFB9500D33C97 /* SyncWeb3OrdersJob.swift in Sources */,
73917394
7BD00F222559716C004D8814 /* WalletSearchRecommendationViewController.swift in Sources */,
7395+
946D1B362EF29FA600E572F2 /* SyncWeb3AddressJob.swift in Sources */,
73927396
7BCA3A572057F08E007617C1 /* CATransactionExtension.swift in Sources */,
73937397
7C5304A129014F6800567CF6 /* AuthorizationScopesTableView.swift in Sources */,
73947398
94B8D189266E41D300F43CBB /* DatabaseDiagnosticViewController.swift in Sources */,

Mixin/Assets.xcassets/classic_wallet_chains.imageset/Contents.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
{
22
"images" : [
33
{
4-
"idiom" : "universal",
5-
"scale" : "1x"
6-
},
7-
{
8-
"filename" : "classic_wallet_chains@2x.png",
9-
"idiom" : "universal",
10-
"scale" : "2x"
11-
},
12-
{
13-
"filename" : "classic_wallet_chains@3x.png",
14-
"idiom" : "universal",
15-
"scale" : "3x"
4+
"filename" : "classic_wallet_chains.pdf",
5+
"idiom" : "universal"
166
}
177
],
188
"info" : {
Binary file not shown.
Binary file not shown.
Binary file not shown.
640 Bytes
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Foundation
2+
import MixinServices
3+
4+
final class SyncWeb3AddressJob: BaseJob {
5+
6+
private let walletID: String
7+
8+
init(walletID: String) {
9+
self.walletID = walletID
10+
super.init()
11+
}
12+
13+
static func jobID(walletID: String) -> String {
14+
"sync-web3address-\(walletID)"
15+
}
16+
17+
override func getJobId() -> String {
18+
Self.jobID(walletID: walletID)
19+
}
20+
21+
override func run() throws {
22+
switch RouteAPI.addresses(walletID: walletID) {
23+
case .success(let addresses):
24+
Web3AddressDAO.shared.save(addresses: addresses)
25+
case .failure(let error):
26+
throw error
27+
}
28+
}
29+
30+
}

Mixin/UserInterface/Controllers/Home/HomeViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ final class HomeViewController: UIViewController {
111111
let walletIDs = Web3WalletDAO.shared.walletIDs()
112112
for id in walletIDs {
113113
let jobs = [
114+
SyncWeb3AddressJob(walletID: id),
114115
RefreshWeb3WalletTokenJob(walletID: id),
115116
SyncWeb3TransactionJob(walletID: id),
116117
]

Mixin/UserInterface/Controllers/Wallet/DeleteWalletViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ extension DeleteWalletViewController: AuthenticationIntent {
7676
switch result {
7777
case .success:
7878
let jobIDs = [
79+
SyncWeb3AddressJob.jobID(walletID: walletID),
7980
SyncWeb3TransactionJob.jobID(walletID: walletID),
8081
ReviewPendingWeb3RawTransactionJob.jobID(walletID: walletID),
8182
ReviewPendingWeb3TransactionJob.jobID(walletID: walletID),

Mixin/UserInterface/Controllers/Web3/Model/Web3Chain.swift

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class Web3Chain {
1414
var chains: [Web3Chain] {
1515
switch self {
1616
case .evm:
17-
[.ethereum, .polygon, .bnbSmartChain, .base, .arbitrumOne, .opMainnet]
17+
[.ethereum, .polygon, .bnbSmartChain, .base, .arbitrumOne, .opMainnet, .avalancheCChain]
1818
case .solana:
1919
[.solana]
2020
}
@@ -171,7 +171,7 @@ extension Web3Chain {
171171

172172
static let all: [Web3Chain] = {
173173
let chains: [Web3Chain] = [
174-
.ethereum, .solana, .bnbSmartChain, .base, .polygon, .arbitrumOne, .opMainnet
174+
.ethereum, .solana, .bnbSmartChain, .base, .polygon, .arbitrumOne, .opMainnet, .avalancheCChain,
175175
]
176176
// Make sure all chains are included
177177
let allChains = Kind.allCases.reduce(into: []) { results, kind in
@@ -213,6 +213,30 @@ extension Web3Chain {
213213
failsafeRPCServerURL: URL(string: "https://base.llamarpc.com")!
214214
)
215215

216+
static let arbitrumOne = Web3Chain.evm(
217+
chainID: 42161,
218+
mixinChainID: ChainID.arbitrumOne,
219+
feeTokenAssetID: AssetID.arbitrumOneETH,
220+
name: "Arbitrum One",
221+
failsafeRPCServerURL: URL(string: "https://arbitrum.llamarpc.com")!
222+
)
223+
224+
static let opMainnet = Web3Chain.evm(
225+
chainID: 10,
226+
mixinChainID: ChainID.opMainnet,
227+
feeTokenAssetID: AssetID.opMainnetETH,
228+
name: "OP Mainnet",
229+
failsafeRPCServerURL: URL(string: "https://optimism.llamarpc.com")!
230+
)
231+
232+
static let avalancheCChain = Web3Chain.evm(
233+
chainID: 43114,
234+
mixinChainID: ChainID.avalancheCChain,
235+
feeTokenAssetID: AssetID.avalancheCAVAX,
236+
name: "Avalanche",
237+
failsafeRPCServerURL: URL(string: "https://api.avax.network/ext/bc/C/rpc")!
238+
)
239+
216240
static let solana = Web3Chain.solana(
217241
reference: "4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",
218242
mixinChainID: ChainID.solana,
@@ -231,22 +255,6 @@ extension Web3Chain {
231255
)
232256
#endif
233257

234-
static let arbitrumOne = Web3Chain.evm(
235-
chainID: 42161,
236-
mixinChainID: ChainID.arbitrumOne,
237-
feeTokenAssetID: AssetID.arbitrumOneETH,
238-
name: "Arbitrum One",
239-
failsafeRPCServerURL: URL(string: "https://arbitrum.llamarpc.com")!
240-
)
241-
242-
static let opMainnet = Web3Chain.evm(
243-
chainID: 10,
244-
mixinChainID: ChainID.opMainnet,
245-
feeTokenAssetID: AssetID.opMainnetETH,
246-
name: "OP Mainnet",
247-
failsafeRPCServerURL: URL(string: "https://optimism.llamarpc.com")!
248-
)
249-
250258
}
251259

252260
// MARK: - Dapp Sync

0 commit comments

Comments
 (0)