Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract more information from tx and msgs #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 115 additions & 2 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1006,11 +1006,38 @@
"format": "int64",
"type": "integer"
},
"msgs_created": {
"example": 1000,
"format": "int16",
"type": "integer"
},
"no_funds": {
"example": true,
"type": "boolean"
},
"result_arg": {
"example": 5,
"format": "int32",
"type": "integer"
},
"result_code": {
"example": 5,
"format": "int32",
"type": "integer"
},
"skipped_actions": {
"example": 5,
"format": "int32",
"type": "integer"
},
"spec_actions": {
"example": 5,
"format": "int32",
"type": "integer"
},
"status_change": {
"$ref": "#/components/schemas/AccStatusChange"
},
"success": {
"example": true,
"type": "boolean"
Expand All @@ -1024,14 +1051,37 @@
"example": 1000,
"format": "int64",
"type": "integer"
},
"total_msg_size_bits": {
"example": 1000,
"format": "int64",
"type": "integer"
},
"total_msg_size_cells": {
"example": 3,
"format": "int64",
"type": "integer"
},
"valid": {
"example": true,
"type": "boolean"
}
},
"required": [
"success",
"valid",
"no_funds",
"status_change",
"result_code",
"result_arg",
"total_actions",
"spec_actions",
"skipped_actions",
"fwd_fees",
"total_fees"
"total_fees",
"msgs_created",
"total_msg_size_cells",
"total_msg_size_bits"
],
"type": "object"
},
Expand Down Expand Up @@ -2326,6 +2376,37 @@
],
"type": "object"
},
"BouncePhase": {
"properties": {
"bounce_type": {
"$ref": "#/components/schemas/BouncePhaseType"
},
"fwd_fees": {
"format": "int64",
"type": "integer"
},
"msg_fees": {
"format": "int64",
"type": "integer"
},
"msg_size_bits": {
"format": "int64",
"type": "integer"
},
"msg_size_cells": {
"format": "int64",
"type": "integer"
},
"req_fwd_fees": {
"format": "int64",
"type": "integer"
}
},
"required": [
"bounce_type"
],
"type": "object"
},
"BouncePhaseType": {
"enum": [
"TrPhaseBounceNegfunds",
Expand All @@ -2337,21 +2418,49 @@
},
"ComputePhase": {
"properties": {
"account_activated": {
"example": true,
"type": "boolean"
},
"exit_arg": {
"example": 0,
"format": "int32",
"type": "integer"
},
"exit_code": {
"example": 0,
"format": "int32",
"type": "integer"
},
"gas_credit": {
"example": 10000,
"format": "int64",
"type": "integer"
},
"gas_fees": {
"example": 1000,
"format": "int64",
"type": "integer"
},
"gas_limit": {
"example": 10000,
"format": "int64",
"type": "integer"
},
"gas_used": {
"example": 10000,
"format": "int64",
"type": "integer"
},
"mode": {
"example": 0,
"format": "int8",
"type": "integer"
},
"msg_state_used": {
"example": true,
"type": "boolean"
},
"skip_reason": {
"$ref": "#/components/schemas/ComputeSkipReason"
},
Expand Down Expand Up @@ -4747,8 +4856,12 @@
"example": "(-1,4234234,8000000000000000)",
"type": "string"
},
"bounce": {
"$ref": "#/components/schemas/BouncePhase"
},
"bounce_phase": {
"$ref": "#/components/schemas/BouncePhaseType"
"$ref": "#/components/schemas/BouncePhaseType",
"deprecated": true
},
"compute_phase": {
"$ref": "#/components/schemas/ComputePhase"
Expand Down
89 changes: 89 additions & 0 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,29 @@ components:
- TrPhaseBounceNegfunds
- TrPhaseBounceNofunds
- TrPhaseBounceOk
BouncePhase:
type: object
required:
- bounce_type
properties:
bounce_type:
$ref: '#/components/schemas/BouncePhaseType'
msg_size_cells:
type: integer
format: int64
msg_size_bits:
type: integer
format: int64
req_fwd_fees:
type: integer
format: int64
msg_fees:
type: integer
format: int64
fwd_fees:
type: integer
format: int64

ComputePhase:
type: object
required:
Expand All @@ -3170,6 +3193,12 @@ components:
success:
type: boolean
example: true
msg_state_used:
type: boolean
example: true
account_activated:
type: boolean
example: true
gas_fees:
type: integer
format: int64
Expand All @@ -3178,6 +3207,14 @@ components:
type: integer
format: int64
example: 10000
gas_credit:
type: integer
format: int64
example: 10000
gas_limit:
type: integer
format: int64
example: 10000
vm_steps:
type: integer
format: uint32
Expand All @@ -3186,6 +3223,14 @@ components:
type: integer
format: int32
example: 0
exit_arg:
type: integer
format: int32
example: 0
mode:
type: integer
format: int8
example: 0
StoragePhase:
type: object
required:
Expand Down Expand Up @@ -3220,18 +3265,47 @@ components:
type: object
required:
- success
- valid
- no_funds
- status_change
- result_code
- result_arg
- total_actions
- spec_actions
- skipped_actions
- fwd_fees
- total_fees
- msgs_created
- total_msg_size_cells
- total_msg_size_bits
properties:
success:
type: boolean
example: true
valid:
type: boolean
example: true
no_funds:
type: boolean
example: true
status_change:
$ref: '#/components/schemas/AccStatusChange'
result_code:
type: integer
format: int32
example: 5
result_arg:
type: integer
format: int32
example: 5
total_actions:
type: integer
format: int32
example: 5
spec_actions:
type: integer
format: int32
example: 5
skipped_actions:
type: integer
format: int32
Expand All @@ -3244,6 +3318,18 @@ components:
type: integer
format: int64
example: 1000
msgs_created:
type: integer
format: int16
example: 1000
total_msg_size_cells:
type: integer
format: int64
example: 3
total_msg_size_bits:
type: integer
format: int64
example: 1000
Transaction:
type: object
required:
Expand Down Expand Up @@ -3320,7 +3406,10 @@ components:
action_phase:
$ref: '#/components/schemas/ActionPhase'
bounce_phase:
deprecated: true
$ref: '#/components/schemas/BouncePhaseType'
bounce:
$ref: '#/components/schemas/BouncePhase'
aborted:
type: boolean
example: true
Expand Down
34 changes: 14 additions & 20 deletions pkg/api/account_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/tonkeeper/opentonapi/pkg/chainstate"
pkgTesting "github.com/tonkeeper/opentonapi/pkg/testing"
"github.com/tonkeeper/tongo/liteapi"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -162,21 +163,20 @@ func TestHandler_GetAccounts(t *testing.T) {
}

func TestHandler_GetTransactions(t *testing.T) {
t.Skip()
tests := []struct {
name string
params oas.GetBlockchainBlockTransactionsParams
wantTxCount int
wantTxHashes map[string]struct{}
name string
params oas.GetBlockchainBlockTransactionsParams
filenamePrefix string
}{
{
params: oas.GetBlockchainBlockTransactionsParams{BlockID: "(-1,8000000000000000,28741341)"},
wantTxCount: 3,
wantTxHashes: map[string]struct{}{
"fec4f77e8b72eec62d14944d9cf99171a32c03783c8e6e30590aabbe35236f9b": {},
"ed07582702c23aeaa6f1b7ce28def3a810399467a8e062ed1c67eed8c1abd2ad": {},
"6f268d1fcd0bd36021237bb2b1810a7a78cd1d3b5e96d826ffddbcc96b848523": {},
},
name: "masterchain block",
params: oas.GetBlockchainBlockTransactionsParams{BlockID: "(-1,8000000000000000,28741341)"},
filenamePrefix: "block-txs-1",
},
{
name: "basechain block",
params: oas.GetBlockchainBlockTransactionsParams{BlockID: "(0,8000000000000000,40834551)"},
filenamePrefix: "block-txs-2",
},
}
for _, tt := range tests {
Expand All @@ -186,18 +186,12 @@ func TestHandler_GetTransactions(t *testing.T) {
require.Nil(t, err)
liteStorage, err := litestorage.NewLiteStorage(logger, cli)
require.Nil(t, err)
h, err := NewHandler(logger, WithStorage(liteStorage), WithExecutor(liteStorage))
h, err := NewHandler(logger, WithStorage(liteStorage), WithExecutor(liteStorage), WithAddressBook(&mockAddressBook{}))
require.Nil(t, err)
res, err := h.GetBlockchainBlockTransactions(context.Background(), tt.params)
require.Nil(t, err)
fmt.Printf("%v\n", res)

require.Equal(t, tt.wantTxCount, len(res.Transactions))
txHashes := map[string]struct{}{}
for _, tx := range res.Transactions {
txHashes[tx.Hash] = struct{}{}
}
require.Equal(t, tt.wantTxHashes, txHashes)
pkgTesting.CompareResults(t, res, tt.filenamePrefix)
})
}
}
Loading