@omegax/protocol-sdk 0.5.0 → 0.6.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 (54) hide show
  1. package/README.md +14 -4
  2. package/dist/claims.js +38 -43
  3. package/dist/internal/protocol/all.d.ts +283 -0
  4. package/dist/internal/protocol/all.js +7195 -0
  5. package/dist/internal/protocol/builders.d.ts +1 -0
  6. package/dist/internal/protocol/builders.js +1 -0
  7. package/dist/internal/protocol/client.d.ts +1 -0
  8. package/dist/internal/protocol/client.js +1 -0
  9. package/dist/internal/protocol/constants.d.ts +1 -0
  10. package/dist/internal/protocol/constants.js +1 -0
  11. package/dist/internal/protocol/decoders.d.ts +1 -0
  12. package/dist/internal/protocol/decoders.js +1 -0
  13. package/dist/internal/protocol/fetchers.d.ts +1 -0
  14. package/dist/internal/protocol/fetchers.js +1 -0
  15. package/dist/internal/protocol/shared.d.ts +1 -0
  16. package/dist/internal/protocol/shared.js +1 -0
  17. package/dist/internal/protocol-seeds/all.d.ts +265 -0
  18. package/dist/internal/protocol-seeds/all.js +455 -0
  19. package/dist/internal/protocol-seeds/claims.d.ts +1 -0
  20. package/dist/internal/protocol-seeds/claims.js +1 -0
  21. package/dist/internal/protocol-seeds/core.d.ts +1 -0
  22. package/dist/internal/protocol-seeds/core.js +1 -0
  23. package/dist/internal/protocol-seeds/liquidity.d.ts +1 -0
  24. package/dist/internal/protocol-seeds/liquidity.js +1 -0
  25. package/dist/internal/protocol-seeds/oracle.d.ts +1 -0
  26. package/dist/internal/protocol-seeds/oracle.js +1 -0
  27. package/dist/internal/protocol-seeds/policy.d.ts +1 -0
  28. package/dist/internal/protocol-seeds/policy.js +1 -0
  29. package/dist/internal/reward-claim.d.ts +17 -0
  30. package/dist/internal/reward-claim.js +27 -0
  31. package/dist/internal/rpc.d.ts +15 -0
  32. package/dist/internal/rpc.js +26 -0
  33. package/dist/internal/types/all.d.ts +1952 -0
  34. package/dist/internal/types/all.js +1 -0
  35. package/dist/internal/types/builders.d.ts +1 -0
  36. package/dist/internal/types/builders.js +1 -0
  37. package/dist/internal/types/claims.d.ts +1 -0
  38. package/dist/internal/types/claims.js +1 -0
  39. package/dist/internal/types/oracle.d.ts +1 -0
  40. package/dist/internal/types/oracle.js +1 -0
  41. package/dist/internal/types/protocol.d.ts +1 -0
  42. package/dist/internal/types/protocol.js +1 -0
  43. package/dist/internal/types/rpc.d.ts +1 -0
  44. package/dist/internal/types/rpc.js +1 -0
  45. package/dist/oracle.js +3 -2
  46. package/dist/protocol.d.ts +3 -13
  47. package/dist/protocol.js +3 -6422
  48. package/dist/protocol_seeds.d.ts +1 -265
  49. package/dist/protocol_seeds.js +1 -443
  50. package/dist/rpc.js +13 -28
  51. package/dist/transactions.js +11 -6
  52. package/dist/types.d.ts +1 -1946
  53. package/dist/types.js +1 -1
  54. package/package.json +13 -3
@@ -1,443 +1 @@
1
- import { PublicKey, } from '@solana/web3.js';
2
- export const SEED_CONFIG = 'config';
3
- export const SEED_POOL = 'pool';
4
- export const SEED_ORACLE = 'oracle';
5
- export const SEED_ORACLE_PROFILE = 'oracle_profile';
6
- export const SEED_POOL_ORACLE = 'pool_oracle';
7
- export const SEED_MEMBERSHIP = 'membership';
8
- export const SEED_CYCLE = 'cycle';
9
- export const SEED_CLAIM = 'claim';
10
- export const SEED_ORACLE_STAKE = 'oracle_stake';
11
- export const SEED_POOL_ORACLE_POLICY = 'pool_oracle_policy';
12
- export const SEED_POOL_TERMS = 'pool_terms';
13
- export const SEED_POOL_ASSET_VAULT = 'pool_asset_vault';
14
- export const SEED_POOL_RISK_CONFIG = 'pool_risk_config';
15
- export const SEED_POOL_CAPITAL_CLASS = 'pool_capital_class';
16
- export const SEED_POLICY_SERIES = 'policy_series';
17
- export const SEED_POLICY_SERIES_PAYMENT_OPTION = 'policy_series_payment_option';
18
- export const SEED_POLICY_POSITION = 'policy_position';
19
- export const SEED_POLICY_POSITION_NFT = 'policy_position_nft';
20
- export const SEED_POOL_COMPLIANCE_POLICY = 'pool_compliance_policy';
21
- export const SEED_POOL_CONTROL_AUTHORITY = 'pool_control_authority';
22
- export const SEED_POOL_AUTOMATION_POLICY = 'pool_automation_policy';
23
- export const SEED_POOL_LIQUIDITY_CONFIG = 'pool_liquidity_config';
24
- export const SEED_POOL_ORACLE_PERMISSIONS = 'pool_oracle_permissions';
25
- export const SEED_MEMBER_CYCLE = 'member_cycle';
26
- export const SEED_CYCLE_QUOTE_REPLAY = 'cycle_quote_replay';
27
- export const SEED_POOL_TREASURY_RESERVE = 'pool_treasury_reserve';
28
- export const SEED_POOL_SHARE_MINT = 'pool_share_mint';
29
- export const SEED_REDEMPTION_REQUEST = 'redemption_request';
30
- export const SEED_COHORT_SETTLEMENT_ROOT = 'cohort_settlement_root';
31
- export const SEED_PROTOCOL_FEE_VAULT = 'protocol_fee_vault';
32
- export const SEED_POOL_ORACLE_FEE_VAULT = 'pool_oracle_fee_vault';
33
- export const SEED_SCHEMA = 'schema';
34
- export const SEED_SCHEMA_DEPENDENCY = 'schema_dependency';
35
- export const SEED_POOL_RULE = 'pool_rule';
36
- export const SEED_INVITE_ISSUER = 'invite_issuer';
37
- export const SEED_ENROLLMENT_REPLAY = 'enrollment_replay';
38
- export const SEED_ATTESTATION_VOTE = 'attestation_vote';
39
- export const SEED_OUTCOME_AGGREGATE = 'outcome_agg';
40
- export const SEED_CLAIM_DELEGATE = 'claim_delegate';
41
- export const SEED_PREMIUM_LEDGER = 'premium_ledger';
42
- export const SEED_PREMIUM_REPLAY = 'premium_replay';
43
- export const SEED_COVERAGE_CLAIM = 'coverage_claim';
44
- export const ZERO_PUBKEY = '11111111111111111111111111111111';
45
- export function asPubkey(value) {
46
- if (value instanceof PublicKey)
47
- return value;
48
- return new PublicKey(value);
49
- }
50
- export function deriveConfigPda(programId) {
51
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_CONFIG)], programId);
52
- }
53
- export function derivePoolPda(params) {
54
- const program = asPubkey(params.programId);
55
- const authority = asPubkey(params.authority);
56
- return PublicKey.findProgramAddressSync([
57
- Buffer.from(SEED_POOL),
58
- authority.toBuffer(),
59
- Buffer.from(params.poolId, 'utf8'),
60
- ], program);
61
- }
62
- export function deriveOraclePda(params) {
63
- const program = asPubkey(params.programId);
64
- const oracle = asPubkey(params.oracle);
65
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_ORACLE), oracle.toBuffer()], program);
66
- }
67
- export function deriveOracleProfilePda(params) {
68
- const program = asPubkey(params.programId);
69
- const oracle = asPubkey(params.oracle);
70
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_ORACLE_PROFILE), oracle.toBuffer()], program);
71
- }
72
- export function derivePoolOraclePda(params) {
73
- const program = asPubkey(params.programId);
74
- const pool = asPubkey(params.poolAddress);
75
- const oracle = asPubkey(params.oracle);
76
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_ORACLE), pool.toBuffer(), oracle.toBuffer()], program);
77
- }
78
- export function deriveMembershipPda(params) {
79
- const program = asPubkey(params.programId);
80
- const pool = asPubkey(params.poolAddress);
81
- const member = asPubkey(params.member);
82
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_MEMBERSHIP), pool.toBuffer(), member.toBuffer()], program);
83
- }
84
- export function deriveCycleOutcomePda(params) {
85
- const program = asPubkey(params.programId);
86
- const pool = asPubkey(params.poolAddress);
87
- const member = asPubkey(params.member);
88
- return PublicKey.findProgramAddressSync([
89
- Buffer.from(SEED_CYCLE),
90
- pool.toBuffer(),
91
- member.toBuffer(),
92
- Buffer.from(params.cycleHash),
93
- ], program);
94
- }
95
- export function deriveClaimPda(params) {
96
- if (params.seriesRefHash.length !== 32) {
97
- throw new Error('seriesRefHash must be exactly 32 bytes');
98
- }
99
- if (params.ruleHash.length !== 32) {
100
- throw new Error('ruleHash must be exactly 32 bytes');
101
- }
102
- const program = asPubkey(params.programId);
103
- const pool = asPubkey(params.poolAddress);
104
- const member = asPubkey(params.member);
105
- return PublicKey.findProgramAddressSync([
106
- Buffer.from(SEED_CLAIM),
107
- pool.toBuffer(),
108
- Buffer.from(params.seriesRefHash),
109
- member.toBuffer(),
110
- Buffer.from(params.cycleHash),
111
- Buffer.from(params.ruleHash),
112
- ], program);
113
- }
114
- export function deriveOracleStakePda(params) {
115
- const program = asPubkey(params.programId);
116
- const oracle = asPubkey(params.oracle);
117
- const staker = asPubkey(params.staker);
118
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_ORACLE_STAKE), oracle.toBuffer(), staker.toBuffer()], program);
119
- }
120
- export function derivePoolOraclePolicyPda(params) {
121
- const program = asPubkey(params.programId);
122
- const pool = asPubkey(params.poolAddress);
123
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_ORACLE_POLICY), pool.toBuffer()], program);
124
- }
125
- export function derivePoolTermsPda(params) {
126
- const program = asPubkey(params.programId);
127
- const pool = asPubkey(params.poolAddress);
128
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_TERMS), pool.toBuffer()], program);
129
- }
130
- export function derivePoolAssetVaultPda(params) {
131
- const program = asPubkey(params.programId);
132
- const pool = asPubkey(params.poolAddress);
133
- const mint = asPubkey(params.payoutMint);
134
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_ASSET_VAULT), pool.toBuffer(), mint.toBuffer()], program);
135
- }
136
- export function derivePoolRiskConfigPda(params) {
137
- const program = asPubkey(params.programId);
138
- const pool = asPubkey(params.poolAddress);
139
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_RISK_CONFIG), pool.toBuffer()], program);
140
- }
141
- export function derivePoolLiquidityConfigPda(params) {
142
- const program = asPubkey(params.programId);
143
- const pool = asPubkey(params.poolAddress);
144
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_LIQUIDITY_CONFIG), pool.toBuffer()], program);
145
- }
146
- export function derivePoolCapitalClassPda(params) {
147
- const program = asPubkey(params.programId);
148
- const pool = asPubkey(params.poolAddress);
149
- const shareMint = asPubkey(params.shareMint);
150
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_CAPITAL_CLASS), pool.toBuffer(), shareMint.toBuffer()], program);
151
- }
152
- export function derivePoolCompliancePolicyPda(params) {
153
- const program = asPubkey(params.programId);
154
- const pool = asPubkey(params.poolAddress);
155
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_COMPLIANCE_POLICY), pool.toBuffer()], program);
156
- }
157
- export function derivePoolControlAuthorityPda(params) {
158
- const program = asPubkey(params.programId);
159
- const pool = asPubkey(params.poolAddress);
160
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_CONTROL_AUTHORITY), pool.toBuffer()], program);
161
- }
162
- export function derivePoolAutomationPolicyPda(params) {
163
- const program = asPubkey(params.programId);
164
- const pool = asPubkey(params.poolAddress);
165
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_AUTOMATION_POLICY), pool.toBuffer()], program);
166
- }
167
- function encodeU64Seed(value) {
168
- const out = Buffer.alloc(8);
169
- out.writeBigUInt64LE(typeof value === 'bigint' ? value : BigInt(value));
170
- return out;
171
- }
172
- export function derivePoolOraclePermissionSetPda(params) {
173
- const program = asPubkey(params.programId);
174
- const pool = asPubkey(params.poolAddress);
175
- const oracle = asPubkey(params.oracle);
176
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_ORACLE_PERMISSIONS), pool.toBuffer(), oracle.toBuffer()], program);
177
- }
178
- export function deriveMemberCyclePda(params) {
179
- if (params.seriesRefHash.length !== 32) {
180
- throw new Error('seriesRefHash must be exactly 32 bytes');
181
- }
182
- const program = asPubkey(params.programId);
183
- const pool = asPubkey(params.poolAddress);
184
- const member = asPubkey(params.member);
185
- return PublicKey.findProgramAddressSync([
186
- Buffer.from(SEED_MEMBER_CYCLE),
187
- pool.toBuffer(),
188
- Buffer.from(params.seriesRefHash),
189
- member.toBuffer(),
190
- encodeU64Seed(params.periodIndex),
191
- ], program);
192
- }
193
- export function deriveCycleQuoteReplayPda(params) {
194
- if (params.seriesRefHash.length !== 32) {
195
- throw new Error('seriesRefHash must be exactly 32 bytes');
196
- }
197
- const program = asPubkey(params.programId);
198
- const pool = asPubkey(params.poolAddress);
199
- const member = asPubkey(params.member);
200
- return PublicKey.findProgramAddressSync([
201
- Buffer.from(SEED_CYCLE_QUOTE_REPLAY),
202
- pool.toBuffer(),
203
- Buffer.from(params.seriesRefHash),
204
- member.toBuffer(),
205
- Buffer.from(params.nonceHash),
206
- ], program);
207
- }
208
- export function derivePoolTreasuryReservePda(params) {
209
- const program = asPubkey(params.programId);
210
- const pool = asPubkey(params.poolAddress);
211
- const paymentMint = asPubkey(params.paymentMint);
212
- return PublicKey.findProgramAddressSync([
213
- Buffer.from(SEED_POOL_TREASURY_RESERVE),
214
- pool.toBuffer(),
215
- paymentMint.toBuffer(),
216
- ], program);
217
- }
218
- export function derivePoolShareMintPda(params) {
219
- const program = asPubkey(params.programId);
220
- const pool = asPubkey(params.poolAddress);
221
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POOL_SHARE_MINT), pool.toBuffer()], program);
222
- }
223
- export function deriveRedemptionRequestPda(params) {
224
- if (params.requestHash.length !== 32) {
225
- throw new Error('requestHash must be exactly 32 bytes');
226
- }
227
- const program = asPubkey(params.programId);
228
- const pool = asPubkey(params.poolAddress);
229
- const redeemer = asPubkey(params.redeemer);
230
- return PublicKey.findProgramAddressSync([
231
- Buffer.from(SEED_REDEMPTION_REQUEST),
232
- pool.toBuffer(),
233
- redeemer.toBuffer(),
234
- Buffer.from(params.requestHash),
235
- ], program);
236
- }
237
- export function deriveCohortSettlementRootPda(params) {
238
- if (params.seriesRefHash.length !== 32) {
239
- throw new Error('seriesRefHash must be exactly 32 bytes');
240
- }
241
- const program = asPubkey(params.programId);
242
- const pool = asPubkey(params.poolAddress);
243
- return PublicKey.findProgramAddressSync([
244
- Buffer.from(SEED_COHORT_SETTLEMENT_ROOT),
245
- pool.toBuffer(),
246
- Buffer.from(params.seriesRefHash),
247
- Buffer.from(params.cohortHash),
248
- ], program);
249
- }
250
- export function deriveProtocolFeeVaultPda(params) {
251
- const program = asPubkey(params.programId);
252
- const paymentMint = asPubkey(params.paymentMint);
253
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_PROTOCOL_FEE_VAULT), paymentMint.toBuffer()], program);
254
- }
255
- export function derivePoolOracleFeeVaultPda(params) {
256
- const program = asPubkey(params.programId);
257
- const pool = asPubkey(params.poolAddress);
258
- const oracle = asPubkey(params.oracle);
259
- const paymentMint = asPubkey(params.paymentMint);
260
- return PublicKey.findProgramAddressSync([
261
- Buffer.from(SEED_POOL_ORACLE_FEE_VAULT),
262
- pool.toBuffer(),
263
- oracle.toBuffer(),
264
- paymentMint.toBuffer(),
265
- ], program);
266
- }
267
- export function deriveSchemaPda(params) {
268
- const program = asPubkey(params.programId);
269
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_SCHEMA), Buffer.from(params.schemaKeyHash)], program);
270
- }
271
- export function deriveSchemaDependencyPda(params) {
272
- if (params.schemaKeyHash.length !== 32) {
273
- throw new Error('schemaKeyHash must be 32 bytes');
274
- }
275
- const program = asPubkey(params.programId);
276
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_SCHEMA_DEPENDENCY), Buffer.from(params.schemaKeyHash)], program);
277
- }
278
- export function derivePoolRulePda(params) {
279
- if (params.seriesRefHash.length !== 32) {
280
- throw new Error('seriesRefHash must be exactly 32 bytes');
281
- }
282
- if (params.ruleHash.length !== 32) {
283
- throw new Error('ruleHash must be exactly 32 bytes');
284
- }
285
- const program = asPubkey(params.programId);
286
- const pool = asPubkey(params.poolAddress);
287
- return PublicKey.findProgramAddressSync([
288
- Buffer.from(SEED_POOL_RULE),
289
- pool.toBuffer(),
290
- Buffer.from(params.seriesRefHash),
291
- Buffer.from(params.ruleHash),
292
- ], program);
293
- }
294
- export function deriveInviteIssuerPda(params) {
295
- const program = asPubkey(params.programId);
296
- const issuer = asPubkey(params.issuer);
297
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_INVITE_ISSUER), issuer.toBuffer()], program);
298
- }
299
- export function deriveEnrollmentReplayPda(params) {
300
- const program = asPubkey(params.programId);
301
- const pool = asPubkey(params.poolAddress);
302
- const member = asPubkey(params.member);
303
- return PublicKey.findProgramAddressSync([
304
- Buffer.from(SEED_ENROLLMENT_REPLAY),
305
- pool.toBuffer(),
306
- member.toBuffer(),
307
- Buffer.from(params.nonceHash),
308
- ], program);
309
- }
310
- export function deriveAttestationVotePda(params) {
311
- if (params.seriesRefHash.length !== 32) {
312
- throw new Error('seriesRefHash must be exactly 32 bytes');
313
- }
314
- const program = asPubkey(params.programId);
315
- const pool = asPubkey(params.poolAddress);
316
- const member = asPubkey(params.member);
317
- const oracle = asPubkey(params.oracle);
318
- return PublicKey.findProgramAddressSync([
319
- Buffer.from(SEED_ATTESTATION_VOTE),
320
- pool.toBuffer(),
321
- Buffer.from(params.seriesRefHash),
322
- member.toBuffer(),
323
- Buffer.from(params.cycleHash),
324
- Buffer.from(params.ruleHash),
325
- oracle.toBuffer(),
326
- ], program);
327
- }
328
- export function deriveClaimDelegatePda(params) {
329
- const program = asPubkey(params.programId);
330
- const pool = asPubkey(params.poolAddress);
331
- const member = asPubkey(params.member);
332
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_CLAIM_DELEGATE), pool.toBuffer(), member.toBuffer()], program);
333
- }
334
- export function deriveOutcomeAggregatePda(params) {
335
- if (params.seriesRefHash.length !== 32) {
336
- throw new Error('seriesRefHash must be exactly 32 bytes');
337
- }
338
- const program = asPubkey(params.programId);
339
- const pool = asPubkey(params.poolAddress);
340
- const member = asPubkey(params.member);
341
- return PublicKey.findProgramAddressSync([
342
- Buffer.from(SEED_OUTCOME_AGGREGATE),
343
- pool.toBuffer(),
344
- Buffer.from(params.seriesRefHash),
345
- member.toBuffer(),
346
- Buffer.from(params.cycleHash),
347
- Buffer.from(params.ruleHash),
348
- ], program);
349
- }
350
- export function derivePolicyPositionPda(params) {
351
- if (params.seriesRefHash.length !== 32) {
352
- throw new Error('seriesRefHash must be exactly 32 bytes');
353
- }
354
- const program = asPubkey(params.programId);
355
- const pool = asPubkey(params.poolAddress);
356
- const member = asPubkey(params.member);
357
- return PublicKey.findProgramAddressSync([
358
- Buffer.from(SEED_POLICY_POSITION),
359
- pool.toBuffer(),
360
- Buffer.from(params.seriesRefHash),
361
- member.toBuffer(),
362
- ], program);
363
- }
364
- export function derivePolicySeriesPda(params) {
365
- if (params.seriesRefHash.length !== 32) {
366
- throw new Error('seriesRefHash must be exactly 32 bytes');
367
- }
368
- const program = asPubkey(params.programId);
369
- const pool = asPubkey(params.poolAddress);
370
- return PublicKey.findProgramAddressSync([Buffer.from(SEED_POLICY_SERIES), pool.toBuffer(), Buffer.from(params.seriesRefHash)], program);
371
- }
372
- export function derivePolicyPositionNftPda(params) {
373
- if (params.seriesRefHash.length !== 32) {
374
- throw new Error('seriesRefHash must be exactly 32 bytes');
375
- }
376
- const program = asPubkey(params.programId);
377
- const pool = asPubkey(params.poolAddress);
378
- const member = asPubkey(params.member);
379
- return PublicKey.findProgramAddressSync([
380
- Buffer.from(SEED_POLICY_POSITION_NFT),
381
- pool.toBuffer(),
382
- Buffer.from(params.seriesRefHash),
383
- member.toBuffer(),
384
- ], program);
385
- }
386
- export function derivePremiumLedgerPda(params) {
387
- if (params.seriesRefHash.length !== 32) {
388
- throw new Error('seriesRefHash must be exactly 32 bytes');
389
- }
390
- const program = asPubkey(params.programId);
391
- const pool = asPubkey(params.poolAddress);
392
- const member = asPubkey(params.member);
393
- return PublicKey.findProgramAddressSync([
394
- Buffer.from(SEED_PREMIUM_LEDGER),
395
- pool.toBuffer(),
396
- Buffer.from(params.seriesRefHash),
397
- member.toBuffer(),
398
- ], program);
399
- }
400
- export function derivePremiumReplayPda(params) {
401
- if (params.seriesRefHash.length !== 32) {
402
- throw new Error('seriesRefHash must be exactly 32 bytes');
403
- }
404
- const program = asPubkey(params.programId);
405
- const pool = asPubkey(params.poolAddress);
406
- const member = asPubkey(params.member);
407
- return PublicKey.findProgramAddressSync([
408
- Buffer.from(SEED_PREMIUM_REPLAY),
409
- pool.toBuffer(),
410
- Buffer.from(params.seriesRefHash),
411
- member.toBuffer(),
412
- Buffer.from(params.replayHash),
413
- ], program);
414
- }
415
- export function derivePolicySeriesPaymentOptionPda(params) {
416
- if (params.seriesRefHash.length !== 32) {
417
- throw new Error('seriesRefHash must be exactly 32 bytes');
418
- }
419
- const program = asPubkey(params.programId);
420
- const pool = asPubkey(params.poolAddress);
421
- const paymentMint = asPubkey(params.paymentMint);
422
- return PublicKey.findProgramAddressSync([
423
- Buffer.from(SEED_POLICY_SERIES_PAYMENT_OPTION),
424
- pool.toBuffer(),
425
- Buffer.from(params.seriesRefHash),
426
- paymentMint.toBuffer(),
427
- ], program);
428
- }
429
- export function deriveCoverageClaimPda(params) {
430
- if (params.seriesRefHash.length !== 32) {
431
- throw new Error('seriesRefHash must be exactly 32 bytes');
432
- }
433
- const program = asPubkey(params.programId);
434
- const pool = asPubkey(params.poolAddress);
435
- const member = asPubkey(params.member);
436
- return PublicKey.findProgramAddressSync([
437
- Buffer.from(SEED_COVERAGE_CLAIM),
438
- pool.toBuffer(),
439
- Buffer.from(params.seriesRefHash),
440
- member.toBuffer(),
441
- Buffer.from(params.intentHash),
442
- ], program);
443
- }
1
+ export * from './internal/protocol-seeds/all.js';
package/dist/rpc.js CHANGED
@@ -1,30 +1,10 @@
1
- import { Connection, } from '@solana/web3.js';
1
+ import { Connection } from '@solana/web3.js';
2
+ import { simulateSignedTransactionViaConnection } from './internal/rpc.js';
2
3
  import { normalizeClaimSimulationFailure } from './claims.js';
3
- import { decodeSolanaTransaction, serializeSolanaTransaction, } from './transactions.js';
4
+ import { decodeSolanaTransaction, } from './transactions.js';
4
5
  function shouldRetrySignedSimulationWithoutSigVerify(params) {
5
6
  const message = params.error instanceof Error ? params.error.message : String(params.error);
6
- return (params.sigVerify
7
- && /invalid arguments/i.test(message));
8
- }
9
- async function simulateSignedTransaction(connection, transaction, options) {
10
- const rpcRequest = connection._rpcRequest;
11
- if (typeof rpcRequest !== 'function') {
12
- return await connection.simulateTransaction(transaction, options);
13
- }
14
- const unsafe = await rpcRequest.call(connection, 'simulateTransaction', [
15
- serializeSolanaTransaction(transaction).toString('base64'),
16
- {
17
- encoding: 'base64',
18
- ...options,
19
- },
20
- ]);
21
- if (unsafe?.error) {
22
- throw new Error(unsafe.error.message ?? 'failed to simulate transaction');
23
- }
24
- if (!unsafe?.result?.value) {
25
- throw new Error('failed to simulate transaction: missing RPC result');
26
- }
27
- return unsafe.result;
7
+ return params.sigVerify && /invalid arguments/i.test(message);
28
8
  }
29
9
  export const OMEGAX_NETWORKS = {
30
10
  devnet: {
@@ -45,7 +25,9 @@ export const OMEGAX_NETWORKS = {
45
25
  },
46
26
  };
47
27
  function normalizeOmegaXNetwork(input) {
48
- const normalized = String(input ?? 'devnet').trim().toLowerCase();
28
+ const normalized = String(input ?? 'devnet')
29
+ .trim()
30
+ .toLowerCase();
49
31
  if (normalized === 'devnet')
50
32
  return 'devnet';
51
33
  if (normalized === 'mainnet' || normalized === 'mainnet-beta')
@@ -119,7 +101,7 @@ export function createRpcClient(connection) {
119
101
  };
120
102
  let result;
121
103
  try {
122
- result = await simulateSignedTransaction(connection, tx, baseOptions);
104
+ result = await simulateSignedTransactionViaConnection(connection, tx, baseOptions);
123
105
  }
124
106
  catch (error) {
125
107
  if (!shouldRetrySignedSimulationWithoutSigVerify({
@@ -135,7 +117,7 @@ export function createRpcClient(connection) {
135
117
  };
136
118
  }
137
119
  try {
138
- result = await simulateSignedTransaction(connection, tx, {
120
+ result = await simulateSignedTransactionViaConnection(connection, tx, {
139
121
  ...baseOptions,
140
122
  sigVerify: false,
141
123
  });
@@ -146,7 +128,10 @@ export function createRpcClient(connection) {
146
128
  logs: [],
147
129
  unitsConsumed: null,
148
130
  err: retryError,
149
- failure: normalizeClaimSimulationFailure({ err: retryError, logs: [] }),
131
+ failure: normalizeClaimSimulationFailure({
132
+ err: retryError,
133
+ logs: [],
134
+ }),
150
135
  };
151
136
  }
152
137
  }
@@ -1,5 +1,5 @@
1
1
  import bs58 from 'bs58';
2
- import { Transaction, VersionedTransaction, } from '@solana/web3.js';
2
+ import { Transaction, VersionedTransaction } from '@solana/web3.js';
3
3
  function decodeShortVecLength(bytes, offset = 0) {
4
4
  let length = 0;
5
5
  let size = 0;
@@ -27,7 +27,9 @@ function signatureIsPresent(signature) {
27
27
  return signature.some((value) => value !== 0);
28
28
  }
29
29
  export function decodeSolanaTransaction(input) {
30
- const bytes = typeof input === 'string' ? Buffer.from(input, 'base64') : Buffer.from(input);
30
+ const bytes = typeof input === 'string'
31
+ ? Buffer.from(input, 'base64')
32
+ : Buffer.from(input);
31
33
  const { length: signatureCount, bytesRead } = decodeShortVecLength(bytes);
32
34
  const messageOffset = bytesRead + signatureCount * 64;
33
35
  if (messageOffset >= bytes.length) {
@@ -75,7 +77,9 @@ export function solanaTransactionIntentMessageBytes(transaction) {
75
77
  return normalizeSolanaMessageBytesIgnoringRecentBlockhash(solanaTransactionMessageBytes(transaction));
76
78
  }
77
79
  export function solanaTransactionMessageBase64(input) {
78
- const transaction = typeof input === 'string' || input instanceof Uint8Array || Buffer.isBuffer(input)
80
+ const transaction = typeof input === 'string' ||
81
+ input instanceof Uint8Array ||
82
+ Buffer.isBuffer(input)
79
83
  ? decodeSolanaTransaction(input)
80
84
  : input;
81
85
  return Buffer.from(solanaTransactionMessageBytes(transaction)).toString('base64');
@@ -104,14 +108,15 @@ export function solanaTransactionFirstSignature(transaction) {
104
108
  export function solanaTransactionSignerSignature(transaction, signer) {
105
109
  if (transaction instanceof Transaction) {
106
110
  const entry = transaction.signatures.find((candidate) => candidate.publicKey.toBase58() === signer);
107
- return signatureIsPresent(entry?.signature) ? entry?.signature : null;
111
+ return signatureIsPresent(entry?.signature)
112
+ ? entry?.signature
113
+ : null;
108
114
  }
109
115
  const accountKeys = versionedStaticAccountKeys(transaction);
110
116
  const signerIndex = accountKeys.findIndex((candidate) => candidate.toBase58() === signer);
111
117
  if (signerIndex < 0)
112
118
  return null;
113
- const header = transaction.message
114
- .header;
119
+ const header = transaction.message.header;
115
120
  const requiredSignerCount = header?.numRequiredSignatures ?? 0;
116
121
  if (signerIndex >= requiredSignerCount) {
117
122
  return null;