npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pioneeringtechventures/concordium-wallet-client

v1.0.5

Published

ConcordiumWalletClient

Downloads

33

Readme

ConcordiumWalletClient

A JavaScript library to use with CryproX Wallet.

How to use

const concordiumWalletClient = new ConcordiumWalletClient({
    bridgeHost: 'bridge.example.cloud',
    bridgeConnectionKey: '82ac31f81'
});

const transactionPayload = utils.interpolate(config, {
    contract_address: {
        index: '253',
        sub_index: 0
    }
});

concordiumWalletClient.connect();

concordiumWalletClient.on('connect', () => {
    console.log('Connected')
});

concordiumWalletClient.on('accept', () => {
    concordiumWalletClient.send('Transaction', transactionPayload);
});

concordiumWalletClient.on('accountInfo', (message) => {
	console.log('Wallet balance: ', message.balance);
});

concordiumWalletClient.on('transfer', (message) => {
    if (message.tx_status === 'Accepted') {
        console.log(message.tx_hash);
    }

    concordiumWalletClient.disconnect();
});

concordiumWalletClient.on('error', async (message) => {
    await concordiumWalletClient.disconnect();

    throw new Error(`WS.bridge.error ${JSON.stringify(message)}`);
});

concordiumWalletClient.on('reject', () => {
    console.error('Request was rejected');

    concordiumWalletClient.disconnect();
});

concordiumWalletClient.on('transactionReject', () => {
    console.error('Transaction was rejected');
});

concordiumWalletClient.on('connectionReject', () => {
    console.error('Connection was rejected');
});

QR Modal usage

class ModalAdapter {
    constructor(opts) {
        this.pubSub = TypedEventEmitter;
        this.pubSub.on('close', () => {
            this.close();
            opts.onClose();
        });
    }

    close () {
        const wrapper = document.getElementById('qr-modal');

        if (wrapper) {
            document.body.removeChild(wrapper);
        }
    }

    open(msg) {
        const wrapper = document.createElement('div');
        wrapper.setAttribute('id', 'qr-modal');

        document.body.appendChild(wrapper);

        ReactDOM.render(
            <div className="modal">
                <button onClick={() => this.pubSub.emit('close')}>Close</button>
                {isMobile ? (
                    <a href={`tcwb://ws?uri=${msg.connect_string}`}>Wallet connect</a>
                 ) : (
                     <QRCode value={msg.connect_string} />
                 )}
            </div>
        );
    }
}

const concordiumWalletClient = new ConcordiumWalletClient({
    bridgeHost: 'bridge.example.cloud',
    bridgeConnectionKey: '82ac31f81',
    qrModal: ModalAdapter
});

concordiumWalletClient.connect(); // opens QR code (deep link) modal

Utils API

|Name|Args |Description| |--|--|--| | removeHexLiteral |value: string (optional) |Removes a leading 0x HEX literal from the string (default: '') | |toUint32|value: string (optional)|Converts a number represented by a string to Uint32 (little endian) (default: '')| |toUint64|value: string (optional)|Converts a number represented by a string to Uint64 (little endian) (default: '')| |base58ToHex|value: string (optional)|Converts a base58 encoded string to HEX without leading 0x literal (default: '')|

ConcordiumQrModalAdapter

|Name|Args|Description| |--|--|--| |ConcordiumQrModalAdapter|opts: IConcordiumWalletQrModalOptions (required)|Constructor| |open|msg: IBridgeMessage (optional)|Opens a modal with QR code.| |close|-|Closes the modal|

Events

|Event|Payload|Description| |--|--|--| |connect|-|When user has scanned QR Code with wallet app| |accept|{ data: 'ConnectionAcceptedNotification' \| '' }|When user has accepted wallet connection | |accountInfo|{ data: { address: string, balance: string }|When user has connected the wallet| |transfer|{ data: { tx_hash: string, tx_status: 'Accepted' \| 'Rejected' }|When user transfers NFT ownership to another wallet| |transaction|data: { tx_hash: string; tx_status: 'Accepted' \| 'Rejected' }|When user did a transaction (mint, burn, etc.)| |error|{ message: any }|When any error has occured| |reject|-|When user has rejected operation in wallet| |transactionReject|-|When user has rejected transaction in wallet| |connectionReject|-|When user has rejected connection in wallet|