Skip to content

Commit

Permalink
feat(ario): add new APIs to ario class, update ant removePrimaryNames…
Browse files Browse the repository at this point in the history
… tags
  • Loading branch information
dtfiedler committed Jan 7, 2025
1 parent 96991e8 commit 61e0ee8
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"MD033": {
"allowed_elements": ["details", "summary"]
}
}
},
"cSpell.words": ["redelegate", "redelegating"]
}
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
- [`releaseName({ name, arioProcessId })`](#releasename-name-arioprocessid-)
- [`reassignName({ name, arioProcessId, antProcessId })`](#reassignname-name-arioprocessid-antprocessid-)
- [`approvePrimaryNameRequest({ name, address, arioProcessId })`](#approveprimarynamerequest-name-address-arioprocessid-)
- [`removePrimaryNames({ names, arioProcessId })`](#removeprimarynames-names-arioprocessid-)
- [`removePrimaryNames({ names, arioProcessId, notifyOwners })`](#removeprimarynames-names-arioprocessid-notifyowners-)
- [Configuration](#configuration-1)
- [Logging](#logging)
- [Configuration](#configuration-2)
- [Pagination](#pagination)
- [Resources](#resources)
- [Bundling](#bundling)
- [Gateways](#gateways-1)
- [AR.IO Gateways](#ario-gateways)
- [Running a Gateway](#running-a-gateway)
- [AO](#ao)
- [Developers](#developers)
Expand Down Expand Up @@ -2089,7 +2088,7 @@ const { id: txId } = await ant.approvePrimaryNameRequest({
});
```

#### `removePrimaryNames({ names, arioProcessId })`
#### `removePrimaryNames({ names, arioProcessId, notifyOwners })`

Removes primary names from the ANT process.

Expand All @@ -2099,6 +2098,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
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,
notifyOwners: true, // if true, the owners of the removed names will be send AO messages to notify them of the removal
});
```

Expand All @@ -2125,8 +2125,6 @@ const ant = ANT.init({

The library uses the [Winston] logger for node based projects, and `console` logger for web based projects by default. You can configure the log level via `setLogLevel()` API. Alternatively you can set a custom logger as the default logger so long as it satisfes the `ILogger` interface.

### Configuration

```typescript
import { Logger } from '@ar.io/sdk';

Expand Down Expand Up @@ -2170,7 +2168,7 @@ while (hasMore) {

For [ANS-104] bundling compatible with ar.io gateways, we recommend using [turbo-sdk](https://github.com/ardriveapp/turbo-sdk). Turbo SDK provides efficient and reliable methods for creating and uploading data bundles to the Arweave network, which are fully compatible with ar.io gateways. Turbo supports fiat and crypto bundling and uploading with a focus on ease of use and reliability.

### Gateways
### AR.IO Gateways

### Running a Gateway

Expand Down
7 changes: 6 additions & 1 deletion src/common/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,11 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
}

async removePrimaryNames(
{ names, arioProcessId }: { names: string[]; arioProcessId: string },
{
names,
arioProcessId,
notifyOwners = false,
}: { names: string[]; arioProcessId: string; notifyOwners?: boolean },
options?: WriteOptions,
): Promise<AoMessageResult> {
return this.process.send({
Expand All @@ -657,6 +661,7 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
{ name: 'Names', value: names.join(',') },
{ name: 'IO-Process-Id', value: arioProcessId },
{ name: 'ARIO-Process-Id', value: arioProcessId },
{ name: 'Notify-Owners', value: notifyOwners.toString() },
],
signer: this.signer,
});
Expand Down
21 changes: 19 additions & 2 deletions src/common/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,14 +993,22 @@ export class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
});
}

// @deprecated - use `buyArNSName` instead
async buyRecord(
params: AoBuyRecordParams,
options?: WriteOptions,
): Promise<AoMessageResult> {
return this.buyArNSName(params, options);
}

async buyArNSName(
params: AoBuyRecordParams,
options?: WriteOptions,
): Promise<AoMessageResult> {
const { tags = [] } = options || {};
const allTags = [
...tags,
{ name: 'Action', value: 'Buy-Record' },
{ name: 'Action', value: 'Buy-Name' },
{ name: 'Name', value: params.name },
{ name: 'Years', value: params.years?.toString() ?? '1' },
{ name: 'Process-Id', value: params.processId },
Expand All @@ -1022,7 +1030,8 @@ export class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
* @param {Object} [options] - The options for the upgrade
* @returns {Promise<AoMessageResult>} The result of the upgrade
*/
async upgradeRecord(

async upgradeArNSName(
params: AoArNSPurchaseParams,
options?: WriteOptions,
): Promise<AoMessageResult> {
Expand All @@ -1039,6 +1048,14 @@ export class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
});
}

// @deprecated - use `upgradeArNSName` instead
async upgradeRecord(
params: AoArNSPurchaseParams,
options?: WriteOptions,
): Promise<AoMessageResult> {
return this.upgradeArNSName(params, options);
}

/**
* Extends the lease of an existing leased record.
*
Expand Down
6 changes: 5 additions & 1 deletion src/types/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ export interface AoANTWrite extends AoANTRead {
options?: WriteOptions,
): Promise<AoMessageResult>;
removePrimaryNames(
{ names, arioProcessId }: { names: string[]; arioProcessId: string },
{
names,
arioProcessId,
notifyOwners,
}: { names: string[]; arioProcessId: string; notifyOwners?: boolean },
options?: WriteOptions,
): Promise<AoMessageResult>;
}
10 changes: 10 additions & 0 deletions src/types/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,24 @@ export interface AoARIOWrite extends AoARIORead {
options?: WriteOptions,
): Promise<AoMessageResult>;
// END OF GATEWAY SPECIFIC INTERACTIONS
// @deprecated - use `buyArNSName` instead
buyRecord(
params: AoBuyRecordParams,
options?: WriteOptions,
): Promise<AoMessageResult>;
buyArNSName(
params: AoArNSPurchaseParams,
options?: WriteOptions,
): Promise<AoMessageResult>;
// @deprecated - use `upgradeArNSName` instead
upgradeRecord(
params: AoArNSPurchaseParams,
options?: WriteOptions,
): Promise<AoMessageResult>;
upgradeArNSName(
params: AoArNSPurchaseParams,
options?: WriteOptions,
): Promise<AoMessageResult>;
extendLease(
params: AoExtendLeaseParams,
options?: WriteOptions,
Expand Down

0 comments on commit 61e0ee8

Please sign in to comment.