0.0.48 • Published 2 years ago

@cryptolions/ulm-eosio v0.0.48

Weekly downloads
21
License
-
Repository
-
Last release
2 years ago

Login with popular EOS wallets

Module dependencies

scatter-core
scatterjs-plugin-eosjs
eosjs@20.0.0
@waxio/waxjs@0.0.11
anchor-link@2.0.1

Installation

// better utilize node v14.20
npm i --save @cryptolions/ulm-eosio

Patch for scatter libs compatible with your angular app

// put the code below in patch.js in root of your project and (node patch.js)
const fs = require('fs');
const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';

fs.readFile(f, 'utf8', function (err,data) {
  if (err) {
    return console.log(err);
  }
  var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}');

  fs.writeFile(f, result, 'utf8', function (err) {
    if (err) return console.log(err);
  });
});

Usage

app.module.ts

import { LoginEOSModule } from '@cryptolions/ulm-eosio';

...
// @NgModule config example
LoginEOSModule.forRoot({
          appName: 'your_app_name',
          httpEndpoint: 'https://bp.cryptolions.io',
          chain: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
          verbose: false,
          blockchain: 'eos',
          host: 'bp.cryptolions.io',
          port: 443,
          protocol: 'https',
          expireInSeconds: 5
    }),
...

app.component.html

<app-login-eos></app-login-eos>

login.component.ts

import { Component, OnInit } from '@angular/core';
import { LoginEOSService } from '@cryptolions/ulm-eosio';

@Component({
  selector: 'login',
  templateUrl: './login.component.html'
})
export class LoginComponent {
  constructor(public loginEOSService: LoginEOSService){}
}

login.component.html

// example of login/logout button
 <a class="" (click)="loginEOSService.openPopup()" *ngIf="!loginEOSService.connected">Login</a>
 <a class="" (click)="loginEOSService.logout()" *ngIf="loginEOSService.connected">Logout</a>

Events

// you can subscribe for loggedin events
this.loginEOSService.loggedIn.subscribe(res => {
        // do something
});

Example of usage with transaction

this.loginEOSService.eos.transaction({
      actions: [{ 'your actions' }]
    }, {
      blocksBehind: 'your blocksBehind',
      expireSeconds: 'your expireSeconds',
    }).then((result: any) => {
      // do something
    }).catch(err => {
      this.loginEOSService.contractError(err);
    });

Example of usage with get_table_rows

this.loginEOSService.rpc.get_table_rows({
  'your data'
}).then((result: any) => {
  // do something
}).catch(err => {
  this.loginEOSService.contractError(err);
});

Show messages

this.loginEOSService.contractError(err);
this.loginEOSService.showMessage('your message text');

Important notes

- ledger only works on sites that use https
- in order to use WAX Cloud Wallet, WAX (uppercase!) must be present in the appName
- in order to use MYKEY, EOS (uppercase!) must be present in the appName
- in order to use Proton Wallet, XPR (uppercase!) must be present in the appName

Testing with private key

// add to localstorage
account: '${your_name}'
privateKey: '${your_private_key}'
walletConnected: 'connected'
0.0.48

2 years ago

0.0.47

4 years ago

0.0.46

4 years ago

0.0.45

4 years ago

0.0.42

4 years ago

0.0.43

4 years ago

0.0.44

4 years ago

0.0.41

4 years ago

0.0.40

5 years ago

0.0.39

5 years ago

0.0.38

5 years ago

0.0.37

5 years ago

0.0.36

5 years ago

0.0.35

5 years ago

0.0.34

5 years ago

0.0.33

5 years ago

0.0.32

5 years ago

0.0.30

5 years ago

0.0.31

5 years ago

0.0.29

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.20

5 years ago

0.0.21

5 years ago

0.0.22

5 years ago

0.0.23

5 years ago

0.0.24

5 years ago

0.0.25

5 years ago

0.0.26

5 years ago

0.0.18

5 years ago

0.0.19

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.10

5 years ago

0.0.11

5 years ago

0.0.12

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.5

5 years ago

0.0.6

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago