• Stars
    star
    121
  • Rank 293,847 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utils library for contracts and tests

Build Status Coverage Status NPM Package

About

This repository contains frequently used smart contracts, libraries and interfaces. Also it contains utils which are used in tests.

Solidity

directory .sol description
contracts EthReceiver
contracts Permitable
contracts GasChecker
contracts/interfaces IDaiLikePermit Interface of token which has permit method like DAI token
contracts/interfaces IWETH WETH token interface
contracts/libraries AddressArray library for work with array of addresses
contracts/libraries AddressSet library for work with set of addresses
contracts/libraries RevertReasonParser library parse the message from reverted method to readble format
contracts/libraries StringUtil optimized methods to convert data to hex
contracts/libraries UniERC20

JS

module function descrption
asserts assertThrowsAsync(action, msg) checks the async function action() thrown with message msg
asserts assertRoughlyEqualValues(expected, actual, relativeDiff) checks the expected value is equal to actual value with relativeDiff precision
utils timeIncreaseTo(seconds) increases blockchain time to seconds sec
utils trackReceivedToken(token, wallet, txPromise, ...args) returns amount of token which recieved the wallet in async method txPromise with arguments args
utils trackReceivedTokenAndTx(token, wallet, txPromise, ...args) returns transaction info and amount of token which recieved the wallet in async method txPromise with arguments args
utils fixSignature(signature) patchs ganache's signature to geth's version
utils signMessage(signer, messageHex) signs messageHex with signer and patchs ganache's signature to geth's version
utils countInstructions(txHash, instruction) counts amount of instruction in transaction with txHash hash
utils deployAndGetContract(contractName, constructorArgs, deployments, deployer, deploymentName, skipVerify, skipIfAlreadyDeployed, gasPrice, maxPriorityFeePerGas, maxFeePerGas, log, waitConfirmations) deploys contract contractName as deploymentName if not skipIfAlreadyDeployed with constructorArgs from deployer using hardhat-deploy deployments with additional gas options gasPrice, maxPriorityFeePerGas and maxFeePerGas and outputs results to the console if log. Tries to verify it after waitConfirmations on Etherscan if not skipVerify.
profileEVM profileEVM(txHash, instruction, optionalTraceFile) the same as the countInstructions() with option of writing all trace to optionalTraceFile
profileEVM gasspectEVM(txHash, options, optionalTraceFile) returns all used operations in txHash transaction with options and their costs with option of writing all trace to optionalTraceFile

UTILS

Docify

Generates documentation in markdown format from natspec docs

Usage

Add to package.json file solidity compiler version and shortcut to run command

devDependencies section

"solc": "0.8.12",

scripts section

"docify": "npx solidity-utils-docify"

...

Dependencies list (imports-list)

Lists all imports recursively for the given solidity contract file.

Usage
npx imports-list -i <solidity file> [-a <alias list>]

Available parameters

Options:
  -i, --input <input>     file to get dependencies for
  -a, --alias [alias...]  projects alias list
  -h, --help              display help for command

Aliases are used to provide source code for third-party projects. For example, your contract uses imports from your other project and import is defined as

import "@1inch/otherproject/contracts/dependency.sol";

and you've got source code for @1inch/otherproject locally. Then you provide local path for the project to rip dependencies from dependency.sol as well. If there are several dependencies they should be provided using space as separator.

Example

File imports

#rootFile.sol
import '@1inch/otherproject/contracts/dependency.sol'

#@1inch/otherproject/contracts/dependency.sol
import 'helpers/helper.sol'

File and folder structure

rootFolder/

-- mainProject/
---- contracts/
------ rootFile.sol

-- dependencyProject/
---- helpers/
------ helper.sol
---- dependency.sol

Command

rootFolder/mainProject % npx imports-list -i './contracts/rootFile.sol' -a '@1inch/otherproject' '../dependencyProject'

Output

Project => root
not set

Project => @1inch/otherproject
../otherproject/contracts/dependency.sol
../otherproject/contracts/helpers/helper.sol

Test documentation generator (test-docgen)

Script generates documentation for tests in markdown format. Give descriptions for describe and it sections and build documentation using these descriptions.

Example

Test described as shown below

// Test suite
describe('My feature', function() {
    // Nested test suite
    describe("My subfeature", function() {
        /*
            **Test case 1**
            Test case should work
         */
        it("My case", function() {
        // code here
        })
    })
})

will generated the following output

# My feature

Test suite

## My subfeature

Nested test suite

### My case

**Test case 1**
Test case should work
Installation
  • Before use install documentation parser
yarn add acquit --dev
  • Optionally configure script for default usage. Add to script section in package.json
"test:docs": "npx test-docgen"
  • Optionally configure script for generating test list only. Add to script section in package.json
"test:docs": "npx test-docgen -l"
Usage

If script configured

yarn test:docs

or

npx test-docgen

Available parameters

Options:
  -i, --input <input>      tests directory (default: "test")
  -x, --exclude [exclude]  exclude directories and files. omit argument to exclude all subdirectories (default: false)
  -o, --output <output>    file to write output (default: "TESTS.md")
  -c, --code               include code (default: false)
  -l, --list               list tests only, do not include description (default: false)
  -d, --debug              debug mode (default: false)
  -h, --help               display help for command
Examples

Generate docs with default input and output

npx test-docgen

Generate docs for files in folders tests/mocks and tests/utils

npx test-docgen -i "tests/mocks;tests/utils"

Exclude from docs file test/mock-exclude.js and test/utils folder

npx test-docgen -x "tests/mock-exclude.js;tests/utils"

Generate list of tests only

npx test-docgen -l

More Repositories

1

shieldy

@shieldy_bot Telegram bot repository
TypeScript
793
star
2

1inchProtocol

1inch Protocol โ€“ fully on-chain DeFi aggregation protocol
Solidity
565
star
3

spot-price-aggregator

Liquidity-weighted dex price oracle for offchain price discovery
JavaScript
163
star
4

limit-order-protocol

JavaScript
152
star
5

1inch-token

Solidity
114
star
6

mooniswap

Mooniswap
JavaScript
108
star
7

chi

Chi Gastoken by 1inch
Solidity
98
star
8

farming

JavaScript
97
star
9

multicall

TypeScript
82
star
10

liquidity-protocol

JavaScript
81
star
11

1inch-v2-contracts

Solidity
63
star
12

merkle-distribution

JavaScript
53
star
13

token-plugins

JavaScript
48
star
14

1IPs

48
star
15

limit-order-protocol-utils

TypeScript
43
star
16

1inch-docs

CSS
41
star
17

1inch-audits

38
star
18

limit-order-settlement

JavaScript
36
star
19

gDAI.io

gDAI - Gas less DAI transfers by using GSN, Fulcrum and KyberNetwork
TypeScript
32
star
20

gnosis.1inch.exchange

Gnosis 1inch dApp
TypeScript
31
star
21

permit-signed-approvals-utils

TypeScript
25
star
22

fusion-sdk

TypeScript
25
star
23

dexcandles

DEX trades candles (5m/15m/1h/4h/1d/1w)
TypeScript
21
star
24

evm-helpers

Solidity
17
star
25

solidity-dispatcher-miner

Rust
16
star
26

QRToken

Token Drop in Real World
TypeScript
10
star
27

1lend.io

Cryptocurrency lending aggregator
TypeScript
9
star
28

BEARROWING

Borrowing aggregator
Solidity
9
star
29

solidity-audit-checklist

9
star
30

approved.zone

Ethereum smart contracts approvals dashboard
TypeScript
9
star
31

fixed-rate-swap

JavaScript
8
star
32

1x.ag

Leverage aggregator
TypeScript
8
star
33

fusion-resolver-example

TypeScript
8
star
34

1inch-sdk-go

SDK of 1inch APIs for golang
Go
8
star
35

embedded-widget

TypeScript
7
star
36

ERC3652

Solidity
7
star
37

governance-contracts

JavaScript
7
star
38

limit-order-sdk-py

1inch Limit Order Protocol v4 SDK Python
Python
7
star
39

st1inch

Solidity
7
star
40

fusion-101

1inch Fusion 101: Basic how-to examples for public workshops
TypeScript
6
star
41

delegating

JavaScript
6
star
42

evm-trace

JavaScript
6
star
43

MultiKyber

Kyber smart contract wrapper for cTokens, iTokens and sTokens native support
Solidity
6
star
44

calldata-compressor

JavaScript
5
star
45

penetration-tools

Tools repository for penetration tools
5
star
46

1hop

CDP migration aggregator
TypeScript
5
star
47

1inch-uni-addresses

5
star
48

address-token-miner

Rust
5
star
49

address-token

JavaScript
4
star
50

nuTube.network

Incentivized, decentralized livestream p2p network
TypeScript
4
star
51

desktop-dapp

Desktop version of app.1inch.io
TypeScript
4
star
52

candles-subgraph

TypeScript
4
star
53

LimitSwapSubgraph

TypeScript
3
star
54

solidity-selector-miner

Rust
2
star
55

1inch-airdrop

Python
2
star
56

fee-collector

JavaScript
2
star
57

jobocar

Self Sharing Car - Jobocar
TypeScript
2
star
58

VIC.cards

ยซVery Important Contact Cardsยป to prioritise you communications
TypeScript
2
star
59

BalancerRegistry

0x65e67cbc342712df67494acefc06fe951ee93982
Solidity
2
star
60

limit-order-parser

TypeScript
2
star
61

Donatocracy

JavaScript
1
star
62

dev-portal-101

101 for developer portal
TypeScript
1
star
63

paymaster-zksync

JavaScript
1
star
64

1inch-liquidity-protocol-audits

1
star
65

Arweavify

Chrome plugin for Arweave relayers verification
JavaScript
1
star
66

cross-chain-sdk

TypeScript
1
star
67

vested-token

Solidity
1
star
68

cross-chain-swap

Solidity
1
star
69

dev-portal-apis-examples

We are giving you a hands-on experience of how the Web3 APIs can be used to create engaging and dynamic decentralized applications.
1
star