UNPKG

sui-direct

Version:

Decentralized version control system on SUI blockchain

36 lines (35 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const client_1 = require("@mysten/sui/client"); const SUI_ADDR = "0x2::sui::SUI"; const WAL_ADDR = "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL"; class Wallet { constructor(wallet) { this.wallet = null; this.client = new client_1.SuiClient({ url: (0, client_1.getFullnodeUrl)("mainnet"), }); if (wallet) this.wallet = wallet; } async getBalance(wallet) { if (!wallet && !this.wallet) throw new Error("Wallet address is required"); const targetWallet = wallet || this.wallet; const [SUI_BALANCE, WAL_BALANCE] = await Promise.all([ this.client.getBalance({ owner: targetWallet, coinType: SUI_ADDR, }), this.client.getBalance({ owner: targetWallet, coinType: WAL_ADDR, }), ]); return { SUI: SUI_BALANCE, WAL: WAL_BALANCE, }; } } exports.default = Wallet;