0.2.1 • Published 5 years ago

@kosu/create-portal-helper v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Create

Kind: global class

new Create()

create.init()

Kind: instance method of Create

create.createAndSignOrder(options)

Kind: instance method of Create

ParamTypeDescription
optionsobjectobject 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
ParamTypeDescription
signedZeroExOrderobjectas outputted from createAndSignOrder

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

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

ParamTypeDescription
etherAmountstring | BigNumbera 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

ParamTypeDescription
weiAmountstring | BigNumbera 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

ParamTypeDescription
addressstringa 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

ParamTypeDescription
userAddressstringcan 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)

ParamTypeDescription
txIDstring32 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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
userAddressstringoverride user's detected coinbase address

create.setProxyAllowanceWeth(userAddress) ⇒ string

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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
userAddressstringoverride 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

ParamTypeDescription
tokenAddressstring0x-prefixed address of the custom token
userAddressstringoverride 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

ParamTypeDescription
tokenAddressstring0x-prefixed address of the custom token
userAddressstringoverride 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

ParamTypeDescription
tokenAddressstring0x-prefixed address of the custom token
userAddressstringoverride user's detected coinbase address

Example

await create.setProxyAllowanceCustom("0x4f833a24e1f95d70f028921e27040ca56e09ab0b");
0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.1.0-alpha.8

5 years ago

0.1.0-alpha.7

5 years ago

0.1.0-alpha.6

5 years ago

0.1.0-alpha.5

5 years ago

0.1.0-alpha.4

5 years ago

0.1.0-alpha.3

5 years ago

0.1.0-alpha.2

5 years ago

0.1.0-alpha.1

5 years ago