@iqprotocol/abstract-storage
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -18,3 +18,3 @@ interface Account { | ||
accountId: string; | ||
gapHalvingPeriod: number; | ||
energyGapHalvingPeriod: number; | ||
power: bigint; | ||
@@ -21,0 +21,0 @@ lockedPower: bigint; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.name="AccountStateError"}}const e=t=>null==t||!String(t).trim().length;class r{validateAccount(t){if(e(t.id))throw new Error("Empty id")}validateAccountState(r){if(["serviceId","accountId","gapHalvingPeriod","power","lockedPower","energyCap","energy","energyCalculatedAt"].forEach((a=>{if(e(r[a]))throw new t(`Empty ${a}`)})),r.power<0)throw new t("Negative power");if(r.gapHalvingPeriod<=0)throw new t("Invalid gap halving period");if(r.lockedPower<0)throw new t("Negative locked power");if(r.energy>r.energyCap)throw new t("Energy above cap");if(r.energyCalculatedAt<0)throw new t("Negative energy calculation time")}}exports.AbstractStore=class{constructor(t){this.validator=t.validator??new r}async saveAccount(t){return this.validator.validateAccount(t),this._saveAccount(t)}async initAccountState(t){return this.validator.validateAccountState(t),this._initAccountState(t)}async changeAccountState(t,e){if(t.accountId!==e.accountId)throw new Error("Account ID mismatch");if(t.serviceId!==e.serviceId)throw new Error("Service ID mismatch");return this.validator.validateAccountState(e),this._changeAccountState(t,e)}},exports.AccountStateError=t,exports.DefaultValidator=r; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class t extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.name="AccountStateError"}}const e=t=>null==t||!String(t).trim().length;class r{validateAccount(t){if(e(t.id))throw new Error("Empty id")}validateAccountState(r){if(["serviceId","accountId","power","lockedPower","energyCap","energy","energyCalculatedAt","energyGapHalvingPeriod"].forEach((a=>{if(e(r[a]))throw new t(`Empty ${a}`)})),r.power<0)throw new t("Negative power");if(r.energyGapHalvingPeriod<=0)throw new t("Invalid energy gap halving period");if(r.lockedPower<0)throw new t("Negative locked power");if(r.energy>r.energyCap)throw new t("Energy above cap");if(r.energyCalculatedAt<0)throw new t("Negative energy calculation time")}}exports.AbstractStore=class{constructor(t){this.validator=t.validator??new r}async saveAccount(t){return this.validator.validateAccount(t),this._saveAccount(t)}async initAccountState(t){return this.validator.validateAccountState(t),this._initAccountState(t)}async changeAccountState(t,e){if(t.accountId!==e.accountId)throw new Error("Account ID mismatch");if(t.serviceId!==e.serviceId)throw new Error("Service ID mismatch");return this.validator.validateAccountState(e),this._changeAccountState(t,e)}},exports.AccountStateError=t,exports.DefaultValidator=r; | ||
//# sourceMappingURL=index.js.map |
@@ -18,3 +18,3 @@ interface Account { | ||
accountId: string; | ||
gapHalvingPeriod: number; | ||
energyGapHalvingPeriod: number; | ||
power: bigint; | ||
@@ -21,0 +21,0 @@ lockedPower: bigint; |
@@ -1,2 +0,2 @@ | ||
class t extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.name="AccountStateError"}}const e=t=>null==t||!String(t).trim().length;class r{validateAccount(t){if(e(t.id))throw new Error("Empty id")}validateAccountState(r){if(["serviceId","accountId","gapHalvingPeriod","power","lockedPower","energyCap","energy","energyCalculatedAt"].forEach((a=>{if(e(r[a]))throw new t(`Empty ${a}`)})),r.power<0)throw new t("Negative power");if(r.gapHalvingPeriod<=0)throw new t("Invalid gap halving period");if(r.lockedPower<0)throw new t("Negative locked power");if(r.energy>r.energyCap)throw new t("Energy above cap");if(r.energyCalculatedAt<0)throw new t("Negative energy calculation time")}}class a{constructor(t){this.validator=t.validator??new r}async saveAccount(t){return this.validator.validateAccount(t),this._saveAccount(t)}async initAccountState(t){return this.validator.validateAccountState(t),this._initAccountState(t)}async changeAccountState(t,e){if(t.accountId!==e.accountId)throw new Error("Account ID mismatch");if(t.serviceId!==e.serviceId)throw new Error("Service ID mismatch");return this.validator.validateAccountState(e),this._changeAccountState(t,e)}}export{a as AbstractStore,t as AccountStateError,r as DefaultValidator}; | ||
class t extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.name="AccountStateError"}}const e=t=>null==t||!String(t).trim().length;class r{validateAccount(t){if(e(t.id))throw new Error("Empty id")}validateAccountState(r){if(["serviceId","accountId","power","lockedPower","energyCap","energy","energyCalculatedAt","energyGapHalvingPeriod"].forEach((a=>{if(e(r[a]))throw new t(`Empty ${a}`)})),r.power<0)throw new t("Negative power");if(r.energyGapHalvingPeriod<=0)throw new t("Invalid energy gap halving period");if(r.lockedPower<0)throw new t("Negative locked power");if(r.energy>r.energyCap)throw new t("Energy above cap");if(r.energyCalculatedAt<0)throw new t("Negative energy calculation time")}}class a{constructor(t){this.validator=t.validator??new r}async saveAccount(t){return this.validator.validateAccount(t),this._saveAccount(t)}async initAccountState(t){return this.validator.validateAccountState(t),this._initAccountState(t)}async changeAccountState(t,e){if(t.accountId!==e.accountId)throw new Error("Account ID mismatch");if(t.serviceId!==e.serviceId)throw new Error("Service ID mismatch");return this.validator.validateAccountState(e),this._changeAccountState(t,e)}}export{a as AbstractStore,t as AccountStateError,r as DefaultValidator}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@iqprotocol/abstract-storage", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"bugs": "https://github.com/iqlabsorg/iq-sdk-js/issues", | ||
@@ -20,2 +20,3 @@ "repository": { | ||
"build": "rollup -c", | ||
"build:clean": "rimraf dist", | ||
"prepublish": "NODE_ENV=production yarn build", | ||
@@ -29,3 +30,3 @@ "start": "rollup -cw", | ||
"typedocMain": "src/index.ts", | ||
"gitHead": "e8d82a1a20389dec31835e16f58bf4f7dbe445b7" | ||
"gitHead": "91320f84a804bf0cc6520d8254cd53d7e582d618" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21960
0