fix pump wrapper buy and sell
This commit is contained in:
30
tx_binary.go
30
tx_binary.go
@@ -1191,7 +1191,7 @@ func (enc *txBinaryEncoder) writeTxBinaryBody(tx *TxBinary, enumTable *txBinaryE
|
||||
func (enc *txBinaryEncoder) writePlatformEntries(entries []PlatformBinary, enumTable *txBinaryEnumTable) error {
|
||||
enc.writeUint32(uint32(len(entries)))
|
||||
for i, entry := range entries {
|
||||
enumID, err := enumTable.platforms.id(entry.Platform)
|
||||
enumID, err := enumTable.platforms.idOrFallback(entry.Platform, PlatformNone)
|
||||
if err != nil {
|
||||
return fmt.Errorf("platform[%d]: %w", i, err)
|
||||
}
|
||||
@@ -1204,7 +1204,7 @@ func (enc *txBinaryEncoder) writePlatformEntries(entries []PlatformBinary, enumT
|
||||
func (enc *txBinaryEncoder) writeMevAgentEntries(entries []MevAgentBinary, enumTable *txBinaryEnumTable) error {
|
||||
enc.writeUint32(uint32(len(entries)))
|
||||
for i, entry := range entries {
|
||||
enumID, err := enumTable.mevAgents.id(entry.MevAgent)
|
||||
enumID, err := enumTable.mevAgents.idOrFallback(entry.MevAgent, MevAgentUnknown)
|
||||
if err != nil {
|
||||
return fmt.Errorf("mev_agent[%d]: %w", i, err)
|
||||
}
|
||||
@@ -1592,7 +1592,7 @@ func txBinaryReadPlatformEntries(dec txBinaryBodyReader, enumTable *txBinaryEnum
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
platform, err := enumTable.platforms.value(enumID)
|
||||
platform, err := enumTable.platforms.valueOrFallback(enumID, PlatformNone)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("platform[%d]: %w", i, err)
|
||||
}
|
||||
@@ -1619,7 +1619,7 @@ func txBinaryReadMevAgentEntries(dec txBinaryBodyReader, enumTable *txBinaryEnum
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mevAgent, err := enumTable.mevAgents.value(enumID)
|
||||
mevAgent, err := enumTable.mevAgents.valueOrFallback(enumID, MevAgentUnknown)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("mev_agent[%d]: %w", i, err)
|
||||
}
|
||||
@@ -2144,6 +2144,7 @@ var txBinaryEnumTables = map[uint16]*txBinaryEnumTable{
|
||||
MevAgentAllenhark,
|
||||
MevAgentRaiden,
|
||||
MevAgentZan,
|
||||
MevAgentTunneling,
|
||||
},
|
||||
),
|
||||
}
|
||||
@@ -2199,9 +2200,30 @@ func (set txBinaryEnumSet) id(value string) (uint16, error) {
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (set txBinaryEnumSet) idOrFallback(value string, fallback string) (uint16, error) {
|
||||
if id, ok := set.ids[value]; ok {
|
||||
return id, nil
|
||||
}
|
||||
id, ok := set.ids[fallback]
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("unsupported %s fallback enum value %q for versioned tx binary", set.name, fallback)
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (set txBinaryEnumSet) value(id uint16) (string, error) {
|
||||
if int(id) >= len(set.values) {
|
||||
return "", fmt.Errorf("unknown %s enum id %d", set.name, id)
|
||||
}
|
||||
return set.values[id], nil
|
||||
}
|
||||
|
||||
func (set txBinaryEnumSet) valueOrFallback(id uint16, fallback string) (string, error) {
|
||||
if int(id) < len(set.values) {
|
||||
return set.values[id], nil
|
||||
}
|
||||
if _, ok := set.ids[fallback]; !ok {
|
||||
return "", fmt.Errorf("unsupported %s fallback enum value %q for versioned tx binary", set.name, fallback)
|
||||
}
|
||||
return fallback, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user