0.2.1 • Published 2 years ago

signer-interface v0.2.1

Weekly downloads
-
License
GPL-3.0-only
Repository
-
Last release
2 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

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.4

2 years ago

0.1.5

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

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

0.0.0

2 years ago

0.0.21

2 years ago