Skip to content

Commit

Permalink
Edit to default freename connections
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrovisentini committed Sep 15, 2022
1 parent 9454063 commit ff56a98
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
38 changes: 31 additions & 7 deletions src/defaults/default-connections.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
import { NetworkConnection, NetworkName } from "../networks/connections/network-connection.types";

export const DEFAULT_RPC_URL: Record<NetworkName, string> = {
"polygon-mumbai": "https://rpc-mumbai.matic.today",
bsc: "https://bsc-dataseed.binance.org",
bsc: "https://bsc-dataseed1.ninicoin.io",
ethereum: "https://eth-mainnet.public.blastapi.io",
polygon: "https://rpc-mainnet.matic.quiknode.pro",
zil: "",
hardhat: "http://127.0.0.1:8545/",
aurora: "https://mainnet.aurora.dev",
cronos: "https://cronosrpc-1.xstaking.sg"
cronos: "https://node.croswap.com/rpc",

//TEST
"polygon-mumbai": "https://rpc-mumbai.matic.today",
hardhat: "http://127.0.0.1:8545/",
zil: "",
};

//theese urls can only connect to Freename smart contract addresses
export const DEFAULT_INFURA_RPC_URL: Record<NetworkName, string> = {
polygon: "https://polygon-mainnet.infura.io/v3/de21d7dc37334e459e15e172ee9d45f2",
ethereum: "https://mainnet.infura.io/v3/de21d7dc37334e459e15e172ee9d45f2",
aurora: "https://aurora-mainnet.infura.io/v3/de21d7dc37334e459e15e172ee9d45f2",
"polygon-mumbai": "",
bsc: "",
zil: "",
hardhat: "",
cronos: ""
}

export class DefaultTools {
static getDefaultConnection(networkName: NetworkName): NetworkConnection {
const url = DEFAULT_RPC_URL[networkName];
static getDefaultConnection(networkName: NetworkName, options: { infuraIfAvailable?: boolean } = {}): NetworkConnection {
const { infuraIfAvailable = false } = options
let url: string | undefined;

if (infuraIfAvailable) {
url = DEFAULT_INFURA_RPC_URL[networkName];
}

if (!url) {
url = DEFAULT_RPC_URL[networkName];
}

return {
networkName: networkName,
rpcUrl: url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class FreenameResolverProvider extends BaseResolverProvider implements IR
const freenameContractConfs = cloneDeep(FREENAME_CONTRACT_CONFS);
for (const contractConf of freenameContractConfs) {
if (contractConf.test == options.testMode) {
const connection = options.connectionLibrary?.getConnection(contractConf.networkName) || DefaultTools.getDefaultConnection(contractConf.networkName);
const connection = options.connectionLibrary?.getConnection(contractConf.networkName) || DefaultTools.getDefaultConnection(contractConf.networkName, { infuraIfAvailable: true });
if (contractConf.type == "read") {
readContractConnections.push(new ContractConnection(connection, contractConf.address, contractConf.abi))
} else if (contractConf.type == "write") {
Expand Down

0 comments on commit ff56a98

Please sign in to comment.