npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@identity.com/gateway-evm-ts-client

v0.1.4

Published

Adapter library for Identity.com gateway token system on Ethereum

Downloads

24

Readme

gateway-eth-ts

Version Downloads/week License

Gateway ETH TS library

This client library allows JS/TS applications to communicate with Gateway token system on Ethereum blockchain. Common methods include validation of existing tokens, new gateway token issuance, token freezing/unfreezing and revocation.

Installation

yarn add @identity.com/gateway-evm-ts-client

Metamask integration example

import {
  GatewayTs,
} from "@identity.com/gateway-evm-ts-client";
import {
  getDefaultProvider,
  Wallet,
  providers
} = from 'ethers';
import { useWallet } from 'use-wallet';


(async function() {
  const { ethereum } = useWallet();
  const chainId = Number(ethereum.chainId);
  const provider = new ethers.providers.Web3Provider(
      ethereum,
      chainId
  );
  const signer = provider.getSigner();
  const network = await provider.getNetwork();
  const gateway = new GatewayTs(gatekeeper, network, DEFAULT_GATEWAY_TOKEN_ADDRESS);
  const testUser = '0xD42Ef952F2EA1E77a8b771884f15Bf20e35cF85f';
  await (await gateway.issue(testUser)).wait();
})();

Utility functions

Token bitmask construction

The easiest way to associate certain flags with the gateway token is by using list of supported KYC flags, and addFlagsToBitmask function.

  flags = [KYCFlags.IDCOM_1];
  bitmask = addFlagsToBitmask(bitmask, flags);

Examples

Charges

Charging in Eth:

// when charging in ETH - the gatekeeper cannot send the transaction directly
// Use GatewayTsTransaction to generate a transaction that can be sent to the client
const gateway = new GatewayTsTransaction(
    gatekeeper,
    DEFAULT_GATEWAY_TOKEN_ADDRESS
);
const charge = makeWeiCharge(chargeValue, recipientAddress);
const tx = gateway.issue(wallet, gatekeeperNetwork, undefined, undefined, charge)

// send tx to the user to sign and send

Charging in ERC20:

const charge = makeERC20Charge(
    chargeValue,
    erc20TokenAddress,
    userAddress,
    recipientAddress
);
const approvalTx = await approveERC20Charge(
    charge,
    provider
);
const internalApproveTx = await approveInternalERC20Charge(
    charge,
    gatekeeperNetwork,
    provider
);
// send approvalTx and approveInternalTx to the user to sign
// once the user has signed the above transactions

const gateway = new GatewayTs(
    gatekeeper,
    DEFAULT_GATEWAY_TOKEN_ADDRESS
);

await gateway.issue(wallet, gatekeeperNetwork, undefined, undefined, charge)

);

Running Test Suite

We currently use a local node (either foundry or hardhat) with a fork from the bsc testnet contract deployments for our test. To run the test suite locally you must specify the $RPC_URL enviornment variable to a bsc testnet node.