@ar.io/sdk 3.8.4 → 3.9.0-alpha.2
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 +57 -57
- package/lib/cjs/common/ant-versions.js +92 -0
- package/lib/cjs/common/ant.js +2 -0
- package/lib/cjs/common/index.js +1 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant-versions.js +86 -0
- package/lib/esm/common/ant.js +2 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant-versions.d.ts +42 -0
- package/lib/types/common/ant.d.ts +2 -1
- package/lib/types/common/index.d.ts +1 -0
- package/lib/types/types/ant.d.ts +21 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ANTVersionsWritable = exports.ANTVersionsReadable = exports.ANTVersions = 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 constants_js_1 = require("../constants.js");
|
|
20
|
+
const io_js_1 = require("../types/io.js");
|
|
21
|
+
const ao_js_1 = require("../utils/ao.js");
|
|
22
|
+
const arweave_js_1 = require("../utils/arweave.js");
|
|
23
|
+
const ao_process_js_1 = require("./contracts/ao-process.js");
|
|
24
|
+
const error_js_1 = require("./error.js");
|
|
25
|
+
class ANTVersions {
|
|
26
|
+
static init(config) {
|
|
27
|
+
if (config !== undefined && 'signer' in config) {
|
|
28
|
+
return new ANTVersionsWritable(config);
|
|
29
|
+
}
|
|
30
|
+
return new ANTVersionsReadable(config);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ANTVersions = ANTVersions;
|
|
34
|
+
class ANTVersionsReadable {
|
|
35
|
+
process;
|
|
36
|
+
constructor(config) {
|
|
37
|
+
if (config === undefined || Object.keys(config).length === 0) {
|
|
38
|
+
this.process = new ao_process_js_1.AOProcess({
|
|
39
|
+
processId: constants_js_1.ANT_REGISTRY_ID,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else if ((0, io_js_1.isProcessConfiguration)(config)) {
|
|
43
|
+
this.process = config.process;
|
|
44
|
+
}
|
|
45
|
+
else if ((0, io_js_1.isProcessIdConfiguration)(config)) {
|
|
46
|
+
this.process = new ao_process_js_1.AOProcess({
|
|
47
|
+
processId: config.processId,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new error_js_1.InvalidContractConfigurationError();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async getANTVersions() {
|
|
55
|
+
const res = await this.process.read({
|
|
56
|
+
tags: [{ name: 'Action', value: 'Get-Versions' }],
|
|
57
|
+
});
|
|
58
|
+
return Object.fromEntries(Object.entries(res).sort(([a], [b]) => a.localeCompare(b)));
|
|
59
|
+
}
|
|
60
|
+
async getLatestANTVersion() {
|
|
61
|
+
const versions = await this.getANTVersions();
|
|
62
|
+
const lastestVersion = Object.entries(versions).at(-1);
|
|
63
|
+
if (!lastestVersion)
|
|
64
|
+
throw new Error('No version found');
|
|
65
|
+
return {
|
|
66
|
+
version: lastestVersion[0],
|
|
67
|
+
...lastestVersion[1],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ANTVersionsReadable = ANTVersionsReadable;
|
|
72
|
+
class ANTVersionsWritable extends ANTVersionsReadable {
|
|
73
|
+
signer;
|
|
74
|
+
constructor({ signer, ...config }) {
|
|
75
|
+
super(config);
|
|
76
|
+
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
77
|
+
}
|
|
78
|
+
async addVersion(params, { tags }) {
|
|
79
|
+
return this.process.send({
|
|
80
|
+
tags: (0, arweave_js_1.pruneTags)([
|
|
81
|
+
{ name: 'Action', value: 'Add-Version' },
|
|
82
|
+
{ name: 'Version', value: params.version },
|
|
83
|
+
{ name: 'Module-Id', value: params.moduleId },
|
|
84
|
+
{ name: 'Lua-Source-Id', value: params.luaSourceId },
|
|
85
|
+
{ name: 'Notes', value: params.notes },
|
|
86
|
+
...(tags ?? []),
|
|
87
|
+
]),
|
|
88
|
+
signer: this.signer,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.ANTVersionsWritable = ANTVersionsWritable;
|
package/lib/cjs/common/ant.js
CHANGED
|
@@ -22,8 +22,10 @@ const index_js_1 = require("../types/index.js");
|
|
|
22
22
|
const ant_js_2 = require("../utils/ant.js");
|
|
23
23
|
const ao_js_1 = require("../utils/ao.js");
|
|
24
24
|
const schema_js_1 = require("../utils/schema.js");
|
|
25
|
+
const ant_versions_js_1 = require("./ant-versions.js");
|
|
25
26
|
const index_js_2 = require("./index.js");
|
|
26
27
|
class ANT {
|
|
28
|
+
static versions = ant_versions_js_1.ANTVersions.init();
|
|
27
29
|
// implementation
|
|
28
30
|
static init(config) {
|
|
29
31
|
if (config !== undefined && 'signer' in config) {
|
package/lib/cjs/common/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __exportStar(require("./error.js"), exports);
|
|
|
33
33
|
__exportStar(require("./logger.js"), exports);
|
|
34
34
|
__exportStar(require("./ant.js"), exports);
|
|
35
35
|
__exportStar(require("./ant-registry.js"), exports);
|
|
36
|
+
__exportStar(require("./ant-versions.js"), exports);
|
|
36
37
|
// ao
|
|
37
38
|
__exportStar(require("./io.js"), exports);
|
|
38
39
|
__exportStar(require("./contracts/ao-process.js"), exports);
|
package/lib/cjs/version.js
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ANT_REGISTRY_ID } from '../constants.js';
|
|
17
|
+
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
|
|
18
|
+
import { createAoSigner } from '../utils/ao.js';
|
|
19
|
+
import { pruneTags } from '../utils/arweave.js';
|
|
20
|
+
import { AOProcess } from './contracts/ao-process.js';
|
|
21
|
+
import { InvalidContractConfigurationError } from './error.js';
|
|
22
|
+
export class ANTVersions {
|
|
23
|
+
static init(config) {
|
|
24
|
+
if (config !== undefined && 'signer' in config) {
|
|
25
|
+
return new ANTVersionsWritable(config);
|
|
26
|
+
}
|
|
27
|
+
return new ANTVersionsReadable(config);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class ANTVersionsReadable {
|
|
31
|
+
process;
|
|
32
|
+
constructor(config) {
|
|
33
|
+
if (config === undefined || Object.keys(config).length === 0) {
|
|
34
|
+
this.process = new AOProcess({
|
|
35
|
+
processId: ANT_REGISTRY_ID,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else if (isProcessConfiguration(config)) {
|
|
39
|
+
this.process = config.process;
|
|
40
|
+
}
|
|
41
|
+
else if (isProcessIdConfiguration(config)) {
|
|
42
|
+
this.process = new AOProcess({
|
|
43
|
+
processId: config.processId,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new InvalidContractConfigurationError();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async getANTVersions() {
|
|
51
|
+
const res = await this.process.read({
|
|
52
|
+
tags: [{ name: 'Action', value: 'Get-Versions' }],
|
|
53
|
+
});
|
|
54
|
+
return Object.fromEntries(Object.entries(res).sort(([a], [b]) => a.localeCompare(b)));
|
|
55
|
+
}
|
|
56
|
+
async getLatestANTVersion() {
|
|
57
|
+
const versions = await this.getANTVersions();
|
|
58
|
+
const lastestVersion = Object.entries(versions).at(-1);
|
|
59
|
+
if (!lastestVersion)
|
|
60
|
+
throw new Error('No version found');
|
|
61
|
+
return {
|
|
62
|
+
version: lastestVersion[0],
|
|
63
|
+
...lastestVersion[1],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class ANTVersionsWritable extends ANTVersionsReadable {
|
|
68
|
+
signer;
|
|
69
|
+
constructor({ signer, ...config }) {
|
|
70
|
+
super(config);
|
|
71
|
+
this.signer = createAoSigner(signer);
|
|
72
|
+
}
|
|
73
|
+
async addVersion(params, { tags }) {
|
|
74
|
+
return this.process.send({
|
|
75
|
+
tags: pruneTags([
|
|
76
|
+
{ name: 'Action', value: 'Add-Version' },
|
|
77
|
+
{ name: 'Version', value: params.version },
|
|
78
|
+
{ name: 'Module-Id', value: params.moduleId },
|
|
79
|
+
{ name: 'Lua-Source-Id', value: params.luaSourceId },
|
|
80
|
+
{ name: 'Notes', value: params.notes },
|
|
81
|
+
...(tags ?? []),
|
|
82
|
+
]),
|
|
83
|
+
signer: this.signer,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
package/lib/esm/common/ant.js
CHANGED
|
@@ -19,8 +19,10 @@ import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/inde
|
|
|
19
19
|
import { sortANTRecords } from '../utils/ant.js';
|
|
20
20
|
import { createAoSigner } from '../utils/ao.js';
|
|
21
21
|
import { parseSchemaResult } from '../utils/schema.js';
|
|
22
|
+
import { ANTVersions } from './ant-versions.js';
|
|
22
23
|
import { AOProcess, InvalidContractConfigurationError } from './index.js';
|
|
23
24
|
export class ANT {
|
|
25
|
+
static versions = ANTVersions.init();
|
|
24
26
|
// implementation
|
|
25
27
|
static init(config) {
|
|
26
28
|
if (config !== undefined && 'signer' in config) {
|
package/lib/esm/common/index.js
CHANGED
package/lib/esm/version.js
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AoANTVersionsRead, AoANTVersionsWrite } from '../types/ant.js';
|
|
2
|
+
import { WithSigner } from '../types/common.js';
|
|
3
|
+
import { ProcessConfiguration } from '../types/io.js';
|
|
4
|
+
import { AOProcess } from './contracts/ao-process.js';
|
|
5
|
+
type ANTVersionsNoSigner = ProcessConfiguration;
|
|
6
|
+
type ANTVersionsWithSigner = WithSigner<ProcessConfiguration>;
|
|
7
|
+
export declare class ANTVersions {
|
|
8
|
+
static init(): AoANTVersionsRead;
|
|
9
|
+
static init(config: ANTVersionsNoSigner): AoANTVersionsRead;
|
|
10
|
+
static init(config: ANTVersionsWithSigner): AoANTVersionsWrite;
|
|
11
|
+
}
|
|
12
|
+
export declare class ANTVersionsReadable implements AoANTVersionsRead {
|
|
13
|
+
protected process: AOProcess;
|
|
14
|
+
constructor(config?: ProcessConfiguration);
|
|
15
|
+
getANTVersions(): Promise<Record<string, {
|
|
16
|
+
moduleId: string;
|
|
17
|
+
luaSourceId?: string;
|
|
18
|
+
notes: string;
|
|
19
|
+
}>>;
|
|
20
|
+
getLatestANTVersion(): Promise<{
|
|
21
|
+
version: string;
|
|
22
|
+
moduleId: string;
|
|
23
|
+
luaSourceId?: string;
|
|
24
|
+
notes?: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export declare class ANTVersionsWritable extends ANTVersionsReadable implements AoANTVersionsWrite {
|
|
28
|
+
private signer;
|
|
29
|
+
constructor({ signer, ...config }: WithSigner<ProcessConfiguration>);
|
|
30
|
+
addVersion(params: {
|
|
31
|
+
version: string;
|
|
32
|
+
moduleId: string;
|
|
33
|
+
luaSourceId?: string;
|
|
34
|
+
notes?: string;
|
|
35
|
+
}, { tags }: {
|
|
36
|
+
tags: any;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
id: string;
|
|
39
|
+
result?: unknown;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState, AoANTWrite, SortedANTRecords } from '../types/ant.js';
|
|
1
|
+
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState, AoANTVersionsRead, AoANTWrite, SortedANTRecords } from '../types/ant.js';
|
|
2
2
|
import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
3
3
|
import { AOProcess } from './index.js';
|
|
4
4
|
type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
@@ -7,6 +7,7 @@ type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
|
7
7
|
type ANTConfigNoSigner = ANTConfigOptionalStrict;
|
|
8
8
|
type ANTConfigWithSigner = WithSigner<ANTConfigOptionalStrict>;
|
|
9
9
|
export declare class ANT {
|
|
10
|
+
static versions: AoANTVersionsRead;
|
|
10
11
|
static init(config: ANTConfigNoSigner): AoANTRead;
|
|
11
12
|
static init(config: ANTConfigWithSigner): AoANTWrite;
|
|
12
13
|
}
|
package/lib/types/types/ant.d.ts
CHANGED
|
@@ -260,3 +260,24 @@ export type AoANTSetBaseNameRecordParams = {
|
|
|
260
260
|
export type AoANTSetUndernameRecordParams = AoANTSetBaseNameRecordParams & {
|
|
261
261
|
undername: string;
|
|
262
262
|
};
|
|
263
|
+
export interface AoANTVersionsRead {
|
|
264
|
+
getANTVersions(): Promise<Record<string, {
|
|
265
|
+
moduleId: string;
|
|
266
|
+
luaSourceId?: string;
|
|
267
|
+
notes?: string;
|
|
268
|
+
}>>;
|
|
269
|
+
getLatestANTVersion(): Promise<{
|
|
270
|
+
version: string;
|
|
271
|
+
moduleId: string;
|
|
272
|
+
luaSourceId?: string;
|
|
273
|
+
notes?: string;
|
|
274
|
+
}>;
|
|
275
|
+
}
|
|
276
|
+
export interface AoANTVersionsWrite extends AoANTVersionsRead {
|
|
277
|
+
addVersion: AoWriteAction<{
|
|
278
|
+
version: string;
|
|
279
|
+
moduleId: string;
|
|
280
|
+
luaSourceId?: string;
|
|
281
|
+
notes?: string;
|
|
282
|
+
}>;
|
|
283
|
+
}
|
package/lib/types/version.d.ts
CHANGED