-
Notifications
You must be signed in to change notification settings - Fork 4
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 #13 from v-sharaev/release/4.0.0
Release/4.0.0
- Loading branch information
Showing
61 changed files
with
4,492 additions
and
220 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,3 @@ public struct RegistrationTask: Decodable { | |
difficulty = try values.decode(UInt8.self, forKey: .difficulty) | ||
} | ||
} | ||
|
||
|
64 changes: 64 additions & 0 deletions
64
ECHO/Core/Classes/Objects/SidechainObjects/BTC/BtcAddress.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,64 @@ | ||
// | ||
// BtcAddress.swift | ||
// ECHO | ||
// | ||
// Created by Vladimir Sharaev on 28.11.2019. | ||
// Copyright © 2019 PixelPlex. All rights reserved. | ||
// | ||
|
||
/** | ||
Represents btc address object from blockchain | ||
*/ | ||
public struct BtcAddress: ECHOObject, Decodable { | ||
|
||
enum EthAddressKeys: String, CodingKey { | ||
case id | ||
case accountId = "account" | ||
case depositAddress = "deposit_address" | ||
case committeeMemberIdsInScript = "committee_member_ids_in_script" | ||
case isRelevant = "is_relevant" | ||
case backupAddress = "backup_address" | ||
case extensions | ||
} | ||
|
||
public var id: String | ||
public let accountId: String | ||
public let depositAddress: BtcDepositAddress | ||
public let committeeMemberIdsInScript: [BtcCommitteeMemberIdInScript] | ||
public let isRelevant: Bool | ||
public let backupAddress: String | ||
public let extensions: Extensions | ||
|
||
public init(from decoder: Decoder) throws { | ||
|
||
let values = try decoder.container(keyedBy: EthAddressKeys.self) | ||
id = try values.decode(String.self, forKey: .id) | ||
accountId = try values.decode(String.self, forKey: .accountId) | ||
depositAddress = try values.decode(BtcDepositAddress.self, forKey: .depositAddress) | ||
let members = try values.decode([[String]].self, forKey: .committeeMemberIdsInScript) | ||
isRelevant = try values.decode(Bool.self, forKey: .isRelevant) | ||
backupAddress = try values.decode(String.self, forKey: .backupAddress) | ||
extensions = Extensions() | ||
|
||
var committeeMemberIdsInScript = [BtcCommitteeMemberIdInScript]() | ||
members.forEach { | ||
guard let accountId = $0.first, | ||
let script = $0.last else { | ||
return | ||
} | ||
|
||
let member = BtcCommitteeMemberIdInScript(accountId: accountId, script: script) | ||
committeeMemberIdsInScript.append(member) | ||
} | ||
self.committeeMemberIdsInScript = committeeMemberIdsInScript | ||
} | ||
} | ||
|
||
public struct BtcDepositAddress: Decodable { | ||
let address: String | ||
} | ||
|
||
public struct BtcCommitteeMemberIdInScript { | ||
let accountId: String | ||
let script: String | ||
} |
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
45 changes: 45 additions & 0 deletions
45
ECHO/Core/Classes/Objects/SidechainObjects/ERC20/ERC20Deposit.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,45 @@ | ||
// | ||
// ERC20Deposit.swift | ||
// ECHO | ||
// | ||
// Created by Vladimir Sharaev on 29.11.2019. | ||
// Copyright © 2019 PixelPlex. All rights reserved. | ||
// | ||
|
||
/** | ||
Represents erc20_deposit_object from blockchain | ||
*/ | ||
public struct ERC20Deposit: ECHOObject, Decodable { | ||
|
||
enum ERC20DepositCodingKeys: String, CodingKey { | ||
case id | ||
case account | ||
case erc20Address = "erc20_addr" | ||
case value | ||
case transactionHash = "transaction_hash" | ||
case isApproved = "is_approved" | ||
case approves | ||
} | ||
|
||
public var id: String | ||
public let account: Account | ||
public let erc20Address: String | ||
public let value: String | ||
public let transactionHash: String | ||
public let isApproved: Bool | ||
public let approves: [String] | ||
|
||
public init(from decoder: Decoder) throws { | ||
|
||
let values = try decoder.container(keyedBy: ERC20DepositCodingKeys.self) | ||
id = try values.decode(String.self, forKey: .id) | ||
erc20Address = try values.decode(String.self, forKey: .erc20Address) | ||
value = try values.decode(String.self, forKey: .value) | ||
transactionHash = try values.decode(String.self, forKey: .transactionHash) | ||
isApproved = try values.decode(Bool.self, forKey: .isApproved) | ||
approves = try values.decode([String].self, forKey: .approves) | ||
|
||
let accountId = try values.decode(String.self, forKey: .account) | ||
account = Account(accountId) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
ECHO/Core/Classes/Objects/SidechainObjects/ERC20/ERC20Token.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,46 @@ | ||
// | ||
// ERC20Token.swift | ||
// ECHO | ||
// | ||
// Created by Vladimir Sharaev on 31.10.2019. | ||
// Copyright © 2019 PixelPlex. All rights reserved. | ||
// | ||
|
||
/** | ||
Information about erc20 token | ||
*/ | ||
public struct ERC20Token: ECHOObject, Decodable { | ||
|
||
enum ERC20TokenCodingKeys: String, CodingKey { | ||
case id | ||
case owner | ||
case ethAddress = "eth_addr" | ||
case contract | ||
case name | ||
case symbol | ||
case decimals | ||
} | ||
|
||
public var id: String | ||
public var owner: String? | ||
public var ethAddress: String? | ||
public var contract: String? | ||
public var name: String? | ||
public var symbol: String? | ||
public var decimals: UInt8? | ||
|
||
public init(id: String) { | ||
self.id = id | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let values = try decoder.container(keyedBy: ERC20TokenCodingKeys.self) | ||
id = try values.decode(String.self, forKey: .id) | ||
owner = try values.decode(String.self, forKey: .owner) | ||
ethAddress = try values.decode(String.self, forKey: .ethAddress) | ||
contract = try values.decode(String.self, forKey: .contract) | ||
name = try values.decode(String.self, forKey: .name) | ||
symbol = try values.decode(String.self, forKey: .symbol) | ||
decimals = try values.decode(UInt8.self, forKey: .decimals) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
ECHO/Core/Classes/Objects/SidechainObjects/ERC20/ERC20Withdrawal.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,50 @@ | ||
// | ||
// ERC20Withdrawal.swift | ||
// ECHO | ||
// | ||
// Created by Vladimir Sharaev on 29.11.2019. | ||
// Copyright © 2019 PixelPlex. All rights reserved. | ||
// | ||
|
||
/** | ||
Represents erc20_withdrawal_object from blockchain | ||
*/ | ||
public struct ERC20Withdrawal: ECHOObject, Decodable { | ||
|
||
enum ERC20WithdrawalCodingKeys: String, CodingKey { | ||
case id | ||
case withdrawId = "withdraw_id" | ||
case account | ||
case toAddress = "to" | ||
case erc20Token = "erc20_token" | ||
case value | ||
case isApproved = "is_approved" | ||
case approves | ||
} | ||
|
||
public var id: String | ||
public let withdrawId: UInt | ||
public let account: Account | ||
public let toAddress: String | ||
public let erc20Token: ERC20Token | ||
public let value: String | ||
public let isApproved: Bool | ||
public let approves: [String] | ||
|
||
public init(from decoder: Decoder) throws { | ||
|
||
let values = try decoder.container(keyedBy: ERC20WithdrawalCodingKeys.self) | ||
id = try values.decode(String.self, forKey: .id) | ||
withdrawId = try values.decode(UInt.self, forKey: .withdrawId) | ||
toAddress = try values.decode(String.self, forKey: .toAddress) | ||
value = try values.decode(String.self, forKey: .value) | ||
isApproved = try values.decode(Bool.self, forKey: .isApproved) | ||
approves = try values.decode([String].self, forKey: .approves) | ||
|
||
let tokenId = try values.decode(String.self, forKey: .erc20Token) | ||
erc20Token = ERC20Token(id: tokenId) | ||
|
||
let accountId = try values.decode(String.self, forKey: .account) | ||
account = Account(accountId) | ||
} | ||
} |
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
Oops, something went wrong.