forked from oday0311/TrustCore
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Coin and blockchain improvements (#17)
1 parent
680570c
commit 4659b30
Showing
10 changed files
with
106 additions
and
38 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
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,37 @@ | ||
// Copyright © 2017-2018 Trust. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
import Foundation | ||
|
||
/// Blockchain types | ||
public enum BlockchainType { | ||
case bitcoin | ||
case ethereum | ||
} | ||
|
||
/// Blockchains | ||
public struct Blockchain: Equatable { | ||
public var chainID: Int | ||
public var type: BlockchainType | ||
|
||
public init(chainID: Int, type: BlockchainType) { | ||
self.chainID = chainID | ||
self.type = type | ||
} | ||
} | ||
|
||
extension Blockchain { | ||
public static let bitcoin = Blockchain(chainID: 0, type: .bitcoin) | ||
|
||
public static let ethereum = Blockchain(chainID: 1, type: .ethereum) | ||
public static let ropsten = Blockchain(chainID: 3, type: .ethereum) | ||
public static let rinkeby = Blockchain(chainID: 4, type: .ethereum) | ||
public static let eosClassic = Blockchain(chainID: 20, type: .ethereum) | ||
public static let kovan = Blockchain(chainID: 42, type: .ethereum) | ||
public static let go = Blockchain(chainID: 60, type: .ethereum) | ||
public static let ethereumClassic = Blockchain(chainID: 61, type: .ethereum) | ||
public static let ethereumClassicTestnet = Blockchain(chainID: 62, type: .ethereum) | ||
} |
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
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,15 @@ | ||
// Copyright © 2017-2018 Trust. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
import TrustCore | ||
import XCTest | ||
|
||
class CoinTests: XCTestCase { | ||
func testCreateWithIDOnly() { | ||
XCTAssertEqual(Coin(coinType: 0).blockchain, .bitcoin) | ||
XCTAssertEqual(Coin(coinType: 60).blockchain, .ethereum) | ||
} | ||
} |
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