@accret/bridge-sdk
Version:
42 lines • 1.61 kB
JavaScript
import { executeSwap, getQuote, getTokenList } from "./lib";
import { AccretSupportedChain, AccretSupportedProvider } from "./types";
import { setAPIKeys } from "./constants";
export class AccretBridgeClient {
constructor() {
this.getQuote = getQuote;
this.executeSwap = executeSwap;
this.getTokenList = getTokenList;
//Exporting types and constants
this.AccretSupportedChain = AccretSupportedChain;
this.AccretSupportedProvider = AccretSupportedProvider;
if (!AccretBridgeClient.instance) {
AccretBridgeClient.instance = this;
return;
}
return AccretBridgeClient.instance;
}
/**
* Initializes the Accret bridge client with the provided API keys.
* @param infuraApiKey - The Infura API key.
* @param heliusApiKey - The Helius API key.
* @throws An error if any of the API keys are invalid.
*/
async configure({ infuraApiKey, heliusApiKey, }) {
if (!infuraApiKey ||
typeof infuraApiKey !== "string" ||
infuraApiKey.trim().length === 0) {
throw new Error("Invalid Infura API key: API key must be a non-empty string");
}
if (!heliusApiKey ||
typeof heliusApiKey !== "string" ||
heliusApiKey.trim().length === 0) {
throw new Error("Invalid Helius API key: API key must be a non-empty string");
}
await setAPIKeys({
infuraApiKey,
heliusApiKey,
});
return AccretBridgeClient.instance;
}
}
//# sourceMappingURL=index.js.map