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

Incentives: Storing/ serving heartbeat transactions, synthetic transactions for payouts #1635

Merged
merged 8 commits into from
Dec 20, 2024
Merged
2 changes: 1 addition & 1 deletion api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The API is defined using [OpenAPI v2](https://swagger.io/specification/v2/) in *
The Makefile will install our fork of **oapi-codegen**, use `make oapi-codegen` to install it directly.

1. Document your changes by editing **indexer.oas2.yml**
2. Regenerate the endpoints by running **generate.sh**. The sources at **generated/** will be updated.
2. Regenerate the endpoints by running **make generate** from the `api` directory. The sources at **generated/** will be updated.
3. Update the implementation in **handlers.go**. It is sometimes useful to consult **generated/routes.go** to make sure the handler properly implements **ServerInterface**.

## What codegen tool is used?
Expand Down
26 changes: 22 additions & 4 deletions api/converter_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
var assetTransfer *generated.TransactionAssetTransfer
var application *generated.TransactionApplication
var stateProof *generated.TransactionStateProof
var heartbeat *generated.TransactionHeartbeat

switch stxn.Txn.Type {
case sdk.PaymentTx:
Expand Down Expand Up @@ -509,6 +510,22 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
StateProofType: uint64Ptr(uint64(stxn.Txn.StateProofType)),
}
stateProof = &proofTxn
case sdk.HeartbeatTx:
hb := stxn.Txn.HeartbeatTxnFields
hbTxn := generated.TransactionHeartbeat{
HbAddress: hb.HbAddress.String(),
HbKeyDilution: hb.HbKeyDilution,
jannotti marked this conversation as resolved.
Show resolved Hide resolved
HbProof: generated.HbProofFields{
HbPk: byteSliceOmitZeroPtr(hb.HbProof.PK[:]),
HbPk1sig: byteSliceOmitZeroPtr(hb.HbProof.PK1Sig[:]),
HbPk2: byteSliceOmitZeroPtr(hb.HbProof.PK2[:]),
HbPk2sig: byteSliceOmitZeroPtr(hb.HbProof.PK2Sig[:]),
HbSig: byteSliceOmitZeroPtr(hb.HbProof.Sig[:]),
},
HbSeed: hb.HbSeed[:],
HbVoteId: hb.HbVoteID[:],
}
heartbeat = &hbTxn
}

var localStateDelta *[]generated.AccountStateDelta
Expand Down Expand Up @@ -559,9 +576,9 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
for _, t := range stxn.ApplyData.EvalDelta.InnerTxns {
extra2 := extra
if t.Txn.Type == sdk.ApplicationCallTx {
extra2.AssetID = uint64(t.ApplyData.ApplicationID)
extra2.AssetID = t.ApplyData.ApplicationID
} else if t.Txn.Type == sdk.AssetConfigTx {
extra2.AssetID = uint64(t.ApplyData.ConfigAsset)
extra2.AssetID = t.ApplyData.ConfigAsset
} else {
extra2.AssetID = 0
}
Expand All @@ -585,6 +602,7 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
PaymentTransaction: payment,
KeyregTransaction: keyreg,
StateProofTransaction: stateProof,
HeartbeatTransaction: heartbeat,
ClosingAmount: uint64Ptr(uint64(stxn.ClosingAmount)),
ConfirmedRound: uint64Ptr(extra.Round),
IntraRoundOffset: uint64Ptr(uint64(extra.Intra)),
Expand Down Expand Up @@ -751,9 +769,9 @@ func (si *ServerImplementation) transactionParamsToTransactionFilter(params gene

func (si *ServerImplementation) maxAccountsErrorToAccountsErrorResponse(maxErr idb.MaxAPIResourcesPerAccountError) generated.ErrorResponse {
addr := maxErr.Address.String()
max := uint64(si.opts.MaxAPIResourcesPerAccount)
maxResults := si.opts.MaxAPIResourcesPerAccount
extraData := map[string]interface{}{
"max-results": max,
"max-results": maxResults,
"address": addr,
"total-assets-opted-in": maxErr.TotalAssets,
"total-created-assets": maxErr.TotalAssetParams,
Expand Down
18 changes: 0 additions & 18 deletions api/generate.sh

This file was deleted.

373 changes: 190 additions & 183 deletions api/generated/common/routes.go

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions api/generated/common/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading