add preAppBase getAccount method and rename other preAppbase methods (#20)
* add preAppBase getAccount method and rename other preAppbase methods * Removed PreAppbase stuff and updated a few operations for "condenser_api."
This commit is contained in:
parent
0608e4359a
commit
a4291384b5
|
@ -57,18 +57,10 @@ public struct API {
|
|||
|
||||
public struct GetDynamicGlobalProperties: Request {
|
||||
public typealias Response = DynamicGlobalProperties
|
||||
public let method = "get_dynamic_global_properties"
|
||||
public let method = "condenser_api.get_dynamic_global_properties"
|
||||
public let params: RequestParams<[String]>? = RequestParams([])
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public struct TestnetGetDynamicGlobalProperties: Request {
|
||||
public typealias Response = DynamicGlobalProperties
|
||||
public let method = "call"
|
||||
public let params: CallParams<SignedTransaction>?
|
||||
public init() {
|
||||
self.params = CallParams("condenser_api", "get_dynamic_global_properties", [])
|
||||
}
|
||||
}
|
||||
|
||||
public struct SteemPrices: Decodable {
|
||||
public let steemSbd: Float32
|
||||
|
@ -115,16 +107,6 @@ public struct API {
|
|||
}
|
||||
|
||||
public struct BroadcastTransaction: Request {
|
||||
public typealias Response = TransactionConfirmation
|
||||
public let method = "call"
|
||||
public let params: CallParams<SignedTransaction>?
|
||||
public init(transaction: SignedTransaction) {
|
||||
self.params = CallParams("network_broadcast_api", "broadcast_transaction_synchronous", [transaction])
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Uses pre-appbase condenser_api
|
||||
public struct TestnetBroadcastTransaction: Request {
|
||||
public typealias Response = TransactionConfirmation
|
||||
public let method = "call"
|
||||
public let params: CallParams<SignedTransaction>?
|
||||
|
@ -211,7 +193,7 @@ public struct API {
|
|||
/// Fetch accounts.
|
||||
public struct GetAccounts: Request {
|
||||
public typealias Response = [ExtendedAccount]
|
||||
public let method = "get_accounts"
|
||||
public let method = "condenser_api.get_accounts"
|
||||
public let params: RequestParams<[String]>?
|
||||
public init(names: [String]) {
|
||||
self.params = RequestParams([names])
|
||||
|
|
|
@ -124,7 +124,7 @@ class ClientTest: XCTestCase {
|
|||
)
|
||||
comment.parentPermlink = "test"
|
||||
let vote = Operation.Vote(voter: "test19", author: "test19", permlink: comment.permlink)
|
||||
testnetClient.send(API.TestnetGetDynamicGlobalProperties()) { props, error in
|
||||
testnetClient.send(API.GetDynamicGlobalProperties()) { props, error in
|
||||
XCTAssertNil(error)
|
||||
guard let props = props else {
|
||||
return XCTFail("Unable to get props")
|
||||
|
@ -139,7 +139,7 @@ class ClientTest: XCTestCase {
|
|||
guard let stx = try? tx.sign(usingKey: key, forChain: testnetId) else {
|
||||
return XCTFail("Unable to sign tx")
|
||||
}
|
||||
testnetClient.send(API.TestnetBroadcastTransaction(transaction: stx)) { res, error in
|
||||
testnetClient.send(API.BroadcastTransaction(transaction: stx)) { res, error in
|
||||
XCTAssertNil(error)
|
||||
if let res = res {
|
||||
XCTAssertFalse(res.expired)
|
||||
|
@ -167,6 +167,16 @@ class ClientTest: XCTestCase {
|
|||
XCTAssertEqual(account.name, "almost-digital")
|
||||
XCTAssertEqual(account.created, Date(timeIntervalSince1970: 1_496_691_060))
|
||||
}
|
||||
|
||||
func testTestnetGetAccount() throws {
|
||||
let result = try testnetClient.sendSynchronous(API.GetAccounts(names: ["almost-digital"]))
|
||||
guard let account = result?.first else {
|
||||
XCTFail("No account returned")
|
||||
return
|
||||
}
|
||||
XCTAssertEqual(account.id, 40413)
|
||||
XCTAssertEqual(account.name, "almost-digital")
|
||||
}
|
||||
|
||||
func testGetAccountHistory() throws {
|
||||
let req = API.GetAccountHistory(account: "almost-digital", from: 0, limit: 0)
|
||||
|
|
Loading…
Reference in New Issue