You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
Endpoint: for testing: https://dex-asiapacific.binance.org/api
Replicate Swift implementation in TypeScript, as implemented in Cosmos RPC
Swift implementation:
var path: String {
switch self {
case .getAccount(let address):
return "/v1/account/\(address)"
case .getTransaction(let hash):
return "/v1/tx/\(hash)?format=json"
case .order(let order):
return "/v1/orders/\(order)"
case .broadcast(_, let sync):
return "/v1/broadcast?sync=\(sync)"
case .markets:
return "/v1/markets"
case .nodeInfo:
return "/v1/node-info"
}
}
var method: Moya.Method {
switch self {
case .getAccount,
.getTransaction,
.order,
.markets,
.nodeInfo:
return .get
case .broadcast:
return .post
}
}
var task: Task {
switch self {
case .getAccount, .getTransaction, .order, .markets, .nodeInfo:
return .requestPlain
case .broadcast(let body, _):
return Task.requestData(body.hexString.data(using: .utf8) ?? Data())
}
}
var sampleData: Data {
return Data()
}
var headers: [String: String]? {
switch self {
case .broadcast:
return [
"Content-type": "text/plain",
]
case .getAccount, .getTransaction, .order, .markets, .nodeInfo:
return [
"Content-type": "application/json",
]
}
}
models:
struct BinanceTokenBalance: Codable {
let symbol: String
let free: String
let locked: String
let frozen: String
}
struct BinanceAccount: Codable {
let address: String
let account_number: Int64
let sequence: Int64
let balances: [BinanceTokenBalance]
}
struct BinanceNodeInfo: Codable {
struct NodeInfo: Codable {
let network: String
}
let node_info: NodeInfo
var chainID: String {
return node_info.network
}
}
enum BinanceOrderType: String, Codable {
case FullyFill
case Ack
case PartialFill
case IocNoFill
case Canceled
case Expired
case FailedBlocking
case FailedMatching
}
struct BinanceOrder: Codable {
let symbol: String
let price: String
let quantity: String
let cumulateQuantity: String
let lastExecutedPrice: String
let lastExecutedQuantity: String
let transactionHash: String
let status: BinanceOrderType
}
struct BinanceRPCTransaction: Codable {
let hash: String
}
public struct BinanceTraderOrder: Codable {
public struct Tx: Codable {
public struct Value: Codable {
public struct Msg: Codable {
public struct Value: Codable {
public let id: String // order ID
}
let value: Value
}
let msg: [Msg]
}
let value: Value
}
let tx: Tx
}
The text was updated successfully, but these errors were encountered:
Example Cosmos RPC: https://github.com/trustwallet/web-core/tree/master/packages/rpc/src/cosmos
Endpoint: for testing:
https://dex-asiapacific.binance.org/api
Replicate Swift implementation in TypeScript, as implemented in Cosmos RPC
Swift implementation:
models:
The text was updated successfully, but these errors were encountered: