Proton
public class Proton : ObservableObject
The Proton class is the heart of the ProtonSwift SDK.
-
The proton config object which is a required param for initialisation of Proton
See moreDeclaration
Swift
public struct Config -
Proton typealias of the EOSIO.Name
Declaration
Swift
public typealias Name = EOSIO.Name -
Proton typealias of the EOSIO.PrivateKey
Declaration
Swift
public typealias PrivateKey = EOSIO.PrivateKey -
Proton typealias of the EOSIO.Asset
Declaration
Swift
public typealias Asset = EOSIO.Asset -
Proton typealias of the EOSIO.Asset.Symbol
Declaration
Swift
public typealias Symbol = EOSIO.Asset.Symbol -
Proton typealias of the of WebOperations WebError
Declaration
Swift
public typealias ProtonError = WebError -
The proton config which gets set during initialisation
Declaration
Swift
public static var config: Config? -
Use this function as your starting point to initialize the singleton class Proton
Declaration
Swift
@discardableResult public static func initialize(_ config: Config) -> ProtonParameters
configThe configuration object that includes urls for chainProviders
Return Value
Initialized Proton singleton
-
The shared instance of the Proton class. Use this for accessing functionality after initialisation of Proton
Declaration
Swift
public static let shared: Proton -
Checks if user has authentication enabled. At least passcode set is required
Declaration
Swift
public func authenticationEnabled() -> BoolReturn Value
Bool
-
Live updated chainProvider.
Declaration
Swift
@Published public var chainProvider: ChainProvider? { get set } -
Live updated array of tokenContracts
Declaration
Swift
@Published public var tokenContracts: [TokenContract] { get set } -
Live updated array of tokenBalances.
Declaration
Swift
@Published public var tokenBalances: [TokenBalance] { get set } -
Live updated array of tokenTransferActions.
Declaration
Swift
@Published public var tokenTransferActions: [String : [TokenTransferAction]] { get set } -
Live updated array of contacts.
Declaration
Swift
@Published public var contacts: [Contact] { get set } -
Live updated array of producers.
Declaration
Swift
@Published public var producers: [Producer] { get set } -
Live updated array of protonESRSessions.
Declaration
Swift
@Published public var protonESRSessions: [ProtonESRSession] { get set } -
Live updated protonESR.
Declaration
Swift
@Published public var protonESR: ProtonESR? { get set } -
Live updated protonESR.
Declaration
Swift
@Published public var protonESRAvailable: Bool { get set } -
Live updated account.
Declaration
Swift
@Published public var account: Account? { get set } -
Live updated GlobalsXPR.
Declaration
Swift
@Published public var globalsXPR: GlobalsXPR? { get set }
-
Loads all data objects from disk into memory
Declaration
Swift
public func loadAll() -
Saves all current data objects that are in memory to disk
Declaration
Swift
public func saveAll() -
Connects/Reconnects websocket connections needed for ESR requests
Declaration
Swift
public func enableProtonESRWebSocketConnections() -
Use this to force storing the key into the keychain.
Declaration
Swift
public func store(privateKey: PrivateKey, synchronizable: Bool = false, completion: @escaping ((Result<Bool, Error>) -> Void))Parameters
privateKeyPrivateKey
chainIdchainId for the account
completionClosure returning Result
-
Fetches the account from the chain, the stores private key and sets account active
Declaration
Swift
public func setAccount(withName accountName: String, andPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Account, Error>) -> Void))Parameters
withNameProton account name not including @
andPrivateKeyPrivateKey
chainIdchainId for the account
completionClosure returning Result
-
Sets the active account, fetchs and updates. This includes, account names, avatars, balances, etc Use this for switching accounts when you know the private key has already been stored.
Declaration
Swift
public func setAccount(withName accountName: String, chainId: String, synchronizable: Bool = false, completion: @escaping ((Result<Account, Error>) -> Void))Parameters
withNameProton account name not including @
chainIdchainId for the account
completionClosure returning Result
-
Use this function to store the private key and set the account after finding the account you want to save via findAccounts
Declaration
Parameters
accountAccount object, normally retrieved via findAccounts
withPrivateKeyStringWif formated private key
completionClosure returning Result
-
Fetchs all required data objects from external data sources. This should be done at startup
Declaration
Swift
public func clearAccount(removingPrivateKey: Bool = false)Parameters
removingPrivateKeyNOT WORKING YET
-
Fetchs all required data objects from external data sources. This should be done at startup
Declaration
Swift
public func updateDataRequirements(completion: @escaping ((Result<Bool, Error>) -> Void))Parameters
completionClosure returning Result
-
Updates the GlobalsXPR object. This has information like min required bp votes, staking period, etc.
Declaration
Swift
public func updateGlobalsXPR(completion: @escaping ((Result<Bool, Error>) -> Void))Parameters
completionClosure returning Result
-
Updates all TokenContract data objects with latest exchange rates from external data sources.
Declaration
Swift
public func updateExchangeRates(completion: @escaping ((Result<Bool, Error>) -> Void))Parameters
completionClosure returning Result
-
Fetchs and updates the active account. This includes, account names, avatars, balances, etc
Declaration
Swift
public func updateAccount(completion: @escaping ((Result<Account, Error>) -> Void))Parameters
completionClosure returning Result
-
Changes the account’s userdefined name on chain
Declaration
Swift
public func changeAccountUserDefinedName(withUserDefinedName userDefinedName: String, andPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Account, Error>) -> Void))Parameters
userDefinedNameNew user defined name
andPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Changes the account’s avatar on chain
Declaration
Swift
public func changeAccountAvatar(withImage image: AvatarImage, andPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Account, Error>) -> Void))Parameters
withImageAvatarImage which is platform dependent alias. UIImage for iOS, NSImage for macOS
andPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Changes the account’s userdefined name and avatar on chain
Declaration
Swift
public func changeAccountUserDefinedNameAndAvatar(withUserDefinedName userDefinedName: String, image: AvatarImage, andPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Account, Error>) -> Void))Parameters
withUserDefinedNameNew user defined name
imageAvatarImage
andPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Use this function to obtain a list of Accounts which match a given private key. These accounts are not stored. If you want to store the Account and private key, you should then call storePrivateKey function
Declaration
Swift
public func findAccounts(forPrivateKeyString privateKey: String, completion: @escaping ((Result<Set<Account>, Error>) -> Void))Parameters
forPrivateKeyStringWif formated private key
completionClosure returning Result
-
Checks the chain for presence of account by name
Declaration
Swift
public func chain(hasAccountWithName accountName: String, completion: @escaping ((Result<Bool, Error>) -> Void))Parameters
hasAccountWithNameString account name
completionClosure returning Result
-
Creates a transfer, signs and pushes that transfer to the chain
Declaration
Swift
public func transfer(withPrivateKey privateKey: PrivateKey, to: Name, quantity: Double, tokenContract: TokenContract, memo: String = "", completion: @escaping ((Result<TokenTransferAction, Error>) -> Void))Parameters
withPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
toThe account to be transfered to
quantityThe amount to be transfered
tokenContractThe TokenContract that’s being transfered
memoThe memo for the transfer
completionClosure returning Result
-
Stakes XPR
Declaration
Swift
public func stake(withPrivateKey privateKey: PrivateKey, quantity: Double, completion: @escaping ((Result<Any?, Error>) -> Void))Parameters
withPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
quantityAmount to added or removed from stake. Postive for adding stake, Negative for removing stake. Cannot be zero
completionClosure returning Result
-
Claims XPR staking rewards
Declaration
Swift
public func claimRewards(withPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Any?, Error>) -> Void))Parameters
withPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Refunds unstaking amount if the deferred action did not complete
Declaration
Swift
public func refund(withPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Any?, Error>) -> Void))Parameters
withPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Votes for block producers
Declaration
Swift
public func vote(forProducers producerNames: [Name], withPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Any?, Error>) -> Void))Parameters
forProducersArray of producer Names
withPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Use this function generate a k1 PrivateKey object. See PrivateKey inside of EOSIO for more details
Declaration
Swift
public func generatePrivateKey() -> PrivateKey? -
Creates signature by signing arbitrary string
Declaration
Swift
public func signArbitrary(string: String, withPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<Signature, Error>) -> Void))Parameters
withPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Signs and pushes transaction
Declaration
Swift
public func signAndPushTransaction(withActions actions: [Action], andPrivateKey privateKey: PrivateKey, completion: @escaping ((Result<API.V1.Chain.PushTransaction.Response, Error>) -> Void))Parameters
withActions[Actions]
andPrivateKeyPrivateKey, FYI, this is used to sign on the device. Private key is never sent.
completionClosure returning Result
-
Fetches a single contact’s info without saving to contacts
Declaration
Swift
public func fetchContact(withAccountName accountName: String, completion: @escaping ((Result<Contact?, Error>) -> Void))Parameters
withAccountNameString
completionClosure returning Result
-
Undocumented
Declaration
Swift
public func isSigningRequest(withUrl url: URL) -> Bool -
Undocumented
Declaration
Swift
public func decodeAndPrepareProtonSigningRequest(withURL url: URL, sessionId: String?, completion: @escaping ((Result<Bool, Error>) -> Void)) -
🚧 UNDER CONSTRUCTION: WARNING, DO NOT USE YET
Declaration
Swift
public func declineProtonSigningRequest(autoCompleteRequest: Bool = true, completion: @escaping ((Result<URL?, Error>) -> Void)) -
🚧 UNDER CONSTRUCTION: WARNING, DO NOT USE YET
Declaration
Swift
public func completeProtonSigningRequest() -
🚧 UNDER CONSTRUCTION: WARNING, DO NOT USE YET
Declaration
Swift
public func acceptProtonSigningRequest(privateKey: PrivateKey, autoCompleteRequest: Bool = true, completion: @escaping ((Result<URL?, Error>) -> Void))
Proton Class Reference