2025-01-16 22:06:59 +01:00
|
|
|
package bridge
|
2019-11-23 18:57:05 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2025-01-16 22:06:59 +01:00
|
|
|
wakutypes "github.com/status-im/status-go/waku/types"
|
|
|
|
|
2025-01-10 19:56:00 +01:00
|
|
|
wakuv1common "github.com/status-im/status-go/wakuv1/common"
|
|
|
|
wakuv2common "github.com/status-im/status-go/wakuv2/common"
|
2019-11-23 18:57:05 +01:00
|
|
|
)
|
|
|
|
|
2025-01-16 22:06:59 +01:00
|
|
|
// NewWakuEnvelopeErrorWrapper returns a wakutypes.EnvelopeError object that mimics Geth's EnvelopeError
|
|
|
|
func NewWakuEnvelopeErrorWrapper(envelopeError *wakuv1common.EnvelopeError) *wakutypes.EnvelopeError {
|
2019-11-23 18:57:05 +01:00
|
|
|
if envelopeError == nil {
|
|
|
|
panic("envelopeError should not be nil")
|
|
|
|
}
|
|
|
|
|
2025-01-16 22:06:59 +01:00
|
|
|
return &wakutypes.EnvelopeError{
|
2019-11-23 18:57:05 +01:00
|
|
|
Hash: types.Hash(envelopeError.Hash),
|
|
|
|
Code: mapGethErrorCode(envelopeError.Code),
|
|
|
|
Description: envelopeError.Description,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-16 22:06:59 +01:00
|
|
|
// NewWakuEnvelopeErrorWrapper returns a wakutypes.EnvelopeError object that mimics Geth's EnvelopeError
|
|
|
|
func NewWakuV2EnvelopeErrorWrapper(envelopeError *wakuv2common.EnvelopeError) *wakutypes.EnvelopeError {
|
2021-06-16 16:19:45 -04:00
|
|
|
if envelopeError == nil {
|
|
|
|
panic("envelopeError should not be nil")
|
|
|
|
}
|
|
|
|
|
2025-01-16 22:06:59 +01:00
|
|
|
return &wakutypes.EnvelopeError{
|
2021-06-16 16:19:45 -04:00
|
|
|
Hash: types.Hash(envelopeError.Hash),
|
|
|
|
Code: mapGethErrorCode(envelopeError.Code),
|
|
|
|
Description: envelopeError.Description,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-23 18:57:05 +01:00
|
|
|
func mapGethErrorCode(code uint) uint {
|
|
|
|
switch code {
|
2025-01-10 19:56:00 +01:00
|
|
|
case wakuv1common.EnvelopeTimeNotSynced:
|
2025-01-16 22:06:59 +01:00
|
|
|
return wakutypes.EnvelopeTimeNotSynced
|
2025-01-10 19:56:00 +01:00
|
|
|
case wakuv1common.EnvelopeOtherError:
|
2025-01-16 22:06:59 +01:00
|
|
|
return wakutypes.EnvelopeOtherError
|
2019-11-23 18:57:05 +01:00
|
|
|
}
|
2025-01-16 22:06:59 +01:00
|
|
|
return wakutypes.EnvelopeOtherError
|
2019-11-23 18:57:05 +01:00
|
|
|
}
|