Skip to content

Commit

Permalink
Merge pull request #35 from piotr-layerzero/main
Browse files Browse the repository at this point in the history
feat: browser support
  • Loading branch information
mikemaccana authored Jun 5, 2024
2 parents f76d0cd + 06865a5 commit ee5dbf2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
SimulatedTransactionResponse,
} from "@solana/web3.js";
import base58 from "bs58";
import path from "path";
import { readFile, appendFile } from "fs/promises";

// Default value from Solana CLI
const DEFAULT_FILEPATH = "~/.config/solana/id.json";
Expand Down Expand Up @@ -122,6 +120,7 @@ export const getExplorerLink = (
};

export const getKeypairFromFile = async (filepath?: string) => {
const path = await import("path");
// Work out correct file name
if (!filepath) {
filepath = DEFAULT_FILEPATH;
Expand All @@ -136,6 +135,7 @@ export const getKeypairFromFile = async (filepath?: string) => {
// Get contents of file
let fileContents: string;
try {
const { readFile } = await import("fs/promises");
const fileContentsBuffer = await readFile(filepath);
fileContents = fileContentsBuffer.toString();
} catch (error) {
Expand Down Expand Up @@ -192,6 +192,7 @@ export const addKeypairToEnvFile = async (
variableName: string,
envFileName?: string,
) => {
const { appendFile } = await import("fs/promises");
if (!envFileName) {
envFileName = ".env";
}
Expand Down

0 comments on commit ee5dbf2

Please sign in to comment.