@kadi.build/deploy-ability 0.0.3 → 0.0.5

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 (110) hide show
  1. package/dist/targets/akash/bids.d.ts +183 -0
  2. package/dist/targets/akash/bids.d.ts.map +1 -0
  3. package/dist/targets/akash/bids.js +247 -0
  4. package/dist/targets/akash/bids.js.map +1 -0
  5. package/dist/targets/akash/certificate-manager.d.ts +89 -167
  6. package/dist/targets/akash/certificate-manager.d.ts.map +1 -1
  7. package/dist/targets/akash/certificate-manager.js +193 -301
  8. package/dist/targets/akash/certificate-manager.js.map +1 -1
  9. package/dist/targets/akash/client.d.ts +644 -0
  10. package/dist/targets/akash/client.d.ts.map +1 -0
  11. package/dist/targets/akash/client.js +972 -0
  12. package/dist/targets/akash/client.js.map +1 -0
  13. package/dist/targets/akash/constants.d.ts +12 -149
  14. package/dist/targets/akash/constants.d.ts.map +1 -1
  15. package/dist/targets/akash/constants.js +14 -136
  16. package/dist/targets/akash/constants.js.map +1 -1
  17. package/dist/targets/akash/deployer.d.ts +3 -82
  18. package/dist/targets/akash/deployer.d.ts.map +1 -1
  19. package/dist/targets/akash/deployer.js +122 -160
  20. package/dist/targets/akash/deployer.js.map +1 -1
  21. package/dist/targets/akash/environment.d.ts +16 -214
  22. package/dist/targets/akash/environment.d.ts.map +1 -1
  23. package/dist/targets/akash/environment.js +20 -210
  24. package/dist/targets/akash/environment.js.map +1 -1
  25. package/dist/targets/akash/index.d.ts +95 -189
  26. package/dist/targets/akash/index.d.ts.map +1 -1
  27. package/dist/targets/akash/index.js +69 -197
  28. package/dist/targets/akash/index.js.map +1 -1
  29. package/dist/targets/akash/lease-monitor.d.ts +3 -21
  30. package/dist/targets/akash/lease-monitor.d.ts.map +1 -1
  31. package/dist/targets/akash/lease-monitor.js +39 -56
  32. package/dist/targets/akash/lease-monitor.js.map +1 -1
  33. package/dist/targets/akash/logs.d.ts +103 -4
  34. package/dist/targets/akash/logs.d.ts.map +1 -1
  35. package/dist/targets/akash/logs.js +12 -3
  36. package/dist/targets/akash/logs.js.map +1 -1
  37. package/dist/targets/akash/pricing.d.ts +12 -191
  38. package/dist/targets/akash/pricing.d.ts.map +1 -1
  39. package/dist/targets/akash/pricing.js +12 -188
  40. package/dist/targets/akash/pricing.js.map +1 -1
  41. package/dist/targets/akash/provider-manager.d.ts +120 -0
  42. package/dist/targets/akash/provider-manager.d.ts.map +1 -0
  43. package/dist/targets/akash/provider-manager.js +574 -0
  44. package/dist/targets/akash/provider-manager.js.map +1 -0
  45. package/dist/targets/akash/sdl-generator.d.ts +2 -2
  46. package/dist/targets/akash/sdl-generator.d.ts.map +1 -1
  47. package/dist/targets/akash/sdl-generator.js +6 -39
  48. package/dist/targets/akash/sdl-generator.js.map +1 -1
  49. package/dist/targets/akash/types.d.ts +66 -243
  50. package/dist/targets/akash/types.d.ts.map +1 -1
  51. package/dist/targets/akash/types.js +4 -41
  52. package/dist/targets/akash/types.js.map +1 -1
  53. package/dist/targets/akash/wallet-manager.d.ts +35 -352
  54. package/dist/targets/akash/wallet-manager.d.ts.map +1 -1
  55. package/dist/targets/akash/wallet-manager.js +37 -439
  56. package/dist/targets/akash/wallet-manager.js.map +1 -1
  57. package/dist/targets/local/compose-generator.d.ts.map +1 -1
  58. package/dist/targets/local/compose-generator.js +1 -0
  59. package/dist/targets/local/compose-generator.js.map +1 -1
  60. package/dist/targets/local/deployer.js +4 -4
  61. package/dist/targets/local/deployer.js.map +1 -1
  62. package/dist/targets/local/types.d.ts +4 -0
  63. package/dist/targets/local/types.d.ts.map +1 -1
  64. package/dist/types/index.d.ts +1 -1
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/dist/types/index.js.map +1 -1
  67. package/dist/types/options.d.ts +45 -4
  68. package/dist/types/options.d.ts.map +1 -1
  69. package/dist/utils/registry/manager.js +6 -6
  70. package/dist/utils/registry/manager.js.map +1 -1
  71. package/dist/utils/registry/setup.js +4 -4
  72. package/dist/utils/registry/setup.js.map +1 -1
  73. package/docs/KADI_ABILITY_CONVERSION.md +1365 -0
  74. package/docs/PIPELINE_BUILDER_DESIGN.md +1149 -0
  75. package/package.json +8 -11
  76. package/dist/targets/akash/bid-selectors.d.ts +0 -251
  77. package/dist/targets/akash/bid-selectors.d.ts.map +0 -1
  78. package/dist/targets/akash/bid-selectors.js +0 -322
  79. package/dist/targets/akash/bid-selectors.js.map +0 -1
  80. package/dist/targets/akash/bid-types.d.ts +0 -297
  81. package/dist/targets/akash/bid-types.d.ts.map +0 -1
  82. package/dist/targets/akash/bid-types.js +0 -89
  83. package/dist/targets/akash/bid-types.js.map +0 -1
  84. package/dist/targets/akash/blockchain-client.d.ts +0 -577
  85. package/dist/targets/akash/blockchain-client.d.ts.map +0 -1
  86. package/dist/targets/akash/blockchain-client.js +0 -803
  87. package/dist/targets/akash/blockchain-client.js.map +0 -1
  88. package/dist/targets/akash/logs.types.d.ts +0 -102
  89. package/dist/targets/akash/logs.types.d.ts.map +0 -1
  90. package/dist/targets/akash/logs.types.js +0 -9
  91. package/dist/targets/akash/logs.types.js.map +0 -1
  92. package/dist/targets/akash/provider-client.d.ts +0 -114
  93. package/dist/targets/akash/provider-client.d.ts.map +0 -1
  94. package/dist/targets/akash/provider-client.js +0 -318
  95. package/dist/targets/akash/provider-client.js.map +0 -1
  96. package/dist/targets/akash/provider-metadata.d.ts +0 -228
  97. package/dist/targets/akash/provider-metadata.d.ts.map +0 -1
  98. package/dist/targets/akash/provider-metadata.js +0 -14
  99. package/dist/targets/akash/provider-metadata.js.map +0 -1
  100. package/dist/targets/akash/provider-service.d.ts +0 -133
  101. package/dist/targets/akash/provider-service.d.ts.map +0 -1
  102. package/dist/targets/akash/provider-service.js +0 -391
  103. package/dist/targets/akash/provider-service.js.map +0 -1
  104. package/dist/targets/akash/query-client.d.ts +0 -125
  105. package/dist/targets/akash/query-client.d.ts.map +0 -1
  106. package/dist/targets/akash/query-client.js +0 -332
  107. package/dist/targets/akash/query-client.js.map +0 -1
  108. package/docs/EXAMPLES.md +0 -293
  109. package/docs/PLACEMENT.md +0 -433
  110. package/docs/STORAGE.md +0 -318
@@ -1,297 +0,0 @@
1
- /**
2
- * Bid Types and Pricing
3
- *
4
- * Type definitions for enhanced provider bids including comprehensive pricing
5
- * calculations across multiple time periods (hour, day, week, month) and
6
- * currencies (uAKT, AKT, USD).
7
- *
8
- * @module targets/akash/bid-types
9
- */
10
- import type { Bid as ProviderBid } from '@akashnetwork/akash-api/akash/market/v1beta4';
11
- import type { ProviderInfo } from './provider-metadata.js';
12
- /**
13
- * Comprehensive bid pricing across multiple time periods and currencies
14
- *
15
- * Provides pre-calculated pricing for a lease in various formats to support
16
- * different use cases and display preferences. All calculations are derived
17
- * from the raw per-block price returned by the blockchain.
18
- *
19
- * **Price Calculation Background:**
20
- *
21
- * Akash leases are priced per block on the blockchain. The raw price from
22
- * providers is in uAKT (micro AKT) per block. We calculate prices for
23
- * different time periods using:
24
- * - Blocks per hour = 3600 seconds/hour ÷ 6.098 seconds/block ≈ 590.8 blocks
25
- * - Blocks per day = 24 hours × blocks per hour ≈ 14,179 blocks
26
- * - Blocks per week = 7 days × blocks per day ≈ 99,254 blocks
27
- * - Blocks per month = 30.437 days × blocks per day ≈ 431,572 blocks
28
- *
29
- * **USD Conversion:**
30
- *
31
- * USD prices require the current AKT market price, which must be provided
32
- * by the caller via the `toUSD()` method. This keeps the library free from
33
- * external API dependencies while allowing flexible price display.
34
- *
35
- * @example Display pricing in multiple formats
36
- * ```typescript
37
- * const bid: EnhancedBid = // ... from queryBids
38
- *
39
- * // Display in uAKT
40
- * console.log(`${bid.pricing.uakt.perMonth} uAKT/month`);
41
- *
42
- * // Display in AKT
43
- * console.log(`${bid.pricing.akt.perMonth.toFixed(2)} AKT/month`);
44
- *
45
- * // Display in USD (requires AKT price)
46
- * const aktPrice = 0.50; // $0.50 per AKT
47
- * const usd = bid.pricing.toUSD(aktPrice);
48
- * console.log(`$${usd.perMonth.toFixed(2)}/month`);
49
- * console.log(`$${usd.perHour.toFixed(4)}/hour`);
50
- * ```
51
- */
52
- export interface BidPricing {
53
- /**
54
- * Raw price from blockchain (per block)
55
- *
56
- * This is the authoritative source - all other prices are computed from this.
57
- */
58
- readonly raw: {
59
- /** Denomination (typically "uakt") */
60
- readonly denom: string;
61
- /** Amount per block as string */
62
- readonly amount: string;
63
- };
64
- /**
65
- * Pre-computed prices in uAKT for different time periods
66
- *
67
- * All values are in micro AKT (uAKT). To convert to AKT, divide by 1,000,000.
68
- */
69
- readonly uakt: {
70
- /** Price in uAKT per block */
71
- readonly perBlock: number;
72
- /** Price in uAKT per hour (~590.8 blocks) */
73
- readonly perHour: number;
74
- /** Price in uAKT per day (~14,179 blocks) */
75
- readonly perDay: number;
76
- /** Price in uAKT per week (~99,254 blocks) */
77
- readonly perWeek: number;
78
- /** Price in uAKT per month (~431,572 blocks, 30.437 days) */
79
- readonly perMonth: number;
80
- };
81
- /**
82
- * Pre-computed prices in AKT (1 AKT = 1,000,000 uAKT)
83
- *
84
- * Convenient for display without manual conversion.
85
- */
86
- readonly akt: {
87
- /** Price in AKT per block */
88
- readonly perBlock: number;
89
- /** Price in AKT per hour */
90
- readonly perHour: number;
91
- /** Price in AKT per day */
92
- readonly perDay: number;
93
- /** Price in AKT per week */
94
- readonly perWeek: number;
95
- /** Price in AKT per month */
96
- readonly perMonth: number;
97
- };
98
- /**
99
- * Convert prices to USD using current AKT market price
100
- *
101
- * **Important:** This method requires you to provide the current AKT price.
102
- * deploy-ability does not fetch market data to remain pure and dependency-free.
103
- *
104
- * **Where to get AKT price:**
105
- * - CoinGecko API: https://api.coingecko.com/api/v3/simple/price?ids=akash-network&vs_currencies=usd
106
- * - Your own price oracle
107
- * - Akash Console API (if available)
108
- * - Cached/hardcoded value for estimates
109
- *
110
- * @param aktPriceUSD - Current price of 1 AKT in USD
111
- * @returns Prices in USD for different time periods
112
- *
113
- * @example
114
- * ```typescript
115
- * const aktPrice = 0.50; // $0.50 per AKT
116
- * const usdPricing = bid.pricing.toUSD(aktPrice);
117
- * console.log(`$${usdPricing.perMonth.toFixed(2)}/month`);
118
- * ```
119
- */
120
- toUSD(aktPriceUSD: number): {
121
- readonly perHour: number;
122
- readonly perDay: number;
123
- readonly perWeek: number;
124
- readonly perMonth: number;
125
- };
126
- }
127
- /**
128
- * Create BidPricing instance from blockchain price data
129
- *
130
- * Calculates all time-period prices from the raw per-block price.
131
- *
132
- * @param price - Price object from blockchain bid
133
- * @param price.denom - Denomination (typically "uakt")
134
- * @param price.amount - Amount per block as string
135
- * @returns Complete pricing information across all time periods
136
- *
137
- * @example
138
- * ```typescript
139
- * const pricing = createBidPricing({
140
- * denom: 'uakt',
141
- * amount: '1234'
142
- * });
143
- * console.log(pricing.akt.perMonth); // Monthly cost in AKT
144
- * ```
145
- */
146
- export declare function createBidPricing(price: {
147
- denom: string;
148
- amount: string;
149
- }): BidPricing;
150
- /**
151
- * Enhanced provider bid with complete information
152
- *
153
- * Combines the raw blockchain bid data with enriched provider information
154
- * and pre-calculated pricing. This is the primary type developers work with
155
- * when selecting providers for their deployments.
156
- *
157
- * **Design Philosophy:**
158
- *
159
- * This type provides all the information needed to make an informed provider
160
- * selection decision in a single, convenient package:
161
- * - Provider identity and metadata
162
- * - Location information for latency/compliance needs
163
- * - Reliability metrics for quality assessment
164
- * - Comprehensive pricing in multiple formats
165
- * - Raw bid data for advanced use cases
166
- *
167
- * **Data Availability:**
168
- *
169
- * Not all fields will be populated for all providers:
170
- * - New providers may not have reliability data yet
171
- * - Some providers may not expose location information
172
- * - Provider metadata (name, email, website) is optional
173
- *
174
- * Always check for undefined before using optional provider fields.
175
- *
176
- * @example Displaying bid information
177
- * ```typescript
178
- * function displayBid(bid: EnhancedBid, aktPrice: number): void {
179
- * const usd = bid.pricing.toUSD(aktPrice);
180
- *
181
- * console.log(`
182
- * Provider: ${bid.provider.name || 'Unknown'}
183
- * Location: ${bid.provider.location?.country || 'Unknown'}
184
- * Uptime (7d): ${bid.provider.reliability
185
- * ? (bid.provider.reliability.uptime7d * 100).toFixed(1) + '%'
186
- * : 'No data'}
187
- * Price: $${usd.perMonth.toFixed(2)}/month
188
- * Audited: ${bid.provider.isAudited ? 'Yes' : 'No'}
189
- * `);
190
- * }
191
- * ```
192
- *
193
- * @example Filtering by criteria
194
- * ```typescript
195
- * function selectAffordableReliableBid(
196
- * bids: EnhancedBid[],
197
- * maxUsdPerMonth: number,
198
- * aktPrice: number,
199
- * minUptime: number
200
- * ): EnhancedBid | null {
201
- * const filtered = bids.filter(bid => {
202
- * const usd = bid.pricing.toUSD(aktPrice);
203
- * const uptime = bid.provider.reliability?.uptime7d ?? 0;
204
- * return usd.perMonth <= maxUsdPerMonth && uptime >= minUptime;
205
- * });
206
- *
207
- * return filtered[0] ?? null;
208
- * }
209
- * ```
210
- */
211
- export interface EnhancedBid {
212
- /**
213
- * Unique identifier for this bid
214
- *
215
- * Constructed from the bid coordinates (owner/dseq/gseq/oseq/provider).
216
- * Useful for React keys, logging, and bid tracking.
217
- */
218
- readonly id: string;
219
- /**
220
- * Raw bid data from Akash blockchain
221
- *
222
- * Contains the original protobuf bid object with all coordinates
223
- * (bidId, price, state, etc.). Useful for advanced operations that
224
- * need direct access to blockchain data.
225
- */
226
- readonly bid: ProviderBid;
227
- /**
228
- * Complete provider information
229
- *
230
- * Includes identity, location, reliability metrics, and audit status.
231
- * Some fields may be undefined for providers without complete metadata.
232
- */
233
- readonly provider: ProviderInfo;
234
- /**
235
- * Pre-calculated pricing across all time periods
236
- *
237
- * Includes pricing in uAKT, AKT, and a method for USD conversion.
238
- * Makes it easy to display prices in user-friendly formats.
239
- */
240
- readonly pricing: BidPricing;
241
- /**
242
- * When this bid was created
243
- *
244
- * Timestamp when the provider submitted the bid to the blockchain.
245
- * Useful for sorting by bid age or showing "time since bid" UI.
246
- */
247
- readonly createdAt: Date;
248
- }
249
- /**
250
- * Bid selection function signature
251
- *
252
- * A function that takes an array of enhanced bids and returns the selected bid
253
- * (or null if none are acceptable). Can be synchronous or asynchronous to support
254
- * different selection strategies:
255
- *
256
- * - **Synchronous**: Simple algorithmic selection (cheapest, most reliable, etc.)
257
- * - **Asynchronous**: Interactive selection (user prompts, API calls, external validation)
258
- *
259
- * **Contract:**
260
- * - Input: Array of at least one EnhancedBid
261
- * - Output: Selected EnhancedBid or null if none are acceptable
262
- * - Throws: Should not throw - return null instead for unacceptable bids
263
- *
264
- * **Return null when:**
265
- * - No bids meet your criteria
266
- * - User cancels selection (in interactive mode)
267
- * - External validation fails
268
- *
269
- * @example Simple synchronous selector
270
- * ```typescript
271
- * const selectCheapest: BidSelector = (bids) => {
272
- * if (bids.length === 0) return null;
273
- * return bids.reduce((cheapest, current) =>
274
- * current.pricing.uakt.perMonth < cheapest.pricing.uakt.perMonth
275
- * ? current
276
- * : cheapest
277
- * );
278
- * };
279
- * ```
280
- *
281
- * @example Asynchronous interactive selector
282
- * ```typescript
283
- * const selectInteractive: BidSelector = async (bids) => {
284
- * console.log('Available providers:');
285
- * bids.forEach((bid, i) => {
286
- * console.log(`${i + 1}. ${bid.provider.name} - ${bid.pricing.akt.perMonth} AKT/month`);
287
- * });
288
- *
289
- * const choice = await promptUser('Select provider (1-' + bids.length + '): ');
290
- * const index = parseInt(choice) - 1;
291
- *
292
- * return bids[index] ?? null;
293
- * };
294
- * ```
295
- */
296
- export type BidSelector = ((bids: EnhancedBid[]) => Promise<EnhancedBid | null>) | ((bids: EnhancedBid[]) => EnhancedBid | null);
297
- //# sourceMappingURL=bid-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bid-types.d.ts","sourceRoot":"","sources":["../../../src/targets/akash/bid-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAyB3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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gBAAgB,CAAC,KAAK,EAAE;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,UAAU,CA2Cb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAE1B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAEhC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,MAAM,WAAW,GACnB,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,GACtD,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,WAAW,GAAG,IAAI,CAAC,CAAC"}
@@ -1,89 +0,0 @@
1
- /**
2
- * Bid Types and Pricing
3
- *
4
- * Type definitions for enhanced provider bids including comprehensive pricing
5
- * calculations across multiple time periods (hour, day, week, month) and
6
- * currencies (uAKT, AKT, USD).
7
- *
8
- * @module targets/akash/bid-types
9
- */
10
- /**
11
- * Average time between blocks on Akash Network (in seconds)
12
- *
13
- * This value is determined empirically by observing actual block times.
14
- * Akash Console uses 6.098 seconds as the average.
15
- *
16
- * Used for calculating time-based pricing from per-block prices.
17
- */
18
- const AVERAGE_BLOCK_TIME_SECONDS = 6.098;
19
- /**
20
- * Average number of days in a month (365.25 / 12)
21
- *
22
- * Using the astronomical year (365.25 days) divided by 12 months
23
- * provides accurate monthly cost estimates accounting for leap years.
24
- */
25
- const AVERAGE_DAYS_IN_MONTH = 30.437;
26
- /**
27
- * Conversion factor: 1 AKT = 1,000,000 uAKT
28
- */
29
- const UAKT_PER_AKT = 1_000_000;
30
- /**
31
- * Create BidPricing instance from blockchain price data
32
- *
33
- * Calculates all time-period prices from the raw per-block price.
34
- *
35
- * @param price - Price object from blockchain bid
36
- * @param price.denom - Denomination (typically "uakt")
37
- * @param price.amount - Amount per block as string
38
- * @returns Complete pricing information across all time periods
39
- *
40
- * @example
41
- * ```typescript
42
- * const pricing = createBidPricing({
43
- * denom: 'uakt',
44
- * amount: '1234'
45
- * });
46
- * console.log(pricing.akt.perMonth); // Monthly cost in AKT
47
- * ```
48
- */
49
- export function createBidPricing(price) {
50
- // Parse raw price per block
51
- const pricePerBlock = parseFloat(price.amount);
52
- // Calculate number of blocks for each time period
53
- const blocksPerHour = (60 * 60) / AVERAGE_BLOCK_TIME_SECONDS;
54
- const blocksPerDay = (24 * 60 * 60) / AVERAGE_BLOCK_TIME_SECONDS;
55
- const blocksPerWeek = (7 * 24 * 60 * 60) / AVERAGE_BLOCK_TIME_SECONDS;
56
- const blocksPerMonth = (AVERAGE_DAYS_IN_MONTH * 24 * 60 * 60) / AVERAGE_BLOCK_TIME_SECONDS;
57
- // Calculate prices in uAKT for all time periods
58
- const uaktPricing = {
59
- perBlock: pricePerBlock,
60
- perHour: pricePerBlock * blocksPerHour,
61
- perDay: pricePerBlock * blocksPerDay,
62
- perWeek: pricePerBlock * blocksPerWeek,
63
- perMonth: pricePerBlock * blocksPerMonth,
64
- };
65
- // Calculate prices in AKT (divide uAKT by 1,000,000)
66
- const aktPricing = {
67
- perBlock: uaktPricing.perBlock / UAKT_PER_AKT,
68
- perHour: uaktPricing.perHour / UAKT_PER_AKT,
69
- perDay: uaktPricing.perDay / UAKT_PER_AKT,
70
- perWeek: uaktPricing.perWeek / UAKT_PER_AKT,
71
- perMonth: uaktPricing.perMonth / UAKT_PER_AKT,
72
- };
73
- // Return pricing object with USD conversion method
74
- return {
75
- raw: {
76
- denom: price.denom,
77
- amount: price.amount,
78
- },
79
- uakt: uaktPricing,
80
- akt: aktPricing,
81
- toUSD: (aktPriceUSD) => ({
82
- perHour: aktPricing.perHour * aktPriceUSD,
83
- perDay: aktPricing.perDay * aktPriceUSD,
84
- perWeek: aktPricing.perWeek * aktPriceUSD,
85
- perMonth: aktPricing.perMonth * aktPriceUSD,
86
- }),
87
- };
88
- }
89
- //# sourceMappingURL=bid-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bid-types.js","sourceRoot":"","sources":["../../../src/targets/akash/bid-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;;;;;GAOG;AACH,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAErC;;GAEG;AACH,MAAM,YAAY,GAAG,SAAS,CAAC;AAyH/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAGhC;IACC,4BAA4B;IAC5B,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/C,kDAAkD;IAClD,MAAM,aAAa,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,0BAA0B,CAAC;IAC7D,MAAM,YAAY,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,0BAA0B,CAAC;IACjE,MAAM,aAAa,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,0BAA0B,CAAC;IACtE,MAAM,cAAc,GAAG,CAAC,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,0BAA0B,CAAC;IAE3F,gDAAgD;IAChD,MAAM,WAAW,GAAG;QAClB,QAAQ,EAAE,aAAa;QACvB,OAAO,EAAE,aAAa,GAAG,aAAa;QACtC,MAAM,EAAE,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