@ar.io/sdk 2.1.0-alpha.7 → 2.1.0-alpha.8

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.
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AoANTRegistryWriteable = exports.AoANTRegistryReadable = exports.ANTRegistry = void 0;
4
+ /**
5
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Affero General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Affero General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Affero General Public License
18
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+ const constants_js_1 = require("../constants.js");
21
+ const types_js_1 = require("../types.js");
22
+ const ao_js_1 = require("../utils/ao.js");
23
+ const index_js_1 = require("./index.js");
24
+ class ANTRegistry {
25
+ static init(config) {
26
+ if (config && config.signer) {
27
+ const { signer, ...rest } = config;
28
+ return new AoANTRegistryWriteable({
29
+ ...rest,
30
+ signer,
31
+ });
32
+ }
33
+ return new AoANTRegistryReadable(config);
34
+ }
35
+ }
36
+ exports.ANTRegistry = ANTRegistry;
37
+ class AoANTRegistryReadable {
38
+ process;
39
+ constructor(config) {
40
+ if (config &&
41
+ ((0, types_js_1.isProcessIdConfiguration)(config) || (0, types_js_1.isProcessConfiguration)(config))) {
42
+ if ((0, types_js_1.isProcessConfiguration)(config)) {
43
+ this.process = config.process;
44
+ }
45
+ else if ((0, types_js_1.isProcessIdConfiguration)(config)) {
46
+ this.process = new index_js_1.AOProcess({
47
+ processId: config.processId,
48
+ });
49
+ }
50
+ else {
51
+ throw new index_js_1.InvalidContractConfigurationError();
52
+ }
53
+ }
54
+ else {
55
+ this.process = new index_js_1.AOProcess({
56
+ processId: constants_js_1.ANT_REGISTRY_ID,
57
+ });
58
+ }
59
+ }
60
+ // Should we rename this to "getANTsByAddress"? seems more clear, though not same as handler name
61
+ async accessControlList({ address, }) {
62
+ return this.process.read({
63
+ tags: [
64
+ { name: 'Action', value: 'Access-Control-List' },
65
+ { name: 'Address', value: address },
66
+ ],
67
+ });
68
+ }
69
+ }
70
+ exports.AoANTRegistryReadable = AoANTRegistryReadable;
71
+ class AoANTRegistryWriteable extends AoANTRegistryReadable {
72
+ signer;
73
+ constructor({ signer, ...config }) {
74
+ super(config);
75
+ this.signer = (0, ao_js_1.createAoSigner)(signer);
76
+ }
77
+ async register({ processId, }) {
78
+ return this.process.send({
79
+ tags: [
80
+ { name: 'Action', value: 'Register' },
81
+ { name: 'Process-Id', value: processId },
82
+ ],
83
+ signer: this.signer,
84
+ });
85
+ }
86
+ }
87
+ exports.AoANTRegistryWriteable = AoANTRegistryWriteable;
@@ -33,6 +33,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
33
  __exportStar(require("./error.js"), exports);
34
34
  __exportStar(require("./logger.js"), exports);
35
35
  __exportStar(require("./ant.js"), exports);
36
+ __exportStar(require("./ant-registry.js"), exports);
36
37
  // ao
37
38
  __exportStar(require("./io.js"), exports);
38
39
  __exportStar(require("./contracts/ao-process.js"), exports);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_SCHEDULER_ID = exports.ANT_LUA_ID = exports.AOS_MODULE_ID = exports.MIO_PER_IO = exports.IO_TESTNET_PROCESS_ID = exports.ioDevnetProcessId = exports.IO_DEVNET_PROCESS_ID = exports.ARNS_DEVNET_REGISTRY_TX = exports.ARNS_TESTNET_REGISTRY_TX = exports.SORT_KEY_REGEX = exports.FQDN_REGEX = exports.ARWEAVE_TX_REGEX = void 0;
3
+ exports.DEFAULT_SCHEDULER_ID = exports.ANT_LUA_ID = exports.AOS_MODULE_ID = exports.MIO_PER_IO = exports.ANT_REGISTRY_ID = exports.IO_TESTNET_PROCESS_ID = exports.ioDevnetProcessId = exports.IO_DEVNET_PROCESS_ID = exports.ARNS_DEVNET_REGISTRY_TX = exports.ARNS_TESTNET_REGISTRY_TX = exports.SORT_KEY_REGEX = exports.FQDN_REGEX = exports.ARWEAVE_TX_REGEX = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
6
  *
@@ -28,6 +28,7 @@ exports.IO_DEVNET_PROCESS_ID = 'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc';
28
28
  // backwards compatibility - TODO: remove in v2.0.0
29
29
  exports.ioDevnetProcessId = exports.IO_DEVNET_PROCESS_ID;
30
30
  exports.IO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
31
+ exports.ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
31
32
  exports.MIO_PER_IO = 1_000_000;
32
33
  exports.AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
33
34
  exports.ANT_LUA_ID = 'Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI';
@@ -22,7 +22,7 @@ const arbundles_1 = require("arbundles");
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
- async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, luaCodeTxId = constants_js_1.ANT_LUA_ID, ao = (0, aoconnect_1.connect)(), scheduler = constants_js_1.DEFAULT_SCHEDULER_ID, state, stateContractTxId, }) {
25
+ async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, luaCodeTxId = constants_js_1.ANT_LUA_ID, ao = (0, aoconnect_1.connect)(), scheduler = constants_js_1.DEFAULT_SCHEDULER_ID, state, stateContractTxId, antRegistryId = constants_js_1.ANT_REGISTRY_ID, }) {
26
26
  //TODO: cache locally and only fetch if not cached
27
27
  const luaString = (await arweave_js_1.defaultArweave.transactions.getData(luaCodeTxId, {
28
28
  decode: true,
@@ -32,6 +32,12 @@ async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, luaCode
32
32
  module,
33
33
  scheduler,
34
34
  signer,
35
+ tags: [
36
+ {
37
+ name: 'ANT-Registry-Id',
38
+ value: antRegistryId,
39
+ },
40
+ ],
35
41
  });
36
42
  const aosClient = new index_js_1.AOProcess({
37
43
  processId,
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeDecode = void 0;
4
2
  /**
5
3
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
6
4
  *
@@ -17,6 +15,9 @@ exports.safeDecode = void 0;
17
15
  * You should have received a copy of the GNU Affero General Public License
18
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
17
  */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.safeDecode = void 0;
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
21
  function safeDecode(data) {
21
22
  try {
22
23
  return JSON.parse(data);
@@ -19,37 +19,17 @@ exports.fetchAllArNSRecords = exports.ArNSEventEmitter = exports.getANTProcesses
19
19
  */
20
20
  const eventemitter3_1 = require("eventemitter3");
21
21
  const plimit_lit_1 = require("plimit-lit");
22
+ const ant_registry_js_1 = require("../common/ant-registry.js");
22
23
  const ant_js_1 = require("../common/ant.js");
23
24
  const io_js_1 = require("../common/io.js");
24
25
  const logger_js_1 = require("../common/logger.js");
25
26
  const constants_js_1 = require("../constants.js");
26
- const getANTProcessesOwnedByWallet = async ({ address, contract = io_js_1.IO.init({
27
- processId: constants_js_1.IO_TESTNET_PROCESS_ID,
28
- }), }) => {
29
- const throttle = (0, plimit_lit_1.pLimit)(50);
30
- // get the record names of the registry - TODO: this may need to be paginated
31
- const records = await (0, exports.fetchAllArNSRecords)({
32
- contract: contract,
33
- });
34
- const uniqueContractProcessIds = Object.values(records)
35
- .filter((record) => record.processId !== undefined)
36
- .map((record) => record.processId);
37
- // check the contract owner and controllers
38
- const ownedOrControlledByWallet = await Promise.all(uniqueContractProcessIds.map(async (processId) => throttle(async () => {
39
- const ant = ant_js_1.ANT.init({
40
- processId,
41
- });
42
- const { Owner, Controllers } = await ant.getState();
43
- if (Owner === address || Controllers.includes(address)) {
44
- return processId;
45
- }
46
- return;
47
- })));
48
- if (ownedOrControlledByWallet.length === 0) {
49
- return [];
50
- }
51
- // TODO: insert gql query to find ANT processes owned by wallet given wallet not currently in the registry
52
- return [...new Set(ownedOrControlledByWallet)];
27
+ /**
28
+ * @beta This API is in beta and may change in the future.
29
+ */
30
+ const getANTProcessesOwnedByWallet = async ({ address, registry = ant_registry_js_1.ANTRegistry.init(), }) => {
31
+ const res = await registry.accessControlList({ address });
32
+ return [...new Set([...res.Owned, ...res.Controlled])];
53
33
  };
54
34
  exports.getANTProcessesOwnedByWallet = getANTProcessesOwnedByWallet;
55
35
  function timeout(ms, promise) {
@@ -82,8 +62,10 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
82
62
  this.throttle = (0, plimit_lit_1.pLimit)(concurrency);
83
63
  this.logger = logger;
84
64
  }
85
- async fetchProcessesOwnedByWallet({ address, pageSize, }) {
65
+ async fetchProcessesOwnedByWallet({ address, pageSize, antRegistry = ant_registry_js_1.ANTRegistry.init(), }) {
86
66
  const uniqueContractProcessIds = {};
67
+ const antIdRes = await antRegistry.accessControlList({ address });
68
+ const antIds = new Set([...antIdRes.Owned, ...antIdRes.Controlled]);
87
69
  await timeout(this.timeoutMs, (0, exports.fetchAllArNSRecords)({ contract: this.contract, emitter: this, pageSize }))
88
70
  .catch((e) => {
89
71
  this.emit('error', `Error getting ArNS records: ${e}`);
@@ -94,19 +76,17 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
94
76
  return {};
95
77
  })
96
78
  .then((records) => {
97
- if (!records)
98
- return;
99
- Object.entries(records).forEach(([name, record]) => {
100
- if (record.processId === undefined) {
101
- return;
102
- }
103
- if (uniqueContractProcessIds[record.processId] === undefined) {
104
- uniqueContractProcessIds[record.processId] = {
105
- state: undefined,
106
- names: {},
107
- };
79
+ Object.entries(records).forEach(([name, arnsRecord]) => {
80
+ if (antIds.has(arnsRecord.processId)) {
81
+ if (uniqueContractProcessIds[arnsRecord.processId] == undefined) {
82
+ uniqueContractProcessIds[arnsRecord.processId] = {
83
+ state: undefined,
84
+ names: {},
85
+ };
86
+ }
87
+ uniqueContractProcessIds[arnsRecord.processId].names[name] =
88
+ arnsRecord;
108
89
  }
109
- uniqueContractProcessIds[record.processId].names[name] = record;
110
90
  });
111
91
  });
112
92
  const idCount = Object.keys(uniqueContractProcessIds).length;
@@ -144,6 +124,7 @@ const fetchAllArNSRecords = async ({ contract = io_js_1.IO.init({
144
124
  do {
145
125
  const pageResult = await contract
146
126
  .getArNSRecords({ cursor, limit: pageSize })
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
147
128
  .catch((e) => {
148
129
  logger?.error(`Error getting ArNS records`, {
149
130
  message: e?.message,
@@ -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.1.0-alpha.7';
21
+ exports.version = '2.1.0-alpha.8';
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU Affero General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { ANT_REGISTRY_ID } from '../constants.js';
18
+ import { isProcessConfiguration, isProcessIdConfiguration, } from '../types.js';
19
+ import { createAoSigner } from '../utils/ao.js';
20
+ import { AOProcess, InvalidContractConfigurationError } from './index.js';
21
+ export class ANTRegistry {
22
+ static init(config) {
23
+ if (config && config.signer) {
24
+ const { signer, ...rest } = config;
25
+ return new AoANTRegistryWriteable({
26
+ ...rest,
27
+ signer,
28
+ });
29
+ }
30
+ return new AoANTRegistryReadable(config);
31
+ }
32
+ }
33
+ export class AoANTRegistryReadable {
34
+ process;
35
+ constructor(config) {
36
+ if (config &&
37
+ (isProcessIdConfiguration(config) || isProcessConfiguration(config))) {
38
+ 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
+ else {
51
+ this.process = new AOProcess({
52
+ processId: ANT_REGISTRY_ID,
53
+ });
54
+ }
55
+ }
56
+ // Should we rename this to "getANTsByAddress"? seems more clear, though not same as handler name
57
+ async accessControlList({ address, }) {
58
+ return this.process.read({
59
+ tags: [
60
+ { name: 'Action', value: 'Access-Control-List' },
61
+ { name: 'Address', value: address },
62
+ ],
63
+ });
64
+ }
65
+ }
66
+ export class AoANTRegistryWriteable extends AoANTRegistryReadable {
67
+ signer;
68
+ constructor({ signer, ...config }) {
69
+ super(config);
70
+ this.signer = createAoSigner(signer);
71
+ }
72
+ async register({ processId, }) {
73
+ return this.process.send({
74
+ tags: [
75
+ { name: 'Action', value: 'Register' },
76
+ { name: 'Process-Id', value: processId },
77
+ ],
78
+ signer: this.signer,
79
+ });
80
+ }
81
+ }
@@ -17,6 +17,7 @@
17
17
  export * from './error.js';
18
18
  export * from './logger.js';
19
19
  export * from './ant.js';
20
+ export * from './ant-registry.js';
20
21
  // ao
21
22
  export * from './io.js';
22
23
  export * from './contracts/ao-process.js';
@@ -25,6 +25,7 @@ export const IO_DEVNET_PROCESS_ID = 'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc
25
25
  // backwards compatibility - TODO: remove in v2.0.0
26
26
  export const ioDevnetProcessId = IO_DEVNET_PROCESS_ID;
27
27
  export const IO_TESTNET_PROCESS_ID = 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
28
+ export const ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
28
29
  export const MIO_PER_IO = 1_000_000;
29
30
  export const AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
30
31
  export const ANT_LUA_ID = 'Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI';
@@ -18,8 +18,8 @@ import { connect, createDataItemSigner } from '@permaweb/aoconnect';
18
18
  import { createData } from 'arbundles';
19
19
  import { defaultArweave } from '../common/arweave.js';
20
20
  import { AOProcess } from '../common/index.js';
21
- import { ANT_LUA_ID, AOS_MODULE_ID, DEFAULT_SCHEDULER_ID, } from '../constants.js';
22
- export async function spawnANT({ signer, module = AOS_MODULE_ID, luaCodeTxId = ANT_LUA_ID, ao = connect(), scheduler = DEFAULT_SCHEDULER_ID, state, stateContractTxId, }) {
21
+ import { ANT_LUA_ID, ANT_REGISTRY_ID, AOS_MODULE_ID, DEFAULT_SCHEDULER_ID, } from '../constants.js';
22
+ 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, }) {
23
23
  //TODO: cache locally and only fetch if not cached
24
24
  const luaString = (await defaultArweave.transactions.getData(luaCodeTxId, {
25
25
  decode: true,
@@ -29,6 +29,12 @@ export async function spawnANT({ signer, module = AOS_MODULE_ID, luaCodeTxId = A
29
29
  module,
30
30
  scheduler,
31
31
  signer,
32
+ tags: [
33
+ {
34
+ name: 'ANT-Registry-Id',
35
+ value: antRegistryId,
36
+ },
37
+ ],
32
38
  });
33
39
  const aosClient = new AOProcess({
34
40
  processId,
@@ -14,6 +14,7 @@
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
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
18
  export function safeDecode(data) {
18
19
  try {
19
20
  return JSON.parse(data);
@@ -16,37 +16,17 @@
16
16
  */
17
17
  import { EventEmitter } from 'eventemitter3';
18
18
  import { pLimit } from 'plimit-lit';
19
+ import { ANTRegistry } from '../common/ant-registry.js';
19
20
  import { ANT } from '../common/ant.js';
20
21
  import { IO } from '../common/io.js';
21
22
  import { Logger } from '../common/logger.js';
22
23
  import { IO_TESTNET_PROCESS_ID } from '../constants.js';
23
- export const getANTProcessesOwnedByWallet = async ({ address, contract = IO.init({
24
- processId: IO_TESTNET_PROCESS_ID,
25
- }), }) => {
26
- const throttle = pLimit(50);
27
- // get the record names of the registry - TODO: this may need to be paginated
28
- const records = await fetchAllArNSRecords({
29
- contract: contract,
30
- });
31
- const uniqueContractProcessIds = Object.values(records)
32
- .filter((record) => record.processId !== undefined)
33
- .map((record) => record.processId);
34
- // check the contract owner and controllers
35
- const ownedOrControlledByWallet = await Promise.all(uniqueContractProcessIds.map(async (processId) => throttle(async () => {
36
- const ant = ANT.init({
37
- processId,
38
- });
39
- const { Owner, Controllers } = await ant.getState();
40
- if (Owner === address || Controllers.includes(address)) {
41
- return processId;
42
- }
43
- return;
44
- })));
45
- if (ownedOrControlledByWallet.length === 0) {
46
- return [];
47
- }
48
- // TODO: insert gql query to find ANT processes owned by wallet given wallet not currently in the registry
49
- return [...new Set(ownedOrControlledByWallet)];
24
+ /**
25
+ * @beta This API is in beta and may change in the future.
26
+ */
27
+ export const getANTProcessesOwnedByWallet = async ({ address, registry = ANTRegistry.init(), }) => {
28
+ const res = await registry.accessControlList({ address });
29
+ return [...new Set([...res.Owned, ...res.Controlled])];
50
30
  };
51
31
  function timeout(ms, promise) {
52
32
  return new Promise((resolve, reject) => {
@@ -78,8 +58,10 @@ export class ArNSEventEmitter extends EventEmitter {
78
58
  this.throttle = pLimit(concurrency);
79
59
  this.logger = logger;
80
60
  }
81
- async fetchProcessesOwnedByWallet({ address, pageSize, }) {
61
+ async fetchProcessesOwnedByWallet({ address, pageSize, antRegistry = ANTRegistry.init(), }) {
82
62
  const uniqueContractProcessIds = {};
63
+ const antIdRes = await antRegistry.accessControlList({ address });
64
+ const antIds = new Set([...antIdRes.Owned, ...antIdRes.Controlled]);
83
65
  await timeout(this.timeoutMs, fetchAllArNSRecords({ contract: this.contract, emitter: this, pageSize }))
84
66
  .catch((e) => {
85
67
  this.emit('error', `Error getting ArNS records: ${e}`);
@@ -90,19 +72,17 @@ export class ArNSEventEmitter extends EventEmitter {
90
72
  return {};
91
73
  })
92
74
  .then((records) => {
93
- if (!records)
94
- return;
95
- Object.entries(records).forEach(([name, record]) => {
96
- if (record.processId === undefined) {
97
- return;
98
- }
99
- if (uniqueContractProcessIds[record.processId] === undefined) {
100
- uniqueContractProcessIds[record.processId] = {
101
- state: undefined,
102
- names: {},
103
- };
75
+ Object.entries(records).forEach(([name, arnsRecord]) => {
76
+ if (antIds.has(arnsRecord.processId)) {
77
+ if (uniqueContractProcessIds[arnsRecord.processId] == undefined) {
78
+ uniqueContractProcessIds[arnsRecord.processId] = {
79
+ state: undefined,
80
+ names: {},
81
+ };
82
+ }
83
+ uniqueContractProcessIds[arnsRecord.processId].names[name] =
84
+ arnsRecord;
104
85
  }
105
- uniqueContractProcessIds[record.processId].names[name] = record;
106
86
  });
107
87
  });
108
88
  const idCount = Object.keys(uniqueContractProcessIds).length;
@@ -139,6 +119,7 @@ export const fetchAllArNSRecords = async ({ contract = IO.init({
139
119
  do {
140
120
  const pageResult = await contract
141
121
  .getArNSRecords({ cursor, limit: pageSize })
122
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
123
  .catch((e) => {
143
124
  logger?.error(`Error getting ArNS records`, {
144
125
  message: e?.message,
@@ -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.1.0-alpha.7';
18
+ export const version = '2.1.0-alpha.8';
@@ -0,0 +1,26 @@
1
+ import { AoANTRegistryRead, AoANTRegistryWrite, AoMessageResult, ProcessConfiguration, WithSigner } from '../types.js';
2
+ import { AOProcess } from './index.js';
3
+ export declare class ANTRegistry {
4
+ static init(): AoANTRegistryRead;
5
+ static init(config: Required<ProcessConfiguration> & {
6
+ signer?: undefined;
7
+ }): AoANTRegistryRead;
8
+ static init({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>): AoANTRegistryRead;
9
+ }
10
+ export declare class AoANTRegistryReadable implements AoANTRegistryRead {
11
+ protected process: AOProcess;
12
+ constructor(config?: ProcessConfiguration);
13
+ accessControlList({ address, }: {
14
+ address: string;
15
+ }): Promise<{
16
+ Owned: string[];
17
+ Controlled: string[];
18
+ }>;
19
+ }
20
+ export declare class AoANTRegistryWriteable extends AoANTRegistryReadable implements AoANTRegistryWrite {
21
+ private signer;
22
+ constructor({ signer, ...config }: WithSigner<ProcessConfiguration>);
23
+ register({ processId, }: {
24
+ processId: string;
25
+ }): Promise<AoMessageResult>;
26
+ }
@@ -17,5 +17,6 @@
17
17
  export * from './error.js';
18
18
  export * from './logger.js';
19
19
  export * from './ant.js';
20
+ export * from './ant-registry.js';
20
21
  export * from './io.js';
21
22
  export * from './contracts/ao-process.js';
@@ -23,6 +23,7 @@ export declare const ARNS_DEVNET_REGISTRY_TX = "_NctcA2sRy1-J4OmIQZbYFPM17piNcbd
23
23
  export declare const IO_DEVNET_PROCESS_ID = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc";
24
24
  export declare const ioDevnetProcessId = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc";
25
25
  export declare const IO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA";
26
+ export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
26
27
  export declare const MIO_PER_IO = 1000000;
27
28
  export declare const AOS_MODULE_ID = "cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk";
28
29
  export declare const ANT_LUA_ID = "Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI";
package/lib/types/io.d.ts CHANGED
@@ -199,6 +199,19 @@ export interface AoANTWrite extends AoANTRead {
199
199
  name: any;
200
200
  }): Promise<AoMessageResult>;
201
201
  }
202
+ export interface AoANTRegistryRead {
203
+ accessControlList(params: {
204
+ address: string;
205
+ }): Promise<{
206
+ Owned: string[];
207
+ Controlled: string[];
208
+ }>;
209
+ }
210
+ export interface AoANTRegistryWrite extends AoANTRegistryRead {
211
+ register(params: {
212
+ processId: string;
213
+ }): Promise<AoMessageResult>;
214
+ }
202
215
  export interface AoIOState {
203
216
  GatewayRegistry: Record<WalletAddress, AoGateway>;
204
217
  Epochs: Record<AoEpochIndex, AoEpochData>;
@@ -1,6 +1,6 @@
1
1
  import { ANTState } from '../contract-state.js';
2
2
  import { AoClient, AoSigner, ContractSigner } from '../types.js';
3
- export declare function spawnANT({ signer, module, luaCodeTxId, ao, scheduler, state, stateContractTxId, }: {
3
+ export declare function spawnANT({ signer, module, luaCodeTxId, ao, scheduler, state, stateContractTxId, antRegistryId, }: {
4
4
  signer: AoSigner;
5
5
  module?: string;
6
6
  luaCodeTxId?: string;
@@ -8,6 +8,7 @@ export declare function spawnANT({ signer, module, luaCodeTxId, ao, scheduler, s
8
8
  scheduler?: string;
9
9
  state?: ANTState;
10
10
  stateContractTxId?: string;
11
+ antRegistryId?: string;
11
12
  }): Promise<string>;
12
13
  export declare function evolveANT({ signer, processId, luaCodeTxId, ao, }: {
13
14
  signer: AoSigner;
@@ -16,10 +16,13 @@
16
16
  */
17
17
  import { EventEmitter } from 'eventemitter3';
18
18
  import { ILogger } from '../common/logger.js';
19
- import { AoArNSNameData, AoIORead, ProcessId, WalletAddress } from '../types.js';
20
- export declare const getANTProcessesOwnedByWallet: ({ address, contract, }: {
19
+ import { AoANTRegistryRead, AoArNSNameData, AoIORead, ProcessId, WalletAddress } from '../types.js';
20
+ /**
21
+ * @beta This API is in beta and may change in the future.
22
+ */
23
+ export declare const getANTProcessesOwnedByWallet: ({ address, registry, }: {
21
24
  address: WalletAddress;
22
- contract?: AoIORead;
25
+ registry?: AoANTRegistryRead;
23
26
  }) => Promise<ProcessId[]>;
24
27
  export declare class ArNSEventEmitter extends EventEmitter {
25
28
  protected contract: AoIORead;
@@ -32,9 +35,10 @@ export declare class ArNSEventEmitter extends EventEmitter {
32
35
  concurrency?: number;
33
36
  logger?: ILogger;
34
37
  });
35
- fetchProcessesOwnedByWallet({ address, pageSize, }: {
38
+ fetchProcessesOwnedByWallet({ address, pageSize, antRegistry, }: {
36
39
  address: WalletAddress;
37
40
  pageSize?: number;
41
+ antRegistry?: AoANTRegistryRead;
38
42
  }): Promise<void>;
39
43
  }
40
44
  export declare const fetchAllArNSRecords: ({ contract, emitter, logger, pageSize, }: {
@@ -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.6";
17
+ export declare const version = "2.1.0-alpha.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.1.0-alpha.7",
3
+ "version": "2.1.0-alpha.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"