Skip to content

Commit

Permalink
chore: update ar.io/sdk to 2.0.0.alpha.10 and use paginated call for …
Browse files Browse the repository at this point in the history
…gateways
  • Loading branch information
kunstmusik committed Jul 11, 2024
1 parent 32b4bd4 commit d6b6a85
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"deploy": "yarn build && permaweb-deploy --ant-process ${DEPLOY_ANT_PROCESS_ID}"
},
"dependencies": {
"@ar.io/sdk": "2.0.0-alpha.7",
"@ar.io/sdk": "2.0.0-alpha.10",
"@fontsource/rubik": "^5.0.19",
"@headlessui/react": "^1.7.19",
"@radix-ui/react-tooltip": "^1.0.7",
Expand Down
20 changes: 19 additions & 1 deletion src/hooks/useGateways.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import { AoGateway, AoIORead } from '@ar.io/sdk';
import { useGlobalState } from '@src/store';
import { useQuery } from '@tanstack/react-query';

const useGateways = () => {
const arIOReadSDK = useGlobalState((state) => state.arIOReadSDK);

const fetchAllGateways = async (
arIOReadSDK: AoIORead,
): Promise<Record<string, AoGateway>> => {
let cursor: string | undefined;
const gateways: Record<string, AoGateway> = {};

do {
const pageResult = await arIOReadSDK.getGateways({ cursor });
pageResult.items.forEach((gateway) => {
gateways[gateway.gatewayAddress] = gateway;
});
cursor = pageResult.nextCursor;
} while (cursor !== undefined);

return gateways;
};

const queryResults = useQuery({
queryKey: ['gateways'],
queryFn: () => {
if (arIOReadSDK) {
return arIOReadSDK.getGateways();
return fetchAllGateways(arIOReadSDK);
}
},
});
Expand Down
39 changes: 7 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
plimit-lit "^3.0.1"
warp-contracts "1.4.45"

"@ar.io/[email protected].7":
version "2.0.0-alpha.7"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-2.0.0-alpha.7.tgz#19123063799ae5a7193b1adc721e9ee61f905ba5"
integrity sha512-mq7hCIiQVpvAyHRfJMmyumXiLDUkYB3M+OCQXGf0HU1aZTCaAIcNQIpMaSrPdq5soQktDxQfF4b1eij7CNgdIw==
"@ar.io/[email protected].10":
version "2.0.0-alpha.10"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-2.0.0-alpha.10.tgz#09ab709064fe552f0af0c566bd0ee8304489594f"
integrity sha512-33tenbU1yz6R4WtuMXcnixKEVoi/E7f+AWxiVcWaNKKC0YpKq0AvTvVI6OsoehgnP5NGyi80GbMA4fZ6NTJH4w==
dependencies:
"@permaweb/aoconnect" "^0.0.55"
arbundles "0.11.0"
Expand Down Expand Up @@ -9881,16 +9881,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"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@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, 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 @@ -9977,14 +9968,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -10870,7 +10854,7 @@ word-wrap@^1.2.5:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -10888,15 +10872,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit d6b6a85

Please sign in to comment.