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/algod/waitForBlock.go b/client/v2/algod/waitForBlock.go index 70435f39..0c26ec97 100644 --- a/client/v2/algod/waitForBlock.go +++ b/client/v2/algod/waitForBlock.go @@ -9,7 +9,9 @@ import ( ) // StatusAfterBlock waits for a block to appear after round {round} and returns the -// node's status at the time. +// node's status at the time. There is a 1 minute timeout, when reached the current +// status is returned regardless of whether or not it is the round after the given +// round. type StatusAfterBlock struct { c *Client diff --git a/client/v2/common/models/avm_value.go b/client/v2/common/models/avm_value.go new file mode 100644 index 00000000..28e5a47c --- /dev/null +++ b/client/v2/common/models/avm_value.go @@ -0,0 +1,13 @@ +package models + +// AvmValue represents an AVM value. +type AvmValue struct { + // Bytes bytes value. + Bytes []byte `json:"bytes,omitempty"` + + // Type value type. Value `1` refers to **bytes**, value `2` refers to **uint64** + Type uint64 `json:"type"` + + // Uint uint value. + Uint uint64 `json:"uint,omitempty"` +} 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/common/models/scratch_change.go b/client/v2/common/models/scratch_change.go new file mode 100644 index 00000000..851f69ee --- /dev/null +++ b/client/v2/common/models/scratch_change.go @@ -0,0 +1,10 @@ +package models + +// ScratchChange a write operation into a scratch slot. +type ScratchChange struct { + // NewValue represents an AVM value. + NewValue AvmValue `json:"new-value"` + + // Slot the scratch slot written. + Slot uint64 `json:"slot"` +} diff --git a/client/v2/common/models/simulate_trace_config.go b/client/v2/common/models/simulate_trace_config.go index 27e4166b..c7552d6d 100644 --- a/client/v2/common/models/simulate_trace_config.go +++ b/client/v2/common/models/simulate_trace_config.go @@ -5,4 +5,12 @@ type SimulateTraceConfig struct { // Enable a boolean option for opting in execution trace features simulation // endpoint. Enable bool `json:"enable,omitempty"` + + // ScratchChange a boolean option enabling returning scratch slot changes together + // with execution trace during simulation. + ScratchChange bool `json:"scratch-change,omitempty"` + + // StackChange a boolean option enabling returning stack changes together with + // execution trace during simulation. + StackChange bool `json:"stack-change,omitempty"` } diff --git a/client/v2/common/models/simulation_opcode_trace_unit.go b/client/v2/common/models/simulation_opcode_trace_unit.go index 1b256458..c6b72144 100644 --- a/client/v2/common/models/simulation_opcode_trace_unit.go +++ b/client/v2/common/models/simulation_opcode_trace_unit.go @@ -6,7 +6,16 @@ type SimulationOpcodeTraceUnit struct { // Pc the program counter of the current opcode being evaluated. Pc uint64 `json:"pc"` + // ScratchChanges the writes into scratch slots. + ScratchChanges []ScratchChange `json:"scratch-changes,omitempty"` + // SpawnedInners the indexes of the traces for inner transactions spawned by this // opcode, if any. SpawnedInners []uint64 `json:"spawned-inners,omitempty"` + + // StackAdditions the values added by this opcode to the stack. + StackAdditions []AvmValue `json:"stack-additions,omitempty"` + + // StackPopCount the number of deleted stack values by this opcode. + StackPopCount uint64 `json:"stack-pop-count,omitempty"` } 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 }