Skip to content

Commit

Permalink
feat(mainnet): use mainnet process ID by default
Browse files Browse the repository at this point in the history
BREAKING CHANGE: SDK and CLI will not longer go to AR.IO Testnet by default
  • Loading branch information
fedellen committed Feb 4, 2025
1 parent 9fbb563 commit 9d5f2c5
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 32 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
```typescript
const { id: txId } = await ant.releaseName({
name: 'permalink',
arioProcessId: ARIO_TESTNET_PROCESS_ID, // releases the name owned by the ANT and sends it to recently returned names on the ARIO contract
arioProcessId: ARIO_MAINNET_PROCESS_ID, // releases the name owned by the ANT and sends it to recently returned names on the ARIO contract
});
```

Expand All @@ -2312,7 +2312,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
```typescript
const { id: txId } = await ant.reassignName({
name: 'ardrive',
arioProcessId: ARIO_TESTNET_PROCESS_ID,
arioProcessId: ARIO_MAINNET_PROCESS_ID,
antProcessId: NEW_ANT_PROCESS_ID, // the new ANT process id that will take over ownership of the name
});
```
Expand All @@ -2327,7 +2327,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
const { id: txId } = await ant.approvePrimaryNameRequest({
name: 'arns',
address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3', // must match the request initiator address
arioProcessId: ARIO_TESTNET_PROCESS_ID, // the ARIO process id to use for the request
arioProcessId: ARIO_MAINNET_PROCESS_ID, // the ARIO process id to use for the request
});
```

Expand All @@ -2340,7 +2340,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
```typescript
const { id: txId } = await ant.removePrimaryNames({
names: ['arns', 'test_arns'], // any primary names associated with a base name controlled by this ANT will be removed
arioProcessId: ARIO_TESTNET_PROCESS_ID,
arioProcessId: ARIO_MAINNET_PROCESS_ID,
notifyOwners: true, // if true, the owners of the removed names will be send AO messages to notify them of the removal
});
```
Expand Down
4 changes: 2 additions & 2 deletions examples/cjs/index.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ARIO, Logger, ARIO_TESTNET_PROCESS_ID } = require('@ar.io/sdk');
const { ARIO, Logger, ARIO_MAINNET_PROCESS_ID } = require('@ar.io/sdk');

(async () => {
// set the log level for the SDK
Expand All @@ -8,7 +8,7 @@ const { ARIO, Logger, ARIO_TESTNET_PROCESS_ID } = require('@ar.io/sdk');
// testnet gateways
const testnetGateways = await arIO.getGateways();
const protocolBalance = await arIO.getBalance({
address: ARIO_TESTNET_PROCESS_ID,
address: ARIO_MAINNET_PROCESS_ID,
});
const ardriveRecord = await arIO.getArNSRecord({ name: 'ardrive' });
const partialRecords = await arIO.getArNSRecords({
Expand Down
4 changes: 2 additions & 2 deletions examples/esm/index.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
ANT,
ARIO,
ARIO_TESTNET_PROCESS_ID,
ARIO_MAINNET_PROCESS_ID,
getANTProcessesOwnedByWallet,
} from '@ar.io/sdk';

(async () => {
const arIO = ARIO.init();
const testnetGateways = await arIO.getGateways();
const protocolBalance = await arIO.getBalance({
address: ARIO_TESTNET_PROCESS_ID,
address: ARIO_MAINNET_PROCESS_ID,
});
const contractInfo = await arIO.getInfo();
const ardriveRecord = await arIO.getArNSRecord({ name: 'ardrive' });
Expand Down
12 changes: 9 additions & 3 deletions src/cli/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ export const optionMap = {
alias: '--private-key <key>',
description: 'Stringified private key to use with the action',
},
dev: {
alias: '--dev',
testnet: {
alias: '--testnet',
description: 'Run against the AR.IO testnet process',
type: 'boolean',
},
devnet: {
alias: '--dev, --devnet',
description: 'Run against the AR.IO devnet process',
type: 'boolean',
},
Expand Down Expand Up @@ -271,7 +276,8 @@ export const walletOptions = [

export const globalOptions = [
...walletOptions,
optionMap.dev,
optionMap.devnet,
optionMap.testnet,
optionMap.debug,
optionMap.arioProcessId,
optionMap.cuUrl,
Expand Down
3 changes: 2 additions & 1 deletion src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export type WalletCLIOptions = {
};

export type GlobalCLIOptions = WalletCLIOptions & {
dev: boolean;
devnet: boolean;
testnet: boolean;
debug: boolean;
arioProcessId?: string;
cuUrl?: string;
Expand Down
12 changes: 8 additions & 4 deletions src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ARIO,
ARIOToken,
ARIO_DEVNET_PROCESS_ID,
ARIO_MAINNET_PROCESS_ID,
ARIO_TESTNET_PROCESS_ID,
AoANTRead,
AoANTWrite,
Expand Down Expand Up @@ -149,13 +150,16 @@ export function makeCommand<O extends OptionValues = GlobalCLIOptions>({

export function arioProcessIdFromOptions({
arioProcessId,
dev,
testnet,
devnet,
}: GlobalCLIOptions): string {
return arioProcessId !== undefined
? arioProcessId
: dev
? ARIO_DEVNET_PROCESS_ID
: ARIO_TESTNET_PROCESS_ID;
: testnet
? ARIO_TESTNET_PROCESS_ID
: devnet
? ARIO_DEVNET_PROCESS_ID
: ARIO_MAINNET_PROCESS_ID;
}

function jwkFromOptions({
Expand Down
8 changes: 4 additions & 4 deletions src/common/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* @returns {Promise<AoMessageResult>} The result of the interaction.
* @example
* ```ts
* ant.releaseName({ name: "ardrive", arioProcessId: AR_TESTNET_PROCESS_ID });
* ant.releaseName({ name: "ardrive", arioProcessId: AR_MAINNET_PROCESS_ID });
* ```
*/
async releaseName(
Expand Down Expand Up @@ -670,7 +670,7 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* @returns {Promise<AoMessageResult>} The result of the interaction.
* @example
* ```ts
* ant.reassignName({ name: "ardrive", arioProcessId: ARIO_TESTNET_PROCESS_ID, antProcessId: NEW_ANT_PROCESS_ID });
* ant.reassignName({ name: "ardrive", arioProcessId: ARIO_MAINNET_PROCESS_ID, antProcessId: NEW_ANT_PROCESS_ID });
* ```
*/
async reassignName(
Expand Down Expand Up @@ -703,7 +703,7 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* @returns {Promise<AoMessageResult>} The result of the interaction.
* @example
* ```ts
* ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_TESTNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
* ant.approvePrimaryNameRequest({ name: "ardrive", address: "U7RXcpaVShG4u9nIcPVmm2FJSM5Gru9gQCIiRaIPV7f", arioProcessId: ARIO_MAINNET_PROCESS_ID }); // approves the request for ardrive.ar.io to be registered by the address
* ```
*/
async approvePrimaryNameRequest(
Expand Down Expand Up @@ -736,7 +736,7 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* @returns {Promise<AoMessageResult>} The result of the interaction.
* @example
* ```ts
* ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_TESTNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
* ant.removePrimaryNames({ names: ["ardrive", "dapp_ardrive"], arioProcessId: ARIO_MAINNET_PROCESS_ID, notifyOwners: true }); // removes the primary names and associated wallet addresses assigned to "ardrive" and "dapp_ardrive"
* ```
*/
async removePrimaryNames(
Expand Down
6 changes: 3 additions & 3 deletions src/common/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import Arweave from 'arweave';

import { ARIO_TESTNET_PROCESS_ID } from '../constants.js';
import { ARIO_MAINNET_PROCESS_ID } from '../constants.js';
import {
AoArNSNameDataWithName,
AoArNSReservedNameData,
Expand Down Expand Up @@ -118,7 +118,7 @@ export class ARIOReadable implements AoARIORead {
this.arweave = config?.arweave ?? defaultArweave;
if (config === undefined || Object.keys(config).length === 0) {
this.process = new AOProcess({
processId: ARIO_TESTNET_PROCESS_ID,
processId: ARIO_MAINNET_PROCESS_ID,
});
} else if (isProcessConfiguration(config)) {
this.process = config.process;
Expand Down Expand Up @@ -759,7 +759,7 @@ export class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
if (config === undefined) {
super({
process: new AOProcess({
processId: ARIO_TESTNET_PROCESS_ID,
processId: ARIO_MAINNET_PROCESS_ID,
}),
});
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const arioDevnetProcessId = ARIO_DEVNET_PROCESS_ID;
export const ARIO_TESTNET_PROCESS_ID =
'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';

export const ARIO_MAINNET_PROCESS_ID = 'placeholder'; // TODO: update when mainnet process ID is available

export const ANT_REGISTRY_ID = 'i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc';
export const MARIO_PER_ARIO = 1_000_000;
export const AOS_MODULE_ID = 'acdKHzHAG-RVC06nNVlX3jIXvomfiBnA5NZTEPYOMv8';
Expand Down
8 changes: 4 additions & 4 deletions src/utils/arweave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import Arweave from 'arweave';

import { ARIO_TESTNET_PROCESS_ID, ARWEAVE_TX_REGEX } from '../constants.js';
import { ARIO_MAINNET_PROCESS_ID, ARWEAVE_TX_REGEX } from '../constants.js';
import { BlockHeight } from '../types/common.js';
import { AoEpochData, PaginationParams } from '../types/io.js';
import { parseAoEpochData } from './ao.js';
Expand Down Expand Up @@ -66,7 +66,7 @@ export const paginationParamsToTags = <T>(
export const getEpochDataFromGql = async ({
arweave,
epochIndex,
processId = ARIO_TESTNET_PROCESS_ID,
processId = ARIO_MAINNET_PROCESS_ID,
retries = 3,
}: {
arweave: Arweave;
Expand Down Expand Up @@ -104,12 +104,12 @@ export const getEpochDataFromGql = async ({
* Get the epoch with distribution data for the current epoch
* @param arweave - The Arweave instance
* @param epochIndex - The index of the epoch
* @param processId - The process ID (optional, defaults to ARIO_TESTNET_PROCESS_ID)
* @param processId - The process ID (optional, defaults to ARIO_MAINNET_PROCESS_ID)
* @returns string - The stringified GQL query
*/
export const epochDistributionNoticeGqlQuery = ({
epochIndex,
processId = ARIO_TESTNET_PROCESS_ID,
processId = ARIO_MAINNET_PROCESS_ID,
}: {
epochIndex: number;
processId?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/processes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ANT } from '../common/ant.js';
import { AOProcess } from '../common/index.js';
import { ARIO } from '../common/io.js';
import { ILogger, Logger } from '../common/logger.js';
import { ARIO_TESTNET_PROCESS_ID } from '../constants.js';
import { ARIO_MAINNET_PROCESS_ID } from '../constants.js';
import { AoANTRegistryRead } from '../types/ant-registry.js';
import { AoANTState } from '../types/ant.js';
import {
Expand Down Expand Up @@ -74,7 +74,7 @@ export class ArNSEventEmitter extends EventEmitter {
private antAoClient: AoClient;
constructor({
contract = ARIO.init({
processId: ARIO_TESTNET_PROCESS_ID,
processId: ARIO_MAINNET_PROCESS_ID,
}),
timeoutMs = 60_000,
concurrency = 30,
Expand Down Expand Up @@ -192,7 +192,7 @@ export class ArNSEventEmitter extends EventEmitter {

export const fetchAllArNSRecords = async ({
contract = ARIO.init({
processId: ARIO_TESTNET_PROCESS_ID,
processId: ARIO_MAINNET_PROCESS_ID,
}),
emitter,
logger = Logger.default,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/esm/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ARIO,
ARIOReadable,
ARIOWriteable,
ARIO_TESTNET_PROCESS_ID,
ARIO_MAINNET_PROCESS_ID,
AoANTReadable,
AoANTRegistryWriteable,
AoANTWriteable,
Expand Down Expand Up @@ -50,7 +50,7 @@ const ario = ARIO.init({
});

// epochs with known distribution data notices
const epochIndex = processId === ARIO_TESTNET_PROCESS_ID ? 189 : 200;
const epochIndex = processId === ARIO_MAINNET_PROCESS_ID ? 189 : 200;

describe('e2e esm tests', async () => {
let compose;
Expand Down

0 comments on commit 9d5f2c5

Please sign in to comment.