@haven-fi/solauto-sdk 1.0.176 → 1.0.178

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/dist/constants/generalAccounts.d.ts.map +1 -1
  2. package/dist/constants/generalAccounts.js +0 -1
  3. package/dist/constants/solautoConstants.d.ts +0 -1
  4. package/dist/constants/solautoConstants.d.ts.map +1 -1
  5. package/dist/constants/solautoConstants.js +3 -3
  6. package/dist/generated/errors/solauto.d.ts +8 -26
  7. package/dist/generated/errors/solauto.d.ts.map +1 -1
  8. package/dist/generated/errors/solauto.js +26 -59
  9. package/dist/index.js +2 -0
  10. package/dist/jupiter-sdk/errors/index.d.ts +9 -0
  11. package/dist/jupiter-sdk/errors/index.d.ts.map +1 -0
  12. package/dist/jupiter-sdk/errors/index.js +24 -0
  13. package/dist/jupiter-sdk/errors/jupiter.d.ts +127 -0
  14. package/dist/jupiter-sdk/errors/jupiter.d.ts.map +1 -0
  15. package/dist/jupiter-sdk/errors/jupiter.js +229 -0
  16. package/dist/jupiter-sdk/index.d.ts +10 -0
  17. package/dist/jupiter-sdk/index.d.ts.map +1 -0
  18. package/dist/jupiter-sdk/index.js +25 -0
  19. package/dist/jupiter-sdk/programs/index.d.ts +9 -0
  20. package/dist/jupiter-sdk/programs/index.d.ts.map +1 -0
  21. package/dist/jupiter-sdk/programs/index.js +24 -0
  22. package/dist/jupiter-sdk/programs/jupiter.d.ts +13 -0
  23. package/dist/jupiter-sdk/programs/jupiter.d.ts.map +1 -0
  24. package/dist/jupiter-sdk/programs/jupiter.js +36 -0
  25. package/dist/transactions/transactionUtils.d.ts +5 -0
  26. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  27. package/dist/transactions/transactionUtils.js +46 -4
  28. package/dist/transactions/transactionsManager.d.ts +2 -1
  29. package/dist/transactions/transactionsManager.d.ts.map +1 -1
  30. package/dist/transactions/transactionsManager.js +12 -20
  31. package/package.json +1 -1
  32. package/src/constants/generalAccounts.ts +0 -3
  33. package/src/constants/solautoConstants.ts +1 -2
  34. package/src/generated/errors/solauto.ts +30 -88
  35. package/src/index.ts +3 -1
  36. package/src/jupiter-sdk/errors/index.ts +9 -0
  37. package/src/jupiter-sdk/errors/jupiter.ts +282 -0
  38. package/src/jupiter-sdk/index.ts +10 -0
  39. package/src/jupiter-sdk/programs/index.ts +9 -0
  40. package/src/jupiter-sdk/programs/jupiter.ts +52 -0
  41. package/src/transactions/transactionUtils.ts +72 -5
  42. package/src/transactions/transactionsManager.ts +26 -29
@@ -32,18 +32,14 @@ export class IncorrectAccountsError extends ProgramError {
32
32
  codeToErrorMap.set(0x0, IncorrectAccountsError);
33
33
  nameToErrorMap.set('IncorrectAccounts', IncorrectAccountsError);
34
34
 
35
- /** FailedAccountDeserialization: Failed to deserialize account data, incorrect account was likely given */
35
+ /** FailedAccountDeserialization: Failed to deserialize account data */
36
36
  export class FailedAccountDeserializationError extends ProgramError {
37
37
  override readonly name: string = 'FailedAccountDeserialization';
38
38
 
39
39
  readonly code: number = 0x1; // 1
40
40
 
41
41
  constructor(program: Program, cause?: Error) {
42
- super(
43
- 'Failed to deserialize account data, incorrect account was likely given',
44
- program,
45
- cause
46
- );
42
+ super('Failed to deserialize account data', program, cause);
47
43
  }
48
44
  }
49
45
  codeToErrorMap.set(0x1, FailedAccountDeserializationError);
@@ -52,154 +48,100 @@ nameToErrorMap.set(
52
48
  FailedAccountDeserializationError
53
49
  );
54
50
 
55
- /** InvalidPositionSettings: Invalid position settings given */
51
+ /** InvalidPositionSettings: Invalid position settings provided */
56
52
  export class InvalidPositionSettingsError extends ProgramError {
57
53
  override readonly name: string = 'InvalidPositionSettings';
58
54
 
59
55
  readonly code: number = 0x2; // 2
60
56
 
61
57
  constructor(program: Program, cause?: Error) {
62
- super('Invalid position settings given', program, cause);
58
+ super('Invalid position settings provided', program, cause);
63
59
  }
64
60
  }
65
61
  codeToErrorMap.set(0x2, InvalidPositionSettingsError);
66
62
  nameToErrorMap.set('InvalidPositionSettings', InvalidPositionSettingsError);
67
63
 
68
- /** InvalidDCASettings: Invalid DCA settings given */
64
+ /** InvalidDCASettings: Invalid DCA configuration provided */
69
65
  export class InvalidDCASettingsError extends ProgramError {
70
66
  override readonly name: string = 'InvalidDCASettings';
71
67
 
72
68
  readonly code: number = 0x3; // 3
73
69
 
74
70
  constructor(program: Program, cause?: Error) {
75
- super('Invalid DCA settings given', program, cause);
71
+ super('Invalid DCA configuration provided', program, cause);
76
72
  }
77
73
  }
78
74
  codeToErrorMap.set(0x3, InvalidDCASettingsError);
79
75
  nameToErrorMap.set('InvalidDCASettings', InvalidDCASettingsError);
80
76
 
81
- /** InvalidAutomationData: Invalid automation data given */
77
+ /** InvalidAutomationData: Invalid automation settings provided */
82
78
  export class InvalidAutomationDataError extends ProgramError {
83
79
  override readonly name: string = 'InvalidAutomationData';
84
80
 
85
81
  readonly code: number = 0x4; // 4
86
82
 
87
83
  constructor(program: Program, cause?: Error) {
88
- super('Invalid automation data given', program, cause);
84
+ super('Invalid automation settings provided', program, cause);
89
85
  }
90
86
  }
91
87
  codeToErrorMap.set(0x4, InvalidAutomationDataError);
92
88
  nameToErrorMap.set('InvalidAutomationData', InvalidAutomationDataError);
93
89
 
94
- /** StaleProtocolData: Stale protocol data. Refresh instruction must be invoked before taking a protocol action */
95
- export class StaleProtocolDataError extends ProgramError {
96
- override readonly name: string = 'StaleProtocolData';
97
-
98
- readonly code: number = 0x5; // 5
99
-
100
- constructor(program: Program, cause?: Error) {
101
- super(
102
- 'Stale protocol data. Refresh instruction must be invoked before taking a protocol action',
103
- program,
104
- cause
105
- );
106
- }
107
- }
108
- codeToErrorMap.set(0x5, StaleProtocolDataError);
109
- nameToErrorMap.set('StaleProtocolData', StaleProtocolDataError);
110
-
111
- /** UnableToRebalance: Unable to adjust position to the desired utilization rate */
112
- export class UnableToRebalanceError extends ProgramError {
113
- override readonly name: string = 'UnableToRebalance';
114
-
115
- readonly code: number = 0x6; // 6
116
-
117
- constructor(program: Program, cause?: Error) {
118
- super(
119
- 'Unable to adjust position to the desired utilization rate',
120
- program,
121
- cause
122
- );
123
- }
124
- }
125
- codeToErrorMap.set(0x6, UnableToRebalanceError);
126
- nameToErrorMap.set('UnableToRebalance', UnableToRebalanceError);
127
-
128
- /** ExceededValidUtilizationRate: Desired action brought the utilization rate to an unsafe amount */
129
- export class ExceededValidUtilizationRateError extends ProgramError {
130
- override readonly name: string = 'ExceededValidUtilizationRate';
131
-
132
- readonly code: number = 0x7; // 7
133
-
134
- constructor(program: Program, cause?: Error) {
135
- super(
136
- 'Desired action brought the utilization rate to an unsafe amount',
137
- program,
138
- cause
139
- );
140
- }
141
- }
142
- codeToErrorMap.set(0x7, ExceededValidUtilizationRateError);
143
- nameToErrorMap.set(
144
- 'ExceededValidUtilizationRate',
145
- ExceededValidUtilizationRateError
146
- );
147
-
148
90
  /** InvalidRebalanceCondition: Invalid position condition to rebalance */
149
91
  export class InvalidRebalanceConditionError extends ProgramError {
150
92
  override readonly name: string = 'InvalidRebalanceCondition';
151
93
 
152
- readonly code: number = 0x8; // 8
94
+ readonly code: number = 0x5; // 5
153
95
 
154
96
  constructor(program: Program, cause?: Error) {
155
97
  super('Invalid position condition to rebalance', program, cause);
156
98
  }
157
99
  }
158
- codeToErrorMap.set(0x8, InvalidRebalanceConditionError);
100
+ codeToErrorMap.set(0x5, InvalidRebalanceConditionError);
159
101
  nameToErrorMap.set('InvalidRebalanceCondition', InvalidRebalanceConditionError);
160
102
 
161
103
  /** InstructionIsCPI: Unable to invoke instruction through a CPI */
162
104
  export class InstructionIsCPIError extends ProgramError {
163
105
  override readonly name: string = 'InstructionIsCPI';
164
106
 
165
- readonly code: number = 0x9; // 9
107
+ readonly code: number = 0x6; // 6
166
108
 
167
109
  constructor(program: Program, cause?: Error) {
168
110
  super('Unable to invoke instruction through a CPI', program, cause);
169
111
  }
170
112
  }
171
- codeToErrorMap.set(0x9, InstructionIsCPIError);
113
+ codeToErrorMap.set(0x6, InstructionIsCPIError);
172
114
  nameToErrorMap.set('InstructionIsCPI', InstructionIsCPIError);
173
115
 
174
- /** RebalanceAbuse: Too many rebalance instruction invocations in the same transaction */
175
- export class RebalanceAbuseError extends ProgramError {
176
- override readonly name: string = 'RebalanceAbuse';
116
+ /** IncorrectInstructions: Incorrect set of instructions in the transaction */
117
+ export class IncorrectInstructionsError extends ProgramError {
118
+ override readonly name: string = 'IncorrectInstructions';
177
119
 
178
- readonly code: number = 0xa; // 10
120
+ readonly code: number = 0x7; // 7
179
121
 
180
122
  constructor(program: Program, cause?: Error) {
181
- super(
182
- 'Too many rebalance instruction invocations in the same transaction',
183
- program,
184
- cause
185
- );
123
+ super('Incorrect set of instructions in the transaction', program, cause);
186
124
  }
187
125
  }
188
- codeToErrorMap.set(0xa, RebalanceAbuseError);
189
- nameToErrorMap.set('RebalanceAbuse', RebalanceAbuseError);
126
+ codeToErrorMap.set(0x7, IncorrectInstructionsError);
127
+ nameToErrorMap.set('IncorrectInstructions', IncorrectInstructionsError);
190
128
 
191
- /** IncorrectInstructions: Incorrect set of instructions in the transaction */
192
- export class IncorrectInstructionsError extends ProgramError {
193
- override readonly name: string = 'IncorrectInstructions';
129
+ /** IncorrectDebtAdjustment: Incorrect swap amount provided. Likely due to high price volatility */
130
+ export class IncorrectDebtAdjustmentError extends ProgramError {
131
+ override readonly name: string = 'IncorrectDebtAdjustment';
194
132
 
195
- readonly code: number = 0xb; // 11
133
+ readonly code: number = 0x8; // 8
196
134
 
197
135
  constructor(program: Program, cause?: Error) {
198
- super('Incorrect set of instructions in the transaction', program, cause);
136
+ super(
137
+ 'Incorrect swap amount provided. Likely due to high price volatility',
138
+ program,
139
+ cause
140
+ );
199
141
  }
200
142
  }
201
- codeToErrorMap.set(0xb, IncorrectInstructionsError);
202
- nameToErrorMap.set('IncorrectInstructions', IncorrectInstructionsError);
143
+ codeToErrorMap.set(0x8, IncorrectDebtAdjustmentError);
144
+ nameToErrorMap.set('IncorrectDebtAdjustment', IncorrectDebtAdjustmentError);
203
145
 
204
146
  /**
205
147
  * Attempts to resolve a custom program error from the provided error code.
package/src/index.ts CHANGED
@@ -3,4 +3,6 @@ export * from './constants';
3
3
  export * from './generated';
4
4
  export * from './transactions';
5
5
  export * from './types';
6
- export * from './utils';
6
+ export * from './utils';
7
+ // export * from './marginfi-sdk';
8
+ // export * from './jupiter-sdk';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ export * from './jupiter';
@@ -0,0 +1,282 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ import { Program, ProgramError } from '@metaplex-foundation/umi';
10
+
11
+ type ProgramErrorConstructor = new (
12
+ program: Program,
13
+ cause?: Error
14
+ ) => ProgramError;
15
+ const codeToErrorMap: Map<number, ProgramErrorConstructor> = new Map();
16
+ const nameToErrorMap: Map<string, ProgramErrorConstructor> = new Map();
17
+
18
+ /** EmptyRoute: Empty route */
19
+ export class EmptyRouteError extends ProgramError {
20
+ override readonly name: string = 'EmptyRoute';
21
+
22
+ readonly code: number = 0x1770; // 6000
23
+
24
+ constructor(program: Program, cause?: Error) {
25
+ super('Empty route', program, cause);
26
+ }
27
+ }
28
+ codeToErrorMap.set(0x1770, EmptyRouteError);
29
+ nameToErrorMap.set('EmptyRoute', EmptyRouteError);
30
+
31
+ /** SlippageToleranceExceeded: Slippage tolerance exceeded */
32
+ export class SlippageToleranceExceededError extends ProgramError {
33
+ override readonly name: string = 'SlippageToleranceExceeded';
34
+
35
+ readonly code: number = 0x1771; // 6001
36
+
37
+ constructor(program: Program, cause?: Error) {
38
+ super('Slippage tolerance exceeded', program, cause);
39
+ }
40
+ }
41
+ codeToErrorMap.set(0x1771, SlippageToleranceExceededError);
42
+ nameToErrorMap.set('SlippageToleranceExceeded', SlippageToleranceExceededError);
43
+
44
+ /** InvalidCalculation: Invalid calculation */
45
+ export class InvalidCalculationError extends ProgramError {
46
+ override readonly name: string = 'InvalidCalculation';
47
+
48
+ readonly code: number = 0x1772; // 6002
49
+
50
+ constructor(program: Program, cause?: Error) {
51
+ super('Invalid calculation', program, cause);
52
+ }
53
+ }
54
+ codeToErrorMap.set(0x1772, InvalidCalculationError);
55
+ nameToErrorMap.set('InvalidCalculation', InvalidCalculationError);
56
+
57
+ /** MissingPlatformFeeAccount: Missing platform fee account */
58
+ export class MissingPlatformFeeAccountError extends ProgramError {
59
+ override readonly name: string = 'MissingPlatformFeeAccount';
60
+
61
+ readonly code: number = 0x1773; // 6003
62
+
63
+ constructor(program: Program, cause?: Error) {
64
+ super('Missing platform fee account', program, cause);
65
+ }
66
+ }
67
+ codeToErrorMap.set(0x1773, MissingPlatformFeeAccountError);
68
+ nameToErrorMap.set('MissingPlatformFeeAccount', MissingPlatformFeeAccountError);
69
+
70
+ /** InvalidSlippage: Invalid slippage */
71
+ export class InvalidSlippageError extends ProgramError {
72
+ override readonly name: string = 'InvalidSlippage';
73
+
74
+ readonly code: number = 0x1774; // 6004
75
+
76
+ constructor(program: Program, cause?: Error) {
77
+ super('Invalid slippage', program, cause);
78
+ }
79
+ }
80
+ codeToErrorMap.set(0x1774, InvalidSlippageError);
81
+ nameToErrorMap.set('InvalidSlippage', InvalidSlippageError);
82
+
83
+ /** NotEnoughPercent: Not enough percent to 100 */
84
+ export class NotEnoughPercentError extends ProgramError {
85
+ override readonly name: string = 'NotEnoughPercent';
86
+
87
+ readonly code: number = 0x1775; // 6005
88
+
89
+ constructor(program: Program, cause?: Error) {
90
+ super('Not enough percent to 100', program, cause);
91
+ }
92
+ }
93
+ codeToErrorMap.set(0x1775, NotEnoughPercentError);
94
+ nameToErrorMap.set('NotEnoughPercent', NotEnoughPercentError);
95
+
96
+ /** InvalidInputIndex: Token input index is invalid */
97
+ export class InvalidInputIndexError extends ProgramError {
98
+ override readonly name: string = 'InvalidInputIndex';
99
+
100
+ readonly code: number = 0x1776; // 6006
101
+
102
+ constructor(program: Program, cause?: Error) {
103
+ super('Token input index is invalid', program, cause);
104
+ }
105
+ }
106
+ codeToErrorMap.set(0x1776, InvalidInputIndexError);
107
+ nameToErrorMap.set('InvalidInputIndex', InvalidInputIndexError);
108
+
109
+ /** InvalidOutputIndex: Token output index is invalid */
110
+ export class InvalidOutputIndexError extends ProgramError {
111
+ override readonly name: string = 'InvalidOutputIndex';
112
+
113
+ readonly code: number = 0x1777; // 6007
114
+
115
+ constructor(program: Program, cause?: Error) {
116
+ super('Token output index is invalid', program, cause);
117
+ }
118
+ }
119
+ codeToErrorMap.set(0x1777, InvalidOutputIndexError);
120
+ nameToErrorMap.set('InvalidOutputIndex', InvalidOutputIndexError);
121
+
122
+ /** NotEnoughAccountKeys: Not Enough Account keys */
123
+ export class NotEnoughAccountKeysError extends ProgramError {
124
+ override readonly name: string = 'NotEnoughAccountKeys';
125
+
126
+ readonly code: number = 0x1778; // 6008
127
+
128
+ constructor(program: Program, cause?: Error) {
129
+ super('Not Enough Account keys', program, cause);
130
+ }
131
+ }
132
+ codeToErrorMap.set(0x1778, NotEnoughAccountKeysError);
133
+ nameToErrorMap.set('NotEnoughAccountKeys', NotEnoughAccountKeysError);
134
+
135
+ /** NonZeroMinimumOutAmountNotSupported: Non zero minimum out amount not supported */
136
+ export class NonZeroMinimumOutAmountNotSupportedError extends ProgramError {
137
+ override readonly name: string = 'NonZeroMinimumOutAmountNotSupported';
138
+
139
+ readonly code: number = 0x1779; // 6009
140
+
141
+ constructor(program: Program, cause?: Error) {
142
+ super('Non zero minimum out amount not supported', program, cause);
143
+ }
144
+ }
145
+ codeToErrorMap.set(0x1779, NonZeroMinimumOutAmountNotSupportedError);
146
+ nameToErrorMap.set(
147
+ 'NonZeroMinimumOutAmountNotSupported',
148
+ NonZeroMinimumOutAmountNotSupportedError
149
+ );
150
+
151
+ /** InvalidRoutePlan: Invalid route plan */
152
+ export class InvalidRoutePlanError extends ProgramError {
153
+ override readonly name: string = 'InvalidRoutePlan';
154
+
155
+ readonly code: number = 0x177a; // 6010
156
+
157
+ constructor(program: Program, cause?: Error) {
158
+ super('Invalid route plan', program, cause);
159
+ }
160
+ }
161
+ codeToErrorMap.set(0x177a, InvalidRoutePlanError);
162
+ nameToErrorMap.set('InvalidRoutePlan', InvalidRoutePlanError);
163
+
164
+ /** InvalidReferralAuthority: Invalid referral authority */
165
+ export class InvalidReferralAuthorityError extends ProgramError {
166
+ override readonly name: string = 'InvalidReferralAuthority';
167
+
168
+ readonly code: number = 0x177b; // 6011
169
+
170
+ constructor(program: Program, cause?: Error) {
171
+ super('Invalid referral authority', program, cause);
172
+ }
173
+ }
174
+ codeToErrorMap.set(0x177b, InvalidReferralAuthorityError);
175
+ nameToErrorMap.set('InvalidReferralAuthority', InvalidReferralAuthorityError);
176
+
177
+ /** LedgerTokenAccountDoesNotMatch: Token account doesn't match the ledger */
178
+ export class LedgerTokenAccountDoesNotMatchError extends ProgramError {
179
+ override readonly name: string = 'LedgerTokenAccountDoesNotMatch';
180
+
181
+ readonly code: number = 0x177c; // 6012
182
+
183
+ constructor(program: Program, cause?: Error) {
184
+ super("Token account doesn't match the ledger", program, cause);
185
+ }
186
+ }
187
+ codeToErrorMap.set(0x177c, LedgerTokenAccountDoesNotMatchError);
188
+ nameToErrorMap.set(
189
+ 'LedgerTokenAccountDoesNotMatch',
190
+ LedgerTokenAccountDoesNotMatchError
191
+ );
192
+
193
+ /** InvalidTokenLedger: Invalid token ledger */
194
+ export class InvalidTokenLedgerError extends ProgramError {
195
+ override readonly name: string = 'InvalidTokenLedger';
196
+
197
+ readonly code: number = 0x177d; // 6013
198
+
199
+ constructor(program: Program, cause?: Error) {
200
+ super('Invalid token ledger', program, cause);
201
+ }
202
+ }
203
+ codeToErrorMap.set(0x177d, InvalidTokenLedgerError);
204
+ nameToErrorMap.set('InvalidTokenLedger', InvalidTokenLedgerError);
205
+
206
+ /** IncorrectTokenProgramID: Token program ID is invalid */
207
+ export class IncorrectTokenProgramIDError extends ProgramError {
208
+ override readonly name: string = 'IncorrectTokenProgramID';
209
+
210
+ readonly code: number = 0x177e; // 6014
211
+
212
+ constructor(program: Program, cause?: Error) {
213
+ super('Token program ID is invalid', program, cause);
214
+ }
215
+ }
216
+ codeToErrorMap.set(0x177e, IncorrectTokenProgramIDError);
217
+ nameToErrorMap.set('IncorrectTokenProgramID', IncorrectTokenProgramIDError);
218
+
219
+ /** TokenProgramNotProvided: Token program not provided */
220
+ export class TokenProgramNotProvidedError extends ProgramError {
221
+ override readonly name: string = 'TokenProgramNotProvided';
222
+
223
+ readonly code: number = 0x177f; // 6015
224
+
225
+ constructor(program: Program, cause?: Error) {
226
+ super('Token program not provided', program, cause);
227
+ }
228
+ }
229
+ codeToErrorMap.set(0x177f, TokenProgramNotProvidedError);
230
+ nameToErrorMap.set('TokenProgramNotProvided', TokenProgramNotProvidedError);
231
+
232
+ /** SwapNotSupported: Swap not supported */
233
+ export class SwapNotSupportedError extends ProgramError {
234
+ override readonly name: string = 'SwapNotSupported';
235
+
236
+ readonly code: number = 0x1780; // 6016
237
+
238
+ constructor(program: Program, cause?: Error) {
239
+ super('Swap not supported', program, cause);
240
+ }
241
+ }
242
+ codeToErrorMap.set(0x1780, SwapNotSupportedError);
243
+ nameToErrorMap.set('SwapNotSupported', SwapNotSupportedError);
244
+
245
+ /** ExactOutAmountNotMatched: Exact out amount doesn't match */
246
+ export class ExactOutAmountNotMatchedError extends ProgramError {
247
+ override readonly name: string = 'ExactOutAmountNotMatched';
248
+
249
+ readonly code: number = 0x1781; // 6017
250
+
251
+ constructor(program: Program, cause?: Error) {
252
+ super("Exact out amount doesn't match", program, cause);
253
+ }
254
+ }
255
+ codeToErrorMap.set(0x1781, ExactOutAmountNotMatchedError);
256
+ nameToErrorMap.set('ExactOutAmountNotMatched', ExactOutAmountNotMatchedError);
257
+
258
+ /**
259
+ * Attempts to resolve a custom program error from the provided error code.
260
+ * @category Errors
261
+ */
262
+ export function getJupiterErrorFromCode(
263
+ code: number,
264
+ program: Program,
265
+ cause?: Error
266
+ ): ProgramError | null {
267
+ const constructor = codeToErrorMap.get(code);
268
+ return constructor ? new constructor(program, cause) : null;
269
+ }
270
+
271
+ /**
272
+ * Attempts to resolve a custom program error from the provided error name, i.e. 'Unauthorized'.
273
+ * @category Errors
274
+ */
275
+ export function getJupiterErrorFromName(
276
+ name: string,
277
+ program: Program,
278
+ cause?: Error
279
+ ): ProgramError | null {
280
+ const constructor = nameToErrorMap.get(name);
281
+ return constructor ? new constructor(program, cause) : null;
282
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ export * from './errors';
10
+ export * from './programs';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ export * from './jupiter';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ import {
10
+ ClusterFilter,
11
+ Context,
12
+ Program,
13
+ PublicKey,
14
+ } from '@metaplex-foundation/umi';
15
+ import { getJupiterErrorFromCode, getJupiterErrorFromName } from '../errors';
16
+
17
+ export const JUPITER_PROGRAM_ID =
18
+ 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4' as PublicKey<'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'>;
19
+
20
+ export function createJupiterProgram(): Program {
21
+ return {
22
+ name: 'jupiter',
23
+ publicKey: JUPITER_PROGRAM_ID,
24
+ getErrorFromCode(code: number, cause?: Error) {
25
+ return getJupiterErrorFromCode(code, this, cause);
26
+ },
27
+ getErrorFromName(name: string, cause?: Error) {
28
+ return getJupiterErrorFromName(name, this, cause);
29
+ },
30
+ isOnCluster() {
31
+ return true;
32
+ },
33
+ };
34
+ }
35
+
36
+ export function getJupiterProgram<T extends Program = Program>(
37
+ context: Pick<Context, 'programs'>,
38
+ clusterFilter?: ClusterFilter
39
+ ): T {
40
+ return context.programs.get<T>('jupiter', clusterFilter);
41
+ }
42
+
43
+ export function getJupiterProgramId(
44
+ context: Pick<Context, 'programs'>,
45
+ clusterFilter?: ClusterFilter
46
+ ): PublicKey {
47
+ return context.programs.getPublicKey(
48
+ 'jupiter',
49
+ JUPITER_PROGRAM_ID,
50
+ clusterFilter
51
+ );
52
+ }