@cyberk/hyperion-sdk
Version:
Hyperion SDK from Cyberk
32 lines • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountInfoFromLcd = getAccountInfoFromLcd;
async function getAccountInfoFromLcd({ address, lcdUrl, }) {
try {
const response = await fetch(`${lcdUrl}/cosmos/auth/v1beta1/accounts/${address}`);
const account = (await response.json()).account;
console.log("account", account);
if (account && account.base_account) {
// Dành cho BaseAccount thông thường
return {
accountNumber: account.base_account.account_number,
sequence: account.base_account.sequence,
pubKey: account.base_account.pub_key, // Có thể là null, cần xử lý
};
}
else if (account && account.account_number !== undefined) {
// Dành cho các loại account khác có thể có cấu trúc phẳng hơn
return {
accountNumber: account.account_number,
sequence: account.sequence,
pubKey: account.pub_key, // Có thể là null
};
}
throw new Error("Không thể lấy account_number hoặc sequence.");
}
catch (error) {
console.error("Lỗi khi lấy thông tin tài khoản:", error);
throw error;
}
}
//# sourceMappingURL=getAccountInfoFromLcd.js.map