@ar.io/sdk 2.3.2 → 2.4.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 (56) hide show
  1. package/README.md +37 -3
  2. package/bundles/web.bundle.min.js +63 -63
  3. package/lib/cjs/common/ant-registry.js +8 -8
  4. package/lib/cjs/common/ant.js +47 -24
  5. package/lib/cjs/common/io.js +14 -1
  6. package/lib/cjs/node/index.js +1 -1
  7. package/lib/cjs/types/ant.js +122 -0
  8. package/lib/cjs/types/common.js +2 -0
  9. package/lib/cjs/{io.js → types/io.js} +1 -1
  10. package/lib/cjs/{token.js → types/token.js} +1 -1
  11. package/lib/cjs/utils/ao.js +1 -35
  12. package/lib/cjs/utils/arweave.js +15 -0
  13. package/lib/cjs/utils/index.js +1 -0
  14. package/lib/cjs/utils/processes.js +1 -0
  15. package/lib/cjs/utils/schema.js +17 -0
  16. package/lib/cjs/version.js +1 -1
  17. package/lib/cjs/web/index.js +1 -1
  18. package/lib/esm/common/ant-registry.js +1 -1
  19. package/lib/esm/common/ant.js +40 -17
  20. package/lib/esm/common/io.js +14 -1
  21. package/lib/esm/node/index.js +1 -1
  22. package/lib/esm/types/ant.js +118 -0
  23. package/lib/esm/types/common.js +1 -0
  24. package/lib/esm/{io.js → types/io.js} +1 -1
  25. package/lib/esm/{token.js → types/token.js} +1 -1
  26. package/lib/esm/utils/ao.js +0 -33
  27. package/lib/esm/utils/arweave.js +15 -0
  28. package/lib/esm/utils/index.js +1 -0
  29. package/lib/esm/utils/processes.js +1 -0
  30. package/lib/esm/utils/schema.js +13 -0
  31. package/lib/esm/version.js +1 -1
  32. package/lib/esm/web/index.js +1 -1
  33. package/lib/types/common/ant-registry.d.ts +2 -1
  34. package/lib/types/common/ant.d.ts +23 -29
  35. package/lib/types/common/contracts/ao-process.d.ts +1 -1
  36. package/lib/types/common/http.d.ts +1 -1
  37. package/lib/types/common/io.d.ts +8 -3
  38. package/lib/types/node/index.d.ts +1 -1
  39. package/lib/types/types/ant-registry.d.ts +29 -0
  40. package/lib/types/types/ant.d.ts +190 -0
  41. package/lib/types/{common.d.ts → types/common.d.ts} +20 -0
  42. package/lib/types/{io.d.ts → types/io.d.ts} +7 -103
  43. package/lib/types/utils/ao.d.ts +2 -60
  44. package/lib/types/utils/arweave.d.ts +1 -16
  45. package/lib/types/utils/index.d.ts +1 -0
  46. package/lib/types/utils/processes.d.ts +2 -1
  47. package/lib/types/utils/schema.d.ts +23 -0
  48. package/lib/types/version.d.ts +1 -1
  49. package/lib/types/web/index.d.ts +1 -1
  50. package/package.json +1 -1
  51. /package/lib/cjs/{common.js → types/ant-registry.js} +0 -0
  52. /package/lib/cjs/{types.js → types/index.js} +0 -0
  53. /package/lib/esm/{common.js → types/ant-registry.js} +0 -0
  54. /package/lib/esm/{types.js → types/index.js} +0 -0
  55. /package/lib/types/{types.d.ts → types/index.d.ts} +0 -0
  56. /package/lib/types/{token.d.ts → types/token.d.ts} +0 -0
@@ -17,9 +17,9 @@ exports.AoANTRegistryWriteable = exports.AoANTRegistryReadable = exports.ANTRegi
17
17
  * limitations under the License.
18
18
  */
19
19
  const constants_js_1 = require("../constants.js");
20
- const types_js_1 = require("../types.js");
20
+ const index_js_1 = require("../types/index.js");
21
21
  const ao_js_1 = require("../utils/ao.js");
22
- const index_js_1 = require("./index.js");
22
+ const index_js_2 = require("./index.js");
23
23
  class ANTRegistry {
24
24
  static init(config) {
25
25
  if (config && config.signer) {
@@ -37,21 +37,21 @@ class AoANTRegistryReadable {
37
37
  process;
38
38
  constructor(config) {
39
39
  if (config &&
40
- ((0, types_js_1.isProcessIdConfiguration)(config) || (0, types_js_1.isProcessConfiguration)(config))) {
41
- if ((0, types_js_1.isProcessConfiguration)(config)) {
40
+ ((0, index_js_1.isProcessIdConfiguration)(config) || (0, index_js_1.isProcessConfiguration)(config))) {
41
+ if ((0, index_js_1.isProcessConfiguration)(config)) {
42
42
  this.process = config.process;
43
43
  }
44
- else if ((0, types_js_1.isProcessIdConfiguration)(config)) {
45
- this.process = new index_js_1.AOProcess({
44
+ else if ((0, index_js_1.isProcessIdConfiguration)(config)) {
45
+ this.process = new index_js_2.AOProcess({
46
46
  processId: config.processId,
47
47
  });
48
48
  }
49
49
  else {
50
- throw new index_js_1.InvalidContractConfigurationError();
50
+ throw new index_js_2.InvalidContractConfigurationError();
51
51
  }
52
52
  }
53
53
  else {
54
- this.process = new index_js_1.AOProcess({
54
+ this.process = new index_js_2.AOProcess({
55
55
  processId: constants_js_1.ANT_REGISTRY_ID,
56
56
  });
57
57
  }
@@ -16,49 +16,62 @@ exports.AoANTWriteable = exports.AoANTReadable = exports.ANT = void 0;
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- const types_js_1 = require("../types.js");
19
+ const zod_1 = require("zod");
20
+ const ant_js_1 = require("../types/ant.js");
21
+ const index_js_1 = require("../types/index.js");
20
22
  const ao_js_1 = require("../utils/ao.js");
21
- const index_js_1 = require("./index.js");
23
+ const schema_js_1 = require("../utils/schema.js");
24
+ const index_js_2 = require("./index.js");
22
25
  class ANT {
23
- static init({ signer, ...config }) {
26
+ static init({ signer, strict = false, ...config }) {
24
27
  // ao supported implementation
25
- if ((0, types_js_1.isProcessConfiguration)(config) || (0, types_js_1.isProcessIdConfiguration)(config)) {
28
+ if ((0, index_js_1.isProcessConfiguration)(config) || (0, index_js_1.isProcessIdConfiguration)(config)) {
26
29
  if (!signer) {
27
- return new AoANTReadable(config);
30
+ return new AoANTReadable({ strict, ...config });
28
31
  }
29
- return new AoANTWriteable({ signer, ...config });
32
+ return new AoANTWriteable({ signer, strict, ...config });
30
33
  }
31
- throw new index_js_1.InvalidContractConfigurationError();
34
+ throw new index_js_2.InvalidContractConfigurationError();
32
35
  }
33
36
  }
34
37
  exports.ANT = ANT;
35
38
  class AoANTReadable {
36
39
  process;
40
+ strict;
37
41
  constructor(config) {
38
- if ((0, types_js_1.isProcessConfiguration)(config)) {
42
+ this.strict = config.strict || false;
43
+ if ((0, index_js_1.isProcessConfiguration)(config)) {
39
44
  this.process = config.process;
40
45
  }
41
- else if ((0, types_js_1.isProcessIdConfiguration)(config)) {
42
- this.process = new index_js_1.AOProcess({
46
+ else if ((0, index_js_1.isProcessIdConfiguration)(config)) {
47
+ this.process = new index_js_2.AOProcess({
43
48
  processId: config.processId,
44
49
  });
45
50
  }
46
51
  else {
47
- throw new index_js_1.InvalidContractConfigurationError();
52
+ throw new index_js_2.InvalidContractConfigurationError();
48
53
  }
49
54
  }
50
- async getState() {
55
+ async getState({ strict } = { strict: this.strict }) {
51
56
  const tags = [{ name: 'Action', value: 'State' }];
52
57
  const res = await this.process.read({
53
58
  tags,
54
59
  });
60
+ if (strict) {
61
+ (0, schema_js_1.parseSchemaResult)(ant_js_1.AntStateSchema.passthrough().and(zod_1.z.object({
62
+ Records: zod_1.z.record(zod_1.z.string(), ant_js_1.AntRecordSchema.passthrough()),
63
+ })), res);
64
+ }
55
65
  return res;
56
66
  }
57
- async getInfo() {
67
+ async getInfo({ strict } = { strict: this.strict }) {
58
68
  const tags = [{ name: 'Action', value: 'Info' }];
59
69
  const info = await this.process.read({
60
70
  tags,
61
71
  });
72
+ if (strict) {
73
+ (0, schema_js_1.parseSchemaResult)(ant_js_1.AntInfoSchema.passthrough(), info);
74
+ }
62
75
  return info;
63
76
  }
64
77
  /**
@@ -70,7 +83,7 @@ class AoANTReadable {
70
83
  * ant.getRecord({ undername: "john" });
71
84
  * ```
72
85
  */
73
- async getRecord({ undername }) {
86
+ async getRecord({ undername }, { strict } = { strict: this.strict }) {
74
87
  const tags = [
75
88
  { name: 'Sub-Domain', value: undername },
76
89
  { name: 'Action', value: 'Record' },
@@ -78,6 +91,8 @@ class AoANTReadable {
78
91
  const record = await this.process.read({
79
92
  tags,
80
93
  });
94
+ if (strict)
95
+ (0, schema_js_1.parseSchemaResult)(ant_js_1.AntRecordSchema.passthrough(), record);
81
96
  return record;
82
97
  }
83
98
  /**
@@ -88,11 +103,13 @@ class AoANTReadable {
88
103
  * ant.getRecords();
89
104
  * ````
90
105
  */
91
- async getRecords() {
106
+ async getRecords({ strict } = { strict: this.strict }) {
92
107
  const tags = [{ name: 'Action', value: 'Records' }];
93
108
  const records = await this.process.read({
94
109
  tags,
95
110
  });
111
+ if (strict)
112
+ (0, schema_js_1.parseSchemaResult)(ant_js_1.AntRecordsSchema, records);
96
113
  return records;
97
114
  }
98
115
  /**
@@ -103,8 +120,8 @@ class AoANTReadable {
103
120
  * ant.getOwner();
104
121
  * ```
105
122
  */
106
- async getOwner() {
107
- const info = await this.getInfo();
123
+ async getOwner({ strict } = { strict: this.strict }) {
124
+ const info = await this.getInfo({ strict });
108
125
  return info.Owner;
109
126
  }
110
127
  /**
@@ -115,11 +132,13 @@ class AoANTReadable {
115
132
  * ant.getControllers();
116
133
  * ```
117
134
  */
118
- async getControllers() {
135
+ async getControllers({ strict } = { strict: this.strict }) {
119
136
  const tags = [{ name: 'Action', value: 'Controllers' }];
120
137
  const controllers = await this.process.read({
121
138
  tags,
122
139
  });
140
+ if (strict)
141
+ (0, schema_js_1.parseSchemaResult)(ant_js_1.AntControllersSchema, controllers);
123
142
  return controllers;
124
143
  }
125
144
  /**
@@ -130,8 +149,8 @@ class AoANTReadable {
130
149
  * ant.getName();
131
150
  * ```
132
151
  */
133
- async getName() {
134
- const info = await this.getInfo();
152
+ async getName({ strict } = { strict: this.strict }) {
153
+ const info = await this.getInfo({ strict });
135
154
  return info.Name;
136
155
  }
137
156
  /**
@@ -142,8 +161,8 @@ class AoANTReadable {
142
161
  * ant.getTicker();
143
162
  * ```
144
163
  */
145
- async getTicker() {
146
- const info = await this.getInfo();
164
+ async getTicker({ strict } = { strict: this.strict }) {
165
+ const info = await this.getInfo({ strict });
147
166
  return info.Ticker;
148
167
  }
149
168
  /**
@@ -154,11 +173,13 @@ class AoANTReadable {
154
173
  * ant.getBalances();
155
174
  * ```
156
175
  */
157
- async getBalances() {
176
+ async getBalances({ strict } = { strict: this.strict }) {
158
177
  const tags = [{ name: 'Action', value: 'Balances' }];
159
178
  const balances = await this.process.read({
160
179
  tags,
161
180
  });
181
+ if (strict)
182
+ (0, schema_js_1.parseSchemaResult)(ant_js_1.AntBalancesSchema, balances);
162
183
  return balances;
163
184
  }
164
185
  /**
@@ -170,7 +191,7 @@ class AoANTReadable {
170
191
  * ant.getBalance({ address });
171
192
  * ```
172
193
  */
173
- async getBalance({ address }) {
194
+ async getBalance({ address }, { strict } = { strict: this.strict }) {
174
195
  const tags = [
175
196
  { name: 'Action', value: 'Balance' },
176
197
  { name: 'Recipient', value: address },
@@ -178,6 +199,8 @@ class AoANTReadable {
178
199
  const balance = await this.process.read({
179
200
  tags,
180
201
  });
202
+ if (strict)
203
+ (0, schema_js_1.parseSchemaResult)(zod_1.z.number(), balance);
181
204
  return balance;
182
205
  }
183
206
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IOWriteable = exports.IOReadable = exports.IO = void 0;
4
4
  const constants_js_1 = require("../constants.js");
5
- const io_js_1 = require("../io.js");
5
+ const io_js_1 = require("../types/io.js");
6
6
  const ao_js_1 = require("../utils/ao.js");
7
7
  const arweave_js_1 = require("./arweave.js");
8
8
  const ao_process_js_1 = require("./contracts/ao-process.js");
@@ -513,6 +513,19 @@ class IOWriteable extends IOReadable {
513
513
  { name: 'Action', value: 'Decrease-Delegate-Stake' },
514
514
  { name: 'Target', value: params.target },
515
515
  { name: 'Quantity', value: params.decreaseQty.valueOf().toString() },
516
+ { name: 'Instant', value: `${params.instant || false}` },
517
+ ],
518
+ });
519
+ }
520
+ async instantDelegateWithdrawal(params, options) {
521
+ const { tags = [] } = options || {};
522
+ return this.process.send({
523
+ signer: this.signer,
524
+ tags: [
525
+ ...tags,
526
+ { name: 'Action', value: 'Decrease-Delegate-Stake' },
527
+ { name: 'Target', value: params.target },
528
+ { name: 'Vault-Id', value: params.vaultId },
516
529
  ],
517
530
  });
518
531
  }
@@ -33,7 +33,7 @@ exports.ArconnectSigner = exports.ArweaveSigner = void 0;
33
33
  var arbundles_1 = require("@dha-team/arbundles");
34
34
  Object.defineProperty(exports, "ArweaveSigner", { enumerable: true, get: function () { return arbundles_1.ArweaveSigner; } });
35
35
  Object.defineProperty(exports, "ArconnectSigner", { enumerable: true, get: function () { return arbundles_1.ArconnectSigner; } });
36
- __exportStar(require("../types.js"), exports);
36
+ __exportStar(require("../types/index.js"), exports);
37
37
  __exportStar(require("../common/index.js"), exports);
38
38
  __exportStar(require("../constants.js"), exports);
39
39
  __exportStar(require("../utils/index.js"), exports);
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAoANTState = exports.AntInfoSchema = exports.AntHandlersSchema = exports.AntHandlerNames = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.AntRecordsSchema = exports.AntRecordSchema = exports.IntegerStringSchema = exports.ArweaveTxIdSchema = 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
+ const zod_1 = require("zod");
20
+ const constants_js_1 = require("../constants.js");
21
+ /**
22
+ * example error:
23
+ * {
24
+ "code": "custom",
25
+ "message": "Must be an Arweave Transaction ID",
26
+ "path": [
27
+ "Records",
28
+ "record1",
29
+ "transactionId"
30
+ ]
31
+ },
32
+ */
33
+ exports.ArweaveTxIdSchema = zod_1.z
34
+ .string({
35
+ description: 'Arweave Transaction ID',
36
+ })
37
+ .refine((val) => constants_js_1.ARWEAVE_TX_REGEX.test(val), {
38
+ message: 'Must be an Arweave Transaction ID',
39
+ });
40
+ exports.IntegerStringSchema = zod_1.z
41
+ .string({
42
+ description: 'Integer String',
43
+ })
44
+ .refine((val) => {
45
+ const num = parseInt(val);
46
+ return Number.isInteger(num) && num >= 0;
47
+ }, { message: 'Must be a non negative integer string' });
48
+ exports.AntRecordSchema = zod_1.z.object({
49
+ transactionId: exports.ArweaveTxIdSchema.describe('The Target ID of the undername'),
50
+ ttlSeconds: zod_1.z.number(),
51
+ });
52
+ exports.AntRecordsSchema = zod_1.z.record(zod_1.z.string(), exports.AntRecordSchema);
53
+ exports.AntControllersSchema = zod_1.z.array(exports.ArweaveTxIdSchema.describe('Controller address'));
54
+ exports.AntBalancesSchema = zod_1.z.record(exports.ArweaveTxIdSchema.describe('Holder address'), zod_1.z.number());
55
+ exports.AntStateSchema = zod_1.z.object({
56
+ Name: zod_1.z.string().describe('The name of the ANT.'),
57
+ Ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
58
+ Denomination: zod_1.z
59
+ .number()
60
+ .describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.')
61
+ .min(0, { message: 'Denomination must be a non-negative number' }),
62
+ Owner: exports.ArweaveTxIdSchema.describe('The Owners address.'),
63
+ Controllers: exports.AntControllersSchema.describe('Controllers of the ANT who have administrative privileges.'),
64
+ Records: exports.AntRecordsSchema.describe('Records associated with the ANT.'),
65
+ Balances: exports.AntBalancesSchema.describe('Balance details for each address holding the ANT.'),
66
+ Logo: exports.ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
67
+ TotalSupply: zod_1.z
68
+ .number()
69
+ .describe('Total supply of the ANT in circulation.')
70
+ .min(0, { message: 'Total supply must be a non-negative number' }),
71
+ Initialized: zod_1.z
72
+ .boolean()
73
+ .describe('Flag indicating whether the ANT has been initialized.'),
74
+ ['Source-Code-TX-ID']: exports.ArweaveTxIdSchema.describe('Transaction ID of the Source Code for the ANT.'),
75
+ });
76
+ exports.AntHandlerNames = [
77
+ 'evolve',
78
+ '_eval',
79
+ '_default',
80
+ 'transfer',
81
+ 'balance',
82
+ 'balances',
83
+ 'totalSupply',
84
+ 'info',
85
+ 'addController',
86
+ 'removeController',
87
+ 'controllers',
88
+ 'setRecord',
89
+ 'removeRecord',
90
+ 'record',
91
+ 'records',
92
+ 'setName',
93
+ 'setTicker',
94
+ 'initializeState',
95
+ 'state',
96
+ ];
97
+ exports.AntHandlersSchema = zod_1.z
98
+ .array(zod_1.z.string({ description: 'Handler Name' }))
99
+ .refine((antHandlers) => {
100
+ return exports.AntHandlerNames.every((handler) => antHandlers.includes(handler));
101
+ }, {
102
+ message: 'ANT is missing required handlers',
103
+ });
104
+ exports.AntInfoSchema = zod_1.z.object({
105
+ Name: zod_1.z.string().describe('The name of the ANT.'),
106
+ Owner: exports.ArweaveTxIdSchema.describe('The Owners address.'),
107
+ ['Source-Code-TX-ID']: exports.ArweaveTxIdSchema.describe('Transaction ID of the Source Code for the ANT.'),
108
+ Ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
109
+ ['Total-Supply']: exports.IntegerStringSchema.describe('Total supply of the ANT in circulation.'),
110
+ Logo: exports.ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
111
+ Denomination: exports.IntegerStringSchema.describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.'),
112
+ Handlers: exports.AntHandlersSchema.optional().describe('List of handlers for the ANT.'),
113
+ HandlerNames: exports.AntHandlersSchema.optional().describe('Deprecated: List of handlers for the ANT. Use "Handlers" instead.'),
114
+ });
115
+ /**
116
+ * @param state {object}
117
+ * @returns {boolean}
118
+ */
119
+ function isAoANTState(state) {
120
+ return exports.AntStateSchema.safeParse(state).success;
121
+ }
122
+ exports.isAoANTState = isAoANTState;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isLeasedArNSRecord = exports.isProcessIdConfiguration = exports.isProcessConfiguration = void 0;
4
- const arweave_js_1 = require("./utils/arweave.js");
4
+ const arweave_js_1 = require("../utils/arweave.js");
5
5
  // Typeguard functions
6
6
  function isProcessConfiguration(config) {
7
7
  return 'process' in config;
@@ -16,7 +16,7 @@ exports.mIOToken = exports.IOToken = void 0;
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- const constants_js_1 = require("./constants.js");
19
+ const constants_js_1 = require("../constants.js");
20
20
  class PositiveFiniteInteger {
21
21
  positiveFiniteInteger;
22
22
  constructor(positiveFiniteInteger) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAoANTState = exports.AntStateSchema = exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
3
+ exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
6
  *
@@ -177,37 +177,3 @@ function createAoSigner(signer) {
177
177
  return aoSigner;
178
178
  }
179
179
  exports.createAoSigner = createAoSigner;
180
- // using passThrough to require the minimum fields and allow others (eg TotalSupply, Logo, etc)
181
- exports.AntStateSchema = zod_1.z
182
- .object({
183
- Name: zod_1.z.string(),
184
- Ticker: zod_1.z.string(),
185
- Owner: zod_1.z.string(),
186
- Controllers: zod_1.z.array(zod_1.z.string()),
187
- Records: zod_1.z.record(zod_1.z.string(), zod_1.z
188
- .object({
189
- transactionId: zod_1.z.string(),
190
- ttlSeconds: zod_1.z.number(),
191
- })
192
- .passthrough()),
193
- Balances: zod_1.z.record(zod_1.z.string(), zod_1.z.number()),
194
- ['Source-Code-TX-ID']: zod_1.z.string(),
195
- })
196
- .passthrough();
197
- /**
198
- * @param state
199
- * @returns {boolean}
200
- * @throws {z.ZodError} if the state object does not match the expected schema
201
- */
202
- function isAoANTState(state, logger = index_js_1.Logger.default) {
203
- try {
204
- exports.AntStateSchema.parse(state);
205
- return true;
206
- }
207
- catch (error) {
208
- // this allows us to see the path of the error in the object as well as the expected schema on invalid fields
209
- logger.error(error.issues);
210
- return false;
211
- }
212
- }
213
- exports.isAoANTState = isAoANTState;
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isBlockHeight = exports.validateArweaveId = 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
+ */
4
19
  const constants_js_1 = require("../constants.js");
5
20
  const validateArweaveId = (id) => {
6
21
  return constants_js_1.ARWEAVE_TX_REGEX.test(id);
@@ -34,3 +34,4 @@ __exportStar(require("./http-client.js"), exports);
34
34
  __exportStar(require("./ao.js"), exports);
35
35
  __exportStar(require("./json.js"), exports);
36
36
  __exportStar(require("./processes.js"), exports);
37
+ __exportStar(require("./schema.js"), exports);
@@ -98,6 +98,7 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
98
98
  }
99
99
  const ant = ant_js_1.ANT.init({
100
100
  processId,
101
+ strict: true,
101
102
  });
102
103
  const state = (await timeout(this.timeoutMs, ant.getState()).catch((e) => {
103
104
  this.emit('error', `Error getting state for process ${processId}: ${e}`);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseSchemaResult = void 0;
4
+ /**
5
+ *
6
+ * @param schema - zod schema
7
+ * @param v - value to parse
8
+ * @throws {z.SafeParseError<any>} - if the value fails to parse
9
+ */
10
+ function parseSchemaResult(schema, v) {
11
+ const schemaResult = schema.safeParse(v);
12
+ if (!schemaResult.success) {
13
+ throw new Error(JSON.stringify(schemaResult.error.format(), null, 2));
14
+ }
15
+ return schemaResult;
16
+ }
17
+ exports.parseSchemaResult = parseSchemaResult;
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '2.3.2';
20
+ exports.version = '2.4.0-alpha.1';
@@ -33,7 +33,7 @@ exports.ArconnectSigner = exports.ArweaveSigner = void 0;
33
33
  var arbundles_1 = require("@dha-team/arbundles");
34
34
  Object.defineProperty(exports, "ArweaveSigner", { enumerable: true, get: function () { return arbundles_1.ArweaveSigner; } });
35
35
  Object.defineProperty(exports, "ArconnectSigner", { enumerable: true, get: function () { return arbundles_1.ArconnectSigner; } });
36
- __exportStar(require("../types.js"), exports);
36
+ __exportStar(require("../types/index.js"), exports);
37
37
  __exportStar(require("../common/index.js"), exports);
38
38
  __exportStar(require("../constants.js"), exports);
39
39
  __exportStar(require("../utils/index.js"), exports);
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ANT_REGISTRY_ID } from '../constants.js';
17
- import { isProcessConfiguration, isProcessIdConfiguration, } from '../types.js';
17
+ import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/index.js';
18
18
  import { createAoSigner } from '../utils/ao.js';
19
19
  import { AOProcess, InvalidContractConfigurationError } from './index.js';
20
20
  export class ANTRegistry {