@ar.io/sdk 3.10.0-alpha.3 → 3.10.0-alpha.5
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.
- package/bundles/web.bundle.min.js +63 -63
- package/lib/cjs/common/turbo.js +1 -1
- package/lib/cjs/types/ant.js +12 -1
- package/lib/cjs/utils/ao.js +5 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/turbo.js +1 -1
- package/lib/esm/types/ant.js +11 -0
- package/lib/esm/utils/ao.js +5 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/types/ant.d.ts +53 -1
- package/lib/types/utils/ao.d.ts +1 -12
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/common/turbo.js
CHANGED
|
@@ -39,7 +39,7 @@ async function signedRequestHeadersFromSigner({ signer, nonce = (0, uuid_1.v4)()
|
|
|
39
39
|
else if (signer instanceof arbundles_1.ArweaveSigner ||
|
|
40
40
|
signer instanceof arbundles_1.EthereumSigner ||
|
|
41
41
|
signer instanceof arbundles_1.InjectedEthereumSigner) {
|
|
42
|
-
if ('setPublicKey' in signer) {
|
|
42
|
+
if ('setPublicKey' in signer && signer['publicKey'] === undefined) {
|
|
43
43
|
await signer.setPublicKey();
|
|
44
44
|
}
|
|
45
45
|
signature = (0, base64_js_1.toB64Url)(Buffer.from(await signer.sign(Uint8Array.from(Buffer.from(nonce)))));
|
package/lib/cjs/types/ant.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAoANTState = exports.AntInfoSchema = exports.AntHandlersSchema = exports.AntHandlerNames = exports.AntWriteHandlers = exports.AntReadHandlers = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.AntRecordsSchema = exports.AntRecordSchema = exports.AntKeywordsSchema = exports.AntDescriptionSchema = exports.IntegerStringSchema = exports.AOAddressSchema = exports.ArweaveTxIdSchema = void 0;
|
|
3
|
+
exports.isAoANTState = 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
4
|
/**
|
|
5
5
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
6
|
*
|
|
@@ -80,6 +80,17 @@ exports.AntStateSchema = zod_1.z.object({
|
|
|
80
80
|
.boolean()
|
|
81
81
|
.describe('Flag indicating whether the ANT has been initialized.'),
|
|
82
82
|
});
|
|
83
|
+
exports.SpawnANTStateSchema = zod_1.z.object({
|
|
84
|
+
name: zod_1.z.string().describe('The name of the ANT.'),
|
|
85
|
+
ticker: zod_1.z.string().describe('The ticker symbol for the ANT.'),
|
|
86
|
+
description: zod_1.z.string().describe('The description for the ANT.'),
|
|
87
|
+
keywords: exports.AntKeywordsSchema.describe('The keywords for the ANT.'),
|
|
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
|
+
});
|
|
83
94
|
exports.AntReadHandlers = [
|
|
84
95
|
'balance',
|
|
85
96
|
'balances',
|
package/lib/cjs/utils/ao.js
CHANGED
|
@@ -22,8 +22,13 @@ const zod_1 = require("zod");
|
|
|
22
22
|
const arweave_js_1 = require("../common/arweave.js");
|
|
23
23
|
const index_js_1 = require("../common/index.js");
|
|
24
24
|
const constants_js_1 = require("../constants.js");
|
|
25
|
+
const ant_js_1 = require("../types/ant.js");
|
|
26
|
+
const schema_js_1 = require("./schema.js");
|
|
25
27
|
async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, ao = (0, aoconnect_1.connect)(), scheduler = constants_js_1.DEFAULT_SCHEDULER_ID, state, antRegistryId = constants_js_1.ANT_REGISTRY_ID, logger = index_js_1.Logger.default, authority = constants_js_1.AO_AUTHORITY, }) {
|
|
26
28
|
// TODO: use On-Boot data handler for bootstrapping state instead of initialize-state
|
|
29
|
+
if (state) {
|
|
30
|
+
(0, schema_js_1.parseSchemaResult)(ant_js_1.SpawnANTStateSchema, state);
|
|
31
|
+
}
|
|
27
32
|
const processId = await ao.spawn({
|
|
28
33
|
module,
|
|
29
34
|
scheduler,
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/turbo.js
CHANGED
|
@@ -36,7 +36,7 @@ export async function signedRequestHeadersFromSigner({ signer, nonce = uuidv4(),
|
|
|
36
36
|
else if (signer instanceof ArweaveSigner ||
|
|
37
37
|
signer instanceof EthereumSigner ||
|
|
38
38
|
signer instanceof InjectedEthereumSigner) {
|
|
39
|
-
if ('setPublicKey' in signer) {
|
|
39
|
+
if ('setPublicKey' in signer && signer['publicKey'] === undefined) {
|
|
40
40
|
await signer.setPublicKey();
|
|
41
41
|
}
|
|
42
42
|
signature = toB64Url(Buffer.from(await signer.sign(Uint8Array.from(Buffer.from(nonce)))));
|
package/lib/esm/types/ant.js
CHANGED
|
@@ -77,6 +77,17 @@ export const AntStateSchema = z.object({
|
|
|
77
77
|
.boolean()
|
|
78
78
|
.describe('Flag indicating whether the ANT has been initialized.'),
|
|
79
79
|
});
|
|
80
|
+
export const SpawnANTStateSchema = z.object({
|
|
81
|
+
name: z.string().describe('The name of the ANT.'),
|
|
82
|
+
ticker: z.string().describe('The ticker symbol for the ANT.'),
|
|
83
|
+
description: z.string().describe('The description for the ANT.'),
|
|
84
|
+
keywords: AntKeywordsSchema.describe('The keywords for the ANT.'),
|
|
85
|
+
owner: AOAddressSchema.describe('The Owners address.'),
|
|
86
|
+
controllers: AntControllersSchema.describe('Controllers of the ANT who have administrative privileges.'),
|
|
87
|
+
records: AntRecordsSchema.describe('Records associated with the ANT.'),
|
|
88
|
+
balances: AntBalancesSchema.describe('Balance details for each address holding the ANT.'),
|
|
89
|
+
logo: ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
|
|
90
|
+
});
|
|
80
91
|
export const AntReadHandlers = [
|
|
81
92
|
'balance',
|
|
82
93
|
'balances',
|
package/lib/esm/utils/ao.js
CHANGED
|
@@ -19,8 +19,13 @@ import { z } from 'zod';
|
|
|
19
19
|
import { defaultArweave } from '../common/arweave.js';
|
|
20
20
|
import { AOProcess, Logger } from '../common/index.js';
|
|
21
21
|
import { ANT_LUA_ID, ANT_REGISTRY_ID, AOS_MODULE_ID, AO_AUTHORITY, DEFAULT_SCHEDULER_ID, } from '../constants.js';
|
|
22
|
+
import { SpawnANTStateSchema } from '../types/ant.js';
|
|
23
|
+
import { parseSchemaResult } from './schema.js';
|
|
22
24
|
export async function spawnANT({ signer, module = AOS_MODULE_ID, ao = connect(), scheduler = DEFAULT_SCHEDULER_ID, state, antRegistryId = ANT_REGISTRY_ID, logger = Logger.default, authority = AO_AUTHORITY, }) {
|
|
23
25
|
// TODO: use On-Boot data handler for bootstrapping state instead of initialize-state
|
|
26
|
+
if (state) {
|
|
27
|
+
parseSchemaResult(SpawnANTStateSchema, state);
|
|
28
|
+
}
|
|
24
29
|
const processId = await ao.spawn({
|
|
25
30
|
module,
|
|
26
31
|
scheduler,
|
package/lib/esm/version.js
CHANGED
package/lib/types/types/ant.d.ts
CHANGED
|
@@ -127,11 +127,63 @@ export declare const AntStateSchema: z.ZodObject<{
|
|
|
127
127
|
Initialized: boolean;
|
|
128
128
|
}>;
|
|
129
129
|
export type AoANTState = z.infer<typeof AntStateSchema>;
|
|
130
|
+
export declare const SpawnANTStateSchema: z.ZodObject<{
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
ticker: z.ZodString;
|
|
133
|
+
description: z.ZodString;
|
|
134
|
+
keywords: z.ZodArray<z.ZodString, "many">;
|
|
135
|
+
owner: z.ZodString;
|
|
136
|
+
controllers: z.ZodArray<z.ZodString, "many">;
|
|
137
|
+
records: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
138
|
+
transactionId: z.ZodEffects<z.ZodString, string, string>;
|
|
139
|
+
ttlSeconds: z.ZodNumber;
|
|
140
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
transactionId: string;
|
|
143
|
+
ttlSeconds: number;
|
|
144
|
+
priority?: number | undefined;
|
|
145
|
+
}, {
|
|
146
|
+
transactionId: string;
|
|
147
|
+
ttlSeconds: number;
|
|
148
|
+
priority?: number | undefined;
|
|
149
|
+
}>>;
|
|
150
|
+
balances: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
151
|
+
logo: z.ZodEffects<z.ZodString, string, string>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
description: string;
|
|
154
|
+
name: string;
|
|
155
|
+
ticker: string;
|
|
156
|
+
keywords: string[];
|
|
157
|
+
owner: string;
|
|
158
|
+
controllers: string[];
|
|
159
|
+
records: Record<string, {
|
|
160
|
+
transactionId: string;
|
|
161
|
+
ttlSeconds: number;
|
|
162
|
+
priority?: number | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
balances: Record<string, number>;
|
|
165
|
+
logo: string;
|
|
166
|
+
}, {
|
|
167
|
+
description: string;
|
|
168
|
+
name: string;
|
|
169
|
+
ticker: string;
|
|
170
|
+
keywords: string[];
|
|
171
|
+
owner: string;
|
|
172
|
+
controllers: string[];
|
|
173
|
+
records: Record<string, {
|
|
174
|
+
transactionId: string;
|
|
175
|
+
ttlSeconds: number;
|
|
176
|
+
priority?: number | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
balances: Record<string, number>;
|
|
179
|
+
logo: string;
|
|
180
|
+
}>;
|
|
181
|
+
export type SpawnANTState = z.infer<typeof SpawnANTStateSchema>;
|
|
130
182
|
export declare const AntReadHandlers: readonly ["balance", "balances", "totalSupply", "info", "controllers", "record", "records", "state"];
|
|
131
183
|
export type AoANTReadHandler = (typeof AntReadHandlers)[number];
|
|
132
184
|
export declare const AntWriteHandlers: readonly ["_eval", "_default", "transfer", "addController", "removeController", "setRecord", "removeRecord", "setName", "setTicker", "setDescription", "setKeywords", "setLogo", "initializeState", "releaseName", "reassignName", "approvePrimaryName", "removePrimaryNames"];
|
|
133
185
|
export type AoANTWriteHandler = (typeof AntWriteHandlers)[number];
|
|
134
|
-
export declare const AntHandlerNames: ("
|
|
186
|
+
export declare const AntHandlerNames: ("controllers" | "records" | "balances" | "balance" | "totalSupply" | "info" | "record" | "state" | "_eval" | "_default" | "transfer" | "addController" | "removeController" | "setRecord" | "removeRecord" | "setName" | "setTicker" | "setDescription" | "setKeywords" | "setLogo" | "initializeState" | "releaseName" | "reassignName" | "approvePrimaryName" | "removePrimaryNames")[];
|
|
135
187
|
export type AoANTHandler = AoANTWriteHandler | AoANTReadHandler;
|
|
136
188
|
export declare const AntHandlersSchema: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
|
|
137
189
|
export declare const AntInfoSchema: z.ZodObject<{
|
package/lib/types/utils/ao.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import Arweave from 'arweave';
|
|
2
2
|
import { Logger } from '../common/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { SpawnANTState } from '../types/ant.js';
|
|
4
4
|
import { AoClient, AoEpochData, AoEpochDistributed, AoSigner, ContractSigner, WalletAddress } from '../types/index.js';
|
|
5
|
-
export type SpawnANTState = {
|
|
6
|
-
owner: WalletAddress;
|
|
7
|
-
controllers: WalletAddress[];
|
|
8
|
-
name: string;
|
|
9
|
-
description: string;
|
|
10
|
-
keywords: string[];
|
|
11
|
-
ticker: string;
|
|
12
|
-
records: Record<string, AoANTRecord>;
|
|
13
|
-
balances: Record<WalletAddress, number>;
|
|
14
|
-
logo: string;
|
|
15
|
-
};
|
|
16
5
|
export type SpawnANTParams = {
|
|
17
6
|
signer: AoSigner;
|
|
18
7
|
module?: string;
|
package/lib/types/version.d.ts
CHANGED