0.2.1 • Published 3 years ago

signer-interface v0.2.1

Weekly downloads
-
License
GPL-3.0-only
Repository
-
Last release
3 years ago

Manta Signer Interface

An interface to simplify interacting with Manta Signer

Installation

yarn add signer-interface

Usage

Initialization

// get an instance of polkadot.js api
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = new ApiPromise({ provider, types, rpc: jsonrpc });
await api.isReady;

// Create a config deppending on your environment
import {
  BrowserSignerInterfaceConfig,
  NodeJsSignerInterfaceConfig
} from 'signer-interface';

const config = NodeJsSignerInterfaceConfig(
  1, // testnet
  'http://localhost:29986', // default Manta Signer url
  'User1'
);
const signerInterface = new SignerInterface(api, config);

Recovering (or refreshing) a wallet

// returns an array of ClientAsset
const myRecoveredAssets = signerInterface.recoverAccount();

Doing a private transfer (or reclaim, similarly)

// The transfer you want to do
const assetId = 1;
const targetValue = 100;
const receivingAddress = 'AAAAAAABBBBBBCCCCCCCDDDDDD...';

// install 'manta-coin-selection' with yarn
import { selectCoins, CoinSelection } from 'manta-coin-selection';

// returns a `CoinSelection`, which contains the selected coins and associated metadata
const coinSelection = selectCoins(targetValue, myRecoveredAssets, assetId);

const transaction = await signerInterface.buildExternalPrivateTransferTxs(
  receivingAddress,
  coinSelection
);

// Submit the transaction using polkadot.js

// wait ...

// If transaction fails, run:
signerInterface.cleanupTxFailure();

// If transaction succeeds, run:
signerInterface.cleanupTxSuccess();
0.0.22

4 years ago

0.2.1

3 years ago

0.2.0

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago

0.0.21

4 years ago