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

@kosu/create-portal-helper

v0.2.1

Published

Abstraction library for simplifying web-portal interactions.

Downloads

4

Readme

Create

Kind: global class

new Create()

create.init()

Kind: instance method of Create

create.createAndSignOrder(options)

Kind: instance method of Create

| Param | Type | Description | | ------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | options | object | object with the following properties: makerAssetAddress: either ("WETH/DAI/ZRX") or a full 42 char hex address takerAssetAddress: either ("WETH/DAI/ZRX") or a full 42 char hex address makerAssetAmount: units are wei, value can be string/number or BigNumber takerAssetAmount: units are wei, value can be string/number or BigNumber orderDuration: the number of seconds the order should be valid for makerAddress: can be provided to override coinbase, but shouldn't |

Example

// create an order for 0.5 WETH <> 80 custom token, valid for 10 minutes
let order = await create.createAndSignOrder({
    makerAssetAddress: "WETH",
    takerAssetAddress: "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
    makerAssetAmount: create.convertToWei("0.5"),
    takerAssetAmount: create.convertToWei("80"),
    orderDuration: 600,
});

create.signAndPost(signedZeroExOrder)

Kind: instance method of Create
Todo:: - undo split-network ugly-ness

  • don't pull makerArguments from subcontract if provided
  • ability to use direct kosu.js to sign

| Param | Type | Description | | ----------------- | ------------------- | -------------------------------------------------------- | | signedZeroExOrder | object | as outputted from createAndSignOrder |

create.convertToWei(etherAmount) ⇒ Promise.<string>

Kind: instance method of Create
Returns: Promise.<string> - the same amount in wei

| Param | Type | Description | | ----------- | --------------------------------------------- | ----------------------------------------------- | | etherAmount | string | BigNumber | a number of tokens in full units (ether) |

Example

// convert 100 tokens (as entered by user) to wei
create.convertToWei("100"); // > "100000000000000000000" (BigNumber)
create.convertToWei(100); // > "100000000000000000000" (BigNumber)

create.convertFromWei(weiAmount) ⇒ Promise.<string>

Kind: instance method of Create
Returns: Promise.<string> - the same amount in ether

| Param | Type | Description | | --------- | --------------------------------------------- | ------------------------------------------------- | | weiAmount | string | BigNumber | a number of tokens in smallest units (wei) |

Example

// convert 100 tokens (as received as balance or allowance) to tokens
create.convertToWei("100000000000000000000"); // > "100" (BigNumber)
create.convertToWei(100000000000000000000); // > "100" (BigNumber)

create.isValidAddress(address) ⇒ boolean

Kind: instance method of Create
Returns: boolean - true if valid Ethereum address, otherwise false

| Param | Type | Description | | ------- | ------------------- | ------------------------------------------------------ | | address | string | a string to be validated as an Ethereum address |

Example

create.isValidAddress("0x4f833a24e1f95d70f028921e27040ca56e09ab0b"); // > true
create.isValidAddress("4f833a24e1f95d70f028921e27040ca56e09ab0b"); // > false
create.isValidAddress("0x4f833a24e1f95d70f028921e27040ca56e09ab0"); // > false

create.userHasBond(userAddress) ⇒ Promise.<boolean>

Kind: instance method of Create
Returns: Promise.<boolean> - true if user has active bond, false otherwise

| Param | Type | Description | | ----------- | ------------------- | ---------------------------------------------------------- | | userAddress | string | can be provided to override coinbase, but shouldn't |

create.awaitTransactionSuccessOrThrow(txID) ⇒

Kind: instance method of Create
Returns: the full decoded transaction receipt (usually will not need)

| Param | Type | Description | | ----- | ------------------- | ----------------------------------------------------- | | txID | string | 32 byte (64-char) 0x-prefixed transaction hash |

Example

const txId = await create.setProxyAllowanceWeth();

// wait for the transaction to be mined, show loading icon, etc.
await create.awaitTransactionSuccessOrThrow(txId);

create.getUserWethBalance(userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's WETH balance in wei

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.getUserWethAllowance(userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's 0x proxy WETH allowance in wei

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.setProxyAllowanceWeth(userAddress) ⇒ string

Kind: instance method of Create
Returns: string - the transaction hash of the resulting tx

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.getUserZrxBalance(userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's ZRX balance in wei

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.getUserZrxAllowance(userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's 0x proxy ZRX allowance in wei

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.setProxyAllowanceZrx(userAddress) ⇒ Promise.<string>

Kind: instance method of Create
Returns: Promise.<string> - the transaction hash of the resulting tx

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.getUserDaiBalance(userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's DAI balance in wei

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.getUserDaiAllowance(userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's 0x proxy DAI allowance in wei

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.setProxyAllowanceDai(userAddress) ⇒ Promise.<string>

Kind: instance method of Create
Returns: Promise.<string> - the transaction hash of the resulting tx

| Param | Type | Description | | ----------- | ------------------- | ------------------------------------------------ | | userAddress | string | override user's detected coinbase address |

create.getUserCustomBalance(tokenAddress, userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's balance in wei of custom token

| Param | Type | Description | | ------------ | ------------------- | ------------------------------------------------ | | tokenAddress | string | 0x-prefixed address of the custom token | | userAddress | string | override user's detected coinbase address |

Example

const balance = await create.getUserCustomBalance("0x4f833a24e1f95d70f028921e27040ca56e09ab0b");

create.getUserCustomAllowance(tokenAddress, userAddress) ⇒ Promise.<BigNumber>

Kind: instance method of Create
Returns: Promise.<BigNumber> - the user's 0x proxy allowance in wei for custom token

| Param | Type | Description | | ------------ | ------------------- | ------------------------------------------------ | | tokenAddress | string | 0x-prefixed address of the custom token | | userAddress | string | override user's detected coinbase address |

Example

const allowance = await create.getUserCustomAllowance("0x4f833a24e1f95d70f028921e27040ca56e09ab0b");

create.setProxyAllowanceCustom(tokenAddress, userAddress) ⇒ Promise.<string>

Kind: instance method of Create
Returns: Promise.<string> - the transaction hash of the resulting tx

| Param | Type | Description | | ------------ | ------------------- | ------------------------------------------------ | | tokenAddress | string | 0x-prefixed address of the custom token | | userAddress | string | override user's detected coinbase address |

Example

await create.setProxyAllowanceCustom("0x4f833a24e1f95d70f028921e27040ca56e09ab0b");