From 82a167161280b04ec7fdaea435389fe83ddebb66 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Sun, 10 Jan 2021 17:42:37 -0500 Subject: [PATCH] Add getAtomicUTXOs to avm and platformvm clients --- vms/avm/client.go | 11 +++++++++-- vms/platformvm/client.go | 20 ++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/vms/avm/client.go b/vms/avm/client.go index 44469fa6b730..2c02a51aa2d8 100644 --- a/vms/avm/client.go +++ b/vms/avm/client.go @@ -92,10 +92,17 @@ func (c *Client) GetTx(txID ids.ID) ([]byte, error) { // GetUTXOs returns the byte representation of the UTXOs controlled by [addrs] func (c *Client) GetUTXOs(addrs []string, limit uint32, startAddress, startUTXOID string) ([][]byte, api.Index, error) { + return c.GetAtomicUTXOs(addrs, "", limit, startAddress, startUTXOID) +} + +// GetAtomicUTXOs returns the byte representation of the atomic UTXOs controlled by [addresses] +// from [sourceChain] +func (c *Client) GetAtomicUTXOs(addrs []string, sourceChain string, limit uint32, startAddress, startUTXOID string) ([][]byte, api.Index, error) { res := &api.GetUTXOsReply{} err := c.requester.SendRequest("getUTXOs", &api.GetUTXOsArgs{ - Addresses: addrs, - Limit: cjson.Uint32(limit), + Addresses: addrs, + SourceChain: sourceChain, + Limit: cjson.Uint32(limit), StartIndex: api.Index{ Address: startAddress, UTXO: startUTXOID, diff --git a/vms/platformvm/client.go b/vms/platformvm/client.go index cf271e331ccc..39db7c5ab643 100644 --- a/vms/platformvm/client.go +++ b/vms/platformvm/client.go @@ -75,12 +75,24 @@ func (c *Client) ListAddresses(user api.UserPass) ([]string, error) { return res.Addresses, err } -// GetUTXOs returns the byte representation of the UTXOs controlled by [addresses] -func (c *Client) GetUTXOs(addresses []string) ([][]byte, api.Index, error) { +// GetUTXOs returns the byte representation of the UTXOs controlled by [addrs] +func (c *Client) GetUTXOs(addrs []string, limit uint32, startAddress, startUTXOID string) ([][]byte, api.Index, error) { + return c.GetAtomicUTXOs(addrs, "", limit, startAddress, startUTXOID) +} + +// GetAtomicUTXOs returns the byte representation of the atomic UTXOs controlled by [addresses] +// from [sourceChain] +func (c *Client) GetAtomicUTXOs(addrs []string, sourceChain string, limit uint32, startAddress, startUTXOID string) ([][]byte, api.Index, error) { res := &api.GetUTXOsReply{} err := c.requester.SendRequest("getUTXOs", &api.GetUTXOsArgs{ - Addresses: addresses, - Encoding: formatting.Hex, + Addresses: addrs, + SourceChain: sourceChain, + Limit: cjson.Uint32(limit), + StartIndex: api.Index{ + Address: startAddress, + UTXO: startUTXOID, + }, + Encoding: formatting.Hex, }, res) if err != nil { return nil, api.Index{}, err