ribbit-wallet-connect
Version:
Next-generation multi-chain wallet and payments app that makes crypto simple, secure, and usable in daily life.
24 lines (23 loc) • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGasPrice = exports.getSequenceNumber = void 0;
const constants_1 = require("../core/constants");
const joinBase = (base, path) => base.replace(/\/+$/, "") + "/" + path.replace(/^\/+/, "");
const getSequenceNumber = async (address, network) => {
const baseUrl = constants_1.API_URLS[network]["SUPRA_RPC_API_URL"];
const res = await fetch(joinBase(baseUrl, `/accounts/${encodeURIComponent(address)}`));
if (!res.ok)
throw new Error(`Failed to fetch account: ${res.status} ${res.statusText}`);
const json = await res.json();
return Number(json.sequence_number);
};
exports.getSequenceNumber = getSequenceNumber;
const getGasPrice = async (network) => {
const baseUrl = constants_1.API_URLS[network]["SUPRA_RPC_API_URL"];
const res = await fetch(joinBase(baseUrl, "/transactions/estimate_gas_price"));
if (!res.ok)
throw new Error(`Failed to fetch gas price: ${res.status} ${res.statusText}`);
const json = await res.json();
return json;
};
exports.getGasPrice = getGasPrice;