@ar.io/sdk
Version:
[](https://codecov.io/gh/ar-io/ar-io-sdk)
767 lines (766 loc) • 32.3 kB
JavaScript
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line header/header -- This is a CLI file
const commander_1 = require("commander");
const index_js_1 = require("../node/index.js");
const token_js_1 = require("../types/token.js");
const version_js_1 = require("../version.js");
const antCommands_js_1 = require("./commands/antCommands.js");
const arnsPurchaseCommands_js_1 = require("./commands/arnsPurchaseCommands.js");
const gatewayWriteCommands_js_1 = require("./commands/gatewayWriteCommands.js");
const readCommands_js_1 = require("./commands/readCommands.js");
const transfer_js_1 = require("./commands/transfer.js");
const options_js_1 = require("./options.js");
const utils_js_1 = require("./utils.js");
(0, utils_js_1.applyOptions)(commander_1.program
.name('ar.io')
.version(version_js_1.version)
.description('AR.IO Network CLI')
.helpCommand(true), options_js_1.globalOptions);
// # Getters
(0, utils_js_1.makeCommand)({
name: 'info',
description: 'Get network info',
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getInfo(),
});
(0, utils_js_1.makeCommand)({
name: 'token-supply',
description: 'Get the total token supply',
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getTokenSupply(),
});
(0, utils_js_1.makeCommand)({
name: 'balance',
description: 'Get the balance of an address',
options: [options_js_1.optionMap.address],
action: (options) => (0, utils_js_1.readARIOFromOptions)(options)
.getBalance({ address: (0, utils_js_1.requiredAddressFromOptions)(options) })
.then((result) => ({
address: (0, utils_js_1.requiredAddressFromOptions)(options),
mARIOBalance: result,
message: `Provided address current has a balance of ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(result).toARIO())} ARIO`,
})),
});
(0, utils_js_1.makeCommand)({
name: 'get-registration-fees',
description: 'Get registration fees',
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getRegistrationFees(),
});
(0, utils_js_1.makeCommand)({
name: 'get-demand-factor',
description: 'Get demand factor',
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getDemandFactor(),
});
(0, utils_js_1.makeCommand)({
name: 'get-demand-factor-settings',
description: 'Get current settings for demand factor',
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getDemandFactorSettings(),
});
(0, utils_js_1.makeCommand)({
name: 'get-epoch-settings',
description: 'Get current settings for epochs',
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getEpochSettings(),
});
(0, utils_js_1.makeCommand)({
name: 'get-gateway',
description: 'Get the gateway of an address',
options: [options_js_1.optionMap.address],
action: readCommands_js_1.getGateway,
});
(0, utils_js_1.makeCommand)({
name: 'get-gateway-delegates',
description: 'Get the delegates of a gateway',
options: options_js_1.paginationAddressOptions,
action: readCommands_js_1.getGatewayDelegates,
});
(0, utils_js_1.makeCommand)({
name: 'get-gateway-vaults',
description: 'Get the vaults of a gateway',
options: options_js_1.paginationAddressOptions,
action: readCommands_js_1.getGatewayVaults,
});
(0, utils_js_1.makeCommand)({
name: 'get-delegations',
description: 'Get all stake delegated to gateways from this address',
options: [options_js_1.optionMap.address],
action: readCommands_js_1.getDelegations,
});
(0, utils_js_1.makeCommand)({
name: 'get-allowed-delegates',
description: 'Get the allow list of a gateway delegate',
options: options_js_1.paginationAddressOptions,
action: readCommands_js_1.getAllowedDelegates,
});
(0, utils_js_1.makeCommand)({
name: 'get-arns-record',
description: 'Get an ArNS record by name',
options: [options_js_1.optionMap.name],
action: readCommands_js_1.getArNSRecord,
});
(0, utils_js_1.makeCommand)({
name: 'get-arns-reserved-name',
description: 'Get a reserved ArNS name',
options: [options_js_1.optionMap.name],
action: readCommands_js_1.getArNSReservedName,
});
(0, utils_js_1.makeCommand)({
name: 'get-arns-returned-name',
description: 'Get an ArNS returned name by name',
options: [options_js_1.optionMap.name],
action: readCommands_js_1.getArNSReturnedName,
});
(0, utils_js_1.makeCommand)({
name: 'get-epoch',
description: 'Get epoch data',
options: options_js_1.epochOptions,
action: readCommands_js_1.getEpoch,
});
(0, utils_js_1.makeCommand)({
name: 'get-current-epoch',
description: 'Get current epoch data',
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getCurrentEpoch(),
});
(0, utils_js_1.makeCommand)({
name: 'get-prescribed-observers',
description: 'Get prescribed observers for an epoch',
options: options_js_1.epochOptions,
action: readCommands_js_1.getPrescribedObservers,
});
(0, utils_js_1.makeCommand)({
name: 'get-prescribed-names',
description: 'Get prescribed names for an epoch',
options: options_js_1.epochOptions,
action: readCommands_js_1.getPrescribedNames,
});
(0, utils_js_1.makeCommand)({
name: 'get-observations',
description: 'Get observations for an epoch',
options: options_js_1.epochOptions,
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getObservations((0, utils_js_1.epochInputFromOptions)(o))
.then((result) => result ?? { message: 'No observations found for epoch' }),
});
(0, utils_js_1.makeCommand)({
name: 'get-distributions',
description: 'Get distributions for an epoch',
options: options_js_1.epochOptions,
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getDistributions((0, utils_js_1.epochInputFromOptions)(o))
.then((result) => result ?? { message: 'No distributions found for epoch' }),
});
(0, utils_js_1.makeCommand)({
name: 'get-eligible-rewards',
description: 'Get eligible rewards for an epoch',
options: [...options_js_1.epochOptions, ...options_js_1.paginationOptions],
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getEligibleEpochRewards((0, utils_js_1.epochInputFromOptions)(o), (0, utils_js_1.paginationParamsFromOptions)(o))
.then((result) => result ?? { message: 'No eligible distributions found for epoch' }),
});
(0, utils_js_1.makeCommand)({
name: 'get-token-cost',
description: 'Get token cost for an intended action',
options: options_js_1.tokenCostOptions,
action: readCommands_js_1.getTokenCost,
});
(0, utils_js_1.makeCommand)({
name: 'get-cost-details',
description: 'Get expanded cost details for an intended action',
options: options_js_1.tokenCostOptions,
action: readCommands_js_1.getCostDetails,
});
(0, utils_js_1.makeCommand)({
name: 'get-primary-name',
description: 'Get primary name',
options: [options_js_1.optionMap.address, options_js_1.optionMap.name],
action: readCommands_js_1.getPrimaryName,
});
(0, utils_js_1.makeCommand)({
name: 'get-primary-name-request',
description: 'Get primary name request',
options: [options_js_1.optionMap.initiator],
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getPrimaryNameRequest({
initiator: (0, utils_js_1.requiredStringFromOptions)(o, 'initiator'),
})
.then((result) => result ?? {
message: `No primary name request found`,
}),
});
(0, utils_js_1.makeCommand)({
name: 'get-redelegation-fee',
description: 'Get redelegation fee',
options: [options_js_1.optionMap.address],
action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getRedelegationFee({
address: (0, utils_js_1.requiredAddressFromOptions)(options),
}),
});
(0, utils_js_1.makeCommand)({
name: 'get-vault',
description: 'Get the vault of provided address and vault ID',
options: options_js_1.getVaultOptions,
action: readCommands_js_1.getVault,
});
// # ArNS Resolution
(0, utils_js_1.makeCommand)({
name: 'resolve-arns-name',
description: 'Resolve an ArNS name',
options: [options_js_1.optionMap.name],
action: readCommands_js_1.resolveArNSName,
});
// # Paginated handlers
(0, utils_js_1.makeCommand)({
name: 'list-gateways',
description: 'List the gateways of the network',
options: options_js_1.paginationOptions,
action: readCommands_js_1.listGateways,
});
(0, utils_js_1.makeCommand)({
name: 'list-all-delegates',
description: 'List all paginated delegates from all gateways',
options: options_js_1.paginationOptions,
action: readCommands_js_1.listAllDelegatesCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'list-arns-records',
description: 'List all ArNS records',
options: options_js_1.paginationOptions,
action: readCommands_js_1.listArNSRecords,
});
(0, utils_js_1.makeCommand)({
name: 'list-arns-reserved-names',
description: 'Get all reserved ArNS names',
options: options_js_1.paginationOptions,
action: readCommands_js_1.listArNSReservedNames,
});
(0, utils_js_1.makeCommand)({
name: 'list-arns-returned-names',
description: 'Get all ArNS recently returned names',
options: options_js_1.paginationOptions,
action: readCommands_js_1.listArNSReturnedNames,
});
(0, utils_js_1.makeCommand)({
name: 'list-vaults',
description: 'Get all wallet vaults',
options: options_js_1.paginationOptions,
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getVaults((0, utils_js_1.paginationParamsFromOptions)(o))
.then((result) => result.items.length ? result : { message: 'No vaults found' }),
});
(0, utils_js_1.makeCommand)({
name: 'list-primary-name-requests',
description: 'Get primary name requests',
options: options_js_1.paginationOptions,
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getPrimaryNameRequests((0, utils_js_1.paginationParamsFromOptions)(o))
.then((result) => result.items.length ? result : { message: 'No requests found' }),
});
(0, utils_js_1.makeCommand)({
name: 'list-primary-names',
description: 'Get primary names',
options: options_js_1.paginationOptions,
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getPrimaryNames((0, utils_js_1.paginationParamsFromOptions)(o))
.then((result) => result.items.length ? result : { message: 'No names found' }),
});
(0, utils_js_1.makeCommand)({
name: 'list-balances',
description: 'List all balances',
options: options_js_1.paginationOptions,
action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
.getBalances((0, utils_js_1.paginationParamsFromOptions)(o))
.then((result) => result.items.length ? result : { message: 'No balances found' }),
});
(0, utils_js_1.makeCommand)({
name: 'list-all-gateway-vaults',
description: 'List vaults from all gateways',
options: options_js_1.paginationAddressOptions,
action: readCommands_js_1.getAllGatewayVaults,
});
// # Actions
(0, utils_js_1.makeCommand)({
name: 'transfer',
description: 'Transfer ARIO to another address',
options: options_js_1.transferOptions,
action: transfer_js_1.transferCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'vaulted-transfer',
description: 'Transfer ARIO to another address into a locked vault',
options: options_js_1.vaultedTransferOptions,
action: transfer_js_1.vaultedTransferCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'revoke-vault',
description: 'Revoke a vaulted transfer as the controller',
options: [...options_js_1.writeActionOptions, options_js_1.optionMap.vaultId, options_js_1.optionMap.recipient],
action: transfer_js_1.revokeVaultCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'create-vault',
description: 'Create a locked vault with balance from the sender',
options: [...options_js_1.writeActionOptions, options_js_1.optionMap.lockLengthMs, options_js_1.optionMap.quantity],
action: transfer_js_1.createVaultCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'extend-vault',
description: 'Extend the lock length of a vault as the recipient',
options: [...options_js_1.writeActionOptions, options_js_1.optionMap.vaultId, options_js_1.optionMap.extendLengthMs],
action: transfer_js_1.extendVaultCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'increase-vault',
description: 'Increase the balance of a locked vault as the recipient',
options: [...options_js_1.writeActionOptions, options_js_1.optionMap.vaultId, options_js_1.optionMap.quantity],
action: transfer_js_1.increaseVaultCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'join-network',
description: 'Join a gateway to the AR.IO network',
options: options_js_1.joinNetworkOptions,
action: gatewayWriteCommands_js_1.joinNetwork,
});
(0, utils_js_1.makeCommand)({
name: 'leave-network',
description: 'Leave a gateway from the AR.IO network',
action: gatewayWriteCommands_js_1.leaveNetwork,
});
(0, utils_js_1.makeCommand)({
name: 'update-gateway-settings',
description: 'Update AR.IO gateway settings',
options: options_js_1.updateGatewaySettingsOptions,
action: gatewayWriteCommands_js_1.updateGatewaySettings,
});
(0, utils_js_1.makeCommand)({
name: 'save-observations',
description: 'Save observations',
options: [
options_js_1.optionMap.failedGateways,
options_js_1.optionMap.transactionId,
...options_js_1.writeActionOptions,
],
action: gatewayWriteCommands_js_1.saveObservations,
});
(0, utils_js_1.makeCommand)({
name: 'increase-operator-stake',
description: 'Increase operator stake',
options: options_js_1.operatorStakeOptions,
action: gatewayWriteCommands_js_1.increaseOperatorStake,
});
(0, utils_js_1.makeCommand)({
name: 'decrease-operator-stake',
description: 'Decrease operator stake',
options: options_js_1.operatorStakeOptions,
action: gatewayWriteCommands_js_1.decreaseOperatorStake,
});
(0, utils_js_1.makeCommand)({
name: 'instant-withdrawal',
description: 'Instantly withdraw stake from an existing gateway withdrawal vault',
options: options_js_1.addressAndVaultIdOptions,
action: gatewayWriteCommands_js_1.instantWithdrawal,
});
(0, utils_js_1.makeCommand)({
name: 'cancel-withdrawal',
description: 'Cancel a pending gateway withdrawal vault',
options: options_js_1.addressAndVaultIdOptions,
action: gatewayWriteCommands_js_1.cancelWithdrawal,
});
(0, utils_js_1.makeCommand)({
name: 'delegate-stake',
description: 'Delegate stake to a gateway',
options: options_js_1.delegateStakeOptions,
action: gatewayWriteCommands_js_1.delegateStake,
});
(0, utils_js_1.makeCommand)({
name: 'decrease-delegate-stake',
description: 'Decrease delegated stake',
options: options_js_1.decreaseDelegateStakeOptions,
action: gatewayWriteCommands_js_1.decreaseDelegateStake,
});
(0, utils_js_1.makeCommand)({
name: 'redelegate-stake',
description: 'Redelegate stake to another gateway',
options: options_js_1.redelegateStakeOptions,
action: gatewayWriteCommands_js_1.redelegateStake,
});
(0, utils_js_1.makeCommand)({
name: 'buy-record',
description: 'Buy a record',
options: options_js_1.buyRecordOptions,
action: arnsPurchaseCommands_js_1.buyRecordCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'upgrade-record',
description: 'Upgrade the lease of a record to a permabuy',
options: options_js_1.arnsPurchaseOptions,
action: arnsPurchaseCommands_js_1.upgradeRecordCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'extend-lease',
description: 'Extend the lease of a record',
options: [...options_js_1.arnsPurchaseOptions, options_js_1.optionMap.years],
action: arnsPurchaseCommands_js_1.extendLeaseCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'increase-undername-limit',
description: 'Increase the limit of a name',
options: [...options_js_1.arnsPurchaseOptions, options_js_1.optionMap.increaseCount],
action: arnsPurchaseCommands_js_1.increaseUndernameLimitCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'request-primary-name',
description: 'Request a primary name',
options: options_js_1.arnsPurchaseOptions,
action: arnsPurchaseCommands_js_1.requestPrimaryNameCLICommand,
});
// # ANTS
// # Getters
(0, utils_js_1.makeCommand)({
name: 'get-ant-state',
description: 'Get the state of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getState();
},
});
(0, utils_js_1.makeCommand)({
name: 'get-ant-info',
description: 'Get the info of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getInfo();
},
});
(0, utils_js_1.makeCommand)({
name: 'get-ant-record',
description: 'Get a record of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.undername],
action: async (options) => {
return ((await (0, utils_js_1.readANTFromOptions)(options).getRecord({
undername: (0, utils_js_1.requiredStringFromOptions)(options, 'undername'),
})) ?? { message: 'No record found' });
},
});
(0, utils_js_1.makeCommand)({
name: 'get-ant-owner',
description: 'Get the owner of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getOwner();
},
});
(0, utils_js_1.makeCommand)({
name: 'get-ant-name',
description: 'Get the name of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getName();
},
});
(0, utils_js_1.makeCommand)({
name: 'get-ant-ticker',
description: 'Get the ticker of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getTicker();
},
});
(0, utils_js_1.makeCommand)({
name: 'get-ant-balance',
description: 'Get the balance of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.address],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getBalance({
address: (0, utils_js_1.requiredAddressFromOptions)(options),
});
},
});
// # Spawn
(0, utils_js_1.makeCommand)({
name: 'spawn-ant',
description: 'Spawn an ANT process',
options: options_js_1.antStateOptions,
action: async (options) => {
const state = (0, utils_js_1.getANTStateFromOptions)(options);
const antProcessId = await (0, index_js_1.spawnANT)({
state,
signer: (0, utils_js_1.requiredAoSignerFromOptions)(options),
logger: (0, utils_js_1.getLoggerFromOptions)(options),
});
return {
processId: antProcessId,
state,
message: `Spawned ANT process with process ID ${antProcessId}`,
};
},
});
// # ANT Paginated Handlers
(0, utils_js_1.makeCommand)({
name: 'list-ant-records',
description: 'Get the records of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getRecords();
},
});
(0, utils_js_1.makeCommand)({
name: 'list-ant-controllers',
description: 'List the controllers of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getControllers();
},
});
(0, utils_js_1.makeCommand)({
name: 'list-ant-balances',
description: 'Get the balances of an ANT process',
options: [options_js_1.optionMap.processId],
action: async (options) => {
return (0, utils_js_1.readANTFromOptions)(options).getBalances();
},
});
// # Actions
(0, utils_js_1.makeCommand)({
name: 'transfer-ant-ownership',
description: 'Transfer ownership of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.target, ...options_js_1.writeActionOptions],
action: async (options) => {
const target = (0, utils_js_1.requiredStringFromOptions)(options, 'target');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to transfer ANT ownership to ${target}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).transfer({
target,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'add-ant-controller',
description: 'Add a controller to an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.controller, ...options_js_1.writeActionOptions],
action: async (options) => {
const controller = (0, utils_js_1.requiredStringFromOptions)(options, 'controller');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to add ${controller} as a controller?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).addController({
controller: (0, utils_js_1.requiredStringFromOptions)(options, 'controller'),
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'remove-ant-controller',
description: 'Remove a controller from an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.controller, ...options_js_1.writeActionOptions],
action: async (options) => {
return (0, utils_js_1.writeANTFromOptions)(options).removeController({
controller: (0, utils_js_1.requiredStringFromOptions)(options, 'controller'),
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'remove-ant-record',
description: 'Remove a record from an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.undername, ...options_js_1.writeActionOptions],
action: async (options) => {
const undername = (0, utils_js_1.requiredStringFromOptions)(options, 'undername');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to remove the record with undername ${undername}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).removeRecord({
undername,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-record',
description: 'Set a record of an ANT process. Deprecated: use set-ant-base-name and set-ant-undername',
options: options_js_1.setAntUndernameOptions,
action: antCommands_js_1.setAntRecordCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-base-name',
description: 'Set the base name of an ANT process',
options: options_js_1.setAntBaseNameOptions,
action: antCommands_js_1.setAntBaseNameCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-undername',
description: 'Set an undername of an ANT process',
options: options_js_1.setAntUndernameOptions,
action: antCommands_js_1.setAntRecordCLICommand,
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-ticker',
description: 'Set the ticker of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.ticker, ...options_js_1.writeActionOptions],
action: async (options) => {
const ticker = (0, utils_js_1.requiredStringFromOptions)(options, 'ticker');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ticker to ${ticker}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).setTicker({
ticker,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-name',
description: 'Set the name of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.name, ...options_js_1.writeActionOptions],
action: async (options) => {
const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the name to ${(0, utils_js_1.requiredStringFromOptions)(options, 'name')}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).setName({
name,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-description',
description: 'Set the description of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.description, ...options_js_1.writeActionOptions],
action: async (options) => {
const description = (0, utils_js_1.requiredStringFromOptions)(options, 'description');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ANT description to ${description}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).setDescription({
description,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-keywords',
description: 'Set the keywords of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.keywords, ...options_js_1.writeActionOptions],
action: async (options) => {
const keywords = (0, utils_js_1.requiredStringArrayFromOptions)(options, 'keywords');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ANT keywords to ${keywords}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).setKeywords({
keywords,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'set-ant-logo',
description: 'Set the logo of an ANT process',
options: [
options_js_1.optionMap.processId,
options_js_1.optionMap.transactionId,
...options_js_1.writeActionOptions,
],
action: async (options) => {
const txId = (0, utils_js_1.requiredStringFromOptions)(options, 'transactionId');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ANT logo to target Arweave TxID ${txId}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).setLogo({
txId,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
// # ARIO Actions
(0, utils_js_1.makeCommand)({
name: 'release-name',
description: 'Release the name of an ANT process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.name, ...options_js_1.writeActionOptions],
action: async (options) => {
const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to release the name ${name} back to the protocol?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).releaseName({
name,
arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'reassign-name',
description: 'Reassign the name of an ANT process to another ANT process',
options: [
options_js_1.optionMap.processId,
options_js_1.optionMap.name,
options_js_1.optionMap.target,
...options_js_1.writeActionOptions,
],
action: async (options) => {
const targetProcess = (0, utils_js_1.requiredStringFromOptions)(options, 'target');
const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to reassign the name ${name} to ANT process ${targetProcess}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).reassignName({
name,
arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
antProcessId: targetProcess,
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'approve-primary-name-request',
description: 'Approve a primary name request',
options: [
options_js_1.optionMap.processId,
options_js_1.optionMap.name,
options_js_1.optionMap.address,
...options_js_1.writeActionOptions,
],
action: async (options) => {
const address = (0, utils_js_1.requiredAddressFromOptions)(options);
const name = (0, utils_js_1.requiredStringFromOptions)(options, 'name');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to approve the primary name request ${name} to ${address}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).approvePrimaryNameRequest({
name,
address,
arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
(0, utils_js_1.makeCommand)({
name: 'remove-primary-names',
description: 'Remove primary names',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.names, ...options_js_1.writeActionOptions],
action: async (options) => {
const names = (0, utils_js_1.requiredStringArrayFromOptions)(options, 'names');
await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to remove the primary names ${names}?`, options);
return (0, utils_js_1.writeANTFromOptions)(options).removePrimaryNames({
names,
arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
}, (0, utils_js_1.customTagsFromOptions)(options));
},
});
// # Utilities
(0, utils_js_1.makeCommand)({
name: 'write-action',
description: 'Send a write action to an AO Process',
options: [...options_js_1.writeActionOptions, options_js_1.optionMap.processId],
action: async (options) => {
const process = new index_js_1.AOProcess({
processId: (0, utils_js_1.requiredProcessIdFromOptions)(options),
logger: (0, utils_js_1.getLoggerFromOptions)(options),
});
return process.send({
tags: (0, utils_js_1.customTagsFromOptions)(options).tags ?? [],
signer: (0, utils_js_1.requiredAoSignerFromOptions)(options),
});
},
});
(0, utils_js_1.makeCommand)({
name: 'read-action',
description: 'Send a dry-run read action to an AO Process',
options: [options_js_1.optionMap.processId, options_js_1.optionMap.tags],
action: async (options) => {
const process = new index_js_1.AOProcess({
processId: (0, utils_js_1.requiredProcessIdFromOptions)(options),
logger: (0, utils_js_1.getLoggerFromOptions)(options),
});
return process.read({
tags: (0, utils_js_1.customTagsFromOptions)(options).tags ?? [],
});
},
});
if (process.argv[1].includes('bin/ar.io') || // Running from global .bin
process.argv[1].includes('cli/cli') // Running from source
) {
commander_1.program.parse(process.argv);
}