Skip to content

Commit

Permalink
get rid of the json blobs hanging out in this library and simply down…
Browse files Browse the repository at this point in the history
…load them from github when needed
  • Loading branch information
chuckbergeron committed May 25, 2023
1 parent b08014c commit 1165d94
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 35,068 deletions.
9 changes: 2 additions & 7 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
artifacts
broadcast
cache
cache_hardhat
deployments
dist
lib
out
types

package.json
package.json
9 changes: 6 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"tabWidth": 2,
"overrides": [
{
"files": "*.sol",
"files": "*.{ts,js}",
"options": {
"bracketSpacing": true
"parser": "typescript",
"trailingComma": "all",
"arrowParens": "always",
"singleQuote": true
}
}
]
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"peerDependencies": {},
"dependencies": {
"@pooltogether/contract-list-schema": "^0.1.4",
"axios": "^1.4.0",
"ethereum-multicall": "^2.17.0",
"ethers": "^5.5.1",
"graphql": "^16.6.0",
Expand All @@ -40,10 +41,11 @@
"devDependencies": {
"@types/node": "^16.11.7",
"debug": "^4.3.2",
"prettier": "^2.8.8",
"replace-in-files": "^3.0.0",
"tslib": "^2.5.0",
"typedoc": "^0.22.10",
"typedoc-plugin-markdown": "^3.11.8",
"typescript": "^4.4.4"
}
}
}
32 changes: 32 additions & 0 deletions src/contracts/downloadContractsBlob.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import axios from 'axios';

import { ContractsBlob } from '../types';

interface StringMap {
[key: string]: string;
}

const CONTRACTS_STORE: StringMap = {
'5': 'https://raw.githubusercontent.com/pooltogether/v5-testnet/main/deployments/ethGoerli/contracts.json',
'80001': 'https://github.com/pooltogether/v5-testnet/blob/main/deployments/mumbai/contracts.json',
'11155111':
'https://raw.githubusercontent.com/pooltogether/v5-testnet/main/deployments/ethSepolia/contracts.json',
};

/**
* Downloads the latest contracts blob from the raw data source on GitHub
* @param {number} chainId
* @returns {ContractsBlob} contracts
*/
export const downloadContractsBlob = async (chainId: number): Promise<ContractsBlob> => {
let contracts;

try {
const { data } = await axios.get(CONTRACTS_STORE[chainId.toString()]);
contracts = data;
} catch (error) {
console.error(error);
}

return contracts;
};
3 changes: 1 addition & 2 deletions src/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { testnetContractsBlobSepolia } from "./testnetContractsBlobSepolia";
export { testnetContractsBlobMumbai } from "./testnetContractsBlobMumbai";
export { downloadContractsBlob } from "./downloadContractsBlob";
Loading

0 comments on commit 1165d94

Please sign in to comment.