Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

errors.gno

3.74 Kb · 83 lines
 1package ucs03_zkgm
 2
 3import (
 4	"errors"
 5	"strings"
 6)
 7
 8// Error messages for the zkgm v1 impl, collected in one place so the wording
 9// stays consistent. They are string constants rather than package-level error
10
11// values; build them with makeError at the call site (see above).
12const (
13	// opcode routing
14	errUnsupportedOpcode = "unsupported opcode"
15
16	// instruction decoding
17	errUnsupportedTokenOrderVersion = "unsupported token order version"
18	errUnsupportedCallVersion       = "unsupported call version"
19	errUnsupportedBatchVersion      = "unsupported batch version"
20	errUnsupportedForwardVersion    = "unsupported forward version"
21
22	// token order
23	errInvalidUnescrow                    = "invalid token order unescrow"
24	errTokenOrderFeeUnderflow             = "token order fee underflow: quote amount exceeds base amount"
25	errUnknownTokenOrderKind              = "unknown token order kind"
26	errUnknownFillType                    = "unknown fill type"
27	errUnsupportedTokenOrderKindForAck    = "unsupported token order kind for ack"
28	errUnsupportedTokenOrderKindForRefund = "unsupported token order kind for refund"
29	errSolveNotImplemented                = "solve token order not implemented"
30	errInvalidTokenOrderDestChannel       = "invalid token order destination channel"
31	errInvalidTokenOrderTransferAmount    = "invalid token order transfer amount"
32
33	// errMetadataDecimalsMismatch guards an INITIALIZE order's declared
34	// metadata decimals against the locally-known ground truth for its base
35	// denom (a registered grc20's real decimals, or a held voucher's recorded
36	// OriginDecimals when forwarding it onward). Left unchecked, the
37	// counterparty (or next hop) would deploy/interpret the wrapped copy at
38	// the wrong precision even though the raw amount moved correctly here.
39	errMetadataDecimalsMismatch = "token order: metadata decimals do not match the local token"
40
41	// call
42	errEurekaUnsupported     = "eureka mode not supported"
43	errInvalidCallSender     = "invalid call sender"
44	errReceiverNotRegistered = "receiver not registered"
45	errIsOnlyMakerAck        = "is only maker ack"
46
47	// forward
48	errInvalidForwardInstruction    = "invalid forward instruction"
49	errForwardMissingPrevDest       = "forward missing previous destination channel"
50	errForwardMissingNextSource     = "forward missing next source channel"
51	errForwardPrevDestMismatch      = "forward previous-destination mismatch"
52	errForwardZeroTimeout           = "forward timeout timestamp must be non-zero"
53	errForwardChildPacketTooLarge   = "forward child packet data too large"
54	errForwardChannelNotOwned       = "forward next-hop channel not owned by this realm"
55	errForwardChannelNotOpen        = "forward next-hop channel not open"
56	errForwardConnectionNotOpen     = "forward next-hop connection not open"
57	errForwardChildAlreadyCommitted = "forward child packet already committed"
58
59	// batch
60	errInvalidBatchInstruction = "invalid batch instruction"
61	errBatchAckCountMismatch   = "batch ack count mismatch"
62
63	// voucher
64	errAmountOverflow                 = "amount overflows int64"
65	errVoucherNotFound                = "voucher not found"
66	errVoucherSymbolAlreadyRegistered = "voucher symbol already registered under a different denom"
67
68	// rate limit
69	errTokenBucketAbsent = "token bucket is absent"
70
71	// coins / channel balance
72	errCoinMismatch            = "zkgm/coins: sent coin mismatch"
73	errChannelBalanceUnderflow = "zkgm/channel_balance: underflow"
74	errChannelBalanceOverflow  = "zkgm/channel_balance: overflow"
75
76	// ErrSpoofedRealm guards non-crossing (_ int, rlm realm, ...) entrypoints: the
77	// passed rlm must be the current crossing frame, not a forged or stale token.
78	errSpoofedRealm = "rlm does not match the current crossing frame"
79)
80
81func makeError(msgs ...string) error {
82	return errors.New(strings.Join(msgs, ", "))
83}