Skip to content

Commit

Permalink
fix(ant): allow sending tags on ant write interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Sep 26, 2024
1 parent 56dbc05 commit 99c24f8
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 49 deletions.
83 changes: 56 additions & 27 deletions src/common/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ProcessConfiguration,
WalletAddress,
WithSigner,
WriteOptions,
isProcessConfiguration,
isProcessIdConfiguration,
} from '../types.js';
Expand Down Expand Up @@ -245,8 +246,12 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
* ```
*/
async transfer({ target }: { target: string }): Promise<AoMessageResult> {
async transfer(
{ target }: { target: string },
options?: WriteOptions,
): Promise<AoMessageResult> {
const tags = [
...(options?.tags ?? []),
{ name: 'Action', value: 'Transfer' },
{ name: 'Recipient', value: target },
];
Expand All @@ -265,12 +270,16 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
* ```
*/
async addController({
controller,
}: {
controller: string;
}): Promise<AoMessageResult> {
async addController(
{
controller,
}: {
controller: string;
},
options?: WriteOptions,
): Promise<AoMessageResult> {
const tags = [
...(options?.tags ?? []),
{ name: 'Action', value: 'Add-Controller' },
{ name: 'Controller', value: controller },
];
Expand All @@ -289,12 +298,16 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
* ```
*/
async removeController({
controller,
}: {
controller: string;
}): Promise<AoMessageResult> {
async removeController(
{
controller,
}: {
controller: string;
},
options?: WriteOptions,
): Promise<AoMessageResult> {
const tags = [
...(options?.tags ?? []),
{ name: 'Action', value: 'Remove-Controller' },
{ name: 'Controller', value: controller },
];
Expand All @@ -315,17 +328,21 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
* ```
*/
async setRecord({
undername,
transactionId,
ttlSeconds,
}: {
undername: string;
transactionId: string;
ttlSeconds: number;
}): Promise<AoMessageResult> {
async setRecord(
{
undername,
transactionId,
ttlSeconds,
}: {
undername: string;
transactionId: string;
ttlSeconds: number;
},
options?: WriteOptions,
): Promise<AoMessageResult> {
return this.process.send({
tags: [
...(options?.tags ?? []),
{ name: 'Action', value: 'Set-Record' },
{ name: 'Sub-Domain', value: undername },
{ name: 'Transaction-Id', value: transactionId },
Expand All @@ -343,13 +360,17 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* ant.removeRecord({ subDomain: "shorts" });
* ```
*/
async removeRecord({
undername,
}: {
undername: string;
}): Promise<AoMessageResult> {
async removeRecord(
{
undername,
}: {
undername: string;
},
options?: WriteOptions,
): Promise<AoMessageResult> {
return this.process.send({
tags: [
...(options?.tags ?? []),
{ name: 'Action', value: 'Remove-Record' },
{ name: 'Sub-Domain', value: undername },
],
Expand All @@ -365,9 +386,13 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* ant.setTicker({ ticker: "KAPOW" });
* ```
*/
async setTicker({ ticker }: { ticker: string }): Promise<AoMessageResult> {
async setTicker(
{ ticker }: { ticker: string },
options?: WriteOptions,
): Promise<AoMessageResult> {
return this.process.send({
tags: [
...(options?.tags ?? []),
{ name: 'Action', value: 'Set-Ticker' },
{ name: 'Ticker', value: ticker },
],
Expand All @@ -382,9 +407,13 @@ export class AoANTWriteable extends AoANTReadable implements AoANTWrite {
* ant.setName({ name: "ships at sea" });
* ```
*/
async setName({ name }: { name: string }): Promise<AoMessageResult> {
async setName(
{ name }: { name: string },
options?: WriteOptions,
): Promise<AoMessageResult> {
return this.process.send({
tags: [
...(options?.tags ?? []),
{ name: 'Action', value: 'Set-Name' },
{ name: 'Name', value: name },
],
Expand Down
56 changes: 34 additions & 22 deletions src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,28 +466,40 @@ export interface AoANTRead {

export interface AoANTWrite extends AoANTRead {
transfer({ target }: { target: WalletAddress }): Promise<AoMessageResult>;
addController({
controller,
}: {
controller: WalletAddress;
}): Promise<AoMessageResult>;
removeController({
controller,
}: {
controller: WalletAddress;
}): Promise<AoMessageResult>;
setRecord({
undername,
transactionId,
ttlSeconds,
}: {
undername: string;
transactionId: string;
ttlSeconds: number;
}): Promise<AoMessageResult>;
removeRecord({ undername }: { undername: string }): Promise<AoMessageResult>;
setTicker({ ticker }): Promise<AoMessageResult>;
setName({ name }): Promise<AoMessageResult>;
addController(
{
controller,
}: {
controller: WalletAddress;
},
options?: WriteOptions,
): Promise<AoMessageResult>;
removeController(
{
controller,
}: {
controller: WalletAddress;
},
options?: WriteOptions,
): Promise<AoMessageResult>;
setRecord(
{
undername,
transactionId,
ttlSeconds,
}: {
undername: string;
transactionId: string;
ttlSeconds: number;
},
options,
): Promise<AoMessageResult>;
removeRecord(
{ undername }: { undername: string },
options,
): Promise<AoMessageResult>;
setTicker({ ticker }, options): Promise<AoMessageResult>;
setName({ name }, options): Promise<AoMessageResult>;
}

export interface AoANTRegistryRead {
Expand Down

0 comments on commit 99c24f8

Please sign in to comment.