@biconomy/abstractjs
Version:
SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.
75 lines • 3.2 kB
JavaScript
import { isStaging, isTesting } from "../account/utils/Helpers.js";
import createHttpClient, {} from "./createHttpClient.js";
import { getInfo, meeActions } from "./decorators/mee/index.js";
const isStagingOrTesting = isStaging() || isTesting();
export const getDefaultMEENetworkUrl = (isStaging = false) => {
if (isStaging) {
return "https://staging-network.biconomy.io/v1";
}
return "https://network.biconomy.io/v1";
};
export const getDefaultMEENetworkApiKey = (isStaging = false) => {
if (isStaging) {
return "mee_3ZhZhHx3hmKrBQxacr283dHt";
}
return "mee_3ZZmXCSod4xVXDRCZ5k5LTHg";
};
/**
* Default URL for the MEE node service
*/
export const DEFAULT_PATHFINDER_URL = getDefaultMEENetworkUrl(isStagingOrTesting);
/**
* Default API key for the MEE node service
*/
export const DEFAULT_PATHFINDER_API_KEY = getDefaultMEENetworkApiKey(isStagingOrTesting);
/**
* Constants for sponshorship
*/
// Sponsorship Nexus Account Address
export const DEFAULT_MEE_SPONSORSHIP_PAYMASTER_ACCOUNT = "0x18eAc826f3dD77d065E75E285d3456B751AC80d5";
// Base
export const DEFAULT_MEE_SPONSORSHIP_CHAIN_ID = 8453;
// USDC
export const DEFAULT_MEE_SPONSORSHIP_TOKEN_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
// Sponsorship Nexus Account Address
export const DEFAULT_MEE_TESTNET_SPONSORSHIP_PAYMASTER_ACCOUNT = "0x18eAc826f3dD77d065E75E285d3456B751AC80d5";
// Base Sepolia
export const DEFAULT_MEE_TESTNET_SPONSORSHIP_CHAIN_ID = 84532;
// USDC
export const DEFAULT_MEE_TESTNET_SPONSORSHIP_TOKEN_ADDRESS = "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
export const getDefaultMeeGasTank = (isTestnet = false) => {
if (isTestnet) {
return {
address: DEFAULT_MEE_TESTNET_SPONSORSHIP_PAYMASTER_ACCOUNT,
token: DEFAULT_MEE_TESTNET_SPONSORSHIP_TOKEN_ADDRESS,
chainId: DEFAULT_MEE_TESTNET_SPONSORSHIP_CHAIN_ID
};
}
return {
address: DEFAULT_MEE_SPONSORSHIP_PAYMASTER_ACCOUNT,
token: DEFAULT_MEE_SPONSORSHIP_TOKEN_ADDRESS,
chainId: DEFAULT_MEE_SPONSORSHIP_CHAIN_ID
};
};
export const createMeeClient = async (params) => {
const { account, pollingInterval = 250, url = DEFAULT_PATHFINDER_URL, apiKey = DEFAULT_PATHFINDER_API_KEY,
// By default: its false.
// If staging or testing suite, its true by default
isDebugMode = !!isStagingOrTesting } = params;
const httpClient = createHttpClient(url, apiKey, isDebugMode);
const info = await getInfo(httpClient);
info.isDebugMode = isDebugMode;
const baseMeeClient = Object.assign(httpClient, {
pollingInterval,
account,
info
});
// Check if the account is supported by the MEE node. Throws if not.
const supportedChains = info.supportedChains.map(({ chainId }) => Number(chainId));
const supported = account.deployments.every(({ chain }) => supportedChains.includes(chain.id));
if (!supported) {
throw new Error(`Some account chains are not supported by the MEE node. Please check the supported chains and try again. ${supportedChains.join(", ")}`);
}
return baseMeeClient.extend(meeActions);
};
//# sourceMappingURL=createMeeClient.js.map