Skip to content

Commit

Permalink
Merge pull request #13 from v-sharaev/release/4.0.0
Browse files Browse the repository at this point in the history
Release/4.0.0
  • Loading branch information
vl-px authored Dec 6, 2019
2 parents 7469fdc + 4a6f66d commit 66e251e
Show file tree
Hide file tree
Showing 61 changed files with 4,492 additions and 220 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# CHANGELOG

## Changelog 4.0.0 - 2019-12-03

### Added

#### ERC20 Sidechain
Socket operations:
* GetERC20TokenSocketOperation
* CheckERC20TokenSocketOperation
* GetERC20AccountDepositsSocketOperation
* GetERC20AccountWithdrawalsSocketOperation

Chain operations:
* SidechainERC20RegisterTokenOperation
* SidechainERC20DepositTokenOperation
* SidechainERC20WithdrawTokenOperation
* SidechainERC20IssueOperation
* SidechainERC20BurnOperation

#### BTC Sidechain
Socket operations:
* GetBtcAddressSocketOperation

Chain operations:
* SidechainBTCCreateAddressOperation
* SidechainBTCWithdrawOperation
* SidechainBTCCreateIntermediateDepositOperation

#### Chain operations:
* ContractFundPoolOperation
* BlockRewardOperation

## Changelog 3.7.2 - 2019-11-19

### Fixed
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 = "3.7.2"
spec.version = "4.0.0"
spec.summary = "Echo iOS Framework"
spec.homepage = "https://github.com/echoprotocol/echo-ios-framework"
spec.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
140 changes: 128 additions & 12 deletions ECHO.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions ECHO/Core/Classes/Extensions/Data+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ extension Data {
return Data() + Int8(clamping: input).littleEndian
}

static func fromUInt8(_ input: UInt8) -> Data {

return Data() + UInt8(clamping: input).littleEndian
}

static func fromInt16(_ input: Int) -> Data {

return Data() + Int16(clamping: input).littleEndian
Expand Down
5 changes: 4 additions & 1 deletion ECHO/Core/Classes/Objects/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ public enum ECHOError: Swift.Error, Equatable {
/// Indicates that object identifier have not valid type
case identifier(ObjectType)

/// Indicates that ETH address have not valid format or checksum
/// Indicates that Ethereum address have not valid format or checksum
case invalidETHAddress

/// Indicates that Bitcoin address have not valid format or checksum
case invalidBTCAddress

case undefined
}
4 changes: 2 additions & 2 deletions ECHO/Core/Classes/Objects/ObjectType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum ObjectType: Int {
case vestingBalance
case balance
case frozenBalance
case committeeFrozenBalance
case committeeFrozenBalance //10
case contract
case contractResult
case ethAddress
Expand All @@ -40,7 +40,7 @@ public enum ObjectType: Int {
case depositERC20Token
case withdrawERC20Token
case btcAddress
case btcIntermediateDeposit
case btcIntermediateDeposit //20
case btcDeposit
case btcWithdraw
case btcAggregating
Expand Down
2 changes: 0 additions & 2 deletions ECHO/Core/Classes/Objects/RegistrationTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ public struct RegistrationTask: Decodable {
difficulty = try values.decode(UInt8.self, forKey: .difficulty)
}
}


64 changes: 64 additions & 0 deletions ECHO/Core/Classes/Objects/SidechainObjects/BTC/BtcAddress.swift
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public struct BtcDeposit: ECHOObject, Decodable {
case account
case intermediateDepositId = "intermediate_deposit_id"
case txInfo = "tx_info"
case blockNumber = "block_number"
case isApproved = "is_approved"
case isSent = "is_sent"
case approves
}

public var id: String
public let account: Account
public let intermediateDepositId: String
public let txInfo: BtcDepositTransactionInfo
public let blockNumber: UInt
public let isSent: Bool
public let isApproved: Bool
public let approves: [String]

Expand All @@ -36,7 +36,7 @@ public struct BtcDeposit: ECHOObject, Decodable {
account = Account(accountId)
intermediateDepositId = try values.decode(String.self, forKey: .intermediateDepositId)
txInfo = try values.decode(BtcDepositTransactionInfo.self, forKey: .txInfo)
blockNumber = try values.decode(UInt.self, forKey: .blockNumber)
isSent = try values.decode(Bool.self, forKey: .isSent)
isApproved = try values.decode(Bool.self, forKey: .isApproved)
approves = try values.decode([String].self, forKey: .approves)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ public struct BtcWithdrawal: ECHOObject, Decodable {
case account
case btcAddress = "btc_addr"
case value
case blockNumber = "block_number"
case isSent = "is_sent"
case echoBlockNumber = "echo_block_number"
case isApproved = "is_approved"
case approves
}

public var id: String
public let account: Account
public let btcAddress: String
public let value: UInt
public let blockNumber: UInt
public let isSent: Bool
public let echoBlockNumber: UInt
public let isApproved: Bool
public let approves: [String]

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: BtcWithdrawalCodingKeys.self)
Expand All @@ -37,8 +37,8 @@ public struct BtcWithdrawal: ECHOObject, Decodable {
account = Account(accountId)
btcAddress = try values.decode(String.self, forKey: .btcAddress)
value = try values.decode(UInt.self, forKey: .value)
blockNumber = try values.decode(UInt.self, forKey: .blockNumber)
isSent = try values.decode(Bool.self, forKey: .isSent)
echoBlockNumber = try values.decode(UInt.self, forKey: .echoBlockNumber)
isApproved = try values.decode(Bool.self, forKey: .isApproved)
approves = try values.decode([String].self, forKey: .approves)
}
}
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 ECHO/Core/Classes/Objects/SidechainObjects/ERC20/ERC20Token.swift
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)
}
}
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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

/**
Represents eth_address_object from blockchain
Represents eth address object from blockchain
*/
public struct EthAddress: ECHOObject, Decodable {

Expand Down
Loading

0 comments on commit 66e251e

Please sign in to comment.