From c63ad05d3e3bc9f2dd5f5747bfa2542da714b04e Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 17 Apr 2024 21:24:51 +0200 Subject: [PATCH] Bump XDR definitions again (#5282) --- Makefile | 2 +- gxdr/xdr_generated.go | 48 +++++++++++++- xdr/Stellar-contract-spec.x | 8 +++ xdr/xdr_commit_generated.txt | 2 +- xdr/xdr_generated.go | 120 ++++++++++++++++++++++++++++++++++- 5 files changed, 176 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8ac1abb337..fe2021d39a 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ XDRS = $(DOWNLOADABLE_XDRS) xdr/Stellar-lighthorizon.x \ XDRGEN_COMMIT=e2cac557162d99b12ae73b846cf3d5bfe16636de -XDR_COMMIT=59062438237d5f77fd6feb060b76288e88b7e222 +XDR_COMMIT=2ba4049554bb0564950e6d9213e01a60fc190f54 .PHONY: xdr xdr-clean xdr-update diff --git a/gxdr/xdr_generated.go b/gxdr/xdr_generated.go index e7c8f3ed58..214d405e80 100644 --- a/gxdr/xdr_generated.go +++ b/gxdr/xdr_generated.go @@ -3804,6 +3804,7 @@ const ( SC_SPEC_TYPE_MAP SCSpecType = 1004 SC_SPEC_TYPE_TUPLE SCSpecType = 1005 SC_SPEC_TYPE_BYTES_N SCSpecType = 1006 + SC_SPEC_TYPE_HASH SCSpecType = 1007 // User defined types. SC_SPEC_TYPE_UDT SCSpecType = 2000 ) @@ -3834,6 +3835,10 @@ type SCSpecTypeBytesN struct { N Uint32 } +type SCSpectTypeHash struct { + N Uint32 +} + type SCSpecTypeUDT struct { Name string // bound 60 } @@ -3854,6 +3859,8 @@ type SCSpecTypeDef struct { // Tuple() *SCSpecTypeTuple // SC_SPEC_TYPE_BYTES_N: // BytesN() *SCSpecTypeBytesN + // SC_SPEC_TYPE_HASH: + // Hash() *SCSpectTypeHash // SC_SPEC_TYPE_UDT: // Udt() *SCSpecTypeUDT Type SCSpecType @@ -25624,6 +25631,7 @@ var _XdrNames_SCSpecType = map[int32]string{ int32(SC_SPEC_TYPE_MAP): "SC_SPEC_TYPE_MAP", int32(SC_SPEC_TYPE_TUPLE): "SC_SPEC_TYPE_TUPLE", int32(SC_SPEC_TYPE_BYTES_N): "SC_SPEC_TYPE_BYTES_N", + int32(SC_SPEC_TYPE_HASH): "SC_SPEC_TYPE_HASH", int32(SC_SPEC_TYPE_UDT): "SC_SPEC_TYPE_UDT", } var _XdrValues_SCSpecType = map[string]int32{ @@ -25651,6 +25659,7 @@ var _XdrValues_SCSpecType = map[string]int32{ "SC_SPEC_TYPE_MAP": int32(SC_SPEC_TYPE_MAP), "SC_SPEC_TYPE_TUPLE": int32(SC_SPEC_TYPE_TUPLE), "SC_SPEC_TYPE_BYTES_N": int32(SC_SPEC_TYPE_BYTES_N), + "SC_SPEC_TYPE_HASH": int32(SC_SPEC_TYPE_HASH), "SC_SPEC_TYPE_UDT": int32(SC_SPEC_TYPE_UDT), } @@ -25843,6 +25852,20 @@ func (v *SCSpecTypeBytesN) XdrRecurse(x XDR, name string) { } func XDR_SCSpecTypeBytesN(v *SCSpecTypeBytesN) *SCSpecTypeBytesN { return v } +type XdrType_SCSpectTypeHash = *SCSpectTypeHash + +func (v *SCSpectTypeHash) XdrPointer() interface{} { return v } +func (SCSpectTypeHash) XdrTypeName() string { return "SCSpectTypeHash" } +func (v SCSpectTypeHash) XdrValue() interface{} { return v } +func (v *SCSpectTypeHash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SCSpectTypeHash) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%sn", name), XDR_Uint32(&v.N)) +} +func XDR_SCSpectTypeHash(v *SCSpectTypeHash) *SCSpectTypeHash { return v } + type XdrType_SCSpecTypeUDT = *SCSpecTypeUDT func (v *SCSpecTypeUDT) XdrPointer() interface{} { return v } @@ -25882,6 +25905,7 @@ var _XdrTags_SCSpecTypeDef = map[int32]bool{ XdrToI32(SC_SPEC_TYPE_MAP): true, XdrToI32(SC_SPEC_TYPE_TUPLE): true, XdrToI32(SC_SPEC_TYPE_BYTES_N): true, + XdrToI32(SC_SPEC_TYPE_HASH): true, XdrToI32(SC_SPEC_TYPE_UDT): true, } @@ -25978,6 +26002,21 @@ func (u *SCSpecTypeDef) BytesN() *SCSpecTypeBytesN { return nil } } +func (u *SCSpecTypeDef) Hash() *SCSpectTypeHash { + switch u.Type { + case SC_SPEC_TYPE_HASH: + if v, ok := u._u.(*SCSpectTypeHash); ok { + return v + } else { + var zero SCSpectTypeHash + u._u = &zero + return &zero + } + default: + XdrPanic("SCSpecTypeDef.Hash accessed when Type == %v", u.Type) + return nil + } +} func (u *SCSpecTypeDef) Udt() *SCSpecTypeUDT { switch u.Type { case SC_SPEC_TYPE_UDT: @@ -25995,7 +26034,7 @@ func (u *SCSpecTypeDef) Udt() *SCSpecTypeUDT { } func (u SCSpecTypeDef) XdrValid() bool { switch u.Type { - case SC_SPEC_TYPE_VAL, SC_SPEC_TYPE_BOOL, SC_SPEC_TYPE_VOID, SC_SPEC_TYPE_ERROR, SC_SPEC_TYPE_U32, SC_SPEC_TYPE_I32, SC_SPEC_TYPE_U64, SC_SPEC_TYPE_I64, SC_SPEC_TYPE_TIMEPOINT, SC_SPEC_TYPE_DURATION, SC_SPEC_TYPE_U128, SC_SPEC_TYPE_I128, SC_SPEC_TYPE_U256, SC_SPEC_TYPE_I256, SC_SPEC_TYPE_BYTES, SC_SPEC_TYPE_STRING, SC_SPEC_TYPE_SYMBOL, SC_SPEC_TYPE_ADDRESS, SC_SPEC_TYPE_OPTION, SC_SPEC_TYPE_RESULT, SC_SPEC_TYPE_VEC, SC_SPEC_TYPE_MAP, SC_SPEC_TYPE_TUPLE, SC_SPEC_TYPE_BYTES_N, SC_SPEC_TYPE_UDT: + case SC_SPEC_TYPE_VAL, SC_SPEC_TYPE_BOOL, SC_SPEC_TYPE_VOID, SC_SPEC_TYPE_ERROR, SC_SPEC_TYPE_U32, SC_SPEC_TYPE_I32, SC_SPEC_TYPE_U64, SC_SPEC_TYPE_I64, SC_SPEC_TYPE_TIMEPOINT, SC_SPEC_TYPE_DURATION, SC_SPEC_TYPE_U128, SC_SPEC_TYPE_I128, SC_SPEC_TYPE_U256, SC_SPEC_TYPE_I256, SC_SPEC_TYPE_BYTES, SC_SPEC_TYPE_STRING, SC_SPEC_TYPE_SYMBOL, SC_SPEC_TYPE_ADDRESS, SC_SPEC_TYPE_OPTION, SC_SPEC_TYPE_RESULT, SC_SPEC_TYPE_VEC, SC_SPEC_TYPE_MAP, SC_SPEC_TYPE_TUPLE, SC_SPEC_TYPE_BYTES_N, SC_SPEC_TYPE_HASH, SC_SPEC_TYPE_UDT: return true } return false @@ -26022,6 +26061,8 @@ func (u *SCSpecTypeDef) XdrUnionBody() XdrType { return XDR_SCSpecTypeTuple(u.Tuple()) case SC_SPEC_TYPE_BYTES_N: return XDR_SCSpecTypeBytesN(u.BytesN()) + case SC_SPEC_TYPE_HASH: + return XDR_SCSpectTypeHash(u.Hash()) case SC_SPEC_TYPE_UDT: return XDR_SCSpecTypeUDT(u.Udt()) } @@ -26043,6 +26084,8 @@ func (u *SCSpecTypeDef) XdrUnionBodyName() string { return "Tuple" case SC_SPEC_TYPE_BYTES_N: return "BytesN" + case SC_SPEC_TYPE_HASH: + return "Hash" case SC_SPEC_TYPE_UDT: return "Udt" } @@ -26081,6 +26124,9 @@ func (u *SCSpecTypeDef) XdrRecurse(x XDR, name string) { case SC_SPEC_TYPE_BYTES_N: x.Marshal(x.Sprintf("%sbytesN", name), XDR_SCSpecTypeBytesN(u.BytesN())) return + case SC_SPEC_TYPE_HASH: + x.Marshal(x.Sprintf("%shash", name), XDR_SCSpectTypeHash(u.Hash())) + return case SC_SPEC_TYPE_UDT: x.Marshal(x.Sprintf("%sudt", name), XDR_SCSpecTypeUDT(u.Udt())) return diff --git a/xdr/Stellar-contract-spec.x b/xdr/Stellar-contract-spec.x index 6988a63385..5d3e029951 100644 --- a/xdr/Stellar-contract-spec.x +++ b/xdr/Stellar-contract-spec.x @@ -42,6 +42,7 @@ enum SCSpecType SC_SPEC_TYPE_MAP = 1004, SC_SPEC_TYPE_TUPLE = 1005, SC_SPEC_TYPE_BYTES_N = 1006, + SC_SPEC_TYPE_HASH = 1007, // User defined types. SC_SPEC_TYPE_UDT = 2000 @@ -79,6 +80,11 @@ struct SCSpecTypeBytesN uint32 n; }; +struct SCSpectTypeHash +{ + uint32 n; +}; + struct SCSpecTypeUDT { string name<60>; @@ -117,6 +123,8 @@ case SC_SPEC_TYPE_TUPLE: SCSpecTypeTuple tuple; case SC_SPEC_TYPE_BYTES_N: SCSpecTypeBytesN bytesN; +case SC_SPEC_TYPE_HASH: + SCSpectTypeHash hash; case SC_SPEC_TYPE_UDT: SCSpecTypeUDT udt; }; diff --git a/xdr/xdr_commit_generated.txt b/xdr/xdr_commit_generated.txt index 610c71d294..8c75a203d4 100644 --- a/xdr/xdr_commit_generated.txt +++ b/xdr/xdr_commit_generated.txt @@ -1 +1 @@ -59062438237d5f77fd6feb060b76288e88b7e222 \ No newline at end of file +2ba4049554bb0564950e6d9213e01a60fc190f54 \ No newline at end of file diff --git a/xdr/xdr_generated.go b/xdr/xdr_generated.go index b336714562..49f8c691a3 100644 --- a/xdr/xdr_generated.go +++ b/xdr/xdr_generated.go @@ -37,7 +37,7 @@ var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-contract-config-setting.x": "393369678663cb0f9471a0b69e2a9cfa3ac93c4415fa40cec166e9a231ecbe0d", "xdr/Stellar-contract-env-meta.x": "928a30de814ee589bc1d2aadd8dd81c39f71b7e6f430f56974505ccb1f49654b", "xdr/Stellar-contract-meta.x": "f01532c11ca044e19d9f9f16fe373e9af64835da473be556b9a807ee3319ae0d", - "xdr/Stellar-contract-spec.x": "c7ffa21d2e91afb8e666b33524d307955426ff553a486d670c29217ed9888d49", + "xdr/Stellar-contract-spec.x": "8d7f6bdd82c3e529cd8c6f035202ca0e7677cc05e4727492a165dfdc51a9cb3e", "xdr/Stellar-contract.x": "7f665e4103e146a88fcdabce879aaaacd3bf9283feb194cc47ff986264c1e315", "xdr/Stellar-exporter.x": "a00c83d02e8c8382e06f79a191f1fb5abd097a4bbcab8481c67467e3270e0529", "xdr/Stellar-internal.x": "227835866c1b2122d1eaf28839ba85ea7289d1cb681dda4ca619c2da3d71fe00", @@ -48095,6 +48095,7 @@ const ScSpecDocLimit = 1024 // SC_SPEC_TYPE_MAP = 1004, // SC_SPEC_TYPE_TUPLE = 1005, // SC_SPEC_TYPE_BYTES_N = 1006, +// SC_SPEC_TYPE_HASH = 1007, // // // User defined types. // SC_SPEC_TYPE_UDT = 2000 @@ -48126,6 +48127,7 @@ const ( ScSpecTypeScSpecTypeMap ScSpecType = 1004 ScSpecTypeScSpecTypeTuple ScSpecType = 1005 ScSpecTypeScSpecTypeBytesN ScSpecType = 1006 + ScSpecTypeScSpecTypeHash ScSpecType = 1007 ScSpecTypeScSpecTypeUdt ScSpecType = 2000 ) @@ -48154,6 +48156,7 @@ var scSpecTypeMap = map[int32]string{ 1004: "ScSpecTypeScSpecTypeMap", 1005: "ScSpecTypeScSpecTypeTuple", 1006: "ScSpecTypeScSpecTypeBytesN", + 1007: "ScSpecTypeScSpecTypeHash", 2000: "ScSpecTypeScSpecTypeUdt", } @@ -48659,6 +48662,71 @@ func (s ScSpecTypeBytesN) xdrType() {} var _ xdrType = (*ScSpecTypeBytesN)(nil) +// ScSpectTypeHash is an XDR Struct defines as: +// +// struct SCSpectTypeHash +// { +// uint32 n; +// }; +type ScSpectTypeHash struct { + N Uint32 +} + +// EncodeTo encodes this value using the Encoder. +func (s *ScSpectTypeHash) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.N.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*ScSpectTypeHash)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *ScSpectTypeHash) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { + if maxDepth == 0 { + return 0, fmt.Errorf("decoding ScSpectTypeHash: %w", ErrMaxDecodingDepthReached) + } + maxDepth -= 1 + var err error + var n, nTmp int + nTmp, err = s.N.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 ScSpectTypeHash) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *ScSpectTypeHash) 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 = (*ScSpectTypeHash)(nil) + _ encoding.BinaryUnmarshaler = (*ScSpectTypeHash)(nil) +) + +// xdrType signals that this type represents XDR values defined by this package. +func (s ScSpectTypeHash) xdrType() {} + +var _ xdrType = (*ScSpectTypeHash)(nil) + // ScSpecTypeUdt is an XDR Struct defines as: // // struct SCSpecTypeUDT @@ -48759,6 +48827,8 @@ var _ xdrType = (*ScSpecTypeUdt)(nil) // SCSpecTypeTuple tuple; // case SC_SPEC_TYPE_BYTES_N: // SCSpecTypeBytesN bytesN; +// case SC_SPEC_TYPE_HASH: +// SCSpectTypeHash hash; // case SC_SPEC_TYPE_UDT: // SCSpecTypeUDT udt; // }; @@ -48770,6 +48840,7 @@ type ScSpecTypeDef struct { Map *ScSpecTypeMap Tuple *ScSpecTypeTuple BytesN *ScSpecTypeBytesN + Hash *ScSpectTypeHash Udt *ScSpecTypeUdt } @@ -48831,6 +48902,8 @@ func (u ScSpecTypeDef) ArmForSwitch(sw int32) (string, bool) { return "Tuple", true case ScSpecTypeScSpecTypeBytesN: return "BytesN", true + case ScSpecTypeScSpecTypeHash: + return "Hash", true case ScSpecTypeScSpecTypeUdt: return "Udt", true } @@ -48919,6 +48992,13 @@ func NewScSpecTypeDef(aType ScSpecType, value interface{}) (result ScSpecTypeDef return } result.BytesN = &tv + case ScSpecTypeScSpecTypeHash: + tv, ok := value.(ScSpectTypeHash) + if !ok { + err = errors.New("invalid value, must be ScSpectTypeHash") + return + } + result.Hash = &tv case ScSpecTypeScSpecTypeUdt: tv, ok := value.(ScSpecTypeUdt) if !ok { @@ -49080,6 +49160,31 @@ func (u ScSpecTypeDef) GetBytesN() (result ScSpecTypeBytesN, ok bool) { return } +// MustHash retrieves the Hash value from the union, +// panicing if the value is not set. +func (u ScSpecTypeDef) MustHash() ScSpectTypeHash { + val, ok := u.GetHash() + + if !ok { + panic("arm Hash is not set") + } + + return val +} + +// GetHash retrieves the Hash value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u ScSpecTypeDef) GetHash() (result ScSpectTypeHash, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Hash" { + result = *u.Hash + ok = true + } + + return +} + // MustUdt retrieves the Udt value from the union, // panicing if the value is not set. func (u ScSpecTypeDef) MustUdt() ScSpecTypeUdt { @@ -49196,6 +49301,11 @@ func (u ScSpecTypeDef) EncodeTo(e *xdr.Encoder) error { return err } return nil + case ScSpecTypeScSpecTypeHash: + if err = (*u.Hash).EncodeTo(e); err != nil { + return err + } + return nil case ScSpecTypeScSpecTypeUdt: if err = (*u.Udt).EncodeTo(e); err != nil { return err @@ -49323,6 +49433,14 @@ func (u *ScSpecTypeDef) DecodeFrom(d *xdr.Decoder, maxDepth uint) (int, error) { return n, fmt.Errorf("decoding ScSpecTypeBytesN: %w", err) } return n, nil + case ScSpecTypeScSpecTypeHash: + u.Hash = new(ScSpectTypeHash) + nTmp, err = (*u.Hash).DecodeFrom(d, maxDepth) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScSpectTypeHash: %w", err) + } + return n, nil case ScSpecTypeScSpecTypeUdt: u.Udt = new(ScSpecTypeUdt) nTmp, err = (*u.Udt).DecodeFrom(d, maxDepth)