Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iqprotocol/abstract-storage

Package Overview
Dependencies
Maintainers
9
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iqprotocol/abstract-storage - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

2

dist/cjs/index.d.ts

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc