-
Notifications
You must be signed in to change notification settings - Fork 3
/
WalletProvider.swift
82 lines (65 loc) · 2.85 KB
/
WalletProvider.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// WalletProvider.swift
//
//
// Created by Andrew Wang on 2022/7/5.
//
import Foundation
import FlowSDK
import Cadence
public protocol WalletProvider {
/// Info to describe wallet provider
var providerInfo: ProviderInfo { get }
/// Method called by user changing network of Flow blockchain.
/// - Parameter network: Flow network
func updateNetwork(_ network: Network) throws
/// Authentication of Flow blockchain account address. if valid account proof data provided,
/// - Parameter accountProofData: Pre-defined struct used to sign for account proot.
func authn(accountProofData: FCLAccountProofData?) async throws
/// To retrive user signatures of specific input message.
/// - Parameter message: A human readable string e.g. "message to be sign"
/// - Returns: Pre-defined signature array.
func getUserSignature(_ message: String) async throws -> [FCLCompositeSignature]
/// Modify Flow blockchain state with transaction compositions.
/// - Parameters:
/// - cadence: Transaction script of Flow transaction.
/// - arguments: Arguments of Flow transaction.
/// - limit: Gas limit (compute limit) of Flow transaction.
/// - authorizers: Addresses of accounts data being modify by current transaction.
/// - Returns: Transaction identifier (tx hash).
func mutate(
cadence: String,
arguments: [Cadence.Argument],
limit: UInt64,
authorizers: [Cadence.Address]
) async throws -> Identifier
/// Retrive preSignable info for Flow transaction.
/// - Parameter preSignable: Pre-defined type.
/// - Returns: Data includes proposer, payer, authorization.
/// Only be used if wallet provider implement web send transaction.
func preAuthz(preSignable: PreSignable?) async throws -> AuthData
/// Method to modify url request before sending. Default implementation will not modify request.
/// - Parameter request: URLRequest about to send.
/// - Returns: URLRequest that has been modified.
func modifyRequest(_ request: URLRequest) -> URLRequest
/// Entry of Universal Links
/// - Parameter userActivity: the same userActivity from UIApplicationDelegate
/// Only be used if wallet provider involve other native app authentication.
func continueForLinks(_ userActivity: NSUserActivity)
/// Entry of custom scheme
/// - Parameters:
/// - url: custom scheme URL
/// Only be used if wallet provider involve other native app authentication.
func application(open url: URL)
// TODO: implementation
/*
func openId() async throws -> JSON {}
*/
}
extension WalletProvider {
func modifyRequest(_ request: URLRequest) -> URLRequest {
request
}
public func continueForLinks(_ userActivity: NSUserActivity) {}
public func application(open url: URL) {}
}