Socket
Book a DemoInstallSign in
Socket

@circles/transfer

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@circles/transfer

Find maximum flow and transitive transfers steps in a trust graph

Source
npmnpm
Version
0.1.0
Version published
Maintainers
2
Created
Source

Circles Transfer

License Build Status Follow Circles

Utility module for Circles to find the Maximum flow and necessary transitive transfers steps in a trust graph with multiple tokens.

Requirements

  • NodeJS

Installation

npm i @circles/transfer

Usage

import findTransitiveTransfer from '@circles/transfer';

// Define a weighted trust graph between trusted tokens. Each edge describes
// how much ("capacity") of what token ("token") can be sent from which node
// ("from") to which ("to"):
const nodes = [
  'A',
  'B',
  'C',
  'D',
];

const edges = [
  {
    from: 'A',
    to: 'B',
    token: 'A',
    capacity: 10,
  },
  {
    from: 'B',
    to: 'C',
    token: 'B',
    capacity: 7,
  },
  {
    from: 'B',
    to: 'C',
    token: 'C',
    capacity: 5,
  },
  ...
];

// Find required transfer steps to send transfer transitively between two nodes:
const { transferSteps, maxFlowValue } = findTransitiveTransfer({
  nodes,
  edges,
  from: 'A',
  to: 'D',
  value: 5,
});

// ... we get the maximum possible value:
console.log(`Can send max. ${maxFlowValue} between A and D`);

// ... and finally the transfer steps:
transferSteps.forEach(({ step, from, to, value, token }) => {
  console.log(`${step}.: Send ${value} of ${token} from ${from} to ${to}`);
});

Development

circles-transfer is a JavaScript module written in JavaScript, tested with Jest, transpiled with Babel and bundled with Rollup.

// Install dependencies
npm install

// Run test suite
npm run test
npm run test:watch

// Check code formatting
npm run lint

// Build it!
npm run build

License

GNU Affero General Public License v3.0 AGPL-3.0

FAQs

Package last updated on 17 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts