UNPKG

@unilogin/sdk

Version:

SDK is a JS library, that communicates with relayer. SDK allows managing contract, by creating basic contract-calling messages.

19 lines (14 loc) 505 B
import {BlockchainService} from '@unilogin/contracts'; import {ReferenceCountedState} from './ReferenceCountedState'; export class BlockNumberState extends ReferenceCountedState<number> { constructor(private readonly blockchainService: BlockchainService) { super(0); } bindedSet = (v: number) => this.set(v); onFirstSubscribe() { this.blockchainService.on('block', this.bindedSet); } onLastUnsubscribe() { this.blockchainService.removeListener('block', this.bindedSet); } };