status-lib/status/stickers.nim
Sale Djenic 4eab2fa86b refactor: repo cleaning
- all unused/unnecessary files remove
- `statusgo_backend_new` content promoted to main content
- only necessary submodules for `status-lib` are kept
2022-02-01 11:16:20 +01:00

55 lines
1.6 KiB
Nim

import json
import ./eth
# Retrieves number of sticker packs owned by user
# See https://notes.status.im/Q-sQmQbpTOOWCQcYiXtf5g#Read-Sticker-Packs-owned-by-a-user
# for more details
proc getBalance*(address: string, data: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [{
"to": address,
"data": data
}, "latest"]
let response = eth.doEthCall(payload)
if not response.error.isNil:
raise newException(RpcException, "Error getting stickers balance: " & response.error.message)
return response
proc tokenOfOwnerByIndex*(address: string, data: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [{
"to": address,
"data": data
}, "latest"]
let response = eth.doEthCall(payload)
if not response.error.isNil:
raise newException(RpcException, "Error getting owned tokens: " & response.error.message)
return response
proc getPackIdFromTokenId*(address: string, data: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [{
"to": address,
"data": data
}, "latest"]
let response = eth.doEthCall(payload)
if not response.error.isNil:
raise newException(RpcException, "Error getting pack id from token id: " & response.error.message)
return response
proc getPackCount*(address: string, data: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [{
"to": address,
"data": data
}, "latest"]
let response = eth.doEthCall(payload)
if not response.error.isNil:
raise newException(RpcException, "Error getting stickers balance: " & response.error.message)
return response