@ar.io/sdk 2.2.0-alpha.1 → 2.2.0-alpha.3

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
3
+ exports.isAoANTState = exports.AntStateSchema = exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
6
  *
@@ -152,3 +152,36 @@ function createAoSigner(signer) {
152
152
  return aoSigner;
153
153
  }
154
154
  exports.createAoSigner = createAoSigner;
155
+ // using passThrough to require the minimum fields and allow others (eg TotalSupply, Logo, etc)
156
+ exports.AntStateSchema = zod_1.z
157
+ .object({
158
+ Name: zod_1.z.string(),
159
+ Ticker: zod_1.z.string(),
160
+ Owner: zod_1.z.string(),
161
+ Controllers: zod_1.z.array(zod_1.z.string()),
162
+ Records: zod_1.z.record(zod_1.z.string(), zod_1.z
163
+ .object({
164
+ transactionId: zod_1.z.string(),
165
+ ttlSeconds: zod_1.z.number(),
166
+ })
167
+ .passthrough()),
168
+ Balances: zod_1.z.record(zod_1.z.string(), zod_1.z.number()),
169
+ })
170
+ .passthrough();
171
+ /**
172
+ * @param state
173
+ * @returns {boolean}
174
+ * @throws {z.ZodError} if the state object does not match the expected schema
175
+ */
176
+ function isAoANTState(state, logger = index_js_1.Logger.default) {
177
+ try {
178
+ exports.AntStateSchema.parse(state);
179
+ return true;
180
+ }
181
+ catch (error) {
182
+ // this allows us to see the path of the error in the object as well as the expected schema on invalid fields
183
+ logger.error(error.issues);
184
+ return false;
185
+ }
186
+ }
187
+ exports.isAoANTState = isAoANTState;
@@ -18,4 +18,4 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.version = void 0;
20
20
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
21
- exports.version = '2.2.0-alpha.1';
21
+ exports.version = '2.2.0-alpha.3';
@@ -18,7 +18,7 @@ import { connect, createDataItemSigner } from '@permaweb/aoconnect';
18
18
  import { createData } from 'arbundles';
19
19
  import { z } from 'zod';
20
20
  import { defaultArweave } from '../common/arweave.js';
21
- import { AOProcess } from '../common/index.js';
21
+ import { AOProcess, Logger } from '../common/index.js';
22
22
  import { ANT_LUA_ID, ANT_REGISTRY_ID, AOS_MODULE_ID, DEFAULT_SCHEDULER_ID, } from '../constants.js';
23
23
  export async function spawnANT({ signer, module = AOS_MODULE_ID, luaCodeTxId = ANT_LUA_ID, ao = connect(), scheduler = DEFAULT_SCHEDULER_ID, state, stateContractTxId, antRegistryId = ANT_REGISTRY_ID, }) {
24
24
  // AoSigner is not a Contract Signer - should probably add that to the contract signer type
@@ -145,3 +145,35 @@ export function createAoSigner(signer) {
145
145
  };
146
146
  return aoSigner;
147
147
  }
148
+ // using passThrough to require the minimum fields and allow others (eg TotalSupply, Logo, etc)
149
+ export const AntStateSchema = z
150
+ .object({
151
+ Name: z.string(),
152
+ Ticker: z.string(),
153
+ Owner: z.string(),
154
+ Controllers: z.array(z.string()),
155
+ Records: z.record(z.string(), z
156
+ .object({
157
+ transactionId: z.string(),
158
+ ttlSeconds: z.number(),
159
+ })
160
+ .passthrough()),
161
+ Balances: z.record(z.string(), z.number()),
162
+ })
163
+ .passthrough();
164
+ /**
165
+ * @param state
166
+ * @returns {boolean}
167
+ * @throws {z.ZodError} if the state object does not match the expected schema
168
+ */
169
+ export function isAoANTState(state, logger = Logger.default) {
170
+ try {
171
+ AntStateSchema.parse(state);
172
+ return true;
173
+ }
174
+ catch (error) {
175
+ // this allows us to see the path of the error in the object as well as the expected schema on invalid fields
176
+ logger.error(error.issues);
177
+ return false;
178
+ }
179
+ }
@@ -15,4 +15,4 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
18
- export const version = '2.2.0-alpha.1';
18
+ export const version = '2.2.0-alpha.3';
package/lib/types/io.d.ts CHANGED
@@ -67,11 +67,20 @@ export type AoVaultData = {
67
67
  locked: number;
68
68
  endTimestamp: Timestamp;
69
69
  };
70
+ export type AoEpochDistributionRewards = {
71
+ eligible: Record<WalletAddress, {
72
+ delegateRewards: Record<WalletAddress, number>;
73
+ operatorReward: number;
74
+ }>;
75
+ distributed?: Record<WalletAddress, number>;
76
+ };
70
77
  export type AoEpochDistributionData = {
71
- rewards: Record<WalletAddress, number>;
72
- distributedTimestamp: Timestamp;
73
- totalDistributedRewards: number;
78
+ rewards: AoEpochDistributionRewards;
74
79
  totalEligibleRewards: number;
80
+ totalEligibleObserverReward: number;
81
+ totalEligibleGatewayReward: number;
82
+ distributedTimestamp?: Timestamp;
83
+ totalDistributedRewards?: number;
75
84
  };
76
85
  export type AoArNSReservedNameData = {
77
86
  target?: string;
@@ -1,4 +1,6 @@
1
- import { AoANTRecord, AoClient, AoSigner, ContractSigner, WalletAddress } from '../types.js';
1
+ import { z } from 'zod';
2
+ import { Logger } from '../common/index.js';
3
+ import { AoANTRecord, AoANTState, AoClient, AoSigner, ContractSigner, WalletAddress } from '../types.js';
2
4
  export declare function spawnANT({ signer, module, luaCodeTxId, ao, scheduler, state, stateContractTxId, antRegistryId, }: {
3
5
  signer: AoSigner;
4
6
  module?: string;
@@ -24,3 +26,58 @@ export declare function evolveANT({ signer, processId, luaCodeTxId, ao, }: {
24
26
  }): Promise<string>;
25
27
  export declare function isAoSigner(value: unknown): value is AoSigner;
26
28
  export declare function createAoSigner(signer: ContractSigner): AoSigner;
29
+ export declare const AntStateSchema: z.ZodObject<{
30
+ Name: z.ZodString;
31
+ Ticker: z.ZodString;
32
+ Owner: z.ZodString;
33
+ Controllers: z.ZodArray<z.ZodString, "many">;
34
+ Records: z.ZodRecord<z.ZodString, z.ZodObject<{
35
+ transactionId: z.ZodString;
36
+ ttlSeconds: z.ZodNumber;
37
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
38
+ transactionId: z.ZodString;
39
+ ttlSeconds: z.ZodNumber;
40
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
41
+ transactionId: z.ZodString;
42
+ ttlSeconds: z.ZodNumber;
43
+ }, z.ZodTypeAny, "passthrough">>>;
44
+ Balances: z.ZodRecord<z.ZodString, z.ZodNumber>;
45
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
46
+ Name: z.ZodString;
47
+ Ticker: z.ZodString;
48
+ Owner: z.ZodString;
49
+ Controllers: z.ZodArray<z.ZodString, "many">;
50
+ Records: z.ZodRecord<z.ZodString, z.ZodObject<{
51
+ transactionId: z.ZodString;
52
+ ttlSeconds: z.ZodNumber;
53
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
54
+ transactionId: z.ZodString;
55
+ ttlSeconds: z.ZodNumber;
56
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
57
+ transactionId: z.ZodString;
58
+ ttlSeconds: z.ZodNumber;
59
+ }, z.ZodTypeAny, "passthrough">>>;
60
+ Balances: z.ZodRecord<z.ZodString, z.ZodNumber>;
61
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
62
+ Name: z.ZodString;
63
+ Ticker: z.ZodString;
64
+ Owner: z.ZodString;
65
+ Controllers: z.ZodArray<z.ZodString, "many">;
66
+ Records: z.ZodRecord<z.ZodString, z.ZodObject<{
67
+ transactionId: z.ZodString;
68
+ ttlSeconds: z.ZodNumber;
69
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
70
+ transactionId: z.ZodString;
71
+ ttlSeconds: z.ZodNumber;
72
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
73
+ transactionId: z.ZodString;
74
+ ttlSeconds: z.ZodNumber;
75
+ }, z.ZodTypeAny, "passthrough">>>;
76
+ Balances: z.ZodRecord<z.ZodString, z.ZodNumber>;
77
+ }, z.ZodTypeAny, "passthrough">>;
78
+ /**
79
+ * @param state
80
+ * @returns {boolean}
81
+ * @throws {z.ZodError} if the state object does not match the expected schema
82
+ */
83
+ export declare function isAoANTState(state: object, logger?: Logger): state is AoANTState;
@@ -14,4 +14,4 @@
14
14
  * You should have received a copy of the GNU Affero General Public License
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
- export declare const version = "2.1.0-alpha.13";
17
+ export declare const version = "2.2.0-alpha.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.2.0-alpha.1",
3
+ "version": "2.2.0-alpha.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"