@blockbolt/boltpay-wallet
Version:
BlockBolt package for SUI wallet
31 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockBolt = void 0;
const client_1 = require("@mysten/sui/client");
const TransactionService_1 = require("./services/TransactionService");
const TresuryService_1 = require("./services/TresuryService");
class BlockBolt {
constructor() {
const rpcUrl = (0, client_1.getFullnodeUrl)("mainnet");
this.client = new client_1.SuiClient({ url: rpcUrl });
this.transactionService = new TransactionService_1.TransactionService(this.client);
this.treasuryService = new TresuryService_1.TreasuryService(this.client);
}
async send(params) {
const derivedAddress = params.keyPair.getPublicKey().toSuiAddress();
if (params.senderAddr && params.senderAddr !== derivedAddress) {
throw new Error("The sender's address does not match the wallet address.");
}
const internalParams = await this.prepareInternalParams(params);
return this.transactionService.send(internalParams);
}
async prepareInternalParams(params) {
const treasury = await this.treasuryService.getTreasury(params.coinType);
return {
...params,
treasury,
};
}
}
exports.BlockBolt = BlockBolt;
//# sourceMappingURL=blockbolt.js.map