Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Mar 19, 2024
1 parent 2641a60 commit 61ed2bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
2 changes: 1 addition & 1 deletion examples/opensea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const run = async (slug: string): Promise<void> => {

const tx = data.fulfillment_data.transaction;
const input_data = tx.input_data;

// TODO - report or fix these bugs with OpenseaSDK
// @ts-expect-error: Undocumented field on type FulfillmentData within FulfillmentDataResponse
const order = input_data.parameters;
Expand Down
27 changes: 7 additions & 20 deletions src/chains/ethereum.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Common } from "@ethereumjs/common";
import { FeeMarketEIP1559Transaction } from "@ethereumjs/tx";
import { bytesToHex } from "@ethereumjs/util";
import { BN } from "bn.js";
import { ethers } from "ethers";
import { providers as nearProviders } from "near-api-js";
import { functionCall } from "near-api-js/lib/transaction";
import { Web3, Bytes } from "web3";
import { Bytes } from "web3";
import {
deriveChildPublicKey,
najPublicKeyStrToUncompressedHexPoint,
Expand All @@ -15,21 +14,7 @@ import { NO_DEPOSIT, getNearAccount, provider as nearProvider } from "./near";
import { GasPriceResponse, GasPrices, TxPayload } from "../types";
import { getMultichainContract } from "../mpc_contract";
import { getFirstNonZeroGasPrice } from "../utils/gasPrice";

const config = {
chainId: 11155111,
// providerUrl: "https://rpc.sepolia.ethpandaops.io",
// providerUrl: "https://sepolia.gateway.tenderly.co",
providerUrl: "https://rpc2.sepolia.org",
chain: "sepolia",
};

export const web3 = new Web3(config.providerUrl);
export const common = new Common({ chain: config.chain });
export const provider = new ethers.JsonRpcProvider(
config.providerUrl,
config.chainId
);
import { common, provider, web3 } from "../config";

export const deriveEthAddress = async (
derivationPath: string
Expand All @@ -47,9 +32,9 @@ export const deriveEthAddress = async (
return uncompressedHexPointToEvmAddress(publicKey);
};

async function queryGasPrice(): Promise<GasPrices> {
async function queryGasPrice(network: string): Promise<GasPrices> {
const res = await fetch(
"https://sepolia.beaconcha.in/api/v1/execution/gasnow"
`https://${network}.beaconcha.in/api/v1/execution/gasnow`
);
const gasPrices = (await res.json()) as GasPriceResponse;
const maxPriorityFeePerGas = BigInt(getFirstNonZeroGasPrice(gasPrices)!);
Expand All @@ -72,7 +57,9 @@ export const createPayload = async (
data?: string
): Promise<TxPayload> => {
const nonce = await provider.getTransactionCount(sender);
const { maxFeePerGas, maxPriorityFeePerGas } = await queryGasPrice();
const { maxFeePerGas, maxPriorityFeePerGas } = await queryGasPrice(
(await provider.getNetwork()).name
);
const transactionData = {
nonce,
to: receiver,
Expand Down
8 changes: 2 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
import {
deriveEthAddress,
signAndSendTransaction,
web3,
} from "./chains/ethereum";
export { deriveEthAddress, signAndSendTransaction, web3 };
import { deriveEthAddress, signAndSendTransaction } from "./chains/ethereum";
export { deriveEthAddress, signAndSendTransaction };

0 comments on commit 61ed2bf

Please sign in to comment.