Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public iterStorage(address: AddressString): AsyncIterable {
return AsyncIterableX.from(this.mutableClient.getAllStorage(address).then((res) => AsyncIterableX.from(res))).pipe(
// tslint:disable-next-line no-any
flatten() as any,
map((storageItem) => this.convertStorageItem(storageItem)),
);
}
invoke: async ({ context, args }) => {
const hash = vmUtils.toStorageContext({ context, value: args[0] }).value;
await checkStorage({ context, hash });
const prefix = args[1].asBuffer();
const iterable = AsyncIterableX.from(context.blockchain.storageItem.getAll$({ hash, prefix })).pipe<{
key: BufferStackItem;
value: BufferStackItem;
}>(
asyncMap(({ key, value }) => ({
key: new BufferStackItem(key),
value: new BufferStackItem(value),
})),
);
return {
context,
results: [new IteratorStackItem(new StackItemIterator(iterable[Symbol.asyncIterator]()))],
};
},
}),
public values(): StackItemEnumerator {
const iterable = AsyncIterableX.from(this.enumerator as AsyncIterableIterator).pipe<{
value: StackItemBase;
}>(map(({ value }) => ({ value })));
return new StackItemEnumerator(iterable[Symbol.asyncIterator]());
}
const iterEvents = (actionFilter?: BlockFilter): AsyncIterable =>
AsyncIterableX.from(iterActions(actionFilter)).pipe(
map((action) => {
if (action.type === 'Log') {
return undefined;
}
return action;
}),
filter(Boolean),
);
const iterActions = (options?: SmartContractIterOptions): AsyncIterable =>
AsyncIterableX.from(iterActionsRaw(options)).pipe(
map(convertAction),
filter(utils.notNull),
);
public keys(): StackItemEnumerator {
const iterable = AsyncIterableX.from(this.enumerator as AsyncIterableIterator).pipe<{
value: StackItemBase;
}>(map(({ key }) => ({ value: key })));
return new StackItemEnumerator(iterable[Symbol.asyncIterator]());
}
const iterActions = (filterIn?: BlockFilter): AsyncIterable =>
AsyncIterableX.from(iterActionsRaw(filterIn)).pipe(map(convertAction));
const iterLogs = (options?: SmartContractIterOptions): AsyncIterable =>
AsyncIterableX.from(iterActions(options)).pipe(
map((action) => {
if (action.type === 'Event') {
return undefined;
}
return action;
}),
filter(utils.notNull),
filter(Boolean),
);