Skip to content

Commit

Permalink
Merge pull request #1241 from Chia-Network/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
TheLastCicada authored Dec 9, 2024
2 parents 2a9f57c + 811873f commit e63d38b
Show file tree
Hide file tree
Showing 8 changed files with 13,037 additions and 12,952 deletions.
25,924 changes: 12,999 additions & 12,925 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cadt",
"version": "1.7.19",
"version": "1.7.20",
"_comment": "DONT CHANGE MAJOR UNLESS DATAMODEL CHANGES: The major version corresponds to the datamodel version your using, so 2.0.0 means it'll use datamodel v2",
"private": true,
"bin": "build/server.js",
Expand Down Expand Up @@ -71,21 +71,21 @@
"@babel/plugin-syntax-import-attributes": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/register": "^7.25.9",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0",
"@commitlint/cli": "^19.6.0",
"@commitlint/config-conventional": "^19.6.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.16.0",
"@yao-pkg/pkg": "^6.1.1",
"babel-plugin-module-resolver": "^5.0.2",
"chai": "^5.1.2",
"chai-http": "^5.1.1",
"eslint": "^9.13.0",
"eslint": "^9.16.0",
"eslint-plugin-es": "^4.1.0",
"eslint-plugin-mocha": "^10.5.0",
"extensionless": "^1.9.9",
"globals": "^15.11.0",
"husky": "^9.1.6",
"mocha": "^10.8.2",
"globals": "^15.13.0",
"husky": "^9.1.7",
"mocha": "^11.0.1",
"semver": "^7.6.3",
"sinon": "^19.0.2",
"socket.io-client": "^4.8.1",
Expand Down
11 changes: 5 additions & 6 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,20 @@ export const subscribeToOrganization = async (req, res) => {
export const deleteImportedOrg = async (req, res) => {
let transaction;
try {
const orgUid = req.body.orgUid;
await assertIfReadOnlyMode();
await assertWalletIsSynced();
await assertHomeOrgExists();
await assertCanDeleteOrg(req.body.orgUid);
await assertCanDeleteOrg(orgUid);

transaction = await sequelize.transaction();

await Organization.destroy({ where: { orgUid: req.body.orgUid } });
await Organization.destroy({ where: { orgUid } });

await Promise.all([
...Object.keys(ModelKeys).map(
async (key) =>
await ModelKeys[key].destroy({ where: { orgUid: req.body.orgUid } }),
async (key) => await ModelKeys[key].destroy({ where: { orgUid } }),
),
Audit.destroy({ where: { orgUid: req.body.orgUid } }),
Audit.destroy({ where: { orgUid } }),
]);

await transaction.commit();
Expand Down
5 changes: 4 additions & 1 deletion src/datalayer/persistance.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ const subscribeToStoreOnDataLayer = async (
return { success: true };
}

const { storeIds: subscriptions } = await getSubscriptions();
const { storeIds: subscriptions, success } = await getSubscriptions();
if (!success) {
return false;
}

if (subscriptions.includes(storeId)) {
logger.info(`Already subscribed to: ${storeId}`);
Expand Down
6 changes: 5 additions & 1 deletion src/datalayer/syncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ const subscribeToStoreOnDataLayer = async (storeId) => {
};

const getSubscribedStoreData = async (storeId) => {
const { storeIds: subscriptions } = await dataLayer.getSubscriptions(storeId);
const { storeIds: subscriptions, success } =
await dataLayer.getSubscriptions();
if (!success) {
throw new Error('failed to retrieve subscriptions from datalayer');
}
const alreadySubscribed = subscriptions.includes(storeId);

if (!alreadySubscribed) {
Expand Down
18 changes: 10 additions & 8 deletions src/models/organizations/organizations.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,16 @@ class Organization extends Model {

await datalayer.subscribeToStoreOnDataLayer(registryData.v1);

logger.info({
orgUid,
name: orgData.name,
icon: orgData.icon,
registryId: registryData[dataModelVersion],
subscribed: true,
isHome: false,
});
logger.info(
`setting the following organization information: ${{
orgUid,
name: orgData.name,
icon: orgData.icon,
registryId: registryData[dataModelVersion],
subscribed: true,
isHome: false,
}}`,
);

await Organization.upsert({
orgUid,
Expand Down
5 changes: 4 additions & 1 deletion src/tasks/sync-registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ const processJob = async () => {
});

// verify that the latest organization root hash is up to date with the audit records. attempt correction.
if (mostRecentOrgAuditRecord?.rootHash !== organization?.registryHash) {
if (
mostRecentOrgAuditRecord &&
mostRecentOrgAuditRecord?.rootHash !== organization?.registryHash
) {
logger.warn(
`latest root hash in org table for organization ${organization.name} (orgUid ${organization.orgUid}) does not match the audit records. attempting to correct`,
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/data-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const assertRecordExistance = async (Model, pk) => {

export const assertCanDeleteOrg = async (orgUid) => {
const homeOrg = await Organization.getHomeOrg();
if (homeOrg.orgUid === orgUid) {
if (homeOrg?.orgUid === orgUid) {
throw new Error(`Cant delete your own organization`);
}
};
Expand Down

0 comments on commit e63d38b

Please sign in to comment.