diff --git a/.github/workflows/galexie-release.yml b/.github/workflows/galexie-release.yml index b84f3c1cf0..815eb7107d 100644 --- a/.github/workflows/galexie-release.yml +++ b/.github/workflows/galexie-release.yml @@ -14,9 +14,9 @@ jobs: GALEXIE_INTEGRATION_TESTS_CAPTIVE_CORE_BIN: /usr/bin/stellar-core # this pins to a version of quickstart:testing that has the same version as STELLAR_CORE_VERSION # this is the multi-arch index sha, get it by 'docker buildx imagetools inspect stellar/quickstart:testing' - GALEXIE_INTEGRATION_TESTS_QUICKSTART_IMAGE: docker.io/stellar/quickstart:testing@sha256:03c6679f838a92b1eda4cd3a9e2bdee4c3586e278a138a0acf36a9bc99a0041f + GALEXIE_INTEGRATION_TESTS_QUICKSTART_IMAGE: docker.io/stellar/quickstart:testing@sha256:5333ec87069efd7bb61f6654a801dc093bf0aad91f43a5ba84806d3efe4a6322 GALEXIE_INTEGRATION_TESTS_QUICKSTART_IMAGE_PULL: "false" - STELLAR_CORE_VERSION: 21.3.1-2007.4ede19620.focal + STELLAR_CORE_VERSION: 22.0.0-2138.721fd0a65.focal steps: - name: Set VERSION run: | diff --git a/.github/workflows/galexie.yml b/.github/workflows/galexie.yml index 6406a7a897..7db2848d75 100644 --- a/.github/workflows/galexie.yml +++ b/.github/workflows/galexie.yml @@ -10,12 +10,12 @@ jobs: name: Test runs-on: ubuntu-latest env: - CAPTIVE_CORE_DEBIAN_PKG_VERSION: 21.3.1-2007.4ede19620.focal + CAPTIVE_CORE_DEBIAN_PKG_VERSION: 22.0.0-2138.721fd0a65.focal GALEXIE_INTEGRATION_TESTS_ENABLED: "true" GALEXIE_INTEGRATION_TESTS_CAPTIVE_CORE_BIN: /usr/bin/stellar-core # this pins to a version of quickstart:testing that has the same version as GALEXIE_INTEGRATION_TESTS_CAPTIVE_CORE_BIN # this is the multi-arch index sha, get it by 'docker buildx imagetools inspect stellar/quickstart:testing' - GALEXIE_INTEGRATION_TESTS_QUICKSTART_IMAGE: docker.io/stellar/quickstart:testing@sha256:5c8186f53cc98571749054dd782dce33b0aca2d1a622a7610362f7c15b79b1bf + GALEXIE_INTEGRATION_TESTS_QUICKSTART_IMAGE: docker.io/stellar/quickstart:testing@sha256:5333ec87069efd7bb61f6654a801dc093bf0aad91f43a5ba84806d3efe4a6322 GALEXIE_INTEGRATION_TESTS_QUICKSTART_IMAGE_PULL: "false" steps: - name: Install captive core diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index 86e68c3d85..21c3e234dd 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -13,7 +13,7 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] go: ["1.21", "1.22"] pg: [12, 16] - protocol-version: [21] + protocol-version: [21, 22] runs-on: ${{ matrix.os }} services: postgres: @@ -36,6 +36,9 @@ jobs: PROTOCOL_21_CORE_DEBIAN_PKG_VERSION: 21.3.1-2007.4ede19620.focal PROTOCOL_21_CORE_DOCKER_IMG: stellar/stellar-core:21.3.1-2007.4ede19620.focal PROTOCOL_21_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:21.5.1 + PROTOCOL_22_CORE_DEBIAN_PKG_VERSION: 22.0.0-2138.721fd0a65.focal + PROTOCOL_22_CORE_DOCKER_IMG: stellar/stellar-core:22.0.0-2138.721fd0a65.focal + PROTOCOL_22_SOROBAN_RPC_DOCKER_IMG: stellar/soroban-rpc:22.0.0-rc3-101 PGHOST: localhost PGPORT: 5432 PGUSER: postgres diff --git a/.gitignore b/.gitignore index c505323c66..8b40766e30 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ /services/horizon/captive-core /services/horizon/horizon /services/horizon/stellar-horizon -/bucket-cache +**bucket-cache/ .vscode .idea debug diff --git a/Makefile b/Makefile index 6e41e653bb..2e1a589414 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ XDRS = $(DOWNLOADABLE_XDRS) xdr/Stellar-exporter.x XDRGEN_COMMIT=e2cac557162d99b12ae73b846cf3d5bfe16636de -XDR_COMMIT=70180d5e8d9caee9e8645ed8a38c36a8cf403cd9 +XDR_COMMIT=529d5176f24c73eeccfa5eba481d4e89c19b1181 .PHONY: xdr xdr-clean xdr-update diff --git a/clients/horizonclient/internal.go b/clients/horizonclient/internal.go index 9dc6052263..9f43548a41 100644 --- a/clients/horizonclient/internal.go +++ b/clients/horizonclient/internal.go @@ -1,13 +1,16 @@ package horizonclient import ( + "bytes" "encoding/json" + "io" "net/http" "net/url" "strconv" "strings" "time" + "github.com/stellar/go/protocols/horizon" "github.com/stellar/go/support/clock" "github.com/stellar/go/support/errors" ) @@ -27,10 +30,11 @@ func decodeResponse(resp *http.Response, object interface{}, horizonUrl string, } setCurrentServerTime(u.Hostname(), resp.Header["Date"], clock) - // While this part of code assumes that any error < 200 or error >= 300 is a Horizon problem, it is not - // true for the response from /transactions_async endpoint which does give these codes for certain responses - // from core. - if !(resp.StatusCode >= 200 && resp.StatusCode < 300) && (resp.Request == nil || resp.Request.URL == nil || resp.Request.URL.Path != "/transactions_async") { + if isStatusCodeAnError(resp.StatusCode) { + if isAsyncTxSubRequest(resp) { + return decodeAsyncTxSubResponse(resp, object) + } + horizonError := &Error{ Response: resp, } @@ -47,6 +51,42 @@ func decodeResponse(resp *http.Response, object interface{}, horizonUrl string, return } +func isStatusCodeAnError(statusCode int) bool { + return !(statusCode >= 200 && statusCode < 300) +} + +func isAsyncTxSubRequest(resp *http.Response) bool { + return resp.Request != nil && resp.Request.URL != nil && resp.Request.URL.Path == "/transactions_async" +} + +func decodeAsyncTxSubResponse(resp *http.Response, object interface{}) error { + // We need to read the entire body in order to create 2 decoders later. + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + return errors.Wrap(err, "error reading response body") + } + + // The first decoder converts the response to AsyncTransactionSubmissionResponse and checks + // the hash of the transaction. If the response was not a valid AsyncTransactionSubmissionResponse object, + // the hash of the converted object will be empty. + asyncRespDecoder := json.NewDecoder(bytes.NewReader(bodyBytes)) + err = asyncRespDecoder.Decode(&object) + if asyncResp, ok := object.(*horizon.AsyncTransactionSubmissionResponse); err == nil && ok && asyncResp.Hash != "" { + return nil + } + + // Create a new reader for the second decoding. The second decoder decodes to Horizon.Problem object. + problemDecoder := json.NewDecoder(bytes.NewReader(bodyBytes)) + horizonError := Error{ + Response: resp, + } + err = problemDecoder.Decode(&horizonError.Problem) + if err != nil { + return errors.Wrap(err, "error decoding horizon error") + } + return horizonError +} + // countParams counts the number of parameters provided func countParams(params ...interface{}) int { counter := 0 diff --git a/clients/horizonclient/main_test.go b/clients/horizonclient/main_test.go index f7b4ba0788..b11b807bee 100644 --- a/clients/horizonclient/main_test.go +++ b/clients/horizonclient/main_test.go @@ -480,8 +480,6 @@ func TestAssetsRequest(t *testing.T) { assert.Equal(t, record.Asset.Code, "ABC") assert.Equal(t, record.Asset.Issuer, "GCLWGQPMKXQSPF776IU33AH4PZNOOWNAWGGKVTBQMIC5IMKUNP3E6NVU") assert.Equal(t, record.PT, "1") - assert.Equal(t, record.NumAccounts, int32(3)) - assert.Equal(t, record.Amount, "105.0000000") assert.Equal(t, record.Flags.AuthRevocable, false) assert.Equal(t, record.Flags.AuthRequired, true) assert.Equal(t, record.Flags.AuthImmutable, false) diff --git a/clients/stellarcore/client.go b/clients/stellarcore/client.go index 931a076021..80938da577 100644 --- a/clients/stellarcore/client.go +++ b/clients/stellarcore/client.go @@ -1,11 +1,11 @@ package stellarcore import ( + "bytes" "context" "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -21,7 +21,7 @@ import ( // Client represents a client that is capable of communicating with a // stellar-core server using HTTP type Client struct { - // HTTP is the client to use when communicating with stellar-core. If nil, + // HTTP is the client to use when communicating with stellar-core. If nil, // http.DefaultClient will be used. HTTP HTTP @@ -36,7 +36,7 @@ type Client struct { // in case an error was encountered during either the draining or closing of the // stream, that error would be returned. func drainReponse(hresp *http.Response, close bool, err *error) (outerror error) { - _, err2 := io.Copy(ioutil.Discard, hresp.Body) + _, err2 := io.Copy(io.Discard, hresp.Body) if err2 != nil { if err != nil && *err == nil { *err = errors.Wrap(err2, "unable to read excess data from response") @@ -75,54 +75,12 @@ func (c *Client) Upgrade(ctx context.Context, version int) (err error) { } defer drainReponse(hresp, true, &err) //nolint:errcheck - if !(hresp.StatusCode >= 200 && hresp.StatusCode < 300) { - err = errors.New("http request failed with non-200 status code") - return + if hresp.StatusCode < 200 || hresp.StatusCode >= 300 { + return errors.New("http request failed with non-200 status code") } return nil } -// GetLedgerEntry submits a request to the stellar core instance to get the latest -// state of a given ledger entry. -func (c *Client) GetLedgerEntry(ctx context.Context, ledgerKey xdr.LedgerKey) (proto.GetLedgerEntryResponse, error) { - b64, err := xdr.MarshalBase64(ledgerKey) - if err != nil { - return proto.GetLedgerEntryResponse{}, errors.Wrap(err, "failed to marshal ledger key") - } - q := url.Values{} - q.Set("key", b64) - - req, err := c.simpleGet(ctx, "getledgerentry", q) - if err != nil { - return proto.GetLedgerEntryResponse{}, errors.Wrap(err, "failed to create request") - } - - hresp, err := c.http().Do(req) - if err != nil { - return proto.GetLedgerEntryResponse{}, errors.Wrap(err, "http request errored") - } - defer hresp.Body.Close() - - if !(hresp.StatusCode >= 200 && hresp.StatusCode < 300) { - if drainReponse(hresp, false, &err) != nil { - return proto.GetLedgerEntryResponse{}, err - } - return proto.GetLedgerEntryResponse{}, errors.New("http request failed with non-200 status code") - } - - responseBytes, err := io.ReadAll(hresp.Body) - if err != nil { - return proto.GetLedgerEntryResponse{}, errors.Wrap(err, "could not read response") - } - - var response proto.GetLedgerEntryResponse - if err = json.Unmarshal(responseBytes, &response); err != nil { - return proto.GetLedgerEntryResponse{}, errors.Wrap(err, "json decode failed: "+string(responseBytes)) - } - - return response, nil -} - // Info calls the `info` command on the connected stellar core and returns the // provided response func (c *Client) Info(ctx context.Context) (resp *proto.InfoResponse, err error) { @@ -180,7 +138,7 @@ func (c *Client) SetCursor(ctx context.Context, id string, cursor int32) (err er } var raw []byte - raw, err = ioutil.ReadAll(hresp.Body) + raw, err = io.ReadAll(hresp.Body) if err != nil { return err } @@ -193,9 +151,13 @@ func (c *Client) SetCursor(ctx context.Context, id string, cursor int32) (err er return nil } +func (c *Client) GetLedgerEntryRaw(ctx context.Context, ledgerSeq uint32, keys ...xdr.LedgerKey) (proto.GetLedgerEntryRawResponse, error) { + var resp proto.GetLedgerEntryRawResponse + return resp, c.makeLedgerKeyRequest(ctx, &resp, "getledgerentryraw", 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{} q.Set("blob", envelope) @@ -214,13 +176,12 @@ func (c *Client) SubmitTransaction(ctx context.Context, envelope string) (resp * } defer drainReponse(hresp, true, &err) //nolint:errcheck - if !(hresp.StatusCode >= 200 && hresp.StatusCode < 300) { + if hresp.StatusCode < 200 || hresp.StatusCode >= 300 { err = errors.New("http request failed with non-200 status code") return } err = json.NewDecoder(hresp.Body).Decode(&resp) - if err != nil { err = errors.Wrap(err, "json decode failed") return @@ -232,7 +193,6 @@ func (c *Client) SubmitTransaction(ctx context.Context, envelope string) (resp * // WaitForNetworkSync continually polls the connected stellar-core until it // receives a response that indicated the node has synced with the network func (c *Client) WaitForNetworkSync(ctx context.Context) error { - for { info, err := c.Info(ctx) @@ -256,7 +216,6 @@ func (c *Client) WaitForNetworkSync(ctx context.Context) error { // ManualClose closes a ledger when Core is running in `MANUAL_CLOSE` mode func (c *Client) ManualClose(ctx context.Context) (err error) { - q := url.Values{} var req *http.Request @@ -274,7 +233,7 @@ func (c *Client) ManualClose(ctx context.Context) (err error) { } defer drainReponse(hresp, true, &err) //nolint:errcheck - if !(hresp.StatusCode >= 200 && hresp.StatusCode < 300) { + if hresp.StatusCode < 200 || hresp.StatusCode >= 300 { err = errors.New("http request failed with non-200 status code") return } @@ -312,7 +271,6 @@ func (c *Client) simpleGet( newPath string, query url.Values, ) (*http.Request, error) { - u, err := url.Parse(c.URL) if err != nil { return nil, errors.Wrap(err, "unparseable url") @@ -332,3 +290,93 @@ func (c *Client) simpleGet( return req, nil } + +// rawPost returns a new POST request to the connected stellar-core using the +// provided path and the params values encoded as the request body to construct +// the result. +func (c *Client) rawPost( + ctx context.Context, + newPath string, + body string, +) (*http.Request, error) { + u, err := url.Parse(c.URL) + if err != nil { + return nil, errors.Wrap(err, "unparseable url") + } + + u.Path = path.Join(u.Path, newPath) + newURL := u.String() + + var req *http.Request + req, err = http.NewRequestWithContext( + ctx, + http.MethodPost, + newURL, + bytes.NewBuffer([]byte(body))) + if err != nil { + return nil, errors.Wrap(err, "failed to create request") + } + + return req, nil +} + +// makeLedgerKeyRequest is a generic method to perform a request in the form +// `key=...&key=...&ledgerSeq=...` which is useful because several Stellar Core +// endpoints all use this request format. Be sure to pass `target` by reference. +func (c *Client) makeLedgerKeyRequest( + ctx context.Context, + target interface{}, + endpoint string, + ledgerSeq uint32, + keys ...xdr.LedgerKey, +) error { + if len(keys) == 0 { + return errors.New("no keys specified in request") + } + + q, err := buildMultiKeyRequest(keys...) + if err != nil { + return err + } + if ledgerSeq >= 2 { // optional param + q += fmt.Sprintf("&ledgerSeq=%d", ledgerSeq) + } + + var req *http.Request + req, err = c.rawPost(ctx, endpoint, q) + if err != nil { + return err + } + + var hresp *http.Response + hresp, err = c.http().Do(req) + if err != nil { + return errors.Wrap(err, "http request errored") + } + defer drainReponse(hresp, true, &err) //nolint:errcheck + + if hresp.StatusCode < 200 || hresp.StatusCode >= 300 { + return fmt.Errorf("http request failed with non-200 status code (%d)", hresp.StatusCode) + } + + // wrap returns nil if the inner error is nil + return errors.Wrap(json.NewDecoder(hresp.Body).Decode(&target), "json decode failed") +} + +// buildMultiKeyRequest is a workaround helper because, unfortunately, +// url.Values does not support multiple keys via Set(), so we have to build our +// URL parameters manually. +func buildMultiKeyRequest(keys ...xdr.LedgerKey) (string, error) { + stringKeys := make([]string, 0, len(keys)) + + for _, key := range keys { + keyB64, err := key.MarshalBinaryBase64() + if err != nil { + return "", errors.Wrap(err, "failed to encode LedgerKey") + } + + stringKeys = append(stringKeys, "key="+url.QueryEscape(keyB64)) + } + + return strings.Join(stringKeys, "&"), nil +} diff --git a/clients/stellarcore/client_test.go b/clients/stellarcore/client_test.go index 6cfd01b210..47540b2464 100644 --- a/clients/stellarcore/client_test.go +++ b/clients/stellarcore/client_test.go @@ -2,13 +2,20 @@ package stellarcore import ( "context" + "fmt" + "io" "net/http" + "net/url" "testing" + "github.com/jarcoal/httpmock" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/stellar/go/keypair" proto "github.com/stellar/go/protocols/stellarcore" "github.com/stellar/go/support/http/httptest" + "github.com/stellar/go/xdr" ) func TestSubmitTransaction(t *testing.T) { @@ -75,3 +82,56 @@ func TestManualClose_NotAvailable(t *testing.T) { assert.EqualError(t, err, "exception in response: Set MANUAL_CLOSE=true") } + +func TestGetLedgerEntries(t *testing.T) { + hmock := httptest.NewClient() + c := &Client{HTTP: hmock, URL: "http://localhost:11626"} + + // build a fake response body + mockResp := proto.GetLedgerEntryRawResponse{ + Ledger: 1215, // checkpoint align on expected request + Entries: []proto.RawLedgerEntryResponse{ + { + Entry: "pretend this is XDR lol", + }, + { + Entry: "pretend this is another XDR lol", + }, + }, + } + + var key xdr.LedgerKey + acc, err := xdr.AddressToAccountId(keypair.MustRandom().Address()) + require.NoError(t, err) + key.SetAccount(acc) + + // happy path - fetch an entry + ce := hmock.On("POST", "http://localhost:11626/getledgerentryraw") + hmock.RegisterResponder( + "POST", + "http://localhost:11626/getledgerentryraw", + func(r *http.Request) (*http.Response, error) { + // Ensure the request has the correct POST body + requestData, ierr := io.ReadAll(r.Body) + require.NoError(t, ierr) + + keyB64, ierr := key.MarshalBinaryBase64() + require.NoError(t, ierr) + expected := fmt.Sprintf("key=%s&ledgerSeq=1234", url.QueryEscape(keyB64)) + require.Equal(t, expected, string(requestData)) + + resp, ierr := httpmock.NewJsonResponse(http.StatusOK, &mockResp) + require.NoError(t, ierr) + ce.Return(httpmock.ResponderFromResponse(resp)) + return resp, nil + }) + + resp, err := c.GetLedgerEntryRaw(context.Background(), 1234, key) + require.NoError(t, err) + require.NotNil(t, resp) + + require.EqualValues(t, 1215, resp.Ledger) + require.Len(t, resp.Entries, 2) + require.Equal(t, "pretend this is XDR lol", resp.Entries[0].Entry) + require.Equal(t, "pretend this is another XDR lol", resp.Entries[1].Entry) +} diff --git a/gxdr/xdr_generated.go b/gxdr/xdr_generated.go index 0b41834ce9..5686964be2 100644 --- a/gxdr/xdr_generated.go +++ b/gxdr/xdr_generated.go @@ -813,6 +813,135 @@ const ( ENVELOPE_TYPE_SOROBAN_AUTHORIZATION EnvelopeType = 9 ) +type BucketListType int32 + +const ( + LIVE BucketListType = 0 + HOT_ARCHIVE BucketListType = 1 + COLD_ARCHIVE BucketListType = 2 +) + +/* Entries used to define the bucket list */ +type BucketEntryType int32 + +const ( + // At-and-after protocol 11: bucket metadata, should come first. + METAENTRY BucketEntryType = -1 + // Before protocol 11: created-or-updated; + LIVEENTRY BucketEntryType = 0 + // At-and-after protocol 11: only updated. + DEADENTRY BucketEntryType = 1 + // At-and-after protocol 11: only created. + INITENTRY BucketEntryType = 2 +) + +type HotArchiveBucketEntryType int32 + +const ( + // Bucket metadata, should come first. + HOT_ARCHIVE_METAENTRY HotArchiveBucketEntryType = -1 + // Entry is Archived + HOT_ARCHIVE_ARCHIVED HotArchiveBucketEntryType = 0 + // Entry was previously HOT_ARCHIVE_ARCHIVED, or HOT_ARCHIVE_DELETED, but + HOT_ARCHIVE_LIVE HotArchiveBucketEntryType = 1 + // has been added back to the live BucketList. + // Does not need to be persisted. + HOT_ARCHIVE_DELETED HotArchiveBucketEntryType = 2 +) + +type ColdArchiveBucketEntryType int32 + +const ( + // Bucket metadata, should come first. + COLD_ARCHIVE_METAENTRY ColdArchiveBucketEntryType = -1 + // Full LedgerEntry that was archived during the epoch + COLD_ARCHIVE_ARCHIVED_LEAF ColdArchiveBucketEntryType = 0 + // LedgerKey that was deleted during the epoch + COLD_ARCHIVE_DELETED_LEAF ColdArchiveBucketEntryType = 1 + // Dummy leaf representing low/high bound + COLD_ARCHIVE_BOUNDARY_LEAF ColdArchiveBucketEntryType = 2 + // Intermediary Merkle hash entry + COLD_ARCHIVE_HASH ColdArchiveBucketEntryType = 3 +) + +type BucketMetadata struct { + // Indicates the protocol version used to create / merge this bucket. + LedgerVersion Uint32 + Ext XdrAnon_BucketMetadata_Ext +} + +// reserved for future use +type XdrAnon_BucketMetadata_Ext struct { + // The union discriminant V selects among the following arms: + // 0: + // void + // 1: + // BucketListType() *BucketListType + V int32 + _u interface{} +} + +type BucketEntry struct { + // The union discriminant Type selects among the following arms: + // LIVEENTRY, INITENTRY: + // LiveEntry() *LedgerEntry + // DEADENTRY: + // DeadEntry() *LedgerKey + // METAENTRY: + // MetaEntry() *BucketMetadata + Type BucketEntryType + _u interface{} +} + +type HotArchiveBucketEntry struct { + // The union discriminant Type selects among the following arms: + // HOT_ARCHIVE_ARCHIVED: + // ArchivedEntry() *LedgerEntry + // HOT_ARCHIVE_LIVE, HOT_ARCHIVE_DELETED: + // Key() *LedgerKey + // HOT_ARCHIVE_METAENTRY: + // MetaEntry() *BucketMetadata + Type HotArchiveBucketEntryType + _u interface{} +} + +type ColdArchiveArchivedLeaf struct { + Index Uint32 + ArchivedEntry LedgerEntry +} + +type ColdArchiveDeletedLeaf struct { + Index Uint32 + DeletedKey LedgerKey +} + +type ColdArchiveBoundaryLeaf struct { + Index Uint32 + IsLowerBound bool +} + +type ColdArchiveHashEntry struct { + Index Uint32 + Level Uint32 + Hash Hash +} + +type ColdArchiveBucketEntry struct { + // The union discriminant Type selects among the following arms: + // COLD_ARCHIVE_METAENTRY: + // MetaEntry() *BucketMetadata + // COLD_ARCHIVE_ARCHIVED_LEAF: + // ArchivedLeaf() *ColdArchiveArchivedLeaf + // COLD_ARCHIVE_DELETED_LEAF: + // DeletedLeaf() *ColdArchiveDeletedLeaf + // COLD_ARCHIVE_BOUNDARY_LEAF: + // BoundaryLeaf() *ColdArchiveBoundaryLeaf + // COLD_ARCHIVE_HASH: + // HashEntry() *ColdArchiveHashEntry + Type ColdArchiveBucketEntryType + _u interface{} +} + type UpgradeType = []byte // bound 128 type StellarValueType int32 @@ -973,47 +1102,6 @@ type ConfigUpgradeSet struct { UpdatedEntry []ConfigSettingEntry } -/* Entries used to define the bucket list */ -type BucketEntryType int32 - -const ( - // At-and-after protocol 11: bucket metadata, should come first. - METAENTRY BucketEntryType = -1 - // Before protocol 11: created-or-updated; - LIVEENTRY BucketEntryType = 0 - // At-and-after protocol 11: only updated. - DEADENTRY BucketEntryType = 1 - // At-and-after protocol 11: only created. - INITENTRY BucketEntryType = 2 -) - -type BucketMetadata struct { - // Indicates the protocol version used to create / merge this bucket. - LedgerVersion Uint32 - Ext XdrAnon_BucketMetadata_Ext -} - -// reserved for future use -type XdrAnon_BucketMetadata_Ext struct { - // The union discriminant V selects among the following arms: - // 0: - // void - V int32 - _u interface{} -} - -type BucketEntry struct { - // The union discriminant Type selects among the following arms: - // LIVEENTRY, INITENTRY: - // LiveEntry() *LedgerEntry - // DEADENTRY: - // DeadEntry() *LedgerKey - // METAENTRY: - // MetaEntry() *BucketMetadata - Type BucketEntryType - _u interface{} -} - type TxSetComponentType int32 const ( @@ -2217,6 +2305,7 @@ const ( HOST_FUNCTION_TYPE_INVOKE_CONTRACT HostFunctionType = 0 HOST_FUNCTION_TYPE_CREATE_CONTRACT HostFunctionType = 1 HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM HostFunctionType = 2 + HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2 HostFunctionType = 3 ) type ContractIDPreimageType int32 @@ -2245,6 +2334,13 @@ type CreateContractArgs struct { Executable ContractExecutable } +type CreateContractArgsV2 struct { + ContractIDPreimage ContractIDPreimage + Executable ContractExecutable + // Arguments of the contract's constructor. + ConstructorArgs []SCVal +} + type InvokeContractArgs struct { ContractAddress SCAddress FunctionName SCSymbol @@ -2259,6 +2355,8 @@ type HostFunction struct { // CreateContract() *CreateContractArgs // HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: // Wasm() *[]byte + // HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + // CreateContractV2() *CreateContractArgsV2 Type HostFunctionType _u interface{} } @@ -2266,8 +2364,9 @@ type HostFunction struct { type SorobanAuthorizedFunctionType int32 const ( - SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN SorobanAuthorizedFunctionType = 0 - SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN SorobanAuthorizedFunctionType = 1 + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN SorobanAuthorizedFunctionType = 0 + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN SorobanAuthorizedFunctionType = 1 + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN SorobanAuthorizedFunctionType = 2 ) type SorobanAuthorizedFunction struct { @@ -2276,6 +2375,8 @@ type SorobanAuthorizedFunction struct { // ContractFn() *InvokeContractArgs // SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: // CreateContractHostFn() *CreateContractArgs + // SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + // CreateContractV2HostFn() *CreateContractArgsV2 Type SorobanAuthorizedFunctionType _u interface{} } @@ -2551,6 +2652,53 @@ type LedgerFootprint struct { ReadWrite []LedgerKey } +type ArchivalProofType int32 + +const ( + EXISTENCE ArchivalProofType = 0 + NONEXISTENCE ArchivalProofType = 1 +) + +type ArchivalProofNode struct { + Index Uint32 + Hash Hash +} + +type ProofLevel = []ArchivalProofNode + +type NonexistenceProofBody struct { + EntriesToProve []ColdArchiveBucketEntry + // Vector of vectors, where proofLevels[level] + // contains all HashNodes that correspond with that level + ProofLevels []ProofLevel +} + +type ExistenceProofBody struct { + KeysToProve []LedgerKey + // Bounds for each key being proved, where bound[n] + // corresponds to keysToProve[n] + LowBoundEntries []ColdArchiveBucketEntry + HighBoundEntries []ColdArchiveBucketEntry + // Vector of vectors, where proofLevels[level] + // contains all HashNodes that correspond with that level + ProofLevels []ProofLevel +} + +type ArchivalProof struct { + // AST Subtree for this proof + Epoch Uint32 + Body XdrAnon_ArchivalProof_Body +} +type XdrAnon_ArchivalProof_Body struct { + // The union discriminant T selects among the following arms: + // EXISTENCE: + // NonexistenceProof() *NonexistenceProofBody + // NONEXISTENCE: + // ExistenceProof() *ExistenceProofBody + T ArchivalProofType + _u interface{} +} + // Resource limits for a Soroban transaction. // The transaction will fail if it exceeds any of these limits. type SorobanResources struct { @@ -3831,6 +3979,34 @@ type HmacSha256Mac struct { Mac [32]byte } +type ShortHashSeed struct { + Seed [16]byte +} + +type BinaryFuseFilterType int32 + +const ( + BINARY_FUSE_FILTER_8_BIT BinaryFuseFilterType = 0 + BINARY_FUSE_FILTER_16_BIT BinaryFuseFilterType = 1 + BINARY_FUSE_FILTER_32_BIT BinaryFuseFilterType = 2 +) + +type SerializedBinaryFuseFilter struct { + Type BinaryFuseFilterType + // Seed used to hash input to filter + InputHashSeed ShortHashSeed + // Seed used for internal filter hash operations + FilterSeed ShortHashSeed + SegmentLength Uint32 + SegementLengthMask Uint32 + SegmentCount Uint32 + SegmentCountLength Uint32 + // Length in terms of element count, not bytes + FingerprintLength Uint32 + // Array of uint8_t, uint16_t, or uint32_t depending on filter type + Fingerprints []byte +} + type SCEnvMetaKind int32 const ( @@ -3840,10 +4016,14 @@ const ( type SCEnvMetaEntry struct { // The union discriminant Kind selects among the following arms: // SC_ENV_META_KIND_INTERFACE_VERSION: - // InterfaceVersion() *Uint64 + // InterfaceVersion() *XdrAnon_SCEnvMetaEntry_InterfaceVersion Kind SCEnvMetaKind _u interface{} } +type XdrAnon_SCEnvMetaEntry_InterfaceVersion struct { + Protocol Uint32 + PreRelease Uint32 +} type SCMetaV0 struct { Key string @@ -4529,6 +4709,56 @@ const ( Sec1DecodePointUncompressed ContractCostType = 43 // Cost of verifying an ECDSA Secp256r1 signature VerifyEcdsaSecp256r1Sig ContractCostType = 44 + // Cost of encoding a BLS12-381 Fp (base field element) + Bls12381EncodeFp ContractCostType = 45 + // Cost of decoding a BLS12-381 Fp (base field element) + Bls12381DecodeFp ContractCostType = 46 + // Cost of checking a G1 point lies on the curve + Bls12381G1CheckPointOnCurve ContractCostType = 47 + // Cost of checking a G1 point belongs to the correct subgroup + Bls12381G1CheckPointInSubgroup ContractCostType = 48 + // Cost of checking a G2 point lies on the curve + Bls12381G2CheckPointOnCurve ContractCostType = 49 + // Cost of checking a G2 point belongs to the correct subgroup + Bls12381G2CheckPointInSubgroup ContractCostType = 50 + // Cost of converting a BLS12-381 G1 point from projective to affine coordinates + Bls12381G1ProjectiveToAffine ContractCostType = 51 + // Cost of converting a BLS12-381 G2 point from projective to affine coordinates + Bls12381G2ProjectiveToAffine ContractCostType = 52 + // Cost of performing BLS12-381 G1 point addition + Bls12381G1Add ContractCostType = 53 + // Cost of performing BLS12-381 G1 scalar multiplication + Bls12381G1Mul ContractCostType = 54 + // Cost of performing BLS12-381 G1 multi-scalar multiplication (MSM) + Bls12381G1Msm ContractCostType = 55 + // Cost of mapping a BLS12-381 Fp field element to a G1 point + Bls12381MapFpToG1 ContractCostType = 56 + // Cost of hashing to a BLS12-381 G1 point + Bls12381HashToG1 ContractCostType = 57 + // Cost of performing BLS12-381 G2 point addition + Bls12381G2Add ContractCostType = 58 + // Cost of performing BLS12-381 G2 scalar multiplication + Bls12381G2Mul ContractCostType = 59 + // Cost of performing BLS12-381 G2 multi-scalar multiplication (MSM) + Bls12381G2Msm ContractCostType = 60 + // Cost of mapping a BLS12-381 Fp2 field element to a G2 point + Bls12381MapFp2ToG2 ContractCostType = 61 + // Cost of hashing to a BLS12-381 G2 point + Bls12381HashToG2 ContractCostType = 62 + // Cost of performing BLS12-381 pairing operation + Bls12381Pairing ContractCostType = 63 + // Cost of converting a BLS12-381 scalar element from U256 + Bls12381FrFromU256 ContractCostType = 64 + // Cost of converting a BLS12-381 scalar element to U256 + Bls12381FrToU256 ContractCostType = 65 + // Cost of performing BLS12-381 scalar element addition/subtraction + Bls12381FrAddSub ContractCostType = 66 + // Cost of performing BLS12-381 scalar element multiplication + Bls12381FrMul ContractCostType = 67 + // Cost of performing BLS12-381 scalar element exponentiation + Bls12381FrPow ContractCostType = 68 + // Cost of performing BLS12-381 scalar element inversion + Bls12381FrInv ContractCostType = 69 ) type ContractCostParamEntry struct { @@ -9236,327 +9466,300 @@ type XdrType_EnvelopeType = *EnvelopeType func XDR_EnvelopeType(v *EnvelopeType) *EnvelopeType { return v } -type XdrType_UpgradeType struct { - XdrVecOpaque +var _XdrNames_BucketListType = map[int32]string{ + int32(LIVE): "LIVE", + int32(HOT_ARCHIVE): "HOT_ARCHIVE", + int32(COLD_ARCHIVE): "COLD_ARCHIVE", +} +var _XdrValues_BucketListType = map[string]int32{ + "LIVE": int32(LIVE), + "HOT_ARCHIVE": int32(HOT_ARCHIVE), + "COLD_ARCHIVE": int32(COLD_ARCHIVE), } -func XDR_UpgradeType(v *UpgradeType) XdrType_UpgradeType { - return XdrType_UpgradeType{XdrVecOpaque{v, 128}} +func (BucketListType) XdrEnumNames() map[int32]string { + return _XdrNames_BucketListType } -func (XdrType_UpgradeType) XdrTypeName() string { return "UpgradeType" } -func (v XdrType_UpgradeType) XdrUnwrap() XdrType { return v.XdrVecOpaque } +func (v BucketListType) String() string { + if s, ok := _XdrNames_BucketListType[int32(v)]; ok { + return s + } + return fmt.Sprintf("BucketListType#%d", v) +} +func (v *BucketListType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_BucketListType[stok]; ok { + *v = BucketListType(val) + return nil + } else if stok == "BucketListType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid BucketListType.", stok)) + } +} +func (v BucketListType) GetU32() uint32 { return uint32(v) } +func (v *BucketListType) SetU32(n uint32) { *v = BucketListType(n) } +func (v *BucketListType) XdrPointer() interface{} { return v } +func (BucketListType) XdrTypeName() string { return "BucketListType" } +func (v BucketListType) XdrValue() interface{} { return v } +func (v *BucketListType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -var _XdrNames_StellarValueType = map[int32]string{ - int32(STELLAR_VALUE_BASIC): "STELLAR_VALUE_BASIC", - int32(STELLAR_VALUE_SIGNED): "STELLAR_VALUE_SIGNED", +type XdrType_BucketListType = *BucketListType + +func XDR_BucketListType(v *BucketListType) *BucketListType { return v } + +var _XdrNames_BucketEntryType = map[int32]string{ + int32(METAENTRY): "METAENTRY", + int32(LIVEENTRY): "LIVEENTRY", + int32(DEADENTRY): "DEADENTRY", + int32(INITENTRY): "INITENTRY", } -var _XdrValues_StellarValueType = map[string]int32{ - "STELLAR_VALUE_BASIC": int32(STELLAR_VALUE_BASIC), - "STELLAR_VALUE_SIGNED": int32(STELLAR_VALUE_SIGNED), +var _XdrValues_BucketEntryType = map[string]int32{ + "METAENTRY": int32(METAENTRY), + "LIVEENTRY": int32(LIVEENTRY), + "DEADENTRY": int32(DEADENTRY), + "INITENTRY": int32(INITENTRY), } -func (StellarValueType) XdrEnumNames() map[int32]string { - return _XdrNames_StellarValueType +func (BucketEntryType) XdrEnumNames() map[int32]string { + return _XdrNames_BucketEntryType } -func (v StellarValueType) String() string { - if s, ok := _XdrNames_StellarValueType[int32(v)]; ok { +func (v BucketEntryType) String() string { + if s, ok := _XdrNames_BucketEntryType[int32(v)]; ok { return s } - return fmt.Sprintf("StellarValueType#%d", v) + return fmt.Sprintf("BucketEntryType#%d", v) } -func (v *StellarValueType) Scan(ss fmt.ScanState, _ rune) error { +func (v *BucketEntryType) Scan(ss fmt.ScanState, _ rune) error { if tok, err := ss.Token(true, XdrSymChar); err != nil { return err } else { stok := string(tok) - if val, ok := _XdrValues_StellarValueType[stok]; ok { - *v = StellarValueType(val) + if val, ok := _XdrValues_BucketEntryType[stok]; ok { + *v = BucketEntryType(val) return nil - } else if stok == "StellarValueType" { + } else if stok == "BucketEntryType" { if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { return nil } } - return XdrError(fmt.Sprintf("%s is not a valid StellarValueType.", stok)) + return XdrError(fmt.Sprintf("%s is not a valid BucketEntryType.", stok)) } } -func (v StellarValueType) GetU32() uint32 { return uint32(v) } -func (v *StellarValueType) SetU32(n uint32) { *v = StellarValueType(n) } -func (v *StellarValueType) XdrPointer() interface{} { return v } -func (StellarValueType) XdrTypeName() string { return "StellarValueType" } -func (v StellarValueType) XdrValue() interface{} { return v } -func (v *StellarValueType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v BucketEntryType) GetU32() uint32 { return uint32(v) } +func (v *BucketEntryType) SetU32(n uint32) { *v = BucketEntryType(n) } +func (v *BucketEntryType) XdrPointer() interface{} { return v } +func (BucketEntryType) XdrTypeName() string { return "BucketEntryType" } +func (v BucketEntryType) XdrValue() interface{} { return v } +func (v *BucketEntryType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_StellarValueType = *StellarValueType +type XdrType_BucketEntryType = *BucketEntryType -func XDR_StellarValueType(v *StellarValueType) *StellarValueType { return v } +func XDR_BucketEntryType(v *BucketEntryType) *BucketEntryType { return v } -type XdrType_LedgerCloseValueSignature = *LedgerCloseValueSignature +var _XdrComments_BucketEntryType = map[int32]string{ + int32(METAENTRY): "At-and-after protocol 11: bucket metadata, should come first.", + int32(LIVEENTRY): "Before protocol 11: created-or-updated;", + int32(DEADENTRY): "At-and-after protocol 11: only updated.", + int32(INITENTRY): "At-and-after protocol 11: only created.", +} -func (v *LedgerCloseValueSignature) XdrPointer() interface{} { return v } -func (LedgerCloseValueSignature) XdrTypeName() string { return "LedgerCloseValueSignature" } -func (v LedgerCloseValueSignature) XdrValue() interface{} { return v } -func (v *LedgerCloseValueSignature) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerCloseValueSignature) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%snodeID", name), XDR_NodeID(&v.NodeID)) - x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) +func (e BucketEntryType) XdrEnumComments() map[int32]string { + return _XdrComments_BucketEntryType } -func XDR_LedgerCloseValueSignature(v *LedgerCloseValueSignature) *LedgerCloseValueSignature { return v } -var _XdrTags_XdrAnon_StellarValue_Ext = map[int32]bool{ - XdrToI32(STELLAR_VALUE_BASIC): true, - XdrToI32(STELLAR_VALUE_SIGNED): true, +var _XdrNames_HotArchiveBucketEntryType = map[int32]string{ + int32(HOT_ARCHIVE_METAENTRY): "HOT_ARCHIVE_METAENTRY", + int32(HOT_ARCHIVE_ARCHIVED): "HOT_ARCHIVE_ARCHIVED", + int32(HOT_ARCHIVE_LIVE): "HOT_ARCHIVE_LIVE", + int32(HOT_ARCHIVE_DELETED): "HOT_ARCHIVE_DELETED", +} +var _XdrValues_HotArchiveBucketEntryType = map[string]int32{ + "HOT_ARCHIVE_METAENTRY": int32(HOT_ARCHIVE_METAENTRY), + "HOT_ARCHIVE_ARCHIVED": int32(HOT_ARCHIVE_ARCHIVED), + "HOT_ARCHIVE_LIVE": int32(HOT_ARCHIVE_LIVE), + "HOT_ARCHIVE_DELETED": int32(HOT_ARCHIVE_DELETED), } -func (_ XdrAnon_StellarValue_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_StellarValue_Ext +func (HotArchiveBucketEntryType) XdrEnumNames() map[int32]string { + return _XdrNames_HotArchiveBucketEntryType } -func (u *XdrAnon_StellarValue_Ext) LcValueSignature() *LedgerCloseValueSignature { - switch u.V { - case STELLAR_VALUE_SIGNED: - if v, ok := u._u.(*LedgerCloseValueSignature); ok { - return v - } else { - var zero LedgerCloseValueSignature - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_StellarValue_Ext.LcValueSignature accessed when V == %v", u.V) - return nil +func (v HotArchiveBucketEntryType) String() string { + if s, ok := _XdrNames_HotArchiveBucketEntryType[int32(v)]; ok { + return s } + return fmt.Sprintf("HotArchiveBucketEntryType#%d", v) } -func (u XdrAnon_StellarValue_Ext) XdrValid() bool { - switch u.V { - case STELLAR_VALUE_BASIC, STELLAR_VALUE_SIGNED: - return true - } - return false -} -func (u *XdrAnon_StellarValue_Ext) XdrUnionTag() XdrNum32 { - return XDR_StellarValueType(&u.V) -} -func (u *XdrAnon_StellarValue_Ext) XdrUnionTagName() string { - return "V" -} -func (u *XdrAnon_StellarValue_Ext) XdrUnionBody() XdrType { - switch u.V { - case STELLAR_VALUE_BASIC: - return nil - case STELLAR_VALUE_SIGNED: - return XDR_LedgerCloseValueSignature(u.LcValueSignature()) - } - return nil -} -func (u *XdrAnon_StellarValue_Ext) XdrUnionBodyName() string { - switch u.V { - case STELLAR_VALUE_BASIC: - return "" - case STELLAR_VALUE_SIGNED: - return "LcValueSignature" +func (v *HotArchiveBucketEntryType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_HotArchiveBucketEntryType[stok]; ok { + *v = HotArchiveBucketEntryType(val) + return nil + } else if stok == "HotArchiveBucketEntryType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid HotArchiveBucketEntryType.", stok)) } - return "" } +func (v HotArchiveBucketEntryType) GetU32() uint32 { return uint32(v) } +func (v *HotArchiveBucketEntryType) SetU32(n uint32) { *v = HotArchiveBucketEntryType(n) } +func (v *HotArchiveBucketEntryType) XdrPointer() interface{} { return v } +func (HotArchiveBucketEntryType) XdrTypeName() string { return "HotArchiveBucketEntryType" } +func (v HotArchiveBucketEntryType) XdrValue() interface{} { return v } +func (v *HotArchiveBucketEntryType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_XdrAnon_StellarValue_Ext = *XdrAnon_StellarValue_Ext - -func (v *XdrAnon_StellarValue_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_StellarValue_Ext) XdrTypeName() string { return "XdrAnon_StellarValue_Ext" } -func (v XdrAnon_StellarValue_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_StellarValue_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_StellarValue_Ext) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - XDR_StellarValueType(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) - switch u.V { - case STELLAR_VALUE_BASIC: - return - case STELLAR_VALUE_SIGNED: - x.Marshal(x.Sprintf("%slcValueSignature", name), XDR_LedgerCloseValueSignature(u.LcValueSignature())) - return - } - XdrPanic("invalid V (%v) in XdrAnon_StellarValue_Ext", u.V) -} -func XDR_XdrAnon_StellarValue_Ext(v *XdrAnon_StellarValue_Ext) *XdrAnon_StellarValue_Ext { return v } +type XdrType_HotArchiveBucketEntryType = *HotArchiveBucketEntryType -type _XdrVec_6_UpgradeType []UpgradeType +func XDR_HotArchiveBucketEntryType(v *HotArchiveBucketEntryType) *HotArchiveBucketEntryType { return v } -func (_XdrVec_6_UpgradeType) XdrBound() uint32 { - const bound uint32 = 6 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_6_UpgradeType) XdrCheckLen(length uint32) { - if length > uint32(6) { - XdrPanic("_XdrVec_6_UpgradeType length %d exceeds bound 6", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_6_UpgradeType length %d exceeds max int", length) - } -} -func (v _XdrVec_6_UpgradeType) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_6_UpgradeType) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(6); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) - } - nv := make([]UpgradeType, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_6_UpgradeType) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_UpgradeType(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } +var _XdrComments_HotArchiveBucketEntryType = map[int32]string{ + int32(HOT_ARCHIVE_METAENTRY): "Bucket metadata, should come first.", + int32(HOT_ARCHIVE_ARCHIVED): "Entry is Archived", + int32(HOT_ARCHIVE_LIVE): "Entry was previously HOT_ARCHIVE_ARCHIVED, or HOT_ARCHIVE_DELETED, but", + int32(HOT_ARCHIVE_DELETED): "has been added back to the live BucketList. Does not need to be persisted.", } -func (v *_XdrVec_6_UpgradeType) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 6} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_6_UpgradeType) XdrTypeName() string { return "UpgradeType<>" } -func (v *_XdrVec_6_UpgradeType) XdrPointer() interface{} { return (*[]UpgradeType)(v) } -func (v _XdrVec_6_UpgradeType) XdrValue() interface{} { return ([]UpgradeType)(v) } -func (v *_XdrVec_6_UpgradeType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_StellarValue = *StellarValue -func (v *StellarValue) XdrPointer() interface{} { return v } -func (StellarValue) XdrTypeName() string { return "StellarValue" } -func (v StellarValue) XdrValue() interface{} { return v } -func (v *StellarValue) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *StellarValue) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%stxSetHash", name), XDR_Hash(&v.TxSetHash)) - x.Marshal(x.Sprintf("%scloseTime", name), XDR_TimePoint(&v.CloseTime)) - x.Marshal(x.Sprintf("%supgrades", name), (*_XdrVec_6_UpgradeType)(&v.Upgrades)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_StellarValue_Ext(&v.Ext)) +func (e HotArchiveBucketEntryType) XdrEnumComments() map[int32]string { + return _XdrComments_HotArchiveBucketEntryType } -func XDR_StellarValue(v *StellarValue) *StellarValue { return v } -var _XdrNames_LedgerHeaderFlags = map[int32]string{ - int32(DISABLE_LIQUIDITY_POOL_TRADING_FLAG): "DISABLE_LIQUIDITY_POOL_TRADING_FLAG", - int32(DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG): "DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG", - int32(DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG): "DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG", +var _XdrNames_ColdArchiveBucketEntryType = map[int32]string{ + int32(COLD_ARCHIVE_METAENTRY): "COLD_ARCHIVE_METAENTRY", + int32(COLD_ARCHIVE_ARCHIVED_LEAF): "COLD_ARCHIVE_ARCHIVED_LEAF", + int32(COLD_ARCHIVE_DELETED_LEAF): "COLD_ARCHIVE_DELETED_LEAF", + int32(COLD_ARCHIVE_BOUNDARY_LEAF): "COLD_ARCHIVE_BOUNDARY_LEAF", + int32(COLD_ARCHIVE_HASH): "COLD_ARCHIVE_HASH", } -var _XdrValues_LedgerHeaderFlags = map[string]int32{ - "DISABLE_LIQUIDITY_POOL_TRADING_FLAG": int32(DISABLE_LIQUIDITY_POOL_TRADING_FLAG), - "DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG": int32(DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG), - "DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG": int32(DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG), +var _XdrValues_ColdArchiveBucketEntryType = map[string]int32{ + "COLD_ARCHIVE_METAENTRY": int32(COLD_ARCHIVE_METAENTRY), + "COLD_ARCHIVE_ARCHIVED_LEAF": int32(COLD_ARCHIVE_ARCHIVED_LEAF), + "COLD_ARCHIVE_DELETED_LEAF": int32(COLD_ARCHIVE_DELETED_LEAF), + "COLD_ARCHIVE_BOUNDARY_LEAF": int32(COLD_ARCHIVE_BOUNDARY_LEAF), + "COLD_ARCHIVE_HASH": int32(COLD_ARCHIVE_HASH), } -func (LedgerHeaderFlags) XdrEnumNames() map[int32]string { - return _XdrNames_LedgerHeaderFlags +func (ColdArchiveBucketEntryType) XdrEnumNames() map[int32]string { + return _XdrNames_ColdArchiveBucketEntryType } -func (v LedgerHeaderFlags) String() string { - if s, ok := _XdrNames_LedgerHeaderFlags[int32(v)]; ok { +func (v ColdArchiveBucketEntryType) String() string { + if s, ok := _XdrNames_ColdArchiveBucketEntryType[int32(v)]; ok { return s } - return fmt.Sprintf("LedgerHeaderFlags#%d", v) + return fmt.Sprintf("ColdArchiveBucketEntryType#%d", v) } -func (v *LedgerHeaderFlags) Scan(ss fmt.ScanState, _ rune) error { +func (v *ColdArchiveBucketEntryType) Scan(ss fmt.ScanState, _ rune) error { if tok, err := ss.Token(true, XdrSymChar); err != nil { return err } else { stok := string(tok) - if val, ok := _XdrValues_LedgerHeaderFlags[stok]; ok { - *v = LedgerHeaderFlags(val) + if val, ok := _XdrValues_ColdArchiveBucketEntryType[stok]; ok { + *v = ColdArchiveBucketEntryType(val) return nil - } else if stok == "LedgerHeaderFlags" { + } else if stok == "ColdArchiveBucketEntryType" { if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { return nil } } - return XdrError(fmt.Sprintf("%s is not a valid LedgerHeaderFlags.", stok)) + return XdrError(fmt.Sprintf("%s is not a valid ColdArchiveBucketEntryType.", stok)) } } -func (v LedgerHeaderFlags) GetU32() uint32 { return uint32(v) } -func (v *LedgerHeaderFlags) SetU32(n uint32) { *v = LedgerHeaderFlags(n) } -func (v *LedgerHeaderFlags) XdrPointer() interface{} { return v } -func (LedgerHeaderFlags) XdrTypeName() string { return "LedgerHeaderFlags" } -func (v LedgerHeaderFlags) XdrValue() interface{} { return v } -func (v *LedgerHeaderFlags) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v ColdArchiveBucketEntryType) GetU32() uint32 { return uint32(v) } +func (v *ColdArchiveBucketEntryType) SetU32(n uint32) { *v = ColdArchiveBucketEntryType(n) } +func (v *ColdArchiveBucketEntryType) XdrPointer() interface{} { return v } +func (ColdArchiveBucketEntryType) XdrTypeName() string { return "ColdArchiveBucketEntryType" } +func (v ColdArchiveBucketEntryType) XdrValue() interface{} { return v } +func (v *ColdArchiveBucketEntryType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_LedgerHeaderFlags = *LedgerHeaderFlags +type XdrType_ColdArchiveBucketEntryType = *ColdArchiveBucketEntryType -func XDR_LedgerHeaderFlags(v *LedgerHeaderFlags) *LedgerHeaderFlags { return v } -func (v *LedgerHeaderFlags) XdrInitialize() { - switch LedgerHeaderFlags(0) { - case DISABLE_LIQUIDITY_POOL_TRADING_FLAG, DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG, DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG: - default: - if *v == LedgerHeaderFlags(0) { - *v = DISABLE_LIQUIDITY_POOL_TRADING_FLAG - } - } +func XDR_ColdArchiveBucketEntryType(v *ColdArchiveBucketEntryType) *ColdArchiveBucketEntryType { + return v } -var _XdrTags_XdrAnon_LedgerHeaderExtensionV1_Ext = map[int32]bool{ +var _XdrComments_ColdArchiveBucketEntryType = map[int32]string{ + int32(COLD_ARCHIVE_METAENTRY): "Bucket metadata, should come first.", + int32(COLD_ARCHIVE_ARCHIVED_LEAF): "Full LedgerEntry that was archived during the epoch", + int32(COLD_ARCHIVE_DELETED_LEAF): "LedgerKey that was deleted during the epoch", + int32(COLD_ARCHIVE_BOUNDARY_LEAF): "Dummy leaf representing low/high bound", + int32(COLD_ARCHIVE_HASH): "Intermediary Merkle hash entry", +} + +func (e ColdArchiveBucketEntryType) XdrEnumComments() map[int32]string { + return _XdrComments_ColdArchiveBucketEntryType +} + +var _XdrTags_XdrAnon_BucketMetadata_Ext = map[int32]bool{ XdrToI32(0): true, + XdrToI32(1): true, } -func (_ XdrAnon_LedgerHeaderExtensionV1_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_LedgerHeaderExtensionV1_Ext +func (_ XdrAnon_BucketMetadata_Ext) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_BucketMetadata_Ext } -func (u XdrAnon_LedgerHeaderExtensionV1_Ext) XdrValid() bool { +func (u *XdrAnon_BucketMetadata_Ext) BucketListType() *BucketListType { switch u.V { - case 0: + case 1: + if v, ok := u._u.(*BucketListType); ok { + return v + } else { + var zero BucketListType + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_BucketMetadata_Ext.BucketListType accessed when V == %v", u.V) + return nil + } +} +func (u XdrAnon_BucketMetadata_Ext) XdrValid() bool { + switch u.V { + case 0, 1: return true } return false } -func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionTag() XdrNum32 { +func (u *XdrAnon_BucketMetadata_Ext) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionTagName() string { +func (u *XdrAnon_BucketMetadata_Ext) XdrUnionTagName() string { return "V" } -func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionBody() XdrType { +func (u *XdrAnon_BucketMetadata_Ext) XdrUnionBody() XdrType { switch u.V { case 0: return nil + case 1: + return XDR_BucketListType(u.BucketListType()) } return nil } -func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionBodyName() string { +func (u *XdrAnon_BucketMetadata_Ext) XdrUnionBodyName() string { switch u.V { case 0: return "" + case 1: + return "BucketListType" } return "" } -type XdrType_XdrAnon_LedgerHeaderExtensionV1_Ext = *XdrAnon_LedgerHeaderExtensionV1_Ext +type XdrType_XdrAnon_BucketMetadata_Ext = *XdrAnon_BucketMetadata_Ext -func (v *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_LedgerHeaderExtensionV1_Ext) XdrTypeName() string { - return "XdrAnon_LedgerHeaderExtensionV1_Ext" -} -func (v XdrAnon_LedgerHeaderExtensionV1_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_BucketMetadata_Ext) XdrPointer() interface{} { return v } +func (XdrAnon_BucketMetadata_Ext) XdrTypeName() string { return "XdrAnon_BucketMetadata_Ext" } +func (v XdrAnon_BucketMetadata_Ext) XdrValue() interface{} { return v } +func (v *XdrAnon_BucketMetadata_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_BucketMetadata_Ext) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } @@ -9564,1386 +9767,1286 @@ func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrRecurse(x XDR, name string) { switch u.V { case 0: return + case 1: + x.Marshal(x.Sprintf("%sbucketListType", name), XDR_BucketListType(u.BucketListType())) + return } - XdrPanic("invalid V (%v) in XdrAnon_LedgerHeaderExtensionV1_Ext", u.V) + XdrPanic("invalid V (%v) in XdrAnon_BucketMetadata_Ext", u.V) } -func XDR_XdrAnon_LedgerHeaderExtensionV1_Ext(v *XdrAnon_LedgerHeaderExtensionV1_Ext) *XdrAnon_LedgerHeaderExtensionV1_Ext { +func XDR_XdrAnon_BucketMetadata_Ext(v *XdrAnon_BucketMetadata_Ext) *XdrAnon_BucketMetadata_Ext { return v } -type XdrType_LedgerHeaderExtensionV1 = *LedgerHeaderExtensionV1 +type XdrType_BucketMetadata = *BucketMetadata -func (v *LedgerHeaderExtensionV1) XdrPointer() interface{} { return v } -func (LedgerHeaderExtensionV1) XdrTypeName() string { return "LedgerHeaderExtensionV1" } -func (v LedgerHeaderExtensionV1) XdrValue() interface{} { return v } -func (v *LedgerHeaderExtensionV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerHeaderExtensionV1) XdrRecurse(x XDR, name string) { +func (v *BucketMetadata) XdrPointer() interface{} { return v } +func (BucketMetadata) XdrTypeName() string { return "BucketMetadata" } +func (v BucketMetadata) XdrValue() interface{} { return v } +func (v *BucketMetadata) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *BucketMetadata) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sflags", name), XDR_Uint32(&v.Flags)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_LedgerHeaderExtensionV1_Ext(&v.Ext)) + x.Marshal(x.Sprintf("%sledgerVersion", name), XDR_Uint32(&v.LedgerVersion)) + x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_BucketMetadata_Ext(&v.Ext)) } -func XDR_LedgerHeaderExtensionV1(v *LedgerHeaderExtensionV1) *LedgerHeaderExtensionV1 { return v } +func XDR_BucketMetadata(v *BucketMetadata) *BucketMetadata { return v } -var _XdrTags_XdrAnon_LedgerHeader_Ext = map[int32]bool{ - XdrToI32(0): true, - XdrToI32(1): true, +var _XdrTags_BucketEntry = map[int32]bool{ + XdrToI32(LIVEENTRY): true, + XdrToI32(INITENTRY): true, + XdrToI32(DEADENTRY): true, + XdrToI32(METAENTRY): true, } -func (_ XdrAnon_LedgerHeader_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_LedgerHeader_Ext +func (_ BucketEntry) XdrValidTags() map[int32]bool { + return _XdrTags_BucketEntry } -func (u *XdrAnon_LedgerHeader_Ext) V1() *LedgerHeaderExtensionV1 { - switch u.V { - case 1: - if v, ok := u._u.(*LedgerHeaderExtensionV1); ok { - return v - } else { - var zero LedgerHeaderExtensionV1 +func (u *BucketEntry) LiveEntry() *LedgerEntry { + switch u.Type { + case LIVEENTRY, INITENTRY: + if v, ok := u._u.(*LedgerEntry); ok { + return v + } else { + var zero LedgerEntry u._u = &zero return &zero } default: - XdrPanic("XdrAnon_LedgerHeader_Ext.V1 accessed when V == %v", u.V) + XdrPanic("BucketEntry.LiveEntry accessed when Type == %v", u.Type) return nil } } -func (u XdrAnon_LedgerHeader_Ext) XdrValid() bool { - switch u.V { - case 0, 1: +func (u *BucketEntry) DeadEntry() *LedgerKey { + switch u.Type { + case DEADENTRY: + if v, ok := u._u.(*LedgerKey); ok { + return v + } else { + var zero LedgerKey + u._u = &zero + return &zero + } + default: + XdrPanic("BucketEntry.DeadEntry accessed when Type == %v", u.Type) + return nil + } +} +func (u *BucketEntry) MetaEntry() *BucketMetadata { + switch u.Type { + case METAENTRY: + if v, ok := u._u.(*BucketMetadata); ok { + return v + } else { + var zero BucketMetadata + u._u = &zero + return &zero + } + default: + XdrPanic("BucketEntry.MetaEntry accessed when Type == %v", u.Type) + return nil + } +} +func (u BucketEntry) XdrValid() bool { + switch u.Type { + case LIVEENTRY, INITENTRY, DEADENTRY, METAENTRY: return true } return false } -func (u *XdrAnon_LedgerHeader_Ext) XdrUnionTag() XdrNum32 { - return XDR_int32(&u.V) +func (u *BucketEntry) XdrUnionTag() XdrNum32 { + return XDR_BucketEntryType(&u.Type) } -func (u *XdrAnon_LedgerHeader_Ext) XdrUnionTagName() string { - return "V" +func (u *BucketEntry) XdrUnionTagName() string { + return "Type" } -func (u *XdrAnon_LedgerHeader_Ext) XdrUnionBody() XdrType { - switch u.V { - case 0: - return nil - case 1: - return XDR_LedgerHeaderExtensionV1(u.V1()) +func (u *BucketEntry) XdrUnionBody() XdrType { + switch u.Type { + case LIVEENTRY, INITENTRY: + return XDR_LedgerEntry(u.LiveEntry()) + case DEADENTRY: + return XDR_LedgerKey(u.DeadEntry()) + case METAENTRY: + return XDR_BucketMetadata(u.MetaEntry()) } return nil } -func (u *XdrAnon_LedgerHeader_Ext) XdrUnionBodyName() string { - switch u.V { - case 0: - return "" - case 1: - return "V1" +func (u *BucketEntry) XdrUnionBodyName() string { + switch u.Type { + case LIVEENTRY, INITENTRY: + return "LiveEntry" + case DEADENTRY: + return "DeadEntry" + case METAENTRY: + return "MetaEntry" } return "" } -type XdrType_XdrAnon_LedgerHeader_Ext = *XdrAnon_LedgerHeader_Ext +type XdrType_BucketEntry = *BucketEntry -func (v *XdrAnon_LedgerHeader_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_LedgerHeader_Ext) XdrTypeName() string { return "XdrAnon_LedgerHeader_Ext" } -func (v XdrAnon_LedgerHeader_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_LedgerHeader_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_LedgerHeader_Ext) XdrRecurse(x XDR, name string) { +func (v *BucketEntry) XdrPointer() interface{} { return v } +func (BucketEntry) XdrTypeName() string { return "BucketEntry" } +func (v BucketEntry) XdrValue() interface{} { return v } +func (v *BucketEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *BucketEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) - switch u.V { - case 0: + XDR_BucketEntryType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case LIVEENTRY, INITENTRY: + x.Marshal(x.Sprintf("%sliveEntry", name), XDR_LedgerEntry(u.LiveEntry())) return - case 1: - x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerHeaderExtensionV1(u.V1())) + case DEADENTRY: + x.Marshal(x.Sprintf("%sdeadEntry", name), XDR_LedgerKey(u.DeadEntry())) + return + case METAENTRY: + x.Marshal(x.Sprintf("%smetaEntry", name), XDR_BucketMetadata(u.MetaEntry())) return } - XdrPanic("invalid V (%v) in XdrAnon_LedgerHeader_Ext", u.V) + XdrPanic("invalid Type (%v) in BucketEntry", u.Type) } -func XDR_XdrAnon_LedgerHeader_Ext(v *XdrAnon_LedgerHeader_Ext) *XdrAnon_LedgerHeader_Ext { return v } +func XDR_BucketEntry(v *BucketEntry) *BucketEntry { return v } -type _XdrArray_4_Hash [4]Hash +var _XdrTags_HotArchiveBucketEntry = map[int32]bool{ + XdrToI32(HOT_ARCHIVE_ARCHIVED): true, + XdrToI32(HOT_ARCHIVE_LIVE): true, + XdrToI32(HOT_ARCHIVE_DELETED): true, + XdrToI32(HOT_ARCHIVE_METAENTRY): true, +} -func (_XdrArray_4_Hash) XdrArraySize() uint32 { - const bound uint32 = 4 // Force error if not const or doesn't fit - return bound +func (_ HotArchiveBucketEntry) XdrValidTags() map[int32]bool { + return _XdrTags_HotArchiveBucketEntry } -func (v *_XdrArray_4_Hash) XdrRecurse(x XDR, name string) { - for i := 0; i < len(*v); i++ { - XDR_Hash(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) +func (u *HotArchiveBucketEntry) ArchivedEntry() *LedgerEntry { + switch u.Type { + case HOT_ARCHIVE_ARCHIVED: + if v, ok := u._u.(*LedgerEntry); ok { + return v + } else { + var zero LedgerEntry + u._u = &zero + return &zero + } + default: + XdrPanic("HotArchiveBucketEntry.ArchivedEntry accessed when Type == %v", u.Type) + return nil } } -func (v *_XdrArray_4_Hash) XdrPointer() interface{} { return (*[4]Hash)(v) } -func (_XdrArray_4_Hash) XdrTypeName() string { return "Hash[]" } -func (v *_XdrArray_4_Hash) XdrValue() interface{} { return v[:] } -func (v *_XdrArray_4_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_LedgerHeader = *LedgerHeader - -func (v *LedgerHeader) XdrPointer() interface{} { return v } -func (LedgerHeader) XdrTypeName() string { return "LedgerHeader" } -func (v LedgerHeader) XdrValue() interface{} { return v } -func (v *LedgerHeader) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerHeader) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *HotArchiveBucketEntry) Key() *LedgerKey { + switch u.Type { + case HOT_ARCHIVE_LIVE, HOT_ARCHIVE_DELETED: + if v, ok := u._u.(*LedgerKey); ok { + return v + } else { + var zero LedgerKey + u._u = &zero + return &zero + } + default: + XdrPanic("HotArchiveBucketEntry.Key accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%sledgerVersion", name), XDR_Uint32(&v.LedgerVersion)) - x.Marshal(x.Sprintf("%spreviousLedgerHash", name), XDR_Hash(&v.PreviousLedgerHash)) - x.Marshal(x.Sprintf("%sscpValue", name), XDR_StellarValue(&v.ScpValue)) - x.Marshal(x.Sprintf("%stxSetResultHash", name), XDR_Hash(&v.TxSetResultHash)) - x.Marshal(x.Sprintf("%sbucketListHash", name), XDR_Hash(&v.BucketListHash)) - x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) - x.Marshal(x.Sprintf("%stotalCoins", name), XDR_Int64(&v.TotalCoins)) - x.Marshal(x.Sprintf("%sfeePool", name), XDR_Int64(&v.FeePool)) - x.Marshal(x.Sprintf("%sinflationSeq", name), XDR_Uint32(&v.InflationSeq)) - x.Marshal(x.Sprintf("%sidPool", name), XDR_Uint64(&v.IdPool)) - x.Marshal(x.Sprintf("%sbaseFee", name), XDR_Uint32(&v.BaseFee)) - x.Marshal(x.Sprintf("%sbaseReserve", name), XDR_Uint32(&v.BaseReserve)) - x.Marshal(x.Sprintf("%smaxTxSetSize", name), XDR_Uint32(&v.MaxTxSetSize)) - x.Marshal(x.Sprintf("%sskipList", name), (*_XdrArray_4_Hash)(&v.SkipList)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_LedgerHeader_Ext(&v.Ext)) } -func XDR_LedgerHeader(v *LedgerHeader) *LedgerHeader { return v } - -var _XdrNames_LedgerUpgradeType = map[int32]string{ - int32(LEDGER_UPGRADE_VERSION): "LEDGER_UPGRADE_VERSION", - int32(LEDGER_UPGRADE_BASE_FEE): "LEDGER_UPGRADE_BASE_FEE", - int32(LEDGER_UPGRADE_MAX_TX_SET_SIZE): "LEDGER_UPGRADE_MAX_TX_SET_SIZE", - int32(LEDGER_UPGRADE_BASE_RESERVE): "LEDGER_UPGRADE_BASE_RESERVE", - int32(LEDGER_UPGRADE_FLAGS): "LEDGER_UPGRADE_FLAGS", - int32(LEDGER_UPGRADE_CONFIG): "LEDGER_UPGRADE_CONFIG", - int32(LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE): "LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE", +func (u *HotArchiveBucketEntry) MetaEntry() *BucketMetadata { + switch u.Type { + case HOT_ARCHIVE_METAENTRY: + if v, ok := u._u.(*BucketMetadata); ok { + return v + } else { + var zero BucketMetadata + u._u = &zero + return &zero + } + default: + XdrPanic("HotArchiveBucketEntry.MetaEntry accessed when Type == %v", u.Type) + return nil + } } -var _XdrValues_LedgerUpgradeType = map[string]int32{ - "LEDGER_UPGRADE_VERSION": int32(LEDGER_UPGRADE_VERSION), - "LEDGER_UPGRADE_BASE_FEE": int32(LEDGER_UPGRADE_BASE_FEE), - "LEDGER_UPGRADE_MAX_TX_SET_SIZE": int32(LEDGER_UPGRADE_MAX_TX_SET_SIZE), - "LEDGER_UPGRADE_BASE_RESERVE": int32(LEDGER_UPGRADE_BASE_RESERVE), - "LEDGER_UPGRADE_FLAGS": int32(LEDGER_UPGRADE_FLAGS), - "LEDGER_UPGRADE_CONFIG": int32(LEDGER_UPGRADE_CONFIG), - "LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE": int32(LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE), +func (u HotArchiveBucketEntry) XdrValid() bool { + switch u.Type { + case HOT_ARCHIVE_ARCHIVED, HOT_ARCHIVE_LIVE, HOT_ARCHIVE_DELETED, HOT_ARCHIVE_METAENTRY: + return true + } + return false } - -func (LedgerUpgradeType) XdrEnumNames() map[int32]string { - return _XdrNames_LedgerUpgradeType +func (u *HotArchiveBucketEntry) XdrUnionTag() XdrNum32 { + return XDR_HotArchiveBucketEntryType(&u.Type) } -func (v LedgerUpgradeType) String() string { - if s, ok := _XdrNames_LedgerUpgradeType[int32(v)]; ok { - return s - } - return fmt.Sprintf("LedgerUpgradeType#%d", v) +func (u *HotArchiveBucketEntry) XdrUnionTagName() string { + return "Type" } -func (v *LedgerUpgradeType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_LedgerUpgradeType[stok]; ok { - *v = LedgerUpgradeType(val) - return nil - } else if stok == "LedgerUpgradeType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid LedgerUpgradeType.", stok)) +func (u *HotArchiveBucketEntry) XdrUnionBody() XdrType { + switch u.Type { + case HOT_ARCHIVE_ARCHIVED: + return XDR_LedgerEntry(u.ArchivedEntry()) + case HOT_ARCHIVE_LIVE, HOT_ARCHIVE_DELETED: + return XDR_LedgerKey(u.Key()) + case HOT_ARCHIVE_METAENTRY: + return XDR_BucketMetadata(u.MetaEntry()) } + return nil } -func (v LedgerUpgradeType) GetU32() uint32 { return uint32(v) } -func (v *LedgerUpgradeType) SetU32(n uint32) { *v = LedgerUpgradeType(n) } -func (v *LedgerUpgradeType) XdrPointer() interface{} { return v } -func (LedgerUpgradeType) XdrTypeName() string { return "LedgerUpgradeType" } -func (v LedgerUpgradeType) XdrValue() interface{} { return v } -func (v *LedgerUpgradeType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_LedgerUpgradeType = *LedgerUpgradeType - -func XDR_LedgerUpgradeType(v *LedgerUpgradeType) *LedgerUpgradeType { return v } -func (v *LedgerUpgradeType) XdrInitialize() { - switch LedgerUpgradeType(0) { - case LEDGER_UPGRADE_VERSION, LEDGER_UPGRADE_BASE_FEE, LEDGER_UPGRADE_MAX_TX_SET_SIZE, LEDGER_UPGRADE_BASE_RESERVE, LEDGER_UPGRADE_FLAGS, LEDGER_UPGRADE_CONFIG, LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: - default: - if *v == LedgerUpgradeType(0) { - *v = LEDGER_UPGRADE_VERSION - } +func (u *HotArchiveBucketEntry) XdrUnionBodyName() string { + switch u.Type { + case HOT_ARCHIVE_ARCHIVED: + return "ArchivedEntry" + case HOT_ARCHIVE_LIVE, HOT_ARCHIVE_DELETED: + return "Key" + case HOT_ARCHIVE_METAENTRY: + return "MetaEntry" } + return "" } -type XdrType_ConfigUpgradeSetKey = *ConfigUpgradeSetKey +type XdrType_HotArchiveBucketEntry = *HotArchiveBucketEntry -func (v *ConfigUpgradeSetKey) XdrPointer() interface{} { return v } -func (ConfigUpgradeSetKey) XdrTypeName() string { return "ConfigUpgradeSetKey" } -func (v ConfigUpgradeSetKey) XdrValue() interface{} { return v } -func (v *ConfigUpgradeSetKey) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ConfigUpgradeSetKey) XdrRecurse(x XDR, name string) { +func (v *HotArchiveBucketEntry) XdrPointer() interface{} { return v } +func (HotArchiveBucketEntry) XdrTypeName() string { return "HotArchiveBucketEntry" } +func (v HotArchiveBucketEntry) XdrValue() interface{} { return v } +func (v *HotArchiveBucketEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *HotArchiveBucketEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%scontractID", name), XDR_Hash(&v.ContractID)) - x.Marshal(x.Sprintf("%scontentHash", name), XDR_Hash(&v.ContentHash)) -} -func XDR_ConfigUpgradeSetKey(v *ConfigUpgradeSetKey) *ConfigUpgradeSetKey { return v } + XDR_HotArchiveBucketEntryType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case HOT_ARCHIVE_ARCHIVED: + x.Marshal(x.Sprintf("%sarchivedEntry", name), XDR_LedgerEntry(u.ArchivedEntry())) + return + case HOT_ARCHIVE_LIVE, HOT_ARCHIVE_DELETED: + x.Marshal(x.Sprintf("%skey", name), XDR_LedgerKey(u.Key())) + return + case HOT_ARCHIVE_METAENTRY: + x.Marshal(x.Sprintf("%smetaEntry", name), XDR_BucketMetadata(u.MetaEntry())) + return + } + XdrPanic("invalid Type (%v) in HotArchiveBucketEntry", u.Type) +} +func XDR_HotArchiveBucketEntry(v *HotArchiveBucketEntry) *HotArchiveBucketEntry { return v } -var _XdrTags_LedgerUpgrade = map[int32]bool{ - XdrToI32(LEDGER_UPGRADE_VERSION): true, - XdrToI32(LEDGER_UPGRADE_BASE_FEE): true, - XdrToI32(LEDGER_UPGRADE_MAX_TX_SET_SIZE): true, - XdrToI32(LEDGER_UPGRADE_BASE_RESERVE): true, - XdrToI32(LEDGER_UPGRADE_FLAGS): true, - XdrToI32(LEDGER_UPGRADE_CONFIG): true, - XdrToI32(LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE): true, +type XdrType_ColdArchiveArchivedLeaf = *ColdArchiveArchivedLeaf + +func (v *ColdArchiveArchivedLeaf) XdrPointer() interface{} { return v } +func (ColdArchiveArchivedLeaf) XdrTypeName() string { return "ColdArchiveArchivedLeaf" } +func (v ColdArchiveArchivedLeaf) XdrValue() interface{} { return v } +func (v *ColdArchiveArchivedLeaf) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ColdArchiveArchivedLeaf) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sindex", name), XDR_Uint32(&v.Index)) + x.Marshal(x.Sprintf("%sarchivedEntry", name), XDR_LedgerEntry(&v.ArchivedEntry)) } +func XDR_ColdArchiveArchivedLeaf(v *ColdArchiveArchivedLeaf) *ColdArchiveArchivedLeaf { return v } -func (_ LedgerUpgrade) XdrValidTags() map[int32]bool { - return _XdrTags_LedgerUpgrade +type XdrType_ColdArchiveDeletedLeaf = *ColdArchiveDeletedLeaf + +func (v *ColdArchiveDeletedLeaf) XdrPointer() interface{} { return v } +func (ColdArchiveDeletedLeaf) XdrTypeName() string { return "ColdArchiveDeletedLeaf" } +func (v ColdArchiveDeletedLeaf) XdrValue() interface{} { return v } +func (v *ColdArchiveDeletedLeaf) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ColdArchiveDeletedLeaf) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sindex", name), XDR_Uint32(&v.Index)) + x.Marshal(x.Sprintf("%sdeletedKey", name), XDR_LedgerKey(&v.DeletedKey)) } +func XDR_ColdArchiveDeletedLeaf(v *ColdArchiveDeletedLeaf) *ColdArchiveDeletedLeaf { return v } -// update ledgerVersion -func (u *LedgerUpgrade) NewLedgerVersion() *Uint32 { - switch u.Type { - case LEDGER_UPGRADE_VERSION: - if v, ok := u._u.(*Uint32); ok { - return v - } else { - var zero Uint32 - u._u = &zero - return &zero - } - default: - XdrPanic("LedgerUpgrade.NewLedgerVersion accessed when Type == %v", u.Type) - return nil +type XdrType_ColdArchiveBoundaryLeaf = *ColdArchiveBoundaryLeaf + +func (v *ColdArchiveBoundaryLeaf) XdrPointer() interface{} { return v } +func (ColdArchiveBoundaryLeaf) XdrTypeName() string { return "ColdArchiveBoundaryLeaf" } +func (v ColdArchiveBoundaryLeaf) XdrValue() interface{} { return v } +func (v *ColdArchiveBoundaryLeaf) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ColdArchiveBoundaryLeaf) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%sindex", name), XDR_Uint32(&v.Index)) + x.Marshal(x.Sprintf("%sisLowerBound", name), XDR_bool(&v.IsLowerBound)) } +func XDR_ColdArchiveBoundaryLeaf(v *ColdArchiveBoundaryLeaf) *ColdArchiveBoundaryLeaf { return v } -// update baseFee -func (u *LedgerUpgrade) NewBaseFee() *Uint32 { - switch u.Type { - case LEDGER_UPGRADE_BASE_FEE: - if v, ok := u._u.(*Uint32); ok { - return v - } else { - var zero Uint32 - u._u = &zero - return &zero - } - default: - XdrPanic("LedgerUpgrade.NewBaseFee accessed when Type == %v", u.Type) - return nil +type XdrType_ColdArchiveHashEntry = *ColdArchiveHashEntry + +func (v *ColdArchiveHashEntry) XdrPointer() interface{} { return v } +func (ColdArchiveHashEntry) XdrTypeName() string { return "ColdArchiveHashEntry" } +func (v ColdArchiveHashEntry) XdrValue() interface{} { return v } +func (v *ColdArchiveHashEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ColdArchiveHashEntry) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%sindex", name), XDR_Uint32(&v.Index)) + x.Marshal(x.Sprintf("%slevel", name), XDR_Uint32(&v.Level)) + x.Marshal(x.Sprintf("%shash", name), XDR_Hash(&v.Hash)) } +func XDR_ColdArchiveHashEntry(v *ColdArchiveHashEntry) *ColdArchiveHashEntry { return v } -// update maxTxSetSize -func (u *LedgerUpgrade) NewMaxTxSetSize() *Uint32 { +var _XdrTags_ColdArchiveBucketEntry = map[int32]bool{ + XdrToI32(COLD_ARCHIVE_METAENTRY): true, + XdrToI32(COLD_ARCHIVE_ARCHIVED_LEAF): true, + XdrToI32(COLD_ARCHIVE_DELETED_LEAF): true, + XdrToI32(COLD_ARCHIVE_BOUNDARY_LEAF): true, + XdrToI32(COLD_ARCHIVE_HASH): true, +} + +func (_ ColdArchiveBucketEntry) XdrValidTags() map[int32]bool { + return _XdrTags_ColdArchiveBucketEntry +} +func (u *ColdArchiveBucketEntry) MetaEntry() *BucketMetadata { switch u.Type { - case LEDGER_UPGRADE_MAX_TX_SET_SIZE: - if v, ok := u._u.(*Uint32); ok { + case COLD_ARCHIVE_METAENTRY: + if v, ok := u._u.(*BucketMetadata); ok { return v } else { - var zero Uint32 + var zero BucketMetadata u._u = &zero return &zero } default: - XdrPanic("LedgerUpgrade.NewMaxTxSetSize accessed when Type == %v", u.Type) + XdrPanic("ColdArchiveBucketEntry.MetaEntry accessed when Type == %v", u.Type) return nil } } - -// update baseReserve -func (u *LedgerUpgrade) NewBaseReserve() *Uint32 { +func (u *ColdArchiveBucketEntry) ArchivedLeaf() *ColdArchiveArchivedLeaf { switch u.Type { - case LEDGER_UPGRADE_BASE_RESERVE: - if v, ok := u._u.(*Uint32); ok { + case COLD_ARCHIVE_ARCHIVED_LEAF: + if v, ok := u._u.(*ColdArchiveArchivedLeaf); ok { return v } else { - var zero Uint32 + var zero ColdArchiveArchivedLeaf u._u = &zero return &zero } default: - XdrPanic("LedgerUpgrade.NewBaseReserve accessed when Type == %v", u.Type) + XdrPanic("ColdArchiveBucketEntry.ArchivedLeaf accessed when Type == %v", u.Type) return nil } } - -// update flags -func (u *LedgerUpgrade) NewFlags() *Uint32 { +func (u *ColdArchiveBucketEntry) DeletedLeaf() *ColdArchiveDeletedLeaf { switch u.Type { - case LEDGER_UPGRADE_FLAGS: - if v, ok := u._u.(*Uint32); ok { + case COLD_ARCHIVE_DELETED_LEAF: + if v, ok := u._u.(*ColdArchiveDeletedLeaf); ok { return v } else { - var zero Uint32 + var zero ColdArchiveDeletedLeaf u._u = &zero return &zero } default: - XdrPanic("LedgerUpgrade.NewFlags accessed when Type == %v", u.Type) + XdrPanic("ColdArchiveBucketEntry.DeletedLeaf accessed when Type == %v", u.Type) return nil } } - -// Update arbitrary `ConfigSetting` entries identified by the key. -func (u *LedgerUpgrade) NewConfig() *ConfigUpgradeSetKey { +func (u *ColdArchiveBucketEntry) BoundaryLeaf() *ColdArchiveBoundaryLeaf { switch u.Type { - case LEDGER_UPGRADE_CONFIG: - if v, ok := u._u.(*ConfigUpgradeSetKey); ok { + case COLD_ARCHIVE_BOUNDARY_LEAF: + if v, ok := u._u.(*ColdArchiveBoundaryLeaf); ok { return v } else { - var zero ConfigUpgradeSetKey + var zero ColdArchiveBoundaryLeaf u._u = &zero return &zero } default: - XdrPanic("LedgerUpgrade.NewConfig accessed when Type == %v", u.Type) + XdrPanic("ColdArchiveBucketEntry.BoundaryLeaf accessed when Type == %v", u.Type) return nil } } - -// Update ConfigSettingContractExecutionLanesV0.ledgerMaxTxCount without -// using `LEDGER_UPGRADE_CONFIG`. -func (u *LedgerUpgrade) NewMaxSorobanTxSetSize() *Uint32 { +func (u *ColdArchiveBucketEntry) HashEntry() *ColdArchiveHashEntry { switch u.Type { - case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: - if v, ok := u._u.(*Uint32); ok { + case COLD_ARCHIVE_HASH: + if v, ok := u._u.(*ColdArchiveHashEntry); ok { return v } else { - var zero Uint32 + var zero ColdArchiveHashEntry u._u = &zero return &zero } default: - XdrPanic("LedgerUpgrade.NewMaxSorobanTxSetSize accessed when Type == %v", u.Type) + XdrPanic("ColdArchiveBucketEntry.HashEntry accessed when Type == %v", u.Type) return nil } } -func (u LedgerUpgrade) XdrValid() bool { +func (u ColdArchiveBucketEntry) XdrValid() bool { switch u.Type { - case LEDGER_UPGRADE_VERSION, LEDGER_UPGRADE_BASE_FEE, LEDGER_UPGRADE_MAX_TX_SET_SIZE, LEDGER_UPGRADE_BASE_RESERVE, LEDGER_UPGRADE_FLAGS, LEDGER_UPGRADE_CONFIG, LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + case COLD_ARCHIVE_METAENTRY, COLD_ARCHIVE_ARCHIVED_LEAF, COLD_ARCHIVE_DELETED_LEAF, COLD_ARCHIVE_BOUNDARY_LEAF, COLD_ARCHIVE_HASH: return true } return false } -func (u *LedgerUpgrade) XdrUnionTag() XdrNum32 { - return XDR_LedgerUpgradeType(&u.Type) +func (u *ColdArchiveBucketEntry) XdrUnionTag() XdrNum32 { + return XDR_ColdArchiveBucketEntryType(&u.Type) } -func (u *LedgerUpgrade) XdrUnionTagName() string { +func (u *ColdArchiveBucketEntry) XdrUnionTagName() string { return "Type" } -func (u *LedgerUpgrade) XdrUnionBody() XdrType { +func (u *ColdArchiveBucketEntry) XdrUnionBody() XdrType { switch u.Type { - case LEDGER_UPGRADE_VERSION: - return XDR_Uint32(u.NewLedgerVersion()) - case LEDGER_UPGRADE_BASE_FEE: - return XDR_Uint32(u.NewBaseFee()) - case LEDGER_UPGRADE_MAX_TX_SET_SIZE: - return XDR_Uint32(u.NewMaxTxSetSize()) - case LEDGER_UPGRADE_BASE_RESERVE: - return XDR_Uint32(u.NewBaseReserve()) - case LEDGER_UPGRADE_FLAGS: - return XDR_Uint32(u.NewFlags()) - case LEDGER_UPGRADE_CONFIG: - return XDR_ConfigUpgradeSetKey(u.NewConfig()) - case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: - return XDR_Uint32(u.NewMaxSorobanTxSetSize()) + case COLD_ARCHIVE_METAENTRY: + return XDR_BucketMetadata(u.MetaEntry()) + case COLD_ARCHIVE_ARCHIVED_LEAF: + return XDR_ColdArchiveArchivedLeaf(u.ArchivedLeaf()) + case COLD_ARCHIVE_DELETED_LEAF: + return XDR_ColdArchiveDeletedLeaf(u.DeletedLeaf()) + case COLD_ARCHIVE_BOUNDARY_LEAF: + return XDR_ColdArchiveBoundaryLeaf(u.BoundaryLeaf()) + case COLD_ARCHIVE_HASH: + return XDR_ColdArchiveHashEntry(u.HashEntry()) } return nil } -func (u *LedgerUpgrade) XdrUnionBodyName() string { +func (u *ColdArchiveBucketEntry) XdrUnionBodyName() string { switch u.Type { - case LEDGER_UPGRADE_VERSION: - return "NewLedgerVersion" - case LEDGER_UPGRADE_BASE_FEE: - return "NewBaseFee" - case LEDGER_UPGRADE_MAX_TX_SET_SIZE: - return "NewMaxTxSetSize" - case LEDGER_UPGRADE_BASE_RESERVE: - return "NewBaseReserve" - case LEDGER_UPGRADE_FLAGS: - return "NewFlags" - case LEDGER_UPGRADE_CONFIG: - return "NewConfig" - case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: - return "NewMaxSorobanTxSetSize" + case COLD_ARCHIVE_METAENTRY: + return "MetaEntry" + case COLD_ARCHIVE_ARCHIVED_LEAF: + return "ArchivedLeaf" + case COLD_ARCHIVE_DELETED_LEAF: + return "DeletedLeaf" + case COLD_ARCHIVE_BOUNDARY_LEAF: + return "BoundaryLeaf" + case COLD_ARCHIVE_HASH: + return "HashEntry" } return "" } -type XdrType_LedgerUpgrade = *LedgerUpgrade +type XdrType_ColdArchiveBucketEntry = *ColdArchiveBucketEntry -func (v *LedgerUpgrade) XdrPointer() interface{} { return v } -func (LedgerUpgrade) XdrTypeName() string { return "LedgerUpgrade" } -func (v LedgerUpgrade) XdrValue() interface{} { return v } -func (v *LedgerUpgrade) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *LedgerUpgrade) XdrRecurse(x XDR, name string) { +func (v *ColdArchiveBucketEntry) XdrPointer() interface{} { return v } +func (ColdArchiveBucketEntry) XdrTypeName() string { return "ColdArchiveBucketEntry" } +func (v ColdArchiveBucketEntry) XdrValue() interface{} { return v } +func (v *ColdArchiveBucketEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *ColdArchiveBucketEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_LedgerUpgradeType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + XDR_ColdArchiveBucketEntryType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case LEDGER_UPGRADE_VERSION: - x.Marshal(x.Sprintf("%snewLedgerVersion", name), XDR_Uint32(u.NewLedgerVersion())) - return - case LEDGER_UPGRADE_BASE_FEE: - x.Marshal(x.Sprintf("%snewBaseFee", name), XDR_Uint32(u.NewBaseFee())) - return - case LEDGER_UPGRADE_MAX_TX_SET_SIZE: - x.Marshal(x.Sprintf("%snewMaxTxSetSize", name), XDR_Uint32(u.NewMaxTxSetSize())) + case COLD_ARCHIVE_METAENTRY: + x.Marshal(x.Sprintf("%smetaEntry", name), XDR_BucketMetadata(u.MetaEntry())) return - case LEDGER_UPGRADE_BASE_RESERVE: - x.Marshal(x.Sprintf("%snewBaseReserve", name), XDR_Uint32(u.NewBaseReserve())) + case COLD_ARCHIVE_ARCHIVED_LEAF: + x.Marshal(x.Sprintf("%sarchivedLeaf", name), XDR_ColdArchiveArchivedLeaf(u.ArchivedLeaf())) return - case LEDGER_UPGRADE_FLAGS: - x.Marshal(x.Sprintf("%snewFlags", name), XDR_Uint32(u.NewFlags())) + case COLD_ARCHIVE_DELETED_LEAF: + x.Marshal(x.Sprintf("%sdeletedLeaf", name), XDR_ColdArchiveDeletedLeaf(u.DeletedLeaf())) return - case LEDGER_UPGRADE_CONFIG: - x.Marshal(x.Sprintf("%snewConfig", name), XDR_ConfigUpgradeSetKey(u.NewConfig())) + case COLD_ARCHIVE_BOUNDARY_LEAF: + x.Marshal(x.Sprintf("%sboundaryLeaf", name), XDR_ColdArchiveBoundaryLeaf(u.BoundaryLeaf())) return - case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: - x.Marshal(x.Sprintf("%snewMaxSorobanTxSetSize", name), XDR_Uint32(u.NewMaxSorobanTxSetSize())) + case COLD_ARCHIVE_HASH: + x.Marshal(x.Sprintf("%shashEntry", name), XDR_ColdArchiveHashEntry(u.HashEntry())) return } - XdrPanic("invalid Type (%v) in LedgerUpgrade", u.Type) + XdrPanic("invalid Type (%v) in ColdArchiveBucketEntry", u.Type) } -func (v *LedgerUpgrade) XdrInitialize() { - var zero LedgerUpgradeType - switch zero { - case LEDGER_UPGRADE_VERSION, LEDGER_UPGRADE_BASE_FEE, LEDGER_UPGRADE_MAX_TX_SET_SIZE, LEDGER_UPGRADE_BASE_RESERVE, LEDGER_UPGRADE_FLAGS, LEDGER_UPGRADE_CONFIG, LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: - default: - if v.Type == zero { - v.Type = LEDGER_UPGRADE_VERSION - } - } +func XDR_ColdArchiveBucketEntry(v *ColdArchiveBucketEntry) *ColdArchiveBucketEntry { return v } + +type XdrType_UpgradeType struct { + XdrVecOpaque } -func XDR_LedgerUpgrade(v *LedgerUpgrade) *LedgerUpgrade { return v } -type _XdrVec_unbounded_ConfigSettingEntry []ConfigSettingEntry +func XDR_UpgradeType(v *UpgradeType) XdrType_UpgradeType { + return XdrType_UpgradeType{XdrVecOpaque{v, 128}} +} +func (XdrType_UpgradeType) XdrTypeName() string { return "UpgradeType" } +func (v XdrType_UpgradeType) XdrUnwrap() XdrType { return v.XdrVecOpaque } -func (_XdrVec_unbounded_ConfigSettingEntry) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound +var _XdrNames_StellarValueType = map[int32]string{ + int32(STELLAR_VALUE_BASIC): "STELLAR_VALUE_BASIC", + int32(STELLAR_VALUE_SIGNED): "STELLAR_VALUE_SIGNED", } -func (_XdrVec_unbounded_ConfigSettingEntry) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_ConfigSettingEntry length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_ConfigSettingEntry length %d exceeds max int", length) - } +var _XdrValues_StellarValueType = map[string]int32{ + "STELLAR_VALUE_BASIC": int32(STELLAR_VALUE_BASIC), + "STELLAR_VALUE_SIGNED": int32(STELLAR_VALUE_SIGNED), } -func (v _XdrVec_unbounded_ConfigSettingEntry) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_ConfigSettingEntry) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) + +func (StellarValueType) XdrEnumNames() map[int32]string { + return _XdrNames_StellarValueType +} +func (v StellarValueType) String() string { + if s, ok := _XdrNames_StellarValueType[int32(v)]; ok { + return s } - nv := make([]ConfigSettingEntry, int(length), newcap) - copy(nv, *v) - *v = nv + return fmt.Sprintf("StellarValueType#%d", v) } -func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) +func (v *StellarValueType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_StellarValueType[stok]; ok { + *v = StellarValueType(val) + return nil + } else if stok == "StellarValueType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - XDR_ConfigSettingEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] + return XdrError(fmt.Sprintf("%s is not a valid StellarValueType.", stok)) } } -func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_unbounded_ConfigSettingEntry) XdrTypeName() string { return "ConfigSettingEntry<>" } -func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrPointer() interface{} { - return (*[]ConfigSettingEntry)(v) -} -func (v _XdrVec_unbounded_ConfigSettingEntry) XdrValue() interface{} { - return ([]ConfigSettingEntry)(v) -} -func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v StellarValueType) GetU32() uint32 { return uint32(v) } +func (v *StellarValueType) SetU32(n uint32) { *v = StellarValueType(n) } +func (v *StellarValueType) XdrPointer() interface{} { return v } +func (StellarValueType) XdrTypeName() string { return "StellarValueType" } +func (v StellarValueType) XdrValue() interface{} { return v } +func (v *StellarValueType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_ConfigUpgradeSet = *ConfigUpgradeSet +type XdrType_StellarValueType = *StellarValueType -func (v *ConfigUpgradeSet) XdrPointer() interface{} { return v } -func (ConfigUpgradeSet) XdrTypeName() string { return "ConfigUpgradeSet" } -func (v ConfigUpgradeSet) XdrValue() interface{} { return v } -func (v *ConfigUpgradeSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ConfigUpgradeSet) XdrRecurse(x XDR, name string) { +func XDR_StellarValueType(v *StellarValueType) *StellarValueType { return v } + +type XdrType_LedgerCloseValueSignature = *LedgerCloseValueSignature + +func (v *LedgerCloseValueSignature) XdrPointer() interface{} { return v } +func (LedgerCloseValueSignature) XdrTypeName() string { return "LedgerCloseValueSignature" } +func (v LedgerCloseValueSignature) XdrValue() interface{} { return v } +func (v *LedgerCloseValueSignature) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerCloseValueSignature) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%supdatedEntry", name), (*_XdrVec_unbounded_ConfigSettingEntry)(&v.UpdatedEntry)) + x.Marshal(x.Sprintf("%snodeID", name), XDR_NodeID(&v.NodeID)) + x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) } -func XDR_ConfigUpgradeSet(v *ConfigUpgradeSet) *ConfigUpgradeSet { return v } +func XDR_LedgerCloseValueSignature(v *LedgerCloseValueSignature) *LedgerCloseValueSignature { return v } -var _XdrNames_BucketEntryType = map[int32]string{ - int32(METAENTRY): "METAENTRY", - int32(LIVEENTRY): "LIVEENTRY", - int32(DEADENTRY): "DEADENTRY", - int32(INITENTRY): "INITENTRY", -} -var _XdrValues_BucketEntryType = map[string]int32{ - "METAENTRY": int32(METAENTRY), - "LIVEENTRY": int32(LIVEENTRY), - "DEADENTRY": int32(DEADENTRY), - "INITENTRY": int32(INITENTRY), +var _XdrTags_XdrAnon_StellarValue_Ext = map[int32]bool{ + XdrToI32(STELLAR_VALUE_BASIC): true, + XdrToI32(STELLAR_VALUE_SIGNED): true, } -func (BucketEntryType) XdrEnumNames() map[int32]string { - return _XdrNames_BucketEntryType -} -func (v BucketEntryType) String() string { - if s, ok := _XdrNames_BucketEntryType[int32(v)]; ok { - return s - } - return fmt.Sprintf("BucketEntryType#%d", v) +func (_ XdrAnon_StellarValue_Ext) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_StellarValue_Ext } -func (v *BucketEntryType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_BucketEntryType[stok]; ok { - *v = BucketEntryType(val) - return nil - } else if stok == "BucketEntryType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } +func (u *XdrAnon_StellarValue_Ext) LcValueSignature() *LedgerCloseValueSignature { + switch u.V { + case STELLAR_VALUE_SIGNED: + if v, ok := u._u.(*LedgerCloseValueSignature); ok { + return v + } else { + var zero LedgerCloseValueSignature + u._u = &zero + return &zero } - return XdrError(fmt.Sprintf("%s is not a valid BucketEntryType.", stok)) + default: + XdrPanic("XdrAnon_StellarValue_Ext.LcValueSignature accessed when V == %v", u.V) + return nil } } -func (v BucketEntryType) GetU32() uint32 { return uint32(v) } -func (v *BucketEntryType) SetU32(n uint32) { *v = BucketEntryType(n) } -func (v *BucketEntryType) XdrPointer() interface{} { return v } -func (BucketEntryType) XdrTypeName() string { return "BucketEntryType" } -func (v BucketEntryType) XdrValue() interface{} { return v } -func (v *BucketEntryType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_BucketEntryType = *BucketEntryType - -func XDR_BucketEntryType(v *BucketEntryType) *BucketEntryType { return v } - -var _XdrComments_BucketEntryType = map[int32]string{ - int32(METAENTRY): "At-and-after protocol 11: bucket metadata, should come first.", - int32(LIVEENTRY): "Before protocol 11: created-or-updated;", - int32(DEADENTRY): "At-and-after protocol 11: only updated.", - int32(INITENTRY): "At-and-after protocol 11: only created.", -} - -func (e BucketEntryType) XdrEnumComments() map[int32]string { - return _XdrComments_BucketEntryType -} - -var _XdrTags_XdrAnon_BucketMetadata_Ext = map[int32]bool{ - XdrToI32(0): true, -} - -func (_ XdrAnon_BucketMetadata_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_BucketMetadata_Ext -} -func (u XdrAnon_BucketMetadata_Ext) XdrValid() bool { +func (u XdrAnon_StellarValue_Ext) XdrValid() bool { switch u.V { - case 0: + case STELLAR_VALUE_BASIC, STELLAR_VALUE_SIGNED: return true } return false } -func (u *XdrAnon_BucketMetadata_Ext) XdrUnionTag() XdrNum32 { - return XDR_int32(&u.V) +func (u *XdrAnon_StellarValue_Ext) XdrUnionTag() XdrNum32 { + return XDR_StellarValueType(&u.V) } -func (u *XdrAnon_BucketMetadata_Ext) XdrUnionTagName() string { +func (u *XdrAnon_StellarValue_Ext) XdrUnionTagName() string { return "V" } -func (u *XdrAnon_BucketMetadata_Ext) XdrUnionBody() XdrType { +func (u *XdrAnon_StellarValue_Ext) XdrUnionBody() XdrType { switch u.V { - case 0: + case STELLAR_VALUE_BASIC: return nil + case STELLAR_VALUE_SIGNED: + return XDR_LedgerCloseValueSignature(u.LcValueSignature()) } return nil } -func (u *XdrAnon_BucketMetadata_Ext) XdrUnionBodyName() string { +func (u *XdrAnon_StellarValue_Ext) XdrUnionBodyName() string { switch u.V { - case 0: + case STELLAR_VALUE_BASIC: return "" + case STELLAR_VALUE_SIGNED: + return "LcValueSignature" } return "" } -type XdrType_XdrAnon_BucketMetadata_Ext = *XdrAnon_BucketMetadata_Ext +type XdrType_XdrAnon_StellarValue_Ext = *XdrAnon_StellarValue_Ext -func (v *XdrAnon_BucketMetadata_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_BucketMetadata_Ext) XdrTypeName() string { return "XdrAnon_BucketMetadata_Ext" } -func (v XdrAnon_BucketMetadata_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_BucketMetadata_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_BucketMetadata_Ext) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_StellarValue_Ext) XdrPointer() interface{} { return v } +func (XdrAnon_StellarValue_Ext) XdrTypeName() string { return "XdrAnon_StellarValue_Ext" } +func (v XdrAnon_StellarValue_Ext) XdrValue() interface{} { return v } +func (v *XdrAnon_StellarValue_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_StellarValue_Ext) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + XDR_StellarValueType(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { - case 0: + case STELLAR_VALUE_BASIC: + return + case STELLAR_VALUE_SIGNED: + x.Marshal(x.Sprintf("%slcValueSignature", name), XDR_LedgerCloseValueSignature(u.LcValueSignature())) return } - XdrPanic("invalid V (%v) in XdrAnon_BucketMetadata_Ext", u.V) -} -func XDR_XdrAnon_BucketMetadata_Ext(v *XdrAnon_BucketMetadata_Ext) *XdrAnon_BucketMetadata_Ext { - return v + XdrPanic("invalid V (%v) in XdrAnon_StellarValue_Ext", u.V) } +func XDR_XdrAnon_StellarValue_Ext(v *XdrAnon_StellarValue_Ext) *XdrAnon_StellarValue_Ext { return v } -type XdrType_BucketMetadata = *BucketMetadata - -func (v *BucketMetadata) XdrPointer() interface{} { return v } -func (BucketMetadata) XdrTypeName() string { return "BucketMetadata" } -func (v BucketMetadata) XdrValue() interface{} { return v } -func (v *BucketMetadata) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *BucketMetadata) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sledgerVersion", name), XDR_Uint32(&v.LedgerVersion)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_BucketMetadata_Ext(&v.Ext)) -} -func XDR_BucketMetadata(v *BucketMetadata) *BucketMetadata { return v } +type _XdrVec_6_UpgradeType []UpgradeType -var _XdrTags_BucketEntry = map[int32]bool{ - XdrToI32(LIVEENTRY): true, - XdrToI32(INITENTRY): true, - XdrToI32(DEADENTRY): true, - XdrToI32(METAENTRY): true, +func (_XdrVec_6_UpgradeType) XdrBound() uint32 { + const bound uint32 = 6 // Force error if not const or doesn't fit + return bound } - -func (_ BucketEntry) XdrValidTags() map[int32]bool { - return _XdrTags_BucketEntry +func (_XdrVec_6_UpgradeType) XdrCheckLen(length uint32) { + if length > uint32(6) { + XdrPanic("_XdrVec_6_UpgradeType length %d exceeds bound 6", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_6_UpgradeType length %d exceeds max int", length) + } } -func (u *BucketEntry) LiveEntry() *LedgerEntry { - switch u.Type { - case LIVEENTRY, INITENTRY: - if v, ok := u._u.(*LedgerEntry); ok { - return v - } else { - var zero LedgerEntry - u._u = &zero - return &zero +func (v _XdrVec_6_UpgradeType) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_6_UpgradeType) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] } - default: - XdrPanic("BucketEntry.LiveEntry accessed when Type == %v", u.Type) - return nil + return } -} -func (u *BucketEntry) DeadEntry() *LedgerKey { - switch u.Type { - case DEADENTRY: - if v, ok := u._u.(*LedgerKey); ok { - return v - } else { - var zero LedgerKey - u._u = &zero - return &zero + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(6); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 } - default: - XdrPanic("BucketEntry.DeadEntry accessed when Type == %v", u.Type) - return nil + newcap = int(bound) } + nv := make([]UpgradeType, int(length), newcap) + copy(nv, *v) + *v = nv } -func (u *BucketEntry) MetaEntry() *BucketMetadata { - switch u.Type { - case METAENTRY: - if v, ok := u._u.(*BucketMetadata); ok { - return v - } else { - var zero BucketMetadata - u._u = &zero - return &zero +func (v *_XdrVec_6_UpgradeType) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) } - default: - XdrPanic("BucketEntry.MetaEntry accessed when Type == %v", u.Type) - return nil + XDR_UpgradeType(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } -} -func (u BucketEntry) XdrValid() bool { - switch u.Type { - case LIVEENTRY, INITENTRY, DEADENTRY, METAENTRY: - return true + if int(n) < len(*v) { + *v = (*v)[:int(n)] } - return false } -func (u *BucketEntry) XdrUnionTag() XdrNum32 { - return XDR_BucketEntryType(&u.Type) -} -func (u *BucketEntry) XdrUnionTagName() string { - return "Type" -} -func (u *BucketEntry) XdrUnionBody() XdrType { - switch u.Type { - case LIVEENTRY, INITENTRY: - return XDR_LedgerEntry(u.LiveEntry()) - case DEADENTRY: - return XDR_LedgerKey(u.DeadEntry()) - case METAENTRY: - return XDR_BucketMetadata(u.MetaEntry()) - } - return nil -} -func (u *BucketEntry) XdrUnionBodyName() string { - switch u.Type { - case LIVEENTRY, INITENTRY: - return "LiveEntry" - case DEADENTRY: - return "DeadEntry" - case METAENTRY: - return "MetaEntry" - } - return "" +func (v *_XdrVec_6_UpgradeType) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 6} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } +func (_XdrVec_6_UpgradeType) XdrTypeName() string { return "UpgradeType<>" } +func (v *_XdrVec_6_UpgradeType) XdrPointer() interface{} { return (*[]UpgradeType)(v) } +func (v _XdrVec_6_UpgradeType) XdrValue() interface{} { return ([]UpgradeType)(v) } +func (v *_XdrVec_6_UpgradeType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_BucketEntry = *BucketEntry +type XdrType_StellarValue = *StellarValue -func (v *BucketEntry) XdrPointer() interface{} { return v } -func (BucketEntry) XdrTypeName() string { return "BucketEntry" } -func (v BucketEntry) XdrValue() interface{} { return v } -func (v *BucketEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *BucketEntry) XdrRecurse(x XDR, name string) { +func (v *StellarValue) XdrPointer() interface{} { return v } +func (StellarValue) XdrTypeName() string { return "StellarValue" } +func (v StellarValue) XdrValue() interface{} { return v } +func (v *StellarValue) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *StellarValue) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_BucketEntryType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case LIVEENTRY, INITENTRY: - x.Marshal(x.Sprintf("%sliveEntry", name), XDR_LedgerEntry(u.LiveEntry())) - return - case DEADENTRY: - x.Marshal(x.Sprintf("%sdeadEntry", name), XDR_LedgerKey(u.DeadEntry())) - return - case METAENTRY: - x.Marshal(x.Sprintf("%smetaEntry", name), XDR_BucketMetadata(u.MetaEntry())) - return - } - XdrPanic("invalid Type (%v) in BucketEntry", u.Type) + x.Marshal(x.Sprintf("%stxSetHash", name), XDR_Hash(&v.TxSetHash)) + x.Marshal(x.Sprintf("%scloseTime", name), XDR_TimePoint(&v.CloseTime)) + x.Marshal(x.Sprintf("%supgrades", name), (*_XdrVec_6_UpgradeType)(&v.Upgrades)) + x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_StellarValue_Ext(&v.Ext)) } -func XDR_BucketEntry(v *BucketEntry) *BucketEntry { return v } +func XDR_StellarValue(v *StellarValue) *StellarValue { return v } -var _XdrNames_TxSetComponentType = map[int32]string{ - int32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE): "TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE", +var _XdrNames_LedgerHeaderFlags = map[int32]string{ + int32(DISABLE_LIQUIDITY_POOL_TRADING_FLAG): "DISABLE_LIQUIDITY_POOL_TRADING_FLAG", + int32(DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG): "DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG", + int32(DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG): "DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG", } -var _XdrValues_TxSetComponentType = map[string]int32{ - "TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE": int32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE), +var _XdrValues_LedgerHeaderFlags = map[string]int32{ + "DISABLE_LIQUIDITY_POOL_TRADING_FLAG": int32(DISABLE_LIQUIDITY_POOL_TRADING_FLAG), + "DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG": int32(DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG), + "DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG": int32(DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG), } -func (TxSetComponentType) XdrEnumNames() map[int32]string { - return _XdrNames_TxSetComponentType +func (LedgerHeaderFlags) XdrEnumNames() map[int32]string { + return _XdrNames_LedgerHeaderFlags } -func (v TxSetComponentType) String() string { - if s, ok := _XdrNames_TxSetComponentType[int32(v)]; ok { +func (v LedgerHeaderFlags) String() string { + if s, ok := _XdrNames_LedgerHeaderFlags[int32(v)]; ok { return s } - return fmt.Sprintf("TxSetComponentType#%d", v) + return fmt.Sprintf("LedgerHeaderFlags#%d", v) } -func (v *TxSetComponentType) Scan(ss fmt.ScanState, _ rune) error { +func (v *LedgerHeaderFlags) Scan(ss fmt.ScanState, _ rune) error { if tok, err := ss.Token(true, XdrSymChar); err != nil { return err } else { stok := string(tok) - if val, ok := _XdrValues_TxSetComponentType[stok]; ok { - *v = TxSetComponentType(val) + if val, ok := _XdrValues_LedgerHeaderFlags[stok]; ok { + *v = LedgerHeaderFlags(val) return nil - } else if stok == "TxSetComponentType" { + } else if stok == "LedgerHeaderFlags" { if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { return nil } } - return XdrError(fmt.Sprintf("%s is not a valid TxSetComponentType.", stok)) + return XdrError(fmt.Sprintf("%s is not a valid LedgerHeaderFlags.", stok)) } } -func (v TxSetComponentType) GetU32() uint32 { return uint32(v) } -func (v *TxSetComponentType) SetU32(n uint32) { *v = TxSetComponentType(n) } -func (v *TxSetComponentType) XdrPointer() interface{} { return v } -func (TxSetComponentType) XdrTypeName() string { return "TxSetComponentType" } -func (v TxSetComponentType) XdrValue() interface{} { return v } -func (v *TxSetComponentType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_TxSetComponentType = *TxSetComponentType +func (v LedgerHeaderFlags) GetU32() uint32 { return uint32(v) } +func (v *LedgerHeaderFlags) SetU32(n uint32) { *v = LedgerHeaderFlags(n) } +func (v *LedgerHeaderFlags) XdrPointer() interface{} { return v } +func (LedgerHeaderFlags) XdrTypeName() string { return "LedgerHeaderFlags" } +func (v LedgerHeaderFlags) XdrValue() interface{} { return v } +func (v *LedgerHeaderFlags) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func XDR_TxSetComponentType(v *TxSetComponentType) *TxSetComponentType { return v } +type XdrType_LedgerHeaderFlags = *LedgerHeaderFlags -var _XdrComments_TxSetComponentType = map[int32]string{ - int32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE): "txs with effective fee <= bid derived from a base fee (if any). If base fee is not specified, no discount is applied.", +func XDR_LedgerHeaderFlags(v *LedgerHeaderFlags) *LedgerHeaderFlags { return v } +func (v *LedgerHeaderFlags) XdrInitialize() { + switch LedgerHeaderFlags(0) { + case DISABLE_LIQUIDITY_POOL_TRADING_FLAG, DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG, DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG: + default: + if *v == LedgerHeaderFlags(0) { + *v = DISABLE_LIQUIDITY_POOL_TRADING_FLAG + } + } } -func (e TxSetComponentType) XdrEnumComments() map[int32]string { - return _XdrComments_TxSetComponentType +var _XdrTags_XdrAnon_LedgerHeaderExtensionV1_Ext = map[int32]bool{ + XdrToI32(0): true, } -type _XdrPtr_Int64 struct { - p **Int64 +func (_ XdrAnon_LedgerHeaderExtensionV1_Ext) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_LedgerHeaderExtensionV1_Ext } -type _ptrflag_Int64 _XdrPtr_Int64 - -func (v _ptrflag_Int64) String() string { - if *v.p == nil { - return "nil" +func (u XdrAnon_LedgerHeaderExtensionV1_Ext) XdrValid() bool { + switch u.V { + case 0: + return true } - return "non-nil" + return false } -func (v _ptrflag_Int64) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("Int64 flag should be \"nil\" or \"non-nil\"") - } - return nil +func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionTag() XdrNum32 { + return XDR_int32(&u.V) } -func (v _ptrflag_Int64) GetU32() uint32 { - if *v.p == nil { - return 0 - } - return 1 +func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionTagName() string { + return "V" } -func (v _ptrflag_Int64) SetU32(nv uint32) { - switch nv { +func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionBody() XdrType { + switch u.V { case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(Int64) - } - default: - XdrPanic("*Int64 present flag value %d should be 0 or 1", nv) - } -} -func (_ptrflag_Int64) XdrTypeName() string { return "Int64?" } -func (v _ptrflag_Int64) XdrPointer() interface{} { return nil } -func (v _ptrflag_Int64) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_Int64) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_Int64) XdrBound() uint32 { return 1 } -func (v _XdrPtr_Int64) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_Int64) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(Int64) + return nil } + return nil } -func (v _XdrPtr_Int64) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_Int64(*v.p).XdrMarshal(x, name) +func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrUnionBodyName() string { + switch u.V { + case 0: + return "" } + return "" } -func (v _XdrPtr_Int64) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_Int64) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_Int64(v)) - v.XdrMarshalValue(x, name) -} -func (_XdrPtr_Int64) XdrTypeName() string { return "Int64*" } -func (v _XdrPtr_Int64) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_Int64) XdrValue() interface{} { return *v.p } -type _XdrVec_unbounded_TransactionEnvelope []TransactionEnvelope +type XdrType_XdrAnon_LedgerHeaderExtensionV1_Ext = *XdrAnon_LedgerHeaderExtensionV1_Ext -func (_XdrVec_unbounded_TransactionEnvelope) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound +func (v *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrPointer() interface{} { return v } +func (XdrAnon_LedgerHeaderExtensionV1_Ext) XdrTypeName() string { + return "XdrAnon_LedgerHeaderExtensionV1_Ext" } -func (_XdrVec_unbounded_TransactionEnvelope) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_TransactionEnvelope length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_TransactionEnvelope length %d exceeds max int", length) +func (v XdrAnon_LedgerHeaderExtensionV1_Ext) XdrValue() interface{} { return v } +func (v *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_LedgerHeaderExtensionV1_Ext) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } -} -func (v _XdrVec_unbounded_TransactionEnvelope) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_TransactionEnvelope) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } + XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + switch u.V { + case 0: return } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) - } - nv := make([]TransactionEnvelope, int(length), newcap) - copy(nv, *v) - *v = nv + XdrPanic("invalid V (%v) in XdrAnon_LedgerHeaderExtensionV1_Ext", u.V) } -func (v *_XdrVec_unbounded_TransactionEnvelope) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_TransactionEnvelope(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_unbounded_TransactionEnvelope) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_unbounded_TransactionEnvelope) XdrTypeName() string { return "TransactionEnvelope<>" } -func (v *_XdrVec_unbounded_TransactionEnvelope) XdrPointer() interface{} { - return (*[]TransactionEnvelope)(v) -} -func (v _XdrVec_unbounded_TransactionEnvelope) XdrValue() interface{} { - return ([]TransactionEnvelope)(v) -} -func (v *_XdrVec_unbounded_TransactionEnvelope) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee = *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee - -func (v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrPointer() interface{} { return v } -func (XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrTypeName() string { - return "XdrAnon_TxSetComponent_TxsMaybeDiscountedFee" -} -func (v XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrValue() interface{} { return v } -func (v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} -func (v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sbaseFee", name), _XdrPtr_Int64{&v.BaseFee}) - x.Marshal(x.Sprintf("%stxs", name), (*_XdrVec_unbounded_TransactionEnvelope)(&v.Txs)) -} -func XDR_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee(v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee { +func XDR_XdrAnon_LedgerHeaderExtensionV1_Ext(v *XdrAnon_LedgerHeaderExtensionV1_Ext) *XdrAnon_LedgerHeaderExtensionV1_Ext { return v } -var _XdrTags_TxSetComponent = map[int32]bool{ - XdrToI32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE): true, -} - -func (_ TxSetComponent) XdrValidTags() map[int32]bool { - return _XdrTags_TxSetComponent -} -func (u *TxSetComponent) TxsMaybeDiscountedFee() *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee { - switch u.Type { - case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: - if v, ok := u._u.(*XdrAnon_TxSetComponent_TxsMaybeDiscountedFee); ok { - return v - } else { - var zero XdrAnon_TxSetComponent_TxsMaybeDiscountedFee - u._u = &zero - return &zero - } - default: - XdrPanic("TxSetComponent.TxsMaybeDiscountedFee accessed when Type == %v", u.Type) - return nil - } -} -func (u TxSetComponent) XdrValid() bool { - switch u.Type { - case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: - return true - } - return false -} -func (u *TxSetComponent) XdrUnionTag() XdrNum32 { - return XDR_TxSetComponentType(&u.Type) -} -func (u *TxSetComponent) XdrUnionTagName() string { - return "Type" -} -func (u *TxSetComponent) XdrUnionBody() XdrType { - switch u.Type { - case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: - return XDR_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee(u.TxsMaybeDiscountedFee()) - } - return nil -} -func (u *TxSetComponent) XdrUnionBodyName() string { - switch u.Type { - case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: - return "TxsMaybeDiscountedFee" - } - return "" -} - -type XdrType_TxSetComponent = *TxSetComponent +type XdrType_LedgerHeaderExtensionV1 = *LedgerHeaderExtensionV1 -func (v *TxSetComponent) XdrPointer() interface{} { return v } -func (TxSetComponent) XdrTypeName() string { return "TxSetComponent" } -func (v TxSetComponent) XdrValue() interface{} { return v } -func (v *TxSetComponent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *TxSetComponent) XdrRecurse(x XDR, name string) { +func (v *LedgerHeaderExtensionV1) XdrPointer() interface{} { return v } +func (LedgerHeaderExtensionV1) XdrTypeName() string { return "LedgerHeaderExtensionV1" } +func (v LedgerHeaderExtensionV1) XdrValue() interface{} { return v } +func (v *LedgerHeaderExtensionV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerHeaderExtensionV1) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_TxSetComponentType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: - x.Marshal(x.Sprintf("%stxsMaybeDiscountedFee", name), XDR_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee(u.TxsMaybeDiscountedFee())) - return - } - XdrPanic("invalid Type (%v) in TxSetComponent", u.Type) -} -func XDR_TxSetComponent(v *TxSetComponent) *TxSetComponent { return v } - -type _XdrVec_unbounded_TxSetComponent []TxSetComponent - -func (_XdrVec_unbounded_TxSetComponent) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_unbounded_TxSetComponent) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_TxSetComponent length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_TxSetComponent length %d exceeds max int", length) - } -} -func (v _XdrVec_unbounded_TxSetComponent) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_TxSetComponent) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) - } - nv := make([]TxSetComponent, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_unbounded_TxSetComponent) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_TxSetComponent(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_unbounded_TxSetComponent) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) + x.Marshal(x.Sprintf("%sflags", name), XDR_Uint32(&v.Flags)) + x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_LedgerHeaderExtensionV1_Ext(&v.Ext)) } -func (_XdrVec_unbounded_TxSetComponent) XdrTypeName() string { return "TxSetComponent<>" } -func (v *_XdrVec_unbounded_TxSetComponent) XdrPointer() interface{} { return (*[]TxSetComponent)(v) } -func (v _XdrVec_unbounded_TxSetComponent) XdrValue() interface{} { return ([]TxSetComponent)(v) } -func (v *_XdrVec_unbounded_TxSetComponent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func XDR_LedgerHeaderExtensionV1(v *LedgerHeaderExtensionV1) *LedgerHeaderExtensionV1 { return v } -var _XdrTags_TransactionPhase = map[int32]bool{ +var _XdrTags_XdrAnon_LedgerHeader_Ext = map[int32]bool{ XdrToI32(0): true, + XdrToI32(1): true, } -func (_ TransactionPhase) XdrValidTags() map[int32]bool { - return _XdrTags_TransactionPhase +func (_ XdrAnon_LedgerHeader_Ext) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_LedgerHeader_Ext } -func (u *TransactionPhase) V0Components() *[]TxSetComponent { +func (u *XdrAnon_LedgerHeader_Ext) V1() *LedgerHeaderExtensionV1 { switch u.V { - case 0: - if v, ok := u._u.(*[]TxSetComponent); ok { + case 1: + if v, ok := u._u.(*LedgerHeaderExtensionV1); ok { return v } else { - var zero []TxSetComponent + var zero LedgerHeaderExtensionV1 u._u = &zero return &zero } default: - XdrPanic("TransactionPhase.V0Components accessed when V == %v", u.V) + XdrPanic("XdrAnon_LedgerHeader_Ext.V1 accessed when V == %v", u.V) return nil } } -func (u TransactionPhase) XdrValid() bool { +func (u XdrAnon_LedgerHeader_Ext) XdrValid() bool { switch u.V { - case 0: + case 0, 1: return true } return false } -func (u *TransactionPhase) XdrUnionTag() XdrNum32 { +func (u *XdrAnon_LedgerHeader_Ext) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *TransactionPhase) XdrUnionTagName() string { +func (u *XdrAnon_LedgerHeader_Ext) XdrUnionTagName() string { return "V" } -func (u *TransactionPhase) XdrUnionBody() XdrType { +func (u *XdrAnon_LedgerHeader_Ext) XdrUnionBody() XdrType { switch u.V { case 0: - return (*_XdrVec_unbounded_TxSetComponent)(u.V0Components()) + return nil + case 1: + return XDR_LedgerHeaderExtensionV1(u.V1()) } return nil } -func (u *TransactionPhase) XdrUnionBodyName() string { +func (u *XdrAnon_LedgerHeader_Ext) XdrUnionBodyName() string { switch u.V { case 0: - return "V0Components" + return "" + case 1: + return "V1" } return "" } -type XdrType_TransactionPhase = *TransactionPhase +type XdrType_XdrAnon_LedgerHeader_Ext = *XdrAnon_LedgerHeader_Ext -func (v *TransactionPhase) XdrPointer() interface{} { return v } -func (TransactionPhase) XdrTypeName() string { return "TransactionPhase" } -func (v TransactionPhase) XdrValue() interface{} { return v } -func (v *TransactionPhase) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *TransactionPhase) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_LedgerHeader_Ext) XdrPointer() interface{} { return v } +func (XdrAnon_LedgerHeader_Ext) XdrTypeName() string { return "XdrAnon_LedgerHeader_Ext" } +func (v XdrAnon_LedgerHeader_Ext) XdrValue() interface{} { return v } +func (v *XdrAnon_LedgerHeader_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_LedgerHeader_Ext) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { case 0: - x.Marshal(x.Sprintf("%sv0Components", name), (*_XdrVec_unbounded_TxSetComponent)(u.V0Components())) + return + case 1: + x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerHeaderExtensionV1(u.V1())) return } - XdrPanic("invalid V (%v) in TransactionPhase", u.V) + XdrPanic("invalid V (%v) in XdrAnon_LedgerHeader_Ext", u.V) } -func XDR_TransactionPhase(v *TransactionPhase) *TransactionPhase { return v } +func XDR_XdrAnon_LedgerHeader_Ext(v *XdrAnon_LedgerHeader_Ext) *XdrAnon_LedgerHeader_Ext { return v } -type XdrType_TransactionSet = *TransactionSet +type _XdrArray_4_Hash [4]Hash -func (v *TransactionSet) XdrPointer() interface{} { return v } -func (TransactionSet) XdrTypeName() string { return "TransactionSet" } -func (v TransactionSet) XdrValue() interface{} { return v } -func (v *TransactionSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionSet) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (_XdrArray_4_Hash) XdrArraySize() uint32 { + const bound uint32 = 4 // Force error if not const or doesn't fit + return bound +} +func (v *_XdrArray_4_Hash) XdrRecurse(x XDR, name string) { + for i := 0; i < len(*v); i++ { + XDR_Hash(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } - x.Marshal(x.Sprintf("%spreviousLedgerHash", name), XDR_Hash(&v.PreviousLedgerHash)) - x.Marshal(x.Sprintf("%stxs", name), (*_XdrVec_unbounded_TransactionEnvelope)(&v.Txs)) } -func XDR_TransactionSet(v *TransactionSet) *TransactionSet { return v } +func (v *_XdrArray_4_Hash) XdrPointer() interface{} { return (*[4]Hash)(v) } +func (_XdrArray_4_Hash) XdrTypeName() string { return "Hash[]" } +func (v *_XdrArray_4_Hash) XdrValue() interface{} { return v[:] } +func (v *_XdrArray_4_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type _XdrVec_unbounded_TransactionPhase []TransactionPhase +type XdrType_LedgerHeader = *LedgerHeader -func (_XdrVec_unbounded_TransactionPhase) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_unbounded_TransactionPhase) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_TransactionPhase length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_TransactionPhase length %d exceeds max int", length) +func (v *LedgerHeader) XdrPointer() interface{} { return v } +func (LedgerHeader) XdrTypeName() string { return "LedgerHeader" } +func (v LedgerHeader) XdrValue() interface{} { return v } +func (v *LedgerHeader) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerHeader) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%sledgerVersion", name), XDR_Uint32(&v.LedgerVersion)) + x.Marshal(x.Sprintf("%spreviousLedgerHash", name), XDR_Hash(&v.PreviousLedgerHash)) + x.Marshal(x.Sprintf("%sscpValue", name), XDR_StellarValue(&v.ScpValue)) + x.Marshal(x.Sprintf("%stxSetResultHash", name), XDR_Hash(&v.TxSetResultHash)) + x.Marshal(x.Sprintf("%sbucketListHash", name), XDR_Hash(&v.BucketListHash)) + x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) + x.Marshal(x.Sprintf("%stotalCoins", name), XDR_Int64(&v.TotalCoins)) + x.Marshal(x.Sprintf("%sfeePool", name), XDR_Int64(&v.FeePool)) + x.Marshal(x.Sprintf("%sinflationSeq", name), XDR_Uint32(&v.InflationSeq)) + x.Marshal(x.Sprintf("%sidPool", name), XDR_Uint64(&v.IdPool)) + x.Marshal(x.Sprintf("%sbaseFee", name), XDR_Uint32(&v.BaseFee)) + x.Marshal(x.Sprintf("%sbaseReserve", name), XDR_Uint32(&v.BaseReserve)) + x.Marshal(x.Sprintf("%smaxTxSetSize", name), XDR_Uint32(&v.MaxTxSetSize)) + x.Marshal(x.Sprintf("%sskipList", name), (*_XdrArray_4_Hash)(&v.SkipList)) + x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_LedgerHeader_Ext(&v.Ext)) } -func (v _XdrVec_unbounded_TransactionPhase) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_TransactionPhase) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return +func XDR_LedgerHeader(v *LedgerHeader) *LedgerHeader { return v } + +var _XdrNames_LedgerUpgradeType = map[int32]string{ + int32(LEDGER_UPGRADE_VERSION): "LEDGER_UPGRADE_VERSION", + int32(LEDGER_UPGRADE_BASE_FEE): "LEDGER_UPGRADE_BASE_FEE", + int32(LEDGER_UPGRADE_MAX_TX_SET_SIZE): "LEDGER_UPGRADE_MAX_TX_SET_SIZE", + int32(LEDGER_UPGRADE_BASE_RESERVE): "LEDGER_UPGRADE_BASE_RESERVE", + int32(LEDGER_UPGRADE_FLAGS): "LEDGER_UPGRADE_FLAGS", + int32(LEDGER_UPGRADE_CONFIG): "LEDGER_UPGRADE_CONFIG", + int32(LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE): "LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE", +} +var _XdrValues_LedgerUpgradeType = map[string]int32{ + "LEDGER_UPGRADE_VERSION": int32(LEDGER_UPGRADE_VERSION), + "LEDGER_UPGRADE_BASE_FEE": int32(LEDGER_UPGRADE_BASE_FEE), + "LEDGER_UPGRADE_MAX_TX_SET_SIZE": int32(LEDGER_UPGRADE_MAX_TX_SET_SIZE), + "LEDGER_UPGRADE_BASE_RESERVE": int32(LEDGER_UPGRADE_BASE_RESERVE), + "LEDGER_UPGRADE_FLAGS": int32(LEDGER_UPGRADE_FLAGS), + "LEDGER_UPGRADE_CONFIG": int32(LEDGER_UPGRADE_CONFIG), + "LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE": int32(LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE), +} + +func (LedgerUpgradeType) XdrEnumNames() map[int32]string { + return _XdrNames_LedgerUpgradeType +} +func (v LedgerUpgradeType) String() string { + if s, ok := _XdrNames_LedgerUpgradeType[int32(v)]; ok { + return s } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 + return fmt.Sprintf("LedgerUpgradeType#%d", v) +} +func (v *LedgerUpgradeType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_LedgerUpgradeType[stok]; ok { + *v = LedgerUpgradeType(val) + return nil + } else if stok == "LedgerUpgradeType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - newcap = int(bound) + return XdrError(fmt.Sprintf("%s is not a valid LedgerUpgradeType.", stok)) } - nv := make([]TransactionPhase, int(length), newcap) - copy(nv, *v) - *v = nv } -func (v *_XdrVec_unbounded_TransactionPhase) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) +func (v LedgerUpgradeType) GetU32() uint32 { return uint32(v) } +func (v *LedgerUpgradeType) SetU32(n uint32) { *v = LedgerUpgradeType(n) } +func (v *LedgerUpgradeType) XdrPointer() interface{} { return v } +func (LedgerUpgradeType) XdrTypeName() string { return "LedgerUpgradeType" } +func (v LedgerUpgradeType) XdrValue() interface{} { return v } +func (v *LedgerUpgradeType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_LedgerUpgradeType = *LedgerUpgradeType + +func XDR_LedgerUpgradeType(v *LedgerUpgradeType) *LedgerUpgradeType { return v } +func (v *LedgerUpgradeType) XdrInitialize() { + switch LedgerUpgradeType(0) { + case LEDGER_UPGRADE_VERSION, LEDGER_UPGRADE_BASE_FEE, LEDGER_UPGRADE_MAX_TX_SET_SIZE, LEDGER_UPGRADE_BASE_RESERVE, LEDGER_UPGRADE_FLAGS, LEDGER_UPGRADE_CONFIG, LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + default: + if *v == LedgerUpgradeType(0) { + *v = LEDGER_UPGRADE_VERSION } - XDR_TransactionPhase(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_TransactionPhase) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_unbounded_TransactionPhase) XdrTypeName() string { return "TransactionPhase<>" } -func (v *_XdrVec_unbounded_TransactionPhase) XdrPointer() interface{} { - return (*[]TransactionPhase)(v) -} -func (v _XdrVec_unbounded_TransactionPhase) XdrValue() interface{} { return ([]TransactionPhase)(v) } -func (v *_XdrVec_unbounded_TransactionPhase) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_TransactionSetV1 = *TransactionSetV1 +type XdrType_ConfigUpgradeSetKey = *ConfigUpgradeSetKey -func (v *TransactionSetV1) XdrPointer() interface{} { return v } -func (TransactionSetV1) XdrTypeName() string { return "TransactionSetV1" } -func (v TransactionSetV1) XdrValue() interface{} { return v } -func (v *TransactionSetV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionSetV1) XdrRecurse(x XDR, name string) { +func (v *ConfigUpgradeSetKey) XdrPointer() interface{} { return v } +func (ConfigUpgradeSetKey) XdrTypeName() string { return "ConfigUpgradeSetKey" } +func (v ConfigUpgradeSetKey) XdrValue() interface{} { return v } +func (v *ConfigUpgradeSetKey) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ConfigUpgradeSetKey) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%spreviousLedgerHash", name), XDR_Hash(&v.PreviousLedgerHash)) - x.Marshal(x.Sprintf("%sphases", name), (*_XdrVec_unbounded_TransactionPhase)(&v.Phases)) + x.Marshal(x.Sprintf("%scontractID", name), XDR_Hash(&v.ContractID)) + x.Marshal(x.Sprintf("%scontentHash", name), XDR_Hash(&v.ContentHash)) } -func XDR_TransactionSetV1(v *TransactionSetV1) *TransactionSetV1 { return v } +func XDR_ConfigUpgradeSetKey(v *ConfigUpgradeSetKey) *ConfigUpgradeSetKey { return v } -var _XdrTags_GeneralizedTransactionSet = map[int32]bool{ - XdrToI32(1): true, +var _XdrTags_LedgerUpgrade = map[int32]bool{ + XdrToI32(LEDGER_UPGRADE_VERSION): true, + XdrToI32(LEDGER_UPGRADE_BASE_FEE): true, + XdrToI32(LEDGER_UPGRADE_MAX_TX_SET_SIZE): true, + XdrToI32(LEDGER_UPGRADE_BASE_RESERVE): true, + XdrToI32(LEDGER_UPGRADE_FLAGS): true, + XdrToI32(LEDGER_UPGRADE_CONFIG): true, + XdrToI32(LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE): true, } -func (_ GeneralizedTransactionSet) XdrValidTags() map[int32]bool { - return _XdrTags_GeneralizedTransactionSet +func (_ LedgerUpgrade) XdrValidTags() map[int32]bool { + return _XdrTags_LedgerUpgrade } -func (u *GeneralizedTransactionSet) V1TxSet() *TransactionSetV1 { - switch u.V { - case 1: - if v, ok := u._u.(*TransactionSetV1); ok { + +// update ledgerVersion +func (u *LedgerUpgrade) NewLedgerVersion() *Uint32 { + switch u.Type { + case LEDGER_UPGRADE_VERSION: + if v, ok := u._u.(*Uint32); ok { return v } else { - var zero TransactionSetV1 + var zero Uint32 u._u = &zero return &zero } default: - XdrPanic("GeneralizedTransactionSet.V1TxSet accessed when V == %v", u.V) + XdrPanic("LedgerUpgrade.NewLedgerVersion accessed when Type == %v", u.Type) return nil } } -func (u GeneralizedTransactionSet) XdrValid() bool { - switch u.V { - case 1: - return true + +// update baseFee +func (u *LedgerUpgrade) NewBaseFee() *Uint32 { + switch u.Type { + case LEDGER_UPGRADE_BASE_FEE: + if v, ok := u._u.(*Uint32); ok { + return v + } else { + var zero Uint32 + u._u = &zero + return &zero + } + default: + XdrPanic("LedgerUpgrade.NewBaseFee accessed when Type == %v", u.Type) + return nil } - return false -} -func (u *GeneralizedTransactionSet) XdrUnionTag() XdrNum32 { - return XDR_int32(&u.V) -} -func (u *GeneralizedTransactionSet) XdrUnionTagName() string { - return "V" } -func (u *GeneralizedTransactionSet) XdrUnionBody() XdrType { - switch u.V { - case 1: - return XDR_TransactionSetV1(u.V1TxSet()) + +// update maxTxSetSize +func (u *LedgerUpgrade) NewMaxTxSetSize() *Uint32 { + switch u.Type { + case LEDGER_UPGRADE_MAX_TX_SET_SIZE: + if v, ok := u._u.(*Uint32); ok { + return v + } else { + var zero Uint32 + u._u = &zero + return &zero + } + default: + XdrPanic("LedgerUpgrade.NewMaxTxSetSize accessed when Type == %v", u.Type) + return nil } - return nil } -func (u *GeneralizedTransactionSet) XdrUnionBodyName() string { - switch u.V { - case 1: - return "V1TxSet" + +// update baseReserve +func (u *LedgerUpgrade) NewBaseReserve() *Uint32 { + switch u.Type { + case LEDGER_UPGRADE_BASE_RESERVE: + if v, ok := u._u.(*Uint32); ok { + return v + } else { + var zero Uint32 + u._u = &zero + return &zero + } + default: + XdrPanic("LedgerUpgrade.NewBaseReserve accessed when Type == %v", u.Type) + return nil } - return "" } -type XdrType_GeneralizedTransactionSet = *GeneralizedTransactionSet +// update flags +func (u *LedgerUpgrade) NewFlags() *Uint32 { + switch u.Type { + case LEDGER_UPGRADE_FLAGS: + if v, ok := u._u.(*Uint32); ok { + return v + } else { + var zero Uint32 + u._u = &zero + return &zero + } + default: + XdrPanic("LedgerUpgrade.NewFlags accessed when Type == %v", u.Type) + return nil + } +} -func (v *GeneralizedTransactionSet) XdrPointer() interface{} { return v } -func (GeneralizedTransactionSet) XdrTypeName() string { return "GeneralizedTransactionSet" } -func (v GeneralizedTransactionSet) XdrValue() interface{} { return v } -func (v *GeneralizedTransactionSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *GeneralizedTransactionSet) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) - switch u.V { - case 1: - x.Marshal(x.Sprintf("%sv1TxSet", name), XDR_TransactionSetV1(u.V1TxSet())) - return +// Update arbitrary `ConfigSetting` entries identified by the key. +func (u *LedgerUpgrade) NewConfig() *ConfigUpgradeSetKey { + switch u.Type { + case LEDGER_UPGRADE_CONFIG: + if v, ok := u._u.(*ConfigUpgradeSetKey); ok { + return v + } else { + var zero ConfigUpgradeSetKey + u._u = &zero + return &zero + } + default: + XdrPanic("LedgerUpgrade.NewConfig accessed when Type == %v", u.Type) + return nil } - XdrPanic("invalid V (%v) in GeneralizedTransactionSet", u.V) } -func (v *GeneralizedTransactionSet) XdrInitialize() { - var zero int32 - switch zero { - case 1: - default: - if v.V == zero { - v.V = 1 + +// Update ConfigSettingContractExecutionLanesV0.ledgerMaxTxCount without +// using `LEDGER_UPGRADE_CONFIG`. +func (u *LedgerUpgrade) NewMaxSorobanTxSetSize() *Uint32 { + switch u.Type { + case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + if v, ok := u._u.(*Uint32); ok { + return v + } else { + var zero Uint32 + u._u = &zero + return &zero } + default: + XdrPanic("LedgerUpgrade.NewMaxSorobanTxSetSize accessed when Type == %v", u.Type) + return nil } } -func XDR_GeneralizedTransactionSet(v *GeneralizedTransactionSet) *GeneralizedTransactionSet { return v } +func (u LedgerUpgrade) XdrValid() bool { + switch u.Type { + case LEDGER_UPGRADE_VERSION, LEDGER_UPGRADE_BASE_FEE, LEDGER_UPGRADE_MAX_TX_SET_SIZE, LEDGER_UPGRADE_BASE_RESERVE, LEDGER_UPGRADE_FLAGS, LEDGER_UPGRADE_CONFIG, LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + return true + } + return false +} +func (u *LedgerUpgrade) XdrUnionTag() XdrNum32 { + return XDR_LedgerUpgradeType(&u.Type) +} +func (u *LedgerUpgrade) XdrUnionTagName() string { + return "Type" +} +func (u *LedgerUpgrade) XdrUnionBody() XdrType { + switch u.Type { + case LEDGER_UPGRADE_VERSION: + return XDR_Uint32(u.NewLedgerVersion()) + case LEDGER_UPGRADE_BASE_FEE: + return XDR_Uint32(u.NewBaseFee()) + case LEDGER_UPGRADE_MAX_TX_SET_SIZE: + return XDR_Uint32(u.NewMaxTxSetSize()) + case LEDGER_UPGRADE_BASE_RESERVE: + return XDR_Uint32(u.NewBaseReserve()) + case LEDGER_UPGRADE_FLAGS: + return XDR_Uint32(u.NewFlags()) + case LEDGER_UPGRADE_CONFIG: + return XDR_ConfigUpgradeSetKey(u.NewConfig()) + case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + return XDR_Uint32(u.NewMaxSorobanTxSetSize()) + } + return nil +} +func (u *LedgerUpgrade) XdrUnionBodyName() string { + switch u.Type { + case LEDGER_UPGRADE_VERSION: + return "NewLedgerVersion" + case LEDGER_UPGRADE_BASE_FEE: + return "NewBaseFee" + case LEDGER_UPGRADE_MAX_TX_SET_SIZE: + return "NewMaxTxSetSize" + case LEDGER_UPGRADE_BASE_RESERVE: + return "NewBaseReserve" + case LEDGER_UPGRADE_FLAGS: + return "NewFlags" + case LEDGER_UPGRADE_CONFIG: + return "NewConfig" + case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + return "NewMaxSorobanTxSetSize" + } + return "" +} -type XdrType_TransactionResultPair = *TransactionResultPair +type XdrType_LedgerUpgrade = *LedgerUpgrade -func (v *TransactionResultPair) XdrPointer() interface{} { return v } -func (TransactionResultPair) XdrTypeName() string { return "TransactionResultPair" } -func (v TransactionResultPair) XdrValue() interface{} { return v } -func (v *TransactionResultPair) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionResultPair) XdrRecurse(x XDR, name string) { +func (v *LedgerUpgrade) XdrPointer() interface{} { return v } +func (LedgerUpgrade) XdrTypeName() string { return "LedgerUpgrade" } +func (v LedgerUpgrade) XdrValue() interface{} { return v } +func (v *LedgerUpgrade) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *LedgerUpgrade) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%stransactionHash", name), XDR_Hash(&v.TransactionHash)) - x.Marshal(x.Sprintf("%sresult", name), XDR_TransactionResult(&v.Result)) + XDR_LedgerUpgradeType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case LEDGER_UPGRADE_VERSION: + x.Marshal(x.Sprintf("%snewLedgerVersion", name), XDR_Uint32(u.NewLedgerVersion())) + return + case LEDGER_UPGRADE_BASE_FEE: + x.Marshal(x.Sprintf("%snewBaseFee", name), XDR_Uint32(u.NewBaseFee())) + return + case LEDGER_UPGRADE_MAX_TX_SET_SIZE: + x.Marshal(x.Sprintf("%snewMaxTxSetSize", name), XDR_Uint32(u.NewMaxTxSetSize())) + return + case LEDGER_UPGRADE_BASE_RESERVE: + x.Marshal(x.Sprintf("%snewBaseReserve", name), XDR_Uint32(u.NewBaseReserve())) + return + case LEDGER_UPGRADE_FLAGS: + x.Marshal(x.Sprintf("%snewFlags", name), XDR_Uint32(u.NewFlags())) + return + case LEDGER_UPGRADE_CONFIG: + x.Marshal(x.Sprintf("%snewConfig", name), XDR_ConfigUpgradeSetKey(u.NewConfig())) + return + case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + x.Marshal(x.Sprintf("%snewMaxSorobanTxSetSize", name), XDR_Uint32(u.NewMaxSorobanTxSetSize())) + return + } + XdrPanic("invalid Type (%v) in LedgerUpgrade", u.Type) } -func XDR_TransactionResultPair(v *TransactionResultPair) *TransactionResultPair { return v } +func (v *LedgerUpgrade) XdrInitialize() { + var zero LedgerUpgradeType + switch zero { + case LEDGER_UPGRADE_VERSION, LEDGER_UPGRADE_BASE_FEE, LEDGER_UPGRADE_MAX_TX_SET_SIZE, LEDGER_UPGRADE_BASE_RESERVE, LEDGER_UPGRADE_FLAGS, LEDGER_UPGRADE_CONFIG, LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: + default: + if v.Type == zero { + v.Type = LEDGER_UPGRADE_VERSION + } + } +} +func XDR_LedgerUpgrade(v *LedgerUpgrade) *LedgerUpgrade { return v } -type _XdrVec_unbounded_TransactionResultPair []TransactionResultPair +type _XdrVec_unbounded_ConfigSettingEntry []ConfigSettingEntry -func (_XdrVec_unbounded_TransactionResultPair) XdrBound() uint32 { +func (_XdrVec_unbounded_ConfigSettingEntry) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_TransactionResultPair) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_ConfigSettingEntry) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_TransactionResultPair length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_ConfigSettingEntry length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_TransactionResultPair length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_ConfigSettingEntry length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_TransactionResultPair) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_TransactionResultPair) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_ConfigSettingEntry) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_ConfigSettingEntry) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -10960,314 +11063,483 @@ func (v *_XdrVec_unbounded_TransactionResultPair) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]TransactionResultPair, int(length), newcap) + nv := make([]ConfigSettingEntry, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_TransactionResultPair) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_TransactionResultPair(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_ConfigSettingEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_TransactionResultPair) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_TransactionResultPair) XdrTypeName() string { return "TransactionResultPair<>" } -func (v *_XdrVec_unbounded_TransactionResultPair) XdrPointer() interface{} { - return (*[]TransactionResultPair)(v) +func (_XdrVec_unbounded_ConfigSettingEntry) XdrTypeName() string { return "ConfigSettingEntry<>" } +func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrPointer() interface{} { + return (*[]ConfigSettingEntry)(v) } -func (v _XdrVec_unbounded_TransactionResultPair) XdrValue() interface{} { - return ([]TransactionResultPair)(v) +func (v _XdrVec_unbounded_ConfigSettingEntry) XdrValue() interface{} { + return ([]ConfigSettingEntry)(v) } -func (v *_XdrVec_unbounded_TransactionResultPair) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *_XdrVec_unbounded_ConfigSettingEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_TransactionResultSet = *TransactionResultSet +type XdrType_ConfigUpgradeSet = *ConfigUpgradeSet -func (v *TransactionResultSet) XdrPointer() interface{} { return v } -func (TransactionResultSet) XdrTypeName() string { return "TransactionResultSet" } -func (v TransactionResultSet) XdrValue() interface{} { return v } -func (v *TransactionResultSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionResultSet) XdrRecurse(x XDR, name string) { +func (v *ConfigUpgradeSet) XdrPointer() interface{} { return v } +func (ConfigUpgradeSet) XdrTypeName() string { return "ConfigUpgradeSet" } +func (v ConfigUpgradeSet) XdrValue() interface{} { return v } +func (v *ConfigUpgradeSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ConfigUpgradeSet) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sresults", name), (*_XdrVec_unbounded_TransactionResultPair)(&v.Results)) + x.Marshal(x.Sprintf("%supdatedEntry", name), (*_XdrVec_unbounded_ConfigSettingEntry)(&v.UpdatedEntry)) } -func XDR_TransactionResultSet(v *TransactionResultSet) *TransactionResultSet { return v } +func XDR_ConfigUpgradeSet(v *ConfigUpgradeSet) *ConfigUpgradeSet { return v } -var _XdrTags_XdrAnon_TransactionHistoryEntry_Ext = map[int32]bool{ - XdrToI32(0): true, - XdrToI32(1): true, +var _XdrNames_TxSetComponentType = map[int32]string{ + int32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE): "TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE", +} +var _XdrValues_TxSetComponentType = map[string]int32{ + "TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE": int32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE), } -func (_ XdrAnon_TransactionHistoryEntry_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_TransactionHistoryEntry_Ext +func (TxSetComponentType) XdrEnumNames() map[int32]string { + return _XdrNames_TxSetComponentType } -func (u *XdrAnon_TransactionHistoryEntry_Ext) GeneralizedTxSet() *GeneralizedTransactionSet { - switch u.V { - case 1: - if v, ok := u._u.(*GeneralizedTransactionSet); ok { - return v - } else { - var zero GeneralizedTransactionSet - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_TransactionHistoryEntry_Ext.GeneralizedTxSet accessed when V == %v", u.V) - return nil +func (v TxSetComponentType) String() string { + if s, ok := _XdrNames_TxSetComponentType[int32(v)]; ok { + return s } + return fmt.Sprintf("TxSetComponentType#%d", v) } -func (u XdrAnon_TransactionHistoryEntry_Ext) XdrValid() bool { - switch u.V { - case 0, 1: - return true +func (v *TxSetComponentType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_TxSetComponentType[stok]; ok { + *v = TxSetComponentType(val) + return nil + } else if stok == "TxSetComponentType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid TxSetComponentType.", stok)) } - return false -} -func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionTag() XdrNum32 { - return XDR_int32(&u.V) } -func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionTagName() string { - return "V" -} -func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionBody() XdrType { - switch u.V { - case 0: - return nil - case 1: - return XDR_GeneralizedTransactionSet(u.GeneralizedTxSet()) +func (v TxSetComponentType) GetU32() uint32 { return uint32(v) } +func (v *TxSetComponentType) SetU32(n uint32) { *v = TxSetComponentType(n) } +func (v *TxSetComponentType) XdrPointer() interface{} { return v } +func (TxSetComponentType) XdrTypeName() string { return "TxSetComponentType" } +func (v TxSetComponentType) XdrValue() interface{} { return v } +func (v *TxSetComponentType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_TxSetComponentType = *TxSetComponentType + +func XDR_TxSetComponentType(v *TxSetComponentType) *TxSetComponentType { return v } + +var _XdrComments_TxSetComponentType = map[int32]string{ + int32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE): "txs with effective fee <= bid derived from a base fee (if any). If base fee is not specified, no discount is applied.", +} + +func (e TxSetComponentType) XdrEnumComments() map[int32]string { + return _XdrComments_TxSetComponentType +} + +type _XdrPtr_Int64 struct { + p **Int64 +} +type _ptrflag_Int64 _XdrPtr_Int64 + +func (v _ptrflag_Int64) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" +} +func (v _ptrflag_Int64) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) + default: + return XdrError("Int64 flag should be \"nil\" or \"non-nil\"") } return nil } -func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionBodyName() string { - switch u.V { +func (v _ptrflag_Int64) GetU32() uint32 { + if *v.p == nil { + return 0 + } + return 1 +} +func (v _ptrflag_Int64) SetU32(nv uint32) { + switch nv { case 0: - return "" + *v.p = nil case 1: - return "GeneralizedTxSet" + if *v.p == nil { + *v.p = new(Int64) + } + default: + XdrPanic("*Int64 present flag value %d should be 0 or 1", nv) } - return "" } +func (_ptrflag_Int64) XdrTypeName() string { return "Int64?" } +func (v _ptrflag_Int64) XdrPointer() interface{} { return nil } +func (v _ptrflag_Int64) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_Int64) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_Int64) XdrBound() uint32 { return 1 } +func (v _XdrPtr_Int64) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_Int64) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(Int64) + } +} +func (v _XdrPtr_Int64) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_Int64(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_Int64) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_Int64) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_Int64(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_Int64) XdrTypeName() string { return "Int64*" } +func (v _XdrPtr_Int64) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_Int64) XdrValue() interface{} { return *v.p } -type XdrType_XdrAnon_TransactionHistoryEntry_Ext = *XdrAnon_TransactionHistoryEntry_Ext +type _XdrVec_unbounded_TransactionEnvelope []TransactionEnvelope -func (v *XdrAnon_TransactionHistoryEntry_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_TransactionHistoryEntry_Ext) XdrTypeName() string { - return "XdrAnon_TransactionHistoryEntry_Ext" +func (_XdrVec_unbounded_TransactionEnvelope) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v XdrAnon_TransactionHistoryEntry_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_TransactionHistoryEntry_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (_XdrVec_unbounded_TransactionEnvelope) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_TransactionEnvelope length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_TransactionEnvelope length %d exceeds max int", length) } - XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) - switch u.V { - case 0: - return - case 1: - x.Marshal(x.Sprintf("%sgeneralizedTxSet", name), XDR_GeneralizedTransactionSet(u.GeneralizedTxSet())) +} +func (v _XdrVec_unbounded_TransactionEnvelope) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_TransactionEnvelope) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } return } - XdrPanic("invalid V (%v) in XdrAnon_TransactionHistoryEntry_Ext", u.V) + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]TransactionEnvelope, int(length), newcap) + copy(nv, *v) + *v = nv } -func XDR_XdrAnon_TransactionHistoryEntry_Ext(v *XdrAnon_TransactionHistoryEntry_Ext) *XdrAnon_TransactionHistoryEntry_Ext { - return v +func (v *_XdrVec_unbounded_TransactionEnvelope) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_TransactionEnvelope(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] + } +} +func (v *_XdrVec_unbounded_TransactionEnvelope) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_unbounded_TransactionEnvelope) XdrTypeName() string { return "TransactionEnvelope<>" } +func (v *_XdrVec_unbounded_TransactionEnvelope) XdrPointer() interface{} { + return (*[]TransactionEnvelope)(v) +} +func (v _XdrVec_unbounded_TransactionEnvelope) XdrValue() interface{} { + return ([]TransactionEnvelope)(v) } +func (v *_XdrVec_unbounded_TransactionEnvelope) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_TransactionHistoryEntry = *TransactionHistoryEntry +type XdrType_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee = *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee -func (v *TransactionHistoryEntry) XdrPointer() interface{} { return v } -func (TransactionHistoryEntry) XdrTypeName() string { return "TransactionHistoryEntry" } -func (v TransactionHistoryEntry) XdrValue() interface{} { return v } -func (v *TransactionHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionHistoryEntry) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrPointer() interface{} { return v } +func (XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrTypeName() string { + return "XdrAnon_TxSetComponent_TxsMaybeDiscountedFee" +} +func (v XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrValue() interface{} { return v } +func (v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrMarshal(x XDR, name string) { + x.Marshal(name, v) +} +func (v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) - x.Marshal(x.Sprintf("%stxSet", name), XDR_TransactionSet(&v.TxSet)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_TransactionHistoryEntry_Ext(&v.Ext)) + x.Marshal(x.Sprintf("%sbaseFee", name), _XdrPtr_Int64{&v.BaseFee}) + x.Marshal(x.Sprintf("%stxs", name), (*_XdrVec_unbounded_TransactionEnvelope)(&v.Txs)) +} +func XDR_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee(v *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee) *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee { + return v } -func XDR_TransactionHistoryEntry(v *TransactionHistoryEntry) *TransactionHistoryEntry { return v } -var _XdrTags_XdrAnon_TransactionHistoryResultEntry_Ext = map[int32]bool{ - XdrToI32(0): true, +var _XdrTags_TxSetComponent = map[int32]bool{ + XdrToI32(TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE): true, } -func (_ XdrAnon_TransactionHistoryResultEntry_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_TransactionHistoryResultEntry_Ext +func (_ TxSetComponent) XdrValidTags() map[int32]bool { + return _XdrTags_TxSetComponent } -func (u XdrAnon_TransactionHistoryResultEntry_Ext) XdrValid() bool { - switch u.V { - case 0: +func (u *TxSetComponent) TxsMaybeDiscountedFee() *XdrAnon_TxSetComponent_TxsMaybeDiscountedFee { + switch u.Type { + case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: + if v, ok := u._u.(*XdrAnon_TxSetComponent_TxsMaybeDiscountedFee); ok { + return v + } else { + var zero XdrAnon_TxSetComponent_TxsMaybeDiscountedFee + u._u = &zero + return &zero + } + default: + XdrPanic("TxSetComponent.TxsMaybeDiscountedFee accessed when Type == %v", u.Type) + return nil + } +} +func (u TxSetComponent) XdrValid() bool { + switch u.Type { + case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: return true } return false } -func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionTag() XdrNum32 { - return XDR_int32(&u.V) +func (u *TxSetComponent) XdrUnionTag() XdrNum32 { + return XDR_TxSetComponentType(&u.Type) } -func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionTagName() string { - return "V" +func (u *TxSetComponent) XdrUnionTagName() string { + return "Type" } -func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionBody() XdrType { - switch u.V { - case 0: - return nil +func (u *TxSetComponent) XdrUnionBody() XdrType { + switch u.Type { + case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: + return XDR_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee(u.TxsMaybeDiscountedFee()) } return nil } -func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionBodyName() string { - switch u.V { - case 0: - return "" +func (u *TxSetComponent) XdrUnionBodyName() string { + switch u.Type { + case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: + return "TxsMaybeDiscountedFee" } return "" } -type XdrType_XdrAnon_TransactionHistoryResultEntry_Ext = *XdrAnon_TransactionHistoryResultEntry_Ext +type XdrType_TxSetComponent = *TxSetComponent -func (v *XdrAnon_TransactionHistoryResultEntry_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_TransactionHistoryResultEntry_Ext) XdrTypeName() string { - return "XdrAnon_TransactionHistoryResultEntry_Ext" -} -func (v XdrAnon_TransactionHistoryResultEntry_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_TransactionHistoryResultEntry_Ext) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} -func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v *TxSetComponent) XdrPointer() interface{} { return v } +func (TxSetComponent) XdrTypeName() string { return "TxSetComponent" } +func (v TxSetComponent) XdrValue() interface{} { return v } +func (v *TxSetComponent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *TxSetComponent) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) - switch u.V { - case 0: + XDR_TxSetComponentType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: + x.Marshal(x.Sprintf("%stxsMaybeDiscountedFee", name), XDR_XdrAnon_TxSetComponent_TxsMaybeDiscountedFee(u.TxsMaybeDiscountedFee())) return } - XdrPanic("invalid V (%v) in XdrAnon_TransactionHistoryResultEntry_Ext", u.V) -} -func XDR_XdrAnon_TransactionHistoryResultEntry_Ext(v *XdrAnon_TransactionHistoryResultEntry_Ext) *XdrAnon_TransactionHistoryResultEntry_Ext { - return v + XdrPanic("invalid Type (%v) in TxSetComponent", u.Type) } +func XDR_TxSetComponent(v *TxSetComponent) *TxSetComponent { return v } -type XdrType_TransactionHistoryResultEntry = *TransactionHistoryResultEntry +type _XdrVec_unbounded_TxSetComponent []TxSetComponent -func (v *TransactionHistoryResultEntry) XdrPointer() interface{} { return v } -func (TransactionHistoryResultEntry) XdrTypeName() string { return "TransactionHistoryResultEntry" } -func (v TransactionHistoryResultEntry) XdrValue() interface{} { return v } -func (v *TransactionHistoryResultEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionHistoryResultEntry) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (_XdrVec_unbounded_TxSetComponent) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound +} +func (_XdrVec_unbounded_TxSetComponent) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_TxSetComponent length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_TxSetComponent length %d exceeds max int", length) } - x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) - x.Marshal(x.Sprintf("%stxResultSet", name), XDR_TransactionResultSet(&v.TxResultSet)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_TransactionHistoryResultEntry_Ext(&v.Ext)) } -func XDR_TransactionHistoryResultEntry(v *TransactionHistoryResultEntry) *TransactionHistoryResultEntry { - return v +func (v _XdrVec_unbounded_TxSetComponent) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_TxSetComponent) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return + } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]TxSetComponent, int(length), newcap) + copy(nv, *v) + *v = nv } +func (v *_XdrVec_unbounded_TxSetComponent) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_TxSetComponent(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] + } +} +func (v *_XdrVec_unbounded_TxSetComponent) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_unbounded_TxSetComponent) XdrTypeName() string { return "TxSetComponent<>" } +func (v *_XdrVec_unbounded_TxSetComponent) XdrPointer() interface{} { return (*[]TxSetComponent)(v) } +func (v _XdrVec_unbounded_TxSetComponent) XdrValue() interface{} { return ([]TxSetComponent)(v) } +func (v *_XdrVec_unbounded_TxSetComponent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -var _XdrTags_XdrAnon_LedgerHeaderHistoryEntry_Ext = map[int32]bool{ +var _XdrTags_TransactionPhase = map[int32]bool{ XdrToI32(0): true, } -func (_ XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_LedgerHeaderHistoryEntry_Ext +func (_ TransactionPhase) XdrValidTags() map[int32]bool { + return _XdrTags_TransactionPhase } -func (u XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrValid() bool { +func (u *TransactionPhase) V0Components() *[]TxSetComponent { + switch u.V { + case 0: + if v, ok := u._u.(*[]TxSetComponent); ok { + return v + } else { + var zero []TxSetComponent + u._u = &zero + return &zero + } + default: + XdrPanic("TransactionPhase.V0Components accessed when V == %v", u.V) + return nil + } +} +func (u TransactionPhase) XdrValid() bool { switch u.V { case 0: return true } return false } -func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionTag() XdrNum32 { +func (u *TransactionPhase) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionTagName() string { +func (u *TransactionPhase) XdrUnionTagName() string { return "V" } -func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionBody() XdrType { +func (u *TransactionPhase) XdrUnionBody() XdrType { switch u.V { case 0: - return nil + return (*_XdrVec_unbounded_TxSetComponent)(u.V0Components()) } return nil } -func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionBodyName() string { +func (u *TransactionPhase) XdrUnionBodyName() string { switch u.V { case 0: - return "" + return "V0Components" } return "" } -type XdrType_XdrAnon_LedgerHeaderHistoryEntry_Ext = *XdrAnon_LedgerHeaderHistoryEntry_Ext +type XdrType_TransactionPhase = *TransactionPhase -func (v *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrTypeName() string { - return "XdrAnon_LedgerHeaderHistoryEntry_Ext" -} -func (v XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrRecurse(x XDR, name string) { +func (v *TransactionPhase) XdrPointer() interface{} { return v } +func (TransactionPhase) XdrTypeName() string { return "TransactionPhase" } +func (v TransactionPhase) XdrValue() interface{} { return v } +func (v *TransactionPhase) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *TransactionPhase) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { case 0: + x.Marshal(x.Sprintf("%sv0Components", name), (*_XdrVec_unbounded_TxSetComponent)(u.V0Components())) return } - XdrPanic("invalid V (%v) in XdrAnon_LedgerHeaderHistoryEntry_Ext", u.V) -} -func XDR_XdrAnon_LedgerHeaderHistoryEntry_Ext(v *XdrAnon_LedgerHeaderHistoryEntry_Ext) *XdrAnon_LedgerHeaderHistoryEntry_Ext { - return v + XdrPanic("invalid V (%v) in TransactionPhase", u.V) } +func XDR_TransactionPhase(v *TransactionPhase) *TransactionPhase { return v } -type XdrType_LedgerHeaderHistoryEntry = *LedgerHeaderHistoryEntry +type XdrType_TransactionSet = *TransactionSet -func (v *LedgerHeaderHistoryEntry) XdrPointer() interface{} { return v } -func (LedgerHeaderHistoryEntry) XdrTypeName() string { return "LedgerHeaderHistoryEntry" } -func (v LedgerHeaderHistoryEntry) XdrValue() interface{} { return v } -func (v *LedgerHeaderHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerHeaderHistoryEntry) XdrRecurse(x XDR, name string) { +func (v *TransactionSet) XdrPointer() interface{} { return v } +func (TransactionSet) XdrTypeName() string { return "TransactionSet" } +func (v TransactionSet) XdrValue() interface{} { return v } +func (v *TransactionSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionSet) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%shash", name), XDR_Hash(&v.Hash)) - x.Marshal(x.Sprintf("%sheader", name), XDR_LedgerHeader(&v.Header)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_LedgerHeaderHistoryEntry_Ext(&v.Ext)) + x.Marshal(x.Sprintf("%spreviousLedgerHash", name), XDR_Hash(&v.PreviousLedgerHash)) + x.Marshal(x.Sprintf("%stxs", name), (*_XdrVec_unbounded_TransactionEnvelope)(&v.Txs)) } -func XDR_LedgerHeaderHistoryEntry(v *LedgerHeaderHistoryEntry) *LedgerHeaderHistoryEntry { return v } +func XDR_TransactionSet(v *TransactionSet) *TransactionSet { return v } -type _XdrVec_unbounded_SCPEnvelope []SCPEnvelope +type _XdrVec_unbounded_TransactionPhase []TransactionPhase -func (_XdrVec_unbounded_SCPEnvelope) XdrBound() uint32 { +func (_XdrVec_unbounded_TransactionPhase) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_SCPEnvelope) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_TransactionPhase) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_SCPEnvelope length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_TransactionPhase length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_SCPEnvelope length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_TransactionPhase length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_SCPEnvelope) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_SCPEnvelope) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_TransactionPhase) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_TransactionPhase) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -11284,346 +11556,159 @@ func (v *_XdrVec_unbounded_SCPEnvelope) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]SCPEnvelope, int(length), newcap) + nv := make([]TransactionPhase, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_SCPEnvelope) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_TransactionPhase) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_SCPEnvelope(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_TransactionPhase(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_SCPEnvelope) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_TransactionPhase) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_SCPEnvelope) XdrTypeName() string { return "SCPEnvelope<>" } -func (v *_XdrVec_unbounded_SCPEnvelope) XdrPointer() interface{} { return (*[]SCPEnvelope)(v) } -func (v _XdrVec_unbounded_SCPEnvelope) XdrValue() interface{} { return ([]SCPEnvelope)(v) } -func (v *_XdrVec_unbounded_SCPEnvelope) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_LedgerSCPMessages = *LedgerSCPMessages - -func (v *LedgerSCPMessages) XdrPointer() interface{} { return v } -func (LedgerSCPMessages) XdrTypeName() string { return "LedgerSCPMessages" } -func (v LedgerSCPMessages) XdrValue() interface{} { return v } -func (v *LedgerSCPMessages) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerSCPMessages) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) - x.Marshal(x.Sprintf("%smessages", name), (*_XdrVec_unbounded_SCPEnvelope)(&v.Messages)) +func (_XdrVec_unbounded_TransactionPhase) XdrTypeName() string { return "TransactionPhase<>" } +func (v *_XdrVec_unbounded_TransactionPhase) XdrPointer() interface{} { + return (*[]TransactionPhase)(v) } -func XDR_LedgerSCPMessages(v *LedgerSCPMessages) *LedgerSCPMessages { return v } +func (v _XdrVec_unbounded_TransactionPhase) XdrValue() interface{} { return ([]TransactionPhase)(v) } +func (v *_XdrVec_unbounded_TransactionPhase) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_SCPHistoryEntryV0 = *SCPHistoryEntryV0 +type XdrType_TransactionSetV1 = *TransactionSetV1 -func (v *SCPHistoryEntryV0) XdrPointer() interface{} { return v } -func (SCPHistoryEntryV0) XdrTypeName() string { return "SCPHistoryEntryV0" } -func (v SCPHistoryEntryV0) XdrValue() interface{} { return v } -func (v *SCPHistoryEntryV0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SCPHistoryEntryV0) XdrRecurse(x XDR, name string) { +func (v *TransactionSetV1) XdrPointer() interface{} { return v } +func (TransactionSetV1) XdrTypeName() string { return "TransactionSetV1" } +func (v TransactionSetV1) XdrValue() interface{} { return v } +func (v *TransactionSetV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionSetV1) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%squorumSets", name), (*_XdrVec_unbounded_SCPQuorumSet)(&v.QuorumSets)) - x.Marshal(x.Sprintf("%sledgerMessages", name), XDR_LedgerSCPMessages(&v.LedgerMessages)) + x.Marshal(x.Sprintf("%spreviousLedgerHash", name), XDR_Hash(&v.PreviousLedgerHash)) + x.Marshal(x.Sprintf("%sphases", name), (*_XdrVec_unbounded_TransactionPhase)(&v.Phases)) } -func XDR_SCPHistoryEntryV0(v *SCPHistoryEntryV0) *SCPHistoryEntryV0 { return v } +func XDR_TransactionSetV1(v *TransactionSetV1) *TransactionSetV1 { return v } -var _XdrTags_SCPHistoryEntry = map[int32]bool{ - XdrToI32(0): true, +var _XdrTags_GeneralizedTransactionSet = map[int32]bool{ + XdrToI32(1): true, } -func (_ SCPHistoryEntry) XdrValidTags() map[int32]bool { - return _XdrTags_SCPHistoryEntry +func (_ GeneralizedTransactionSet) XdrValidTags() map[int32]bool { + return _XdrTags_GeneralizedTransactionSet } -func (u *SCPHistoryEntry) V0() *SCPHistoryEntryV0 { +func (u *GeneralizedTransactionSet) V1TxSet() *TransactionSetV1 { switch u.V { - case 0: - if v, ok := u._u.(*SCPHistoryEntryV0); ok { + case 1: + if v, ok := u._u.(*TransactionSetV1); ok { return v } else { - var zero SCPHistoryEntryV0 + var zero TransactionSetV1 u._u = &zero return &zero } default: - XdrPanic("SCPHistoryEntry.V0 accessed when V == %v", u.V) + XdrPanic("GeneralizedTransactionSet.V1TxSet accessed when V == %v", u.V) return nil } } -func (u SCPHistoryEntry) XdrValid() bool { +func (u GeneralizedTransactionSet) XdrValid() bool { switch u.V { - case 0: + case 1: return true } return false } -func (u *SCPHistoryEntry) XdrUnionTag() XdrNum32 { +func (u *GeneralizedTransactionSet) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *SCPHistoryEntry) XdrUnionTagName() string { +func (u *GeneralizedTransactionSet) XdrUnionTagName() string { return "V" } -func (u *SCPHistoryEntry) XdrUnionBody() XdrType { +func (u *GeneralizedTransactionSet) XdrUnionBody() XdrType { switch u.V { - case 0: - return XDR_SCPHistoryEntryV0(u.V0()) + case 1: + return XDR_TransactionSetV1(u.V1TxSet()) } return nil } -func (u *SCPHistoryEntry) XdrUnionBodyName() string { +func (u *GeneralizedTransactionSet) XdrUnionBodyName() string { switch u.V { - case 0: - return "V0" + case 1: + return "V1TxSet" } return "" } -type XdrType_SCPHistoryEntry = *SCPHistoryEntry +type XdrType_GeneralizedTransactionSet = *GeneralizedTransactionSet -func (v *SCPHistoryEntry) XdrPointer() interface{} { return v } -func (SCPHistoryEntry) XdrTypeName() string { return "SCPHistoryEntry" } -func (v SCPHistoryEntry) XdrValue() interface{} { return v } -func (v *SCPHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *SCPHistoryEntry) XdrRecurse(x XDR, name string) { +func (v *GeneralizedTransactionSet) XdrPointer() interface{} { return v } +func (GeneralizedTransactionSet) XdrTypeName() string { return "GeneralizedTransactionSet" } +func (v GeneralizedTransactionSet) XdrValue() interface{} { return v } +func (v *GeneralizedTransactionSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *GeneralizedTransactionSet) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { - case 0: - x.Marshal(x.Sprintf("%sv0", name), XDR_SCPHistoryEntryV0(u.V0())) + case 1: + x.Marshal(x.Sprintf("%sv1TxSet", name), XDR_TransactionSetV1(u.V1TxSet())) return } - XdrPanic("invalid V (%v) in SCPHistoryEntry", u.V) -} -func XDR_SCPHistoryEntry(v *SCPHistoryEntry) *SCPHistoryEntry { return v } - -var _XdrNames_LedgerEntryChangeType = map[int32]string{ - int32(LEDGER_ENTRY_CREATED): "LEDGER_ENTRY_CREATED", - int32(LEDGER_ENTRY_UPDATED): "LEDGER_ENTRY_UPDATED", - int32(LEDGER_ENTRY_REMOVED): "LEDGER_ENTRY_REMOVED", - int32(LEDGER_ENTRY_STATE): "LEDGER_ENTRY_STATE", -} -var _XdrValues_LedgerEntryChangeType = map[string]int32{ - "LEDGER_ENTRY_CREATED": int32(LEDGER_ENTRY_CREATED), - "LEDGER_ENTRY_UPDATED": int32(LEDGER_ENTRY_UPDATED), - "LEDGER_ENTRY_REMOVED": int32(LEDGER_ENTRY_REMOVED), - "LEDGER_ENTRY_STATE": int32(LEDGER_ENTRY_STATE), -} - -func (LedgerEntryChangeType) XdrEnumNames() map[int32]string { - return _XdrNames_LedgerEntryChangeType -} -func (v LedgerEntryChangeType) String() string { - if s, ok := _XdrNames_LedgerEntryChangeType[int32(v)]; ok { - return s - } - return fmt.Sprintf("LedgerEntryChangeType#%d", v) -} -func (v *LedgerEntryChangeType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_LedgerEntryChangeType[stok]; ok { - *v = LedgerEntryChangeType(val) - return nil - } else if stok == "LedgerEntryChangeType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid LedgerEntryChangeType.", stok)) - } -} -func (v LedgerEntryChangeType) GetU32() uint32 { return uint32(v) } -func (v *LedgerEntryChangeType) SetU32(n uint32) { *v = LedgerEntryChangeType(n) } -func (v *LedgerEntryChangeType) XdrPointer() interface{} { return v } -func (LedgerEntryChangeType) XdrTypeName() string { return "LedgerEntryChangeType" } -func (v LedgerEntryChangeType) XdrValue() interface{} { return v } -func (v *LedgerEntryChangeType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_LedgerEntryChangeType = *LedgerEntryChangeType - -func XDR_LedgerEntryChangeType(v *LedgerEntryChangeType) *LedgerEntryChangeType { return v } - -var _XdrComments_LedgerEntryChangeType = map[int32]string{ - int32(LEDGER_ENTRY_CREATED): "entry was added to the ledger", - int32(LEDGER_ENTRY_UPDATED): "entry was modified in the ledger", - int32(LEDGER_ENTRY_REMOVED): "entry was removed from the ledger", - int32(LEDGER_ENTRY_STATE): "value of the entry", -} - -func (e LedgerEntryChangeType) XdrEnumComments() map[int32]string { - return _XdrComments_LedgerEntryChangeType -} - -var _XdrTags_LedgerEntryChange = map[int32]bool{ - XdrToI32(LEDGER_ENTRY_CREATED): true, - XdrToI32(LEDGER_ENTRY_UPDATED): true, - XdrToI32(LEDGER_ENTRY_REMOVED): true, - XdrToI32(LEDGER_ENTRY_STATE): true, -} - -func (_ LedgerEntryChange) XdrValidTags() map[int32]bool { - return _XdrTags_LedgerEntryChange -} -func (u *LedgerEntryChange) Created() *LedgerEntry { - switch u.Type { - case LEDGER_ENTRY_CREATED: - if v, ok := u._u.(*LedgerEntry); ok { - return v - } else { - var zero LedgerEntry - u._u = &zero - return &zero - } - default: - XdrPanic("LedgerEntryChange.Created accessed when Type == %v", u.Type) - return nil - } -} -func (u *LedgerEntryChange) Updated() *LedgerEntry { - switch u.Type { - case LEDGER_ENTRY_UPDATED: - if v, ok := u._u.(*LedgerEntry); ok { - return v - } else { - var zero LedgerEntry - u._u = &zero - return &zero - } - default: - XdrPanic("LedgerEntryChange.Updated accessed when Type == %v", u.Type) - return nil - } + XdrPanic("invalid V (%v) in GeneralizedTransactionSet", u.V) } -func (u *LedgerEntryChange) Removed() *LedgerKey { - switch u.Type { - case LEDGER_ENTRY_REMOVED: - if v, ok := u._u.(*LedgerKey); ok { - return v - } else { - var zero LedgerKey - u._u = &zero - return &zero - } +func (v *GeneralizedTransactionSet) XdrInitialize() { + var zero int32 + switch zero { + case 1: default: - XdrPanic("LedgerEntryChange.Removed accessed when Type == %v", u.Type) - return nil - } -} -func (u *LedgerEntryChange) State() *LedgerEntry { - switch u.Type { - case LEDGER_ENTRY_STATE: - if v, ok := u._u.(*LedgerEntry); ok { - return v - } else { - var zero LedgerEntry - u._u = &zero - return &zero + if v.V == zero { + v.V = 1 } - default: - XdrPanic("LedgerEntryChange.State accessed when Type == %v", u.Type) - return nil - } -} -func (u LedgerEntryChange) XdrValid() bool { - switch u.Type { - case LEDGER_ENTRY_CREATED, LEDGER_ENTRY_UPDATED, LEDGER_ENTRY_REMOVED, LEDGER_ENTRY_STATE: - return true - } - return false -} -func (u *LedgerEntryChange) XdrUnionTag() XdrNum32 { - return XDR_LedgerEntryChangeType(&u.Type) -} -func (u *LedgerEntryChange) XdrUnionTagName() string { - return "Type" -} -func (u *LedgerEntryChange) XdrUnionBody() XdrType { - switch u.Type { - case LEDGER_ENTRY_CREATED: - return XDR_LedgerEntry(u.Created()) - case LEDGER_ENTRY_UPDATED: - return XDR_LedgerEntry(u.Updated()) - case LEDGER_ENTRY_REMOVED: - return XDR_LedgerKey(u.Removed()) - case LEDGER_ENTRY_STATE: - return XDR_LedgerEntry(u.State()) - } - return nil -} -func (u *LedgerEntryChange) XdrUnionBodyName() string { - switch u.Type { - case LEDGER_ENTRY_CREATED: - return "Created" - case LEDGER_ENTRY_UPDATED: - return "Updated" - case LEDGER_ENTRY_REMOVED: - return "Removed" - case LEDGER_ENTRY_STATE: - return "State" } - return "" } +func XDR_GeneralizedTransactionSet(v *GeneralizedTransactionSet) *GeneralizedTransactionSet { return v } -type XdrType_LedgerEntryChange = *LedgerEntryChange +type XdrType_TransactionResultPair = *TransactionResultPair -func (v *LedgerEntryChange) XdrPointer() interface{} { return v } -func (LedgerEntryChange) XdrTypeName() string { return "LedgerEntryChange" } -func (v LedgerEntryChange) XdrValue() interface{} { return v } -func (v *LedgerEntryChange) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *LedgerEntryChange) XdrRecurse(x XDR, name string) { +func (v *TransactionResultPair) XdrPointer() interface{} { return v } +func (TransactionResultPair) XdrTypeName() string { return "TransactionResultPair" } +func (v TransactionResultPair) XdrValue() interface{} { return v } +func (v *TransactionResultPair) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionResultPair) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_LedgerEntryChangeType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case LEDGER_ENTRY_CREATED: - x.Marshal(x.Sprintf("%screated", name), XDR_LedgerEntry(u.Created())) - return - case LEDGER_ENTRY_UPDATED: - x.Marshal(x.Sprintf("%supdated", name), XDR_LedgerEntry(u.Updated())) - return - case LEDGER_ENTRY_REMOVED: - x.Marshal(x.Sprintf("%sremoved", name), XDR_LedgerKey(u.Removed())) - return - case LEDGER_ENTRY_STATE: - x.Marshal(x.Sprintf("%sstate", name), XDR_LedgerEntry(u.State())) - return - } - XdrPanic("invalid Type (%v) in LedgerEntryChange", u.Type) + x.Marshal(x.Sprintf("%stransactionHash", name), XDR_Hash(&v.TransactionHash)) + x.Marshal(x.Sprintf("%sresult", name), XDR_TransactionResult(&v.Result)) } -func XDR_LedgerEntryChange(v *LedgerEntryChange) *LedgerEntryChange { return v } +func XDR_TransactionResultPair(v *TransactionResultPair) *TransactionResultPair { return v } -type _XdrVec_unbounded_LedgerEntryChange []LedgerEntryChange +type _XdrVec_unbounded_TransactionResultPair []TransactionResultPair -func (_XdrVec_unbounded_LedgerEntryChange) XdrBound() uint32 { +func (_XdrVec_unbounded_TransactionResultPair) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_LedgerEntryChange) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_TransactionResultPair) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_LedgerEntryChange length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_TransactionResultPair length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_LedgerEntryChange length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_TransactionResultPair length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_LedgerEntryChange) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_LedgerEntryChange) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_TransactionResultPair) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_TransactionResultPair) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -11640,459 +11725,314 @@ func (v *_XdrVec_unbounded_LedgerEntryChange) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]LedgerEntryChange, int(length), newcap) + nv := make([]TransactionResultPair, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_LedgerEntryChange) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_TransactionResultPair) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_LedgerEntryChange(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_TransactionResultPair(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_LedgerEntryChange) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_TransactionResultPair) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_LedgerEntryChange) XdrTypeName() string { return "LedgerEntryChange<>" } -func (v *_XdrVec_unbounded_LedgerEntryChange) XdrPointer() interface{} { - return (*[]LedgerEntryChange)(v) -} -func (v _XdrVec_unbounded_LedgerEntryChange) XdrValue() interface{} { return ([]LedgerEntryChange)(v) } -func (v *_XdrVec_unbounded_LedgerEntryChange) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_LedgerEntryChanges struct { - *_XdrVec_unbounded_LedgerEntryChange +func (_XdrVec_unbounded_TransactionResultPair) XdrTypeName() string { return "TransactionResultPair<>" } +func (v *_XdrVec_unbounded_TransactionResultPair) XdrPointer() interface{} { + return (*[]TransactionResultPair)(v) } - -func XDR_LedgerEntryChanges(v *LedgerEntryChanges) XdrType_LedgerEntryChanges { - return XdrType_LedgerEntryChanges{(*_XdrVec_unbounded_LedgerEntryChange)(v)} +func (v _XdrVec_unbounded_TransactionResultPair) XdrValue() interface{} { + return ([]TransactionResultPair)(v) } -func (XdrType_LedgerEntryChanges) XdrTypeName() string { return "LedgerEntryChanges" } -func (v XdrType_LedgerEntryChanges) XdrUnwrap() XdrType { return v._XdrVec_unbounded_LedgerEntryChange } +func (v *_XdrVec_unbounded_TransactionResultPair) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_OperationMeta = *OperationMeta +type XdrType_TransactionResultSet = *TransactionResultSet -func (v *OperationMeta) XdrPointer() interface{} { return v } -func (OperationMeta) XdrTypeName() string { return "OperationMeta" } -func (v OperationMeta) XdrValue() interface{} { return v } -func (v *OperationMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *OperationMeta) XdrRecurse(x XDR, name string) { +func (v *TransactionResultSet) XdrPointer() interface{} { return v } +func (TransactionResultSet) XdrTypeName() string { return "TransactionResultSet" } +func (v TransactionResultSet) XdrValue() interface{} { return v } +func (v *TransactionResultSet) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionResultSet) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%schanges", name), XDR_LedgerEntryChanges(&v.Changes)) + x.Marshal(x.Sprintf("%sresults", name), (*_XdrVec_unbounded_TransactionResultPair)(&v.Results)) } -func XDR_OperationMeta(v *OperationMeta) *OperationMeta { return v } - -type _XdrVec_unbounded_OperationMeta []OperationMeta +func XDR_TransactionResultSet(v *TransactionResultSet) *TransactionResultSet { return v } -func (_XdrVec_unbounded_OperationMeta) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound +var _XdrTags_XdrAnon_TransactionHistoryEntry_Ext = map[int32]bool{ + XdrToI32(0): true, + XdrToI32(1): true, } -func (_XdrVec_unbounded_OperationMeta) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_OperationMeta length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_OperationMeta length %d exceeds max int", length) - } + +func (_ XdrAnon_TransactionHistoryEntry_Ext) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_TransactionHistoryEntry_Ext } -func (v _XdrVec_unbounded_OperationMeta) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_OperationMeta) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 +func (u *XdrAnon_TransactionHistoryEntry_Ext) GeneralizedTxSet() *GeneralizedTransactionSet { + switch u.V { + case 1: + if v, ok := u._u.(*GeneralizedTransactionSet); ok { + return v + } else { + var zero GeneralizedTransactionSet + u._u = &zero + return &zero } - newcap = int(bound) + default: + XdrPanic("XdrAnon_TransactionHistoryEntry_Ext.GeneralizedTxSet accessed when V == %v", u.V) + return nil } - nv := make([]OperationMeta, int(length), newcap) - copy(nv, *v) - *v = nv } -func (v *_XdrVec_unbounded_OperationMeta) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_OperationMeta(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) +func (u XdrAnon_TransactionHistoryEntry_Ext) XdrValid() bool { + switch u.V { + case 0, 1: + return true } - if int(n) < len(*v) { - *v = (*v)[:int(n)] + return false +} +func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionTag() XdrNum32 { + return XDR_int32(&u.V) +} +func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionTagName() string { + return "V" +} +func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionBody() XdrType { + switch u.V { + case 0: + return nil + case 1: + return XDR_GeneralizedTransactionSet(u.GeneralizedTxSet()) } + return nil } -func (v *_XdrVec_unbounded_OperationMeta) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) +func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrUnionBodyName() string { + switch u.V { + case 0: + return "" + case 1: + return "GeneralizedTxSet" + } + return "" } -func (_XdrVec_unbounded_OperationMeta) XdrTypeName() string { return "OperationMeta<>" } -func (v *_XdrVec_unbounded_OperationMeta) XdrPointer() interface{} { return (*[]OperationMeta)(v) } -func (v _XdrVec_unbounded_OperationMeta) XdrValue() interface{} { return ([]OperationMeta)(v) } -func (v *_XdrVec_unbounded_OperationMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_TransactionMetaV1 = *TransactionMetaV1 +type XdrType_XdrAnon_TransactionHistoryEntry_Ext = *XdrAnon_TransactionHistoryEntry_Ext -func (v *TransactionMetaV1) XdrPointer() interface{} { return v } -func (TransactionMetaV1) XdrTypeName() string { return "TransactionMetaV1" } -func (v TransactionMetaV1) XdrValue() interface{} { return v } -func (v *TransactionMetaV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionMetaV1) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_TransactionHistoryEntry_Ext) XdrPointer() interface{} { return v } +func (XdrAnon_TransactionHistoryEntry_Ext) XdrTypeName() string { + return "XdrAnon_TransactionHistoryEntry_Ext" +} +func (v XdrAnon_TransactionHistoryEntry_Ext) XdrValue() interface{} { return v } +func (v *XdrAnon_TransactionHistoryEntry_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_TransactionHistoryEntry_Ext) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%stxChanges", name), XDR_LedgerEntryChanges(&v.TxChanges)) - x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(&v.Operations)) + XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + switch u.V { + case 0: + return + case 1: + x.Marshal(x.Sprintf("%sgeneralizedTxSet", name), XDR_GeneralizedTransactionSet(u.GeneralizedTxSet())) + return + } + XdrPanic("invalid V (%v) in XdrAnon_TransactionHistoryEntry_Ext", u.V) +} +func XDR_XdrAnon_TransactionHistoryEntry_Ext(v *XdrAnon_TransactionHistoryEntry_Ext) *XdrAnon_TransactionHistoryEntry_Ext { + return v } -func XDR_TransactionMetaV1(v *TransactionMetaV1) *TransactionMetaV1 { return v } -type XdrType_TransactionMetaV2 = *TransactionMetaV2 +type XdrType_TransactionHistoryEntry = *TransactionHistoryEntry -func (v *TransactionMetaV2) XdrPointer() interface{} { return v } -func (TransactionMetaV2) XdrTypeName() string { return "TransactionMetaV2" } -func (v TransactionMetaV2) XdrValue() interface{} { return v } -func (v *TransactionMetaV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionMetaV2) XdrRecurse(x XDR, name string) { +func (v *TransactionHistoryEntry) XdrPointer() interface{} { return v } +func (TransactionHistoryEntry) XdrTypeName() string { return "TransactionHistoryEntry" } +func (v TransactionHistoryEntry) XdrValue() interface{} { return v } +func (v *TransactionHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionHistoryEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%stxChangesBefore", name), XDR_LedgerEntryChanges(&v.TxChangesBefore)) - x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(&v.Operations)) - x.Marshal(x.Sprintf("%stxChangesAfter", name), XDR_LedgerEntryChanges(&v.TxChangesAfter)) + x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) + x.Marshal(x.Sprintf("%stxSet", name), XDR_TransactionSet(&v.TxSet)) + x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_TransactionHistoryEntry_Ext(&v.Ext)) } -func XDR_TransactionMetaV2(v *TransactionMetaV2) *TransactionMetaV2 { return v } +func XDR_TransactionHistoryEntry(v *TransactionHistoryEntry) *TransactionHistoryEntry { return v } -var _XdrNames_ContractEventType = map[int32]string{ - int32(SYSTEM): "SYSTEM", - int32(CONTRACT): "CONTRACT", - int32(DIAGNOSTIC): "DIAGNOSTIC", -} -var _XdrValues_ContractEventType = map[string]int32{ - "SYSTEM": int32(SYSTEM), - "CONTRACT": int32(CONTRACT), - "DIAGNOSTIC": int32(DIAGNOSTIC), +var _XdrTags_XdrAnon_TransactionHistoryResultEntry_Ext = map[int32]bool{ + XdrToI32(0): true, } -func (ContractEventType) XdrEnumNames() map[int32]string { - return _XdrNames_ContractEventType +func (_ XdrAnon_TransactionHistoryResultEntry_Ext) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_TransactionHistoryResultEntry_Ext } -func (v ContractEventType) String() string { - if s, ok := _XdrNames_ContractEventType[int32(v)]; ok { - return s +func (u XdrAnon_TransactionHistoryResultEntry_Ext) XdrValid() bool { + switch u.V { + case 0: + return true } - return fmt.Sprintf("ContractEventType#%d", v) + return false } -func (v *ContractEventType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_ContractEventType[stok]; ok { - *v = ContractEventType(val) - return nil - } else if stok == "ContractEventType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid ContractEventType.", stok)) +func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionTag() XdrNum32 { + return XDR_int32(&u.V) +} +func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionTagName() string { + return "V" +} +func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionBody() XdrType { + switch u.V { + case 0: + return nil } + return nil +} +func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrUnionBodyName() string { + switch u.V { + case 0: + return "" + } + return "" } -func (v ContractEventType) GetU32() uint32 { return uint32(v) } -func (v *ContractEventType) SetU32(n uint32) { *v = ContractEventType(n) } -func (v *ContractEventType) XdrPointer() interface{} { return v } -func (ContractEventType) XdrTypeName() string { return "ContractEventType" } -func (v ContractEventType) XdrValue() interface{} { return v } -func (v *ContractEventType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_ContractEventType = *ContractEventType - -func XDR_ContractEventType(v *ContractEventType) *ContractEventType { return v } -type _XdrVec_unbounded_SCVal []SCVal +type XdrType_XdrAnon_TransactionHistoryResultEntry_Ext = *XdrAnon_TransactionHistoryResultEntry_Ext -func (_XdrVec_unbounded_SCVal) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound +func (v *XdrAnon_TransactionHistoryResultEntry_Ext) XdrPointer() interface{} { return v } +func (XdrAnon_TransactionHistoryResultEntry_Ext) XdrTypeName() string { + return "XdrAnon_TransactionHistoryResultEntry_Ext" } -func (_XdrVec_unbounded_SCVal) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_SCVal length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_SCVal length %d exceeds max int", length) - } +func (v XdrAnon_TransactionHistoryResultEntry_Ext) XdrValue() interface{} { return v } +func (v *XdrAnon_TransactionHistoryResultEntry_Ext) XdrMarshal(x XDR, name string) { + x.Marshal(name, v) } -func (v _XdrVec_unbounded_SCVal) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_SCVal) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) - } - nv := make([]SCVal, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_unbounded_SCVal) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_SCVal(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) +func (u *XdrAnon_TransactionHistoryResultEntry_Ext) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - if int(n) < len(*v) { - *v = (*v)[:int(n)] + XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + switch u.V { + case 0: + return } + XdrPanic("invalid V (%v) in XdrAnon_TransactionHistoryResultEntry_Ext", u.V) } -func (v *_XdrVec_unbounded_SCVal) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) +func XDR_XdrAnon_TransactionHistoryResultEntry_Ext(v *XdrAnon_TransactionHistoryResultEntry_Ext) *XdrAnon_TransactionHistoryResultEntry_Ext { + return v } -func (_XdrVec_unbounded_SCVal) XdrTypeName() string { return "SCVal<>" } -func (v *_XdrVec_unbounded_SCVal) XdrPointer() interface{} { return (*[]SCVal)(v) } -func (v _XdrVec_unbounded_SCVal) XdrValue() interface{} { return ([]SCVal)(v) } -func (v *_XdrVec_unbounded_SCVal) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_XdrAnon_ContractEvent_Body_V0 = *XdrAnon_ContractEvent_Body_V0 +type XdrType_TransactionHistoryResultEntry = *TransactionHistoryResultEntry -func (v *XdrAnon_ContractEvent_Body_V0) XdrPointer() interface{} { return v } -func (XdrAnon_ContractEvent_Body_V0) XdrTypeName() string { return "XdrAnon_ContractEvent_Body_V0" } -func (v XdrAnon_ContractEvent_Body_V0) XdrValue() interface{} { return v } -func (v *XdrAnon_ContractEvent_Body_V0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_ContractEvent_Body_V0) XdrRecurse(x XDR, name string) { +func (v *TransactionHistoryResultEntry) XdrPointer() interface{} { return v } +func (TransactionHistoryResultEntry) XdrTypeName() string { return "TransactionHistoryResultEntry" } +func (v TransactionHistoryResultEntry) XdrValue() interface{} { return v } +func (v *TransactionHistoryResultEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionHistoryResultEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%stopics", name), (*_XdrVec_unbounded_SCVal)(&v.Topics)) - x.Marshal(x.Sprintf("%sdata", name), XDR_SCVal(&v.Data)) + x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) + x.Marshal(x.Sprintf("%stxResultSet", name), XDR_TransactionResultSet(&v.TxResultSet)) + x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_TransactionHistoryResultEntry_Ext(&v.Ext)) } -func XDR_XdrAnon_ContractEvent_Body_V0(v *XdrAnon_ContractEvent_Body_V0) *XdrAnon_ContractEvent_Body_V0 { +func XDR_TransactionHistoryResultEntry(v *TransactionHistoryResultEntry) *TransactionHistoryResultEntry { return v } -var _XdrTags_XdrAnon_ContractEvent_Body = map[int32]bool{ +var _XdrTags_XdrAnon_LedgerHeaderHistoryEntry_Ext = map[int32]bool{ XdrToI32(0): true, } -func (_ XdrAnon_ContractEvent_Body) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_ContractEvent_Body -} -func (u *XdrAnon_ContractEvent_Body) V0() *XdrAnon_ContractEvent_Body_V0 { - switch u.V { - case 0: - if v, ok := u._u.(*XdrAnon_ContractEvent_Body_V0); ok { - return v - } else { - var zero XdrAnon_ContractEvent_Body_V0 - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_ContractEvent_Body.V0 accessed when V == %v", u.V) - return nil - } +func (_ XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_LedgerHeaderHistoryEntry_Ext } -func (u XdrAnon_ContractEvent_Body) XdrValid() bool { +func (u XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrValid() bool { switch u.V { case 0: return true } return false } -func (u *XdrAnon_ContractEvent_Body) XdrUnionTag() XdrNum32 { +func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *XdrAnon_ContractEvent_Body) XdrUnionTagName() string { +func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionTagName() string { return "V" } -func (u *XdrAnon_ContractEvent_Body) XdrUnionBody() XdrType { +func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionBody() XdrType { switch u.V { case 0: - return XDR_XdrAnon_ContractEvent_Body_V0(u.V0()) + return nil } return nil } -func (u *XdrAnon_ContractEvent_Body) XdrUnionBodyName() string { +func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrUnionBodyName() string { switch u.V { case 0: - return "V0" + return "" } return "" } -type XdrType_XdrAnon_ContractEvent_Body = *XdrAnon_ContractEvent_Body +type XdrType_XdrAnon_LedgerHeaderHistoryEntry_Ext = *XdrAnon_LedgerHeaderHistoryEntry_Ext -func (v *XdrAnon_ContractEvent_Body) XdrPointer() interface{} { return v } -func (XdrAnon_ContractEvent_Body) XdrTypeName() string { return "XdrAnon_ContractEvent_Body" } -func (v XdrAnon_ContractEvent_Body) XdrValue() interface{} { return v } -func (v *XdrAnon_ContractEvent_Body) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_ContractEvent_Body) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrPointer() interface{} { return v } +func (XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrTypeName() string { + return "XdrAnon_LedgerHeaderHistoryEntry_Ext" +} +func (v XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrValue() interface{} { return v } +func (v *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_LedgerHeaderHistoryEntry_Ext) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { case 0: - x.Marshal(x.Sprintf("%sv0", name), XDR_XdrAnon_ContractEvent_Body_V0(u.V0())) return } - XdrPanic("invalid V (%v) in XdrAnon_ContractEvent_Body", u.V) + XdrPanic("invalid V (%v) in XdrAnon_LedgerHeaderHistoryEntry_Ext", u.V) } -func XDR_XdrAnon_ContractEvent_Body(v *XdrAnon_ContractEvent_Body) *XdrAnon_ContractEvent_Body { +func XDR_XdrAnon_LedgerHeaderHistoryEntry_Ext(v *XdrAnon_LedgerHeaderHistoryEntry_Ext) *XdrAnon_LedgerHeaderHistoryEntry_Ext { return v } -type _XdrPtr_Hash struct { - p **Hash -} -type _ptrflag_Hash _XdrPtr_Hash - -func (v _ptrflag_Hash) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" -} -func (v _ptrflag_Hash) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("Hash flag should be \"nil\" or \"non-nil\"") - } - return nil -} -func (v _ptrflag_Hash) GetU32() uint32 { - if *v.p == nil { - return 0 - } - return 1 -} -func (v _ptrflag_Hash) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(Hash) - } - default: - XdrPanic("*Hash present flag value %d should be 0 or 1", nv) - } -} -func (_ptrflag_Hash) XdrTypeName() string { return "Hash?" } -func (v _ptrflag_Hash) XdrPointer() interface{} { return nil } -func (v _ptrflag_Hash) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_Hash) XdrBound() uint32 { return 1 } -func (v _XdrPtr_Hash) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_Hash) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(Hash) - } -} -func (v _XdrPtr_Hash) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_Hash(*v.p).XdrMarshal(x, name) - } -} -func (v _XdrPtr_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_Hash) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_Hash(v)) - v.XdrMarshalValue(x, name) -} -func (_XdrPtr_Hash) XdrTypeName() string { return "Hash*" } -func (v _XdrPtr_Hash) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_Hash) XdrValue() interface{} { return *v.p } - -type XdrType_ContractEvent = *ContractEvent - -func (v *ContractEvent) XdrPointer() interface{} { return v } -func (ContractEvent) XdrTypeName() string { return "ContractEvent" } -func (v ContractEvent) XdrValue() interface{} { return v } -func (v *ContractEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ContractEvent) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) - x.Marshal(x.Sprintf("%scontractID", name), _XdrPtr_Hash{&v.ContractID}) - x.Marshal(x.Sprintf("%stype", name), XDR_ContractEventType(&v.Type)) - x.Marshal(x.Sprintf("%sbody", name), XDR_XdrAnon_ContractEvent_Body(&v.Body)) -} -func XDR_ContractEvent(v *ContractEvent) *ContractEvent { return v } - -type XdrType_DiagnosticEvent = *DiagnosticEvent +type XdrType_LedgerHeaderHistoryEntry = *LedgerHeaderHistoryEntry -func (v *DiagnosticEvent) XdrPointer() interface{} { return v } -func (DiagnosticEvent) XdrTypeName() string { return "DiagnosticEvent" } -func (v DiagnosticEvent) XdrValue() interface{} { return v } -func (v *DiagnosticEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *DiagnosticEvent) XdrRecurse(x XDR, name string) { +func (v *LedgerHeaderHistoryEntry) XdrPointer() interface{} { return v } +func (LedgerHeaderHistoryEntry) XdrTypeName() string { return "LedgerHeaderHistoryEntry" } +func (v LedgerHeaderHistoryEntry) XdrValue() interface{} { return v } +func (v *LedgerHeaderHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerHeaderHistoryEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sinSuccessfulContractCall", name), XDR_bool(&v.InSuccessfulContractCall)) - x.Marshal(x.Sprintf("%sevent", name), XDR_ContractEvent(&v.Event)) + x.Marshal(x.Sprintf("%shash", name), XDR_Hash(&v.Hash)) + x.Marshal(x.Sprintf("%sheader", name), XDR_LedgerHeader(&v.Header)) + x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_LedgerHeaderHistoryEntry_Ext(&v.Ext)) } -func XDR_DiagnosticEvent(v *DiagnosticEvent) *DiagnosticEvent { return v } +func XDR_LedgerHeaderHistoryEntry(v *LedgerHeaderHistoryEntry) *LedgerHeaderHistoryEntry { return v } -type _XdrVec_unbounded_DiagnosticEvent []DiagnosticEvent +type _XdrVec_unbounded_SCPEnvelope []SCPEnvelope -func (_XdrVec_unbounded_DiagnosticEvent) XdrBound() uint32 { +func (_XdrVec_unbounded_SCPEnvelope) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_DiagnosticEvent) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_SCPEnvelope) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_SCPEnvelope length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_SCPEnvelope length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_DiagnosticEvent) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_DiagnosticEvent) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_SCPEnvelope) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_SCPEnvelope) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -12109,507 +12049,346 @@ func (v *_XdrVec_unbounded_DiagnosticEvent) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]DiagnosticEvent, int(length), newcap) + nv := make([]SCPEnvelope, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_DiagnosticEvent) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_SCPEnvelope) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_DiagnosticEvent(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_SCPEnvelope(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_DiagnosticEvent) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_SCPEnvelope) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_DiagnosticEvent) XdrTypeName() string { return "DiagnosticEvent<>" } -func (v *_XdrVec_unbounded_DiagnosticEvent) XdrPointer() interface{} { return (*[]DiagnosticEvent)(v) } -func (v _XdrVec_unbounded_DiagnosticEvent) XdrValue() interface{} { return ([]DiagnosticEvent)(v) } -func (v *_XdrVec_unbounded_DiagnosticEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (_XdrVec_unbounded_SCPEnvelope) XdrTypeName() string { return "SCPEnvelope<>" } +func (v *_XdrVec_unbounded_SCPEnvelope) XdrPointer() interface{} { return (*[]SCPEnvelope)(v) } +func (v _XdrVec_unbounded_SCPEnvelope) XdrValue() interface{} { return ([]SCPEnvelope)(v) } +func (v *_XdrVec_unbounded_SCPEnvelope) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_DiagnosticEvents struct { - *_XdrVec_unbounded_DiagnosticEvent -} +type XdrType_LedgerSCPMessages = *LedgerSCPMessages -func XDR_DiagnosticEvents(v *DiagnosticEvents) XdrType_DiagnosticEvents { - return XdrType_DiagnosticEvents{(*_XdrVec_unbounded_DiagnosticEvent)(v)} +func (v *LedgerSCPMessages) XdrPointer() interface{} { return v } +func (LedgerSCPMessages) XdrTypeName() string { return "LedgerSCPMessages" } +func (v LedgerSCPMessages) XdrValue() interface{} { return v } +func (v *LedgerSCPMessages) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerSCPMessages) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sledgerSeq", name), XDR_Uint32(&v.LedgerSeq)) + x.Marshal(x.Sprintf("%smessages", name), (*_XdrVec_unbounded_SCPEnvelope)(&v.Messages)) } -func (XdrType_DiagnosticEvents) XdrTypeName() string { return "DiagnosticEvents" } -func (v XdrType_DiagnosticEvents) XdrUnwrap() XdrType { return v._XdrVec_unbounded_DiagnosticEvent } +func XDR_LedgerSCPMessages(v *LedgerSCPMessages) *LedgerSCPMessages { return v } -type XdrType_SorobanTransactionMetaExtV1 = *SorobanTransactionMetaExtV1 +type XdrType_SCPHistoryEntryV0 = *SCPHistoryEntryV0 -func (v *SorobanTransactionMetaExtV1) XdrPointer() interface{} { return v } -func (SorobanTransactionMetaExtV1) XdrTypeName() string { return "SorobanTransactionMetaExtV1" } -func (v SorobanTransactionMetaExtV1) XdrValue() interface{} { return v } -func (v *SorobanTransactionMetaExtV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SorobanTransactionMetaExtV1) XdrRecurse(x XDR, name string) { +func (v *SCPHistoryEntryV0) XdrPointer() interface{} { return v } +func (SCPHistoryEntryV0) XdrTypeName() string { return "SCPHistoryEntryV0" } +func (v SCPHistoryEntryV0) XdrValue() interface{} { return v } +func (v *SCPHistoryEntryV0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SCPHistoryEntryV0) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) - x.Marshal(x.Sprintf("%stotalNonRefundableResourceFeeCharged", name), XDR_Int64(&v.TotalNonRefundableResourceFeeCharged)) - x.Marshal(x.Sprintf("%stotalRefundableResourceFeeCharged", name), XDR_Int64(&v.TotalRefundableResourceFeeCharged)) - x.Marshal(x.Sprintf("%srentFeeCharged", name), XDR_Int64(&v.RentFeeCharged)) -} -func XDR_SorobanTransactionMetaExtV1(v *SorobanTransactionMetaExtV1) *SorobanTransactionMetaExtV1 { - return v + x.Marshal(x.Sprintf("%squorumSets", name), (*_XdrVec_unbounded_SCPQuorumSet)(&v.QuorumSets)) + x.Marshal(x.Sprintf("%sledgerMessages", name), XDR_LedgerSCPMessages(&v.LedgerMessages)) } +func XDR_SCPHistoryEntryV0(v *SCPHistoryEntryV0) *SCPHistoryEntryV0 { return v } -var _XdrTags_SorobanTransactionMetaExt = map[int32]bool{ +var _XdrTags_SCPHistoryEntry = map[int32]bool{ XdrToI32(0): true, - XdrToI32(1): true, } -func (_ SorobanTransactionMetaExt) XdrValidTags() map[int32]bool { - return _XdrTags_SorobanTransactionMetaExt +func (_ SCPHistoryEntry) XdrValidTags() map[int32]bool { + return _XdrTags_SCPHistoryEntry } -func (u *SorobanTransactionMetaExt) V1() *SorobanTransactionMetaExtV1 { +func (u *SCPHistoryEntry) V0() *SCPHistoryEntryV0 { switch u.V { - case 1: - if v, ok := u._u.(*SorobanTransactionMetaExtV1); ok { + case 0: + if v, ok := u._u.(*SCPHistoryEntryV0); ok { return v } else { - var zero SorobanTransactionMetaExtV1 + var zero SCPHistoryEntryV0 u._u = &zero return &zero } default: - XdrPanic("SorobanTransactionMetaExt.V1 accessed when V == %v", u.V) + XdrPanic("SCPHistoryEntry.V0 accessed when V == %v", u.V) return nil } } -func (u SorobanTransactionMetaExt) XdrValid() bool { +func (u SCPHistoryEntry) XdrValid() bool { switch u.V { - case 0, 1: + case 0: return true } return false } -func (u *SorobanTransactionMetaExt) XdrUnionTag() XdrNum32 { +func (u *SCPHistoryEntry) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *SorobanTransactionMetaExt) XdrUnionTagName() string { +func (u *SCPHistoryEntry) XdrUnionTagName() string { return "V" } -func (u *SorobanTransactionMetaExt) XdrUnionBody() XdrType { +func (u *SCPHistoryEntry) XdrUnionBody() XdrType { switch u.V { case 0: - return nil - case 1: - return XDR_SorobanTransactionMetaExtV1(u.V1()) + return XDR_SCPHistoryEntryV0(u.V0()) } return nil } -func (u *SorobanTransactionMetaExt) XdrUnionBodyName() string { +func (u *SCPHistoryEntry) XdrUnionBodyName() string { switch u.V { case 0: - return "" - case 1: - return "V1" + return "V0" } return "" } -type XdrType_SorobanTransactionMetaExt = *SorobanTransactionMetaExt +type XdrType_SCPHistoryEntry = *SCPHistoryEntry -func (v *SorobanTransactionMetaExt) XdrPointer() interface{} { return v } -func (SorobanTransactionMetaExt) XdrTypeName() string { return "SorobanTransactionMetaExt" } -func (v SorobanTransactionMetaExt) XdrValue() interface{} { return v } -func (v *SorobanTransactionMetaExt) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *SorobanTransactionMetaExt) XdrRecurse(x XDR, name string) { +func (v *SCPHistoryEntry) XdrPointer() interface{} { return v } +func (SCPHistoryEntry) XdrTypeName() string { return "SCPHistoryEntry" } +func (v SCPHistoryEntry) XdrValue() interface{} { return v } +func (v *SCPHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *SCPHistoryEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { case 0: - return - case 1: - x.Marshal(x.Sprintf("%sv1", name), XDR_SorobanTransactionMetaExtV1(u.V1())) + x.Marshal(x.Sprintf("%sv0", name), XDR_SCPHistoryEntryV0(u.V0())) return } - XdrPanic("invalid V (%v) in SorobanTransactionMetaExt", u.V) + XdrPanic("invalid V (%v) in SCPHistoryEntry", u.V) } -func XDR_SorobanTransactionMetaExt(v *SorobanTransactionMetaExt) *SorobanTransactionMetaExt { return v } - -type _XdrVec_unbounded_ContractEvent []ContractEvent +func XDR_SCPHistoryEntry(v *SCPHistoryEntry) *SCPHistoryEntry { return v } -func (_XdrVec_unbounded_ContractEvent) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound +var _XdrNames_LedgerEntryChangeType = map[int32]string{ + int32(LEDGER_ENTRY_CREATED): "LEDGER_ENTRY_CREATED", + int32(LEDGER_ENTRY_UPDATED): "LEDGER_ENTRY_UPDATED", + int32(LEDGER_ENTRY_REMOVED): "LEDGER_ENTRY_REMOVED", + int32(LEDGER_ENTRY_STATE): "LEDGER_ENTRY_STATE", } -func (_XdrVec_unbounded_ContractEvent) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_ContractEvent length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_ContractEvent length %d exceeds max int", length) - } +var _XdrValues_LedgerEntryChangeType = map[string]int32{ + "LEDGER_ENTRY_CREATED": int32(LEDGER_ENTRY_CREATED), + "LEDGER_ENTRY_UPDATED": int32(LEDGER_ENTRY_UPDATED), + "LEDGER_ENTRY_REMOVED": int32(LEDGER_ENTRY_REMOVED), + "LEDGER_ENTRY_STATE": int32(LEDGER_ENTRY_STATE), } -func (v _XdrVec_unbounded_ContractEvent) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_ContractEvent) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) + +func (LedgerEntryChangeType) XdrEnumNames() map[int32]string { + return _XdrNames_LedgerEntryChangeType +} +func (v LedgerEntryChangeType) String() string { + if s, ok := _XdrNames_LedgerEntryChangeType[int32(v)]; ok { + return s } - nv := make([]ContractEvent, int(length), newcap) - copy(nv, *v) - *v = nv + return fmt.Sprintf("LedgerEntryChangeType#%d", v) } -func (v *_XdrVec_unbounded_ContractEvent) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) +func (v *LedgerEntryChangeType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_LedgerEntryChangeType[stok]; ok { + *v = LedgerEntryChangeType(val) + return nil + } else if stok == "LedgerEntryChangeType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - XDR_ContractEvent(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] + return XdrError(fmt.Sprintf("%s is not a valid LedgerEntryChangeType.", stok)) } } -func (v *_XdrVec_unbounded_ContractEvent) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_unbounded_ContractEvent) XdrTypeName() string { return "ContractEvent<>" } -func (v *_XdrVec_unbounded_ContractEvent) XdrPointer() interface{} { return (*[]ContractEvent)(v) } -func (v _XdrVec_unbounded_ContractEvent) XdrValue() interface{} { return ([]ContractEvent)(v) } -func (v *_XdrVec_unbounded_ContractEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v LedgerEntryChangeType) GetU32() uint32 { return uint32(v) } +func (v *LedgerEntryChangeType) SetU32(n uint32) { *v = LedgerEntryChangeType(n) } +func (v *LedgerEntryChangeType) XdrPointer() interface{} { return v } +func (LedgerEntryChangeType) XdrTypeName() string { return "LedgerEntryChangeType" } +func (v LedgerEntryChangeType) XdrValue() interface{} { return v } +func (v *LedgerEntryChangeType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_SorobanTransactionMeta = *SorobanTransactionMeta +type XdrType_LedgerEntryChangeType = *LedgerEntryChangeType -func (v *SorobanTransactionMeta) XdrPointer() interface{} { return v } -func (SorobanTransactionMeta) XdrTypeName() string { return "SorobanTransactionMeta" } -func (v SorobanTransactionMeta) XdrValue() interface{} { return v } -func (v *SorobanTransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SorobanTransactionMeta) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sext", name), XDR_SorobanTransactionMetaExt(&v.Ext)) - x.Marshal(x.Sprintf("%sevents", name), (*_XdrVec_unbounded_ContractEvent)(&v.Events)) - x.Marshal(x.Sprintf("%sreturnValue", name), XDR_SCVal(&v.ReturnValue)) - x.Marshal(x.Sprintf("%sdiagnosticEvents", name), (*_XdrVec_unbounded_DiagnosticEvent)(&v.DiagnosticEvents)) +func XDR_LedgerEntryChangeType(v *LedgerEntryChangeType) *LedgerEntryChangeType { return v } + +var _XdrComments_LedgerEntryChangeType = map[int32]string{ + int32(LEDGER_ENTRY_CREATED): "entry was added to the ledger", + int32(LEDGER_ENTRY_UPDATED): "entry was modified in the ledger", + int32(LEDGER_ENTRY_REMOVED): "entry was removed from the ledger", + int32(LEDGER_ENTRY_STATE): "value of the entry", } -func XDR_SorobanTransactionMeta(v *SorobanTransactionMeta) *SorobanTransactionMeta { return v } -type _XdrPtr_SorobanTransactionMeta struct { - p **SorobanTransactionMeta +func (e LedgerEntryChangeType) XdrEnumComments() map[int32]string { + return _XdrComments_LedgerEntryChangeType } -type _ptrflag_SorobanTransactionMeta _XdrPtr_SorobanTransactionMeta -func (v _ptrflag_SorobanTransactionMeta) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" +var _XdrTags_LedgerEntryChange = map[int32]bool{ + XdrToI32(LEDGER_ENTRY_CREATED): true, + XdrToI32(LEDGER_ENTRY_UPDATED): true, + XdrToI32(LEDGER_ENTRY_REMOVED): true, + XdrToI32(LEDGER_ENTRY_STATE): true, } -func (v _ptrflag_SorobanTransactionMeta) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) + +func (_ LedgerEntryChange) XdrValidTags() map[int32]bool { + return _XdrTags_LedgerEntryChange +} +func (u *LedgerEntryChange) Created() *LedgerEntry { + switch u.Type { + case LEDGER_ENTRY_CREATED: + if v, ok := u._u.(*LedgerEntry); ok { + return v + } else { + var zero LedgerEntry + u._u = &zero + return &zero + } default: - return XdrError("SorobanTransactionMeta flag should be \"nil\" or \"non-nil\"") + XdrPanic("LedgerEntryChange.Created accessed when Type == %v", u.Type) + return nil } - return nil } -func (v _ptrflag_SorobanTransactionMeta) GetU32() uint32 { - if *v.p == nil { - return 0 - } - return 1 -} -func (v _ptrflag_SorobanTransactionMeta) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(SorobanTransactionMeta) - } - default: - XdrPanic("*SorobanTransactionMeta present flag value %d should be 0 or 1", nv) - } -} -func (_ptrflag_SorobanTransactionMeta) XdrTypeName() string { return "SorobanTransactionMeta?" } -func (v _ptrflag_SorobanTransactionMeta) XdrPointer() interface{} { return nil } -func (v _ptrflag_SorobanTransactionMeta) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_SorobanTransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_SorobanTransactionMeta) XdrBound() uint32 { return 1 } -func (v _XdrPtr_SorobanTransactionMeta) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_SorobanTransactionMeta) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(SorobanTransactionMeta) - } -} -func (v _XdrPtr_SorobanTransactionMeta) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_SorobanTransactionMeta(*v.p).XdrMarshal(x, name) - } -} -func (v _XdrPtr_SorobanTransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_SorobanTransactionMeta) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_SorobanTransactionMeta(v)) - v.XdrMarshalValue(x, name) -} -func (_XdrPtr_SorobanTransactionMeta) XdrTypeName() string { return "SorobanTransactionMeta*" } -func (v _XdrPtr_SorobanTransactionMeta) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_SorobanTransactionMeta) XdrValue() interface{} { return *v.p } - -type XdrType_TransactionMetaV3 = *TransactionMetaV3 - -func (v *TransactionMetaV3) XdrPointer() interface{} { return v } -func (TransactionMetaV3) XdrTypeName() string { return "TransactionMetaV3" } -func (v TransactionMetaV3) XdrValue() interface{} { return v } -func (v *TransactionMetaV3) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionMetaV3) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) - x.Marshal(x.Sprintf("%stxChangesBefore", name), XDR_LedgerEntryChanges(&v.TxChangesBefore)) - x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(&v.Operations)) - x.Marshal(x.Sprintf("%stxChangesAfter", name), XDR_LedgerEntryChanges(&v.TxChangesAfter)) - x.Marshal(x.Sprintf("%ssorobanMeta", name), _XdrPtr_SorobanTransactionMeta{&v.SorobanMeta}) -} -func XDR_TransactionMetaV3(v *TransactionMetaV3) *TransactionMetaV3 { return v } - -type XdrType_InvokeHostFunctionSuccessPreImage = *InvokeHostFunctionSuccessPreImage - -func (v *InvokeHostFunctionSuccessPreImage) XdrPointer() interface{} { return v } -func (InvokeHostFunctionSuccessPreImage) XdrTypeName() string { - return "InvokeHostFunctionSuccessPreImage" -} -func (v InvokeHostFunctionSuccessPreImage) XdrValue() interface{} { return v } -func (v *InvokeHostFunctionSuccessPreImage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *InvokeHostFunctionSuccessPreImage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sreturnValue", name), XDR_SCVal(&v.ReturnValue)) - x.Marshal(x.Sprintf("%sevents", name), (*_XdrVec_unbounded_ContractEvent)(&v.Events)) -} -func XDR_InvokeHostFunctionSuccessPreImage(v *InvokeHostFunctionSuccessPreImage) *InvokeHostFunctionSuccessPreImage { - return v -} - -var _XdrTags_TransactionMeta = map[int32]bool{ - XdrToI32(0): true, - XdrToI32(1): true, - XdrToI32(2): true, - XdrToI32(3): true, -} - -func (_ TransactionMeta) XdrValidTags() map[int32]bool { - return _XdrTags_TransactionMeta -} -func (u *TransactionMeta) Operations() *[]OperationMeta { - switch u.V { - case 0: - if v, ok := u._u.(*[]OperationMeta); ok { - return v - } else { - var zero []OperationMeta - u._u = &zero - return &zero - } - default: - XdrPanic("TransactionMeta.Operations accessed when V == %v", u.V) - return nil - } -} -func (u *TransactionMeta) V1() *TransactionMetaV1 { - switch u.V { - case 1: - if v, ok := u._u.(*TransactionMetaV1); ok { +func (u *LedgerEntryChange) Updated() *LedgerEntry { + switch u.Type { + case LEDGER_ENTRY_UPDATED: + if v, ok := u._u.(*LedgerEntry); ok { return v } else { - var zero TransactionMetaV1 + var zero LedgerEntry u._u = &zero return &zero } default: - XdrPanic("TransactionMeta.V1 accessed when V == %v", u.V) + XdrPanic("LedgerEntryChange.Updated accessed when Type == %v", u.Type) return nil } } -func (u *TransactionMeta) V2() *TransactionMetaV2 { - switch u.V { - case 2: - if v, ok := u._u.(*TransactionMetaV2); ok { +func (u *LedgerEntryChange) Removed() *LedgerKey { + switch u.Type { + case LEDGER_ENTRY_REMOVED: + if v, ok := u._u.(*LedgerKey); ok { return v } else { - var zero TransactionMetaV2 + var zero LedgerKey u._u = &zero return &zero } default: - XdrPanic("TransactionMeta.V2 accessed when V == %v", u.V) + XdrPanic("LedgerEntryChange.Removed accessed when Type == %v", u.Type) return nil } } -func (u *TransactionMeta) V3() *TransactionMetaV3 { - switch u.V { - case 3: - if v, ok := u._u.(*TransactionMetaV3); ok { +func (u *LedgerEntryChange) State() *LedgerEntry { + switch u.Type { + case LEDGER_ENTRY_STATE: + if v, ok := u._u.(*LedgerEntry); ok { return v } else { - var zero TransactionMetaV3 + var zero LedgerEntry u._u = &zero return &zero } default: - XdrPanic("TransactionMeta.V3 accessed when V == %v", u.V) + XdrPanic("LedgerEntryChange.State accessed when Type == %v", u.Type) return nil } } -func (u TransactionMeta) XdrValid() bool { - switch u.V { - case 0, 1, 2, 3: +func (u LedgerEntryChange) XdrValid() bool { + switch u.Type { + case LEDGER_ENTRY_CREATED, LEDGER_ENTRY_UPDATED, LEDGER_ENTRY_REMOVED, LEDGER_ENTRY_STATE: return true } return false } -func (u *TransactionMeta) XdrUnionTag() XdrNum32 { - return XDR_int32(&u.V) +func (u *LedgerEntryChange) XdrUnionTag() XdrNum32 { + return XDR_LedgerEntryChangeType(&u.Type) } -func (u *TransactionMeta) XdrUnionTagName() string { - return "V" +func (u *LedgerEntryChange) XdrUnionTagName() string { + return "Type" } -func (u *TransactionMeta) XdrUnionBody() XdrType { - switch u.V { - case 0: - return (*_XdrVec_unbounded_OperationMeta)(u.Operations()) - case 1: - return XDR_TransactionMetaV1(u.V1()) - case 2: - return XDR_TransactionMetaV2(u.V2()) - case 3: - return XDR_TransactionMetaV3(u.V3()) +func (u *LedgerEntryChange) XdrUnionBody() XdrType { + switch u.Type { + case LEDGER_ENTRY_CREATED: + return XDR_LedgerEntry(u.Created()) + case LEDGER_ENTRY_UPDATED: + return XDR_LedgerEntry(u.Updated()) + case LEDGER_ENTRY_REMOVED: + return XDR_LedgerKey(u.Removed()) + case LEDGER_ENTRY_STATE: + return XDR_LedgerEntry(u.State()) } return nil } -func (u *TransactionMeta) XdrUnionBodyName() string { - switch u.V { - case 0: - return "Operations" - case 1: - return "V1" - case 2: - return "V2" - case 3: - return "V3" +func (u *LedgerEntryChange) XdrUnionBodyName() string { + switch u.Type { + case LEDGER_ENTRY_CREATED: + return "Created" + case LEDGER_ENTRY_UPDATED: + return "Updated" + case LEDGER_ENTRY_REMOVED: + return "Removed" + case LEDGER_ENTRY_STATE: + return "State" } return "" } -type XdrType_TransactionMeta = *TransactionMeta +type XdrType_LedgerEntryChange = *LedgerEntryChange -func (v *TransactionMeta) XdrPointer() interface{} { return v } -func (TransactionMeta) XdrTypeName() string { return "TransactionMeta" } -func (v TransactionMeta) XdrValue() interface{} { return v } -func (v *TransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *TransactionMeta) XdrRecurse(x XDR, name string) { +func (v *LedgerEntryChange) XdrPointer() interface{} { return v } +func (LedgerEntryChange) XdrTypeName() string { return "LedgerEntryChange" } +func (v LedgerEntryChange) XdrValue() interface{} { return v } +func (v *LedgerEntryChange) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *LedgerEntryChange) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) - switch u.V { - case 0: - x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(u.Operations())) + XDR_LedgerEntryChangeType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case LEDGER_ENTRY_CREATED: + x.Marshal(x.Sprintf("%screated", name), XDR_LedgerEntry(u.Created())) return - case 1: - x.Marshal(x.Sprintf("%sv1", name), XDR_TransactionMetaV1(u.V1())) + case LEDGER_ENTRY_UPDATED: + x.Marshal(x.Sprintf("%supdated", name), XDR_LedgerEntry(u.Updated())) return - case 2: - x.Marshal(x.Sprintf("%sv2", name), XDR_TransactionMetaV2(u.V2())) + case LEDGER_ENTRY_REMOVED: + x.Marshal(x.Sprintf("%sremoved", name), XDR_LedgerKey(u.Removed())) return - case 3: - x.Marshal(x.Sprintf("%sv3", name), XDR_TransactionMetaV3(u.V3())) + case LEDGER_ENTRY_STATE: + x.Marshal(x.Sprintf("%sstate", name), XDR_LedgerEntry(u.State())) return } - XdrPanic("invalid V (%v) in TransactionMeta", u.V) + XdrPanic("invalid Type (%v) in LedgerEntryChange", u.Type) } -func XDR_TransactionMeta(v *TransactionMeta) *TransactionMeta { return v } +func XDR_LedgerEntryChange(v *LedgerEntryChange) *LedgerEntryChange { return v } -type XdrType_TransactionResultMeta = *TransactionResultMeta +type _XdrVec_unbounded_LedgerEntryChange []LedgerEntryChange -func (v *TransactionResultMeta) XdrPointer() interface{} { return v } -func (TransactionResultMeta) XdrTypeName() string { return "TransactionResultMeta" } -func (v TransactionResultMeta) XdrValue() interface{} { return v } -func (v *TransactionResultMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionResultMeta) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (_XdrVec_unbounded_LedgerEntryChange) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound +} +func (_XdrVec_unbounded_LedgerEntryChange) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_LedgerEntryChange length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_LedgerEntryChange length %d exceeds max int", length) } - x.Marshal(x.Sprintf("%sresult", name), XDR_TransactionResultPair(&v.Result)) - x.Marshal(x.Sprintf("%sfeeProcessing", name), XDR_LedgerEntryChanges(&v.FeeProcessing)) - x.Marshal(x.Sprintf("%stxApplyProcessing", name), XDR_TransactionMeta(&v.TxApplyProcessing)) } -func XDR_TransactionResultMeta(v *TransactionResultMeta) *TransactionResultMeta { return v } - -type XdrType_UpgradeEntryMeta = *UpgradeEntryMeta - -func (v *UpgradeEntryMeta) XdrPointer() interface{} { return v } -func (UpgradeEntryMeta) XdrTypeName() string { return "UpgradeEntryMeta" } -func (v UpgradeEntryMeta) XdrValue() interface{} { return v } -func (v *UpgradeEntryMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *UpgradeEntryMeta) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%supgrade", name), XDR_LedgerUpgrade(&v.Upgrade)) - x.Marshal(x.Sprintf("%schanges", name), XDR_LedgerEntryChanges(&v.Changes)) -} -func XDR_UpgradeEntryMeta(v *UpgradeEntryMeta) *UpgradeEntryMeta { return v } - -type _XdrVec_unbounded_TransactionResultMeta []TransactionResultMeta - -func (_XdrVec_unbounded_TransactionResultMeta) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_unbounded_TransactionResultMeta) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_TransactionResultMeta length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_TransactionResultMeta length %d exceeds max int", length) - } -} -func (v _XdrVec_unbounded_TransactionResultMeta) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_TransactionResultMeta) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_LedgerEntryChange) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_LedgerEntryChange) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -12626,51 +12405,73 @@ func (v *_XdrVec_unbounded_TransactionResultMeta) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]TransactionResultMeta, int(length), newcap) + nv := make([]LedgerEntryChange, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_TransactionResultMeta) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_LedgerEntryChange) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_TransactionResultMeta(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_LedgerEntryChange(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_TransactionResultMeta) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_LedgerEntryChange) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_TransactionResultMeta) XdrTypeName() string { return "TransactionResultMeta<>" } -func (v *_XdrVec_unbounded_TransactionResultMeta) XdrPointer() interface{} { - return (*[]TransactionResultMeta)(v) +func (_XdrVec_unbounded_LedgerEntryChange) XdrTypeName() string { return "LedgerEntryChange<>" } +func (v *_XdrVec_unbounded_LedgerEntryChange) XdrPointer() interface{} { + return (*[]LedgerEntryChange)(v) } -func (v _XdrVec_unbounded_TransactionResultMeta) XdrValue() interface{} { - return ([]TransactionResultMeta)(v) +func (v _XdrVec_unbounded_LedgerEntryChange) XdrValue() interface{} { return ([]LedgerEntryChange)(v) } +func (v *_XdrVec_unbounded_LedgerEntryChange) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_LedgerEntryChanges struct { + *_XdrVec_unbounded_LedgerEntryChange } -func (v *_XdrVec_unbounded_TransactionResultMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type _XdrVec_unbounded_UpgradeEntryMeta []UpgradeEntryMeta +func XDR_LedgerEntryChanges(v *LedgerEntryChanges) XdrType_LedgerEntryChanges { + return XdrType_LedgerEntryChanges{(*_XdrVec_unbounded_LedgerEntryChange)(v)} +} +func (XdrType_LedgerEntryChanges) XdrTypeName() string { return "LedgerEntryChanges" } +func (v XdrType_LedgerEntryChanges) XdrUnwrap() XdrType { return v._XdrVec_unbounded_LedgerEntryChange } -func (_XdrVec_unbounded_UpgradeEntryMeta) XdrBound() uint32 { +type XdrType_OperationMeta = *OperationMeta + +func (v *OperationMeta) XdrPointer() interface{} { return v } +func (OperationMeta) XdrTypeName() string { return "OperationMeta" } +func (v OperationMeta) XdrValue() interface{} { return v } +func (v *OperationMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *OperationMeta) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%schanges", name), XDR_LedgerEntryChanges(&v.Changes)) +} +func XDR_OperationMeta(v *OperationMeta) *OperationMeta { return v } + +type _XdrVec_unbounded_OperationMeta []OperationMeta + +func (_XdrVec_unbounded_OperationMeta) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_UpgradeEntryMeta) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_OperationMeta) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_UpgradeEntryMeta length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_OperationMeta length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_UpgradeEntryMeta length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_OperationMeta length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_UpgradeEntryMeta) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_UpgradeEntryMeta) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_OperationMeta) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_OperationMeta) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -12687,49 +12488,125 @@ func (v *_XdrVec_unbounded_UpgradeEntryMeta) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]UpgradeEntryMeta, int(length), newcap) + nv := make([]OperationMeta, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_OperationMeta) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_UpgradeEntryMeta(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_OperationMeta(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_OperationMeta) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_UpgradeEntryMeta) XdrTypeName() string { return "UpgradeEntryMeta<>" } -func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrPointer() interface{} { - return (*[]UpgradeEntryMeta)(v) +func (_XdrVec_unbounded_OperationMeta) XdrTypeName() string { return "OperationMeta<>" } +func (v *_XdrVec_unbounded_OperationMeta) XdrPointer() interface{} { return (*[]OperationMeta)(v) } +func (v _XdrVec_unbounded_OperationMeta) XdrValue() interface{} { return ([]OperationMeta)(v) } +func (v *_XdrVec_unbounded_OperationMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_TransactionMetaV1 = *TransactionMetaV1 + +func (v *TransactionMetaV1) XdrPointer() interface{} { return v } +func (TransactionMetaV1) XdrTypeName() string { return "TransactionMetaV1" } +func (v TransactionMetaV1) XdrValue() interface{} { return v } +func (v *TransactionMetaV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionMetaV1) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%stxChanges", name), XDR_LedgerEntryChanges(&v.TxChanges)) + x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(&v.Operations)) } -func (v _XdrVec_unbounded_UpgradeEntryMeta) XdrValue() interface{} { return ([]UpgradeEntryMeta)(v) } -func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func XDR_TransactionMetaV1(v *TransactionMetaV1) *TransactionMetaV1 { return v } -type _XdrVec_unbounded_SCPHistoryEntry []SCPHistoryEntry +type XdrType_TransactionMetaV2 = *TransactionMetaV2 -func (_XdrVec_unbounded_SCPHistoryEntry) XdrBound() uint32 { +func (v *TransactionMetaV2) XdrPointer() interface{} { return v } +func (TransactionMetaV2) XdrTypeName() string { return "TransactionMetaV2" } +func (v TransactionMetaV2) XdrValue() interface{} { return v } +func (v *TransactionMetaV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionMetaV2) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%stxChangesBefore", name), XDR_LedgerEntryChanges(&v.TxChangesBefore)) + x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(&v.Operations)) + x.Marshal(x.Sprintf("%stxChangesAfter", name), XDR_LedgerEntryChanges(&v.TxChangesAfter)) +} +func XDR_TransactionMetaV2(v *TransactionMetaV2) *TransactionMetaV2 { return v } + +var _XdrNames_ContractEventType = map[int32]string{ + int32(SYSTEM): "SYSTEM", + int32(CONTRACT): "CONTRACT", + int32(DIAGNOSTIC): "DIAGNOSTIC", +} +var _XdrValues_ContractEventType = map[string]int32{ + "SYSTEM": int32(SYSTEM), + "CONTRACT": int32(CONTRACT), + "DIAGNOSTIC": int32(DIAGNOSTIC), +} + +func (ContractEventType) XdrEnumNames() map[int32]string { + return _XdrNames_ContractEventType +} +func (v ContractEventType) String() string { + if s, ok := _XdrNames_ContractEventType[int32(v)]; ok { + return s + } + return fmt.Sprintf("ContractEventType#%d", v) +} +func (v *ContractEventType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_ContractEventType[stok]; ok { + *v = ContractEventType(val) + return nil + } else if stok == "ContractEventType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid ContractEventType.", stok)) + } +} +func (v ContractEventType) GetU32() uint32 { return uint32(v) } +func (v *ContractEventType) SetU32(n uint32) { *v = ContractEventType(n) } +func (v *ContractEventType) XdrPointer() interface{} { return v } +func (ContractEventType) XdrTypeName() string { return "ContractEventType" } +func (v ContractEventType) XdrValue() interface{} { return v } +func (v *ContractEventType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_ContractEventType = *ContractEventType + +func XDR_ContractEventType(v *ContractEventType) *ContractEventType { return v } + +type _XdrVec_unbounded_SCVal []SCVal + +func (_XdrVec_unbounded_SCVal) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_SCPHistoryEntry) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_SCVal) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_SCPHistoryEntry length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_SCVal length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_SCPHistoryEntry length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_SCVal length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_SCPHistoryEntry) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_SCPHistoryEntry) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_SCVal) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_SCVal) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -12746,214 +12623,241 @@ func (v *_XdrVec_unbounded_SCPHistoryEntry) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]SCPHistoryEntry, int(length), newcap) + nv := make([]SCVal, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_SCVal) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_SCPHistoryEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_SCVal(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_SCVal) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_SCPHistoryEntry) XdrTypeName() string { return "SCPHistoryEntry<>" } -func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrPointer() interface{} { return (*[]SCPHistoryEntry)(v) } -func (v _XdrVec_unbounded_SCPHistoryEntry) XdrValue() interface{} { return ([]SCPHistoryEntry)(v) } -func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (_XdrVec_unbounded_SCVal) XdrTypeName() string { return "SCVal<>" } +func (v *_XdrVec_unbounded_SCVal) XdrPointer() interface{} { return (*[]SCVal)(v) } +func (v _XdrVec_unbounded_SCVal) XdrValue() interface{} { return ([]SCVal)(v) } +func (v *_XdrVec_unbounded_SCVal) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_LedgerCloseMetaV0 = *LedgerCloseMetaV0 +type XdrType_XdrAnon_ContractEvent_Body_V0 = *XdrAnon_ContractEvent_Body_V0 -func (v *LedgerCloseMetaV0) XdrPointer() interface{} { return v } -func (LedgerCloseMetaV0) XdrTypeName() string { return "LedgerCloseMetaV0" } -func (v LedgerCloseMetaV0) XdrValue() interface{} { return v } -func (v *LedgerCloseMetaV0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerCloseMetaV0) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_ContractEvent_Body_V0) XdrPointer() interface{} { return v } +func (XdrAnon_ContractEvent_Body_V0) XdrTypeName() string { return "XdrAnon_ContractEvent_Body_V0" } +func (v XdrAnon_ContractEvent_Body_V0) XdrValue() interface{} { return v } +func (v *XdrAnon_ContractEvent_Body_V0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_ContractEvent_Body_V0) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sledgerHeader", name), XDR_LedgerHeaderHistoryEntry(&v.LedgerHeader)) - x.Marshal(x.Sprintf("%stxSet", name), XDR_TransactionSet(&v.TxSet)) - x.Marshal(x.Sprintf("%stxProcessing", name), (*_XdrVec_unbounded_TransactionResultMeta)(&v.TxProcessing)) - x.Marshal(x.Sprintf("%supgradesProcessing", name), (*_XdrVec_unbounded_UpgradeEntryMeta)(&v.UpgradesProcessing)) - x.Marshal(x.Sprintf("%sscpInfo", name), (*_XdrVec_unbounded_SCPHistoryEntry)(&v.ScpInfo)) + x.Marshal(x.Sprintf("%stopics", name), (*_XdrVec_unbounded_SCVal)(&v.Topics)) + x.Marshal(x.Sprintf("%sdata", name), XDR_SCVal(&v.Data)) } -func XDR_LedgerCloseMetaV0(v *LedgerCloseMetaV0) *LedgerCloseMetaV0 { return v } - -type XdrType_LedgerCloseMetaExtV1 = *LedgerCloseMetaExtV1 - -func (v *LedgerCloseMetaExtV1) XdrPointer() interface{} { return v } -func (LedgerCloseMetaExtV1) XdrTypeName() string { return "LedgerCloseMetaExtV1" } -func (v LedgerCloseMetaExtV1) XdrValue() interface{} { return v } -func (v *LedgerCloseMetaExtV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerCloseMetaExtV1) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) - x.Marshal(x.Sprintf("%ssorobanFeeWrite1KB", name), XDR_Int64(&v.SorobanFeeWrite1KB)) +func XDR_XdrAnon_ContractEvent_Body_V0(v *XdrAnon_ContractEvent_Body_V0) *XdrAnon_ContractEvent_Body_V0 { + return v } -func XDR_LedgerCloseMetaExtV1(v *LedgerCloseMetaExtV1) *LedgerCloseMetaExtV1 { return v } -var _XdrTags_LedgerCloseMetaExt = map[int32]bool{ +var _XdrTags_XdrAnon_ContractEvent_Body = map[int32]bool{ XdrToI32(0): true, - XdrToI32(1): true, } -func (_ LedgerCloseMetaExt) XdrValidTags() map[int32]bool { - return _XdrTags_LedgerCloseMetaExt +func (_ XdrAnon_ContractEvent_Body) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_ContractEvent_Body } -func (u *LedgerCloseMetaExt) V1() *LedgerCloseMetaExtV1 { +func (u *XdrAnon_ContractEvent_Body) V0() *XdrAnon_ContractEvent_Body_V0 { switch u.V { - case 1: - if v, ok := u._u.(*LedgerCloseMetaExtV1); ok { + case 0: + if v, ok := u._u.(*XdrAnon_ContractEvent_Body_V0); ok { return v } else { - var zero LedgerCloseMetaExtV1 + var zero XdrAnon_ContractEvent_Body_V0 u._u = &zero return &zero } default: - XdrPanic("LedgerCloseMetaExt.V1 accessed when V == %v", u.V) + XdrPanic("XdrAnon_ContractEvent_Body.V0 accessed when V == %v", u.V) return nil } } -func (u LedgerCloseMetaExt) XdrValid() bool { +func (u XdrAnon_ContractEvent_Body) XdrValid() bool { switch u.V { - case 0, 1: + case 0: return true } return false } -func (u *LedgerCloseMetaExt) XdrUnionTag() XdrNum32 { +func (u *XdrAnon_ContractEvent_Body) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *LedgerCloseMetaExt) XdrUnionTagName() string { +func (u *XdrAnon_ContractEvent_Body) XdrUnionTagName() string { return "V" } -func (u *LedgerCloseMetaExt) XdrUnionBody() XdrType { +func (u *XdrAnon_ContractEvent_Body) XdrUnionBody() XdrType { switch u.V { case 0: - return nil - case 1: - return XDR_LedgerCloseMetaExtV1(u.V1()) + return XDR_XdrAnon_ContractEvent_Body_V0(u.V0()) } return nil } -func (u *LedgerCloseMetaExt) XdrUnionBodyName() string { +func (u *XdrAnon_ContractEvent_Body) XdrUnionBodyName() string { switch u.V { case 0: - return "" - case 1: - return "V1" + return "V0" } return "" } -type XdrType_LedgerCloseMetaExt = *LedgerCloseMetaExt +type XdrType_XdrAnon_ContractEvent_Body = *XdrAnon_ContractEvent_Body -func (v *LedgerCloseMetaExt) XdrPointer() interface{} { return v } -func (LedgerCloseMetaExt) XdrTypeName() string { return "LedgerCloseMetaExt" } -func (v LedgerCloseMetaExt) XdrValue() interface{} { return v } -func (v *LedgerCloseMetaExt) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *LedgerCloseMetaExt) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_ContractEvent_Body) XdrPointer() interface{} { return v } +func (XdrAnon_ContractEvent_Body) XdrTypeName() string { return "XdrAnon_ContractEvent_Body" } +func (v XdrAnon_ContractEvent_Body) XdrValue() interface{} { return v } +func (v *XdrAnon_ContractEvent_Body) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_ContractEvent_Body) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { case 0: - return - case 1: - x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerCloseMetaExtV1(u.V1())) + x.Marshal(x.Sprintf("%sv0", name), XDR_XdrAnon_ContractEvent_Body_V0(u.V0())) return } - XdrPanic("invalid V (%v) in LedgerCloseMetaExt", u.V) + XdrPanic("invalid V (%v) in XdrAnon_ContractEvent_Body", u.V) +} +func XDR_XdrAnon_ContractEvent_Body(v *XdrAnon_ContractEvent_Body) *XdrAnon_ContractEvent_Body { + return v } -func XDR_LedgerCloseMetaExt(v *LedgerCloseMetaExt) *LedgerCloseMetaExt { return v } -type _XdrVec_unbounded_LedgerKey []LedgerKey +type _XdrPtr_Hash struct { + p **Hash +} +type _ptrflag_Hash _XdrPtr_Hash -func (_XdrVec_unbounded_LedgerKey) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound +func (v _ptrflag_Hash) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" } -func (_XdrVec_unbounded_LedgerKey) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_LedgerKey length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_LedgerKey length %d exceeds max int", length) +func (v _ptrflag_Hash) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) + default: + return XdrError("Hash flag should be \"nil\" or \"non-nil\"") } + return nil } -func (v _XdrVec_unbounded_LedgerKey) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_LedgerKey) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return +func (v _ptrflag_Hash) GetU32() uint32 { + if *v.p == nil { + return 0 } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 + return 1 +} +func (v _ptrflag_Hash) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(Hash) } - newcap = int(bound) + default: + XdrPanic("*Hash present flag value %d should be 0 or 1", nv) } - nv := make([]LedgerKey, int(length), newcap) - copy(nv, *v) - *v = nv } -func (v *_XdrVec_unbounded_LedgerKey) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_LedgerKey(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) +func (_ptrflag_Hash) XdrTypeName() string { return "Hash?" } +func (v _ptrflag_Hash) XdrPointer() interface{} { return nil } +func (v _ptrflag_Hash) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_Hash) XdrBound() uint32 { return 1 } +func (v _XdrPtr_Hash) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_Hash) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(Hash) } - if int(n) < len(*v) { - *v = (*v)[:int(n)] +} +func (v _XdrPtr_Hash) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_Hash(*v.p).XdrMarshal(x, name) } } -func (v *_XdrVec_unbounded_LedgerKey) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) +func (v _XdrPtr_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_Hash) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_Hash(v)) + v.XdrMarshalValue(x, name) } -func (_XdrVec_unbounded_LedgerKey) XdrTypeName() string { return "LedgerKey<>" } -func (v *_XdrVec_unbounded_LedgerKey) XdrPointer() interface{} { return (*[]LedgerKey)(v) } -func (v _XdrVec_unbounded_LedgerKey) XdrValue() interface{} { return ([]LedgerKey)(v) } -func (v *_XdrVec_unbounded_LedgerKey) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (_XdrPtr_Hash) XdrTypeName() string { return "Hash*" } +func (v _XdrPtr_Hash) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_Hash) XdrValue() interface{} { return *v.p } -type _XdrVec_unbounded_LedgerEntry []LedgerEntry +type XdrType_ContractEvent = *ContractEvent -func (_XdrVec_unbounded_LedgerEntry) XdrBound() uint32 { +func (v *ContractEvent) XdrPointer() interface{} { return v } +func (ContractEvent) XdrTypeName() string { return "ContractEvent" } +func (v ContractEvent) XdrValue() interface{} { return v } +func (v *ContractEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ContractEvent) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) + x.Marshal(x.Sprintf("%scontractID", name), _XdrPtr_Hash{&v.ContractID}) + x.Marshal(x.Sprintf("%stype", name), XDR_ContractEventType(&v.Type)) + x.Marshal(x.Sprintf("%sbody", name), XDR_XdrAnon_ContractEvent_Body(&v.Body)) +} +func XDR_ContractEvent(v *ContractEvent) *ContractEvent { return v } + +type XdrType_DiagnosticEvent = *DiagnosticEvent + +func (v *DiagnosticEvent) XdrPointer() interface{} { return v } +func (DiagnosticEvent) XdrTypeName() string { return "DiagnosticEvent" } +func (v DiagnosticEvent) XdrValue() interface{} { return v } +func (v *DiagnosticEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *DiagnosticEvent) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sinSuccessfulContractCall", name), XDR_bool(&v.InSuccessfulContractCall)) + x.Marshal(x.Sprintf("%sevent", name), XDR_ContractEvent(&v.Event)) +} +func XDR_DiagnosticEvent(v *DiagnosticEvent) *DiagnosticEvent { return v } + +type _XdrVec_unbounded_DiagnosticEvent []DiagnosticEvent + +func (_XdrVec_unbounded_DiagnosticEvent) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_LedgerEntry) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_DiagnosticEvent) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_LedgerEntry length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_LedgerEntry length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_LedgerEntry) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_LedgerEntry) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_DiagnosticEvent) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_DiagnosticEvent) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -12970,963 +12874,851 @@ func (v *_XdrVec_unbounded_LedgerEntry) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]LedgerEntry, int(length), newcap) + nv := make([]DiagnosticEvent, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_LedgerEntry) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_DiagnosticEvent) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_LedgerEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_DiagnosticEvent(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_LedgerEntry) XdrRecurse(x XDR, name string) { +func (v *_XdrVec_unbounded_DiagnosticEvent) XdrRecurse(x XDR, name string) { size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_LedgerEntry) XdrTypeName() string { return "LedgerEntry<>" } -func (v *_XdrVec_unbounded_LedgerEntry) XdrPointer() interface{} { return (*[]LedgerEntry)(v) } -func (v _XdrVec_unbounded_LedgerEntry) XdrValue() interface{} { return ([]LedgerEntry)(v) } -func (v *_XdrVec_unbounded_LedgerEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (_XdrVec_unbounded_DiagnosticEvent) XdrTypeName() string { return "DiagnosticEvent<>" } +func (v *_XdrVec_unbounded_DiagnosticEvent) XdrPointer() interface{} { return (*[]DiagnosticEvent)(v) } +func (v _XdrVec_unbounded_DiagnosticEvent) XdrValue() interface{} { return ([]DiagnosticEvent)(v) } +func (v *_XdrVec_unbounded_DiagnosticEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_LedgerCloseMetaV1 = *LedgerCloseMetaV1 +type XdrType_DiagnosticEvents struct { + *_XdrVec_unbounded_DiagnosticEvent +} -func (v *LedgerCloseMetaV1) XdrPointer() interface{} { return v } -func (LedgerCloseMetaV1) XdrTypeName() string { return "LedgerCloseMetaV1" } -func (v LedgerCloseMetaV1) XdrValue() interface{} { return v } -func (v *LedgerCloseMetaV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerCloseMetaV1) XdrRecurse(x XDR, name string) { +func XDR_DiagnosticEvents(v *DiagnosticEvents) XdrType_DiagnosticEvents { + return XdrType_DiagnosticEvents{(*_XdrVec_unbounded_DiagnosticEvent)(v)} +} +func (XdrType_DiagnosticEvents) XdrTypeName() string { return "DiagnosticEvents" } +func (v XdrType_DiagnosticEvents) XdrUnwrap() XdrType { return v._XdrVec_unbounded_DiagnosticEvent } + +type XdrType_SorobanTransactionMetaExtV1 = *SorobanTransactionMetaExtV1 + +func (v *SorobanTransactionMetaExtV1) XdrPointer() interface{} { return v } +func (SorobanTransactionMetaExtV1) XdrTypeName() string { return "SorobanTransactionMetaExtV1" } +func (v SorobanTransactionMetaExtV1) XdrValue() interface{} { return v } +func (v *SorobanTransactionMetaExtV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SorobanTransactionMetaExtV1) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sext", name), XDR_LedgerCloseMetaExt(&v.Ext)) - x.Marshal(x.Sprintf("%sledgerHeader", name), XDR_LedgerHeaderHistoryEntry(&v.LedgerHeader)) - x.Marshal(x.Sprintf("%stxSet", name), XDR_GeneralizedTransactionSet(&v.TxSet)) - x.Marshal(x.Sprintf("%stxProcessing", name), (*_XdrVec_unbounded_TransactionResultMeta)(&v.TxProcessing)) - x.Marshal(x.Sprintf("%supgradesProcessing", name), (*_XdrVec_unbounded_UpgradeEntryMeta)(&v.UpgradesProcessing)) - x.Marshal(x.Sprintf("%sscpInfo", name), (*_XdrVec_unbounded_SCPHistoryEntry)(&v.ScpInfo)) - x.Marshal(x.Sprintf("%stotalByteSizeOfBucketList", name), XDR_Uint64(&v.TotalByteSizeOfBucketList)) - x.Marshal(x.Sprintf("%sevictedTemporaryLedgerKeys", name), (*_XdrVec_unbounded_LedgerKey)(&v.EvictedTemporaryLedgerKeys)) - x.Marshal(x.Sprintf("%sevictedPersistentLedgerEntries", name), (*_XdrVec_unbounded_LedgerEntry)(&v.EvictedPersistentLedgerEntries)) + x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) + x.Marshal(x.Sprintf("%stotalNonRefundableResourceFeeCharged", name), XDR_Int64(&v.TotalNonRefundableResourceFeeCharged)) + x.Marshal(x.Sprintf("%stotalRefundableResourceFeeCharged", name), XDR_Int64(&v.TotalRefundableResourceFeeCharged)) + x.Marshal(x.Sprintf("%srentFeeCharged", name), XDR_Int64(&v.RentFeeCharged)) +} +func XDR_SorobanTransactionMetaExtV1(v *SorobanTransactionMetaExtV1) *SorobanTransactionMetaExtV1 { + return v } -func XDR_LedgerCloseMetaV1(v *LedgerCloseMetaV1) *LedgerCloseMetaV1 { return v } -var _XdrTags_LedgerCloseMeta = map[int32]bool{ +var _XdrTags_SorobanTransactionMetaExt = map[int32]bool{ XdrToI32(0): true, XdrToI32(1): true, } -func (_ LedgerCloseMeta) XdrValidTags() map[int32]bool { - return _XdrTags_LedgerCloseMeta -} -func (u *LedgerCloseMeta) V0() *LedgerCloseMetaV0 { - switch u.V { - case 0: - if v, ok := u._u.(*LedgerCloseMetaV0); ok { - return v - } else { - var zero LedgerCloseMetaV0 - u._u = &zero - return &zero - } - default: - XdrPanic("LedgerCloseMeta.V0 accessed when V == %v", u.V) - return nil - } +func (_ SorobanTransactionMetaExt) XdrValidTags() map[int32]bool { + return _XdrTags_SorobanTransactionMetaExt } -func (u *LedgerCloseMeta) V1() *LedgerCloseMetaV1 { +func (u *SorobanTransactionMetaExt) V1() *SorobanTransactionMetaExtV1 { switch u.V { case 1: - if v, ok := u._u.(*LedgerCloseMetaV1); ok { + if v, ok := u._u.(*SorobanTransactionMetaExtV1); ok { return v } else { - var zero LedgerCloseMetaV1 + var zero SorobanTransactionMetaExtV1 u._u = &zero return &zero } default: - XdrPanic("LedgerCloseMeta.V1 accessed when V == %v", u.V) + XdrPanic("SorobanTransactionMetaExt.V1 accessed when V == %v", u.V) return nil } } -func (u LedgerCloseMeta) XdrValid() bool { +func (u SorobanTransactionMetaExt) XdrValid() bool { switch u.V { case 0, 1: return true } return false } -func (u *LedgerCloseMeta) XdrUnionTag() XdrNum32 { +func (u *SorobanTransactionMetaExt) XdrUnionTag() XdrNum32 { return XDR_int32(&u.V) } -func (u *LedgerCloseMeta) XdrUnionTagName() string { +func (u *SorobanTransactionMetaExt) XdrUnionTagName() string { return "V" } -func (u *LedgerCloseMeta) XdrUnionBody() XdrType { +func (u *SorobanTransactionMetaExt) XdrUnionBody() XdrType { switch u.V { case 0: - return XDR_LedgerCloseMetaV0(u.V0()) + return nil case 1: - return XDR_LedgerCloseMetaV1(u.V1()) + return XDR_SorobanTransactionMetaExtV1(u.V1()) } return nil } -func (u *LedgerCloseMeta) XdrUnionBodyName() string { +func (u *SorobanTransactionMetaExt) XdrUnionBodyName() string { switch u.V { case 0: - return "V0" + return "" case 1: return "V1" } return "" } -type XdrType_LedgerCloseMeta = *LedgerCloseMeta +type XdrType_SorobanTransactionMetaExt = *SorobanTransactionMetaExt -func (v *LedgerCloseMeta) XdrPointer() interface{} { return v } -func (LedgerCloseMeta) XdrTypeName() string { return "LedgerCloseMeta" } -func (v LedgerCloseMeta) XdrValue() interface{} { return v } -func (v *LedgerCloseMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *LedgerCloseMeta) XdrRecurse(x XDR, name string) { +func (v *SorobanTransactionMetaExt) XdrPointer() interface{} { return v } +func (SorobanTransactionMetaExt) XdrTypeName() string { return "SorobanTransactionMetaExt" } +func (v SorobanTransactionMetaExt) XdrValue() interface{} { return v } +func (v *SorobanTransactionMetaExt) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *SorobanTransactionMetaExt) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) switch u.V { case 0: - x.Marshal(x.Sprintf("%sv0", name), XDR_LedgerCloseMetaV0(u.V0())) return case 1: - x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerCloseMetaV1(u.V1())) + x.Marshal(x.Sprintf("%sv1", name), XDR_SorobanTransactionMetaExtV1(u.V1())) return } - XdrPanic("invalid V (%v) in LedgerCloseMeta", u.V) + XdrPanic("invalid V (%v) in SorobanTransactionMetaExt", u.V) } -func XDR_LedgerCloseMeta(v *LedgerCloseMeta) *LedgerCloseMeta { return v } +func XDR_SorobanTransactionMetaExt(v *SorobanTransactionMetaExt) *SorobanTransactionMetaExt { return v } -var _XdrNames_ErrorCode = map[int32]string{ - int32(ERR_MISC): "ERR_MISC", - int32(ERR_DATA): "ERR_DATA", - int32(ERR_CONF): "ERR_CONF", - int32(ERR_AUTH): "ERR_AUTH", - int32(ERR_LOAD): "ERR_LOAD", -} -var _XdrValues_ErrorCode = map[string]int32{ - "ERR_MISC": int32(ERR_MISC), - "ERR_DATA": int32(ERR_DATA), - "ERR_CONF": int32(ERR_CONF), - "ERR_AUTH": int32(ERR_AUTH), - "ERR_LOAD": int32(ERR_LOAD), -} +type _XdrVec_unbounded_ContractEvent []ContractEvent -func (ErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_ErrorCode +func (_XdrVec_unbounded_ContractEvent) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v ErrorCode) String() string { - if s, ok := _XdrNames_ErrorCode[int32(v)]; ok { - return s +func (_XdrVec_unbounded_ContractEvent) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_ContractEvent length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_ContractEvent length %d exceeds max int", length) } - return fmt.Sprintf("ErrorCode#%d", v) } -func (v *ErrorCode) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_ErrorCode[stok]; ok { - *v = ErrorCode(val) - return nil - } else if stok == "ErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } +func (v _XdrVec_unbounded_ContractEvent) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_ContractEvent) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] } - return XdrError(fmt.Sprintf("%s is not a valid ErrorCode.", stok)) + return } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]ContractEvent, int(length), newcap) + copy(nv, *v) + *v = nv } -func (v ErrorCode) GetU32() uint32 { return uint32(v) } -func (v *ErrorCode) SetU32(n uint32) { *v = ErrorCode(n) } -func (v *ErrorCode) XdrPointer() interface{} { return v } -func (ErrorCode) XdrTypeName() string { return "ErrorCode" } -func (v ErrorCode) XdrValue() interface{} { return v } -func (v *ErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_ErrorCode = *ErrorCode - -func XDR_ErrorCode(v *ErrorCode) *ErrorCode { return v } - -var _XdrComments_ErrorCode = map[int32]string{ - int32(ERR_MISC): "Unspecific error", - int32(ERR_DATA): "Malformed data", - int32(ERR_CONF): "Misconfiguration error", - int32(ERR_AUTH): "Authentication failure", - int32(ERR_LOAD): "System overloaded", +func (v *_XdrVec_unbounded_ContractEvent) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_ContractEvent(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] + } } - -func (e ErrorCode) XdrEnumComments() map[int32]string { - return _XdrComments_ErrorCode +func (v *_XdrVec_unbounded_ContractEvent) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } +func (_XdrVec_unbounded_ContractEvent) XdrTypeName() string { return "ContractEvent<>" } +func (v *_XdrVec_unbounded_ContractEvent) XdrPointer() interface{} { return (*[]ContractEvent)(v) } +func (v _XdrVec_unbounded_ContractEvent) XdrValue() interface{} { return ([]ContractEvent)(v) } +func (v *_XdrVec_unbounded_ContractEvent) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_Error = *Error +type XdrType_SorobanTransactionMeta = *SorobanTransactionMeta -func (v *Error) XdrPointer() interface{} { return v } -func (Error) XdrTypeName() string { return "Error" } -func (v Error) XdrValue() interface{} { return v } -func (v *Error) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *Error) XdrRecurse(x XDR, name string) { +func (v *SorobanTransactionMeta) XdrPointer() interface{} { return v } +func (SorobanTransactionMeta) XdrTypeName() string { return "SorobanTransactionMeta" } +func (v SorobanTransactionMeta) XdrValue() interface{} { return v } +func (v *SorobanTransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SorobanTransactionMeta) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%scode", name), XDR_ErrorCode(&v.Code)) - x.Marshal(x.Sprintf("%smsg", name), XdrString{&v.Msg, 100}) + x.Marshal(x.Sprintf("%sext", name), XDR_SorobanTransactionMetaExt(&v.Ext)) + x.Marshal(x.Sprintf("%sevents", name), (*_XdrVec_unbounded_ContractEvent)(&v.Events)) + x.Marshal(x.Sprintf("%sreturnValue", name), XDR_SCVal(&v.ReturnValue)) + x.Marshal(x.Sprintf("%sdiagnosticEvents", name), (*_XdrVec_unbounded_DiagnosticEvent)(&v.DiagnosticEvents)) } -func XDR_Error(v *Error) *Error { return v } - -type XdrType_SendMore = *SendMore +func XDR_SorobanTransactionMeta(v *SorobanTransactionMeta) *SorobanTransactionMeta { return v } -func (v *SendMore) XdrPointer() interface{} { return v } -func (SendMore) XdrTypeName() string { return "SendMore" } -func (v SendMore) XdrValue() interface{} { return v } -func (v *SendMore) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SendMore) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%snumMessages", name), XDR_Uint32(&v.NumMessages)) +type _XdrPtr_SorobanTransactionMeta struct { + p **SorobanTransactionMeta } -func XDR_SendMore(v *SendMore) *SendMore { return v } - -type XdrType_SendMoreExtended = *SendMoreExtended +type _ptrflag_SorobanTransactionMeta _XdrPtr_SorobanTransactionMeta -func (v *SendMoreExtended) XdrPointer() interface{} { return v } -func (SendMoreExtended) XdrTypeName() string { return "SendMoreExtended" } -func (v SendMoreExtended) XdrValue() interface{} { return v } -func (v *SendMoreExtended) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SendMoreExtended) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v _ptrflag_SorobanTransactionMeta) String() string { + if *v.p == nil { + return "nil" } - x.Marshal(x.Sprintf("%snumMessages", name), XDR_Uint32(&v.NumMessages)) - x.Marshal(x.Sprintf("%snumBytes", name), XDR_Uint32(&v.NumBytes)) + return "non-nil" } -func XDR_SendMoreExtended(v *SendMoreExtended) *SendMoreExtended { return v } - -type XdrType_AuthCert = *AuthCert - -func (v *AuthCert) XdrPointer() interface{} { return v } -func (AuthCert) XdrTypeName() string { return "AuthCert" } -func (v AuthCert) XdrValue() interface{} { return v } -func (v *AuthCert) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *AuthCert) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v _ptrflag_SorobanTransactionMeta) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err } - x.Marshal(x.Sprintf("%spubkey", name), XDR_Curve25519Public(&v.Pubkey)) - x.Marshal(x.Sprintf("%sexpiration", name), XDR_Uint64(&v.Expiration)) - x.Marshal(x.Sprintf("%ssig", name), XDR_Signature(&v.Sig)) + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) + default: + return XdrError("SorobanTransactionMeta flag should be \"nil\" or \"non-nil\"") + } + return nil } -func XDR_AuthCert(v *AuthCert) *AuthCert { return v } - -type XdrType_Hello = *Hello - -func (v *Hello) XdrPointer() interface{} { return v } -func (Hello) XdrTypeName() string { return "Hello" } -func (v Hello) XdrValue() interface{} { return v } -func (v *Hello) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *Hello) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v _ptrflag_SorobanTransactionMeta) GetU32() uint32 { + if *v.p == nil { + return 0 } - x.Marshal(x.Sprintf("%sledgerVersion", name), XDR_Uint32(&v.LedgerVersion)) - x.Marshal(x.Sprintf("%soverlayVersion", name), XDR_Uint32(&v.OverlayVersion)) - x.Marshal(x.Sprintf("%soverlayMinVersion", name), XDR_Uint32(&v.OverlayMinVersion)) - x.Marshal(x.Sprintf("%snetworkID", name), XDR_Hash(&v.NetworkID)) - x.Marshal(x.Sprintf("%sversionStr", name), XdrString{&v.VersionStr, 100}) - x.Marshal(x.Sprintf("%slisteningPort", name), XDR_int32(&v.ListeningPort)) - x.Marshal(x.Sprintf("%speerID", name), XDR_NodeID(&v.PeerID)) - x.Marshal(x.Sprintf("%scert", name), XDR_AuthCert(&v.Cert)) - x.Marshal(x.Sprintf("%snonce", name), XDR_Uint256(&v.Nonce)) + return 1 } -func XDR_Hello(v *Hello) *Hello { return v } +func (v _ptrflag_SorobanTransactionMeta) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(SorobanTransactionMeta) + } + default: + XdrPanic("*SorobanTransactionMeta present flag value %d should be 0 or 1", nv) + } +} +func (_ptrflag_SorobanTransactionMeta) XdrTypeName() string { return "SorobanTransactionMeta?" } +func (v _ptrflag_SorobanTransactionMeta) XdrPointer() interface{} { return nil } +func (v _ptrflag_SorobanTransactionMeta) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_SorobanTransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_SorobanTransactionMeta) XdrBound() uint32 { return 1 } +func (v _XdrPtr_SorobanTransactionMeta) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_SorobanTransactionMeta) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(SorobanTransactionMeta) + } +} +func (v _XdrPtr_SorobanTransactionMeta) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_SorobanTransactionMeta(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_SorobanTransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_SorobanTransactionMeta) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_SorobanTransactionMeta(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_SorobanTransactionMeta) XdrTypeName() string { return "SorobanTransactionMeta*" } +func (v _XdrPtr_SorobanTransactionMeta) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_SorobanTransactionMeta) XdrValue() interface{} { return *v.p } -type XdrType_Auth = *Auth +type XdrType_TransactionMetaV3 = *TransactionMetaV3 -func (v *Auth) XdrPointer() interface{} { return v } -func (Auth) XdrTypeName() string { return "Auth" } -func (v Auth) XdrValue() interface{} { return v } -func (v *Auth) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *Auth) XdrRecurse(x XDR, name string) { +func (v *TransactionMetaV3) XdrPointer() interface{} { return v } +func (TransactionMetaV3) XdrTypeName() string { return "TransactionMetaV3" } +func (v TransactionMetaV3) XdrValue() interface{} { return v } +func (v *TransactionMetaV3) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionMetaV3) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sflags", name), XDR_int32(&v.Flags)) + x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) + x.Marshal(x.Sprintf("%stxChangesBefore", name), XDR_LedgerEntryChanges(&v.TxChangesBefore)) + x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(&v.Operations)) + x.Marshal(x.Sprintf("%stxChangesAfter", name), XDR_LedgerEntryChanges(&v.TxChangesAfter)) + x.Marshal(x.Sprintf("%ssorobanMeta", name), _XdrPtr_SorobanTransactionMeta{&v.SorobanMeta}) } -func XDR_Auth(v *Auth) *Auth { return v } +func XDR_TransactionMetaV3(v *TransactionMetaV3) *TransactionMetaV3 { return v } -var _XdrNames_IPAddrType = map[int32]string{ - int32(IPv4): "IPv4", - int32(IPv6): "IPv6", -} -var _XdrValues_IPAddrType = map[string]int32{ - "IPv4": int32(IPv4), - "IPv6": int32(IPv6), -} +type XdrType_InvokeHostFunctionSuccessPreImage = *InvokeHostFunctionSuccessPreImage -func (IPAddrType) XdrEnumNames() map[int32]string { - return _XdrNames_IPAddrType +func (v *InvokeHostFunctionSuccessPreImage) XdrPointer() interface{} { return v } +func (InvokeHostFunctionSuccessPreImage) XdrTypeName() string { + return "InvokeHostFunctionSuccessPreImage" } -func (v IPAddrType) String() string { - if s, ok := _XdrNames_IPAddrType[int32(v)]; ok { - return s +func (v InvokeHostFunctionSuccessPreImage) XdrValue() interface{} { return v } +func (v *InvokeHostFunctionSuccessPreImage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *InvokeHostFunctionSuccessPreImage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - return fmt.Sprintf("IPAddrType#%d", v) + x.Marshal(x.Sprintf("%sreturnValue", name), XDR_SCVal(&v.ReturnValue)) + x.Marshal(x.Sprintf("%sevents", name), (*_XdrVec_unbounded_ContractEvent)(&v.Events)) } -func (v *IPAddrType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_IPAddrType[stok]; ok { - *v = IPAddrType(val) - return nil - } else if stok == "IPAddrType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid IPAddrType.", stok)) - } +func XDR_InvokeHostFunctionSuccessPreImage(v *InvokeHostFunctionSuccessPreImage) *InvokeHostFunctionSuccessPreImage { + return v } -func (v IPAddrType) GetU32() uint32 { return uint32(v) } -func (v *IPAddrType) SetU32(n uint32) { *v = IPAddrType(n) } -func (v *IPAddrType) XdrPointer() interface{} { return v } -func (IPAddrType) XdrTypeName() string { return "IPAddrType" } -func (v IPAddrType) XdrValue() interface{} { return v } -func (v *IPAddrType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_IPAddrType = *IPAddrType - -func XDR_IPAddrType(v *IPAddrType) *IPAddrType { return v } - -type _XdrArray_16_opaque [16]byte -func (v *_XdrArray_16_opaque) GetByteSlice() []byte { return v[:] } -func (v *_XdrArray_16_opaque) XdrTypeName() string { return "opaque[]" } -func (v *_XdrArray_16_opaque) XdrValue() interface{} { return v[:] } -func (v *_XdrArray_16_opaque) XdrPointer() interface{} { return (*[16]byte)(v) } -func (v *_XdrArray_16_opaque) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *_XdrArray_16_opaque) String() string { return fmt.Sprintf("%x", v[:]) } -func (v *_XdrArray_16_opaque) Scan(ss fmt.ScanState, c rune) error { - return XdrArrayOpaqueScan(v[:], ss, c) -} -func (_XdrArray_16_opaque) XdrArraySize() uint32 { - const bound uint32 = 16 // Force error if not const or doesn't fit - return bound +var _XdrTags_TransactionMeta = map[int32]bool{ + XdrToI32(0): true, + XdrToI32(1): true, + XdrToI32(2): true, + XdrToI32(3): true, } -var _XdrTags_XdrAnon_PeerAddress_Ip = map[int32]bool{ - XdrToI32(IPv4): true, - XdrToI32(IPv6): true, +func (_ TransactionMeta) XdrValidTags() map[int32]bool { + return _XdrTags_TransactionMeta } - -func (_ XdrAnon_PeerAddress_Ip) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_PeerAddress_Ip +func (u *TransactionMeta) Operations() *[]OperationMeta { + switch u.V { + case 0: + if v, ok := u._u.(*[]OperationMeta); ok { + return v + } else { + var zero []OperationMeta + u._u = &zero + return &zero + } + default: + XdrPanic("TransactionMeta.Operations accessed when V == %v", u.V) + return nil + } } -func (u *XdrAnon_PeerAddress_Ip) Ipv4() *[4]byte { - switch u.Type { - case IPv4: - if v, ok := u._u.(*[4]byte); ok { +func (u *TransactionMeta) V1() *TransactionMetaV1 { + switch u.V { + case 1: + if v, ok := u._u.(*TransactionMetaV1); ok { return v } else { - var zero [4]byte + var zero TransactionMetaV1 u._u = &zero return &zero } default: - XdrPanic("XdrAnon_PeerAddress_Ip.Ipv4 accessed when Type == %v", u.Type) + XdrPanic("TransactionMeta.V1 accessed when V == %v", u.V) return nil } } -func (u *XdrAnon_PeerAddress_Ip) Ipv6() *[16]byte { - switch u.Type { - case IPv6: - if v, ok := u._u.(*[16]byte); ok { +func (u *TransactionMeta) V2() *TransactionMetaV2 { + switch u.V { + case 2: + if v, ok := u._u.(*TransactionMetaV2); ok { return v } else { - var zero [16]byte + var zero TransactionMetaV2 u._u = &zero return &zero } default: - XdrPanic("XdrAnon_PeerAddress_Ip.Ipv6 accessed when Type == %v", u.Type) + XdrPanic("TransactionMeta.V2 accessed when V == %v", u.V) return nil } } -func (u XdrAnon_PeerAddress_Ip) XdrValid() bool { - switch u.Type { - case IPv4, IPv6: +func (u *TransactionMeta) V3() *TransactionMetaV3 { + switch u.V { + case 3: + if v, ok := u._u.(*TransactionMetaV3); ok { + return v + } else { + var zero TransactionMetaV3 + u._u = &zero + return &zero + } + default: + XdrPanic("TransactionMeta.V3 accessed when V == %v", u.V) + return nil + } +} +func (u TransactionMeta) XdrValid() bool { + switch u.V { + case 0, 1, 2, 3: return true } return false } -func (u *XdrAnon_PeerAddress_Ip) XdrUnionTag() XdrNum32 { - return XDR_IPAddrType(&u.Type) +func (u *TransactionMeta) XdrUnionTag() XdrNum32 { + return XDR_int32(&u.V) } -func (u *XdrAnon_PeerAddress_Ip) XdrUnionTagName() string { - return "Type" +func (u *TransactionMeta) XdrUnionTagName() string { + return "V" } -func (u *XdrAnon_PeerAddress_Ip) XdrUnionBody() XdrType { - switch u.Type { - case IPv4: - return (*_XdrArray_4_opaque)(u.Ipv4()) - case IPv6: - return (*_XdrArray_16_opaque)(u.Ipv6()) +func (u *TransactionMeta) XdrUnionBody() XdrType { + switch u.V { + case 0: + return (*_XdrVec_unbounded_OperationMeta)(u.Operations()) + case 1: + return XDR_TransactionMetaV1(u.V1()) + case 2: + return XDR_TransactionMetaV2(u.V2()) + case 3: + return XDR_TransactionMetaV3(u.V3()) } return nil } -func (u *XdrAnon_PeerAddress_Ip) XdrUnionBodyName() string { - switch u.Type { - case IPv4: - return "Ipv4" - case IPv6: - return "Ipv6" +func (u *TransactionMeta) XdrUnionBodyName() string { + switch u.V { + case 0: + return "Operations" + case 1: + return "V1" + case 2: + return "V2" + case 3: + return "V3" } return "" } -type XdrType_XdrAnon_PeerAddress_Ip = *XdrAnon_PeerAddress_Ip +type XdrType_TransactionMeta = *TransactionMeta -func (v *XdrAnon_PeerAddress_Ip) XdrPointer() interface{} { return v } -func (XdrAnon_PeerAddress_Ip) XdrTypeName() string { return "XdrAnon_PeerAddress_Ip" } -func (v XdrAnon_PeerAddress_Ip) XdrValue() interface{} { return v } -func (v *XdrAnon_PeerAddress_Ip) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_PeerAddress_Ip) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v *TransactionMeta) XdrPointer() interface{} { return v } +func (TransactionMeta) XdrTypeName() string { return "TransactionMeta" } +func (v TransactionMeta) XdrValue() interface{} { return v } +func (v *TransactionMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *TransactionMeta) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - XDR_IPAddrType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case IPv4: - x.Marshal(x.Sprintf("%sipv4", name), (*_XdrArray_4_opaque)(u.Ipv4())) + XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + switch u.V { + case 0: + x.Marshal(x.Sprintf("%soperations", name), (*_XdrVec_unbounded_OperationMeta)(u.Operations())) return - case IPv6: - x.Marshal(x.Sprintf("%sipv6", name), (*_XdrArray_16_opaque)(u.Ipv6())) + case 1: + x.Marshal(x.Sprintf("%sv1", name), XDR_TransactionMetaV1(u.V1())) + return + case 2: + x.Marshal(x.Sprintf("%sv2", name), XDR_TransactionMetaV2(u.V2())) + return + case 3: + x.Marshal(x.Sprintf("%sv3", name), XDR_TransactionMetaV3(u.V3())) return } - XdrPanic("invalid Type (%v) in XdrAnon_PeerAddress_Ip", u.Type) + XdrPanic("invalid V (%v) in TransactionMeta", u.V) } -func XDR_XdrAnon_PeerAddress_Ip(v *XdrAnon_PeerAddress_Ip) *XdrAnon_PeerAddress_Ip { return v } +func XDR_TransactionMeta(v *TransactionMeta) *TransactionMeta { return v } -type XdrType_PeerAddress = *PeerAddress +type XdrType_TransactionResultMeta = *TransactionResultMeta -func (v *PeerAddress) XdrPointer() interface{} { return v } -func (PeerAddress) XdrTypeName() string { return "PeerAddress" } -func (v PeerAddress) XdrValue() interface{} { return v } -func (v *PeerAddress) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *PeerAddress) XdrRecurse(x XDR, name string) { +func (v *TransactionResultMeta) XdrPointer() interface{} { return v } +func (TransactionResultMeta) XdrTypeName() string { return "TransactionResultMeta" } +func (v TransactionResultMeta) XdrValue() interface{} { return v } +func (v *TransactionResultMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TransactionResultMeta) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sip", name), XDR_XdrAnon_PeerAddress_Ip(&v.Ip)) - x.Marshal(x.Sprintf("%sport", name), XDR_Uint32(&v.Port)) - x.Marshal(x.Sprintf("%snumFailures", name), XDR_Uint32(&v.NumFailures)) + x.Marshal(x.Sprintf("%sresult", name), XDR_TransactionResultPair(&v.Result)) + x.Marshal(x.Sprintf("%sfeeProcessing", name), XDR_LedgerEntryChanges(&v.FeeProcessing)) + x.Marshal(x.Sprintf("%stxApplyProcessing", name), XDR_TransactionMeta(&v.TxApplyProcessing)) } -func XDR_PeerAddress(v *PeerAddress) *PeerAddress { return v } +func XDR_TransactionResultMeta(v *TransactionResultMeta) *TransactionResultMeta { return v } -var _XdrNames_MessageType = map[int32]string{ - int32(ERROR_MSG): "ERROR_MSG", - int32(AUTH): "AUTH", - int32(DONT_HAVE): "DONT_HAVE", - int32(GET_PEERS): "GET_PEERS", - int32(PEERS): "PEERS", - int32(GET_TX_SET): "GET_TX_SET", - int32(TX_SET): "TX_SET", - int32(GENERALIZED_TX_SET): "GENERALIZED_TX_SET", - int32(TRANSACTION): "TRANSACTION", - int32(GET_SCP_QUORUMSET): "GET_SCP_QUORUMSET", - int32(SCP_QUORUMSET): "SCP_QUORUMSET", - int32(SCP_MESSAGE): "SCP_MESSAGE", - int32(GET_SCP_STATE): "GET_SCP_STATE", - int32(HELLO): "HELLO", - int32(SURVEY_REQUEST): "SURVEY_REQUEST", - int32(SURVEY_RESPONSE): "SURVEY_RESPONSE", - int32(SEND_MORE): "SEND_MORE", - int32(SEND_MORE_EXTENDED): "SEND_MORE_EXTENDED", - int32(FLOOD_ADVERT): "FLOOD_ADVERT", - int32(FLOOD_DEMAND): "FLOOD_DEMAND", - int32(TIME_SLICED_SURVEY_REQUEST): "TIME_SLICED_SURVEY_REQUEST", - int32(TIME_SLICED_SURVEY_RESPONSE): "TIME_SLICED_SURVEY_RESPONSE", - int32(TIME_SLICED_SURVEY_START_COLLECTING): "TIME_SLICED_SURVEY_START_COLLECTING", - int32(TIME_SLICED_SURVEY_STOP_COLLECTING): "TIME_SLICED_SURVEY_STOP_COLLECTING", -} -var _XdrValues_MessageType = map[string]int32{ - "ERROR_MSG": int32(ERROR_MSG), - "AUTH": int32(AUTH), - "DONT_HAVE": int32(DONT_HAVE), - "GET_PEERS": int32(GET_PEERS), - "PEERS": int32(PEERS), - "GET_TX_SET": int32(GET_TX_SET), - "TX_SET": int32(TX_SET), - "GENERALIZED_TX_SET": int32(GENERALIZED_TX_SET), - "TRANSACTION": int32(TRANSACTION), - "GET_SCP_QUORUMSET": int32(GET_SCP_QUORUMSET), - "SCP_QUORUMSET": int32(SCP_QUORUMSET), - "SCP_MESSAGE": int32(SCP_MESSAGE), - "GET_SCP_STATE": int32(GET_SCP_STATE), - "HELLO": int32(HELLO), - "SURVEY_REQUEST": int32(SURVEY_REQUEST), - "SURVEY_RESPONSE": int32(SURVEY_RESPONSE), - "SEND_MORE": int32(SEND_MORE), - "SEND_MORE_EXTENDED": int32(SEND_MORE_EXTENDED), - "FLOOD_ADVERT": int32(FLOOD_ADVERT), - "FLOOD_DEMAND": int32(FLOOD_DEMAND), - "TIME_SLICED_SURVEY_REQUEST": int32(TIME_SLICED_SURVEY_REQUEST), - "TIME_SLICED_SURVEY_RESPONSE": int32(TIME_SLICED_SURVEY_RESPONSE), - "TIME_SLICED_SURVEY_START_COLLECTING": int32(TIME_SLICED_SURVEY_START_COLLECTING), - "TIME_SLICED_SURVEY_STOP_COLLECTING": int32(TIME_SLICED_SURVEY_STOP_COLLECTING), +type XdrType_UpgradeEntryMeta = *UpgradeEntryMeta + +func (v *UpgradeEntryMeta) XdrPointer() interface{} { return v } +func (UpgradeEntryMeta) XdrTypeName() string { return "UpgradeEntryMeta" } +func (v UpgradeEntryMeta) XdrValue() interface{} { return v } +func (v *UpgradeEntryMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *UpgradeEntryMeta) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%supgrade", name), XDR_LedgerUpgrade(&v.Upgrade)) + x.Marshal(x.Sprintf("%schanges", name), XDR_LedgerEntryChanges(&v.Changes)) } +func XDR_UpgradeEntryMeta(v *UpgradeEntryMeta) *UpgradeEntryMeta { return v } -func (MessageType) XdrEnumNames() map[int32]string { - return _XdrNames_MessageType +type _XdrVec_unbounded_TransactionResultMeta []TransactionResultMeta + +func (_XdrVec_unbounded_TransactionResultMeta) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v MessageType) String() string { - if s, ok := _XdrNames_MessageType[int32(v)]; ok { - return s +func (_XdrVec_unbounded_TransactionResultMeta) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_TransactionResultMeta length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_TransactionResultMeta length %d exceeds max int", length) } - return fmt.Sprintf("MessageType#%d", v) } -func (v *MessageType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_MessageType[stok]; ok { - *v = MessageType(val) - return nil - } else if stok == "MessageType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } +func (v _XdrVec_unbounded_TransactionResultMeta) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_TransactionResultMeta) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] } - return XdrError(fmt.Sprintf("%s is not a valid MessageType.", stok)) + return } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]TransactionResultMeta, int(length), newcap) + copy(nv, *v) + *v = nv } -func (v MessageType) GetU32() uint32 { return uint32(v) } -func (v *MessageType) SetU32(n uint32) { *v = MessageType(n) } -func (v *MessageType) XdrPointer() interface{} { return v } -func (MessageType) XdrTypeName() string { return "MessageType" } -func (v MessageType) XdrValue() interface{} { return v } -func (v *MessageType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_MessageType = *MessageType - -func XDR_MessageType(v *MessageType) *MessageType { return v } - -var _XdrComments_MessageType = map[int32]string{ - int32(GET_PEERS): "gets a list of peers this guy knows about", - int32(GET_TX_SET): "gets a particular txset by hash", - int32(TRANSACTION): "pass on a tx you have heard about", - int32(GET_SCP_QUORUMSET): "SCP", - int32(HELLO): "new messages", -} - -func (e MessageType) XdrEnumComments() map[int32]string { - return _XdrComments_MessageType -} - -type XdrType_DontHave = *DontHave - -func (v *DontHave) XdrPointer() interface{} { return v } -func (DontHave) XdrTypeName() string { return "DontHave" } -func (v DontHave) XdrValue() interface{} { return v } -func (v *DontHave) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *DontHave) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v *_XdrVec_unbounded_TransactionResultMeta) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_TransactionResultMeta(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] } - x.Marshal(x.Sprintf("%stype", name), XDR_MessageType(&v.Type)) - x.Marshal(x.Sprintf("%sreqHash", name), XDR_Uint256(&v.ReqHash)) } -func XDR_DontHave(v *DontHave) *DontHave { return v } - -var _XdrNames_SurveyMessageCommandType = map[int32]string{ - int32(SURVEY_TOPOLOGY): "SURVEY_TOPOLOGY", - int32(TIME_SLICED_SURVEY_TOPOLOGY): "TIME_SLICED_SURVEY_TOPOLOGY", +func (v *_XdrVec_unbounded_TransactionResultMeta) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } -var _XdrValues_SurveyMessageCommandType = map[string]int32{ - "SURVEY_TOPOLOGY": int32(SURVEY_TOPOLOGY), - "TIME_SLICED_SURVEY_TOPOLOGY": int32(TIME_SLICED_SURVEY_TOPOLOGY), +func (_XdrVec_unbounded_TransactionResultMeta) XdrTypeName() string { return "TransactionResultMeta<>" } +func (v *_XdrVec_unbounded_TransactionResultMeta) XdrPointer() interface{} { + return (*[]TransactionResultMeta)(v) } - -func (SurveyMessageCommandType) XdrEnumNames() map[int32]string { - return _XdrNames_SurveyMessageCommandType +func (v _XdrVec_unbounded_TransactionResultMeta) XdrValue() interface{} { + return ([]TransactionResultMeta)(v) } -func (v SurveyMessageCommandType) String() string { - if s, ok := _XdrNames_SurveyMessageCommandType[int32(v)]; ok { - return s - } - return fmt.Sprintf("SurveyMessageCommandType#%d", v) +func (v *_XdrVec_unbounded_TransactionResultMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type _XdrVec_unbounded_UpgradeEntryMeta []UpgradeEntryMeta + +func (_XdrVec_unbounded_UpgradeEntryMeta) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v *SurveyMessageCommandType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_SurveyMessageCommandType[stok]; ok { - *v = SurveyMessageCommandType(val) - return nil - } else if stok == "SurveyMessageCommandType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SurveyMessageCommandType.", stok)) +func (_XdrVec_unbounded_UpgradeEntryMeta) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_UpgradeEntryMeta length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_UpgradeEntryMeta length %d exceeds max int", length) } } -func (v SurveyMessageCommandType) GetU32() uint32 { return uint32(v) } -func (v *SurveyMessageCommandType) SetU32(n uint32) { *v = SurveyMessageCommandType(n) } -func (v *SurveyMessageCommandType) XdrPointer() interface{} { return v } -func (SurveyMessageCommandType) XdrTypeName() string { return "SurveyMessageCommandType" } -func (v SurveyMessageCommandType) XdrValue() interface{} { return v } -func (v *SurveyMessageCommandType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SurveyMessageCommandType = *SurveyMessageCommandType - -func XDR_SurveyMessageCommandType(v *SurveyMessageCommandType) *SurveyMessageCommandType { return v } - -var _XdrNames_SurveyMessageResponseType = map[int32]string{ - int32(SURVEY_TOPOLOGY_RESPONSE_V0): "SURVEY_TOPOLOGY_RESPONSE_V0", - int32(SURVEY_TOPOLOGY_RESPONSE_V1): "SURVEY_TOPOLOGY_RESPONSE_V1", - int32(SURVEY_TOPOLOGY_RESPONSE_V2): "SURVEY_TOPOLOGY_RESPONSE_V2", -} -var _XdrValues_SurveyMessageResponseType = map[string]int32{ - "SURVEY_TOPOLOGY_RESPONSE_V0": int32(SURVEY_TOPOLOGY_RESPONSE_V0), - "SURVEY_TOPOLOGY_RESPONSE_V1": int32(SURVEY_TOPOLOGY_RESPONSE_V1), - "SURVEY_TOPOLOGY_RESPONSE_V2": int32(SURVEY_TOPOLOGY_RESPONSE_V2), -} - -func (SurveyMessageResponseType) XdrEnumNames() map[int32]string { - return _XdrNames_SurveyMessageResponseType -} -func (v SurveyMessageResponseType) String() string { - if s, ok := _XdrNames_SurveyMessageResponseType[int32(v)]; ok { - return s +func (v _XdrVec_unbounded_UpgradeEntryMeta) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_UpgradeEntryMeta) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return } - return fmt.Sprintf("SurveyMessageResponseType#%d", v) -} -func (v *SurveyMessageResponseType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_SurveyMessageResponseType[stok]; ok { - *v = SurveyMessageResponseType(val) - return nil - } else if stok == "SurveyMessageResponseType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 } - return XdrError(fmt.Sprintf("%s is not a valid SurveyMessageResponseType.", stok)) + newcap = int(bound) } + nv := make([]UpgradeEntryMeta, int(length), newcap) + copy(nv, *v) + *v = nv } -func (v SurveyMessageResponseType) GetU32() uint32 { return uint32(v) } -func (v *SurveyMessageResponseType) SetU32(n uint32) { *v = SurveyMessageResponseType(n) } -func (v *SurveyMessageResponseType) XdrPointer() interface{} { return v } -func (SurveyMessageResponseType) XdrTypeName() string { return "SurveyMessageResponseType" } -func (v SurveyMessageResponseType) XdrValue() interface{} { return v } -func (v *SurveyMessageResponseType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SurveyMessageResponseType = *SurveyMessageResponseType - -func XDR_SurveyMessageResponseType(v *SurveyMessageResponseType) *SurveyMessageResponseType { return v } - -type XdrType_TimeSlicedSurveyStartCollectingMessage = *TimeSlicedSurveyStartCollectingMessage - -func (v *TimeSlicedSurveyStartCollectingMessage) XdrPointer() interface{} { return v } -func (TimeSlicedSurveyStartCollectingMessage) XdrTypeName() string { - return "TimeSlicedSurveyStartCollectingMessage" -} -func (v TimeSlicedSurveyStartCollectingMessage) XdrValue() interface{} { return v } -func (v *TimeSlicedSurveyStartCollectingMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TimeSlicedSurveyStartCollectingMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_UpgradeEntryMeta(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } - x.Marshal(x.Sprintf("%ssurveyorID", name), XDR_NodeID(&v.SurveyorID)) - x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) - x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) -} -func XDR_TimeSlicedSurveyStartCollectingMessage(v *TimeSlicedSurveyStartCollectingMessage) *TimeSlicedSurveyStartCollectingMessage { - return v -} - -type XdrType_SignedTimeSlicedSurveyStartCollectingMessage = *SignedTimeSlicedSurveyStartCollectingMessage - -func (v *SignedTimeSlicedSurveyStartCollectingMessage) XdrPointer() interface{} { return v } -func (SignedTimeSlicedSurveyStartCollectingMessage) XdrTypeName() string { - return "SignedTimeSlicedSurveyStartCollectingMessage" -} -func (v SignedTimeSlicedSurveyStartCollectingMessage) XdrValue() interface{} { return v } -func (v *SignedTimeSlicedSurveyStartCollectingMessage) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} -func (v *SignedTimeSlicedSurveyStartCollectingMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) + if int(n) < len(*v) { + *v = (*v)[:int(n)] } - x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) - x.Marshal(x.Sprintf("%sstartCollecting", name), XDR_TimeSlicedSurveyStartCollectingMessage(&v.StartCollecting)) } -func XDR_SignedTimeSlicedSurveyStartCollectingMessage(v *SignedTimeSlicedSurveyStartCollectingMessage) *SignedTimeSlicedSurveyStartCollectingMessage { - return v +func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_unbounded_UpgradeEntryMeta) XdrTypeName() string { return "UpgradeEntryMeta<>" } +func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrPointer() interface{} { + return (*[]UpgradeEntryMeta)(v) } +func (v _XdrVec_unbounded_UpgradeEntryMeta) XdrValue() interface{} { return ([]UpgradeEntryMeta)(v) } +func (v *_XdrVec_unbounded_UpgradeEntryMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_TimeSlicedSurveyStopCollectingMessage = *TimeSlicedSurveyStopCollectingMessage +type _XdrVec_unbounded_SCPHistoryEntry []SCPHistoryEntry -func (v *TimeSlicedSurveyStopCollectingMessage) XdrPointer() interface{} { return v } -func (TimeSlicedSurveyStopCollectingMessage) XdrTypeName() string { - return "TimeSlicedSurveyStopCollectingMessage" +func (_XdrVec_unbounded_SCPHistoryEntry) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v TimeSlicedSurveyStopCollectingMessage) XdrValue() interface{} { return v } -func (v *TimeSlicedSurveyStopCollectingMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TimeSlicedSurveyStopCollectingMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (_XdrVec_unbounded_SCPHistoryEntry) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_SCPHistoryEntry length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_SCPHistoryEntry length %d exceeds max int", length) } - x.Marshal(x.Sprintf("%ssurveyorID", name), XDR_NodeID(&v.SurveyorID)) - x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) - x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) -} -func XDR_TimeSlicedSurveyStopCollectingMessage(v *TimeSlicedSurveyStopCollectingMessage) *TimeSlicedSurveyStopCollectingMessage { - return v -} - -type XdrType_SignedTimeSlicedSurveyStopCollectingMessage = *SignedTimeSlicedSurveyStopCollectingMessage - -func (v *SignedTimeSlicedSurveyStopCollectingMessage) XdrPointer() interface{} { return v } -func (SignedTimeSlicedSurveyStopCollectingMessage) XdrTypeName() string { - return "SignedTimeSlicedSurveyStopCollectingMessage" } -func (v SignedTimeSlicedSurveyStopCollectingMessage) XdrValue() interface{} { return v } -func (v *SignedTimeSlicedSurveyStopCollectingMessage) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) +func (v _XdrVec_unbounded_SCPHistoryEntry) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_SCPHistoryEntry) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return + } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]SCPHistoryEntry, int(length), newcap) + copy(nv, *v) + *v = nv } -func (v *SignedTimeSlicedSurveyStopCollectingMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_SCPHistoryEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] } - x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) - x.Marshal(x.Sprintf("%sstopCollecting", name), XDR_TimeSlicedSurveyStopCollectingMessage(&v.StopCollecting)) } -func XDR_SignedTimeSlicedSurveyStopCollectingMessage(v *SignedTimeSlicedSurveyStopCollectingMessage) *SignedTimeSlicedSurveyStopCollectingMessage { - return v +func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } +func (_XdrVec_unbounded_SCPHistoryEntry) XdrTypeName() string { return "SCPHistoryEntry<>" } +func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrPointer() interface{} { return (*[]SCPHistoryEntry)(v) } +func (v _XdrVec_unbounded_SCPHistoryEntry) XdrValue() interface{} { return ([]SCPHistoryEntry)(v) } +func (v *_XdrVec_unbounded_SCPHistoryEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_SurveyRequestMessage = *SurveyRequestMessage +type XdrType_LedgerCloseMetaV0 = *LedgerCloseMetaV0 -func (v *SurveyRequestMessage) XdrPointer() interface{} { return v } -func (SurveyRequestMessage) XdrTypeName() string { return "SurveyRequestMessage" } -func (v SurveyRequestMessage) XdrValue() interface{} { return v } -func (v *SurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SurveyRequestMessage) XdrRecurse(x XDR, name string) { +func (v *LedgerCloseMetaV0) XdrPointer() interface{} { return v } +func (LedgerCloseMetaV0) XdrTypeName() string { return "LedgerCloseMetaV0" } +func (v LedgerCloseMetaV0) XdrValue() interface{} { return v } +func (v *LedgerCloseMetaV0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerCloseMetaV0) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%ssurveyorPeerID", name), XDR_NodeID(&v.SurveyorPeerID)) - x.Marshal(x.Sprintf("%ssurveyedPeerID", name), XDR_NodeID(&v.SurveyedPeerID)) - x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) - x.Marshal(x.Sprintf("%sencryptionKey", name), XDR_Curve25519Public(&v.EncryptionKey)) - x.Marshal(x.Sprintf("%scommandType", name), XDR_SurveyMessageCommandType(&v.CommandType)) + x.Marshal(x.Sprintf("%sledgerHeader", name), XDR_LedgerHeaderHistoryEntry(&v.LedgerHeader)) + x.Marshal(x.Sprintf("%stxSet", name), XDR_TransactionSet(&v.TxSet)) + x.Marshal(x.Sprintf("%stxProcessing", name), (*_XdrVec_unbounded_TransactionResultMeta)(&v.TxProcessing)) + x.Marshal(x.Sprintf("%supgradesProcessing", name), (*_XdrVec_unbounded_UpgradeEntryMeta)(&v.UpgradesProcessing)) + x.Marshal(x.Sprintf("%sscpInfo", name), (*_XdrVec_unbounded_SCPHistoryEntry)(&v.ScpInfo)) } -func XDR_SurveyRequestMessage(v *SurveyRequestMessage) *SurveyRequestMessage { return v } +func XDR_LedgerCloseMetaV0(v *LedgerCloseMetaV0) *LedgerCloseMetaV0 { return v } -type XdrType_TimeSlicedSurveyRequestMessage = *TimeSlicedSurveyRequestMessage +type XdrType_LedgerCloseMetaExtV1 = *LedgerCloseMetaExtV1 -func (v *TimeSlicedSurveyRequestMessage) XdrPointer() interface{} { return v } -func (TimeSlicedSurveyRequestMessage) XdrTypeName() string { return "TimeSlicedSurveyRequestMessage" } -func (v TimeSlicedSurveyRequestMessage) XdrValue() interface{} { return v } -func (v *TimeSlicedSurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TimeSlicedSurveyRequestMessage) XdrRecurse(x XDR, name string) { +func (v *LedgerCloseMetaExtV1) XdrPointer() interface{} { return v } +func (LedgerCloseMetaExtV1) XdrTypeName() string { return "LedgerCloseMetaExtV1" } +func (v LedgerCloseMetaExtV1) XdrValue() interface{} { return v } +func (v *LedgerCloseMetaExtV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerCloseMetaExtV1) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%srequest", name), XDR_SurveyRequestMessage(&v.Request)) - x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) - x.Marshal(x.Sprintf("%sinboundPeersIndex", name), XDR_Uint32(&v.InboundPeersIndex)) - x.Marshal(x.Sprintf("%soutboundPeersIndex", name), XDR_Uint32(&v.OutboundPeersIndex)) + x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) + x.Marshal(x.Sprintf("%ssorobanFeeWrite1KB", name), XDR_Int64(&v.SorobanFeeWrite1KB)) } -func XDR_TimeSlicedSurveyRequestMessage(v *TimeSlicedSurveyRequestMessage) *TimeSlicedSurveyRequestMessage { - return v +func XDR_LedgerCloseMetaExtV1(v *LedgerCloseMetaExtV1) *LedgerCloseMetaExtV1 { return v } + +var _XdrTags_LedgerCloseMetaExt = map[int32]bool{ + XdrToI32(0): true, + XdrToI32(1): true, } -type XdrType_SignedSurveyRequestMessage = *SignedSurveyRequestMessage - -func (v *SignedSurveyRequestMessage) XdrPointer() interface{} { return v } -func (SignedSurveyRequestMessage) XdrTypeName() string { return "SignedSurveyRequestMessage" } -func (v SignedSurveyRequestMessage) XdrValue() interface{} { return v } -func (v *SignedSurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SignedSurveyRequestMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%srequestSignature", name), XDR_Signature(&v.RequestSignature)) - x.Marshal(x.Sprintf("%srequest", name), XDR_SurveyRequestMessage(&v.Request)) -} -func XDR_SignedSurveyRequestMessage(v *SignedSurveyRequestMessage) *SignedSurveyRequestMessage { - return v -} - -type XdrType_SignedTimeSlicedSurveyRequestMessage = *SignedTimeSlicedSurveyRequestMessage - -func (v *SignedTimeSlicedSurveyRequestMessage) XdrPointer() interface{} { return v } -func (SignedTimeSlicedSurveyRequestMessage) XdrTypeName() string { - return "SignedTimeSlicedSurveyRequestMessage" +func (_ LedgerCloseMetaExt) XdrValidTags() map[int32]bool { + return _XdrTags_LedgerCloseMetaExt } -func (v SignedTimeSlicedSurveyRequestMessage) XdrValue() interface{} { return v } -func (v *SignedTimeSlicedSurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SignedTimeSlicedSurveyRequestMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *LedgerCloseMetaExt) V1() *LedgerCloseMetaExtV1 { + switch u.V { + case 1: + if v, ok := u._u.(*LedgerCloseMetaExtV1); ok { + return v + } else { + var zero LedgerCloseMetaExtV1 + u._u = &zero + return &zero + } + default: + XdrPanic("LedgerCloseMetaExt.V1 accessed when V == %v", u.V) + return nil } - x.Marshal(x.Sprintf("%srequestSignature", name), XDR_Signature(&v.RequestSignature)) - x.Marshal(x.Sprintf("%srequest", name), XDR_TimeSlicedSurveyRequestMessage(&v.Request)) } -func XDR_SignedTimeSlicedSurveyRequestMessage(v *SignedTimeSlicedSurveyRequestMessage) *SignedTimeSlicedSurveyRequestMessage { - return v +func (u LedgerCloseMetaExt) XdrValid() bool { + switch u.V { + case 0, 1: + return true + } + return false } - -type XdrType_EncryptedBody struct { - XdrVecOpaque +func (u *LedgerCloseMetaExt) XdrUnionTag() XdrNum32 { + return XDR_int32(&u.V) } - -func XDR_EncryptedBody(v *EncryptedBody) XdrType_EncryptedBody { - return XdrType_EncryptedBody{XdrVecOpaque{v, 64000}} +func (u *LedgerCloseMetaExt) XdrUnionTagName() string { + return "V" } -func (XdrType_EncryptedBody) XdrTypeName() string { return "EncryptedBody" } -func (v XdrType_EncryptedBody) XdrUnwrap() XdrType { return v.XdrVecOpaque } - -type XdrType_SurveyResponseMessage = *SurveyResponseMessage - -func (v *SurveyResponseMessage) XdrPointer() interface{} { return v } -func (SurveyResponseMessage) XdrTypeName() string { return "SurveyResponseMessage" } -func (v SurveyResponseMessage) XdrValue() interface{} { return v } -func (v *SurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SurveyResponseMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *LedgerCloseMetaExt) XdrUnionBody() XdrType { + switch u.V { + case 0: + return nil + case 1: + return XDR_LedgerCloseMetaExtV1(u.V1()) } - x.Marshal(x.Sprintf("%ssurveyorPeerID", name), XDR_NodeID(&v.SurveyorPeerID)) - x.Marshal(x.Sprintf("%ssurveyedPeerID", name), XDR_NodeID(&v.SurveyedPeerID)) - x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) - x.Marshal(x.Sprintf("%scommandType", name), XDR_SurveyMessageCommandType(&v.CommandType)) - x.Marshal(x.Sprintf("%sencryptedBody", name), XDR_EncryptedBody(&v.EncryptedBody)) + return nil } -func XDR_SurveyResponseMessage(v *SurveyResponseMessage) *SurveyResponseMessage { return v } - -type XdrType_TimeSlicedSurveyResponseMessage = *TimeSlicedSurveyResponseMessage - -func (v *TimeSlicedSurveyResponseMessage) XdrPointer() interface{} { return v } -func (TimeSlicedSurveyResponseMessage) XdrTypeName() string { return "TimeSlicedSurveyResponseMessage" } -func (v TimeSlicedSurveyResponseMessage) XdrValue() interface{} { return v } -func (v *TimeSlicedSurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TimeSlicedSurveyResponseMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *LedgerCloseMetaExt) XdrUnionBodyName() string { + switch u.V { + case 0: + return "" + case 1: + return "V1" } - x.Marshal(x.Sprintf("%sresponse", name), XDR_SurveyResponseMessage(&v.Response)) - x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) -} -func XDR_TimeSlicedSurveyResponseMessage(v *TimeSlicedSurveyResponseMessage) *TimeSlicedSurveyResponseMessage { - return v + return "" } -type XdrType_SignedSurveyResponseMessage = *SignedSurveyResponseMessage +type XdrType_LedgerCloseMetaExt = *LedgerCloseMetaExt -func (v *SignedSurveyResponseMessage) XdrPointer() interface{} { return v } -func (SignedSurveyResponseMessage) XdrTypeName() string { return "SignedSurveyResponseMessage" } -func (v SignedSurveyResponseMessage) XdrValue() interface{} { return v } -func (v *SignedSurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SignedSurveyResponseMessage) XdrRecurse(x XDR, name string) { +func (v *LedgerCloseMetaExt) XdrPointer() interface{} { return v } +func (LedgerCloseMetaExt) XdrTypeName() string { return "LedgerCloseMetaExt" } +func (v LedgerCloseMetaExt) XdrValue() interface{} { return v } +func (v *LedgerCloseMetaExt) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *LedgerCloseMetaExt) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sresponseSignature", name), XDR_Signature(&v.ResponseSignature)) - x.Marshal(x.Sprintf("%sresponse", name), XDR_SurveyResponseMessage(&v.Response)) -} -func XDR_SignedSurveyResponseMessage(v *SignedSurveyResponseMessage) *SignedSurveyResponseMessage { - return v + XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + switch u.V { + case 0: + return + case 1: + x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerCloseMetaExtV1(u.V1())) + return + } + XdrPanic("invalid V (%v) in LedgerCloseMetaExt", u.V) } +func XDR_LedgerCloseMetaExt(v *LedgerCloseMetaExt) *LedgerCloseMetaExt { return v } -type XdrType_SignedTimeSlicedSurveyResponseMessage = *SignedTimeSlicedSurveyResponseMessage +type _XdrVec_unbounded_LedgerKey []LedgerKey -func (v *SignedTimeSlicedSurveyResponseMessage) XdrPointer() interface{} { return v } -func (SignedTimeSlicedSurveyResponseMessage) XdrTypeName() string { - return "SignedTimeSlicedSurveyResponseMessage" +func (_XdrVec_unbounded_LedgerKey) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v SignedTimeSlicedSurveyResponseMessage) XdrValue() interface{} { return v } -func (v *SignedTimeSlicedSurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SignedTimeSlicedSurveyResponseMessage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (_XdrVec_unbounded_LedgerKey) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_LedgerKey length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_LedgerKey length %d exceeds max int", length) } - x.Marshal(x.Sprintf("%sresponseSignature", name), XDR_Signature(&v.ResponseSignature)) - x.Marshal(x.Sprintf("%sresponse", name), XDR_TimeSlicedSurveyResponseMessage(&v.Response)) } -func XDR_SignedTimeSlicedSurveyResponseMessage(v *SignedTimeSlicedSurveyResponseMessage) *SignedTimeSlicedSurveyResponseMessage { - return v +func (v _XdrVec_unbounded_LedgerKey) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_LedgerKey) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return + } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]LedgerKey, int(length), newcap) + copy(nv, *v) + *v = nv } - -type XdrType_PeerStats = *PeerStats - -func (v *PeerStats) XdrPointer() interface{} { return v } -func (PeerStats) XdrTypeName() string { return "PeerStats" } -func (v PeerStats) XdrValue() interface{} { return v } -func (v *PeerStats) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *PeerStats) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (v *_XdrVec_unbounded_LedgerKey) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_LedgerKey(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] } - x.Marshal(x.Sprintf("%sid", name), XDR_NodeID(&v.Id)) - x.Marshal(x.Sprintf("%sversionStr", name), XdrString{&v.VersionStr, 100}) - x.Marshal(x.Sprintf("%smessagesRead", name), XDR_Uint64(&v.MessagesRead)) - x.Marshal(x.Sprintf("%smessagesWritten", name), XDR_Uint64(&v.MessagesWritten)) - x.Marshal(x.Sprintf("%sbytesRead", name), XDR_Uint64(&v.BytesRead)) - x.Marshal(x.Sprintf("%sbytesWritten", name), XDR_Uint64(&v.BytesWritten)) - x.Marshal(x.Sprintf("%ssecondsConnected", name), XDR_Uint64(&v.SecondsConnected)) - x.Marshal(x.Sprintf("%suniqueFloodBytesRecv", name), XDR_Uint64(&v.UniqueFloodBytesRecv)) - x.Marshal(x.Sprintf("%sduplicateFloodBytesRecv", name), XDR_Uint64(&v.DuplicateFloodBytesRecv)) - x.Marshal(x.Sprintf("%suniqueFetchBytesRecv", name), XDR_Uint64(&v.UniqueFetchBytesRecv)) - x.Marshal(x.Sprintf("%sduplicateFetchBytesRecv", name), XDR_Uint64(&v.DuplicateFetchBytesRecv)) - x.Marshal(x.Sprintf("%suniqueFloodMessageRecv", name), XDR_Uint64(&v.UniqueFloodMessageRecv)) - x.Marshal(x.Sprintf("%sduplicateFloodMessageRecv", name), XDR_Uint64(&v.DuplicateFloodMessageRecv)) - x.Marshal(x.Sprintf("%suniqueFetchMessageRecv", name), XDR_Uint64(&v.UniqueFetchMessageRecv)) - x.Marshal(x.Sprintf("%sduplicateFetchMessageRecv", name), XDR_Uint64(&v.DuplicateFetchMessageRecv)) } -func XDR_PeerStats(v *PeerStats) *PeerStats { return v } +func (v *_XdrVec_unbounded_LedgerKey) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_unbounded_LedgerKey) XdrTypeName() string { return "LedgerKey<>" } +func (v *_XdrVec_unbounded_LedgerKey) XdrPointer() interface{} { return (*[]LedgerKey)(v) } +func (v _XdrVec_unbounded_LedgerKey) XdrValue() interface{} { return ([]LedgerKey)(v) } +func (v *_XdrVec_unbounded_LedgerKey) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type _XdrVec_25_PeerStats []PeerStats +type _XdrVec_unbounded_LedgerEntry []LedgerEntry -func (_XdrVec_25_PeerStats) XdrBound() uint32 { - const bound uint32 = 25 // Force error if not const or doesn't fit +func (_XdrVec_unbounded_LedgerEntry) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_25_PeerStats) XdrCheckLen(length uint32) { - if length > uint32(25) { - XdrPanic("_XdrVec_25_PeerStats length %d exceeds bound 25", length) +func (_XdrVec_unbounded_LedgerEntry) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_LedgerEntry length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_25_PeerStats length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_LedgerEntry length %d exceeds max int", length) } } -func (v _XdrVec_25_PeerStats) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_25_PeerStats) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_LedgerEntry) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_LedgerEntry) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -13937,1492 +13729,1074 @@ func (v *_XdrVec_25_PeerStats) SetVecLen(length uint32) { newcap := 2 * cap(*v) if newcap < int(length) { // also catches overflow where 2*cap < 0 newcap = int(length) - } else if bound := uint(25); uint(newcap) > bound { + } else if bound := uint(4294967295); uint(newcap) > bound { if int(bound) < 0 { bound = ^uint(0) >> 1 } newcap = int(bound) } - nv := make([]PeerStats, int(length), newcap) + nv := make([]LedgerEntry, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_25_PeerStats) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_LedgerEntry) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_PeerStats(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_LedgerEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_25_PeerStats) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 25} +func (v *_XdrVec_unbounded_LedgerEntry) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_25_PeerStats) XdrTypeName() string { return "PeerStats<>" } -func (v *_XdrVec_25_PeerStats) XdrPointer() interface{} { return (*[]PeerStats)(v) } -func (v _XdrVec_25_PeerStats) XdrValue() interface{} { return ([]PeerStats)(v) } -func (v *_XdrVec_25_PeerStats) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_PeerStatList struct { - *_XdrVec_25_PeerStats -} - -func XDR_PeerStatList(v *PeerStatList) XdrType_PeerStatList { - return XdrType_PeerStatList{(*_XdrVec_25_PeerStats)(v)} -} -func (XdrType_PeerStatList) XdrTypeName() string { return "PeerStatList" } -func (v XdrType_PeerStatList) XdrUnwrap() XdrType { return v._XdrVec_25_PeerStats } - -type XdrType_TimeSlicedNodeData = *TimeSlicedNodeData - -func (v *TimeSlicedNodeData) XdrPointer() interface{} { return v } -func (TimeSlicedNodeData) XdrTypeName() string { return "TimeSlicedNodeData" } -func (v TimeSlicedNodeData) XdrValue() interface{} { return v } -func (v *TimeSlicedNodeData) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TimeSlicedNodeData) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%saddedAuthenticatedPeers", name), XDR_Uint32(&v.AddedAuthenticatedPeers)) - x.Marshal(x.Sprintf("%sdroppedAuthenticatedPeers", name), XDR_Uint32(&v.DroppedAuthenticatedPeers)) - x.Marshal(x.Sprintf("%stotalInboundPeerCount", name), XDR_Uint32(&v.TotalInboundPeerCount)) - x.Marshal(x.Sprintf("%stotalOutboundPeerCount", name), XDR_Uint32(&v.TotalOutboundPeerCount)) - x.Marshal(x.Sprintf("%sp75SCPFirstToSelfLatencyMs", name), XDR_Uint32(&v.P75SCPFirstToSelfLatencyMs)) - x.Marshal(x.Sprintf("%sp75SCPSelfToOtherLatencyMs", name), XDR_Uint32(&v.P75SCPSelfToOtherLatencyMs)) - x.Marshal(x.Sprintf("%slostSyncCount", name), XDR_Uint32(&v.LostSyncCount)) - x.Marshal(x.Sprintf("%sisValidator", name), XDR_bool(&v.IsValidator)) - x.Marshal(x.Sprintf("%smaxInboundPeerCount", name), XDR_Uint32(&v.MaxInboundPeerCount)) - x.Marshal(x.Sprintf("%smaxOutboundPeerCount", name), XDR_Uint32(&v.MaxOutboundPeerCount)) -} -func XDR_TimeSlicedNodeData(v *TimeSlicedNodeData) *TimeSlicedNodeData { return v } - -type XdrType_TimeSlicedPeerData = *TimeSlicedPeerData - -func (v *TimeSlicedPeerData) XdrPointer() interface{} { return v } -func (TimeSlicedPeerData) XdrTypeName() string { return "TimeSlicedPeerData" } -func (v TimeSlicedPeerData) XdrValue() interface{} { return v } -func (v *TimeSlicedPeerData) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TimeSlicedPeerData) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%speerStats", name), XDR_PeerStats(&v.PeerStats)) - x.Marshal(x.Sprintf("%saverageLatencyMs", name), XDR_Uint32(&v.AverageLatencyMs)) -} -func XDR_TimeSlicedPeerData(v *TimeSlicedPeerData) *TimeSlicedPeerData { return v } - -type _XdrVec_25_TimeSlicedPeerData []TimeSlicedPeerData - -func (_XdrVec_25_TimeSlicedPeerData) XdrBound() uint32 { - const bound uint32 = 25 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_25_TimeSlicedPeerData) XdrCheckLen(length uint32) { - if length > uint32(25) { - XdrPanic("_XdrVec_25_TimeSlicedPeerData length %d exceeds bound 25", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_25_TimeSlicedPeerData length %d exceeds max int", length) - } -} -func (v _XdrVec_25_TimeSlicedPeerData) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_25_TimeSlicedPeerData) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(25); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) - } - nv := make([]TimeSlicedPeerData, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_25_TimeSlicedPeerData) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_TimeSlicedPeerData(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_25_TimeSlicedPeerData) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 25} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_25_TimeSlicedPeerData) XdrTypeName() string { return "TimeSlicedPeerData<>" } -func (v *_XdrVec_25_TimeSlicedPeerData) XdrPointer() interface{} { return (*[]TimeSlicedPeerData)(v) } -func (v _XdrVec_25_TimeSlicedPeerData) XdrValue() interface{} { return ([]TimeSlicedPeerData)(v) } -func (v *_XdrVec_25_TimeSlicedPeerData) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_TimeSlicedPeerDataList struct { - *_XdrVec_25_TimeSlicedPeerData -} - -func XDR_TimeSlicedPeerDataList(v *TimeSlicedPeerDataList) XdrType_TimeSlicedPeerDataList { - return XdrType_TimeSlicedPeerDataList{(*_XdrVec_25_TimeSlicedPeerData)(v)} -} -func (XdrType_TimeSlicedPeerDataList) XdrTypeName() string { return "TimeSlicedPeerDataList" } -func (v XdrType_TimeSlicedPeerDataList) XdrUnwrap() XdrType { return v._XdrVec_25_TimeSlicedPeerData } - -type XdrType_TopologyResponseBodyV0 = *TopologyResponseBodyV0 - -func (v *TopologyResponseBodyV0) XdrPointer() interface{} { return v } -func (TopologyResponseBodyV0) XdrTypeName() string { return "TopologyResponseBodyV0" } -func (v TopologyResponseBodyV0) XdrValue() interface{} { return v } -func (v *TopologyResponseBodyV0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TopologyResponseBodyV0) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sinboundPeers", name), XDR_PeerStatList(&v.InboundPeers)) - x.Marshal(x.Sprintf("%soutboundPeers", name), XDR_PeerStatList(&v.OutboundPeers)) - x.Marshal(x.Sprintf("%stotalInboundPeerCount", name), XDR_Uint32(&v.TotalInboundPeerCount)) - x.Marshal(x.Sprintf("%stotalOutboundPeerCount", name), XDR_Uint32(&v.TotalOutboundPeerCount)) -} -func XDR_TopologyResponseBodyV0(v *TopologyResponseBodyV0) *TopologyResponseBodyV0 { return v } - -type XdrType_TopologyResponseBodyV1 = *TopologyResponseBodyV1 - -func (v *TopologyResponseBodyV1) XdrPointer() interface{} { return v } -func (TopologyResponseBodyV1) XdrTypeName() string { return "TopologyResponseBodyV1" } -func (v TopologyResponseBodyV1) XdrValue() interface{} { return v } -func (v *TopologyResponseBodyV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TopologyResponseBodyV1) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sinboundPeers", name), XDR_PeerStatList(&v.InboundPeers)) - x.Marshal(x.Sprintf("%soutboundPeers", name), XDR_PeerStatList(&v.OutboundPeers)) - x.Marshal(x.Sprintf("%stotalInboundPeerCount", name), XDR_Uint32(&v.TotalInboundPeerCount)) - x.Marshal(x.Sprintf("%stotalOutboundPeerCount", name), XDR_Uint32(&v.TotalOutboundPeerCount)) - x.Marshal(x.Sprintf("%smaxInboundPeerCount", name), XDR_Uint32(&v.MaxInboundPeerCount)) - x.Marshal(x.Sprintf("%smaxOutboundPeerCount", name), XDR_Uint32(&v.MaxOutboundPeerCount)) -} -func XDR_TopologyResponseBodyV1(v *TopologyResponseBodyV1) *TopologyResponseBodyV1 { return v } +func (_XdrVec_unbounded_LedgerEntry) XdrTypeName() string { return "LedgerEntry<>" } +func (v *_XdrVec_unbounded_LedgerEntry) XdrPointer() interface{} { return (*[]LedgerEntry)(v) } +func (v _XdrVec_unbounded_LedgerEntry) XdrValue() interface{} { return ([]LedgerEntry)(v) } +func (v *_XdrVec_unbounded_LedgerEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_TopologyResponseBodyV2 = *TopologyResponseBodyV2 +type XdrType_LedgerCloseMetaV1 = *LedgerCloseMetaV1 -func (v *TopologyResponseBodyV2) XdrPointer() interface{} { return v } -func (TopologyResponseBodyV2) XdrTypeName() string { return "TopologyResponseBodyV2" } -func (v TopologyResponseBodyV2) XdrValue() interface{} { return v } -func (v *TopologyResponseBodyV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TopologyResponseBodyV2) XdrRecurse(x XDR, name string) { +func (v *LedgerCloseMetaV1) XdrPointer() interface{} { return v } +func (LedgerCloseMetaV1) XdrTypeName() string { return "LedgerCloseMetaV1" } +func (v LedgerCloseMetaV1) XdrValue() interface{} { return v } +func (v *LedgerCloseMetaV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerCloseMetaV1) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sinboundPeers", name), XDR_TimeSlicedPeerDataList(&v.InboundPeers)) - x.Marshal(x.Sprintf("%soutboundPeers", name), XDR_TimeSlicedPeerDataList(&v.OutboundPeers)) - x.Marshal(x.Sprintf("%snodeData", name), XDR_TimeSlicedNodeData(&v.NodeData)) + x.Marshal(x.Sprintf("%sext", name), XDR_LedgerCloseMetaExt(&v.Ext)) + x.Marshal(x.Sprintf("%sledgerHeader", name), XDR_LedgerHeaderHistoryEntry(&v.LedgerHeader)) + x.Marshal(x.Sprintf("%stxSet", name), XDR_GeneralizedTransactionSet(&v.TxSet)) + x.Marshal(x.Sprintf("%stxProcessing", name), (*_XdrVec_unbounded_TransactionResultMeta)(&v.TxProcessing)) + x.Marshal(x.Sprintf("%supgradesProcessing", name), (*_XdrVec_unbounded_UpgradeEntryMeta)(&v.UpgradesProcessing)) + x.Marshal(x.Sprintf("%sscpInfo", name), (*_XdrVec_unbounded_SCPHistoryEntry)(&v.ScpInfo)) + x.Marshal(x.Sprintf("%stotalByteSizeOfBucketList", name), XDR_Uint64(&v.TotalByteSizeOfBucketList)) + x.Marshal(x.Sprintf("%sevictedTemporaryLedgerKeys", name), (*_XdrVec_unbounded_LedgerKey)(&v.EvictedTemporaryLedgerKeys)) + x.Marshal(x.Sprintf("%sevictedPersistentLedgerEntries", name), (*_XdrVec_unbounded_LedgerEntry)(&v.EvictedPersistentLedgerEntries)) } -func XDR_TopologyResponseBodyV2(v *TopologyResponseBodyV2) *TopologyResponseBodyV2 { return v } +func XDR_LedgerCloseMetaV1(v *LedgerCloseMetaV1) *LedgerCloseMetaV1 { return v } -var _XdrTags_SurveyResponseBody = map[int32]bool{ - XdrToI32(SURVEY_TOPOLOGY_RESPONSE_V0): true, - XdrToI32(SURVEY_TOPOLOGY_RESPONSE_V1): true, - XdrToI32(SURVEY_TOPOLOGY_RESPONSE_V2): true, +var _XdrTags_LedgerCloseMeta = map[int32]bool{ + XdrToI32(0): true, + XdrToI32(1): true, } -func (_ SurveyResponseBody) XdrValidTags() map[int32]bool { - return _XdrTags_SurveyResponseBody -} -func (u *SurveyResponseBody) TopologyResponseBodyV0() *TopologyResponseBodyV0 { - switch u.Type { - case SURVEY_TOPOLOGY_RESPONSE_V0: - if v, ok := u._u.(*TopologyResponseBodyV0); ok { - return v - } else { - var zero TopologyResponseBodyV0 - u._u = &zero - return &zero - } - default: - XdrPanic("SurveyResponseBody.TopologyResponseBodyV0 accessed when Type == %v", u.Type) - return nil - } +func (_ LedgerCloseMeta) XdrValidTags() map[int32]bool { + return _XdrTags_LedgerCloseMeta } -func (u *SurveyResponseBody) TopologyResponseBodyV1() *TopologyResponseBodyV1 { - switch u.Type { - case SURVEY_TOPOLOGY_RESPONSE_V1: - if v, ok := u._u.(*TopologyResponseBodyV1); ok { +func (u *LedgerCloseMeta) V0() *LedgerCloseMetaV0 { + switch u.V { + case 0: + if v, ok := u._u.(*LedgerCloseMetaV0); ok { return v } else { - var zero TopologyResponseBodyV1 + var zero LedgerCloseMetaV0 u._u = &zero return &zero } default: - XdrPanic("SurveyResponseBody.TopologyResponseBodyV1 accessed when Type == %v", u.Type) + XdrPanic("LedgerCloseMeta.V0 accessed when V == %v", u.V) return nil } } -func (u *SurveyResponseBody) TopologyResponseBodyV2() *TopologyResponseBodyV2 { - switch u.Type { - case SURVEY_TOPOLOGY_RESPONSE_V2: - if v, ok := u._u.(*TopologyResponseBodyV2); ok { +func (u *LedgerCloseMeta) V1() *LedgerCloseMetaV1 { + switch u.V { + case 1: + if v, ok := u._u.(*LedgerCloseMetaV1); ok { return v } else { - var zero TopologyResponseBodyV2 + var zero LedgerCloseMetaV1 u._u = &zero return &zero } default: - XdrPanic("SurveyResponseBody.TopologyResponseBodyV2 accessed when Type == %v", u.Type) + XdrPanic("LedgerCloseMeta.V1 accessed when V == %v", u.V) return nil } } -func (u SurveyResponseBody) XdrValid() bool { - switch u.Type { - case SURVEY_TOPOLOGY_RESPONSE_V0, SURVEY_TOPOLOGY_RESPONSE_V1, SURVEY_TOPOLOGY_RESPONSE_V2: +func (u LedgerCloseMeta) XdrValid() bool { + switch u.V { + case 0, 1: return true } return false } -func (u *SurveyResponseBody) XdrUnionTag() XdrNum32 { - return XDR_SurveyMessageResponseType(&u.Type) +func (u *LedgerCloseMeta) XdrUnionTag() XdrNum32 { + return XDR_int32(&u.V) } -func (u *SurveyResponseBody) XdrUnionTagName() string { - return "Type" +func (u *LedgerCloseMeta) XdrUnionTagName() string { + return "V" } -func (u *SurveyResponseBody) XdrUnionBody() XdrType { - switch u.Type { - case SURVEY_TOPOLOGY_RESPONSE_V0: - return XDR_TopologyResponseBodyV0(u.TopologyResponseBodyV0()) - case SURVEY_TOPOLOGY_RESPONSE_V1: - return XDR_TopologyResponseBodyV1(u.TopologyResponseBodyV1()) - case SURVEY_TOPOLOGY_RESPONSE_V2: - return XDR_TopologyResponseBodyV2(u.TopologyResponseBodyV2()) - } +func (u *LedgerCloseMeta) XdrUnionBody() XdrType { + switch u.V { + case 0: + return XDR_LedgerCloseMetaV0(u.V0()) + case 1: + return XDR_LedgerCloseMetaV1(u.V1()) + } return nil } -func (u *SurveyResponseBody) XdrUnionBodyName() string { - switch u.Type { - case SURVEY_TOPOLOGY_RESPONSE_V0: - return "TopologyResponseBodyV0" - case SURVEY_TOPOLOGY_RESPONSE_V1: - return "TopologyResponseBodyV1" - case SURVEY_TOPOLOGY_RESPONSE_V2: - return "TopologyResponseBodyV2" +func (u *LedgerCloseMeta) XdrUnionBodyName() string { + switch u.V { + case 0: + return "V0" + case 1: + return "V1" } return "" } -type XdrType_SurveyResponseBody = *SurveyResponseBody +type XdrType_LedgerCloseMeta = *LedgerCloseMeta -func (v *SurveyResponseBody) XdrPointer() interface{} { return v } -func (SurveyResponseBody) XdrTypeName() string { return "SurveyResponseBody" } -func (v SurveyResponseBody) XdrValue() interface{} { return v } -func (v *SurveyResponseBody) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *SurveyResponseBody) XdrRecurse(x XDR, name string) { +func (v *LedgerCloseMeta) XdrPointer() interface{} { return v } +func (LedgerCloseMeta) XdrTypeName() string { return "LedgerCloseMeta" } +func (v LedgerCloseMeta) XdrValue() interface{} { return v } +func (v *LedgerCloseMeta) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *LedgerCloseMeta) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_SurveyMessageResponseType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case SURVEY_TOPOLOGY_RESPONSE_V0: - x.Marshal(x.Sprintf("%stopologyResponseBodyV0", name), XDR_TopologyResponseBodyV0(u.TopologyResponseBodyV0())) - return - case SURVEY_TOPOLOGY_RESPONSE_V1: - x.Marshal(x.Sprintf("%stopologyResponseBodyV1", name), XDR_TopologyResponseBodyV1(u.TopologyResponseBodyV1())) + XDR_int32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + switch u.V { + case 0: + x.Marshal(x.Sprintf("%sv0", name), XDR_LedgerCloseMetaV0(u.V0())) return - case SURVEY_TOPOLOGY_RESPONSE_V2: - x.Marshal(x.Sprintf("%stopologyResponseBodyV2", name), XDR_TopologyResponseBodyV2(u.TopologyResponseBodyV2())) + case 1: + x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerCloseMetaV1(u.V1())) return } - XdrPanic("invalid Type (%v) in SurveyResponseBody", u.Type) + XdrPanic("invalid V (%v) in LedgerCloseMeta", u.V) } -func XDR_SurveyResponseBody(v *SurveyResponseBody) *SurveyResponseBody { return v } - -type _XdrVec_1000_Hash []Hash +func XDR_LedgerCloseMeta(v *LedgerCloseMeta) *LedgerCloseMeta { return v } -func (_XdrVec_1000_Hash) XdrBound() uint32 { - const bound uint32 = 1000 // Force error if not const or doesn't fit - return bound +var _XdrNames_ErrorCode = map[int32]string{ + int32(ERR_MISC): "ERR_MISC", + int32(ERR_DATA): "ERR_DATA", + int32(ERR_CONF): "ERR_CONF", + int32(ERR_AUTH): "ERR_AUTH", + int32(ERR_LOAD): "ERR_LOAD", } -func (_XdrVec_1000_Hash) XdrCheckLen(length uint32) { - if length > uint32(1000) { - XdrPanic("_XdrVec_1000_Hash length %d exceeds bound 1000", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_1000_Hash length %d exceeds max int", length) - } +var _XdrValues_ErrorCode = map[string]int32{ + "ERR_MISC": int32(ERR_MISC), + "ERR_DATA": int32(ERR_DATA), + "ERR_CONF": int32(ERR_CONF), + "ERR_AUTH": int32(ERR_AUTH), + "ERR_LOAD": int32(ERR_LOAD), } -func (v _XdrVec_1000_Hash) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_1000_Hash) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(1000); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) + +func (ErrorCode) XdrEnumNames() map[int32]string { + return _XdrNames_ErrorCode +} +func (v ErrorCode) String() string { + if s, ok := _XdrNames_ErrorCode[int32(v)]; ok { + return s } - nv := make([]Hash, int(length), newcap) - copy(nv, *v) - *v = nv + return fmt.Sprintf("ErrorCode#%d", v) } -func (v *_XdrVec_1000_Hash) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) +func (v *ErrorCode) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_ErrorCode[stok]; ok { + *v = ErrorCode(val) + return nil + } else if stok == "ErrorCode" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - XDR_Hash(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] + return XdrError(fmt.Sprintf("%s is not a valid ErrorCode.", stok)) } } -func (v *_XdrVec_1000_Hash) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 1000} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_1000_Hash) XdrTypeName() string { return "Hash<>" } -func (v *_XdrVec_1000_Hash) XdrPointer() interface{} { return (*[]Hash)(v) } -func (v _XdrVec_1000_Hash) XdrValue() interface{} { return ([]Hash)(v) } -func (v *_XdrVec_1000_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v ErrorCode) GetU32() uint32 { return uint32(v) } +func (v *ErrorCode) SetU32(n uint32) { *v = ErrorCode(n) } +func (v *ErrorCode) XdrPointer() interface{} { return v } +func (ErrorCode) XdrTypeName() string { return "ErrorCode" } +func (v ErrorCode) XdrValue() interface{} { return v } +func (v *ErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_TxAdvertVector struct { - *_XdrVec_1000_Hash +type XdrType_ErrorCode = *ErrorCode + +func XDR_ErrorCode(v *ErrorCode) *ErrorCode { return v } + +var _XdrComments_ErrorCode = map[int32]string{ + int32(ERR_MISC): "Unspecific error", + int32(ERR_DATA): "Malformed data", + int32(ERR_CONF): "Misconfiguration error", + int32(ERR_AUTH): "Authentication failure", + int32(ERR_LOAD): "System overloaded", } -func XDR_TxAdvertVector(v *TxAdvertVector) XdrType_TxAdvertVector { - return XdrType_TxAdvertVector{(*_XdrVec_1000_Hash)(v)} +func (e ErrorCode) XdrEnumComments() map[int32]string { + return _XdrComments_ErrorCode } -func (XdrType_TxAdvertVector) XdrTypeName() string { return "TxAdvertVector" } -func (v XdrType_TxAdvertVector) XdrUnwrap() XdrType { return v._XdrVec_1000_Hash } -type XdrType_FloodAdvert = *FloodAdvert +type XdrType_Error = *Error -func (v *FloodAdvert) XdrPointer() interface{} { return v } -func (FloodAdvert) XdrTypeName() string { return "FloodAdvert" } -func (v FloodAdvert) XdrValue() interface{} { return v } -func (v *FloodAdvert) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *FloodAdvert) XdrRecurse(x XDR, name string) { +func (v *Error) XdrPointer() interface{} { return v } +func (Error) XdrTypeName() string { return "Error" } +func (v Error) XdrValue() interface{} { return v } +func (v *Error) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *Error) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%stxHashes", name), XDR_TxAdvertVector(&v.TxHashes)) + x.Marshal(x.Sprintf("%scode", name), XDR_ErrorCode(&v.Code)) + x.Marshal(x.Sprintf("%smsg", name), XdrString{&v.Msg, 100}) } -func XDR_FloodAdvert(v *FloodAdvert) *FloodAdvert { return v } +func XDR_Error(v *Error) *Error { return v } -type XdrType_TxDemandVector struct { - *_XdrVec_1000_Hash -} +type XdrType_SendMore = *SendMore -func XDR_TxDemandVector(v *TxDemandVector) XdrType_TxDemandVector { - return XdrType_TxDemandVector{(*_XdrVec_1000_Hash)(v)} +func (v *SendMore) XdrPointer() interface{} { return v } +func (SendMore) XdrTypeName() string { return "SendMore" } +func (v SendMore) XdrValue() interface{} { return v } +func (v *SendMore) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SendMore) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%snumMessages", name), XDR_Uint32(&v.NumMessages)) } -func (XdrType_TxDemandVector) XdrTypeName() string { return "TxDemandVector" } -func (v XdrType_TxDemandVector) XdrUnwrap() XdrType { return v._XdrVec_1000_Hash } +func XDR_SendMore(v *SendMore) *SendMore { return v } -type XdrType_FloodDemand = *FloodDemand +type XdrType_SendMoreExtended = *SendMoreExtended -func (v *FloodDemand) XdrPointer() interface{} { return v } -func (FloodDemand) XdrTypeName() string { return "FloodDemand" } -func (v FloodDemand) XdrValue() interface{} { return v } -func (v *FloodDemand) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *FloodDemand) XdrRecurse(x XDR, name string) { +func (v *SendMoreExtended) XdrPointer() interface{} { return v } +func (SendMoreExtended) XdrTypeName() string { return "SendMoreExtended" } +func (v SendMoreExtended) XdrValue() interface{} { return v } +func (v *SendMoreExtended) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SendMoreExtended) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%stxHashes", name), XDR_TxDemandVector(&v.TxHashes)) + x.Marshal(x.Sprintf("%snumMessages", name), XDR_Uint32(&v.NumMessages)) + x.Marshal(x.Sprintf("%snumBytes", name), XDR_Uint32(&v.NumBytes)) } -func XDR_FloodDemand(v *FloodDemand) *FloodDemand { return v } +func XDR_SendMoreExtended(v *SendMoreExtended) *SendMoreExtended { return v } -type _XdrVec_100_PeerAddress []PeerAddress +type XdrType_AuthCert = *AuthCert -func (_XdrVec_100_PeerAddress) XdrBound() uint32 { - const bound uint32 = 100 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_100_PeerAddress) XdrCheckLen(length uint32) { - if length > uint32(100) { - XdrPanic("_XdrVec_100_PeerAddress length %d exceeds bound 100", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_100_PeerAddress length %d exceeds max int", length) +func (v *AuthCert) XdrPointer() interface{} { return v } +func (AuthCert) XdrTypeName() string { return "AuthCert" } +func (v AuthCert) XdrValue() interface{} { return v } +func (v *AuthCert) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *AuthCert) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%spubkey", name), XDR_Curve25519Public(&v.Pubkey)) + x.Marshal(x.Sprintf("%sexpiration", name), XDR_Uint64(&v.Expiration)) + x.Marshal(x.Sprintf("%ssig", name), XDR_Signature(&v.Sig)) } -func (v _XdrVec_100_PeerAddress) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_100_PeerAddress) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return +func XDR_AuthCert(v *AuthCert) *AuthCert { return v } + +type XdrType_Hello = *Hello + +func (v *Hello) XdrPointer() interface{} { return v } +func (Hello) XdrTypeName() string { return "Hello" } +func (v Hello) XdrValue() interface{} { return v } +func (v *Hello) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *Hello) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(100); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) + x.Marshal(x.Sprintf("%sledgerVersion", name), XDR_Uint32(&v.LedgerVersion)) + x.Marshal(x.Sprintf("%soverlayVersion", name), XDR_Uint32(&v.OverlayVersion)) + x.Marshal(x.Sprintf("%soverlayMinVersion", name), XDR_Uint32(&v.OverlayMinVersion)) + x.Marshal(x.Sprintf("%snetworkID", name), XDR_Hash(&v.NetworkID)) + x.Marshal(x.Sprintf("%sversionStr", name), XdrString{&v.VersionStr, 100}) + x.Marshal(x.Sprintf("%slisteningPort", name), XDR_int32(&v.ListeningPort)) + x.Marshal(x.Sprintf("%speerID", name), XDR_NodeID(&v.PeerID)) + x.Marshal(x.Sprintf("%scert", name), XDR_AuthCert(&v.Cert)) + x.Marshal(x.Sprintf("%snonce", name), XDR_Uint256(&v.Nonce)) +} +func XDR_Hello(v *Hello) *Hello { return v } + +type XdrType_Auth = *Auth + +func (v *Auth) XdrPointer() interface{} { return v } +func (Auth) XdrTypeName() string { return "Auth" } +func (v Auth) XdrValue() interface{} { return v } +func (v *Auth) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *Auth) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - nv := make([]PeerAddress, int(length), newcap) - copy(nv, *v) - *v = nv + x.Marshal(x.Sprintf("%sflags", name), XDR_int32(&v.Flags)) } -func (v *_XdrVec_100_PeerAddress) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_PeerAddress(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) +func XDR_Auth(v *Auth) *Auth { return v } + +var _XdrNames_IPAddrType = map[int32]string{ + int32(IPv4): "IPv4", + int32(IPv6): "IPv6", +} +var _XdrValues_IPAddrType = map[string]int32{ + "IPv4": int32(IPv4), + "IPv6": int32(IPv6), +} + +func (IPAddrType) XdrEnumNames() map[int32]string { + return _XdrNames_IPAddrType +} +func (v IPAddrType) String() string { + if s, ok := _XdrNames_IPAddrType[int32(v)]; ok { + return s } - if int(n) < len(*v) { - *v = (*v)[:int(n)] + return fmt.Sprintf("IPAddrType#%d", v) +} +func (v *IPAddrType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_IPAddrType[stok]; ok { + *v = IPAddrType(val) + return nil + } else if stok == "IPAddrType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid IPAddrType.", stok)) } } -func (v *_XdrVec_100_PeerAddress) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 100} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) +func (v IPAddrType) GetU32() uint32 { return uint32(v) } +func (v *IPAddrType) SetU32(n uint32) { *v = IPAddrType(n) } +func (v *IPAddrType) XdrPointer() interface{} { return v } +func (IPAddrType) XdrTypeName() string { return "IPAddrType" } +func (v IPAddrType) XdrValue() interface{} { return v } +func (v *IPAddrType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_IPAddrType = *IPAddrType + +func XDR_IPAddrType(v *IPAddrType) *IPAddrType { return v } + +type _XdrArray_16_opaque [16]byte + +func (v *_XdrArray_16_opaque) GetByteSlice() []byte { return v[:] } +func (v *_XdrArray_16_opaque) XdrTypeName() string { return "opaque[]" } +func (v *_XdrArray_16_opaque) XdrValue() interface{} { return v[:] } +func (v *_XdrArray_16_opaque) XdrPointer() interface{} { return (*[16]byte)(v) } +func (v *_XdrArray_16_opaque) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *_XdrArray_16_opaque) String() string { return fmt.Sprintf("%x", v[:]) } +func (v *_XdrArray_16_opaque) Scan(ss fmt.ScanState, c rune) error { + return XdrArrayOpaqueScan(v[:], ss, c) +} +func (_XdrArray_16_opaque) XdrArraySize() uint32 { + const bound uint32 = 16 // Force error if not const or doesn't fit + return bound } -func (_XdrVec_100_PeerAddress) XdrTypeName() string { return "PeerAddress<>" } -func (v *_XdrVec_100_PeerAddress) XdrPointer() interface{} { return (*[]PeerAddress)(v) } -func (v _XdrVec_100_PeerAddress) XdrValue() interface{} { return ([]PeerAddress)(v) } -func (v *_XdrVec_100_PeerAddress) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -var _XdrTags_StellarMessage = map[int32]bool{ - XdrToI32(ERROR_MSG): true, - XdrToI32(HELLO): true, - XdrToI32(AUTH): true, - XdrToI32(DONT_HAVE): true, - XdrToI32(GET_PEERS): true, - XdrToI32(PEERS): true, - XdrToI32(GET_TX_SET): true, - XdrToI32(TX_SET): true, - XdrToI32(GENERALIZED_TX_SET): true, - XdrToI32(TRANSACTION): true, - XdrToI32(SURVEY_REQUEST): true, - XdrToI32(SURVEY_RESPONSE): true, - XdrToI32(TIME_SLICED_SURVEY_REQUEST): true, - XdrToI32(TIME_SLICED_SURVEY_RESPONSE): true, - XdrToI32(TIME_SLICED_SURVEY_START_COLLECTING): true, - XdrToI32(TIME_SLICED_SURVEY_STOP_COLLECTING): true, - XdrToI32(GET_SCP_QUORUMSET): true, - XdrToI32(SCP_QUORUMSET): true, - XdrToI32(SCP_MESSAGE): true, - XdrToI32(GET_SCP_STATE): true, - XdrToI32(SEND_MORE): true, - XdrToI32(SEND_MORE_EXTENDED): true, - XdrToI32(FLOOD_ADVERT): true, - XdrToI32(FLOOD_DEMAND): true, +var _XdrTags_XdrAnon_PeerAddress_Ip = map[int32]bool{ + XdrToI32(IPv4): true, + XdrToI32(IPv6): true, } -func (_ StellarMessage) XdrValidTags() map[int32]bool { - return _XdrTags_StellarMessage +func (_ XdrAnon_PeerAddress_Ip) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_PeerAddress_Ip } -func (u *StellarMessage) Error() *Error { +func (u *XdrAnon_PeerAddress_Ip) Ipv4() *[4]byte { switch u.Type { - case ERROR_MSG: - if v, ok := u._u.(*Error); ok { + case IPv4: + if v, ok := u._u.(*[4]byte); ok { return v } else { - var zero Error + var zero [4]byte u._u = &zero return &zero } default: - XdrPanic("StellarMessage.Error accessed when Type == %v", u.Type) + XdrPanic("XdrAnon_PeerAddress_Ip.Ipv4 accessed when Type == %v", u.Type) return nil } } -func (u *StellarMessage) Hello() *Hello { +func (u *XdrAnon_PeerAddress_Ip) Ipv6() *[16]byte { switch u.Type { - case HELLO: - if v, ok := u._u.(*Hello); ok { + case IPv6: + if v, ok := u._u.(*[16]byte); ok { return v } else { - var zero Hello + var zero [16]byte u._u = &zero return &zero } default: - XdrPanic("StellarMessage.Hello accessed when Type == %v", u.Type) + XdrPanic("XdrAnon_PeerAddress_Ip.Ipv6 accessed when Type == %v", u.Type) return nil } } -func (u *StellarMessage) Auth() *Auth { +func (u XdrAnon_PeerAddress_Ip) XdrValid() bool { switch u.Type { - case AUTH: - if v, ok := u._u.(*Auth); ok { - return v - } else { - var zero Auth - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.Auth accessed when Type == %v", u.Type) - return nil + case IPv4, IPv6: + return true } + return false } -func (u *StellarMessage) DontHave() *DontHave { - switch u.Type { - case DONT_HAVE: - if v, ok := u._u.(*DontHave); ok { - return v - } else { - var zero DontHave - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.DontHave accessed when Type == %v", u.Type) - return nil - } +func (u *XdrAnon_PeerAddress_Ip) XdrUnionTag() XdrNum32 { + return XDR_IPAddrType(&u.Type) } -func (u *StellarMessage) Peers() *[]PeerAddress { +func (u *XdrAnon_PeerAddress_Ip) XdrUnionTagName() string { + return "Type" +} +func (u *XdrAnon_PeerAddress_Ip) XdrUnionBody() XdrType { switch u.Type { - case PEERS: - if v, ok := u._u.(*[]PeerAddress); ok { - return v - } else { - var zero []PeerAddress - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.Peers accessed when Type == %v", u.Type) - return nil + case IPv4: + return (*_XdrArray_4_opaque)(u.Ipv4()) + case IPv6: + return (*_XdrArray_16_opaque)(u.Ipv6()) } + return nil } -func (u *StellarMessage) TxSetHash() *Uint256 { +func (u *XdrAnon_PeerAddress_Ip) XdrUnionBodyName() string { switch u.Type { - case GET_TX_SET: - if v, ok := u._u.(*Uint256); ok { - return v - } else { - var zero Uint256 - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.TxSetHash accessed when Type == %v", u.Type) - return nil + case IPv4: + return "Ipv4" + case IPv6: + return "Ipv6" } + return "" } -func (u *StellarMessage) TxSet() *TransactionSet { + +type XdrType_XdrAnon_PeerAddress_Ip = *XdrAnon_PeerAddress_Ip + +func (v *XdrAnon_PeerAddress_Ip) XdrPointer() interface{} { return v } +func (XdrAnon_PeerAddress_Ip) XdrTypeName() string { return "XdrAnon_PeerAddress_Ip" } +func (v XdrAnon_PeerAddress_Ip) XdrValue() interface{} { return v } +func (v *XdrAnon_PeerAddress_Ip) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_PeerAddress_Ip) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_IPAddrType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case TX_SET: - if v, ok := u._u.(*TransactionSet); ok { - return v - } else { - var zero TransactionSet - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.TxSet accessed when Type == %v", u.Type) - return nil + case IPv4: + x.Marshal(x.Sprintf("%sipv4", name), (*_XdrArray_4_opaque)(u.Ipv4())) + return + case IPv6: + x.Marshal(x.Sprintf("%sipv6", name), (*_XdrArray_16_opaque)(u.Ipv6())) + return } + XdrPanic("invalid Type (%v) in XdrAnon_PeerAddress_Ip", u.Type) } -func (u *StellarMessage) GeneralizedTxSet() *GeneralizedTransactionSet { - switch u.Type { - case GENERALIZED_TX_SET: - if v, ok := u._u.(*GeneralizedTransactionSet); ok { - return v - } else { - var zero GeneralizedTransactionSet - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.GeneralizedTxSet accessed when Type == %v", u.Type) - return nil +func XDR_XdrAnon_PeerAddress_Ip(v *XdrAnon_PeerAddress_Ip) *XdrAnon_PeerAddress_Ip { return v } + +type XdrType_PeerAddress = *PeerAddress + +func (v *PeerAddress) XdrPointer() interface{} { return v } +func (PeerAddress) XdrTypeName() string { return "PeerAddress" } +func (v PeerAddress) XdrValue() interface{} { return v } +func (v *PeerAddress) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *PeerAddress) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%sip", name), XDR_XdrAnon_PeerAddress_Ip(&v.Ip)) + x.Marshal(x.Sprintf("%sport", name), XDR_Uint32(&v.Port)) + x.Marshal(x.Sprintf("%snumFailures", name), XDR_Uint32(&v.NumFailures)) } -func (u *StellarMessage) Transaction() *TransactionEnvelope { - switch u.Type { - case TRANSACTION: - if v, ok := u._u.(*TransactionEnvelope); ok { - return v - } else { - var zero TransactionEnvelope - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.Transaction accessed when Type == %v", u.Type) - return nil - } +func XDR_PeerAddress(v *PeerAddress) *PeerAddress { return v } + +var _XdrNames_MessageType = map[int32]string{ + int32(ERROR_MSG): "ERROR_MSG", + int32(AUTH): "AUTH", + int32(DONT_HAVE): "DONT_HAVE", + int32(GET_PEERS): "GET_PEERS", + int32(PEERS): "PEERS", + int32(GET_TX_SET): "GET_TX_SET", + int32(TX_SET): "TX_SET", + int32(GENERALIZED_TX_SET): "GENERALIZED_TX_SET", + int32(TRANSACTION): "TRANSACTION", + int32(GET_SCP_QUORUMSET): "GET_SCP_QUORUMSET", + int32(SCP_QUORUMSET): "SCP_QUORUMSET", + int32(SCP_MESSAGE): "SCP_MESSAGE", + int32(GET_SCP_STATE): "GET_SCP_STATE", + int32(HELLO): "HELLO", + int32(SURVEY_REQUEST): "SURVEY_REQUEST", + int32(SURVEY_RESPONSE): "SURVEY_RESPONSE", + int32(SEND_MORE): "SEND_MORE", + int32(SEND_MORE_EXTENDED): "SEND_MORE_EXTENDED", + int32(FLOOD_ADVERT): "FLOOD_ADVERT", + int32(FLOOD_DEMAND): "FLOOD_DEMAND", + int32(TIME_SLICED_SURVEY_REQUEST): "TIME_SLICED_SURVEY_REQUEST", + int32(TIME_SLICED_SURVEY_RESPONSE): "TIME_SLICED_SURVEY_RESPONSE", + int32(TIME_SLICED_SURVEY_START_COLLECTING): "TIME_SLICED_SURVEY_START_COLLECTING", + int32(TIME_SLICED_SURVEY_STOP_COLLECTING): "TIME_SLICED_SURVEY_STOP_COLLECTING", } -func (u *StellarMessage) SignedSurveyRequestMessage() *SignedSurveyRequestMessage { - switch u.Type { - case SURVEY_REQUEST: - if v, ok := u._u.(*SignedSurveyRequestMessage); ok { - return v - } else { - var zero SignedSurveyRequestMessage - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.SignedSurveyRequestMessage accessed when Type == %v", u.Type) - return nil - } +var _XdrValues_MessageType = map[string]int32{ + "ERROR_MSG": int32(ERROR_MSG), + "AUTH": int32(AUTH), + "DONT_HAVE": int32(DONT_HAVE), + "GET_PEERS": int32(GET_PEERS), + "PEERS": int32(PEERS), + "GET_TX_SET": int32(GET_TX_SET), + "TX_SET": int32(TX_SET), + "GENERALIZED_TX_SET": int32(GENERALIZED_TX_SET), + "TRANSACTION": int32(TRANSACTION), + "GET_SCP_QUORUMSET": int32(GET_SCP_QUORUMSET), + "SCP_QUORUMSET": int32(SCP_QUORUMSET), + "SCP_MESSAGE": int32(SCP_MESSAGE), + "GET_SCP_STATE": int32(GET_SCP_STATE), + "HELLO": int32(HELLO), + "SURVEY_REQUEST": int32(SURVEY_REQUEST), + "SURVEY_RESPONSE": int32(SURVEY_RESPONSE), + "SEND_MORE": int32(SEND_MORE), + "SEND_MORE_EXTENDED": int32(SEND_MORE_EXTENDED), + "FLOOD_ADVERT": int32(FLOOD_ADVERT), + "FLOOD_DEMAND": int32(FLOOD_DEMAND), + "TIME_SLICED_SURVEY_REQUEST": int32(TIME_SLICED_SURVEY_REQUEST), + "TIME_SLICED_SURVEY_RESPONSE": int32(TIME_SLICED_SURVEY_RESPONSE), + "TIME_SLICED_SURVEY_START_COLLECTING": int32(TIME_SLICED_SURVEY_START_COLLECTING), + "TIME_SLICED_SURVEY_STOP_COLLECTING": int32(TIME_SLICED_SURVEY_STOP_COLLECTING), } -func (u *StellarMessage) SignedSurveyResponseMessage() *SignedSurveyResponseMessage { - switch u.Type { - case SURVEY_RESPONSE: - if v, ok := u._u.(*SignedSurveyResponseMessage); ok { - return v - } else { - var zero SignedSurveyResponseMessage - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.SignedSurveyResponseMessage accessed when Type == %v", u.Type) - return nil + +func (MessageType) XdrEnumNames() map[int32]string { + return _XdrNames_MessageType +} +func (v MessageType) String() string { + if s, ok := _XdrNames_MessageType[int32(v)]; ok { + return s } + return fmt.Sprintf("MessageType#%d", v) } -func (u *StellarMessage) SignedTimeSlicedSurveyRequestMessage() *SignedTimeSlicedSurveyRequestMessage { - switch u.Type { - case TIME_SLICED_SURVEY_REQUEST: - if v, ok := u._u.(*SignedTimeSlicedSurveyRequestMessage); ok { - return v - } else { - var zero SignedTimeSlicedSurveyRequestMessage - u._u = &zero - return &zero +func (v *MessageType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_MessageType[stok]; ok { + *v = MessageType(val) + return nil + } else if stok == "MessageType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - default: - XdrPanic("StellarMessage.SignedTimeSlicedSurveyRequestMessage accessed when Type == %v", u.Type) - return nil + return XdrError(fmt.Sprintf("%s is not a valid MessageType.", stok)) } } -func (u *StellarMessage) SignedTimeSlicedSurveyResponseMessage() *SignedTimeSlicedSurveyResponseMessage { - switch u.Type { - case TIME_SLICED_SURVEY_RESPONSE: - if v, ok := u._u.(*SignedTimeSlicedSurveyResponseMessage); ok { - return v - } else { - var zero SignedTimeSlicedSurveyResponseMessage - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.SignedTimeSlicedSurveyResponseMessage accessed when Type == %v", u.Type) - return nil +func (v MessageType) GetU32() uint32 { return uint32(v) } +func (v *MessageType) SetU32(n uint32) { *v = MessageType(n) } +func (v *MessageType) XdrPointer() interface{} { return v } +func (MessageType) XdrTypeName() string { return "MessageType" } +func (v MessageType) XdrValue() interface{} { return v } +func (v *MessageType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_MessageType = *MessageType + +func XDR_MessageType(v *MessageType) *MessageType { return v } + +var _XdrComments_MessageType = map[int32]string{ + int32(GET_PEERS): "gets a list of peers this guy knows about", + int32(GET_TX_SET): "gets a particular txset by hash", + int32(TRANSACTION): "pass on a tx you have heard about", + int32(GET_SCP_QUORUMSET): "SCP", + int32(HELLO): "new messages", +} + +func (e MessageType) XdrEnumComments() map[int32]string { + return _XdrComments_MessageType +} + +type XdrType_DontHave = *DontHave + +func (v *DontHave) XdrPointer() interface{} { return v } +func (DontHave) XdrTypeName() string { return "DontHave" } +func (v DontHave) XdrValue() interface{} { return v } +func (v *DontHave) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *DontHave) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%stype", name), XDR_MessageType(&v.Type)) + x.Marshal(x.Sprintf("%sreqHash", name), XDR_Uint256(&v.ReqHash)) } -func (u *StellarMessage) SignedTimeSlicedSurveyStartCollectingMessage() *SignedTimeSlicedSurveyStartCollectingMessage { - switch u.Type { - case TIME_SLICED_SURVEY_START_COLLECTING: - if v, ok := u._u.(*SignedTimeSlicedSurveyStartCollectingMessage); ok { - return v - } else { - var zero SignedTimeSlicedSurveyStartCollectingMessage - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.SignedTimeSlicedSurveyStartCollectingMessage accessed when Type == %v", u.Type) - return nil +func XDR_DontHave(v *DontHave) *DontHave { return v } + +var _XdrNames_SurveyMessageCommandType = map[int32]string{ + int32(SURVEY_TOPOLOGY): "SURVEY_TOPOLOGY", + int32(TIME_SLICED_SURVEY_TOPOLOGY): "TIME_SLICED_SURVEY_TOPOLOGY", +} +var _XdrValues_SurveyMessageCommandType = map[string]int32{ + "SURVEY_TOPOLOGY": int32(SURVEY_TOPOLOGY), + "TIME_SLICED_SURVEY_TOPOLOGY": int32(TIME_SLICED_SURVEY_TOPOLOGY), +} + +func (SurveyMessageCommandType) XdrEnumNames() map[int32]string { + return _XdrNames_SurveyMessageCommandType +} +func (v SurveyMessageCommandType) String() string { + if s, ok := _XdrNames_SurveyMessageCommandType[int32(v)]; ok { + return s } + return fmt.Sprintf("SurveyMessageCommandType#%d", v) } -func (u *StellarMessage) SignedTimeSlicedSurveyStopCollectingMessage() *SignedTimeSlicedSurveyStopCollectingMessage { - switch u.Type { - case TIME_SLICED_SURVEY_STOP_COLLECTING: - if v, ok := u._u.(*SignedTimeSlicedSurveyStopCollectingMessage); ok { - return v - } else { - var zero SignedTimeSlicedSurveyStopCollectingMessage - u._u = &zero - return &zero +func (v *SurveyMessageCommandType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_SurveyMessageCommandType[stok]; ok { + *v = SurveyMessageCommandType(val) + return nil + } else if stok == "SurveyMessageCommandType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - default: - XdrPanic("StellarMessage.SignedTimeSlicedSurveyStopCollectingMessage accessed when Type == %v", u.Type) - return nil + return XdrError(fmt.Sprintf("%s is not a valid SurveyMessageCommandType.", stok)) } } -func (u *StellarMessage) QSetHash() *Uint256 { - switch u.Type { - case GET_SCP_QUORUMSET: - if v, ok := u._u.(*Uint256); ok { - return v - } else { - var zero Uint256 - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.QSetHash accessed when Type == %v", u.Type) - return nil - } +func (v SurveyMessageCommandType) GetU32() uint32 { return uint32(v) } +func (v *SurveyMessageCommandType) SetU32(n uint32) { *v = SurveyMessageCommandType(n) } +func (v *SurveyMessageCommandType) XdrPointer() interface{} { return v } +func (SurveyMessageCommandType) XdrTypeName() string { return "SurveyMessageCommandType" } +func (v SurveyMessageCommandType) XdrValue() interface{} { return v } +func (v *SurveyMessageCommandType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_SurveyMessageCommandType = *SurveyMessageCommandType + +func XDR_SurveyMessageCommandType(v *SurveyMessageCommandType) *SurveyMessageCommandType { return v } + +var _XdrNames_SurveyMessageResponseType = map[int32]string{ + int32(SURVEY_TOPOLOGY_RESPONSE_V0): "SURVEY_TOPOLOGY_RESPONSE_V0", + int32(SURVEY_TOPOLOGY_RESPONSE_V1): "SURVEY_TOPOLOGY_RESPONSE_V1", + int32(SURVEY_TOPOLOGY_RESPONSE_V2): "SURVEY_TOPOLOGY_RESPONSE_V2", } -func (u *StellarMessage) QSet() *SCPQuorumSet { - switch u.Type { - case SCP_QUORUMSET: - if v, ok := u._u.(*SCPQuorumSet); ok { - return v - } else { - var zero SCPQuorumSet - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.QSet accessed when Type == %v", u.Type) - return nil +var _XdrValues_SurveyMessageResponseType = map[string]int32{ + "SURVEY_TOPOLOGY_RESPONSE_V0": int32(SURVEY_TOPOLOGY_RESPONSE_V0), + "SURVEY_TOPOLOGY_RESPONSE_V1": int32(SURVEY_TOPOLOGY_RESPONSE_V1), + "SURVEY_TOPOLOGY_RESPONSE_V2": int32(SURVEY_TOPOLOGY_RESPONSE_V2), +} + +func (SurveyMessageResponseType) XdrEnumNames() map[int32]string { + return _XdrNames_SurveyMessageResponseType +} +func (v SurveyMessageResponseType) String() string { + if s, ok := _XdrNames_SurveyMessageResponseType[int32(v)]; ok { + return s } + return fmt.Sprintf("SurveyMessageResponseType#%d", v) } -func (u *StellarMessage) Envelope() *SCPEnvelope { - switch u.Type { - case SCP_MESSAGE: - if v, ok := u._u.(*SCPEnvelope); ok { - return v - } else { - var zero SCPEnvelope - u._u = &zero - return &zero +func (v *SurveyMessageResponseType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_SurveyMessageResponseType[stok]; ok { + *v = SurveyMessageResponseType(val) + return nil + } else if stok == "SurveyMessageResponseType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - default: - XdrPanic("StellarMessage.Envelope accessed when Type == %v", u.Type) - return nil + return XdrError(fmt.Sprintf("%s is not a valid SurveyMessageResponseType.", stok)) } } +func (v SurveyMessageResponseType) GetU32() uint32 { return uint32(v) } +func (v *SurveyMessageResponseType) SetU32(n uint32) { *v = SurveyMessageResponseType(n) } +func (v *SurveyMessageResponseType) XdrPointer() interface{} { return v } +func (SurveyMessageResponseType) XdrTypeName() string { return "SurveyMessageResponseType" } +func (v SurveyMessageResponseType) XdrValue() interface{} { return v } +func (v *SurveyMessageResponseType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -// ledger seq requested ; if 0, requests the latest -func (u *StellarMessage) GetSCPLedgerSeq() *Uint32 { - switch u.Type { - case GET_SCP_STATE: - if v, ok := u._u.(*Uint32); ok { - return v - } else { - var zero Uint32 - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.GetSCPLedgerSeq accessed when Type == %v", u.Type) - return nil - } +type XdrType_SurveyMessageResponseType = *SurveyMessageResponseType + +func XDR_SurveyMessageResponseType(v *SurveyMessageResponseType) *SurveyMessageResponseType { return v } + +type XdrType_TimeSlicedSurveyStartCollectingMessage = *TimeSlicedSurveyStartCollectingMessage + +func (v *TimeSlicedSurveyStartCollectingMessage) XdrPointer() interface{} { return v } +func (TimeSlicedSurveyStartCollectingMessage) XdrTypeName() string { + return "TimeSlicedSurveyStartCollectingMessage" } -func (u *StellarMessage) SendMoreMessage() *SendMore { - switch u.Type { - case SEND_MORE: - if v, ok := u._u.(*SendMore); ok { - return v - } else { - var zero SendMore - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.SendMoreMessage accessed when Type == %v", u.Type) - return nil +func (v TimeSlicedSurveyStartCollectingMessage) XdrValue() interface{} { return v } +func (v *TimeSlicedSurveyStartCollectingMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TimeSlicedSurveyStartCollectingMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%ssurveyorID", name), XDR_NodeID(&v.SurveyorID)) + x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) + x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) } -func (u *StellarMessage) SendMoreExtendedMessage() *SendMoreExtended { - switch u.Type { - case SEND_MORE_EXTENDED: - if v, ok := u._u.(*SendMoreExtended); ok { - return v - } else { - var zero SendMoreExtended - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.SendMoreExtendedMessage accessed when Type == %v", u.Type) - return nil - } +func XDR_TimeSlicedSurveyStartCollectingMessage(v *TimeSlicedSurveyStartCollectingMessage) *TimeSlicedSurveyStartCollectingMessage { + return v } -func (u *StellarMessage) FloodAdvert() *FloodAdvert { - switch u.Type { - case FLOOD_ADVERT: - if v, ok := u._u.(*FloodAdvert); ok { - return v - } else { - var zero FloodAdvert - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.FloodAdvert accessed when Type == %v", u.Type) - return nil + +type XdrType_SignedTimeSlicedSurveyStartCollectingMessage = *SignedTimeSlicedSurveyStartCollectingMessage + +func (v *SignedTimeSlicedSurveyStartCollectingMessage) XdrPointer() interface{} { return v } +func (SignedTimeSlicedSurveyStartCollectingMessage) XdrTypeName() string { + return "SignedTimeSlicedSurveyStartCollectingMessage" +} +func (v SignedTimeSlicedSurveyStartCollectingMessage) XdrValue() interface{} { return v } +func (v *SignedTimeSlicedSurveyStartCollectingMessage) XdrMarshal(x XDR, name string) { + x.Marshal(name, v) +} +func (v *SignedTimeSlicedSurveyStartCollectingMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) + x.Marshal(x.Sprintf("%sstartCollecting", name), XDR_TimeSlicedSurveyStartCollectingMessage(&v.StartCollecting)) } -func (u *StellarMessage) FloodDemand() *FloodDemand { - switch u.Type { - case FLOOD_DEMAND: - if v, ok := u._u.(*FloodDemand); ok { - return v - } else { - var zero FloodDemand - u._u = &zero - return &zero - } - default: - XdrPanic("StellarMessage.FloodDemand accessed when Type == %v", u.Type) - return nil +func XDR_SignedTimeSlicedSurveyStartCollectingMessage(v *SignedTimeSlicedSurveyStartCollectingMessage) *SignedTimeSlicedSurveyStartCollectingMessage { + return v +} + +type XdrType_TimeSlicedSurveyStopCollectingMessage = *TimeSlicedSurveyStopCollectingMessage + +func (v *TimeSlicedSurveyStopCollectingMessage) XdrPointer() interface{} { return v } +func (TimeSlicedSurveyStopCollectingMessage) XdrTypeName() string { + return "TimeSlicedSurveyStopCollectingMessage" +} +func (v TimeSlicedSurveyStopCollectingMessage) XdrValue() interface{} { return v } +func (v *TimeSlicedSurveyStopCollectingMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TimeSlicedSurveyStopCollectingMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%ssurveyorID", name), XDR_NodeID(&v.SurveyorID)) + x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) + x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) } -func (u StellarMessage) XdrValid() bool { - switch u.Type { - case ERROR_MSG, HELLO, AUTH, DONT_HAVE, GET_PEERS, PEERS, GET_TX_SET, TX_SET, GENERALIZED_TX_SET, TRANSACTION, SURVEY_REQUEST, SURVEY_RESPONSE, TIME_SLICED_SURVEY_REQUEST, TIME_SLICED_SURVEY_RESPONSE, TIME_SLICED_SURVEY_START_COLLECTING, TIME_SLICED_SURVEY_STOP_COLLECTING, GET_SCP_QUORUMSET, SCP_QUORUMSET, SCP_MESSAGE, GET_SCP_STATE, SEND_MORE, SEND_MORE_EXTENDED, FLOOD_ADVERT, FLOOD_DEMAND: - return true +func XDR_TimeSlicedSurveyStopCollectingMessage(v *TimeSlicedSurveyStopCollectingMessage) *TimeSlicedSurveyStopCollectingMessage { + return v +} + +type XdrType_SignedTimeSlicedSurveyStopCollectingMessage = *SignedTimeSlicedSurveyStopCollectingMessage + +func (v *SignedTimeSlicedSurveyStopCollectingMessage) XdrPointer() interface{} { return v } +func (SignedTimeSlicedSurveyStopCollectingMessage) XdrTypeName() string { + return "SignedTimeSlicedSurveyStopCollectingMessage" +} +func (v SignedTimeSlicedSurveyStopCollectingMessage) XdrValue() interface{} { return v } +func (v *SignedTimeSlicedSurveyStopCollectingMessage) XdrMarshal(x XDR, name string) { + x.Marshal(name, v) +} +func (v *SignedTimeSlicedSurveyStopCollectingMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - return false + x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) + x.Marshal(x.Sprintf("%sstopCollecting", name), XDR_TimeSlicedSurveyStopCollectingMessage(&v.StopCollecting)) } -func (u *StellarMessage) XdrUnionTag() XdrNum32 { - return XDR_MessageType(&u.Type) +func XDR_SignedTimeSlicedSurveyStopCollectingMessage(v *SignedTimeSlicedSurveyStopCollectingMessage) *SignedTimeSlicedSurveyStopCollectingMessage { + return v } -func (u *StellarMessage) XdrUnionTagName() string { - return "Type" + +type XdrType_SurveyRequestMessage = *SurveyRequestMessage + +func (v *SurveyRequestMessage) XdrPointer() interface{} { return v } +func (SurveyRequestMessage) XdrTypeName() string { return "SurveyRequestMessage" } +func (v SurveyRequestMessage) XdrValue() interface{} { return v } +func (v *SurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SurveyRequestMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%ssurveyorPeerID", name), XDR_NodeID(&v.SurveyorPeerID)) + x.Marshal(x.Sprintf("%ssurveyedPeerID", name), XDR_NodeID(&v.SurveyedPeerID)) + x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) + x.Marshal(x.Sprintf("%sencryptionKey", name), XDR_Curve25519Public(&v.EncryptionKey)) + x.Marshal(x.Sprintf("%scommandType", name), XDR_SurveyMessageCommandType(&v.CommandType)) } -func (u *StellarMessage) XdrUnionBody() XdrType { - switch u.Type { - case ERROR_MSG: - return XDR_Error(u.Error()) - case HELLO: - return XDR_Hello(u.Hello()) - case AUTH: - return XDR_Auth(u.Auth()) - case DONT_HAVE: - return XDR_DontHave(u.DontHave()) - case GET_PEERS: - return nil - case PEERS: - return (*_XdrVec_100_PeerAddress)(u.Peers()) - case GET_TX_SET: - return XDR_Uint256(u.TxSetHash()) - case TX_SET: - return XDR_TransactionSet(u.TxSet()) - case GENERALIZED_TX_SET: - return XDR_GeneralizedTransactionSet(u.GeneralizedTxSet()) - case TRANSACTION: - return XDR_TransactionEnvelope(u.Transaction()) - case SURVEY_REQUEST: - return XDR_SignedSurveyRequestMessage(u.SignedSurveyRequestMessage()) - case SURVEY_RESPONSE: - return XDR_SignedSurveyResponseMessage(u.SignedSurveyResponseMessage()) - case TIME_SLICED_SURVEY_REQUEST: - return XDR_SignedTimeSlicedSurveyRequestMessage(u.SignedTimeSlicedSurveyRequestMessage()) - case TIME_SLICED_SURVEY_RESPONSE: - return XDR_SignedTimeSlicedSurveyResponseMessage(u.SignedTimeSlicedSurveyResponseMessage()) - case TIME_SLICED_SURVEY_START_COLLECTING: - return XDR_SignedTimeSlicedSurveyStartCollectingMessage(u.SignedTimeSlicedSurveyStartCollectingMessage()) - case TIME_SLICED_SURVEY_STOP_COLLECTING: - return XDR_SignedTimeSlicedSurveyStopCollectingMessage(u.SignedTimeSlicedSurveyStopCollectingMessage()) - case GET_SCP_QUORUMSET: - return XDR_Uint256(u.QSetHash()) - case SCP_QUORUMSET: - return XDR_SCPQuorumSet(u.QSet()) - case SCP_MESSAGE: - return XDR_SCPEnvelope(u.Envelope()) - case GET_SCP_STATE: - return XDR_Uint32(u.GetSCPLedgerSeq()) - case SEND_MORE: - return XDR_SendMore(u.SendMoreMessage()) - case SEND_MORE_EXTENDED: - return XDR_SendMoreExtended(u.SendMoreExtendedMessage()) - case FLOOD_ADVERT: - return XDR_FloodAdvert(u.FloodAdvert()) - case FLOOD_DEMAND: - return XDR_FloodDemand(u.FloodDemand()) +func XDR_SurveyRequestMessage(v *SurveyRequestMessage) *SurveyRequestMessage { return v } + +type XdrType_TimeSlicedSurveyRequestMessage = *TimeSlicedSurveyRequestMessage + +func (v *TimeSlicedSurveyRequestMessage) XdrPointer() interface{} { return v } +func (TimeSlicedSurveyRequestMessage) XdrTypeName() string { return "TimeSlicedSurveyRequestMessage" } +func (v TimeSlicedSurveyRequestMessage) XdrValue() interface{} { return v } +func (v *TimeSlicedSurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TimeSlicedSurveyRequestMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - return nil + x.Marshal(x.Sprintf("%srequest", name), XDR_SurveyRequestMessage(&v.Request)) + x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) + x.Marshal(x.Sprintf("%sinboundPeersIndex", name), XDR_Uint32(&v.InboundPeersIndex)) + x.Marshal(x.Sprintf("%soutboundPeersIndex", name), XDR_Uint32(&v.OutboundPeersIndex)) } -func (u *StellarMessage) XdrUnionBodyName() string { - switch u.Type { - case ERROR_MSG: - return "Error" - case HELLO: - return "Hello" - case AUTH: - return "Auth" - case DONT_HAVE: - return "DontHave" - case GET_PEERS: - return "" - case PEERS: - return "Peers" - case GET_TX_SET: - return "TxSetHash" - case TX_SET: - return "TxSet" - case GENERALIZED_TX_SET: - return "GeneralizedTxSet" - case TRANSACTION: - return "Transaction" - case SURVEY_REQUEST: - return "SignedSurveyRequestMessage" - case SURVEY_RESPONSE: - return "SignedSurveyResponseMessage" - case TIME_SLICED_SURVEY_REQUEST: - return "SignedTimeSlicedSurveyRequestMessage" - case TIME_SLICED_SURVEY_RESPONSE: - return "SignedTimeSlicedSurveyResponseMessage" - case TIME_SLICED_SURVEY_START_COLLECTING: - return "SignedTimeSlicedSurveyStartCollectingMessage" - case TIME_SLICED_SURVEY_STOP_COLLECTING: - return "SignedTimeSlicedSurveyStopCollectingMessage" - case GET_SCP_QUORUMSET: - return "QSetHash" - case SCP_QUORUMSET: - return "QSet" - case SCP_MESSAGE: - return "Envelope" - case GET_SCP_STATE: - return "GetSCPLedgerSeq" - case SEND_MORE: - return "SendMoreMessage" - case SEND_MORE_EXTENDED: - return "SendMoreExtendedMessage" - case FLOOD_ADVERT: - return "FloodAdvert" - case FLOOD_DEMAND: - return "FloodDemand" - } - return "" +func XDR_TimeSlicedSurveyRequestMessage(v *TimeSlicedSurveyRequestMessage) *TimeSlicedSurveyRequestMessage { + return v } -type XdrType_StellarMessage = *StellarMessage +type XdrType_SignedSurveyRequestMessage = *SignedSurveyRequestMessage -func (v *StellarMessage) XdrPointer() interface{} { return v } -func (StellarMessage) XdrTypeName() string { return "StellarMessage" } -func (v StellarMessage) XdrValue() interface{} { return v } -func (v *StellarMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *StellarMessage) XdrRecurse(x XDR, name string) { +func (v *SignedSurveyRequestMessage) XdrPointer() interface{} { return v } +func (SignedSurveyRequestMessage) XdrTypeName() string { return "SignedSurveyRequestMessage" } +func (v SignedSurveyRequestMessage) XdrValue() interface{} { return v } +func (v *SignedSurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SignedSurveyRequestMessage) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_MessageType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case ERROR_MSG: - x.Marshal(x.Sprintf("%serror", name), XDR_Error(u.Error())) - return - case HELLO: - x.Marshal(x.Sprintf("%shello", name), XDR_Hello(u.Hello())) - return - case AUTH: - x.Marshal(x.Sprintf("%sauth", name), XDR_Auth(u.Auth())) - return - case DONT_HAVE: - x.Marshal(x.Sprintf("%sdontHave", name), XDR_DontHave(u.DontHave())) - return - case GET_PEERS: - return - case PEERS: - x.Marshal(x.Sprintf("%speers", name), (*_XdrVec_100_PeerAddress)(u.Peers())) - return - case GET_TX_SET: - x.Marshal(x.Sprintf("%stxSetHash", name), XDR_Uint256(u.TxSetHash())) - return - case TX_SET: - x.Marshal(x.Sprintf("%stxSet", name), XDR_TransactionSet(u.TxSet())) - return - case GENERALIZED_TX_SET: - x.Marshal(x.Sprintf("%sgeneralizedTxSet", name), XDR_GeneralizedTransactionSet(u.GeneralizedTxSet())) - return - case TRANSACTION: - x.Marshal(x.Sprintf("%stransaction", name), XDR_TransactionEnvelope(u.Transaction())) - return - case SURVEY_REQUEST: - x.Marshal(x.Sprintf("%ssignedSurveyRequestMessage", name), XDR_SignedSurveyRequestMessage(u.SignedSurveyRequestMessage())) - return - case SURVEY_RESPONSE: - x.Marshal(x.Sprintf("%ssignedSurveyResponseMessage", name), XDR_SignedSurveyResponseMessage(u.SignedSurveyResponseMessage())) - return - case TIME_SLICED_SURVEY_REQUEST: - x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyRequestMessage", name), XDR_SignedTimeSlicedSurveyRequestMessage(u.SignedTimeSlicedSurveyRequestMessage())) - return - case TIME_SLICED_SURVEY_RESPONSE: - x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyResponseMessage", name), XDR_SignedTimeSlicedSurveyResponseMessage(u.SignedTimeSlicedSurveyResponseMessage())) - return - case TIME_SLICED_SURVEY_START_COLLECTING: - x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyStartCollectingMessage", name), XDR_SignedTimeSlicedSurveyStartCollectingMessage(u.SignedTimeSlicedSurveyStartCollectingMessage())) - return - case TIME_SLICED_SURVEY_STOP_COLLECTING: - x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyStopCollectingMessage", name), XDR_SignedTimeSlicedSurveyStopCollectingMessage(u.SignedTimeSlicedSurveyStopCollectingMessage())) - return - case GET_SCP_QUORUMSET: - x.Marshal(x.Sprintf("%sqSetHash", name), XDR_Uint256(u.QSetHash())) - return - case SCP_QUORUMSET: - x.Marshal(x.Sprintf("%sqSet", name), XDR_SCPQuorumSet(u.QSet())) - return - case SCP_MESSAGE: - x.Marshal(x.Sprintf("%senvelope", name), XDR_SCPEnvelope(u.Envelope())) - return - case GET_SCP_STATE: - x.Marshal(x.Sprintf("%sgetSCPLedgerSeq", name), XDR_Uint32(u.GetSCPLedgerSeq())) - return - case SEND_MORE: - x.Marshal(x.Sprintf("%ssendMoreMessage", name), XDR_SendMore(u.SendMoreMessage())) - return - case SEND_MORE_EXTENDED: - x.Marshal(x.Sprintf("%ssendMoreExtendedMessage", name), XDR_SendMoreExtended(u.SendMoreExtendedMessage())) - return - case FLOOD_ADVERT: - x.Marshal(x.Sprintf("%sfloodAdvert", name), XDR_FloodAdvert(u.FloodAdvert())) - return - case FLOOD_DEMAND: - x.Marshal(x.Sprintf("%sfloodDemand", name), XDR_FloodDemand(u.FloodDemand())) - return - } - XdrPanic("invalid Type (%v) in StellarMessage", u.Type) + x.Marshal(x.Sprintf("%srequestSignature", name), XDR_Signature(&v.RequestSignature)) + x.Marshal(x.Sprintf("%srequest", name), XDR_SurveyRequestMessage(&v.Request)) +} +func XDR_SignedSurveyRequestMessage(v *SignedSurveyRequestMessage) *SignedSurveyRequestMessage { + return v } -func XDR_StellarMessage(v *StellarMessage) *StellarMessage { return v } -type XdrType_XdrAnon_AuthenticatedMessage_V0 = *XdrAnon_AuthenticatedMessage_V0 +type XdrType_SignedTimeSlicedSurveyRequestMessage = *SignedTimeSlicedSurveyRequestMessage -func (v *XdrAnon_AuthenticatedMessage_V0) XdrPointer() interface{} { return v } -func (XdrAnon_AuthenticatedMessage_V0) XdrTypeName() string { return "XdrAnon_AuthenticatedMessage_V0" } -func (v XdrAnon_AuthenticatedMessage_V0) XdrValue() interface{} { return v } -func (v *XdrAnon_AuthenticatedMessage_V0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_AuthenticatedMessage_V0) XdrRecurse(x XDR, name string) { +func (v *SignedTimeSlicedSurveyRequestMessage) XdrPointer() interface{} { return v } +func (SignedTimeSlicedSurveyRequestMessage) XdrTypeName() string { + return "SignedTimeSlicedSurveyRequestMessage" +} +func (v SignedTimeSlicedSurveyRequestMessage) XdrValue() interface{} { return v } +func (v *SignedTimeSlicedSurveyRequestMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SignedTimeSlicedSurveyRequestMessage) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%ssequence", name), XDR_Uint64(&v.Sequence)) - x.Marshal(x.Sprintf("%smessage", name), XDR_StellarMessage(&v.Message)) - x.Marshal(x.Sprintf("%smac", name), XDR_HmacSha256Mac(&v.Mac)) + x.Marshal(x.Sprintf("%srequestSignature", name), XDR_Signature(&v.RequestSignature)) + x.Marshal(x.Sprintf("%srequest", name), XDR_TimeSlicedSurveyRequestMessage(&v.Request)) } -func XDR_XdrAnon_AuthenticatedMessage_V0(v *XdrAnon_AuthenticatedMessage_V0) *XdrAnon_AuthenticatedMessage_V0 { +func XDR_SignedTimeSlicedSurveyRequestMessage(v *SignedTimeSlicedSurveyRequestMessage) *SignedTimeSlicedSurveyRequestMessage { return v } -var _XdrTags_AuthenticatedMessage = map[int32]bool{ - XdrToI32(0): true, +type XdrType_EncryptedBody struct { + XdrVecOpaque } -func (_ AuthenticatedMessage) XdrValidTags() map[int32]bool { - return _XdrTags_AuthenticatedMessage -} -func (u *AuthenticatedMessage) V0() *XdrAnon_AuthenticatedMessage_V0 { - switch u.V { - case 0: - if v, ok := u._u.(*XdrAnon_AuthenticatedMessage_V0); ok { - return v - } else { - var zero XdrAnon_AuthenticatedMessage_V0 - u._u = &zero - return &zero - } - default: - XdrPanic("AuthenticatedMessage.V0 accessed when V == %v", u.V) - return nil - } -} -func (u AuthenticatedMessage) XdrValid() bool { - switch u.V { - case 0: - return true - } - return false -} -func (u *AuthenticatedMessage) XdrUnionTag() XdrNum32 { - return XDR_Uint32(&u.V) -} -func (u *AuthenticatedMessage) XdrUnionTagName() string { - return "V" -} -func (u *AuthenticatedMessage) XdrUnionBody() XdrType { - switch u.V { - case 0: - return XDR_XdrAnon_AuthenticatedMessage_V0(u.V0()) - } - return nil -} -func (u *AuthenticatedMessage) XdrUnionBodyName() string { - switch u.V { - case 0: - return "V0" - } - return "" +func XDR_EncryptedBody(v *EncryptedBody) XdrType_EncryptedBody { + return XdrType_EncryptedBody{XdrVecOpaque{v, 64000}} } +func (XdrType_EncryptedBody) XdrTypeName() string { return "EncryptedBody" } +func (v XdrType_EncryptedBody) XdrUnwrap() XdrType { return v.XdrVecOpaque } -type XdrType_AuthenticatedMessage = *AuthenticatedMessage +type XdrType_SurveyResponseMessage = *SurveyResponseMessage -func (v *AuthenticatedMessage) XdrPointer() interface{} { return v } -func (AuthenticatedMessage) XdrTypeName() string { return "AuthenticatedMessage" } -func (v AuthenticatedMessage) XdrValue() interface{} { return v } -func (v *AuthenticatedMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *AuthenticatedMessage) XdrRecurse(x XDR, name string) { +func (v *SurveyResponseMessage) XdrPointer() interface{} { return v } +func (SurveyResponseMessage) XdrTypeName() string { return "SurveyResponseMessage" } +func (v SurveyResponseMessage) XdrValue() interface{} { return v } +func (v *SurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SurveyResponseMessage) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_Uint32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) - switch u.V { - case 0: - x.Marshal(x.Sprintf("%sv0", name), XDR_XdrAnon_AuthenticatedMessage_V0(u.V0())) - return - } - XdrPanic("invalid V (%v) in AuthenticatedMessage", u.V) + x.Marshal(x.Sprintf("%ssurveyorPeerID", name), XDR_NodeID(&v.SurveyorPeerID)) + x.Marshal(x.Sprintf("%ssurveyedPeerID", name), XDR_NodeID(&v.SurveyedPeerID)) + x.Marshal(x.Sprintf("%sledgerNum", name), XDR_Uint32(&v.LedgerNum)) + x.Marshal(x.Sprintf("%scommandType", name), XDR_SurveyMessageCommandType(&v.CommandType)) + x.Marshal(x.Sprintf("%sencryptedBody", name), XDR_EncryptedBody(&v.EncryptedBody)) } -func XDR_AuthenticatedMessage(v *AuthenticatedMessage) *AuthenticatedMessage { return v } +func XDR_SurveyResponseMessage(v *SurveyResponseMessage) *SurveyResponseMessage { return v } -var _XdrTags_LiquidityPoolParameters = map[int32]bool{ - XdrToI32(LIQUIDITY_POOL_CONSTANT_PRODUCT): true, -} +type XdrType_TimeSlicedSurveyResponseMessage = *TimeSlicedSurveyResponseMessage -func (_ LiquidityPoolParameters) XdrValidTags() map[int32]bool { - return _XdrTags_LiquidityPoolParameters -} -func (u *LiquidityPoolParameters) ConstantProduct() *LiquidityPoolConstantProductParameters { - switch u.Type { - case LIQUIDITY_POOL_CONSTANT_PRODUCT: - if v, ok := u._u.(*LiquidityPoolConstantProductParameters); ok { - return v - } else { - var zero LiquidityPoolConstantProductParameters - u._u = &zero - return &zero - } - default: - XdrPanic("LiquidityPoolParameters.ConstantProduct accessed when Type == %v", u.Type) - return nil - } -} -func (u LiquidityPoolParameters) XdrValid() bool { - switch u.Type { - case LIQUIDITY_POOL_CONSTANT_PRODUCT: - return true - } - return false -} -func (u *LiquidityPoolParameters) XdrUnionTag() XdrNum32 { - return XDR_LiquidityPoolType(&u.Type) -} -func (u *LiquidityPoolParameters) XdrUnionTagName() string { - return "Type" -} -func (u *LiquidityPoolParameters) XdrUnionBody() XdrType { - switch u.Type { - case LIQUIDITY_POOL_CONSTANT_PRODUCT: - return XDR_LiquidityPoolConstantProductParameters(u.ConstantProduct()) +func (v *TimeSlicedSurveyResponseMessage) XdrPointer() interface{} { return v } +func (TimeSlicedSurveyResponseMessage) XdrTypeName() string { return "TimeSlicedSurveyResponseMessage" } +func (v TimeSlicedSurveyResponseMessage) XdrValue() interface{} { return v } +func (v *TimeSlicedSurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TimeSlicedSurveyResponseMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - return nil + x.Marshal(x.Sprintf("%sresponse", name), XDR_SurveyResponseMessage(&v.Response)) + x.Marshal(x.Sprintf("%snonce", name), XDR_Uint32(&v.Nonce)) } -func (u *LiquidityPoolParameters) XdrUnionBodyName() string { - switch u.Type { - case LIQUIDITY_POOL_CONSTANT_PRODUCT: - return "ConstantProduct" - } - return "" +func XDR_TimeSlicedSurveyResponseMessage(v *TimeSlicedSurveyResponseMessage) *TimeSlicedSurveyResponseMessage { + return v } -type XdrType_LiquidityPoolParameters = *LiquidityPoolParameters +type XdrType_SignedSurveyResponseMessage = *SignedSurveyResponseMessage -func (v *LiquidityPoolParameters) XdrPointer() interface{} { return v } -func (LiquidityPoolParameters) XdrTypeName() string { return "LiquidityPoolParameters" } -func (v LiquidityPoolParameters) XdrValue() interface{} { return v } -func (v *LiquidityPoolParameters) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *LiquidityPoolParameters) XdrRecurse(x XDR, name string) { +func (v *SignedSurveyResponseMessage) XdrPointer() interface{} { return v } +func (SignedSurveyResponseMessage) XdrTypeName() string { return "SignedSurveyResponseMessage" } +func (v SignedSurveyResponseMessage) XdrValue() interface{} { return v } +func (v *SignedSurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SignedSurveyResponseMessage) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_LiquidityPoolType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case LIQUIDITY_POOL_CONSTANT_PRODUCT: - x.Marshal(x.Sprintf("%sconstantProduct", name), XDR_LiquidityPoolConstantProductParameters(u.ConstantProduct())) - return - } - XdrPanic("invalid Type (%v) in LiquidityPoolParameters", u.Type) + x.Marshal(x.Sprintf("%sresponseSignature", name), XDR_Signature(&v.ResponseSignature)) + x.Marshal(x.Sprintf("%sresponse", name), XDR_SurveyResponseMessage(&v.Response)) +} +func XDR_SignedSurveyResponseMessage(v *SignedSurveyResponseMessage) *SignedSurveyResponseMessage { + return v } -func XDR_LiquidityPoolParameters(v *LiquidityPoolParameters) *LiquidityPoolParameters { return v } -type XdrType_XdrAnon_MuxedAccount_Med25519 = *XdrAnon_MuxedAccount_Med25519 +type XdrType_SignedTimeSlicedSurveyResponseMessage = *SignedTimeSlicedSurveyResponseMessage -func (v *XdrAnon_MuxedAccount_Med25519) XdrPointer() interface{} { return v } -func (XdrAnon_MuxedAccount_Med25519) XdrTypeName() string { return "XdrAnon_MuxedAccount_Med25519" } -func (v XdrAnon_MuxedAccount_Med25519) XdrValue() interface{} { return v } -func (v *XdrAnon_MuxedAccount_Med25519) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_MuxedAccount_Med25519) XdrRecurse(x XDR, name string) { +func (v *SignedTimeSlicedSurveyResponseMessage) XdrPointer() interface{} { return v } +func (SignedTimeSlicedSurveyResponseMessage) XdrTypeName() string { + return "SignedTimeSlicedSurveyResponseMessage" +} +func (v SignedTimeSlicedSurveyResponseMessage) XdrValue() interface{} { return v } +func (v *SignedTimeSlicedSurveyResponseMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SignedTimeSlicedSurveyResponseMessage) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sid", name), XDR_Uint64(&v.Id)) - x.Marshal(x.Sprintf("%sed25519", name), XDR_Uint256(&v.Ed25519)) + x.Marshal(x.Sprintf("%sresponseSignature", name), XDR_Signature(&v.ResponseSignature)) + x.Marshal(x.Sprintf("%sresponse", name), XDR_TimeSlicedSurveyResponseMessage(&v.Response)) } -func XDR_XdrAnon_MuxedAccount_Med25519(v *XdrAnon_MuxedAccount_Med25519) *XdrAnon_MuxedAccount_Med25519 { +func XDR_SignedTimeSlicedSurveyResponseMessage(v *SignedTimeSlicedSurveyResponseMessage) *SignedTimeSlicedSurveyResponseMessage { return v } -var _XdrTags_MuxedAccount = map[int32]bool{ - XdrToI32(KEY_TYPE_ED25519): true, - XdrToI32(KEY_TYPE_MUXED_ED25519): true, +type XdrType_PeerStats = *PeerStats + +func (v *PeerStats) XdrPointer() interface{} { return v } +func (PeerStats) XdrTypeName() string { return "PeerStats" } +func (v PeerStats) XdrValue() interface{} { return v } +func (v *PeerStats) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *PeerStats) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sid", name), XDR_NodeID(&v.Id)) + x.Marshal(x.Sprintf("%sversionStr", name), XdrString{&v.VersionStr, 100}) + x.Marshal(x.Sprintf("%smessagesRead", name), XDR_Uint64(&v.MessagesRead)) + x.Marshal(x.Sprintf("%smessagesWritten", name), XDR_Uint64(&v.MessagesWritten)) + x.Marshal(x.Sprintf("%sbytesRead", name), XDR_Uint64(&v.BytesRead)) + x.Marshal(x.Sprintf("%sbytesWritten", name), XDR_Uint64(&v.BytesWritten)) + x.Marshal(x.Sprintf("%ssecondsConnected", name), XDR_Uint64(&v.SecondsConnected)) + x.Marshal(x.Sprintf("%suniqueFloodBytesRecv", name), XDR_Uint64(&v.UniqueFloodBytesRecv)) + x.Marshal(x.Sprintf("%sduplicateFloodBytesRecv", name), XDR_Uint64(&v.DuplicateFloodBytesRecv)) + x.Marshal(x.Sprintf("%suniqueFetchBytesRecv", name), XDR_Uint64(&v.UniqueFetchBytesRecv)) + x.Marshal(x.Sprintf("%sduplicateFetchBytesRecv", name), XDR_Uint64(&v.DuplicateFetchBytesRecv)) + x.Marshal(x.Sprintf("%suniqueFloodMessageRecv", name), XDR_Uint64(&v.UniqueFloodMessageRecv)) + x.Marshal(x.Sprintf("%sduplicateFloodMessageRecv", name), XDR_Uint64(&v.DuplicateFloodMessageRecv)) + x.Marshal(x.Sprintf("%suniqueFetchMessageRecv", name), XDR_Uint64(&v.UniqueFetchMessageRecv)) + x.Marshal(x.Sprintf("%sduplicateFetchMessageRecv", name), XDR_Uint64(&v.DuplicateFetchMessageRecv)) } +func XDR_PeerStats(v *PeerStats) *PeerStats { return v } -func (_ MuxedAccount) XdrValidTags() map[int32]bool { - return _XdrTags_MuxedAccount +type _XdrVec_25_PeerStats []PeerStats + +func (_XdrVec_25_PeerStats) XdrBound() uint32 { + const bound uint32 = 25 // Force error if not const or doesn't fit + return bound } -func (u *MuxedAccount) Ed25519() *Uint256 { - switch u.Type { - case KEY_TYPE_ED25519: - if v, ok := u._u.(*Uint256); ok { - return v - } else { - var zero Uint256 - u._u = &zero - return &zero - } - default: - XdrPanic("MuxedAccount.Ed25519 accessed when Type == %v", u.Type) - return nil +func (_XdrVec_25_PeerStats) XdrCheckLen(length uint32) { + if length > uint32(25) { + XdrPanic("_XdrVec_25_PeerStats length %d exceeds bound 25", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_25_PeerStats length %d exceeds max int", length) } } -func (u *MuxedAccount) Med25519() *XdrAnon_MuxedAccount_Med25519 { - switch u.Type { - case KEY_TYPE_MUXED_ED25519: - if v, ok := u._u.(*XdrAnon_MuxedAccount_Med25519); ok { - return v - } else { - var zero XdrAnon_MuxedAccount_Med25519 - u._u = &zero - return &zero +func (v _XdrVec_25_PeerStats) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_25_PeerStats) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] } - default: - XdrPanic("MuxedAccount.Med25519 accessed when Type == %v", u.Type) - return nil + return + } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(25); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) } + nv := make([]PeerStats, int(length), newcap) + copy(nv, *v) + *v = nv } -func (u MuxedAccount) XdrValid() bool { - switch u.Type { - case KEY_TYPE_ED25519, KEY_TYPE_MUXED_ED25519: - return true +func (v *_XdrVec_25_PeerStats) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_PeerStats(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] } - return false } -func (u *MuxedAccount) XdrUnionTag() XdrNum32 { - return XDR_CryptoKeyType(&u.Type) -} -func (u *MuxedAccount) XdrUnionTagName() string { - return "Type" -} -func (u *MuxedAccount) XdrUnionBody() XdrType { - switch u.Type { - case KEY_TYPE_ED25519: - return XDR_Uint256(u.Ed25519()) - case KEY_TYPE_MUXED_ED25519: - return XDR_XdrAnon_MuxedAccount_Med25519(u.Med25519()) - } - return nil -} -func (u *MuxedAccount) XdrUnionBodyName() string { - switch u.Type { - case KEY_TYPE_ED25519: - return "Ed25519" - case KEY_TYPE_MUXED_ED25519: - return "Med25519" - } - return "" -} - -type XdrType_MuxedAccount = *MuxedAccount - -func (v *MuxedAccount) XdrPointer() interface{} { return v } -func (MuxedAccount) XdrTypeName() string { return "MuxedAccount" } -func (v MuxedAccount) XdrValue() interface{} { return v } -func (v *MuxedAccount) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *MuxedAccount) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - XDR_CryptoKeyType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case KEY_TYPE_ED25519: - x.Marshal(x.Sprintf("%sed25519", name), XDR_Uint256(u.Ed25519())) - return - case KEY_TYPE_MUXED_ED25519: - x.Marshal(x.Sprintf("%smed25519", name), XDR_XdrAnon_MuxedAccount_Med25519(u.Med25519())) - return - } - XdrPanic("invalid Type (%v) in MuxedAccount", u.Type) -} -func XDR_MuxedAccount(v *MuxedAccount) *MuxedAccount { return v } - -type XdrType_DecoratedSignature = *DecoratedSignature - -func (v *DecoratedSignature) XdrPointer() interface{} { return v } -func (DecoratedSignature) XdrTypeName() string { return "DecoratedSignature" } -func (v DecoratedSignature) XdrValue() interface{} { return v } -func (v *DecoratedSignature) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *DecoratedSignature) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%shint", name), XDR_SignatureHint(&v.Hint)) - x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) +func (v *_XdrVec_25_PeerStats) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 25} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } -func XDR_DecoratedSignature(v *DecoratedSignature) *DecoratedSignature { return v } +func (_XdrVec_25_PeerStats) XdrTypeName() string { return "PeerStats<>" } +func (v *_XdrVec_25_PeerStats) XdrPointer() interface{} { return (*[]PeerStats)(v) } +func (v _XdrVec_25_PeerStats) XdrValue() interface{} { return ([]PeerStats)(v) } +func (v *_XdrVec_25_PeerStats) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -var _XdrNames_OperationType = map[int32]string{ - int32(CREATE_ACCOUNT): "CREATE_ACCOUNT", - int32(PAYMENT): "PAYMENT", - int32(PATH_PAYMENT_STRICT_RECEIVE): "PATH_PAYMENT_STRICT_RECEIVE", - int32(MANAGE_SELL_OFFER): "MANAGE_SELL_OFFER", - int32(CREATE_PASSIVE_SELL_OFFER): "CREATE_PASSIVE_SELL_OFFER", - int32(SET_OPTIONS): "SET_OPTIONS", - int32(CHANGE_TRUST): "CHANGE_TRUST", - int32(ALLOW_TRUST): "ALLOW_TRUST", - int32(ACCOUNT_MERGE): "ACCOUNT_MERGE", - int32(INFLATION): "INFLATION", - int32(MANAGE_DATA): "MANAGE_DATA", - int32(BUMP_SEQUENCE): "BUMP_SEQUENCE", - int32(MANAGE_BUY_OFFER): "MANAGE_BUY_OFFER", - int32(PATH_PAYMENT_STRICT_SEND): "PATH_PAYMENT_STRICT_SEND", - int32(CREATE_CLAIMABLE_BALANCE): "CREATE_CLAIMABLE_BALANCE", - int32(CLAIM_CLAIMABLE_BALANCE): "CLAIM_CLAIMABLE_BALANCE", - int32(BEGIN_SPONSORING_FUTURE_RESERVES): "BEGIN_SPONSORING_FUTURE_RESERVES", - int32(END_SPONSORING_FUTURE_RESERVES): "END_SPONSORING_FUTURE_RESERVES", - int32(REVOKE_SPONSORSHIP): "REVOKE_SPONSORSHIP", - int32(CLAWBACK): "CLAWBACK", - int32(CLAWBACK_CLAIMABLE_BALANCE): "CLAWBACK_CLAIMABLE_BALANCE", - int32(SET_TRUST_LINE_FLAGS): "SET_TRUST_LINE_FLAGS", - int32(LIQUIDITY_POOL_DEPOSIT): "LIQUIDITY_POOL_DEPOSIT", - int32(LIQUIDITY_POOL_WITHDRAW): "LIQUIDITY_POOL_WITHDRAW", - int32(INVOKE_HOST_FUNCTION): "INVOKE_HOST_FUNCTION", - int32(EXTEND_FOOTPRINT_TTL): "EXTEND_FOOTPRINT_TTL", - int32(RESTORE_FOOTPRINT): "RESTORE_FOOTPRINT", -} -var _XdrValues_OperationType = map[string]int32{ - "CREATE_ACCOUNT": int32(CREATE_ACCOUNT), - "PAYMENT": int32(PAYMENT), - "PATH_PAYMENT_STRICT_RECEIVE": int32(PATH_PAYMENT_STRICT_RECEIVE), - "MANAGE_SELL_OFFER": int32(MANAGE_SELL_OFFER), - "CREATE_PASSIVE_SELL_OFFER": int32(CREATE_PASSIVE_SELL_OFFER), - "SET_OPTIONS": int32(SET_OPTIONS), - "CHANGE_TRUST": int32(CHANGE_TRUST), - "ALLOW_TRUST": int32(ALLOW_TRUST), - "ACCOUNT_MERGE": int32(ACCOUNT_MERGE), - "INFLATION": int32(INFLATION), - "MANAGE_DATA": int32(MANAGE_DATA), - "BUMP_SEQUENCE": int32(BUMP_SEQUENCE), - "MANAGE_BUY_OFFER": int32(MANAGE_BUY_OFFER), - "PATH_PAYMENT_STRICT_SEND": int32(PATH_PAYMENT_STRICT_SEND), - "CREATE_CLAIMABLE_BALANCE": int32(CREATE_CLAIMABLE_BALANCE), - "CLAIM_CLAIMABLE_BALANCE": int32(CLAIM_CLAIMABLE_BALANCE), - "BEGIN_SPONSORING_FUTURE_RESERVES": int32(BEGIN_SPONSORING_FUTURE_RESERVES), - "END_SPONSORING_FUTURE_RESERVES": int32(END_SPONSORING_FUTURE_RESERVES), - "REVOKE_SPONSORSHIP": int32(REVOKE_SPONSORSHIP), - "CLAWBACK": int32(CLAWBACK), - "CLAWBACK_CLAIMABLE_BALANCE": int32(CLAWBACK_CLAIMABLE_BALANCE), - "SET_TRUST_LINE_FLAGS": int32(SET_TRUST_LINE_FLAGS), - "LIQUIDITY_POOL_DEPOSIT": int32(LIQUIDITY_POOL_DEPOSIT), - "LIQUIDITY_POOL_WITHDRAW": int32(LIQUIDITY_POOL_WITHDRAW), - "INVOKE_HOST_FUNCTION": int32(INVOKE_HOST_FUNCTION), - "EXTEND_FOOTPRINT_TTL": int32(EXTEND_FOOTPRINT_TTL), - "RESTORE_FOOTPRINT": int32(RESTORE_FOOTPRINT), +type XdrType_PeerStatList struct { + *_XdrVec_25_PeerStats } -func (OperationType) XdrEnumNames() map[int32]string { - return _XdrNames_OperationType -} -func (v OperationType) String() string { - if s, ok := _XdrNames_OperationType[int32(v)]; ok { - return s - } - return fmt.Sprintf("OperationType#%d", v) -} -func (v *OperationType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_OperationType[stok]; ok { - *v = OperationType(val) - return nil - } else if stok == "OperationType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid OperationType.", stok)) - } +func XDR_PeerStatList(v *PeerStatList) XdrType_PeerStatList { + return XdrType_PeerStatList{(*_XdrVec_25_PeerStats)(v)} } -func (v OperationType) GetU32() uint32 { return uint32(v) } -func (v *OperationType) SetU32(n uint32) { *v = OperationType(n) } -func (v *OperationType) XdrPointer() interface{} { return v } -func (OperationType) XdrTypeName() string { return "OperationType" } -func (v OperationType) XdrValue() interface{} { return v } -func (v *OperationType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_OperationType = *OperationType - -func XDR_OperationType(v *OperationType) *OperationType { return v } +func (XdrType_PeerStatList) XdrTypeName() string { return "PeerStatList" } +func (v XdrType_PeerStatList) XdrUnwrap() XdrType { return v._XdrVec_25_PeerStats } -type XdrType_CreateAccountOp = *CreateAccountOp +type XdrType_TimeSlicedNodeData = *TimeSlicedNodeData -func (v *CreateAccountOp) XdrPointer() interface{} { return v } -func (CreateAccountOp) XdrTypeName() string { return "CreateAccountOp" } -func (v CreateAccountOp) XdrValue() interface{} { return v } -func (v *CreateAccountOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *CreateAccountOp) XdrRecurse(x XDR, name string) { +func (v *TimeSlicedNodeData) XdrPointer() interface{} { return v } +func (TimeSlicedNodeData) XdrTypeName() string { return "TimeSlicedNodeData" } +func (v TimeSlicedNodeData) XdrValue() interface{} { return v } +func (v *TimeSlicedNodeData) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TimeSlicedNodeData) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sdestination", name), XDR_AccountID(&v.Destination)) - x.Marshal(x.Sprintf("%sstartingBalance", name), XDR_Int64(&v.StartingBalance)) + x.Marshal(x.Sprintf("%saddedAuthenticatedPeers", name), XDR_Uint32(&v.AddedAuthenticatedPeers)) + x.Marshal(x.Sprintf("%sdroppedAuthenticatedPeers", name), XDR_Uint32(&v.DroppedAuthenticatedPeers)) + x.Marshal(x.Sprintf("%stotalInboundPeerCount", name), XDR_Uint32(&v.TotalInboundPeerCount)) + x.Marshal(x.Sprintf("%stotalOutboundPeerCount", name), XDR_Uint32(&v.TotalOutboundPeerCount)) + x.Marshal(x.Sprintf("%sp75SCPFirstToSelfLatencyMs", name), XDR_Uint32(&v.P75SCPFirstToSelfLatencyMs)) + x.Marshal(x.Sprintf("%sp75SCPSelfToOtherLatencyMs", name), XDR_Uint32(&v.P75SCPSelfToOtherLatencyMs)) + x.Marshal(x.Sprintf("%slostSyncCount", name), XDR_Uint32(&v.LostSyncCount)) + x.Marshal(x.Sprintf("%sisValidator", name), XDR_bool(&v.IsValidator)) + x.Marshal(x.Sprintf("%smaxInboundPeerCount", name), XDR_Uint32(&v.MaxInboundPeerCount)) + x.Marshal(x.Sprintf("%smaxOutboundPeerCount", name), XDR_Uint32(&v.MaxOutboundPeerCount)) } -func XDR_CreateAccountOp(v *CreateAccountOp) *CreateAccountOp { return v } +func XDR_TimeSlicedNodeData(v *TimeSlicedNodeData) *TimeSlicedNodeData { return v } -type XdrType_PaymentOp = *PaymentOp +type XdrType_TimeSlicedPeerData = *TimeSlicedPeerData -func (v *PaymentOp) XdrPointer() interface{} { return v } -func (PaymentOp) XdrTypeName() string { return "PaymentOp" } -func (v PaymentOp) XdrValue() interface{} { return v } -func (v *PaymentOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *PaymentOp) XdrRecurse(x XDR, name string) { +func (v *TimeSlicedPeerData) XdrPointer() interface{} { return v } +func (TimeSlicedPeerData) XdrTypeName() string { return "TimeSlicedPeerData" } +func (v TimeSlicedPeerData) XdrValue() interface{} { return v } +func (v *TimeSlicedPeerData) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TimeSlicedPeerData) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(&v.Destination)) - x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) - x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) + x.Marshal(x.Sprintf("%speerStats", name), XDR_PeerStats(&v.PeerStats)) + x.Marshal(x.Sprintf("%saverageLatencyMs", name), XDR_Uint32(&v.AverageLatencyMs)) } -func XDR_PaymentOp(v *PaymentOp) *PaymentOp { return v } +func XDR_TimeSlicedPeerData(v *TimeSlicedPeerData) *TimeSlicedPeerData { return v } -type _XdrVec_5_Asset []Asset +type _XdrVec_25_TimeSlicedPeerData []TimeSlicedPeerData -func (_XdrVec_5_Asset) XdrBound() uint32 { - const bound uint32 = 5 // Force error if not const or doesn't fit +func (_XdrVec_25_TimeSlicedPeerData) XdrBound() uint32 { + const bound uint32 = 25 // Force error if not const or doesn't fit return bound } -func (_XdrVec_5_Asset) XdrCheckLen(length uint32) { - if length > uint32(5) { - XdrPanic("_XdrVec_5_Asset length %d exceeds bound 5", length) +func (_XdrVec_25_TimeSlicedPeerData) XdrCheckLen(length uint32) { + if length > uint32(25) { + XdrPanic("_XdrVec_25_TimeSlicedPeerData length %d exceeds bound 25", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_5_Asset length %d exceeds max int", length) + XdrPanic("_XdrVec_25_TimeSlicedPeerData length %d exceeds max int", length) } } -func (v _XdrVec_5_Asset) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_5_Asset) SetVecLen(length uint32) { +func (v _XdrVec_25_TimeSlicedPeerData) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_25_TimeSlicedPeerData) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -15433,1657 +14807,1387 @@ func (v *_XdrVec_5_Asset) SetVecLen(length uint32) { newcap := 2 * cap(*v) if newcap < int(length) { // also catches overflow where 2*cap < 0 newcap = int(length) - } else if bound := uint(5); uint(newcap) > bound { + } else if bound := uint(25); uint(newcap) > bound { if int(bound) < 0 { bound = ^uint(0) >> 1 } newcap = int(bound) } - nv := make([]Asset, int(length), newcap) + nv := make([]TimeSlicedPeerData, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_5_Asset) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_25_TimeSlicedPeerData) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_Asset(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_TimeSlicedPeerData(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_5_Asset) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 5} +func (v *_XdrVec_25_TimeSlicedPeerData) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 25} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_5_Asset) XdrTypeName() string { return "Asset<>" } -func (v *_XdrVec_5_Asset) XdrPointer() interface{} { return (*[]Asset)(v) } -func (v _XdrVec_5_Asset) XdrValue() interface{} { return ([]Asset)(v) } -func (v *_XdrVec_5_Asset) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (_XdrVec_25_TimeSlicedPeerData) XdrTypeName() string { return "TimeSlicedPeerData<>" } +func (v *_XdrVec_25_TimeSlicedPeerData) XdrPointer() interface{} { return (*[]TimeSlicedPeerData)(v) } +func (v _XdrVec_25_TimeSlicedPeerData) XdrValue() interface{} { return ([]TimeSlicedPeerData)(v) } +func (v *_XdrVec_25_TimeSlicedPeerData) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_PathPaymentStrictReceiveOp = *PathPaymentStrictReceiveOp +type XdrType_TimeSlicedPeerDataList struct { + *_XdrVec_25_TimeSlicedPeerData +} -func (v *PathPaymentStrictReceiveOp) XdrPointer() interface{} { return v } -func (PathPaymentStrictReceiveOp) XdrTypeName() string { return "PathPaymentStrictReceiveOp" } -func (v PathPaymentStrictReceiveOp) XdrValue() interface{} { return v } -func (v *PathPaymentStrictReceiveOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *PathPaymentStrictReceiveOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%ssendAsset", name), XDR_Asset(&v.SendAsset)) - x.Marshal(x.Sprintf("%ssendMax", name), XDR_Int64(&v.SendMax)) - x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(&v.Destination)) - x.Marshal(x.Sprintf("%sdestAsset", name), XDR_Asset(&v.DestAsset)) - x.Marshal(x.Sprintf("%sdestAmount", name), XDR_Int64(&v.DestAmount)) - x.Marshal(x.Sprintf("%spath", name), (*_XdrVec_5_Asset)(&v.Path)) -} -func XDR_PathPaymentStrictReceiveOp(v *PathPaymentStrictReceiveOp) *PathPaymentStrictReceiveOp { - return v -} - -type XdrType_PathPaymentStrictSendOp = *PathPaymentStrictSendOp - -func (v *PathPaymentStrictSendOp) XdrPointer() interface{} { return v } -func (PathPaymentStrictSendOp) XdrTypeName() string { return "PathPaymentStrictSendOp" } -func (v PathPaymentStrictSendOp) XdrValue() interface{} { return v } -func (v *PathPaymentStrictSendOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *PathPaymentStrictSendOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%ssendAsset", name), XDR_Asset(&v.SendAsset)) - x.Marshal(x.Sprintf("%ssendAmount", name), XDR_Int64(&v.SendAmount)) - x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(&v.Destination)) - x.Marshal(x.Sprintf("%sdestAsset", name), XDR_Asset(&v.DestAsset)) - x.Marshal(x.Sprintf("%sdestMin", name), XDR_Int64(&v.DestMin)) - x.Marshal(x.Sprintf("%spath", name), (*_XdrVec_5_Asset)(&v.Path)) +func XDR_TimeSlicedPeerDataList(v *TimeSlicedPeerDataList) XdrType_TimeSlicedPeerDataList { + return XdrType_TimeSlicedPeerDataList{(*_XdrVec_25_TimeSlicedPeerData)(v)} } -func XDR_PathPaymentStrictSendOp(v *PathPaymentStrictSendOp) *PathPaymentStrictSendOp { return v } +func (XdrType_TimeSlicedPeerDataList) XdrTypeName() string { return "TimeSlicedPeerDataList" } +func (v XdrType_TimeSlicedPeerDataList) XdrUnwrap() XdrType { return v._XdrVec_25_TimeSlicedPeerData } -type XdrType_ManageSellOfferOp = *ManageSellOfferOp +type XdrType_TopologyResponseBodyV0 = *TopologyResponseBodyV0 -func (v *ManageSellOfferOp) XdrPointer() interface{} { return v } -func (ManageSellOfferOp) XdrTypeName() string { return "ManageSellOfferOp" } -func (v ManageSellOfferOp) XdrValue() interface{} { return v } -func (v *ManageSellOfferOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ManageSellOfferOp) XdrRecurse(x XDR, name string) { +func (v *TopologyResponseBodyV0) XdrPointer() interface{} { return v } +func (TopologyResponseBodyV0) XdrTypeName() string { return "TopologyResponseBodyV0" } +func (v TopologyResponseBodyV0) XdrValue() interface{} { return v } +func (v *TopologyResponseBodyV0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TopologyResponseBodyV0) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sselling", name), XDR_Asset(&v.Selling)) - x.Marshal(x.Sprintf("%sbuying", name), XDR_Asset(&v.Buying)) - x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) - x.Marshal(x.Sprintf("%sprice", name), XDR_Price(&v.Price)) - x.Marshal(x.Sprintf("%sofferID", name), XDR_Int64(&v.OfferID)) + x.Marshal(x.Sprintf("%sinboundPeers", name), XDR_PeerStatList(&v.InboundPeers)) + x.Marshal(x.Sprintf("%soutboundPeers", name), XDR_PeerStatList(&v.OutboundPeers)) + x.Marshal(x.Sprintf("%stotalInboundPeerCount", name), XDR_Uint32(&v.TotalInboundPeerCount)) + x.Marshal(x.Sprintf("%stotalOutboundPeerCount", name), XDR_Uint32(&v.TotalOutboundPeerCount)) } -func XDR_ManageSellOfferOp(v *ManageSellOfferOp) *ManageSellOfferOp { return v } +func XDR_TopologyResponseBodyV0(v *TopologyResponseBodyV0) *TopologyResponseBodyV0 { return v } -type XdrType_ManageBuyOfferOp = *ManageBuyOfferOp +type XdrType_TopologyResponseBodyV1 = *TopologyResponseBodyV1 -func (v *ManageBuyOfferOp) XdrPointer() interface{} { return v } -func (ManageBuyOfferOp) XdrTypeName() string { return "ManageBuyOfferOp" } -func (v ManageBuyOfferOp) XdrValue() interface{} { return v } -func (v *ManageBuyOfferOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ManageBuyOfferOp) XdrRecurse(x XDR, name string) { +func (v *TopologyResponseBodyV1) XdrPointer() interface{} { return v } +func (TopologyResponseBodyV1) XdrTypeName() string { return "TopologyResponseBodyV1" } +func (v TopologyResponseBodyV1) XdrValue() interface{} { return v } +func (v *TopologyResponseBodyV1) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TopologyResponseBodyV1) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sselling", name), XDR_Asset(&v.Selling)) - x.Marshal(x.Sprintf("%sbuying", name), XDR_Asset(&v.Buying)) - x.Marshal(x.Sprintf("%sbuyAmount", name), XDR_Int64(&v.BuyAmount)) - x.Marshal(x.Sprintf("%sprice", name), XDR_Price(&v.Price)) - x.Marshal(x.Sprintf("%sofferID", name), XDR_Int64(&v.OfferID)) + x.Marshal(x.Sprintf("%sinboundPeers", name), XDR_PeerStatList(&v.InboundPeers)) + x.Marshal(x.Sprintf("%soutboundPeers", name), XDR_PeerStatList(&v.OutboundPeers)) + x.Marshal(x.Sprintf("%stotalInboundPeerCount", name), XDR_Uint32(&v.TotalInboundPeerCount)) + x.Marshal(x.Sprintf("%stotalOutboundPeerCount", name), XDR_Uint32(&v.TotalOutboundPeerCount)) + x.Marshal(x.Sprintf("%smaxInboundPeerCount", name), XDR_Uint32(&v.MaxInboundPeerCount)) + x.Marshal(x.Sprintf("%smaxOutboundPeerCount", name), XDR_Uint32(&v.MaxOutboundPeerCount)) } -func XDR_ManageBuyOfferOp(v *ManageBuyOfferOp) *ManageBuyOfferOp { return v } +func XDR_TopologyResponseBodyV1(v *TopologyResponseBodyV1) *TopologyResponseBodyV1 { return v } -type XdrType_CreatePassiveSellOfferOp = *CreatePassiveSellOfferOp +type XdrType_TopologyResponseBodyV2 = *TopologyResponseBodyV2 -func (v *CreatePassiveSellOfferOp) XdrPointer() interface{} { return v } -func (CreatePassiveSellOfferOp) XdrTypeName() string { return "CreatePassiveSellOfferOp" } -func (v CreatePassiveSellOfferOp) XdrValue() interface{} { return v } -func (v *CreatePassiveSellOfferOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *CreatePassiveSellOfferOp) XdrRecurse(x XDR, name string) { +func (v *TopologyResponseBodyV2) XdrPointer() interface{} { return v } +func (TopologyResponseBodyV2) XdrTypeName() string { return "TopologyResponseBodyV2" } +func (v TopologyResponseBodyV2) XdrValue() interface{} { return v } +func (v *TopologyResponseBodyV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TopologyResponseBodyV2) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sselling", name), XDR_Asset(&v.Selling)) - x.Marshal(x.Sprintf("%sbuying", name), XDR_Asset(&v.Buying)) - x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) - x.Marshal(x.Sprintf("%sprice", name), XDR_Price(&v.Price)) + x.Marshal(x.Sprintf("%sinboundPeers", name), XDR_TimeSlicedPeerDataList(&v.InboundPeers)) + x.Marshal(x.Sprintf("%soutboundPeers", name), XDR_TimeSlicedPeerDataList(&v.OutboundPeers)) + x.Marshal(x.Sprintf("%snodeData", name), XDR_TimeSlicedNodeData(&v.NodeData)) } -func XDR_CreatePassiveSellOfferOp(v *CreatePassiveSellOfferOp) *CreatePassiveSellOfferOp { return v } +func XDR_TopologyResponseBodyV2(v *TopologyResponseBodyV2) *TopologyResponseBodyV2 { return v } -type _XdrPtr_Uint32 struct { - p **Uint32 +var _XdrTags_SurveyResponseBody = map[int32]bool{ + XdrToI32(SURVEY_TOPOLOGY_RESPONSE_V0): true, + XdrToI32(SURVEY_TOPOLOGY_RESPONSE_V1): true, + XdrToI32(SURVEY_TOPOLOGY_RESPONSE_V2): true, } -type _ptrflag_Uint32 _XdrPtr_Uint32 -func (v _ptrflag_Uint32) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" +func (_ SurveyResponseBody) XdrValidTags() map[int32]bool { + return _XdrTags_SurveyResponseBody } -func (v _ptrflag_Uint32) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) +func (u *SurveyResponseBody) TopologyResponseBodyV0() *TopologyResponseBodyV0 { + switch u.Type { + case SURVEY_TOPOLOGY_RESPONSE_V0: + if v, ok := u._u.(*TopologyResponseBodyV0); ok { + return v + } else { + var zero TopologyResponseBodyV0 + u._u = &zero + return &zero + } default: - return XdrError("Uint32 flag should be \"nil\" or \"non-nil\"") - } - return nil -} -func (v _ptrflag_Uint32) GetU32() uint32 { - if *v.p == nil { - return 0 + XdrPanic("SurveyResponseBody.TopologyResponseBodyV0 accessed when Type == %v", u.Type) + return nil } - return 1 } -func (v _ptrflag_Uint32) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(Uint32) +func (u *SurveyResponseBody) TopologyResponseBodyV1() *TopologyResponseBodyV1 { + switch u.Type { + case SURVEY_TOPOLOGY_RESPONSE_V1: + if v, ok := u._u.(*TopologyResponseBodyV1); ok { + return v + } else { + var zero TopologyResponseBodyV1 + u._u = &zero + return &zero } default: - XdrPanic("*Uint32 present flag value %d should be 0 or 1", nv) + XdrPanic("SurveyResponseBody.TopologyResponseBodyV1 accessed when Type == %v", u.Type) + return nil } } -func (_ptrflag_Uint32) XdrTypeName() string { return "Uint32?" } -func (v _ptrflag_Uint32) XdrPointer() interface{} { return nil } -func (v _ptrflag_Uint32) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_Uint32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_Uint32) XdrBound() uint32 { return 1 } -func (v _XdrPtr_Uint32) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_Uint32) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(Uint32) +func (u *SurveyResponseBody) TopologyResponseBodyV2() *TopologyResponseBodyV2 { + switch u.Type { + case SURVEY_TOPOLOGY_RESPONSE_V2: + if v, ok := u._u.(*TopologyResponseBodyV2); ok { + return v + } else { + var zero TopologyResponseBodyV2 + u._u = &zero + return &zero + } + default: + XdrPanic("SurveyResponseBody.TopologyResponseBodyV2 accessed when Type == %v", u.Type) + return nil } } -func (v _XdrPtr_Uint32) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_Uint32(*v.p).XdrMarshal(x, name) +func (u SurveyResponseBody) XdrValid() bool { + switch u.Type { + case SURVEY_TOPOLOGY_RESPONSE_V0, SURVEY_TOPOLOGY_RESPONSE_V1, SURVEY_TOPOLOGY_RESPONSE_V2: + return true } + return false } -func (v _XdrPtr_Uint32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_Uint32) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_Uint32(v)) - v.XdrMarshalValue(x, name) +func (u *SurveyResponseBody) XdrUnionTag() XdrNum32 { + return XDR_SurveyMessageResponseType(&u.Type) } -func (_XdrPtr_Uint32) XdrTypeName() string { return "Uint32*" } -func (v _XdrPtr_Uint32) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_Uint32) XdrValue() interface{} { return *v.p } - -type _XdrPtr_String32 struct { - p **String32 +func (u *SurveyResponseBody) XdrUnionTagName() string { + return "Type" } -type _ptrflag_String32 _XdrPtr_String32 - -func (v _ptrflag_String32) String() string { - if *v.p == nil { - return "nil" +func (u *SurveyResponseBody) XdrUnionBody() XdrType { + switch u.Type { + case SURVEY_TOPOLOGY_RESPONSE_V0: + return XDR_TopologyResponseBodyV0(u.TopologyResponseBodyV0()) + case SURVEY_TOPOLOGY_RESPONSE_V1: + return XDR_TopologyResponseBodyV1(u.TopologyResponseBodyV1()) + case SURVEY_TOPOLOGY_RESPONSE_V2: + return XDR_TopologyResponseBodyV2(u.TopologyResponseBodyV2()) } - return "non-nil" + return nil } -func (v _ptrflag_String32) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("String32 flag should be \"nil\" or \"non-nil\"") +func (u *SurveyResponseBody) XdrUnionBodyName() string { + switch u.Type { + case SURVEY_TOPOLOGY_RESPONSE_V0: + return "TopologyResponseBodyV0" + case SURVEY_TOPOLOGY_RESPONSE_V1: + return "TopologyResponseBodyV1" + case SURVEY_TOPOLOGY_RESPONSE_V2: + return "TopologyResponseBodyV2" } - return nil + return "" } -func (v _ptrflag_String32) GetU32() uint32 { - if *v.p == nil { - return 0 - } - return 1 -} -func (v _ptrflag_String32) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(String32) - } - default: - XdrPanic("*String32 present flag value %d should be 0 or 1", nv) - } -} -func (_ptrflag_String32) XdrTypeName() string { return "String32?" } -func (v _ptrflag_String32) XdrPointer() interface{} { return nil } -func (v _ptrflag_String32) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_String32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_String32) XdrBound() uint32 { return 1 } -func (v _XdrPtr_String32) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_String32) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(String32) + +type XdrType_SurveyResponseBody = *SurveyResponseBody + +func (v *SurveyResponseBody) XdrPointer() interface{} { return v } +func (SurveyResponseBody) XdrTypeName() string { return "SurveyResponseBody" } +func (v SurveyResponseBody) XdrValue() interface{} { return v } +func (v *SurveyResponseBody) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *SurveyResponseBody) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } -} -func (v _XdrPtr_String32) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_String32(*v.p).XdrMarshal(x, name) + XDR_SurveyMessageResponseType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case SURVEY_TOPOLOGY_RESPONSE_V0: + x.Marshal(x.Sprintf("%stopologyResponseBodyV0", name), XDR_TopologyResponseBodyV0(u.TopologyResponseBodyV0())) + return + case SURVEY_TOPOLOGY_RESPONSE_V1: + x.Marshal(x.Sprintf("%stopologyResponseBodyV1", name), XDR_TopologyResponseBodyV1(u.TopologyResponseBodyV1())) + return + case SURVEY_TOPOLOGY_RESPONSE_V2: + x.Marshal(x.Sprintf("%stopologyResponseBodyV2", name), XDR_TopologyResponseBodyV2(u.TopologyResponseBodyV2())) + return } + XdrPanic("invalid Type (%v) in SurveyResponseBody", u.Type) } -func (v _XdrPtr_String32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_String32) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_String32(v)) - v.XdrMarshalValue(x, name) -} -func (_XdrPtr_String32) XdrTypeName() string { return "String32*" } -func (v _XdrPtr_String32) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_String32) XdrValue() interface{} { return *v.p } +func XDR_SurveyResponseBody(v *SurveyResponseBody) *SurveyResponseBody { return v } -type _XdrPtr_Signer struct { - p **Signer -} -type _ptrflag_Signer _XdrPtr_Signer +type _XdrVec_1000_Hash []Hash -func (v _ptrflag_Signer) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" +func (_XdrVec_1000_Hash) XdrBound() uint32 { + const bound uint32 = 1000 // Force error if not const or doesn't fit + return bound } -func (v _ptrflag_Signer) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("Signer flag should be \"nil\" or \"non-nil\"") +func (_XdrVec_1000_Hash) XdrCheckLen(length uint32) { + if length > uint32(1000) { + XdrPanic("_XdrVec_1000_Hash length %d exceeds bound 1000", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_1000_Hash length %d exceeds max int", length) } - return nil } -func (v _ptrflag_Signer) GetU32() uint32 { - if *v.p == nil { - return 0 +func (v _XdrVec_1000_Hash) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_1000_Hash) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return } - return 1 -} -func (v _ptrflag_Signer) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(Signer) + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(1000); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 } - default: - XdrPanic("*Signer present flag value %d should be 0 or 1", nv) + newcap = int(bound) } + nv := make([]Hash, int(length), newcap) + copy(nv, *v) + *v = nv } -func (_ptrflag_Signer) XdrTypeName() string { return "Signer?" } -func (v _ptrflag_Signer) XdrPointer() interface{} { return nil } -func (v _ptrflag_Signer) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_Signer) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_Signer) XdrBound() uint32 { return 1 } -func (v _XdrPtr_Signer) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_Signer) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(Signer) +func (v *_XdrVec_1000_Hash) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_Hash(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } -} -func (v _XdrPtr_Signer) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_Signer(*v.p).XdrMarshal(x, name) + if int(n) < len(*v) { + *v = (*v)[:int(n)] } } -func (v _XdrPtr_Signer) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_Signer) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_Signer(v)) - v.XdrMarshalValue(x, name) +func (v *_XdrVec_1000_Hash) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 1000} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } -func (_XdrPtr_Signer) XdrTypeName() string { return "Signer*" } -func (v _XdrPtr_Signer) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_Signer) XdrValue() interface{} { return *v.p } +func (_XdrVec_1000_Hash) XdrTypeName() string { return "Hash<>" } +func (v *_XdrVec_1000_Hash) XdrPointer() interface{} { return (*[]Hash)(v) } +func (v _XdrVec_1000_Hash) XdrValue() interface{} { return ([]Hash)(v) } +func (v *_XdrVec_1000_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_SetOptionsOp = *SetOptionsOp +type XdrType_TxAdvertVector struct { + *_XdrVec_1000_Hash +} -func (v *SetOptionsOp) XdrPointer() interface{} { return v } -func (SetOptionsOp) XdrTypeName() string { return "SetOptionsOp" } -func (v SetOptionsOp) XdrValue() interface{} { return v } -func (v *SetOptionsOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SetOptionsOp) XdrRecurse(x XDR, name string) { +func XDR_TxAdvertVector(v *TxAdvertVector) XdrType_TxAdvertVector { + return XdrType_TxAdvertVector{(*_XdrVec_1000_Hash)(v)} +} +func (XdrType_TxAdvertVector) XdrTypeName() string { return "TxAdvertVector" } +func (v XdrType_TxAdvertVector) XdrUnwrap() XdrType { return v._XdrVec_1000_Hash } + +type XdrType_FloodAdvert = *FloodAdvert + +func (v *FloodAdvert) XdrPointer() interface{} { return v } +func (FloodAdvert) XdrTypeName() string { return "FloodAdvert" } +func (v FloodAdvert) XdrValue() interface{} { return v } +func (v *FloodAdvert) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *FloodAdvert) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sinflationDest", name), _XdrPtr_AccountID{&v.InflationDest}) - x.Marshal(x.Sprintf("%sclearFlags", name), _XdrPtr_Uint32{&v.ClearFlags}) - x.Marshal(x.Sprintf("%ssetFlags", name), _XdrPtr_Uint32{&v.SetFlags}) - x.Marshal(x.Sprintf("%smasterWeight", name), _XdrPtr_Uint32{&v.MasterWeight}) - x.Marshal(x.Sprintf("%slowThreshold", name), _XdrPtr_Uint32{&v.LowThreshold}) - x.Marshal(x.Sprintf("%smedThreshold", name), _XdrPtr_Uint32{&v.MedThreshold}) - x.Marshal(x.Sprintf("%shighThreshold", name), _XdrPtr_Uint32{&v.HighThreshold}) - x.Marshal(x.Sprintf("%shomeDomain", name), _XdrPtr_String32{&v.HomeDomain}) - x.Marshal(x.Sprintf("%ssigner", name), _XdrPtr_Signer{&v.Signer}) + x.Marshal(x.Sprintf("%stxHashes", name), XDR_TxAdvertVector(&v.TxHashes)) } -func XDR_SetOptionsOp(v *SetOptionsOp) *SetOptionsOp { return v } +func XDR_FloodAdvert(v *FloodAdvert) *FloodAdvert { return v } -var _XdrTags_ChangeTrustAsset = map[int32]bool{ - XdrToI32(ASSET_TYPE_NATIVE): true, - XdrToI32(ASSET_TYPE_CREDIT_ALPHANUM4): true, - XdrToI32(ASSET_TYPE_CREDIT_ALPHANUM12): true, - XdrToI32(ASSET_TYPE_POOL_SHARE): true, +type XdrType_TxDemandVector struct { + *_XdrVec_1000_Hash } -func (_ ChangeTrustAsset) XdrValidTags() map[int32]bool { - return _XdrTags_ChangeTrustAsset -} -func (u *ChangeTrustAsset) AlphaNum4() *AlphaNum4 { - switch u.Type { - case ASSET_TYPE_CREDIT_ALPHANUM4: - if v, ok := u._u.(*AlphaNum4); ok { - return v - } else { - var zero AlphaNum4 - u._u = &zero - return &zero - } - default: - XdrPanic("ChangeTrustAsset.AlphaNum4 accessed when Type == %v", u.Type) - return nil - } +func XDR_TxDemandVector(v *TxDemandVector) XdrType_TxDemandVector { + return XdrType_TxDemandVector{(*_XdrVec_1000_Hash)(v)} } -func (u *ChangeTrustAsset) AlphaNum12() *AlphaNum12 { - switch u.Type { - case ASSET_TYPE_CREDIT_ALPHANUM12: - if v, ok := u._u.(*AlphaNum12); ok { - return v - } else { - var zero AlphaNum12 - u._u = &zero - return &zero - } - default: - XdrPanic("ChangeTrustAsset.AlphaNum12 accessed when Type == %v", u.Type) - return nil +func (XdrType_TxDemandVector) XdrTypeName() string { return "TxDemandVector" } +func (v XdrType_TxDemandVector) XdrUnwrap() XdrType { return v._XdrVec_1000_Hash } + +type XdrType_FloodDemand = *FloodDemand + +func (v *FloodDemand) XdrPointer() interface{} { return v } +func (FloodDemand) XdrTypeName() string { return "FloodDemand" } +func (v FloodDemand) XdrValue() interface{} { return v } +func (v *FloodDemand) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *FloodDemand) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%stxHashes", name), XDR_TxDemandVector(&v.TxHashes)) } -func (u *ChangeTrustAsset) LiquidityPool() *LiquidityPoolParameters { - switch u.Type { - case ASSET_TYPE_POOL_SHARE: - if v, ok := u._u.(*LiquidityPoolParameters); ok { +func XDR_FloodDemand(v *FloodDemand) *FloodDemand { return v } + +type _XdrVec_100_PeerAddress []PeerAddress + +func (_XdrVec_100_PeerAddress) XdrBound() uint32 { + const bound uint32 = 100 // Force error if not const or doesn't fit + return bound +} +func (_XdrVec_100_PeerAddress) XdrCheckLen(length uint32) { + if length > uint32(100) { + XdrPanic("_XdrVec_100_PeerAddress length %d exceeds bound 100", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_100_PeerAddress length %d exceeds max int", length) + } +} +func (v _XdrVec_100_PeerAddress) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_100_PeerAddress) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return + } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(100); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]PeerAddress, int(length), newcap) + copy(nv, *v) + *v = nv +} +func (v *_XdrVec_100_PeerAddress) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_PeerAddress(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] + } +} +func (v *_XdrVec_100_PeerAddress) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 100} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_100_PeerAddress) XdrTypeName() string { return "PeerAddress<>" } +func (v *_XdrVec_100_PeerAddress) XdrPointer() interface{} { return (*[]PeerAddress)(v) } +func (v _XdrVec_100_PeerAddress) XdrValue() interface{} { return ([]PeerAddress)(v) } +func (v *_XdrVec_100_PeerAddress) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +var _XdrTags_StellarMessage = map[int32]bool{ + XdrToI32(ERROR_MSG): true, + XdrToI32(HELLO): true, + XdrToI32(AUTH): true, + XdrToI32(DONT_HAVE): true, + XdrToI32(GET_PEERS): true, + XdrToI32(PEERS): true, + XdrToI32(GET_TX_SET): true, + XdrToI32(TX_SET): true, + XdrToI32(GENERALIZED_TX_SET): true, + XdrToI32(TRANSACTION): true, + XdrToI32(SURVEY_REQUEST): true, + XdrToI32(SURVEY_RESPONSE): true, + XdrToI32(TIME_SLICED_SURVEY_REQUEST): true, + XdrToI32(TIME_SLICED_SURVEY_RESPONSE): true, + XdrToI32(TIME_SLICED_SURVEY_START_COLLECTING): true, + XdrToI32(TIME_SLICED_SURVEY_STOP_COLLECTING): true, + XdrToI32(GET_SCP_QUORUMSET): true, + XdrToI32(SCP_QUORUMSET): true, + XdrToI32(SCP_MESSAGE): true, + XdrToI32(GET_SCP_STATE): true, + XdrToI32(SEND_MORE): true, + XdrToI32(SEND_MORE_EXTENDED): true, + XdrToI32(FLOOD_ADVERT): true, + XdrToI32(FLOOD_DEMAND): true, +} + +func (_ StellarMessage) XdrValidTags() map[int32]bool { + return _XdrTags_StellarMessage +} +func (u *StellarMessage) Error() *Error { + switch u.Type { + case ERROR_MSG: + if v, ok := u._u.(*Error); ok { return v } else { - var zero LiquidityPoolParameters + var zero Error u._u = &zero return &zero } default: - XdrPanic("ChangeTrustAsset.LiquidityPool accessed when Type == %v", u.Type) + XdrPanic("StellarMessage.Error accessed when Type == %v", u.Type) return nil } } -func (u ChangeTrustAsset) XdrValid() bool { +func (u *StellarMessage) Hello() *Hello { switch u.Type { - case ASSET_TYPE_NATIVE, ASSET_TYPE_CREDIT_ALPHANUM4, ASSET_TYPE_CREDIT_ALPHANUM12, ASSET_TYPE_POOL_SHARE: - return true + case HELLO: + if v, ok := u._u.(*Hello); ok { + return v + } else { + var zero Hello + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.Hello accessed when Type == %v", u.Type) + return nil } - return false -} -func (u *ChangeTrustAsset) XdrUnionTag() XdrNum32 { - return XDR_AssetType(&u.Type) -} -func (u *ChangeTrustAsset) XdrUnionTagName() string { - return "Type" } -func (u *ChangeTrustAsset) XdrUnionBody() XdrType { +func (u *StellarMessage) Auth() *Auth { switch u.Type { - case ASSET_TYPE_NATIVE: + case AUTH: + if v, ok := u._u.(*Auth); ok { + return v + } else { + var zero Auth + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.Auth accessed when Type == %v", u.Type) return nil - case ASSET_TYPE_CREDIT_ALPHANUM4: - return XDR_AlphaNum4(u.AlphaNum4()) - case ASSET_TYPE_CREDIT_ALPHANUM12: - return XDR_AlphaNum12(u.AlphaNum12()) - case ASSET_TYPE_POOL_SHARE: - return XDR_LiquidityPoolParameters(u.LiquidityPool()) } - return nil } -func (u *ChangeTrustAsset) XdrUnionBodyName() string { +func (u *StellarMessage) DontHave() *DontHave { switch u.Type { - case ASSET_TYPE_NATIVE: - return "" - case ASSET_TYPE_CREDIT_ALPHANUM4: - return "AlphaNum4" - case ASSET_TYPE_CREDIT_ALPHANUM12: - return "AlphaNum12" - case ASSET_TYPE_POOL_SHARE: - return "LiquidityPool" + case DONT_HAVE: + if v, ok := u._u.(*DontHave); ok { + return v + } else { + var zero DontHave + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.DontHave accessed when Type == %v", u.Type) + return nil } - return "" } - -type XdrType_ChangeTrustAsset = *ChangeTrustAsset - -func (v *ChangeTrustAsset) XdrPointer() interface{} { return v } -func (ChangeTrustAsset) XdrTypeName() string { return "ChangeTrustAsset" } -func (v ChangeTrustAsset) XdrValue() interface{} { return v } -func (v *ChangeTrustAsset) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *ChangeTrustAsset) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - XDR_AssetType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) +func (u *StellarMessage) Peers() *[]PeerAddress { switch u.Type { - case ASSET_TYPE_NATIVE: - return - case ASSET_TYPE_CREDIT_ALPHANUM4: - x.Marshal(x.Sprintf("%salphaNum4", name), XDR_AlphaNum4(u.AlphaNum4())) - return - case ASSET_TYPE_CREDIT_ALPHANUM12: - x.Marshal(x.Sprintf("%salphaNum12", name), XDR_AlphaNum12(u.AlphaNum12())) - return - case ASSET_TYPE_POOL_SHARE: - x.Marshal(x.Sprintf("%sliquidityPool", name), XDR_LiquidityPoolParameters(u.LiquidityPool())) - return + case PEERS: + if v, ok := u._u.(*[]PeerAddress); ok { + return v + } else { + var zero []PeerAddress + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.Peers accessed when Type == %v", u.Type) + return nil } - XdrPanic("invalid Type (%v) in ChangeTrustAsset", u.Type) } -func XDR_ChangeTrustAsset(v *ChangeTrustAsset) *ChangeTrustAsset { return v } - -type XdrType_ChangeTrustOp = *ChangeTrustOp - -func (v *ChangeTrustOp) XdrPointer() interface{} { return v } -func (ChangeTrustOp) XdrTypeName() string { return "ChangeTrustOp" } -func (v ChangeTrustOp) XdrValue() interface{} { return v } -func (v *ChangeTrustOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ChangeTrustOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *StellarMessage) TxSetHash() *Uint256 { + switch u.Type { + case GET_TX_SET: + if v, ok := u._u.(*Uint256); ok { + return v + } else { + var zero Uint256 + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.TxSetHash accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%sline", name), XDR_ChangeTrustAsset(&v.Line)) - x.Marshal(x.Sprintf("%slimit", name), XDR_Int64(&v.Limit)) } -func XDR_ChangeTrustOp(v *ChangeTrustOp) *ChangeTrustOp { return v } - -type XdrType_AllowTrustOp = *AllowTrustOp - -func (v *AllowTrustOp) XdrPointer() interface{} { return v } -func (AllowTrustOp) XdrTypeName() string { return "AllowTrustOp" } -func (v AllowTrustOp) XdrValue() interface{} { return v } -func (v *AllowTrustOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *AllowTrustOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *StellarMessage) TxSet() *TransactionSet { + switch u.Type { + case TX_SET: + if v, ok := u._u.(*TransactionSet); ok { + return v + } else { + var zero TransactionSet + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.TxSet accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%strustor", name), XDR_AccountID(&v.Trustor)) - x.Marshal(x.Sprintf("%sasset", name), XDR_AssetCode(&v.Asset)) - x.Marshal(x.Sprintf("%sauthorize", name), XDR_Uint32(&v.Authorize)) -} -func XDR_AllowTrustOp(v *AllowTrustOp) *AllowTrustOp { return v } - -type _XdrPtr_DataValue struct { - p **DataValue } -type _ptrflag_DataValue _XdrPtr_DataValue - -func (v _ptrflag_DataValue) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" -} -func (v _ptrflag_DataValue) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("DataValue flag should be \"nil\" or \"non-nil\"") - } - return nil -} -func (v _ptrflag_DataValue) GetU32() uint32 { - if *v.p == nil { - return 0 - } - return 1 -} -func (v _ptrflag_DataValue) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(DataValue) +func (u *StellarMessage) GeneralizedTxSet() *GeneralizedTransactionSet { + switch u.Type { + case GENERALIZED_TX_SET: + if v, ok := u._u.(*GeneralizedTransactionSet); ok { + return v + } else { + var zero GeneralizedTransactionSet + u._u = &zero + return &zero } default: - XdrPanic("*DataValue present flag value %d should be 0 or 1", nv) - } -} -func (_ptrflag_DataValue) XdrTypeName() string { return "DataValue?" } -func (v _ptrflag_DataValue) XdrPointer() interface{} { return nil } -func (v _ptrflag_DataValue) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_DataValue) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_DataValue) XdrBound() uint32 { return 1 } -func (v _XdrPtr_DataValue) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_DataValue) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(DataValue) - } -} -func (v _XdrPtr_DataValue) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_DataValue(*v.p).XdrMarshal(x, name) - } -} -func (v _XdrPtr_DataValue) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_DataValue) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_DataValue(v)) - v.XdrMarshalValue(x, name) -} -func (_XdrPtr_DataValue) XdrTypeName() string { return "DataValue*" } -func (v _XdrPtr_DataValue) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_DataValue) XdrValue() interface{} { return *v.p } - -type XdrType_ManageDataOp = *ManageDataOp - -func (v *ManageDataOp) XdrPointer() interface{} { return v } -func (ManageDataOp) XdrTypeName() string { return "ManageDataOp" } -func (v ManageDataOp) XdrValue() interface{} { return v } -func (v *ManageDataOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ManageDataOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sdataName", name), XDR_String64(&v.DataName)) - x.Marshal(x.Sprintf("%sdataValue", name), _XdrPtr_DataValue{&v.DataValue}) -} -func XDR_ManageDataOp(v *ManageDataOp) *ManageDataOp { return v } - -type XdrType_BumpSequenceOp = *BumpSequenceOp - -func (v *BumpSequenceOp) XdrPointer() interface{} { return v } -func (BumpSequenceOp) XdrTypeName() string { return "BumpSequenceOp" } -func (v BumpSequenceOp) XdrValue() interface{} { return v } -func (v *BumpSequenceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *BumpSequenceOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sbumpTo", name), XDR_SequenceNumber(&v.BumpTo)) -} -func XDR_BumpSequenceOp(v *BumpSequenceOp) *BumpSequenceOp { return v } - -type XdrType_CreateClaimableBalanceOp = *CreateClaimableBalanceOp - -func (v *CreateClaimableBalanceOp) XdrPointer() interface{} { return v } -func (CreateClaimableBalanceOp) XdrTypeName() string { return "CreateClaimableBalanceOp" } -func (v CreateClaimableBalanceOp) XdrValue() interface{} { return v } -func (v *CreateClaimableBalanceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *CreateClaimableBalanceOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) - x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) - x.Marshal(x.Sprintf("%sclaimants", name), (*_XdrVec_10_Claimant)(&v.Claimants)) -} -func XDR_CreateClaimableBalanceOp(v *CreateClaimableBalanceOp) *CreateClaimableBalanceOp { return v } - -type XdrType_ClaimClaimableBalanceOp = *ClaimClaimableBalanceOp - -func (v *ClaimClaimableBalanceOp) XdrPointer() interface{} { return v } -func (ClaimClaimableBalanceOp) XdrTypeName() string { return "ClaimClaimableBalanceOp" } -func (v ClaimClaimableBalanceOp) XdrValue() interface{} { return v } -func (v *ClaimClaimableBalanceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ClaimClaimableBalanceOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sbalanceID", name), XDR_ClaimableBalanceID(&v.BalanceID)) -} -func XDR_ClaimClaimableBalanceOp(v *ClaimClaimableBalanceOp) *ClaimClaimableBalanceOp { return v } - -type XdrType_BeginSponsoringFutureReservesOp = *BeginSponsoringFutureReservesOp - -func (v *BeginSponsoringFutureReservesOp) XdrPointer() interface{} { return v } -func (BeginSponsoringFutureReservesOp) XdrTypeName() string { return "BeginSponsoringFutureReservesOp" } -func (v BeginSponsoringFutureReservesOp) XdrValue() interface{} { return v } -func (v *BeginSponsoringFutureReservesOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *BeginSponsoringFutureReservesOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%ssponsoredID", name), XDR_AccountID(&v.SponsoredID)) -} -func XDR_BeginSponsoringFutureReservesOp(v *BeginSponsoringFutureReservesOp) *BeginSponsoringFutureReservesOp { - return v -} - -var _XdrNames_RevokeSponsorshipType = map[int32]string{ - int32(REVOKE_SPONSORSHIP_LEDGER_ENTRY): "REVOKE_SPONSORSHIP_LEDGER_ENTRY", - int32(REVOKE_SPONSORSHIP_SIGNER): "REVOKE_SPONSORSHIP_SIGNER", -} -var _XdrValues_RevokeSponsorshipType = map[string]int32{ - "REVOKE_SPONSORSHIP_LEDGER_ENTRY": int32(REVOKE_SPONSORSHIP_LEDGER_ENTRY), - "REVOKE_SPONSORSHIP_SIGNER": int32(REVOKE_SPONSORSHIP_SIGNER), -} - -func (RevokeSponsorshipType) XdrEnumNames() map[int32]string { - return _XdrNames_RevokeSponsorshipType -} -func (v RevokeSponsorshipType) String() string { - if s, ok := _XdrNames_RevokeSponsorshipType[int32(v)]; ok { - return s + XdrPanic("StellarMessage.GeneralizedTxSet accessed when Type == %v", u.Type) + return nil } - return fmt.Sprintf("RevokeSponsorshipType#%d", v) } -func (v *RevokeSponsorshipType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_RevokeSponsorshipType[stok]; ok { - *v = RevokeSponsorshipType(val) - return nil - } else if stok == "RevokeSponsorshipType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } +func (u *StellarMessage) Transaction() *TransactionEnvelope { + switch u.Type { + case TRANSACTION: + if v, ok := u._u.(*TransactionEnvelope); ok { + return v + } else { + var zero TransactionEnvelope + u._u = &zero + return &zero } - return XdrError(fmt.Sprintf("%s is not a valid RevokeSponsorshipType.", stok)) - } -} -func (v RevokeSponsorshipType) GetU32() uint32 { return uint32(v) } -func (v *RevokeSponsorshipType) SetU32(n uint32) { *v = RevokeSponsorshipType(n) } -func (v *RevokeSponsorshipType) XdrPointer() interface{} { return v } -func (RevokeSponsorshipType) XdrTypeName() string { return "RevokeSponsorshipType" } -func (v RevokeSponsorshipType) XdrValue() interface{} { return v } -func (v *RevokeSponsorshipType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_RevokeSponsorshipType = *RevokeSponsorshipType - -func XDR_RevokeSponsorshipType(v *RevokeSponsorshipType) *RevokeSponsorshipType { return v } - -type XdrType_XdrAnon_RevokeSponsorshipOp_Signer = *XdrAnon_RevokeSponsorshipOp_Signer - -func (v *XdrAnon_RevokeSponsorshipOp_Signer) XdrPointer() interface{} { return v } -func (XdrAnon_RevokeSponsorshipOp_Signer) XdrTypeName() string { - return "XdrAnon_RevokeSponsorshipOp_Signer" -} -func (v XdrAnon_RevokeSponsorshipOp_Signer) XdrValue() interface{} { return v } -func (v *XdrAnon_RevokeSponsorshipOp_Signer) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_RevokeSponsorshipOp_Signer) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) + default: + XdrPanic("StellarMessage.Transaction accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%saccountID", name), XDR_AccountID(&v.AccountID)) - x.Marshal(x.Sprintf("%ssignerKey", name), XDR_SignerKey(&v.SignerKey)) -} -func XDR_XdrAnon_RevokeSponsorshipOp_Signer(v *XdrAnon_RevokeSponsorshipOp_Signer) *XdrAnon_RevokeSponsorshipOp_Signer { - return v } - -var _XdrTags_RevokeSponsorshipOp = map[int32]bool{ - XdrToI32(REVOKE_SPONSORSHIP_LEDGER_ENTRY): true, - XdrToI32(REVOKE_SPONSORSHIP_SIGNER): true, -} - -func (_ RevokeSponsorshipOp) XdrValidTags() map[int32]bool { - return _XdrTags_RevokeSponsorshipOp -} -func (u *RevokeSponsorshipOp) LedgerKey() *LedgerKey { +func (u *StellarMessage) SignedSurveyRequestMessage() *SignedSurveyRequestMessage { switch u.Type { - case REVOKE_SPONSORSHIP_LEDGER_ENTRY: - if v, ok := u._u.(*LedgerKey); ok { + case SURVEY_REQUEST: + if v, ok := u._u.(*SignedSurveyRequestMessage); ok { return v } else { - var zero LedgerKey + var zero SignedSurveyRequestMessage u._u = &zero return &zero } default: - XdrPanic("RevokeSponsorshipOp.LedgerKey accessed when Type == %v", u.Type) + XdrPanic("StellarMessage.SignedSurveyRequestMessage accessed when Type == %v", u.Type) return nil } } -func (u *RevokeSponsorshipOp) Signer() *XdrAnon_RevokeSponsorshipOp_Signer { +func (u *StellarMessage) SignedSurveyResponseMessage() *SignedSurveyResponseMessage { switch u.Type { - case REVOKE_SPONSORSHIP_SIGNER: - if v, ok := u._u.(*XdrAnon_RevokeSponsorshipOp_Signer); ok { + case SURVEY_RESPONSE: + if v, ok := u._u.(*SignedSurveyResponseMessage); ok { return v } else { - var zero XdrAnon_RevokeSponsorshipOp_Signer + var zero SignedSurveyResponseMessage u._u = &zero return &zero } default: - XdrPanic("RevokeSponsorshipOp.Signer accessed when Type == %v", u.Type) + XdrPanic("StellarMessage.SignedSurveyResponseMessage accessed when Type == %v", u.Type) return nil } } -func (u RevokeSponsorshipOp) XdrValid() bool { +func (u *StellarMessage) SignedTimeSlicedSurveyRequestMessage() *SignedTimeSlicedSurveyRequestMessage { switch u.Type { - case REVOKE_SPONSORSHIP_LEDGER_ENTRY, REVOKE_SPONSORSHIP_SIGNER: - return true + case TIME_SLICED_SURVEY_REQUEST: + if v, ok := u._u.(*SignedTimeSlicedSurveyRequestMessage); ok { + return v + } else { + var zero SignedTimeSlicedSurveyRequestMessage + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.SignedTimeSlicedSurveyRequestMessage accessed when Type == %v", u.Type) + return nil } - return false -} -func (u *RevokeSponsorshipOp) XdrUnionTag() XdrNum32 { - return XDR_RevokeSponsorshipType(&u.Type) } -func (u *RevokeSponsorshipOp) XdrUnionTagName() string { - return "Type" +func (u *StellarMessage) SignedTimeSlicedSurveyResponseMessage() *SignedTimeSlicedSurveyResponseMessage { + switch u.Type { + case TIME_SLICED_SURVEY_RESPONSE: + if v, ok := u._u.(*SignedTimeSlicedSurveyResponseMessage); ok { + return v + } else { + var zero SignedTimeSlicedSurveyResponseMessage + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.SignedTimeSlicedSurveyResponseMessage accessed when Type == %v", u.Type) + return nil + } } -func (u *RevokeSponsorshipOp) XdrUnionBody() XdrType { +func (u *StellarMessage) SignedTimeSlicedSurveyStartCollectingMessage() *SignedTimeSlicedSurveyStartCollectingMessage { switch u.Type { - case REVOKE_SPONSORSHIP_LEDGER_ENTRY: - return XDR_LedgerKey(u.LedgerKey()) - case REVOKE_SPONSORSHIP_SIGNER: - return XDR_XdrAnon_RevokeSponsorshipOp_Signer(u.Signer()) + case TIME_SLICED_SURVEY_START_COLLECTING: + if v, ok := u._u.(*SignedTimeSlicedSurveyStartCollectingMessage); ok { + return v + } else { + var zero SignedTimeSlicedSurveyStartCollectingMessage + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.SignedTimeSlicedSurveyStartCollectingMessage accessed when Type == %v", u.Type) + return nil } - return nil } -func (u *RevokeSponsorshipOp) XdrUnionBodyName() string { +func (u *StellarMessage) SignedTimeSlicedSurveyStopCollectingMessage() *SignedTimeSlicedSurveyStopCollectingMessage { switch u.Type { - case REVOKE_SPONSORSHIP_LEDGER_ENTRY: - return "LedgerKey" - case REVOKE_SPONSORSHIP_SIGNER: - return "Signer" + case TIME_SLICED_SURVEY_STOP_COLLECTING: + if v, ok := u._u.(*SignedTimeSlicedSurveyStopCollectingMessage); ok { + return v + } else { + var zero SignedTimeSlicedSurveyStopCollectingMessage + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.SignedTimeSlicedSurveyStopCollectingMessage accessed when Type == %v", u.Type) + return nil } - return "" } - -type XdrType_RevokeSponsorshipOp = *RevokeSponsorshipOp - -func (v *RevokeSponsorshipOp) XdrPointer() interface{} { return v } -func (RevokeSponsorshipOp) XdrTypeName() string { return "RevokeSponsorshipOp" } -func (v RevokeSponsorshipOp) XdrValue() interface{} { return v } -func (v *RevokeSponsorshipOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *RevokeSponsorshipOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *StellarMessage) QSetHash() *Uint256 { + switch u.Type { + case GET_SCP_QUORUMSET: + if v, ok := u._u.(*Uint256); ok { + return v + } else { + var zero Uint256 + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.QSetHash accessed when Type == %v", u.Type) + return nil } - XDR_RevokeSponsorshipType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) +} +func (u *StellarMessage) QSet() *SCPQuorumSet { switch u.Type { - case REVOKE_SPONSORSHIP_LEDGER_ENTRY: - x.Marshal(x.Sprintf("%sledgerKey", name), XDR_LedgerKey(u.LedgerKey())) - return - case REVOKE_SPONSORSHIP_SIGNER: - x.Marshal(x.Sprintf("%ssigner", name), XDR_XdrAnon_RevokeSponsorshipOp_Signer(u.Signer())) - return + case SCP_QUORUMSET: + if v, ok := u._u.(*SCPQuorumSet); ok { + return v + } else { + var zero SCPQuorumSet + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.QSet accessed when Type == %v", u.Type) + return nil } - XdrPanic("invalid Type (%v) in RevokeSponsorshipOp", u.Type) } -func XDR_RevokeSponsorshipOp(v *RevokeSponsorshipOp) *RevokeSponsorshipOp { return v } - -type XdrType_ClawbackOp = *ClawbackOp - -func (v *ClawbackOp) XdrPointer() interface{} { return v } -func (ClawbackOp) XdrTypeName() string { return "ClawbackOp" } -func (v ClawbackOp) XdrValue() interface{} { return v } -func (v *ClawbackOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ClawbackOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *StellarMessage) Envelope() *SCPEnvelope { + switch u.Type { + case SCP_MESSAGE: + if v, ok := u._u.(*SCPEnvelope); ok { + return v + } else { + var zero SCPEnvelope + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.Envelope accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) - x.Marshal(x.Sprintf("%sfrom", name), XDR_MuxedAccount(&v.From)) - x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) } -func XDR_ClawbackOp(v *ClawbackOp) *ClawbackOp { return v } -type XdrType_ClawbackClaimableBalanceOp = *ClawbackClaimableBalanceOp - -func (v *ClawbackClaimableBalanceOp) XdrPointer() interface{} { return v } -func (ClawbackClaimableBalanceOp) XdrTypeName() string { return "ClawbackClaimableBalanceOp" } -func (v ClawbackClaimableBalanceOp) XdrValue() interface{} { return v } -func (v *ClawbackClaimableBalanceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ClawbackClaimableBalanceOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +// ledger seq requested ; if 0, requests the latest +func (u *StellarMessage) GetSCPLedgerSeq() *Uint32 { + switch u.Type { + case GET_SCP_STATE: + if v, ok := u._u.(*Uint32); ok { + return v + } else { + var zero Uint32 + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.GetSCPLedgerSeq accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%sbalanceID", name), XDR_ClaimableBalanceID(&v.BalanceID)) } -func XDR_ClawbackClaimableBalanceOp(v *ClawbackClaimableBalanceOp) *ClawbackClaimableBalanceOp { - return v -} - -type XdrType_SetTrustLineFlagsOp = *SetTrustLineFlagsOp - -func (v *SetTrustLineFlagsOp) XdrPointer() interface{} { return v } -func (SetTrustLineFlagsOp) XdrTypeName() string { return "SetTrustLineFlagsOp" } -func (v SetTrustLineFlagsOp) XdrValue() interface{} { return v } -func (v *SetTrustLineFlagsOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SetTrustLineFlagsOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *StellarMessage) SendMoreMessage() *SendMore { + switch u.Type { + case SEND_MORE: + if v, ok := u._u.(*SendMore); ok { + return v + } else { + var zero SendMore + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.SendMoreMessage accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%strustor", name), XDR_AccountID(&v.Trustor)) - x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) - x.Marshal(x.Sprintf("%sclearFlags", name), XDR_Uint32(&v.ClearFlags)) - x.Marshal(x.Sprintf("%ssetFlags", name), XDR_Uint32(&v.SetFlags)) } -func XDR_SetTrustLineFlagsOp(v *SetTrustLineFlagsOp) *SetTrustLineFlagsOp { return v } - -type XdrType_LiquidityPoolDepositOp = *LiquidityPoolDepositOp - -func (v *LiquidityPoolDepositOp) XdrPointer() interface{} { return v } -func (LiquidityPoolDepositOp) XdrTypeName() string { return "LiquidityPoolDepositOp" } -func (v LiquidityPoolDepositOp) XdrValue() interface{} { return v } -func (v *LiquidityPoolDepositOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LiquidityPoolDepositOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *StellarMessage) SendMoreExtendedMessage() *SendMoreExtended { + switch u.Type { + case SEND_MORE_EXTENDED: + if v, ok := u._u.(*SendMoreExtended); ok { + return v + } else { + var zero SendMoreExtended + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.SendMoreExtendedMessage accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%sliquidityPoolID", name), XDR_PoolID(&v.LiquidityPoolID)) - x.Marshal(x.Sprintf("%smaxAmountA", name), XDR_Int64(&v.MaxAmountA)) - x.Marshal(x.Sprintf("%smaxAmountB", name), XDR_Int64(&v.MaxAmountB)) - x.Marshal(x.Sprintf("%sminPrice", name), XDR_Price(&v.MinPrice)) - x.Marshal(x.Sprintf("%smaxPrice", name), XDR_Price(&v.MaxPrice)) } -func XDR_LiquidityPoolDepositOp(v *LiquidityPoolDepositOp) *LiquidityPoolDepositOp { return v } - -type XdrType_LiquidityPoolWithdrawOp = *LiquidityPoolWithdrawOp - -func (v *LiquidityPoolWithdrawOp) XdrPointer() interface{} { return v } -func (LiquidityPoolWithdrawOp) XdrTypeName() string { return "LiquidityPoolWithdrawOp" } -func (v LiquidityPoolWithdrawOp) XdrValue() interface{} { return v } -func (v *LiquidityPoolWithdrawOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LiquidityPoolWithdrawOp) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) +func (u *StellarMessage) FloodAdvert() *FloodAdvert { + switch u.Type { + case FLOOD_ADVERT: + if v, ok := u._u.(*FloodAdvert); ok { + return v + } else { + var zero FloodAdvert + u._u = &zero + return &zero + } + default: + XdrPanic("StellarMessage.FloodAdvert accessed when Type == %v", u.Type) + return nil } - x.Marshal(x.Sprintf("%sliquidityPoolID", name), XDR_PoolID(&v.LiquidityPoolID)) - x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) - x.Marshal(x.Sprintf("%sminAmountA", name), XDR_Int64(&v.MinAmountA)) - x.Marshal(x.Sprintf("%sminAmountB", name), XDR_Int64(&v.MinAmountB)) } -func XDR_LiquidityPoolWithdrawOp(v *LiquidityPoolWithdrawOp) *LiquidityPoolWithdrawOp { return v } - -var _XdrNames_HostFunctionType = map[int32]string{ - int32(HOST_FUNCTION_TYPE_INVOKE_CONTRACT): "HOST_FUNCTION_TYPE_INVOKE_CONTRACT", - int32(HOST_FUNCTION_TYPE_CREATE_CONTRACT): "HOST_FUNCTION_TYPE_CREATE_CONTRACT", - int32(HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM): "HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM", -} -var _XdrValues_HostFunctionType = map[string]int32{ - "HOST_FUNCTION_TYPE_INVOKE_CONTRACT": int32(HOST_FUNCTION_TYPE_INVOKE_CONTRACT), - "HOST_FUNCTION_TYPE_CREATE_CONTRACT": int32(HOST_FUNCTION_TYPE_CREATE_CONTRACT), - "HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM": int32(HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM), -} - -func (HostFunctionType) XdrEnumNames() map[int32]string { - return _XdrNames_HostFunctionType -} -func (v HostFunctionType) String() string { - if s, ok := _XdrNames_HostFunctionType[int32(v)]; ok { - return s - } - return fmt.Sprintf("HostFunctionType#%d", v) -} -func (v *HostFunctionType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_HostFunctionType[stok]; ok { - *v = HostFunctionType(val) - return nil - } else if stok == "HostFunctionType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid HostFunctionType.", stok)) - } -} -func (v HostFunctionType) GetU32() uint32 { return uint32(v) } -func (v *HostFunctionType) SetU32(n uint32) { *v = HostFunctionType(n) } -func (v *HostFunctionType) XdrPointer() interface{} { return v } -func (HostFunctionType) XdrTypeName() string { return "HostFunctionType" } -func (v HostFunctionType) XdrValue() interface{} { return v } -func (v *HostFunctionType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_HostFunctionType = *HostFunctionType - -func XDR_HostFunctionType(v *HostFunctionType) *HostFunctionType { return v } - -var _XdrNames_ContractIDPreimageType = map[int32]string{ - int32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS): "CONTRACT_ID_PREIMAGE_FROM_ADDRESS", - int32(CONTRACT_ID_PREIMAGE_FROM_ASSET): "CONTRACT_ID_PREIMAGE_FROM_ASSET", -} -var _XdrValues_ContractIDPreimageType = map[string]int32{ - "CONTRACT_ID_PREIMAGE_FROM_ADDRESS": int32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS), - "CONTRACT_ID_PREIMAGE_FROM_ASSET": int32(CONTRACT_ID_PREIMAGE_FROM_ASSET), -} - -func (ContractIDPreimageType) XdrEnumNames() map[int32]string { - return _XdrNames_ContractIDPreimageType -} -func (v ContractIDPreimageType) String() string { - if s, ok := _XdrNames_ContractIDPreimageType[int32(v)]; ok { - return s - } - return fmt.Sprintf("ContractIDPreimageType#%d", v) -} -func (v *ContractIDPreimageType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_ContractIDPreimageType[stok]; ok { - *v = ContractIDPreimageType(val) - return nil - } else if stok == "ContractIDPreimageType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid ContractIDPreimageType.", stok)) - } -} -func (v ContractIDPreimageType) GetU32() uint32 { return uint32(v) } -func (v *ContractIDPreimageType) SetU32(n uint32) { *v = ContractIDPreimageType(n) } -func (v *ContractIDPreimageType) XdrPointer() interface{} { return v } -func (ContractIDPreimageType) XdrTypeName() string { return "ContractIDPreimageType" } -func (v ContractIDPreimageType) XdrValue() interface{} { return v } -func (v *ContractIDPreimageType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_ContractIDPreimageType = *ContractIDPreimageType - -func XDR_ContractIDPreimageType(v *ContractIDPreimageType) *ContractIDPreimageType { return v } - -type XdrType_XdrAnon_ContractIDPreimage_FromAddress = *XdrAnon_ContractIDPreimage_FromAddress - -func (v *XdrAnon_ContractIDPreimage_FromAddress) XdrPointer() interface{} { return v } -func (XdrAnon_ContractIDPreimage_FromAddress) XdrTypeName() string { - return "XdrAnon_ContractIDPreimage_FromAddress" -} -func (v XdrAnon_ContractIDPreimage_FromAddress) XdrValue() interface{} { return v } -func (v *XdrAnon_ContractIDPreimage_FromAddress) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_ContractIDPreimage_FromAddress) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%saddress", name), XDR_SCAddress(&v.Address)) - x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(&v.Salt)) -} -func XDR_XdrAnon_ContractIDPreimage_FromAddress(v *XdrAnon_ContractIDPreimage_FromAddress) *XdrAnon_ContractIDPreimage_FromAddress { - return v -} - -var _XdrTags_ContractIDPreimage = map[int32]bool{ - XdrToI32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS): true, - XdrToI32(CONTRACT_ID_PREIMAGE_FROM_ASSET): true, -} - -func (_ ContractIDPreimage) XdrValidTags() map[int32]bool { - return _XdrTags_ContractIDPreimage -} -func (u *ContractIDPreimage) FromAddress() *XdrAnon_ContractIDPreimage_FromAddress { - switch u.Type { - case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: - if v, ok := u._u.(*XdrAnon_ContractIDPreimage_FromAddress); ok { - return v - } else { - var zero XdrAnon_ContractIDPreimage_FromAddress - u._u = &zero - return &zero - } - default: - XdrPanic("ContractIDPreimage.FromAddress accessed when Type == %v", u.Type) - return nil - } -} -func (u *ContractIDPreimage) FromAsset() *Asset { +func (u *StellarMessage) FloodDemand() *FloodDemand { switch u.Type { - case CONTRACT_ID_PREIMAGE_FROM_ASSET: - if v, ok := u._u.(*Asset); ok { + case FLOOD_DEMAND: + if v, ok := u._u.(*FloodDemand); ok { return v } else { - var zero Asset + var zero FloodDemand u._u = &zero return &zero } default: - XdrPanic("ContractIDPreimage.FromAsset accessed when Type == %v", u.Type) + XdrPanic("StellarMessage.FloodDemand accessed when Type == %v", u.Type) return nil } } -func (u ContractIDPreimage) XdrValid() bool { +func (u StellarMessage) XdrValid() bool { switch u.Type { - case CONTRACT_ID_PREIMAGE_FROM_ADDRESS, CONTRACT_ID_PREIMAGE_FROM_ASSET: + case ERROR_MSG, HELLO, AUTH, DONT_HAVE, GET_PEERS, PEERS, GET_TX_SET, TX_SET, GENERALIZED_TX_SET, TRANSACTION, SURVEY_REQUEST, SURVEY_RESPONSE, TIME_SLICED_SURVEY_REQUEST, TIME_SLICED_SURVEY_RESPONSE, TIME_SLICED_SURVEY_START_COLLECTING, TIME_SLICED_SURVEY_STOP_COLLECTING, GET_SCP_QUORUMSET, SCP_QUORUMSET, SCP_MESSAGE, GET_SCP_STATE, SEND_MORE, SEND_MORE_EXTENDED, FLOOD_ADVERT, FLOOD_DEMAND: return true } return false } -func (u *ContractIDPreimage) XdrUnionTag() XdrNum32 { - return XDR_ContractIDPreimageType(&u.Type) +func (u *StellarMessage) XdrUnionTag() XdrNum32 { + return XDR_MessageType(&u.Type) } -func (u *ContractIDPreimage) XdrUnionTagName() string { +func (u *StellarMessage) XdrUnionTagName() string { return "Type" } -func (u *ContractIDPreimage) XdrUnionBody() XdrType { +func (u *StellarMessage) XdrUnionBody() XdrType { switch u.Type { - case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: - return XDR_XdrAnon_ContractIDPreimage_FromAddress(u.FromAddress()) - case CONTRACT_ID_PREIMAGE_FROM_ASSET: - return XDR_Asset(u.FromAsset()) + case ERROR_MSG: + return XDR_Error(u.Error()) + case HELLO: + return XDR_Hello(u.Hello()) + case AUTH: + return XDR_Auth(u.Auth()) + case DONT_HAVE: + return XDR_DontHave(u.DontHave()) + case GET_PEERS: + return nil + case PEERS: + return (*_XdrVec_100_PeerAddress)(u.Peers()) + case GET_TX_SET: + return XDR_Uint256(u.TxSetHash()) + case TX_SET: + return XDR_TransactionSet(u.TxSet()) + case GENERALIZED_TX_SET: + return XDR_GeneralizedTransactionSet(u.GeneralizedTxSet()) + case TRANSACTION: + return XDR_TransactionEnvelope(u.Transaction()) + case SURVEY_REQUEST: + return XDR_SignedSurveyRequestMessage(u.SignedSurveyRequestMessage()) + case SURVEY_RESPONSE: + return XDR_SignedSurveyResponseMessage(u.SignedSurveyResponseMessage()) + case TIME_SLICED_SURVEY_REQUEST: + return XDR_SignedTimeSlicedSurveyRequestMessage(u.SignedTimeSlicedSurveyRequestMessage()) + case TIME_SLICED_SURVEY_RESPONSE: + return XDR_SignedTimeSlicedSurveyResponseMessage(u.SignedTimeSlicedSurveyResponseMessage()) + case TIME_SLICED_SURVEY_START_COLLECTING: + return XDR_SignedTimeSlicedSurveyStartCollectingMessage(u.SignedTimeSlicedSurveyStartCollectingMessage()) + case TIME_SLICED_SURVEY_STOP_COLLECTING: + return XDR_SignedTimeSlicedSurveyStopCollectingMessage(u.SignedTimeSlicedSurveyStopCollectingMessage()) + case GET_SCP_QUORUMSET: + return XDR_Uint256(u.QSetHash()) + case SCP_QUORUMSET: + return XDR_SCPQuorumSet(u.QSet()) + case SCP_MESSAGE: + return XDR_SCPEnvelope(u.Envelope()) + case GET_SCP_STATE: + return XDR_Uint32(u.GetSCPLedgerSeq()) + case SEND_MORE: + return XDR_SendMore(u.SendMoreMessage()) + case SEND_MORE_EXTENDED: + return XDR_SendMoreExtended(u.SendMoreExtendedMessage()) + case FLOOD_ADVERT: + return XDR_FloodAdvert(u.FloodAdvert()) + case FLOOD_DEMAND: + return XDR_FloodDemand(u.FloodDemand()) } return nil } -func (u *ContractIDPreimage) XdrUnionBodyName() string { - switch u.Type { - case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: - return "FromAddress" - case CONTRACT_ID_PREIMAGE_FROM_ASSET: - return "FromAsset" - } - return "" -} - -type XdrType_ContractIDPreimage = *ContractIDPreimage - -func (v *ContractIDPreimage) XdrPointer() interface{} { return v } -func (ContractIDPreimage) XdrTypeName() string { return "ContractIDPreimage" } -func (v ContractIDPreimage) XdrValue() interface{} { return v } -func (v *ContractIDPreimage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *ContractIDPreimage) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - XDR_ContractIDPreimageType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) +func (u *StellarMessage) XdrUnionBodyName() string { switch u.Type { - case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: - x.Marshal(x.Sprintf("%sfromAddress", name), XDR_XdrAnon_ContractIDPreimage_FromAddress(u.FromAddress())) - return - case CONTRACT_ID_PREIMAGE_FROM_ASSET: - x.Marshal(x.Sprintf("%sfromAsset", name), XDR_Asset(u.FromAsset())) - return - } - XdrPanic("invalid Type (%v) in ContractIDPreimage", u.Type) -} -func XDR_ContractIDPreimage(v *ContractIDPreimage) *ContractIDPreimage { return v } - -type XdrType_CreateContractArgs = *CreateContractArgs - -func (v *CreateContractArgs) XdrPointer() interface{} { return v } -func (CreateContractArgs) XdrTypeName() string { return "CreateContractArgs" } -func (v CreateContractArgs) XdrValue() interface{} { return v } -func (v *CreateContractArgs) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *CreateContractArgs) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%scontractIDPreimage", name), XDR_ContractIDPreimage(&v.ContractIDPreimage)) - x.Marshal(x.Sprintf("%sexecutable", name), XDR_ContractExecutable(&v.Executable)) -} -func XDR_CreateContractArgs(v *CreateContractArgs) *CreateContractArgs { return v } - -type XdrType_InvokeContractArgs = *InvokeContractArgs - -func (v *InvokeContractArgs) XdrPointer() interface{} { return v } -func (InvokeContractArgs) XdrTypeName() string { return "InvokeContractArgs" } -func (v InvokeContractArgs) XdrValue() interface{} { return v } -func (v *InvokeContractArgs) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *InvokeContractArgs) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) + case ERROR_MSG: + return "Error" + case HELLO: + return "Hello" + case AUTH: + return "Auth" + case DONT_HAVE: + return "DontHave" + case GET_PEERS: + return "" + case PEERS: + return "Peers" + case GET_TX_SET: + return "TxSetHash" + case TX_SET: + return "TxSet" + case GENERALIZED_TX_SET: + return "GeneralizedTxSet" + case TRANSACTION: + return "Transaction" + case SURVEY_REQUEST: + return "SignedSurveyRequestMessage" + case SURVEY_RESPONSE: + return "SignedSurveyResponseMessage" + case TIME_SLICED_SURVEY_REQUEST: + return "SignedTimeSlicedSurveyRequestMessage" + case TIME_SLICED_SURVEY_RESPONSE: + return "SignedTimeSlicedSurveyResponseMessage" + case TIME_SLICED_SURVEY_START_COLLECTING: + return "SignedTimeSlicedSurveyStartCollectingMessage" + case TIME_SLICED_SURVEY_STOP_COLLECTING: + return "SignedTimeSlicedSurveyStopCollectingMessage" + case GET_SCP_QUORUMSET: + return "QSetHash" + case SCP_QUORUMSET: + return "QSet" + case SCP_MESSAGE: + return "Envelope" + case GET_SCP_STATE: + return "GetSCPLedgerSeq" + case SEND_MORE: + return "SendMoreMessage" + case SEND_MORE_EXTENDED: + return "SendMoreExtendedMessage" + case FLOOD_ADVERT: + return "FloodAdvert" + case FLOOD_DEMAND: + return "FloodDemand" } - x.Marshal(x.Sprintf("%scontractAddress", name), XDR_SCAddress(&v.ContractAddress)) - x.Marshal(x.Sprintf("%sfunctionName", name), XDR_SCSymbol(&v.FunctionName)) - x.Marshal(x.Sprintf("%sargs", name), (*_XdrVec_unbounded_SCVal)(&v.Args)) + return "" } -func XDR_InvokeContractArgs(v *InvokeContractArgs) *InvokeContractArgs { return v } -var _XdrTags_HostFunction = map[int32]bool{ - XdrToI32(HOST_FUNCTION_TYPE_INVOKE_CONTRACT): true, - XdrToI32(HOST_FUNCTION_TYPE_CREATE_CONTRACT): true, - XdrToI32(HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM): true, -} +type XdrType_StellarMessage = *StellarMessage -func (_ HostFunction) XdrValidTags() map[int32]bool { - return _XdrTags_HostFunction -} -func (u *HostFunction) InvokeContract() *InvokeContractArgs { +func (v *StellarMessage) XdrPointer() interface{} { return v } +func (StellarMessage) XdrTypeName() string { return "StellarMessage" } +func (v StellarMessage) XdrValue() interface{} { return v } +func (v *StellarMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *StellarMessage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_MessageType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: - if v, ok := u._u.(*InvokeContractArgs); ok { - return v - } else { - var zero InvokeContractArgs - u._u = &zero - return &zero - } - default: - XdrPanic("HostFunction.InvokeContract accessed when Type == %v", u.Type) - return nil + case ERROR_MSG: + x.Marshal(x.Sprintf("%serror", name), XDR_Error(u.Error())) + return + case HELLO: + x.Marshal(x.Sprintf("%shello", name), XDR_Hello(u.Hello())) + return + case AUTH: + x.Marshal(x.Sprintf("%sauth", name), XDR_Auth(u.Auth())) + return + case DONT_HAVE: + x.Marshal(x.Sprintf("%sdontHave", name), XDR_DontHave(u.DontHave())) + return + case GET_PEERS: + return + case PEERS: + x.Marshal(x.Sprintf("%speers", name), (*_XdrVec_100_PeerAddress)(u.Peers())) + return + case GET_TX_SET: + x.Marshal(x.Sprintf("%stxSetHash", name), XDR_Uint256(u.TxSetHash())) + return + case TX_SET: + x.Marshal(x.Sprintf("%stxSet", name), XDR_TransactionSet(u.TxSet())) + return + case GENERALIZED_TX_SET: + x.Marshal(x.Sprintf("%sgeneralizedTxSet", name), XDR_GeneralizedTransactionSet(u.GeneralizedTxSet())) + return + case TRANSACTION: + x.Marshal(x.Sprintf("%stransaction", name), XDR_TransactionEnvelope(u.Transaction())) + return + case SURVEY_REQUEST: + x.Marshal(x.Sprintf("%ssignedSurveyRequestMessage", name), XDR_SignedSurveyRequestMessage(u.SignedSurveyRequestMessage())) + return + case SURVEY_RESPONSE: + x.Marshal(x.Sprintf("%ssignedSurveyResponseMessage", name), XDR_SignedSurveyResponseMessage(u.SignedSurveyResponseMessage())) + return + case TIME_SLICED_SURVEY_REQUEST: + x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyRequestMessage", name), XDR_SignedTimeSlicedSurveyRequestMessage(u.SignedTimeSlicedSurveyRequestMessage())) + return + case TIME_SLICED_SURVEY_RESPONSE: + x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyResponseMessage", name), XDR_SignedTimeSlicedSurveyResponseMessage(u.SignedTimeSlicedSurveyResponseMessage())) + return + case TIME_SLICED_SURVEY_START_COLLECTING: + x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyStartCollectingMessage", name), XDR_SignedTimeSlicedSurveyStartCollectingMessage(u.SignedTimeSlicedSurveyStartCollectingMessage())) + return + case TIME_SLICED_SURVEY_STOP_COLLECTING: + x.Marshal(x.Sprintf("%ssignedTimeSlicedSurveyStopCollectingMessage", name), XDR_SignedTimeSlicedSurveyStopCollectingMessage(u.SignedTimeSlicedSurveyStopCollectingMessage())) + return + case GET_SCP_QUORUMSET: + x.Marshal(x.Sprintf("%sqSetHash", name), XDR_Uint256(u.QSetHash())) + return + case SCP_QUORUMSET: + x.Marshal(x.Sprintf("%sqSet", name), XDR_SCPQuorumSet(u.QSet())) + return + case SCP_MESSAGE: + x.Marshal(x.Sprintf("%senvelope", name), XDR_SCPEnvelope(u.Envelope())) + return + case GET_SCP_STATE: + x.Marshal(x.Sprintf("%sgetSCPLedgerSeq", name), XDR_Uint32(u.GetSCPLedgerSeq())) + return + case SEND_MORE: + x.Marshal(x.Sprintf("%ssendMoreMessage", name), XDR_SendMore(u.SendMoreMessage())) + return + case SEND_MORE_EXTENDED: + x.Marshal(x.Sprintf("%ssendMoreExtendedMessage", name), XDR_SendMoreExtended(u.SendMoreExtendedMessage())) + return + case FLOOD_ADVERT: + x.Marshal(x.Sprintf("%sfloodAdvert", name), XDR_FloodAdvert(u.FloodAdvert())) + return + case FLOOD_DEMAND: + x.Marshal(x.Sprintf("%sfloodDemand", name), XDR_FloodDemand(u.FloodDemand())) + return } + XdrPanic("invalid Type (%v) in StellarMessage", u.Type) } -func (u *HostFunction) CreateContract() *CreateContractArgs { - switch u.Type { - case HOST_FUNCTION_TYPE_CREATE_CONTRACT: - if v, ok := u._u.(*CreateContractArgs); ok { - return v - } else { - var zero CreateContractArgs - u._u = &zero - return &zero - } - default: - XdrPanic("HostFunction.CreateContract accessed when Type == %v", u.Type) - return nil +func XDR_StellarMessage(v *StellarMessage) *StellarMessage { return v } + +type XdrType_XdrAnon_AuthenticatedMessage_V0 = *XdrAnon_AuthenticatedMessage_V0 + +func (v *XdrAnon_AuthenticatedMessage_V0) XdrPointer() interface{} { return v } +func (XdrAnon_AuthenticatedMessage_V0) XdrTypeName() string { return "XdrAnon_AuthenticatedMessage_V0" } +func (v XdrAnon_AuthenticatedMessage_V0) XdrValue() interface{} { return v } +func (v *XdrAnon_AuthenticatedMessage_V0) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_AuthenticatedMessage_V0) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%ssequence", name), XDR_Uint64(&v.Sequence)) + x.Marshal(x.Sprintf("%smessage", name), XDR_StellarMessage(&v.Message)) + x.Marshal(x.Sprintf("%smac", name), XDR_HmacSha256Mac(&v.Mac)) } -func (u *HostFunction) Wasm() *[]byte { - switch u.Type { - case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - if v, ok := u._u.(*[]byte); ok { +func XDR_XdrAnon_AuthenticatedMessage_V0(v *XdrAnon_AuthenticatedMessage_V0) *XdrAnon_AuthenticatedMessage_V0 { + return v +} + +var _XdrTags_AuthenticatedMessage = map[int32]bool{ + XdrToI32(0): true, +} + +func (_ AuthenticatedMessage) XdrValidTags() map[int32]bool { + return _XdrTags_AuthenticatedMessage +} +func (u *AuthenticatedMessage) V0() *XdrAnon_AuthenticatedMessage_V0 { + switch u.V { + case 0: + if v, ok := u._u.(*XdrAnon_AuthenticatedMessage_V0); ok { return v } else { - var zero []byte + var zero XdrAnon_AuthenticatedMessage_V0 u._u = &zero return &zero } default: - XdrPanic("HostFunction.Wasm accessed when Type == %v", u.Type) + XdrPanic("AuthenticatedMessage.V0 accessed when V == %v", u.V) return nil } } -func (u HostFunction) XdrValid() bool { - switch u.Type { - case HOST_FUNCTION_TYPE_INVOKE_CONTRACT, HOST_FUNCTION_TYPE_CREATE_CONTRACT, HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: +func (u AuthenticatedMessage) XdrValid() bool { + switch u.V { + case 0: return true } return false } -func (u *HostFunction) XdrUnionTag() XdrNum32 { - return XDR_HostFunctionType(&u.Type) +func (u *AuthenticatedMessage) XdrUnionTag() XdrNum32 { + return XDR_Uint32(&u.V) } -func (u *HostFunction) XdrUnionTagName() string { - return "Type" +func (u *AuthenticatedMessage) XdrUnionTagName() string { + return "V" } -func (u *HostFunction) XdrUnionBody() XdrType { - switch u.Type { - case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: - return XDR_InvokeContractArgs(u.InvokeContract()) - case HOST_FUNCTION_TYPE_CREATE_CONTRACT: - return XDR_CreateContractArgs(u.CreateContract()) - case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - return XdrVecOpaque{u.Wasm(), 0xffffffff} +func (u *AuthenticatedMessage) XdrUnionBody() XdrType { + switch u.V { + case 0: + return XDR_XdrAnon_AuthenticatedMessage_V0(u.V0()) } return nil } -func (u *HostFunction) XdrUnionBodyName() string { - switch u.Type { - case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: - return "InvokeContract" - case HOST_FUNCTION_TYPE_CREATE_CONTRACT: - return "CreateContract" - case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - return "Wasm" +func (u *AuthenticatedMessage) XdrUnionBodyName() string { + switch u.V { + case 0: + return "V0" } return "" } -type XdrType_HostFunction = *HostFunction +type XdrType_AuthenticatedMessage = *AuthenticatedMessage -func (v *HostFunction) XdrPointer() interface{} { return v } -func (HostFunction) XdrTypeName() string { return "HostFunction" } -func (v HostFunction) XdrValue() interface{} { return v } -func (v *HostFunction) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *HostFunction) XdrRecurse(x XDR, name string) { - if name != "" { +func (v *AuthenticatedMessage) XdrPointer() interface{} { return v } +func (AuthenticatedMessage) XdrTypeName() string { return "AuthenticatedMessage" } +func (v AuthenticatedMessage) XdrValue() interface{} { return v } +func (v *AuthenticatedMessage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *AuthenticatedMessage) XdrRecurse(x XDR, name string) { + if name != "" { name = x.Sprintf("%s.", name) } - XDR_HostFunctionType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: - x.Marshal(x.Sprintf("%sinvokeContract", name), XDR_InvokeContractArgs(u.InvokeContract())) - return - case HOST_FUNCTION_TYPE_CREATE_CONTRACT: - x.Marshal(x.Sprintf("%screateContract", name), XDR_CreateContractArgs(u.CreateContract())) - return - case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - x.Marshal(x.Sprintf("%swasm", name), XdrVecOpaque{u.Wasm(), 0xffffffff}) + XDR_Uint32(&u.V).XdrMarshal(x, x.Sprintf("%sv", name)) + switch u.V { + case 0: + x.Marshal(x.Sprintf("%sv0", name), XDR_XdrAnon_AuthenticatedMessage_V0(u.V0())) return } - XdrPanic("invalid Type (%v) in HostFunction", u.Type) + XdrPanic("invalid V (%v) in AuthenticatedMessage", u.V) } -func XDR_HostFunction(v *HostFunction) *HostFunction { return v } +func XDR_AuthenticatedMessage(v *AuthenticatedMessage) *AuthenticatedMessage { return v } -var _XdrNames_SorobanAuthorizedFunctionType = map[int32]string{ - int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN): "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN", - int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN): "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN", -} -var _XdrValues_SorobanAuthorizedFunctionType = map[string]int32{ - "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN": int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN), - "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN": int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN), +var _XdrTags_LiquidityPoolParameters = map[int32]bool{ + XdrToI32(LIQUIDITY_POOL_CONSTANT_PRODUCT): true, } -func (SorobanAuthorizedFunctionType) XdrEnumNames() map[int32]string { - return _XdrNames_SorobanAuthorizedFunctionType +func (_ LiquidityPoolParameters) XdrValidTags() map[int32]bool { + return _XdrTags_LiquidityPoolParameters } -func (v SorobanAuthorizedFunctionType) String() string { - if s, ok := _XdrNames_SorobanAuthorizedFunctionType[int32(v)]; ok { - return s +func (u *LiquidityPoolParameters) ConstantProduct() *LiquidityPoolConstantProductParameters { + switch u.Type { + case LIQUIDITY_POOL_CONSTANT_PRODUCT: + if v, ok := u._u.(*LiquidityPoolConstantProductParameters); ok { + return v + } else { + var zero LiquidityPoolConstantProductParameters + u._u = &zero + return &zero + } + default: + XdrPanic("LiquidityPoolParameters.ConstantProduct accessed when Type == %v", u.Type) + return nil } - return fmt.Sprintf("SorobanAuthorizedFunctionType#%d", v) } -func (v *SorobanAuthorizedFunctionType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_SorobanAuthorizedFunctionType[stok]; ok { - *v = SorobanAuthorizedFunctionType(val) - return nil - } else if stok == "SorobanAuthorizedFunctionType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SorobanAuthorizedFunctionType.", stok)) +func (u LiquidityPoolParameters) XdrValid() bool { + switch u.Type { + case LIQUIDITY_POOL_CONSTANT_PRODUCT: + return true } + return false +} +func (u *LiquidityPoolParameters) XdrUnionTag() XdrNum32 { + return XDR_LiquidityPoolType(&u.Type) +} +func (u *LiquidityPoolParameters) XdrUnionTagName() string { + return "Type" +} +func (u *LiquidityPoolParameters) XdrUnionBody() XdrType { + switch u.Type { + case LIQUIDITY_POOL_CONSTANT_PRODUCT: + return XDR_LiquidityPoolConstantProductParameters(u.ConstantProduct()) + } + return nil +} +func (u *LiquidityPoolParameters) XdrUnionBodyName() string { + switch u.Type { + case LIQUIDITY_POOL_CONSTANT_PRODUCT: + return "ConstantProduct" + } + return "" } -func (v SorobanAuthorizedFunctionType) GetU32() uint32 { return uint32(v) } -func (v *SorobanAuthorizedFunctionType) SetU32(n uint32) { *v = SorobanAuthorizedFunctionType(n) } -func (v *SorobanAuthorizedFunctionType) XdrPointer() interface{} { return v } -func (SorobanAuthorizedFunctionType) XdrTypeName() string { return "SorobanAuthorizedFunctionType" } -func (v SorobanAuthorizedFunctionType) XdrValue() interface{} { return v } -func (v *SorobanAuthorizedFunctionType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_SorobanAuthorizedFunctionType = *SorobanAuthorizedFunctionType +type XdrType_LiquidityPoolParameters = *LiquidityPoolParameters -func XDR_SorobanAuthorizedFunctionType(v *SorobanAuthorizedFunctionType) *SorobanAuthorizedFunctionType { +func (v *LiquidityPoolParameters) XdrPointer() interface{} { return v } +func (LiquidityPoolParameters) XdrTypeName() string { return "LiquidityPoolParameters" } +func (v LiquidityPoolParameters) XdrValue() interface{} { return v } +func (v *LiquidityPoolParameters) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *LiquidityPoolParameters) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_LiquidityPoolType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case LIQUIDITY_POOL_CONSTANT_PRODUCT: + x.Marshal(x.Sprintf("%sconstantProduct", name), XDR_LiquidityPoolConstantProductParameters(u.ConstantProduct())) + return + } + XdrPanic("invalid Type (%v) in LiquidityPoolParameters", u.Type) +} +func XDR_LiquidityPoolParameters(v *LiquidityPoolParameters) *LiquidityPoolParameters { return v } + +type XdrType_XdrAnon_MuxedAccount_Med25519 = *XdrAnon_MuxedAccount_Med25519 + +func (v *XdrAnon_MuxedAccount_Med25519) XdrPointer() interface{} { return v } +func (XdrAnon_MuxedAccount_Med25519) XdrTypeName() string { return "XdrAnon_MuxedAccount_Med25519" } +func (v XdrAnon_MuxedAccount_Med25519) XdrValue() interface{} { return v } +func (v *XdrAnon_MuxedAccount_Med25519) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_MuxedAccount_Med25519) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sid", name), XDR_Uint64(&v.Id)) + x.Marshal(x.Sprintf("%sed25519", name), XDR_Uint256(&v.Ed25519)) +} +func XDR_XdrAnon_MuxedAccount_Med25519(v *XdrAnon_MuxedAccount_Med25519) *XdrAnon_MuxedAccount_Med25519 { return v } -var _XdrTags_SorobanAuthorizedFunction = map[int32]bool{ - XdrToI32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN): true, - XdrToI32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN): true, +var _XdrTags_MuxedAccount = map[int32]bool{ + XdrToI32(KEY_TYPE_ED25519): true, + XdrToI32(KEY_TYPE_MUXED_ED25519): true, } -func (_ SorobanAuthorizedFunction) XdrValidTags() map[int32]bool { - return _XdrTags_SorobanAuthorizedFunction +func (_ MuxedAccount) XdrValidTags() map[int32]bool { + return _XdrTags_MuxedAccount } -func (u *SorobanAuthorizedFunction) ContractFn() *InvokeContractArgs { +func (u *MuxedAccount) Ed25519() *Uint256 { switch u.Type { - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: - if v, ok := u._u.(*InvokeContractArgs); ok { + case KEY_TYPE_ED25519: + if v, ok := u._u.(*Uint256); ok { return v } else { - var zero InvokeContractArgs + var zero Uint256 u._u = &zero return &zero } default: - XdrPanic("SorobanAuthorizedFunction.ContractFn accessed when Type == %v", u.Type) + XdrPanic("MuxedAccount.Ed25519 accessed when Type == %v", u.Type) return nil } } -func (u *SorobanAuthorizedFunction) CreateContractHostFn() *CreateContractArgs { +func (u *MuxedAccount) Med25519() *XdrAnon_MuxedAccount_Med25519 { switch u.Type { - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: - if v, ok := u._u.(*CreateContractArgs); ok { + case KEY_TYPE_MUXED_ED25519: + if v, ok := u._u.(*XdrAnon_MuxedAccount_Med25519); ok { return v } else { - var zero CreateContractArgs + var zero XdrAnon_MuxedAccount_Med25519 u._u = &zero return &zero } default: - XdrPanic("SorobanAuthorizedFunction.CreateContractHostFn accessed when Type == %v", u.Type) + XdrPanic("MuxedAccount.Med25519 accessed when Type == %v", u.Type) return nil } } -func (u SorobanAuthorizedFunction) XdrValid() bool { +func (u MuxedAccount) XdrValid() bool { switch u.Type { - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN, SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + case KEY_TYPE_ED25519, KEY_TYPE_MUXED_ED25519: return true } return false } -func (u *SorobanAuthorizedFunction) XdrUnionTag() XdrNum32 { - return XDR_SorobanAuthorizedFunctionType(&u.Type) +func (u *MuxedAccount) XdrUnionTag() XdrNum32 { + return XDR_CryptoKeyType(&u.Type) } -func (u *SorobanAuthorizedFunction) XdrUnionTagName() string { +func (u *MuxedAccount) XdrUnionTagName() string { return "Type" } -func (u *SorobanAuthorizedFunction) XdrUnionBody() XdrType { +func (u *MuxedAccount) XdrUnionBody() XdrType { switch u.Type { - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: - return XDR_InvokeContractArgs(u.ContractFn()) - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: - return XDR_CreateContractArgs(u.CreateContractHostFn()) + case KEY_TYPE_ED25519: + return XDR_Uint256(u.Ed25519()) + case KEY_TYPE_MUXED_ED25519: + return XDR_XdrAnon_MuxedAccount_Med25519(u.Med25519()) } return nil } -func (u *SorobanAuthorizedFunction) XdrUnionBodyName() string { +func (u *MuxedAccount) XdrUnionBodyName() string { switch u.Type { - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: - return "ContractFn" - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: - return "CreateContractHostFn" + case KEY_TYPE_ED25519: + return "Ed25519" + case KEY_TYPE_MUXED_ED25519: + return "Med25519" } return "" } -type XdrType_SorobanAuthorizedFunction = *SorobanAuthorizedFunction +type XdrType_MuxedAccount = *MuxedAccount -func (v *SorobanAuthorizedFunction) XdrPointer() interface{} { return v } -func (SorobanAuthorizedFunction) XdrTypeName() string { return "SorobanAuthorizedFunction" } -func (v SorobanAuthorizedFunction) XdrValue() interface{} { return v } -func (v *SorobanAuthorizedFunction) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *SorobanAuthorizedFunction) XdrRecurse(x XDR, name string) { +func (v *MuxedAccount) XdrPointer() interface{} { return v } +func (MuxedAccount) XdrTypeName() string { return "MuxedAccount" } +func (v MuxedAccount) XdrValue() interface{} { return v } +func (v *MuxedAccount) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *MuxedAccount) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_SorobanAuthorizedFunctionType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + XDR_CryptoKeyType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: - x.Marshal(x.Sprintf("%scontractFn", name), XDR_InvokeContractArgs(u.ContractFn())) + case KEY_TYPE_ED25519: + x.Marshal(x.Sprintf("%sed25519", name), XDR_Uint256(u.Ed25519())) return - case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: - x.Marshal(x.Sprintf("%screateContractHostFn", name), XDR_CreateContractArgs(u.CreateContractHostFn())) + case KEY_TYPE_MUXED_ED25519: + x.Marshal(x.Sprintf("%smed25519", name), XDR_XdrAnon_MuxedAccount_Med25519(u.Med25519())) return } - XdrPanic("invalid Type (%v) in SorobanAuthorizedFunction", u.Type) + XdrPanic("invalid Type (%v) in MuxedAccount", u.Type) } -func XDR_SorobanAuthorizedFunction(v *SorobanAuthorizedFunction) *SorobanAuthorizedFunction { return v } +func XDR_MuxedAccount(v *MuxedAccount) *MuxedAccount { return v } -type _XdrVec_unbounded_SorobanAuthorizedInvocation []SorobanAuthorizedInvocation +type XdrType_DecoratedSignature = *DecoratedSignature -func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_SorobanAuthorizedInvocation length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_SorobanAuthorizedInvocation length %d exceeds max int", length) - } -} -func (v _XdrVec_unbounded_SorobanAuthorizedInvocation) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) SetVecLen(length uint32) { - v.XdrCheckLen(length) - if int(length) <= cap(*v) { - if int(length) != len(*v) { - *v = (*v)[:int(length)] - } - return - } - newcap := 2 * cap(*v) - if newcap < int(length) { // also catches overflow where 2*cap < 0 - newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { - if int(bound) < 0 { - bound = ^uint(0) >> 1 - } - newcap = int(bound) +func (v *DecoratedSignature) XdrPointer() interface{} { return v } +func (DecoratedSignature) XdrTypeName() string { return "DecoratedSignature" } +func (v DecoratedSignature) XdrValue() interface{} { return v } +func (v *DecoratedSignature) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *DecoratedSignature) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - nv := make([]SorobanAuthorizedInvocation, int(length), newcap) - copy(nv, *v) - *v = nv + x.Marshal(x.Sprintf("%shint", name), XDR_SignatureHint(&v.Hint)) + x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) } -func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrMarshalN(x XDR, name string, n uint32) { - v.XdrCheckLen(n) - for i := 0; i < int(n); i++ { - if i >= len(*v) { - v.SetVecLen(uint32(i + 1)) - } - XDR_SorobanAuthorizedInvocation(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} - x.Marshal(name, &size) - v.XdrMarshalN(x, name, size.Size) -} -func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrTypeName() string { - return "SorobanAuthorizedInvocation<>" -} -func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrPointer() interface{} { - return (*[]SorobanAuthorizedInvocation)(v) -} -func (v _XdrVec_unbounded_SorobanAuthorizedInvocation) XdrValue() interface{} { - return ([]SorobanAuthorizedInvocation)(v) -} -func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} - -type XdrType_SorobanAuthorizedInvocation = *SorobanAuthorizedInvocation - -func (v *SorobanAuthorizedInvocation) XdrPointer() interface{} { return v } -func (SorobanAuthorizedInvocation) XdrTypeName() string { return "SorobanAuthorizedInvocation" } -func (v SorobanAuthorizedInvocation) XdrValue() interface{} { return v } -func (v *SorobanAuthorizedInvocation) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SorobanAuthorizedInvocation) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sfunction", name), XDR_SorobanAuthorizedFunction(&v.Function)) - x.Marshal(x.Sprintf("%ssubInvocations", name), (*_XdrVec_unbounded_SorobanAuthorizedInvocation)(&v.SubInvocations)) -} -func XDR_SorobanAuthorizedInvocation(v *SorobanAuthorizedInvocation) *SorobanAuthorizedInvocation { - return v -} - -type XdrType_SorobanAddressCredentials = *SorobanAddressCredentials - -func (v *SorobanAddressCredentials) XdrPointer() interface{} { return v } -func (SorobanAddressCredentials) XdrTypeName() string { return "SorobanAddressCredentials" } -func (v SorobanAddressCredentials) XdrValue() interface{} { return v } -func (v *SorobanAddressCredentials) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SorobanAddressCredentials) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%saddress", name), XDR_SCAddress(&v.Address)) - x.Marshal(x.Sprintf("%snonce", name), XDR_Int64(&v.Nonce)) - x.Marshal(x.Sprintf("%ssignatureExpirationLedger", name), XDR_Uint32(&v.SignatureExpirationLedger)) - x.Marshal(x.Sprintf("%ssignature", name), XDR_SCVal(&v.Signature)) -} -func XDR_SorobanAddressCredentials(v *SorobanAddressCredentials) *SorobanAddressCredentials { return v } +func XDR_DecoratedSignature(v *DecoratedSignature) *DecoratedSignature { return v } -var _XdrNames_SorobanCredentialsType = map[int32]string{ - int32(SOROBAN_CREDENTIALS_SOURCE_ACCOUNT): "SOROBAN_CREDENTIALS_SOURCE_ACCOUNT", - int32(SOROBAN_CREDENTIALS_ADDRESS): "SOROBAN_CREDENTIALS_ADDRESS", +var _XdrNames_OperationType = map[int32]string{ + int32(CREATE_ACCOUNT): "CREATE_ACCOUNT", + int32(PAYMENT): "PAYMENT", + int32(PATH_PAYMENT_STRICT_RECEIVE): "PATH_PAYMENT_STRICT_RECEIVE", + int32(MANAGE_SELL_OFFER): "MANAGE_SELL_OFFER", + int32(CREATE_PASSIVE_SELL_OFFER): "CREATE_PASSIVE_SELL_OFFER", + int32(SET_OPTIONS): "SET_OPTIONS", + int32(CHANGE_TRUST): "CHANGE_TRUST", + int32(ALLOW_TRUST): "ALLOW_TRUST", + int32(ACCOUNT_MERGE): "ACCOUNT_MERGE", + int32(INFLATION): "INFLATION", + int32(MANAGE_DATA): "MANAGE_DATA", + int32(BUMP_SEQUENCE): "BUMP_SEQUENCE", + int32(MANAGE_BUY_OFFER): "MANAGE_BUY_OFFER", + int32(PATH_PAYMENT_STRICT_SEND): "PATH_PAYMENT_STRICT_SEND", + int32(CREATE_CLAIMABLE_BALANCE): "CREATE_CLAIMABLE_BALANCE", + int32(CLAIM_CLAIMABLE_BALANCE): "CLAIM_CLAIMABLE_BALANCE", + int32(BEGIN_SPONSORING_FUTURE_RESERVES): "BEGIN_SPONSORING_FUTURE_RESERVES", + int32(END_SPONSORING_FUTURE_RESERVES): "END_SPONSORING_FUTURE_RESERVES", + int32(REVOKE_SPONSORSHIP): "REVOKE_SPONSORSHIP", + int32(CLAWBACK): "CLAWBACK", + int32(CLAWBACK_CLAIMABLE_BALANCE): "CLAWBACK_CLAIMABLE_BALANCE", + int32(SET_TRUST_LINE_FLAGS): "SET_TRUST_LINE_FLAGS", + int32(LIQUIDITY_POOL_DEPOSIT): "LIQUIDITY_POOL_DEPOSIT", + int32(LIQUIDITY_POOL_WITHDRAW): "LIQUIDITY_POOL_WITHDRAW", + int32(INVOKE_HOST_FUNCTION): "INVOKE_HOST_FUNCTION", + int32(EXTEND_FOOTPRINT_TTL): "EXTEND_FOOTPRINT_TTL", + int32(RESTORE_FOOTPRINT): "RESTORE_FOOTPRINT", } -var _XdrValues_SorobanCredentialsType = map[string]int32{ - "SOROBAN_CREDENTIALS_SOURCE_ACCOUNT": int32(SOROBAN_CREDENTIALS_SOURCE_ACCOUNT), - "SOROBAN_CREDENTIALS_ADDRESS": int32(SOROBAN_CREDENTIALS_ADDRESS), +var _XdrValues_OperationType = map[string]int32{ + "CREATE_ACCOUNT": int32(CREATE_ACCOUNT), + "PAYMENT": int32(PAYMENT), + "PATH_PAYMENT_STRICT_RECEIVE": int32(PATH_PAYMENT_STRICT_RECEIVE), + "MANAGE_SELL_OFFER": int32(MANAGE_SELL_OFFER), + "CREATE_PASSIVE_SELL_OFFER": int32(CREATE_PASSIVE_SELL_OFFER), + "SET_OPTIONS": int32(SET_OPTIONS), + "CHANGE_TRUST": int32(CHANGE_TRUST), + "ALLOW_TRUST": int32(ALLOW_TRUST), + "ACCOUNT_MERGE": int32(ACCOUNT_MERGE), + "INFLATION": int32(INFLATION), + "MANAGE_DATA": int32(MANAGE_DATA), + "BUMP_SEQUENCE": int32(BUMP_SEQUENCE), + "MANAGE_BUY_OFFER": int32(MANAGE_BUY_OFFER), + "PATH_PAYMENT_STRICT_SEND": int32(PATH_PAYMENT_STRICT_SEND), + "CREATE_CLAIMABLE_BALANCE": int32(CREATE_CLAIMABLE_BALANCE), + "CLAIM_CLAIMABLE_BALANCE": int32(CLAIM_CLAIMABLE_BALANCE), + "BEGIN_SPONSORING_FUTURE_RESERVES": int32(BEGIN_SPONSORING_FUTURE_RESERVES), + "END_SPONSORING_FUTURE_RESERVES": int32(END_SPONSORING_FUTURE_RESERVES), + "REVOKE_SPONSORSHIP": int32(REVOKE_SPONSORSHIP), + "CLAWBACK": int32(CLAWBACK), + "CLAWBACK_CLAIMABLE_BALANCE": int32(CLAWBACK_CLAIMABLE_BALANCE), + "SET_TRUST_LINE_FLAGS": int32(SET_TRUST_LINE_FLAGS), + "LIQUIDITY_POOL_DEPOSIT": int32(LIQUIDITY_POOL_DEPOSIT), + "LIQUIDITY_POOL_WITHDRAW": int32(LIQUIDITY_POOL_WITHDRAW), + "INVOKE_HOST_FUNCTION": int32(INVOKE_HOST_FUNCTION), + "EXTEND_FOOTPRINT_TTL": int32(EXTEND_FOOTPRINT_TTL), + "RESTORE_FOOTPRINT": int32(RESTORE_FOOTPRINT), } -func (SorobanCredentialsType) XdrEnumNames() map[int32]string { - return _XdrNames_SorobanCredentialsType +func (OperationType) XdrEnumNames() map[int32]string { + return _XdrNames_OperationType } -func (v SorobanCredentialsType) String() string { - if s, ok := _XdrNames_SorobanCredentialsType[int32(v)]; ok { +func (v OperationType) String() string { + if s, ok := _XdrNames_OperationType[int32(v)]; ok { return s } - return fmt.Sprintf("SorobanCredentialsType#%d", v) + return fmt.Sprintf("OperationType#%d", v) } -func (v *SorobanCredentialsType) Scan(ss fmt.ScanState, _ rune) error { +func (v *OperationType) Scan(ss fmt.ScanState, _ rune) error { if tok, err := ss.Token(true, XdrSymChar); err != nil { return err } else { stok := string(tok) - if val, ok := _XdrValues_SorobanCredentialsType[stok]; ok { - *v = SorobanCredentialsType(val) + if val, ok := _XdrValues_OperationType[stok]; ok { + *v = OperationType(val) return nil - } else if stok == "SorobanCredentialsType" { + } else if stok == "OperationType" { if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { return nil } } - return XdrError(fmt.Sprintf("%s is not a valid SorobanCredentialsType.", stok)) + return XdrError(fmt.Sprintf("%s is not a valid OperationType.", stok)) } } -func (v SorobanCredentialsType) GetU32() uint32 { return uint32(v) } -func (v *SorobanCredentialsType) SetU32(n uint32) { *v = SorobanCredentialsType(n) } -func (v *SorobanCredentialsType) XdrPointer() interface{} { return v } -func (SorobanCredentialsType) XdrTypeName() string { return "SorobanCredentialsType" } -func (v SorobanCredentialsType) XdrValue() interface{} { return v } -func (v *SorobanCredentialsType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v OperationType) GetU32() uint32 { return uint32(v) } +func (v *OperationType) SetU32(n uint32) { *v = OperationType(n) } +func (v *OperationType) XdrPointer() interface{} { return v } +func (OperationType) XdrTypeName() string { return "OperationType" } +func (v OperationType) XdrValue() interface{} { return v } +func (v *OperationType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_SorobanCredentialsType = *SorobanCredentialsType +type XdrType_OperationType = *OperationType -func XDR_SorobanCredentialsType(v *SorobanCredentialsType) *SorobanCredentialsType { return v } +func XDR_OperationType(v *OperationType) *OperationType { return v } -var _XdrTags_SorobanCredentials = map[int32]bool{ - XdrToI32(SOROBAN_CREDENTIALS_SOURCE_ACCOUNT): true, - XdrToI32(SOROBAN_CREDENTIALS_ADDRESS): true, -} +type XdrType_CreateAccountOp = *CreateAccountOp -func (_ SorobanCredentials) XdrValidTags() map[int32]bool { - return _XdrTags_SorobanCredentials -} -func (u *SorobanCredentials) Address() *SorobanAddressCredentials { - switch u.Type { - case SOROBAN_CREDENTIALS_ADDRESS: - if v, ok := u._u.(*SorobanAddressCredentials); ok { - return v - } else { - var zero SorobanAddressCredentials - u._u = &zero - return &zero - } - default: - XdrPanic("SorobanCredentials.Address accessed when Type == %v", u.Type) - return nil - } -} -func (u SorobanCredentials) XdrValid() bool { - switch u.Type { - case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT, SOROBAN_CREDENTIALS_ADDRESS: - return true - } - return false -} -func (u *SorobanCredentials) XdrUnionTag() XdrNum32 { - return XDR_SorobanCredentialsType(&u.Type) -} -func (u *SorobanCredentials) XdrUnionTagName() string { - return "Type" -} -func (u *SorobanCredentials) XdrUnionBody() XdrType { - switch u.Type { - case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: - return nil - case SOROBAN_CREDENTIALS_ADDRESS: - return XDR_SorobanAddressCredentials(u.Address()) - } - return nil -} -func (u *SorobanCredentials) XdrUnionBodyName() string { - switch u.Type { - case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: - return "" - case SOROBAN_CREDENTIALS_ADDRESS: - return "Address" +func (v *CreateAccountOp) XdrPointer() interface{} { return v } +func (CreateAccountOp) XdrTypeName() string { return "CreateAccountOp" } +func (v CreateAccountOp) XdrValue() interface{} { return v } +func (v *CreateAccountOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *CreateAccountOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } - return "" + x.Marshal(x.Sprintf("%sdestination", name), XDR_AccountID(&v.Destination)) + x.Marshal(x.Sprintf("%sstartingBalance", name), XDR_Int64(&v.StartingBalance)) } +func XDR_CreateAccountOp(v *CreateAccountOp) *CreateAccountOp { return v } -type XdrType_SorobanCredentials = *SorobanCredentials +type XdrType_PaymentOp = *PaymentOp -func (v *SorobanCredentials) XdrPointer() interface{} { return v } -func (SorobanCredentials) XdrTypeName() string { return "SorobanCredentials" } -func (v SorobanCredentials) XdrValue() interface{} { return v } -func (v *SorobanCredentials) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *SorobanCredentials) XdrRecurse(x XDR, name string) { +func (v *PaymentOp) XdrPointer() interface{} { return v } +func (PaymentOp) XdrTypeName() string { return "PaymentOp" } +func (v PaymentOp) XdrValue() interface{} { return v } +func (v *PaymentOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *PaymentOp) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_SorobanCredentialsType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: - return - case SOROBAN_CREDENTIALS_ADDRESS: - x.Marshal(x.Sprintf("%saddress", name), XDR_SorobanAddressCredentials(u.Address())) - return - } - XdrPanic("invalid Type (%v) in SorobanCredentials", u.Type) + x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(&v.Destination)) + x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) + x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) } -func XDR_SorobanCredentials(v *SorobanCredentials) *SorobanCredentials { return v } +func XDR_PaymentOp(v *PaymentOp) *PaymentOp { return v } -type XdrType_SorobanAuthorizationEntry = *SorobanAuthorizationEntry +type _XdrVec_5_Asset []Asset -func (v *SorobanAuthorizationEntry) XdrPointer() interface{} { return v } -func (SorobanAuthorizationEntry) XdrTypeName() string { return "SorobanAuthorizationEntry" } -func (v SorobanAuthorizationEntry) XdrValue() interface{} { return v } -func (v *SorobanAuthorizationEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *SorobanAuthorizationEntry) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%scredentials", name), XDR_SorobanCredentials(&v.Credentials)) - x.Marshal(x.Sprintf("%srootInvocation", name), XDR_SorobanAuthorizedInvocation(&v.RootInvocation)) -} -func XDR_SorobanAuthorizationEntry(v *SorobanAuthorizationEntry) *SorobanAuthorizationEntry { return v } - -type _XdrVec_unbounded_SorobanAuthorizationEntry []SorobanAuthorizationEntry - -func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit +func (_XdrVec_5_Asset) XdrBound() uint32 { + const bound uint32 = 5 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_SorobanAuthorizationEntry length %d exceeds bound 4294967295", length) +func (_XdrVec_5_Asset) XdrCheckLen(length uint32) { + if length > uint32(5) { + XdrPanic("_XdrVec_5_Asset length %d exceeds bound 5", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_SorobanAuthorizationEntry length %d exceeds max int", length) + XdrPanic("_XdrVec_5_Asset length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_SorobanAuthorizationEntry) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) SetVecLen(length uint32) { +func (v _XdrVec_5_Asset) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_5_Asset) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -17094,738 +16198,3161 @@ func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) SetVecLen(length uint32) { newcap := 2 * cap(*v) if newcap < int(length) { // also catches overflow where 2*cap < 0 newcap = int(length) - } else if bound := uint(4294967295); uint(newcap) > bound { + } else if bound := uint(5); uint(newcap) > bound { if int(bound) < 0 { bound = ^uint(0) >> 1 } newcap = int(bound) } - nv := make([]SorobanAuthorizationEntry, int(length), newcap) + nv := make([]Asset, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_5_Asset) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_SorobanAuthorizationEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_Asset(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} +func (v *_XdrVec_5_Asset) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 5} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrTypeName() string { - return "SorobanAuthorizationEntry<>" -} -func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrPointer() interface{} { - return (*[]SorobanAuthorizationEntry)(v) +func (_XdrVec_5_Asset) XdrTypeName() string { return "Asset<>" } +func (v *_XdrVec_5_Asset) XdrPointer() interface{} { return (*[]Asset)(v) } +func (v _XdrVec_5_Asset) XdrValue() interface{} { return ([]Asset)(v) } +func (v *_XdrVec_5_Asset) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_PathPaymentStrictReceiveOp = *PathPaymentStrictReceiveOp + +func (v *PathPaymentStrictReceiveOp) XdrPointer() interface{} { return v } +func (PathPaymentStrictReceiveOp) XdrTypeName() string { return "PathPaymentStrictReceiveOp" } +func (v PathPaymentStrictReceiveOp) XdrValue() interface{} { return v } +func (v *PathPaymentStrictReceiveOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *PathPaymentStrictReceiveOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%ssendAsset", name), XDR_Asset(&v.SendAsset)) + x.Marshal(x.Sprintf("%ssendMax", name), XDR_Int64(&v.SendMax)) + x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(&v.Destination)) + x.Marshal(x.Sprintf("%sdestAsset", name), XDR_Asset(&v.DestAsset)) + x.Marshal(x.Sprintf("%sdestAmount", name), XDR_Int64(&v.DestAmount)) + x.Marshal(x.Sprintf("%spath", name), (*_XdrVec_5_Asset)(&v.Path)) } -func (v _XdrVec_unbounded_SorobanAuthorizationEntry) XdrValue() interface{} { - return ([]SorobanAuthorizationEntry)(v) +func XDR_PathPaymentStrictReceiveOp(v *PathPaymentStrictReceiveOp) *PathPaymentStrictReceiveOp { + return v } -func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) + +type XdrType_PathPaymentStrictSendOp = *PathPaymentStrictSendOp + +func (v *PathPaymentStrictSendOp) XdrPointer() interface{} { return v } +func (PathPaymentStrictSendOp) XdrTypeName() string { return "PathPaymentStrictSendOp" } +func (v PathPaymentStrictSendOp) XdrValue() interface{} { return v } +func (v *PathPaymentStrictSendOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *PathPaymentStrictSendOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%ssendAsset", name), XDR_Asset(&v.SendAsset)) + x.Marshal(x.Sprintf("%ssendAmount", name), XDR_Int64(&v.SendAmount)) + x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(&v.Destination)) + x.Marshal(x.Sprintf("%sdestAsset", name), XDR_Asset(&v.DestAsset)) + x.Marshal(x.Sprintf("%sdestMin", name), XDR_Int64(&v.DestMin)) + x.Marshal(x.Sprintf("%spath", name), (*_XdrVec_5_Asset)(&v.Path)) } +func XDR_PathPaymentStrictSendOp(v *PathPaymentStrictSendOp) *PathPaymentStrictSendOp { return v } -type XdrType_InvokeHostFunctionOp = *InvokeHostFunctionOp +type XdrType_ManageSellOfferOp = *ManageSellOfferOp -func (v *InvokeHostFunctionOp) XdrPointer() interface{} { return v } -func (InvokeHostFunctionOp) XdrTypeName() string { return "InvokeHostFunctionOp" } -func (v InvokeHostFunctionOp) XdrValue() interface{} { return v } -func (v *InvokeHostFunctionOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *InvokeHostFunctionOp) XdrRecurse(x XDR, name string) { +func (v *ManageSellOfferOp) XdrPointer() interface{} { return v } +func (ManageSellOfferOp) XdrTypeName() string { return "ManageSellOfferOp" } +func (v ManageSellOfferOp) XdrValue() interface{} { return v } +func (v *ManageSellOfferOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ManageSellOfferOp) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%shostFunction", name), XDR_HostFunction(&v.HostFunction)) - x.Marshal(x.Sprintf("%sauth", name), (*_XdrVec_unbounded_SorobanAuthorizationEntry)(&v.Auth)) + x.Marshal(x.Sprintf("%sselling", name), XDR_Asset(&v.Selling)) + x.Marshal(x.Sprintf("%sbuying", name), XDR_Asset(&v.Buying)) + x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) + x.Marshal(x.Sprintf("%sprice", name), XDR_Price(&v.Price)) + x.Marshal(x.Sprintf("%sofferID", name), XDR_Int64(&v.OfferID)) } -func XDR_InvokeHostFunctionOp(v *InvokeHostFunctionOp) *InvokeHostFunctionOp { return v } +func XDR_ManageSellOfferOp(v *ManageSellOfferOp) *ManageSellOfferOp { return v } -type XdrType_ExtendFootprintTTLOp = *ExtendFootprintTTLOp +type XdrType_ManageBuyOfferOp = *ManageBuyOfferOp -func (v *ExtendFootprintTTLOp) XdrPointer() interface{} { return v } -func (ExtendFootprintTTLOp) XdrTypeName() string { return "ExtendFootprintTTLOp" } -func (v ExtendFootprintTTLOp) XdrValue() interface{} { return v } -func (v *ExtendFootprintTTLOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ExtendFootprintTTLOp) XdrRecurse(x XDR, name string) { +func (v *ManageBuyOfferOp) XdrPointer() interface{} { return v } +func (ManageBuyOfferOp) XdrTypeName() string { return "ManageBuyOfferOp" } +func (v ManageBuyOfferOp) XdrValue() interface{} { return v } +func (v *ManageBuyOfferOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ManageBuyOfferOp) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) - x.Marshal(x.Sprintf("%sextendTo", name), XDR_Uint32(&v.ExtendTo)) + x.Marshal(x.Sprintf("%sselling", name), XDR_Asset(&v.Selling)) + x.Marshal(x.Sprintf("%sbuying", name), XDR_Asset(&v.Buying)) + x.Marshal(x.Sprintf("%sbuyAmount", name), XDR_Int64(&v.BuyAmount)) + x.Marshal(x.Sprintf("%sprice", name), XDR_Price(&v.Price)) + x.Marshal(x.Sprintf("%sofferID", name), XDR_Int64(&v.OfferID)) } -func XDR_ExtendFootprintTTLOp(v *ExtendFootprintTTLOp) *ExtendFootprintTTLOp { return v } +func XDR_ManageBuyOfferOp(v *ManageBuyOfferOp) *ManageBuyOfferOp { return v } -type XdrType_RestoreFootprintOp = *RestoreFootprintOp +type XdrType_CreatePassiveSellOfferOp = *CreatePassiveSellOfferOp -func (v *RestoreFootprintOp) XdrPointer() interface{} { return v } -func (RestoreFootprintOp) XdrTypeName() string { return "RestoreFootprintOp" } -func (v RestoreFootprintOp) XdrValue() interface{} { return v } -func (v *RestoreFootprintOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *RestoreFootprintOp) XdrRecurse(x XDR, name string) { +func (v *CreatePassiveSellOfferOp) XdrPointer() interface{} { return v } +func (CreatePassiveSellOfferOp) XdrTypeName() string { return "CreatePassiveSellOfferOp" } +func (v CreatePassiveSellOfferOp) XdrValue() interface{} { return v } +func (v *CreatePassiveSellOfferOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *CreatePassiveSellOfferOp) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) + x.Marshal(x.Sprintf("%sselling", name), XDR_Asset(&v.Selling)) + x.Marshal(x.Sprintf("%sbuying", name), XDR_Asset(&v.Buying)) + x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) + x.Marshal(x.Sprintf("%sprice", name), XDR_Price(&v.Price)) } -func XDR_RestoreFootprintOp(v *RestoreFootprintOp) *RestoreFootprintOp { return v } +func XDR_CreatePassiveSellOfferOp(v *CreatePassiveSellOfferOp) *CreatePassiveSellOfferOp { return v } -var _XdrTags_XdrAnon_Operation_Body = map[int32]bool{ - XdrToI32(CREATE_ACCOUNT): true, - XdrToI32(PAYMENT): true, - XdrToI32(PATH_PAYMENT_STRICT_RECEIVE): true, - XdrToI32(MANAGE_SELL_OFFER): true, - XdrToI32(CREATE_PASSIVE_SELL_OFFER): true, - XdrToI32(SET_OPTIONS): true, - XdrToI32(CHANGE_TRUST): true, - XdrToI32(ALLOW_TRUST): true, - XdrToI32(ACCOUNT_MERGE): true, - XdrToI32(INFLATION): true, - XdrToI32(MANAGE_DATA): true, - XdrToI32(BUMP_SEQUENCE): true, - XdrToI32(MANAGE_BUY_OFFER): true, - XdrToI32(PATH_PAYMENT_STRICT_SEND): true, - XdrToI32(CREATE_CLAIMABLE_BALANCE): true, - XdrToI32(CLAIM_CLAIMABLE_BALANCE): true, - XdrToI32(BEGIN_SPONSORING_FUTURE_RESERVES): true, - XdrToI32(END_SPONSORING_FUTURE_RESERVES): true, - XdrToI32(REVOKE_SPONSORSHIP): true, - XdrToI32(CLAWBACK): true, - XdrToI32(CLAWBACK_CLAIMABLE_BALANCE): true, - XdrToI32(SET_TRUST_LINE_FLAGS): true, - XdrToI32(LIQUIDITY_POOL_DEPOSIT): true, - XdrToI32(LIQUIDITY_POOL_WITHDRAW): true, - XdrToI32(INVOKE_HOST_FUNCTION): true, - XdrToI32(EXTEND_FOOTPRINT_TTL): true, - XdrToI32(RESTORE_FOOTPRINT): true, +type _XdrPtr_Uint32 struct { + p **Uint32 } +type _ptrflag_Uint32 _XdrPtr_Uint32 -func (_ XdrAnon_Operation_Body) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_Operation_Body +func (v _ptrflag_Uint32) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" } -func (u *XdrAnon_Operation_Body) CreateAccountOp() *CreateAccountOp { - switch u.Type { - case CREATE_ACCOUNT: - if v, ok := u._u.(*CreateAccountOp); ok { - return v - } else { - var zero CreateAccountOp - u._u = &zero - return &zero - } +func (v _ptrflag_Uint32) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) default: - XdrPanic("XdrAnon_Operation_Body.CreateAccountOp accessed when Type == %v", u.Type) - return nil + return XdrError("Uint32 flag should be \"nil\" or \"non-nil\"") } + return nil } -func (u *XdrAnon_Operation_Body) PaymentOp() *PaymentOp { - switch u.Type { - case PAYMENT: - if v, ok := u._u.(*PaymentOp); ok { - return v - } else { - var zero PaymentOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.PaymentOp accessed when Type == %v", u.Type) - return nil +func (v _ptrflag_Uint32) GetU32() uint32 { + if *v.p == nil { + return 0 } + return 1 } -func (u *XdrAnon_Operation_Body) PathPaymentStrictReceiveOp() *PathPaymentStrictReceiveOp { - switch u.Type { - case PATH_PAYMENT_STRICT_RECEIVE: - if v, ok := u._u.(*PathPaymentStrictReceiveOp); ok { - return v - } else { - var zero PathPaymentStrictReceiveOp - u._u = &zero - return &zero +func (v _ptrflag_Uint32) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(Uint32) } default: - XdrPanic("XdrAnon_Operation_Body.PathPaymentStrictReceiveOp accessed when Type == %v", u.Type) - return nil + XdrPanic("*Uint32 present flag value %d should be 0 or 1", nv) } } -func (u *XdrAnon_Operation_Body) ManageSellOfferOp() *ManageSellOfferOp { - switch u.Type { - case MANAGE_SELL_OFFER: - if v, ok := u._u.(*ManageSellOfferOp); ok { - return v - } else { - var zero ManageSellOfferOp - u._u = &zero - return &zero - } +func (_ptrflag_Uint32) XdrTypeName() string { return "Uint32?" } +func (v _ptrflag_Uint32) XdrPointer() interface{} { return nil } +func (v _ptrflag_Uint32) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_Uint32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_Uint32) XdrBound() uint32 { return 1 } +func (v _XdrPtr_Uint32) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_Uint32) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(Uint32) + } +} +func (v _XdrPtr_Uint32) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_Uint32(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_Uint32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_Uint32) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_Uint32(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_Uint32) XdrTypeName() string { return "Uint32*" } +func (v _XdrPtr_Uint32) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_Uint32) XdrValue() interface{} { return *v.p } + +type _XdrPtr_String32 struct { + p **String32 +} +type _ptrflag_String32 _XdrPtr_String32 + +func (v _ptrflag_String32) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" +} +func (v _ptrflag_String32) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) default: - XdrPanic("XdrAnon_Operation_Body.ManageSellOfferOp accessed when Type == %v", u.Type) - return nil + return XdrError("String32 flag should be \"nil\" or \"non-nil\"") } + return nil } -func (u *XdrAnon_Operation_Body) CreatePassiveSellOfferOp() *CreatePassiveSellOfferOp { - switch u.Type { - case CREATE_PASSIVE_SELL_OFFER: - if v, ok := u._u.(*CreatePassiveSellOfferOp); ok { - return v - } else { - var zero CreatePassiveSellOfferOp - u._u = &zero - return &zero +func (v _ptrflag_String32) GetU32() uint32 { + if *v.p == nil { + return 0 + } + return 1 +} +func (v _ptrflag_String32) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(String32) } default: - XdrPanic("XdrAnon_Operation_Body.CreatePassiveSellOfferOp accessed when Type == %v", u.Type) - return nil + XdrPanic("*String32 present flag value %d should be 0 or 1", nv) } } -func (u *XdrAnon_Operation_Body) SetOptionsOp() *SetOptionsOp { - switch u.Type { - case SET_OPTIONS: - if v, ok := u._u.(*SetOptionsOp); ok { - return v - } else { - var zero SetOptionsOp - u._u = &zero - return &zero +func (_ptrflag_String32) XdrTypeName() string { return "String32?" } +func (v _ptrflag_String32) XdrPointer() interface{} { return nil } +func (v _ptrflag_String32) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_String32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_String32) XdrBound() uint32 { return 1 } +func (v _XdrPtr_String32) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_String32) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(String32) + } +} +func (v _XdrPtr_String32) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_String32(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_String32) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_String32) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_String32(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_String32) XdrTypeName() string { return "String32*" } +func (v _XdrPtr_String32) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_String32) XdrValue() interface{} { return *v.p } + +type _XdrPtr_Signer struct { + p **Signer +} +type _ptrflag_Signer _XdrPtr_Signer + +func (v _ptrflag_Signer) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" +} +func (v _ptrflag_Signer) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) + default: + return XdrError("Signer flag should be \"nil\" or \"non-nil\"") + } + return nil +} +func (v _ptrflag_Signer) GetU32() uint32 { + if *v.p == nil { + return 0 + } + return 1 +} +func (v _ptrflag_Signer) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(Signer) } default: - XdrPanic("XdrAnon_Operation_Body.SetOptionsOp accessed when Type == %v", u.Type) - return nil + XdrPanic("*Signer present flag value %d should be 0 or 1", nv) } } -func (u *XdrAnon_Operation_Body) ChangeTrustOp() *ChangeTrustOp { +func (_ptrflag_Signer) XdrTypeName() string { return "Signer?" } +func (v _ptrflag_Signer) XdrPointer() interface{} { return nil } +func (v _ptrflag_Signer) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_Signer) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_Signer) XdrBound() uint32 { return 1 } +func (v _XdrPtr_Signer) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_Signer) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(Signer) + } +} +func (v _XdrPtr_Signer) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_Signer(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_Signer) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_Signer) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_Signer(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_Signer) XdrTypeName() string { return "Signer*" } +func (v _XdrPtr_Signer) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_Signer) XdrValue() interface{} { return *v.p } + +type XdrType_SetOptionsOp = *SetOptionsOp + +func (v *SetOptionsOp) XdrPointer() interface{} { return v } +func (SetOptionsOp) XdrTypeName() string { return "SetOptionsOp" } +func (v SetOptionsOp) XdrValue() interface{} { return v } +func (v *SetOptionsOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SetOptionsOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sinflationDest", name), _XdrPtr_AccountID{&v.InflationDest}) + x.Marshal(x.Sprintf("%sclearFlags", name), _XdrPtr_Uint32{&v.ClearFlags}) + x.Marshal(x.Sprintf("%ssetFlags", name), _XdrPtr_Uint32{&v.SetFlags}) + x.Marshal(x.Sprintf("%smasterWeight", name), _XdrPtr_Uint32{&v.MasterWeight}) + x.Marshal(x.Sprintf("%slowThreshold", name), _XdrPtr_Uint32{&v.LowThreshold}) + x.Marshal(x.Sprintf("%smedThreshold", name), _XdrPtr_Uint32{&v.MedThreshold}) + x.Marshal(x.Sprintf("%shighThreshold", name), _XdrPtr_Uint32{&v.HighThreshold}) + x.Marshal(x.Sprintf("%shomeDomain", name), _XdrPtr_String32{&v.HomeDomain}) + x.Marshal(x.Sprintf("%ssigner", name), _XdrPtr_Signer{&v.Signer}) +} +func XDR_SetOptionsOp(v *SetOptionsOp) *SetOptionsOp { return v } + +var _XdrTags_ChangeTrustAsset = map[int32]bool{ + XdrToI32(ASSET_TYPE_NATIVE): true, + XdrToI32(ASSET_TYPE_CREDIT_ALPHANUM4): true, + XdrToI32(ASSET_TYPE_CREDIT_ALPHANUM12): true, + XdrToI32(ASSET_TYPE_POOL_SHARE): true, +} + +func (_ ChangeTrustAsset) XdrValidTags() map[int32]bool { + return _XdrTags_ChangeTrustAsset +} +func (u *ChangeTrustAsset) AlphaNum4() *AlphaNum4 { switch u.Type { - case CHANGE_TRUST: - if v, ok := u._u.(*ChangeTrustOp); ok { + case ASSET_TYPE_CREDIT_ALPHANUM4: + if v, ok := u._u.(*AlphaNum4); ok { return v } else { - var zero ChangeTrustOp + var zero AlphaNum4 u._u = &zero return &zero } default: - XdrPanic("XdrAnon_Operation_Body.ChangeTrustOp accessed when Type == %v", u.Type) + XdrPanic("ChangeTrustAsset.AlphaNum4 accessed when Type == %v", u.Type) return nil } } -func (u *XdrAnon_Operation_Body) AllowTrustOp() *AllowTrustOp { +func (u *ChangeTrustAsset) AlphaNum12() *AlphaNum12 { switch u.Type { - case ALLOW_TRUST: - if v, ok := u._u.(*AllowTrustOp); ok { + case ASSET_TYPE_CREDIT_ALPHANUM12: + if v, ok := u._u.(*AlphaNum12); ok { return v } else { - var zero AllowTrustOp + var zero AlphaNum12 u._u = &zero return &zero } default: - XdrPanic("XdrAnon_Operation_Body.AllowTrustOp accessed when Type == %v", u.Type) + XdrPanic("ChangeTrustAsset.AlphaNum12 accessed when Type == %v", u.Type) return nil } } -func (u *XdrAnon_Operation_Body) Destination() *MuxedAccount { +func (u *ChangeTrustAsset) LiquidityPool() *LiquidityPoolParameters { switch u.Type { - case ACCOUNT_MERGE: - if v, ok := u._u.(*MuxedAccount); ok { + case ASSET_TYPE_POOL_SHARE: + if v, ok := u._u.(*LiquidityPoolParameters); ok { return v } else { - var zero MuxedAccount + var zero LiquidityPoolParameters u._u = &zero return &zero } default: - XdrPanic("XdrAnon_Operation_Body.Destination accessed when Type == %v", u.Type) + XdrPanic("ChangeTrustAsset.LiquidityPool accessed when Type == %v", u.Type) return nil } } -func (u *XdrAnon_Operation_Body) ManageDataOp() *ManageDataOp { +func (u ChangeTrustAsset) XdrValid() bool { switch u.Type { - case MANAGE_DATA: - if v, ok := u._u.(*ManageDataOp); ok { - return v - } else { - var zero ManageDataOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.ManageDataOp accessed when Type == %v", u.Type) - return nil + case ASSET_TYPE_NATIVE, ASSET_TYPE_CREDIT_ALPHANUM4, ASSET_TYPE_CREDIT_ALPHANUM12, ASSET_TYPE_POOL_SHARE: + return true } + return false } -func (u *XdrAnon_Operation_Body) BumpSequenceOp() *BumpSequenceOp { - switch u.Type { - case BUMP_SEQUENCE: - if v, ok := u._u.(*BumpSequenceOp); ok { - return v - } else { - var zero BumpSequenceOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.BumpSequenceOp accessed when Type == %v", u.Type) - return nil - } +func (u *ChangeTrustAsset) XdrUnionTag() XdrNum32 { + return XDR_AssetType(&u.Type) } -func (u *XdrAnon_Operation_Body) ManageBuyOfferOp() *ManageBuyOfferOp { +func (u *ChangeTrustAsset) XdrUnionTagName() string { + return "Type" +} +func (u *ChangeTrustAsset) XdrUnionBody() XdrType { switch u.Type { - case MANAGE_BUY_OFFER: - if v, ok := u._u.(*ManageBuyOfferOp); ok { - return v - } else { - var zero ManageBuyOfferOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.ManageBuyOfferOp accessed when Type == %v", u.Type) + case ASSET_TYPE_NATIVE: return nil + case ASSET_TYPE_CREDIT_ALPHANUM4: + return XDR_AlphaNum4(u.AlphaNum4()) + case ASSET_TYPE_CREDIT_ALPHANUM12: + return XDR_AlphaNum12(u.AlphaNum12()) + case ASSET_TYPE_POOL_SHARE: + return XDR_LiquidityPoolParameters(u.LiquidityPool()) } + return nil } -func (u *XdrAnon_Operation_Body) PathPaymentStrictSendOp() *PathPaymentStrictSendOp { +func (u *ChangeTrustAsset) XdrUnionBodyName() string { switch u.Type { - case PATH_PAYMENT_STRICT_SEND: - if v, ok := u._u.(*PathPaymentStrictSendOp); ok { - return v - } else { - var zero PathPaymentStrictSendOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.PathPaymentStrictSendOp accessed when Type == %v", u.Type) - return nil + case ASSET_TYPE_NATIVE: + return "" + case ASSET_TYPE_CREDIT_ALPHANUM4: + return "AlphaNum4" + case ASSET_TYPE_CREDIT_ALPHANUM12: + return "AlphaNum12" + case ASSET_TYPE_POOL_SHARE: + return "LiquidityPool" } + return "" } -func (u *XdrAnon_Operation_Body) CreateClaimableBalanceOp() *CreateClaimableBalanceOp { + +type XdrType_ChangeTrustAsset = *ChangeTrustAsset + +func (v *ChangeTrustAsset) XdrPointer() interface{} { return v } +func (ChangeTrustAsset) XdrTypeName() string { return "ChangeTrustAsset" } +func (v ChangeTrustAsset) XdrValue() interface{} { return v } +func (v *ChangeTrustAsset) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *ChangeTrustAsset) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_AssetType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case CREATE_CLAIMABLE_BALANCE: - if v, ok := u._u.(*CreateClaimableBalanceOp); ok { - return v - } else { - var zero CreateClaimableBalanceOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.CreateClaimableBalanceOp accessed when Type == %v", u.Type) - return nil + case ASSET_TYPE_NATIVE: + return + case ASSET_TYPE_CREDIT_ALPHANUM4: + x.Marshal(x.Sprintf("%salphaNum4", name), XDR_AlphaNum4(u.AlphaNum4())) + return + case ASSET_TYPE_CREDIT_ALPHANUM12: + x.Marshal(x.Sprintf("%salphaNum12", name), XDR_AlphaNum12(u.AlphaNum12())) + return + case ASSET_TYPE_POOL_SHARE: + x.Marshal(x.Sprintf("%sliquidityPool", name), XDR_LiquidityPoolParameters(u.LiquidityPool())) + return } + XdrPanic("invalid Type (%v) in ChangeTrustAsset", u.Type) } -func (u *XdrAnon_Operation_Body) ClaimClaimableBalanceOp() *ClaimClaimableBalanceOp { - switch u.Type { - case CLAIM_CLAIMABLE_BALANCE: - if v, ok := u._u.(*ClaimClaimableBalanceOp); ok { - return v - } else { - var zero ClaimClaimableBalanceOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.ClaimClaimableBalanceOp accessed when Type == %v", u.Type) - return nil +func XDR_ChangeTrustAsset(v *ChangeTrustAsset) *ChangeTrustAsset { return v } + +type XdrType_ChangeTrustOp = *ChangeTrustOp + +func (v *ChangeTrustOp) XdrPointer() interface{} { return v } +func (ChangeTrustOp) XdrTypeName() string { return "ChangeTrustOp" } +func (v ChangeTrustOp) XdrValue() interface{} { return v } +func (v *ChangeTrustOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ChangeTrustOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%sline", name), XDR_ChangeTrustAsset(&v.Line)) + x.Marshal(x.Sprintf("%slimit", name), XDR_Int64(&v.Limit)) } -func (u *XdrAnon_Operation_Body) BeginSponsoringFutureReservesOp() *BeginSponsoringFutureReservesOp { - switch u.Type { - case BEGIN_SPONSORING_FUTURE_RESERVES: - if v, ok := u._u.(*BeginSponsoringFutureReservesOp); ok { - return v - } else { - var zero BeginSponsoringFutureReservesOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.BeginSponsoringFutureReservesOp accessed when Type == %v", u.Type) - return nil +func XDR_ChangeTrustOp(v *ChangeTrustOp) *ChangeTrustOp { return v } + +type XdrType_AllowTrustOp = *AllowTrustOp + +func (v *AllowTrustOp) XdrPointer() interface{} { return v } +func (AllowTrustOp) XdrTypeName() string { return "AllowTrustOp" } +func (v AllowTrustOp) XdrValue() interface{} { return v } +func (v *AllowTrustOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *AllowTrustOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%strustor", name), XDR_AccountID(&v.Trustor)) + x.Marshal(x.Sprintf("%sasset", name), XDR_AssetCode(&v.Asset)) + x.Marshal(x.Sprintf("%sauthorize", name), XDR_Uint32(&v.Authorize)) } -func (u *XdrAnon_Operation_Body) RevokeSponsorshipOp() *RevokeSponsorshipOp { - switch u.Type { - case REVOKE_SPONSORSHIP: - if v, ok := u._u.(*RevokeSponsorshipOp); ok { - return v - } else { - var zero RevokeSponsorshipOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.RevokeSponsorshipOp accessed when Type == %v", u.Type) - return nil +func XDR_AllowTrustOp(v *AllowTrustOp) *AllowTrustOp { return v } + +type _XdrPtr_DataValue struct { + p **DataValue +} +type _ptrflag_DataValue _XdrPtr_DataValue + +func (v _ptrflag_DataValue) String() string { + if *v.p == nil { + return "nil" } + return "non-nil" } -func (u *XdrAnon_Operation_Body) ClawbackOp() *ClawbackOp { - switch u.Type { - case CLAWBACK: - if v, ok := u._u.(*ClawbackOp); ok { - return v - } else { - var zero ClawbackOp - u._u = &zero - return &zero - } +func (v _ptrflag_DataValue) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) default: - XdrPanic("XdrAnon_Operation_Body.ClawbackOp accessed when Type == %v", u.Type) - return nil + return XdrError("DataValue flag should be \"nil\" or \"non-nil\"") } + return nil } -func (u *XdrAnon_Operation_Body) ClawbackClaimableBalanceOp() *ClawbackClaimableBalanceOp { - switch u.Type { - case CLAWBACK_CLAIMABLE_BALANCE: - if v, ok := u._u.(*ClawbackClaimableBalanceOp); ok { - return v - } else { - var zero ClawbackClaimableBalanceOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.ClawbackClaimableBalanceOp accessed when Type == %v", u.Type) - return nil +func (v _ptrflag_DataValue) GetU32() uint32 { + if *v.p == nil { + return 0 } + return 1 } -func (u *XdrAnon_Operation_Body) SetTrustLineFlagsOp() *SetTrustLineFlagsOp { - switch u.Type { - case SET_TRUST_LINE_FLAGS: - if v, ok := u._u.(*SetTrustLineFlagsOp); ok { - return v - } else { - var zero SetTrustLineFlagsOp - u._u = &zero - return &zero +func (v _ptrflag_DataValue) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(DataValue) } default: - XdrPanic("XdrAnon_Operation_Body.SetTrustLineFlagsOp accessed when Type == %v", u.Type) - return nil + XdrPanic("*DataValue present flag value %d should be 0 or 1", nv) } } -func (u *XdrAnon_Operation_Body) LiquidityPoolDepositOp() *LiquidityPoolDepositOp { - switch u.Type { - case LIQUIDITY_POOL_DEPOSIT: - if v, ok := u._u.(*LiquidityPoolDepositOp); ok { - return v - } else { - var zero LiquidityPoolDepositOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.LiquidityPoolDepositOp accessed when Type == %v", u.Type) - return nil +func (_ptrflag_DataValue) XdrTypeName() string { return "DataValue?" } +func (v _ptrflag_DataValue) XdrPointer() interface{} { return nil } +func (v _ptrflag_DataValue) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_DataValue) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_DataValue) XdrBound() uint32 { return 1 } +func (v _XdrPtr_DataValue) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_DataValue) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(DataValue) } } -func (u *XdrAnon_Operation_Body) LiquidityPoolWithdrawOp() *LiquidityPoolWithdrawOp { - switch u.Type { - case LIQUIDITY_POOL_WITHDRAW: - if v, ok := u._u.(*LiquidityPoolWithdrawOp); ok { - return v - } else { - var zero LiquidityPoolWithdrawOp - u._u = &zero - return &zero - } - default: - XdrPanic("XdrAnon_Operation_Body.LiquidityPoolWithdrawOp accessed when Type == %v", u.Type) - return nil +func (v _XdrPtr_DataValue) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_DataValue(*v.p).XdrMarshal(x, name) } } -func (u *XdrAnon_Operation_Body) InvokeHostFunctionOp() *InvokeHostFunctionOp { - switch u.Type { - case INVOKE_HOST_FUNCTION: - if v, ok := u._u.(*InvokeHostFunctionOp); ok { - return v - } else { - var zero InvokeHostFunctionOp - u._u = &zero - return &zero +func (v _XdrPtr_DataValue) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_DataValue) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_DataValue(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_DataValue) XdrTypeName() string { return "DataValue*" } +func (v _XdrPtr_DataValue) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_DataValue) XdrValue() interface{} { return *v.p } + +type XdrType_ManageDataOp = *ManageDataOp + +func (v *ManageDataOp) XdrPointer() interface{} { return v } +func (ManageDataOp) XdrTypeName() string { return "ManageDataOp" } +func (v ManageDataOp) XdrValue() interface{} { return v } +func (v *ManageDataOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ManageDataOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sdataName", name), XDR_String64(&v.DataName)) + x.Marshal(x.Sprintf("%sdataValue", name), _XdrPtr_DataValue{&v.DataValue}) +} +func XDR_ManageDataOp(v *ManageDataOp) *ManageDataOp { return v } + +type XdrType_BumpSequenceOp = *BumpSequenceOp + +func (v *BumpSequenceOp) XdrPointer() interface{} { return v } +func (BumpSequenceOp) XdrTypeName() string { return "BumpSequenceOp" } +func (v BumpSequenceOp) XdrValue() interface{} { return v } +func (v *BumpSequenceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *BumpSequenceOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sbumpTo", name), XDR_SequenceNumber(&v.BumpTo)) +} +func XDR_BumpSequenceOp(v *BumpSequenceOp) *BumpSequenceOp { return v } + +type XdrType_CreateClaimableBalanceOp = *CreateClaimableBalanceOp + +func (v *CreateClaimableBalanceOp) XdrPointer() interface{} { return v } +func (CreateClaimableBalanceOp) XdrTypeName() string { return "CreateClaimableBalanceOp" } +func (v CreateClaimableBalanceOp) XdrValue() interface{} { return v } +func (v *CreateClaimableBalanceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *CreateClaimableBalanceOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) + x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) + x.Marshal(x.Sprintf("%sclaimants", name), (*_XdrVec_10_Claimant)(&v.Claimants)) +} +func XDR_CreateClaimableBalanceOp(v *CreateClaimableBalanceOp) *CreateClaimableBalanceOp { return v } + +type XdrType_ClaimClaimableBalanceOp = *ClaimClaimableBalanceOp + +func (v *ClaimClaimableBalanceOp) XdrPointer() interface{} { return v } +func (ClaimClaimableBalanceOp) XdrTypeName() string { return "ClaimClaimableBalanceOp" } +func (v ClaimClaimableBalanceOp) XdrValue() interface{} { return v } +func (v *ClaimClaimableBalanceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ClaimClaimableBalanceOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sbalanceID", name), XDR_ClaimableBalanceID(&v.BalanceID)) +} +func XDR_ClaimClaimableBalanceOp(v *ClaimClaimableBalanceOp) *ClaimClaimableBalanceOp { return v } + +type XdrType_BeginSponsoringFutureReservesOp = *BeginSponsoringFutureReservesOp + +func (v *BeginSponsoringFutureReservesOp) XdrPointer() interface{} { return v } +func (BeginSponsoringFutureReservesOp) XdrTypeName() string { return "BeginSponsoringFutureReservesOp" } +func (v BeginSponsoringFutureReservesOp) XdrValue() interface{} { return v } +func (v *BeginSponsoringFutureReservesOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *BeginSponsoringFutureReservesOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%ssponsoredID", name), XDR_AccountID(&v.SponsoredID)) +} +func XDR_BeginSponsoringFutureReservesOp(v *BeginSponsoringFutureReservesOp) *BeginSponsoringFutureReservesOp { + return v +} + +var _XdrNames_RevokeSponsorshipType = map[int32]string{ + int32(REVOKE_SPONSORSHIP_LEDGER_ENTRY): "REVOKE_SPONSORSHIP_LEDGER_ENTRY", + int32(REVOKE_SPONSORSHIP_SIGNER): "REVOKE_SPONSORSHIP_SIGNER", +} +var _XdrValues_RevokeSponsorshipType = map[string]int32{ + "REVOKE_SPONSORSHIP_LEDGER_ENTRY": int32(REVOKE_SPONSORSHIP_LEDGER_ENTRY), + "REVOKE_SPONSORSHIP_SIGNER": int32(REVOKE_SPONSORSHIP_SIGNER), +} + +func (RevokeSponsorshipType) XdrEnumNames() map[int32]string { + return _XdrNames_RevokeSponsorshipType +} +func (v RevokeSponsorshipType) String() string { + if s, ok := _XdrNames_RevokeSponsorshipType[int32(v)]; ok { + return s + } + return fmt.Sprintf("RevokeSponsorshipType#%d", v) +} +func (v *RevokeSponsorshipType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_RevokeSponsorshipType[stok]; ok { + *v = RevokeSponsorshipType(val) + return nil + } else if stok == "RevokeSponsorshipType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - default: - XdrPanic("XdrAnon_Operation_Body.InvokeHostFunctionOp accessed when Type == %v", u.Type) - return nil + return XdrError(fmt.Sprintf("%s is not a valid RevokeSponsorshipType.", stok)) } } -func (u *XdrAnon_Operation_Body) ExtendFootprintTTLOp() *ExtendFootprintTTLOp { +func (v RevokeSponsorshipType) GetU32() uint32 { return uint32(v) } +func (v *RevokeSponsorshipType) SetU32(n uint32) { *v = RevokeSponsorshipType(n) } +func (v *RevokeSponsorshipType) XdrPointer() interface{} { return v } +func (RevokeSponsorshipType) XdrTypeName() string { return "RevokeSponsorshipType" } +func (v RevokeSponsorshipType) XdrValue() interface{} { return v } +func (v *RevokeSponsorshipType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_RevokeSponsorshipType = *RevokeSponsorshipType + +func XDR_RevokeSponsorshipType(v *RevokeSponsorshipType) *RevokeSponsorshipType { return v } + +type XdrType_XdrAnon_RevokeSponsorshipOp_Signer = *XdrAnon_RevokeSponsorshipOp_Signer + +func (v *XdrAnon_RevokeSponsorshipOp_Signer) XdrPointer() interface{} { return v } +func (XdrAnon_RevokeSponsorshipOp_Signer) XdrTypeName() string { + return "XdrAnon_RevokeSponsorshipOp_Signer" +} +func (v XdrAnon_RevokeSponsorshipOp_Signer) XdrValue() interface{} { return v } +func (v *XdrAnon_RevokeSponsorshipOp_Signer) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_RevokeSponsorshipOp_Signer) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%saccountID", name), XDR_AccountID(&v.AccountID)) + x.Marshal(x.Sprintf("%ssignerKey", name), XDR_SignerKey(&v.SignerKey)) +} +func XDR_XdrAnon_RevokeSponsorshipOp_Signer(v *XdrAnon_RevokeSponsorshipOp_Signer) *XdrAnon_RevokeSponsorshipOp_Signer { + return v +} + +var _XdrTags_RevokeSponsorshipOp = map[int32]bool{ + XdrToI32(REVOKE_SPONSORSHIP_LEDGER_ENTRY): true, + XdrToI32(REVOKE_SPONSORSHIP_SIGNER): true, +} + +func (_ RevokeSponsorshipOp) XdrValidTags() map[int32]bool { + return _XdrTags_RevokeSponsorshipOp +} +func (u *RevokeSponsorshipOp) LedgerKey() *LedgerKey { switch u.Type { - case EXTEND_FOOTPRINT_TTL: - if v, ok := u._u.(*ExtendFootprintTTLOp); ok { + case REVOKE_SPONSORSHIP_LEDGER_ENTRY: + if v, ok := u._u.(*LedgerKey); ok { return v } else { - var zero ExtendFootprintTTLOp + var zero LedgerKey u._u = &zero return &zero } default: - XdrPanic("XdrAnon_Operation_Body.ExtendFootprintTTLOp accessed when Type == %v", u.Type) + XdrPanic("RevokeSponsorshipOp.LedgerKey accessed when Type == %v", u.Type) return nil } } -func (u *XdrAnon_Operation_Body) RestoreFootprintOp() *RestoreFootprintOp { +func (u *RevokeSponsorshipOp) Signer() *XdrAnon_RevokeSponsorshipOp_Signer { switch u.Type { - case RESTORE_FOOTPRINT: - if v, ok := u._u.(*RestoreFootprintOp); ok { + case REVOKE_SPONSORSHIP_SIGNER: + if v, ok := u._u.(*XdrAnon_RevokeSponsorshipOp_Signer); ok { return v } else { - var zero RestoreFootprintOp + var zero XdrAnon_RevokeSponsorshipOp_Signer u._u = &zero return &zero } default: - XdrPanic("XdrAnon_Operation_Body.RestoreFootprintOp accessed when Type == %v", u.Type) + XdrPanic("RevokeSponsorshipOp.Signer accessed when Type == %v", u.Type) return nil } } -func (u XdrAnon_Operation_Body) XdrValid() bool { +func (u RevokeSponsorshipOp) XdrValid() bool { switch u.Type { - case CREATE_ACCOUNT, PAYMENT, PATH_PAYMENT_STRICT_RECEIVE, MANAGE_SELL_OFFER, CREATE_PASSIVE_SELL_OFFER, SET_OPTIONS, CHANGE_TRUST, ALLOW_TRUST, ACCOUNT_MERGE, INFLATION, MANAGE_DATA, BUMP_SEQUENCE, MANAGE_BUY_OFFER, PATH_PAYMENT_STRICT_SEND, CREATE_CLAIMABLE_BALANCE, CLAIM_CLAIMABLE_BALANCE, BEGIN_SPONSORING_FUTURE_RESERVES, END_SPONSORING_FUTURE_RESERVES, REVOKE_SPONSORSHIP, CLAWBACK, CLAWBACK_CLAIMABLE_BALANCE, SET_TRUST_LINE_FLAGS, LIQUIDITY_POOL_DEPOSIT, LIQUIDITY_POOL_WITHDRAW, INVOKE_HOST_FUNCTION, EXTEND_FOOTPRINT_TTL, RESTORE_FOOTPRINT: + case REVOKE_SPONSORSHIP_LEDGER_ENTRY, REVOKE_SPONSORSHIP_SIGNER: return true } return false } -func (u *XdrAnon_Operation_Body) XdrUnionTag() XdrNum32 { - return XDR_OperationType(&u.Type) +func (u *RevokeSponsorshipOp) XdrUnionTag() XdrNum32 { + return XDR_RevokeSponsorshipType(&u.Type) } -func (u *XdrAnon_Operation_Body) XdrUnionTagName() string { +func (u *RevokeSponsorshipOp) XdrUnionTagName() string { return "Type" } -func (u *XdrAnon_Operation_Body) XdrUnionBody() XdrType { +func (u *RevokeSponsorshipOp) XdrUnionBody() XdrType { switch u.Type { - case CREATE_ACCOUNT: - return XDR_CreateAccountOp(u.CreateAccountOp()) - case PAYMENT: - return XDR_PaymentOp(u.PaymentOp()) - case PATH_PAYMENT_STRICT_RECEIVE: - return XDR_PathPaymentStrictReceiveOp(u.PathPaymentStrictReceiveOp()) - case MANAGE_SELL_OFFER: - return XDR_ManageSellOfferOp(u.ManageSellOfferOp()) - case CREATE_PASSIVE_SELL_OFFER: - return XDR_CreatePassiveSellOfferOp(u.CreatePassiveSellOfferOp()) - case SET_OPTIONS: - return XDR_SetOptionsOp(u.SetOptionsOp()) - case CHANGE_TRUST: - return XDR_ChangeTrustOp(u.ChangeTrustOp()) - case ALLOW_TRUST: - return XDR_AllowTrustOp(u.AllowTrustOp()) - case ACCOUNT_MERGE: - return XDR_MuxedAccount(u.Destination()) - case INFLATION: - return nil - case MANAGE_DATA: - return XDR_ManageDataOp(u.ManageDataOp()) - case BUMP_SEQUENCE: - return XDR_BumpSequenceOp(u.BumpSequenceOp()) - case MANAGE_BUY_OFFER: - return XDR_ManageBuyOfferOp(u.ManageBuyOfferOp()) - case PATH_PAYMENT_STRICT_SEND: - return XDR_PathPaymentStrictSendOp(u.PathPaymentStrictSendOp()) - case CREATE_CLAIMABLE_BALANCE: - return XDR_CreateClaimableBalanceOp(u.CreateClaimableBalanceOp()) - case CLAIM_CLAIMABLE_BALANCE: - return XDR_ClaimClaimableBalanceOp(u.ClaimClaimableBalanceOp()) - case BEGIN_SPONSORING_FUTURE_RESERVES: - return XDR_BeginSponsoringFutureReservesOp(u.BeginSponsoringFutureReservesOp()) - case END_SPONSORING_FUTURE_RESERVES: - return nil - case REVOKE_SPONSORSHIP: - return XDR_RevokeSponsorshipOp(u.RevokeSponsorshipOp()) - case CLAWBACK: - return XDR_ClawbackOp(u.ClawbackOp()) - case CLAWBACK_CLAIMABLE_BALANCE: - return XDR_ClawbackClaimableBalanceOp(u.ClawbackClaimableBalanceOp()) - case SET_TRUST_LINE_FLAGS: - return XDR_SetTrustLineFlagsOp(u.SetTrustLineFlagsOp()) - case LIQUIDITY_POOL_DEPOSIT: - return XDR_LiquidityPoolDepositOp(u.LiquidityPoolDepositOp()) - case LIQUIDITY_POOL_WITHDRAW: - return XDR_LiquidityPoolWithdrawOp(u.LiquidityPoolWithdrawOp()) - case INVOKE_HOST_FUNCTION: - return XDR_InvokeHostFunctionOp(u.InvokeHostFunctionOp()) - case EXTEND_FOOTPRINT_TTL: - return XDR_ExtendFootprintTTLOp(u.ExtendFootprintTTLOp()) - case RESTORE_FOOTPRINT: - return XDR_RestoreFootprintOp(u.RestoreFootprintOp()) + case REVOKE_SPONSORSHIP_LEDGER_ENTRY: + return XDR_LedgerKey(u.LedgerKey()) + case REVOKE_SPONSORSHIP_SIGNER: + return XDR_XdrAnon_RevokeSponsorshipOp_Signer(u.Signer()) } return nil } -func (u *XdrAnon_Operation_Body) XdrUnionBodyName() string { +func (u *RevokeSponsorshipOp) XdrUnionBodyName() string { switch u.Type { - case CREATE_ACCOUNT: - return "CreateAccountOp" - case PAYMENT: - return "PaymentOp" - case PATH_PAYMENT_STRICT_RECEIVE: - return "PathPaymentStrictReceiveOp" - case MANAGE_SELL_OFFER: - return "ManageSellOfferOp" - case CREATE_PASSIVE_SELL_OFFER: - return "CreatePassiveSellOfferOp" - case SET_OPTIONS: - return "SetOptionsOp" - case CHANGE_TRUST: - return "ChangeTrustOp" - case ALLOW_TRUST: - return "AllowTrustOp" - case ACCOUNT_MERGE: - return "Destination" - case INFLATION: - return "" - case MANAGE_DATA: - return "ManageDataOp" - case BUMP_SEQUENCE: - return "BumpSequenceOp" - case MANAGE_BUY_OFFER: - return "ManageBuyOfferOp" - case PATH_PAYMENT_STRICT_SEND: - return "PathPaymentStrictSendOp" - case CREATE_CLAIMABLE_BALANCE: - return "CreateClaimableBalanceOp" - case CLAIM_CLAIMABLE_BALANCE: - return "ClaimClaimableBalanceOp" - case BEGIN_SPONSORING_FUTURE_RESERVES: - return "BeginSponsoringFutureReservesOp" - case END_SPONSORING_FUTURE_RESERVES: - return "" - case REVOKE_SPONSORSHIP: - return "RevokeSponsorshipOp" - case CLAWBACK: - return "ClawbackOp" - case CLAWBACK_CLAIMABLE_BALANCE: - return "ClawbackClaimableBalanceOp" - case SET_TRUST_LINE_FLAGS: - return "SetTrustLineFlagsOp" - case LIQUIDITY_POOL_DEPOSIT: - return "LiquidityPoolDepositOp" - case LIQUIDITY_POOL_WITHDRAW: - return "LiquidityPoolWithdrawOp" - case INVOKE_HOST_FUNCTION: - return "InvokeHostFunctionOp" - case EXTEND_FOOTPRINT_TTL: - return "ExtendFootprintTTLOp" - case RESTORE_FOOTPRINT: - return "RestoreFootprintOp" + case REVOKE_SPONSORSHIP_LEDGER_ENTRY: + return "LedgerKey" + case REVOKE_SPONSORSHIP_SIGNER: + return "Signer" } return "" } -type XdrType_XdrAnon_Operation_Body = *XdrAnon_Operation_Body +type XdrType_RevokeSponsorshipOp = *RevokeSponsorshipOp -func (v *XdrAnon_Operation_Body) XdrPointer() interface{} { return v } -func (XdrAnon_Operation_Body) XdrTypeName() string { return "XdrAnon_Operation_Body" } -func (v XdrAnon_Operation_Body) XdrValue() interface{} { return v } -func (v *XdrAnon_Operation_Body) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *XdrAnon_Operation_Body) XdrRecurse(x XDR, name string) { +func (v *RevokeSponsorshipOp) XdrPointer() interface{} { return v } +func (RevokeSponsorshipOp) XdrTypeName() string { return "RevokeSponsorshipOp" } +func (v RevokeSponsorshipOp) XdrValue() interface{} { return v } +func (v *RevokeSponsorshipOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *RevokeSponsorshipOp) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_OperationType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + XDR_RevokeSponsorshipType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case CREATE_ACCOUNT: - x.Marshal(x.Sprintf("%screateAccountOp", name), XDR_CreateAccountOp(u.CreateAccountOp())) - return - case PAYMENT: - x.Marshal(x.Sprintf("%spaymentOp", name), XDR_PaymentOp(u.PaymentOp())) - return - case PATH_PAYMENT_STRICT_RECEIVE: - x.Marshal(x.Sprintf("%spathPaymentStrictReceiveOp", name), XDR_PathPaymentStrictReceiveOp(u.PathPaymentStrictReceiveOp())) - return - case MANAGE_SELL_OFFER: - x.Marshal(x.Sprintf("%smanageSellOfferOp", name), XDR_ManageSellOfferOp(u.ManageSellOfferOp())) - return - case CREATE_PASSIVE_SELL_OFFER: - x.Marshal(x.Sprintf("%screatePassiveSellOfferOp", name), XDR_CreatePassiveSellOfferOp(u.CreatePassiveSellOfferOp())) - return - case SET_OPTIONS: - x.Marshal(x.Sprintf("%ssetOptionsOp", name), XDR_SetOptionsOp(u.SetOptionsOp())) - return - case CHANGE_TRUST: - x.Marshal(x.Sprintf("%schangeTrustOp", name), XDR_ChangeTrustOp(u.ChangeTrustOp())) - return - case ALLOW_TRUST: - x.Marshal(x.Sprintf("%sallowTrustOp", name), XDR_AllowTrustOp(u.AllowTrustOp())) - return - case ACCOUNT_MERGE: - x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(u.Destination())) - return - case INFLATION: - return - case MANAGE_DATA: - x.Marshal(x.Sprintf("%smanageDataOp", name), XDR_ManageDataOp(u.ManageDataOp())) - return - case BUMP_SEQUENCE: - x.Marshal(x.Sprintf("%sbumpSequenceOp", name), XDR_BumpSequenceOp(u.BumpSequenceOp())) - return - case MANAGE_BUY_OFFER: - x.Marshal(x.Sprintf("%smanageBuyOfferOp", name), XDR_ManageBuyOfferOp(u.ManageBuyOfferOp())) - return - case PATH_PAYMENT_STRICT_SEND: - x.Marshal(x.Sprintf("%spathPaymentStrictSendOp", name), XDR_PathPaymentStrictSendOp(u.PathPaymentStrictSendOp())) - return - case CREATE_CLAIMABLE_BALANCE: - x.Marshal(x.Sprintf("%screateClaimableBalanceOp", name), XDR_CreateClaimableBalanceOp(u.CreateClaimableBalanceOp())) - return - case CLAIM_CLAIMABLE_BALANCE: - x.Marshal(x.Sprintf("%sclaimClaimableBalanceOp", name), XDR_ClaimClaimableBalanceOp(u.ClaimClaimableBalanceOp())) - return - case BEGIN_SPONSORING_FUTURE_RESERVES: - x.Marshal(x.Sprintf("%sbeginSponsoringFutureReservesOp", name), XDR_BeginSponsoringFutureReservesOp(u.BeginSponsoringFutureReservesOp())) - return - case END_SPONSORING_FUTURE_RESERVES: - return - case REVOKE_SPONSORSHIP: - x.Marshal(x.Sprintf("%srevokeSponsorshipOp", name), XDR_RevokeSponsorshipOp(u.RevokeSponsorshipOp())) - return - case CLAWBACK: - x.Marshal(x.Sprintf("%sclawbackOp", name), XDR_ClawbackOp(u.ClawbackOp())) - return - case CLAWBACK_CLAIMABLE_BALANCE: - x.Marshal(x.Sprintf("%sclawbackClaimableBalanceOp", name), XDR_ClawbackClaimableBalanceOp(u.ClawbackClaimableBalanceOp())) - return - case SET_TRUST_LINE_FLAGS: - x.Marshal(x.Sprintf("%ssetTrustLineFlagsOp", name), XDR_SetTrustLineFlagsOp(u.SetTrustLineFlagsOp())) - return - case LIQUIDITY_POOL_DEPOSIT: - x.Marshal(x.Sprintf("%sliquidityPoolDepositOp", name), XDR_LiquidityPoolDepositOp(u.LiquidityPoolDepositOp())) - return - case LIQUIDITY_POOL_WITHDRAW: - x.Marshal(x.Sprintf("%sliquidityPoolWithdrawOp", name), XDR_LiquidityPoolWithdrawOp(u.LiquidityPoolWithdrawOp())) - return - case INVOKE_HOST_FUNCTION: - x.Marshal(x.Sprintf("%sinvokeHostFunctionOp", name), XDR_InvokeHostFunctionOp(u.InvokeHostFunctionOp())) - return - case EXTEND_FOOTPRINT_TTL: - x.Marshal(x.Sprintf("%sextendFootprintTTLOp", name), XDR_ExtendFootprintTTLOp(u.ExtendFootprintTTLOp())) + case REVOKE_SPONSORSHIP_LEDGER_ENTRY: + x.Marshal(x.Sprintf("%sledgerKey", name), XDR_LedgerKey(u.LedgerKey())) return - case RESTORE_FOOTPRINT: - x.Marshal(x.Sprintf("%srestoreFootprintOp", name), XDR_RestoreFootprintOp(u.RestoreFootprintOp())) + case REVOKE_SPONSORSHIP_SIGNER: + x.Marshal(x.Sprintf("%ssigner", name), XDR_XdrAnon_RevokeSponsorshipOp_Signer(u.Signer())) return } - XdrPanic("invalid Type (%v) in XdrAnon_Operation_Body", u.Type) + XdrPanic("invalid Type (%v) in RevokeSponsorshipOp", u.Type) } -func XDR_XdrAnon_Operation_Body(v *XdrAnon_Operation_Body) *XdrAnon_Operation_Body { return v } +func XDR_RevokeSponsorshipOp(v *RevokeSponsorshipOp) *RevokeSponsorshipOp { return v } -type _XdrPtr_MuxedAccount struct { - p **MuxedAccount +type XdrType_ClawbackOp = *ClawbackOp + +func (v *ClawbackOp) XdrPointer() interface{} { return v } +func (ClawbackOp) XdrTypeName() string { return "ClawbackOp" } +func (v ClawbackOp) XdrValue() interface{} { return v } +func (v *ClawbackOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ClawbackOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) + x.Marshal(x.Sprintf("%sfrom", name), XDR_MuxedAccount(&v.From)) + x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) +} +func XDR_ClawbackOp(v *ClawbackOp) *ClawbackOp { return v } + +type XdrType_ClawbackClaimableBalanceOp = *ClawbackClaimableBalanceOp + +func (v *ClawbackClaimableBalanceOp) XdrPointer() interface{} { return v } +func (ClawbackClaimableBalanceOp) XdrTypeName() string { return "ClawbackClaimableBalanceOp" } +func (v ClawbackClaimableBalanceOp) XdrValue() interface{} { return v } +func (v *ClawbackClaimableBalanceOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ClawbackClaimableBalanceOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sbalanceID", name), XDR_ClaimableBalanceID(&v.BalanceID)) +} +func XDR_ClawbackClaimableBalanceOp(v *ClawbackClaimableBalanceOp) *ClawbackClaimableBalanceOp { + return v +} + +type XdrType_SetTrustLineFlagsOp = *SetTrustLineFlagsOp + +func (v *SetTrustLineFlagsOp) XdrPointer() interface{} { return v } +func (SetTrustLineFlagsOp) XdrTypeName() string { return "SetTrustLineFlagsOp" } +func (v SetTrustLineFlagsOp) XdrValue() interface{} { return v } +func (v *SetTrustLineFlagsOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SetTrustLineFlagsOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%strustor", name), XDR_AccountID(&v.Trustor)) + x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) + x.Marshal(x.Sprintf("%sclearFlags", name), XDR_Uint32(&v.ClearFlags)) + x.Marshal(x.Sprintf("%ssetFlags", name), XDR_Uint32(&v.SetFlags)) +} +func XDR_SetTrustLineFlagsOp(v *SetTrustLineFlagsOp) *SetTrustLineFlagsOp { return v } + +type XdrType_LiquidityPoolDepositOp = *LiquidityPoolDepositOp + +func (v *LiquidityPoolDepositOp) XdrPointer() interface{} { return v } +func (LiquidityPoolDepositOp) XdrTypeName() string { return "LiquidityPoolDepositOp" } +func (v LiquidityPoolDepositOp) XdrValue() interface{} { return v } +func (v *LiquidityPoolDepositOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LiquidityPoolDepositOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sliquidityPoolID", name), XDR_PoolID(&v.LiquidityPoolID)) + x.Marshal(x.Sprintf("%smaxAmountA", name), XDR_Int64(&v.MaxAmountA)) + x.Marshal(x.Sprintf("%smaxAmountB", name), XDR_Int64(&v.MaxAmountB)) + x.Marshal(x.Sprintf("%sminPrice", name), XDR_Price(&v.MinPrice)) + x.Marshal(x.Sprintf("%smaxPrice", name), XDR_Price(&v.MaxPrice)) +} +func XDR_LiquidityPoolDepositOp(v *LiquidityPoolDepositOp) *LiquidityPoolDepositOp { return v } + +type XdrType_LiquidityPoolWithdrawOp = *LiquidityPoolWithdrawOp + +func (v *LiquidityPoolWithdrawOp) XdrPointer() interface{} { return v } +func (LiquidityPoolWithdrawOp) XdrTypeName() string { return "LiquidityPoolWithdrawOp" } +func (v LiquidityPoolWithdrawOp) XdrValue() interface{} { return v } +func (v *LiquidityPoolWithdrawOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LiquidityPoolWithdrawOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sliquidityPoolID", name), XDR_PoolID(&v.LiquidityPoolID)) + x.Marshal(x.Sprintf("%samount", name), XDR_Int64(&v.Amount)) + x.Marshal(x.Sprintf("%sminAmountA", name), XDR_Int64(&v.MinAmountA)) + x.Marshal(x.Sprintf("%sminAmountB", name), XDR_Int64(&v.MinAmountB)) +} +func XDR_LiquidityPoolWithdrawOp(v *LiquidityPoolWithdrawOp) *LiquidityPoolWithdrawOp { return v } + +var _XdrNames_HostFunctionType = map[int32]string{ + int32(HOST_FUNCTION_TYPE_INVOKE_CONTRACT): "HOST_FUNCTION_TYPE_INVOKE_CONTRACT", + int32(HOST_FUNCTION_TYPE_CREATE_CONTRACT): "HOST_FUNCTION_TYPE_CREATE_CONTRACT", + int32(HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM): "HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM", + int32(HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2): "HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2", +} +var _XdrValues_HostFunctionType = map[string]int32{ + "HOST_FUNCTION_TYPE_INVOKE_CONTRACT": int32(HOST_FUNCTION_TYPE_INVOKE_CONTRACT), + "HOST_FUNCTION_TYPE_CREATE_CONTRACT": int32(HOST_FUNCTION_TYPE_CREATE_CONTRACT), + "HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM": int32(HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM), + "HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2": int32(HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2), +} + +func (HostFunctionType) XdrEnumNames() map[int32]string { + return _XdrNames_HostFunctionType +} +func (v HostFunctionType) String() string { + if s, ok := _XdrNames_HostFunctionType[int32(v)]; ok { + return s + } + return fmt.Sprintf("HostFunctionType#%d", v) +} +func (v *HostFunctionType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_HostFunctionType[stok]; ok { + *v = HostFunctionType(val) + return nil + } else if stok == "HostFunctionType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid HostFunctionType.", stok)) + } +} +func (v HostFunctionType) GetU32() uint32 { return uint32(v) } +func (v *HostFunctionType) SetU32(n uint32) { *v = HostFunctionType(n) } +func (v *HostFunctionType) XdrPointer() interface{} { return v } +func (HostFunctionType) XdrTypeName() string { return "HostFunctionType" } +func (v HostFunctionType) XdrValue() interface{} { return v } +func (v *HostFunctionType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_HostFunctionType = *HostFunctionType + +func XDR_HostFunctionType(v *HostFunctionType) *HostFunctionType { return v } + +var _XdrNames_ContractIDPreimageType = map[int32]string{ + int32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS): "CONTRACT_ID_PREIMAGE_FROM_ADDRESS", + int32(CONTRACT_ID_PREIMAGE_FROM_ASSET): "CONTRACT_ID_PREIMAGE_FROM_ASSET", +} +var _XdrValues_ContractIDPreimageType = map[string]int32{ + "CONTRACT_ID_PREIMAGE_FROM_ADDRESS": int32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS), + "CONTRACT_ID_PREIMAGE_FROM_ASSET": int32(CONTRACT_ID_PREIMAGE_FROM_ASSET), +} + +func (ContractIDPreimageType) XdrEnumNames() map[int32]string { + return _XdrNames_ContractIDPreimageType +} +func (v ContractIDPreimageType) String() string { + if s, ok := _XdrNames_ContractIDPreimageType[int32(v)]; ok { + return s + } + return fmt.Sprintf("ContractIDPreimageType#%d", v) +} +func (v *ContractIDPreimageType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_ContractIDPreimageType[stok]; ok { + *v = ContractIDPreimageType(val) + return nil + } else if stok == "ContractIDPreimageType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid ContractIDPreimageType.", stok)) + } +} +func (v ContractIDPreimageType) GetU32() uint32 { return uint32(v) } +func (v *ContractIDPreimageType) SetU32(n uint32) { *v = ContractIDPreimageType(n) } +func (v *ContractIDPreimageType) XdrPointer() interface{} { return v } +func (ContractIDPreimageType) XdrTypeName() string { return "ContractIDPreimageType" } +func (v ContractIDPreimageType) XdrValue() interface{} { return v } +func (v *ContractIDPreimageType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_ContractIDPreimageType = *ContractIDPreimageType + +func XDR_ContractIDPreimageType(v *ContractIDPreimageType) *ContractIDPreimageType { return v } + +type XdrType_XdrAnon_ContractIDPreimage_FromAddress = *XdrAnon_ContractIDPreimage_FromAddress + +func (v *XdrAnon_ContractIDPreimage_FromAddress) XdrPointer() interface{} { return v } +func (XdrAnon_ContractIDPreimage_FromAddress) XdrTypeName() string { + return "XdrAnon_ContractIDPreimage_FromAddress" +} +func (v XdrAnon_ContractIDPreimage_FromAddress) XdrValue() interface{} { return v } +func (v *XdrAnon_ContractIDPreimage_FromAddress) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_ContractIDPreimage_FromAddress) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%saddress", name), XDR_SCAddress(&v.Address)) + x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(&v.Salt)) +} +func XDR_XdrAnon_ContractIDPreimage_FromAddress(v *XdrAnon_ContractIDPreimage_FromAddress) *XdrAnon_ContractIDPreimage_FromAddress { + return v +} + +var _XdrTags_ContractIDPreimage = map[int32]bool{ + XdrToI32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS): true, + XdrToI32(CONTRACT_ID_PREIMAGE_FROM_ASSET): true, +} + +func (_ ContractIDPreimage) XdrValidTags() map[int32]bool { + return _XdrTags_ContractIDPreimage +} +func (u *ContractIDPreimage) FromAddress() *XdrAnon_ContractIDPreimage_FromAddress { + switch u.Type { + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + if v, ok := u._u.(*XdrAnon_ContractIDPreimage_FromAddress); ok { + return v + } else { + var zero XdrAnon_ContractIDPreimage_FromAddress + u._u = &zero + return &zero + } + default: + XdrPanic("ContractIDPreimage.FromAddress accessed when Type == %v", u.Type) + return nil + } +} +func (u *ContractIDPreimage) FromAsset() *Asset { + switch u.Type { + case CONTRACT_ID_PREIMAGE_FROM_ASSET: + if v, ok := u._u.(*Asset); ok { + return v + } else { + var zero Asset + u._u = &zero + return &zero + } + default: + XdrPanic("ContractIDPreimage.FromAsset accessed when Type == %v", u.Type) + return nil + } +} +func (u ContractIDPreimage) XdrValid() bool { + switch u.Type { + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS, CONTRACT_ID_PREIMAGE_FROM_ASSET: + return true + } + return false +} +func (u *ContractIDPreimage) XdrUnionTag() XdrNum32 { + return XDR_ContractIDPreimageType(&u.Type) +} +func (u *ContractIDPreimage) XdrUnionTagName() string { + return "Type" +} +func (u *ContractIDPreimage) XdrUnionBody() XdrType { + switch u.Type { + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + return XDR_XdrAnon_ContractIDPreimage_FromAddress(u.FromAddress()) + case CONTRACT_ID_PREIMAGE_FROM_ASSET: + return XDR_Asset(u.FromAsset()) + } + return nil +} +func (u *ContractIDPreimage) XdrUnionBodyName() string { + switch u.Type { + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + return "FromAddress" + case CONTRACT_ID_PREIMAGE_FROM_ASSET: + return "FromAsset" + } + return "" +} + +type XdrType_ContractIDPreimage = *ContractIDPreimage + +func (v *ContractIDPreimage) XdrPointer() interface{} { return v } +func (ContractIDPreimage) XdrTypeName() string { return "ContractIDPreimage" } +func (v ContractIDPreimage) XdrValue() interface{} { return v } +func (v *ContractIDPreimage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *ContractIDPreimage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_ContractIDPreimageType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + x.Marshal(x.Sprintf("%sfromAddress", name), XDR_XdrAnon_ContractIDPreimage_FromAddress(u.FromAddress())) + return + case CONTRACT_ID_PREIMAGE_FROM_ASSET: + x.Marshal(x.Sprintf("%sfromAsset", name), XDR_Asset(u.FromAsset())) + return + } + XdrPanic("invalid Type (%v) in ContractIDPreimage", u.Type) +} +func XDR_ContractIDPreimage(v *ContractIDPreimage) *ContractIDPreimage { return v } + +type XdrType_CreateContractArgs = *CreateContractArgs + +func (v *CreateContractArgs) XdrPointer() interface{} { return v } +func (CreateContractArgs) XdrTypeName() string { return "CreateContractArgs" } +func (v CreateContractArgs) XdrValue() interface{} { return v } +func (v *CreateContractArgs) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *CreateContractArgs) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%scontractIDPreimage", name), XDR_ContractIDPreimage(&v.ContractIDPreimage)) + x.Marshal(x.Sprintf("%sexecutable", name), XDR_ContractExecutable(&v.Executable)) +} +func XDR_CreateContractArgs(v *CreateContractArgs) *CreateContractArgs { return v } + +type XdrType_CreateContractArgsV2 = *CreateContractArgsV2 + +func (v *CreateContractArgsV2) XdrPointer() interface{} { return v } +func (CreateContractArgsV2) XdrTypeName() string { return "CreateContractArgsV2" } +func (v CreateContractArgsV2) XdrValue() interface{} { return v } +func (v *CreateContractArgsV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *CreateContractArgsV2) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%scontractIDPreimage", name), XDR_ContractIDPreimage(&v.ContractIDPreimage)) + x.Marshal(x.Sprintf("%sexecutable", name), XDR_ContractExecutable(&v.Executable)) + x.Marshal(x.Sprintf("%sconstructorArgs", name), (*_XdrVec_unbounded_SCVal)(&v.ConstructorArgs)) +} +func XDR_CreateContractArgsV2(v *CreateContractArgsV2) *CreateContractArgsV2 { return v } + +type XdrType_InvokeContractArgs = *InvokeContractArgs + +func (v *InvokeContractArgs) XdrPointer() interface{} { return v } +func (InvokeContractArgs) XdrTypeName() string { return "InvokeContractArgs" } +func (v InvokeContractArgs) XdrValue() interface{} { return v } +func (v *InvokeContractArgs) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *InvokeContractArgs) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%scontractAddress", name), XDR_SCAddress(&v.ContractAddress)) + x.Marshal(x.Sprintf("%sfunctionName", name), XDR_SCSymbol(&v.FunctionName)) + x.Marshal(x.Sprintf("%sargs", name), (*_XdrVec_unbounded_SCVal)(&v.Args)) +} +func XDR_InvokeContractArgs(v *InvokeContractArgs) *InvokeContractArgs { return v } + +var _XdrTags_HostFunction = map[int32]bool{ + XdrToI32(HOST_FUNCTION_TYPE_INVOKE_CONTRACT): true, + XdrToI32(HOST_FUNCTION_TYPE_CREATE_CONTRACT): true, + XdrToI32(HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM): true, + XdrToI32(HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2): true, +} + +func (_ HostFunction) XdrValidTags() map[int32]bool { + return _XdrTags_HostFunction +} +func (u *HostFunction) InvokeContract() *InvokeContractArgs { + switch u.Type { + case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: + if v, ok := u._u.(*InvokeContractArgs); ok { + return v + } else { + var zero InvokeContractArgs + u._u = &zero + return &zero + } + default: + XdrPanic("HostFunction.InvokeContract accessed when Type == %v", u.Type) + return nil + } +} +func (u *HostFunction) CreateContract() *CreateContractArgs { + switch u.Type { + case HOST_FUNCTION_TYPE_CREATE_CONTRACT: + if v, ok := u._u.(*CreateContractArgs); ok { + return v + } else { + var zero CreateContractArgs + u._u = &zero + return &zero + } + default: + XdrPanic("HostFunction.CreateContract accessed when Type == %v", u.Type) + return nil + } +} +func (u *HostFunction) Wasm() *[]byte { + switch u.Type { + case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: + if v, ok := u._u.(*[]byte); ok { + return v + } else { + var zero []byte + u._u = &zero + return &zero + } + default: + XdrPanic("HostFunction.Wasm accessed when Type == %v", u.Type) + return nil + } +} +func (u *HostFunction) CreateContractV2() *CreateContractArgsV2 { + switch u.Type { + case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + if v, ok := u._u.(*CreateContractArgsV2); ok { + return v + } else { + var zero CreateContractArgsV2 + u._u = &zero + return &zero + } + default: + XdrPanic("HostFunction.CreateContractV2 accessed when Type == %v", u.Type) + return nil + } +} +func (u HostFunction) XdrValid() bool { + switch u.Type { + case HOST_FUNCTION_TYPE_INVOKE_CONTRACT, HOST_FUNCTION_TYPE_CREATE_CONTRACT, HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM, HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + return true + } + return false +} +func (u *HostFunction) XdrUnionTag() XdrNum32 { + return XDR_HostFunctionType(&u.Type) +} +func (u *HostFunction) XdrUnionTagName() string { + return "Type" +} +func (u *HostFunction) XdrUnionBody() XdrType { + switch u.Type { + case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: + return XDR_InvokeContractArgs(u.InvokeContract()) + case HOST_FUNCTION_TYPE_CREATE_CONTRACT: + return XDR_CreateContractArgs(u.CreateContract()) + case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: + return XdrVecOpaque{u.Wasm(), 0xffffffff} + case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + return XDR_CreateContractArgsV2(u.CreateContractV2()) + } + return nil +} +func (u *HostFunction) XdrUnionBodyName() string { + switch u.Type { + case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: + return "InvokeContract" + case HOST_FUNCTION_TYPE_CREATE_CONTRACT: + return "CreateContract" + case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: + return "Wasm" + case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + return "CreateContractV2" + } + return "" +} + +type XdrType_HostFunction = *HostFunction + +func (v *HostFunction) XdrPointer() interface{} { return v } +func (HostFunction) XdrTypeName() string { return "HostFunction" } +func (v HostFunction) XdrValue() interface{} { return v } +func (v *HostFunction) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *HostFunction) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_HostFunctionType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: + x.Marshal(x.Sprintf("%sinvokeContract", name), XDR_InvokeContractArgs(u.InvokeContract())) + return + case HOST_FUNCTION_TYPE_CREATE_CONTRACT: + x.Marshal(x.Sprintf("%screateContract", name), XDR_CreateContractArgs(u.CreateContract())) + return + case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: + x.Marshal(x.Sprintf("%swasm", name), XdrVecOpaque{u.Wasm(), 0xffffffff}) + return + case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + x.Marshal(x.Sprintf("%screateContractV2", name), XDR_CreateContractArgsV2(u.CreateContractV2())) + return + } + XdrPanic("invalid Type (%v) in HostFunction", u.Type) +} +func XDR_HostFunction(v *HostFunction) *HostFunction { return v } + +var _XdrNames_SorobanAuthorizedFunctionType = map[int32]string{ + int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN): "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN", + int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN): "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN", + int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN): "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN", +} +var _XdrValues_SorobanAuthorizedFunctionType = map[string]int32{ + "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN": int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN), + "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN": int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN), + "SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN": int32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN), +} + +func (SorobanAuthorizedFunctionType) XdrEnumNames() map[int32]string { + return _XdrNames_SorobanAuthorizedFunctionType +} +func (v SorobanAuthorizedFunctionType) String() string { + if s, ok := _XdrNames_SorobanAuthorizedFunctionType[int32(v)]; ok { + return s + } + return fmt.Sprintf("SorobanAuthorizedFunctionType#%d", v) +} +func (v *SorobanAuthorizedFunctionType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_SorobanAuthorizedFunctionType[stok]; ok { + *v = SorobanAuthorizedFunctionType(val) + return nil + } else if stok == "SorobanAuthorizedFunctionType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid SorobanAuthorizedFunctionType.", stok)) + } +} +func (v SorobanAuthorizedFunctionType) GetU32() uint32 { return uint32(v) } +func (v *SorobanAuthorizedFunctionType) SetU32(n uint32) { *v = SorobanAuthorizedFunctionType(n) } +func (v *SorobanAuthorizedFunctionType) XdrPointer() interface{} { return v } +func (SorobanAuthorizedFunctionType) XdrTypeName() string { return "SorobanAuthorizedFunctionType" } +func (v SorobanAuthorizedFunctionType) XdrValue() interface{} { return v } +func (v *SorobanAuthorizedFunctionType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_SorobanAuthorizedFunctionType = *SorobanAuthorizedFunctionType + +func XDR_SorobanAuthorizedFunctionType(v *SorobanAuthorizedFunctionType) *SorobanAuthorizedFunctionType { + return v +} + +var _XdrTags_SorobanAuthorizedFunction = map[int32]bool{ + XdrToI32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN): true, + XdrToI32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN): true, + XdrToI32(SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN): true, +} + +func (_ SorobanAuthorizedFunction) XdrValidTags() map[int32]bool { + return _XdrTags_SorobanAuthorizedFunction +} +func (u *SorobanAuthorizedFunction) ContractFn() *InvokeContractArgs { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: + if v, ok := u._u.(*InvokeContractArgs); ok { + return v + } else { + var zero InvokeContractArgs + u._u = &zero + return &zero + } + default: + XdrPanic("SorobanAuthorizedFunction.ContractFn accessed when Type == %v", u.Type) + return nil + } +} +func (u *SorobanAuthorizedFunction) CreateContractHostFn() *CreateContractArgs { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + if v, ok := u._u.(*CreateContractArgs); ok { + return v + } else { + var zero CreateContractArgs + u._u = &zero + return &zero + } + default: + XdrPanic("SorobanAuthorizedFunction.CreateContractHostFn accessed when Type == %v", u.Type) + return nil + } +} +func (u *SorobanAuthorizedFunction) CreateContractV2HostFn() *CreateContractArgsV2 { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + if v, ok := u._u.(*CreateContractArgsV2); ok { + return v + } else { + var zero CreateContractArgsV2 + u._u = &zero + return &zero + } + default: + XdrPanic("SorobanAuthorizedFunction.CreateContractV2HostFn accessed when Type == %v", u.Type) + return nil + } +} +func (u SorobanAuthorizedFunction) XdrValid() bool { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN, SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN, SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + return true + } + return false +} +func (u *SorobanAuthorizedFunction) XdrUnionTag() XdrNum32 { + return XDR_SorobanAuthorizedFunctionType(&u.Type) +} +func (u *SorobanAuthorizedFunction) XdrUnionTagName() string { + return "Type" +} +func (u *SorobanAuthorizedFunction) XdrUnionBody() XdrType { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: + return XDR_InvokeContractArgs(u.ContractFn()) + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + return XDR_CreateContractArgs(u.CreateContractHostFn()) + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + return XDR_CreateContractArgsV2(u.CreateContractV2HostFn()) + } + return nil +} +func (u *SorobanAuthorizedFunction) XdrUnionBodyName() string { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: + return "ContractFn" + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + return "CreateContractHostFn" + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + return "CreateContractV2HostFn" + } + return "" +} + +type XdrType_SorobanAuthorizedFunction = *SorobanAuthorizedFunction + +func (v *SorobanAuthorizedFunction) XdrPointer() interface{} { return v } +func (SorobanAuthorizedFunction) XdrTypeName() string { return "SorobanAuthorizedFunction" } +func (v SorobanAuthorizedFunction) XdrValue() interface{} { return v } +func (v *SorobanAuthorizedFunction) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *SorobanAuthorizedFunction) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_SorobanAuthorizedFunctionType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: + x.Marshal(x.Sprintf("%scontractFn", name), XDR_InvokeContractArgs(u.ContractFn())) + return + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + x.Marshal(x.Sprintf("%screateContractHostFn", name), XDR_CreateContractArgs(u.CreateContractHostFn())) + return + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + x.Marshal(x.Sprintf("%screateContractV2HostFn", name), XDR_CreateContractArgsV2(u.CreateContractV2HostFn())) + return + } + XdrPanic("invalid Type (%v) in SorobanAuthorizedFunction", u.Type) +} +func XDR_SorobanAuthorizedFunction(v *SorobanAuthorizedFunction) *SorobanAuthorizedFunction { return v } + +type _XdrVec_unbounded_SorobanAuthorizedInvocation []SorobanAuthorizedInvocation + +func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound +} +func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_SorobanAuthorizedInvocation length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_SorobanAuthorizedInvocation length %d exceeds max int", length) + } +} +func (v _XdrVec_unbounded_SorobanAuthorizedInvocation) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return + } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]SorobanAuthorizedInvocation, int(length), newcap) + copy(nv, *v) + *v = nv +} +func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_SorobanAuthorizedInvocation(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] + } +} +func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrTypeName() string { + return "SorobanAuthorizedInvocation<>" +} +func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrPointer() interface{} { + return (*[]SorobanAuthorizedInvocation)(v) +} +func (v _XdrVec_unbounded_SorobanAuthorizedInvocation) XdrValue() interface{} { + return ([]SorobanAuthorizedInvocation)(v) +} +func (v *_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrMarshal(x XDR, name string) { + x.Marshal(name, v) +} + +type XdrType_SorobanAuthorizedInvocation = *SorobanAuthorizedInvocation + +func (v *SorobanAuthorizedInvocation) XdrPointer() interface{} { return v } +func (SorobanAuthorizedInvocation) XdrTypeName() string { return "SorobanAuthorizedInvocation" } +func (v SorobanAuthorizedInvocation) XdrValue() interface{} { return v } +func (v *SorobanAuthorizedInvocation) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SorobanAuthorizedInvocation) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sfunction", name), XDR_SorobanAuthorizedFunction(&v.Function)) + x.Marshal(x.Sprintf("%ssubInvocations", name), (*_XdrVec_unbounded_SorobanAuthorizedInvocation)(&v.SubInvocations)) +} +func XDR_SorobanAuthorizedInvocation(v *SorobanAuthorizedInvocation) *SorobanAuthorizedInvocation { + return v +} + +type XdrType_SorobanAddressCredentials = *SorobanAddressCredentials + +func (v *SorobanAddressCredentials) XdrPointer() interface{} { return v } +func (SorobanAddressCredentials) XdrTypeName() string { return "SorobanAddressCredentials" } +func (v SorobanAddressCredentials) XdrValue() interface{} { return v } +func (v *SorobanAddressCredentials) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SorobanAddressCredentials) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%saddress", name), XDR_SCAddress(&v.Address)) + x.Marshal(x.Sprintf("%snonce", name), XDR_Int64(&v.Nonce)) + x.Marshal(x.Sprintf("%ssignatureExpirationLedger", name), XDR_Uint32(&v.SignatureExpirationLedger)) + x.Marshal(x.Sprintf("%ssignature", name), XDR_SCVal(&v.Signature)) +} +func XDR_SorobanAddressCredentials(v *SorobanAddressCredentials) *SorobanAddressCredentials { return v } + +var _XdrNames_SorobanCredentialsType = map[int32]string{ + int32(SOROBAN_CREDENTIALS_SOURCE_ACCOUNT): "SOROBAN_CREDENTIALS_SOURCE_ACCOUNT", + int32(SOROBAN_CREDENTIALS_ADDRESS): "SOROBAN_CREDENTIALS_ADDRESS", +} +var _XdrValues_SorobanCredentialsType = map[string]int32{ + "SOROBAN_CREDENTIALS_SOURCE_ACCOUNT": int32(SOROBAN_CREDENTIALS_SOURCE_ACCOUNT), + "SOROBAN_CREDENTIALS_ADDRESS": int32(SOROBAN_CREDENTIALS_ADDRESS), +} + +func (SorobanCredentialsType) XdrEnumNames() map[int32]string { + return _XdrNames_SorobanCredentialsType +} +func (v SorobanCredentialsType) String() string { + if s, ok := _XdrNames_SorobanCredentialsType[int32(v)]; ok { + return s + } + return fmt.Sprintf("SorobanCredentialsType#%d", v) +} +func (v *SorobanCredentialsType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_SorobanCredentialsType[stok]; ok { + *v = SorobanCredentialsType(val) + return nil + } else if stok == "SorobanCredentialsType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid SorobanCredentialsType.", stok)) + } +} +func (v SorobanCredentialsType) GetU32() uint32 { return uint32(v) } +func (v *SorobanCredentialsType) SetU32(n uint32) { *v = SorobanCredentialsType(n) } +func (v *SorobanCredentialsType) XdrPointer() interface{} { return v } +func (SorobanCredentialsType) XdrTypeName() string { return "SorobanCredentialsType" } +func (v SorobanCredentialsType) XdrValue() interface{} { return v } +func (v *SorobanCredentialsType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_SorobanCredentialsType = *SorobanCredentialsType + +func XDR_SorobanCredentialsType(v *SorobanCredentialsType) *SorobanCredentialsType { return v } + +var _XdrTags_SorobanCredentials = map[int32]bool{ + XdrToI32(SOROBAN_CREDENTIALS_SOURCE_ACCOUNT): true, + XdrToI32(SOROBAN_CREDENTIALS_ADDRESS): true, +} + +func (_ SorobanCredentials) XdrValidTags() map[int32]bool { + return _XdrTags_SorobanCredentials +} +func (u *SorobanCredentials) Address() *SorobanAddressCredentials { + switch u.Type { + case SOROBAN_CREDENTIALS_ADDRESS: + if v, ok := u._u.(*SorobanAddressCredentials); ok { + return v + } else { + var zero SorobanAddressCredentials + u._u = &zero + return &zero + } + default: + XdrPanic("SorobanCredentials.Address accessed when Type == %v", u.Type) + return nil + } +} +func (u SorobanCredentials) XdrValid() bool { + switch u.Type { + case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT, SOROBAN_CREDENTIALS_ADDRESS: + return true + } + return false +} +func (u *SorobanCredentials) XdrUnionTag() XdrNum32 { + return XDR_SorobanCredentialsType(&u.Type) +} +func (u *SorobanCredentials) XdrUnionTagName() string { + return "Type" +} +func (u *SorobanCredentials) XdrUnionBody() XdrType { + switch u.Type { + case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: + return nil + case SOROBAN_CREDENTIALS_ADDRESS: + return XDR_SorobanAddressCredentials(u.Address()) + } + return nil +} +func (u *SorobanCredentials) XdrUnionBodyName() string { + switch u.Type { + case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: + return "" + case SOROBAN_CREDENTIALS_ADDRESS: + return "Address" + } + return "" +} + +type XdrType_SorobanCredentials = *SorobanCredentials + +func (v *SorobanCredentials) XdrPointer() interface{} { return v } +func (SorobanCredentials) XdrTypeName() string { return "SorobanCredentials" } +func (v SorobanCredentials) XdrValue() interface{} { return v } +func (v *SorobanCredentials) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *SorobanCredentials) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_SorobanCredentialsType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: + return + case SOROBAN_CREDENTIALS_ADDRESS: + x.Marshal(x.Sprintf("%saddress", name), XDR_SorobanAddressCredentials(u.Address())) + return + } + XdrPanic("invalid Type (%v) in SorobanCredentials", u.Type) +} +func XDR_SorobanCredentials(v *SorobanCredentials) *SorobanCredentials { return v } + +type XdrType_SorobanAuthorizationEntry = *SorobanAuthorizationEntry + +func (v *SorobanAuthorizationEntry) XdrPointer() interface{} { return v } +func (SorobanAuthorizationEntry) XdrTypeName() string { return "SorobanAuthorizationEntry" } +func (v SorobanAuthorizationEntry) XdrValue() interface{} { return v } +func (v *SorobanAuthorizationEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SorobanAuthorizationEntry) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%scredentials", name), XDR_SorobanCredentials(&v.Credentials)) + x.Marshal(x.Sprintf("%srootInvocation", name), XDR_SorobanAuthorizedInvocation(&v.RootInvocation)) +} +func XDR_SorobanAuthorizationEntry(v *SorobanAuthorizationEntry) *SorobanAuthorizationEntry { return v } + +type _XdrVec_unbounded_SorobanAuthorizationEntry []SorobanAuthorizationEntry + +func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound +} +func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_SorobanAuthorizationEntry length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_SorobanAuthorizationEntry length %d exceeds max int", length) + } +} +func (v _XdrVec_unbounded_SorobanAuthorizationEntry) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return + } + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) + } + nv := make([]SorobanAuthorizationEntry, int(length), newcap) + copy(nv, *v) + *v = nv +} +func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_SorobanAuthorizationEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] + } +} +func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrTypeName() string { + return "SorobanAuthorizationEntry<>" +} +func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrPointer() interface{} { + return (*[]SorobanAuthorizationEntry)(v) +} +func (v _XdrVec_unbounded_SorobanAuthorizationEntry) XdrValue() interface{} { + return ([]SorobanAuthorizationEntry)(v) +} +func (v *_XdrVec_unbounded_SorobanAuthorizationEntry) XdrMarshal(x XDR, name string) { + x.Marshal(name, v) +} + +type XdrType_InvokeHostFunctionOp = *InvokeHostFunctionOp + +func (v *InvokeHostFunctionOp) XdrPointer() interface{} { return v } +func (InvokeHostFunctionOp) XdrTypeName() string { return "InvokeHostFunctionOp" } +func (v InvokeHostFunctionOp) XdrValue() interface{} { return v } +func (v *InvokeHostFunctionOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *InvokeHostFunctionOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%shostFunction", name), XDR_HostFunction(&v.HostFunction)) + x.Marshal(x.Sprintf("%sauth", name), (*_XdrVec_unbounded_SorobanAuthorizationEntry)(&v.Auth)) +} +func XDR_InvokeHostFunctionOp(v *InvokeHostFunctionOp) *InvokeHostFunctionOp { return v } + +type XdrType_ExtendFootprintTTLOp = *ExtendFootprintTTLOp + +func (v *ExtendFootprintTTLOp) XdrPointer() interface{} { return v } +func (ExtendFootprintTTLOp) XdrTypeName() string { return "ExtendFootprintTTLOp" } +func (v ExtendFootprintTTLOp) XdrValue() interface{} { return v } +func (v *ExtendFootprintTTLOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ExtendFootprintTTLOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) + x.Marshal(x.Sprintf("%sextendTo", name), XDR_Uint32(&v.ExtendTo)) +} +func XDR_ExtendFootprintTTLOp(v *ExtendFootprintTTLOp) *ExtendFootprintTTLOp { return v } + +type XdrType_RestoreFootprintOp = *RestoreFootprintOp + +func (v *RestoreFootprintOp) XdrPointer() interface{} { return v } +func (RestoreFootprintOp) XdrTypeName() string { return "RestoreFootprintOp" } +func (v RestoreFootprintOp) XdrValue() interface{} { return v } +func (v *RestoreFootprintOp) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *RestoreFootprintOp) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) +} +func XDR_RestoreFootprintOp(v *RestoreFootprintOp) *RestoreFootprintOp { return v } + +var _XdrTags_XdrAnon_Operation_Body = map[int32]bool{ + XdrToI32(CREATE_ACCOUNT): true, + XdrToI32(PAYMENT): true, + XdrToI32(PATH_PAYMENT_STRICT_RECEIVE): true, + XdrToI32(MANAGE_SELL_OFFER): true, + XdrToI32(CREATE_PASSIVE_SELL_OFFER): true, + XdrToI32(SET_OPTIONS): true, + XdrToI32(CHANGE_TRUST): true, + XdrToI32(ALLOW_TRUST): true, + XdrToI32(ACCOUNT_MERGE): true, + XdrToI32(INFLATION): true, + XdrToI32(MANAGE_DATA): true, + XdrToI32(BUMP_SEQUENCE): true, + XdrToI32(MANAGE_BUY_OFFER): true, + XdrToI32(PATH_PAYMENT_STRICT_SEND): true, + XdrToI32(CREATE_CLAIMABLE_BALANCE): true, + XdrToI32(CLAIM_CLAIMABLE_BALANCE): true, + XdrToI32(BEGIN_SPONSORING_FUTURE_RESERVES): true, + XdrToI32(END_SPONSORING_FUTURE_RESERVES): true, + XdrToI32(REVOKE_SPONSORSHIP): true, + XdrToI32(CLAWBACK): true, + XdrToI32(CLAWBACK_CLAIMABLE_BALANCE): true, + XdrToI32(SET_TRUST_LINE_FLAGS): true, + XdrToI32(LIQUIDITY_POOL_DEPOSIT): true, + XdrToI32(LIQUIDITY_POOL_WITHDRAW): true, + XdrToI32(INVOKE_HOST_FUNCTION): true, + XdrToI32(EXTEND_FOOTPRINT_TTL): true, + XdrToI32(RESTORE_FOOTPRINT): true, +} + +func (_ XdrAnon_Operation_Body) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_Operation_Body +} +func (u *XdrAnon_Operation_Body) CreateAccountOp() *CreateAccountOp { + switch u.Type { + case CREATE_ACCOUNT: + if v, ok := u._u.(*CreateAccountOp); ok { + return v + } else { + var zero CreateAccountOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.CreateAccountOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) PaymentOp() *PaymentOp { + switch u.Type { + case PAYMENT: + if v, ok := u._u.(*PaymentOp); ok { + return v + } else { + var zero PaymentOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.PaymentOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) PathPaymentStrictReceiveOp() *PathPaymentStrictReceiveOp { + switch u.Type { + case PATH_PAYMENT_STRICT_RECEIVE: + if v, ok := u._u.(*PathPaymentStrictReceiveOp); ok { + return v + } else { + var zero PathPaymentStrictReceiveOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.PathPaymentStrictReceiveOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ManageSellOfferOp() *ManageSellOfferOp { + switch u.Type { + case MANAGE_SELL_OFFER: + if v, ok := u._u.(*ManageSellOfferOp); ok { + return v + } else { + var zero ManageSellOfferOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ManageSellOfferOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) CreatePassiveSellOfferOp() *CreatePassiveSellOfferOp { + switch u.Type { + case CREATE_PASSIVE_SELL_OFFER: + if v, ok := u._u.(*CreatePassiveSellOfferOp); ok { + return v + } else { + var zero CreatePassiveSellOfferOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.CreatePassiveSellOfferOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) SetOptionsOp() *SetOptionsOp { + switch u.Type { + case SET_OPTIONS: + if v, ok := u._u.(*SetOptionsOp); ok { + return v + } else { + var zero SetOptionsOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.SetOptionsOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ChangeTrustOp() *ChangeTrustOp { + switch u.Type { + case CHANGE_TRUST: + if v, ok := u._u.(*ChangeTrustOp); ok { + return v + } else { + var zero ChangeTrustOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ChangeTrustOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) AllowTrustOp() *AllowTrustOp { + switch u.Type { + case ALLOW_TRUST: + if v, ok := u._u.(*AllowTrustOp); ok { + return v + } else { + var zero AllowTrustOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.AllowTrustOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) Destination() *MuxedAccount { + switch u.Type { + case ACCOUNT_MERGE: + if v, ok := u._u.(*MuxedAccount); ok { + return v + } else { + var zero MuxedAccount + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.Destination accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ManageDataOp() *ManageDataOp { + switch u.Type { + case MANAGE_DATA: + if v, ok := u._u.(*ManageDataOp); ok { + return v + } else { + var zero ManageDataOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ManageDataOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) BumpSequenceOp() *BumpSequenceOp { + switch u.Type { + case BUMP_SEQUENCE: + if v, ok := u._u.(*BumpSequenceOp); ok { + return v + } else { + var zero BumpSequenceOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.BumpSequenceOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ManageBuyOfferOp() *ManageBuyOfferOp { + switch u.Type { + case MANAGE_BUY_OFFER: + if v, ok := u._u.(*ManageBuyOfferOp); ok { + return v + } else { + var zero ManageBuyOfferOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ManageBuyOfferOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) PathPaymentStrictSendOp() *PathPaymentStrictSendOp { + switch u.Type { + case PATH_PAYMENT_STRICT_SEND: + if v, ok := u._u.(*PathPaymentStrictSendOp); ok { + return v + } else { + var zero PathPaymentStrictSendOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.PathPaymentStrictSendOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) CreateClaimableBalanceOp() *CreateClaimableBalanceOp { + switch u.Type { + case CREATE_CLAIMABLE_BALANCE: + if v, ok := u._u.(*CreateClaimableBalanceOp); ok { + return v + } else { + var zero CreateClaimableBalanceOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.CreateClaimableBalanceOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ClaimClaimableBalanceOp() *ClaimClaimableBalanceOp { + switch u.Type { + case CLAIM_CLAIMABLE_BALANCE: + if v, ok := u._u.(*ClaimClaimableBalanceOp); ok { + return v + } else { + var zero ClaimClaimableBalanceOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ClaimClaimableBalanceOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) BeginSponsoringFutureReservesOp() *BeginSponsoringFutureReservesOp { + switch u.Type { + case BEGIN_SPONSORING_FUTURE_RESERVES: + if v, ok := u._u.(*BeginSponsoringFutureReservesOp); ok { + return v + } else { + var zero BeginSponsoringFutureReservesOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.BeginSponsoringFutureReservesOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) RevokeSponsorshipOp() *RevokeSponsorshipOp { + switch u.Type { + case REVOKE_SPONSORSHIP: + if v, ok := u._u.(*RevokeSponsorshipOp); ok { + return v + } else { + var zero RevokeSponsorshipOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.RevokeSponsorshipOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ClawbackOp() *ClawbackOp { + switch u.Type { + case CLAWBACK: + if v, ok := u._u.(*ClawbackOp); ok { + return v + } else { + var zero ClawbackOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ClawbackOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ClawbackClaimableBalanceOp() *ClawbackClaimableBalanceOp { + switch u.Type { + case CLAWBACK_CLAIMABLE_BALANCE: + if v, ok := u._u.(*ClawbackClaimableBalanceOp); ok { + return v + } else { + var zero ClawbackClaimableBalanceOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ClawbackClaimableBalanceOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) SetTrustLineFlagsOp() *SetTrustLineFlagsOp { + switch u.Type { + case SET_TRUST_LINE_FLAGS: + if v, ok := u._u.(*SetTrustLineFlagsOp); ok { + return v + } else { + var zero SetTrustLineFlagsOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.SetTrustLineFlagsOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) LiquidityPoolDepositOp() *LiquidityPoolDepositOp { + switch u.Type { + case LIQUIDITY_POOL_DEPOSIT: + if v, ok := u._u.(*LiquidityPoolDepositOp); ok { + return v + } else { + var zero LiquidityPoolDepositOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.LiquidityPoolDepositOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) LiquidityPoolWithdrawOp() *LiquidityPoolWithdrawOp { + switch u.Type { + case LIQUIDITY_POOL_WITHDRAW: + if v, ok := u._u.(*LiquidityPoolWithdrawOp); ok { + return v + } else { + var zero LiquidityPoolWithdrawOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.LiquidityPoolWithdrawOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) InvokeHostFunctionOp() *InvokeHostFunctionOp { + switch u.Type { + case INVOKE_HOST_FUNCTION: + if v, ok := u._u.(*InvokeHostFunctionOp); ok { + return v + } else { + var zero InvokeHostFunctionOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.InvokeHostFunctionOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) ExtendFootprintTTLOp() *ExtendFootprintTTLOp { + switch u.Type { + case EXTEND_FOOTPRINT_TTL: + if v, ok := u._u.(*ExtendFootprintTTLOp); ok { + return v + } else { + var zero ExtendFootprintTTLOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.ExtendFootprintTTLOp accessed when Type == %v", u.Type) + return nil + } +} +func (u *XdrAnon_Operation_Body) RestoreFootprintOp() *RestoreFootprintOp { + switch u.Type { + case RESTORE_FOOTPRINT: + if v, ok := u._u.(*RestoreFootprintOp); ok { + return v + } else { + var zero RestoreFootprintOp + u._u = &zero + return &zero + } + default: + XdrPanic("XdrAnon_Operation_Body.RestoreFootprintOp accessed when Type == %v", u.Type) + return nil + } +} +func (u XdrAnon_Operation_Body) XdrValid() bool { + switch u.Type { + case CREATE_ACCOUNT, PAYMENT, PATH_PAYMENT_STRICT_RECEIVE, MANAGE_SELL_OFFER, CREATE_PASSIVE_SELL_OFFER, SET_OPTIONS, CHANGE_TRUST, ALLOW_TRUST, ACCOUNT_MERGE, INFLATION, MANAGE_DATA, BUMP_SEQUENCE, MANAGE_BUY_OFFER, PATH_PAYMENT_STRICT_SEND, CREATE_CLAIMABLE_BALANCE, CLAIM_CLAIMABLE_BALANCE, BEGIN_SPONSORING_FUTURE_RESERVES, END_SPONSORING_FUTURE_RESERVES, REVOKE_SPONSORSHIP, CLAWBACK, CLAWBACK_CLAIMABLE_BALANCE, SET_TRUST_LINE_FLAGS, LIQUIDITY_POOL_DEPOSIT, LIQUIDITY_POOL_WITHDRAW, INVOKE_HOST_FUNCTION, EXTEND_FOOTPRINT_TTL, RESTORE_FOOTPRINT: + return true + } + return false +} +func (u *XdrAnon_Operation_Body) XdrUnionTag() XdrNum32 { + return XDR_OperationType(&u.Type) +} +func (u *XdrAnon_Operation_Body) XdrUnionTagName() string { + return "Type" +} +func (u *XdrAnon_Operation_Body) XdrUnionBody() XdrType { + switch u.Type { + case CREATE_ACCOUNT: + return XDR_CreateAccountOp(u.CreateAccountOp()) + case PAYMENT: + return XDR_PaymentOp(u.PaymentOp()) + case PATH_PAYMENT_STRICT_RECEIVE: + return XDR_PathPaymentStrictReceiveOp(u.PathPaymentStrictReceiveOp()) + case MANAGE_SELL_OFFER: + return XDR_ManageSellOfferOp(u.ManageSellOfferOp()) + case CREATE_PASSIVE_SELL_OFFER: + return XDR_CreatePassiveSellOfferOp(u.CreatePassiveSellOfferOp()) + case SET_OPTIONS: + return XDR_SetOptionsOp(u.SetOptionsOp()) + case CHANGE_TRUST: + return XDR_ChangeTrustOp(u.ChangeTrustOp()) + case ALLOW_TRUST: + return XDR_AllowTrustOp(u.AllowTrustOp()) + case ACCOUNT_MERGE: + return XDR_MuxedAccount(u.Destination()) + case INFLATION: + return nil + case MANAGE_DATA: + return XDR_ManageDataOp(u.ManageDataOp()) + case BUMP_SEQUENCE: + return XDR_BumpSequenceOp(u.BumpSequenceOp()) + case MANAGE_BUY_OFFER: + return XDR_ManageBuyOfferOp(u.ManageBuyOfferOp()) + case PATH_PAYMENT_STRICT_SEND: + return XDR_PathPaymentStrictSendOp(u.PathPaymentStrictSendOp()) + case CREATE_CLAIMABLE_BALANCE: + return XDR_CreateClaimableBalanceOp(u.CreateClaimableBalanceOp()) + case CLAIM_CLAIMABLE_BALANCE: + return XDR_ClaimClaimableBalanceOp(u.ClaimClaimableBalanceOp()) + case BEGIN_SPONSORING_FUTURE_RESERVES: + return XDR_BeginSponsoringFutureReservesOp(u.BeginSponsoringFutureReservesOp()) + case END_SPONSORING_FUTURE_RESERVES: + return nil + case REVOKE_SPONSORSHIP: + return XDR_RevokeSponsorshipOp(u.RevokeSponsorshipOp()) + case CLAWBACK: + return XDR_ClawbackOp(u.ClawbackOp()) + case CLAWBACK_CLAIMABLE_BALANCE: + return XDR_ClawbackClaimableBalanceOp(u.ClawbackClaimableBalanceOp()) + case SET_TRUST_LINE_FLAGS: + return XDR_SetTrustLineFlagsOp(u.SetTrustLineFlagsOp()) + case LIQUIDITY_POOL_DEPOSIT: + return XDR_LiquidityPoolDepositOp(u.LiquidityPoolDepositOp()) + case LIQUIDITY_POOL_WITHDRAW: + return XDR_LiquidityPoolWithdrawOp(u.LiquidityPoolWithdrawOp()) + case INVOKE_HOST_FUNCTION: + return XDR_InvokeHostFunctionOp(u.InvokeHostFunctionOp()) + case EXTEND_FOOTPRINT_TTL: + return XDR_ExtendFootprintTTLOp(u.ExtendFootprintTTLOp()) + case RESTORE_FOOTPRINT: + return XDR_RestoreFootprintOp(u.RestoreFootprintOp()) + } + return nil +} +func (u *XdrAnon_Operation_Body) XdrUnionBodyName() string { + switch u.Type { + case CREATE_ACCOUNT: + return "CreateAccountOp" + case PAYMENT: + return "PaymentOp" + case PATH_PAYMENT_STRICT_RECEIVE: + return "PathPaymentStrictReceiveOp" + case MANAGE_SELL_OFFER: + return "ManageSellOfferOp" + case CREATE_PASSIVE_SELL_OFFER: + return "CreatePassiveSellOfferOp" + case SET_OPTIONS: + return "SetOptionsOp" + case CHANGE_TRUST: + return "ChangeTrustOp" + case ALLOW_TRUST: + return "AllowTrustOp" + case ACCOUNT_MERGE: + return "Destination" + case INFLATION: + return "" + case MANAGE_DATA: + return "ManageDataOp" + case BUMP_SEQUENCE: + return "BumpSequenceOp" + case MANAGE_BUY_OFFER: + return "ManageBuyOfferOp" + case PATH_PAYMENT_STRICT_SEND: + return "PathPaymentStrictSendOp" + case CREATE_CLAIMABLE_BALANCE: + return "CreateClaimableBalanceOp" + case CLAIM_CLAIMABLE_BALANCE: + return "ClaimClaimableBalanceOp" + case BEGIN_SPONSORING_FUTURE_RESERVES: + return "BeginSponsoringFutureReservesOp" + case END_SPONSORING_FUTURE_RESERVES: + return "" + case REVOKE_SPONSORSHIP: + return "RevokeSponsorshipOp" + case CLAWBACK: + return "ClawbackOp" + case CLAWBACK_CLAIMABLE_BALANCE: + return "ClawbackClaimableBalanceOp" + case SET_TRUST_LINE_FLAGS: + return "SetTrustLineFlagsOp" + case LIQUIDITY_POOL_DEPOSIT: + return "LiquidityPoolDepositOp" + case LIQUIDITY_POOL_WITHDRAW: + return "LiquidityPoolWithdrawOp" + case INVOKE_HOST_FUNCTION: + return "InvokeHostFunctionOp" + case EXTEND_FOOTPRINT_TTL: + return "ExtendFootprintTTLOp" + case RESTORE_FOOTPRINT: + return "RestoreFootprintOp" + } + return "" +} + +type XdrType_XdrAnon_Operation_Body = *XdrAnon_Operation_Body + +func (v *XdrAnon_Operation_Body) XdrPointer() interface{} { return v } +func (XdrAnon_Operation_Body) XdrTypeName() string { return "XdrAnon_Operation_Body" } +func (v XdrAnon_Operation_Body) XdrValue() interface{} { return v } +func (v *XdrAnon_Operation_Body) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_Operation_Body) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_OperationType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case CREATE_ACCOUNT: + x.Marshal(x.Sprintf("%screateAccountOp", name), XDR_CreateAccountOp(u.CreateAccountOp())) + return + case PAYMENT: + x.Marshal(x.Sprintf("%spaymentOp", name), XDR_PaymentOp(u.PaymentOp())) + return + case PATH_PAYMENT_STRICT_RECEIVE: + x.Marshal(x.Sprintf("%spathPaymentStrictReceiveOp", name), XDR_PathPaymentStrictReceiveOp(u.PathPaymentStrictReceiveOp())) + return + case MANAGE_SELL_OFFER: + x.Marshal(x.Sprintf("%smanageSellOfferOp", name), XDR_ManageSellOfferOp(u.ManageSellOfferOp())) + return + case CREATE_PASSIVE_SELL_OFFER: + x.Marshal(x.Sprintf("%screatePassiveSellOfferOp", name), XDR_CreatePassiveSellOfferOp(u.CreatePassiveSellOfferOp())) + return + case SET_OPTIONS: + x.Marshal(x.Sprintf("%ssetOptionsOp", name), XDR_SetOptionsOp(u.SetOptionsOp())) + return + case CHANGE_TRUST: + x.Marshal(x.Sprintf("%schangeTrustOp", name), XDR_ChangeTrustOp(u.ChangeTrustOp())) + return + case ALLOW_TRUST: + x.Marshal(x.Sprintf("%sallowTrustOp", name), XDR_AllowTrustOp(u.AllowTrustOp())) + return + case ACCOUNT_MERGE: + x.Marshal(x.Sprintf("%sdestination", name), XDR_MuxedAccount(u.Destination())) + return + case INFLATION: + return + case MANAGE_DATA: + x.Marshal(x.Sprintf("%smanageDataOp", name), XDR_ManageDataOp(u.ManageDataOp())) + return + case BUMP_SEQUENCE: + x.Marshal(x.Sprintf("%sbumpSequenceOp", name), XDR_BumpSequenceOp(u.BumpSequenceOp())) + return + case MANAGE_BUY_OFFER: + x.Marshal(x.Sprintf("%smanageBuyOfferOp", name), XDR_ManageBuyOfferOp(u.ManageBuyOfferOp())) + return + case PATH_PAYMENT_STRICT_SEND: + x.Marshal(x.Sprintf("%spathPaymentStrictSendOp", name), XDR_PathPaymentStrictSendOp(u.PathPaymentStrictSendOp())) + return + case CREATE_CLAIMABLE_BALANCE: + x.Marshal(x.Sprintf("%screateClaimableBalanceOp", name), XDR_CreateClaimableBalanceOp(u.CreateClaimableBalanceOp())) + return + case CLAIM_CLAIMABLE_BALANCE: + x.Marshal(x.Sprintf("%sclaimClaimableBalanceOp", name), XDR_ClaimClaimableBalanceOp(u.ClaimClaimableBalanceOp())) + return + case BEGIN_SPONSORING_FUTURE_RESERVES: + x.Marshal(x.Sprintf("%sbeginSponsoringFutureReservesOp", name), XDR_BeginSponsoringFutureReservesOp(u.BeginSponsoringFutureReservesOp())) + return + case END_SPONSORING_FUTURE_RESERVES: + return + case REVOKE_SPONSORSHIP: + x.Marshal(x.Sprintf("%srevokeSponsorshipOp", name), XDR_RevokeSponsorshipOp(u.RevokeSponsorshipOp())) + return + case CLAWBACK: + x.Marshal(x.Sprintf("%sclawbackOp", name), XDR_ClawbackOp(u.ClawbackOp())) + return + case CLAWBACK_CLAIMABLE_BALANCE: + x.Marshal(x.Sprintf("%sclawbackClaimableBalanceOp", name), XDR_ClawbackClaimableBalanceOp(u.ClawbackClaimableBalanceOp())) + return + case SET_TRUST_LINE_FLAGS: + x.Marshal(x.Sprintf("%ssetTrustLineFlagsOp", name), XDR_SetTrustLineFlagsOp(u.SetTrustLineFlagsOp())) + return + case LIQUIDITY_POOL_DEPOSIT: + x.Marshal(x.Sprintf("%sliquidityPoolDepositOp", name), XDR_LiquidityPoolDepositOp(u.LiquidityPoolDepositOp())) + return + case LIQUIDITY_POOL_WITHDRAW: + x.Marshal(x.Sprintf("%sliquidityPoolWithdrawOp", name), XDR_LiquidityPoolWithdrawOp(u.LiquidityPoolWithdrawOp())) + return + case INVOKE_HOST_FUNCTION: + x.Marshal(x.Sprintf("%sinvokeHostFunctionOp", name), XDR_InvokeHostFunctionOp(u.InvokeHostFunctionOp())) + return + case EXTEND_FOOTPRINT_TTL: + x.Marshal(x.Sprintf("%sextendFootprintTTLOp", name), XDR_ExtendFootprintTTLOp(u.ExtendFootprintTTLOp())) + return + case RESTORE_FOOTPRINT: + x.Marshal(x.Sprintf("%srestoreFootprintOp", name), XDR_RestoreFootprintOp(u.RestoreFootprintOp())) + return + } + XdrPanic("invalid Type (%v) in XdrAnon_Operation_Body", u.Type) +} +func XDR_XdrAnon_Operation_Body(v *XdrAnon_Operation_Body) *XdrAnon_Operation_Body { return v } + +type _XdrPtr_MuxedAccount struct { + p **MuxedAccount +} +type _ptrflag_MuxedAccount _XdrPtr_MuxedAccount + +func (v _ptrflag_MuxedAccount) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" +} +func (v _ptrflag_MuxedAccount) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) + default: + return XdrError("MuxedAccount flag should be \"nil\" or \"non-nil\"") + } + return nil +} +func (v _ptrflag_MuxedAccount) GetU32() uint32 { + if *v.p == nil { + return 0 + } + return 1 +} +func (v _ptrflag_MuxedAccount) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(MuxedAccount) + } + default: + XdrPanic("*MuxedAccount present flag value %d should be 0 or 1", nv) + } +} +func (_ptrflag_MuxedAccount) XdrTypeName() string { return "MuxedAccount?" } +func (v _ptrflag_MuxedAccount) XdrPointer() interface{} { return nil } +func (v _ptrflag_MuxedAccount) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_MuxedAccount) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_MuxedAccount) XdrBound() uint32 { return 1 } +func (v _XdrPtr_MuxedAccount) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_MuxedAccount) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(MuxedAccount) + } +} +func (v _XdrPtr_MuxedAccount) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_MuxedAccount(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_MuxedAccount) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_MuxedAccount) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_MuxedAccount(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_MuxedAccount) XdrTypeName() string { return "MuxedAccount*" } +func (v _XdrPtr_MuxedAccount) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_MuxedAccount) XdrValue() interface{} { return *v.p } + +type XdrType_Operation = *Operation + +func (v *Operation) XdrPointer() interface{} { return v } +func (Operation) XdrTypeName() string { return "Operation" } +func (v Operation) XdrValue() interface{} { return v } +func (v *Operation) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *Operation) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%ssourceAccount", name), _XdrPtr_MuxedAccount{&v.SourceAccount}) + x.Marshal(x.Sprintf("%sbody", name), XDR_XdrAnon_Operation_Body(&v.Body)) +} +func XDR_Operation(v *Operation) *Operation { return v } + +type XdrType_XdrAnon_HashIDPreimage_OperationID = *XdrAnon_HashIDPreimage_OperationID + +func (v *XdrAnon_HashIDPreimage_OperationID) XdrPointer() interface{} { return v } +func (XdrAnon_HashIDPreimage_OperationID) XdrTypeName() string { + return "XdrAnon_HashIDPreimage_OperationID" +} +func (v XdrAnon_HashIDPreimage_OperationID) XdrValue() interface{} { return v } +func (v *XdrAnon_HashIDPreimage_OperationID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_HashIDPreimage_OperationID) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%ssourceAccount", name), XDR_AccountID(&v.SourceAccount)) + x.Marshal(x.Sprintf("%sseqNum", name), XDR_SequenceNumber(&v.SeqNum)) + x.Marshal(x.Sprintf("%sopNum", name), XDR_Uint32(&v.OpNum)) +} +func XDR_XdrAnon_HashIDPreimage_OperationID(v *XdrAnon_HashIDPreimage_OperationID) *XdrAnon_HashIDPreimage_OperationID { + return v +} + +type XdrType_XdrAnon_HashIDPreimage_RevokeID = *XdrAnon_HashIDPreimage_RevokeID + +func (v *XdrAnon_HashIDPreimage_RevokeID) XdrPointer() interface{} { return v } +func (XdrAnon_HashIDPreimage_RevokeID) XdrTypeName() string { return "XdrAnon_HashIDPreimage_RevokeID" } +func (v XdrAnon_HashIDPreimage_RevokeID) XdrValue() interface{} { return v } +func (v *XdrAnon_HashIDPreimage_RevokeID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_HashIDPreimage_RevokeID) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%ssourceAccount", name), XDR_AccountID(&v.SourceAccount)) + x.Marshal(x.Sprintf("%sseqNum", name), XDR_SequenceNumber(&v.SeqNum)) + x.Marshal(x.Sprintf("%sopNum", name), XDR_Uint32(&v.OpNum)) + x.Marshal(x.Sprintf("%sliquidityPoolID", name), XDR_PoolID(&v.LiquidityPoolID)) + x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) +} +func XDR_XdrAnon_HashIDPreimage_RevokeID(v *XdrAnon_HashIDPreimage_RevokeID) *XdrAnon_HashIDPreimage_RevokeID { + return v +} + +type XdrType_XdrAnon_HashIDPreimage_ContractID = *XdrAnon_HashIDPreimage_ContractID + +func (v *XdrAnon_HashIDPreimage_ContractID) XdrPointer() interface{} { return v } +func (XdrAnon_HashIDPreimage_ContractID) XdrTypeName() string { + return "XdrAnon_HashIDPreimage_ContractID" +} +func (v XdrAnon_HashIDPreimage_ContractID) XdrValue() interface{} { return v } +func (v *XdrAnon_HashIDPreimage_ContractID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_HashIDPreimage_ContractID) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%snetworkID", name), XDR_Hash(&v.NetworkID)) + x.Marshal(x.Sprintf("%scontractIDPreimage", name), XDR_ContractIDPreimage(&v.ContractIDPreimage)) +} +func XDR_XdrAnon_HashIDPreimage_ContractID(v *XdrAnon_HashIDPreimage_ContractID) *XdrAnon_HashIDPreimage_ContractID { + return v +} + +type XdrType_XdrAnon_HashIDPreimage_SorobanAuthorization = *XdrAnon_HashIDPreimage_SorobanAuthorization + +func (v *XdrAnon_HashIDPreimage_SorobanAuthorization) XdrPointer() interface{} { return v } +func (XdrAnon_HashIDPreimage_SorobanAuthorization) XdrTypeName() string { + return "XdrAnon_HashIDPreimage_SorobanAuthorization" +} +func (v XdrAnon_HashIDPreimage_SorobanAuthorization) XdrValue() interface{} { return v } +func (v *XdrAnon_HashIDPreimage_SorobanAuthorization) XdrMarshal(x XDR, name string) { + x.Marshal(name, v) +} +func (v *XdrAnon_HashIDPreimage_SorobanAuthorization) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%snetworkID", name), XDR_Hash(&v.NetworkID)) + x.Marshal(x.Sprintf("%snonce", name), XDR_Int64(&v.Nonce)) + x.Marshal(x.Sprintf("%ssignatureExpirationLedger", name), XDR_Uint32(&v.SignatureExpirationLedger)) + x.Marshal(x.Sprintf("%sinvocation", name), XDR_SorobanAuthorizedInvocation(&v.Invocation)) +} +func XDR_XdrAnon_HashIDPreimage_SorobanAuthorization(v *XdrAnon_HashIDPreimage_SorobanAuthorization) *XdrAnon_HashIDPreimage_SorobanAuthorization { + return v +} + +var _XdrTags_HashIDPreimage = map[int32]bool{ + XdrToI32(ENVELOPE_TYPE_OP_ID): true, + XdrToI32(ENVELOPE_TYPE_POOL_REVOKE_OP_ID): true, + XdrToI32(ENVELOPE_TYPE_CONTRACT_ID): true, + XdrToI32(ENVELOPE_TYPE_SOROBAN_AUTHORIZATION): true, +} + +func (_ HashIDPreimage) XdrValidTags() map[int32]bool { + return _XdrTags_HashIDPreimage +} +func (u *HashIDPreimage) OperationID() *XdrAnon_HashIDPreimage_OperationID { + switch u.Type { + case ENVELOPE_TYPE_OP_ID: + if v, ok := u._u.(*XdrAnon_HashIDPreimage_OperationID); ok { + return v + } else { + var zero XdrAnon_HashIDPreimage_OperationID + u._u = &zero + return &zero + } + default: + XdrPanic("HashIDPreimage.OperationID accessed when Type == %v", u.Type) + return nil + } +} +func (u *HashIDPreimage) RevokeID() *XdrAnon_HashIDPreimage_RevokeID { + switch u.Type { + case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: + if v, ok := u._u.(*XdrAnon_HashIDPreimage_RevokeID); ok { + return v + } else { + var zero XdrAnon_HashIDPreimage_RevokeID + u._u = &zero + return &zero + } + default: + XdrPanic("HashIDPreimage.RevokeID accessed when Type == %v", u.Type) + return nil + } +} +func (u *HashIDPreimage) ContractID() *XdrAnon_HashIDPreimage_ContractID { + switch u.Type { + case ENVELOPE_TYPE_CONTRACT_ID: + if v, ok := u._u.(*XdrAnon_HashIDPreimage_ContractID); ok { + return v + } else { + var zero XdrAnon_HashIDPreimage_ContractID + u._u = &zero + return &zero + } + default: + XdrPanic("HashIDPreimage.ContractID accessed when Type == %v", u.Type) + return nil + } +} +func (u *HashIDPreimage) SorobanAuthorization() *XdrAnon_HashIDPreimage_SorobanAuthorization { + switch u.Type { + case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + if v, ok := u._u.(*XdrAnon_HashIDPreimage_SorobanAuthorization); ok { + return v + } else { + var zero XdrAnon_HashIDPreimage_SorobanAuthorization + u._u = &zero + return &zero + } + default: + XdrPanic("HashIDPreimage.SorobanAuthorization accessed when Type == %v", u.Type) + return nil + } +} +func (u HashIDPreimage) XdrValid() bool { + switch u.Type { + case ENVELOPE_TYPE_OP_ID, ENVELOPE_TYPE_POOL_REVOKE_OP_ID, ENVELOPE_TYPE_CONTRACT_ID, ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + return true + } + return false +} +func (u *HashIDPreimage) XdrUnionTag() XdrNum32 { + return XDR_EnvelopeType(&u.Type) +} +func (u *HashIDPreimage) XdrUnionTagName() string { + return "Type" +} +func (u *HashIDPreimage) XdrUnionBody() XdrType { + switch u.Type { + case ENVELOPE_TYPE_OP_ID: + return XDR_XdrAnon_HashIDPreimage_OperationID(u.OperationID()) + case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: + return XDR_XdrAnon_HashIDPreimage_RevokeID(u.RevokeID()) + case ENVELOPE_TYPE_CONTRACT_ID: + return XDR_XdrAnon_HashIDPreimage_ContractID(u.ContractID()) + case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + return XDR_XdrAnon_HashIDPreimage_SorobanAuthorization(u.SorobanAuthorization()) + } + return nil +} +func (u *HashIDPreimage) XdrUnionBodyName() string { + switch u.Type { + case ENVELOPE_TYPE_OP_ID: + return "OperationID" + case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: + return "RevokeID" + case ENVELOPE_TYPE_CONTRACT_ID: + return "ContractID" + case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + return "SorobanAuthorization" + } + return "" +} + +type XdrType_HashIDPreimage = *HashIDPreimage + +func (v *HashIDPreimage) XdrPointer() interface{} { return v } +func (HashIDPreimage) XdrTypeName() string { return "HashIDPreimage" } +func (v HashIDPreimage) XdrValue() interface{} { return v } +func (v *HashIDPreimage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *HashIDPreimage) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_EnvelopeType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case ENVELOPE_TYPE_OP_ID: + x.Marshal(x.Sprintf("%soperationID", name), XDR_XdrAnon_HashIDPreimage_OperationID(u.OperationID())) + return + case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: + x.Marshal(x.Sprintf("%srevokeID", name), XDR_XdrAnon_HashIDPreimage_RevokeID(u.RevokeID())) + return + case ENVELOPE_TYPE_CONTRACT_ID: + x.Marshal(x.Sprintf("%scontractID", name), XDR_XdrAnon_HashIDPreimage_ContractID(u.ContractID())) + return + case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + x.Marshal(x.Sprintf("%ssorobanAuthorization", name), XDR_XdrAnon_HashIDPreimage_SorobanAuthorization(u.SorobanAuthorization())) + return + } + XdrPanic("invalid Type (%v) in HashIDPreimage", u.Type) +} +func (v *HashIDPreimage) XdrInitialize() { + var zero EnvelopeType + switch zero { + case ENVELOPE_TYPE_OP_ID, ENVELOPE_TYPE_POOL_REVOKE_OP_ID, ENVELOPE_TYPE_CONTRACT_ID, ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + default: + if v.Type == zero { + v.Type = ENVELOPE_TYPE_OP_ID + } + } +} +func XDR_HashIDPreimage(v *HashIDPreimage) *HashIDPreimage { return v } + +var _XdrNames_MemoType = map[int32]string{ + int32(MEMO_NONE): "MEMO_NONE", + int32(MEMO_TEXT): "MEMO_TEXT", + int32(MEMO_ID): "MEMO_ID", + int32(MEMO_HASH): "MEMO_HASH", + int32(MEMO_RETURN): "MEMO_RETURN", +} +var _XdrValues_MemoType = map[string]int32{ + "MEMO_NONE": int32(MEMO_NONE), + "MEMO_TEXT": int32(MEMO_TEXT), + "MEMO_ID": int32(MEMO_ID), + "MEMO_HASH": int32(MEMO_HASH), + "MEMO_RETURN": int32(MEMO_RETURN), +} + +func (MemoType) XdrEnumNames() map[int32]string { + return _XdrNames_MemoType +} +func (v MemoType) String() string { + if s, ok := _XdrNames_MemoType[int32(v)]; ok { + return s + } + return fmt.Sprintf("MemoType#%d", v) +} +func (v *MemoType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_MemoType[stok]; ok { + *v = MemoType(val) + return nil + } else if stok == "MemoType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid MemoType.", stok)) + } +} +func (v MemoType) GetU32() uint32 { return uint32(v) } +func (v *MemoType) SetU32(n uint32) { *v = MemoType(n) } +func (v *MemoType) XdrPointer() interface{} { return v } +func (MemoType) XdrTypeName() string { return "MemoType" } +func (v MemoType) XdrValue() interface{} { return v } +func (v *MemoType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_MemoType = *MemoType + +func XDR_MemoType(v *MemoType) *MemoType { return v } + +var _XdrTags_Memo = map[int32]bool{ + XdrToI32(MEMO_NONE): true, + XdrToI32(MEMO_TEXT): true, + XdrToI32(MEMO_ID): true, + XdrToI32(MEMO_HASH): true, + XdrToI32(MEMO_RETURN): true, +} + +func (_ Memo) XdrValidTags() map[int32]bool { + return _XdrTags_Memo +} +func (u *Memo) Text() *string { + switch u.Type { + case MEMO_TEXT: + if v, ok := u._u.(*string); ok { + return v + } else { + var zero string + u._u = &zero + return &zero + } + default: + XdrPanic("Memo.Text accessed when Type == %v", u.Type) + return nil + } +} +func (u *Memo) Id() *Uint64 { + switch u.Type { + case MEMO_ID: + if v, ok := u._u.(*Uint64); ok { + return v + } else { + var zero Uint64 + u._u = &zero + return &zero + } + default: + XdrPanic("Memo.Id accessed when Type == %v", u.Type) + return nil + } +} + +// the hash of what to pull from the content server +func (u *Memo) Hash() *Hash { + switch u.Type { + case MEMO_HASH: + if v, ok := u._u.(*Hash); ok { + return v + } else { + var zero Hash + u._u = &zero + return &zero + } + default: + XdrPanic("Memo.Hash accessed when Type == %v", u.Type) + return nil + } +} + +// the hash of the tx you are rejecting +func (u *Memo) RetHash() *Hash { + switch u.Type { + case MEMO_RETURN: + if v, ok := u._u.(*Hash); ok { + return v + } else { + var zero Hash + u._u = &zero + return &zero + } + default: + XdrPanic("Memo.RetHash accessed when Type == %v", u.Type) + return nil + } +} +func (u Memo) XdrValid() bool { + switch u.Type { + case MEMO_NONE, MEMO_TEXT, MEMO_ID, MEMO_HASH, MEMO_RETURN: + return true + } + return false +} +func (u *Memo) XdrUnionTag() XdrNum32 { + return XDR_MemoType(&u.Type) +} +func (u *Memo) XdrUnionTagName() string { + return "Type" +} +func (u *Memo) XdrUnionBody() XdrType { + switch u.Type { + case MEMO_NONE: + return nil + case MEMO_TEXT: + return XdrString{u.Text(), 28} + case MEMO_ID: + return XDR_Uint64(u.Id()) + case MEMO_HASH: + return XDR_Hash(u.Hash()) + case MEMO_RETURN: + return XDR_Hash(u.RetHash()) + } + return nil +} +func (u *Memo) XdrUnionBodyName() string { + switch u.Type { + case MEMO_NONE: + return "" + case MEMO_TEXT: + return "Text" + case MEMO_ID: + return "Id" + case MEMO_HASH: + return "Hash" + case MEMO_RETURN: + return "RetHash" + } + return "" +} + +type XdrType_Memo = *Memo + +func (v *Memo) XdrPointer() interface{} { return v } +func (Memo) XdrTypeName() string { return "Memo" } +func (v Memo) XdrValue() interface{} { return v } +func (v *Memo) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *Memo) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + XDR_MemoType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + switch u.Type { + case MEMO_NONE: + return + case MEMO_TEXT: + x.Marshal(x.Sprintf("%stext", name), XdrString{u.Text(), 28}) + return + case MEMO_ID: + x.Marshal(x.Sprintf("%sid", name), XDR_Uint64(u.Id())) + return + case MEMO_HASH: + x.Marshal(x.Sprintf("%shash", name), XDR_Hash(u.Hash())) + return + case MEMO_RETURN: + x.Marshal(x.Sprintf("%sretHash", name), XDR_Hash(u.RetHash())) + return + } + XdrPanic("invalid Type (%v) in Memo", u.Type) +} +func XDR_Memo(v *Memo) *Memo { return v } + +type XdrType_TimeBounds = *TimeBounds + +func (v *TimeBounds) XdrPointer() interface{} { return v } +func (TimeBounds) XdrTypeName() string { return "TimeBounds" } +func (v TimeBounds) XdrValue() interface{} { return v } +func (v *TimeBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *TimeBounds) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sminTime", name), XDR_TimePoint(&v.MinTime)) + x.Marshal(x.Sprintf("%smaxTime", name), XDR_TimePoint(&v.MaxTime)) +} +func XDR_TimeBounds(v *TimeBounds) *TimeBounds { return v } + +type XdrType_LedgerBounds = *LedgerBounds + +func (v *LedgerBounds) XdrPointer() interface{} { return v } +func (LedgerBounds) XdrTypeName() string { return "LedgerBounds" } +func (v LedgerBounds) XdrValue() interface{} { return v } +func (v *LedgerBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerBounds) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sminLedger", name), XDR_Uint32(&v.MinLedger)) + x.Marshal(x.Sprintf("%smaxLedger", name), XDR_Uint32(&v.MaxLedger)) +} +func XDR_LedgerBounds(v *LedgerBounds) *LedgerBounds { return v } + +type _XdrPtr_TimeBounds struct { + p **TimeBounds +} +type _ptrflag_TimeBounds _XdrPtr_TimeBounds + +func (v _ptrflag_TimeBounds) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" +} +func (v _ptrflag_TimeBounds) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) + default: + return XdrError("TimeBounds flag should be \"nil\" or \"non-nil\"") + } + return nil +} +func (v _ptrflag_TimeBounds) GetU32() uint32 { + if *v.p == nil { + return 0 + } + return 1 +} +func (v _ptrflag_TimeBounds) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(TimeBounds) + } + default: + XdrPanic("*TimeBounds present flag value %d should be 0 or 1", nv) + } +} +func (_ptrflag_TimeBounds) XdrTypeName() string { return "TimeBounds?" } +func (v _ptrflag_TimeBounds) XdrPointer() interface{} { return nil } +func (v _ptrflag_TimeBounds) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_TimeBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_TimeBounds) XdrBound() uint32 { return 1 } +func (v _XdrPtr_TimeBounds) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_TimeBounds) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(TimeBounds) + } +} +func (v _XdrPtr_TimeBounds) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_TimeBounds(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_TimeBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_TimeBounds) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_TimeBounds(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_TimeBounds) XdrTypeName() string { return "TimeBounds*" } +func (v _XdrPtr_TimeBounds) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_TimeBounds) XdrValue() interface{} { return *v.p } + +type _XdrPtr_LedgerBounds struct { + p **LedgerBounds +} +type _ptrflag_LedgerBounds _XdrPtr_LedgerBounds + +func (v _ptrflag_LedgerBounds) String() string { + if *v.p == nil { + return "nil" + } + return "non-nil" +} +func (v _ptrflag_LedgerBounds) Scan(ss fmt.ScanState, r rune) error { + tok, err := ss.Token(true, func(c rune) bool { + return c == '-' || (c >= 'a' && c <= 'z') + }) + if err != nil { + return err + } + switch string(tok) { + case "nil": + v.SetU32(0) + case "non-nil": + v.SetU32(1) + default: + return XdrError("LedgerBounds flag should be \"nil\" or \"non-nil\"") + } + return nil +} +func (v _ptrflag_LedgerBounds) GetU32() uint32 { + if *v.p == nil { + return 0 + } + return 1 +} +func (v _ptrflag_LedgerBounds) SetU32(nv uint32) { + switch nv { + case 0: + *v.p = nil + case 1: + if *v.p == nil { + *v.p = new(LedgerBounds) + } + default: + XdrPanic("*LedgerBounds present flag value %d should be 0 or 1", nv) + } +} +func (_ptrflag_LedgerBounds) XdrTypeName() string { return "LedgerBounds?" } +func (v _ptrflag_LedgerBounds) XdrPointer() interface{} { return nil } +func (v _ptrflag_LedgerBounds) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_LedgerBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_LedgerBounds) XdrBound() uint32 { return 1 } +func (v _XdrPtr_LedgerBounds) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_LedgerBounds) SetPresent(present bool) { + if !present { + *v.p = nil + } else if *v.p == nil { + *v.p = new(LedgerBounds) + } +} +func (v _XdrPtr_LedgerBounds) XdrMarshalValue(x XDR, name string) { + if *v.p != nil { + XDR_LedgerBounds(*v.p).XdrMarshal(x, name) + } +} +func (v _XdrPtr_LedgerBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_LedgerBounds) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_LedgerBounds(v)) + v.XdrMarshalValue(x, name) +} +func (_XdrPtr_LedgerBounds) XdrTypeName() string { return "LedgerBounds*" } +func (v _XdrPtr_LedgerBounds) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_LedgerBounds) XdrValue() interface{} { return *v.p } + +type _XdrPtr_SequenceNumber struct { + p **SequenceNumber } -type _ptrflag_MuxedAccount _XdrPtr_MuxedAccount +type _ptrflag_SequenceNumber _XdrPtr_SequenceNumber -func (v _ptrflag_MuxedAccount) String() string { +func (v _ptrflag_SequenceNumber) String() string { if *v.p == nil { return "nil" } return "non-nil" } -func (v _ptrflag_MuxedAccount) Scan(ss fmt.ScanState, r rune) error { +func (v _ptrflag_SequenceNumber) Scan(ss fmt.ScanState, r rune) error { tok, err := ss.Token(true, func(c rune) bool { return c == '-' || (c >= 'a' && c <= 'z') }) @@ -17838,766 +19365,500 @@ func (v _ptrflag_MuxedAccount) Scan(ss fmt.ScanState, r rune) error { case "non-nil": v.SetU32(1) default: - return XdrError("MuxedAccount flag should be \"nil\" or \"non-nil\"") + return XdrError("SequenceNumber flag should be \"nil\" or \"non-nil\"") } return nil } -func (v _ptrflag_MuxedAccount) GetU32() uint32 { +func (v _ptrflag_SequenceNumber) GetU32() uint32 { if *v.p == nil { return 0 } return 1 } -func (v _ptrflag_MuxedAccount) SetU32(nv uint32) { +func (v _ptrflag_SequenceNumber) SetU32(nv uint32) { switch nv { case 0: *v.p = nil case 1: if *v.p == nil { - *v.p = new(MuxedAccount) + *v.p = new(SequenceNumber) } default: - XdrPanic("*MuxedAccount present flag value %d should be 0 or 1", nv) + XdrPanic("*SequenceNumber present flag value %d should be 0 or 1", nv) } } -func (_ptrflag_MuxedAccount) XdrTypeName() string { return "MuxedAccount?" } -func (v _ptrflag_MuxedAccount) XdrPointer() interface{} { return nil } -func (v _ptrflag_MuxedAccount) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_MuxedAccount) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_MuxedAccount) XdrBound() uint32 { return 1 } -func (v _XdrPtr_MuxedAccount) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_MuxedAccount) SetPresent(present bool) { +func (_ptrflag_SequenceNumber) XdrTypeName() string { return "SequenceNumber?" } +func (v _ptrflag_SequenceNumber) XdrPointer() interface{} { return nil } +func (v _ptrflag_SequenceNumber) XdrValue() interface{} { return v.GetU32() != 0 } +func (v _ptrflag_SequenceNumber) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _ptrflag_SequenceNumber) XdrBound() uint32 { return 1 } +func (v _XdrPtr_SequenceNumber) GetPresent() bool { return *v.p != nil } +func (v _XdrPtr_SequenceNumber) SetPresent(present bool) { if !present { *v.p = nil } else if *v.p == nil { - *v.p = new(MuxedAccount) + *v.p = new(SequenceNumber) } } -func (v _XdrPtr_MuxedAccount) XdrMarshalValue(x XDR, name string) { +func (v _XdrPtr_SequenceNumber) XdrMarshalValue(x XDR, name string) { if *v.p != nil { - XDR_MuxedAccount(*v.p).XdrMarshal(x, name) + XDR_SequenceNumber(*v.p).XdrMarshal(x, name) } } -func (v _XdrPtr_MuxedAccount) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_MuxedAccount) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_MuxedAccount(v)) +func (v _XdrPtr_SequenceNumber) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v _XdrPtr_SequenceNumber) XdrRecurse(x XDR, name string) { + x.Marshal(name, _ptrflag_SequenceNumber(v)) v.XdrMarshalValue(x, name) } -func (_XdrPtr_MuxedAccount) XdrTypeName() string { return "MuxedAccount*" } -func (v _XdrPtr_MuxedAccount) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_MuxedAccount) XdrValue() interface{} { return *v.p } - -type XdrType_Operation = *Operation - -func (v *Operation) XdrPointer() interface{} { return v } -func (Operation) XdrTypeName() string { return "Operation" } -func (v Operation) XdrValue() interface{} { return v } -func (v *Operation) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *Operation) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%ssourceAccount", name), _XdrPtr_MuxedAccount{&v.SourceAccount}) - x.Marshal(x.Sprintf("%sbody", name), XDR_XdrAnon_Operation_Body(&v.Body)) -} -func XDR_Operation(v *Operation) *Operation { return v } - -type XdrType_XdrAnon_HashIDPreimage_OperationID = *XdrAnon_HashIDPreimage_OperationID - -func (v *XdrAnon_HashIDPreimage_OperationID) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_OperationID) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_OperationID" -} -func (v XdrAnon_HashIDPreimage_OperationID) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_OperationID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_HashIDPreimage_OperationID) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%ssourceAccount", name), XDR_AccountID(&v.SourceAccount)) - x.Marshal(x.Sprintf("%sseqNum", name), XDR_SequenceNumber(&v.SeqNum)) - x.Marshal(x.Sprintf("%sopNum", name), XDR_Uint32(&v.OpNum)) -} -func XDR_XdrAnon_HashIDPreimage_OperationID(v *XdrAnon_HashIDPreimage_OperationID) *XdrAnon_HashIDPreimage_OperationID { - return v -} - -type XdrType_XdrAnon_HashIDPreimage_RevokeID = *XdrAnon_HashIDPreimage_RevokeID - -func (v *XdrAnon_HashIDPreimage_RevokeID) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_RevokeID) XdrTypeName() string { return "XdrAnon_HashIDPreimage_RevokeID" } -func (v XdrAnon_HashIDPreimage_RevokeID) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_RevokeID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_HashIDPreimage_RevokeID) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%ssourceAccount", name), XDR_AccountID(&v.SourceAccount)) - x.Marshal(x.Sprintf("%sseqNum", name), XDR_SequenceNumber(&v.SeqNum)) - x.Marshal(x.Sprintf("%sopNum", name), XDR_Uint32(&v.OpNum)) - x.Marshal(x.Sprintf("%sliquidityPoolID", name), XDR_PoolID(&v.LiquidityPoolID)) - x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(&v.Asset)) -} -func XDR_XdrAnon_HashIDPreimage_RevokeID(v *XdrAnon_HashIDPreimage_RevokeID) *XdrAnon_HashIDPreimage_RevokeID { - return v -} - -type XdrType_XdrAnon_HashIDPreimage_ContractID = *XdrAnon_HashIDPreimage_ContractID - -func (v *XdrAnon_HashIDPreimage_ContractID) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_ContractID) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_ContractID" -} -func (v XdrAnon_HashIDPreimage_ContractID) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_ContractID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_HashIDPreimage_ContractID) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%snetworkID", name), XDR_Hash(&v.NetworkID)) - x.Marshal(x.Sprintf("%scontractIDPreimage", name), XDR_ContractIDPreimage(&v.ContractIDPreimage)) -} -func XDR_XdrAnon_HashIDPreimage_ContractID(v *XdrAnon_HashIDPreimage_ContractID) *XdrAnon_HashIDPreimage_ContractID { - return v -} - -type XdrType_XdrAnon_HashIDPreimage_SorobanAuthorization = *XdrAnon_HashIDPreimage_SorobanAuthorization - -func (v *XdrAnon_HashIDPreimage_SorobanAuthorization) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_SorobanAuthorization) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_SorobanAuthorization" -} -func (v XdrAnon_HashIDPreimage_SorobanAuthorization) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_SorobanAuthorization) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} -func (v *XdrAnon_HashIDPreimage_SorobanAuthorization) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%snetworkID", name), XDR_Hash(&v.NetworkID)) - x.Marshal(x.Sprintf("%snonce", name), XDR_Int64(&v.Nonce)) - x.Marshal(x.Sprintf("%ssignatureExpirationLedger", name), XDR_Uint32(&v.SignatureExpirationLedger)) - x.Marshal(x.Sprintf("%sinvocation", name), XDR_SorobanAuthorizedInvocation(&v.Invocation)) -} -func XDR_XdrAnon_HashIDPreimage_SorobanAuthorization(v *XdrAnon_HashIDPreimage_SorobanAuthorization) *XdrAnon_HashIDPreimage_SorobanAuthorization { - return v -} +func (_XdrPtr_SequenceNumber) XdrTypeName() string { return "SequenceNumber*" } +func (v _XdrPtr_SequenceNumber) XdrPointer() interface{} { return v.p } +func (v _XdrPtr_SequenceNumber) XdrValue() interface{} { return *v.p } -var _XdrTags_HashIDPreimage = map[int32]bool{ - XdrToI32(ENVELOPE_TYPE_OP_ID): true, - XdrToI32(ENVELOPE_TYPE_POOL_REVOKE_OP_ID): true, - XdrToI32(ENVELOPE_TYPE_CONTRACT_ID): true, - XdrToI32(ENVELOPE_TYPE_SOROBAN_AUTHORIZATION): true, -} +type _XdrVec_2_SignerKey []SignerKey -func (_ HashIDPreimage) XdrValidTags() map[int32]bool { - return _XdrTags_HashIDPreimage -} -func (u *HashIDPreimage) OperationID() *XdrAnon_HashIDPreimage_OperationID { - switch u.Type { - case ENVELOPE_TYPE_OP_ID: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_OperationID); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_OperationID - u._u = &zero - return &zero - } - default: - XdrPanic("HashIDPreimage.OperationID accessed when Type == %v", u.Type) - return nil - } +func (_XdrVec_2_SignerKey) XdrBound() uint32 { + const bound uint32 = 2 // Force error if not const or doesn't fit + return bound } -func (u *HashIDPreimage) RevokeID() *XdrAnon_HashIDPreimage_RevokeID { - switch u.Type { - case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_RevokeID); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_RevokeID - u._u = &zero - return &zero - } - default: - XdrPanic("HashIDPreimage.RevokeID accessed when Type == %v", u.Type) - return nil +func (_XdrVec_2_SignerKey) XdrCheckLen(length uint32) { + if length > uint32(2) { + XdrPanic("_XdrVec_2_SignerKey length %d exceeds bound 2", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_2_SignerKey length %d exceeds max int", length) } } -func (u *HashIDPreimage) ContractID() *XdrAnon_HashIDPreimage_ContractID { - switch u.Type { - case ENVELOPE_TYPE_CONTRACT_ID: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_ContractID); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_ContractID - u._u = &zero - return &zero +func (v _XdrVec_2_SignerKey) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_2_SignerKey) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] } - default: - XdrPanic("HashIDPreimage.ContractID accessed when Type == %v", u.Type) - return nil + return } -} -func (u *HashIDPreimage) SorobanAuthorization() *XdrAnon_HashIDPreimage_SorobanAuthorization { - switch u.Type { - case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_SorobanAuthorization); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_SorobanAuthorization - u._u = &zero - return &zero + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(2); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 } - default: - XdrPanic("HashIDPreimage.SorobanAuthorization accessed when Type == %v", u.Type) - return nil - } -} -func (u HashIDPreimage) XdrValid() bool { - switch u.Type { - case ENVELOPE_TYPE_OP_ID, ENVELOPE_TYPE_POOL_REVOKE_OP_ID, ENVELOPE_TYPE_CONTRACT_ID, ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: - return true - } - return false -} -func (u *HashIDPreimage) XdrUnionTag() XdrNum32 { - return XDR_EnvelopeType(&u.Type) -} -func (u *HashIDPreimage) XdrUnionTagName() string { - return "Type" -} -func (u *HashIDPreimage) XdrUnionBody() XdrType { - switch u.Type { - case ENVELOPE_TYPE_OP_ID: - return XDR_XdrAnon_HashIDPreimage_OperationID(u.OperationID()) - case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: - return XDR_XdrAnon_HashIDPreimage_RevokeID(u.RevokeID()) - case ENVELOPE_TYPE_CONTRACT_ID: - return XDR_XdrAnon_HashIDPreimage_ContractID(u.ContractID()) - case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: - return XDR_XdrAnon_HashIDPreimage_SorobanAuthorization(u.SorobanAuthorization()) + newcap = int(bound) } - return nil + nv := make([]SignerKey, int(length), newcap) + copy(nv, *v) + *v = nv } -func (u *HashIDPreimage) XdrUnionBodyName() string { - switch u.Type { - case ENVELOPE_TYPE_OP_ID: - return "OperationID" - case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: - return "RevokeID" - case ENVELOPE_TYPE_CONTRACT_ID: - return "ContractID" - case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: - return "SorobanAuthorization" +func (v *_XdrVec_2_SignerKey) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_SignerKey(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] } - return "" } +func (v *_XdrVec_2_SignerKey) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 2} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) +} +func (_XdrVec_2_SignerKey) XdrTypeName() string { return "SignerKey<>" } +func (v *_XdrVec_2_SignerKey) XdrPointer() interface{} { return (*[]SignerKey)(v) } +func (v _XdrVec_2_SignerKey) XdrValue() interface{} { return ([]SignerKey)(v) } +func (v *_XdrVec_2_SignerKey) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_HashIDPreimage = *HashIDPreimage +type XdrType_PreconditionsV2 = *PreconditionsV2 -func (v *HashIDPreimage) XdrPointer() interface{} { return v } -func (HashIDPreimage) XdrTypeName() string { return "HashIDPreimage" } -func (v HashIDPreimage) XdrValue() interface{} { return v } -func (v *HashIDPreimage) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *HashIDPreimage) XdrRecurse(x XDR, name string) { +func (v *PreconditionsV2) XdrPointer() interface{} { return v } +func (PreconditionsV2) XdrTypeName() string { return "PreconditionsV2" } +func (v PreconditionsV2) XdrValue() interface{} { return v } +func (v *PreconditionsV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *PreconditionsV2) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_EnvelopeType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case ENVELOPE_TYPE_OP_ID: - x.Marshal(x.Sprintf("%soperationID", name), XDR_XdrAnon_HashIDPreimage_OperationID(u.OperationID())) - return - case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: - x.Marshal(x.Sprintf("%srevokeID", name), XDR_XdrAnon_HashIDPreimage_RevokeID(u.RevokeID())) - return - case ENVELOPE_TYPE_CONTRACT_ID: - x.Marshal(x.Sprintf("%scontractID", name), XDR_XdrAnon_HashIDPreimage_ContractID(u.ContractID())) - return - case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: - x.Marshal(x.Sprintf("%ssorobanAuthorization", name), XDR_XdrAnon_HashIDPreimage_SorobanAuthorization(u.SorobanAuthorization())) - return - } - XdrPanic("invalid Type (%v) in HashIDPreimage", u.Type) -} -func (v *HashIDPreimage) XdrInitialize() { - var zero EnvelopeType - switch zero { - case ENVELOPE_TYPE_OP_ID, ENVELOPE_TYPE_POOL_REVOKE_OP_ID, ENVELOPE_TYPE_CONTRACT_ID, ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: - default: - if v.Type == zero { - v.Type = ENVELOPE_TYPE_OP_ID - } - } + x.Marshal(x.Sprintf("%stimeBounds", name), _XdrPtr_TimeBounds{&v.TimeBounds}) + x.Marshal(x.Sprintf("%sledgerBounds", name), _XdrPtr_LedgerBounds{&v.LedgerBounds}) + x.Marshal(x.Sprintf("%sminSeqNum", name), _XdrPtr_SequenceNumber{&v.MinSeqNum}) + x.Marshal(x.Sprintf("%sminSeqAge", name), XDR_Duration(&v.MinSeqAge)) + x.Marshal(x.Sprintf("%sminSeqLedgerGap", name), XDR_Uint32(&v.MinSeqLedgerGap)) + x.Marshal(x.Sprintf("%sextraSigners", name), (*_XdrVec_2_SignerKey)(&v.ExtraSigners)) } -func XDR_HashIDPreimage(v *HashIDPreimage) *HashIDPreimage { return v } +func XDR_PreconditionsV2(v *PreconditionsV2) *PreconditionsV2 { return v } -var _XdrNames_MemoType = map[int32]string{ - int32(MEMO_NONE): "MEMO_NONE", - int32(MEMO_TEXT): "MEMO_TEXT", - int32(MEMO_ID): "MEMO_ID", - int32(MEMO_HASH): "MEMO_HASH", - int32(MEMO_RETURN): "MEMO_RETURN", +var _XdrNames_PreconditionType = map[int32]string{ + int32(PRECOND_NONE): "PRECOND_NONE", + int32(PRECOND_TIME): "PRECOND_TIME", + int32(PRECOND_V2): "PRECOND_V2", } -var _XdrValues_MemoType = map[string]int32{ - "MEMO_NONE": int32(MEMO_NONE), - "MEMO_TEXT": int32(MEMO_TEXT), - "MEMO_ID": int32(MEMO_ID), - "MEMO_HASH": int32(MEMO_HASH), - "MEMO_RETURN": int32(MEMO_RETURN), +var _XdrValues_PreconditionType = map[string]int32{ + "PRECOND_NONE": int32(PRECOND_NONE), + "PRECOND_TIME": int32(PRECOND_TIME), + "PRECOND_V2": int32(PRECOND_V2), } -func (MemoType) XdrEnumNames() map[int32]string { - return _XdrNames_MemoType +func (PreconditionType) XdrEnumNames() map[int32]string { + return _XdrNames_PreconditionType } -func (v MemoType) String() string { - if s, ok := _XdrNames_MemoType[int32(v)]; ok { +func (v PreconditionType) String() string { + if s, ok := _XdrNames_PreconditionType[int32(v)]; ok { return s } - return fmt.Sprintf("MemoType#%d", v) + return fmt.Sprintf("PreconditionType#%d", v) } -func (v *MemoType) Scan(ss fmt.ScanState, _ rune) error { +func (v *PreconditionType) Scan(ss fmt.ScanState, _ rune) error { if tok, err := ss.Token(true, XdrSymChar); err != nil { return err } else { stok := string(tok) - if val, ok := _XdrValues_MemoType[stok]; ok { - *v = MemoType(val) + if val, ok := _XdrValues_PreconditionType[stok]; ok { + *v = PreconditionType(val) return nil - } else if stok == "MemoType" { + } else if stok == "PreconditionType" { if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { return nil } } - return XdrError(fmt.Sprintf("%s is not a valid MemoType.", stok)) + return XdrError(fmt.Sprintf("%s is not a valid PreconditionType.", stok)) } } -func (v MemoType) GetU32() uint32 { return uint32(v) } -func (v *MemoType) SetU32(n uint32) { *v = MemoType(n) } -func (v *MemoType) XdrPointer() interface{} { return v } -func (MemoType) XdrTypeName() string { return "MemoType" } -func (v MemoType) XdrValue() interface{} { return v } -func (v *MemoType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v PreconditionType) GetU32() uint32 { return uint32(v) } +func (v *PreconditionType) SetU32(n uint32) { *v = PreconditionType(n) } +func (v *PreconditionType) XdrPointer() interface{} { return v } +func (PreconditionType) XdrTypeName() string { return "PreconditionType" } +func (v PreconditionType) XdrValue() interface{} { return v } +func (v *PreconditionType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_MemoType = *MemoType +type XdrType_PreconditionType = *PreconditionType -func XDR_MemoType(v *MemoType) *MemoType { return v } +func XDR_PreconditionType(v *PreconditionType) *PreconditionType { return v } -var _XdrTags_Memo = map[int32]bool{ - XdrToI32(MEMO_NONE): true, - XdrToI32(MEMO_TEXT): true, - XdrToI32(MEMO_ID): true, - XdrToI32(MEMO_HASH): true, - XdrToI32(MEMO_RETURN): true, +var _XdrTags_Preconditions = map[int32]bool{ + XdrToI32(PRECOND_NONE): true, + XdrToI32(PRECOND_TIME): true, + XdrToI32(PRECOND_V2): true, } -func (_ Memo) XdrValidTags() map[int32]bool { - return _XdrTags_Memo -} -func (u *Memo) Text() *string { - switch u.Type { - case MEMO_TEXT: - if v, ok := u._u.(*string); ok { - return v - } else { - var zero string - u._u = &zero - return &zero - } - default: - XdrPanic("Memo.Text accessed when Type == %v", u.Type) - return nil - } -} -func (u *Memo) Id() *Uint64 { - switch u.Type { - case MEMO_ID: - if v, ok := u._u.(*Uint64); ok { - return v - } else { - var zero Uint64 - u._u = &zero - return &zero - } - default: - XdrPanic("Memo.Id accessed when Type == %v", u.Type) - return nil - } +func (_ Preconditions) XdrValidTags() map[int32]bool { + return _XdrTags_Preconditions } - -// the hash of what to pull from the content server -func (u *Memo) Hash() *Hash { +func (u *Preconditions) TimeBounds() *TimeBounds { switch u.Type { - case MEMO_HASH: - if v, ok := u._u.(*Hash); ok { + case PRECOND_TIME: + if v, ok := u._u.(*TimeBounds); ok { return v } else { - var zero Hash + var zero TimeBounds u._u = &zero return &zero } default: - XdrPanic("Memo.Hash accessed when Type == %v", u.Type) + XdrPanic("Preconditions.TimeBounds accessed when Type == %v", u.Type) return nil } } - -// the hash of the tx you are rejecting -func (u *Memo) RetHash() *Hash { +func (u *Preconditions) V2() *PreconditionsV2 { switch u.Type { - case MEMO_RETURN: - if v, ok := u._u.(*Hash); ok { + case PRECOND_V2: + if v, ok := u._u.(*PreconditionsV2); ok { return v } else { - var zero Hash + var zero PreconditionsV2 u._u = &zero return &zero } default: - XdrPanic("Memo.RetHash accessed when Type == %v", u.Type) + XdrPanic("Preconditions.V2 accessed when Type == %v", u.Type) return nil } } -func (u Memo) XdrValid() bool { +func (u Preconditions) XdrValid() bool { switch u.Type { - case MEMO_NONE, MEMO_TEXT, MEMO_ID, MEMO_HASH, MEMO_RETURN: + case PRECOND_NONE, PRECOND_TIME, PRECOND_V2: return true } return false } -func (u *Memo) XdrUnionTag() XdrNum32 { - return XDR_MemoType(&u.Type) +func (u *Preconditions) XdrUnionTag() XdrNum32 { + return XDR_PreconditionType(&u.Type) } -func (u *Memo) XdrUnionTagName() string { +func (u *Preconditions) XdrUnionTagName() string { return "Type" } -func (u *Memo) XdrUnionBody() XdrType { +func (u *Preconditions) XdrUnionBody() XdrType { switch u.Type { - case MEMO_NONE: + case PRECOND_NONE: return nil - case MEMO_TEXT: - return XdrString{u.Text(), 28} - case MEMO_ID: - return XDR_Uint64(u.Id()) - case MEMO_HASH: - return XDR_Hash(u.Hash()) - case MEMO_RETURN: - return XDR_Hash(u.RetHash()) + case PRECOND_TIME: + return XDR_TimeBounds(u.TimeBounds()) + case PRECOND_V2: + return XDR_PreconditionsV2(u.V2()) } return nil } -func (u *Memo) XdrUnionBodyName() string { +func (u *Preconditions) XdrUnionBodyName() string { switch u.Type { - case MEMO_NONE: + case PRECOND_NONE: return "" - case MEMO_TEXT: - return "Text" - case MEMO_ID: - return "Id" - case MEMO_HASH: - return "Hash" - case MEMO_RETURN: - return "RetHash" + case PRECOND_TIME: + return "TimeBounds" + case PRECOND_V2: + return "V2" } return "" } -type XdrType_Memo = *Memo +type XdrType_Preconditions = *Preconditions -func (v *Memo) XdrPointer() interface{} { return v } -func (Memo) XdrTypeName() string { return "Memo" } -func (v Memo) XdrValue() interface{} { return v } -func (v *Memo) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *Memo) XdrRecurse(x XDR, name string) { +func (v *Preconditions) XdrPointer() interface{} { return v } +func (Preconditions) XdrTypeName() string { return "Preconditions" } +func (v Preconditions) XdrValue() interface{} { return v } +func (v *Preconditions) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *Preconditions) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_MemoType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + XDR_PreconditionType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case MEMO_NONE: - return - case MEMO_TEXT: - x.Marshal(x.Sprintf("%stext", name), XdrString{u.Text(), 28}) - return - case MEMO_ID: - x.Marshal(x.Sprintf("%sid", name), XDR_Uint64(u.Id())) + case PRECOND_NONE: return - case MEMO_HASH: - x.Marshal(x.Sprintf("%shash", name), XDR_Hash(u.Hash())) + case PRECOND_TIME: + x.Marshal(x.Sprintf("%stimeBounds", name), XDR_TimeBounds(u.TimeBounds())) return - case MEMO_RETURN: - x.Marshal(x.Sprintf("%sretHash", name), XDR_Hash(u.RetHash())) + case PRECOND_V2: + x.Marshal(x.Sprintf("%sv2", name), XDR_PreconditionsV2(u.V2())) return } - XdrPanic("invalid Type (%v) in Memo", u.Type) + XdrPanic("invalid Type (%v) in Preconditions", u.Type) } -func XDR_Memo(v *Memo) *Memo { return v } +func XDR_Preconditions(v *Preconditions) *Preconditions { return v } -type XdrType_TimeBounds = *TimeBounds +type XdrType_LedgerFootprint = *LedgerFootprint -func (v *TimeBounds) XdrPointer() interface{} { return v } -func (TimeBounds) XdrTypeName() string { return "TimeBounds" } -func (v TimeBounds) XdrValue() interface{} { return v } -func (v *TimeBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TimeBounds) XdrRecurse(x XDR, name string) { +func (v *LedgerFootprint) XdrPointer() interface{} { return v } +func (LedgerFootprint) XdrTypeName() string { return "LedgerFootprint" } +func (v LedgerFootprint) XdrValue() interface{} { return v } +func (v *LedgerFootprint) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *LedgerFootprint) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sminTime", name), XDR_TimePoint(&v.MinTime)) - x.Marshal(x.Sprintf("%smaxTime", name), XDR_TimePoint(&v.MaxTime)) + x.Marshal(x.Sprintf("%sreadOnly", name), (*_XdrVec_unbounded_LedgerKey)(&v.ReadOnly)) + x.Marshal(x.Sprintf("%sreadWrite", name), (*_XdrVec_unbounded_LedgerKey)(&v.ReadWrite)) } -func XDR_TimeBounds(v *TimeBounds) *TimeBounds { return v } - -type XdrType_LedgerBounds = *LedgerBounds +func XDR_LedgerFootprint(v *LedgerFootprint) *LedgerFootprint { return v } -func (v *LedgerBounds) XdrPointer() interface{} { return v } -func (LedgerBounds) XdrTypeName() string { return "LedgerBounds" } -func (v LedgerBounds) XdrValue() interface{} { return v } -func (v *LedgerBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerBounds) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sminLedger", name), XDR_Uint32(&v.MinLedger)) - x.Marshal(x.Sprintf("%smaxLedger", name), XDR_Uint32(&v.MaxLedger)) +var _XdrNames_ArchivalProofType = map[int32]string{ + int32(EXISTENCE): "EXISTENCE", + int32(NONEXISTENCE): "NONEXISTENCE", } -func XDR_LedgerBounds(v *LedgerBounds) *LedgerBounds { return v } - -type _XdrPtr_TimeBounds struct { - p **TimeBounds +var _XdrValues_ArchivalProofType = map[string]int32{ + "EXISTENCE": int32(EXISTENCE), + "NONEXISTENCE": int32(NONEXISTENCE), } -type _ptrflag_TimeBounds _XdrPtr_TimeBounds -func (v _ptrflag_TimeBounds) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" -} -func (v _ptrflag_TimeBounds) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("TimeBounds flag should be \"nil\" or \"non-nil\"") - } - return nil +func (ArchivalProofType) XdrEnumNames() map[int32]string { + return _XdrNames_ArchivalProofType } -func (v _ptrflag_TimeBounds) GetU32() uint32 { - if *v.p == nil { - return 0 +func (v ArchivalProofType) String() string { + if s, ok := _XdrNames_ArchivalProofType[int32(v)]; ok { + return s } - return 1 + return fmt.Sprintf("ArchivalProofType#%d", v) } -func (v _ptrflag_TimeBounds) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(TimeBounds) +func (v *ArchivalProofType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_ArchivalProofType[stok]; ok { + *v = ArchivalProofType(val) + return nil + } else if stok == "ArchivalProofType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } } - default: - XdrPanic("*TimeBounds present flag value %d should be 0 or 1", nv) - } -} -func (_ptrflag_TimeBounds) XdrTypeName() string { return "TimeBounds?" } -func (v _ptrflag_TimeBounds) XdrPointer() interface{} { return nil } -func (v _ptrflag_TimeBounds) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_TimeBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_TimeBounds) XdrBound() uint32 { return 1 } -func (v _XdrPtr_TimeBounds) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_TimeBounds) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(TimeBounds) + return XdrError(fmt.Sprintf("%s is not a valid ArchivalProofType.", stok)) } } -func (v _XdrPtr_TimeBounds) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_TimeBounds(*v.p).XdrMarshal(x, name) +func (v ArchivalProofType) GetU32() uint32 { return uint32(v) } +func (v *ArchivalProofType) SetU32(n uint32) { *v = ArchivalProofType(n) } +func (v *ArchivalProofType) XdrPointer() interface{} { return v } +func (ArchivalProofType) XdrTypeName() string { return "ArchivalProofType" } +func (v ArchivalProofType) XdrValue() interface{} { return v } +func (v *ArchivalProofType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_ArchivalProofType = *ArchivalProofType + +func XDR_ArchivalProofType(v *ArchivalProofType) *ArchivalProofType { return v } + +type XdrType_ArchivalProofNode = *ArchivalProofNode + +func (v *ArchivalProofNode) XdrPointer() interface{} { return v } +func (ArchivalProofNode) XdrTypeName() string { return "ArchivalProofNode" } +func (v ArchivalProofNode) XdrValue() interface{} { return v } +func (v *ArchivalProofNode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ArchivalProofNode) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%sindex", name), XDR_Uint32(&v.Index)) + x.Marshal(x.Sprintf("%shash", name), XDR_Hash(&v.Hash)) } -func (v _XdrPtr_TimeBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_TimeBounds) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_TimeBounds(v)) - v.XdrMarshalValue(x, name) -} -func (_XdrPtr_TimeBounds) XdrTypeName() string { return "TimeBounds*" } -func (v _XdrPtr_TimeBounds) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_TimeBounds) XdrValue() interface{} { return *v.p } +func XDR_ArchivalProofNode(v *ArchivalProofNode) *ArchivalProofNode { return v } -type _XdrPtr_LedgerBounds struct { - p **LedgerBounds -} -type _ptrflag_LedgerBounds _XdrPtr_LedgerBounds +type _XdrVec_unbounded_ArchivalProofNode []ArchivalProofNode -func (v _ptrflag_LedgerBounds) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" +func (_XdrVec_unbounded_ArchivalProofNode) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v _ptrflag_LedgerBounds) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("LedgerBounds flag should be \"nil\" or \"non-nil\"") +func (_XdrVec_unbounded_ArchivalProofNode) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_ArchivalProofNode length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_ArchivalProofNode length %d exceeds max int", length) } - return nil } -func (v _ptrflag_LedgerBounds) GetU32() uint32 { - if *v.p == nil { - return 0 +func (v _XdrVec_unbounded_ArchivalProofNode) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_ArchivalProofNode) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] + } + return } - return 1 -} -func (v _ptrflag_LedgerBounds) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(LedgerBounds) + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 } - default: - XdrPanic("*LedgerBounds present flag value %d should be 0 or 1", nv) + newcap = int(bound) } + nv := make([]ArchivalProofNode, int(length), newcap) + copy(nv, *v) + *v = nv } -func (_ptrflag_LedgerBounds) XdrTypeName() string { return "LedgerBounds?" } -func (v _ptrflag_LedgerBounds) XdrPointer() interface{} { return nil } -func (v _ptrflag_LedgerBounds) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_LedgerBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_LedgerBounds) XdrBound() uint32 { return 1 } -func (v _XdrPtr_LedgerBounds) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_LedgerBounds) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(LedgerBounds) +func (v *_XdrVec_unbounded_ArchivalProofNode) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_ArchivalProofNode(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } -} -func (v _XdrPtr_LedgerBounds) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_LedgerBounds(*v.p).XdrMarshal(x, name) + if int(n) < len(*v) { + *v = (*v)[:int(n)] } } -func (v _XdrPtr_LedgerBounds) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_LedgerBounds) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_LedgerBounds(v)) - v.XdrMarshalValue(x, name) +func (v *_XdrVec_unbounded_ArchivalProofNode) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } -func (_XdrPtr_LedgerBounds) XdrTypeName() string { return "LedgerBounds*" } -func (v _XdrPtr_LedgerBounds) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_LedgerBounds) XdrValue() interface{} { return *v.p } +func (_XdrVec_unbounded_ArchivalProofNode) XdrTypeName() string { return "ArchivalProofNode<>" } +func (v *_XdrVec_unbounded_ArchivalProofNode) XdrPointer() interface{} { + return (*[]ArchivalProofNode)(v) +} +func (v _XdrVec_unbounded_ArchivalProofNode) XdrValue() interface{} { return ([]ArchivalProofNode)(v) } +func (v *_XdrVec_unbounded_ArchivalProofNode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type _XdrPtr_SequenceNumber struct { - p **SequenceNumber +type XdrType_ProofLevel struct { + *_XdrVec_unbounded_ArchivalProofNode } -type _ptrflag_SequenceNumber _XdrPtr_SequenceNumber -func (v _ptrflag_SequenceNumber) String() string { - if *v.p == nil { - return "nil" - } - return "non-nil" +func XDR_ProofLevel(v *ProofLevel) XdrType_ProofLevel { + return XdrType_ProofLevel{(*_XdrVec_unbounded_ArchivalProofNode)(v)} } -func (v _ptrflag_SequenceNumber) Scan(ss fmt.ScanState, r rune) error { - tok, err := ss.Token(true, func(c rune) bool { - return c == '-' || (c >= 'a' && c <= 'z') - }) - if err != nil { - return err - } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("SequenceNumber flag should be \"nil\" or \"non-nil\"") - } - return nil +func (XdrType_ProofLevel) XdrTypeName() string { return "ProofLevel" } +func (v XdrType_ProofLevel) XdrUnwrap() XdrType { return v._XdrVec_unbounded_ArchivalProofNode } + +type _XdrVec_unbounded_ColdArchiveBucketEntry []ColdArchiveBucketEntry + +func (_XdrVec_unbounded_ColdArchiveBucketEntry) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit + return bound } -func (v _ptrflag_SequenceNumber) GetU32() uint32 { - if *v.p == nil { - return 0 +func (_XdrVec_unbounded_ColdArchiveBucketEntry) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_ColdArchiveBucketEntry length %d exceeds bound 4294967295", length) + } else if int(length) < 0 { + XdrPanic("_XdrVec_unbounded_ColdArchiveBucketEntry length %d exceeds max int", length) } - return 1 } -func (v _ptrflag_SequenceNumber) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(SequenceNumber) +func (v _XdrVec_unbounded_ColdArchiveBucketEntry) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_ColdArchiveBucketEntry) SetVecLen(length uint32) { + v.XdrCheckLen(length) + if int(length) <= cap(*v) { + if int(length) != len(*v) { + *v = (*v)[:int(length)] } - default: - XdrPanic("*SequenceNumber present flag value %d should be 0 or 1", nv) + return } -} -func (_ptrflag_SequenceNumber) XdrTypeName() string { return "SequenceNumber?" } -func (v _ptrflag_SequenceNumber) XdrPointer() interface{} { return nil } -func (v _ptrflag_SequenceNumber) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_SequenceNumber) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_SequenceNumber) XdrBound() uint32 { return 1 } -func (v _XdrPtr_SequenceNumber) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_SequenceNumber) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(SequenceNumber) + newcap := 2 * cap(*v) + if newcap < int(length) { // also catches overflow where 2*cap < 0 + newcap = int(length) + } else if bound := uint(4294967295); uint(newcap) > bound { + if int(bound) < 0 { + bound = ^uint(0) >> 1 + } + newcap = int(bound) } + nv := make([]ColdArchiveBucketEntry, int(length), newcap) + copy(nv, *v) + *v = nv } -func (v _XdrPtr_SequenceNumber) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_SequenceNumber(*v.p).XdrMarshal(x, name) +func (v *_XdrVec_unbounded_ColdArchiveBucketEntry) XdrMarshalN(x XDR, name string, n uint32) { + v.XdrCheckLen(n) + for i := 0; i < int(n); i++ { + if i >= len(*v) { + v.SetVecLen(uint32(i + 1)) + } + XDR_ColdArchiveBucketEntry(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + } + if int(n) < len(*v) { + *v = (*v)[:int(n)] } } -func (v _XdrPtr_SequenceNumber) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_SequenceNumber) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_SequenceNumber(v)) - v.XdrMarshalValue(x, name) +func (v *_XdrVec_unbounded_ColdArchiveBucketEntry) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} + x.Marshal(name, &size) + v.XdrMarshalN(x, name, size.Size) } -func (_XdrPtr_SequenceNumber) XdrTypeName() string { return "SequenceNumber*" } -func (v _XdrPtr_SequenceNumber) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_SequenceNumber) XdrValue() interface{} { return *v.p } +func (_XdrVec_unbounded_ColdArchiveBucketEntry) XdrTypeName() string { + return "ColdArchiveBucketEntry<>" +} +func (v *_XdrVec_unbounded_ColdArchiveBucketEntry) XdrPointer() interface{} { + return (*[]ColdArchiveBucketEntry)(v) +} +func (v _XdrVec_unbounded_ColdArchiveBucketEntry) XdrValue() interface{} { + return ([]ColdArchiveBucketEntry)(v) +} +func (v *_XdrVec_unbounded_ColdArchiveBucketEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type _XdrVec_2_SignerKey []SignerKey +type _XdrVec_unbounded_ProofLevel []ProofLevel -func (_XdrVec_2_SignerKey) XdrBound() uint32 { - const bound uint32 = 2 // Force error if not const or doesn't fit +func (_XdrVec_unbounded_ProofLevel) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_2_SignerKey) XdrCheckLen(length uint32) { - if length > uint32(2) { - XdrPanic("_XdrVec_2_SignerKey length %d exceeds bound 2", length) +func (_XdrVec_unbounded_ProofLevel) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_ProofLevel length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_2_SignerKey length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_ProofLevel length %d exceeds max int", length) } } -func (v _XdrVec_2_SignerKey) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_2_SignerKey) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_ProofLevel) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_ProofLevel) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -18608,218 +19869,179 @@ func (v *_XdrVec_2_SignerKey) SetVecLen(length uint32) { newcap := 2 * cap(*v) if newcap < int(length) { // also catches overflow where 2*cap < 0 newcap = int(length) - } else if bound := uint(2); uint(newcap) > bound { + } else if bound := uint(4294967295); uint(newcap) > bound { if int(bound) < 0 { bound = ^uint(0) >> 1 } newcap = int(bound) } - nv := make([]SignerKey, int(length), newcap) + nv := make([]ProofLevel, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_2_SignerKey) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_ProofLevel) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { v.SetVecLen(uint32(i + 1)) } - XDR_SignerKey(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_ProofLevel(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) } if int(n) < len(*v) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_2_SignerKey) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 2} +func (v *_XdrVec_unbounded_ProofLevel) XdrRecurse(x XDR, name string) { + size := XdrSize{Size: uint32(len(*v)), Bound: 4294967295} x.Marshal(name, &size) v.XdrMarshalN(x, name, size.Size) } -func (_XdrVec_2_SignerKey) XdrTypeName() string { return "SignerKey<>" } -func (v *_XdrVec_2_SignerKey) XdrPointer() interface{} { return (*[]SignerKey)(v) } -func (v _XdrVec_2_SignerKey) XdrValue() interface{} { return ([]SignerKey)(v) } -func (v *_XdrVec_2_SignerKey) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (_XdrVec_unbounded_ProofLevel) XdrTypeName() string { return "ProofLevel<>" } +func (v *_XdrVec_unbounded_ProofLevel) XdrPointer() interface{} { return (*[]ProofLevel)(v) } +func (v _XdrVec_unbounded_ProofLevel) XdrValue() interface{} { return ([]ProofLevel)(v) } +func (v *_XdrVec_unbounded_ProofLevel) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_PreconditionsV2 = *PreconditionsV2 +type XdrType_NonexistenceProofBody = *NonexistenceProofBody -func (v *PreconditionsV2) XdrPointer() interface{} { return v } -func (PreconditionsV2) XdrTypeName() string { return "PreconditionsV2" } -func (v PreconditionsV2) XdrValue() interface{} { return v } -func (v *PreconditionsV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *PreconditionsV2) XdrRecurse(x XDR, name string) { +func (v *NonexistenceProofBody) XdrPointer() interface{} { return v } +func (NonexistenceProofBody) XdrTypeName() string { return "NonexistenceProofBody" } +func (v NonexistenceProofBody) XdrValue() interface{} { return v } +func (v *NonexistenceProofBody) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *NonexistenceProofBody) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%stimeBounds", name), _XdrPtr_TimeBounds{&v.TimeBounds}) - x.Marshal(x.Sprintf("%sledgerBounds", name), _XdrPtr_LedgerBounds{&v.LedgerBounds}) - x.Marshal(x.Sprintf("%sminSeqNum", name), _XdrPtr_SequenceNumber{&v.MinSeqNum}) - x.Marshal(x.Sprintf("%sminSeqAge", name), XDR_Duration(&v.MinSeqAge)) - x.Marshal(x.Sprintf("%sminSeqLedgerGap", name), XDR_Uint32(&v.MinSeqLedgerGap)) - x.Marshal(x.Sprintf("%sextraSigners", name), (*_XdrVec_2_SignerKey)(&v.ExtraSigners)) + x.Marshal(x.Sprintf("%sentriesToProve", name), (*_XdrVec_unbounded_ColdArchiveBucketEntry)(&v.EntriesToProve)) + x.Marshal(x.Sprintf("%sproofLevels", name), (*_XdrVec_unbounded_ProofLevel)(&v.ProofLevels)) } -func XDR_PreconditionsV2(v *PreconditionsV2) *PreconditionsV2 { return v } +func XDR_NonexistenceProofBody(v *NonexistenceProofBody) *NonexistenceProofBody { return v } -var _XdrNames_PreconditionType = map[int32]string{ - int32(PRECOND_NONE): "PRECOND_NONE", - int32(PRECOND_TIME): "PRECOND_TIME", - int32(PRECOND_V2): "PRECOND_V2", -} -var _XdrValues_PreconditionType = map[string]int32{ - "PRECOND_NONE": int32(PRECOND_NONE), - "PRECOND_TIME": int32(PRECOND_TIME), - "PRECOND_V2": int32(PRECOND_V2), -} +type XdrType_ExistenceProofBody = *ExistenceProofBody -func (PreconditionType) XdrEnumNames() map[int32]string { - return _XdrNames_PreconditionType -} -func (v PreconditionType) String() string { - if s, ok := _XdrNames_PreconditionType[int32(v)]; ok { - return s - } - return fmt.Sprintf("PreconditionType#%d", v) -} -func (v *PreconditionType) Scan(ss fmt.ScanState, _ rune) error { - if tok, err := ss.Token(true, XdrSymChar); err != nil { - return err - } else { - stok := string(tok) - if val, ok := _XdrValues_PreconditionType[stok]; ok { - *v = PreconditionType(val) - return nil - } else if stok == "PreconditionType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid PreconditionType.", stok)) +func (v *ExistenceProofBody) XdrPointer() interface{} { return v } +func (ExistenceProofBody) XdrTypeName() string { return "ExistenceProofBody" } +func (v ExistenceProofBody) XdrValue() interface{} { return v } +func (v *ExistenceProofBody) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ExistenceProofBody) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) } + x.Marshal(x.Sprintf("%skeysToProve", name), (*_XdrVec_unbounded_LedgerKey)(&v.KeysToProve)) + x.Marshal(x.Sprintf("%slowBoundEntries", name), (*_XdrVec_unbounded_ColdArchiveBucketEntry)(&v.LowBoundEntries)) + x.Marshal(x.Sprintf("%shighBoundEntries", name), (*_XdrVec_unbounded_ColdArchiveBucketEntry)(&v.HighBoundEntries)) + x.Marshal(x.Sprintf("%sproofLevels", name), (*_XdrVec_unbounded_ProofLevel)(&v.ProofLevels)) } -func (v PreconditionType) GetU32() uint32 { return uint32(v) } -func (v *PreconditionType) SetU32(n uint32) { *v = PreconditionType(n) } -func (v *PreconditionType) XdrPointer() interface{} { return v } -func (PreconditionType) XdrTypeName() string { return "PreconditionType" } -func (v PreconditionType) XdrValue() interface{} { return v } -func (v *PreconditionType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_PreconditionType = *PreconditionType +func XDR_ExistenceProofBody(v *ExistenceProofBody) *ExistenceProofBody { return v } -func XDR_PreconditionType(v *PreconditionType) *PreconditionType { return v } - -var _XdrTags_Preconditions = map[int32]bool{ - XdrToI32(PRECOND_NONE): true, - XdrToI32(PRECOND_TIME): true, - XdrToI32(PRECOND_V2): true, +var _XdrTags_XdrAnon_ArchivalProof_Body = map[int32]bool{ + XdrToI32(EXISTENCE): true, + XdrToI32(NONEXISTENCE): true, } -func (_ Preconditions) XdrValidTags() map[int32]bool { - return _XdrTags_Preconditions +func (_ XdrAnon_ArchivalProof_Body) XdrValidTags() map[int32]bool { + return _XdrTags_XdrAnon_ArchivalProof_Body } -func (u *Preconditions) TimeBounds() *TimeBounds { - switch u.Type { - case PRECOND_TIME: - if v, ok := u._u.(*TimeBounds); ok { +func (u *XdrAnon_ArchivalProof_Body) NonexistenceProof() *NonexistenceProofBody { + switch u.T { + case EXISTENCE: + if v, ok := u._u.(*NonexistenceProofBody); ok { return v } else { - var zero TimeBounds + var zero NonexistenceProofBody u._u = &zero return &zero } default: - XdrPanic("Preconditions.TimeBounds accessed when Type == %v", u.Type) + XdrPanic("XdrAnon_ArchivalProof_Body.NonexistenceProof accessed when T == %v", u.T) return nil } } -func (u *Preconditions) V2() *PreconditionsV2 { - switch u.Type { - case PRECOND_V2: - if v, ok := u._u.(*PreconditionsV2); ok { +func (u *XdrAnon_ArchivalProof_Body) ExistenceProof() *ExistenceProofBody { + switch u.T { + case NONEXISTENCE: + if v, ok := u._u.(*ExistenceProofBody); ok { return v } else { - var zero PreconditionsV2 + var zero ExistenceProofBody u._u = &zero return &zero } default: - XdrPanic("Preconditions.V2 accessed when Type == %v", u.Type) + XdrPanic("XdrAnon_ArchivalProof_Body.ExistenceProof accessed when T == %v", u.T) return nil } } -func (u Preconditions) XdrValid() bool { - switch u.Type { - case PRECOND_NONE, PRECOND_TIME, PRECOND_V2: +func (u XdrAnon_ArchivalProof_Body) XdrValid() bool { + switch u.T { + case EXISTENCE, NONEXISTENCE: return true } return false } -func (u *Preconditions) XdrUnionTag() XdrNum32 { - return XDR_PreconditionType(&u.Type) +func (u *XdrAnon_ArchivalProof_Body) XdrUnionTag() XdrNum32 { + return XDR_ArchivalProofType(&u.T) } -func (u *Preconditions) XdrUnionTagName() string { - return "Type" +func (u *XdrAnon_ArchivalProof_Body) XdrUnionTagName() string { + return "T" } -func (u *Preconditions) XdrUnionBody() XdrType { - switch u.Type { - case PRECOND_NONE: - return nil - case PRECOND_TIME: - return XDR_TimeBounds(u.TimeBounds()) - case PRECOND_V2: - return XDR_PreconditionsV2(u.V2()) +func (u *XdrAnon_ArchivalProof_Body) XdrUnionBody() XdrType { + switch u.T { + case EXISTENCE: + return XDR_NonexistenceProofBody(u.NonexistenceProof()) + case NONEXISTENCE: + return XDR_ExistenceProofBody(u.ExistenceProof()) } return nil } -func (u *Preconditions) XdrUnionBodyName() string { - switch u.Type { - case PRECOND_NONE: - return "" - case PRECOND_TIME: - return "TimeBounds" - case PRECOND_V2: - return "V2" +func (u *XdrAnon_ArchivalProof_Body) XdrUnionBodyName() string { + switch u.T { + case EXISTENCE: + return "NonexistenceProof" + case NONEXISTENCE: + return "ExistenceProof" } return "" } -type XdrType_Preconditions = *Preconditions +type XdrType_XdrAnon_ArchivalProof_Body = *XdrAnon_ArchivalProof_Body -func (v *Preconditions) XdrPointer() interface{} { return v } -func (Preconditions) XdrTypeName() string { return "Preconditions" } -func (v Preconditions) XdrValue() interface{} { return v } -func (v *Preconditions) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *Preconditions) XdrRecurse(x XDR, name string) { +func (v *XdrAnon_ArchivalProof_Body) XdrPointer() interface{} { return v } +func (XdrAnon_ArchivalProof_Body) XdrTypeName() string { return "XdrAnon_ArchivalProof_Body" } +func (v XdrAnon_ArchivalProof_Body) XdrValue() interface{} { return v } +func (v *XdrAnon_ArchivalProof_Body) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *XdrAnon_ArchivalProof_Body) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_PreconditionType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case PRECOND_NONE: + XDR_ArchivalProofType(&u.T).XdrMarshal(x, x.Sprintf("%st", name)) + switch u.T { + case EXISTENCE: + x.Marshal(x.Sprintf("%snonexistenceProof", name), XDR_NonexistenceProofBody(u.NonexistenceProof())) return - case PRECOND_TIME: - x.Marshal(x.Sprintf("%stimeBounds", name), XDR_TimeBounds(u.TimeBounds())) - return - case PRECOND_V2: - x.Marshal(x.Sprintf("%sv2", name), XDR_PreconditionsV2(u.V2())) + case NONEXISTENCE: + x.Marshal(x.Sprintf("%sexistenceProof", name), XDR_ExistenceProofBody(u.ExistenceProof())) return } - XdrPanic("invalid Type (%v) in Preconditions", u.Type) + XdrPanic("invalid T (%v) in XdrAnon_ArchivalProof_Body", u.T) +} +func XDR_XdrAnon_ArchivalProof_Body(v *XdrAnon_ArchivalProof_Body) *XdrAnon_ArchivalProof_Body { + return v } -func XDR_Preconditions(v *Preconditions) *Preconditions { return v } -type XdrType_LedgerFootprint = *LedgerFootprint +type XdrType_ArchivalProof = *ArchivalProof -func (v *LedgerFootprint) XdrPointer() interface{} { return v } -func (LedgerFootprint) XdrTypeName() string { return "LedgerFootprint" } -func (v LedgerFootprint) XdrValue() interface{} { return v } -func (v *LedgerFootprint) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerFootprint) XdrRecurse(x XDR, name string) { +func (v *ArchivalProof) XdrPointer() interface{} { return v } +func (ArchivalProof) XdrTypeName() string { return "ArchivalProof" } +func (v ArchivalProof) XdrValue() interface{} { return v } +func (v *ArchivalProof) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ArchivalProof) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%sreadOnly", name), (*_XdrVec_unbounded_LedgerKey)(&v.ReadOnly)) - x.Marshal(x.Sprintf("%sreadWrite", name), (*_XdrVec_unbounded_LedgerKey)(&v.ReadWrite)) + x.Marshal(x.Sprintf("%sepoch", name), XDR_Uint32(&v.Epoch)) + x.Marshal(x.Sprintf("%sbody", name), XDR_XdrAnon_ArchivalProof_Body(&v.Body)) } -func XDR_LedgerFootprint(v *LedgerFootprint) *LedgerFootprint { return v } +func XDR_ArchivalProof(v *ArchivalProof) *ArchivalProof { return v } type XdrType_SorobanResources = *SorobanResources @@ -25832,6 +27054,91 @@ func (v *HmacSha256Mac) XdrRecurse(x XDR, name string) { } func XDR_HmacSha256Mac(v *HmacSha256Mac) *HmacSha256Mac { return v } +type XdrType_ShortHashSeed = *ShortHashSeed + +func (v *ShortHashSeed) XdrPointer() interface{} { return v } +func (ShortHashSeed) XdrTypeName() string { return "ShortHashSeed" } +func (v ShortHashSeed) XdrValue() interface{} { return v } +func (v *ShortHashSeed) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *ShortHashSeed) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sseed", name), (*_XdrArray_16_opaque)(&v.Seed)) +} +func XDR_ShortHashSeed(v *ShortHashSeed) *ShortHashSeed { return v } + +var _XdrNames_BinaryFuseFilterType = map[int32]string{ + int32(BINARY_FUSE_FILTER_8_BIT): "BINARY_FUSE_FILTER_8_BIT", + int32(BINARY_FUSE_FILTER_16_BIT): "BINARY_FUSE_FILTER_16_BIT", + int32(BINARY_FUSE_FILTER_32_BIT): "BINARY_FUSE_FILTER_32_BIT", +} +var _XdrValues_BinaryFuseFilterType = map[string]int32{ + "BINARY_FUSE_FILTER_8_BIT": int32(BINARY_FUSE_FILTER_8_BIT), + "BINARY_FUSE_FILTER_16_BIT": int32(BINARY_FUSE_FILTER_16_BIT), + "BINARY_FUSE_FILTER_32_BIT": int32(BINARY_FUSE_FILTER_32_BIT), +} + +func (BinaryFuseFilterType) XdrEnumNames() map[int32]string { + return _XdrNames_BinaryFuseFilterType +} +func (v BinaryFuseFilterType) String() string { + if s, ok := _XdrNames_BinaryFuseFilterType[int32(v)]; ok { + return s + } + return fmt.Sprintf("BinaryFuseFilterType#%d", v) +} +func (v *BinaryFuseFilterType) Scan(ss fmt.ScanState, _ rune) error { + if tok, err := ss.Token(true, XdrSymChar); err != nil { + return err + } else { + stok := string(tok) + if val, ok := _XdrValues_BinaryFuseFilterType[stok]; ok { + *v = BinaryFuseFilterType(val) + return nil + } else if stok == "BinaryFuseFilterType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid BinaryFuseFilterType.", stok)) + } +} +func (v BinaryFuseFilterType) GetU32() uint32 { return uint32(v) } +func (v *BinaryFuseFilterType) SetU32(n uint32) { *v = BinaryFuseFilterType(n) } +func (v *BinaryFuseFilterType) XdrPointer() interface{} { return v } +func (BinaryFuseFilterType) XdrTypeName() string { return "BinaryFuseFilterType" } +func (v BinaryFuseFilterType) XdrValue() interface{} { return v } +func (v *BinaryFuseFilterType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_BinaryFuseFilterType = *BinaryFuseFilterType + +func XDR_BinaryFuseFilterType(v *BinaryFuseFilterType) *BinaryFuseFilterType { return v } + +type XdrType_SerializedBinaryFuseFilter = *SerializedBinaryFuseFilter + +func (v *SerializedBinaryFuseFilter) XdrPointer() interface{} { return v } +func (SerializedBinaryFuseFilter) XdrTypeName() string { return "SerializedBinaryFuseFilter" } +func (v SerializedBinaryFuseFilter) XdrValue() interface{} { return v } +func (v *SerializedBinaryFuseFilter) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SerializedBinaryFuseFilter) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%stype", name), XDR_BinaryFuseFilterType(&v.Type)) + x.Marshal(x.Sprintf("%sinputHashSeed", name), XDR_ShortHashSeed(&v.InputHashSeed)) + x.Marshal(x.Sprintf("%sfilterSeed", name), XDR_ShortHashSeed(&v.FilterSeed)) + x.Marshal(x.Sprintf("%ssegmentLength", name), XDR_Uint32(&v.SegmentLength)) + x.Marshal(x.Sprintf("%ssegementLengthMask", name), XDR_Uint32(&v.SegementLengthMask)) + x.Marshal(x.Sprintf("%ssegmentCount", name), XDR_Uint32(&v.SegmentCount)) + x.Marshal(x.Sprintf("%ssegmentCountLength", name), XDR_Uint32(&v.SegmentCountLength)) + x.Marshal(x.Sprintf("%sfingerprintLength", name), XDR_Uint32(&v.FingerprintLength)) + x.Marshal(x.Sprintf("%sfingerprints", name), XdrVecOpaque{&v.Fingerprints, 0xffffffff}) +} +func XDR_SerializedBinaryFuseFilter(v *SerializedBinaryFuseFilter) *SerializedBinaryFuseFilter { + return v +} + var _XdrNames_SCEnvMetaKind = map[int32]string{ int32(SC_ENV_META_KIND_INTERFACE_VERSION): "SC_ENV_META_KIND_INTERFACE_VERSION", } @@ -25875,6 +27182,25 @@ type XdrType_SCEnvMetaKind = *SCEnvMetaKind func XDR_SCEnvMetaKind(v *SCEnvMetaKind) *SCEnvMetaKind { return v } +type XdrType_XdrAnon_SCEnvMetaEntry_InterfaceVersion = *XdrAnon_SCEnvMetaEntry_InterfaceVersion + +func (v *XdrAnon_SCEnvMetaEntry_InterfaceVersion) XdrPointer() interface{} { return v } +func (XdrAnon_SCEnvMetaEntry_InterfaceVersion) XdrTypeName() string { + return "XdrAnon_SCEnvMetaEntry_InterfaceVersion" +} +func (v XdrAnon_SCEnvMetaEntry_InterfaceVersion) XdrValue() interface{} { return v } +func (v *XdrAnon_SCEnvMetaEntry_InterfaceVersion) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *XdrAnon_SCEnvMetaEntry_InterfaceVersion) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sprotocol", name), XDR_Uint32(&v.Protocol)) + x.Marshal(x.Sprintf("%spreRelease", name), XDR_Uint32(&v.PreRelease)) +} +func XDR_XdrAnon_SCEnvMetaEntry_InterfaceVersion(v *XdrAnon_SCEnvMetaEntry_InterfaceVersion) *XdrAnon_SCEnvMetaEntry_InterfaceVersion { + return v +} + var _XdrTags_SCEnvMetaEntry = map[int32]bool{ XdrToI32(SC_ENV_META_KIND_INTERFACE_VERSION): true, } @@ -25882,13 +27208,13 @@ var _XdrTags_SCEnvMetaEntry = map[int32]bool{ func (_ SCEnvMetaEntry) XdrValidTags() map[int32]bool { return _XdrTags_SCEnvMetaEntry } -func (u *SCEnvMetaEntry) InterfaceVersion() *Uint64 { +func (u *SCEnvMetaEntry) InterfaceVersion() *XdrAnon_SCEnvMetaEntry_InterfaceVersion { switch u.Kind { case SC_ENV_META_KIND_INTERFACE_VERSION: - if v, ok := u._u.(*Uint64); ok { + if v, ok := u._u.(*XdrAnon_SCEnvMetaEntry_InterfaceVersion); ok { return v } else { - var zero Uint64 + var zero XdrAnon_SCEnvMetaEntry_InterfaceVersion u._u = &zero return &zero } @@ -25913,7 +27239,7 @@ func (u *SCEnvMetaEntry) XdrUnionTagName() string { func (u *SCEnvMetaEntry) XdrUnionBody() XdrType { switch u.Kind { case SC_ENV_META_KIND_INTERFACE_VERSION: - return XDR_Uint64(u.InterfaceVersion()) + return XDR_XdrAnon_SCEnvMetaEntry_InterfaceVersion(u.InterfaceVersion()) } return nil } @@ -25938,7 +27264,7 @@ func (u *SCEnvMetaEntry) XdrRecurse(x XDR, name string) { XDR_SCEnvMetaKind(&u.Kind).XdrMarshal(x, x.Sprintf("%skind", name)) switch u.Kind { case SC_ENV_META_KIND_INTERFACE_VERSION: - x.Marshal(x.Sprintf("%sinterfaceVersion", name), XDR_Uint64(u.InterfaceVersion())) + x.Marshal(x.Sprintf("%sinterfaceVersion", name), XDR_XdrAnon_SCEnvMetaEntry_InterfaceVersion(u.InterfaceVersion())) return } XdrPanic("invalid Kind (%v) in SCEnvMetaEntry", u.Kind) @@ -29413,6 +30739,31 @@ var _XdrNames_ContractCostType = map[int32]string{ int32(InstantiateWasmDataSegmentBytes): "InstantiateWasmDataSegmentBytes", int32(Sec1DecodePointUncompressed): "Sec1DecodePointUncompressed", int32(VerifyEcdsaSecp256r1Sig): "VerifyEcdsaSecp256r1Sig", + int32(Bls12381EncodeFp): "Bls12381EncodeFp", + int32(Bls12381DecodeFp): "Bls12381DecodeFp", + int32(Bls12381G1CheckPointOnCurve): "Bls12381G1CheckPointOnCurve", + int32(Bls12381G1CheckPointInSubgroup): "Bls12381G1CheckPointInSubgroup", + int32(Bls12381G2CheckPointOnCurve): "Bls12381G2CheckPointOnCurve", + int32(Bls12381G2CheckPointInSubgroup): "Bls12381G2CheckPointInSubgroup", + int32(Bls12381G1ProjectiveToAffine): "Bls12381G1ProjectiveToAffine", + int32(Bls12381G2ProjectiveToAffine): "Bls12381G2ProjectiveToAffine", + int32(Bls12381G1Add): "Bls12381G1Add", + int32(Bls12381G1Mul): "Bls12381G1Mul", + int32(Bls12381G1Msm): "Bls12381G1Msm", + int32(Bls12381MapFpToG1): "Bls12381MapFpToG1", + int32(Bls12381HashToG1): "Bls12381HashToG1", + int32(Bls12381G2Add): "Bls12381G2Add", + int32(Bls12381G2Mul): "Bls12381G2Mul", + int32(Bls12381G2Msm): "Bls12381G2Msm", + int32(Bls12381MapFp2ToG2): "Bls12381MapFp2ToG2", + int32(Bls12381HashToG2): "Bls12381HashToG2", + int32(Bls12381Pairing): "Bls12381Pairing", + int32(Bls12381FrFromU256): "Bls12381FrFromU256", + int32(Bls12381FrToU256): "Bls12381FrToU256", + int32(Bls12381FrAddSub): "Bls12381FrAddSub", + int32(Bls12381FrMul): "Bls12381FrMul", + int32(Bls12381FrPow): "Bls12381FrPow", + int32(Bls12381FrInv): "Bls12381FrInv", } var _XdrValues_ContractCostType = map[string]int32{ "WasmInsnExec": int32(WasmInsnExec), @@ -29460,6 +30811,31 @@ var _XdrValues_ContractCostType = map[string]int32{ "InstantiateWasmDataSegmentBytes": int32(InstantiateWasmDataSegmentBytes), "Sec1DecodePointUncompressed": int32(Sec1DecodePointUncompressed), "VerifyEcdsaSecp256r1Sig": int32(VerifyEcdsaSecp256r1Sig), + "Bls12381EncodeFp": int32(Bls12381EncodeFp), + "Bls12381DecodeFp": int32(Bls12381DecodeFp), + "Bls12381G1CheckPointOnCurve": int32(Bls12381G1CheckPointOnCurve), + "Bls12381G1CheckPointInSubgroup": int32(Bls12381G1CheckPointInSubgroup), + "Bls12381G2CheckPointOnCurve": int32(Bls12381G2CheckPointOnCurve), + "Bls12381G2CheckPointInSubgroup": int32(Bls12381G2CheckPointInSubgroup), + "Bls12381G1ProjectiveToAffine": int32(Bls12381G1ProjectiveToAffine), + "Bls12381G2ProjectiveToAffine": int32(Bls12381G2ProjectiveToAffine), + "Bls12381G1Add": int32(Bls12381G1Add), + "Bls12381G1Mul": int32(Bls12381G1Mul), + "Bls12381G1Msm": int32(Bls12381G1Msm), + "Bls12381MapFpToG1": int32(Bls12381MapFpToG1), + "Bls12381HashToG1": int32(Bls12381HashToG1), + "Bls12381G2Add": int32(Bls12381G2Add), + "Bls12381G2Mul": int32(Bls12381G2Mul), + "Bls12381G2Msm": int32(Bls12381G2Msm), + "Bls12381MapFp2ToG2": int32(Bls12381MapFp2ToG2), + "Bls12381HashToG2": int32(Bls12381HashToG2), + "Bls12381Pairing": int32(Bls12381Pairing), + "Bls12381FrFromU256": int32(Bls12381FrFromU256), + "Bls12381FrToU256": int32(Bls12381FrToU256), + "Bls12381FrAddSub": int32(Bls12381FrAddSub), + "Bls12381FrMul": int32(Bls12381FrMul), + "Bls12381FrPow": int32(Bls12381FrPow), + "Bls12381FrInv": int32(Bls12381FrInv), } func (ContractCostType) XdrEnumNames() map[int32]string { @@ -29544,6 +30920,31 @@ var _XdrComments_ContractCostType = map[int32]string{ int32(InstantiateWasmDataSegmentBytes): "Cost of instantiating a known number of data segment bytes.", int32(Sec1DecodePointUncompressed): "Cost of decoding a bytes array representing an uncompressed SEC-1 encoded point on a 256-bit elliptic curve", int32(VerifyEcdsaSecp256r1Sig): "Cost of verifying an ECDSA Secp256r1 signature", + int32(Bls12381EncodeFp): "Cost of encoding a BLS12-381 Fp (base field element)", + int32(Bls12381DecodeFp): "Cost of decoding a BLS12-381 Fp (base field element)", + int32(Bls12381G1CheckPointOnCurve): "Cost of checking a G1 point lies on the curve", + int32(Bls12381G1CheckPointInSubgroup): "Cost of checking a G1 point belongs to the correct subgroup", + int32(Bls12381G2CheckPointOnCurve): "Cost of checking a G2 point lies on the curve", + int32(Bls12381G2CheckPointInSubgroup): "Cost of checking a G2 point belongs to the correct subgroup", + int32(Bls12381G1ProjectiveToAffine): "Cost of converting a BLS12-381 G1 point from projective to affine coordinates", + int32(Bls12381G2ProjectiveToAffine): "Cost of converting a BLS12-381 G2 point from projective to affine coordinates", + int32(Bls12381G1Add): "Cost of performing BLS12-381 G1 point addition", + int32(Bls12381G1Mul): "Cost of performing BLS12-381 G1 scalar multiplication", + int32(Bls12381G1Msm): "Cost of performing BLS12-381 G1 multi-scalar multiplication (MSM)", + int32(Bls12381MapFpToG1): "Cost of mapping a BLS12-381 Fp field element to a G1 point", + int32(Bls12381HashToG1): "Cost of hashing to a BLS12-381 G1 point", + int32(Bls12381G2Add): "Cost of performing BLS12-381 G2 point addition", + int32(Bls12381G2Mul): "Cost of performing BLS12-381 G2 scalar multiplication", + int32(Bls12381G2Msm): "Cost of performing BLS12-381 G2 multi-scalar multiplication (MSM)", + int32(Bls12381MapFp2ToG2): "Cost of mapping a BLS12-381 Fp2 field element to a G2 point", + int32(Bls12381HashToG2): "Cost of hashing to a BLS12-381 G2 point", + int32(Bls12381Pairing): "Cost of performing BLS12-381 pairing operation", + int32(Bls12381FrFromU256): "Cost of converting a BLS12-381 scalar element from U256", + int32(Bls12381FrToU256): "Cost of converting a BLS12-381 scalar element to U256", + int32(Bls12381FrAddSub): "Cost of performing BLS12-381 scalar element addition/subtraction", + int32(Bls12381FrMul): "Cost of performing BLS12-381 scalar element multiplication", + int32(Bls12381FrPow): "Cost of performing BLS12-381 scalar element exponentiation", + int32(Bls12381FrInv): "Cost of performing BLS12-381 scalar element inversion", } func (e ContractCostType) XdrEnumComments() map[int32]string { diff --git a/ingest/cdp/producer_test.go b/ingest/cdp/producer_test.go index ba3c10bc9b..e7605b4512 100644 --- a/ingest/cdp/producer_test.go +++ b/ingest/cdp/producer_test.go @@ -10,13 +10,14 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stellar/go/ingest/ledgerbackend" "github.com/stellar/go/support/compressxdr" "github.com/stellar/go/support/datastore" "github.com/stellar/go/support/errors" "github.com/stellar/go/xdr" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" ) func TestDefaultBSBConfigs(t *testing.T) { @@ -189,46 +190,6 @@ func TestBSBProducerFnGetLedgerError(t *testing.T) { mockDataStore.AssertExpectations(t) } -func TestBSBProducerCallerCancelsCtx(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - pubConfig := PublisherConfig{ - DataStoreConfig: datastore.DataStoreConfig{}, - BufferedStorageConfig: DefaultBufferedStorageBackendConfig(1), - } - - pubConfig.BufferedStorageConfig.NumWorkers = 1 - - // the buffering runs async, test needs to stub datastore methods for potential invocation, - // but is race, since test also cancels the backend context which started the buffer, - // so, not deterministic, no assert on these. - mockDataStore := new(datastore.MockDataStore) - mockDataStore.On("GetSchema").Return(datastore.DataStoreSchema{ - LedgersPerFile: 1, - FilesPerPartition: 1, - }) - - mockDataStore.On("GetFile", mock.Anything, "FFFFFFFD--2.xdr.zstd"). - Run(func(args mock.Arguments) { - cancel() - }). - Return(makeSingleLCMBatch(2), nil) - // this second attempt needs to be mocked, ledger buffer queues this 'next' sequence task automatically - // in getFromLedgerQueue after it receives "FFFFFFFD--2.xdr.zstd", the ctx is not checked then or in - // the async worker routine that receives the task. - mockDataStore.On("GetFile", mock.Anything, "FFFFFFFC--3.xdr.zstd").Return(makeSingleLCMBatch(3), nil) - - appCallback := func(lcm xdr.LedgerCloseMeta) error { - return nil - } - - datastoreFactory = func(_ context.Context, _ datastore.DataStoreConfig) (datastore.DataStore, error) { - return mockDataStore, nil - } - assert.ErrorIs(t, - ApplyLedgerMetadata(ledgerbackend.BoundedRange(uint32(2), uint32(3)), pubConfig, ctx, appCallback), - context.Canceled) -} - func TestBSBProducerFnCallbackError(t *testing.T) { ctx := context.Background() pubConfig := PublisherConfig{ diff --git a/protocols/horizon/main.go b/protocols/horizon/main.go index dd9cc7814f..3fa6ef1ab1 100644 --- a/protocols/horizon/main.go +++ b/protocols/horizon/main.go @@ -175,20 +175,20 @@ type AssetStat struct { } `json:"_links"` base.Asset - PT string `json:"paging_token"` - ContractID string `json:"contract_id,omitempty"` - // Action needed in release: horizon-v3.0.0: deprecated field - NumAccounts int32 `json:"num_accounts"` - NumClaimableBalances int32 `json:"num_claimable_balances"` - NumLiquidityPools int32 `json:"num_liquidity_pools"` - NumContracts int32 `json:"num_contracts"` - NumArchivedContracts int32 `json:"num_archived_contracts"` - // Action needed in release: horizon-v3.0.0: deprecated field - Amount string `json:"amount"` + PT string `json:"paging_token"` + ContractID string `json:"contract_id,omitempty"` + NumClaimableBalances int32 `json:"num_claimable_balances"` + NumLiquidityPools int32 `json:"num_liquidity_pools"` + NumContracts int32 `json:"num_contracts"` + // NumArchivedContracts is deprecated and will be removed in the v23 release + // Action needed in release: horizon-v23.0.0: remove field + NumArchivedContracts int32 `json:"num_archived_contracts"` Accounts AssetStatAccounts `json:"accounts"` ClaimableBalancesAmount string `json:"claimable_balances_amount"` LiquidityPoolsAmount string `json:"liquidity_pools_amount"` ContractsAmount string `json:"contracts_amount"` + // ArchivedContractsAmount is deprecated and will be removed in the v23 release + // Action needed in release: horizon-v23.0.0: remove field ArchivedContractsAmount string `json:"archived_contracts_amount"` Balances AssetStatBalances `json:"balances"` Flags AccountFlags `json:"flags"` @@ -509,33 +509,30 @@ type Transaction struct { // When TransactionSuccess is removed from the SDKs we can remove this HAL link Transaction hal.Link `json:"transaction"` } `json:"_links"` - ID string `json:"id"` - PT string `json:"paging_token"` - Successful bool `json:"successful"` - Hash string `json:"hash"` - Ledger int32 `json:"ledger"` - LedgerCloseTime time.Time `json:"created_at"` - Account string `json:"source_account"` - AccountMuxed string `json:"account_muxed,omitempty"` - AccountMuxedID uint64 `json:"account_muxed_id,omitempty,string"` - AccountSequence int64 `json:"source_account_sequence,string"` - FeeAccount string `json:"fee_account"` - FeeAccountMuxed string `json:"fee_account_muxed,omitempty"` - FeeAccountMuxedID uint64 `json:"fee_account_muxed_id,omitempty,string"` - FeeCharged int64 `json:"fee_charged,string"` - MaxFee int64 `json:"max_fee,string"` - OperationCount int32 `json:"operation_count"` - EnvelopeXdr string `json:"envelope_xdr"` - ResultXdr string `json:"result_xdr"` - ResultMetaXdr string `json:"result_meta_xdr,omitempty"` - FeeMetaXdr string `json:"fee_meta_xdr"` - MemoType string `json:"memo_type"` - MemoBytes string `json:"memo_bytes,omitempty"` - Memo string `json:"memo,omitempty"` - Signatures []string `json:"signatures"` - // Action needed in release: horizon-v3.0.0: remove valid_(after|before) - ValidAfter string `json:"valid_after,omitempty"` - ValidBefore string `json:"valid_before,omitempty"` + ID string `json:"id"` + PT string `json:"paging_token"` + Successful bool `json:"successful"` + Hash string `json:"hash"` + Ledger int32 `json:"ledger"` + LedgerCloseTime time.Time `json:"created_at"` + Account string `json:"source_account"` + AccountMuxed string `json:"account_muxed,omitempty"` + AccountMuxedID uint64 `json:"account_muxed_id,omitempty,string"` + AccountSequence int64 `json:"source_account_sequence,string"` + FeeAccount string `json:"fee_account"` + FeeAccountMuxed string `json:"fee_account_muxed,omitempty"` + FeeAccountMuxedID uint64 `json:"fee_account_muxed_id,omitempty,string"` + FeeCharged int64 `json:"fee_charged,string"` + MaxFee int64 `json:"max_fee,string"` + OperationCount int32 `json:"operation_count"` + EnvelopeXdr string `json:"envelope_xdr"` + ResultXdr string `json:"result_xdr"` + ResultMetaXdr string `json:"result_meta_xdr,omitempty"` + FeeMetaXdr string `json:"fee_meta_xdr"` + MemoType string `json:"memo_type"` + MemoBytes string `json:"memo_bytes,omitempty"` + Memo string `json:"memo,omitempty"` + Signatures []string `json:"signatures"` Preconditions *TransactionPreconditions `json:"preconditions,omitempty"` FeeBumpTransaction *FeeBumpTransaction `json:"fee_bump_transaction,omitempty"` InnerTransaction *InnerTransaction `json:"inner_transaction,omitempty"` @@ -582,7 +579,11 @@ type AsyncTransactionSubmissionResponse struct { // ErrorResultXDR is present only if Status is equal to proto.TXStatusError. // ErrorResultXDR is a TransactionResult xdr string which contains details on why // the transaction could not be accepted by stellar-core. - ErrorResultXDR string `json:"errorResultXdr,omitempty"` + ErrorResultXDR string `json:"error_result_xdr,omitempty"` + // DeprecatedErrorResultXDR is a deprecated field equivalent to ErrorResultXDR + // which will be removed in the v23 release. Use ErrorResultXDR instead of + // DeprecatedErrorResultXDR + DeprecatedErrorResultXDR string `json:"errorResultXdr,omitempty"` // TxStatus represents the status of the transaction submission returned by stellar-core. // It can be one of: proto.TXStatusPending, proto.TXStatusDuplicate, // proto.TXStatusTryAgainLater, or proto.TXStatusError. diff --git a/protocols/stellarcore/getledgerentry_response.go b/protocols/stellarcore/getledgerentry_response.go deleted file mode 100644 index d3289c6aa8..0000000000 --- a/protocols/stellarcore/getledgerentry_response.go +++ /dev/null @@ -1,18 +0,0 @@ -package stellarcore - -const ( - // LiveState represents the state value returned by stellar-core when a - // ledger entry is live - LiveState = "live" - - // DeadState represents the state value returned by stellar-core when a - // ledger entry is dead - DeadState = "dead" -) - -// GetLedgerEntryResponse is the response from Stellar Core for the getLedgerEntry endpoint -type GetLedgerEntryResponse struct { - State string `json:"state"` - Entry string `json:"entry"` - Ledger int64 `json:"ledger"` -} diff --git a/protocols/stellarcore/getledgerentryraw_response.go b/protocols/stellarcore/getledgerentryraw_response.go new file mode 100644 index 0000000000..f4d31a635f --- /dev/null +++ b/protocols/stellarcore/getledgerentryraw_response.go @@ -0,0 +1,11 @@ +package stellarcore + +// GetLedgerEntryRawResponse is the structure of Stellar Core's /getledgerentryraw +type GetLedgerEntryRawResponse struct { + Ledger uint32 `json:"ledger"` + Entries []RawLedgerEntryResponse `json:"entries"` +} + +type RawLedgerEntryResponse struct { + Entry string `json:"le"` // base64-encoded xdr.LedgerEntry +} diff --git a/services/horizon/CHANGELOG.md b/services/horizon/CHANGELOG.md index e3af62d580..4b48c6c46d 100644 --- a/services/horizon/CHANGELOG.md +++ b/services/horizon/CHANGELOG.md @@ -2,14 +2,47 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## Pending + +## 22.0.0-rc2 + + +### Deprecations + +- The `errorResultXdr` field from the response of the async transaction submission endpoint has been temporarily reinstated. However it will be removed in the v23 release. ([5496](https://github.com/stellar/go/pull/5496)) +- The `num_archived_contracts` and `archived_contracts_amount` fields from the `/assets` response have been deprecated and will be removed in the v23 Horizon release. ([5496](https://github.com/stellar/go/pull/5496)) + +## 22.0.0-rc1 + +**This release adds support for Protocol 22** ### Breaking Changes - `--parallel-job-size` configuration parameter for the `stellar-horizon db reingest` command has been removed. Job size will be automatically determined based on the number of workers (configuration parameter --parallel-workers), distributing the range equally among them. The minimum job size will remain 64 ledgers and the start and end ledger range will be rounded to - the nearest checkpoint.([5484](https://github.com/stellar/go/pull/5484)) + the nearest checkpoint. ([5484](https://github.com/stellar/go/pull/5484)) + +- Removed `num_accounts` and `amount` fields from Asset stats related endpoints, and `valid_before` and `valid_after` fields from transaction related endpoints. Issue - [5438](https://github.com/stellar/go/issues/5438), PR - [5478](https://github.com/stellar/go/pull/5478) + - These fields have already been functionally deprecated as of release v2.1.0. As a part of this release, these fields are omitted from API Response + - Additionally, the `num_accounts` and `amount` columns have been dropped from `exp_asset_stats` table in Postgres. + +- Renamed `errorResultXdr` field to `error_result_xdr` in the response of the async transaction submission endpoint, `POST /transactions_async`. ([5445](https://github.com/stellar/go/pull/5445)) + +### Added + +- Added response for new constructor functionality (introduced in protocol 22) in invoke host function operation ([5488](https://github.com/stellar/go/pull/5488)). + +- Add metrics which give insight into how long it takes for ingestion to startup ([5449](https://github.com/stellar/go/pull/5449)). + +### Fixed + +- Fixed the `error` field nested in the `extras` field in the response of the async transaction submission endpoint `POST /transactions_async`. ([5440](https://github.com/stellar/go/issues/5440)) + +- Improved performance of requests which query the lower boundary of horizon's history when running a horizon instance with the `--history-retention-count` flag. ([5410](https://github.com/stellar/go/pull/5410), [5448](https://github.com/stellar/go/pull/5448), [5465](https://github.com/stellar/go/pull/5465)) + +- Improve performance of ingestion when running horizon with the `--history-retention-count` flag by executing reaping of history lookup tables concurrently with ingestion. ([5405](https://github.com/stellar/go/pull/5405)) + +- Improve performance of ingestion when consuming ledgers via the BufferedStorageBackend. ([5494](https://github.com/stellar/go/pull/5494)) ## 2.32.0 diff --git a/services/horizon/internal/actions/asset_test.go b/services/horizon/internal/actions/asset_test.go index 0e4995d93c..6547a6b853 100644 --- a/services/horizon/internal/actions/asset_test.go +++ b/services/horizon/internal/actions/asset_test.go @@ -139,8 +139,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "10", LiquidityPools: "20", }, - Amount: "1", - NumAccounts: 2, } usdAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -157,8 +155,6 @@ func TestAssetStats(t *testing.T) { }, ClaimableBalancesAmount: "0.0000010", LiquidityPoolsAmount: "0.0000020", - Amount: "0.0000001", - NumAccounts: usdAssetStat.NumAccounts, ContractsAmount: "0.0000000", ArchivedContractsAmount: "0.0000000", Asset: base.Asset{ @@ -187,8 +183,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "23", - NumAccounts: 1, } etherAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -206,8 +200,6 @@ func TestAssetStats(t *testing.T) { LiquidityPoolsAmount: "0.0000000", ContractsAmount: "0.0000000", ArchivedContractsAmount: "0.0000000", - Amount: "0.0000023", - NumAccounts: etherAssetStat.NumAccounts, Asset: base.Asset{ Type: "credit_alphanum4", Code: etherAssetStat.AssetCode, @@ -234,8 +226,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 2, } otherUSDAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -251,10 +241,8 @@ func TestAssetStats(t *testing.T) { }, ClaimableBalancesAmount: "0.0000000", LiquidityPoolsAmount: "0.0000000", - Amount: "0.0000001", ContractsAmount: "0.0000000", ArchivedContractsAmount: "0.0000000", - NumAccounts: otherUSDAssetStat.NumAccounts, Asset: base.Asset{ Type: "credit_alphanum4", Code: otherUSDAssetStat.AssetCode, @@ -283,8 +271,6 @@ func TestAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "111", - NumAccounts: 3, } eurAssetStatResponse := horizon.AssetStat{ Accounts: horizon.AssetStatAccounts{ @@ -300,10 +286,8 @@ func TestAssetStats(t *testing.T) { }, ClaimableBalancesAmount: "0.0000000", LiquidityPoolsAmount: "0.0000000", - Amount: "0.0000111", ContractsAmount: "0.0000000", ArchivedContractsAmount: "0.0000000", - NumAccounts: eurAssetStat.NumAccounts, Asset: base.Asset{ Type: "credit_alphanum4", Code: eurAssetStat.AssetCode, @@ -453,8 +437,6 @@ func TestAssetStatsIssuerDoesNotExist(t *testing.T) { Unauthorized: "3", ClaimableBalances: "0", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.InsertAssetStat(tt.Ctx, usdAssetStat) tt.Assert.NoError(err) @@ -478,10 +460,8 @@ func TestAssetStatsIssuerDoesNotExist(t *testing.T) { }, ClaimableBalancesAmount: "0.0000000", LiquidityPoolsAmount: "0.0000000", - Amount: "0.0000001", ContractsAmount: "0.0000000", ArchivedContractsAmount: "0.0000000", - NumAccounts: usdAssetStat.NumAccounts, Asset: base.Asset{ Type: "credit_alphanum4", Code: usdAssetStat.AssetCode, diff --git a/services/horizon/internal/actions/submit_transaction_async.go b/services/horizon/internal/actions/submit_transaction_async.go index 0cce31b5f6..d0a78c5218 100644 --- a/services/horizon/internal/actions/submit_transaction_async.go +++ b/services/horizon/internal/actions/submit_transaction_async.go @@ -115,6 +115,8 @@ func (handler AsyncSubmitTransactionHandler) GetResource(_ HeaderWriter, r *http if resp.Status == proto.TXStatusError { response.ErrorResultXDR = resp.Error + // Action needed in release: horizon-v23.0.0: remove deprecated field + response.DeprecatedErrorResultXDR = resp.Error } return response, nil diff --git a/services/horizon/internal/actions/submit_transaction_async_test.go b/services/horizon/internal/actions/submit_transaction_async_test.go index 258012bc3c..a72cbe8347 100644 --- a/services/horizon/internal/actions/submit_transaction_async_test.go +++ b/services/horizon/internal/actions/submit_transaction_async_test.go @@ -164,9 +164,10 @@ func TestAsyncSubmitTransactionHandler_TransactionStatusResponse(t *testing.T) { DiagnosticEvents: "test-diagnostic-events", }, expectedResponse: horizon.AsyncTransactionSubmissionResponse{ - ErrorResultXDR: "test-error", - TxStatus: proto.TXStatusError, - Hash: TxHash, + ErrorResultXDR: "test-error", + DeprecatedErrorResultXDR: "test-error", + TxStatus: proto.TXStatusError, + Hash: TxHash, }, }, { diff --git a/services/horizon/internal/db2/history/asset_stats.go b/services/horizon/internal/db2/history/asset_stats.go index 622619680b..12e910d533 100644 --- a/services/horizon/internal/db2/history/asset_stats.go +++ b/services/horizon/internal/db2/history/asset_stats.go @@ -20,8 +20,6 @@ func assetStatToMap(assetStat ExpAssetStat) map[string]interface{} { "asset_issuer": assetStat.AssetIssuer, "accounts": assetStat.Accounts, "balances": assetStat.Balances, - "amount": assetStat.Amount, - "num_accounts": assetStat.NumAccounts, "contract_id": assetStat.ContractID, } } diff --git a/services/horizon/internal/db2/history/asset_stats_test.go b/services/horizon/internal/db2/history/asset_stats_test.go index a8352e4d97..520b480fd6 100644 --- a/services/horizon/internal/db2/history/asset_stats_test.go +++ b/services/horizon/internal/db2/history/asset_stats_test.go @@ -40,8 +40,6 @@ func TestAssetStatContracts(t *testing.T) { LiquidityPools: "0", Unauthorized: "0", }, - Amount: "0", - NumAccounts: 0, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, @@ -59,8 +57,6 @@ func TestAssetStatContracts(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "23", - NumAccounts: 1, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -78,8 +74,6 @@ func TestAssetStatContracts(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, }, } var contractID [32]byte @@ -219,8 +213,6 @@ func TestInsertAssetStats(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, @@ -238,8 +230,6 @@ func TestInsertAssetStats(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "23", - NumAccounts: 1, }, } tt.Assert.NoError(q.InsertAssetStats(tt.Ctx, assetStats)) @@ -276,8 +266,6 @@ func TestInsertAssetStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, }, { AssetType: xdr.AssetTypeAssetTypeCreditAlphanum12, @@ -295,8 +283,6 @@ func TestInsertAssetStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "23", - NumAccounts: 1, }, } @@ -333,8 +319,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat) @@ -344,18 +328,6 @@ func TestInsertAssetStatAlreadyExistsError(t *testing.T) { numChanged, err = q.InsertAssetStat(tt.Ctx, assetStat) tt.Assert.Error(err) tt.Assert.Equal(numChanged, int64(0)) - - assetStat.NumAccounts = 4 - assetStat.Amount = "3" - numChanged, err = q.InsertAssetStat(tt.Ctx, assetStat) - tt.Assert.Error(err) - tt.Assert.Equal(numChanged, int64(0)) - - assetStat.NumAccounts = 2 - assetStat.Amount = "1" - got, err := q.GetAssetStat(tt.Ctx, assetStat.AssetType, assetStat.AssetCode, assetStat.AssetIssuer) - tt.Assert.NoError(err) - tt.Assert.Equal(got, assetStat) } func TestUpdateAssetStatDoesNotExistsError(t *testing.T) { @@ -380,8 +352,6 @@ func TestUpdateAssetStatDoesNotExistsError(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.UpdateAssetStat(tt.Ctx, assetStat) @@ -415,8 +385,6 @@ func TestUpdateStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.InsertAssetStat(tt.Ctx, assetStat) @@ -427,8 +395,6 @@ func TestUpdateStat(t *testing.T) { tt.Assert.NoError(err) tt.Assert.Equal(got, assetStat) - assetStat.NumAccounts = 50 - assetStat.Amount = "23" assetStat.SetContractID([32]byte{23}) numChanged, err = q.UpdateAssetStat(tt.Ctx, assetStat) @@ -462,8 +428,6 @@ func TestGetAssetStatDoesNotExist(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } _, err := q.GetAssetStat(tt.Ctx, assetStat.AssetType, assetStat.AssetCode, assetStat.AssetIssuer) @@ -493,8 +457,6 @@ func TestRemoveAssetStat(t *testing.T) { ClaimableBalances: "4", LiquidityPools: "5", }, - Amount: "1", - NumAccounts: 2, } numChanged, err := q.RemoveAssetStat(tt.Ctx, @@ -628,8 +590,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 2, }, Contracts: zero, } @@ -650,8 +610,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "23", - NumAccounts: 1, }, Contracts: zero, } @@ -672,8 +630,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 2, }, Contracts: zero, } @@ -694,8 +650,6 @@ func TestGetAssetStatsFiltersAndCursor(t *testing.T) { ClaimableBalances: "1", LiquidityPools: "2", }, - Amount: "111", - NumAccounts: 3, }, Contracts: ContractStat{ ActiveBalance: "120", diff --git a/services/horizon/internal/db2/history/main.go b/services/horizon/internal/db2/history/main.go index 7cb7097508..7bb4516ff0 100644 --- a/services/horizon/internal/db2/history/main.go +++ b/services/horizon/internal/db2/history/main.go @@ -430,8 +430,6 @@ type ExpAssetStat struct { AssetIssuer string `db:"asset_issuer"` Accounts ExpAssetStatAccounts `db:"accounts"` Balances ExpAssetStatBalances `db:"balances"` - Amount string `db:"amount"` - NumAccounts int32 `db:"num_accounts"` ContractID *[]byte `db:"contract_id"` // make sure to update Equals() when adding new fields to ExpAssetStat } @@ -484,9 +482,7 @@ func (e *ExpAssetStat) Equals(o ExpAssetStat) bool { e.AssetCode == o.AssetCode && e.AssetIssuer == o.AssetIssuer && e.Accounts == o.Accounts && - e.Balances == o.Balances && - e.Amount == o.Amount && - e.NumAccounts == o.NumAccounts + e.Balances == o.Balances } func (e *ExpAssetStat) GetContractID() ([32]byte, bool) { diff --git a/services/horizon/internal/db2/schema/bindata.go b/services/horizon/internal/db2/schema/bindata.go index 3c68f6b2fd..5dd80aec97 100644 --- a/services/horizon/internal/db2/schema/bindata.go +++ b/services/horizon/internal/db2/schema/bindata.go @@ -64,6 +64,7 @@ // migrations/65_drop_payment_index.sql (260B) // migrations/66_contract_asset_stats.sql (583B) // migrations/67_remove_unused_indexes.sql (2.897kB) +// migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql (471B) // migrations/6_create_assets_table.sql (366B) // migrations/7_modify_trades_table.sql (2.303kB) // migrations/8_add_aggregators.sql (907B) @@ -1417,6 +1418,26 @@ func migrations67_remove_unused_indexesSql() (*asset, error) { return a, nil } +var _migrations68_remove_deprecated_fields_from_exp_asset_statsSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\xd0\x4d\x4b\xc4\x30\x18\x04\xe0\x7b\x7e\xc5\xdc\xaa\x48\xa1\xf7\xa2\x10\x9b\xa8\xc5\x98\x4a\x7c\x23\xde\x42\xa8\x45\x0a\xf6\x03\x93\xaa\x3f\x5f\xdc\x0f\xe8\xb2\x4b\x77\x61\xaf\x81\x79\x66\xf2\xa6\x29\xae\xba\xf6\xe3\xcb\xc7\x06\x76\x64\x8c\x2b\x92\x06\xc4\x6f\x95\x44\xf3\x3b\x3a\x1f\x42\x13\x5d\x88\x3e\x06\x08\x53\x3d\xa3\xa8\xf4\x0b\x19\x5e\x6a\xc2\xb7\xff\x6c\xdf\x5d\x3f\x75\xce\xd7\xf5\x30\xf5\x31\xe4\x8b\x00\x03\xb0\x45\x94\x7d\xd2\x38\x23\xea\xbb\xff\x54\xce\xd8\xfc\x03\x62\xf8\xe9\x8f\x2a\x5c\x88\x43\xfd\x28\x35\xc9\x7b\x69\xa0\x2b\x82\xb6\x4a\x41\xc8\x3b\x6e\x15\x21\x3b\x61\xda\x0c\x5d\x2f\x03\xc9\x37\xda\xb7\x92\x64\x19\xdb\x40\x0b\x27\x46\xf1\x20\x8b\x47\x5c\xec\xbc\xdd\x5c\x23\xbb\x5c\xb5\xbd\x72\x55\x8a\x9c\xfd\x05\x00\x00\xff\xff\x7f\x2b\x3e\x4a\xd7\x01\x00\x00") + +func migrations68_remove_deprecated_fields_from_exp_asset_statsSqlBytes() ([]byte, error) { + return bindataRead( + _migrations68_remove_deprecated_fields_from_exp_asset_statsSql, + "migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql", + ) +} + +func migrations68_remove_deprecated_fields_from_exp_asset_statsSql() (*asset, error) { + bytes, err := migrations68_remove_deprecated_fields_from_exp_asset_statsSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8, 0x9f, 0xc8, 0xbb, 0xb3, 0x73, 0xf7, 0x7a, 0x22, 0x14, 0x5f, 0x5a, 0x8a, 0x35, 0x6, 0xf1, 0x92, 0x45, 0xd, 0xe5, 0x75, 0x9, 0x7f, 0xab, 0xec, 0xa8, 0x35, 0xdc, 0xcf, 0x7b, 0x96, 0xde}} + return a, nil +} + var _migrations6_create_assets_tableSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x90\x3d\x4f\xc3\x30\x18\x84\x77\xff\x8a\x1b\x1d\x91\x0e\x20\xe8\x92\xc9\x34\x16\x58\x18\xa7\xb8\x31\xa2\x53\xe5\x26\x16\x78\x80\x54\xb6\x11\xca\xbf\x47\xaa\x28\xf9\x50\xe6\x7b\xf4\xbc\xef\xdd\x6a\x85\xab\x4f\xff\x1e\x6c\x72\x30\x27\xb2\xd1\x9c\xd5\x1c\x35\xbb\x97\x1c\x1f\x3e\xa6\x2e\xf4\x07\x1b\xa3\x4b\x11\x94\x00\x80\x6f\xb1\xe3\x5a\x30\x89\xad\x16\xcf\x4c\xef\xf1\xc4\xf7\xc8\xcf\xd9\x19\x3c\xa4\xfe\xe4\xf0\xca\xf4\xe6\x91\x69\xba\xbe\xcd\xa0\xaa\x1a\xca\x48\x39\x86\x9a\xae\x1d\xa0\xeb\x9b\x65\xc8\xc7\xf8\xed\xc2\x3f\x76\xb7\x9e\x63\x46\x89\x17\xc3\xe9\xa0\xcc\x47\x3f\xe4\x13\x4b\x46\xb2\x82\x5c\xfa\x09\x55\xf2\xb7\xbf\xf8\xd8\x5f\xee\x54\x6a\x5e\xd9\xec\x84\x7a\xc0\x31\x05\xe7\x40\x27\xb6\x82\x90\xf1\x74\x65\xf7\xf3\x45\x4a\x5d\x6d\x97\xa7\x6b\x6c\x6c\x6c\xeb\x8a\xdf\x00\x00\x00\xff\xff\xfb\x53\x3e\x81\x6e\x01\x00\x00") func migrations6_create_assets_tableSqlBytes() ([]byte, error) { @@ -1672,6 +1693,7 @@ var _bindata = map[string]func() (*asset, error){ "migrations/65_drop_payment_index.sql": migrations65_drop_payment_indexSql, "migrations/66_contract_asset_stats.sql": migrations66_contract_asset_statsSql, "migrations/67_remove_unused_indexes.sql": migrations67_remove_unused_indexesSql, + "migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql": migrations68_remove_deprecated_fields_from_exp_asset_statsSql, "migrations/6_create_assets_table.sql": migrations6_create_assets_tableSql, "migrations/7_modify_trades_table.sql": migrations7_modify_trades_tableSql, "migrations/8_add_aggregators.sql": migrations8_add_aggregatorsSql, @@ -1787,6 +1809,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "65_drop_payment_index.sql": {migrations65_drop_payment_indexSql, map[string]*bintree{}}, "66_contract_asset_stats.sql": {migrations66_contract_asset_statsSql, map[string]*bintree{}}, "67_remove_unused_indexes.sql": {migrations67_remove_unused_indexesSql, map[string]*bintree{}}, + "68_remove_deprecated_fields_from_exp_asset_stats.sql": {migrations68_remove_deprecated_fields_from_exp_asset_statsSql, map[string]*bintree{}}, "6_create_assets_table.sql": {migrations6_create_assets_tableSql, map[string]*bintree{}}, "7_modify_trades_table.sql": {migrations7_modify_trades_tableSql, map[string]*bintree{}}, "8_add_aggregators.sql": {migrations8_add_aggregatorsSql, map[string]*bintree{}}, diff --git a/services/horizon/internal/db2/schema/migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql b/services/horizon/internal/db2/schema/migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql new file mode 100644 index 0000000000..691a070274 --- /dev/null +++ b/services/horizon/internal/db2/schema/migrations/68_remove_deprecated_fields_from_exp_asset_stats.sql @@ -0,0 +1,18 @@ +-- +migrate Up + +ALTER TABLE exp_asset_stats DROP CONSTRAINT valid_num_accounts; + +ALTER TABLE exp_asset_stats + DROP COLUMN num_accounts; + +ALTER TABLE exp_asset_stats + DROP COLUMN amount; + +-- +migrate Down +ALTER TABLE exp_asset_stats + ADD COLUMN num_accounts INTEGER NOT NULL DEFAULT 0; + +ALTER TABLE exp_asset_stats + ADD COLUMN amount TEXT NOT NULL DEFAULT ''; + +ALTER TABLE exp_asset_stats ADD CONSTRAINT valid_num_accounts CHECK (num_accounts >= 0) NOT VALID; diff --git a/services/horizon/internal/httpx/static/txsub_async_oapi.yaml b/services/horizon/internal/httpx/static/txsub_async_oapi.yaml index f889cf4ec8..10502b4387 100644 --- a/services/horizon/internal/httpx/static/txsub_async_oapi.yaml +++ b/services/horizon/internal/httpx/static/txsub_async_oapi.yaml @@ -52,7 +52,7 @@ paths: ErrorStatusExample: summary: ERROR Status from core value: - errorResultXdr: "AAAAAAAAAGT////7AAAAAA==" + error_result_xdr: "AAAAAAAAAGT////7AAAAAA==" tx_status: "ERROR" hash: "6cbb7f714bd08cea7c30cab7818a35c510cbbfc0a6aa06172a1e94146ecf0165" '405': @@ -78,7 +78,7 @@ paths: schema: $ref: '#/components/schemas/AsyncTransactionSubmissionResponse' example: - errorResultXdr: "" + error_result_xdr: "" tx_status: "DUPLICATE" hash: "6cbb7f714bd08cea7c30cab7818a35c510cbbfc0a6aa06172a1e94146ecf0165" '500': @@ -136,10 +136,14 @@ components: AsyncTransactionSubmissionResponse: type: object properties: - errorResultXdr: + error_result_xdr: type: string nullable: true description: TransactionResult XDR string which is present only if the submission status from core is an ERROR. + errorResultXdr: + type: string + nullable: true + description: This field is deprecated, use error_result_xdr instead. tx_status: type: string enum: ["ERROR", "PENDING", "DUPLICATE", "TRY_AGAIN_LATER"] diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index 9ec13078e3..8711684e59 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -31,7 +31,7 @@ import ( const ( // MaxSupportedProtocolVersion defines the maximum supported version of // the Stellar protocol. - MaxSupportedProtocolVersion uint32 = 21 + MaxSupportedProtocolVersion uint32 = 22 // CurrentVersion reflects the latest version of the ingestion // algorithm. This value is stored in KV store and is used to decide diff --git a/services/horizon/internal/ingest/processors/asset_stats_processor.go b/services/horizon/internal/ingest/processors/asset_stats_processor.go index 6ae83c3a3c..7e76b509c2 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_processor.go +++ b/services/horizon/internal/ingest/processors/asset_stats_processor.go @@ -305,8 +305,6 @@ func IncludeContractIDsInAssetStats( AssetIssuer: assetIssuer, Accounts: history.ExpAssetStatAccounts{}, Balances: newAssetStatBalance().ConvertToHistoryObject(), - Amount: "0", - NumAccounts: 0, } row.SetContractID(contractID) assetStatsDeltas = append(assetStatsDeltas, row) @@ -456,8 +454,6 @@ func (p *AssetStatsProcessor) updateAssetStats( AssetIssuer: delta.AssetIssuer, Accounts: statAccounts, Balances: statBalances.ConvertToHistoryObject(), - Amount: statBalances.Authorized.String(), - NumAccounts: statAccounts.Authorized, ContractID: delta.ContractID, }) if err != nil { @@ -549,8 +545,6 @@ func (p *AssetStatsProcessor) updateContractID( AssetIssuer: assetIssuer, Accounts: history.ExpAssetStatAccounts{}, Balances: newAssetStatBalance().ConvertToHistoryObject(), - Amount: "0", - NumAccounts: 0, } row.SetContractID(contractID) diff --git a/services/horizon/internal/ingest/processors/asset_stats_processor_test.go b/services/horizon/internal/ingest/processors/asset_stats_processor_test.go index e8080773e8..ea267f6d3e 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_processor_test.go +++ b/services/horizon/internal/ingest/processors/asset_stats_processor_test.go @@ -74,8 +74,6 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, }, }).Return(nil).Once() } @@ -141,8 +139,6 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLineWithClawback() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, }, }).Return(nil).Once() } @@ -179,8 +175,6 @@ func (s *AssetStatsProcessorTestSuiteState) TestCreateTrustLineUnauthorized() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, }).Return(nil).Once() } @@ -320,8 +314,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalance() { ClaimableBalances: "24", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -343,8 +335,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalance() { ClaimableBalances: "46", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -487,8 +477,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -510,8 +498,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -599,8 +585,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -625,8 +609,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } usdAssetStat.SetContractID(usdID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -932,8 +914,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -974,8 +954,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } usdAssetStat.SetContractID(usdID) s.mockQ.On("InsertAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -1097,8 +1075,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestInsertClaimableBalanceAndTrustl ClaimableBalances: "12", LiquidityPools: "100", }, - Amount: "9", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -1148,8 +1124,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() eurAssetStat := history.ExpAssetStat{ @@ -1164,8 +1138,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -1309,8 +1281,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() eurAssetStat := history.ExpAssetStat{ @@ -1327,8 +1297,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDWithBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { @@ -1406,8 +1374,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDError() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(usdID) s.mockQ.On("GetAssetStat", s.ctx, @@ -1485,8 +1451,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndContractIDErr ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(usdID) s.mockQ.On("GetAssetStat", s.ctx, @@ -1588,8 +1552,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } s.mockQ.On("GetAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1654,8 +1616,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1669,8 +1629,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "110", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -1805,8 +1763,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1822,8 +1778,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -1844,8 +1798,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1861,8 +1813,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("GetAssetStat", s.ctx, @@ -1883,8 +1833,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -1900,8 +1848,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustLineAuthorization() ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -1978,8 +1924,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { ClaimableBalances: "12", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2006,8 +1950,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { ClaimableBalances: "21", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("UpdateAssetStat", s.ctx, history.ExpAssetStat{ AssetType: xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2021,8 +1963,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveClaimableBalance() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). @@ -2094,8 +2034,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, }, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2121,8 +2059,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveTrustLine() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, }, nil).Once() s.mockQ.On("RemoveAssetStat", s.ctx, xdr.AssetTypeAssetTypeCreditAlphanum4, @@ -2173,8 +2109,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractID() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). @@ -2260,8 +2194,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "100", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStat", s.ctx, @@ -2282,8 +2214,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "110", - NumAccounts: 1, } s.mockQ.On("UpdateAssetStat", s.ctx, mock.MatchedBy(func(assetStat history.ExpAssetStat) bool { return eurAssetStat.Equals(assetStat) @@ -2332,8 +2262,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDFromZeroRow() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). @@ -2432,8 +2360,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndBalanceZeroR ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 0, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStatByContract", s.ctx, xdr.Hash(eurID)). @@ -2524,8 +2450,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDAndRow() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "0", - NumAccounts: 1, } eurAssetStat.SetContractID(eurID) s.mockQ.On("GetAssetStat", s.ctx, @@ -2621,8 +2545,6 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestProcessUpgradeChange() { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }).Return(int64(1), nil).Once() s.mockQ.On("RemoveContractAssetBalances", s.ctx, []xdr.Hash(nil)). diff --git a/services/horizon/internal/ingest/processors/asset_stats_set.go b/services/horizon/internal/ingest/processors/asset_stats_set.go index bc27c2a4ef..9b79e49d82 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_set.go +++ b/services/horizon/internal/ingest/processors/asset_stats_set.go @@ -109,8 +109,6 @@ func (value assetStatValue) ConvertToHistoryObject() history.ExpAssetStat { AssetIssuer: value.assetIssuer, Accounts: value.accounts, Balances: balances, - Amount: balances.Authorized, - NumAccounts: value.accounts.Authorized, } } diff --git a/services/horizon/internal/ingest/processors/asset_stats_set_test.go b/services/horizon/internal/ingest/processors/asset_stats_set_test.go index f9989fdc9e..330a2132ec 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_set_test.go +++ b/services/horizon/internal/ingest/processors/asset_stats_set_test.go @@ -109,8 +109,6 @@ func TestAddAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "1", - NumAccounts: 1, } assert.NoError( @@ -150,9 +148,7 @@ func TestAddAssetStats(t *testing.T) { ) eurAssetStat.Balances.Authorized = "25" - eurAssetStat.Amount = "25" eurAssetStat.Accounts.Authorized++ - eurAssetStat.NumAccounts++ assertAllEquals(t, set, []history.ExpAssetStat{eurAssetStat}) usd := "USD" @@ -214,8 +210,6 @@ func TestAddAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "3", - NumAccounts: 1, }, eurAssetStat, { @@ -232,8 +226,6 @@ func TestAddAssetStats(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "10", - NumAccounts: 1, }, } assertAllEquals(t, set, expected) @@ -270,8 +262,6 @@ func TestOverflowAssetStatSet(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "9223372036854775807", - NumAccounts: 1, } if all[0] != eurAssetStat { t.Fatalf("expected asset stat to be %v but got %v", eurAssetStat, all[0]) @@ -305,8 +295,6 @@ func TestOverflowAssetStatSet(t *testing.T) { ClaimableBalances: "0", LiquidityPools: "0", }, - Amount: "18446744073709551614", - NumAccounts: 2, } if all[0] != eurAssetStat { t.Fatalf("expected asset stat to be %v but got %v", eurAssetStat, all[0]) diff --git a/services/horizon/internal/ingest/processors/operations_processor.go b/services/horizon/internal/ingest/processors/operations_processor.go index 252d5a6ba0..39d09b1608 100644 --- a/services/horizon/internal/ingest/processors/operations_processor.go +++ b/services/horizon/internal/ingest/processors/operations_processor.go @@ -550,7 +550,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, op := operation.operation.Body.MustClaimClaimableBalanceOp() balanceID, err := xdr.MarshalHex(op.BalanceId) if err != nil { - panic(fmt.Errorf("Invalid balanceId in op: %d", operation.index)) + return nil, fmt.Errorf("Invalid balanceId in op: %d", operation.index) } details["balance_id"] = balanceID addAccountAndMuxedAccountDetails(details, *source, "claimant") @@ -585,7 +585,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, op := operation.operation.Body.MustClawbackClaimableBalanceOp() balanceID, err := xdr.MarshalHex(op.BalanceId) if err != nil { - panic(fmt.Errorf("Invalid balanceId in op: %d", operation.index)) + return nil, fmt.Errorf("Invalid balanceId in op: %d", operation.index) } details["balance_id"] = balanceID case xdr.OperationTypeSetTrustLineFlags: @@ -676,22 +676,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, args = append(args, xdr.ScVal{Type: xdr.ScValTypeScvAddress, Address: &invokeArgs.ContractAddress}) args = append(args, xdr.ScVal{Type: xdr.ScValTypeScvSymbol, Sym: &invokeArgs.FunctionName}) args = append(args, invokeArgs.Args...) - params := make([]map[string]string, 0, len(args)) - - for _, param := range args { - serializedParam := map[string]string{} - serializedParam["value"] = "n/a" - serializedParam["type"] = "n/a" - - if scValTypeName, ok := param.ArmForSwitch(int32(param.Type)); ok { - serializedParam["type"] = scValTypeName - if raw, err := param.MarshalBinary(); err == nil { - serializedParam["value"] = base64.StdEncoding.EncodeToString(raw) - } - } - params = append(params, serializedParam) - } - details["parameters"] = params + details["parameters"] = extractFunctionArgs(args) if balanceChanges, err := operation.parseAssetBalanceChangesFromContractEvents(); err != nil { return nil, err @@ -706,7 +691,25 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, fromAddress := args.ContractIdPreimage.MustFromAddress() address, err := fromAddress.Address.String() if err != nil { - panic(fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type)) + return nil, fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type) + } + details["from"] = "address" + details["address"] = address + details["salt"] = fromAddress.Salt.String() + case xdr.ContractIdPreimageTypeContractIdPreimageFromAsset: + details["from"] = "asset" + details["asset"] = args.ContractIdPreimage.MustFromAsset().StringCanonical() + default: + return nil, fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type) + } + case xdr.HostFunctionTypeHostFunctionTypeCreateContractV2: + args := op.HostFunction.MustCreateContractV2() + switch args.ContractIdPreimage.Type { + case xdr.ContractIdPreimageTypeContractIdPreimageFromAddress: + fromAddress := args.ContractIdPreimage.MustFromAddress() + address, err := fromAddress.Address.String() + if err != nil { + return nil, fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type) } details["from"] = "address" details["address"] = address @@ -715,18 +718,26 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, details["from"] = "asset" details["asset"] = args.ContractIdPreimage.MustFromAsset().StringCanonical() default: - panic(fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type)) + return nil, fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type) + } + + details["parameters"] = extractFunctionArgs(args.ConstructorArgs) + + if balanceChanges, err := operation.parseAssetBalanceChangesFromContractEvents(); err != nil { + return nil, err + } else { + details["asset_balance_changes"] = balanceChanges } case xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm: default: - panic(fmt.Errorf("unknown host function type: %s", op.HostFunction.Type)) + return nil, fmt.Errorf("unknown host function type: %s", op.HostFunction.Type) } case xdr.OperationTypeExtendFootprintTtl: op := operation.operation.Body.MustExtendFootprintTtlOp() details["extend_to"] = op.ExtendTo case xdr.OperationTypeRestoreFootprint: default: - panic(fmt.Errorf("unknown operation type: %s", operation.OperationType())) + return nil, fmt.Errorf("unknown operation type: %s", operation.OperationType()) } sponsor, err := operation.getSponsor() @@ -740,6 +751,24 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, return details, nil } +func extractFunctionArgs(args []xdr.ScVal) []map[string]string { + params := make([]map[string]string, 0, len(args)) + for _, param := range args { + serializedParam := map[string]string{} + serializedParam["value"] = "n/a" + serializedParam["type"] = "n/a" + + if scValTypeName, ok := param.ArmForSwitch(int32(param.Type)); ok { + serializedParam["type"] = scValTypeName + if raw, err := param.MarshalBinary(); err == nil { + serializedParam["value"] = base64.StdEncoding.EncodeToString(raw) + } + } + params = append(params, serializedParam) + } + return params +} + // Searches an operation for SAC events that are of a type which represent // asset balances having changed. // diff --git a/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go b/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go index 48b1f729b4..78afaa6e71 100644 --- a/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go +++ b/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go @@ -2282,9 +2282,6 @@ func TestDetailsCoversAllOperationTypes(t *testing.T) { operation: op, ledgerSequence: 1, } - // calling Details should panic with unknown operation type - f := func() { - operation.Details() - } - assert.PanicsWithError(t, "unknown operation type: ", f) + _, err := operation.Details() + assert.ErrorContains(t, err, "unknown operation type: ") } diff --git a/services/horizon/internal/ingest/verify_range_state_test.go b/services/horizon/internal/ingest/verify_range_state_test.go index a1df30d854..f330ba362a 100644 --- a/services/horizon/internal/ingest/verify_range_state_test.go +++ b/services/horizon/internal/ingest/verify_range_state_test.go @@ -568,7 +568,6 @@ func (s *VerifyRangeStateTestSuite) TestSuccessWithVerify() { LiquidityPools: "450", Unauthorized: "0", }, - Amount: "0", }, }, }, nil).Once() @@ -651,8 +650,6 @@ func (s *VerifyRangeStateTestSuite) TestVerifyFailsWhenAssetStatsMismatch() { AuthorizedToMaintainLiabilities: "0", Unauthorized: "123", }, - Amount: "0", - NumAccounts: 0, }, } diff --git a/services/horizon/internal/integration/contracts/Cargo.lock b/services/horizon/internal/integration/contracts/Cargo.lock index e80d7d5d28..9a51ac7a62 100644 --- a/services/horizon/internal/integration/contracts/Cargo.lock +++ b/services/horizon/internal/integration/contracts/Cargo.lock @@ -3,20 +3,17 @@ version = 3 [[package]] -name = "addr2line" -version = "0.21.0" +name = "ahash" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ - "gimli", + "cfg-if", + "once_cell", + "version_check", + "zerocopy", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "android-tzdata" version = "0.1.1" @@ -42,37 +39,134 @@ dependencies = [ ] [[package]] -name = "autocfg" -version = "1.1.0" +name = "ark-bls12-381" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] [[package]] -name = "backtrace" -version = "0.3.69" +name = "ark-ec" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", ] [[package]] -name = "base16ct" -version = "0.2.0" +name = "ark-ff" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] [[package]] -name = "base32" +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" @@ -82,9 +176,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -103,9 +197,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes-lit" @@ -116,16 +216,16 @@ dependencies = [ "num-bigint", "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] name = "cc" -version = "1.0.83" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" dependencies = [ - "libc", + "shlex", ] [[package]] @@ -136,9 +236,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -149,21 +249,21 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -203,26 +303,25 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" +checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn", + "syn 2.0.79", ] [[package]] name = "curve25519-dalek" -version = "4.1.1" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest", "fiat-crypto", - "platforms", "rustc_version", "subtle", "zeroize", @@ -236,14 +335,14 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] name = "darling" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -251,34 +350,40 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.79", ] [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.79", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", @@ -286,14 +391,25 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", "serde", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_arbitrary" version = "1.3.2" @@ -302,7 +418,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] @@ -319,9 +435,9 @@ dependencies = [ [[package]] name = "downcast-rs" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "ecdsa" @@ -334,7 +450,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -349,9 +464,9 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", @@ -364,9 +479,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -380,7 +495,6 @@ dependencies = [ "ff", "generic-array", "group", - "pkcs8", "rand_core", "sec1", "subtle", @@ -393,6 +507,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "escape-bytes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfcf67fea2815c2fc3b90873fae90957be12ff417335dfadc7f52927feb03b2" + [[package]] name = "ethnum" version = "1.5.0" @@ -411,9 +531,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "fnv" @@ -434,9 +554,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -445,12 +565,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - [[package]] name = "group" version = "0.13.0" @@ -470,9 +584,18 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "hex" @@ -500,9 +623,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -540,12 +663,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.15.0", "serde", ] @@ -557,56 +680,54 @@ checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" [[package]] name = "itertools" -version = "0.11.0" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] [[package]] name = "libc" -version = "0.2.150" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libm" @@ -616,86 +737,84 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "miniz_oxide" -version = "0.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-derive" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] -name = "object" -version = "0.32.1" +name = "once_cell" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" -dependencies = [ - "memchr", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] -name = "once_cell" -version = "1.18.0" +name = "p256" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pkcs8" @@ -707,12 +826,6 @@ dependencies = [ "spki", ] -[[package]] -name = "platforms" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" - [[package]] name = "powerfmt" version = "0.2.0" @@ -721,34 +834,46 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.79", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", ] [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -793,26 +918,20 @@ dependencies = [ "subtle", ] -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "sec1" @@ -823,60 +942,61 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] [[package]] name = "semver" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_with" -version = "3.4.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" dependencies = [ - "base64 0.21.5", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.1.0", + "indexmap 2.6.0", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -884,14 +1004,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.4.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] @@ -915,6 +1035,12 @@ dependencies = [ "keccak", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" version = "2.2.0" @@ -927,25 +1053,34 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "soroban-builtin-sdk-macros" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" +version = "22.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cdb13e8f4556fe89d2b1c8f529a66997e1d90fd6f10440dc5a1717f5f733251" dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 2.0.79", +] + +[[package]] +name = "soroban-constructor-contract" +version = "0.0.0" +dependencies = [ + "soroban-sdk", ] [[package]] name = "soroban-env-common" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" +version = "22.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "984c9a1a84c05599f5c9cb17d5fbb75fe1c7106598659a34d9da8a8f16d2c23f" dependencies = [ "arbitrary", "crate-git-revision", @@ -957,12 +1092,14 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-xdr", + "wasmparser", ] [[package]] name = "soroban-env-guest" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" +version = "22.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "570dfaa0f35b373a2f9793b89a1864caf68e9071c5c8a4100654aa3434b4fde1" dependencies = [ "soroban-env-common", "static_assertions", @@ -970,12 +1107,19 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" +version = "22.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e59d22359f8d372872b7630fc0dc6884c36356d5d33d3fca83d2b76e572c2a32" dependencies = [ - "backtrace", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", "curve25519-dalek", + "ecdsa", "ed25519-dalek", + "elliptic-curve", + "generic-array", "getrandom", "hex-literal", "hmac", @@ -983,8 +1127,10 @@ dependencies = [ "num-derive", "num-integer", "num-traits", + "p256", "rand", "rand_chacha", + "sec1", "sha2", "sha3", "soroban-builtin-sdk-macros", @@ -992,12 +1138,14 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-strkey", + "wasmparser", ] [[package]] name = "soroban-env-macros" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=be04cf31e925ba5bacd9b22db7caf7b4f6dd8372#be04cf31e925ba5bacd9b22db7caf7b4f6dd8372" +version = "22.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76184b736ac2ce144461efbe7c3551ac2c2973fa144e32957bb2ae2d80467f64" dependencies = [ "itertools", "proc-macro2", @@ -1005,7 +1153,7 @@ dependencies = [ "serde", "serde_json", "stellar-xdr", - "syn", + "syn 2.0.79", ] [[package]] @@ -1017,8 +1165,8 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" +version = "22.0.0-rc.2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=f0e653e364b19a7bf23bcb6b1cb2427ba12cee44#f0e653e364b19a7bf23bcb6b1cb2427ba12cee44" dependencies = [ "serde", "serde_json", @@ -1037,8 +1185,8 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" +version = "22.0.0-rc.2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=f0e653e364b19a7bf23bcb6b1cb2427ba12cee44#f0e653e364b19a7bf23bcb6b1cb2427ba12cee44" dependencies = [ "arbitrary", "bytes-lit", @@ -1056,8 +1204,8 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" +version = "22.0.0-rc.2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=f0e653e364b19a7bf23bcb6b1cb2427ba12cee44#f0e653e364b19a7bf23bcb6b1cb2427ba12cee44" dependencies = [ "crate-git-revision", "darling", @@ -1070,13 +1218,13 @@ dependencies = [ "soroban-spec", "soroban-spec-rust", "stellar-xdr", - "syn", + "syn 2.0.79", ] [[package]] name = "soroban-spec" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" +version = "22.0.0-rc.2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=f0e653e364b19a7bf23bcb6b1cb2427ba12cee44#f0e653e364b19a7bf23bcb6b1cb2427ba12cee44" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1086,8 +1234,8 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=e35bace9de5addae7c32f405cdc11bb459cb1d61#e35bace9de5addae7c32f405cdc11bb459cb1d61" +version = "22.0.0-rc.2" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=f0e653e364b19a7bf23bcb6b1cb2427ba12cee44#f0e653e364b19a7bf23bcb6b1cb2427ba12cee44" dependencies = [ "prettyplease", "proc-macro2", @@ -1095,7 +1243,7 @@ dependencies = [ "sha2", "soroban-spec", "stellar-xdr", - "syn", + "syn 2.0.79", "thiserror", ] @@ -1108,8 +1256,9 @@ dependencies = [ [[package]] name = "soroban-wasmi" -version = "0.31.0-soroban1" -source = "git+https://github.com/stellar/wasmi?rev=7e63b4c9e08c4163f417d118d81f7ea34789d0be#7e63b4c9e08c4163f417d118d81f7ea34789d0be" +version = "0.31.1-soroban.20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710403de32d0e0c35375518cb995d4fc056d0d48966f2e56ea471b8cb8fc9719" dependencies = [ "smallvec", "spin", @@ -1149,23 +1298,25 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-strkey" -version = "0.0.8" +version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd" +checksum = "5e3aa3ed00e70082cb43febc1c2afa5056b9bb3e348bbb43d0cd0aa88a611144" dependencies = [ - "base32", "crate-git-revision", + "data-encoding", "thiserror", ] [[package]] name = "stellar-xdr" -version = "20.0.0-rc1" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=d6f8ece2c89809d5e2800b9df64ae60787ee492b#d6f8ece2c89809d5e2800b9df64ae60787ee492b" +version = "22.0.0-rc.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c88dc0e928b9cb65ea43836b52560bb4ead3e32895f5019ca223dc7cd1966cbf" dependencies = [ "arbitrary", "base64 0.13.1", "crate-git-revision", + "escape-bytes", "hex", "serde", "serde_with", @@ -1174,21 +1325,32 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.39" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1197,32 +1359,33 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.79", ] [[package]] name = "time" -version = "0.3.30" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -1237,10 +1400,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -1252,15 +1416,15 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1270,34 +1434,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.79", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1305,32 +1470,34 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasmi_arena" -version = "0.4.0" -source = "git+https://github.com/stellar/wasmi?rev=7e63b4c9e08c4163f417d118d81f7ea34789d0be#7e63b4c9e08c4163f417d118d81f7ea34789d0be" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "104a7f73be44570cac297b3035d76b169d6599637631cf37a1703326a0727073" [[package]] name = "wasmi_core" version = "0.13.0" -source = "git+https://github.com/stellar/wasmi?rev=7e63b4c9e08c4163f417d118d81f7ea34789d0be#7e63b4c9e08c4163f417d118d81f7ea34789d0be" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a" dependencies = [ "downcast-rs", "libm", @@ -1340,40 +1507,42 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.88.0" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8cf7dd82407fe68161bedcd57fde15596f32ebf6e9b3bdbf3ae1da20e38e5e" +checksum = "a58e28b80dd8340cb07b8242ae654756161f6fc8d0038123d679b7b99964fa50" dependencies = [ - "indexmap 1.9.3", + "indexmap 2.6.0", + "semver", ] [[package]] name = "wasmparser-nostd" -version = "0.100.1" +version = "0.100.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9157cab83003221bfd385833ab587a039f5d6fa7304854042ba358a3b09e0724" +checksum = "d5a015fe95f3504a94bb1462c717aae75253e39b9dd6c3fb1062c934535c64aa" dependencies = [ "indexmap-nostd", ] [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1382,48 +1551,89 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] diff --git a/services/horizon/internal/integration/contracts/Cargo.toml b/services/horizon/internal/integration/contracts/Cargo.toml index 72ada87404..2fcdb8fd5b 100644 --- a/services/horizon/internal/integration/contracts/Cargo.toml +++ b/services/horizon/internal/integration/contracts/Cargo.toml @@ -6,6 +6,7 @@ members = [ "increment", "add_u64", "store", + "constructor", ] [profile.release-with-logs] @@ -23,6 +24,6 @@ codegen-units = 1 lto = true [workspace.dependencies.soroban-sdk] -version = "20.0.0-rc2" +version = "22.0.0-rc.2" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "e35bace9de5addae7c32f405cdc11bb459cb1d61" +rev = "f0e653e364b19a7bf23bcb6b1cb2427ba12cee44" diff --git a/services/horizon/internal/integration/contracts/constructor/Cargo.toml b/services/horizon/internal/integration/contracts/constructor/Cargo.toml new file mode 100644 index 0000000000..1ff6d4e505 --- /dev/null +++ b/services/horizon/internal/integration/contracts/constructor/Cargo.toml @@ -0,0 +1,17 @@ +[package] +version = "0.0.0" +name = "soroban-constructor-contract" +authors = ["Stellar Development Foundation "] +license = "Apache-2.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] +doctest = false + +[dependencies] +soroban-sdk = { workspace = true } + +[dev_dependencies] +soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/services/horizon/internal/integration/contracts/constructor/src/lib.rs b/services/horizon/internal/integration/contracts/constructor/src/lib.rs new file mode 100644 index 0000000000..08be44d001 --- /dev/null +++ b/services/horizon/internal/integration/contracts/constructor/src/lib.rs @@ -0,0 +1,18 @@ +#![no_std] +use soroban_sdk::{contract, contractimpl, symbol_short, Address, Env, token, Symbol}; + +#[contract] +pub struct Contract; + +const KEY: Symbol = symbol_short!("key"); + +#[contractimpl] +impl Contract { + pub fn __constructor(env: Env, sender: Address, token_contract: Address, amount: i128) { + let client = token::Client::new(&env, &token_contract); + client.transfer(&sender, &env.current_contract_address(), &amount); + env.storage().persistent().set(&KEY, &1_u32); + env.storage().instance().set(&KEY, &2_u32); + env.storage().temporary().set(&KEY, &3_u32); + } +} diff --git a/services/horizon/internal/integration/invokehostfunction_test.go b/services/horizon/internal/integration/invokehostfunction_test.go index 6447b98147..216bc8607c 100644 --- a/services/horizon/internal/integration/invokehostfunction_test.go +++ b/services/horizon/internal/integration/invokehostfunction_test.go @@ -5,11 +5,14 @@ import ( "encoding/hex" "os" "path/filepath" + "strings" "testing" + "github.com/stellar/go/amount" "github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/protocols/horizon/operations" "github.com/stellar/go/services/horizon/internal/test/integration" + "github.com/stellar/go/strkey" "github.com/stellar/go/txnbuild" "github.com/stellar/go/xdr" @@ -19,6 +22,7 @@ import ( const add_u64_contract = "soroban_add_u64.wasm" const increment_contract = "soroban_increment_contract.wasm" +const constructor_contract = "soroban_constructor_contract.wasm" // Tests use precompiled wasm bin files that are added to the testdata directory. // Refer to ./services/horizon/internal/integration/contracts/README.md on how to recompile @@ -94,7 +98,7 @@ func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) { itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract - createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) + createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1") preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) @@ -126,6 +130,99 @@ func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) { assert.Equal(t, invokeHostFunctionOpJson.Salt, "110986164698320180327942133831752629430491002266485370052238869825166557303060") } +func TestContractInvokeHostFunctionCreateConstructorContract(t *testing.T) { + if integration.GetCoreMaxSupportedProtocol() < 22 { + t.Skip("This test run does not support less than Protocol 22") + } + + itest := integration.NewTest(t, integration.Config{ + EnableSorobanRPC: true, + }) + + issuer := itest.Master().Address() + code := "USD" + asset := xdr.MustNewCreditAsset(code, issuer) + createSAC(itest, asset) + + // Install the contract + installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), constructor_contract) + preFlightOp, minFee := itest.PreflightHostFunctions(itest.MasterAccount(), *installContractOp) + itest.MustSubmitOperationsWithFee(itest.MasterAccount(), itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) + + // Create the contract + senderAddressArg := accountAddressParam(itest.Master().Address()) + usdcAddress := contractIDParam(stellarAssetContractID(itest, asset)) + usdcAddressArg := xdr.ScVal{ + Type: xdr.ScValTypeScvAddress, + Address: &usdcAddress, + } + amount := i128Param(0, uint64(amount.MustParse("10.0000000"))) + createContractOp := assembleCreateContractConstructorOp( + t, + itest.Master().Address(), + constructor_contract, + "a1", + []xdr.ScVal{ + senderAddressArg, + usdcAddressArg, + amount, + }, + ) + preFlightOp, minFee = itest.PreflightHostFunctions(itest.MasterAccount(), *createContractOp) + tx, err := itest.SubmitOperationsWithFee(itest.MasterAccount(), itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) + require.NoError(t, err) + contractID := preFlightOp.Ext.SorobanData.Resources.Footprint.ReadWrite[0].MustContractData().Contract.ContractId + + clientTx, err := itest.Client().TransactionDetail(tx.Hash) + require.NoError(t, err) + + assert.Equal(t, tx.Hash, clientTx.Hash) + var txResult xdr.TransactionResult + err = xdr.SafeUnmarshalBase64(clientTx.ResultXdr, &txResult) + require.NoError(t, err) + + opResults, ok := txResult.OperationResults() + assert.True(t, ok) + assert.Equal(t, len(opResults), 1) + invokeHostFunctionResult, ok := opResults[0].MustTr().GetInvokeHostFunctionResult() + assert.True(t, ok) + assert.Equal(t, invokeHostFunctionResult.Code, xdr.InvokeHostFunctionResultCodeInvokeHostFunctionSuccess) + + clientInvokeOp, err := itest.Client().Operations(horizonclient.OperationRequest{ + ForTransaction: tx.Hash, + }) + require.NoError(t, err) + + invokeHostFunctionOpJson, ok := clientInvokeOp.Embedded.Records[0].(operations.InvokeHostFunction) + assert.True(t, ok) + assert.Equal(t, invokeHostFunctionOpJson.Function, "HostFunctionTypeHostFunctionTypeCreateContractV2") + assert.Equal(t, invokeHostFunctionOpJson.Address, itest.Master().Address()) + assert.Equal(t, invokeHostFunctionOpJson.Salt, "110986164698320180327942133831752629430491002266485370052238869825166557303060") + + assert.Len(t, invokeHostFunctionOpJson.Parameters, 3) + serializedKey, err := xdr.MarshalBase64(senderAddressArg) + assert.NoError(t, err) + assert.Equal(t, invokeHostFunctionOpJson.Parameters[0].Value, serializedKey) + assert.Equal(t, invokeHostFunctionOpJson.Parameters[0].Type, "Address") + serializedKey, err = xdr.MarshalBase64(usdcAddressArg) + assert.NoError(t, err) + assert.Equal(t, invokeHostFunctionOpJson.Parameters[1].Value, serializedKey) + assert.Equal(t, invokeHostFunctionOpJson.Parameters[1].Type, "Address") + serializedKey, err = xdr.MarshalBase64(amount) + assert.NoError(t, err) + assert.Equal(t, invokeHostFunctionOpJson.Parameters[2].Value, serializedKey) + assert.Equal(t, invokeHostFunctionOpJson.Parameters[2].Type, "I128") + + assert.Len(t, invokeHostFunctionOpJson.AssetBalanceChanges, 1) + assetBalanceChange := invokeHostFunctionOpJson.AssetBalanceChanges[0] + assert.Equal(itest.CurrentTest(), assetBalanceChange.Amount, "10.0000000") + assert.Equal(itest.CurrentTest(), assetBalanceChange.From, issuer) + assert.Equal(itest.CurrentTest(), assetBalanceChange.To, strkey.MustEncode(strkey.VersionByteContract, contractID[:])) + assert.Equal(itest.CurrentTest(), assetBalanceChange.Type, "transfer") + assert.Equal(itest.CurrentTest(), assetBalanceChange.Asset.Code, strings.TrimRight(asset.GetCode(), "\x00")) + assert.Equal(itest.CurrentTest(), assetBalanceChange.Asset.Issuer, asset.GetIssuer()) +} + func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") @@ -147,7 +244,7 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract - createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) + createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1") preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) @@ -257,7 +354,7 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { // Create the contract - createContractOp := assembleCreateContractOp(t, itest.Master().Address(), increment_contract, "a1", itest.GetPassPhrase()) + createContractOp := assembleCreateContractOp(t, itest.Master().Address(), increment_contract, "a1") preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) @@ -342,7 +439,7 @@ func assembleInstallContractCodeOp(t *testing.T, sourceAccount string, wasmFileN } } -func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName string, contractSalt string, passPhrase string) *txnbuild.InvokeHostFunction { +func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName string, contractSalt string) *txnbuild.InvokeHostFunction { // Assemble the InvokeHostFunction CreateContract operation: // CAP-0047 - https://github.com/stellar/stellar-protocol/blob/master/core/cap-0047.md#creating-a-contract-using-invokehostfunctionop @@ -380,3 +477,40 @@ func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName s SourceAccount: sourceAccount, } } + +func assembleCreateContractConstructorOp(t *testing.T, sourceAccount string, wasmFileName string, contractSalt string, args []xdr.ScVal) *txnbuild.InvokeHostFunction { + contract, err := os.ReadFile(filepath.Join("testdata", wasmFileName)) + require.NoError(t, err) + + salt := sha256.Sum256([]byte(contractSalt)) + t.Logf("Salt hash: %v", hex.EncodeToString(salt[:])) + saltParameter := xdr.Uint256(salt) + + accountId := xdr.MustAddress(sourceAccount) + require.NoError(t, err) + contractHash := xdr.Hash(sha256.Sum256(contract)) + + return &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeCreateContractV2, + CreateContractV2: &xdr.CreateContractArgsV2{ + ContractIdPreimage: xdr.ContractIdPreimage{ + Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAddress, + FromAddress: &xdr.ContractIdPreimageFromAddress{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Salt: saltParameter, + }, + }, + Executable: xdr.ContractExecutable{ + Type: xdr.ContractExecutableTypeContractExecutableWasm, + WasmHash: &contractHash, + }, + ConstructorArgs: args, + }, + }, + SourceAccount: sourceAccount, + } +} diff --git a/services/horizon/internal/integration/liquidity_pool_test.go b/services/horizon/internal/integration/liquidity_pool_test.go index 9106003179..bb7e39a7c6 100644 --- a/services/horizon/internal/integration/liquidity_pool_test.go +++ b/services/horizon/internal/integration/liquidity_pool_test.go @@ -156,8 +156,6 @@ func TestLiquidityPoolHappyPath(t *testing.T) { tt.Equal("credit_alphanum4", stat.Asset.Type) tt.Equal("USD", stat.Asset.Code) tt.Equal(master.Address(), stat.Asset.Issuer) - tt.Equal(int32(2), stat.NumAccounts) - tt.Equal("225.0000000", stat.Amount) tt.Equal(int32(1), stat.NumLiquidityPools) tt.Equal("775.0000000", stat.LiquidityPoolsAmount) diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index 7eb91a201c..4a9db284bf 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -260,9 +260,7 @@ func TestExpirationAndRestoration(t *testing.T) { LiquidityPools: "0", Unauthorized: "0", }, - Amount: "0", - NumAccounts: 0, - ContractID: nil, + ContractID: nil, } syntheticAssetStat.SetContractID(storeContractID) _, err := itest.HorizonIngest().HistoryQ().InsertAssetStat( @@ -1104,9 +1102,7 @@ func assertAssetStats(itest *integration.Test, expected assetStats) { asset := assets.Embedded.Records[0] assert.Equal(itest.CurrentTest(), expected.code, asset.Code) assert.Equal(itest.CurrentTest(), expected.issuer, asset.Issuer) - assert.Equal(itest.CurrentTest(), expected.numAccounts, asset.NumAccounts) assert.Equal(itest.CurrentTest(), expected.numAccounts, asset.Accounts.Authorized) - assert.Equal(itest.CurrentTest(), expected.balanceAccounts, amount.MustParse(asset.Amount)) assert.Equal(itest.CurrentTest(), expected.numContracts, asset.NumContracts) assert.Equal(itest.CurrentTest(), expected.numArchivedContracts, asset.NumArchivedContracts) assert.Equal(itest.CurrentTest(), expected.balanceContracts.String(), parseBalance(itest, asset.ContractsAmount).String()) @@ -1425,13 +1421,7 @@ func mustCreateAndInstallContract(itest *integration.Test, signer *keypair.Full, _, _, createContractOp := assertInvokeHostFnSucceeds( itest, signer, - assembleCreateContractOp( - itest.CurrentTest(), - itest.Master().Address(), - wasmFileName, - contractSalt, - itest.GetPassPhrase(), - ), + assembleCreateContractOp(itest.CurrentTest(), itest.Master().Address(), wasmFileName, contractSalt), ) keys := append( diff --git a/services/horizon/internal/integration/testdata/soroban_add_u64.wasm b/services/horizon/internal/integration/testdata/soroban_add_u64.wasm index 9ffd8622b7..76a8f617d7 100755 Binary files a/services/horizon/internal/integration/testdata/soroban_add_u64.wasm and b/services/horizon/internal/integration/testdata/soroban_add_u64.wasm differ diff --git a/services/horizon/internal/integration/testdata/soroban_constructor_contract.wasm b/services/horizon/internal/integration/testdata/soroban_constructor_contract.wasm new file mode 100755 index 0000000000..88ff28aa4e Binary files /dev/null and b/services/horizon/internal/integration/testdata/soroban_constructor_contract.wasm differ diff --git a/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm b/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm index b975e5ccd5..de0b68c62a 100755 Binary files a/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm and b/services/horizon/internal/integration/testdata/soroban_increment_contract.wasm differ diff --git a/services/horizon/internal/integration/testdata/soroban_sac_test.wasm b/services/horizon/internal/integration/testdata/soroban_sac_test.wasm index 9424da50fd..5a251794bb 100755 Binary files a/services/horizon/internal/integration/testdata/soroban_sac_test.wasm and b/services/horizon/internal/integration/testdata/soroban_sac_test.wasm differ diff --git a/services/horizon/internal/integration/testdata/soroban_store.wasm b/services/horizon/internal/integration/testdata/soroban_store.wasm index 7f839bd208..3d2c799b26 100755 Binary files a/services/horizon/internal/integration/testdata/soroban_store.wasm and b/services/horizon/internal/integration/testdata/soroban_store.wasm differ diff --git a/services/horizon/internal/integration/transaction_preconditions_test.go b/services/horizon/internal/integration/transaction_preconditions_test.go index e3aff9e0da..4bf7a6acb8 100644 --- a/services/horizon/internal/integration/transaction_preconditions_test.go +++ b/services/horizon/internal/integration/transaction_preconditions_test.go @@ -49,20 +49,11 @@ func TestTransactionPreconditionsTimeBounds(t *testing.T) { txHistory, err := itest.Client().TransactionDetail(tx.Hash) assert.NoError(t, err) - // Check that the deprecated string datetime fields match the new UNIX - // timestamp fields. - deprecatedHistoryMinTime, err := time.Parse(time.RFC3339, txHistory.ValidAfter) - assert.NoError(t, err) - deprecatedHistoryMaxTime, err := time.Parse(time.RFC3339, txHistory.ValidBefore) - assert.NoError(t, err) - historyMinTime, err := strconv.ParseInt(txHistory.Preconditions.TimeBounds.MinTime, 10, 64) assert.NoError(t, err) historyMaxTime, err := strconv.ParseInt(txHistory.Preconditions.TimeBounds.MaxTime, 10, 64) assert.NoError(t, err) - assert.Equal(t, historyMinTime, deprecatedHistoryMinTime.UTC().Unix()) - assert.Equal(t, historyMaxTime, deprecatedHistoryMaxTime.UTC().Unix()) assert.Equal(t, historyMinTime, txParams.Preconditions.TimeBounds.MinTime) assert.Equal(t, historyMaxTime, txParams.Preconditions.TimeBounds.MaxTime) } diff --git a/services/horizon/internal/integration/txsub_async_test.go b/services/horizon/internal/integration/txsub_async_test.go index 2d16e4d4ea..8310be1dba 100644 --- a/services/horizon/internal/integration/txsub_async_test.go +++ b/services/horizon/internal/integration/txsub_async_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/protocols/horizon" @@ -86,9 +87,10 @@ func TestAsyncTxSub_SubmissionError(t *testing.T) { txResp, err := itest.AsyncSubmitTransaction(master, txParams) assert.NoError(t, err) assert.Equal(t, txResp, horizon.AsyncTransactionSubmissionResponse{ - ErrorResultXDR: "AAAAAAAAAGT////7AAAAAA==", - TxStatus: "ERROR", - Hash: "0684df00f20efd5876f1b8d17bc6d3a68d8b85c06bb41e448815ecaa6307a251", + ErrorResultXDR: "AAAAAAAAAGT////7AAAAAA==", + DeprecatedErrorResultXDR: "AAAAAAAAAGT////7AAAAAA==", + TxStatus: "ERROR", + Hash: "0684df00f20efd5876f1b8d17bc6d3a68d8b85c06bb41e448815ecaa6307a251", }) } @@ -131,6 +133,31 @@ func TestAsyncTxSub_SubmissionTryAgainLater(t *testing.T) { }) } +func TestAsyncTxSub_TransactionMalformed(t *testing.T) { + itest := integration.NewTest(t, integration.Config{ + EnableSorobanRPC: true, + HorizonEnvironment: map[string]string{ + "MAX_HTTP_REQUEST_SIZE": "1800", + }, + }) + master := itest.Master() + + // establish which account will be contract owner, and load it's current seq + sourceAccount, err := itest.Client().AccountDetail(horizonclient.AccountRequest{ + AccountID: itest.Master().Address(), + }) + require.NoError(t, err) + + installContractOp := assembleInstallContractCodeOp(t, master.Address(), "soroban_sac_test.wasm") + preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) + txParams := integration.GetBaseTransactionParamsWithFee(&sourceAccount, minFee+txnbuild.MinBaseFee, &preFlightOp) + _, err = itest.AsyncSubmitTransaction(master, txParams) + assert.EqualError( + t, err, + "horizon error: \"Transaction Malformed\" - check horizon.Error.Problem for more information", + ) +} + func TestAsyncTxSub_GetOpenAPISpecResponse(t *testing.T) { itest := integration.NewTest(t, integration.Config{}) res, err := http.Get(itest.AsyncTxSubOpenAPISpecURL()) diff --git a/services/horizon/internal/resourceadapter/asset_stat.go b/services/horizon/internal/resourceadapter/asset_stat.go index 994cce99a0..8cc2c12740 100644 --- a/services/horizon/internal/resourceadapter/asset_stat.go +++ b/services/horizon/internal/resourceadapter/asset_stat.go @@ -39,7 +39,6 @@ func PopulateAssetStat( res.NumLiquidityPools = row.Accounts.LiquidityPools res.NumContracts = row.Contracts.ActiveHolders res.NumArchivedContracts = row.Contracts.ArchivedHolders - res.NumAccounts = row.NumAccounts err = populateAssetStatBalances(res, row) if err != nil { return err @@ -63,7 +62,6 @@ func PopulateAssetStat( } func populateAssetStatBalances(res *protocol.AssetStat, row history.AssetAndContractStat) (err error) { - res.Amount, err = amount.IntStringToAmount(row.Balances.Authorized) if err != nil { return errors.Wrap(err, "Invalid amount in PopulateAssetStat") } diff --git a/services/horizon/internal/resourceadapter/asset_stat_test.go b/services/horizon/internal/resourceadapter/asset_stat_test.go index d3b14d62e6..cd3209414d 100644 --- a/services/horizon/internal/resourceadapter/asset_stat_test.go +++ b/services/horizon/internal/resourceadapter/asset_stat_test.go @@ -31,8 +31,6 @@ func TestPopulateExpAssetStat(t *testing.T) { ClaimableBalances: "1200000000000000000", LiquidityPools: "7700000000000000000", }, - Amount: "100000000000000000000", // 10T - NumAccounts: 429, }, Contracts: history.ContractStat{ ActiveBalance: "900000000000000000", @@ -67,8 +65,6 @@ func TestPopulateExpAssetStat(t *testing.T) { assert.Equal(t, "770000000000.0000000", res.LiquidityPoolsAmount) assert.Equal(t, "90000000000.0000000", res.ContractsAmount) assert.Equal(t, "70000000000.0000000", res.ArchivedContractsAmount) - assert.Equal(t, "10000000000000.0000000", res.Amount) - assert.Equal(t, int32(429), res.NumAccounts) assert.Equal(t, horizon.AccountFlags{}, res.Flags) assert.Equal(t, "https://xim.com/.well-known/stellar.toml", res.Links.Toml.Href) assert.Equal(t, "", res.ContractID) @@ -90,8 +86,6 @@ func TestPopulateExpAssetStat(t *testing.T) { assert.Equal(t, "credit_alphanum4", res.Type) assert.Equal(t, "XIM", res.Code) assert.Equal(t, "GBZ35ZJRIKJGYH5PBKLKOZ5L6EXCNTO7BKIL7DAVVDFQ2ODJEEHHJXIM", res.Issuer) - assert.Equal(t, "10000000000000.0000000", res.Amount) - assert.Equal(t, int32(429), res.NumAccounts) assert.Equal( t, horizon.AccountFlags{ diff --git a/services/horizon/internal/resourceadapter/transaction.go b/services/horizon/internal/resourceadapter/transaction.go index f458830c2d..4120c5f564 100644 --- a/services/horizon/internal/resourceadapter/transaction.go +++ b/services/horizon/internal/resourceadapter/transaction.go @@ -4,10 +4,8 @@ import ( "context" "encoding/base64" "fmt" - "strconv" - "time" - "github.com/guregu/null" + "strconv" horizonContext "github.com/stellar/go/services/horizon/internal/context" "github.com/stellar/go/xdr" @@ -66,10 +64,6 @@ func PopulateTransaction( dest.Preconditions = &protocol.TransactionPreconditions{} if !row.TimeBounds.Null { - // Action needed in release: horizon-v3.0.0: remove ValidBefore and ValidAfter - dest.ValidBefore = timeString(row.TimeBounds.Upper) - dest.ValidAfter = timeString(row.TimeBounds.Lower) - dest.Preconditions.TimeBounds = &protocol.TransactionPreconditionsTimebounds{ MaxTime: timestampString(row.TimeBounds.Upper), MinTime: timestampString(row.TimeBounds.Lower), @@ -157,14 +151,6 @@ func memoBytes(envelopeXDR string) (string, error) { return base64.StdEncoding.EncodeToString([]byte(memo)), nil } -func timeString(in null.Int) string { - if !in.Valid { - return "" - } - - return time.Unix(in.Int64, 0).UTC().Format(time.RFC3339) -} - func timestampString(in null.Int) string { if !in.Valid { return "" diff --git a/services/horizon/internal/resourceadapter/transaction_test.go b/services/horizon/internal/resourceadapter/transaction_test.go index 694fc885fb..8ce0fe0271 100644 --- a/services/horizon/internal/resourceadapter/transaction_test.go +++ b/services/horizon/internal/resourceadapter/transaction_test.go @@ -223,8 +223,6 @@ func TestPopulateTransaction_Preconditions(t *testing.T) { assert.NoError(t, PopulateTransaction(ctx, row.TransactionHash, &dest, row, false)) assert.NotEmpty(t, dest.ResultMetaXdr) p := dest.Preconditions - assert.Equal(t, validAfter.Format(time.RFC3339), dest.ValidAfter) - assert.Equal(t, validBefore.Format(time.RFC3339), dest.ValidBefore) assert.Equal(t, fmt.Sprint(validAfter.Unix()), p.TimeBounds.MinTime) assert.Equal(t, fmt.Sprint(validBefore.Unix()), p.TimeBounds.MaxTime) assert.Equal(t, minLedger, p.LedgerBounds.MinLedger) diff --git a/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go b/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go index f26afdae11..a24afb9318 100644 --- a/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go +++ b/services/regulated-assets-approval-server/internal/configureissuer/configureissuer_test.go @@ -45,6 +45,9 @@ func TestSetup_accountAlreadyConfigured(t *testing.T) { HomeDomain: "domain.test.com", Sequence: 10, }, nil) + + dummyAsset := horizon.AssetStat{} + dummyAsset.Asset.Code = "FOO" horizonMock. On("Assets", horizonclient.AssetRequest{ ForAssetCode: opts.AssetCode, @@ -53,9 +56,7 @@ func TestSetup_accountAlreadyConfigured(t *testing.T) { }). Return(horizon.AssetsPage{ Embedded: struct{ Records []horizon.AssetStat }{ - Records: []horizon.AssetStat{ - {Amount: "0.0000001"}, - }, + Records: []horizon.AssetStat{dummyAsset}, }, }, nil) diff --git a/services/ticker/internal/scraper/asset_scraper.go b/services/ticker/internal/scraper/asset_scraper.go index ca7899a25d..0bbc82452a 100644 --- a/services/ticker/internal/scraper/asset_scraper.go +++ b/services/ticker/internal/scraper/asset_scraper.go @@ -23,15 +23,16 @@ import ( // shouldDiscardAsset maps the criteria for discarding an asset from the asset index func shouldDiscardAsset(asset hProtocol.AssetStat, shouldValidateTOML bool) bool { - if asset.Amount == "" { + + if asset.Balances.Authorized == "" { return true } - f, _ := strconv.ParseFloat(asset.Amount, 64) + f, _ := strconv.ParseFloat(asset.Balances.Authorized, 64) if f == 0.0 { return true } // [StellarX Ticker]: assets need at least some adoption to show up - if asset.NumAccounts < 10 { + if asset.Accounts.Authorized < 10 { return true } if asset.Code == "REMOVE" { @@ -39,7 +40,7 @@ func shouldDiscardAsset(asset hProtocol.AssetStat, shouldValidateTOML bool) bool } // [StellarX Ticker]: assets with at least 100 accounts get a pass, // even with toml issues - if asset.NumAccounts >= 100 { + if asset.Accounts.Authorized >= 100 { return false } @@ -150,7 +151,7 @@ func makeFinalAsset( issuer TOMLIssuer, errors []error, ) (t FinalAsset, err error) { - amount, err := strconv.ParseFloat(asset.Amount, 64) + amount, err := strconv.ParseFloat(asset.Balances.Authorized, 64) if err != nil { return } @@ -159,7 +160,7 @@ func makeFinalAsset( Type: asset.Type, Code: asset.Code, Issuer: asset.Issuer, - NumAccounts: asset.NumAccounts, + NumAccounts: asset.Accounts.Authorized, AuthRequired: asset.Flags.AuthRequired, AuthRevocable: asset.Flags.AuthRevocable, Amount: amount, diff --git a/services/ticker/internal/scraper/asset_scraper_test.go b/services/ticker/internal/scraper/asset_scraper_test.go index 39f3e0a2ee..411fa9e528 100644 --- a/services/ticker/internal/scraper/asset_scraper_test.go +++ b/services/ticker/internal/scraper/asset_scraper_test.go @@ -15,63 +15,52 @@ import ( ) func TestShouldDiscardAsset(t *testing.T) { - testAsset := hProtocol.AssetStat{ - Amount: "", - } - + testAsset := hProtocol.AssetStat{} assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "0.0", - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "0", - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "0" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 8, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 0 assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 12, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 12 testAsset.Code = "REMOVE" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 100, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 100 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "" assert.Equal(t, shouldDiscardAsset(testAsset, true), false) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 40, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 40 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "http://www.stellar.org/.well-known/stellar.toml" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 40, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 40 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "" assert.Equal(t, shouldDiscardAsset(testAsset, true), true) - testAsset = hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 40, - } + testAsset = hProtocol.AssetStat{} + testAsset.Balances.Authorized = "12345.67" + testAsset.Accounts.Authorized = 40 testAsset.Code = "SOMETHINGVALID" testAsset.Links.Toml.Href = "https://www.stellar.org/.well-known/stellar.toml" assert.Equal(t, shouldDiscardAsset(testAsset, true), false) @@ -154,11 +143,10 @@ func TestProcessAsset_notCached(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, `SIGNING_KEY="not cached signing key"`) })) - asset := hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 100, - } + asset := hProtocol.AssetStat{} asset.Code = "SOMETHINGVALID" + asset.Accounts.Authorized = 1 + asset.Balances.Authorized = "123.4" asset.Links.Toml.Href = server.URL tomlCache := &TOMLCache{} finalAsset, err := processAsset(logger, asset, tomlCache, true) @@ -172,11 +160,10 @@ func TestProcessAsset_notCached(t *testing.T) { func TestProcessAsset_cached(t *testing.T) { logger := log.DefaultLogger - asset := hProtocol.AssetStat{ - Amount: "123901.0129310", - NumAccounts: 100, - } + asset := hProtocol.AssetStat{} asset.Code = "SOMETHINGVALID" + asset.Accounts.Authorized = 1 + asset.Balances.Authorized = "123.4" asset.Links.Toml.Href = "url" tomlCache := &TOMLCache{} tomlCache.Set("url", TOMLIssuer{SigningKey: "signing key"}) diff --git a/support/compressxdr/compress_xdr.go b/support/compressxdr/compress_xdr.go index 514251f971..7fc957d2a8 100644 --- a/support/compressxdr/compress_xdr.go +++ b/support/compressxdr/compress_xdr.go @@ -3,7 +3,7 @@ package compressxdr import ( "io" - xdr3 "github.com/stellar/go-xdr/xdr3" + "github.com/stellar/go/xdr" ) func NewXDREncoder(compressor Compressor, xdrPayload interface{}) XDREncoder { @@ -29,7 +29,7 @@ func (e XDREncoder) WriteTo(w io.Writer) (int64, error) { } defer zw.Close() - n, err := xdr3.Marshal(zw, e.XdrPayload) + n, err := xdr.Marshal(zw, e.XdrPayload) return int64(n), err } @@ -47,6 +47,6 @@ func (d XDRDecoder) ReadFrom(r io.Reader) (int64, error) { } defer zr.Close() - n, err := xdr3.Unmarshal(zr, d.XdrPayload) + n, err := xdr.Unmarshal(zr, d.XdrPayload) return int64(n), err } diff --git a/support/compressxdr/compress_xdr_test.go b/support/compressxdr/compress_xdr_test.go index 82aa7e186c..79d6b65690 100644 --- a/support/compressxdr/compress_xdr_test.go +++ b/support/compressxdr/compress_xdr_test.go @@ -2,10 +2,13 @@ package compressxdr import ( "bytes" + "io/ioutil" + "os" "testing" - "github.com/stellar/go/xdr" "github.com/stretchr/testify/require" + + "github.com/stellar/go/xdr" ) func createTestLedgerCloseMetaBatch(startSeq, endSeq uint32, count int) xdr.LedgerCloseMetaBatch { @@ -46,3 +49,34 @@ func TestEncodeDecodeLedgerCloseMetaBatch(t *testing.T) { require.Equal(t, testData.LedgerCloseMetas[i], decodedData.LedgerCloseMetas[i]) } } + +func BenchmarkDecodeLedgerCloseMetaBatch(b *testing.B) { + lcmBatch := xdr.LedgerCloseMetaBatch{} + decoder := NewXDRDecoder(DefaultCompressor, &lcmBatch) + + for n := 0; n < b.N; n++ { + file, err := os.Open("testdata/FCD285FF--53312000.xdr.zstd") + require.NoError(b, err) + + _, err = decoder.ReadFrom(file) + require.NoError(b, err) + } +} + +func BenchmarkEncodeLedgerCloseMetaBatch(b *testing.B) { + lcmBatch := xdr.LedgerCloseMetaBatch{} + decoder := NewXDRDecoder(DefaultCompressor, &lcmBatch) + file, err := os.Open("testdata/FCD285FF--53312000.xdr.zstd") + require.NoError(b, err) + + _, err = decoder.ReadFrom(file) + require.NoError(b, err) + + b.ResetTimer() + + for n := 0; n < b.N; n++ { + encoder := NewXDREncoder(DefaultCompressor, &lcmBatch) + _, err = encoder.WriteTo(ioutil.Discard) + require.NoError(b, err) + } +} diff --git a/support/compressxdr/testdata/FCD285FF--53312000.xdr.zstd b/support/compressxdr/testdata/FCD285FF--53312000.xdr.zstd new file mode 100644 index 0000000000..e6d901815a Binary files /dev/null and b/support/compressxdr/testdata/FCD285FF--53312000.xdr.zstd differ diff --git a/xdr/Stellar-contract-config-setting.x b/xdr/Stellar-contract-config-setting.x index 52cc0224df..9f09c7b0e4 100644 --- a/xdr/Stellar-contract-config-setting.x +++ b/xdr/Stellar-contract-config-setting.x @@ -188,7 +188,58 @@ enum ContractCostType { // point on a 256-bit elliptic curve Sec1DecodePointUncompressed = 43, // Cost of verifying an ECDSA Secp256r1 signature - VerifyEcdsaSecp256r1Sig = 44 + VerifyEcdsaSecp256r1Sig = 44, + + // Cost of encoding a BLS12-381 Fp (base field element) + Bls12381EncodeFp = 45, + // Cost of decoding a BLS12-381 Fp (base field element) + Bls12381DecodeFp = 46, + // Cost of checking a G1 point lies on the curve + Bls12381G1CheckPointOnCurve = 47, + // Cost of checking a G1 point belongs to the correct subgroup + Bls12381G1CheckPointInSubgroup = 48, + // Cost of checking a G2 point lies on the curve + Bls12381G2CheckPointOnCurve = 49, + // Cost of checking a G2 point belongs to the correct subgroup + Bls12381G2CheckPointInSubgroup = 50, + // Cost of converting a BLS12-381 G1 point from projective to affine coordinates + Bls12381G1ProjectiveToAffine = 51, + // Cost of converting a BLS12-381 G2 point from projective to affine coordinates + Bls12381G2ProjectiveToAffine = 52, + // Cost of performing BLS12-381 G1 point addition + Bls12381G1Add = 53, + // Cost of performing BLS12-381 G1 scalar multiplication + Bls12381G1Mul = 54, + // Cost of performing BLS12-381 G1 multi-scalar multiplication (MSM) + Bls12381G1Msm = 55, + // Cost of mapping a BLS12-381 Fp field element to a G1 point + Bls12381MapFpToG1 = 56, + // Cost of hashing to a BLS12-381 G1 point + Bls12381HashToG1 = 57, + // Cost of performing BLS12-381 G2 point addition + Bls12381G2Add = 58, + // Cost of performing BLS12-381 G2 scalar multiplication + Bls12381G2Mul = 59, + // Cost of performing BLS12-381 G2 multi-scalar multiplication (MSM) + Bls12381G2Msm = 60, + // Cost of mapping a BLS12-381 Fp2 field element to a G2 point + Bls12381MapFp2ToG2 = 61, + // Cost of hashing to a BLS12-381 G2 point + Bls12381HashToG2 = 62, + // Cost of performing BLS12-381 pairing operation + Bls12381Pairing = 63, + // Cost of converting a BLS12-381 scalar element from U256 + Bls12381FrFromU256 = 64, + // Cost of converting a BLS12-381 scalar element to U256 + Bls12381FrToU256 = 65, + // Cost of performing BLS12-381 scalar element addition/subtraction + Bls12381FrAddSub = 66, + // Cost of performing BLS12-381 scalar element multiplication + Bls12381FrMul = 67, + // Cost of performing BLS12-381 scalar element exponentiation + Bls12381FrPow = 68, + // Cost of performing BLS12-381 scalar element inversion + Bls12381FrInv = 69 }; struct ContractCostParamEntry { diff --git a/xdr/Stellar-contract-env-meta.x b/xdr/Stellar-contract-env-meta.x index 330726de41..ed6b0b675b 100644 --- a/xdr/Stellar-contract-env-meta.x +++ b/xdr/Stellar-contract-env-meta.x @@ -17,7 +17,10 @@ enum SCEnvMetaKind union SCEnvMetaEntry switch (SCEnvMetaKind kind) { case SC_ENV_META_KIND_INTERFACE_VERSION: - uint64 interfaceVersion; + struct { + uint32 protocol; + uint32 preRelease; + } interfaceVersion; }; } diff --git a/xdr/Stellar-ledger-entries.x b/xdr/Stellar-ledger-entries.x index 3a137ae60d..5bf4f9d368 100644 --- a/xdr/Stellar-ledger-entries.x +++ b/xdr/Stellar-ledger-entries.x @@ -678,4 +678,120 @@ enum EnvelopeType ENVELOPE_TYPE_CONTRACT_ID = 8, ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9 }; -} + +enum BucketListType +{ + LIVE = 0, + HOT_ARCHIVE = 1, + COLD_ARCHIVE = 2 +}; + +/* Entries used to define the bucket list */ +enum BucketEntryType +{ + METAENTRY = + -1, // At-and-after protocol 11: bucket metadata, should come first. + LIVEENTRY = 0, // Before protocol 11: created-or-updated; + // At-and-after protocol 11: only updated. + DEADENTRY = 1, + INITENTRY = 2 // At-and-after protocol 11: only created. +}; + +enum HotArchiveBucketEntryType +{ + HOT_ARCHIVE_METAENTRY = -1, // Bucket metadata, should come first. + HOT_ARCHIVE_ARCHIVED = 0, // Entry is Archived + HOT_ARCHIVE_LIVE = 1, // Entry was previously HOT_ARCHIVE_ARCHIVED, or HOT_ARCHIVE_DELETED, but + // has been added back to the live BucketList. + // Does not need to be persisted. + HOT_ARCHIVE_DELETED = 2 // Entry deleted (Note: must be persisted in archive) +}; + +enum ColdArchiveBucketEntryType +{ + COLD_ARCHIVE_METAENTRY = -1, // Bucket metadata, should come first. + COLD_ARCHIVE_ARCHIVED_LEAF = 0, // Full LedgerEntry that was archived during the epoch + COLD_ARCHIVE_DELETED_LEAF = 1, // LedgerKey that was deleted during the epoch + COLD_ARCHIVE_BOUNDARY_LEAF = 2, // Dummy leaf representing low/high bound + COLD_ARCHIVE_HASH = 3 // Intermediary Merkle hash entry +}; + +struct BucketMetadata +{ + // Indicates the protocol version used to create / merge this bucket. + uint32 ledgerVersion; + + // reserved for future use + union switch (int v) + { + case 0: + void; + case 1: + BucketListType bucketListType; + } + ext; +}; + +union BucketEntry switch (BucketEntryType type) +{ +case LIVEENTRY: +case INITENTRY: + LedgerEntry liveEntry; + +case DEADENTRY: + LedgerKey deadEntry; +case METAENTRY: + BucketMetadata metaEntry; +}; + +union HotArchiveBucketEntry switch (HotArchiveBucketEntryType type) +{ +case HOT_ARCHIVE_ARCHIVED: + LedgerEntry archivedEntry; + +case HOT_ARCHIVE_LIVE: +case HOT_ARCHIVE_DELETED: + LedgerKey key; +case HOT_ARCHIVE_METAENTRY: + BucketMetadata metaEntry; +}; + +struct ColdArchiveArchivedLeaf +{ + uint32 index; + LedgerEntry archivedEntry; +}; + +struct ColdArchiveDeletedLeaf +{ + uint32 index; + LedgerKey deletedKey; +}; + +struct ColdArchiveBoundaryLeaf +{ + uint32 index; + bool isLowerBound; +}; + +struct ColdArchiveHashEntry +{ + uint32 index; + uint32 level; + Hash hash; +}; + +union ColdArchiveBucketEntry switch (ColdArchiveBucketEntryType type) +{ +case COLD_ARCHIVE_METAENTRY: + BucketMetadata metaEntry; +case COLD_ARCHIVE_ARCHIVED_LEAF: + ColdArchiveArchivedLeaf archivedLeaf; +case COLD_ARCHIVE_DELETED_LEAF: + ColdArchiveDeletedLeaf deletedLeaf; +case COLD_ARCHIVE_BOUNDARY_LEAF: + ColdArchiveBoundaryLeaf boundaryLeaf; +case COLD_ARCHIVE_HASH: + ColdArchiveHashEntry hashEntry; +}; +} \ No newline at end of file diff --git a/xdr/Stellar-ledger.x b/xdr/Stellar-ledger.x index d19462aa18..0fc03e2af3 100644 --- a/xdr/Stellar-ledger.x +++ b/xdr/Stellar-ledger.x @@ -157,43 +157,6 @@ struct ConfigUpgradeSet { ConfigSettingEntry updatedEntry<>; }; -/* Entries used to define the bucket list */ -enum BucketEntryType -{ - METAENTRY = - -1, // At-and-after protocol 11: bucket metadata, should come first. - LIVEENTRY = 0, // Before protocol 11: created-or-updated; - // At-and-after protocol 11: only updated. - DEADENTRY = 1, - INITENTRY = 2 // At-and-after protocol 11: only created. -}; - -struct BucketMetadata -{ - // Indicates the protocol version used to create / merge this bucket. - uint32 ledgerVersion; - - // reserved for future use - union switch (int v) - { - case 0: - void; - } - ext; -}; - -union BucketEntry switch (BucketEntryType type) -{ -case LIVEENTRY: -case INITENTRY: - LedgerEntry liveEntry; - -case DEADENTRY: - LedgerKey deadEntry; -case METAENTRY: - BucketMetadata metaEntry; -}; - enum TxSetComponentType { // txs with effective fee <= bid derived from a base fee (if any). diff --git a/xdr/Stellar-transaction.x b/xdr/Stellar-transaction.x index 87dd32d385..7d3248102b 100644 --- a/xdr/Stellar-transaction.x +++ b/xdr/Stellar-transaction.x @@ -476,7 +476,8 @@ enum HostFunctionType { HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0, HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1, - HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 + HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2, + HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2 = 3 }; enum ContractIDPreimageType @@ -503,6 +504,14 @@ struct CreateContractArgs ContractExecutable executable; }; +struct CreateContractArgsV2 +{ + ContractIDPreimage contractIDPreimage; + ContractExecutable executable; + // Arguments of the contract's constructor. + SCVal constructorArgs<>; +}; + struct InvokeContractArgs { SCAddress contractAddress; SCSymbol functionName; @@ -517,20 +526,33 @@ case HOST_FUNCTION_TYPE_CREATE_CONTRACT: CreateContractArgs createContract; case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: opaque wasm<>; +case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: + CreateContractArgsV2 createContractV2; }; enum SorobanAuthorizedFunctionType { SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, - SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1, + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN = 2 }; union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type) { case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: InvokeContractArgs contractFn; +// This variant of auth payload for creating new contract instances +// doesn't allow specifying the constructor arguments, creating contracts +// with constructors that take arguments is only possible by authorizing +// `SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN` +// (protocol 22+). case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: CreateContractArgs createContractHostFn; +// This variant of auth payload for creating new contract instances +// is only accepted in and after protocol 22. It allows authorizing the +// contract constructor arguments. +case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: + CreateContractArgsV2 createContractV2HostFn; }; struct SorobanAuthorizedInvocation @@ -801,6 +823,56 @@ struct LedgerFootprint LedgerKey readWrite<>; }; +enum ArchivalProofType +{ + EXISTENCE = 0, + NONEXISTENCE = 1 +}; + +struct ArchivalProofNode +{ + uint32 index; + Hash hash; +}; + +typedef ArchivalProofNode ProofLevel<>; + +struct NonexistenceProofBody +{ + ColdArchiveBucketEntry entriesToProve<>; + + // Vector of vectors, where proofLevels[level] + // contains all HashNodes that correspond with that level + ProofLevel proofLevels<>; +}; + +struct ExistenceProofBody +{ + LedgerKey keysToProve<>; + + // Bounds for each key being proved, where bound[n] + // corresponds to keysToProve[n] + ColdArchiveBucketEntry lowBoundEntries<>; + ColdArchiveBucketEntry highBoundEntries<>; + + // Vector of vectors, where proofLevels[level] + // contains all HashNodes that correspond with that level + ProofLevel proofLevels<>; +}; + +struct ArchivalProof +{ + uint32 epoch; // AST Subtree for this proof + + union switch (ArchivalProofType t) + { + case EXISTENCE: + NonexistenceProofBody nonexistenceProof; + case NONEXISTENCE: + ExistenceProofBody existenceProof; + } body; +}; + // Resource limits for a Soroban transaction. // The transaction will fail if it exceeds any of these limits. struct SorobanResources diff --git a/xdr/Stellar-types.x b/xdr/Stellar-types.x index d71bf0d49d..73c4e79581 100644 --- a/xdr/Stellar-types.x +++ b/xdr/Stellar-types.x @@ -103,4 +103,35 @@ struct HmacSha256Mac { opaque mac[32]; }; -} + +struct ShortHashSeed +{ + opaque seed[16]; +}; + +enum BinaryFuseFilterType +{ + BINARY_FUSE_FILTER_8_BIT = 0, + BINARY_FUSE_FILTER_16_BIT = 1, + BINARY_FUSE_FILTER_32_BIT = 2 +}; + +struct SerializedBinaryFuseFilter +{ + BinaryFuseFilterType type; + + // Seed used to hash input to filter + ShortHashSeed inputHashSeed; + + // Seed used for internal filter hash operations + ShortHashSeed filterSeed; + uint32 segmentLength; + uint32 segementLengthMask; + uint32 segmentCount; + uint32 segmentCountLength; + uint32 fingerprintLength; // Length in terms of element count, not bytes + + // Array of uint8_t, uint16_t, or uint32_t depending on filter type + opaque fingerprints<>; +}; +} \ No newline at end of file diff --git a/xdr/xdr_commit_generated.txt b/xdr/xdr_commit_generated.txt index 793097adeb..20a2fce7f1 100644 --- a/xdr/xdr_commit_generated.txt +++ b/xdr/xdr_commit_generated.txt @@ -1 +1 @@ -70180d5e8d9caee9e8645ed8a38c36a8cf403cd9 \ No newline at end of file +529d5176f24c73eeccfa5eba481d4e89c19b1181 \ No newline at end of file diff --git a/xdr/xdr_generated.go b/xdr/xdr_generated.go index fb7fb7471e..4b3f35490d 100644 --- a/xdr/xdr_generated.go +++ b/xdr/xdr_generated.go @@ -33,18 +33,18 @@ import ( // XdrFilesSHA256 is the SHA256 hashes of source files. var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-SCP.x": "8f32b04d008f8bc33b8843d075e69837231a673691ee41d8b821ca229a6e802a", - "xdr/Stellar-contract-config-setting.x": "393369678663cb0f9471a0b69e2a9cfa3ac93c4415fa40cec166e9a231ecbe0d", - "xdr/Stellar-contract-env-meta.x": "928a30de814ee589bc1d2aadd8dd81c39f71b7e6f430f56974505ccb1f49654b", + "xdr/Stellar-contract-config-setting.x": "f5487397dda4c27135f0f9e930042a186d1abdc9698163ca6a30efe1a03ee495", + "xdr/Stellar-contract-env-meta.x": "75a271414d852096fea3283c63b7f2a702f2905f78fc28eb60ec7d7bd366a780", "xdr/Stellar-contract-meta.x": "f01532c11ca044e19d9f9f16fe373e9af64835da473be556b9a807ee3319ae0d", "xdr/Stellar-contract-spec.x": "c7ffa21d2e91afb8e666b33524d307955426ff553a486d670c29217ed9888d49", "xdr/Stellar-contract.x": "7f665e4103e146a88fcdabce879aaaacd3bf9283feb194cc47ff986264c1e315", "xdr/Stellar-exporter.x": "a00c83d02e8c8382e06f79a191f1fb5abd097a4bbcab8481c67467e3270e0529", "xdr/Stellar-internal.x": "227835866c1b2122d1eaf28839ba85ea7289d1cb681dda4ca619c2da3d71fe00", - "xdr/Stellar-ledger-entries.x": "77dc7062ae6d0812136333e12e35b2294d7c2896a536be9c811eb0ed2abbbccb", - "xdr/Stellar-ledger.x": "46c1c55972750b97650ff00788a2be4764975b787ef51c8fa931c56e2028a3c4", + "xdr/Stellar-ledger-entries.x": "03e8be938bace784410b0e837ed6496ff66dc0d1e70fc6e4f0d006566a344879", + "xdr/Stellar-ledger.x": "c2ac5bde5da28d4d02e2ea455f3bc5d5133adf271d374010cebe4e314c8504e8", "xdr/Stellar-overlay.x": "8c73b7c3ad974e7fc4aa4fdf34f7ad50053406254efbd7406c96657cf41691d3", - "xdr/Stellar-transaction.x": "0d2b35a331a540b48643925d0869857236eb2487c02d340ea32e365e784ea2b8", - "xdr/Stellar-types.x": "6e3b13f0d3e360b09fa5e2b0e55d43f4d974a769df66afb34e8aecbb329d3f15", + "xdr/Stellar-transaction.x": "fdd854ea6ce450500c331a6613d714d9b2f00d2adc86210a8f709e8a9ef4c641", + "xdr/Stellar-types.x": "253f515fc5e06bc938105e92a4c7f562251d4ebc178d39d6e6751e6b85fe1064", } var ErrMaxDecodingDepthReached = errors.New("maximum decoding depth reached") @@ -11114,45 +11114,71 @@ func (s EnvelopeType) xdrType() {} var _ xdrType = (*EnvelopeType)(nil) -// UpgradeType is an XDR Typedef defines as: +// BucketListType is an XDR Enum defines as: // -// typedef opaque UpgradeType<128>; -type UpgradeType []byte +// enum BucketListType +// { +// LIVE = 0, +// HOT_ARCHIVE = 1, +// COLD_ARCHIVE = 2 +// }; +type BucketListType int32 -// XDRMaxSize implements the Sized interface for UpgradeType -func (e UpgradeType) XDRMaxSize() int { - return 128 +const ( + BucketListTypeLive BucketListType = 0 + BucketListTypeHotArchive BucketListType = 1 + BucketListTypeColdArchive BucketListType = 2 +) + +var bucketListTypeMap = map[int32]string{ + 0: "BucketListTypeLive", + 1: "BucketListTypeHotArchive", + 2: "BucketListTypeColdArchive", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for BucketListType +func (e BucketListType) ValidEnum(v int32) bool { + _, ok := bucketListTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e BucketListType) String() string { + name, _ := bucketListTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s UpgradeType) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeOpaque(s[:]); err != nil { - return err +func (e BucketListType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := bucketListTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid BucketListType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*UpgradeType)(nil) +var _ decoderFrom = (*BucketListType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *UpgradeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *BucketListType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding UpgradeType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding BucketListType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - (*s), nTmp, err = d.DecodeOpaque(128) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding UpgradeType: %w", err) + return n, fmt.Errorf("decoding BucketListType: %w", err) + } + if _, ok := bucketListTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid BucketListType enum value", v) } + *e = BucketListType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s UpgradeType) MarshalBinary() ([]byte, error) { +func (s BucketListType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11160,7 +11186,7 @@ func (s UpgradeType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *UpgradeType) UnmarshalBinary(inp []byte) error { +func (s *BucketListType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11170,77 +11196,85 @@ func (s *UpgradeType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*UpgradeType)(nil) - _ encoding.BinaryUnmarshaler = (*UpgradeType)(nil) + _ encoding.BinaryMarshaler = (*BucketListType)(nil) + _ encoding.BinaryUnmarshaler = (*BucketListType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s UpgradeType) xdrType() {} +func (s BucketListType) xdrType() {} -var _ xdrType = (*UpgradeType)(nil) +var _ xdrType = (*BucketListType)(nil) -// StellarValueType is an XDR Enum defines as: +// BucketEntryType is an XDR Enum defines as: // -// enum StellarValueType +// enum BucketEntryType // { -// STELLAR_VALUE_BASIC = 0, -// STELLAR_VALUE_SIGNED = 1 +// METAENTRY = +// -1, // At-and-after protocol 11: bucket metadata, should come first. +// LIVEENTRY = 0, // Before protocol 11: created-or-updated; +// // At-and-after protocol 11: only updated. +// DEADENTRY = 1, +// INITENTRY = 2 // At-and-after protocol 11: only created. // }; -type StellarValueType int32 +type BucketEntryType int32 const ( - StellarValueTypeStellarValueBasic StellarValueType = 0 - StellarValueTypeStellarValueSigned StellarValueType = 1 + BucketEntryTypeMetaentry BucketEntryType = -1 + BucketEntryTypeLiveentry BucketEntryType = 0 + BucketEntryTypeDeadentry BucketEntryType = 1 + BucketEntryTypeInitentry BucketEntryType = 2 ) -var stellarValueTypeMap = map[int32]string{ - 0: "StellarValueTypeStellarValueBasic", - 1: "StellarValueTypeStellarValueSigned", +var bucketEntryTypeMap = map[int32]string{ + -1: "BucketEntryTypeMetaentry", + 0: "BucketEntryTypeLiveentry", + 1: "BucketEntryTypeDeadentry", + 2: "BucketEntryTypeInitentry", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for StellarValueType -func (e StellarValueType) ValidEnum(v int32) bool { - _, ok := stellarValueTypeMap[v] +// the Enum interface for BucketEntryType +func (e BucketEntryType) ValidEnum(v int32) bool { + _, ok := bucketEntryTypeMap[v] return ok } // String returns the name of `e` -func (e StellarValueType) String() string { - name, _ := stellarValueTypeMap[int32(e)] +func (e BucketEntryType) String() string { + name, _ := bucketEntryTypeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e StellarValueType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := stellarValueTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid StellarValueType enum value", e) +func (e BucketEntryType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := bucketEntryTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid BucketEntryType enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*StellarValueType)(nil) +var _ decoderFrom = (*BucketEntryType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *StellarValueType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *BucketEntryType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding StellarValueType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding BucketEntryType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding StellarValueType: %w", err) + return n, fmt.Errorf("decoding BucketEntryType: %w", err) } - if _, ok := stellarValueTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid StellarValueType enum value", v) + if _, ok := bucketEntryTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid BucketEntryType enum value", v) } - *e = StellarValueType(v) + *e = BucketEntryType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s StellarValueType) MarshalBinary() ([]byte, error) { +func (s BucketEntryType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11248,7 +11282,7 @@ func (s StellarValueType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *StellarValueType) UnmarshalBinary(inp []byte) error { +func (s *BucketEntryType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11258,64 +11292,182 @@ func (s *StellarValueType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*StellarValueType)(nil) - _ encoding.BinaryUnmarshaler = (*StellarValueType)(nil) + _ encoding.BinaryMarshaler = (*BucketEntryType)(nil) + _ encoding.BinaryUnmarshaler = (*BucketEntryType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s StellarValueType) xdrType() {} +func (s BucketEntryType) xdrType() {} -var _ xdrType = (*StellarValueType)(nil) +var _ xdrType = (*BucketEntryType)(nil) -// LedgerCloseValueSignature is an XDR Struct defines as: +// HotArchiveBucketEntryType is an XDR Enum defines as: // -// struct LedgerCloseValueSignature +// enum HotArchiveBucketEntryType // { -// NodeID nodeID; // which node introduced the value -// Signature signature; // nodeID's signature +// HOT_ARCHIVE_METAENTRY = -1, // Bucket metadata, should come first. +// HOT_ARCHIVE_ARCHIVED = 0, // Entry is Archived +// HOT_ARCHIVE_LIVE = 1, // Entry was previously HOT_ARCHIVE_ARCHIVED, or HOT_ARCHIVE_DELETED, but +// // has been added back to the live BucketList. +// // Does not need to be persisted. +// HOT_ARCHIVE_DELETED = 2 // Entry deleted (Note: must be persisted in archive) // }; -type LedgerCloseValueSignature struct { - NodeId NodeId - Signature Signature +type HotArchiveBucketEntryType int32 + +const ( + HotArchiveBucketEntryTypeHotArchiveMetaentry HotArchiveBucketEntryType = -1 + HotArchiveBucketEntryTypeHotArchiveArchived HotArchiveBucketEntryType = 0 + HotArchiveBucketEntryTypeHotArchiveLive HotArchiveBucketEntryType = 1 + HotArchiveBucketEntryTypeHotArchiveDeleted HotArchiveBucketEntryType = 2 +) + +var hotArchiveBucketEntryTypeMap = map[int32]string{ + -1: "HotArchiveBucketEntryTypeHotArchiveMetaentry", + 0: "HotArchiveBucketEntryTypeHotArchiveArchived", + 1: "HotArchiveBucketEntryTypeHotArchiveLive", + 2: "HotArchiveBucketEntryTypeHotArchiveDeleted", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for HotArchiveBucketEntryType +func (e HotArchiveBucketEntryType) ValidEnum(v int32) bool { + _, ok := hotArchiveBucketEntryTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e HotArchiveBucketEntryType) String() string { + name, _ := hotArchiveBucketEntryTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *LedgerCloseValueSignature) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.NodeId.EncodeTo(e); err != nil { - return err - } - if err = s.Signature.EncodeTo(e); err != nil { - return err +func (e HotArchiveBucketEntryType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := hotArchiveBucketEntryTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid HotArchiveBucketEntryType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*LedgerCloseValueSignature)(nil) +var _ decoderFrom = (*HotArchiveBucketEntryType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseValueSignature) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *HotArchiveBucketEntryType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerCloseValueSignature: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding HotArchiveBucketEntryType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.NodeId.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding NodeId: %w", err) + return n, fmt.Errorf("decoding HotArchiveBucketEntryType: %w", err) } - nTmp, err = s.Signature.DecodeFrom(d, maxDepth) - n += nTmp + if _, ok := hotArchiveBucketEntryTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid HotArchiveBucketEntryType enum value", v) + } + *e = HotArchiveBucketEntryType(v) + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s HotArchiveBucketEntryType) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *HotArchiveBucketEntryType) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*HotArchiveBucketEntryType)(nil) + _ encoding.BinaryUnmarshaler = (*HotArchiveBucketEntryType)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s HotArchiveBucketEntryType) xdrType() {} + +var _ xdrType = (*HotArchiveBucketEntryType)(nil) + +// ColdArchiveBucketEntryType is an XDR Enum defines as: +// +// enum ColdArchiveBucketEntryType +// { +// COLD_ARCHIVE_METAENTRY = -1, // Bucket metadata, should come first. +// COLD_ARCHIVE_ARCHIVED_LEAF = 0, // Full LedgerEntry that was archived during the epoch +// COLD_ARCHIVE_DELETED_LEAF = 1, // LedgerKey that was deleted during the epoch +// COLD_ARCHIVE_BOUNDARY_LEAF = 2, // Dummy leaf representing low/high bound +// COLD_ARCHIVE_HASH = 3 // Intermediary Merkle hash entry +// }; +type ColdArchiveBucketEntryType int32 + +const ( + ColdArchiveBucketEntryTypeColdArchiveMetaentry ColdArchiveBucketEntryType = -1 + ColdArchiveBucketEntryTypeColdArchiveArchivedLeaf ColdArchiveBucketEntryType = 0 + ColdArchiveBucketEntryTypeColdArchiveDeletedLeaf ColdArchiveBucketEntryType = 1 + ColdArchiveBucketEntryTypeColdArchiveBoundaryLeaf ColdArchiveBucketEntryType = 2 + ColdArchiveBucketEntryTypeColdArchiveHash ColdArchiveBucketEntryType = 3 +) + +var coldArchiveBucketEntryTypeMap = map[int32]string{ + -1: "ColdArchiveBucketEntryTypeColdArchiveMetaentry", + 0: "ColdArchiveBucketEntryTypeColdArchiveArchivedLeaf", + 1: "ColdArchiveBucketEntryTypeColdArchiveDeletedLeaf", + 2: "ColdArchiveBucketEntryTypeColdArchiveBoundaryLeaf", + 3: "ColdArchiveBucketEntryTypeColdArchiveHash", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for ColdArchiveBucketEntryType +func (e ColdArchiveBucketEntryType) ValidEnum(v int32) bool { + _, ok := coldArchiveBucketEntryTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e ColdArchiveBucketEntryType) String() string { + name, _ := coldArchiveBucketEntryTypeMap[int32(e)] + return name +} + +// EncodeTo encodes this value using the Encoder. +func (e ColdArchiveBucketEntryType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := coldArchiveBucketEntryTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ColdArchiveBucketEntryType enum value", e) + } + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*ColdArchiveBucketEntryType)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (e *ColdArchiveBucketEntryType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ColdArchiveBucketEntryType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + return n, fmt.Errorf("decoding ColdArchiveBucketEntryType: %w", err) } + if _, ok := coldArchiveBucketEntryTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ColdArchiveBucketEntryType enum value", v) + } + *e = ColdArchiveBucketEntryType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseValueSignature) MarshalBinary() ([]byte, error) { +func (s ColdArchiveBucketEntryType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11323,7 +11475,7 @@ func (s LedgerCloseValueSignature) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseValueSignature) UnmarshalBinary(inp []byte) error { +func (s *ColdArchiveBucketEntryType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11333,83 +11485,83 @@ func (s *LedgerCloseValueSignature) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerCloseValueSignature)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseValueSignature)(nil) + _ encoding.BinaryMarshaler = (*ColdArchiveBucketEntryType)(nil) + _ encoding.BinaryUnmarshaler = (*ColdArchiveBucketEntryType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerCloseValueSignature) xdrType() {} +func (s ColdArchiveBucketEntryType) xdrType() {} -var _ xdrType = (*LedgerCloseValueSignature)(nil) +var _ xdrType = (*ColdArchiveBucketEntryType)(nil) -// StellarValueExt is an XDR NestedUnion defines as: +// BucketMetadataExt is an XDR NestedUnion defines as: // -// union switch (StellarValueType v) +// union switch (int v) // { -// case STELLAR_VALUE_BASIC: +// case 0: // void; -// case STELLAR_VALUE_SIGNED: -// LedgerCloseValueSignature lcValueSignature; +// case 1: +// BucketListType bucketListType; // } -type StellarValueExt struct { - V StellarValueType - LcValueSignature *LedgerCloseValueSignature +type BucketMetadataExt struct { + V int32 + BucketListType *BucketListType } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u StellarValueExt) SwitchFieldName() string { +func (u BucketMetadataExt) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of StellarValueExt -func (u StellarValueExt) ArmForSwitch(sw int32) (string, bool) { - switch StellarValueType(sw) { - case StellarValueTypeStellarValueBasic: +// the value for an instance of BucketMetadataExt +func (u BucketMetadataExt) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: return "", true - case StellarValueTypeStellarValueSigned: - return "LcValueSignature", true + case 1: + return "BucketListType", true } return "-", false } -// NewStellarValueExt creates a new StellarValueExt. -func NewStellarValueExt(v StellarValueType, value interface{}) (result StellarValueExt, err error) { +// NewBucketMetadataExt creates a new BucketMetadataExt. +func NewBucketMetadataExt(v int32, value interface{}) (result BucketMetadataExt, err error) { result.V = v - switch StellarValueType(v) { - case StellarValueTypeStellarValueBasic: + switch int32(v) { + case 0: // void - case StellarValueTypeStellarValueSigned: - tv, ok := value.(LedgerCloseValueSignature) + case 1: + tv, ok := value.(BucketListType) if !ok { - err = errors.New("invalid value, must be LedgerCloseValueSignature") + err = errors.New("invalid value, must be BucketListType") return } - result.LcValueSignature = &tv + result.BucketListType = &tv } return } -// MustLcValueSignature retrieves the LcValueSignature value from the union, +// MustBucketListType retrieves the BucketListType value from the union, // panicing if the value is not set. -func (u StellarValueExt) MustLcValueSignature() LedgerCloseValueSignature { - val, ok := u.GetLcValueSignature() +func (u BucketMetadataExt) MustBucketListType() BucketListType { + val, ok := u.GetBucketListType() if !ok { - panic("arm LcValueSignature is not set") + panic("arm BucketListType is not set") } return val } -// GetLcValueSignature retrieves the LcValueSignature value from the union, +// GetBucketListType retrieves the BucketListType value from the union, // returning ok if the union's switch indicated the value is valid. -func (u StellarValueExt) GetLcValueSignature() (result LedgerCloseValueSignature, ok bool) { +func (u BucketMetadataExt) GetBucketListType() (result BucketListType, ok bool) { armName, _ := u.ArmForSwitch(int32(u.V)) - if armName == "LcValueSignature" { - result = *u.LcValueSignature + if armName == "BucketListType" { + result = *u.BucketListType ok = true } @@ -11417,57 +11569,57 @@ func (u StellarValueExt) GetLcValueSignature() (result LedgerCloseValueSignature } // EncodeTo encodes this value using the Encoder. -func (u StellarValueExt) EncodeTo(e *xdr.Encoder) error { +func (u BucketMetadataExt) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.V.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } - switch StellarValueType(u.V) { - case StellarValueTypeStellarValueBasic: + switch int32(u.V) { + case 0: // Void return nil - case StellarValueTypeStellarValueSigned: - if err = (*u.LcValueSignature).EncodeTo(e); err != nil { + case 1: + if err = (*u.BucketListType).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("V (StellarValueType) switch value '%d' is not valid for union StellarValueExt", u.V) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union BucketMetadataExt", u.V) } -var _ decoderFrom = (*StellarValueExt)(nil) +var _ decoderFrom = (*BucketMetadataExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *StellarValueExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *BucketMetadataExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding StellarValueExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding BucketMetadataExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.V.DecodeFrom(d, maxDepth) + u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding StellarValueType: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - switch StellarValueType(u.V) { - case StellarValueTypeStellarValueBasic: + switch int32(u.V) { + case 0: // Void return n, nil - case StellarValueTypeStellarValueSigned: - u.LcValueSignature = new(LedgerCloseValueSignature) - nTmp, err = (*u.LcValueSignature).DecodeFrom(d, maxDepth) + case 1: + u.BucketListType = new(BucketListType) + nTmp, err = (*u.BucketListType).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseValueSignature: %w", err) + return n, fmt.Errorf("decoding BucketListType: %w", err) } return n, nil } - return n, fmt.Errorf("union StellarValueExt has invalid V (StellarValueType) switch value '%d'", u.V) + return n, fmt.Errorf("union BucketMetadataExt has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s StellarValueExt) MarshalBinary() ([]byte, error) { +func (s BucketMetadataExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11475,7 +11627,7 @@ func (s StellarValueExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *StellarValueExt) UnmarshalBinary(inp []byte) error { +func (s *BucketMetadataExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11485,122 +11637,74 @@ func (s *StellarValueExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*StellarValueExt)(nil) - _ encoding.BinaryUnmarshaler = (*StellarValueExt)(nil) + _ encoding.BinaryMarshaler = (*BucketMetadataExt)(nil) + _ encoding.BinaryUnmarshaler = (*BucketMetadataExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s StellarValueExt) xdrType() {} +func (s BucketMetadataExt) xdrType() {} -var _ xdrType = (*StellarValueExt)(nil) +var _ xdrType = (*BucketMetadataExt)(nil) -// StellarValue is an XDR Struct defines as: +// BucketMetadata is an XDR Struct defines as: // -// struct StellarValue +// struct BucketMetadata // { -// Hash txSetHash; // transaction set to apply to previous ledger -// TimePoint closeTime; // network close time -// -// // upgrades to apply to the previous ledger (usually empty) -// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop -// // unknown steps during consensus if needed. -// // see notes below on 'LedgerUpgrade' for more detail -// // max size is dictated by number of upgrade types (+ room for future) -// UpgradeType upgrades<6>; +// // Indicates the protocol version used to create / merge this bucket. +// uint32 ledgerVersion; // // // reserved for future use -// union switch (StellarValueType v) +// union switch (int v) // { -// case STELLAR_VALUE_BASIC: +// case 0: // void; -// case STELLAR_VALUE_SIGNED: -// LedgerCloseValueSignature lcValueSignature; +// case 1: +// BucketListType bucketListType; // } // ext; // }; -type StellarValue struct { - TxSetHash Hash - CloseTime TimePoint - Upgrades []UpgradeType `xdrmaxsize:"6"` - Ext StellarValueExt +type BucketMetadata struct { + LedgerVersion Uint32 + Ext BucketMetadataExt } // EncodeTo encodes this value using the Encoder. -func (s *StellarValue) EncodeTo(e *xdr.Encoder) error { +func (s *BucketMetadata) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.TxSetHash.EncodeTo(e); err != nil { - return err - } - if err = s.CloseTime.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.Upgrades))); err != nil { + if err = s.LedgerVersion.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Upgrades); i++ { - if err = s.Upgrades[i].EncodeTo(e); err != nil { - return err - } - } if err = s.Ext.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*StellarValue)(nil) +var _ decoderFrom = (*BucketMetadata)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *StellarValue) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *BucketMetadata) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding StellarValue: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding BucketMetadata: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxSetHash.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - nTmp, err = s.CloseTime.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TimePoint: %w", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeType: %w", err) - } - if l > 6 { - return n, fmt.Errorf("decoding UpgradeType: data size (%d) exceeds size limit (6)", l) - } - s.Upgrades = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding UpgradeType: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Upgrades = make([]UpgradeType, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Upgrades[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding UpgradeType: %w", err) - } - } + return n, fmt.Errorf("decoding Uint32: %w", err) } nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding StellarValueExt: %w", err) + return n, fmt.Errorf("decoding BucketMetadataExt: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s StellarValue) MarshalBinary() ([]byte, error) { +func (s BucketMetadata) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11608,7 +11712,7 @@ func (s StellarValue) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *StellarValue) UnmarshalBinary(inp []byte) error { +func (s *BucketMetadata) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11618,85 +11722,253 @@ func (s *StellarValue) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*StellarValue)(nil) - _ encoding.BinaryUnmarshaler = (*StellarValue)(nil) + _ encoding.BinaryMarshaler = (*BucketMetadata)(nil) + _ encoding.BinaryUnmarshaler = (*BucketMetadata)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s StellarValue) xdrType() {} - -var _ xdrType = (*StellarValue)(nil) +func (s BucketMetadata) xdrType() {} -// MaskLedgerHeaderFlags is an XDR Const defines as: -// -// const MASK_LEDGER_HEADER_FLAGS = 0x7; -const MaskLedgerHeaderFlags = 0x7 +var _ xdrType = (*BucketMetadata)(nil) -// LedgerHeaderFlags is an XDR Enum defines as: +// BucketEntry is an XDR Union defines as: // -// enum LedgerHeaderFlags +// union BucketEntry switch (BucketEntryType type) // { -// DISABLE_LIQUIDITY_POOL_TRADING_FLAG = 0x1, -// DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG = 0x2, -// DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 0x4 +// case LIVEENTRY: +// case INITENTRY: +// LedgerEntry liveEntry; +// +// case DEADENTRY: +// LedgerKey deadEntry; +// case METAENTRY: +// BucketMetadata metaEntry; // }; -type LedgerHeaderFlags int32 - -const ( - LedgerHeaderFlagsDisableLiquidityPoolTradingFlag LedgerHeaderFlags = 1 - LedgerHeaderFlagsDisableLiquidityPoolDepositFlag LedgerHeaderFlags = 2 - LedgerHeaderFlagsDisableLiquidityPoolWithdrawalFlag LedgerHeaderFlags = 4 -) - -var ledgerHeaderFlagsMap = map[int32]string{ - 1: "LedgerHeaderFlagsDisableLiquidityPoolTradingFlag", - 2: "LedgerHeaderFlagsDisableLiquidityPoolDepositFlag", - 4: "LedgerHeaderFlagsDisableLiquidityPoolWithdrawalFlag", +type BucketEntry struct { + Type BucketEntryType + LiveEntry *LedgerEntry + DeadEntry *LedgerKey + MetaEntry *BucketMetadata } -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for LedgerHeaderFlags -func (e LedgerHeaderFlags) ValidEnum(v int32) bool { - _, ok := ledgerHeaderFlagsMap[v] - return ok +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u BucketEntry) SwitchFieldName() string { + return "Type" } -// String returns the name of `e` -func (e LedgerHeaderFlags) String() string { - name, _ := ledgerHeaderFlagsMap[int32(e)] - return name +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of BucketEntry +func (u BucketEntry) ArmForSwitch(sw int32) (string, bool) { + switch BucketEntryType(sw) { + case BucketEntryTypeLiveentry: + return "LiveEntry", true + case BucketEntryTypeInitentry: + return "LiveEntry", true + case BucketEntryTypeDeadentry: + return "DeadEntry", true + case BucketEntryTypeMetaentry: + return "MetaEntry", true + } + return "-", false } -// EncodeTo encodes this value using the Encoder. -func (e LedgerHeaderFlags) EncodeTo(enc *xdr.Encoder) error { - if _, ok := ledgerHeaderFlagsMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid LedgerHeaderFlags enum value", e) +// NewBucketEntry creates a new BucketEntry. +func NewBucketEntry(aType BucketEntryType, value interface{}) (result BucketEntry, err error) { + result.Type = aType + switch BucketEntryType(aType) { + case BucketEntryTypeLiveentry: + tv, ok := value.(LedgerEntry) + if !ok { + err = errors.New("invalid value, must be LedgerEntry") + return + } + result.LiveEntry = &tv + case BucketEntryTypeInitentry: + tv, ok := value.(LedgerEntry) + if !ok { + err = errors.New("invalid value, must be LedgerEntry") + return + } + result.LiveEntry = &tv + case BucketEntryTypeDeadentry: + tv, ok := value.(LedgerKey) + if !ok { + err = errors.New("invalid value, must be LedgerKey") + return + } + result.DeadEntry = &tv + case BucketEntryTypeMetaentry: + tv, ok := value.(BucketMetadata) + if !ok { + err = errors.New("invalid value, must be BucketMetadata") + return + } + result.MetaEntry = &tv } - _, err := enc.EncodeInt(int32(e)) - return err + return } -var _ decoderFrom = (*LedgerHeaderFlags)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *LedgerHeaderFlags) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +// MustLiveEntry retrieves the LiveEntry value from the union, +// panicing if the value is not set. +func (u BucketEntry) MustLiveEntry() LedgerEntry { + val, ok := u.GetLiveEntry() + + if !ok { + panic("arm LiveEntry is not set") + } + + return val +} + +// GetLiveEntry retrieves the LiveEntry value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u BucketEntry) GetLiveEntry() (result LedgerEntry, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "LiveEntry" { + result = *u.LiveEntry + ok = true + } + + return +} + +// MustDeadEntry retrieves the DeadEntry value from the union, +// panicing if the value is not set. +func (u BucketEntry) MustDeadEntry() LedgerKey { + val, ok := u.GetDeadEntry() + + if !ok { + panic("arm DeadEntry is not set") + } + + return val +} + +// GetDeadEntry retrieves the DeadEntry value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u BucketEntry) GetDeadEntry() (result LedgerKey, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "DeadEntry" { + result = *u.DeadEntry + ok = true + } + + return +} + +// MustMetaEntry retrieves the MetaEntry value from the union, +// panicing if the value is not set. +func (u BucketEntry) MustMetaEntry() BucketMetadata { + val, ok := u.GetMetaEntry() + + if !ok { + panic("arm MetaEntry is not set") + } + + return val +} + +// GetMetaEntry retrieves the MetaEntry value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u BucketEntry) GetMetaEntry() (result BucketMetadata, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "MetaEntry" { + result = *u.MetaEntry + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u BucketEntry) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err + } + switch BucketEntryType(u.Type) { + case BucketEntryTypeLiveentry: + if err = (*u.LiveEntry).EncodeTo(e); err != nil { + return err + } + return nil + case BucketEntryTypeInitentry: + if err = (*u.LiveEntry).EncodeTo(e); err != nil { + return err + } + return nil + case BucketEntryTypeDeadentry: + if err = (*u.DeadEntry).EncodeTo(e); err != nil { + return err + } + return nil + case BucketEntryTypeMetaentry: + if err = (*u.MetaEntry).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (BucketEntryType) switch value '%d' is not valid for union BucketEntry", u.Type) +} + +var _ decoderFrom = (*BucketEntry)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *BucketEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerHeaderFlags: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding BucketEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderFlags: %w", err) + return n, fmt.Errorf("decoding BucketEntryType: %w", err) } - if _, ok := ledgerHeaderFlagsMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid LedgerHeaderFlags enum value", v) + switch BucketEntryType(u.Type) { + case BucketEntryTypeLiveentry: + u.LiveEntry = new(LedgerEntry) + nTmp, err = (*u.LiveEntry).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + return n, nil + case BucketEntryTypeInitentry: + u.LiveEntry = new(LedgerEntry) + nTmp, err = (*u.LiveEntry).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + return n, nil + case BucketEntryTypeDeadentry: + u.DeadEntry = new(LedgerKey) + nTmp, err = (*u.DeadEntry).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + return n, nil + case BucketEntryTypeMetaentry: + u.MetaEntry = new(BucketMetadata) + nTmp, err = (*u.MetaEntry).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding BucketMetadata: %w", err) + } + return n, nil } - *e = LedgerHeaderFlags(v) - return n, nil + return n, fmt.Errorf("union BucketEntry has invalid Type (BucketEntryType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerHeaderFlags) MarshalBinary() ([]byte, error) { +func (s BucketEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11704,7 +11976,7 @@ func (s LedgerHeaderFlags) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerHeaderFlags) UnmarshalBinary(inp []byte) error { +func (s *BucketEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11714,91 +11986,253 @@ func (s *LedgerHeaderFlags) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerHeaderFlags)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerHeaderFlags)(nil) + _ encoding.BinaryMarshaler = (*BucketEntry)(nil) + _ encoding.BinaryUnmarshaler = (*BucketEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerHeaderFlags) xdrType() {} +func (s BucketEntry) xdrType() {} -var _ xdrType = (*LedgerHeaderFlags)(nil) +var _ xdrType = (*BucketEntry)(nil) -// LedgerHeaderExtensionV1Ext is an XDR NestedUnion defines as: +// HotArchiveBucketEntry is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } -type LedgerHeaderExtensionV1Ext struct { - V int32 +// union HotArchiveBucketEntry switch (HotArchiveBucketEntryType type) +// { +// case HOT_ARCHIVE_ARCHIVED: +// LedgerEntry archivedEntry; +// +// case HOT_ARCHIVE_LIVE: +// case HOT_ARCHIVE_DELETED: +// LedgerKey key; +// case HOT_ARCHIVE_METAENTRY: +// BucketMetadata metaEntry; +// }; +type HotArchiveBucketEntry struct { + Type HotArchiveBucketEntryType + ArchivedEntry *LedgerEntry + Key *LedgerKey + MetaEntry *BucketMetadata } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u LedgerHeaderExtensionV1Ext) SwitchFieldName() string { - return "V" +func (u HotArchiveBucketEntry) SwitchFieldName() string { + return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of LedgerHeaderExtensionV1Ext -func (u LedgerHeaderExtensionV1Ext) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: - return "", true +// the value for an instance of HotArchiveBucketEntry +func (u HotArchiveBucketEntry) ArmForSwitch(sw int32) (string, bool) { + switch HotArchiveBucketEntryType(sw) { + case HotArchiveBucketEntryTypeHotArchiveArchived: + return "ArchivedEntry", true + case HotArchiveBucketEntryTypeHotArchiveLive: + return "Key", true + case HotArchiveBucketEntryTypeHotArchiveDeleted: + return "Key", true + case HotArchiveBucketEntryTypeHotArchiveMetaentry: + return "MetaEntry", true } return "-", false } -// NewLedgerHeaderExtensionV1Ext creates a new LedgerHeaderExtensionV1Ext. -func NewLedgerHeaderExtensionV1Ext(v int32, value interface{}) (result LedgerHeaderExtensionV1Ext, err error) { - result.V = v - switch int32(v) { - case 0: - // void +// NewHotArchiveBucketEntry creates a new HotArchiveBucketEntry. +func NewHotArchiveBucketEntry(aType HotArchiveBucketEntryType, value interface{}) (result HotArchiveBucketEntry, err error) { + result.Type = aType + switch HotArchiveBucketEntryType(aType) { + case HotArchiveBucketEntryTypeHotArchiveArchived: + tv, ok := value.(LedgerEntry) + if !ok { + err = errors.New("invalid value, must be LedgerEntry") + return + } + result.ArchivedEntry = &tv + case HotArchiveBucketEntryTypeHotArchiveLive: + tv, ok := value.(LedgerKey) + if !ok { + err = errors.New("invalid value, must be LedgerKey") + return + } + result.Key = &tv + case HotArchiveBucketEntryTypeHotArchiveDeleted: + tv, ok := value.(LedgerKey) + if !ok { + err = errors.New("invalid value, must be LedgerKey") + return + } + result.Key = &tv + case HotArchiveBucketEntryTypeHotArchiveMetaentry: + tv, ok := value.(BucketMetadata) + if !ok { + err = errors.New("invalid value, must be BucketMetadata") + return + } + result.MetaEntry = &tv + } + return +} + +// MustArchivedEntry retrieves the ArchivedEntry value from the union, +// panicing if the value is not set. +func (u HotArchiveBucketEntry) MustArchivedEntry() LedgerEntry { + val, ok := u.GetArchivedEntry() + + if !ok { + panic("arm ArchivedEntry is not set") + } + + return val +} + +// GetArchivedEntry retrieves the ArchivedEntry value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u HotArchiveBucketEntry) GetArchivedEntry() (result LedgerEntry, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "ArchivedEntry" { + result = *u.ArchivedEntry + ok = true + } + + return +} + +// MustKey retrieves the Key value from the union, +// panicing if the value is not set. +func (u HotArchiveBucketEntry) MustKey() LedgerKey { + val, ok := u.GetKey() + + if !ok { + panic("arm Key is not set") + } + + return val +} + +// GetKey retrieves the Key value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u HotArchiveBucketEntry) GetKey() (result LedgerKey, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Key" { + result = *u.Key + ok = true + } + + return +} + +// MustMetaEntry retrieves the MetaEntry value from the union, +// panicing if the value is not set. +func (u HotArchiveBucketEntry) MustMetaEntry() BucketMetadata { + val, ok := u.GetMetaEntry() + + if !ok { + panic("arm MetaEntry is not set") + } + + return val +} + +// GetMetaEntry retrieves the MetaEntry value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u HotArchiveBucketEntry) GetMetaEntry() (result BucketMetadata, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "MetaEntry" { + result = *u.MetaEntry + ok = true } + return } // EncodeTo encodes this value using the Encoder. -func (u LedgerHeaderExtensionV1Ext) EncodeTo(e *xdr.Encoder) error { +func (u HotArchiveBucketEntry) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { + if err = u.Type.EncodeTo(e); err != nil { return err } - switch int32(u.V) { - case 0: - // Void + switch HotArchiveBucketEntryType(u.Type) { + case HotArchiveBucketEntryTypeHotArchiveArchived: + if err = (*u.ArchivedEntry).EncodeTo(e); err != nil { + return err + } + return nil + case HotArchiveBucketEntryTypeHotArchiveLive: + if err = (*u.Key).EncodeTo(e); err != nil { + return err + } + return nil + case HotArchiveBucketEntryTypeHotArchiveDeleted: + if err = (*u.Key).EncodeTo(e); err != nil { + return err + } + return nil + case HotArchiveBucketEntryTypeHotArchiveMetaentry: + if err = (*u.MetaEntry).EncodeTo(e); err != nil { + return err + } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerHeaderExtensionV1Ext", u.V) + return fmt.Errorf("Type (HotArchiveBucketEntryType) switch value '%d' is not valid for union HotArchiveBucketEntry", u.Type) } -var _ decoderFrom = (*LedgerHeaderExtensionV1Ext)(nil) +var _ decoderFrom = (*HotArchiveBucketEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerHeaderExtensionV1Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *HotArchiveBucketEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerHeaderExtensionV1Ext: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding HotArchiveBucketEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding HotArchiveBucketEntryType: %w", err) } - switch int32(u.V) { - case 0: - // Void + switch HotArchiveBucketEntryType(u.Type) { + case HotArchiveBucketEntryTypeHotArchiveArchived: + u.ArchivedEntry = new(LedgerEntry) + nTmp, err = (*u.ArchivedEntry).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + return n, nil + case HotArchiveBucketEntryTypeHotArchiveLive: + u.Key = new(LedgerKey) + nTmp, err = (*u.Key).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + return n, nil + case HotArchiveBucketEntryTypeHotArchiveDeleted: + u.Key = new(LedgerKey) + nTmp, err = (*u.Key).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + return n, nil + case HotArchiveBucketEntryTypeHotArchiveMetaentry: + u.MetaEntry = new(BucketMetadata) + nTmp, err = (*u.MetaEntry).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding BucketMetadata: %w", err) + } return n, nil } - return n, fmt.Errorf("union LedgerHeaderExtensionV1Ext has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union HotArchiveBucketEntry has invalid Type (HotArchiveBucketEntryType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerHeaderExtensionV1Ext) MarshalBinary() ([]byte, error) { +func (s HotArchiveBucketEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11806,7 +12240,7 @@ func (s LedgerHeaderExtensionV1Ext) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerHeaderExtensionV1Ext) UnmarshalBinary(inp []byte) error { +func (s *HotArchiveBucketEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11816,70 +12250,64 @@ func (s *LedgerHeaderExtensionV1Ext) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerHeaderExtensionV1Ext)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerHeaderExtensionV1Ext)(nil) + _ encoding.BinaryMarshaler = (*HotArchiveBucketEntry)(nil) + _ encoding.BinaryUnmarshaler = (*HotArchiveBucketEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerHeaderExtensionV1Ext) xdrType() {} +func (s HotArchiveBucketEntry) xdrType() {} -var _ xdrType = (*LedgerHeaderExtensionV1Ext)(nil) +var _ xdrType = (*HotArchiveBucketEntry)(nil) -// LedgerHeaderExtensionV1 is an XDR Struct defines as: +// ColdArchiveArchivedLeaf is an XDR Struct defines as: // -// struct LedgerHeaderExtensionV1 +// struct ColdArchiveArchivedLeaf // { -// uint32 flags; // LedgerHeaderFlags -// -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// uint32 index; +// LedgerEntry archivedEntry; // }; -type LedgerHeaderExtensionV1 struct { - Flags Uint32 - Ext LedgerHeaderExtensionV1Ext +type ColdArchiveArchivedLeaf struct { + Index Uint32 + ArchivedEntry LedgerEntry } // EncodeTo encodes this value using the Encoder. -func (s *LedgerHeaderExtensionV1) EncodeTo(e *xdr.Encoder) error { +func (s *ColdArchiveArchivedLeaf) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Flags.EncodeTo(e); err != nil { + if err = s.Index.EncodeTo(e); err != nil { return err } - if err = s.Ext.EncodeTo(e); err != nil { + if err = s.ArchivedEntry.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*LedgerHeaderExtensionV1)(nil) +var _ decoderFrom = (*ColdArchiveArchivedLeaf)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerHeaderExtensionV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ColdArchiveArchivedLeaf) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerHeaderExtensionV1: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ColdArchiveArchivedLeaf: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Flags.DecodeFrom(d, maxDepth) + nTmp, err = s.Index.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + nTmp, err = s.ArchivedEntry.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderExtensionV1Ext: %w", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerHeaderExtensionV1) MarshalBinary() ([]byte, error) { +func (s ColdArchiveArchivedLeaf) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -11887,7 +12315,7 @@ func (s LedgerHeaderExtensionV1) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerHeaderExtensionV1) UnmarshalBinary(inp []byte) error { +func (s *ColdArchiveArchivedLeaf) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -11897,141 +12325,139 @@ func (s *LedgerHeaderExtensionV1) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerHeaderExtensionV1)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerHeaderExtensionV1)(nil) + _ encoding.BinaryMarshaler = (*ColdArchiveArchivedLeaf)(nil) + _ encoding.BinaryUnmarshaler = (*ColdArchiveArchivedLeaf)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerHeaderExtensionV1) xdrType() {} +func (s ColdArchiveArchivedLeaf) xdrType() {} -var _ xdrType = (*LedgerHeaderExtensionV1)(nil) +var _ xdrType = (*ColdArchiveArchivedLeaf)(nil) -// LedgerHeaderExt is an XDR NestedUnion defines as: +// ColdArchiveDeletedLeaf is an XDR Struct defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// LedgerHeaderExtensionV1 v1; -// } -type LedgerHeaderExt struct { - V int32 - V1 *LedgerHeaderExtensionV1 -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u LedgerHeaderExt) SwitchFieldName() string { - return "V" +// struct ColdArchiveDeletedLeaf +// { +// uint32 index; +// LedgerKey deletedKey; +// }; +type ColdArchiveDeletedLeaf struct { + Index Uint32 + DeletedKey LedgerKey } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of LedgerHeaderExt -func (u LedgerHeaderExt) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: - return "", true - case 1: - return "V1", true +// EncodeTo encodes this value using the Encoder. +func (s *ColdArchiveDeletedLeaf) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Index.EncodeTo(e); err != nil { + return err } - return "-", false -} - -// NewLedgerHeaderExt creates a new LedgerHeaderExt. -func NewLedgerHeaderExt(v int32, value interface{}) (result LedgerHeaderExt, err error) { - result.V = v - switch int32(v) { - case 0: - // void - case 1: - tv, ok := value.(LedgerHeaderExtensionV1) - if !ok { - err = errors.New("invalid value, must be LedgerHeaderExtensionV1") - return - } - result.V1 = &tv + if err = s.DeletedKey.EncodeTo(e); err != nil { + return err } - return + return nil } -// MustV1 retrieves the V1 value from the union, -// panicing if the value is not set. -func (u LedgerHeaderExt) MustV1() LedgerHeaderExtensionV1 { - val, ok := u.GetV1() +var _ decoderFrom = (*ColdArchiveDeletedLeaf)(nil) - if !ok { - panic("arm V1 is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *ColdArchiveDeletedLeaf) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ColdArchiveDeletedLeaf: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Index.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } + nTmp, err = s.DeletedKey.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + return n, nil +} - return val +// MarshalBinary implements encoding.BinaryMarshaler. +func (s ColdArchiveDeletedLeaf) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err } -// GetV1 retrieves the V1 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerHeaderExt) GetV1() (result LedgerHeaderExtensionV1, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *ColdArchiveDeletedLeaf) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} - if armName == "V1" { - result = *u.V1 - ok = true - } +var ( + _ encoding.BinaryMarshaler = (*ColdArchiveDeletedLeaf)(nil) + _ encoding.BinaryUnmarshaler = (*ColdArchiveDeletedLeaf)(nil) +) - return +// xdrType signals that this type represents XDR values defined by this package. +func (s ColdArchiveDeletedLeaf) xdrType() {} + +var _ xdrType = (*ColdArchiveDeletedLeaf)(nil) + +// ColdArchiveBoundaryLeaf is an XDR Struct defines as: +// +// struct ColdArchiveBoundaryLeaf +// { +// uint32 index; +// bool isLowerBound; +// }; +type ColdArchiveBoundaryLeaf struct { + Index Uint32 + IsLowerBound bool } // EncodeTo encodes this value using the Encoder. -func (u LedgerHeaderExt) EncodeTo(e *xdr.Encoder) error { +func (s *ColdArchiveBoundaryLeaf) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { + if err = s.Index.EncodeTo(e); err != nil { return err } - switch int32(u.V) { - case 0: - // Void - return nil - case 1: - if err = (*u.V1).EncodeTo(e); err != nil { - return err - } - return nil + if _, err = e.EncodeBool(bool(s.IsLowerBound)); err != nil { + return err } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerHeaderExt", u.V) + return nil } -var _ decoderFrom = (*LedgerHeaderExt)(nil) +var _ decoderFrom = (*ColdArchiveBoundaryLeaf)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerHeaderExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ColdArchiveBoundaryLeaf) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerHeaderExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ColdArchiveBoundaryLeaf: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = s.Index.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - switch int32(u.V) { - case 0: - // Void - return n, nil - case 1: - u.V1 = new(LedgerHeaderExtensionV1) - nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderExtensionV1: %w", err) - } - return n, nil + s.IsLowerBound, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Bool: %w", err) } - return n, fmt.Errorf("union LedgerHeaderExt has invalid V (int32) switch value '%d'", u.V) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerHeaderExt) MarshalBinary() ([]byte, error) { +func (s ColdArchiveBoundaryLeaf) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -12039,7 +12465,7 @@ func (s LedgerHeaderExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerHeaderExt) UnmarshalBinary(inp []byte) error { +func (s *ColdArchiveBoundaryLeaf) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -12049,387 +12475,65 @@ func (s *LedgerHeaderExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerHeaderExt)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerHeaderExt)(nil) + _ encoding.BinaryMarshaler = (*ColdArchiveBoundaryLeaf)(nil) + _ encoding.BinaryUnmarshaler = (*ColdArchiveBoundaryLeaf)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerHeaderExt) xdrType() {} +func (s ColdArchiveBoundaryLeaf) xdrType() {} -var _ xdrType = (*LedgerHeaderExt)(nil) +var _ xdrType = (*ColdArchiveBoundaryLeaf)(nil) -// LedgerHeader is an XDR Struct defines as: +// ColdArchiveHashEntry is an XDR Struct defines as: // -// struct LedgerHeader +// struct ColdArchiveHashEntry // { -// uint32 ledgerVersion; // the protocol version of the ledger -// Hash previousLedgerHash; // hash of the previous ledger header -// StellarValue scpValue; // what consensus agreed to -// Hash txSetResultHash; // the TransactionResultSet that led to this ledger -// Hash bucketListHash; // hash of the ledger state -// -// uint32 ledgerSeq; // sequence number of this ledger -// -// int64 totalCoins; // total number of stroops in existence. -// // 10,000,000 stroops in 1 XLM -// -// int64 feePool; // fees burned since last inflation run -// uint32 inflationSeq; // inflation sequence number -// -// uint64 idPool; // last used global ID, used for generating objects -// -// uint32 baseFee; // base fee per operation in stroops -// uint32 baseReserve; // account base reserve in stroops -// -// uint32 maxTxSetSize; // maximum size a transaction set can be -// -// Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back -// // in time without walking the chain back ledger by ledger -// // each slot contains the oldest ledger that is mod of -// // either 50 5000 50000 or 500000 depending on index -// // skipList[0] mod(50), skipList[1] mod(5000), etc -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// LedgerHeaderExtensionV1 v1; -// } -// ext; +// uint32 index; +// uint32 level; +// Hash hash; // }; -type LedgerHeader struct { - LedgerVersion Uint32 - PreviousLedgerHash Hash - ScpValue StellarValue - TxSetResultHash Hash - BucketListHash Hash - LedgerSeq Uint32 - TotalCoins Int64 - FeePool Int64 - InflationSeq Uint32 - IdPool Uint64 - BaseFee Uint32 - BaseReserve Uint32 - MaxTxSetSize Uint32 - SkipList [4]Hash - Ext LedgerHeaderExt +type ColdArchiveHashEntry struct { + Index Uint32 + Level Uint32 + Hash Hash } // EncodeTo encodes this value using the Encoder. -func (s *LedgerHeader) EncodeTo(e *xdr.Encoder) error { +func (s *ColdArchiveHashEntry) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.LedgerVersion.EncodeTo(e); err != nil { - return err - } - if err = s.PreviousLedgerHash.EncodeTo(e); err != nil { - return err - } - if err = s.ScpValue.EncodeTo(e); err != nil { - return err - } - if err = s.TxSetResultHash.EncodeTo(e); err != nil { - return err - } - if err = s.BucketListHash.EncodeTo(e); err != nil { - return err - } - if err = s.LedgerSeq.EncodeTo(e); err != nil { + if err = s.Index.EncodeTo(e); err != nil { return err } - if err = s.TotalCoins.EncodeTo(e); err != nil { - return err - } - if err = s.FeePool.EncodeTo(e); err != nil { - return err - } - if err = s.InflationSeq.EncodeTo(e); err != nil { - return err - } - if err = s.IdPool.EncodeTo(e); err != nil { - return err - } - if err = s.BaseFee.EncodeTo(e); err != nil { - return err - } - if err = s.BaseReserve.EncodeTo(e); err != nil { + if err = s.Level.EncodeTo(e); err != nil { return err } - if err = s.MaxTxSetSize.EncodeTo(e); err != nil { - return err - } - for i := 0; i < len(s.SkipList); i++ { - if err = s.SkipList[i].EncodeTo(e); err != nil { - return err - } - } - if err = s.Ext.EncodeTo(e); err != nil { + if err = s.Hash.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*LedgerHeader)(nil) +var _ decoderFrom = (*ColdArchiveHashEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerHeader) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ColdArchiveHashEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerHeader: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ColdArchiveHashEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - nTmp, err = s.ScpValue.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding StellarValue: %w", err) - } - nTmp, err = s.TxSetResultHash.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - nTmp, err = s.BucketListHash.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.TotalCoins.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.FeePool.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.InflationSeq.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.IdPool.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.BaseFee.DecodeFrom(d, maxDepth) + nTmp, err = s.Index.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.BaseReserve.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.MaxTxSetSize.DecodeFrom(d, maxDepth) + nTmp, err = s.Level.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) } - for i := 0; i < len(s.SkipList); i++ { - nTmp, err = s.SkipList[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - } - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderExt: %w", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerHeader) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerHeader) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*LedgerHeader)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerHeader)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s LedgerHeader) xdrType() {} - -var _ xdrType = (*LedgerHeader)(nil) - -// LedgerUpgradeType is an XDR Enum defines as: -// -// enum LedgerUpgradeType -// { -// LEDGER_UPGRADE_VERSION = 1, -// LEDGER_UPGRADE_BASE_FEE = 2, -// LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3, -// LEDGER_UPGRADE_BASE_RESERVE = 4, -// LEDGER_UPGRADE_FLAGS = 5, -// LEDGER_UPGRADE_CONFIG = 6, -// LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE = 7 -// }; -type LedgerUpgradeType int32 - -const ( - LedgerUpgradeTypeLedgerUpgradeVersion LedgerUpgradeType = 1 - LedgerUpgradeTypeLedgerUpgradeBaseFee LedgerUpgradeType = 2 - LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize LedgerUpgradeType = 3 - LedgerUpgradeTypeLedgerUpgradeBaseReserve LedgerUpgradeType = 4 - LedgerUpgradeTypeLedgerUpgradeFlags LedgerUpgradeType = 5 - LedgerUpgradeTypeLedgerUpgradeConfig LedgerUpgradeType = 6 - LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize LedgerUpgradeType = 7 -) - -var ledgerUpgradeTypeMap = map[int32]string{ - 1: "LedgerUpgradeTypeLedgerUpgradeVersion", - 2: "LedgerUpgradeTypeLedgerUpgradeBaseFee", - 3: "LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize", - 4: "LedgerUpgradeTypeLedgerUpgradeBaseReserve", - 5: "LedgerUpgradeTypeLedgerUpgradeFlags", - 6: "LedgerUpgradeTypeLedgerUpgradeConfig", - 7: "LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for LedgerUpgradeType -func (e LedgerUpgradeType) ValidEnum(v int32) bool { - _, ok := ledgerUpgradeTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e LedgerUpgradeType) String() string { - name, _ := ledgerUpgradeTypeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e LedgerUpgradeType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := ledgerUpgradeTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid LedgerUpgradeType enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*LedgerUpgradeType)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *LedgerUpgradeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerUpgradeType: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding LedgerUpgradeType: %w", err) - } - if _, ok := ledgerUpgradeTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid LedgerUpgradeType enum value", v) - } - *e = LedgerUpgradeType(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerUpgradeType) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerUpgradeType) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*LedgerUpgradeType)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerUpgradeType)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s LedgerUpgradeType) xdrType() {} - -var _ xdrType = (*LedgerUpgradeType)(nil) - -// ConfigUpgradeSetKey is an XDR Struct defines as: -// -// struct ConfigUpgradeSetKey { -// Hash contractID; -// Hash contentHash; -// }; -type ConfigUpgradeSetKey struct { - ContractId Hash - ContentHash Hash -} - -// EncodeTo encodes this value using the Encoder. -func (s *ConfigUpgradeSetKey) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.ContractId.EncodeTo(e); err != nil { - return err - } - if err = s.ContentHash.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*ConfigUpgradeSetKey)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *ConfigUpgradeSetKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding ConfigUpgradeSetKey: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.ContractId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - nTmp, err = s.ContentHash.DecodeFrom(d, maxDepth) + nTmp, err = s.Hash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Hash: %w", err) @@ -12438,7 +12542,7 @@ func (s *ConfigUpgradeSetKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ConfigUpgradeSetKey) MarshalBinary() ([]byte, error) { +func (s ColdArchiveHashEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -12446,7 +12550,7 @@ func (s ConfigUpgradeSetKey) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ConfigUpgradeSetKey) UnmarshalBinary(inp []byte) error { +func (s *ColdArchiveHashEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -12456,360 +12560,273 @@ func (s *ConfigUpgradeSetKey) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ConfigUpgradeSetKey)(nil) - _ encoding.BinaryUnmarshaler = (*ConfigUpgradeSetKey)(nil) + _ encoding.BinaryMarshaler = (*ColdArchiveHashEntry)(nil) + _ encoding.BinaryUnmarshaler = (*ColdArchiveHashEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ConfigUpgradeSetKey) xdrType() {} +func (s ColdArchiveHashEntry) xdrType() {} -var _ xdrType = (*ConfigUpgradeSetKey)(nil) +var _ xdrType = (*ColdArchiveHashEntry)(nil) -// LedgerUpgrade is an XDR Union defines as: +// ColdArchiveBucketEntry is an XDR Union defines as: // -// union LedgerUpgrade switch (LedgerUpgradeType type) +// union ColdArchiveBucketEntry switch (ColdArchiveBucketEntryType type) // { -// case LEDGER_UPGRADE_VERSION: -// uint32 newLedgerVersion; // update ledgerVersion -// case LEDGER_UPGRADE_BASE_FEE: -// uint32 newBaseFee; // update baseFee -// case LEDGER_UPGRADE_MAX_TX_SET_SIZE: -// uint32 newMaxTxSetSize; // update maxTxSetSize -// case LEDGER_UPGRADE_BASE_RESERVE: -// uint32 newBaseReserve; // update baseReserve -// case LEDGER_UPGRADE_FLAGS: -// uint32 newFlags; // update flags -// case LEDGER_UPGRADE_CONFIG: -// // Update arbitrary `ConfigSetting` entries identified by the key. -// ConfigUpgradeSetKey newConfig; -// case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: -// // Update ConfigSettingContractExecutionLanesV0.ledgerMaxTxCount without -// // using `LEDGER_UPGRADE_CONFIG`. -// uint32 newMaxSorobanTxSetSize; -// }; -type LedgerUpgrade struct { - Type LedgerUpgradeType - NewLedgerVersion *Uint32 - NewBaseFee *Uint32 - NewMaxTxSetSize *Uint32 - NewBaseReserve *Uint32 - NewFlags *Uint32 - NewConfig *ConfigUpgradeSetKey - NewMaxSorobanTxSetSize *Uint32 +// case COLD_ARCHIVE_METAENTRY: +// BucketMetadata metaEntry; +// case COLD_ARCHIVE_ARCHIVED_LEAF: +// ColdArchiveArchivedLeaf archivedLeaf; +// case COLD_ARCHIVE_DELETED_LEAF: +// ColdArchiveDeletedLeaf deletedLeaf; +// case COLD_ARCHIVE_BOUNDARY_LEAF: +// ColdArchiveBoundaryLeaf boundaryLeaf; +// case COLD_ARCHIVE_HASH: +// ColdArchiveHashEntry hashEntry; +// }; +type ColdArchiveBucketEntry struct { + Type ColdArchiveBucketEntryType + MetaEntry *BucketMetadata + ArchivedLeaf *ColdArchiveArchivedLeaf + DeletedLeaf *ColdArchiveDeletedLeaf + BoundaryLeaf *ColdArchiveBoundaryLeaf + HashEntry *ColdArchiveHashEntry } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u LedgerUpgrade) SwitchFieldName() string { +func (u ColdArchiveBucketEntry) SwitchFieldName() string { return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of LedgerUpgrade -func (u LedgerUpgrade) ArmForSwitch(sw int32) (string, bool) { - switch LedgerUpgradeType(sw) { - case LedgerUpgradeTypeLedgerUpgradeVersion: - return "NewLedgerVersion", true - case LedgerUpgradeTypeLedgerUpgradeBaseFee: - return "NewBaseFee", true - case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: - return "NewMaxTxSetSize", true - case LedgerUpgradeTypeLedgerUpgradeBaseReserve: - return "NewBaseReserve", true - case LedgerUpgradeTypeLedgerUpgradeFlags: - return "NewFlags", true - case LedgerUpgradeTypeLedgerUpgradeConfig: - return "NewConfig", true - case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: - return "NewMaxSorobanTxSetSize", true +// the value for an instance of ColdArchiveBucketEntry +func (u ColdArchiveBucketEntry) ArmForSwitch(sw int32) (string, bool) { + switch ColdArchiveBucketEntryType(sw) { + case ColdArchiveBucketEntryTypeColdArchiveMetaentry: + return "MetaEntry", true + case ColdArchiveBucketEntryTypeColdArchiveArchivedLeaf: + return "ArchivedLeaf", true + case ColdArchiveBucketEntryTypeColdArchiveDeletedLeaf: + return "DeletedLeaf", true + case ColdArchiveBucketEntryTypeColdArchiveBoundaryLeaf: + return "BoundaryLeaf", true + case ColdArchiveBucketEntryTypeColdArchiveHash: + return "HashEntry", true } return "-", false } -// NewLedgerUpgrade creates a new LedgerUpgrade. -func NewLedgerUpgrade(aType LedgerUpgradeType, value interface{}) (result LedgerUpgrade, err error) { +// NewColdArchiveBucketEntry creates a new ColdArchiveBucketEntry. +func NewColdArchiveBucketEntry(aType ColdArchiveBucketEntryType, value interface{}) (result ColdArchiveBucketEntry, err error) { result.Type = aType - switch LedgerUpgradeType(aType) { - case LedgerUpgradeTypeLedgerUpgradeVersion: - tv, ok := value.(Uint32) - if !ok { - err = errors.New("invalid value, must be Uint32") - return - } - result.NewLedgerVersion = &tv - case LedgerUpgradeTypeLedgerUpgradeBaseFee: - tv, ok := value.(Uint32) - if !ok { - err = errors.New("invalid value, must be Uint32") - return - } - result.NewBaseFee = &tv - case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: - tv, ok := value.(Uint32) + switch ColdArchiveBucketEntryType(aType) { + case ColdArchiveBucketEntryTypeColdArchiveMetaentry: + tv, ok := value.(BucketMetadata) if !ok { - err = errors.New("invalid value, must be Uint32") + err = errors.New("invalid value, must be BucketMetadata") return } - result.NewMaxTxSetSize = &tv - case LedgerUpgradeTypeLedgerUpgradeBaseReserve: - tv, ok := value.(Uint32) + result.MetaEntry = &tv + case ColdArchiveBucketEntryTypeColdArchiveArchivedLeaf: + tv, ok := value.(ColdArchiveArchivedLeaf) if !ok { - err = errors.New("invalid value, must be Uint32") + err = errors.New("invalid value, must be ColdArchiveArchivedLeaf") return } - result.NewBaseReserve = &tv - case LedgerUpgradeTypeLedgerUpgradeFlags: - tv, ok := value.(Uint32) + result.ArchivedLeaf = &tv + case ColdArchiveBucketEntryTypeColdArchiveDeletedLeaf: + tv, ok := value.(ColdArchiveDeletedLeaf) if !ok { - err = errors.New("invalid value, must be Uint32") + err = errors.New("invalid value, must be ColdArchiveDeletedLeaf") return } - result.NewFlags = &tv - case LedgerUpgradeTypeLedgerUpgradeConfig: - tv, ok := value.(ConfigUpgradeSetKey) + result.DeletedLeaf = &tv + case ColdArchiveBucketEntryTypeColdArchiveBoundaryLeaf: + tv, ok := value.(ColdArchiveBoundaryLeaf) if !ok { - err = errors.New("invalid value, must be ConfigUpgradeSetKey") + err = errors.New("invalid value, must be ColdArchiveBoundaryLeaf") return } - result.NewConfig = &tv - case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: - tv, ok := value.(Uint32) + result.BoundaryLeaf = &tv + case ColdArchiveBucketEntryTypeColdArchiveHash: + tv, ok := value.(ColdArchiveHashEntry) if !ok { - err = errors.New("invalid value, must be Uint32") + err = errors.New("invalid value, must be ColdArchiveHashEntry") return } - result.NewMaxSorobanTxSetSize = &tv + result.HashEntry = &tv } return } -// MustNewLedgerVersion retrieves the NewLedgerVersion value from the union, +// MustMetaEntry retrieves the MetaEntry value from the union, // panicing if the value is not set. -func (u LedgerUpgrade) MustNewLedgerVersion() Uint32 { - val, ok := u.GetNewLedgerVersion() +func (u ColdArchiveBucketEntry) MustMetaEntry() BucketMetadata { + val, ok := u.GetMetaEntry() if !ok { - panic("arm NewLedgerVersion is not set") + panic("arm MetaEntry is not set") } return val } -// GetNewLedgerVersion retrieves the NewLedgerVersion value from the union, +// GetMetaEntry retrieves the MetaEntry value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerUpgrade) GetNewLedgerVersion() (result Uint32, ok bool) { +func (u ColdArchiveBucketEntry) GetMetaEntry() (result BucketMetadata, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "NewLedgerVersion" { - result = *u.NewLedgerVersion + if armName == "MetaEntry" { + result = *u.MetaEntry ok = true } return } -// MustNewBaseFee retrieves the NewBaseFee value from the union, +// MustArchivedLeaf retrieves the ArchivedLeaf value from the union, // panicing if the value is not set. -func (u LedgerUpgrade) MustNewBaseFee() Uint32 { - val, ok := u.GetNewBaseFee() +func (u ColdArchiveBucketEntry) MustArchivedLeaf() ColdArchiveArchivedLeaf { + val, ok := u.GetArchivedLeaf() if !ok { - panic("arm NewBaseFee is not set") + panic("arm ArchivedLeaf is not set") } return val } -// GetNewBaseFee retrieves the NewBaseFee value from the union, +// GetArchivedLeaf retrieves the ArchivedLeaf value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerUpgrade) GetNewBaseFee() (result Uint32, ok bool) { +func (u ColdArchiveBucketEntry) GetArchivedLeaf() (result ColdArchiveArchivedLeaf, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "NewBaseFee" { - result = *u.NewBaseFee + if armName == "ArchivedLeaf" { + result = *u.ArchivedLeaf ok = true } return } -// MustNewMaxTxSetSize retrieves the NewMaxTxSetSize value from the union, +// MustDeletedLeaf retrieves the DeletedLeaf value from the union, // panicing if the value is not set. -func (u LedgerUpgrade) MustNewMaxTxSetSize() Uint32 { - val, ok := u.GetNewMaxTxSetSize() +func (u ColdArchiveBucketEntry) MustDeletedLeaf() ColdArchiveDeletedLeaf { + val, ok := u.GetDeletedLeaf() if !ok { - panic("arm NewMaxTxSetSize is not set") + panic("arm DeletedLeaf is not set") } return val } -// GetNewMaxTxSetSize retrieves the NewMaxTxSetSize value from the union, +// GetDeletedLeaf retrieves the DeletedLeaf value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerUpgrade) GetNewMaxTxSetSize() (result Uint32, ok bool) { +func (u ColdArchiveBucketEntry) GetDeletedLeaf() (result ColdArchiveDeletedLeaf, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "NewMaxTxSetSize" { - result = *u.NewMaxTxSetSize + if armName == "DeletedLeaf" { + result = *u.DeletedLeaf ok = true } return } -// MustNewBaseReserve retrieves the NewBaseReserve value from the union, +// MustBoundaryLeaf retrieves the BoundaryLeaf value from the union, // panicing if the value is not set. -func (u LedgerUpgrade) MustNewBaseReserve() Uint32 { - val, ok := u.GetNewBaseReserve() +func (u ColdArchiveBucketEntry) MustBoundaryLeaf() ColdArchiveBoundaryLeaf { + val, ok := u.GetBoundaryLeaf() if !ok { - panic("arm NewBaseReserve is not set") + panic("arm BoundaryLeaf is not set") } return val } -// GetNewBaseReserve retrieves the NewBaseReserve value from the union, +// GetBoundaryLeaf retrieves the BoundaryLeaf value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerUpgrade) GetNewBaseReserve() (result Uint32, ok bool) { +func (u ColdArchiveBucketEntry) GetBoundaryLeaf() (result ColdArchiveBoundaryLeaf, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "NewBaseReserve" { - result = *u.NewBaseReserve + if armName == "BoundaryLeaf" { + result = *u.BoundaryLeaf ok = true } return } -// MustNewFlags retrieves the NewFlags value from the union, +// MustHashEntry retrieves the HashEntry value from the union, // panicing if the value is not set. -func (u LedgerUpgrade) MustNewFlags() Uint32 { - val, ok := u.GetNewFlags() +func (u ColdArchiveBucketEntry) MustHashEntry() ColdArchiveHashEntry { + val, ok := u.GetHashEntry() if !ok { - panic("arm NewFlags is not set") + panic("arm HashEntry is not set") } return val } -// GetNewFlags retrieves the NewFlags value from the union, +// GetHashEntry retrieves the HashEntry value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerUpgrade) GetNewFlags() (result Uint32, ok bool) { +func (u ColdArchiveBucketEntry) GetHashEntry() (result ColdArchiveHashEntry, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "NewFlags" { - result = *u.NewFlags + if armName == "HashEntry" { + result = *u.HashEntry ok = true } return } -// MustNewConfig retrieves the NewConfig value from the union, -// panicing if the value is not set. -func (u LedgerUpgrade) MustNewConfig() ConfigUpgradeSetKey { - val, ok := u.GetNewConfig() - - if !ok { - panic("arm NewConfig is not set") +// EncodeTo encodes this value using the Encoder. +func (u ColdArchiveBucketEntry) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err } - - return val + switch ColdArchiveBucketEntryType(u.Type) { + case ColdArchiveBucketEntryTypeColdArchiveMetaentry: + if err = (*u.MetaEntry).EncodeTo(e); err != nil { + return err + } + return nil + case ColdArchiveBucketEntryTypeColdArchiveArchivedLeaf: + if err = (*u.ArchivedLeaf).EncodeTo(e); err != nil { + return err + } + return nil + case ColdArchiveBucketEntryTypeColdArchiveDeletedLeaf: + if err = (*u.DeletedLeaf).EncodeTo(e); err != nil { + return err + } + return nil + case ColdArchiveBucketEntryTypeColdArchiveBoundaryLeaf: + if err = (*u.BoundaryLeaf).EncodeTo(e); err != nil { + return err + } + return nil + case ColdArchiveBucketEntryTypeColdArchiveHash: + if err = (*u.HashEntry).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (ColdArchiveBucketEntryType) switch value '%d' is not valid for union ColdArchiveBucketEntry", u.Type) } -// GetNewConfig retrieves the NewConfig value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerUpgrade) GetNewConfig() (result ConfigUpgradeSetKey, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "NewConfig" { - result = *u.NewConfig - ok = true - } - - return -} - -// MustNewMaxSorobanTxSetSize retrieves the NewMaxSorobanTxSetSize value from the union, -// panicing if the value is not set. -func (u LedgerUpgrade) MustNewMaxSorobanTxSetSize() Uint32 { - val, ok := u.GetNewMaxSorobanTxSetSize() - - if !ok { - panic("arm NewMaxSorobanTxSetSize is not set") - } - - return val -} - -// GetNewMaxSorobanTxSetSize retrieves the NewMaxSorobanTxSetSize value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerUpgrade) GetNewMaxSorobanTxSetSize() (result Uint32, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "NewMaxSorobanTxSetSize" { - result = *u.NewMaxSorobanTxSetSize - ok = true - } - - return -} - -// EncodeTo encodes this value using the Encoder. -func (u LedgerUpgrade) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.Type.EncodeTo(e); err != nil { - return err - } - switch LedgerUpgradeType(u.Type) { - case LedgerUpgradeTypeLedgerUpgradeVersion: - if err = (*u.NewLedgerVersion).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerUpgradeTypeLedgerUpgradeBaseFee: - if err = (*u.NewBaseFee).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: - if err = (*u.NewMaxTxSetSize).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerUpgradeTypeLedgerUpgradeBaseReserve: - if err = (*u.NewBaseReserve).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerUpgradeTypeLedgerUpgradeFlags: - if err = (*u.NewFlags).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerUpgradeTypeLedgerUpgradeConfig: - if err = (*u.NewConfig).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: - if err = (*u.NewMaxSorobanTxSetSize).EncodeTo(e); err != nil { - return err - } - return nil - } - return fmt.Errorf("Type (LedgerUpgradeType) switch value '%d' is not valid for union LedgerUpgrade", u.Type) -} - -var _ decoderFrom = (*LedgerUpgrade)(nil) +var _ decoderFrom = (*ColdArchiveBucketEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerUpgrade) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *ColdArchiveBucketEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerUpgrade: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ColdArchiveBucketEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -12817,71 +12834,55 @@ func (u *LedgerUpgrade) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerUpgradeType: %w", err) + return n, fmt.Errorf("decoding ColdArchiveBucketEntryType: %w", err) } - switch LedgerUpgradeType(u.Type) { - case LedgerUpgradeTypeLedgerUpgradeVersion: - u.NewLedgerVersion = new(Uint32) - nTmp, err = (*u.NewLedgerVersion).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - return n, nil - case LedgerUpgradeTypeLedgerUpgradeBaseFee: - u.NewBaseFee = new(Uint32) - nTmp, err = (*u.NewBaseFee).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - return n, nil - case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: - u.NewMaxTxSetSize = new(Uint32) - nTmp, err = (*u.NewMaxTxSetSize).DecodeFrom(d, maxDepth) + switch ColdArchiveBucketEntryType(u.Type) { + case ColdArchiveBucketEntryTypeColdArchiveMetaentry: + u.MetaEntry = new(BucketMetadata) + nTmp, err = (*u.MetaEntry).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding BucketMetadata: %w", err) } return n, nil - case LedgerUpgradeTypeLedgerUpgradeBaseReserve: - u.NewBaseReserve = new(Uint32) - nTmp, err = (*u.NewBaseReserve).DecodeFrom(d, maxDepth) + case ColdArchiveBucketEntryTypeColdArchiveArchivedLeaf: + u.ArchivedLeaf = new(ColdArchiveArchivedLeaf) + nTmp, err = (*u.ArchivedLeaf).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding ColdArchiveArchivedLeaf: %w", err) } return n, nil - case LedgerUpgradeTypeLedgerUpgradeFlags: - u.NewFlags = new(Uint32) - nTmp, err = (*u.NewFlags).DecodeFrom(d, maxDepth) + case ColdArchiveBucketEntryTypeColdArchiveDeletedLeaf: + u.DeletedLeaf = new(ColdArchiveDeletedLeaf) + nTmp, err = (*u.DeletedLeaf).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding ColdArchiveDeletedLeaf: %w", err) } return n, nil - case LedgerUpgradeTypeLedgerUpgradeConfig: - u.NewConfig = new(ConfigUpgradeSetKey) - nTmp, err = (*u.NewConfig).DecodeFrom(d, maxDepth) + case ColdArchiveBucketEntryTypeColdArchiveBoundaryLeaf: + u.BoundaryLeaf = new(ColdArchiveBoundaryLeaf) + nTmp, err = (*u.BoundaryLeaf).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigUpgradeSetKey: %w", err) + return n, fmt.Errorf("decoding ColdArchiveBoundaryLeaf: %w", err) } return n, nil - case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: - u.NewMaxSorobanTxSetSize = new(Uint32) - nTmp, err = (*u.NewMaxSorobanTxSetSize).DecodeFrom(d, maxDepth) + case ColdArchiveBucketEntryTypeColdArchiveHash: + u.HashEntry = new(ColdArchiveHashEntry) + nTmp, err = (*u.HashEntry).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding ColdArchiveHashEntry: %w", err) } return n, nil } - return n, fmt.Errorf("union LedgerUpgrade has invalid Type (LedgerUpgradeType) switch value '%d'", u.Type) + return n, fmt.Errorf("union ColdArchiveBucketEntry has invalid Type (ColdArchiveBucketEntryType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerUpgrade) MarshalBinary() ([]byte, error) { +func (s ColdArchiveBucketEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -12889,7 +12890,7 @@ func (s LedgerUpgrade) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerUpgrade) UnmarshalBinary(inp []byte) error { +func (s *ColdArchiveBucketEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -12899,73 +12900,54 @@ func (s *LedgerUpgrade) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerUpgrade)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerUpgrade)(nil) + _ encoding.BinaryMarshaler = (*ColdArchiveBucketEntry)(nil) + _ encoding.BinaryUnmarshaler = (*ColdArchiveBucketEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerUpgrade) xdrType() {} +func (s ColdArchiveBucketEntry) xdrType() {} -var _ xdrType = (*LedgerUpgrade)(nil) +var _ xdrType = (*ColdArchiveBucketEntry)(nil) -// ConfigUpgradeSet is an XDR Struct defines as: +// UpgradeType is an XDR Typedef defines as: // -// struct ConfigUpgradeSet { -// ConfigSettingEntry updatedEntry<>; -// }; -type ConfigUpgradeSet struct { - UpdatedEntry []ConfigSettingEntry +// typedef opaque UpgradeType<128>; +type UpgradeType []byte + +// XDRMaxSize implements the Sized interface for UpgradeType +func (e UpgradeType) XDRMaxSize() int { + return 128 } // EncodeTo encodes this value using the Encoder. -func (s *ConfigUpgradeSet) EncodeTo(e *xdr.Encoder) error { +func (s UpgradeType) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s.UpdatedEntry))); err != nil { + if _, err = e.EncodeOpaque(s[:]); err != nil { return err } - for i := 0; i < len(s.UpdatedEntry); i++ { - if err = s.UpdatedEntry[i].EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*ConfigUpgradeSet)(nil) +var _ decoderFrom = (*UpgradeType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ConfigUpgradeSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *UpgradeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ConfigUpgradeSet: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding UpgradeType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var l uint32 - l, nTmp, err = d.DecodeUint() + (*s), nTmp, err = d.DecodeOpaque(128) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ConfigSettingEntry: %w", err) - } - s.UpdatedEntry = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ConfigSettingEntry: length (%d) exceeds remaining input length (%d)", l, il) - } - s.UpdatedEntry = make([]ConfigSettingEntry, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.UpdatedEntry[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ConfigSettingEntry: %w", err) - } - } + return n, fmt.Errorf("decoding UpgradeType: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ConfigUpgradeSet) MarshalBinary() ([]byte, error) { +func (s UpgradeType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -12973,7 +12955,7 @@ func (s ConfigUpgradeSet) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ConfigUpgradeSet) UnmarshalBinary(inp []byte) error { +func (s *UpgradeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -12983,85 +12965,77 @@ func (s *ConfigUpgradeSet) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ConfigUpgradeSet)(nil) - _ encoding.BinaryUnmarshaler = (*ConfigUpgradeSet)(nil) + _ encoding.BinaryMarshaler = (*UpgradeType)(nil) + _ encoding.BinaryUnmarshaler = (*UpgradeType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ConfigUpgradeSet) xdrType() {} +func (s UpgradeType) xdrType() {} -var _ xdrType = (*ConfigUpgradeSet)(nil) +var _ xdrType = (*UpgradeType)(nil) -// BucketEntryType is an XDR Enum defines as: +// StellarValueType is an XDR Enum defines as: // -// enum BucketEntryType +// enum StellarValueType // { -// METAENTRY = -// -1, // At-and-after protocol 11: bucket metadata, should come first. -// LIVEENTRY = 0, // Before protocol 11: created-or-updated; -// // At-and-after protocol 11: only updated. -// DEADENTRY = 1, -// INITENTRY = 2 // At-and-after protocol 11: only created. +// STELLAR_VALUE_BASIC = 0, +// STELLAR_VALUE_SIGNED = 1 // }; -type BucketEntryType int32 +type StellarValueType int32 const ( - BucketEntryTypeMetaentry BucketEntryType = -1 - BucketEntryTypeLiveentry BucketEntryType = 0 - BucketEntryTypeDeadentry BucketEntryType = 1 - BucketEntryTypeInitentry BucketEntryType = 2 + StellarValueTypeStellarValueBasic StellarValueType = 0 + StellarValueTypeStellarValueSigned StellarValueType = 1 ) -var bucketEntryTypeMap = map[int32]string{ - -1: "BucketEntryTypeMetaentry", - 0: "BucketEntryTypeLiveentry", - 1: "BucketEntryTypeDeadentry", - 2: "BucketEntryTypeInitentry", +var stellarValueTypeMap = map[int32]string{ + 0: "StellarValueTypeStellarValueBasic", + 1: "StellarValueTypeStellarValueSigned", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for BucketEntryType -func (e BucketEntryType) ValidEnum(v int32) bool { - _, ok := bucketEntryTypeMap[v] +// the Enum interface for StellarValueType +func (e StellarValueType) ValidEnum(v int32) bool { + _, ok := stellarValueTypeMap[v] return ok } // String returns the name of `e` -func (e BucketEntryType) String() string { - name, _ := bucketEntryTypeMap[int32(e)] +func (e StellarValueType) String() string { + name, _ := stellarValueTypeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e BucketEntryType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := bucketEntryTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid BucketEntryType enum value", e) +func (e StellarValueType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := stellarValueTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid StellarValueType enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*BucketEntryType)(nil) +var _ decoderFrom = (*StellarValueType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *BucketEntryType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *StellarValueType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding BucketEntryType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding StellarValueType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding BucketEntryType: %w", err) + return n, fmt.Errorf("decoding StellarValueType: %w", err) } - if _, ok := bucketEntryTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid BucketEntryType enum value", v) + if _, ok := stellarValueTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid StellarValueType enum value", v) } - *e = BucketEntryType(v) + *e = StellarValueType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BucketEntryType) MarshalBinary() ([]byte, error) { +func (s StellarValueType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -13069,7 +13043,7 @@ func (s BucketEntryType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BucketEntryType) UnmarshalBinary(inp []byte) error { +func (s *StellarValueType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -13079,91 +13053,216 @@ func (s *BucketEntryType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*BucketEntryType)(nil) - _ encoding.BinaryUnmarshaler = (*BucketEntryType)(nil) + _ encoding.BinaryMarshaler = (*StellarValueType)(nil) + _ encoding.BinaryUnmarshaler = (*StellarValueType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s BucketEntryType) xdrType() {} +func (s StellarValueType) xdrType() {} -var _ xdrType = (*BucketEntryType)(nil) +var _ xdrType = (*StellarValueType)(nil) -// BucketMetadataExt is an XDR NestedUnion defines as: +// LedgerCloseValueSignature is an XDR Struct defines as: // -// union switch (int v) +// struct LedgerCloseValueSignature +// { +// NodeID nodeID; // which node introduced the value +// Signature signature; // nodeID's signature +// }; +type LedgerCloseValueSignature struct { + NodeId NodeId + Signature Signature +} + +// EncodeTo encodes this value using the Encoder. +func (s *LedgerCloseValueSignature) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.NodeId.EncodeTo(e); err != nil { + return err + } + if err = s.Signature.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*LedgerCloseValueSignature)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *LedgerCloseValueSignature) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerCloseValueSignature: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.NodeId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding NodeId: %w", err) + } + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Signature: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s LedgerCloseValueSignature) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *LedgerCloseValueSignature) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*LedgerCloseValueSignature)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerCloseValueSignature)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s LedgerCloseValueSignature) xdrType() {} + +var _ xdrType = (*LedgerCloseValueSignature)(nil) + +// StellarValueExt is an XDR NestedUnion defines as: +// +// union switch (StellarValueType v) // { -// case 0: +// case STELLAR_VALUE_BASIC: // void; +// case STELLAR_VALUE_SIGNED: +// LedgerCloseValueSignature lcValueSignature; // } -type BucketMetadataExt struct { - V int32 +type StellarValueExt struct { + V StellarValueType + LcValueSignature *LedgerCloseValueSignature } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u BucketMetadataExt) SwitchFieldName() string { +func (u StellarValueExt) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of BucketMetadataExt -func (u BucketMetadataExt) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: +// the value for an instance of StellarValueExt +func (u StellarValueExt) ArmForSwitch(sw int32) (string, bool) { + switch StellarValueType(sw) { + case StellarValueTypeStellarValueBasic: return "", true + case StellarValueTypeStellarValueSigned: + return "LcValueSignature", true } return "-", false } -// NewBucketMetadataExt creates a new BucketMetadataExt. -func NewBucketMetadataExt(v int32, value interface{}) (result BucketMetadataExt, err error) { +// NewStellarValueExt creates a new StellarValueExt. +func NewStellarValueExt(v StellarValueType, value interface{}) (result StellarValueExt, err error) { result.V = v - switch int32(v) { - case 0: + switch StellarValueType(v) { + case StellarValueTypeStellarValueBasic: // void + case StellarValueTypeStellarValueSigned: + tv, ok := value.(LedgerCloseValueSignature) + if !ok { + err = errors.New("invalid value, must be LedgerCloseValueSignature") + return + } + result.LcValueSignature = &tv + } + return +} + +// MustLcValueSignature retrieves the LcValueSignature value from the union, +// panicing if the value is not set. +func (u StellarValueExt) MustLcValueSignature() LedgerCloseValueSignature { + val, ok := u.GetLcValueSignature() + + if !ok { + panic("arm LcValueSignature is not set") + } + + return val +} + +// GetLcValueSignature retrieves the LcValueSignature value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarValueExt) GetLcValueSignature() (result LedgerCloseValueSignature, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "LcValueSignature" { + result = *u.LcValueSignature + ok = true } + return } // EncodeTo encodes this value using the Encoder. -func (u BucketMetadataExt) EncodeTo(e *xdr.Encoder) error { +func (u StellarValueExt) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { + if err = u.V.EncodeTo(e); err != nil { return err } - switch int32(u.V) { - case 0: + switch StellarValueType(u.V) { + case StellarValueTypeStellarValueBasic: // Void return nil + case StellarValueTypeStellarValueSigned: + if err = (*u.LcValueSignature).EncodeTo(e); err != nil { + return err + } + return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union BucketMetadataExt", u.V) + return fmt.Errorf("V (StellarValueType) switch value '%d' is not valid for union StellarValueExt", u.V) } -var _ decoderFrom = (*BucketMetadataExt)(nil) +var _ decoderFrom = (*StellarValueExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *BucketMetadataExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *StellarValueExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding BucketMetadataExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding StellarValueExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = u.V.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding StellarValueType: %w", err) } - switch int32(u.V) { - case 0: + switch StellarValueType(u.V) { + case StellarValueTypeStellarValueBasic: // Void return n, nil + case StellarValueTypeStellarValueSigned: + u.LcValueSignature = new(LedgerCloseValueSignature) + nTmp, err = (*u.LcValueSignature).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerCloseValueSignature: %w", err) + } + return n, nil } - return n, fmt.Errorf("union BucketMetadataExt has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union StellarValueExt has invalid V (StellarValueType) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BucketMetadataExt) MarshalBinary() ([]byte, error) { +func (s StellarValueExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -13171,7 +13270,7 @@ func (s BucketMetadataExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BucketMetadataExt) UnmarshalBinary(inp []byte) error { +func (s *StellarValueExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -13181,72 +13280,122 @@ func (s *BucketMetadataExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*BucketMetadataExt)(nil) - _ encoding.BinaryUnmarshaler = (*BucketMetadataExt)(nil) + _ encoding.BinaryMarshaler = (*StellarValueExt)(nil) + _ encoding.BinaryUnmarshaler = (*StellarValueExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s BucketMetadataExt) xdrType() {} +func (s StellarValueExt) xdrType() {} -var _ xdrType = (*BucketMetadataExt)(nil) +var _ xdrType = (*StellarValueExt)(nil) -// BucketMetadata is an XDR Struct defines as: +// StellarValue is an XDR Struct defines as: // -// struct BucketMetadata +// struct StellarValue // { -// // Indicates the protocol version used to create / merge this bucket. -// uint32 ledgerVersion; +// Hash txSetHash; // transaction set to apply to previous ledger +// TimePoint closeTime; // network close time +// +// // upgrades to apply to the previous ledger (usually empty) +// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop +// // unknown steps during consensus if needed. +// // see notes below on 'LedgerUpgrade' for more detail +// // max size is dictated by number of upgrade types (+ room for future) +// UpgradeType upgrades<6>; // // // reserved for future use -// union switch (int v) +// union switch (StellarValueType v) // { -// case 0: +// case STELLAR_VALUE_BASIC: // void; +// case STELLAR_VALUE_SIGNED: +// LedgerCloseValueSignature lcValueSignature; // } // ext; // }; -type BucketMetadata struct { - LedgerVersion Uint32 - Ext BucketMetadataExt +type StellarValue struct { + TxSetHash Hash + CloseTime TimePoint + Upgrades []UpgradeType `xdrmaxsize:"6"` + Ext StellarValueExt } // EncodeTo encodes this value using the Encoder. -func (s *BucketMetadata) EncodeTo(e *xdr.Encoder) error { +func (s *StellarValue) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.LedgerVersion.EncodeTo(e); err != nil { + if err = s.TxSetHash.EncodeTo(e); err != nil { + return err + } + if err = s.CloseTime.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.Upgrades))); err != nil { return err } + for i := 0; i < len(s.Upgrades); i++ { + if err = s.Upgrades[i].EncodeTo(e); err != nil { + return err + } + } if err = s.Ext.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*BucketMetadata)(nil) +var _ decoderFrom = (*StellarValue)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *BucketMetadata) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *StellarValue) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding BucketMetadata: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding StellarValue: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) + nTmp, err = s.TxSetHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + nTmp, err = s.CloseTime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding BucketMetadataExt: %w", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s BucketMetadata) MarshalBinary() ([]byte, error) { + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding UpgradeType: %w", err) + } + if l > 6 { + return n, fmt.Errorf("decoding UpgradeType: data size (%d) exceeds size limit (6)", l) + } + s.Upgrades = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding UpgradeType: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Upgrades = make([]UpgradeType, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Upgrades[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding UpgradeType: %w", err) + } + } + } + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding StellarValueExt: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s StellarValue) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -13254,7 +13403,7 @@ func (s BucketMetadata) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BucketMetadata) UnmarshalBinary(inp []byte) error { +func (s *StellarValue) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -13264,253 +13413,85 @@ func (s *BucketMetadata) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*BucketMetadata)(nil) - _ encoding.BinaryUnmarshaler = (*BucketMetadata)(nil) + _ encoding.BinaryMarshaler = (*StellarValue)(nil) + _ encoding.BinaryUnmarshaler = (*StellarValue)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s BucketMetadata) xdrType() {} +func (s StellarValue) xdrType() {} -var _ xdrType = (*BucketMetadata)(nil) +var _ xdrType = (*StellarValue)(nil) -// BucketEntry is an XDR Union defines as: +// MaskLedgerHeaderFlags is an XDR Const defines as: // -// union BucketEntry switch (BucketEntryType type) -// { -// case LIVEENTRY: -// case INITENTRY: -// LedgerEntry liveEntry; +// const MASK_LEDGER_HEADER_FLAGS = 0x7; +const MaskLedgerHeaderFlags = 0x7 + +// LedgerHeaderFlags is an XDR Enum defines as: // -// case DEADENTRY: -// LedgerKey deadEntry; -// case METAENTRY: -// BucketMetadata metaEntry; +// enum LedgerHeaderFlags +// { +// DISABLE_LIQUIDITY_POOL_TRADING_FLAG = 0x1, +// DISABLE_LIQUIDITY_POOL_DEPOSIT_FLAG = 0x2, +// DISABLE_LIQUIDITY_POOL_WITHDRAWAL_FLAG = 0x4 // }; -type BucketEntry struct { - Type BucketEntryType - LiveEntry *LedgerEntry - DeadEntry *LedgerKey - MetaEntry *BucketMetadata -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u BucketEntry) SwitchFieldName() string { - return "Type" -} - -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of BucketEntry -func (u BucketEntry) ArmForSwitch(sw int32) (string, bool) { - switch BucketEntryType(sw) { - case BucketEntryTypeLiveentry: - return "LiveEntry", true - case BucketEntryTypeInitentry: - return "LiveEntry", true - case BucketEntryTypeDeadentry: - return "DeadEntry", true - case BucketEntryTypeMetaentry: - return "MetaEntry", true - } - return "-", false -} - -// NewBucketEntry creates a new BucketEntry. -func NewBucketEntry(aType BucketEntryType, value interface{}) (result BucketEntry, err error) { - result.Type = aType - switch BucketEntryType(aType) { - case BucketEntryTypeLiveentry: - tv, ok := value.(LedgerEntry) - if !ok { - err = errors.New("invalid value, must be LedgerEntry") - return - } - result.LiveEntry = &tv - case BucketEntryTypeInitentry: - tv, ok := value.(LedgerEntry) - if !ok { - err = errors.New("invalid value, must be LedgerEntry") - return - } - result.LiveEntry = &tv - case BucketEntryTypeDeadentry: - tv, ok := value.(LedgerKey) - if !ok { - err = errors.New("invalid value, must be LedgerKey") - return - } - result.DeadEntry = &tv - case BucketEntryTypeMetaentry: - tv, ok := value.(BucketMetadata) - if !ok { - err = errors.New("invalid value, must be BucketMetadata") - return - } - result.MetaEntry = &tv - } - return -} - -// MustLiveEntry retrieves the LiveEntry value from the union, -// panicing if the value is not set. -func (u BucketEntry) MustLiveEntry() LedgerEntry { - val, ok := u.GetLiveEntry() - - if !ok { - panic("arm LiveEntry is not set") - } - - return val -} - -// GetLiveEntry retrieves the LiveEntry value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u BucketEntry) GetLiveEntry() (result LedgerEntry, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "LiveEntry" { - result = *u.LiveEntry - ok = true - } - - return -} - -// MustDeadEntry retrieves the DeadEntry value from the union, -// panicing if the value is not set. -func (u BucketEntry) MustDeadEntry() LedgerKey { - val, ok := u.GetDeadEntry() - - if !ok { - panic("arm DeadEntry is not set") - } - - return val -} - -// GetDeadEntry retrieves the DeadEntry value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u BucketEntry) GetDeadEntry() (result LedgerKey, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +type LedgerHeaderFlags int32 - if armName == "DeadEntry" { - result = *u.DeadEntry - ok = true - } +const ( + LedgerHeaderFlagsDisableLiquidityPoolTradingFlag LedgerHeaderFlags = 1 + LedgerHeaderFlagsDisableLiquidityPoolDepositFlag LedgerHeaderFlags = 2 + LedgerHeaderFlagsDisableLiquidityPoolWithdrawalFlag LedgerHeaderFlags = 4 +) - return +var ledgerHeaderFlagsMap = map[int32]string{ + 1: "LedgerHeaderFlagsDisableLiquidityPoolTradingFlag", + 2: "LedgerHeaderFlagsDisableLiquidityPoolDepositFlag", + 4: "LedgerHeaderFlagsDisableLiquidityPoolWithdrawalFlag", } -// MustMetaEntry retrieves the MetaEntry value from the union, -// panicing if the value is not set. -func (u BucketEntry) MustMetaEntry() BucketMetadata { - val, ok := u.GetMetaEntry() - - if !ok { - panic("arm MetaEntry is not set") - } - - return val +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for LedgerHeaderFlags +func (e LedgerHeaderFlags) ValidEnum(v int32) bool { + _, ok := ledgerHeaderFlagsMap[v] + return ok } -// GetMetaEntry retrieves the MetaEntry value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u BucketEntry) GetMetaEntry() (result BucketMetadata, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "MetaEntry" { - result = *u.MetaEntry - ok = true - } - - return +// String returns the name of `e` +func (e LedgerHeaderFlags) String() string { + name, _ := ledgerHeaderFlagsMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (u BucketEntry) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.Type.EncodeTo(e); err != nil { - return err - } - switch BucketEntryType(u.Type) { - case BucketEntryTypeLiveentry: - if err = (*u.LiveEntry).EncodeTo(e); err != nil { - return err - } - return nil - case BucketEntryTypeInitentry: - if err = (*u.LiveEntry).EncodeTo(e); err != nil { - return err - } - return nil - case BucketEntryTypeDeadentry: - if err = (*u.DeadEntry).EncodeTo(e); err != nil { - return err - } - return nil - case BucketEntryTypeMetaentry: - if err = (*u.MetaEntry).EncodeTo(e); err != nil { - return err - } - return nil +func (e LedgerHeaderFlags) EncodeTo(enc *xdr.Encoder) error { + if _, ok := ledgerHeaderFlagsMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid LedgerHeaderFlags enum value", e) } - return fmt.Errorf("Type (BucketEntryType) switch value '%d' is not valid for union BucketEntry", u.Type) + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*BucketEntry)(nil) +var _ decoderFrom = (*LedgerHeaderFlags)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *BucketEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *LedgerHeaderFlags) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding BucketEntry: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerHeaderFlags: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding BucketEntryType: %w", err) + return n, fmt.Errorf("decoding LedgerHeaderFlags: %w", err) } - switch BucketEntryType(u.Type) { - case BucketEntryTypeLiveentry: - u.LiveEntry = new(LedgerEntry) - nTmp, err = (*u.LiveEntry).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %w", err) - } - return n, nil - case BucketEntryTypeInitentry: - u.LiveEntry = new(LedgerEntry) - nTmp, err = (*u.LiveEntry).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %w", err) - } - return n, nil - case BucketEntryTypeDeadentry: - u.DeadEntry = new(LedgerKey) - nTmp, err = (*u.DeadEntry).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) - } - return n, nil - case BucketEntryTypeMetaentry: - u.MetaEntry = new(BucketMetadata) - nTmp, err = (*u.MetaEntry).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding BucketMetadata: %w", err) - } - return n, nil + if _, ok := ledgerHeaderFlagsMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid LedgerHeaderFlags enum value", v) } - return n, fmt.Errorf("union BucketEntry has invalid Type (BucketEntryType) switch value '%d'", u.Type) + *e = LedgerHeaderFlags(v) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BucketEntry) MarshalBinary() ([]byte, error) { +func (s LedgerHeaderFlags) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -13518,7 +13499,7 @@ func (s BucketEntry) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BucketEntry) UnmarshalBinary(inp []byte) error { +func (s *LedgerHeaderFlags) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -13528,76 +13509,91 @@ func (s *BucketEntry) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*BucketEntry)(nil) - _ encoding.BinaryUnmarshaler = (*BucketEntry)(nil) + _ encoding.BinaryMarshaler = (*LedgerHeaderFlags)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerHeaderFlags)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s BucketEntry) xdrType() {} +func (s LedgerHeaderFlags) xdrType() {} -var _ xdrType = (*BucketEntry)(nil) +var _ xdrType = (*LedgerHeaderFlags)(nil) -// TxSetComponentType is an XDR Enum defines as: +// LedgerHeaderExtensionV1Ext is an XDR NestedUnion defines as: // -// enum TxSetComponentType -// { -// // txs with effective fee <= bid derived from a base fee (if any). -// // If base fee is not specified, no discount is applied. -// TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE = 0 -// }; -type TxSetComponentType int32 - -const ( - TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee TxSetComponentType = 0 -) +// union switch (int v) +// { +// case 0: +// void; +// } +type LedgerHeaderExtensionV1Ext struct { + V int32 +} -var txSetComponentTypeMap = map[int32]string{ - 0: "TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee", +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u LedgerHeaderExtensionV1Ext) SwitchFieldName() string { + return "V" } -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for TxSetComponentType -func (e TxSetComponentType) ValidEnum(v int32) bool { - _, ok := txSetComponentTypeMap[v] - return ok +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of LedgerHeaderExtensionV1Ext +func (u LedgerHeaderExtensionV1Ext) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: + return "", true + } + return "-", false } -// String returns the name of `e` -func (e TxSetComponentType) String() string { - name, _ := txSetComponentTypeMap[int32(e)] - return name +// NewLedgerHeaderExtensionV1Ext creates a new LedgerHeaderExtensionV1Ext. +func NewLedgerHeaderExtensionV1Ext(v int32, value interface{}) (result LedgerHeaderExtensionV1Ext, err error) { + result.V = v + switch int32(v) { + case 0: + // void + } + return } // EncodeTo encodes this value using the Encoder. -func (e TxSetComponentType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := txSetComponentTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid TxSetComponentType enum value", e) +func (u LedgerHeaderExtensionV1Ext) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeInt(int32(u.V)); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + switch int32(u.V) { + case 0: + // Void + return nil + } + return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerHeaderExtensionV1Ext", u.V) } -var _ decoderFrom = (*TxSetComponentType)(nil) +var _ decoderFrom = (*LedgerHeaderExtensionV1Ext)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *TxSetComponentType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *LedgerHeaderExtensionV1Ext) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TxSetComponentType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerHeaderExtensionV1Ext: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + u.V, nTmp, err = d.DecodeInt() + n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponentType: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - if _, ok := txSetComponentTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid TxSetComponentType enum value", v) + switch int32(u.V) { + case 0: + // Void + return n, nil } - *e = TxSetComponentType(v) - return n, nil + return n, fmt.Errorf("union LedgerHeaderExtensionV1Ext has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TxSetComponentType) MarshalBinary() ([]byte, error) { +func (s LedgerHeaderExtensionV1Ext) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -13605,7 +13601,7 @@ func (s TxSetComponentType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TxSetComponentType) UnmarshalBinary(inp []byte) error { +func (s *LedgerHeaderExtensionV1Ext) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -13615,99 +13611,70 @@ func (s *TxSetComponentType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TxSetComponentType)(nil) - _ encoding.BinaryUnmarshaler = (*TxSetComponentType)(nil) + _ encoding.BinaryMarshaler = (*LedgerHeaderExtensionV1Ext)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerHeaderExtensionV1Ext)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TxSetComponentType) xdrType() {} +func (s LedgerHeaderExtensionV1Ext) xdrType() {} -var _ xdrType = (*TxSetComponentType)(nil) +var _ xdrType = (*LedgerHeaderExtensionV1Ext)(nil) -// TxSetComponentTxsMaybeDiscountedFee is an XDR NestedStruct defines as: +// LedgerHeaderExtensionV1 is an XDR Struct defines as: // -// struct -// { -// int64* baseFee; -// TransactionEnvelope txs<>; -// } -type TxSetComponentTxsMaybeDiscountedFee struct { - BaseFee *Int64 - Txs []TransactionEnvelope +// struct LedgerHeaderExtensionV1 +// { +// uint32 flags; // LedgerHeaderFlags +// +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +type LedgerHeaderExtensionV1 struct { + Flags Uint32 + Ext LedgerHeaderExtensionV1Ext } // EncodeTo encodes this value using the Encoder. -func (s *TxSetComponentTxsMaybeDiscountedFee) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerHeaderExtensionV1) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeBool(s.BaseFee != nil); err != nil { + if err = s.Flags.EncodeTo(e); err != nil { return err } - if s.BaseFee != nil { - if err = (*s.BaseFee).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.Txs))); err != nil { + if err = s.Ext.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Txs); i++ { - if err = s.Txs[i].EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*TxSetComponentTxsMaybeDiscountedFee)(nil) +var _ decoderFrom = (*LedgerHeaderExtensionV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TxSetComponentTxsMaybeDiscountedFee) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerHeaderExtensionV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TxSetComponentTxsMaybeDiscountedFee: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerHeaderExtensionV1: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var b bool - b, nTmp, err = d.DecodeBool() + nTmp, err = s.Flags.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - s.BaseFee = nil - if b { - s.BaseFee = new(Int64) - nTmp, err = s.BaseFee.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } + return n, fmt.Errorf("decoding Uint32: %w", err) } - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) - } - s.Txs = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Txs = make([]TransactionEnvelope, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) - } - } + return n, fmt.Errorf("decoding LedgerHeaderExtensionV1Ext: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TxSetComponentTxsMaybeDiscountedFee) MarshalBinary() ([]byte, error) { +func (s LedgerHeaderExtensionV1) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -13715,7 +13682,7 @@ func (s TxSetComponentTxsMaybeDiscountedFee) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TxSetComponentTxsMaybeDiscountedFee) UnmarshalBinary(inp []byte) error { +func (s *LedgerHeaderExtensionV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -13725,81 +13692,83 @@ func (s *TxSetComponentTxsMaybeDiscountedFee) UnmarshalBinary(inp []byte) error } var ( - _ encoding.BinaryMarshaler = (*TxSetComponentTxsMaybeDiscountedFee)(nil) - _ encoding.BinaryUnmarshaler = (*TxSetComponentTxsMaybeDiscountedFee)(nil) + _ encoding.BinaryMarshaler = (*LedgerHeaderExtensionV1)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerHeaderExtensionV1)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TxSetComponentTxsMaybeDiscountedFee) xdrType() {} +func (s LedgerHeaderExtensionV1) xdrType() {} -var _ xdrType = (*TxSetComponentTxsMaybeDiscountedFee)(nil) +var _ xdrType = (*LedgerHeaderExtensionV1)(nil) -// TxSetComponent is an XDR Union defines as: +// LedgerHeaderExt is an XDR NestedUnion defines as: // -// union TxSetComponent switch (TxSetComponentType type) -// { -// case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: -// struct -// { -// int64* baseFee; -// TransactionEnvelope txs<>; -// } txsMaybeDiscountedFee; -// }; -type TxSetComponent struct { - Type TxSetComponentType - TxsMaybeDiscountedFee *TxSetComponentTxsMaybeDiscountedFee +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// LedgerHeaderExtensionV1 v1; +// } +type LedgerHeaderExt struct { + V int32 + V1 *LedgerHeaderExtensionV1 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u TxSetComponent) SwitchFieldName() string { - return "Type" +func (u LedgerHeaderExt) SwitchFieldName() string { + return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of TxSetComponent -func (u TxSetComponent) ArmForSwitch(sw int32) (string, bool) { - switch TxSetComponentType(sw) { - case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: - return "TxsMaybeDiscountedFee", true +// the value for an instance of LedgerHeaderExt +func (u LedgerHeaderExt) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: + return "", true + case 1: + return "V1", true } return "-", false } -// NewTxSetComponent creates a new TxSetComponent. -func NewTxSetComponent(aType TxSetComponentType, value interface{}) (result TxSetComponent, err error) { - result.Type = aType - switch TxSetComponentType(aType) { - case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: - tv, ok := value.(TxSetComponentTxsMaybeDiscountedFee) +// NewLedgerHeaderExt creates a new LedgerHeaderExt. +func NewLedgerHeaderExt(v int32, value interface{}) (result LedgerHeaderExt, err error) { + result.V = v + switch int32(v) { + case 0: + // void + case 1: + tv, ok := value.(LedgerHeaderExtensionV1) if !ok { - err = errors.New("invalid value, must be TxSetComponentTxsMaybeDiscountedFee") + err = errors.New("invalid value, must be LedgerHeaderExtensionV1") return } - result.TxsMaybeDiscountedFee = &tv + result.V1 = &tv } return } -// MustTxsMaybeDiscountedFee retrieves the TxsMaybeDiscountedFee value from the union, +// MustV1 retrieves the V1 value from the union, // panicing if the value is not set. -func (u TxSetComponent) MustTxsMaybeDiscountedFee() TxSetComponentTxsMaybeDiscountedFee { - val, ok := u.GetTxsMaybeDiscountedFee() +func (u LedgerHeaderExt) MustV1() LedgerHeaderExtensionV1 { + val, ok := u.GetV1() if !ok { - panic("arm TxsMaybeDiscountedFee is not set") + panic("arm V1 is not set") } return val } -// GetTxsMaybeDiscountedFee retrieves the TxsMaybeDiscountedFee value from the union, +// GetV1 retrieves the V1 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u TxSetComponent) GetTxsMaybeDiscountedFee() (result TxSetComponentTxsMaybeDiscountedFee, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +func (u LedgerHeaderExt) GetV1() (result LedgerHeaderExtensionV1, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) - if armName == "TxsMaybeDiscountedFee" { - result = *u.TxsMaybeDiscountedFee + if armName == "V1" { + result = *u.V1 ok = true } @@ -13807,51 +13776,57 @@ func (u TxSetComponent) GetTxsMaybeDiscountedFee() (result TxSetComponentTxsMayb } // EncodeTo encodes this value using the Encoder. -func (u TxSetComponent) EncodeTo(e *xdr.Encoder) error { +func (u LedgerHeaderExt) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } - switch TxSetComponentType(u.Type) { - case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: - if err = (*u.TxsMaybeDiscountedFee).EncodeTo(e); err != nil { + switch int32(u.V) { + case 0: + // Void + return nil + case 1: + if err = (*u.V1).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (TxSetComponentType) switch value '%d' is not valid for union TxSetComponent", u.Type) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerHeaderExt", u.V) } -var _ decoderFrom = (*TxSetComponent)(nil) +var _ decoderFrom = (*LedgerHeaderExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TxSetComponent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *LedgerHeaderExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TxSetComponent: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerHeaderExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponentType: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - switch TxSetComponentType(u.Type) { - case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: - u.TxsMaybeDiscountedFee = new(TxSetComponentTxsMaybeDiscountedFee) - nTmp, err = (*u.TxsMaybeDiscountedFee).DecodeFrom(d, maxDepth) + switch int32(u.V) { + case 0: + // Void + return n, nil + case 1: + u.V1 = new(LedgerHeaderExtensionV1) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponentTxsMaybeDiscountedFee: %w", err) + return n, fmt.Errorf("decoding LedgerHeaderExtensionV1: %w", err) } return n, nil } - return n, fmt.Errorf("union TxSetComponent has invalid Type (TxSetComponentType) switch value '%d'", u.Type) + return n, fmt.Errorf("union LedgerHeaderExt has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TxSetComponent) MarshalBinary() ([]byte, error) { +func (s LedgerHeaderExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -13859,7 +13834,7 @@ func (s TxSetComponent) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TxSetComponent) UnmarshalBinary(inp []byte) error { +func (s *LedgerHeaderExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -13869,149 +13844,219 @@ func (s *TxSetComponent) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TxSetComponent)(nil) - _ encoding.BinaryUnmarshaler = (*TxSetComponent)(nil) + _ encoding.BinaryMarshaler = (*LedgerHeaderExt)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerHeaderExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TxSetComponent) xdrType() {} +func (s LedgerHeaderExt) xdrType() {} -var _ xdrType = (*TxSetComponent)(nil) +var _ xdrType = (*LedgerHeaderExt)(nil) -// TransactionPhase is an XDR Union defines as: +// LedgerHeader is an XDR Struct defines as: // -// union TransactionPhase switch (int v) +// struct LedgerHeader // { -// case 0: -// TxSetComponent v0Components<>; +// uint32 ledgerVersion; // the protocol version of the ledger +// Hash previousLedgerHash; // hash of the previous ledger header +// StellarValue scpValue; // what consensus agreed to +// Hash txSetResultHash; // the TransactionResultSet that led to this ledger +// Hash bucketListHash; // hash of the ledger state +// +// uint32 ledgerSeq; // sequence number of this ledger +// +// int64 totalCoins; // total number of stroops in existence. +// // 10,000,000 stroops in 1 XLM +// +// int64 feePool; // fees burned since last inflation run +// uint32 inflationSeq; // inflation sequence number +// +// uint64 idPool; // last used global ID, used for generating objects +// +// uint32 baseFee; // base fee per operation in stroops +// uint32 baseReserve; // account base reserve in stroops +// +// uint32 maxTxSetSize; // maximum size a transaction set can be +// +// Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back +// // in time without walking the chain back ledger by ledger +// // each slot contains the oldest ledger that is mod of +// // either 50 5000 50000 or 500000 depending on index +// // skipList[0] mod(50), skipList[1] mod(5000), etc +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// LedgerHeaderExtensionV1 v1; +// } +// ext; // }; -type TransactionPhase struct { - V int32 - V0Components *[]TxSetComponent -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u TransactionPhase) SwitchFieldName() string { - return "V" +type LedgerHeader struct { + LedgerVersion Uint32 + PreviousLedgerHash Hash + ScpValue StellarValue + TxSetResultHash Hash + BucketListHash Hash + LedgerSeq Uint32 + TotalCoins Int64 + FeePool Int64 + InflationSeq Uint32 + IdPool Uint64 + BaseFee Uint32 + BaseReserve Uint32 + MaxTxSetSize Uint32 + SkipList [4]Hash + Ext LedgerHeaderExt } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of TransactionPhase -func (u TransactionPhase) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: - return "V0Components", true +// EncodeTo encodes this value using the Encoder. +func (s *LedgerHeader) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.LedgerVersion.EncodeTo(e); err != nil { + return err } - return "-", false -} - -// NewTransactionPhase creates a new TransactionPhase. -func NewTransactionPhase(v int32, value interface{}) (result TransactionPhase, err error) { - result.V = v - switch int32(v) { - case 0: - tv, ok := value.([]TxSetComponent) - if !ok { - err = errors.New("invalid value, must be []TxSetComponent") - return - } - result.V0Components = &tv + if err = s.PreviousLedgerHash.EncodeTo(e); err != nil { + return err } - return -} - -// MustV0Components retrieves the V0Components value from the union, -// panicing if the value is not set. -func (u TransactionPhase) MustV0Components() []TxSetComponent { - val, ok := u.GetV0Components() - - if !ok { - panic("arm V0Components is not set") + if err = s.ScpValue.EncodeTo(e); err != nil { + return err } - - return val -} - -// GetV0Components retrieves the V0Components value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u TransactionPhase) GetV0Components() (result []TxSetComponent, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) - - if armName == "V0Components" { - result = *u.V0Components - ok = true + if err = s.TxSetResultHash.EncodeTo(e); err != nil { + return err } - - return -} - -// EncodeTo encodes this value using the Encoder. -func (u TransactionPhase) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { + if err = s.BucketListHash.EncodeTo(e); err != nil { return err } - switch int32(u.V) { - case 0: - if _, err = e.EncodeUint(uint32(len((*u.V0Components)))); err != nil { + if err = s.LedgerSeq.EncodeTo(e); err != nil { + return err + } + if err = s.TotalCoins.EncodeTo(e); err != nil { + return err + } + if err = s.FeePool.EncodeTo(e); err != nil { + return err + } + if err = s.InflationSeq.EncodeTo(e); err != nil { + return err + } + if err = s.IdPool.EncodeTo(e); err != nil { + return err + } + if err = s.BaseFee.EncodeTo(e); err != nil { + return err + } + if err = s.BaseReserve.EncodeTo(e); err != nil { + return err + } + if err = s.MaxTxSetSize.EncodeTo(e); err != nil { + return err + } + for i := 0; i < len(s.SkipList); i++ { + if err = s.SkipList[i].EncodeTo(e); err != nil { return err } - for i := 0; i < len((*u.V0Components)); i++ { - if err = (*u.V0Components)[i].EncodeTo(e); err != nil { - return err - } - } - return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionPhase", u.V) + if err = s.Ext.EncodeTo(e); err != nil { + return err + } + return nil } -var _ decoderFrom = (*TransactionPhase)(nil) +var _ decoderFrom = (*LedgerHeader)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionPhase) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerHeader) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionPhase: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerHeader: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - switch int32(u.V) { - case 0: - u.V0Components = new([]TxSetComponent) - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + nTmp, err = s.ScpValue.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding StellarValue: %w", err) + } + nTmp, err = s.TxSetResultHash.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + nTmp, err = s.BucketListHash.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.TotalCoins.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.FeePool.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.InflationSeq.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.IdPool.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.BaseFee.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.BaseReserve.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.MaxTxSetSize.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + for i := 0; i < len(s.SkipList); i++ { + nTmp, err = s.SkipList[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxSetComponent: %w", err) - } - (*u.V0Components) = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TxSetComponent: length (%d) exceeds remaining input length (%d)", l, il) - } - (*u.V0Components) = make([]TxSetComponent, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*u.V0Components)[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TxSetComponent: %w", err) - } - } + return n, fmt.Errorf("decoding Hash: %w", err) } - return n, nil } - return n, fmt.Errorf("union TransactionPhase has invalid V (int32) switch value '%d'", u.V) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerHeaderExt: %w", err) + } + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionPhase) MarshalBinary() ([]byte, error) { +func (s LedgerHeader) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14019,7 +14064,7 @@ func (s TransactionPhase) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionPhase) UnmarshalBinary(inp []byte) error { +func (s *LedgerHeader) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14029,84 +14074,92 @@ func (s *TransactionPhase) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionPhase)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionPhase)(nil) + _ encoding.BinaryMarshaler = (*LedgerHeader)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerHeader)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionPhase) xdrType() {} +func (s LedgerHeader) xdrType() {} -var _ xdrType = (*TransactionPhase)(nil) +var _ xdrType = (*LedgerHeader)(nil) -// TransactionSet is an XDR Struct defines as: +// LedgerUpgradeType is an XDR Enum defines as: // -// struct TransactionSet +// enum LedgerUpgradeType // { -// Hash previousLedgerHash; -// TransactionEnvelope txs<>; +// LEDGER_UPGRADE_VERSION = 1, +// LEDGER_UPGRADE_BASE_FEE = 2, +// LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3, +// LEDGER_UPGRADE_BASE_RESERVE = 4, +// LEDGER_UPGRADE_FLAGS = 5, +// LEDGER_UPGRADE_CONFIG = 6, +// LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE = 7 // }; -type TransactionSet struct { - PreviousLedgerHash Hash - Txs []TransactionEnvelope +type LedgerUpgradeType int32 + +const ( + LedgerUpgradeTypeLedgerUpgradeVersion LedgerUpgradeType = 1 + LedgerUpgradeTypeLedgerUpgradeBaseFee LedgerUpgradeType = 2 + LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize LedgerUpgradeType = 3 + LedgerUpgradeTypeLedgerUpgradeBaseReserve LedgerUpgradeType = 4 + LedgerUpgradeTypeLedgerUpgradeFlags LedgerUpgradeType = 5 + LedgerUpgradeTypeLedgerUpgradeConfig LedgerUpgradeType = 6 + LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize LedgerUpgradeType = 7 +) + +var ledgerUpgradeTypeMap = map[int32]string{ + 1: "LedgerUpgradeTypeLedgerUpgradeVersion", + 2: "LedgerUpgradeTypeLedgerUpgradeBaseFee", + 3: "LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize", + 4: "LedgerUpgradeTypeLedgerUpgradeBaseReserve", + 5: "LedgerUpgradeTypeLedgerUpgradeFlags", + 6: "LedgerUpgradeTypeLedgerUpgradeConfig", + 7: "LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for LedgerUpgradeType +func (e LedgerUpgradeType) ValidEnum(v int32) bool { + _, ok := ledgerUpgradeTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e LedgerUpgradeType) String() string { + name, _ := ledgerUpgradeTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *TransactionSet) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.PreviousLedgerHash.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.Txs))); err != nil { - return err - } - for i := 0; i < len(s.Txs); i++ { - if err = s.Txs[i].EncodeTo(e); err != nil { - return err - } +func (e LedgerUpgradeType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := ledgerUpgradeTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid LedgerUpgradeType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*TransactionSet)(nil) +var _ decoderFrom = (*LedgerUpgradeType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *LedgerUpgradeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionSet: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerUpgradeType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) + return n, fmt.Errorf("decoding LedgerUpgradeType: %w", err) } - s.Txs = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Txs = make([]TransactionEnvelope, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) - } - } + if _, ok := ledgerUpgradeTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid LedgerUpgradeType enum value", v) } + *e = LedgerUpgradeType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionSet) MarshalBinary() ([]byte, error) { +func (s LedgerUpgradeType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14114,7 +14167,7 @@ func (s TransactionSet) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionSet) UnmarshalBinary(inp []byte) error { +func (s *LedgerUpgradeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14124,84 +14177,63 @@ func (s *TransactionSet) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionSet)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionSet)(nil) + _ encoding.BinaryMarshaler = (*LedgerUpgradeType)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerUpgradeType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionSet) xdrType() {} +func (s LedgerUpgradeType) xdrType() {} -var _ xdrType = (*TransactionSet)(nil) +var _ xdrType = (*LedgerUpgradeType)(nil) -// TransactionSetV1 is an XDR Struct defines as: +// ConfigUpgradeSetKey is an XDR Struct defines as: // -// struct TransactionSetV1 -// { -// Hash previousLedgerHash; -// TransactionPhase phases<>; +// struct ConfigUpgradeSetKey { +// Hash contractID; +// Hash contentHash; // }; -type TransactionSetV1 struct { - PreviousLedgerHash Hash - Phases []TransactionPhase +type ConfigUpgradeSetKey struct { + ContractId Hash + ContentHash Hash } // EncodeTo encodes this value using the Encoder. -func (s *TransactionSetV1) EncodeTo(e *xdr.Encoder) error { +func (s *ConfigUpgradeSetKey) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.PreviousLedgerHash.EncodeTo(e); err != nil { + if err = s.ContractId.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Phases))); err != nil { + if err = s.ContentHash.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Phases); i++ { - if err = s.Phases[i].EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*TransactionSetV1)(nil) +var _ decoderFrom = (*ConfigUpgradeSetKey)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionSetV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ConfigUpgradeSetKey) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionSetV1: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ConfigUpgradeSetKey: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) + nTmp, err = s.ContractId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Hash: %w", err) } - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.ContentHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionPhase: %w", err) - } - s.Phases = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TransactionPhase: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Phases = make([]TransactionPhase, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Phases[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionPhase: %w", err) - } - } + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionSetV1) MarshalBinary() ([]byte, error) { +func (s ConfigUpgradeSetKey) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14209,7 +14241,7 @@ func (s TransactionSetV1) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionSetV1) UnmarshalBinary(inp []byte) error { +func (s *ConfigUpgradeSetKey) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14219,78 +14251,302 @@ func (s *TransactionSetV1) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionSetV1)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionSetV1)(nil) + _ encoding.BinaryMarshaler = (*ConfigUpgradeSetKey)(nil) + _ encoding.BinaryUnmarshaler = (*ConfigUpgradeSetKey)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionSetV1) xdrType() {} +func (s ConfigUpgradeSetKey) xdrType() {} -var _ xdrType = (*TransactionSetV1)(nil) +var _ xdrType = (*ConfigUpgradeSetKey)(nil) -// GeneralizedTransactionSet is an XDR Union defines as: +// LedgerUpgrade is an XDR Union defines as: // -// union GeneralizedTransactionSet switch (int v) +// union LedgerUpgrade switch (LedgerUpgradeType type) // { -// // We consider the legacy TransactionSet to be v0. -// case 1: -// TransactionSetV1 v1TxSet; +// case LEDGER_UPGRADE_VERSION: +// uint32 newLedgerVersion; // update ledgerVersion +// case LEDGER_UPGRADE_BASE_FEE: +// uint32 newBaseFee; // update baseFee +// case LEDGER_UPGRADE_MAX_TX_SET_SIZE: +// uint32 newMaxTxSetSize; // update maxTxSetSize +// case LEDGER_UPGRADE_BASE_RESERVE: +// uint32 newBaseReserve; // update baseReserve +// case LEDGER_UPGRADE_FLAGS: +// uint32 newFlags; // update flags +// case LEDGER_UPGRADE_CONFIG: +// // Update arbitrary `ConfigSetting` entries identified by the key. +// ConfigUpgradeSetKey newConfig; +// case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE: +// // Update ConfigSettingContractExecutionLanesV0.ledgerMaxTxCount without +// // using `LEDGER_UPGRADE_CONFIG`. +// uint32 newMaxSorobanTxSetSize; // }; -type GeneralizedTransactionSet struct { - V int32 - V1TxSet *TransactionSetV1 +type LedgerUpgrade struct { + Type LedgerUpgradeType + NewLedgerVersion *Uint32 + NewBaseFee *Uint32 + NewMaxTxSetSize *Uint32 + NewBaseReserve *Uint32 + NewFlags *Uint32 + NewConfig *ConfigUpgradeSetKey + NewMaxSorobanTxSetSize *Uint32 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u GeneralizedTransactionSet) SwitchFieldName() string { - return "V" +func (u LedgerUpgrade) SwitchFieldName() string { + return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of GeneralizedTransactionSet -func (u GeneralizedTransactionSet) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 1: - return "V1TxSet", true +// the value for an instance of LedgerUpgrade +func (u LedgerUpgrade) ArmForSwitch(sw int32) (string, bool) { + switch LedgerUpgradeType(sw) { + case LedgerUpgradeTypeLedgerUpgradeVersion: + return "NewLedgerVersion", true + case LedgerUpgradeTypeLedgerUpgradeBaseFee: + return "NewBaseFee", true + case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: + return "NewMaxTxSetSize", true + case LedgerUpgradeTypeLedgerUpgradeBaseReserve: + return "NewBaseReserve", true + case LedgerUpgradeTypeLedgerUpgradeFlags: + return "NewFlags", true + case LedgerUpgradeTypeLedgerUpgradeConfig: + return "NewConfig", true + case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: + return "NewMaxSorobanTxSetSize", true } return "-", false } -// NewGeneralizedTransactionSet creates a new GeneralizedTransactionSet. -func NewGeneralizedTransactionSet(v int32, value interface{}) (result GeneralizedTransactionSet, err error) { - result.V = v - switch int32(v) { - case 1: - tv, ok := value.(TransactionSetV1) +// NewLedgerUpgrade creates a new LedgerUpgrade. +func NewLedgerUpgrade(aType LedgerUpgradeType, value interface{}) (result LedgerUpgrade, err error) { + result.Type = aType + switch LedgerUpgradeType(aType) { + case LedgerUpgradeTypeLedgerUpgradeVersion: + tv, ok := value.(Uint32) if !ok { - err = errors.New("invalid value, must be TransactionSetV1") + err = errors.New("invalid value, must be Uint32") return } - result.V1TxSet = &tv + result.NewLedgerVersion = &tv + case LedgerUpgradeTypeLedgerUpgradeBaseFee: + tv, ok := value.(Uint32) + if !ok { + err = errors.New("invalid value, must be Uint32") + return + } + result.NewBaseFee = &tv + case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: + tv, ok := value.(Uint32) + if !ok { + err = errors.New("invalid value, must be Uint32") + return + } + result.NewMaxTxSetSize = &tv + case LedgerUpgradeTypeLedgerUpgradeBaseReserve: + tv, ok := value.(Uint32) + if !ok { + err = errors.New("invalid value, must be Uint32") + return + } + result.NewBaseReserve = &tv + case LedgerUpgradeTypeLedgerUpgradeFlags: + tv, ok := value.(Uint32) + if !ok { + err = errors.New("invalid value, must be Uint32") + return + } + result.NewFlags = &tv + case LedgerUpgradeTypeLedgerUpgradeConfig: + tv, ok := value.(ConfigUpgradeSetKey) + if !ok { + err = errors.New("invalid value, must be ConfigUpgradeSetKey") + return + } + result.NewConfig = &tv + case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: + tv, ok := value.(Uint32) + if !ok { + err = errors.New("invalid value, must be Uint32") + return + } + result.NewMaxSorobanTxSetSize = &tv } return } -// MustV1TxSet retrieves the V1TxSet value from the union, +// MustNewLedgerVersion retrieves the NewLedgerVersion value from the union, // panicing if the value is not set. -func (u GeneralizedTransactionSet) MustV1TxSet() TransactionSetV1 { - val, ok := u.GetV1TxSet() +func (u LedgerUpgrade) MustNewLedgerVersion() Uint32 { + val, ok := u.GetNewLedgerVersion() if !ok { - panic("arm V1TxSet is not set") + panic("arm NewLedgerVersion is not set") } return val } -// GetV1TxSet retrieves the V1TxSet value from the union, +// GetNewLedgerVersion retrieves the NewLedgerVersion value from the union, // returning ok if the union's switch indicated the value is valid. -func (u GeneralizedTransactionSet) GetV1TxSet() (result TransactionSetV1, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) +func (u LedgerUpgrade) GetNewLedgerVersion() (result Uint32, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "V1TxSet" { - result = *u.V1TxSet + if armName == "NewLedgerVersion" { + result = *u.NewLedgerVersion + ok = true + } + + return +} + +// MustNewBaseFee retrieves the NewBaseFee value from the union, +// panicing if the value is not set. +func (u LedgerUpgrade) MustNewBaseFee() Uint32 { + val, ok := u.GetNewBaseFee() + + if !ok { + panic("arm NewBaseFee is not set") + } + + return val +} + +// GetNewBaseFee retrieves the NewBaseFee value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerUpgrade) GetNewBaseFee() (result Uint32, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "NewBaseFee" { + result = *u.NewBaseFee + ok = true + } + + return +} + +// MustNewMaxTxSetSize retrieves the NewMaxTxSetSize value from the union, +// panicing if the value is not set. +func (u LedgerUpgrade) MustNewMaxTxSetSize() Uint32 { + val, ok := u.GetNewMaxTxSetSize() + + if !ok { + panic("arm NewMaxTxSetSize is not set") + } + + return val +} + +// GetNewMaxTxSetSize retrieves the NewMaxTxSetSize value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerUpgrade) GetNewMaxTxSetSize() (result Uint32, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "NewMaxTxSetSize" { + result = *u.NewMaxTxSetSize + ok = true + } + + return +} + +// MustNewBaseReserve retrieves the NewBaseReserve value from the union, +// panicing if the value is not set. +func (u LedgerUpgrade) MustNewBaseReserve() Uint32 { + val, ok := u.GetNewBaseReserve() + + if !ok { + panic("arm NewBaseReserve is not set") + } + + return val +} + +// GetNewBaseReserve retrieves the NewBaseReserve value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerUpgrade) GetNewBaseReserve() (result Uint32, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "NewBaseReserve" { + result = *u.NewBaseReserve + ok = true + } + + return +} + +// MustNewFlags retrieves the NewFlags value from the union, +// panicing if the value is not set. +func (u LedgerUpgrade) MustNewFlags() Uint32 { + val, ok := u.GetNewFlags() + + if !ok { + panic("arm NewFlags is not set") + } + + return val +} + +// GetNewFlags retrieves the NewFlags value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerUpgrade) GetNewFlags() (result Uint32, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "NewFlags" { + result = *u.NewFlags + ok = true + } + + return +} + +// MustNewConfig retrieves the NewConfig value from the union, +// panicing if the value is not set. +func (u LedgerUpgrade) MustNewConfig() ConfigUpgradeSetKey { + val, ok := u.GetNewConfig() + + if !ok { + panic("arm NewConfig is not set") + } + + return val +} + +// GetNewConfig retrieves the NewConfig value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerUpgrade) GetNewConfig() (result ConfigUpgradeSetKey, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "NewConfig" { + result = *u.NewConfig + ok = true + } + + return +} + +// MustNewMaxSorobanTxSetSize retrieves the NewMaxSorobanTxSetSize value from the union, +// panicing if the value is not set. +func (u LedgerUpgrade) MustNewMaxSorobanTxSetSize() Uint32 { + val, ok := u.GetNewMaxSorobanTxSetSize() + + if !ok { + panic("arm NewMaxSorobanTxSetSize is not set") + } + + return val +} + +// GetNewMaxSorobanTxSetSize retrieves the NewMaxSorobanTxSetSize value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerUpgrade) GetNewMaxSorobanTxSetSize() (result Uint32, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "NewMaxSorobanTxSetSize" { + result = *u.NewMaxSorobanTxSetSize ok = true } @@ -14298,51 +14554,129 @@ func (u GeneralizedTransactionSet) GetV1TxSet() (result TransactionSetV1, ok boo } // EncodeTo encodes this value using the Encoder. -func (u GeneralizedTransactionSet) EncodeTo(e *xdr.Encoder) error { +func (u LedgerUpgrade) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { + if err = u.Type.EncodeTo(e); err != nil { return err } - switch int32(u.V) { - case 1: - if err = (*u.V1TxSet).EncodeTo(e); err != nil { + switch LedgerUpgradeType(u.Type) { + case LedgerUpgradeTypeLedgerUpgradeVersion: + if err = (*u.NewLedgerVersion).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerUpgradeTypeLedgerUpgradeBaseFee: + if err = (*u.NewBaseFee).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: + if err = (*u.NewMaxTxSetSize).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerUpgradeTypeLedgerUpgradeBaseReserve: + if err = (*u.NewBaseReserve).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerUpgradeTypeLedgerUpgradeFlags: + if err = (*u.NewFlags).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerUpgradeTypeLedgerUpgradeConfig: + if err = (*u.NewConfig).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: + if err = (*u.NewMaxSorobanTxSetSize).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union GeneralizedTransactionSet", u.V) + return fmt.Errorf("Type (LedgerUpgradeType) switch value '%d' is not valid for union LedgerUpgrade", u.Type) } -var _ decoderFrom = (*GeneralizedTransactionSet)(nil) +var _ decoderFrom = (*LedgerUpgrade)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *GeneralizedTransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *LedgerUpgrade) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding GeneralizedTransactionSet: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerUpgrade: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding LedgerUpgradeType: %w", err) } - switch int32(u.V) { - case 1: - u.V1TxSet = new(TransactionSetV1) - nTmp, err = (*u.V1TxSet).DecodeFrom(d, maxDepth) + switch LedgerUpgradeType(u.Type) { + case LedgerUpgradeTypeLedgerUpgradeVersion: + u.NewLedgerVersion = new(Uint32) + nTmp, err = (*u.NewLedgerVersion).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionSetV1: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil + case LedgerUpgradeTypeLedgerUpgradeBaseFee: + u.NewBaseFee = new(Uint32) + nTmp, err = (*u.NewBaseFee).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil + case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: + u.NewMaxTxSetSize = new(Uint32) + nTmp, err = (*u.NewMaxTxSetSize).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil + case LedgerUpgradeTypeLedgerUpgradeBaseReserve: + u.NewBaseReserve = new(Uint32) + nTmp, err = (*u.NewBaseReserve).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil + case LedgerUpgradeTypeLedgerUpgradeFlags: + u.NewFlags = new(Uint32) + nTmp, err = (*u.NewFlags).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil + case LedgerUpgradeTypeLedgerUpgradeConfig: + u.NewConfig = new(ConfigUpgradeSetKey) + nTmp, err = (*u.NewConfig).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ConfigUpgradeSetKey: %w", err) + } + return n, nil + case LedgerUpgradeTypeLedgerUpgradeMaxSorobanTxSetSize: + u.NewMaxSorobanTxSetSize = new(Uint32) + nTmp, err = (*u.NewMaxSorobanTxSetSize).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } - return n, fmt.Errorf("union GeneralizedTransactionSet has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union LedgerUpgrade has invalid Type (LedgerUpgradeType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s GeneralizedTransactionSet) MarshalBinary() ([]byte, error) { +func (s LedgerUpgrade) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14350,7 +14684,7 @@ func (s GeneralizedTransactionSet) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *GeneralizedTransactionSet) UnmarshalBinary(inp []byte) error { +func (s *LedgerUpgrade) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14360,64 +14694,73 @@ func (s *GeneralizedTransactionSet) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*GeneralizedTransactionSet)(nil) - _ encoding.BinaryUnmarshaler = (*GeneralizedTransactionSet)(nil) + _ encoding.BinaryMarshaler = (*LedgerUpgrade)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerUpgrade)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s GeneralizedTransactionSet) xdrType() {} +func (s LedgerUpgrade) xdrType() {} -var _ xdrType = (*GeneralizedTransactionSet)(nil) +var _ xdrType = (*LedgerUpgrade)(nil) -// TransactionResultPair is an XDR Struct defines as: +// ConfigUpgradeSet is an XDR Struct defines as: // -// struct TransactionResultPair -// { -// Hash transactionHash; -// TransactionResult result; // result for the transaction +// struct ConfigUpgradeSet { +// ConfigSettingEntry updatedEntry<>; // }; -type TransactionResultPair struct { - TransactionHash Hash - Result TransactionResult +type ConfigUpgradeSet struct { + UpdatedEntry []ConfigSettingEntry } // EncodeTo encodes this value using the Encoder. -func (s *TransactionResultPair) EncodeTo(e *xdr.Encoder) error { +func (s *ConfigUpgradeSet) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.TransactionHash.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s.UpdatedEntry))); err != nil { return err } - if err = s.Result.EncodeTo(e); err != nil { - return err + for i := 0; i < len(s.UpdatedEntry); i++ { + if err = s.UpdatedEntry[i].EncodeTo(e); err != nil { + return err + } } return nil } -var _ decoderFrom = (*TransactionResultPair)(nil) +var _ decoderFrom = (*ConfigUpgradeSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultPair) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ConfigUpgradeSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionResultPair: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ConfigUpgradeSet: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TransactionHash.DecodeFrom(d, maxDepth) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + return n, fmt.Errorf("decoding ConfigSettingEntry: %w", err) } - nTmp, err = s.Result.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResult: %w", err) + s.UpdatedEntry = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ConfigSettingEntry: length (%d) exceeds remaining input length (%d)", l, il) + } + s.UpdatedEntry = make([]ConfigSettingEntry, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.UpdatedEntry[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ConfigSettingEntry: %w", err) + } + } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionResultPair) MarshalBinary() ([]byte, error) { +func (s ConfigUpgradeSet) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14425,7 +14768,7 @@ func (s TransactionResultPair) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionResultPair) UnmarshalBinary(inp []byte) error { +func (s *ConfigUpgradeSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14435,66 +14778,178 @@ func (s *TransactionResultPair) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionResultPair)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionResultPair)(nil) + _ encoding.BinaryMarshaler = (*ConfigUpgradeSet)(nil) + _ encoding.BinaryUnmarshaler = (*ConfigUpgradeSet)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionResultPair) xdrType() {} +func (s ConfigUpgradeSet) xdrType() {} -var _ xdrType = (*TransactionResultPair)(nil) +var _ xdrType = (*ConfigUpgradeSet)(nil) -// TransactionResultSet is an XDR Struct defines as: +// TxSetComponentType is an XDR Enum defines as: // -// struct TransactionResultSet +// enum TxSetComponentType // { -// TransactionResultPair results<>; +// // txs with effective fee <= bid derived from a base fee (if any). +// // If base fee is not specified, no discount is applied. +// TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE = 0 // }; -type TransactionResultSet struct { - Results []TransactionResultPair +type TxSetComponentType int32 + +const ( + TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee TxSetComponentType = 0 +) + +var txSetComponentTypeMap = map[int32]string{ + 0: "TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for TxSetComponentType +func (e TxSetComponentType) ValidEnum(v int32) bool { + _, ok := txSetComponentTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e TxSetComponentType) String() string { + name, _ := txSetComponentTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *TransactionResultSet) EncodeTo(e *xdr.Encoder) error { +func (e TxSetComponentType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := txSetComponentTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid TxSetComponentType enum value", e) + } + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*TxSetComponentType)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (e *TxSetComponentType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TxSetComponentType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + v, n, err := d.DecodeInt() + if err != nil { + return n, fmt.Errorf("decoding TxSetComponentType: %w", err) + } + if _, ok := txSetComponentTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid TxSetComponentType enum value", v) + } + *e = TxSetComponentType(v) + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TxSetComponentType) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TxSetComponentType) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*TxSetComponentType)(nil) + _ encoding.BinaryUnmarshaler = (*TxSetComponentType)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s TxSetComponentType) xdrType() {} + +var _ xdrType = (*TxSetComponentType)(nil) + +// TxSetComponentTxsMaybeDiscountedFee is an XDR NestedStruct defines as: +// +// struct +// { +// int64* baseFee; +// TransactionEnvelope txs<>; +// } +type TxSetComponentTxsMaybeDiscountedFee struct { + BaseFee *Int64 + Txs []TransactionEnvelope +} + +// EncodeTo encodes this value using the Encoder. +func (s *TxSetComponentTxsMaybeDiscountedFee) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s.Results))); err != nil { + if _, err = e.EncodeBool(s.BaseFee != nil); err != nil { return err } - for i := 0; i < len(s.Results); i++ { - if err = s.Results[i].EncodeTo(e); err != nil { + if s.BaseFee != nil { + if err = (*s.BaseFee).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.Txs))); err != nil { + return err + } + for i := 0; i < len(s.Txs); i++ { + if err = s.Txs[i].EncodeTo(e); err != nil { return err } } return nil } -var _ decoderFrom = (*TransactionResultSet)(nil) +var _ decoderFrom = (*TxSetComponentTxsMaybeDiscountedFee)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TxSetComponentTxsMaybeDiscountedFee) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionResultSet: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TxSetComponentTxsMaybeDiscountedFee: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int + var b bool + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + s.BaseFee = nil + if b { + s.BaseFee = new(Int64) + nTmp, err = s.BaseFee.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultPair: %w", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } - s.Results = nil + s.Txs = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TransactionResultPair: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) } - s.Results = make([]TransactionResultPair, l) + s.Txs = make([]TransactionEnvelope, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Results[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultPair: %w", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } } } @@ -14502,7 +14957,7 @@ func (s *TransactionResultSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionResultSet) MarshalBinary() ([]byte, error) { +func (s TxSetComponentTxsMaybeDiscountedFee) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14510,7 +14965,7 @@ func (s TransactionResultSet) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionResultSet) UnmarshalBinary(inp []byte) error { +func (s *TxSetComponentTxsMaybeDiscountedFee) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14520,83 +14975,81 @@ func (s *TransactionResultSet) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionResultSet)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionResultSet)(nil) + _ encoding.BinaryMarshaler = (*TxSetComponentTxsMaybeDiscountedFee)(nil) + _ encoding.BinaryUnmarshaler = (*TxSetComponentTxsMaybeDiscountedFee)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionResultSet) xdrType() {} +func (s TxSetComponentTxsMaybeDiscountedFee) xdrType() {} -var _ xdrType = (*TransactionResultSet)(nil) +var _ xdrType = (*TxSetComponentTxsMaybeDiscountedFee)(nil) -// TransactionHistoryEntryExt is an XDR NestedUnion defines as: +// TxSetComponent is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// GeneralizedTransactionSet generalizedTxSet; -// } -type TransactionHistoryEntryExt struct { - V int32 - GeneralizedTxSet *GeneralizedTransactionSet +// union TxSetComponent switch (TxSetComponentType type) +// { +// case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE: +// struct +// { +// int64* baseFee; +// TransactionEnvelope txs<>; +// } txsMaybeDiscountedFee; +// }; +type TxSetComponent struct { + Type TxSetComponentType + TxsMaybeDiscountedFee *TxSetComponentTxsMaybeDiscountedFee } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u TransactionHistoryEntryExt) SwitchFieldName() string { - return "V" +func (u TxSetComponent) SwitchFieldName() string { + return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of TransactionHistoryEntryExt -func (u TransactionHistoryEntryExt) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: - return "", true - case 1: - return "GeneralizedTxSet", true +// the value for an instance of TxSetComponent +func (u TxSetComponent) ArmForSwitch(sw int32) (string, bool) { + switch TxSetComponentType(sw) { + case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: + return "TxsMaybeDiscountedFee", true } return "-", false } -// NewTransactionHistoryEntryExt creates a new TransactionHistoryEntryExt. -func NewTransactionHistoryEntryExt(v int32, value interface{}) (result TransactionHistoryEntryExt, err error) { - result.V = v - switch int32(v) { - case 0: - // void - case 1: - tv, ok := value.(GeneralizedTransactionSet) +// NewTxSetComponent creates a new TxSetComponent. +func NewTxSetComponent(aType TxSetComponentType, value interface{}) (result TxSetComponent, err error) { + result.Type = aType + switch TxSetComponentType(aType) { + case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: + tv, ok := value.(TxSetComponentTxsMaybeDiscountedFee) if !ok { - err = errors.New("invalid value, must be GeneralizedTransactionSet") + err = errors.New("invalid value, must be TxSetComponentTxsMaybeDiscountedFee") return } - result.GeneralizedTxSet = &tv + result.TxsMaybeDiscountedFee = &tv } return } -// MustGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, +// MustTxsMaybeDiscountedFee retrieves the TxsMaybeDiscountedFee value from the union, // panicing if the value is not set. -func (u TransactionHistoryEntryExt) MustGeneralizedTxSet() GeneralizedTransactionSet { - val, ok := u.GetGeneralizedTxSet() +func (u TxSetComponent) MustTxsMaybeDiscountedFee() TxSetComponentTxsMaybeDiscountedFee { + val, ok := u.GetTxsMaybeDiscountedFee() if !ok { - panic("arm GeneralizedTxSet is not set") + panic("arm TxsMaybeDiscountedFee is not set") } return val } -// GetGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, +// GetTxsMaybeDiscountedFee retrieves the TxsMaybeDiscountedFee value from the union, // returning ok if the union's switch indicated the value is valid. -func (u TransactionHistoryEntryExt) GetGeneralizedTxSet() (result GeneralizedTransactionSet, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) +func (u TxSetComponent) GetTxsMaybeDiscountedFee() (result TxSetComponentTxsMaybeDiscountedFee, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "GeneralizedTxSet" { - result = *u.GeneralizedTxSet + if armName == "TxsMaybeDiscountedFee" { + result = *u.TxsMaybeDiscountedFee ok = true } @@ -14604,57 +15057,51 @@ func (u TransactionHistoryEntryExt) GetGeneralizedTxSet() (result GeneralizedTra } // EncodeTo encodes this value using the Encoder. -func (u TransactionHistoryEntryExt) EncodeTo(e *xdr.Encoder) error { +func (u TxSetComponent) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { + if err = u.Type.EncodeTo(e); err != nil { return err } - switch int32(u.V) { - case 0: - // Void - return nil - case 1: - if err = (*u.GeneralizedTxSet).EncodeTo(e); err != nil { + switch TxSetComponentType(u.Type) { + case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: + if err = (*u.TxsMaybeDiscountedFee).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionHistoryEntryExt", u.V) + return fmt.Errorf("Type (TxSetComponentType) switch value '%d' is not valid for union TxSetComponent", u.Type) } -var _ decoderFrom = (*TransactionHistoryEntryExt)(nil) +var _ decoderFrom = (*TxSetComponent)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionHistoryEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *TxSetComponent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionHistoryEntryExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TxSetComponent: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding TxSetComponentType: %w", err) } - switch int32(u.V) { - case 0: - // Void - return n, nil - case 1: - u.GeneralizedTxSet = new(GeneralizedTransactionSet) - nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d, maxDepth) + switch TxSetComponentType(u.Type) { + case TxSetComponentTypeTxsetCompTxsMaybeDiscountedFee: + u.TxsMaybeDiscountedFee = new(TxSetComponentTxsMaybeDiscountedFee) + nTmp, err = (*u.TxsMaybeDiscountedFee).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) + return n, fmt.Errorf("decoding TxSetComponentTxsMaybeDiscountedFee: %w", err) } return n, nil } - return n, fmt.Errorf("union TransactionHistoryEntryExt has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union TxSetComponent has invalid Type (TxSetComponentType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionHistoryEntryExt) MarshalBinary() ([]byte, error) { +func (s TxSetComponent) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14662,7 +15109,7 @@ func (s TransactionHistoryEntryExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionHistoryEntryExt) UnmarshalBinary(inp []byte) error { +func (s *TxSetComponent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14672,166 +15119,110 @@ func (s *TransactionHistoryEntryExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionHistoryEntryExt)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntryExt)(nil) + _ encoding.BinaryMarshaler = (*TxSetComponent)(nil) + _ encoding.BinaryUnmarshaler = (*TxSetComponent)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionHistoryEntryExt) xdrType() {} +func (s TxSetComponent) xdrType() {} -var _ xdrType = (*TransactionHistoryEntryExt)(nil) +var _ xdrType = (*TxSetComponent)(nil) -// TransactionHistoryEntry is an XDR Struct defines as: +// TransactionPhase is an XDR Union defines as: // -// struct TransactionHistoryEntry +// union TransactionPhase switch (int v) // { -// uint32 ledgerSeq; -// TransactionSet txSet; -// -// // when v != 0, txSet must be empty -// union switch (int v) -// { -// case 0: -// void; -// case 1: -// GeneralizedTransactionSet generalizedTxSet; -// } -// ext; +// case 0: +// TxSetComponent v0Components<>; // }; -type TransactionHistoryEntry struct { - LedgerSeq Uint32 - TxSet TransactionSet - Ext TransactionHistoryEntryExt -} - -// EncodeTo encodes this value using the Encoder. -func (s *TransactionHistoryEntry) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.LedgerSeq.EncodeTo(e); err != nil { - return err - } - if err = s.TxSet.EncodeTo(e); err != nil { - return err - } - if err = s.Ext.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*TransactionHistoryEntry)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *TransactionHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionHistoryEntry: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionSet: %w", err) - } - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionHistoryEntryExt: %w", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionHistoryEntry) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionHistoryEntry) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*TransactionHistoryEntry)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntry)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s TransactionHistoryEntry) xdrType() {} - -var _ xdrType = (*TransactionHistoryEntry)(nil) - -// TransactionHistoryResultEntryExt is an XDR NestedUnion defines as: -// -// union switch (int v) -// { -// case 0: -// void; -// } -type TransactionHistoryResultEntryExt struct { - V int32 +type TransactionPhase struct { + V int32 + V0Components *[]TxSetComponent } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u TransactionHistoryResultEntryExt) SwitchFieldName() string { +func (u TransactionPhase) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of TransactionHistoryResultEntryExt -func (u TransactionHistoryResultEntryExt) ArmForSwitch(sw int32) (string, bool) { +// the value for an instance of TransactionPhase +func (u TransactionPhase) ArmForSwitch(sw int32) (string, bool) { switch int32(sw) { case 0: - return "", true + return "V0Components", true } return "-", false } -// NewTransactionHistoryResultEntryExt creates a new TransactionHistoryResultEntryExt. -func NewTransactionHistoryResultEntryExt(v int32, value interface{}) (result TransactionHistoryResultEntryExt, err error) { +// NewTransactionPhase creates a new TransactionPhase. +func NewTransactionPhase(v int32, value interface{}) (result TransactionPhase, err error) { result.V = v switch int32(v) { case 0: - // void + tv, ok := value.([]TxSetComponent) + if !ok { + err = errors.New("invalid value, must be []TxSetComponent") + return + } + result.V0Components = &tv + } + return +} + +// MustV0Components retrieves the V0Components value from the union, +// panicing if the value is not set. +func (u TransactionPhase) MustV0Components() []TxSetComponent { + val, ok := u.GetV0Components() + + if !ok { + panic("arm V0Components is not set") + } + + return val +} + +// GetV0Components retrieves the V0Components value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u TransactionPhase) GetV0Components() (result []TxSetComponent, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "V0Components" { + result = *u.V0Components + ok = true } + return } // EncodeTo encodes this value using the Encoder. -func (u TransactionHistoryResultEntryExt) EncodeTo(e *xdr.Encoder) error { +func (u TransactionPhase) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } switch int32(u.V) { case 0: - // Void + if _, err = e.EncodeUint(uint32(len((*u.V0Components)))); err != nil { + return err + } + for i := 0; i < len((*u.V0Components)); i++ { + if err = (*u.V0Components)[i].EncodeTo(e); err != nil { + return err + } + } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionHistoryResultEntryExt", u.V) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionPhase", u.V) } -var _ decoderFrom = (*TransactionHistoryResultEntryExt)(nil) +var _ decoderFrom = (*TransactionPhase)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionHistoryResultEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *TransactionPhase) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionHistoryResultEntryExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionPhase: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -14843,14 +15234,34 @@ func (u *TransactionHistoryResultEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth u } switch int32(u.V) { case 0: - // Void + u.V0Components = new([]TxSetComponent) + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TxSetComponent: %w", err) + } + (*u.V0Components) = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TxSetComponent: length (%d) exceeds remaining input length (%d)", l, il) + } + (*u.V0Components) = make([]TxSetComponent, l) + for i := uint32(0); i < l; i++ { + nTmp, err = (*u.V0Components)[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TxSetComponent: %w", err) + } + } + } return n, nil } - return n, fmt.Errorf("union TransactionHistoryResultEntryExt has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union TransactionPhase has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionHistoryResultEntryExt) MarshalBinary() ([]byte, error) { +func (s TransactionPhase) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14858,7 +15269,7 @@ func (s TransactionHistoryResultEntryExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionHistoryResultEntryExt) UnmarshalBinary(inp []byte) error { +func (s *TransactionPhase) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14868,81 +15279,84 @@ func (s *TransactionHistoryResultEntryExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntryExt)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntryExt)(nil) + _ encoding.BinaryMarshaler = (*TransactionPhase)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionPhase)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionHistoryResultEntryExt) xdrType() {} +func (s TransactionPhase) xdrType() {} -var _ xdrType = (*TransactionHistoryResultEntryExt)(nil) +var _ xdrType = (*TransactionPhase)(nil) -// TransactionHistoryResultEntry is an XDR Struct defines as: +// TransactionSet is an XDR Struct defines as: // -// struct TransactionHistoryResultEntry +// struct TransactionSet // { -// uint32 ledgerSeq; -// TransactionResultSet txResultSet; -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// Hash previousLedgerHash; +// TransactionEnvelope txs<>; // }; -type TransactionHistoryResultEntry struct { - LedgerSeq Uint32 - TxResultSet TransactionResultSet - Ext TransactionHistoryResultEntryExt +type TransactionSet struct { + PreviousLedgerHash Hash + Txs []TransactionEnvelope } // EncodeTo encodes this value using the Encoder. -func (s *TransactionHistoryResultEntry) EncodeTo(e *xdr.Encoder) error { +func (s *TransactionSet) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.LedgerSeq.EncodeTo(e); err != nil { + if err = s.PreviousLedgerHash.EncodeTo(e); err != nil { return err } - if err = s.TxResultSet.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Txs))); err != nil { return err } - if err = s.Ext.EncodeTo(e); err != nil { - return err + for i := 0; i < len(s.Txs); i++ { + if err = s.Txs[i].EncodeTo(e); err != nil { + return err + } } return nil } -var _ decoderFrom = (*TransactionHistoryResultEntry)(nil) +var _ decoderFrom = (*TransactionSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionHistoryResultEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionHistoryResultEntry: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionSet: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) + nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.TxResultSet.DecodeFrom(d, maxDepth) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultSet: %w", err) + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionHistoryResultEntryExt: %w", err) + s.Txs = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionEnvelope: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Txs = make([]TransactionEnvelope, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Txs[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) + } + } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionHistoryResultEntry) MarshalBinary() ([]byte, error) { +func (s TransactionSet) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -14950,7 +15364,7 @@ func (s TransactionHistoryResultEntry) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionHistoryResultEntry) UnmarshalBinary(inp []byte) error { +func (s *TransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -14960,91 +15374,84 @@ func (s *TransactionHistoryResultEntry) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntry)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntry)(nil) + _ encoding.BinaryMarshaler = (*TransactionSet)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionSet)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionHistoryResultEntry) xdrType() {} +func (s TransactionSet) xdrType() {} -var _ xdrType = (*TransactionHistoryResultEntry)(nil) +var _ xdrType = (*TransactionSet)(nil) -// LedgerHeaderHistoryEntryExt is an XDR NestedUnion defines as: +// TransactionSetV1 is an XDR Struct defines as: // -// union switch (int v) -// { -// case 0: -// void; -// } -type LedgerHeaderHistoryEntryExt struct { - V int32 -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u LedgerHeaderHistoryEntryExt) SwitchFieldName() string { - return "V" -} - -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of LedgerHeaderHistoryEntryExt -func (u LedgerHeaderHistoryEntryExt) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: - return "", true - } - return "-", false -} - -// NewLedgerHeaderHistoryEntryExt creates a new LedgerHeaderHistoryEntryExt. -func NewLedgerHeaderHistoryEntryExt(v int32, value interface{}) (result LedgerHeaderHistoryEntryExt, err error) { - result.V = v - switch int32(v) { - case 0: - // void - } - return +// struct TransactionSetV1 +// { +// Hash previousLedgerHash; +// TransactionPhase phases<>; +// }; +type TransactionSetV1 struct { + PreviousLedgerHash Hash + Phases []TransactionPhase } // EncodeTo encodes this value using the Encoder. -func (u LedgerHeaderHistoryEntryExt) EncodeTo(e *xdr.Encoder) error { +func (s *TransactionSetV1) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { + if err = s.PreviousLedgerHash.EncodeTo(e); err != nil { return err } - switch int32(u.V) { - case 0: - // Void - return nil + if _, err = e.EncodeUint(uint32(len(s.Phases))); err != nil { + return err } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerHeaderHistoryEntryExt", u.V) + for i := 0; i < len(s.Phases); i++ { + if err = s.Phases[i].EncodeTo(e); err != nil { + return err + } + } + return nil } -var _ decoderFrom = (*LedgerHeaderHistoryEntryExt)(nil) +var _ decoderFrom = (*TransactionSetV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerHeaderHistoryEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionSetV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerHeaderHistoryEntryExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionSetV1: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = s.PreviousLedgerHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - switch int32(u.V) { - case 0: - // Void - return n, nil + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionPhase: %w", err) } - return n, fmt.Errorf("union LedgerHeaderHistoryEntryExt has invalid V (int32) switch value '%d'", u.V) + s.Phases = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionPhase: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Phases = make([]TransactionPhase, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Phases[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionPhase: %w", err) + } + } + } + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerHeaderHistoryEntryExt) MarshalBinary() ([]byte, error) { +func (s TransactionSetV1) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15052,7 +15459,7 @@ func (s LedgerHeaderHistoryEntryExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerHeaderHistoryEntryExt) UnmarshalBinary(inp []byte) error { +func (s *TransactionSetV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15062,81 +15469,130 @@ func (s *LedgerHeaderHistoryEntryExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerHeaderHistoryEntryExt)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntryExt)(nil) + _ encoding.BinaryMarshaler = (*TransactionSetV1)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionSetV1)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerHeaderHistoryEntryExt) xdrType() {} +func (s TransactionSetV1) xdrType() {} -var _ xdrType = (*LedgerHeaderHistoryEntryExt)(nil) +var _ xdrType = (*TransactionSetV1)(nil) -// LedgerHeaderHistoryEntry is an XDR Struct defines as: +// GeneralizedTransactionSet is an XDR Union defines as: // -// struct LedgerHeaderHistoryEntry +// union GeneralizedTransactionSet switch (int v) // { -// Hash hash; -// LedgerHeader header; -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; +// // We consider the legacy TransactionSet to be v0. +// case 1: +// TransactionSetV1 v1TxSet; // }; -type LedgerHeaderHistoryEntry struct { - Hash Hash - Header LedgerHeader - Ext LedgerHeaderHistoryEntryExt +type GeneralizedTransactionSet struct { + V int32 + V1TxSet *TransactionSetV1 +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u GeneralizedTransactionSet) SwitchFieldName() string { + return "V" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of GeneralizedTransactionSet +func (u GeneralizedTransactionSet) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 1: + return "V1TxSet", true + } + return "-", false +} + +// NewGeneralizedTransactionSet creates a new GeneralizedTransactionSet. +func NewGeneralizedTransactionSet(v int32, value interface{}) (result GeneralizedTransactionSet, err error) { + result.V = v + switch int32(v) { + case 1: + tv, ok := value.(TransactionSetV1) + if !ok { + err = errors.New("invalid value, must be TransactionSetV1") + return + } + result.V1TxSet = &tv + } + return +} + +// MustV1TxSet retrieves the V1TxSet value from the union, +// panicing if the value is not set. +func (u GeneralizedTransactionSet) MustV1TxSet() TransactionSetV1 { + val, ok := u.GetV1TxSet() + + if !ok { + panic("arm V1TxSet is not set") + } + + return val +} + +// GetV1TxSet retrieves the V1TxSet value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u GeneralizedTransactionSet) GetV1TxSet() (result TransactionSetV1, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "V1TxSet" { + result = *u.V1TxSet + ok = true + } + + return } // EncodeTo encodes this value using the Encoder. -func (s *LedgerHeaderHistoryEntry) EncodeTo(e *xdr.Encoder) error { +func (u GeneralizedTransactionSet) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Hash.EncodeTo(e); err != nil { - return err - } - if err = s.Header.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } - if err = s.Ext.EncodeTo(e); err != nil { - return err + switch int32(u.V) { + case 1: + if err = (*u.V1TxSet).EncodeTo(e); err != nil { + return err + } + return nil } - return nil + return fmt.Errorf("V (int32) switch value '%d' is not valid for union GeneralizedTransactionSet", u.V) } -var _ decoderFrom = (*LedgerHeaderHistoryEntry)(nil) +var _ decoderFrom = (*GeneralizedTransactionSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerHeaderHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *GeneralizedTransactionSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding GeneralizedTransactionSet: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Hash.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - nTmp, err = s.Header.DecodeFrom(d, maxDepth) + u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerHeader: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntryExt: %w", err) + switch int32(u.V) { + case 1: + u.V1TxSet = new(TransactionSetV1) + nTmp, err = (*u.V1TxSet).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionSetV1: %w", err) + } + return n, nil } - return n, nil + return n, fmt.Errorf("union GeneralizedTransactionSet has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerHeaderHistoryEntry) MarshalBinary() ([]byte, error) { +func (s GeneralizedTransactionSet) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15144,7 +15600,7 @@ func (s LedgerHeaderHistoryEntry) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerHeaderHistoryEntry) UnmarshalBinary(inp []byte) error { +func (s *GeneralizedTransactionSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15154,84 +15610,64 @@ func (s *LedgerHeaderHistoryEntry) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerHeaderHistoryEntry)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntry)(nil) + _ encoding.BinaryMarshaler = (*GeneralizedTransactionSet)(nil) + _ encoding.BinaryUnmarshaler = (*GeneralizedTransactionSet)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerHeaderHistoryEntry) xdrType() {} +func (s GeneralizedTransactionSet) xdrType() {} -var _ xdrType = (*LedgerHeaderHistoryEntry)(nil) +var _ xdrType = (*GeneralizedTransactionSet)(nil) -// LedgerScpMessages is an XDR Struct defines as: +// TransactionResultPair is an XDR Struct defines as: // -// struct LedgerSCPMessages +// struct TransactionResultPair // { -// uint32 ledgerSeq; -// SCPEnvelope messages<>; +// Hash transactionHash; +// TransactionResult result; // result for the transaction // }; -type LedgerScpMessages struct { - LedgerSeq Uint32 - Messages []ScpEnvelope +type TransactionResultPair struct { + TransactionHash Hash + Result TransactionResult } // EncodeTo encodes this value using the Encoder. -func (s *LedgerScpMessages) EncodeTo(e *xdr.Encoder) error { +func (s *TransactionResultPair) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.LedgerSeq.EncodeTo(e); err != nil { + if err = s.TransactionHash.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Messages))); err != nil { + if err = s.Result.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Messages); i++ { - if err = s.Messages[i].EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*LedgerScpMessages)(nil) +var _ decoderFrom = (*TransactionResultPair)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerScpMessages) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionResultPair) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerScpMessages: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionResultPair: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) + nTmp, err = s.TransactionHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.Result.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %w", err) - } - s.Messages = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Messages = make([]ScpEnvelope, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Messages[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %w", err) - } - } + return n, fmt.Errorf("decoding TransactionResult: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerScpMessages) MarshalBinary() ([]byte, error) { +func (s TransactionResultPair) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15239,7 +15675,7 @@ func (s LedgerScpMessages) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerScpMessages) UnmarshalBinary(inp []byte) error { +func (s *TransactionResultPair) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15249,50 +15685,45 @@ func (s *LedgerScpMessages) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerScpMessages)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerScpMessages)(nil) + _ encoding.BinaryMarshaler = (*TransactionResultPair)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionResultPair)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerScpMessages) xdrType() {} +func (s TransactionResultPair) xdrType() {} -var _ xdrType = (*LedgerScpMessages)(nil) +var _ xdrType = (*TransactionResultPair)(nil) -// ScpHistoryEntryV0 is an XDR Struct defines as: +// TransactionResultSet is an XDR Struct defines as: // -// struct SCPHistoryEntryV0 +// struct TransactionResultSet // { -// SCPQuorumSet quorumSets<>; // additional quorum sets used by ledgerMessages -// LedgerSCPMessages ledgerMessages; +// TransactionResultPair results<>; // }; -type ScpHistoryEntryV0 struct { - QuorumSets []ScpQuorumSet - LedgerMessages LedgerScpMessages +type TransactionResultSet struct { + Results []TransactionResultPair } // EncodeTo encodes this value using the Encoder. -func (s *ScpHistoryEntryV0) EncodeTo(e *xdr.Encoder) error { +func (s *TransactionResultSet) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s.QuorumSets))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Results))); err != nil { return err } - for i := 0; i < len(s.QuorumSets); i++ { - if err = s.QuorumSets[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.Results); i++ { + if err = s.Results[i].EncodeTo(e); err != nil { return err } } - if err = s.LedgerMessages.EncodeTo(e); err != nil { - return err - } return nil } -var _ decoderFrom = (*ScpHistoryEntryV0)(nil) +var _ decoderFrom = (*TransactionResultSet)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ScpHistoryEntryV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionResultSet) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ScpHistoryEntryV0: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionResultSet: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -15301,32 +15732,27 @@ func (s *ScpHistoryEntryV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) + return n, fmt.Errorf("decoding TransactionResultPair: %w", err) } - s.QuorumSets = nil + s.Results = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding TransactionResultPair: length (%d) exceeds remaining input length (%d)", l, il) } - s.QuorumSets = make([]ScpQuorumSet, l) + s.Results = make([]TransactionResultPair, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Results[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) + return n, fmt.Errorf("decoding TransactionResultPair: %w", err) } } } - nTmp, err = s.LedgerMessages.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerScpMessages: %w", err) - } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ScpHistoryEntryV0) MarshalBinary() ([]byte, error) { +func (s TransactionResultSet) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15334,7 +15760,7 @@ func (s ScpHistoryEntryV0) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScpHistoryEntryV0) UnmarshalBinary(inp []byte) error { +func (s *TransactionResultSet) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15344,77 +15770,83 @@ func (s *ScpHistoryEntryV0) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ScpHistoryEntryV0)(nil) - _ encoding.BinaryUnmarshaler = (*ScpHistoryEntryV0)(nil) + _ encoding.BinaryMarshaler = (*TransactionResultSet)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionResultSet)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ScpHistoryEntryV0) xdrType() {} +func (s TransactionResultSet) xdrType() {} -var _ xdrType = (*ScpHistoryEntryV0)(nil) +var _ xdrType = (*TransactionResultSet)(nil) -// ScpHistoryEntry is an XDR Union defines as: +// TransactionHistoryEntryExt is an XDR NestedUnion defines as: // -// union SCPHistoryEntry switch (int v) -// { -// case 0: -// SCPHistoryEntryV0 v0; -// }; -type ScpHistoryEntry struct { - V int32 - V0 *ScpHistoryEntryV0 +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// GeneralizedTransactionSet generalizedTxSet; +// } +type TransactionHistoryEntryExt struct { + V int32 + GeneralizedTxSet *GeneralizedTransactionSet } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u ScpHistoryEntry) SwitchFieldName() string { +func (u TransactionHistoryEntryExt) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of ScpHistoryEntry -func (u ScpHistoryEntry) ArmForSwitch(sw int32) (string, bool) { +// the value for an instance of TransactionHistoryEntryExt +func (u TransactionHistoryEntryExt) ArmForSwitch(sw int32) (string, bool) { switch int32(sw) { case 0: - return "V0", true + return "", true + case 1: + return "GeneralizedTxSet", true } return "-", false } -// NewScpHistoryEntry creates a new ScpHistoryEntry. -func NewScpHistoryEntry(v int32, value interface{}) (result ScpHistoryEntry, err error) { +// NewTransactionHistoryEntryExt creates a new TransactionHistoryEntryExt. +func NewTransactionHistoryEntryExt(v int32, value interface{}) (result TransactionHistoryEntryExt, err error) { result.V = v switch int32(v) { case 0: - tv, ok := value.(ScpHistoryEntryV0) + // void + case 1: + tv, ok := value.(GeneralizedTransactionSet) if !ok { - err = errors.New("invalid value, must be ScpHistoryEntryV0") + err = errors.New("invalid value, must be GeneralizedTransactionSet") return } - result.V0 = &tv + result.GeneralizedTxSet = &tv } return } -// MustV0 retrieves the V0 value from the union, +// MustGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, // panicing if the value is not set. -func (u ScpHistoryEntry) MustV0() ScpHistoryEntryV0 { - val, ok := u.GetV0() +func (u TransactionHistoryEntryExt) MustGeneralizedTxSet() GeneralizedTransactionSet { + val, ok := u.GetGeneralizedTxSet() if !ok { - panic("arm V0 is not set") + panic("arm GeneralizedTxSet is not set") } return val } -// GetV0 retrieves the V0 value from the union, +// GetGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ScpHistoryEntry) GetV0() (result ScpHistoryEntryV0, ok bool) { +func (u TransactionHistoryEntryExt) GetGeneralizedTxSet() (result GeneralizedTransactionSet, ok bool) { armName, _ := u.ArmForSwitch(int32(u.V)) - if armName == "V0" { - result = *u.V0 + if armName == "GeneralizedTxSet" { + result = *u.GeneralizedTxSet ok = true } @@ -15422,27 +15854,30 @@ func (u ScpHistoryEntry) GetV0() (result ScpHistoryEntryV0, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u ScpHistoryEntry) EncodeTo(e *xdr.Encoder) error { +func (u TransactionHistoryEntryExt) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } switch int32(u.V) { case 0: - if err = (*u.V0).EncodeTo(e); err != nil { + // Void + return nil + case 1: + if err = (*u.GeneralizedTxSet).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union ScpHistoryEntry", u.V) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionHistoryEntryExt", u.V) } -var _ decoderFrom = (*ScpHistoryEntry)(nil) +var _ decoderFrom = (*TransactionHistoryEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScpHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *TransactionHistoryEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ScpHistoryEntry: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionHistoryEntryExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -15454,19 +15889,22 @@ func (u *ScpHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } switch int32(u.V) { case 0: - u.V0 = new(ScpHistoryEntryV0) - nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) + // Void + return n, nil + case 1: + u.GeneralizedTxSet = new(GeneralizedTransactionSet) + nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntryV0: %w", err) + return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) } return n, nil } - return n, fmt.Errorf("union ScpHistoryEntry has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union TransactionHistoryEntryExt has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ScpHistoryEntry) MarshalBinary() ([]byte, error) { +func (s TransactionHistoryEntryExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15474,7 +15912,7 @@ func (s ScpHistoryEntry) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScpHistoryEntry) UnmarshalBinary(inp []byte) error { +func (s *TransactionHistoryEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15484,83 +15922,83 @@ func (s *ScpHistoryEntry) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ScpHistoryEntry)(nil) - _ encoding.BinaryUnmarshaler = (*ScpHistoryEntry)(nil) + _ encoding.BinaryMarshaler = (*TransactionHistoryEntryExt)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntryExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ScpHistoryEntry) xdrType() {} +func (s TransactionHistoryEntryExt) xdrType() {} -var _ xdrType = (*ScpHistoryEntry)(nil) +var _ xdrType = (*TransactionHistoryEntryExt)(nil) -// LedgerEntryChangeType is an XDR Enum defines as: +// TransactionHistoryEntry is an XDR Struct defines as: // -// enum LedgerEntryChangeType +// struct TransactionHistoryEntry // { -// LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger -// LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger -// LEDGER_ENTRY_REMOVED = 2, // entry was removed from the ledger -// LEDGER_ENTRY_STATE = 3 // value of the entry +// uint32 ledgerSeq; +// TransactionSet txSet; +// +// // when v != 0, txSet must be empty +// union switch (int v) +// { +// case 0: +// void; +// case 1: +// GeneralizedTransactionSet generalizedTxSet; +// } +// ext; // }; -type LedgerEntryChangeType int32 - -const ( - LedgerEntryChangeTypeLedgerEntryCreated LedgerEntryChangeType = 0 - LedgerEntryChangeTypeLedgerEntryUpdated LedgerEntryChangeType = 1 - LedgerEntryChangeTypeLedgerEntryRemoved LedgerEntryChangeType = 2 - LedgerEntryChangeTypeLedgerEntryState LedgerEntryChangeType = 3 -) - -var ledgerEntryChangeTypeMap = map[int32]string{ - 0: "LedgerEntryChangeTypeLedgerEntryCreated", - 1: "LedgerEntryChangeTypeLedgerEntryUpdated", - 2: "LedgerEntryChangeTypeLedgerEntryRemoved", - 3: "LedgerEntryChangeTypeLedgerEntryState", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for LedgerEntryChangeType -func (e LedgerEntryChangeType) ValidEnum(v int32) bool { - _, ok := ledgerEntryChangeTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e LedgerEntryChangeType) String() string { - name, _ := ledgerEntryChangeTypeMap[int32(e)] - return name +type TransactionHistoryEntry struct { + LedgerSeq Uint32 + TxSet TransactionSet + Ext TransactionHistoryEntryExt } // EncodeTo encodes this value using the Encoder. -func (e LedgerEntryChangeType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := ledgerEntryChangeTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid LedgerEntryChangeType enum value", e) +func (s *TransactionHistoryEntry) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.LedgerSeq.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + if err = s.TxSet.EncodeTo(e); err != nil { + return err + } + if err = s.Ext.EncodeTo(e); err != nil { + return err + } + return nil } -var _ decoderFrom = (*LedgerEntryChangeType)(nil) +var _ decoderFrom = (*TransactionHistoryEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *LedgerEntryChangeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerEntryChangeType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionHistoryEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChangeType: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - if _, ok := ledgerEntryChangeTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid LedgerEntryChangeType enum value", v) + nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionSet: %w", err) + } + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionHistoryEntryExt: %w", err) } - *e = LedgerEntryChangeType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerEntryChangeType) MarshalBinary() ([]byte, error) { +func (s TransactionHistoryEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15568,7 +16006,7 @@ func (s LedgerEntryChangeType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerEntryChangeType) UnmarshalBinary(inp []byte) error { +func (s *TransactionHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15578,279 +16016,91 @@ func (s *LedgerEntryChangeType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerEntryChangeType)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerEntryChangeType)(nil) + _ encoding.BinaryMarshaler = (*TransactionHistoryEntry)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerEntryChangeType) xdrType() {} +func (s TransactionHistoryEntry) xdrType() {} -var _ xdrType = (*LedgerEntryChangeType)(nil) +var _ xdrType = (*TransactionHistoryEntry)(nil) -// LedgerEntryChange is an XDR Union defines as: +// TransactionHistoryResultEntryExt is an XDR NestedUnion defines as: // -// union LedgerEntryChange switch (LedgerEntryChangeType type) -// { -// case LEDGER_ENTRY_CREATED: -// LedgerEntry created; -// case LEDGER_ENTRY_UPDATED: -// LedgerEntry updated; -// case LEDGER_ENTRY_REMOVED: -// LedgerKey removed; -// case LEDGER_ENTRY_STATE: -// LedgerEntry state; -// }; -type LedgerEntryChange struct { - Type LedgerEntryChangeType - Created *LedgerEntry - Updated *LedgerEntry - Removed *LedgerKey - State *LedgerEntry +// union switch (int v) +// { +// case 0: +// void; +// } +type TransactionHistoryResultEntryExt struct { + V int32 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u LedgerEntryChange) SwitchFieldName() string { - return "Type" +func (u TransactionHistoryResultEntryExt) SwitchFieldName() string { + return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of LedgerEntryChange -func (u LedgerEntryChange) ArmForSwitch(sw int32) (string, bool) { - switch LedgerEntryChangeType(sw) { - case LedgerEntryChangeTypeLedgerEntryCreated: - return "Created", true - case LedgerEntryChangeTypeLedgerEntryUpdated: - return "Updated", true - case LedgerEntryChangeTypeLedgerEntryRemoved: - return "Removed", true - case LedgerEntryChangeTypeLedgerEntryState: - return "State", true +// the value for an instance of TransactionHistoryResultEntryExt +func (u TransactionHistoryResultEntryExt) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: + return "", true } return "-", false } -// NewLedgerEntryChange creates a new LedgerEntryChange. -func NewLedgerEntryChange(aType LedgerEntryChangeType, value interface{}) (result LedgerEntryChange, err error) { - result.Type = aType - switch LedgerEntryChangeType(aType) { - case LedgerEntryChangeTypeLedgerEntryCreated: - tv, ok := value.(LedgerEntry) - if !ok { - err = errors.New("invalid value, must be LedgerEntry") - return - } - result.Created = &tv - case LedgerEntryChangeTypeLedgerEntryUpdated: - tv, ok := value.(LedgerEntry) - if !ok { - err = errors.New("invalid value, must be LedgerEntry") - return - } - result.Updated = &tv - case LedgerEntryChangeTypeLedgerEntryRemoved: - tv, ok := value.(LedgerKey) - if !ok { - err = errors.New("invalid value, must be LedgerKey") - return - } - result.Removed = &tv - case LedgerEntryChangeTypeLedgerEntryState: - tv, ok := value.(LedgerEntry) - if !ok { - err = errors.New("invalid value, must be LedgerEntry") - return - } - result.State = &tv - } - return -} - -// MustCreated retrieves the Created value from the union, -// panicing if the value is not set. -func (u LedgerEntryChange) MustCreated() LedgerEntry { - val, ok := u.GetCreated() - - if !ok { - panic("arm Created is not set") - } - - return val -} - -// GetCreated retrieves the Created value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerEntryChange) GetCreated() (result LedgerEntry, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Created" { - result = *u.Created - ok = true - } - - return -} - -// MustUpdated retrieves the Updated value from the union, -// panicing if the value is not set. -func (u LedgerEntryChange) MustUpdated() LedgerEntry { - val, ok := u.GetUpdated() - - if !ok { - panic("arm Updated is not set") - } - - return val -} - -// GetUpdated retrieves the Updated value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerEntryChange) GetUpdated() (result LedgerEntry, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Updated" { - result = *u.Updated - ok = true - } - - return -} - -// MustRemoved retrieves the Removed value from the union, -// panicing if the value is not set. -func (u LedgerEntryChange) MustRemoved() LedgerKey { - val, ok := u.GetRemoved() - - if !ok { - panic("arm Removed is not set") - } - - return val -} - -// GetRemoved retrieves the Removed value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerEntryChange) GetRemoved() (result LedgerKey, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Removed" { - result = *u.Removed - ok = true - } - - return -} - -// MustState retrieves the State value from the union, -// panicing if the value is not set. -func (u LedgerEntryChange) MustState() LedgerEntry { - val, ok := u.GetState() - - if !ok { - panic("arm State is not set") - } - - return val -} - -// GetState retrieves the State value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u LedgerEntryChange) GetState() (result LedgerEntry, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "State" { - result = *u.State - ok = true +// NewTransactionHistoryResultEntryExt creates a new TransactionHistoryResultEntryExt. +func NewTransactionHistoryResultEntryExt(v int32, value interface{}) (result TransactionHistoryResultEntryExt, err error) { + result.V = v + switch int32(v) { + case 0: + // void } - return } // EncodeTo encodes this value using the Encoder. -func (u LedgerEntryChange) EncodeTo(e *xdr.Encoder) error { +func (u TransactionHistoryResultEntryExt) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } - switch LedgerEntryChangeType(u.Type) { - case LedgerEntryChangeTypeLedgerEntryCreated: - if err = (*u.Created).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerEntryChangeTypeLedgerEntryUpdated: - if err = (*u.Updated).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerEntryChangeTypeLedgerEntryRemoved: - if err = (*u.Removed).EncodeTo(e); err != nil { - return err - } - return nil - case LedgerEntryChangeTypeLedgerEntryState: - if err = (*u.State).EncodeTo(e); err != nil { - return err - } + switch int32(u.V) { + case 0: + // Void return nil } - return fmt.Errorf("Type (LedgerEntryChangeType) switch value '%d' is not valid for union LedgerEntryChange", u.Type) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionHistoryResultEntryExt", u.V) } -var _ decoderFrom = (*LedgerEntryChange)(nil) +var _ decoderFrom = (*TransactionHistoryResultEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerEntryChange) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *TransactionHistoryResultEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerEntryChange: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionHistoryResultEntryExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChangeType: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - switch LedgerEntryChangeType(u.Type) { - case LedgerEntryChangeTypeLedgerEntryCreated: - u.Created = new(LedgerEntry) - nTmp, err = (*u.Created).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %w", err) - } - return n, nil - case LedgerEntryChangeTypeLedgerEntryUpdated: - u.Updated = new(LedgerEntry) - nTmp, err = (*u.Updated).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %w", err) - } - return n, nil - case LedgerEntryChangeTypeLedgerEntryRemoved: - u.Removed = new(LedgerKey) - nTmp, err = (*u.Removed).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) - } - return n, nil - case LedgerEntryChangeTypeLedgerEntryState: - u.State = new(LedgerEntry) - nTmp, err = (*u.State).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %w", err) - } + switch int32(u.V) { + case 0: + // Void return n, nil } - return n, fmt.Errorf("union LedgerEntryChange has invalid Type (LedgerEntryChangeType) switch value '%d'", u.Type) + return n, fmt.Errorf("union TransactionHistoryResultEntryExt has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerEntryChange) MarshalBinary() ([]byte, error) { +func (s TransactionHistoryResultEntryExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15858,7 +16108,7 @@ func (s LedgerEntryChange) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerEntryChange) UnmarshalBinary(inp []byte) error { +func (s *TransactionHistoryResultEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15868,69 +16118,81 @@ func (s *LedgerEntryChange) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerEntryChange)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerEntryChange)(nil) + _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntryExt)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntryExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerEntryChange) xdrType() {} +func (s TransactionHistoryResultEntryExt) xdrType() {} -var _ xdrType = (*LedgerEntryChange)(nil) +var _ xdrType = (*TransactionHistoryResultEntryExt)(nil) -// LedgerEntryChanges is an XDR Typedef defines as: +// TransactionHistoryResultEntry is an XDR Struct defines as: // -// typedef LedgerEntryChange LedgerEntryChanges<>; -type LedgerEntryChanges []LedgerEntryChange +// struct TransactionHistoryResultEntry +// { +// uint32 ledgerSeq; +// TransactionResultSet txResultSet; +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; +// }; +type TransactionHistoryResultEntry struct { + LedgerSeq Uint32 + TxResultSet TransactionResultSet + Ext TransactionHistoryResultEntryExt +} // EncodeTo encodes this value using the Encoder. -func (s LedgerEntryChanges) EncodeTo(e *xdr.Encoder) error { +func (s *TransactionHistoryResultEntry) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s))); err != nil { + if err = s.LedgerSeq.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s); i++ { - if err = s[i].EncodeTo(e); err != nil { - return err - } + if err = s.TxResultSet.EncodeTo(e); err != nil { + return err + } + if err = s.Ext.EncodeTo(e); err != nil { + return err } return nil } -var _ decoderFrom = (*LedgerEntryChanges)(nil) +var _ decoderFrom = (*TransactionHistoryResultEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerEntryChanges) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionHistoryResultEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerEntryChanges: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionHistoryResultEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChange: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - (*s) = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding LedgerEntryChange: length (%d) exceeds remaining input length (%d)", l, il) - } - (*s) = make([]LedgerEntryChange, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChange: %w", err) - } - } + nTmp, err = s.TxResultSet.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionResultSet: %w", err) + } + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionHistoryResultEntryExt: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerEntryChanges) MarshalBinary() ([]byte, error) { +func (s TransactionHistoryResultEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -15938,7 +16200,7 @@ func (s LedgerEntryChanges) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerEntryChanges) UnmarshalBinary(inp []byte) error { +func (s *TransactionHistoryResultEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -15948,54 +16210,91 @@ func (s *LedgerEntryChanges) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerEntryChanges)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerEntryChanges)(nil) + _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntry)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerEntryChanges) xdrType() {} +func (s TransactionHistoryResultEntry) xdrType() {} -var _ xdrType = (*LedgerEntryChanges)(nil) +var _ xdrType = (*TransactionHistoryResultEntry)(nil) -// OperationMeta is an XDR Struct defines as: +// LedgerHeaderHistoryEntryExt is an XDR NestedUnion defines as: // -// struct OperationMeta -// { -// LedgerEntryChanges changes; -// }; -type OperationMeta struct { - Changes LedgerEntryChanges -} - -// EncodeTo encodes this value using the Encoder. -func (s *OperationMeta) EncodeTo(e *xdr.Encoder) error { +// union switch (int v) +// { +// case 0: +// void; +// } +type LedgerHeaderHistoryEntryExt struct { + V int32 +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u LedgerHeaderHistoryEntryExt) SwitchFieldName() string { + return "V" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of LedgerHeaderHistoryEntryExt +func (u LedgerHeaderHistoryEntryExt) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: + return "", true + } + return "-", false +} + +// NewLedgerHeaderHistoryEntryExt creates a new LedgerHeaderHistoryEntryExt. +func NewLedgerHeaderHistoryEntryExt(v int32, value interface{}) (result LedgerHeaderHistoryEntryExt, err error) { + result.V = v + switch int32(v) { + case 0: + // void + } + return +} + +// EncodeTo encodes this value using the Encoder. +func (u LedgerHeaderHistoryEntryExt) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Changes.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } - return nil + switch int32(u.V) { + case 0: + // Void + return nil + } + return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerHeaderHistoryEntryExt", u.V) } -var _ decoderFrom = (*OperationMeta)(nil) +var _ decoderFrom = (*LedgerHeaderHistoryEntryExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *OperationMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *LedgerHeaderHistoryEntryExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding OperationMeta: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerHeaderHistoryEntryExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Changes.DecodeFrom(d, maxDepth) + u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - return n, nil + switch int32(u.V) { + case 0: + // Void + return n, nil + } + return n, fmt.Errorf("union LedgerHeaderHistoryEntryExt has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s OperationMeta) MarshalBinary() ([]byte, error) { +func (s LedgerHeaderHistoryEntryExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16003,7 +16302,7 @@ func (s OperationMeta) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *OperationMeta) UnmarshalBinary(inp []byte) error { +func (s *LedgerHeaderHistoryEntryExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16013,84 +16312,81 @@ func (s *OperationMeta) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*OperationMeta)(nil) - _ encoding.BinaryUnmarshaler = (*OperationMeta)(nil) + _ encoding.BinaryMarshaler = (*LedgerHeaderHistoryEntryExt)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntryExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s OperationMeta) xdrType() {} +func (s LedgerHeaderHistoryEntryExt) xdrType() {} -var _ xdrType = (*OperationMeta)(nil) +var _ xdrType = (*LedgerHeaderHistoryEntryExt)(nil) -// TransactionMetaV1 is an XDR Struct defines as: +// LedgerHeaderHistoryEntry is an XDR Struct defines as: // -// struct TransactionMetaV1 +// struct LedgerHeaderHistoryEntry // { -// LedgerEntryChanges txChanges; // tx level changes if any -// OperationMeta operations<>; // meta for each operation +// Hash hash; +// LedgerHeader header; +// +// // reserved for future use +// union switch (int v) +// { +// case 0: +// void; +// } +// ext; // }; -type TransactionMetaV1 struct { - TxChanges LedgerEntryChanges - Operations []OperationMeta +type LedgerHeaderHistoryEntry struct { + Hash Hash + Header LedgerHeader + Ext LedgerHeaderHistoryEntryExt } // EncodeTo encodes this value using the Encoder. -func (s *TransactionMetaV1) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerHeaderHistoryEntry) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.TxChanges.EncodeTo(e); err != nil { + if err = s.Hash.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Operations))); err != nil { + if err = s.Header.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Operations); i++ { - if err = s.Operations[i].EncodeTo(e); err != nil { - return err - } + if err = s.Ext.EncodeTo(e); err != nil { + return err } return nil } -var _ decoderFrom = (*TransactionMetaV1)(nil) +var _ decoderFrom = (*LedgerHeaderHistoryEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerHeaderHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionMetaV1: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxChanges.DecodeFrom(d, maxDepth) + nTmp, err = s.Hash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.Header.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) + return n, fmt.Errorf("decoding LedgerHeader: %w", err) } - s.Operations = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Operations = make([]OperationMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) - } - } + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerHeaderHistoryEntryExt: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionMetaV1) MarshalBinary() ([]byte, error) { +func (s LedgerHeaderHistoryEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16098,7 +16394,7 @@ func (s TransactionMetaV1) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionMetaV1) UnmarshalBinary(inp []byte) error { +func (s *LedgerHeaderHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16108,96 +16404,84 @@ func (s *TransactionMetaV1) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionMetaV1)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionMetaV1)(nil) + _ encoding.BinaryMarshaler = (*LedgerHeaderHistoryEntry)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionMetaV1) xdrType() {} +func (s LedgerHeaderHistoryEntry) xdrType() {} -var _ xdrType = (*TransactionMetaV1)(nil) +var _ xdrType = (*LedgerHeaderHistoryEntry)(nil) -// TransactionMetaV2 is an XDR Struct defines as: +// LedgerScpMessages is an XDR Struct defines as: // -// struct TransactionMetaV2 +// struct LedgerSCPMessages // { -// LedgerEntryChanges txChangesBefore; // tx level changes before operations -// // are applied if any -// OperationMeta operations<>; // meta for each operation -// LedgerEntryChanges txChangesAfter; // tx level changes after operations are -// // applied if any +// uint32 ledgerSeq; +// SCPEnvelope messages<>; // }; -type TransactionMetaV2 struct { - TxChangesBefore LedgerEntryChanges - Operations []OperationMeta - TxChangesAfter LedgerEntryChanges +type LedgerScpMessages struct { + LedgerSeq Uint32 + Messages []ScpEnvelope } // EncodeTo encodes this value using the Encoder. -func (s *TransactionMetaV2) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerScpMessages) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.TxChangesBefore.EncodeTo(e); err != nil { + if err = s.LedgerSeq.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Operations))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Messages))); err != nil { return err } - for i := 0; i < len(s.Operations); i++ { - if err = s.Operations[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.Messages); i++ { + if err = s.Messages[i].EncodeTo(e); err != nil { return err } } - if err = s.TxChangesAfter.EncodeTo(e); err != nil { - return err - } return nil } -var _ decoderFrom = (*TransactionMetaV2)(nil) +var _ decoderFrom = (*LedgerScpMessages)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionMetaV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerScpMessages) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionMetaV2: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerScpMessages: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxChangesBefore.DecodeFrom(d, maxDepth) + nTmp, err = s.LedgerSeq.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } - s.Operations = nil + s.Messages = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding ScpEnvelope: length (%d) exceeds remaining input length (%d)", l, il) } - s.Operations = make([]OperationMeta, l) + s.Messages = make([]ScpEnvelope, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Messages[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) } } } - nTmp, err = s.TxChangesAfter.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) - } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionMetaV2) MarshalBinary() ([]byte, error) { +func (s LedgerScpMessages) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16205,7 +16489,7 @@ func (s TransactionMetaV2) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionMetaV2) UnmarshalBinary(inp []byte) error { +func (s *LedgerScpMessages) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16215,141 +16499,50 @@ func (s *TransactionMetaV2) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionMetaV2)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionMetaV2)(nil) + _ encoding.BinaryMarshaler = (*LedgerScpMessages)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerScpMessages)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionMetaV2) xdrType() {} +func (s LedgerScpMessages) xdrType() {} -var _ xdrType = (*TransactionMetaV2)(nil) +var _ xdrType = (*LedgerScpMessages)(nil) -// ContractEventType is an XDR Enum defines as: +// ScpHistoryEntryV0 is an XDR Struct defines as: // -// enum ContractEventType +// struct SCPHistoryEntryV0 // { -// SYSTEM = 0, -// CONTRACT = 1, -// DIAGNOSTIC = 2 +// SCPQuorumSet quorumSets<>; // additional quorum sets used by ledgerMessages +// LedgerSCPMessages ledgerMessages; // }; -type ContractEventType int32 - -const ( - ContractEventTypeSystem ContractEventType = 0 - ContractEventTypeContract ContractEventType = 1 - ContractEventTypeDiagnostic ContractEventType = 2 -) - -var contractEventTypeMap = map[int32]string{ - 0: "ContractEventTypeSystem", - 1: "ContractEventTypeContract", - 2: "ContractEventTypeDiagnostic", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ContractEventType -func (e ContractEventType) ValidEnum(v int32) bool { - _, ok := contractEventTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e ContractEventType) String() string { - name, _ := contractEventTypeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ContractEventType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := contractEventTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ContractEventType enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ContractEventType)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ContractEventType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding ContractEventType: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ContractEventType: %w", err) - } - if _, ok := contractEventTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ContractEventType enum value", v) - } - *e = ContractEventType(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractEventType) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractEventType) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ContractEventType)(nil) - _ encoding.BinaryUnmarshaler = (*ContractEventType)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s ContractEventType) xdrType() {} - -var _ xdrType = (*ContractEventType)(nil) - -// ContractEventV0 is an XDR NestedStruct defines as: -// -// struct -// { -// SCVal topics<>; -// SCVal data; -// } -type ContractEventV0 struct { - Topics []ScVal - Data ScVal +type ScpHistoryEntryV0 struct { + QuorumSets []ScpQuorumSet + LedgerMessages LedgerScpMessages } // EncodeTo encodes this value using the Encoder. -func (s *ContractEventV0) EncodeTo(e *xdr.Encoder) error { +func (s *ScpHistoryEntryV0) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s.Topics))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.QuorumSets))); err != nil { return err } - for i := 0; i < len(s.Topics); i++ { - if err = s.Topics[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.QuorumSets); i++ { + if err = s.QuorumSets[i].EncodeTo(e); err != nil { return err } } - if err = s.Data.EncodeTo(e); err != nil { + if err = s.LedgerMessages.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*ContractEventV0)(nil) +var _ decoderFrom = (*ScpHistoryEntryV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractEventV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ScpHistoryEntryV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ContractEventV0: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ScpHistoryEntryV0: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -16358,32 +16551,32 @@ func (s *ContractEventV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } - s.Topics = nil + s.QuorumSets = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding ScpQuorumSet: length (%d) exceeds remaining input length (%d)", l, il) } - s.Topics = make([]ScVal, l) + s.QuorumSets = make([]ScpQuorumSet, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Topics[i].DecodeFrom(d, maxDepth) + nTmp, err = s.QuorumSets[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) } } } - nTmp, err = s.Data.DecodeFrom(d, maxDepth) + nTmp, err = s.LedgerMessages.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) + return n, fmt.Errorf("decoding LedgerScpMessages: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractEventV0) MarshalBinary() ([]byte, error) { +func (s ScpHistoryEntryV0) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16391,7 +16584,7 @@ func (s ContractEventV0) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractEventV0) UnmarshalBinary(inp []byte) error { +func (s *ScpHistoryEntryV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16401,40 +16594,36 @@ func (s *ContractEventV0) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractEventV0)(nil) - _ encoding.BinaryUnmarshaler = (*ContractEventV0)(nil) + _ encoding.BinaryMarshaler = (*ScpHistoryEntryV0)(nil) + _ encoding.BinaryUnmarshaler = (*ScpHistoryEntryV0)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ContractEventV0) xdrType() {} +func (s ScpHistoryEntryV0) xdrType() {} -var _ xdrType = (*ContractEventV0)(nil) +var _ xdrType = (*ScpHistoryEntryV0)(nil) -// ContractEventBody is an XDR NestedUnion defines as: +// ScpHistoryEntry is an XDR Union defines as: // -// union switch (int v) -// { -// case 0: -// struct -// { -// SCVal topics<>; -// SCVal data; -// } v0; -// } -type ContractEventBody struct { +// union SCPHistoryEntry switch (int v) +// { +// case 0: +// SCPHistoryEntryV0 v0; +// }; +type ScpHistoryEntry struct { V int32 - V0 *ContractEventV0 + V0 *ScpHistoryEntryV0 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u ContractEventBody) SwitchFieldName() string { +func (u ScpHistoryEntry) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of ContractEventBody -func (u ContractEventBody) ArmForSwitch(sw int32) (string, bool) { +// the value for an instance of ScpHistoryEntry +func (u ScpHistoryEntry) ArmForSwitch(sw int32) (string, bool) { switch int32(sw) { case 0: return "V0", true @@ -16442,14 +16631,14 @@ func (u ContractEventBody) ArmForSwitch(sw int32) (string, bool) { return "-", false } -// NewContractEventBody creates a new ContractEventBody. -func NewContractEventBody(v int32, value interface{}) (result ContractEventBody, err error) { +// NewScpHistoryEntry creates a new ScpHistoryEntry. +func NewScpHistoryEntry(v int32, value interface{}) (result ScpHistoryEntry, err error) { result.V = v switch int32(v) { case 0: - tv, ok := value.(ContractEventV0) + tv, ok := value.(ScpHistoryEntryV0) if !ok { - err = errors.New("invalid value, must be ContractEventV0") + err = errors.New("invalid value, must be ScpHistoryEntryV0") return } result.V0 = &tv @@ -16459,7 +16648,7 @@ func NewContractEventBody(v int32, value interface{}) (result ContractEventBody, // MustV0 retrieves the V0 value from the union, // panicing if the value is not set. -func (u ContractEventBody) MustV0() ContractEventV0 { +func (u ScpHistoryEntry) MustV0() ScpHistoryEntryV0 { val, ok := u.GetV0() if !ok { @@ -16471,7 +16660,7 @@ func (u ContractEventBody) MustV0() ContractEventV0 { // GetV0 retrieves the V0 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ContractEventBody) GetV0() (result ContractEventV0, ok bool) { +func (u ScpHistoryEntry) GetV0() (result ScpHistoryEntryV0, ok bool) { armName, _ := u.ArmForSwitch(int32(u.V)) if armName == "V0" { @@ -16483,7 +16672,7 @@ func (u ContractEventBody) GetV0() (result ContractEventV0, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u ContractEventBody) EncodeTo(e *xdr.Encoder) error { +func (u ScpHistoryEntry) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeInt(int32(u.V)); err != nil { return err @@ -16495,15 +16684,15 @@ func (u ContractEventBody) EncodeTo(e *xdr.Encoder) error { } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union ContractEventBody", u.V) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union ScpHistoryEntry", u.V) } -var _ decoderFrom = (*ContractEventBody)(nil) +var _ decoderFrom = (*ScpHistoryEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ContractEventBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *ScpHistoryEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ContractEventBody: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ScpHistoryEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -16515,19 +16704,19 @@ func (u *ContractEventBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } switch int32(u.V) { case 0: - u.V0 = new(ContractEventV0) + u.V0 = new(ScpHistoryEntryV0) nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEventV0: %w", err) + return n, fmt.Errorf("decoding ScpHistoryEntryV0: %w", err) } return n, nil } - return n, fmt.Errorf("union ContractEventBody has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union ScpHistoryEntry has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractEventBody) MarshalBinary() ([]byte, error) { +func (s ScpHistoryEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16535,7 +16724,7 @@ func (s ContractEventBody) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractEventBody) UnmarshalBinary(inp []byte) error { +func (s *ScpHistoryEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16545,112 +16734,83 @@ func (s *ContractEventBody) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractEventBody)(nil) - _ encoding.BinaryUnmarshaler = (*ContractEventBody)(nil) + _ encoding.BinaryMarshaler = (*ScpHistoryEntry)(nil) + _ encoding.BinaryUnmarshaler = (*ScpHistoryEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ContractEventBody) xdrType() {} +func (s ScpHistoryEntry) xdrType() {} -var _ xdrType = (*ContractEventBody)(nil) +var _ xdrType = (*ScpHistoryEntry)(nil) -// ContractEvent is an XDR Struct defines as: +// LedgerEntryChangeType is an XDR Enum defines as: // -// struct ContractEvent +// enum LedgerEntryChangeType // { -// // We can use this to add more fields, or because it -// // is first, to change ContractEvent into a union. -// ExtensionPoint ext; -// -// Hash* contractID; -// ContractEventType type; -// -// union switch (int v) -// { -// case 0: -// struct -// { -// SCVal topics<>; -// SCVal data; -// } v0; -// } -// body; +// LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger +// LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger +// LEDGER_ENTRY_REMOVED = 2, // entry was removed from the ledger +// LEDGER_ENTRY_STATE = 3 // value of the entry // }; -type ContractEvent struct { - Ext ExtensionPoint - ContractId *Hash - Type ContractEventType - Body ContractEventBody -} +type LedgerEntryChangeType int32 -// EncodeTo encodes this value using the Encoder. -func (s *ContractEvent) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Ext.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeBool(s.ContractId != nil); err != nil { - return err - } - if s.ContractId != nil { - if err = (*s.ContractId).EncodeTo(e); err != nil { - return err - } - } - if err = s.Type.EncodeTo(e); err != nil { - return err - } - if err = s.Body.EncodeTo(e); err != nil { - return err - } - return nil +const ( + LedgerEntryChangeTypeLedgerEntryCreated LedgerEntryChangeType = 0 + LedgerEntryChangeTypeLedgerEntryUpdated LedgerEntryChangeType = 1 + LedgerEntryChangeTypeLedgerEntryRemoved LedgerEntryChangeType = 2 + LedgerEntryChangeTypeLedgerEntryState LedgerEntryChangeType = 3 +) + +var ledgerEntryChangeTypeMap = map[int32]string{ + 0: "LedgerEntryChangeTypeLedgerEntryCreated", + 1: "LedgerEntryChangeTypeLedgerEntryUpdated", + 2: "LedgerEntryChangeTypeLedgerEntryRemoved", + 3: "LedgerEntryChangeTypeLedgerEntryState", } -var _ decoderFrom = (*ContractEvent)(nil) +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for LedgerEntryChangeType +func (e LedgerEntryChangeType) ValidEnum(v int32) bool { + _, ok := ledgerEntryChangeTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e LedgerEntryChangeType) String() string { + name, _ := ledgerEntryChangeTypeMap[int32(e)] + return name +} + +// EncodeTo encodes this value using the Encoder. +func (e LedgerEntryChangeType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := ledgerEntryChangeTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid LedgerEntryChangeType enum value", e) + } + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*LedgerEntryChangeType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractEvent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *LedgerEntryChangeType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ContractEvent: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerEntryChangeType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %w", err) - } - var b bool - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - s.ContractId = nil - if b { - s.ContractId = new(Hash) - nTmp, err = s.ContractId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - } - nTmp, err = s.Type.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ContractEventType: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChangeType: %w", err) } - nTmp, err = s.Body.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ContractEventBody: %w", err) + if _, ok := ledgerEntryChangeTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid LedgerEntryChangeType enum value", v) } + *e = LedgerEntryChangeType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractEvent) MarshalBinary() ([]byte, error) { +func (s LedgerEntryChangeType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16658,7 +16818,7 @@ func (s ContractEvent) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractEvent) UnmarshalBinary(inp []byte) error { +func (s *LedgerEntryChangeType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16668,64 +16828,279 @@ func (s *ContractEvent) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractEvent)(nil) - _ encoding.BinaryUnmarshaler = (*ContractEvent)(nil) + _ encoding.BinaryMarshaler = (*LedgerEntryChangeType)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerEntryChangeType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ContractEvent) xdrType() {} +func (s LedgerEntryChangeType) xdrType() {} -var _ xdrType = (*ContractEvent)(nil) +var _ xdrType = (*LedgerEntryChangeType)(nil) -// DiagnosticEvent is an XDR Struct defines as: +// LedgerEntryChange is an XDR Union defines as: // -// struct DiagnosticEvent +// union LedgerEntryChange switch (LedgerEntryChangeType type) // { -// bool inSuccessfulContractCall; -// ContractEvent event; +// case LEDGER_ENTRY_CREATED: +// LedgerEntry created; +// case LEDGER_ENTRY_UPDATED: +// LedgerEntry updated; +// case LEDGER_ENTRY_REMOVED: +// LedgerKey removed; +// case LEDGER_ENTRY_STATE: +// LedgerEntry state; // }; -type DiagnosticEvent struct { - InSuccessfulContractCall bool - Event ContractEvent +type LedgerEntryChange struct { + Type LedgerEntryChangeType + Created *LedgerEntry + Updated *LedgerEntry + Removed *LedgerKey + State *LedgerEntry +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u LedgerEntryChange) SwitchFieldName() string { + return "Type" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of LedgerEntryChange +func (u LedgerEntryChange) ArmForSwitch(sw int32) (string, bool) { + switch LedgerEntryChangeType(sw) { + case LedgerEntryChangeTypeLedgerEntryCreated: + return "Created", true + case LedgerEntryChangeTypeLedgerEntryUpdated: + return "Updated", true + case LedgerEntryChangeTypeLedgerEntryRemoved: + return "Removed", true + case LedgerEntryChangeTypeLedgerEntryState: + return "State", true + } + return "-", false +} + +// NewLedgerEntryChange creates a new LedgerEntryChange. +func NewLedgerEntryChange(aType LedgerEntryChangeType, value interface{}) (result LedgerEntryChange, err error) { + result.Type = aType + switch LedgerEntryChangeType(aType) { + case LedgerEntryChangeTypeLedgerEntryCreated: + tv, ok := value.(LedgerEntry) + if !ok { + err = errors.New("invalid value, must be LedgerEntry") + return + } + result.Created = &tv + case LedgerEntryChangeTypeLedgerEntryUpdated: + tv, ok := value.(LedgerEntry) + if !ok { + err = errors.New("invalid value, must be LedgerEntry") + return + } + result.Updated = &tv + case LedgerEntryChangeTypeLedgerEntryRemoved: + tv, ok := value.(LedgerKey) + if !ok { + err = errors.New("invalid value, must be LedgerKey") + return + } + result.Removed = &tv + case LedgerEntryChangeTypeLedgerEntryState: + tv, ok := value.(LedgerEntry) + if !ok { + err = errors.New("invalid value, must be LedgerEntry") + return + } + result.State = &tv + } + return +} + +// MustCreated retrieves the Created value from the union, +// panicing if the value is not set. +func (u LedgerEntryChange) MustCreated() LedgerEntry { + val, ok := u.GetCreated() + + if !ok { + panic("arm Created is not set") + } + + return val +} + +// GetCreated retrieves the Created value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerEntryChange) GetCreated() (result LedgerEntry, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Created" { + result = *u.Created + ok = true + } + + return +} + +// MustUpdated retrieves the Updated value from the union, +// panicing if the value is not set. +func (u LedgerEntryChange) MustUpdated() LedgerEntry { + val, ok := u.GetUpdated() + + if !ok { + panic("arm Updated is not set") + } + + return val +} + +// GetUpdated retrieves the Updated value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerEntryChange) GetUpdated() (result LedgerEntry, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Updated" { + result = *u.Updated + ok = true + } + + return +} + +// MustRemoved retrieves the Removed value from the union, +// panicing if the value is not set. +func (u LedgerEntryChange) MustRemoved() LedgerKey { + val, ok := u.GetRemoved() + + if !ok { + panic("arm Removed is not set") + } + + return val +} + +// GetRemoved retrieves the Removed value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerEntryChange) GetRemoved() (result LedgerKey, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Removed" { + result = *u.Removed + ok = true + } + + return +} + +// MustState retrieves the State value from the union, +// panicing if the value is not set. +func (u LedgerEntryChange) MustState() LedgerEntry { + val, ok := u.GetState() + + if !ok { + panic("arm State is not set") + } + + return val +} + +// GetState retrieves the State value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerEntryChange) GetState() (result LedgerEntry, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "State" { + result = *u.State + ok = true + } + + return } // EncodeTo encodes this value using the Encoder. -func (s *DiagnosticEvent) EncodeTo(e *xdr.Encoder) error { +func (u LedgerEntryChange) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeBool(bool(s.InSuccessfulContractCall)); err != nil { + if err = u.Type.EncodeTo(e); err != nil { return err } - if err = s.Event.EncodeTo(e); err != nil { - return err + switch LedgerEntryChangeType(u.Type) { + case LedgerEntryChangeTypeLedgerEntryCreated: + if err = (*u.Created).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerEntryChangeTypeLedgerEntryUpdated: + if err = (*u.Updated).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerEntryChangeTypeLedgerEntryRemoved: + if err = (*u.Removed).EncodeTo(e); err != nil { + return err + } + return nil + case LedgerEntryChangeTypeLedgerEntryState: + if err = (*u.State).EncodeTo(e); err != nil { + return err + } + return nil } - return nil + return fmt.Errorf("Type (LedgerEntryChangeType) switch value '%d' is not valid for union LedgerEntryChange", u.Type) } -var _ decoderFrom = (*DiagnosticEvent)(nil) +var _ decoderFrom = (*LedgerEntryChange)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DiagnosticEvent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *LedgerEntryChange) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding DiagnosticEvent: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerEntryChange: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - s.InSuccessfulContractCall, nTmp, err = d.DecodeBool() + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Bool: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChangeType: %w", err) } - nTmp, err = s.Event.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %w", err) + switch LedgerEntryChangeType(u.Type) { + case LedgerEntryChangeTypeLedgerEntryCreated: + u.Created = new(LedgerEntry) + nTmp, err = (*u.Created).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + return n, nil + case LedgerEntryChangeTypeLedgerEntryUpdated: + u.Updated = new(LedgerEntry) + nTmp, err = (*u.Updated).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + return n, nil + case LedgerEntryChangeTypeLedgerEntryRemoved: + u.Removed = new(LedgerKey) + nTmp, err = (*u.Removed).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + return n, nil + case LedgerEntryChangeTypeLedgerEntryState: + u.State = new(LedgerEntry) + nTmp, err = (*u.State).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + return n, nil } - return n, nil + return n, fmt.Errorf("union LedgerEntryChange has invalid Type (LedgerEntryChangeType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s DiagnosticEvent) MarshalBinary() ([]byte, error) { +func (s LedgerEntryChange) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16733,7 +17108,7 @@ func (s DiagnosticEvent) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *DiagnosticEvent) UnmarshalBinary(inp []byte) error { +func (s *LedgerEntryChange) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16743,22 +17118,22 @@ func (s *DiagnosticEvent) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*DiagnosticEvent)(nil) - _ encoding.BinaryUnmarshaler = (*DiagnosticEvent)(nil) + _ encoding.BinaryMarshaler = (*LedgerEntryChange)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerEntryChange)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s DiagnosticEvent) xdrType() {} +func (s LedgerEntryChange) xdrType() {} -var _ xdrType = (*DiagnosticEvent)(nil) +var _ xdrType = (*LedgerEntryChange)(nil) -// DiagnosticEvents is an XDR Typedef defines as: +// LedgerEntryChanges is an XDR Typedef defines as: // -// typedef DiagnosticEvent DiagnosticEvents<>; -type DiagnosticEvents []DiagnosticEvent +// typedef LedgerEntryChange LedgerEntryChanges<>; +type LedgerEntryChanges []LedgerEntryChange // EncodeTo encodes this value using the Encoder. -func (s DiagnosticEvents) EncodeTo(e *xdr.Encoder) error { +func (s LedgerEntryChanges) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeUint(uint32(len(s))); err != nil { return err @@ -16771,12 +17146,12 @@ func (s DiagnosticEvents) EncodeTo(e *xdr.Encoder) error { return nil } -var _ decoderFrom = (*DiagnosticEvents)(nil) +var _ decoderFrom = (*LedgerEntryChanges)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DiagnosticEvents) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerEntryChanges) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding DiagnosticEvents: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerEntryChanges: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -16785,19 +17160,19 @@ func (s *DiagnosticEvents) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChange: %w", err) } (*s) = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding DiagnosticEvent: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding LedgerEntryChange: length (%d) exceeds remaining input length (%d)", l, il) } - (*s) = make([]DiagnosticEvent, l) + (*s) = make([]LedgerEntryChange, l) for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChange: %w", err) } } } @@ -16805,7 +17180,7 @@ func (s *DiagnosticEvents) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error } // MarshalBinary implements encoding.BinaryMarshaler. -func (s DiagnosticEvents) MarshalBinary() ([]byte, error) { +func (s LedgerEntryChanges) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16813,7 +17188,7 @@ func (s DiagnosticEvents) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *DiagnosticEvents) UnmarshalBinary(inp []byte) error { +func (s *LedgerEntryChanges) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16823,110 +17198,54 @@ func (s *DiagnosticEvents) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*DiagnosticEvents)(nil) - _ encoding.BinaryUnmarshaler = (*DiagnosticEvents)(nil) + _ encoding.BinaryMarshaler = (*LedgerEntryChanges)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerEntryChanges)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s DiagnosticEvents) xdrType() {} +func (s LedgerEntryChanges) xdrType() {} -var _ xdrType = (*DiagnosticEvents)(nil) +var _ xdrType = (*LedgerEntryChanges)(nil) -// SorobanTransactionMetaExtV1 is an XDR Struct defines as: +// OperationMeta is an XDR Struct defines as: // -// struct SorobanTransactionMetaExtV1 +// struct OperationMeta // { -// ExtensionPoint ext; -// -// // The following are the components of the overall Soroban resource fee -// // charged for the transaction. -// // The following relation holds: -// // `resourceFeeCharged = totalNonRefundableResourceFeeCharged + totalRefundableResourceFeeCharged` -// // where `resourceFeeCharged` is the overall fee charged for the -// // transaction. Also, `resourceFeeCharged` <= `sorobanData.resourceFee` -// // i.e.we never charge more than the declared resource fee. -// // The inclusion fee for charged the Soroban transaction can be found using -// // the following equation: -// // `result.feeCharged = resourceFeeCharged + inclusionFeeCharged`. -// -// // Total amount (in stroops) that has been charged for non-refundable -// // Soroban resources. -// // Non-refundable resources are charged based on the usage declared in -// // the transaction envelope (such as `instructions`, `readBytes` etc.) and -// // is charged regardless of the success of the transaction. -// int64 totalNonRefundableResourceFeeCharged; -// // Total amount (in stroops) that has been charged for refundable -// // Soroban resource fees. -// // Currently this comprises the rent fee (`rentFeeCharged`) and the -// // fee for the events and return value. -// // Refundable resources are charged based on the actual resources usage. -// // Since currently refundable resources are only used for the successful -// // transactions, this will be `0` for failed transactions. -// int64 totalRefundableResourceFeeCharged; -// // Amount (in stroops) that has been charged for rent. -// // This is a part of `totalNonRefundableResourceFeeCharged`. -// int64 rentFeeCharged; +// LedgerEntryChanges changes; // }; -type SorobanTransactionMetaExtV1 struct { - Ext ExtensionPoint - TotalNonRefundableResourceFeeCharged Int64 - TotalRefundableResourceFeeCharged Int64 - RentFeeCharged Int64 +type OperationMeta struct { + Changes LedgerEntryChanges } // EncodeTo encodes this value using the Encoder. -func (s *SorobanTransactionMetaExtV1) EncodeTo(e *xdr.Encoder) error { +func (s *OperationMeta) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Ext.EncodeTo(e); err != nil { - return err - } - if err = s.TotalNonRefundableResourceFeeCharged.EncodeTo(e); err != nil { - return err - } - if err = s.TotalRefundableResourceFeeCharged.EncodeTo(e); err != nil { - return err - } - if err = s.RentFeeCharged.EncodeTo(e); err != nil { + if err = s.Changes.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*SorobanTransactionMetaExtV1)(nil) +var _ decoderFrom = (*OperationMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanTransactionMetaExtV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *OperationMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanTransactionMetaExtV1: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding OperationMeta: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %w", err) - } - nTmp, err = s.TotalNonRefundableResourceFeeCharged.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.TotalRefundableResourceFeeCharged.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.RentFeeCharged.DecodeFrom(d, maxDepth) + nTmp, err = s.Changes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanTransactionMetaExtV1) MarshalBinary() ([]byte, error) { +func (s OperationMeta) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -16934,7 +17253,7 @@ func (s SorobanTransactionMetaExtV1) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanTransactionMetaExtV1) UnmarshalBinary(inp []byte) error { +func (s *OperationMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -16944,141 +17263,84 @@ func (s *SorobanTransactionMetaExtV1) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SorobanTransactionMetaExtV1)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanTransactionMetaExtV1)(nil) + _ encoding.BinaryMarshaler = (*OperationMeta)(nil) + _ encoding.BinaryUnmarshaler = (*OperationMeta)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SorobanTransactionMetaExtV1) xdrType() {} +func (s OperationMeta) xdrType() {} -var _ xdrType = (*SorobanTransactionMetaExtV1)(nil) +var _ xdrType = (*OperationMeta)(nil) -// SorobanTransactionMetaExt is an XDR Union defines as: +// TransactionMetaV1 is an XDR Struct defines as: // -// union SorobanTransactionMetaExt switch (int v) +// struct TransactionMetaV1 // { -// case 0: -// void; -// case 1: -// SorobanTransactionMetaExtV1 v1; +// LedgerEntryChanges txChanges; // tx level changes if any +// OperationMeta operations<>; // meta for each operation // }; -type SorobanTransactionMetaExt struct { - V int32 - V1 *SorobanTransactionMetaExtV1 -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u SorobanTransactionMetaExt) SwitchFieldName() string { - return "V" +type TransactionMetaV1 struct { + TxChanges LedgerEntryChanges + Operations []OperationMeta } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of SorobanTransactionMetaExt -func (u SorobanTransactionMetaExt) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: - return "", true - case 1: - return "V1", true +// EncodeTo encodes this value using the Encoder. +func (s *TransactionMetaV1) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.TxChanges.EncodeTo(e); err != nil { + return err } - return "-", false + if _, err = e.EncodeUint(uint32(len(s.Operations))); err != nil { + return err + } + for i := 0; i < len(s.Operations); i++ { + if err = s.Operations[i].EncodeTo(e); err != nil { + return err + } + } + return nil } -// NewSorobanTransactionMetaExt creates a new SorobanTransactionMetaExt. -func NewSorobanTransactionMetaExt(v int32, value interface{}) (result SorobanTransactionMetaExt, err error) { - result.V = v - switch int32(v) { - case 0: - // void - case 1: - tv, ok := value.(SorobanTransactionMetaExtV1) - if !ok { - err = errors.New("invalid value, must be SorobanTransactionMetaExtV1") - return - } - result.V1 = &tv - } - return -} - -// MustV1 retrieves the V1 value from the union, -// panicing if the value is not set. -func (u SorobanTransactionMetaExt) MustV1() SorobanTransactionMetaExtV1 { - val, ok := u.GetV1() - - if !ok { - panic("arm V1 is not set") - } - - return val -} - -// GetV1 retrieves the V1 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u SorobanTransactionMetaExt) GetV1() (result SorobanTransactionMetaExtV1, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) - - if armName == "V1" { - result = *u.V1 - ok = true - } - - return -} - -// EncodeTo encodes this value using the Encoder. -func (u SorobanTransactionMetaExt) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeInt(int32(u.V)); err != nil { - return err - } - switch int32(u.V) { - case 0: - // Void - return nil - case 1: - if err = (*u.V1).EncodeTo(e); err != nil { - return err - } - return nil - } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union SorobanTransactionMetaExt", u.V) -} - -var _ decoderFrom = (*SorobanTransactionMetaExt)(nil) +var _ decoderFrom = (*TransactionMetaV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SorobanTransactionMetaExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanTransactionMetaExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionMetaV1: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - u.V, nTmp, err = d.DecodeInt() + nTmp, err = s.TxChanges.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } - switch int32(u.V) { - case 0: - // Void - return n, nil - case 1: - u.V1 = new(SorobanTransactionMetaExtV1) - nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanTransactionMetaExtV1: %w", err) + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding OperationMeta: %w", err) + } + s.Operations = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Operations = make([]OperationMeta, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding OperationMeta: %w", err) + } } - return n, nil } - return n, fmt.Errorf("union SorobanTransactionMetaExt has invalid V (int32) switch value '%d'", u.V) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanTransactionMetaExt) MarshalBinary() ([]byte, error) { +func (s TransactionMetaV1) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -17086,7 +17348,7 @@ func (s SorobanTransactionMetaExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanTransactionMetaExt) UnmarshalBinary(inp []byte) error { +func (s *TransactionMetaV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -17096,129 +17358,96 @@ func (s *SorobanTransactionMetaExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SorobanTransactionMetaExt)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanTransactionMetaExt)(nil) + _ encoding.BinaryMarshaler = (*TransactionMetaV1)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionMetaV1)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SorobanTransactionMetaExt) xdrType() {} +func (s TransactionMetaV1) xdrType() {} -var _ xdrType = (*SorobanTransactionMetaExt)(nil) +var _ xdrType = (*TransactionMetaV1)(nil) -// SorobanTransactionMeta is an XDR Struct defines as: +// TransactionMetaV2 is an XDR Struct defines as: // -// struct SorobanTransactionMeta +// struct TransactionMetaV2 // { -// SorobanTransactionMetaExt ext; -// -// ContractEvent events<>; // custom events populated by the -// // contracts themselves. -// SCVal returnValue; // return value of the host fn invocation -// -// // Diagnostics events that are not hashed. -// // This will contain all contract and diagnostic events. Even ones -// // that were emitted in a failed contract call. -// DiagnosticEvent diagnosticEvents<>; +// LedgerEntryChanges txChangesBefore; // tx level changes before operations +// // are applied if any +// OperationMeta operations<>; // meta for each operation +// LedgerEntryChanges txChangesAfter; // tx level changes after operations are +// // applied if any // }; -type SorobanTransactionMeta struct { - Ext SorobanTransactionMetaExt - Events []ContractEvent - ReturnValue ScVal - DiagnosticEvents []DiagnosticEvent +type TransactionMetaV2 struct { + TxChangesBefore LedgerEntryChanges + Operations []OperationMeta + TxChangesAfter LedgerEntryChanges } // EncodeTo encodes this value using the Encoder. -func (s *SorobanTransactionMeta) EncodeTo(e *xdr.Encoder) error { +func (s *TransactionMetaV2) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Ext.EncodeTo(e); err != nil { + if err = s.TxChangesBefore.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Events))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Operations))); err != nil { return err } - for i := 0; i < len(s.Events); i++ { - if err = s.Events[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.Operations); i++ { + if err = s.Operations[i].EncodeTo(e); err != nil { return err } } - if err = s.ReturnValue.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.DiagnosticEvents))); err != nil { + if err = s.TxChangesAfter.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.DiagnosticEvents); i++ { - if err = s.DiagnosticEvents[i].EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*SorobanTransactionMeta)(nil) +var _ decoderFrom = (*TransactionMetaV2)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionMetaV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanTransactionMeta: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionMetaV2: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + nTmp, err = s.TxChangesBefore.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanTransactionMetaExt: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %w", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } - s.Events = nil + s.Operations = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) } - s.Events = make([]ContractEvent, l) + s.Operations = make([]OperationMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %w", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } } } - nTmp, err = s.ReturnValue.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) - } - l, nTmp, err = d.DecodeUint() + nTmp, err = s.TxChangesAfter.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) - } - s.DiagnosticEvents = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding DiagnosticEvent: length (%d) exceeds remaining input length (%d)", l, il) - } - s.DiagnosticEvents = make([]DiagnosticEvent, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.DiagnosticEvents[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) - } - } + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanTransactionMeta) MarshalBinary() ([]byte, error) { +func (s TransactionMetaV2) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -17226,7 +17455,7 @@ func (s SorobanTransactionMeta) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanTransactionMeta) UnmarshalBinary(inp []byte) error { +func (s *TransactionMetaV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -17236,133 +17465,80 @@ func (s *SorobanTransactionMeta) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SorobanTransactionMeta)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanTransactionMeta)(nil) + _ encoding.BinaryMarshaler = (*TransactionMetaV2)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionMetaV2)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SorobanTransactionMeta) xdrType() {} +func (s TransactionMetaV2) xdrType() {} -var _ xdrType = (*SorobanTransactionMeta)(nil) +var _ xdrType = (*TransactionMetaV2)(nil) -// TransactionMetaV3 is an XDR Struct defines as: +// ContractEventType is an XDR Enum defines as: // -// struct TransactionMetaV3 +// enum ContractEventType // { -// ExtensionPoint ext; -// -// LedgerEntryChanges txChangesBefore; // tx level changes before operations -// // are applied if any -// OperationMeta operations<>; // meta for each operation -// LedgerEntryChanges txChangesAfter; // tx level changes after operations are -// // applied if any -// SorobanTransactionMeta* sorobanMeta; // Soroban-specific meta (only for -// // Soroban transactions). +// SYSTEM = 0, +// CONTRACT = 1, +// DIAGNOSTIC = 2 // }; -type TransactionMetaV3 struct { - Ext ExtensionPoint - TxChangesBefore LedgerEntryChanges - Operations []OperationMeta - TxChangesAfter LedgerEntryChanges - SorobanMeta *SorobanTransactionMeta +type ContractEventType int32 + +const ( + ContractEventTypeSystem ContractEventType = 0 + ContractEventTypeContract ContractEventType = 1 + ContractEventTypeDiagnostic ContractEventType = 2 +) + +var contractEventTypeMap = map[int32]string{ + 0: "ContractEventTypeSystem", + 1: "ContractEventTypeContract", + 2: "ContractEventTypeDiagnostic", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for ContractEventType +func (e ContractEventType) ValidEnum(v int32) bool { + _, ok := contractEventTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e ContractEventType) String() string { + name, _ := contractEventTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *TransactionMetaV3) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Ext.EncodeTo(e); err != nil { - return err - } - if err = s.TxChangesBefore.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.Operations))); err != nil { - return err - } - for i := 0; i < len(s.Operations); i++ { - if err = s.Operations[i].EncodeTo(e); err != nil { - return err - } - } - if err = s.TxChangesAfter.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeBool(s.SorobanMeta != nil); err != nil { - return err - } - if s.SorobanMeta != nil { - if err = (*s.SorobanMeta).EncodeTo(e); err != nil { - return err - } +func (e ContractEventType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := contractEventTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ContractEventType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*TransactionMetaV3)(nil) +var _ decoderFrom = (*ContractEventType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionMetaV3) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *ContractEventType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionMetaV3: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ContractEventType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %w", err) - } - nTmp, err = s.TxChangesBefore.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) - } - s.Operations = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Operations = make([]OperationMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) - } - } - } - nTmp, err = s.TxChangesAfter.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) - } - var b bool - b, nTmp, err = d.DecodeBool() - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding SorobanTransactionMeta: %w", err) + return n, fmt.Errorf("decoding ContractEventType: %w", err) } - s.SorobanMeta = nil - if b { - s.SorobanMeta = new(SorobanTransactionMeta) - nTmp, err = s.SorobanMeta.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanTransactionMeta: %w", err) - } + if _, ok := contractEventTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ContractEventType enum value", v) } + *e = ContractEventType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionMetaV3) MarshalBinary() ([]byte, error) { +func (s ContractEventType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -17370,7 +17546,7 @@ func (s TransactionMetaV3) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionMetaV3) UnmarshalBinary(inp []byte) error { +func (s *ContractEventType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -17380,84 +17556,84 @@ func (s *TransactionMetaV3) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionMetaV3)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionMetaV3)(nil) + _ encoding.BinaryMarshaler = (*ContractEventType)(nil) + _ encoding.BinaryUnmarshaler = (*ContractEventType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionMetaV3) xdrType() {} +func (s ContractEventType) xdrType() {} -var _ xdrType = (*TransactionMetaV3)(nil) +var _ xdrType = (*ContractEventType)(nil) -// InvokeHostFunctionSuccessPreImage is an XDR Struct defines as: +// ContractEventV0 is an XDR NestedStruct defines as: // -// struct InvokeHostFunctionSuccessPreImage -// { -// SCVal returnValue; -// ContractEvent events<>; -// }; -type InvokeHostFunctionSuccessPreImage struct { - ReturnValue ScVal - Events []ContractEvent +// struct +// { +// SCVal topics<>; +// SCVal data; +// } +type ContractEventV0 struct { + Topics []ScVal + Data ScVal } // EncodeTo encodes this value using the Encoder. -func (s *InvokeHostFunctionSuccessPreImage) EncodeTo(e *xdr.Encoder) error { +func (s *ContractEventV0) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.ReturnValue.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.Events))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Topics))); err != nil { return err } - for i := 0; i < len(s.Events); i++ { - if err = s.Events[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.Topics); i++ { + if err = s.Topics[i].EncodeTo(e); err != nil { return err } } + if err = s.Data.EncodeTo(e); err != nil { + return err + } return nil } -var _ decoderFrom = (*InvokeHostFunctionSuccessPreImage)(nil) +var _ decoderFrom = (*ContractEventV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InvokeHostFunctionSuccessPreImage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ContractEventV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding InvokeHostFunctionSuccessPreImage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ContractEventV0: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ReturnValue.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) - } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %w", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } - s.Events = nil + s.Topics = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) } - s.Events = make([]ContractEvent, l) + s.Topics = make([]ScVal, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Topics[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %w", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } } } + nTmp, err = s.Data.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %w", err) + } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s InvokeHostFunctionSuccessPreImage) MarshalBinary() ([]byte, error) { +func (s ContractEventV0) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -17465,7 +17641,7 @@ func (s InvokeHostFunctionSuccessPreImage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *InvokeHostFunctionSuccessPreImage) UnmarshalBinary(inp []byte) error { +func (s *ContractEventV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -17475,188 +17651,81 @@ func (s *InvokeHostFunctionSuccessPreImage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*InvokeHostFunctionSuccessPreImage)(nil) - _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionSuccessPreImage)(nil) + _ encoding.BinaryMarshaler = (*ContractEventV0)(nil) + _ encoding.BinaryUnmarshaler = (*ContractEventV0)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s InvokeHostFunctionSuccessPreImage) xdrType() {} +func (s ContractEventV0) xdrType() {} -var _ xdrType = (*InvokeHostFunctionSuccessPreImage)(nil) +var _ xdrType = (*ContractEventV0)(nil) -// TransactionMeta is an XDR Union defines as: +// ContractEventBody is an XDR NestedUnion defines as: // -// union TransactionMeta switch (int v) -// { -// case 0: -// OperationMeta operations<>; -// case 1: -// TransactionMetaV1 v1; -// case 2: -// TransactionMetaV2 v2; -// case 3: -// TransactionMetaV3 v3; -// }; -type TransactionMeta struct { - V int32 - Operations *[]OperationMeta - V1 *TransactionMetaV1 - V2 *TransactionMetaV2 - V3 *TransactionMetaV3 +// union switch (int v) +// { +// case 0: +// struct +// { +// SCVal topics<>; +// SCVal data; +// } v0; +// } +type ContractEventBody struct { + V int32 + V0 *ContractEventV0 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u TransactionMeta) SwitchFieldName() string { +func (u ContractEventBody) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of TransactionMeta -func (u TransactionMeta) ArmForSwitch(sw int32) (string, bool) { +// the value for an instance of ContractEventBody +func (u ContractEventBody) ArmForSwitch(sw int32) (string, bool) { switch int32(sw) { case 0: - return "Operations", true - case 1: - return "V1", true - case 2: - return "V2", true - case 3: - return "V3", true + return "V0", true } return "-", false } -// NewTransactionMeta creates a new TransactionMeta. -func NewTransactionMeta(v int32, value interface{}) (result TransactionMeta, err error) { +// NewContractEventBody creates a new ContractEventBody. +func NewContractEventBody(v int32, value interface{}) (result ContractEventBody, err error) { result.V = v switch int32(v) { case 0: - tv, ok := value.([]OperationMeta) - if !ok { - err = errors.New("invalid value, must be []OperationMeta") - return - } - result.Operations = &tv - case 1: - tv, ok := value.(TransactionMetaV1) - if !ok { - err = errors.New("invalid value, must be TransactionMetaV1") - return - } - result.V1 = &tv - case 2: - tv, ok := value.(TransactionMetaV2) + tv, ok := value.(ContractEventV0) if !ok { - err = errors.New("invalid value, must be TransactionMetaV2") + err = errors.New("invalid value, must be ContractEventV0") return } - result.V2 = &tv - case 3: - tv, ok := value.(TransactionMetaV3) - if !ok { - err = errors.New("invalid value, must be TransactionMetaV3") - return - } - result.V3 = &tv - } - return -} - -// MustOperations retrieves the Operations value from the union, -// panicing if the value is not set. -func (u TransactionMeta) MustOperations() []OperationMeta { - val, ok := u.GetOperations() - - if !ok { - panic("arm Operations is not set") - } - - return val -} - -// GetOperations retrieves the Operations value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u TransactionMeta) GetOperations() (result []OperationMeta, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) - - if armName == "Operations" { - result = *u.Operations - ok = true - } - - return -} - -// MustV1 retrieves the V1 value from the union, -// panicing if the value is not set. -func (u TransactionMeta) MustV1() TransactionMetaV1 { - val, ok := u.GetV1() - - if !ok { - panic("arm V1 is not set") - } - - return val -} - -// GetV1 retrieves the V1 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u TransactionMeta) GetV1() (result TransactionMetaV1, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) - - if armName == "V1" { - result = *u.V1 - ok = true - } - - return -} - -// MustV2 retrieves the V2 value from the union, -// panicing if the value is not set. -func (u TransactionMeta) MustV2() TransactionMetaV2 { - val, ok := u.GetV2() - - if !ok { - panic("arm V2 is not set") - } - - return val -} - -// GetV2 retrieves the V2 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u TransactionMeta) GetV2() (result TransactionMetaV2, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) - - if armName == "V2" { - result = *u.V2 - ok = true + result.V0 = &tv } - return } -// MustV3 retrieves the V3 value from the union, +// MustV0 retrieves the V0 value from the union, // panicing if the value is not set. -func (u TransactionMeta) MustV3() TransactionMetaV3 { - val, ok := u.GetV3() +func (u ContractEventBody) MustV0() ContractEventV0 { + val, ok := u.GetV0() if !ok { - panic("arm V3 is not set") + panic("arm V0 is not set") } return val } -// GetV3 retrieves the V3 value from the union, +// GetV0 retrieves the V0 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u TransactionMeta) GetV3() (result TransactionMetaV3, ok bool) { +func (u ContractEventBody) GetV0() (result ContractEventV0, ok bool) { armName, _ := u.ArmForSwitch(int32(u.V)) - if armName == "V3" { - result = *u.V3 + if armName == "V0" { + result = *u.V0 ok = true } @@ -17664,47 +17733,27 @@ func (u TransactionMeta) GetV3() (result TransactionMetaV3, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u TransactionMeta) EncodeTo(e *xdr.Encoder) error { +func (u ContractEventBody) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } switch int32(u.V) { case 0: - if _, err = e.EncodeUint(uint32(len((*u.Operations)))); err != nil { - return err - } - for i := 0; i < len((*u.Operations)); i++ { - if err = (*u.Operations)[i].EncodeTo(e); err != nil { - return err - } - } - return nil - case 1: - if err = (*u.V1).EncodeTo(e); err != nil { - return err - } - return nil - case 2: - if err = (*u.V2).EncodeTo(e); err != nil { - return err - } - return nil - case 3: - if err = (*u.V3).EncodeTo(e); err != nil { + if err = (*u.V0).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionMeta", u.V) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union ContractEventBody", u.V) } -var _ decoderFrom = (*TransactionMeta)(nil) +var _ decoderFrom = (*ContractEventBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *ContractEventBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionMeta: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ContractEventBody: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -17716,58 +17765,19 @@ func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } switch int32(u.V) { case 0: - u.Operations = new([]OperationMeta) - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) - } - (*u.Operations) = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) - } - (*u.Operations) = make([]OperationMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Operations)[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding OperationMeta: %w", err) - } - } - } - return n, nil - case 1: - u.V1 = new(TransactionMetaV1) - nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionMetaV1: %w", err) - } - return n, nil - case 2: - u.V2 = new(TransactionMetaV2) - nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionMetaV2: %w", err) - } - return n, nil - case 3: - u.V3 = new(TransactionMetaV3) - nTmp, err = (*u.V3).DecodeFrom(d, maxDepth) + u.V0 = new(ContractEventV0) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionMetaV3: %w", err) + return n, fmt.Errorf("decoding ContractEventV0: %w", err) } return n, nil } - return n, fmt.Errorf("union TransactionMeta has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union ContractEventBody has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionMeta) MarshalBinary() ([]byte, error) { +func (s ContractEventBody) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -17775,7 +17785,7 @@ func (s TransactionMeta) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionMeta) UnmarshalBinary(inp []byte) error { +func (s *ContractEventBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -17785,74 +17795,112 @@ func (s *TransactionMeta) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionMeta)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionMeta)(nil) + _ encoding.BinaryMarshaler = (*ContractEventBody)(nil) + _ encoding.BinaryUnmarshaler = (*ContractEventBody)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionMeta) xdrType() {} +func (s ContractEventBody) xdrType() {} -var _ xdrType = (*TransactionMeta)(nil) +var _ xdrType = (*ContractEventBody)(nil) -// TransactionResultMeta is an XDR Struct defines as: +// ContractEvent is an XDR Struct defines as: // -// struct TransactionResultMeta +// struct ContractEvent // { -// TransactionResultPair result; -// LedgerEntryChanges feeProcessing; -// TransactionMeta txApplyProcessing; +// // We can use this to add more fields, or because it +// // is first, to change ContractEvent into a union. +// ExtensionPoint ext; +// +// Hash* contractID; +// ContractEventType type; +// +// union switch (int v) +// { +// case 0: +// struct +// { +// SCVal topics<>; +// SCVal data; +// } v0; +// } +// body; // }; -type TransactionResultMeta struct { - Result TransactionResultPair - FeeProcessing LedgerEntryChanges - TxApplyProcessing TransactionMeta +type ContractEvent struct { + Ext ExtensionPoint + ContractId *Hash + Type ContractEventType + Body ContractEventBody } // EncodeTo encodes this value using the Encoder. -func (s *TransactionResultMeta) EncodeTo(e *xdr.Encoder) error { +func (s *ContractEvent) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Result.EncodeTo(e); err != nil { + if err = s.Ext.EncodeTo(e); err != nil { return err } - if err = s.FeeProcessing.EncodeTo(e); err != nil { + if _, err = e.EncodeBool(s.ContractId != nil); err != nil { return err } - if err = s.TxApplyProcessing.EncodeTo(e); err != nil { + if s.ContractId != nil { + if err = (*s.ContractId).EncodeTo(e); err != nil { + return err + } + } + if err = s.Type.EncodeTo(e); err != nil { + return err + } + if err = s.Body.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TransactionResultMeta)(nil) +var _ decoderFrom = (*ContractEvent)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ContractEvent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TransactionResultMeta: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ContractEvent: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Result.DecodeFrom(d, maxDepth) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultPair: %w", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.FeeProcessing.DecodeFrom(d, maxDepth) + var b bool + b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - nTmp, err = s.TxApplyProcessing.DecodeFrom(d, maxDepth) + s.ContractId = nil + if b { + s.ContractId = new(Hash) + nTmp, err = s.ContractId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + } + nTmp, err = s.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionMeta: %w", err) + return n, fmt.Errorf("decoding ContractEventType: %w", err) + } + nTmp, err = s.Body.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ContractEventBody: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionResultMeta) MarshalBinary() ([]byte, error) { +func (s ContractEvent) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -17860,7 +17908,7 @@ func (s TransactionResultMeta) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionResultMeta) UnmarshalBinary(inp []byte) error { +func (s *ContractEvent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -17870,64 +17918,64 @@ func (s *TransactionResultMeta) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TransactionResultMeta)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionResultMeta)(nil) + _ encoding.BinaryMarshaler = (*ContractEvent)(nil) + _ encoding.BinaryUnmarshaler = (*ContractEvent)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TransactionResultMeta) xdrType() {} +func (s ContractEvent) xdrType() {} -var _ xdrType = (*TransactionResultMeta)(nil) +var _ xdrType = (*ContractEvent)(nil) -// UpgradeEntryMeta is an XDR Struct defines as: +// DiagnosticEvent is an XDR Struct defines as: // -// struct UpgradeEntryMeta +// struct DiagnosticEvent // { -// LedgerUpgrade upgrade; -// LedgerEntryChanges changes; +// bool inSuccessfulContractCall; +// ContractEvent event; // }; -type UpgradeEntryMeta struct { - Upgrade LedgerUpgrade - Changes LedgerEntryChanges +type DiagnosticEvent struct { + InSuccessfulContractCall bool + Event ContractEvent } // EncodeTo encodes this value using the Encoder. -func (s *UpgradeEntryMeta) EncodeTo(e *xdr.Encoder) error { +func (s *DiagnosticEvent) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Upgrade.EncodeTo(e); err != nil { + if _, err = e.EncodeBool(bool(s.InSuccessfulContractCall)); err != nil { return err } - if err = s.Changes.EncodeTo(e); err != nil { + if err = s.Event.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*UpgradeEntryMeta)(nil) +var _ decoderFrom = (*DiagnosticEvent)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *UpgradeEntryMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *DiagnosticEvent) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding UpgradeEntryMeta: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding DiagnosticEvent: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Upgrade.DecodeFrom(d, maxDepth) + s.InSuccessfulContractCall, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerUpgrade: %w", err) + return n, fmt.Errorf("decoding Bool: %w", err) } - nTmp, err = s.Changes.DecodeFrom(d, maxDepth) + nTmp, err = s.Event.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s UpgradeEntryMeta) MarshalBinary() ([]byte, error) { +func (s DiagnosticEvent) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -17935,7 +17983,7 @@ func (s UpgradeEntryMeta) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *UpgradeEntryMeta) UnmarshalBinary(inp []byte) error { +func (s *DiagnosticEvent) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -17945,153 +17993,61 @@ func (s *UpgradeEntryMeta) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*UpgradeEntryMeta)(nil) - _ encoding.BinaryUnmarshaler = (*UpgradeEntryMeta)(nil) + _ encoding.BinaryMarshaler = (*DiagnosticEvent)(nil) + _ encoding.BinaryUnmarshaler = (*DiagnosticEvent)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s UpgradeEntryMeta) xdrType() {} +func (s DiagnosticEvent) xdrType() {} -var _ xdrType = (*UpgradeEntryMeta)(nil) +var _ xdrType = (*DiagnosticEvent)(nil) -// LedgerCloseMetaV0 is an XDR Struct defines as: -// -// struct LedgerCloseMetaV0 -// { -// LedgerHeaderHistoryEntry ledgerHeader; -// // NB: txSet is sorted in "Hash order" -// TransactionSet txSet; -// -// // NB: transactions are sorted in apply order here -// // fees for all transactions are processed first -// // followed by applying transactions -// TransactionResultMeta txProcessing<>; -// -// // upgrades are applied last -// UpgradeEntryMeta upgradesProcessing<>; +// DiagnosticEvents is an XDR Typedef defines as: // -// // other misc information attached to the ledger close -// SCPHistoryEntry scpInfo<>; -// }; -type LedgerCloseMetaV0 struct { - LedgerHeader LedgerHeaderHistoryEntry - TxSet TransactionSet - TxProcessing []TransactionResultMeta - UpgradesProcessing []UpgradeEntryMeta - ScpInfo []ScpHistoryEntry -} +// typedef DiagnosticEvent DiagnosticEvents<>; +type DiagnosticEvents []DiagnosticEvent // EncodeTo encodes this value using the Encoder. -func (s *LedgerCloseMetaV0) EncodeTo(e *xdr.Encoder) error { +func (s DiagnosticEvents) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.LedgerHeader.EncodeTo(e); err != nil { - return err - } - if err = s.TxSet.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.TxProcessing))); err != nil { - return err - } - for i := 0; i < len(s.TxProcessing); i++ { - if err = s.TxProcessing[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.UpgradesProcessing))); err != nil { - return err - } - for i := 0; i < len(s.UpgradesProcessing); i++ { - if err = s.UpgradesProcessing[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.ScpInfo))); err != nil { + if _, err = e.EncodeUint(uint32(len(s))); err != nil { return err } - for i := 0; i < len(s.ScpInfo); i++ { - if err = s.ScpInfo[i].EncodeTo(e); err != nil { + for i := 0; i < len(s); i++ { + if err = s[i].EncodeTo(e); err != nil { return err } } return nil } -var _ decoderFrom = (*LedgerCloseMetaV0)(nil) +var _ decoderFrom = (*DiagnosticEvents)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *DiagnosticEvents) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerCloseMetaV0: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding DiagnosticEvents: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerHeader.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", err) - } - nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionSet: %w", err) - } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) - } - s.TxProcessing = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) - } - s.TxProcessing = make([]TransactionResultMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) - } - } - } - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) - } - s.UpgradesProcessing = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) - } - s.UpgradesProcessing = make([]UpgradeEntryMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) - } - } - } - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) } - s.ScpInfo = nil + (*s) = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding DiagnosticEvent: length (%d) exceeds remaining input length (%d)", l, il) } - s.ScpInfo = make([]ScpHistoryEntry, l) + (*s) = make([]DiagnosticEvent, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) } } } @@ -18099,7 +18055,7 @@ func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMetaV0) MarshalBinary() ([]byte, error) { +func (s DiagnosticEvents) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -18107,7 +18063,7 @@ func (s LedgerCloseMetaV0) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMetaV0) UnmarshalBinary(inp []byte) error { +func (s *DiagnosticEvents) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -18117,45 +18073,81 @@ func (s *LedgerCloseMetaV0) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMetaV0)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV0)(nil) + _ encoding.BinaryMarshaler = (*DiagnosticEvents)(nil) + _ encoding.BinaryUnmarshaler = (*DiagnosticEvents)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerCloseMetaV0) xdrType() {} +func (s DiagnosticEvents) xdrType() {} -var _ xdrType = (*LedgerCloseMetaV0)(nil) +var _ xdrType = (*DiagnosticEvents)(nil) -// LedgerCloseMetaExtV1 is an XDR Struct defines as: +// SorobanTransactionMetaExtV1 is an XDR Struct defines as: // -// struct LedgerCloseMetaExtV1 +// struct SorobanTransactionMetaExtV1 // { // ExtensionPoint ext; -// int64 sorobanFeeWrite1KB; +// +// // The following are the components of the overall Soroban resource fee +// // charged for the transaction. +// // The following relation holds: +// // `resourceFeeCharged = totalNonRefundableResourceFeeCharged + totalRefundableResourceFeeCharged` +// // where `resourceFeeCharged` is the overall fee charged for the +// // transaction. Also, `resourceFeeCharged` <= `sorobanData.resourceFee` +// // i.e.we never charge more than the declared resource fee. +// // The inclusion fee for charged the Soroban transaction can be found using +// // the following equation: +// // `result.feeCharged = resourceFeeCharged + inclusionFeeCharged`. +// +// // Total amount (in stroops) that has been charged for non-refundable +// // Soroban resources. +// // Non-refundable resources are charged based on the usage declared in +// // the transaction envelope (such as `instructions`, `readBytes` etc.) and +// // is charged regardless of the success of the transaction. +// int64 totalNonRefundableResourceFeeCharged; +// // Total amount (in stroops) that has been charged for refundable +// // Soroban resource fees. +// // Currently this comprises the rent fee (`rentFeeCharged`) and the +// // fee for the events and return value. +// // Refundable resources are charged based on the actual resources usage. +// // Since currently refundable resources are only used for the successful +// // transactions, this will be `0` for failed transactions. +// int64 totalRefundableResourceFeeCharged; +// // Amount (in stroops) that has been charged for rent. +// // This is a part of `totalNonRefundableResourceFeeCharged`. +// int64 rentFeeCharged; // }; -type LedgerCloseMetaExtV1 struct { - Ext ExtensionPoint - SorobanFeeWrite1Kb Int64 +type SorobanTransactionMetaExtV1 struct { + Ext ExtensionPoint + TotalNonRefundableResourceFeeCharged Int64 + TotalRefundableResourceFeeCharged Int64 + RentFeeCharged Int64 } // EncodeTo encodes this value using the Encoder. -func (s *LedgerCloseMetaExtV1) EncodeTo(e *xdr.Encoder) error { +func (s *SorobanTransactionMetaExtV1) EncodeTo(e *xdr.Encoder) error { var err error if err = s.Ext.EncodeTo(e); err != nil { return err } - if err = s.SorobanFeeWrite1Kb.EncodeTo(e); err != nil { + if err = s.TotalNonRefundableResourceFeeCharged.EncodeTo(e); err != nil { return err } - return nil -} - -var _ decoderFrom = (*LedgerCloseMetaExtV1)(nil) - + if err = s.TotalRefundableResourceFeeCharged.EncodeTo(e); err != nil { + return err + } + if err = s.RentFeeCharged.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*SorobanTransactionMetaExtV1)(nil) + // DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseMetaExtV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SorobanTransactionMetaExtV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerCloseMetaExtV1: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanTransactionMetaExtV1: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -18165,7 +18157,17 @@ func (s *LedgerCloseMetaExtV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e if err != nil { return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.SorobanFeeWrite1Kb.DecodeFrom(d, maxDepth) + nTmp, err = s.TotalNonRefundableResourceFeeCharged.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.TotalRefundableResourceFeeCharged.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.RentFeeCharged.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Int64: %w", err) @@ -18174,7 +18176,7 @@ func (s *LedgerCloseMetaExtV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, e } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMetaExtV1) MarshalBinary() ([]byte, error) { +func (s SorobanTransactionMetaExtV1) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -18182,7 +18184,7 @@ func (s LedgerCloseMetaExtV1) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMetaExtV1) UnmarshalBinary(inp []byte) error { +func (s *SorobanTransactionMetaExtV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -18192,38 +18194,38 @@ func (s *LedgerCloseMetaExtV1) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMetaExtV1)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaExtV1)(nil) + _ encoding.BinaryMarshaler = (*SorobanTransactionMetaExtV1)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanTransactionMetaExtV1)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerCloseMetaExtV1) xdrType() {} +func (s SorobanTransactionMetaExtV1) xdrType() {} -var _ xdrType = (*LedgerCloseMetaExtV1)(nil) +var _ xdrType = (*SorobanTransactionMetaExtV1)(nil) -// LedgerCloseMetaExt is an XDR Union defines as: +// SorobanTransactionMetaExt is an XDR Union defines as: // -// union LedgerCloseMetaExt switch (int v) +// union SorobanTransactionMetaExt switch (int v) // { // case 0: // void; // case 1: -// LedgerCloseMetaExtV1 v1; +// SorobanTransactionMetaExtV1 v1; // }; -type LedgerCloseMetaExt struct { +type SorobanTransactionMetaExt struct { V int32 - V1 *LedgerCloseMetaExtV1 + V1 *SorobanTransactionMetaExtV1 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u LedgerCloseMetaExt) SwitchFieldName() string { +func (u SorobanTransactionMetaExt) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of LedgerCloseMetaExt -func (u LedgerCloseMetaExt) ArmForSwitch(sw int32) (string, bool) { +// the value for an instance of SorobanTransactionMetaExt +func (u SorobanTransactionMetaExt) ArmForSwitch(sw int32) (string, bool) { switch int32(sw) { case 0: return "", true @@ -18233,16 +18235,16 @@ func (u LedgerCloseMetaExt) ArmForSwitch(sw int32) (string, bool) { return "-", false } -// NewLedgerCloseMetaExt creates a new LedgerCloseMetaExt. -func NewLedgerCloseMetaExt(v int32, value interface{}) (result LedgerCloseMetaExt, err error) { +// NewSorobanTransactionMetaExt creates a new SorobanTransactionMetaExt. +func NewSorobanTransactionMetaExt(v int32, value interface{}) (result SorobanTransactionMetaExt, err error) { result.V = v switch int32(v) { case 0: // void case 1: - tv, ok := value.(LedgerCloseMetaExtV1) + tv, ok := value.(SorobanTransactionMetaExtV1) if !ok { - err = errors.New("invalid value, must be LedgerCloseMetaExtV1") + err = errors.New("invalid value, must be SorobanTransactionMetaExtV1") return } result.V1 = &tv @@ -18252,7 +18254,7 @@ func NewLedgerCloseMetaExt(v int32, value interface{}) (result LedgerCloseMetaEx // MustV1 retrieves the V1 value from the union, // panicing if the value is not set. -func (u LedgerCloseMetaExt) MustV1() LedgerCloseMetaExtV1 { +func (u SorobanTransactionMetaExt) MustV1() SorobanTransactionMetaExtV1 { val, ok := u.GetV1() if !ok { @@ -18264,7 +18266,7 @@ func (u LedgerCloseMetaExt) MustV1() LedgerCloseMetaExtV1 { // GetV1 retrieves the V1 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerCloseMetaExt) GetV1() (result LedgerCloseMetaExtV1, ok bool) { +func (u SorobanTransactionMetaExt) GetV1() (result SorobanTransactionMetaExtV1, ok bool) { armName, _ := u.ArmForSwitch(int32(u.V)) if armName == "V1" { @@ -18276,7 +18278,7 @@ func (u LedgerCloseMetaExt) GetV1() (result LedgerCloseMetaExtV1, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u LedgerCloseMetaExt) EncodeTo(e *xdr.Encoder) error { +func (u SorobanTransactionMetaExt) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeInt(int32(u.V)); err != nil { return err @@ -18291,15 +18293,15 @@ func (u LedgerCloseMetaExt) EncodeTo(e *xdr.Encoder) error { } return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerCloseMetaExt", u.V) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union SorobanTransactionMetaExt", u.V) } -var _ decoderFrom = (*LedgerCloseMetaExt)(nil) +var _ decoderFrom = (*SorobanTransactionMetaExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerCloseMetaExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *SorobanTransactionMetaExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerCloseMetaExt: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanTransactionMetaExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -18314,19 +18316,19 @@ func (u *LedgerCloseMetaExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err // Void return n, nil case 1: - u.V1 = new(LedgerCloseMetaExtV1) + u.V1 = new(SorobanTransactionMetaExtV1) nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaExtV1: %w", err) + return n, fmt.Errorf("decoding SorobanTransactionMetaExtV1: %w", err) } return n, nil } - return n, fmt.Errorf("union LedgerCloseMetaExt has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union SorobanTransactionMetaExt has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMetaExt) MarshalBinary() ([]byte, error) { +func (s SorobanTransactionMetaExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -18334,7 +18336,7 @@ func (s LedgerCloseMetaExt) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMetaExt) UnmarshalBinary(inp []byte) error { +func (s *SorobanTransactionMetaExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -18344,123 +18346,71 @@ func (s *LedgerCloseMetaExt) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMetaExt)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaExt)(nil) + _ encoding.BinaryMarshaler = (*SorobanTransactionMetaExt)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanTransactionMetaExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerCloseMetaExt) xdrType() {} +func (s SorobanTransactionMetaExt) xdrType() {} -var _ xdrType = (*LedgerCloseMetaExt)(nil) +var _ xdrType = (*SorobanTransactionMetaExt)(nil) -// LedgerCloseMetaV1 is an XDR Struct defines as: +// SorobanTransactionMeta is an XDR Struct defines as: // -// struct LedgerCloseMetaV1 +// struct SorobanTransactionMeta // { -// LedgerCloseMetaExt ext; -// -// LedgerHeaderHistoryEntry ledgerHeader; -// -// GeneralizedTransactionSet txSet; -// -// // NB: transactions are sorted in apply order here -// // fees for all transactions are processed first -// // followed by applying transactions -// TransactionResultMeta txProcessing<>; -// -// // upgrades are applied last -// UpgradeEntryMeta upgradesProcessing<>; -// -// // other misc information attached to the ledger close -// SCPHistoryEntry scpInfo<>; -// -// // Size in bytes of BucketList, to support downstream -// // systems calculating storage fees correctly. -// uint64 totalByteSizeOfBucketList; +// SorobanTransactionMetaExt ext; // -// // Temp keys that are being evicted at this ledger. -// LedgerKey evictedTemporaryLedgerKeys<>; +// ContractEvent events<>; // custom events populated by the +// // contracts themselves. +// SCVal returnValue; // return value of the host fn invocation // -// // Archived restorable ledger entries that are being -// // evicted at this ledger. -// LedgerEntry evictedPersistentLedgerEntries<>; +// // Diagnostics events that are not hashed. +// // This will contain all contract and diagnostic events. Even ones +// // that were emitted in a failed contract call. +// DiagnosticEvent diagnosticEvents<>; // }; -type LedgerCloseMetaV1 struct { - Ext LedgerCloseMetaExt - LedgerHeader LedgerHeaderHistoryEntry - TxSet GeneralizedTransactionSet - TxProcessing []TransactionResultMeta - UpgradesProcessing []UpgradeEntryMeta - ScpInfo []ScpHistoryEntry - TotalByteSizeOfBucketList Uint64 - EvictedTemporaryLedgerKeys []LedgerKey - EvictedPersistentLedgerEntries []LedgerEntry +type SorobanTransactionMeta struct { + Ext SorobanTransactionMetaExt + Events []ContractEvent + ReturnValue ScVal + DiagnosticEvents []DiagnosticEvent } // EncodeTo encodes this value using the Encoder. -func (s *LedgerCloseMetaV1) EncodeTo(e *xdr.Encoder) error { +func (s *SorobanTransactionMeta) EncodeTo(e *xdr.Encoder) error { var err error if err = s.Ext.EncodeTo(e); err != nil { return err } - if err = s.LedgerHeader.EncodeTo(e); err != nil { - return err - } - if err = s.TxSet.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.TxProcessing))); err != nil { - return err - } - for i := 0; i < len(s.TxProcessing); i++ { - if err = s.TxProcessing[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.UpgradesProcessing))); err != nil { - return err - } - for i := 0; i < len(s.UpgradesProcessing); i++ { - if err = s.UpgradesProcessing[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.ScpInfo))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Events))); err != nil { return err } - for i := 0; i < len(s.ScpInfo); i++ { - if err = s.ScpInfo[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.Events); i++ { + if err = s.Events[i].EncodeTo(e); err != nil { return err } } - if err = s.TotalByteSizeOfBucketList.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.EvictedTemporaryLedgerKeys))); err != nil { + if err = s.ReturnValue.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.EvictedTemporaryLedgerKeys); i++ { - if err = s.EvictedTemporaryLedgerKeys[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.EvictedPersistentLedgerEntries))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.DiagnosticEvents))); err != nil { return err } - for i := 0; i < len(s.EvictedPersistentLedgerEntries); i++ { - if err = s.EvictedPersistentLedgerEntries[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.DiagnosticEvents); i++ { + if err = s.DiagnosticEvents[i].EncodeTo(e); err != nil { return err } } return nil } -var _ decoderFrom = (*LedgerCloseMetaV1)(nil) +var _ decoderFrom = (*SorobanTransactionMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SorobanTransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerCloseMetaV1: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanTransactionMeta: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -18468,116 +18418,288 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaExt: %w", err) - } - nTmp, err = s.LedgerHeader.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", err) - } - nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) + return n, fmt.Errorf("decoding SorobanTransactionMetaExt: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } - s.TxProcessing = nil + s.Events = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) } - s.TxProcessing = make([]TransactionResultMeta, l) + s.Events = make([]ContractEvent, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } } } + nTmp, err = s.ReturnValue.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %w", err) + } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) } - s.UpgradesProcessing = nil + s.DiagnosticEvents = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding DiagnosticEvent: length (%d) exceeds remaining input length (%d)", l, il) } - s.UpgradesProcessing = make([]UpgradeEntryMeta, l) + s.DiagnosticEvents = make([]DiagnosticEvent, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) + nTmp, err = s.DiagnosticEvents[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %w", err) } } } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s SorobanTransactionMeta) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SorobanTransactionMeta) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SorobanTransactionMeta)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanTransactionMeta)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s SorobanTransactionMeta) xdrType() {} + +var _ xdrType = (*SorobanTransactionMeta)(nil) + +// TransactionMetaV3 is an XDR Struct defines as: +// +// struct TransactionMetaV3 +// { +// ExtensionPoint ext; +// +// LedgerEntryChanges txChangesBefore; // tx level changes before operations +// // are applied if any +// OperationMeta operations<>; // meta for each operation +// LedgerEntryChanges txChangesAfter; // tx level changes after operations are +// // applied if any +// SorobanTransactionMeta* sorobanMeta; // Soroban-specific meta (only for +// // Soroban transactions). +// }; +type TransactionMetaV3 struct { + Ext ExtensionPoint + TxChangesBefore LedgerEntryChanges + Operations []OperationMeta + TxChangesAfter LedgerEntryChanges + SorobanMeta *SorobanTransactionMeta +} + +// EncodeTo encodes this value using the Encoder. +func (s *TransactionMetaV3) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Ext.EncodeTo(e); err != nil { + return err + } + if err = s.TxChangesBefore.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.Operations))); err != nil { + return err + } + for i := 0; i < len(s.Operations); i++ { + if err = s.Operations[i].EncodeTo(e); err != nil { + return err + } + } + if err = s.TxChangesAfter.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeBool(s.SorobanMeta != nil); err != nil { + return err + } + if s.SorobanMeta != nil { + if err = (*s.SorobanMeta).EncodeTo(e); err != nil { + return err + } + } + return nil +} + +var _ decoderFrom = (*TransactionMetaV3)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *TransactionMetaV3) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TransactionMetaV3: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) + } + nTmp, err = s.TxChangesBefore.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) + } + var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } - s.ScpInfo = nil + s.Operations = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) } - s.ScpInfo = make([]ScpHistoryEntry, l) + s.Operations = make([]OperationMeta, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Operations[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) } } } - nTmp, err = s.TotalByteSizeOfBucketList.DecodeFrom(d, maxDepth) + nTmp, err = s.TxChangesAfter.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } - l, nTmp, err = d.DecodeUint() + var b bool + b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) + return n, fmt.Errorf("decoding SorobanTransactionMeta: %w", err) } - s.EvictedTemporaryLedgerKeys = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + s.SorobanMeta = nil + if b { + s.SorobanMeta = new(SorobanTransactionMeta) + nTmp, err = s.SorobanMeta.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanTransactionMeta: %w", err) } - s.EvictedTemporaryLedgerKeys = make([]LedgerKey, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.EvictedTemporaryLedgerKeys[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) - } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TransactionMetaV3) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TransactionMetaV3) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*TransactionMetaV3)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionMetaV3)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s TransactionMetaV3) xdrType() {} + +var _ xdrType = (*TransactionMetaV3)(nil) + +// InvokeHostFunctionSuccessPreImage is an XDR Struct defines as: +// +// struct InvokeHostFunctionSuccessPreImage +// { +// SCVal returnValue; +// ContractEvent events<>; +// }; +type InvokeHostFunctionSuccessPreImage struct { + ReturnValue ScVal + Events []ContractEvent +} + +// EncodeTo encodes this value using the Encoder. +func (s *InvokeHostFunctionSuccessPreImage) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.ReturnValue.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.Events))); err != nil { + return err + } + for i := 0; i < len(s.Events); i++ { + if err = s.Events[i].EncodeTo(e); err != nil { + return err } } + return nil +} + +var _ decoderFrom = (*InvokeHostFunctionSuccessPreImage)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *InvokeHostFunctionSuccessPreImage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding InvokeHostFunctionSuccessPreImage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.ReturnValue.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %w", err) + } + var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %w", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } - s.EvictedPersistentLedgerEntries = nil + s.Events = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding LedgerEntry: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding ContractEvent: length (%d) exceeds remaining input length (%d)", l, il) } - s.EvictedPersistentLedgerEntries = make([]LedgerEntry, l) + s.Events = make([]ContractEvent, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.EvictedPersistentLedgerEntries[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Events[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerEntry: %w", err) + return n, fmt.Errorf("decoding ContractEvent: %w", err) } } } @@ -18585,7 +18707,7 @@ func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMetaV1) MarshalBinary() ([]byte, error) { +func (s InvokeHostFunctionSuccessPreImage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -18593,7 +18715,7 @@ func (s LedgerCloseMetaV1) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMetaV1) UnmarshalBinary(inp []byte) error { +func (s *InvokeHostFunctionSuccessPreImage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -18603,89 +18725,113 @@ func (s *LedgerCloseMetaV1) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMetaV1)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV1)(nil) + _ encoding.BinaryMarshaler = (*InvokeHostFunctionSuccessPreImage)(nil) + _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionSuccessPreImage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerCloseMetaV1) xdrType() {} +func (s InvokeHostFunctionSuccessPreImage) xdrType() {} -var _ xdrType = (*LedgerCloseMetaV1)(nil) +var _ xdrType = (*InvokeHostFunctionSuccessPreImage)(nil) -// LedgerCloseMeta is an XDR Union defines as: +// TransactionMeta is an XDR Union defines as: // -// union LedgerCloseMeta switch (int v) +// union TransactionMeta switch (int v) // { // case 0: -// LedgerCloseMetaV0 v0; +// OperationMeta operations<>; // case 1: -// LedgerCloseMetaV1 v1; +// TransactionMetaV1 v1; +// case 2: +// TransactionMetaV2 v2; +// case 3: +// TransactionMetaV3 v3; // }; -type LedgerCloseMeta struct { - V int32 - V0 *LedgerCloseMetaV0 - V1 *LedgerCloseMetaV1 +type TransactionMeta struct { + V int32 + Operations *[]OperationMeta + V1 *TransactionMetaV1 + V2 *TransactionMetaV2 + V3 *TransactionMetaV3 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u LedgerCloseMeta) SwitchFieldName() string { +func (u TransactionMeta) SwitchFieldName() string { return "V" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of LedgerCloseMeta -func (u LedgerCloseMeta) ArmForSwitch(sw int32) (string, bool) { +// the value for an instance of TransactionMeta +func (u TransactionMeta) ArmForSwitch(sw int32) (string, bool) { switch int32(sw) { case 0: - return "V0", true + return "Operations", true case 1: return "V1", true + case 2: + return "V2", true + case 3: + return "V3", true } return "-", false } -// NewLedgerCloseMeta creates a new LedgerCloseMeta. -func NewLedgerCloseMeta(v int32, value interface{}) (result LedgerCloseMeta, err error) { +// NewTransactionMeta creates a new TransactionMeta. +func NewTransactionMeta(v int32, value interface{}) (result TransactionMeta, err error) { result.V = v switch int32(v) { case 0: - tv, ok := value.(LedgerCloseMetaV0) + tv, ok := value.([]OperationMeta) if !ok { - err = errors.New("invalid value, must be LedgerCloseMetaV0") + err = errors.New("invalid value, must be []OperationMeta") return } - result.V0 = &tv + result.Operations = &tv case 1: - tv, ok := value.(LedgerCloseMetaV1) + tv, ok := value.(TransactionMetaV1) if !ok { - err = errors.New("invalid value, must be LedgerCloseMetaV1") + err = errors.New("invalid value, must be TransactionMetaV1") return } result.V1 = &tv + case 2: + tv, ok := value.(TransactionMetaV2) + if !ok { + err = errors.New("invalid value, must be TransactionMetaV2") + return + } + result.V2 = &tv + case 3: + tv, ok := value.(TransactionMetaV3) + if !ok { + err = errors.New("invalid value, must be TransactionMetaV3") + return + } + result.V3 = &tv } return } -// MustV0 retrieves the V0 value from the union, +// MustOperations retrieves the Operations value from the union, // panicing if the value is not set. -func (u LedgerCloseMeta) MustV0() LedgerCloseMetaV0 { - val, ok := u.GetV0() +func (u TransactionMeta) MustOperations() []OperationMeta { + val, ok := u.GetOperations() if !ok { - panic("arm V0 is not set") + panic("arm Operations is not set") } return val } -// GetV0 retrieves the V0 value from the union, +// GetOperations retrieves the Operations value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerCloseMeta) GetV0() (result LedgerCloseMetaV0, ok bool) { +func (u TransactionMeta) GetOperations() (result []OperationMeta, ok bool) { armName, _ := u.ArmForSwitch(int32(u.V)) - if armName == "V0" { - result = *u.V0 + if armName == "Operations" { + result = *u.Operations ok = true } @@ -18694,7 +18840,7 @@ func (u LedgerCloseMeta) GetV0() (result LedgerCloseMetaV0, ok bool) { // MustV1 retrieves the V1 value from the union, // panicing if the value is not set. -func (u LedgerCloseMeta) MustV1() LedgerCloseMetaV1 { +func (u TransactionMeta) MustV1() TransactionMetaV1 { val, ok := u.GetV1() if !ok { @@ -18706,7 +18852,7 @@ func (u LedgerCloseMeta) MustV1() LedgerCloseMetaV1 { // GetV1 retrieves the V1 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LedgerCloseMeta) GetV1() (result LedgerCloseMetaV1, ok bool) { +func (u TransactionMeta) GetV1() (result TransactionMetaV1, ok bool) { armName, _ := u.ArmForSwitch(int32(u.V)) if armName == "V1" { @@ -18717,33 +18863,98 @@ func (u LedgerCloseMeta) GetV1() (result LedgerCloseMetaV1, ok bool) { return } +// MustV2 retrieves the V2 value from the union, +// panicing if the value is not set. +func (u TransactionMeta) MustV2() TransactionMetaV2 { + val, ok := u.GetV2() + + if !ok { + panic("arm V2 is not set") + } + + return val +} + +// GetV2 retrieves the V2 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u TransactionMeta) GetV2() (result TransactionMetaV2, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "V2" { + result = *u.V2 + ok = true + } + + return +} + +// MustV3 retrieves the V3 value from the union, +// panicing if the value is not set. +func (u TransactionMeta) MustV3() TransactionMetaV3 { + val, ok := u.GetV3() + + if !ok { + panic("arm V3 is not set") + } + + return val +} + +// GetV3 retrieves the V3 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u TransactionMeta) GetV3() (result TransactionMetaV3, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "V3" { + result = *u.V3 + ok = true + } + + return +} + // EncodeTo encodes this value using the Encoder. -func (u LedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { +func (u TransactionMeta) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } switch int32(u.V) { case 0: - if err = (*u.V0).EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len((*u.Operations)))); err != nil { return err } + for i := 0; i < len((*u.Operations)); i++ { + if err = (*u.Operations)[i].EncodeTo(e); err != nil { + return err + } + } return nil case 1: if err = (*u.V1).EncodeTo(e); err != nil { return err } return nil + case 2: + if err = (*u.V2).EncodeTo(e); err != nil { + return err + } + return nil + case 3: + if err = (*u.V3).EncodeTo(e); err != nil { + return err + } + return nil } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerCloseMeta", u.V) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionMeta", u.V) } -var _ decoderFrom = (*LedgerCloseMeta)(nil) +var _ decoderFrom = (*TransactionMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *LedgerCloseMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *TransactionMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerCloseMeta: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionMeta: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -18755,27 +18966,58 @@ func (u *LedgerCloseMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } switch int32(u.V) { case 0: - u.V0 = new(LedgerCloseMetaV0) - nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) + u.Operations = new([]OperationMeta) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaV0: %w", err) + return n, fmt.Errorf("decoding OperationMeta: %w", err) + } + (*u.Operations) = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding OperationMeta: length (%d) exceeds remaining input length (%d)", l, il) + } + (*u.Operations) = make([]OperationMeta, l) + for i := uint32(0); i < l; i++ { + nTmp, err = (*u.Operations)[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding OperationMeta: %w", err) + } + } } return n, nil case 1: - u.V1 = new(LedgerCloseMetaV1) + u.V1 = new(TransactionMetaV1) nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaV1: %w", err) + return n, fmt.Errorf("decoding TransactionMetaV1: %w", err) + } + return n, nil + case 2: + u.V2 = new(TransactionMetaV2) + nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionMetaV2: %w", err) + } + return n, nil + case 3: + u.V3 = new(TransactionMetaV3) + nTmp, err = (*u.V3).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionMetaV3: %w", err) } return n, nil } - return n, fmt.Errorf("union LedgerCloseMeta has invalid V (int32) switch value '%d'", u.V) + return n, fmt.Errorf("union TransactionMeta has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMeta) MarshalBinary() ([]byte, error) { +func (s TransactionMeta) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -18783,7 +19025,7 @@ func (s LedgerCloseMeta) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMeta) UnmarshalBinary(inp []byte) error { +func (s *TransactionMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -18793,86 +19035,74 @@ func (s *LedgerCloseMeta) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMeta)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMeta)(nil) + _ encoding.BinaryMarshaler = (*TransactionMeta)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionMeta)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerCloseMeta) xdrType() {} +func (s TransactionMeta) xdrType() {} -var _ xdrType = (*LedgerCloseMeta)(nil) +var _ xdrType = (*TransactionMeta)(nil) -// ErrorCode is an XDR Enum defines as: +// TransactionResultMeta is an XDR Struct defines as: // -// enum ErrorCode +// struct TransactionResultMeta // { -// ERR_MISC = 0, // Unspecific error -// ERR_DATA = 1, // Malformed data -// ERR_CONF = 2, // Misconfiguration error -// ERR_AUTH = 3, // Authentication failure -// ERR_LOAD = 4 // System overloaded +// TransactionResultPair result; +// LedgerEntryChanges feeProcessing; +// TransactionMeta txApplyProcessing; // }; -type ErrorCode int32 - -const ( - ErrorCodeErrMisc ErrorCode = 0 - ErrorCodeErrData ErrorCode = 1 - ErrorCodeErrConf ErrorCode = 2 - ErrorCodeErrAuth ErrorCode = 3 - ErrorCodeErrLoad ErrorCode = 4 -) - -var errorCodeMap = map[int32]string{ - 0: "ErrorCodeErrMisc", - 1: "ErrorCodeErrData", - 2: "ErrorCodeErrConf", - 3: "ErrorCodeErrAuth", - 4: "ErrorCodeErrLoad", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ErrorCode -func (e ErrorCode) ValidEnum(v int32) bool { - _, ok := errorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ErrorCode) String() string { - name, _ := errorCodeMap[int32(e)] - return name +type TransactionResultMeta struct { + Result TransactionResultPair + FeeProcessing LedgerEntryChanges + TxApplyProcessing TransactionMeta } // EncodeTo encodes this value using the Encoder. -func (e ErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := errorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ErrorCode enum value", e) +func (s *TransactionResultMeta) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Result.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + if err = s.FeeProcessing.EncodeTo(e); err != nil { + return err + } + if err = s.TxApplyProcessing.EncodeTo(e); err != nil { + return err + } + return nil } -var _ decoderFrom = (*ErrorCode)(nil) +var _ decoderFrom = (*TransactionResultMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ErrorCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TransactionResultMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ErrorCode: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TransactionResultMeta: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = s.Result.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding ErrorCode: %w", err) + return n, fmt.Errorf("decoding TransactionResultPair: %w", err) } - if _, ok := errorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ErrorCode enum value", v) + nTmp, err = s.FeeProcessing.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) + } + nTmp, err = s.TxApplyProcessing.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionMeta: %w", err) } - *e = ErrorCode(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ErrorCode) MarshalBinary() ([]byte, error) { +func (s TransactionResultMeta) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -18880,7 +19110,7 @@ func (s ErrorCode) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ErrorCode) UnmarshalBinary(inp []byte) error { +func (s *TransactionResultMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -18890,64 +19120,64 @@ func (s *ErrorCode) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ErrorCode)(nil) + _ encoding.BinaryMarshaler = (*TransactionResultMeta)(nil) + _ encoding.BinaryUnmarshaler = (*TransactionResultMeta)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ErrorCode) xdrType() {} +func (s TransactionResultMeta) xdrType() {} -var _ xdrType = (*ErrorCode)(nil) +var _ xdrType = (*TransactionResultMeta)(nil) -// Error is an XDR Struct defines as: +// UpgradeEntryMeta is an XDR Struct defines as: // -// struct Error +// struct UpgradeEntryMeta // { -// ErrorCode code; -// string msg<100>; +// LedgerUpgrade upgrade; +// LedgerEntryChanges changes; // }; -type Error struct { - Code ErrorCode - Msg string `xdrmaxsize:"100"` +type UpgradeEntryMeta struct { + Upgrade LedgerUpgrade + Changes LedgerEntryChanges } // EncodeTo encodes this value using the Encoder. -func (s *Error) EncodeTo(e *xdr.Encoder) error { +func (s *UpgradeEntryMeta) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Code.EncodeTo(e); err != nil { + if err = s.Upgrade.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeString(string(s.Msg)); err != nil { + if err = s.Changes.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*Error)(nil) +var _ decoderFrom = (*UpgradeEntryMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Error) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *UpgradeEntryMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding Error: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding UpgradeEntryMeta: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Code.DecodeFrom(d, maxDepth) + nTmp, err = s.Upgrade.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ErrorCode: %w", err) + return n, fmt.Errorf("decoding LedgerUpgrade: %w", err) } - s.Msg, nTmp, err = d.DecodeString(100) + nTmp, err = s.Changes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Msg: %w", err) + return n, fmt.Errorf("decoding LedgerEntryChanges: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s Error) MarshalBinary() ([]byte, error) { +func (s UpgradeEntryMeta) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -18955,7 +19185,7 @@ func (s Error) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *Error) UnmarshalBinary(inp []byte) error { +func (s *UpgradeEntryMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -18965,54 +19195,161 @@ func (s *Error) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*Error)(nil) - _ encoding.BinaryUnmarshaler = (*Error)(nil) + _ encoding.BinaryMarshaler = (*UpgradeEntryMeta)(nil) + _ encoding.BinaryUnmarshaler = (*UpgradeEntryMeta)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s Error) xdrType() {} +func (s UpgradeEntryMeta) xdrType() {} -var _ xdrType = (*Error)(nil) +var _ xdrType = (*UpgradeEntryMeta)(nil) -// SendMore is an XDR Struct defines as: +// LedgerCloseMetaV0 is an XDR Struct defines as: // -// struct SendMore +// struct LedgerCloseMetaV0 // { -// uint32 numMessages; +// LedgerHeaderHistoryEntry ledgerHeader; +// // NB: txSet is sorted in "Hash order" +// TransactionSet txSet; +// +// // NB: transactions are sorted in apply order here +// // fees for all transactions are processed first +// // followed by applying transactions +// TransactionResultMeta txProcessing<>; +// +// // upgrades are applied last +// UpgradeEntryMeta upgradesProcessing<>; +// +// // other misc information attached to the ledger close +// SCPHistoryEntry scpInfo<>; // }; -type SendMore struct { - NumMessages Uint32 +type LedgerCloseMetaV0 struct { + LedgerHeader LedgerHeaderHistoryEntry + TxSet TransactionSet + TxProcessing []TransactionResultMeta + UpgradesProcessing []UpgradeEntryMeta + ScpInfo []ScpHistoryEntry } // EncodeTo encodes this value using the Encoder. -func (s *SendMore) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerCloseMetaV0) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.NumMessages.EncodeTo(e); err != nil { + if err = s.LedgerHeader.EncodeTo(e); err != nil { + return err + } + if err = s.TxSet.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.TxProcessing))); err != nil { + return err + } + for i := 0; i < len(s.TxProcessing); i++ { + if err = s.TxProcessing[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.UpgradesProcessing))); err != nil { + return err + } + for i := 0; i < len(s.UpgradesProcessing); i++ { + if err = s.UpgradesProcessing[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.ScpInfo))); err != nil { return err } + for i := 0; i < len(s.ScpInfo); i++ { + if err = s.ScpInfo[i].EncodeTo(e); err != nil { + return err + } + } return nil } -var _ decoderFrom = (*SendMore)(nil) +var _ decoderFrom = (*LedgerCloseMetaV0)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SendMore) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerCloseMetaV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SendMore: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerCloseMetaV0: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NumMessages.DecodeFrom(d, maxDepth) + nTmp, err = s.LedgerHeader.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", err) + } + nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionSet: %w", err) + } + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) + } + s.TxProcessing = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) + } + s.TxProcessing = make([]TransactionResultMeta, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) + } + s.UpgradesProcessing = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) + } + s.UpgradesProcessing = make([]UpgradeEntryMeta, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) + } + s.ScpInfo = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) + } + s.ScpInfo = make([]ScpHistoryEntry, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) + } + } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SendMore) MarshalBinary() ([]byte, error) { +func (s LedgerCloseMetaV0) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -19020,7 +19357,7 @@ func (s SendMore) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SendMore) UnmarshalBinary(inp []byte) error { +func (s *LedgerCloseMetaV0) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -19030,64 +19367,64 @@ func (s *SendMore) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SendMore)(nil) - _ encoding.BinaryUnmarshaler = (*SendMore)(nil) + _ encoding.BinaryMarshaler = (*LedgerCloseMetaV0)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV0)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SendMore) xdrType() {} +func (s LedgerCloseMetaV0) xdrType() {} -var _ xdrType = (*SendMore)(nil) +var _ xdrType = (*LedgerCloseMetaV0)(nil) -// SendMoreExtended is an XDR Struct defines as: +// LedgerCloseMetaExtV1 is an XDR Struct defines as: // -// struct SendMoreExtended +// struct LedgerCloseMetaExtV1 // { -// uint32 numMessages; -// uint32 numBytes; +// ExtensionPoint ext; +// int64 sorobanFeeWrite1KB; // }; -type SendMoreExtended struct { - NumMessages Uint32 - NumBytes Uint32 +type LedgerCloseMetaExtV1 struct { + Ext ExtensionPoint + SorobanFeeWrite1Kb Int64 } // EncodeTo encodes this value using the Encoder. -func (s *SendMoreExtended) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerCloseMetaExtV1) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.NumMessages.EncodeTo(e); err != nil { + if err = s.Ext.EncodeTo(e); err != nil { return err } - if err = s.NumBytes.EncodeTo(e); err != nil { + if err = s.SorobanFeeWrite1Kb.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*SendMoreExtended)(nil) +var _ decoderFrom = (*LedgerCloseMetaExtV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SendMoreExtended) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerCloseMetaExtV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SendMoreExtended: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerCloseMetaExtV1: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NumMessages.DecodeFrom(d, maxDepth) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - nTmp, err = s.NumBytes.DecodeFrom(d, maxDepth) + nTmp, err = s.SorobanFeeWrite1Kb.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SendMoreExtended) MarshalBinary() ([]byte, error) { +func (s LedgerCloseMetaExtV1) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -19095,7 +19432,7 @@ func (s SendMoreExtended) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SendMoreExtended) UnmarshalBinary(inp []byte) error { +func (s *LedgerCloseMetaExtV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -19105,74 +19442,141 @@ func (s *SendMoreExtended) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SendMoreExtended)(nil) - _ encoding.BinaryUnmarshaler = (*SendMoreExtended)(nil) + _ encoding.BinaryMarshaler = (*LedgerCloseMetaExtV1)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaExtV1)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SendMoreExtended) xdrType() {} +func (s LedgerCloseMetaExtV1) xdrType() {} -var _ xdrType = (*SendMoreExtended)(nil) +var _ xdrType = (*LedgerCloseMetaExtV1)(nil) -// AuthCert is an XDR Struct defines as: +// LedgerCloseMetaExt is an XDR Union defines as: // -// struct AuthCert +// union LedgerCloseMetaExt switch (int v) // { -// Curve25519Public pubkey; -// uint64 expiration; -// Signature sig; +// case 0: +// void; +// case 1: +// LedgerCloseMetaExtV1 v1; // }; -type AuthCert struct { - Pubkey Curve25519Public - Expiration Uint64 - Sig Signature +type LedgerCloseMetaExt struct { + V int32 + V1 *LedgerCloseMetaExtV1 +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u LedgerCloseMetaExt) SwitchFieldName() string { + return "V" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of LedgerCloseMetaExt +func (u LedgerCloseMetaExt) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: + return "", true + case 1: + return "V1", true + } + return "-", false +} + +// NewLedgerCloseMetaExt creates a new LedgerCloseMetaExt. +func NewLedgerCloseMetaExt(v int32, value interface{}) (result LedgerCloseMetaExt, err error) { + result.V = v + switch int32(v) { + case 0: + // void + case 1: + tv, ok := value.(LedgerCloseMetaExtV1) + if !ok { + err = errors.New("invalid value, must be LedgerCloseMetaExtV1") + return + } + result.V1 = &tv + } + return +} + +// MustV1 retrieves the V1 value from the union, +// panicing if the value is not set. +func (u LedgerCloseMetaExt) MustV1() LedgerCloseMetaExtV1 { + val, ok := u.GetV1() + + if !ok { + panic("arm V1 is not set") + } + + return val +} + +// GetV1 retrieves the V1 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerCloseMetaExt) GetV1() (result LedgerCloseMetaExtV1, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "V1" { + result = *u.V1 + ok = true + } + + return } // EncodeTo encodes this value using the Encoder. -func (s *AuthCert) EncodeTo(e *xdr.Encoder) error { +func (u LedgerCloseMetaExt) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Pubkey.EncodeTo(e); err != nil { - return err - } - if err = s.Expiration.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } - if err = s.Sig.EncodeTo(e); err != nil { - return err + switch int32(u.V) { + case 0: + // Void + return nil + case 1: + if err = (*u.V1).EncodeTo(e); err != nil { + return err + } + return nil } - return nil + return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerCloseMetaExt", u.V) } -var _ decoderFrom = (*AuthCert)(nil) +var _ decoderFrom = (*LedgerCloseMetaExt)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AuthCert) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *LedgerCloseMetaExt) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding AuthCert: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerCloseMetaExt: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Pubkey.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Curve25519Public: %w", err) - } - nTmp, err = s.Expiration.DecodeFrom(d, maxDepth) + u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - nTmp, err = s.Sig.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + switch int32(u.V) { + case 0: + // Void + return n, nil + case 1: + u.V1 = new(LedgerCloseMetaExtV1) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerCloseMetaExtV1: %w", err) + } + return n, nil } - return n, nil + return n, fmt.Errorf("union LedgerCloseMetaExt has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s AuthCert) MarshalBinary() ([]byte, error) { +func (s LedgerCloseMetaExt) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -19180,7 +19584,7 @@ func (s AuthCert) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *AuthCert) UnmarshalBinary(inp []byte) error { +func (s *LedgerCloseMetaExt) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -19190,134 +19594,248 @@ func (s *AuthCert) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*AuthCert)(nil) - _ encoding.BinaryUnmarshaler = (*AuthCert)(nil) + _ encoding.BinaryMarshaler = (*LedgerCloseMetaExt)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaExt)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s AuthCert) xdrType() {} +func (s LedgerCloseMetaExt) xdrType() {} -var _ xdrType = (*AuthCert)(nil) +var _ xdrType = (*LedgerCloseMetaExt)(nil) -// Hello is an XDR Struct defines as: +// LedgerCloseMetaV1 is an XDR Struct defines as: // -// struct Hello +// struct LedgerCloseMetaV1 // { -// uint32 ledgerVersion; -// uint32 overlayVersion; -// uint32 overlayMinVersion; -// Hash networkID; -// string versionStr<100>; -// int listeningPort; -// NodeID peerID; -// AuthCert cert; -// uint256 nonce; +// LedgerCloseMetaExt ext; +// +// LedgerHeaderHistoryEntry ledgerHeader; +// +// GeneralizedTransactionSet txSet; +// +// // NB: transactions are sorted in apply order here +// // fees for all transactions are processed first +// // followed by applying transactions +// TransactionResultMeta txProcessing<>; +// +// // upgrades are applied last +// UpgradeEntryMeta upgradesProcessing<>; +// +// // other misc information attached to the ledger close +// SCPHistoryEntry scpInfo<>; +// +// // Size in bytes of BucketList, to support downstream +// // systems calculating storage fees correctly. +// uint64 totalByteSizeOfBucketList; +// +// // Temp keys that are being evicted at this ledger. +// LedgerKey evictedTemporaryLedgerKeys<>; +// +// // Archived restorable ledger entries that are being +// // evicted at this ledger. +// LedgerEntry evictedPersistentLedgerEntries<>; // }; -type Hello struct { - LedgerVersion Uint32 - OverlayVersion Uint32 - OverlayMinVersion Uint32 - NetworkId Hash - VersionStr string `xdrmaxsize:"100"` - ListeningPort int32 - PeerId NodeId - Cert AuthCert - Nonce Uint256 +type LedgerCloseMetaV1 struct { + Ext LedgerCloseMetaExt + LedgerHeader LedgerHeaderHistoryEntry + TxSet GeneralizedTransactionSet + TxProcessing []TransactionResultMeta + UpgradesProcessing []UpgradeEntryMeta + ScpInfo []ScpHistoryEntry + TotalByteSizeOfBucketList Uint64 + EvictedTemporaryLedgerKeys []LedgerKey + EvictedPersistentLedgerEntries []LedgerEntry } // EncodeTo encodes this value using the Encoder. -func (s *Hello) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerCloseMetaV1) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.LedgerVersion.EncodeTo(e); err != nil { + if err = s.Ext.EncodeTo(e); err != nil { return err } - if err = s.OverlayVersion.EncodeTo(e); err != nil { + if err = s.LedgerHeader.EncodeTo(e); err != nil { return err } - if err = s.OverlayMinVersion.EncodeTo(e); err != nil { + if err = s.TxSet.EncodeTo(e); err != nil { return err } - if err = s.NetworkId.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s.TxProcessing))); err != nil { return err } - if _, err = e.EncodeString(string(s.VersionStr)); err != nil { + for i := 0; i < len(s.TxProcessing); i++ { + if err = s.TxProcessing[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.UpgradesProcessing))); err != nil { return err } - if _, err = e.EncodeInt(int32(s.ListeningPort)); err != nil { + for i := 0; i < len(s.UpgradesProcessing); i++ { + if err = s.UpgradesProcessing[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.ScpInfo))); err != nil { return err } - if err = s.PeerId.EncodeTo(e); err != nil { + for i := 0; i < len(s.ScpInfo); i++ { + if err = s.ScpInfo[i].EncodeTo(e); err != nil { + return err + } + } + if err = s.TotalByteSizeOfBucketList.EncodeTo(e); err != nil { return err } - if err = s.Cert.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s.EvictedTemporaryLedgerKeys))); err != nil { return err } - if err = s.Nonce.EncodeTo(e); err != nil { + for i := 0; i < len(s.EvictedTemporaryLedgerKeys); i++ { + if err = s.EvictedTemporaryLedgerKeys[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.EvictedPersistentLedgerEntries))); err != nil { return err } + for i := 0; i < len(s.EvictedPersistentLedgerEntries); i++ { + if err = s.EvictedPersistentLedgerEntries[i].EncodeTo(e); err != nil { + return err + } + } return nil } -var _ decoderFrom = (*Hello)(nil) +var _ decoderFrom = (*LedgerCloseMetaV1)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Hello) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerCloseMetaV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding Hello: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerCloseMetaV1: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding LedgerCloseMetaExt: %w", err) } - nTmp, err = s.OverlayVersion.DecodeFrom(d, maxDepth) + nTmp, err = s.LedgerHeader.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %w", err) } - nTmp, err = s.OverlayMinVersion.DecodeFrom(d, maxDepth) + nTmp, err = s.TxSet.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) } - nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) } - s.VersionStr, nTmp, err = d.DecodeString(100) + s.TxProcessing = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TransactionResultMeta: length (%d) exceeds remaining input length (%d)", l, il) + } + s.TxProcessing = make([]TransactionResultMeta, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.TxProcessing[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionResultMeta: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding VersionStr: %w", err) + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) } - s.ListeningPort, nTmp, err = d.DecodeInt() + s.UpgradesProcessing = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding UpgradeEntryMeta: length (%d) exceeds remaining input length (%d)", l, il) + } + s.UpgradesProcessing = make([]UpgradeEntryMeta, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding UpgradeEntryMeta: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) } - nTmp, err = s.PeerId.DecodeFrom(d, maxDepth) + s.ScpInfo = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScpHistoryEntry: length (%d) exceeds remaining input length (%d)", l, il) + } + s.ScpInfo = make([]ScpHistoryEntry, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.ScpInfo[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScpHistoryEntry: %w", err) + } + } + } + nTmp, err = s.TotalByteSizeOfBucketList.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %w", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.Cert.DecodeFrom(d, maxDepth) + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding AuthCert: %w", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } - nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + s.EvictedTemporaryLedgerKeys = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + } + s.EvictedTemporaryLedgerKeys = make([]LedgerKey, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.EvictedTemporaryLedgerKeys[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %w", err) + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + s.EvictedPersistentLedgerEntries = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerEntry: length (%d) exceeds remaining input length (%d)", l, il) + } + s.EvictedPersistentLedgerEntries = make([]LedgerEntry, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.EvictedPersistentLedgerEntries[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerEntry: %w", err) + } + } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s Hello) MarshalBinary() ([]byte, error) { +func (s LedgerCloseMetaV1) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -19325,7 +19843,7 @@ func (s Hello) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *Hello) UnmarshalBinary(inp []byte) error { +func (s *LedgerCloseMetaV1) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -19335,272 +19853,114 @@ func (s *Hello) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*Hello)(nil) - _ encoding.BinaryUnmarshaler = (*Hello)(nil) + _ encoding.BinaryMarshaler = (*LedgerCloseMetaV1)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV1)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s Hello) xdrType() {} - -var _ xdrType = (*Hello)(nil) +func (s LedgerCloseMetaV1) xdrType() {} -// AuthMsgFlagFlowControlBytesRequested is an XDR Const defines as: -// -// const AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED = 200; -const AuthMsgFlagFlowControlBytesRequested = 200 +var _ xdrType = (*LedgerCloseMetaV1)(nil) -// Auth is an XDR Struct defines as: +// LedgerCloseMeta is an XDR Union defines as: // -// struct Auth +// union LedgerCloseMeta switch (int v) // { -// int flags; +// case 0: +// LedgerCloseMetaV0 v0; +// case 1: +// LedgerCloseMetaV1 v1; // }; -type Auth struct { - Flags int32 +type LedgerCloseMeta struct { + V int32 + V0 *LedgerCloseMetaV0 + V1 *LedgerCloseMetaV1 } -// EncodeTo encodes this value using the Encoder. -func (s *Auth) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeInt(int32(s.Flags)); err != nil { - return err - } - return nil +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u LedgerCloseMeta) SwitchFieldName() string { + return "V" } -var _ decoderFrom = (*Auth)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *Auth) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding Auth: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - s.Flags, nTmp, err = d.DecodeInt() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int: %w", err) +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of LedgerCloseMeta +func (u LedgerCloseMeta) ArmForSwitch(sw int32) (string, bool) { + switch int32(sw) { + case 0: + return "V0", true + case 1: + return "V1", true } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s Auth) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return "-", false } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *Auth) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err +// NewLedgerCloseMeta creates a new LedgerCloseMeta. +func NewLedgerCloseMeta(v int32, value interface{}) (result LedgerCloseMeta, err error) { + result.V = v + switch int32(v) { + case 0: + tv, ok := value.(LedgerCloseMetaV0) + if !ok { + err = errors.New("invalid value, must be LedgerCloseMetaV0") + return + } + result.V0 = &tv + case 1: + tv, ok := value.(LedgerCloseMetaV1) + if !ok { + err = errors.New("invalid value, must be LedgerCloseMetaV1") + return + } + result.V1 = &tv + } + return } -var ( - _ encoding.BinaryMarshaler = (*Auth)(nil) - _ encoding.BinaryUnmarshaler = (*Auth)(nil) -) +// MustV0 retrieves the V0 value from the union, +// panicing if the value is not set. +func (u LedgerCloseMeta) MustV0() LedgerCloseMetaV0 { + val, ok := u.GetV0() -// xdrType signals that this type represents XDR values defined by this package. -func (s Auth) xdrType() {} + if !ok { + panic("arm V0 is not set") + } -var _ xdrType = (*Auth)(nil) + return val +} -// IpAddrType is an XDR Enum defines as: -// -// enum IPAddrType -// { -// IPv4 = 0, -// IPv6 = 1 -// }; -type IpAddrType int32 +// GetV0 retrieves the V0 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LedgerCloseMeta) GetV0() (result LedgerCloseMetaV0, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) -const ( - IpAddrTypeIPv4 IpAddrType = 0 - IpAddrTypeIPv6 IpAddrType = 1 -) + if armName == "V0" { + result = *u.V0 + ok = true + } -var ipAddrTypeMap = map[int32]string{ - 0: "IpAddrTypeIPv4", - 1: "IpAddrTypeIPv6", + return } -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for IpAddrType -func (e IpAddrType) ValidEnum(v int32) bool { - _, ok := ipAddrTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e IpAddrType) String() string { - name, _ := ipAddrTypeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e IpAddrType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := ipAddrTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid IpAddrType enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*IpAddrType)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *IpAddrType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding IpAddrType: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding IpAddrType: %w", err) - } - if _, ok := ipAddrTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid IpAddrType enum value", v) - } - *e = IpAddrType(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s IpAddrType) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *IpAddrType) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*IpAddrType)(nil) - _ encoding.BinaryUnmarshaler = (*IpAddrType)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s IpAddrType) xdrType() {} - -var _ xdrType = (*IpAddrType)(nil) - -// PeerAddressIp is an XDR NestedUnion defines as: -// -// union switch (IPAddrType type) -// { -// case IPv4: -// opaque ipv4[4]; -// case IPv6: -// opaque ipv6[16]; -// } -type PeerAddressIp struct { - Type IpAddrType - Ipv4 *[4]byte `xdrmaxsize:"4"` - Ipv6 *[16]byte `xdrmaxsize:"16"` -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u PeerAddressIp) SwitchFieldName() string { - return "Type" -} - -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of PeerAddressIp -func (u PeerAddressIp) ArmForSwitch(sw int32) (string, bool) { - switch IpAddrType(sw) { - case IpAddrTypeIPv4: - return "Ipv4", true - case IpAddrTypeIPv6: - return "Ipv6", true - } - return "-", false -} - -// NewPeerAddressIp creates a new PeerAddressIp. -func NewPeerAddressIp(aType IpAddrType, value interface{}) (result PeerAddressIp, err error) { - result.Type = aType - switch IpAddrType(aType) { - case IpAddrTypeIPv4: - tv, ok := value.([4]byte) - if !ok { - err = errors.New("invalid value, must be [4]byte") - return - } - result.Ipv4 = &tv - case IpAddrTypeIPv6: - tv, ok := value.([16]byte) - if !ok { - err = errors.New("invalid value, must be [16]byte") - return - } - result.Ipv6 = &tv - } - return -} - -// MustIpv4 retrieves the Ipv4 value from the union, -// panicing if the value is not set. -func (u PeerAddressIp) MustIpv4() [4]byte { - val, ok := u.GetIpv4() - - if !ok { - panic("arm Ipv4 is not set") - } - - return val -} - -// GetIpv4 retrieves the Ipv4 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u PeerAddressIp) GetIpv4() (result [4]byte, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Ipv4" { - result = *u.Ipv4 - ok = true - } - - return -} - -// MustIpv6 retrieves the Ipv6 value from the union, +// MustV1 retrieves the V1 value from the union, // panicing if the value is not set. -func (u PeerAddressIp) MustIpv6() [16]byte { - val, ok := u.GetIpv6() +func (u LedgerCloseMeta) MustV1() LedgerCloseMetaV1 { + val, ok := u.GetV1() if !ok { - panic("arm Ipv6 is not set") + panic("arm V1 is not set") } return val } -// GetIpv6 retrieves the Ipv6 value from the union, +// GetV1 retrieves the V1 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u PeerAddressIp) GetIpv6() (result [16]byte, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +func (u LedgerCloseMeta) GetV1() (result LedgerCloseMetaV1, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) - if armName == "Ipv6" { - result = *u.Ipv6 + if armName == "V1" { + result = *u.V1 ok = true } @@ -19608,156 +19968,64 @@ func (u PeerAddressIp) GetIpv6() (result [16]byte, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u PeerAddressIp) EncodeTo(e *xdr.Encoder) error { +func (u LedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(u.V)); err != nil { return err } - switch IpAddrType(u.Type) { - case IpAddrTypeIPv4: - if _, err = e.EncodeFixedOpaque((*u.Ipv4)[:]); err != nil { + switch int32(u.V) { + case 0: + if err = (*u.V0).EncodeTo(e); err != nil { return err } return nil - case IpAddrTypeIPv6: - if _, err = e.EncodeFixedOpaque((*u.Ipv6)[:]); err != nil { + case 1: + if err = (*u.V1).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (IpAddrType) switch value '%d' is not valid for union PeerAddressIp", u.Type) + return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerCloseMeta", u.V) } -var _ decoderFrom = (*PeerAddressIp)(nil) +var _ decoderFrom = (*LedgerCloseMeta)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *PeerAddressIp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *LedgerCloseMeta) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding PeerAddressIp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerCloseMeta: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + u.V, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding IpAddrType: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } - switch IpAddrType(u.Type) { - case IpAddrTypeIPv4: - u.Ipv4 = new([4]byte) - nTmp, err = d.DecodeFixedOpaqueInplace((*u.Ipv4)[:]) + switch int32(u.V) { + case 0: + u.V0 = new(LedgerCloseMetaV0) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Ipv4: %w", err) + return n, fmt.Errorf("decoding LedgerCloseMetaV0: %w", err) } return n, nil - case IpAddrTypeIPv6: - u.Ipv6 = new([16]byte) - nTmp, err = d.DecodeFixedOpaqueInplace((*u.Ipv6)[:]) + case 1: + u.V1 = new(LedgerCloseMetaV1) + nTmp, err = (*u.V1).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Ipv6: %w", err) + return n, fmt.Errorf("decoding LedgerCloseMetaV1: %w", err) } return n, nil } - return n, fmt.Errorf("union PeerAddressIp has invalid Type (IpAddrType) switch value '%d'", u.Type) -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s PeerAddressIp) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PeerAddressIp) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*PeerAddressIp)(nil) - _ encoding.BinaryUnmarshaler = (*PeerAddressIp)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s PeerAddressIp) xdrType() {} - -var _ xdrType = (*PeerAddressIp)(nil) - -// PeerAddress is an XDR Struct defines as: -// -// struct PeerAddress -// { -// union switch (IPAddrType type) -// { -// case IPv4: -// opaque ipv4[4]; -// case IPv6: -// opaque ipv6[16]; -// } -// ip; -// uint32 port; -// uint32 numFailures; -// }; -type PeerAddress struct { - Ip PeerAddressIp - Port Uint32 - NumFailures Uint32 -} - -// EncodeTo encodes this value using the Encoder. -func (s *PeerAddress) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Ip.EncodeTo(e); err != nil { - return err - } - if err = s.Port.EncodeTo(e); err != nil { - return err - } - if err = s.NumFailures.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*PeerAddress)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *PeerAddress) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding PeerAddress: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Ip.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PeerAddressIp: %w", err) - } - nTmp, err = s.Port.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.NumFailures.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - return n, nil + return n, fmt.Errorf("union LedgerCloseMeta has invalid V (int32) switch value '%d'", u.V) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PeerAddress) MarshalBinary() ([]byte, error) { +func (s LedgerCloseMeta) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -19765,7 +20033,7 @@ func (s PeerAddress) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PeerAddress) UnmarshalBinary(inp []byte) error { +func (s *LedgerCloseMeta) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -19775,154 +20043,86 @@ func (s *PeerAddress) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PeerAddress)(nil) - _ encoding.BinaryUnmarshaler = (*PeerAddress)(nil) + _ encoding.BinaryMarshaler = (*LedgerCloseMeta)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerCloseMeta)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PeerAddress) xdrType() {} +func (s LedgerCloseMeta) xdrType() {} -var _ xdrType = (*PeerAddress)(nil) +var _ xdrType = (*LedgerCloseMeta)(nil) -// MessageType is an XDR Enum defines as: +// ErrorCode is an XDR Enum defines as: // -// enum MessageType +// enum ErrorCode // { -// ERROR_MSG = 0, -// AUTH = 2, -// DONT_HAVE = 3, -// -// GET_PEERS = 4, // gets a list of peers this guy knows about -// PEERS = 5, -// -// GET_TX_SET = 6, // gets a particular txset by hash -// TX_SET = 7, -// GENERALIZED_TX_SET = 17, -// -// TRANSACTION = 8, // pass on a tx you have heard about -// -// // SCP -// GET_SCP_QUORUMSET = 9, -// SCP_QUORUMSET = 10, -// SCP_MESSAGE = 11, -// GET_SCP_STATE = 12, -// -// // new messages -// HELLO = 13, -// -// SURVEY_REQUEST = 14, -// SURVEY_RESPONSE = 15, -// -// SEND_MORE = 16, -// SEND_MORE_EXTENDED = 20, -// -// FLOOD_ADVERT = 18, -// FLOOD_DEMAND = 19, -// -// TIME_SLICED_SURVEY_REQUEST = 21, -// TIME_SLICED_SURVEY_RESPONSE = 22, -// TIME_SLICED_SURVEY_START_COLLECTING = 23, -// TIME_SLICED_SURVEY_STOP_COLLECTING = 24 +// ERR_MISC = 0, // Unspecific error +// ERR_DATA = 1, // Malformed data +// ERR_CONF = 2, // Misconfiguration error +// ERR_AUTH = 3, // Authentication failure +// ERR_LOAD = 4 // System overloaded // }; -type MessageType int32 +type ErrorCode int32 const ( - MessageTypeErrorMsg MessageType = 0 - MessageTypeAuth MessageType = 2 - MessageTypeDontHave MessageType = 3 - MessageTypeGetPeers MessageType = 4 - MessageTypePeers MessageType = 5 - MessageTypeGetTxSet MessageType = 6 - MessageTypeTxSet MessageType = 7 - MessageTypeGeneralizedTxSet MessageType = 17 - MessageTypeTransaction MessageType = 8 - MessageTypeGetScpQuorumset MessageType = 9 - MessageTypeScpQuorumset MessageType = 10 - MessageTypeScpMessage MessageType = 11 - MessageTypeGetScpState MessageType = 12 - MessageTypeHello MessageType = 13 - MessageTypeSurveyRequest MessageType = 14 - MessageTypeSurveyResponse MessageType = 15 - MessageTypeSendMore MessageType = 16 - MessageTypeSendMoreExtended MessageType = 20 - MessageTypeFloodAdvert MessageType = 18 - MessageTypeFloodDemand MessageType = 19 - MessageTypeTimeSlicedSurveyRequest MessageType = 21 - MessageTypeTimeSlicedSurveyResponse MessageType = 22 - MessageTypeTimeSlicedSurveyStartCollecting MessageType = 23 - MessageTypeTimeSlicedSurveyStopCollecting MessageType = 24 + ErrorCodeErrMisc ErrorCode = 0 + ErrorCodeErrData ErrorCode = 1 + ErrorCodeErrConf ErrorCode = 2 + ErrorCodeErrAuth ErrorCode = 3 + ErrorCodeErrLoad ErrorCode = 4 ) -var messageTypeMap = map[int32]string{ - 0: "MessageTypeErrorMsg", - 2: "MessageTypeAuth", - 3: "MessageTypeDontHave", - 4: "MessageTypeGetPeers", - 5: "MessageTypePeers", - 6: "MessageTypeGetTxSet", - 7: "MessageTypeTxSet", - 17: "MessageTypeGeneralizedTxSet", - 8: "MessageTypeTransaction", - 9: "MessageTypeGetScpQuorumset", - 10: "MessageTypeScpQuorumset", - 11: "MessageTypeScpMessage", - 12: "MessageTypeGetScpState", - 13: "MessageTypeHello", - 14: "MessageTypeSurveyRequest", - 15: "MessageTypeSurveyResponse", - 16: "MessageTypeSendMore", - 20: "MessageTypeSendMoreExtended", - 18: "MessageTypeFloodAdvert", - 19: "MessageTypeFloodDemand", - 21: "MessageTypeTimeSlicedSurveyRequest", - 22: "MessageTypeTimeSlicedSurveyResponse", - 23: "MessageTypeTimeSlicedSurveyStartCollecting", - 24: "MessageTypeTimeSlicedSurveyStopCollecting", +var errorCodeMap = map[int32]string{ + 0: "ErrorCodeErrMisc", + 1: "ErrorCodeErrData", + 2: "ErrorCodeErrConf", + 3: "ErrorCodeErrAuth", + 4: "ErrorCodeErrLoad", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for MessageType -func (e MessageType) ValidEnum(v int32) bool { - _, ok := messageTypeMap[v] +// the Enum interface for ErrorCode +func (e ErrorCode) ValidEnum(v int32) bool { + _, ok := errorCodeMap[v] return ok } // String returns the name of `e` -func (e MessageType) String() string { - name, _ := messageTypeMap[int32(e)] +func (e ErrorCode) String() string { + name, _ := errorCodeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e MessageType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := messageTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid MessageType enum value", e) +func (e ErrorCode) EncodeTo(enc *xdr.Encoder) error { + if _, ok := errorCodeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ErrorCode enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*MessageType)(nil) +var _ decoderFrom = (*ErrorCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *MessageType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *ErrorCode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding MessageType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ErrorCode: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding MessageType: %w", err) + return n, fmt.Errorf("decoding ErrorCode: %w", err) } - if _, ok := messageTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid MessageType enum value", v) + if _, ok := errorCodeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ErrorCode enum value", v) } - *e = MessageType(v) + *e = ErrorCode(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s MessageType) MarshalBinary() ([]byte, error) { +func (s ErrorCode) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -19930,7 +20130,7 @@ func (s MessageType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *MessageType) UnmarshalBinary(inp []byte) error { +func (s *ErrorCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -19940,64 +20140,64 @@ func (s *MessageType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*MessageType)(nil) - _ encoding.BinaryUnmarshaler = (*MessageType)(nil) + _ encoding.BinaryMarshaler = (*ErrorCode)(nil) + _ encoding.BinaryUnmarshaler = (*ErrorCode)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s MessageType) xdrType() {} +func (s ErrorCode) xdrType() {} -var _ xdrType = (*MessageType)(nil) +var _ xdrType = (*ErrorCode)(nil) -// DontHave is an XDR Struct defines as: +// Error is an XDR Struct defines as: // -// struct DontHave +// struct Error // { -// MessageType type; -// uint256 reqHash; +// ErrorCode code; +// string msg<100>; // }; -type DontHave struct { - Type MessageType - ReqHash Uint256 +type Error struct { + Code ErrorCode + Msg string `xdrmaxsize:"100"` } // EncodeTo encodes this value using the Encoder. -func (s *DontHave) EncodeTo(e *xdr.Encoder) error { +func (s *Error) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Type.EncodeTo(e); err != nil { + if err = s.Code.EncodeTo(e); err != nil { return err } - if err = s.ReqHash.EncodeTo(e); err != nil { + if _, err = e.EncodeString(string(s.Msg)); err != nil { return err } return nil } -var _ decoderFrom = (*DontHave)(nil) +var _ decoderFrom = (*Error)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *DontHave) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *Error) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding DontHave: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding Error: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Type.DecodeFrom(d, maxDepth) + nTmp, err = s.Code.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MessageType: %w", err) + return n, fmt.Errorf("decoding ErrorCode: %w", err) } - nTmp, err = s.ReqHash.DecodeFrom(d, maxDepth) + s.Msg, nTmp, err = d.DecodeString(100) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint256: %w", err) + return n, fmt.Errorf("decoding Msg: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s DontHave) MarshalBinary() ([]byte, error) { +func (s Error) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20005,7 +20205,7 @@ func (s DontHave) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *DontHave) UnmarshalBinary(inp []byte) error { +func (s *Error) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20015,77 +20215,54 @@ func (s *DontHave) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*DontHave)(nil) - _ encoding.BinaryUnmarshaler = (*DontHave)(nil) + _ encoding.BinaryMarshaler = (*Error)(nil) + _ encoding.BinaryUnmarshaler = (*Error)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s DontHave) xdrType() {} +func (s Error) xdrType() {} -var _ xdrType = (*DontHave)(nil) +var _ xdrType = (*Error)(nil) -// SurveyMessageCommandType is an XDR Enum defines as: +// SendMore is an XDR Struct defines as: // -// enum SurveyMessageCommandType +// struct SendMore // { -// SURVEY_TOPOLOGY = 0, -// TIME_SLICED_SURVEY_TOPOLOGY = 1 +// uint32 numMessages; // }; -type SurveyMessageCommandType int32 - -const ( - SurveyMessageCommandTypeSurveyTopology SurveyMessageCommandType = 0 - SurveyMessageCommandTypeTimeSlicedSurveyTopology SurveyMessageCommandType = 1 -) - -var surveyMessageCommandTypeMap = map[int32]string{ - 0: "SurveyMessageCommandTypeSurveyTopology", - 1: "SurveyMessageCommandTypeTimeSlicedSurveyTopology", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for SurveyMessageCommandType -func (e SurveyMessageCommandType) ValidEnum(v int32) bool { - _, ok := surveyMessageCommandTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e SurveyMessageCommandType) String() string { - name, _ := surveyMessageCommandTypeMap[int32(e)] - return name +type SendMore struct { + NumMessages Uint32 } // EncodeTo encodes this value using the Encoder. -func (e SurveyMessageCommandType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := surveyMessageCommandTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid SurveyMessageCommandType enum value", e) +func (s *SendMore) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.NumMessages.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + return nil } -var _ decoderFrom = (*SurveyMessageCommandType)(nil) +var _ decoderFrom = (*SendMore)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SurveyMessageCommandType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SendMore) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SurveyMessageCommandType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SendMore: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = s.NumMessages.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) - } - if _, ok := surveyMessageCommandTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid SurveyMessageCommandType enum value", v) + return n, fmt.Errorf("decoding Uint32: %w", err) } - *e = SurveyMessageCommandType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SurveyMessageCommandType) MarshalBinary() ([]byte, error) { +func (s SendMore) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20093,7 +20270,7 @@ func (s SurveyMessageCommandType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SurveyMessageCommandType) UnmarshalBinary(inp []byte) error { +func (s *SendMore) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20103,80 +20280,64 @@ func (s *SurveyMessageCommandType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SurveyMessageCommandType)(nil) - _ encoding.BinaryUnmarshaler = (*SurveyMessageCommandType)(nil) + _ encoding.BinaryMarshaler = (*SendMore)(nil) + _ encoding.BinaryUnmarshaler = (*SendMore)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SurveyMessageCommandType) xdrType() {} +func (s SendMore) xdrType() {} -var _ xdrType = (*SurveyMessageCommandType)(nil) +var _ xdrType = (*SendMore)(nil) -// SurveyMessageResponseType is an XDR Enum defines as: +// SendMoreExtended is an XDR Struct defines as: // -// enum SurveyMessageResponseType +// struct SendMoreExtended // { -// SURVEY_TOPOLOGY_RESPONSE_V0 = 0, -// SURVEY_TOPOLOGY_RESPONSE_V1 = 1, -// SURVEY_TOPOLOGY_RESPONSE_V2 = 2 +// uint32 numMessages; +// uint32 numBytes; // }; -type SurveyMessageResponseType int32 - -const ( - SurveyMessageResponseTypeSurveyTopologyResponseV0 SurveyMessageResponseType = 0 - SurveyMessageResponseTypeSurveyTopologyResponseV1 SurveyMessageResponseType = 1 - SurveyMessageResponseTypeSurveyTopologyResponseV2 SurveyMessageResponseType = 2 -) - -var surveyMessageResponseTypeMap = map[int32]string{ - 0: "SurveyMessageResponseTypeSurveyTopologyResponseV0", - 1: "SurveyMessageResponseTypeSurveyTopologyResponseV1", - 2: "SurveyMessageResponseTypeSurveyTopologyResponseV2", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for SurveyMessageResponseType -func (e SurveyMessageResponseType) ValidEnum(v int32) bool { - _, ok := surveyMessageResponseTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e SurveyMessageResponseType) String() string { - name, _ := surveyMessageResponseTypeMap[int32(e)] - return name +type SendMoreExtended struct { + NumMessages Uint32 + NumBytes Uint32 } // EncodeTo encodes this value using the Encoder. -func (e SurveyMessageResponseType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := surveyMessageResponseTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid SurveyMessageResponseType enum value", e) +func (s *SendMoreExtended) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.NumMessages.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + if err = s.NumBytes.EncodeTo(e); err != nil { + return err + } + return nil } -var _ decoderFrom = (*SurveyMessageResponseType)(nil) +var _ decoderFrom = (*SendMoreExtended)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SurveyMessageResponseType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SendMoreExtended) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SurveyMessageResponseType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SendMoreExtended: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = s.NumMessages.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyMessageResponseType: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - if _, ok := surveyMessageResponseTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid SurveyMessageResponseType enum value", v) + nTmp, err = s.NumBytes.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } - *e = SurveyMessageResponseType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SurveyMessageResponseType) MarshalBinary() ([]byte, error) { +func (s SendMoreExtended) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20184,7 +20345,7 @@ func (s SurveyMessageResponseType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SurveyMessageResponseType) UnmarshalBinary(inp []byte) error { +func (s *SendMoreExtended) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20194,74 +20355,74 @@ func (s *SurveyMessageResponseType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SurveyMessageResponseType)(nil) - _ encoding.BinaryUnmarshaler = (*SurveyMessageResponseType)(nil) + _ encoding.BinaryMarshaler = (*SendMoreExtended)(nil) + _ encoding.BinaryUnmarshaler = (*SendMoreExtended)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SurveyMessageResponseType) xdrType() {} +func (s SendMoreExtended) xdrType() {} -var _ xdrType = (*SurveyMessageResponseType)(nil) +var _ xdrType = (*SendMoreExtended)(nil) -// TimeSlicedSurveyStartCollectingMessage is an XDR Struct defines as: +// AuthCert is an XDR Struct defines as: // -// struct TimeSlicedSurveyStartCollectingMessage +// struct AuthCert // { -// NodeID surveyorID; -// uint32 nonce; -// uint32 ledgerNum; +// Curve25519Public pubkey; +// uint64 expiration; +// Signature sig; // }; -type TimeSlicedSurveyStartCollectingMessage struct { - SurveyorId NodeId - Nonce Uint32 - LedgerNum Uint32 +type AuthCert struct { + Pubkey Curve25519Public + Expiration Uint64 + Sig Signature } // EncodeTo encodes this value using the Encoder. -func (s *TimeSlicedSurveyStartCollectingMessage) EncodeTo(e *xdr.Encoder) error { +func (s *AuthCert) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.SurveyorId.EncodeTo(e); err != nil { + if err = s.Pubkey.EncodeTo(e); err != nil { return err } - if err = s.Nonce.EncodeTo(e); err != nil { + if err = s.Expiration.EncodeTo(e); err != nil { return err } - if err = s.LedgerNum.EncodeTo(e); err != nil { + if err = s.Sig.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TimeSlicedSurveyStartCollectingMessage)(nil) +var _ decoderFrom = (*AuthCert)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeSlicedSurveyStartCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *AuthCert) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeSlicedSurveyStartCollectingMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding AuthCert: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SurveyorId.DecodeFrom(d, maxDepth) + nTmp, err = s.Pubkey.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %w", err) + return n, fmt.Errorf("decoding Curve25519Public: %w", err) } - nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + nTmp, err = s.Expiration.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Uint64: %w", err) } - nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) + nTmp, err = s.Sig.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Signature: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeSlicedSurveyStartCollectingMessage) MarshalBinary() ([]byte, error) { +func (s AuthCert) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20269,7 +20430,7 @@ func (s TimeSlicedSurveyStartCollectingMessage) MarshalBinary() ([]byte, error) } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeSlicedSurveyStartCollectingMessage) UnmarshalBinary(inp []byte) error { +func (s *AuthCert) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20279,64 +20440,134 @@ func (s *TimeSlicedSurveyStartCollectingMessage) UnmarshalBinary(inp []byte) err } var ( - _ encoding.BinaryMarshaler = (*TimeSlicedSurveyStartCollectingMessage)(nil) - _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyStartCollectingMessage)(nil) + _ encoding.BinaryMarshaler = (*AuthCert)(nil) + _ encoding.BinaryUnmarshaler = (*AuthCert)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeSlicedSurveyStartCollectingMessage) xdrType() {} +func (s AuthCert) xdrType() {} -var _ xdrType = (*TimeSlicedSurveyStartCollectingMessage)(nil) +var _ xdrType = (*AuthCert)(nil) -// SignedTimeSlicedSurveyStartCollectingMessage is an XDR Struct defines as: +// Hello is an XDR Struct defines as: // -// struct SignedTimeSlicedSurveyStartCollectingMessage +// struct Hello // { -// Signature signature; -// TimeSlicedSurveyStartCollectingMessage startCollecting; +// uint32 ledgerVersion; +// uint32 overlayVersion; +// uint32 overlayMinVersion; +// Hash networkID; +// string versionStr<100>; +// int listeningPort; +// NodeID peerID; +// AuthCert cert; +// uint256 nonce; // }; -type SignedTimeSlicedSurveyStartCollectingMessage struct { - Signature Signature - StartCollecting TimeSlicedSurveyStartCollectingMessage +type Hello struct { + LedgerVersion Uint32 + OverlayVersion Uint32 + OverlayMinVersion Uint32 + NetworkId Hash + VersionStr string `xdrmaxsize:"100"` + ListeningPort int32 + PeerId NodeId + Cert AuthCert + Nonce Uint256 } // EncodeTo encodes this value using the Encoder. -func (s *SignedTimeSlicedSurveyStartCollectingMessage) EncodeTo(e *xdr.Encoder) error { +func (s *Hello) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Signature.EncodeTo(e); err != nil { + if err = s.LedgerVersion.EncodeTo(e); err != nil { return err } - if err = s.StartCollecting.EncodeTo(e); err != nil { + if err = s.OverlayVersion.EncodeTo(e); err != nil { + return err + } + if err = s.OverlayMinVersion.EncodeTo(e); err != nil { + return err + } + if err = s.NetworkId.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeString(string(s.VersionStr)); err != nil { + return err + } + if _, err = e.EncodeInt(int32(s.ListeningPort)); err != nil { + return err + } + if err = s.PeerId.EncodeTo(e); err != nil { + return err + } + if err = s.Cert.EncodeTo(e); err != nil { + return err + } + if err = s.Nonce.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) +var _ decoderFrom = (*Hello)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedTimeSlicedSurveyStartCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *Hello) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyStartCollectingMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding Hello: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Signature.DecodeFrom(d, maxDepth) + nTmp, err = s.LedgerVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.StartCollecting.DecodeFrom(d, maxDepth) + nTmp, err = s.OverlayVersion.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeSlicedSurveyStartCollectingMessage: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.OverlayMinVersion.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + s.VersionStr, nTmp, err = d.DecodeString(100) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding VersionStr: %w", err) + } + s.ListeningPort, nTmp, err = d.DecodeInt() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int: %w", err) + } + nTmp, err = s.PeerId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding NodeId: %w", err) + } + nTmp, err = s.Cert.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AuthCert: %w", err) + } + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SignedTimeSlicedSurveyStartCollectingMessage) MarshalBinary() ([]byte, error) { +func (s Hello) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20344,7 +20575,7 @@ func (s SignedTimeSlicedSurveyStartCollectingMessage) MarshalBinary() ([]byte, e } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SignedTimeSlicedSurveyStartCollectingMessage) UnmarshalBinary(inp []byte) error { +func (s *Hello) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20354,74 +20585,59 @@ func (s *SignedTimeSlicedSurveyStartCollectingMessage) UnmarshalBinary(inp []byt } var ( - _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) + _ encoding.BinaryMarshaler = (*Hello)(nil) + _ encoding.BinaryUnmarshaler = (*Hello)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SignedTimeSlicedSurveyStartCollectingMessage) xdrType() {} +func (s Hello) xdrType() {} -var _ xdrType = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) +var _ xdrType = (*Hello)(nil) -// TimeSlicedSurveyStopCollectingMessage is an XDR Struct defines as: +// AuthMsgFlagFlowControlBytesRequested is an XDR Const defines as: // -// struct TimeSlicedSurveyStopCollectingMessage +// const AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED = 200; +const AuthMsgFlagFlowControlBytesRequested = 200 + +// Auth is an XDR Struct defines as: +// +// struct Auth // { -// NodeID surveyorID; -// uint32 nonce; -// uint32 ledgerNum; +// int flags; // }; -type TimeSlicedSurveyStopCollectingMessage struct { - SurveyorId NodeId - Nonce Uint32 - LedgerNum Uint32 +type Auth struct { + Flags int32 } // EncodeTo encodes this value using the Encoder. -func (s *TimeSlicedSurveyStopCollectingMessage) EncodeTo(e *xdr.Encoder) error { +func (s *Auth) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.SurveyorId.EncodeTo(e); err != nil { - return err - } - if err = s.Nonce.EncodeTo(e); err != nil { - return err - } - if err = s.LedgerNum.EncodeTo(e); err != nil { + if _, err = e.EncodeInt(int32(s.Flags)); err != nil { return err } return nil } -var _ decoderFrom = (*TimeSlicedSurveyStopCollectingMessage)(nil) +var _ decoderFrom = (*Auth)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeSlicedSurveyStopCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *Auth) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeSlicedSurveyStopCollectingMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding Auth: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SurveyorId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding NodeId: %w", err) - } - nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) + s.Flags, nTmp, err = d.DecodeInt() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Int: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeSlicedSurveyStopCollectingMessage) MarshalBinary() ([]byte, error) { +func (s Auth) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20429,7 +20645,7 @@ func (s TimeSlicedSurveyStopCollectingMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeSlicedSurveyStopCollectingMessage) UnmarshalBinary(inp []byte) error { +func (s *Auth) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20439,64 +20655,77 @@ func (s *TimeSlicedSurveyStopCollectingMessage) UnmarshalBinary(inp []byte) erro } var ( - _ encoding.BinaryMarshaler = (*TimeSlicedSurveyStopCollectingMessage)(nil) - _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyStopCollectingMessage)(nil) + _ encoding.BinaryMarshaler = (*Auth)(nil) + _ encoding.BinaryUnmarshaler = (*Auth)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeSlicedSurveyStopCollectingMessage) xdrType() {} +func (s Auth) xdrType() {} -var _ xdrType = (*TimeSlicedSurveyStopCollectingMessage)(nil) +var _ xdrType = (*Auth)(nil) -// SignedTimeSlicedSurveyStopCollectingMessage is an XDR Struct defines as: +// IpAddrType is an XDR Enum defines as: // -// struct SignedTimeSlicedSurveyStopCollectingMessage +// enum IPAddrType // { -// Signature signature; -// TimeSlicedSurveyStopCollectingMessage stopCollecting; +// IPv4 = 0, +// IPv6 = 1 // }; -type SignedTimeSlicedSurveyStopCollectingMessage struct { - Signature Signature - StopCollecting TimeSlicedSurveyStopCollectingMessage +type IpAddrType int32 + +const ( + IpAddrTypeIPv4 IpAddrType = 0 + IpAddrTypeIPv6 IpAddrType = 1 +) + +var ipAddrTypeMap = map[int32]string{ + 0: "IpAddrTypeIPv4", + 1: "IpAddrTypeIPv6", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for IpAddrType +func (e IpAddrType) ValidEnum(v int32) bool { + _, ok := ipAddrTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e IpAddrType) String() string { + name, _ := ipAddrTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *SignedTimeSlicedSurveyStopCollectingMessage) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Signature.EncodeTo(e); err != nil { - return err - } - if err = s.StopCollecting.EncodeTo(e); err != nil { - return err +func (e IpAddrType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := ipAddrTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid IpAddrType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) +var _ decoderFrom = (*IpAddrType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedTimeSlicedSurveyStopCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *IpAddrType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyStopCollectingMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding IpAddrType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Signature.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + return n, fmt.Errorf("decoding IpAddrType: %w", err) } - nTmp, err = s.StopCollecting.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TimeSlicedSurveyStopCollectingMessage: %w", err) + if _, ok := ipAddrTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid IpAddrType enum value", v) } + *e = IpAddrType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SignedTimeSlicedSurveyStopCollectingMessage) MarshalBinary() ([]byte, error) { +func (s IpAddrType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20504,7 +20733,7 @@ func (s SignedTimeSlicedSurveyStopCollectingMessage) MarshalBinary() ([]byte, er } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SignedTimeSlicedSurveyStopCollectingMessage) UnmarshalBinary(inp []byte) error { +func (s *IpAddrType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20514,94 +20743,179 @@ func (s *SignedTimeSlicedSurveyStopCollectingMessage) UnmarshalBinary(inp []byte } var ( - _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) + _ encoding.BinaryMarshaler = (*IpAddrType)(nil) + _ encoding.BinaryUnmarshaler = (*IpAddrType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SignedTimeSlicedSurveyStopCollectingMessage) xdrType() {} +func (s IpAddrType) xdrType() {} -var _ xdrType = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) +var _ xdrType = (*IpAddrType)(nil) -// SurveyRequestMessage is an XDR Struct defines as: +// PeerAddressIp is an XDR NestedUnion defines as: // -// struct SurveyRequestMessage -// { -// NodeID surveyorPeerID; -// NodeID surveyedPeerID; -// uint32 ledgerNum; -// Curve25519Public encryptionKey; -// SurveyMessageCommandType commandType; -// }; -type SurveyRequestMessage struct { - SurveyorPeerId NodeId - SurveyedPeerId NodeId - LedgerNum Uint32 - EncryptionKey Curve25519Public - CommandType SurveyMessageCommandType +// union switch (IPAddrType type) +// { +// case IPv4: +// opaque ipv4[4]; +// case IPv6: +// opaque ipv6[16]; +// } +type PeerAddressIp struct { + Type IpAddrType + Ipv4 *[4]byte `xdrmaxsize:"4"` + Ipv6 *[16]byte `xdrmaxsize:"16"` } -// EncodeTo encodes this value using the Encoder. -func (s *SurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.SurveyorPeerId.EncodeTo(e); err != nil { - return err - } - if err = s.SurveyedPeerId.EncodeTo(e); err != nil { - return err - } - if err = s.LedgerNum.EncodeTo(e); err != nil { - return err - } - if err = s.EncryptionKey.EncodeTo(e); err != nil { - return err - } - if err = s.CommandType.EncodeTo(e); err != nil { - return err - } - return nil +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u PeerAddressIp) SwitchFieldName() string { + return "Type" } -var _ decoderFrom = (*SurveyRequestMessage)(nil) +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of PeerAddressIp +func (u PeerAddressIp) ArmForSwitch(sw int32) (string, bool) { + switch IpAddrType(sw) { + case IpAddrTypeIPv4: + return "Ipv4", true + case IpAddrTypeIPv6: + return "Ipv6", true + } + return "-", false +} + +// NewPeerAddressIp creates a new PeerAddressIp. +func NewPeerAddressIp(aType IpAddrType, value interface{}) (result PeerAddressIp, err error) { + result.Type = aType + switch IpAddrType(aType) { + case IpAddrTypeIPv4: + tv, ok := value.([4]byte) + if !ok { + err = errors.New("invalid value, must be [4]byte") + return + } + result.Ipv4 = &tv + case IpAddrTypeIPv6: + tv, ok := value.([16]byte) + if !ok { + err = errors.New("invalid value, must be [16]byte") + return + } + result.Ipv6 = &tv + } + return +} + +// MustIpv4 retrieves the Ipv4 value from the union, +// panicing if the value is not set. +func (u PeerAddressIp) MustIpv4() [4]byte { + val, ok := u.GetIpv4() + + if !ok { + panic("arm Ipv4 is not set") + } + + return val +} + +// GetIpv4 retrieves the Ipv4 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u PeerAddressIp) GetIpv4() (result [4]byte, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Ipv4" { + result = *u.Ipv4 + ok = true + } + + return +} + +// MustIpv6 retrieves the Ipv6 value from the union, +// panicing if the value is not set. +func (u PeerAddressIp) MustIpv6() [16]byte { + val, ok := u.GetIpv6() + + if !ok { + panic("arm Ipv6 is not set") + } + + return val +} + +// GetIpv6 retrieves the Ipv6 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u PeerAddressIp) GetIpv6() (result [16]byte, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Ipv6" { + result = *u.Ipv6 + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u PeerAddressIp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err + } + switch IpAddrType(u.Type) { + case IpAddrTypeIPv4: + if _, err = e.EncodeFixedOpaque((*u.Ipv4)[:]); err != nil { + return err + } + return nil + case IpAddrTypeIPv6: + if _, err = e.EncodeFixedOpaque((*u.Ipv6)[:]); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (IpAddrType) switch value '%d' is not valid for union PeerAddressIp", u.Type) +} + +var _ decoderFrom = (*PeerAddressIp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *PeerAddressIp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SurveyRequestMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding PeerAddressIp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SurveyorPeerId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding NodeId: %w", err) - } - nTmp, err = s.SurveyedPeerId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding NodeId: %w", err) - } - nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.EncryptionKey.DecodeFrom(d, maxDepth) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Curve25519Public: %w", err) + return n, fmt.Errorf("decoding IpAddrType: %w", err) } - nTmp, err = s.CommandType.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) + switch IpAddrType(u.Type) { + case IpAddrTypeIPv4: + u.Ipv4 = new([4]byte) + nTmp, err = d.DecodeFixedOpaqueInplace((*u.Ipv4)[:]) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Ipv4: %w", err) + } + return n, nil + case IpAddrTypeIPv6: + u.Ipv6 = new([16]byte) + nTmp, err = d.DecodeFixedOpaqueInplace((*u.Ipv6)[:]) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Ipv6: %w", err) + } + return n, nil } - return n, nil + return n, fmt.Errorf("union PeerAddressIp has invalid Type (IpAddrType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SurveyRequestMessage) MarshalBinary() ([]byte, error) { +func (s PeerAddressIp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20609,7 +20923,7 @@ func (s SurveyRequestMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SurveyRequestMessage) UnmarshalBinary(inp []byte) error { +func (s *PeerAddressIp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20619,75 +20933,72 @@ func (s *SurveyRequestMessage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SurveyRequestMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SurveyRequestMessage)(nil) + _ encoding.BinaryMarshaler = (*PeerAddressIp)(nil) + _ encoding.BinaryUnmarshaler = (*PeerAddressIp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SurveyRequestMessage) xdrType() {} +func (s PeerAddressIp) xdrType() {} -var _ xdrType = (*SurveyRequestMessage)(nil) +var _ xdrType = (*PeerAddressIp)(nil) -// TimeSlicedSurveyRequestMessage is an XDR Struct defines as: +// PeerAddress is an XDR Struct defines as: // -// struct TimeSlicedSurveyRequestMessage +// struct PeerAddress // { -// SurveyRequestMessage request; -// uint32 nonce; -// uint32 inboundPeersIndex; -// uint32 outboundPeersIndex; +// union switch (IPAddrType type) +// { +// case IPv4: +// opaque ipv4[4]; +// case IPv6: +// opaque ipv6[16]; +// } +// ip; +// uint32 port; +// uint32 numFailures; // }; -type TimeSlicedSurveyRequestMessage struct { - Request SurveyRequestMessage - Nonce Uint32 - InboundPeersIndex Uint32 - OutboundPeersIndex Uint32 +type PeerAddress struct { + Ip PeerAddressIp + Port Uint32 + NumFailures Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *TimeSlicedSurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { +func (s *PeerAddress) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Request.EncodeTo(e); err != nil { - return err - } - if err = s.Nonce.EncodeTo(e); err != nil { + if err = s.Ip.EncodeTo(e); err != nil { return err } - if err = s.InboundPeersIndex.EncodeTo(e); err != nil { + if err = s.Port.EncodeTo(e); err != nil { return err } - if err = s.OutboundPeersIndex.EncodeTo(e); err != nil { + if err = s.NumFailures.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TimeSlicedSurveyRequestMessage)(nil) +var _ decoderFrom = (*PeerAddress)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeSlicedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *PeerAddress) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeSlicedSurveyRequestMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding PeerAddress: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Request.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SurveyRequestMessage: %w", err) - } - nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + nTmp, err = s.Ip.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding PeerAddressIp: %w", err) } - nTmp, err = s.InboundPeersIndex.DecodeFrom(d, maxDepth) + nTmp, err = s.Port.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.OutboundPeersIndex.DecodeFrom(d, maxDepth) + nTmp, err = s.NumFailures.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) @@ -20696,7 +21007,7 @@ func (s *TimeSlicedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uin } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeSlicedSurveyRequestMessage) MarshalBinary() ([]byte, error) { +func (s PeerAddress) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20704,7 +21015,7 @@ func (s TimeSlicedSurveyRequestMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeSlicedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { +func (s *PeerAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20714,64 +21025,154 @@ func (s *TimeSlicedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TimeSlicedSurveyRequestMessage)(nil) - _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyRequestMessage)(nil) + _ encoding.BinaryMarshaler = (*PeerAddress)(nil) + _ encoding.BinaryUnmarshaler = (*PeerAddress)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeSlicedSurveyRequestMessage) xdrType() {} +func (s PeerAddress) xdrType() {} -var _ xdrType = (*TimeSlicedSurveyRequestMessage)(nil) +var _ xdrType = (*PeerAddress)(nil) -// SignedSurveyRequestMessage is an XDR Struct defines as: +// MessageType is an XDR Enum defines as: // -// struct SignedSurveyRequestMessage +// enum MessageType // { -// Signature requestSignature; -// SurveyRequestMessage request; +// ERROR_MSG = 0, +// AUTH = 2, +// DONT_HAVE = 3, +// +// GET_PEERS = 4, // gets a list of peers this guy knows about +// PEERS = 5, +// +// GET_TX_SET = 6, // gets a particular txset by hash +// TX_SET = 7, +// GENERALIZED_TX_SET = 17, +// +// TRANSACTION = 8, // pass on a tx you have heard about +// +// // SCP +// GET_SCP_QUORUMSET = 9, +// SCP_QUORUMSET = 10, +// SCP_MESSAGE = 11, +// GET_SCP_STATE = 12, +// +// // new messages +// HELLO = 13, +// +// SURVEY_REQUEST = 14, +// SURVEY_RESPONSE = 15, +// +// SEND_MORE = 16, +// SEND_MORE_EXTENDED = 20, +// +// FLOOD_ADVERT = 18, +// FLOOD_DEMAND = 19, +// +// TIME_SLICED_SURVEY_REQUEST = 21, +// TIME_SLICED_SURVEY_RESPONSE = 22, +// TIME_SLICED_SURVEY_START_COLLECTING = 23, +// TIME_SLICED_SURVEY_STOP_COLLECTING = 24 // }; -type SignedSurveyRequestMessage struct { - RequestSignature Signature - Request SurveyRequestMessage +type MessageType int32 + +const ( + MessageTypeErrorMsg MessageType = 0 + MessageTypeAuth MessageType = 2 + MessageTypeDontHave MessageType = 3 + MessageTypeGetPeers MessageType = 4 + MessageTypePeers MessageType = 5 + MessageTypeGetTxSet MessageType = 6 + MessageTypeTxSet MessageType = 7 + MessageTypeGeneralizedTxSet MessageType = 17 + MessageTypeTransaction MessageType = 8 + MessageTypeGetScpQuorumset MessageType = 9 + MessageTypeScpQuorumset MessageType = 10 + MessageTypeScpMessage MessageType = 11 + MessageTypeGetScpState MessageType = 12 + MessageTypeHello MessageType = 13 + MessageTypeSurveyRequest MessageType = 14 + MessageTypeSurveyResponse MessageType = 15 + MessageTypeSendMore MessageType = 16 + MessageTypeSendMoreExtended MessageType = 20 + MessageTypeFloodAdvert MessageType = 18 + MessageTypeFloodDemand MessageType = 19 + MessageTypeTimeSlicedSurveyRequest MessageType = 21 + MessageTypeTimeSlicedSurveyResponse MessageType = 22 + MessageTypeTimeSlicedSurveyStartCollecting MessageType = 23 + MessageTypeTimeSlicedSurveyStopCollecting MessageType = 24 +) + +var messageTypeMap = map[int32]string{ + 0: "MessageTypeErrorMsg", + 2: "MessageTypeAuth", + 3: "MessageTypeDontHave", + 4: "MessageTypeGetPeers", + 5: "MessageTypePeers", + 6: "MessageTypeGetTxSet", + 7: "MessageTypeTxSet", + 17: "MessageTypeGeneralizedTxSet", + 8: "MessageTypeTransaction", + 9: "MessageTypeGetScpQuorumset", + 10: "MessageTypeScpQuorumset", + 11: "MessageTypeScpMessage", + 12: "MessageTypeGetScpState", + 13: "MessageTypeHello", + 14: "MessageTypeSurveyRequest", + 15: "MessageTypeSurveyResponse", + 16: "MessageTypeSendMore", + 20: "MessageTypeSendMoreExtended", + 18: "MessageTypeFloodAdvert", + 19: "MessageTypeFloodDemand", + 21: "MessageTypeTimeSlicedSurveyRequest", + 22: "MessageTypeTimeSlicedSurveyResponse", + 23: "MessageTypeTimeSlicedSurveyStartCollecting", + 24: "MessageTypeTimeSlicedSurveyStopCollecting", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for MessageType +func (e MessageType) ValidEnum(v int32) bool { + _, ok := messageTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e MessageType) String() string { + name, _ := messageTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *SignedSurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.RequestSignature.EncodeTo(e); err != nil { - return err - } - if err = s.Request.EncodeTo(e); err != nil { - return err +func (e MessageType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := messageTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid MessageType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*SignedSurveyRequestMessage)(nil) +var _ decoderFrom = (*MessageType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *MessageType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SignedSurveyRequestMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding MessageType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.RequestSignature.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + return n, fmt.Errorf("decoding MessageType: %w", err) } - nTmp, err = s.Request.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SurveyRequestMessage: %w", err) + if _, ok := messageTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid MessageType enum value", v) } + *e = MessageType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SignedSurveyRequestMessage) MarshalBinary() ([]byte, error) { +func (s MessageType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20779,7 +21180,7 @@ func (s SignedSurveyRequestMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SignedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { +func (s *MessageType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20789,64 +21190,64 @@ func (s *SignedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SignedSurveyRequestMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SignedSurveyRequestMessage)(nil) + _ encoding.BinaryMarshaler = (*MessageType)(nil) + _ encoding.BinaryUnmarshaler = (*MessageType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SignedSurveyRequestMessage) xdrType() {} +func (s MessageType) xdrType() {} -var _ xdrType = (*SignedSurveyRequestMessage)(nil) +var _ xdrType = (*MessageType)(nil) -// SignedTimeSlicedSurveyRequestMessage is an XDR Struct defines as: +// DontHave is an XDR Struct defines as: // -// struct SignedTimeSlicedSurveyRequestMessage +// struct DontHave // { -// Signature requestSignature; -// TimeSlicedSurveyRequestMessage request; +// MessageType type; +// uint256 reqHash; // }; -type SignedTimeSlicedSurveyRequestMessage struct { - RequestSignature Signature - Request TimeSlicedSurveyRequestMessage +type DontHave struct { + Type MessageType + ReqHash Uint256 } // EncodeTo encodes this value using the Encoder. -func (s *SignedTimeSlicedSurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { +func (s *DontHave) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.RequestSignature.EncodeTo(e); err != nil { + if err = s.Type.EncodeTo(e); err != nil { return err } - if err = s.Request.EncodeTo(e); err != nil { + if err = s.ReqHash.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*SignedTimeSlicedSurveyRequestMessage)(nil) +var _ decoderFrom = (*DontHave)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedTimeSlicedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *DontHave) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyRequestMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding DontHave: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.RequestSignature.DecodeFrom(d, maxDepth) + nTmp, err = s.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + return n, fmt.Errorf("decoding MessageType: %w", err) } - nTmp, err = s.Request.DecodeFrom(d, maxDepth) + nTmp, err = s.ReqHash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeSlicedSurveyRequestMessage: %w", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SignedTimeSlicedSurveyRequestMessage) MarshalBinary() ([]byte, error) { +func (s DontHave) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20854,7 +21255,7 @@ func (s SignedTimeSlicedSurveyRequestMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SignedTimeSlicedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { +func (s *DontHave) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20864,54 +21265,77 @@ func (s *SignedTimeSlicedSurveyRequestMessage) UnmarshalBinary(inp []byte) error } var ( - _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyRequestMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyRequestMessage)(nil) + _ encoding.BinaryMarshaler = (*DontHave)(nil) + _ encoding.BinaryUnmarshaler = (*DontHave)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SignedTimeSlicedSurveyRequestMessage) xdrType() {} +func (s DontHave) xdrType() {} -var _ xdrType = (*SignedTimeSlicedSurveyRequestMessage)(nil) +var _ xdrType = (*DontHave)(nil) -// EncryptedBody is an XDR Typedef defines as: +// SurveyMessageCommandType is an XDR Enum defines as: // -// typedef opaque EncryptedBody<64000>; -type EncryptedBody []byte +// enum SurveyMessageCommandType +// { +// SURVEY_TOPOLOGY = 0, +// TIME_SLICED_SURVEY_TOPOLOGY = 1 +// }; +type SurveyMessageCommandType int32 -// XDRMaxSize implements the Sized interface for EncryptedBody -func (e EncryptedBody) XDRMaxSize() int { - return 64000 +const ( + SurveyMessageCommandTypeSurveyTopology SurveyMessageCommandType = 0 + SurveyMessageCommandTypeTimeSlicedSurveyTopology SurveyMessageCommandType = 1 +) + +var surveyMessageCommandTypeMap = map[int32]string{ + 0: "SurveyMessageCommandTypeSurveyTopology", + 1: "SurveyMessageCommandTypeTimeSlicedSurveyTopology", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for SurveyMessageCommandType +func (e SurveyMessageCommandType) ValidEnum(v int32) bool { + _, ok := surveyMessageCommandTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e SurveyMessageCommandType) String() string { + name, _ := surveyMessageCommandTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s EncryptedBody) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeOpaque(s[:]); err != nil { - return err +func (e SurveyMessageCommandType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := surveyMessageCommandTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid SurveyMessageCommandType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*EncryptedBody)(nil) +var _ decoderFrom = (*SurveyMessageCommandType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *EncryptedBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *SurveyMessageCommandType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding EncryptedBody: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SurveyMessageCommandType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - (*s), nTmp, err = d.DecodeOpaque(64000) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding EncryptedBody: %w", err) + return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) + } + if _, ok := surveyMessageCommandTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid SurveyMessageCommandType enum value", v) } + *e = SurveyMessageCommandType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s EncryptedBody) MarshalBinary() ([]byte, error) { +func (s SurveyMessageCommandType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -20919,7 +21343,7 @@ func (s EncryptedBody) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *EncryptedBody) UnmarshalBinary(inp []byte) error { +func (s *SurveyMessageCommandType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -20929,94 +21353,165 @@ func (s *EncryptedBody) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*EncryptedBody)(nil) - _ encoding.BinaryUnmarshaler = (*EncryptedBody)(nil) + _ encoding.BinaryMarshaler = (*SurveyMessageCommandType)(nil) + _ encoding.BinaryUnmarshaler = (*SurveyMessageCommandType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s EncryptedBody) xdrType() {} +func (s SurveyMessageCommandType) xdrType() {} -var _ xdrType = (*EncryptedBody)(nil) +var _ xdrType = (*SurveyMessageCommandType)(nil) -// SurveyResponseMessage is an XDR Struct defines as: +// SurveyMessageResponseType is an XDR Enum defines as: // -// struct SurveyResponseMessage +// enum SurveyMessageResponseType // { -// NodeID surveyorPeerID; -// NodeID surveyedPeerID; +// SURVEY_TOPOLOGY_RESPONSE_V0 = 0, +// SURVEY_TOPOLOGY_RESPONSE_V1 = 1, +// SURVEY_TOPOLOGY_RESPONSE_V2 = 2 +// }; +type SurveyMessageResponseType int32 + +const ( + SurveyMessageResponseTypeSurveyTopologyResponseV0 SurveyMessageResponseType = 0 + SurveyMessageResponseTypeSurveyTopologyResponseV1 SurveyMessageResponseType = 1 + SurveyMessageResponseTypeSurveyTopologyResponseV2 SurveyMessageResponseType = 2 +) + +var surveyMessageResponseTypeMap = map[int32]string{ + 0: "SurveyMessageResponseTypeSurveyTopologyResponseV0", + 1: "SurveyMessageResponseTypeSurveyTopologyResponseV1", + 2: "SurveyMessageResponseTypeSurveyTopologyResponseV2", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for SurveyMessageResponseType +func (e SurveyMessageResponseType) ValidEnum(v int32) bool { + _, ok := surveyMessageResponseTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e SurveyMessageResponseType) String() string { + name, _ := surveyMessageResponseTypeMap[int32(e)] + return name +} + +// EncodeTo encodes this value using the Encoder. +func (e SurveyMessageResponseType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := surveyMessageResponseTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid SurveyMessageResponseType enum value", e) + } + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*SurveyMessageResponseType)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (e *SurveyMessageResponseType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SurveyMessageResponseType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + v, n, err := d.DecodeInt() + if err != nil { + return n, fmt.Errorf("decoding SurveyMessageResponseType: %w", err) + } + if _, ok := surveyMessageResponseTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid SurveyMessageResponseType enum value", v) + } + *e = SurveyMessageResponseType(v) + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s SurveyMessageResponseType) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SurveyMessageResponseType) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SurveyMessageResponseType)(nil) + _ encoding.BinaryUnmarshaler = (*SurveyMessageResponseType)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s SurveyMessageResponseType) xdrType() {} + +var _ xdrType = (*SurveyMessageResponseType)(nil) + +// TimeSlicedSurveyStartCollectingMessage is an XDR Struct defines as: +// +// struct TimeSlicedSurveyStartCollectingMessage +// { +// NodeID surveyorID; +// uint32 nonce; // uint32 ledgerNum; -// SurveyMessageCommandType commandType; -// EncryptedBody encryptedBody; // }; -type SurveyResponseMessage struct { - SurveyorPeerId NodeId - SurveyedPeerId NodeId - LedgerNum Uint32 - CommandType SurveyMessageCommandType - EncryptedBody EncryptedBody +type TimeSlicedSurveyStartCollectingMessage struct { + SurveyorId NodeId + Nonce Uint32 + LedgerNum Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *SurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { +func (s *TimeSlicedSurveyStartCollectingMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.SurveyorPeerId.EncodeTo(e); err != nil { + if err = s.SurveyorId.EncodeTo(e); err != nil { return err } - if err = s.SurveyedPeerId.EncodeTo(e); err != nil { + if err = s.Nonce.EncodeTo(e); err != nil { return err } if err = s.LedgerNum.EncodeTo(e); err != nil { return err } - if err = s.CommandType.EncodeTo(e); err != nil { - return err - } - if err = s.EncryptedBody.EncodeTo(e); err != nil { - return err - } return nil } -var _ decoderFrom = (*SurveyResponseMessage)(nil) +var _ decoderFrom = (*TimeSlicedSurveyStartCollectingMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TimeSlicedSurveyStartCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SurveyResponseMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TimeSlicedSurveyStartCollectingMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SurveyorPeerId.DecodeFrom(d, maxDepth) + nTmp, err = s.SurveyorId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.SurveyedPeerId.DecodeFrom(d, maxDepth) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding NodeId: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.CommandType.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) - } - nTmp, err = s.EncryptedBody.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding EncryptedBody: %w", err) - } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SurveyResponseMessage) MarshalBinary() ([]byte, error) { +func (s TimeSlicedSurveyStartCollectingMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21024,7 +21519,7 @@ func (s SurveyResponseMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SurveyResponseMessage) UnmarshalBinary(inp []byte) error { +func (s *TimeSlicedSurveyStartCollectingMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21034,64 +21529,64 @@ func (s *SurveyResponseMessage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SurveyResponseMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SurveyResponseMessage)(nil) + _ encoding.BinaryMarshaler = (*TimeSlicedSurveyStartCollectingMessage)(nil) + _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyStartCollectingMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SurveyResponseMessage) xdrType() {} +func (s TimeSlicedSurveyStartCollectingMessage) xdrType() {} -var _ xdrType = (*SurveyResponseMessage)(nil) +var _ xdrType = (*TimeSlicedSurveyStartCollectingMessage)(nil) -// TimeSlicedSurveyResponseMessage is an XDR Struct defines as: +// SignedTimeSlicedSurveyStartCollectingMessage is an XDR Struct defines as: // -// struct TimeSlicedSurveyResponseMessage +// struct SignedTimeSlicedSurveyStartCollectingMessage // { -// SurveyResponseMessage response; -// uint32 nonce; +// Signature signature; +// TimeSlicedSurveyStartCollectingMessage startCollecting; // }; -type TimeSlicedSurveyResponseMessage struct { - Response SurveyResponseMessage - Nonce Uint32 +type SignedTimeSlicedSurveyStartCollectingMessage struct { + Signature Signature + StartCollecting TimeSlicedSurveyStartCollectingMessage } // EncodeTo encodes this value using the Encoder. -func (s *TimeSlicedSurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { +func (s *SignedTimeSlicedSurveyStartCollectingMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Response.EncodeTo(e); err != nil { + if err = s.Signature.EncodeTo(e); err != nil { return err } - if err = s.Nonce.EncodeTo(e); err != nil { + if err = s.StartCollecting.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TimeSlicedSurveyResponseMessage)(nil) +var _ decoderFrom = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeSlicedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SignedTimeSlicedSurveyStartCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeSlicedSurveyResponseMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyStartCollectingMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Response.DecodeFrom(d, maxDepth) + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyResponseMessage: %w", err) + return n, fmt.Errorf("decoding Signature: %w", err) } - nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + nTmp, err = s.StartCollecting.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding TimeSlicedSurveyStartCollectingMessage: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeSlicedSurveyResponseMessage) MarshalBinary() ([]byte, error) { +func (s SignedTimeSlicedSurveyStartCollectingMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21099,7 +21594,7 @@ func (s TimeSlicedSurveyResponseMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeSlicedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { +func (s *SignedTimeSlicedSurveyStartCollectingMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21109,64 +21604,74 @@ func (s *TimeSlicedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TimeSlicedSurveyResponseMessage)(nil) - _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyResponseMessage)(nil) + _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeSlicedSurveyResponseMessage) xdrType() {} +func (s SignedTimeSlicedSurveyStartCollectingMessage) xdrType() {} -var _ xdrType = (*TimeSlicedSurveyResponseMessage)(nil) +var _ xdrType = (*SignedTimeSlicedSurveyStartCollectingMessage)(nil) -// SignedSurveyResponseMessage is an XDR Struct defines as: +// TimeSlicedSurveyStopCollectingMessage is an XDR Struct defines as: // -// struct SignedSurveyResponseMessage +// struct TimeSlicedSurveyStopCollectingMessage // { -// Signature responseSignature; -// SurveyResponseMessage response; +// NodeID surveyorID; +// uint32 nonce; +// uint32 ledgerNum; // }; -type SignedSurveyResponseMessage struct { - ResponseSignature Signature - Response SurveyResponseMessage +type TimeSlicedSurveyStopCollectingMessage struct { + SurveyorId NodeId + Nonce Uint32 + LedgerNum Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *SignedSurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { +func (s *TimeSlicedSurveyStopCollectingMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.ResponseSignature.EncodeTo(e); err != nil { + if err = s.SurveyorId.EncodeTo(e); err != nil { return err } - if err = s.Response.EncodeTo(e); err != nil { + if err = s.Nonce.EncodeTo(e); err != nil { + return err + } + if err = s.LedgerNum.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*SignedSurveyResponseMessage)(nil) +var _ decoderFrom = (*TimeSlicedSurveyStopCollectingMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TimeSlicedSurveyStopCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SignedSurveyResponseMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TimeSlicedSurveyStopCollectingMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ResponseSignature.DecodeFrom(d, maxDepth) + nTmp, err = s.SurveyorId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.Response.DecodeFrom(d, maxDepth) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyResponseMessage: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SignedSurveyResponseMessage) MarshalBinary() ([]byte, error) { +func (s TimeSlicedSurveyStopCollectingMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21174,7 +21679,7 @@ func (s SignedSurveyResponseMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SignedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { +func (s *TimeSlicedSurveyStopCollectingMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21184,64 +21689,64 @@ func (s *SignedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SignedSurveyResponseMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SignedSurveyResponseMessage)(nil) + _ encoding.BinaryMarshaler = (*TimeSlicedSurveyStopCollectingMessage)(nil) + _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyStopCollectingMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SignedSurveyResponseMessage) xdrType() {} +func (s TimeSlicedSurveyStopCollectingMessage) xdrType() {} -var _ xdrType = (*SignedSurveyResponseMessage)(nil) +var _ xdrType = (*TimeSlicedSurveyStopCollectingMessage)(nil) -// SignedTimeSlicedSurveyResponseMessage is an XDR Struct defines as: +// SignedTimeSlicedSurveyStopCollectingMessage is an XDR Struct defines as: // -// struct SignedTimeSlicedSurveyResponseMessage +// struct SignedTimeSlicedSurveyStopCollectingMessage // { -// Signature responseSignature; -// TimeSlicedSurveyResponseMessage response; +// Signature signature; +// TimeSlicedSurveyStopCollectingMessage stopCollecting; // }; -type SignedTimeSlicedSurveyResponseMessage struct { - ResponseSignature Signature - Response TimeSlicedSurveyResponseMessage +type SignedTimeSlicedSurveyStopCollectingMessage struct { + Signature Signature + StopCollecting TimeSlicedSurveyStopCollectingMessage } // EncodeTo encodes this value using the Encoder. -func (s *SignedTimeSlicedSurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { +func (s *SignedTimeSlicedSurveyStopCollectingMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.ResponseSignature.EncodeTo(e); err != nil { + if err = s.Signature.EncodeTo(e); err != nil { return err } - if err = s.Response.EncodeTo(e); err != nil { + if err = s.StopCollecting.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*SignedTimeSlicedSurveyResponseMessage)(nil) +var _ decoderFrom = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SignedTimeSlicedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SignedTimeSlicedSurveyStopCollectingMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyResponseMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyStopCollectingMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ResponseSignature.DecodeFrom(d, maxDepth) + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Signature: %w", err) } - nTmp, err = s.Response.DecodeFrom(d, maxDepth) + nTmp, err = s.StopCollecting.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeSlicedSurveyResponseMessage: %w", err) + return n, fmt.Errorf("decoding TimeSlicedSurveyStopCollectingMessage: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SignedTimeSlicedSurveyResponseMessage) MarshalBinary() ([]byte, error) { +func (s SignedTimeSlicedSurveyStopCollectingMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21249,7 +21754,7 @@ func (s SignedTimeSlicedSurveyResponseMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SignedTimeSlicedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { +func (s *SignedTimeSlicedSurveyStopCollectingMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21259,196 +21764,94 @@ func (s *SignedTimeSlicedSurveyResponseMessage) UnmarshalBinary(inp []byte) erro } var ( - _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyResponseMessage)(nil) - _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyResponseMessage)(nil) + _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SignedTimeSlicedSurveyResponseMessage) xdrType() {} +func (s SignedTimeSlicedSurveyStopCollectingMessage) xdrType() {} -var _ xdrType = (*SignedTimeSlicedSurveyResponseMessage)(nil) +var _ xdrType = (*SignedTimeSlicedSurveyStopCollectingMessage)(nil) -// PeerStats is an XDR Struct defines as: +// SurveyRequestMessage is an XDR Struct defines as: // -// struct PeerStats +// struct SurveyRequestMessage // { -// NodeID id; -// string versionStr<100>; -// uint64 messagesRead; -// uint64 messagesWritten; -// uint64 bytesRead; -// uint64 bytesWritten; -// uint64 secondsConnected; -// -// uint64 uniqueFloodBytesRecv; -// uint64 duplicateFloodBytesRecv; -// uint64 uniqueFetchBytesRecv; -// uint64 duplicateFetchBytesRecv; -// -// uint64 uniqueFloodMessageRecv; -// uint64 duplicateFloodMessageRecv; -// uint64 uniqueFetchMessageRecv; -// uint64 duplicateFetchMessageRecv; +// NodeID surveyorPeerID; +// NodeID surveyedPeerID; +// uint32 ledgerNum; +// Curve25519Public encryptionKey; +// SurveyMessageCommandType commandType; // }; -type PeerStats struct { - Id NodeId - VersionStr string `xdrmaxsize:"100"` - MessagesRead Uint64 - MessagesWritten Uint64 - BytesRead Uint64 - BytesWritten Uint64 - SecondsConnected Uint64 - UniqueFloodBytesRecv Uint64 - DuplicateFloodBytesRecv Uint64 - UniqueFetchBytesRecv Uint64 - DuplicateFetchBytesRecv Uint64 - UniqueFloodMessageRecv Uint64 - DuplicateFloodMessageRecv Uint64 - UniqueFetchMessageRecv Uint64 - DuplicateFetchMessageRecv Uint64 +type SurveyRequestMessage struct { + SurveyorPeerId NodeId + SurveyedPeerId NodeId + LedgerNum Uint32 + EncryptionKey Curve25519Public + CommandType SurveyMessageCommandType } // EncodeTo encodes this value using the Encoder. -func (s *PeerStats) EncodeTo(e *xdr.Encoder) error { +func (s *SurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Id.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeString(string(s.VersionStr)); err != nil { - return err - } - if err = s.MessagesRead.EncodeTo(e); err != nil { - return err - } - if err = s.MessagesWritten.EncodeTo(e); err != nil { - return err - } - if err = s.BytesRead.EncodeTo(e); err != nil { - return err - } - if err = s.BytesWritten.EncodeTo(e); err != nil { - return err - } - if err = s.SecondsConnected.EncodeTo(e); err != nil { - return err - } - if err = s.UniqueFloodBytesRecv.EncodeTo(e); err != nil { - return err - } - if err = s.DuplicateFloodBytesRecv.EncodeTo(e); err != nil { - return err - } - if err = s.UniqueFetchBytesRecv.EncodeTo(e); err != nil { - return err - } - if err = s.DuplicateFetchBytesRecv.EncodeTo(e); err != nil { + if err = s.SurveyorPeerId.EncodeTo(e); err != nil { return err } - if err = s.UniqueFloodMessageRecv.EncodeTo(e); err != nil { + if err = s.SurveyedPeerId.EncodeTo(e); err != nil { return err } - if err = s.DuplicateFloodMessageRecv.EncodeTo(e); err != nil { + if err = s.LedgerNum.EncodeTo(e); err != nil { return err } - if err = s.UniqueFetchMessageRecv.EncodeTo(e); err != nil { + if err = s.EncryptionKey.EncodeTo(e); err != nil { return err } - if err = s.DuplicateFetchMessageRecv.EncodeTo(e); err != nil { + if err = s.CommandType.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*PeerStats)(nil) +var _ decoderFrom = (*SurveyRequestMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PeerStats) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding PeerStats: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SurveyRequestMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Id.DecodeFrom(d, maxDepth) + nTmp, err = s.SurveyorPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding NodeId: %w", err) } - s.VersionStr, nTmp, err = d.DecodeString(100) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding VersionStr: %w", err) - } - nTmp, err = s.MessagesRead.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.MessagesWritten.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.BytesRead.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.BytesWritten.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.SecondsConnected.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.UniqueFloodBytesRecv.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.DuplicateFloodBytesRecv.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.UniqueFetchBytesRecv.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.DuplicateFetchBytesRecv.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.UniqueFloodMessageRecv.DecodeFrom(d, maxDepth) + nTmp, err = s.SurveyedPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.DuplicateFloodMessageRecv.DecodeFrom(d, maxDepth) + nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.UniqueFetchMessageRecv.DecodeFrom(d, maxDepth) + nTmp, err = s.EncryptionKey.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding Curve25519Public: %w", err) } - nTmp, err = s.DuplicateFetchMessageRecv.DecodeFrom(d, maxDepth) + nTmp, err = s.CommandType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PeerStats) MarshalBinary() ([]byte, error) { +func (s SurveyRequestMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21456,7 +21859,7 @@ func (s PeerStats) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PeerStats) UnmarshalBinary(inp []byte) error { +func (s *SurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21466,77 +21869,84 @@ func (s *PeerStats) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PeerStats)(nil) - _ encoding.BinaryUnmarshaler = (*PeerStats)(nil) + _ encoding.BinaryMarshaler = (*SurveyRequestMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SurveyRequestMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PeerStats) xdrType() {} +func (s SurveyRequestMessage) xdrType() {} -var _ xdrType = (*PeerStats)(nil) +var _ xdrType = (*SurveyRequestMessage)(nil) -// PeerStatList is an XDR Typedef defines as: +// TimeSlicedSurveyRequestMessage is an XDR Struct defines as: // -// typedef PeerStats PeerStatList<25>; -type PeerStatList []PeerStats - -// XDRMaxSize implements the Sized interface for PeerStatList -func (e PeerStatList) XDRMaxSize() int { - return 25 +// struct TimeSlicedSurveyRequestMessage +// { +// SurveyRequestMessage request; +// uint32 nonce; +// uint32 inboundPeersIndex; +// uint32 outboundPeersIndex; +// }; +type TimeSlicedSurveyRequestMessage struct { + Request SurveyRequestMessage + Nonce Uint32 + InboundPeersIndex Uint32 + OutboundPeersIndex Uint32 } // EncodeTo encodes this value using the Encoder. -func (s PeerStatList) EncodeTo(e *xdr.Encoder) error { +func (s *TimeSlicedSurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s))); err != nil { + if err = s.Request.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s); i++ { - if err = s[i].EncodeTo(e); err != nil { - return err - } + if err = s.Nonce.EncodeTo(e); err != nil { + return err + } + if err = s.InboundPeersIndex.EncodeTo(e); err != nil { + return err + } + if err = s.OutboundPeersIndex.EncodeTo(e); err != nil { + return err } return nil } -var _ decoderFrom = (*PeerStatList)(nil) +var _ decoderFrom = (*TimeSlicedSurveyRequestMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PeerStatList) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TimeSlicedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding PeerStatList: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TimeSlicedSurveyRequestMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.Request.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStats: %w", err) + return n, fmt.Errorf("decoding SurveyRequestMessage: %w", err) } - if l > 25 { - return n, fmt.Errorf("decoding PeerStats: data size (%d) exceeds size limit (25)", l) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } - (*s) = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding PeerStats: length (%d) exceeds remaining input length (%d)", l, il) - } - (*s) = make([]PeerStats, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PeerStats: %w", err) - } - } + nTmp, err = s.InboundPeersIndex.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.OutboundPeersIndex.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PeerStatList) MarshalBinary() ([]byte, error) { +func (s TimeSlicedSurveyRequestMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21544,7 +21954,7 @@ func (s PeerStatList) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PeerStatList) UnmarshalBinary(inp []byte) error { +func (s *TimeSlicedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21554,150 +21964,64 @@ func (s *PeerStatList) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PeerStatList)(nil) - _ encoding.BinaryUnmarshaler = (*PeerStatList)(nil) + _ encoding.BinaryMarshaler = (*TimeSlicedSurveyRequestMessage)(nil) + _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyRequestMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PeerStatList) xdrType() {} +func (s TimeSlicedSurveyRequestMessage) xdrType() {} -var _ xdrType = (*PeerStatList)(nil) +var _ xdrType = (*TimeSlicedSurveyRequestMessage)(nil) -// TimeSlicedNodeData is an XDR Struct defines as: +// SignedSurveyRequestMessage is an XDR Struct defines as: // -// struct TimeSlicedNodeData +// struct SignedSurveyRequestMessage // { -// uint32 addedAuthenticatedPeers; -// uint32 droppedAuthenticatedPeers; -// uint32 totalInboundPeerCount; -// uint32 totalOutboundPeerCount; -// -// // SCP stats -// uint32 p75SCPFirstToSelfLatencyMs; -// uint32 p75SCPSelfToOtherLatencyMs; -// -// // How many times the node lost sync in the time slice -// uint32 lostSyncCount; -// -// // Config data -// bool isValidator; -// uint32 maxInboundPeerCount; -// uint32 maxOutboundPeerCount; +// Signature requestSignature; +// SurveyRequestMessage request; // }; -type TimeSlicedNodeData struct { - AddedAuthenticatedPeers Uint32 - DroppedAuthenticatedPeers Uint32 - TotalInboundPeerCount Uint32 - TotalOutboundPeerCount Uint32 - P75ScpFirstToSelfLatencyMs Uint32 - P75ScpSelfToOtherLatencyMs Uint32 - LostSyncCount Uint32 - IsValidator bool - MaxInboundPeerCount Uint32 - MaxOutboundPeerCount Uint32 +type SignedSurveyRequestMessage struct { + RequestSignature Signature + Request SurveyRequestMessage } // EncodeTo encodes this value using the Encoder. -func (s *TimeSlicedNodeData) EncodeTo(e *xdr.Encoder) error { +func (s *SignedSurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.AddedAuthenticatedPeers.EncodeTo(e); err != nil { - return err - } - if err = s.DroppedAuthenticatedPeers.EncodeTo(e); err != nil { - return err - } - if err = s.TotalInboundPeerCount.EncodeTo(e); err != nil { - return err - } - if err = s.TotalOutboundPeerCount.EncodeTo(e); err != nil { - return err - } - if err = s.P75ScpFirstToSelfLatencyMs.EncodeTo(e); err != nil { - return err - } - if err = s.P75ScpSelfToOtherLatencyMs.EncodeTo(e); err != nil { - return err - } - if err = s.LostSyncCount.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeBool(bool(s.IsValidator)); err != nil { - return err - } - if err = s.MaxInboundPeerCount.EncodeTo(e); err != nil { + if err = s.RequestSignature.EncodeTo(e); err != nil { return err } - if err = s.MaxOutboundPeerCount.EncodeTo(e); err != nil { + if err = s.Request.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TimeSlicedNodeData)(nil) +var _ decoderFrom = (*SignedSurveyRequestMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeSlicedNodeData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SignedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeSlicedNodeData: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SignedSurveyRequestMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AddedAuthenticatedPeers.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.DroppedAuthenticatedPeers.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.P75ScpFirstToSelfLatencyMs.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.P75ScpSelfToOtherLatencyMs.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.LostSyncCount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - s.IsValidator, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Bool: %w", err) - } - nTmp, err = s.MaxInboundPeerCount.DecodeFrom(d, maxDepth) + nTmp, err = s.RequestSignature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Signature: %w", err) } - nTmp, err = s.MaxOutboundPeerCount.DecodeFrom(d, maxDepth) + nTmp, err = s.Request.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding SurveyRequestMessage: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeSlicedNodeData) MarshalBinary() ([]byte, error) { +func (s SignedSurveyRequestMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21705,7 +22029,7 @@ func (s TimeSlicedNodeData) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeSlicedNodeData) UnmarshalBinary(inp []byte) error { +func (s *SignedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21715,64 +22039,64 @@ func (s *TimeSlicedNodeData) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TimeSlicedNodeData)(nil) - _ encoding.BinaryUnmarshaler = (*TimeSlicedNodeData)(nil) + _ encoding.BinaryMarshaler = (*SignedSurveyRequestMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SignedSurveyRequestMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeSlicedNodeData) xdrType() {} +func (s SignedSurveyRequestMessage) xdrType() {} -var _ xdrType = (*TimeSlicedNodeData)(nil) +var _ xdrType = (*SignedSurveyRequestMessage)(nil) -// TimeSlicedPeerData is an XDR Struct defines as: +// SignedTimeSlicedSurveyRequestMessage is an XDR Struct defines as: // -// struct TimeSlicedPeerData +// struct SignedTimeSlicedSurveyRequestMessage // { -// PeerStats peerStats; -// uint32 averageLatencyMs; +// Signature requestSignature; +// TimeSlicedSurveyRequestMessage request; // }; -type TimeSlicedPeerData struct { - PeerStats PeerStats - AverageLatencyMs Uint32 +type SignedTimeSlicedSurveyRequestMessage struct { + RequestSignature Signature + Request TimeSlicedSurveyRequestMessage } // EncodeTo encodes this value using the Encoder. -func (s *TimeSlicedPeerData) EncodeTo(e *xdr.Encoder) error { +func (s *SignedTimeSlicedSurveyRequestMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.PeerStats.EncodeTo(e); err != nil { + if err = s.RequestSignature.EncodeTo(e); err != nil { return err } - if err = s.AverageLatencyMs.EncodeTo(e); err != nil { + if err = s.Request.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TimeSlicedPeerData)(nil) +var _ decoderFrom = (*SignedTimeSlicedSurveyRequestMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeSlicedPeerData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SignedTimeSlicedSurveyRequestMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeSlicedPeerData: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyRequestMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.PeerStats.DecodeFrom(d, maxDepth) + nTmp, err = s.RequestSignature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStats: %w", err) + return n, fmt.Errorf("decoding Signature: %w", err) } - nTmp, err = s.AverageLatencyMs.DecodeFrom(d, maxDepth) + nTmp, err = s.Request.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding TimeSlicedSurveyRequestMessage: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeSlicedPeerData) MarshalBinary() ([]byte, error) { +func (s SignedTimeSlicedSurveyRequestMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21780,7 +22104,7 @@ func (s TimeSlicedPeerData) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeSlicedPeerData) UnmarshalBinary(inp []byte) error { +func (s *SignedTimeSlicedSurveyRequestMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21790,77 +22114,54 @@ func (s *TimeSlicedPeerData) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TimeSlicedPeerData)(nil) - _ encoding.BinaryUnmarshaler = (*TimeSlicedPeerData)(nil) + _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyRequestMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyRequestMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeSlicedPeerData) xdrType() {} +func (s SignedTimeSlicedSurveyRequestMessage) xdrType() {} -var _ xdrType = (*TimeSlicedPeerData)(nil) +var _ xdrType = (*SignedTimeSlicedSurveyRequestMessage)(nil) -// TimeSlicedPeerDataList is an XDR Typedef defines as: +// EncryptedBody is an XDR Typedef defines as: // -// typedef TimeSlicedPeerData TimeSlicedPeerDataList<25>; -type TimeSlicedPeerDataList []TimeSlicedPeerData +// typedef opaque EncryptedBody<64000>; +type EncryptedBody []byte -// XDRMaxSize implements the Sized interface for TimeSlicedPeerDataList -func (e TimeSlicedPeerDataList) XDRMaxSize() int { - return 25 +// XDRMaxSize implements the Sized interface for EncryptedBody +func (e EncryptedBody) XDRMaxSize() int { + return 64000 } // EncodeTo encodes this value using the Encoder. -func (s TimeSlicedPeerDataList) EncodeTo(e *xdr.Encoder) error { +func (s EncryptedBody) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s))); err != nil { + if _, err = e.EncodeOpaque(s[:]); err != nil { return err } - for i := 0; i < len(s); i++ { - if err = s[i].EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*TimeSlicedPeerDataList)(nil) +var _ decoderFrom = (*EncryptedBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeSlicedPeerDataList) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *EncryptedBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeSlicedPeerDataList: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding EncryptedBody: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var l uint32 - l, nTmp, err = d.DecodeUint() + (*s), nTmp, err = d.DecodeOpaque(64000) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeSlicedPeerData: %w", err) - } - if l > 25 { - return n, fmt.Errorf("decoding TimeSlicedPeerData: data size (%d) exceeds size limit (25)", l) - } - (*s) = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding TimeSlicedPeerData: length (%d) exceeds remaining input length (%d)", l, il) - } - (*s) = make([]TimeSlicedPeerData, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TimeSlicedPeerData: %w", err) - } - } + return n, fmt.Errorf("decoding EncryptedBody: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeSlicedPeerDataList) MarshalBinary() ([]byte, error) { +func (s EncryptedBody) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21868,7 +22169,7 @@ func (s TimeSlicedPeerDataList) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeSlicedPeerDataList) UnmarshalBinary(inp []byte) error { +func (s *EncryptedBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21878,85 +22179,94 @@ func (s *TimeSlicedPeerDataList) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TimeSlicedPeerDataList)(nil) - _ encoding.BinaryUnmarshaler = (*TimeSlicedPeerDataList)(nil) + _ encoding.BinaryMarshaler = (*EncryptedBody)(nil) + _ encoding.BinaryUnmarshaler = (*EncryptedBody)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeSlicedPeerDataList) xdrType() {} +func (s EncryptedBody) xdrType() {} -var _ xdrType = (*TimeSlicedPeerDataList)(nil) +var _ xdrType = (*EncryptedBody)(nil) -// TopologyResponseBodyV0 is an XDR Struct defines as: +// SurveyResponseMessage is an XDR Struct defines as: // -// struct TopologyResponseBodyV0 +// struct SurveyResponseMessage // { -// PeerStatList inboundPeers; -// PeerStatList outboundPeers; -// -// uint32 totalInboundPeerCount; -// uint32 totalOutboundPeerCount; +// NodeID surveyorPeerID; +// NodeID surveyedPeerID; +// uint32 ledgerNum; +// SurveyMessageCommandType commandType; +// EncryptedBody encryptedBody; // }; -type TopologyResponseBodyV0 struct { - InboundPeers PeerStatList - OutboundPeers PeerStatList - TotalInboundPeerCount Uint32 - TotalOutboundPeerCount Uint32 +type SurveyResponseMessage struct { + SurveyorPeerId NodeId + SurveyedPeerId NodeId + LedgerNum Uint32 + CommandType SurveyMessageCommandType + EncryptedBody EncryptedBody } // EncodeTo encodes this value using the Encoder. -func (s *TopologyResponseBodyV0) EncodeTo(e *xdr.Encoder) error { +func (s *SurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.InboundPeers.EncodeTo(e); err != nil { + if err = s.SurveyorPeerId.EncodeTo(e); err != nil { return err } - if err = s.OutboundPeers.EncodeTo(e); err != nil { + if err = s.SurveyedPeerId.EncodeTo(e); err != nil { return err } - if err = s.TotalInboundPeerCount.EncodeTo(e); err != nil { + if err = s.LedgerNum.EncodeTo(e); err != nil { return err } - if err = s.TotalOutboundPeerCount.EncodeTo(e); err != nil { + if err = s.CommandType.EncodeTo(e); err != nil { + return err + } + if err = s.EncryptedBody.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TopologyResponseBodyV0)(nil) +var _ decoderFrom = (*SurveyResponseMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TopologyResponseBodyV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TopologyResponseBodyV0: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SurveyResponseMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) + nTmp, err = s.SurveyorPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %w", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) + nTmp, err = s.SurveyedPeerId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %w", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) + nTmp, err = s.LedgerNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) + nTmp, err = s.CommandType.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding SurveyMessageCommandType: %w", err) + } + nTmp, err = s.EncryptedBody.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding EncryptedBody: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TopologyResponseBodyV0) MarshalBinary() ([]byte, error) { +func (s SurveyResponseMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -21964,7 +22274,7 @@ func (s TopologyResponseBodyV0) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TopologyResponseBodyV0) UnmarshalBinary(inp []byte) error { +func (s *SurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -21974,97 +22284,55 @@ func (s *TopologyResponseBodyV0) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TopologyResponseBodyV0)(nil) - _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV0)(nil) + _ encoding.BinaryMarshaler = (*SurveyResponseMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SurveyResponseMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TopologyResponseBodyV0) xdrType() {} +func (s SurveyResponseMessage) xdrType() {} -var _ xdrType = (*TopologyResponseBodyV0)(nil) +var _ xdrType = (*SurveyResponseMessage)(nil) -// TopologyResponseBodyV1 is an XDR Struct defines as: +// TimeSlicedSurveyResponseMessage is an XDR Struct defines as: // -// struct TopologyResponseBodyV1 +// struct TimeSlicedSurveyResponseMessage // { -// PeerStatList inboundPeers; -// PeerStatList outboundPeers; -// -// uint32 totalInboundPeerCount; -// uint32 totalOutboundPeerCount; -// -// uint32 maxInboundPeerCount; -// uint32 maxOutboundPeerCount; +// SurveyResponseMessage response; +// uint32 nonce; // }; -type TopologyResponseBodyV1 struct { - InboundPeers PeerStatList - OutboundPeers PeerStatList - TotalInboundPeerCount Uint32 - TotalOutboundPeerCount Uint32 - MaxInboundPeerCount Uint32 - MaxOutboundPeerCount Uint32 +type TimeSlicedSurveyResponseMessage struct { + Response SurveyResponseMessage + Nonce Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *TopologyResponseBodyV1) EncodeTo(e *xdr.Encoder) error { +func (s *TimeSlicedSurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.InboundPeers.EncodeTo(e); err != nil { - return err - } - if err = s.OutboundPeers.EncodeTo(e); err != nil { - return err - } - if err = s.TotalInboundPeerCount.EncodeTo(e); err != nil { - return err - } - if err = s.TotalOutboundPeerCount.EncodeTo(e); err != nil { - return err - } - if err = s.MaxInboundPeerCount.EncodeTo(e); err != nil { + if err = s.Response.EncodeTo(e); err != nil { return err } - if err = s.MaxOutboundPeerCount.EncodeTo(e); err != nil { + if err = s.Nonce.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TopologyResponseBodyV1)(nil) +var _ decoderFrom = (*TimeSlicedSurveyResponseMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TopologyResponseBodyV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TimeSlicedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TopologyResponseBodyV1: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TimeSlicedSurveyResponseMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %w", err) - } - nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PeerStatList: %w", err) - } - nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.MaxInboundPeerCount.DecodeFrom(d, maxDepth) + nTmp, err = s.Response.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding SurveyResponseMessage: %w", err) } - nTmp, err = s.MaxOutboundPeerCount.DecodeFrom(d, maxDepth) + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) @@ -22073,7 +22341,7 @@ func (s *TopologyResponseBodyV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TopologyResponseBodyV1) MarshalBinary() ([]byte, error) { +func (s TimeSlicedSurveyResponseMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -22081,7 +22349,7 @@ func (s TopologyResponseBodyV1) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TopologyResponseBodyV1) UnmarshalBinary(inp []byte) error { +func (s *TimeSlicedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -22091,74 +22359,64 @@ func (s *TopologyResponseBodyV1) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TopologyResponseBodyV1)(nil) - _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV1)(nil) + _ encoding.BinaryMarshaler = (*TimeSlicedSurveyResponseMessage)(nil) + _ encoding.BinaryUnmarshaler = (*TimeSlicedSurveyResponseMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TopologyResponseBodyV1) xdrType() {} +func (s TimeSlicedSurveyResponseMessage) xdrType() {} -var _ xdrType = (*TopologyResponseBodyV1)(nil) +var _ xdrType = (*TimeSlicedSurveyResponseMessage)(nil) -// TopologyResponseBodyV2 is an XDR Struct defines as: +// SignedSurveyResponseMessage is an XDR Struct defines as: // -// struct TopologyResponseBodyV2 +// struct SignedSurveyResponseMessage // { -// TimeSlicedPeerDataList inboundPeers; -// TimeSlicedPeerDataList outboundPeers; -// TimeSlicedNodeData nodeData; +// Signature responseSignature; +// SurveyResponseMessage response; // }; -type TopologyResponseBodyV2 struct { - InboundPeers TimeSlicedPeerDataList - OutboundPeers TimeSlicedPeerDataList - NodeData TimeSlicedNodeData +type SignedSurveyResponseMessage struct { + ResponseSignature Signature + Response SurveyResponseMessage } // EncodeTo encodes this value using the Encoder. -func (s *TopologyResponseBodyV2) EncodeTo(e *xdr.Encoder) error { +func (s *SignedSurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.InboundPeers.EncodeTo(e); err != nil { - return err - } - if err = s.OutboundPeers.EncodeTo(e); err != nil { + if err = s.ResponseSignature.EncodeTo(e); err != nil { return err } - if err = s.NodeData.EncodeTo(e); err != nil { + if err = s.Response.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TopologyResponseBodyV2)(nil) +var _ decoderFrom = (*SignedSurveyResponseMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TopologyResponseBodyV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SignedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TopologyResponseBodyV2: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SignedSurveyResponseMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TimeSlicedPeerDataList: %w", err) - } - nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) + nTmp, err = s.ResponseSignature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeSlicedPeerDataList: %w", err) + return n, fmt.Errorf("decoding Signature: %w", err) } - nTmp, err = s.NodeData.DecodeFrom(d, maxDepth) + nTmp, err = s.Response.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeSlicedNodeData: %w", err) + return n, fmt.Errorf("decoding SurveyResponseMessage: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TopologyResponseBodyV2) MarshalBinary() ([]byte, error) { +func (s SignedSurveyResponseMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -22166,7 +22424,7 @@ func (s TopologyResponseBodyV2) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TopologyResponseBodyV2) UnmarshalBinary(inp []byte) error { +func (s *SignedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -22176,229 +22434,64 @@ func (s *TopologyResponseBodyV2) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TopologyResponseBodyV2)(nil) - _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV2)(nil) + _ encoding.BinaryMarshaler = (*SignedSurveyResponseMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SignedSurveyResponseMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TopologyResponseBodyV2) xdrType() {} +func (s SignedSurveyResponseMessage) xdrType() {} -var _ xdrType = (*TopologyResponseBodyV2)(nil) +var _ xdrType = (*SignedSurveyResponseMessage)(nil) -// SurveyResponseBody is an XDR Union defines as: +// SignedTimeSlicedSurveyResponseMessage is an XDR Struct defines as: // -// union SurveyResponseBody switch (SurveyMessageResponseType type) +// struct SignedTimeSlicedSurveyResponseMessage // { -// case SURVEY_TOPOLOGY_RESPONSE_V0: -// TopologyResponseBodyV0 topologyResponseBodyV0; -// case SURVEY_TOPOLOGY_RESPONSE_V1: -// TopologyResponseBodyV1 topologyResponseBodyV1; -// case SURVEY_TOPOLOGY_RESPONSE_V2: -// TopologyResponseBodyV2 topologyResponseBodyV2; +// Signature responseSignature; +// TimeSlicedSurveyResponseMessage response; // }; -type SurveyResponseBody struct { - Type SurveyMessageResponseType - TopologyResponseBodyV0 *TopologyResponseBodyV0 - TopologyResponseBodyV1 *TopologyResponseBodyV1 - TopologyResponseBodyV2 *TopologyResponseBodyV2 -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u SurveyResponseBody) SwitchFieldName() string { - return "Type" -} - -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of SurveyResponseBody -func (u SurveyResponseBody) ArmForSwitch(sw int32) (string, bool) { - switch SurveyMessageResponseType(sw) { - case SurveyMessageResponseTypeSurveyTopologyResponseV0: - return "TopologyResponseBodyV0", true - case SurveyMessageResponseTypeSurveyTopologyResponseV1: - return "TopologyResponseBodyV1", true - case SurveyMessageResponseTypeSurveyTopologyResponseV2: - return "TopologyResponseBodyV2", true - } - return "-", false -} - -// NewSurveyResponseBody creates a new SurveyResponseBody. -func NewSurveyResponseBody(aType SurveyMessageResponseType, value interface{}) (result SurveyResponseBody, err error) { - result.Type = aType - switch SurveyMessageResponseType(aType) { - case SurveyMessageResponseTypeSurveyTopologyResponseV0: - tv, ok := value.(TopologyResponseBodyV0) - if !ok { - err = errors.New("invalid value, must be TopologyResponseBodyV0") - return - } - result.TopologyResponseBodyV0 = &tv - case SurveyMessageResponseTypeSurveyTopologyResponseV1: - tv, ok := value.(TopologyResponseBodyV1) - if !ok { - err = errors.New("invalid value, must be TopologyResponseBodyV1") - return - } - result.TopologyResponseBodyV1 = &tv - case SurveyMessageResponseTypeSurveyTopologyResponseV2: - tv, ok := value.(TopologyResponseBodyV2) - if !ok { - err = errors.New("invalid value, must be TopologyResponseBodyV2") - return - } - result.TopologyResponseBodyV2 = &tv - } - return -} - -// MustTopologyResponseBodyV0 retrieves the TopologyResponseBodyV0 value from the union, -// panicing if the value is not set. -func (u SurveyResponseBody) MustTopologyResponseBodyV0() TopologyResponseBodyV0 { - val, ok := u.GetTopologyResponseBodyV0() - - if !ok { - panic("arm TopologyResponseBodyV0 is not set") - } - - return val -} - -// GetTopologyResponseBodyV0 retrieves the TopologyResponseBodyV0 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u SurveyResponseBody) GetTopologyResponseBodyV0() (result TopologyResponseBodyV0, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "TopologyResponseBodyV0" { - result = *u.TopologyResponseBodyV0 - ok = true - } - - return -} - -// MustTopologyResponseBodyV1 retrieves the TopologyResponseBodyV1 value from the union, -// panicing if the value is not set. -func (u SurveyResponseBody) MustTopologyResponseBodyV1() TopologyResponseBodyV1 { - val, ok := u.GetTopologyResponseBodyV1() - - if !ok { - panic("arm TopologyResponseBodyV1 is not set") - } - - return val -} - -// GetTopologyResponseBodyV1 retrieves the TopologyResponseBodyV1 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u SurveyResponseBody) GetTopologyResponseBodyV1() (result TopologyResponseBodyV1, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "TopologyResponseBodyV1" { - result = *u.TopologyResponseBodyV1 - ok = true - } - - return -} - -// MustTopologyResponseBodyV2 retrieves the TopologyResponseBodyV2 value from the union, -// panicing if the value is not set. -func (u SurveyResponseBody) MustTopologyResponseBodyV2() TopologyResponseBodyV2 { - val, ok := u.GetTopologyResponseBodyV2() - - if !ok { - panic("arm TopologyResponseBodyV2 is not set") - } - - return val -} - -// GetTopologyResponseBodyV2 retrieves the TopologyResponseBodyV2 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u SurveyResponseBody) GetTopologyResponseBodyV2() (result TopologyResponseBodyV2, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "TopologyResponseBodyV2" { - result = *u.TopologyResponseBodyV2 - ok = true - } - - return +type SignedTimeSlicedSurveyResponseMessage struct { + ResponseSignature Signature + Response TimeSlicedSurveyResponseMessage } // EncodeTo encodes this value using the Encoder. -func (u SurveyResponseBody) EncodeTo(e *xdr.Encoder) error { +func (s *SignedTimeSlicedSurveyResponseMessage) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if err = s.ResponseSignature.EncodeTo(e); err != nil { return err } - switch SurveyMessageResponseType(u.Type) { - case SurveyMessageResponseTypeSurveyTopologyResponseV0: - if err = (*u.TopologyResponseBodyV0).EncodeTo(e); err != nil { - return err - } - return nil - case SurveyMessageResponseTypeSurveyTopologyResponseV1: - if err = (*u.TopologyResponseBodyV1).EncodeTo(e); err != nil { - return err - } - return nil - case SurveyMessageResponseTypeSurveyTopologyResponseV2: - if err = (*u.TopologyResponseBodyV2).EncodeTo(e); err != nil { - return err - } - return nil + if err = s.Response.EncodeTo(e); err != nil { + return err } - return fmt.Errorf("Type (SurveyMessageResponseType) switch value '%d' is not valid for union SurveyResponseBody", u.Type) + return nil } -var _ decoderFrom = (*SurveyResponseBody)(nil) +var _ decoderFrom = (*SignedTimeSlicedSurveyResponseMessage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *SurveyResponseBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SignedTimeSlicedSurveyResponseMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SurveyResponseBody: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SignedTimeSlicedSurveyResponseMessage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + nTmp, err = s.ResponseSignature.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SurveyMessageResponseType: %w", err) + return n, fmt.Errorf("decoding Signature: %w", err) } - switch SurveyMessageResponseType(u.Type) { - case SurveyMessageResponseTypeSurveyTopologyResponseV0: - u.TopologyResponseBodyV0 = new(TopologyResponseBodyV0) - nTmp, err = (*u.TopologyResponseBodyV0).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TopologyResponseBodyV0: %w", err) - } - return n, nil - case SurveyMessageResponseTypeSurveyTopologyResponseV1: - u.TopologyResponseBodyV1 = new(TopologyResponseBodyV1) - nTmp, err = (*u.TopologyResponseBodyV1).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TopologyResponseBodyV1: %w", err) - } - return n, nil - case SurveyMessageResponseTypeSurveyTopologyResponseV2: - u.TopologyResponseBodyV2 = new(TopologyResponseBodyV2) - nTmp, err = (*u.TopologyResponseBodyV2).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TopologyResponseBodyV2: %w", err) - } - return n, nil + nTmp, err = s.Response.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TimeSlicedSurveyResponseMessage: %w", err) } - return n, fmt.Errorf("union SurveyResponseBody has invalid Type (SurveyMessageResponseType) switch value '%d'", u.Type) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SurveyResponseBody) MarshalBinary() ([]byte, error) { +func (s SignedTimeSlicedSurveyResponseMessage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -22406,7 +22499,7 @@ func (s SurveyResponseBody) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SurveyResponseBody) UnmarshalBinary(inp []byte) error { +func (s *SignedTimeSlicedSurveyResponseMessage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -22416,147 +22509,196 @@ func (s *SurveyResponseBody) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SurveyResponseBody)(nil) - _ encoding.BinaryUnmarshaler = (*SurveyResponseBody)(nil) + _ encoding.BinaryMarshaler = (*SignedTimeSlicedSurveyResponseMessage)(nil) + _ encoding.BinaryUnmarshaler = (*SignedTimeSlicedSurveyResponseMessage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SurveyResponseBody) xdrType() {} +func (s SignedTimeSlicedSurveyResponseMessage) xdrType() {} -var _ xdrType = (*SurveyResponseBody)(nil) +var _ xdrType = (*SignedTimeSlicedSurveyResponseMessage)(nil) -// TxAdvertVectorMaxSize is an XDR Const defines as: +// PeerStats is an XDR Struct defines as: // -// const TX_ADVERT_VECTOR_MAX_SIZE = 1000; -const TxAdvertVectorMaxSize = 1000 - -// TxAdvertVector is an XDR Typedef defines as: +// struct PeerStats +// { +// NodeID id; +// string versionStr<100>; +// uint64 messagesRead; +// uint64 messagesWritten; +// uint64 bytesRead; +// uint64 bytesWritten; +// uint64 secondsConnected; // -// typedef Hash TxAdvertVector; -type TxAdvertVector []Hash - -// XDRMaxSize implements the Sized interface for TxAdvertVector -func (e TxAdvertVector) XDRMaxSize() int { - return 1000 +// uint64 uniqueFloodBytesRecv; +// uint64 duplicateFloodBytesRecv; +// uint64 uniqueFetchBytesRecv; +// uint64 duplicateFetchBytesRecv; +// +// uint64 uniqueFloodMessageRecv; +// uint64 duplicateFloodMessageRecv; +// uint64 uniqueFetchMessageRecv; +// uint64 duplicateFetchMessageRecv; +// }; +type PeerStats struct { + Id NodeId + VersionStr string `xdrmaxsize:"100"` + MessagesRead Uint64 + MessagesWritten Uint64 + BytesRead Uint64 + BytesWritten Uint64 + SecondsConnected Uint64 + UniqueFloodBytesRecv Uint64 + DuplicateFloodBytesRecv Uint64 + UniqueFetchBytesRecv Uint64 + DuplicateFetchBytesRecv Uint64 + UniqueFloodMessageRecv Uint64 + DuplicateFloodMessageRecv Uint64 + UniqueFetchMessageRecv Uint64 + DuplicateFetchMessageRecv Uint64 } // EncodeTo encodes this value using the Encoder. -func (s TxAdvertVector) EncodeTo(e *xdr.Encoder) error { +func (s *PeerStats) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s))); err != nil { + if err = s.Id.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s); i++ { - if err = s[i].EncodeTo(e); err != nil { - return err - } + if _, err = e.EncodeString(string(s.VersionStr)); err != nil { + return err + } + if err = s.MessagesRead.EncodeTo(e); err != nil { + return err + } + if err = s.MessagesWritten.EncodeTo(e); err != nil { + return err + } + if err = s.BytesRead.EncodeTo(e); err != nil { + return err + } + if err = s.BytesWritten.EncodeTo(e); err != nil { + return err + } + if err = s.SecondsConnected.EncodeTo(e); err != nil { + return err + } + if err = s.UniqueFloodBytesRecv.EncodeTo(e); err != nil { + return err + } + if err = s.DuplicateFloodBytesRecv.EncodeTo(e); err != nil { + return err + } + if err = s.UniqueFetchBytesRecv.EncodeTo(e); err != nil { + return err + } + if err = s.DuplicateFetchBytesRecv.EncodeTo(e); err != nil { + return err + } + if err = s.UniqueFloodMessageRecv.EncodeTo(e); err != nil { + return err + } + if err = s.DuplicateFloodMessageRecv.EncodeTo(e); err != nil { + return err + } + if err = s.UniqueFetchMessageRecv.EncodeTo(e); err != nil { + return err + } + if err = s.DuplicateFetchMessageRecv.EncodeTo(e); err != nil { + return err } return nil } -var _ decoderFrom = (*TxAdvertVector)(nil) +var _ decoderFrom = (*PeerStats)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TxAdvertVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *PeerStats) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TxAdvertVector: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding PeerStats: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.Id.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + return n, fmt.Errorf("decoding NodeId: %w", err) } - if l > 1000 { - return n, fmt.Errorf("decoding Hash: data size (%d) exceeds size limit (1000)", l) + s.VersionStr, nTmp, err = d.DecodeString(100) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding VersionStr: %w", err) } - (*s) = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) - } - (*s) = make([]Hash, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - } + nTmp, err = s.MessagesRead.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s TxAdvertVector) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TxAdvertVector) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*TxAdvertVector)(nil) - _ encoding.BinaryUnmarshaler = (*TxAdvertVector)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s TxAdvertVector) xdrType() {} - -var _ xdrType = (*TxAdvertVector)(nil) - -// FloodAdvert is an XDR Struct defines as: -// -// struct FloodAdvert -// { -// TxAdvertVector txHashes; -// }; -type FloodAdvert struct { - TxHashes TxAdvertVector -} - -// EncodeTo encodes this value using the Encoder. -func (s *FloodAdvert) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.TxHashes.EncodeTo(e); err != nil { - return err + nTmp, err = s.MessagesWritten.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) } - return nil -} - -var _ decoderFrom = (*FloodAdvert)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *FloodAdvert) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding FloodAdvert: %w", ErrMaxDecodingDepthReached) + nTmp, err = s.BytesRead.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.TxHashes.DecodeFrom(d, maxDepth) + nTmp, err = s.BytesWritten.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxAdvertVector: %w", err) + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.SecondsConnected.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.UniqueFloodBytesRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.DuplicateFloodBytesRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.UniqueFetchBytesRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.DuplicateFetchBytesRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.UniqueFloodMessageRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.DuplicateFloodMessageRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.UniqueFetchMessageRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.DuplicateFetchMessageRecv.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s FloodAdvert) MarshalBinary() ([]byte, error) { +func (s PeerStats) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -22564,7 +22706,7 @@ func (s FloodAdvert) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *FloodAdvert) UnmarshalBinary(inp []byte) error { +func (s *PeerStats) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -22574,32 +22716,27 @@ func (s *FloodAdvert) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*FloodAdvert)(nil) - _ encoding.BinaryUnmarshaler = (*FloodAdvert)(nil) + _ encoding.BinaryMarshaler = (*PeerStats)(nil) + _ encoding.BinaryUnmarshaler = (*PeerStats)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s FloodAdvert) xdrType() {} - -var _ xdrType = (*FloodAdvert)(nil) +func (s PeerStats) xdrType() {} -// TxDemandVectorMaxSize is an XDR Const defines as: -// -// const TX_DEMAND_VECTOR_MAX_SIZE = 1000; -const TxDemandVectorMaxSize = 1000 +var _ xdrType = (*PeerStats)(nil) -// TxDemandVector is an XDR Typedef defines as: +// PeerStatList is an XDR Typedef defines as: // -// typedef Hash TxDemandVector; -type TxDemandVector []Hash +// typedef PeerStats PeerStatList<25>; +type PeerStatList []PeerStats -// XDRMaxSize implements the Sized interface for TxDemandVector -func (e TxDemandVector) XDRMaxSize() int { - return 1000 +// XDRMaxSize implements the Sized interface for PeerStatList +func (e PeerStatList) XDRMaxSize() int { + return 25 } // EncodeTo encodes this value using the Encoder. -func (s TxDemandVector) EncodeTo(e *xdr.Encoder) error { +func (s PeerStatList) EncodeTo(e *xdr.Encoder) error { var err error if _, err = e.EncodeUint(uint32(len(s))); err != nil { return err @@ -22612,12 +22749,12 @@ func (s TxDemandVector) EncodeTo(e *xdr.Encoder) error { return nil } -var _ decoderFrom = (*TxDemandVector)(nil) +var _ decoderFrom = (*PeerStatList)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *PeerStatList) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TxDemandVector: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding PeerStatList: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -22626,22 +22763,22 @@ func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + return n, fmt.Errorf("decoding PeerStats: %w", err) } - if l > 1000 { - return n, fmt.Errorf("decoding Hash: data size (%d) exceeds size limit (1000)", l) + if l > 25 { + return n, fmt.Errorf("decoding PeerStats: data size (%d) exceeds size limit (25)", l) } (*s) = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding PeerStats: length (%d) exceeds remaining input length (%d)", l, il) } - (*s) = make([]Hash, l) + (*s) = make([]PeerStats, l) for i := uint32(0); i < l; i++ { nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + return n, fmt.Errorf("decoding PeerStats: %w", err) } } } @@ -22649,7 +22786,7 @@ func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TxDemandVector) MarshalBinary() ([]byte, error) { +func (s PeerStatList) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -22657,7 +22794,7 @@ func (s TxDemandVector) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TxDemandVector) UnmarshalBinary(inp []byte) error { +func (s *PeerStatList) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -22667,54 +22804,150 @@ func (s *TxDemandVector) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TxDemandVector)(nil) - _ encoding.BinaryUnmarshaler = (*TxDemandVector)(nil) + _ encoding.BinaryMarshaler = (*PeerStatList)(nil) + _ encoding.BinaryUnmarshaler = (*PeerStatList)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TxDemandVector) xdrType() {} +func (s PeerStatList) xdrType() {} -var _ xdrType = (*TxDemandVector)(nil) +var _ xdrType = (*PeerStatList)(nil) -// FloodDemand is an XDR Struct defines as: +// TimeSlicedNodeData is an XDR Struct defines as: // -// struct FloodDemand +// struct TimeSlicedNodeData // { -// TxDemandVector txHashes; +// uint32 addedAuthenticatedPeers; +// uint32 droppedAuthenticatedPeers; +// uint32 totalInboundPeerCount; +// uint32 totalOutboundPeerCount; +// +// // SCP stats +// uint32 p75SCPFirstToSelfLatencyMs; +// uint32 p75SCPSelfToOtherLatencyMs; +// +// // How many times the node lost sync in the time slice +// uint32 lostSyncCount; +// +// // Config data +// bool isValidator; +// uint32 maxInboundPeerCount; +// uint32 maxOutboundPeerCount; // }; -type FloodDemand struct { - TxHashes TxDemandVector +type TimeSlicedNodeData struct { + AddedAuthenticatedPeers Uint32 + DroppedAuthenticatedPeers Uint32 + TotalInboundPeerCount Uint32 + TotalOutboundPeerCount Uint32 + P75ScpFirstToSelfLatencyMs Uint32 + P75ScpSelfToOtherLatencyMs Uint32 + LostSyncCount Uint32 + IsValidator bool + MaxInboundPeerCount Uint32 + MaxOutboundPeerCount Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *FloodDemand) EncodeTo(e *xdr.Encoder) error { +func (s *TimeSlicedNodeData) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.TxHashes.EncodeTo(e); err != nil { + if err = s.AddedAuthenticatedPeers.EncodeTo(e); err != nil { + return err + } + if err = s.DroppedAuthenticatedPeers.EncodeTo(e); err != nil { + return err + } + if err = s.TotalInboundPeerCount.EncodeTo(e); err != nil { + return err + } + if err = s.TotalOutboundPeerCount.EncodeTo(e); err != nil { + return err + } + if err = s.P75ScpFirstToSelfLatencyMs.EncodeTo(e); err != nil { + return err + } + if err = s.P75ScpSelfToOtherLatencyMs.EncodeTo(e); err != nil { + return err + } + if err = s.LostSyncCount.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeBool(bool(s.IsValidator)); err != nil { + return err + } + if err = s.MaxInboundPeerCount.EncodeTo(e); err != nil { + return err + } + if err = s.MaxOutboundPeerCount.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*FloodDemand)(nil) +var _ decoderFrom = (*TimeSlicedNodeData)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *FloodDemand) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TimeSlicedNodeData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding FloodDemand: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TimeSlicedNodeData: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.TxHashes.DecodeFrom(d, maxDepth) + nTmp, err = s.AddedAuthenticatedPeers.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TxDemandVector: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.DroppedAuthenticatedPeers.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.P75ScpFirstToSelfLatencyMs.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.P75ScpSelfToOtherLatencyMs.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.LostSyncCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.IsValidator, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Bool: %w", err) + } + nTmp, err = s.MaxInboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.MaxOutboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s FloodDemand) MarshalBinary() ([]byte, error) { +func (s TimeSlicedNodeData) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -22722,7 +22955,7 @@ func (s FloodDemand) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *FloodDemand) UnmarshalBinary(inp []byte) error { +func (s *TimeSlicedNodeData) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -22732,1277 +22965,941 @@ func (s *FloodDemand) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*FloodDemand)(nil) - _ encoding.BinaryUnmarshaler = (*FloodDemand)(nil) + _ encoding.BinaryMarshaler = (*TimeSlicedNodeData)(nil) + _ encoding.BinaryUnmarshaler = (*TimeSlicedNodeData)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s FloodDemand) xdrType() {} +func (s TimeSlicedNodeData) xdrType() {} -var _ xdrType = (*FloodDemand)(nil) +var _ xdrType = (*TimeSlicedNodeData)(nil) -// StellarMessage is an XDR Union defines as: +// TimeSlicedPeerData is an XDR Struct defines as: // -// union StellarMessage switch (MessageType type) +// struct TimeSlicedPeerData // { -// case ERROR_MSG: -// Error error; -// case HELLO: -// Hello hello; -// case AUTH: -// Auth auth; -// case DONT_HAVE: -// DontHave dontHave; -// case GET_PEERS: -// void; -// case PEERS: -// PeerAddress peers<100>; -// -// case GET_TX_SET: -// uint256 txSetHash; -// case TX_SET: -// TransactionSet txSet; -// case GENERALIZED_TX_SET: -// GeneralizedTransactionSet generalizedTxSet; -// -// case TRANSACTION: -// TransactionEnvelope transaction; -// -// case SURVEY_REQUEST: -// SignedSurveyRequestMessage signedSurveyRequestMessage; -// -// case SURVEY_RESPONSE: -// SignedSurveyResponseMessage signedSurveyResponseMessage; -// -// case TIME_SLICED_SURVEY_REQUEST: -// SignedTimeSlicedSurveyRequestMessage signedTimeSlicedSurveyRequestMessage; -// -// case TIME_SLICED_SURVEY_RESPONSE: -// SignedTimeSlicedSurveyResponseMessage signedTimeSlicedSurveyResponseMessage; -// -// case TIME_SLICED_SURVEY_START_COLLECTING: -// SignedTimeSlicedSurveyStartCollectingMessage -// signedTimeSlicedSurveyStartCollectingMessage; -// -// case TIME_SLICED_SURVEY_STOP_COLLECTING: -// SignedTimeSlicedSurveyStopCollectingMessage -// signedTimeSlicedSurveyStopCollectingMessage; -// -// // SCP -// case GET_SCP_QUORUMSET: -// uint256 qSetHash; -// case SCP_QUORUMSET: -// SCPQuorumSet qSet; -// case SCP_MESSAGE: -// SCPEnvelope envelope; -// case GET_SCP_STATE: -// uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest -// case SEND_MORE: -// SendMore sendMoreMessage; -// case SEND_MORE_EXTENDED: -// SendMoreExtended sendMoreExtendedMessage; -// // Pull mode -// case FLOOD_ADVERT: -// FloodAdvert floodAdvert; -// case FLOOD_DEMAND: -// FloodDemand floodDemand; +// PeerStats peerStats; +// uint32 averageLatencyMs; // }; -type StellarMessage struct { - Type MessageType - Error *Error - Hello *Hello - Auth *Auth - DontHave *DontHave - Peers *[]PeerAddress `xdrmaxsize:"100"` - TxSetHash *Uint256 - TxSet *TransactionSet - GeneralizedTxSet *GeneralizedTransactionSet - Transaction *TransactionEnvelope - SignedSurveyRequestMessage *SignedSurveyRequestMessage - SignedSurveyResponseMessage *SignedSurveyResponseMessage - SignedTimeSlicedSurveyRequestMessage *SignedTimeSlicedSurveyRequestMessage - SignedTimeSlicedSurveyResponseMessage *SignedTimeSlicedSurveyResponseMessage - SignedTimeSlicedSurveyStartCollectingMessage *SignedTimeSlicedSurveyStartCollectingMessage - SignedTimeSlicedSurveyStopCollectingMessage *SignedTimeSlicedSurveyStopCollectingMessage - QSetHash *Uint256 - QSet *ScpQuorumSet - Envelope *ScpEnvelope - GetScpLedgerSeq *Uint32 - SendMoreMessage *SendMore - SendMoreExtendedMessage *SendMoreExtended - FloodAdvert *FloodAdvert - FloodDemand *FloodDemand -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u StellarMessage) SwitchFieldName() string { - return "Type" +type TimeSlicedPeerData struct { + PeerStats PeerStats + AverageLatencyMs Uint32 } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of StellarMessage -func (u StellarMessage) ArmForSwitch(sw int32) (string, bool) { - switch MessageType(sw) { - case MessageTypeErrorMsg: - return "Error", true - case MessageTypeHello: - return "Hello", true - case MessageTypeAuth: - return "Auth", true - case MessageTypeDontHave: - return "DontHave", true - case MessageTypeGetPeers: - return "", true - case MessageTypePeers: - return "Peers", true - case MessageTypeGetTxSet: - return "TxSetHash", true - case MessageTypeTxSet: - return "TxSet", true - case MessageTypeGeneralizedTxSet: - return "GeneralizedTxSet", true - case MessageTypeTransaction: - return "Transaction", true - case MessageTypeSurveyRequest: - return "SignedSurveyRequestMessage", true - case MessageTypeSurveyResponse: - return "SignedSurveyResponseMessage", true - case MessageTypeTimeSlicedSurveyRequest: - return "SignedTimeSlicedSurveyRequestMessage", true - case MessageTypeTimeSlicedSurveyResponse: - return "SignedTimeSlicedSurveyResponseMessage", true - case MessageTypeTimeSlicedSurveyStartCollecting: - return "SignedTimeSlicedSurveyStartCollectingMessage", true - case MessageTypeTimeSlicedSurveyStopCollecting: - return "SignedTimeSlicedSurveyStopCollectingMessage", true - case MessageTypeGetScpQuorumset: - return "QSetHash", true - case MessageTypeScpQuorumset: - return "QSet", true - case MessageTypeScpMessage: - return "Envelope", true - case MessageTypeGetScpState: - return "GetScpLedgerSeq", true - case MessageTypeSendMore: - return "SendMoreMessage", true - case MessageTypeSendMoreExtended: - return "SendMoreExtendedMessage", true - case MessageTypeFloodAdvert: - return "FloodAdvert", true - case MessageTypeFloodDemand: - return "FloodDemand", true +// EncodeTo encodes this value using the Encoder. +func (s *TimeSlicedPeerData) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.PeerStats.EncodeTo(e); err != nil { + return err } - return "-", false -} - -// NewStellarMessage creates a new StellarMessage. -func NewStellarMessage(aType MessageType, value interface{}) (result StellarMessage, err error) { - result.Type = aType - switch MessageType(aType) { - case MessageTypeErrorMsg: - tv, ok := value.(Error) - if !ok { - err = errors.New("invalid value, must be Error") - return - } - result.Error = &tv - case MessageTypeHello: - tv, ok := value.(Hello) - if !ok { - err = errors.New("invalid value, must be Hello") - return - } - result.Hello = &tv - case MessageTypeAuth: - tv, ok := value.(Auth) - if !ok { - err = errors.New("invalid value, must be Auth") - return - } - result.Auth = &tv - case MessageTypeDontHave: - tv, ok := value.(DontHave) - if !ok { - err = errors.New("invalid value, must be DontHave") - return - } - result.DontHave = &tv - case MessageTypeGetPeers: - // void - case MessageTypePeers: - tv, ok := value.([]PeerAddress) - if !ok { - err = errors.New("invalid value, must be []PeerAddress") - return - } - result.Peers = &tv - case MessageTypeGetTxSet: - tv, ok := value.(Uint256) - if !ok { - err = errors.New("invalid value, must be Uint256") - return - } - result.TxSetHash = &tv - case MessageTypeTxSet: - tv, ok := value.(TransactionSet) - if !ok { - err = errors.New("invalid value, must be TransactionSet") - return - } - result.TxSet = &tv - case MessageTypeGeneralizedTxSet: - tv, ok := value.(GeneralizedTransactionSet) - if !ok { - err = errors.New("invalid value, must be GeneralizedTransactionSet") - return - } - result.GeneralizedTxSet = &tv - case MessageTypeTransaction: - tv, ok := value.(TransactionEnvelope) - if !ok { - err = errors.New("invalid value, must be TransactionEnvelope") - return - } - result.Transaction = &tv - case MessageTypeSurveyRequest: - tv, ok := value.(SignedSurveyRequestMessage) - if !ok { - err = errors.New("invalid value, must be SignedSurveyRequestMessage") - return - } - result.SignedSurveyRequestMessage = &tv - case MessageTypeSurveyResponse: - tv, ok := value.(SignedSurveyResponseMessage) - if !ok { - err = errors.New("invalid value, must be SignedSurveyResponseMessage") - return - } - result.SignedSurveyResponseMessage = &tv - case MessageTypeTimeSlicedSurveyRequest: - tv, ok := value.(SignedTimeSlicedSurveyRequestMessage) - if !ok { - err = errors.New("invalid value, must be SignedTimeSlicedSurveyRequestMessage") - return - } - result.SignedTimeSlicedSurveyRequestMessage = &tv - case MessageTypeTimeSlicedSurveyResponse: - tv, ok := value.(SignedTimeSlicedSurveyResponseMessage) - if !ok { - err = errors.New("invalid value, must be SignedTimeSlicedSurveyResponseMessage") - return - } - result.SignedTimeSlicedSurveyResponseMessage = &tv - case MessageTypeTimeSlicedSurveyStartCollecting: - tv, ok := value.(SignedTimeSlicedSurveyStartCollectingMessage) - if !ok { - err = errors.New("invalid value, must be SignedTimeSlicedSurveyStartCollectingMessage") - return - } - result.SignedTimeSlicedSurveyStartCollectingMessage = &tv - case MessageTypeTimeSlicedSurveyStopCollecting: - tv, ok := value.(SignedTimeSlicedSurveyStopCollectingMessage) - if !ok { - err = errors.New("invalid value, must be SignedTimeSlicedSurveyStopCollectingMessage") - return - } - result.SignedTimeSlicedSurveyStopCollectingMessage = &tv - case MessageTypeGetScpQuorumset: - tv, ok := value.(Uint256) - if !ok { - err = errors.New("invalid value, must be Uint256") - return - } - result.QSetHash = &tv - case MessageTypeScpQuorumset: - tv, ok := value.(ScpQuorumSet) - if !ok { - err = errors.New("invalid value, must be ScpQuorumSet") - return - } - result.QSet = &tv - case MessageTypeScpMessage: - tv, ok := value.(ScpEnvelope) - if !ok { - err = errors.New("invalid value, must be ScpEnvelope") - return - } - result.Envelope = &tv - case MessageTypeGetScpState: - tv, ok := value.(Uint32) - if !ok { - err = errors.New("invalid value, must be Uint32") - return - } - result.GetScpLedgerSeq = &tv - case MessageTypeSendMore: - tv, ok := value.(SendMore) - if !ok { - err = errors.New("invalid value, must be SendMore") - return - } - result.SendMoreMessage = &tv - case MessageTypeSendMoreExtended: - tv, ok := value.(SendMoreExtended) - if !ok { - err = errors.New("invalid value, must be SendMoreExtended") - return - } - result.SendMoreExtendedMessage = &tv - case MessageTypeFloodAdvert: - tv, ok := value.(FloodAdvert) - if !ok { - err = errors.New("invalid value, must be FloodAdvert") - return - } - result.FloodAdvert = &tv - case MessageTypeFloodDemand: - tv, ok := value.(FloodDemand) - if !ok { - err = errors.New("invalid value, must be FloodDemand") - return - } - result.FloodDemand = &tv + if err = s.AverageLatencyMs.EncodeTo(e); err != nil { + return err } - return + return nil } -// MustError retrieves the Error value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustError() Error { - val, ok := u.GetError() +var _ decoderFrom = (*TimeSlicedPeerData)(nil) - if !ok { - panic("arm Error is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *TimeSlicedPeerData) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TimeSlicedPeerData: %w", ErrMaxDecodingDepthReached) } - - return val -} - -// GetError retrieves the Error value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetError() (result Error, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Error" { - result = *u.Error - ok = true + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.PeerStats.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PeerStats: %w", err) } - - return + nTmp, err = s.AverageLatencyMs.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil } -// MustHello retrieves the Hello value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustHello() Hello { - val, ok := u.GetHello() - - if !ok { - panic("arm Hello is not set") - } - - return val +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TimeSlicedPeerData) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err } -// GetHello retrieves the Hello value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetHello() (result Hello, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Hello" { - result = *u.Hello - ok = true - } - - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TimeSlicedPeerData) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustAuth retrieves the Auth value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustAuth() Auth { - val, ok := u.GetAuth() - - if !ok { - panic("arm Auth is not set") - } +var ( + _ encoding.BinaryMarshaler = (*TimeSlicedPeerData)(nil) + _ encoding.BinaryUnmarshaler = (*TimeSlicedPeerData)(nil) +) - return val -} +// xdrType signals that this type represents XDR values defined by this package. +func (s TimeSlicedPeerData) xdrType() {} -// GetAuth retrieves the Auth value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetAuth() (result Auth, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +var _ xdrType = (*TimeSlicedPeerData)(nil) - if armName == "Auth" { - result = *u.Auth - ok = true - } +// TimeSlicedPeerDataList is an XDR Typedef defines as: +// +// typedef TimeSlicedPeerData TimeSlicedPeerDataList<25>; +type TimeSlicedPeerDataList []TimeSlicedPeerData - return +// XDRMaxSize implements the Sized interface for TimeSlicedPeerDataList +func (e TimeSlicedPeerDataList) XDRMaxSize() int { + return 25 } -// MustDontHave retrieves the DontHave value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustDontHave() DontHave { - val, ok := u.GetDontHave() - - if !ok { - panic("arm DontHave is not set") +// EncodeTo encodes this value using the Encoder. +func (s TimeSlicedPeerDataList) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeUint(uint32(len(s))); err != nil { + return err } - - return val -} - -// GetDontHave retrieves the DontHave value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetDontHave() (result DontHave, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "DontHave" { - result = *u.DontHave - ok = true + for i := 0; i < len(s); i++ { + if err = s[i].EncodeTo(e); err != nil { + return err + } } - - return + return nil } -// MustPeers retrieves the Peers value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustPeers() []PeerAddress { - val, ok := u.GetPeers() +var _ decoderFrom = (*TimeSlicedPeerDataList)(nil) - if !ok { - panic("arm Peers is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *TimeSlicedPeerDataList) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TimeSlicedPeerDataList: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TimeSlicedPeerData: %w", err) + } + if l > 25 { + return n, fmt.Errorf("decoding TimeSlicedPeerData: data size (%d) exceeds size limit (25)", l) + } + (*s) = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding TimeSlicedPeerData: length (%d) exceeds remaining input length (%d)", l, il) + } + (*s) = make([]TimeSlicedPeerData, l) + for i := uint32(0); i < l; i++ { + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TimeSlicedPeerData: %w", err) + } + } + } + return n, nil } -// GetPeers retrieves the Peers value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetPeers() (result []PeerAddress, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Peers" { - result = *u.Peers - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TimeSlicedPeerDataList) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TimeSlicedPeerDataList) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustTxSetHash retrieves the TxSetHash value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustTxSetHash() Uint256 { - val, ok := u.GetTxSetHash() +var ( + _ encoding.BinaryMarshaler = (*TimeSlicedPeerDataList)(nil) + _ encoding.BinaryUnmarshaler = (*TimeSlicedPeerDataList)(nil) +) - if !ok { - panic("arm TxSetHash is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s TimeSlicedPeerDataList) xdrType() {} - return val -} +var _ xdrType = (*TimeSlicedPeerDataList)(nil) -// GetTxSetHash retrieves the TxSetHash value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetTxSetHash() (result Uint256, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// TopologyResponseBodyV0 is an XDR Struct defines as: +// +// struct TopologyResponseBodyV0 +// { +// PeerStatList inboundPeers; +// PeerStatList outboundPeers; +// +// uint32 totalInboundPeerCount; +// uint32 totalOutboundPeerCount; +// }; +type TopologyResponseBodyV0 struct { + InboundPeers PeerStatList + OutboundPeers PeerStatList + TotalInboundPeerCount Uint32 + TotalOutboundPeerCount Uint32 +} - if armName == "TxSetHash" { - result = *u.TxSetHash - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *TopologyResponseBodyV0) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.InboundPeers.EncodeTo(e); err != nil { + return err } - - return + if err = s.OutboundPeers.EncodeTo(e); err != nil { + return err + } + if err = s.TotalInboundPeerCount.EncodeTo(e); err != nil { + return err + } + if err = s.TotalOutboundPeerCount.EncodeTo(e); err != nil { + return err + } + return nil } -// MustTxSet retrieves the TxSet value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustTxSet() TransactionSet { - val, ok := u.GetTxSet() +var _ decoderFrom = (*TopologyResponseBodyV0)(nil) - if !ok { - panic("arm TxSet is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *TopologyResponseBodyV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TopologyResponseBodyV0: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PeerStatList: %w", err) + } + nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PeerStatList: %w", err) + } + nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil } -// GetTxSet retrieves the TxSet value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetTxSet() (result TransactionSet, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "TxSet" { - result = *u.TxSet - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TopologyResponseBodyV0) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TopologyResponseBodyV0) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustGeneralizedTxSet() GeneralizedTransactionSet { - val, ok := u.GetGeneralizedTxSet() +var ( + _ encoding.BinaryMarshaler = (*TopologyResponseBodyV0)(nil) + _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV0)(nil) +) - if !ok { - panic("arm GeneralizedTxSet is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s TopologyResponseBodyV0) xdrType() {} - return val -} +var _ xdrType = (*TopologyResponseBodyV0)(nil) -// GetGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetGeneralizedTxSet() (result GeneralizedTransactionSet, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// TopologyResponseBodyV1 is an XDR Struct defines as: +// +// struct TopologyResponseBodyV1 +// { +// PeerStatList inboundPeers; +// PeerStatList outboundPeers; +// +// uint32 totalInboundPeerCount; +// uint32 totalOutboundPeerCount; +// +// uint32 maxInboundPeerCount; +// uint32 maxOutboundPeerCount; +// }; +type TopologyResponseBodyV1 struct { + InboundPeers PeerStatList + OutboundPeers PeerStatList + TotalInboundPeerCount Uint32 + TotalOutboundPeerCount Uint32 + MaxInboundPeerCount Uint32 + MaxOutboundPeerCount Uint32 +} - if armName == "GeneralizedTxSet" { - result = *u.GeneralizedTxSet - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *TopologyResponseBodyV1) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.InboundPeers.EncodeTo(e); err != nil { + return err } - - return + if err = s.OutboundPeers.EncodeTo(e); err != nil { + return err + } + if err = s.TotalInboundPeerCount.EncodeTo(e); err != nil { + return err + } + if err = s.TotalOutboundPeerCount.EncodeTo(e); err != nil { + return err + } + if err = s.MaxInboundPeerCount.EncodeTo(e); err != nil { + return err + } + if err = s.MaxOutboundPeerCount.EncodeTo(e); err != nil { + return err + } + return nil } -// MustTransaction retrieves the Transaction value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustTransaction() TransactionEnvelope { - val, ok := u.GetTransaction() +var _ decoderFrom = (*TopologyResponseBodyV1)(nil) - if !ok { - panic("arm Transaction is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *TopologyResponseBodyV1) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TopologyResponseBodyV1: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PeerStatList: %w", err) + } + nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PeerStatList: %w", err) + } + nTmp, err = s.TotalInboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.TotalOutboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.MaxInboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.MaxOutboundPeerCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil } -// GetTransaction retrieves the Transaction value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetTransaction() (result TransactionEnvelope, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Transaction" { - result = *u.Transaction - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TopologyResponseBodyV1) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TopologyResponseBodyV1) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustSignedSurveyRequestMessage retrieves the SignedSurveyRequestMessage value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustSignedSurveyRequestMessage() SignedSurveyRequestMessage { - val, ok := u.GetSignedSurveyRequestMessage() +var ( + _ encoding.BinaryMarshaler = (*TopologyResponseBodyV1)(nil) + _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV1)(nil) +) - if !ok { - panic("arm SignedSurveyRequestMessage is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s TopologyResponseBodyV1) xdrType() {} - return val -} +var _ xdrType = (*TopologyResponseBodyV1)(nil) -// GetSignedSurveyRequestMessage retrieves the SignedSurveyRequestMessage value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSignedSurveyRequestMessage() (result SignedSurveyRequestMessage, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// TopologyResponseBodyV2 is an XDR Struct defines as: +// +// struct TopologyResponseBodyV2 +// { +// TimeSlicedPeerDataList inboundPeers; +// TimeSlicedPeerDataList outboundPeers; +// TimeSlicedNodeData nodeData; +// }; +type TopologyResponseBodyV2 struct { + InboundPeers TimeSlicedPeerDataList + OutboundPeers TimeSlicedPeerDataList + NodeData TimeSlicedNodeData +} - if armName == "SignedSurveyRequestMessage" { - result = *u.SignedSurveyRequestMessage - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *TopologyResponseBodyV2) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.InboundPeers.EncodeTo(e); err != nil { + return err } - - return + if err = s.OutboundPeers.EncodeTo(e); err != nil { + return err + } + if err = s.NodeData.EncodeTo(e); err != nil { + return err + } + return nil } -// MustSignedSurveyResponseMessage retrieves the SignedSurveyResponseMessage value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustSignedSurveyResponseMessage() SignedSurveyResponseMessage { - val, ok := u.GetSignedSurveyResponseMessage() +var _ decoderFrom = (*TopologyResponseBodyV2)(nil) - if !ok { - panic("arm SignedSurveyResponseMessage is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *TopologyResponseBodyV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TopologyResponseBodyV2: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.InboundPeers.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TimeSlicedPeerDataList: %w", err) + } + nTmp, err = s.OutboundPeers.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TimeSlicedPeerDataList: %w", err) + } + nTmp, err = s.NodeData.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TimeSlicedNodeData: %w", err) } + return n, nil +} - return val +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TopologyResponseBodyV2) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err } -// GetSignedSurveyResponseMessage retrieves the SignedSurveyResponseMessage value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSignedSurveyResponseMessage() (result SignedSurveyResponseMessage, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "SignedSurveyResponseMessage" { - result = *u.SignedSurveyResponseMessage - ok = true - } - - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TopologyResponseBodyV2) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustSignedTimeSlicedSurveyRequestMessage retrieves the SignedTimeSlicedSurveyRequestMessage value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustSignedTimeSlicedSurveyRequestMessage() SignedTimeSlicedSurveyRequestMessage { - val, ok := u.GetSignedTimeSlicedSurveyRequestMessage() - - if !ok { - panic("arm SignedTimeSlicedSurveyRequestMessage is not set") - } - - return val -} +var ( + _ encoding.BinaryMarshaler = (*TopologyResponseBodyV2)(nil) + _ encoding.BinaryUnmarshaler = (*TopologyResponseBodyV2)(nil) +) -// GetSignedTimeSlicedSurveyRequestMessage retrieves the SignedTimeSlicedSurveyRequestMessage value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSignedTimeSlicedSurveyRequestMessage() (result SignedTimeSlicedSurveyRequestMessage, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// xdrType signals that this type represents XDR values defined by this package. +func (s TopologyResponseBodyV2) xdrType() {} - if armName == "SignedTimeSlicedSurveyRequestMessage" { - result = *u.SignedTimeSlicedSurveyRequestMessage - ok = true - } +var _ xdrType = (*TopologyResponseBodyV2)(nil) - return +// SurveyResponseBody is an XDR Union defines as: +// +// union SurveyResponseBody switch (SurveyMessageResponseType type) +// { +// case SURVEY_TOPOLOGY_RESPONSE_V0: +// TopologyResponseBodyV0 topologyResponseBodyV0; +// case SURVEY_TOPOLOGY_RESPONSE_V1: +// TopologyResponseBodyV1 topologyResponseBodyV1; +// case SURVEY_TOPOLOGY_RESPONSE_V2: +// TopologyResponseBodyV2 topologyResponseBodyV2; +// }; +type SurveyResponseBody struct { + Type SurveyMessageResponseType + TopologyResponseBodyV0 *TopologyResponseBodyV0 + TopologyResponseBodyV1 *TopologyResponseBodyV1 + TopologyResponseBodyV2 *TopologyResponseBodyV2 } -// MustSignedTimeSlicedSurveyResponseMessage retrieves the SignedTimeSlicedSurveyResponseMessage value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustSignedTimeSlicedSurveyResponseMessage() SignedTimeSlicedSurveyResponseMessage { - val, ok := u.GetSignedTimeSlicedSurveyResponseMessage() +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u SurveyResponseBody) SwitchFieldName() string { + return "Type" +} - if !ok { - panic("arm SignedTimeSlicedSurveyResponseMessage is not set") +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of SurveyResponseBody +func (u SurveyResponseBody) ArmForSwitch(sw int32) (string, bool) { + switch SurveyMessageResponseType(sw) { + case SurveyMessageResponseTypeSurveyTopologyResponseV0: + return "TopologyResponseBodyV0", true + case SurveyMessageResponseTypeSurveyTopologyResponseV1: + return "TopologyResponseBodyV1", true + case SurveyMessageResponseTypeSurveyTopologyResponseV2: + return "TopologyResponseBodyV2", true } - - return val + return "-", false } -// GetSignedTimeSlicedSurveyResponseMessage retrieves the SignedTimeSlicedSurveyResponseMessage value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSignedTimeSlicedSurveyResponseMessage() (result SignedTimeSlicedSurveyResponseMessage, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "SignedTimeSlicedSurveyResponseMessage" { - result = *u.SignedTimeSlicedSurveyResponseMessage - ok = true +// NewSurveyResponseBody creates a new SurveyResponseBody. +func NewSurveyResponseBody(aType SurveyMessageResponseType, value interface{}) (result SurveyResponseBody, err error) { + result.Type = aType + switch SurveyMessageResponseType(aType) { + case SurveyMessageResponseTypeSurveyTopologyResponseV0: + tv, ok := value.(TopologyResponseBodyV0) + if !ok { + err = errors.New("invalid value, must be TopologyResponseBodyV0") + return + } + result.TopologyResponseBodyV0 = &tv + case SurveyMessageResponseTypeSurveyTopologyResponseV1: + tv, ok := value.(TopologyResponseBodyV1) + if !ok { + err = errors.New("invalid value, must be TopologyResponseBodyV1") + return + } + result.TopologyResponseBodyV1 = &tv + case SurveyMessageResponseTypeSurveyTopologyResponseV2: + tv, ok := value.(TopologyResponseBodyV2) + if !ok { + err = errors.New("invalid value, must be TopologyResponseBodyV2") + return + } + result.TopologyResponseBodyV2 = &tv } - return } -// MustSignedTimeSlicedSurveyStartCollectingMessage retrieves the SignedTimeSlicedSurveyStartCollectingMessage value from the union, +// MustTopologyResponseBodyV0 retrieves the TopologyResponseBodyV0 value from the union, // panicing if the value is not set. -func (u StellarMessage) MustSignedTimeSlicedSurveyStartCollectingMessage() SignedTimeSlicedSurveyStartCollectingMessage { - val, ok := u.GetSignedTimeSlicedSurveyStartCollectingMessage() +func (u SurveyResponseBody) MustTopologyResponseBodyV0() TopologyResponseBodyV0 { + val, ok := u.GetTopologyResponseBodyV0() if !ok { - panic("arm SignedTimeSlicedSurveyStartCollectingMessage is not set") + panic("arm TopologyResponseBodyV0 is not set") } return val } -// GetSignedTimeSlicedSurveyStartCollectingMessage retrieves the SignedTimeSlicedSurveyStartCollectingMessage value from the union, +// GetTopologyResponseBodyV0 retrieves the TopologyResponseBodyV0 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSignedTimeSlicedSurveyStartCollectingMessage() (result SignedTimeSlicedSurveyStartCollectingMessage, ok bool) { +func (u SurveyResponseBody) GetTopologyResponseBodyV0() (result TopologyResponseBodyV0, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "SignedTimeSlicedSurveyStartCollectingMessage" { - result = *u.SignedTimeSlicedSurveyStartCollectingMessage + if armName == "TopologyResponseBodyV0" { + result = *u.TopologyResponseBodyV0 ok = true } return } -// MustSignedTimeSlicedSurveyStopCollectingMessage retrieves the SignedTimeSlicedSurveyStopCollectingMessage value from the union, +// MustTopologyResponseBodyV1 retrieves the TopologyResponseBodyV1 value from the union, // panicing if the value is not set. -func (u StellarMessage) MustSignedTimeSlicedSurveyStopCollectingMessage() SignedTimeSlicedSurveyStopCollectingMessage { - val, ok := u.GetSignedTimeSlicedSurveyStopCollectingMessage() +func (u SurveyResponseBody) MustTopologyResponseBodyV1() TopologyResponseBodyV1 { + val, ok := u.GetTopologyResponseBodyV1() if !ok { - panic("arm SignedTimeSlicedSurveyStopCollectingMessage is not set") + panic("arm TopologyResponseBodyV1 is not set") } return val } -// GetSignedTimeSlicedSurveyStopCollectingMessage retrieves the SignedTimeSlicedSurveyStopCollectingMessage value from the union, +// GetTopologyResponseBodyV1 retrieves the TopologyResponseBodyV1 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSignedTimeSlicedSurveyStopCollectingMessage() (result SignedTimeSlicedSurveyStopCollectingMessage, ok bool) { +func (u SurveyResponseBody) GetTopologyResponseBodyV1() (result TopologyResponseBodyV1, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "SignedTimeSlicedSurveyStopCollectingMessage" { - result = *u.SignedTimeSlicedSurveyStopCollectingMessage + if armName == "TopologyResponseBodyV1" { + result = *u.TopologyResponseBodyV1 ok = true } return } -// MustQSetHash retrieves the QSetHash value from the union, +// MustTopologyResponseBodyV2 retrieves the TopologyResponseBodyV2 value from the union, // panicing if the value is not set. -func (u StellarMessage) MustQSetHash() Uint256 { - val, ok := u.GetQSetHash() +func (u SurveyResponseBody) MustTopologyResponseBodyV2() TopologyResponseBodyV2 { + val, ok := u.GetTopologyResponseBodyV2() if !ok { - panic("arm QSetHash is not set") + panic("arm TopologyResponseBodyV2 is not set") } return val } -// GetQSetHash retrieves the QSetHash value from the union, +// GetTopologyResponseBodyV2 retrieves the TopologyResponseBodyV2 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetQSetHash() (result Uint256, ok bool) { +func (u SurveyResponseBody) GetTopologyResponseBodyV2() (result TopologyResponseBodyV2, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "QSetHash" { - result = *u.QSetHash + if armName == "TopologyResponseBodyV2" { + result = *u.TopologyResponseBodyV2 ok = true } return } -// MustQSet retrieves the QSet value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustQSet() ScpQuorumSet { - val, ok := u.GetQSet() - - if !ok { - panic("arm QSet is not set") +// EncodeTo encodes this value using the Encoder. +func (u SurveyResponseBody) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err } - - return val + switch SurveyMessageResponseType(u.Type) { + case SurveyMessageResponseTypeSurveyTopologyResponseV0: + if err = (*u.TopologyResponseBodyV0).EncodeTo(e); err != nil { + return err + } + return nil + case SurveyMessageResponseTypeSurveyTopologyResponseV1: + if err = (*u.TopologyResponseBodyV1).EncodeTo(e); err != nil { + return err + } + return nil + case SurveyMessageResponseTypeSurveyTopologyResponseV2: + if err = (*u.TopologyResponseBodyV2).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (SurveyMessageResponseType) switch value '%d' is not valid for union SurveyResponseBody", u.Type) } -// GetQSet retrieves the QSet value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetQSet() (result ScpQuorumSet, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +var _ decoderFrom = (*SurveyResponseBody)(nil) - if armName == "QSet" { - result = *u.QSet - ok = true +// DecodeFrom decodes this value using the Decoder. +func (u *SurveyResponseBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SurveyResponseBody: %w", ErrMaxDecodingDepthReached) } - - return + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SurveyMessageResponseType: %w", err) + } + switch SurveyMessageResponseType(u.Type) { + case SurveyMessageResponseTypeSurveyTopologyResponseV0: + u.TopologyResponseBodyV0 = new(TopologyResponseBodyV0) + nTmp, err = (*u.TopologyResponseBodyV0).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TopologyResponseBodyV0: %w", err) + } + return n, nil + case SurveyMessageResponseTypeSurveyTopologyResponseV1: + u.TopologyResponseBodyV1 = new(TopologyResponseBodyV1) + nTmp, err = (*u.TopologyResponseBodyV1).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TopologyResponseBodyV1: %w", err) + } + return n, nil + case SurveyMessageResponseTypeSurveyTopologyResponseV2: + u.TopologyResponseBodyV2 = new(TopologyResponseBodyV2) + nTmp, err = (*u.TopologyResponseBodyV2).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TopologyResponseBodyV2: %w", err) + } + return n, nil + } + return n, fmt.Errorf("union SurveyResponseBody has invalid Type (SurveyMessageResponseType) switch value '%d'", u.Type) } -// MustEnvelope retrieves the Envelope value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustEnvelope() ScpEnvelope { - val, ok := u.GetEnvelope() - - if !ok { - panic("arm Envelope is not set") - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s SurveyResponseBody) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return val +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SurveyResponseBody) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// GetEnvelope retrieves the Envelope value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetEnvelope() (result ScpEnvelope, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +var ( + _ encoding.BinaryMarshaler = (*SurveyResponseBody)(nil) + _ encoding.BinaryUnmarshaler = (*SurveyResponseBody)(nil) +) - if armName == "Envelope" { - result = *u.Envelope - ok = true - } +// xdrType signals that this type represents XDR values defined by this package. +func (s SurveyResponseBody) xdrType() {} - return -} +var _ xdrType = (*SurveyResponseBody)(nil) -// MustGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustGetScpLedgerSeq() Uint32 { - val, ok := u.GetGetScpLedgerSeq() +// TxAdvertVectorMaxSize is an XDR Const defines as: +// +// const TX_ADVERT_VECTOR_MAX_SIZE = 1000; +const TxAdvertVectorMaxSize = 1000 - if !ok { - panic("arm GetScpLedgerSeq is not set") - } +// TxAdvertVector is an XDR Typedef defines as: +// +// typedef Hash TxAdvertVector; +type TxAdvertVector []Hash - return val +// XDRMaxSize implements the Sized interface for TxAdvertVector +func (e TxAdvertVector) XDRMaxSize() int { + return 1000 } -// GetGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetGetScpLedgerSeq() (result Uint32, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "GetScpLedgerSeq" { - result = *u.GetScpLedgerSeq - ok = true +// EncodeTo encodes this value using the Encoder. +func (s TxAdvertVector) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeUint(uint32(len(s))); err != nil { + return err } - - return + for i := 0; i < len(s); i++ { + if err = s[i].EncodeTo(e); err != nil { + return err + } + } + return nil } -// MustSendMoreMessage retrieves the SendMoreMessage value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustSendMoreMessage() SendMore { - val, ok := u.GetSendMoreMessage() +var _ decoderFrom = (*TxAdvertVector)(nil) - if !ok { - panic("arm SendMoreMessage is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *TxAdvertVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding TxAdvertVector: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + if l > 1000 { + return n, fmt.Errorf("decoding Hash: data size (%d) exceeds size limit (1000)", l) + } + (*s) = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) + } + (*s) = make([]Hash, l) + for i := uint32(0); i < l; i++ { + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + } + } + return n, nil } -// GetSendMoreMessage retrieves the SendMoreMessage value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSendMoreMessage() (result SendMore, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "SendMoreMessage" { - result = *u.SendMoreMessage - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s TxAdvertVector) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *TxAdvertVector) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustSendMoreExtendedMessage retrieves the SendMoreExtendedMessage value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustSendMoreExtendedMessage() SendMoreExtended { - val, ok := u.GetSendMoreExtendedMessage() +var ( + _ encoding.BinaryMarshaler = (*TxAdvertVector)(nil) + _ encoding.BinaryUnmarshaler = (*TxAdvertVector)(nil) +) - if !ok { - panic("arm SendMoreExtendedMessage is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s TxAdvertVector) xdrType() {} - return val -} +var _ xdrType = (*TxAdvertVector)(nil) -// GetSendMoreExtendedMessage retrieves the SendMoreExtendedMessage value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetSendMoreExtendedMessage() (result SendMoreExtended, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// FloodAdvert is an XDR Struct defines as: +// +// struct FloodAdvert +// { +// TxAdvertVector txHashes; +// }; +type FloodAdvert struct { + TxHashes TxAdvertVector +} - if armName == "SendMoreExtendedMessage" { - result = *u.SendMoreExtendedMessage - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *FloodAdvert) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.TxHashes.EncodeTo(e); err != nil { + return err } - - return + return nil } -// MustFloodAdvert retrieves the FloodAdvert value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustFloodAdvert() FloodAdvert { - val, ok := u.GetFloodAdvert() +var _ decoderFrom = (*FloodAdvert)(nil) - if !ok { - panic("arm FloodAdvert is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *FloodAdvert) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding FloodAdvert: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.TxHashes.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TxAdvertVector: %w", err) + } + return n, nil } -// GetFloodAdvert retrieves the FloodAdvert value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetFloodAdvert() (result FloodAdvert, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "FloodAdvert" { - result = *u.FloodAdvert - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s FloodAdvert) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *FloodAdvert) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustFloodDemand retrieves the FloodDemand value from the union, -// panicing if the value is not set. -func (u StellarMessage) MustFloodDemand() FloodDemand { - val, ok := u.GetFloodDemand() +var ( + _ encoding.BinaryMarshaler = (*FloodAdvert)(nil) + _ encoding.BinaryUnmarshaler = (*FloodAdvert)(nil) +) - if !ok { - panic("arm FloodDemand is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s FloodAdvert) xdrType() {} - return val -} +var _ xdrType = (*FloodAdvert)(nil) -// GetFloodDemand retrieves the FloodDemand value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u StellarMessage) GetFloodDemand() (result FloodDemand, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// TxDemandVectorMaxSize is an XDR Const defines as: +// +// const TX_DEMAND_VECTOR_MAX_SIZE = 1000; +const TxDemandVectorMaxSize = 1000 - if armName == "FloodDemand" { - result = *u.FloodDemand - ok = true - } +// TxDemandVector is an XDR Typedef defines as: +// +// typedef Hash TxDemandVector; +type TxDemandVector []Hash - return +// XDRMaxSize implements the Sized interface for TxDemandVector +func (e TxDemandVector) XDRMaxSize() int { + return 1000 } // EncodeTo encodes this value using the Encoder. -func (u StellarMessage) EncodeTo(e *xdr.Encoder) error { +func (s TxDemandVector) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s))); err != nil { return err } - switch MessageType(u.Type) { - case MessageTypeErrorMsg: - if err = (*u.Error).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeHello: - if err = (*u.Hello).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeAuth: - if err = (*u.Auth).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeDontHave: - if err = (*u.DontHave).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeGetPeers: - // Void - return nil - case MessageTypePeers: - if _, err = e.EncodeUint(uint32(len((*u.Peers)))); err != nil { - return err - } - for i := 0; i < len((*u.Peers)); i++ { - if err = (*u.Peers)[i].EncodeTo(e); err != nil { - return err - } - } - return nil - case MessageTypeGetTxSet: - if err = (*u.TxSetHash).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeTxSet: - if err = (*u.TxSet).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeGeneralizedTxSet: - if err = (*u.GeneralizedTxSet).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeTransaction: - if err = (*u.Transaction).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeSurveyRequest: - if err = (*u.SignedSurveyRequestMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeSurveyResponse: - if err = (*u.SignedSurveyResponseMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeTimeSlicedSurveyRequest: - if err = (*u.SignedTimeSlicedSurveyRequestMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeTimeSlicedSurveyResponse: - if err = (*u.SignedTimeSlicedSurveyResponseMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeTimeSlicedSurveyStartCollecting: - if err = (*u.SignedTimeSlicedSurveyStartCollectingMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeTimeSlicedSurveyStopCollecting: - if err = (*u.SignedTimeSlicedSurveyStopCollectingMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeGetScpQuorumset: - if err = (*u.QSetHash).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeScpQuorumset: - if err = (*u.QSet).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeScpMessage: - if err = (*u.Envelope).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeGetScpState: - if err = (*u.GetScpLedgerSeq).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeSendMore: - if err = (*u.SendMoreMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeSendMoreExtended: - if err = (*u.SendMoreExtendedMessage).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeFloodAdvert: - if err = (*u.FloodAdvert).EncodeTo(e); err != nil { - return err - } - return nil - case MessageTypeFloodDemand: - if err = (*u.FloodDemand).EncodeTo(e); err != nil { + for i := 0; i < len(s); i++ { + if err = s[i].EncodeTo(e); err != nil { return err } - return nil } - return fmt.Errorf("Type (MessageType) switch value '%d' is not valid for union StellarMessage", u.Type) + return nil } -var _ decoderFrom = (*StellarMessage)(nil) +var _ decoderFrom = (*TxDemandVector)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *StellarMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TxDemandVector) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding StellarMessage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TxDemandVector: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding MessageType: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } - switch MessageType(u.Type) { - case MessageTypeErrorMsg: - u.Error = new(Error) - nTmp, err = (*u.Error).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Error: %w", err) - } - return n, nil - case MessageTypeHello: - u.Hello = new(Hello) - nTmp, err = (*u.Hello).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hello: %w", err) - } - return n, nil - case MessageTypeAuth: - u.Auth = new(Auth) - nTmp, err = (*u.Auth).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Auth: %w", err) - } - return n, nil - case MessageTypeDontHave: - u.DontHave = new(DontHave) - nTmp, err = (*u.DontHave).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding DontHave: %w", err) - } - return n, nil - case MessageTypeGetPeers: - // Void - return n, nil - case MessageTypePeers: - u.Peers = new([]PeerAddress) - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PeerAddress: %w", err) - } - if l > 100 { - return n, fmt.Errorf("decoding PeerAddress: data size (%d) exceeds size limit (100)", l) + if l > 1000 { + return n, fmt.Errorf("decoding Hash: data size (%d) exceeds size limit (1000)", l) + } + (*s) = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Hash: length (%d) exceeds remaining input length (%d)", l, il) } - (*u.Peers) = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding PeerAddress: length (%d) exceeds remaining input length (%d)", l, il) - } - (*u.Peers) = make([]PeerAddress, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Peers)[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PeerAddress: %w", err) - } + (*s) = make([]Hash, l) + for i := uint32(0); i < l; i++ { + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) } } - return n, nil - case MessageTypeGetTxSet: - u.TxSetHash = new(Uint256) - nTmp, err = (*u.TxSetHash).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %w", err) - } - return n, nil - case MessageTypeTxSet: - u.TxSet = new(TransactionSet) - nTmp, err = (*u.TxSet).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionSet: %w", err) - } - return n, nil - case MessageTypeGeneralizedTxSet: - u.GeneralizedTxSet = new(GeneralizedTransactionSet) - nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) - } - return n, nil - case MessageTypeTransaction: - u.Transaction = new(TransactionEnvelope) - nTmp, err = (*u.Transaction).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) - } - return n, nil - case MessageTypeSurveyRequest: - u.SignedSurveyRequestMessage = new(SignedSurveyRequestMessage) - nTmp, err = (*u.SignedSurveyRequestMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SignedSurveyRequestMessage: %w", err) - } - return n, nil - case MessageTypeSurveyResponse: - u.SignedSurveyResponseMessage = new(SignedSurveyResponseMessage) - nTmp, err = (*u.SignedSurveyResponseMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SignedSurveyResponseMessage: %w", err) - } - return n, nil - case MessageTypeTimeSlicedSurveyRequest: - u.SignedTimeSlicedSurveyRequestMessage = new(SignedTimeSlicedSurveyRequestMessage) - nTmp, err = (*u.SignedTimeSlicedSurveyRequestMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SignedTimeSlicedSurveyRequestMessage: %w", err) - } - return n, nil - case MessageTypeTimeSlicedSurveyResponse: - u.SignedTimeSlicedSurveyResponseMessage = new(SignedTimeSlicedSurveyResponseMessage) - nTmp, err = (*u.SignedTimeSlicedSurveyResponseMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SignedTimeSlicedSurveyResponseMessage: %w", err) - } - return n, nil - case MessageTypeTimeSlicedSurveyStartCollecting: - u.SignedTimeSlicedSurveyStartCollectingMessage = new(SignedTimeSlicedSurveyStartCollectingMessage) - nTmp, err = (*u.SignedTimeSlicedSurveyStartCollectingMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SignedTimeSlicedSurveyStartCollectingMessage: %w", err) - } - return n, nil - case MessageTypeTimeSlicedSurveyStopCollecting: - u.SignedTimeSlicedSurveyStopCollectingMessage = new(SignedTimeSlicedSurveyStopCollectingMessage) - nTmp, err = (*u.SignedTimeSlicedSurveyStopCollectingMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SignedTimeSlicedSurveyStopCollectingMessage: %w", err) - } - return n, nil - case MessageTypeGetScpQuorumset: - u.QSetHash = new(Uint256) - nTmp, err = (*u.QSetHash).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %w", err) - } - return n, nil - case MessageTypeScpQuorumset: - u.QSet = new(ScpQuorumSet) - nTmp, err = (*u.QSet).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) - } - return n, nil - case MessageTypeScpMessage: - u.Envelope = new(ScpEnvelope) - nTmp, err = (*u.Envelope).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpEnvelope: %w", err) - } - return n, nil - case MessageTypeGetScpState: - u.GetScpLedgerSeq = new(Uint32) - nTmp, err = (*u.GetScpLedgerSeq).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - return n, nil - case MessageTypeSendMore: - u.SendMoreMessage = new(SendMore) - nTmp, err = (*u.SendMoreMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SendMore: %w", err) - } - return n, nil - case MessageTypeSendMoreExtended: - u.SendMoreExtendedMessage = new(SendMoreExtended) - nTmp, err = (*u.SendMoreExtendedMessage).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SendMoreExtended: %w", err) - } - return n, nil - case MessageTypeFloodAdvert: - u.FloodAdvert = new(FloodAdvert) - nTmp, err = (*u.FloodAdvert).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding FloodAdvert: %w", err) - } - return n, nil - case MessageTypeFloodDemand: - u.FloodDemand = new(FloodDemand) - nTmp, err = (*u.FloodDemand).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding FloodDemand: %w", err) - } - return n, nil } - return n, fmt.Errorf("union StellarMessage has invalid Type (MessageType) switch value '%d'", u.Type) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s StellarMessage) MarshalBinary() ([]byte, error) { +func (s TxDemandVector) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -24010,7 +23907,7 @@ func (s StellarMessage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *StellarMessage) UnmarshalBinary(inp []byte) error { +func (s *TxDemandVector) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -24020,74 +23917,54 @@ func (s *StellarMessage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*StellarMessage)(nil) - _ encoding.BinaryUnmarshaler = (*StellarMessage)(nil) + _ encoding.BinaryMarshaler = (*TxDemandVector)(nil) + _ encoding.BinaryUnmarshaler = (*TxDemandVector)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s StellarMessage) xdrType() {} +func (s TxDemandVector) xdrType() {} -var _ xdrType = (*StellarMessage)(nil) +var _ xdrType = (*TxDemandVector)(nil) -// AuthenticatedMessageV0 is an XDR NestedStruct defines as: +// FloodDemand is an XDR Struct defines as: // -// struct -// { -// uint64 sequence; -// StellarMessage message; -// HmacSha256Mac mac; -// } -type AuthenticatedMessageV0 struct { - Sequence Uint64 - Message StellarMessage - Mac HmacSha256Mac +// struct FloodDemand +// { +// TxDemandVector txHashes; +// }; +type FloodDemand struct { + TxHashes TxDemandVector } // EncodeTo encodes this value using the Encoder. -func (s *AuthenticatedMessageV0) EncodeTo(e *xdr.Encoder) error { +func (s *FloodDemand) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Sequence.EncodeTo(e); err != nil { - return err - } - if err = s.Message.EncodeTo(e); err != nil { - return err - } - if err = s.Mac.EncodeTo(e); err != nil { + if err = s.TxHashes.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*AuthenticatedMessageV0)(nil) +var _ decoderFrom = (*FloodDemand)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AuthenticatedMessageV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *FloodDemand) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding AuthenticatedMessageV0: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding FloodDemand: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Sequence.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.Message.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding StellarMessage: %w", err) - } - nTmp, err = s.Mac.DecodeFrom(d, maxDepth) + nTmp, err = s.TxHashes.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HmacSha256Mac: %w", err) + return n, fmt.Errorf("decoding TxDemandVector: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s AuthenticatedMessageV0) MarshalBinary() ([]byte, error) { +func (s FloodDemand) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -24095,7 +23972,7 @@ func (s AuthenticatedMessageV0) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *AuthenticatedMessageV0) UnmarshalBinary(inp []byte) error { +func (s *FloodDemand) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -24105,786 +23982,3449 @@ func (s *AuthenticatedMessageV0) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*AuthenticatedMessageV0)(nil) - _ encoding.BinaryUnmarshaler = (*AuthenticatedMessageV0)(nil) + _ encoding.BinaryMarshaler = (*FloodDemand)(nil) + _ encoding.BinaryUnmarshaler = (*FloodDemand)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s AuthenticatedMessageV0) xdrType() {} +func (s FloodDemand) xdrType() {} -var _ xdrType = (*AuthenticatedMessageV0)(nil) +var _ xdrType = (*FloodDemand)(nil) -// AuthenticatedMessage is an XDR Union defines as: +// StellarMessage is an XDR Union defines as: // -// union AuthenticatedMessage switch (uint32 v) +// union StellarMessage switch (MessageType type) // { -// case 0: -// struct -// { -// uint64 sequence; -// StellarMessage message; -// HmacSha256Mac mac; -// } v0; +// case ERROR_MSG: +// Error error; +// case HELLO: +// Hello hello; +// case AUTH: +// Auth auth; +// case DONT_HAVE: +// DontHave dontHave; +// case GET_PEERS: +// void; +// case PEERS: +// PeerAddress peers<100>; +// +// case GET_TX_SET: +// uint256 txSetHash; +// case TX_SET: +// TransactionSet txSet; +// case GENERALIZED_TX_SET: +// GeneralizedTransactionSet generalizedTxSet; +// +// case TRANSACTION: +// TransactionEnvelope transaction; +// +// case SURVEY_REQUEST: +// SignedSurveyRequestMessage signedSurveyRequestMessage; +// +// case SURVEY_RESPONSE: +// SignedSurveyResponseMessage signedSurveyResponseMessage; +// +// case TIME_SLICED_SURVEY_REQUEST: +// SignedTimeSlicedSurveyRequestMessage signedTimeSlicedSurveyRequestMessage; +// +// case TIME_SLICED_SURVEY_RESPONSE: +// SignedTimeSlicedSurveyResponseMessage signedTimeSlicedSurveyResponseMessage; +// +// case TIME_SLICED_SURVEY_START_COLLECTING: +// SignedTimeSlicedSurveyStartCollectingMessage +// signedTimeSlicedSurveyStartCollectingMessage; +// +// case TIME_SLICED_SURVEY_STOP_COLLECTING: +// SignedTimeSlicedSurveyStopCollectingMessage +// signedTimeSlicedSurveyStopCollectingMessage; +// +// // SCP +// case GET_SCP_QUORUMSET: +// uint256 qSetHash; +// case SCP_QUORUMSET: +// SCPQuorumSet qSet; +// case SCP_MESSAGE: +// SCPEnvelope envelope; +// case GET_SCP_STATE: +// uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest +// case SEND_MORE: +// SendMore sendMoreMessage; +// case SEND_MORE_EXTENDED: +// SendMoreExtended sendMoreExtendedMessage; +// // Pull mode +// case FLOOD_ADVERT: +// FloodAdvert floodAdvert; +// case FLOOD_DEMAND: +// FloodDemand floodDemand; // }; -type AuthenticatedMessage struct { - V Uint32 - V0 *AuthenticatedMessageV0 -} - -// SwitchFieldName returns the field name in which this union's +type StellarMessage struct { + Type MessageType + Error *Error + Hello *Hello + Auth *Auth + DontHave *DontHave + Peers *[]PeerAddress `xdrmaxsize:"100"` + TxSetHash *Uint256 + TxSet *TransactionSet + GeneralizedTxSet *GeneralizedTransactionSet + Transaction *TransactionEnvelope + SignedSurveyRequestMessage *SignedSurveyRequestMessage + SignedSurveyResponseMessage *SignedSurveyResponseMessage + SignedTimeSlicedSurveyRequestMessage *SignedTimeSlicedSurveyRequestMessage + SignedTimeSlicedSurveyResponseMessage *SignedTimeSlicedSurveyResponseMessage + SignedTimeSlicedSurveyStartCollectingMessage *SignedTimeSlicedSurveyStartCollectingMessage + SignedTimeSlicedSurveyStopCollectingMessage *SignedTimeSlicedSurveyStopCollectingMessage + QSetHash *Uint256 + QSet *ScpQuorumSet + Envelope *ScpEnvelope + GetScpLedgerSeq *Uint32 + SendMoreMessage *SendMore + SendMoreExtendedMessage *SendMoreExtended + FloodAdvert *FloodAdvert + FloodDemand *FloodDemand +} + +// SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u AuthenticatedMessage) SwitchFieldName() string { - return "V" +func (u StellarMessage) SwitchFieldName() string { + return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of AuthenticatedMessage -func (u AuthenticatedMessage) ArmForSwitch(sw int32) (string, bool) { - switch Uint32(sw) { - case 0: - return "V0", true +// the value for an instance of StellarMessage +func (u StellarMessage) ArmForSwitch(sw int32) (string, bool) { + switch MessageType(sw) { + case MessageTypeErrorMsg: + return "Error", true + case MessageTypeHello: + return "Hello", true + case MessageTypeAuth: + return "Auth", true + case MessageTypeDontHave: + return "DontHave", true + case MessageTypeGetPeers: + return "", true + case MessageTypePeers: + return "Peers", true + case MessageTypeGetTxSet: + return "TxSetHash", true + case MessageTypeTxSet: + return "TxSet", true + case MessageTypeGeneralizedTxSet: + return "GeneralizedTxSet", true + case MessageTypeTransaction: + return "Transaction", true + case MessageTypeSurveyRequest: + return "SignedSurveyRequestMessage", true + case MessageTypeSurveyResponse: + return "SignedSurveyResponseMessage", true + case MessageTypeTimeSlicedSurveyRequest: + return "SignedTimeSlicedSurveyRequestMessage", true + case MessageTypeTimeSlicedSurveyResponse: + return "SignedTimeSlicedSurveyResponseMessage", true + case MessageTypeTimeSlicedSurveyStartCollecting: + return "SignedTimeSlicedSurveyStartCollectingMessage", true + case MessageTypeTimeSlicedSurveyStopCollecting: + return "SignedTimeSlicedSurveyStopCollectingMessage", true + case MessageTypeGetScpQuorumset: + return "QSetHash", true + case MessageTypeScpQuorumset: + return "QSet", true + case MessageTypeScpMessage: + return "Envelope", true + case MessageTypeGetScpState: + return "GetScpLedgerSeq", true + case MessageTypeSendMore: + return "SendMoreMessage", true + case MessageTypeSendMoreExtended: + return "SendMoreExtendedMessage", true + case MessageTypeFloodAdvert: + return "FloodAdvert", true + case MessageTypeFloodDemand: + return "FloodDemand", true } return "-", false } -// NewAuthenticatedMessage creates a new AuthenticatedMessage. -func NewAuthenticatedMessage(v Uint32, value interface{}) (result AuthenticatedMessage, err error) { - result.V = v - switch Uint32(v) { - case 0: - tv, ok := value.(AuthenticatedMessageV0) +// NewStellarMessage creates a new StellarMessage. +func NewStellarMessage(aType MessageType, value interface{}) (result StellarMessage, err error) { + result.Type = aType + switch MessageType(aType) { + case MessageTypeErrorMsg: + tv, ok := value.(Error) if !ok { - err = errors.New("invalid value, must be AuthenticatedMessageV0") + err = errors.New("invalid value, must be Error") return } - result.V0 = &tv + result.Error = &tv + case MessageTypeHello: + tv, ok := value.(Hello) + if !ok { + err = errors.New("invalid value, must be Hello") + return + } + result.Hello = &tv + case MessageTypeAuth: + tv, ok := value.(Auth) + if !ok { + err = errors.New("invalid value, must be Auth") + return + } + result.Auth = &tv + case MessageTypeDontHave: + tv, ok := value.(DontHave) + if !ok { + err = errors.New("invalid value, must be DontHave") + return + } + result.DontHave = &tv + case MessageTypeGetPeers: + // void + case MessageTypePeers: + tv, ok := value.([]PeerAddress) + if !ok { + err = errors.New("invalid value, must be []PeerAddress") + return + } + result.Peers = &tv + case MessageTypeGetTxSet: + tv, ok := value.(Uint256) + if !ok { + err = errors.New("invalid value, must be Uint256") + return + } + result.TxSetHash = &tv + case MessageTypeTxSet: + tv, ok := value.(TransactionSet) + if !ok { + err = errors.New("invalid value, must be TransactionSet") + return + } + result.TxSet = &tv + case MessageTypeGeneralizedTxSet: + tv, ok := value.(GeneralizedTransactionSet) + if !ok { + err = errors.New("invalid value, must be GeneralizedTransactionSet") + return + } + result.GeneralizedTxSet = &tv + case MessageTypeTransaction: + tv, ok := value.(TransactionEnvelope) + if !ok { + err = errors.New("invalid value, must be TransactionEnvelope") + return + } + result.Transaction = &tv + case MessageTypeSurveyRequest: + tv, ok := value.(SignedSurveyRequestMessage) + if !ok { + err = errors.New("invalid value, must be SignedSurveyRequestMessage") + return + } + result.SignedSurveyRequestMessage = &tv + case MessageTypeSurveyResponse: + tv, ok := value.(SignedSurveyResponseMessage) + if !ok { + err = errors.New("invalid value, must be SignedSurveyResponseMessage") + return + } + result.SignedSurveyResponseMessage = &tv + case MessageTypeTimeSlicedSurveyRequest: + tv, ok := value.(SignedTimeSlicedSurveyRequestMessage) + if !ok { + err = errors.New("invalid value, must be SignedTimeSlicedSurveyRequestMessage") + return + } + result.SignedTimeSlicedSurveyRequestMessage = &tv + case MessageTypeTimeSlicedSurveyResponse: + tv, ok := value.(SignedTimeSlicedSurveyResponseMessage) + if !ok { + err = errors.New("invalid value, must be SignedTimeSlicedSurveyResponseMessage") + return + } + result.SignedTimeSlicedSurveyResponseMessage = &tv + case MessageTypeTimeSlicedSurveyStartCollecting: + tv, ok := value.(SignedTimeSlicedSurveyStartCollectingMessage) + if !ok { + err = errors.New("invalid value, must be SignedTimeSlicedSurveyStartCollectingMessage") + return + } + result.SignedTimeSlicedSurveyStartCollectingMessage = &tv + case MessageTypeTimeSlicedSurveyStopCollecting: + tv, ok := value.(SignedTimeSlicedSurveyStopCollectingMessage) + if !ok { + err = errors.New("invalid value, must be SignedTimeSlicedSurveyStopCollectingMessage") + return + } + result.SignedTimeSlicedSurveyStopCollectingMessage = &tv + case MessageTypeGetScpQuorumset: + tv, ok := value.(Uint256) + if !ok { + err = errors.New("invalid value, must be Uint256") + return + } + result.QSetHash = &tv + case MessageTypeScpQuorumset: + tv, ok := value.(ScpQuorumSet) + if !ok { + err = errors.New("invalid value, must be ScpQuorumSet") + return + } + result.QSet = &tv + case MessageTypeScpMessage: + tv, ok := value.(ScpEnvelope) + if !ok { + err = errors.New("invalid value, must be ScpEnvelope") + return + } + result.Envelope = &tv + case MessageTypeGetScpState: + tv, ok := value.(Uint32) + if !ok { + err = errors.New("invalid value, must be Uint32") + return + } + result.GetScpLedgerSeq = &tv + case MessageTypeSendMore: + tv, ok := value.(SendMore) + if !ok { + err = errors.New("invalid value, must be SendMore") + return + } + result.SendMoreMessage = &tv + case MessageTypeSendMoreExtended: + tv, ok := value.(SendMoreExtended) + if !ok { + err = errors.New("invalid value, must be SendMoreExtended") + return + } + result.SendMoreExtendedMessage = &tv + case MessageTypeFloodAdvert: + tv, ok := value.(FloodAdvert) + if !ok { + err = errors.New("invalid value, must be FloodAdvert") + return + } + result.FloodAdvert = &tv + case MessageTypeFloodDemand: + tv, ok := value.(FloodDemand) + if !ok { + err = errors.New("invalid value, must be FloodDemand") + return + } + result.FloodDemand = &tv } return } -// MustV0 retrieves the V0 value from the union, +// MustError retrieves the Error value from the union, // panicing if the value is not set. -func (u AuthenticatedMessage) MustV0() AuthenticatedMessageV0 { - val, ok := u.GetV0() +func (u StellarMessage) MustError() Error { + val, ok := u.GetError() if !ok { - panic("arm V0 is not set") + panic("arm Error is not set") } return val } -// GetV0 retrieves the V0 value from the union, +// GetError retrieves the Error value from the union, // returning ok if the union's switch indicated the value is valid. -func (u AuthenticatedMessage) GetV0() (result AuthenticatedMessageV0, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) +func (u StellarMessage) GetError() (result Error, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "V0" { - result = *u.V0 + if armName == "Error" { + result = *u.Error ok = true } return } -// EncodeTo encodes this value using the Encoder. -func (u AuthenticatedMessage) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.V.EncodeTo(e); err != nil { - return err - } - switch Uint32(u.V) { - case 0: - if err = (*u.V0).EncodeTo(e); err != nil { - return err - } - return nil +// MustHello retrieves the Hello value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustHello() Hello { + val, ok := u.GetHello() + + if !ok { + panic("arm Hello is not set") } - return fmt.Errorf("V (Uint32) switch value '%d' is not valid for union AuthenticatedMessage", u.V) + + return val } -var _ decoderFrom = (*AuthenticatedMessage)(nil) +// GetHello retrieves the Hello value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetHello() (result Hello, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (u *AuthenticatedMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding AuthenticatedMessage: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = u.V.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - switch Uint32(u.V) { - case 0: - u.V0 = new(AuthenticatedMessageV0) - nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AuthenticatedMessageV0: %w", err) - } - return n, nil + if armName == "Hello" { + result = *u.Hello + ok = true } - return n, fmt.Errorf("union AuthenticatedMessage has invalid V (Uint32) switch value '%d'", u.V) -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s AuthenticatedMessage) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *AuthenticatedMessage) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustAuth retrieves the Auth value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustAuth() Auth { + val, ok := u.GetAuth() -var ( - _ encoding.BinaryMarshaler = (*AuthenticatedMessage)(nil) - _ encoding.BinaryUnmarshaler = (*AuthenticatedMessage)(nil) -) + if !ok { + panic("arm Auth is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s AuthenticatedMessage) xdrType() {} + return val +} -var _ xdrType = (*AuthenticatedMessage)(nil) +// GetAuth retrieves the Auth value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetAuth() (result Auth, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// MaxOpsPerTx is an XDR Const defines as: -// -// const MAX_OPS_PER_TX = 100; -const MaxOpsPerTx = 100 + if armName == "Auth" { + result = *u.Auth + ok = true + } -// LiquidityPoolParameters is an XDR Union defines as: -// -// union LiquidityPoolParameters switch (LiquidityPoolType type) -// { -// case LIQUIDITY_POOL_CONSTANT_PRODUCT: -// LiquidityPoolConstantProductParameters constantProduct; -// }; -type LiquidityPoolParameters struct { - Type LiquidityPoolType - ConstantProduct *LiquidityPoolConstantProductParameters + return } -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u LiquidityPoolParameters) SwitchFieldName() string { - return "Type" -} +// MustDontHave retrieves the DontHave value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustDontHave() DontHave { + val, ok := u.GetDontHave() -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of LiquidityPoolParameters -func (u LiquidityPoolParameters) ArmForSwitch(sw int32) (string, bool) { - switch LiquidityPoolType(sw) { - case LiquidityPoolTypeLiquidityPoolConstantProduct: - return "ConstantProduct", true + if !ok { + panic("arm DontHave is not set") } - return "-", false + + return val } -// NewLiquidityPoolParameters creates a new LiquidityPoolParameters. -func NewLiquidityPoolParameters(aType LiquidityPoolType, value interface{}) (result LiquidityPoolParameters, err error) { - result.Type = aType - switch LiquidityPoolType(aType) { - case LiquidityPoolTypeLiquidityPoolConstantProduct: - tv, ok := value.(LiquidityPoolConstantProductParameters) - if !ok { - err = errors.New("invalid value, must be LiquidityPoolConstantProductParameters") - return - } - result.ConstantProduct = &tv +// GetDontHave retrieves the DontHave value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetDontHave() (result DontHave, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "DontHave" { + result = *u.DontHave + ok = true } + return } -// MustConstantProduct retrieves the ConstantProduct value from the union, +// MustPeers retrieves the Peers value from the union, // panicing if the value is not set. -func (u LiquidityPoolParameters) MustConstantProduct() LiquidityPoolConstantProductParameters { - val, ok := u.GetConstantProduct() +func (u StellarMessage) MustPeers() []PeerAddress { + val, ok := u.GetPeers() if !ok { - panic("arm ConstantProduct is not set") + panic("arm Peers is not set") } return val } -// GetConstantProduct retrieves the ConstantProduct value from the union, +// GetPeers retrieves the Peers value from the union, // returning ok if the union's switch indicated the value is valid. -func (u LiquidityPoolParameters) GetConstantProduct() (result LiquidityPoolConstantProductParameters, ok bool) { +func (u StellarMessage) GetPeers() (result []PeerAddress, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "ConstantProduct" { - result = *u.ConstantProduct + if armName == "Peers" { + result = *u.Peers ok = true } return } -// EncodeTo encodes this value using the Encoder. -func (u LiquidityPoolParameters) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.Type.EncodeTo(e); err != nil { - return err - } - switch LiquidityPoolType(u.Type) { - case LiquidityPoolTypeLiquidityPoolConstantProduct: - if err = (*u.ConstantProduct).EncodeTo(e); err != nil { - return err - } - return nil +// MustTxSetHash retrieves the TxSetHash value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustTxSetHash() Uint256 { + val, ok := u.GetTxSetHash() + + if !ok { + panic("arm TxSetHash is not set") } - return fmt.Errorf("Type (LiquidityPoolType) switch value '%d' is not valid for union LiquidityPoolParameters", u.Type) + + return val } -var _ decoderFrom = (*LiquidityPoolParameters)(nil) +// GetTxSetHash retrieves the TxSetHash value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetTxSetHash() (result Uint256, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (u *LiquidityPoolParameters) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding LiquidityPoolParameters: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolType: %w", err) - } - switch LiquidityPoolType(u.Type) { - case LiquidityPoolTypeLiquidityPoolConstantProduct: - u.ConstantProduct = new(LiquidityPoolConstantProductParameters) - nTmp, err = (*u.ConstantProduct).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolConstantProductParameters: %w", err) - } - return n, nil + if armName == "TxSetHash" { + result = *u.TxSetHash + ok = true } - return n, fmt.Errorf("union LiquidityPoolParameters has invalid Type (LiquidityPoolType) switch value '%d'", u.Type) -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s LiquidityPoolParameters) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LiquidityPoolParameters) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustTxSet retrieves the TxSet value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustTxSet() TransactionSet { + val, ok := u.GetTxSet() -var ( - _ encoding.BinaryMarshaler = (*LiquidityPoolParameters)(nil) - _ encoding.BinaryUnmarshaler = (*LiquidityPoolParameters)(nil) -) + if !ok { + panic("arm TxSet is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s LiquidityPoolParameters) xdrType() {} + return val +} -var _ xdrType = (*LiquidityPoolParameters)(nil) +// GetTxSet retrieves the TxSet value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetTxSet() (result TransactionSet, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// MuxedAccountMed25519 is an XDR NestedStruct defines as: -// -// struct -// { -// uint64 id; -// uint256 ed25519; -// } -type MuxedAccountMed25519 struct { - Id Uint64 - Ed25519 Uint256 + if armName == "TxSet" { + result = *u.TxSet + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (s *MuxedAccountMed25519) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Id.EncodeTo(e); err != nil { - return err - } - if err = s.Ed25519.EncodeTo(e); err != nil { - return err +// MustGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustGeneralizedTxSet() GeneralizedTransactionSet { + val, ok := u.GetGeneralizedTxSet() + + if !ok { + panic("arm GeneralizedTxSet is not set") } - return nil + + return val } -var _ decoderFrom = (*MuxedAccountMed25519)(nil) +// GetGeneralizedTxSet retrieves the GeneralizedTxSet value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetGeneralizedTxSet() (result GeneralizedTransactionSet, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (s *MuxedAccountMed25519) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding MuxedAccountMed25519: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Id.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) - } - nTmp, err = s.Ed25519.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %w", err) + if armName == "GeneralizedTxSet" { + result = *u.GeneralizedTxSet + ok = true } - return n, nil -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s MuxedAccountMed25519) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *MuxedAccountMed25519) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustTransaction retrieves the Transaction value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustTransaction() TransactionEnvelope { + val, ok := u.GetTransaction() -var ( - _ encoding.BinaryMarshaler = (*MuxedAccountMed25519)(nil) - _ encoding.BinaryUnmarshaler = (*MuxedAccountMed25519)(nil) -) + if !ok { + panic("arm Transaction is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s MuxedAccountMed25519) xdrType() {} + return val +} -var _ xdrType = (*MuxedAccountMed25519)(nil) +// GetTransaction retrieves the Transaction value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetTransaction() (result TransactionEnvelope, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// MuxedAccount is an XDR Union defines as: -// -// union MuxedAccount switch (CryptoKeyType type) -// { -// case KEY_TYPE_ED25519: -// uint256 ed25519; -// case KEY_TYPE_MUXED_ED25519: -// struct -// { -// uint64 id; -// uint256 ed25519; -// } med25519; -// }; -type MuxedAccount struct { - Type CryptoKeyType - Ed25519 *Uint256 - Med25519 *MuxedAccountMed25519 -} + if armName == "Transaction" { + result = *u.Transaction + ok = true + } -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u MuxedAccount) SwitchFieldName() string { - return "Type" + return } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of MuxedAccount -func (u MuxedAccount) ArmForSwitch(sw int32) (string, bool) { - switch CryptoKeyType(sw) { - case CryptoKeyTypeKeyTypeEd25519: - return "Ed25519", true - case CryptoKeyTypeKeyTypeMuxedEd25519: - return "Med25519", true +// MustSignedSurveyRequestMessage retrieves the SignedSurveyRequestMessage value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustSignedSurveyRequestMessage() SignedSurveyRequestMessage { + val, ok := u.GetSignedSurveyRequestMessage() + + if !ok { + panic("arm SignedSurveyRequestMessage is not set") } - return "-", false + + return val } -// NewMuxedAccount creates a new MuxedAccount. -func NewMuxedAccount(aType CryptoKeyType, value interface{}) (result MuxedAccount, err error) { - result.Type = aType - switch CryptoKeyType(aType) { - case CryptoKeyTypeKeyTypeEd25519: - tv, ok := value.(Uint256) - if !ok { - err = errors.New("invalid value, must be Uint256") - return - } - result.Ed25519 = &tv - case CryptoKeyTypeKeyTypeMuxedEd25519: - tv, ok := value.(MuxedAccountMed25519) - if !ok { - err = errors.New("invalid value, must be MuxedAccountMed25519") - return - } - result.Med25519 = &tv +// GetSignedSurveyRequestMessage retrieves the SignedSurveyRequestMessage value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetSignedSurveyRequestMessage() (result SignedSurveyRequestMessage, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "SignedSurveyRequestMessage" { + result = *u.SignedSurveyRequestMessage + ok = true } + return } -// MustEd25519 retrieves the Ed25519 value from the union, +// MustSignedSurveyResponseMessage retrieves the SignedSurveyResponseMessage value from the union, // panicing if the value is not set. -func (u MuxedAccount) MustEd25519() Uint256 { - val, ok := u.GetEd25519() +func (u StellarMessage) MustSignedSurveyResponseMessage() SignedSurveyResponseMessage { + val, ok := u.GetSignedSurveyResponseMessage() if !ok { - panic("arm Ed25519 is not set") + panic("arm SignedSurveyResponseMessage is not set") } return val } -// GetEd25519 retrieves the Ed25519 value from the union, +// GetSignedSurveyResponseMessage retrieves the SignedSurveyResponseMessage value from the union, // returning ok if the union's switch indicated the value is valid. -func (u MuxedAccount) GetEd25519() (result Uint256, ok bool) { +func (u StellarMessage) GetSignedSurveyResponseMessage() (result SignedSurveyResponseMessage, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Ed25519" { - result = *u.Ed25519 + if armName == "SignedSurveyResponseMessage" { + result = *u.SignedSurveyResponseMessage ok = true } return } -// MustMed25519 retrieves the Med25519 value from the union, +// MustSignedTimeSlicedSurveyRequestMessage retrieves the SignedTimeSlicedSurveyRequestMessage value from the union, // panicing if the value is not set. -func (u MuxedAccount) MustMed25519() MuxedAccountMed25519 { - val, ok := u.GetMed25519() +func (u StellarMessage) MustSignedTimeSlicedSurveyRequestMessage() SignedTimeSlicedSurveyRequestMessage { + val, ok := u.GetSignedTimeSlicedSurveyRequestMessage() if !ok { - panic("arm Med25519 is not set") + panic("arm SignedTimeSlicedSurveyRequestMessage is not set") } return val } -// GetMed25519 retrieves the Med25519 value from the union, +// GetSignedTimeSlicedSurveyRequestMessage retrieves the SignedTimeSlicedSurveyRequestMessage value from the union, // returning ok if the union's switch indicated the value is valid. -func (u MuxedAccount) GetMed25519() (result MuxedAccountMed25519, ok bool) { +func (u StellarMessage) GetSignedTimeSlicedSurveyRequestMessage() (result SignedTimeSlicedSurveyRequestMessage, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Med25519" { - result = *u.Med25519 + if armName == "SignedTimeSlicedSurveyRequestMessage" { + result = *u.SignedTimeSlicedSurveyRequestMessage ok = true } return } -// EncodeTo encodes this value using the Encoder. -func (u MuxedAccount) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.Type.EncodeTo(e); err != nil { - return err - } - switch CryptoKeyType(u.Type) { - case CryptoKeyTypeKeyTypeEd25519: - if err = (*u.Ed25519).EncodeTo(e); err != nil { - return err - } - return nil - case CryptoKeyTypeKeyTypeMuxedEd25519: - if err = (*u.Med25519).EncodeTo(e); err != nil { - return err - } - return nil +// MustSignedTimeSlicedSurveyResponseMessage retrieves the SignedTimeSlicedSurveyResponseMessage value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustSignedTimeSlicedSurveyResponseMessage() SignedTimeSlicedSurveyResponseMessage { + val, ok := u.GetSignedTimeSlicedSurveyResponseMessage() + + if !ok { + panic("arm SignedTimeSlicedSurveyResponseMessage is not set") } - return fmt.Errorf("Type (CryptoKeyType) switch value '%d' is not valid for union MuxedAccount", u.Type) + + return val } -var _ decoderFrom = (*MuxedAccount)(nil) +// GetSignedTimeSlicedSurveyResponseMessage retrieves the SignedTimeSlicedSurveyResponseMessage value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetSignedTimeSlicedSurveyResponseMessage() (result SignedTimeSlicedSurveyResponseMessage, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (u *MuxedAccount) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding MuxedAccount: %w", ErrMaxDecodingDepthReached) + if armName == "SignedTimeSlicedSurveyResponseMessage" { + result = *u.SignedTimeSlicedSurveyResponseMessage + ok = true } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding CryptoKeyType: %w", err) + + return +} + +// MustSignedTimeSlicedSurveyStartCollectingMessage retrieves the SignedTimeSlicedSurveyStartCollectingMessage value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustSignedTimeSlicedSurveyStartCollectingMessage() SignedTimeSlicedSurveyStartCollectingMessage { + val, ok := u.GetSignedTimeSlicedSurveyStartCollectingMessage() + + if !ok { + panic("arm SignedTimeSlicedSurveyStartCollectingMessage is not set") } - switch CryptoKeyType(u.Type) { - case CryptoKeyTypeKeyTypeEd25519: - u.Ed25519 = new(Uint256) - nTmp, err = (*u.Ed25519).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %w", err) - } - return n, nil - case CryptoKeyTypeKeyTypeMuxedEd25519: - u.Med25519 = new(MuxedAccountMed25519) - nTmp, err = (*u.Med25519).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding MuxedAccountMed25519: %w", err) - } - return n, nil + + return val +} + +// GetSignedTimeSlicedSurveyStartCollectingMessage retrieves the SignedTimeSlicedSurveyStartCollectingMessage value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetSignedTimeSlicedSurveyStartCollectingMessage() (result SignedTimeSlicedSurveyStartCollectingMessage, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "SignedTimeSlicedSurveyStartCollectingMessage" { + result = *u.SignedTimeSlicedSurveyStartCollectingMessage + ok = true } - return n, fmt.Errorf("union MuxedAccount has invalid Type (CryptoKeyType) switch value '%d'", u.Type) + + return } -// MarshalBinary implements encoding.BinaryMarshaler. -func (s MuxedAccount) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err +// MustSignedTimeSlicedSurveyStopCollectingMessage retrieves the SignedTimeSlicedSurveyStopCollectingMessage value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustSignedTimeSlicedSurveyStopCollectingMessage() SignedTimeSlicedSurveyStopCollectingMessage { + val, ok := u.GetSignedTimeSlicedSurveyStopCollectingMessage() + + if !ok { + panic("arm SignedTimeSlicedSurveyStopCollectingMessage is not set") + } + + return val } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *MuxedAccount) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err +// GetSignedTimeSlicedSurveyStopCollectingMessage retrieves the SignedTimeSlicedSurveyStopCollectingMessage value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetSignedTimeSlicedSurveyStopCollectingMessage() (result SignedTimeSlicedSurveyStopCollectingMessage, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "SignedTimeSlicedSurveyStopCollectingMessage" { + result = *u.SignedTimeSlicedSurveyStopCollectingMessage + ok = true + } + + return } -var ( - _ encoding.BinaryMarshaler = (*MuxedAccount)(nil) - _ encoding.BinaryUnmarshaler = (*MuxedAccount)(nil) -) +// MustQSetHash retrieves the QSetHash value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustQSetHash() Uint256 { + val, ok := u.GetQSetHash() -// xdrType signals that this type represents XDR values defined by this package. -func (s MuxedAccount) xdrType() {} + if !ok { + panic("arm QSetHash is not set") + } -var _ xdrType = (*MuxedAccount)(nil) + return val +} -// DecoratedSignature is an XDR Struct defines as: -// -// struct DecoratedSignature -// { -// SignatureHint hint; // last 4 bytes of the public key, used as a hint -// Signature signature; // actual signature -// }; -type DecoratedSignature struct { - Hint SignatureHint - Signature Signature +// GetQSetHash retrieves the QSetHash value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetQSetHash() (result Uint256, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "QSetHash" { + result = *u.QSetHash + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (s *DecoratedSignature) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Hint.EncodeTo(e); err != nil { - return err +// MustQSet retrieves the QSet value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustQSet() ScpQuorumSet { + val, ok := u.GetQSet() + + if !ok { + panic("arm QSet is not set") } - if err = s.Signature.EncodeTo(e); err != nil { - return err + + return val +} + +// GetQSet retrieves the QSet value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetQSet() (result ScpQuorumSet, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "QSet" { + result = *u.QSet + ok = true } - return nil + + return } -var _ decoderFrom = (*DecoratedSignature)(nil) +// MustEnvelope retrieves the Envelope value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustEnvelope() ScpEnvelope { + val, ok := u.GetEnvelope() -// DecodeFrom decodes this value using the Decoder. -func (s *DecoratedSignature) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding DecoratedSignature: %w", ErrMaxDecodingDepthReached) + if !ok { + panic("arm Envelope is not set") } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Hint.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SignatureHint: %w", err) + + return val +} + +// GetEnvelope retrieves the Envelope value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetEnvelope() (result ScpEnvelope, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Envelope" { + result = *u.Envelope + ok = true } - nTmp, err = s.Signature.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Signature: %w", err) + + return +} + +// MustGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustGetScpLedgerSeq() Uint32 { + val, ok := u.GetGetScpLedgerSeq() + + if !ok { + panic("arm GetScpLedgerSeq is not set") } - return n, nil + + return val } -// MarshalBinary implements encoding.BinaryMarshaler. -func (s DecoratedSignature) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err +// GetGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetGetScpLedgerSeq() (result Uint32, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "GetScpLedgerSeq" { + result = *u.GetScpLedgerSeq + ok = true + } + + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *DecoratedSignature) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err +// MustSendMoreMessage retrieves the SendMoreMessage value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustSendMoreMessage() SendMore { + val, ok := u.GetSendMoreMessage() + + if !ok { + panic("arm SendMoreMessage is not set") + } + + return val } -var ( - _ encoding.BinaryMarshaler = (*DecoratedSignature)(nil) - _ encoding.BinaryUnmarshaler = (*DecoratedSignature)(nil) -) +// GetSendMoreMessage retrieves the SendMoreMessage value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetSendMoreMessage() (result SendMore, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// xdrType signals that this type represents XDR values defined by this package. -func (s DecoratedSignature) xdrType() {} + if armName == "SendMoreMessage" { + result = *u.SendMoreMessage + ok = true + } -var _ xdrType = (*DecoratedSignature)(nil) + return +} + +// MustSendMoreExtendedMessage retrieves the SendMoreExtendedMessage value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustSendMoreExtendedMessage() SendMoreExtended { + val, ok := u.GetSendMoreExtendedMessage() + + if !ok { + panic("arm SendMoreExtendedMessage is not set") + } + + return val +} + +// GetSendMoreExtendedMessage retrieves the SendMoreExtendedMessage value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetSendMoreExtendedMessage() (result SendMoreExtended, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "SendMoreExtendedMessage" { + result = *u.SendMoreExtendedMessage + ok = true + } + + return +} + +// MustFloodAdvert retrieves the FloodAdvert value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustFloodAdvert() FloodAdvert { + val, ok := u.GetFloodAdvert() + + if !ok { + panic("arm FloodAdvert is not set") + } + + return val +} + +// GetFloodAdvert retrieves the FloodAdvert value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetFloodAdvert() (result FloodAdvert, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "FloodAdvert" { + result = *u.FloodAdvert + ok = true + } + + return +} + +// MustFloodDemand retrieves the FloodDemand value from the union, +// panicing if the value is not set. +func (u StellarMessage) MustFloodDemand() FloodDemand { + val, ok := u.GetFloodDemand() + + if !ok { + panic("arm FloodDemand is not set") + } + + return val +} + +// GetFloodDemand retrieves the FloodDemand value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u StellarMessage) GetFloodDemand() (result FloodDemand, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "FloodDemand" { + result = *u.FloodDemand + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u StellarMessage) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err + } + switch MessageType(u.Type) { + case MessageTypeErrorMsg: + if err = (*u.Error).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeHello: + if err = (*u.Hello).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeAuth: + if err = (*u.Auth).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeDontHave: + if err = (*u.DontHave).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeGetPeers: + // Void + return nil + case MessageTypePeers: + if _, err = e.EncodeUint(uint32(len((*u.Peers)))); err != nil { + return err + } + for i := 0; i < len((*u.Peers)); i++ { + if err = (*u.Peers)[i].EncodeTo(e); err != nil { + return err + } + } + return nil + case MessageTypeGetTxSet: + if err = (*u.TxSetHash).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeTxSet: + if err = (*u.TxSet).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeGeneralizedTxSet: + if err = (*u.GeneralizedTxSet).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeTransaction: + if err = (*u.Transaction).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeSurveyRequest: + if err = (*u.SignedSurveyRequestMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeSurveyResponse: + if err = (*u.SignedSurveyResponseMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeTimeSlicedSurveyRequest: + if err = (*u.SignedTimeSlicedSurveyRequestMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeTimeSlicedSurveyResponse: + if err = (*u.SignedTimeSlicedSurveyResponseMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeTimeSlicedSurveyStartCollecting: + if err = (*u.SignedTimeSlicedSurveyStartCollectingMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeTimeSlicedSurveyStopCollecting: + if err = (*u.SignedTimeSlicedSurveyStopCollectingMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeGetScpQuorumset: + if err = (*u.QSetHash).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeScpQuorumset: + if err = (*u.QSet).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeScpMessage: + if err = (*u.Envelope).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeGetScpState: + if err = (*u.GetScpLedgerSeq).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeSendMore: + if err = (*u.SendMoreMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeSendMoreExtended: + if err = (*u.SendMoreExtendedMessage).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeFloodAdvert: + if err = (*u.FloodAdvert).EncodeTo(e); err != nil { + return err + } + return nil + case MessageTypeFloodDemand: + if err = (*u.FloodDemand).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (MessageType) switch value '%d' is not valid for union StellarMessage", u.Type) +} + +var _ decoderFrom = (*StellarMessage)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *StellarMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding StellarMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MessageType: %w", err) + } + switch MessageType(u.Type) { + case MessageTypeErrorMsg: + u.Error = new(Error) + nTmp, err = (*u.Error).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Error: %w", err) + } + return n, nil + case MessageTypeHello: + u.Hello = new(Hello) + nTmp, err = (*u.Hello).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hello: %w", err) + } + return n, nil + case MessageTypeAuth: + u.Auth = new(Auth) + nTmp, err = (*u.Auth).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Auth: %w", err) + } + return n, nil + case MessageTypeDontHave: + u.DontHave = new(DontHave) + nTmp, err = (*u.DontHave).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding DontHave: %w", err) + } + return n, nil + case MessageTypeGetPeers: + // Void + return n, nil + case MessageTypePeers: + u.Peers = new([]PeerAddress) + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PeerAddress: %w", err) + } + if l > 100 { + return n, fmt.Errorf("decoding PeerAddress: data size (%d) exceeds size limit (100)", l) + } + (*u.Peers) = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding PeerAddress: length (%d) exceeds remaining input length (%d)", l, il) + } + (*u.Peers) = make([]PeerAddress, l) + for i := uint32(0); i < l; i++ { + nTmp, err = (*u.Peers)[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PeerAddress: %w", err) + } + } + } + return n, nil + case MessageTypeGetTxSet: + u.TxSetHash = new(Uint256) + nTmp, err = (*u.TxSetHash).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint256: %w", err) + } + return n, nil + case MessageTypeTxSet: + u.TxSet = new(TransactionSet) + nTmp, err = (*u.TxSet).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionSet: %w", err) + } + return n, nil + case MessageTypeGeneralizedTxSet: + u.GeneralizedTxSet = new(GeneralizedTransactionSet) + nTmp, err = (*u.GeneralizedTxSet).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding GeneralizedTransactionSet: %w", err) + } + return n, nil + case MessageTypeTransaction: + u.Transaction = new(TransactionEnvelope) + nTmp, err = (*u.Transaction).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding TransactionEnvelope: %w", err) + } + return n, nil + case MessageTypeSurveyRequest: + u.SignedSurveyRequestMessage = new(SignedSurveyRequestMessage) + nTmp, err = (*u.SignedSurveyRequestMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignedSurveyRequestMessage: %w", err) + } + return n, nil + case MessageTypeSurveyResponse: + u.SignedSurveyResponseMessage = new(SignedSurveyResponseMessage) + nTmp, err = (*u.SignedSurveyResponseMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignedSurveyResponseMessage: %w", err) + } + return n, nil + case MessageTypeTimeSlicedSurveyRequest: + u.SignedTimeSlicedSurveyRequestMessage = new(SignedTimeSlicedSurveyRequestMessage) + nTmp, err = (*u.SignedTimeSlicedSurveyRequestMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignedTimeSlicedSurveyRequestMessage: %w", err) + } + return n, nil + case MessageTypeTimeSlicedSurveyResponse: + u.SignedTimeSlicedSurveyResponseMessage = new(SignedTimeSlicedSurveyResponseMessage) + nTmp, err = (*u.SignedTimeSlicedSurveyResponseMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignedTimeSlicedSurveyResponseMessage: %w", err) + } + return n, nil + case MessageTypeTimeSlicedSurveyStartCollecting: + u.SignedTimeSlicedSurveyStartCollectingMessage = new(SignedTimeSlicedSurveyStartCollectingMessage) + nTmp, err = (*u.SignedTimeSlicedSurveyStartCollectingMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignedTimeSlicedSurveyStartCollectingMessage: %w", err) + } + return n, nil + case MessageTypeTimeSlicedSurveyStopCollecting: + u.SignedTimeSlicedSurveyStopCollectingMessage = new(SignedTimeSlicedSurveyStopCollectingMessage) + nTmp, err = (*u.SignedTimeSlicedSurveyStopCollectingMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignedTimeSlicedSurveyStopCollectingMessage: %w", err) + } + return n, nil + case MessageTypeGetScpQuorumset: + u.QSetHash = new(Uint256) + nTmp, err = (*u.QSetHash).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint256: %w", err) + } + return n, nil + case MessageTypeScpQuorumset: + u.QSet = new(ScpQuorumSet) + nTmp, err = (*u.QSet).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScpQuorumSet: %w", err) + } + return n, nil + case MessageTypeScpMessage: + u.Envelope = new(ScpEnvelope) + nTmp, err = (*u.Envelope).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScpEnvelope: %w", err) + } + return n, nil + case MessageTypeGetScpState: + u.GetScpLedgerSeq = new(Uint32) + nTmp, err = (*u.GetScpLedgerSeq).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil + case MessageTypeSendMore: + u.SendMoreMessage = new(SendMore) + nTmp, err = (*u.SendMoreMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SendMore: %w", err) + } + return n, nil + case MessageTypeSendMoreExtended: + u.SendMoreExtendedMessage = new(SendMoreExtended) + nTmp, err = (*u.SendMoreExtendedMessage).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SendMoreExtended: %w", err) + } + return n, nil + case MessageTypeFloodAdvert: + u.FloodAdvert = new(FloodAdvert) + nTmp, err = (*u.FloodAdvert).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding FloodAdvert: %w", err) + } + return n, nil + case MessageTypeFloodDemand: + u.FloodDemand = new(FloodDemand) + nTmp, err = (*u.FloodDemand).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding FloodDemand: %w", err) + } + return n, nil + } + return n, fmt.Errorf("union StellarMessage has invalid Type (MessageType) switch value '%d'", u.Type) +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s StellarMessage) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *StellarMessage) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*StellarMessage)(nil) + _ encoding.BinaryUnmarshaler = (*StellarMessage)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s StellarMessage) xdrType() {} + +var _ xdrType = (*StellarMessage)(nil) + +// AuthenticatedMessageV0 is an XDR NestedStruct defines as: +// +// struct +// { +// uint64 sequence; +// StellarMessage message; +// HmacSha256Mac mac; +// } +type AuthenticatedMessageV0 struct { + Sequence Uint64 + Message StellarMessage + Mac HmacSha256Mac +} + +// EncodeTo encodes this value using the Encoder. +func (s *AuthenticatedMessageV0) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Sequence.EncodeTo(e); err != nil { + return err + } + if err = s.Message.EncodeTo(e); err != nil { + return err + } + if err = s.Mac.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*AuthenticatedMessageV0)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *AuthenticatedMessageV0) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AuthenticatedMessageV0: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Sequence.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.Message.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding StellarMessage: %w", err) + } + nTmp, err = s.Mac.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding HmacSha256Mac: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s AuthenticatedMessageV0) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *AuthenticatedMessageV0) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*AuthenticatedMessageV0)(nil) + _ encoding.BinaryUnmarshaler = (*AuthenticatedMessageV0)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s AuthenticatedMessageV0) xdrType() {} + +var _ xdrType = (*AuthenticatedMessageV0)(nil) + +// AuthenticatedMessage is an XDR Union defines as: +// +// union AuthenticatedMessage switch (uint32 v) +// { +// case 0: +// struct +// { +// uint64 sequence; +// StellarMessage message; +// HmacSha256Mac mac; +// } v0; +// }; +type AuthenticatedMessage struct { + V Uint32 + V0 *AuthenticatedMessageV0 +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u AuthenticatedMessage) SwitchFieldName() string { + return "V" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of AuthenticatedMessage +func (u AuthenticatedMessage) ArmForSwitch(sw int32) (string, bool) { + switch Uint32(sw) { + case 0: + return "V0", true + } + return "-", false +} + +// NewAuthenticatedMessage creates a new AuthenticatedMessage. +func NewAuthenticatedMessage(v Uint32, value interface{}) (result AuthenticatedMessage, err error) { + result.V = v + switch Uint32(v) { + case 0: + tv, ok := value.(AuthenticatedMessageV0) + if !ok { + err = errors.New("invalid value, must be AuthenticatedMessageV0") + return + } + result.V0 = &tv + } + return +} + +// MustV0 retrieves the V0 value from the union, +// panicing if the value is not set. +func (u AuthenticatedMessage) MustV0() AuthenticatedMessageV0 { + val, ok := u.GetV0() + + if !ok { + panic("arm V0 is not set") + } + + return val +} + +// GetV0 retrieves the V0 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u AuthenticatedMessage) GetV0() (result AuthenticatedMessageV0, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.V)) + + if armName == "V0" { + result = *u.V0 + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u AuthenticatedMessage) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.V.EncodeTo(e); err != nil { + return err + } + switch Uint32(u.V) { + case 0: + if err = (*u.V0).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("V (Uint32) switch value '%d' is not valid for union AuthenticatedMessage", u.V) +} + +var _ decoderFrom = (*AuthenticatedMessage)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *AuthenticatedMessage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding AuthenticatedMessage: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = u.V.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + switch Uint32(u.V) { + case 0: + u.V0 = new(AuthenticatedMessageV0) + nTmp, err = (*u.V0).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AuthenticatedMessageV0: %w", err) + } + return n, nil + } + return n, fmt.Errorf("union AuthenticatedMessage has invalid V (Uint32) switch value '%d'", u.V) +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s AuthenticatedMessage) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *AuthenticatedMessage) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*AuthenticatedMessage)(nil) + _ encoding.BinaryUnmarshaler = (*AuthenticatedMessage)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s AuthenticatedMessage) xdrType() {} + +var _ xdrType = (*AuthenticatedMessage)(nil) + +// MaxOpsPerTx is an XDR Const defines as: +// +// const MAX_OPS_PER_TX = 100; +const MaxOpsPerTx = 100 + +// LiquidityPoolParameters is an XDR Union defines as: +// +// union LiquidityPoolParameters switch (LiquidityPoolType type) +// { +// case LIQUIDITY_POOL_CONSTANT_PRODUCT: +// LiquidityPoolConstantProductParameters constantProduct; +// }; +type LiquidityPoolParameters struct { + Type LiquidityPoolType + ConstantProduct *LiquidityPoolConstantProductParameters +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u LiquidityPoolParameters) SwitchFieldName() string { + return "Type" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of LiquidityPoolParameters +func (u LiquidityPoolParameters) ArmForSwitch(sw int32) (string, bool) { + switch LiquidityPoolType(sw) { + case LiquidityPoolTypeLiquidityPoolConstantProduct: + return "ConstantProduct", true + } + return "-", false +} + +// NewLiquidityPoolParameters creates a new LiquidityPoolParameters. +func NewLiquidityPoolParameters(aType LiquidityPoolType, value interface{}) (result LiquidityPoolParameters, err error) { + result.Type = aType + switch LiquidityPoolType(aType) { + case LiquidityPoolTypeLiquidityPoolConstantProduct: + tv, ok := value.(LiquidityPoolConstantProductParameters) + if !ok { + err = errors.New("invalid value, must be LiquidityPoolConstantProductParameters") + return + } + result.ConstantProduct = &tv + } + return +} + +// MustConstantProduct retrieves the ConstantProduct value from the union, +// panicing if the value is not set. +func (u LiquidityPoolParameters) MustConstantProduct() LiquidityPoolConstantProductParameters { + val, ok := u.GetConstantProduct() + + if !ok { + panic("arm ConstantProduct is not set") + } + + return val +} + +// GetConstantProduct retrieves the ConstantProduct value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u LiquidityPoolParameters) GetConstantProduct() (result LiquidityPoolConstantProductParameters, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "ConstantProduct" { + result = *u.ConstantProduct + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u LiquidityPoolParameters) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err + } + switch LiquidityPoolType(u.Type) { + case LiquidityPoolTypeLiquidityPoolConstantProduct: + if err = (*u.ConstantProduct).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (LiquidityPoolType) switch value '%d' is not valid for union LiquidityPoolParameters", u.Type) +} + +var _ decoderFrom = (*LiquidityPoolParameters)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *LiquidityPoolParameters) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LiquidityPoolParameters: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LiquidityPoolType: %w", err) + } + switch LiquidityPoolType(u.Type) { + case LiquidityPoolTypeLiquidityPoolConstantProduct: + u.ConstantProduct = new(LiquidityPoolConstantProductParameters) + nTmp, err = (*u.ConstantProduct).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LiquidityPoolConstantProductParameters: %w", err) + } + return n, nil + } + return n, fmt.Errorf("union LiquidityPoolParameters has invalid Type (LiquidityPoolType) switch value '%d'", u.Type) +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s LiquidityPoolParameters) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *LiquidityPoolParameters) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*LiquidityPoolParameters)(nil) + _ encoding.BinaryUnmarshaler = (*LiquidityPoolParameters)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s LiquidityPoolParameters) xdrType() {} + +var _ xdrType = (*LiquidityPoolParameters)(nil) + +// MuxedAccountMed25519 is an XDR NestedStruct defines as: +// +// struct +// { +// uint64 id; +// uint256 ed25519; +// } +type MuxedAccountMed25519 struct { + Id Uint64 + Ed25519 Uint256 +} + +// EncodeTo encodes this value using the Encoder. +func (s *MuxedAccountMed25519) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Id.EncodeTo(e); err != nil { + return err + } + if err = s.Ed25519.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*MuxedAccountMed25519)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *MuxedAccountMed25519) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding MuxedAccountMed25519: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Id.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + nTmp, err = s.Ed25519.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint256: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s MuxedAccountMed25519) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *MuxedAccountMed25519) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*MuxedAccountMed25519)(nil) + _ encoding.BinaryUnmarshaler = (*MuxedAccountMed25519)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s MuxedAccountMed25519) xdrType() {} + +var _ xdrType = (*MuxedAccountMed25519)(nil) + +// MuxedAccount is an XDR Union defines as: +// +// union MuxedAccount switch (CryptoKeyType type) +// { +// case KEY_TYPE_ED25519: +// uint256 ed25519; +// case KEY_TYPE_MUXED_ED25519: +// struct +// { +// uint64 id; +// uint256 ed25519; +// } med25519; +// }; +type MuxedAccount struct { + Type CryptoKeyType + Ed25519 *Uint256 + Med25519 *MuxedAccountMed25519 +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u MuxedAccount) SwitchFieldName() string { + return "Type" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of MuxedAccount +func (u MuxedAccount) ArmForSwitch(sw int32) (string, bool) { + switch CryptoKeyType(sw) { + case CryptoKeyTypeKeyTypeEd25519: + return "Ed25519", true + case CryptoKeyTypeKeyTypeMuxedEd25519: + return "Med25519", true + } + return "-", false +} + +// NewMuxedAccount creates a new MuxedAccount. +func NewMuxedAccount(aType CryptoKeyType, value interface{}) (result MuxedAccount, err error) { + result.Type = aType + switch CryptoKeyType(aType) { + case CryptoKeyTypeKeyTypeEd25519: + tv, ok := value.(Uint256) + if !ok { + err = errors.New("invalid value, must be Uint256") + return + } + result.Ed25519 = &tv + case CryptoKeyTypeKeyTypeMuxedEd25519: + tv, ok := value.(MuxedAccountMed25519) + if !ok { + err = errors.New("invalid value, must be MuxedAccountMed25519") + return + } + result.Med25519 = &tv + } + return +} + +// MustEd25519 retrieves the Ed25519 value from the union, +// panicing if the value is not set. +func (u MuxedAccount) MustEd25519() Uint256 { + val, ok := u.GetEd25519() + + if !ok { + panic("arm Ed25519 is not set") + } + + return val +} + +// GetEd25519 retrieves the Ed25519 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u MuxedAccount) GetEd25519() (result Uint256, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Ed25519" { + result = *u.Ed25519 + ok = true + } + + return +} + +// MustMed25519 retrieves the Med25519 value from the union, +// panicing if the value is not set. +func (u MuxedAccount) MustMed25519() MuxedAccountMed25519 { + val, ok := u.GetMed25519() + + if !ok { + panic("arm Med25519 is not set") + } + + return val +} + +// GetMed25519 retrieves the Med25519 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u MuxedAccount) GetMed25519() (result MuxedAccountMed25519, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Med25519" { + result = *u.Med25519 + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u MuxedAccount) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err + } + switch CryptoKeyType(u.Type) { + case CryptoKeyTypeKeyTypeEd25519: + if err = (*u.Ed25519).EncodeTo(e); err != nil { + return err + } + return nil + case CryptoKeyTypeKeyTypeMuxedEd25519: + if err = (*u.Med25519).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (CryptoKeyType) switch value '%d' is not valid for union MuxedAccount", u.Type) +} + +var _ decoderFrom = (*MuxedAccount)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *MuxedAccount) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding MuxedAccount: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CryptoKeyType: %w", err) + } + switch CryptoKeyType(u.Type) { + case CryptoKeyTypeKeyTypeEd25519: + u.Ed25519 = new(Uint256) + nTmp, err = (*u.Ed25519).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint256: %w", err) + } + return n, nil + case CryptoKeyTypeKeyTypeMuxedEd25519: + u.Med25519 = new(MuxedAccountMed25519) + nTmp, err = (*u.Med25519).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MuxedAccountMed25519: %w", err) + } + return n, nil + } + return n, fmt.Errorf("union MuxedAccount has invalid Type (CryptoKeyType) switch value '%d'", u.Type) +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s MuxedAccount) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *MuxedAccount) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*MuxedAccount)(nil) + _ encoding.BinaryUnmarshaler = (*MuxedAccount)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s MuxedAccount) xdrType() {} + +var _ xdrType = (*MuxedAccount)(nil) + +// DecoratedSignature is an XDR Struct defines as: +// +// struct DecoratedSignature +// { +// SignatureHint hint; // last 4 bytes of the public key, used as a hint +// Signature signature; // actual signature +// }; +type DecoratedSignature struct { + Hint SignatureHint + Signature Signature +} + +// EncodeTo encodes this value using the Encoder. +func (s *DecoratedSignature) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Hint.EncodeTo(e); err != nil { + return err + } + if err = s.Signature.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*DecoratedSignature)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *DecoratedSignature) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding DecoratedSignature: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Hint.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignatureHint: %w", err) + } + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Signature: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s DecoratedSignature) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *DecoratedSignature) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*DecoratedSignature)(nil) + _ encoding.BinaryUnmarshaler = (*DecoratedSignature)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s DecoratedSignature) xdrType() {} + +var _ xdrType = (*DecoratedSignature)(nil) // OperationType is an XDR Enum defines as: // -// enum OperationType +// enum OperationType +// { +// CREATE_ACCOUNT = 0, +// PAYMENT = 1, +// PATH_PAYMENT_STRICT_RECEIVE = 2, +// MANAGE_SELL_OFFER = 3, +// CREATE_PASSIVE_SELL_OFFER = 4, +// SET_OPTIONS = 5, +// CHANGE_TRUST = 6, +// ALLOW_TRUST = 7, +// ACCOUNT_MERGE = 8, +// INFLATION = 9, +// MANAGE_DATA = 10, +// BUMP_SEQUENCE = 11, +// MANAGE_BUY_OFFER = 12, +// PATH_PAYMENT_STRICT_SEND = 13, +// CREATE_CLAIMABLE_BALANCE = 14, +// CLAIM_CLAIMABLE_BALANCE = 15, +// BEGIN_SPONSORING_FUTURE_RESERVES = 16, +// END_SPONSORING_FUTURE_RESERVES = 17, +// REVOKE_SPONSORSHIP = 18, +// CLAWBACK = 19, +// CLAWBACK_CLAIMABLE_BALANCE = 20, +// SET_TRUST_LINE_FLAGS = 21, +// LIQUIDITY_POOL_DEPOSIT = 22, +// LIQUIDITY_POOL_WITHDRAW = 23, +// INVOKE_HOST_FUNCTION = 24, +// EXTEND_FOOTPRINT_TTL = 25, +// RESTORE_FOOTPRINT = 26 +// }; +type OperationType int32 + +const ( + OperationTypeCreateAccount OperationType = 0 + OperationTypePayment OperationType = 1 + OperationTypePathPaymentStrictReceive OperationType = 2 + OperationTypeManageSellOffer OperationType = 3 + OperationTypeCreatePassiveSellOffer OperationType = 4 + OperationTypeSetOptions OperationType = 5 + OperationTypeChangeTrust OperationType = 6 + OperationTypeAllowTrust OperationType = 7 + OperationTypeAccountMerge OperationType = 8 + OperationTypeInflation OperationType = 9 + OperationTypeManageData OperationType = 10 + OperationTypeBumpSequence OperationType = 11 + OperationTypeManageBuyOffer OperationType = 12 + OperationTypePathPaymentStrictSend OperationType = 13 + OperationTypeCreateClaimableBalance OperationType = 14 + OperationTypeClaimClaimableBalance OperationType = 15 + OperationTypeBeginSponsoringFutureReserves OperationType = 16 + OperationTypeEndSponsoringFutureReserves OperationType = 17 + OperationTypeRevokeSponsorship OperationType = 18 + OperationTypeClawback OperationType = 19 + OperationTypeClawbackClaimableBalance OperationType = 20 + OperationTypeSetTrustLineFlags OperationType = 21 + OperationTypeLiquidityPoolDeposit OperationType = 22 + OperationTypeLiquidityPoolWithdraw OperationType = 23 + OperationTypeInvokeHostFunction OperationType = 24 + OperationTypeExtendFootprintTtl OperationType = 25 + OperationTypeRestoreFootprint OperationType = 26 +) + +var operationTypeMap = map[int32]string{ + 0: "OperationTypeCreateAccount", + 1: "OperationTypePayment", + 2: "OperationTypePathPaymentStrictReceive", + 3: "OperationTypeManageSellOffer", + 4: "OperationTypeCreatePassiveSellOffer", + 5: "OperationTypeSetOptions", + 6: "OperationTypeChangeTrust", + 7: "OperationTypeAllowTrust", + 8: "OperationTypeAccountMerge", + 9: "OperationTypeInflation", + 10: "OperationTypeManageData", + 11: "OperationTypeBumpSequence", + 12: "OperationTypeManageBuyOffer", + 13: "OperationTypePathPaymentStrictSend", + 14: "OperationTypeCreateClaimableBalance", + 15: "OperationTypeClaimClaimableBalance", + 16: "OperationTypeBeginSponsoringFutureReserves", + 17: "OperationTypeEndSponsoringFutureReserves", + 18: "OperationTypeRevokeSponsorship", + 19: "OperationTypeClawback", + 20: "OperationTypeClawbackClaimableBalance", + 21: "OperationTypeSetTrustLineFlags", + 22: "OperationTypeLiquidityPoolDeposit", + 23: "OperationTypeLiquidityPoolWithdraw", + 24: "OperationTypeInvokeHostFunction", + 25: "OperationTypeExtendFootprintTtl", + 26: "OperationTypeRestoreFootprint", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for OperationType +func (e OperationType) ValidEnum(v int32) bool { + _, ok := operationTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e OperationType) String() string { + name, _ := operationTypeMap[int32(e)] + return name +} + +// EncodeTo encodes this value using the Encoder. +func (e OperationType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := operationTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid OperationType enum value", e) + } + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*OperationType)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (e *OperationType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + v, n, err := d.DecodeInt() + if err != nil { + return n, fmt.Errorf("decoding OperationType: %w", err) + } + if _, ok := operationTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid OperationType enum value", v) + } + *e = OperationType(v) + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s OperationType) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *OperationType) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*OperationType)(nil) + _ encoding.BinaryUnmarshaler = (*OperationType)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s OperationType) xdrType() {} + +var _ xdrType = (*OperationType)(nil) + +// CreateAccountOp is an XDR Struct defines as: +// +// struct CreateAccountOp +// { +// AccountID destination; // account to create +// int64 startingBalance; // amount they end up with +// }; +type CreateAccountOp struct { + Destination AccountId + StartingBalance Int64 +} + +// EncodeTo encodes this value using the Encoder. +func (s *CreateAccountOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Destination.EncodeTo(e); err != nil { + return err + } + if err = s.StartingBalance.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*CreateAccountOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *CreateAccountOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreateAccountOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AccountId: %w", err) + } + nTmp, err = s.StartingBalance.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s CreateAccountOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *CreateAccountOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*CreateAccountOp)(nil) + _ encoding.BinaryUnmarshaler = (*CreateAccountOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s CreateAccountOp) xdrType() {} + +var _ xdrType = (*CreateAccountOp)(nil) + +// PaymentOp is an XDR Struct defines as: +// +// struct PaymentOp +// { +// MuxedAccount destination; // recipient of the payment +// Asset asset; // what they end up with +// int64 amount; // amount they end up with +// }; +type PaymentOp struct { + Destination MuxedAccount + Asset Asset + Amount Int64 +} + +// EncodeTo encodes this value using the Encoder. +func (s *PaymentOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Destination.EncodeTo(e); err != nil { + return err + } + if err = s.Asset.EncodeTo(e); err != nil { + return err + } + if err = s.Amount.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*PaymentOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *PaymentOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PaymentOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MuxedAccount: %w", err) + } + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s PaymentOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *PaymentOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*PaymentOp)(nil) + _ encoding.BinaryUnmarshaler = (*PaymentOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s PaymentOp) xdrType() {} + +var _ xdrType = (*PaymentOp)(nil) + +// PathPaymentStrictReceiveOp is an XDR Struct defines as: +// +// struct PathPaymentStrictReceiveOp +// { +// Asset sendAsset; // asset we pay with +// int64 sendMax; // the maximum amount of sendAsset to +// // send (excluding fees). +// // The operation will fail if can't be met +// +// MuxedAccount destination; // recipient of the payment +// Asset destAsset; // what they end up with +// int64 destAmount; // amount they end up with +// +// Asset path<5>; // additional hops it must go through to get there +// }; +type PathPaymentStrictReceiveOp struct { + SendAsset Asset + SendMax Int64 + Destination MuxedAccount + DestAsset Asset + DestAmount Int64 + Path []Asset `xdrmaxsize:"5"` +} + +// EncodeTo encodes this value using the Encoder. +func (s *PathPaymentStrictReceiveOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.SendAsset.EncodeTo(e); err != nil { + return err + } + if err = s.SendMax.EncodeTo(e); err != nil { + return err + } + if err = s.Destination.EncodeTo(e); err != nil { + return err + } + if err = s.DestAsset.EncodeTo(e); err != nil { + return err + } + if err = s.DestAmount.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.Path))); err != nil { + return err + } + for i := 0; i < len(s.Path); i++ { + if err = s.Path[i].EncodeTo(e); err != nil { + return err + } + } + return nil +} + +var _ decoderFrom = (*PathPaymentStrictReceiveOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *PathPaymentStrictReceiveOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictReceiveOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.SendAsset.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.SendMax.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MuxedAccount: %w", err) + } + nTmp, err = s.DestAsset.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.DestAmount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + if l > 5 { + return n, fmt.Errorf("decoding Asset: data size (%d) exceeds size limit (5)", l) + } + s.Path = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Path = make([]Asset, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s PathPaymentStrictReceiveOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *PathPaymentStrictReceiveOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*PathPaymentStrictReceiveOp)(nil) + _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s PathPaymentStrictReceiveOp) xdrType() {} + +var _ xdrType = (*PathPaymentStrictReceiveOp)(nil) + +// PathPaymentStrictSendOp is an XDR Struct defines as: +// +// struct PathPaymentStrictSendOp +// { +// Asset sendAsset; // asset we pay with +// int64 sendAmount; // amount of sendAsset to send (excluding fees) +// +// MuxedAccount destination; // recipient of the payment +// Asset destAsset; // what they end up with +// int64 destMin; // the minimum amount of dest asset to +// // be received +// // The operation will fail if it can't be met +// +// Asset path<5>; // additional hops it must go through to get there +// }; +type PathPaymentStrictSendOp struct { + SendAsset Asset + SendAmount Int64 + Destination MuxedAccount + DestAsset Asset + DestMin Int64 + Path []Asset `xdrmaxsize:"5"` +} + +// EncodeTo encodes this value using the Encoder. +func (s *PathPaymentStrictSendOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.SendAsset.EncodeTo(e); err != nil { + return err + } + if err = s.SendAmount.EncodeTo(e); err != nil { + return err + } + if err = s.Destination.EncodeTo(e); err != nil { + return err + } + if err = s.DestAsset.EncodeTo(e); err != nil { + return err + } + if err = s.DestMin.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.Path))); err != nil { + return err + } + for i := 0; i < len(s.Path); i++ { + if err = s.Path[i].EncodeTo(e); err != nil { + return err + } + } + return nil +} + +var _ decoderFrom = (*PathPaymentStrictSendOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *PathPaymentStrictSendOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding PathPaymentStrictSendOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.SendAsset.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.SendAmount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.Destination.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MuxedAccount: %w", err) + } + nTmp, err = s.DestAsset.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.DestMin.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + if l > 5 { + return n, fmt.Errorf("decoding Asset: data size (%d) exceeds size limit (5)", l) + } + s.Path = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Path = make([]Asset, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s PathPaymentStrictSendOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *PathPaymentStrictSendOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*PathPaymentStrictSendOp)(nil) + _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s PathPaymentStrictSendOp) xdrType() {} + +var _ xdrType = (*PathPaymentStrictSendOp)(nil) + +// ManageSellOfferOp is an XDR Struct defines as: +// +// struct ManageSellOfferOp +// { +// Asset selling; +// Asset buying; +// int64 amount; // amount being sold. if set to 0, delete the offer +// Price price; // price of thing being sold in terms of what you are buying +// +// // 0=create a new offer, otherwise edit an existing offer +// int64 offerID; +// }; +type ManageSellOfferOp struct { + Selling Asset + Buying Asset + Amount Int64 + Price Price + OfferId Int64 +} + +// EncodeTo encodes this value using the Encoder. +func (s *ManageSellOfferOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Selling.EncodeTo(e); err != nil { + return err + } + if err = s.Buying.EncodeTo(e); err != nil { + return err + } + if err = s.Amount.EncodeTo(e); err != nil { + return err + } + if err = s.Price.EncodeTo(e); err != nil { + return err + } + if err = s.OfferId.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*ManageSellOfferOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *ManageSellOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageSellOfferOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.Price.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Price: %w", err) + } + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s ManageSellOfferOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *ManageSellOfferOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*ManageSellOfferOp)(nil) + _ encoding.BinaryUnmarshaler = (*ManageSellOfferOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s ManageSellOfferOp) xdrType() {} + +var _ xdrType = (*ManageSellOfferOp)(nil) + +// ManageBuyOfferOp is an XDR Struct defines as: +// +// struct ManageBuyOfferOp +// { +// Asset selling; +// Asset buying; +// int64 buyAmount; // amount being bought. if set to 0, delete the offer +// Price price; // price of thing being bought in terms of what you are +// // selling +// +// // 0=create a new offer, otherwise edit an existing offer +// int64 offerID; +// }; +type ManageBuyOfferOp struct { + Selling Asset + Buying Asset + BuyAmount Int64 + Price Price + OfferId Int64 +} + +// EncodeTo encodes this value using the Encoder. +func (s *ManageBuyOfferOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Selling.EncodeTo(e); err != nil { + return err + } + if err = s.Buying.EncodeTo(e); err != nil { + return err + } + if err = s.BuyAmount.EncodeTo(e); err != nil { + return err + } + if err = s.Price.EncodeTo(e); err != nil { + return err + } + if err = s.OfferId.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*ManageBuyOfferOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *ManageBuyOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ManageBuyOfferOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.BuyAmount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.Price.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Price: %w", err) + } + nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s ManageBuyOfferOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *ManageBuyOfferOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*ManageBuyOfferOp)(nil) + _ encoding.BinaryUnmarshaler = (*ManageBuyOfferOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s ManageBuyOfferOp) xdrType() {} + +var _ xdrType = (*ManageBuyOfferOp)(nil) + +// CreatePassiveSellOfferOp is an XDR Struct defines as: +// +// struct CreatePassiveSellOfferOp // { -// CREATE_ACCOUNT = 0, -// PAYMENT = 1, -// PATH_PAYMENT_STRICT_RECEIVE = 2, -// MANAGE_SELL_OFFER = 3, -// CREATE_PASSIVE_SELL_OFFER = 4, -// SET_OPTIONS = 5, -// CHANGE_TRUST = 6, -// ALLOW_TRUST = 7, -// ACCOUNT_MERGE = 8, -// INFLATION = 9, -// MANAGE_DATA = 10, -// BUMP_SEQUENCE = 11, -// MANAGE_BUY_OFFER = 12, -// PATH_PAYMENT_STRICT_SEND = 13, -// CREATE_CLAIMABLE_BALANCE = 14, -// CLAIM_CLAIMABLE_BALANCE = 15, -// BEGIN_SPONSORING_FUTURE_RESERVES = 16, -// END_SPONSORING_FUTURE_RESERVES = 17, -// REVOKE_SPONSORSHIP = 18, -// CLAWBACK = 19, -// CLAWBACK_CLAIMABLE_BALANCE = 20, -// SET_TRUST_LINE_FLAGS = 21, -// LIQUIDITY_POOL_DEPOSIT = 22, -// LIQUIDITY_POOL_WITHDRAW = 23, -// INVOKE_HOST_FUNCTION = 24, -// EXTEND_FOOTPRINT_TTL = 25, -// RESTORE_FOOTPRINT = 26 +// Asset selling; // A +// Asset buying; // B +// int64 amount; // amount taker gets +// Price price; // cost of A in terms of B // }; -type OperationType int32 +type CreatePassiveSellOfferOp struct { + Selling Asset + Buying Asset + Amount Int64 + Price Price +} + +// EncodeTo encodes this value using the Encoder. +func (s *CreatePassiveSellOfferOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Selling.EncodeTo(e); err != nil { + return err + } + if err = s.Buying.EncodeTo(e); err != nil { + return err + } + if err = s.Amount.EncodeTo(e); err != nil { + return err + } + if err = s.Price.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*CreatePassiveSellOfferOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *CreatePassiveSellOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding CreatePassiveSellOfferOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Selling.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.Buying.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.Price.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Price: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s CreatePassiveSellOfferOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *CreatePassiveSellOfferOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*CreatePassiveSellOfferOp)(nil) + _ encoding.BinaryUnmarshaler = (*CreatePassiveSellOfferOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s CreatePassiveSellOfferOp) xdrType() {} + +var _ xdrType = (*CreatePassiveSellOfferOp)(nil) + +// SetOptionsOp is an XDR Struct defines as: +// +// struct SetOptionsOp +// { +// AccountID* inflationDest; // sets the inflation destination +// +// uint32* clearFlags; // which flags to clear +// uint32* setFlags; // which flags to set +// +// // account threshold manipulation +// uint32* masterWeight; // weight of the master account +// uint32* lowThreshold; +// uint32* medThreshold; +// uint32* highThreshold; +// +// string32* homeDomain; // sets the home domain +// +// // Add, update or remove a signer for the account +// // signer is deleted if the weight is 0 +// Signer* signer; +// }; +type SetOptionsOp struct { + InflationDest *AccountId + ClearFlags *Uint32 + SetFlags *Uint32 + MasterWeight *Uint32 + LowThreshold *Uint32 + MedThreshold *Uint32 + HighThreshold *Uint32 + HomeDomain *String32 + Signer *Signer +} + +// EncodeTo encodes this value using the Encoder. +func (s *SetOptionsOp) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeBool(s.InflationDest != nil); err != nil { + return err + } + if s.InflationDest != nil { + if err = (*s.InflationDest).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.ClearFlags != nil); err != nil { + return err + } + if s.ClearFlags != nil { + if err = (*s.ClearFlags).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.SetFlags != nil); err != nil { + return err + } + if s.SetFlags != nil { + if err = (*s.SetFlags).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.MasterWeight != nil); err != nil { + return err + } + if s.MasterWeight != nil { + if err = (*s.MasterWeight).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.LowThreshold != nil); err != nil { + return err + } + if s.LowThreshold != nil { + if err = (*s.LowThreshold).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.MedThreshold != nil); err != nil { + return err + } + if s.MedThreshold != nil { + if err = (*s.MedThreshold).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.HighThreshold != nil); err != nil { + return err + } + if s.HighThreshold != nil { + if err = (*s.HighThreshold).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.HomeDomain != nil); err != nil { + return err + } + if s.HomeDomain != nil { + if err = (*s.HomeDomain).EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeBool(s.Signer != nil); err != nil { + return err + } + if s.Signer != nil { + if err = (*s.Signer).EncodeTo(e); err != nil { + return err + } + } + return nil +} + +var _ decoderFrom = (*SetOptionsOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *SetOptionsOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SetOptionsOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + var b bool + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AccountId: %w", err) + } + s.InflationDest = nil + if b { + s.InflationDest = new(AccountId) + nTmp, err = s.InflationDest.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AccountId: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.ClearFlags = nil + if b { + s.ClearFlags = new(Uint32) + nTmp, err = s.ClearFlags.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.SetFlags = nil + if b { + s.SetFlags = new(Uint32) + nTmp, err = s.SetFlags.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.MasterWeight = nil + if b { + s.MasterWeight = new(Uint32) + nTmp, err = s.MasterWeight.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.LowThreshold = nil + if b { + s.LowThreshold = new(Uint32) + nTmp, err = s.LowThreshold.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.MedThreshold = nil + if b { + s.MedThreshold = new(Uint32) + nTmp, err = s.MedThreshold.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.HighThreshold = nil + if b { + s.HighThreshold = new(Uint32) + nTmp, err = s.HighThreshold.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding String32: %w", err) + } + s.HomeDomain = nil + if b { + s.HomeDomain = new(String32) + nTmp, err = s.HomeDomain.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding String32: %w", err) + } + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Signer: %w", err) + } + s.Signer = nil + if b { + s.Signer = new(Signer) + nTmp, err = s.Signer.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Signer: %w", err) + } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s SetOptionsOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SetOptionsOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SetOptionsOp)(nil) + _ encoding.BinaryUnmarshaler = (*SetOptionsOp)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s SetOptionsOp) xdrType() {} + +var _ xdrType = (*SetOptionsOp)(nil) + +// ChangeTrustAsset is an XDR Union defines as: +// +// union ChangeTrustAsset switch (AssetType type) +// { +// case ASSET_TYPE_NATIVE: // Not credit +// void; +// +// case ASSET_TYPE_CREDIT_ALPHANUM4: +// AlphaNum4 alphaNum4; +// +// case ASSET_TYPE_CREDIT_ALPHANUM12: +// AlphaNum12 alphaNum12; +// +// case ASSET_TYPE_POOL_SHARE: +// LiquidityPoolParameters liquidityPool; +// +// // add other asset types here in the future +// }; +type ChangeTrustAsset struct { + Type AssetType + AlphaNum4 *AlphaNum4 + AlphaNum12 *AlphaNum12 + LiquidityPool *LiquidityPoolParameters +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u ChangeTrustAsset) SwitchFieldName() string { + return "Type" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of ChangeTrustAsset +func (u ChangeTrustAsset) ArmForSwitch(sw int32) (string, bool) { + switch AssetType(sw) { + case AssetTypeAssetTypeNative: + return "", true + case AssetTypeAssetTypeCreditAlphanum4: + return "AlphaNum4", true + case AssetTypeAssetTypeCreditAlphanum12: + return "AlphaNum12", true + case AssetTypeAssetTypePoolShare: + return "LiquidityPool", true + } + return "-", false +} + +// NewChangeTrustAsset creates a new ChangeTrustAsset. +func NewChangeTrustAsset(aType AssetType, value interface{}) (result ChangeTrustAsset, err error) { + result.Type = aType + switch AssetType(aType) { + case AssetTypeAssetTypeNative: + // void + case AssetTypeAssetTypeCreditAlphanum4: + tv, ok := value.(AlphaNum4) + if !ok { + err = errors.New("invalid value, must be AlphaNum4") + return + } + result.AlphaNum4 = &tv + case AssetTypeAssetTypeCreditAlphanum12: + tv, ok := value.(AlphaNum12) + if !ok { + err = errors.New("invalid value, must be AlphaNum12") + return + } + result.AlphaNum12 = &tv + case AssetTypeAssetTypePoolShare: + tv, ok := value.(LiquidityPoolParameters) + if !ok { + err = errors.New("invalid value, must be LiquidityPoolParameters") + return + } + result.LiquidityPool = &tv + } + return +} + +// MustAlphaNum4 retrieves the AlphaNum4 value from the union, +// panicing if the value is not set. +func (u ChangeTrustAsset) MustAlphaNum4() AlphaNum4 { + val, ok := u.GetAlphaNum4() + + if !ok { + panic("arm AlphaNum4 is not set") + } + + return val +} + +// GetAlphaNum4 retrieves the AlphaNum4 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u ChangeTrustAsset) GetAlphaNum4() (result AlphaNum4, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -const ( - OperationTypeCreateAccount OperationType = 0 - OperationTypePayment OperationType = 1 - OperationTypePathPaymentStrictReceive OperationType = 2 - OperationTypeManageSellOffer OperationType = 3 - OperationTypeCreatePassiveSellOffer OperationType = 4 - OperationTypeSetOptions OperationType = 5 - OperationTypeChangeTrust OperationType = 6 - OperationTypeAllowTrust OperationType = 7 - OperationTypeAccountMerge OperationType = 8 - OperationTypeInflation OperationType = 9 - OperationTypeManageData OperationType = 10 - OperationTypeBumpSequence OperationType = 11 - OperationTypeManageBuyOffer OperationType = 12 - OperationTypePathPaymentStrictSend OperationType = 13 - OperationTypeCreateClaimableBalance OperationType = 14 - OperationTypeClaimClaimableBalance OperationType = 15 - OperationTypeBeginSponsoringFutureReserves OperationType = 16 - OperationTypeEndSponsoringFutureReserves OperationType = 17 - OperationTypeRevokeSponsorship OperationType = 18 - OperationTypeClawback OperationType = 19 - OperationTypeClawbackClaimableBalance OperationType = 20 - OperationTypeSetTrustLineFlags OperationType = 21 - OperationTypeLiquidityPoolDeposit OperationType = 22 - OperationTypeLiquidityPoolWithdraw OperationType = 23 - OperationTypeInvokeHostFunction OperationType = 24 - OperationTypeExtendFootprintTtl OperationType = 25 - OperationTypeRestoreFootprint OperationType = 26 -) + if armName == "AlphaNum4" { + result = *u.AlphaNum4 + ok = true + } -var operationTypeMap = map[int32]string{ - 0: "OperationTypeCreateAccount", - 1: "OperationTypePayment", - 2: "OperationTypePathPaymentStrictReceive", - 3: "OperationTypeManageSellOffer", - 4: "OperationTypeCreatePassiveSellOffer", - 5: "OperationTypeSetOptions", - 6: "OperationTypeChangeTrust", - 7: "OperationTypeAllowTrust", - 8: "OperationTypeAccountMerge", - 9: "OperationTypeInflation", - 10: "OperationTypeManageData", - 11: "OperationTypeBumpSequence", - 12: "OperationTypeManageBuyOffer", - 13: "OperationTypePathPaymentStrictSend", - 14: "OperationTypeCreateClaimableBalance", - 15: "OperationTypeClaimClaimableBalance", - 16: "OperationTypeBeginSponsoringFutureReserves", - 17: "OperationTypeEndSponsoringFutureReserves", - 18: "OperationTypeRevokeSponsorship", - 19: "OperationTypeClawback", - 20: "OperationTypeClawbackClaimableBalance", - 21: "OperationTypeSetTrustLineFlags", - 22: "OperationTypeLiquidityPoolDeposit", - 23: "OperationTypeLiquidityPoolWithdraw", - 24: "OperationTypeInvokeHostFunction", - 25: "OperationTypeExtendFootprintTtl", - 26: "OperationTypeRestoreFootprint", + return } -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for OperationType -func (e OperationType) ValidEnum(v int32) bool { - _, ok := operationTypeMap[v] - return ok +// MustAlphaNum12 retrieves the AlphaNum12 value from the union, +// panicing if the value is not set. +func (u ChangeTrustAsset) MustAlphaNum12() AlphaNum12 { + val, ok := u.GetAlphaNum12() + + if !ok { + panic("arm AlphaNum12 is not set") + } + + return val } -// String returns the name of `e` -func (e OperationType) String() string { - name, _ := operationTypeMap[int32(e)] - return name +// GetAlphaNum12 retrieves the AlphaNum12 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u ChangeTrustAsset) GetAlphaNum12() (result AlphaNum12, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "AlphaNum12" { + result = *u.AlphaNum12 + ok = true + } + + return +} + +// MustLiquidityPool retrieves the LiquidityPool value from the union, +// panicing if the value is not set. +func (u ChangeTrustAsset) MustLiquidityPool() LiquidityPoolParameters { + val, ok := u.GetLiquidityPool() + + if !ok { + panic("arm LiquidityPool is not set") + } + + return val +} + +// GetLiquidityPool retrieves the LiquidityPool value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u ChangeTrustAsset) GetLiquidityPool() (result LiquidityPoolParameters, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "LiquidityPool" { + result = *u.LiquidityPool + ok = true + } + + return } // EncodeTo encodes this value using the Encoder. -func (e OperationType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := operationTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid OperationType enum value", e) +func (u ChangeTrustAsset) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + switch AssetType(u.Type) { + case AssetTypeAssetTypeNative: + // Void + return nil + case AssetTypeAssetTypeCreditAlphanum4: + if err = (*u.AlphaNum4).EncodeTo(e); err != nil { + return err + } + return nil + case AssetTypeAssetTypeCreditAlphanum12: + if err = (*u.AlphaNum12).EncodeTo(e); err != nil { + return err + } + return nil + case AssetTypeAssetTypePoolShare: + if err = (*u.LiquidityPool).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (AssetType) switch value '%d' is not valid for union ChangeTrustAsset", u.Type) } -var _ decoderFrom = (*OperationType)(nil) +var _ decoderFrom = (*ChangeTrustAsset)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *OperationType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *ChangeTrustAsset) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding OperationType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ChangeTrustAsset: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationType: %w", err) + return n, fmt.Errorf("decoding AssetType: %w", err) } - if _, ok := operationTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid OperationType enum value", v) + switch AssetType(u.Type) { + case AssetTypeAssetTypeNative: + // Void + return n, nil + case AssetTypeAssetTypeCreditAlphanum4: + u.AlphaNum4 = new(AlphaNum4) + nTmp, err = (*u.AlphaNum4).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AlphaNum4: %w", err) + } + return n, nil + case AssetTypeAssetTypeCreditAlphanum12: + u.AlphaNum12 = new(AlphaNum12) + nTmp, err = (*u.AlphaNum12).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AlphaNum12: %w", err) + } + return n, nil + case AssetTypeAssetTypePoolShare: + u.LiquidityPool = new(LiquidityPoolParameters) + nTmp, err = (*u.LiquidityPool).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LiquidityPoolParameters: %w", err) + } + return n, nil } - *e = OperationType(v) - return n, nil + return n, fmt.Errorf("union ChangeTrustAsset has invalid Type (AssetType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s OperationType) MarshalBinary() ([]byte, error) { +func (s ChangeTrustAsset) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -24892,7 +27432,7 @@ func (s OperationType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *OperationType) UnmarshalBinary(inp []byte) error { +func (s *ChangeTrustAsset) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -24902,55 +27442,57 @@ func (s *OperationType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*OperationType)(nil) - _ encoding.BinaryUnmarshaler = (*OperationType)(nil) + _ encoding.BinaryMarshaler = (*ChangeTrustAsset)(nil) + _ encoding.BinaryUnmarshaler = (*ChangeTrustAsset)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s OperationType) xdrType() {} +func (s ChangeTrustAsset) xdrType() {} -var _ xdrType = (*OperationType)(nil) +var _ xdrType = (*ChangeTrustAsset)(nil) -// CreateAccountOp is an XDR Struct defines as: +// ChangeTrustOp is an XDR Struct defines as: // -// struct CreateAccountOp +// struct ChangeTrustOp // { -// AccountID destination; // account to create -// int64 startingBalance; // amount they end up with +// ChangeTrustAsset line; +// +// // if limit is set to 0, deletes the trust line +// int64 limit; // }; -type CreateAccountOp struct { - Destination AccountId - StartingBalance Int64 +type ChangeTrustOp struct { + Line ChangeTrustAsset + Limit Int64 } // EncodeTo encodes this value using the Encoder. -func (s *CreateAccountOp) EncodeTo(e *xdr.Encoder) error { +func (s *ChangeTrustOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Destination.EncodeTo(e); err != nil { + if err = s.Line.EncodeTo(e); err != nil { return err } - if err = s.StartingBalance.EncodeTo(e); err != nil { + if err = s.Limit.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*CreateAccountOp)(nil) +var _ decoderFrom = (*ChangeTrustOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreateAccountOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ChangeTrustOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding CreateAccountOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ChangeTrustOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Destination.DecodeFrom(d, maxDepth) + nTmp, err = s.Line.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) + return n, fmt.Errorf("decoding ChangeTrustAsset: %w", err) } - nTmp, err = s.StartingBalance.DecodeFrom(d, maxDepth) + nTmp, err = s.Limit.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Int64: %w", err) @@ -24959,7 +27501,7 @@ func (s *CreateAccountOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s CreateAccountOp) MarshalBinary() ([]byte, error) { +func (s ChangeTrustOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -24967,7 +27509,7 @@ func (s CreateAccountOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *CreateAccountOp) UnmarshalBinary(inp []byte) error { +func (s *ChangeTrustOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -24977,74 +27519,76 @@ func (s *CreateAccountOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*CreateAccountOp)(nil) - _ encoding.BinaryUnmarshaler = (*CreateAccountOp)(nil) + _ encoding.BinaryMarshaler = (*ChangeTrustOp)(nil) + _ encoding.BinaryUnmarshaler = (*ChangeTrustOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s CreateAccountOp) xdrType() {} +func (s ChangeTrustOp) xdrType() {} -var _ xdrType = (*CreateAccountOp)(nil) +var _ xdrType = (*ChangeTrustOp)(nil) -// PaymentOp is an XDR Struct defines as: +// AllowTrustOp is an XDR Struct defines as: // -// struct PaymentOp +// struct AllowTrustOp // { -// MuxedAccount destination; // recipient of the payment -// Asset asset; // what they end up with -// int64 amount; // amount they end up with +// AccountID trustor; +// AssetCode asset; +// +// // One of 0, AUTHORIZED_FLAG, or AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG +// uint32 authorize; // }; -type PaymentOp struct { - Destination MuxedAccount - Asset Asset - Amount Int64 +type AllowTrustOp struct { + Trustor AccountId + Asset AssetCode + Authorize Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *PaymentOp) EncodeTo(e *xdr.Encoder) error { +func (s *AllowTrustOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Destination.EncodeTo(e); err != nil { + if err = s.Trustor.EncodeTo(e); err != nil { return err } if err = s.Asset.EncodeTo(e); err != nil { return err } - if err = s.Amount.EncodeTo(e); err != nil { + if err = s.Authorize.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*PaymentOp)(nil) +var _ decoderFrom = (*AllowTrustOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PaymentOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *AllowTrustOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding PaymentOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding AllowTrustOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Destination.DecodeFrom(d, maxDepth) + nTmp, err = s.Trustor.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %w", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) + return n, fmt.Errorf("decoding AssetCode: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d, maxDepth) + nTmp, err = s.Authorize.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PaymentOp) MarshalBinary() ([]byte, error) { +func (s AllowTrustOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25052,7 +27596,7 @@ func (s PaymentOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PaymentOp) UnmarshalBinary(inp []byte) error { +func (s *AllowTrustOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -25062,131 +27606,79 @@ func (s *PaymentOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PaymentOp)(nil) - _ encoding.BinaryUnmarshaler = (*PaymentOp)(nil) + _ encoding.BinaryMarshaler = (*AllowTrustOp)(nil) + _ encoding.BinaryUnmarshaler = (*AllowTrustOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PaymentOp) xdrType() {} +func (s AllowTrustOp) xdrType() {} -var _ xdrType = (*PaymentOp)(nil) +var _ xdrType = (*AllowTrustOp)(nil) -// PathPaymentStrictReceiveOp is an XDR Struct defines as: +// ManageDataOp is an XDR Struct defines as: // -// struct PathPaymentStrictReceiveOp +// struct ManageDataOp // { -// Asset sendAsset; // asset we pay with -// int64 sendMax; // the maximum amount of sendAsset to -// // send (excluding fees). -// // The operation will fail if can't be met -// -// MuxedAccount destination; // recipient of the payment -// Asset destAsset; // what they end up with -// int64 destAmount; // amount they end up with -// -// Asset path<5>; // additional hops it must go through to get there +// string64 dataName; +// DataValue* dataValue; // set to null to clear // }; -type PathPaymentStrictReceiveOp struct { - SendAsset Asset - SendMax Int64 - Destination MuxedAccount - DestAsset Asset - DestAmount Int64 - Path []Asset `xdrmaxsize:"5"` +type ManageDataOp struct { + DataName String64 + DataValue *DataValue } // EncodeTo encodes this value using the Encoder. -func (s *PathPaymentStrictReceiveOp) EncodeTo(e *xdr.Encoder) error { +func (s *ManageDataOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.SendAsset.EncodeTo(e); err != nil { - return err - } - if err = s.SendMax.EncodeTo(e); err != nil { - return err - } - if err = s.Destination.EncodeTo(e); err != nil { - return err - } - if err = s.DestAsset.EncodeTo(e); err != nil { - return err - } - if err = s.DestAmount.EncodeTo(e); err != nil { + if err = s.DataName.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Path))); err != nil { + if _, err = e.EncodeBool(s.DataValue != nil); err != nil { return err } - for i := 0; i < len(s.Path); i++ { - if err = s.Path[i].EncodeTo(e); err != nil { + if s.DataValue != nil { + if err = (*s.DataValue).EncodeTo(e); err != nil { return err } } return nil } -var _ decoderFrom = (*PathPaymentStrictReceiveOp)(nil) +var _ decoderFrom = (*ManageDataOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PathPaymentStrictReceiveOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ManageDataOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding PathPaymentStrictReceiveOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ManageDataOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SendAsset.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.SendMax.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.Destination.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %w", err) - } - nTmp, err = s.DestAsset.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.DestAmount.DecodeFrom(d, maxDepth) + nTmp, err = s.DataName.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + return n, fmt.Errorf("decoding String64: %w", err) } - var l uint32 - l, nTmp, err = d.DecodeUint() + var b bool + b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - if l > 5 { - return n, fmt.Errorf("decoding Asset: data size (%d) exceeds size limit (5)", l) + return n, fmt.Errorf("decoding DataValue: %w", err) } - s.Path = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Path = make([]Asset, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } + s.DataValue = nil + if b { + s.DataValue = new(DataValue) + nTmp, err = s.DataValue.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding DataValue: %w", err) } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PathPaymentStrictReceiveOp) MarshalBinary() ([]byte, error) { +func (s ManageDataOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25194,7 +27686,7 @@ func (s PathPaymentStrictReceiveOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PathPaymentStrictReceiveOp) UnmarshalBinary(inp []byte) error { +func (s *ManageDataOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -25204,131 +27696,54 @@ func (s *PathPaymentStrictReceiveOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PathPaymentStrictReceiveOp)(nil) - _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveOp)(nil) + _ encoding.BinaryMarshaler = (*ManageDataOp)(nil) + _ encoding.BinaryUnmarshaler = (*ManageDataOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PathPaymentStrictReceiveOp) xdrType() {} +func (s ManageDataOp) xdrType() {} -var _ xdrType = (*PathPaymentStrictReceiveOp)(nil) +var _ xdrType = (*ManageDataOp)(nil) -// PathPaymentStrictSendOp is an XDR Struct defines as: +// BumpSequenceOp is an XDR Struct defines as: // -// struct PathPaymentStrictSendOp +// struct BumpSequenceOp // { -// Asset sendAsset; // asset we pay with -// int64 sendAmount; // amount of sendAsset to send (excluding fees) -// -// MuxedAccount destination; // recipient of the payment -// Asset destAsset; // what they end up with -// int64 destMin; // the minimum amount of dest asset to -// // be received -// // The operation will fail if it can't be met -// -// Asset path<5>; // additional hops it must go through to get there +// SequenceNumber bumpTo; // }; -type PathPaymentStrictSendOp struct { - SendAsset Asset - SendAmount Int64 - Destination MuxedAccount - DestAsset Asset - DestMin Int64 - Path []Asset `xdrmaxsize:"5"` +type BumpSequenceOp struct { + BumpTo SequenceNumber } // EncodeTo encodes this value using the Encoder. -func (s *PathPaymentStrictSendOp) EncodeTo(e *xdr.Encoder) error { +func (s *BumpSequenceOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.SendAsset.EncodeTo(e); err != nil { - return err - } - if err = s.SendAmount.EncodeTo(e); err != nil { - return err - } - if err = s.Destination.EncodeTo(e); err != nil { - return err - } - if err = s.DestAsset.EncodeTo(e); err != nil { - return err - } - if err = s.DestMin.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.Path))); err != nil { + if err = s.BumpTo.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Path); i++ { - if err = s.Path[i].EncodeTo(e); err != nil { - return err - } - } - return nil -} - -var _ decoderFrom = (*PathPaymentStrictSendOp)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *PathPaymentStrictSendOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding PathPaymentStrictSendOp: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.SendAsset.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.SendAmount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.Destination.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %w", err) - } - nTmp, err = s.DestAsset.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.DestMin.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() + return nil +} + +var _ decoderFrom = (*BumpSequenceOp)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *BumpSequenceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BumpSequenceOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.BumpTo.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - if l > 5 { - return n, fmt.Errorf("decoding Asset: data size (%d) exceeds size limit (5)", l) - } - s.Path = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding Asset: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Path = make([]Asset, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Path[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - } + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PathPaymentStrictSendOp) MarshalBinary() ([]byte, error) { +func (s BumpSequenceOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25336,7 +27751,7 @@ func (s PathPaymentStrictSendOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PathPaymentStrictSendOp) UnmarshalBinary(inp []byte) error { +func (s *BumpSequenceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -25346,72 +27761,60 @@ func (s *PathPaymentStrictSendOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PathPaymentStrictSendOp)(nil) - _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendOp)(nil) + _ encoding.BinaryMarshaler = (*BumpSequenceOp)(nil) + _ encoding.BinaryUnmarshaler = (*BumpSequenceOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PathPaymentStrictSendOp) xdrType() {} +func (s BumpSequenceOp) xdrType() {} -var _ xdrType = (*PathPaymentStrictSendOp)(nil) +var _ xdrType = (*BumpSequenceOp)(nil) -// ManageSellOfferOp is an XDR Struct defines as: +// CreateClaimableBalanceOp is an XDR Struct defines as: // -// struct ManageSellOfferOp +// struct CreateClaimableBalanceOp // { -// Asset selling; -// Asset buying; -// int64 amount; // amount being sold. if set to 0, delete the offer -// Price price; // price of thing being sold in terms of what you are buying -// -// // 0=create a new offer, otherwise edit an existing offer -// int64 offerID; +// Asset asset; +// int64 amount; +// Claimant claimants<10>; // }; -type ManageSellOfferOp struct { - Selling Asset - Buying Asset - Amount Int64 - Price Price - OfferId Int64 +type CreateClaimableBalanceOp struct { + Asset Asset + Amount Int64 + Claimants []Claimant `xdrmaxsize:"10"` } // EncodeTo encodes this value using the Encoder. -func (s *ManageSellOfferOp) EncodeTo(e *xdr.Encoder) error { +func (s *CreateClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Selling.EncodeTo(e); err != nil { - return err - } - if err = s.Buying.EncodeTo(e); err != nil { + if err = s.Asset.EncodeTo(e); err != nil { return err } if err = s.Amount.EncodeTo(e); err != nil { return err } - if err = s.Price.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Claimants))); err != nil { return err } - if err = s.OfferId.EncodeTo(e); err != nil { - return err + for i := 0; i < len(s.Claimants); i++ { + if err = s.Claimants[i].EncodeTo(e); err != nil { + return err + } } return nil } -var _ decoderFrom = (*ManageSellOfferOp)(nil) +var _ decoderFrom = (*CreateClaimableBalanceOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ManageSellOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *CreateClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ManageSellOfferOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding CreateClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Selling.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.Buying.DecodeFrom(d, maxDepth) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Asset: %w", err) @@ -25421,21 +27824,34 @@ func (s *ManageSellOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, erro if err != nil { return n, fmt.Errorf("decoding Int64: %w", err) } - nTmp, err = s.Price.DecodeFrom(d, maxDepth) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %w", err) + return n, fmt.Errorf("decoding Claimant: %w", err) } - nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + if l > 10 { + return n, fmt.Errorf("decoding Claimant: data size (%d) exceeds size limit (10)", l) + } + s.Claimants = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding Claimant: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Claimants = make([]Claimant, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Claimant: %w", err) + } + } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ManageSellOfferOp) MarshalBinary() ([]byte, error) { +func (s CreateClaimableBalanceOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25443,7 +27859,7 @@ func (s ManageSellOfferOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ManageSellOfferOp) UnmarshalBinary(inp []byte) error { +func (s *CreateClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -25453,97 +27869,54 @@ func (s *ManageSellOfferOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ManageSellOfferOp)(nil) - _ encoding.BinaryUnmarshaler = (*ManageSellOfferOp)(nil) + _ encoding.BinaryMarshaler = (*CreateClaimableBalanceOp)(nil) + _ encoding.BinaryUnmarshaler = (*CreateClaimableBalanceOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ManageSellOfferOp) xdrType() {} +func (s CreateClaimableBalanceOp) xdrType() {} -var _ xdrType = (*ManageSellOfferOp)(nil) +var _ xdrType = (*CreateClaimableBalanceOp)(nil) -// ManageBuyOfferOp is an XDR Struct defines as: +// ClaimClaimableBalanceOp is an XDR Struct defines as: // -// struct ManageBuyOfferOp +// struct ClaimClaimableBalanceOp // { -// Asset selling; -// Asset buying; -// int64 buyAmount; // amount being bought. if set to 0, delete the offer -// Price price; // price of thing being bought in terms of what you are -// // selling -// -// // 0=create a new offer, otherwise edit an existing offer -// int64 offerID; +// ClaimableBalanceID balanceID; // }; -type ManageBuyOfferOp struct { - Selling Asset - Buying Asset - BuyAmount Int64 - Price Price - OfferId Int64 +type ClaimClaimableBalanceOp struct { + BalanceId ClaimableBalanceId } // EncodeTo encodes this value using the Encoder. -func (s *ManageBuyOfferOp) EncodeTo(e *xdr.Encoder) error { +func (s *ClaimClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Selling.EncodeTo(e); err != nil { - return err - } - if err = s.Buying.EncodeTo(e); err != nil { - return err - } - if err = s.BuyAmount.EncodeTo(e); err != nil { - return err - } - if err = s.Price.EncodeTo(e); err != nil { - return err - } - if err = s.OfferId.EncodeTo(e); err != nil { + if err = s.BalanceId.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*ManageBuyOfferOp)(nil) +var _ decoderFrom = (*ClaimClaimableBalanceOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ManageBuyOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ClaimClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ManageBuyOfferOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ClaimClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Selling.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.Buying.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.BuyAmount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.Price.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Price: %w", err) - } - nTmp, err = s.OfferId.DecodeFrom(d, maxDepth) + nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ManageBuyOfferOp) MarshalBinary() ([]byte, error) { +func (s ClaimClaimableBalanceOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25551,7 +27924,7 @@ func (s ManageBuyOfferOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ManageBuyOfferOp) UnmarshalBinary(inp []byte) error { +func (s *ClaimClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -25561,84 +27934,54 @@ func (s *ManageBuyOfferOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ManageBuyOfferOp)(nil) - _ encoding.BinaryUnmarshaler = (*ManageBuyOfferOp)(nil) + _ encoding.BinaryMarshaler = (*ClaimClaimableBalanceOp)(nil) + _ encoding.BinaryUnmarshaler = (*ClaimClaimableBalanceOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ManageBuyOfferOp) xdrType() {} +func (s ClaimClaimableBalanceOp) xdrType() {} -var _ xdrType = (*ManageBuyOfferOp)(nil) +var _ xdrType = (*ClaimClaimableBalanceOp)(nil) -// CreatePassiveSellOfferOp is an XDR Struct defines as: +// BeginSponsoringFutureReservesOp is an XDR Struct defines as: // -// struct CreatePassiveSellOfferOp +// struct BeginSponsoringFutureReservesOp // { -// Asset selling; // A -// Asset buying; // B -// int64 amount; // amount taker gets -// Price price; // cost of A in terms of B +// AccountID sponsoredID; // }; -type CreatePassiveSellOfferOp struct { - Selling Asset - Buying Asset - Amount Int64 - Price Price +type BeginSponsoringFutureReservesOp struct { + SponsoredId AccountId } // EncodeTo encodes this value using the Encoder. -func (s *CreatePassiveSellOfferOp) EncodeTo(e *xdr.Encoder) error { +func (s *BeginSponsoringFutureReservesOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Selling.EncodeTo(e); err != nil { - return err - } - if err = s.Buying.EncodeTo(e); err != nil { - return err - } - if err = s.Amount.EncodeTo(e); err != nil { - return err - } - if err = s.Price.EncodeTo(e); err != nil { + if err = s.SponsoredId.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*CreatePassiveSellOfferOp)(nil) +var _ decoderFrom = (*BeginSponsoringFutureReservesOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreatePassiveSellOfferOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *BeginSponsoringFutureReservesOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding CreatePassiveSellOfferOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding BeginSponsoringFutureReservesOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Selling.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.Buying.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.Amount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.Price.DecodeFrom(d, maxDepth) + nTmp, err = s.SponsoredId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Price: %w", err) + return n, fmt.Errorf("decoding AccountId: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s CreatePassiveSellOfferOp) MarshalBinary() ([]byte, error) { +func (s BeginSponsoringFutureReservesOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25646,7 +27989,7 @@ func (s CreatePassiveSellOfferOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *CreatePassiveSellOfferOp) UnmarshalBinary(inp []byte) error { +func (s *BeginSponsoringFutureReservesOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -25656,268 +27999,152 @@ func (s *CreatePassiveSellOfferOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*CreatePassiveSellOfferOp)(nil) - _ encoding.BinaryUnmarshaler = (*CreatePassiveSellOfferOp)(nil) + _ encoding.BinaryMarshaler = (*BeginSponsoringFutureReservesOp)(nil) + _ encoding.BinaryUnmarshaler = (*BeginSponsoringFutureReservesOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s CreatePassiveSellOfferOp) xdrType() {} +func (s BeginSponsoringFutureReservesOp) xdrType() {} -var _ xdrType = (*CreatePassiveSellOfferOp)(nil) +var _ xdrType = (*BeginSponsoringFutureReservesOp)(nil) -// SetOptionsOp is an XDR Struct defines as: +// RevokeSponsorshipType is an XDR Enum defines as: // -// struct SetOptionsOp +// enum RevokeSponsorshipType // { -// AccountID* inflationDest; // sets the inflation destination -// -// uint32* clearFlags; // which flags to clear -// uint32* setFlags; // which flags to set -// -// // account threshold manipulation -// uint32* masterWeight; // weight of the master account -// uint32* lowThreshold; -// uint32* medThreshold; -// uint32* highThreshold; -// -// string32* homeDomain; // sets the home domain -// -// // Add, update or remove a signer for the account -// // signer is deleted if the weight is 0 -// Signer* signer; +// REVOKE_SPONSORSHIP_LEDGER_ENTRY = 0, +// REVOKE_SPONSORSHIP_SIGNER = 1 // }; -type SetOptionsOp struct { - InflationDest *AccountId - ClearFlags *Uint32 - SetFlags *Uint32 - MasterWeight *Uint32 - LowThreshold *Uint32 - MedThreshold *Uint32 - HighThreshold *Uint32 - HomeDomain *String32 - Signer *Signer +type RevokeSponsorshipType int32 + +const ( + RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry RevokeSponsorshipType = 0 + RevokeSponsorshipTypeRevokeSponsorshipSigner RevokeSponsorshipType = 1 +) + +var revokeSponsorshipTypeMap = map[int32]string{ + 0: "RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry", + 1: "RevokeSponsorshipTypeRevokeSponsorshipSigner", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for RevokeSponsorshipType +func (e RevokeSponsorshipType) ValidEnum(v int32) bool { + _, ok := revokeSponsorshipTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e RevokeSponsorshipType) String() string { + name, _ := revokeSponsorshipTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *SetOptionsOp) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeBool(s.InflationDest != nil); err != nil { - return err - } - if s.InflationDest != nil { - if err = (*s.InflationDest).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.ClearFlags != nil); err != nil { - return err - } - if s.ClearFlags != nil { - if err = (*s.ClearFlags).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.SetFlags != nil); err != nil { - return err - } - if s.SetFlags != nil { - if err = (*s.SetFlags).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.MasterWeight != nil); err != nil { - return err - } - if s.MasterWeight != nil { - if err = (*s.MasterWeight).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.LowThreshold != nil); err != nil { - return err - } - if s.LowThreshold != nil { - if err = (*s.LowThreshold).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.MedThreshold != nil); err != nil { - return err - } - if s.MedThreshold != nil { - if err = (*s.MedThreshold).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.HighThreshold != nil); err != nil { - return err - } - if s.HighThreshold != nil { - if err = (*s.HighThreshold).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.HomeDomain != nil); err != nil { - return err - } - if s.HomeDomain != nil { - if err = (*s.HomeDomain).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.Signer != nil); err != nil { - return err - } - if s.Signer != nil { - if err = (*s.Signer).EncodeTo(e); err != nil { - return err - } +func (e RevokeSponsorshipType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := revokeSponsorshipTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid RevokeSponsorshipType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*SetOptionsOp)(nil) +var _ decoderFrom = (*RevokeSponsorshipType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SetOptionsOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *RevokeSponsorshipType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SetOptionsOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding RevokeSponsorshipType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - var b bool - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) - } - s.InflationDest = nil - if b { - s.InflationDest = new(AccountId) - nTmp, err = s.InflationDest.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) - } - } - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - s.ClearFlags = nil - if b { - s.ClearFlags = new(Uint32) - nTmp, err = s.ClearFlags.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - } - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - s.SetFlags = nil - if b { - s.SetFlags = new(Uint32) - nTmp, err = s.SetFlags.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - } - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - s.MasterWeight = nil - if b { - s.MasterWeight = new(Uint32) - nTmp, err = s.MasterWeight.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - } - b, nTmp, err = d.DecodeBool() - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - s.LowThreshold = nil - if b { - s.LowThreshold = new(Uint32) - nTmp, err = s.LowThreshold.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } + return n, fmt.Errorf("decoding RevokeSponsorshipType: %w", err) } - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + if _, ok := revokeSponsorshipTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid RevokeSponsorshipType enum value", v) } - s.MedThreshold = nil - if b { - s.MedThreshold = new(Uint32) - nTmp, err = s.MedThreshold.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } + *e = RevokeSponsorshipType(v) + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s RevokeSponsorshipType) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *RevokeSponsorshipType) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*RevokeSponsorshipType)(nil) + _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipType)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s RevokeSponsorshipType) xdrType() {} + +var _ xdrType = (*RevokeSponsorshipType)(nil) + +// RevokeSponsorshipOpSigner is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID accountID; +// SignerKey signerKey; +// } +type RevokeSponsorshipOpSigner struct { + AccountId AccountId + SignerKey SignerKey +} + +// EncodeTo encodes this value using the Encoder. +func (s *RevokeSponsorshipOpSigner) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.AccountId.EncodeTo(e); err != nil { + return err } - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + if err = s.SignerKey.EncodeTo(e); err != nil { + return err } - s.HighThreshold = nil - if b { - s.HighThreshold = new(Uint32) - nTmp, err = s.HighThreshold.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } + return nil +} + +var _ decoderFrom = (*RevokeSponsorshipOpSigner)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *RevokeSponsorshipOpSigner) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding RevokeSponsorshipOpSigner: %w", ErrMaxDecodingDepthReached) } - b, nTmp, err = d.DecodeBool() + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding String32: %w", err) - } - s.HomeDomain = nil - if b { - s.HomeDomain = new(String32) - nTmp, err = s.HomeDomain.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding String32: %w", err) - } + return n, fmt.Errorf("decoding AccountId: %w", err) } - b, nTmp, err = d.DecodeBool() + nTmp, err = s.SignerKey.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signer: %w", err) - } - s.Signer = nil - if b { - s.Signer = new(Signer) - nTmp, err = s.Signer.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Signer: %w", err) - } + return n, fmt.Errorf("decoding SignerKey: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SetOptionsOp) MarshalBinary() ([]byte, error) { +func (s RevokeSponsorshipOpSigner) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25925,7 +28152,7 @@ func (s SetOptionsOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SetOptionsOp) UnmarshalBinary(inp []byte) error { +func (s *RevokeSponsorshipOpSigner) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -25935,162 +28162,118 @@ func (s *SetOptionsOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SetOptionsOp)(nil) - _ encoding.BinaryUnmarshaler = (*SetOptionsOp)(nil) + _ encoding.BinaryMarshaler = (*RevokeSponsorshipOpSigner)(nil) + _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipOpSigner)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SetOptionsOp) xdrType() {} +func (s RevokeSponsorshipOpSigner) xdrType() {} -var _ xdrType = (*SetOptionsOp)(nil) +var _ xdrType = (*RevokeSponsorshipOpSigner)(nil) -// ChangeTrustAsset is an XDR Union defines as: +// RevokeSponsorshipOp is an XDR Union defines as: // -// union ChangeTrustAsset switch (AssetType type) +// union RevokeSponsorshipOp switch (RevokeSponsorshipType type) // { -// case ASSET_TYPE_NATIVE: // Not credit -// void; -// -// case ASSET_TYPE_CREDIT_ALPHANUM4: -// AlphaNum4 alphaNum4; -// -// case ASSET_TYPE_CREDIT_ALPHANUM12: -// AlphaNum12 alphaNum12; -// -// case ASSET_TYPE_POOL_SHARE: -// LiquidityPoolParameters liquidityPool; -// -// // add other asset types here in the future +// case REVOKE_SPONSORSHIP_LEDGER_ENTRY: +// LedgerKey ledgerKey; +// case REVOKE_SPONSORSHIP_SIGNER: +// struct +// { +// AccountID accountID; +// SignerKey signerKey; +// } signer; // }; -type ChangeTrustAsset struct { - Type AssetType - AlphaNum4 *AlphaNum4 - AlphaNum12 *AlphaNum12 - LiquidityPool *LiquidityPoolParameters +type RevokeSponsorshipOp struct { + Type RevokeSponsorshipType + LedgerKey *LedgerKey + Signer *RevokeSponsorshipOpSigner } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u ChangeTrustAsset) SwitchFieldName() string { +func (u RevokeSponsorshipOp) SwitchFieldName() string { return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of ChangeTrustAsset -func (u ChangeTrustAsset) ArmForSwitch(sw int32) (string, bool) { - switch AssetType(sw) { - case AssetTypeAssetTypeNative: - return "", true - case AssetTypeAssetTypeCreditAlphanum4: - return "AlphaNum4", true - case AssetTypeAssetTypeCreditAlphanum12: - return "AlphaNum12", true - case AssetTypeAssetTypePoolShare: - return "LiquidityPool", true +// the value for an instance of RevokeSponsorshipOp +func (u RevokeSponsorshipOp) ArmForSwitch(sw int32) (string, bool) { + switch RevokeSponsorshipType(sw) { + case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: + return "LedgerKey", true + case RevokeSponsorshipTypeRevokeSponsorshipSigner: + return "Signer", true } return "-", false } -// NewChangeTrustAsset creates a new ChangeTrustAsset. -func NewChangeTrustAsset(aType AssetType, value interface{}) (result ChangeTrustAsset, err error) { +// NewRevokeSponsorshipOp creates a new RevokeSponsorshipOp. +func NewRevokeSponsorshipOp(aType RevokeSponsorshipType, value interface{}) (result RevokeSponsorshipOp, err error) { result.Type = aType - switch AssetType(aType) { - case AssetTypeAssetTypeNative: - // void - case AssetTypeAssetTypeCreditAlphanum4: - tv, ok := value.(AlphaNum4) - if !ok { - err = errors.New("invalid value, must be AlphaNum4") - return - } - result.AlphaNum4 = &tv - case AssetTypeAssetTypeCreditAlphanum12: - tv, ok := value.(AlphaNum12) + switch RevokeSponsorshipType(aType) { + case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: + tv, ok := value.(LedgerKey) if !ok { - err = errors.New("invalid value, must be AlphaNum12") + err = errors.New("invalid value, must be LedgerKey") return } - result.AlphaNum12 = &tv - case AssetTypeAssetTypePoolShare: - tv, ok := value.(LiquidityPoolParameters) + result.LedgerKey = &tv + case RevokeSponsorshipTypeRevokeSponsorshipSigner: + tv, ok := value.(RevokeSponsorshipOpSigner) if !ok { - err = errors.New("invalid value, must be LiquidityPoolParameters") + err = errors.New("invalid value, must be RevokeSponsorshipOpSigner") return } - result.LiquidityPool = &tv - } - return -} - -// MustAlphaNum4 retrieves the AlphaNum4 value from the union, -// panicing if the value is not set. -func (u ChangeTrustAsset) MustAlphaNum4() AlphaNum4 { - val, ok := u.GetAlphaNum4() - - if !ok { - panic("arm AlphaNum4 is not set") - } - - return val -} - -// GetAlphaNum4 retrieves the AlphaNum4 value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ChangeTrustAsset) GetAlphaNum4() (result AlphaNum4, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "AlphaNum4" { - result = *u.AlphaNum4 - ok = true + result.Signer = &tv } - return } -// MustAlphaNum12 retrieves the AlphaNum12 value from the union, +// MustLedgerKey retrieves the LedgerKey value from the union, // panicing if the value is not set. -func (u ChangeTrustAsset) MustAlphaNum12() AlphaNum12 { - val, ok := u.GetAlphaNum12() +func (u RevokeSponsorshipOp) MustLedgerKey() LedgerKey { + val, ok := u.GetLedgerKey() if !ok { - panic("arm AlphaNum12 is not set") + panic("arm LedgerKey is not set") } return val } -// GetAlphaNum12 retrieves the AlphaNum12 value from the union, +// GetLedgerKey retrieves the LedgerKey value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ChangeTrustAsset) GetAlphaNum12() (result AlphaNum12, ok bool) { +func (u RevokeSponsorshipOp) GetLedgerKey() (result LedgerKey, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "AlphaNum12" { - result = *u.AlphaNum12 + if armName == "LedgerKey" { + result = *u.LedgerKey ok = true } return } -// MustLiquidityPool retrieves the LiquidityPool value from the union, +// MustSigner retrieves the Signer value from the union, // panicing if the value is not set. -func (u ChangeTrustAsset) MustLiquidityPool() LiquidityPoolParameters { - val, ok := u.GetLiquidityPool() +func (u RevokeSponsorshipOp) MustSigner() RevokeSponsorshipOpSigner { + val, ok := u.GetSigner() if !ok { - panic("arm LiquidityPool is not set") + panic("arm Signer is not set") } return val } -// GetLiquidityPool retrieves the LiquidityPool value from the union, +// GetSigner retrieves the Signer value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ChangeTrustAsset) GetLiquidityPool() (result LiquidityPoolParameters, ok bool) { +func (u RevokeSponsorshipOp) GetSigner() (result RevokeSponsorshipOpSigner, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "LiquidityPool" { - result = *u.LiquidityPool + if armName == "Signer" { + result = *u.Signer ok = true } @@ -26098,40 +28281,32 @@ func (u ChangeTrustAsset) GetLiquidityPool() (result LiquidityPoolParameters, ok } // EncodeTo encodes this value using the Encoder. -func (u ChangeTrustAsset) EncodeTo(e *xdr.Encoder) error { +func (u RevokeSponsorshipOp) EncodeTo(e *xdr.Encoder) error { var err error if err = u.Type.EncodeTo(e); err != nil { return err } - switch AssetType(u.Type) { - case AssetTypeAssetTypeNative: - // Void - return nil - case AssetTypeAssetTypeCreditAlphanum4: - if err = (*u.AlphaNum4).EncodeTo(e); err != nil { - return err - } - return nil - case AssetTypeAssetTypeCreditAlphanum12: - if err = (*u.AlphaNum12).EncodeTo(e); err != nil { + switch RevokeSponsorshipType(u.Type) { + case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: + if err = (*u.LedgerKey).EncodeTo(e); err != nil { return err } return nil - case AssetTypeAssetTypePoolShare: - if err = (*u.LiquidityPool).EncodeTo(e); err != nil { + case RevokeSponsorshipTypeRevokeSponsorshipSigner: + if err = (*u.Signer).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (AssetType) switch value '%d' is not valid for union ChangeTrustAsset", u.Type) + return fmt.Errorf("Type (RevokeSponsorshipType) switch value '%d' is not valid for union RevokeSponsorshipOp", u.Type) } -var _ decoderFrom = (*ChangeTrustAsset)(nil) +var _ decoderFrom = (*RevokeSponsorshipOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ChangeTrustAsset) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *RevokeSponsorshipOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ChangeTrustAsset: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding RevokeSponsorshipOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -26139,119 +28314,31 @@ func (u *ChangeTrustAsset) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetType: %w", err) + return n, fmt.Errorf("decoding RevokeSponsorshipType: %w", err) } - switch AssetType(u.Type) { - case AssetTypeAssetTypeNative: - // Void - return n, nil - case AssetTypeAssetTypeCreditAlphanum4: - u.AlphaNum4 = new(AlphaNum4) - nTmp, err = (*u.AlphaNum4).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AlphaNum4: %w", err) - } - return n, nil - case AssetTypeAssetTypeCreditAlphanum12: - u.AlphaNum12 = new(AlphaNum12) - nTmp, err = (*u.AlphaNum12).DecodeFrom(d, maxDepth) + switch RevokeSponsorshipType(u.Type) { + case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: + u.LedgerKey = new(LedgerKey) + nTmp, err = (*u.LedgerKey).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AlphaNum12: %w", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } return n, nil - case AssetTypeAssetTypePoolShare: - u.LiquidityPool = new(LiquidityPoolParameters) - nTmp, err = (*u.LiquidityPool).DecodeFrom(d, maxDepth) + case RevokeSponsorshipTypeRevokeSponsorshipSigner: + u.Signer = new(RevokeSponsorshipOpSigner) + nTmp, err = (*u.Signer).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolParameters: %w", err) + return n, fmt.Errorf("decoding RevokeSponsorshipOpSigner: %w", err) } return n, nil } - return n, fmt.Errorf("union ChangeTrustAsset has invalid Type (AssetType) switch value '%d'", u.Type) -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ChangeTrustAsset) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ChangeTrustAsset) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ChangeTrustAsset)(nil) - _ encoding.BinaryUnmarshaler = (*ChangeTrustAsset)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s ChangeTrustAsset) xdrType() {} - -var _ xdrType = (*ChangeTrustAsset)(nil) - -// ChangeTrustOp is an XDR Struct defines as: -// -// struct ChangeTrustOp -// { -// ChangeTrustAsset line; -// -// // if limit is set to 0, deletes the trust line -// int64 limit; -// }; -type ChangeTrustOp struct { - Line ChangeTrustAsset - Limit Int64 -} - -// EncodeTo encodes this value using the Encoder. -func (s *ChangeTrustOp) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Line.EncodeTo(e); err != nil { - return err - } - if err = s.Limit.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*ChangeTrustOp)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *ChangeTrustOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding ChangeTrustOp: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Line.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ChangeTrustAsset: %w", err) - } - nTmp, err = s.Limit.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - return n, nil + return n, fmt.Errorf("union RevokeSponsorshipOp has invalid Type (RevokeSponsorshipType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ChangeTrustOp) MarshalBinary() ([]byte, error) { +func (s RevokeSponsorshipOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26259,7 +28346,7 @@ func (s ChangeTrustOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ChangeTrustOp) UnmarshalBinary(inp []byte) error { +func (s *RevokeSponsorshipOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26269,76 +28356,74 @@ func (s *ChangeTrustOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ChangeTrustOp)(nil) - _ encoding.BinaryUnmarshaler = (*ChangeTrustOp)(nil) + _ encoding.BinaryMarshaler = (*RevokeSponsorshipOp)(nil) + _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ChangeTrustOp) xdrType() {} +func (s RevokeSponsorshipOp) xdrType() {} -var _ xdrType = (*ChangeTrustOp)(nil) +var _ xdrType = (*RevokeSponsorshipOp)(nil) -// AllowTrustOp is an XDR Struct defines as: +// ClawbackOp is an XDR Struct defines as: // -// struct AllowTrustOp +// struct ClawbackOp // { -// AccountID trustor; -// AssetCode asset; -// -// // One of 0, AUTHORIZED_FLAG, or AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG -// uint32 authorize; +// Asset asset; +// MuxedAccount from; +// int64 amount; // }; -type AllowTrustOp struct { - Trustor AccountId - Asset AssetCode - Authorize Uint32 +type ClawbackOp struct { + Asset Asset + From MuxedAccount + Amount Int64 } // EncodeTo encodes this value using the Encoder. -func (s *AllowTrustOp) EncodeTo(e *xdr.Encoder) error { +func (s *ClawbackOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Trustor.EncodeTo(e); err != nil { + if err = s.Asset.EncodeTo(e); err != nil { return err } - if err = s.Asset.EncodeTo(e); err != nil { + if err = s.From.EncodeTo(e); err != nil { return err } - if err = s.Authorize.EncodeTo(e); err != nil { + if err = s.Amount.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*AllowTrustOp)(nil) +var _ decoderFrom = (*ClawbackOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AllowTrustOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ClawbackOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding AllowTrustOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ClawbackOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Trustor.DecodeFrom(d, maxDepth) + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) + return n, fmt.Errorf("decoding Asset: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d, maxDepth) + nTmp, err = s.From.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AssetCode: %w", err) + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - nTmp, err = s.Authorize.DecodeFrom(d, maxDepth) + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s AllowTrustOp) MarshalBinary() ([]byte, error) { +func (s ClawbackOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26346,7 +28431,7 @@ func (s AllowTrustOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *AllowTrustOp) UnmarshalBinary(inp []byte) error { +func (s *ClawbackOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26356,79 +28441,54 @@ func (s *AllowTrustOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*AllowTrustOp)(nil) - _ encoding.BinaryUnmarshaler = (*AllowTrustOp)(nil) + _ encoding.BinaryMarshaler = (*ClawbackOp)(nil) + _ encoding.BinaryUnmarshaler = (*ClawbackOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s AllowTrustOp) xdrType() {} +func (s ClawbackOp) xdrType() {} -var _ xdrType = (*AllowTrustOp)(nil) +var _ xdrType = (*ClawbackOp)(nil) -// ManageDataOp is an XDR Struct defines as: +// ClawbackClaimableBalanceOp is an XDR Struct defines as: // -// struct ManageDataOp +// struct ClawbackClaimableBalanceOp // { -// string64 dataName; -// DataValue* dataValue; // set to null to clear +// ClaimableBalanceID balanceID; // }; -type ManageDataOp struct { - DataName String64 - DataValue *DataValue +type ClawbackClaimableBalanceOp struct { + BalanceId ClaimableBalanceId } // EncodeTo encodes this value using the Encoder. -func (s *ManageDataOp) EncodeTo(e *xdr.Encoder) error { +func (s *ClawbackClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.DataName.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeBool(s.DataValue != nil); err != nil { + if err = s.BalanceId.EncodeTo(e); err != nil { return err } - if s.DataValue != nil { - if err = (*s.DataValue).EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*ManageDataOp)(nil) +var _ decoderFrom = (*ClawbackClaimableBalanceOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ManageDataOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ClawbackClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ManageDataOp: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.DataName.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding String64: %w", err) - } - var b bool - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding DataValue: %w", err) - } - s.DataValue = nil - if b { - s.DataValue = new(DataValue) - nTmp, err = s.DataValue.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding DataValue: %w", err) - } + return 0, fmt.Errorf("decoding ClawbackClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ManageDataOp) MarshalBinary() ([]byte, error) { +func (s ClawbackClaimableBalanceOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26436,7 +28496,7 @@ func (s ManageDataOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ManageDataOp) UnmarshalBinary(inp []byte) error { +func (s *ClawbackClaimableBalanceOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26446,54 +28506,85 @@ func (s *ManageDataOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ManageDataOp)(nil) - _ encoding.BinaryUnmarshaler = (*ManageDataOp)(nil) + _ encoding.BinaryMarshaler = (*ClawbackClaimableBalanceOp)(nil) + _ encoding.BinaryUnmarshaler = (*ClawbackClaimableBalanceOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ManageDataOp) xdrType() {} +func (s ClawbackClaimableBalanceOp) xdrType() {} -var _ xdrType = (*ManageDataOp)(nil) +var _ xdrType = (*ClawbackClaimableBalanceOp)(nil) -// BumpSequenceOp is an XDR Struct defines as: +// SetTrustLineFlagsOp is an XDR Struct defines as: // -// struct BumpSequenceOp +// struct SetTrustLineFlagsOp // { -// SequenceNumber bumpTo; +// AccountID trustor; +// Asset asset; +// +// uint32 clearFlags; // which flags to clear +// uint32 setFlags; // which flags to set // }; -type BumpSequenceOp struct { - BumpTo SequenceNumber +type SetTrustLineFlagsOp struct { + Trustor AccountId + Asset Asset + ClearFlags Uint32 + SetFlags Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *BumpSequenceOp) EncodeTo(e *xdr.Encoder) error { +func (s *SetTrustLineFlagsOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.BumpTo.EncodeTo(e); err != nil { + if err = s.Trustor.EncodeTo(e); err != nil { + return err + } + if err = s.Asset.EncodeTo(e); err != nil { + return err + } + if err = s.ClearFlags.EncodeTo(e); err != nil { + return err + } + if err = s.SetFlags.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*BumpSequenceOp)(nil) +var _ decoderFrom = (*SetTrustLineFlagsOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *BumpSequenceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SetTrustLineFlagsOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding BumpSequenceOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SetTrustLineFlagsOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BumpTo.DecodeFrom(d, maxDepth) + nTmp, err = s.Trustor.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %w", err) + return n, fmt.Errorf("decoding AccountId: %w", err) + } + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + nTmp, err = s.ClearFlags.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.SetFlags.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BumpSequenceOp) MarshalBinary() ([]byte, error) { +func (s SetTrustLineFlagsOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26501,7 +28592,7 @@ func (s BumpSequenceOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BumpSequenceOp) UnmarshalBinary(inp []byte) error { +func (s *SetTrustLineFlagsOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26511,97 +28602,99 @@ func (s *BumpSequenceOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*BumpSequenceOp)(nil) - _ encoding.BinaryUnmarshaler = (*BumpSequenceOp)(nil) + _ encoding.BinaryMarshaler = (*SetTrustLineFlagsOp)(nil) + _ encoding.BinaryUnmarshaler = (*SetTrustLineFlagsOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s BumpSequenceOp) xdrType() {} +func (s SetTrustLineFlagsOp) xdrType() {} -var _ xdrType = (*BumpSequenceOp)(nil) +var _ xdrType = (*SetTrustLineFlagsOp)(nil) -// CreateClaimableBalanceOp is an XDR Struct defines as: +// LiquidityPoolFeeV18 is an XDR Const defines as: // -// struct CreateClaimableBalanceOp +// const LIQUIDITY_POOL_FEE_V18 = 30; +const LiquidityPoolFeeV18 = 30 + +// LiquidityPoolDepositOp is an XDR Struct defines as: +// +// struct LiquidityPoolDepositOp // { -// Asset asset; -// int64 amount; -// Claimant claimants<10>; +// PoolID liquidityPoolID; +// int64 maxAmountA; // maximum amount of first asset to deposit +// int64 maxAmountB; // maximum amount of second asset to deposit +// Price minPrice; // minimum depositA/depositB +// Price maxPrice; // maximum depositA/depositB // }; -type CreateClaimableBalanceOp struct { - Asset Asset - Amount Int64 - Claimants []Claimant `xdrmaxsize:"10"` +type LiquidityPoolDepositOp struct { + LiquidityPoolId PoolId + MaxAmountA Int64 + MaxAmountB Int64 + MinPrice Price + MaxPrice Price } // EncodeTo encodes this value using the Encoder. -func (s *CreateClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { +func (s *LiquidityPoolDepositOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Asset.EncodeTo(e); err != nil { + if err = s.LiquidityPoolId.EncodeTo(e); err != nil { return err } - if err = s.Amount.EncodeTo(e); err != nil { + if err = s.MaxAmountA.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Claimants))); err != nil { + if err = s.MaxAmountB.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Claimants); i++ { - if err = s.Claimants[i].EncodeTo(e); err != nil { - return err - } + if err = s.MinPrice.EncodeTo(e); err != nil { + return err + } + if err = s.MaxPrice.EncodeTo(e); err != nil { + return err } return nil } -var _ decoderFrom = (*CreateClaimableBalanceOp)(nil) +var _ decoderFrom = (*LiquidityPoolDepositOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreateClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LiquidityPoolDepositOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding CreateClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LiquidityPoolDepositOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Asset.DecodeFrom(d, maxDepth) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) + return n, fmt.Errorf("decoding PoolId: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d, maxDepth) + nTmp, err = s.MaxAmountA.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Int64: %w", err) } - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.MaxAmountB.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Claimant: %w", err) + return n, fmt.Errorf("decoding Int64: %w", err) } - if l > 10 { - return n, fmt.Errorf("decoding Claimant: data size (%d) exceeds size limit (10)", l) + nTmp, err = s.MinPrice.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Price: %w", err) } - s.Claimants = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding Claimant: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Claimants = make([]Claimant, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Claimants[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Claimant: %w", err) - } - } + nTmp, err = s.MaxPrice.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Price: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s CreateClaimableBalanceOp) MarshalBinary() ([]byte, error) { +func (s LiquidityPoolDepositOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26609,7 +28702,7 @@ func (s CreateClaimableBalanceOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *CreateClaimableBalanceOp) UnmarshalBinary(inp []byte) error { +func (s *LiquidityPoolDepositOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26619,54 +28712,84 @@ func (s *CreateClaimableBalanceOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*CreateClaimableBalanceOp)(nil) - _ encoding.BinaryUnmarshaler = (*CreateClaimableBalanceOp)(nil) + _ encoding.BinaryMarshaler = (*LiquidityPoolDepositOp)(nil) + _ encoding.BinaryUnmarshaler = (*LiquidityPoolDepositOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s CreateClaimableBalanceOp) xdrType() {} +func (s LiquidityPoolDepositOp) xdrType() {} -var _ xdrType = (*CreateClaimableBalanceOp)(nil) +var _ xdrType = (*LiquidityPoolDepositOp)(nil) -// ClaimClaimableBalanceOp is an XDR Struct defines as: +// LiquidityPoolWithdrawOp is an XDR Struct defines as: // -// struct ClaimClaimableBalanceOp +// struct LiquidityPoolWithdrawOp // { -// ClaimableBalanceID balanceID; +// PoolID liquidityPoolID; +// int64 amount; // amount of pool shares to withdraw +// int64 minAmountA; // minimum amount of first asset to withdraw +// int64 minAmountB; // minimum amount of second asset to withdraw // }; -type ClaimClaimableBalanceOp struct { - BalanceId ClaimableBalanceId +type LiquidityPoolWithdrawOp struct { + LiquidityPoolId PoolId + Amount Int64 + MinAmountA Int64 + MinAmountB Int64 } // EncodeTo encodes this value using the Encoder. -func (s *ClaimClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { +func (s *LiquidityPoolWithdrawOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.BalanceId.EncodeTo(e); err != nil { + if err = s.LiquidityPoolId.EncodeTo(e); err != nil { + return err + } + if err = s.Amount.EncodeTo(e); err != nil { + return err + } + if err = s.MinAmountA.EncodeTo(e); err != nil { + return err + } + if err = s.MinAmountB.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*ClaimClaimableBalanceOp)(nil) +var _ decoderFrom = (*LiquidityPoolWithdrawOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClaimClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LiquidityPoolWithdrawOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ClaimClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LiquidityPoolWithdrawOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) + return n, fmt.Errorf("decoding PoolId: %w", err) + } + nTmp, err = s.Amount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.MinAmountA.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.MinAmountB.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ClaimClaimableBalanceOp) MarshalBinary() ([]byte, error) { +func (s LiquidityPoolWithdrawOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26674,7 +28797,7 @@ func (s ClaimClaimableBalanceOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ClaimClaimableBalanceOp) UnmarshalBinary(inp []byte) error { +func (s *LiquidityPoolWithdrawOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26684,54 +28807,83 @@ func (s *ClaimClaimableBalanceOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ClaimClaimableBalanceOp)(nil) - _ encoding.BinaryUnmarshaler = (*ClaimClaimableBalanceOp)(nil) + _ encoding.BinaryMarshaler = (*LiquidityPoolWithdrawOp)(nil) + _ encoding.BinaryUnmarshaler = (*LiquidityPoolWithdrawOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ClaimClaimableBalanceOp) xdrType() {} +func (s LiquidityPoolWithdrawOp) xdrType() {} -var _ xdrType = (*ClaimClaimableBalanceOp)(nil) +var _ xdrType = (*LiquidityPoolWithdrawOp)(nil) -// BeginSponsoringFutureReservesOp is an XDR Struct defines as: +// HostFunctionType is an XDR Enum defines as: // -// struct BeginSponsoringFutureReservesOp +// enum HostFunctionType // { -// AccountID sponsoredID; +// HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0, +// HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1, +// HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2, +// HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2 = 3 // }; -type BeginSponsoringFutureReservesOp struct { - SponsoredId AccountId +type HostFunctionType int32 + +const ( + HostFunctionTypeHostFunctionTypeInvokeContract HostFunctionType = 0 + HostFunctionTypeHostFunctionTypeCreateContract HostFunctionType = 1 + HostFunctionTypeHostFunctionTypeUploadContractWasm HostFunctionType = 2 + HostFunctionTypeHostFunctionTypeCreateContractV2 HostFunctionType = 3 +) + +var hostFunctionTypeMap = map[int32]string{ + 0: "HostFunctionTypeHostFunctionTypeInvokeContract", + 1: "HostFunctionTypeHostFunctionTypeCreateContract", + 2: "HostFunctionTypeHostFunctionTypeUploadContractWasm", + 3: "HostFunctionTypeHostFunctionTypeCreateContractV2", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for HostFunctionType +func (e HostFunctionType) ValidEnum(v int32) bool { + _, ok := hostFunctionTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e HostFunctionType) String() string { + name, _ := hostFunctionTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *BeginSponsoringFutureReservesOp) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.SponsoredId.EncodeTo(e); err != nil { - return err +func (e HostFunctionType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := hostFunctionTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid HostFunctionType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*BeginSponsoringFutureReservesOp)(nil) +var _ decoderFrom = (*HostFunctionType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *BeginSponsoringFutureReservesOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *HostFunctionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding BeginSponsoringFutureReservesOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding HostFunctionType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.SponsoredId.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) + return n, fmt.Errorf("decoding HostFunctionType: %w", err) + } + if _, ok := hostFunctionTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid HostFunctionType enum value", v) } + *e = HostFunctionType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s BeginSponsoringFutureReservesOp) MarshalBinary() ([]byte, error) { +func (s HostFunctionType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26739,7 +28891,7 @@ func (s BeginSponsoringFutureReservesOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *BeginSponsoringFutureReservesOp) UnmarshalBinary(inp []byte) error { +func (s *HostFunctionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26749,77 +28901,77 @@ func (s *BeginSponsoringFutureReservesOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*BeginSponsoringFutureReservesOp)(nil) - _ encoding.BinaryUnmarshaler = (*BeginSponsoringFutureReservesOp)(nil) + _ encoding.BinaryMarshaler = (*HostFunctionType)(nil) + _ encoding.BinaryUnmarshaler = (*HostFunctionType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s BeginSponsoringFutureReservesOp) xdrType() {} +func (s HostFunctionType) xdrType() {} -var _ xdrType = (*BeginSponsoringFutureReservesOp)(nil) +var _ xdrType = (*HostFunctionType)(nil) -// RevokeSponsorshipType is an XDR Enum defines as: +// ContractIdPreimageType is an XDR Enum defines as: // -// enum RevokeSponsorshipType +// enum ContractIDPreimageType // { -// REVOKE_SPONSORSHIP_LEDGER_ENTRY = 0, -// REVOKE_SPONSORSHIP_SIGNER = 1 +// CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0, +// CONTRACT_ID_PREIMAGE_FROM_ASSET = 1 // }; -type RevokeSponsorshipType int32 +type ContractIdPreimageType int32 const ( - RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry RevokeSponsorshipType = 0 - RevokeSponsorshipTypeRevokeSponsorshipSigner RevokeSponsorshipType = 1 + ContractIdPreimageTypeContractIdPreimageFromAddress ContractIdPreimageType = 0 + ContractIdPreimageTypeContractIdPreimageFromAsset ContractIdPreimageType = 1 ) -var revokeSponsorshipTypeMap = map[int32]string{ - 0: "RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry", - 1: "RevokeSponsorshipTypeRevokeSponsorshipSigner", +var contractIdPreimageTypeMap = map[int32]string{ + 0: "ContractIdPreimageTypeContractIdPreimageFromAddress", + 1: "ContractIdPreimageTypeContractIdPreimageFromAsset", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for RevokeSponsorshipType -func (e RevokeSponsorshipType) ValidEnum(v int32) bool { - _, ok := revokeSponsorshipTypeMap[v] +// the Enum interface for ContractIdPreimageType +func (e ContractIdPreimageType) ValidEnum(v int32) bool { + _, ok := contractIdPreimageTypeMap[v] return ok } // String returns the name of `e` -func (e RevokeSponsorshipType) String() string { - name, _ := revokeSponsorshipTypeMap[int32(e)] +func (e ContractIdPreimageType) String() string { + name, _ := contractIdPreimageTypeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e RevokeSponsorshipType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := revokeSponsorshipTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid RevokeSponsorshipType enum value", e) +func (e ContractIdPreimageType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := contractIdPreimageTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ContractIdPreimageType enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*RevokeSponsorshipType)(nil) +var _ decoderFrom = (*ContractIdPreimageType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *RevokeSponsorshipType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *ContractIdPreimageType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding RevokeSponsorshipType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ContractIdPreimageType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipType: %w", err) + return n, fmt.Errorf("decoding ContractIdPreimageType: %w", err) } - if _, ok := revokeSponsorshipTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid RevokeSponsorshipType enum value", v) + if _, ok := contractIdPreimageTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ContractIdPreimageType enum value", v) } - *e = RevokeSponsorshipType(v) + *e = ContractIdPreimageType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s RevokeSponsorshipType) MarshalBinary() ([]byte, error) { +func (s ContractIdPreimageType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26827,7 +28979,7 @@ func (s RevokeSponsorshipType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *RevokeSponsorshipType) UnmarshalBinary(inp []byte) error { +func (s *ContractIdPreimageType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26837,64 +28989,64 @@ func (s *RevokeSponsorshipType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*RevokeSponsorshipType)(nil) - _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipType)(nil) + _ encoding.BinaryMarshaler = (*ContractIdPreimageType)(nil) + _ encoding.BinaryUnmarshaler = (*ContractIdPreimageType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s RevokeSponsorshipType) xdrType() {} +func (s ContractIdPreimageType) xdrType() {} -var _ xdrType = (*RevokeSponsorshipType)(nil) +var _ xdrType = (*ContractIdPreimageType)(nil) -// RevokeSponsorshipOpSigner is an XDR NestedStruct defines as: +// ContractIdPreimageFromAddress is an XDR NestedStruct defines as: // // struct // { -// AccountID accountID; -// SignerKey signerKey; +// SCAddress address; +// uint256 salt; // } -type RevokeSponsorshipOpSigner struct { - AccountId AccountId - SignerKey SignerKey +type ContractIdPreimageFromAddress struct { + Address ScAddress + Salt Uint256 } // EncodeTo encodes this value using the Encoder. -func (s *RevokeSponsorshipOpSigner) EncodeTo(e *xdr.Encoder) error { +func (s *ContractIdPreimageFromAddress) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.AccountId.EncodeTo(e); err != nil { + if err = s.Address.EncodeTo(e); err != nil { return err } - if err = s.SignerKey.EncodeTo(e); err != nil { + if err = s.Salt.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*RevokeSponsorshipOpSigner)(nil) +var _ decoderFrom = (*ContractIdPreimageFromAddress)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *RevokeSponsorshipOpSigner) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ContractIdPreimageFromAddress) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding RevokeSponsorshipOpSigner: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ContractIdPreimageFromAddress: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.AccountId.DecodeFrom(d, maxDepth) + nTmp, err = s.Address.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } - nTmp, err = s.SignerKey.DecodeFrom(d, maxDepth) + nTmp, err = s.Salt.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKey: %w", err) + return n, fmt.Errorf("decoding Uint256: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s RevokeSponsorshipOpSigner) MarshalBinary() ([]byte, error) { +func (s ContractIdPreimageFromAddress) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -26902,7 +29054,7 @@ func (s RevokeSponsorshipOpSigner) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *RevokeSponsorshipOpSigner) UnmarshalBinary(inp []byte) error { +func (s *ContractIdPreimageFromAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -26912,118 +29064,118 @@ func (s *RevokeSponsorshipOpSigner) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*RevokeSponsorshipOpSigner)(nil) - _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipOpSigner)(nil) + _ encoding.BinaryMarshaler = (*ContractIdPreimageFromAddress)(nil) + _ encoding.BinaryUnmarshaler = (*ContractIdPreimageFromAddress)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s RevokeSponsorshipOpSigner) xdrType() {} +func (s ContractIdPreimageFromAddress) xdrType() {} -var _ xdrType = (*RevokeSponsorshipOpSigner)(nil) +var _ xdrType = (*ContractIdPreimageFromAddress)(nil) -// RevokeSponsorshipOp is an XDR Union defines as: +// ContractIdPreimage is an XDR Union defines as: // -// union RevokeSponsorshipOp switch (RevokeSponsorshipType type) +// union ContractIDPreimage switch (ContractIDPreimageType type) // { -// case REVOKE_SPONSORSHIP_LEDGER_ENTRY: -// LedgerKey ledgerKey; -// case REVOKE_SPONSORSHIP_SIGNER: +// case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: // struct // { -// AccountID accountID; -// SignerKey signerKey; -// } signer; +// SCAddress address; +// uint256 salt; +// } fromAddress; +// case CONTRACT_ID_PREIMAGE_FROM_ASSET: +// Asset fromAsset; // }; -type RevokeSponsorshipOp struct { - Type RevokeSponsorshipType - LedgerKey *LedgerKey - Signer *RevokeSponsorshipOpSigner +type ContractIdPreimage struct { + Type ContractIdPreimageType + FromAddress *ContractIdPreimageFromAddress + FromAsset *Asset } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u RevokeSponsorshipOp) SwitchFieldName() string { +func (u ContractIdPreimage) SwitchFieldName() string { return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of RevokeSponsorshipOp -func (u RevokeSponsorshipOp) ArmForSwitch(sw int32) (string, bool) { - switch RevokeSponsorshipType(sw) { - case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: - return "LedgerKey", true - case RevokeSponsorshipTypeRevokeSponsorshipSigner: - return "Signer", true +// the value for an instance of ContractIdPreimage +func (u ContractIdPreimage) ArmForSwitch(sw int32) (string, bool) { + switch ContractIdPreimageType(sw) { + case ContractIdPreimageTypeContractIdPreimageFromAddress: + return "FromAddress", true + case ContractIdPreimageTypeContractIdPreimageFromAsset: + return "FromAsset", true } return "-", false } -// NewRevokeSponsorshipOp creates a new RevokeSponsorshipOp. -func NewRevokeSponsorshipOp(aType RevokeSponsorshipType, value interface{}) (result RevokeSponsorshipOp, err error) { +// NewContractIdPreimage creates a new ContractIdPreimage. +func NewContractIdPreimage(aType ContractIdPreimageType, value interface{}) (result ContractIdPreimage, err error) { result.Type = aType - switch RevokeSponsorshipType(aType) { - case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: - tv, ok := value.(LedgerKey) + switch ContractIdPreimageType(aType) { + case ContractIdPreimageTypeContractIdPreimageFromAddress: + tv, ok := value.(ContractIdPreimageFromAddress) if !ok { - err = errors.New("invalid value, must be LedgerKey") + err = errors.New("invalid value, must be ContractIdPreimageFromAddress") return } - result.LedgerKey = &tv - case RevokeSponsorshipTypeRevokeSponsorshipSigner: - tv, ok := value.(RevokeSponsorshipOpSigner) + result.FromAddress = &tv + case ContractIdPreimageTypeContractIdPreimageFromAsset: + tv, ok := value.(Asset) if !ok { - err = errors.New("invalid value, must be RevokeSponsorshipOpSigner") + err = errors.New("invalid value, must be Asset") return } - result.Signer = &tv + result.FromAsset = &tv } return } -// MustLedgerKey retrieves the LedgerKey value from the union, +// MustFromAddress retrieves the FromAddress value from the union, // panicing if the value is not set. -func (u RevokeSponsorshipOp) MustLedgerKey() LedgerKey { - val, ok := u.GetLedgerKey() +func (u ContractIdPreimage) MustFromAddress() ContractIdPreimageFromAddress { + val, ok := u.GetFromAddress() if !ok { - panic("arm LedgerKey is not set") + panic("arm FromAddress is not set") } return val } -// GetLedgerKey retrieves the LedgerKey value from the union, +// GetFromAddress retrieves the FromAddress value from the union, // returning ok if the union's switch indicated the value is valid. -func (u RevokeSponsorshipOp) GetLedgerKey() (result LedgerKey, ok bool) { +func (u ContractIdPreimage) GetFromAddress() (result ContractIdPreimageFromAddress, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "LedgerKey" { - result = *u.LedgerKey + if armName == "FromAddress" { + result = *u.FromAddress ok = true } return } -// MustSigner retrieves the Signer value from the union, +// MustFromAsset retrieves the FromAsset value from the union, // panicing if the value is not set. -func (u RevokeSponsorshipOp) MustSigner() RevokeSponsorshipOpSigner { - val, ok := u.GetSigner() +func (u ContractIdPreimage) MustFromAsset() Asset { + val, ok := u.GetFromAsset() if !ok { - panic("arm Signer is not set") + panic("arm FromAsset is not set") } return val } -// GetSigner retrieves the Signer value from the union, +// GetFromAsset retrieves the FromAsset value from the union, // returning ok if the union's switch indicated the value is valid. -func (u RevokeSponsorshipOp) GetSigner() (result RevokeSponsorshipOpSigner, ok bool) { +func (u ContractIdPreimage) GetFromAsset() (result Asset, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Signer" { - result = *u.Signer + if armName == "FromAsset" { + result = *u.FromAsset ok = true } @@ -27031,32 +29183,32 @@ func (u RevokeSponsorshipOp) GetSigner() (result RevokeSponsorshipOpSigner, ok b } // EncodeTo encodes this value using the Encoder. -func (u RevokeSponsorshipOp) EncodeTo(e *xdr.Encoder) error { +func (u ContractIdPreimage) EncodeTo(e *xdr.Encoder) error { var err error if err = u.Type.EncodeTo(e); err != nil { return err } - switch RevokeSponsorshipType(u.Type) { - case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: - if err = (*u.LedgerKey).EncodeTo(e); err != nil { + switch ContractIdPreimageType(u.Type) { + case ContractIdPreimageTypeContractIdPreimageFromAddress: + if err = (*u.FromAddress).EncodeTo(e); err != nil { return err } return nil - case RevokeSponsorshipTypeRevokeSponsorshipSigner: - if err = (*u.Signer).EncodeTo(e); err != nil { + case ContractIdPreimageTypeContractIdPreimageFromAsset: + if err = (*u.FromAsset).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (RevokeSponsorshipType) switch value '%d' is not valid for union RevokeSponsorshipOp", u.Type) + return fmt.Errorf("Type (ContractIdPreimageType) switch value '%d' is not valid for union ContractIdPreimage", u.Type) } -var _ decoderFrom = (*RevokeSponsorshipOp)(nil) +var _ decoderFrom = (*ContractIdPreimage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *RevokeSponsorshipOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *ContractIdPreimage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding RevokeSponsorshipOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ContractIdPreimage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -27064,31 +29216,31 @@ func (u *RevokeSponsorshipOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, er nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipType: %w", err) + return n, fmt.Errorf("decoding ContractIdPreimageType: %w", err) } - switch RevokeSponsorshipType(u.Type) { - case RevokeSponsorshipTypeRevokeSponsorshipLedgerEntry: - u.LedgerKey = new(LedgerKey) - nTmp, err = (*u.LedgerKey).DecodeFrom(d, maxDepth) + switch ContractIdPreimageType(u.Type) { + case ContractIdPreimageTypeContractIdPreimageFromAddress: + u.FromAddress = new(ContractIdPreimageFromAddress) + nTmp, err = (*u.FromAddress).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) + return n, fmt.Errorf("decoding ContractIdPreimageFromAddress: %w", err) } return n, nil - case RevokeSponsorshipTypeRevokeSponsorshipSigner: - u.Signer = new(RevokeSponsorshipOpSigner) - nTmp, err = (*u.Signer).DecodeFrom(d, maxDepth) + case ContractIdPreimageTypeContractIdPreimageFromAsset: + u.FromAsset = new(Asset) + nTmp, err = (*u.FromAsset).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipOpSigner: %w", err) + return n, fmt.Errorf("decoding Asset: %w", err) } return n, nil } - return n, fmt.Errorf("union RevokeSponsorshipOp has invalid Type (RevokeSponsorshipType) switch value '%d'", u.Type) + return n, fmt.Errorf("union ContractIdPreimage has invalid Type (ContractIdPreimageType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s RevokeSponsorshipOp) MarshalBinary() ([]byte, error) { +func (s ContractIdPreimage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27096,7 +29248,7 @@ func (s RevokeSponsorshipOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *RevokeSponsorshipOp) UnmarshalBinary(inp []byte) error { +func (s *ContractIdPreimage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27106,74 +29258,64 @@ func (s *RevokeSponsorshipOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*RevokeSponsorshipOp)(nil) - _ encoding.BinaryUnmarshaler = (*RevokeSponsorshipOp)(nil) + _ encoding.BinaryMarshaler = (*ContractIdPreimage)(nil) + _ encoding.BinaryUnmarshaler = (*ContractIdPreimage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s RevokeSponsorshipOp) xdrType() {} +func (s ContractIdPreimage) xdrType() {} -var _ xdrType = (*RevokeSponsorshipOp)(nil) +var _ xdrType = (*ContractIdPreimage)(nil) -// ClawbackOp is an XDR Struct defines as: +// CreateContractArgs is an XDR Struct defines as: // -// struct ClawbackOp +// struct CreateContractArgs // { -// Asset asset; -// MuxedAccount from; -// int64 amount; +// ContractIDPreimage contractIDPreimage; +// ContractExecutable executable; // }; -type ClawbackOp struct { - Asset Asset - From MuxedAccount - Amount Int64 +type CreateContractArgs struct { + ContractIdPreimage ContractIdPreimage + Executable ContractExecutable } // EncodeTo encodes this value using the Encoder. -func (s *ClawbackOp) EncodeTo(e *xdr.Encoder) error { +func (s *CreateContractArgs) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Asset.EncodeTo(e); err != nil { - return err - } - if err = s.From.EncodeTo(e); err != nil { + if err = s.ContractIdPreimage.EncodeTo(e); err != nil { return err } - if err = s.Amount.EncodeTo(e); err != nil { + if err = s.Executable.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*ClawbackOp)(nil) +var _ decoderFrom = (*CreateContractArgs)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClawbackOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *CreateContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ClawbackOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding CreateContractArgs: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Asset.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) - } - nTmp, err = s.From.DecodeFrom(d, maxDepth) + nTmp, err = s.ContractIdPreimage.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %w", err) + return n, fmt.Errorf("decoding ContractIdPreimage: %w", err) } - nTmp, err = s.Amount.DecodeFrom(d, maxDepth) + nTmp, err = s.Executable.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + return n, fmt.Errorf("decoding ContractExecutable: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ClawbackOp) MarshalBinary() ([]byte, error) { +func (s CreateContractArgs) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27181,7 +29323,7 @@ func (s ClawbackOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ClawbackOp) UnmarshalBinary(inp []byte) error { +func (s *CreateContractArgs) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27191,54 +29333,95 @@ func (s *ClawbackOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ClawbackOp)(nil) - _ encoding.BinaryUnmarshaler = (*ClawbackOp)(nil) + _ encoding.BinaryMarshaler = (*CreateContractArgs)(nil) + _ encoding.BinaryUnmarshaler = (*CreateContractArgs)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ClawbackOp) xdrType() {} +func (s CreateContractArgs) xdrType() {} -var _ xdrType = (*ClawbackOp)(nil) +var _ xdrType = (*CreateContractArgs)(nil) -// ClawbackClaimableBalanceOp is an XDR Struct defines as: +// CreateContractArgsV2 is an XDR Struct defines as: // -// struct ClawbackClaimableBalanceOp +// struct CreateContractArgsV2 // { -// ClaimableBalanceID balanceID; +// ContractIDPreimage contractIDPreimage; +// ContractExecutable executable; +// // Arguments of the contract's constructor. +// SCVal constructorArgs<>; // }; -type ClawbackClaimableBalanceOp struct { - BalanceId ClaimableBalanceId +type CreateContractArgsV2 struct { + ContractIdPreimage ContractIdPreimage + Executable ContractExecutable + ConstructorArgs []ScVal } // EncodeTo encodes this value using the Encoder. -func (s *ClawbackClaimableBalanceOp) EncodeTo(e *xdr.Encoder) error { +func (s *CreateContractArgsV2) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.BalanceId.EncodeTo(e); err != nil { + if err = s.ContractIdPreimage.EncodeTo(e); err != nil { + return err + } + if err = s.Executable.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeUint(uint32(len(s.ConstructorArgs))); err != nil { return err } + for i := 0; i < len(s.ConstructorArgs); i++ { + if err = s.ConstructorArgs[i].EncodeTo(e); err != nil { + return err + } + } return nil } -var _ decoderFrom = (*ClawbackClaimableBalanceOp)(nil) +var _ decoderFrom = (*CreateContractArgsV2)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ClawbackClaimableBalanceOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *CreateContractArgsV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ClawbackClaimableBalanceOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding CreateContractArgsV2: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.BalanceId.DecodeFrom(d, maxDepth) + nTmp, err = s.ContractIdPreimage.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ClaimableBalanceId: %w", err) + return n, fmt.Errorf("decoding ContractIdPreimage: %w", err) + } + nTmp, err = s.Executable.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ContractExecutable: %w", err) + } + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %w", err) + } + s.ConstructorArgs = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) + } + s.ConstructorArgs = make([]ScVal, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.ConstructorArgs[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %w", err) + } + } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ClawbackClaimableBalanceOp) MarshalBinary() ([]byte, error) { +func (s CreateContractArgsV2) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27246,7 +29429,7 @@ func (s ClawbackClaimableBalanceOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ClawbackClaimableBalanceOp) UnmarshalBinary(inp []byte) error { +func (s *CreateContractArgsV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27256,85 +29439,383 @@ func (s *ClawbackClaimableBalanceOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ClawbackClaimableBalanceOp)(nil) - _ encoding.BinaryUnmarshaler = (*ClawbackClaimableBalanceOp)(nil) + _ encoding.BinaryMarshaler = (*CreateContractArgsV2)(nil) + _ encoding.BinaryUnmarshaler = (*CreateContractArgsV2)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ClawbackClaimableBalanceOp) xdrType() {} +func (s CreateContractArgsV2) xdrType() {} -var _ xdrType = (*ClawbackClaimableBalanceOp)(nil) +var _ xdrType = (*CreateContractArgsV2)(nil) -// SetTrustLineFlagsOp is an XDR Struct defines as: -// -// struct SetTrustLineFlagsOp -// { -// AccountID trustor; -// Asset asset; +// InvokeContractArgs is an XDR Struct defines as: // -// uint32 clearFlags; // which flags to clear -// uint32 setFlags; // which flags to set +// struct InvokeContractArgs { +// SCAddress contractAddress; +// SCSymbol functionName; +// SCVal args<>; // }; -type SetTrustLineFlagsOp struct { - Trustor AccountId - Asset Asset - ClearFlags Uint32 - SetFlags Uint32 +type InvokeContractArgs struct { + ContractAddress ScAddress + FunctionName ScSymbol + Args []ScVal } // EncodeTo encodes this value using the Encoder. -func (s *SetTrustLineFlagsOp) EncodeTo(e *xdr.Encoder) error { +func (s *InvokeContractArgs) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Trustor.EncodeTo(e); err != nil { + if err = s.ContractAddress.EncodeTo(e); err != nil { return err } - if err = s.Asset.EncodeTo(e); err != nil { + if err = s.FunctionName.EncodeTo(e); err != nil { return err } - if err = s.ClearFlags.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Args))); err != nil { return err } - if err = s.SetFlags.EncodeTo(e); err != nil { - return err + for i := 0; i < len(s.Args); i++ { + if err = s.Args[i].EncodeTo(e); err != nil { + return err + } } return nil } -var _ decoderFrom = (*SetTrustLineFlagsOp)(nil) +var _ decoderFrom = (*InvokeContractArgs)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *SetTrustLineFlagsOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *InvokeContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SetTrustLineFlagsOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding InvokeContractArgs: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.Trustor.DecodeFrom(d, maxDepth) + nTmp, err = s.ContractAddress.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) + return n, fmt.Errorf("decoding ScAddress: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d, maxDepth) + nTmp, err = s.FunctionName.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) + return n, fmt.Errorf("decoding ScSymbol: %w", err) } - nTmp, err = s.ClearFlags.DecodeFrom(d, maxDepth) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding ScVal: %w", err) } - nTmp, err = s.SetFlags.DecodeFrom(d, maxDepth) + s.Args = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) + } + s.Args = make([]ScVal, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Args[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %w", err) + } + } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s InvokeContractArgs) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *InvokeContractArgs) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*InvokeContractArgs)(nil) + _ encoding.BinaryUnmarshaler = (*InvokeContractArgs)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s InvokeContractArgs) xdrType() {} + +var _ xdrType = (*InvokeContractArgs)(nil) + +// HostFunction is an XDR Union defines as: +// +// union HostFunction switch (HostFunctionType type) +// { +// case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: +// InvokeContractArgs invokeContract; +// case HOST_FUNCTION_TYPE_CREATE_CONTRACT: +// CreateContractArgs createContract; +// case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: +// opaque wasm<>; +// case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2: +// CreateContractArgsV2 createContractV2; +// }; +type HostFunction struct { + Type HostFunctionType + InvokeContract *InvokeContractArgs + CreateContract *CreateContractArgs + Wasm *[]byte + CreateContractV2 *CreateContractArgsV2 +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u HostFunction) SwitchFieldName() string { + return "Type" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of HostFunction +func (u HostFunction) ArmForSwitch(sw int32) (string, bool) { + switch HostFunctionType(sw) { + case HostFunctionTypeHostFunctionTypeInvokeContract: + return "InvokeContract", true + case HostFunctionTypeHostFunctionTypeCreateContract: + return "CreateContract", true + case HostFunctionTypeHostFunctionTypeUploadContractWasm: + return "Wasm", true + case HostFunctionTypeHostFunctionTypeCreateContractV2: + return "CreateContractV2", true + } + return "-", false +} + +// NewHostFunction creates a new HostFunction. +func NewHostFunction(aType HostFunctionType, value interface{}) (result HostFunction, err error) { + result.Type = aType + switch HostFunctionType(aType) { + case HostFunctionTypeHostFunctionTypeInvokeContract: + tv, ok := value.(InvokeContractArgs) + if !ok { + err = errors.New("invalid value, must be InvokeContractArgs") + return + } + result.InvokeContract = &tv + case HostFunctionTypeHostFunctionTypeCreateContract: + tv, ok := value.(CreateContractArgs) + if !ok { + err = errors.New("invalid value, must be CreateContractArgs") + return + } + result.CreateContract = &tv + case HostFunctionTypeHostFunctionTypeUploadContractWasm: + tv, ok := value.([]byte) + if !ok { + err = errors.New("invalid value, must be []byte") + return + } + result.Wasm = &tv + case HostFunctionTypeHostFunctionTypeCreateContractV2: + tv, ok := value.(CreateContractArgsV2) + if !ok { + err = errors.New("invalid value, must be CreateContractArgsV2") + return + } + result.CreateContractV2 = &tv + } + return +} + +// MustInvokeContract retrieves the InvokeContract value from the union, +// panicing if the value is not set. +func (u HostFunction) MustInvokeContract() InvokeContractArgs { + val, ok := u.GetInvokeContract() + + if !ok { + panic("arm InvokeContract is not set") + } + + return val +} + +// GetInvokeContract retrieves the InvokeContract value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u HostFunction) GetInvokeContract() (result InvokeContractArgs, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "InvokeContract" { + result = *u.InvokeContract + ok = true + } + + return +} + +// MustCreateContract retrieves the CreateContract value from the union, +// panicing if the value is not set. +func (u HostFunction) MustCreateContract() CreateContractArgs { + val, ok := u.GetCreateContract() + + if !ok { + panic("arm CreateContract is not set") + } + + return val +} + +// GetCreateContract retrieves the CreateContract value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u HostFunction) GetCreateContract() (result CreateContractArgs, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "CreateContract" { + result = *u.CreateContract + ok = true + } + + return +} + +// MustWasm retrieves the Wasm value from the union, +// panicing if the value is not set. +func (u HostFunction) MustWasm() []byte { + val, ok := u.GetWasm() + + if !ok { + panic("arm Wasm is not set") + } + + return val +} + +// GetWasm retrieves the Wasm value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u HostFunction) GetWasm() (result []byte, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Wasm" { + result = *u.Wasm + ok = true + } + + return +} + +// MustCreateContractV2 retrieves the CreateContractV2 value from the union, +// panicing if the value is not set. +func (u HostFunction) MustCreateContractV2() CreateContractArgsV2 { + val, ok := u.GetCreateContractV2() + + if !ok { + panic("arm CreateContractV2 is not set") + } + + return val +} + +// GetCreateContractV2 retrieves the CreateContractV2 value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u HostFunction) GetCreateContractV2() (result CreateContractArgsV2, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "CreateContractV2" { + result = *u.CreateContractV2 + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u HostFunction) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err + } + switch HostFunctionType(u.Type) { + case HostFunctionTypeHostFunctionTypeInvokeContract: + if err = (*u.InvokeContract).EncodeTo(e); err != nil { + return err + } + return nil + case HostFunctionTypeHostFunctionTypeCreateContract: + if err = (*u.CreateContract).EncodeTo(e); err != nil { + return err + } + return nil + case HostFunctionTypeHostFunctionTypeUploadContractWasm: + if _, err = e.EncodeOpaque((*u.Wasm)[:]); err != nil { + return err + } + return nil + case HostFunctionTypeHostFunctionTypeCreateContractV2: + if err = (*u.CreateContractV2).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (HostFunctionType) switch value '%d' is not valid for union HostFunction", u.Type) +} + +var _ decoderFrom = (*HostFunction)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *HostFunction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HostFunction: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding HostFunctionType: %w", err) } - return n, nil + switch HostFunctionType(u.Type) { + case HostFunctionTypeHostFunctionTypeInvokeContract: + u.InvokeContract = new(InvokeContractArgs) + nTmp, err = (*u.InvokeContract).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding InvokeContractArgs: %w", err) + } + return n, nil + case HostFunctionTypeHostFunctionTypeCreateContract: + u.CreateContract = new(CreateContractArgs) + nTmp, err = (*u.CreateContract).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreateContractArgs: %w", err) + } + return n, nil + case HostFunctionTypeHostFunctionTypeUploadContractWasm: + u.Wasm = new([]byte) + (*u.Wasm), nTmp, err = d.DecodeOpaque(0) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Wasm: %w", err) + } + return n, nil + case HostFunctionTypeHostFunctionTypeCreateContractV2: + u.CreateContractV2 = new(CreateContractArgsV2) + nTmp, err = (*u.CreateContractV2).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreateContractArgsV2: %w", err) + } + return n, nil + } + return n, fmt.Errorf("union HostFunction has invalid Type (HostFunctionType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SetTrustLineFlagsOp) MarshalBinary() ([]byte, error) { +func (s HostFunction) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27342,7 +29823,7 @@ func (s SetTrustLineFlagsOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SetTrustLineFlagsOp) UnmarshalBinary(inp []byte) error { +func (s *HostFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27352,99 +29833,80 @@ func (s *SetTrustLineFlagsOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SetTrustLineFlagsOp)(nil) - _ encoding.BinaryUnmarshaler = (*SetTrustLineFlagsOp)(nil) + _ encoding.BinaryMarshaler = (*HostFunction)(nil) + _ encoding.BinaryUnmarshaler = (*HostFunction)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SetTrustLineFlagsOp) xdrType() {} - -var _ xdrType = (*SetTrustLineFlagsOp)(nil) +func (s HostFunction) xdrType() {} -// LiquidityPoolFeeV18 is an XDR Const defines as: -// -// const LIQUIDITY_POOL_FEE_V18 = 30; -const LiquidityPoolFeeV18 = 30 +var _ xdrType = (*HostFunction)(nil) -// LiquidityPoolDepositOp is an XDR Struct defines as: +// SorobanAuthorizedFunctionType is an XDR Enum defines as: // -// struct LiquidityPoolDepositOp +// enum SorobanAuthorizedFunctionType // { -// PoolID liquidityPoolID; -// int64 maxAmountA; // maximum amount of first asset to deposit -// int64 maxAmountB; // maximum amount of second asset to deposit -// Price minPrice; // minimum depositA/depositB -// Price maxPrice; // maximum depositA/depositB +// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, +// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1, +// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN = 2 // }; -type LiquidityPoolDepositOp struct { - LiquidityPoolId PoolId - MaxAmountA Int64 - MaxAmountB Int64 - MinPrice Price - MaxPrice Price +type SorobanAuthorizedFunctionType int32 + +const ( + SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn SorobanAuthorizedFunctionType = 0 + SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn SorobanAuthorizedFunctionType = 1 + SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractV2HostFn SorobanAuthorizedFunctionType = 2 +) + +var sorobanAuthorizedFunctionTypeMap = map[int32]string{ + 0: "SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn", + 1: "SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn", + 2: "SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractV2HostFn", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for SorobanAuthorizedFunctionType +func (e SorobanAuthorizedFunctionType) ValidEnum(v int32) bool { + _, ok := sorobanAuthorizedFunctionTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e SorobanAuthorizedFunctionType) String() string { + name, _ := sorobanAuthorizedFunctionTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *LiquidityPoolDepositOp) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.LiquidityPoolId.EncodeTo(e); err != nil { - return err - } - if err = s.MaxAmountA.EncodeTo(e); err != nil { - return err - } - if err = s.MaxAmountB.EncodeTo(e); err != nil { - return err - } - if err = s.MinPrice.EncodeTo(e); err != nil { - return err - } - if err = s.MaxPrice.EncodeTo(e); err != nil { - return err +func (e SorobanAuthorizedFunctionType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := sorobanAuthorizedFunctionTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid SorobanAuthorizedFunctionType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*LiquidityPoolDepositOp)(nil) +var _ decoderFrom = (*SorobanAuthorizedFunctionType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LiquidityPoolDepositOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *SorobanAuthorizedFunctionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LiquidityPoolDepositOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PoolId: %w", err) - } - nTmp, err = s.MaxAmountA.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.MaxAmountB.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.MinPrice.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding Price: %w", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", err) } - nTmp, err = s.MaxPrice.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Price: %w", err) + if _, ok := sorobanAuthorizedFunctionTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid SorobanAuthorizedFunctionType enum value", v) } + *e = SorobanAuthorizedFunctionType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LiquidityPoolDepositOp) MarshalBinary() ([]byte, error) { +func (s SorobanAuthorizedFunctionType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27452,7 +29914,7 @@ func (s LiquidityPoolDepositOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LiquidityPoolDepositOp) UnmarshalBinary(inp []byte) error { +func (s *SorobanAuthorizedFunctionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27462,84 +29924,237 @@ func (s *LiquidityPoolDepositOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LiquidityPoolDepositOp)(nil) - _ encoding.BinaryUnmarshaler = (*LiquidityPoolDepositOp)(nil) + _ encoding.BinaryMarshaler = (*SorobanAuthorizedFunctionType)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunctionType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LiquidityPoolDepositOp) xdrType() {} +func (s SorobanAuthorizedFunctionType) xdrType() {} -var _ xdrType = (*LiquidityPoolDepositOp)(nil) +var _ xdrType = (*SorobanAuthorizedFunctionType)(nil) -// LiquidityPoolWithdrawOp is an XDR Struct defines as: +// SorobanAuthorizedFunction is an XDR Union defines as: // -// struct LiquidityPoolWithdrawOp +// union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type) // { -// PoolID liquidityPoolID; -// int64 amount; // amount of pool shares to withdraw -// int64 minAmountA; // minimum amount of first asset to withdraw -// int64 minAmountB; // minimum amount of second asset to withdraw +// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: +// InvokeContractArgs contractFn; +// // This variant of auth payload for creating new contract instances +// // doesn't allow specifying the constructor arguments, creating contracts +// // with constructors that take arguments is only possible by authorizing +// // `SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN` +// // (protocol 22+). +// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: +// CreateContractArgs createContractHostFn; +// // This variant of auth payload for creating new contract instances +// // is only accepted in and after protocol 22. It allows authorizing the +// // contract constructor arguments. +// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN: +// CreateContractArgsV2 createContractV2HostFn; // }; -type LiquidityPoolWithdrawOp struct { - LiquidityPoolId PoolId - Amount Int64 - MinAmountA Int64 - MinAmountB Int64 +type SorobanAuthorizedFunction struct { + Type SorobanAuthorizedFunctionType + ContractFn *InvokeContractArgs + CreateContractHostFn *CreateContractArgs + CreateContractV2HostFn *CreateContractArgsV2 } -// EncodeTo encodes this value using the Encoder. -func (s *LiquidityPoolWithdrawOp) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.LiquidityPoolId.EncodeTo(e); err != nil { - return err +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u SorobanAuthorizedFunction) SwitchFieldName() string { + return "Type" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of SorobanAuthorizedFunction +func (u SorobanAuthorizedFunction) ArmForSwitch(sw int32) (string, bool) { + switch SorobanAuthorizedFunctionType(sw) { + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: + return "ContractFn", true + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: + return "CreateContractHostFn", true + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractV2HostFn: + return "CreateContractV2HostFn", true } - if err = s.Amount.EncodeTo(e); err != nil { - return err + return "-", false +} + +// NewSorobanAuthorizedFunction creates a new SorobanAuthorizedFunction. +func NewSorobanAuthorizedFunction(aType SorobanAuthorizedFunctionType, value interface{}) (result SorobanAuthorizedFunction, err error) { + result.Type = aType + switch SorobanAuthorizedFunctionType(aType) { + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: + tv, ok := value.(InvokeContractArgs) + if !ok { + err = errors.New("invalid value, must be InvokeContractArgs") + return + } + result.ContractFn = &tv + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: + tv, ok := value.(CreateContractArgs) + if !ok { + err = errors.New("invalid value, must be CreateContractArgs") + return + } + result.CreateContractHostFn = &tv + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractV2HostFn: + tv, ok := value.(CreateContractArgsV2) + if !ok { + err = errors.New("invalid value, must be CreateContractArgsV2") + return + } + result.CreateContractV2HostFn = &tv } - if err = s.MinAmountA.EncodeTo(e); err != nil { - return err + return +} + +// MustContractFn retrieves the ContractFn value from the union, +// panicing if the value is not set. +func (u SorobanAuthorizedFunction) MustContractFn() InvokeContractArgs { + val, ok := u.GetContractFn() + + if !ok { + panic("arm ContractFn is not set") } - if err = s.MinAmountB.EncodeTo(e); err != nil { + + return val +} + +// GetContractFn retrieves the ContractFn value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u SorobanAuthorizedFunction) GetContractFn() (result InvokeContractArgs, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "ContractFn" { + result = *u.ContractFn + ok = true + } + + return +} + +// MustCreateContractHostFn retrieves the CreateContractHostFn value from the union, +// panicing if the value is not set. +func (u SorobanAuthorizedFunction) MustCreateContractHostFn() CreateContractArgs { + val, ok := u.GetCreateContractHostFn() + + if !ok { + panic("arm CreateContractHostFn is not set") + } + + return val +} + +// GetCreateContractHostFn retrieves the CreateContractHostFn value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u SorobanAuthorizedFunction) GetCreateContractHostFn() (result CreateContractArgs, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "CreateContractHostFn" { + result = *u.CreateContractHostFn + ok = true + } + + return +} + +// MustCreateContractV2HostFn retrieves the CreateContractV2HostFn value from the union, +// panicing if the value is not set. +func (u SorobanAuthorizedFunction) MustCreateContractV2HostFn() CreateContractArgsV2 { + val, ok := u.GetCreateContractV2HostFn() + + if !ok { + panic("arm CreateContractV2HostFn is not set") + } + + return val +} + +// GetCreateContractV2HostFn retrieves the CreateContractV2HostFn value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u SorobanAuthorizedFunction) GetCreateContractV2HostFn() (result CreateContractArgsV2, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "CreateContractV2HostFn" { + result = *u.CreateContractV2HostFn + ok = true + } + + return +} + +// EncodeTo encodes this value using the Encoder. +func (u SorobanAuthorizedFunction) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { return err } - return nil + switch SorobanAuthorizedFunctionType(u.Type) { + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: + if err = (*u.ContractFn).EncodeTo(e); err != nil { + return err + } + return nil + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: + if err = (*u.CreateContractHostFn).EncodeTo(e); err != nil { + return err + } + return nil + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractV2HostFn: + if err = (*u.CreateContractV2HostFn).EncodeTo(e); err != nil { + return err + } + return nil + } + return fmt.Errorf("Type (SorobanAuthorizedFunctionType) switch value '%d' is not valid for union SorobanAuthorizedFunction", u.Type) } -var _ decoderFrom = (*LiquidityPoolWithdrawOp)(nil) +var _ decoderFrom = (*SorobanAuthorizedFunction)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LiquidityPoolWithdrawOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *SorobanAuthorizedFunction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LiquidityPoolWithdrawOp: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanAuthorizedFunction: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PoolId: %w", err) - } - nTmp, err = s.Amount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.MinAmountA.DecodeFrom(d, maxDepth) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", err) } - nTmp, err = s.MinAmountB.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) + switch SorobanAuthorizedFunctionType(u.Type) { + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: + u.ContractFn = new(InvokeContractArgs) + nTmp, err = (*u.ContractFn).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding InvokeContractArgs: %w", err) + } + return n, nil + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: + u.CreateContractHostFn = new(CreateContractArgs) + nTmp, err = (*u.CreateContractHostFn).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreateContractArgs: %w", err) + } + return n, nil + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractV2HostFn: + u.CreateContractV2HostFn = new(CreateContractArgsV2) + nTmp, err = (*u.CreateContractV2HostFn).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreateContractArgsV2: %w", err) + } + return n, nil } - return n, nil + return n, fmt.Errorf("union SorobanAuthorizedFunction has invalid Type (SorobanAuthorizedFunctionType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LiquidityPoolWithdrawOp) MarshalBinary() ([]byte, error) { +func (s SorobanAuthorizedFunction) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27547,7 +30162,7 @@ func (s LiquidityPoolWithdrawOp) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LiquidityPoolWithdrawOp) UnmarshalBinary(inp []byte) error { +func (s *SorobanAuthorizedFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27557,80 +30172,84 @@ func (s *LiquidityPoolWithdrawOp) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LiquidityPoolWithdrawOp)(nil) - _ encoding.BinaryUnmarshaler = (*LiquidityPoolWithdrawOp)(nil) + _ encoding.BinaryMarshaler = (*SorobanAuthorizedFunction)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunction)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LiquidityPoolWithdrawOp) xdrType() {} +func (s SorobanAuthorizedFunction) xdrType() {} -var _ xdrType = (*LiquidityPoolWithdrawOp)(nil) +var _ xdrType = (*SorobanAuthorizedFunction)(nil) -// HostFunctionType is an XDR Enum defines as: +// SorobanAuthorizedInvocation is an XDR Struct defines as: // -// enum HostFunctionType +// struct SorobanAuthorizedInvocation // { -// HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0, -// HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1, -// HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 +// SorobanAuthorizedFunction function; +// SorobanAuthorizedInvocation subInvocations<>; // }; -type HostFunctionType int32 - -const ( - HostFunctionTypeHostFunctionTypeInvokeContract HostFunctionType = 0 - HostFunctionTypeHostFunctionTypeCreateContract HostFunctionType = 1 - HostFunctionTypeHostFunctionTypeUploadContractWasm HostFunctionType = 2 -) - -var hostFunctionTypeMap = map[int32]string{ - 0: "HostFunctionTypeHostFunctionTypeInvokeContract", - 1: "HostFunctionTypeHostFunctionTypeCreateContract", - 2: "HostFunctionTypeHostFunctionTypeUploadContractWasm", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for HostFunctionType -func (e HostFunctionType) ValidEnum(v int32) bool { - _, ok := hostFunctionTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e HostFunctionType) String() string { - name, _ := hostFunctionTypeMap[int32(e)] - return name +type SorobanAuthorizedInvocation struct { + Function SorobanAuthorizedFunction + SubInvocations []SorobanAuthorizedInvocation } // EncodeTo encodes this value using the Encoder. -func (e HostFunctionType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := hostFunctionTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid HostFunctionType enum value", e) +func (s *SorobanAuthorizedInvocation) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Function.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + if _, err = e.EncodeUint(uint32(len(s.SubInvocations))); err != nil { + return err + } + for i := 0; i < len(s.SubInvocations); i++ { + if err = s.SubInvocations[i].EncodeTo(e); err != nil { + return err + } + } + return nil } -var _ decoderFrom = (*HostFunctionType)(nil) +var _ decoderFrom = (*SorobanAuthorizedInvocation)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *HostFunctionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SorobanAuthorizedInvocation) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding HostFunctionType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = s.Function.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding HostFunctionType: %w", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunction: %w", err) } - if _, ok := hostFunctionTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid HostFunctionType enum value", v) + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) + } + s.SubInvocations = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: length (%d) exceeds remaining input length (%d)", l, il) + } + s.SubInvocations = make([]SorobanAuthorizedInvocation, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.SubInvocations[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) + } + } } - *e = HostFunctionType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HostFunctionType) MarshalBinary() ([]byte, error) { +func (s SorobanAuthorizedInvocation) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27638,7 +30257,7 @@ func (s HostFunctionType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HostFunctionType) UnmarshalBinary(inp []byte) error { +func (s *SorobanAuthorizedInvocation) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27648,77 +30267,84 @@ func (s *HostFunctionType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HostFunctionType)(nil) - _ encoding.BinaryUnmarshaler = (*HostFunctionType)(nil) + _ encoding.BinaryMarshaler = (*SorobanAuthorizedInvocation)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedInvocation)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s HostFunctionType) xdrType() {} +func (s SorobanAuthorizedInvocation) xdrType() {} -var _ xdrType = (*HostFunctionType)(nil) +var _ xdrType = (*SorobanAuthorizedInvocation)(nil) -// ContractIdPreimageType is an XDR Enum defines as: +// SorobanAddressCredentials is an XDR Struct defines as: // -// enum ContractIDPreimageType +// struct SorobanAddressCredentials // { -// CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0, -// CONTRACT_ID_PREIMAGE_FROM_ASSET = 1 +// SCAddress address; +// int64 nonce; +// uint32 signatureExpirationLedger; +// SCVal signature; // }; -type ContractIdPreimageType int32 - -const ( - ContractIdPreimageTypeContractIdPreimageFromAddress ContractIdPreimageType = 0 - ContractIdPreimageTypeContractIdPreimageFromAsset ContractIdPreimageType = 1 -) - -var contractIdPreimageTypeMap = map[int32]string{ - 0: "ContractIdPreimageTypeContractIdPreimageFromAddress", - 1: "ContractIdPreimageTypeContractIdPreimageFromAsset", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ContractIdPreimageType -func (e ContractIdPreimageType) ValidEnum(v int32) bool { - _, ok := contractIdPreimageTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e ContractIdPreimageType) String() string { - name, _ := contractIdPreimageTypeMap[int32(e)] - return name +type SorobanAddressCredentials struct { + Address ScAddress + Nonce Int64 + SignatureExpirationLedger Uint32 + Signature ScVal } // EncodeTo encodes this value using the Encoder. -func (e ContractIdPreimageType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := contractIdPreimageTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ContractIdPreimageType enum value", e) +func (s *SorobanAddressCredentials) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Address.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + if err = s.Nonce.EncodeTo(e); err != nil { + return err + } + if err = s.SignatureExpirationLedger.EncodeTo(e); err != nil { + return err + } + if err = s.Signature.EncodeTo(e); err != nil { + return err + } + return nil } -var _ decoderFrom = (*ContractIdPreimageType)(nil) +var _ decoderFrom = (*SorobanAddressCredentials)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ContractIdPreimageType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SorobanAddressCredentials) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ContractIdPreimageType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanAddressCredentials: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = s.Address.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScAddress: %w", err) + } + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimageType: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - if _, ok := contractIdPreimageTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ContractIdPreimageType enum value", v) + nTmp, err = s.Signature.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %w", err) } - *e = ContractIdPreimageType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractIdPreimageType) MarshalBinary() ([]byte, error) { +func (s SorobanAddressCredentials) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27726,7 +30352,7 @@ func (s ContractIdPreimageType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractIdPreimageType) UnmarshalBinary(inp []byte) error { +func (s *SorobanAddressCredentials) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27736,64 +30362,77 @@ func (s *ContractIdPreimageType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractIdPreimageType)(nil) - _ encoding.BinaryUnmarshaler = (*ContractIdPreimageType)(nil) + _ encoding.BinaryMarshaler = (*SorobanAddressCredentials)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAddressCredentials)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ContractIdPreimageType) xdrType() {} +func (s SorobanAddressCredentials) xdrType() {} -var _ xdrType = (*ContractIdPreimageType)(nil) +var _ xdrType = (*SorobanAddressCredentials)(nil) -// ContractIdPreimageFromAddress is an XDR NestedStruct defines as: +// SorobanCredentialsType is an XDR Enum defines as: // -// struct -// { -// SCAddress address; -// uint256 salt; -// } -type ContractIdPreimageFromAddress struct { - Address ScAddress - Salt Uint256 +// enum SorobanCredentialsType +// { +// SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0, +// SOROBAN_CREDENTIALS_ADDRESS = 1 +// }; +type SorobanCredentialsType int32 + +const ( + SorobanCredentialsTypeSorobanCredentialsSourceAccount SorobanCredentialsType = 0 + SorobanCredentialsTypeSorobanCredentialsAddress SorobanCredentialsType = 1 +) + +var sorobanCredentialsTypeMap = map[int32]string{ + 0: "SorobanCredentialsTypeSorobanCredentialsSourceAccount", + 1: "SorobanCredentialsTypeSorobanCredentialsAddress", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for SorobanCredentialsType +func (e SorobanCredentialsType) ValidEnum(v int32) bool { + _, ok := sorobanCredentialsTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e SorobanCredentialsType) String() string { + name, _ := sorobanCredentialsTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *ContractIdPreimageFromAddress) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Address.EncodeTo(e); err != nil { - return err - } - if err = s.Salt.EncodeTo(e); err != nil { - return err +func (e SorobanCredentialsType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := sorobanCredentialsTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid SorobanCredentialsType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*ContractIdPreimageFromAddress)(nil) +var _ decoderFrom = (*SorobanCredentialsType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractIdPreimageFromAddress) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *SorobanCredentialsType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ContractIdPreimageFromAddress: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanCredentialsType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Address.DecodeFrom(d, maxDepth) - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScAddress: %w", err) + return n, fmt.Errorf("decoding SorobanCredentialsType: %w", err) } - nTmp, err = s.Salt.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %w", err) + if _, ok := sorobanCredentialsTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid SorobanCredentialsType enum value", v) } + *e = SorobanCredentialsType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractIdPreimageFromAddress) MarshalBinary() ([]byte, error) { +func (s SorobanCredentialsType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27801,7 +30440,7 @@ func (s ContractIdPreimageFromAddress) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractIdPreimageFromAddress) UnmarshalBinary(inp []byte) error { +func (s *SorobanCredentialsType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -27811,118 +30450,83 @@ func (s *ContractIdPreimageFromAddress) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractIdPreimageFromAddress)(nil) - _ encoding.BinaryUnmarshaler = (*ContractIdPreimageFromAddress)(nil) + _ encoding.BinaryMarshaler = (*SorobanCredentialsType)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanCredentialsType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ContractIdPreimageFromAddress) xdrType() {} +func (s SorobanCredentialsType) xdrType() {} -var _ xdrType = (*ContractIdPreimageFromAddress)(nil) +var _ xdrType = (*SorobanCredentialsType)(nil) -// ContractIdPreimage is an XDR Union defines as: +// SorobanCredentials is an XDR Union defines as: // -// union ContractIDPreimage switch (ContractIDPreimageType type) +// union SorobanCredentials switch (SorobanCredentialsType type) // { -// case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: -// struct -// { -// SCAddress address; -// uint256 salt; -// } fromAddress; -// case CONTRACT_ID_PREIMAGE_FROM_ASSET: -// Asset fromAsset; +// case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: +// void; +// case SOROBAN_CREDENTIALS_ADDRESS: +// SorobanAddressCredentials address; // }; -type ContractIdPreimage struct { - Type ContractIdPreimageType - FromAddress *ContractIdPreimageFromAddress - FromAsset *Asset +type SorobanCredentials struct { + Type SorobanCredentialsType + Address *SorobanAddressCredentials } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u ContractIdPreimage) SwitchFieldName() string { +func (u SorobanCredentials) SwitchFieldName() string { return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of ContractIdPreimage -func (u ContractIdPreimage) ArmForSwitch(sw int32) (string, bool) { - switch ContractIdPreimageType(sw) { - case ContractIdPreimageTypeContractIdPreimageFromAddress: - return "FromAddress", true - case ContractIdPreimageTypeContractIdPreimageFromAsset: - return "FromAsset", true +// the value for an instance of SorobanCredentials +func (u SorobanCredentials) ArmForSwitch(sw int32) (string, bool) { + switch SorobanCredentialsType(sw) { + case SorobanCredentialsTypeSorobanCredentialsSourceAccount: + return "", true + case SorobanCredentialsTypeSorobanCredentialsAddress: + return "Address", true } return "-", false } -// NewContractIdPreimage creates a new ContractIdPreimage. -func NewContractIdPreimage(aType ContractIdPreimageType, value interface{}) (result ContractIdPreimage, err error) { +// NewSorobanCredentials creates a new SorobanCredentials. +func NewSorobanCredentials(aType SorobanCredentialsType, value interface{}) (result SorobanCredentials, err error) { result.Type = aType - switch ContractIdPreimageType(aType) { - case ContractIdPreimageTypeContractIdPreimageFromAddress: - tv, ok := value.(ContractIdPreimageFromAddress) - if !ok { - err = errors.New("invalid value, must be ContractIdPreimageFromAddress") - return - } - result.FromAddress = &tv - case ContractIdPreimageTypeContractIdPreimageFromAsset: - tv, ok := value.(Asset) + switch SorobanCredentialsType(aType) { + case SorobanCredentialsTypeSorobanCredentialsSourceAccount: + // void + case SorobanCredentialsTypeSorobanCredentialsAddress: + tv, ok := value.(SorobanAddressCredentials) if !ok { - err = errors.New("invalid value, must be Asset") + err = errors.New("invalid value, must be SorobanAddressCredentials") return } - result.FromAsset = &tv - } - return -} - -// MustFromAddress retrieves the FromAddress value from the union, -// panicing if the value is not set. -func (u ContractIdPreimage) MustFromAddress() ContractIdPreimageFromAddress { - val, ok := u.GetFromAddress() - - if !ok { - panic("arm FromAddress is not set") - } - - return val -} - -// GetFromAddress retrieves the FromAddress value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ContractIdPreimage) GetFromAddress() (result ContractIdPreimageFromAddress, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "FromAddress" { - result = *u.FromAddress - ok = true + result.Address = &tv } - return } -// MustFromAsset retrieves the FromAsset value from the union, +// MustAddress retrieves the Address value from the union, // panicing if the value is not set. -func (u ContractIdPreimage) MustFromAsset() Asset { - val, ok := u.GetFromAsset() +func (u SorobanCredentials) MustAddress() SorobanAddressCredentials { + val, ok := u.GetAddress() if !ok { - panic("arm FromAsset is not set") + panic("arm Address is not set") } return val } -// GetFromAsset retrieves the FromAsset value from the union, +// GetAddress retrieves the Address value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ContractIdPreimage) GetFromAsset() (result Asset, ok bool) { +func (u SorobanCredentials) GetAddress() (result SorobanAddressCredentials, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "FromAsset" { - result = *u.FromAsset + if armName == "Address" { + result = *u.Address ok = true } @@ -27930,32 +30534,30 @@ func (u ContractIdPreimage) GetFromAsset() (result Asset, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u ContractIdPreimage) EncodeTo(e *xdr.Encoder) error { +func (u SorobanCredentials) EncodeTo(e *xdr.Encoder) error { var err error if err = u.Type.EncodeTo(e); err != nil { return err } - switch ContractIdPreimageType(u.Type) { - case ContractIdPreimageTypeContractIdPreimageFromAddress: - if err = (*u.FromAddress).EncodeTo(e); err != nil { - return err - } + switch SorobanCredentialsType(u.Type) { + case SorobanCredentialsTypeSorobanCredentialsSourceAccount: + // Void return nil - case ContractIdPreimageTypeContractIdPreimageFromAsset: - if err = (*u.FromAsset).EncodeTo(e); err != nil { + case SorobanCredentialsTypeSorobanCredentialsAddress: + if err = (*u.Address).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (ContractIdPreimageType) switch value '%d' is not valid for union ContractIdPreimage", u.Type) + return fmt.Errorf("Type (SorobanCredentialsType) switch value '%d' is not valid for union SorobanCredentials", u.Type) } -var _ decoderFrom = (*ContractIdPreimage)(nil) +var _ decoderFrom = (*SorobanCredentials)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ContractIdPreimage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *SorobanCredentials) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding ContractIdPreimage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanCredentials: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -27963,31 +30565,26 @@ func (u *ContractIdPreimage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, err nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimageType: %w", err) + return n, fmt.Errorf("decoding SorobanCredentialsType: %w", err) } - switch ContractIdPreimageType(u.Type) { - case ContractIdPreimageTypeContractIdPreimageFromAddress: - u.FromAddress = new(ContractIdPreimageFromAddress) - nTmp, err = (*u.FromAddress).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimageFromAddress: %w", err) - } + switch SorobanCredentialsType(u.Type) { + case SorobanCredentialsTypeSorobanCredentialsSourceAccount: + // Void return n, nil - case ContractIdPreimageTypeContractIdPreimageFromAsset: - u.FromAsset = new(Asset) - nTmp, err = (*u.FromAsset).DecodeFrom(d, maxDepth) + case SorobanCredentialsTypeSorobanCredentialsAddress: + u.Address = new(SorobanAddressCredentials) + nTmp, err = (*u.Address).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) + return n, fmt.Errorf("decoding SorobanAddressCredentials: %w", err) } return n, nil } - return n, fmt.Errorf("union ContractIdPreimage has invalid Type (ContractIdPreimageType) switch value '%d'", u.Type) + return n, fmt.Errorf("union SorobanCredentials has invalid Type (SorobanCredentialsType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractIdPreimage) MarshalBinary() ([]byte, error) { +func (s SorobanCredentials) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27995,7 +30592,7 @@ func (s ContractIdPreimage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractIdPreimage) UnmarshalBinary(inp []byte) error { +func (s *SorobanCredentials) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -28005,64 +30602,64 @@ func (s *ContractIdPreimage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractIdPreimage)(nil) - _ encoding.BinaryUnmarshaler = (*ContractIdPreimage)(nil) + _ encoding.BinaryMarshaler = (*SorobanCredentials)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanCredentials)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s ContractIdPreimage) xdrType() {} +func (s SorobanCredentials) xdrType() {} -var _ xdrType = (*ContractIdPreimage)(nil) +var _ xdrType = (*SorobanCredentials)(nil) -// CreateContractArgs is an XDR Struct defines as: +// SorobanAuthorizationEntry is an XDR Struct defines as: // -// struct CreateContractArgs +// struct SorobanAuthorizationEntry // { -// ContractIDPreimage contractIDPreimage; -// ContractExecutable executable; +// SorobanCredentials credentials; +// SorobanAuthorizedInvocation rootInvocation; // }; -type CreateContractArgs struct { - ContractIdPreimage ContractIdPreimage - Executable ContractExecutable +type SorobanAuthorizationEntry struct { + Credentials SorobanCredentials + RootInvocation SorobanAuthorizedInvocation } // EncodeTo encodes this value using the Encoder. -func (s *CreateContractArgs) EncodeTo(e *xdr.Encoder) error { +func (s *SorobanAuthorizationEntry) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.ContractIdPreimage.EncodeTo(e); err != nil { + if err = s.Credentials.EncodeTo(e); err != nil { return err } - if err = s.Executable.EncodeTo(e); err != nil { + if err = s.RootInvocation.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*CreateContractArgs)(nil) +var _ decoderFrom = (*SorobanAuthorizationEntry)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *CreateContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *SorobanAuthorizationEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding CreateContractArgs: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ContractIdPreimage.DecodeFrom(d, maxDepth) + nTmp, err = s.Credentials.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimage: %w", err) + return n, fmt.Errorf("decoding SorobanCredentials: %w", err) } - nTmp, err = s.Executable.DecodeFrom(d, maxDepth) + nTmp, err = s.RootInvocation.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractExecutable: %w", err) + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s CreateContractArgs) MarshalBinary() ([]byte, error) { +func (s SorobanAuthorizationEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -28070,7 +30667,7 @@ func (s CreateContractArgs) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *CreateContractArgs) UnmarshalBinary(inp []byte) error { +func (s *SorobanAuthorizationEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -28080,333 +30677,161 @@ func (s *CreateContractArgs) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*CreateContractArgs)(nil) - _ encoding.BinaryUnmarshaler = (*CreateContractArgs)(nil) + _ encoding.BinaryMarshaler = (*SorobanAuthorizationEntry)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizationEntry)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s CreateContractArgs) xdrType() {} +func (s SorobanAuthorizationEntry) xdrType() {} -var _ xdrType = (*CreateContractArgs)(nil) +var _ xdrType = (*SorobanAuthorizationEntry)(nil) -// InvokeContractArgs is an XDR Struct defines as: +// InvokeHostFunctionOp is an XDR Struct defines as: // -// struct InvokeContractArgs { -// SCAddress contractAddress; -// SCSymbol functionName; -// SCVal args<>; +// struct InvokeHostFunctionOp +// { +// // Host function to invoke. +// HostFunction hostFunction; +// // Per-address authorizations for this host function. +// SorobanAuthorizationEntry auth<>; // }; -type InvokeContractArgs struct { - ContractAddress ScAddress - FunctionName ScSymbol - Args []ScVal +type InvokeHostFunctionOp struct { + HostFunction HostFunction + Auth []SorobanAuthorizationEntry } // EncodeTo encodes this value using the Encoder. -func (s *InvokeContractArgs) EncodeTo(e *xdr.Encoder) error { +func (s *InvokeHostFunctionOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.ContractAddress.EncodeTo(e); err != nil { - return err - } - if err = s.FunctionName.EncodeTo(e); err != nil { + if err = s.HostFunction.EncodeTo(e); err != nil { return err } - if _, err = e.EncodeUint(uint32(len(s.Args))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.Auth))); err != nil { return err } - for i := 0; i < len(s.Args); i++ { - if err = s.Args[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.Auth); i++ { + if err = s.Auth[i].EncodeTo(e); err != nil { return err } } return nil } -var _ decoderFrom = (*InvokeContractArgs)(nil) +var _ decoderFrom = (*InvokeHostFunctionOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *InvokeContractArgs) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *InvokeHostFunctionOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding InvokeContractArgs: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding InvokeHostFunctionOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.ContractAddress.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScAddress: %w", err) - } - nTmp, err = s.FunctionName.DecodeFrom(d, maxDepth) + nTmp, err = s.HostFunction.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScSymbol: %w", err) + return n, fmt.Errorf("decoding HostFunction: %w", err) } var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", err) } - s.Args = nil + s.Auth = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding ScVal: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: length (%d) exceeds remaining input length (%d)", l, il) } - s.Args = make([]ScVal, l) + s.Auth = make([]SorobanAuthorizationEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Args[i].DecodeFrom(d, maxDepth) + nTmp, err = s.Auth[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) - } - } - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s InvokeContractArgs) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *InvokeContractArgs) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*InvokeContractArgs)(nil) - _ encoding.BinaryUnmarshaler = (*InvokeContractArgs)(nil) -) - -// xdrType signals that this type represents XDR values defined by this package. -func (s InvokeContractArgs) xdrType() {} - -var _ xdrType = (*InvokeContractArgs)(nil) - -// HostFunction is an XDR Union defines as: -// -// union HostFunction switch (HostFunctionType type) -// { -// case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: -// InvokeContractArgs invokeContract; -// case HOST_FUNCTION_TYPE_CREATE_CONTRACT: -// CreateContractArgs createContract; -// case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: -// opaque wasm<>; -// }; -type HostFunction struct { - Type HostFunctionType - InvokeContract *InvokeContractArgs - CreateContract *CreateContractArgs - Wasm *[]byte -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u HostFunction) SwitchFieldName() string { - return "Type" -} - -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of HostFunction -func (u HostFunction) ArmForSwitch(sw int32) (string, bool) { - switch HostFunctionType(sw) { - case HostFunctionTypeHostFunctionTypeInvokeContract: - return "InvokeContract", true - case HostFunctionTypeHostFunctionTypeCreateContract: - return "CreateContract", true - case HostFunctionTypeHostFunctionTypeUploadContractWasm: - return "Wasm", true - } - return "-", false -} - -// NewHostFunction creates a new HostFunction. -func NewHostFunction(aType HostFunctionType, value interface{}) (result HostFunction, err error) { - result.Type = aType - switch HostFunctionType(aType) { - case HostFunctionTypeHostFunctionTypeInvokeContract: - tv, ok := value.(InvokeContractArgs) - if !ok { - err = errors.New("invalid value, must be InvokeContractArgs") - return - } - result.InvokeContract = &tv - case HostFunctionTypeHostFunctionTypeCreateContract: - tv, ok := value.(CreateContractArgs) - if !ok { - err = errors.New("invalid value, must be CreateContractArgs") - return - } - result.CreateContract = &tv - case HostFunctionTypeHostFunctionTypeUploadContractWasm: - tv, ok := value.([]byte) - if !ok { - err = errors.New("invalid value, must be []byte") - return - } - result.Wasm = &tv - } - return -} - -// MustInvokeContract retrieves the InvokeContract value from the union, -// panicing if the value is not set. -func (u HostFunction) MustInvokeContract() InvokeContractArgs { - val, ok := u.GetInvokeContract() - - if !ok { - panic("arm InvokeContract is not set") - } - - return val -} - -// GetInvokeContract retrieves the InvokeContract value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HostFunction) GetInvokeContract() (result InvokeContractArgs, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "InvokeContract" { - result = *u.InvokeContract - ok = true - } - - return -} - -// MustCreateContract retrieves the CreateContract value from the union, -// panicing if the value is not set. -func (u HostFunction) MustCreateContract() CreateContractArgs { - val, ok := u.GetCreateContract() - - if !ok { - panic("arm CreateContract is not set") - } - - return val -} - -// GetCreateContract retrieves the CreateContract value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HostFunction) GetCreateContract() (result CreateContractArgs, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "CreateContract" { - result = *u.CreateContract - ok = true + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", err) + } + } } - - return + return n, nil } -// MustWasm retrieves the Wasm value from the union, -// panicing if the value is not set. -func (u HostFunction) MustWasm() []byte { - val, ok := u.GetWasm() - - if !ok { - panic("arm Wasm is not set") - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s InvokeHostFunctionOp) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return val +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *InvokeHostFunctionOp) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// GetWasm retrieves the Wasm value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HostFunction) GetWasm() (result []byte, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +var ( + _ encoding.BinaryMarshaler = (*InvokeHostFunctionOp)(nil) + _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionOp)(nil) +) - if armName == "Wasm" { - result = *u.Wasm - ok = true - } +// xdrType signals that this type represents XDR values defined by this package. +func (s InvokeHostFunctionOp) xdrType() {} - return +var _ xdrType = (*InvokeHostFunctionOp)(nil) + +// ExtendFootprintTtlOp is an XDR Struct defines as: +// +// struct ExtendFootprintTTLOp +// { +// ExtensionPoint ext; +// uint32 extendTo; +// }; +type ExtendFootprintTtlOp struct { + Ext ExtensionPoint + ExtendTo Uint32 } // EncodeTo encodes this value using the Encoder. -func (u HostFunction) EncodeTo(e *xdr.Encoder) error { +func (s *ExtendFootprintTtlOp) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if err = s.Ext.EncodeTo(e); err != nil { return err } - switch HostFunctionType(u.Type) { - case HostFunctionTypeHostFunctionTypeInvokeContract: - if err = (*u.InvokeContract).EncodeTo(e); err != nil { - return err - } - return nil - case HostFunctionTypeHostFunctionTypeCreateContract: - if err = (*u.CreateContract).EncodeTo(e); err != nil { - return err - } - return nil - case HostFunctionTypeHostFunctionTypeUploadContractWasm: - if _, err = e.EncodeOpaque((*u.Wasm)[:]); err != nil { - return err - } - return nil + if err = s.ExtendTo.EncodeTo(e); err != nil { + return err } - return fmt.Errorf("Type (HostFunctionType) switch value '%d' is not valid for union HostFunction", u.Type) + return nil } -var _ decoderFrom = (*HostFunction)(nil) +var _ decoderFrom = (*ExtendFootprintTtlOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *HostFunction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ExtendFootprintTtlOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding HostFunction: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ExtendFootprintTtlOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HostFunctionType: %w", err) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - switch HostFunctionType(u.Type) { - case HostFunctionTypeHostFunctionTypeInvokeContract: - u.InvokeContract = new(InvokeContractArgs) - nTmp, err = (*u.InvokeContract).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding InvokeContractArgs: %w", err) - } - return n, nil - case HostFunctionTypeHostFunctionTypeCreateContract: - u.CreateContract = new(CreateContractArgs) - nTmp, err = (*u.CreateContract).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding CreateContractArgs: %w", err) - } - return n, nil - case HostFunctionTypeHostFunctionTypeUploadContractWasm: - u.Wasm = new([]byte) - (*u.Wasm), nTmp, err = d.DecodeOpaque(0) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Wasm: %w", err) - } - return n, nil + nTmp, err = s.ExtendTo.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) } - return n, fmt.Errorf("union HostFunction has invalid Type (HostFunctionType) switch value '%d'", u.Type) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HostFunction) MarshalBinary() ([]byte, error) { +func (s ExtendFootprintTtlOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -28414,7 +30839,7 @@ func (s HostFunction) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HostFunction) UnmarshalBinary(inp []byte) error { +func (s *ExtendFootprintTtlOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -28424,77 +30849,54 @@ func (s *HostFunction) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HostFunction)(nil) - _ encoding.BinaryUnmarshaler = (*HostFunction)(nil) + _ encoding.BinaryMarshaler = (*ExtendFootprintTtlOp)(nil) + _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s HostFunction) xdrType() {} +func (s ExtendFootprintTtlOp) xdrType() {} -var _ xdrType = (*HostFunction)(nil) +var _ xdrType = (*ExtendFootprintTtlOp)(nil) -// SorobanAuthorizedFunctionType is an XDR Enum defines as: +// RestoreFootprintOp is an XDR Struct defines as: // -// enum SorobanAuthorizedFunctionType +// struct RestoreFootprintOp // { -// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, -// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 +// ExtensionPoint ext; // }; -type SorobanAuthorizedFunctionType int32 - -const ( - SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn SorobanAuthorizedFunctionType = 0 - SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn SorobanAuthorizedFunctionType = 1 -) - -var sorobanAuthorizedFunctionTypeMap = map[int32]string{ - 0: "SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn", - 1: "SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for SorobanAuthorizedFunctionType -func (e SorobanAuthorizedFunctionType) ValidEnum(v int32) bool { - _, ok := sorobanAuthorizedFunctionTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e SorobanAuthorizedFunctionType) String() string { - name, _ := sorobanAuthorizedFunctionTypeMap[int32(e)] - return name +type RestoreFootprintOp struct { + Ext ExtensionPoint } // EncodeTo encodes this value using the Encoder. -func (e SorobanAuthorizedFunctionType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := sorobanAuthorizedFunctionTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid SorobanAuthorizedFunctionType enum value", e) +func (s *RestoreFootprintOp) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Ext.EncodeTo(e); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + return nil } -var _ decoderFrom = (*SorobanAuthorizedFunctionType)(nil) +var _ decoderFrom = (*RestoreFootprintOp)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *SorobanAuthorizedFunctionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *RestoreFootprintOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding RestoreFootprintOp: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + nTmp, err = s.Ext.DecodeFrom(d, maxDepth) + n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", err) - } - if _, ok := sorobanAuthorizedFunctionTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid SorobanAuthorizedFunctionType enum value", v) + return n, fmt.Errorf("decoding ExtensionPoint: %w", err) } - *e = SorobanAuthorizedFunctionType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanAuthorizedFunctionType) MarshalBinary() ([]byte, error) { +func (s RestoreFootprintOp) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -28502,7 +30904,7 @@ func (s SorobanAuthorizedFunctionType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanAuthorizedFunctionType) UnmarshalBinary(inp []byte) error { +func (s *RestoreFootprintOp) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -28512,1909 +30914,2085 @@ func (s *SorobanAuthorizedFunctionType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*SorobanAuthorizedFunctionType)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunctionType)(nil) + _ encoding.BinaryMarshaler = (*RestoreFootprintOp)(nil) + _ encoding.BinaryUnmarshaler = (*RestoreFootprintOp)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s SorobanAuthorizedFunctionType) xdrType() {} +func (s RestoreFootprintOp) xdrType() {} -var _ xdrType = (*SorobanAuthorizedFunctionType)(nil) +var _ xdrType = (*RestoreFootprintOp)(nil) -// SorobanAuthorizedFunction is an XDR Union defines as: +// OperationBody is an XDR NestedUnion defines as: // -// union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type) -// { -// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: -// InvokeContractArgs contractFn; -// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: -// CreateContractArgs createContractHostFn; -// }; -type SorobanAuthorizedFunction struct { - Type SorobanAuthorizedFunctionType - ContractFn *InvokeContractArgs - CreateContractHostFn *CreateContractArgs +// union switch (OperationType type) +// { +// case CREATE_ACCOUNT: +// CreateAccountOp createAccountOp; +// case PAYMENT: +// PaymentOp paymentOp; +// case PATH_PAYMENT_STRICT_RECEIVE: +// PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp; +// case MANAGE_SELL_OFFER: +// ManageSellOfferOp manageSellOfferOp; +// case CREATE_PASSIVE_SELL_OFFER: +// CreatePassiveSellOfferOp createPassiveSellOfferOp; +// case SET_OPTIONS: +// SetOptionsOp setOptionsOp; +// case CHANGE_TRUST: +// ChangeTrustOp changeTrustOp; +// case ALLOW_TRUST: +// AllowTrustOp allowTrustOp; +// case ACCOUNT_MERGE: +// MuxedAccount destination; +// case INFLATION: +// void; +// case MANAGE_DATA: +// ManageDataOp manageDataOp; +// case BUMP_SEQUENCE: +// BumpSequenceOp bumpSequenceOp; +// case MANAGE_BUY_OFFER: +// ManageBuyOfferOp manageBuyOfferOp; +// case PATH_PAYMENT_STRICT_SEND: +// PathPaymentStrictSendOp pathPaymentStrictSendOp; +// case CREATE_CLAIMABLE_BALANCE: +// CreateClaimableBalanceOp createClaimableBalanceOp; +// case CLAIM_CLAIMABLE_BALANCE: +// ClaimClaimableBalanceOp claimClaimableBalanceOp; +// case BEGIN_SPONSORING_FUTURE_RESERVES: +// BeginSponsoringFutureReservesOp beginSponsoringFutureReservesOp; +// case END_SPONSORING_FUTURE_RESERVES: +// void; +// case REVOKE_SPONSORSHIP: +// RevokeSponsorshipOp revokeSponsorshipOp; +// case CLAWBACK: +// ClawbackOp clawbackOp; +// case CLAWBACK_CLAIMABLE_BALANCE: +// ClawbackClaimableBalanceOp clawbackClaimableBalanceOp; +// case SET_TRUST_LINE_FLAGS: +// SetTrustLineFlagsOp setTrustLineFlagsOp; +// case LIQUIDITY_POOL_DEPOSIT: +// LiquidityPoolDepositOp liquidityPoolDepositOp; +// case LIQUIDITY_POOL_WITHDRAW: +// LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; +// case INVOKE_HOST_FUNCTION: +// InvokeHostFunctionOp invokeHostFunctionOp; +// case EXTEND_FOOTPRINT_TTL: +// ExtendFootprintTTLOp extendFootprintTTLOp; +// case RESTORE_FOOTPRINT: +// RestoreFootprintOp restoreFootprintOp; +// } +type OperationBody struct { + Type OperationType + CreateAccountOp *CreateAccountOp + PaymentOp *PaymentOp + PathPaymentStrictReceiveOp *PathPaymentStrictReceiveOp + ManageSellOfferOp *ManageSellOfferOp + CreatePassiveSellOfferOp *CreatePassiveSellOfferOp + SetOptionsOp *SetOptionsOp + ChangeTrustOp *ChangeTrustOp + AllowTrustOp *AllowTrustOp + Destination *MuxedAccount + ManageDataOp *ManageDataOp + BumpSequenceOp *BumpSequenceOp + ManageBuyOfferOp *ManageBuyOfferOp + PathPaymentStrictSendOp *PathPaymentStrictSendOp + CreateClaimableBalanceOp *CreateClaimableBalanceOp + ClaimClaimableBalanceOp *ClaimClaimableBalanceOp + BeginSponsoringFutureReservesOp *BeginSponsoringFutureReservesOp + RevokeSponsorshipOp *RevokeSponsorshipOp + ClawbackOp *ClawbackOp + ClawbackClaimableBalanceOp *ClawbackClaimableBalanceOp + SetTrustLineFlagsOp *SetTrustLineFlagsOp + LiquidityPoolDepositOp *LiquidityPoolDepositOp + LiquidityPoolWithdrawOp *LiquidityPoolWithdrawOp + InvokeHostFunctionOp *InvokeHostFunctionOp + ExtendFootprintTtlOp *ExtendFootprintTtlOp + RestoreFootprintOp *RestoreFootprintOp } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u SorobanAuthorizedFunction) SwitchFieldName() string { +func (u OperationBody) SwitchFieldName() string { return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of SorobanAuthorizedFunction -func (u SorobanAuthorizedFunction) ArmForSwitch(sw int32) (string, bool) { - switch SorobanAuthorizedFunctionType(sw) { - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: - return "ContractFn", true - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: - return "CreateContractHostFn", true +// the value for an instance of OperationBody +func (u OperationBody) ArmForSwitch(sw int32) (string, bool) { + switch OperationType(sw) { + case OperationTypeCreateAccount: + return "CreateAccountOp", true + case OperationTypePayment: + return "PaymentOp", true + case OperationTypePathPaymentStrictReceive: + return "PathPaymentStrictReceiveOp", true + case OperationTypeManageSellOffer: + return "ManageSellOfferOp", true + case OperationTypeCreatePassiveSellOffer: + return "CreatePassiveSellOfferOp", true + case OperationTypeSetOptions: + return "SetOptionsOp", true + case OperationTypeChangeTrust: + return "ChangeTrustOp", true + case OperationTypeAllowTrust: + return "AllowTrustOp", true + case OperationTypeAccountMerge: + return "Destination", true + case OperationTypeInflation: + return "", true + case OperationTypeManageData: + return "ManageDataOp", true + case OperationTypeBumpSequence: + return "BumpSequenceOp", true + case OperationTypeManageBuyOffer: + return "ManageBuyOfferOp", true + case OperationTypePathPaymentStrictSend: + return "PathPaymentStrictSendOp", true + case OperationTypeCreateClaimableBalance: + return "CreateClaimableBalanceOp", true + case OperationTypeClaimClaimableBalance: + return "ClaimClaimableBalanceOp", true + case OperationTypeBeginSponsoringFutureReserves: + return "BeginSponsoringFutureReservesOp", true + case OperationTypeEndSponsoringFutureReserves: + return "", true + case OperationTypeRevokeSponsorship: + return "RevokeSponsorshipOp", true + case OperationTypeClawback: + return "ClawbackOp", true + case OperationTypeClawbackClaimableBalance: + return "ClawbackClaimableBalanceOp", true + case OperationTypeSetTrustLineFlags: + return "SetTrustLineFlagsOp", true + case OperationTypeLiquidityPoolDeposit: + return "LiquidityPoolDepositOp", true + case OperationTypeLiquidityPoolWithdraw: + return "LiquidityPoolWithdrawOp", true + case OperationTypeInvokeHostFunction: + return "InvokeHostFunctionOp", true + case OperationTypeExtendFootprintTtl: + return "ExtendFootprintTtlOp", true + case OperationTypeRestoreFootprint: + return "RestoreFootprintOp", true } return "-", false } -// NewSorobanAuthorizedFunction creates a new SorobanAuthorizedFunction. -func NewSorobanAuthorizedFunction(aType SorobanAuthorizedFunctionType, value interface{}) (result SorobanAuthorizedFunction, err error) { +// NewOperationBody creates a new OperationBody. +func NewOperationBody(aType OperationType, value interface{}) (result OperationBody, err error) { result.Type = aType - switch SorobanAuthorizedFunctionType(aType) { - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: - tv, ok := value.(InvokeContractArgs) + switch OperationType(aType) { + case OperationTypeCreateAccount: + tv, ok := value.(CreateAccountOp) + if !ok { + err = errors.New("invalid value, must be CreateAccountOp") + return + } + result.CreateAccountOp = &tv + case OperationTypePayment: + tv, ok := value.(PaymentOp) + if !ok { + err = errors.New("invalid value, must be PaymentOp") + return + } + result.PaymentOp = &tv + case OperationTypePathPaymentStrictReceive: + tv, ok := value.(PathPaymentStrictReceiveOp) + if !ok { + err = errors.New("invalid value, must be PathPaymentStrictReceiveOp") + return + } + result.PathPaymentStrictReceiveOp = &tv + case OperationTypeManageSellOffer: + tv, ok := value.(ManageSellOfferOp) + if !ok { + err = errors.New("invalid value, must be ManageSellOfferOp") + return + } + result.ManageSellOfferOp = &tv + case OperationTypeCreatePassiveSellOffer: + tv, ok := value.(CreatePassiveSellOfferOp) + if !ok { + err = errors.New("invalid value, must be CreatePassiveSellOfferOp") + return + } + result.CreatePassiveSellOfferOp = &tv + case OperationTypeSetOptions: + tv, ok := value.(SetOptionsOp) + if !ok { + err = errors.New("invalid value, must be SetOptionsOp") + return + } + result.SetOptionsOp = &tv + case OperationTypeChangeTrust: + tv, ok := value.(ChangeTrustOp) + if !ok { + err = errors.New("invalid value, must be ChangeTrustOp") + return + } + result.ChangeTrustOp = &tv + case OperationTypeAllowTrust: + tv, ok := value.(AllowTrustOp) + if !ok { + err = errors.New("invalid value, must be AllowTrustOp") + return + } + result.AllowTrustOp = &tv + case OperationTypeAccountMerge: + tv, ok := value.(MuxedAccount) + if !ok { + err = errors.New("invalid value, must be MuxedAccount") + return + } + result.Destination = &tv + case OperationTypeInflation: + // void + case OperationTypeManageData: + tv, ok := value.(ManageDataOp) + if !ok { + err = errors.New("invalid value, must be ManageDataOp") + return + } + result.ManageDataOp = &tv + case OperationTypeBumpSequence: + tv, ok := value.(BumpSequenceOp) + if !ok { + err = errors.New("invalid value, must be BumpSequenceOp") + return + } + result.BumpSequenceOp = &tv + case OperationTypeManageBuyOffer: + tv, ok := value.(ManageBuyOfferOp) + if !ok { + err = errors.New("invalid value, must be ManageBuyOfferOp") + return + } + result.ManageBuyOfferOp = &tv + case OperationTypePathPaymentStrictSend: + tv, ok := value.(PathPaymentStrictSendOp) + if !ok { + err = errors.New("invalid value, must be PathPaymentStrictSendOp") + return + } + result.PathPaymentStrictSendOp = &tv + case OperationTypeCreateClaimableBalance: + tv, ok := value.(CreateClaimableBalanceOp) + if !ok { + err = errors.New("invalid value, must be CreateClaimableBalanceOp") + return + } + result.CreateClaimableBalanceOp = &tv + case OperationTypeClaimClaimableBalance: + tv, ok := value.(ClaimClaimableBalanceOp) + if !ok { + err = errors.New("invalid value, must be ClaimClaimableBalanceOp") + return + } + result.ClaimClaimableBalanceOp = &tv + case OperationTypeBeginSponsoringFutureReserves: + tv, ok := value.(BeginSponsoringFutureReservesOp) + if !ok { + err = errors.New("invalid value, must be BeginSponsoringFutureReservesOp") + return + } + result.BeginSponsoringFutureReservesOp = &tv + case OperationTypeEndSponsoringFutureReserves: + // void + case OperationTypeRevokeSponsorship: + tv, ok := value.(RevokeSponsorshipOp) + if !ok { + err = errors.New("invalid value, must be RevokeSponsorshipOp") + return + } + result.RevokeSponsorshipOp = &tv + case OperationTypeClawback: + tv, ok := value.(ClawbackOp) + if !ok { + err = errors.New("invalid value, must be ClawbackOp") + return + } + result.ClawbackOp = &tv + case OperationTypeClawbackClaimableBalance: + tv, ok := value.(ClawbackClaimableBalanceOp) + if !ok { + err = errors.New("invalid value, must be ClawbackClaimableBalanceOp") + return + } + result.ClawbackClaimableBalanceOp = &tv + case OperationTypeSetTrustLineFlags: + tv, ok := value.(SetTrustLineFlagsOp) + if !ok { + err = errors.New("invalid value, must be SetTrustLineFlagsOp") + return + } + result.SetTrustLineFlagsOp = &tv + case OperationTypeLiquidityPoolDeposit: + tv, ok := value.(LiquidityPoolDepositOp) if !ok { - err = errors.New("invalid value, must be InvokeContractArgs") + err = errors.New("invalid value, must be LiquidityPoolDepositOp") return } - result.ContractFn = &tv - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: - tv, ok := value.(CreateContractArgs) + result.LiquidityPoolDepositOp = &tv + case OperationTypeLiquidityPoolWithdraw: + tv, ok := value.(LiquidityPoolWithdrawOp) if !ok { - err = errors.New("invalid value, must be CreateContractArgs") + err = errors.New("invalid value, must be LiquidityPoolWithdrawOp") return } - result.CreateContractHostFn = &tv + result.LiquidityPoolWithdrawOp = &tv + case OperationTypeInvokeHostFunction: + tv, ok := value.(InvokeHostFunctionOp) + if !ok { + err = errors.New("invalid value, must be InvokeHostFunctionOp") + return + } + result.InvokeHostFunctionOp = &tv + case OperationTypeExtendFootprintTtl: + tv, ok := value.(ExtendFootprintTtlOp) + if !ok { + err = errors.New("invalid value, must be ExtendFootprintTtlOp") + return + } + result.ExtendFootprintTtlOp = &tv + case OperationTypeRestoreFootprint: + tv, ok := value.(RestoreFootprintOp) + if !ok { + err = errors.New("invalid value, must be RestoreFootprintOp") + return + } + result.RestoreFootprintOp = &tv } return } -// MustContractFn retrieves the ContractFn value from the union, +// MustCreateAccountOp retrieves the CreateAccountOp value from the union, // panicing if the value is not set. -func (u SorobanAuthorizedFunction) MustContractFn() InvokeContractArgs { - val, ok := u.GetContractFn() +func (u OperationBody) MustCreateAccountOp() CreateAccountOp { + val, ok := u.GetCreateAccountOp() if !ok { - panic("arm ContractFn is not set") + panic("arm CreateAccountOp is not set") } return val } -// GetContractFn retrieves the ContractFn value from the union, +// GetCreateAccountOp retrieves the CreateAccountOp value from the union, // returning ok if the union's switch indicated the value is valid. -func (u SorobanAuthorizedFunction) GetContractFn() (result InvokeContractArgs, ok bool) { +func (u OperationBody) GetCreateAccountOp() (result CreateAccountOp, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "ContractFn" { - result = *u.ContractFn + if armName == "CreateAccountOp" { + result = *u.CreateAccountOp ok = true } return } -// MustCreateContractHostFn retrieves the CreateContractHostFn value from the union, +// MustPaymentOp retrieves the PaymentOp value from the union, // panicing if the value is not set. -func (u SorobanAuthorizedFunction) MustCreateContractHostFn() CreateContractArgs { - val, ok := u.GetCreateContractHostFn() +func (u OperationBody) MustPaymentOp() PaymentOp { + val, ok := u.GetPaymentOp() if !ok { - panic("arm CreateContractHostFn is not set") + panic("arm PaymentOp is not set") } return val } -// GetCreateContractHostFn retrieves the CreateContractHostFn value from the union, +// GetPaymentOp retrieves the PaymentOp value from the union, // returning ok if the union's switch indicated the value is valid. -func (u SorobanAuthorizedFunction) GetCreateContractHostFn() (result CreateContractArgs, ok bool) { +func (u OperationBody) GetPaymentOp() (result PaymentOp, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "CreateContractHostFn" { - result = *u.CreateContractHostFn + if armName == "PaymentOp" { + result = *u.PaymentOp ok = true } return } -// EncodeTo encodes this value using the Encoder. -func (u SorobanAuthorizedFunction) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.Type.EncodeTo(e); err != nil { - return err - } - switch SorobanAuthorizedFunctionType(u.Type) { - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: - if err = (*u.ContractFn).EncodeTo(e); err != nil { - return err - } - return nil - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: - if err = (*u.CreateContractHostFn).EncodeTo(e); err != nil { - return err - } - return nil +// MustPathPaymentStrictReceiveOp retrieves the PathPaymentStrictReceiveOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustPathPaymentStrictReceiveOp() PathPaymentStrictReceiveOp { + val, ok := u.GetPathPaymentStrictReceiveOp() + + if !ok { + panic("arm PathPaymentStrictReceiveOp is not set") } - return fmt.Errorf("Type (SorobanAuthorizedFunctionType) switch value '%d' is not valid for union SorobanAuthorizedFunction", u.Type) + + return val } -var _ decoderFrom = (*SorobanAuthorizedFunction)(nil) +// GetPathPaymentStrictReceiveOp retrieves the PathPaymentStrictReceiveOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetPathPaymentStrictReceiveOp() (result PathPaymentStrictReceiveOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (u *SorobanAuthorizedFunction) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanAuthorizedFunction: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %w", err) - } - switch SorobanAuthorizedFunctionType(u.Type) { - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: - u.ContractFn = new(InvokeContractArgs) - nTmp, err = (*u.ContractFn).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding InvokeContractArgs: %w", err) - } - return n, nil - case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: - u.CreateContractHostFn = new(CreateContractArgs) - nTmp, err = (*u.CreateContractHostFn).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding CreateContractArgs: %w", err) - } - return n, nil + if armName == "PathPaymentStrictReceiveOp" { + result = *u.PathPaymentStrictReceiveOp + ok = true } - return n, fmt.Errorf("union SorobanAuthorizedFunction has invalid Type (SorobanAuthorizedFunctionType) switch value '%d'", u.Type) -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanAuthorizedFunction) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanAuthorizedFunction) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustManageSellOfferOp retrieves the ManageSellOfferOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustManageSellOfferOp() ManageSellOfferOp { + val, ok := u.GetManageSellOfferOp() -var ( - _ encoding.BinaryMarshaler = (*SorobanAuthorizedFunction)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunction)(nil) -) + if !ok { + panic("arm ManageSellOfferOp is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s SorobanAuthorizedFunction) xdrType() {} + return val +} -var _ xdrType = (*SorobanAuthorizedFunction)(nil) +// GetManageSellOfferOp retrieves the ManageSellOfferOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetManageSellOfferOp() (result ManageSellOfferOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// SorobanAuthorizedInvocation is an XDR Struct defines as: -// -// struct SorobanAuthorizedInvocation -// { -// SorobanAuthorizedFunction function; -// SorobanAuthorizedInvocation subInvocations<>; -// }; -type SorobanAuthorizedInvocation struct { - Function SorobanAuthorizedFunction - SubInvocations []SorobanAuthorizedInvocation + if armName == "ManageSellOfferOp" { + result = *u.ManageSellOfferOp + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (s *SorobanAuthorizedInvocation) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Function.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.SubInvocations))); err != nil { - return err - } - for i := 0; i < len(s.SubInvocations); i++ { - if err = s.SubInvocations[i].EncodeTo(e); err != nil { - return err - } +// MustCreatePassiveSellOfferOp retrieves the CreatePassiveSellOfferOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustCreatePassiveSellOfferOp() CreatePassiveSellOfferOp { + val, ok := u.GetCreatePassiveSellOfferOp() + + if !ok { + panic("arm CreatePassiveSellOfferOp is not set") } - return nil + + return val } -var _ decoderFrom = (*SorobanAuthorizedInvocation)(nil) +// GetCreatePassiveSellOfferOp retrieves the CreatePassiveSellOfferOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetCreatePassiveSellOfferOp() (result CreatePassiveSellOfferOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (s *SorobanAuthorizedInvocation) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Function.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedFunction: %w", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) - } - s.SubInvocations = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: length (%d) exceeds remaining input length (%d)", l, il) - } - s.SubInvocations = make([]SorobanAuthorizedInvocation, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.SubInvocations[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) - } - } + if armName == "CreatePassiveSellOfferOp" { + result = *u.CreatePassiveSellOfferOp + ok = true } - return n, nil -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanAuthorizedInvocation) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanAuthorizedInvocation) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustSetOptionsOp retrieves the SetOptionsOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustSetOptionsOp() SetOptionsOp { + val, ok := u.GetSetOptionsOp() -var ( - _ encoding.BinaryMarshaler = (*SorobanAuthorizedInvocation)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedInvocation)(nil) -) + if !ok { + panic("arm SetOptionsOp is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s SorobanAuthorizedInvocation) xdrType() {} + return val +} -var _ xdrType = (*SorobanAuthorizedInvocation)(nil) +// GetSetOptionsOp retrieves the SetOptionsOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetSetOptionsOp() (result SetOptionsOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// SorobanAddressCredentials is an XDR Struct defines as: -// -// struct SorobanAddressCredentials -// { -// SCAddress address; -// int64 nonce; -// uint32 signatureExpirationLedger; -// SCVal signature; -// }; -type SorobanAddressCredentials struct { - Address ScAddress - Nonce Int64 - SignatureExpirationLedger Uint32 - Signature ScVal + if armName == "SetOptionsOp" { + result = *u.SetOptionsOp + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (s *SorobanAddressCredentials) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Address.EncodeTo(e); err != nil { - return err - } - if err = s.Nonce.EncodeTo(e); err != nil { - return err - } - if err = s.SignatureExpirationLedger.EncodeTo(e); err != nil { - return err - } - if err = s.Signature.EncodeTo(e); err != nil { - return err +// MustChangeTrustOp retrieves the ChangeTrustOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustChangeTrustOp() ChangeTrustOp { + val, ok := u.GetChangeTrustOp() + + if !ok { + panic("arm ChangeTrustOp is not set") } - return nil + + return val } -var _ decoderFrom = (*SorobanAddressCredentials)(nil) +// GetChangeTrustOp retrieves the ChangeTrustOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetChangeTrustOp() (result ChangeTrustOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (s *SorobanAddressCredentials) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanAddressCredentials: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Address.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScAddress: %w", err) - } - nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.Signature.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScVal: %w", err) + if armName == "ChangeTrustOp" { + result = *u.ChangeTrustOp + ok = true } - return n, nil -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanAddressCredentials) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanAddressCredentials) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err +// MustAllowTrustOp retrieves the AllowTrustOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustAllowTrustOp() AllowTrustOp { + val, ok := u.GetAllowTrustOp() + + if !ok { + panic("arm AllowTrustOp is not set") + } + + return val } -var ( - _ encoding.BinaryMarshaler = (*SorobanAddressCredentials)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanAddressCredentials)(nil) -) +// GetAllowTrustOp retrieves the AllowTrustOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetAllowTrustOp() (result AllowTrustOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// xdrType signals that this type represents XDR values defined by this package. -func (s SorobanAddressCredentials) xdrType() {} + if armName == "AllowTrustOp" { + result = *u.AllowTrustOp + ok = true + } -var _ xdrType = (*SorobanAddressCredentials)(nil) + return +} -// SorobanCredentialsType is an XDR Enum defines as: -// -// enum SorobanCredentialsType -// { -// SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0, -// SOROBAN_CREDENTIALS_ADDRESS = 1 -// }; -type SorobanCredentialsType int32 +// MustDestination retrieves the Destination value from the union, +// panicing if the value is not set. +func (u OperationBody) MustDestination() MuxedAccount { + val, ok := u.GetDestination() -const ( - SorobanCredentialsTypeSorobanCredentialsSourceAccount SorobanCredentialsType = 0 - SorobanCredentialsTypeSorobanCredentialsAddress SorobanCredentialsType = 1 -) + if !ok { + panic("arm Destination is not set") + } -var sorobanCredentialsTypeMap = map[int32]string{ - 0: "SorobanCredentialsTypeSorobanCredentialsSourceAccount", - 1: "SorobanCredentialsTypeSorobanCredentialsAddress", + return val } -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for SorobanCredentialsType -func (e SorobanCredentialsType) ValidEnum(v int32) bool { - _, ok := sorobanCredentialsTypeMap[v] - return ok -} +// GetDestination retrieves the Destination value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetDestination() (result MuxedAccount, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// String returns the name of `e` -func (e SorobanCredentialsType) String() string { - name, _ := sorobanCredentialsTypeMap[int32(e)] - return name + if armName == "Destination" { + result = *u.Destination + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (e SorobanCredentialsType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := sorobanCredentialsTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid SorobanCredentialsType enum value", e) +// MustManageDataOp retrieves the ManageDataOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustManageDataOp() ManageDataOp { + val, ok := u.GetManageDataOp() + + if !ok { + panic("arm ManageDataOp is not set") } - _, err := enc.EncodeInt(int32(e)) - return err + + return val } -var _ decoderFrom = (*SorobanCredentialsType)(nil) +// GetManageDataOp retrieves the ManageDataOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetManageDataOp() (result ManageDataOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (e *SorobanCredentialsType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanCredentialsType: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding SorobanCredentialsType: %w", err) + if armName == "ManageDataOp" { + result = *u.ManageDataOp + ok = true } - if _, ok := sorobanCredentialsTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid SorobanCredentialsType enum value", v) + + return +} + +// MustBumpSequenceOp retrieves the BumpSequenceOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustBumpSequenceOp() BumpSequenceOp { + val, ok := u.GetBumpSequenceOp() + + if !ok { + panic("arm BumpSequenceOp is not set") } - *e = SorobanCredentialsType(v) - return n, nil + + return val } -// MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanCredentialsType) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err +// GetBumpSequenceOp retrieves the BumpSequenceOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetBumpSequenceOp() (result BumpSequenceOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "BumpSequenceOp" { + result = *u.BumpSequenceOp + ok = true + } + + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanCredentialsType) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustManageBuyOfferOp retrieves the ManageBuyOfferOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustManageBuyOfferOp() ManageBuyOfferOp { + val, ok := u.GetManageBuyOfferOp() -var ( - _ encoding.BinaryMarshaler = (*SorobanCredentialsType)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanCredentialsType)(nil) -) + if !ok { + panic("arm ManageBuyOfferOp is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s SorobanCredentialsType) xdrType() {} + return val +} -var _ xdrType = (*SorobanCredentialsType)(nil) +// GetManageBuyOfferOp retrieves the ManageBuyOfferOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetManageBuyOfferOp() (result ManageBuyOfferOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// SorobanCredentials is an XDR Union defines as: -// -// union SorobanCredentials switch (SorobanCredentialsType type) -// { -// case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: -// void; -// case SOROBAN_CREDENTIALS_ADDRESS: -// SorobanAddressCredentials address; -// }; -type SorobanCredentials struct { - Type SorobanCredentialsType - Address *SorobanAddressCredentials -} + if armName == "ManageBuyOfferOp" { + result = *u.ManageBuyOfferOp + ok = true + } -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u SorobanCredentials) SwitchFieldName() string { - return "Type" + return } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of SorobanCredentials -func (u SorobanCredentials) ArmForSwitch(sw int32) (string, bool) { - switch SorobanCredentialsType(sw) { - case SorobanCredentialsTypeSorobanCredentialsSourceAccount: - return "", true - case SorobanCredentialsTypeSorobanCredentialsAddress: - return "Address", true +// MustPathPaymentStrictSendOp retrieves the PathPaymentStrictSendOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustPathPaymentStrictSendOp() PathPaymentStrictSendOp { + val, ok := u.GetPathPaymentStrictSendOp() + + if !ok { + panic("arm PathPaymentStrictSendOp is not set") } - return "-", false + + return val } -// NewSorobanCredentials creates a new SorobanCredentials. -func NewSorobanCredentials(aType SorobanCredentialsType, value interface{}) (result SorobanCredentials, err error) { - result.Type = aType - switch SorobanCredentialsType(aType) { - case SorobanCredentialsTypeSorobanCredentialsSourceAccount: - // void - case SorobanCredentialsTypeSorobanCredentialsAddress: - tv, ok := value.(SorobanAddressCredentials) - if !ok { - err = errors.New("invalid value, must be SorobanAddressCredentials") - return - } - result.Address = &tv +// GetPathPaymentStrictSendOp retrieves the PathPaymentStrictSendOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetPathPaymentStrictSendOp() (result PathPaymentStrictSendOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "PathPaymentStrictSendOp" { + result = *u.PathPaymentStrictSendOp + ok = true } + return } -// MustAddress retrieves the Address value from the union, +// MustCreateClaimableBalanceOp retrieves the CreateClaimableBalanceOp value from the union, // panicing if the value is not set. -func (u SorobanCredentials) MustAddress() SorobanAddressCredentials { - val, ok := u.GetAddress() +func (u OperationBody) MustCreateClaimableBalanceOp() CreateClaimableBalanceOp { + val, ok := u.GetCreateClaimableBalanceOp() if !ok { - panic("arm Address is not set") + panic("arm CreateClaimableBalanceOp is not set") } return val } -// GetAddress retrieves the Address value from the union, +// GetCreateClaimableBalanceOp retrieves the CreateClaimableBalanceOp value from the union, // returning ok if the union's switch indicated the value is valid. -func (u SorobanCredentials) GetAddress() (result SorobanAddressCredentials, ok bool) { +func (u OperationBody) GetCreateClaimableBalanceOp() (result CreateClaimableBalanceOp, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Address" { - result = *u.Address + if armName == "CreateClaimableBalanceOp" { + result = *u.CreateClaimableBalanceOp ok = true } return } -// EncodeTo encodes this value using the Encoder. -func (u SorobanCredentials) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.Type.EncodeTo(e); err != nil { - return err - } - switch SorobanCredentialsType(u.Type) { - case SorobanCredentialsTypeSorobanCredentialsSourceAccount: - // Void - return nil - case SorobanCredentialsTypeSorobanCredentialsAddress: - if err = (*u.Address).EncodeTo(e); err != nil { - return err - } - return nil +// MustClaimClaimableBalanceOp retrieves the ClaimClaimableBalanceOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustClaimClaimableBalanceOp() ClaimClaimableBalanceOp { + val, ok := u.GetClaimClaimableBalanceOp() + + if !ok { + panic("arm ClaimClaimableBalanceOp is not set") } - return fmt.Errorf("Type (SorobanCredentialsType) switch value '%d' is not valid for union SorobanCredentials", u.Type) + + return val } -var _ decoderFrom = (*SorobanCredentials)(nil) +// GetClaimClaimableBalanceOp retrieves the ClaimClaimableBalanceOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetClaimClaimableBalanceOp() (result ClaimClaimableBalanceOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (u *SorobanCredentials) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanCredentials: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanCredentialsType: %w", err) - } - switch SorobanCredentialsType(u.Type) { - case SorobanCredentialsTypeSorobanCredentialsSourceAccount: - // Void - return n, nil - case SorobanCredentialsTypeSorobanCredentialsAddress: - u.Address = new(SorobanAddressCredentials) - nTmp, err = (*u.Address).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAddressCredentials: %w", err) - } - return n, nil + if armName == "ClaimClaimableBalanceOp" { + result = *u.ClaimClaimableBalanceOp + ok = true } - return n, fmt.Errorf("union SorobanCredentials has invalid Type (SorobanCredentialsType) switch value '%d'", u.Type) -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanCredentials) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanCredentials) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustBeginSponsoringFutureReservesOp retrieves the BeginSponsoringFutureReservesOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustBeginSponsoringFutureReservesOp() BeginSponsoringFutureReservesOp { + val, ok := u.GetBeginSponsoringFutureReservesOp() -var ( - _ encoding.BinaryMarshaler = (*SorobanCredentials)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanCredentials)(nil) -) + if !ok { + panic("arm BeginSponsoringFutureReservesOp is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s SorobanCredentials) xdrType() {} + return val +} -var _ xdrType = (*SorobanCredentials)(nil) +// GetBeginSponsoringFutureReservesOp retrieves the BeginSponsoringFutureReservesOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetBeginSponsoringFutureReservesOp() (result BeginSponsoringFutureReservesOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// SorobanAuthorizationEntry is an XDR Struct defines as: -// -// struct SorobanAuthorizationEntry -// { -// SorobanCredentials credentials; -// SorobanAuthorizedInvocation rootInvocation; -// }; -type SorobanAuthorizationEntry struct { - Credentials SorobanCredentials - RootInvocation SorobanAuthorizedInvocation + if armName == "BeginSponsoringFutureReservesOp" { + result = *u.BeginSponsoringFutureReservesOp + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (s *SorobanAuthorizationEntry) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Credentials.EncodeTo(e); err != nil { - return err - } - if err = s.RootInvocation.EncodeTo(e); err != nil { - return err +// MustRevokeSponsorshipOp retrieves the RevokeSponsorshipOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustRevokeSponsorshipOp() RevokeSponsorshipOp { + val, ok := u.GetRevokeSponsorshipOp() + + if !ok { + panic("arm RevokeSponsorshipOp is not set") } - return nil + + return val } -var _ decoderFrom = (*SorobanAuthorizationEntry)(nil) +// GetRevokeSponsorshipOp retrieves the RevokeSponsorshipOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetRevokeSponsorshipOp() (result RevokeSponsorshipOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (s *SorobanAuthorizationEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Credentials.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanCredentials: %w", err) - } - nTmp, err = s.RootInvocation.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) + if armName == "RevokeSponsorshipOp" { + result = *u.RevokeSponsorshipOp + ok = true } - return n, nil -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s SorobanAuthorizationEntry) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *SorobanAuthorizationEntry) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustClawbackOp retrieves the ClawbackOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustClawbackOp() ClawbackOp { + val, ok := u.GetClawbackOp() -var ( - _ encoding.BinaryMarshaler = (*SorobanAuthorizationEntry)(nil) - _ encoding.BinaryUnmarshaler = (*SorobanAuthorizationEntry)(nil) -) + if !ok { + panic("arm ClawbackOp is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s SorobanAuthorizationEntry) xdrType() {} + return val +} -var _ xdrType = (*SorobanAuthorizationEntry)(nil) +// GetClawbackOp retrieves the ClawbackOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetClawbackOp() (result ClawbackOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// InvokeHostFunctionOp is an XDR Struct defines as: -// -// struct InvokeHostFunctionOp -// { -// // Host function to invoke. -// HostFunction hostFunction; -// // Per-address authorizations for this host function. -// SorobanAuthorizationEntry auth<>; -// }; -type InvokeHostFunctionOp struct { - HostFunction HostFunction - Auth []SorobanAuthorizationEntry + if armName == "ClawbackOp" { + result = *u.ClawbackOp + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (s *InvokeHostFunctionOp) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.HostFunction.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.Auth))); err != nil { - return err - } - for i := 0; i < len(s.Auth); i++ { - if err = s.Auth[i].EncodeTo(e); err != nil { - return err - } +// MustClawbackClaimableBalanceOp retrieves the ClawbackClaimableBalanceOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustClawbackClaimableBalanceOp() ClawbackClaimableBalanceOp { + val, ok := u.GetClawbackClaimableBalanceOp() + + if !ok { + panic("arm ClawbackClaimableBalanceOp is not set") } - return nil + + return val } -var _ decoderFrom = (*InvokeHostFunctionOp)(nil) +// GetClawbackClaimableBalanceOp retrieves the ClawbackClaimableBalanceOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetClawbackClaimableBalanceOp() (result ClawbackClaimableBalanceOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (s *InvokeHostFunctionOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding InvokeHostFunctionOp: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.HostFunction.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding HostFunction: %w", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", err) - } - s.Auth = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding SorobanAuthorizationEntry: length (%d) exceeds remaining input length (%d)", l, il) - } - s.Auth = make([]SorobanAuthorizationEntry, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Auth[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %w", err) - } - } + if armName == "ClawbackClaimableBalanceOp" { + result = *u.ClawbackClaimableBalanceOp + ok = true } - return n, nil -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s InvokeHostFunctionOp) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *InvokeHostFunctionOp) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustSetTrustLineFlagsOp retrieves the SetTrustLineFlagsOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustSetTrustLineFlagsOp() SetTrustLineFlagsOp { + val, ok := u.GetSetTrustLineFlagsOp() -var ( - _ encoding.BinaryMarshaler = (*InvokeHostFunctionOp)(nil) - _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionOp)(nil) -) + if !ok { + panic("arm SetTrustLineFlagsOp is not set") + } -// xdrType signals that this type represents XDR values defined by this package. -func (s InvokeHostFunctionOp) xdrType() {} + return val +} -var _ xdrType = (*InvokeHostFunctionOp)(nil) +// GetSetTrustLineFlagsOp retrieves the SetTrustLineFlagsOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetSetTrustLineFlagsOp() (result SetTrustLineFlagsOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// ExtendFootprintTtlOp is an XDR Struct defines as: -// -// struct ExtendFootprintTTLOp -// { -// ExtensionPoint ext; -// uint32 extendTo; -// }; -type ExtendFootprintTtlOp struct { - Ext ExtensionPoint - ExtendTo Uint32 + if armName == "SetTrustLineFlagsOp" { + result = *u.SetTrustLineFlagsOp + ok = true + } + + return } -// EncodeTo encodes this value using the Encoder. -func (s *ExtendFootprintTtlOp) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Ext.EncodeTo(e); err != nil { - return err - } - if err = s.ExtendTo.EncodeTo(e); err != nil { - return err +// MustLiquidityPoolDepositOp retrieves the LiquidityPoolDepositOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustLiquidityPoolDepositOp() LiquidityPoolDepositOp { + val, ok := u.GetLiquidityPoolDepositOp() + + if !ok { + panic("arm LiquidityPoolDepositOp is not set") } - return nil + + return val } -var _ decoderFrom = (*ExtendFootprintTtlOp)(nil) +// GetLiquidityPoolDepositOp retrieves the LiquidityPoolDepositOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetLiquidityPoolDepositOp() (result LiquidityPoolDepositOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (s *ExtendFootprintTtlOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding ExtendFootprintTtlOp: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %w", err) - } - nTmp, err = s.ExtendTo.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + if armName == "LiquidityPoolDepositOp" { + result = *u.LiquidityPoolDepositOp + ok = true } - return n, nil -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ExtendFootprintTtlOp) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ExtendFootprintTtlOp) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err -} +// MustLiquidityPoolWithdrawOp retrieves the LiquidityPoolWithdrawOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustLiquidityPoolWithdrawOp() LiquidityPoolWithdrawOp { + val, ok := u.GetLiquidityPoolWithdrawOp() + + if !ok { + panic("arm LiquidityPoolWithdrawOp is not set") + } -var ( - _ encoding.BinaryMarshaler = (*ExtendFootprintTtlOp)(nil) - _ encoding.BinaryUnmarshaler = (*ExtendFootprintTtlOp)(nil) -) + return val +} -// xdrType signals that this type represents XDR values defined by this package. -func (s ExtendFootprintTtlOp) xdrType() {} +// GetLiquidityPoolWithdrawOp retrieves the LiquidityPoolWithdrawOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetLiquidityPoolWithdrawOp() (result LiquidityPoolWithdrawOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -var _ xdrType = (*ExtendFootprintTtlOp)(nil) + if armName == "LiquidityPoolWithdrawOp" { + result = *u.LiquidityPoolWithdrawOp + ok = true + } -// RestoreFootprintOp is an XDR Struct defines as: -// -// struct RestoreFootprintOp -// { -// ExtensionPoint ext; -// }; -type RestoreFootprintOp struct { - Ext ExtensionPoint + return } -// EncodeTo encodes this value using the Encoder. -func (s *RestoreFootprintOp) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Ext.EncodeTo(e); err != nil { - return err +// MustInvokeHostFunctionOp retrieves the InvokeHostFunctionOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustInvokeHostFunctionOp() InvokeHostFunctionOp { + val, ok := u.GetInvokeHostFunctionOp() + + if !ok { + panic("arm InvokeHostFunctionOp is not set") } - return nil + + return val } -var _ decoderFrom = (*RestoreFootprintOp)(nil) +// GetInvokeHostFunctionOp retrieves the InvokeHostFunctionOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetInvokeHostFunctionOp() (result InvokeHostFunctionOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// DecodeFrom decodes this value using the Decoder. -func (s *RestoreFootprintOp) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding RestoreFootprintOp: %w", ErrMaxDecodingDepthReached) - } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.Ext.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ExtensionPoint: %w", err) + if armName == "InvokeHostFunctionOp" { + result = *u.InvokeHostFunctionOp + ok = true } - return n, nil -} -// MarshalBinary implements encoding.BinaryMarshaler. -func (s RestoreFootprintOp) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err + return } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *RestoreFootprintOp) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err +// MustExtendFootprintTtlOp retrieves the ExtendFootprintTtlOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustExtendFootprintTtlOp() ExtendFootprintTtlOp { + val, ok := u.GetExtendFootprintTtlOp() + + if !ok { + panic("arm ExtendFootprintTtlOp is not set") + } + + return val } -var ( - _ encoding.BinaryMarshaler = (*RestoreFootprintOp)(nil) - _ encoding.BinaryUnmarshaler = (*RestoreFootprintOp)(nil) -) +// GetExtendFootprintTtlOp retrieves the ExtendFootprintTtlOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetExtendFootprintTtlOp() (result ExtendFootprintTtlOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) -// xdrType signals that this type represents XDR values defined by this package. -func (s RestoreFootprintOp) xdrType() {} + if armName == "ExtendFootprintTtlOp" { + result = *u.ExtendFootprintTtlOp + ok = true + } -var _ xdrType = (*RestoreFootprintOp)(nil) + return +} -// OperationBody is an XDR NestedUnion defines as: -// -// union switch (OperationType type) -// { -// case CREATE_ACCOUNT: -// CreateAccountOp createAccountOp; -// case PAYMENT: -// PaymentOp paymentOp; -// case PATH_PAYMENT_STRICT_RECEIVE: -// PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp; -// case MANAGE_SELL_OFFER: -// ManageSellOfferOp manageSellOfferOp; -// case CREATE_PASSIVE_SELL_OFFER: -// CreatePassiveSellOfferOp createPassiveSellOfferOp; -// case SET_OPTIONS: -// SetOptionsOp setOptionsOp; -// case CHANGE_TRUST: -// ChangeTrustOp changeTrustOp; -// case ALLOW_TRUST: -// AllowTrustOp allowTrustOp; -// case ACCOUNT_MERGE: -// MuxedAccount destination; -// case INFLATION: -// void; -// case MANAGE_DATA: -// ManageDataOp manageDataOp; -// case BUMP_SEQUENCE: -// BumpSequenceOp bumpSequenceOp; -// case MANAGE_BUY_OFFER: -// ManageBuyOfferOp manageBuyOfferOp; -// case PATH_PAYMENT_STRICT_SEND: -// PathPaymentStrictSendOp pathPaymentStrictSendOp; -// case CREATE_CLAIMABLE_BALANCE: -// CreateClaimableBalanceOp createClaimableBalanceOp; -// case CLAIM_CLAIMABLE_BALANCE: -// ClaimClaimableBalanceOp claimClaimableBalanceOp; -// case BEGIN_SPONSORING_FUTURE_RESERVES: -// BeginSponsoringFutureReservesOp beginSponsoringFutureReservesOp; -// case END_SPONSORING_FUTURE_RESERVES: -// void; -// case REVOKE_SPONSORSHIP: -// RevokeSponsorshipOp revokeSponsorshipOp; -// case CLAWBACK: -// ClawbackOp clawbackOp; -// case CLAWBACK_CLAIMABLE_BALANCE: -// ClawbackClaimableBalanceOp clawbackClaimableBalanceOp; -// case SET_TRUST_LINE_FLAGS: -// SetTrustLineFlagsOp setTrustLineFlagsOp; -// case LIQUIDITY_POOL_DEPOSIT: -// LiquidityPoolDepositOp liquidityPoolDepositOp; -// case LIQUIDITY_POOL_WITHDRAW: -// LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; -// case INVOKE_HOST_FUNCTION: -// InvokeHostFunctionOp invokeHostFunctionOp; -// case EXTEND_FOOTPRINT_TTL: -// ExtendFootprintTTLOp extendFootprintTTLOp; -// case RESTORE_FOOTPRINT: -// RestoreFootprintOp restoreFootprintOp; -// } -type OperationBody struct { - Type OperationType - CreateAccountOp *CreateAccountOp - PaymentOp *PaymentOp - PathPaymentStrictReceiveOp *PathPaymentStrictReceiveOp - ManageSellOfferOp *ManageSellOfferOp - CreatePassiveSellOfferOp *CreatePassiveSellOfferOp - SetOptionsOp *SetOptionsOp - ChangeTrustOp *ChangeTrustOp - AllowTrustOp *AllowTrustOp - Destination *MuxedAccount - ManageDataOp *ManageDataOp - BumpSequenceOp *BumpSequenceOp - ManageBuyOfferOp *ManageBuyOfferOp - PathPaymentStrictSendOp *PathPaymentStrictSendOp - CreateClaimableBalanceOp *CreateClaimableBalanceOp - ClaimClaimableBalanceOp *ClaimClaimableBalanceOp - BeginSponsoringFutureReservesOp *BeginSponsoringFutureReservesOp - RevokeSponsorshipOp *RevokeSponsorshipOp - ClawbackOp *ClawbackOp - ClawbackClaimableBalanceOp *ClawbackClaimableBalanceOp - SetTrustLineFlagsOp *SetTrustLineFlagsOp - LiquidityPoolDepositOp *LiquidityPoolDepositOp - LiquidityPoolWithdrawOp *LiquidityPoolWithdrawOp - InvokeHostFunctionOp *InvokeHostFunctionOp - ExtendFootprintTtlOp *ExtendFootprintTtlOp - RestoreFootprintOp *RestoreFootprintOp +// MustRestoreFootprintOp retrieves the RestoreFootprintOp value from the union, +// panicing if the value is not set. +func (u OperationBody) MustRestoreFootprintOp() RestoreFootprintOp { + val, ok := u.GetRestoreFootprintOp() + + if !ok { + panic("arm RestoreFootprintOp is not set") + } + + return val } -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u OperationBody) SwitchFieldName() string { - return "Type" +// GetRestoreFootprintOp retrieves the RestoreFootprintOp value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u OperationBody) GetRestoreFootprintOp() (result RestoreFootprintOp, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "RestoreFootprintOp" { + result = *u.RestoreFootprintOp + ok = true + } + + return } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of OperationBody -func (u OperationBody) ArmForSwitch(sw int32) (string, bool) { - switch OperationType(sw) { +// EncodeTo encodes this value using the Encoder. +func (u OperationBody) EncodeTo(e *xdr.Encoder) error { + var err error + if err = u.Type.EncodeTo(e); err != nil { + return err + } + switch OperationType(u.Type) { case OperationTypeCreateAccount: - return "CreateAccountOp", true + if err = (*u.CreateAccountOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypePayment: - return "PaymentOp", true + if err = (*u.PaymentOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypePathPaymentStrictReceive: - return "PathPaymentStrictReceiveOp", true + if err = (*u.PathPaymentStrictReceiveOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeManageSellOffer: - return "ManageSellOfferOp", true + if err = (*u.ManageSellOfferOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeCreatePassiveSellOffer: - return "CreatePassiveSellOfferOp", true + if err = (*u.CreatePassiveSellOfferOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeSetOptions: - return "SetOptionsOp", true + if err = (*u.SetOptionsOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeChangeTrust: - return "ChangeTrustOp", true + if err = (*u.ChangeTrustOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeAllowTrust: - return "AllowTrustOp", true + if err = (*u.AllowTrustOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeAccountMerge: - return "Destination", true + if err = (*u.Destination).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeInflation: - return "", true + // Void + return nil case OperationTypeManageData: - return "ManageDataOp", true + if err = (*u.ManageDataOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeBumpSequence: - return "BumpSequenceOp", true + if err = (*u.BumpSequenceOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeManageBuyOffer: - return "ManageBuyOfferOp", true + if err = (*u.ManageBuyOfferOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypePathPaymentStrictSend: - return "PathPaymentStrictSendOp", true + if err = (*u.PathPaymentStrictSendOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeCreateClaimableBalance: - return "CreateClaimableBalanceOp", true + if err = (*u.CreateClaimableBalanceOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeClaimClaimableBalance: - return "ClaimClaimableBalanceOp", true + if err = (*u.ClaimClaimableBalanceOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeBeginSponsoringFutureReserves: - return "BeginSponsoringFutureReservesOp", true + if err = (*u.BeginSponsoringFutureReservesOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeEndSponsoringFutureReserves: - return "", true + // Void + return nil case OperationTypeRevokeSponsorship: - return "RevokeSponsorshipOp", true + if err = (*u.RevokeSponsorshipOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeClawback: - return "ClawbackOp", true + if err = (*u.ClawbackOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeClawbackClaimableBalance: - return "ClawbackClaimableBalanceOp", true + if err = (*u.ClawbackClaimableBalanceOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeSetTrustLineFlags: - return "SetTrustLineFlagsOp", true + if err = (*u.SetTrustLineFlagsOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeLiquidityPoolDeposit: - return "LiquidityPoolDepositOp", true + if err = (*u.LiquidityPoolDepositOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeLiquidityPoolWithdraw: - return "LiquidityPoolWithdrawOp", true + if err = (*u.LiquidityPoolWithdrawOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeInvokeHostFunction: - return "InvokeHostFunctionOp", true + if err = (*u.InvokeHostFunctionOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeExtendFootprintTtl: - return "ExtendFootprintTtlOp", true + if err = (*u.ExtendFootprintTtlOp).EncodeTo(e); err != nil { + return err + } + return nil case OperationTypeRestoreFootprint: - return "RestoreFootprintOp", true + if err = (*u.RestoreFootprintOp).EncodeTo(e); err != nil { + return err + } + return nil } - return "-", false + return fmt.Errorf("Type (OperationType) switch value '%d' is not valid for union OperationBody", u.Type) } -// NewOperationBody creates a new OperationBody. -func NewOperationBody(aType OperationType, value interface{}) (result OperationBody, err error) { - result.Type = aType - switch OperationType(aType) { +var _ decoderFrom = (*OperationBody)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *OperationBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding OperationBody: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding OperationType: %w", err) + } + switch OperationType(u.Type) { case OperationTypeCreateAccount: - tv, ok := value.(CreateAccountOp) - if !ok { - err = errors.New("invalid value, must be CreateAccountOp") - return + u.CreateAccountOp = new(CreateAccountOp) + nTmp, err = (*u.CreateAccountOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreateAccountOp: %w", err) } - result.CreateAccountOp = &tv + return n, nil case OperationTypePayment: - tv, ok := value.(PaymentOp) - if !ok { - err = errors.New("invalid value, must be PaymentOp") - return + u.PaymentOp = new(PaymentOp) + nTmp, err = (*u.PaymentOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PaymentOp: %w", err) } - result.PaymentOp = &tv + return n, nil case OperationTypePathPaymentStrictReceive: - tv, ok := value.(PathPaymentStrictReceiveOp) - if !ok { - err = errors.New("invalid value, must be PathPaymentStrictReceiveOp") - return + u.PathPaymentStrictReceiveOp = new(PathPaymentStrictReceiveOp) + nTmp, err = (*u.PathPaymentStrictReceiveOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PathPaymentStrictReceiveOp: %w", err) } - result.PathPaymentStrictReceiveOp = &tv + return n, nil case OperationTypeManageSellOffer: - tv, ok := value.(ManageSellOfferOp) - if !ok { - err = errors.New("invalid value, must be ManageSellOfferOp") - return + u.ManageSellOfferOp = new(ManageSellOfferOp) + nTmp, err = (*u.ManageSellOfferOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ManageSellOfferOp: %w", err) } - result.ManageSellOfferOp = &tv + return n, nil case OperationTypeCreatePassiveSellOffer: - tv, ok := value.(CreatePassiveSellOfferOp) - if !ok { - err = errors.New("invalid value, must be CreatePassiveSellOfferOp") - return + u.CreatePassiveSellOfferOp = new(CreatePassiveSellOfferOp) + nTmp, err = (*u.CreatePassiveSellOfferOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreatePassiveSellOfferOp: %w", err) } - result.CreatePassiveSellOfferOp = &tv + return n, nil case OperationTypeSetOptions: - tv, ok := value.(SetOptionsOp) - if !ok { - err = errors.New("invalid value, must be SetOptionsOp") - return + u.SetOptionsOp = new(SetOptionsOp) + nTmp, err = (*u.SetOptionsOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SetOptionsOp: %w", err) } - result.SetOptionsOp = &tv + return n, nil case OperationTypeChangeTrust: - tv, ok := value.(ChangeTrustOp) - if !ok { - err = errors.New("invalid value, must be ChangeTrustOp") - return + u.ChangeTrustOp = new(ChangeTrustOp) + nTmp, err = (*u.ChangeTrustOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ChangeTrustOp: %w", err) } - result.ChangeTrustOp = &tv + return n, nil case OperationTypeAllowTrust: - tv, ok := value.(AllowTrustOp) - if !ok { - err = errors.New("invalid value, must be AllowTrustOp") - return + u.AllowTrustOp = new(AllowTrustOp) + nTmp, err = (*u.AllowTrustOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AllowTrustOp: %w", err) } - result.AllowTrustOp = &tv + return n, nil case OperationTypeAccountMerge: - tv, ok := value.(MuxedAccount) - if !ok { - err = errors.New("invalid value, must be MuxedAccount") - return + u.Destination = new(MuxedAccount) + nTmp, err = (*u.Destination).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - result.Destination = &tv + return n, nil case OperationTypeInflation: - // void + // Void + return n, nil case OperationTypeManageData: - tv, ok := value.(ManageDataOp) - if !ok { - err = errors.New("invalid value, must be ManageDataOp") - return + u.ManageDataOp = new(ManageDataOp) + nTmp, err = (*u.ManageDataOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ManageDataOp: %w", err) } - result.ManageDataOp = &tv + return n, nil case OperationTypeBumpSequence: - tv, ok := value.(BumpSequenceOp) - if !ok { - err = errors.New("invalid value, must be BumpSequenceOp") - return + u.BumpSequenceOp = new(BumpSequenceOp) + nTmp, err = (*u.BumpSequenceOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding BumpSequenceOp: %w", err) } - result.BumpSequenceOp = &tv + return n, nil case OperationTypeManageBuyOffer: - tv, ok := value.(ManageBuyOfferOp) - if !ok { - err = errors.New("invalid value, must be ManageBuyOfferOp") - return + u.ManageBuyOfferOp = new(ManageBuyOfferOp) + nTmp, err = (*u.ManageBuyOfferOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ManageBuyOfferOp: %w", err) } - result.ManageBuyOfferOp = &tv + return n, nil case OperationTypePathPaymentStrictSend: - tv, ok := value.(PathPaymentStrictSendOp) - if !ok { - err = errors.New("invalid value, must be PathPaymentStrictSendOp") - return + u.PathPaymentStrictSendOp = new(PathPaymentStrictSendOp) + nTmp, err = (*u.PathPaymentStrictSendOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PathPaymentStrictSendOp: %w", err) } - result.PathPaymentStrictSendOp = &tv + return n, nil case OperationTypeCreateClaimableBalance: - tv, ok := value.(CreateClaimableBalanceOp) - if !ok { - err = errors.New("invalid value, must be CreateClaimableBalanceOp") - return + u.CreateClaimableBalanceOp = new(CreateClaimableBalanceOp) + nTmp, err = (*u.CreateClaimableBalanceOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreateClaimableBalanceOp: %w", err) } - result.CreateClaimableBalanceOp = &tv + return n, nil case OperationTypeClaimClaimableBalance: - tv, ok := value.(ClaimClaimableBalanceOp) - if !ok { - err = errors.New("invalid value, must be ClaimClaimableBalanceOp") - return + u.ClaimClaimableBalanceOp = new(ClaimClaimableBalanceOp) + nTmp, err = (*u.ClaimClaimableBalanceOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ClaimClaimableBalanceOp: %w", err) } - result.ClaimClaimableBalanceOp = &tv + return n, nil case OperationTypeBeginSponsoringFutureReserves: - tv, ok := value.(BeginSponsoringFutureReservesOp) - if !ok { - err = errors.New("invalid value, must be BeginSponsoringFutureReservesOp") - return + u.BeginSponsoringFutureReservesOp = new(BeginSponsoringFutureReservesOp) + nTmp, err = (*u.BeginSponsoringFutureReservesOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding BeginSponsoringFutureReservesOp: %w", err) } - result.BeginSponsoringFutureReservesOp = &tv + return n, nil case OperationTypeEndSponsoringFutureReserves: - // void + // Void + return n, nil case OperationTypeRevokeSponsorship: - tv, ok := value.(RevokeSponsorshipOp) - if !ok { - err = errors.New("invalid value, must be RevokeSponsorshipOp") - return + u.RevokeSponsorshipOp = new(RevokeSponsorshipOp) + nTmp, err = (*u.RevokeSponsorshipOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding RevokeSponsorshipOp: %w", err) } - result.RevokeSponsorshipOp = &tv + return n, nil case OperationTypeClawback: - tv, ok := value.(ClawbackOp) - if !ok { - err = errors.New("invalid value, must be ClawbackOp") - return + u.ClawbackOp = new(ClawbackOp) + nTmp, err = (*u.ClawbackOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ClawbackOp: %w", err) } - result.ClawbackOp = &tv + return n, nil case OperationTypeClawbackClaimableBalance: - tv, ok := value.(ClawbackClaimableBalanceOp) - if !ok { - err = errors.New("invalid value, must be ClawbackClaimableBalanceOp") - return + u.ClawbackClaimableBalanceOp = new(ClawbackClaimableBalanceOp) + nTmp, err = (*u.ClawbackClaimableBalanceOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ClawbackClaimableBalanceOp: %w", err) } - result.ClawbackClaimableBalanceOp = &tv + return n, nil case OperationTypeSetTrustLineFlags: - tv, ok := value.(SetTrustLineFlagsOp) - if !ok { - err = errors.New("invalid value, must be SetTrustLineFlagsOp") - return + u.SetTrustLineFlagsOp = new(SetTrustLineFlagsOp) + nTmp, err = (*u.SetTrustLineFlagsOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SetTrustLineFlagsOp: %w", err) } - result.SetTrustLineFlagsOp = &tv + return n, nil case OperationTypeLiquidityPoolDeposit: - tv, ok := value.(LiquidityPoolDepositOp) - if !ok { - err = errors.New("invalid value, must be LiquidityPoolDepositOp") - return + u.LiquidityPoolDepositOp = new(LiquidityPoolDepositOp) + nTmp, err = (*u.LiquidityPoolDepositOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LiquidityPoolDepositOp: %w", err) } - result.LiquidityPoolDepositOp = &tv + return n, nil case OperationTypeLiquidityPoolWithdraw: - tv, ok := value.(LiquidityPoolWithdrawOp) - if !ok { - err = errors.New("invalid value, must be LiquidityPoolWithdrawOp") - return + u.LiquidityPoolWithdrawOp = new(LiquidityPoolWithdrawOp) + nTmp, err = (*u.LiquidityPoolWithdrawOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LiquidityPoolWithdrawOp: %w", err) } - result.LiquidityPoolWithdrawOp = &tv + return n, nil case OperationTypeInvokeHostFunction: - tv, ok := value.(InvokeHostFunctionOp) - if !ok { - err = errors.New("invalid value, must be InvokeHostFunctionOp") - return + u.InvokeHostFunctionOp = new(InvokeHostFunctionOp) + nTmp, err = (*u.InvokeHostFunctionOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding InvokeHostFunctionOp: %w", err) } - result.InvokeHostFunctionOp = &tv + return n, nil case OperationTypeExtendFootprintTtl: - tv, ok := value.(ExtendFootprintTtlOp) - if !ok { - err = errors.New("invalid value, must be ExtendFootprintTtlOp") - return + u.ExtendFootprintTtlOp = new(ExtendFootprintTtlOp) + nTmp, err = (*u.ExtendFootprintTtlOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ExtendFootprintTtlOp: %w", err) } - result.ExtendFootprintTtlOp = &tv + return n, nil case OperationTypeRestoreFootprint: - tv, ok := value.(RestoreFootprintOp) - if !ok { - err = errors.New("invalid value, must be RestoreFootprintOp") - return + u.RestoreFootprintOp = new(RestoreFootprintOp) + nTmp, err = (*u.RestoreFootprintOp).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding RestoreFootprintOp: %w", err) } - result.RestoreFootprintOp = &tv - } - return -} - -// MustCreateAccountOp retrieves the CreateAccountOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustCreateAccountOp() CreateAccountOp { - val, ok := u.GetCreateAccountOp() - - if !ok { - panic("arm CreateAccountOp is not set") - } - - return val -} - -// GetCreateAccountOp retrieves the CreateAccountOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetCreateAccountOp() (result CreateAccountOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "CreateAccountOp" { - result = *u.CreateAccountOp - ok = true - } - - return -} - -// MustPaymentOp retrieves the PaymentOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustPaymentOp() PaymentOp { - val, ok := u.GetPaymentOp() - - if !ok { - panic("arm PaymentOp is not set") - } - - return val -} - -// GetPaymentOp retrieves the PaymentOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetPaymentOp() (result PaymentOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "PaymentOp" { - result = *u.PaymentOp - ok = true - } - - return -} - -// MustPathPaymentStrictReceiveOp retrieves the PathPaymentStrictReceiveOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustPathPaymentStrictReceiveOp() PathPaymentStrictReceiveOp { - val, ok := u.GetPathPaymentStrictReceiveOp() - - if !ok { - panic("arm PathPaymentStrictReceiveOp is not set") - } - - return val -} - -// GetPathPaymentStrictReceiveOp retrieves the PathPaymentStrictReceiveOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetPathPaymentStrictReceiveOp() (result PathPaymentStrictReceiveOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "PathPaymentStrictReceiveOp" { - result = *u.PathPaymentStrictReceiveOp - ok = true - } - - return -} - -// MustManageSellOfferOp retrieves the ManageSellOfferOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustManageSellOfferOp() ManageSellOfferOp { - val, ok := u.GetManageSellOfferOp() - - if !ok { - panic("arm ManageSellOfferOp is not set") - } - - return val -} - -// GetManageSellOfferOp retrieves the ManageSellOfferOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetManageSellOfferOp() (result ManageSellOfferOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ManageSellOfferOp" { - result = *u.ManageSellOfferOp - ok = true - } - - return -} - -// MustCreatePassiveSellOfferOp retrieves the CreatePassiveSellOfferOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustCreatePassiveSellOfferOp() CreatePassiveSellOfferOp { - val, ok := u.GetCreatePassiveSellOfferOp() - - if !ok { - panic("arm CreatePassiveSellOfferOp is not set") - } - - return val -} - -// GetCreatePassiveSellOfferOp retrieves the CreatePassiveSellOfferOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetCreatePassiveSellOfferOp() (result CreatePassiveSellOfferOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "CreatePassiveSellOfferOp" { - result = *u.CreatePassiveSellOfferOp - ok = true - } - - return -} - -// MustSetOptionsOp retrieves the SetOptionsOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustSetOptionsOp() SetOptionsOp { - val, ok := u.GetSetOptionsOp() - - if !ok { - panic("arm SetOptionsOp is not set") + return n, nil } - - return val + return n, fmt.Errorf("union OperationBody has invalid Type (OperationType) switch value '%d'", u.Type) } -// GetSetOptionsOp retrieves the SetOptionsOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetSetOptionsOp() (result SetOptionsOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "SetOptionsOp" { - result = *u.SetOptionsOp - ok = true - } - - return +// MarshalBinary implements encoding.BinaryMarshaler. +func (s OperationBody) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err } -// MustChangeTrustOp retrieves the ChangeTrustOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustChangeTrustOp() ChangeTrustOp { - val, ok := u.GetChangeTrustOp() - - if !ok { - panic("arm ChangeTrustOp is not set") - } - - return val +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *OperationBody) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// GetChangeTrustOp retrieves the ChangeTrustOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetChangeTrustOp() (result ChangeTrustOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ChangeTrustOp" { - result = *u.ChangeTrustOp - ok = true - } - - return -} +var ( + _ encoding.BinaryMarshaler = (*OperationBody)(nil) + _ encoding.BinaryUnmarshaler = (*OperationBody)(nil) +) -// MustAllowTrustOp retrieves the AllowTrustOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustAllowTrustOp() AllowTrustOp { - val, ok := u.GetAllowTrustOp() +// xdrType signals that this type represents XDR values defined by this package. +func (s OperationBody) xdrType() {} - if !ok { - panic("arm AllowTrustOp is not set") - } +var _ xdrType = (*OperationBody)(nil) - return val +// Operation is an XDR Struct defines as: +// +// struct Operation +// { +// // sourceAccount is the account used to run the operation +// // if not set, the runtime defaults to "sourceAccount" specified at +// // the transaction level +// MuxedAccount* sourceAccount; +// +// union switch (OperationType type) +// { +// case CREATE_ACCOUNT: +// CreateAccountOp createAccountOp; +// case PAYMENT: +// PaymentOp paymentOp; +// case PATH_PAYMENT_STRICT_RECEIVE: +// PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp; +// case MANAGE_SELL_OFFER: +// ManageSellOfferOp manageSellOfferOp; +// case CREATE_PASSIVE_SELL_OFFER: +// CreatePassiveSellOfferOp createPassiveSellOfferOp; +// case SET_OPTIONS: +// SetOptionsOp setOptionsOp; +// case CHANGE_TRUST: +// ChangeTrustOp changeTrustOp; +// case ALLOW_TRUST: +// AllowTrustOp allowTrustOp; +// case ACCOUNT_MERGE: +// MuxedAccount destination; +// case INFLATION: +// void; +// case MANAGE_DATA: +// ManageDataOp manageDataOp; +// case BUMP_SEQUENCE: +// BumpSequenceOp bumpSequenceOp; +// case MANAGE_BUY_OFFER: +// ManageBuyOfferOp manageBuyOfferOp; +// case PATH_PAYMENT_STRICT_SEND: +// PathPaymentStrictSendOp pathPaymentStrictSendOp; +// case CREATE_CLAIMABLE_BALANCE: +// CreateClaimableBalanceOp createClaimableBalanceOp; +// case CLAIM_CLAIMABLE_BALANCE: +// ClaimClaimableBalanceOp claimClaimableBalanceOp; +// case BEGIN_SPONSORING_FUTURE_RESERVES: +// BeginSponsoringFutureReservesOp beginSponsoringFutureReservesOp; +// case END_SPONSORING_FUTURE_RESERVES: +// void; +// case REVOKE_SPONSORSHIP: +// RevokeSponsorshipOp revokeSponsorshipOp; +// case CLAWBACK: +// ClawbackOp clawbackOp; +// case CLAWBACK_CLAIMABLE_BALANCE: +// ClawbackClaimableBalanceOp clawbackClaimableBalanceOp; +// case SET_TRUST_LINE_FLAGS: +// SetTrustLineFlagsOp setTrustLineFlagsOp; +// case LIQUIDITY_POOL_DEPOSIT: +// LiquidityPoolDepositOp liquidityPoolDepositOp; +// case LIQUIDITY_POOL_WITHDRAW: +// LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; +// case INVOKE_HOST_FUNCTION: +// InvokeHostFunctionOp invokeHostFunctionOp; +// case EXTEND_FOOTPRINT_TTL: +// ExtendFootprintTTLOp extendFootprintTTLOp; +// case RESTORE_FOOTPRINT: +// RestoreFootprintOp restoreFootprintOp; +// } +// body; +// }; +type Operation struct { + SourceAccount *MuxedAccount + Body OperationBody } -// GetAllowTrustOp retrieves the AllowTrustOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetAllowTrustOp() (result AllowTrustOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "AllowTrustOp" { - result = *u.AllowTrustOp - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *Operation) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeBool(s.SourceAccount != nil); err != nil { + return err } - - return -} - -// MustDestination retrieves the Destination value from the union, -// panicing if the value is not set. -func (u OperationBody) MustDestination() MuxedAccount { - val, ok := u.GetDestination() - - if !ok { - panic("arm Destination is not set") + if s.SourceAccount != nil { + if err = (*s.SourceAccount).EncodeTo(e); err != nil { + return err + } } - - return val -} - -// GetDestination retrieves the Destination value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetDestination() (result MuxedAccount, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Destination" { - result = *u.Destination - ok = true + if err = s.Body.EncodeTo(e); err != nil { + return err } - - return + return nil } -// MustManageDataOp retrieves the ManageDataOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustManageDataOp() ManageDataOp { - val, ok := u.GetManageDataOp() +var _ decoderFrom = (*Operation)(nil) - if !ok { - panic("arm ManageDataOp is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *Operation) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding Operation: %w", ErrMaxDecodingDepthReached) } - - return val -} - -// GetManageDataOp retrieves the ManageDataOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetManageDataOp() (result ManageDataOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ManageDataOp" { - result = *u.ManageDataOp - ok = true + maxDepth -= 1 + var err error + var n, nTmp int + var b bool + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MuxedAccount: %w", err) } - - return -} - -// MustBumpSequenceOp retrieves the BumpSequenceOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustBumpSequenceOp() BumpSequenceOp { - val, ok := u.GetBumpSequenceOp() - - if !ok { - panic("arm BumpSequenceOp is not set") + s.SourceAccount = nil + if b { + s.SourceAccount = new(MuxedAccount) + nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding MuxedAccount: %w", err) + } } - - return val + nTmp, err = s.Body.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding OperationBody: %w", err) + } + return n, nil } -// GetBumpSequenceOp retrieves the BumpSequenceOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetBumpSequenceOp() (result BumpSequenceOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "BumpSequenceOp" { - result = *u.BumpSequenceOp - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s Operation) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *Operation) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustManageBuyOfferOp retrieves the ManageBuyOfferOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustManageBuyOfferOp() ManageBuyOfferOp { - val, ok := u.GetManageBuyOfferOp() +var ( + _ encoding.BinaryMarshaler = (*Operation)(nil) + _ encoding.BinaryUnmarshaler = (*Operation)(nil) +) - if !ok { - panic("arm ManageBuyOfferOp is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s Operation) xdrType() {} - return val -} +var _ xdrType = (*Operation)(nil) -// GetManageBuyOfferOp retrieves the ManageBuyOfferOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetManageBuyOfferOp() (result ManageBuyOfferOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// HashIdPreimageOperationId is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID sourceAccount; +// SequenceNumber seqNum; +// uint32 opNum; +// } +type HashIdPreimageOperationId struct { + SourceAccount AccountId + SeqNum SequenceNumber + OpNum Uint32 +} - if armName == "ManageBuyOfferOp" { - result = *u.ManageBuyOfferOp - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *HashIdPreimageOperationId) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.SourceAccount.EncodeTo(e); err != nil { + return err } - - return + if err = s.SeqNum.EncodeTo(e); err != nil { + return err + } + if err = s.OpNum.EncodeTo(e); err != nil { + return err + } + return nil } -// MustPathPaymentStrictSendOp retrieves the PathPaymentStrictSendOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustPathPaymentStrictSendOp() PathPaymentStrictSendOp { - val, ok := u.GetPathPaymentStrictSendOp() +var _ decoderFrom = (*HashIdPreimageOperationId)(nil) - if !ok { - panic("arm PathPaymentStrictSendOp is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *HashIdPreimageOperationId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageOperationId: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AccountId: %w", err) + } + nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SequenceNumber: %w", err) + } + nTmp, err = s.OpNum.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil } -// GetPathPaymentStrictSendOp retrieves the PathPaymentStrictSendOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetPathPaymentStrictSendOp() (result PathPaymentStrictSendOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "PathPaymentStrictSendOp" { - result = *u.PathPaymentStrictSendOp - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s HashIdPreimageOperationId) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *HashIdPreimageOperationId) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustCreateClaimableBalanceOp retrieves the CreateClaimableBalanceOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustCreateClaimableBalanceOp() CreateClaimableBalanceOp { - val, ok := u.GetCreateClaimableBalanceOp() +var ( + _ encoding.BinaryMarshaler = (*HashIdPreimageOperationId)(nil) + _ encoding.BinaryUnmarshaler = (*HashIdPreimageOperationId)(nil) +) - if !ok { - panic("arm CreateClaimableBalanceOp is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s HashIdPreimageOperationId) xdrType() {} - return val -} +var _ xdrType = (*HashIdPreimageOperationId)(nil) -// GetCreateClaimableBalanceOp retrieves the CreateClaimableBalanceOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetCreateClaimableBalanceOp() (result CreateClaimableBalanceOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// HashIdPreimageRevokeId is an XDR NestedStruct defines as: +// +// struct +// { +// AccountID sourceAccount; +// SequenceNumber seqNum; +// uint32 opNum; +// PoolID liquidityPoolID; +// Asset asset; +// } +type HashIdPreimageRevokeId struct { + SourceAccount AccountId + SeqNum SequenceNumber + OpNum Uint32 + LiquidityPoolId PoolId + Asset Asset +} - if armName == "CreateClaimableBalanceOp" { - result = *u.CreateClaimableBalanceOp - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *HashIdPreimageRevokeId) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.SourceAccount.EncodeTo(e); err != nil { + return err } - - return + if err = s.SeqNum.EncodeTo(e); err != nil { + return err + } + if err = s.OpNum.EncodeTo(e); err != nil { + return err + } + if err = s.LiquidityPoolId.EncodeTo(e); err != nil { + return err + } + if err = s.Asset.EncodeTo(e); err != nil { + return err + } + return nil } -// MustClaimClaimableBalanceOp retrieves the ClaimClaimableBalanceOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustClaimClaimableBalanceOp() ClaimClaimableBalanceOp { - val, ok := u.GetClaimClaimableBalanceOp() +var _ decoderFrom = (*HashIdPreimageRevokeId)(nil) - if !ok { - panic("arm ClaimClaimableBalanceOp is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *HashIdPreimageRevokeId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageRevokeId: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding AccountId: %w", err) + } + nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SequenceNumber: %w", err) + } + nTmp, err = s.OpNum.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding PoolId: %w", err) + } + nTmp, err = s.Asset.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Asset: %w", err) + } + return n, nil } -// GetClaimClaimableBalanceOp retrieves the ClaimClaimableBalanceOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetClaimClaimableBalanceOp() (result ClaimClaimableBalanceOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ClaimClaimableBalanceOp" { - result = *u.ClaimClaimableBalanceOp - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s HashIdPreimageRevokeId) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *HashIdPreimageRevokeId) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustBeginSponsoringFutureReservesOp retrieves the BeginSponsoringFutureReservesOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustBeginSponsoringFutureReservesOp() BeginSponsoringFutureReservesOp { - val, ok := u.GetBeginSponsoringFutureReservesOp() +var ( + _ encoding.BinaryMarshaler = (*HashIdPreimageRevokeId)(nil) + _ encoding.BinaryUnmarshaler = (*HashIdPreimageRevokeId)(nil) +) - if !ok { - panic("arm BeginSponsoringFutureReservesOp is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s HashIdPreimageRevokeId) xdrType() {} - return val -} +var _ xdrType = (*HashIdPreimageRevokeId)(nil) -// GetBeginSponsoringFutureReservesOp retrieves the BeginSponsoringFutureReservesOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetBeginSponsoringFutureReservesOp() (result BeginSponsoringFutureReservesOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// HashIdPreimageContractId is an XDR NestedStruct defines as: +// +// struct +// { +// Hash networkID; +// ContractIDPreimage contractIDPreimage; +// } +type HashIdPreimageContractId struct { + NetworkId Hash + ContractIdPreimage ContractIdPreimage +} - if armName == "BeginSponsoringFutureReservesOp" { - result = *u.BeginSponsoringFutureReservesOp - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *HashIdPreimageContractId) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.NetworkId.EncodeTo(e); err != nil { + return err } - - return + if err = s.ContractIdPreimage.EncodeTo(e); err != nil { + return err + } + return nil } -// MustRevokeSponsorshipOp retrieves the RevokeSponsorshipOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustRevokeSponsorshipOp() RevokeSponsorshipOp { - val, ok := u.GetRevokeSponsorshipOp() +var _ decoderFrom = (*HashIdPreimageContractId)(nil) - if !ok { - panic("arm RevokeSponsorshipOp is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *HashIdPreimageContractId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageContractId: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + nTmp, err = s.ContractIdPreimage.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ContractIdPreimage: %w", err) + } + return n, nil } -// GetRevokeSponsorshipOp retrieves the RevokeSponsorshipOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetRevokeSponsorshipOp() (result RevokeSponsorshipOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "RevokeSponsorshipOp" { - result = *u.RevokeSponsorshipOp - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s HashIdPreimageContractId) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *HashIdPreimageContractId) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustClawbackOp retrieves the ClawbackOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustClawbackOp() ClawbackOp { - val, ok := u.GetClawbackOp() +var ( + _ encoding.BinaryMarshaler = (*HashIdPreimageContractId)(nil) + _ encoding.BinaryUnmarshaler = (*HashIdPreimageContractId)(nil) +) - if !ok { - panic("arm ClawbackOp is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s HashIdPreimageContractId) xdrType() {} - return val -} +var _ xdrType = (*HashIdPreimageContractId)(nil) -// GetClawbackOp retrieves the ClawbackOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetClawbackOp() (result ClawbackOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +// HashIdPreimageSorobanAuthorization is an XDR NestedStruct defines as: +// +// struct +// { +// Hash networkID; +// int64 nonce; +// uint32 signatureExpirationLedger; +// SorobanAuthorizedInvocation invocation; +// } +type HashIdPreimageSorobanAuthorization struct { + NetworkId Hash + Nonce Int64 + SignatureExpirationLedger Uint32 + Invocation SorobanAuthorizedInvocation +} - if armName == "ClawbackOp" { - result = *u.ClawbackOp - ok = true +// EncodeTo encodes this value using the Encoder. +func (s *HashIdPreimageSorobanAuthorization) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.NetworkId.EncodeTo(e); err != nil { + return err } - - return + if err = s.Nonce.EncodeTo(e); err != nil { + return err + } + if err = s.SignatureExpirationLedger.EncodeTo(e); err != nil { + return err + } + if err = s.Invocation.EncodeTo(e); err != nil { + return err + } + return nil } -// MustClawbackClaimableBalanceOp retrieves the ClawbackClaimableBalanceOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustClawbackClaimableBalanceOp() ClawbackClaimableBalanceOp { - val, ok := u.GetClawbackClaimableBalanceOp() +var _ decoderFrom = (*HashIdPreimageSorobanAuthorization)(nil) - if !ok { - panic("arm ClawbackClaimableBalanceOp is not set") +// DecodeFrom decodes this value using the Decoder. +func (s *HashIdPreimageSorobanAuthorization) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %w", ErrMaxDecodingDepthReached) } - - return val + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Int64: %w", err) + } + nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.Invocation.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) + } + return n, nil } -// GetClawbackClaimableBalanceOp retrieves the ClawbackClaimableBalanceOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetClawbackClaimableBalanceOp() (result ClawbackClaimableBalanceOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ClawbackClaimableBalanceOp" { - result = *u.ClawbackClaimableBalanceOp - ok = true - } +// MarshalBinary implements encoding.BinaryMarshaler. +func (s HashIdPreimageSorobanAuthorization) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} - return +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *HashIdPreimageSorobanAuthorization) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err } -// MustSetTrustLineFlagsOp retrieves the SetTrustLineFlagsOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustSetTrustLineFlagsOp() SetTrustLineFlagsOp { - val, ok := u.GetSetTrustLineFlagsOp() +var ( + _ encoding.BinaryMarshaler = (*HashIdPreimageSorobanAuthorization)(nil) + _ encoding.BinaryUnmarshaler = (*HashIdPreimageSorobanAuthorization)(nil) +) - if !ok { - panic("arm SetTrustLineFlagsOp is not set") - } +// xdrType signals that this type represents XDR values defined by this package. +func (s HashIdPreimageSorobanAuthorization) xdrType() {} - return val +var _ xdrType = (*HashIdPreimageSorobanAuthorization)(nil) + +// HashIdPreimage is an XDR Union defines as: +// +// union HashIDPreimage switch (EnvelopeType type) +// { +// case ENVELOPE_TYPE_OP_ID: +// struct +// { +// AccountID sourceAccount; +// SequenceNumber seqNum; +// uint32 opNum; +// } operationID; +// case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: +// struct +// { +// AccountID sourceAccount; +// SequenceNumber seqNum; +// uint32 opNum; +// PoolID liquidityPoolID; +// Asset asset; +// } revokeID; +// case ENVELOPE_TYPE_CONTRACT_ID: +// struct +// { +// Hash networkID; +// ContractIDPreimage contractIDPreimage; +// } contractID; +// case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: +// struct +// { +// Hash networkID; +// int64 nonce; +// uint32 signatureExpirationLedger; +// SorobanAuthorizedInvocation invocation; +// } sorobanAuthorization; +// }; +type HashIdPreimage struct { + Type EnvelopeType + OperationId *HashIdPreimageOperationId + RevokeId *HashIdPreimageRevokeId + ContractId *HashIdPreimageContractId + SorobanAuthorization *HashIdPreimageSorobanAuthorization } -// GetSetTrustLineFlagsOp retrieves the SetTrustLineFlagsOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetSetTrustLineFlagsOp() (result SetTrustLineFlagsOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "SetTrustLineFlagsOp" { - result = *u.SetTrustLineFlagsOp - ok = true - } - - return +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u HashIdPreimage) SwitchFieldName() string { + return "Type" } -// MustLiquidityPoolDepositOp retrieves the LiquidityPoolDepositOp value from the union, -// panicing if the value is not set. -func (u OperationBody) MustLiquidityPoolDepositOp() LiquidityPoolDepositOp { - val, ok := u.GetLiquidityPoolDepositOp() - - if !ok { - panic("arm LiquidityPoolDepositOp is not set") +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of HashIdPreimage +func (u HashIdPreimage) ArmForSwitch(sw int32) (string, bool) { + switch EnvelopeType(sw) { + case EnvelopeTypeEnvelopeTypeOpId: + return "OperationId", true + case EnvelopeTypeEnvelopeTypePoolRevokeOpId: + return "RevokeId", true + case EnvelopeTypeEnvelopeTypeContractId: + return "ContractId", true + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + return "SorobanAuthorization", true } - - return val + return "-", false } -// GetLiquidityPoolDepositOp retrieves the LiquidityPoolDepositOp value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetLiquidityPoolDepositOp() (result LiquidityPoolDepositOp, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "LiquidityPoolDepositOp" { - result = *u.LiquidityPoolDepositOp - ok = true +// NewHashIdPreimage creates a new HashIdPreimage. +func NewHashIdPreimage(aType EnvelopeType, value interface{}) (result HashIdPreimage, err error) { + result.Type = aType + switch EnvelopeType(aType) { + case EnvelopeTypeEnvelopeTypeOpId: + tv, ok := value.(HashIdPreimageOperationId) + if !ok { + err = errors.New("invalid value, must be HashIdPreimageOperationId") + return + } + result.OperationId = &tv + case EnvelopeTypeEnvelopeTypePoolRevokeOpId: + tv, ok := value.(HashIdPreimageRevokeId) + if !ok { + err = errors.New("invalid value, must be HashIdPreimageRevokeId") + return + } + result.RevokeId = &tv + case EnvelopeTypeEnvelopeTypeContractId: + tv, ok := value.(HashIdPreimageContractId) + if !ok { + err = errors.New("invalid value, must be HashIdPreimageContractId") + return + } + result.ContractId = &tv + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + tv, ok := value.(HashIdPreimageSorobanAuthorization) + if !ok { + err = errors.New("invalid value, must be HashIdPreimageSorobanAuthorization") + return + } + result.SorobanAuthorization = &tv } - return } -// MustLiquidityPoolWithdrawOp retrieves the LiquidityPoolWithdrawOp value from the union, +// MustOperationId retrieves the OperationId value from the union, // panicing if the value is not set. -func (u OperationBody) MustLiquidityPoolWithdrawOp() LiquidityPoolWithdrawOp { - val, ok := u.GetLiquidityPoolWithdrawOp() +func (u HashIdPreimage) MustOperationId() HashIdPreimageOperationId { + val, ok := u.GetOperationId() if !ok { - panic("arm LiquidityPoolWithdrawOp is not set") + panic("arm OperationId is not set") } return val } -// GetLiquidityPoolWithdrawOp retrieves the LiquidityPoolWithdrawOp value from the union, +// GetOperationId retrieves the OperationId value from the union, // returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetLiquidityPoolWithdrawOp() (result LiquidityPoolWithdrawOp, ok bool) { +func (u HashIdPreimage) GetOperationId() (result HashIdPreimageOperationId, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "LiquidityPoolWithdrawOp" { - result = *u.LiquidityPoolWithdrawOp + if armName == "OperationId" { + result = *u.OperationId ok = true } return } -// MustInvokeHostFunctionOp retrieves the InvokeHostFunctionOp value from the union, +// MustRevokeId retrieves the RevokeId value from the union, // panicing if the value is not set. -func (u OperationBody) MustInvokeHostFunctionOp() InvokeHostFunctionOp { - val, ok := u.GetInvokeHostFunctionOp() +func (u HashIdPreimage) MustRevokeId() HashIdPreimageRevokeId { + val, ok := u.GetRevokeId() if !ok { - panic("arm InvokeHostFunctionOp is not set") + panic("arm RevokeId is not set") } return val } -// GetInvokeHostFunctionOp retrieves the InvokeHostFunctionOp value from the union, +// GetRevokeId retrieves the RevokeId value from the union, // returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetInvokeHostFunctionOp() (result InvokeHostFunctionOp, ok bool) { +func (u HashIdPreimage) GetRevokeId() (result HashIdPreimageRevokeId, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "InvokeHostFunctionOp" { - result = *u.InvokeHostFunctionOp + if armName == "RevokeId" { + result = *u.RevokeId ok = true } return } -// MustExtendFootprintTtlOp retrieves the ExtendFootprintTtlOp value from the union, +// MustContractId retrieves the ContractId value from the union, // panicing if the value is not set. -func (u OperationBody) MustExtendFootprintTtlOp() ExtendFootprintTtlOp { - val, ok := u.GetExtendFootprintTtlOp() +func (u HashIdPreimage) MustContractId() HashIdPreimageContractId { + val, ok := u.GetContractId() if !ok { - panic("arm ExtendFootprintTtlOp is not set") + panic("arm ContractId is not set") } return val } -// GetExtendFootprintTtlOp retrieves the ExtendFootprintTtlOp value from the union, +// GetContractId retrieves the ContractId value from the union, // returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetExtendFootprintTtlOp() (result ExtendFootprintTtlOp, ok bool) { +func (u HashIdPreimage) GetContractId() (result HashIdPreimageContractId, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "ExtendFootprintTtlOp" { - result = *u.ExtendFootprintTtlOp + if armName == "ContractId" { + result = *u.ContractId ok = true } return } -// MustRestoreFootprintOp retrieves the RestoreFootprintOp value from the union, +// MustSorobanAuthorization retrieves the SorobanAuthorization value from the union, // panicing if the value is not set. -func (u OperationBody) MustRestoreFootprintOp() RestoreFootprintOp { - val, ok := u.GetRestoreFootprintOp() +func (u HashIdPreimage) MustSorobanAuthorization() HashIdPreimageSorobanAuthorization { + val, ok := u.GetSorobanAuthorization() if !ok { - panic("arm RestoreFootprintOp is not set") + panic("arm SorobanAuthorization is not set") } return val } -// GetRestoreFootprintOp retrieves the RestoreFootprintOp value from the union, +// GetSorobanAuthorization retrieves the SorobanAuthorization value from the union, // returning ok if the union's switch indicated the value is valid. -func (u OperationBody) GetRestoreFootprintOp() (result RestoreFootprintOp, ok bool) { +func (u HashIdPreimage) GetSorobanAuthorization() (result HashIdPreimageSorobanAuthorization, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "RestoreFootprintOp" { - result = *u.RestoreFootprintOp + if armName == "SorobanAuthorization" { + result = *u.SorobanAuthorization ok = true } @@ -30422,153 +33000,42 @@ func (u OperationBody) GetRestoreFootprintOp() (result RestoreFootprintOp, ok bo } // EncodeTo encodes this value using the Encoder. -func (u OperationBody) EncodeTo(e *xdr.Encoder) error { +func (u HashIdPreimage) EncodeTo(e *xdr.Encoder) error { var err error if err = u.Type.EncodeTo(e); err != nil { return err } - switch OperationType(u.Type) { - case OperationTypeCreateAccount: - if err = (*u.CreateAccountOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypePayment: - if err = (*u.PaymentOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypePathPaymentStrictReceive: - if err = (*u.PathPaymentStrictReceiveOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeManageSellOffer: - if err = (*u.ManageSellOfferOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeCreatePassiveSellOffer: - if err = (*u.CreatePassiveSellOfferOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeSetOptions: - if err = (*u.SetOptionsOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeChangeTrust: - if err = (*u.ChangeTrustOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeAllowTrust: - if err = (*u.AllowTrustOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeAccountMerge: - if err = (*u.Destination).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeInflation: - // Void - return nil - case OperationTypeManageData: - if err = (*u.ManageDataOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeBumpSequence: - if err = (*u.BumpSequenceOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeManageBuyOffer: - if err = (*u.ManageBuyOfferOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypePathPaymentStrictSend: - if err = (*u.PathPaymentStrictSendOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeCreateClaimableBalance: - if err = (*u.CreateClaimableBalanceOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeClaimClaimableBalance: - if err = (*u.ClaimClaimableBalanceOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeBeginSponsoringFutureReserves: - if err = (*u.BeginSponsoringFutureReservesOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeEndSponsoringFutureReserves: - // Void - return nil - case OperationTypeRevokeSponsorship: - if err = (*u.RevokeSponsorshipOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeClawback: - if err = (*u.ClawbackOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeClawbackClaimableBalance: - if err = (*u.ClawbackClaimableBalanceOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeSetTrustLineFlags: - if err = (*u.SetTrustLineFlagsOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeLiquidityPoolDeposit: - if err = (*u.LiquidityPoolDepositOp).EncodeTo(e); err != nil { - return err - } - return nil - case OperationTypeLiquidityPoolWithdraw: - if err = (*u.LiquidityPoolWithdrawOp).EncodeTo(e); err != nil { + switch EnvelopeType(u.Type) { + case EnvelopeTypeEnvelopeTypeOpId: + if err = (*u.OperationId).EncodeTo(e); err != nil { return err } return nil - case OperationTypeInvokeHostFunction: - if err = (*u.InvokeHostFunctionOp).EncodeTo(e); err != nil { + case EnvelopeTypeEnvelopeTypePoolRevokeOpId: + if err = (*u.RevokeId).EncodeTo(e); err != nil { return err } return nil - case OperationTypeExtendFootprintTtl: - if err = (*u.ExtendFootprintTtlOp).EncodeTo(e); err != nil { + case EnvelopeTypeEnvelopeTypeContractId: + if err = (*u.ContractId).EncodeTo(e); err != nil { return err } return nil - case OperationTypeRestoreFootprint: - if err = (*u.RestoreFootprintOp).EncodeTo(e); err != nil { + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + if err = (*u.SorobanAuthorization).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (OperationType) switch value '%d' is not valid for union OperationBody", u.Type) + return fmt.Errorf("Type (EnvelopeType) switch value '%d' is not valid for union HashIdPreimage", u.Type) } -var _ decoderFrom = (*OperationBody)(nil) +var _ decoderFrom = (*HashIdPreimage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *OperationBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *HashIdPreimage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding OperationBody: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding HashIdPreimage: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -30576,221 +33043,47 @@ func (u *OperationBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationType: %w", err) + return n, fmt.Errorf("decoding EnvelopeType: %w", err) } - switch OperationType(u.Type) { - case OperationTypeCreateAccount: - u.CreateAccountOp = new(CreateAccountOp) - nTmp, err = (*u.CreateAccountOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding CreateAccountOp: %w", err) - } - return n, nil - case OperationTypePayment: - u.PaymentOp = new(PaymentOp) - nTmp, err = (*u.PaymentOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PaymentOp: %w", err) - } - return n, nil - case OperationTypePathPaymentStrictReceive: - u.PathPaymentStrictReceiveOp = new(PathPaymentStrictReceiveOp) - nTmp, err = (*u.PathPaymentStrictReceiveOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictReceiveOp: %w", err) - } - return n, nil - case OperationTypeManageSellOffer: - u.ManageSellOfferOp = new(ManageSellOfferOp) - nTmp, err = (*u.ManageSellOfferOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ManageSellOfferOp: %w", err) - } - return n, nil - case OperationTypeCreatePassiveSellOffer: - u.CreatePassiveSellOfferOp = new(CreatePassiveSellOfferOp) - nTmp, err = (*u.CreatePassiveSellOfferOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding CreatePassiveSellOfferOp: %w", err) - } - return n, nil - case OperationTypeSetOptions: - u.SetOptionsOp = new(SetOptionsOp) - nTmp, err = (*u.SetOptionsOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SetOptionsOp: %w", err) - } - return n, nil - case OperationTypeChangeTrust: - u.ChangeTrustOp = new(ChangeTrustOp) - nTmp, err = (*u.ChangeTrustOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ChangeTrustOp: %w", err) - } - return n, nil - case OperationTypeAllowTrust: - u.AllowTrustOp = new(AllowTrustOp) - nTmp, err = (*u.AllowTrustOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AllowTrustOp: %w", err) - } - return n, nil - case OperationTypeAccountMerge: - u.Destination = new(MuxedAccount) - nTmp, err = (*u.Destination).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %w", err) - } - return n, nil - case OperationTypeInflation: - // Void - return n, nil - case OperationTypeManageData: - u.ManageDataOp = new(ManageDataOp) - nTmp, err = (*u.ManageDataOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ManageDataOp: %w", err) - } - return n, nil - case OperationTypeBumpSequence: - u.BumpSequenceOp = new(BumpSequenceOp) - nTmp, err = (*u.BumpSequenceOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding BumpSequenceOp: %w", err) - } - return n, nil - case OperationTypeManageBuyOffer: - u.ManageBuyOfferOp = new(ManageBuyOfferOp) - nTmp, err = (*u.ManageBuyOfferOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ManageBuyOfferOp: %w", err) - } - return n, nil - case OperationTypePathPaymentStrictSend: - u.PathPaymentStrictSendOp = new(PathPaymentStrictSendOp) - nTmp, err = (*u.PathPaymentStrictSendOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding PathPaymentStrictSendOp: %w", err) - } - return n, nil - case OperationTypeCreateClaimableBalance: - u.CreateClaimableBalanceOp = new(CreateClaimableBalanceOp) - nTmp, err = (*u.CreateClaimableBalanceOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding CreateClaimableBalanceOp: %w", err) - } - return n, nil - case OperationTypeClaimClaimableBalance: - u.ClaimClaimableBalanceOp = new(ClaimClaimableBalanceOp) - nTmp, err = (*u.ClaimClaimableBalanceOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ClaimClaimableBalanceOp: %w", err) - } - return n, nil - case OperationTypeBeginSponsoringFutureReserves: - u.BeginSponsoringFutureReservesOp = new(BeginSponsoringFutureReservesOp) - nTmp, err = (*u.BeginSponsoringFutureReservesOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding BeginSponsoringFutureReservesOp: %w", err) - } - return n, nil - case OperationTypeEndSponsoringFutureReserves: - // Void - return n, nil - case OperationTypeRevokeSponsorship: - u.RevokeSponsorshipOp = new(RevokeSponsorshipOp) - nTmp, err = (*u.RevokeSponsorshipOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding RevokeSponsorshipOp: %w", err) - } - return n, nil - case OperationTypeClawback: - u.ClawbackOp = new(ClawbackOp) - nTmp, err = (*u.ClawbackOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ClawbackOp: %w", err) - } - return n, nil - case OperationTypeClawbackClaimableBalance: - u.ClawbackClaimableBalanceOp = new(ClawbackClaimableBalanceOp) - nTmp, err = (*u.ClawbackClaimableBalanceOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ClawbackClaimableBalanceOp: %w", err) - } - return n, nil - case OperationTypeSetTrustLineFlags: - u.SetTrustLineFlagsOp = new(SetTrustLineFlagsOp) - nTmp, err = (*u.SetTrustLineFlagsOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SetTrustLineFlagsOp: %w", err) - } - return n, nil - case OperationTypeLiquidityPoolDeposit: - u.LiquidityPoolDepositOp = new(LiquidityPoolDepositOp) - nTmp, err = (*u.LiquidityPoolDepositOp).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolDepositOp: %w", err) - } - return n, nil - case OperationTypeLiquidityPoolWithdraw: - u.LiquidityPoolWithdrawOp = new(LiquidityPoolWithdrawOp) - nTmp, err = (*u.LiquidityPoolWithdrawOp).DecodeFrom(d, maxDepth) + switch EnvelopeType(u.Type) { + case EnvelopeTypeEnvelopeTypeOpId: + u.OperationId = new(HashIdPreimageOperationId) + nTmp, err = (*u.OperationId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LiquidityPoolWithdrawOp: %w", err) + return n, fmt.Errorf("decoding HashIdPreimageOperationId: %w", err) } return n, nil - case OperationTypeInvokeHostFunction: - u.InvokeHostFunctionOp = new(InvokeHostFunctionOp) - nTmp, err = (*u.InvokeHostFunctionOp).DecodeFrom(d, maxDepth) + case EnvelopeTypeEnvelopeTypePoolRevokeOpId: + u.RevokeId = new(HashIdPreimageRevokeId) + nTmp, err = (*u.RevokeId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding InvokeHostFunctionOp: %w", err) + return n, fmt.Errorf("decoding HashIdPreimageRevokeId: %w", err) } return n, nil - case OperationTypeExtendFootprintTtl: - u.ExtendFootprintTtlOp = new(ExtendFootprintTtlOp) - nTmp, err = (*u.ExtendFootprintTtlOp).DecodeFrom(d, maxDepth) + case EnvelopeTypeEnvelopeTypeContractId: + u.ContractId = new(HashIdPreimageContractId) + nTmp, err = (*u.ContractId).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ExtendFootprintTtlOp: %w", err) + return n, fmt.Errorf("decoding HashIdPreimageContractId: %w", err) } return n, nil - case OperationTypeRestoreFootprint: - u.RestoreFootprintOp = new(RestoreFootprintOp) - nTmp, err = (*u.RestoreFootprintOp).DecodeFrom(d, maxDepth) + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + u.SorobanAuthorization = new(HashIdPreimageSorobanAuthorization) + nTmp, err = (*u.SorobanAuthorization).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding RestoreFootprintOp: %w", err) + return n, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %w", err) } return n, nil } - return n, fmt.Errorf("union OperationBody has invalid Type (OperationType) switch value '%d'", u.Type) + return n, fmt.Errorf("union HashIdPreimage has invalid Type (EnvelopeType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s OperationBody) MarshalBinary() ([]byte, error) { +func (s HashIdPreimage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -30798,7 +33091,7 @@ func (s OperationBody) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *OperationBody) UnmarshalBinary(inp []byte) error { +func (s *HashIdPreimage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -30808,140 +33101,86 @@ func (s *OperationBody) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*OperationBody)(nil) - _ encoding.BinaryUnmarshaler = (*OperationBody)(nil) + _ encoding.BinaryMarshaler = (*HashIdPreimage)(nil) + _ encoding.BinaryUnmarshaler = (*HashIdPreimage)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s OperationBody) xdrType() {} +func (s HashIdPreimage) xdrType() {} -var _ xdrType = (*OperationBody)(nil) +var _ xdrType = (*HashIdPreimage)(nil) -// Operation is an XDR Struct defines as: +// MemoType is an XDR Enum defines as: // -// struct Operation +// enum MemoType // { -// // sourceAccount is the account used to run the operation -// // if not set, the runtime defaults to "sourceAccount" specified at -// // the transaction level -// MuxedAccount* sourceAccount; -// -// union switch (OperationType type) -// { -// case CREATE_ACCOUNT: -// CreateAccountOp createAccountOp; -// case PAYMENT: -// PaymentOp paymentOp; -// case PATH_PAYMENT_STRICT_RECEIVE: -// PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp; -// case MANAGE_SELL_OFFER: -// ManageSellOfferOp manageSellOfferOp; -// case CREATE_PASSIVE_SELL_OFFER: -// CreatePassiveSellOfferOp createPassiveSellOfferOp; -// case SET_OPTIONS: -// SetOptionsOp setOptionsOp; -// case CHANGE_TRUST: -// ChangeTrustOp changeTrustOp; -// case ALLOW_TRUST: -// AllowTrustOp allowTrustOp; -// case ACCOUNT_MERGE: -// MuxedAccount destination; -// case INFLATION: -// void; -// case MANAGE_DATA: -// ManageDataOp manageDataOp; -// case BUMP_SEQUENCE: -// BumpSequenceOp bumpSequenceOp; -// case MANAGE_BUY_OFFER: -// ManageBuyOfferOp manageBuyOfferOp; -// case PATH_PAYMENT_STRICT_SEND: -// PathPaymentStrictSendOp pathPaymentStrictSendOp; -// case CREATE_CLAIMABLE_BALANCE: -// CreateClaimableBalanceOp createClaimableBalanceOp; -// case CLAIM_CLAIMABLE_BALANCE: -// ClaimClaimableBalanceOp claimClaimableBalanceOp; -// case BEGIN_SPONSORING_FUTURE_RESERVES: -// BeginSponsoringFutureReservesOp beginSponsoringFutureReservesOp; -// case END_SPONSORING_FUTURE_RESERVES: -// void; -// case REVOKE_SPONSORSHIP: -// RevokeSponsorshipOp revokeSponsorshipOp; -// case CLAWBACK: -// ClawbackOp clawbackOp; -// case CLAWBACK_CLAIMABLE_BALANCE: -// ClawbackClaimableBalanceOp clawbackClaimableBalanceOp; -// case SET_TRUST_LINE_FLAGS: -// SetTrustLineFlagsOp setTrustLineFlagsOp; -// case LIQUIDITY_POOL_DEPOSIT: -// LiquidityPoolDepositOp liquidityPoolDepositOp; -// case LIQUIDITY_POOL_WITHDRAW: -// LiquidityPoolWithdrawOp liquidityPoolWithdrawOp; -// case INVOKE_HOST_FUNCTION: -// InvokeHostFunctionOp invokeHostFunctionOp; -// case EXTEND_FOOTPRINT_TTL: -// ExtendFootprintTTLOp extendFootprintTTLOp; -// case RESTORE_FOOTPRINT: -// RestoreFootprintOp restoreFootprintOp; -// } -// body; +// MEMO_NONE = 0, +// MEMO_TEXT = 1, +// MEMO_ID = 2, +// MEMO_HASH = 3, +// MEMO_RETURN = 4 // }; -type Operation struct { - SourceAccount *MuxedAccount - Body OperationBody +type MemoType int32 + +const ( + MemoTypeMemoNone MemoType = 0 + MemoTypeMemoText MemoType = 1 + MemoTypeMemoId MemoType = 2 + MemoTypeMemoHash MemoType = 3 + MemoTypeMemoReturn MemoType = 4 +) + +var memoTypeMap = map[int32]string{ + 0: "MemoTypeMemoNone", + 1: "MemoTypeMemoText", + 2: "MemoTypeMemoId", + 3: "MemoTypeMemoHash", + 4: "MemoTypeMemoReturn", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for MemoType +func (e MemoType) ValidEnum(v int32) bool { + _, ok := memoTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e MemoType) String() string { + name, _ := memoTypeMap[int32(e)] + return name } // EncodeTo encodes this value using the Encoder. -func (s *Operation) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeBool(s.SourceAccount != nil); err != nil { - return err - } - if s.SourceAccount != nil { - if err = (*s.SourceAccount).EncodeTo(e); err != nil { - return err - } - } - if err = s.Body.EncodeTo(e); err != nil { - return err +func (e MemoType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := memoTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid MemoType enum value", e) } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*Operation)(nil) +var _ decoderFrom = (*MemoType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *Operation) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *MemoType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding Operation: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding MemoType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - var err error - var n, nTmp int - var b bool - b, nTmp, err = d.DecodeBool() - n += nTmp + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %w", err) - } - s.SourceAccount = nil - if b { - s.SourceAccount = new(MuxedAccount) - nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding MuxedAccount: %w", err) - } + return n, fmt.Errorf("decoding MemoType: %w", err) } - nTmp, err = s.Body.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding OperationBody: %w", err) + if _, ok := memoTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid MemoType enum value", v) } + *e = MemoType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s Operation) MarshalBinary() ([]byte, error) { +func (s MemoType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -30949,7 +33188,7 @@ func (s Operation) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *Operation) UnmarshalBinary(inp []byte) error { +func (s *MemoType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -30959,179 +33198,291 @@ func (s *Operation) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*Operation)(nil) - _ encoding.BinaryUnmarshaler = (*Operation)(nil) + _ encoding.BinaryMarshaler = (*MemoType)(nil) + _ encoding.BinaryUnmarshaler = (*MemoType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s Operation) xdrType() {} +func (s MemoType) xdrType() {} -var _ xdrType = (*Operation)(nil) +var _ xdrType = (*MemoType)(nil) -// HashIdPreimageOperationId is an XDR NestedStruct defines as: +// Memo is an XDR Union defines as: // -// struct -// { -// AccountID sourceAccount; -// SequenceNumber seqNum; -// uint32 opNum; -// } -type HashIdPreimageOperationId struct { - SourceAccount AccountId - SeqNum SequenceNumber - OpNum Uint32 +// union Memo switch (MemoType type) +// { +// case MEMO_NONE: +// void; +// case MEMO_TEXT: +// string text<28>; +// case MEMO_ID: +// uint64 id; +// case MEMO_HASH: +// Hash hash; // the hash of what to pull from the content server +// case MEMO_RETURN: +// Hash retHash; // the hash of the tx you are rejecting +// }; +type Memo struct { + Type MemoType + Text *string `xdrmaxsize:"28"` + Id *Uint64 + Hash *Hash + RetHash *Hash } -// EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageOperationId) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.SourceAccount.EncodeTo(e); err != nil { - return err - } - if err = s.SeqNum.EncodeTo(e); err != nil { - return err +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u Memo) SwitchFieldName() string { + return "Type" +} + +// ArmForSwitch returns which field name should be used for storing +// the value for an instance of Memo +func (u Memo) ArmForSwitch(sw int32) (string, bool) { + switch MemoType(sw) { + case MemoTypeMemoNone: + return "", true + case MemoTypeMemoText: + return "Text", true + case MemoTypeMemoId: + return "Id", true + case MemoTypeMemoHash: + return "Hash", true + case MemoTypeMemoReturn: + return "RetHash", true } - if err = s.OpNum.EncodeTo(e); err != nil { - return err + return "-", false +} + +// NewMemo creates a new Memo. +func NewMemo(aType MemoType, value interface{}) (result Memo, err error) { + result.Type = aType + switch MemoType(aType) { + case MemoTypeMemoNone: + // void + case MemoTypeMemoText: + tv, ok := value.(string) + if !ok { + err = errors.New("invalid value, must be string") + return + } + result.Text = &tv + case MemoTypeMemoId: + tv, ok := value.(Uint64) + if !ok { + err = errors.New("invalid value, must be Uint64") + return + } + result.Id = &tv + case MemoTypeMemoHash: + tv, ok := value.(Hash) + if !ok { + err = errors.New("invalid value, must be Hash") + return + } + result.Hash = &tv + case MemoTypeMemoReturn: + tv, ok := value.(Hash) + if !ok { + err = errors.New("invalid value, must be Hash") + return + } + result.RetHash = &tv } - return nil + return } -var _ decoderFrom = (*HashIdPreimageOperationId)(nil) +// MustText retrieves the Text value from the union, +// panicing if the value is not set. +func (u Memo) MustText() string { + val, ok := u.GetText() -// DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageOperationId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { - if maxDepth == 0 { - return 0, fmt.Errorf("decoding HashIdPreimageOperationId: %w", ErrMaxDecodingDepthReached) + if !ok { + panic("arm Text is not set") } - maxDepth -= 1 - var err error - var n, nTmp int - nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) + + return val +} + +// GetText retrieves the Text value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u Memo) GetText() (result string, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Text" { + result = *u.Text + ok = true } - nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %w", err) + + return +} + +// MustId retrieves the Id value from the union, +// panicing if the value is not set. +func (u Memo) MustId() Uint64 { + val, ok := u.GetId() + + if !ok { + panic("arm Id is not set") } - nTmp, err = s.OpNum.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + + return val +} + +// GetId retrieves the Id value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u Memo) GetId() (result Uint64, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Id" { + result = *u.Id + ok = true } - return n, nil + + return } -// MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageOperationId) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err +// MustHash retrieves the Hash value from the union, +// panicing if the value is not set. +func (u Memo) MustHash() Hash { + val, ok := u.GetHash() + + if !ok { + panic("arm Hash is not set") + } + + return val } -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageOperationId) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - o := xdr.DefaultDecodeOptions - o.MaxInputLen = len(inp) - d := xdr.NewDecoderWithOptions(r, o) - _, err := s.DecodeFrom(d, o.MaxDepth) - return err +// GetHash retrieves the Hash value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u Memo) GetHash() (result Hash, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Hash" { + result = *u.Hash + ok = true + } + + return } -var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageOperationId)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageOperationId)(nil) -) +// MustRetHash retrieves the RetHash value from the union, +// panicing if the value is not set. +func (u Memo) MustRetHash() Hash { + val, ok := u.GetRetHash() -// xdrType signals that this type represents XDR values defined by this package. -func (s HashIdPreimageOperationId) xdrType() {} + if !ok { + panic("arm RetHash is not set") + } -var _ xdrType = (*HashIdPreimageOperationId)(nil) + return val +} -// HashIdPreimageRevokeId is an XDR NestedStruct defines as: -// -// struct -// { -// AccountID sourceAccount; -// SequenceNumber seqNum; -// uint32 opNum; -// PoolID liquidityPoolID; -// Asset asset; -// } -type HashIdPreimageRevokeId struct { - SourceAccount AccountId - SeqNum SequenceNumber - OpNum Uint32 - LiquidityPoolId PoolId - Asset Asset +// GetRetHash retrieves the RetHash value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u Memo) GetRetHash() (result Hash, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "RetHash" { + result = *u.RetHash + ok = true + } + + return } // EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageRevokeId) EncodeTo(e *xdr.Encoder) error { +func (u Memo) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.SourceAccount.EncodeTo(e); err != nil { - return err - } - if err = s.SeqNum.EncodeTo(e); err != nil { - return err - } - if err = s.OpNum.EncodeTo(e); err != nil { - return err - } - if err = s.LiquidityPoolId.EncodeTo(e); err != nil { + if err = u.Type.EncodeTo(e); err != nil { return err } - if err = s.Asset.EncodeTo(e); err != nil { - return err + switch MemoType(u.Type) { + case MemoTypeMemoNone: + // Void + return nil + case MemoTypeMemoText: + if _, err = e.EncodeString(string((*u.Text))); err != nil { + return err + } + return nil + case MemoTypeMemoId: + if err = (*u.Id).EncodeTo(e); err != nil { + return err + } + return nil + case MemoTypeMemoHash: + if err = (*u.Hash).EncodeTo(e); err != nil { + return err + } + return nil + case MemoTypeMemoReturn: + if err = (*u.RetHash).EncodeTo(e); err != nil { + return err + } + return nil } - return nil + return fmt.Errorf("Type (MemoType) switch value '%d' is not valid for union Memo", u.Type) } -var _ decoderFrom = (*HashIdPreimageRevokeId)(nil) +var _ decoderFrom = (*Memo)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageRevokeId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *Memo) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding HashIdPreimageRevokeId: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding Memo: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.SourceAccount.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AccountId: %w", err) - } - nTmp, err = s.SeqNum.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %w", err) - } - nTmp, err = s.OpNum.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - nTmp, err = s.LiquidityPoolId.DecodeFrom(d, maxDepth) + nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PoolId: %w", err) + return n, fmt.Errorf("decoding MemoType: %w", err) } - nTmp, err = s.Asset.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %w", err) + switch MemoType(u.Type) { + case MemoTypeMemoNone: + // Void + return n, nil + case MemoTypeMemoText: + u.Text = new(string) + (*u.Text), nTmp, err = d.DecodeString(28) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Text: %w", err) + } + return n, nil + case MemoTypeMemoId: + u.Id = new(Uint64) + nTmp, err = (*u.Id).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint64: %w", err) + } + return n, nil + case MemoTypeMemoHash: + u.Hash = new(Hash) + nTmp, err = (*u.Hash).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + return n, nil + case MemoTypeMemoReturn: + u.RetHash = new(Hash) + nTmp, err = (*u.RetHash).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Hash: %w", err) + } + return n, nil } - return n, nil + return n, fmt.Errorf("union Memo has invalid Type (MemoType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageRevokeId) MarshalBinary() ([]byte, error) { +func (s Memo) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -31139,7 +33490,7 @@ func (s HashIdPreimageRevokeId) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageRevokeId) UnmarshalBinary(inp []byte) error { +func (s *Memo) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -31149,64 +33500,64 @@ func (s *HashIdPreimageRevokeId) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageRevokeId)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageRevokeId)(nil) + _ encoding.BinaryMarshaler = (*Memo)(nil) + _ encoding.BinaryUnmarshaler = (*Memo)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s HashIdPreimageRevokeId) xdrType() {} +func (s Memo) xdrType() {} -var _ xdrType = (*HashIdPreimageRevokeId)(nil) +var _ xdrType = (*Memo)(nil) -// HashIdPreimageContractId is an XDR NestedStruct defines as: +// TimeBounds is an XDR Struct defines as: // -// struct -// { -// Hash networkID; -// ContractIDPreimage contractIDPreimage; -// } -type HashIdPreimageContractId struct { - NetworkId Hash - ContractIdPreimage ContractIdPreimage +// struct TimeBounds +// { +// TimePoint minTime; +// TimePoint maxTime; // 0 here means no maxTime +// }; +type TimeBounds struct { + MinTime TimePoint + MaxTime TimePoint } // EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageContractId) EncodeTo(e *xdr.Encoder) error { +func (s *TimeBounds) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.NetworkId.EncodeTo(e); err != nil { + if err = s.MinTime.EncodeTo(e); err != nil { return err } - if err = s.ContractIdPreimage.EncodeTo(e); err != nil { + if err = s.MaxTime.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*HashIdPreimageContractId)(nil) +var _ decoderFrom = (*TimeBounds)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageContractId) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *TimeBounds) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding HashIdPreimageContractId: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding TimeBounds: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) + nTmp, err = s.MinTime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } - nTmp, err = s.ContractIdPreimage.DecodeFrom(d, maxDepth) + nTmp, err = s.MaxTime.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdPreimage: %w", err) + return n, fmt.Errorf("decoding TimePoint: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageContractId) MarshalBinary() ([]byte, error) { +func (s TimeBounds) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -31214,7 +33565,7 @@ func (s HashIdPreimageContractId) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageContractId) UnmarshalBinary(inp []byte) error { +func (s *TimeBounds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -31224,84 +33575,64 @@ func (s *HashIdPreimageContractId) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageContractId)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageContractId)(nil) + _ encoding.BinaryMarshaler = (*TimeBounds)(nil) + _ encoding.BinaryUnmarshaler = (*TimeBounds)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s HashIdPreimageContractId) xdrType() {} +func (s TimeBounds) xdrType() {} -var _ xdrType = (*HashIdPreimageContractId)(nil) +var _ xdrType = (*TimeBounds)(nil) -// HashIdPreimageSorobanAuthorization is an XDR NestedStruct defines as: +// LedgerBounds is an XDR Struct defines as: // -// struct -// { -// Hash networkID; -// int64 nonce; -// uint32 signatureExpirationLedger; -// SorobanAuthorizedInvocation invocation; -// } -type HashIdPreimageSorobanAuthorization struct { - NetworkId Hash - Nonce Int64 - SignatureExpirationLedger Uint32 - Invocation SorobanAuthorizedInvocation +// struct LedgerBounds +// { +// uint32 minLedger; +// uint32 maxLedger; // 0 here means no maxLedger +// }; +type LedgerBounds struct { + MinLedger Uint32 + MaxLedger Uint32 } // EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageSorobanAuthorization) EncodeTo(e *xdr.Encoder) error { +func (s *LedgerBounds) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.NetworkId.EncodeTo(e); err != nil { - return err - } - if err = s.Nonce.EncodeTo(e); err != nil { - return err - } - if err = s.SignatureExpirationLedger.EncodeTo(e); err != nil { + if err = s.MinLedger.EncodeTo(e); err != nil { return err } - if err = s.Invocation.EncodeTo(e); err != nil { + if err = s.MaxLedger.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*HashIdPreimageSorobanAuthorization)(nil) +var _ decoderFrom = (*LedgerBounds)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageSorobanAuthorization) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *LedgerBounds) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding LedgerBounds: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) - } - nTmp, err = s.Nonce.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int64: %w", err) - } - nTmp, err = s.SignatureExpirationLedger.DecodeFrom(d, maxDepth) + nTmp, err = s.MinLedger.DecodeFrom(d, maxDepth) n += nTmp if err != nil { return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.Invocation.DecodeFrom(d, maxDepth) + nTmp, err = s.MaxLedger.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageSorobanAuthorization) MarshalBinary() ([]byte, error) { +func (s LedgerBounds) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -31309,7 +33640,7 @@ func (s HashIdPreimageSorobanAuthorization) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageSorobanAuthorization) UnmarshalBinary(inp []byte) error { +func (s *LedgerBounds) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -31319,301 +33650,193 @@ func (s *HashIdPreimageSorobanAuthorization) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageSorobanAuthorization)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageSorobanAuthorization)(nil) + _ encoding.BinaryMarshaler = (*LedgerBounds)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerBounds)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s HashIdPreimageSorobanAuthorization) xdrType() {} +func (s LedgerBounds) xdrType() {} -var _ xdrType = (*HashIdPreimageSorobanAuthorization)(nil) +var _ xdrType = (*LedgerBounds)(nil) -// HashIdPreimage is an XDR Union defines as: +// PreconditionsV2 is an XDR Struct defines as: // -// union HashIDPreimage switch (EnvelopeType type) +// struct PreconditionsV2 // { -// case ENVELOPE_TYPE_OP_ID: -// struct -// { -// AccountID sourceAccount; -// SequenceNumber seqNum; -// uint32 opNum; -// } operationID; -// case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: -// struct -// { -// AccountID sourceAccount; -// SequenceNumber seqNum; -// uint32 opNum; -// PoolID liquidityPoolID; -// Asset asset; -// } revokeID; -// case ENVELOPE_TYPE_CONTRACT_ID: -// struct -// { -// Hash networkID; -// ContractIDPreimage contractIDPreimage; -// } contractID; -// case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: -// struct -// { -// Hash networkID; -// int64 nonce; -// uint32 signatureExpirationLedger; -// SorobanAuthorizedInvocation invocation; -// } sorobanAuthorization; +// TimeBounds* timeBounds; +// +// // Transaction only valid for ledger numbers n such that +// // minLedger <= n < maxLedger (if maxLedger == 0, then +// // only minLedger is checked) +// LedgerBounds* ledgerBounds; +// +// // If NULL, only valid when sourceAccount's sequence number +// // is seqNum - 1. Otherwise, valid when sourceAccount's +// // sequence number n satisfies minSeqNum <= n < tx.seqNum. +// // Note that after execution the account's sequence number +// // is always raised to tx.seqNum, and a transaction is not +// // valid if tx.seqNum is too high to ensure replay protection. +// SequenceNumber* minSeqNum; +// +// // For the transaction to be valid, the current ledger time must +// // be at least minSeqAge greater than sourceAccount's seqTime. +// Duration minSeqAge; +// +// // For the transaction to be valid, the current ledger number +// // must be at least minSeqLedgerGap greater than sourceAccount's +// // seqLedger. +// uint32 minSeqLedgerGap; +// +// // For the transaction to be valid, there must be a signature +// // corresponding to every Signer in this array, even if the +// // signature is not otherwise required by the sourceAccount or +// // operations. +// SignerKey extraSigners<2>; // }; -type HashIdPreimage struct { - Type EnvelopeType - OperationId *HashIdPreimageOperationId - RevokeId *HashIdPreimageRevokeId - ContractId *HashIdPreimageContractId - SorobanAuthorization *HashIdPreimageSorobanAuthorization -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u HashIdPreimage) SwitchFieldName() string { - return "Type" +type PreconditionsV2 struct { + TimeBounds *TimeBounds + LedgerBounds *LedgerBounds + MinSeqNum *SequenceNumber + MinSeqAge Duration + MinSeqLedgerGap Uint32 + ExtraSigners []SignerKey `xdrmaxsize:"2"` } -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of HashIdPreimage -func (u HashIdPreimage) ArmForSwitch(sw int32) (string, bool) { - switch EnvelopeType(sw) { - case EnvelopeTypeEnvelopeTypeOpId: - return "OperationId", true - case EnvelopeTypeEnvelopeTypePoolRevokeOpId: - return "RevokeId", true - case EnvelopeTypeEnvelopeTypeContractId: - return "ContractId", true - case EnvelopeTypeEnvelopeTypeSorobanAuthorization: - return "SorobanAuthorization", true +// EncodeTo encodes this value using the Encoder. +func (s *PreconditionsV2) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeBool(s.TimeBounds != nil); err != nil { + return err } - return "-", false -} - -// NewHashIdPreimage creates a new HashIdPreimage. -func NewHashIdPreimage(aType EnvelopeType, value interface{}) (result HashIdPreimage, err error) { - result.Type = aType - switch EnvelopeType(aType) { - case EnvelopeTypeEnvelopeTypeOpId: - tv, ok := value.(HashIdPreimageOperationId) - if !ok { - err = errors.New("invalid value, must be HashIdPreimageOperationId") - return - } - result.OperationId = &tv - case EnvelopeTypeEnvelopeTypePoolRevokeOpId: - tv, ok := value.(HashIdPreimageRevokeId) - if !ok { - err = errors.New("invalid value, must be HashIdPreimageRevokeId") - return - } - result.RevokeId = &tv - case EnvelopeTypeEnvelopeTypeContractId: - tv, ok := value.(HashIdPreimageContractId) - if !ok { - err = errors.New("invalid value, must be HashIdPreimageContractId") - return - } - result.ContractId = &tv - case EnvelopeTypeEnvelopeTypeSorobanAuthorization: - tv, ok := value.(HashIdPreimageSorobanAuthorization) - if !ok { - err = errors.New("invalid value, must be HashIdPreimageSorobanAuthorization") - return + if s.TimeBounds != nil { + if err = (*s.TimeBounds).EncodeTo(e); err != nil { + return err } - result.SorobanAuthorization = &tv - } - return -} - -// MustOperationId retrieves the OperationId value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustOperationId() HashIdPreimageOperationId { - val, ok := u.GetOperationId() - - if !ok { - panic("arm OperationId is not set") - } - - return val -} - -// GetOperationId retrieves the OperationId value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetOperationId() (result HashIdPreimageOperationId, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "OperationId" { - result = *u.OperationId - ok = true } - - return -} - -// MustRevokeId retrieves the RevokeId value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustRevokeId() HashIdPreimageRevokeId { - val, ok := u.GetRevokeId() - - if !ok { - panic("arm RevokeId is not set") + if _, err = e.EncodeBool(s.LedgerBounds != nil); err != nil { + return err } - - return val -} - -// GetRevokeId retrieves the RevokeId value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetRevokeId() (result HashIdPreimageRevokeId, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "RevokeId" { - result = *u.RevokeId - ok = true + if s.LedgerBounds != nil { + if err = (*s.LedgerBounds).EncodeTo(e); err != nil { + return err + } } - - return -} - -// MustContractId retrieves the ContractId value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustContractId() HashIdPreimageContractId { - val, ok := u.GetContractId() - - if !ok { - panic("arm ContractId is not set") + if _, err = e.EncodeBool(s.MinSeqNum != nil); err != nil { + return err } - - return val -} - -// GetContractId retrieves the ContractId value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetContractId() (result HashIdPreimageContractId, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ContractId" { - result = *u.ContractId - ok = true + if s.MinSeqNum != nil { + if err = (*s.MinSeqNum).EncodeTo(e); err != nil { + return err + } } - - return -} - -// MustSorobanAuthorization retrieves the SorobanAuthorization value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustSorobanAuthorization() HashIdPreimageSorobanAuthorization { - val, ok := u.GetSorobanAuthorization() - - if !ok { - panic("arm SorobanAuthorization is not set") + if err = s.MinSeqAge.EncodeTo(e); err != nil { + return err } - - return val -} - -// GetSorobanAuthorization retrieves the SorobanAuthorization value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetSorobanAuthorization() (result HashIdPreimageSorobanAuthorization, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "SorobanAuthorization" { - result = *u.SorobanAuthorization - ok = true + if err = s.MinSeqLedgerGap.EncodeTo(e); err != nil { + return err } - - return -} - -// EncodeTo encodes this value using the Encoder. -func (u HashIdPreimage) EncodeTo(e *xdr.Encoder) error { - var err error - if err = u.Type.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s.ExtraSigners))); err != nil { return err } - switch EnvelopeType(u.Type) { - case EnvelopeTypeEnvelopeTypeOpId: - if err = (*u.OperationId).EncodeTo(e); err != nil { - return err - } - return nil - case EnvelopeTypeEnvelopeTypePoolRevokeOpId: - if err = (*u.RevokeId).EncodeTo(e); err != nil { - return err - } - return nil - case EnvelopeTypeEnvelopeTypeContractId: - if err = (*u.ContractId).EncodeTo(e); err != nil { - return err - } - return nil - case EnvelopeTypeEnvelopeTypeSorobanAuthorization: - if err = (*u.SorobanAuthorization).EncodeTo(e); err != nil { + for i := 0; i < len(s.ExtraSigners); i++ { + if err = s.ExtraSigners[i].EncodeTo(e); err != nil { return err } - return nil } - return fmt.Errorf("Type (EnvelopeType) switch value '%d' is not valid for union HashIdPreimage", u.Type) + return nil } -var _ decoderFrom = (*HashIdPreimage)(nil) +var _ decoderFrom = (*PreconditionsV2)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *HashIdPreimage) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding HashIdPreimage: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding PreconditionsV2: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + var b bool + b, nTmp, err = d.DecodeBool() n += nTmp if err != nil { - return n, fmt.Errorf("decoding EnvelopeType: %w", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } - switch EnvelopeType(u.Type) { - case EnvelopeTypeEnvelopeTypeOpId: - u.OperationId = new(HashIdPreimageOperationId) - nTmp, err = (*u.OperationId).DecodeFrom(d, maxDepth) + s.TimeBounds = nil + if b { + s.TimeBounds = new(TimeBounds) + nTmp, err = s.TimeBounds.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageOperationId: %w", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } - return n, nil - case EnvelopeTypeEnvelopeTypePoolRevokeOpId: - u.RevokeId = new(HashIdPreimageRevokeId) - nTmp, err = (*u.RevokeId).DecodeFrom(d, maxDepth) + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerBounds: %w", err) + } + s.LedgerBounds = nil + if b { + s.LedgerBounds = new(LedgerBounds) + nTmp, err = s.LedgerBounds.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageRevokeId: %w", err) + return n, fmt.Errorf("decoding LedgerBounds: %w", err) } - return n, nil - case EnvelopeTypeEnvelopeTypeContractId: - u.ContractId = new(HashIdPreimageContractId) - nTmp, err = (*u.ContractId).DecodeFrom(d, maxDepth) + } + b, nTmp, err = d.DecodeBool() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SequenceNumber: %w", err) + } + s.MinSeqNum = nil + if b { + s.MinSeqNum = new(SequenceNumber) + nTmp, err = s.MinSeqNum.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageContractId: %w", err) + return n, fmt.Errorf("decoding SequenceNumber: %w", err) } - return n, nil - case EnvelopeTypeEnvelopeTypeSorobanAuthorization: - u.SorobanAuthorization = new(HashIdPreimageSorobanAuthorization) - nTmp, err = (*u.SorobanAuthorization).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %w", err) + } + nTmp, err = s.MinSeqAge.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Duration: %w", err) + } + nTmp, err = s.MinSeqLedgerGap.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignerKey: %w", err) + } + if l > 2 { + return n, fmt.Errorf("decoding SignerKey: data size (%d) exceeds size limit (2)", l) + } + s.ExtraSigners = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding SignerKey: length (%d) exceeds remaining input length (%d)", l, il) + } + s.ExtraSigners = make([]SignerKey, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.ExtraSigners[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SignerKey: %w", err) + } } - return n, nil } - return n, fmt.Errorf("union HashIdPreimage has invalid Type (EnvelopeType) switch value '%d'", u.Type) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimage) MarshalBinary() ([]byte, error) { +func (s PreconditionsV2) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -31621,7 +33844,7 @@ func (s HashIdPreimage) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimage) UnmarshalBinary(inp []byte) error { +func (s *PreconditionsV2) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -31631,86 +33854,80 @@ func (s *HashIdPreimage) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HashIdPreimage)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimage)(nil) + _ encoding.BinaryMarshaler = (*PreconditionsV2)(nil) + _ encoding.BinaryUnmarshaler = (*PreconditionsV2)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s HashIdPreimage) xdrType() {} +func (s PreconditionsV2) xdrType() {} -var _ xdrType = (*HashIdPreimage)(nil) +var _ xdrType = (*PreconditionsV2)(nil) -// MemoType is an XDR Enum defines as: +// PreconditionType is an XDR Enum defines as: // -// enum MemoType +// enum PreconditionType // { -// MEMO_NONE = 0, -// MEMO_TEXT = 1, -// MEMO_ID = 2, -// MEMO_HASH = 3, -// MEMO_RETURN = 4 +// PRECOND_NONE = 0, +// PRECOND_TIME = 1, +// PRECOND_V2 = 2 // }; -type MemoType int32 +type PreconditionType int32 const ( - MemoTypeMemoNone MemoType = 0 - MemoTypeMemoText MemoType = 1 - MemoTypeMemoId MemoType = 2 - MemoTypeMemoHash MemoType = 3 - MemoTypeMemoReturn MemoType = 4 + PreconditionTypePrecondNone PreconditionType = 0 + PreconditionTypePrecondTime PreconditionType = 1 + PreconditionTypePrecondV2 PreconditionType = 2 ) -var memoTypeMap = map[int32]string{ - 0: "MemoTypeMemoNone", - 1: "MemoTypeMemoText", - 2: "MemoTypeMemoId", - 3: "MemoTypeMemoHash", - 4: "MemoTypeMemoReturn", +var preconditionTypeMap = map[int32]string{ + 0: "PreconditionTypePrecondNone", + 1: "PreconditionTypePrecondTime", + 2: "PreconditionTypePrecondV2", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for MemoType -func (e MemoType) ValidEnum(v int32) bool { - _, ok := memoTypeMap[v] +// the Enum interface for PreconditionType +func (e PreconditionType) ValidEnum(v int32) bool { + _, ok := preconditionTypeMap[v] return ok } // String returns the name of `e` -func (e MemoType) String() string { - name, _ := memoTypeMap[int32(e)] +func (e PreconditionType) String() string { + name, _ := preconditionTypeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e MemoType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := memoTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid MemoType enum value", e) +func (e PreconditionType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := preconditionTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid PreconditionType enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*MemoType)(nil) +var _ decoderFrom = (*PreconditionType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *MemoType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (e *PreconditionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding MemoType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding PreconditionType: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding MemoType: %w", err) + return n, fmt.Errorf("decoding PreconditionType: %w", err) } - if _, ok := memoTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid MemoType enum value", v) + if _, ok := preconditionTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid PreconditionType enum value", v) } - *e = MemoType(v) + *e = PreconditionType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s MemoType) MarshalBinary() ([]byte, error) { +func (s PreconditionType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -31718,7 +33935,7 @@ func (s MemoType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *MemoType) UnmarshalBinary(inp []byte) error { +func (s *PreconditionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -31728,194 +33945,120 @@ func (s *MemoType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*MemoType)(nil) - _ encoding.BinaryUnmarshaler = (*MemoType)(nil) + _ encoding.BinaryMarshaler = (*PreconditionType)(nil) + _ encoding.BinaryUnmarshaler = (*PreconditionType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s MemoType) xdrType() {} +func (s PreconditionType) xdrType() {} -var _ xdrType = (*MemoType)(nil) +var _ xdrType = (*PreconditionType)(nil) -// Memo is an XDR Union defines as: +// Preconditions is an XDR Union defines as: // -// union Memo switch (MemoType type) +// union Preconditions switch (PreconditionType type) // { -// case MEMO_NONE: +// case PRECOND_NONE: // void; -// case MEMO_TEXT: -// string text<28>; -// case MEMO_ID: -// uint64 id; -// case MEMO_HASH: -// Hash hash; // the hash of what to pull from the content server -// case MEMO_RETURN: -// Hash retHash; // the hash of the tx you are rejecting +// case PRECOND_TIME: +// TimeBounds timeBounds; +// case PRECOND_V2: +// PreconditionsV2 v2; // }; -type Memo struct { - Type MemoType - Text *string `xdrmaxsize:"28"` - Id *Uint64 - Hash *Hash - RetHash *Hash +type Preconditions struct { + Type PreconditionType + TimeBounds *TimeBounds + V2 *PreconditionsV2 } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u Memo) SwitchFieldName() string { +func (u Preconditions) SwitchFieldName() string { return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of Memo -func (u Memo) ArmForSwitch(sw int32) (string, bool) { - switch MemoType(sw) { - case MemoTypeMemoNone: +// the value for an instance of Preconditions +func (u Preconditions) ArmForSwitch(sw int32) (string, bool) { + switch PreconditionType(sw) { + case PreconditionTypePrecondNone: return "", true - case MemoTypeMemoText: - return "Text", true - case MemoTypeMemoId: - return "Id", true - case MemoTypeMemoHash: - return "Hash", true - case MemoTypeMemoReturn: - return "RetHash", true + case PreconditionTypePrecondTime: + return "TimeBounds", true + case PreconditionTypePrecondV2: + return "V2", true } return "-", false } -// NewMemo creates a new Memo. -func NewMemo(aType MemoType, value interface{}) (result Memo, err error) { +// NewPreconditions creates a new Preconditions. +func NewPreconditions(aType PreconditionType, value interface{}) (result Preconditions, err error) { result.Type = aType - switch MemoType(aType) { - case MemoTypeMemoNone: + switch PreconditionType(aType) { + case PreconditionTypePrecondNone: // void - case MemoTypeMemoText: - tv, ok := value.(string) - if !ok { - err = errors.New("invalid value, must be string") - return - } - result.Text = &tv - case MemoTypeMemoId: - tv, ok := value.(Uint64) - if !ok { - err = errors.New("invalid value, must be Uint64") - return - } - result.Id = &tv - case MemoTypeMemoHash: - tv, ok := value.(Hash) + case PreconditionTypePrecondTime: + tv, ok := value.(TimeBounds) if !ok { - err = errors.New("invalid value, must be Hash") + err = errors.New("invalid value, must be TimeBounds") return } - result.Hash = &tv - case MemoTypeMemoReturn: - tv, ok := value.(Hash) + result.TimeBounds = &tv + case PreconditionTypePrecondV2: + tv, ok := value.(PreconditionsV2) if !ok { - err = errors.New("invalid value, must be Hash") + err = errors.New("invalid value, must be PreconditionsV2") return } - result.RetHash = &tv - } - return -} - -// MustText retrieves the Text value from the union, -// panicing if the value is not set. -func (u Memo) MustText() string { - val, ok := u.GetText() - - if !ok { - panic("arm Text is not set") - } - - return val -} - -// GetText retrieves the Text value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u Memo) GetText() (result string, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Text" { - result = *u.Text - ok = true - } - - return -} - -// MustId retrieves the Id value from the union, -// panicing if the value is not set. -func (u Memo) MustId() Uint64 { - val, ok := u.GetId() - - if !ok { - panic("arm Id is not set") - } - - return val -} - -// GetId retrieves the Id value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u Memo) GetId() (result Uint64, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Id" { - result = *u.Id - ok = true + result.V2 = &tv } - return } -// MustHash retrieves the Hash value from the union, +// MustTimeBounds retrieves the TimeBounds value from the union, // panicing if the value is not set. -func (u Memo) MustHash() Hash { - val, ok := u.GetHash() +func (u Preconditions) MustTimeBounds() TimeBounds { + val, ok := u.GetTimeBounds() if !ok { - panic("arm Hash is not set") + panic("arm TimeBounds is not set") } return val } -// GetHash retrieves the Hash value from the union, +// GetTimeBounds retrieves the TimeBounds value from the union, // returning ok if the union's switch indicated the value is valid. -func (u Memo) GetHash() (result Hash, ok bool) { +func (u Preconditions) GetTimeBounds() (result TimeBounds, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Hash" { - result = *u.Hash + if armName == "TimeBounds" { + result = *u.TimeBounds ok = true } return } -// MustRetHash retrieves the RetHash value from the union, +// MustV2 retrieves the V2 value from the union, // panicing if the value is not set. -func (u Memo) MustRetHash() Hash { - val, ok := u.GetRetHash() +func (u Preconditions) MustV2() PreconditionsV2 { + val, ok := u.GetV2() if !ok { - panic("arm RetHash is not set") + panic("arm V2 is not set") } return val } -// GetRetHash retrieves the RetHash value from the union, +// GetV2 retrieves the V2 value from the union, // returning ok if the union's switch indicated the value is valid. -func (u Memo) GetRetHash() (result Hash, ok bool) { +func (u Preconditions) GetV2() (result PreconditionsV2, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "RetHash" { - result = *u.RetHash + if armName == "V2" { + result = *u.V2 ok = true } @@ -31923,45 +34066,35 @@ func (u Memo) GetRetHash() (result Hash, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u Memo) EncodeTo(e *xdr.Encoder) error { +func (u Preconditions) EncodeTo(e *xdr.Encoder) error { var err error if err = u.Type.EncodeTo(e); err != nil { return err } - switch MemoType(u.Type) { - case MemoTypeMemoNone: + switch PreconditionType(u.Type) { + case PreconditionTypePrecondNone: // Void return nil - case MemoTypeMemoText: - if _, err = e.EncodeString(string((*u.Text))); err != nil { - return err - } - return nil - case MemoTypeMemoId: - if err = (*u.Id).EncodeTo(e); err != nil { - return err - } - return nil - case MemoTypeMemoHash: - if err = (*u.Hash).EncodeTo(e); err != nil { + case PreconditionTypePrecondTime: + if err = (*u.TimeBounds).EncodeTo(e); err != nil { return err } return nil - case MemoTypeMemoReturn: - if err = (*u.RetHash).EncodeTo(e); err != nil { + case PreconditionTypePrecondV2: + if err = (*u.V2).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (MemoType) switch value '%d' is not valid for union Memo", u.Type) + return fmt.Errorf("Type (PreconditionType) switch value '%d' is not valid for union Preconditions", u.Type) } -var _ decoderFrom = (*Memo)(nil) +var _ decoderFrom = (*Preconditions)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *Memo) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *Preconditions) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding Memo: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding Preconditions: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error @@ -31969,50 +34102,236 @@ func (u *Memo) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { nTmp, err = u.Type.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding MemoType: %w", err) + return n, fmt.Errorf("decoding PreconditionType: %w", err) } - switch MemoType(u.Type) { - case MemoTypeMemoNone: + switch PreconditionType(u.Type) { + case PreconditionTypePrecondNone: // Void return n, nil - case MemoTypeMemoText: - u.Text = new(string) - (*u.Text), nTmp, err = d.DecodeString(28) + case PreconditionTypePrecondTime: + u.TimeBounds = new(TimeBounds) + nTmp, err = (*u.TimeBounds).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Text: %w", err) + return n, fmt.Errorf("decoding TimeBounds: %w", err) } return n, nil - case MemoTypeMemoId: - u.Id = new(Uint64) - nTmp, err = (*u.Id).DecodeFrom(d, maxDepth) + case PreconditionTypePrecondV2: + u.V2 = new(PreconditionsV2) + nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding PreconditionsV2: %w", err) } return n, nil - case MemoTypeMemoHash: - u.Hash = new(Hash) - nTmp, err = (*u.Hash).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + } + return n, fmt.Errorf("union Preconditions has invalid Type (PreconditionType) switch value '%d'", u.Type) +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s Preconditions) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *Preconditions) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*Preconditions)(nil) + _ encoding.BinaryUnmarshaler = (*Preconditions)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s Preconditions) xdrType() {} + +var _ xdrType = (*Preconditions)(nil) + +// LedgerFootprint is an XDR Struct defines as: +// +// struct LedgerFootprint +// { +// LedgerKey readOnly<>; +// LedgerKey readWrite<>; +// }; +type LedgerFootprint struct { + ReadOnly []LedgerKey + ReadWrite []LedgerKey +} + +// EncodeTo encodes this value using the Encoder. +func (s *LedgerFootprint) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeUint(uint32(len(s.ReadOnly))); err != nil { + return err + } + for i := 0; i < len(s.ReadOnly); i++ { + if err = s.ReadOnly[i].EncodeTo(e); err != nil { + return err } - return n, nil - case MemoTypeMemoReturn: - u.RetHash = new(Hash) - nTmp, err = (*u.RetHash).DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %w", err) + } + if _, err = e.EncodeUint(uint32(len(s.ReadWrite))); err != nil { + return err + } + for i := 0; i < len(s.ReadWrite); i++ { + if err = s.ReadWrite[i].EncodeTo(e); err != nil { + return err } - return n, nil } - return n, fmt.Errorf("union Memo has invalid Type (MemoType) switch value '%d'", u.Type) + return nil +} + +var _ decoderFrom = (*LedgerFootprint)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding LedgerFootprint: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + s.ReadOnly = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + } + s.ReadOnly = make([]LedgerKey, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.ReadOnly[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + s.ReadWrite = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + } + s.ReadWrite = make([]LedgerKey, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.ReadWrite[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s LedgerFootprint) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *LedgerFootprint) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*LedgerFootprint)(nil) + _ encoding.BinaryUnmarshaler = (*LedgerFootprint)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s LedgerFootprint) xdrType() {} + +var _ xdrType = (*LedgerFootprint)(nil) + +// ArchivalProofType is an XDR Enum defines as: +// +// enum ArchivalProofType +// { +// EXISTENCE = 0, +// NONEXISTENCE = 1 +// }; +type ArchivalProofType int32 + +const ( + ArchivalProofTypeExistence ArchivalProofType = 0 + ArchivalProofTypeNonexistence ArchivalProofType = 1 +) + +var archivalProofTypeMap = map[int32]string{ + 0: "ArchivalProofTypeExistence", + 1: "ArchivalProofTypeNonexistence", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for ArchivalProofType +func (e ArchivalProofType) ValidEnum(v int32) bool { + _, ok := archivalProofTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e ArchivalProofType) String() string { + name, _ := archivalProofTypeMap[int32(e)] + return name +} + +// EncodeTo encodes this value using the Encoder. +func (e ArchivalProofType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := archivalProofTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ArchivalProofType enum value", e) + } + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*ArchivalProofType)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (e *ArchivalProofType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ArchivalProofType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + v, n, err := d.DecodeInt() + if err != nil { + return n, fmt.Errorf("decoding ArchivalProofType: %w", err) + } + if _, ok := archivalProofTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ArchivalProofType enum value", v) + } + *e = ArchivalProofType(v) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s Memo) MarshalBinary() ([]byte, error) { +func (s ArchivalProofType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -32020,7 +34339,7 @@ func (s Memo) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *Memo) UnmarshalBinary(inp []byte) error { +func (s *ArchivalProofType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -32030,64 +34349,64 @@ func (s *Memo) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*Memo)(nil) - _ encoding.BinaryUnmarshaler = (*Memo)(nil) + _ encoding.BinaryMarshaler = (*ArchivalProofType)(nil) + _ encoding.BinaryUnmarshaler = (*ArchivalProofType)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s Memo) xdrType() {} +func (s ArchivalProofType) xdrType() {} -var _ xdrType = (*Memo)(nil) +var _ xdrType = (*ArchivalProofType)(nil) -// TimeBounds is an XDR Struct defines as: +// ArchivalProofNode is an XDR Struct defines as: // -// struct TimeBounds +// struct ArchivalProofNode // { -// TimePoint minTime; -// TimePoint maxTime; // 0 here means no maxTime +// uint32 index; +// Hash hash; // }; -type TimeBounds struct { - MinTime TimePoint - MaxTime TimePoint +type ArchivalProofNode struct { + Index Uint32 + Hash Hash } // EncodeTo encodes this value using the Encoder. -func (s *TimeBounds) EncodeTo(e *xdr.Encoder) error { +func (s *ArchivalProofNode) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.MinTime.EncodeTo(e); err != nil { + if err = s.Index.EncodeTo(e); err != nil { return err } - if err = s.MaxTime.EncodeTo(e); err != nil { + if err = s.Hash.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*TimeBounds)(nil) +var _ decoderFrom = (*ArchivalProofNode)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *TimeBounds) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ArchivalProofNode) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding TimeBounds: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ArchivalProofNode: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.MinTime.DecodeFrom(d, maxDepth) + nTmp, err = s.Index.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimePoint: %w", err) + return n, fmt.Errorf("decoding Uint32: %w", err) } - nTmp, err = s.MaxTime.DecodeFrom(d, maxDepth) + nTmp, err = s.Hash.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimePoint: %w", err) + return n, fmt.Errorf("decoding Hash: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s TimeBounds) MarshalBinary() ([]byte, error) { +func (s ArchivalProofNode) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -32095,7 +34414,7 @@ func (s TimeBounds) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TimeBounds) UnmarshalBinary(inp []byte) error { +func (s *ArchivalProofNode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -32105,64 +34424,69 @@ func (s *TimeBounds) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*TimeBounds)(nil) - _ encoding.BinaryUnmarshaler = (*TimeBounds)(nil) + _ encoding.BinaryMarshaler = (*ArchivalProofNode)(nil) + _ encoding.BinaryUnmarshaler = (*ArchivalProofNode)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s TimeBounds) xdrType() {} +func (s ArchivalProofNode) xdrType() {} -var _ xdrType = (*TimeBounds)(nil) +var _ xdrType = (*ArchivalProofNode)(nil) -// LedgerBounds is an XDR Struct defines as: +// ProofLevel is an XDR Typedef defines as: // -// struct LedgerBounds -// { -// uint32 minLedger; -// uint32 maxLedger; // 0 here means no maxLedger -// }; -type LedgerBounds struct { - MinLedger Uint32 - MaxLedger Uint32 -} +// typedef ArchivalProofNode ProofLevel<>; +type ProofLevel []ArchivalProofNode // EncodeTo encodes this value using the Encoder. -func (s *LedgerBounds) EncodeTo(e *xdr.Encoder) error { +func (s ProofLevel) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.MinLedger.EncodeTo(e); err != nil { + if _, err = e.EncodeUint(uint32(len(s))); err != nil { return err } - if err = s.MaxLedger.EncodeTo(e); err != nil { - return err + for i := 0; i < len(s); i++ { + if err = s[i].EncodeTo(e); err != nil { + return err + } } return nil } -var _ decoderFrom = (*LedgerBounds)(nil) +var _ decoderFrom = (*ProofLevel)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerBounds) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ProofLevel) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerBounds: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ProofLevel: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = s.MinLedger.DecodeFrom(d, maxDepth) + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + return n, fmt.Errorf("decoding ArchivalProofNode: %w", err) } - nTmp, err = s.MaxLedger.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) + (*s) = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ArchivalProofNode: length (%d) exceeds remaining input length (%d)", l, il) + } + (*s) = make([]ArchivalProofNode, l) + for i := uint32(0); i < l; i++ { + nTmp, err = (*s)[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ArchivalProofNode: %w", err) + } + } } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerBounds) MarshalBinary() ([]byte, error) { +func (s ProofLevel) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -32170,7 +34494,7 @@ func (s LedgerBounds) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerBounds) UnmarshalBinary(inp []byte) error { +func (s *ProofLevel) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -32180,185 +34504,98 @@ func (s *LedgerBounds) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerBounds)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerBounds)(nil) + _ encoding.BinaryMarshaler = (*ProofLevel)(nil) + _ encoding.BinaryUnmarshaler = (*ProofLevel)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerBounds) xdrType() {} +func (s ProofLevel) xdrType() {} -var _ xdrType = (*LedgerBounds)(nil) +var _ xdrType = (*ProofLevel)(nil) -// PreconditionsV2 is an XDR Struct defines as: +// NonexistenceProofBody is an XDR Struct defines as: // -// struct PreconditionsV2 +// struct NonexistenceProofBody // { -// TimeBounds* timeBounds; -// -// // Transaction only valid for ledger numbers n such that -// // minLedger <= n < maxLedger (if maxLedger == 0, then -// // only minLedger is checked) -// LedgerBounds* ledgerBounds; -// -// // If NULL, only valid when sourceAccount's sequence number -// // is seqNum - 1. Otherwise, valid when sourceAccount's -// // sequence number n satisfies minSeqNum <= n < tx.seqNum. -// // Note that after execution the account's sequence number -// // is always raised to tx.seqNum, and a transaction is not -// // valid if tx.seqNum is too high to ensure replay protection. -// SequenceNumber* minSeqNum; -// -// // For the transaction to be valid, the current ledger time must -// // be at least minSeqAge greater than sourceAccount's seqTime. -// Duration minSeqAge; +// ColdArchiveBucketEntry entriesToProve<>; // -// // For the transaction to be valid, the current ledger number -// // must be at least minSeqLedgerGap greater than sourceAccount's -// // seqLedger. -// uint32 minSeqLedgerGap; -// -// // For the transaction to be valid, there must be a signature -// // corresponding to every Signer in this array, even if the -// // signature is not otherwise required by the sourceAccount or -// // operations. -// SignerKey extraSigners<2>; +// // Vector of vectors, where proofLevels[level] +// // contains all HashNodes that correspond with that level +// ProofLevel proofLevels<>; // }; -type PreconditionsV2 struct { - TimeBounds *TimeBounds - LedgerBounds *LedgerBounds - MinSeqNum *SequenceNumber - MinSeqAge Duration - MinSeqLedgerGap Uint32 - ExtraSigners []SignerKey `xdrmaxsize:"2"` +type NonexistenceProofBody struct { + EntriesToProve []ColdArchiveBucketEntry + ProofLevels []ProofLevel } // EncodeTo encodes this value using the Encoder. -func (s *PreconditionsV2) EncodeTo(e *xdr.Encoder) error { +func (s *NonexistenceProofBody) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeBool(s.TimeBounds != nil); err != nil { - return err - } - if s.TimeBounds != nil { - if err = (*s.TimeBounds).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.LedgerBounds != nil); err != nil { - return err - } - if s.LedgerBounds != nil { - if err = (*s.LedgerBounds).EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeBool(s.MinSeqNum != nil); err != nil { + if _, err = e.EncodeUint(uint32(len(s.EntriesToProve))); err != nil { return err } - if s.MinSeqNum != nil { - if err = (*s.MinSeqNum).EncodeTo(e); err != nil { + for i := 0; i < len(s.EntriesToProve); i++ { + if err = s.EntriesToProve[i].EncodeTo(e); err != nil { return err } } - if err = s.MinSeqAge.EncodeTo(e); err != nil { - return err - } - if err = s.MinSeqLedgerGap.EncodeTo(e); err != nil { - return err - } - if _, err = e.EncodeUint(uint32(len(s.ExtraSigners))); err != nil { + if _, err = e.EncodeUint(uint32(len(s.ProofLevels))); err != nil { return err } - for i := 0; i < len(s.ExtraSigners); i++ { - if err = s.ExtraSigners[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.ProofLevels); i++ { + if err = s.ProofLevels[i].EncodeTo(e); err != nil { return err } } return nil } -var _ decoderFrom = (*PreconditionsV2)(nil) +var _ decoderFrom = (*NonexistenceProofBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *NonexistenceProofBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding PreconditionsV2: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding NonexistenceProofBody: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var b bool - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %w", err) - } - s.TimeBounds = nil - if b { - s.TimeBounds = new(TimeBounds) - nTmp, err = s.TimeBounds.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %w", err) - } - } - b, nTmp, err = d.DecodeBool() + var l uint32 + l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerBounds: %w", err) + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: %w", err) } - s.LedgerBounds = nil - if b { - s.LedgerBounds = new(LedgerBounds) - nTmp, err = s.LedgerBounds.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerBounds: %w", err) + s.EntriesToProve = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: length (%d) exceeds remaining input length (%d)", l, il) } - } - b, nTmp, err = d.DecodeBool() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %w", err) - } - s.MinSeqNum = nil - if b { - s.MinSeqNum = new(SequenceNumber) - nTmp, err = s.MinSeqNum.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding SequenceNumber: %w", err) + s.EntriesToProve = make([]ColdArchiveBucketEntry, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.EntriesToProve[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: %w", err) + } } } - nTmp, err = s.MinSeqAge.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Duration: %w", err) - } - nTmp, err = s.MinSeqLedgerGap.DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %w", err) - } - var l uint32 l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKey: %w", err) - } - if l > 2 { - return n, fmt.Errorf("decoding SignerKey: data size (%d) exceeds size limit (2)", l) + return n, fmt.Errorf("decoding ProofLevel: %w", err) } - s.ExtraSigners = nil + s.ProofLevels = nil if l > 0 { if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding SignerKey: length (%d) exceeds remaining input length (%d)", l, il) + return n, fmt.Errorf("decoding ProofLevel: length (%d) exceeds remaining input length (%d)", l, il) } - s.ExtraSigners = make([]SignerKey, l) + s.ProofLevels = make([]ProofLevel, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.ExtraSigners[i].DecodeFrom(d, maxDepth) + nTmp, err = s.ProofLevels[i].DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding SignerKey: %w", err) + return n, fmt.Errorf("decoding ProofLevel: %w", err) } } } @@ -32366,7 +34603,7 @@ func (s *PreconditionsV2) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PreconditionsV2) MarshalBinary() ([]byte, error) { +func (s NonexistenceProofBody) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -32374,7 +34611,7 @@ func (s PreconditionsV2) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PreconditionsV2) UnmarshalBinary(inp []byte) error { +func (s *NonexistenceProofBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -32384,80 +34621,167 @@ func (s *PreconditionsV2) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PreconditionsV2)(nil) - _ encoding.BinaryUnmarshaler = (*PreconditionsV2)(nil) + _ encoding.BinaryMarshaler = (*NonexistenceProofBody)(nil) + _ encoding.BinaryUnmarshaler = (*NonexistenceProofBody)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PreconditionsV2) xdrType() {} +func (s NonexistenceProofBody) xdrType() {} -var _ xdrType = (*PreconditionsV2)(nil) +var _ xdrType = (*NonexistenceProofBody)(nil) -// PreconditionType is an XDR Enum defines as: +// ExistenceProofBody is an XDR Struct defines as: // -// enum PreconditionType +// struct ExistenceProofBody // { -// PRECOND_NONE = 0, -// PRECOND_TIME = 1, -// PRECOND_V2 = 2 +// LedgerKey keysToProve<>; +// +// // Bounds for each key being proved, where bound[n] +// // corresponds to keysToProve[n] +// ColdArchiveBucketEntry lowBoundEntries<>; +// ColdArchiveBucketEntry highBoundEntries<>; +// +// // Vector of vectors, where proofLevels[level] +// // contains all HashNodes that correspond with that level +// ProofLevel proofLevels<>; // }; -type PreconditionType int32 - -const ( - PreconditionTypePrecondNone PreconditionType = 0 - PreconditionTypePrecondTime PreconditionType = 1 - PreconditionTypePrecondV2 PreconditionType = 2 -) - -var preconditionTypeMap = map[int32]string{ - 0: "PreconditionTypePrecondNone", - 1: "PreconditionTypePrecondTime", - 2: "PreconditionTypePrecondV2", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for PreconditionType -func (e PreconditionType) ValidEnum(v int32) bool { - _, ok := preconditionTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e PreconditionType) String() string { - name, _ := preconditionTypeMap[int32(e)] - return name +type ExistenceProofBody struct { + KeysToProve []LedgerKey + LowBoundEntries []ColdArchiveBucketEntry + HighBoundEntries []ColdArchiveBucketEntry + ProofLevels []ProofLevel } // EncodeTo encodes this value using the Encoder. -func (e PreconditionType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := preconditionTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid PreconditionType enum value", e) +func (s *ExistenceProofBody) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeUint(uint32(len(s.KeysToProve))); err != nil { + return err } - _, err := enc.EncodeInt(int32(e)) - return err + for i := 0; i < len(s.KeysToProve); i++ { + if err = s.KeysToProve[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.LowBoundEntries))); err != nil { + return err + } + for i := 0; i < len(s.LowBoundEntries); i++ { + if err = s.LowBoundEntries[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.HighBoundEntries))); err != nil { + return err + } + for i := 0; i < len(s.HighBoundEntries); i++ { + if err = s.HighBoundEntries[i].EncodeTo(e); err != nil { + return err + } + } + if _, err = e.EncodeUint(uint32(len(s.ProofLevels))); err != nil { + return err + } + for i := 0; i < len(s.ProofLevels); i++ { + if err = s.ProofLevels[i].EncodeTo(e); err != nil { + return err + } + } + return nil } -var _ decoderFrom = (*PreconditionType)(nil) +var _ decoderFrom = (*ExistenceProofBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *PreconditionType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ExistenceProofBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding PreconditionType: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ExistenceProofBody: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 - v, n, err := d.DecodeInt() + var err error + var n, nTmp int + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp if err != nil { - return n, fmt.Errorf("decoding PreconditionType: %w", err) + return n, fmt.Errorf("decoding LedgerKey: %w", err) } - if _, ok := preconditionTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid PreconditionType enum value", v) + s.KeysToProve = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) + } + s.KeysToProve = make([]LedgerKey, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.KeysToProve[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding LedgerKey: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: %w", err) + } + s.LowBoundEntries = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: length (%d) exceeds remaining input length (%d)", l, il) + } + s.LowBoundEntries = make([]ColdArchiveBucketEntry, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.LowBoundEntries[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: %w", err) + } + s.HighBoundEntries = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: length (%d) exceeds remaining input length (%d)", l, il) + } + s.HighBoundEntries = make([]ColdArchiveBucketEntry, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.HighBoundEntries[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ColdArchiveBucketEntry: %w", err) + } + } + } + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ProofLevel: %w", err) + } + s.ProofLevels = nil + if l > 0 { + if il, ok := d.InputLen(); ok && uint(il) < uint(l) { + return n, fmt.Errorf("decoding ProofLevel: length (%d) exceeds remaining input length (%d)", l, il) + } + s.ProofLevels = make([]ProofLevel, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.ProofLevels[i].DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ProofLevel: %w", err) + } + } } - *e = PreconditionType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s PreconditionType) MarshalBinary() ([]byte, error) { +func (s ExistenceProofBody) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -32465,7 +34789,7 @@ func (s PreconditionType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *PreconditionType) UnmarshalBinary(inp []byte) error { +func (s *ExistenceProofBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -32475,120 +34799,114 @@ func (s *PreconditionType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*PreconditionType)(nil) - _ encoding.BinaryUnmarshaler = (*PreconditionType)(nil) + _ encoding.BinaryMarshaler = (*ExistenceProofBody)(nil) + _ encoding.BinaryUnmarshaler = (*ExistenceProofBody)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s PreconditionType) xdrType() {} +func (s ExistenceProofBody) xdrType() {} -var _ xdrType = (*PreconditionType)(nil) +var _ xdrType = (*ExistenceProofBody)(nil) -// Preconditions is an XDR Union defines as: +// ArchivalProofBody is an XDR NestedUnion defines as: // -// union Preconditions switch (PreconditionType type) -// { -// case PRECOND_NONE: -// void; -// case PRECOND_TIME: -// TimeBounds timeBounds; -// case PRECOND_V2: -// PreconditionsV2 v2; -// }; -type Preconditions struct { - Type PreconditionType - TimeBounds *TimeBounds - V2 *PreconditionsV2 +// union switch (ArchivalProofType t) +// { +// case EXISTENCE: +// NonexistenceProofBody nonexistenceProof; +// case NONEXISTENCE: +// ExistenceProofBody existenceProof; +// } +type ArchivalProofBody struct { + T ArchivalProofType + NonexistenceProof *NonexistenceProofBody + ExistenceProof *ExistenceProofBody } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u Preconditions) SwitchFieldName() string { - return "Type" +func (u ArchivalProofBody) SwitchFieldName() string { + return "T" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of Preconditions -func (u Preconditions) ArmForSwitch(sw int32) (string, bool) { - switch PreconditionType(sw) { - case PreconditionTypePrecondNone: - return "", true - case PreconditionTypePrecondTime: - return "TimeBounds", true - case PreconditionTypePrecondV2: - return "V2", true +// the value for an instance of ArchivalProofBody +func (u ArchivalProofBody) ArmForSwitch(sw int32) (string, bool) { + switch ArchivalProofType(sw) { + case ArchivalProofTypeExistence: + return "NonexistenceProof", true + case ArchivalProofTypeNonexistence: + return "ExistenceProof", true } return "-", false } -// NewPreconditions creates a new Preconditions. -func NewPreconditions(aType PreconditionType, value interface{}) (result Preconditions, err error) { - result.Type = aType - switch PreconditionType(aType) { - case PreconditionTypePrecondNone: - // void - case PreconditionTypePrecondTime: - tv, ok := value.(TimeBounds) +// NewArchivalProofBody creates a new ArchivalProofBody. +func NewArchivalProofBody(t ArchivalProofType, value interface{}) (result ArchivalProofBody, err error) { + result.T = t + switch ArchivalProofType(t) { + case ArchivalProofTypeExistence: + tv, ok := value.(NonexistenceProofBody) if !ok { - err = errors.New("invalid value, must be TimeBounds") + err = errors.New("invalid value, must be NonexistenceProofBody") return } - result.TimeBounds = &tv - case PreconditionTypePrecondV2: - tv, ok := value.(PreconditionsV2) + result.NonexistenceProof = &tv + case ArchivalProofTypeNonexistence: + tv, ok := value.(ExistenceProofBody) if !ok { - err = errors.New("invalid value, must be PreconditionsV2") + err = errors.New("invalid value, must be ExistenceProofBody") return } - result.V2 = &tv + result.ExistenceProof = &tv } return } -// MustTimeBounds retrieves the TimeBounds value from the union, +// MustNonexistenceProof retrieves the NonexistenceProof value from the union, // panicing if the value is not set. -func (u Preconditions) MustTimeBounds() TimeBounds { - val, ok := u.GetTimeBounds() +func (u ArchivalProofBody) MustNonexistenceProof() NonexistenceProofBody { + val, ok := u.GetNonexistenceProof() if !ok { - panic("arm TimeBounds is not set") + panic("arm NonexistenceProof is not set") } return val } -// GetTimeBounds retrieves the TimeBounds value from the union, +// GetNonexistenceProof retrieves the NonexistenceProof value from the union, // returning ok if the union's switch indicated the value is valid. -func (u Preconditions) GetTimeBounds() (result TimeBounds, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +func (u ArchivalProofBody) GetNonexistenceProof() (result NonexistenceProofBody, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.T)) - if armName == "TimeBounds" { - result = *u.TimeBounds + if armName == "NonexistenceProof" { + result = *u.NonexistenceProof ok = true } return } -// MustV2 retrieves the V2 value from the union, +// MustExistenceProof retrieves the ExistenceProof value from the union, // panicing if the value is not set. -func (u Preconditions) MustV2() PreconditionsV2 { - val, ok := u.GetV2() +func (u ArchivalProofBody) MustExistenceProof() ExistenceProofBody { + val, ok := u.GetExistenceProof() if !ok { - panic("arm V2 is not set") + panic("arm ExistenceProof is not set") } return val } -// GetV2 retrieves the V2 value from the union, +// GetExistenceProof retrieves the ExistenceProof value from the union, // returning ok if the union's switch indicated the value is valid. -func (u Preconditions) GetV2() (result PreconditionsV2, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) +func (u ArchivalProofBody) GetExistenceProof() (result ExistenceProofBody, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.T)) - if armName == "V2" { - result = *u.V2 + if armName == "ExistenceProof" { + result = *u.ExistenceProof ok = true } @@ -32596,70 +34914,64 @@ func (u Preconditions) GetV2() (result PreconditionsV2, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u Preconditions) EncodeTo(e *xdr.Encoder) error { +func (u ArchivalProofBody) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if err = u.T.EncodeTo(e); err != nil { return err } - switch PreconditionType(u.Type) { - case PreconditionTypePrecondNone: - // Void - return nil - case PreconditionTypePrecondTime: - if err = (*u.TimeBounds).EncodeTo(e); err != nil { + switch ArchivalProofType(u.T) { + case ArchivalProofTypeExistence: + if err = (*u.NonexistenceProof).EncodeTo(e); err != nil { return err } return nil - case PreconditionTypePrecondV2: - if err = (*u.V2).EncodeTo(e); err != nil { + case ArchivalProofTypeNonexistence: + if err = (*u.ExistenceProof).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (PreconditionType) switch value '%d' is not valid for union Preconditions", u.Type) + return fmt.Errorf("T (ArchivalProofType) switch value '%d' is not valid for union ArchivalProofBody", u.T) } -var _ decoderFrom = (*Preconditions)(nil) +var _ decoderFrom = (*ArchivalProofBody)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *Preconditions) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (u *ArchivalProofBody) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding Preconditions: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ArchivalProofBody: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d, maxDepth) + nTmp, err = u.T.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PreconditionType: %w", err) + return n, fmt.Errorf("decoding ArchivalProofType: %w", err) } - switch PreconditionType(u.Type) { - case PreconditionTypePrecondNone: - // Void - return n, nil - case PreconditionTypePrecondTime: - u.TimeBounds = new(TimeBounds) - nTmp, err = (*u.TimeBounds).DecodeFrom(d, maxDepth) + switch ArchivalProofType(u.T) { + case ArchivalProofTypeExistence: + u.NonexistenceProof = new(NonexistenceProofBody) + nTmp, err = (*u.NonexistenceProof).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TimeBounds: %w", err) + return n, fmt.Errorf("decoding NonexistenceProofBody: %w", err) } return n, nil - case PreconditionTypePrecondV2: - u.V2 = new(PreconditionsV2) - nTmp, err = (*u.V2).DecodeFrom(d, maxDepth) + case ArchivalProofTypeNonexistence: + u.ExistenceProof = new(ExistenceProofBody) + nTmp, err = (*u.ExistenceProof).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding PreconditionsV2: %w", err) + return n, fmt.Errorf("decoding ExistenceProofBody: %w", err) } return n, nil } - return n, fmt.Errorf("union Preconditions has invalid Type (PreconditionType) switch value '%d'", u.Type) + return n, fmt.Errorf("union ArchivalProofBody has invalid T (ArchivalProofType) switch value '%d'", u.T) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s Preconditions) MarshalBinary() ([]byte, error) { +func (s ArchivalProofBody) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -32667,7 +34979,7 @@ func (s Preconditions) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *Preconditions) UnmarshalBinary(inp []byte) error { +func (s *ArchivalProofBody) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -32677,103 +34989,71 @@ func (s *Preconditions) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*Preconditions)(nil) - _ encoding.BinaryUnmarshaler = (*Preconditions)(nil) + _ encoding.BinaryMarshaler = (*ArchivalProofBody)(nil) + _ encoding.BinaryUnmarshaler = (*ArchivalProofBody)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s Preconditions) xdrType() {} +func (s ArchivalProofBody) xdrType() {} -var _ xdrType = (*Preconditions)(nil) +var _ xdrType = (*ArchivalProofBody)(nil) -// LedgerFootprint is an XDR Struct defines as: +// ArchivalProof is an XDR Struct defines as: // -// struct LedgerFootprint +// struct ArchivalProof // { -// LedgerKey readOnly<>; -// LedgerKey readWrite<>; +// uint32 epoch; // AST Subtree for this proof +// +// union switch (ArchivalProofType t) +// { +// case EXISTENCE: +// NonexistenceProofBody nonexistenceProof; +// case NONEXISTENCE: +// ExistenceProofBody existenceProof; +// } body; // }; -type LedgerFootprint struct { - ReadOnly []LedgerKey - ReadWrite []LedgerKey +type ArchivalProof struct { + Epoch Uint32 + Body ArchivalProofBody } // EncodeTo encodes this value using the Encoder. -func (s *LedgerFootprint) EncodeTo(e *xdr.Encoder) error { +func (s *ArchivalProof) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s.ReadOnly))); err != nil { + if err = s.Epoch.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.ReadOnly); i++ { - if err = s.ReadOnly[i].EncodeTo(e); err != nil { - return err - } - } - if _, err = e.EncodeUint(uint32(len(s.ReadWrite))); err != nil { + if err = s.Body.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.ReadWrite); i++ { - if err = s.ReadWrite[i].EncodeTo(e); err != nil { - return err - } - } return nil } -var _ decoderFrom = (*LedgerFootprint)(nil) +var _ decoderFrom = (*ArchivalProof)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *LedgerFootprint) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { +func (s *ArchivalProof) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { if maxDepth == 0 { - return 0, fmt.Errorf("decoding LedgerFootprint: %w", ErrMaxDecodingDepthReached) + return 0, fmt.Errorf("decoding ArchivalProof: %w", ErrMaxDecodingDepthReached) } maxDepth -= 1 var err error var n, nTmp int - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.Epoch.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) - } - s.ReadOnly = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) - } - s.ReadOnly = make([]LedgerKey, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.ReadOnly[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) - } - } + return n, fmt.Errorf("decoding Uint32: %w", err) } - l, nTmp, err = d.DecodeUint() + nTmp, err = s.Body.DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) - } - s.ReadWrite = nil - if l > 0 { - if il, ok := d.InputLen(); ok && uint(il) < uint(l) { - return n, fmt.Errorf("decoding LedgerKey: length (%d) exceeds remaining input length (%d)", l, il) - } - s.ReadWrite = make([]LedgerKey, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.ReadWrite[i].DecodeFrom(d, maxDepth) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerKey: %w", err) - } - } + return n, fmt.Errorf("decoding ArchivalProofBody: %w", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerFootprint) MarshalBinary() ([]byte, error) { +func (s ArchivalProof) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -32781,7 +35061,7 @@ func (s LedgerFootprint) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerFootprint) UnmarshalBinary(inp []byte) error { +func (s *ArchivalProof) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) o := xdr.DefaultDecodeOptions o.MaxInputLen = len(inp) @@ -32791,14 +35071,14 @@ func (s *LedgerFootprint) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*LedgerFootprint)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerFootprint)(nil) + _ encoding.BinaryMarshaler = (*ArchivalProof)(nil) + _ encoding.BinaryUnmarshaler = (*ArchivalProof)(nil) ) // xdrType signals that this type represents XDR values defined by this package. -func (s LedgerFootprint) xdrType() {} +func (s ArchivalProof) xdrType() {} -var _ xdrType = (*LedgerFootprint)(nil) +var _ xdrType = (*ArchivalProof)(nil) // SorobanResources is an XDR Struct defines as: // @@ -48935,6 +51215,313 @@ func (s HmacSha256Mac) xdrType() {} var _ xdrType = (*HmacSha256Mac)(nil) +// ShortHashSeed is an XDR Struct defines as: +// +// struct ShortHashSeed +// { +// opaque seed[16]; +// }; +type ShortHashSeed struct { + Seed [16]byte `xdrmaxsize:"16"` +} + +// EncodeTo encodes this value using the Encoder. +func (s *ShortHashSeed) EncodeTo(e *xdr.Encoder) error { + var err error + if _, err = e.EncodeFixedOpaque(s.Seed[:]); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*ShortHashSeed)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *ShortHashSeed) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ShortHashSeed: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = d.DecodeFixedOpaqueInplace(s.Seed[:]) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Seed: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s ShortHashSeed) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *ShortHashSeed) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*ShortHashSeed)(nil) + _ encoding.BinaryUnmarshaler = (*ShortHashSeed)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s ShortHashSeed) xdrType() {} + +var _ xdrType = (*ShortHashSeed)(nil) + +// BinaryFuseFilterType is an XDR Enum defines as: +// +// enum BinaryFuseFilterType +// { +// BINARY_FUSE_FILTER_8_BIT = 0, +// BINARY_FUSE_FILTER_16_BIT = 1, +// BINARY_FUSE_FILTER_32_BIT = 2 +// }; +type BinaryFuseFilterType int32 + +const ( + BinaryFuseFilterTypeBinaryFuseFilter8Bit BinaryFuseFilterType = 0 + BinaryFuseFilterTypeBinaryFuseFilter16Bit BinaryFuseFilterType = 1 + BinaryFuseFilterTypeBinaryFuseFilter32Bit BinaryFuseFilterType = 2 +) + +var binaryFuseFilterTypeMap = map[int32]string{ + 0: "BinaryFuseFilterTypeBinaryFuseFilter8Bit", + 1: "BinaryFuseFilterTypeBinaryFuseFilter16Bit", + 2: "BinaryFuseFilterTypeBinaryFuseFilter32Bit", +} + +// ValidEnum validates a proposed value for this enum. Implements +// the Enum interface for BinaryFuseFilterType +func (e BinaryFuseFilterType) ValidEnum(v int32) bool { + _, ok := binaryFuseFilterTypeMap[v] + return ok +} + +// String returns the name of `e` +func (e BinaryFuseFilterType) String() string { + name, _ := binaryFuseFilterTypeMap[int32(e)] + return name +} + +// EncodeTo encodes this value using the Encoder. +func (e BinaryFuseFilterType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := binaryFuseFilterTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid BinaryFuseFilterType enum value", e) + } + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*BinaryFuseFilterType)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (e *BinaryFuseFilterType) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding BinaryFuseFilterType: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + v, n, err := d.DecodeInt() + if err != nil { + return n, fmt.Errorf("decoding BinaryFuseFilterType: %w", err) + } + if _, ok := binaryFuseFilterTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid BinaryFuseFilterType enum value", v) + } + *e = BinaryFuseFilterType(v) + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s BinaryFuseFilterType) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *BinaryFuseFilterType) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*BinaryFuseFilterType)(nil) + _ encoding.BinaryUnmarshaler = (*BinaryFuseFilterType)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s BinaryFuseFilterType) xdrType() {} + +var _ xdrType = (*BinaryFuseFilterType)(nil) + +// SerializedBinaryFuseFilter is an XDR Struct defines as: +// +// struct SerializedBinaryFuseFilter +// { +// BinaryFuseFilterType type; +// +// // Seed used to hash input to filter +// ShortHashSeed inputHashSeed; +// +// // Seed used for internal filter hash operations +// ShortHashSeed filterSeed; +// uint32 segmentLength; +// uint32 segementLengthMask; +// uint32 segmentCount; +// uint32 segmentCountLength; +// uint32 fingerprintLength; // Length in terms of element count, not bytes +// +// // Array of uint8_t, uint16_t, or uint32_t depending on filter type +// opaque fingerprints<>; +// }; +type SerializedBinaryFuseFilter struct { + Type BinaryFuseFilterType + InputHashSeed ShortHashSeed + FilterSeed ShortHashSeed + SegmentLength Uint32 + SegementLengthMask Uint32 + SegmentCount Uint32 + SegmentCountLength Uint32 + FingerprintLength Uint32 + Fingerprints []byte +} + +// EncodeTo encodes this value using the Encoder. +func (s *SerializedBinaryFuseFilter) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Type.EncodeTo(e); err != nil { + return err + } + if err = s.InputHashSeed.EncodeTo(e); err != nil { + return err + } + if err = s.FilterSeed.EncodeTo(e); err != nil { + return err + } + if err = s.SegmentLength.EncodeTo(e); err != nil { + return err + } + if err = s.SegementLengthMask.EncodeTo(e); err != nil { + return err + } + if err = s.SegmentCount.EncodeTo(e); err != nil { + return err + } + if err = s.SegmentCountLength.EncodeTo(e); err != nil { + return err + } + if err = s.FingerprintLength.EncodeTo(e); err != nil { + return err + } + if _, err = e.EncodeOpaque(s.Fingerprints[:]); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*SerializedBinaryFuseFilter)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *SerializedBinaryFuseFilter) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding SerializedBinaryFuseFilter: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Type.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding BinaryFuseFilterType: %w", err) + } + nTmp, err = s.InputHashSeed.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ShortHashSeed: %w", err) + } + nTmp, err = s.FilterSeed.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ShortHashSeed: %w", err) + } + nTmp, err = s.SegmentLength.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.SegementLengthMask.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.SegmentCount.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.SegmentCountLength.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.FingerprintLength.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + s.Fingerprints, nTmp, err = d.DecodeOpaque(0) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Fingerprints: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s SerializedBinaryFuseFilter) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SerializedBinaryFuseFilter) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SerializedBinaryFuseFilter)(nil) + _ encoding.BinaryUnmarshaler = (*SerializedBinaryFuseFilter)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s SerializedBinaryFuseFilter) xdrType() {} + +var _ xdrType = (*SerializedBinaryFuseFilter)(nil) + // ScEnvMetaKind is an XDR Enum defines as: // // enum SCEnvMetaKind @@ -49020,16 +51607,93 @@ func (s ScEnvMetaKind) xdrType() {} var _ xdrType = (*ScEnvMetaKind)(nil) +// ScEnvMetaEntryInterfaceVersion is an XDR NestedStruct defines as: +// +// struct { +// uint32 protocol; +// uint32 preRelease; +// } +type ScEnvMetaEntryInterfaceVersion struct { + Protocol Uint32 + PreRelease Uint32 +} + +// EncodeTo encodes this value using the Encoder. +func (s *ScEnvMetaEntryInterfaceVersion) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.Protocol.EncodeTo(e); err != nil { + return err + } + if err = s.PreRelease.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*ScEnvMetaEntryInterfaceVersion)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *ScEnvMetaEntryInterfaceVersion) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScEnvMetaEntryInterfaceVersion: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.Protocol.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + nTmp, err = s.PreRelease.DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %w", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s ScEnvMetaEntryInterfaceVersion) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *ScEnvMetaEntryInterfaceVersion) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + o := xdr.DefaultDecodeOptions + o.MaxInputLen = len(inp) + d := xdr.NewDecoderWithOptions(r, o) + _, err := s.DecodeFrom(d, o.MaxDepth) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*ScEnvMetaEntryInterfaceVersion)(nil) + _ encoding.BinaryUnmarshaler = (*ScEnvMetaEntryInterfaceVersion)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s ScEnvMetaEntryInterfaceVersion) xdrType() {} + +var _ xdrType = (*ScEnvMetaEntryInterfaceVersion)(nil) + // ScEnvMetaEntry is an XDR Union defines as: // // union SCEnvMetaEntry switch (SCEnvMetaKind kind) // { // case SC_ENV_META_KIND_INTERFACE_VERSION: -// uint64 interfaceVersion; +// struct { +// uint32 protocol; +// uint32 preRelease; +// } interfaceVersion; // }; type ScEnvMetaEntry struct { Kind ScEnvMetaKind - InterfaceVersion *Uint64 + InterfaceVersion *ScEnvMetaEntryInterfaceVersion } // SwitchFieldName returns the field name in which this union's @@ -49053,9 +51717,9 @@ func NewScEnvMetaEntry(kind ScEnvMetaKind, value interface{}) (result ScEnvMetaE result.Kind = kind switch ScEnvMetaKind(kind) { case ScEnvMetaKindScEnvMetaKindInterfaceVersion: - tv, ok := value.(Uint64) + tv, ok := value.(ScEnvMetaEntryInterfaceVersion) if !ok { - err = errors.New("invalid value, must be Uint64") + err = errors.New("invalid value, must be ScEnvMetaEntryInterfaceVersion") return } result.InterfaceVersion = &tv @@ -49065,7 +51729,7 @@ func NewScEnvMetaEntry(kind ScEnvMetaKind, value interface{}) (result ScEnvMetaE // MustInterfaceVersion retrieves the InterfaceVersion value from the union, // panicing if the value is not set. -func (u ScEnvMetaEntry) MustInterfaceVersion() Uint64 { +func (u ScEnvMetaEntry) MustInterfaceVersion() ScEnvMetaEntryInterfaceVersion { val, ok := u.GetInterfaceVersion() if !ok { @@ -49077,7 +51741,7 @@ func (u ScEnvMetaEntry) MustInterfaceVersion() Uint64 { // GetInterfaceVersion retrieves the InterfaceVersion value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ScEnvMetaEntry) GetInterfaceVersion() (result Uint64, ok bool) { +func (u ScEnvMetaEntry) GetInterfaceVersion() (result ScEnvMetaEntryInterfaceVersion, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Kind)) if armName == "InterfaceVersion" { @@ -49121,11 +51785,11 @@ func (u *ScEnvMetaEntry) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) } switch ScEnvMetaKind(u.Kind) { case ScEnvMetaKindScEnvMetaKindInterfaceVersion: - u.InterfaceVersion = new(Uint64) + u.InterfaceVersion = new(ScEnvMetaEntryInterfaceVersion) nTmp, err = (*u.InterfaceVersion).DecodeFrom(d, maxDepth) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %w", err) + return n, fmt.Errorf("decoding ScEnvMetaEntryInterfaceVersion: %w", err) } return n, nil } @@ -57428,7 +60092,58 @@ var _ xdrType = (*ConfigSettingContractBandwidthV0)(nil) // // point on a 256-bit elliptic curve // Sec1DecodePointUncompressed = 43, // // Cost of verifying an ECDSA Secp256r1 signature -// VerifyEcdsaSecp256r1Sig = 44 +// VerifyEcdsaSecp256r1Sig = 44, +// +// // Cost of encoding a BLS12-381 Fp (base field element) +// Bls12381EncodeFp = 45, +// // Cost of decoding a BLS12-381 Fp (base field element) +// Bls12381DecodeFp = 46, +// // Cost of checking a G1 point lies on the curve +// Bls12381G1CheckPointOnCurve = 47, +// // Cost of checking a G1 point belongs to the correct subgroup +// Bls12381G1CheckPointInSubgroup = 48, +// // Cost of checking a G2 point lies on the curve +// Bls12381G2CheckPointOnCurve = 49, +// // Cost of checking a G2 point belongs to the correct subgroup +// Bls12381G2CheckPointInSubgroup = 50, +// // Cost of converting a BLS12-381 G1 point from projective to affine coordinates +// Bls12381G1ProjectiveToAffine = 51, +// // Cost of converting a BLS12-381 G2 point from projective to affine coordinates +// Bls12381G2ProjectiveToAffine = 52, +// // Cost of performing BLS12-381 G1 point addition +// Bls12381G1Add = 53, +// // Cost of performing BLS12-381 G1 scalar multiplication +// Bls12381G1Mul = 54, +// // Cost of performing BLS12-381 G1 multi-scalar multiplication (MSM) +// Bls12381G1Msm = 55, +// // Cost of mapping a BLS12-381 Fp field element to a G1 point +// Bls12381MapFpToG1 = 56, +// // Cost of hashing to a BLS12-381 G1 point +// Bls12381HashToG1 = 57, +// // Cost of performing BLS12-381 G2 point addition +// Bls12381G2Add = 58, +// // Cost of performing BLS12-381 G2 scalar multiplication +// Bls12381G2Mul = 59, +// // Cost of performing BLS12-381 G2 multi-scalar multiplication (MSM) +// Bls12381G2Msm = 60, +// // Cost of mapping a BLS12-381 Fp2 field element to a G2 point +// Bls12381MapFp2ToG2 = 61, +// // Cost of hashing to a BLS12-381 G2 point +// Bls12381HashToG2 = 62, +// // Cost of performing BLS12-381 pairing operation +// Bls12381Pairing = 63, +// // Cost of converting a BLS12-381 scalar element from U256 +// Bls12381FrFromU256 = 64, +// // Cost of converting a BLS12-381 scalar element to U256 +// Bls12381FrToU256 = 65, +// // Cost of performing BLS12-381 scalar element addition/subtraction +// Bls12381FrAddSub = 66, +// // Cost of performing BLS12-381 scalar element multiplication +// Bls12381FrMul = 67, +// // Cost of performing BLS12-381 scalar element exponentiation +// Bls12381FrPow = 68, +// // Cost of performing BLS12-381 scalar element inversion +// Bls12381FrInv = 69 // }; type ContractCostType int32 @@ -57478,6 +60193,31 @@ const ( ContractCostTypeInstantiateWasmDataSegmentBytes ContractCostType = 42 ContractCostTypeSec1DecodePointUncompressed ContractCostType = 43 ContractCostTypeVerifyEcdsaSecp256r1Sig ContractCostType = 44 + ContractCostTypeBls12381EncodeFp ContractCostType = 45 + ContractCostTypeBls12381DecodeFp ContractCostType = 46 + ContractCostTypeBls12381G1CheckPointOnCurve ContractCostType = 47 + ContractCostTypeBls12381G1CheckPointInSubgroup ContractCostType = 48 + ContractCostTypeBls12381G2CheckPointOnCurve ContractCostType = 49 + ContractCostTypeBls12381G2CheckPointInSubgroup ContractCostType = 50 + ContractCostTypeBls12381G1ProjectiveToAffine ContractCostType = 51 + ContractCostTypeBls12381G2ProjectiveToAffine ContractCostType = 52 + ContractCostTypeBls12381G1Add ContractCostType = 53 + ContractCostTypeBls12381G1Mul ContractCostType = 54 + ContractCostTypeBls12381G1Msm ContractCostType = 55 + ContractCostTypeBls12381MapFpToG1 ContractCostType = 56 + ContractCostTypeBls12381HashToG1 ContractCostType = 57 + ContractCostTypeBls12381G2Add ContractCostType = 58 + ContractCostTypeBls12381G2Mul ContractCostType = 59 + ContractCostTypeBls12381G2Msm ContractCostType = 60 + ContractCostTypeBls12381MapFp2ToG2 ContractCostType = 61 + ContractCostTypeBls12381HashToG2 ContractCostType = 62 + ContractCostTypeBls12381Pairing ContractCostType = 63 + ContractCostTypeBls12381FrFromU256 ContractCostType = 64 + ContractCostTypeBls12381FrToU256 ContractCostType = 65 + ContractCostTypeBls12381FrAddSub ContractCostType = 66 + ContractCostTypeBls12381FrMul ContractCostType = 67 + ContractCostTypeBls12381FrPow ContractCostType = 68 + ContractCostTypeBls12381FrInv ContractCostType = 69 ) var contractCostTypeMap = map[int32]string{ @@ -57526,6 +60266,31 @@ var contractCostTypeMap = map[int32]string{ 42: "ContractCostTypeInstantiateWasmDataSegmentBytes", 43: "ContractCostTypeSec1DecodePointUncompressed", 44: "ContractCostTypeVerifyEcdsaSecp256r1Sig", + 45: "ContractCostTypeBls12381EncodeFp", + 46: "ContractCostTypeBls12381DecodeFp", + 47: "ContractCostTypeBls12381G1CheckPointOnCurve", + 48: "ContractCostTypeBls12381G1CheckPointInSubgroup", + 49: "ContractCostTypeBls12381G2CheckPointOnCurve", + 50: "ContractCostTypeBls12381G2CheckPointInSubgroup", + 51: "ContractCostTypeBls12381G1ProjectiveToAffine", + 52: "ContractCostTypeBls12381G2ProjectiveToAffine", + 53: "ContractCostTypeBls12381G1Add", + 54: "ContractCostTypeBls12381G1Mul", + 55: "ContractCostTypeBls12381G1Msm", + 56: "ContractCostTypeBls12381MapFpToG1", + 57: "ContractCostTypeBls12381HashToG1", + 58: "ContractCostTypeBls12381G2Add", + 59: "ContractCostTypeBls12381G2Mul", + 60: "ContractCostTypeBls12381G2Msm", + 61: "ContractCostTypeBls12381MapFp2ToG2", + 62: "ContractCostTypeBls12381HashToG2", + 63: "ContractCostTypeBls12381Pairing", + 64: "ContractCostTypeBls12381FrFromU256", + 65: "ContractCostTypeBls12381FrToU256", + 66: "ContractCostTypeBls12381FrAddSub", + 67: "ContractCostTypeBls12381FrMul", + 68: "ContractCostTypeBls12381FrPow", + 69: "ContractCostTypeBls12381FrInv", } // ValidEnum validates a proposed value for this enum. Implements