@iqprotocol/abstract-storage
Advanced tools
Comparing version 0.13.1 to 0.15.0
@@ -1,67 +0,1 @@ | ||
type Account = { | ||
id: string; | ||
data: AccountData; | ||
}; | ||
type AccountOwnershipProof = { | ||
v: string; | ||
sig: string; | ||
}; | ||
type AccountData = Serializable & { | ||
proof: AccountOwnershipProof; | ||
}; | ||
type Serializable = boolean | number | string | null | readonly Serializable[] | { | ||
[key: string]: Serializable | undefined; | ||
}; | ||
type AccountState = { | ||
serviceId: string; | ||
accountId: string; | ||
energyGapHalvingPeriod: number; | ||
power: bigint; | ||
lockedPower: bigint; | ||
energyCap: bigint; | ||
energy: bigint; | ||
energyCalculatedAt: number; | ||
}; | ||
type AccountStateChangeResult = { | ||
successful: boolean; | ||
currentState: AccountState; | ||
}; | ||
interface AccountStateValidator { | ||
validateAccount(account: Account): void; | ||
validateAccountState(accountState: AccountState): void; | ||
} | ||
interface StorageProvider { | ||
saveAccount(account: Account): Promise<Account>; | ||
deleteAccount(id: string): Promise<boolean>; | ||
getAccount(id: string): Promise<Account | null>; | ||
initAccountState(accountState: AccountState): Promise<AccountState>; | ||
changeAccountState(prevState: AccountState, newState: AccountState): Promise<AccountStateChangeResult>; | ||
getAccountState(serviceId: string, accountId: string): Promise<AccountState | null>; | ||
deleteAccountState(serviceId: string, accountId: string): Promise<boolean>; | ||
} | ||
declare class AccountStateError extends Error { | ||
constructor(msg: string); | ||
} | ||
type AbstractStoreConfig = { | ||
validator?: AccountStateValidator; | ||
}; | ||
declare abstract class AccountStore implements StorageProvider { | ||
private readonly validator; | ||
protected constructor({ validator }: AbstractStoreConfig); | ||
saveAccount(account: Account): Promise<Account>; | ||
initAccountState(accountState: AccountState): Promise<AccountState>; | ||
changeAccountState(prevState: AccountState, newState: AccountState): Promise<AccountStateChangeResult>; | ||
abstract getAccount(id: string): Promise<Account | null>; | ||
abstract deleteAccount(id: string): Promise<boolean>; | ||
abstract getAccountState(serviceId: string, accountId: string): Promise<AccountState | null>; | ||
abstract deleteAccountState(serviceId: string, accountId: string): Promise<boolean>; | ||
protected abstract _saveAccount(account: Account): Promise<Account>; | ||
protected abstract _initAccountState(accountState: AccountState): Promise<AccountState>; | ||
protected abstract _changeAccountState(prevState: AccountState, newState: AccountState): Promise<AccountStateChangeResult>; | ||
} | ||
declare class DefaultValidator implements AccountStateValidator { | ||
validateAccount(account: Account): void; | ||
validateAccountState(accountState: AccountState): void; | ||
} | ||
export { Account, AccountOwnershipProof, AccountData, AccountState, AccountStateChangeResult, AccountStateValidator, StorageProvider, AccountStateError, AccountStore, DefaultValidator }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -66,3 +66,6 @@ type Account = { | ||
} | ||
/** | ||
* @module abstract-storage | ||
*/ | ||
export { Account, AccountOwnershipProof, AccountData, AccountState, AccountStateChangeResult, AccountStateValidator, StorageProvider, AccountStateError, AccountStore, DefaultValidator }; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@iqprotocol/abstract-storage", | ||
"version": "0.13.1", | ||
"version": "0.15.0", | ||
"bugs": "https://github.com/iqlabsorg/iq-sdk-js/issues", | ||
@@ -10,3 +10,3 @@ "repository": { | ||
"license": "MIT", | ||
"author": "IQ Labs (https://iqlabs.org)", | ||
"author": "IQ Labs (https://iq.space)", | ||
"main": "dist/cjs/index.js", | ||
@@ -30,3 +30,3 @@ "module": "dist/esm/index.js", | ||
"typedocMain": "src/index.ts", | ||
"gitHead": "47c98de9099124fab6733a14c556e615602ad0ef" | ||
"gitHead": "2b3b40d6c6e9e422befb995823c537cf839e962e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
18908
82