-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from MetaMask/convenience-methods
Convenience methods
- Loading branch information
Showing
10 changed files
with
294 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Sources/metamask-ios-sdk/Classes/Communication/Models/AddChainParameters.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// AddChainParameters.swift | ||
// metamask-ios-sdk | ||
// | ||
|
||
|
||
import Foundation | ||
|
||
public struct AddChainParameters: CodableData { | ||
public let chainId: String | ||
public let chainName: String | ||
public let rpcUrls: [String] | ||
public let iconUrls: [String]? | ||
public let blockExplorerUrls: [String]? | ||
public let nativeCurrency: NativeCurrency | ||
|
||
public func socketRepresentation() -> NetworkData { | ||
[ | ||
"chainId": chainId, | ||
"chainName": chainName, | ||
"rpcUrls": rpcUrls, | ||
"iconUrls": iconUrls ?? [], | ||
"blockExplorerUrls": blockExplorerUrls ?? [], | ||
"nativeCurrency": nativeCurrency.socketRepresentation() | ||
] | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Sources/metamask-ios-sdk/Classes/Communication/Models/NativeCurrency.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// NativeCurrency.swift | ||
// metamask-ios-sdk | ||
|
||
import Foundation | ||
|
||
public struct NativeCurrency: CodableData { | ||
public let name: String? | ||
public let symbol: String | ||
public let decimals: Int | ||
|
||
public init(name: String?, symbol: String, decimals: Int) { | ||
self.name = name | ||
self.symbol = symbol | ||
self.decimals = decimals | ||
} | ||
|
||
public func socketRepresentation() -> NetworkData { | ||
[ | ||
"name": name ?? "", | ||
"symbol": symbol, | ||
"decimals": decimals | ||
] | ||
} | ||
} |
Oops, something went wrong.