Skip to content

Commit

Permalink
remove some devnet based code
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Apr 16, 2024
1 parent 3515ae8 commit 9d2c0a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
5 changes: 1 addition & 4 deletions lib/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ export async function declareContract(contractName: string, wait = true, folder
return cachedClass;
}
const payload = getDeclareContractPayload(contractName, folder);
const skipSimulation = provider.isDevnet;
// max fee avoids slow estimate
const maxFee = skipSimulation ? 1e18 : undefined;

const { class_hash, transaction_hash } = await deployer.declareIfNot(payload, { maxFee });
const { class_hash, transaction_hash } = await deployer.declareIfNot(payload, { maxFee: undefined });

if (wait && transaction_hash) {
await provider.waitForTransaction(transaction_hash);
Expand Down
13 changes: 3 additions & 10 deletions lib/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@ import { RpcProvider } from "starknet";

dotenv.config({ override: true });

const devnetBaseUrl = "http://127.0.0.1:5050";

// Polls quickly for a local network
// Polls quickly
export class FastRpcProvider extends RpcProvider {
get isDevnet() {
return this.channel.nodeUrl.startsWith(devnetBaseUrl);
}

waitForTransaction(txHash: string, options = {}) {
const retryInterval = this.isDevnet ? 250 : 1000;
return super.waitForTransaction(txHash, { retryInterval, ...options });
return super.waitForTransaction(txHash, { retryInterval: 1000, ...options });
}
}

export const provider = new FastRpcProvider({ nodeUrl: process.env.RPC_URL || `${devnetBaseUrl}` });
export const provider = new FastRpcProvider({ nodeUrl: process.env.RPC_URL });
console.log("Provider:", provider.channel.nodeUrl);

0 comments on commit 9d2c0a7

Please sign in to comment.