27 lines
1.3 KiB
JavaScript
27 lines
1.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getActiveColdWallet = getActiveColdWallet;
|
|
exports.listColdWallets = listColdWallets;
|
|
exports.upsertActiveColdWallet = upsertActiveColdWallet;
|
|
exports.deactivateColdWallet = deactivateColdWallet;
|
|
const connection_1 = require("../db/connection");
|
|
async function getActiveColdWallet(walletTypeId) {
|
|
const rows = await (0, connection_1.query)('SELECT * FROM cold_wallets WHERE wallet_type_id = $1 AND is_active = TRUE LIMIT 1', [walletTypeId]);
|
|
return rows[0] ?? null;
|
|
}
|
|
async function listColdWallets() {
|
|
return (0, connection_1.query)('SELECT * FROM cold_wallets ORDER BY wallet_type_id, created_at DESC');
|
|
}
|
|
async function upsertActiveColdWallet(input) {
|
|
await (0, connection_1.query)('UPDATE cold_wallets SET is_active = FALSE, updated_at = NOW() WHERE wallet_type_id = $1', [
|
|
input.walletTypeId,
|
|
]);
|
|
const rows = await (0, connection_1.query)(`INSERT INTO cold_wallets (wallet_type_id, address, label, is_active)
|
|
VALUES ($1, $2, $3, TRUE)
|
|
RETURNING *`, [input.walletTypeId, input.address.trim(), input.label ?? null]);
|
|
return rows[0];
|
|
}
|
|
async function deactivateColdWallet(id) {
|
|
await (0, connection_1.query)('UPDATE cold_wallets SET is_active = FALSE, updated_at = NOW() WHERE id = $1', [id]);
|
|
}
|
|
//# sourceMappingURL=coldWalletRepository.js.map
|