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

wings-light-bridge

v1.2.10

Published

Wings easy integration.

Downloads

12

Readme

Wings Light Bridge

Wings easy integration.

Content

Initial setup

Crowdsale start

Bridge methods

Finishing Bridge

Requirements

  • Nodejs ~8.6.0
  • Truffle 4.0.4
  • Ganache-cli ^6.1.0

Step by step guide

In this tutorial we are going to walkthrough the Wings integration process.

1. Setup

Clone this repository.

git clone https://github.com/wingsdao/wings-light-bridge.git

2. Сonstructor

await deployer.deploy(Bridge, owner, manager, { from: creator })

Parameters:

  • owner - address - owner of Bridge
  • manager - address - could be either owner or DAO address (if already exists)

3. Deploy

Deploy Bridge contract to mainnet using truffle, parity, etc. with constructor arguments described above.


If you already created project on wings.ai head to ¶Crowdsale start.


4. Create project

Create project on Wings platform as custom contract and provide address of bridge contract.

Now we need to create project on Wings platform.

  1. Go to Wings project creating and select Custom Contract select custom contract
  2. In Project overview tab add Bridge contract address to Bridge contract address field add bridge contract address

After this step you can start your project's forecasting.



When the forecasting finish you have 45 days to start your project's crowdsale.


Crowdsale start

1. Find DAO address from url

To do it, just take URL of your project, like:

https://wings.ai/project/0x28e7f296570498f1182cf148034e818df723798a

As you see - 0x28e7f296570498f1182cf148034e818df723798a, it's your DAO contract address. You can check it via parity or some other ethereum client/tool. Account that you used during project creation on wings.ai is owner of this smart contract.

Initiate DAO contract with the address we just retrieved:

Here are artifacts for contracts and we recommend to use truffle contract library to make calls.

Here are interfaces for contracts.

const dao = await DAO.at('0x28e7f296570498f1182cf148034e818df723798a') // change with your DAO address

2. Transfer management to DAO

During forecasting period transfer manager to DAO contract.

Interface:

function transferManager(address _newManager) public;

Example:

await bridge.transferManager(dao.address, { from: yourAccount }) // change with your DAO address

To start crowdsale, complete the following steps.

3. Make a call to method createCustomCrowdsale in DAO contract

Make a call to method DAO.createCustomCrowdsale().

Interface:

function createCustomCrowdsale() public;

Example:

await dao.createCustomCrowdsale()

4. Find crowdsaleController address

Make a call to getter method DAO.crowdsaleController().

Interface:

function crowdsaleController() public view returns (address);

Example:

const ccAddress = await dao.crowdsaleController.call()
const crowdsaleController = await IWingsController.at(ccAddress)

5. Start crowdsale

To start your project's crowdsale (Bridge) you need to make a call to crowdsaleController's method start.

Interface:

function start(uint256 _startTimestamp, uint256 _endTimestamp, address _fundingAddress) public;

Parameters:

  • _startTimestamp - timestamp of the start of your crowdsale.
  • _endTimestamp - timestamp of the end of your crowdsale.
  • _fundingAddress - the address, which will receive funds

Example:

await crowdsaleController.start(0, 0, '0x0')

IMPORTANT: values like 0, 0, '0x0' for start works fine only if you are using bridge. If you've done full integration, you have to do it in another way.


After this step your crowdsale is taking place and you come back right before the end of crowdfunding to complete few final steps.


Bridge methods

getToken

If you need to check address of token contract which you specified during Bridge deploy, use getToken method.

function getToken() public view returns (address);

Returns:

  • address of token contract

changeToken

Please note that if you used DefaultToken you must change token address to the address of your real token contract which stores your project token rewards.

To change token address use changeToken method.

function changeToken(address _newToken) public onlyOwner() {
  token = IERC20(_newToken);
}

Parameters:

  • _newToken - address of new token contract

setCrowdsaleGoal (optional)

You can set and update crowdsale goals in the Bridge any time before the end of crowdsale.

function setCrowdsaleGoal(uint256 _minimalGoal, uint256 _hardCap) public;

Description:

  • Can be called any time before Bridge is finished.

Parameters:

  • _minimalGoal - uint256 - soft cap of crowdsale (in the same currency as the forecast question)
  • _hardCap - uint256 - hard cap of crowdsale (in the same currency as the forecast question)

Important: If collected minimal goal or hard cap is in normal currency (with 2 decimal places, e.g. USD) it should be padded to the number with 18 decimal places.
Example: If your hard cap is 1000000$ you will have to pass 1000000000000000000000000 as _hardCap.

NOTE: Hard cap must be greater then minimal goal. Minimal goal must be greater then 0.

setCrowdsalePeriod (optional)

You can set and update crowdsale time frame in the Bridge any time before the end of crowdsale.

function setCrowdsalePeriod(uint256 _startTimestamp, uint256 _endTimestamp) public;

Description:

  • Can be called any time before Bridge is finished.

Parameters:

  • _startTimestamp - uint256 - start of crowdsale (unix timestamp)
  • _endTimestamp - uint256 - end of crowdsale (unix timestamp)

NOTE: End timestamp must be greater then start timestamp. Start timestamp must be greater then 0.

withdraw

If some error occurred during token and/or ETH reward transfer to Bridge contract, you can use method withdraw to return funds.

function withdraw(uint256 _ethAmount, uint256 _tokenAmount) public;

Parameters:

  • _ethAmount - uint256 - amount of wei to withdraw
  • _tokenAmount - uint256 - amount of tokens (minimal value similar to wei in eth) to withdraw

Description:

  • Can be called any time before Bridge is finished.

Finishing Bridge

notifySale

When crowdsale is over, make a call to this method and pass as arguments collected ETH amount and how many tokens were sold.

function notifySale(uint256 _amount, uint256 _ethAmount, uint256 _tokensAmount) public;

Parameters:

  • _amount - total collected amount (in currency which you specified in forecasting question)
  • _ethAmount - amount of funds raised (in Wei) (0 if forecasting currency is ETH)
  • _tokensAmount - amount of tokens sold

Important: If collected amount is in normal currency (with 2 decimal places, e.g. USD) it should be padded to the number with 18 decimal places.
Example: If you have collected 1000$ and 14¢ you will have to pass 1000140000000000000000 as _totalCollected.

Important: _amount should be the same as the currency which was used in forecasting question. If you have collected funds in USD, pass USD collected amount (padded to 18 decimals) as _amount argument and its translated amount in ETH as _ethAmount argument.

NOTE: Every call to this method will override previous values.

calculateRewards

Communicates with CrowdsaleController (aka IWingsController) and calculates rewards.

function calculateRewards() public view returns (uint256, uint256);

Description:

  • Calculates rewards absolutely the same as it does the wings crowdsale controller.

Returns:

  • ethReward - ETH reward amount (in Wei)
  • tokenReward - token reward amount

Transferring rewards

And now, before making a call to finish method, make a call to method calculateRewards to find out the amount of rewards.

Important: Send token and ETH rewards to Bridge contract.

rewardsAreReady

Check whether rewards are ready and Bridge can be finished.

function rewardsAreReady() public;

Returns:

  • bool - whether Bridge contract contains rewards and is ready to be finished

finish

Call this method to stop Bridge.

function finish() public;

Description:

  • Checks if the Bridge balance has enough ETH and tokens for rewards.
  • Changes the state of crowdsale to completed.
  • If total collected amount is less then minimal goal - crowdsale status will evaluate to failed.

That's it. Crowdsale is finished.


Developing

We recommend to make pull requests to current repository. Each pull request should be covered with tests.

Fetch current repository, install dependencies:

npm install

We strongly recommend to develop using ganache-cli to save time and cost.

Testing

To run tests fetch current repository, install dependencies and run:

truffle test

Authors

Wings Stiftung

License

See in license file.