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

[Draft] clients/stellarcore: Add support for new Protocol 23 HTTP endpoints #5542

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
15 changes: 15 additions & 0 deletions clients/stellarcore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ func (c *Client) GetLedgerEntryRaw(ctx context.Context, ledgerSeq uint32, keys .
return resp, c.makeLedgerKeyRequest(ctx, &resp, "getledgerentryraw", ledgerSeq, keys...)
}

func (c *Client) GetLedgerEntries(ctx context.Context, ledgerSeq uint32, keys ...xdr.LedgerKey) (*proto.GetLedgerEntriesResponse, error) {
var resp *proto.GetLedgerEntriesResponse
return resp, c.makeLedgerKeyRequest(ctx, resp, "getledgerentries", ledgerSeq, keys...)
}

func (c *Client) GetInvocationProof(ctx context.Context, ledgerSeq uint32, keys ...xdr.LedgerKey) (*proto.ProofResponse, error) {
var resp *proto.ProofResponse
return resp, c.makeLedgerKeyRequest(ctx, resp, "getinvocationproof", ledgerSeq, keys...)
}

func (c *Client) GetRestorationProof(ctx context.Context, ledgerSeq uint32, keys ...xdr.LedgerKey) (*proto.ProofResponse, error) {
var resp *proto.ProofResponse
return resp, c.makeLedgerKeyRequest(ctx, resp, "getrestorationproof", ledgerSeq, keys...)
}

// SubmitTransaction calls the `tx` command on the connected stellar core with the provided envelope
func (c *Client) SubmitTransaction(ctx context.Context, envelope string) (resp *proto.TXResponse, err error) {
q := url.Values{}
Expand Down
20 changes: 20 additions & 0 deletions protocols/stellarcore/getledgerentry_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package stellarcore

const (
LedgerEntryStateLive = "live"
LedgerEntryStateNewProofless = "new_entry_no_proof"
LedgerEntryStateNewProof = "new_entry_proof"
LedgerEntryStateArchivedProofless = "archived_no_proof"
LedgerEntryStateArchivedProof = "archived_proof"
)

// GetLedgerEntriesResponse is the structure of Stellar Core's /getledgerentry
type GetLedgerEntriesResponse struct {
Ledger uint32 `json:"ledger"`
Entries []RawLedgerEntriesResponse `json:"entries"`
}

type RawLedgerEntriesResponse struct {
Entry string `json:"le"` // base64-encoded xdr.LedgerEntry
State string `json:"state"` // one of the above states
}
8 changes: 8 additions & 0 deletions protocols/stellarcore/proof_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package stellarcore

// ProofResponse is the structure of Stellar Core's /getrestorationproof and
// /getinvocationproof
type ProofResponse struct {
Ledger uint32 `json:"ledger"`
Proof string `json:"proof,omitempty"`
}
Loading