@ar.io/sdk 1.2.2 → 2.0.0-alpha.10

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 (68) hide show
  1. package/README.md +148 -60
  2. package/bundles/web.bundle.min.js +132 -331
  3. package/lib/cjs/common/ant.js +147 -206
  4. package/lib/cjs/common/contracts/ao-process.js +1 -1
  5. package/lib/cjs/common/http.js +1 -2
  6. package/lib/cjs/common/index.js +0 -5
  7. package/lib/cjs/common/io.js +39 -31
  8. package/lib/cjs/common/logger.js +31 -19
  9. package/lib/cjs/types.js +0 -1
  10. package/lib/cjs/utils/arweave.js +1 -15
  11. package/lib/cjs/utils/http-client.js +1 -1
  12. package/lib/cjs/utils/index.js +1 -2
  13. package/lib/cjs/utils/{graphql/processes.js → processes.js} +35 -10
  14. package/lib/cjs/version.js +1 -1
  15. package/lib/esm/common/ant.js +144 -203
  16. package/lib/esm/common/contracts/ao-process.js +2 -2
  17. package/lib/esm/common/http.js +2 -3
  18. package/lib/esm/common/index.js +0 -5
  19. package/lib/esm/common/io.js +39 -28
  20. package/lib/esm/common/logger.js +29 -14
  21. package/lib/esm/types.js +0 -1
  22. package/lib/esm/utils/arweave.js +0 -12
  23. package/lib/esm/utils/http-client.js +2 -2
  24. package/lib/esm/utils/index.js +1 -2
  25. package/lib/esm/utils/{graphql/processes.js → processes.js} +33 -9
  26. package/lib/esm/version.js +1 -1
  27. package/lib/types/common/ant.d.ts +53 -175
  28. package/lib/types/common/contracts/ao-process.d.ts +2 -2
  29. package/lib/types/common/http.d.ts +3 -2
  30. package/lib/types/common/index.d.ts +0 -4
  31. package/lib/types/common/io.d.ts +5 -4
  32. package/lib/types/common/logger.d.ts +10 -3
  33. package/lib/types/common.d.ts +1 -145
  34. package/lib/types/io.d.ts +28 -3
  35. package/lib/types/types.d.ts +0 -1
  36. package/lib/types/utils/arweave.d.ts +0 -5
  37. package/lib/types/utils/http-client.d.ts +2 -2
  38. package/lib/types/utils/index.d.ts +1 -2
  39. package/lib/types/utils/{graphql/processes.d.ts → processes.d.ts} +4 -1
  40. package/lib/types/version.d.ts +1 -1
  41. package/package.json +8 -13
  42. package/lib/cjs/arns-service.js +0 -2
  43. package/lib/cjs/common/ant-ao.js +0 -297
  44. package/lib/cjs/common/ar-io.js +0 -741
  45. package/lib/cjs/common/contracts/remote-contract.js +0 -55
  46. package/lib/cjs/common/contracts/warp-contract.js +0 -176
  47. package/lib/cjs/common/warp.js +0 -25
  48. package/lib/cjs/utils/graphql/index.js +0 -34
  49. package/lib/cjs/utils/graphql/smartweave.js +0 -309
  50. package/lib/cjs/utils/smartweave.js +0 -58
  51. package/lib/esm/arns-service.js +0 -1
  52. package/lib/esm/common/ant-ao.js +0 -292
  53. package/lib/esm/common/ar-io.js +0 -735
  54. package/lib/esm/common/contracts/remote-contract.js +0 -51
  55. package/lib/esm/common/contracts/warp-contract.js +0 -172
  56. package/lib/esm/common/warp.js +0 -22
  57. package/lib/esm/utils/graphql/index.js +0 -18
  58. package/lib/esm/utils/graphql/smartweave.js +0 -303
  59. package/lib/esm/utils/smartweave.js +0 -50
  60. package/lib/types/arns-service.d.ts +0 -23
  61. package/lib/types/common/ant-ao.d.ts +0 -194
  62. package/lib/types/common/ar-io.d.ts +0 -551
  63. package/lib/types/common/contracts/remote-contract.d.ts +0 -38
  64. package/lib/types/common/contracts/warp-contract.d.ts +0 -43
  65. package/lib/types/common/warp.d.ts +0 -1
  66. package/lib/types/utils/graphql/index.d.ts +0 -18
  67. package/lib/types/utils/graphql/smartweave.d.ts +0 -47
  68. package/lib/types/utils/smartweave.d.ts +0 -41
@@ -1,292 +0,0 @@
1
- import { isProcessConfiguration, isProcessIdConfiguration, } from '../io.js';
2
- import { AOProcess } from './contracts/ao-process.js';
3
- import { InvalidContractConfigurationError } from './error.js';
4
- export class AoANTReadable {
5
- process;
6
- constructor(config) {
7
- if (isProcessConfiguration(config)) {
8
- this.process = config.process;
9
- }
10
- else if (isProcessIdConfiguration(config)) {
11
- this.process = new AOProcess({
12
- processId: config.processId,
13
- });
14
- }
15
- else {
16
- throw new InvalidContractConfigurationError();
17
- }
18
- }
19
- async getState() {
20
- const tags = [{ name: 'Action', value: 'State' }];
21
- const res = await this.process.read({
22
- tags,
23
- });
24
- return res;
25
- }
26
- async getInfo() {
27
- const tags = [{ name: 'Action', value: 'Info' }];
28
- const info = await this.process.read({
29
- tags,
30
- });
31
- return info;
32
- }
33
- /**
34
- * @param undername @type {string} The domain name.
35
- * @returns {Promise<ANTRecord>} The record of the undername domain.
36
- * @example
37
- * Get the current record
38
- * ```ts
39
- * ant.getRecord({ undername: "john" });
40
- * ```
41
- */
42
- async getRecord({ undername }) {
43
- const tags = [
44
- { name: 'Sub-Domain', value: undername },
45
- { name: 'Action', value: 'Record' },
46
- ];
47
- const record = await this.process.read({
48
- tags,
49
- });
50
- return record;
51
- }
52
- /**
53
- * @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
54
- * @example
55
- * Get the current records
56
- * ```ts
57
- * ant.getRecords();
58
- * ````
59
- */
60
- async getRecords() {
61
- const tags = [{ name: 'Action', value: 'Records' }];
62
- const records = await this.process.read({
63
- tags,
64
- });
65
- return records;
66
- }
67
- /**
68
- * @returns {Promise<string>} The owner of the ANT.
69
- * @example
70
- * Get the current owner
71
- * ```ts
72
- * ant.getOwner();
73
- * ```
74
- */
75
- async getOwner() {
76
- const info = await this.getInfo();
77
- return info.Owner;
78
- }
79
- /**
80
- * @returns {Promise<string[]>} The controllers of the ANT.
81
- * @example
82
- * Get the controllers of the ANT.
83
- * ```ts
84
- * ant.getControllers();
85
- * ```
86
- */
87
- async getControllers() {
88
- const tags = [{ name: 'Action', value: 'Controllers' }];
89
- const controllers = await this.process.read({
90
- tags,
91
- });
92
- return controllers;
93
- }
94
- /**
95
- * @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
96
- * @example
97
- * Get the current name
98
- * ```ts
99
- * ant.getName();
100
- * ```
101
- */
102
- async getName() {
103
- const info = await this.getInfo();
104
- return info.Name;
105
- }
106
- /**
107
- * @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
108
- * @example
109
- * The current ticker of the ANT.
110
- * ```ts
111
- * ant.getTicker();
112
- * ```
113
- */
114
- async getTicker() {
115
- const info = await this.getInfo();
116
- return info.Ticker;
117
- }
118
- /**
119
- * @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT
120
- * @example
121
- * The current balances of the ANT.
122
- * ```ts
123
- * ant.getBalances();
124
- * ```
125
- */
126
- async getBalances() {
127
- const tags = [{ name: 'Action', value: 'Balances' }];
128
- const balances = await this.process.read({
129
- tags,
130
- });
131
- return balances;
132
- }
133
- /**
134
- * @param address @type {string} The address of the account you want the balance of.
135
- * @returns {Promise<number>} The balance of the provided address
136
- * @example
137
- * The current balance of the address.
138
- * ```ts
139
- * ant.getBalance({ address });
140
- * ```
141
- */
142
- async getBalance({ address }) {
143
- const tags = [
144
- { name: 'Action', value: 'Balance' },
145
- { name: 'Recipient', value: address },
146
- ];
147
- const balance = await this.process.read({
148
- tags,
149
- });
150
- return balance;
151
- }
152
- }
153
- export class AoANTWriteable extends AoANTReadable {
154
- signer;
155
- constructor({ signer, ...config }) {
156
- super(config);
157
- this.signer = signer;
158
- }
159
- /**
160
- * @param target @type {string} The address of the account you want to transfer the ANT to.
161
- * @returns {Promise<AoMessageResult>} The result of the interaction.
162
- * @example
163
- * ```ts
164
- * ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
165
- * ```
166
- */
167
- async transfer({ target }) {
168
- const tags = [
169
- { name: 'Action', value: 'Transfer' },
170
- { name: 'Recipient', value: target },
171
- ];
172
- return this.process.send({
173
- tags,
174
- data: {},
175
- signer: this.signer,
176
- });
177
- }
178
- /**
179
- * @param controller @type {string} The address of the account you want to set as a controller.
180
- * @returns {Promise<AoMessageResult>} The result of the interaction.
181
- * @example
182
- * ```ts
183
- * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
184
- * ```
185
- */
186
- async addController({ controller, }) {
187
- const tags = [
188
- { name: 'Action', value: 'Add-Controller' },
189
- { name: 'Controller', value: controller },
190
- ];
191
- return this.process.send({
192
- tags,
193
- data: {},
194
- signer: this.signer,
195
- });
196
- }
197
- /**
198
- * @param controller @type {string} The address of the account you want to remove from the controllers list
199
- * @returns {Promise<AoMessageResult>} The result of the interaction.
200
- * @example
201
- * ```ts
202
- * ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
203
- * ```
204
- */
205
- async removeController({ controller, }) {
206
- const tags = [
207
- { name: 'Action', value: 'Remove-Controller' },
208
- { name: 'Controller', value: controller },
209
- ];
210
- return this.process.send({
211
- tags,
212
- data: {},
213
- signer: this.signer,
214
- });
215
- }
216
- /**
217
- * @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
218
- * @param transactionId @type {string} The transactionId of the record.
219
- * @param ttlSeconds @type {number} The time to live of the record.
220
- * @returns {Promise<AoMessageResult>} The result of the interaction.
221
- * @example
222
- * ```ts
223
- * ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
224
- * ```
225
- */
226
- async setRecord({ undername, transactionId, ttlSeconds, }) {
227
- return this.process.send({
228
- tags: [
229
- { name: 'Action', value: 'Set-Record' },
230
- { name: 'Sub-Domain', value: undername },
231
- { name: 'Transaction-Id', value: transactionId },
232
- { name: 'TTL-Seconds', value: ttlSeconds.toString() },
233
- ],
234
- data: { transactionId, ttlSeconds },
235
- signer: this.signer,
236
- });
237
- }
238
- /**
239
- * @param undername @type {string} The record you want to remove.
240
- * @returns {Promise<AoMessageResult>} The result of the interaction.
241
- * @example
242
- * ```ts
243
- * ant.removeRecord({ subDomain: "shorts" });
244
- * ```
245
- */
246
- async removeRecord({ undername, }) {
247
- return this.process.send({
248
- tags: [
249
- { name: 'Action', value: 'Remove-Record' },
250
- { name: 'Sub-Domain', value: undername },
251
- ],
252
- data: { undername },
253
- signer: this.signer,
254
- });
255
- }
256
- /**
257
- * @param ticker @type {string} Sets the ANT Ticker.
258
- * @returns {Promise<AoMessageResult>} The result of the interaction.
259
- * @example
260
- * ```ts
261
- * ant.setTicker({ ticker: "KAPOW" });
262
- * ```
263
- */
264
- async setTicker({ ticker }) {
265
- return this.process.send({
266
- tags: [
267
- { name: 'Action', value: 'Set-Ticker' },
268
- { name: 'Ticker', value: ticker },
269
- ],
270
- data: { ticker },
271
- signer: this.signer,
272
- });
273
- }
274
- /**
275
- * @param name @type {string} Sets the Name of the ANT.
276
- * @returns {Promise<AoMessageResult>} The result of the interaction.
277
- * @example
278
- * ```ts
279
- * ant.setName({ name: "ships at sea" });
280
- * ```
281
- */
282
- async setName({ name }) {
283
- return this.process.send({
284
- tags: [
285
- { name: 'Action', value: 'Set-Name' },
286
- { name: 'Name', value: name },
287
- ],
288
- data: { name },
289
- signer: this.signer,
290
- });
291
- }
292
- }