_id
stringlengths 2
7
| title
stringlengths 1
118
| partition
stringclasses 3
values | text
stringlengths 52
85.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q182000
|
Through
|
test
|
func (pathSend PayWithPath) Through(asset Asset) PayWithPath {
pathSend.Path = append(pathSend.Path, asset)
return pathSend
}
|
go
|
{
"resource": ""
}
|
q182001
|
PayWith
|
test
|
func PayWith(sendAsset Asset, maxAmount string) PayWithPath {
return PayWithPath{
Asset: sendAsset,
MaxAmount: maxAmount,
}
}
|
go
|
{
"resource": ""
}
|
q182002
|
continuedFraction
|
test
|
func continuedFraction(price string) (xdrPrice xdr.Price, err error) {
number := &big.Rat{}
maxInt32 := &big.Rat{}
zero := &big.Rat{}
one := &big.Rat{}
_, ok := number.SetString(price)
if !ok {
return xdrPrice, fmt.Errorf("cannot parse price: %s", price)
}
maxInt32.SetInt64(int64(math.MaxInt32))
zero.SetInt64(int64(0))
one.SetInt64(int64(1))
fractions := [][2]*big.Rat{
{zero, one},
{one, zero},
}
i := 2
for {
if number.Cmp(maxInt32) == 1 {
break
}
f := &big.Rat{}
h := &big.Rat{}
k := &big.Rat{}
a := floor(number)
f.Sub(number, a)
h.Mul(a, fractions[i-1][0])
h.Add(h, fractions[i-2][0])
k.Mul(a, fractions[i-1][1])
k.Add(k, fractions[i-2][1])
if h.Cmp(maxInt32) == 1 || k.Cmp(maxInt32) == 1 {
break
}
fractions = append(fractions, [2]*big.Rat{h, k})
if f.Cmp(zero) == 0 {
break
}
number.Quo(one, f)
i++
}
n, d := fractions[len(fractions)-1][0], fractions[len(fractions)-1][1]
if n.Cmp(zero) == 0 || d.Cmp(zero) == 0 {
return xdrPrice, errors.New("Couldn't find approximation")
}
return xdr.Price{
N: xdr.Int32(n.Num().Int64()),
D: xdr.Int32(d.Num().Int64()),
}, nil
}
|
go
|
{
"resource": ""
}
|
q182003
|
Mutate
|
test
|
func (b *TransactionEnvelopeBuilder) Mutate(muts ...TransactionEnvelopeMutator) {
b.Init()
for _, m := range muts {
err := m.MutateTransactionEnvelope(b)
if err != nil {
b.Err = err
return
}
}
}
|
go
|
{
"resource": ""
}
|
q182004
|
MutateTX
|
test
|
func (b *TransactionEnvelopeBuilder) MutateTX(muts ...TransactionMutator) {
b.Init()
if b.Err != nil {
return
}
b.child.Mutate(muts...)
b.Err = b.child.Err
}
|
go
|
{
"resource": ""
}
|
q182005
|
Bytes
|
test
|
func (b *TransactionEnvelopeBuilder) Bytes() ([]byte, error) {
if b.Err != nil {
return nil, b.Err
}
var txBytes bytes.Buffer
_, err := xdr.Marshal(&txBytes, b.E)
if err != nil {
return nil, err
}
return txBytes.Bytes(), nil
}
|
go
|
{
"resource": ""
}
|
q182006
|
Base64
|
test
|
func (b *TransactionEnvelopeBuilder) Base64() (string, error) {
bs, err := b.Bytes()
return base64.StdEncoding.EncodeToString(bs), err
}
|
go
|
{
"resource": ""
}
|
q182007
|
MutateTransactionEnvelope
|
test
|
func (m *TransactionBuilder) MutateTransactionEnvelope(txe *TransactionEnvelopeBuilder) error {
if m.Err != nil {
return m.Err
}
txe.E.Tx = *m.TX
newChild := *m
txe.child = &newChild
m.TX = &txe.E.Tx
return nil
}
|
go
|
{
"resource": ""
}
|
q182008
|
MutateSetOptions
|
test
|
func (m HomeDomain) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
if len(m) > 32 {
return errors.New("HomeDomain is too long")
}
value := xdr.String32(m)
o.HomeDomain = &value
return
}
|
go
|
{
"resource": ""
}
|
q182009
|
MutateSetOptions
|
test
|
func (m InflationDest) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
o.InflationDest = &xdr.AccountId{}
err = setAccountId(string(m), o.InflationDest)
return
}
|
go
|
{
"resource": ""
}
|
q182010
|
MutateSetOptions
|
test
|
func (m MasterWeight) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
val := xdr.Uint32(m)
o.MasterWeight = &val
return
}
|
go
|
{
"resource": ""
}
|
q182011
|
MutateSetOptions
|
test
|
func (m Signer) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
var signer xdr.Signer
signer.Weight = xdr.Uint32(m.Weight)
err = setAccountId(m.PublicKey, &signer.PubKey)
o.Signer = &signer
return
}
|
go
|
{
"resource": ""
}
|
q182012
|
SetThresholds
|
test
|
func SetThresholds(low, medium, high uint32) Thresholds {
return Thresholds{
Low: &low,
Medium: &medium,
High: &high,
}
}
|
go
|
{
"resource": ""
}
|
q182013
|
MutateSetOptions
|
test
|
func (m Thresholds) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
if m.Low != nil {
val := xdr.Uint32(*m.Low)
o.LowThreshold = &val
}
if m.Medium != nil {
val := xdr.Uint32(*m.Medium)
o.MedThreshold = &val
}
if m.High != nil {
val := xdr.Uint32(*m.High)
o.HighThreshold = &val
}
return
}
|
go
|
{
"resource": ""
}
|
q182014
|
MutateSetOptions
|
test
|
func (m SetFlag) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
if !isFlagValid(xdr.AccountFlags(m)) {
return errors.New("Unknown flag in SetFlag mutator")
}
var val xdr.Uint32
if o.SetFlags == nil {
val = xdr.Uint32(m)
} else {
val = xdr.Uint32(m) | *o.SetFlags
}
o.SetFlags = &val
return
}
|
go
|
{
"resource": ""
}
|
q182015
|
MutateSetOptions
|
test
|
func (m ClearFlag) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
if !isFlagValid(xdr.AccountFlags(m)) {
return errors.New("Unknown flag in SetFlag mutator")
}
var val xdr.Uint32
if o.ClearFlags == nil {
val = xdr.Uint32(m)
} else {
val = xdr.Uint32(m) | *o.ClearFlags
}
o.ClearFlags = &val
return
}
|
go
|
{
"resource": ""
}
|
q182016
|
MutateCreateAccount
|
test
|
func (m Destination) MutateCreateAccount(o *xdr.CreateAccountOp) error {
return setAccountId(m.AddressOrSeed, &o.Destination)
}
|
go
|
{
"resource": ""
}
|
q182017
|
MutateCreateAccount
|
test
|
func (m NativeAmount) MutateCreateAccount(o *xdr.CreateAccountOp) (err error) {
o.StartingBalance, err = amount.Parse(m.Amount)
return
}
|
go
|
{
"resource": ""
}
|
q182018
|
Random
|
test
|
func Random() (*Full, error) {
var rawSeed [32]byte
_, err := io.ReadFull(rand.Reader, rawSeed[:])
if err != nil {
return nil, err
}
kp, err := FromRawSeed(rawSeed)
if err != nil {
return nil, err
}
return kp, nil
}
|
go
|
{
"resource": ""
}
|
q182019
|
Master
|
test
|
func Master(networkPassphrase string) KP {
kp, err := FromRawSeed(network.ID(networkPassphrase))
if err != nil {
panic(err)
}
return kp
}
|
go
|
{
"resource": ""
}
|
q182020
|
Parse
|
test
|
func Parse(addressOrSeed string) (KP, error) {
_, err := strkey.Decode(strkey.VersionByteAccountID, addressOrSeed)
if err == nil {
return &FromAddress{addressOrSeed}, nil
}
if err != strkey.ErrInvalidVersionByte {
return nil, err
}
_, err = strkey.Decode(strkey.VersionByteSeed, addressOrSeed)
if err == nil {
return &Full{addressOrSeed}, nil
}
return nil, err
}
|
go
|
{
"resource": ""
}
|
q182021
|
MustParse
|
test
|
func MustParse(addressOrSeed string) KP {
kp, err := Parse(addressOrSeed)
if err != nil {
panic(err)
}
return kp
}
|
go
|
{
"resource": ""
}
|
q182022
|
MutateAllowTrust
|
test
|
func (m Authorize) MutateAllowTrust(o *xdr.AllowTrustOp) error {
o.Authorize = m.Value
return nil
}
|
go
|
{
"resource": ""
}
|
q182023
|
MutateAllowTrust
|
test
|
func (m AllowTrustAsset) MutateAllowTrust(o *xdr.AllowTrustOp) (err error) {
length := len(m.Code)
switch {
case length >= 1 && length <= 4:
var code [4]byte
byteArray := []byte(m.Code)
copy(code[:], byteArray[0:length])
o.Asset, err = xdr.NewAllowTrustOpAsset(xdr.AssetTypeAssetTypeCreditAlphanum4, code)
case length >= 5 && length <= 12:
var code [12]byte
byteArray := []byte(m.Code)
copy(code[:], byteArray[0:length])
o.Asset, err = xdr.NewAllowTrustOpAsset(xdr.AssetTypeAssetTypeCreditAlphanum12, code)
default:
err = errors.New("Asset code length is invalid")
}
return
}
|
go
|
{
"resource": ""
}
|
q182024
|
MutateAllowTrust
|
test
|
func (m Trustor) MutateAllowTrust(o *xdr.AllowTrustOp) error {
return setAccountId(m.Address, &o.Trustor)
}
|
go
|
{
"resource": ""
}
|
q182025
|
ToAsset
|
test
|
func (a AllowTrustOpAsset) ToAsset(issuer AccountId) (ret Asset) {
var err error
switch a.Type {
case AssetTypeAssetTypeCreditAlphanum4:
ret, err = NewAsset(AssetTypeAssetTypeCreditAlphanum4, AssetAlphaNum4{
AssetCode: a.MustAssetCode4(),
Issuer: issuer,
})
case AssetTypeAssetTypeCreditAlphanum12:
ret, err = NewAsset(AssetTypeAssetTypeCreditAlphanum12, AssetAlphaNum12{
AssetCode: a.MustAssetCode12(),
Issuer: issuer,
})
default:
err = fmt.Errorf("Unexpected type for AllowTrustOpAsset: %d", a.Type)
}
if err != nil {
panic(err)
}
return
}
|
go
|
{
"resource": ""
}
|
q182026
|
SetNative
|
test
|
func (a *Asset) SetNative() error {
newa, err := NewAsset(AssetTypeAssetTypeNative, nil)
if err != nil {
return err
}
*a = newa
return nil
}
|
go
|
{
"resource": ""
}
|
q182027
|
String
|
test
|
func (a Asset) String() string {
var t, c, i string
a.MustExtract(&t, &c, &i)
if a.Type == AssetTypeAssetTypeNative {
return t
}
return fmt.Sprintf("%s/%s/%s", t, c, i)
}
|
go
|
{
"resource": ""
}
|
q182028
|
Equals
|
test
|
func (a Asset) Equals(other Asset) bool {
if a.Type != other.Type {
return false
}
switch a.Type {
case AssetTypeAssetTypeNative:
return true
case AssetTypeAssetTypeCreditAlphanum4:
l := a.MustAlphaNum4()
r := other.MustAlphaNum4()
return l.AssetCode == r.AssetCode && l.Issuer.Equals(r.Issuer)
case AssetTypeAssetTypeCreditAlphanum12:
l := a.MustAlphaNum12()
r := other.MustAlphaNum12()
return l.AssetCode == r.AssetCode && l.Issuer.Equals(r.Issuer)
default:
panic(fmt.Errorf("Unknown asset type: %v", a.Type))
}
}
|
go
|
{
"resource": ""
}
|
q182029
|
MustExtract
|
test
|
func (a Asset) MustExtract(typ interface{}, code interface{}, issuer interface{}) {
err := a.Extract(typ, code, issuer)
if err != nil {
panic(err)
}
}
|
go
|
{
"resource": ""
}
|
q182030
|
Unmarshal
|
test
|
func Unmarshal(r io.Reader, v interface{}) (int, error) {
// delegate to xdr package's Unmarshal
return xdr.Unmarshal(r, v)
}
|
go
|
{
"resource": ""
}
|
q182031
|
Marshal
|
test
|
func Marshal(w io.Writer, v interface{}) (int, error) {
// delegate to xdr package's Marshal
return xdr.Marshal(w, v)
}
|
go
|
{
"resource": ""
}
|
q182032
|
ValidEnum
|
test
|
func (e CryptoKeyType) ValidEnum(v int32) bool {
_, ok := cryptoKeyTypeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182033
|
NewPublicKey
|
test
|
func NewPublicKey(aType CryptoKeyType, value interface{}) (result PublicKey, err error) {
result.Type = aType
switch CryptoKeyType(aType) {
case CryptoKeyTypeKeyTypeEd25519:
tv, ok := value.(Uint256)
if !ok {
err = fmt.Errorf("invalid value, must be Uint256")
return
}
result.Ed25519 = &tv
}
return
}
|
go
|
{
"resource": ""
}
|
q182034
|
MustEd25519
|
test
|
func (u PublicKey) MustEd25519() Uint256 {
val, ok := u.GetEd25519()
if !ok {
panic("arm Ed25519 is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182035
|
NewNodeId
|
test
|
func NewNodeId(aType CryptoKeyType, value interface{}) (result NodeId, err error) {
u, err := NewPublicKey(aType, value)
result = NodeId(u)
return
}
|
go
|
{
"resource": ""
}
|
q182036
|
NewAccountId
|
test
|
func NewAccountId(aType CryptoKeyType, value interface{}) (result AccountId, err error) {
u, err := NewPublicKey(aType, value)
result = AccountId(u)
return
}
|
go
|
{
"resource": ""
}
|
q182037
|
ValidEnum
|
test
|
func (e AssetType) ValidEnum(v int32) bool {
_, ok := assetTypeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182038
|
ArmForSwitch
|
test
|
func (u Asset) ArmForSwitch(sw int32) (string, bool) {
switch AssetType(sw) {
case AssetTypeAssetTypeNative:
return "", true
case AssetTypeAssetTypeCreditAlphanum4:
return "AlphaNum4", true
case AssetTypeAssetTypeCreditAlphanum12:
return "AlphaNum12", true
}
return "-", false
}
|
go
|
{
"resource": ""
}
|
q182039
|
NewAsset
|
test
|
func NewAsset(aType AssetType, value interface{}) (result Asset, err error) {
result.Type = aType
switch AssetType(aType) {
case AssetTypeAssetTypeNative:
// void
case AssetTypeAssetTypeCreditAlphanum4:
tv, ok := value.(AssetAlphaNum4)
if !ok {
err = fmt.Errorf("invalid value, must be AssetAlphaNum4")
return
}
result.AlphaNum4 = &tv
case AssetTypeAssetTypeCreditAlphanum12:
tv, ok := value.(AssetAlphaNum12)
if !ok {
err = fmt.Errorf("invalid value, must be AssetAlphaNum12")
return
}
result.AlphaNum12 = &tv
}
return
}
|
go
|
{
"resource": ""
}
|
q182040
|
MustAlphaNum4
|
test
|
func (u Asset) MustAlphaNum4() AssetAlphaNum4 {
val, ok := u.GetAlphaNum4()
if !ok {
panic("arm AlphaNum4 is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182041
|
GetAlphaNum4
|
test
|
func (u Asset) GetAlphaNum4() (result AssetAlphaNum4, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "AlphaNum4" {
result = *u.AlphaNum4
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182042
|
MustAlphaNum12
|
test
|
func (u Asset) MustAlphaNum12() AssetAlphaNum12 {
val, ok := u.GetAlphaNum12()
if !ok {
panic("arm AlphaNum12 is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182043
|
GetAlphaNum12
|
test
|
func (u Asset) GetAlphaNum12() (result AssetAlphaNum12, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "AlphaNum12" {
result = *u.AlphaNum12
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182044
|
ValidEnum
|
test
|
func (e ThresholdIndexes) ValidEnum(v int32) bool {
_, ok := thresholdIndexesMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182045
|
ValidEnum
|
test
|
func (e LedgerEntryType) ValidEnum(v int32) bool {
_, ok := ledgerEntryTypeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182046
|
ValidEnum
|
test
|
func (e AccountFlags) ValidEnum(v int32) bool {
_, ok := accountFlagsMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182047
|
NewAccountEntryExt
|
test
|
func NewAccountEntryExt(v int32, value interface{}) (result AccountEntryExt, err error) {
result.V = v
switch int32(v) {
case 0:
// void
}
return
}
|
go
|
{
"resource": ""
}
|
q182048
|
ValidEnum
|
test
|
func (e TrustLineFlags) ValidEnum(v int32) bool {
_, ok := trustLineFlagsMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182049
|
NewTrustLineEntryExt
|
test
|
func NewTrustLineEntryExt(v int32, value interface{}) (result TrustLineEntryExt, err error) {
result.V = v
switch int32(v) {
case 0:
// void
}
return
}
|
go
|
{
"resource": ""
}
|
q182050
|
ValidEnum
|
test
|
func (e OfferEntryFlags) ValidEnum(v int32) bool {
_, ok := offerEntryFlagsMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182051
|
NewOfferEntryExt
|
test
|
func NewOfferEntryExt(v int32, value interface{}) (result OfferEntryExt, err error) {
result.V = v
switch int32(v) {
case 0:
// void
}
return
}
|
go
|
{
"resource": ""
}
|
q182052
|
NewDataEntryExt
|
test
|
func NewDataEntryExt(v int32, value interface{}) (result DataEntryExt, err error) {
result.V = v
switch int32(v) {
case 0:
// void
}
return
}
|
go
|
{
"resource": ""
}
|
q182053
|
NewLedgerEntryData
|
test
|
func NewLedgerEntryData(aType LedgerEntryType, value interface{}) (result LedgerEntryData, err error) {
result.Type = aType
switch LedgerEntryType(aType) {
case LedgerEntryTypeAccount:
tv, ok := value.(AccountEntry)
if !ok {
err = fmt.Errorf("invalid value, must be AccountEntry")
return
}
result.Account = &tv
case LedgerEntryTypeTrustline:
tv, ok := value.(TrustLineEntry)
if !ok {
err = fmt.Errorf("invalid value, must be TrustLineEntry")
return
}
result.TrustLine = &tv
case LedgerEntryTypeOffer:
tv, ok := value.(OfferEntry)
if !ok {
err = fmt.Errorf("invalid value, must be OfferEntry")
return
}
result.Offer = &tv
case LedgerEntryTypeData:
tv, ok := value.(DataEntry)
if !ok {
err = fmt.Errorf("invalid value, must be DataEntry")
return
}
result.Data = &tv
}
return
}
|
go
|
{
"resource": ""
}
|
q182054
|
NewLedgerEntryExt
|
test
|
func NewLedgerEntryExt(v int32, value interface{}) (result LedgerEntryExt, err error) {
result.V = v
switch int32(v) {
case 0:
// void
}
return
}
|
go
|
{
"resource": ""
}
|
q182055
|
ValidEnum
|
test
|
func (e EnvelopeType) ValidEnum(v int32) bool {
_, ok := envelopeTypeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182056
|
ValidEnum
|
test
|
func (e OperationType) ValidEnum(v int32) bool {
_, ok := operationTypeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182057
|
ArmForSwitch
|
test
|
func (u AllowTrustOpAsset) ArmForSwitch(sw int32) (string, bool) {
switch AssetType(sw) {
case AssetTypeAssetTypeCreditAlphanum4:
return "AssetCode4", true
case AssetTypeAssetTypeCreditAlphanum12:
return "AssetCode12", true
}
return "-", false
}
|
go
|
{
"resource": ""
}
|
q182058
|
NewAllowTrustOpAsset
|
test
|
func NewAllowTrustOpAsset(aType AssetType, value interface{}) (result AllowTrustOpAsset, err error) {
result.Type = aType
switch AssetType(aType) {
case AssetTypeAssetTypeCreditAlphanum4:
tv, ok := value.([4]byte)
if !ok {
err = fmt.Errorf("invalid value, must be [4]byte")
return
}
result.AssetCode4 = &tv
case AssetTypeAssetTypeCreditAlphanum12:
tv, ok := value.([12]byte)
if !ok {
err = fmt.Errorf("invalid value, must be [12]byte")
return
}
result.AssetCode12 = &tv
}
return
}
|
go
|
{
"resource": ""
}
|
q182059
|
MustAssetCode4
|
test
|
func (u AllowTrustOpAsset) MustAssetCode4() [4]byte {
val, ok := u.GetAssetCode4()
if !ok {
panic("arm AssetCode4 is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182060
|
GetAssetCode4
|
test
|
func (u AllowTrustOpAsset) GetAssetCode4() (result [4]byte, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "AssetCode4" {
result = *u.AssetCode4
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182061
|
MustAssetCode12
|
test
|
func (u AllowTrustOpAsset) MustAssetCode12() [12]byte {
val, ok := u.GetAssetCode12()
if !ok {
panic("arm AssetCode12 is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182062
|
GetAssetCode12
|
test
|
func (u AllowTrustOpAsset) GetAssetCode12() (result [12]byte, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "AssetCode12" {
result = *u.AssetCode12
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182063
|
NewOperationBody
|
test
|
func NewOperationBody(aType OperationType, value interface{}) (result OperationBody, err error) {
result.Type = aType
switch OperationType(aType) {
case OperationTypeCreateAccount:
tv, ok := value.(CreateAccountOp)
if !ok {
err = fmt.Errorf("invalid value, must be CreateAccountOp")
return
}
result.CreateAccountOp = &tv
case OperationTypePayment:
tv, ok := value.(PaymentOp)
if !ok {
err = fmt.Errorf("invalid value, must be PaymentOp")
return
}
result.PaymentOp = &tv
case OperationTypePathPayment:
tv, ok := value.(PathPaymentOp)
if !ok {
err = fmt.Errorf("invalid value, must be PathPaymentOp")
return
}
result.PathPaymentOp = &tv
case OperationTypeManageOffer:
tv, ok := value.(ManageOfferOp)
if !ok {
err = fmt.Errorf("invalid value, must be ManageOfferOp")
return
}
result.ManageOfferOp = &tv
case OperationTypeCreatePassiveOffer:
tv, ok := value.(CreatePassiveOfferOp)
if !ok {
err = fmt.Errorf("invalid value, must be CreatePassiveOfferOp")
return
}
result.CreatePassiveOfferOp = &tv
case OperationTypeSetOptions:
tv, ok := value.(SetOptionsOp)
if !ok {
err = fmt.Errorf("invalid value, must be SetOptionsOp")
return
}
result.SetOptionsOp = &tv
case OperationTypeChangeTrust:
tv, ok := value.(ChangeTrustOp)
if !ok {
err = fmt.Errorf("invalid value, must be ChangeTrustOp")
return
}
result.ChangeTrustOp = &tv
case OperationTypeAllowTrust:
tv, ok := value.(AllowTrustOp)
if !ok {
err = fmt.Errorf("invalid value, must be AllowTrustOp")
return
}
result.AllowTrustOp = &tv
case OperationTypeAccountMerge:
tv, ok := value.(AccountId)
if !ok {
err = fmt.Errorf("invalid value, must be AccountId")
return
}
result.Destination = &tv
case OperationTypeInflation:
// void
case OperationTypeManageData:
tv, ok := value.(ManageDataOp)
if !ok {
err = fmt.Errorf("invalid value, must be ManageDataOp")
return
}
result.ManageDataOp = &tv
}
return
}
|
go
|
{
"resource": ""
}
|
q182064
|
MustCreateAccountOp
|
test
|
func (u OperationBody) MustCreateAccountOp() CreateAccountOp {
val, ok := u.GetCreateAccountOp()
if !ok {
panic("arm CreateAccountOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182065
|
GetCreateAccountOp
|
test
|
func (u OperationBody) GetCreateAccountOp() (result CreateAccountOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "CreateAccountOp" {
result = *u.CreateAccountOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182066
|
MustPaymentOp
|
test
|
func (u OperationBody) MustPaymentOp() PaymentOp {
val, ok := u.GetPaymentOp()
if !ok {
panic("arm PaymentOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182067
|
GetPaymentOp
|
test
|
func (u OperationBody) GetPaymentOp() (result PaymentOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "PaymentOp" {
result = *u.PaymentOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182068
|
MustPathPaymentOp
|
test
|
func (u OperationBody) MustPathPaymentOp() PathPaymentOp {
val, ok := u.GetPathPaymentOp()
if !ok {
panic("arm PathPaymentOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182069
|
GetPathPaymentOp
|
test
|
func (u OperationBody) GetPathPaymentOp() (result PathPaymentOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "PathPaymentOp" {
result = *u.PathPaymentOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182070
|
MustManageOfferOp
|
test
|
func (u OperationBody) MustManageOfferOp() ManageOfferOp {
val, ok := u.GetManageOfferOp()
if !ok {
panic("arm ManageOfferOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182071
|
GetManageOfferOp
|
test
|
func (u OperationBody) GetManageOfferOp() (result ManageOfferOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "ManageOfferOp" {
result = *u.ManageOfferOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182072
|
MustCreatePassiveOfferOp
|
test
|
func (u OperationBody) MustCreatePassiveOfferOp() CreatePassiveOfferOp {
val, ok := u.GetCreatePassiveOfferOp()
if !ok {
panic("arm CreatePassiveOfferOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182073
|
GetCreatePassiveOfferOp
|
test
|
func (u OperationBody) GetCreatePassiveOfferOp() (result CreatePassiveOfferOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "CreatePassiveOfferOp" {
result = *u.CreatePassiveOfferOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182074
|
MustSetOptionsOp
|
test
|
func (u OperationBody) MustSetOptionsOp() SetOptionsOp {
val, ok := u.GetSetOptionsOp()
if !ok {
panic("arm SetOptionsOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182075
|
GetSetOptionsOp
|
test
|
func (u OperationBody) GetSetOptionsOp() (result SetOptionsOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "SetOptionsOp" {
result = *u.SetOptionsOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182076
|
MustChangeTrustOp
|
test
|
func (u OperationBody) MustChangeTrustOp() ChangeTrustOp {
val, ok := u.GetChangeTrustOp()
if !ok {
panic("arm ChangeTrustOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182077
|
GetChangeTrustOp
|
test
|
func (u OperationBody) GetChangeTrustOp() (result ChangeTrustOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "ChangeTrustOp" {
result = *u.ChangeTrustOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182078
|
MustAllowTrustOp
|
test
|
func (u OperationBody) MustAllowTrustOp() AllowTrustOp {
val, ok := u.GetAllowTrustOp()
if !ok {
panic("arm AllowTrustOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182079
|
GetAllowTrustOp
|
test
|
func (u OperationBody) GetAllowTrustOp() (result AllowTrustOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "AllowTrustOp" {
result = *u.AllowTrustOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182080
|
MustDestination
|
test
|
func (u OperationBody) MustDestination() AccountId {
val, ok := u.GetDestination()
if !ok {
panic("arm Destination is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182081
|
GetDestination
|
test
|
func (u OperationBody) GetDestination() (result AccountId, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Destination" {
result = *u.Destination
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182082
|
MustManageDataOp
|
test
|
func (u OperationBody) MustManageDataOp() ManageDataOp {
val, ok := u.GetManageDataOp()
if !ok {
panic("arm ManageDataOp is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182083
|
GetManageDataOp
|
test
|
func (u OperationBody) GetManageDataOp() (result ManageDataOp, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "ManageDataOp" {
result = *u.ManageDataOp
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182084
|
ValidEnum
|
test
|
func (e MemoType) ValidEnum(v int32) bool {
_, ok := memoTypeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182085
|
ArmForSwitch
|
test
|
func (u Memo) ArmForSwitch(sw int32) (string, bool) {
switch MemoType(sw) {
case MemoTypeMemoNone:
return "", true
case MemoTypeMemoText:
return "Text", true
case MemoTypeMemoId:
return "Id", true
case MemoTypeMemoHash:
return "Hash", true
case MemoTypeMemoReturn:
return "RetHash", true
}
return "-", false
}
|
go
|
{
"resource": ""
}
|
q182086
|
NewMemo
|
test
|
func NewMemo(aType MemoType, value interface{}) (result Memo, err error) {
result.Type = aType
switch MemoType(aType) {
case MemoTypeMemoNone:
// void
case MemoTypeMemoText:
tv, ok := value.(string)
if !ok {
err = fmt.Errorf("invalid value, must be string")
return
}
result.Text = &tv
case MemoTypeMemoId:
tv, ok := value.(Uint64)
if !ok {
err = fmt.Errorf("invalid value, must be Uint64")
return
}
result.Id = &tv
case MemoTypeMemoHash:
tv, ok := value.(Hash)
if !ok {
err = fmt.Errorf("invalid value, must be Hash")
return
}
result.Hash = &tv
case MemoTypeMemoReturn:
tv, ok := value.(Hash)
if !ok {
err = fmt.Errorf("invalid value, must be Hash")
return
}
result.RetHash = &tv
}
return
}
|
go
|
{
"resource": ""
}
|
q182087
|
MustText
|
test
|
func (u Memo) MustText() string {
val, ok := u.GetText()
if !ok {
panic("arm Text is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182088
|
GetText
|
test
|
func (u Memo) GetText() (result string, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Text" {
result = *u.Text
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182089
|
MustId
|
test
|
func (u Memo) MustId() Uint64 {
val, ok := u.GetId()
if !ok {
panic("arm Id is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182090
|
GetId
|
test
|
func (u Memo) GetId() (result Uint64, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Id" {
result = *u.Id
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182091
|
MustHash
|
test
|
func (u Memo) MustHash() Hash {
val, ok := u.GetHash()
if !ok {
panic("arm Hash is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182092
|
GetHash
|
test
|
func (u Memo) GetHash() (result Hash, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Hash" {
result = *u.Hash
ok = true
}
return
}
|
go
|
{
"resource": ""
}
|
q182093
|
MustRetHash
|
test
|
func (u Memo) MustRetHash() Hash {
val, ok := u.GetRetHash()
if !ok {
panic("arm RetHash is not set")
}
return val
}
|
go
|
{
"resource": ""
}
|
q182094
|
NewTransactionExt
|
test
|
func NewTransactionExt(v int32, value interface{}) (result TransactionExt, err error) {
result.V = v
switch int32(v) {
case 0:
// void
}
return
}
|
go
|
{
"resource": ""
}
|
q182095
|
ValidEnum
|
test
|
func (e CreateAccountResultCode) ValidEnum(v int32) bool {
_, ok := createAccountResultCodeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182096
|
ArmForSwitch
|
test
|
func (u CreateAccountResult) ArmForSwitch(sw int32) (string, bool) {
switch CreateAccountResultCode(sw) {
case CreateAccountResultCodeCreateAccountSuccess:
return "", true
default:
return "", true
}
}
|
go
|
{
"resource": ""
}
|
q182097
|
NewCreateAccountResult
|
test
|
func NewCreateAccountResult(code CreateAccountResultCode, value interface{}) (result CreateAccountResult, err error) {
result.Code = code
switch CreateAccountResultCode(code) {
case CreateAccountResultCodeCreateAccountSuccess:
// void
default:
// void
}
return
}
|
go
|
{
"resource": ""
}
|
q182098
|
ValidEnum
|
test
|
func (e PaymentResultCode) ValidEnum(v int32) bool {
_, ok := paymentResultCodeMap[v]
return ok
}
|
go
|
{
"resource": ""
}
|
q182099
|
ArmForSwitch
|
test
|
func (u PaymentResult) ArmForSwitch(sw int32) (string, bool) {
switch PaymentResultCode(sw) {
case PaymentResultCodePaymentSuccess:
return "", true
default:
return "", true
}
}
|
go
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.