Skip to content

Commit

Permalink
Merge pull request #154 from ar-io/PE-6314-evolve-ant
Browse files Browse the repository at this point in the history
feat(PE-6314): add evolve util
  • Loading branch information
dtfiedler authored Jul 16, 2024
2 parents e6b7b8a + b72dc1f commit 6b33775
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
7 changes: 0 additions & 7 deletions examples/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ const { IO, ioDevnetProcessId, Logger } = require('@ar.io/sdk');
address: ioDevnetProcessId,
});
const ardriveRecord = await arIO.getArNSRecord({ name: 'ardrive' });
const partialRecords = await arIO
.getArNSRecords({
page: 10,
pageSize: 5,
})
.then((page) => page.items);
const oldEpoch = await arIO.getEpoch({
epochIndex: 0,
});
Expand All @@ -29,7 +23,6 @@ const { IO, ioDevnetProcessId, Logger } = require('@ar.io/sdk');
{
testnetGateways,
ardriveRecord,
partialRecords,
protocolBalance,
arnsStats: {
'registered domains': Object.keys(allRecords).length,
Expand Down
2 changes: 2 additions & 0 deletions src/common/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ export class AoANTReadable implements AoANTRead {
Ticker: string;
Denomination: number;
Owner: string;
['Source-Code-TX-ID']?: string;
}> {
const tags = [{ name: 'Action', value: 'Info' }];
const info = await this.process.read<{
Name: string;
Ticker: string;
Denomination: number;
Owner: string;
['Source-Code-TX-ID']?: string;
}>({
tags,
});
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export const IO_TESTNET_PROCESS_ID =
'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA';
export const MIO_PER_IO = 1_000_000;
export const AOS_MODULE_ID = 'cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk';
export const ANT_LUA_ID = '3OlGzE5mrsN2GsxCYM0Tae1KzWepGOr5a94deOWmApM';
export const ANT_LUA_ID = 'Flwio4Lr08g6s6uim6lEJNnVGD9ylvz0_aafvpiL8FI';
export const DEFAULT_SCHEDULER_ID =
'_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA';
1 change: 1 addition & 0 deletions src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export interface AoANTRead {
Ticker: string;
Denomination: number;
Owner: string;
['Source-Code-TX-ID']?: string;
}>;
getRecord({ undername }): Promise<ANTRecord | undefined>;
getRecords(): Promise<Record<string, ANTRecord>>;
Expand Down
35 changes: 35 additions & 0 deletions src/utils/ao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,38 @@ export async function spawnANT({

return processId;
}

export async function evolveANT({
signer,
processId,
luaCodeTxId = ANT_LUA_ID,
ao = connect(),
}: {
signer: ContractSigner;
processId: string;
luaCodeTxId?: string;
ao?: AoClient;
}): Promise<string> {
const aosClient = new AOProcess({
processId,
ao,
});

//TODO: cache locally and only fetch if not cached
const luaString = (await defaultArweave.transactions.getData(luaCodeTxId, {
decode: true,
string: true,
})) as string;

const { id } = await aosClient.send({
tags: [
{ name: 'Action', value: 'Eval' },
{ name: 'App-Name', value: 'ArNS-ANT' },
{ name: 'Source-Code-TX-ID', value: luaCodeTxId },
],
data: luaString,
signer,
});

return id;
}

0 comments on commit 6b33775

Please sign in to comment.