diff --git a/.github/workflows/horizon.yml b/.github/workflows/horizon.yml index 830e6839b0..49831316c0 100644 --- a/.github/workflows/horizon.yml +++ b/.github/workflows/horizon.yml @@ -34,8 +34,8 @@ jobs: env: HORIZON_INTEGRATION_TESTS_ENABLED: true HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} - PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.10.1-1282.57cc8198c.focal~soroban - PROTOCOL_20_CORE_DOCKER_IMG: 2opremio/stellar-core:19.10.1-1282.57cc8198c.focal-soroban + PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.11.1-1328.cfa6a8918.focal~authchanges + PROTOCOL_20_CORE_DOCKER_IMG: 2opremio/stellar-core:19.11.1-1328.cfa6a8918.focal-authchanges PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.5.0-1108.ca2fb0605.focal PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.5.0-1108.ca2fb0605.focal PGHOST: localhost diff --git a/Makefile b/Makefile index 41f5f5c526..3c01e78210 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ xdr/Stellar-internal.x \ xdr/Stellar-contract-config-setting.x XDRGEN_COMMIT=80e38ef2a96489f6b501d4db3a350406e5aa3bab -XDRNEXT_COMMIT=2f16687fdf6f4bcfb56805e2035f69997f4b34c4 +XDRNEXT_COMMIT=de264d81ea87dfaa19e089b60fed8eb0219b2ab4 .PHONY: xdr xdr-clean xdr-update diff --git a/go.mod b/go.mod index 4f729a0678..fc1da1a0dc 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,14 @@ go 1.19 require ( firebase.google.com/go v3.12.0+incompatible + github.com/2opremio/pretty v0.2.2-0.20230601220618-e1d5758b2a95 github.com/BurntSushi/toml v0.3.1 github.com/Masterminds/squirrel v1.5.0 github.com/Microsoft/go-winio v0.4.14 github.com/adjust/goautoneg v0.0.0-20150426214442-d788f35a0315 github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/aws/aws-sdk-go v1.39.5 + github.com/creachadair/jrpc2 v0.41.1 github.com/elazarl/go-bindata-assetfs v1.0.0 github.com/getsentry/raven-go v0.0.0-20160805001729-c9d3cc542ad1 github.com/go-chi/chi v4.0.3+incompatible @@ -51,7 +53,11 @@ require ( gopkg.in/tylerb/graceful.v1 v1.2.13 ) -require github.com/andybalholm/brotli v1.0.4 // indirect +require ( + github.com/andybalholm/brotli v1.0.4 // indirect + github.com/rogpeppe/go-internal v1.6.1 // indirect + golang.org/x/sync v0.2.0 // indirect +) require ( cloud.google.com/go v0.84.0 // indirect @@ -65,7 +71,7 @@ require ( github.com/gobuffalo/packr v1.12.1 // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5 // indirect github.com/googleapis/gax-go/v2 v2.0.5 // indirect github.com/hashicorp/golang-lru v0.5.1 // indirect diff --git a/go.sum b/go.sum index c714b5fe83..b0bd9e3f99 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= firebase.google.com/go v3.12.0+incompatible h1:q70KCp/J0oOL8kJ8oV2j3646kV4TB8Y5IvxXC0WT1bo= firebase.google.com/go v3.12.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs= +github.com/2opremio/pretty v0.2.2-0.20230601220618-e1d5758b2a95 h1:vvMDiVd621MU1Djr7Ep7OXu8gHOtsdwrI4tjnIGvpTg= +github.com/2opremio/pretty v0.2.2-0.20230601220618-e1d5758b2a95/go.mod h1:Gv4NIpY67KDahg+DtIG5/2Ok4l8vzYEekiirSCH+IGA= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -74,6 +76,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/creachadair/jrpc2 v0.41.1 h1:GnSQNk+vt8B/oayJlfOXVRi4hg8DuB9NsppFGe8iVJ0= +github.com/creachadair/jrpc2 v0.41.1/go.mod h1:k2mGfjsgE2h2Vo12C9NzZguUzzl3gnfGCmLIvg84pVE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -88,6 +92,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955 h1:gmtGRvSexPU4B1T/yYo0sLOKzER1YT+b4kPxPpm0Ty4= @@ -157,8 +163,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5 h1:oERTZ1buOUYlpmKaqlO5fYmz8cZ1rYu5DieJzF4ZVmU= github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= @@ -289,6 +296,8 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 h1:/K3IL0Z1quvmJ7X0A1AwNEK7CRkVK3YwfOU/QAL4WGg= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00 h1:8DPul/X0IT/1TNMIxoKLwdemEOBBHDC/K4EB16Cw5WE= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521 h1:3hxavr+IHMsQBrYUPQM5v0CgENFktkkbg1sfpgM3h20= @@ -487,6 +496,9 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/gxdr/xdr_generated.go b/gxdr/xdr_generated.go index 3467d76b29..35bf5e7429 100644 --- a/gxdr/xdr_generated.go +++ b/gxdr/xdr_generated.go @@ -632,7 +632,7 @@ type ContractDataEntry struct { type ContractCodeEntry struct { Ext ExtensionPoint Hash Hash - Code []byte // bound SCVAL_LIMIT + Code []byte } type LedgerEntryExtensionV1 struct { @@ -749,20 +749,16 @@ type XdrAnon_LedgerKey_ConfigSetting struct { type EnvelopeType int32 const ( - ENVELOPE_TYPE_TX_V0 EnvelopeType = 0 - ENVELOPE_TYPE_SCP EnvelopeType = 1 - ENVELOPE_TYPE_TX EnvelopeType = 2 - ENVELOPE_TYPE_AUTH EnvelopeType = 3 - ENVELOPE_TYPE_SCPVALUE EnvelopeType = 4 - ENVELOPE_TYPE_TX_FEE_BUMP EnvelopeType = 5 - ENVELOPE_TYPE_OP_ID EnvelopeType = 6 - ENVELOPE_TYPE_POOL_REVOKE_OP_ID EnvelopeType = 7 - ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519 EnvelopeType = 8 - ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT EnvelopeType = 9 - ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET EnvelopeType = 10 - ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT EnvelopeType = 11 - ENVELOPE_TYPE_CREATE_CONTRACT_ARGS EnvelopeType = 12 - ENVELOPE_TYPE_CONTRACT_AUTH EnvelopeType = 13 + ENVELOPE_TYPE_TX_V0 EnvelopeType = 0 + ENVELOPE_TYPE_SCP EnvelopeType = 1 + ENVELOPE_TYPE_TX EnvelopeType = 2 + ENVELOPE_TYPE_AUTH EnvelopeType = 3 + ENVELOPE_TYPE_SCPVALUE EnvelopeType = 4 + ENVELOPE_TYPE_TX_FEE_BUMP EnvelopeType = 5 + ENVELOPE_TYPE_OP_ID EnvelopeType = 6 + ENVELOPE_TYPE_POOL_REVOKE_OP_ID EnvelopeType = 7 + ENVELOPE_TYPE_CONTRACT_ID EnvelopeType = 8 + ENVELOPE_TYPE_SOROBAN_AUTHORIZATION EnvelopeType = 9 ) type UpgradeType = []byte // bound 128 @@ -1058,31 +1054,6 @@ type XdrAnon_TransactionHistoryResultEntry_Ext struct { _u interface{} } -type TransactionResultPairV2 struct { - TransactionHash Hash - // hash of hashes in TransactionMetaV3 - HashOfMetaHashes Hash -} - -type TransactionResultSetV2 struct { - Results []TransactionResultPairV2 -} - -type TransactionHistoryResultEntryV2 struct { - LedgerSeq Uint32 - TxResultSet TransactionResultSetV2 - Ext XdrAnon_TransactionHistoryResultEntryV2_Ext -} - -// reserved for future use -type XdrAnon_TransactionHistoryResultEntryV2_Ext struct { - // The union discriminant V selects among the following arms: - // 0: - // void - V int32 - _u interface{} -} - type LedgerHeaderHistoryEntry struct { Hash Hash Header LedgerHeader @@ -1202,14 +1173,6 @@ type DiagnosticEvent struct { Event ContractEvent } -type OperationDiagnosticEvents struct { - Events []DiagnosticEvent -} - -type OperationEvents struct { - Events []ContractEvent -} - type TransactionMetaV3 struct { // tx level changes before operations TxChangesBefore LedgerEntryChanges @@ -1218,15 +1181,19 @@ type TransactionMetaV3 struct { // tx level changes after operations are TxChangesAfter LedgerEntryChanges // applied if any - Events []OperationEvents - // contracts themselves. One list per operation. - TxResult TransactionResult - // stores sha256(txChangesBefore, operations, txChangesAfter), - Hashes [3]Hash - // Diagnostics events that are not hashed. One list per operation. + Events []ContractEvent + // contracts themselves. + ReturnValue SCVal + // Diagnostics events that are not hashed. // This will contain all contract and diagnostic events. Even ones // that were emitted in a failed contract call. - DiagnosticEvents []OperationDiagnosticEvents + DiagnosticEvents []DiagnosticEvent +} + +// This is in Stellar-ledger.x to due to a circular dependency +type InvokeHostFunctionSuccessPreImage struct { + ReturnValue SCVal + Events []ContractEvent } // this is the meta produced when applying transactions @@ -1254,12 +1221,6 @@ type TransactionResultMeta struct { TxApplyProcessing TransactionMeta } -type TransactionResultMetaV2 struct { - Result TransactionResultPairV2 - FeeProcessing LedgerEntryChanges - TxApplyProcessing TransactionMeta -} - // this represents a single upgrade that was performed as part of a ledger // upgrade type UpgradeEntryMeta struct { @@ -1294,28 +1255,12 @@ type LedgerCloseMetaV1 struct { ScpInfo []SCPHistoryEntry } -// only difference between V1 and V2 is this uses TransactionResultMetaV2 -type LedgerCloseMetaV2 struct { - LedgerHeader LedgerHeaderHistoryEntry - TxSet GeneralizedTransactionSet - // NB: transactions are sorted in apply order here - // fees for all transactions are processed first - // followed by applying transactions - TxProcessing []TransactionResultMetaV2 - // upgrades are applied last - UpgradesProcessing []UpgradeEntryMeta - // other misc information attached to the ledger close - ScpInfo []SCPHistoryEntry -} - type LedgerCloseMeta struct { // The union discriminant V selects among the following arms: // 0: // V0() *LedgerCloseMetaV0 // 1: // V1() *LedgerCloseMetaV1 - // 2: - // V2() *LedgerCloseMetaV2 V int32 _u interface{} } @@ -1344,6 +1289,11 @@ type SendMore struct { NumMessages Uint32 } +type SendMoreExtended struct { + NumMessages Uint32 + NumBytes Uint32 +} + type AuthCert struct { Pubkey Curve25519Public Expiration Uint64 @@ -1362,15 +1312,14 @@ type Hello struct { Nonce Uint256 } -// During the roll-out phrase, pull mode will be optional. +// During the roll-out phrase, nodes can disable flow control in bytes. // Therefore, we need a way to communicate with other nodes -// that we want/don't want pull mode. -// However, the goal is for everyone to enable it by default, -// so we don't want to introduce a new member variable. -// For now, we'll use the `flags` field (originally named -// `unused`) in `Auth`. -// 100 is just a number that is not 0. -const AUTH_MSG_FLAG_PULL_MODE_REQUESTED = 100 +// that we want/don't want flow control in bytes. +// We use the `flags` field in the Auth message with a special value +// set to communicate this. Note that AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED != 0 +// AND AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED != 100 (as previously +// that value was used for other purposes). +const AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED = 200 type Auth struct { Flags int32 @@ -1398,7 +1347,7 @@ type XdrAnon_PeerAddress_Ip struct { _u interface{} } -// Next ID: 18 +// Next ID: 21 type MessageType int32 const ( @@ -1420,12 +1369,13 @@ const ( SCP_MESSAGE MessageType = 11 GET_SCP_STATE MessageType = 12 // new messages - HELLO MessageType = 13 - SURVEY_REQUEST MessageType = 14 - SURVEY_RESPONSE MessageType = 15 - SEND_MORE MessageType = 16 - FLOOD_ADVERT MessageType = 18 - FLOOD_DEMAND MessageType = 19 + HELLO MessageType = 13 + SURVEY_REQUEST MessageType = 14 + SURVEY_RESPONSE MessageType = 15 + SEND_MORE MessageType = 16 + SEND_MORE_EXTENDED MessageType = 20 + FLOOD_ADVERT MessageType = 18 + FLOOD_DEMAND MessageType = 19 ) type DontHave struct { @@ -1572,6 +1522,8 @@ type StellarMessage struct { // GetSCPLedgerSeq() *Uint32 // SEND_MORE: // SendMoreMessage() *SendMore + // SEND_MORE_EXTENDED: + // SendMoreExtendedMessage() *SendMoreExtended // FLOOD_ADVERT: // FloodAdvert() *FloodAdvert // FLOOD_DEMAND: @@ -2061,93 +2013,111 @@ const ( HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM HostFunctionType = 2 ) -type ContractIDType int32 - -const ( - CONTRACT_ID_FROM_SOURCE_ACCOUNT ContractIDType = 0 - CONTRACT_ID_FROM_ED25519_PUBLIC_KEY ContractIDType = 1 - CONTRACT_ID_FROM_ASSET ContractIDType = 2 -) - -type ContractIDPublicKeyType int32 +type ContractIDPreimageType int32 const ( - CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT ContractIDPublicKeyType = 0 - CONTRACT_ID_PUBLIC_KEY_ED25519 ContractIDPublicKeyType = 1 + CONTRACT_ID_PREIMAGE_FROM_ADDRESS ContractIDPreimageType = 0 + CONTRACT_ID_PREIMAGE_FROM_ASSET ContractIDPreimageType = 1 ) -type UploadContractWasmArgs struct { - Code []byte // bound SCVAL_LIMIT -} - -type ContractID struct { +type ContractIDPreimage struct { // The union discriminant Type selects among the following arms: - // CONTRACT_ID_FROM_SOURCE_ACCOUNT: - // Salt() *Uint256 - // CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: - // FromEd25519PublicKey() *XdrAnon_ContractID_FromEd25519PublicKey - // CONTRACT_ID_FROM_ASSET: - // Asset() *Asset - Type ContractIDType + // CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + // FromAddress() *XdrAnon_ContractIDPreimage_FromAddress + // CONTRACT_ID_PREIMAGE_FROM_ASSET: + // FromAsset() *Asset + Type ContractIDPreimageType _u interface{} } -type XdrAnon_ContractID_FromEd25519PublicKey struct { - Key Uint256 - Signature Signature - Salt Uint256 +type XdrAnon_ContractIDPreimage_FromAddress struct { + Address SCAddress + Salt Uint256 } type CreateContractArgs struct { - ContractID ContractID - Executable SCContractExecutable + ContractIDPreimage ContractIDPreimage + Executable SCContractExecutable } -type HostFunctionArgs struct { +type HostFunction struct { // The union discriminant Type selects among the following arms: // HOST_FUNCTION_TYPE_INVOKE_CONTRACT: // InvokeContract() *SCVec // HOST_FUNCTION_TYPE_CREATE_CONTRACT: // CreateContract() *CreateContractArgs // HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - // UploadContractWasm() *UploadContractWasmArgs + // Wasm() *[]byte Type HostFunctionType _u interface{} } -type AuthorizedInvocation struct { - ContractID Hash - FunctionName SCSymbol - Args SCVec - SubInvocations []AuthorizedInvocation +type SorobanAuthorizedFunctionType int32 + +const ( + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN SorobanAuthorizedFunctionType = 0 + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN SorobanAuthorizedFunctionType = 1 +) + +type SorobanAuthorizedContractFunction struct { + ContractAddress SCAddress + FunctionName SCSymbol + Args SCVec +} + +type SorobanAuthorizedFunction struct { + // The union discriminant Type selects among the following arms: + // SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: + // ContractFn() *SorobanAuthorizedContractFunction + // SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + // CreateContractHostFn() *CreateContractArgs + Type SorobanAuthorizedFunctionType + _u interface{} } -type AddressWithNonce struct { - Address SCAddress - Nonce Uint64 +type SorobanAuthorizedInvocation struct { + Function SorobanAuthorizedFunction + SubInvocations []SorobanAuthorizedInvocation } -type ContractAuth struct { - // not present for invoker - AddressWithNonce *AddressWithNonce - RootInvocation AuthorizedInvocation - SignatureArgs SCVec +type SorobanAddressCredentials struct { + Address SCAddress + Nonce Uint64 + SignatureArgs SCVec } -type HostFunction struct { - // Arguments of the function to call defined by the function - // type. - Args HostFunctionArgs - // Per-address authorizations for this host fn - // Currently only supported for INVOKE_CONTRACT function - Auth []ContractAuth +type SorobanCredentialsType int32 + +const ( + SOROBAN_CREDENTIALS_SOURCE_ACCOUNT SorobanCredentialsType = 0 + SOROBAN_CREDENTIALS_ADDRESS SorobanCredentialsType = 1 +) + +type SorobanCredentials struct { + // The union discriminant Type selects among the following arms: + // SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: + // void + // SOROBAN_CREDENTIALS_ADDRESS: + // Address() *SorobanAddressCredentials + Type SorobanCredentialsType + _u interface{} +} + +/* +Unit of authorization data for Soroban. + + Represents an authorization for executing the tree of authorized contract + and/or host function calls by the user defined by `credentials`. +*/ +type SorobanAuthorizationEntry struct { + Credentials SorobanCredentials + RootInvocation SorobanAuthorizedInvocation } type InvokeHostFunctionOp struct { - // The host functions to invoke. The functions will be executed - // in the same fashion as operations: either all functions will - // be successfully applied or all fail if at least one of them - // fails. - Functions []HostFunction // bound MAX_OPS_PER_TX + // Host function to invoke. + HostFunction HostFunction + // Per-address authorizations for this host function. + Auth []SorobanAuthorizationEntry } /* An operation is the lowest unit of work that a transaction does */ @@ -2220,18 +2190,10 @@ type HashIDPreimage struct { // OperationID() *XdrAnon_HashIDPreimage_OperationID // ENVELOPE_TYPE_POOL_REVOKE_OP_ID: // RevokeID() *XdrAnon_HashIDPreimage_RevokeID - // ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519: - // Ed25519ContractID() *XdrAnon_HashIDPreimage_Ed25519ContractID - // ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: + // ENVELOPE_TYPE_CONTRACT_ID: // ContractID() *XdrAnon_HashIDPreimage_ContractID - // ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: - // FromAsset() *XdrAnon_HashIDPreimage_FromAsset - // ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: - // SourceAccountContractID() *XdrAnon_HashIDPreimage_SourceAccountContractID - // ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: - // CreateContractArgs() *XdrAnon_HashIDPreimage_CreateContractArgs - // ENVELOPE_TYPE_CONTRACT_AUTH: - // ContractAuth() *XdrAnon_HashIDPreimage_ContractAuth + // ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + // SorobanAuthorization() *XdrAnon_HashIDPreimage_SorobanAuthorization Type EnvelopeType _u interface{} } @@ -2247,34 +2209,14 @@ type XdrAnon_HashIDPreimage_RevokeID struct { LiquidityPoolID PoolID Asset Asset } -type XdrAnon_HashIDPreimage_Ed25519ContractID struct { - NetworkID Hash - Ed25519 Uint256 - Salt Uint256 -} type XdrAnon_HashIDPreimage_ContractID struct { - NetworkID Hash - ContractID Hash - Salt Uint256 -} -type XdrAnon_HashIDPreimage_FromAsset struct { - NetworkID Hash - Asset Asset -} -type XdrAnon_HashIDPreimage_SourceAccountContractID struct { - NetworkID Hash - SourceAccount AccountID - Salt Uint256 -} -type XdrAnon_HashIDPreimage_CreateContractArgs struct { - NetworkID Hash - Executable SCContractExecutable - Salt Uint256 + NetworkID Hash + ContractIDPreimage ContractIDPreimage } -type XdrAnon_HashIDPreimage_ContractAuth struct { +type XdrAnon_HashIDPreimage_SorobanAuthorization struct { NetworkID Hash Nonce Uint64 - Invocation AuthorizedInvocation + Invocation SorobanAuthorizedInvocation } type MemoType int32 @@ -3292,7 +3234,7 @@ const ( type InvokeHostFunctionResult struct { // The union discriminant Code selects among the following arms: // INVOKE_HOST_FUNCTION_SUCCESS: - // Success() *[]SCVal // bound MAX_OPS_PER_TX + // Success() *Hash // INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: // void Code InvokeHostFunctionResultCode @@ -3637,7 +3579,7 @@ const ( // Types with no parameters. SC_SPEC_TYPE_BOOL SCSpecType = 1 SC_SPEC_TYPE_VOID SCSpecType = 2 - SC_SPEC_TYPE_STATUS SCSpecType = 3 + SC_SPEC_TYPE_ERROR SCSpecType = 3 SC_SPEC_TYPE_U32 SCSpecType = 4 SC_SPEC_TYPE_I32 SCSpecType = 5 SC_SPEC_TYPE_U64 SCSpecType = 6 @@ -3700,7 +3642,7 @@ type SCSpecTypeUDT struct { type SCSpecTypeDef struct { // The union discriminant Type selects among the following arms: - // SC_SPEC_TYPE_VAL, SC_SPEC_TYPE_BOOL, SC_SPEC_TYPE_VOID, SC_SPEC_TYPE_STATUS, 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_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: // void // SC_SPEC_TYPE_OPTION: // Option() *SCSpecTypeOption @@ -3838,9 +3780,9 @@ type SCSpecEntry struct { type SCValType int32 const ( - SCV_BOOL SCValType = 0 - SCV_VOID SCValType = 1 - SCV_STATUS SCValType = 2 + SCV_BOOL SCValType = 0 + SCV_VOID SCValType = 1 + SCV_ERROR SCValType = 2 // 32 bits is the smallest type in WASM or XDR; no need for u8/u16. SCV_U32 SCValType = 3 SCV_I32 SCValType = 4 @@ -3880,142 +3822,49 @@ const ( SCV_LEDGER_KEY_NONCE SCValType = 21 ) -type SCStatusType int32 - -const ( - SST_OK SCStatusType = 0 - SST_UNKNOWN_ERROR SCStatusType = 1 - SST_HOST_VALUE_ERROR SCStatusType = 2 - SST_HOST_OBJECT_ERROR SCStatusType = 3 - SST_HOST_FUNCTION_ERROR SCStatusType = 4 - SST_HOST_STORAGE_ERROR SCStatusType = 5 - SST_HOST_CONTEXT_ERROR SCStatusType = 6 - SST_VM_ERROR SCStatusType = 7 - SST_CONTRACT_ERROR SCStatusType = 8 - SST_HOST_AUTH_ERROR SCStatusType = 9 -) - -type SCHostValErrorCode int32 - -const ( - HOST_VALUE_UNKNOWN_ERROR SCHostValErrorCode = 0 - HOST_VALUE_RESERVED_TAG_VALUE SCHostValErrorCode = 1 - HOST_VALUE_UNEXPECTED_VAL_TYPE SCHostValErrorCode = 2 - HOST_VALUE_U63_OUT_OF_RANGE SCHostValErrorCode = 3 - HOST_VALUE_U32_OUT_OF_RANGE SCHostValErrorCode = 4 - HOST_VALUE_STATIC_UNKNOWN SCHostValErrorCode = 5 - HOST_VALUE_MISSING_OBJECT SCHostValErrorCode = 6 - HOST_VALUE_SYMBOL_TOO_LONG SCHostValErrorCode = 7 - HOST_VALUE_SYMBOL_BAD_CHAR SCHostValErrorCode = 8 - HOST_VALUE_SYMBOL_CONTAINS_NON_UTF8 SCHostValErrorCode = 9 - HOST_VALUE_BITSET_TOO_MANY_BITS SCHostValErrorCode = 10 - HOST_VALUE_STATUS_UNKNOWN SCHostValErrorCode = 11 -) - -type SCHostObjErrorCode int32 - -const ( - HOST_OBJECT_UNKNOWN_ERROR SCHostObjErrorCode = 0 - HOST_OBJECT_UNKNOWN_REFERENCE SCHostObjErrorCode = 1 - HOST_OBJECT_UNEXPECTED_TYPE SCHostObjErrorCode = 2 - HOST_OBJECT_OBJECT_COUNT_EXCEEDS_U32_MAX SCHostObjErrorCode = 3 - HOST_OBJECT_OBJECT_NOT_EXIST SCHostObjErrorCode = 4 - HOST_OBJECT_VEC_INDEX_OUT_OF_BOUND SCHostObjErrorCode = 5 - HOST_OBJECT_CONTRACT_HASH_WRONG_LENGTH SCHostObjErrorCode = 6 -) - -type SCHostFnErrorCode int32 - -const ( - HOST_FN_UNKNOWN_ERROR SCHostFnErrorCode = 0 - HOST_FN_UNEXPECTED_HOST_FUNCTION_ACTION SCHostFnErrorCode = 1 - HOST_FN_INPUT_ARGS_WRONG_LENGTH SCHostFnErrorCode = 2 - HOST_FN_INPUT_ARGS_WRONG_TYPE SCHostFnErrorCode = 3 - HOST_FN_INPUT_ARGS_INVALID SCHostFnErrorCode = 4 -) - -type SCHostStorageErrorCode int32 - -const ( - HOST_STORAGE_UNKNOWN_ERROR SCHostStorageErrorCode = 0 - HOST_STORAGE_EXPECT_CONTRACT_DATA SCHostStorageErrorCode = 1 - HOST_STORAGE_READWRITE_ACCESS_TO_READONLY_ENTRY SCHostStorageErrorCode = 2 - HOST_STORAGE_ACCESS_TO_UNKNOWN_ENTRY SCHostStorageErrorCode = 3 - HOST_STORAGE_MISSING_KEY_IN_GET SCHostStorageErrorCode = 4 - HOST_STORAGE_GET_ON_DELETED_KEY SCHostStorageErrorCode = 5 -) - -type SCHostAuthErrorCode int32 - -const ( - HOST_AUTH_UNKNOWN_ERROR SCHostAuthErrorCode = 0 - HOST_AUTH_NONCE_ERROR SCHostAuthErrorCode = 1 - HOST_AUTH_DUPLICATE_AUTHORIZATION SCHostAuthErrorCode = 2 - HOST_AUTH_NOT_AUTHORIZED SCHostAuthErrorCode = 3 -) - -type SCHostContextErrorCode int32 - -const ( - HOST_CONTEXT_UNKNOWN_ERROR SCHostContextErrorCode = 0 - HOST_CONTEXT_NO_CONTRACT_RUNNING SCHostContextErrorCode = 1 -) - -type SCVmErrorCode int32 +type SCErrorType int32 const ( - VM_UNKNOWN SCVmErrorCode = 0 - VM_VALIDATION SCVmErrorCode = 1 - VM_INSTANTIATION SCVmErrorCode = 2 - VM_FUNCTION SCVmErrorCode = 3 - VM_TABLE SCVmErrorCode = 4 - VM_MEMORY SCVmErrorCode = 5 - VM_GLOBAL SCVmErrorCode = 6 - VM_VALUE SCVmErrorCode = 7 - VM_TRAP_UNREACHABLE SCVmErrorCode = 8 - VM_TRAP_MEMORY_ACCESS_OUT_OF_BOUNDS SCVmErrorCode = 9 - VM_TRAP_TABLE_ACCESS_OUT_OF_BOUNDS SCVmErrorCode = 10 - VM_TRAP_ELEM_UNINITIALIZED SCVmErrorCode = 11 - VM_TRAP_DIVISION_BY_ZERO SCVmErrorCode = 12 - VM_TRAP_INTEGER_OVERFLOW SCVmErrorCode = 13 - VM_TRAP_INVALID_CONVERSION_TO_INT SCVmErrorCode = 14 - VM_TRAP_STACK_OVERFLOW SCVmErrorCode = 15 - VM_TRAP_UNEXPECTED_SIGNATURE SCVmErrorCode = 16 - VM_TRAP_MEM_LIMIT_EXCEEDED SCVmErrorCode = 17 - VM_TRAP_CPU_LIMIT_EXCEEDED SCVmErrorCode = 18 + SCE_CONTRACT SCErrorType = 0 + SCE_WASM_VM SCErrorType = 1 + SCE_CONTEXT SCErrorType = 2 + SCE_STORAGE SCErrorType = 3 + SCE_OBJECT SCErrorType = 4 + SCE_CRYPTO SCErrorType = 5 + SCE_EVENTS SCErrorType = 6 + SCE_BUDGET SCErrorType = 7 + SCE_VALUE SCErrorType = 8 + SCE_AUTH SCErrorType = 9 ) -type SCUnknownErrorCode int32 +type SCErrorCode int32 const ( - UNKNOWN_ERROR_GENERAL SCUnknownErrorCode = 0 - UNKNOWN_ERROR_XDR SCUnknownErrorCode = 1 + // some arithmetic wasn't defined (overflow, divide-by-zero) + SCEC_ARITH_DOMAIN SCErrorCode = 0 + // something was indexed beyond its bounds + SCEC_INDEX_BOUNDS SCErrorCode = 1 + // user provided some otherwise-bad data + SCEC_INVALID_INPUT SCErrorCode = 2 + // some value was required but not provided + SCEC_MISSING_VALUE SCErrorCode = 3 + // some value was provided where not allowed + SCEC_EXISTING_VALUE SCErrorCode = 4 + // some arbitrary limit -- gas or otherwise -- was hit + SCEC_EXCEEDED_LIMIT SCErrorCode = 5 + // data was valid but action requested was not + SCEC_INVALID_ACTION SCErrorCode = 6 + // the internal state of the host was otherwise-bad + SCEC_INTERNAL_ERROR SCErrorCode = 7 + // some type wasn't as expected + SCEC_UNEXPECTED_TYPE SCErrorCode = 8 + // something's size wasn't as expected + SCEC_UNEXPECTED_SIZE SCErrorCode = 9 ) -type SCStatus struct { - // The union discriminant Type selects among the following arms: - // SST_OK: - // void - // SST_UNKNOWN_ERROR: - // UnknownCode() *SCUnknownErrorCode - // SST_HOST_VALUE_ERROR: - // ValCode() *SCHostValErrorCode - // SST_HOST_OBJECT_ERROR: - // ObjCode() *SCHostObjErrorCode - // SST_HOST_FUNCTION_ERROR: - // FnCode() *SCHostFnErrorCode - // SST_HOST_STORAGE_ERROR: - // StorageCode() *SCHostStorageErrorCode - // SST_HOST_CONTEXT_ERROR: - // ContextCode() *SCHostContextErrorCode - // SST_VM_ERROR: - // VmCode() *SCVmErrorCode - // SST_CONTRACT_ERROR: - // ContractCode() *Uint32 - // SST_HOST_AUTH_ERROR: - // AuthCode() *SCHostAuthErrorCode - Type SCStatusType - _u interface{} +type SCError struct { + Type SCErrorType + Code SCErrorCode } type UInt128Parts struct { @@ -4084,17 +3933,15 @@ type SCAddress struct { _u interface{} } -const SCVAL_LIMIT = 256000 - const SCSYMBOL_LIMIT = 32 -type SCVec = []SCVal // bound SCVAL_LIMIT +type SCVec = []SCVal -type SCMap = []SCMapEntry // bound SCVAL_LIMIT +type SCMap = []SCMapEntry -type SCBytes = []byte // bound SCVAL_LIMIT +type SCBytes = []byte -type SCString = string // bound SCVAL_LIMIT +type SCString = string type SCSymbol = string // bound SCSYMBOL_LIMIT @@ -4108,8 +3955,8 @@ type SCVal struct { // B() *bool // SCV_VOID: // void - // SCV_STATUS: - // Error() *SCStatus + // SCV_ERROR: + // Error() *SCError // SCV_U32: // U32() *Uint32 // SCV_I32: @@ -7840,7 +7687,7 @@ func (v *ContractCodeEntry) XdrRecurse(x XDR, name string) { } x.Marshal(x.Sprintf("%sext", name), XDR_ExtensionPoint(&v.Ext)) x.Marshal(x.Sprintf("%shash", name), XDR_Hash(&v.Hash)) - x.Marshal(x.Sprintf("%scode", name), XdrVecOpaque{&v.Code, SCVAL_LIMIT}) + x.Marshal(x.Sprintf("%scode", name), XdrVecOpaque{&v.Code, 0xffffffff}) } func XDR_ContractCodeEntry(v *ContractCodeEntry) *ContractCodeEntry { return v } @@ -8663,36 +8510,28 @@ func (u *LedgerKey) XdrRecurse(x XDR, name string) { func XDR_LedgerKey(v *LedgerKey) *LedgerKey { return v } var _XdrNames_EnvelopeType = map[int32]string{ - int32(ENVELOPE_TYPE_TX_V0): "ENVELOPE_TYPE_TX_V0", - int32(ENVELOPE_TYPE_SCP): "ENVELOPE_TYPE_SCP", - int32(ENVELOPE_TYPE_TX): "ENVELOPE_TYPE_TX", - int32(ENVELOPE_TYPE_AUTH): "ENVELOPE_TYPE_AUTH", - int32(ENVELOPE_TYPE_SCPVALUE): "ENVELOPE_TYPE_SCPVALUE", - int32(ENVELOPE_TYPE_TX_FEE_BUMP): "ENVELOPE_TYPE_TX_FEE_BUMP", - int32(ENVELOPE_TYPE_OP_ID): "ENVELOPE_TYPE_OP_ID", - int32(ENVELOPE_TYPE_POOL_REVOKE_OP_ID): "ENVELOPE_TYPE_POOL_REVOKE_OP_ID", - int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519): "ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519", - int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT): "ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT", - int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET): "ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET", - int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT): "ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT", - int32(ENVELOPE_TYPE_CREATE_CONTRACT_ARGS): "ENVELOPE_TYPE_CREATE_CONTRACT_ARGS", - int32(ENVELOPE_TYPE_CONTRACT_AUTH): "ENVELOPE_TYPE_CONTRACT_AUTH", + int32(ENVELOPE_TYPE_TX_V0): "ENVELOPE_TYPE_TX_V0", + int32(ENVELOPE_TYPE_SCP): "ENVELOPE_TYPE_SCP", + int32(ENVELOPE_TYPE_TX): "ENVELOPE_TYPE_TX", + int32(ENVELOPE_TYPE_AUTH): "ENVELOPE_TYPE_AUTH", + int32(ENVELOPE_TYPE_SCPVALUE): "ENVELOPE_TYPE_SCPVALUE", + int32(ENVELOPE_TYPE_TX_FEE_BUMP): "ENVELOPE_TYPE_TX_FEE_BUMP", + int32(ENVELOPE_TYPE_OP_ID): "ENVELOPE_TYPE_OP_ID", + int32(ENVELOPE_TYPE_POOL_REVOKE_OP_ID): "ENVELOPE_TYPE_POOL_REVOKE_OP_ID", + int32(ENVELOPE_TYPE_CONTRACT_ID): "ENVELOPE_TYPE_CONTRACT_ID", + int32(ENVELOPE_TYPE_SOROBAN_AUTHORIZATION): "ENVELOPE_TYPE_SOROBAN_AUTHORIZATION", } var _XdrValues_EnvelopeType = map[string]int32{ - "ENVELOPE_TYPE_TX_V0": int32(ENVELOPE_TYPE_TX_V0), - "ENVELOPE_TYPE_SCP": int32(ENVELOPE_TYPE_SCP), - "ENVELOPE_TYPE_TX": int32(ENVELOPE_TYPE_TX), - "ENVELOPE_TYPE_AUTH": int32(ENVELOPE_TYPE_AUTH), - "ENVELOPE_TYPE_SCPVALUE": int32(ENVELOPE_TYPE_SCPVALUE), - "ENVELOPE_TYPE_TX_FEE_BUMP": int32(ENVELOPE_TYPE_TX_FEE_BUMP), - "ENVELOPE_TYPE_OP_ID": int32(ENVELOPE_TYPE_OP_ID), - "ENVELOPE_TYPE_POOL_REVOKE_OP_ID": int32(ENVELOPE_TYPE_POOL_REVOKE_OP_ID), - "ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519": int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519), - "ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT": int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT), - "ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET": int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET), - "ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT": int32(ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT), - "ENVELOPE_TYPE_CREATE_CONTRACT_ARGS": int32(ENVELOPE_TYPE_CREATE_CONTRACT_ARGS), - "ENVELOPE_TYPE_CONTRACT_AUTH": int32(ENVELOPE_TYPE_CONTRACT_AUTH), + "ENVELOPE_TYPE_TX_V0": int32(ENVELOPE_TYPE_TX_V0), + "ENVELOPE_TYPE_SCP": int32(ENVELOPE_TYPE_SCP), + "ENVELOPE_TYPE_TX": int32(ENVELOPE_TYPE_TX), + "ENVELOPE_TYPE_AUTH": int32(ENVELOPE_TYPE_AUTH), + "ENVELOPE_TYPE_SCPVALUE": int32(ENVELOPE_TYPE_SCPVALUE), + "ENVELOPE_TYPE_TX_FEE_BUMP": int32(ENVELOPE_TYPE_TX_FEE_BUMP), + "ENVELOPE_TYPE_OP_ID": int32(ENVELOPE_TYPE_OP_ID), + "ENVELOPE_TYPE_POOL_REVOKE_OP_ID": int32(ENVELOPE_TYPE_POOL_REVOKE_OP_ID), + "ENVELOPE_TYPE_CONTRACT_ID": int32(ENVELOPE_TYPE_CONTRACT_ID), + "ENVELOPE_TYPE_SOROBAN_AUTHORIZATION": int32(ENVELOPE_TYPE_SOROBAN_AUTHORIZATION), } func (EnvelopeType) XdrEnumNames() map[int32]string { @@ -10652,178 +10491,6 @@ func XDR_TransactionHistoryResultEntry(v *TransactionHistoryResultEntry) *Transa return v } -type XdrType_TransactionResultPairV2 = *TransactionResultPairV2 - -func (v *TransactionResultPairV2) XdrPointer() interface{} { return v } -func (TransactionResultPairV2) XdrTypeName() string { return "TransactionResultPairV2" } -func (v TransactionResultPairV2) XdrValue() interface{} { return v } -func (v *TransactionResultPairV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionResultPairV2) 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("%shashOfMetaHashes", name), XDR_Hash(&v.HashOfMetaHashes)) -} -func XDR_TransactionResultPairV2(v *TransactionResultPairV2) *TransactionResultPairV2 { return v } - -type _XdrVec_unbounded_TransactionResultPairV2 []TransactionResultPairV2 - -func (_XdrVec_unbounded_TransactionResultPairV2) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_unbounded_TransactionResultPairV2) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_TransactionResultPairV2 length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_TransactionResultPairV2 length %d exceeds max int", length) - } -} -func (v _XdrVec_unbounded_TransactionResultPairV2) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_TransactionResultPairV2) 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([]TransactionResultPairV2, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_unbounded_TransactionResultPairV2) 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_TransactionResultPairV2(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_unbounded_TransactionResultPairV2) 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_TransactionResultPairV2) XdrTypeName() string { - return "TransactionResultPairV2<>" -} -func (v *_XdrVec_unbounded_TransactionResultPairV2) XdrPointer() interface{} { - return (*[]TransactionResultPairV2)(v) -} -func (v _XdrVec_unbounded_TransactionResultPairV2) XdrValue() interface{} { - return ([]TransactionResultPairV2)(v) -} -func (v *_XdrVec_unbounded_TransactionResultPairV2) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} - -type XdrType_TransactionResultSetV2 = *TransactionResultSetV2 - -func (v *TransactionResultSetV2) XdrPointer() interface{} { return v } -func (TransactionResultSetV2) XdrTypeName() string { return "TransactionResultSetV2" } -func (v TransactionResultSetV2) XdrValue() interface{} { return v } -func (v *TransactionResultSetV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionResultSetV2) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sresults", name), (*_XdrVec_unbounded_TransactionResultPairV2)(&v.Results)) -} -func XDR_TransactionResultSetV2(v *TransactionResultSetV2) *TransactionResultSetV2 { return v } - -var _XdrTags_XdrAnon_TransactionHistoryResultEntryV2_Ext = map[int32]bool{ - XdrToI32(0): true, -} - -func (_ XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrValidTags() map[int32]bool { - return _XdrTags_XdrAnon_TransactionHistoryResultEntryV2_Ext -} -func (u XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrValid() bool { - switch u.V { - case 0: - return true - } - return false -} -func (u *XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrUnionTag() XdrNum32 { - return XDR_int32(&u.V) -} -func (u *XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrUnionTagName() string { - return "V" -} -func (u *XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrUnionBody() XdrType { - switch u.V { - case 0: - return nil - } - return nil -} -func (u *XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrUnionBodyName() string { - switch u.V { - case 0: - return "" - } - return "" -} - -type XdrType_XdrAnon_TransactionHistoryResultEntryV2_Ext = *XdrAnon_TransactionHistoryResultEntryV2_Ext - -func (v *XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrPointer() interface{} { return v } -func (XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrTypeName() string { - return "XdrAnon_TransactionHistoryResultEntryV2_Ext" -} -func (v XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrValue() interface{} { return v } -func (v *XdrAnon_TransactionHistoryResultEntryV2_Ext) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} -func (u *XdrAnon_TransactionHistoryResultEntryV2_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: - return - } - XdrPanic("invalid V (%v) in XdrAnon_TransactionHistoryResultEntryV2_Ext", u.V) -} -func XDR_XdrAnon_TransactionHistoryResultEntryV2_Ext(v *XdrAnon_TransactionHistoryResultEntryV2_Ext) *XdrAnon_TransactionHistoryResultEntryV2_Ext { - return v -} - -type XdrType_TransactionHistoryResultEntryV2 = *TransactionHistoryResultEntryV2 - -func (v *TransactionHistoryResultEntryV2) XdrPointer() interface{} { return v } -func (TransactionHistoryResultEntryV2) XdrTypeName() string { return "TransactionHistoryResultEntryV2" } -func (v TransactionHistoryResultEntryV2) XdrValue() interface{} { return v } -func (v *TransactionHistoryResultEntryV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionHistoryResultEntryV2) 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("%stxResultSet", name), XDR_TransactionResultSetV2(&v.TxResultSet)) - x.Marshal(x.Sprintf("%sext", name), XDR_XdrAnon_TransactionHistoryResultEntryV2_Ext(&v.Ext)) -} -func XDR_TransactionHistoryResultEntryV2(v *TransactionHistoryResultEntryV2) *TransactionHistoryResultEntryV2 { - return v -} - var _XdrTags_XdrAnon_LedgerHeaderHistoryEntry_Ext = map[int32]bool{ XdrToI32(0): true, } @@ -11666,21 +11333,21 @@ func (v *DiagnosticEvent) XdrRecurse(x XDR, name string) { } func XDR_DiagnosticEvent(v *DiagnosticEvent) *DiagnosticEvent { return v } -type _XdrVec_unbounded_DiagnosticEvent []DiagnosticEvent +type _XdrVec_unbounded_ContractEvent []ContractEvent -func (_XdrVec_unbounded_DiagnosticEvent) XdrBound() uint32 { +func (_XdrVec_unbounded_ContractEvent) 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_ContractEvent) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_ContractEvent length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_ContractEvent 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_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) { @@ -11697,94 +11364,23 @@ func (v *_XdrVec_unbounded_DiagnosticEvent) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]DiagnosticEvent, int(length), newcap) + nv := make([]ContractEvent, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_DiagnosticEvent) XdrMarshalN(x XDR, name string, n uint32) { +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_DiagnosticEvent(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + XDR_ContractEvent(&(*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) { - 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) } - -type XdrType_OperationDiagnosticEvents = *OperationDiagnosticEvents - -func (v *OperationDiagnosticEvents) XdrPointer() interface{} { return v } -func (OperationDiagnosticEvents) XdrTypeName() string { return "OperationDiagnosticEvents" } -func (v OperationDiagnosticEvents) XdrValue() interface{} { return v } -func (v *OperationDiagnosticEvents) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *OperationDiagnosticEvents) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sevents", name), (*_XdrVec_unbounded_DiagnosticEvent)(&v.Events)) -} -func XDR_OperationDiagnosticEvents(v *OperationDiagnosticEvents) *OperationDiagnosticEvents { return v } - -type _XdrVec_unbounded_ContractEvent []ContractEvent - -func (_XdrVec_unbounded_ContractEvent) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -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) - } -} -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) - } - nv := make([]ContractEvent, int(length), newcap) - copy(nv, *v) - *v = nv -} -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 (v *_XdrVec_unbounded_ContractEvent) XdrRecurse(x XDR, name string) { +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) @@ -11794,108 +11390,21 @@ func (v *_XdrVec_unbounded_ContractEvent) XdrPointer() interface{} { retur 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_OperationEvents = *OperationEvents - -func (v *OperationEvents) XdrPointer() interface{} { return v } -func (OperationEvents) XdrTypeName() string { return "OperationEvents" } -func (v OperationEvents) XdrValue() interface{} { return v } -func (v *OperationEvents) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *OperationEvents) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sevents", name), (*_XdrVec_unbounded_ContractEvent)(&v.Events)) -} -func XDR_OperationEvents(v *OperationEvents) *OperationEvents { return v } - -type _XdrVec_unbounded_OperationEvents []OperationEvents - -func (_XdrVec_unbounded_OperationEvents) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_unbounded_OperationEvents) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_OperationEvents length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_OperationEvents length %d exceeds max int", length) - } -} -func (v _XdrVec_unbounded_OperationEvents) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_OperationEvents) 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([]OperationEvents, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_unbounded_OperationEvents) 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_OperationEvents(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_unbounded_OperationEvents) 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_OperationEvents) XdrTypeName() string { return "OperationEvents<>" } -func (v *_XdrVec_unbounded_OperationEvents) XdrPointer() interface{} { return (*[]OperationEvents)(v) } -func (v _XdrVec_unbounded_OperationEvents) XdrValue() interface{} { return ([]OperationEvents)(v) } -func (v *_XdrVec_unbounded_OperationEvents) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type _XdrArray_3_Hash [3]Hash - -func (_XdrArray_3_Hash) XdrArraySize() uint32 { - const bound uint32 = 3 // Force error if not const or doesn't fit - return bound -} -func (v *_XdrArray_3_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 (v *_XdrArray_3_Hash) XdrPointer() interface{} { return (*[3]Hash)(v) } -func (_XdrArray_3_Hash) XdrTypeName() string { return "Hash[]" } -func (v *_XdrArray_3_Hash) XdrValue() interface{} { return v[:] } -func (v *_XdrArray_3_Hash) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type _XdrVec_unbounded_OperationDiagnosticEvents []OperationDiagnosticEvents +type _XdrVec_unbounded_DiagnosticEvent []DiagnosticEvent -func (_XdrVec_unbounded_OperationDiagnosticEvents) XdrBound() uint32 { +func (_XdrVec_unbounded_DiagnosticEvent) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_OperationDiagnosticEvents) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_DiagnosticEvent) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_OperationDiagnosticEvents length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_OperationDiagnosticEvents length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_DiagnosticEvent length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_OperationDiagnosticEvents) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_OperationDiagnosticEvents) 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) { @@ -11912,39 +11421,31 @@ func (v *_XdrVec_unbounded_OperationDiagnosticEvents) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]OperationDiagnosticEvents, int(length), newcap) + nv := make([]DiagnosticEvent, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_OperationDiagnosticEvents) 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_OperationDiagnosticEvents(&(*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_OperationDiagnosticEvents) 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_OperationDiagnosticEvents) XdrTypeName() string { - return "OperationDiagnosticEvents<>" -} -func (v *_XdrVec_unbounded_OperationDiagnosticEvents) XdrPointer() interface{} { - return (*[]OperationDiagnosticEvents)(v) -} -func (v _XdrVec_unbounded_OperationDiagnosticEvents) XdrValue() interface{} { - return ([]OperationDiagnosticEvents)(v) -} -func (v *_XdrVec_unbounded_OperationDiagnosticEvents) 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_TransactionMetaV3 = *TransactionMetaV3 @@ -11959,13 +11460,31 @@ func (v *TransactionMetaV3) XdrRecurse(x XDR, name string) { 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("%sevents", name), (*_XdrVec_unbounded_OperationEvents)(&v.Events)) - x.Marshal(x.Sprintf("%stxResult", name), XDR_TransactionResult(&v.TxResult)) - x.Marshal(x.Sprintf("%shashes", name), (*_XdrArray_3_Hash)(&v.Hashes)) - x.Marshal(x.Sprintf("%sdiagnosticEvents", name), (*_XdrVec_unbounded_OperationDiagnosticEvents)(&v.DiagnosticEvents)) + 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_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, @@ -12121,22 +11640,6 @@ func (v *TransactionResultMeta) XdrRecurse(x XDR, name string) { } func XDR_TransactionResultMeta(v *TransactionResultMeta) *TransactionResultMeta { return v } -type XdrType_TransactionResultMetaV2 = *TransactionResultMetaV2 - -func (v *TransactionResultMetaV2) XdrPointer() interface{} { return v } -func (TransactionResultMetaV2) XdrTypeName() string { return "TransactionResultMetaV2" } -func (v TransactionResultMetaV2) XdrValue() interface{} { return v } -func (v *TransactionResultMetaV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *TransactionResultMetaV2) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%sresult", name), XDR_TransactionResultPairV2(&v.Result)) - x.Marshal(x.Sprintf("%sfeeProcessing", name), XDR_LedgerEntryChanges(&v.FeeProcessing)) - x.Marshal(x.Sprintf("%stxApplyProcessing", name), XDR_TransactionMeta(&v.TxApplyProcessing)) -} -func XDR_TransactionResultMetaV2(v *TransactionResultMetaV2) *TransactionResultMetaV2 { return v } - type XdrType_UpgradeEntryMeta = *UpgradeEntryMeta func (v *UpgradeEntryMeta) XdrPointer() interface{} { return v } @@ -12365,93 +11868,9 @@ func (v *LedgerCloseMetaV1) XdrRecurse(x XDR, name string) { } func XDR_LedgerCloseMetaV1(v *LedgerCloseMetaV1) *LedgerCloseMetaV1 { return v } -type _XdrVec_unbounded_TransactionResultMetaV2 []TransactionResultMetaV2 - -func (_XdrVec_unbounded_TransactionResultMetaV2) XdrBound() uint32 { - const bound uint32 = 4294967295 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_unbounded_TransactionResultMetaV2) XdrCheckLen(length uint32) { - if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_TransactionResultMetaV2 length %d exceeds bound 4294967295", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_TransactionResultMetaV2 length %d exceeds max int", length) - } -} -func (v _XdrVec_unbounded_TransactionResultMetaV2) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_TransactionResultMetaV2) 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([]TransactionResultMetaV2, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_unbounded_TransactionResultMetaV2) 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_TransactionResultMetaV2(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_unbounded_TransactionResultMetaV2) 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_TransactionResultMetaV2) XdrTypeName() string { - return "TransactionResultMetaV2<>" -} -func (v *_XdrVec_unbounded_TransactionResultMetaV2) XdrPointer() interface{} { - return (*[]TransactionResultMetaV2)(v) -} -func (v _XdrVec_unbounded_TransactionResultMetaV2) XdrValue() interface{} { - return ([]TransactionResultMetaV2)(v) -} -func (v *_XdrVec_unbounded_TransactionResultMetaV2) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} - -type XdrType_LedgerCloseMetaV2 = *LedgerCloseMetaV2 - -func (v *LedgerCloseMetaV2) XdrPointer() interface{} { return v } -func (LedgerCloseMetaV2) XdrTypeName() string { return "LedgerCloseMetaV2" } -func (v LedgerCloseMetaV2) XdrValue() interface{} { return v } -func (v *LedgerCloseMetaV2) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *LedgerCloseMetaV2) 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_GeneralizedTransactionSet(&v.TxSet)) - x.Marshal(x.Sprintf("%stxProcessing", name), (*_XdrVec_unbounded_TransactionResultMetaV2)(&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_LedgerCloseMetaV2(v *LedgerCloseMetaV2) *LedgerCloseMetaV2 { return v } - var _XdrTags_LedgerCloseMeta = map[int32]bool{ XdrToI32(0): true, XdrToI32(1): true, - XdrToI32(2): true, } func (_ LedgerCloseMeta) XdrValidTags() map[int32]bool { @@ -12487,24 +11906,9 @@ func (u *LedgerCloseMeta) V1() *LedgerCloseMetaV1 { return nil } } -func (u *LedgerCloseMeta) V2() *LedgerCloseMetaV2 { - switch u.V { - case 2: - if v, ok := u._u.(*LedgerCloseMetaV2); ok { - return v - } else { - var zero LedgerCloseMetaV2 - u._u = &zero - return &zero - } - default: - XdrPanic("LedgerCloseMeta.V2 accessed when V == %v", u.V) - return nil - } -} func (u LedgerCloseMeta) XdrValid() bool { switch u.V { - case 0, 1, 2: + case 0, 1: return true } return false @@ -12521,8 +11925,6 @@ func (u *LedgerCloseMeta) XdrUnionBody() XdrType { return XDR_LedgerCloseMetaV0(u.V0()) case 1: return XDR_LedgerCloseMetaV1(u.V1()) - case 2: - return XDR_LedgerCloseMetaV2(u.V2()) } return nil } @@ -12532,8 +11934,6 @@ func (u *LedgerCloseMeta) XdrUnionBodyName() string { return "V0" case 1: return "V1" - case 2: - return "V2" } return "" } @@ -12556,9 +11956,6 @@ func (u *LedgerCloseMeta) XdrRecurse(x XDR, name string) { case 1: x.Marshal(x.Sprintf("%sv1", name), XDR_LedgerCloseMetaV1(u.V1())) return - case 2: - x.Marshal(x.Sprintf("%sv2", name), XDR_LedgerCloseMetaV2(u.V2())) - return } XdrPanic("invalid V (%v) in LedgerCloseMeta", u.V) } @@ -12656,6 +12053,21 @@ func (v *SendMore) XdrRecurse(x XDR, name string) { } func XDR_SendMore(v *SendMore) *SendMore { return v } +type XdrType_SendMoreExtended = *SendMoreExtended + +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("%snumMessages", name), XDR_Uint32(&v.NumMessages)) + x.Marshal(x.Sprintf("%snumBytes", name), XDR_Uint32(&v.NumBytes)) +} +func XDR_SendMoreExtended(v *SendMoreExtended) *SendMoreExtended { return v } + type XdrType_AuthCert = *AuthCert func (v *AuthCert) XdrPointer() interface{} { return v } @@ -12896,6 +12308,7 @@ var _XdrNames_MessageType = map[int32]string{ 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", } @@ -12917,6 +12330,7 @@ var _XdrValues_MessageType = map[string]int32{ "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), } @@ -13556,6 +12970,7 @@ var _XdrTags_StellarMessage = map[int32]bool{ 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, } @@ -13805,6 +13220,21 @@ func (u *StellarMessage) SendMoreMessage() *SendMore { return nil } } +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 (u *StellarMessage) FloodAdvert() *FloodAdvert { switch u.Type { case FLOOD_ADVERT: @@ -13837,7 +13267,7 @@ func (u *StellarMessage) FloodDemand() *FloodDemand { } 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, GET_SCP_QUORUMSET, SCP_QUORUMSET, SCP_MESSAGE, GET_SCP_STATE, SEND_MORE, FLOOD_ADVERT, FLOOD_DEMAND: + case ERROR_MSG, HELLO, AUTH, DONT_HAVE, GET_PEERS, PEERS, GET_TX_SET, TX_SET, GENERALIZED_TX_SET, TRANSACTION, SURVEY_REQUEST, SURVEY_RESPONSE, GET_SCP_QUORUMSET, SCP_QUORUMSET, SCP_MESSAGE, GET_SCP_STATE, SEND_MORE, SEND_MORE_EXTENDED, FLOOD_ADVERT, FLOOD_DEMAND: return true } return false @@ -13884,6 +13314,8 @@ func (u *StellarMessage) XdrUnionBody() XdrType { 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: @@ -13927,6 +13359,8 @@ func (u *StellarMessage) XdrUnionBodyName() string { return "GetSCPLedgerSeq" case SEND_MORE: return "SendMoreMessage" + case SEND_MORE_EXTENDED: + return "SendMoreExtendedMessage" case FLOOD_ADVERT: return "FloodAdvert" case FLOOD_DEMAND: @@ -13997,6 +13431,9 @@ func (u *StellarMessage) XdrRecurse(x XDR, name string) { 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 @@ -15394,174 +14831,96 @@ type XdrType_HostFunctionType = *HostFunctionType func XDR_HostFunctionType(v *HostFunctionType) *HostFunctionType { return v } -var _XdrNames_ContractIDType = map[int32]string{ - int32(CONTRACT_ID_FROM_SOURCE_ACCOUNT): "CONTRACT_ID_FROM_SOURCE_ACCOUNT", - int32(CONTRACT_ID_FROM_ED25519_PUBLIC_KEY): "CONTRACT_ID_FROM_ED25519_PUBLIC_KEY", - int32(CONTRACT_ID_FROM_ASSET): "CONTRACT_ID_FROM_ASSET", +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_ContractIDType = map[string]int32{ - "CONTRACT_ID_FROM_SOURCE_ACCOUNT": int32(CONTRACT_ID_FROM_SOURCE_ACCOUNT), - "CONTRACT_ID_FROM_ED25519_PUBLIC_KEY": int32(CONTRACT_ID_FROM_ED25519_PUBLIC_KEY), - "CONTRACT_ID_FROM_ASSET": int32(CONTRACT_ID_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 (ContractIDType) XdrEnumNames() map[int32]string { - return _XdrNames_ContractIDType +func (ContractIDPreimageType) XdrEnumNames() map[int32]string { + return _XdrNames_ContractIDPreimageType } -func (v ContractIDType) String() string { - if s, ok := _XdrNames_ContractIDType[int32(v)]; ok { +func (v ContractIDPreimageType) String() string { + if s, ok := _XdrNames_ContractIDPreimageType[int32(v)]; ok { return s } - return fmt.Sprintf("ContractIDType#%d", v) + return fmt.Sprintf("ContractIDPreimageType#%d", v) } -func (v *ContractIDType) Scan(ss fmt.ScanState, _ rune) error { +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_ContractIDType[stok]; ok { - *v = ContractIDType(val) + if val, ok := _XdrValues_ContractIDPreimageType[stok]; ok { + *v = ContractIDPreimageType(val) return nil - } else if stok == "ContractIDType" { + } 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 ContractIDType.", stok)) + return XdrError(fmt.Sprintf("%s is not a valid ContractIDPreimageType.", stok)) } } -func (v ContractIDType) GetU32() uint32 { return uint32(v) } -func (v *ContractIDType) SetU32(n uint32) { *v = ContractIDType(n) } -func (v *ContractIDType) XdrPointer() interface{} { return v } -func (ContractIDType) XdrTypeName() string { return "ContractIDType" } -func (v ContractIDType) XdrValue() interface{} { return v } -func (v *ContractIDType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +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 -type XdrType_ContractIDType = *ContractIDType +func XDR_ContractIDPreimageType(v *ContractIDPreimageType) *ContractIDPreimageType { return v } -func XDR_ContractIDType(v *ContractIDType) *ContractIDType { return v } +type XdrType_XdrAnon_ContractIDPreimage_FromAddress = *XdrAnon_ContractIDPreimage_FromAddress -var _XdrNames_ContractIDPublicKeyType = map[int32]string{ - int32(CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT): "CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT", - int32(CONTRACT_ID_PUBLIC_KEY_ED25519): "CONTRACT_ID_PUBLIC_KEY_ED25519", +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)) } -var _XdrValues_ContractIDPublicKeyType = map[string]int32{ - "CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT": int32(CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT), - "CONTRACT_ID_PUBLIC_KEY_ED25519": int32(CONTRACT_ID_PUBLIC_KEY_ED25519), +func XDR_XdrAnon_ContractIDPreimage_FromAddress(v *XdrAnon_ContractIDPreimage_FromAddress) *XdrAnon_ContractIDPreimage_FromAddress { + return v } -func (ContractIDPublicKeyType) XdrEnumNames() map[int32]string { - return _XdrNames_ContractIDPublicKeyType +var _XdrTags_ContractIDPreimage = map[int32]bool{ + XdrToI32(CONTRACT_ID_PREIMAGE_FROM_ADDRESS): true, + XdrToI32(CONTRACT_ID_PREIMAGE_FROM_ASSET): true, } -func (v ContractIDPublicKeyType) String() string { - if s, ok := _XdrNames_ContractIDPublicKeyType[int32(v)]; ok { - return s - } - return fmt.Sprintf("ContractIDPublicKeyType#%d", v) + +func (_ ContractIDPreimage) XdrValidTags() map[int32]bool { + return _XdrTags_ContractIDPreimage } -func (v *ContractIDPublicKeyType) 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_ContractIDPublicKeyType[stok]; ok { - *v = ContractIDPublicKeyType(val) - return nil - } else if stok == "ContractIDPublicKeyType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid ContractIDPublicKeyType.", stok)) - } -} -func (v ContractIDPublicKeyType) GetU32() uint32 { return uint32(v) } -func (v *ContractIDPublicKeyType) SetU32(n uint32) { *v = ContractIDPublicKeyType(n) } -func (v *ContractIDPublicKeyType) XdrPointer() interface{} { return v } -func (ContractIDPublicKeyType) XdrTypeName() string { return "ContractIDPublicKeyType" } -func (v ContractIDPublicKeyType) XdrValue() interface{} { return v } -func (v *ContractIDPublicKeyType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_ContractIDPublicKeyType = *ContractIDPublicKeyType - -func XDR_ContractIDPublicKeyType(v *ContractIDPublicKeyType) *ContractIDPublicKeyType { return v } - -type XdrType_UploadContractWasmArgs = *UploadContractWasmArgs - -func (v *UploadContractWasmArgs) XdrPointer() interface{} { return v } -func (UploadContractWasmArgs) XdrTypeName() string { return "UploadContractWasmArgs" } -func (v UploadContractWasmArgs) XdrValue() interface{} { return v } -func (v *UploadContractWasmArgs) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *UploadContractWasmArgs) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%scode", name), XdrVecOpaque{&v.Code, SCVAL_LIMIT}) -} -func XDR_UploadContractWasmArgs(v *UploadContractWasmArgs) *UploadContractWasmArgs { return v } - -type XdrType_XdrAnon_ContractID_FromEd25519PublicKey = *XdrAnon_ContractID_FromEd25519PublicKey - -func (v *XdrAnon_ContractID_FromEd25519PublicKey) XdrPointer() interface{} { return v } -func (XdrAnon_ContractID_FromEd25519PublicKey) XdrTypeName() string { - return "XdrAnon_ContractID_FromEd25519PublicKey" -} -func (v XdrAnon_ContractID_FromEd25519PublicKey) XdrValue() interface{} { return v } -func (v *XdrAnon_ContractID_FromEd25519PublicKey) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_ContractID_FromEd25519PublicKey) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - x.Marshal(x.Sprintf("%skey", name), XDR_Uint256(&v.Key)) - x.Marshal(x.Sprintf("%ssignature", name), XDR_Signature(&v.Signature)) - x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(&v.Salt)) -} -func XDR_XdrAnon_ContractID_FromEd25519PublicKey(v *XdrAnon_ContractID_FromEd25519PublicKey) *XdrAnon_ContractID_FromEd25519PublicKey { - return v -} - -var _XdrTags_ContractID = map[int32]bool{ - XdrToI32(CONTRACT_ID_FROM_SOURCE_ACCOUNT): true, - XdrToI32(CONTRACT_ID_FROM_ED25519_PUBLIC_KEY): true, - XdrToI32(CONTRACT_ID_FROM_ASSET): true, -} - -func (_ ContractID) XdrValidTags() map[int32]bool { - return _XdrTags_ContractID -} -func (u *ContractID) Salt() *Uint256 { - switch u.Type { - case CONTRACT_ID_FROM_SOURCE_ACCOUNT: - if v, ok := u._u.(*Uint256); ok { - return v - } else { - var zero Uint256 - u._u = &zero - return &zero - } - default: - XdrPanic("ContractID.Salt accessed when Type == %v", u.Type) - return nil - } -} -func (u *ContractID) FromEd25519PublicKey() *XdrAnon_ContractID_FromEd25519PublicKey { +func (u *ContractIDPreimage) FromAddress() *XdrAnon_ContractIDPreimage_FromAddress { switch u.Type { - case CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: - if v, ok := u._u.(*XdrAnon_ContractID_FromEd25519PublicKey); ok { + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + if v, ok := u._u.(*XdrAnon_ContractIDPreimage_FromAddress); ok { return v } else { - var zero XdrAnon_ContractID_FromEd25519PublicKey + var zero XdrAnon_ContractIDPreimage_FromAddress u._u = &zero return &zero } default: - XdrPanic("ContractID.FromEd25519PublicKey accessed when Type == %v", u.Type) + XdrPanic("ContractIDPreimage.FromAddress accessed when Type == %v", u.Type) return nil } } -func (u *ContractID) Asset() *Asset { +func (u *ContractIDPreimage) FromAsset() *Asset { switch u.Type { - case CONTRACT_ID_FROM_ASSET: + case CONTRACT_ID_PREIMAGE_FROM_ASSET: if v, ok := u._u.(*Asset); ok { return v } else { @@ -15570,71 +14929,64 @@ func (u *ContractID) Asset() *Asset { return &zero } default: - XdrPanic("ContractID.Asset accessed when Type == %v", u.Type) + XdrPanic("ContractIDPreimage.FromAsset accessed when Type == %v", u.Type) return nil } } -func (u ContractID) XdrValid() bool { +func (u ContractIDPreimage) XdrValid() bool { switch u.Type { - case CONTRACT_ID_FROM_SOURCE_ACCOUNT, CONTRACT_ID_FROM_ED25519_PUBLIC_KEY, CONTRACT_ID_FROM_ASSET: + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS, CONTRACT_ID_PREIMAGE_FROM_ASSET: return true } return false } -func (u *ContractID) XdrUnionTag() XdrNum32 { - return XDR_ContractIDType(&u.Type) +func (u *ContractIDPreimage) XdrUnionTag() XdrNum32 { + return XDR_ContractIDPreimageType(&u.Type) } -func (u *ContractID) XdrUnionTagName() string { +func (u *ContractIDPreimage) XdrUnionTagName() string { return "Type" } -func (u *ContractID) XdrUnionBody() XdrType { +func (u *ContractIDPreimage) XdrUnionBody() XdrType { switch u.Type { - case CONTRACT_ID_FROM_SOURCE_ACCOUNT: - return XDR_Uint256(u.Salt()) - case CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: - return XDR_XdrAnon_ContractID_FromEd25519PublicKey(u.FromEd25519PublicKey()) - case CONTRACT_ID_FROM_ASSET: - return XDR_Asset(u.Asset()) + 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 *ContractID) XdrUnionBodyName() string { +func (u *ContractIDPreimage) XdrUnionBodyName() string { switch u.Type { - case CONTRACT_ID_FROM_SOURCE_ACCOUNT: - return "Salt" - case CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: - return "FromEd25519PublicKey" - case CONTRACT_ID_FROM_ASSET: - return "Asset" + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + return "FromAddress" + case CONTRACT_ID_PREIMAGE_FROM_ASSET: + return "FromAsset" } return "" } -type XdrType_ContractID = *ContractID +type XdrType_ContractIDPreimage = *ContractIDPreimage -func (v *ContractID) XdrPointer() interface{} { return v } -func (ContractID) XdrTypeName() string { return "ContractID" } -func (v ContractID) XdrValue() interface{} { return v } -func (v *ContractID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *ContractID) XdrRecurse(x XDR, name string) { +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_ContractIDType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) + XDR_ContractIDPreimageType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case CONTRACT_ID_FROM_SOURCE_ACCOUNT: - x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(u.Salt())) - return - case CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: - x.Marshal(x.Sprintf("%sfromEd25519PublicKey", name), XDR_XdrAnon_ContractID_FromEd25519PublicKey(u.FromEd25519PublicKey())) + case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + x.Marshal(x.Sprintf("%sfromAddress", name), XDR_XdrAnon_ContractIDPreimage_FromAddress(u.FromAddress())) return - case CONTRACT_ID_FROM_ASSET: - x.Marshal(x.Sprintf("%sasset", name), XDR_Asset(u.Asset())) + case CONTRACT_ID_PREIMAGE_FROM_ASSET: + x.Marshal(x.Sprintf("%sfromAsset", name), XDR_Asset(u.FromAsset())) return } - XdrPanic("invalid Type (%v) in ContractID", u.Type) + XdrPanic("invalid Type (%v) in ContractIDPreimage", u.Type) } -func XDR_ContractID(v *ContractID) *ContractID { return v } +func XDR_ContractIDPreimage(v *ContractIDPreimage) *ContractIDPreimage { return v } type XdrType_CreateContractArgs = *CreateContractArgs @@ -15646,21 +14998,21 @@ func (v *CreateContractArgs) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - x.Marshal(x.Sprintf("%scontractID", name), XDR_ContractID(&v.ContractID)) + x.Marshal(x.Sprintf("%scontractIDPreimage", name), XDR_ContractIDPreimage(&v.ContractIDPreimage)) x.Marshal(x.Sprintf("%sexecutable", name), XDR_SCContractExecutable(&v.Executable)) } func XDR_CreateContractArgs(v *CreateContractArgs) *CreateContractArgs { return v } -var _XdrTags_HostFunctionArgs = map[int32]bool{ +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, } -func (_ HostFunctionArgs) XdrValidTags() map[int32]bool { - return _XdrTags_HostFunctionArgs +func (_ HostFunction) XdrValidTags() map[int32]bool { + return _XdrTags_HostFunction } -func (u *HostFunctionArgs) InvokeContract() *SCVec { +func (u *HostFunction) InvokeContract() *SCVec { switch u.Type { case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: if v, ok := u._u.(*SCVec); ok { @@ -15671,11 +15023,11 @@ func (u *HostFunctionArgs) InvokeContract() *SCVec { return &zero } default: - XdrPanic("HostFunctionArgs.InvokeContract accessed when Type == %v", u.Type) + XdrPanic("HostFunction.InvokeContract accessed when Type == %v", u.Type) return nil } } -func (u *HostFunctionArgs) CreateContract() *CreateContractArgs { +func (u *HostFunction) CreateContract() *CreateContractArgs { switch u.Type { case HOST_FUNCTION_TYPE_CREATE_CONTRACT: if v, ok := u._u.(*CreateContractArgs); ok { @@ -15686,68 +15038,68 @@ func (u *HostFunctionArgs) CreateContract() *CreateContractArgs { return &zero } default: - XdrPanic("HostFunctionArgs.CreateContract accessed when Type == %v", u.Type) + XdrPanic("HostFunction.CreateContract accessed when Type == %v", u.Type) return nil } } -func (u *HostFunctionArgs) UploadContractWasm() *UploadContractWasmArgs { +func (u *HostFunction) Wasm() *[]byte { switch u.Type { case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - if v, ok := u._u.(*UploadContractWasmArgs); ok { + if v, ok := u._u.(*[]byte); ok { return v } else { - var zero UploadContractWasmArgs + var zero []byte u._u = &zero return &zero } default: - XdrPanic("HostFunctionArgs.UploadContractWasm accessed when Type == %v", u.Type) + XdrPanic("HostFunction.Wasm accessed when Type == %v", u.Type) return nil } } -func (u HostFunctionArgs) XdrValid() bool { +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: return true } return false } -func (u *HostFunctionArgs) XdrUnionTag() XdrNum32 { +func (u *HostFunction) XdrUnionTag() XdrNum32 { return XDR_HostFunctionType(&u.Type) } -func (u *HostFunctionArgs) XdrUnionTagName() string { +func (u *HostFunction) XdrUnionTagName() string { return "Type" } -func (u *HostFunctionArgs) XdrUnionBody() XdrType { +func (u *HostFunction) XdrUnionBody() XdrType { switch u.Type { case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: return XDR_SCVec(u.InvokeContract()) case HOST_FUNCTION_TYPE_CREATE_CONTRACT: return XDR_CreateContractArgs(u.CreateContract()) case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - return XDR_UploadContractWasmArgs(u.UploadContractWasm()) + return XdrVecOpaque{u.Wasm(), 0xffffffff} } return nil } -func (u *HostFunctionArgs) XdrUnionBodyName() string { +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 "UploadContractWasm" + return "Wasm" } return "" } -type XdrType_HostFunctionArgs = *HostFunctionArgs +type XdrType_HostFunction = *HostFunction -func (v *HostFunctionArgs) XdrPointer() interface{} { return v } -func (HostFunctionArgs) XdrTypeName() string { return "HostFunctionArgs" } -func (v HostFunctionArgs) XdrValue() interface{} { return v } -func (v *HostFunctionArgs) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *HostFunctionArgs) XdrRecurse(x XDR, name string) { +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) } @@ -15760,28 +15112,188 @@ func (u *HostFunctionArgs) XdrRecurse(x XDR, name string) { x.Marshal(x.Sprintf("%screateContract", name), XDR_CreateContractArgs(u.CreateContract())) return case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - x.Marshal(x.Sprintf("%suploadContractWasm", name), XDR_UploadContractWasmArgs(u.UploadContractWasm())) + x.Marshal(x.Sprintf("%swasm", name), XdrVecOpaque{u.Wasm(), 0xffffffff}) + 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", +} +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), +} + +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 +} + +type XdrType_SorobanAuthorizedContractFunction = *SorobanAuthorizedContractFunction + +func (v *SorobanAuthorizedContractFunction) XdrPointer() interface{} { return v } +func (SorobanAuthorizedContractFunction) XdrTypeName() string { + return "SorobanAuthorizedContractFunction" +} +func (v SorobanAuthorizedContractFunction) XdrValue() interface{} { return v } +func (v *SorobanAuthorizedContractFunction) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SorobanAuthorizedContractFunction) 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), XDR_SCVec(&v.Args)) +} +func XDR_SorobanAuthorizedContractFunction(v *SorobanAuthorizedContractFunction) *SorobanAuthorizedContractFunction { + 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, +} + +func (_ SorobanAuthorizedFunction) XdrValidTags() map[int32]bool { + return _XdrTags_SorobanAuthorizedFunction +} +func (u *SorobanAuthorizedFunction) ContractFn() *SorobanAuthorizedContractFunction { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: + if v, ok := u._u.(*SorobanAuthorizedContractFunction); ok { + return v + } else { + var zero SorobanAuthorizedContractFunction + 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) XdrValid() bool { + switch u.Type { + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN, SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_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_SorobanAuthorizedContractFunction(u.ContractFn()) + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + return XDR_CreateContractArgs(u.CreateContractHostFn()) + } + 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" + } + 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_SorobanAuthorizedContractFunction(u.ContractFn())) + return + case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + x.Marshal(x.Sprintf("%screateContractHostFn", name), XDR_CreateContractArgs(u.CreateContractHostFn())) return } - XdrPanic("invalid Type (%v) in HostFunctionArgs", u.Type) + XdrPanic("invalid Type (%v) in SorobanAuthorizedFunction", u.Type) } -func XDR_HostFunctionArgs(v *HostFunctionArgs) *HostFunctionArgs { return v } +func XDR_SorobanAuthorizedFunction(v *SorobanAuthorizedFunction) *SorobanAuthorizedFunction { return v } -type _XdrVec_unbounded_AuthorizedInvocation []AuthorizedInvocation +type _XdrVec_unbounded_SorobanAuthorizedInvocation []SorobanAuthorizedInvocation -func (_XdrVec_unbounded_AuthorizedInvocation) XdrBound() uint32 { +func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_AuthorizedInvocation) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_AuthorizedInvocation length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_SorobanAuthorizedInvocation length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_AuthorizedInvocation length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_SorobanAuthorizedInvocation length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_AuthorizedInvocation) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_AuthorizedInvocation) SetVecLen(length uint32) { +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) { @@ -15798,172 +15310,225 @@ func (v *_XdrVec_unbounded_AuthorizedInvocation) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]AuthorizedInvocation, int(length), newcap) + nv := make([]SorobanAuthorizedInvocation, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_AuthorizedInvocation) XdrMarshalN(x XDR, name string, n uint32) { +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_AuthorizedInvocation(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + 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_AuthorizedInvocation) XdrRecurse(x XDR, name string) { +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_AuthorizedInvocation) XdrTypeName() string { return "AuthorizedInvocation<>" } -func (v *_XdrVec_unbounded_AuthorizedInvocation) XdrPointer() interface{} { - return (*[]AuthorizedInvocation)(v) +func (_XdrVec_unbounded_SorobanAuthorizedInvocation) XdrTypeName() string { + return "SorobanAuthorizedInvocation<>" } -func (v _XdrVec_unbounded_AuthorizedInvocation) XdrValue() interface{} { - return ([]AuthorizedInvocation)(v) +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) } -func (v *_XdrVec_unbounded_AuthorizedInvocation) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -type XdrType_AuthorizedInvocation = *AuthorizedInvocation +type XdrType_SorobanAuthorizedInvocation = *SorobanAuthorizedInvocation -func (v *AuthorizedInvocation) XdrPointer() interface{} { return v } -func (AuthorizedInvocation) XdrTypeName() string { return "AuthorizedInvocation" } -func (v AuthorizedInvocation) XdrValue() interface{} { return v } -func (v *AuthorizedInvocation) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *AuthorizedInvocation) XdrRecurse(x XDR, name string) { +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("%scontractID", name), XDR_Hash(&v.ContractID)) - x.Marshal(x.Sprintf("%sfunctionName", name), XDR_SCSymbol(&v.FunctionName)) - x.Marshal(x.Sprintf("%sargs", name), XDR_SCVec(&v.Args)) - x.Marshal(x.Sprintf("%ssubInvocations", name), (*_XdrVec_unbounded_AuthorizedInvocation)(&v.SubInvocations)) + 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 } -func XDR_AuthorizedInvocation(v *AuthorizedInvocation) *AuthorizedInvocation { return v } -type XdrType_AddressWithNonce = *AddressWithNonce +type XdrType_SorobanAddressCredentials = *SorobanAddressCredentials -func (v *AddressWithNonce) XdrPointer() interface{} { return v } -func (AddressWithNonce) XdrTypeName() string { return "AddressWithNonce" } -func (v AddressWithNonce) XdrValue() interface{} { return v } -func (v *AddressWithNonce) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *AddressWithNonce) XdrRecurse(x XDR, name string) { +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_Uint64(&v.Nonce)) + x.Marshal(x.Sprintf("%ssignatureArgs", name), XDR_SCVec(&v.SignatureArgs)) } -func XDR_AddressWithNonce(v *AddressWithNonce) *AddressWithNonce { return v } +func XDR_SorobanAddressCredentials(v *SorobanAddressCredentials) *SorobanAddressCredentials { return v } -type _XdrPtr_AddressWithNonce struct { - p **AddressWithNonce +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), } -type _ptrflag_AddressWithNonce _XdrPtr_AddressWithNonce -func (v _ptrflag_AddressWithNonce) String() string { - if *v.p == nil { - return "nil" +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 "non-nil" + return fmt.Sprintf("SorobanCredentialsType#%d", v) } -func (v _ptrflag_AddressWithNonce) 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 { +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)) } - switch string(tok) { - case "nil": - v.SetU32(0) - case "non-nil": - v.SetU32(1) - default: - return XdrError("AddressWithNonce flag should be \"nil\" or \"non-nil\"") - } - return nil } -func (v _ptrflag_AddressWithNonce) GetU32() uint32 { - if *v.p == nil { - return 0 - } - return 1 +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 (v _ptrflag_AddressWithNonce) SetU32(nv uint32) { - switch nv { - case 0: - *v.p = nil - case 1: - if *v.p == nil { - *v.p = new(AddressWithNonce) + +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("*AddressWithNonce present flag value %d should be 0 or 1", nv) + XdrPanic("SorobanCredentials.Address accessed when Type == %v", u.Type) + return nil } } -func (_ptrflag_AddressWithNonce) XdrTypeName() string { return "AddressWithNonce?" } -func (v _ptrflag_AddressWithNonce) XdrPointer() interface{} { return nil } -func (v _ptrflag_AddressWithNonce) XdrValue() interface{} { return v.GetU32() != 0 } -func (v _ptrflag_AddressWithNonce) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _ptrflag_AddressWithNonce) XdrBound() uint32 { return 1 } -func (v _XdrPtr_AddressWithNonce) GetPresent() bool { return *v.p != nil } -func (v _XdrPtr_AddressWithNonce) SetPresent(present bool) { - if !present { - *v.p = nil - } else if *v.p == nil { - *v.p = new(AddressWithNonce) +func (u SorobanCredentials) XdrValid() bool { + switch u.Type { + case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT, SOROBAN_CREDENTIALS_ADDRESS: + return true } + return false } -func (v _XdrPtr_AddressWithNonce) XdrMarshalValue(x XDR, name string) { - if *v.p != nil { - XDR_AddressWithNonce(*v.p).XdrMarshal(x, name) +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 (v _XdrPtr_AddressWithNonce) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v _XdrPtr_AddressWithNonce) XdrRecurse(x XDR, name string) { - x.Marshal(name, _ptrflag_AddressWithNonce(v)) - v.XdrMarshalValue(x, name) +func (u *SorobanCredentials) XdrUnionBodyName() string { + switch u.Type { + case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: + return "" + case SOROBAN_CREDENTIALS_ADDRESS: + return "Address" + } + return "" } -func (_XdrPtr_AddressWithNonce) XdrTypeName() string { return "AddressWithNonce*" } -func (v _XdrPtr_AddressWithNonce) XdrPointer() interface{} { return v.p } -func (v _XdrPtr_AddressWithNonce) XdrValue() interface{} { return *v.p } -type XdrType_ContractAuth = *ContractAuth +type XdrType_SorobanCredentials = *SorobanCredentials -func (v *ContractAuth) XdrPointer() interface{} { return v } -func (ContractAuth) XdrTypeName() string { return "ContractAuth" } -func (v ContractAuth) XdrValue() interface{} { return v } -func (v *ContractAuth) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *ContractAuth) XdrRecurse(x XDR, name string) { +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) } - x.Marshal(x.Sprintf("%saddressWithNonce", name), _XdrPtr_AddressWithNonce{&v.AddressWithNonce}) - x.Marshal(x.Sprintf("%srootInvocation", name), XDR_AuthorizedInvocation(&v.RootInvocation)) - x.Marshal(x.Sprintf("%ssignatureArgs", name), XDR_SCVec(&v.SignatureArgs)) + 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_ContractAuth(v *ContractAuth) *ContractAuth { return v } +func XDR_SorobanAuthorizationEntry(v *SorobanAuthorizationEntry) *SorobanAuthorizationEntry { return v } -type _XdrVec_unbounded_ContractAuth []ContractAuth +type _XdrVec_unbounded_SorobanAuthorizationEntry []SorobanAuthorizationEntry -func (_XdrVec_unbounded_ContractAuth) XdrBound() uint32 { +func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrBound() uint32 { const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_unbounded_ContractAuth) XdrCheckLen(length uint32) { +func (_XdrVec_unbounded_SorobanAuthorizationEntry) XdrCheckLen(length uint32) { if length > uint32(4294967295) { - XdrPanic("_XdrVec_unbounded_ContractAuth length %d exceeds bound 4294967295", length) + XdrPanic("_XdrVec_unbounded_SorobanAuthorizationEntry length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_unbounded_ContractAuth length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_SorobanAuthorizationEntry length %d exceeds max int", length) } } -func (v _XdrVec_unbounded_ContractAuth) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_unbounded_ContractAuth) SetVecLen(length uint32) { +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) { @@ -15980,117 +15545,54 @@ func (v *_XdrVec_unbounded_ContractAuth) SetVecLen(length uint32) { } newcap = int(bound) } - nv := make([]ContractAuth, int(length), newcap) + nv := make([]SorobanAuthorizationEntry, int(length), newcap) copy(nv, *v) *v = nv } -func (v *_XdrVec_unbounded_ContractAuth) XdrMarshalN(x XDR, name string, n uint32) { +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_ContractAuth(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) + 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_ContractAuth) XdrRecurse(x XDR, name string) { +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_ContractAuth) XdrTypeName() string { return "ContractAuth<>" } -func (v *_XdrVec_unbounded_ContractAuth) XdrPointer() interface{} { return (*[]ContractAuth)(v) } -func (v _XdrVec_unbounded_ContractAuth) XdrValue() interface{} { return ([]ContractAuth)(v) } -func (v *_XdrVec_unbounded_ContractAuth) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +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_HostFunction = *HostFunction +type XdrType_InvokeHostFunctionOp = *InvokeHostFunctionOp -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 (v *HostFunction) XdrRecurse(x XDR, name string) { +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("%sargs", name), XDR_HostFunctionArgs(&v.Args)) - x.Marshal(x.Sprintf("%sauth", name), (*_XdrVec_unbounded_ContractAuth)(&v.Auth)) + x.Marshal(x.Sprintf("%shostFunction", name), XDR_HostFunction(&v.HostFunction)) + x.Marshal(x.Sprintf("%sauth", name), (*_XdrVec_unbounded_SorobanAuthorizationEntry)(&v.Auth)) } -func XDR_HostFunction(v *HostFunction) *HostFunction { return v } - -type _XdrVec_100_HostFunction []HostFunction - -func (_XdrVec_100_HostFunction) XdrBound() uint32 { - const bound uint32 = 100 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_100_HostFunction) XdrCheckLen(length uint32) { - if length > uint32(100) { - XdrPanic("_XdrVec_100_HostFunction length %d exceeds bound 100", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_100_HostFunction length %d exceeds max int", length) - } -} -func (v _XdrVec_100_HostFunction) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_100_HostFunction) 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([]HostFunction, int(length), newcap) - copy(nv, *v) - *v = nv -} -func (v *_XdrVec_100_HostFunction) 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_HostFunction(&(*v)[i]).XdrMarshal(x, x.Sprintf("%s[%d]", name, i)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_100_HostFunction) 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_HostFunction) XdrTypeName() string { return "HostFunction<>" } -func (v *_XdrVec_100_HostFunction) XdrPointer() interface{} { return (*[]HostFunction)(v) } -func (v _XdrVec_100_HostFunction) XdrValue() interface{} { return ([]HostFunction)(v) } -func (v *_XdrVec_100_HostFunction) 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("%sfunctions", name), (*_XdrVec_100_HostFunction)(&v.Functions)) -} -func XDR_InvokeHostFunctionOp(v *InvokeHostFunctionOp) *InvokeHostFunctionOp { return v } +func XDR_InvokeHostFunctionOp(v *InvokeHostFunctionOp) *InvokeHostFunctionOp { return v } var _XdrTags_XdrAnon_Operation_Body = map[int32]bool{ XdrToI32(CREATE_ACCOUNT): true, @@ -16810,26 +16312,6 @@ func XDR_XdrAnon_HashIDPreimage_RevokeID(v *XdrAnon_HashIDPreimage_RevokeID) *Xd return v } -type XdrType_XdrAnon_HashIDPreimage_Ed25519ContractID = *XdrAnon_HashIDPreimage_Ed25519ContractID - -func (v *XdrAnon_HashIDPreimage_Ed25519ContractID) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_Ed25519ContractID) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_Ed25519ContractID" -} -func (v XdrAnon_HashIDPreimage_Ed25519ContractID) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_Ed25519ContractID) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_HashIDPreimage_Ed25519ContractID) 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("%sed25519", name), XDR_Uint256(&v.Ed25519)) - x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(&v.Salt)) -} -func XDR_XdrAnon_HashIDPreimage_Ed25519ContractID(v *XdrAnon_HashIDPreimage_Ed25519ContractID) *XdrAnon_HashIDPreimage_Ed25519ContractID { - return v -} - type XdrType_XdrAnon_HashIDPreimage_ContractID = *XdrAnon_HashIDPreimage_ContractID func (v *XdrAnon_HashIDPreimage_ContractID) XdrPointer() interface{} { return v } @@ -16843,105 +16325,39 @@ func (v *XdrAnon_HashIDPreimage_ContractID) XdrRecurse(x XDR, name string) { name = x.Sprintf("%s.", name) } x.Marshal(x.Sprintf("%snetworkID", name), XDR_Hash(&v.NetworkID)) - x.Marshal(x.Sprintf("%scontractID", name), XDR_Hash(&v.ContractID)) - x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(&v.Salt)) + 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_FromAsset = *XdrAnon_HashIDPreimage_FromAsset - -func (v *XdrAnon_HashIDPreimage_FromAsset) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_FromAsset) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_FromAsset" -} -func (v XdrAnon_HashIDPreimage_FromAsset) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_FromAsset) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_HashIDPreimage_FromAsset) 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("%sasset", name), XDR_Asset(&v.Asset)) -} -func XDR_XdrAnon_HashIDPreimage_FromAsset(v *XdrAnon_HashIDPreimage_FromAsset) *XdrAnon_HashIDPreimage_FromAsset { - return v -} - -type XdrType_XdrAnon_HashIDPreimage_SourceAccountContractID = *XdrAnon_HashIDPreimage_SourceAccountContractID - -func (v *XdrAnon_HashIDPreimage_SourceAccountContractID) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_SourceAccountContractID) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_SourceAccountContractID" -} -func (v XdrAnon_HashIDPreimage_SourceAccountContractID) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_SourceAccountContractID) XdrMarshal(x XDR, name string) { - x.Marshal(name, v) -} -func (v *XdrAnon_HashIDPreimage_SourceAccountContractID) 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("%ssourceAccount", name), XDR_AccountID(&v.SourceAccount)) - x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(&v.Salt)) -} -func XDR_XdrAnon_HashIDPreimage_SourceAccountContractID(v *XdrAnon_HashIDPreimage_SourceAccountContractID) *XdrAnon_HashIDPreimage_SourceAccountContractID { - return v -} - -type XdrType_XdrAnon_HashIDPreimage_CreateContractArgs = *XdrAnon_HashIDPreimage_CreateContractArgs +type XdrType_XdrAnon_HashIDPreimage_SorobanAuthorization = *XdrAnon_HashIDPreimage_SorobanAuthorization -func (v *XdrAnon_HashIDPreimage_CreateContractArgs) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_CreateContractArgs) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_CreateContractArgs" +func (v *XdrAnon_HashIDPreimage_SorobanAuthorization) XdrPointer() interface{} { return v } +func (XdrAnon_HashIDPreimage_SorobanAuthorization) XdrTypeName() string { + return "XdrAnon_HashIDPreimage_SorobanAuthorization" } -func (v XdrAnon_HashIDPreimage_CreateContractArgs) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_CreateContractArgs) XdrMarshal(x XDR, name string) { +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_CreateContractArgs) 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("%sexecutable", name), XDR_SCContractExecutable(&v.Executable)) - x.Marshal(x.Sprintf("%ssalt", name), XDR_Uint256(&v.Salt)) -} -func XDR_XdrAnon_HashIDPreimage_CreateContractArgs(v *XdrAnon_HashIDPreimage_CreateContractArgs) *XdrAnon_HashIDPreimage_CreateContractArgs { - return v -} - -type XdrType_XdrAnon_HashIDPreimage_ContractAuth = *XdrAnon_HashIDPreimage_ContractAuth - -func (v *XdrAnon_HashIDPreimage_ContractAuth) XdrPointer() interface{} { return v } -func (XdrAnon_HashIDPreimage_ContractAuth) XdrTypeName() string { - return "XdrAnon_HashIDPreimage_ContractAuth" -} -func (v XdrAnon_HashIDPreimage_ContractAuth) XdrValue() interface{} { return v } -func (v *XdrAnon_HashIDPreimage_ContractAuth) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (v *XdrAnon_HashIDPreimage_ContractAuth) XdrRecurse(x XDR, name string) { +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_Uint64(&v.Nonce)) - x.Marshal(x.Sprintf("%sinvocation", name), XDR_AuthorizedInvocation(&v.Invocation)) + x.Marshal(x.Sprintf("%sinvocation", name), XDR_SorobanAuthorizedInvocation(&v.Invocation)) } -func XDR_XdrAnon_HashIDPreimage_ContractAuth(v *XdrAnon_HashIDPreimage_ContractAuth) *XdrAnon_HashIDPreimage_ContractAuth { +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_FROM_ED25519): true, - XdrToI32(ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT): true, - XdrToI32(ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET): true, - XdrToI32(ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT): true, - XdrToI32(ENVELOPE_TYPE_CREATE_CONTRACT_ARGS): true, - XdrToI32(ENVELOPE_TYPE_CONTRACT_AUTH): true, + 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 { @@ -16977,24 +16393,9 @@ func (u *HashIDPreimage) RevokeID() *XdrAnon_HashIDPreimage_RevokeID { return nil } } -func (u *HashIDPreimage) Ed25519ContractID() *XdrAnon_HashIDPreimage_Ed25519ContractID { - switch u.Type { - case ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_Ed25519ContractID); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_Ed25519ContractID - u._u = &zero - return &zero - } - default: - XdrPanic("HashIDPreimage.Ed25519ContractID accessed when Type == %v", u.Type) - return nil - } -} func (u *HashIDPreimage) ContractID() *XdrAnon_HashIDPreimage_ContractID { switch u.Type { - case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: + case ENVELOPE_TYPE_CONTRACT_ID: if v, ok := u._u.(*XdrAnon_HashIDPreimage_ContractID); ok { return v } else { @@ -17007,69 +16408,24 @@ func (u *HashIDPreimage) ContractID() *XdrAnon_HashIDPreimage_ContractID { return nil } } -func (u *HashIDPreimage) FromAsset() *XdrAnon_HashIDPreimage_FromAsset { - switch u.Type { - case ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_FromAsset); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_FromAsset - u._u = &zero - return &zero - } - default: - XdrPanic("HashIDPreimage.FromAsset accessed when Type == %v", u.Type) - return nil - } -} -func (u *HashIDPreimage) SourceAccountContractID() *XdrAnon_HashIDPreimage_SourceAccountContractID { - switch u.Type { - case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_SourceAccountContractID); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_SourceAccountContractID - u._u = &zero - return &zero - } - default: - XdrPanic("HashIDPreimage.SourceAccountContractID accessed when Type == %v", u.Type) - return nil - } -} -func (u *HashIDPreimage) CreateContractArgs() *XdrAnon_HashIDPreimage_CreateContractArgs { - switch u.Type { - case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_CreateContractArgs); ok { - return v - } else { - var zero XdrAnon_HashIDPreimage_CreateContractArgs - u._u = &zero - return &zero - } - default: - XdrPanic("HashIDPreimage.CreateContractArgs accessed when Type == %v", u.Type) - return nil - } -} -func (u *HashIDPreimage) ContractAuth() *XdrAnon_HashIDPreimage_ContractAuth { +func (u *HashIDPreimage) SorobanAuthorization() *XdrAnon_HashIDPreimage_SorobanAuthorization { switch u.Type { - case ENVELOPE_TYPE_CONTRACT_AUTH: - if v, ok := u._u.(*XdrAnon_HashIDPreimage_ContractAuth); ok { + case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + if v, ok := u._u.(*XdrAnon_HashIDPreimage_SorobanAuthorization); ok { return v } else { - var zero XdrAnon_HashIDPreimage_ContractAuth + var zero XdrAnon_HashIDPreimage_SorobanAuthorization u._u = &zero return &zero } default: - XdrPanic("HashIDPreimage.ContractAuth accessed when Type == %v", u.Type) + 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_FROM_ED25519, ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT, ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET, ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT, ENVELOPE_TYPE_CREATE_CONTRACT_ARGS, ENVELOPE_TYPE_CONTRACT_AUTH: + case ENVELOPE_TYPE_OP_ID, ENVELOPE_TYPE_POOL_REVOKE_OP_ID, ENVELOPE_TYPE_CONTRACT_ID, ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: return true } return false @@ -17086,18 +16442,10 @@ func (u *HashIDPreimage) XdrUnionBody() XdrType { 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_FROM_ED25519: - return XDR_XdrAnon_HashIDPreimage_Ed25519ContractID(u.Ed25519ContractID()) - case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: + case ENVELOPE_TYPE_CONTRACT_ID: return XDR_XdrAnon_HashIDPreimage_ContractID(u.ContractID()) - case ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: - return XDR_XdrAnon_HashIDPreimage_FromAsset(u.FromAsset()) - case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: - return XDR_XdrAnon_HashIDPreimage_SourceAccountContractID(u.SourceAccountContractID()) - case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: - return XDR_XdrAnon_HashIDPreimage_CreateContractArgs(u.CreateContractArgs()) - case ENVELOPE_TYPE_CONTRACT_AUTH: - return XDR_XdrAnon_HashIDPreimage_ContractAuth(u.ContractAuth()) + case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + return XDR_XdrAnon_HashIDPreimage_SorobanAuthorization(u.SorobanAuthorization()) } return nil } @@ -17107,18 +16455,10 @@ func (u *HashIDPreimage) XdrUnionBodyName() string { return "OperationID" case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: return "RevokeID" - case ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519: - return "Ed25519ContractID" - case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: + case ENVELOPE_TYPE_CONTRACT_ID: return "ContractID" - case ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: - return "FromAsset" - case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: - return "SourceAccountContractID" - case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: - return "CreateContractArgs" - case ENVELOPE_TYPE_CONTRACT_AUTH: - return "ContractAuth" + case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: + return "SorobanAuthorization" } return "" } @@ -17141,23 +16481,11 @@ func (u *HashIDPreimage) XdrRecurse(x XDR, name string) { 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_FROM_ED25519: - x.Marshal(x.Sprintf("%sed25519ContractID", name), XDR_XdrAnon_HashIDPreimage_Ed25519ContractID(u.Ed25519ContractID())) - return - case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: + case ENVELOPE_TYPE_CONTRACT_ID: x.Marshal(x.Sprintf("%scontractID", name), XDR_XdrAnon_HashIDPreimage_ContractID(u.ContractID())) return - case ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: - x.Marshal(x.Sprintf("%sfromAsset", name), XDR_XdrAnon_HashIDPreimage_FromAsset(u.FromAsset())) - return - case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: - x.Marshal(x.Sprintf("%ssourceAccountContractID", name), XDR_XdrAnon_HashIDPreimage_SourceAccountContractID(u.SourceAccountContractID())) - return - case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: - x.Marshal(x.Sprintf("%screateContractArgs", name), XDR_XdrAnon_HashIDPreimage_CreateContractArgs(u.CreateContractArgs())) - return - case ENVELOPE_TYPE_CONTRACT_AUTH: - x.Marshal(x.Sprintf("%scontractAuth", name), XDR_XdrAnon_HashIDPreimage_ContractAuth(u.ContractAuth())) + 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) @@ -17165,7 +16493,7 @@ func (u *HashIDPreimage) XdrRecurse(x XDR, name string) { func (v *HashIDPreimage) XdrInitialize() { var zero EnvelopeType switch zero { - case ENVELOPE_TYPE_OP_ID, ENVELOPE_TYPE_POOL_REVOKE_OP_ID, ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519, ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT, ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET, ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT, ENVELOPE_TYPE_CREATE_CONTRACT_ARGS, ENVELOPE_TYPE_CONTRACT_AUTH: + 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 @@ -22607,63 +21935,6 @@ func (e InvokeHostFunctionResultCode) XdrEnumComments() map[int32]string { return _XdrComments_InvokeHostFunctionResultCode } -type _XdrVec_100_SCVal []SCVal - -func (_XdrVec_100_SCVal) XdrBound() uint32 { - const bound uint32 = 100 // Force error if not const or doesn't fit - return bound -} -func (_XdrVec_100_SCVal) XdrCheckLen(length uint32) { - if length > uint32(100) { - XdrPanic("_XdrVec_100_SCVal length %d exceeds bound 100", length) - } else if int(length) < 0 { - XdrPanic("_XdrVec_100_SCVal length %d exceeds max int", length) - } -} -func (v _XdrVec_100_SCVal) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_100_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(100); 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_100_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)) - } - if int(n) < len(*v) { - *v = (*v)[:int(n)] - } -} -func (v *_XdrVec_100_SCVal) 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_SCVal) XdrTypeName() string { return "SCVal<>" } -func (v *_XdrVec_100_SCVal) XdrPointer() interface{} { return (*[]SCVal)(v) } -func (v _XdrVec_100_SCVal) XdrValue() interface{} { return ([]SCVal)(v) } -func (v *_XdrVec_100_SCVal) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - var _XdrTags_InvokeHostFunctionResult = map[int32]bool{ XdrToI32(INVOKE_HOST_FUNCTION_SUCCESS): true, XdrToI32(INVOKE_HOST_FUNCTION_MALFORMED): true, @@ -22674,13 +21945,15 @@ var _XdrTags_InvokeHostFunctionResult = map[int32]bool{ func (_ InvokeHostFunctionResult) XdrValidTags() map[int32]bool { return _XdrTags_InvokeHostFunctionResult } -func (u *InvokeHostFunctionResult) Success() *[]SCVal { + +// sha256(InvokeHostFunctionSuccessPreImage) +func (u *InvokeHostFunctionResult) Success() *Hash { switch u.Code { case INVOKE_HOST_FUNCTION_SUCCESS: - if v, ok := u._u.(*[]SCVal); ok { + if v, ok := u._u.(*Hash); ok { return v } else { - var zero []SCVal + var zero Hash u._u = &zero return &zero } @@ -22705,7 +21978,7 @@ func (u *InvokeHostFunctionResult) XdrUnionTagName() string { func (u *InvokeHostFunctionResult) XdrUnionBody() XdrType { switch u.Code { case INVOKE_HOST_FUNCTION_SUCCESS: - return (*_XdrVec_100_SCVal)(u.Success()) + return XDR_Hash(u.Success()) case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: return nil } @@ -22734,7 +22007,7 @@ func (u *InvokeHostFunctionResult) XdrRecurse(x XDR, name string) { XDR_InvokeHostFunctionResultCode(&u.Code).XdrMarshal(x, x.Sprintf("%scode", name)) switch u.Code { case INVOKE_HOST_FUNCTION_SUCCESS: - x.Marshal(x.Sprintf("%ssuccess", name), (*_XdrVec_100_SCVal)(u.Success())) + x.Marshal(x.Sprintf("%ssuccess", name), XDR_Hash(u.Success())) return case INVOKE_HOST_FUNCTION_MALFORMED, INVOKE_HOST_FUNCTION_TRAPPED, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: return @@ -24933,7 +24206,7 @@ var _XdrNames_SCSpecType = map[int32]string{ int32(SC_SPEC_TYPE_VAL): "SC_SPEC_TYPE_VAL", int32(SC_SPEC_TYPE_BOOL): "SC_SPEC_TYPE_BOOL", int32(SC_SPEC_TYPE_VOID): "SC_SPEC_TYPE_VOID", - int32(SC_SPEC_TYPE_STATUS): "SC_SPEC_TYPE_STATUS", + int32(SC_SPEC_TYPE_ERROR): "SC_SPEC_TYPE_ERROR", int32(SC_SPEC_TYPE_U32): "SC_SPEC_TYPE_U32", int32(SC_SPEC_TYPE_I32): "SC_SPEC_TYPE_I32", int32(SC_SPEC_TYPE_U64): "SC_SPEC_TYPE_U64", @@ -24961,7 +24234,7 @@ var _XdrValues_SCSpecType = map[string]int32{ "SC_SPEC_TYPE_VAL": int32(SC_SPEC_TYPE_VAL), "SC_SPEC_TYPE_BOOL": int32(SC_SPEC_TYPE_BOOL), "SC_SPEC_TYPE_VOID": int32(SC_SPEC_TYPE_VOID), - "SC_SPEC_TYPE_STATUS": int32(SC_SPEC_TYPE_STATUS), + "SC_SPEC_TYPE_ERROR": int32(SC_SPEC_TYPE_ERROR), "SC_SPEC_TYPE_U32": int32(SC_SPEC_TYPE_U32), "SC_SPEC_TYPE_I32": int32(SC_SPEC_TYPE_I32), "SC_SPEC_TYPE_U64": int32(SC_SPEC_TYPE_U64), @@ -25207,7 +24480,7 @@ var _XdrTags_SCSpecTypeDef = map[int32]bool{ XdrToI32(SC_SPEC_TYPE_VAL): true, XdrToI32(SC_SPEC_TYPE_BOOL): true, XdrToI32(SC_SPEC_TYPE_VOID): true, - XdrToI32(SC_SPEC_TYPE_STATUS): true, + XdrToI32(SC_SPEC_TYPE_ERROR): true, XdrToI32(SC_SPEC_TYPE_U32): true, XdrToI32(SC_SPEC_TYPE_I32): true, XdrToI32(SC_SPEC_TYPE_U64): true, @@ -25357,7 +24630,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_STATUS, 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_SET, 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_SET, SC_SPEC_TYPE_TUPLE, SC_SPEC_TYPE_BYTES_N, SC_SPEC_TYPE_UDT: return true } return false @@ -25370,7 +24643,7 @@ func (u *SCSpecTypeDef) XdrUnionTagName() string { } func (u *SCSpecTypeDef) XdrUnionBody() XdrType { switch u.Type { - case SC_SPEC_TYPE_VAL, SC_SPEC_TYPE_BOOL, SC_SPEC_TYPE_VOID, SC_SPEC_TYPE_STATUS, 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: + 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: return nil case SC_SPEC_TYPE_OPTION: return XDR_SCSpecTypeOption(u.Option()) @@ -25393,7 +24666,7 @@ func (u *SCSpecTypeDef) XdrUnionBody() XdrType { } func (u *SCSpecTypeDef) XdrUnionBodyName() string { switch u.Type { - case SC_SPEC_TYPE_VAL, SC_SPEC_TYPE_BOOL, SC_SPEC_TYPE_VOID, SC_SPEC_TYPE_STATUS, 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: + 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: return "" case SC_SPEC_TYPE_OPTION: return "Option" @@ -25427,7 +24700,7 @@ func (u *SCSpecTypeDef) XdrRecurse(x XDR, name string) { } XDR_SCSpecType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) switch u.Type { - case SC_SPEC_TYPE_VAL, SC_SPEC_TYPE_BOOL, SC_SPEC_TYPE_VOID, SC_SPEC_TYPE_STATUS, 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: + 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: return case SC_SPEC_TYPE_OPTION: x.Marshal(x.Sprintf("%soption", name), XDR_SCSpecTypeOption(u.Option())) @@ -26180,1033 +25453,423 @@ func (v *SCSpecEntryKind) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } type XdrType_SCSpecEntryKind = *SCSpecEntryKind func XDR_SCSpecEntryKind(v *SCSpecEntryKind) *SCSpecEntryKind { return v } - -var _XdrTags_SCSpecEntry = map[int32]bool{ - XdrToI32(SC_SPEC_ENTRY_FUNCTION_V0): true, - XdrToI32(SC_SPEC_ENTRY_UDT_STRUCT_V0): true, - XdrToI32(SC_SPEC_ENTRY_UDT_UNION_V0): true, - XdrToI32(SC_SPEC_ENTRY_UDT_ENUM_V0): true, - XdrToI32(SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0): true, -} - -func (_ SCSpecEntry) XdrValidTags() map[int32]bool { - return _XdrTags_SCSpecEntry -} -func (u *SCSpecEntry) FunctionV0() *SCSpecFunctionV0 { - switch u.Kind { - case SC_SPEC_ENTRY_FUNCTION_V0: - if v, ok := u._u.(*SCSpecFunctionV0); ok { - return v - } else { - var zero SCSpecFunctionV0 - u._u = &zero - return &zero - } - default: - XdrPanic("SCSpecEntry.FunctionV0 accessed when Kind == %v", u.Kind) - return nil - } -} -func (u *SCSpecEntry) UdtStructV0() *SCSpecUDTStructV0 { - switch u.Kind { - case SC_SPEC_ENTRY_UDT_STRUCT_V0: - if v, ok := u._u.(*SCSpecUDTStructV0); ok { - return v - } else { - var zero SCSpecUDTStructV0 - u._u = &zero - return &zero - } - default: - XdrPanic("SCSpecEntry.UdtStructV0 accessed when Kind == %v", u.Kind) - return nil - } -} -func (u *SCSpecEntry) UdtUnionV0() *SCSpecUDTUnionV0 { - switch u.Kind { - case SC_SPEC_ENTRY_UDT_UNION_V0: - if v, ok := u._u.(*SCSpecUDTUnionV0); ok { - return v - } else { - var zero SCSpecUDTUnionV0 - u._u = &zero - return &zero - } - default: - XdrPanic("SCSpecEntry.UdtUnionV0 accessed when Kind == %v", u.Kind) - return nil - } -} -func (u *SCSpecEntry) UdtEnumV0() *SCSpecUDTEnumV0 { - switch u.Kind { - case SC_SPEC_ENTRY_UDT_ENUM_V0: - if v, ok := u._u.(*SCSpecUDTEnumV0); ok { - return v - } else { - var zero SCSpecUDTEnumV0 - u._u = &zero - return &zero - } - default: - XdrPanic("SCSpecEntry.UdtEnumV0 accessed when Kind == %v", u.Kind) - return nil - } -} -func (u *SCSpecEntry) UdtErrorEnumV0() *SCSpecUDTErrorEnumV0 { - switch u.Kind { - case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: - if v, ok := u._u.(*SCSpecUDTErrorEnumV0); ok { - return v - } else { - var zero SCSpecUDTErrorEnumV0 - u._u = &zero - return &zero - } - default: - XdrPanic("SCSpecEntry.UdtErrorEnumV0 accessed when Kind == %v", u.Kind) - return nil - } -} -func (u SCSpecEntry) XdrValid() bool { - switch u.Kind { - case SC_SPEC_ENTRY_FUNCTION_V0, SC_SPEC_ENTRY_UDT_STRUCT_V0, SC_SPEC_ENTRY_UDT_UNION_V0, SC_SPEC_ENTRY_UDT_ENUM_V0, SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: - return true - } - return false -} -func (u *SCSpecEntry) XdrUnionTag() XdrNum32 { - return XDR_SCSpecEntryKind(&u.Kind) -} -func (u *SCSpecEntry) XdrUnionTagName() string { - return "Kind" -} -func (u *SCSpecEntry) XdrUnionBody() XdrType { - switch u.Kind { - case SC_SPEC_ENTRY_FUNCTION_V0: - return XDR_SCSpecFunctionV0(u.FunctionV0()) - case SC_SPEC_ENTRY_UDT_STRUCT_V0: - return XDR_SCSpecUDTStructV0(u.UdtStructV0()) - case SC_SPEC_ENTRY_UDT_UNION_V0: - return XDR_SCSpecUDTUnionV0(u.UdtUnionV0()) - case SC_SPEC_ENTRY_UDT_ENUM_V0: - return XDR_SCSpecUDTEnumV0(u.UdtEnumV0()) - case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: - return XDR_SCSpecUDTErrorEnumV0(u.UdtErrorEnumV0()) - } - return nil -} -func (u *SCSpecEntry) XdrUnionBodyName() string { - switch u.Kind { - case SC_SPEC_ENTRY_FUNCTION_V0: - return "FunctionV0" - case SC_SPEC_ENTRY_UDT_STRUCT_V0: - return "UdtStructV0" - case SC_SPEC_ENTRY_UDT_UNION_V0: - return "UdtUnionV0" - case SC_SPEC_ENTRY_UDT_ENUM_V0: - return "UdtEnumV0" - case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: - return "UdtErrorEnumV0" - } - return "" -} - -type XdrType_SCSpecEntry = *SCSpecEntry - -func (v *SCSpecEntry) XdrPointer() interface{} { return v } -func (SCSpecEntry) XdrTypeName() string { return "SCSpecEntry" } -func (v SCSpecEntry) XdrValue() interface{} { return v } -func (v *SCSpecEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *SCSpecEntry) XdrRecurse(x XDR, name string) { - if name != "" { - name = x.Sprintf("%s.", name) - } - XDR_SCSpecEntryKind(&u.Kind).XdrMarshal(x, x.Sprintf("%skind", name)) - switch u.Kind { - case SC_SPEC_ENTRY_FUNCTION_V0: - x.Marshal(x.Sprintf("%sfunctionV0", name), XDR_SCSpecFunctionV0(u.FunctionV0())) - return - case SC_SPEC_ENTRY_UDT_STRUCT_V0: - x.Marshal(x.Sprintf("%sudtStructV0", name), XDR_SCSpecUDTStructV0(u.UdtStructV0())) - return - case SC_SPEC_ENTRY_UDT_UNION_V0: - x.Marshal(x.Sprintf("%sudtUnionV0", name), XDR_SCSpecUDTUnionV0(u.UdtUnionV0())) - return - case SC_SPEC_ENTRY_UDT_ENUM_V0: - x.Marshal(x.Sprintf("%sudtEnumV0", name), XDR_SCSpecUDTEnumV0(u.UdtEnumV0())) - return - case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: - x.Marshal(x.Sprintf("%sudtErrorEnumV0", name), XDR_SCSpecUDTErrorEnumV0(u.UdtErrorEnumV0())) - return - } - XdrPanic("invalid Kind (%v) in SCSpecEntry", u.Kind) -} -func XDR_SCSpecEntry(v *SCSpecEntry) *SCSpecEntry { return v } - -var _XdrNames_SCValType = map[int32]string{ - int32(SCV_BOOL): "SCV_BOOL", - int32(SCV_VOID): "SCV_VOID", - int32(SCV_STATUS): "SCV_STATUS", - int32(SCV_U32): "SCV_U32", - int32(SCV_I32): "SCV_I32", - int32(SCV_U64): "SCV_U64", - int32(SCV_I64): "SCV_I64", - int32(SCV_TIMEPOINT): "SCV_TIMEPOINT", - int32(SCV_DURATION): "SCV_DURATION", - int32(SCV_U128): "SCV_U128", - int32(SCV_I128): "SCV_I128", - int32(SCV_U256): "SCV_U256", - int32(SCV_I256): "SCV_I256", - int32(SCV_BYTES): "SCV_BYTES", - int32(SCV_STRING): "SCV_STRING", - int32(SCV_SYMBOL): "SCV_SYMBOL", - int32(SCV_VEC): "SCV_VEC", - int32(SCV_MAP): "SCV_MAP", - int32(SCV_CONTRACT_EXECUTABLE): "SCV_CONTRACT_EXECUTABLE", - int32(SCV_ADDRESS): "SCV_ADDRESS", - int32(SCV_LEDGER_KEY_CONTRACT_EXECUTABLE): "SCV_LEDGER_KEY_CONTRACT_EXECUTABLE", - int32(SCV_LEDGER_KEY_NONCE): "SCV_LEDGER_KEY_NONCE", -} -var _XdrValues_SCValType = map[string]int32{ - "SCV_BOOL": int32(SCV_BOOL), - "SCV_VOID": int32(SCV_VOID), - "SCV_STATUS": int32(SCV_STATUS), - "SCV_U32": int32(SCV_U32), - "SCV_I32": int32(SCV_I32), - "SCV_U64": int32(SCV_U64), - "SCV_I64": int32(SCV_I64), - "SCV_TIMEPOINT": int32(SCV_TIMEPOINT), - "SCV_DURATION": int32(SCV_DURATION), - "SCV_U128": int32(SCV_U128), - "SCV_I128": int32(SCV_I128), - "SCV_U256": int32(SCV_U256), - "SCV_I256": int32(SCV_I256), - "SCV_BYTES": int32(SCV_BYTES), - "SCV_STRING": int32(SCV_STRING), - "SCV_SYMBOL": int32(SCV_SYMBOL), - "SCV_VEC": int32(SCV_VEC), - "SCV_MAP": int32(SCV_MAP), - "SCV_CONTRACT_EXECUTABLE": int32(SCV_CONTRACT_EXECUTABLE), - "SCV_ADDRESS": int32(SCV_ADDRESS), - "SCV_LEDGER_KEY_CONTRACT_EXECUTABLE": int32(SCV_LEDGER_KEY_CONTRACT_EXECUTABLE), - "SCV_LEDGER_KEY_NONCE": int32(SCV_LEDGER_KEY_NONCE), -} - -func (SCValType) XdrEnumNames() map[int32]string { - return _XdrNames_SCValType -} -func (v SCValType) String() string { - if s, ok := _XdrNames_SCValType[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCValType#%d", v) -} -func (v *SCValType) 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_SCValType[stok]; ok { - *v = SCValType(val) - return nil - } else if stok == "SCValType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCValType.", stok)) - } -} -func (v SCValType) GetU32() uint32 { return uint32(v) } -func (v *SCValType) SetU32(n uint32) { *v = SCValType(n) } -func (v *SCValType) XdrPointer() interface{} { return v } -func (SCValType) XdrTypeName() string { return "SCValType" } -func (v SCValType) XdrValue() interface{} { return v } -func (v *SCValType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCValType = *SCValType - -func XDR_SCValType(v *SCValType) *SCValType { return v } - -var _XdrComments_SCValType = map[int32]string{ - int32(SCV_U32): "32 bits is the smallest type in WASM or XDR; no need for u8/u16.", - int32(SCV_U64): "64 bits is naturally supported by both WASM and XDR also.", - int32(SCV_TIMEPOINT): "Time-related u64 subtypes with their own functions and formatting.", - int32(SCV_U128): "128 bits is naturally supported by Rust and we use it for Soroban fixed-point arithmetic prices / balances / similar \"quantities\". These are represented in XDR as a pair of 2 u64s, unlike {u,i}256 which is represented as an array of 32 bytes.", - int32(SCV_U256): "256 bits is the size of sha256 output, ed25519 keys, and the EVM machine word, so for interop use we include this even though it requires a small amount of Rust guest and/or host library code.", - int32(SCV_BYTES): "Bytes come in 3 flavors, 2 of which have meaningfully different formatting and validity-checking / domain-restriction.", - int32(SCV_VEC): "Vecs and maps are just polymorphic containers of other ScVals.", - int32(SCV_CONTRACT_EXECUTABLE): "SCContractExecutable and SCAddressType are types that gets used separately from SCVal so we do not flatten their structures into separate SCVal cases.", - int32(SCV_LEDGER_KEY_CONTRACT_EXECUTABLE): "SCV_LEDGER_KEY_CONTRACT_EXECUTABLE and SCV_LEDGER_KEY_NONCE are unique symbolic SCVals used as the key for ledger entries for a contract's code and an address' nonce, respectively.", -} - -func (e SCValType) XdrEnumComments() map[int32]string { - return _XdrComments_SCValType -} - -var _XdrNames_SCStatusType = map[int32]string{ - int32(SST_OK): "SST_OK", - int32(SST_UNKNOWN_ERROR): "SST_UNKNOWN_ERROR", - int32(SST_HOST_VALUE_ERROR): "SST_HOST_VALUE_ERROR", - int32(SST_HOST_OBJECT_ERROR): "SST_HOST_OBJECT_ERROR", - int32(SST_HOST_FUNCTION_ERROR): "SST_HOST_FUNCTION_ERROR", - int32(SST_HOST_STORAGE_ERROR): "SST_HOST_STORAGE_ERROR", - int32(SST_HOST_CONTEXT_ERROR): "SST_HOST_CONTEXT_ERROR", - int32(SST_VM_ERROR): "SST_VM_ERROR", - int32(SST_CONTRACT_ERROR): "SST_CONTRACT_ERROR", - int32(SST_HOST_AUTH_ERROR): "SST_HOST_AUTH_ERROR", -} -var _XdrValues_SCStatusType = map[string]int32{ - "SST_OK": int32(SST_OK), - "SST_UNKNOWN_ERROR": int32(SST_UNKNOWN_ERROR), - "SST_HOST_VALUE_ERROR": int32(SST_HOST_VALUE_ERROR), - "SST_HOST_OBJECT_ERROR": int32(SST_HOST_OBJECT_ERROR), - "SST_HOST_FUNCTION_ERROR": int32(SST_HOST_FUNCTION_ERROR), - "SST_HOST_STORAGE_ERROR": int32(SST_HOST_STORAGE_ERROR), - "SST_HOST_CONTEXT_ERROR": int32(SST_HOST_CONTEXT_ERROR), - "SST_VM_ERROR": int32(SST_VM_ERROR), - "SST_CONTRACT_ERROR": int32(SST_CONTRACT_ERROR), - "SST_HOST_AUTH_ERROR": int32(SST_HOST_AUTH_ERROR), -} - -func (SCStatusType) XdrEnumNames() map[int32]string { - return _XdrNames_SCStatusType -} -func (v SCStatusType) String() string { - if s, ok := _XdrNames_SCStatusType[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCStatusType#%d", v) -} -func (v *SCStatusType) 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_SCStatusType[stok]; ok { - *v = SCStatusType(val) - return nil - } else if stok == "SCStatusType" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCStatusType.", stok)) - } -} -func (v SCStatusType) GetU32() uint32 { return uint32(v) } -func (v *SCStatusType) SetU32(n uint32) { *v = SCStatusType(n) } -func (v *SCStatusType) XdrPointer() interface{} { return v } -func (SCStatusType) XdrTypeName() string { return "SCStatusType" } -func (v SCStatusType) XdrValue() interface{} { return v } -func (v *SCStatusType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCStatusType = *SCStatusType - -func XDR_SCStatusType(v *SCStatusType) *SCStatusType { return v } - -var _XdrNames_SCHostValErrorCode = map[int32]string{ - int32(HOST_VALUE_UNKNOWN_ERROR): "HOST_VALUE_UNKNOWN_ERROR", - int32(HOST_VALUE_RESERVED_TAG_VALUE): "HOST_VALUE_RESERVED_TAG_VALUE", - int32(HOST_VALUE_UNEXPECTED_VAL_TYPE): "HOST_VALUE_UNEXPECTED_VAL_TYPE", - int32(HOST_VALUE_U63_OUT_OF_RANGE): "HOST_VALUE_U63_OUT_OF_RANGE", - int32(HOST_VALUE_U32_OUT_OF_RANGE): "HOST_VALUE_U32_OUT_OF_RANGE", - int32(HOST_VALUE_STATIC_UNKNOWN): "HOST_VALUE_STATIC_UNKNOWN", - int32(HOST_VALUE_MISSING_OBJECT): "HOST_VALUE_MISSING_OBJECT", - int32(HOST_VALUE_SYMBOL_TOO_LONG): "HOST_VALUE_SYMBOL_TOO_LONG", - int32(HOST_VALUE_SYMBOL_BAD_CHAR): "HOST_VALUE_SYMBOL_BAD_CHAR", - int32(HOST_VALUE_SYMBOL_CONTAINS_NON_UTF8): "HOST_VALUE_SYMBOL_CONTAINS_NON_UTF8", - int32(HOST_VALUE_BITSET_TOO_MANY_BITS): "HOST_VALUE_BITSET_TOO_MANY_BITS", - int32(HOST_VALUE_STATUS_UNKNOWN): "HOST_VALUE_STATUS_UNKNOWN", -} -var _XdrValues_SCHostValErrorCode = map[string]int32{ - "HOST_VALUE_UNKNOWN_ERROR": int32(HOST_VALUE_UNKNOWN_ERROR), - "HOST_VALUE_RESERVED_TAG_VALUE": int32(HOST_VALUE_RESERVED_TAG_VALUE), - "HOST_VALUE_UNEXPECTED_VAL_TYPE": int32(HOST_VALUE_UNEXPECTED_VAL_TYPE), - "HOST_VALUE_U63_OUT_OF_RANGE": int32(HOST_VALUE_U63_OUT_OF_RANGE), - "HOST_VALUE_U32_OUT_OF_RANGE": int32(HOST_VALUE_U32_OUT_OF_RANGE), - "HOST_VALUE_STATIC_UNKNOWN": int32(HOST_VALUE_STATIC_UNKNOWN), - "HOST_VALUE_MISSING_OBJECT": int32(HOST_VALUE_MISSING_OBJECT), - "HOST_VALUE_SYMBOL_TOO_LONG": int32(HOST_VALUE_SYMBOL_TOO_LONG), - "HOST_VALUE_SYMBOL_BAD_CHAR": int32(HOST_VALUE_SYMBOL_BAD_CHAR), - "HOST_VALUE_SYMBOL_CONTAINS_NON_UTF8": int32(HOST_VALUE_SYMBOL_CONTAINS_NON_UTF8), - "HOST_VALUE_BITSET_TOO_MANY_BITS": int32(HOST_VALUE_BITSET_TOO_MANY_BITS), - "HOST_VALUE_STATUS_UNKNOWN": int32(HOST_VALUE_STATUS_UNKNOWN), -} - -func (SCHostValErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCHostValErrorCode -} -func (v SCHostValErrorCode) String() string { - if s, ok := _XdrNames_SCHostValErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCHostValErrorCode#%d", v) -} -func (v *SCHostValErrorCode) 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_SCHostValErrorCode[stok]; ok { - *v = SCHostValErrorCode(val) - return nil - } else if stok == "SCHostValErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCHostValErrorCode.", stok)) - } -} -func (v SCHostValErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCHostValErrorCode) SetU32(n uint32) { *v = SCHostValErrorCode(n) } -func (v *SCHostValErrorCode) XdrPointer() interface{} { return v } -func (SCHostValErrorCode) XdrTypeName() string { return "SCHostValErrorCode" } -func (v SCHostValErrorCode) XdrValue() interface{} { return v } -func (v *SCHostValErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCHostValErrorCode = *SCHostValErrorCode - -func XDR_SCHostValErrorCode(v *SCHostValErrorCode) *SCHostValErrorCode { return v } - -var _XdrNames_SCHostObjErrorCode = map[int32]string{ - int32(HOST_OBJECT_UNKNOWN_ERROR): "HOST_OBJECT_UNKNOWN_ERROR", - int32(HOST_OBJECT_UNKNOWN_REFERENCE): "HOST_OBJECT_UNKNOWN_REFERENCE", - int32(HOST_OBJECT_UNEXPECTED_TYPE): "HOST_OBJECT_UNEXPECTED_TYPE", - int32(HOST_OBJECT_OBJECT_COUNT_EXCEEDS_U32_MAX): "HOST_OBJECT_OBJECT_COUNT_EXCEEDS_U32_MAX", - int32(HOST_OBJECT_OBJECT_NOT_EXIST): "HOST_OBJECT_OBJECT_NOT_EXIST", - int32(HOST_OBJECT_VEC_INDEX_OUT_OF_BOUND): "HOST_OBJECT_VEC_INDEX_OUT_OF_BOUND", - int32(HOST_OBJECT_CONTRACT_HASH_WRONG_LENGTH): "HOST_OBJECT_CONTRACT_HASH_WRONG_LENGTH", -} -var _XdrValues_SCHostObjErrorCode = map[string]int32{ - "HOST_OBJECT_UNKNOWN_ERROR": int32(HOST_OBJECT_UNKNOWN_ERROR), - "HOST_OBJECT_UNKNOWN_REFERENCE": int32(HOST_OBJECT_UNKNOWN_REFERENCE), - "HOST_OBJECT_UNEXPECTED_TYPE": int32(HOST_OBJECT_UNEXPECTED_TYPE), - "HOST_OBJECT_OBJECT_COUNT_EXCEEDS_U32_MAX": int32(HOST_OBJECT_OBJECT_COUNT_EXCEEDS_U32_MAX), - "HOST_OBJECT_OBJECT_NOT_EXIST": int32(HOST_OBJECT_OBJECT_NOT_EXIST), - "HOST_OBJECT_VEC_INDEX_OUT_OF_BOUND": int32(HOST_OBJECT_VEC_INDEX_OUT_OF_BOUND), - "HOST_OBJECT_CONTRACT_HASH_WRONG_LENGTH": int32(HOST_OBJECT_CONTRACT_HASH_WRONG_LENGTH), -} - -func (SCHostObjErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCHostObjErrorCode -} -func (v SCHostObjErrorCode) String() string { - if s, ok := _XdrNames_SCHostObjErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCHostObjErrorCode#%d", v) -} -func (v *SCHostObjErrorCode) 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_SCHostObjErrorCode[stok]; ok { - *v = SCHostObjErrorCode(val) - return nil - } else if stok == "SCHostObjErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCHostObjErrorCode.", stok)) - } -} -func (v SCHostObjErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCHostObjErrorCode) SetU32(n uint32) { *v = SCHostObjErrorCode(n) } -func (v *SCHostObjErrorCode) XdrPointer() interface{} { return v } -func (SCHostObjErrorCode) XdrTypeName() string { return "SCHostObjErrorCode" } -func (v SCHostObjErrorCode) XdrValue() interface{} { return v } -func (v *SCHostObjErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCHostObjErrorCode = *SCHostObjErrorCode - -func XDR_SCHostObjErrorCode(v *SCHostObjErrorCode) *SCHostObjErrorCode { return v } - -var _XdrNames_SCHostFnErrorCode = map[int32]string{ - int32(HOST_FN_UNKNOWN_ERROR): "HOST_FN_UNKNOWN_ERROR", - int32(HOST_FN_UNEXPECTED_HOST_FUNCTION_ACTION): "HOST_FN_UNEXPECTED_HOST_FUNCTION_ACTION", - int32(HOST_FN_INPUT_ARGS_WRONG_LENGTH): "HOST_FN_INPUT_ARGS_WRONG_LENGTH", - int32(HOST_FN_INPUT_ARGS_WRONG_TYPE): "HOST_FN_INPUT_ARGS_WRONG_TYPE", - int32(HOST_FN_INPUT_ARGS_INVALID): "HOST_FN_INPUT_ARGS_INVALID", -} -var _XdrValues_SCHostFnErrorCode = map[string]int32{ - "HOST_FN_UNKNOWN_ERROR": int32(HOST_FN_UNKNOWN_ERROR), - "HOST_FN_UNEXPECTED_HOST_FUNCTION_ACTION": int32(HOST_FN_UNEXPECTED_HOST_FUNCTION_ACTION), - "HOST_FN_INPUT_ARGS_WRONG_LENGTH": int32(HOST_FN_INPUT_ARGS_WRONG_LENGTH), - "HOST_FN_INPUT_ARGS_WRONG_TYPE": int32(HOST_FN_INPUT_ARGS_WRONG_TYPE), - "HOST_FN_INPUT_ARGS_INVALID": int32(HOST_FN_INPUT_ARGS_INVALID), -} - -func (SCHostFnErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCHostFnErrorCode -} -func (v SCHostFnErrorCode) String() string { - if s, ok := _XdrNames_SCHostFnErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCHostFnErrorCode#%d", v) -} -func (v *SCHostFnErrorCode) 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_SCHostFnErrorCode[stok]; ok { - *v = SCHostFnErrorCode(val) - return nil - } else if stok == "SCHostFnErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCHostFnErrorCode.", stok)) - } -} -func (v SCHostFnErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCHostFnErrorCode) SetU32(n uint32) { *v = SCHostFnErrorCode(n) } -func (v *SCHostFnErrorCode) XdrPointer() interface{} { return v } -func (SCHostFnErrorCode) XdrTypeName() string { return "SCHostFnErrorCode" } -func (v SCHostFnErrorCode) XdrValue() interface{} { return v } -func (v *SCHostFnErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCHostFnErrorCode = *SCHostFnErrorCode - -func XDR_SCHostFnErrorCode(v *SCHostFnErrorCode) *SCHostFnErrorCode { return v } - -var _XdrNames_SCHostStorageErrorCode = map[int32]string{ - int32(HOST_STORAGE_UNKNOWN_ERROR): "HOST_STORAGE_UNKNOWN_ERROR", - int32(HOST_STORAGE_EXPECT_CONTRACT_DATA): "HOST_STORAGE_EXPECT_CONTRACT_DATA", - int32(HOST_STORAGE_READWRITE_ACCESS_TO_READONLY_ENTRY): "HOST_STORAGE_READWRITE_ACCESS_TO_READONLY_ENTRY", - int32(HOST_STORAGE_ACCESS_TO_UNKNOWN_ENTRY): "HOST_STORAGE_ACCESS_TO_UNKNOWN_ENTRY", - int32(HOST_STORAGE_MISSING_KEY_IN_GET): "HOST_STORAGE_MISSING_KEY_IN_GET", - int32(HOST_STORAGE_GET_ON_DELETED_KEY): "HOST_STORAGE_GET_ON_DELETED_KEY", -} -var _XdrValues_SCHostStorageErrorCode = map[string]int32{ - "HOST_STORAGE_UNKNOWN_ERROR": int32(HOST_STORAGE_UNKNOWN_ERROR), - "HOST_STORAGE_EXPECT_CONTRACT_DATA": int32(HOST_STORAGE_EXPECT_CONTRACT_DATA), - "HOST_STORAGE_READWRITE_ACCESS_TO_READONLY_ENTRY": int32(HOST_STORAGE_READWRITE_ACCESS_TO_READONLY_ENTRY), - "HOST_STORAGE_ACCESS_TO_UNKNOWN_ENTRY": int32(HOST_STORAGE_ACCESS_TO_UNKNOWN_ENTRY), - "HOST_STORAGE_MISSING_KEY_IN_GET": int32(HOST_STORAGE_MISSING_KEY_IN_GET), - "HOST_STORAGE_GET_ON_DELETED_KEY": int32(HOST_STORAGE_GET_ON_DELETED_KEY), -} - -func (SCHostStorageErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCHostStorageErrorCode -} -func (v SCHostStorageErrorCode) String() string { - if s, ok := _XdrNames_SCHostStorageErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCHostStorageErrorCode#%d", v) -} -func (v *SCHostStorageErrorCode) 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_SCHostStorageErrorCode[stok]; ok { - *v = SCHostStorageErrorCode(val) - return nil - } else if stok == "SCHostStorageErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCHostStorageErrorCode.", stok)) - } -} -func (v SCHostStorageErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCHostStorageErrorCode) SetU32(n uint32) { *v = SCHostStorageErrorCode(n) } -func (v *SCHostStorageErrorCode) XdrPointer() interface{} { return v } -func (SCHostStorageErrorCode) XdrTypeName() string { return "SCHostStorageErrorCode" } -func (v SCHostStorageErrorCode) XdrValue() interface{} { return v } -func (v *SCHostStorageErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCHostStorageErrorCode = *SCHostStorageErrorCode - -func XDR_SCHostStorageErrorCode(v *SCHostStorageErrorCode) *SCHostStorageErrorCode { return v } - -var _XdrNames_SCHostAuthErrorCode = map[int32]string{ - int32(HOST_AUTH_UNKNOWN_ERROR): "HOST_AUTH_UNKNOWN_ERROR", - int32(HOST_AUTH_NONCE_ERROR): "HOST_AUTH_NONCE_ERROR", - int32(HOST_AUTH_DUPLICATE_AUTHORIZATION): "HOST_AUTH_DUPLICATE_AUTHORIZATION", - int32(HOST_AUTH_NOT_AUTHORIZED): "HOST_AUTH_NOT_AUTHORIZED", -} -var _XdrValues_SCHostAuthErrorCode = map[string]int32{ - "HOST_AUTH_UNKNOWN_ERROR": int32(HOST_AUTH_UNKNOWN_ERROR), - "HOST_AUTH_NONCE_ERROR": int32(HOST_AUTH_NONCE_ERROR), - "HOST_AUTH_DUPLICATE_AUTHORIZATION": int32(HOST_AUTH_DUPLICATE_AUTHORIZATION), - "HOST_AUTH_NOT_AUTHORIZED": int32(HOST_AUTH_NOT_AUTHORIZED), -} - -func (SCHostAuthErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCHostAuthErrorCode -} -func (v SCHostAuthErrorCode) String() string { - if s, ok := _XdrNames_SCHostAuthErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCHostAuthErrorCode#%d", v) -} -func (v *SCHostAuthErrorCode) 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_SCHostAuthErrorCode[stok]; ok { - *v = SCHostAuthErrorCode(val) - return nil - } else if stok == "SCHostAuthErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCHostAuthErrorCode.", stok)) - } -} -func (v SCHostAuthErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCHostAuthErrorCode) SetU32(n uint32) { *v = SCHostAuthErrorCode(n) } -func (v *SCHostAuthErrorCode) XdrPointer() interface{} { return v } -func (SCHostAuthErrorCode) XdrTypeName() string { return "SCHostAuthErrorCode" } -func (v SCHostAuthErrorCode) XdrValue() interface{} { return v } -func (v *SCHostAuthErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCHostAuthErrorCode = *SCHostAuthErrorCode - -func XDR_SCHostAuthErrorCode(v *SCHostAuthErrorCode) *SCHostAuthErrorCode { return v } - -var _XdrNames_SCHostContextErrorCode = map[int32]string{ - int32(HOST_CONTEXT_UNKNOWN_ERROR): "HOST_CONTEXT_UNKNOWN_ERROR", - int32(HOST_CONTEXT_NO_CONTRACT_RUNNING): "HOST_CONTEXT_NO_CONTRACT_RUNNING", -} -var _XdrValues_SCHostContextErrorCode = map[string]int32{ - "HOST_CONTEXT_UNKNOWN_ERROR": int32(HOST_CONTEXT_UNKNOWN_ERROR), - "HOST_CONTEXT_NO_CONTRACT_RUNNING": int32(HOST_CONTEXT_NO_CONTRACT_RUNNING), -} - -func (SCHostContextErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCHostContextErrorCode -} -func (v SCHostContextErrorCode) String() string { - if s, ok := _XdrNames_SCHostContextErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCHostContextErrorCode#%d", v) -} -func (v *SCHostContextErrorCode) 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_SCHostContextErrorCode[stok]; ok { - *v = SCHostContextErrorCode(val) - return nil - } else if stok == "SCHostContextErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCHostContextErrorCode.", stok)) - } -} -func (v SCHostContextErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCHostContextErrorCode) SetU32(n uint32) { *v = SCHostContextErrorCode(n) } -func (v *SCHostContextErrorCode) XdrPointer() interface{} { return v } -func (SCHostContextErrorCode) XdrTypeName() string { return "SCHostContextErrorCode" } -func (v SCHostContextErrorCode) XdrValue() interface{} { return v } -func (v *SCHostContextErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCHostContextErrorCode = *SCHostContextErrorCode - -func XDR_SCHostContextErrorCode(v *SCHostContextErrorCode) *SCHostContextErrorCode { return v } - -var _XdrNames_SCVmErrorCode = map[int32]string{ - int32(VM_UNKNOWN): "VM_UNKNOWN", - int32(VM_VALIDATION): "VM_VALIDATION", - int32(VM_INSTANTIATION): "VM_INSTANTIATION", - int32(VM_FUNCTION): "VM_FUNCTION", - int32(VM_TABLE): "VM_TABLE", - int32(VM_MEMORY): "VM_MEMORY", - int32(VM_GLOBAL): "VM_GLOBAL", - int32(VM_VALUE): "VM_VALUE", - int32(VM_TRAP_UNREACHABLE): "VM_TRAP_UNREACHABLE", - int32(VM_TRAP_MEMORY_ACCESS_OUT_OF_BOUNDS): "VM_TRAP_MEMORY_ACCESS_OUT_OF_BOUNDS", - int32(VM_TRAP_TABLE_ACCESS_OUT_OF_BOUNDS): "VM_TRAP_TABLE_ACCESS_OUT_OF_BOUNDS", - int32(VM_TRAP_ELEM_UNINITIALIZED): "VM_TRAP_ELEM_UNINITIALIZED", - int32(VM_TRAP_DIVISION_BY_ZERO): "VM_TRAP_DIVISION_BY_ZERO", - int32(VM_TRAP_INTEGER_OVERFLOW): "VM_TRAP_INTEGER_OVERFLOW", - int32(VM_TRAP_INVALID_CONVERSION_TO_INT): "VM_TRAP_INVALID_CONVERSION_TO_INT", - int32(VM_TRAP_STACK_OVERFLOW): "VM_TRAP_STACK_OVERFLOW", - int32(VM_TRAP_UNEXPECTED_SIGNATURE): "VM_TRAP_UNEXPECTED_SIGNATURE", - int32(VM_TRAP_MEM_LIMIT_EXCEEDED): "VM_TRAP_MEM_LIMIT_EXCEEDED", - int32(VM_TRAP_CPU_LIMIT_EXCEEDED): "VM_TRAP_CPU_LIMIT_EXCEEDED", -} -var _XdrValues_SCVmErrorCode = map[string]int32{ - "VM_UNKNOWN": int32(VM_UNKNOWN), - "VM_VALIDATION": int32(VM_VALIDATION), - "VM_INSTANTIATION": int32(VM_INSTANTIATION), - "VM_FUNCTION": int32(VM_FUNCTION), - "VM_TABLE": int32(VM_TABLE), - "VM_MEMORY": int32(VM_MEMORY), - "VM_GLOBAL": int32(VM_GLOBAL), - "VM_VALUE": int32(VM_VALUE), - "VM_TRAP_UNREACHABLE": int32(VM_TRAP_UNREACHABLE), - "VM_TRAP_MEMORY_ACCESS_OUT_OF_BOUNDS": int32(VM_TRAP_MEMORY_ACCESS_OUT_OF_BOUNDS), - "VM_TRAP_TABLE_ACCESS_OUT_OF_BOUNDS": int32(VM_TRAP_TABLE_ACCESS_OUT_OF_BOUNDS), - "VM_TRAP_ELEM_UNINITIALIZED": int32(VM_TRAP_ELEM_UNINITIALIZED), - "VM_TRAP_DIVISION_BY_ZERO": int32(VM_TRAP_DIVISION_BY_ZERO), - "VM_TRAP_INTEGER_OVERFLOW": int32(VM_TRAP_INTEGER_OVERFLOW), - "VM_TRAP_INVALID_CONVERSION_TO_INT": int32(VM_TRAP_INVALID_CONVERSION_TO_INT), - "VM_TRAP_STACK_OVERFLOW": int32(VM_TRAP_STACK_OVERFLOW), - "VM_TRAP_UNEXPECTED_SIGNATURE": int32(VM_TRAP_UNEXPECTED_SIGNATURE), - "VM_TRAP_MEM_LIMIT_EXCEEDED": int32(VM_TRAP_MEM_LIMIT_EXCEEDED), - "VM_TRAP_CPU_LIMIT_EXCEEDED": int32(VM_TRAP_CPU_LIMIT_EXCEEDED), -} - -func (SCVmErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCVmErrorCode -} -func (v SCVmErrorCode) String() string { - if s, ok := _XdrNames_SCVmErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCVmErrorCode#%d", v) -} -func (v *SCVmErrorCode) 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_SCVmErrorCode[stok]; ok { - *v = SCVmErrorCode(val) - return nil - } else if stok == "SCVmErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCVmErrorCode.", stok)) - } -} -func (v SCVmErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCVmErrorCode) SetU32(n uint32) { *v = SCVmErrorCode(n) } -func (v *SCVmErrorCode) XdrPointer() interface{} { return v } -func (SCVmErrorCode) XdrTypeName() string { return "SCVmErrorCode" } -func (v SCVmErrorCode) XdrValue() interface{} { return v } -func (v *SCVmErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCVmErrorCode = *SCVmErrorCode - -func XDR_SCVmErrorCode(v *SCVmErrorCode) *SCVmErrorCode { return v } - -var _XdrNames_SCUnknownErrorCode = map[int32]string{ - int32(UNKNOWN_ERROR_GENERAL): "UNKNOWN_ERROR_GENERAL", - int32(UNKNOWN_ERROR_XDR): "UNKNOWN_ERROR_XDR", -} -var _XdrValues_SCUnknownErrorCode = map[string]int32{ - "UNKNOWN_ERROR_GENERAL": int32(UNKNOWN_ERROR_GENERAL), - "UNKNOWN_ERROR_XDR": int32(UNKNOWN_ERROR_XDR), -} - -func (SCUnknownErrorCode) XdrEnumNames() map[int32]string { - return _XdrNames_SCUnknownErrorCode -} -func (v SCUnknownErrorCode) String() string { - if s, ok := _XdrNames_SCUnknownErrorCode[int32(v)]; ok { - return s - } - return fmt.Sprintf("SCUnknownErrorCode#%d", v) -} -func (v *SCUnknownErrorCode) 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_SCUnknownErrorCode[stok]; ok { - *v = SCUnknownErrorCode(val) - return nil - } else if stok == "SCUnknownErrorCode" { - if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { - return nil - } - } - return XdrError(fmt.Sprintf("%s is not a valid SCUnknownErrorCode.", stok)) - } -} -func (v SCUnknownErrorCode) GetU32() uint32 { return uint32(v) } -func (v *SCUnknownErrorCode) SetU32(n uint32) { *v = SCUnknownErrorCode(n) } -func (v *SCUnknownErrorCode) XdrPointer() interface{} { return v } -func (SCUnknownErrorCode) XdrTypeName() string { return "SCUnknownErrorCode" } -func (v SCUnknownErrorCode) XdrValue() interface{} { return v } -func (v *SCUnknownErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } - -type XdrType_SCUnknownErrorCode = *SCUnknownErrorCode - -func XDR_SCUnknownErrorCode(v *SCUnknownErrorCode) *SCUnknownErrorCode { return v } - -var _XdrTags_SCStatus = map[int32]bool{ - XdrToI32(SST_OK): true, - XdrToI32(SST_UNKNOWN_ERROR): true, - XdrToI32(SST_HOST_VALUE_ERROR): true, - XdrToI32(SST_HOST_OBJECT_ERROR): true, - XdrToI32(SST_HOST_FUNCTION_ERROR): true, - XdrToI32(SST_HOST_STORAGE_ERROR): true, - XdrToI32(SST_HOST_CONTEXT_ERROR): true, - XdrToI32(SST_VM_ERROR): true, - XdrToI32(SST_CONTRACT_ERROR): true, - XdrToI32(SST_HOST_AUTH_ERROR): true, -} - -func (_ SCStatus) XdrValidTags() map[int32]bool { - return _XdrTags_SCStatus -} -func (u *SCStatus) UnknownCode() *SCUnknownErrorCode { - switch u.Type { - case SST_UNKNOWN_ERROR: - if v, ok := u._u.(*SCUnknownErrorCode); ok { - return v - } else { - var zero SCUnknownErrorCode - u._u = &zero - return &zero - } - default: - XdrPanic("SCStatus.UnknownCode accessed when Type == %v", u.Type) - return nil - } -} -func (u *SCStatus) ValCode() *SCHostValErrorCode { - switch u.Type { - case SST_HOST_VALUE_ERROR: - if v, ok := u._u.(*SCHostValErrorCode); ok { - return v - } else { - var zero SCHostValErrorCode - u._u = &zero - return &zero - } - default: - XdrPanic("SCStatus.ValCode accessed when Type == %v", u.Type) - return nil - } -} -func (u *SCStatus) ObjCode() *SCHostObjErrorCode { - switch u.Type { - case SST_HOST_OBJECT_ERROR: - if v, ok := u._u.(*SCHostObjErrorCode); ok { - return v - } else { - var zero SCHostObjErrorCode - u._u = &zero - return &zero - } - default: - XdrPanic("SCStatus.ObjCode accessed when Type == %v", u.Type) - return nil - } -} -func (u *SCStatus) FnCode() *SCHostFnErrorCode { - switch u.Type { - case SST_HOST_FUNCTION_ERROR: - if v, ok := u._u.(*SCHostFnErrorCode); ok { - return v - } else { - var zero SCHostFnErrorCode - u._u = &zero - return &zero - } - default: - XdrPanic("SCStatus.FnCode accessed when Type == %v", u.Type) - return nil - } + +var _XdrTags_SCSpecEntry = map[int32]bool{ + XdrToI32(SC_SPEC_ENTRY_FUNCTION_V0): true, + XdrToI32(SC_SPEC_ENTRY_UDT_STRUCT_V0): true, + XdrToI32(SC_SPEC_ENTRY_UDT_UNION_V0): true, + XdrToI32(SC_SPEC_ENTRY_UDT_ENUM_V0): true, + XdrToI32(SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0): true, } -func (u *SCStatus) StorageCode() *SCHostStorageErrorCode { - switch u.Type { - case SST_HOST_STORAGE_ERROR: - if v, ok := u._u.(*SCHostStorageErrorCode); ok { + +func (_ SCSpecEntry) XdrValidTags() map[int32]bool { + return _XdrTags_SCSpecEntry +} +func (u *SCSpecEntry) FunctionV0() *SCSpecFunctionV0 { + switch u.Kind { + case SC_SPEC_ENTRY_FUNCTION_V0: + if v, ok := u._u.(*SCSpecFunctionV0); ok { return v } else { - var zero SCHostStorageErrorCode + var zero SCSpecFunctionV0 u._u = &zero return &zero } default: - XdrPanic("SCStatus.StorageCode accessed when Type == %v", u.Type) + XdrPanic("SCSpecEntry.FunctionV0 accessed when Kind == %v", u.Kind) return nil } } -func (u *SCStatus) ContextCode() *SCHostContextErrorCode { - switch u.Type { - case SST_HOST_CONTEXT_ERROR: - if v, ok := u._u.(*SCHostContextErrorCode); ok { +func (u *SCSpecEntry) UdtStructV0() *SCSpecUDTStructV0 { + switch u.Kind { + case SC_SPEC_ENTRY_UDT_STRUCT_V0: + if v, ok := u._u.(*SCSpecUDTStructV0); ok { return v } else { - var zero SCHostContextErrorCode + var zero SCSpecUDTStructV0 u._u = &zero return &zero } default: - XdrPanic("SCStatus.ContextCode accessed when Type == %v", u.Type) + XdrPanic("SCSpecEntry.UdtStructV0 accessed when Kind == %v", u.Kind) return nil } } -func (u *SCStatus) VmCode() *SCVmErrorCode { - switch u.Type { - case SST_VM_ERROR: - if v, ok := u._u.(*SCVmErrorCode); ok { +func (u *SCSpecEntry) UdtUnionV0() *SCSpecUDTUnionV0 { + switch u.Kind { + case SC_SPEC_ENTRY_UDT_UNION_V0: + if v, ok := u._u.(*SCSpecUDTUnionV0); ok { return v } else { - var zero SCVmErrorCode + var zero SCSpecUDTUnionV0 u._u = &zero return &zero } default: - XdrPanic("SCStatus.VmCode accessed when Type == %v", u.Type) + XdrPanic("SCSpecEntry.UdtUnionV0 accessed when Kind == %v", u.Kind) return nil } } -func (u *SCStatus) ContractCode() *Uint32 { - switch u.Type { - case SST_CONTRACT_ERROR: - if v, ok := u._u.(*Uint32); ok { +func (u *SCSpecEntry) UdtEnumV0() *SCSpecUDTEnumV0 { + switch u.Kind { + case SC_SPEC_ENTRY_UDT_ENUM_V0: + if v, ok := u._u.(*SCSpecUDTEnumV0); ok { return v } else { - var zero Uint32 + var zero SCSpecUDTEnumV0 u._u = &zero return &zero } default: - XdrPanic("SCStatus.ContractCode accessed when Type == %v", u.Type) + XdrPanic("SCSpecEntry.UdtEnumV0 accessed when Kind == %v", u.Kind) return nil } } -func (u *SCStatus) AuthCode() *SCHostAuthErrorCode { - switch u.Type { - case SST_HOST_AUTH_ERROR: - if v, ok := u._u.(*SCHostAuthErrorCode); ok { +func (u *SCSpecEntry) UdtErrorEnumV0() *SCSpecUDTErrorEnumV0 { + switch u.Kind { + case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: + if v, ok := u._u.(*SCSpecUDTErrorEnumV0); ok { return v } else { - var zero SCHostAuthErrorCode + var zero SCSpecUDTErrorEnumV0 u._u = &zero return &zero } default: - XdrPanic("SCStatus.AuthCode accessed when Type == %v", u.Type) + XdrPanic("SCSpecEntry.UdtErrorEnumV0 accessed when Kind == %v", u.Kind) return nil } } -func (u SCStatus) XdrValid() bool { - switch u.Type { - case SST_OK, SST_UNKNOWN_ERROR, SST_HOST_VALUE_ERROR, SST_HOST_OBJECT_ERROR, SST_HOST_FUNCTION_ERROR, SST_HOST_STORAGE_ERROR, SST_HOST_CONTEXT_ERROR, SST_VM_ERROR, SST_CONTRACT_ERROR, SST_HOST_AUTH_ERROR: +func (u SCSpecEntry) XdrValid() bool { + switch u.Kind { + case SC_SPEC_ENTRY_FUNCTION_V0, SC_SPEC_ENTRY_UDT_STRUCT_V0, SC_SPEC_ENTRY_UDT_UNION_V0, SC_SPEC_ENTRY_UDT_ENUM_V0, SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: return true } return false } -func (u *SCStatus) XdrUnionTag() XdrNum32 { - return XDR_SCStatusType(&u.Type) +func (u *SCSpecEntry) XdrUnionTag() XdrNum32 { + return XDR_SCSpecEntryKind(&u.Kind) } -func (u *SCStatus) XdrUnionTagName() string { - return "Type" +func (u *SCSpecEntry) XdrUnionTagName() string { + return "Kind" } -func (u *SCStatus) XdrUnionBody() XdrType { - switch u.Type { - case SST_OK: - return nil - case SST_UNKNOWN_ERROR: - return XDR_SCUnknownErrorCode(u.UnknownCode()) - case SST_HOST_VALUE_ERROR: - return XDR_SCHostValErrorCode(u.ValCode()) - case SST_HOST_OBJECT_ERROR: - return XDR_SCHostObjErrorCode(u.ObjCode()) - case SST_HOST_FUNCTION_ERROR: - return XDR_SCHostFnErrorCode(u.FnCode()) - case SST_HOST_STORAGE_ERROR: - return XDR_SCHostStorageErrorCode(u.StorageCode()) - case SST_HOST_CONTEXT_ERROR: - return XDR_SCHostContextErrorCode(u.ContextCode()) - case SST_VM_ERROR: - return XDR_SCVmErrorCode(u.VmCode()) - case SST_CONTRACT_ERROR: - return XDR_Uint32(u.ContractCode()) - case SST_HOST_AUTH_ERROR: - return XDR_SCHostAuthErrorCode(u.AuthCode()) +func (u *SCSpecEntry) XdrUnionBody() XdrType { + switch u.Kind { + case SC_SPEC_ENTRY_FUNCTION_V0: + return XDR_SCSpecFunctionV0(u.FunctionV0()) + case SC_SPEC_ENTRY_UDT_STRUCT_V0: + return XDR_SCSpecUDTStructV0(u.UdtStructV0()) + case SC_SPEC_ENTRY_UDT_UNION_V0: + return XDR_SCSpecUDTUnionV0(u.UdtUnionV0()) + case SC_SPEC_ENTRY_UDT_ENUM_V0: + return XDR_SCSpecUDTEnumV0(u.UdtEnumV0()) + case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: + return XDR_SCSpecUDTErrorEnumV0(u.UdtErrorEnumV0()) } return nil } -func (u *SCStatus) XdrUnionBodyName() string { - switch u.Type { - case SST_OK: - return "" - case SST_UNKNOWN_ERROR: - return "UnknownCode" - case SST_HOST_VALUE_ERROR: - return "ValCode" - case SST_HOST_OBJECT_ERROR: - return "ObjCode" - case SST_HOST_FUNCTION_ERROR: - return "FnCode" - case SST_HOST_STORAGE_ERROR: - return "StorageCode" - case SST_HOST_CONTEXT_ERROR: - return "ContextCode" - case SST_VM_ERROR: - return "VmCode" - case SST_CONTRACT_ERROR: - return "ContractCode" - case SST_HOST_AUTH_ERROR: - return "AuthCode" +func (u *SCSpecEntry) XdrUnionBodyName() string { + switch u.Kind { + case SC_SPEC_ENTRY_FUNCTION_V0: + return "FunctionV0" + case SC_SPEC_ENTRY_UDT_STRUCT_V0: + return "UdtStructV0" + case SC_SPEC_ENTRY_UDT_UNION_V0: + return "UdtUnionV0" + case SC_SPEC_ENTRY_UDT_ENUM_V0: + return "UdtEnumV0" + case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: + return "UdtErrorEnumV0" } return "" } -type XdrType_SCStatus = *SCStatus +type XdrType_SCSpecEntry = *SCSpecEntry -func (v *SCStatus) XdrPointer() interface{} { return v } -func (SCStatus) XdrTypeName() string { return "SCStatus" } -func (v SCStatus) XdrValue() interface{} { return v } -func (v *SCStatus) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } -func (u *SCStatus) XdrRecurse(x XDR, name string) { +func (v *SCSpecEntry) XdrPointer() interface{} { return v } +func (SCSpecEntry) XdrTypeName() string { return "SCSpecEntry" } +func (v SCSpecEntry) XdrValue() interface{} { return v } +func (v *SCSpecEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (u *SCSpecEntry) XdrRecurse(x XDR, name string) { if name != "" { name = x.Sprintf("%s.", name) } - XDR_SCStatusType(&u.Type).XdrMarshal(x, x.Sprintf("%stype", name)) - switch u.Type { - case SST_OK: - return - case SST_UNKNOWN_ERROR: - x.Marshal(x.Sprintf("%sunknownCode", name), XDR_SCUnknownErrorCode(u.UnknownCode())) - return - case SST_HOST_VALUE_ERROR: - x.Marshal(x.Sprintf("%svalCode", name), XDR_SCHostValErrorCode(u.ValCode())) - return - case SST_HOST_OBJECT_ERROR: - x.Marshal(x.Sprintf("%sobjCode", name), XDR_SCHostObjErrorCode(u.ObjCode())) - return - case SST_HOST_FUNCTION_ERROR: - x.Marshal(x.Sprintf("%sfnCode", name), XDR_SCHostFnErrorCode(u.FnCode())) - return - case SST_HOST_STORAGE_ERROR: - x.Marshal(x.Sprintf("%sstorageCode", name), XDR_SCHostStorageErrorCode(u.StorageCode())) + XDR_SCSpecEntryKind(&u.Kind).XdrMarshal(x, x.Sprintf("%skind", name)) + switch u.Kind { + case SC_SPEC_ENTRY_FUNCTION_V0: + x.Marshal(x.Sprintf("%sfunctionV0", name), XDR_SCSpecFunctionV0(u.FunctionV0())) return - case SST_HOST_CONTEXT_ERROR: - x.Marshal(x.Sprintf("%scontextCode", name), XDR_SCHostContextErrorCode(u.ContextCode())) + case SC_SPEC_ENTRY_UDT_STRUCT_V0: + x.Marshal(x.Sprintf("%sudtStructV0", name), XDR_SCSpecUDTStructV0(u.UdtStructV0())) return - case SST_VM_ERROR: - x.Marshal(x.Sprintf("%svmCode", name), XDR_SCVmErrorCode(u.VmCode())) + case SC_SPEC_ENTRY_UDT_UNION_V0: + x.Marshal(x.Sprintf("%sudtUnionV0", name), XDR_SCSpecUDTUnionV0(u.UdtUnionV0())) return - case SST_CONTRACT_ERROR: - x.Marshal(x.Sprintf("%scontractCode", name), XDR_Uint32(u.ContractCode())) + case SC_SPEC_ENTRY_UDT_ENUM_V0: + x.Marshal(x.Sprintf("%sudtEnumV0", name), XDR_SCSpecUDTEnumV0(u.UdtEnumV0())) return - case SST_HOST_AUTH_ERROR: - x.Marshal(x.Sprintf("%sauthCode", name), XDR_SCHostAuthErrorCode(u.AuthCode())) + case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0: + x.Marshal(x.Sprintf("%sudtErrorEnumV0", name), XDR_SCSpecUDTErrorEnumV0(u.UdtErrorEnumV0())) return } - XdrPanic("invalid Type (%v) in SCStatus", u.Type) + XdrPanic("invalid Kind (%v) in SCSpecEntry", u.Kind) +} +func XDR_SCSpecEntry(v *SCSpecEntry) *SCSpecEntry { return v } + +var _XdrNames_SCValType = map[int32]string{ + int32(SCV_BOOL): "SCV_BOOL", + int32(SCV_VOID): "SCV_VOID", + int32(SCV_ERROR): "SCV_ERROR", + int32(SCV_U32): "SCV_U32", + int32(SCV_I32): "SCV_I32", + int32(SCV_U64): "SCV_U64", + int32(SCV_I64): "SCV_I64", + int32(SCV_TIMEPOINT): "SCV_TIMEPOINT", + int32(SCV_DURATION): "SCV_DURATION", + int32(SCV_U128): "SCV_U128", + int32(SCV_I128): "SCV_I128", + int32(SCV_U256): "SCV_U256", + int32(SCV_I256): "SCV_I256", + int32(SCV_BYTES): "SCV_BYTES", + int32(SCV_STRING): "SCV_STRING", + int32(SCV_SYMBOL): "SCV_SYMBOL", + int32(SCV_VEC): "SCV_VEC", + int32(SCV_MAP): "SCV_MAP", + int32(SCV_CONTRACT_EXECUTABLE): "SCV_CONTRACT_EXECUTABLE", + int32(SCV_ADDRESS): "SCV_ADDRESS", + int32(SCV_LEDGER_KEY_CONTRACT_EXECUTABLE): "SCV_LEDGER_KEY_CONTRACT_EXECUTABLE", + int32(SCV_LEDGER_KEY_NONCE): "SCV_LEDGER_KEY_NONCE", +} +var _XdrValues_SCValType = map[string]int32{ + "SCV_BOOL": int32(SCV_BOOL), + "SCV_VOID": int32(SCV_VOID), + "SCV_ERROR": int32(SCV_ERROR), + "SCV_U32": int32(SCV_U32), + "SCV_I32": int32(SCV_I32), + "SCV_U64": int32(SCV_U64), + "SCV_I64": int32(SCV_I64), + "SCV_TIMEPOINT": int32(SCV_TIMEPOINT), + "SCV_DURATION": int32(SCV_DURATION), + "SCV_U128": int32(SCV_U128), + "SCV_I128": int32(SCV_I128), + "SCV_U256": int32(SCV_U256), + "SCV_I256": int32(SCV_I256), + "SCV_BYTES": int32(SCV_BYTES), + "SCV_STRING": int32(SCV_STRING), + "SCV_SYMBOL": int32(SCV_SYMBOL), + "SCV_VEC": int32(SCV_VEC), + "SCV_MAP": int32(SCV_MAP), + "SCV_CONTRACT_EXECUTABLE": int32(SCV_CONTRACT_EXECUTABLE), + "SCV_ADDRESS": int32(SCV_ADDRESS), + "SCV_LEDGER_KEY_CONTRACT_EXECUTABLE": int32(SCV_LEDGER_KEY_CONTRACT_EXECUTABLE), + "SCV_LEDGER_KEY_NONCE": int32(SCV_LEDGER_KEY_NONCE), +} + +func (SCValType) XdrEnumNames() map[int32]string { + return _XdrNames_SCValType +} +func (v SCValType) String() string { + if s, ok := _XdrNames_SCValType[int32(v)]; ok { + return s + } + return fmt.Sprintf("SCValType#%d", v) +} +func (v *SCValType) 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_SCValType[stok]; ok { + *v = SCValType(val) + return nil + } else if stok == "SCValType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid SCValType.", stok)) + } +} +func (v SCValType) GetU32() uint32 { return uint32(v) } +func (v *SCValType) SetU32(n uint32) { *v = SCValType(n) } +func (v *SCValType) XdrPointer() interface{} { return v } +func (SCValType) XdrTypeName() string { return "SCValType" } +func (v SCValType) XdrValue() interface{} { return v } +func (v *SCValType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_SCValType = *SCValType + +func XDR_SCValType(v *SCValType) *SCValType { return v } + +var _XdrComments_SCValType = map[int32]string{ + int32(SCV_U32): "32 bits is the smallest type in WASM or XDR; no need for u8/u16.", + int32(SCV_U64): "64 bits is naturally supported by both WASM and XDR also.", + int32(SCV_TIMEPOINT): "Time-related u64 subtypes with their own functions and formatting.", + int32(SCV_U128): "128 bits is naturally supported by Rust and we use it for Soroban fixed-point arithmetic prices / balances / similar \"quantities\". These are represented in XDR as a pair of 2 u64s, unlike {u,i}256 which is represented as an array of 32 bytes.", + int32(SCV_U256): "256 bits is the size of sha256 output, ed25519 keys, and the EVM machine word, so for interop use we include this even though it requires a small amount of Rust guest and/or host library code.", + int32(SCV_BYTES): "Bytes come in 3 flavors, 2 of which have meaningfully different formatting and validity-checking / domain-restriction.", + int32(SCV_VEC): "Vecs and maps are just polymorphic containers of other ScVals.", + int32(SCV_CONTRACT_EXECUTABLE): "SCContractExecutable and SCAddressType are types that gets used separately from SCVal so we do not flatten their structures into separate SCVal cases.", + int32(SCV_LEDGER_KEY_CONTRACT_EXECUTABLE): "SCV_LEDGER_KEY_CONTRACT_EXECUTABLE and SCV_LEDGER_KEY_NONCE are unique symbolic SCVals used as the key for ledger entries for a contract's code and an address' nonce, respectively.", +} + +func (e SCValType) XdrEnumComments() map[int32]string { + return _XdrComments_SCValType +} + +var _XdrNames_SCErrorType = map[int32]string{ + int32(SCE_CONTRACT): "SCE_CONTRACT", + int32(SCE_WASM_VM): "SCE_WASM_VM", + int32(SCE_CONTEXT): "SCE_CONTEXT", + int32(SCE_STORAGE): "SCE_STORAGE", + int32(SCE_OBJECT): "SCE_OBJECT", + int32(SCE_CRYPTO): "SCE_CRYPTO", + int32(SCE_EVENTS): "SCE_EVENTS", + int32(SCE_BUDGET): "SCE_BUDGET", + int32(SCE_VALUE): "SCE_VALUE", + int32(SCE_AUTH): "SCE_AUTH", +} +var _XdrValues_SCErrorType = map[string]int32{ + "SCE_CONTRACT": int32(SCE_CONTRACT), + "SCE_WASM_VM": int32(SCE_WASM_VM), + "SCE_CONTEXT": int32(SCE_CONTEXT), + "SCE_STORAGE": int32(SCE_STORAGE), + "SCE_OBJECT": int32(SCE_OBJECT), + "SCE_CRYPTO": int32(SCE_CRYPTO), + "SCE_EVENTS": int32(SCE_EVENTS), + "SCE_BUDGET": int32(SCE_BUDGET), + "SCE_VALUE": int32(SCE_VALUE), + "SCE_AUTH": int32(SCE_AUTH), +} + +func (SCErrorType) XdrEnumNames() map[int32]string { + return _XdrNames_SCErrorType +} +func (v SCErrorType) String() string { + if s, ok := _XdrNames_SCErrorType[int32(v)]; ok { + return s + } + return fmt.Sprintf("SCErrorType#%d", v) +} +func (v *SCErrorType) 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_SCErrorType[stok]; ok { + *v = SCErrorType(val) + return nil + } else if stok == "SCErrorType" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid SCErrorType.", stok)) + } +} +func (v SCErrorType) GetU32() uint32 { return uint32(v) } +func (v *SCErrorType) SetU32(n uint32) { *v = SCErrorType(n) } +func (v *SCErrorType) XdrPointer() interface{} { return v } +func (SCErrorType) XdrTypeName() string { return "SCErrorType" } +func (v SCErrorType) XdrValue() interface{} { return v } +func (v *SCErrorType) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_SCErrorType = *SCErrorType + +func XDR_SCErrorType(v *SCErrorType) *SCErrorType { return v } + +var _XdrNames_SCErrorCode = map[int32]string{ + int32(SCEC_ARITH_DOMAIN): "SCEC_ARITH_DOMAIN", + int32(SCEC_INDEX_BOUNDS): "SCEC_INDEX_BOUNDS", + int32(SCEC_INVALID_INPUT): "SCEC_INVALID_INPUT", + int32(SCEC_MISSING_VALUE): "SCEC_MISSING_VALUE", + int32(SCEC_EXISTING_VALUE): "SCEC_EXISTING_VALUE", + int32(SCEC_EXCEEDED_LIMIT): "SCEC_EXCEEDED_LIMIT", + int32(SCEC_INVALID_ACTION): "SCEC_INVALID_ACTION", + int32(SCEC_INTERNAL_ERROR): "SCEC_INTERNAL_ERROR", + int32(SCEC_UNEXPECTED_TYPE): "SCEC_UNEXPECTED_TYPE", + int32(SCEC_UNEXPECTED_SIZE): "SCEC_UNEXPECTED_SIZE", +} +var _XdrValues_SCErrorCode = map[string]int32{ + "SCEC_ARITH_DOMAIN": int32(SCEC_ARITH_DOMAIN), + "SCEC_INDEX_BOUNDS": int32(SCEC_INDEX_BOUNDS), + "SCEC_INVALID_INPUT": int32(SCEC_INVALID_INPUT), + "SCEC_MISSING_VALUE": int32(SCEC_MISSING_VALUE), + "SCEC_EXISTING_VALUE": int32(SCEC_EXISTING_VALUE), + "SCEC_EXCEEDED_LIMIT": int32(SCEC_EXCEEDED_LIMIT), + "SCEC_INVALID_ACTION": int32(SCEC_INVALID_ACTION), + "SCEC_INTERNAL_ERROR": int32(SCEC_INTERNAL_ERROR), + "SCEC_UNEXPECTED_TYPE": int32(SCEC_UNEXPECTED_TYPE), + "SCEC_UNEXPECTED_SIZE": int32(SCEC_UNEXPECTED_SIZE), +} + +func (SCErrorCode) XdrEnumNames() map[int32]string { + return _XdrNames_SCErrorCode +} +func (v SCErrorCode) String() string { + if s, ok := _XdrNames_SCErrorCode[int32(v)]; ok { + return s + } + return fmt.Sprintf("SCErrorCode#%d", v) +} +func (v *SCErrorCode) 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_SCErrorCode[stok]; ok { + *v = SCErrorCode(val) + return nil + } else if stok == "SCErrorCode" { + if n, err := fmt.Fscanf(ss, "#%d", (*int32)(v)); n == 1 && err == nil { + return nil + } + } + return XdrError(fmt.Sprintf("%s is not a valid SCErrorCode.", stok)) + } +} +func (v SCErrorCode) GetU32() uint32 { return uint32(v) } +func (v *SCErrorCode) SetU32(n uint32) { *v = SCErrorCode(n) } +func (v *SCErrorCode) XdrPointer() interface{} { return v } +func (SCErrorCode) XdrTypeName() string { return "SCErrorCode" } +func (v SCErrorCode) XdrValue() interface{} { return v } +func (v *SCErrorCode) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } + +type XdrType_SCErrorCode = *SCErrorCode + +func XDR_SCErrorCode(v *SCErrorCode) *SCErrorCode { return v } + +var _XdrComments_SCErrorCode = map[int32]string{ + int32(SCEC_ARITH_DOMAIN): "some arithmetic wasn't defined (overflow, divide-by-zero)", + int32(SCEC_INDEX_BOUNDS): "something was indexed beyond its bounds", + int32(SCEC_INVALID_INPUT): "user provided some otherwise-bad data", + int32(SCEC_MISSING_VALUE): "some value was required but not provided", + int32(SCEC_EXISTING_VALUE): "some value was provided where not allowed", + int32(SCEC_EXCEEDED_LIMIT): "some arbitrary limit -- gas or otherwise -- was hit", + int32(SCEC_INVALID_ACTION): "data was valid but action requested was not", + int32(SCEC_INTERNAL_ERROR): "the internal state of the host was otherwise-bad", + int32(SCEC_UNEXPECTED_TYPE): "some type wasn't as expected", + int32(SCEC_UNEXPECTED_SIZE): "something's size wasn't as expected", +} + +func (e SCErrorCode) XdrEnumComments() map[int32]string { + return _XdrComments_SCErrorCode +} + +type XdrType_SCError = *SCError + +func (v *SCError) XdrPointer() interface{} { return v } +func (SCError) XdrTypeName() string { return "SCError" } +func (v SCError) XdrValue() interface{} { return v } +func (v *SCError) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (v *SCError) XdrRecurse(x XDR, name string) { + if name != "" { + name = x.Sprintf("%s.", name) + } + x.Marshal(x.Sprintf("%stype", name), XDR_SCErrorType(&v.Type)) + x.Marshal(x.Sprintf("%scode", name), XDR_SCErrorCode(&v.Code)) } -func XDR_SCStatus(v *SCStatus) *SCStatus { return v } +func XDR_SCError(v *SCError) *SCError { return v } type XdrType_UInt128Parts = *UInt128Parts @@ -27532,21 +26195,21 @@ func (u *SCAddress) XdrRecurse(x XDR, name string) { } func XDR_SCAddress(v *SCAddress) *SCAddress { return v } -type _XdrVec_256000_SCVal []SCVal +type _XdrVec_unbounded_SCVal []SCVal -func (_XdrVec_256000_SCVal) XdrBound() uint32 { - const bound uint32 = 256000 // Force error if not const or doesn't fit +func (_XdrVec_unbounded_SCVal) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_256000_SCVal) XdrCheckLen(length uint32) { - if length > uint32(256000) { - XdrPanic("_XdrVec_256000_SCVal length %d exceeds bound 256000", length) +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_256000_SCVal length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_SCVal length %d exceeds max int", length) } } -func (v _XdrVec_256000_SCVal) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_256000_SCVal) 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) { @@ -27557,7 +26220,7 @@ func (v *_XdrVec_256000_SCVal) 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(256000); uint(newcap) > bound { + } else if bound := uint(4294967295); uint(newcap) > bound { if int(bound) < 0 { bound = ^uint(0) >> 1 } @@ -27567,7 +26230,7 @@ func (v *_XdrVec_256000_SCVal) SetVecLen(length uint32) { copy(nv, *v) *v = nv } -func (v *_XdrVec_256000_SCVal) 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) { @@ -27579,41 +26242,41 @@ func (v *_XdrVec_256000_SCVal) XdrMarshalN(x XDR, name string, n uint32) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_256000_SCVal) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 256000} +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_256000_SCVal) XdrTypeName() string { return "SCVal<>" } -func (v *_XdrVec_256000_SCVal) XdrPointer() interface{} { return (*[]SCVal)(v) } -func (v _XdrVec_256000_SCVal) XdrValue() interface{} { return ([]SCVal)(v) } -func (v *_XdrVec_256000_SCVal) 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_SCVec struct { - *_XdrVec_256000_SCVal + *_XdrVec_unbounded_SCVal } func XDR_SCVec(v *SCVec) XdrType_SCVec { - return XdrType_SCVec{(*_XdrVec_256000_SCVal)(v)} + return XdrType_SCVec{(*_XdrVec_unbounded_SCVal)(v)} } func (XdrType_SCVec) XdrTypeName() string { return "SCVec" } -func (v XdrType_SCVec) XdrUnwrap() XdrType { return v._XdrVec_256000_SCVal } +func (v XdrType_SCVec) XdrUnwrap() XdrType { return v._XdrVec_unbounded_SCVal } -type _XdrVec_256000_SCMapEntry []SCMapEntry +type _XdrVec_unbounded_SCMapEntry []SCMapEntry -func (_XdrVec_256000_SCMapEntry) XdrBound() uint32 { - const bound uint32 = 256000 // Force error if not const or doesn't fit +func (_XdrVec_unbounded_SCMapEntry) XdrBound() uint32 { + const bound uint32 = 4294967295 // Force error if not const or doesn't fit return bound } -func (_XdrVec_256000_SCMapEntry) XdrCheckLen(length uint32) { - if length > uint32(256000) { - XdrPanic("_XdrVec_256000_SCMapEntry length %d exceeds bound 256000", length) +func (_XdrVec_unbounded_SCMapEntry) XdrCheckLen(length uint32) { + if length > uint32(4294967295) { + XdrPanic("_XdrVec_unbounded_SCMapEntry length %d exceeds bound 4294967295", length) } else if int(length) < 0 { - XdrPanic("_XdrVec_256000_SCMapEntry length %d exceeds max int", length) + XdrPanic("_XdrVec_unbounded_SCMapEntry length %d exceeds max int", length) } } -func (v _XdrVec_256000_SCMapEntry) GetVecLen() uint32 { return uint32(len(v)) } -func (v *_XdrVec_256000_SCMapEntry) SetVecLen(length uint32) { +func (v _XdrVec_unbounded_SCMapEntry) GetVecLen() uint32 { return uint32(len(v)) } +func (v *_XdrVec_unbounded_SCMapEntry) SetVecLen(length uint32) { v.XdrCheckLen(length) if int(length) <= cap(*v) { if int(length) != len(*v) { @@ -27624,7 +26287,7 @@ func (v *_XdrVec_256000_SCMapEntry) 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(256000); uint(newcap) > bound { + } else if bound := uint(4294967295); uint(newcap) > bound { if int(bound) < 0 { bound = ^uint(0) >> 1 } @@ -27634,7 +26297,7 @@ func (v *_XdrVec_256000_SCMapEntry) SetVecLen(length uint32) { copy(nv, *v) *v = nv } -func (v *_XdrVec_256000_SCMapEntry) XdrMarshalN(x XDR, name string, n uint32) { +func (v *_XdrVec_unbounded_SCMapEntry) XdrMarshalN(x XDR, name string, n uint32) { v.XdrCheckLen(n) for i := 0; i < int(n); i++ { if i >= len(*v) { @@ -27646,32 +26309,32 @@ func (v *_XdrVec_256000_SCMapEntry) XdrMarshalN(x XDR, name string, n uint32) { *v = (*v)[:int(n)] } } -func (v *_XdrVec_256000_SCMapEntry) XdrRecurse(x XDR, name string) { - size := XdrSize{Size: uint32(len(*v)), Bound: 256000} +func (v *_XdrVec_unbounded_SCMapEntry) 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_256000_SCMapEntry) XdrTypeName() string { return "SCMapEntry<>" } -func (v *_XdrVec_256000_SCMapEntry) XdrPointer() interface{} { return (*[]SCMapEntry)(v) } -func (v _XdrVec_256000_SCMapEntry) XdrValue() interface{} { return ([]SCMapEntry)(v) } -func (v *_XdrVec_256000_SCMapEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } +func (_XdrVec_unbounded_SCMapEntry) XdrTypeName() string { return "SCMapEntry<>" } +func (v *_XdrVec_unbounded_SCMapEntry) XdrPointer() interface{} { return (*[]SCMapEntry)(v) } +func (v _XdrVec_unbounded_SCMapEntry) XdrValue() interface{} { return ([]SCMapEntry)(v) } +func (v *_XdrVec_unbounded_SCMapEntry) XdrMarshal(x XDR, name string) { x.Marshal(name, v) } type XdrType_SCMap struct { - *_XdrVec_256000_SCMapEntry + *_XdrVec_unbounded_SCMapEntry } func XDR_SCMap(v *SCMap) XdrType_SCMap { - return XdrType_SCMap{(*_XdrVec_256000_SCMapEntry)(v)} + return XdrType_SCMap{(*_XdrVec_unbounded_SCMapEntry)(v)} } func (XdrType_SCMap) XdrTypeName() string { return "SCMap" } -func (v XdrType_SCMap) XdrUnwrap() XdrType { return v._XdrVec_256000_SCMapEntry } +func (v XdrType_SCMap) XdrUnwrap() XdrType { return v._XdrVec_unbounded_SCMapEntry } type XdrType_SCBytes struct { XdrVecOpaque } func XDR_SCBytes(v *SCBytes) XdrType_SCBytes { - return XdrType_SCBytes{XdrVecOpaque{v, SCVAL_LIMIT}} + return XdrType_SCBytes{XdrVecOpaque{v, 0xffffffff}} } func (XdrType_SCBytes) XdrTypeName() string { return "SCBytes" } func (v XdrType_SCBytes) XdrUnwrap() XdrType { return v.XdrVecOpaque } @@ -27681,7 +26344,7 @@ type XdrType_SCString struct { } func XDR_SCString(v *SCString) XdrType_SCString { - return XdrType_SCString{XdrString{v, SCVAL_LIMIT}} + return XdrType_SCString{XdrString{v, 0xffffffff}} } func (XdrType_SCString) XdrTypeName() string { return "SCString" } func (v XdrType_SCString) XdrUnwrap() XdrType { return v.XdrString } @@ -27859,7 +26522,7 @@ func (v _XdrPtr_SCMap) XdrValue() interface{} { return *v.p } var _XdrTags_SCVal = map[int32]bool{ XdrToI32(SCV_BOOL): true, XdrToI32(SCV_VOID): true, - XdrToI32(SCV_STATUS): true, + XdrToI32(SCV_ERROR): true, XdrToI32(SCV_U32): true, XdrToI32(SCV_I32): true, XdrToI32(SCV_U64): true, @@ -27899,13 +26562,13 @@ func (u *SCVal) B() *bool { return nil } } -func (u *SCVal) Error() *SCStatus { +func (u *SCVal) Error() *SCError { switch u.Type { - case SCV_STATUS: - if v, ok := u._u.(*SCStatus); ok { + case SCV_ERROR: + if v, ok := u._u.(*SCError); ok { return v } else { - var zero SCStatus + var zero SCError u._u = &zero return &zero } @@ -28186,7 +26849,7 @@ func (u *SCVal) Nonce_key() *SCNonceKey { } func (u SCVal) XdrValid() bool { switch u.Type { - case SCV_BOOL, SCV_VOID, SCV_STATUS, SCV_U32, SCV_I32, SCV_U64, SCV_I64, SCV_TIMEPOINT, SCV_DURATION, SCV_U128, SCV_I128, SCV_U256, SCV_I256, SCV_BYTES, SCV_STRING, SCV_SYMBOL, SCV_VEC, SCV_MAP, SCV_CONTRACT_EXECUTABLE, SCV_ADDRESS, SCV_LEDGER_KEY_CONTRACT_EXECUTABLE, SCV_LEDGER_KEY_NONCE: + case SCV_BOOL, SCV_VOID, SCV_ERROR, SCV_U32, SCV_I32, SCV_U64, SCV_I64, SCV_TIMEPOINT, SCV_DURATION, SCV_U128, SCV_I128, SCV_U256, SCV_I256, SCV_BYTES, SCV_STRING, SCV_SYMBOL, SCV_VEC, SCV_MAP, SCV_CONTRACT_EXECUTABLE, SCV_ADDRESS, SCV_LEDGER_KEY_CONTRACT_EXECUTABLE, SCV_LEDGER_KEY_NONCE: return true } return false @@ -28203,8 +26866,8 @@ func (u *SCVal) XdrUnionBody() XdrType { return XDR_bool(u.B()) case SCV_VOID: return nil - case SCV_STATUS: - return XDR_SCStatus(u.Error()) + case SCV_ERROR: + return XDR_SCError(u.Error()) case SCV_U32: return XDR_Uint32(u.U32()) case SCV_I32: @@ -28252,7 +26915,7 @@ func (u *SCVal) XdrUnionBodyName() string { return "B" case SCV_VOID: return "" - case SCV_STATUS: + case SCV_ERROR: return "Error" case SCV_U32: return "U32" @@ -28313,8 +26976,8 @@ func (u *SCVal) XdrRecurse(x XDR, name string) { return case SCV_VOID: return - case SCV_STATUS: - x.Marshal(x.Sprintf("%serror", name), XDR_SCStatus(u.Error())) + case SCV_ERROR: + x.Marshal(x.Sprintf("%serror", name), XDR_SCError(u.Error())) return case SCV_U32: x.Marshal(x.Sprintf("%su32", name), XDR_Uint32(u.U32())) diff --git a/ingest/ledger_transaction.go b/ingest/ledger_transaction.go index 83bf25eadc..9be801ec45 100644 --- a/ingest/ledger_transaction.go +++ b/ingest/ledger_transaction.go @@ -152,8 +152,8 @@ func operationChanges(ops []xdr.OperationMeta, index uint32) []Change { ) } -// GetOperationEvents returns all contract events emitted by a given operation. -func (t *LedgerTransaction) GetOperationEvents(operationIndex uint32) ([]xdr.DiagnosticEvent, error) { +// GetDiagnosticEvents returns all contract events emitted by a given operation. +func (t *LedgerTransaction) GetDiagnosticEvents() ([]xdr.DiagnosticEvent, error) { // Ignore operations meta if txInternalError https://github.com/stellar/go/issues/2111 if t.txInternalError() { return nil, nil @@ -165,29 +165,29 @@ func (t *LedgerTransaction) GetOperationEvents(operationIndex uint32) ([]xdr.Dia case 2: return nil, nil case 3: - diagnosticEventsByOperation := t.UnsafeMeta.MustV3().DiagnosticEvents - if int(operationIndex) < len(diagnosticEventsByOperation) { + diagnosticEvents := t.UnsafeMeta.MustV3().DiagnosticEvents + if len(diagnosticEvents) > 0 { // all contract events and diag events for a single operation(by it's index in the tx) were available // in tx meta's DiagnosticEvents, no need to look anywhere else for events - return diagnosticEventsByOperation[operationIndex].Events, nil + return diagnosticEvents, nil } - eventsByOperation := t.UnsafeMeta.MustV3().Events - if int(operationIndex) >= len(eventsByOperation) { + + contractEvents := t.UnsafeMeta.MustV3().Events + if len(contractEvents) == 0 { // no events were present in this tx meta return nil, nil } // tx meta only provided contract events, no diagnostic events, we convert the contract // event to a diagnostic event, to fit the response interface. - events := eventsByOperation[operationIndex].Events - diagnosticEvents := make([]xdr.DiagnosticEvent, len(events)) - for i, event := range events { - diagnosticEvents[i] = xdr.DiagnosticEvent{ + convertedDiagnosticEvents := make([]xdr.DiagnosticEvent, len(contractEvents)) + for i, event := range contractEvents { + convertedDiagnosticEvents[i] = xdr.DiagnosticEvent{ InSuccessfulContractCall: true, Event: event, } } - return diagnosticEvents, nil + return convertedDiagnosticEvents, nil default: return nil, fmt.Errorf("unsupported TransactionMeta version: %v", t.UnsafeMeta.V) } diff --git a/ingest/ledger_transaction_test.go b/ingest/ledger_transaction_test.go index 630a341022..9484f8e7e0 100644 --- a/ingest/ledger_transaction_test.go +++ b/ingest/ledger_transaction_test.go @@ -21,95 +21,70 @@ func TestChangeAccountChangedExceptSignersInvalidType(t *testing.T) { require.NoError(t, err) } -func TestGetOperationEvents(t *testing.T) { - values := make([]xdr.Uint32, 3) - for i := range values { - values[i] = xdr.Uint32(i) +func TestGetContractEventsEmpty(t *testing.T) { + tx := LedgerTransaction{ + FeeChanges: xdr.LedgerEntryChanges{}, + UnsafeMeta: xdr.TransactionMeta{ + V: 3, + V3: &xdr.TransactionMetaV3{ + Events: []xdr.ContractEvent{}, + }, + }, } + + events, err := tx.GetDiagnosticEvents() + assert.NoError(t, err) + assert.Empty(t, events) +} + +func TestGetContractEventsSingle(t *testing.T) { + value := xdr.Uint32(1) tx := LedgerTransaction{ FeeChanges: xdr.LedgerEntryChanges{}, UnsafeMeta: xdr.TransactionMeta{ V: 3, V3: &xdr.TransactionMetaV3{ - Events: []xdr.OperationEvents{ - {Events: []xdr.ContractEvent{ - { - Type: xdr.ContractEventTypeSystem, - Body: xdr.ContractEventBody{ - V: 0, - V0: &xdr.ContractEventV0{ - Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[0]}, - }, - }, - }, - }}, - {Events: []xdr.ContractEvent{}}, - {Events: []xdr.ContractEvent{ - { - Type: xdr.ContractEventTypeSystem, - Body: xdr.ContractEventBody{ - V: 0, - V0: &xdr.ContractEventV0{ - Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[1]}, - }, - }, - }, - { - Type: xdr.ContractEventTypeSystem, - Body: xdr.ContractEventBody{ - V: 0, - V0: &xdr.ContractEventV0{ - Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[2]}, - }, + Events: []xdr.ContractEvent{ + { + Type: xdr.ContractEventTypeSystem, + Body: xdr.ContractEventBody{ + V: 0, + V0: &xdr.ContractEventV0{ + Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &value}, }, }, - }}, + }, }, }, - }} - events, err := tx.GetOperationEvents(0) - assert.NoError(t, err) - assert.Len(t, events, 1) - assert.True(t, events[0].InSuccessfulContractCall) - assert.Equal(t, *events[0].Event.Body.V0.Data.U32, values[0]) - - events, err = tx.GetOperationEvents(1) - assert.NoError(t, err) - assert.Empty(t, events) + }, + } - events, err = tx.GetOperationEvents(2) - assert.NoError(t, err) - assert.Len(t, events, 2) + events, err := tx.GetDiagnosticEvents() + assert.Len(t, events, 1) assert.True(t, events[0].InSuccessfulContractCall) - assert.Equal(t, *events[0].Event.Body.V0.Data.U32, values[1]) - assert.True(t, events[1].InSuccessfulContractCall) - assert.Equal(t, *events[1].Event.Body.V0.Data.U32, values[2]) - - events, err = tx.GetOperationEvents(3) - assert.NoError(t, err) - assert.Empty(t, events) + assert.Equal(t, *events[0].Event.Body.V0.Data.U32, value) tx.UnsafeMeta.V = 0 - _, err = tx.GetOperationEvents(0) + _, err = tx.GetDiagnosticEvents() assert.EqualError(t, err, "unsupported TransactionMeta version: 0") tx.UnsafeMeta.V = 4 - _, err = tx.GetOperationEvents(0) + _, err = tx.GetDiagnosticEvents() assert.EqualError(t, err, "unsupported TransactionMeta version: 4") tx.UnsafeMeta.V = 1 - events, err = tx.GetOperationEvents(0) + events, err = tx.GetDiagnosticEvents() assert.NoError(t, err) assert.Empty(t, events) tx.UnsafeMeta.V = 2 - events, err = tx.GetOperationEvents(0) + events, err = tx.GetDiagnosticEvents() assert.NoError(t, err) assert.Empty(t, events) } -func TestGetDiagnosticEvents(t *testing.T) { - values := make([]xdr.Uint32, 3) +func TestGetContractEventsMultiple(t *testing.T) { + values := make([]xdr.Uint32, 2) for i := range values { values[i] = xdr.Uint32(i) } @@ -118,91 +93,154 @@ func TestGetDiagnosticEvents(t *testing.T) { UnsafeMeta: xdr.TransactionMeta{ V: 3, V3: &xdr.TransactionMetaV3{ - DiagnosticEvents: []xdr.OperationDiagnosticEvents{ - {Events: []xdr.DiagnosticEvent{ - { - InSuccessfulContractCall: false, - Event: xdr.ContractEvent{ - Type: xdr.ContractEventTypeSystem, - Body: xdr.ContractEventBody{ - V: 0, - V0: &xdr.ContractEventV0{ - Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[0]}, - }, - }, + Events: []xdr.ContractEvent{ + { + Type: xdr.ContractEventTypeSystem, + Body: xdr.ContractEventBody{ + V: 0, + V0: &xdr.ContractEventV0{ + Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[0]}, }, }, - }}, - {Events: []xdr.DiagnosticEvent{}}, - {Events: []xdr.DiagnosticEvent{ - { - InSuccessfulContractCall: true, - - Event: xdr.ContractEvent{ - Type: xdr.ContractEventTypeSystem, - Body: xdr.ContractEventBody{ - V: 0, - V0: &xdr.ContractEventV0{ - Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[1]}, - }, - }, - }}, - { - InSuccessfulContractCall: true, - Event: xdr.ContractEvent{ - Type: xdr.ContractEventTypeSystem, - Body: xdr.ContractEventBody{ - V: 0, - V0: &xdr.ContractEventV0{ - Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[2]}, - }, - }, - }}, - }}, + }, + { + Type: xdr.ContractEventTypeSystem, + Body: xdr.ContractEventBody{ + V: 0, + V0: &xdr.ContractEventV0{ + Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[1]}, + }, + }, + }, }, }, - }} - events, err := tx.GetOperationEvents(0) + }, + } + events, err := tx.GetDiagnosticEvents() assert.NoError(t, err) - assert.Len(t, events, 1) - assert.False(t, events[0].InSuccessfulContractCall) + assert.Len(t, events, 2) + assert.True(t, events[0].InSuccessfulContractCall) assert.Equal(t, *events[0].Event.Body.V0.Data.U32, values[0]) + assert.True(t, events[1].InSuccessfulContractCall) + assert.Equal(t, *events[1].Event.Body.V0.Data.U32, values[1]) +} + +func TestGetDiagnosticEventsEmpty(t *testing.T) { + tx := LedgerTransaction{ + FeeChanges: xdr.LedgerEntryChanges{}, + UnsafeMeta: xdr.TransactionMeta{ + V: 3, + V3: &xdr.TransactionMetaV3{ + DiagnosticEvents: []xdr.DiagnosticEvent{}, + }, + }, + } - events, err = tx.GetOperationEvents(1) + events, err := tx.GetDiagnosticEvents() assert.NoError(t, err) assert.Empty(t, events) +} - events, err = tx.GetOperationEvents(2) - assert.NoError(t, err) - assert.Len(t, events, 2) - assert.True(t, events[0].InSuccessfulContractCall) - assert.Equal(t, *events[0].Event.Body.V0.Data.U32, values[1]) - assert.True(t, events[1].InSuccessfulContractCall) - assert.Equal(t, *events[1].Event.Body.V0.Data.U32, values[2]) +func TestGetDiagnosticEventsSingle(t *testing.T) { + value := xdr.Uint32(1) + tx := LedgerTransaction{ + FeeChanges: xdr.LedgerEntryChanges{}, + UnsafeMeta: xdr.TransactionMeta{ + V: 3, + V3: &xdr.TransactionMetaV3{ + DiagnosticEvents: []xdr.DiagnosticEvent{ + { + InSuccessfulContractCall: false, + Event: xdr.ContractEvent{ + Type: xdr.ContractEventTypeSystem, + Body: xdr.ContractEventBody{ + V: 0, + V0: &xdr.ContractEventV0{ + Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &value}, + }, + }, + }, + }, + }, + }, + }, + } - events, err = tx.GetOperationEvents(3) + events, err := tx.GetDiagnosticEvents() assert.NoError(t, err) - assert.Empty(t, events) + assert.Len(t, events, 1) + assert.False(t, events[0].InSuccessfulContractCall) + assert.Equal(t, *events[0].Event.Body.V0.Data.U32, value) tx.UnsafeMeta.V = 0 - _, err = tx.GetOperationEvents(0) + _, err = tx.GetDiagnosticEvents() assert.EqualError(t, err, "unsupported TransactionMeta version: 0") tx.UnsafeMeta.V = 4 - _, err = tx.GetOperationEvents(0) + _, err = tx.GetDiagnosticEvents() assert.EqualError(t, err, "unsupported TransactionMeta version: 4") tx.UnsafeMeta.V = 1 - events, err = tx.GetOperationEvents(0) + events, err = tx.GetDiagnosticEvents() assert.NoError(t, err) assert.Empty(t, events) tx.UnsafeMeta.V = 2 - events, err = tx.GetOperationEvents(0) + events, err = tx.GetDiagnosticEvents() assert.NoError(t, err) assert.Empty(t, events) } +func TestGetDiagnosticEventsMultiple(t *testing.T) { + values := make([]xdr.Uint32, 2) + for i := range values { + values[i] = xdr.Uint32(i) + } + tx := LedgerTransaction{ + FeeChanges: xdr.LedgerEntryChanges{}, + UnsafeMeta: xdr.TransactionMeta{ + V: 3, + V3: &xdr.TransactionMetaV3{ + DiagnosticEvents: []xdr.DiagnosticEvent{ + { + InSuccessfulContractCall: true, + + Event: xdr.ContractEvent{ + Type: xdr.ContractEventTypeSystem, + Body: xdr.ContractEventBody{ + V: 0, + V0: &xdr.ContractEventV0{ + Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[0]}, + }, + }, + }, + }, + { + InSuccessfulContractCall: true, + Event: xdr.ContractEvent{ + Type: xdr.ContractEventTypeSystem, + Body: xdr.ContractEventBody{ + V: 0, + V0: &xdr.ContractEventV0{ + Data: xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &values[1]}, + }, + }, + }, + }, + }, + }, + }, + } + + events, err := tx.GetDiagnosticEvents() + assert.NoError(t, err) + assert.Len(t, events, 2) + assert.True(t, events[0].InSuccessfulContractCall) + assert.Equal(t, *events[0].Event.Body.V0.Data.U32, values[0]) + assert.True(t, events[1].InSuccessfulContractCall) + assert.Equal(t, *events[1].Event.Body.V0.Data.U32, values[1]) +} + func TestFeeMetaAndOperationsChangesSeparate(t *testing.T) { tx := LedgerTransaction{ FeeChanges: xdr.LedgerEntryChanges{ diff --git a/ingest/ledgerbackend/captive_core_backend.go b/ingest/ledgerbackend/captive_core_backend.go index 62b848106a..a0f7c99821 100644 --- a/ingest/ledgerbackend/captive_core_backend.go +++ b/ingest/ledgerbackend/captive_core_backend.go @@ -97,6 +97,12 @@ type CaptiveStellarCore struct { // cachedMeta keeps that ledger data of the last fetched ledger. Updated in GetLedger(). cachedMeta *xdr.LedgerCloseMeta + // ledgerSequenceLock mutex is used to protect the member variables used in the + // read-only GetLatestLedgerSequence method from concurrent write operations. + // This is required when GetLatestLedgerSequence is called from other goroutine + // such as writing Prometheus metric captive_stellar_core_latest_ledger. + ledgerSequenceLock sync.RWMutex + prepared *Range // non-nil if any range is prepared closed bool // False until the core is closed nextLedger uint32 // next ledger expected, error w/ restart if not seen @@ -307,6 +313,9 @@ func (c *CaptiveStellarCore) openOfflineReplaySubprocess(from, to uint32) error // The next ledger should be the first ledger of the checkpoint containing // the requested ledger ran := BoundedRange(from, to) + c.ledgerSequenceLock.Lock() + defer c.ledgerSequenceLock.Unlock() + c.prepared = &ran c.nextLedger = c.roundDownToFirstReplayAfterCheckpointStart(from) c.lastLedger = &to @@ -330,6 +339,9 @@ func (c *CaptiveStellarCore) openOnlineReplaySubprocess(ctx context.Context, fro // In the online mode we update nextLedger after streaming the first ledger. // This is to support versions before and after/including v17.1.0 that // introduced minimal persistent DB. + c.ledgerSequenceLock.Lock() + defer c.ledgerSequenceLock.Unlock() + c.nextLedger = 0 ran := UnboundedRange(from) c.prepared = &ran @@ -647,7 +659,10 @@ func (c *CaptiveStellarCore) handleMetaPipeResult(sequence uint32, result metaRe ) } + c.ledgerSequenceLock.Lock() c.nextLedger = result.LedgerSequence() + 1 + c.ledgerSequenceLock.Unlock() + currentLedgerHash := result.LedgerCloseMeta.LedgerHash().HexString() c.previousLedgerHash = ¤tLedgerHash @@ -708,6 +723,9 @@ func (c *CaptiveStellarCore) GetLatestLedgerSequence(ctx context.Context) (uint3 c.stellarCoreLock.RLock() defer c.stellarCoreLock.RUnlock() + c.ledgerSequenceLock.RLock() + defer c.ledgerSequenceLock.RUnlock() + if c.closed { return 0, errors.New("stellar-core is no longer usable") } diff --git a/ingest/ledgerbackend/captive_core_backend_test.go b/ingest/ledgerbackend/captive_core_backend_test.go index 709551f810..df8ad1ce59 100644 --- a/ingest/ledgerbackend/captive_core_backend_test.go +++ b/ingest/ledgerbackend/captive_core_backend_test.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "fmt" "os" + "sync" "testing" "github.com/stretchr/testify/assert" @@ -645,6 +646,71 @@ func TestGetLatestLedgerSequence(t *testing.T) { mockRunner.AssertExpectations(t) } +func TestGetLatestLedgerSequenceRaceCondition(t *testing.T) { + var fromSeq uint32 = 64 + var toSeq uint32 = 400 + metaChan := make(chan metaResult, toSeq) + + for i := fromSeq; i <= toSeq; i++ { + meta := buildLedgerCloseMeta(testLedgerHeader{sequence: i}) + metaChan <- metaResult{ + LedgerCloseMeta: &meta, + } + } + ctx, cancel := context.WithCancel(context.Background()) + mockRunner := &stellarCoreRunnerMock{} + mockRunner.On("getMetaPipe").Return((<-chan metaResult)(metaChan)) + mockRunner.On("context").Return(ctx) + mockRunner.On("runFrom", mock.Anything, mock.Anything).Return(nil) + + mockArchive := &historyarchive.MockArchive{} + mockArchive. + On("GetRootHAS"). + Return(historyarchive.HistoryArchiveState{ + CurrentLedger: toSeq * 2, + }, nil) + + mockArchive. + On("GetLedgerHeader", mock.Anything). + Return(xdr.LedgerHeaderHistoryEntry{}, nil) + + captiveBackend := CaptiveStellarCore{ + archive: mockArchive, + stellarCoreRunnerFactory: func() stellarCoreRunnerInterface { + return mockRunner + }, + checkpointManager: historyarchive.NewCheckpointManager(10), + } + + ledgerRange := UnboundedRange(fromSeq) + err := captiveBackend.PrepareRange(ctx, ledgerRange) + assert.NoError(t, err) + + var wg sync.WaitGroup + wg.Add(1) + + go func(ctx context.Context) { + defer wg.Done() + for { + select { + case <-ctx.Done(): + return + default: + _, _ = captiveBackend.GetLatestLedgerSequence(ctx) + } + } + }(ctx) + + for i := fromSeq; i < toSeq; i++ { + _, err = captiveBackend.GetLedger(ctx, i) + assert.NoError(t, err) + } + + cancel() + + wg.Wait() +} + func TestCaptiveGetLedger(t *testing.T) { tt := assert.New(t) metaChan := make(chan metaResult, 300) diff --git a/ingest/ledgerbackend/toml.go b/ingest/ledgerbackend/toml.go index c9cf7b0c92..68145b517e 100644 --- a/ingest/ledgerbackend/toml.go +++ b/ingest/ledgerbackend/toml.go @@ -70,11 +70,12 @@ type captiveCoreTomlValues struct { BucketDirPath string `toml:"BUCKET_DIR_PATH,omitempty"` // we cannot omitempty because 0 is a valid configuration for HTTP_PORT // and the default is 11626 - HTTPPort uint `toml:"HTTP_PORT"` - PublicHTTPPort bool `toml:"PUBLIC_HTTP_PORT,omitempty"` - NodeNames []string `toml:"NODE_NAMES,omitempty"` - NetworkPassphrase string `toml:"NETWORK_PASSPHRASE,omitempty"` - PeerPort uint `toml:"PEER_PORT,omitempty"` + HTTPPort uint `toml:"HTTP_PORT"` + PublicHTTPPort bool `toml:"PUBLIC_HTTP_PORT,omitempty"` + NodeNames []string `toml:"NODE_NAMES,omitempty"` + NetworkPassphrase string `toml:"NETWORK_PASSPHRASE,omitempty"` + PeerPort uint `toml:"PEER_PORT,omitempty"` + LimitTxQueueSourceAccount bool `toml:"LIMIT_TX_QUEUE_SOURCE_ACCOUNT,omitempty"` // we cannot omitempty because 0 is a valid configuration for FAILURE_SAFETY // and the default is -1 FailureSafety int `toml:"FAILURE_SAFETY"` diff --git a/protocols/horizon/operations/main.go b/protocols/horizon/operations/main.go index 2ead2ee5ee..6bdfb28c8d 100644 --- a/protocols/horizon/operations/main.go +++ b/protocols/horizon/operations/main.go @@ -347,7 +347,7 @@ type LiquidityPoolWithdraw struct { // InvokeHostFunction is the json resource representing a single InvokeHostFunctionOp. // The model for InvokeHostFunction assimilates InvokeHostFunctionOp, but is simplified. -// Functions - list of contract function invocations performed. +// HostFunction - contract function invocation to be performed. // AssetBalanceChanges - array of asset balance changed records related to contract invocations in this host invocation. // // The asset balance change record is captured at ingestion time from the asset contract @@ -357,19 +357,19 @@ type LiquidityPoolWithdraw struct { // as there is no explicit model in horizon for contract addresses yet. type InvokeHostFunction struct { Base - HostFunctions []HostFunction `json:"host_functions"` + Function string `json:"function"` + Parameters []HostFunctionParameter `json:"parameters"` + Type string `json:"type"` + Address string `json:"address"` + Salt string `json:"salt"` AssetBalanceChanges []AssetContractBalanceChange `json:"asset_balance_changes"` } -// HostFunction has the values specific to a single host function invocation -// Type - the type of host function, invoke_contract, create_contract, upload_wasm -// Parameters - array of key,value tuples for each function parameter. -// -// one key that will always be incluced is 'type' which will be one of: -// xdr.ScValTypeScv's ( Sym, I32, U32, U64, Bytes, B ) or 'n/a' or 'string' -type HostFunction struct { - Type string `json:"type"` - Parameters []map[string]string `json:"parameters"` +// InvokeHostFunction parameter model, intentionally simplified, Value +// just contains a base64 encoded string of the ScVal xdr serialization. +type HostFunctionParameter struct { + Value string `json:"value"` + Type string `json:"type"` } // Type - refers to the source SAC Event diff --git a/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg b/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg new file mode 100644 index 0000000000..74887c3d48 --- /dev/null +++ b/services/horizon/docker/captive-core-integration-tests.soroban-rpc.cfg @@ -0,0 +1,13 @@ +PEER_PORT=11725 +ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true + +UNSAFE_QUORUM=true +FAILURE_SAFETY=0 + +[[VALIDATORS]] +NAME="local_core" +HOME_DOMAIN="core.local" +# From "SACJC372QBSSKJYTV5A7LWT4NXWHTQO6GHG4QDAVC2XDPX6CNNXFZ4JK" +PUBLIC_KEY="GD5KD2KEZJIGTC63IGW6UMUSMVUVG5IHG64HUTFWCHVZH2N2IBOQN7PS" +ADDRESS="host.docker.internal" +QUALITY="MEDIUM" diff --git a/services/horizon/docker/docker-compose.integration-tests.soroban-rpc.yml b/services/horizon/docker/docker-compose.integration-tests.soroban-rpc.yml new file mode 100644 index 0000000000..561609449d --- /dev/null +++ b/services/horizon/docker/docker-compose.integration-tests.soroban-rpc.yml @@ -0,0 +1,20 @@ +version: '3' +services: + soroban-rpc: + platform: linux/amd64 + image: ${SOROBAN_RPC_IMAGE:-stellar/soroban-rpc} + depends_on: + - core + restart: on-failure + ports: + - "8080:8080" + environment: + - ENDPOINT=:8080 + - NETWORK_PASSPHRASE=Standalone Network ; February 2017 + - CAPTIVE_CORE_CONFIG_PATH=/captive-core.cfg + - HISTORY_ARCHIVE_URLS=http://host.docker.internal:1570 + - CHECKPOINT_FREQUENCY=8 + - LOG_LEVEL=debug + volumes: + - ./captive-core-integration-tests.soroban-rpc.cfg:/captive-core.cfg + diff --git a/services/horizon/internal/actions/operation_test.go b/services/horizon/internal/actions/operation_test.go index c832d01751..85157777fb 100644 --- a/services/horizon/internal/actions/operation_test.go +++ b/services/horizon/internal/actions/operation_test.go @@ -65,37 +65,17 @@ func TestInvokeHostFnDetailsInPaymentOperations(t *testing.T) { 1, xdr.OperationTypeInvokeHostFunction, []byte(`{ - "host_functions": [ + "type": "invoke_contract", + "parameters": [ { - "type": "invoke_contract", - "parameters": [ - { - "value": "AAAADwAAAAdmbl9uYW1lAA==", - "type": "Sym" - }, - { - "value": "AAAAAwAAAAI=", - "type": "U32" - } - ] + "value": "AAAADwAAAAdmbl9uYW1lAA==", + "type": "Sym" }, { - "type": "create_contract", - "parameters": [ - { - "from": "source_account", - "type": "string" - }, - { - "salt": "123", - "type": "string" - } - ] - }, - { - "type": "upload_wasm" + "value": "AAAAAwAAAAI=", + "type": "U32" } - ], + ], "asset_balance_changes": [ { "asset_type": "credit_alphanum4", @@ -149,23 +129,12 @@ func TestInvokeHostFnDetailsInPaymentOperations(t *testing.T) { tt.Assert.Len(records, 1) op := records[0].(operations.InvokeHostFunction) - tt.Assert.Equal(len(op.HostFunctions), 3) - tt.Assert.Equal(op.HostFunctions[0].Type, "invoke_contract") - tt.Assert.Equal(len(op.HostFunctions[0].Parameters), 2) - tt.Assert.Equal(op.HostFunctions[0].Parameters[0]["value"], "AAAADwAAAAdmbl9uYW1lAA==") - tt.Assert.Equal(op.HostFunctions[0].Parameters[0]["type"], "Sym") - tt.Assert.Equal(op.HostFunctions[0].Parameters[1]["value"], "AAAAAwAAAAI=") - tt.Assert.Equal(op.HostFunctions[0].Parameters[1]["type"], "U32") - - tt.Assert.Equal(op.HostFunctions[1].Type, "create_contract") - tt.Assert.Equal(len(op.HostFunctions[1].Parameters), 2) - tt.Assert.Equal(op.HostFunctions[1].Parameters[0]["from"], "source_account") - tt.Assert.Equal(op.HostFunctions[1].Parameters[0]["type"], "string") - tt.Assert.Equal(op.HostFunctions[1].Parameters[1]["salt"], "123") - tt.Assert.Equal(op.HostFunctions[1].Parameters[1]["type"], "string") - - tt.Assert.Equal(op.HostFunctions[2].Type, "upload_wasm") - tt.Assert.Equal(len(op.HostFunctions[2].Parameters), 0) + tt.Assert.Equal(op.Type, "invoke_contract") + tt.Assert.Equal(len(op.Parameters), 2) + tt.Assert.Equal(op.Parameters[0].Value, "AAAADwAAAAdmbl9uYW1lAA==") + tt.Assert.Equal(op.Parameters[0].Type, "Sym") + tt.Assert.Equal(op.Parameters[1].Value, "AAAAAwAAAAI=") + tt.Assert.Equal(op.Parameters[1].Type, "U32") tt.Assert.Equal(len(op.AssetBalanceChanges), 4) tt.Assert.Equal(op.AssetBalanceChanges[0].From, "C_CONTRACT_ADDRESS1") diff --git a/services/horizon/internal/app.go b/services/horizon/internal/app.go index e19251c040..6c6132f739 100644 --- a/services/horizon/internal/app.go +++ b/services/horizon/internal/app.go @@ -218,6 +218,14 @@ func (a *App) Paths() paths.Finder { func (a *App) UpdateCoreLedgerState(ctx context.Context) { var next ledger.CoreStatus + // #4446 If the ingestion state machine is in the build state, the query can time out + // because the captive-core buffer may be full. In this case, skip the check. + if a.config.CaptiveCoreToml != nil && + a.config.StellarCoreURL == fmt.Sprintf("http://localhost:%d", a.config.CaptiveCoreToml.HTTPPort) && + a.ingester != nil && a.ingester.GetCurrentState() == ingest.Build { + return + } + logErr := func(err error, msg string) { log.WithStack(err).WithField("err", err.Error()).Error(msg) } diff --git a/services/horizon/internal/ingest/fsm.go b/services/horizon/internal/ingest/fsm.go index ff4fa02712..50f98879c2 100644 --- a/services/horizon/internal/ingest/fsm.go +++ b/services/horizon/internal/ingest/fsm.go @@ -30,9 +30,25 @@ func (e ErrReingestRangeConflict) Error() string { return fmt.Sprintf("reingest range overlaps with horizon ingestion, supplied range shouldn't contain ledger %d", e.maximumLedgerSequence) } +type State int + +const ( + None State = iota + Start + Stop + Build + Resume + WaitForCheckpoint + StressTest + VerifyRange + HistoryRange + ReingestHistoryRange +) + type stateMachineNode interface { run(*system) (transition, error) String() string + GetState() State } type transition struct { @@ -105,6 +121,10 @@ func (stopState) String() string { return "stop" } +func (stopState) GetState() State { + return Stop +} + func (stopState) run(s *system) (transition, error) { return stop(), errors.New("Cannot run terminal state") } @@ -117,6 +137,10 @@ func (startState) String() string { return "start" } +func (startState) GetState() State { + return Start +} + func (state startState) run(s *system) (transition, error) { if err := s.historyQ.Begin(s.ctx); err != nil { return start(), errors.Wrap(err, "Error starting a transaction") @@ -234,6 +258,10 @@ func (b buildState) String() string { return fmt.Sprintf("buildFromCheckpoint(checkpointLedger=%d, skipChecks=%t)", b.checkpointLedger, b.skipChecks) } +func (buildState) GetState() State { + return Build +} + func (b buildState) run(s *system) (transition, error) { var nextFailState = start() if b.stop { @@ -377,6 +405,10 @@ func (r resumeState) String() string { return fmt.Sprintf("resume(latestSuccessfullyProcessedLedger=%d)", r.latestSuccessfullyProcessedLedger) } +func (resumeState) GetState() State { + return Resume +} + func (r resumeState) run(s *system) (transition, error) { if r.latestSuccessfullyProcessedLedger == 0 { return start(), errors.New("unexpected latestSuccessfullyProcessedLedger value") @@ -564,6 +596,10 @@ func (h historyRangeState) String() string { ) } +func (historyRangeState) GetState() State { + return HistoryRange +} + // historyRangeState is used when catching up history data func (h historyRangeState) run(s *system) (transition, error) { if h.fromLedger == 0 || h.toLedger == 0 || @@ -677,6 +713,10 @@ func (h reingestHistoryRangeState) String() string { ) } +func (reingestHistoryRangeState) GetState() State { + return ReingestHistoryRange +} + func (h reingestHistoryRangeState) ingestRange(s *system, fromLedger, toLedger uint32) error { if s.historyQ.GetTx() == nil { return errors.New("expected transaction to be present") @@ -831,6 +871,10 @@ func (waitForCheckpointState) String() string { return "waitForCheckpoint" } +func (waitForCheckpointState) GetState() State { + return WaitForCheckpoint +} + func (waitForCheckpointState) run(*system) (transition, error) { log.Info("Waiting for the next checkpoint...") time.Sleep(10 * time.Second) @@ -852,6 +896,10 @@ func (v verifyRangeState) String() string { ) } +func (verifyRangeState) GetState() State { + return VerifyRange +} + func (v verifyRangeState) run(s *system) (transition, error) { if v.fromLedger == 0 || v.toLedger == 0 || v.fromLedger > v.toLedger { @@ -983,6 +1031,10 @@ func (stressTestState) String() string { return "stressTest" } +func (stressTestState) GetState() State { + return StressTest +} + func (stressTestState) run(s *system) (transition, error) { if err := s.historyQ.Begin(s.ctx); err != nil { err = errors.Wrap(err, "Error starting a transaction") diff --git a/services/horizon/internal/ingest/main.go b/services/horizon/internal/ingest/main.go index a5d62544de..dbc586e8ff 100644 --- a/services/horizon/internal/ingest/main.go +++ b/services/horizon/internal/ingest/main.go @@ -185,6 +185,7 @@ type System interface { ReingestRange(ledgerRanges []history.LedgerRange, force bool) error BuildGenesisState() error Shutdown() + GetCurrentState() State } type system struct { @@ -217,6 +218,9 @@ type system struct { runStateVerificationOnLedger func(uint32) bool reapOffsets map[string]int64 + + currentStateMutex sync.Mutex + currentState State } func NewSystem(config Config) (System, error) { @@ -281,6 +285,7 @@ func NewSystem(config Config) (System, error) { cancel: cancel, config: config, ctx: ctx, + currentState: None, disableStateVerification: config.DisableStateVerification, historyAdapter: historyAdapter, historyQ: historyQ, @@ -401,6 +406,12 @@ func (s *system) initMetrics() { ) } +func (s *system) GetCurrentState() State { + s.currentStateMutex.Lock() + defer s.currentStateMutex.Unlock() + return s.currentState +} + func (s *system) Metrics() Metrics { return s.metrics } @@ -564,6 +575,10 @@ func (s *system) runStateMachine(cur stateMachineNode) error { panic("unexpected transaction") } + s.currentStateMutex.Lock() + s.currentState = cur.GetState() + s.currentStateMutex.Unlock() + next, err := cur.run(s) if err != nil { logger := log.WithFields(logpkg.F{ diff --git a/services/horizon/internal/ingest/main_test.go b/services/horizon/internal/ingest/main_test.go index 9f0a390acc..fb5ad15948 100644 --- a/services/horizon/internal/ingest/main_test.go +++ b/services/horizon/internal/ingest/main_test.go @@ -5,6 +5,7 @@ import ( "context" "database/sql" "testing" + "time" "github.com/jmoiron/sqlx" "github.com/prometheus/client_golang/prometheus" @@ -242,6 +243,46 @@ func TestMaybeVerifyInternalDBErrCancelOrContextCanceled(t *testing.T) { historyQ.AssertExpectations(t) } +func TestCurrentStateRaceCondition(t *testing.T) { + historyQ := &mockDBQ{} + s := &system{ + historyQ: historyQ, + ctx: context.Background(), + } + + historyQ.On("GetTx").Return(nil) + historyQ.On("Begin", s.ctx).Return(nil) + historyQ.On("Rollback").Return(nil) + historyQ.On("GetLastLedgerIngest", s.ctx).Return(uint32(1), nil) + historyQ.On("GetIngestVersion", s.ctx).Return(CurrentVersion, nil) + + timer := time.NewTimer(2000 * time.Millisecond) + getCh := make(chan bool, 1) + doneCh := make(chan bool, 1) + go func() { + var state = buildState{checkpointLedger: 8, + skipChecks: true, + stop: true} + for range getCh { + _ = s.runStateMachine(state) + } + close(doneCh) + }() + +loop: + for { + s.GetCurrentState() + select { + case <-timer.C: + break loop + default: + } + getCh <- true + } + close(getCh) + <-doneCh +} + type mockDBQ struct { mock.Mock @@ -556,6 +597,11 @@ func (m *mockSystem) BuildGenesisState() error { return args.Error(0) } +func (m *mockSystem) GetCurrentState() State { + args := m.Called() + return args.Get(0).(State) +} + func (m *mockSystem) Shutdown() { m.Called() } 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 26fc0f6fdd..e95b9b3c44 100644 --- a/services/horizon/internal/ingest/processors/asset_stats_processor_test.go +++ b/services/horizon/internal/ingest/processors/asset_stats_processor_test.go @@ -1122,7 +1122,7 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateContractIDError() { s.Assert().EqualError( s.processor.Commit(s.ctx), - "attempting to set contract id b729e13867d5c4b2d161574e00854fd41bbba3e3b0e31d36c64904414a862fa7 but row credit_alphanum4/EUR/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H already has contract id set: 6645621141097c0f88b99360ce267c3396bcfd8cfdbe9c462b0dc167b72ecdc4", + "attempting to set contract id 67b1f192e30d8cd56dcb103c783cfee753588a434ad1092ef8a39375c9738bab but row credit_alphanum4/EUR/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H already has contract id set: c9cd6bbf712cfd4e086f0e25f90722c1af24416c0303728ad4527a6967ddc51b", ) } @@ -1202,7 +1202,7 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndContractIDErr s.Assert().EqualError( s.processor.Commit(s.ctx), - "attempting to set contract id b729e13867d5c4b2d161574e00854fd41bbba3e3b0e31d36c64904414a862fa7 but row credit_alphanum4/EUR/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H already has contract id set: 6645621141097c0f88b99360ce267c3396bcfd8cfdbe9c462b0dc167b72ecdc4", + "attempting to set contract id 67b1f192e30d8cd56dcb103c783cfee753588a434ad1092ef8a39375c9738bab but row credit_alphanum4/EUR/GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H already has contract id set: c9cd6bbf712cfd4e086f0e25f90722c1af24416c0303728ad4527a6967ddc51b", ) } @@ -1228,7 +1228,7 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestRemoveContractIDError() { s.Assert().EqualError( s.processor.Commit(s.ctx), - "row for asset with contract b729e13867d5c4b2d161574e00854fd41bbba3e3b0e31d36c64904414a862fa7 is missing", + "row for asset with contract 67b1f192e30d8cd56dcb103c783cfee753588a434ad1092ef8a39375c9738bab is missing", ) } @@ -1305,7 +1305,7 @@ func (s *AssetStatsProcessorTestSuiteLedger) TestUpdateTrustlineAndRemoveContrac s.Assert().EqualError( s.processor.Commit(s.ctx), - "row has no contract id to remove b729e13867d5c4b2d161574e00854fd41bbba3e3b0e31d36c64904414a862fa7: AssetTypeAssetTypeCreditAlphanum4 EUR GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", + "row has no contract id to remove 67b1f192e30d8cd56dcb103c783cfee753588a434ad1092ef8a39375c9738bab: AssetTypeAssetTypeCreditAlphanum4 EUR GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", ) } diff --git a/services/horizon/internal/ingest/processors/contract_data.go b/services/horizon/internal/ingest/processors/contract_data.go index ad64cbfe58..959ed3759b 100644 --- a/services/horizon/internal/ingest/processors/contract_data.go +++ b/services/horizon/internal/ingest/processors/contract_data.go @@ -8,50 +8,52 @@ import ( ) var ( - nativeAssetSym = xdr.ScSymbol("Native") + // https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/public_types.rs#L22 + nativeAssetSym = xdr.ScSymbol("Native") + // these are storage DataKey enum + // https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/storage_types.rs#L23 balanceMetadataSym = xdr.ScSymbol("Balance") - assetMetadataSym = xdr.ScSymbol("Metadata") - assetMetadataVec = &xdr.ScVec{ + assetInfoSym = xdr.ScSymbol("AssetInfo") + assetInfoVec = &xdr.ScVec{ xdr.ScVal{ Type: xdr.ScValTypeScvSymbol, - Sym: &assetMetadataSym, + Sym: &assetInfoSym, }, } - assetMetadataKey = xdr.ScVal{ + assetInfoKey = xdr.ScVal{ Type: xdr.ScValTypeScvVec, - Vec: &assetMetadataVec, + Vec: &assetInfoVec, } ) // AssetFromContractData takes a ledger entry and verifies if the ledger entry -// corresponds to the asset metadata written to contract storage by the Stellar +// corresponds to the asset info entry written to contract storage by the Stellar // Asset Contract upon initialization. // -// Note that AssetFromContractData will ignore forged asset metadata entries by -// deriving the Stellar Asset Contract ID from the asset metadata and comparing +// Note that AssetFromContractData will ignore forged asset info entries by +// deriving the Stellar Asset Contract ID from the asset info entry and comparing // it to the contract ID found in the ledger entry. // -// If the given ledger entry is a verified asset metadata entry, +// If the given ledger entry is a verified asset info entry, // AssetFromContractData will return the corresponding Stellar asset. Otherwise, // it returns nil. // // References: -// -// https://github.com/stellar/rs-soroban-env/blob/da325551829d31dcbfa71427d51c18e71a121c5f/soroban-env-host/src/native_contract/token/public_types.rs#L21 -// https://github.com/stellar/rs-soroban-env/blob/da325551829d31dcbfa71427d51c18e71a121c5f/soroban-env-host/src/native_contract/token/metadata.rs#L8 -// https://github.com/stellar/rs-soroban-env/blob/da325551829d31dcbfa71427d51c18e71a121c5f/soroban-env-host/src/native_contract/token/contract.rs#L108 +// https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/public_types.rs#L21 +// https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/asset_info.rs#L6 +// https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/contract.rs#L115 // // The `ContractData` entry takes the following form: // -// - Key: a vector with one element, which is the symbol "Metadata" +// - Key: a vector with one element, which is the symbol "AssetInfo" // -// ScVal{ Vec: ScVec({ ScVal{ Sym: ScSymbol("metadata") }})} +// ScVal{ Vec: ScVec({ ScVal{ Sym: ScSymbol("AssetInfo") }})} // // - Value: a map with two key-value pairs: code and issuer // // ScVal{ Map: ScMap( // { ScVal{ Sym: ScSymbol("asset_code") } -> ScVal{ Bytes: ScBytes(...) } }, -// { ScVal{ Sym: ScSymbol("asset_code") } -> ScVal{ Bytes: ScBytes(...) } } +// { ScVal{ Sym: ScSymbol("issuer") } -> ScVal{ Bytes: ScBytes(...) } } // )} func AssetFromContractData(ledgerEntry xdr.LedgerEntry, passphrase string) *xdr.Asset { contractData, ok := ledgerEntry.Data.GetContractData() @@ -65,7 +67,7 @@ func AssetFromContractData(ledgerEntry xdr.LedgerEntry, passphrase string) *xdr. return nil } - if !contractData.Key.Equals(assetMetadataKey) { + if !contractData.Key.Equals(assetInfoKey) { return nil } @@ -276,7 +278,7 @@ func metadataObjFromAsset(isNative bool, code, issuer string) (*xdr.ScVec, error } // AssetToContractData is the inverse of AssetFromContractData. It creates a -// ledger entry containing the asset metadata written to contract storage by the +// ledger entry containing the asset info entry written to contract storage by the // Stellar Asset Contract. func AssetToContractData(isNative bool, code, issuer string, contractID [32]byte) (xdr.LedgerEntryData, error) { vec, err := metadataObjFromAsset(isNative, code, issuer) @@ -287,7 +289,7 @@ func AssetToContractData(isNative bool, code, issuer string, contractID [32]byte Type: xdr.LedgerEntryTypeContractData, ContractData: &xdr.ContractDataEntry{ ContractId: contractID, - Key: assetMetadataKey, + Key: assetInfoKey, Val: xdr.ScVal{ Type: xdr.ScValTypeScvVec, Vec: &vec, diff --git a/services/horizon/internal/ingest/processors/effects_processor.go b/services/horizon/internal/ingest/processors/effects_processor.go index c932da891f..d84f0e6128 100644 --- a/services/horizon/internal/ingest/processors/effects_processor.go +++ b/services/horizon/internal/ingest/processors/effects_processor.go @@ -236,7 +236,7 @@ func (operation *transactionOperationWrapper) effects() ([]effect, error) { case xdr.OperationTypeInvokeHostFunction: // If there's an invokeHostFunction operation, there's definitely V3 // meta in the transaction, which means this error is real. - diagnosticEvents, innerErr := operation.transaction.GetOperationEvents(operation.index) + diagnosticEvents, innerErr := operation.transaction.GetDiagnosticEvents() if innerErr != nil { return nil, innerErr } diff --git a/services/horizon/internal/ingest/processors/effects_processor_test.go b/services/horizon/internal/ingest/processors/effects_processor_test.go index 04d24bcfbd..35c143a702 100644 --- a/services/horizon/internal/ingest/processors/effects_processor_test.go +++ b/services/horizon/internal/ingest/processors/effects_processor_test.go @@ -3788,9 +3788,7 @@ func makeInvocationTransaction( meta := xdr.TransactionMetaV3{ // irrelevant for contract invocations: only events are inspected Operations: []xdr.OperationMeta{}, - Events: []xdr.OperationEvents{{ - Events: make([]xdr.ContractEvent, len(types)), - }}, + Events: make([]xdr.ContractEvent, len(types)), } for idx, type_ := range types { @@ -3801,7 +3799,7 @@ func makeInvocationTransaction( amount, networkPassphrase, ) - meta.Events[0].Events[idx] = event + meta.Events[idx] = event } envelope := xdr.TransactionV1Envelope{ diff --git a/services/horizon/internal/ingest/processors/operations_processor.go b/services/horizon/internal/ingest/processors/operations_processor.go index ebbabbde44..8646fa3e87 100644 --- a/services/horizon/internal/ingest/processors/operations_processor.go +++ b/services/horizon/internal/ingest/processors/operations_processor.go @@ -268,7 +268,7 @@ func (operation *transactionOperationWrapper) IsPayment() bool { case xdr.OperationTypeAccountMerge: return true case xdr.OperationTypeInvokeHostFunction: - diagnosticEvents, err := operation.transaction.GetOperationEvents(operation.index) + diagnosticEvents, err := operation.transaction.GetDiagnosticEvents() if err != nil { return false } @@ -631,79 +631,61 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, } case xdr.OperationTypeInvokeHostFunction: op := operation.operation.Body.MustInvokeHostFunctionOp() - hostFunctions := make([]map[string]interface{}, 0, len(op.Functions)) - if balanceChanges, err := operation.parseAssetBalanceChangesFromContractEvents(); err != nil { - return nil, err - } else { - details["asset_balance_changes"] = balanceChanges - } - for _, function := range op.Functions { - hostFunctionInvocation := make(map[string]interface{}, 2) - hostFunctions = append(hostFunctions, hostFunctionInvocation) - params := []map[string]string{} - - switch function.Args.Type { - case xdr.HostFunctionTypeHostFunctionTypeInvokeContract: - hostFunctionInvocation["type"] = "invoke_contract" - args := function.Args.MustInvokeContract() - 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) - } + details["function"] = op.HostFunction.Type.String() + + switch op.HostFunction.Type { + case xdr.HostFunctionTypeHostFunctionTypeInvokeContract: + args := op.HostFunction.MustInvokeContract() + details["type"] = "invoke_contract" + 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) } + params = append(params, serializedParam) + } + details["parameters"] = params - case xdr.HostFunctionTypeHostFunctionTypeCreateContract: - hostFunctionInvocation["type"] = "create_contract" - args := function.Args.MustCreateContract() - - switch args.ContractId.Type { - case xdr.ContractIdTypeContractIdFromSourceAccount: - params = append(params, - map[string]string{"from": "source_account", "type": "string"}, - map[string]string{"salt": args.ContractId.MustSalt().String(), "type": "string"}, - ) - case xdr.ContractIdTypeContractIdFromEd25519PublicKey: - fromEd25519PublicKey := args.ContractId.MustFromEd25519PublicKey() - fromKeyStr := xdr.AccountId(xdr.PublicKey{ - Type: xdr.PublicKeyTypePublicKeyTypeEd25519, - Ed25519: &fromEd25519PublicKey.Key, - }).Address() - signature, err := xdr.MarshalBase64(fromEd25519PublicKey.Signature) - if err != nil { - return nil, err - } - params = append(params, - map[string]string{"from": "public_key", "type": "string"}, - map[string]string{"key": fromKeyStr, "type": "string"}, - map[string]string{"sig": signature, "type": "string"}, - map[string]string{"salt": fromEd25519PublicKey.Salt.String(), "type": "string"}, - ) - case xdr.ContractIdTypeContractIdFromAsset: - params = append(params, - map[string]string{"from": "asset", "type": "string"}, - map[string]string{"asset": args.ContractId.MustAsset().StringCanonical(), "type": "string"}, - ) - default: - panic(fmt.Errorf("unknown contract id type: %s", args.ContractId.Type)) + if balanceChanges, err := operation.parseAssetBalanceChangesFromContractEvents(); err != nil { + return nil, err + } else { + details["asset_balance_changes"] = balanceChanges + } + + case xdr.HostFunctionTypeHostFunctionTypeCreateContract: + args := op.HostFunction.MustCreateContract() + details["type"] = "create_contract" + switch args.ContractIdPreimage.Type { + case xdr.ContractIdPreimageTypeContractIdPreimageFromAddress: + fromAddress := args.ContractIdPreimage.MustFromAddress() + address, err := fromAddress.Address.String() + if err != nil { + panic(fmt.Errorf("error obtaining address for: %s", args.ContractIdPreimage.Type)) } - case xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm: - hostFunctionInvocation["type"] = "upload_wasm" + details["from"] = "address" + details["address"] = address + details["salt"] = fromAddress.Salt + case xdr.ContractIdPreimageTypeContractIdPreimageFromAsset: + details["from"] = "asset" + details["asset"] = args.ContractIdPreimage.MustFromAsset().StringCanonical() default: - panic(fmt.Errorf("unknown host function type: %s", function.Args.Type)) + panic(fmt.Errorf("unknown contract id type: %s", args.ContractIdPreimage.Type)) } - hostFunctionInvocation["parameters"] = params + case xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm: + details["type"] = "upload_wasm" + default: + panic(fmt.Errorf("unknown host function type: %s", op.HostFunction.Type)) } - details["host_functions"] = hostFunctions default: - panic(fmt.Errorf("Unknown operation type: %s", operation.OperationType())) + panic(fmt.Errorf("unknown operation type: %s", operation.OperationType())) } sponsor, err := operation.getSponsor() @@ -730,7 +712,7 @@ func (operation *transactionOperationWrapper) Details() (map[string]interface{}, func (operation *transactionOperationWrapper) parseAssetBalanceChangesFromContractEvents() ([]map[string]interface{}, error) { balanceChanges := []map[string]interface{}{} - diagnosticEvents, err := operation.transaction.GetOperationEvents(operation.index) + diagnosticEvents, err := operation.transaction.GetDiagnosticEvents() if err != nil { // this operation in this context must be an InvokeHostFunctionOp, therefore V3Meta should be present // as it's in same soroban model, so if any err, it's real, diff --git a/services/horizon/internal/ingest/processors/operations_processor_test.go b/services/horizon/internal/ingest/processors/operations_processor_test.go index a1e942fd14..d1dd2df889 100644 --- a/services/horizon/internal/ingest/processors/operations_processor_test.go +++ b/services/horizon/internal/ingest/processors/operations_processor_test.go @@ -96,11 +96,9 @@ func (s *OperationsProcessorTestSuiteLedger) mockBatchInsertAdds(txs []ingest.Le return nil } -func (s *OperationsProcessorTestSuiteLedger) TestInvokeFunctionDetails() { +func (s *OperationsProcessorTestSuiteLedger) TestOperationTypeInvokeHostFunctionDetails() { sourceAddress := "GAUJETIZVEP2NRYLUESJ3LS66NVCEGMON4UDCBCSBEVPIID773P2W6AY" source := xdr.MustMuxedAddress(sourceAddress) - sourceAccountId := source.ToAccountId() - sourcePublicKey := sourceAccountId.Ed25519 contractParamVal1 := xdr.ScSymbol("func1") contractParamVal2 := xdr.Int32(-5) @@ -109,6 +107,9 @@ func (s *OperationsProcessorTestSuiteLedger) TestInvokeFunctionDetails() { contractParamVal5 := xdr.ScBytes([]byte{0, 1, 2}) contractParamVal6 := true + accountId := xdr.MustAddress("GB7BDSZU2Y27LYNLALKKALB52WS2IZWYBDGY6EQBLEED3TJOCVMZRH7H") + wasm := []byte("Some contract code") + tx := ingest.LedgerTransaction{ UnsafeMeta: xdr.TransactionMeta{ V: 2, @@ -124,98 +125,261 @@ func (s *OperationsProcessorTestSuiteLedger) TestInvokeFunctionDetails() { Body: xdr.OperationBody{ Type: xdr.OperationTypeInvokeHostFunction, InvokeHostFunctionOp: &xdr.InvokeHostFunctionOp{ - Functions: []xdr.HostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + { + Type: xdr.ScValTypeScvSymbol, + Sym: &contractParamVal1, + }, + { + Type: xdr.ScValTypeScvI32, + I32: &contractParamVal2, + }, + { + Type: xdr.ScValTypeScvU32, + U32: &contractParamVal3, + }, + { + Type: xdr.ScValTypeScvU64, + U64: &contractParamVal4, + }, + { + Type: xdr.ScValTypeScvBytes, + Bytes: &contractParamVal5, + }, + { + Type: xdr.ScValTypeScvBool, + B: &contractParamVal6, + }, + { + // invalid ScVal + Type: 5555, + }, + }, + }, + Auth: []xdr.SorobanAuthorizationEntry{ { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, - CreateContract: &xdr.CreateContractArgs{ - ContractId: xdr.ContractId{ - Type: xdr.ContractIdTypeContractIdFromAsset, - Asset: &xdr.Asset{ - Type: 1, - AlphaNum4: &xdr.AlphaNum4{ - AssetCode: xdr.AssetCode4{65, 82, 83, 0}, - Issuer: xdr.MustAddress("GCXI6Q73J7F6EUSBZTPW4G4OUGVDHABPYF2U4KO7MVEX52OH5VMVUCRF"), - }, + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Nonce: 0, + SignatureArgs: nil, + }, + }, + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, }, + FunctionName: "foo", + Args: nil, }, }, + SubInvocations: nil, }, }, - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, - CreateContract: &xdr.CreateContractArgs{ - ContractId: xdr.ContractId{ - Type: xdr.ContractIdTypeContractIdFromSourceAccount, - Salt: &xdr.Uint256{ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1}, + }, + }, + }, + }, + } + + details, err := wrapper.Details() + s.Assert().NoError(err) + + var hostFnArgs []xdr.ScVal = *(wrapper.operation.Body.InvokeHostFunctionOp.HostFunction.InvokeContract) + detailsFunctionParams := details["parameters"].([]map[string]string) + s.Assert().Equal(details["type"], "invoke_contract") + s.assertInvokeHostFunctionParameter(detailsFunctionParams, 0, "Sym", hostFnArgs[0]) + s.assertInvokeHostFunctionParameter(detailsFunctionParams, 1, "I32", hostFnArgs[1]) + s.assertInvokeHostFunctionParameter(detailsFunctionParams, 2, "U32", hostFnArgs[2]) + s.assertInvokeHostFunctionParameter(detailsFunctionParams, 3, "U64", hostFnArgs[3]) + s.assertInvokeHostFunctionParameter(detailsFunctionParams, 4, "Bytes", hostFnArgs[4]) + s.assertInvokeHostFunctionParameter(detailsFunctionParams, 5, "B", hostFnArgs[5]) + s.assertInvokeHostFunctionParameter(detailsFunctionParams, 6, "n/a", hostFnArgs[6]) + }) + + s.T().Run("CreateContractFromAsset", func(t *testing.T) { + wrapper := transactionOperationWrapper{ + transaction: tx, + operation: xdr.Operation{ + SourceAccount: &source, + Body: xdr.OperationBody{ + Type: xdr.OperationTypeInvokeHostFunction, + InvokeHostFunctionOp: &xdr.InvokeHostFunctionOp{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, + CreateContract: &xdr.CreateContractArgs{ + ContractIdPreimage: xdr.ContractIdPreimage{ + Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAsset, + FromAsset: &xdr.Asset{ + Type: 1, + AlphaNum4: &xdr.AlphaNum4{ + AssetCode: xdr.AssetCode4{65, 82, 83, 0}, + Issuer: xdr.MustAddress("GCXI6Q73J7F6EUSBZTPW4G4OUGVDHABPYF2U4KO7MVEX52OH5VMVUCRF"), }, }, }, + Executable: xdr.ScContractExecutable{ + Type: xdr.ScContractExecutableTypeSccontractExecutableToken, + }, }, + }, + Auth: []xdr.SorobanAuthorizationEntry{ { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, - CreateContract: &xdr.CreateContractArgs{ - ContractId: xdr.ContractId{ - Type: xdr.ContractIdTypeContractIdFromEd25519PublicKey, - FromEd25519PublicKey: &xdr.ContractIdFromEd25519PublicKey{ - Key: xdr.Uint256{1, 2, 3}, - Salt: xdr.Uint256{1}, - Signature: xdr.Signature{ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 6, 7, 8, - }, + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Nonce: 0, + SignatureArgs: nil, + }, + }, + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, }, + FunctionName: "foo", + Args: nil, }, }, + SubInvocations: nil, }, }, - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - { - Type: xdr.ScValTypeScvSymbol, - Sym: &contractParamVal1, - }, - { - Type: xdr.ScValTypeScvI32, - I32: &contractParamVal2, - }, - { - Type: xdr.ScValTypeScvU32, - U32: &contractParamVal3, - }, - { - Type: xdr.ScValTypeScvU64, - U64: &contractParamVal4, - }, - { - Type: xdr.ScValTypeScvBytes, - Bytes: &contractParamVal5, + }, + }, + }, + }, + } + + details, err := wrapper.Details() + s.Assert().NoError(err) + + s.Assert().Equal(details["type"], "create_contract") + s.Assert().Equal(details["from"], "asset") + s.Assert().Equal(details["asset"], "ARS:GCXI6Q73J7F6EUSBZTPW4G4OUGVDHABPYF2U4KO7MVEX52OH5VMVUCRF") + }) + + s.T().Run("CreateContractFromAddress", func(t *testing.T) { + wrapper := transactionOperationWrapper{ + transaction: tx, + operation: xdr.Operation{ + SourceAccount: &source, + Body: xdr.OperationBody{ + Type: xdr.OperationTypeInvokeHostFunction, + InvokeHostFunctionOp: &xdr.InvokeHostFunctionOp{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, + CreateContract: &xdr.CreateContractArgs{ + ContractIdPreimage: xdr.ContractIdPreimage{ + Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAddress, + FromAddress: &xdr.ContractIdPreimageFromAddress{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, }, - { - Type: xdr.ScValTypeScvBool, - B: &contractParamVal6, + Salt: xdr.Uint256{1}, + }, + }, + Executable: xdr.ScContractExecutable{}, + }, + }, + Auth: []xdr.SorobanAuthorizationEntry{ + { + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, }, - { - // invalid ScVal - Type: 5555, + Nonce: 0, + SignatureArgs: nil, + }, + }, + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + FunctionName: "foo", + Args: nil, }, }, + SubInvocations: nil, }, }, + }, + }, + }, + }, + } + + details, err := wrapper.Details() + s.Assert().NoError(err) + + s.Assert().Equal(details["type"], "create_contract") + s.Assert().Equal(details["from"], "address") + s.Assert().Equal(details["address"], "GB7BDSZU2Y27LYNLALKKALB52WS2IZWYBDGY6EQBLEED3TJOCVMZRH7H") + s.Assert().Equal(details["salt"], xdr.Uint256{1}) + }) + + s.T().Run("UploadContractWasm", func(t *testing.T) { + wrapper := transactionOperationWrapper{ + transaction: tx, + operation: xdr.Operation{ + SourceAccount: &source, + Body: xdr.OperationBody{ + Type: xdr.OperationTypeInvokeHostFunction, + InvokeHostFunctionOp: &xdr.InvokeHostFunctionOp{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm, + Wasm: &wasm, + }, + Auth: []xdr.SorobanAuthorizationEntry{ { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm, - UploadContractWasm: &xdr.UploadContractWasmArgs{}, + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Nonce: 0, + SignatureArgs: nil, + }, + }, + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + FunctionName: "foo", + Args: nil, + }, + }, + SubInvocations: nil, }, }, }, @@ -227,44 +391,10 @@ func (s *OperationsProcessorTestSuiteLedger) TestInvokeFunctionDetails() { details, err := wrapper.Details() s.Assert().NoError(err) - detailsHostFunctions := details["host_functions"].([]map[string]interface{}) - s.Assert().Len(detailsHostFunctions, 5) - - var detailsFunctionParams []map[string]string = detailsHostFunctions[0]["parameters"].([]map[string]string) - s.Assert().Equal(detailsHostFunctions[0]["type"], "create_contract") - s.Assert().Equal(detailsFunctionParams[0], map[string]string{"from": "asset", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[1], map[string]string{"asset": "ARS:GCXI6Q73J7F6EUSBZTPW4G4OUGVDHABPYF2U4KO7MVEX52OH5VMVUCRF", "type": "string"}) - - detailsFunctionParams = detailsHostFunctions[1]["parameters"].([]map[string]string) - s.Assert().Equal(detailsHostFunctions[1]["type"], "create_contract") - s.Assert().Equal(detailsFunctionParams[0], map[string]string{"from": "source_account", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[1], map[string]string{"salt": "1", "type": "string"}) - - detailsFunctionParams = detailsHostFunctions[2]["parameters"].([]map[string]string) - s.Assert().Equal(detailsHostFunctions[2]["type"], "create_contract") - s.Assert().Equal(detailsFunctionParams[0], map[string]string{"from": "public_key", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[1], map[string]string{"key": "GAAQEAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATFL", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[2], map[string]string{"sig": "AAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBgcI", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[3], map[string]string{"salt": "452312848583266388373324160190187140051835877600158453279131187530910662656", "type": "string"}) - - var hostFnArgs []xdr.ScVal = *(wrapper.operation.Body.InvokeHostFunctionOp.Functions[3].Args.InvokeContract) - detailsFunctionParams = detailsHostFunctions[3]["parameters"].([]map[string]string) - s.Assert().Equal(detailsHostFunctions[3]["type"], "invoke_contract") - s.assertInvokeHostFunctionParameter(detailsFunctionParams, 0, "Sym", hostFnArgs[0]) - s.assertInvokeHostFunctionParameter(detailsFunctionParams, 1, "I32", hostFnArgs[1]) - s.assertInvokeHostFunctionParameter(detailsFunctionParams, 2, "U32", hostFnArgs[2]) - s.assertInvokeHostFunctionParameter(detailsFunctionParams, 3, "U64", hostFnArgs[3]) - s.assertInvokeHostFunctionParameter(detailsFunctionParams, 4, "Bytes", hostFnArgs[4]) - s.assertInvokeHostFunctionParameter(detailsFunctionParams, 5, "B", hostFnArgs[5]) - s.assertInvokeHostFunctionParameter(detailsFunctionParams, 6, "n/a", hostFnArgs[6]) - - s.Assert().Equal(detailsHostFunctions[4]["type"], "upload_wasm") - detailsFunctionParams = detailsHostFunctions[4]["parameters"].([]map[string]string) - s.Assert().Len(detailsFunctionParams, 0) + s.Assert().Equal(details["type"], "upload_wasm") }) s.T().Run("InvokeContractWithSACEventsInDetails", func(t *testing.T) { - randomIssuer := keypair.MustRandom() randomAsset := xdr.MustNewCreditAsset("TESTING", randomIssuer.Address()) passphrase := "passphrase" @@ -282,15 +412,11 @@ func (s *OperationsProcessorTestSuiteLedger) TestInvokeFunctionDetails() { UnsafeMeta: xdr.TransactionMeta{ V: 3, V3: &xdr.TransactionMetaV3{ - Events: []xdr.OperationEvents{ - { - Events: []xdr.ContractEvent{ - transferContractEvent, - burnContractEvent, - mintContractEvent, - clawbackContractEvent, - }, - }, + Events: []xdr.ContractEvent{ + transferContractEvent, + burnContractEvent, + mintContractEvent, + clawbackContractEvent, }, }, }, @@ -302,11 +428,36 @@ func (s *OperationsProcessorTestSuiteLedger) TestInvokeFunctionDetails() { Body: xdr.OperationBody{ Type: xdr.OperationTypeInvokeHostFunction, InvokeHostFunctionOp: &xdr.InvokeHostFunctionOp{ - Functions: []xdr.HostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{}, + }, + Auth: []xdr.SorobanAuthorizationEntry{ { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{}, + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Nonce: 0, + SignatureArgs: nil, + }, + }, + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + FunctionName: "foo", + Args: nil, + }, + }, + SubInvocations: nil, }, }, }, @@ -352,101 +503,6 @@ func (s *OperationsProcessorTestSuiteLedger) TestInvokeFunctionDetails() { } s.Assert().Equal(found, 4, "should have one balance changed record for each of mint, burn, clawback, transfer") }) - - s.T().Run("CreateContract", func(t *testing.T) { - signature := xdr.Signature{ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 5, 6, 7, 8, - } - - salt := xdr.Uint256{ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 2, 3, 4, - } - wrapper := transactionOperationWrapper{ - transaction: tx, - operation: xdr.Operation{ - SourceAccount: &source, - Body: xdr.OperationBody{ - Type: xdr.OperationTypeInvokeHostFunction, - InvokeHostFunctionOp: &xdr.InvokeHostFunctionOp{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, - CreateContract: &xdr.CreateContractArgs{ - ContractId: xdr.ContractId{ - Type: xdr.ContractIdTypeContractIdFromEd25519PublicKey, - FromEd25519PublicKey: &xdr.ContractIdFromEd25519PublicKey{ - Key: *sourcePublicKey, - Signature: signature, - Salt: salt, - }, - }, - Executable: xdr.ScContractExecutable{ - Type: xdr.ScContractExecutableTypeSccontractExecutableToken, - }, - }, - }, - }, - }, - }, - }, - }, - } - - details, err := wrapper.Details() - s.Assert().NoError(err) - - serializedDetailsHostFunctions := details["host_functions"].([]map[string]interface{}) - s.Assert().Len(serializedDetailsHostFunctions, 1) - - var detailsFunctionParams []map[string]string = serializedDetailsHostFunctions[0]["parameters"].([]map[string]string) - s.Assert().Equal(serializedDetailsHostFunctions[0]["type"], "create_contract") - s.Assert().Equal(detailsFunctionParams[0], map[string]string{"from": "public_key", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[1], map[string]string{"key": "GAUJETIZVEP2NRYLUESJ3LS66NVCEGMON4UDCBCSBEVPIID773P2W6AY", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[2], map[string]string{"sig": "AAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBgcI", "type": "string"}) - s.Assert().Equal(detailsFunctionParams[3], map[string]string{"salt": "16909060", "type": "string"}) - }) - - s.T().Run("InstallContractCode", func(t *testing.T) { - code := []byte("Some contract code") - wrapper := transactionOperationWrapper{ - transaction: tx, - operation: xdr.Operation{ - SourceAccount: &source, - Body: xdr.OperationBody{ - Type: xdr.OperationTypeInvokeHostFunction, - InvokeHostFunctionOp: &xdr.InvokeHostFunctionOp{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm, - UploadContractWasm: &xdr.UploadContractWasmArgs{ - Code: code, - }, - }, - }, - }, - }, - }, - }, - } - - details, err := wrapper.Details() - s.Assert().NoError(err) - - serializedDetailsHostFunctions := details["host_functions"].([]map[string]interface{}) - s.Assert().Len(serializedDetailsHostFunctions, 1) - - s.Assert().Equal(serializedDetailsHostFunctions[0]["type"], "upload_wasm") - var detailsFunctionParams []map[string]string = serializedDetailsHostFunctions[0]["parameters"].([]map[string]string) - s.Assert().Len(detailsFunctionParams, 0) - }) } func (s *OperationsProcessorTestSuiteLedger) assertInvokeHostFunctionParameter(parameters []map[string]string, paramPosition int, expectedType string, expectedVal xdr.ScVal) { 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 4b002183e2..770f61e663 100644 --- a/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go +++ b/services/horizon/internal/ingest/processors/transaction_operation_wrapper_test.go @@ -2278,5 +2278,5 @@ func TestDetailsCoversAllOperationTypes(t *testing.T) { f := func() { operation.Details() } - assert.PanicsWithError(t, "Unknown operation type: ", f) + assert.PanicsWithError(t, "unknown operation type: ", f) } diff --git a/services/horizon/internal/integration/contracts/Cargo.lock b/services/horizon/internal/integration/contracts/Cargo.lock index f79d1bb53e..f0967c1de3 100644 --- a/services/horizon/internal/integration/contracts/Cargo.lock +++ b/services/horizon/internal/integration/contracts/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -69,28 +75,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] -name = "block-buffer" -version = "0.9.0" +name = "base64" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "block-buffer" -version = "0.10.4" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ "generic-array", ] [[package]] name = "bumpalo" -version = "3.12.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byteorder" @@ -100,14 +103,14 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes-lit" -version = "0.0.4" +version = "0.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c181bca161a49348b90fa75f9a54fe11b7138098eed90d841a1055d574b4250" +checksum = "0adabf37211a5276e46335feabcbb1530c95eb3fdf85f324c7db942770aa025d" dependencies = [ "num-bigint", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -124,27 +127,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ + "android-tzdata", "iana-time-zone", - "num-integer", "num-traits", "serde", "winapi", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -171,16 +164,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "curve25519-dalek" version = "3.2.1" @@ -188,88 +171,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" dependencies = [ "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "digest", + "rand_core", "subtle", "zeroize", ] -[[package]] -name = "cxx" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.15", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.15", -] - -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core 0.14.4", - "darling_macro 0.14.4", -] - [[package]] name = "darling" version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ - "darling_core 0.20.1", - "darling_macro 0.20.1", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", + "darling_core", + "darling_macro", ] [[package]] @@ -283,18 +198,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.15", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core 0.14.4", - "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -303,20 +207,20 @@ version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ - "darling_core 0.20.1", + "darling_core", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "derive_arbitrary" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cdeb9ec472d588e539a818b2dee436825730da08ad0017c4b1a17676bdc8b7" +checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -328,28 +232,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common", -] - [[package]] name = "downcast-rs" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" -[[package]] -name = "dyn-fmt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a0836c9bd73a9d3ca55b0effc5b1eedf96dd13ef994389bcac6d4d33c46188" - [[package]] name = "ed25519" version = "1.5.3" @@ -367,9 +255,9 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", "ed25519", - "rand 0.7.3", + "rand", "serde", - "sha2 0.9.9", + "sha2", "zeroize", ] @@ -409,18 +297,7 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -460,12 +337,11 @@ dependencies = [ [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -491,6 +367,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" +[[package]] +name = "intx" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f38a50a899dc47a6d0ed5508e7f601a2e34c3a85303514b5d137f3c10a0c75" + [[package]] name = "itertools" version = "0.10.5" @@ -508,42 +390,30 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] [[package]] name = "libc" -version = "0.2.142" +version = "0.2.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" [[package]] name = "libm" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" - -[[package]] -name = "link-cplusplus" -version = "1.0.8" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "memchr" @@ -551,12 +421,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "miniz_oxide" version = "0.6.2" @@ -598,18 +462,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -621,18 +473,18 @@ dependencies = [ [[package]] name = "object" -version = "0.30.3" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -640,6 +492,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -648,28 +506,28 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "prettyplease" -version = "0.1.25" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" dependencies = [ "proc-macro2", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -680,24 +538,13 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.16", + "getrandom", "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", "rand_hc", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -705,17 +552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -724,16 +561,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.9", + "getrandom", ] [[package]] @@ -742,7 +570,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", + "rand_core", ] [[package]] @@ -757,30 +585,24 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "scratch" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" - [[package]] name = "serde" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -796,11 +618,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "2.3.3" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +checksum = "9f02d8aa6e3c385bf084924f660ce2a3a6bd333ba55b35e8590b321f35d88513" dependencies = [ - "base64", + "base64 0.21.2", "chrono", "hex", "indexmap", @@ -812,14 +634,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "2.3.3" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +checksum = "edc7d5d3932fb12ce722ee5e64dd38c504efba37567f0c402f6ca728c3b8b070" dependencies = [ - "darling 0.20.1", + "darling", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -828,34 +650,29 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer 0.9.0", + "block-buffer", "cfg-if", "cpufeatures", - "digest 0.9.0", + "digest", "opaque-debug", ] -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.6", -] - [[package]] name = "signature" version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + [[package]] name = "soroban-env-common" -version = "0.0.15" -source = "git+https://github.com/stellar/rs-soroban-env?rev=bad318a9805cf25ae64afb5122cb37af67a2edbd#bad318a9805cf25ae64afb5122cb37af67a2edbd" +version = "0.0.16" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c09c5f1b9af1a60d93c881a545607a84d36b88d2#c09c5f1b9af1a60d93c881a545607a84d36b88d2" dependencies = [ "arbitrary", "crate-git-revision", @@ -869,8 +686,8 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "0.0.15" -source = "git+https://github.com/stellar/rs-soroban-env?rev=bad318a9805cf25ae64afb5122cb37af67a2edbd#bad318a9805cf25ae64afb5122cb37af67a2edbd" +version = "0.0.16" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c09c5f1b9af1a60d93c881a545607a84d36b88d2#c09c5f1b9af1a60d93c881a545607a84d36b88d2" dependencies = [ "soroban-env-common", "static_assertions", @@ -878,30 +695,30 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "0.0.15" -source = "git+https://github.com/stellar/rs-soroban-env?rev=bad318a9805cf25ae64afb5122cb37af67a2edbd#bad318a9805cf25ae64afb5122cb37af67a2edbd" +version = "0.0.16" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c09c5f1b9af1a60d93c881a545607a84d36b88d2#c09c5f1b9af1a60d93c881a545607a84d36b88d2" dependencies = [ "backtrace", "curve25519-dalek", - "dyn-fmt", "ed25519-dalek", "hex", "log", "num-derive", "num-integer", "num-traits", - "sha2 0.9.9", + "rand", + "rand_chacha", + "sha2", "soroban-env-common", "soroban-native-sdk-macros", "soroban-wasmi", "static_assertions", - "tinyvec", ] [[package]] name = "soroban-env-macros" -version = "0.0.15" -source = "git+https://github.com/stellar/rs-soroban-env?rev=bad318a9805cf25ae64afb5122cb37af67a2edbd#bad318a9805cf25ae64afb5122cb37af67a2edbd" +version = "0.0.16" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c09c5f1b9af1a60d93c881a545607a84d36b88d2#c09c5f1b9af1a60d93c881a545607a84d36b88d2" dependencies = [ "itertools", "proc-macro2", @@ -909,7 +726,7 @@ dependencies = [ "serde", "serde_json", "stellar-xdr", - "syn 2.0.15", + "syn 2.0.18", "thiserror", ] @@ -922,24 +739,25 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" -version = "0.7.0" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=c39aad350e9c1e49105118058c75f8f0d7237b2b#c39aad350e9c1e49105118058c75f8f0d7237b2b" +version = "0.8.4" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694#8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694" dependencies = [ "serde", "serde_json", + "soroban-env-common", "soroban-env-host", "thiserror", ] [[package]] name = "soroban-native-sdk-macros" -version = "0.0.15" -source = "git+https://github.com/stellar/rs-soroban-env?rev=bad318a9805cf25ae64afb5122cb37af67a2edbd#bad318a9805cf25ae64afb5122cb37af67a2edbd" +version = "0.0.16" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c09c5f1b9af1a60d93c881a545607a84d36b88d2#c09c5f1b9af1a60d93c881a545607a84d36b88d2" dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -951,12 +769,12 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "0.7.0" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=c39aad350e9c1e49105118058c75f8f0d7237b2b#c39aad350e9c1e49105118058c75f8f0d7237b2b" +version = "0.8.4" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694#8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694" dependencies = [ "bytes-lit", "ed25519-dalek", - "rand 0.8.5", + "rand", "soroban-env-guest", "soroban-env-host", "soroban-ledger-snapshot", @@ -966,27 +784,27 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "0.7.0" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=c39aad350e9c1e49105118058c75f8f0d7237b2b#c39aad350e9c1e49105118058c75f8f0d7237b2b" +version = "0.8.4" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694#8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694" dependencies = [ - "darling 0.14.4", + "darling", "itertools", "proc-macro2", "quote", - "sha2 0.10.6", + "sha2", "soroban-env-common", "soroban-spec", "stellar-xdr", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "soroban-spec" -version = "0.7.0" -source = "git+https://github.com/stellar/rs-soroban-sdk?rev=c39aad350e9c1e49105118058c75f8f0d7237b2b#c39aad350e9c1e49105118058c75f8f0d7237b2b" +version = "0.8.4" +source = "git+https://github.com/stellar/rs-soroban-sdk?rev=8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694#8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694" dependencies = [ - "base64", - "darling 0.14.4", + "base64 0.13.1", + "darling", "itertools", "prettyplease", "proc-macro2", @@ -994,33 +812,35 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha2 0.10.6", + "sha2", "stellar-xdr", - "syn 1.0.109", + "syn 2.0.18", "thiserror", "wasmparser", ] [[package]] name = "soroban-wasmi" -version = "0.16.0-soroban2" -source = "git+https://github.com/stellar/wasmi?rev=862b32f5#862b32f53f9c6223911e79e0b0fc8592fb3bb04c" +version = "0.30.0-soroban" +source = "git+https://github.com/stellar/wasmi?rev=1a2bc7f#1a2bc7f3801c565c2dab22021255a164c05a7f76" dependencies = [ + "intx", + "smallvec", "soroban-wasmi_core", "spin", + "wasmi_arena", "wasmparser-nostd", ] [[package]] name = "soroban-wasmi_core" -version = "0.16.0-soroban2" -source = "git+https://github.com/stellar/wasmi?rev=862b32f5#862b32f53f9c6223911e79e0b0fc8592fb3bb04c" +version = "0.30.0-soroban" +source = "git+https://github.com/stellar/wasmi?rev=1a2bc7f#1a2bc7f3801c565c2dab22021255a164c05a7f76" dependencies = [ "downcast-rs", "libm", - "memory_units", - "num-rational", "num-traits", + "paste", ] [[package]] @@ -1053,11 +873,11 @@ dependencies = [ [[package]] name = "stellar-xdr" -version = "0.0.15" -source = "git+https://github.com/stellar/rs-stellar-xdr?rev=df3a145bfaf75504bc85f20eceb49b4536836e18#df3a145bfaf75504bc85f20eceb49b4536836e18" +version = "0.0.16" +source = "git+https://github.com/stellar/rs-stellar-xdr?rev=a2f370c930bb94f7bc0c9ea0426ecef3700b90a9#a2f370c930bb94f7bc0c9ea0426ecef3700b90a9" dependencies = [ "arbitrary", - "base64", + "base64 0.13.1", "crate-git-revision", "hex", "serde", @@ -1089,24 +909,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - [[package]] name = "thiserror" version = "1.0.40" @@ -1124,14 +935,14 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "time" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "serde", @@ -1141,34 +952,19 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "typenum" version = "1.16.0" @@ -1177,15 +973,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" - -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "version_check" @@ -1199,17 +989,11 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1217,24 +1001,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1242,22 +1026,27 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" + +[[package]] +name = "wasmi_arena" +version = "0.4.0" +source = "git+https://github.com/stellar/wasmi?rev=1a2bc7f#1a2bc7f3801c565c2dab22021255a164c05a7f76" [[package]] name = "wasmparser" @@ -1270,9 +1059,9 @@ dependencies = [ [[package]] name = "wasmparser-nostd" -version = "0.90.0" +version = "0.100.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92a94fbf4c521b038f41382df2056cf47099d3b7a0faa5a6e46f7771fd7c84a6" +checksum = "9157cab83003221bfd385833ab587a039f5d6fa7304854042ba358a3b09e0724" dependencies = [ "indexmap-nostd", ] @@ -1293,15 +1082,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1391,5 +1171,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] diff --git a/services/horizon/internal/integration/contracts/Cargo.toml b/services/horizon/internal/integration/contracts/Cargo.toml index 735e93a2f4..cd009b5db8 100644 --- a/services/horizon/internal/integration/contracts/Cargo.toml +++ b/services/horizon/internal/integration/contracts/Cargo.toml @@ -22,6 +22,7 @@ codegen-units = 1 lto = true [workspace.dependencies.soroban-sdk] -version = "0.7.0" +# TODO: Does a new version need to be released to update to 8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694 +version = "0.8.4" git = "https://github.com/stellar/rs-soroban-sdk" -rev = "c39aad350e9c1e49105118058c75f8f0d7237b2b" +rev = "8a7d2c3c8c5bc1664ab38f977ff947cc2a26d694" diff --git a/services/horizon/internal/integration/invokehostfunction_test.go b/services/horizon/internal/integration/invokehostfunction_test.go index 02432699e5..83b40a2e55 100644 --- a/services/horizon/internal/integration/invokehostfunction_test.go +++ b/services/horizon/internal/integration/invokehostfunction_test.go @@ -25,7 +25,6 @@ const increment_contract = "soroban_increment_contract.wasm" // contract code if needed to new wasm. func TestContractInvokeHostFunctionInstallContract(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -41,7 +40,8 @@ func TestContractInvokeHostFunctionInstallContract(t *testing.T) { require.NoError(t, err) installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) - tx, err := itest.SubmitOperations(&sourceAccount, itest.Master(), installContractOp) + // Set a very generous fee (10 XLM) which would satisfy any contract invocation + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, installContractOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) require.NoError(t, err) @@ -69,14 +69,11 @@ func TestContractInvokeHostFunctionInstallContract(t *testing.T) { invokeHostFunctionOpJson, ok := clientInvokeOp.Embedded.Records[0].(operations.InvokeHostFunction) assert.True(t, ok) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions, 1) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters, 0) - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Type, "upload_wasm") + assert.Equal(t, invokeHostFunctionOpJson.Type, "upload_wasm") } -func TestContractInvokeHostFunctionCreateContractBySourceAccount(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") +func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) { if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -93,13 +90,14 @@ func TestContractInvokeHostFunctionCreateContractBySourceAccount(t *testing.T) { // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) - itest.MustSubmitOperations(&sourceAccount, itest.Master(), installContractOp) + // Set a very generous fee (10 XLM) which would satisfy any contract invocation + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, installContractOp) // Create the contract require.NoError(t, err) createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) - tx, err := itest.SubmitOperations(&sourceAccount, itest.Master(), createContractOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, createContractOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -124,17 +122,13 @@ func TestContractInvokeHostFunctionCreateContractBySourceAccount(t *testing.T) { invokeHostFunctionOpJson, ok := clientInvokeOp.Embedded.Records[0].(operations.InvokeHostFunction) assert.True(t, ok) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions, 1) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters, 2) - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Type, "create_contract") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[0]["from"], "source_account") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[0]["type"], "string") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[1]["salt"], "110986164698320180327942133831752629430491002266485370052238869825166557303060") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[1]["type"], "string") + assert.Equal(t, invokeHostFunctionOpJson.Function, "HostFunctionTypeHostFunctionTypeCreateContract") + assert.Equal(t, invokeHostFunctionOpJson.Type, "create_contract") + assert.Equal(t, invokeHostFunctionOpJson.Address, sourceAccount.AccountID) + assert.Equal(t, invokeHostFunctionOpJson.Salt, "110986164698320180327942133831752629430491002266485370052238869825166557303060") } func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -149,15 +143,17 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { }) require.NoError(t, err) + accountId := xdr.MustAddress(sourceAccount.AccountID) + // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) - itest.MustSubmitOperations(&sourceAccount, itest.Master(), installContractOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, installContractOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) - tx, err := itest.SubmitOperations(&sourceAccount, itest.Master(), createContractOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, createContractOp) require.NoError(t, err) // contract has been deployed, now invoke a simple 'add' fn on the contract @@ -188,55 +184,68 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { U64: &secondParamValue, } - invokeHostFunctionOp := &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ + invokeHostFunctionOp := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIdParameter, + contractFnParameter, + firstParamScVal, + secondParamScVal, + }, + }, + Auth: []xdr.SorobanAuthorizationEntry{ { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIdParameter, - contractFnParameter, - firstParamScVal, - secondParamScVal, + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Nonce: 0, + SignatureArgs: nil, + }, + }, + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + FunctionName: "foo", + Args: nil, + }, }, + SubInvocations: nil, }, }, }, SourceAccount: sourceAccount.AccountID, Ext: xdr.TransactionExt{ V: 1, - SorobanData: &xdr.SorobanTransactionData{ - Resources: xdr.SorobanResources{ - Footprint: xdr.LedgerFootprint{ - ReadOnly: []xdr.LedgerKey{ - { - Type: xdr.LedgerEntryTypeContractData, - ContractData: &xdr.LedgerKeyContractData{ - ContractId: contractID, - Key: xdr.ScVal{ - Type: xdr.ScValTypeScvLedgerKeyContractExecutable, - // symbolic: no value - }, - }, + SorobanData: getMaxSorobanTransactionData(xdr.LedgerFootprint{ + ReadOnly: []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvLedgerKeyContractExecutable, + // symbolic: no value }, - contractCodeLedgerKey, }, - ReadWrite: []xdr.LedgerKey{}, }, - Instructions: 0, - ReadBytes: 0, - WriteBytes: 0, - ExtendedMetaDataSizeBytes: 0, - }, - RefundableFee: 1, - Ext: xdr.ExtensionPoint{ - V: 0, + contractCodeLedgerKey, }, - }, + ReadWrite: []xdr.LedgerKey{}, + }), }, } - tx, err = itest.SubmitOperations(&sourceAccount, itest.Master(), invokeHostFunctionOp) + tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, invokeHostFunctionOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -255,10 +264,8 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { assert.Equal(t, invokeHostFunctionResult.Code, xdr.InvokeHostFunctionResultCodeInvokeHostFunctionSuccess) // check the function response, should have summed the two input numbers - scvals := invokeHostFunctionResult.MustSuccess() - for _, scval := range scvals { - assert.Equal(t, xdr.Uint64(9), scval.MustU64()) - } + hash := invokeHostFunctionResult.MustSuccess() + assert.Equal(t, xdr.Uint64(9), hash) clientInvokeOp, err := itest.Client().Operations(horizonclient.OperationRequest{ ForTransaction: tx.Hash, @@ -267,21 +274,20 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { invokeHostFunctionOpJson, ok := clientInvokeOp.Embedded.Records[0].(operations.InvokeHostFunction) assert.True(t, ok) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions, 1) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters, 4) - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Type, "invoke_contract") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[0]["value"], "AAAADQAAACDhq+vRxjISTR62JpK1SAnzz1cZKpSpkRlwLJH6Zrzssg==") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[0]["type"], "Bytes") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[1]["value"], "AAAADwAAAANhZGQA") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[1]["type"], "Sym") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[2]["value"], "AAAABQAAAAAAAAAE") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[2]["type"], "U64") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[3]["value"], "AAAABQAAAAAAAAAF") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[3]["type"], "U64") + assert.Len(t, invokeHostFunctionOpJson.Parameters, 2) + assert.Equal(t, invokeHostFunctionOpJson.Function, "HostFunctionTypeHostFunctionTypeInvokeContract") + assert.Equal(t, invokeHostFunctionOpJson.Type, "invoke_contract") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[0].Value, "AAAADQAAACDhq+vRxjISTR62JpK1SAnzz1cZKpSpkRlwLJH6Zrzssg==") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[0].Type, "Bytes") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[1].Value, "AAAADwAAAANhZGQA") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[1].Type, "Sym") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[2].Value, "AAAABQAAAAAAAAAE") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[2].Type, "U64") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[3].Value, "AAAABQAAAAAAAAAF") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[3].Type, "U64") } func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -299,12 +305,12 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), increment_contract) - itest.MustSubmitOperations(&sourceAccount, itest.Master(), installContractOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, installContractOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), increment_contract, "a1", itest.GetPassPhrase()) - tx, err := itest.SubmitOperations(&sourceAccount, itest.Master(), createContractOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, createContractOp) require.NoError(t, err) // contract has been deployed, now invoke a simple 'add' fn on the contract @@ -324,64 +330,48 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { } contractStateFootprintSym := xdr.ScSymbol("COUNTER") - invokeHostFunctionOp := &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIdParameter, - contractFnParameter, - }, - }, + invokeHostFunctionOp := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIdParameter, + contractFnParameter, }, }, SourceAccount: sourceAccount.AccountID, Ext: xdr.TransactionExt{ V: 1, - SorobanData: &xdr.SorobanTransactionData{ - Resources: xdr.SorobanResources{ - Footprint: xdr.LedgerFootprint{ - ReadOnly: []xdr.LedgerKey{ - { - Type: xdr.LedgerEntryTypeContractData, - ContractData: &xdr.LedgerKeyContractData{ - ContractId: contractID, - Key: xdr.ScVal{ - Type: xdr.ScValTypeScvLedgerKeyContractExecutable, - // symbolic: no value - }, - }, + SorobanData: getMaxSorobanTransactionData(xdr.LedgerFootprint{ + ReadOnly: []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvLedgerKeyContractExecutable, + // symbolic: no value }, - contractCodeLedgerKey, }, - ReadWrite: []xdr.LedgerKey{ - { - Type: xdr.LedgerEntryTypeContractData, - ContractData: &xdr.LedgerKeyContractData{ - ContractId: contractID, - Key: xdr.ScVal{ - Type: xdr.ScValTypeScvSymbol, - Sym: &contractStateFootprintSym, - }, - }, + }, + contractCodeLedgerKey, + }, + ReadWrite: []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvSymbol, + Sym: &contractStateFootprintSym, }, }, }, - Instructions: 0, - ReadBytes: 0, - WriteBytes: 0, - ExtendedMetaDataSizeBytes: 0, - }, - RefundableFee: 1, - Ext: xdr.ExtensionPoint{ - V: 0, }, - }, + }), }, } - tx, err = itest.SubmitOperations(&sourceAccount, itest.Master(), invokeHostFunctionOp) + tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), 10*stroopsIn1XLM, invokeHostFunctionOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -400,10 +390,8 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { assert.Equal(t, invokeHostFunctionResult.Code, xdr.InvokeHostFunctionResultCodeInvokeHostFunctionSuccess) // check the function response, should have incremented state from 0 to 1 - scvals := invokeHostFunctionResult.MustSuccess() - for _, scval := range scvals { - assert.Equal(t, xdr.Uint32(1), scval.MustU32()) - } + hash := invokeHostFunctionResult.MustSuccess() + assert.Equal(t, xdr.Uint32(1), hash) clientInvokeOp, err := itest.Client().Operations(horizonclient.OperationRequest{ ForTransaction: tx.Hash, @@ -412,68 +400,68 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { invokeHostFunctionOpJson, ok := clientInvokeOp.Embedded.Records[0].(operations.InvokeHostFunction) assert.True(t, ok) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions, 1) - assert.Len(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters, 2) - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Type, "invoke_contract") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[0]["value"], "AAAADQAAACDhq+vRxjISTR62JpK1SAnzz1cZKpSpkRlwLJH6Zrzssg==") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[0]["type"], "Bytes") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[1]["value"], "AAAADwAAAAlpbmNyZW1lbnQAAAA=") - assert.Equal(t, invokeHostFunctionOpJson.HostFunctions[0].Parameters[1]["type"], "Sym") + assert.Len(t, invokeHostFunctionOpJson.Parameters, 2) + assert.Equal(t, invokeHostFunctionOpJson.Function, "HostFunctionTypeHostFunctionTypeInvokeContract") + assert.Equal(t, invokeHostFunctionOpJson.Type, "invoke_contract") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[0].Value, "AAAADQAAACDhq+vRxjISTR62JpK1SAnzz1cZKpSpkRlwLJH6Zrzssg==") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[0].Type, "Bytes") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[1].Value, "AAAADwAAAAlpbmNyZW1lbnQAAAA=") + assert.Equal(t, invokeHostFunctionOpJson.Parameters[1].Type, "Sym") } -func assembleInstallContractCodeOp(t *testing.T, sourceAccount string, wasmFileName string) *txnbuild.InvokeHostFunctions { - // Assemble the InvokeHostFunction CreateContract operation: +const stroopsIn1XLM = int64(10_000_000) + +func getMaxSorobanTransactionData(fp xdr.LedgerFootprint) *xdr.SorobanTransactionData { + // From https://soroban.stellar.org/docs/learn/fees-and-metering#resource-limits + return &xdr.SorobanTransactionData{ + Resources: xdr.SorobanResources{ + Footprint: fp, + Instructions: 40_000_000, + ReadBytes: 200 * 1024, + WriteBytes: 100 * 1024, + ExtendedMetaDataSizeBytes: 200 * 1024, + }, + // 1 XML should be future-proof + RefundableFee: 1 * xdr.Int64(stroopsIn1XLM), + Ext: xdr.ExtensionPoint{ + V: 0, + }, + } +} + +func assembleInstallContractCodeOp(t *testing.T, sourceAccount string, wasmFileName string) *txnbuild.InvokeHostFunction { + // Assemble the InvokeHostFunction UploadContractWasm operation: // CAP-0047 - https://github.com/stellar/stellar-protocol/blob/master/core/cap-0047.md#creating-a-contract-using-invokehostfunctionop contract, err := os.ReadFile(filepath.Join("testdata", wasmFileName)) require.NoError(t, err) t.Logf("Contract File Contents: %v", hex.EncodeToString(contract)) - installContractCodeArgs, err := xdr.UploadContractWasmArgs{Code: contract}.MarshalBinary() - assert.NoError(t, err) - contractHash := sha256.Sum256(installContractCodeArgs) + contractHash := sha256.Sum256(contract) - return &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm, - UploadContractWasm: &xdr.UploadContractWasmArgs{ - Code: contract, - }, - }, - }, + return &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeUploadContractWasm, + Wasm: &contract, }, SourceAccount: sourceAccount, Ext: xdr.TransactionExt{ V: 1, - SorobanData: &xdr.SorobanTransactionData{ - Resources: xdr.SorobanResources{ - Footprint: xdr.LedgerFootprint{ - ReadWrite: []xdr.LedgerKey{ - { - Type: xdr.LedgerEntryTypeContractCode, - ContractCode: &xdr.LedgerKeyContractCode{ - Hash: contractHash, - }, - }, + SorobanData: getMaxSorobanTransactionData(xdr.LedgerFootprint{ + ReadWrite: []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractCode, + ContractCode: &xdr.LedgerKeyContractCode{ + Hash: contractHash, }, }, - Instructions: 0, - ReadBytes: 0, - WriteBytes: 0, - ExtendedMetaDataSizeBytes: 0, }, - RefundableFee: 1, - Ext: xdr.ExtensionPoint{ - V: 0, - }, - }, + }), }, } } -func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName string, contractSalt string, passPhrase string) *txnbuild.InvokeHostFunctions { +func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName string, contractSalt string, passPhrase 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 @@ -482,25 +470,31 @@ func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName s salt := sha256.Sum256([]byte(contractSalt)) t.Logf("Salt hash: %v", hex.EncodeToString(salt[:])) + saltParameter := xdr.Uint256(salt) networkId := xdr.Hash(sha256.Sum256([]byte(passPhrase))) + accountId := xdr.MustAddress(sourceAccount) preImage := xdr.HashIdPreimage{ - Type: xdr.EnvelopeTypeEnvelopeTypeContractIdFromSourceAccount, - SourceAccountContractId: &xdr.HashIdPreimageSourceAccountContractId{ + Type: xdr.EnvelopeTypeEnvelopeTypeContractId, + ContractId: &xdr.HashIdPreimageContractId{ NetworkId: networkId, - Salt: salt, + ContractIdPreimage: xdr.ContractIdPreimage{ + Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAddress, + FromAddress: &xdr.ContractIdPreimageFromAddress{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Salt: salt, + }, + }, }, } - preImage.SourceAccountContractId.SourceAccount.SetAddress(sourceAccount) xdrPreImageBytes, err := preImage.MarshalBinary() require.NoError(t, err) hashedContractID := sha256.Sum256(xdrPreImageBytes) - saltParameter := xdr.Uint256(salt) - - installContractCodeArgs, err := xdr.UploadContractWasmArgs{Code: contract}.MarshalBinary() - assert.NoError(t, err) - contractHash := xdr.Hash(sha256.Sum256(installContractCodeArgs)) + contractHash := xdr.Hash(sha256.Sum256(contract)) ledgerKey := xdr.LedgerKeyContractData{ ContractId: xdr.Hash(hashedContractID), @@ -510,55 +504,45 @@ func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName s }, } - return &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, - CreateContract: &xdr.CreateContractArgs{ - ContractId: xdr.ContractId{ - Type: xdr.ContractIdTypeContractIdFromSourceAccount, - Salt: &saltParameter, - }, - Executable: xdr.ScContractExecutable{ - Type: xdr.ScContractExecutableTypeSccontractExecutableWasmRef, - WasmId: &contractHash, + return &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, + CreateContract: &xdr.CreateContractArgs{ + ContractIdPreimage: xdr.ContractIdPreimage{ + Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAddress, + FromAddress: &xdr.ContractIdPreimageFromAddress{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, }, + Salt: saltParameter, }, }, + Executable: xdr.ScContractExecutable{ + Type: xdr.ScContractExecutableTypeSccontractExecutableWasmRef, + WasmId: &contractHash, + }, }, }, SourceAccount: sourceAccount, Ext: xdr.TransactionExt{ V: 1, - SorobanData: &xdr.SorobanTransactionData{ - Resources: xdr.SorobanResources{ - Footprint: xdr.LedgerFootprint{ - ReadWrite: []xdr.LedgerKey{ - { - Type: xdr.LedgerEntryTypeContractData, - ContractData: &ledgerKey, - }, - }, - ReadOnly: []xdr.LedgerKey{ - { - Type: xdr.LedgerEntryTypeContractCode, - ContractCode: &xdr.LedgerKeyContractCode{ - Hash: contractHash, - }, - }, - }, + SorobanData: getMaxSorobanTransactionData(xdr.LedgerFootprint{ + ReadWrite: []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &ledgerKey, }, - Instructions: 0, - ReadBytes: 0, - WriteBytes: 0, - ExtendedMetaDataSizeBytes: 0, }, - RefundableFee: 1, - Ext: xdr.ExtensionPoint{ - V: 0, + ReadOnly: []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractCode, + ContractCode: &xdr.LedgerKeyContractCode{ + Hash: contractHash, + }, + }, }, - }, + }), }, } } diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index 803e49c7dd..172ff6a46a 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -6,6 +6,9 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/stellar/go/amount" "github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/keypair" @@ -15,9 +18,6 @@ import ( "github.com/stellar/go/strkey" "github.com/stellar/go/txnbuild" "github.com/stellar/go/xdr" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) const sac_contract = "soroban_sac_test.wasm" @@ -25,9 +25,8 @@ const sac_contract = "soroban_sac_test.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 // contract code if needed to new wasm. -func TestContractMintToAccount(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") +func TestContractMintToAccount(t *testing.T) { if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -102,7 +101,6 @@ func TestContractMintToAccount(t *testing.T) { } func TestContractMintToContract(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -119,7 +117,7 @@ func TestContractMintToContract(t *testing.T) { assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) // Create recipient contract - recipientContractID := mustCreateAndInstallContract(itest, itest.Master(), "a1", add_u64_contract) + recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a1", add_u64_contract) strkeyRecipientContractID, err := strkey.Encode(strkey.VersionByteContract, recipientContractID[:]) assert.NoError(t, err) @@ -139,11 +137,11 @@ func TestContractMintToContract(t *testing.T) { balanceAmount, _ := assertInvokeHostFnSucceeds( itest, itest.Master(), - balance(itest, issuer, asset, contractAddressParam(recipientContractID)), + contractBalance(itest, issuer, asset, recipientContractID), ) assert.Equal(itest.CurrentTest(), xdr.ScValTypeScvI128, balanceAmount.Type) assert.Equal(itest.CurrentTest(), xdr.Uint64(math.MaxUint64-3), (*balanceAmount.I128).Lo) - assert.Equal(itest.CurrentTest(), xdr.Uint64(math.MaxInt64), (*balanceAmount.I128).Hi) + assert.Equal(itest.CurrentTest(), xdr.Int64(math.MaxInt64), (*balanceAmount.I128).Hi) assertEventPayments(itest, mintTx, asset, "", strkeyRecipientContractID, "mint", amount.String128(mintAmount)) // calling transfer from the issuer account will also mint the asset @@ -160,11 +158,11 @@ func TestContractMintToContract(t *testing.T) { balanceAmount, _ = assertInvokeHostFnSucceeds( itest, itest.Master(), - balance(itest, issuer, asset, contractAddressParam(recipientContractID)), + contractBalance(itest, issuer, asset, recipientContractID), ) assert.Equal(itest.CurrentTest(), xdr.ScValTypeScvI128, balanceAmount.Type) assert.Equal(itest.CurrentTest(), xdr.Uint64(math.MaxUint64), (*balanceAmount.I128).Lo) - assert.Equal(itest.CurrentTest(), xdr.Uint64(math.MaxInt64), (*balanceAmount.I128).Hi) + assert.Equal(itest.CurrentTest(), xdr.Int64(math.MaxInt64), (*balanceAmount.I128).Hi) // 2^127 - 1 balanceContracts := new(big.Int).Lsh(big.NewInt(1), 127) @@ -181,7 +179,6 @@ func TestContractMintToContract(t *testing.T) { } func TestContractTransferBetweenAccounts(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -253,7 +250,6 @@ func TestContractTransferBetweenAccounts(t *testing.T) { } func TestContractTransferBetweenAccountAndContract(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -287,7 +283,7 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { ) // Create recipient contract - recipientContractID := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) + recipientContractID, recipientContractHash := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) strkeyRecipientContractID, err := strkey.Encode(strkey.VersionByteContract, recipientContractID[:]) assert.NoError(t, err) @@ -295,7 +291,7 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { assertInvokeHostFnSucceeds( itest, itest.Master(), - initAssetContract(itest, issuer, asset, recipientContractID), + initAssetContract(itest, issuer, asset, recipientContractID, recipientContractHash), ) // Add funds to recipient contract @@ -342,11 +338,7 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { _, transferTx = assertInvokeHostFnSucceeds( itest, recipientKp, - transfer(itest, - strkeyRecipientContractID, - asset, - "500", - accountAddressParam(recipient.GetAccountID())), + transferFromContract(itest, recipientKp.Address(), asset, recipientContractID, recipientContractHash, "500", accountAddressParam(recipient.GetAccountID())), ) assertContainsEffect(t, getTxEffects(itest, transferTx, asset), effects.EffectContractDebited, effects.EffectAccountCredited) @@ -365,15 +357,14 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { balanceAmount, _ := assertInvokeHostFnSucceeds( itest, itest.Master(), - balance(itest, issuer, asset, contractAddressParam(recipientContractID)), + contractBalance(itest, issuer, asset, recipientContractID), ) assert.Equal(itest.CurrentTest(), xdr.ScValTypeScvI128, balanceAmount.Type) assert.Equal(itest.CurrentTest(), xdr.Uint64(5300000000), (*balanceAmount.I128).Lo) - assert.Equal(itest.CurrentTest(), xdr.Uint64(0), (*balanceAmount.I128).Hi) + assert.Equal(itest.CurrentTest(), xdr.Int64(0), (*balanceAmount.I128).Hi) } func TestContractTransferBetweenContracts(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -390,12 +381,12 @@ func TestContractTransferBetweenContracts(t *testing.T) { assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) // Create recipient contract - recipientContractID := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) + recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) strkeyRecipientContractID, err := strkey.Encode(strkey.VersionByteContract, recipientContractID[:]) assert.NoError(t, err) // Create emitter contract - emitterContractID := mustCreateAndInstallContract(itest, itest.Master(), "a2", sac_contract) + emitterContractID, emitterContractHash := mustCreateAndInstallContract(itest, itest.Master(), "a2", sac_contract) strkeyEmitterContractID, err := strkey.Encode(strkey.VersionByteContract, emitterContractID[:]) assert.NoError(t, err) @@ -403,7 +394,7 @@ func TestContractTransferBetweenContracts(t *testing.T) { assertInvokeHostFnSucceeds( itest, itest.Master(), - initAssetContract(itest, issuer, asset, emitterContractID), + initAssetContract(itest, issuer, asset, emitterContractID, emitterContractHash), ) // Add funds to emitter contract @@ -417,7 +408,7 @@ func TestContractTransferBetweenContracts(t *testing.T) { _, transferTx := assertInvokeHostFnSucceeds( itest, itest.Master(), - transfer(itest, strkeyEmitterContractID, asset, "10", contractAddressParam(recipientContractID)), + transferFromContract(itest, issuer, asset, emitterContractID, emitterContractHash, "10", contractAddressParam(recipientContractID)), ) assertContainsEffect(t, getTxEffects(itest, transferTx, asset), effects.EffectContractCredited, effects.EffectContractDebited) @@ -426,21 +417,20 @@ func TestContractTransferBetweenContracts(t *testing.T) { emitterBalanceAmount, _ := assertInvokeHostFnSucceeds( itest, itest.Master(), - balance(itest, issuer, asset, contractAddressParam(emitterContractID)), + contractBalance(itest, issuer, asset, emitterContractID), ) assert.Equal(itest.CurrentTest(), xdr.ScValTypeScvI128, emitterBalanceAmount.Type) assert.Equal(itest.CurrentTest(), xdr.Uint64(9900000000), (*emitterBalanceAmount.I128).Lo) - assert.Equal(itest.CurrentTest(), xdr.Uint64(0), (*emitterBalanceAmount.I128).Hi) + assert.Equal(itest.CurrentTest(), xdr.Int64(0), (*emitterBalanceAmount.I128).Hi) recipientBalanceAmount, _ := assertInvokeHostFnSucceeds( itest, itest.Master(), - balance(itest, issuer, asset, contractAddressParam(recipientContractID)), + contractBalance(itest, issuer, asset, recipientContractID), ) - assert.Equal(itest.CurrentTest(), xdr.ScValTypeScvI128, recipientBalanceAmount.Type) assert.Equal(itest.CurrentTest(), xdr.Uint64(100000000), (*recipientBalanceAmount.I128).Lo) - assert.Equal(itest.CurrentTest(), xdr.Uint64(0), (*recipientBalanceAmount.I128).Hi) + assert.Equal(itest.CurrentTest(), xdr.Int64(0), (*recipientBalanceAmount.I128).Hi) assertAssetStats(itest, assetStats{ code: code, @@ -455,7 +445,6 @@ func TestContractTransferBetweenContracts(t *testing.T) { } func TestContractBurnFromAccount(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -527,7 +516,6 @@ func TestContractBurnFromAccount(t *testing.T) { } func TestContractBurnFromContract(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -544,14 +532,14 @@ func TestContractBurnFromContract(t *testing.T) { assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) // Create recipient contract - recipientContractID := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) + recipientContractID, recipientContractHash := mustCreateAndInstallContract(itest, itest.Master(), "a1", sac_contract) strkeyRecipientContractID, err := strkey.Encode(strkey.VersionByteContract, recipientContractID[:]) assert.NoError(t, err) // init contract with asset contract id assertInvokeHostFnSucceeds( itest, itest.Master(), - initAssetContract(itest, issuer, asset, recipientContractID), + initAssetContract(itest, issuer, asset, recipientContractID, recipientContractHash), ) // Add funds to recipient contract @@ -565,18 +553,18 @@ func TestContractBurnFromContract(t *testing.T) { _, burnTx := assertInvokeHostFnSucceeds( itest, itest.Master(), - burnSelf(itest, issuer, recipientContractID, "10"), + burnSelf(itest, issuer, asset, recipientContractID, recipientContractHash, "10"), ) balanceAmount, _ := assertInvokeHostFnSucceeds( itest, itest.Master(), - balance(itest, issuer, asset, contractAddressParam(recipientContractID)), + contractBalance(itest, issuer, asset, recipientContractID), ) assert.Equal(itest.CurrentTest(), xdr.ScValTypeScvI128, balanceAmount.Type) assert.Equal(itest.CurrentTest(), xdr.Uint64(9900000000), (*balanceAmount.I128).Lo) - assert.Equal(itest.CurrentTest(), xdr.Uint64(0), (*balanceAmount.I128).Hi) + assert.Equal(itest.CurrentTest(), xdr.Int64(0), (*balanceAmount.I128).Hi) assertContainsEffect(t, getTxEffects(itest, burnTx, asset), effects.EffectContractDebited) @@ -594,7 +582,6 @@ func TestContractBurnFromContract(t *testing.T) { } func TestContractClawbackFromAccount(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -669,7 +656,6 @@ func TestContractClawbackFromAccount(t *testing.T) { } func TestContractClawbackFromContract(t *testing.T) { - t.Skip("sac contract tests disabled until footprint/fees are set correctly") if integration.GetCoreMaxSupportedProtocol() < 20 { t.Skip("This test run does not support less than Protocol 20") } @@ -696,7 +682,7 @@ func TestContractClawbackFromContract(t *testing.T) { assertInvokeHostFnSucceeds(itest, itest.Master(), createSAC(itest, issuer, asset)) // Create recipient contract - recipientContractID := mustCreateAndInstallContract(itest, itest.Master(), "a2", sac_contract) + recipientContractID, _ := mustCreateAndInstallContract(itest, itest.Master(), "a2", sac_contract) strkeyRecipientContractID, err := strkey.Encode(strkey.VersionByteContract, recipientContractID[:]) assert.NoError(itest.CurrentTest(), err) @@ -717,12 +703,11 @@ func TestContractClawbackFromContract(t *testing.T) { balanceAmount, _ := assertInvokeHostFnSucceeds( itest, itest.Master(), - balance(itest, issuer, asset, contractAddressParam(recipientContractID)), + contractBalance(itest, issuer, asset, recipientContractID), ) - assert.Equal(itest.CurrentTest(), xdr.ScValTypeScvI128, balanceAmount.Type) assert.Equal(itest.CurrentTest(), xdr.Uint64(9900000000), (*balanceAmount.I128).Lo) - assert.Equal(itest.CurrentTest(), xdr.Uint64(0), (*balanceAmount.I128).Hi) + assert.Equal(itest.CurrentTest(), xdr.Int64(0), (*balanceAmount.I128).Hi) assertContainsEffect(t, getTxEffects(itest, clawTx, asset), effects.EffectContractDebited) @@ -896,56 +881,226 @@ func i128Param(hi int64, lo uint64) xdr.ScVal { } } -func createSAC(itest *integration.Test, sourceAccount string, asset xdr.Asset) *txnbuild.InvokeHostFunctions { - return addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ +func baseSACFootPrint(itest *integration.Test, asset xdr.Asset) []xdr.LedgerKey { + contractID := stellarAssetContractID(itest, asset) + metadata := xdr.ScSymbol("METADATA") + admin := xdr.ScSymbol("Admin") + assetInfo := xdr.ScSymbol("AssetInfo") + adminVec := &xdr.ScVec{ + { + Type: xdr.ScValTypeScvSymbol, + Sym: &admin, + }, + } + assetInfoVec := &xdr.ScVec{ + { + Type: xdr.ScValTypeScvSymbol, + Sym: &assetInfo, + }, + } + masterAddress := xdr.MustAddress(itest.MasterAccount().GetAccountID()) + return []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeAccount, + Account: &xdr.LedgerKeyAccount{AccountId: masterAddress}, + }, + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvSymbol, + Sym: &metadata, + }, + }, + }, + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvVec, + Vec: &adminVec, + }, + }, + }, + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvVec, + Vec: &assetInfoVec, + }, + }, + }, + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvLedgerKeyContractExecutable, + }, + }, + }, + } +} + +func tokenLedgerKey(contractID xdr.Hash) xdr.LedgerKey { + token := xdr.ScSymbol("Token") + tokenVec := &xdr.ScVec{ + { + Type: xdr.ScValTypeScvSymbol, + Sym: &token, + }, + } + return xdr.LedgerKey{ + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvVec, + Vec: &tokenVec, + }, + }, + } +} + +func sacTestContractCodeLedgerKeys(contractID xdr.Hash, contractHash xdr.Hash) []xdr.LedgerKey { + return []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvLedgerKeyContractExecutable, + }, + }, + }, + { + Type: xdr.LedgerEntryTypeContractCode, + ContractCode: &xdr.LedgerKeyContractCode{ + Hash: contractHash, + }, + }, + } +} + +func addressLedgerKeys(itest *integration.Test, contractAsset xdr.Asset, address xdr.ScAddress) []xdr.LedgerKey { + contractID := stellarAssetContractID(itest, contractAsset) + switch address.Type { + case xdr.ScAddressTypeScAddressTypeAccount: + // FIXME: if I comment out this "if" , tx_internal_error is returned due to a Core bug + // we should be able to uncomment it in the future + if address.AccountId.Address() == contractAsset.GetIssuer() { + return nil + } + return []xdr.LedgerKey{ { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, - CreateContract: &xdr.CreateContractArgs{ - ContractId: xdr.ContractId{ - Type: xdr.ContractIdTypeContractIdFromAsset, - Asset: &asset, - }, - Executable: xdr.ScContractExecutable{ - Type: xdr.ScContractExecutableTypeSccontractExecutableToken, - }, + Type: xdr.LedgerEntryTypeTrustline, + TrustLine: &xdr.LedgerKeyTrustLine{ + AccountId: *address.AccountId, + Asset: contractAsset.ToTrustLineAsset(), + }, + }, + } + case xdr.ScAddressTypeScAddressTypeContract: + balance := xdr.ScSymbol("Balance") + vec := &xdr.ScVec{ + { + Type: xdr.ScValTypeScvSymbol, + Sym: &balance, + }, + { + Type: xdr.ScValTypeScvAddress, + Address: &xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeContract, + ContractId: address.ContractId, + }, + }, + } + return []xdr.LedgerKey{ + { + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvVec, + Vec: &vec, }, }, }, + } + } + + return nil +} + +func footprintForRecipientAddress(itest *integration.Test, contractAsset xdr.Asset, address xdr.ScAddress) xdr.LedgerFootprint { + footPrint := xdr.LedgerFootprint{ + ReadOnly: baseSACFootPrint(itest, contractAsset), + } + footPrint.ReadWrite = addressLedgerKeys(itest, contractAsset, address) + return footPrint +} + +func createSAC(itest *integration.Test, sourceAccount string, asset xdr.Asset) *txnbuild.InvokeHostFunction { + footPrint := xdr.LedgerFootprint{ + ReadWrite: baseSACFootPrint(itest, asset), + } + + invokeHostFunction := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract, + CreateContract: &xdr.CreateContractArgs{ + ContractIdPreimage: xdr.ContractIdPreimage{ + Type: xdr.ContractIdPreimageTypeContractIdPreimageFromAsset, + FromAsset: &asset, + }, + Executable: xdr.ScContractExecutable{ + Type: xdr.ScContractExecutableTypeSccontractExecutableToken, + }, + }, }, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } + + return invokeHostFunction } -func mint(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunctions { +func mint(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunction { return mintWithAmt(itest, sourceAccount, asset, i128Param(0, uint64(amount.MustParse(assetAmount))), recipient) } -func mintWithAmt(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount xdr.ScVal, recipient xdr.ScVal) *txnbuild.InvokeHostFunctions { - invokeHostFn := addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIDParam(stellarAssetContractID(itest, asset)), - functionNameParam("mint"), - accountAddressParam(sourceAccount), - recipient, - assetAmount, - }, - }, +func mintWithAmt(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount xdr.ScVal, recipient xdr.ScVal) *txnbuild.InvokeHostFunction { + footPrint := footprintForRecipientAddress(itest, asset, *recipient.Address) + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(stellarAssetContractID(itest, asset)), + functionNameParam("mint"), + accountAddressParam(sourceAccount), + recipient, + assetAmount, }, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } - invokeHostFn.Functions[0].Auth = addAuthNextInvokerFlow( + invokeHostFn.Auth = addAuthNextInvokerFlow( "mint", stellarAssetContractID(itest, asset), xdr.ScVec{ - accountAddressParam(sourceAccount), recipient, assetAmount, }) @@ -953,24 +1108,29 @@ func mintWithAmt(itest *integration.Test, sourceAccount string, asset xdr.Asset, return invokeHostFn } -func initAssetContract(itest *integration.Test, sourceAccount string, asset xdr.Asset, sacTestcontractID xdr.Hash) *txnbuild.InvokeHostFunctions { - invokeHostFn := addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIDParam(sacTestcontractID), - functionNameParam("init"), - contractIDParam(stellarAssetContractID(itest, asset)), - }, - }, +func initAssetContract(itest *integration.Test, sourceAccount string, asset xdr.Asset, sacTestcontractID, sacTestcontractHash xdr.Hash) *txnbuild.InvokeHostFunction { + footPrint := xdr.LedgerFootprint{ + ReadOnly: sacTestContractCodeLedgerKeys(sacTestcontractID, sacTestcontractHash), + ReadWrite: []xdr.LedgerKey{tokenLedgerKey(sacTestcontractID)}, + } + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(sacTestcontractID), + functionNameParam("init"), + contractIDParam(stellarAssetContractID(itest, asset)), }, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } - invokeHostFn.Functions[0].Auth = addAuthNextInvokerFlow( + invokeHostFn.Auth = addAuthNextInvokerFlow( "init", sacTestcontractID, xdr.ScVec{ @@ -980,30 +1140,31 @@ func initAssetContract(itest *integration.Test, sourceAccount string, asset xdr. return invokeHostFn } -func clawback(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunctions { - invokeHostFn := addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIDParam(stellarAssetContractID(itest, asset)), - functionNameParam("clawback"), - accountAddressParam(sourceAccount), - recipient, - i128Param(0, uint64(amount.MustParse(assetAmount))), - }, - }, +func clawback(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunction { + footPrint := footprintForRecipientAddress(itest, asset, *recipient.Address) + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(stellarAssetContractID(itest, asset)), + functionNameParam("clawback"), + accountAddressParam(sourceAccount), + recipient, + i128Param(0, uint64(amount.MustParse(assetAmount))), }, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } - invokeHostFn.Functions[0].Auth = addAuthNextInvokerFlow( + invokeHostFn.Auth = addAuthNextInvokerFlow( "clawback", stellarAssetContractID(itest, asset), xdr.ScVec{ - accountAddressParam(sourceAccount), recipient, i128Param(0, uint64(amount.MustParse(assetAmount))), }) @@ -1011,54 +1172,68 @@ func clawback(itest *integration.Test, sourceAccount string, asset xdr.Asset, as return invokeHostFn } -func balance(itest *integration.Test, sourceAccount string, asset xdr.Asset, holder xdr.ScVal) *txnbuild.InvokeHostFunctions { - return addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIDParam(stellarAssetContractID(itest, asset)), - functionNameParam("balance"), - holder, +func contractBalance(itest *integration.Test, sourceAccount string, asset xdr.Asset, sacTestcontractID xdr.Hash) *txnbuild.InvokeHostFunction { + contractID := stellarAssetContractID(itest, asset) + footPrint := xdr.LedgerFootprint{ + ReadOnly: append( + addressLedgerKeys(itest, asset, *contractAddressParam(sacTestcontractID).Address), + xdr.LedgerKey{ + Type: xdr.LedgerEntryTypeContractData, + ContractData: &xdr.LedgerKeyContractData{ + ContractId: contractID, + Key: xdr.ScVal{ + Type: xdr.ScValTypeScvLedgerKeyContractExecutable, }, }, }, + ), + } + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(stellarAssetContractID(itest, asset)), + functionNameParam("balance"), + contractAddressParam(sacTestcontractID), + }, }, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } + + return invokeHostFn } -func transfer(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunctions { - return transferWithAmount( - itest, - sourceAccount, - asset, - i128Param(0, uint64(amount.MustParse(assetAmount))), - recipient, - ) +func transfer(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunction { + return transferWithAmount(itest, sourceAccount, asset, i128Param(0, uint64(amount.MustParse(assetAmount))), recipient) } -func transferWithAmount(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount xdr.ScVal, recipient xdr.ScVal) *txnbuild.InvokeHostFunctions { - invokeHostFn := addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIDParam(stellarAssetContractID(itest, asset)), - functionNameParam("transfer"), - accountAddressParam(sourceAccount), - recipient, - assetAmount, - }, - }, +func transferWithAmount(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount xdr.ScVal, recipient xdr.ScVal) *txnbuild.InvokeHostFunction { + footPrint := footprintForRecipientAddress(itest, asset, *recipient.Address) + footPrint.ReadWrite = append(footPrint.ReadWrite, addressLedgerKeys(itest, asset, *accountAddressParam(sourceAccount).Address)...) + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(stellarAssetContractID(itest, asset)), + functionNameParam("transfer"), + accountAddressParam(sourceAccount), + recipient, + assetAmount, }, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } - invokeHostFn.Functions[0].Auth = addAuthNextInvokerFlow( + invokeHostFn.Auth = addAuthNextInvokerFlow( "transfer", stellarAssetContractID(itest, asset), xdr.ScVec{ @@ -1070,25 +1245,55 @@ func transferWithAmount(itest *integration.Test, sourceAccount string, asset xdr return invokeHostFn } +func transferFromContract(itest *integration.Test, sourceAccount string, asset xdr.Asset, sacTestcontractID xdr.Hash, sacTestContractHash xdr.Hash, assetAmount string, recipient xdr.ScVal) *txnbuild.InvokeHostFunction { + footPrint := footprintForRecipientAddress(itest, asset, *recipient.Address) + footPrint.ReadOnly = append(footPrint.ReadOnly, tokenLedgerKey(sacTestcontractID)) + footPrint.ReadOnly = append(footPrint.ReadOnly, sacTestContractCodeLedgerKeys(sacTestcontractID, sacTestContractHash)...) + footPrint.ReadWrite = append(footPrint.ReadWrite, addressLedgerKeys(itest, asset, *contractAddressParam(sacTestcontractID).Address)...) + + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(sacTestcontractID), + functionNameParam("transfer"), + recipient, + i128Param(0, uint64(amount.MustParse(assetAmount))), + }, + }, + SourceAccount: sourceAccount, + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } + + return invokeHostFn +} + // Invokes burn_self from the sac_test contract (which just burns assets from itself) -func burnSelf(itest *integration.Test, sourceAccount string, sacTestcontractID xdr.Hash, assetAmount string) *txnbuild.InvokeHostFunctions { - invokeHostFn := addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIDParam(sacTestcontractID), - functionNameParam("burn_self"), - i128Param(0, uint64(amount.MustParse(assetAmount))), - }, - }, +func burnSelf(itest *integration.Test, sourceAccount string, asset xdr.Asset, sacTestcontractID xdr.Hash, sacTestContractHash xdr.Hash, assetAmount string) *txnbuild.InvokeHostFunction { + footPrint := footprintForRecipientAddress(itest, asset, *contractAddressParam(sacTestcontractID).Address) + footPrint.ReadOnly = append(footPrint.ReadOnly, tokenLedgerKey(sacTestcontractID)) + footPrint.ReadOnly = append(footPrint.ReadOnly, sacTestContractCodeLedgerKeys(sacTestcontractID, sacTestContractHash)...) + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(sacTestcontractID), + functionNameParam("burn_self"), + i128Param(0, uint64(amount.MustParse(assetAmount))), }, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } - invokeHostFn.Functions[0].Auth = addAuthNextInvokerFlow( + invokeHostFn.Auth = addAuthNextInvokerFlow( "burn_self", sacTestcontractID, xdr.ScVec{ @@ -1098,25 +1303,27 @@ func burnSelf(itest *integration.Test, sourceAccount string, sacTestcontractID x return invokeHostFn } -func burn(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string) *txnbuild.InvokeHostFunctions { - invokeHostFn := addFootprint(itest, &txnbuild.InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - contractIDParam(stellarAssetContractID(itest, asset)), - functionNameParam("burn"), - accountAddressParam(sourceAccount), - i128Param(0, uint64(amount.MustParse(assetAmount))), - }, - }, +func burn(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetAmount string) *txnbuild.InvokeHostFunction { + footPrint := footprintForRecipientAddress(itest, asset, *accountAddressParam(sourceAccount).Address) + invokeHostFn := &txnbuild.InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + contractIDParam(stellarAssetContractID(itest, asset)), + functionNameParam("burn"), + accountAddressParam(sourceAccount), + i128Param(0, uint64(amount.MustParse(assetAmount))), }, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: sourceAccount, - }) + Ext: xdr.TransactionExt{ + V: 1, + SorobanData: getMaxSorobanTransactionData(footPrint), + }, + } - invokeHostFn.Functions[0].Auth = addAuthNextInvokerFlow( + invokeHostFn.Auth = addAuthNextInvokerFlow( "burn", stellarAssetContractID(itest, asset), xdr.ScVec{ @@ -1127,36 +1334,9 @@ func burn(itest *integration.Test, sourceAccount string, asset xdr.Asset, assetA return invokeHostFn } -func addFootprint(itest *integration.Test, invokeHostFn *txnbuild.InvokeHostFunctions) *txnbuild.InvokeHostFunctions { - invokeHostFn.Ext = xdr.TransactionExt{ - V: 1, - SorobanData: &xdr.SorobanTransactionData{ - Resources: xdr.SorobanResources{ - Instructions: 0, - ReadBytes: 0, - WriteBytes: 0, - ExtendedMetaDataSizeBytes: 0, - Footprint: xdr.LedgerFootprint{ - ReadOnly: []xdr.LedgerKey{ - // TODO: derive the needed value - }, - ReadWrite: []xdr.LedgerKey{ - // TODO: derive the needed value - }, - }, - }, - RefundableFee: 1, - Ext: xdr.ExtensionPoint{ - V: 0, - }, - }, - } - return invokeHostFn -} - -func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, op *txnbuild.InvokeHostFunctions) (*xdr.ScVal, string) { +func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, op *txnbuild.InvokeHostFunction) (*xdr.ScVal, string) { acc := itest.MustGetAccount(signer) - tx, err := itest.SubmitOperations(&acc, signer, op) + tx, err := itest.SubmitOperationsWithFee(&acc, signer, 10*stroopsIn1XLM, op) require.NoError(itest.CurrentTest(), err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -1167,6 +1347,10 @@ func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, o err = xdr.SafeUnmarshalBase64(clientTx.ResultXdr, &txResult) require.NoError(itest.CurrentTest(), err) + var txMetaResult xdr.TransactionMeta + err = xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &txMetaResult) + require.NoError(itest.CurrentTest(), err) + opResults, ok := txResult.OperationResults() assert.True(itest.CurrentTest(), ok) assert.Equal(itest.CurrentTest(), len(opResults), 1) @@ -1174,9 +1358,9 @@ func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, o assert.True(itest.CurrentTest(), ok) assert.Equal(itest.CurrentTest(), invokeHostFunctionResult.Code, xdr.InvokeHostFunctionResultCodeInvokeHostFunctionSuccess) - require.Equal(itest.CurrentTest(), 1, len(*invokeHostFunctionResult.Success)) - firstSuccessScVal := (*invokeHostFunctionResult.Success)[0] - return &firstSuccessScVal, tx.Hash + returnValue := txMetaResult.MustV3().ReturnValue + + return &returnValue, tx.Hash } func stellarAssetContractID(itest *integration.Test, asset xdr.Asset) xdr.Hash { @@ -1185,24 +1369,37 @@ func stellarAssetContractID(itest *integration.Test, asset xdr.Asset) xdr.Hash { return contractID } -func addAuthNextInvokerFlow(fnName string, contractId xdr.Hash, args xdr.ScVec) []xdr.ContractAuth { - return []xdr.ContractAuth{ +func addAuthNextInvokerFlow(fnName string, contractId xdr.Hash, args xdr.ScVec) []xdr.SorobanAuthorizationEntry { + return []xdr.SorobanAuthorizationEntry{ { - RootInvocation: xdr.AuthorizedInvocation{ - ContractId: contractId, - FunctionName: xdr.ScSymbol(fnName), - Args: args, + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{}, + }, + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeContract, + ContractId: &contractId, + }, + FunctionName: xdr.ScSymbol(fnName), + Args: args, + }, + }, SubInvocations: nil, }, - SignatureArgs: nil, }, } } -func mustCreateAndInstallContract(itest *integration.Test, signer *keypair.Full, contractSalt string, wasmFileName string) xdr.Hash { +func mustCreateAndInstallContract(itest *integration.Test, signer *keypair.Full, contractSalt string, wasmFileName string) (xdr.Hash, xdr.Hash) { installContractOp := assembleInstallContractCodeOp(itest.CurrentTest(), itest.Master().Address(), wasmFileName) assertInvokeHostFnSucceeds(itest, signer, installContractOp) createContractOp := assembleCreateContractOp(itest.CurrentTest(), itest.Master().Address(), wasmFileName, contractSalt, itest.GetPassPhrase()) assertInvokeHostFnSucceeds(itest, signer, createContractOp) - return createContractOp.Ext.SorobanData.Resources.Footprint.ReadWrite[0].MustContractData().ContractId + contractHash := createContractOp.Ext.SorobanData.Resources.Footprint.ReadOnly[0].MustContractCode().Hash + contractID := createContractOp.Ext.SorobanData.Resources.Footprint.ReadWrite[0].MustContractData().ContractId + return contractID, contractHash } diff --git a/services/horizon/internal/integration/testdata/soroban_sac_test.wasm b/services/horizon/internal/integration/testdata/soroban_sac_test.wasm index aaf7456a26..2a1f8bc3ac 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/test/integration/integration.go b/services/horizon/internal/test/integration/integration.go index 4f873c0df9..237a1917b0 100644 --- a/services/horizon/internal/test/integration/integration.go +++ b/services/horizon/internal/test/integration/integration.go @@ -16,10 +16,14 @@ import ( "testing" "time" + "github.com/2opremio/pretty" + "github.com/creachadair/jrpc2" + "github.com/creachadair/jrpc2/jhttp" "github.com/spf13/cobra" - "github.com/stellar/go/services/horizon/internal/ingest" "github.com/stretchr/testify/assert" + "github.com/stellar/go/services/horizon/internal/ingest" + sdk "github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/clients/stellarcore" "github.com/stellar/go/keypair" @@ -38,10 +42,12 @@ const ( stellarCorePort = 11626 stellarCorePostgresPort = 5641 historyArchivePort = 1570 + sorobanRPCPort = 8080 ) var ( RunWithCaptiveCore = os.Getenv("HORIZON_INTEGRATION_TESTS_ENABLE_CAPTIVE_CORE") != "" + RunWithSorobanRPC = os.Getenv("HORIZON_INTEGRATION_TESTS_ENABLE_SOROBAN_RPC") != "" RunWithCaptiveCoreUseDB = os.Getenv("HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_USE_DB") != "" ) @@ -49,6 +55,7 @@ type Config struct { ProtocolVersion uint32 SkipContainerCreation bool CoreDockerImage string + SorobanRPCDockerImage string // Weird naming here because bools default to false, but we want to start // Horizon by default. @@ -151,6 +158,10 @@ func NewTest(t *testing.T, config Config) *Test { i.prepareShutdownHandlers() i.coreClient = &stellarcore.Client{URL: "http://localhost:" + strconv.Itoa(stellarCorePort)} i.waitForCore() + if RunWithSorobanRPC { + i.runComposeCommand("up", "--detach", "--quiet-pull", "--no-color", "soroban-rpc") + i.waitForSorobanRPC() + } if !config.SkipHorizonStart { if innerErr := i.StartHorizon(); innerErr != nil { @@ -203,8 +214,13 @@ func (i *Test) getIngestParameter(argName, envName string) string { // Runs a docker-compose command applied to the above configs func (i *Test) runComposeCommand(args ...string) { integrationYaml := filepath.Join(i.composePath, "docker-compose.integration-tests.yml") + integrationSorobanRPCYaml := filepath.Join(i.composePath, "docker-compose.integration-tests.soroban-rpc.yml") - cmdline := append([]string{"-f", integrationYaml}, args...) + cmdline := args + if RunWithSorobanRPC { + cmdline = append([]string{"-f", integrationSorobanRPCYaml}, cmdline...) + } + cmdline = append([]string{"-f", integrationYaml}, cmdline...) cmd := exec.Command("docker-compose", cmdline...) coreImageOverride := "" if i.config.CoreDockerImage != "" { @@ -212,12 +228,26 @@ func (i *Test) runComposeCommand(args ...string) { } else if img := os.Getenv("HORIZON_INTEGRATION_TESTS_DOCKER_IMG"); img != "" { coreImageOverride = img } + + cmd.Env = os.Environ() if coreImageOverride != "" { cmd.Env = append( - os.Environ(), + cmd.Environ(), fmt.Sprintf("CORE_IMAGE=%s", coreImageOverride), ) } + sorobanRPCOverride := "" + if i.config.SorobanRPCDockerImage != "" { + sorobanRPCOverride = i.config.CoreDockerImage + } else if img := os.Getenv("HORIZON_INTEGRATION_TESTS_SOROBAN_RPC_DOCKER_IMG"); img != "" { + sorobanRPCOverride = img + } + if sorobanRPCOverride != "" { + cmd.Env = append( + cmd.Environ(), + fmt.Sprintf("SOROBAN_RPC_IMAGE=%s", sorobanRPCOverride), + ) + } i.t.Log("Running", cmd.Env, cmd.Args) out, innerErr := cmd.Output() if exitErr, ok := innerErr.(*exec.ExitError); ok { @@ -241,6 +271,9 @@ func (i *Test) prepareShutdownHandlers() { } i.runComposeCommand("rm", "-fvs", "core") i.runComposeCommand("rm", "-fvs", "core-postgres") + if os.Getenv("HORIZON_INTEGRATION_TESTS_ENABLE_SOROBAN_RPC") != "" { + i.runComposeCommand("rm", "-fvs", "soroban-rpc") + } }, i.environment.Restore, ) @@ -475,6 +508,72 @@ func (i *Test) waitForCore() { i.t.Fatal("Core could not sync after 30s") } +// Wait for SorobanRPC to be up +func (i *Test) waitForSorobanRPC() { + i.t.Log("Waiting for Soroban RPC to be up...") + + for t := 30 * time.Second; t >= 0; t -= time.Second { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + // TODO: soroban-tools should be exporting a proper Go client + ch := jhttp.NewChannel("http://localhost:"+strconv.Itoa(sorobanRPCPort), nil) + sorobanRPCClient := jrpc2.NewClient(ch, nil) + _, err := sorobanRPCClient.Call(ctx, "getHealth", nil) + cancel() + if err != nil { + i.t.Logf("SorobanRPC is unhealthy: %v", err) + time.Sleep(time.Second) + continue + } + i.t.Log("SorobanRPC is up.") + return + } + + i.t.Fatal("SorobanRPC unhealthy after 30s") +} + +// Wait for SorobanRPC to be up +func (i *Test) PreflightHostFunctions(sourceAccount txnbuild.Account, function txnbuild.InvokeHostFunction) (txnbuild.InvokeHostFunction, int64) { + // TODO: soroban-tools should be exporting a proper Go client + ch := jhttp.NewChannel("http://localhost:"+strconv.Itoa(sorobanRPCPort), nil) + sorobanRPCClient := jrpc2.NewClient(ch, nil) + txParams := GetBaseTransactionParamsWithFee(sourceAccount, txnbuild.MinBaseFee, &function) + txParams.IncrementSequenceNum = false + tx, err := txnbuild.NewTransaction(txParams) + assert.NoError(i.t, err) + base64, err := tx.Base64() + assert.NoError(i.t, err) + var result struct { + Error string `json:"error,omitempty"` + TransactionData string `json:"transactionData"` + Auth []string `json:"auth"` + MinResourceFee int64 `json:"minResourceFee,string"` + } + err = sorobanRPCClient.CallResult(context.Background(), "simulateTransaction", struct { + Transaction string `json:"transaction"` + }{base64}, &result) + assert.NoError(i.t, err) + assert.Empty(i.t, result.Error) + var transactionData xdr.SorobanTransactionData + err = xdr.SafeUnmarshalBase64(result.TransactionData, &transactionData) + assert.NoError(i.t, err) + fmt.Printf("FootPrint:\n\n%# +v\n\n", pretty.Formatter(transactionData.Resources.Footprint)) + function.Ext = xdr.TransactionExt{ + V: 1, + SorobanData: &transactionData, + } + var funAuth []xdr.SorobanAuthorizationEntry + for _, authBase64 := range result.Auth { + var authEntry xdr.SorobanAuthorizationEntry + err = xdr.SafeUnmarshalBase64(authBase64, &authEntry) + assert.NoError(i.t, err) + fmt.Printf("Auth:\n\n%# +v\n\n", pretty.Formatter(authEntry)) + funAuth = append(funAuth, authEntry) + } + function.Auth = funAuth + + return function, result.MinResourceFee +} + // UpgradeProtocol arms Core with upgrade and blocks until protocol is upgraded. func (i *Test) UpgradeProtocol(version uint32) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) @@ -746,7 +845,13 @@ func (i *Test) MustGetAccount(source *keypair.Full) proto.Account { func (i *Test) MustSubmitOperations( source txnbuild.Account, signer *keypair.Full, ops ...txnbuild.Operation, ) proto.Transaction { - tx, err := i.SubmitOperations(source, signer, ops...) + return i.MustSubmitOperationsWithFee(source, signer, txnbuild.MinBaseFee, ops...) +} + +func (i *Test) MustSubmitOperationsWithFee( + source txnbuild.Account, signer *keypair.Full, fee int64, ops ...txnbuild.Operation, +) proto.Transaction { + tx, err := i.SubmitOperationsWithFee(source, signer, fee, ops...) panicIf(err) return tx } @@ -760,7 +865,19 @@ func (i *Test) SubmitOperations( func (i *Test) SubmitMultiSigOperations( source txnbuild.Account, signers []*keypair.Full, ops ...txnbuild.Operation, ) (proto.Transaction, error) { - tx, err := i.CreateSignedTransactionFromOps(source, signers, ops...) + return i.SubmitMultiSigOperationsWithFee(source, signers, txnbuild.MinBaseFee, ops...) +} + +func (i *Test) SubmitOperationsWithFee( + source txnbuild.Account, signer *keypair.Full, fee int64, ops ...txnbuild.Operation, +) (proto.Transaction, error) { + return i.SubmitMultiSigOperationsWithFee(source, []*keypair.Full{signer}, fee, ops...) +} + +func (i *Test) SubmitMultiSigOperationsWithFee( + source txnbuild.Account, signers []*keypair.Full, fee int64, ops ...txnbuild.Operation, +) (proto.Transaction, error) { + tx, err := i.CreateSignedTransactionFromOpsWithFee(source, signers, fee, ops...) if err != nil { return proto.Transaction{}, err } @@ -826,15 +943,31 @@ func (i *Test) CreateSignedTransaction(signers []*keypair.Full, txParams txnbuil func (i *Test) CreateSignedTransactionFromOps( source txnbuild.Account, signers []*keypair.Full, ops ...txnbuild.Operation, ) (*txnbuild.Transaction, error) { - txParams := txnbuild.TransactionParams{ + return i.CreateSignedTransactionFromOpsWithFee(source, signers, txnbuild.MinBaseFee, ops...) +} + +func (i *Test) CreateSignedTransactionFromOpsWithFee( + source txnbuild.Account, signers []*keypair.Full, fee int64, ops ...txnbuild.Operation, +) (*txnbuild.Transaction, error) { + txParams := GetBaseTransactionParamsWithFee(source, fee, ops...) + return i.CreateSignedTransaction(signers, txParams) +} + +func GetBaseTransactionParamsWithFee(source txnbuild.Account, fee int64, ops ...txnbuild.Operation) txnbuild.TransactionParams { + return txnbuild.TransactionParams{ SourceAccount: source, Operations: ops, - BaseFee: txnbuild.MinBaseFee, + BaseFee: fee, Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewInfiniteTimeout()}, IncrementSequenceNum: true, } +} - return i.CreateSignedTransaction(signers, txParams) +func (i *Test) CreateUnsignedTransaction( + source txnbuild.Account, ops ...txnbuild.Operation, +) (*txnbuild.Transaction, error) { + txParams := GetBaseTransactionParamsWithFee(source, txnbuild.MinBaseFee, ops...) + return txnbuild.NewTransaction(txParams) } func (i *Test) GetCurrentCoreLedgerSequence() (int, error) { diff --git a/support/db/session_test.go b/support/db/session_test.go index 4e1d90f9b6..8629b2ca7e 100644 --- a/support/db/session_test.go +++ b/support/db/session_test.go @@ -154,7 +154,7 @@ func TestIdleTransactionTimeout(t *testing.T) { defer sess.Close() assert.NoError(sess.Begin(context.Background())) - <-time.After(100 * time.Millisecond) + <-time.After(150 * time.Millisecond) var count int err = sess.GetRaw(context.Background(), &count, "SELECT COUNT(*) FROM people") diff --git a/txnbuild/invoke_host_function.go b/txnbuild/invoke_host_function.go index 8e639a1def..c278b5f81c 100644 --- a/txnbuild/invoke_host_function.go +++ b/txnbuild/invoke_host_function.go @@ -5,17 +5,19 @@ import ( "github.com/stellar/go/xdr" ) -type InvokeHostFunctions struct { - Functions []xdr.HostFunction +type InvokeHostFunction struct { + HostFunction xdr.HostFunction + Auth []xdr.SorobanAuthorizationEntry SourceAccount string Ext xdr.TransactionExt } -func (f *InvokeHostFunctions) BuildXDR() (xdr.Operation, error) { +func (f *InvokeHostFunction) BuildXDR() (xdr.Operation, error) { opType := xdr.OperationTypeInvokeHostFunction xdrOp := xdr.InvokeHostFunctionOp{ - Functions: f.Functions, + HostFunction: f.HostFunction, + Auth: f.Auth, } body, err := xdr.NewOperationBody(opType, xdrOp) @@ -29,19 +31,20 @@ func (f *InvokeHostFunctions) BuildXDR() (xdr.Operation, error) { return op, nil } -func (f *InvokeHostFunctions) FromXDR(xdrOp xdr.Operation) error { +func (f *InvokeHostFunction) FromXDR(xdrOp xdr.Operation) error { result, ok := xdrOp.Body.GetInvokeHostFunctionOp() if !ok { return errors.New("error parsing invoke host function operation from xdr") } f.SourceAccount = accountFromXDR(xdrOp.SourceAccount) - f.Functions = result.Functions + f.HostFunction = result.HostFunction + f.Auth = result.Auth return nil } -func (f *InvokeHostFunctions) Validate() error { +func (f *InvokeHostFunction) Validate() error { if f.SourceAccount != "" { _, err := xdr.AddressToMuxedAccount(f.SourceAccount) if err != nil { @@ -51,10 +54,10 @@ func (f *InvokeHostFunctions) Validate() error { return nil } -func (f *InvokeHostFunctions) GetSourceAccount() string { +func (f *InvokeHostFunction) GetSourceAccount() string { return f.SourceAccount } -func (f *InvokeHostFunctions) BuildTransactionExt() (xdr.TransactionExt, error) { +func (f *InvokeHostFunction) BuildTransactionExt() (xdr.TransactionExt, error) { return f.Ext, nil } diff --git a/txnbuild/invoke_host_function_test.go b/txnbuild/invoke_host_function_test.go index 123dacf8bb..876cc29897 100644 --- a/txnbuild/invoke_host_function_test.go +++ b/txnbuild/invoke_host_function_test.go @@ -12,16 +12,12 @@ func TestCreateInvokeHostFunctionValid(t *testing.T) { kp1 := newKeypair1() sourceAccount := NewSimpleAccount(kp1.Address(), int64(41137196761100)) - invokeHostFunctionOp := InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{}, - }, - Auth: []xdr.ContractAuth{}, - }, + invokeHostFunctionOp := InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{}, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: sourceAccount.AccountID, } @@ -29,16 +25,12 @@ func TestCreateInvokeHostFunctionValid(t *testing.T) { } func TestCreateInvokeHostFunctionInvalid(t *testing.T) { - invokeHostFunctionOp := InvokeHostFunctions{ - Functions: []xdr.HostFunction{ - { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{}, - }, - Auth: []xdr.ContractAuth{}, - }, + invokeHostFunctionOp := InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{}, }, + Auth: []xdr.SorobanAuthorizationEntry{}, SourceAccount: "invalid account value", } @@ -50,38 +42,46 @@ func TestInvokeHostFunctionRoundTrip(t *testing.T) { wasmId := xdr.Hash{1, 2, 3, 4} i64 := xdr.Int64(45) accountId := xdr.MustAddress("GB7BDSZU2Y27LYNLALKKALB52WS2IZWYBDGY6EQBLEED3TJOCVMZRH7H") - invokeHostFunctionOp := &InvokeHostFunctions{ - Functions: []xdr.HostFunction{ + invokeHostFunctionOp := &InvokeHostFunction{ + HostFunction: xdr.HostFunction{ + Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, + InvokeContract: &xdr.ScVec{ + xdr.ScVal{ + Type: xdr.ScValTypeScvI32, + I32: &val, + }, + }, + }, + Auth: []xdr.SorobanAuthorizationEntry{ { - Args: xdr.HostFunctionArgs{ - Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, - InvokeContract: &xdr.ScVec{ - xdr.ScVal{ - Type: xdr.ScValTypeScvI32, - I32: &val, + Credentials: xdr.SorobanCredentials{ + Type: xdr.SorobanCredentialsTypeSorobanCredentialsAddress, + Address: &xdr.SorobanAddressCredentials{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, }, + Nonce: 0, + SignatureArgs: nil, }, }, - Auth: []xdr.ContractAuth{ - { - AddressWithNonce: &xdr.AddressWithNonce{ - Address: xdr.ScAddress{ + RootInvocation: xdr.SorobanAuthorizedInvocation{ + Function: xdr.SorobanAuthorizedFunction{ + Type: xdr.SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn, + ContractFn: &xdr.SorobanAuthorizedContractFunction{ + ContractAddress: xdr.ScAddress{ Type: xdr.ScAddressTypeScAddressTypeAccount, AccountId: &accountId, }, - Nonce: 0, - }, - RootInvocation: xdr.AuthorizedInvocation{ - ContractId: xdr.Hash{0xaa, 0xbb}, - FunctionName: "foo", - Args: nil, - SubInvocations: nil, + FunctionName: "foo", + Args: nil, }, - SignatureArgs: nil, }, + SubInvocations: nil, }, }, }, + SourceAccount: "GB7BDSZU2Y27LYNLALKKALB52WS2IZWYBDGY6EQBLEED3TJOCVMZRH7H", Ext: xdr.TransactionExt{ V: 1, SorobanData: &xdr.SorobanTransactionData{ @@ -126,7 +126,6 @@ func TestInvokeHostFunctionRoundTrip(t *testing.T) { }, }, }, - SourceAccount: "GB7BDSZU2Y27LYNLALKKALB52WS2IZWYBDGY6EQBLEED3TJOCVMZRH7H", } testOperationsMarshallingRoundtrip(t, []Operation{invokeHostFunctionOp}, false) diff --git a/txnbuild/operation.go b/txnbuild/operation.go index b0e579d96f..55536cb8dd 100644 --- a/txnbuild/operation.go +++ b/txnbuild/operation.go @@ -77,7 +77,7 @@ func operationFromXDR(xdrOp xdr.Operation) (Operation, error) { case xdr.OperationTypeLiquidityPoolWithdraw: newOp = &LiquidityPoolWithdraw{} case xdr.OperationTypeInvokeHostFunction: - newOp = &InvokeHostFunctions{} + newOp = &InvokeHostFunction{} default: return nil, fmt.Errorf("unknown operation type: %d", xdrOp.Body.Type) } diff --git a/txnbuild/transaction.go b/txnbuild/transaction.go index afdc3f385a..0cf284fe02 100644 --- a/txnbuild/transaction.go +++ b/txnbuild/transaction.go @@ -785,9 +785,9 @@ func transactionFromParsedXDR(xdrEnv xdr.TransactionEnvelope) (*GenericTransacti if err != nil { return nil, err } - // if it's a soroban transaction, and we found a InvokeHostFunctions operation. + // if it's a soroban transaction, and we found a InvokeHostFunction operation. if xdrEnv.V1 != nil && xdrEnv.V1.Tx.Ext.V != 0 { - if invoke, ok := newOp.(*InvokeHostFunctions); ok { + if invoke, ok := newOp.(*InvokeHostFunction); ok { invoke.Ext = xdrEnv.V1.Tx.Ext } } diff --git a/xdr/Stellar-contract-spec.x b/xdr/Stellar-contract-spec.x index 8431e226f8..a3145896c9 100644 --- a/xdr/Stellar-contract-spec.x +++ b/xdr/Stellar-contract-spec.x @@ -19,7 +19,7 @@ enum SCSpecType // Types with no parameters. SC_SPEC_TYPE_BOOL = 1, SC_SPEC_TYPE_VOID = 2, - SC_SPEC_TYPE_STATUS = 3, + SC_SPEC_TYPE_ERROR = 3, SC_SPEC_TYPE_U32 = 4, SC_SPEC_TYPE_I32 = 5, SC_SPEC_TYPE_U64 = 6, @@ -95,7 +95,7 @@ union SCSpecTypeDef switch (SCSpecType type) case SC_SPEC_TYPE_VAL: case SC_SPEC_TYPE_BOOL: case SC_SPEC_TYPE_VOID: -case SC_SPEC_TYPE_STATUS: +case SC_SPEC_TYPE_ERROR: case SC_SPEC_TYPE_U32: case SC_SPEC_TYPE_I32: case SC_SPEC_TYPE_U64: diff --git a/xdr/Stellar-contract.x b/xdr/Stellar-contract.x index 6084cdbe2f..54a03643ce 100644 --- a/xdr/Stellar-contract.x +++ b/xdr/Stellar-contract.x @@ -22,7 +22,7 @@ enum SCValType { SCV_BOOL = 0, SCV_VOID = 1, - SCV_STATUS = 2, + SCV_ERROR = 2, // 32 bits is the smallest type in WASM or XDR; no need for u8/u16. SCV_U32 = 3, @@ -49,9 +49,6 @@ enum SCValType SCV_U256 = 11, SCV_I256 = 12, - // TODO: possibly allocate subtypes of i64, i128 and/or u256 for - // fixed-precision with a specific number of decimals. - // Bytes come in 3 flavors, 2 of which have meaningfully different // formatting and validity-checking / domain-restriction. SCV_BYTES = 13, @@ -74,131 +71,38 @@ enum SCValType SCV_LEDGER_KEY_NONCE = 21 }; -enum SCStatusType -{ - SST_OK = 0, - SST_UNKNOWN_ERROR = 1, - SST_HOST_VALUE_ERROR = 2, - SST_HOST_OBJECT_ERROR = 3, - SST_HOST_FUNCTION_ERROR = 4, - SST_HOST_STORAGE_ERROR = 5, - SST_HOST_CONTEXT_ERROR = 6, - SST_VM_ERROR = 7, - SST_CONTRACT_ERROR = 8, - SST_HOST_AUTH_ERROR = 9 - // TODO: add more -}; - -enum SCHostValErrorCode -{ - HOST_VALUE_UNKNOWN_ERROR = 0, - HOST_VALUE_RESERVED_TAG_VALUE = 1, - HOST_VALUE_UNEXPECTED_VAL_TYPE = 2, - HOST_VALUE_U63_OUT_OF_RANGE = 3, - HOST_VALUE_U32_OUT_OF_RANGE = 4, - HOST_VALUE_STATIC_UNKNOWN = 5, - HOST_VALUE_MISSING_OBJECT = 6, - HOST_VALUE_SYMBOL_TOO_LONG = 7, - HOST_VALUE_SYMBOL_BAD_CHAR = 8, - HOST_VALUE_SYMBOL_CONTAINS_NON_UTF8 = 9, - HOST_VALUE_BITSET_TOO_MANY_BITS = 10, - HOST_VALUE_STATUS_UNKNOWN = 11 -}; - -enum SCHostObjErrorCode -{ - HOST_OBJECT_UNKNOWN_ERROR = 0, - HOST_OBJECT_UNKNOWN_REFERENCE = 1, - HOST_OBJECT_UNEXPECTED_TYPE = 2, - HOST_OBJECT_OBJECT_COUNT_EXCEEDS_U32_MAX = 3, - HOST_OBJECT_OBJECT_NOT_EXIST = 4, - HOST_OBJECT_VEC_INDEX_OUT_OF_BOUND = 5, - HOST_OBJECT_CONTRACT_HASH_WRONG_LENGTH = 6 -}; - -enum SCHostFnErrorCode -{ - HOST_FN_UNKNOWN_ERROR = 0, - HOST_FN_UNEXPECTED_HOST_FUNCTION_ACTION = 1, - HOST_FN_INPUT_ARGS_WRONG_LENGTH = 2, - HOST_FN_INPUT_ARGS_WRONG_TYPE = 3, - HOST_FN_INPUT_ARGS_INVALID = 4 -}; - -enum SCHostStorageErrorCode +enum SCErrorType { - HOST_STORAGE_UNKNOWN_ERROR = 0, - HOST_STORAGE_EXPECT_CONTRACT_DATA = 1, - HOST_STORAGE_READWRITE_ACCESS_TO_READONLY_ENTRY = 2, - HOST_STORAGE_ACCESS_TO_UNKNOWN_ENTRY = 3, - HOST_STORAGE_MISSING_KEY_IN_GET = 4, - HOST_STORAGE_GET_ON_DELETED_KEY = 5 + SCE_CONTRACT = 0, + SCE_WASM_VM = 1, + SCE_CONTEXT = 2, + SCE_STORAGE = 3, + SCE_OBJECT = 4, + SCE_CRYPTO = 5, + SCE_EVENTS = 6, + SCE_BUDGET = 7, + SCE_VALUE = 8, + SCE_AUTH = 9 }; -enum SCHostAuthErrorCode +enum SCErrorCode { - HOST_AUTH_UNKNOWN_ERROR = 0, - HOST_AUTH_NONCE_ERROR = 1, - HOST_AUTH_DUPLICATE_AUTHORIZATION = 2, - HOST_AUTH_NOT_AUTHORIZED = 3 + SCEC_ARITH_DOMAIN = 0, // some arithmetic wasn't defined (overflow, divide-by-zero) + SCEC_INDEX_BOUNDS = 1, // something was indexed beyond its bounds + SCEC_INVALID_INPUT = 2, // user provided some otherwise-bad data + SCEC_MISSING_VALUE = 3, // some value was required but not provided + SCEC_EXISTING_VALUE = 4, // some value was provided where not allowed + SCEC_EXCEEDED_LIMIT = 5, // some arbitrary limit -- gas or otherwise -- was hit + SCEC_INVALID_ACTION = 6, // data was valid but action requested was not + SCEC_INTERNAL_ERROR = 7, // the internal state of the host was otherwise-bad + SCEC_UNEXPECTED_TYPE = 8, // some type wasn't as expected + SCEC_UNEXPECTED_SIZE = 9 // something's size wasn't as expected }; -enum SCHostContextErrorCode +struct SCError { - HOST_CONTEXT_UNKNOWN_ERROR = 0, - HOST_CONTEXT_NO_CONTRACT_RUNNING = 1 -}; - -enum SCVmErrorCode { - VM_UNKNOWN = 0, - VM_VALIDATION = 1, - VM_INSTANTIATION = 2, - VM_FUNCTION = 3, - VM_TABLE = 4, - VM_MEMORY = 5, - VM_GLOBAL = 6, - VM_VALUE = 7, - VM_TRAP_UNREACHABLE = 8, - VM_TRAP_MEMORY_ACCESS_OUT_OF_BOUNDS = 9, - VM_TRAP_TABLE_ACCESS_OUT_OF_BOUNDS = 10, - VM_TRAP_ELEM_UNINITIALIZED = 11, - VM_TRAP_DIVISION_BY_ZERO = 12, - VM_TRAP_INTEGER_OVERFLOW = 13, - VM_TRAP_INVALID_CONVERSION_TO_INT = 14, - VM_TRAP_STACK_OVERFLOW = 15, - VM_TRAP_UNEXPECTED_SIGNATURE = 16, - VM_TRAP_MEM_LIMIT_EXCEEDED = 17, - VM_TRAP_CPU_LIMIT_EXCEEDED = 18 -}; - -enum SCUnknownErrorCode -{ - UNKNOWN_ERROR_GENERAL = 0, - UNKNOWN_ERROR_XDR = 1 -}; - -union SCStatus switch (SCStatusType type) -{ -case SST_OK: - void; -case SST_UNKNOWN_ERROR: - SCUnknownErrorCode unknownCode; -case SST_HOST_VALUE_ERROR: - SCHostValErrorCode valCode; -case SST_HOST_OBJECT_ERROR: - SCHostObjErrorCode objCode; -case SST_HOST_FUNCTION_ERROR: - SCHostFnErrorCode fnCode; -case SST_HOST_STORAGE_ERROR: - SCHostStorageErrorCode storageCode; -case SST_HOST_CONTEXT_ERROR: - SCHostContextErrorCode contextCode; -case SST_VM_ERROR: - SCVmErrorCode vmCode; -case SST_CONTRACT_ERROR: - uint32 contractCode; -case SST_HOST_AUTH_ERROR: - SCHostAuthErrorCode authCode; + SCErrorType type; + SCErrorCode code; }; struct UInt128Parts { @@ -264,14 +168,13 @@ case SC_ADDRESS_TYPE_CONTRACT: %struct SCVal; %struct SCMapEntry; -const SCVAL_LIMIT = 256000; const SCSYMBOL_LIMIT = 32; -typedef SCVal SCVec; -typedef SCMapEntry SCMap; +typedef SCVal SCVec<>; +typedef SCMapEntry SCMap<>; -typedef opaque SCBytes; -typedef string SCString; +typedef opaque SCBytes<>; +typedef string SCString<>; typedef string SCSymbol; struct SCNonceKey { @@ -285,8 +188,8 @@ case SCV_BOOL: bool b; case SCV_VOID: void; -case SCV_STATUS: - SCStatus error; +case SCV_ERROR: + SCError error; case SCV_U32: uint32 u32; diff --git a/xdr/Stellar-ledger-entries.x b/xdr/Stellar-ledger-entries.x index 2eca637305..dea2c69d27 100644 --- a/xdr/Stellar-ledger-entries.x +++ b/xdr/Stellar-ledger-entries.x @@ -503,7 +503,7 @@ struct ContractCodeEntry { ExtensionPoint ext; Hash hash; - opaque code; + opaque code<>; }; @@ -628,11 +628,7 @@ enum EnvelopeType ENVELOPE_TYPE_TX_FEE_BUMP = 5, ENVELOPE_TYPE_OP_ID = 6, ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7, - ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519 = 8, - ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT = 9, - ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET = 10, - ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT = 11, - ENVELOPE_TYPE_CREATE_CONTRACT_ARGS = 12, - ENVELOPE_TYPE_CONTRACT_AUTH = 13 + ENVELOPE_TYPE_CONTRACT_ID = 8, + ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9 }; } diff --git a/xdr/Stellar-ledger.x b/xdr/Stellar-ledger.x index 79d3d45d33..7b0e04a463 100644 --- a/xdr/Stellar-ledger.x +++ b/xdr/Stellar-ledger.x @@ -280,32 +280,6 @@ struct TransactionHistoryResultEntry ext; }; -struct TransactionResultPairV2 -{ - Hash transactionHash; - Hash hashOfMetaHashes; // hash of hashes in TransactionMetaV3 - // TransactionResult is in the meta -}; - -struct TransactionResultSetV2 -{ - TransactionResultPairV2 results<>; -}; - -struct TransactionHistoryResultEntryV2 -{ - uint32 ledgerSeq; - TransactionResultSetV2 txResultSet; - - // reserved for future use - union switch (int v) - { - case 0: - void; - } - ext; -}; - struct LedgerHeaderHistoryEntry { Hash hash; @@ -424,16 +398,6 @@ struct DiagnosticEvent ContractEvent event; }; -struct OperationDiagnosticEvents -{ - DiagnosticEvent events<>; -}; - -struct OperationEvents -{ - ContractEvent events<>; -}; - struct TransactionMetaV3 { LedgerEntryChanges txChangesBefore; // tx level changes before operations @@ -441,17 +405,21 @@ struct TransactionMetaV3 OperationMeta operations<>; // meta for each operation LedgerEntryChanges txChangesAfter; // tx level changes after operations are // applied if any - OperationEvents events<>; // custom events populated by the - // contracts themselves. One list per operation. - TransactionResult txResult; + ContractEvent events<>; // custom events populated by the + // contracts themselves. + SCVal returnValue; // return value of the invocation. - Hash hashes[3]; // stores sha256(txChangesBefore, operations, txChangesAfter), - // sha256(events), and sha256(txResult) - - // Diagnostics events that are not hashed. One list per operation. + // Diagnostics events that are not hashed. // This will contain all contract and diagnostic events. Even ones // that were emitted in a failed contract call. - OperationDiagnosticEvents diagnosticEvents<>; + DiagnosticEvent diagnosticEvents<>; +}; + +// This is in Stellar-ledger.x to due to a circular dependency +struct InvokeHostFunctionSuccessPreImage +{ + SCVal returnValue; + ContractEvent events<>; }; // this is the meta produced when applying transactions @@ -478,13 +446,6 @@ struct TransactionResultMeta TransactionMeta txApplyProcessing; }; -struct TransactionResultMetaV2 -{ - TransactionResultPairV2 result; - LedgerEntryChanges feeProcessing; - TransactionMeta txApplyProcessing; -}; - // this represents a single upgrade that was performed as part of a ledger // upgrade struct UpgradeEntryMeta @@ -529,32 +490,11 @@ struct LedgerCloseMetaV1 SCPHistoryEntry scpInfo<>; }; -// only difference between V1 and V2 is this uses TransactionResultMetaV2 -struct LedgerCloseMetaV2 -{ - LedgerHeaderHistoryEntry ledgerHeader; - - GeneralizedTransactionSet txSet; - - // NB: transactions are sorted in apply order here - // fees for all transactions are processed first - // followed by applying transactions - TransactionResultMetaV2 txProcessing<>; - - // upgrades are applied last - UpgradeEntryMeta upgradesProcessing<>; - - // other misc information attached to the ledger close - SCPHistoryEntry scpInfo<>; -}; - union LedgerCloseMeta switch (int v) { case 0: LedgerCloseMetaV0 v0; case 1: LedgerCloseMetaV1 v1; -case 2: - LedgerCloseMetaV2 v2; }; } diff --git a/xdr/Stellar-overlay.x b/xdr/Stellar-overlay.x index 8203258c8c..4c964736dc 100644 --- a/xdr/Stellar-overlay.x +++ b/xdr/Stellar-overlay.x @@ -27,6 +27,12 @@ struct SendMore uint32 numMessages; }; +struct SendMoreExtended +{ + uint32 numMessages; + uint32 numBytes; +}; + struct AuthCert { Curve25519Public pubkey; @@ -47,16 +53,14 @@ struct Hello uint256 nonce; }; - -// During the roll-out phrase, pull mode will be optional. +// During the roll-out phrase, nodes can disable flow control in bytes. // Therefore, we need a way to communicate with other nodes -// that we want/don't want pull mode. -// However, the goal is for everyone to enable it by default, -// so we don't want to introduce a new member variable. -// For now, we'll use the `flags` field (originally named -// `unused`) in `Auth`. -// 100 is just a number that is not 0. -const AUTH_MSG_FLAG_PULL_MODE_REQUESTED = 100; +// that we want/don't want flow control in bytes. +// We use the `flags` field in the Auth message with a special value +// set to communicate this. Note that AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED != 0 +// AND AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED != 100 (as previously +// that value was used for other purposes). +const AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED = 200; struct Auth { @@ -83,7 +87,7 @@ struct PeerAddress uint32 numFailures; }; -// Next ID: 18 +// Next ID: 21 enum MessageType { ERROR_MSG = 0, @@ -112,6 +116,8 @@ enum MessageType SURVEY_RESPONSE = 15, SEND_MORE = 16, + SEND_MORE_EXTENDED = 20, + FLOOD_ADVERT = 18, FLOOD_DEMAND = 19 }; @@ -274,7 +280,8 @@ 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; diff --git a/xdr/Stellar-transaction.x b/xdr/Stellar-transaction.x index ec1538a96b..0a571b502e 100644 --- a/xdr/Stellar-transaction.x +++ b/xdr/Stellar-transaction.x @@ -477,92 +477,105 @@ enum HostFunctionType HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2 }; -enum ContractIDType +enum ContractIDPreimageType { - CONTRACT_ID_FROM_SOURCE_ACCOUNT = 0, - CONTRACT_ID_FROM_ED25519_PUBLIC_KEY = 1, - CONTRACT_ID_FROM_ASSET = 2 + CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0, + CONTRACT_ID_PREIMAGE_FROM_ASSET = 1 }; -enum ContractIDPublicKeyType +union ContractIDPreimage switch (ContractIDPreimageType type) { - CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT = 0, - CONTRACT_ID_PUBLIC_KEY_ED25519 = 1 -}; - -struct UploadContractWasmArgs -{ - opaque code; -}; - -union ContractID switch (ContractIDType type) -{ -case CONTRACT_ID_FROM_SOURCE_ACCOUNT: - uint256 salt; -case CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: - struct +case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: + struct { - uint256 key; - Signature signature; + SCAddress address; uint256 salt; - } fromEd25519PublicKey; -case CONTRACT_ID_FROM_ASSET: - Asset asset; + } fromAddress; +case CONTRACT_ID_PREIMAGE_FROM_ASSET: + Asset fromAsset; }; struct CreateContractArgs { - ContractID contractID; + ContractIDPreimage contractIDPreimage; SCContractExecutable executable; }; -union HostFunctionArgs switch (HostFunctionType type) +union HostFunction switch (HostFunctionType type) { case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: SCVec invokeContract; case HOST_FUNCTION_TYPE_CREATE_CONTRACT: CreateContractArgs createContract; case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: - UploadContractWasmArgs uploadContractWasm; + opaque wasm<>; +}; + +enum SorobanAuthorizedFunctionType +{ + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, + SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 }; -struct AuthorizedInvocation +struct SorobanAuthorizedContractFunction { - Hash contractID; + SCAddress contractAddress; SCSymbol functionName; SCVec args; - AuthorizedInvocation subInvocations<>; }; -struct AddressWithNonce +union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type) +{ +case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: + SorobanAuthorizedContractFunction contractFn; +case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: + CreateContractArgs createContractHostFn; +}; + +struct SorobanAuthorizedInvocation +{ + SorobanAuthorizedFunction function; + SorobanAuthorizedInvocation subInvocations<>; +}; + +struct SorobanAddressCredentials { SCAddress address; uint64 nonce; + SCVec signatureArgs; }; -struct ContractAuth +enum SorobanCredentialsType { - AddressWithNonce* addressWithNonce; // not present for invoker - AuthorizedInvocation rootInvocation; - SCVec signatureArgs; + SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0, + SOROBAN_CREDENTIALS_ADDRESS = 1 +}; + +union SorobanCredentials switch (SorobanCredentialsType type) +{ +case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT: + void; +case SOROBAN_CREDENTIALS_ADDRESS: + SorobanAddressCredentials address; }; -struct HostFunction { - // Arguments of the function to call defined by the function - // type. - HostFunctionArgs args; - // Per-address authorizations for this host fn - // Currently only supported for INVOKE_CONTRACT function - ContractAuth auth<>; +/* Unit of authorization data for Soroban. + + Represents an authorization for executing the tree of authorized contract + and/or host function calls by the user defined by `credentials`. +*/ +struct SorobanAuthorizationEntry +{ + SorobanCredentials credentials; + SorobanAuthorizedInvocation rootInvocation; }; struct InvokeHostFunctionOp { - // The host functions to invoke. The functions will be executed - // in the same fashion as operations: either all functions will - // be successfully applied or all fail if at least one of them - // fails. - HostFunction functions; + // Host function to invoke. + HostFunction hostFunction; + // Per-address authorizations for this host function. + SorobanAuthorizationEntry auth<>; }; /* An operation is the lowest unit of work that a transaction does */ @@ -642,52 +655,24 @@ case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: struct { AccountID sourceAccount; - SequenceNumber seqNum; + SequenceNumber seqNum; uint32 opNum; PoolID liquidityPoolID; Asset asset; } revokeID; -case ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519: - struct - { - Hash networkID; - uint256 ed25519; - uint256 salt; - } ed25519ContractID; -case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: +case ENVELOPE_TYPE_CONTRACT_ID: struct { Hash networkID; - Hash contractID; - uint256 salt; + ContractIDPreimage contractIDPreimage; } contractID; -case ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: - struct - { - Hash networkID; - Asset asset; - } fromAsset; -case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: - struct - { - Hash networkID; - AccountID sourceAccount; - uint256 salt; - } sourceAccountContractID; -case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: - struct - { - Hash networkID; - SCContractExecutable executable; - uint256 salt; - } createContractArgs; -case ENVELOPE_TYPE_CONTRACT_AUTH: +case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: struct { Hash networkID; uint64 nonce; - AuthorizedInvocation invocation; - } contractAuth; + SorobanAuthorizedInvocation invocation; + } sorobanAuthorization; }; enum MemoType @@ -1779,7 +1764,7 @@ enum InvokeHostFunctionResultCode union InvokeHostFunctionResult switch (InvokeHostFunctionResultCode code) { case INVOKE_HOST_FUNCTION_SUCCESS: - SCVal success; + Hash success; // sha256(InvokeHostFunctionSuccessPreImage) case INVOKE_HOST_FUNCTION_MALFORMED: case INVOKE_HOST_FUNCTION_TRAPPED: case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: diff --git a/xdr/asset.go b/xdr/asset.go index 06242adf31..eaf2b4f754 100644 --- a/xdr/asset.go +++ b/xdr/asset.go @@ -440,10 +440,13 @@ func (a *Asset) LessThan(b Asset) bool { func (a Asset) ContractID(passphrase string) ([32]byte, error) { networkId := Hash(sha256.Sum256([]byte(passphrase))) preImage := HashIdPreimage{ - Type: EnvelopeTypeEnvelopeTypeContractIdFromAsset, - FromAsset: &HashIdPreimageFromAsset{ + Type: EnvelopeTypeEnvelopeTypeContractId, + ContractId: &HashIdPreimageContractId{ NetworkId: networkId, - Asset: a, + ContractIdPreimage: ContractIdPreimage{ + Type: ContractIdPreimageTypeContractIdPreimageFromAsset, + FromAsset: &a, + }, }, } xdrPreImageBytes, err := preImage.MarshalBinary() diff --git a/xdr/ledger_close_meta.go b/xdr/ledger_close_meta.go index 110b3318ae..ee59848060 100644 --- a/xdr/ledger_close_meta.go +++ b/xdr/ledger_close_meta.go @@ -8,8 +8,6 @@ func (l LedgerCloseMeta) LedgerHeaderHistoryEntry() LedgerHeaderHistoryEntry { return l.MustV0().LedgerHeader case 1: return l.MustV1().LedgerHeader - case 2: - return l.MustV2().LedgerHeader default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -41,8 +39,6 @@ func (l LedgerCloseMeta) CountTransactions() int { return len(l.MustV0().TxProcessing) case 1: return len(l.MustV1().TxProcessing) - case 2: - return len(l.MustV2().TxProcessing) default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -52,14 +48,10 @@ func (l LedgerCloseMeta) TransactionEnvelopes() []TransactionEnvelope { switch l.V { case 0: return l.MustV0().TxSet.Txs - case 1, 2: + case 1: var envelopes = make([]TransactionEnvelope, 0, l.CountTransactions()) var phases []TransactionPhase - if l.V == 1 { - phases = l.MustV1().TxSet.V1TxSet.Phases - } else { - phases = l.MustV2().TxSet.V1TxSet.Phases - } + phases = l.MustV1().TxSet.V1TxSet.Phases for _, phase := range phases { for _, component := range *phase.V0Components { envelopes = append(envelopes, component.TxsMaybeDiscountedFee.Txs...) @@ -78,8 +70,6 @@ func (l LedgerCloseMeta) TransactionHash(i int) Hash { return l.MustV0().TxProcessing[i].Result.TransactionHash case 1: return l.MustV1().TxProcessing[i].Result.TransactionHash - case 2: - return l.MustV2().TxProcessing[i].Result.TransactionHash default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -92,14 +82,6 @@ func (l LedgerCloseMeta) TransactionResultPair(i int) TransactionResultPair { return l.MustV0().TxProcessing[i].Result case 1: return l.MustV1().TxProcessing[i].Result - case 2: - if l.MustV2().TxProcessing[i].TxApplyProcessing.V != 3 { - panic("TransactionResult unavailable because LedgerCloseMeta.V = 2 and TransactionMeta.V != 3") - } - return TransactionResultPair{ - TransactionHash: l.TransactionHash(i), - Result: l.MustV2().TxProcessing[i].TxApplyProcessing.MustV3().TxResult, - } default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -112,8 +94,6 @@ func (l LedgerCloseMeta) FeeProcessing(i int) LedgerEntryChanges { return l.MustV0().TxProcessing[i].FeeProcessing case 1: return l.MustV1().TxProcessing[i].FeeProcessing - case 2: - return l.MustV2().TxProcessing[i].FeeProcessing default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -126,8 +106,6 @@ func (l LedgerCloseMeta) TxApplyProcessing(i int) TransactionMeta { return l.MustV0().TxProcessing[i].TxApplyProcessing case 1: return l.MustV1().TxProcessing[i].TxApplyProcessing - case 2: - return l.MustV2().TxProcessing[i].TxApplyProcessing default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } @@ -140,8 +118,6 @@ func (l LedgerCloseMeta) UpgradesProcessing() []UpgradeEntryMeta { return l.MustV0().UpgradesProcessing case 1: return l.MustV1().UpgradesProcessing - case 2: - return l.MustV2().UpgradesProcessing default: panic(fmt.Sprintf("Unsupported LedgerCloseMeta.V: %d", l.V)) } diff --git a/xdr/scval.go b/xdr/scval.go index 97e2380853..a883bb67c8 100644 --- a/xdr/scval.go +++ b/xdr/scval.go @@ -43,34 +43,34 @@ func (s ScContractExecutable) Equals(o ScContractExecutable) bool { } } -func (s ScStatus) Equals(o ScStatus) bool { +func (s ScError) Equals(o ScError) bool { if s.Type != o.Type { return false } switch s.Type { - case ScStatusTypeSstContractError: - return s.MustContractCode() == o.MustContractCode() - case ScStatusTypeSstHostFunctionError: - return s.MustFnCode() == o.MustFnCode() - case ScStatusTypeSstHostObjectError: - return s.MustObjCode() == o.MustObjCode() - case ScStatusTypeSstHostContextError: - return s.MustContextCode() == o.MustContextCode() - case ScStatusTypeSstHostStorageError: - return s.MustStorageCode() == o.MustStorageCode() - case ScStatusTypeSstHostValueError: - return s.MustValCode() == o.MustValCode() - case ScStatusTypeSstOk: - return true - case ScStatusTypeSstVmError: - return s.MustVmCode() == o.MustVmCode() - case ScStatusTypeSstUnknownError: - return s.MustUnknownCode() == o.MustUnknownCode() - case ScStatusTypeSstHostAuthError: - return s.MustAuthCode() == o.MustAuthCode() + case ScErrorTypeSceContract: + return s.Code == o.Code + case ScErrorTypeSceWasmVm: + return s.Code == o.Code + case ScErrorTypeSceContext: + return s.Code == o.Code + case ScErrorTypeSceStorage: + return s.Code == o.Code + case ScErrorTypeSceObject: + return s.Code == o.Code + case ScErrorTypeSceCrypto: + return s.Code == o.Code + case ScErrorTypeSceEvents: + return s.Code == o.Code + case ScErrorTypeSceBudget: + return s.Code == o.Code + case ScErrorTypeSceValue: + return s.Code == o.Code + case ScErrorTypeSceAuth: + return s.Code == o.Code default: - panic("unknown ScStatus type: " + s.Type.String()) + panic("unknown ScError type: " + s.Type.String()) } } @@ -84,7 +84,7 @@ func (s ScVal) Equals(o ScVal) bool { return s.MustB() == o.MustB() case ScValTypeScvVoid: return true - case ScValTypeScvStatus: + case ScValTypeScvError: return s.MustError().Equals(o.MustError()) case ScValTypeScvU32: return s.MustU32() == o.MustU32() diff --git a/xdr/xdr_commit_generated.txt b/xdr/xdr_commit_generated.txt index 0b2e160a1e..8b756e2890 100644 --- a/xdr/xdr_commit_generated.txt +++ b/xdr/xdr_commit_generated.txt @@ -1 +1 @@ -2f16687fdf6f4bcfb56805e2035f69997f4b34c4 \ No newline at end of file +de264d81ea87dfaa19e089b60fed8eb0219b2ab4 \ No newline at end of file diff --git a/xdr/xdr_generated.go b/xdr/xdr_generated.go index ca07520f79..8455bbf863 100644 --- a/xdr/xdr_generated.go +++ b/xdr/xdr_generated.go @@ -34,13 +34,13 @@ var XdrFilesSHA256 = map[string]string{ "xdr/Stellar-contract-config-setting.x": "45dc460924dae4c150567c215b43f21977618b48e6667edd814da2c05dd05a7e", "xdr/Stellar-contract-env-meta.x": "928a30de814ee589bc1d2aadd8dd81c39f71b7e6f430f56974505ccb1f49654b", "xdr/Stellar-contract-meta.x": "f01532c11ca044e19d9f9f16fe373e9af64835da473be556b9a807ee3319ae0d", - "xdr/Stellar-contract-spec.x": "6268629577238adf6210d6e919e41375a3b380e941d0c7acb662013c6f8aa575", - "xdr/Stellar-contract.x": "d618ba1a958d2dc50ddab1c986ab1a660a0b638a382a98bfe42d2f62b24aea05", + "xdr/Stellar-contract-spec.x": "739e2480ba197aa859f122632a93172668cb0dbe93e30a54c192b96878af207a", + "xdr/Stellar-contract.x": "697a478d4917ce3cb6f2f26a87a3705e63d71a8194eaae5129ba5ae75bc4196b", "xdr/Stellar-internal.x": "368706dd6e2efafd16a8f63daf3374845b791d097b15c502aa7653a412b68b68", - "xdr/Stellar-ledger-entries.x": "95ab2a488911a6c1a3342e68f88f2fa44ec4bc48af9c9227ccb07bb9b682d3fd", - "xdr/Stellar-ledger.x": "cd4ac7622931831291ed848004328d926d8a317122ca966f4bc105367819cd6c", - "xdr/Stellar-overlay.x": "972f38a9d4a064273f3362cbfa7d3c563293fd5396d5f0774ce6cc690e27645d", - "xdr/Stellar-transaction.x": "dcb90dcd0e7832f38a0db70d65dc603f308c4fc816ed7219c299e481b29897ce", + "xdr/Stellar-ledger-entries.x": "bc33d9275d9a2282b5db14b5748aec0ce46d19bc951aa8ffed33c5ff3a7fd635", + "xdr/Stellar-ledger.x": "0c2b074a68fa9de41b72ba1574825e7ed172e4736ca29fa6f0c88eb70579b682", + "xdr/Stellar-overlay.x": "de3957c58b96ae07968b3d3aebea84f83603e95322d1fa336360e13e3aba737a", + "xdr/Stellar-transaction.x": "6b56f47d1c6aaad860e199a7a9f46d3083921937af2fb4028c08efdcf70edaef", "xdr/Stellar-types.x": "6e3b13f0d3e360b09fa5e2b0e55d43f4d974a769df66afb34e8aecbb329d3f15", } @@ -7565,12 +7565,12 @@ var _ xdrType = (*ContractDataEntry)(nil) // ExtensionPoint ext; // // Hash hash; -// opaque code; +// opaque code<>; // }; type ContractCodeEntry struct { Ext ExtensionPoint Hash Hash - Code []byte `xdrmaxsize:"256000"` + Code []byte } // EncodeTo encodes this value using the Encoder. @@ -7604,7 +7604,7 @@ func (s *ContractCodeEntry) DecodeFrom(d *xdr.Decoder) (int, error) { if err != nil { return n, fmt.Errorf("decoding Hash: %s", err) } - s.Code, nTmp, err = d.DecodeOpaque(256000) + s.Code, nTmp, err = d.DecodeOpaque(0) n += nTmp if err != nil { return n, fmt.Errorf("decoding Code: %s", err) @@ -9783,47 +9783,35 @@ var _ xdrType = (*LedgerKey)(nil) // ENVELOPE_TYPE_TX_FEE_BUMP = 5, // ENVELOPE_TYPE_OP_ID = 6, // ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7, -// ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519 = 8, -// ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT = 9, -// ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET = 10, -// ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT = 11, -// ENVELOPE_TYPE_CREATE_CONTRACT_ARGS = 12, -// ENVELOPE_TYPE_CONTRACT_AUTH = 13 +// ENVELOPE_TYPE_CONTRACT_ID = 8, +// ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9 // }; type EnvelopeType int32 const ( - EnvelopeTypeEnvelopeTypeTxV0 EnvelopeType = 0 - EnvelopeTypeEnvelopeTypeScp EnvelopeType = 1 - EnvelopeTypeEnvelopeTypeTx EnvelopeType = 2 - EnvelopeTypeEnvelopeTypeAuth EnvelopeType = 3 - EnvelopeTypeEnvelopeTypeScpvalue EnvelopeType = 4 - EnvelopeTypeEnvelopeTypeTxFeeBump EnvelopeType = 5 - EnvelopeTypeEnvelopeTypeOpId EnvelopeType = 6 - EnvelopeTypeEnvelopeTypePoolRevokeOpId EnvelopeType = 7 - EnvelopeTypeEnvelopeTypeContractIdFromEd25519 EnvelopeType = 8 - EnvelopeTypeEnvelopeTypeContractIdFromContract EnvelopeType = 9 - EnvelopeTypeEnvelopeTypeContractIdFromAsset EnvelopeType = 10 - EnvelopeTypeEnvelopeTypeContractIdFromSourceAccount EnvelopeType = 11 - EnvelopeTypeEnvelopeTypeCreateContractArgs EnvelopeType = 12 - EnvelopeTypeEnvelopeTypeContractAuth EnvelopeType = 13 + EnvelopeTypeEnvelopeTypeTxV0 EnvelopeType = 0 + EnvelopeTypeEnvelopeTypeScp EnvelopeType = 1 + EnvelopeTypeEnvelopeTypeTx EnvelopeType = 2 + EnvelopeTypeEnvelopeTypeAuth EnvelopeType = 3 + EnvelopeTypeEnvelopeTypeScpvalue EnvelopeType = 4 + EnvelopeTypeEnvelopeTypeTxFeeBump EnvelopeType = 5 + EnvelopeTypeEnvelopeTypeOpId EnvelopeType = 6 + EnvelopeTypeEnvelopeTypePoolRevokeOpId EnvelopeType = 7 + EnvelopeTypeEnvelopeTypeContractId EnvelopeType = 8 + EnvelopeTypeEnvelopeTypeSorobanAuthorization EnvelopeType = 9 ) var envelopeTypeMap = map[int32]string{ - 0: "EnvelopeTypeEnvelopeTypeTxV0", - 1: "EnvelopeTypeEnvelopeTypeScp", - 2: "EnvelopeTypeEnvelopeTypeTx", - 3: "EnvelopeTypeEnvelopeTypeAuth", - 4: "EnvelopeTypeEnvelopeTypeScpvalue", - 5: "EnvelopeTypeEnvelopeTypeTxFeeBump", - 6: "EnvelopeTypeEnvelopeTypeOpId", - 7: "EnvelopeTypeEnvelopeTypePoolRevokeOpId", - 8: "EnvelopeTypeEnvelopeTypeContractIdFromEd25519", - 9: "EnvelopeTypeEnvelopeTypeContractIdFromContract", - 10: "EnvelopeTypeEnvelopeTypeContractIdFromAsset", - 11: "EnvelopeTypeEnvelopeTypeContractIdFromSourceAccount", - 12: "EnvelopeTypeEnvelopeTypeCreateContractArgs", - 13: "EnvelopeTypeEnvelopeTypeContractAuth", + 0: "EnvelopeTypeEnvelopeTypeTxV0", + 1: "EnvelopeTypeEnvelopeTypeScp", + 2: "EnvelopeTypeEnvelopeTypeTx", + 3: "EnvelopeTypeEnvelopeTypeAuth", + 4: "EnvelopeTypeEnvelopeTypeScpvalue", + 5: "EnvelopeTypeEnvelopeTypeTxFeeBump", + 6: "EnvelopeTypeEnvelopeTypeOpId", + 7: "EnvelopeTypeEnvelopeTypePoolRevokeOpId", + 8: "EnvelopeTypeEnvelopeTypeContractId", + 9: "EnvelopeTypeEnvelopeTypeSorobanAuthorization", } // ValidEnum validates a proposed value for this enum. Implements @@ -13525,338 +13513,6 @@ func (s TransactionHistoryResultEntry) xdrType() {} var _ xdrType = (*TransactionHistoryResultEntry)(nil) -// TransactionResultPairV2 is an XDR Struct defines as: -// -// struct TransactionResultPairV2 -// { -// Hash transactionHash; -// Hash hashOfMetaHashes; // hash of hashes in TransactionMetaV3 -// // TransactionResult is in the meta -// }; -type TransactionResultPairV2 struct { - TransactionHash Hash - HashOfMetaHashes Hash -} - -// EncodeTo encodes this value using the Encoder. -func (s *TransactionResultPairV2) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.TransactionHash.EncodeTo(e); err != nil { - return err - } - if err = s.HashOfMetaHashes.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*TransactionResultPairV2)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultPairV2) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.TransactionHash.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - nTmp, err = s.HashOfMetaHashes.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionResultPairV2) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionResultPairV2) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*TransactionResultPairV2)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionResultPairV2)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s TransactionResultPairV2) xdrType() {} - -var _ xdrType = (*TransactionResultPairV2)(nil) - -// TransactionResultSetV2 is an XDR Struct defines as: -// -// struct TransactionResultSetV2 -// { -// TransactionResultPairV2 results<>; -// }; -type TransactionResultSetV2 struct { - Results []TransactionResultPairV2 -} - -// EncodeTo encodes this value using the Encoder. -func (s *TransactionResultSetV2) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeUint(uint32(len(s.Results))); err != nil { - return err - } - for i := 0; i < len(s.Results); i++ { - if err = s.Results[i].EncodeTo(e); err != nil { - return err - } - } - return nil -} - -var _ decoderFrom = (*TransactionResultSetV2)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultSetV2) DecodeFrom(d *xdr.Decoder) (int, error) { - 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 TransactionResultPairV2: %s", err) - } - s.Results = nil - if l > 0 { - s.Results = make([]TransactionResultPairV2, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Results[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultPairV2: %s", err) - } - } - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionResultSetV2) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionResultSetV2) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*TransactionResultSetV2)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionResultSetV2)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s TransactionResultSetV2) xdrType() {} - -var _ xdrType = (*TransactionResultSetV2)(nil) - -// TransactionHistoryResultEntryV2Ext is an XDR NestedUnion defines as: -// -// union switch (int v) -// { -// case 0: -// void; -// } -type TransactionHistoryResultEntryV2Ext struct { - V int32 -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u TransactionHistoryResultEntryV2Ext) SwitchFieldName() string { - return "V" -} - -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of TransactionHistoryResultEntryV2Ext -func (u TransactionHistoryResultEntryV2Ext) ArmForSwitch(sw int32) (string, bool) { - switch int32(sw) { - case 0: - return "", true - } - return "-", false -} - -// NewTransactionHistoryResultEntryV2Ext creates a new TransactionHistoryResultEntryV2Ext. -func NewTransactionHistoryResultEntryV2Ext(v int32, value interface{}) (result TransactionHistoryResultEntryV2Ext, err error) { - result.V = v - switch int32(v) { - case 0: - // void - } - return -} - -// EncodeTo encodes this value using the Encoder. -func (u TransactionHistoryResultEntryV2Ext) 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 - } - return fmt.Errorf("V (int32) switch value '%d' is not valid for union TransactionHistoryResultEntryV2Ext", u.V) -} - -var _ decoderFrom = (*TransactionHistoryResultEntryV2Ext)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (u *TransactionHistoryResultEntryV2Ext) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - u.V, nTmp, err = d.DecodeInt() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Int: %s", err) - } - switch int32(u.V) { - case 0: - // Void - return n, nil - } - return n, fmt.Errorf("union TransactionHistoryResultEntryV2Ext has invalid V (int32) switch value '%d'", u.V) -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionHistoryResultEntryV2Ext) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionHistoryResultEntryV2Ext) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntryV2Ext)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntryV2Ext)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s TransactionHistoryResultEntryV2Ext) xdrType() {} - -var _ xdrType = (*TransactionHistoryResultEntryV2Ext)(nil) - -// TransactionHistoryResultEntryV2 is an XDR Struct defines as: -// -// struct TransactionHistoryResultEntryV2 -// { -// uint32 ledgerSeq; -// TransactionResultSetV2 txResultSet; -// -// // reserved for future use -// union switch (int v) -// { -// case 0: -// void; -// } -// ext; -// }; -type TransactionHistoryResultEntryV2 struct { - LedgerSeq Uint32 - TxResultSet TransactionResultSetV2 - Ext TransactionHistoryResultEntryV2Ext -} - -// EncodeTo encodes this value using the Encoder. -func (s *TransactionHistoryResultEntryV2) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.LedgerSeq.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 = (*TransactionHistoryResultEntryV2)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *TransactionHistoryResultEntryV2) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.LedgerSeq.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) - } - nTmp, err = s.TxResultSet.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultSetV2: %s", err) - } - nTmp, err = s.Ext.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionHistoryResultEntryV2Ext: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionHistoryResultEntryV2) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionHistoryResultEntryV2) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntryV2)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntryV2)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s TransactionHistoryResultEntryV2) xdrType() {} - -var _ xdrType = (*TransactionHistoryResultEntryV2)(nil) - // LedgerHeaderHistoryEntryExt is an XDR NestedUnion defines as: // // union switch (int v) @@ -15525,160 +15181,6 @@ func (s DiagnosticEvent) xdrType() {} var _ xdrType = (*DiagnosticEvent)(nil) -// OperationDiagnosticEvents is an XDR Struct defines as: -// -// struct OperationDiagnosticEvents -// { -// DiagnosticEvent events<>; -// }; -type OperationDiagnosticEvents struct { - Events []DiagnosticEvent -} - -// EncodeTo encodes this value using the Encoder. -func (s *OperationDiagnosticEvents) EncodeTo(e *xdr.Encoder) error { - var err error - 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 = (*OperationDiagnosticEvents)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *OperationDiagnosticEvents) DecodeFrom(d *xdr.Decoder) (int, error) { - 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 DiagnosticEvent: %s", err) - } - s.Events = nil - if l > 0 { - s.Events = make([]DiagnosticEvent, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Events[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding DiagnosticEvent: %s", err) - } - } - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s OperationDiagnosticEvents) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *OperationDiagnosticEvents) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*OperationDiagnosticEvents)(nil) - _ encoding.BinaryUnmarshaler = (*OperationDiagnosticEvents)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s OperationDiagnosticEvents) xdrType() {} - -var _ xdrType = (*OperationDiagnosticEvents)(nil) - -// OperationEvents is an XDR Struct defines as: -// -// struct OperationEvents -// { -// ContractEvent events<>; -// }; -type OperationEvents struct { - Events []ContractEvent -} - -// EncodeTo encodes this value using the Encoder. -func (s *OperationEvents) EncodeTo(e *xdr.Encoder) error { - var err error - 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 = (*OperationEvents)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *OperationEvents) DecodeFrom(d *xdr.Decoder) (int, error) { - 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 ContractEvent: %s", err) - } - s.Events = nil - if l > 0 { - s.Events = make([]ContractEvent, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Events[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ContractEvent: %s", err) - } - } - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s OperationEvents) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *OperationEvents) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*OperationEvents)(nil) - _ encoding.BinaryUnmarshaler = (*OperationEvents)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s OperationEvents) xdrType() {} - -var _ xdrType = (*OperationEvents)(nil) - // TransactionMetaV3 is an XDR Struct defines as: // // struct TransactionMetaV3 @@ -15688,26 +15190,22 @@ var _ xdrType = (*OperationEvents)(nil) // OperationMeta operations<>; // meta for each operation // LedgerEntryChanges txChangesAfter; // tx level changes after operations are // // applied if any -// OperationEvents events<>; // custom events populated by the -// // contracts themselves. One list per operation. -// TransactionResult txResult; -// -// Hash hashes[3]; // stores sha256(txChangesBefore, operations, txChangesAfter), -// // sha256(events), and sha256(txResult) +// ContractEvent events<>; // custom events populated by the +// // contracts themselves. +// SCVal returnValue; // return value of the invocation. // -// // Diagnostics events that are not hashed. One list per operation. +// // Diagnostics events that are not hashed. // // This will contain all contract and diagnostic events. Even ones // // that were emitted in a failed contract call. -// OperationDiagnosticEvents diagnosticEvents<>; +// DiagnosticEvent diagnosticEvents<>; // }; type TransactionMetaV3 struct { TxChangesBefore LedgerEntryChanges Operations []OperationMeta TxChangesAfter LedgerEntryChanges - Events []OperationEvents - TxResult TransactionResult - Hashes [3]Hash - DiagnosticEvents []OperationDiagnosticEvents + Events []ContractEvent + ReturnValue ScVal + DiagnosticEvents []DiagnosticEvent } // EncodeTo encodes this value using the Encoder. @@ -15735,14 +15233,9 @@ func (s *TransactionMetaV3) EncodeTo(e *xdr.Encoder) error { return err } } - if err = s.TxResult.EncodeTo(e); err != nil { + if err = s.ReturnValue.EncodeTo(e); err != nil { return err } - for i := 0; i < len(s.Hashes); i++ { - if err = s.Hashes[i].EncodeTo(e); err != nil { - return err - } - } if _, err = e.EncodeUint(uint32(len(s.DiagnosticEvents))); err != nil { return err } @@ -15790,44 +15283,37 @@ func (s *TransactionMetaV3) DecodeFrom(d *xdr.Decoder) (int, error) { l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationEvents: %s", err) + return n, fmt.Errorf("decoding ContractEvent: %s", err) } s.Events = nil if l > 0 { - s.Events = make([]OperationEvents, l) + s.Events = make([]ContractEvent, l) for i := uint32(0); i < l; i++ { nTmp, err = s.Events[i].DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationEvents: %s", err) + return n, fmt.Errorf("decoding ContractEvent: %s", err) } } } - nTmp, err = s.TxResult.DecodeFrom(d) + nTmp, err = s.ReturnValue.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding TransactionResult: %s", err) - } - for i := 0; i < len(s.Hashes); i++ { - nTmp, err = s.Hashes[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } + return n, fmt.Errorf("decoding ScVal: %s", err) } l, nTmp, err = d.DecodeUint() n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationDiagnosticEvents: %s", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %s", err) } s.DiagnosticEvents = nil if l > 0 { - s.DiagnosticEvents = make([]OperationDiagnosticEvents, l) + s.DiagnosticEvents = make([]DiagnosticEvent, l) for i := uint32(0); i < l; i++ { nTmp, err = s.DiagnosticEvents[i].DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding OperationDiagnosticEvents: %s", err) + return n, fmt.Errorf("decoding DiagnosticEvent: %s", err) } } } @@ -15861,6 +15347,93 @@ 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) (int, error) { + var err error + var n, nTmp int + nTmp, err = s.ReturnValue.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVal: %s", err) + } + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ContractEvent: %s", err) + } + s.Events = nil + if l > 0 { + s.Events = make([]ContractEvent, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.Events[i].DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ContractEvent: %s", err) + } + } + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s InvokeHostFunctionSuccessPreImage) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *InvokeHostFunctionSuccessPreImage) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + d := xdr.NewDecoder(r) + _, err := s.DecodeFrom(d) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*InvokeHostFunctionSuccessPreImage)(nil) + _ encoding.BinaryUnmarshaler = (*InvokeHostFunctionSuccessPreImage)(nil) +) + +// xdrType signals that this type is an type representing +// representing XDR values defined by this package. +func (s InvokeHostFunctionSuccessPreImage) xdrType() {} + +var _ xdrType = (*InvokeHostFunctionSuccessPreImage)(nil) + // TransactionMeta is an XDR Union defines as: // // union TransactionMeta switch (int v) @@ -16243,86 +15816,6 @@ func (s TransactionResultMeta) xdrType() {} var _ xdrType = (*TransactionResultMeta)(nil) -// TransactionResultMetaV2 is an XDR Struct defines as: -// -// struct TransactionResultMetaV2 -// { -// TransactionResultPairV2 result; -// LedgerEntryChanges feeProcessing; -// TransactionMeta txApplyProcessing; -// }; -type TransactionResultMetaV2 struct { - Result TransactionResultPairV2 - FeeProcessing LedgerEntryChanges - TxApplyProcessing TransactionMeta -} - -// EncodeTo encodes this value using the Encoder. -func (s *TransactionResultMetaV2) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Result.EncodeTo(e); err != nil { - 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 = (*TransactionResultMetaV2)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *TransactionResultMetaV2) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.Result.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultPairV2: %s", err) - } - nTmp, err = s.FeeProcessing.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerEntryChanges: %s", err) - } - nTmp, err = s.TxApplyProcessing.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionMeta: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s TransactionResultMetaV2) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *TransactionResultMetaV2) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*TransactionResultMetaV2)(nil) - _ encoding.BinaryUnmarshaler = (*TransactionResultMetaV2)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s TransactionResultMetaV2) xdrType() {} - -var _ xdrType = (*TransactionResultMetaV2)(nil) - // UpgradeEntryMeta is an XDR Struct defines as: // // struct UpgradeEntryMeta @@ -16709,164 +16202,6 @@ func (s LedgerCloseMetaV1) xdrType() {} var _ xdrType = (*LedgerCloseMetaV1)(nil) -// LedgerCloseMetaV2 is an XDR Struct defines as: -// -// struct LedgerCloseMetaV2 -// { -// LedgerHeaderHistoryEntry ledgerHeader; -// -// GeneralizedTransactionSet txSet; -// -// // NB: transactions are sorted in apply order here -// // fees for all transactions are processed first -// // followed by applying transactions -// TransactionResultMetaV2 txProcessing<>; -// -// // upgrades are applied last -// UpgradeEntryMeta upgradesProcessing<>; -// -// // other misc information attached to the ledger close -// SCPHistoryEntry scpInfo<>; -// }; -type LedgerCloseMetaV2 struct { - LedgerHeader LedgerHeaderHistoryEntry - TxSet GeneralizedTransactionSet - TxProcessing []TransactionResultMetaV2 - UpgradesProcessing []UpgradeEntryMeta - ScpInfo []ScpHistoryEntry -} - -// EncodeTo encodes this value using the Encoder. -func (s *LedgerCloseMetaV2) 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 { - 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 = (*LedgerCloseMetaV2)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *LedgerCloseMetaV2) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.LedgerHeader.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerHeaderHistoryEntry: %s", err) - } - nTmp, err = s.TxSet.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding GeneralizedTransactionSet: %s", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultMetaV2: %s", err) - } - s.TxProcessing = nil - if l > 0 { - s.TxProcessing = make([]TransactionResultMetaV2, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.TxProcessing[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding TransactionResultMetaV2: %s", err) - } - } - } - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) - } - s.UpgradesProcessing = nil - if l > 0 { - s.UpgradesProcessing = make([]UpgradeEntryMeta, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.UpgradesProcessing[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding UpgradeEntryMeta: %s", err) - } - } - } - l, nTmp, err = d.DecodeUint() - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) - } - s.ScpInfo = nil - if l > 0 { - s.ScpInfo = make([]ScpHistoryEntry, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.ScpInfo[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScpHistoryEntry: %s", err) - } - } - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s LedgerCloseMetaV2) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *LedgerCloseMetaV2) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*LedgerCloseMetaV2)(nil) - _ encoding.BinaryUnmarshaler = (*LedgerCloseMetaV2)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s LedgerCloseMetaV2) xdrType() {} - -var _ xdrType = (*LedgerCloseMetaV2)(nil) - // LedgerCloseMeta is an XDR Union defines as: // // union LedgerCloseMeta switch (int v) @@ -16875,14 +16210,11 @@ var _ xdrType = (*LedgerCloseMetaV2)(nil) // LedgerCloseMetaV0 v0; // case 1: // LedgerCloseMetaV1 v1; -// case 2: -// LedgerCloseMetaV2 v2; // }; type LedgerCloseMeta struct { V int32 V0 *LedgerCloseMetaV0 V1 *LedgerCloseMetaV1 - V2 *LedgerCloseMetaV2 } // SwitchFieldName returns the field name in which this union's @@ -16899,8 +16231,6 @@ func (u LedgerCloseMeta) ArmForSwitch(sw int32) (string, bool) { return "V0", true case 1: return "V1", true - case 2: - return "V2", true } return "-", false } @@ -16923,13 +16253,6 @@ func NewLedgerCloseMeta(v int32, value interface{}) (result LedgerCloseMeta, err return } result.V1 = &tv - case 2: - tv, ok := value.(LedgerCloseMetaV2) - if !ok { - err = fmt.Errorf("invalid value, must be LedgerCloseMetaV2") - return - } - result.V2 = &tv } return } @@ -16984,31 +16307,6 @@ 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 LedgerCloseMeta) MustV2() LedgerCloseMetaV2 { - 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 LedgerCloseMeta) GetV2() (result LedgerCloseMetaV2, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.V)) - - if armName == "V2" { - result = *u.V2 - ok = true - } - - return -} - // EncodeTo encodes this value using the Encoder. func (u LedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { var err error @@ -17026,11 +16324,6 @@ func (u LedgerCloseMeta) EncodeTo(e *xdr.Encoder) error { return err } return nil - case 2: - if err = (*u.V2).EncodeTo(e); err != nil { - return err - } - return nil } return fmt.Errorf("V (int32) switch value '%d' is not valid for union LedgerCloseMeta", u.V) } @@ -17063,14 +16356,6 @@ func (u *LedgerCloseMeta) DecodeFrom(d *xdr.Decoder) (int, error) { return n, fmt.Errorf("decoding LedgerCloseMetaV1: %s", err) } return n, nil - case 2: - u.V2 = new(LedgerCloseMetaV2) - nTmp, err = (*u.V2).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding LedgerCloseMetaV2: %s", err) - } - return n, nil } return n, fmt.Errorf("union LedgerCloseMeta has invalid V (int32) switch value '%d'", u.V) } @@ -17324,6 +16609,76 @@ func (s SendMore) xdrType() {} var _ xdrType = (*SendMore)(nil) +// SendMoreExtended is an XDR Struct defines as: +// +// struct SendMoreExtended +// { +// uint32 numMessages; +// uint32 numBytes; +// }; +type SendMoreExtended struct { + NumMessages Uint32 + NumBytes Uint32 +} + +// EncodeTo encodes this value using the Encoder. +func (s *SendMoreExtended) EncodeTo(e *xdr.Encoder) error { + var err error + if err = s.NumMessages.EncodeTo(e); err != nil { + return err + } + if err = s.NumBytes.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*SendMoreExtended)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *SendMoreExtended) DecodeFrom(d *xdr.Decoder) (int, error) { + var err error + var n, nTmp int + nTmp, err = s.NumMessages.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %s", err) + } + nTmp, err = s.NumBytes.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding Uint32: %s", err) + } + return n, nil +} + +// MarshalBinary implements encoding.BinaryMarshaler. +func (s SendMoreExtended) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SendMoreExtended) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + d := xdr.NewDecoder(r) + _, err := s.DecodeFrom(d) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SendMoreExtended)(nil) + _ encoding.BinaryUnmarshaler = (*SendMoreExtended)(nil) +) + +// xdrType signals that this type is an type representing +// representing XDR values defined by this package. +func (s SendMoreExtended) xdrType() {} + +var _ xdrType = (*SendMoreExtended)(nil) + // AuthCert is an XDR Struct defines as: // // struct AuthCert @@ -17544,10 +16899,10 @@ func (s Hello) xdrType() {} var _ xdrType = (*Hello)(nil) -// AuthMsgFlagPullModeRequested is an XDR Const defines as: +// AuthMsgFlagFlowControlBytesRequested is an XDR Const defines as: // -// const AUTH_MSG_FLAG_PULL_MODE_REQUESTED = 100; -const AuthMsgFlagPullModeRequested = 100 +// const AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED = 200; +const AuthMsgFlagFlowControlBytesRequested = 200 // Auth is an XDR Struct defines as: // @@ -17994,6 +17349,8 @@ var _ xdrType = (*PeerAddress)(nil) // SURVEY_RESPONSE = 15, // // SEND_MORE = 16, +// SEND_MORE_EXTENDED = 20, +// // FLOOD_ADVERT = 18, // FLOOD_DEMAND = 19 // }; @@ -18017,6 +17374,7 @@ const ( MessageTypeSurveyRequest MessageType = 14 MessageTypeSurveyResponse MessageType = 15 MessageTypeSendMore MessageType = 16 + MessageTypeSendMoreExtended MessageType = 20 MessageTypeFloodAdvert MessageType = 18 MessageTypeFloodDemand MessageType = 19 ) @@ -18039,6 +17397,7 @@ var messageTypeMap = map[int32]string{ 14: "MessageTypeSurveyRequest", 15: "MessageTypeSurveyResponse", 16: "MessageTypeSendMore", + 20: "MessageTypeSendMoreExtended", 18: "MessageTypeFloodAdvert", 19: "MessageTypeFloodDemand", } @@ -19744,7 +19103,8 @@ var _ xdrType = (*FloodDemand)(nil) // 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; @@ -19769,6 +19129,7 @@ type StellarMessage struct { Envelope *ScpEnvelope GetScpLedgerSeq *Uint32 SendMoreMessage *SendMore + SendMoreExtendedMessage *SendMoreExtended FloodAdvert *FloodAdvert FloodDemand *FloodDemand } @@ -19817,6 +19178,8 @@ func (u StellarMessage) ArmForSwitch(sw int32) (string, bool) { return "GetScpLedgerSeq", true case MessageTypeSendMore: return "SendMoreMessage", true + case MessageTypeSendMoreExtended: + return "SendMoreExtendedMessage", true case MessageTypeFloodAdvert: return "FloodAdvert", true case MessageTypeFloodDemand: @@ -19943,6 +19306,13 @@ func NewStellarMessage(aType MessageType, value interface{}) (result StellarMess return } result.SendMoreMessage = &tv + case MessageTypeSendMoreExtended: + tv, ok := value.(SendMoreExtended) + if !ok { + err = fmt.Errorf("invalid value, must be SendMoreExtended") + return + } + result.SendMoreExtendedMessage = &tv case MessageTypeFloodAdvert: tv, ok := value.(FloodAdvert) if !ok { @@ -20361,6 +19731,31 @@ func (u StellarMessage) GetSendMoreMessage() (result SendMore, ok bool) { 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 { @@ -20506,6 +19901,11 @@ func (u StellarMessage) EncodeTo(e *xdr.Encoder) error { 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 @@ -20678,6 +20078,14 @@ func (u *StellarMessage) DecodeFrom(d *xdr.Decoder) (int, error) { return n, fmt.Errorf("decoding SendMore: %s", err) } return n, nil + case MessageTypeSendMoreExtended: + u.SendMoreExtendedMessage = new(SendMoreExtended) + nTmp, err = (*u.SendMoreExtendedMessage).DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SendMoreExtended: %s", err) + } + return n, nil case MessageTypeFloodAdvert: u.FloodAdvert = new(FloodAdvert) nTmp, err = (*u.FloodAdvert).DecodeFrom(d) @@ -24178,67 +23586,64 @@ func (s HostFunctionType) xdrType() {} var _ xdrType = (*HostFunctionType)(nil) -// ContractIdType is an XDR Enum defines as: +// ContractIdPreimageType is an XDR Enum defines as: // -// enum ContractIDType +// enum ContractIDPreimageType // { -// CONTRACT_ID_FROM_SOURCE_ACCOUNT = 0, -// CONTRACT_ID_FROM_ED25519_PUBLIC_KEY = 1, -// CONTRACT_ID_FROM_ASSET = 2 +// CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0, +// CONTRACT_ID_PREIMAGE_FROM_ASSET = 1 // }; -type ContractIdType int32 +type ContractIdPreimageType int32 const ( - ContractIdTypeContractIdFromSourceAccount ContractIdType = 0 - ContractIdTypeContractIdFromEd25519PublicKey ContractIdType = 1 - ContractIdTypeContractIdFromAsset ContractIdType = 2 + ContractIdPreimageTypeContractIdPreimageFromAddress ContractIdPreimageType = 0 + ContractIdPreimageTypeContractIdPreimageFromAsset ContractIdPreimageType = 1 ) -var contractIdTypeMap = map[int32]string{ - 0: "ContractIdTypeContractIdFromSourceAccount", - 1: "ContractIdTypeContractIdFromEd25519PublicKey", - 2: "ContractIdTypeContractIdFromAsset", +var contractIdPreimageTypeMap = map[int32]string{ + 0: "ContractIdPreimageTypeContractIdPreimageFromAddress", + 1: "ContractIdPreimageTypeContractIdPreimageFromAsset", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ContractIdType -func (e ContractIdType) ValidEnum(v int32) bool { - _, ok := contractIdTypeMap[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 ContractIdType) String() string { - name, _ := contractIdTypeMap[int32(e)] +func (e ContractIdPreimageType) String() string { + name, _ := contractIdPreimageTypeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e ContractIdType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := contractIdTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ContractIdType 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 = (*ContractIdType)(nil) +var _ decoderFrom = (*ContractIdPreimageType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ContractIdType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ContractIdPreimageType) DecodeFrom(d *xdr.Decoder) (int, error) { v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ContractIdType: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimageType: %s", err) } - if _, ok := contractIdTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ContractIdType enum value", v) + if _, ok := contractIdPreimageTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ContractIdPreimageType enum value", v) } - *e = ContractIdType(v) + *e = ContractIdPreimageType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractIdType) MarshalBinary() ([]byte, error) { +func (s ContractIdPreimageType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -24246,7 +23651,7 @@ func (s ContractIdType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractIdType) UnmarshalBinary(inp []byte) error { +func (s *ContractIdPreimageType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -24254,180 +23659,32 @@ func (s *ContractIdType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractIdType)(nil) - _ encoding.BinaryUnmarshaler = (*ContractIdType)(nil) + _ encoding.BinaryMarshaler = (*ContractIdPreimageType)(nil) + _ encoding.BinaryUnmarshaler = (*ContractIdPreimageType)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ContractIdType) xdrType() {} +func (s ContractIdPreimageType) xdrType() {} -var _ xdrType = (*ContractIdType)(nil) +var _ xdrType = (*ContractIdPreimageType)(nil) -// ContractIdPublicKeyType is an XDR Enum defines as: -// -// enum ContractIDPublicKeyType -// { -// CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT = 0, -// CONTRACT_ID_PUBLIC_KEY_ED25519 = 1 -// }; -type ContractIdPublicKeyType int32 - -const ( - ContractIdPublicKeyTypeContractIdPublicKeySourceAccount ContractIdPublicKeyType = 0 - ContractIdPublicKeyTypeContractIdPublicKeyEd25519 ContractIdPublicKeyType = 1 -) - -var contractIdPublicKeyTypeMap = map[int32]string{ - 0: "ContractIdPublicKeyTypeContractIdPublicKeySourceAccount", - 1: "ContractIdPublicKeyTypeContractIdPublicKeyEd25519", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ContractIdPublicKeyType -func (e ContractIdPublicKeyType) ValidEnum(v int32) bool { - _, ok := contractIdPublicKeyTypeMap[v] - return ok -} - -// String returns the name of `e` -func (e ContractIdPublicKeyType) String() string { - name, _ := contractIdPublicKeyTypeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ContractIdPublicKeyType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := contractIdPublicKeyTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ContractIdPublicKeyType enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ContractIdPublicKeyType)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ContractIdPublicKeyType) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ContractIdPublicKeyType: %s", err) - } - if _, ok := contractIdPublicKeyTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ContractIdPublicKeyType enum value", v) - } - *e = ContractIdPublicKeyType(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractIdPublicKeyType) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractIdPublicKeyType) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ContractIdPublicKeyType)(nil) - _ encoding.BinaryUnmarshaler = (*ContractIdPublicKeyType)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ContractIdPublicKeyType) xdrType() {} - -var _ xdrType = (*ContractIdPublicKeyType)(nil) - -// UploadContractWasmArgs is an XDR Struct defines as: -// -// struct UploadContractWasmArgs -// { -// opaque code; -// }; -type UploadContractWasmArgs struct { - Code []byte `xdrmaxsize:"256000"` -} - -// EncodeTo encodes this value using the Encoder. -func (s *UploadContractWasmArgs) EncodeTo(e *xdr.Encoder) error { - var err error - if _, err = e.EncodeOpaque(s.Code[:]); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*UploadContractWasmArgs)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *UploadContractWasmArgs) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - s.Code, nTmp, err = d.DecodeOpaque(256000) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Code: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s UploadContractWasmArgs) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *UploadContractWasmArgs) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*UploadContractWasmArgs)(nil) - _ encoding.BinaryUnmarshaler = (*UploadContractWasmArgs)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s UploadContractWasmArgs) xdrType() {} - -var _ xdrType = (*UploadContractWasmArgs)(nil) - -// ContractIdFromEd25519PublicKey is an XDR NestedStruct defines as: +// ContractIdPreimageFromAddress is an XDR NestedStruct defines as: // // struct // { -// uint256 key; -// Signature signature; +// SCAddress address; // uint256 salt; // } -type ContractIdFromEd25519PublicKey struct { - Key Uint256 - Signature Signature - Salt Uint256 +type ContractIdPreimageFromAddress struct { + Address ScAddress + Salt Uint256 } // EncodeTo encodes this value using the Encoder. -func (s *ContractIdFromEd25519PublicKey) EncodeTo(e *xdr.Encoder) error { +func (s *ContractIdPreimageFromAddress) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Key.EncodeTo(e); err != nil { - return err - } - if err = s.Signature.EncodeTo(e); err != nil { + if err = s.Address.EncodeTo(e); err != nil { return err } if err = s.Salt.EncodeTo(e); err != nil { @@ -24436,21 +23693,16 @@ func (s *ContractIdFromEd25519PublicKey) EncodeTo(e *xdr.Encoder) error { return nil } -var _ decoderFrom = (*ContractIdFromEd25519PublicKey)(nil) +var _ decoderFrom = (*ContractIdPreimageFromAddress)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractIdFromEd25519PublicKey) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ContractIdPreimageFromAddress) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - nTmp, err = s.Key.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) - } - nTmp, err = s.Signature.DecodeFrom(d) + nTmp, err = s.Address.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Signature: %s", err) + return n, fmt.Errorf("decoding ScAddress: %s", err) } nTmp, err = s.Salt.DecodeFrom(d) n += nTmp @@ -24461,7 +23713,7 @@ func (s *ContractIdFromEd25519PublicKey) DecodeFrom(d *xdr.Decoder) (int, error) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractIdFromEd25519PublicKey) MarshalBinary() ([]byte, error) { +func (s ContractIdPreimageFromAddress) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -24469,7 +23721,7 @@ func (s ContractIdFromEd25519PublicKey) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractIdFromEd25519PublicKey) UnmarshalBinary(inp []byte) error { +func (s *ContractIdPreimageFromAddress) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -24477,157 +23729,119 @@ func (s *ContractIdFromEd25519PublicKey) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractIdFromEd25519PublicKey)(nil) - _ encoding.BinaryUnmarshaler = (*ContractIdFromEd25519PublicKey)(nil) + _ encoding.BinaryMarshaler = (*ContractIdPreimageFromAddress)(nil) + _ encoding.BinaryUnmarshaler = (*ContractIdPreimageFromAddress)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ContractIdFromEd25519PublicKey) xdrType() {} +func (s ContractIdPreimageFromAddress) xdrType() {} -var _ xdrType = (*ContractIdFromEd25519PublicKey)(nil) +var _ xdrType = (*ContractIdPreimageFromAddress)(nil) -// ContractId is an XDR Union defines as: +// ContractIdPreimage is an XDR Union defines as: // -// union ContractID switch (ContractIDType type) +// union ContractIDPreimage switch (ContractIDPreimageType type) // { -// case CONTRACT_ID_FROM_SOURCE_ACCOUNT: -// uint256 salt; -// case CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: +// case CONTRACT_ID_PREIMAGE_FROM_ADDRESS: // struct // { -// uint256 key; -// Signature signature; +// SCAddress address; // uint256 salt; -// } fromEd25519PublicKey; -// case CONTRACT_ID_FROM_ASSET: -// Asset asset; +// } fromAddress; +// case CONTRACT_ID_PREIMAGE_FROM_ASSET: +// Asset fromAsset; // }; -type ContractId struct { - Type ContractIdType - Salt *Uint256 - FromEd25519PublicKey *ContractIdFromEd25519PublicKey - Asset *Asset +type ContractIdPreimage struct { + Type ContractIdPreimageType + FromAddress *ContractIdPreimageFromAddress + FromAsset *Asset } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u ContractId) 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 ContractId -func (u ContractId) ArmForSwitch(sw int32) (string, bool) { - switch ContractIdType(sw) { - case ContractIdTypeContractIdFromSourceAccount: - return "Salt", true - case ContractIdTypeContractIdFromEd25519PublicKey: - return "FromEd25519PublicKey", true - case ContractIdTypeContractIdFromAsset: - return "Asset", 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 } -// NewContractId creates a new ContractId. -func NewContractId(aType ContractIdType, value interface{}) (result ContractId, err error) { +// NewContractIdPreimage creates a new ContractIdPreimage. +func NewContractIdPreimage(aType ContractIdPreimageType, value interface{}) (result ContractIdPreimage, err error) { result.Type = aType - switch ContractIdType(aType) { - case ContractIdTypeContractIdFromSourceAccount: - tv, ok := value.(Uint256) - if !ok { - err = fmt.Errorf("invalid value, must be Uint256") - return - } - result.Salt = &tv - case ContractIdTypeContractIdFromEd25519PublicKey: - tv, ok := value.(ContractIdFromEd25519PublicKey) + switch ContractIdPreimageType(aType) { + case ContractIdPreimageTypeContractIdPreimageFromAddress: + tv, ok := value.(ContractIdPreimageFromAddress) if !ok { - err = fmt.Errorf("invalid value, must be ContractIdFromEd25519PublicKey") + err = fmt.Errorf("invalid value, must be ContractIdPreimageFromAddress") return } - result.FromEd25519PublicKey = &tv - case ContractIdTypeContractIdFromAsset: + result.FromAddress = &tv + case ContractIdPreimageTypeContractIdPreimageFromAsset: tv, ok := value.(Asset) if !ok { err = fmt.Errorf("invalid value, must be Asset") return } - result.Asset = &tv - } - return -} - -// MustSalt retrieves the Salt value from the union, -// panicing if the value is not set. -func (u ContractId) MustSalt() Uint256 { - val, ok := u.GetSalt() - - if !ok { - panic("arm Salt is not set") - } - - return val -} - -// GetSalt retrieves the Salt value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ContractId) GetSalt() (result Uint256, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Salt" { - result = *u.Salt - ok = true + result.FromAsset = &tv } - return } -// MustFromEd25519PublicKey retrieves the FromEd25519PublicKey value from the union, +// MustFromAddress retrieves the FromAddress value from the union, // panicing if the value is not set. -func (u ContractId) MustFromEd25519PublicKey() ContractIdFromEd25519PublicKey { - val, ok := u.GetFromEd25519PublicKey() +func (u ContractIdPreimage) MustFromAddress() ContractIdPreimageFromAddress { + val, ok := u.GetFromAddress() if !ok { - panic("arm FromEd25519PublicKey is not set") + panic("arm FromAddress is not set") } return val } -// GetFromEd25519PublicKey retrieves the FromEd25519PublicKey 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 ContractId) GetFromEd25519PublicKey() (result ContractIdFromEd25519PublicKey, ok bool) { +func (u ContractIdPreimage) GetFromAddress() (result ContractIdPreimageFromAddress, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "FromEd25519PublicKey" { - result = *u.FromEd25519PublicKey + if armName == "FromAddress" { + result = *u.FromAddress ok = true } return } -// MustAsset retrieves the Asset value from the union, +// MustFromAsset retrieves the FromAsset value from the union, // panicing if the value is not set. -func (u ContractId) MustAsset() Asset { - val, ok := u.GetAsset() +func (u ContractIdPreimage) MustFromAsset() Asset { + val, ok := u.GetFromAsset() if !ok { - panic("arm Asset is not set") + panic("arm FromAsset is not set") } return val } -// GetAsset retrieves the Asset 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 ContractId) GetAsset() (result Asset, ok bool) { +func (u ContractIdPreimage) GetFromAsset() (result Asset, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "Asset" { - result = *u.Asset + if armName == "FromAsset" { + result = *u.FromAsset ok = true } @@ -24635,73 +23849,60 @@ func (u ContractId) GetAsset() (result Asset, ok bool) { } // EncodeTo encodes this value using the Encoder. -func (u ContractId) 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 ContractIdType(u.Type) { - case ContractIdTypeContractIdFromSourceAccount: - if err = (*u.Salt).EncodeTo(e); err != nil { - return err - } - return nil - case ContractIdTypeContractIdFromEd25519PublicKey: - if err = (*u.FromEd25519PublicKey).EncodeTo(e); err != nil { + switch ContractIdPreimageType(u.Type) { + case ContractIdPreimageTypeContractIdPreimageFromAddress: + if err = (*u.FromAddress).EncodeTo(e); err != nil { return err } return nil - case ContractIdTypeContractIdFromAsset: - if err = (*u.Asset).EncodeTo(e); err != nil { + case ContractIdPreimageTypeContractIdPreimageFromAsset: + if err = (*u.FromAsset).EncodeTo(e); err != nil { return err } return nil } - return fmt.Errorf("Type (ContractIdType) switch value '%d' is not valid for union ContractId", u.Type) + return fmt.Errorf("Type (ContractIdPreimageType) switch value '%d' is not valid for union ContractIdPreimage", u.Type) } -var _ decoderFrom = (*ContractId)(nil) +var _ decoderFrom = (*ContractIdPreimage)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ContractId) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *ContractIdPreimage) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int nTmp, err = u.Type.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdType: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimageType: %s", err) } - switch ContractIdType(u.Type) { - case ContractIdTypeContractIdFromSourceAccount: - u.Salt = new(Uint256) - nTmp, err = (*u.Salt).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) - } - return n, nil - case ContractIdTypeContractIdFromEd25519PublicKey: - u.FromEd25519PublicKey = new(ContractIdFromEd25519PublicKey) - nTmp, err = (*u.FromEd25519PublicKey).DecodeFrom(d) + switch ContractIdPreimageType(u.Type) { + case ContractIdPreimageTypeContractIdPreimageFromAddress: + u.FromAddress = new(ContractIdPreimageFromAddress) + nTmp, err = (*u.FromAddress).DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractIdFromEd25519PublicKey: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimageFromAddress: %s", err) } return n, nil - case ContractIdTypeContractIdFromAsset: - u.Asset = new(Asset) - nTmp, err = (*u.Asset).DecodeFrom(d) + case ContractIdPreimageTypeContractIdPreimageFromAsset: + u.FromAsset = new(Asset) + nTmp, err = (*u.FromAsset).DecodeFrom(d) n += nTmp if err != nil { return n, fmt.Errorf("decoding Asset: %s", err) } return n, nil } - return n, fmt.Errorf("union ContractId has invalid Type (ContractIdType) 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 ContractId) MarshalBinary() ([]byte, error) { +func (s ContractIdPreimage) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -24709,7 +23910,7 @@ func (s ContractId) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractId) UnmarshalBinary(inp []byte) error { +func (s *ContractIdPreimage) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -24717,32 +23918,32 @@ func (s *ContractId) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractId)(nil) - _ encoding.BinaryUnmarshaler = (*ContractId)(nil) + _ encoding.BinaryMarshaler = (*ContractIdPreimage)(nil) + _ encoding.BinaryUnmarshaler = (*ContractIdPreimage)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ContractId) xdrType() {} +func (s ContractIdPreimage) xdrType() {} -var _ xdrType = (*ContractId)(nil) +var _ xdrType = (*ContractIdPreimage)(nil) // CreateContractArgs is an XDR Struct defines as: // // struct CreateContractArgs // { -// ContractID contractID; +// ContractIDPreimage contractIDPreimage; // SCContractExecutable executable; // }; type CreateContractArgs struct { - ContractId ContractId - Executable ScContractExecutable + ContractIdPreimage ContractIdPreimage + Executable ScContractExecutable } // EncodeTo encodes this value using the Encoder. func (s *CreateContractArgs) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.ContractId.EncodeTo(e); err != nil { + if err = s.ContractIdPreimage.EncodeTo(e); err != nil { return err } if err = s.Executable.EncodeTo(e); err != nil { @@ -24757,10 +23958,10 @@ var _ decoderFrom = (*CreateContractArgs)(nil) func (s *CreateContractArgs) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - nTmp, err = s.ContractId.DecodeFrom(d) + nTmp, err = s.ContractIdPreimage.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractId: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimage: %s", err) } nTmp, err = s.Executable.DecodeFrom(d) n += nTmp @@ -24797,46 +23998,46 @@ func (s CreateContractArgs) xdrType() {} var _ xdrType = (*CreateContractArgs)(nil) -// HostFunctionArgs is an XDR Union defines as: +// HostFunction is an XDR Union defines as: // -// union HostFunctionArgs switch (HostFunctionType type) +// union HostFunction switch (HostFunctionType type) // { // case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: // SCVec invokeContract; // case HOST_FUNCTION_TYPE_CREATE_CONTRACT: // CreateContractArgs createContract; // case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM: -// UploadContractWasmArgs uploadContractWasm; +// opaque wasm<>; // }; -type HostFunctionArgs struct { - Type HostFunctionType - InvokeContract *ScVec - CreateContract *CreateContractArgs - UploadContractWasm *UploadContractWasmArgs +type HostFunction struct { + Type HostFunctionType + InvokeContract *ScVec + CreateContract *CreateContractArgs + Wasm *[]byte } // SwitchFieldName returns the field name in which this union's // discriminant is stored -func (u HostFunctionArgs) SwitchFieldName() string { +func (u HostFunction) SwitchFieldName() string { return "Type" } // ArmForSwitch returns which field name should be used for storing -// the value for an instance of HostFunctionArgs -func (u HostFunctionArgs) ArmForSwitch(sw int32) (string, bool) { +// 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 "UploadContractWasm", true + return "Wasm", true } return "-", false } -// NewHostFunctionArgs creates a new HostFunctionArgs. -func NewHostFunctionArgs(aType HostFunctionType, value interface{}) (result HostFunctionArgs, err error) { +// NewHostFunction creates a new HostFunction. +func NewHostFunction(aType HostFunctionType, value interface{}) (result HostFunction, err error) { result.Type = aType switch HostFunctionType(aType) { case HostFunctionTypeHostFunctionTypeInvokeContract: @@ -24854,19 +24055,19 @@ func NewHostFunctionArgs(aType HostFunctionType, value interface{}) (result Host } result.CreateContract = &tv case HostFunctionTypeHostFunctionTypeUploadContractWasm: - tv, ok := value.(UploadContractWasmArgs) + tv, ok := value.([]byte) if !ok { - err = fmt.Errorf("invalid value, must be UploadContractWasmArgs") + err = fmt.Errorf("invalid value, must be []byte") return } - result.UploadContractWasm = &tv + result.Wasm = &tv } return } // MustInvokeContract retrieves the InvokeContract value from the union, // panicing if the value is not set. -func (u HostFunctionArgs) MustInvokeContract() ScVec { +func (u HostFunction) MustInvokeContract() ScVec { val, ok := u.GetInvokeContract() if !ok { @@ -24878,7 +24079,7 @@ func (u HostFunctionArgs) MustInvokeContract() ScVec { // GetInvokeContract retrieves the InvokeContract value from the union, // returning ok if the union's switch indicated the value is valid. -func (u HostFunctionArgs) GetInvokeContract() (result ScVec, ok bool) { +func (u HostFunction) GetInvokeContract() (result ScVec, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) if armName == "InvokeContract" { @@ -24891,7 +24092,7 @@ func (u HostFunctionArgs) GetInvokeContract() (result ScVec, ok bool) { // MustCreateContract retrieves the CreateContract value from the union, // panicing if the value is not set. -func (u HostFunctionArgs) MustCreateContract() CreateContractArgs { +func (u HostFunction) MustCreateContract() CreateContractArgs { val, ok := u.GetCreateContract() if !ok { @@ -24903,7 +24104,7 @@ func (u HostFunctionArgs) MustCreateContract() CreateContractArgs { // GetCreateContract retrieves the CreateContract value from the union, // returning ok if the union's switch indicated the value is valid. -func (u HostFunctionArgs) GetCreateContract() (result CreateContractArgs, ok bool) { +func (u HostFunction) GetCreateContract() (result CreateContractArgs, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) if armName == "CreateContract" { @@ -24914,25 +24115,25 @@ func (u HostFunctionArgs) GetCreateContract() (result CreateContractArgs, ok boo return } -// MustUploadContractWasm retrieves the UploadContractWasm value from the union, +// MustWasm retrieves the Wasm value from the union, // panicing if the value is not set. -func (u HostFunctionArgs) MustUploadContractWasm() UploadContractWasmArgs { - val, ok := u.GetUploadContractWasm() +func (u HostFunction) MustWasm() []byte { + val, ok := u.GetWasm() if !ok { - panic("arm UploadContractWasm is not set") + panic("arm Wasm is not set") } return val } -// GetUploadContractWasm retrieves the UploadContractWasm value from the union, +// GetWasm retrieves the Wasm value from the union, // returning ok if the union's switch indicated the value is valid. -func (u HostFunctionArgs) GetUploadContractWasm() (result UploadContractWasmArgs, ok bool) { +func (u HostFunction) GetWasm() (result []byte, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "UploadContractWasm" { - result = *u.UploadContractWasm + if armName == "Wasm" { + result = *u.Wasm ok = true } @@ -24940,7 +24141,7 @@ func (u HostFunctionArgs) GetUploadContractWasm() (result UploadContractWasmArgs } // EncodeTo encodes this value using the Encoder. -func (u HostFunctionArgs) EncodeTo(e *xdr.Encoder) error { +func (u HostFunction) EncodeTo(e *xdr.Encoder) error { var err error if err = u.Type.EncodeTo(e); err != nil { return err @@ -24957,18 +24158,18 @@ func (u HostFunctionArgs) EncodeTo(e *xdr.Encoder) error { } return nil case HostFunctionTypeHostFunctionTypeUploadContractWasm: - if err = (*u.UploadContractWasm).EncodeTo(e); err != nil { + if _, err = e.EncodeOpaque((*u.Wasm)[:]); err != nil { return err } return nil } - return fmt.Errorf("Type (HostFunctionType) switch value '%d' is not valid for union HostFunctionArgs", u.Type) + return fmt.Errorf("Type (HostFunctionType) switch value '%d' is not valid for union HostFunction", u.Type) } -var _ decoderFrom = (*HostFunctionArgs)(nil) +var _ decoderFrom = (*HostFunction)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *HostFunctionArgs) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *HostFunction) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int nTmp, err = u.Type.DecodeFrom(d) @@ -24994,19 +24195,19 @@ func (u *HostFunctionArgs) DecodeFrom(d *xdr.Decoder) (int, error) { } return n, nil case HostFunctionTypeHostFunctionTypeUploadContractWasm: - u.UploadContractWasm = new(UploadContractWasmArgs) - nTmp, err = (*u.UploadContractWasm).DecodeFrom(d) + u.Wasm = new([]byte) + (*u.Wasm), nTmp, err = d.DecodeOpaque(0) n += nTmp if err != nil { - return n, fmt.Errorf("decoding UploadContractWasmArgs: %s", err) + return n, fmt.Errorf("decoding Wasm: %s", err) } return n, nil } - return n, fmt.Errorf("union HostFunctionArgs has invalid Type (HostFunctionType) switch value '%d'", u.Type) + return n, fmt.Errorf("union HostFunction has invalid Type (HostFunctionType) switch value '%d'", u.Type) } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HostFunctionArgs) MarshalBinary() ([]byte, error) { +func (s HostFunction) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25014,7 +24215,7 @@ func (s HostFunctionArgs) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HostFunctionArgs) UnmarshalBinary(inp []byte) error { +func (s *HostFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -25022,98 +24223,74 @@ func (s *HostFunctionArgs) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HostFunctionArgs)(nil) - _ encoding.BinaryUnmarshaler = (*HostFunctionArgs)(nil) + _ encoding.BinaryMarshaler = (*HostFunction)(nil) + _ encoding.BinaryUnmarshaler = (*HostFunction)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s HostFunctionArgs) xdrType() {} +func (s HostFunction) xdrType() {} -var _ xdrType = (*HostFunctionArgs)(nil) +var _ xdrType = (*HostFunction)(nil) -// AuthorizedInvocation is an XDR Struct defines as: +// SorobanAuthorizedFunctionType is an XDR Enum defines as: // -// struct AuthorizedInvocation +// enum SorobanAuthorizedFunctionType // { -// Hash contractID; -// SCSymbol functionName; -// SCVec args; -// AuthorizedInvocation subInvocations<>; +// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0, +// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1 // }; -type AuthorizedInvocation struct { - ContractId Hash - FunctionName ScSymbol - Args ScVec - SubInvocations []AuthorizedInvocation +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 } // EncodeTo encodes this value using the Encoder. -func (s *AuthorizedInvocation) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.ContractId.EncodeTo(e); err != nil { - return err - } - if err = s.FunctionName.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) } - if err = s.Args.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 - } - } - return nil + _, err := enc.EncodeInt(int32(e)) + return err } -var _ decoderFrom = (*AuthorizedInvocation)(nil) +var _ decoderFrom = (*SorobanAuthorizedFunctionType)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AuthorizedInvocation) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.ContractId.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - nTmp, err = s.FunctionName.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScSymbol: %s", err) - } - nTmp, err = s.Args.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScVec: %s", err) - } - var l uint32 - l, nTmp, err = d.DecodeUint() - n += nTmp +func (e *SorobanAuthorizedFunctionType) DecodeFrom(d *xdr.Decoder) (int, error) { + v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding AuthorizedInvocation: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %s", err) } - s.SubInvocations = nil - if l > 0 { - s.SubInvocations = make([]AuthorizedInvocation, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.SubInvocations[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AuthorizedInvocation: %s", 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 AuthorizedInvocation) MarshalBinary() ([]byte, error) { +func (s SorobanAuthorizedFunctionType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25121,7 +24298,7 @@ func (s AuthorizedInvocation) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *AuthorizedInvocation) UnmarshalBinary(inp []byte) error { +func (s *SorobanAuthorizedFunctionType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -25129,61 +24306,71 @@ func (s *AuthorizedInvocation) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*AuthorizedInvocation)(nil) - _ encoding.BinaryUnmarshaler = (*AuthorizedInvocation)(nil) + _ encoding.BinaryMarshaler = (*SorobanAuthorizedFunctionType)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunctionType)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s AuthorizedInvocation) xdrType() {} +func (s SorobanAuthorizedFunctionType) xdrType() {} -var _ xdrType = (*AuthorizedInvocation)(nil) +var _ xdrType = (*SorobanAuthorizedFunctionType)(nil) -// AddressWithNonce is an XDR Struct defines as: +// SorobanAuthorizedContractFunction is an XDR Struct defines as: // -// struct AddressWithNonce +// struct SorobanAuthorizedContractFunction // { -// SCAddress address; -// uint64 nonce; +// SCAddress contractAddress; +// SCSymbol functionName; +// SCVec args; // }; -type AddressWithNonce struct { - Address ScAddress - Nonce Uint64 +type SorobanAuthorizedContractFunction struct { + ContractAddress ScAddress + FunctionName ScSymbol + Args ScVec } // EncodeTo encodes this value using the Encoder. -func (s *AddressWithNonce) EncodeTo(e *xdr.Encoder) error { +func (s *SorobanAuthorizedContractFunction) EncodeTo(e *xdr.Encoder) error { var err error - if err = s.Address.EncodeTo(e); err != nil { + if err = s.ContractAddress.EncodeTo(e); err != nil { return err } - if err = s.Nonce.EncodeTo(e); err != nil { + if err = s.FunctionName.EncodeTo(e); err != nil { + return err + } + if err = s.Args.EncodeTo(e); err != nil { return err } return nil } -var _ decoderFrom = (*AddressWithNonce)(nil) +var _ decoderFrom = (*SorobanAuthorizedContractFunction)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *AddressWithNonce) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanAuthorizedContractFunction) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - nTmp, err = s.Address.DecodeFrom(d) + nTmp, err = s.ContractAddress.DecodeFrom(d) n += nTmp if err != nil { return n, fmt.Errorf("decoding ScAddress: %s", err) } - nTmp, err = s.Nonce.DecodeFrom(d) + nTmp, err = s.FunctionName.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Uint64: %s", err) + return n, fmt.Errorf("decoding ScSymbol: %s", err) + } + nTmp, err = s.Args.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScVec: %s", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s AddressWithNonce) MarshalBinary() ([]byte, error) { +func (s SorobanAuthorizedContractFunction) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25191,7 +24378,7 @@ func (s AddressWithNonce) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *AddressWithNonce) UnmarshalBinary(inp []byte) error { +func (s *SorobanAuthorizedContractFunction) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -25199,75 +24386,332 @@ func (s *AddressWithNonce) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*AddressWithNonce)(nil) - _ encoding.BinaryUnmarshaler = (*AddressWithNonce)(nil) + _ encoding.BinaryMarshaler = (*SorobanAuthorizedContractFunction)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedContractFunction)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s AddressWithNonce) xdrType() {} +func (s SorobanAuthorizedContractFunction) xdrType() {} -var _ xdrType = (*AddressWithNonce)(nil) +var _ xdrType = (*SorobanAuthorizedContractFunction)(nil) -// ContractAuth is an XDR Struct defines as: +// SorobanAuthorizedFunction is an XDR Union defines as: // -// struct ContractAuth +// union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type) // { -// AddressWithNonce* addressWithNonce; // not present for invoker -// AuthorizedInvocation rootInvocation; -// SCVec signatureArgs; +// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN: +// SorobanAuthorizedContractFunction contractFn; +// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN: +// CreateContractArgs createContractHostFn; // }; -type ContractAuth struct { - AddressWithNonce *AddressWithNonce - RootInvocation AuthorizedInvocation - SignatureArgs ScVec +type SorobanAuthorizedFunction struct { + Type SorobanAuthorizedFunctionType + ContractFn *SorobanAuthorizedContractFunction + CreateContractHostFn *CreateContractArgs +} + +// 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 + } + 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.(SorobanAuthorizedContractFunction) + if !ok { + err = fmt.Errorf("invalid value, must be SorobanAuthorizedContractFunction") + return + } + result.ContractFn = &tv + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: + tv, ok := value.(CreateContractArgs) + if !ok { + err = fmt.Errorf("invalid value, must be CreateContractArgs") + return + } + result.CreateContractHostFn = &tv + } + return +} + +// MustContractFn retrieves the ContractFn value from the union, +// panicing if the value is not set. +func (u SorobanAuthorizedFunction) MustContractFn() SorobanAuthorizedContractFunction { + val, ok := u.GetContractFn() + + if !ok { + panic("arm ContractFn is not set") + } + + 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 SorobanAuthorizedContractFunction, 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 } // EncodeTo encodes this value using the Encoder. -func (s *ContractAuth) EncodeTo(e *xdr.Encoder) error { +func (u SorobanAuthorizedFunction) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeBool(s.AddressWithNonce != nil); err != nil { + if err = u.Type.EncodeTo(e); err != nil { return err } - if s.AddressWithNonce != nil { - if err = (*s.AddressWithNonce).EncodeTo(e); err != 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 } - if err = s.RootInvocation.EncodeTo(e); err != nil { + return fmt.Errorf("Type (SorobanAuthorizedFunctionType) switch value '%d' is not valid for union SorobanAuthorizedFunction", u.Type) +} + +var _ decoderFrom = (*SorobanAuthorizedFunction)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (u *SorobanAuthorizedFunction) DecodeFrom(d *xdr.Decoder) (int, error) { + var err error + var n, nTmp int + nTmp, err = u.Type.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedFunctionType: %s", err) + } + switch SorobanAuthorizedFunctionType(u.Type) { + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeContractFn: + u.ContractFn = new(SorobanAuthorizedContractFunction) + nTmp, err = (*u.ContractFn).DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedContractFunction: %s", err) + } + return n, nil + case SorobanAuthorizedFunctionTypeSorobanAuthorizedFunctionTypeCreateContractHostFn: + u.CreateContractHostFn = new(CreateContractArgs) + nTmp, err = (*u.CreateContractHostFn).DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding CreateContractArgs: %s", err) + } + return n, nil + } + 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 +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SorobanAuthorizedFunction) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + d := xdr.NewDecoder(r) + _, err := s.DecodeFrom(d) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SorobanAuthorizedFunction)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedFunction)(nil) +) + +// xdrType signals that this type is an type representing +// representing XDR values defined by this package. +func (s SorobanAuthorizedFunction) xdrType() {} + +var _ xdrType = (*SorobanAuthorizedFunction)(nil) + +// SorobanAuthorizedInvocation is an XDR Struct defines as: +// +// struct SorobanAuthorizedInvocation +// { +// SorobanAuthorizedFunction function; +// SorobanAuthorizedInvocation subInvocations<>; +// }; +type SorobanAuthorizedInvocation struct { + Function SorobanAuthorizedFunction + SubInvocations []SorobanAuthorizedInvocation +} + +// 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 = s.SignatureArgs.EncodeTo(e); err != nil { + 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 = (*ContractAuth)(nil) +var _ decoderFrom = (*SorobanAuthorizedInvocation)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *ContractAuth) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *SorobanAuthorizedInvocation) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - var b bool - b, nTmp, err = d.DecodeBool() + nTmp, err = s.Function.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AddressWithNonce: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedFunction: %s", err) } - s.AddressWithNonce = nil - if b { - s.AddressWithNonce = new(AddressWithNonce) - nTmp, err = s.AddressWithNonce.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AddressWithNonce: %s", err) + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) + } + s.SubInvocations = nil + if l > 0 { + s.SubInvocations = make([]SorobanAuthorizedInvocation, l) + for i := uint32(0); i < l; i++ { + nTmp, err = s.SubInvocations[i].DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) + } } } - nTmp, err = s.RootInvocation.DecodeFrom(d) + 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 +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SorobanAuthorizedInvocation) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + d := xdr.NewDecoder(r) + _, err := s.DecodeFrom(d) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SorobanAuthorizedInvocation)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizedInvocation)(nil) +) + +// xdrType signals that this type is an type representing +// representing XDR values defined by this package. +func (s SorobanAuthorizedInvocation) xdrType() {} + +var _ xdrType = (*SorobanAuthorizedInvocation)(nil) + +// SorobanAddressCredentials is an XDR Struct defines as: +// +// struct SorobanAddressCredentials +// { +// SCAddress address; +// uint64 nonce; +// SCVec signatureArgs; +// }; +type SorobanAddressCredentials struct { + Address ScAddress + Nonce Uint64 + SignatureArgs ScVec +} + +// 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.SignatureArgs.EncodeTo(e); err != nil { + return err + } + return nil +} + +var _ decoderFrom = (*SorobanAddressCredentials)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *SorobanAddressCredentials) DecodeFrom(d *xdr.Decoder) (int, error) { + var err error + var n, nTmp int + nTmp, err = s.Address.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScAddress: %s", err) + } + nTmp, err = s.Nonce.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AuthorizedInvocation: %s", err) + return n, fmt.Errorf("decoding Uint64: %s", err) } nTmp, err = s.SignatureArgs.DecodeFrom(d) n += nTmp @@ -25278,7 +24722,7 @@ func (s *ContractAuth) DecodeFrom(d *xdr.Decoder) (int, error) { } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ContractAuth) MarshalBinary() ([]byte, error) { +func (s SorobanAddressCredentials) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25286,7 +24730,7 @@ func (s ContractAuth) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ContractAuth) UnmarshalBinary(inp []byte) error { +func (s *SorobanAddressCredentials) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -25294,81 +24738,291 @@ func (s *ContractAuth) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ContractAuth)(nil) - _ encoding.BinaryUnmarshaler = (*ContractAuth)(nil) + _ encoding.BinaryMarshaler = (*SorobanAddressCredentials)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAddressCredentials)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ContractAuth) xdrType() {} +func (s SorobanAddressCredentials) xdrType() {} -var _ xdrType = (*ContractAuth)(nil) +var _ xdrType = (*SorobanAddressCredentials)(nil) -// HostFunction is an XDR Struct defines as: +// SorobanCredentialsType is an XDR Enum defines as: // -// struct HostFunction { -// // Arguments of the function to call defined by the function -// // type. -// HostFunctionArgs args; -// // Per-address authorizations for this host fn -// // Currently only supported for INVOKE_CONTRACT function -// ContractAuth auth<>; +// enum SorobanCredentialsType +// { +// SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0, +// SOROBAN_CREDENTIALS_ADDRESS = 1 // }; -type HostFunction struct { - Args HostFunctionArgs - Auth []ContractAuth +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 *HostFunction) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.Args.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) } - if _, err = e.EncodeUint(uint32(len(s.Auth))); err != nil { + _, err := enc.EncodeInt(int32(e)) + return err +} + +var _ decoderFrom = (*SorobanCredentialsType)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (e *SorobanCredentialsType) DecodeFrom(d *xdr.Decoder) (int, error) { + v, n, err := d.DecodeInt() + if err != nil { + return n, fmt.Errorf("decoding SorobanCredentialsType: %s", 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 SorobanCredentialsType) MarshalBinary() ([]byte, error) { + b := bytes.Buffer{} + e := xdr.NewEncoder(&b) + err := s.EncodeTo(e) + return b.Bytes(), err +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SorobanCredentialsType) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + d := xdr.NewDecoder(r) + _, err := s.DecodeFrom(d) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SorobanCredentialsType)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanCredentialsType)(nil) +) + +// xdrType signals that this type is an type representing +// representing XDR values defined by this package. +func (s SorobanCredentialsType) xdrType() {} + +var _ xdrType = (*SorobanCredentialsType)(nil) + +// 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 +} + +// SwitchFieldName returns the field name in which this union's +// discriminant is stored +func (u SorobanCredentials) SwitchFieldName() string { + return "Type" +} + +// 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 + } + return "-", false +} + +// 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 = fmt.Errorf("invalid value, must be SorobanAddressCredentials") + return + } + result.Address = &tv + } + return +} + +// MustAddress retrieves the Address value from the union, +// panicing if the value is not set. +func (u SorobanCredentials) MustAddress() SorobanAddressCredentials { + val, ok := u.GetAddress() + + if !ok { + panic("arm Address is not set") + } + + return val +} + +// GetAddress retrieves the Address value from the union, +// returning ok if the union's switch indicated the value is valid. +func (u SorobanCredentials) GetAddress() (result SorobanAddressCredentials, ok bool) { + armName, _ := u.ArmForSwitch(int32(u.Type)) + + if armName == "Address" { + result = *u.Address + 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 } - for i := 0; i < len(s.Auth); i++ { - if err = s.Auth[i].EncodeTo(e); err != nil { + switch SorobanCredentialsType(u.Type) { + case SorobanCredentialsTypeSorobanCredentialsSourceAccount: + // Void + return nil + case SorobanCredentialsTypeSorobanCredentialsAddress: + if err = (*u.Address).EncodeTo(e); err != nil { return err } + return nil } - return nil + return fmt.Errorf("Type (SorobanCredentialsType) switch value '%d' is not valid for union SorobanCredentials", u.Type) } -var _ decoderFrom = (*HostFunction)(nil) +var _ decoderFrom = (*SorobanCredentials)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HostFunction) DecodeFrom(d *xdr.Decoder) (int, error) { +func (u *SorobanCredentials) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - nTmp, err = s.Args.DecodeFrom(d) + nTmp, err = u.Type.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HostFunctionArgs: %s", err) + return n, fmt.Errorf("decoding SorobanCredentialsType: %s", err) } - var l uint32 - l, nTmp, err = d.DecodeUint() + switch SorobanCredentialsType(u.Type) { + case SorobanCredentialsTypeSorobanCredentialsSourceAccount: + // Void + return n, nil + case SorobanCredentialsTypeSorobanCredentialsAddress: + u.Address = new(SorobanAddressCredentials) + nTmp, err = (*u.Address).DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAddressCredentials: %s", err) + } + return n, nil + } + 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 +} + +// UnmarshalBinary implements encoding.BinaryUnmarshaler. +func (s *SorobanCredentials) UnmarshalBinary(inp []byte) error { + r := bytes.NewReader(inp) + d := xdr.NewDecoder(r) + _, err := s.DecodeFrom(d) + return err +} + +var ( + _ encoding.BinaryMarshaler = (*SorobanCredentials)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanCredentials)(nil) +) + +// xdrType signals that this type is an type representing +// representing XDR values defined by this package. +func (s SorobanCredentials) xdrType() {} + +var _ xdrType = (*SorobanCredentials)(nil) + +// SorobanAuthorizationEntry is an XDR Struct defines as: +// +// struct SorobanAuthorizationEntry +// { +// SorobanCredentials credentials; +// SorobanAuthorizedInvocation rootInvocation; +// }; +type SorobanAuthorizationEntry struct { + Credentials SorobanCredentials + RootInvocation SorobanAuthorizedInvocation +} + +// 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 + } + return nil +} + +var _ decoderFrom = (*SorobanAuthorizationEntry)(nil) + +// DecodeFrom decodes this value using the Decoder. +func (s *SorobanAuthorizationEntry) DecodeFrom(d *xdr.Decoder) (int, error) { + var err error + var n, nTmp int + nTmp, err = s.Credentials.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ContractAuth: %s", err) + return n, fmt.Errorf("decoding SorobanCredentials: %s", err) } - s.Auth = nil - if l > 0 { - s.Auth = make([]ContractAuth, l) - for i := uint32(0); i < l; i++ { - nTmp, err = s.Auth[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ContractAuth: %s", err) - } - } + nTmp, err = s.RootInvocation.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HostFunction) MarshalBinary() ([]byte, error) { +func (s SorobanAuthorizationEntry) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -25376,7 +25030,7 @@ func (s HostFunction) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HostFunction) UnmarshalBinary(inp []byte) error { +func (s *SorobanAuthorizationEntry) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -25384,38 +25038,41 @@ func (s *HostFunction) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HostFunction)(nil) - _ encoding.BinaryUnmarshaler = (*HostFunction)(nil) + _ encoding.BinaryMarshaler = (*SorobanAuthorizationEntry)(nil) + _ encoding.BinaryUnmarshaler = (*SorobanAuthorizationEntry)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s HostFunction) xdrType() {} +func (s SorobanAuthorizationEntry) xdrType() {} -var _ xdrType = (*HostFunction)(nil) +var _ xdrType = (*SorobanAuthorizationEntry)(nil) // InvokeHostFunctionOp is an XDR Struct defines as: // // struct InvokeHostFunctionOp // { -// // The host functions to invoke. The functions will be executed -// // in the same fashion as operations: either all functions will -// // be successfully applied or all fail if at least one of them -// // fails. -// HostFunction functions; +// // Host function to invoke. +// HostFunction hostFunction; +// // Per-address authorizations for this host function. +// SorobanAuthorizationEntry auth<>; // }; type InvokeHostFunctionOp struct { - Functions []HostFunction `xdrmaxsize:"100"` + HostFunction HostFunction + Auth []SorobanAuthorizationEntry } // EncodeTo encodes this value using the Encoder. func (s *InvokeHostFunctionOp) EncodeTo(e *xdr.Encoder) error { var err error - if _, err = e.EncodeUint(uint32(len(s.Functions))); err != nil { + 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.Functions); i++ { - if err = s.Functions[i].EncodeTo(e); err != nil { + for i := 0; i < len(s.Auth); i++ { + if err = s.Auth[i].EncodeTo(e); err != nil { return err } } @@ -25428,23 +25085,25 @@ var _ decoderFrom = (*InvokeHostFunctionOp)(nil) func (s *InvokeHostFunctionOp) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - var l uint32 - l, nTmp, err = d.DecodeUint() + nTmp, err = s.HostFunction.DecodeFrom(d) n += nTmp if err != nil { return n, fmt.Errorf("decoding HostFunction: %s", err) } - if l > 100 { - return n, fmt.Errorf("decoding HostFunction: data size (%d) exceeds size limit (100)", l) + var l uint32 + l, nTmp, err = d.DecodeUint() + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %s", err) } - s.Functions = nil + s.Auth = nil if l > 0 { - s.Functions = make([]HostFunction, l) + s.Auth = make([]SorobanAuthorizationEntry, l) for i := uint32(0); i < l; i++ { - nTmp, err = s.Functions[i].DecodeFrom(d) + nTmp, err = s.Auth[i].DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HostFunction: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizationEntry: %s", err) } } } @@ -27059,98 +26718,16 @@ func (s HashIdPreimageRevokeId) xdrType() {} var _ xdrType = (*HashIdPreimageRevokeId)(nil) -// HashIdPreimageEd25519ContractId is an XDR NestedStruct defines as: -// -// struct -// { -// Hash networkID; -// uint256 ed25519; -// uint256 salt; -// } -type HashIdPreimageEd25519ContractId struct { - NetworkId Hash - Ed25519 Uint256 - Salt Uint256 -} - -// EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageEd25519ContractId) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.NetworkId.EncodeTo(e); err != nil { - return err - } - if err = s.Ed25519.EncodeTo(e); err != nil { - return err - } - if err = s.Salt.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*HashIdPreimageEd25519ContractId)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageEd25519ContractId) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - nTmp, err = s.Ed25519.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) - } - nTmp, err = s.Salt.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageEd25519ContractId) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageEd25519ContractId) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageEd25519ContractId)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageEd25519ContractId)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s HashIdPreimageEd25519ContractId) xdrType() {} - -var _ xdrType = (*HashIdPreimageEd25519ContractId)(nil) - // HashIdPreimageContractId is an XDR NestedStruct defines as: // // struct // { // Hash networkID; -// Hash contractID; -// uint256 salt; +// ContractIDPreimage contractIDPreimage; // } type HashIdPreimageContractId struct { - NetworkId Hash - ContractId Hash - Salt Uint256 + NetworkId Hash + ContractIdPreimage ContractIdPreimage } // EncodeTo encodes this value using the Encoder. @@ -27159,10 +26736,7 @@ func (s *HashIdPreimageContractId) EncodeTo(e *xdr.Encoder) error { if err = s.NetworkId.EncodeTo(e); err != nil { return err } - if err = s.ContractId.EncodeTo(e); err != nil { - return err - } - if err = s.Salt.EncodeTo(e); err != nil { + if err = s.ContractIdPreimage.EncodeTo(e); err != nil { return err } return nil @@ -27179,15 +26753,10 @@ func (s *HashIdPreimageContractId) DecodeFrom(d *xdr.Decoder) (int, error) { if err != nil { return n, fmt.Errorf("decoding Hash: %s", err) } - nTmp, err = s.ContractId.DecodeFrom(d) + nTmp, err = s.ContractIdPreimage.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - nTmp, err = s.Salt.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) + return n, fmt.Errorf("decoding ContractIdPreimage: %s", err) } return n, nil } @@ -27219,252 +26788,22 @@ func (s HashIdPreimageContractId) xdrType() {} var _ xdrType = (*HashIdPreimageContractId)(nil) -// HashIdPreimageFromAsset is an XDR NestedStruct defines as: -// -// struct -// { -// Hash networkID; -// Asset asset; -// } -type HashIdPreimageFromAsset struct { - NetworkId Hash - Asset Asset -} - -// EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageFromAsset) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.NetworkId.EncodeTo(e); err != nil { - return err - } - if err = s.Asset.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*HashIdPreimageFromAsset)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageFromAsset) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - nTmp, err = s.Asset.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Asset: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageFromAsset) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageFromAsset) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageFromAsset)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageFromAsset)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s HashIdPreimageFromAsset) xdrType() {} - -var _ xdrType = (*HashIdPreimageFromAsset)(nil) - -// HashIdPreimageSourceAccountContractId is an XDR NestedStruct defines as: -// -// struct -// { -// Hash networkID; -// AccountID sourceAccount; -// uint256 salt; -// } -type HashIdPreimageSourceAccountContractId struct { - NetworkId Hash - SourceAccount AccountId - Salt Uint256 -} - -// EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageSourceAccountContractId) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.NetworkId.EncodeTo(e); err != nil { - return err - } - if err = s.SourceAccount.EncodeTo(e); err != nil { - return err - } - if err = s.Salt.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*HashIdPreimageSourceAccountContractId)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageSourceAccountContractId) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - nTmp, err = s.SourceAccount.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding AccountId: %s", err) - } - nTmp, err = s.Salt.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageSourceAccountContractId) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageSourceAccountContractId) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageSourceAccountContractId)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageSourceAccountContractId)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s HashIdPreimageSourceAccountContractId) xdrType() {} - -var _ xdrType = (*HashIdPreimageSourceAccountContractId)(nil) - -// HashIdPreimageCreateContractArgs is an XDR NestedStruct defines as: -// -// struct -// { -// Hash networkID; -// SCContractExecutable executable; -// uint256 salt; -// } -type HashIdPreimageCreateContractArgs struct { - NetworkId Hash - Executable ScContractExecutable - Salt Uint256 -} - -// EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageCreateContractArgs) EncodeTo(e *xdr.Encoder) error { - var err error - if err = s.NetworkId.EncodeTo(e); err != nil { - return err - } - if err = s.Executable.EncodeTo(e); err != nil { - return err - } - if err = s.Salt.EncodeTo(e); err != nil { - return err - } - return nil -} - -var _ decoderFrom = (*HashIdPreimageCreateContractArgs)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageCreateContractArgs) DecodeFrom(d *xdr.Decoder) (int, error) { - var err error - var n, nTmp int - nTmp, err = s.NetworkId.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Hash: %s", err) - } - nTmp, err = s.Executable.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScContractExecutable: %s", err) - } - nTmp, err = s.Salt.DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint256: %s", err) - } - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageCreateContractArgs) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageCreateContractArgs) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageCreateContractArgs)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageCreateContractArgs)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s HashIdPreimageCreateContractArgs) xdrType() {} - -var _ xdrType = (*HashIdPreimageCreateContractArgs)(nil) - -// HashIdPreimageContractAuth is an XDR NestedStruct defines as: +// HashIdPreimageSorobanAuthorization is an XDR NestedStruct defines as: // // struct // { // Hash networkID; // uint64 nonce; -// AuthorizedInvocation invocation; +// SorobanAuthorizedInvocation invocation; // } -type HashIdPreimageContractAuth struct { +type HashIdPreimageSorobanAuthorization struct { NetworkId Hash Nonce Uint64 - Invocation AuthorizedInvocation + Invocation SorobanAuthorizedInvocation } // EncodeTo encodes this value using the Encoder. -func (s *HashIdPreimageContractAuth) EncodeTo(e *xdr.Encoder) error { +func (s *HashIdPreimageSorobanAuthorization) EncodeTo(e *xdr.Encoder) error { var err error if err = s.NetworkId.EncodeTo(e); err != nil { return err @@ -27478,10 +26817,10 @@ func (s *HashIdPreimageContractAuth) EncodeTo(e *xdr.Encoder) error { return nil } -var _ decoderFrom = (*HashIdPreimageContractAuth)(nil) +var _ decoderFrom = (*HashIdPreimageSorobanAuthorization)(nil) // DecodeFrom decodes this value using the Decoder. -func (s *HashIdPreimageContractAuth) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *HashIdPreimageSorobanAuthorization) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int nTmp, err = s.NetworkId.DecodeFrom(d) @@ -27497,13 +26836,13 @@ func (s *HashIdPreimageContractAuth) DecodeFrom(d *xdr.Decoder) (int, error) { nTmp, err = s.Invocation.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding AuthorizedInvocation: %s", err) + return n, fmt.Errorf("decoding SorobanAuthorizedInvocation: %s", err) } return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s HashIdPreimageContractAuth) MarshalBinary() ([]byte, error) { +func (s HashIdPreimageSorobanAuthorization) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -27511,7 +26850,7 @@ func (s HashIdPreimageContractAuth) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *HashIdPreimageContractAuth) UnmarshalBinary(inp []byte) error { +func (s *HashIdPreimageSorobanAuthorization) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -27519,15 +26858,15 @@ func (s *HashIdPreimageContractAuth) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*HashIdPreimageContractAuth)(nil) - _ encoding.BinaryUnmarshaler = (*HashIdPreimageContractAuth)(nil) + _ encoding.BinaryMarshaler = (*HashIdPreimageSorobanAuthorization)(nil) + _ encoding.BinaryUnmarshaler = (*HashIdPreimageSorobanAuthorization)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s HashIdPreimageContractAuth) xdrType() {} +func (s HashIdPreimageSorobanAuthorization) xdrType() {} -var _ xdrType = (*HashIdPreimageContractAuth)(nil) +var _ xdrType = (*HashIdPreimageSorobanAuthorization)(nil) // HashIdPreimage is an XDR Union defines as: // @@ -27549,58 +26888,26 @@ var _ xdrType = (*HashIdPreimageContractAuth)(nil) // PoolID liquidityPoolID; // Asset asset; // } revokeID; -// case ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519: -// struct -// { -// Hash networkID; -// uint256 ed25519; -// uint256 salt; -// } ed25519ContractID; -// case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: +// case ENVELOPE_TYPE_CONTRACT_ID: // struct // { // Hash networkID; -// Hash contractID; -// uint256 salt; +// ContractIDPreimage contractIDPreimage; // } contractID; -// case ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: -// struct -// { -// Hash networkID; -// Asset asset; -// } fromAsset; -// case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: -// struct -// { -// Hash networkID; -// AccountID sourceAccount; -// uint256 salt; -// } sourceAccountContractID; -// case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: -// struct -// { -// Hash networkID; -// SCContractExecutable executable; -// uint256 salt; -// } createContractArgs; -// case ENVELOPE_TYPE_CONTRACT_AUTH: +// case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION: // struct // { // Hash networkID; // uint64 nonce; -// AuthorizedInvocation invocation; -// } contractAuth; +// SorobanAuthorizedInvocation invocation; +// } sorobanAuthorization; // }; type HashIdPreimage struct { - Type EnvelopeType - OperationId *HashIdPreimageOperationId - RevokeId *HashIdPreimageRevokeId - Ed25519ContractId *HashIdPreimageEd25519ContractId - ContractId *HashIdPreimageContractId - FromAsset *HashIdPreimageFromAsset - SourceAccountContractId *HashIdPreimageSourceAccountContractId - CreateContractArgs *HashIdPreimageCreateContractArgs - ContractAuth *HashIdPreimageContractAuth + Type EnvelopeType + OperationId *HashIdPreimageOperationId + RevokeId *HashIdPreimageRevokeId + ContractId *HashIdPreimageContractId + SorobanAuthorization *HashIdPreimageSorobanAuthorization } // SwitchFieldName returns the field name in which this union's @@ -27617,18 +26924,10 @@ func (u HashIdPreimage) ArmForSwitch(sw int32) (string, bool) { return "OperationId", true case EnvelopeTypeEnvelopeTypePoolRevokeOpId: return "RevokeId", true - case EnvelopeTypeEnvelopeTypeContractIdFromEd25519: - return "Ed25519ContractId", true - case EnvelopeTypeEnvelopeTypeContractIdFromContract: + case EnvelopeTypeEnvelopeTypeContractId: return "ContractId", true - case EnvelopeTypeEnvelopeTypeContractIdFromAsset: - return "FromAsset", true - case EnvelopeTypeEnvelopeTypeContractIdFromSourceAccount: - return "SourceAccountContractId", true - case EnvelopeTypeEnvelopeTypeCreateContractArgs: - return "CreateContractArgs", true - case EnvelopeTypeEnvelopeTypeContractAuth: - return "ContractAuth", true + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + return "SorobanAuthorization", true } return "-", false } @@ -27651,48 +26950,20 @@ func NewHashIdPreimage(aType EnvelopeType, value interface{}) (result HashIdPrei return } result.RevokeId = &tv - case EnvelopeTypeEnvelopeTypeContractIdFromEd25519: - tv, ok := value.(HashIdPreimageEd25519ContractId) - if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageEd25519ContractId") - return - } - result.Ed25519ContractId = &tv - case EnvelopeTypeEnvelopeTypeContractIdFromContract: + case EnvelopeTypeEnvelopeTypeContractId: tv, ok := value.(HashIdPreimageContractId) if !ok { err = fmt.Errorf("invalid value, must be HashIdPreimageContractId") return } result.ContractId = &tv - case EnvelopeTypeEnvelopeTypeContractIdFromAsset: - tv, ok := value.(HashIdPreimageFromAsset) + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + tv, ok := value.(HashIdPreimageSorobanAuthorization) if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageFromAsset") + err = fmt.Errorf("invalid value, must be HashIdPreimageSorobanAuthorization") return } - result.FromAsset = &tv - case EnvelopeTypeEnvelopeTypeContractIdFromSourceAccount: - tv, ok := value.(HashIdPreimageSourceAccountContractId) - if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageSourceAccountContractId") - return - } - result.SourceAccountContractId = &tv - case EnvelopeTypeEnvelopeTypeCreateContractArgs: - tv, ok := value.(HashIdPreimageCreateContractArgs) - if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageCreateContractArgs") - return - } - result.CreateContractArgs = &tv - case EnvelopeTypeEnvelopeTypeContractAuth: - tv, ok := value.(HashIdPreimageContractAuth) - if !ok { - err = fmt.Errorf("invalid value, must be HashIdPreimageContractAuth") - return - } - result.ContractAuth = &tv + result.SorobanAuthorization = &tv } return } @@ -27747,31 +27018,6 @@ func (u HashIdPreimage) GetRevokeId() (result HashIdPreimageRevokeId, ok bool) { return } -// MustEd25519ContractId retrieves the Ed25519ContractId value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustEd25519ContractId() HashIdPreimageEd25519ContractId { - val, ok := u.GetEd25519ContractId() - - if !ok { - panic("arm Ed25519ContractId is not set") - } - - return val -} - -// GetEd25519ContractId retrieves the Ed25519ContractId value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetEd25519ContractId() (result HashIdPreimageEd25519ContractId, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "Ed25519ContractId" { - result = *u.Ed25519ContractId - ok = true - } - - return -} - // MustContractId retrieves the ContractId value from the union, // panicing if the value is not set. func (u HashIdPreimage) MustContractId() HashIdPreimageContractId { @@ -27797,100 +27043,25 @@ func (u HashIdPreimage) GetContractId() (result HashIdPreimageContractId, ok boo return } -// MustFromAsset retrieves the FromAsset value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustFromAsset() HashIdPreimageFromAsset { - val, ok := u.GetFromAsset() - - if !ok { - panic("arm FromAsset is not set") - } - - return val -} - -// GetFromAsset retrieves the FromAsset value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetFromAsset() (result HashIdPreimageFromAsset, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "FromAsset" { - result = *u.FromAsset - ok = true - } - - return -} - -// MustSourceAccountContractId retrieves the SourceAccountContractId value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustSourceAccountContractId() HashIdPreimageSourceAccountContractId { - val, ok := u.GetSourceAccountContractId() - - if !ok { - panic("arm SourceAccountContractId is not set") - } - - return val -} - -// GetSourceAccountContractId retrieves the SourceAccountContractId value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetSourceAccountContractId() (result HashIdPreimageSourceAccountContractId, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "SourceAccountContractId" { - result = *u.SourceAccountContractId - ok = true - } - - return -} - -// MustCreateContractArgs retrieves the CreateContractArgs value from the union, -// panicing if the value is not set. -func (u HashIdPreimage) MustCreateContractArgs() HashIdPreimageCreateContractArgs { - val, ok := u.GetCreateContractArgs() - - if !ok { - panic("arm CreateContractArgs is not set") - } - - return val -} - -// GetCreateContractArgs retrieves the CreateContractArgs value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u HashIdPreimage) GetCreateContractArgs() (result HashIdPreimageCreateContractArgs, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "CreateContractArgs" { - result = *u.CreateContractArgs - ok = true - } - - return -} - -// MustContractAuth retrieves the ContractAuth value from the union, +// MustSorobanAuthorization retrieves the SorobanAuthorization value from the union, // panicing if the value is not set. -func (u HashIdPreimage) MustContractAuth() HashIdPreimageContractAuth { - val, ok := u.GetContractAuth() +func (u HashIdPreimage) MustSorobanAuthorization() HashIdPreimageSorobanAuthorization { + val, ok := u.GetSorobanAuthorization() if !ok { - panic("arm ContractAuth is not set") + panic("arm SorobanAuthorization is not set") } return val } -// GetContractAuth retrieves the ContractAuth 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 HashIdPreimage) GetContractAuth() (result HashIdPreimageContractAuth, ok bool) { +func (u HashIdPreimage) GetSorobanAuthorization() (result HashIdPreimageSorobanAuthorization, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) - if armName == "ContractAuth" { - result = *u.ContractAuth + if armName == "SorobanAuthorization" { + result = *u.SorobanAuthorization ok = true } @@ -27914,33 +27085,13 @@ func (u HashIdPreimage) EncodeTo(e *xdr.Encoder) error { return err } return nil - case EnvelopeTypeEnvelopeTypeContractIdFromEd25519: - if err = (*u.Ed25519ContractId).EncodeTo(e); err != nil { - return err - } - return nil - case EnvelopeTypeEnvelopeTypeContractIdFromContract: + case EnvelopeTypeEnvelopeTypeContractId: if err = (*u.ContractId).EncodeTo(e); err != nil { return err } return nil - case EnvelopeTypeEnvelopeTypeContractIdFromAsset: - if err = (*u.FromAsset).EncodeTo(e); err != nil { - return err - } - return nil - case EnvelopeTypeEnvelopeTypeContractIdFromSourceAccount: - if err = (*u.SourceAccountContractId).EncodeTo(e); err != nil { - return err - } - return nil - case EnvelopeTypeEnvelopeTypeCreateContractArgs: - if err = (*u.CreateContractArgs).EncodeTo(e); err != nil { - return err - } - return nil - case EnvelopeTypeEnvelopeTypeContractAuth: - if err = (*u.ContractAuth).EncodeTo(e); err != nil { + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + if err = (*u.SorobanAuthorization).EncodeTo(e); err != nil { return err } return nil @@ -27976,15 +27127,7 @@ func (u *HashIdPreimage) DecodeFrom(d *xdr.Decoder) (int, error) { return n, fmt.Errorf("decoding HashIdPreimageRevokeId: %s", err) } return n, nil - case EnvelopeTypeEnvelopeTypeContractIdFromEd25519: - u.Ed25519ContractId = new(HashIdPreimageEd25519ContractId) - nTmp, err = (*u.Ed25519ContractId).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageEd25519ContractId: %s", err) - } - return n, nil - case EnvelopeTypeEnvelopeTypeContractIdFromContract: + case EnvelopeTypeEnvelopeTypeContractId: u.ContractId = new(HashIdPreimageContractId) nTmp, err = (*u.ContractId).DecodeFrom(d) n += nTmp @@ -27992,36 +27135,12 @@ func (u *HashIdPreimage) DecodeFrom(d *xdr.Decoder) (int, error) { return n, fmt.Errorf("decoding HashIdPreimageContractId: %s", err) } return n, nil - case EnvelopeTypeEnvelopeTypeContractIdFromAsset: - u.FromAsset = new(HashIdPreimageFromAsset) - nTmp, err = (*u.FromAsset).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageFromAsset: %s", err) - } - return n, nil - case EnvelopeTypeEnvelopeTypeContractIdFromSourceAccount: - u.SourceAccountContractId = new(HashIdPreimageSourceAccountContractId) - nTmp, err = (*u.SourceAccountContractId).DecodeFrom(d) + case EnvelopeTypeEnvelopeTypeSorobanAuthorization: + u.SorobanAuthorization = new(HashIdPreimageSorobanAuthorization) + nTmp, err = (*u.SorobanAuthorization).DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageSourceAccountContractId: %s", err) - } - return n, nil - case EnvelopeTypeEnvelopeTypeCreateContractArgs: - u.CreateContractArgs = new(HashIdPreimageCreateContractArgs) - nTmp, err = (*u.CreateContractArgs).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageCreateContractArgs: %s", err) - } - return n, nil - case EnvelopeTypeEnvelopeTypeContractAuth: - u.ContractAuth = new(HashIdPreimageContractAuth) - nTmp, err = (*u.ContractAuth).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding HashIdPreimageContractAuth: %s", err) + return n, fmt.Errorf("decoding HashIdPreimageSorobanAuthorization: %s", err) } return n, nil } @@ -39000,7 +38119,7 @@ var _ xdrType = (*InvokeHostFunctionResultCode)(nil) // union InvokeHostFunctionResult switch (InvokeHostFunctionResultCode code) // { // case INVOKE_HOST_FUNCTION_SUCCESS: -// SCVal success; +// Hash success; // sha256(InvokeHostFunctionSuccessPreImage) // case INVOKE_HOST_FUNCTION_MALFORMED: // case INVOKE_HOST_FUNCTION_TRAPPED: // case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: @@ -39008,7 +38127,7 @@ var _ xdrType = (*InvokeHostFunctionResultCode)(nil) // }; type InvokeHostFunctionResult struct { Code InvokeHostFunctionResultCode - Success *[]ScVal `xdrmaxsize:"100"` + Success *Hash } // SwitchFieldName returns the field name in which this union's @@ -39038,9 +38157,9 @@ func NewInvokeHostFunctionResult(code InvokeHostFunctionResultCode, value interf result.Code = code switch InvokeHostFunctionResultCode(code) { case InvokeHostFunctionResultCodeInvokeHostFunctionSuccess: - tv, ok := value.([]ScVal) + tv, ok := value.(Hash) if !ok { - err = fmt.Errorf("invalid value, must be []ScVal") + err = fmt.Errorf("invalid value, must be Hash") return } result.Success = &tv @@ -39056,7 +38175,7 @@ func NewInvokeHostFunctionResult(code InvokeHostFunctionResultCode, value interf // MustSuccess retrieves the Success value from the union, // panicing if the value is not set. -func (u InvokeHostFunctionResult) MustSuccess() []ScVal { +func (u InvokeHostFunctionResult) MustSuccess() Hash { val, ok := u.GetSuccess() if !ok { @@ -39068,7 +38187,7 @@ func (u InvokeHostFunctionResult) MustSuccess() []ScVal { // GetSuccess retrieves the Success value from the union, // returning ok if the union's switch indicated the value is valid. -func (u InvokeHostFunctionResult) GetSuccess() (result []ScVal, ok bool) { +func (u InvokeHostFunctionResult) GetSuccess() (result Hash, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Code)) if armName == "Success" { @@ -39087,14 +38206,9 @@ func (u InvokeHostFunctionResult) EncodeTo(e *xdr.Encoder) error { } switch InvokeHostFunctionResultCode(u.Code) { case InvokeHostFunctionResultCodeInvokeHostFunctionSuccess: - if _, err = e.EncodeUint(uint32(len((*u.Success)))); err != nil { + if err = (*u.Success).EncodeTo(e); err != nil { return err } - for i := 0; i < len((*u.Success)); i++ { - if err = (*u.Success)[i].EncodeTo(e); err != nil { - return err - } - } return nil case InvokeHostFunctionResultCodeInvokeHostFunctionMalformed: // Void @@ -39122,26 +38236,11 @@ func (u *InvokeHostFunctionResult) DecodeFrom(d *xdr.Decoder) (int, error) { } switch InvokeHostFunctionResultCode(u.Code) { case InvokeHostFunctionResultCodeInvokeHostFunctionSuccess: - u.Success = new([]ScVal) - var l uint32 - l, nTmp, err = d.DecodeUint() + u.Success = new(Hash) + nTmp, err = (*u.Success).DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) - } - if l > 100 { - return n, fmt.Errorf("decoding ScVal: data size (%d) exceeds size limit (100)", l) - } - (*u.Success) = nil - if l > 0 { - (*u.Success) = make([]ScVal, l) - for i := uint32(0); i < l; i++ { - nTmp, err = (*u.Success)[i].DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScVal: %s", err) - } - } + return n, fmt.Errorf("decoding Hash: %s", err) } return n, nil case InvokeHostFunctionResultCodeInvokeHostFunctionMalformed: @@ -44660,7 +43759,7 @@ const ScSpecDocLimit = 1024 // // Types with no parameters. // SC_SPEC_TYPE_BOOL = 1, // SC_SPEC_TYPE_VOID = 2, -// SC_SPEC_TYPE_STATUS = 3, +// SC_SPEC_TYPE_ERROR = 3, // SC_SPEC_TYPE_U32 = 4, // SC_SPEC_TYPE_I32 = 5, // SC_SPEC_TYPE_U64 = 6, @@ -44694,7 +43793,7 @@ const ( ScSpecTypeScSpecTypeVal ScSpecType = 0 ScSpecTypeScSpecTypeBool ScSpecType = 1 ScSpecTypeScSpecTypeVoid ScSpecType = 2 - ScSpecTypeScSpecTypeStatus ScSpecType = 3 + ScSpecTypeScSpecTypeError ScSpecType = 3 ScSpecTypeScSpecTypeU32 ScSpecType = 4 ScSpecTypeScSpecTypeI32 ScSpecType = 5 ScSpecTypeScSpecTypeU64 ScSpecType = 6 @@ -44723,7 +43822,7 @@ var scSpecTypeMap = map[int32]string{ 0: "ScSpecTypeScSpecTypeVal", 1: "ScSpecTypeScSpecTypeBool", 2: "ScSpecTypeScSpecTypeVoid", - 3: "ScSpecTypeScSpecTypeStatus", + 3: "ScSpecTypeScSpecTypeError", 4: "ScSpecTypeScSpecTypeU32", 5: "ScSpecTypeScSpecTypeI32", 6: "ScSpecTypeScSpecTypeU64", @@ -45339,7 +44438,7 @@ var _ xdrType = (*ScSpecTypeUdt)(nil) // case SC_SPEC_TYPE_VAL: // case SC_SPEC_TYPE_BOOL: // case SC_SPEC_TYPE_VOID: -// case SC_SPEC_TYPE_STATUS: +// case SC_SPEC_TYPE_ERROR: // case SC_SPEC_TYPE_U32: // case SC_SPEC_TYPE_I32: // case SC_SPEC_TYPE_U64: @@ -45400,7 +44499,7 @@ func (u ScSpecTypeDef) ArmForSwitch(sw int32) (string, bool) { return "", true case ScSpecTypeScSpecTypeVoid: return "", true - case ScSpecTypeScSpecTypeStatus: + case ScSpecTypeScSpecTypeError: return "", true case ScSpecTypeScSpecTypeU32: return "", true @@ -45460,7 +44559,7 @@ func NewScSpecTypeDef(aType ScSpecType, value interface{}) (result ScSpecTypeDef // void case ScSpecTypeScSpecTypeVoid: // void - case ScSpecTypeScSpecTypeStatus: + case ScSpecTypeScSpecTypeError: // void case ScSpecTypeScSpecTypeU32: // void @@ -45766,7 +44865,7 @@ func (u ScSpecTypeDef) EncodeTo(e *xdr.Encoder) error { case ScSpecTypeScSpecTypeVoid: // Void return nil - case ScSpecTypeScSpecTypeStatus: + case ScSpecTypeScSpecTypeError: // Void return nil case ScSpecTypeScSpecTypeU32: @@ -45876,7 +44975,7 @@ func (u *ScSpecTypeDef) DecodeFrom(d *xdr.Decoder) (int, error) { case ScSpecTypeScSpecTypeVoid: // Void return n, nil - case ScSpecTypeScSpecTypeStatus: + case ScSpecTypeScSpecTypeError: // Void return n, nil case ScSpecTypeScSpecTypeU32: @@ -47776,7 +46875,7 @@ var _ xdrType = (*ScSpecEntry)(nil) // { // SCV_BOOL = 0, // SCV_VOID = 1, -// SCV_STATUS = 2, +// SCV_ERROR = 2, // // // 32 bits is the smallest type in WASM or XDR; no need for u8/u16. // SCV_U32 = 3, @@ -47803,9 +46902,6 @@ var _ xdrType = (*ScSpecEntry)(nil) // SCV_U256 = 11, // SCV_I256 = 12, // -// // TODO: possibly allocate subtypes of i64, i128 and/or u256 for -// // fixed-precision with a specific number of decimals. -// // // Bytes come in 3 flavors, 2 of which have meaningfully different // // formatting and validity-checking / domain-restriction. // SCV_BYTES = 13, @@ -47832,7 +46928,7 @@ type ScValType int32 const ( ScValTypeScvBool ScValType = 0 ScValTypeScvVoid ScValType = 1 - ScValTypeScvStatus ScValType = 2 + ScValTypeScvError ScValType = 2 ScValTypeScvU32 ScValType = 3 ScValTypeScvI32 ScValType = 4 ScValTypeScvU64 ScValType = 5 @@ -47857,7 +46953,7 @@ const ( var scValTypeMap = map[int32]string{ 0: "ScValTypeScvBool", 1: "ScValTypeScvVoid", - 2: "ScValTypeScvStatus", + 2: "ScValTypeScvError", 3: "ScValTypeScvU32", 4: "ScValTypeScvI32", 5: "ScValTypeScvU64", @@ -47943,89 +47039,88 @@ func (s ScValType) xdrType() {} var _ xdrType = (*ScValType)(nil) -// ScStatusType is an XDR Enum defines as: +// ScErrorType is an XDR Enum defines as: // -// enum SCStatusType +// enum SCErrorType // { -// SST_OK = 0, -// SST_UNKNOWN_ERROR = 1, -// SST_HOST_VALUE_ERROR = 2, -// SST_HOST_OBJECT_ERROR = 3, -// SST_HOST_FUNCTION_ERROR = 4, -// SST_HOST_STORAGE_ERROR = 5, -// SST_HOST_CONTEXT_ERROR = 6, -// SST_VM_ERROR = 7, -// SST_CONTRACT_ERROR = 8, -// SST_HOST_AUTH_ERROR = 9 -// // TODO: add more +// SCE_CONTRACT = 0, +// SCE_WASM_VM = 1, +// SCE_CONTEXT = 2, +// SCE_STORAGE = 3, +// SCE_OBJECT = 4, +// SCE_CRYPTO = 5, +// SCE_EVENTS = 6, +// SCE_BUDGET = 7, +// SCE_VALUE = 8, +// SCE_AUTH = 9 // }; -type ScStatusType int32 +type ScErrorType int32 const ( - ScStatusTypeSstOk ScStatusType = 0 - ScStatusTypeSstUnknownError ScStatusType = 1 - ScStatusTypeSstHostValueError ScStatusType = 2 - ScStatusTypeSstHostObjectError ScStatusType = 3 - ScStatusTypeSstHostFunctionError ScStatusType = 4 - ScStatusTypeSstHostStorageError ScStatusType = 5 - ScStatusTypeSstHostContextError ScStatusType = 6 - ScStatusTypeSstVmError ScStatusType = 7 - ScStatusTypeSstContractError ScStatusType = 8 - ScStatusTypeSstHostAuthError ScStatusType = 9 -) - -var scStatusTypeMap = map[int32]string{ - 0: "ScStatusTypeSstOk", - 1: "ScStatusTypeSstUnknownError", - 2: "ScStatusTypeSstHostValueError", - 3: "ScStatusTypeSstHostObjectError", - 4: "ScStatusTypeSstHostFunctionError", - 5: "ScStatusTypeSstHostStorageError", - 6: "ScStatusTypeSstHostContextError", - 7: "ScStatusTypeSstVmError", - 8: "ScStatusTypeSstContractError", - 9: "ScStatusTypeSstHostAuthError", + ScErrorTypeSceContract ScErrorType = 0 + ScErrorTypeSceWasmVm ScErrorType = 1 + ScErrorTypeSceContext ScErrorType = 2 + ScErrorTypeSceStorage ScErrorType = 3 + ScErrorTypeSceObject ScErrorType = 4 + ScErrorTypeSceCrypto ScErrorType = 5 + ScErrorTypeSceEvents ScErrorType = 6 + ScErrorTypeSceBudget ScErrorType = 7 + ScErrorTypeSceValue ScErrorType = 8 + ScErrorTypeSceAuth ScErrorType = 9 +) + +var scErrorTypeMap = map[int32]string{ + 0: "ScErrorTypeSceContract", + 1: "ScErrorTypeSceWasmVm", + 2: "ScErrorTypeSceContext", + 3: "ScErrorTypeSceStorage", + 4: "ScErrorTypeSceObject", + 5: "ScErrorTypeSceCrypto", + 6: "ScErrorTypeSceEvents", + 7: "ScErrorTypeSceBudget", + 8: "ScErrorTypeSceValue", + 9: "ScErrorTypeSceAuth", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScStatusType -func (e ScStatusType) ValidEnum(v int32) bool { - _, ok := scStatusTypeMap[v] +// the Enum interface for ScErrorType +func (e ScErrorType) ValidEnum(v int32) bool { + _, ok := scErrorTypeMap[v] return ok } // String returns the name of `e` -func (e ScStatusType) String() string { - name, _ := scStatusTypeMap[int32(e)] +func (e ScErrorType) String() string { + name, _ := scErrorTypeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e ScStatusType) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scStatusTypeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScStatusType enum value", e) +func (e ScErrorType) EncodeTo(enc *xdr.Encoder) error { + if _, ok := scErrorTypeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ScErrorType enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*ScStatusType)(nil) +var _ decoderFrom = (*ScErrorType)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScStatusType) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScErrorType) DecodeFrom(d *xdr.Decoder) (int, error) { v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScStatusType: %s", err) + return n, fmt.Errorf("decoding ScErrorType: %s", err) } - if _, ok := scStatusTypeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScStatusType enum value", v) + if _, ok := scErrorTypeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ScErrorType enum value", v) } - *e = ScStatusType(v) + *e = ScErrorType(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ScStatusType) MarshalBinary() ([]byte, error) { +func (s ScErrorType) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -48033,7 +47128,7 @@ func (s ScStatusType) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScStatusType) UnmarshalBinary(inp []byte) error { +func (s *ScErrorType) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -48041,777 +47136,98 @@ func (s *ScStatusType) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ScStatusType)(nil) - _ encoding.BinaryUnmarshaler = (*ScStatusType)(nil) + _ encoding.BinaryMarshaler = (*ScErrorType)(nil) + _ encoding.BinaryUnmarshaler = (*ScErrorType)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ScStatusType) xdrType() {} +func (s ScErrorType) xdrType() {} -var _ xdrType = (*ScStatusType)(nil) +var _ xdrType = (*ScErrorType)(nil) -// ScHostValErrorCode is an XDR Enum defines as: +// ScErrorCode is an XDR Enum defines as: // -// enum SCHostValErrorCode +// enum SCErrorCode // { -// HOST_VALUE_UNKNOWN_ERROR = 0, -// HOST_VALUE_RESERVED_TAG_VALUE = 1, -// HOST_VALUE_UNEXPECTED_VAL_TYPE = 2, -// HOST_VALUE_U63_OUT_OF_RANGE = 3, -// HOST_VALUE_U32_OUT_OF_RANGE = 4, -// HOST_VALUE_STATIC_UNKNOWN = 5, -// HOST_VALUE_MISSING_OBJECT = 6, -// HOST_VALUE_SYMBOL_TOO_LONG = 7, -// HOST_VALUE_SYMBOL_BAD_CHAR = 8, -// HOST_VALUE_SYMBOL_CONTAINS_NON_UTF8 = 9, -// HOST_VALUE_BITSET_TOO_MANY_BITS = 10, -// HOST_VALUE_STATUS_UNKNOWN = 11 +// SCEC_ARITH_DOMAIN = 0, // some arithmetic wasn't defined (overflow, divide-by-zero) +// SCEC_INDEX_BOUNDS = 1, // something was indexed beyond its bounds +// SCEC_INVALID_INPUT = 2, // user provided some otherwise-bad data +// SCEC_MISSING_VALUE = 3, // some value was required but not provided +// SCEC_EXISTING_VALUE = 4, // some value was provided where not allowed +// SCEC_EXCEEDED_LIMIT = 5, // some arbitrary limit -- gas or otherwise -- was hit +// SCEC_INVALID_ACTION = 6, // data was valid but action requested was not +// SCEC_INTERNAL_ERROR = 7, // the internal state of the host was otherwise-bad +// SCEC_UNEXPECTED_TYPE = 8, // some type wasn't as expected +// SCEC_UNEXPECTED_SIZE = 9 // something's size wasn't as expected // }; -type ScHostValErrorCode int32 +type ScErrorCode int32 const ( - ScHostValErrorCodeHostValueUnknownError ScHostValErrorCode = 0 - ScHostValErrorCodeHostValueReservedTagValue ScHostValErrorCode = 1 - ScHostValErrorCodeHostValueUnexpectedValType ScHostValErrorCode = 2 - ScHostValErrorCodeHostValueU63OutOfRange ScHostValErrorCode = 3 - ScHostValErrorCodeHostValueU32OutOfRange ScHostValErrorCode = 4 - ScHostValErrorCodeHostValueStaticUnknown ScHostValErrorCode = 5 - ScHostValErrorCodeHostValueMissingObject ScHostValErrorCode = 6 - ScHostValErrorCodeHostValueSymbolTooLong ScHostValErrorCode = 7 - ScHostValErrorCodeHostValueSymbolBadChar ScHostValErrorCode = 8 - ScHostValErrorCodeHostValueSymbolContainsNonUtf8 ScHostValErrorCode = 9 - ScHostValErrorCodeHostValueBitsetTooManyBits ScHostValErrorCode = 10 - ScHostValErrorCodeHostValueStatusUnknown ScHostValErrorCode = 11 -) - -var scHostValErrorCodeMap = map[int32]string{ - 0: "ScHostValErrorCodeHostValueUnknownError", - 1: "ScHostValErrorCodeHostValueReservedTagValue", - 2: "ScHostValErrorCodeHostValueUnexpectedValType", - 3: "ScHostValErrorCodeHostValueU63OutOfRange", - 4: "ScHostValErrorCodeHostValueU32OutOfRange", - 5: "ScHostValErrorCodeHostValueStaticUnknown", - 6: "ScHostValErrorCodeHostValueMissingObject", - 7: "ScHostValErrorCodeHostValueSymbolTooLong", - 8: "ScHostValErrorCodeHostValueSymbolBadChar", - 9: "ScHostValErrorCodeHostValueSymbolContainsNonUtf8", - 10: "ScHostValErrorCodeHostValueBitsetTooManyBits", - 11: "ScHostValErrorCodeHostValueStatusUnknown", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScHostValErrorCode -func (e ScHostValErrorCode) ValidEnum(v int32) bool { - _, ok := scHostValErrorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ScHostValErrorCode) String() string { - name, _ := scHostValErrorCodeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ScHostValErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scHostValErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScHostValErrorCode enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ScHostValErrorCode)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ScHostValErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ScHostValErrorCode: %s", err) - } - if _, ok := scHostValErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScHostValErrorCode enum value", v) - } - *e = ScHostValErrorCode(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ScHostValErrorCode) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScHostValErrorCode) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ScHostValErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScHostValErrorCode)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ScHostValErrorCode) xdrType() {} - -var _ xdrType = (*ScHostValErrorCode)(nil) - -// ScHostObjErrorCode is an XDR Enum defines as: -// -// enum SCHostObjErrorCode -// { -// HOST_OBJECT_UNKNOWN_ERROR = 0, -// HOST_OBJECT_UNKNOWN_REFERENCE = 1, -// HOST_OBJECT_UNEXPECTED_TYPE = 2, -// HOST_OBJECT_OBJECT_COUNT_EXCEEDS_U32_MAX = 3, -// HOST_OBJECT_OBJECT_NOT_EXIST = 4, -// HOST_OBJECT_VEC_INDEX_OUT_OF_BOUND = 5, -// HOST_OBJECT_CONTRACT_HASH_WRONG_LENGTH = 6 -// }; -type ScHostObjErrorCode int32 - -const ( - ScHostObjErrorCodeHostObjectUnknownError ScHostObjErrorCode = 0 - ScHostObjErrorCodeHostObjectUnknownReference ScHostObjErrorCode = 1 - ScHostObjErrorCodeHostObjectUnexpectedType ScHostObjErrorCode = 2 - ScHostObjErrorCodeHostObjectObjectCountExceedsU32Max ScHostObjErrorCode = 3 - ScHostObjErrorCodeHostObjectObjectNotExist ScHostObjErrorCode = 4 - ScHostObjErrorCodeHostObjectVecIndexOutOfBound ScHostObjErrorCode = 5 - ScHostObjErrorCodeHostObjectContractHashWrongLength ScHostObjErrorCode = 6 -) - -var scHostObjErrorCodeMap = map[int32]string{ - 0: "ScHostObjErrorCodeHostObjectUnknownError", - 1: "ScHostObjErrorCodeHostObjectUnknownReference", - 2: "ScHostObjErrorCodeHostObjectUnexpectedType", - 3: "ScHostObjErrorCodeHostObjectObjectCountExceedsU32Max", - 4: "ScHostObjErrorCodeHostObjectObjectNotExist", - 5: "ScHostObjErrorCodeHostObjectVecIndexOutOfBound", - 6: "ScHostObjErrorCodeHostObjectContractHashWrongLength", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScHostObjErrorCode -func (e ScHostObjErrorCode) ValidEnum(v int32) bool { - _, ok := scHostObjErrorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ScHostObjErrorCode) String() string { - name, _ := scHostObjErrorCodeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ScHostObjErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scHostObjErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScHostObjErrorCode enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ScHostObjErrorCode)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ScHostObjErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ScHostObjErrorCode: %s", err) - } - if _, ok := scHostObjErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScHostObjErrorCode enum value", v) - } - *e = ScHostObjErrorCode(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ScHostObjErrorCode) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScHostObjErrorCode) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ScHostObjErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScHostObjErrorCode)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ScHostObjErrorCode) xdrType() {} - -var _ xdrType = (*ScHostObjErrorCode)(nil) - -// ScHostFnErrorCode is an XDR Enum defines as: -// -// enum SCHostFnErrorCode -// { -// HOST_FN_UNKNOWN_ERROR = 0, -// HOST_FN_UNEXPECTED_HOST_FUNCTION_ACTION = 1, -// HOST_FN_INPUT_ARGS_WRONG_LENGTH = 2, -// HOST_FN_INPUT_ARGS_WRONG_TYPE = 3, -// HOST_FN_INPUT_ARGS_INVALID = 4 -// }; -type ScHostFnErrorCode int32 - -const ( - ScHostFnErrorCodeHostFnUnknownError ScHostFnErrorCode = 0 - ScHostFnErrorCodeHostFnUnexpectedHostFunctionAction ScHostFnErrorCode = 1 - ScHostFnErrorCodeHostFnInputArgsWrongLength ScHostFnErrorCode = 2 - ScHostFnErrorCodeHostFnInputArgsWrongType ScHostFnErrorCode = 3 - ScHostFnErrorCodeHostFnInputArgsInvalid ScHostFnErrorCode = 4 -) - -var scHostFnErrorCodeMap = map[int32]string{ - 0: "ScHostFnErrorCodeHostFnUnknownError", - 1: "ScHostFnErrorCodeHostFnUnexpectedHostFunctionAction", - 2: "ScHostFnErrorCodeHostFnInputArgsWrongLength", - 3: "ScHostFnErrorCodeHostFnInputArgsWrongType", - 4: "ScHostFnErrorCodeHostFnInputArgsInvalid", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScHostFnErrorCode -func (e ScHostFnErrorCode) ValidEnum(v int32) bool { - _, ok := scHostFnErrorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ScHostFnErrorCode) String() string { - name, _ := scHostFnErrorCodeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ScHostFnErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scHostFnErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScHostFnErrorCode enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ScHostFnErrorCode)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ScHostFnErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ScHostFnErrorCode: %s", err) - } - if _, ok := scHostFnErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScHostFnErrorCode enum value", v) - } - *e = ScHostFnErrorCode(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ScHostFnErrorCode) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScHostFnErrorCode) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ScHostFnErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScHostFnErrorCode)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ScHostFnErrorCode) xdrType() {} - -var _ xdrType = (*ScHostFnErrorCode)(nil) - -// ScHostStorageErrorCode is an XDR Enum defines as: -// -// enum SCHostStorageErrorCode -// { -// HOST_STORAGE_UNKNOWN_ERROR = 0, -// HOST_STORAGE_EXPECT_CONTRACT_DATA = 1, -// HOST_STORAGE_READWRITE_ACCESS_TO_READONLY_ENTRY = 2, -// HOST_STORAGE_ACCESS_TO_UNKNOWN_ENTRY = 3, -// HOST_STORAGE_MISSING_KEY_IN_GET = 4, -// HOST_STORAGE_GET_ON_DELETED_KEY = 5 -// }; -type ScHostStorageErrorCode int32 - -const ( - ScHostStorageErrorCodeHostStorageUnknownError ScHostStorageErrorCode = 0 - ScHostStorageErrorCodeHostStorageExpectContractData ScHostStorageErrorCode = 1 - ScHostStorageErrorCodeHostStorageReadwriteAccessToReadonlyEntry ScHostStorageErrorCode = 2 - ScHostStorageErrorCodeHostStorageAccessToUnknownEntry ScHostStorageErrorCode = 3 - ScHostStorageErrorCodeHostStorageMissingKeyInGet ScHostStorageErrorCode = 4 - ScHostStorageErrorCodeHostStorageGetOnDeletedKey ScHostStorageErrorCode = 5 -) - -var scHostStorageErrorCodeMap = map[int32]string{ - 0: "ScHostStorageErrorCodeHostStorageUnknownError", - 1: "ScHostStorageErrorCodeHostStorageExpectContractData", - 2: "ScHostStorageErrorCodeHostStorageReadwriteAccessToReadonlyEntry", - 3: "ScHostStorageErrorCodeHostStorageAccessToUnknownEntry", - 4: "ScHostStorageErrorCodeHostStorageMissingKeyInGet", - 5: "ScHostStorageErrorCodeHostStorageGetOnDeletedKey", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScHostStorageErrorCode -func (e ScHostStorageErrorCode) ValidEnum(v int32) bool { - _, ok := scHostStorageErrorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ScHostStorageErrorCode) String() string { - name, _ := scHostStorageErrorCodeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ScHostStorageErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scHostStorageErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScHostStorageErrorCode enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ScHostStorageErrorCode)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ScHostStorageErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ScHostStorageErrorCode: %s", err) - } - if _, ok := scHostStorageErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScHostStorageErrorCode enum value", v) - } - *e = ScHostStorageErrorCode(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ScHostStorageErrorCode) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScHostStorageErrorCode) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ScHostStorageErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScHostStorageErrorCode)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ScHostStorageErrorCode) xdrType() {} - -var _ xdrType = (*ScHostStorageErrorCode)(nil) - -// ScHostAuthErrorCode is an XDR Enum defines as: -// -// enum SCHostAuthErrorCode -// { -// HOST_AUTH_UNKNOWN_ERROR = 0, -// HOST_AUTH_NONCE_ERROR = 1, -// HOST_AUTH_DUPLICATE_AUTHORIZATION = 2, -// HOST_AUTH_NOT_AUTHORIZED = 3 -// }; -type ScHostAuthErrorCode int32 - -const ( - ScHostAuthErrorCodeHostAuthUnknownError ScHostAuthErrorCode = 0 - ScHostAuthErrorCodeHostAuthNonceError ScHostAuthErrorCode = 1 - ScHostAuthErrorCodeHostAuthDuplicateAuthorization ScHostAuthErrorCode = 2 - ScHostAuthErrorCodeHostAuthNotAuthorized ScHostAuthErrorCode = 3 -) - -var scHostAuthErrorCodeMap = map[int32]string{ - 0: "ScHostAuthErrorCodeHostAuthUnknownError", - 1: "ScHostAuthErrorCodeHostAuthNonceError", - 2: "ScHostAuthErrorCodeHostAuthDuplicateAuthorization", - 3: "ScHostAuthErrorCodeHostAuthNotAuthorized", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScHostAuthErrorCode -func (e ScHostAuthErrorCode) ValidEnum(v int32) bool { - _, ok := scHostAuthErrorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ScHostAuthErrorCode) String() string { - name, _ := scHostAuthErrorCodeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ScHostAuthErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scHostAuthErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScHostAuthErrorCode enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ScHostAuthErrorCode)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ScHostAuthErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ScHostAuthErrorCode: %s", err) - } - if _, ok := scHostAuthErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScHostAuthErrorCode enum value", v) - } - *e = ScHostAuthErrorCode(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ScHostAuthErrorCode) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScHostAuthErrorCode) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ScHostAuthErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScHostAuthErrorCode)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ScHostAuthErrorCode) xdrType() {} - -var _ xdrType = (*ScHostAuthErrorCode)(nil) - -// ScHostContextErrorCode is an XDR Enum defines as: -// -// enum SCHostContextErrorCode -// { -// HOST_CONTEXT_UNKNOWN_ERROR = 0, -// HOST_CONTEXT_NO_CONTRACT_RUNNING = 1 -// }; -type ScHostContextErrorCode int32 - -const ( - ScHostContextErrorCodeHostContextUnknownError ScHostContextErrorCode = 0 - ScHostContextErrorCodeHostContextNoContractRunning ScHostContextErrorCode = 1 -) - -var scHostContextErrorCodeMap = map[int32]string{ - 0: "ScHostContextErrorCodeHostContextUnknownError", - 1: "ScHostContextErrorCodeHostContextNoContractRunning", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScHostContextErrorCode -func (e ScHostContextErrorCode) ValidEnum(v int32) bool { - _, ok := scHostContextErrorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ScHostContextErrorCode) String() string { - name, _ := scHostContextErrorCodeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ScHostContextErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scHostContextErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScHostContextErrorCode enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ScHostContextErrorCode)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ScHostContextErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ScHostContextErrorCode: %s", err) - } - if _, ok := scHostContextErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScHostContextErrorCode enum value", v) - } - *e = ScHostContextErrorCode(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ScHostContextErrorCode) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScHostContextErrorCode) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ScHostContextErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScHostContextErrorCode)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ScHostContextErrorCode) xdrType() {} - -var _ xdrType = (*ScHostContextErrorCode)(nil) - -// ScVmErrorCode is an XDR Enum defines as: -// -// enum SCVmErrorCode { -// VM_UNKNOWN = 0, -// VM_VALIDATION = 1, -// VM_INSTANTIATION = 2, -// VM_FUNCTION = 3, -// VM_TABLE = 4, -// VM_MEMORY = 5, -// VM_GLOBAL = 6, -// VM_VALUE = 7, -// VM_TRAP_UNREACHABLE = 8, -// VM_TRAP_MEMORY_ACCESS_OUT_OF_BOUNDS = 9, -// VM_TRAP_TABLE_ACCESS_OUT_OF_BOUNDS = 10, -// VM_TRAP_ELEM_UNINITIALIZED = 11, -// VM_TRAP_DIVISION_BY_ZERO = 12, -// VM_TRAP_INTEGER_OVERFLOW = 13, -// VM_TRAP_INVALID_CONVERSION_TO_INT = 14, -// VM_TRAP_STACK_OVERFLOW = 15, -// VM_TRAP_UNEXPECTED_SIGNATURE = 16, -// VM_TRAP_MEM_LIMIT_EXCEEDED = 17, -// VM_TRAP_CPU_LIMIT_EXCEEDED = 18 -// }; -type ScVmErrorCode int32 - -const ( - ScVmErrorCodeVmUnknown ScVmErrorCode = 0 - ScVmErrorCodeVmValidation ScVmErrorCode = 1 - ScVmErrorCodeVmInstantiation ScVmErrorCode = 2 - ScVmErrorCodeVmFunction ScVmErrorCode = 3 - ScVmErrorCodeVmTable ScVmErrorCode = 4 - ScVmErrorCodeVmMemory ScVmErrorCode = 5 - ScVmErrorCodeVmGlobal ScVmErrorCode = 6 - ScVmErrorCodeVmValue ScVmErrorCode = 7 - ScVmErrorCodeVmTrapUnreachable ScVmErrorCode = 8 - ScVmErrorCodeVmTrapMemoryAccessOutOfBounds ScVmErrorCode = 9 - ScVmErrorCodeVmTrapTableAccessOutOfBounds ScVmErrorCode = 10 - ScVmErrorCodeVmTrapElemUninitialized ScVmErrorCode = 11 - ScVmErrorCodeVmTrapDivisionByZero ScVmErrorCode = 12 - ScVmErrorCodeVmTrapIntegerOverflow ScVmErrorCode = 13 - ScVmErrorCodeVmTrapInvalidConversionToInt ScVmErrorCode = 14 - ScVmErrorCodeVmTrapStackOverflow ScVmErrorCode = 15 - ScVmErrorCodeVmTrapUnexpectedSignature ScVmErrorCode = 16 - ScVmErrorCodeVmTrapMemLimitExceeded ScVmErrorCode = 17 - ScVmErrorCodeVmTrapCpuLimitExceeded ScVmErrorCode = 18 -) - -var scVmErrorCodeMap = map[int32]string{ - 0: "ScVmErrorCodeVmUnknown", - 1: "ScVmErrorCodeVmValidation", - 2: "ScVmErrorCodeVmInstantiation", - 3: "ScVmErrorCodeVmFunction", - 4: "ScVmErrorCodeVmTable", - 5: "ScVmErrorCodeVmMemory", - 6: "ScVmErrorCodeVmGlobal", - 7: "ScVmErrorCodeVmValue", - 8: "ScVmErrorCodeVmTrapUnreachable", - 9: "ScVmErrorCodeVmTrapMemoryAccessOutOfBounds", - 10: "ScVmErrorCodeVmTrapTableAccessOutOfBounds", - 11: "ScVmErrorCodeVmTrapElemUninitialized", - 12: "ScVmErrorCodeVmTrapDivisionByZero", - 13: "ScVmErrorCodeVmTrapIntegerOverflow", - 14: "ScVmErrorCodeVmTrapInvalidConversionToInt", - 15: "ScVmErrorCodeVmTrapStackOverflow", - 16: "ScVmErrorCodeVmTrapUnexpectedSignature", - 17: "ScVmErrorCodeVmTrapMemLimitExceeded", - 18: "ScVmErrorCodeVmTrapCpuLimitExceeded", -} - -// ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScVmErrorCode -func (e ScVmErrorCode) ValidEnum(v int32) bool { - _, ok := scVmErrorCodeMap[v] - return ok -} - -// String returns the name of `e` -func (e ScVmErrorCode) String() string { - name, _ := scVmErrorCodeMap[int32(e)] - return name -} - -// EncodeTo encodes this value using the Encoder. -func (e ScVmErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scVmErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScVmErrorCode enum value", e) - } - _, err := enc.EncodeInt(int32(e)) - return err -} - -var _ decoderFrom = (*ScVmErrorCode)(nil) - -// DecodeFrom decodes this value using the Decoder. -func (e *ScVmErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { - v, n, err := d.DecodeInt() - if err != nil { - return n, fmt.Errorf("decoding ScVmErrorCode: %s", err) - } - if _, ok := scVmErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScVmErrorCode enum value", v) - } - *e = ScVmErrorCode(v) - return n, nil -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (s ScVmErrorCode) MarshalBinary() ([]byte, error) { - b := bytes.Buffer{} - e := xdr.NewEncoder(&b) - err := s.EncodeTo(e) - return b.Bytes(), err -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScVmErrorCode) UnmarshalBinary(inp []byte) error { - r := bytes.NewReader(inp) - d := xdr.NewDecoder(r) - _, err := s.DecodeFrom(d) - return err -} - -var ( - _ encoding.BinaryMarshaler = (*ScVmErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScVmErrorCode)(nil) -) - -// xdrType signals that this type is an type representing -// representing XDR values defined by this package. -func (s ScVmErrorCode) xdrType() {} - -var _ xdrType = (*ScVmErrorCode)(nil) - -// ScUnknownErrorCode is an XDR Enum defines as: -// -// enum SCUnknownErrorCode -// { -// UNKNOWN_ERROR_GENERAL = 0, -// UNKNOWN_ERROR_XDR = 1 -// }; -type ScUnknownErrorCode int32 - -const ( - ScUnknownErrorCodeUnknownErrorGeneral ScUnknownErrorCode = 0 - ScUnknownErrorCodeUnknownErrorXdr ScUnknownErrorCode = 1 -) - -var scUnknownErrorCodeMap = map[int32]string{ - 0: "ScUnknownErrorCodeUnknownErrorGeneral", - 1: "ScUnknownErrorCodeUnknownErrorXdr", + ScErrorCodeScecArithDomain ScErrorCode = 0 + ScErrorCodeScecIndexBounds ScErrorCode = 1 + ScErrorCodeScecInvalidInput ScErrorCode = 2 + ScErrorCodeScecMissingValue ScErrorCode = 3 + ScErrorCodeScecExistingValue ScErrorCode = 4 + ScErrorCodeScecExceededLimit ScErrorCode = 5 + ScErrorCodeScecInvalidAction ScErrorCode = 6 + ScErrorCodeScecInternalError ScErrorCode = 7 + ScErrorCodeScecUnexpectedType ScErrorCode = 8 + ScErrorCodeScecUnexpectedSize ScErrorCode = 9 +) + +var scErrorCodeMap = map[int32]string{ + 0: "ScErrorCodeScecArithDomain", + 1: "ScErrorCodeScecIndexBounds", + 2: "ScErrorCodeScecInvalidInput", + 3: "ScErrorCodeScecMissingValue", + 4: "ScErrorCodeScecExistingValue", + 5: "ScErrorCodeScecExceededLimit", + 6: "ScErrorCodeScecInvalidAction", + 7: "ScErrorCodeScecInternalError", + 8: "ScErrorCodeScecUnexpectedType", + 9: "ScErrorCodeScecUnexpectedSize", } // ValidEnum validates a proposed value for this enum. Implements -// the Enum interface for ScUnknownErrorCode -func (e ScUnknownErrorCode) ValidEnum(v int32) bool { - _, ok := scUnknownErrorCodeMap[v] +// the Enum interface for ScErrorCode +func (e ScErrorCode) ValidEnum(v int32) bool { + _, ok := scErrorCodeMap[v] return ok } // String returns the name of `e` -func (e ScUnknownErrorCode) String() string { - name, _ := scUnknownErrorCodeMap[int32(e)] +func (e ScErrorCode) String() string { + name, _ := scErrorCodeMap[int32(e)] return name } // EncodeTo encodes this value using the Encoder. -func (e ScUnknownErrorCode) EncodeTo(enc *xdr.Encoder) error { - if _, ok := scUnknownErrorCodeMap[int32(e)]; !ok { - return fmt.Errorf("'%d' is not a valid ScUnknownErrorCode enum value", e) +func (e ScErrorCode) EncodeTo(enc *xdr.Encoder) error { + if _, ok := scErrorCodeMap[int32(e)]; !ok { + return fmt.Errorf("'%d' is not a valid ScErrorCode enum value", e) } _, err := enc.EncodeInt(int32(e)) return err } -var _ decoderFrom = (*ScUnknownErrorCode)(nil) +var _ decoderFrom = (*ScErrorCode)(nil) // DecodeFrom decodes this value using the Decoder. -func (e *ScUnknownErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { +func (e *ScErrorCode) DecodeFrom(d *xdr.Decoder) (int, error) { v, n, err := d.DecodeInt() if err != nil { - return n, fmt.Errorf("decoding ScUnknownErrorCode: %s", err) + return n, fmt.Errorf("decoding ScErrorCode: %s", err) } - if _, ok := scUnknownErrorCodeMap[v]; !ok { - return n, fmt.Errorf("'%d' is not a valid ScUnknownErrorCode enum value", v) + if _, ok := scErrorCodeMap[v]; !ok { + return n, fmt.Errorf("'%d' is not a valid ScErrorCode enum value", v) } - *e = ScUnknownErrorCode(v) + *e = ScErrorCode(v) return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ScUnknownErrorCode) MarshalBinary() ([]byte, error) { +func (s ScErrorCode) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -48819,7 +47235,7 @@ func (s ScUnknownErrorCode) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScUnknownErrorCode) UnmarshalBinary(inp []byte) error { +func (s *ScErrorCode) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -48827,538 +47243,61 @@ func (s *ScUnknownErrorCode) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ScUnknownErrorCode)(nil) - _ encoding.BinaryUnmarshaler = (*ScUnknownErrorCode)(nil) + _ encoding.BinaryMarshaler = (*ScErrorCode)(nil) + _ encoding.BinaryUnmarshaler = (*ScErrorCode)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ScUnknownErrorCode) xdrType() {} +func (s ScErrorCode) xdrType() {} -var _ xdrType = (*ScUnknownErrorCode)(nil) +var _ xdrType = (*ScErrorCode)(nil) -// ScStatus is an XDR Union defines as: +// ScError is an XDR Struct defines as: // -// union SCStatus switch (SCStatusType type) +// struct SCError // { -// case SST_OK: -// void; -// case SST_UNKNOWN_ERROR: -// SCUnknownErrorCode unknownCode; -// case SST_HOST_VALUE_ERROR: -// SCHostValErrorCode valCode; -// case SST_HOST_OBJECT_ERROR: -// SCHostObjErrorCode objCode; -// case SST_HOST_FUNCTION_ERROR: -// SCHostFnErrorCode fnCode; -// case SST_HOST_STORAGE_ERROR: -// SCHostStorageErrorCode storageCode; -// case SST_HOST_CONTEXT_ERROR: -// SCHostContextErrorCode contextCode; -// case SST_VM_ERROR: -// SCVmErrorCode vmCode; -// case SST_CONTRACT_ERROR: -// uint32 contractCode; -// case SST_HOST_AUTH_ERROR: -// SCHostAuthErrorCode authCode; -// }; -type ScStatus struct { - Type ScStatusType - UnknownCode *ScUnknownErrorCode - ValCode *ScHostValErrorCode - ObjCode *ScHostObjErrorCode - FnCode *ScHostFnErrorCode - StorageCode *ScHostStorageErrorCode - ContextCode *ScHostContextErrorCode - VmCode *ScVmErrorCode - ContractCode *Uint32 - AuthCode *ScHostAuthErrorCode -} - -// SwitchFieldName returns the field name in which this union's -// discriminant is stored -func (u ScStatus) SwitchFieldName() string { - return "Type" -} - -// ArmForSwitch returns which field name should be used for storing -// the value for an instance of ScStatus -func (u ScStatus) ArmForSwitch(sw int32) (string, bool) { - switch ScStatusType(sw) { - case ScStatusTypeSstOk: - return "", true - case ScStatusTypeSstUnknownError: - return "UnknownCode", true - case ScStatusTypeSstHostValueError: - return "ValCode", true - case ScStatusTypeSstHostObjectError: - return "ObjCode", true - case ScStatusTypeSstHostFunctionError: - return "FnCode", true - case ScStatusTypeSstHostStorageError: - return "StorageCode", true - case ScStatusTypeSstHostContextError: - return "ContextCode", true - case ScStatusTypeSstVmError: - return "VmCode", true - case ScStatusTypeSstContractError: - return "ContractCode", true - case ScStatusTypeSstHostAuthError: - return "AuthCode", true - } - return "-", false -} - -// NewScStatus creates a new ScStatus. -func NewScStatus(aType ScStatusType, value interface{}) (result ScStatus, err error) { - result.Type = aType - switch ScStatusType(aType) { - case ScStatusTypeSstOk: - // void - case ScStatusTypeSstUnknownError: - tv, ok := value.(ScUnknownErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScUnknownErrorCode") - return - } - result.UnknownCode = &tv - case ScStatusTypeSstHostValueError: - tv, ok := value.(ScHostValErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScHostValErrorCode") - return - } - result.ValCode = &tv - case ScStatusTypeSstHostObjectError: - tv, ok := value.(ScHostObjErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScHostObjErrorCode") - return - } - result.ObjCode = &tv - case ScStatusTypeSstHostFunctionError: - tv, ok := value.(ScHostFnErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScHostFnErrorCode") - return - } - result.FnCode = &tv - case ScStatusTypeSstHostStorageError: - tv, ok := value.(ScHostStorageErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScHostStorageErrorCode") - return - } - result.StorageCode = &tv - case ScStatusTypeSstHostContextError: - tv, ok := value.(ScHostContextErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScHostContextErrorCode") - return - } - result.ContextCode = &tv - case ScStatusTypeSstVmError: - tv, ok := value.(ScVmErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScVmErrorCode") - return - } - result.VmCode = &tv - case ScStatusTypeSstContractError: - tv, ok := value.(Uint32) - if !ok { - err = fmt.Errorf("invalid value, must be Uint32") - return - } - result.ContractCode = &tv - case ScStatusTypeSstHostAuthError: - tv, ok := value.(ScHostAuthErrorCode) - if !ok { - err = fmt.Errorf("invalid value, must be ScHostAuthErrorCode") - return - } - result.AuthCode = &tv - } - return -} - -// MustUnknownCode retrieves the UnknownCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustUnknownCode() ScUnknownErrorCode { - val, ok := u.GetUnknownCode() - - if !ok { - panic("arm UnknownCode is not set") - } - - return val -} - -// GetUnknownCode retrieves the UnknownCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetUnknownCode() (result ScUnknownErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "UnknownCode" { - result = *u.UnknownCode - ok = true - } - - return -} - -// MustValCode retrieves the ValCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustValCode() ScHostValErrorCode { - val, ok := u.GetValCode() - - if !ok { - panic("arm ValCode is not set") - } - - return val -} - -// GetValCode retrieves the ValCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetValCode() (result ScHostValErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ValCode" { - result = *u.ValCode - ok = true - } - - return -} - -// MustObjCode retrieves the ObjCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustObjCode() ScHostObjErrorCode { - val, ok := u.GetObjCode() - - if !ok { - panic("arm ObjCode is not set") - } - - return val -} - -// GetObjCode retrieves the ObjCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetObjCode() (result ScHostObjErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ObjCode" { - result = *u.ObjCode - ok = true - } - - return -} - -// MustFnCode retrieves the FnCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustFnCode() ScHostFnErrorCode { - val, ok := u.GetFnCode() - - if !ok { - panic("arm FnCode is not set") - } - - return val -} - -// GetFnCode retrieves the FnCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetFnCode() (result ScHostFnErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "FnCode" { - result = *u.FnCode - ok = true - } - - return -} - -// MustStorageCode retrieves the StorageCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustStorageCode() ScHostStorageErrorCode { - val, ok := u.GetStorageCode() - - if !ok { - panic("arm StorageCode is not set") - } - - return val -} - -// GetStorageCode retrieves the StorageCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetStorageCode() (result ScHostStorageErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "StorageCode" { - result = *u.StorageCode - ok = true - } - - return -} - -// MustContextCode retrieves the ContextCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustContextCode() ScHostContextErrorCode { - val, ok := u.GetContextCode() - - if !ok { - panic("arm ContextCode is not set") - } - - return val -} - -// GetContextCode retrieves the ContextCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetContextCode() (result ScHostContextErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ContextCode" { - result = *u.ContextCode - ok = true - } - - return -} - -// MustVmCode retrieves the VmCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustVmCode() ScVmErrorCode { - val, ok := u.GetVmCode() - - if !ok { - panic("arm VmCode is not set") - } - - return val -} - -// GetVmCode retrieves the VmCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetVmCode() (result ScVmErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "VmCode" { - result = *u.VmCode - ok = true - } - - return -} - -// MustContractCode retrieves the ContractCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustContractCode() Uint32 { - val, ok := u.GetContractCode() - - if !ok { - panic("arm ContractCode is not set") - } - - return val -} - -// GetContractCode retrieves the ContractCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetContractCode() (result Uint32, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "ContractCode" { - result = *u.ContractCode - ok = true - } - - return -} - -// MustAuthCode retrieves the AuthCode value from the union, -// panicing if the value is not set. -func (u ScStatus) MustAuthCode() ScHostAuthErrorCode { - val, ok := u.GetAuthCode() - - if !ok { - panic("arm AuthCode is not set") - } - - return val -} - -// GetAuthCode retrieves the AuthCode value from the union, -// returning ok if the union's switch indicated the value is valid. -func (u ScStatus) GetAuthCode() (result ScHostAuthErrorCode, ok bool) { - armName, _ := u.ArmForSwitch(int32(u.Type)) - - if armName == "AuthCode" { - result = *u.AuthCode - ok = true - } - - return +// SCErrorType type; +// SCErrorCode code; +// }; +type ScError struct { + Type ScErrorType + Code ScErrorCode } // EncodeTo encodes this value using the Encoder. -func (u ScStatus) EncodeTo(e *xdr.Encoder) error { +func (s *ScError) EncodeTo(e *xdr.Encoder) error { var err error - if err = u.Type.EncodeTo(e); err != nil { + if err = s.Type.EncodeTo(e); err != nil { return err } - switch ScStatusType(u.Type) { - case ScStatusTypeSstOk: - // Void - return nil - case ScStatusTypeSstUnknownError: - if err = (*u.UnknownCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstHostValueError: - if err = (*u.ValCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstHostObjectError: - if err = (*u.ObjCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstHostFunctionError: - if err = (*u.FnCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstHostStorageError: - if err = (*u.StorageCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstHostContextError: - if err = (*u.ContextCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstVmError: - if err = (*u.VmCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstContractError: - if err = (*u.ContractCode).EncodeTo(e); err != nil { - return err - } - return nil - case ScStatusTypeSstHostAuthError: - if err = (*u.AuthCode).EncodeTo(e); err != nil { - return err - } - return nil + if err = s.Code.EncodeTo(e); err != nil { + return err } - return fmt.Errorf("Type (ScStatusType) switch value '%d' is not valid for union ScStatus", u.Type) + return nil } -var _ decoderFrom = (*ScStatus)(nil) +var _ decoderFrom = (*ScError)(nil) // DecodeFrom decodes this value using the Decoder. -func (u *ScStatus) DecodeFrom(d *xdr.Decoder) (int, error) { +func (s *ScError) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - nTmp, err = u.Type.DecodeFrom(d) + nTmp, err = s.Type.DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScStatusType: %s", err) + return n, fmt.Errorf("decoding ScErrorType: %s", err) } - switch ScStatusType(u.Type) { - case ScStatusTypeSstOk: - // Void - return n, nil - case ScStatusTypeSstUnknownError: - u.UnknownCode = new(ScUnknownErrorCode) - nTmp, err = (*u.UnknownCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScUnknownErrorCode: %s", err) - } - return n, nil - case ScStatusTypeSstHostValueError: - u.ValCode = new(ScHostValErrorCode) - nTmp, err = (*u.ValCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScHostValErrorCode: %s", err) - } - return n, nil - case ScStatusTypeSstHostObjectError: - u.ObjCode = new(ScHostObjErrorCode) - nTmp, err = (*u.ObjCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScHostObjErrorCode: %s", err) - } - return n, nil - case ScStatusTypeSstHostFunctionError: - u.FnCode = new(ScHostFnErrorCode) - nTmp, err = (*u.FnCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScHostFnErrorCode: %s", err) - } - return n, nil - case ScStatusTypeSstHostStorageError: - u.StorageCode = new(ScHostStorageErrorCode) - nTmp, err = (*u.StorageCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScHostStorageErrorCode: %s", err) - } - return n, nil - case ScStatusTypeSstHostContextError: - u.ContextCode = new(ScHostContextErrorCode) - nTmp, err = (*u.ContextCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScHostContextErrorCode: %s", err) - } - return n, nil - case ScStatusTypeSstVmError: - u.VmCode = new(ScVmErrorCode) - nTmp, err = (*u.VmCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScVmErrorCode: %s", err) - } - return n, nil - case ScStatusTypeSstContractError: - u.ContractCode = new(Uint32) - nTmp, err = (*u.ContractCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding Uint32: %s", err) - } - return n, nil - case ScStatusTypeSstHostAuthError: - u.AuthCode = new(ScHostAuthErrorCode) - nTmp, err = (*u.AuthCode).DecodeFrom(d) - n += nTmp - if err != nil { - return n, fmt.Errorf("decoding ScHostAuthErrorCode: %s", err) - } - return n, nil + nTmp, err = s.Code.DecodeFrom(d) + n += nTmp + if err != nil { + return n, fmt.Errorf("decoding ScErrorCode: %s", err) } - return n, fmt.Errorf("union ScStatus has invalid Type (ScStatusType) switch value '%d'", u.Type) + return n, nil } // MarshalBinary implements encoding.BinaryMarshaler. -func (s ScStatus) MarshalBinary() ([]byte, error) { +func (s ScError) MarshalBinary() ([]byte, error) { b := bytes.Buffer{} e := xdr.NewEncoder(&b) err := s.EncodeTo(e) @@ -49366,7 +47305,7 @@ func (s ScStatus) MarshalBinary() ([]byte, error) { } // UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (s *ScStatus) UnmarshalBinary(inp []byte) error { +func (s *ScError) UnmarshalBinary(inp []byte) error { r := bytes.NewReader(inp) d := xdr.NewDecoder(r) _, err := s.DecodeFrom(d) @@ -49374,15 +47313,15 @@ func (s *ScStatus) UnmarshalBinary(inp []byte) error { } var ( - _ encoding.BinaryMarshaler = (*ScStatus)(nil) - _ encoding.BinaryUnmarshaler = (*ScStatus)(nil) + _ encoding.BinaryMarshaler = (*ScError)(nil) + _ encoding.BinaryUnmarshaler = (*ScError)(nil) ) // xdrType signals that this type is an type representing // representing XDR values defined by this package. -func (s ScStatus) xdrType() {} +func (s ScError) xdrType() {} -var _ xdrType = (*ScStatus)(nil) +var _ xdrType = (*ScError)(nil) // UInt128Parts is an XDR Struct defines as: // @@ -50198,11 +48137,6 @@ func (s ScAddress) xdrType() {} var _ xdrType = (*ScAddress)(nil) -// ScvalLimit is an XDR Const defines as: -// -// const SCVAL_LIMIT = 256000; -const ScvalLimit = 256000 - // ScsymbolLimit is an XDR Const defines as: // // const SCSYMBOL_LIMIT = 32; @@ -50210,14 +48144,9 @@ const ScsymbolLimit = 32 // ScVec is an XDR Typedef defines as: // -// typedef SCVal SCVec; +// typedef SCVal SCVec<>; type ScVec []ScVal -// XDRMaxSize implements the Sized interface for ScVec -func (e ScVec) XDRMaxSize() int { - return 256000 -} - // EncodeTo encodes this value using the Encoder. func (s ScVec) EncodeTo(e *xdr.Encoder) error { var err error @@ -50244,9 +48173,6 @@ func (s *ScVec) DecodeFrom(d *xdr.Decoder) (int, error) { if err != nil { return n, fmt.Errorf("decoding ScVal: %s", err) } - if l > 256000 { - return n, fmt.Errorf("decoding ScVal: data size (%d) exceeds size limit (256000)", l) - } (*s) = nil if l > 0 { (*s) = make([]ScVal, l) @@ -50290,14 +48216,9 @@ var _ xdrType = (*ScVec)(nil) // ScMap is an XDR Typedef defines as: // -// typedef SCMapEntry SCMap; +// typedef SCMapEntry SCMap<>; type ScMap []ScMapEntry -// XDRMaxSize implements the Sized interface for ScMap -func (e ScMap) XDRMaxSize() int { - return 256000 -} - // EncodeTo encodes this value using the Encoder. func (s ScMap) EncodeTo(e *xdr.Encoder) error { var err error @@ -50324,9 +48245,6 @@ func (s *ScMap) DecodeFrom(d *xdr.Decoder) (int, error) { if err != nil { return n, fmt.Errorf("decoding ScMapEntry: %s", err) } - if l > 256000 { - return n, fmt.Errorf("decoding ScMapEntry: data size (%d) exceeds size limit (256000)", l) - } (*s) = nil if l > 0 { (*s) = make([]ScMapEntry, l) @@ -50370,14 +48288,9 @@ var _ xdrType = (*ScMap)(nil) // ScBytes is an XDR Typedef defines as: // -// typedef opaque SCBytes; +// typedef opaque SCBytes<>; type ScBytes []byte -// XDRMaxSize implements the Sized interface for ScBytes -func (e ScBytes) XDRMaxSize() int { - return 256000 -} - // EncodeTo encodes this value using the Encoder. func (s ScBytes) EncodeTo(e *xdr.Encoder) error { var err error @@ -50393,7 +48306,7 @@ var _ decoderFrom = (*ScBytes)(nil) func (s *ScBytes) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int - (*s), nTmp, err = d.DecodeOpaque(256000) + (*s), nTmp, err = d.DecodeOpaque(0) n += nTmp if err != nil { return n, fmt.Errorf("decoding ScBytes: %s", err) @@ -50430,14 +48343,9 @@ var _ xdrType = (*ScBytes)(nil) // ScString is an XDR Typedef defines as: // -// typedef string SCString; +// typedef string SCString<>; type ScString string -// XDRMaxSize implements the Sized interface for ScString -func (e ScString) XDRMaxSize() int { - return 256000 -} - // EncodeTo encodes this value using the Encoder. func (s ScString) EncodeTo(e *xdr.Encoder) error { var err error @@ -50454,7 +48362,7 @@ func (s *ScString) DecodeFrom(d *xdr.Decoder) (int, error) { var err error var n, nTmp int var v string - v, nTmp, err = d.DecodeString(256000) + v, nTmp, err = d.DecodeString(0) n += nTmp if err != nil { return n, fmt.Errorf("decoding ScString: %s", err) @@ -50620,8 +48528,8 @@ var _ xdrType = (*ScNonceKey)(nil) // bool b; // case SCV_VOID: // void; -// case SCV_STATUS: -// SCStatus error; +// case SCV_ERROR: +// SCError error; // // case SCV_U32: // uint32 u32; @@ -50676,7 +48584,7 @@ var _ xdrType = (*ScNonceKey)(nil) type ScVal struct { Type ScValType B *bool - Error *ScStatus + Error *ScError U32 *Uint32 I32 *Int32 U64 *Uint64 @@ -50711,7 +48619,7 @@ func (u ScVal) ArmForSwitch(sw int32) (string, bool) { return "B", true case ScValTypeScvVoid: return "", true - case ScValTypeScvStatus: + case ScValTypeScvError: return "Error", true case ScValTypeScvU32: return "U32", true @@ -50768,10 +48676,10 @@ func NewScVal(aType ScValType, value interface{}) (result ScVal, err error) { result.B = &tv case ScValTypeScvVoid: // void - case ScValTypeScvStatus: - tv, ok := value.(ScStatus) + case ScValTypeScvError: + tv, ok := value.(ScError) if !ok { - err = fmt.Errorf("invalid value, must be ScStatus") + err = fmt.Errorf("invalid value, must be ScError") return } result.Error = &tv @@ -50934,7 +48842,7 @@ func (u ScVal) GetB() (result bool, ok bool) { // MustError retrieves the Error value from the union, // panicing if the value is not set. -func (u ScVal) MustError() ScStatus { +func (u ScVal) MustError() ScError { val, ok := u.GetError() if !ok { @@ -50946,7 +48854,7 @@ func (u ScVal) MustError() ScStatus { // GetError retrieves the Error value from the union, // returning ok if the union's switch indicated the value is valid. -func (u ScVal) GetError() (result ScStatus, ok bool) { +func (u ScVal) GetError() (result ScError, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) if armName == "Error" { @@ -51422,7 +49330,7 @@ func (u ScVal) EncodeTo(e *xdr.Encoder) error { case ScValTypeScvVoid: // Void return nil - case ScValTypeScvStatus: + case ScValTypeScvError: if err = (*u.Error).EncodeTo(e); err != nil { return err } @@ -51557,12 +49465,12 @@ func (u *ScVal) DecodeFrom(d *xdr.Decoder) (int, error) { case ScValTypeScvVoid: // Void return n, nil - case ScValTypeScvStatus: - u.Error = new(ScStatus) + case ScValTypeScvError: + u.Error = new(ScError) nTmp, err = (*u.Error).DecodeFrom(d) n += nTmp if err != nil { - return n, fmt.Errorf("decoding ScStatus: %s", err) + return n, fmt.Errorf("decoding ScError: %s", err) } return n, nil case ScValTypeScvU32: