@tmawallet/sdk
Version:
TMA Wallet SDK
36 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletBundleController = void 0;
const simpleHash_1 = require("../utils/simpleHash");
class WalletBundleController {
type;
storage;
constructor(type, storage) {
this.type = type;
this.storage = storage;
//
}
get key() {
return `tmaw_wallet_address_${this.type}`;
}
async getWalletAddress(clientPublicKey) {
const walletData = await this.storage.getItem(this.key);
if (walletData) {
const [publicKeyHash, walletAddress] = walletData.split('|$|');
const hash = (0, simpleHash_1.simpleHash)(clientPublicKey).toString(16);
if (publicKeyHash === hash) {
return walletAddress;
}
}
return null;
}
async storeWalletAddress(clientPublicKey, walletAddress) {
const hash = (0, simpleHash_1.simpleHash)(clientPublicKey).toString(16);
await this.storage.setItem(this.key, `${hash}|$|${walletAddress}`);
}
async clearWalletAddress() {
await this.storage.removeItem(this.key);
}
}
exports.WalletBundleController = WalletBundleController;
//# sourceMappingURL=WalletBundleController.js.map