forked from trustwallet/TrustSDK-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Objective C Extensions for Xamarin (trustwallet#13)
- Loading branch information
1 parent
aae062e
commit 29997e8
Showing
3 changed files
with
65 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright © 2018 Trust. | ||
// | ||
// This file is part of TrustSDK. The full TrustSDK copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
#if XAMARIN | ||
import Foundation | ||
import TrustCore | ||
import BigInt | ||
|
||
@objc(TrustSDK) | ||
public extension TrustSDK { | ||
@objc | ||
public func signMessage(_ message: Data, address: String? = nil, completion: @escaping (Data) -> Void) { | ||
guard WalletAppManager.hasWalletApp else { | ||
return fallbackToInstall() | ||
} | ||
let addr = Address(string: address!) | ||
let command = SignMessageCommand(message: message, address: addr, callbackScheme: callbackScheme, completion: completion) | ||
execute(command: command) | ||
} | ||
@objc | ||
public func signTransaction(_ gasPrice: String, _ gasLimit: UInt64, _ address: String, amount: String, completion: @escaping (Data) -> Void) { | ||
guard WalletAppManager.hasWalletApp else { | ||
return fallbackToInstall() | ||
} | ||
let gasP = BigInt(gasPrice) | ||
let addr = Address(string: address) | ||
var transaction = Transaction(gasPrice: gasP!, gasLimit: gasLimit, to: addr!) | ||
let am = BigInt(amount) | ||
transaction.amount = am! | ||
|
||
let command = SignTransactionCommand(transaction: transaction, callbackScheme: callbackScheme, completion: completion) | ||
execute(command: command) | ||
} | ||
@objc | ||
public func signPersonalMessage(_ message: Data, address: String? = nil, completion: @escaping (Data) -> Void) { | ||
guard WalletAppManager.hasWalletApp else { | ||
return fallbackToInstall() | ||
} | ||
let addr = Address(string: address!) | ||
let command = SignPersonalMessageCommand(message: message, address: addr, callbackScheme: callbackScheme, completion: completion) | ||
execute(command: command) | ||
} | ||
} | ||
|
||
#endif |
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