@wuwei-labs/srsly 2.0.0-beta.24 → 2.0.0-beta.26
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.
- package/README.md +172 -61
- package/dist/cjs/codama/errors/srsly.js +7 -1
- package/dist/cjs/codama/errors/srsly.js.map +1 -1
- package/dist/cjs/contract/create.js +13 -2
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/index.js +25 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +12 -5
- package/dist/cjs/types/paymentFrequency.js +58 -0
- package/dist/cjs/types/paymentFrequency.js.map +1 -0
- package/dist/cjs/utils/config.js +36 -127
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/constants.js +5 -22
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/duration.js +77 -0
- package/dist/cjs/utils/duration.js.map +1 -0
- package/dist/cjs/utils/index.js +2 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/pack-functions.js +148 -0
- package/dist/cjs/utils/pack-functions.js.map +1 -0
- package/dist/cjs/utils/paymentFrequency.js +60 -0
- package/dist/cjs/utils/paymentFrequency.js.map +1 -0
- package/dist/cjs/utils/solana-adapter.js +120 -0
- package/dist/cjs/utils/solana-adapter.js.map +1 -0
- package/dist/cjs/utils/types.js +6 -0
- package/dist/cjs/utils/types.js.map +1 -0
- package/dist/esm/codama/errors/srsly.js +6 -0
- package/dist/esm/codama/errors/srsly.js.map +1 -1
- package/dist/esm/contract/create.js +13 -2
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +12 -5
- package/dist/esm/types/paymentFrequency.js +53 -0
- package/dist/esm/types/paymentFrequency.js.map +1 -0
- package/dist/esm/utils/config.js +36 -128
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/constants.js +4 -20
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/duration.js +68 -0
- package/dist/esm/utils/duration.js.map +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/pack-functions.js +110 -0
- package/dist/esm/utils/pack-functions.js.map +1 -0
- package/dist/esm/utils/paymentFrequency.js +55 -0
- package/dist/esm/utils/paymentFrequency.js.map +1 -0
- package/dist/esm/utils/solana-adapter.js +82 -0
- package/dist/esm/utils/solana-adapter.js.map +1 -0
- package/dist/esm/utils/types.js +5 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/types/codama/errors/srsly.d.ts +5 -1
- package/dist/types/codama/errors/srsly.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +7 -5
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/paymentFrequency.d.ts +44 -0
- package/dist/types/types/paymentFrequency.d.ts.map +1 -0
- package/dist/types/utils/config.d.ts +35 -18
- package/dist/types/utils/config.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +8 -21
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/dist/types/utils/duration.d.ts +56 -0
- package/dist/types/utils/duration.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/pack-functions.d.ts +18 -0
- package/dist/types/utils/pack-functions.d.ts.map +1 -0
- package/dist/types/utils/paymentFrequency.d.ts +18 -0
- package/dist/types/utils/paymentFrequency.d.ts.map +1 -0
- package/dist/types/utils/solana-adapter.d.ts +26 -0
- package/dist/types/utils/solana-adapter.d.ts.map +1 -0
- package/dist/types/utils/types.d.ts +14 -0
- package/dist/types/utils/types.d.ts.map +1 -0
- package/package.json +12 -5
- package/target/idl/srsly.json +10 -0
package/README.md
CHANGED
|
@@ -4,115 +4,122 @@
|
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://solana.com/)
|
|
6
6
|
|
|
7
|
-
A TypeScript SDK for building and sending Solana transactions to interact with the SRSLY (Space Rental from SLY) program - a decentralized rental system for Star Atlas fleets.
|
|
7
|
+
A flexible TypeScript SDK for building and sending Solana transactions to interact with the SRSLY (Space Rental from SLY) program - a decentralized rental system for Star Atlas fleets.
|
|
8
8
|
|
|
9
9
|
## What This SDK Does
|
|
10
10
|
|
|
11
11
|
The SRSLY SDK is a complete toolkit that helps you create Solana transactions for fleet rentals. It provides:
|
|
12
12
|
|
|
13
|
+
- ✅ **Flexible Dependencies** - Choose your preferred Solana library (`@solana/kit` or `@solana/web3.js`)
|
|
14
|
+
- ✅ **Three Pack Methods** - `packKit()`, `packWeb3js()`, or `pack()` (auto-detect)
|
|
13
15
|
- ✅ Account derivation and validation
|
|
14
16
|
- ✅ Instruction data encoding
|
|
15
17
|
- ✅ Type-safe parameter handling
|
|
16
18
|
- ✅ Direct transaction sending via `.send()` (server/CLI)
|
|
17
|
-
- ✅ Unsigned transaction building via `.pack()` (browser/wallets)
|
|
19
|
+
- ✅ Unsigned transaction building via `.pack*()` (browser/wallets)
|
|
18
20
|
- ✅ Wallet-agnostic design (works with any signing method)
|
|
21
|
+
- ✅ Duration helper functions (`days()`, `weeks()`, `months()`)
|
|
19
22
|
|
|
20
|
-
**Current Status**: Full instruction building, transaction packing, and direct sending support.
|
|
23
|
+
**Current Status**: Full instruction building, transaction packing, and direct sending support with dual library compatibility.
|
|
21
24
|
|
|
22
25
|
## Installation
|
|
23
26
|
|
|
24
27
|
```bash
|
|
28
|
+
# 1. Install the SDK
|
|
25
29
|
npm install @wuwei-labs/srsly
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
# 2. Install your preferred Solana library (peer dependency)
|
|
32
|
+
# Option A: Modern @solana/kit (recommended)
|
|
33
|
+
npm install @solana/kit
|
|
34
|
+
|
|
35
|
+
# Option B: Legacy @solana/web3.js (wallet adapter compatibility)
|
|
36
|
+
npm install @solana/web3.js
|
|
37
|
+
|
|
38
|
+
# Option C: Both libraries (for maximum flexibility)
|
|
39
|
+
npm install @solana/kit @solana/web3.js
|
|
30
40
|
```
|
|
31
41
|
|
|
42
|
+
The SDK uses **peer dependencies** to give you control over which Solana library to use, reducing bundle size and avoiding version conflicts.
|
|
43
|
+
|
|
32
44
|
## Quick Start
|
|
33
45
|
|
|
34
|
-
### Option 1:
|
|
46
|
+
### Option 1: Using @solana/kit (Modern, Recommended)
|
|
35
47
|
|
|
36
48
|
```typescript
|
|
37
|
-
import { createContract, setConfig } from '@wuwei-labs/srsly';
|
|
49
|
+
import { createContract, setConfig, days, weeks } from '@wuwei-labs/srsly';
|
|
38
50
|
import { createKeyPairSignerFromBytes } from '@solana/kit';
|
|
39
51
|
|
|
40
52
|
// 1. Configure SDK with RPC endpoint
|
|
41
53
|
setConfig({
|
|
42
54
|
programs: 'atlasnet',
|
|
43
|
-
rpcUrl: 'https://api.atlasnet.solana.com'
|
|
55
|
+
rpcUrl: 'https://api.atlasnet.solana.com',
|
|
56
|
+
solanaLibrary: 'kit' // Optional: specify preferred library
|
|
44
57
|
});
|
|
45
58
|
|
|
46
59
|
// 2. Create signer from keypair
|
|
47
60
|
const signer = await createKeyPairSignerFromBytes(keypairBytes);
|
|
48
61
|
|
|
49
|
-
// 3. Pack and send
|
|
62
|
+
// 3. Pack and send using @solana/kit (chainable!)
|
|
50
63
|
const signature = await createContract({
|
|
51
64
|
owner: signer,
|
|
52
65
|
fleet: fleetAddress,
|
|
53
66
|
ownerProfile: profileAddress,
|
|
54
|
-
rate: 1000000, // ATLAS tokens
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}).pack(signer.address).send(signer); // Now chainable!
|
|
67
|
+
rate: 1000000, // ATLAS tokens per payment period
|
|
68
|
+
durationMax: days(7), // 7 days using helper function
|
|
69
|
+
paymentsFreq: 'daily' // Minimum duration automatically set to 1 day
|
|
70
|
+
}).packKit(signer.address).send(signer); // Uses @solana/kit
|
|
59
71
|
|
|
60
72
|
console.log('Transaction signature:', signature);
|
|
61
73
|
|
|
62
|
-
//
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// With custom transaction options (also chainable!)
|
|
67
|
-
const signature3 = await createContract(params)
|
|
68
|
-
.set({
|
|
69
|
-
transactionOptions: {
|
|
70
|
-
commitment: 'finalized',
|
|
71
|
-
skipPreflight: true
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
.pack(signer.address)
|
|
74
|
+
// Alternative: Auto-detect library (prefers @solana/kit when available)
|
|
75
|
+
const signature2 = await createContract(params)
|
|
76
|
+
.pack(signer.address) // Auto-detects and uses @solana/kit
|
|
75
77
|
.send(signer);
|
|
78
|
+
|
|
79
|
+
// Two-step approach
|
|
80
|
+
const packedTx = await createContract(params).packKit(signer.address);
|
|
81
|
+
const signature3 = await packedTx.send(signer);
|
|
76
82
|
```
|
|
77
83
|
|
|
78
|
-
### Option 2:
|
|
84
|
+
### Option 2: Using @solana/web3.js (Wallet Adapter Compatible)
|
|
79
85
|
|
|
80
86
|
```typescript
|
|
81
|
-
import { createContract, setConfig } from '@wuwei-labs/srsly';
|
|
87
|
+
import { createContract, setConfig, days } from '@wuwei-labs/srsly';
|
|
82
88
|
|
|
83
|
-
// 1. Configure SDK with RPC endpoint
|
|
89
|
+
// 1. Configure SDK with RPC endpoint
|
|
84
90
|
setConfig({
|
|
85
91
|
programs: 'atlasnet',
|
|
86
|
-
rpcUrl: 'https://api.atlasnet.solana.com'
|
|
92
|
+
rpcUrl: 'https://api.atlasnet.solana.com',
|
|
93
|
+
solanaLibrary: 'web3js' // Optional: specify web3.js preference
|
|
87
94
|
});
|
|
88
95
|
|
|
89
|
-
// 2. Pack
|
|
96
|
+
// 2. Pack using web3.js-optimized method
|
|
90
97
|
const packedTx = await createContract({
|
|
91
98
|
owner: walletPublicKey,
|
|
92
99
|
fleet: fleetAddress,
|
|
93
100
|
ownerProfile: profileAddress,
|
|
94
|
-
rate: 1000000, // ATLAS tokens
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
rate: 1000000, // ATLAS tokens per payment period
|
|
102
|
+
durationMax: days(7), // 7 days using helper function
|
|
103
|
+
paymentsFreq: 'daily' // Minimum duration automatically set to 1 day
|
|
104
|
+
}).packWeb3js(walletPublicKey); // Creates web3.js Transaction object
|
|
105
|
+
|
|
106
|
+
// Option A: Use SDK's built-in send (handles signing + sending)
|
|
107
|
+
const signature = await packedTx.send(walletSigner);
|
|
99
108
|
|
|
100
|
-
//
|
|
109
|
+
// Option B: Direct wallet adapter integration
|
|
101
110
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
102
|
-
import {
|
|
111
|
+
import { Connection } from '@solana/web3.js';
|
|
103
112
|
|
|
104
113
|
const wallet = useWallet();
|
|
114
|
+
const connection = new Connection(rpcUrl);
|
|
105
115
|
|
|
106
|
-
//
|
|
107
|
-
const
|
|
108
|
-
const versionedTx = new VersionedTransaction(versionedMessage);
|
|
109
|
-
const signedTx = await wallet.signTransaction(versionedTx);
|
|
110
|
-
|
|
111
|
-
// Send the signed transaction
|
|
116
|
+
// Use the ready-to-go Transaction object directly
|
|
117
|
+
const signedTx = await wallet.signTransaction(packedTx.transaction);
|
|
112
118
|
const signature = await connection.sendRawTransaction(signedTx.serialize());
|
|
113
119
|
|
|
114
|
-
//
|
|
115
|
-
|
|
120
|
+
// Option C: Auto-detect library (will use web3.js if kit isn't available)
|
|
121
|
+
const packedTx2 = await createContract(params)
|
|
122
|
+
.pack(walletPublicKey); // Auto-detects and uses best available library
|
|
116
123
|
```
|
|
117
124
|
|
|
118
125
|
### Option 3: Manual Instruction Building
|
|
@@ -159,8 +166,52 @@ const createIx = await createContract({
|
|
|
159
166
|
fleet: "123abc...", // string
|
|
160
167
|
ownerProfile: address("456def..."), // Address<string>
|
|
161
168
|
rate: 5000000,
|
|
162
|
-
durationMin: 86400,
|
|
163
169
|
durationMax: 2592000,
|
|
170
|
+
paymentsFreq: 'daily' // Minimum duration automatically set to 1 day
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Duration Helper Functions
|
|
175
|
+
|
|
176
|
+
The SDK provides convenient helper functions for converting time units to seconds:
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { days, weeks, months, hours, minutes, duration } from '@wuwei-labs/srsly';
|
|
180
|
+
|
|
181
|
+
// Individual helper functions
|
|
182
|
+
const sevenDays = days(7); // 604800 seconds
|
|
183
|
+
const twoWeeks = weeks(2); // 1209600 seconds
|
|
184
|
+
const oneMonth = months(1); // 2678400 seconds (31 days)
|
|
185
|
+
const sixHours = hours(6); // 21600 seconds
|
|
186
|
+
const thirtyMinutes = minutes(30); // 1800 seconds
|
|
187
|
+
|
|
188
|
+
// Using in contract creation
|
|
189
|
+
const contract = await createContract({
|
|
190
|
+
owner: wallet,
|
|
191
|
+
fleet: fleetAddress,
|
|
192
|
+
ownerProfile: profileAddress,
|
|
193
|
+
rate: 1000000,
|
|
194
|
+
durationMax: weeks(2), // 2 weeks maximum
|
|
195
|
+
paymentsFreq: 'daily' // Min automatically set to 1 day
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Alternative: use the duration object
|
|
199
|
+
const anotherContract = await createContract({
|
|
200
|
+
owner: wallet,
|
|
201
|
+
fleet: fleetAddress,
|
|
202
|
+
ownerProfile: profileAddress,
|
|
203
|
+
rate: 500000,
|
|
204
|
+
durationMax: duration.months(3), // 3 months maximum
|
|
205
|
+
paymentsFreq: 'weekly' // Min automatically set to 1 week
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// You can still use raw seconds if preferred
|
|
209
|
+
const rawContract = await createContract({
|
|
210
|
+
owner: wallet,
|
|
211
|
+
fleet: fleetAddress,
|
|
212
|
+
ownerProfile: profileAddress,
|
|
213
|
+
rate: 750000,
|
|
214
|
+
durationMax: 86400, // Raw 86400 seconds (1 day)
|
|
164
215
|
paymentsFreq: 'daily'
|
|
165
216
|
});
|
|
166
217
|
```
|
|
@@ -168,7 +219,7 @@ const createIx = await createContract({
|
|
|
168
219
|
### Contract Management
|
|
169
220
|
|
|
170
221
|
```typescript
|
|
171
|
-
import { createContract, closeContract } from '@wuwei-labs/srsly';
|
|
222
|
+
import { createContract, closeContract, days, months } from '@wuwei-labs/srsly';
|
|
172
223
|
|
|
173
224
|
// Create rental contract instruction
|
|
174
225
|
const createIx = await createContract({
|
|
@@ -176,9 +227,8 @@ const createIx = await createContract({
|
|
|
176
227
|
fleet: fleetAddress,
|
|
177
228
|
ownerProfile: profileAddress,
|
|
178
229
|
rate: 5000000,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
paymentsFreq: 'daily'
|
|
230
|
+
durationMax: months(1), // 30 days using helper function
|
|
231
|
+
paymentsFreq: 'daily' // Minimum duration automatically set to 1 day
|
|
182
232
|
});
|
|
183
233
|
|
|
184
234
|
// Close contract instruction
|
|
@@ -201,8 +251,8 @@ const acceptIx = await acceptRental({
|
|
|
201
251
|
borrowerFaction: 'mud', // or 1, 2, 3
|
|
202
252
|
fleet: fleetAddress,
|
|
203
253
|
contract: contractAddress,
|
|
204
|
-
rate: 100, // ATLAS per
|
|
205
|
-
duration: 86400 //
|
|
254
|
+
rate: 100, // ATLAS per payment period (based on contract's payment frequency)
|
|
255
|
+
duration: 86400 // Duration in seconds (must be between contract's min/max)
|
|
206
256
|
});
|
|
207
257
|
|
|
208
258
|
// Cancel active rental instruction
|
|
@@ -291,6 +341,55 @@ const ix2 = await acceptRental(params)
|
|
|
291
341
|
.set({ gameId: 'custom-game-id...', atlasMint: 'custom-mint...' });
|
|
292
342
|
```
|
|
293
343
|
|
|
344
|
+
## Duration and Payment Frequency
|
|
345
|
+
|
|
346
|
+
**Important**: All durations must be aligned with the payment frequency to ensure proper payment calculations.
|
|
347
|
+
|
|
348
|
+
### Duration Rules
|
|
349
|
+
|
|
350
|
+
1. **Duration Units**: All durations are specified in seconds
|
|
351
|
+
2. **Alignment Requirement**: Durations must be multiples of the payment frequency interval
|
|
352
|
+
3. **Validation**: The SDK automatically validates duration alignment and throws an error if invalid
|
|
353
|
+
|
|
354
|
+
### Payment Frequency Intervals
|
|
355
|
+
|
|
356
|
+
| Frequency | Interval | Example Valid Durations |
|
|
357
|
+
|-----------|----------|------------------------|
|
|
358
|
+
| `hourly` | 3,600 seconds (1 hour) | 3,600 (1h), 7,200 (2h), 86,400 (24h) |
|
|
359
|
+
| `daily` | 86,400 seconds (1 day) | 86,400 (1d), 172,800 (2d), 604,800 (7d) |
|
|
360
|
+
| `weekly` | 604,800 seconds (1 week) | 604,800 (1w), 1,209,600 (2w), 2,419,200 (4w) |
|
|
361
|
+
| `monthly` | 2,678,400 seconds (31 days) | 2,678,400 (1m), 5,356,800 (2m) |
|
|
362
|
+
|
|
363
|
+
### Examples
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
// ✅ Valid: 7 day max duration with daily payments
|
|
367
|
+
await createContract({
|
|
368
|
+
durationMax: 604800, // 7 days (604800 % 86400 = 0) ✓
|
|
369
|
+
paymentsFreq: 'daily' // Min duration automatically set to 1 day
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// ❌ Invalid: 3.5 day max duration with daily payments
|
|
373
|
+
await createContract({
|
|
374
|
+
durationMax: 302400, // 3.5 days (302400 % 86400 = 43200) ✗
|
|
375
|
+
paymentsFreq: 'daily'
|
|
376
|
+
});
|
|
377
|
+
// Error: Duration (302400 seconds) must be a multiple of daily frequency (86400 seconds)
|
|
378
|
+
|
|
379
|
+
// ✅ Valid: Hourly payments with hour-aligned max duration
|
|
380
|
+
await createContract({
|
|
381
|
+
durationMax: 172800, // 48 hours (172800 % 3600 = 0) ✓
|
|
382
|
+
paymentsFreq: 'hourly' // Min duration automatically set to 1 hour
|
|
383
|
+
});
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Rate Calculation
|
|
387
|
+
|
|
388
|
+
The `rate` parameter in contracts represents ATLAS tokens per payment period:
|
|
389
|
+
- For `daily` frequency: rate is ATLAS per day
|
|
390
|
+
- For `weekly` frequency: rate is ATLAS per week
|
|
391
|
+
- For `hourly` frequency: rate is ATLAS per hour
|
|
392
|
+
|
|
294
393
|
## Payment System
|
|
295
394
|
|
|
296
395
|
SRSLY implements an escrow-based payment system:
|
|
@@ -301,10 +400,12 @@ SRSLY implements an escrow-based payment system:
|
|
|
301
400
|
4. **Refunds**: Pro-rata refunds for early cancellation (24-hour minimum)
|
|
302
401
|
|
|
303
402
|
```typescript
|
|
304
|
-
// Payment calculation
|
|
305
|
-
const rate = 1000; // ATLAS per
|
|
306
|
-
const
|
|
307
|
-
const
|
|
403
|
+
// Payment calculation example
|
|
404
|
+
const rate = 1000; // ATLAS per payment period
|
|
405
|
+
const paymentFrequency = 'daily'; // Payment every 86400 seconds
|
|
406
|
+
const duration = days(7); // 7 days using helper function
|
|
407
|
+
const paymentPeriods = duration / days(1); // 7 periods
|
|
408
|
+
const totalAmount = rate * paymentPeriods * ATLAS_TO_STARDUST; // Total in stardust
|
|
308
409
|
```
|
|
309
410
|
|
|
310
411
|
## Program Sets Reference
|
|
@@ -338,7 +439,11 @@ import type {
|
|
|
338
439
|
import {
|
|
339
440
|
ATLAS_TO_STARDUST,
|
|
340
441
|
FACTION_MAPPING,
|
|
341
|
-
toAddress
|
|
442
|
+
toAddress,
|
|
443
|
+
days,
|
|
444
|
+
weeks,
|
|
445
|
+
months,
|
|
446
|
+
duration
|
|
342
447
|
} from '@wuwei-labs/srsly';
|
|
343
448
|
|
|
344
449
|
// Conversion rate: 1 ATLAS = 100,000,000 stardust
|
|
@@ -352,6 +457,12 @@ console.log(FACTION_MAPPING[3]); // 'ustur'
|
|
|
352
457
|
// Address conversion utility
|
|
353
458
|
const addressObj = toAddress("123abc..."); // converts string to Address<string>
|
|
354
459
|
console.log(addressObj); // Address<string>
|
|
460
|
+
|
|
461
|
+
// Duration helper functions
|
|
462
|
+
console.log(days(7)); // 604800 (7 days in seconds)
|
|
463
|
+
console.log(weeks(2)); // 1209600 (2 weeks in seconds)
|
|
464
|
+
console.log(months(1)); // 2678400 (1 month in seconds)
|
|
465
|
+
console.log(duration.hours(12)); // 43200 (12 hours in seconds)
|
|
355
466
|
```
|
|
356
467
|
|
|
357
468
|
## IDL and Program Information
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://github.com/codama-idl/codama
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SRSLY_ERROR__INVALID_OWNER_PROFILE = exports.SRSLY_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM = exports.SRSLY_ERROR__INVALID_ATLAS_CONVERSION_RATE = exports.SRSLY_ERROR__UNAUTHORIZED_CONFIG_UPDATE = exports.SRSLY_ERROR__INVALID_RENTAL_DURATION = exports.SRSLY_ERROR__INVALID_FEE_RATE = exports.SRSLY_ERROR__UNSUPPORTED_MIGRATION_VERSION = exports.SRSLY_ERROR__RENTAL_STATE_EXISTS = exports.SRSLY_ERROR__RENTAL_IS_ACTIVE = exports.SRSLY_ERROR__INVALID_THREAD_CONTEXT = exports.SRSLY_ERROR__EXPECTED_DAILY_FREQUENCY = exports.SRSLY_ERROR__DEV_ONLY_FREQUENCY = exports.SRSLY_ERROR__CONTRACT_CLOSED = exports.SRSLY_ERROR__INSUFFICIENT_CANCELLATION_NOTICE = exports.SRSLY_ERROR__INVALID_SUB_PROFILE_INVALIDATOR = exports.SRSLY_ERROR__INVALID_PAYMENT_FREQUENCY = exports.SRSLY_ERROR__INVALID_RATE = exports.SRSLY_ERROR__FLEET_ALREADY_RENTED = exports.SRSLY_ERROR__INVALID_RATE_CALCULATION = exports.SRSLY_ERROR__INVALID_DURATION_MAXIMUM = exports.SRSLY_ERROR__INVALID_DURATION_MINIMUM = void 0;
|
|
10
|
+
exports.SRSLY_ERROR__INVALID_DURATION_MAXIMUM_ALIGNMENT = exports.SRSLY_ERROR__INVALID_DURATION_MINIMUM_ALIGNMENT = exports.SRSLY_ERROR__INVALID_OWNER_PROFILE = exports.SRSLY_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM = exports.SRSLY_ERROR__INVALID_ATLAS_CONVERSION_RATE = exports.SRSLY_ERROR__UNAUTHORIZED_CONFIG_UPDATE = exports.SRSLY_ERROR__INVALID_RENTAL_DURATION = exports.SRSLY_ERROR__INVALID_FEE_RATE = exports.SRSLY_ERROR__UNSUPPORTED_MIGRATION_VERSION = exports.SRSLY_ERROR__RENTAL_STATE_EXISTS = exports.SRSLY_ERROR__RENTAL_IS_ACTIVE = exports.SRSLY_ERROR__INVALID_THREAD_CONTEXT = exports.SRSLY_ERROR__EXPECTED_DAILY_FREQUENCY = exports.SRSLY_ERROR__DEV_ONLY_FREQUENCY = exports.SRSLY_ERROR__CONTRACT_CLOSED = exports.SRSLY_ERROR__INSUFFICIENT_CANCELLATION_NOTICE = exports.SRSLY_ERROR__INVALID_SUB_PROFILE_INVALIDATOR = exports.SRSLY_ERROR__INVALID_PAYMENT_FREQUENCY = exports.SRSLY_ERROR__INVALID_RATE = exports.SRSLY_ERROR__FLEET_ALREADY_RENTED = exports.SRSLY_ERROR__INVALID_RATE_CALCULATION = exports.SRSLY_ERROR__INVALID_DURATION_MAXIMUM = exports.SRSLY_ERROR__INVALID_DURATION_MINIMUM = void 0;
|
|
11
11
|
exports.getSrslyErrorMessage = getSrslyErrorMessage;
|
|
12
12
|
exports.isSrslyError = isSrslyError;
|
|
13
13
|
const kit_1 = require("@solana/kit");
|
|
@@ -54,6 +54,10 @@ exports.SRSLY_ERROR__INVALID_ATLAS_CONVERSION_RATE = 0x1782; // 6018
|
|
|
54
54
|
exports.SRSLY_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM = 0x1783; // 6019
|
|
55
55
|
/** InvalidOwnerProfile: Fleet owner profile does not match the provided owner profile. */
|
|
56
56
|
exports.SRSLY_ERROR__INVALID_OWNER_PROFILE = 0x1784; // 6020
|
|
57
|
+
/** InvalidDurationMinimumAlignment: Duration minimum must be a multiple of the payment frequency interval. */
|
|
58
|
+
exports.SRSLY_ERROR__INVALID_DURATION_MINIMUM_ALIGNMENT = 0x1785; // 6021
|
|
59
|
+
/** InvalidDurationMaximumAlignment: Duration maximum must be a multiple of the payment frequency interval. */
|
|
60
|
+
exports.SRSLY_ERROR__INVALID_DURATION_MAXIMUM_ALIGNMENT = 0x1786; // 6022
|
|
57
61
|
let srslyErrorMessages;
|
|
58
62
|
if (process.env.NODE_ENV !== 'production') {
|
|
59
63
|
srslyErrorMessages = {
|
|
@@ -65,7 +69,9 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
65
69
|
[exports.SRSLY_ERROR__INSUFFICIENT_CANCELLATION_NOTICE]: `Rental time remaining is less than minimum cancellation notice required.`,
|
|
66
70
|
[exports.SRSLY_ERROR__INVALID_ATLAS_CONVERSION_RATE]: `Invalid ATLAS conversion rate. Must be greater than 0.`,
|
|
67
71
|
[exports.SRSLY_ERROR__INVALID_DURATION_MAXIMUM]: `Invalid duration maximum. Must be greater than or equal to the duration minimum.`,
|
|
72
|
+
[exports.SRSLY_ERROR__INVALID_DURATION_MAXIMUM_ALIGNMENT]: `Duration maximum must be a multiple of the payment frequency interval.`,
|
|
68
73
|
[exports.SRSLY_ERROR__INVALID_DURATION_MINIMUM]: `Invalid duration minimum. Must be between 1 and the duration maximum.`,
|
|
74
|
+
[exports.SRSLY_ERROR__INVALID_DURATION_MINIMUM_ALIGNMENT]: `Duration minimum must be a multiple of the payment frequency interval.`,
|
|
69
75
|
[exports.SRSLY_ERROR__INVALID_FEE_RATE]: `Invalid fee rate. Service fee must be <= 50%, referral fee <= 100%, base_bps > 0.`,
|
|
70
76
|
[exports.SRSLY_ERROR__INVALID_OWNER_PROFILE]: `Fleet owner profile does not match the provided owner profile.`,
|
|
71
77
|
[exports.SRSLY_ERROR__INVALID_PAYMENT_FREQUENCY]: `Invalid payment frequency. Must be one of: @hourly, @daily, @weekly, @monthly.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"srsly.js","sourceRoot":"","sources":["../../../../src/codama/errors/srsly.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"srsly.js","sourceRoot":"","sources":["../../../../src/codama/errors/srsly.ts"],"names":[],"mappings":"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"}
|
|
@@ -4,11 +4,22 @@ exports.createContract = createContract;
|
|
|
4
4
|
exports.getCreateContractInstructionAsync = getCreateContractInstructionAsync;
|
|
5
5
|
const config_1 = require("../utils/config");
|
|
6
6
|
const constants_1 = require("../utils/constants");
|
|
7
|
+
const paymentFrequency_1 = require("../utils/paymentFrequency");
|
|
8
|
+
const paymentFrequency_2 = require("../types/paymentFrequency");
|
|
7
9
|
/**
|
|
8
10
|
* Internal function to create a contract instruction with configuration options
|
|
9
11
|
*/
|
|
10
12
|
async function _createContract(params, config) {
|
|
11
|
-
const { owner, fleet, ownerProfile, rate,
|
|
13
|
+
const { owner, fleet, ownerProfile, rate, durationMax, paymentsFreq, ownerKeyIndex = 0, gameId, mint, } = params;
|
|
14
|
+
// Validate payment frequency using auto-generated validation
|
|
15
|
+
if (!(0, paymentFrequency_2.isValidPaymentFrequency)(paymentsFreq)) {
|
|
16
|
+
throw new Error(`Invalid payment frequency: ${paymentsFreq}. Valid values are auto-generated from Rust PaymentFrequency enum.`);
|
|
17
|
+
}
|
|
18
|
+
// Calculate durationMin from payment frequency
|
|
19
|
+
const durationMin = (0, paymentFrequency_1.paymentFrequencyStringToSeconds)(paymentsFreq);
|
|
20
|
+
// Validate that durationMax is a multiple of the payment frequency
|
|
21
|
+
// Uses the codama-generated PaymentFrequency enum and mirrors Rust implementation
|
|
22
|
+
(0, paymentFrequency_1.validateDurationAlignment)(durationMax, paymentsFreq);
|
|
12
23
|
// Get the actual game ID to use (param override, config override, or network default)
|
|
13
24
|
const actualGameId = gameId ? (0, constants_1.toAddress)(gameId) : await (0, constants_1.getSageGameId)(config);
|
|
14
25
|
// Get codama functions
|
|
@@ -28,7 +39,7 @@ async function _createContract(params, config) {
|
|
|
28
39
|
rate: BigInt(rate),
|
|
29
40
|
durationMin: BigInt(durationMin),
|
|
30
41
|
durationMax: BigInt(durationMax),
|
|
31
|
-
paymentsFeq: paymentsFreq
|
|
42
|
+
paymentsFeq: `@${paymentsFreq}`,
|
|
32
43
|
ownerKeyIndex,
|
|
33
44
|
sageProgram: (0, constants_1.toAddress)(await (0, constants_1.getSageProgramAddress)(config)),
|
|
34
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":";;AAkKA,wCAIC;AAKD,8EAKC;AA3KD,4CAA2G;AAC3G,kDAAmG;AACnG,gEAAuG;AACvG,gEAA4F;AA+D5F;;GAEG;AACH,KAAK,UAAU,eAAe,CAC5B,MAA4B,EAC5B,MAAsB;IAEtB,MAAM,EACJ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,aAAa,GAAG,CAAC,EACjB,MAAM,EACN,IAAI,GACL,GAAG,MAAM,CAAC;IAEX,6DAA6D;IAC7D,IAAI,CAAC,IAAA,0CAAuB,EAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,8BAA8B,YAAY,oEAAoE,CAAC,CAAC;IAClI,CAAC;IAED,+CAA+C;IAC/C,MAAM,WAAW,GAAG,IAAA,kDAA+B,EAAC,YAAY,CAAC,CAAC;IAElE,mEAAmE;IACnE,kFAAkF;IAClF,IAAA,4CAAyB,EAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAErD,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,yBAAa,EAAC,MAAM,CAAC,CAAC;IAE9E,uBAAuB;IACvB,MAAM,kBAAkB,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,IAAA,kBAAS,EAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,EAAE,iCAAiC,EAAE,GAAG,kBAAkB,CAAC;IACjE,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,2DAA2D;IAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,wBAAY,EAAC,MAAM,CAAC,CAAC;IAEtE,kFAAkF;IAClF,MAAM,KAAK,GAAG;QACZ,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,4BAA4B;QACnC,KAAK,EAAE,IAAA,qBAAS,EAAC,KAAK,CAAC;QACvB,YAAY,EAAE,IAAA,qBAAS,EAAC,YAAY,CAAC;QACrC,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;QAChC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;QAChC,WAAW,EAAE,IAAI,YAAY,EAAE;QAC/B,aAAa;QACb,WAAW,EAAE,IAAA,qBAAS,EAAC,MAAM,IAAA,iCAAqB,EAAC,MAAM,CAAC,CAAC;KAC5D,CAAC;IAEF,OAAO,iCAAiC,CACtC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,cAAc,CAC5B,MAA4B;IAE5B,OAAO,IAAA,6BAAoB,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,KAAU,EAAE,OAAa;IACzE,OAAO,IAAA,6BAAoB,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,iCAAiC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,12 +14,33 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PaymentFrequency = void 0;
|
|
17
|
+
exports.duration = exports.months = exports.weeks = exports.days = exports.hours = exports.minutes = exports.decaseconds = exports.validateDurationAlignment = exports.paymentFrequencyStringToSeconds = exports.paymentFrequencyToSeconds = exports.isValidPaymentFrequency = exports.getPaymentFrequencyFromString = exports.PAYMENT_FREQUENCY_CONSTANTS = exports.PAYMENT_FREQUENCY_MAP = exports.VALID_PAYMENT_FREQUENCIES = exports.PaymentFrequency = void 0;
|
|
18
18
|
// Export main SDK functions
|
|
19
19
|
__exportStar(require("./contract"), exports);
|
|
20
20
|
__exportStar(require("./rental"), exports);
|
|
21
21
|
__exportStar(require("./utils"), exports);
|
|
22
|
-
// Export PaymentFrequency from
|
|
23
|
-
var
|
|
24
|
-
Object.defineProperty(exports, "PaymentFrequency", { enumerable: true, get: function () { return
|
|
22
|
+
// Export PaymentFrequency from codama (generated from Rust)
|
|
23
|
+
var paymentFrequency_1 = require("./codama/types/paymentFrequency");
|
|
24
|
+
Object.defineProperty(exports, "PaymentFrequency", { enumerable: true, get: function () { return paymentFrequency_1.PaymentFrequency; } });
|
|
25
|
+
// Export auto-generated payment frequency types and utilities
|
|
26
|
+
var paymentFrequency_2 = require("./types/paymentFrequency");
|
|
27
|
+
Object.defineProperty(exports, "VALID_PAYMENT_FREQUENCIES", { enumerable: true, get: function () { return paymentFrequency_2.VALID_PAYMENT_FREQUENCIES; } });
|
|
28
|
+
Object.defineProperty(exports, "PAYMENT_FREQUENCY_MAP", { enumerable: true, get: function () { return paymentFrequency_2.PAYMENT_FREQUENCY_MAP; } });
|
|
29
|
+
Object.defineProperty(exports, "PAYMENT_FREQUENCY_CONSTANTS", { enumerable: true, get: function () { return paymentFrequency_2.PAYMENT_FREQUENCY_CONSTANTS; } });
|
|
30
|
+
Object.defineProperty(exports, "getPaymentFrequencyFromString", { enumerable: true, get: function () { return paymentFrequency_2.getPaymentFrequencyFromString; } });
|
|
31
|
+
Object.defineProperty(exports, "isValidPaymentFrequency", { enumerable: true, get: function () { return paymentFrequency_2.isValidPaymentFrequency; } });
|
|
32
|
+
// Export payment frequency utilities that mirror Rust implementation
|
|
33
|
+
var paymentFrequency_3 = require("./utils/paymentFrequency");
|
|
34
|
+
Object.defineProperty(exports, "paymentFrequencyToSeconds", { enumerable: true, get: function () { return paymentFrequency_3.paymentFrequencyToSeconds; } });
|
|
35
|
+
Object.defineProperty(exports, "paymentFrequencyStringToSeconds", { enumerable: true, get: function () { return paymentFrequency_3.paymentFrequencyStringToSeconds; } });
|
|
36
|
+
Object.defineProperty(exports, "validateDurationAlignment", { enumerable: true, get: function () { return paymentFrequency_3.validateDurationAlignment; } });
|
|
37
|
+
// Export duration helper functions for convenient time unit conversion
|
|
38
|
+
var duration_1 = require("./utils/duration");
|
|
39
|
+
Object.defineProperty(exports, "decaseconds", { enumerable: true, get: function () { return duration_1.decaseconds; } });
|
|
40
|
+
Object.defineProperty(exports, "minutes", { enumerable: true, get: function () { return duration_1.minutes; } });
|
|
41
|
+
Object.defineProperty(exports, "hours", { enumerable: true, get: function () { return duration_1.hours; } });
|
|
42
|
+
Object.defineProperty(exports, "days", { enumerable: true, get: function () { return duration_1.days; } });
|
|
43
|
+
Object.defineProperty(exports, "weeks", { enumerable: true, get: function () { return duration_1.weeks; } });
|
|
44
|
+
Object.defineProperty(exports, "months", { enumerable: true, get: function () { return duration_1.months; } });
|
|
45
|
+
Object.defineProperty(exports, "duration", { enumerable: true, get: function () { return duration_1.duration; } });
|
|
25
46
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AAsBxB,8DAA8D;AAC9D,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB;AAsBxB,4DAA4D;AAC5D,oEAAmE;AAA1D,oHAAA,gBAAgB,OAAA;AAEzB,8DAA8D;AAC9D,6DAOkC;AALhC,6HAAA,yBAAyB,OAAA;AACzB,yHAAA,qBAAqB,OAAA;AACrB,+HAAA,2BAA2B,OAAA;AAC3B,iIAAA,6BAA6B,OAAA;AAC7B,2HAAA,uBAAuB,OAAA;AAGzB,qEAAqE;AACrE,6DAIkC;AAHhC,6HAAA,yBAAyB,OAAA;AACzB,mIAAA,+BAA+B,OAAA;AAC/B,6HAAA,yBAAyB,OAAA;AAG3B,uEAAuE;AACvE,6CAQ0B;AAPxB,uGAAA,WAAW,OAAA;AACX,mGAAA,OAAO,OAAA;AACP,iGAAA,KAAK,OAAA;AACL,gGAAA,IAAI,OAAA;AACJ,iGAAA,KAAK,OAAA;AACL,kGAAA,MAAM,OAAA;AACN,oGAAA,QAAQ,OAAA"}
|
package/dist/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wuwei-labs/srsly",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@codama/nodes-from-anchor": "^1.1.13",
|
|
40
40
|
"@codama/renderers": "^1.0.21",
|
|
41
|
-
"@solana/web3.js": "^1.98.2",
|
|
42
41
|
"@types/node": "^24.0.3",
|
|
43
42
|
"codama": "^1.2.13",
|
|
44
43
|
"tsconfig-to-dual-package": "^1.2.0",
|
|
@@ -46,9 +45,17 @@
|
|
|
46
45
|
"typescript": "^5.8.3",
|
|
47
46
|
"vitest": "^3.2.4"
|
|
48
47
|
},
|
|
49
|
-
"
|
|
50
|
-
"@solana/kit": "
|
|
51
|
-
"@
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@solana/kit": ">=2.0.0",
|
|
50
|
+
"@solana/web3.js": ">=1.95.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"@solana/kit": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@solana/web3.js": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
52
59
|
},
|
|
53
60
|
"type": "commonjs"
|
|
54
61
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This code was AUTO-GENERATED from the Rust PaymentFrequency implementation.
|
|
4
|
+
* Please DO NOT EDIT THIS FILE manually - it will be overwritten.
|
|
5
|
+
*
|
|
6
|
+
* Source: programs/srsly/src/utils.rs
|
|
7
|
+
* Generated by: generate.mjs
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PAYMENT_FREQUENCY_CONSTANTS = exports.PAYMENT_FREQUENCY_MAP = exports.VALID_PAYMENT_FREQUENCIES = void 0;
|
|
11
|
+
exports.getPaymentFrequencyFromString = getPaymentFrequencyFromString;
|
|
12
|
+
exports.isValidPaymentFrequency = isValidPaymentFrequency;
|
|
13
|
+
const paymentFrequency_1 = require("../codama/types/paymentFrequency");
|
|
14
|
+
/**
|
|
15
|
+
* Array of all valid payment frequency strings
|
|
16
|
+
* Auto-generated from Rust PaymentFrequency enum
|
|
17
|
+
*/
|
|
18
|
+
exports.VALID_PAYMENT_FREQUENCIES = [
|
|
19
|
+
'hourly',
|
|
20
|
+
'daily',
|
|
21
|
+
'weekly',
|
|
22
|
+
'monthly'
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Mapping from user-friendly strings to PaymentFrequency enum values
|
|
26
|
+
* Auto-generated from Rust PaymentFrequency enum
|
|
27
|
+
*/
|
|
28
|
+
exports.PAYMENT_FREQUENCY_MAP = {
|
|
29
|
+
'hourly': paymentFrequency_1.PaymentFrequency.Hourly,
|
|
30
|
+
'daily': paymentFrequency_1.PaymentFrequency.Daily,
|
|
31
|
+
'weekly': paymentFrequency_1.PaymentFrequency.Weekly,
|
|
32
|
+
'monthly': paymentFrequency_1.PaymentFrequency.Monthly
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Constants extracted from Rust constants.rs
|
|
36
|
+
* Auto-synced with Rust implementation
|
|
37
|
+
*/
|
|
38
|
+
exports.PAYMENT_FREQUENCY_CONSTANTS = {
|
|
39
|
+
SECONDS_PER_DECASECOND: 10,
|
|
40
|
+
SECONDS_PER_MINUTE: 60,
|
|
41
|
+
SECONDS_PER_HOUR: 3600,
|
|
42
|
+
SECONDS_PER_DAY: 86400,
|
|
43
|
+
SECONDS_PER_WEEK: 604800,
|
|
44
|
+
SECONDS_PER_MONTH: 2678400
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Get PaymentFrequency enum value from user-friendly string
|
|
48
|
+
*/
|
|
49
|
+
function getPaymentFrequencyFromString(frequencyString) {
|
|
50
|
+
return exports.PAYMENT_FREQUENCY_MAP[frequencyString];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if a string is a valid payment frequency
|
|
54
|
+
*/
|
|
55
|
+
function isValidPaymentFrequency(value) {
|
|
56
|
+
return exports.VALID_PAYMENT_FREQUENCIES.includes(value);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=paymentFrequency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paymentFrequency.js","sourceRoot":"","sources":["../../../src/types/paymentFrequency.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAgDH,sEAEC;AAKD,0DAEC;AAvDD,uEAAoE;AAQpE;;;GAGG;AACU,QAAA,yBAAyB,GAAsC;IAC1E,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,SAAS;CACD,CAAC;AAEX;;;GAGG;AACU,QAAA,qBAAqB,GAAqD;IACrF,QAAQ,EAAE,mCAAgB,CAAC,MAAM;IACjC,OAAO,EAAE,mCAAgB,CAAC,KAAK;IAC/B,QAAQ,EAAE,mCAAgB,CAAC,MAAM;IACjC,SAAS,EAAE,mCAAgB,CAAC,OAAO;CAC3B,CAAC;AAEX;;;GAGG;AACU,QAAA,2BAA2B,GAAG;IACzC,sBAAsB,EAAE,EAAE;IAC1B,kBAAkB,EAAE,EAAE;IACtB,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,KAAK;IACtB,gBAAgB,EAAE,MAAM;IACxB,iBAAiB,EAAE,OAAO;CAClB,CAAC;AAEX;;GAEG;AACH,SAAgB,6BAA6B,CAAC,eAAuC;IACnF,OAAO,6BAAqB,CAAC,eAAe,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IACnD,OAAO,iCAAyB,CAAC,QAAQ,CAAC,KAA+B,CAAC,CAAC;AAC7E,CAAC"}
|