0.0.86 • Published 10 months ago

kriptou.js v0.0.86

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

NPM Package Version NPM Package Downloads Build Status

A library that gives you access to the underlying blockchain

  • all client side
  • no backend needed

Getting started

Initialise

Without configuration

Kriptou.init();

With configuration

Kriptou.init(
    {
        /**
         * The log level.
         */
        logger: {
            level: 'info'
        },

        /**
         * Chain/network configuration.
         */
        chain: {
            performValidation: boolean,
            delayValidation: boolean,
            supportedChains: [Kriptou.supportedNetworks.Rinkarby],
            walletNotConnectedHandler: () => {
                // When the wallet is not connected 
            },
            chainCheckFailedHandler: () => {
                // When the current Chain Id selected in the wallet needs to be changed
            },
            
            /**
             * Whether the page reloads when the chain/network has changed.
             */
            changeReloadEnabled: boolean
        },

        /**
         * Accounts configuration.
         */
        accounts: {
            /**
             * Whether the page reloads when the account has changed.
             *
             * When the `changeHandler` is configured this setting is ignored and the page reload will not execute.
             */
            changeReloadEnabled: boolean,

            /**
             * Handler to execute when the account has changed.
             *
             * When this handler is configured then the page will not auto reload, the developer will have to implement the
             * page-reload in the handler if this behaviour is required.
             */
            changeHandler: (accounts: Array<string>) => {
                // When the account has changed (accounts is string array of connected wallet addresses)
            }
        }
    }
);

Events

React to 'UserLoggedIn' event (async):

Kriptou.Events.subscribe(
    {
        listener: 'ListenerName ',
        event: Kriptou.events.UserLoggedIn
    },
    (user: Kriptou.Types.User) => {
        // do something with 'user'
    }
);

This subscribe method returns a Kriptou.Types.Subscription which can be used to unsubscribe again.

React to 'NetworkUpdated' event (async):

Kriptou.Events.subscribe(
    {
        listener: 'ListenerName',
        event: Kriptou.events.NetworkUpdated
    },
    (network: Kriptou.Types.Network | undefined) => {
        // do something with 'network', if undefined then selected network not supported
    }
);

This subscribe method returns a Kriptou.Types.Subscription which can be used to unsubscribe again.

Signature methods

sign

Calculates an Ethereum specific signature (web3.eth.personal.sign).

Kriptou.Signature.sign

verifySigner

Verifies whether the connected address (or the one provided as argument) signed the data with the sign method.

It uses the getSigner method under the hood.

Kriptou.Signature.verifySigner

getSigner

Gets the account (web3.eth.personal.ecRecover) that signed the data with the sign method.

Kriptou.Signature.getSigner

Wyvern Protocol

Documentation

Next steps

Connect wallet

[TBC]

Retrieve user

[TBC]

Switch network

[TBC]

Browser applications

Angular project

(This documentation should live in an angular seed project rather)

With a newly created angular project, with angular-cli, ensure the following configs:

webpack.config.js

Put this file in the root of your project:

const webpack = require('webpack');

module.exports = {
    node: {
        global: true
    },
    resolve: {
        fallback: {
            stream: require.resolve('stream-browserify'),
            crypto: require.resolve('crypto-browserify'),
            assert: require.resolve('assert/'),
            http: require.resolve('stream-http'),
            https: require.resolve('https-browserify'),
            os: require.resolve('os-browserify/browser'),
            path: require.resolve('path-browserify'),
            url: false,
            events: require.resolve('events/')
        }
    },
    plugins: [
        new webpack.ProvidePlugin({
            process: 'process/browser',
            Buffer: ['buffer', 'Buffer']
        })
    ]
};

Node modules

Dependencies:

npm i stream-browserify crypto-browserify assert stream-http https-browserify os-browserify path-browserify events

Dev dependencies:

npm i @angular-builders/custom-webpack process --save-dev
0.0.84

10 months ago

0.0.85

10 months ago

0.0.86

10 months ago

0.0.80

1 year ago

0.0.81

1 year ago

0.0.82

1 year ago

0.0.83

1 year ago

0.0.73

1 year ago

0.0.74

1 year ago

0.0.75

1 year ago

0.0.76

1 year ago

0.0.77

1 year ago

0.0.78

1 year ago

0.0.79

1 year ago

0.0.70

1 year ago

0.0.71

1 year ago

0.0.72

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.66

1 year ago

0.0.67

1 year ago

0.0.68

1 year ago

0.0.69

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.51

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.26

2 years ago

0.0.9

2 years ago

0.0.27

2 years ago

0.0.8

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago