-
Notifications
You must be signed in to change notification settings - Fork 11
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 #44 from XYOracleNetwork/feature/naming-standardiz…
…ation Naming Standardization
- Loading branch information
Showing
61 changed files
with
1,636 additions
and
1,440 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 |
---|---|---|
@@ -1,52 +1,52 @@ | ||
import Foundation | ||
|
||
public class Account: AccountInstance, AccountStatic { | ||
let _account: XyoAddress | ||
var _previousHash: String? = nil | ||
|
||
public static func fromPrivateKey(key: Data?) -> AccountInstance { | ||
guard let key else { | ||
return Account() | ||
let _account: XyoAddress | ||
var _previousHash: String? = nil | ||
|
||
public static func fromPrivateKey(key: Data?) -> AccountInstance { | ||
guard let key else { | ||
return Account() | ||
} | ||
let address = XyoAddress(key) | ||
return Account(address: address) | ||
} | ||
let address = XyoAddress(key) | ||
return Account(address: address) | ||
} | ||
|
||
public static func random() -> AccountInstance { | ||
return Account() | ||
} | ||
public static func random() -> AccountInstance { | ||
return Account() | ||
} | ||
|
||
init() { | ||
self._account = XyoAddress() | ||
} | ||
init() { | ||
self._account = XyoAddress() | ||
} | ||
|
||
init(address: XyoAddress) { | ||
self._account = address | ||
} | ||
init(address: XyoAddress) { | ||
self._account = address | ||
} | ||
|
||
public var address: Address { | ||
guard let value = self._account.address else { | ||
fatalError("Invalid address") | ||
public var address: Address { | ||
guard let value = self._account.address else { | ||
fatalError("Invalid address") | ||
} | ||
return value as Address | ||
} | ||
return value as Address | ||
} | ||
|
||
public var addressBytes: Data { | ||
guard let value = self._account.addressBytes else { | ||
fatalError("Invalid addressBytes") | ||
public var addressBytes: Data { | ||
guard let value = self._account.addressBytes else { | ||
fatalError("Invalid addressBytes") | ||
} | ||
return value | ||
} | ||
return value | ||
} | ||
|
||
public var previousHash: Hash? { | ||
return self._previousHash | ||
} | ||
public var previousHash: Hash? { | ||
return self._previousHash | ||
} | ||
|
||
public func sign(hash: Hash) throws -> String { | ||
guard let value = try self._account.sign(hash: hash) else { | ||
fatalError("Error signing hash") | ||
public func sign(hash: Hash) throws -> String { | ||
guard let value = try self._account.sign(hash: hash) else { | ||
fatalError("Error signing hash") | ||
} | ||
_previousHash = value | ||
return value | ||
} | ||
_previousHash = value | ||
return value | ||
} | ||
} |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import Foundation | ||
|
||
public protocol AccountInstance { | ||
var address: Address { get } | ||
var addressBytes: Data { get } | ||
var previousHash: Hash? { get } | ||
// var previousHashBytes: Data? { get set } | ||
// var `private`: Data? { get } | ||
// var `public`: Data? { get } | ||
var address: Address { get } | ||
var addressBytes: Data { get } | ||
var previousHash: Hash? { get } | ||
// var previousHashBytes: Data? { get set } | ||
// var `private`: Data? { get } | ||
// var `public`: Data? { get } | ||
|
||
func sign(hash: Hash) throws -> String | ||
// func sign(hash: Data, previousHash: Data?) async throws -> Data | ||
// func verify(msg: Data, signature: Data) async throws -> Bool | ||
func sign(hash: Hash) throws -> String | ||
// func sign(hash: Data, previousHash: Data?) async throws -> Data | ||
// func verify(msg: Data, signature: Data) async throws -> Bool | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import Foundation | ||
|
||
public protocol AccountStatic { | ||
// associatedtype T: AccountInstance | ||
// associatedtype C: XyoPayload | ||
// associatedtype T: AccountInstance | ||
// associatedtype C: XyoPayload | ||
|
||
// static func create(options: C?) async throws -> T | ||
static func fromPrivateKey(key: Data?) -> AccountInstance | ||
static func random() -> AccountInstance | ||
// static func create(options: C?) async throws -> T | ||
static func fromPrivateKey(key: Data?) -> AccountInstance | ||
static func random() -> AccountInstance | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import Foundation | ||
|
||
enum XyoAddressError: Error { | ||
case invalidPrivateKey | ||
case invalidPrivateKeyLength | ||
case invalidHash | ||
case signingFailed | ||
case invalidPrivateKey | ||
case invalidPrivateKeyLength | ||
case invalidHash | ||
case signingFailed | ||
} |
Oops, something went wrong.