@iqprotocol/abstract-storage
Advanced tools
Comparing version 0.15.0 to 0.15.1
@@ -0,1 +1,70 @@ | ||
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; | ||
} | ||
/** | ||
* @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.15.0", | ||
"version": "0.15.1", | ||
"bugs": "https://github.com/iqlabsorg/iq-sdk-js/issues", | ||
@@ -29,3 +29,3 @@ "repository": { | ||
"typedocMain": "src/index.ts", | ||
"gitHead": "2b3b40d6c6e9e422befb995823c537cf839e962e" | ||
"gitHead": "b698a0e32b2701b7add9ddf9580c121a92e42833" | ||
} |
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
21895
151