nim-status-go/status_go.nim

307 lines
11 KiB
Nim
Raw Normal View History

2021-08-31 14:05:59 +00:00
2021-03-15 15:16:34 +00:00
# This module (see also `./status_go/impl.nim`) wraps the API supplied by
# status-go when it is compiled into `libstatus.a|dll|dylib|so`.
# It is expected that this module will be consumed as an import in another Nim
# module; when doing so, it is not necessary to separately compile
# `./status_go/impl.nim` but it is the responsibility of the user to link
# status-go compiled to `libstatus` into the final executable.
import ./status_go/impl as go_shim
export SignalCallback
proc hashMessage*(message: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.hashMessage(message.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc initKeystore*(keydir: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.initKeystore(keydir.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc openAccounts*(datadir: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.openAccounts(datadir.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountGenerateAndDeriveAddresses*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountGenerateAndDeriveAddresses(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountStoreDerivedAccounts*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountStoreDerivedAccounts(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountImportMnemonic*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountImportMnemonic(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountImportPrivateKey*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountImportPrivateKey(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountDeriveAddresses*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountDeriveAddresses(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc saveAccountAndLogin*(accountData: string, password: string, settingsJSON: string, configJSON: string, subaccountData: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.saveAccountAndLogin(accountData.cstring, password.cstring, settingsJSON.cstring, configJSON.cstring, subaccountData.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc deleteMultiAccount*(keyUID: string, keyStoreDir: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.deleteMultiAccount(keyUID.cstring, keyStoreDir.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc callRPC*(inputJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.callRPC(inputJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc callPrivateRPC*(inputJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.callPrivateRPC(inputJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc addPeer*(peer: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.addPeer(peer.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc setSignalEventCallback*(callback: SignalCallback) =
go_shim.setSignalEventCallback(callback)
proc sendTransaction*(jsonArgs: string, password: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.sendTransaction(jsonArgs.cstring, password.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc generateAlias*(pk: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.generateAlias(pk)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
2022-03-14 18:35:23 +00:00
return $funcOut
proc isAlias*(value: string): string =
var funcOut = go_shim.isAlias(value)
defer: go_shim.free(funcOut)
2021-08-31 14:05:59 +00:00
return $funcOut
2021-03-15 15:16:34 +00:00
proc identicon*(pk: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.identicon(pk)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
2022-03-17 19:52:43 +00:00
proc emojiHash*(pk: string): string =
var funcOut = go_shim.emojiHash(pk)
defer: go_shim.free(funcOut)
return $funcOut
proc colorHash*(pk: string): string =
var funcOut = go_shim.colorHash(pk)
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc login*(accountData: string, password: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.login(accountData.cstring, password.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
2021-12-21 14:28:08 +00:00
proc loginWithConfig*(accountData: string, password: string, nodeCfg: string): string =
var funcOut = go_shim.loginWithConfig(accountData.cstring, password.cstring, nodeCfg.cstring)
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc logout*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.logout()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc verifyAccountPassword*(keyStoreDir: string, address: string, password: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.verifyAccountPassword(keyStoreDir.cstring, address.cstring, password.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc changeDatabasePassword*(keyUID: string, password: string, newPassword: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.changeDatabasePassword(keyUID.cstring, password.cstring, newPassword.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc validateMnemonic*(mnemonic: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.validateMnemonic(mnemonic.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc saveAccountAndLoginWithKeycard*(accountData: string, password: string, settingsJSON: string, configJSON: string, subaccountData: string, keyHex: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.saveAccountAndLoginWithKeycard(accountData.cstring, password.cstring, settingsJSON.cstring, configJSON.cstring, subaccountData.cstring, keyHex.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc hashTransaction*(txArgsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.hashTransaction(txArgsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc extractGroupMembershipSignatures*(signaturePairsStr: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.extractGroupMembershipSignatures(signaturePairsStr.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc connectionChange*(typ: string, expensive: string) =
go_shim.connectionChange(typ.cstring, expensive.cstring)
proc multiformatSerializePublicKey*(key: string, outBase: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiformatSerializePublicKey(key.cstring, outBase.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiformatDeserializePublicKey*(key: string, outBase: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiformatDeserializePublicKey(key.cstring, outBase.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc validateNodeConfig*(configJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.validateNodeConfig(configJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc loginWithKeycard*(accountData: string, password: string, keyHex: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.loginWithKeycard(accountData.cstring, password.cstring, keyHex.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc recover*(rpcParams: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.recover(rpcParams.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc writeHeapProfile*(dataDir: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.writeHeapProfile(dataDir.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc hashTypedData*(data: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.hashTypedData(data.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc resetChainData*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.resetChainData()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc signMessage*(rpcParams: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.signMessage(rpcParams.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc signTypedData*(data: string, address: string, password: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.signTypedData(data.cstring, address.cstring, password.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc stopCPUProfiling*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.stopCPUProfiling()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc getNodesFromContract*(rpcEndpoint: string, contractAddress: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.getNodesFromContract(rpcEndpoint.cstring, contractAddress.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc exportNodeLogs*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.exportNodeLogs()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc chaosModeUpdate*(on: int): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.chaosModeUpdate(on.cint)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc signHash*(hexEncodedHash: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.signHash(hexEncodedHash.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc sendTransactionWithSignature*(txtArgsJSON: string, sigString: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.sendTransactionWithSignature(txtArgsJSON.cstring, sigString.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc startCPUProfile*(dataDir: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.startCPUProfile(dataDir.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc appStateChange*(state: string) =
go_shim.appStateChange(state.cstring)
proc signGroupMembership*(content: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.signGroupMembership(content.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountStoreAccount*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountStoreAccount(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountLoadAccount*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountLoadAccount(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountGenerate*(paramsJSON: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountGenerate(paramsJSON.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc multiAccountReset*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.multiAccountReset()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc migrateKeyStoreDir*(accountData: string, password: string, oldKeystoreDir: string, multiaccountKeystoreDir: string): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.migrateKeyStoreDir(accountData.cstring, password.cstring, oldKeystoreDir.cstring, multiaccountKeystoreDir.cstring)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc startWallet*(watchNewBlocks: bool): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.startWallet(watchNewBlocks)
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc stopWallet*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.stopWallet()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc startLocalNotifications*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.startLocalNotifications()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-03-15 15:16:34 +00:00
proc stopLocalNotifications*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.stopLocalNotifications()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2021-06-04 17:36:05 +00:00
proc getNodeConfig*(): string =
2021-08-31 15:07:28 +00:00
var funcOut = go_shim.getNodeConfig()
2021-08-31 14:05:59 +00:00
defer: go_shim.free(funcOut)
return $funcOut
2022-02-21 20:58:28 +00:00
proc imageServerTLSCert*(): string =
var funcOut = go_shim.imageServerTLSCert()
defer: go_shim.free(funcOut)
return $funcOut