@ar.io/sdk 3.24.0 → 4.0.0-alpha.1

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 (169) hide show
  1. package/README.md +682 -600
  2. package/lib/esm/cli/cli.js +188 -152
  3. package/lib/esm/cli/commands/antCommands.js +23 -58
  4. package/lib/esm/cli/commands/arnsPurchaseCommands.js +48 -30
  5. package/lib/esm/cli/commands/escrowCommands.js +221 -0
  6. package/lib/esm/cli/commands/gatewayWriteCommands.js +142 -23
  7. package/lib/esm/cli/commands/pruneCommands.js +150 -0
  8. package/lib/esm/cli/commands/readCommands.js +22 -3
  9. package/lib/esm/cli/commands/transfer.js +6 -6
  10. package/lib/esm/cli/options.js +124 -58
  11. package/lib/esm/cli/utils.js +280 -174
  12. package/lib/esm/common/ant-registry.js +17 -143
  13. package/lib/esm/common/ant.js +44 -1167
  14. package/lib/esm/common/faucet.js +11 -6
  15. package/lib/esm/common/index.js +0 -4
  16. package/lib/esm/common/io.js +25 -1412
  17. package/lib/esm/constants.js +13 -19
  18. package/lib/esm/solana/ant-readable.js +724 -0
  19. package/lib/esm/solana/ant-registry-readable.js +133 -0
  20. package/lib/esm/solana/ant-registry-writeable.js +472 -0
  21. package/lib/esm/solana/ant-writeable.js +384 -0
  22. package/lib/esm/solana/ata.js +70 -0
  23. package/lib/esm/solana/canonical-message.js +128 -0
  24. package/lib/esm/solana/clusters.js +111 -0
  25. package/lib/esm/solana/constants.js +146 -0
  26. package/lib/esm/solana/delegation-math.js +112 -0
  27. package/lib/esm/solana/deserialize.js +711 -0
  28. package/lib/esm/solana/escrow.js +839 -0
  29. package/lib/{cjs/utils/json.js → esm/solana/events.js} +15 -10
  30. package/lib/esm/solana/funding-plan.js +699 -0
  31. package/lib/esm/solana/index.js +126 -0
  32. package/lib/esm/solana/instruction.js +39 -0
  33. package/lib/esm/solana/io-readable.js +2182 -0
  34. package/lib/esm/solana/io-writeable.js +3196 -0
  35. package/lib/esm/solana/json-rpc.js +90 -0
  36. package/lib/esm/solana/metadata.js +81 -0
  37. package/lib/esm/solana/mpl-core.js +192 -0
  38. package/lib/esm/solana/pda.js +332 -0
  39. package/lib/esm/solana/predict-prescribed-observers.js +110 -0
  40. package/lib/esm/solana/retry.js +117 -0
  41. package/lib/esm/solana/rpc-circuit-breaker.js +258 -0
  42. package/lib/esm/solana/send.js +372 -0
  43. package/lib/esm/solana/spawn-ant.js +224 -0
  44. package/lib/esm/solana/types.js +1 -0
  45. package/lib/esm/types/ant.js +27 -15
  46. package/lib/esm/types/io.js +8 -11
  47. package/lib/esm/utils/ant.js +0 -63
  48. package/lib/esm/utils/index.js +0 -3
  49. package/lib/esm/version.js +1 -1
  50. package/lib/types/cli/commands/antCommands.d.ts +5 -13
  51. package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +33 -7
  52. package/lib/types/cli/commands/escrowCommands.d.ts +68 -0
  53. package/lib/types/cli/commands/gatewayWriteCommands.d.ts +12 -11
  54. package/lib/types/cli/commands/pruneCommands.d.ts +31 -0
  55. package/lib/types/cli/commands/readCommands.d.ts +27 -22
  56. package/lib/types/cli/commands/transfer.d.ts +9 -9
  57. package/lib/types/cli/options.d.ts +76 -21
  58. package/lib/types/cli/types.d.ts +11 -13
  59. package/lib/types/cli/utils.d.ts +71 -31
  60. package/lib/types/common/ant-registry.d.ts +49 -47
  61. package/lib/types/common/ant.d.ts +54 -539
  62. package/lib/types/common/faucet.d.ts +20 -8
  63. package/lib/types/common/index.d.ts +0 -3
  64. package/lib/types/common/io.d.ts +51 -263
  65. package/lib/types/constants.d.ts +11 -18
  66. package/lib/types/solana/ant-readable.d.ts +180 -0
  67. package/lib/types/solana/ant-registry-readable.d.ts +105 -0
  68. package/lib/types/solana/ant-registry-writeable.d.ts +249 -0
  69. package/lib/types/solana/ant-writeable.d.ts +177 -0
  70. package/lib/types/solana/ata.d.ts +44 -0
  71. package/lib/types/solana/canonical-message.d.ts +121 -0
  72. package/lib/types/solana/clusters.d.ts +109 -0
  73. package/lib/types/solana/constants.d.ts +119 -0
  74. package/lib/types/solana/delegation-math.d.ts +45 -0
  75. package/lib/types/solana/deserialize.d.ts +262 -0
  76. package/lib/types/solana/escrow.d.ts +480 -0
  77. package/lib/types/solana/events.d.ts +38 -0
  78. package/lib/types/solana/funding-plan.d.ts +225 -0
  79. package/lib/types/solana/index.d.ts +87 -0
  80. package/lib/types/solana/instruction.d.ts +39 -0
  81. package/lib/types/solana/io-readable.d.ts +499 -0
  82. package/lib/types/solana/io-writeable.d.ts +893 -0
  83. package/lib/types/solana/json-rpc.d.ts +47 -0
  84. package/lib/types/solana/metadata.d.ts +84 -0
  85. package/lib/types/solana/mpl-core.d.ts +120 -0
  86. package/lib/types/solana/pda.d.ts +95 -0
  87. package/lib/types/solana/predict-prescribed-observers.d.ts +28 -0
  88. package/lib/types/solana/retry.d.ts +62 -0
  89. package/lib/types/solana/rpc-circuit-breaker.d.ts +78 -0
  90. package/lib/types/solana/send.d.ts +94 -0
  91. package/lib/types/solana/spawn-ant.d.ts +145 -0
  92. package/lib/types/solana/types.d.ts +82 -0
  93. package/lib/types/types/ant-registry.d.ts +43 -4
  94. package/lib/types/types/ant.d.ts +114 -96
  95. package/lib/types/types/common.d.ts +18 -74
  96. package/lib/types/types/faucet.d.ts +2 -2
  97. package/lib/types/types/io.d.ts +244 -158
  98. package/lib/types/types/token.d.ts +0 -12
  99. package/lib/types/utils/ant.d.ts +1 -12
  100. package/lib/types/utils/index.d.ts +0 -3
  101. package/lib/types/version.d.ts +1 -1
  102. package/package.json +36 -33
  103. package/lib/cjs/cli/cli.js +0 -822
  104. package/lib/cjs/cli/commands/antCommands.js +0 -113
  105. package/lib/cjs/cli/commands/arnsPurchaseCommands.js +0 -212
  106. package/lib/cjs/cli/commands/gatewayWriteCommands.js +0 -210
  107. package/lib/cjs/cli/commands/readCommands.js +0 -215
  108. package/lib/cjs/cli/commands/transfer.js +0 -159
  109. package/lib/cjs/cli/options.js +0 -470
  110. package/lib/cjs/cli/types.js +0 -2
  111. package/lib/cjs/cli/utils.js +0 -639
  112. package/lib/cjs/common/ant-registry.js +0 -155
  113. package/lib/cjs/common/ant-versions.js +0 -93
  114. package/lib/cjs/common/ant.js +0 -1182
  115. package/lib/cjs/common/arweave.js +0 -27
  116. package/lib/cjs/common/contracts/ao-process.js +0 -224
  117. package/lib/cjs/common/error.js +0 -64
  118. package/lib/cjs/common/faucet.js +0 -150
  119. package/lib/cjs/common/hyperbeam/hb.js +0 -173
  120. package/lib/cjs/common/index.js +0 -42
  121. package/lib/cjs/common/io.js +0 -1423
  122. package/lib/cjs/common/logger.js +0 -83
  123. package/lib/cjs/common/loggers/winston.js +0 -68
  124. package/lib/cjs/common/marketplace.js +0 -731
  125. package/lib/cjs/common/turbo.js +0 -223
  126. package/lib/cjs/constants.js +0 -41
  127. package/lib/cjs/node/index.js +0 -39
  128. package/lib/cjs/package.json +0 -1
  129. package/lib/cjs/types/ant-registry.js +0 -2
  130. package/lib/cjs/types/ant.js +0 -168
  131. package/lib/cjs/types/common.js +0 -2
  132. package/lib/cjs/types/faucet.js +0 -2
  133. package/lib/cjs/types/index.js +0 -37
  134. package/lib/cjs/types/io.js +0 -51
  135. package/lib/cjs/types/token.js +0 -116
  136. package/lib/cjs/utils/ant.js +0 -108
  137. package/lib/cjs/utils/ao.js +0 -432
  138. package/lib/cjs/utils/arweave.js +0 -285
  139. package/lib/cjs/utils/base64.js +0 -62
  140. package/lib/cjs/utils/hash.js +0 -56
  141. package/lib/cjs/utils/index.js +0 -38
  142. package/lib/cjs/utils/processes.js +0 -173
  143. package/lib/cjs/utils/random.js +0 -30
  144. package/lib/cjs/utils/schema.js +0 -15
  145. package/lib/cjs/utils/url.js +0 -37
  146. package/lib/cjs/version.js +0 -20
  147. package/lib/cjs/web/index.js +0 -41
  148. package/lib/esm/common/ant-versions.js +0 -87
  149. package/lib/esm/common/arweave.js +0 -21
  150. package/lib/esm/common/contracts/ao-process.js +0 -220
  151. package/lib/esm/common/hyperbeam/hb.js +0 -169
  152. package/lib/esm/common/marketplace.js +0 -724
  153. package/lib/esm/common/turbo.js +0 -215
  154. package/lib/esm/node/index.js +0 -20
  155. package/lib/esm/utils/ao.js +0 -420
  156. package/lib/esm/utils/arweave.js +0 -271
  157. package/lib/esm/utils/processes.js +0 -167
  158. package/lib/esm/web/index.js +0 -20
  159. package/lib/types/common/ant-versions.d.ts +0 -39
  160. package/lib/types/common/arweave.d.ts +0 -17
  161. package/lib/types/common/contracts/ao-process.d.ts +0 -47
  162. package/lib/types/common/hyperbeam/hb.d.ts +0 -88
  163. package/lib/types/common/marketplace.d.ts +0 -568
  164. package/lib/types/common/turbo.d.ts +0 -61
  165. package/lib/types/node/index.d.ts +0 -20
  166. package/lib/types/utils/ao.d.ts +0 -80
  167. package/lib/types/utils/arweave.d.ts +0 -79
  168. package/lib/types/utils/processes.d.ts +0 -39
  169. package/lib/types/web/index.d.ts +0 -20
@@ -1,568 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { AOProcess, AoSigner, Logger } from '../node/index.js';
17
- import { AoMessageResult, WalletAddress } from '../types/common.js';
18
- import { AoARIOWrite, PaginationParams, PaginationResult } from '../types/io.js';
19
- /**
20
- * User-provided order parameters for intent-based order creation
21
- * These are the user-configurable fields when creating an order via the intent workflow
22
- * @experimental
23
- */
24
- export interface MarketplaceOrderIntentParams {
25
- orderType?: 'fixed' | 'dutch' | 'english';
26
- quantity?: string;
27
- price?: string;
28
- expirationTime?: string;
29
- minimumPrice?: string;
30
- decreaseInterval?: string;
31
- }
32
- /**
33
- * Intent structure - matches Lua Intent type
34
- * @experimental
35
- */
36
- export interface MarketplaceIntent {
37
- intentId: string;
38
- initiator: string;
39
- action: string;
40
- status: 'pending' | 'active' | 'settling' | 'completed' | 'resolved' | 'failed';
41
- createdAt: number;
42
- ttl?: number;
43
- resolvedAt?: number;
44
- completedAt?: number;
45
- failureReason?: string;
46
- orderParams: MarketplaceOrderIntentParams;
47
- antProcessId: string;
48
- }
49
- /**
50
- * Fee information structure for calculating order costs
51
- * @experimental
52
- */
53
- export interface MarketplaceFeeInfo {
54
- listingFeePerHour: string;
55
- saleTaxNumerator: number;
56
- saleTaxDenominator: number;
57
- }
58
- /**
59
- * Intent statistics structure
60
- * @experimental
61
- */
62
- export interface MarketplaceIntentStats {
63
- total: number;
64
- byStatus: Record<string, number>;
65
- byType: Record<string, number>;
66
- byAction: Record<string, number>;
67
- }
68
- /**
69
- * Activity information structure
70
- * @experimental
71
- */
72
- export interface MarketplaceActivityInfo {
73
- totalOrders: number;
74
- activeOrders: number;
75
- readyForSettlement: number;
76
- executedOrders: number;
77
- cancelledOrders: number;
78
- expiredOrders: number;
79
- listedOrders: number;
80
- }
81
- /**
82
- * Marketplace information structure
83
- * @experimental
84
- */
85
- export interface MarketplaceInfo {
86
- totalPairs: number;
87
- accruedFees: string;
88
- arioTokenProcess: string;
89
- }
90
- /**
91
- * Info response structure from the marketplace
92
- * @experimental
93
- */
94
- export interface InfoResponse {
95
- name: string;
96
- processId: string;
97
- activity: MarketplaceActivityInfo;
98
- intents: MarketplaceIntentStats;
99
- ucm: MarketplaceInfo;
100
- whitelistedModules: string[];
101
- fees: MarketplaceFeeInfo;
102
- }
103
- /**
104
- * Parameters for creating an intent (Create-Order action is assumed)
105
- * @experimental
106
- */
107
- export interface CreateIntentParams {
108
- antId: string;
109
- orderType: string;
110
- quantity: string;
111
- price: string;
112
- expirationTime: string;
113
- minimumPrice?: string;
114
- decreaseInterval?: string;
115
- }
116
- /**
117
- * Parameters for paginated intent queries
118
- * @experimental
119
- */
120
- export interface GetPaginatedIntentsParams {
121
- cursor?: string;
122
- limit?: number;
123
- sortBy?: string;
124
- sortOrder?: 'asc' | 'desc';
125
- filters?: Record<string, string>;
126
- }
127
- /**
128
- * Parameters for creating an order using internal ARIO balance
129
- * @experimental
130
- */
131
- export interface CreateOrderParams {
132
- swapToken: string;
133
- quantity: string;
134
- orderType?: 'fixed' | 'dutch' | 'english';
135
- price?: string;
136
- expirationTime?: string;
137
- minimumPrice?: string;
138
- decreaseInterval?: string;
139
- transferDenomination?: string;
140
- }
141
- /**
142
- * Parameters for getting orders with flexible selectors
143
- * @experimental
144
- */
145
- export interface GetOrdersParams extends GetPaginatedIntentsParams {
146
- status?: 'all' | 'listed' | 'completed' | 'active' | 'ready-for-settlement' | 'executed' | 'cancelled' | 'expired';
147
- ids?: string[];
148
- dominantToken?: string;
149
- swapToken?: string;
150
- }
151
- /**
152
- * Individual order structure returned from Get-Orders and Get-Order handlers
153
- * @experimental
154
- */
155
- export interface Order {
156
- id: string;
157
- creator: string;
158
- quantity: string;
159
- originalQuantity: string;
160
- token: string;
161
- dominantToken: string;
162
- swapToken: string;
163
- dateCreated: number;
164
- price?: string;
165
- expirationTime?: number;
166
- orderType: 'fixed' | 'dutch' | 'english';
167
- status: 'active' | 'executed' | 'cancelled' | 'ready-for-settlement' | 'expired';
168
- minimumPrice?: string;
169
- decreaseInterval?: string;
170
- decreaseStep?: string;
171
- sender?: string;
172
- receiver?: string;
173
- endedAt?: number;
174
- bids?: Record<string, boolean>;
175
- }
176
- /**
177
- * Marketplace balance information for a wallet address
178
- * @experimental
179
- */
180
- export interface MarketplaceBalance {
181
- address: WalletAddress;
182
- balance: string;
183
- lockedBalance: string;
184
- totalBalance: string;
185
- orders: Record<string, string>;
186
- }
187
- /**
188
- * Read-only interface for the ArNS marketplace
189
- * @experimental
190
- */
191
- export interface AoArNSMarketplaceRead {
192
- getInfo(): Promise<InfoResponse>;
193
- getPaginatedIntents(params: GetPaginatedIntentsParams): Promise<PaginationResult<MarketplaceIntent>>;
194
- getIntent(intentId: string): Promise<MarketplaceIntent>;
195
- getIntentByANTId(antId: string): Promise<MarketplaceIntent>;
196
- getPaginatedOrders(params: GetOrdersParams): Promise<PaginationResult<Order>>;
197
- getOrder(orderId: string): Promise<Order>;
198
- getOrderByANTId(antId: string): Promise<Order>;
199
- getPaginatedMarketplaceBalances(params: PaginationParams<MarketplaceBalance>): Promise<PaginationResult<MarketplaceBalance>>;
200
- getMarketplaceBalance({ address, }: {
201
- address: WalletAddress;
202
- }): Promise<MarketplaceBalance>;
203
- /**
204
- * Get all user assets including intents, orders, balances, and ANT IDs
205
- * @param params - Parameters including address and ARIO process ID
206
- * @returns User assets including intents, orders, balances, and ANT IDs
207
- */
208
- getUserAssets({ address, arioProcessId, }: {
209
- address: WalletAddress;
210
- arioProcessId: string;
211
- }): Promise<{
212
- intents: MarketplaceIntent[];
213
- orders: Order[];
214
- balances: MarketplaceBalance;
215
- antIds: string[];
216
- }>;
217
- }
218
- /**
219
- * Common fields for create-intent progress events
220
- * @experimental
221
- */
222
- export interface CreateIntentEventData {
223
- name: string;
224
- antId: string;
225
- orderType: 'fixed' | 'dutch' | 'english';
226
- price: string;
227
- expirationTime: number;
228
- }
229
- /**
230
- * Progress event emitted while creating the marketplace intent
231
- * @experimental
232
- */
233
- export interface CreatingIntentProgressEvent extends CreateIntentEventData {
234
- step: 'creating-intent';
235
- }
236
- /**
237
- * Progress event emitted after successfully creating the marketplace intent
238
- * @experimental
239
- */
240
- export interface IntentCreatedProgressEvent extends CreateIntentEventData {
241
- step: 'intent-created';
242
- intent: MarketplaceIntent;
243
- }
244
- /**
245
- * Common fields for transfer-ant progress events
246
- * @experimental
247
- */
248
- export interface TransferAntEventData {
249
- name: string;
250
- antId: string;
251
- intentId: string;
252
- marketplaceProcessId: string;
253
- }
254
- /**
255
- * Progress event emitted while transferring the ANT to the marketplace
256
- * @experimental
257
- */
258
- export interface TransferringAntProgressEvent extends TransferAntEventData {
259
- step: 'transferring-ant';
260
- }
261
- /**
262
- * Progress event emitted after successfully transferring the ANT to the marketplace
263
- * @experimental
264
- */
265
- export interface AntTransferredProgressEvent extends TransferAntEventData {
266
- step: 'ant-transferred';
267
- transferResult: AoMessageResult<Record<string, string | number | boolean | null>>;
268
- }
269
- /**
270
- * Progress event emitted when an error occurs during the workflow
271
- * @experimental
272
- */
273
- export interface ListNameForSaleErrorEvent {
274
- step: 'error';
275
- name: string;
276
- antId: string;
277
- error: Error;
278
- /**
279
- * The step that was in progress when the error occurred
280
- */
281
- failedStep: 'creating-intent' | 'transferring-ant';
282
- /**
283
- * The intent if it was created before the error occurred
284
- */
285
- intent?: MarketplaceIntent;
286
- }
287
- /**
288
- * Progress event emitted when the workflow completes successfully
289
- * @experimental
290
- */
291
- export interface ListNameForSaleCompleteEvent {
292
- step: 'complete';
293
- name: string;
294
- antId: string;
295
- intent: MarketplaceIntent;
296
- order: Order;
297
- transferResult: AoMessageResult<Record<string, string | number | boolean | null>>;
298
- }
299
- /**
300
- * Progress events emitted during listNameForSale workflow
301
- * @experimental
302
- */
303
- export type ListNameForSaleProgressEvent = CreatingIntentProgressEvent | IntentCreatedProgressEvent | TransferringAntProgressEvent | AntTransferredProgressEvent | ListNameForSaleErrorEvent | ListNameForSaleCompleteEvent;
304
- /**
305
- * Timeout and retry options for listNameForSale status checks and polling.
306
- * Used when checking for intent (e.g. getIntentByANTId), transfer confirmation, and order listing.
307
- * @experimental
308
- */
309
- export interface ListNameForSaleTimeoutOptions {
310
- /** Max retries when polling for intent, transfer confirmation, or order listing. Default 5. */
311
- maxRetries?: number;
312
- /** Base interval in ms for exponential backoff between status polls / retries. Wait time is base * 2^attempt. Default 1000. */
313
- statusPollIntervalMs?: number;
314
- }
315
- /**
316
- * Write interface for the ArNS marketplace
317
- * @experimental
318
- */
319
- export interface AoArNSMarketplaceWrite {
320
- createIntent(params: CreateIntentParams): Promise<AoMessageResult<MarketplaceIntent>>;
321
- cancelOrder(orderId: string): Promise<AoMessageResult>;
322
- settleAuction(params: {
323
- orderId: string;
324
- dominantToken?: string;
325
- swapToken?: string;
326
- }): Promise<AoMessageResult>;
327
- depositArIO(params: {
328
- amount: string;
329
- }): Promise<AoMessageResult>;
330
- withdrawArIO(params: {
331
- amount: string;
332
- }): Promise<AoMessageResult>;
333
- /**
334
- * Push ANT intent resolution to the marketplace
335
- * @param intentId - The intent ID to push resolution for
336
- * @returns Message result
337
- */
338
- pushANTIntentResolution(intentId: string): Promise<AoMessageResult>;
339
- /**
340
- * List a name for sale on the marketplace
341
- * @param params - Parameters including name, expiration time, price, type, wallet address, and optional auction parameters
342
- * @param timeoutOptions - Optional retries and wait times for intent, transfer, and order listing status polling
343
- * @returns Result containing intent, order, ANT transfer result, and any error
344
- */
345
- listNameForSale({ name, expirationTime, price, type, walletAddress, minimumPrice, decreaseInterval, onProgress, }: {
346
- name: string;
347
- expirationTime: number;
348
- price: string;
349
- type: 'fixed' | 'dutch' | 'english';
350
- walletAddress: WalletAddress;
351
- minimumPrice?: string;
352
- decreaseInterval?: string;
353
- onProgress?: (event: ListNameForSaleProgressEvent) => void;
354
- }, timeoutOptions?: ListNameForSaleTimeoutOptions): Promise<{
355
- intent: MarketplaceIntent;
356
- order: Order | null;
357
- antTransferResult: AoMessageResult<Record<string, string | number | boolean | null>> | null;
358
- error: Error | null;
359
- }>;
360
- /**
361
- * Create an order using internal ARIO balance
362
- * @param params - Order creation parameters
363
- * @returns Message result with the created order
364
- */
365
- createOrder(params: CreateOrderParams): Promise<AoMessageResult<Order>>;
366
- /**
367
- * Buy a fixed price ANT
368
- * @param params - Parameters including ANT ID
369
- * @returns Message result with the order
370
- */
371
- buyFixedPriceANT(params: {
372
- antId: string;
373
- }): Promise<AoMessageResult<Order>>;
374
- /**
375
- * Buy a Dutch auction ANT
376
- * @param params - Parameters including ANT ID
377
- * @returns Message result with the order
378
- */
379
- buyDutchAuctionANT(params: {
380
- antId: string;
381
- }): Promise<AoMessageResult<Order>>;
382
- /**
383
- * Place a bid on an English auction
384
- * @param params - Parameters including ANT ID and bid amount
385
- * @returns Message result
386
- */
387
- bidOnANTEnglishAuction(params: {
388
- antId: string;
389
- bidAmount: string;
390
- }): Promise<AoMessageResult>;
391
- /**
392
- * Settle an expired English auction
393
- * @param params - Parameters including ANT ID
394
- * @returns Message result
395
- */
396
- settleANTEnglishAuction(params: {
397
- antId: string;
398
- }): Promise<AoMessageResult>;
399
- }
400
- /**
401
- * Read-only client for the ArNS marketplace
402
- * @experimental
403
- */
404
- export declare class ArNSMarketplaceRead implements AoArNSMarketplaceRead {
405
- protected process: AOProcess;
406
- protected logger: Logger;
407
- constructor({ process, logger, }: {
408
- process: AOProcess;
409
- logger?: Logger;
410
- });
411
- getInfo(): Promise<InfoResponse>;
412
- getPaginatedIntents({ cursor, limit, sortBy, sortOrder, filters, }?: GetPaginatedIntentsParams): Promise<PaginationResult<MarketplaceIntent>>;
413
- getIntent(intentId: string): Promise<MarketplaceIntent>;
414
- getIntentByANTId(antId: string): Promise<MarketplaceIntent>;
415
- /**
416
- * Get orders with flexible selectors
417
- * @param params - Parameters for filtering and pagination
418
- * @returns Orders matching the criteria
419
- */
420
- getPaginatedOrders(params?: GetOrdersParams): Promise<PaginationResult<Order>>;
421
- /**
422
- * Get a single order by ID
423
- * @param orderId - The order ID to fetch
424
- * @returns The order if found
425
- */
426
- getOrder(orderId: string): Promise<Order>;
427
- getOrderByANTId(antId: string): Promise<Order>;
428
- getPaginatedMarketplaceBalances(params: PaginationParams<MarketplaceBalance>): Promise<PaginationResult<MarketplaceBalance>>;
429
- /**
430
- * Get ARIO balance for an address in the marketplace
431
- */
432
- getMarketplaceBalance({ address, }: {
433
- address: WalletAddress;
434
- }): Promise<MarketplaceBalance>;
435
- getUserAssets({ address, arioProcessId, }: {
436
- address: WalletAddress;
437
- arioProcessId: string;
438
- }): Promise<{
439
- intents: MarketplaceIntent[];
440
- orders: Order[];
441
- balances: MarketplaceBalance;
442
- antIds: string[];
443
- }>;
444
- }
445
- /**
446
- * Write client for the ArNS marketplace
447
- * @experimental
448
- */
449
- export declare class ArNSMarketplaceWrite extends ArNSMarketplaceRead implements AoArNSMarketplaceWrite {
450
- protected process: AOProcess;
451
- protected signer: AoSigner;
452
- protected ario: AoARIOWrite;
453
- constructor({ process, signer, ario, logger, }: {
454
- process: AOProcess;
455
- signer: AoSigner;
456
- ario: AoARIOWrite;
457
- logger?: Logger;
458
- });
459
- /**
460
- * Deposit ARIO to the marketplace (simulates Credit-Notice from ARIO token process)
461
- * Returns the message ID for verification
462
- */
463
- depositArIO(params: {
464
- amount: string;
465
- }): Promise<AoMessageResult>;
466
- /**
467
- * Withdraw ARIO from the marketplace back to user
468
- */
469
- withdrawArIO(params: {
470
- amount: string;
471
- }): Promise<AoMessageResult>;
472
- createIntent({ antId, orderType, quantity, price, expirationTime, minimumPrice, decreaseInterval, }: CreateIntentParams): Promise<AoMessageResult<MarketplaceIntent>>;
473
- pushANTIntentResolution(intentId: string): Promise<AoMessageResult>;
474
- settleAuction(params: {
475
- orderId: string;
476
- dominantToken?: string;
477
- swapToken?: string;
478
- }): Promise<AoMessageResult>;
479
- listNameForSale({ name, expirationTime, price, type, walletAddress, minimumPrice, decreaseInterval, onProgress, }: {
480
- name: string;
481
- expirationTime: number;
482
- price: string;
483
- type: 'fixed' | 'dutch' | 'english';
484
- walletAddress: WalletAddress;
485
- minimumPrice?: string;
486
- decreaseInterval?: string;
487
- onProgress?: (event: ListNameForSaleProgressEvent) => void;
488
- }, timeoutOptions?: ListNameForSaleTimeoutOptions): Promise<{
489
- intent: MarketplaceIntent;
490
- order: Order | null;
491
- antTransferResult: AoMessageResult<Record<string, string | number | boolean | null>> | null;
492
- error: Error | null;
493
- }>;
494
- cancelOrder(orderId: string): Promise<AoMessageResult>;
495
- createOrder({ swapToken, quantity, orderType, price, expirationTime, minimumPrice, decreaseInterval, transferDenomination, }: CreateOrderParams): Promise<AoMessageResult<Order>>;
496
- buyFixedPriceANT(params: {
497
- antId: string;
498
- }): Promise<AoMessageResult<Order>>;
499
- buyDutchAuctionANT(params: {
500
- antId: string;
501
- }): Promise<AoMessageResult<Order>>;
502
- /**
503
- * Place a bid on an English auction
504
- * Note: This requires you to have sufficient ARIO balance in the marketplace
505
- */
506
- bidOnANTEnglishAuction(params: {
507
- antId: string;
508
- bidAmount: string;
509
- }): Promise<AoMessageResult>;
510
- /**
511
- * Settle an expired English auction
512
- * Can be called by anyone after the auction expires
513
- * The highest bidder wins the ANT
514
- */
515
- settleANTEnglishAuction(params: {
516
- antId: string;
517
- }): Promise<AoMessageResult>;
518
- }
519
- /**
520
- * Calculates the listing fee for an order based on the end timestamp.
521
- * The fee is calculated by rounding up the hours until the end timestamp to the nearest hour.
522
- *
523
- * @experimental
524
- * @param params - Parameters for calculating the listing fee
525
- * @param params.listingFeePerHour - The listing fee per hour in mARIO (as a string)
526
- * @param params.endTimestamp - Unix timestamp when the order expires
527
- * @returns The listing fee in mARIO as a BigInt
528
- *
529
- * @example
530
- * ```typescript
531
- * const info = await marketplace.getInfo();
532
- * const endTimestamp = Date.now() + 24 * 60 * 60 * 1000; // 24 hours from now
533
- * const listingFee = calculateListingFee({
534
- * listingFeePerHour: info.fees.listingFeePerHour,
535
- * endTimestamp,
536
- * });
537
- * ```
538
- */
539
- export declare function calculateListingFee({ listingFeePerHour, endTimestamp, }: {
540
- listingFeePerHour: string;
541
- endTimestamp: number;
542
- }): bigint;
543
- /**
544
- * Calculates the sale tax for an order based on the sale amount.
545
- *
546
- * @experimental
547
- * @param params - Parameters for calculating the sale tax
548
- * @param params.saleAmount - The sale amount in mARIO (as a string or number)
549
- * @param params.saleTaxNumerator - The numerator for sale tax calculation
550
- * @param params.saleTaxDenominator - The denominator for sale tax calculation
551
- * @returns The sale tax in mARIO as a BigInt
552
- *
553
- * @example
554
- * ```typescript
555
- * const info = await marketplace.getInfo();
556
- * const saleAmount = 100000000000; // 100 ARIO in mARIO
557
- * const tax = calculateSaleTax({
558
- * saleAmount,
559
- * saleTaxNumerator: info.fees.saleTaxNumerator,
560
- * saleTaxDenominator: info.fees.saleTaxDenominator,
561
- * });
562
- * ```
563
- */
564
- export declare function calculateSaleTax({ saleAmount, saleTaxNumerator, saleTaxDenominator, }: {
565
- saleAmount: string | number;
566
- saleTaxNumerator: number;
567
- saleTaxDenominator: number;
568
- }): bigint;
@@ -1,61 +0,0 @@
1
- import { AoMessageResult, TransactionId, TurboArNSSigner } from '../types/common.js';
2
- import { AoTokenCostParams } from '../types/io.js';
3
- import { mARIOToken } from '../types/token.js';
4
- import { ILogger } from './logger.js';
5
- export interface TurboUnauthenticatedConfig {
6
- paymentUrl?: string;
7
- logger?: ILogger;
8
- }
9
- export interface TurboAuthenticatedConfig extends TurboUnauthenticatedConfig {
10
- signer: TurboArNSSigner;
11
- }
12
- export declare const defaultHeaders: Record<string, string>;
13
- export declare function signedRequestHeadersFromSigner({ signer, nonce, }: {
14
- signer: TurboArNSSigner;
15
- nonce?: string;
16
- }): Promise<Record<string, string>>;
17
- export type ArNSPurchaseReceipt = AoTokenCostParams & {
18
- wincQty: string;
19
- mARIOQty: string;
20
- usdArRate: number;
21
- createdDate: string;
22
- };
23
- export interface ArNSPaymentProvider {
24
- /** Returns the cost of the action in the Payment Provider's native currency (winc for Turbo) */
25
- getPrice(params: AoTokenCostParams): Promise<number>;
26
- getArNSPriceDetails(params: AoTokenCostParams): Promise<{
27
- winc: string;
28
- mARIO: mARIOToken;
29
- }>;
30
- }
31
- export interface TurboInitiateArNSPurchaseParams extends AoTokenCostParams {
32
- processId?: TransactionId;
33
- paidBy?: string | string[];
34
- referrer?: string;
35
- }
36
- export interface ArNSAuthenticatedPaymentProvider extends ArNSPaymentProvider {
37
- initiateArNSPurchase(params: TurboInitiateArNSPurchaseParams): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
38
- }
39
- export declare class TurboArNSPaymentFactory {
40
- static init(): TurboArNSPaymentProviderUnauthenticated;
41
- static init({ paymentUrl, logger, }: TurboUnauthenticatedConfig & {
42
- signer?: TurboArNSSigner;
43
- }): TurboArNSPaymentProviderUnauthenticated;
44
- static init({ signer, paymentUrl, logger, }: TurboAuthenticatedConfig): TurboArNSPaymentProviderAuthenticated;
45
- }
46
- export declare class TurboArNSPaymentProviderUnauthenticated implements ArNSPaymentProvider {
47
- protected readonly paymentUrl: string;
48
- protected readonly logger: ILogger;
49
- constructor({ paymentUrl, logger, }: TurboUnauthenticatedConfig);
50
- getArNSPriceDetails({ intent, name, quantity, type, years, }: AoTokenCostParams): Promise<{
51
- winc: string;
52
- mARIO: mARIOToken;
53
- }>;
54
- getPrice(params: AoTokenCostParams): Promise<number>;
55
- }
56
- export declare class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProviderUnauthenticated implements ArNSAuthenticatedPaymentProvider {
57
- private readonly signer;
58
- constructor({ signer, ...restConfig }: TurboAuthenticatedConfig);
59
- initiateArNSPurchase({ intent, name, quantity, type, processId, years, paidBy, referrer, }: TurboInitiateArNSPurchaseParams): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
60
- }
61
- export declare function isTurboArNSSigner(signer: unknown): signer is TurboArNSSigner;
@@ -1,20 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export { ArweaveSigner, ArconnectSigner } from '@dha-team/arbundles';
17
- export * from '../types/index.js';
18
- export * from '../common/index.js';
19
- export * from '../constants.js';
20
- export * from '../utils/index.js';