A Swift Implementation of the RaiBlocks JSON RPC Spec
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
SwiftyRai.xcodeproj
SwiftyRai
SwiftyRaiTests
.gitignore
.swift-version
LICENSE
README.md
SwiftyRai.podspec

README.md

SwiftyRai

A Swift Implementation of the RaiBlocks JSON RPC Spec (https://github.com/clemahieu/raiblocks/wiki/RPC-protocol)

Installation

Cocoapods

pod 'SwiftyRai'

Example

// Initialize a client with a host, and optionally a URLSession
let client = SRClient(host: "http://[::1]:7076")

// Initialize a Request
let accountBalanceRequest = SRAccountRequest.AccountBalance(account: "xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3")

// Send the request through the client
client.send(request: accountBalanceRequest) { result in
    switch result {
    case .success(let accountBalance):
        print(accountBalance.balance)
        print(accountBalance.pending)
    case .error(let error):
        print(error)
    }
}

SRRequest's

There is a SRRequest type for each of the RPC methods

SRAccountRequest

AccountBalance(account: String)
AccountBlockCount(account: String)
AccountInfo(account: String, representative: Bool, weight: Bool, pending: Bool)
AccountCreate((wallet: String, work: Bool)
AccountGet(key: String)
AccountHistory(account: String, count: Int)
AccountList(wallet: String)
AccountMove(wallet: String, source: String, accounts: [String])
AccountKey(account: String)
AccountRemove(wallet: String, account: String)
AccountRepresentative(account: String)
AccountRepresentativeSet(wallet: String, account: String, representative: String)
AccountWeight(account: String)
AccountsBalances(accounts: [String])
AccountsCreate(wallet: String, count: Int, work: Bool)
AccountsFrontiers(accounts: [String])
AccountsPending(accounts: [String], count: Int, threshold: Int, source: Bool)
ValidateAccountNumber(account: String)

SRBlockRequest

BlockAccount(hash: String)
BlockCountType()
BlockCount()
Chain(block: String, count: Int)
BlockCreate(blockType: BlockType)
Process(block: String)
Block(hash: String)
BlocksInfo(hashes: [String], pending: Bool, source: Bool)
RetrieveBlocks(hashes: [String])

SRBootstrapRequest

Bootstrap(address: String, port: Int)
BootstrapAny()

SRConversionRequest

KraiFromRaw(amount: Int)
KraiToRaw(amount: Int)
MraiFromRaw(amount: Int)
MraiToRaw(amount: Int)
RaiFromRaw(amount: Int)
RaiToRaw(amount: Int)

SRDelegatorsRequest

Delegators(account: String)
DelegatorsCount(account: String)

SRFrontiersRequest

Frontiers(account: String, count: Int)
FrontiersCount()

SRKeysRequest

DeterministicKey(seed: String, index: Int)
KeyCreate()
KeyExpand(key: String)

SRLedgerRequest

History(hash: String, count: Int)
Ledger(account: String, count: Int, representative: Bool, weight: Bool, pending: Bool, sorting: Bool)
Successors(block: String, count: Int)

SRNetworkRequest

AvailableSupply()
Keepalive(address: String, port: Int)
Republish(hash: String, sources: Int, destinations: Int)

SRNodeRequest

Version()
Stop()

SRPaymentsRequest

PaymentBegin(wallet: String)
PaymentEnd(account: String, wallet: String)
PaymentInit(wallet: String)
PaymentWait(account: String, count: Int, timeout: Int)

SRPeersRequest

Pending(account: String, count: Int)
PendingExists(hash: String)
SearchPending(wallet: String)
SearchPendingAll()

SRProofOfWorkRequest

WorkCancel(hash: String)
WorkGenerate(hash: String)
WorkGet(wallet: String, account: String)
WorkSet(wallet: String, account: String, work: String)
WorkValidate(work: String, hash: String)

SRReceivingRequest

Receive(wallet: String, account: String, block: String)
ReceiveMinimum()
ReceiveMinimumSet(amount: Int)

SRRepresentativesRequest

Representatives(count: Int, sorting: Bool)

SRSendingRequest

Send(wallet: String, source: String, destination: String, amount: String, work: String)

SRUncheckedBlocksRequest

UncheckedClear()
UncheckedGet(hash: String)
UncheckedKeys(key: String, count: Int)
Unchecked(count: Int)

SRWalletRequest

WalletBalances(wallet: String, threshold: Int)
WalletAdd(wallet: String, key: String, work: Bool)
WalletChangeSeed(wallet: String, seed: String)
WalletContains(wallet: String, account: String)
WalletCreate()
WalletDestroy()
WalletExport(wallet: String)
WalletFrontiers(wallet: String)
WalletLocked(wallet: String)
WalletPending(wallet: String, count: Int)
WalletRepresentativeSet(wallet: String, representative: String)
WalletRepresentative(wallet: String)
WalletRepublish(wallet: String, count: Int)
WalletBalanceTotal(wallet: String)
WalletWorkGet(wallet: String)

PasswordEnter(wallet: String, password: String)
PasswordChange(wallet: String, password: String)
PasswordValid(wallet: String)

To-do:

  • Convert stringly typed responses into typed responses

Donate

If you'd like to get me a coffee to keep working on this (ie, the todo list), donate here:

xrb_3robyzuc8jn1brkzkdadiphy6gmc15mqq3dro3tyiyn7r8sru1wcagykezab