errors.gno
3.35 Kb · 78 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
54 // batch
55 errInvalidBatchInstruction = "invalid batch instruction"
56 errBatchAckCountMismatch = "batch ack count mismatch"
57
58 // voucher
59 errAmountOverflow = "amount overflows int64"
60 errVoucherNotFound = "voucher not found"
61 errVoucherSymbolAlreadyRegistered = "voucher symbol already registered under a different denom"
62
63 // rate limit
64 errTokenBucketAbsent = "token bucket is absent"
65
66 // coins / channel balance
67 errCoinMismatch = "zkgm/coins: sent coin mismatch"
68 errChannelBalanceUnderflow = "zkgm/channel_balance: underflow"
69 errChannelBalanceOverflow = "zkgm/channel_balance: overflow"
70
71 // ErrSpoofedRealm guards non-crossing (_ int, rlm realm, ...) entrypoints: the
72 // passed rlm must be the current crossing frame, not a forged or stale token.
73 errSpoofedRealm = "rlm does not match the current crossing frame"
74)
75
76func makeError(msgs ...string) error {
77 return errors.New(strings.Join(msgs, ", "))
78}