Skip to content

Commit

Permalink
feat(io): use ao/io contract for fetching peer data sources
Browse files Browse the repository at this point in the history
The SDK supports a new implementation of the same interfaces using the AO/IO contract.
  • Loading branch information
dtfiedler authored and djwhitt committed Jun 7, 2024
1 parent db73c69 commit 25557eb
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "https://github.com/ar-io/ar-io-node"
},
"dependencies": {
"@ar.io/sdk": "^1.0.7",
"@ar.io/sdk": "1.2.0-alpha.1",
"@aws-lite/client": "^0.21.7",
"@aws-lite/s3": "^0.1.21",
"apollo-server-express": "^3.13.0",
Expand Down
5 changes: 5 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export const CONTRACT_ID = env.varOrDefault(
'bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U',
);

export const IO_PROCESS_ID = env.varOrDefault(
'IO_PROCESS_ID',
'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc',
);

//
// Header caching
//
Expand Down
6 changes: 3 additions & 3 deletions src/data/ar-io-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
import { default as axios, AxiosResponse } from 'axios';
import winston from 'winston';
import { ArIOReadable } from '@ar.io/sdk';
import { AoIORead } from '@ar.io/sdk';
import { randomInt } from 'node:crypto';

import {
Expand All @@ -38,7 +38,7 @@ export class ArIODataSource implements ContiguousDataSource {
private requestTimeoutMs: number;
private updatePeersRefreshIntervalMs: number;

private arIO: ArIOReadable;
private arIO: AoIORead;
peers: Record<string, string> = {};
private intervalId?: NodeJS.Timeout;

Expand All @@ -51,7 +51,7 @@ export class ArIODataSource implements ContiguousDataSource {
updatePeersRefreshIntervalMs = DEFAULT_UPDATE_PEERS_REFRESH_INTERVAL_MS,
}: {
log: winston.Logger;
arIO: ArIOReadable;
arIO: AoIORead;
nodeWallet?: string;
maxHopsAllowed?: number;
requestTimeoutMs?: number;
Expand Down
4 changes: 2 additions & 2 deletions src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { default as Arweave } from 'arweave';
import EventEmitter from 'node:events';
import { Server } from 'node:http';
import fs from 'node:fs';
import { ArIO } from '@ar.io/sdk';
import { IO } from '@ar.io/sdk';
import awsLite from '@aws-lite/client';
import awsLiteS3 from '@aws-lite/s3';

Expand Down Expand Up @@ -79,7 +79,7 @@ process.on('uncaughtException', (error) => {
});

const arweave = Arweave.init({});
const arIO = ArIO.init({ contractTxId: config.CONTRACT_ID });
const arIO = IO.init({ processId: config.IO_PROCESS_ID });
const awsClient =
config.AWS_ACCESS_KEY_ID !== undefined &&
config.AWS_SECRET_ACCESS_KEY !== undefined &&
Expand Down
137 changes: 96 additions & 41 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,17 @@
dependencies:
xss "^1.0.8"

"@ar.io/sdk@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-1.0.7.tgz#8e00d707aaff5ef51165978892f59bdd7730ec7c"
integrity sha512-8wjIWBU6r3amKhO3oMdYXYIE+wian1LX0ozzll6mHlzw27ARa4qETGMEkNm+bkLPcYXgkntNG9C/zL9Srhg7sA==
"@ar.io/sdk@1.2.0-alpha.1":
version "1.2.0-alpha.1"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-1.2.0-alpha.1.tgz#16891e85feab3b4197191c4100272225bf866f34"
integrity sha512-4C4JBo6GuaqEm4FnRvJ6n9z4dYA2g++duDRiErsRnOeqmt0ZpuHA4p3vucMBT5d6Bp3nrgckPx+estxRGUqDzg==
dependencies:
"@permaweb/aoconnect" "^0.0.55"
arbundles "0.11.0"
arweave "1.15.1"
axios "1.4.0"
arweave "1.14.4"
axios "1.7.2"
axios-retry "^4.3.0"
bunyan "^1.8.15"
warp-arbundles "^1.0.4"
warp-contracts "1.4.45"

"@aws-crypto/[email protected]":
Expand Down Expand Up @@ -1935,6 +1936,29 @@
read-package-json-fast "^3.0.0"
which "^3.0.0"

"@permaweb/ao-scheduler-utils@~0.0.16":
version "0.0.19"
resolved "https://registry.yarnpkg.com/@permaweb/ao-scheduler-utils/-/ao-scheduler-utils-0.0.19.tgz#69d35c19583624ace3f500f53b4b4d73fca883e1"
integrity sha512-xwIe9FqQ1UZxEYWvSGJDONz0xr4vDq2Ny1NeRUiO0dKYoonShN+oI1ULgrHocKOjOPNEgRX70vMCKGLe+3x70A==
dependencies:
lru-cache "^10.2.2"
ramda "^0.30.0"
zod "^3.23.5"

"@permaweb/aoconnect@^0.0.55":
version "0.0.55"
resolved "https://registry.yarnpkg.com/@permaweb/aoconnect/-/aoconnect-0.0.55.tgz#d856a078d3702154ac58541d09478d25ed3acf2c"
integrity sha512-W2GtLZedVseuDkCKk4CmM9SFmi0DdrMKqvhMBm9xo65z+Mzr/t1TEjMJKRNzEA2qh5IdwM43sWJ5fmbBYLg6TQ==
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"

"@pkgjs/parseargs@^0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
Expand Down Expand Up @@ -3588,16 +3612,6 @@ [email protected], arweave@^1.14.4:
base64-js "^1.5.1"
bignumber.js "^9.0.2"

[email protected], arweave@^1.13.7:
version "1.15.1"
resolved "https://registry.yarnpkg.com/arweave/-/arweave-1.15.1.tgz#c6183136b20980c81a8cb77ce6fd9fb333e1a174"
integrity sha512-rT7FOwqdudd5npqp4xOYdDT2035LtpcqePjwirh4wjRiEtVsz1FZkRiM2Yj+fOAwYzOm/hNG0GDOipDSaiEGGQ==
dependencies:
arconnect "^0.4.2"
asn1.js "^5.4.1"
base64-js "^1.5.1"
bignumber.js "^9.0.2"

arweave@^1.10.13, arweave@^1.11.4:
version "1.11.4"
resolved "https://registry.npmjs.org/arweave/-/arweave-1.11.4.tgz"
Expand All @@ -3610,6 +3624,16 @@ arweave@^1.10.13, arweave@^1.11.4:
bignumber.js "^9.0.2"
util "^0.12.4"

arweave@^1.13.7:
version "1.15.1"
resolved "https://registry.yarnpkg.com/arweave/-/arweave-1.15.1.tgz#c6183136b20980c81a8cb77ce6fd9fb333e1a174"
integrity sha512-rT7FOwqdudd5npqp4xOYdDT2035LtpcqePjwirh4wjRiEtVsz1FZkRiM2Yj+fOAwYzOm/hNG0GDOipDSaiEGGQ==
dependencies:
arconnect "^0.4.2"
asn1.js "^5.4.1"
base64-js "^1.5.1"
bignumber.js "^9.0.2"

asap@^2.0.0:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
Expand Down Expand Up @@ -3680,12 +3704,19 @@ aws4@^1.13.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.13.0.tgz#d9b802e9bb9c248d7be5f7f5ef178dc3684e9dcc"
integrity sha512-3AungXC4I8kKsS9PuS4JH2nc+0bVY/mjgrephHTIi8fpEeGsTHBUJeosp0Wc1myYMElmD0B3Oc4XL/HVJ4PV2g==

axios@1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==
axios-retry@^4.3.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/axios-retry/-/axios-retry-4.4.0.tgz#2df4b9647652e3a4032891001d97bb493607e4aa"
integrity sha512-yewTKjzl6jSgc+2M7FCJ3LxRGgL1iiXHcj+E6h6xie6H1mTHr7yqaUroWIvVXG1UKSPwGDXxV05YxtGvrD6Paw==
dependencies:
follow-redirects "^1.15.0"
is-retry-allowed "^2.2.0"

[email protected], axios@^1.4.0:
version "1.7.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621"
integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

Expand All @@ -3704,15 +3735,6 @@ axios@^0.27.2:
follow-redirects "^1.14.9"
form-data "^4.0.0"

axios@^1.4.0:
version "1.7.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621"
integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2"
Expand Down Expand Up @@ -6068,6 +6090,11 @@ humanize-ms@^1.2.1:
dependencies:
ms "^2.0.0"

hyper-async@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/hyper-async/-/hyper-async-1.1.2.tgz#b9a83be36e726bface6f4a5b84f1a1a25bf19e6a"
integrity sha512-cnpOgKa+5FZOaccTtjduac1FrZuSc38/ftCp3vYJdUMt+7c+uvGDKLDK4MTNK8D3aFjIeveVrPcSgUPvzZLopg==

[email protected]:
version "0.4.24"
resolved "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz"
Expand Down Expand Up @@ -6385,6 +6412,11 @@ is-regex@^1.1.4:
call-bind "^1.0.2"
has-tostringtag "^1.0.0"

is-retry-allowed@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz#88f34cbd236e043e71b6932d09b0c65fb7b4d71d"
integrity sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==

is-shared-array-buffer@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz"
Expand Down Expand Up @@ -6897,6 +6929,11 @@ lowercase-keys@^3.0.0:
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-3.0.0.tgz#c5e7d442e37ead247ae9db117a9d0a467c89d4f2"
integrity sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==

lru-cache@^10.2.2:
version "10.2.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878"
integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz"
Expand Down Expand Up @@ -7228,6 +7265,13 @@ mkdirp@^1.0.3, mkdirp@^1.0.4:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mnemonist@^0.39.8:
version "0.39.8"
resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.39.8.tgz#9078cd8386081afd986cca34b52b5d84ea7a4d38"
integrity sha512-vyWo2K3fjrUw8YeeZ1zF0fy6Mu59RHokURlld8ymdUPjMlD9EC9ov1/YPqTgqRvUN9nTr3Gqfz29LYAmu0PHPQ==
dependencies:
obliterator "^2.0.1"

module-error@^1.0.1, module-error@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/module-error/-/module-error-1.0.2.tgz#8d1a48897ca883f47a45816d4fb3e3c6ba404d86"
Expand Down Expand Up @@ -7660,6 +7704,11 @@ object.assign@^4.1.2:
has-symbols "^1.0.1"
object-keys "^1.1.1"

obliterator@^2.0.1:
version "2.0.4"
resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.4.tgz#fa650e019b2d075d745e44f1effeb13a2adbe816"
integrity sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ==

[email protected]:
version "2.4.1"
resolved "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz"
Expand Down Expand Up @@ -8156,6 +8205,16 @@ ramda@^0.28.0:
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.28.0.tgz#acd785690100337e8b063cab3470019be427cc97"
integrity sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA==

ramda@^0.29.1:
version "0.29.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.29.1.tgz#408a6165b9555b7ba2fc62555804b6c5a2eca196"
integrity sha512-OfxIeWzd4xdUNxlWhgFazxsA/nl3mS4/jGZI5n00uWOoSSFRhC1b6gl6xvmzUamgmqELraWp0J/qqVlXYPDPyA==

ramda@^0.30.0:
version "0.30.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.30.1.tgz#7108ac95673062b060025052cd5143ae8fc605bf"
integrity sha512-tEF5I22zJnuclswcZMc8bDIrwRHRzf+NqVEmqg50ShAZMP7MWeR/RGDthfM/p+BlqvF2fXAzpn8i+SJcYD3alw==

range-parser@^1.2.1, range-parser@~1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz"
Expand Down Expand Up @@ -8913,16 +8972,7 @@ string-argv@~0.3.1:
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"
integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -10071,3 +10121,8 @@ zip-stream@^4.1.0:
archiver-utils "^3.0.4"
compress-commons "^4.1.2"
readable-stream "^3.6.0"

zod@^3.22.4, zod@^3.23.5:
version "3.23.8"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d"
integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==

0 comments on commit 25557eb

Please sign in to comment.