@credenza3/scanner-sui
v0.0.6
Published
Credenza Scanner for Sui
Downloads
1
Readme
Credenza3 Scanner SUI
Installation
with npm
npm install @credenza3/scanner-sui
with yarn
yarn add @credenza3/scanner-sui
with pnpm
pnpm install @credenza3/scanner-sui
or include a script tag
<script src="https://unpkg.com/@credenza3/scanner-sui/dist/scanner.umd.js"></script>
Usage
import {Scanner} from '@credenza3/scanner-sui'
or
const Scanner = window.CredenzaScannerSui
Create an instance of Credenza scanner
const scanner = new Scanner({target: '.scanner-placeholder'}) // query selector to render the scanner into.
Static
Scanner.events
- list of events produced by scanner
Get a list of available video input devices
await scanner.listVideoInputDevices()
Scan
scanner.scan({
deviceId?: string,
isCloseButton?: boolean
maxScansPerSecond? number // 25
}) // (await scanner.listVideoInputDevices())[0].id by default
Cancel
scanner.close()
Events
On capture
// 'capture'
scanner.on(Scanner.events.CAPTURE, ({ rawString, message, userAddress, scanType, chainId }) => {
console.log('Scan completed', { rawString, message, userAddress })
})
On error
// 'error'
scanner.on(Scanner.events.ERROR, (err) => {
console.log('Scan error:', err)
})
On cancel
// 'cancel'
scanner.on(Scanner.events.CAPTURE, () => {
console.log('Scan canceled')
})