From 0865549639f0a359e2f79761203c58952d3b9532 Mon Sep 17 00:00:00 2001 From: shiqizng <80276844+shiqizng@users.noreply.github.com> Date: Thu, 10 Aug 2023 17:07:14 -0400 Subject: [PATCH] bug-fix: include currency-greater-than param for 0 value (#584) * include currency-greater-than param for 0 value --- .test-env | 2 +- client/v2/algod/algod.go | 4 ++++ client/v2/algod/getBlockTxids.go | 23 +++++++++++++++++++ .../v2/common/models/block_txids_response.go | 7 ++++++ .../v2/indexer/lookupAccountTransactions.go | 4 ++-- client/v2/indexer/lookupAssetBalances.go | 4 ++-- client/v2/indexer/lookupAssetTransactions.go | 4 ++-- client/v2/indexer/searchForAccounts.go | 4 ++-- client/v2/indexer/searchForTransactions.go | 4 ++-- 9 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 client/v2/algod/getBlockTxids.go create mode 100644 client/v2/common/models/block_txids_response.go diff --git a/.test-env b/.test-env index 049289d7..a321a7f1 100644 --- a/.test-env +++ b/.test-env @@ -1,6 +1,6 @@ # Configs for testing repo download: SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing" -SDK_TESTING_BRANCH="master" +SDK_TESTING_BRANCH="V2" SDK_TESTING_HARNESS="test-harness" INSTALL_ONLY=0 diff --git a/client/v2/algod/algod.go b/client/v2/algod/algod.go index 2914f2f9..48deecf4 100644 --- a/client/v2/algod/algod.go +++ b/client/v2/algod/algod.go @@ -98,6 +98,10 @@ func (c *Client) Block(round uint64) *Block { return &Block{c: c, round: round} } +func (c *Client) GetBlockTxids(round uint64) *GetBlockTxids { + return &GetBlockTxids{c: c, round: round} +} + func (c *Client) GetBlockHash(round uint64) *GetBlockHash { return &GetBlockHash{c: c, round: round} } diff --git a/client/v2/algod/getBlockTxids.go b/client/v2/algod/getBlockTxids.go new file mode 100644 index 00000000..1297d741 --- /dev/null +++ b/client/v2/algod/getBlockTxids.go @@ -0,0 +1,23 @@ +package algod + +import ( + "context" + "fmt" + + "github.com/algorand/go-algorand-sdk/v2/client/v2/common" + "github.com/algorand/go-algorand-sdk/v2/client/v2/common/models" +) + +// GetBlockTxids get the top level transaction IDs for the block on the given +// round. +type GetBlockTxids struct { + c *Client + + round uint64 +} + +// Do performs the HTTP request +func (s *GetBlockTxids) Do(ctx context.Context, headers ...*common.Header) (response models.BlockTxidsResponse, err error) { + err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s/txids", common.EscapeParams(s.round)...), nil, headers) + return +} diff --git a/client/v2/common/models/block_txids_response.go b/client/v2/common/models/block_txids_response.go new file mode 100644 index 00000000..8830b265 --- /dev/null +++ b/client/v2/common/models/block_txids_response.go @@ -0,0 +1,7 @@ +package models + +// BlockTxidsResponse top level transaction IDs in a block. +type BlockTxidsResponse struct { + // Blocktxids block transaction IDs. + Blocktxids []string `json:"blockTxids"` +} diff --git a/client/v2/indexer/lookupAccountTransactions.go b/client/v2/indexer/lookupAccountTransactions.go index e1bb6fbf..c8200aed 100644 --- a/client/v2/indexer/lookupAccountTransactions.go +++ b/client/v2/indexer/lookupAccountTransactions.go @@ -27,7 +27,7 @@ type LookupAccountTransactionsParams struct { // CurrencyGreaterThan results should have an amount greater than this value. // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. - CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"` + CurrencyGreaterThan *uint64 `url:"currency-greater-than,omitempty"` // CurrencyLessThan results should have an amount less than this value. MicroAlgos // are the default currency unless an asset-id is provided, in which case the asset @@ -123,7 +123,7 @@ func (s *LookupAccountTransactions) BeforeTime(BeforeTime time.Time) *LookupAcco // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. func (s *LookupAccountTransactions) CurrencyGreaterThan(CurrencyGreaterThan uint64) *LookupAccountTransactions { - s.p.CurrencyGreaterThan = CurrencyGreaterThan + s.p.CurrencyGreaterThan = &CurrencyGreaterThan return s } diff --git a/client/v2/indexer/lookupAssetBalances.go b/client/v2/indexer/lookupAssetBalances.go index 33595ec3..edd55e63 100644 --- a/client/v2/indexer/lookupAssetBalances.go +++ b/client/v2/indexer/lookupAssetBalances.go @@ -14,7 +14,7 @@ type LookupAssetBalancesParams struct { // CurrencyGreaterThan results should have an amount greater than this value. // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. - CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"` + CurrencyGreaterThan *uint64 `url:"currency-greater-than,omitempty"` // CurrencyLessThan results should have an amount less than this value. MicroAlgos // are the default currency unless an asset-id is provided, in which case the asset @@ -48,7 +48,7 @@ type LookupAssetBalances struct { // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. func (s *LookupAssetBalances) CurrencyGreaterThan(CurrencyGreaterThan uint64) *LookupAssetBalances { - s.p.CurrencyGreaterThan = CurrencyGreaterThan + s.p.CurrencyGreaterThan = &CurrencyGreaterThan return s } diff --git a/client/v2/indexer/lookupAssetTransactions.go b/client/v2/indexer/lookupAssetTransactions.go index 5890dd49..071addc2 100644 --- a/client/v2/indexer/lookupAssetTransactions.go +++ b/client/v2/indexer/lookupAssetTransactions.go @@ -32,7 +32,7 @@ type LookupAssetTransactionsParams struct { // CurrencyGreaterThan results should have an amount greater than this value. // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. - CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"` + CurrencyGreaterThan *uint64 `url:"currency-greater-than,omitempty"` // CurrencyLessThan results should have an amount less than this value. MicroAlgos // are the default currency unless an asset-id is provided, in which case the asset @@ -142,7 +142,7 @@ func (s *LookupAssetTransactions) BeforeTime(BeforeTime time.Time) *LookupAssetT // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. func (s *LookupAssetTransactions) CurrencyGreaterThan(CurrencyGreaterThan uint64) *LookupAssetTransactions { - s.p.CurrencyGreaterThan = CurrencyGreaterThan + s.p.CurrencyGreaterThan = &CurrencyGreaterThan return s } diff --git a/client/v2/indexer/searchForAccounts.go b/client/v2/indexer/searchForAccounts.go index 175600e4..5d1edf5b 100644 --- a/client/v2/indexer/searchForAccounts.go +++ b/client/v2/indexer/searchForAccounts.go @@ -22,7 +22,7 @@ type SearchAccountsParams struct { // CurrencyGreaterThan results should have an amount greater than this value. // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. - CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"` + CurrencyGreaterThan *uint64 `url:"currency-greater-than,omitempty"` // CurrencyLessThan results should have an amount less than this value. MicroAlgos // are the default currency unless an asset-id is provided, in which case the asset @@ -88,7 +88,7 @@ func (s *SearchAccounts) AuthAddress(AuthAddress string) *SearchAccounts { // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. func (s *SearchAccounts) CurrencyGreaterThan(CurrencyGreaterThan uint64) *SearchAccounts { - s.p.CurrencyGreaterThan = CurrencyGreaterThan + s.p.CurrencyGreaterThan = &CurrencyGreaterThan return s } diff --git a/client/v2/indexer/searchForTransactions.go b/client/v2/indexer/searchForTransactions.go index 04a18556..fa3b6bd0 100644 --- a/client/v2/indexer/searchForTransactions.go +++ b/client/v2/indexer/searchForTransactions.go @@ -37,7 +37,7 @@ type SearchForTransactionsParams struct { // CurrencyGreaterThan results should have an amount greater than this value. // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. - CurrencyGreaterThan uint64 `url:"currency-greater-than,omitempty"` + CurrencyGreaterThan *uint64 `url:"currency-greater-than,omitempty"` // CurrencyLessThan results should have an amount less than this value. MicroAlgos // are the default currency unless an asset-id is provided, in which case the asset @@ -160,7 +160,7 @@ func (s *SearchForTransactions) BeforeTime(BeforeTime time.Time) *SearchForTrans // MicroAlgos are the default currency unless an asset-id is provided, in which // case the asset will be used. func (s *SearchForTransactions) CurrencyGreaterThan(CurrencyGreaterThan uint64) *SearchForTransactions { - s.p.CurrencyGreaterThan = CurrencyGreaterThan + s.p.CurrencyGreaterThan = &CurrencyGreaterThan return s }