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

services: rpc payment ingestor #47

Closed
wants to merge 2 commits into from
Closed

Conversation

gouthamp-stellar
Copy link
Contributor

@gouthamp-stellar gouthamp-stellar commented Sep 30, 2024

What

This pr replaces the ingestion of payments with a getTransactions RPC call

Why

We are removing all dependency on core in the wallet bakend, replacing it with rpc instead

Known limitations

N/A

Issue that this PR addresses

Checklist

PR Structure

  • It is not possible to break this PR down into smaller PRs.
  • This PR does not mix refactoring changes with feature changes.
  • This PR's title starts with name of package that is most changed in the PR, or all if the changes are broad or impact many packages.

Thoroughness

  • This PR adds tests for the new functionality or fixes.
  • All updated queries have been tested (refer to this check if the data set returned by the updated query is expected to be same as the original one).

Release

  • This is not a breaking change.
  • This is ready to be tested in development.
  • The new functionality is gated with a feature flag if this is not ready for production.

@gouthamp-stellar gouthamp-stellar changed the title rpc payment ingestor services: rpc payment ingestor Sep 30, 2024
}

cmd := &cobra.Command{
Use: "ingest",
Short: "Run Ingestion service",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// SET UP WEBHOOK CHANNEL HERE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TODO?

Comment on lines +69 to +70
PersistentPostRun: func(_ *cobra.Command, _ []string) {
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Comment on lines +134 to +143
func RPCURLOption(configKey *string) *config.ConfigOption {
return &config.ConfigOption{
Name: "rpc-url",
Usage: "The URL of the RPC Server.",
OptType: types.String,
ConfigKey: configKey,
FlagDefault: "localhost:8080",
Required: true,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about validating if the value passed here is a URL using the CustomSetValue?

if txMemo != nil {
*txMemo = utils.SanitizeUTF8(*txMemo)
}

for idx, op := range tx.Envelope.Operations() {
txEnvelopeXDR.SourceAccount()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can remove this line.

txns, err := ingestService.GetLedgerTransactions(1)
assert.Equal(t, 1, len(txns))
assert.Equal(t, txns[0].Hash, "hash1")
assert.Empty(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.Empty(t, err)
assert.NoError(t, err)

@@ -52,8 +56,33 @@ func (r *rpcService) GetTransaction(transactionHash string) (entities.RPCGetTran
return result, nil
}

func (r *rpcService) GetTransactions(startLedger int64, startCursor string, limit int) (entities.RPCGetTransactionsResult, error) {
if limit > PageLimit {
return entities.RPCGetTransactionsResult{}, fmt.Errorf("limit cannot exceed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can add a limit to the error to make it clearer.

)

type RPCTXCode struct {
TxResultCode xdr.TransactionResultCode
OtherCodes OtherCodes
}

var FinalErrorCodes = []xdr.TransactionResultCode{
xdr.TransactionResultCodeTxSuccess,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this value on FinalErrorCodes slice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can rename it to FinalCodes only or FinalStateCodes.

account := op.SourceAccount
if account != nil {
return account.ToAccountId().Address()
}

return tx.Envelope.SourceAccount().ToAccountId().Address()
txEnvelope.SourceAccount()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can remove this line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants