Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat(ao): allow AO env variables to point process evaluation against …
Browse files Browse the repository at this point in the history
…specific AO infrastrucutre

The defaults are reccomended, but this gives operators the ability to point the resolvers dryRuns to specific AO infrastructure. Useful for testing and if you are running any part of an AO stack yourself to avoid rate-limiting/network issues.
  • Loading branch information
dtfiedler committed Jul 16, 2024
1 parent 46dbd29 commit 4e949a5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"url": "https://github.com/ar-io/arns-resolver"
},
"dependencies": {
"@ar.io/sdk": "^2.0.0",
"@ar.io/sdk": "^2.0.2",
"@permaweb/aoconnect": "^0.0.56",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ export const ARNS_CACHE_PATH = env.varOrDefault(
'./data/arns',
);
export const PORT = +env.varOrDefault('PORT', '6000');

// AO

export const AO_MU_URL = env.varOrUndefined('AO_MU_URL');
export const AO_CU_URL = env.varOrUndefined('AO_CU_URL');
export const AO_GRAPHQL_URL = env.varOrUndefined('AO_GRAPHQL_URL');
export const AO_GATEWAY_URL = env.varOrUndefined('AO_GATEWAY_URL');
13 changes: 12 additions & 1 deletion src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import {
ANT,
ANTRecord,
AOProcess,
AoIORead,
IO,
ProcessId,
fetchAllArNSRecords,
isLeasedArNSRecord,
} from '@ar.io/sdk/node';
import { connect } from '@permaweb/aoconnect';
import pLimit from 'p-limit';

import { LmdbKVStore } from './cache/lmdb-kv-store.js';
Expand All @@ -36,7 +38,16 @@ let evaluationInProgress = false;
export const getLastEvaluatedTimestamp = () => lastEvaluationTimestamp;
export const isEvaluationInProgress = () => evaluationInProgress;
export const contract: AoIORead = IO.init({
processId: config.IO_PROCESS_ID,
process: new AOProcess({
processId: config.IO_PROCESS_ID,
ao: connect({
// @permaweb/aoconnect defaults will be used if these are not provided
MU_URL: config.AO_CU_URL,
CU_URL: config.AO_CU_URL,
GRAPHQL_URL: config.AO_GATEWAY_URL,
GATEWAY_URL: config.AO_GATEWAY_URL,
}),
}),
});

// TODO: this could be done using any KV store - or in memory. For now, we are using LMDB for persistence.
Expand Down
22 changes: 18 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
call-me-maybe "^1.0.1"
js-yaml "^4.1.0"

"@ar.io/sdk@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-2.0.0.tgz#8725d1ece71b19dd7bfe44e846190bd458164206"
integrity sha512-at40lht1K6BOegoHoTezgL3z8y+Wj3VTEHMjNcoAywAV4R5l69xOTkJqEDL1uyLahspmxYGgX7rf50XFaVxMOw==
"@ar.io/sdk@^2.0.2":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-2.0.2.tgz#64aa7c4e6b30bbe36d7cc7d450f32d100ee731b3"
integrity sha512-DGSHo9Bf90Pe2m4lBEJPFuUageAaoO+nA42nhGJ2vCn6dKVM/y3aSqCJ+H5enHjidx0H1MmsgysiBQGEBElMHg==
dependencies:
"@permaweb/aoconnect" "^0.0.55"
arbundles "0.11.0"
Expand Down Expand Up @@ -1298,6 +1298,20 @@
warp-arbundles "^1.0.4"
zod "^3.22.4"

"@permaweb/aoconnect@^0.0.56":
version "0.0.56"
resolved "https://registry.yarnpkg.com/@permaweb/aoconnect/-/aoconnect-0.0.56.tgz#28dcf1a094a2b1c1cbaa246d63eeb08a5a0c7269"
integrity sha512-Eu4AC1KeX2EOIS9ihWkwPJs7rK+/+XV43QwOJ9DCQAu6EhjanlT3UfV2wSpGiFK/dT/B1YsQyTcxNrmQaXn81g==
dependencies:
"@permaweb/ao-scheduler-utils" "~0.0.16"
buffer "^6.0.3"
debug "^4.3.4"
hyper-async "^1.1.2"
mnemonist "^0.39.8"
ramda "^0.29.1"
warp-arbundles "^1.0.4"
zod "^3.22.4"

"@randlabs/[email protected]":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@randlabs/communication-bridge/-/communication-bridge-1.0.1.tgz#d1ecfc29157afcbb0ca2d73122d67905eecb5bf3"
Expand Down

0 comments on commit 4e949a5

Please sign in to comment.