Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"prettier": "^2.7.1",
"solhint": "^3.4.1",
"typescript": "~5.8.2",
"ts-jest": "^29.4.6",
"ts-jest": "^29.4.0",
"uuid": "^9.0.0"
},
"main": "jest.config.js",
Expand Down
16 changes: 7 additions & 9 deletions src/db/objects/Factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export const FACTORY_VERSION = {
LEGACY: "LEGACY",
};

const CHAIN_ID = {
BASE_MAINNET: "8453",
BASE_SEPOLIA: "84532",
ANVIL: "31337",
};

const FactorySchema = new mongoose.Schema(
{
_id: { type: String, default: () => uuid() },
Expand All @@ -15,21 +21,13 @@ const FactorySchema = new mongoose.Schema(
chain_id: {
type: String,
required: true,
enum: [
"8453", // Base mainnet
"84532", // Base Sepolia
"31337", // anvil
],
enum: Object.values(CHAIN_ID),
},
version: {
type: String,
required: true,
enum: Object.values(FACTORY_VERSION),
},
notes: {
type: String,
default: "",
},
},
{ timestamps: true }
);
Expand Down
43 changes: 0 additions & 43 deletions src/db/objects/HistoricalTransaction.js

This file was deleted.

10 changes: 5 additions & 5 deletions src/db/operations/create.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Factory from "../objects/Factory.js";
import HistoricalTransaction from "../objects/HistoricalTransaction.js";
import Issuer from "../objects/Issuer.js";
import Stakeholder from "../objects/Stakeholder.js";
import StockClass from "../objects/StockClass.js";
Expand All @@ -18,6 +17,7 @@ import EquityCompensationExercise from "../objects/transactions/exercise/EquityC
import StockPlanPoolAdjustment from "../objects/transactions/adjustment/StockPlanPoolAdjustment.js";
import StockClassAuthorizedSharesAdjustment from "../objects/transactions/adjustment/StockClassAuthorizedSharesAdjustment.js";
import IssuerAuthorizedSharesAdjustment from "../objects/transactions/adjustment/IssuerAuthorizedSharesAdjustment.js";
import StockCancellation from "../objects/transactions/cancellation/StockCancellation.js";

export const createIssuer = (issuerData) => {
return save(new Issuer(issuerData));
Expand Down Expand Up @@ -47,10 +47,6 @@ export const createVestingTerms = (vestingTermsData) => {
return save(new VestingTerms(vestingTermsData));
};

export const createHistoricalTransaction = (transactionHistoryData) => {
return save(new HistoricalTransaction(transactionHistoryData));
};

export const createStockIssuance = (stockIssuanceData) => {
return save(new StockIssuance(stockIssuanceData));
};
Expand Down Expand Up @@ -83,6 +79,10 @@ export const createEquityCompensationExercise = (exerciseData) => {
return save(new EquityCompensationExercise(exerciseData));
};

export const createStockCancellation = (stockCancellationData) => {
return save(new StockCancellation(stockCancellationData));
};

export const createStockPlanPoolAdjustment = (stockPlanPoolAdjustmentData) => {
return save(new StockPlanPoolAdjustment(stockPlanPoolAdjustmentData));
};
Expand Down
11 changes: 0 additions & 11 deletions src/db/operations/read.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Factory from "../objects/Factory.js";
import HistoricalTransaction from "../objects/HistoricalTransaction.js";
import Issuer from "../objects/Issuer.js";
import Stakeholder from "../objects/Stakeholder.js";
import StockClass from "../objects/StockClass.js";
Expand Down Expand Up @@ -47,16 +46,6 @@ export const readVestingTermsById = async (id) => {
return await findById(VestingTerms, id);
};

export const readHistoricalTransactionById = async (txId) => {
return await findOne(HistoricalTransaction, { transaction: txId });
};

// READ Multiple
export const readHistoricalTransactionByIssuerId = async (issuerId) => {
return await find(HistoricalTransaction, { issuer: issuerId }).populate("transaction");
};

// COUNT
export const countIssuers = async () => {
return await countDocuments(Issuer);
};
Expand Down
3 changes: 0 additions & 3 deletions src/routes/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import StockLegendTemplate from "../db/objects/StockLegendTemplate";
import StockPlan from "../db/objects/StockPlan";
import Valuation from "../db/objects/Valuation";
import VestingTerm from "../db/objects/VestingTerms";
import HistoricalTransaction from "../db/objects/HistoricalTransaction";

import { find } from "../db/operations/atomic";
const exportCaptable = Router();
Expand All @@ -26,7 +25,6 @@ exportCaptable.get("/ocf", async (req, res) => {
const stockLegendTemplates = await find(StockLegendTemplate, { issuer: issuerId });
const valuations = await find(Valuation, { issuer: issuerId });
const vestingTerms = await find(VestingTerm, { issuer: issuerId });
const historicalTransactions = await find(HistoricalTransaction, { issuer: issuerId });

res.status(200).json({
issuer,
Expand All @@ -36,7 +34,6 @@ exportCaptable.get("/ocf", async (req, res) => {
stockLegendTemplates,
valuations,
vestingTerms,
historicalTransactions,
});
} catch (error) {
console.error("Error fetching data:", error);
Expand Down
6 changes: 3 additions & 3 deletions src/routes/issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ issuer.post("/create", async (req, res) => {

const issuerIdBytes16 = convertUUIDToBytes16(incomingIssuerToValidate.id);
console.log("💾 | Issuer id in bytes16 ", issuerIdBytes16);
const { address, deployHash } = await deployCapTable(issuerIdBytes16, incomingIssuerToValidate.initial_shares_authorized, Number(chain_id));
const { address, deployHash } = await deployCapTable(issuerIdBytes16, incomingIssuerToValidate.initial_shares_authorized, chain_id);

const incomingIssuerForDB = {
...incomingIssuerToValidate,
deployed_to: address,
tx_hash: deployHash,
chain_id: Number(chain_id),
chain_id,
};

const issuer = await createIssuer(incomingIssuerForDB);
addAddressesToWatch(Number(chain_id), address);
addAddressesToWatch(chain_id, address);

console.log("✅ | Issuer created offchain:", issuer);

Expand Down
6 changes: 4 additions & 2 deletions src/routes/stakeholder/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import stakeholderSchema from "../../../ocf/schema/objects/Stakeholder.schema.js
import { createStakeholder } from "../../db/operations/create.js";
import { readIssuerById, readStakeholderById, getAllStakeholdersByIssuerId } from "../../db/operations/read.js";
import validateInputAgainstOCF from "../../utils/validateInputAgainstSchema.js";
import Stakeholder from "../../db/objects/Stakeholder.js";

const router = Router();

Expand Down Expand Up @@ -111,11 +112,12 @@ router.post("/create", async (req, res) => {
const stakeholder = await createStakeholder(incomingStakeholderForDB);

// Save onchain
await convertAndReflectStakeholderOnchain(contract, incomingStakeholderForDB.id);
const receipt = await convertAndReflectStakeholderOnchain(contract, incomingStakeholderForDB.id);
await Stakeholder.findByIdAndUpdate(stakeholder._id, { tx_hash: receipt.hash });

console.log("✅ | Stakeholder created offchain:", stakeholder);

res.status(200).send({ stakeholder });
res.status(200).send({ stakeholder: { ...stakeholder.toObject(), tx_hash: receipt.hash } });
} catch (error) {
console.error(error);
res.status(500).send(`${error}`);
Expand Down
6 changes: 4 additions & 2 deletions src/routes/stockClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { convertAndReflectStockClassOnchain, getStockClassById, getTotalNumberOf
import { createStockClass } from "../db/operations/create.js";
import { readIssuerById, readStockClassById } from "../db/operations/read.js";
import validateInputAgainstOCF from "../utils/validateInputAgainstSchema.js";
import StockClass from "../db/objects/StockClass";

const stockClass = Router();

Expand Down Expand Up @@ -67,11 +68,12 @@ stockClass.post("/create", async (req, res) => {
const stockClass = await createStockClass(incomingStockClassForDB);

// Save Onchain
await convertAndReflectStockClassOnchain(contract, incomingStockClassForDB);
const receipt = await convertAndReflectStockClassOnchain(contract, incomingStockClassForDB);
await StockClass.findByIdAndUpdate(stockClass._id, { tx_hash: receipt.hash });

console.log("✅ | Stock Class created offchain:", stockClass);

res.status(200).send({ stockClass });
res.status(200).send({ stockClass: { ...stockClass.toObject(), tx_hash: receipt.hash } });
} catch (error) {
console.error(error);
res.status(500).send(`${error}`);
Expand Down
Loading
Loading