Skip to content

Commit

Permalink
2.4.0-rc-1 (#117)
Browse files Browse the repository at this point in the history
* adds hardhat

* add proper hardhat.config.js

* replace compilation scripts

* remove truffle workflow-compile dependency

* remove custom contracts

* create a web3-type generator

* make it so generation of abi typings supports hardhat compilation as well

* removes old interface methods, remove uneeded use-model, changes source to work with latest web3js

* testing starts

* tsc builds

* tests run, albeit breaking

* web3-connection spec fixes

* re-writing deploy fn

* fixes and fixes for e2e to properly work with web3js

* e2e passes :)

* and now for all other models as well

* lint, package name change and version

* restructure contracts

* remove npm run watch from docker as it was abandoned

* fix paths on docker-compose.yml and add npm run docs to Dockerfile

* add more models to README.md (missing some example usage)

* make model loadAbi so we don't have to do that on deployjson because its tedious and add links to the model on the sdk in the README.md

* link icons to correct repo

* restructure test-utils folder

* change .env.dist to match actual values that are used also on hardhat.confgi.js

* more readme nudges

* link CONTRIBUTING.md to contributing how-to folder

* more links on readme.md

* remove v1 contracts and models

* clean some dead code [left behind methods and events, for next cleanup]

* remove dupe package list

* removes overrides and fixes homepage

* adds missing types

* fixes imports on contracts

* more import fixes

* try writing the keys secret to a file before starting the ci

* secretS

* ... the ci wars began, i guess

* add shell: bash

* no quotes

* setup node and checkout versions to 3

* ...cat it screw it

* use mnemonic instead of trying to create keys.json -.-'

* mention the most common package json scripts on the how-to/contributing readme

* remove file from yml and change getPrivateKey to work with mnemonic

* add cache to build and npm install, fix get-pvt-key-from-file

* github.sha ?

* revert yml because hardhat doesnt like to be cached

* add secret to yml

* echo the secret, just to be sure

* ... actually echo the thing -.-'

* missing .env

* default for accounts.mnemonic from hardhat

* restructure the utils folder into a "models-utils" and "simple utils"

* more restructuring, erc20 should use Ownable instead of Capped, cleaner will not clean dbg.json

* we have lift off

* gh action wars

* gh is winning

* remove with and .. tomorrow..

* twmp

* make registry start the token before deploying

* types

* add "confirmations" configuration to the web3contract

* lock openzepplin versions on package.json

* update ts version and regenerate abis

* update node-version on gh workflow

* add environment to workflow

* bite the bullet and write the test mnemonic on the workflow because gh wars

* fix test on network registry

* remove ipfs-wrapper

* remove ipfs-wrapper interfaces

* lint

* add missing dependency

* only pass parameters to toFixed if needs to be rounded, because toFixed add trailing zeros

* add default mnemonic

* add develop branch to github actions

---------

Co-authored-by: MoshMage <[email protected]>
  • Loading branch information
vhcsilva and moshmage authored Aug 22, 2024
1 parent 99fe6b6 commit 28bdcd5
Show file tree
Hide file tree
Showing 256 changed files with 7,675 additions and 41,816 deletions.
10 changes: 6 additions & 4 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Tests
WEB3_HOST_PROVIDER=
WALLET_PRIVATE_KEY=

DEBUG_TESTS=
# Chain rpc to use with the tests
CI_WEB3_HOST_PROVIDER=

# Memnonic phrase (12 words) for CI to use as accounts
CI_MNEMONIC=
# If left empty, will default to hardhat default (test.... junk)
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
**/coverage/*
**/test/*
**/tooling/*
**/src/interfaces/methods/*
**/src/interfaces/generated/*
**/src/interfaces/events/*
8 changes: 5 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"parser": "@typescript-eslint/parser",
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {

"indent-legacy": ["error", 2, {
"FunctionDeclaration": {
"parameters": "first"
Expand All @@ -18,7 +17,9 @@
"camelcase": 0,
"no-underscore-dangle": 0,
"class-methods-use-this": 1,
"no-unused-vars": 1,
"no-unused-vars": 0,
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_" }],
"@typescript-eslint/no-non-null-assertion": 0,
"complexity": ["error", 4],
"max-len": [
"error",
Expand All @@ -37,7 +38,8 @@
"function-call-argument-newline": [
"error",
"consistent"
]
],
"@typescript-eslint/no-explicit-any": 0
},
"env": {
"browser": true,
Expand Down
20 changes: 2 additions & 18 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
---
name: Bragging rights
about: Create a pull request to improve something for bragging rights
labels: bug, needs-triage

---

** Relates to **
<!--
A link to the original issue _or_ a clear description of what this Pull request represents
-->



<!--
NOTE: Personal pull requests are considered FOSS and will not be monetarily rewarded
You will, however, win bragging rights. While those can't buy food, they are awesome.
-->
**Describe the PR**
<!-- A clear and concise description of what the PR is -->
10 changes: 7 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.15.0]
node-version: [21.1.0]
environment: [build]
environment: build
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -35,3 +38,4 @@ jobs:
run: npm run test-ci
env:
CI: true
CI_MNEMONIC: test test test test test test test test test test test junk
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
.env
.env*
!.env.dist
.idea
xunit.xml
build/
Expand Down
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
---
noteId: "0d1b7090b1d311eb8c4ed19e49359bd0"
tags: []

---

# Contributor's Guide

Welcome; we appreciate you and would like to thank you for contributing to our project. This document aims to facilitate the process and share with you some structure that hopefully will remove any roadblock.
Expand Down Expand Up @@ -70,4 +64,8 @@ $ git commit -m "MESSAGE"
$ git push origin master
```

---

[Read on how to create models and integration tests](./how-to/contributing);

If you have any comment or ideas in terms of making this process better, please let us know or submit a PR.
8 changes: 0 additions & 8 deletions DEPENDENCIES.md

This file was deleted.

9 changes: 1 addition & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.38.0/install.sh | b
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH

RUN apt-get -y update
RUN apt-get install -y g++ make python2
RUN update-alternatives --install /usr/bin/python python /usr/bin/python2 1
RUN update-alternatives --config python
RUN npm config set python python

WORKDIR /app

COPY package*.json ./
Expand All @@ -47,5 +41,4 @@ COPY . .

RUN npm run-script build

EXPOSE 9012
CMD npm run watch
RUN npm run-script docs
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ up:
down:
@docker-compose -p ${PROJECT_NAME} down

## watch - Watch and build files
watch:
@docker-compose -p ${PROJECT_NAME} up

## build - Build images.
build:
@docker-compose -p ${PROJECT_NAME} build
Expand All @@ -55,6 +51,6 @@ build:
test:
@docker-compose -p ${PROJECT_NAME} exec bepro npm run test

## ganache.start - Start ganache
ganache.start:
@docker-compose -p ${PROJECT_NAME} exec bepro npm run ganache:start
## hardhat.start - Start hardhat node
hardhat.start:
@docker-compose -p ${PROJECT_NAME} exec bepro npm run hardhat:start
86 changes: 58 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# dappkit
A javascript SDK for web3 projects with curated community contracts to ease development and interactions with blockchain contracts.

![Build Status](https://img.shields.io/github/actions/workflow/status/taikai/dappkit/integration-tests.yml)
[![GitHub issues](https://img.shields.io/github/issues/taikai/dappkit)](https://GitHub.com/taikai/dappkit/issues/)
![Build Status](https://img.shields.io/github/actions/workflow/status/layerx-labs/dappkit/integration-tests.yml)
[![GitHub issues](https://img.shields.io/github/issues/layerx-labs/dappkit)](https://GitHub.com/taikai/dappkit/issues/)
![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)
[![License](https://img.shields.io/badge/license-ISC-blue.svg)](https://opensource.org/licenses/ISC)

Expand All @@ -14,53 +14,83 @@ $ npm install @taikai/dappkit
```

## Usage
`dappkit` offers tokens ([ERC20](https://sdk.dappkit.dev/classes/ERC20.html), [ERC721](https://sdk.dappkit.dev/classes/Erc721Standard.html), [ERC1155](https://sdk.dappkit.dev/classes/ERC1155Ownable.html) and [ERC4626](https://sdk.dappkit.dev/classes/ERC4626.html)) along with some other contracts, such as [Staking](https://sdk.dappkit.dev/classes/StakingContract.html) and [Voting](https://sdk.dappkit.dev/classes/Votable.html), for ease of use. you can check all the models over at the [SDK Documentation](https://sdk.dappkit.dev/).

### Simple browser connection
```ts
import {ERC20} from '@taikai/dappkit';
import {Web3Connection} from '@layerx-labs/dappkit';

const erc20 = new ERC20({ web3Host: process.env.WEB3_HOST_PROVIDER });
const web3Connection = new Web3Connection({web3Host: 'https://rpc.tld'});
await web3Connection.connect();

console.log(`Address`, await web3Connection.getAddress());
```

await erc20.connect(); // connect web3 by asking the user to allow the connection and interact with the chain
It's possible to provide [more options](https://sdk.dappkit.dev/interfaces/Web3ConnectionOptions.html) (such as `privateKey`) to the `Web3Connection` class.
> Note: a Server side connection does not need to call `connect()` and should _when needed_ provide a `privateKey`
const tx =
await erc20Deployer.deployJsonAbi(
'Token Name', // the name of the token
'$tokenSymbol', // the symbol of the token
"1000000000000000000000000", // the total amount of the token (with 18 decimals; 1M = 1000000000000000000000000)
"0xOwnerOfErc20Address" // the owner of the total amount of the tokens (your address)
);
### Creating ERC20 tokens

await erc20.transfer('0xYourOtherAddress', 1); // transfer 1 token from your address to other address
console.log(await erc20.balanceOf('0xYourOtherAddress')) // 1
```ts
import {ERC20} from '@layerx-labs/dappkit';

const erc20 = new ERC20({ web3Host: 'http://rpc.tld' });

await erc20.deployJsonAbi(
'Token Name', // the name of the token
'$tokenSymbol', // the symbol of the token
"1000000000000000000000000", // the total amount of the token (with 18 decimals; 1M = 1000000000000000000000000)
"0xOwnerOfErc20Address" // the owner of the total amount of the tokens (your address)
);

console.log(`ERC20 address`, erc20.contractAddress);
```
> Note: Full model documentation [on the sdk](https://sdk.dappkit.dev/classes/ERC20.html)
### Just want to start a connection?
### Creating ERC721 NFTs

```ts
import {Web3Connection} from '@taikai/dappkit';
import {ERC721Collectibles} from '@layerx-labs/dappkit'

const web3Connection = new Web3Connection({web3Host: 'https://rpc.tld'});
const erc721 = new ERC721Collectibles({web3Host: 'http://rpc.tld'});

await web3Connection.connect();
await erc721.deployJsonAbi(
`Token Name`,
`$token_symbol`,
1, // how many packs can be open of this collectible (0 = infinite)
`0xAddressOfPurchasingAddress`, // address of the erc20 used to open packs
`0xBaseFeeAddress`, // address for where the main fee goes
`0xFeeAddress`, // address for where fee from purchases and pack shares
`0xAnotherAddress`); // adress for pack shares fee

console.log(`Address`, await web3Connection.getAddress());
console.log(`ERC721 address`, erc721.contractAddress)
```
> Note: Full model documentation [on the sdk](https://sdk.dappkit.dev/classes/ERC721Collectibles.html)
### Server side?
### Creating ERC1155

```ts
import {Web3Connection, Web3ConnectionOptions} from '@taikai/dappkit';
import {ERC1155Ownable} from "@layerx-labs/dappkit";

const web3ConnecitonOptions: Web3ConnectionOptions = {
web3Host: 'https://rpc.tld',
// no need to provide privateKey for read-only
privateKey: 'your-private-key', // never share your private key
}
const erc1155 = new ERC1155Ownable({web3Host: 'http://rpc.tld'});

const web3Connection = new Web3Connection(web3ConnecitonOptions);
await erc1155.deployJsonAbi('http://my.token-uri.tld/');

console.log(`Address`, await web3Connection.getAddress());
console.log(`ERC1155 address`, erc1155.contractAddress);
```
> Note: Full model documentation [on the sdk](https://sdk.dappkit.dev/classes/ERC1155Ownable.html)
### Creating ERC4626
```ts
import {ERC4626} from "@layerx-labs/dappkit";

const erc4626 = new ERC4626({web3Host: 'http://rpc.tld'})

await erc4626.deployJsonAbi(`0xUnderlyingERC20Address`, `Vault Name`, `$vault_symbol`);

console.log(`ERC4626 address `, erc4626.contractAddress);
```
> Note: Full model documentation [on the sdk](https://sdk.dappkit.dev/classes/ERC4626.html)
## Documentation

Expand Down
23 changes: 0 additions & 23 deletions contracts/ERC1155Standard.sol

This file was deleted.

49 changes: 0 additions & 49 deletions contracts/ERC20.sol

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/ERC20LM.sol

This file was deleted.

Loading

0 comments on commit 28bdcd5

Please sign in to comment.