Skip to content

Commit

Permalink
refactor: use rpc env
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jan 21, 2025
1 parent cf83f12 commit 5077430
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 272 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"vitest": "^1.3.1"
},
"dependencies": {
"@bgd-labs/rpc-env": "^2.3.0",
"@supercharge/promise-pool": "^3.1.1",
"bs58": "^5.0.0",
"gray-matter": "^4.0.3",
Expand All @@ -62,4 +63,4 @@
"peerDependencies": {
"viem": "^2.0.3"
}
}
}
2 changes: 0 additions & 2 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export * from './foundry/storage-diff';
export * from './rpc/chainIds';
export * from './rpc/helpers';
export * from './rpc/clients';
export * from './ipfs/hash';
export * from './ipfs/upload';
export * from './ipfs/parseIpfs';
Expand Down
2 changes: 1 addition & 1 deletion src/ipfs/upload.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest';
import { describe, it } from 'vitest';
import { uploadToQuicknode } from './upload';

describe('upload', () => {
Expand Down
59 changes: 0 additions & 59 deletions src/rpc/chainIds.ts

This file was deleted.

200 changes: 0 additions & 200 deletions src/rpc/clients.ts

This file was deleted.

9 changes: 4 additions & 5 deletions src/rpc/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { describe, it, expect } from 'vitest';
import { getClient, ChainId } from '@bgd-labs/rpc-env';
import {
getContractDeploymentBlock,
getBlockAtTimestamp,
strategicGetLogs,
} from './helpers';
import { getAbiItem } from 'viem';
import { IPoolV1_ABI } from './mocks/IPoolV1';
import { CHAIN_ID_CLIENT_MAP } from './clients.ts';
import { mainnet } from 'viem/chains';
import { getLogs } from 'viem/actions';

describe('helpers', () => {
it(
'getContractDeploymentBlock',
async () => {
const maxDelta = 1000n;
const result = await getContractDeploymentBlock({
client: CHAIN_ID_CLIENT_MAP[mainnet.id],
client: getClient(ChainId.mainnet, {}),
contractAddress: '0x5a98fcbea516cf06857215779fd812ca3bef1b32',
fromBlock: 11470216n,
toBlock: 11475216n,
Expand All @@ -31,7 +30,7 @@ describe('helpers', () => {
it('getBlockAtTimestamp', async () => {
const maxDelta = 1000n;
const result = await getBlockAtTimestamp({
client: CHAIN_ID_CLIENT_MAP[mainnet.id],
client: getClient(ChainId.mainnet, {}),
timestamp: 1704488567n,
fromBlock: 18933610n,
toBlock: 18953610n,
Expand All @@ -47,7 +46,7 @@ describe('helpers', () => {
'getLogs should use batching for known rpcs',
async () => {
const logs = await strategicGetLogs({
client: CHAIN_ID_CLIENT_MAP[mainnet.id],
client: getClient(ChainId.mainnet, {}),
events: [getAbiItem({ abi: IPoolV1_ABI, name: 'Borrow' })],
address: '0x398eC7346DcD622eDc5ae82352F02bE94C62d119', // v1 pool
fromBlock: 9241022n,
Expand Down
27 changes: 23 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7"
integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==

"@bgd-labs/rpc-env@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@bgd-labs/rpc-env/-/rpc-env-2.3.0.tgz#18955fb09dd97a353531612ccfb1b8e88e227ba6"
integrity sha512-kYqzLozksrd/E1fyvy+Afi5ssBv2mI2PvYqrslQocYY1nBrOF9b43/2/VitmAhxhBomGjk/qfWzjOzDPGjgxqQ==

"@cspotcode/source-map-support@^0.8.0":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1"
Expand Down Expand Up @@ -1466,8 +1471,16 @@ std-env@^3.5.0:
resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.7.0.tgz#c9f7386ced6ecf13360b6c6c55b8aaa4ef7481d2"
integrity sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
name string-width-cjs
"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:
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 All @@ -1485,8 +1498,14 @@ string-width@^5.0.1, string-width@^5.1.2:
emoji-regex "^9.2.2"
strip-ansi "^7.0.1"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
name strip-ansi-cjs
"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:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down

0 comments on commit 5077430

Please sign in to comment.