Skip to content

Commit

Permalink
feat(env): add brovider url to envs (#135)
Browse files Browse the repository at this point in the history
* feat(env): add brovider url to envs

* fix(deps): upgrade snapshot.js

* fix(lint): missed conflict

* refactor(env): add default value

* fix(lint): fix lint errors
  • Loading branch information
Todmy authored Aug 28, 2023
1 parent 33a359c commit 1997259
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DATABASE_URL=mysql://...
SEQUENCER_URL=https://seq.snapshot.org
HUB_URL=https://hub.snapshot.org/graphql
BROVIDER_URL=https://rpc.snapshot.org
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@ethersproject/hash": "^5.5.0",
"@snapshot-labs/snapshot-metrics": "^1.0.0",
"@snapshot-labs/snapshot-sentry": "^1.1.0",
"@snapshot-labs/snapshot.js": "^0.5.5",
"@snapshot-labs/snapshot.js": "^0.5.6",
"bluebird": "^3.7.2",
"body-parser": "^1.19.0",
"connection-string": "^1.0.1",
Expand Down
3 changes: 2 additions & 1 deletion src/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { capture } from '@snapshot-labs/snapshot-sentry';

const delay = 60 * 60 * 24 * 3;
const interval = 15e3;
const broviderUrl = process.env.BROVIDER_URL || 'https://rpc.snapshot.org';

const SUPPORTED_NETWORKS = ['1', '5', '10', '56', '100', '137', '42161'];

Expand Down Expand Up @@ -61,7 +62,7 @@ async function processSig(address, safeHash, network) {
async function checkSignedMessages(messages, network) {
if (messages.length > 0) {
const end = timeMessageProcess.startTimer({ network });
const provider = snapshot.utils.getProvider(network);
const provider = snapshot.utils.getProvider(network, { broviderUrl });
const abi = ['function signedMessages(bytes32) view returns (uint256)'];
try {
const response = await snapshot.utils.multicall(
Expand Down
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { Contract } from '@ethersproject/contracts';
import { hexValue } from '@ethersproject/bytes';
import snapshot from '@snapshot-labs/snapshot.js';

const broviderUrl = process.env.BROVIDER_URL || 'https://rpc.snapshot.org';

export async function getSafeVersion(safe, network) {
const provider = snapshot.utils.getProvider(network);
const provider = snapshot.utils.getProvider(network, { broviderUrl });
const storage = await provider.getStorageAt(safe, 0);
const abi = ['function VERSION() view returns (string)'];
const contract = new Contract(hexValue(storage), abi, provider);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1089,10 +1089,10 @@
dependencies:
"@sentry/node" "^7.60.1"

"@snapshot-labs/snapshot.js@^0.5.5":
version "0.5.5"
resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot.js/-/snapshot.js-0.5.5.tgz#1ad759ae1c6504ad2d506ddb6f71756151847622"
integrity sha512-JNBGdqim9+IriPRv0R8vhLe3ojVv7i2R1qrx6PxQCbdHwiBr7d7Npei+h8VpnzOKYcVzPAkttOedxDvxxR2wnA==
"@snapshot-labs/snapshot.js@^0.5.6":
version "0.5.6"
resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot.js/-/snapshot.js-0.5.6.tgz#e8fa4786bfc1fd69c5093d31e65b60ad2f0c5f65"
integrity sha512-5YVgM2V2uhJi3PZfTwSNihcrPa66Wz697IfC8v57enXdYaVYryZnwZfB0A0eahgwdtjBHWlyPOvfRI4Rr7aoTw==
dependencies:
"@ensdomains/eth-ens-namehash" "^2.0.15"
"@ethersproject/abi" "^5.6.4"
Expand Down

0 comments on commit 1997259

Please sign in to comment.