@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,223 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TurboArNSPaymentProviderAuthenticated = exports.TurboArNSPaymentProviderUnauthenticated = exports.TurboArNSPaymentFactory = exports.defaultHeaders = void 0;
4
- exports.signedRequestHeadersFromSigner = signedRequestHeadersFromSigner;
5
- exports.isTurboArNSSigner = isTurboArNSSigner;
6
- /**
7
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
8
- *
9
- * Licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
12
- *
13
- * http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
20
- */
21
- const arbundles_1 = require("@dha-team/arbundles");
22
- const token_js_1 = require("../types/token.js");
23
- const base64_js_1 = require("../utils/base64.js");
24
- const url_js_1 = require("../utils/url.js");
25
- const version_js_1 = require("../version.js");
26
- const logger_js_1 = require("./logger.js");
27
- exports.defaultHeaders = {
28
- 'x-source-version': `${version_js_1.version}`,
29
- 'x-source-identifier': 'ar-io-sdk',
30
- };
31
- async function signedRequestHeadersFromSigner({ signer, nonce = crypto.randomUUID(), }) {
32
- let signature = undefined;
33
- let publicKey = undefined;
34
- const signatureType = isWanderArweaveBrowserSigner(signer)
35
- ? arbundles_1.SignatureConfig.ARWEAVE
36
- : signer.signatureType;
37
- // equivalent to window.arweaveWallet
38
- if (isWanderArweaveBrowserSigner(signer)) {
39
- signature = (0, base64_js_1.toB64Url)(Buffer.from(await signer.signMessage(Uint8Array.from(Buffer.from(nonce)))));
40
- }
41
- else if (signer instanceof arbundles_1.ArconnectSigner) {
42
- signature = (0, base64_js_1.toB64Url)(Buffer.from(await signer['signer'].signMessage(Uint8Array.from(Buffer.from(nonce)))));
43
- }
44
- else if (signer instanceof arbundles_1.ArweaveSigner ||
45
- signer instanceof arbundles_1.EthereumSigner ||
46
- signer instanceof arbundles_1.InjectedEthereumSigner) {
47
- if ('setPublicKey' in signer && signer['publicKey'] === undefined) {
48
- await signer.setPublicKey();
49
- }
50
- signature = (0, base64_js_1.toB64Url)(Buffer.from(await signer.sign(Uint8Array.from(Buffer.from(nonce)))));
51
- }
52
- switch (signatureType) {
53
- case arbundles_1.SignatureConfig.ARWEAVE:
54
- if (isWanderArweaveBrowserSigner(signer)) {
55
- publicKey = await signer.getActivePublicKey();
56
- }
57
- else if ('setPublicKey' in signer) {
58
- await signer.setPublicKey();
59
- publicKey = (0, base64_js_1.toB64Url)(signer.publicKey);
60
- }
61
- else if ('publicKey' in signer) {
62
- publicKey = (0, base64_js_1.toB64Url)(signer.publicKey);
63
- }
64
- break;
65
- case arbundles_1.SignatureConfig.ETHEREUM:
66
- if ('publicKey' in signer) {
67
- publicKey = '0x' + signer.publicKey.toString('hex');
68
- }
69
- else {
70
- throw new Error('Public key not found');
71
- }
72
- break;
73
- // TODO: solana sig support
74
- // case SignatureConfig.SOLANA:
75
- // case SignatureConfig.ED25519:
76
- default:
77
- throw new Error(`Unsupported signer type for signing requests: ${signatureType}`);
78
- }
79
- if (publicKey === undefined || signature === undefined) {
80
- throw new Error('Public key or signature not found');
81
- }
82
- return {
83
- 'x-public-key': publicKey,
84
- 'x-nonce': nonce,
85
- 'x-signature': signature,
86
- 'x-signature-type': signatureType.toString(),
87
- };
88
- }
89
- class TurboArNSPaymentFactory {
90
- static init(config) {
91
- const { signer, paymentUrl, logger } = config ?? {};
92
- if (signer !== undefined) {
93
- return new TurboArNSPaymentProviderAuthenticated({
94
- signer,
95
- paymentUrl,
96
- logger,
97
- });
98
- }
99
- return new TurboArNSPaymentProviderUnauthenticated({
100
- paymentUrl,
101
- logger,
102
- });
103
- }
104
- }
105
- exports.TurboArNSPaymentFactory = TurboArNSPaymentFactory;
106
- // Base class for unauthenticated operations
107
- class TurboArNSPaymentProviderUnauthenticated {
108
- paymentUrl;
109
- logger;
110
- constructor({ paymentUrl = 'https://payment.ardrive.io', logger = logger_js_1.Logger.default, }) {
111
- this.paymentUrl = paymentUrl;
112
- this.logger = logger;
113
- }
114
- async getArNSPriceDetails({ intent, name, quantity, type, years, }) {
115
- const url = (0, url_js_1.urlWithSearchParams)({
116
- baseUrl: `${this.paymentUrl}/v1/arns/price/${intent}/${name}`,
117
- params: {
118
- increaseQty: quantity,
119
- type,
120
- years,
121
- },
122
- });
123
- const response = await fetch(url, {
124
- method: 'GET',
125
- headers: exports.defaultHeaders,
126
- });
127
- const status = response.status;
128
- const data = (await response.json());
129
- this.logger.debug('getArNSPriceDetails', {
130
- intent,
131
- name,
132
- quantity,
133
- type,
134
- years,
135
- data,
136
- status,
137
- });
138
- if (status !== 200) {
139
- throw new Error('Failed to get ArNS purchase price ' + JSON.stringify(data));
140
- }
141
- if (!data.winc || !data.mARIO) {
142
- throw new Error('Invalid response from Turbo ' + JSON.stringify(data));
143
- }
144
- return {
145
- winc: data.winc,
146
- mARIO: new token_js_1.mARIOToken(+data.mARIO),
147
- };
148
- }
149
- async getPrice(params) {
150
- const { winc } = await this.getArNSPriceDetails(params);
151
- return +winc;
152
- }
153
- }
154
- exports.TurboArNSPaymentProviderUnauthenticated = TurboArNSPaymentProviderUnauthenticated;
155
- // Class for authenticated operations, extending the base class
156
- class TurboArNSPaymentProviderAuthenticated extends TurboArNSPaymentProviderUnauthenticated {
157
- signer;
158
- constructor({ signer, ...restConfig }) {
159
- super(restConfig); // Pass unauthenticated config to base class+
160
- if (!isTurboArNSSigner(signer)) {
161
- throw new Error('Signer must be a TurboArNSSigner');
162
- }
163
- this.signer = signer;
164
- }
165
- async initiateArNSPurchase({ intent, name, quantity, type, processId, years, paidBy = [], referrer, }) {
166
- // Signer check is implicitly handled by requiring it in the constructor
167
- const url = (0, url_js_1.urlWithSearchParams)({
168
- baseUrl: `${this.paymentUrl}/v1/arns/purchase/${intent}/${name}`,
169
- params: {
170
- increaseQty: quantity,
171
- processId,
172
- type,
173
- years,
174
- paidBy,
175
- referrer,
176
- },
177
- });
178
- const signedHeaders = await signedRequestHeadersFromSigner({
179
- signer: this.signer,
180
- });
181
- const response = await fetch(url, {
182
- method: 'POST',
183
- headers: {
184
- ...exports.defaultHeaders,
185
- ...signedHeaders,
186
- },
187
- });
188
- const status = response.status;
189
- const data = (await response.json());
190
- this.logger.debug('Initiated ArNS purchase', {
191
- intent,
192
- name,
193
- quantity,
194
- processId,
195
- type,
196
- years,
197
- data,
198
- status,
199
- });
200
- if (status !== 200) {
201
- throw new Error('Failed to initiate ArNS purchase ' + JSON.stringify(data));
202
- }
203
- return {
204
- id: data.arioWriteResult.id,
205
- result: data.purchaseReceipt,
206
- };
207
- }
208
- }
209
- exports.TurboArNSPaymentProviderAuthenticated = TurboArNSPaymentProviderAuthenticated;
210
- function isWanderArweaveBrowserSigner(signer) {
211
- return (typeof signer === 'object' &&
212
- signer !== null &&
213
- 'signMessage' in signer &&
214
- 'getActivePublicKey' in signer);
215
- }
216
- function isTurboArNSSigner(signer) {
217
- const isWanderWallet = isWanderArweaveBrowserSigner(signer);
218
- const isSigner = signer instanceof arbundles_1.EthereumSigner ||
219
- signer instanceof arbundles_1.InjectedEthereumSigner ||
220
- signer instanceof arbundles_1.ArweaveSigner ||
221
- signer instanceof arbundles_1.ArconnectSigner;
222
- return isWanderWallet || isSigner;
223
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_CU_URL = exports.DEFAULT_SCHEDULER_ID = exports.AO_AUTHORITY = exports.ANT_LUA_ID = exports.AOS_MODULE_ID = exports.MARIO_PER_ARIO = exports.MARKETPLACE_CONTRACT_ID = exports.ANT_REGISTRY_ID = exports.ANT_REGISTRY_TESTNET_ID = exports.ARIO_MAINNET_PROCESS_ID = exports.ARIO_TESTNET_PROCESS_ID = exports.arioDevnetProcessId = exports.ARIO_DEVNET_PROCESS_ID = exports.FQDN_REGEX = exports.ARWEAVE_TX_REGEX = void 0;
4
- /**
5
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- exports.ARWEAVE_TX_REGEX = new RegExp('^[a-zA-Z0-9_-]{43}$');
20
- /** FQDN regex that matches the one used in the ArNS contract. */
21
- exports.FQDN_REGEX = new RegExp('^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{1,63}$');
22
- exports.ARIO_DEVNET_PROCESS_ID = 'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc';
23
- // backwards compatibility - TODO: remove in v2.0.0
24
- exports.arioDevnetProcessId = exports.ARIO_DEVNET_PROCESS_ID;
25
- exports.ARIO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
26
- exports.ARIO_MAINNET_PROCESS_ID = 'qNvAoz0TgcH7DMg8BCVn8jF32QH5L6T29VjHxhHqqGE';
27
- exports.ANT_REGISTRY_TESTNET_ID = 'RR0vheYqtsKuJCWh6xj0beE35tjaEug5cejMw9n2aa8';
28
- exports.ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
29
- exports.MARKETPLACE_CONTRACT_ID = 'wPh88ziUF4meLpHfffmgdA6IFtzmXHgdeg-epzBjkao';
30
- exports.MARIO_PER_ARIO = 1_000_000;
31
- /**
32
- * @deprecated - use ANT.versions.getLatestANTVersion() to get latest ANT module
33
- **/
34
- exports.AOS_MODULE_ID = 'nEjlSFA_8narJlVHApbczDPkMc9znSqYtqtf1iOdoxM';
35
- /**
36
- * @deprecated - use ANT.versions.getLatestANTVersion() to get latest ANT module
37
- **/
38
- exports.ANT_LUA_ID = 'sOW9Sdm1yoPRrzerC5iu1nsupp4e6I-HnJyYVHzvzQo';
39
- exports.AO_AUTHORITY = 'fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY';
40
- exports.DEFAULT_SCHEDULER_ID = '_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
41
- exports.DEFAULT_CU_URL = 'https://cu.ardrive.io';
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ArconnectSigner = exports.ArweaveSigner = void 0;
18
- /**
19
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
20
- *
21
- * Licensed under the Apache License, Version 2.0 (the "License");
22
- * you may not use this file except in compliance with the License.
23
- * You may obtain a copy of the License at
24
- *
25
- * http://www.apache.org/licenses/LICENSE-2.0
26
- *
27
- * Unless required by applicable law or agreed to in writing, software
28
- * distributed under the License is distributed on an "AS IS" BASIS,
29
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
- * See the License for the specific language governing permissions and
31
- * limitations under the License.
32
- */
33
- var arbundles_1 = require("@dha-team/arbundles");
34
- Object.defineProperty(exports, "ArweaveSigner", { enumerable: true, get: function () { return arbundles_1.ArweaveSigner; } });
35
- Object.defineProperty(exports, "ArconnectSigner", { enumerable: true, get: function () { return arbundles_1.ArconnectSigner; } });
36
- __exportStar(require("../types/index.js"), exports);
37
- __exportStar(require("../common/index.js"), exports);
38
- __exportStar(require("../constants.js"), exports);
39
- __exportStar(require("../utils/index.js"), exports);
@@ -1 +0,0 @@
1
- {"type": "commonjs"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,168 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AntInfoSchema = exports.AntHandlersSchema = exports.AntHandlerNames = exports.AntWriteHandlers = exports.AntReadHandlers = exports.SpawnANTStateSchema = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.AntRecordsSchema = exports.AntRecordSchema = exports.AntKeywordsSchema = exports.AntDescriptionSchema = exports.IntegerStringSchema = exports.AOAddressSchema = exports.ArweaveTxIdSchema = void 0;
4
- exports.isAoANTState = isAoANTState;
5
- /**
6
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
- const zod_1 = require("zod");
21
- const constants_js_1 = require("../constants.js");
22
- /**
23
- * example error:
24
- * {
25
- "code": "custom",
26
- "message": "Must be an Arweave Transaction ID",
27
- "path": [
28
- "Records",
29
- "record1",
30
- "transactionId"
31
- ]
32
- },
33
- */
34
- exports.ArweaveTxIdSchema = zod_1.z
35
- .string({
36
- description: 'Arweave Transaction ID',
37
- })
38
- .refine((val) => constants_js_1.ARWEAVE_TX_REGEX.test(val), {
39
- message: 'Must be an Arweave Transaction ID',
40
- });
41
- exports.AOAddressSchema = zod_1.z.string({
42
- description: 'AO Address',
43
- });
44
- exports.IntegerStringSchema = zod_1.z
45
- .string({
46
- description: 'Integer String',
47
- })
48
- .refine((val) => {
49
- const num = parseInt(val);
50
- return Number.isInteger(num) && num >= 0;
51
- }, { message: 'Must be a non negative integer string' });
52
- exports.AntDescriptionSchema = zod_1.z.string(); // TODO: add specific limits for description ie max length
53
- exports.AntKeywordsSchema = zod_1.z.array(zod_1.z.string()); // TODO: add specific limits for keywords ie max amount and max length
54
- exports.AntRecordSchema = zod_1.z.object({
55
- transactionId: exports.ArweaveTxIdSchema.describe('The Target ID of the undername'),
56
- ttlSeconds: zod_1.z.number(),
57
- priority: zod_1.z.number().optional(),
58
- owner: exports.AOAddressSchema.describe('The owner address of the record').optional(),
59
- displayName: zod_1.z
60
- .string()
61
- .max(61)
62
- .describe('Display name of the record (max 61 chars)')
63
- .optional(),
64
- logo: exports.ArweaveTxIdSchema.describe('Logo transaction ID for the record').optional(),
65
- description: zod_1.z
66
- .string()
67
- .max(512)
68
- .describe('Description of the record (max 512 chars)')
69
- .optional(),
70
- keywords: zod_1.z
71
- .array(zod_1.z.string().max(32))
72
- .max(16)
73
- .describe('Keywords array (max 16, each max 32 chars)')
74
- .optional(),
75
- });
76
- exports.AntRecordsSchema = zod_1.z.record(zod_1.z.string(), exports.AntRecordSchema);
77
- exports.AntControllersSchema = zod_1.z.array(exports.AOAddressSchema.describe('Controller address'));
78
- exports.AntBalancesSchema = zod_1.z.record(exports.AOAddressSchema.describe('Holder address'), zod_1.z.number());
79
- exports.AntStateSchema = zod_1.z.object({
80
- Name: zod_1.z.string().describe('The name of the ANT.'),
81
- Ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
82
- Description: zod_1.z.string().describe('The description for the ANT.'),
83
- Keywords: exports.AntKeywordsSchema.describe('The keywords for the ANT.'),
84
- Denomination: zod_1.z
85
- .number()
86
- .describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.')
87
- .min(0, { message: 'Denomination must be a non-negative number' }),
88
- Owner: exports.AOAddressSchema.describe('The Owners address.'),
89
- Controllers: exports.AntControllersSchema.describe('Controllers of the ANT who have administrative privileges.'),
90
- Records: exports.AntRecordsSchema.describe('Records associated with the ANT.'),
91
- Balances: exports.AntBalancesSchema.describe('Balance details for each address holding the ANT.'),
92
- Logo: exports.ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
93
- TotalSupply: zod_1.z
94
- .number()
95
- .describe('Total supply of the ANT in circulation.')
96
- .min(0, { message: 'Total supply must be a non-negative number' }),
97
- Initialized: zod_1.z
98
- .boolean()
99
- .describe('Flag indicating whether the ANT has been initialized.'),
100
- });
101
- exports.SpawnANTStateSchema = zod_1.z.object({
102
- name: zod_1.z.string().describe('The name of the ANT.'),
103
- ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
104
- description: zod_1.z.string().describe('The description for the ANT.'),
105
- keywords: exports.AntKeywordsSchema.describe('The keywords for the ANT.'),
106
- owner: exports.AOAddressSchema.describe('The Owners address.'),
107
- controllers: exports.AntControllersSchema.describe('Controllers of the ANT who have administrative privileges.'),
108
- records: exports.AntRecordsSchema.describe('Records associated with the ANT.'),
109
- balances: exports.AntBalancesSchema.describe('Balance details for each address holding the ANT.'),
110
- logo: exports.ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
111
- });
112
- exports.AntReadHandlers = [
113
- 'balance',
114
- 'balances',
115
- 'totalSupply',
116
- 'info',
117
- 'controllers',
118
- 'record',
119
- 'records',
120
- 'state',
121
- ];
122
- exports.AntWriteHandlers = [
123
- '_eval',
124
- '_default',
125
- 'transfer',
126
- 'addController',
127
- 'removeController',
128
- 'setRecord',
129
- 'removeRecord',
130
- 'setName',
131
- 'setTicker',
132
- 'setDescription',
133
- 'setKeywords',
134
- 'setLogo',
135
- 'initializeState',
136
- 'releaseName',
137
- 'reassignName',
138
- 'approvePrimaryName',
139
- 'removePrimaryNames',
140
- 'transferRecordOwnership',
141
- ];
142
- exports.AntHandlerNames = [...exports.AntReadHandlers, ...exports.AntWriteHandlers];
143
- exports.AntHandlersSchema = zod_1.z
144
- .array(zod_1.z.string({ description: 'Handler Name' }))
145
- .refine((antHandlers) => {
146
- return exports.AntHandlerNames.every((handler) => antHandlers.includes(handler));
147
- }, {
148
- message: 'ANT is missing required handlers',
149
- });
150
- exports.AntInfoSchema = zod_1.z.object({
151
- Name: zod_1.z.string().describe('The name of the ANT.'),
152
- Owner: exports.ArweaveTxIdSchema.describe('The Owners address.'),
153
- Ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
154
- ['Total-Supply']: exports.IntegerStringSchema.describe('Total supply of the ANT in circulation.'),
155
- Description: exports.AntDescriptionSchema.describe('The description for the ANT.'),
156
- Keywords: exports.AntKeywordsSchema.describe('The keywords for the ANT.'),
157
- Logo: exports.ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
158
- Denomination: exports.IntegerStringSchema.describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.'),
159
- Handlers: exports.AntHandlersSchema.optional().describe('List of handlers for the ANT.'),
160
- HandlerNames: exports.AntHandlersSchema.optional().describe('Deprecated: List of handlers for the ANT. Use "Handlers" instead.'),
161
- });
162
- /**
163
- * @param state {object}
164
- * @returns {boolean}
165
- */
166
- function isAoANTState(state) {
167
- return exports.AntStateSchema.safeParse(state).success;
168
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- /**
18
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
19
- *
20
- * Licensed under the Apache License, Version 2.0 (the "License");
21
- * you may not use this file except in compliance with the License.
22
- * You may obtain a copy of the License at
23
- *
24
- * http://www.apache.org/licenses/LICENSE-2.0
25
- *
26
- * Unless required by applicable law or agreed to in writing, software
27
- * distributed under the License is distributed on an "AS IS" BASIS,
28
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
- * See the License for the specific language governing permissions and
30
- * limitations under the License.
31
- */
32
- __exportStar(require("./ant-registry.js"), exports);
33
- __exportStar(require("./ant.js"), exports);
34
- __exportStar(require("./common.js"), exports);
35
- __exportStar(require("./faucet.js"), exports);
36
- __exportStar(require("./io.js"), exports);
37
- __exportStar(require("./token.js"), exports);
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidFundFrom = exports.fundFromOptions = exports.isValidIntent = exports.intentsUsingYears = exports.validIntents = exports.isDistributedEpoch = exports.isDistributedEpochData = void 0;
4
- exports.isProcessConfiguration = isProcessConfiguration;
5
- exports.isProcessIdConfiguration = isProcessIdConfiguration;
6
- exports.isLeasedArNSRecord = isLeasedArNSRecord;
7
- const arweave_js_1 = require("../utils/arweave.js");
8
- const isDistributedEpochData = (data) => {
9
- return data.distributedTimestamp !== undefined;
10
- };
11
- exports.isDistributedEpochData = isDistributedEpochData;
12
- const isDistributedEpoch = (data) => {
13
- return (data.distributions !== undefined &&
14
- (0, exports.isDistributedEpochData)(data.distributions));
15
- };
16
- exports.isDistributedEpoch = isDistributedEpoch;
17
- exports.validIntents = [
18
- 'Buy-Name',
19
- 'Buy-Record', // for backwards compatibility
20
- 'Extend-Lease',
21
- 'Increase-Undername-Limit',
22
- 'Upgrade-Name',
23
- 'Primary-Name-Request',
24
- ];
25
- exports.intentsUsingYears = [
26
- 'Buy-Record', // for backwards compatibility
27
- 'Buy-Name',
28
- 'Extend-Lease',
29
- ];
30
- const isValidIntent = (intent) => {
31
- return exports.validIntents.indexOf(intent) !== -1;
32
- };
33
- exports.isValidIntent = isValidIntent;
34
- exports.fundFromOptions = ['balance', 'stakes', 'any', 'turbo'];
35
- const isValidFundFrom = (fundFrom) => {
36
- return exports.fundFromOptions.indexOf(fundFrom) !== -1;
37
- };
38
- exports.isValidFundFrom = isValidFundFrom;
39
- // Type-guard functions
40
- function isProcessConfiguration(config) {
41
- return config !== undefined && 'process' in config;
42
- }
43
- function isProcessIdConfiguration(config) {
44
- return (config !== undefined &&
45
- 'processId' in config &&
46
- typeof config.processId === 'string' &&
47
- (0, arweave_js_1.validateArweaveId)(config.processId) === true);
48
- }
49
- function isLeasedArNSRecord(record) {
50
- return record.type === 'lease';
51
- }