@shunt-network/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/clients/typescript/src/__tests__/instruction-parsers.test.d.ts +1 -0
  2. package/dist/clients/typescript/src/__tests__/voucher-numeric-safety.test.d.ts +1 -0
  3. package/dist/clients/typescript/src/__tests__/voucher-types.test-d.d.ts +1 -0
  4. package/dist/clients/typescript/src/generated/accounts/channel.d.ts +59 -0
  5. package/dist/clients/typescript/src/generated/accounts/index.d.ts +8 -0
  6. package/dist/clients/typescript/src/generated/errors/index.d.ts +8 -0
  7. package/dist/clients/typescript/src/generated/errors/paymentChannels.d.ts +84 -0
  8. package/dist/clients/typescript/src/generated/index.d.ts +13 -0
  9. package/dist/clients/typescript/src/generated/instructions/distribute.d.ts +90 -0
  10. package/dist/clients/typescript/src/generated/instructions/emitEvent.d.ts +42 -0
  11. package/dist/clients/typescript/src/generated/instructions/index.d.ts +17 -0
  12. package/dist/clients/typescript/src/generated/instructions/open.d.ts +100 -0
  13. package/dist/clients/typescript/src/generated/instructions/reclaim.d.ts +39 -0
  14. package/dist/clients/typescript/src/generated/instructions/requestClose.d.ts +39 -0
  15. package/dist/clients/typescript/src/generated/instructions/seal.d.ts +36 -0
  16. package/dist/clients/typescript/src/generated/instructions/settle.d.ts +39 -0
  17. package/dist/clients/typescript/src/generated/instructions/settleAndSeal.d.ts +47 -0
  18. package/dist/clients/typescript/src/generated/instructions/topUp.d.ts +56 -0
  19. package/dist/clients/typescript/src/generated/instructions/withdrawPayer.d.ts +51 -0
  20. package/dist/clients/typescript/src/generated/pdas/eventAuthority.d.ts +11 -0
  21. package/dist/clients/typescript/src/generated/pdas/index.d.ts +8 -0
  22. package/dist/clients/typescript/src/generated/programs/index.d.ts +8 -0
  23. package/dist/clients/typescript/src/generated/programs/paymentChannels.d.ts +80 -0
  24. package/dist/clients/typescript/src/generated/types/accountDiscriminator.d.ts +16 -0
  25. package/dist/clients/typescript/src/generated/types/channelStatus.d.ts +18 -0
  26. package/dist/clients/typescript/src/generated/types/distributeArgs.d.ts +18 -0
  27. package/dist/clients/typescript/src/generated/types/distributionEntry.d.ts +16 -0
  28. package/dist/clients/typescript/src/generated/types/index.d.ts +20 -0
  29. package/dist/clients/typescript/src/generated/types/openArgs.d.ts +26 -0
  30. package/dist/clients/typescript/src/generated/types/opened.d.ts +19 -0
  31. package/dist/clients/typescript/src/generated/types/payoutBeneficiary.d.ts +17 -0
  32. package/dist/clients/typescript/src/generated/types/payoutRedirected.d.ts +26 -0
  33. package/dist/clients/typescript/src/generated/types/redirectReason.d.ts +18 -0
  34. package/dist/clients/typescript/src/generated/types/settleAndSealArgs.d.ts +15 -0
  35. package/dist/clients/typescript/src/generated/types/settlementWatermarks.d.ts +19 -0
  36. package/dist/clients/typescript/src/generated/types/topUpArgs.d.ts +17 -0
  37. package/dist/clients/typescript/src/generated/types/voucherArgs.d.ts +23 -0
  38. package/dist/clients/typescript/src/index.d.ts +1 -0
  39. package/dist/clients/typescript/src/safe-codecs.d.ts +6 -0
  40. package/dist/clients/typescript/tsup.config.d.ts +2 -0
  41. package/dist/index.cjs +1399 -0
  42. package/dist/index.d.ts +4 -0
  43. package/dist/index.js +1549 -0
  44. package/dist/sdk/channel.d.ts +10 -0
  45. package/dist/sdk/client.d.ts +31 -0
  46. package/dist/sdk/utils.d.ts +3 -0
  47. package/dist/sdk/voucher.d.ts +14 -0
  48. package/package.json +36 -0
  49. package/src/clients/typescript/package.json +32 -0
  50. package/src/clients/typescript/src/__tests__/instruction-parsers.test.ts +81 -0
  51. package/src/clients/typescript/src/__tests__/voucher-numeric-safety.test.ts +176 -0
  52. package/src/clients/typescript/src/__tests__/voucher-types.test-d.ts +8 -0
  53. package/src/clients/typescript/src/generated/accounts/channel.ts +192 -0
  54. package/src/clients/typescript/src/generated/accounts/index.ts +9 -0
  55. package/src/clients/typescript/src/generated/errors/index.ts +9 -0
  56. package/src/clients/typescript/src/generated/errors/paymentChannels.ts +251 -0
  57. package/src/clients/typescript/src/generated/index.ts +14 -0
  58. package/src/clients/typescript/src/generated/instructions/distribute.ts +517 -0
  59. package/src/clients/typescript/src/generated/instructions/emitEvent.ts +194 -0
  60. package/src/clients/typescript/src/generated/instructions/index.ts +18 -0
  61. package/src/clients/typescript/src/generated/instructions/open.ts +577 -0
  62. package/src/clients/typescript/src/generated/instructions/reclaim.ts +165 -0
  63. package/src/clients/typescript/src/generated/instructions/requestClose.ts +173 -0
  64. package/src/clients/typescript/src/generated/instructions/seal.ts +151 -0
  65. package/src/clients/typescript/src/generated/instructions/settle.ts +180 -0
  66. package/src/clients/typescript/src/generated/instructions/settleAndSeal.ts +224 -0
  67. package/src/clients/typescript/src/generated/instructions/topUp.ts +267 -0
  68. package/src/clients/typescript/src/generated/instructions/withdrawPayer.ts +246 -0
  69. package/src/clients/typescript/src/generated/pdas/eventAuthority.ts +26 -0
  70. package/src/clients/typescript/src/generated/pdas/index.ts +9 -0
  71. package/src/clients/typescript/src/generated/programs/index.ts +9 -0
  72. package/src/clients/typescript/src/generated/programs/paymentChannels.ts +366 -0
  73. package/src/clients/typescript/src/generated/types/accountDiscriminator.ts +41 -0
  74. package/src/clients/typescript/src/generated/types/channelStatus.ts +40 -0
  75. package/src/clients/typescript/src/generated/types/distributeArgs.ts +47 -0
  76. package/src/clients/typescript/src/generated/types/distributionEntry.ts +48 -0
  77. package/src/clients/typescript/src/generated/types/index.ts +21 -0
  78. package/src/clients/typescript/src/generated/types/openArgs.ts +70 -0
  79. package/src/clients/typescript/src/generated/types/opened.ts +42 -0
  80. package/src/clients/typescript/src/generated/types/payoutBeneficiary.ts +42 -0
  81. package/src/clients/typescript/src/generated/types/payoutRedirected.ts +76 -0
  82. package/src/clients/typescript/src/generated/types/redirectReason.ts +40 -0
  83. package/src/clients/typescript/src/generated/types/settleAndSealArgs.ts +39 -0
  84. package/src/clients/typescript/src/generated/types/settlementWatermarks.ts +48 -0
  85. package/src/clients/typescript/src/generated/types/topUpArgs.ts +33 -0
  86. package/src/clients/typescript/src/generated/types/voucherArgs.ts +68 -0
  87. package/src/clients/typescript/src/index.ts +1 -0
  88. package/src/clients/typescript/src/safe-codecs.ts +82 -0
  89. package/src/clients/typescript/tsconfig.json +11 -0
  90. package/src/clients/typescript/tsup.config.ts +9 -0
  91. package/src/index.ts +4 -0
  92. package/src/sdk/channel.ts +128 -0
  93. package/src/sdk/client.ts +22 -0
  94. package/src/sdk/utils.ts +29 -0
  95. package/src/sdk/voucher.ts +50 -0
  96. package/tsconfig.json +15 -0
@@ -0,0 +1,251 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ isProgramError,
11
+ type Address,
12
+ type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
13
+ type SolanaError,
14
+ } from "@solana/kit";
15
+ import { PAYMENT_CHANNELS_PROGRAM_ADDRESS } from "../programs";
16
+
17
+ export const PAYMENT_CHANNELS_ERROR__NOT_IMPLEMENTED = 0x0; // 0
18
+ export const PAYMENT_CHANNELS_ERROR__MISSING_REQUIRED_SIGNATURE = 0x1; // 1
19
+ export const PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_STATUS = 0x2; // 2
20
+ export const PAYMENT_CHANNELS_ERROR__INVALID_ACCOUNT_DISCRIMINATOR = 0x3; // 3
21
+ export const PAYMENT_CHANNELS_ERROR__UNSUPPORTED_CHANNEL_VERSION = 0x4; // 4
22
+ export const PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_PAYER = 0x5; // 5
23
+ export const PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_PAYEE = 0x6; // 6
24
+ export const PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_MINT = 0x7; // 7
25
+ export const PAYMENT_CHANNELS_ERROR__INVALID_EVENT_AUTHORITY = 0x8; // 8
26
+ export const PAYMENT_CHANNELS_ERROR__NOT_ENOUGH_ACCOUNT_KEYS = 0x9; // 9
27
+ export const PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_RENT_PAYER = 0xa; // 10
28
+ export const PAYMENT_CHANNELS_ERROR__CHANNEL_ACCOUNT_MISMATCH = 0x32; // 50
29
+ export const PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_TOKEN_ACCOUNT = 0x33; // 51
30
+ export const PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_TOKEN_EXTENSIONS = 0x34; // 52
31
+ export const PAYMENT_CHANNELS_ERROR__MINT_ACCOUNT_MISMATCH = 0x35; // 53
32
+ export const PAYMENT_CHANNELS_ERROR__INVALID_MINT_TOKEN_PROGRAM = 0x36; // 54
33
+ export const PAYMENT_CHANNELS_ERROR__MALFORMED_MINT_TOKEN_ACCOUNT_DATA = 0x37; // 55
34
+ export const PAYMENT_CHANNELS_ERROR__MALFORMED_MINT_TOKEN_EXTENSIONS = 0x38; // 56
35
+ export const PAYMENT_CHANNELS_ERROR__PAYER_ACCOUNT_MISMATCH = 0x39; // 57
36
+ export const PAYMENT_CHANNELS_ERROR__INVALID_PAYER_TOKEN_ACCOUNT = 0x3a; // 58
37
+ export const PAYMENT_CHANNELS_ERROR__INVALID_PAYER_TOKEN_EXTENSIONS = 0x3b; // 59
38
+ export const PAYMENT_CHANNELS_ERROR__PAYEE_ACCOUNT_MISMATCH = 0x3c; // 60
39
+ export const PAYMENT_CHANNELS_ERROR__INVALID_PAYEE_TOKEN_ACCOUNT = 0x3d; // 61
40
+ export const PAYMENT_CHANNELS_ERROR__INVALID_PAYEE_TOKEN_EXTENSIONS = 0x3e; // 62
41
+ export const PAYMENT_CHANNELS_ERROR__DEPOSIT_MUST_BE_NON_ZERO = 0xc8; // 200
42
+ export const PAYMENT_CHANNELS_ERROR__GRACE_PERIOD_MUST_BE_NON_ZERO = 0xc9; // 201
43
+ export const PAYMENT_CHANNELS_ERROR__MISSING_ED25519_VERIFICATION = 0xe6; // 230
44
+ export const PAYMENT_CHANNELS_ERROR__MALFORMED_ED25519_INSTRUCTION = 0xe7; // 231
45
+ export const PAYMENT_CHANNELS_ERROR__VOUCHER_CHANNEL_MISMATCH = 0xe8; // 232
46
+ export const PAYMENT_CHANNELS_ERROR__VOUCHER_EXPIRED = 0xe9; // 233
47
+ export const PAYMENT_CHANNELS_ERROR__VOUCHER_WATERMARK_NOT_MONOTONIC = 0xea; // 234
48
+ export const PAYMENT_CHANNELS_ERROR__VOUCHER_OVER_DEPOSIT = 0xeb; // 235
49
+ export const PAYMENT_CHANNELS_ERROR__VOUCHER_MESSAGE_MISMATCH = 0xec; // 236
50
+ export const PAYMENT_CHANNELS_ERROR__VOUCHER_SIGNER_MISMATCH = 0xed; // 237
51
+ export const PAYMENT_CHANNELS_ERROR__VOUCHER_BAD_MAGIC = 0xee; // 238
52
+ export const PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_COUNT = 0x104; // 260
53
+ export const PAYMENT_CHANNELS_ERROR__INVALID_SPLIT_CONFIG = 0x105; // 261
54
+ export const PAYMENT_CHANNELS_ERROR__DISTRIBUTION_PARTS_OVERFLOW = 0x106; // 262
55
+ export const PAYMENT_CHANNELS_ERROR__DUPLICATE_RECIPIENT = 0x107; // 263
56
+ export const PAYMENT_CHANNELS_ERROR__DISTRIBUTION_AMOUNT_OVERFLOW = 0x108; // 264
57
+ export const PAYMENT_CHANNELS_ERROR__DISTRIBUTION_PREIMAGE_LENGTH_OVERFLOW = 0x109; // 265
58
+ export const PAYMENT_CHANNELS_ERROR__CHANNEL_ADDRESS_MISMATCH = 0x7d0; // 2000
59
+ export const PAYMENT_CHANNELS_ERROR__PAYER_PAYEE_MUST_DIFFER = 0x7d1; // 2001
60
+ export const PAYMENT_CHANNELS_ERROR__INVALID_AUTHORIZED_SIGNER = 0x7d2; // 2002
61
+ export const PAYMENT_CHANNELS_ERROR__OPEN_SLOT_OUT_OF_WINDOW = 0x7d3; // 2003
62
+ export const PAYMENT_CHANNELS_ERROR__TOP_UP_DEPOSIT_OVERFLOW = 0x834; // 2100
63
+ export const PAYMENT_CHANNELS_ERROR__SEAL_DEADLINE_OVERFLOW = 0x898; // 2200
64
+ export const PAYMENT_CHANNELS_ERROR__SEAL_GRACE_PERIOD_NOT_ELAPSED = 0x899; // 2201
65
+ export const PAYMENT_CHANNELS_ERROR__PAYER_ALREADY_WITHDRAWN = 0x8fc; // 2300
66
+ export const PAYMENT_CHANNELS_ERROR__REFUND_CALCULATION_OVERFLOW = 0x8fd; // 2301
67
+ export const PAYMENT_CHANNELS_ERROR__CHANNEL_NOT_DISTRIBUTABLE = 0x960; // 2400
68
+ export const PAYMENT_CHANNELS_ERROR__TREASURY_ACCOUNT_MISMATCH = 0x961; // 2401
69
+ export const PAYMENT_CHANNELS_ERROR__INVALID_TREASURY_TOKEN_ACCOUNT = 0x962; // 2402
70
+ export const PAYMENT_CHANNELS_ERROR__INVALID_TREASURY_TOKEN_EXTENSIONS = 0x963; // 2403
71
+ export const PAYMENT_CHANNELS_ERROR__RECIPIENT_ACCOUNT_MISMATCH = 0x964; // 2404
72
+ export const PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_TOKEN_ACCOUNT = 0x965; // 2405
73
+ export const PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_TOKEN_EXTENSIONS = 0x966; // 2406
74
+ export const PAYMENT_CHANNELS_ERROR__INVALID_DISTRIBUTION_HASH = 0x967; // 2407
75
+ export const PAYMENT_CHANNELS_ERROR__NOTHING_TO_DISTRIBUTE = 0x968; // 2408
76
+ export const PAYMENT_CHANNELS_ERROR__RECIPIENT_ACCOUNT_COUNT_MISMATCH = 0x969; // 2409
77
+ export const PAYMENT_CHANNELS_ERROR__DISTRIBUTE_POOL_OVERFLOW = 0x96a; // 2410
78
+ export const PAYMENT_CHANNELS_ERROR__DISTRIBUTE_BALANCE_CALCULATION_OVERFLOW = 0x96b; // 2411
79
+ export const PAYMENT_CHANNELS_ERROR__RENT_PAYER_BALANCE_OVERFLOW = 0x96c; // 2412
80
+ export const PAYMENT_CHANNELS_ERROR__DISTRIBUTE_TRANSFER_QUEUE_OVERFLOW = 0x96d; // 2413
81
+ export const PAYMENT_CHANNELS_ERROR__CHANNEL_CLOSE_TOO_EARLY = 0x96e; // 2414
82
+
83
+ export type PaymentChannelsError =
84
+ | typeof PAYMENT_CHANNELS_ERROR__CHANNEL_ACCOUNT_MISMATCH
85
+ | typeof PAYMENT_CHANNELS_ERROR__CHANNEL_ADDRESS_MISMATCH
86
+ | typeof PAYMENT_CHANNELS_ERROR__CHANNEL_CLOSE_TOO_EARLY
87
+ | typeof PAYMENT_CHANNELS_ERROR__CHANNEL_NOT_DISTRIBUTABLE
88
+ | typeof PAYMENT_CHANNELS_ERROR__DEPOSIT_MUST_BE_NON_ZERO
89
+ | typeof PAYMENT_CHANNELS_ERROR__DISTRIBUTE_BALANCE_CALCULATION_OVERFLOW
90
+ | typeof PAYMENT_CHANNELS_ERROR__DISTRIBUTE_POOL_OVERFLOW
91
+ | typeof PAYMENT_CHANNELS_ERROR__DISTRIBUTE_TRANSFER_QUEUE_OVERFLOW
92
+ | typeof PAYMENT_CHANNELS_ERROR__DISTRIBUTION_AMOUNT_OVERFLOW
93
+ | typeof PAYMENT_CHANNELS_ERROR__DISTRIBUTION_PARTS_OVERFLOW
94
+ | typeof PAYMENT_CHANNELS_ERROR__DISTRIBUTION_PREIMAGE_LENGTH_OVERFLOW
95
+ | typeof PAYMENT_CHANNELS_ERROR__DUPLICATE_RECIPIENT
96
+ | typeof PAYMENT_CHANNELS_ERROR__GRACE_PERIOD_MUST_BE_NON_ZERO
97
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_ACCOUNT_DISCRIMINATOR
98
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_AUTHORIZED_SIGNER
99
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_MINT
100
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_PAYEE
101
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_PAYER
102
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_RENT_PAYER
103
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_STATUS
104
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_TOKEN_ACCOUNT
105
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_TOKEN_EXTENSIONS
106
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_DISTRIBUTION_HASH
107
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_EVENT_AUTHORITY
108
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_MINT_TOKEN_PROGRAM
109
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_PAYEE_TOKEN_ACCOUNT
110
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_PAYEE_TOKEN_EXTENSIONS
111
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_PAYER_TOKEN_ACCOUNT
112
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_PAYER_TOKEN_EXTENSIONS
113
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_COUNT
114
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_TOKEN_ACCOUNT
115
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_TOKEN_EXTENSIONS
116
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_SPLIT_CONFIG
117
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_TREASURY_TOKEN_ACCOUNT
118
+ | typeof PAYMENT_CHANNELS_ERROR__INVALID_TREASURY_TOKEN_EXTENSIONS
119
+ | typeof PAYMENT_CHANNELS_ERROR__MALFORMED_ED25519_INSTRUCTION
120
+ | typeof PAYMENT_CHANNELS_ERROR__MALFORMED_MINT_TOKEN_ACCOUNT_DATA
121
+ | typeof PAYMENT_CHANNELS_ERROR__MALFORMED_MINT_TOKEN_EXTENSIONS
122
+ | typeof PAYMENT_CHANNELS_ERROR__MINT_ACCOUNT_MISMATCH
123
+ | typeof PAYMENT_CHANNELS_ERROR__MISSING_ED25519_VERIFICATION
124
+ | typeof PAYMENT_CHANNELS_ERROR__MISSING_REQUIRED_SIGNATURE
125
+ | typeof PAYMENT_CHANNELS_ERROR__NOT_ENOUGH_ACCOUNT_KEYS
126
+ | typeof PAYMENT_CHANNELS_ERROR__NOTHING_TO_DISTRIBUTE
127
+ | typeof PAYMENT_CHANNELS_ERROR__NOT_IMPLEMENTED
128
+ | typeof PAYMENT_CHANNELS_ERROR__OPEN_SLOT_OUT_OF_WINDOW
129
+ | typeof PAYMENT_CHANNELS_ERROR__PAYEE_ACCOUNT_MISMATCH
130
+ | typeof PAYMENT_CHANNELS_ERROR__PAYER_ACCOUNT_MISMATCH
131
+ | typeof PAYMENT_CHANNELS_ERROR__PAYER_ALREADY_WITHDRAWN
132
+ | typeof PAYMENT_CHANNELS_ERROR__PAYER_PAYEE_MUST_DIFFER
133
+ | typeof PAYMENT_CHANNELS_ERROR__RECIPIENT_ACCOUNT_COUNT_MISMATCH
134
+ | typeof PAYMENT_CHANNELS_ERROR__RECIPIENT_ACCOUNT_MISMATCH
135
+ | typeof PAYMENT_CHANNELS_ERROR__REFUND_CALCULATION_OVERFLOW
136
+ | typeof PAYMENT_CHANNELS_ERROR__RENT_PAYER_BALANCE_OVERFLOW
137
+ | typeof PAYMENT_CHANNELS_ERROR__SEAL_DEADLINE_OVERFLOW
138
+ | typeof PAYMENT_CHANNELS_ERROR__SEAL_GRACE_PERIOD_NOT_ELAPSED
139
+ | typeof PAYMENT_CHANNELS_ERROR__TOP_UP_DEPOSIT_OVERFLOW
140
+ | typeof PAYMENT_CHANNELS_ERROR__TREASURY_ACCOUNT_MISMATCH
141
+ | typeof PAYMENT_CHANNELS_ERROR__UNSUPPORTED_CHANNEL_VERSION
142
+ | typeof PAYMENT_CHANNELS_ERROR__VOUCHER_BAD_MAGIC
143
+ | typeof PAYMENT_CHANNELS_ERROR__VOUCHER_CHANNEL_MISMATCH
144
+ | typeof PAYMENT_CHANNELS_ERROR__VOUCHER_EXPIRED
145
+ | typeof PAYMENT_CHANNELS_ERROR__VOUCHER_MESSAGE_MISMATCH
146
+ | typeof PAYMENT_CHANNELS_ERROR__VOUCHER_OVER_DEPOSIT
147
+ | typeof PAYMENT_CHANNELS_ERROR__VOUCHER_SIGNER_MISMATCH
148
+ | typeof PAYMENT_CHANNELS_ERROR__VOUCHER_WATERMARK_NOT_MONOTONIC;
149
+
150
+ let paymentChannelsErrorMessages:
151
+ | Record<PaymentChannelsError, string>
152
+ | undefined;
153
+ if (process.env["NODE_ENV"] !== "production") {
154
+ paymentChannelsErrorMessages = {
155
+ [PAYMENT_CHANNELS_ERROR__CHANNEL_ACCOUNT_MISMATCH]: `Channel account does not match derived PDA`,
156
+ [PAYMENT_CHANNELS_ERROR__CHANNEL_ADDRESS_MISMATCH]: `Derived channel account address does not match the user provided address`,
157
+ [PAYMENT_CHANNELS_ERROR__CHANNEL_CLOSE_TOO_EARLY]: `Channel cannot be fully closed until clock.slot > open_slot + OPEN_SLOT_WINDOW`,
158
+ [PAYMENT_CHANNELS_ERROR__CHANNEL_NOT_DISTRIBUTABLE]: `Channel is not in OPEN or SEALED`,
159
+ [PAYMENT_CHANNELS_ERROR__DEPOSIT_MUST_BE_NON_ZERO]: `Deposit must be non-zero`,
160
+ [PAYMENT_CHANNELS_ERROR__DISTRIBUTE_BALANCE_CALCULATION_OVERFLOW]: `Channel rent rebalance calculation underflow`,
161
+ [PAYMENT_CHANNELS_ERROR__DISTRIBUTE_POOL_OVERFLOW]: `Distribution pool calculation underflow`,
162
+ [PAYMENT_CHANNELS_ERROR__DISTRIBUTE_TRANSFER_QUEUE_OVERFLOW]: `Transfer queue capacity exceeded`,
163
+ [PAYMENT_CHANNELS_ERROR__DISTRIBUTION_AMOUNT_OVERFLOW]: `num_recipients outside [0, 32]`,
164
+ [PAYMENT_CHANNELS_ERROR__DISTRIBUTION_PARTS_OVERFLOW]: `num_recipients outside [0, 32]`,
165
+ [PAYMENT_CHANNELS_ERROR__DISTRIBUTION_PREIMAGE_LENGTH_OVERFLOW]: `Distribution preimage length calculation overflow`,
166
+ [PAYMENT_CHANNELS_ERROR__DUPLICATE_RECIPIENT]: `Distribution plan contains a duplicate recipient address`,
167
+ [PAYMENT_CHANNELS_ERROR__GRACE_PERIOD_MUST_BE_NON_ZERO]: `Grace period must be non-zero`,
168
+ [PAYMENT_CHANNELS_ERROR__INVALID_ACCOUNT_DISCRIMINATOR]: `Invalid account discriminator`,
169
+ [PAYMENT_CHANNELS_ERROR__INVALID_AUTHORIZED_SIGNER]: `authorized_signer must be a valid Ed25519 public key`,
170
+ [PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_MINT]: `Account does not match channel mint`,
171
+ [PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_PAYEE]: `Account does not match channel payee`,
172
+ [PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_PAYER]: `Account does not match channel payer`,
173
+ [PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_RENT_PAYER]: `Account does not match channel rent_payer`,
174
+ [PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_STATUS]: `Invalid channel status`,
175
+ [PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_TOKEN_ACCOUNT]: `Channel token account is not ATA(channel, mint, token_program)`,
176
+ [PAYMENT_CHANNELS_ERROR__INVALID_CHANNEL_TOKEN_EXTENSIONS]: `Channel token account has invalid extensions`,
177
+ [PAYMENT_CHANNELS_ERROR__INVALID_DISTRIBUTION_HASH]: `Distribution hash mismatch`,
178
+ [PAYMENT_CHANNELS_ERROR__INVALID_EVENT_AUTHORITY]: `Invalid event authority`,
179
+ [PAYMENT_CHANNELS_ERROR__INVALID_MINT_TOKEN_PROGRAM]: `Token program must be SPL Token or Token-2022`,
180
+ [PAYMENT_CHANNELS_ERROR__INVALID_PAYEE_TOKEN_ACCOUNT]: `Payee token account is invalid`,
181
+ [PAYMENT_CHANNELS_ERROR__INVALID_PAYEE_TOKEN_EXTENSIONS]: `Payee token account has invalid extensions`,
182
+ [PAYMENT_CHANNELS_ERROR__INVALID_PAYER_TOKEN_ACCOUNT]: `Payer token account is invalid`,
183
+ [PAYMENT_CHANNELS_ERROR__INVALID_PAYER_TOKEN_EXTENSIONS]: `Payer token account has invalid extensions`,
184
+ [PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_COUNT]: `num_recipients outside [0, 32]`,
185
+ [PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_TOKEN_ACCOUNT]: `Recipient token account is invalid`,
186
+ [PAYMENT_CHANNELS_ERROR__INVALID_RECIPIENT_TOKEN_EXTENSIONS]: `Recipient token account has invalid extensions`,
187
+ [PAYMENT_CHANNELS_ERROR__INVALID_SPLIT_CONFIG]: `Each shareBps must be non-zero and Σbps must be at most 10_000`,
188
+ [PAYMENT_CHANNELS_ERROR__INVALID_TREASURY_TOKEN_ACCOUNT]: `Treasury token account is invalid`,
189
+ [PAYMENT_CHANNELS_ERROR__INVALID_TREASURY_TOKEN_EXTENSIONS]: `Treasury token account has invalid extensions`,
190
+ [PAYMENT_CHANNELS_ERROR__MALFORMED_ED25519_INSTRUCTION]: `Malformed Ed25519 precompile instruction`,
191
+ [PAYMENT_CHANNELS_ERROR__MALFORMED_MINT_TOKEN_ACCOUNT_DATA]: `Token account or mint TLV trailer is malformed`,
192
+ [PAYMENT_CHANNELS_ERROR__MALFORMED_MINT_TOKEN_EXTENSIONS]: `Token account or mint TLV trailer is malformed`,
193
+ [PAYMENT_CHANNELS_ERROR__MINT_ACCOUNT_MISMATCH]: `Mint account does not match channel.mint`,
194
+ [PAYMENT_CHANNELS_ERROR__MISSING_ED25519_VERIFICATION]: `Missing Ed25519 precompile ix at current-1`,
195
+ [PAYMENT_CHANNELS_ERROR__MISSING_REQUIRED_SIGNATURE]: `A signature was required but not found`,
196
+ [PAYMENT_CHANNELS_ERROR__NOT_ENOUGH_ACCOUNT_KEYS]: `Not enough accounts were provided`,
197
+ [PAYMENT_CHANNELS_ERROR__NOTHING_TO_DISTRIBUTE]: `No newly settled funds to distribute`,
198
+ [PAYMENT_CHANNELS_ERROR__NOT_IMPLEMENTED]: `Not implemented`,
199
+ [PAYMENT_CHANNELS_ERROR__OPEN_SLOT_OUT_OF_WINDOW]: `open_slot is in the future or older than the allowed slot window`,
200
+ [PAYMENT_CHANNELS_ERROR__PAYEE_ACCOUNT_MISMATCH]: `Payee token account is not ATA(payee, token_program, mint)`,
201
+ [PAYMENT_CHANNELS_ERROR__PAYER_ACCOUNT_MISMATCH]: `Payer token account is not ATA(payer, token_program, mint)`,
202
+ [PAYMENT_CHANNELS_ERROR__PAYER_ALREADY_WITHDRAWN]: `Payer refund has already been claimed`,
203
+ [PAYMENT_CHANNELS_ERROR__PAYER_PAYEE_MUST_DIFFER]: `Payer and payee must be different accounts`,
204
+ [PAYMENT_CHANNELS_ERROR__RECIPIENT_ACCOUNT_COUNT_MISMATCH]: `Recipient ATA tail length does not match the committed plan's entry count`,
205
+ [PAYMENT_CHANNELS_ERROR__RECIPIENT_ACCOUNT_MISMATCH]: `Recipient token account is not ATA(recipient, token_program, mint)`,
206
+ [PAYMENT_CHANNELS_ERROR__REFUND_CALCULATION_OVERFLOW]: `Payer refund amount calculation underflow`,
207
+ [PAYMENT_CHANNELS_ERROR__RENT_PAYER_BALANCE_OVERFLOW]: `Rent payer lamports overflow on channel deallocation`,
208
+ [PAYMENT_CHANNELS_ERROR__SEAL_DEADLINE_OVERFLOW]: `Deadline overflow on grace period`,
209
+ [PAYMENT_CHANNELS_ERROR__SEAL_GRACE_PERIOD_NOT_ELAPSED]: `Grace period has not elapsed yet`,
210
+ [PAYMENT_CHANNELS_ERROR__TOP_UP_DEPOSIT_OVERFLOW]: `Deposit must be non-zero`,
211
+ [PAYMENT_CHANNELS_ERROR__TREASURY_ACCOUNT_MISMATCH]: `Treasury token account is not ATA(TREASURY_OWNER, mint, token_program)`,
212
+ [PAYMENT_CHANNELS_ERROR__UNSUPPORTED_CHANNEL_VERSION]: `Unsupported channel version`,
213
+ [PAYMENT_CHANNELS_ERROR__VOUCHER_BAD_MAGIC]: `Voucher payload magic prefix is invalid`,
214
+ [PAYMENT_CHANNELS_ERROR__VOUCHER_CHANNEL_MISMATCH]: `Voucher channel_id does not match channel PDA`,
215
+ [PAYMENT_CHANNELS_ERROR__VOUCHER_EXPIRED]: `Voucher expired`,
216
+ [PAYMENT_CHANNELS_ERROR__VOUCHER_MESSAGE_MISMATCH]: `Reserved (formerly: Ed25519 message does not match Borsh voucher payload)`,
217
+ [PAYMENT_CHANNELS_ERROR__VOUCHER_OVER_DEPOSIT]: `Voucher cumulative_amount exceeds channel deposit`,
218
+ [PAYMENT_CHANNELS_ERROR__VOUCHER_SIGNER_MISMATCH]: `Voucher signer does not match channel authorized_signer`,
219
+ [PAYMENT_CHANNELS_ERROR__VOUCHER_WATERMARK_NOT_MONOTONIC]: `Voucher watermark not strictly monotonic`,
220
+ };
221
+ }
222
+
223
+ export function getPaymentChannelsErrorMessage(
224
+ code: PaymentChannelsError,
225
+ ): string {
226
+ if (process.env["NODE_ENV"] !== "production") {
227
+ return (
228
+ paymentChannelsErrorMessages as Record<PaymentChannelsError, string>
229
+ )[code];
230
+ }
231
+
232
+ return "Error message not available in production bundles.";
233
+ }
234
+
235
+ export function isPaymentChannelsError<
236
+ TProgramErrorCode extends PaymentChannelsError,
237
+ >(
238
+ error: unknown,
239
+ transactionMessage: {
240
+ instructions: Record<number, { programAddress: Address }>;
241
+ },
242
+ code?: TProgramErrorCode,
243
+ ): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> &
244
+ Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
245
+ return isProgramError<TProgramErrorCode>(
246
+ error,
247
+ transactionMessage,
248
+ PAYMENT_CHANNELS_PROGRAM_ADDRESS,
249
+ code,
250
+ );
251
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ export * from "./accounts";
10
+ export * from "./errors";
11
+ export * from "./instructions";
12
+ export * from "./pdas";
13
+ export * from "./programs";
14
+ export * from "./types";