Skip to content

Commit

Permalink
Merge pull request #14 from v-sharaev/release/4.0.1
Browse files Browse the repository at this point in the history
Release/4.0.1
  • Loading branch information
vl-px authored Dec 16, 2019
2 parents 66e251e + dcbad0f commit c372b71
Show file tree
Hide file tree
Showing 9 changed files with 483 additions and 18 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# CHANGELOG

## Changelog 4.0.1 - 2019-12-16
### Added
* getFeeForWithdrawEthOperation method
* getFeeForWithdrawBtcOperation method
* getFeeForWithdrawERC20Operation method

### Removed
* WIF field from getFeeForCreateContract methods

### Tests
* Added tests to new methods

## Changelog 4.0.0 - 2019-12-03

### Added
Expand Down
2 changes: 1 addition & 1 deletion ECHO.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "ECHO"
spec.version = "4.0.0"
spec.version = "4.0.1"
spec.summary = "Echo iOS Framework"
spec.homepage = "https://github.com/echoprotocol/echo-ios-framework"
spec.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
4 changes: 2 additions & 2 deletions ECHO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,7 @@
"$(SRCROOT)/Libraries/openssl/lib",
"$(SRCROOT)/Libraries/ed25519/lib/SimulatorRelease/",
);
MARKETING_VERSION = 4.0.0;
MARKETING_VERSION = 4.0.1;
MODULEMAP_FILE = "./ECHO/Supports Files/ECHO.modulemap";
PRODUCT_BUNDLE_IDENTIFIER = org.echo.mobile.framework;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
Expand Down Expand Up @@ -2022,7 +2022,7 @@
"$(SRCROOT)/Libraries/openssl/lib",
"$(SRCROOT)/Libraries/ed25519/lib/SimulatorRelease/",
);
MARKETING_VERSION = 4.0.0;
MARKETING_VERSION = 4.0.1;
MODULEMAP_FILE = "./ECHO/Supports Files/ECHO.modulemap";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.echo.mobile.framework;
Expand Down
282 changes: 279 additions & 3 deletions ECHO/Core/Facades/Implementations/FeeFacadeImp.swift

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ECHO/Core/Facades/Protocols/BtcFacade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public protocol BtcFacade {
- Parameter backupAddress: Bitcoin address to possibility of a refund
- Parameter assetForFee: Id of asset which is pay fee
- Parameter completion: Callback in which the information will return whether the transaction was successful.
- Parameter noticeHandler: Callback in which the information will return whether the transaction was confirmed.

- Remark:
Default asset is **"1.3.0"**
Expand All @@ -37,7 +38,9 @@ public protocol BtcFacade {
- Parameter wif: Sender wif from account
- Parameter toBtcAddress: Receiver bitcoin address
- Parameter amount: Amount
- Parameter assetForFee: Id of asset which is pay fee
- Parameter completion: Callback in which the information will return whether the transaction was successful.
- Parameter noticeHandler: Callback in which the information will return whether the transaction was confirmed.
*/
func withdrawBtc(nameOrId: String,
wif: String,
Expand Down
1 change: 1 addition & 0 deletions ECHO/Core/Facades/Protocols/EthFacade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public protocol EthFacade {
- Parameter wif: Sender wif from account
- Parameter toEthAddress: Receiver ethereum address
- Parameter amount: Amount
- Parameter assetForFee: Id of asset which is pay fee
- Parameter completion: Callback in which the information will return whether the transaction was successful.
- Parameter noticeHandler: Callback in which the information will return whether the transaction was confirmed.
*/
Expand Down
56 changes: 50 additions & 6 deletions ECHO/Core/Facades/Protocols/FeeFacade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ public protocol FeeFacade {
Function for evaluating the fee creates contract operation

- Parameter registrarNameOrId: Name or id of account that creates the contract
- Parameter wif: WIF from account for transaction signature
- Parameter assetId: Asset of contract
- Parameter byteCode: Bytecode of the contract
- Parameter supportedAssetId: If you dont want to link the contract with the specified asset
- Parameter ethAccuracy: If true all balances passing to contract with ethereum accuracy
- Parameter parameters: Parameters of constructor
- Parameter completion: Callback which returns fee for create contract operation or error
- Parameter completion: Callback which returns fee for operation or error
*/
func getFeeForCreateContract(registrarNameOrId: String,
wif: String,
assetId: String,
amount: UInt?,
assetForFee: String?,
Expand All @@ -55,15 +53,13 @@ public protocol FeeFacade {
Function for evaluating the fee creates contract operation

- Parameter registrarNameOrId: Name or id of account that creates the contract
- Parameter wif: WIF from account for transaction signature
- Parameter assetId: Asset of contract
- Parameter byteCode: Full bytecode for contract creation
- Parameter supportedAssetId: If you dont want to link the contract with the specified asset
- Parameter ethAccuracy: If true all balances passing to contract with ethereum accuracy
- Parameter completion: Callback which returns fee for create contract operation or error
- Parameter completion: Callback which returns fee for operation or error
*/
func getFeeForCreateContract(registrarNameOrId: String,
wif: String,
assetId: String,
amount: UInt?,
assetForFee: String?,
Expand Down Expand Up @@ -113,4 +109,52 @@ public protocol FeeFacade {
contratId: String,
byteCode: String,
completion: @escaping Completion<CallContractFee>)

/**
Function for evaluating the fee of withdraw ETH operation

- Parameter nameOrId: Name or id
- Parameter toEthAddress: Receiver ethereum address
- Parameter amount: Amount
- Parameter assetForFee: Id of asset which is pay fee
- Parameter completion: Callback which returns fee for operation or error
*/
func getFeeForWithdrawEthOperation(nameOrId: String,
toEthAddress: String,
amount: UInt,
assetForFee: String?,
completion: @escaping Completion<AssetAmount>)

/**
Function for evaluating the fee of withdraw BTC operation

- Parameter nameOrId: Name or id
- Parameter toBtcAddress: Receiver bitcoin address
- Parameter amount: Amount
- Parameter assetForFee: Id of asset which is pay fee
- Parameter completion: Callback which returns fee for operation or error
*/
func getFeeForWithdrawBtcOperation(nameOrId: String,
toBtcAddress: String,
amount: UInt,
assetForFee: String?,
completion: @escaping Completion<AssetAmount>)

/**
Function for evaluating the fee of withdraw ERC20 token operation

- Parameter nameOrId: Name or id
- Parameter toEthAddress: Receiver eth address
- Parameter tokenId: Echo token id for withdraw
- Parameter value: Amount
- Parameter assetForFee:Id of asset which is pay fee
- Parameter completion: Callback which returns fee for operation or error
*/
func getFeeForWithdrawERC20Operation(nameOrId: String,
toEthAddress: String,
tokenId: String,
value: String,
assetForFee: String?,
completion: @escaping Completion<AssetAmount>)

}
45 changes: 41 additions & 4 deletions ECHO/Core/Interface/ECHO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ final public class ECHO: InterfaceFacades, Startable {
}

public func getFeeForCreateContract(registrarNameOrId: String,
wif: String,
assetId: String,
amount: UInt?,
assetForFee: String?,
Expand All @@ -286,7 +285,6 @@ final public class ECHO: InterfaceFacades, Startable {
completion: @escaping Completion<AssetAmount>) {

feeFacade.getFeeForCreateContract(registrarNameOrId: registrarNameOrId,
wif: wif,
assetId: assetId,
amount: amount,
assetForFee: assetForFee,
Expand All @@ -297,7 +295,6 @@ final public class ECHO: InterfaceFacades, Startable {
}

public func getFeeForCreateContract(registrarNameOrId: String,
wif: String,
assetId: String,
amount: UInt?,
assetForFee: String?,
Expand All @@ -308,7 +305,6 @@ final public class ECHO: InterfaceFacades, Startable {
completion: @escaping Completion<AssetAmount>) {

feeFacade.getFeeForCreateContract(registrarNameOrId: registrarNameOrId,
wif: wif,
assetId: assetId,
amount: amount,
assetForFee: assetForFee,
Expand Down Expand Up @@ -355,6 +351,47 @@ final public class ECHO: InterfaceFacades, Startable {
completion: completion)
}

public func getFeeForWithdrawEthOperation(nameOrId: String,
toEthAddress: String,
amount: UInt,
assetForFee: String?,
completion: @escaping Completion<AssetAmount>) {

feeFacade.getFeeForWithdrawEthOperation(nameOrId: nameOrId,
toEthAddress: toEthAddress,
amount: amount,
assetForFee: assetForFee,
completion: completion)
}

public func getFeeForWithdrawBtcOperation(nameOrId: String,
toBtcAddress: String,
amount: UInt,
assetForFee: String?,
completion: @escaping Completion<AssetAmount>) {

feeFacade.getFeeForWithdrawBtcOperation(nameOrId: nameOrId,
toBtcAddress: toBtcAddress,
amount: amount,
assetForFee: assetForFee,
completion: completion)
}

public func getFeeForWithdrawERC20Operation(nameOrId: String,
toEthAddress: String,
tokenId: String,
value: String,
assetForFee: String?,
completion: @escaping Completion<AssetAmount>) {

feeFacade.getFeeForWithdrawERC20Operation(nameOrId: nameOrId,
toEthAddress: toEthAddress,
tokenId: tokenId,
value: value,
assetForFee: assetForFee,
completion: completion)
}

// MARK: TransactionFacade

public func sendTransferOperation(fromNameOrId: String,
Expand Down
96 changes: 94 additions & 2 deletions ECHONetworkTests/ECHOInterfaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ class ECHOInterfaceTests: XCTestCase {
//act
echo.start { [unowned self] (result) in
self.echo.getFeeForCreateContract(registrarNameOrId: Constants.defaultName,
wif: Constants.defaultWIF,
assetId: Constants.defaultAsset,
amount: 0, assetForFee: nil,
byteCode: Constants.counterContractByteCode,
Expand Down Expand Up @@ -731,7 +730,6 @@ class ECHOInterfaceTests: XCTestCase {
//act
echo.start { [unowned self] (result) in
self.echo.getFeeForCreateContract(registrarNameOrId: Constants.defaultName,
wif: Constants.defaultWIF,
assetId: Constants.defaultAsset,
amount: 0, assetForFee: nil,
byteCode: Constants.counterContractByteCode,
Expand Down Expand Up @@ -2081,6 +2079,37 @@ class ECHOInterfaceTests: XCTestCase {
}
}

func testGetFeeWithdrawEth() {
//arrange
echo = ECHO(settings: Settings(build: {
$0.apiOptions = [.database, .networkBroadcast, .networkNodes, .accountHistory]
$0.network = ECHONetwork(url: Constants.nodeUrl, prefix: .echo, echorandPrefix: .echo)
}))
let exp = expectation(description: "testGetFeeWithdrawEth")
var fee: AssetAmount!

//act
echo.start { [unowned self] (result) in
self.echo.getFeeForWithdrawEthOperation(nameOrId: Constants.defaultName,
toEthAddress: Constants.defaultETHAddress,
amount: 1,
assetForFee: nil) { (result) in
switch result {
case .success(let aFee):
fee = aFee
exp.fulfill()
case .failure(let error):
XCTFail("testGetFeeWithdrawEth failed \(error)")
}
}
}

//assert
waitForExpectations(timeout: Constants.timeout) { error in
XCTAssertNotNil(fee)
}
}

func testWithdrawEth() {

//arrange
Expand Down Expand Up @@ -2312,6 +2341,37 @@ class ECHOInterfaceTests: XCTestCase {
}
}

func testGetFeeWithdrawBtc() {
//arrange
echo = ECHO(settings: Settings(build: {
$0.apiOptions = [.database, .networkBroadcast, .networkNodes, .accountHistory]
$0.network = ECHONetwork(url: Constants.nodeUrl, prefix: .echo, echorandPrefix: .echo)
}))
let exp = expectation(description: "testGetFeeWithdrawBtc")
var fee: AssetAmount!

//act
echo.start { [unowned self] (result) in
self.echo.getFeeForWithdrawBtcOperation(nameOrId: Constants.defaultName,
toBtcAddress: Constants.defaultBTCAddress,
amount: 1,
assetForFee: nil) { (result) in
switch result {
case .success(let aFee):
fee = aFee
exp.fulfill()
case .failure(let error):
XCTFail("testGetFeeWithdrawBtc failed \(error)")
}
}
}

//assert
waitForExpectations(timeout: Constants.timeout) { error in
XCTAssertNotNil(fee)
}
}

func testWithdrawBtc() {

//arrange
Expand Down Expand Up @@ -2474,6 +2534,38 @@ class ECHOInterfaceTests: XCTestCase {
}
}

func testGetFeeWithdrawERC20() {
//arrange
echo = ECHO(settings: Settings(build: {
$0.apiOptions = [.database, .networkBroadcast, .networkNodes, .accountHistory]
$0.network = ECHONetwork(url: Constants.nodeUrl, prefix: .echo, echorandPrefix: .echo)
}))
let exp = expectation(description: "testGetFeeWithdrawERC20")
var fee: AssetAmount!

//act
echo.start { [unowned self] (result) in
self.echo.getFeeForWithdrawERC20Operation(nameOrId: Constants.defaultName,
toEthAddress: Constants.defaultETHAddress,
tokenId: Constants.erc20TokenEchoId,
value: "1",
assetForFee: nil) { (result) in
switch result {
case .success(let aFee):
fee = aFee
exp.fulfill()
case .failure(let error):
XCTFail("testGetFeeWithdrawERC20 failed \(error)")
}
}
}

//assert
waitForExpectations(timeout: Constants.timeout) { error in
XCTAssertNotNil(fee)
}
}

func testWithdrawERC20() {

//arrange
Expand Down

0 comments on commit c372b71

Please sign in to comment.