@ar.io/sdk 3.16.1-alpha.1 → 3.17.0

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.
@@ -241,6 +241,16 @@ const utils_js_1 = require("./utils.js");
241
241
  options: options_js_1.paginationOptions,
242
242
  action: readCommands_js_1.listArNSRecords,
243
243
  });
244
+ (0, utils_js_1.makeCommand)({
245
+ name: 'list-arns-names-for-address',
246
+ description: 'List all ArNS names for an address',
247
+ options: [
248
+ ...options_js_1.paginationOptions,
249
+ options_js_1.optionMap.address,
250
+ options_js_1.optionMap.antRegistryProcessId,
251
+ ],
252
+ action: readCommands_js_1.listArNSRecordsForAddress,
253
+ });
244
254
  (0, utils_js_1.makeCommand)({
245
255
  name: 'list-arns-reserved-names',
246
256
  description: 'Get all reserved ArNS names',
@@ -8,6 +8,7 @@ exports.getDelegations = getDelegations;
8
8
  exports.getAllowedDelegates = getAllowedDelegates;
9
9
  exports.getArNSRecord = getArNSRecord;
10
10
  exports.listArNSRecords = listArNSRecords;
11
+ exports.listArNSRecordsForAddress = listArNSRecordsForAddress;
11
12
  exports.getArNSReservedName = getArNSReservedName;
12
13
  exports.listArNSReservedNames = listArNSReservedNames;
13
14
  exports.getArNSReturnedName = getArNSReturnedName;
@@ -86,6 +87,16 @@ async function listArNSRecords(o) {
86
87
  const records = await (0, utils_js_1.readARIOFromOptions)(o).getArNSRecords((0, utils_js_1.paginationParamsFromOptions)(o));
87
88
  return records.items.length ? records : { message: 'No records found' };
88
89
  }
90
+ async function listArNSRecordsForAddress(o) {
91
+ const paginationParams = (0, utils_js_1.paginationParamsFromOptions)(o);
92
+ const address = (0, utils_js_1.requiredAddressFromOptions)(o);
93
+ const names = await (0, utils_js_1.readARIOFromOptions)(o).getArNSRecordsForAddress({
94
+ ...paginationParams,
95
+ address,
96
+ antRegistryProcessId: o.antRegistryProcessId,
97
+ });
98
+ return names.items.length ? names : { message: 'No names found' };
99
+ }
89
100
  async function getArNSReservedName(o) {
90
101
  const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
91
102
  return ((await (0, utils_js_1.readARIOFromOptions)(o).getArNSReservedName({
@@ -21,6 +21,7 @@ const constants_js_1 = require("../constants.js");
21
21
  const index_js_1 = require("../types/index.js");
22
22
  const ao_js_1 = require("../utils/ao.js");
23
23
  const arweave_js_1 = require("../utils/arweave.js");
24
+ const ant_registry_js_1 = require("./ant-registry.js");
24
25
  const ant_js_1 = require("./ant.js");
25
26
  const arweave_js_2 = require("./arweave.js");
26
27
  const ao_process_js_1 = require("./contracts/ao-process.js");
@@ -671,6 +672,50 @@ class ARIOReadable {
671
672
  type: nameData.type,
672
673
  };
673
674
  }
675
+ /**
676
+ * Get all ARNS names associated with an address using the provided ANT registry address.
677
+ *
678
+ * By default it will use the mainnet ANT registry address.
679
+ *
680
+ * @param {Object} params - The parameters for fetching ARNS names
681
+ * @param {string} params.address - The address to fetch the ARNS names for
682
+ * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
683
+ */
684
+ async getArNSRecordsForAddress(params) {
685
+ const { antRegistryId = constants_js_1.ANT_REGISTRY_ID, address } = params;
686
+ const antRegistry = ant_registry_js_1.ANTRegistry.init({
687
+ process: new ao_process_js_1.AOProcess({
688
+ ao: this.process.ao,
689
+ processId: antRegistryId,
690
+ }),
691
+ });
692
+ // Note: there could be a race condition here if the ACL changes during pagination requests, resulting in different results from the `getArNSRecords`.
693
+ // This is an unlikely scenario, so to give the client control, and keep this API consistent with other ArNS APIs, we refetch the ACL for each page, and
694
+ // return paginated results.
695
+ const { Controlled = [], Owned = [] } = await antRegistry.accessControlList({
696
+ address,
697
+ });
698
+ const allProcessIds = new Set([...Controlled, ...Owned]);
699
+ if (allProcessIds.size === 0) {
700
+ return {
701
+ items: [],
702
+ hasMore: false,
703
+ nextCursor: undefined,
704
+ limit: params.limit ?? 1000,
705
+ totalItems: 0,
706
+ sortOrder: params.sortOrder ?? 'asc',
707
+ };
708
+ }
709
+ const currentPage = await this.getArNSRecords({
710
+ ...params,
711
+ filters: {
712
+ // NOTE: we confirmed that dry-runs are not limited to the same tag limits as data-items.
713
+ // Should this change, we'll need to batch the requests.
714
+ processId: Array.from(allProcessIds),
715
+ },
716
+ });
717
+ return currentPage;
718
+ }
674
719
  }
675
720
  exports.ARIOReadable = ARIOReadable;
676
721
  class ARIOWriteable extends ARIOReadable {
@@ -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 = '3.16.1-alpha.1';
20
+ exports.version = '3.17.0';
@@ -22,7 +22,7 @@ import { version } from '../version.js';
22
22
  import { setAntBaseNameCLICommand, setAntRecordCLICommand, } from './commands/antCommands.js';
23
23
  import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICommand, requestPrimaryNameCLICommand, upgradeRecordCLICommand, } from './commands/arnsPurchaseCommands.js';
24
24
  import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
25
- import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listAntsForAddress, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, resolveArNSName, } from './commands/readCommands.js';
25
+ import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listAntsForAddress, listArNSRecords, listArNSRecordsForAddress, listArNSReservedNames, listArNSReturnedNames, listGateways, resolveArNSName, } from './commands/readCommands.js';
26
26
  import { createVaultCLICommand, extendVaultCLICommand, increaseVaultCLICommand, revokeVaultCLICommand, transferCLICommand, vaultedTransferCLICommand, } from './commands/transfer.js';
27
27
  import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, setAntBaseNameOptions, setAntUndernameOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, vaultedTransferOptions, writeActionOptions, } from './options.js';
28
28
  import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, customTagsFromOptions, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredProcessIdFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, } from './utils.js';
@@ -239,6 +239,16 @@ makeCommand({
239
239
  options: paginationOptions,
240
240
  action: listArNSRecords,
241
241
  });
242
+ makeCommand({
243
+ name: 'list-arns-names-for-address',
244
+ description: 'List all ArNS names for an address',
245
+ options: [
246
+ ...paginationOptions,
247
+ optionMap.address,
248
+ optionMap.antRegistryProcessId,
249
+ ],
250
+ action: listArNSRecordsForAddress,
251
+ });
242
252
  makeCommand({
243
253
  name: 'list-arns-reserved-names',
244
254
  description: 'Get all reserved ArNS names',
@@ -61,6 +61,16 @@ export async function listArNSRecords(o) {
61
61
  const records = await readARIOFromOptions(o).getArNSRecords(paginationParamsFromOptions(o));
62
62
  return records.items.length ? records : { message: 'No records found' };
63
63
  }
64
+ export async function listArNSRecordsForAddress(o) {
65
+ const paginationParams = paginationParamsFromOptions(o);
66
+ const address = requiredAddressFromOptions(o);
67
+ const names = await readARIOFromOptions(o).getArNSRecordsForAddress({
68
+ ...paginationParams,
69
+ address,
70
+ antRegistryProcessId: o.antRegistryProcessId,
71
+ });
72
+ return names.items.length ? names : { message: 'No names found' };
73
+ }
64
74
  export async function getArNSReservedName(o) {
65
75
  const name = requiredStringFromOptions(o, 'name');
66
76
  return ((await readARIOFromOptions(o).getArNSReservedName({
@@ -14,10 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { connect } from '@permaweb/aoconnect';
17
- import { ARIO_MAINNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, } from '../constants.js';
17
+ import { ANT_REGISTRY_ID, ARIO_MAINNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, } from '../constants.js';
18
18
  import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/index.js';
19
19
  import { createAoSigner } from '../utils/ao.js';
20
20
  import { getEpochDataFromGqlWithCUFallback, paginationParamsToTags, pruneTags, removeEligibleRewardsFromEpochData, sortAndPaginateEpochDataIntoEligibleDistributions, } from '../utils/arweave.js';
21
+ import { ANTRegistry } from './ant-registry.js';
21
22
  import { ANT } from './ant.js';
22
23
  import { defaultArweave } from './arweave.js';
23
24
  import { AOProcess } from './contracts/ao-process.js';
@@ -667,6 +668,50 @@ export class ARIOReadable {
667
668
  type: nameData.type,
668
669
  };
669
670
  }
671
+ /**
672
+ * Get all ARNS names associated with an address using the provided ANT registry address.
673
+ *
674
+ * By default it will use the mainnet ANT registry address.
675
+ *
676
+ * @param {Object} params - The parameters for fetching ARNS names
677
+ * @param {string} params.address - The address to fetch the ARNS names for
678
+ * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
679
+ */
680
+ async getArNSRecordsForAddress(params) {
681
+ const { antRegistryId = ANT_REGISTRY_ID, address } = params;
682
+ const antRegistry = ANTRegistry.init({
683
+ process: new AOProcess({
684
+ ao: this.process.ao,
685
+ processId: antRegistryId,
686
+ }),
687
+ });
688
+ // Note: there could be a race condition here if the ACL changes during pagination requests, resulting in different results from the `getArNSRecords`.
689
+ // This is an unlikely scenario, so to give the client control, and keep this API consistent with other ArNS APIs, we refetch the ACL for each page, and
690
+ // return paginated results.
691
+ const { Controlled = [], Owned = [] } = await antRegistry.accessControlList({
692
+ address,
693
+ });
694
+ const allProcessIds = new Set([...Controlled, ...Owned]);
695
+ if (allProcessIds.size === 0) {
696
+ return {
697
+ items: [],
698
+ hasMore: false,
699
+ nextCursor: undefined,
700
+ limit: params.limit ?? 1000,
701
+ totalItems: 0,
702
+ sortOrder: params.sortOrder ?? 'asc',
703
+ };
704
+ }
705
+ const currentPage = await this.getArNSRecords({
706
+ ...params,
707
+ filters: {
708
+ // NOTE: we confirmed that dry-runs are not limited to the same tag limits as data-items.
709
+ // Should this change, we'll need to batch the requests.
710
+ processId: Array.from(allProcessIds),
711
+ },
712
+ });
713
+ return currentPage;
714
+ }
670
715
  }
671
716
  export class ARIOWriteable extends ARIOReadable {
672
717
  signer;
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.16.1-alpha.1';
17
+ export const version = '3.17.0';
@@ -35,6 +35,9 @@ export declare function getArNSRecord(o: NameCLIOptions): Promise<import("../../
35
35
  export declare function listArNSRecords(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<AoArNSNameDataWithName> | {
36
36
  message: string;
37
37
  }>;
38
+ export declare function listArNSRecordsForAddress(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<AoArNSNameDataWithName> | {
39
+ message: string;
40
+ }>;
38
41
  export declare function getArNSReservedName(o: NameCLIOptions): Promise<import("../../types/io.js").AoArNSReservedNameData>;
39
42
  export declare function listArNSReservedNames(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoArNSReservedNameDataWithName> | {
40
43
  message: string;
@@ -140,6 +140,19 @@ export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
140
140
  resolveArNSName({ name, }: {
141
141
  name: string;
142
142
  }): Promise<ArNSNameResolutionData>;
143
+ /**
144
+ * Get all ARNS names associated with an address using the provided ANT registry address.
145
+ *
146
+ * By default it will use the mainnet ANT registry address.
147
+ *
148
+ * @param {Object} params - The parameters for fetching ARNS names
149
+ * @param {string} params.address - The address to fetch the ARNS names for
150
+ * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
151
+ */
152
+ getArNSRecordsForAddress(params: PaginationParams<AoArNSNameDataWithName> & {
153
+ antRegistryId?: string;
154
+ address: WalletAddress;
155
+ }): Promise<PaginationResult<AoArNSNameDataWithName>>;
143
156
  }
144
157
  export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
145
158
  private signer;
@@ -470,6 +470,10 @@ export interface AoARIORead extends ArNSNameResolver {
470
470
  name: string;
471
471
  }): Promise<AoArNSNameData>;
472
472
  getArNSRecords(params?: AoGetArNSRecordsParams): Promise<PaginationResult<AoArNSNameDataWithName>>;
473
+ getArNSRecordsForAddress(params: PaginationParams<AoArNSNameDataWithName> & {
474
+ address: WalletAddress;
475
+ antRegistryProcessId?: string;
476
+ }): Promise<PaginationResult<AoArNSNameDataWithName>>;
473
477
  getArNSReservedNames(params?: PaginationParams<AoArNSReservedNameDataWithName>): Promise<PaginationResult<AoArNSReservedNameDataWithName>>;
474
478
  getArNSReservedName({ name, }: {
475
479
  name: string;
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "3.16.0";
16
+ export declare const version = "3.16.1-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.16.1-alpha.1",
3
+ "version": "3.17.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"