diff --git a/api/rt.yml b/api/rt.yml index 42b38157..b5fef6db 100644 --- a/api/rt.yml +++ b/api/rt.yml @@ -173,6 +173,23 @@ paths: $ref: '#/components/schemas/WebhookAccountTxSubscriptions' 'default': $ref: '#/components/responses/Error' + /webhooks/{webhook_id}/msg-opcode/subscriptions: + get: + operationId: webhookNewContractsSubscriptions + parameters: + - $ref: '#/components/parameters/tokenQuery' + - $ref: '#/components/parameters/webhookId' + - $ref: '#/components/parameters/offsetQuery' + - $ref: '#/components/parameters/limitQuery' + responses: + '200': + description: "subscriptions" + content: + application/json: + schema: + $ref: '#/components/schemas/WebhookMsgOpcodeSubscriptions' + 'default': + $ref: '#/components/responses/Error' /webhooks/{webhook_id}/subscribe-new-contracts: post: description: "receive a notification when a new contract is deployed to the blockchain" @@ -429,6 +446,8 @@ components: - status_failed_attempts - subscribed_accounts - subscribed_to_mempool + - subscribed_to_new_contracts + - subscribed_msg_opcodes properties: id: type: integer @@ -439,8 +458,12 @@ components: type: string subscribed_accounts: type: integer + subscribed_msg_opcodes: + type: integer subscribed_to_mempool: type: boolean + subscribed_to_new_contracts: + type: boolean status: type: string enum: @@ -481,7 +504,20 @@ components: failed_attempts: type: integer format: int64 - + WebhookMsgOpcodeSubscriptions: + type: object + required: + - subscriptions + properties: + subscriptions: + type: array + items: + type: object + required: + - opcode + properties: + opcode: + type: string responses: Error: diff --git a/pkg/api/event_handlers.go b/pkg/api/event_handlers.go index b936df78..6c7bb6fe 100644 --- a/pkg/api/event_handlers.go +++ b/pkg/api/event_handlers.go @@ -310,10 +310,11 @@ func (h *Handler) GetAccountEvent(ctx context.Context, params oas.GetAccountEven if err != nil { return nil, toError(http.StatusInternalServerError, err) } - result, err := bath.FindActions(ctx, trace, bath.ForAccount(account.ID), bath.WithInformationSource(h.storage)) + actions, err := bath.FindActions(ctx, trace, bath.ForAccount(account.ID), bath.WithInformationSource(h.storage)) if err != nil { return nil, toError(http.StatusInternalServerError, err) } + result := bath.EnrichWithIntentions(trace, actions) event, err := h.toAccountEvent(ctx, account.ID, trace, result, params.AcceptLanguage, params.SubjectOnly.Value) if err != nil { return nil, toError(http.StatusInternalServerError, err) @@ -374,10 +375,11 @@ func (h *Handler) EmulateMessageToAccountEvent(ctx context.Context, request *oas if err != nil { return nil, toError(http.StatusInternalServerError, err) } - result, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage)) + actions, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage)) if err != nil { return nil, toError(http.StatusInternalServerError, err) } + result := bath.EnrichWithIntentions(trace, actions) event, err := h.toAccountEvent(ctx, account.ID, trace, result, params.AcceptLanguage, false) if err != nil { return nil, toError(http.StatusInternalServerError, err) @@ -425,10 +427,11 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat return nil, toError(http.StatusInternalServerError, err) } } - result, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage)) + actions, err := bath.FindActions(ctx, trace, bath.WithInformationSource(h.storage)) if err != nil { return nil, toError(http.StatusInternalServerError, err) } + result := bath.EnrichWithIntentions(trace, actions) event, err := h.toEvent(ctx, trace, result, params.AcceptLanguage) if err != nil { return nil, toError(http.StatusInternalServerError, err) @@ -601,10 +604,11 @@ func (h *Handler) EmulateMessageToWallet(ctx context.Context, request *oas.Emula return nil, toError(http.StatusInternalServerError, err) } t := convertTrace(trace, h.addressBook) - result, err := bath.FindActions(ctx, trace, bath.ForAccount(*walletAddress), bath.WithInformationSource(h.storage)) + actions, err := bath.FindActions(ctx, trace, bath.ForAccount(*walletAddress), bath.WithInformationSource(h.storage)) if err != nil { return nil, toError(http.StatusInternalServerError, err) } + result := bath.EnrichWithIntentions(trace, actions) event, err := h.toAccountEvent(ctx, *walletAddress, trace, result, params.AcceptLanguage, true) if err != nil { return nil, toError(http.StatusInternalServerError, err) diff --git a/pkg/core/account.go b/pkg/core/account.go index 57581f14..2d5942ef 100644 --- a/pkg/core/account.go +++ b/pkg/core/account.go @@ -56,7 +56,8 @@ type Contract struct { LastTransactionLt uint64 } -type AccountStats struct { +type AccountStat struct { + TonBalance int64 AccountID ton.AccountID NftsCount int32 JettonsCount int32