SetStorage

Interface
Persistent smart contract set storage. Only usable as a SmartContract property. See the Properties and Storage chapter of the main guide for more information.
export interface SetStorage<V extends SerializableKey> extends Iterable<V> { 
  readonly [Symbol.iterator]: () => IterableIterator<V>; 
  readonly forEach: (callback: (value: V) => void) => void; 
  readonly has: (value: V) => boolean; 
  readonly delete: (value: V) => boolean; 
  readonly add: (value: V) => SetStorage<V>; 
  readonly at: V extends [SK, SK] 
    ? SKSetAtTwo<V> 
    : V extends [SK, SK, SK] 
    ? SKSetAtThree<V> 
    : V extends [SK, SK, SK, SK] 
    ? SKSetAtFour<V> 
    : never; 
  readonly [OpaqueTagSymbol0]: unique symbol; 
} 

Properties

at
V extends [SK, SK] ? SKSetAtTwo<V> : V extends [SK, SK, SK] ? SKSetAtThree<V> : V extends [SK, SK, SK, SK] ? SKSetAtFour<V> : never
Returns the elements from storage with the specified prefix.

Static Methods

for

Constructs a new SetStorage instance. Only usable as a SmartContract property.
for<K extends SerializableKey>(): SetStorage<K>; 

Methods

__@iterator

() => IterableIterator<V> 

forEach

Executes a provided function once per each value in storage.
(callback: (value: V) => void) => void 

has

Returns a boolean indicating whether an element with the specified value exists or not.
(value: V) => boolean 

delete

Removes the specified element from storage.
(value: V) => boolean 

add

Adds an element with the specified value in storage.
(value: V) => SetStorage<V> 

Example

class ICO extends SmartContract { 
 private readonly whitelistedAddresses = 
   SetStorage.for<Address>(); 
 public isWhitelisted(address: Address): boolean { 
   return this.whitelistedAddresses.has(address); 
 } 
} 
  • @neo-one/client
  • @neo-one/smart-contract
DOCS
InstallationMain ConceptsAdvanced GuidesAPI ReferenceContributing
CHANNELS
GitHubStack OverflowDiscord ChatTwitterYouTube
COPYRIGHT © 2021 NEO•ONE