refactor: typescript refactoring ♻️

This commit is contained in:
PedroCailleret 2022-11-14 09:34:53 -03:00
parent 67f9cbb9a7
commit b1fe0a574c
91 changed files with 19768 additions and 30240 deletions

2
.commitlintrc.yaml Normal file
View File

@ -0,0 +1,2 @@
extends:
- "@commitlint/config-conventional"

3
.czrc Normal file
View File

@ -0,0 +1,3 @@
{
"path": "cz-conventional-changelog"
}

16
.editorconfig Normal file
View File

@ -0,0 +1,16 @@
# EditorConfig http://EditorConfig.org
# top-most EditorConfig file
root = true
# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.sol]
indent_size = 4

9
.env.example Normal file
View File

@ -0,0 +1,9 @@
INFURA_API_KEY="{INSERT_API_KEY}"
MNEMONIC="{INSERT_12_WORD_MNEMONIC}"
# Block explorer API keys
ETHERSCAN_API_KEY="{INSERT_API_KEY}"
GASPRICE_API_ENDPOINT="https://api.etherscan.io/api?module=proxy&action=eth_gasPrice"
COINMARKETCAP_API_KEY="{INSERT_API_KEY}"
REPORT_GAS="true"

21
.eslintignore Normal file
View File

@ -0,0 +1,21 @@
# directories
.yarn/
**/.coverage_artifacts
**/.coverage_cache
**/.coverage_contracts
**/artifacts
**/build
**/cache
**/coverage
**/dist
**/node_modules
**/types
# files
*.env
*.log
.pnp.*
coverage.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*

21
.eslintrc.yaml Normal file
View File

@ -0,0 +1,21 @@
extends:
- "eslint:recommended"
- "plugin:@typescript-eslint/eslint-recommended"
- "plugin:@typescript-eslint/recommended"
- "prettier"
parser: "@typescript-eslint/parser"
parserOptions:
project: "./tsconfig.json"
plugins:
- "@typescript-eslint"
root: true
rules:
"@typescript-eslint/no-floating-promises":
- error
- ignoreIIFE: true
ignoreVoid: true
"@typescript-eslint/no-inferrable-types": "off"
"@typescript-eslint/no-unused-vars":
- error
- argsIgnorePattern: "_"
varsIgnorePattern: "_"

35
.gitignore vendored
View File

@ -1,9 +1,28 @@
node_modules
.env
coverage
coverage.json
#Hardhat files
cache
# directories
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
# **/artifacts
artifacts/@openzeppelin
artifacts/build-info
artifacts/@openzeppelin
**/build
**/ref
**/cache
**/coverage
**/.coverage_artifacts
**/.coverage_cache
**/.coverage_contracts
**/dist
**/node_modules
# files
*.env
*.log
.pnp.*
coverage.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*

1
.husky/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
_

4
.husky/commit-msg Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn dlx commitlint --edit $1

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn dlx lint-staged

5
.lintstagedrc Normal file
View File

@ -0,0 +1,5 @@
{
"*.{js,json,md,sol,ts,yaml,yml}": [
"prettier --config ./.prettierrc.yaml --write"
]
}

21
.prettierignore Normal file
View File

@ -0,0 +1,21 @@
# directories
.yarn/
**/.coverage_artifacts
**/.coverage_cache
**/.coverage_contracts
**/artifacts
**/build
**/cache
**/coverage
**/dist
**/node_modules
**/types
# files
*.env
*.log
.pnp.*
coverage.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*

16
.prettierrc.yaml Normal file
View File

@ -0,0 +1,16 @@
arrowParens: avoid
bracketSpacing: true
endOfLine: auto
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]
importOrderParserPlugins: ["typescript"]
importOrderSeparation: true
importOrderSortSpecifiers: true
printWidth: 62
singleQuote: false
tabWidth: 2
trailingComma: all
overrides:
- files: "*.sol"
options:
tabWidth: 4

7
.solcover.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
istanbulReporter: ["html", "lcov"],
providerOptions: {
mnemonic: process.env.MNEMONIC,
},
skipFiles: ["test"],
};

23
.solhint.json Normal file
View File

@ -0,0 +1,23 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.4"],
"const-name-snakecase": "off",
"constructor-syntax": "error",
"func-visibility": [
"error",
{ "ignoreConstructors": true }
],
"max-line-length": ["error", 120],
"not-rely-on-time": "off",
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"reason-string": ["warn", { "maxLength": 64 }]
}
}

3
.solhintignore Normal file
View File

@ -0,0 +1,3 @@
# directories
**/artifacts
**/node_modules

File diff suppressed because one or more lines are too long

786
.yarn/releases/yarn-3.2.1.cjs vendored Executable file

File diff suppressed because one or more lines are too long

7
.yarnrc.yml Normal file
View File

@ -0,0 +1,7 @@
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-3.2.1.cjs

View File

@ -1,68 +1,78 @@
# p2pix-smart-contracts
Repository for P2Pix EVM contracts to be imported by the project.
**Repository for P2Pix EVM contracts to be imported by the project.**
## Installation
## Usage
Import the repository on your app to allow use the artifacts for Ethers.
### Pre Requisites
Before installing, create a `.env` file and set a BIP-39 compatible mnemonic and other env criteria as in `.env.example`.
### Install
```sh
$ yarn install
```
npm install --save git+https://github.com/doiim/p2pix-smart-contracts.git
### Compile
```sh
$ yarn compile
```
**_NOTE:_** TypeChain artifacts generated at compile time.
### Test
```sh
$ yarn test
```
### Report Gas
```sh
$ REPORT_GAS=true yarn test
```
**_NOTE_:** Gas usage per unit test and average gas per method call.
### Clean
Delete the smart contract artifacts and cache:
```sh
$ yarn clean
```
## Importing artifacts
To import artifacts on the project use the following:
```
```ts
import P2PIXArtifact from 'p2pix-smart-contracts/artifacts/contracts/p2pix.sol/P2PIX.json'
```
To grab deployment addresses you can just grab from deploys folder:
```
```ts
import localhostDeploys from 'p2pix-smart-contracts/deploys/localhost.json'
```
The default deploy addresses for localhost is the following:
| Contract | Address |
|-|-|
|p2pix|`0x5FbDB2315678afecb367f032d93F642f64180aa3`|
|token|`0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512`|
Then use a Contract instance to interact directly with it:
## Deploying to local environment
```
const p2pixContract = new ethers.Contract(address, P2PIXArtifact.abi, signer);
On the first teminal, use the following command and import some wallets to your Metamask, then connect to the network pointed:
```sh
yarn hardhat node
```
## Deploying local environment
On the second teminal, run the following commands:
Clone the repo and install dependencies:
```
git clone https://github.com/doiim/p2pix-smart-contracts.git
cd p2pix-smart-contract
npm install
```sh
yarn deploy1:localhost
yarn deploy2:localhost
```
On the first teminal use the following command and import some wallets to your Metamask and connect to the network pointed:
```
npx hardhat node
```
On the second teminal run following commands:
```
npx hardhat run --network localhost scripts/1-deploy-p2pix.js
npx hardhat run --network localhost scripts/2-deploy-mockToken.js
```
The second script transfer 2M tokens to the firrs wallet of the node.
**_NOTE_:** The second script transfers 2M tokens to the first wallet of the node.
To use the P2Pix smart contract first transfer some of the tokens to other wallets.
## Testing
To run tests, clone this repo, install dependencies and run Hardhat tests.
```
git clone https://github.com/doiim/p2pix-smart-contracts.git
cd p2pix-smart-contract
npm install
npx hardhat test
```

View File

@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

View File

@ -0,0 +1,63 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Ownable",
"sourceName": "contracts/@openzeppelin/contracts/access/Ownable.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

View File

@ -0,0 +1,194 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "IERC20",
"sourceName": "contracts/@openzeppelin/contracts/token/ERC20/IERC20.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

View File

@ -0,0 +1,233 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "IERC20Metadata",
"sourceName": "contracts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

View File

@ -0,0 +1,10 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Context",
"sourceName": "contracts/@openzeppelin/contracts/utils/Context.sol",
"abi": [],
"bytecode": "0x",
"deployedBytecode": "0x",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

View File

@ -0,0 +1,10 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "Counters",
"sourceName": "contracts/@openzeppelin/contracts/utils/Counters.sol",
"abi": [],
"bytecode": "0x602d6037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
"linkReferences": {},
"deployedLinkReferences": {}
}

View File

@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/5f0db55f399477fd77a196dfab69a373.json"
"buildInfo": "../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../build-info/7de52626ee9f8f66be6a4217c265b719.json"
"buildInfo": "../../build-info/dbb5a55867d7e81ad1b5b45703a00001.json"
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,96 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(
owner() == _msgSender(),
"Ownable: caller is not the owner"
);
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(
address newOwner
) public virtual onlyOwner {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(
address newOwner
) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}

View File

@ -0,0 +1,479 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256))
private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name()
public
view
virtual
override
returns (string memory)
{
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol()
public
view
virtual
override
returns (string memory)
{
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals()
public
view
virtual
override
returns (uint8)
{
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply()
public
view
virtual
override
returns (uint256)
{
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(
address account
) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(
address to,
uint256 amount
) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(
address owner,
address spender
) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(
address spender,
uint256 amount
) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(
address spender,
uint256 addedValue
) public virtual returns (bool) {
address owner = _msgSender();
_approve(
owner,
spender,
allowance(owner, spender) + addedValue
);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(
address spender,
uint256 subtractedValue
) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(
currentAllowance >= subtractedValue,
"ERC20: decreased allowance below zero"
);
unchecked {
_approve(
owner,
spender,
currentAllowance - subtractedValue
);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(
from != address(0),
"ERC20: transfer from the zero address"
);
require(
to != address(0),
"ERC20: transfer to the zero address"
);
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(
fromBalance >= amount,
"ERC20: transfer amount exceeds balance"
);
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(
address account,
uint256 amount
) internal virtual {
require(
account != address(0),
"ERC20: mint to the zero address"
);
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(
address account,
uint256 amount
) internal virtual {
require(
account != address(0),
"ERC20: burn from the zero address"
);
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(
accountBalance >= amount,
"ERC20: burn amount exceeds balance"
);
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(
owner != address(0),
"ERC20: approve from the zero address"
);
require(
spender != address(0),
"ERC20: approve to the zero address"
);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(
currentAllowance >= amount,
"ERC20: insufficient allowance"
);
unchecked {
_approve(
owner,
spender,
currentAllowance - amount
);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}

View File

@ -0,0 +1,101 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(
address account
) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(
address to,
uint256 amount
) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(
address owner,
address spender
) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(
address spender,
uint256 amount
) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}

View File

@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}

View File

@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender()
internal
view
virtual
returns (address)
{
return msg.sender;
}
function _msgData()
internal
view
virtual
returns (bytes calldata)
{
return msg.data;
}
}

View File

@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(
Counter storage counter
) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}

View File

@ -1,11 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MockToken is ERC20 {
constructor(uint256 supply) ERC20("MockBRL", "MBRL") {
_mint(msg.sender, supply);
}
}
}

View File

@ -1,18 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "./@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./@openzeppelin/contracts/access/Ownable.sol";
import "./@openzeppelin/contracts/utils/Counters.sol";
contract P2PIX is Ownable {
using Counters for Counters.Counter;
event DepositAdded(address indexed seller, uint256 depositID, address token, uint256 premium, uint256 amount);
event DepositClosed(address indexed seller, uint256 depositID);
event DepositWithdrawn(address indexed seller, uint256 depositID, uint256 amount);
event LockAdded(address indexed buyer, bytes32 indexed lockID, uint256 depositID, uint256 amount);
event DepositAdded(
address indexed seller,
uint256 depositID,
address token,
uint256 premium,
uint256 amount
);
event DepositClosed(
address indexed seller,
uint256 depositID
);
event DepositWithdrawn(
address indexed seller,
uint256 depositID,
uint256 amount
);
event LockAdded(
address indexed buyer,
bytes32 indexed lockID,
uint256 depositID,
uint256 amount
);
event LockReleased(address indexed buyer, bytes32 lockId);
event LockReturned(address indexed buyer, bytes32 lockId);
// Events
@ -20,20 +37,20 @@ contract P2PIX is Ownable {
struct Deposit {
address seller;
address token; // ERC20 stable token address
uint256 remaining; // Remaining tokens available
uint256 premium; // Premium paid in ETH for priority
bool valid; // Could be invalidated by the seller
string pixTarget; // The PIX account for the seller receive transactions
address token; // ERC20 stable token address
uint256 remaining; // Remaining tokens available
uint256 premium; // Premium paid in ETH for priority
bool valid; // Could be invalidated by the seller
string pixTarget; // The PIX account for the seller receive transactions
}
struct Lock {
uint256 depositID;
address targetAddress; // Where goes the tokens when validated
address relayerAddress; // Relayer address that facilitated this transaction
uint256 relayerPremium; // Amount to be paid for relayer
uint256 amount; // Amount to be tranfered via PIX
uint256 expirationBlock; // If not paid at this block will be expired
address targetAddress; // Where goes the tokens when validated
address relayerAddress; // Relayer address that facilitated this transaction
uint256 relayerPremium; // Amount to be paid for relayer
uint256 amount; // Amount to be tranfered via PIX
uint256 expirationBlock; // If not paid at this block will be expired
}
Counters.Counter public depositCount;
@ -50,13 +67,19 @@ contract P2PIX is Ownable {
mapping(bytes32 => bool) usedTransactions;
modifier onlySeller(uint256 depositID) {
require(mapDeposits[depositID].seller == msg.sender, "P2PIX: Only seller could call this function.");
require(
mapDeposits[depositID].seller == msg.sender,
"P2PIX: Only seller could call this function."
);
_;
}
constructor (uint256 defaultBlocks, address[] memory validSigners) Ownable() {
constructor(
uint256 defaultBlocks,
address[] memory validSigners
) Ownable() {
defaultLockBlocks = defaultBlocks;
for (uint8 i = 0; i < validSigners.length; i++){
for (uint8 i = 0; i < validSigners.length; i++) {
validBacenSigners[validSigners[i]] = true;
}
}
@ -66,21 +89,42 @@ contract P2PIX is Ownable {
address token,
uint256 amount,
string calldata pixTarget
) public payable returns (uint256 depositID){
) public payable returns (uint256 depositID) {
depositID = depositCount.current();
require(!mapDeposits[depositID].valid, 'P2PIX: Deposit already exist and it is still valid');
require(
!mapDeposits[depositID].valid,
"P2PIX: Deposit already exist and it is still valid"
);
IERC20 t = IERC20(token);
t.transferFrom(msg.sender, address(this), amount);
Deposit memory d = Deposit(msg.sender, token, amount, msg.value, true, pixTarget);
Deposit memory d = Deposit(
msg.sender,
token,
amount,
msg.value,
true,
pixTarget
);
mapDeposits[depositID] = d;
depositCount.increment();
emit DepositAdded(msg.sender, depositID, token, msg.value, amount);
emit DepositAdded(
msg.sender,
depositID,
token,
msg.value,
amount
);
}
// Vendedor pode invalidar da ordem de venda impedindo novos locks na mesma (isso não afeta nenhum lock que esteja ativo).
function cancelDeposit(uint256 depositID) public onlySeller(depositID) {
function cancelDeposit(
uint256 depositID
) public onlySeller(depositID) {
mapDeposits[depositID].valid = false;
emit DepositClosed(mapDeposits[depositID].seller, depositID);
emit DepositClosed(
mapDeposits[depositID].seller,
depositID
);
}
// Relayer interaje adicionando um lock na ordem de venda.
@ -96,12 +140,17 @@ contract P2PIX is Ownable {
uint256 relayerPremium,
uint256 amount,
bytes32[] calldata expiredLocks
) public returns (bytes32 lockID){
) public returns (bytes32 lockID) {
unlockExpired(expiredLocks);
Deposit storage d = mapDeposits[depositID];
require(d.valid, "P2PIX: Deposit not valid anymore");
require(d.remaining >= amount, "P2PIX: Not enough token remaining on deposit");
lockID = keccak256(abi.encodePacked(depositID, amount, targetAddress));
require(
d.remaining >= amount,
"P2PIX: Not enough token remaining on deposit"
);
lockID = keccak256(
abi.encodePacked(depositID, amount, targetAddress)
);
require(
mapLocks[lockID].expirationBlock < block.number,
"P2PIX: Another lock with same ID is not expired yet"
@ -112,11 +161,16 @@ contract P2PIX is Ownable {
relayerAddress,
relayerPremium,
amount,
block.number+defaultLockBlocks
block.number + defaultLockBlocks
);
mapLocks[lockID] = l;
d.remaining -= amount;
emit LockAdded(targetAddress, lockID, depositID, amount);
emit LockAdded(
targetAddress,
lockID,
depositID,
amount
);
}
// Relayer interage com o smart contract, colocando no calldata o comprovante do PIX realizado.
@ -130,20 +184,40 @@ contract P2PIX is Ownable {
) public {
// TODO **Prevenir que um Pix não relacionado ao APP seja usado pois tem o mesmo destino
Lock storage l = mapLocks[lockID];
require(l.expirationBlock > block.number && l.amount > 0, "P2PIX: Lock already released or returned");
require(
l.expirationBlock > block.number && l.amount > 0,
"P2PIX: Lock already released or returned"
);
Deposit storage d = mapDeposits[l.depositID];
bytes32 message = keccak256(abi.encodePacked(
mapDeposits[l.depositID].pixTarget,
l.amount,
pixTimestamp
));
bytes32 messageDigest = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", message));
require(!usedTransactions[message], "P2PIX: Transaction already used to unlock payment");
bytes32 message = keccak256(
abi.encodePacked(
mapDeposits[l.depositID].pixTarget,
l.amount,
pixTimestamp
)
);
bytes32 messageDigest = keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
message
)
);
require(
!usedTransactions[message],
"P2PIX: Transaction already used to unlock payment"
);
address signer = ecrecover(messageDigest, v, r, s);
require(validBacenSigners[signer], "P2PIX: Signer is not a valid signer");
require(
validBacenSigners[signer],
"P2PIX: Signer is not a valid signer"
);
IERC20 t = IERC20(d.token);
t.transfer(l.targetAddress, l.amount-l.relayerPremium);
if (l.relayerPremium > 0) t.transfer(l.relayerAddress, l.relayerPremium);
t.transfer(
l.targetAddress,
l.amount - l.relayerPremium
);
if (l.relayerPremium > 0)
t.transfer(l.relayerAddress, l.relayerPremium);
l.amount = 0;
l.expirationBlock = 0;
usedTransactions[message] = true;
@ -151,11 +225,17 @@ contract P2PIX is Ownable {
}
// Unlock expired locks
function unlockExpired(bytes32[] calldata lockIDs) public {
function unlockExpired(
bytes32[] calldata lockIDs
) public {
uint256 locksSize = lockIDs.length;
for (uint16 i = 0; i < locksSize; i++){
for (uint16 i = 0; i < locksSize; i++) {
Lock storage l = mapLocks[lockIDs[i]];
require(l.expirationBlock < block.number && l.amount > 0, "P2PIX: Lock not expired or already released");
require(
l.expirationBlock < block.number &&
l.amount > 0,
"P2PIX: Lock not expired or already released"
);
mapDeposits[l.depositID].remaining += l.amount;
l.amount = 0;
emit LockReturned(l.targetAddress, lockIDs[i]);
@ -184,5 +264,4 @@ contract P2PIX is Ownable {
payable(msg.sender).transfer(balance);
emit PremiumsWithdrawn(msg.sender, balance);
}
}
}

View File

@ -3,6 +3,6 @@
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
],
"p2pix": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"token": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
"p2pix": "0x294003F602c321627152c6b7DED3EAb5bEa853Ee",
"token": "0x5BdEa33E2D14E3D4C66f9A7bbbc38Cd785D0C592"
}

View File

@ -1,12 +0,0 @@
require("@nomiclabs/hardhat-waffle");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.17",
networks: {
hardhat: {
blockGasLimit: 30000000,
//hardfork: 'london'
}
}
};

123
hardhat.config.ts Normal file
View File

@ -0,0 +1,123 @@
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomicfoundation/hardhat-toolbox";
import { config as dotenvConfig } from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
import { NetworkUserConfig } from "hardhat/types";
import { resolve } from "path";
dotenvConfig({ path: resolve(__dirname, "./.env") });
const mnemonic: string | undefined = process.env.MNEMONIC;
if (!mnemonic) {
throw new Error("Please set your MNEMONIC in a .env file");
}
const infuraApiKey: string | undefined =
process.env.INFURA_API_KEY;
if (!infuraApiKey) {
throw new Error(
"Please set your INFURA_API_KEY in a .env file",
);
}
const chainIds = {
// "{INSERT_NAME}": {INSERT_ID},
hardhat: 31337,
mainnet: 1,
sepolia: 11155111,
};
function getChainConfig(
chain: keyof typeof chainIds,
): NetworkUserConfig {
let jsonRpcUrl: string;
switch (chain) {
// case "{INSERT_NAME}":
// jsonRpcUrl = "{INSERT_URL}";
// break;
default:
jsonRpcUrl =
"https://" + chain + ".infura.io/v3/" + infuraApiKey;
}
return {
// Comment out for default hardhat account settings
accounts: {
count: 10,
mnemonic,
path: "m/44'/60'/0'/0",
},
chainId: chainIds[chain],
url: jsonRpcUrl,
};
}
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
etherscan: {
apiKey: {
mainnet: process.env.ETHERSCAN_API_KEY || "",
rinkeby: process.env.ETHERSCAN_API_KEY || "",
},
// customChains: [
// {
// // network: {INSERT_NAME},
// // chainId: {INSERT_ID},
// // urls: {
// // apiURL:
// // "{INSERT_URL}",
// // browserURL: "{INSERT_URL}",
// // },
// },
// ],
},
gasReporter: {
enabled: !!(
process.env.REPORT_GAS &&
process.env.REPORT_GAS != "false"
),
showTimeSpent: true,
showMethodSig: true,
token: "ONE",
currency: "USD",
// gasPriceApi: process.env.GASPRICE_API_ENDPOINT,
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
excludeContracts: [],
src: "./contracts",
},
networks: {
hardhat: {
blockGasLimit: 30000000,
accounts: {
mnemonic,
},
chainId: chainIds.hardhat,
},
// network: getChainConfig("{INSERT_NAME}"),
mainnet: getChainConfig("mainnet"),
sepolia: getChainConfig("sepolia"),
},
paths: {
artifacts: "./artifacts",
cache: "./cache",
sources: "./contracts",
tests: "./test",
},
solidity: {
version: "0.8.9",
settings: {
metadata: {
bytecodeHash: "none",
},
optimizer: {
enabled: true,
runs: 800,
},
},
},
typechain: {
outDir: "src/types",
target: "ethers-v5",
},
};
export default config;

29715
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,26 +2,84 @@
"name": "p2pix-smart-contracts",
"version": "1.0.0",
"description": "Repository for P2Pix EVM contracts to be imported by the project.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/doiim/p2pix-smart-contracts.git"
},
"homepage": "https://github.com/doiim/p2pix-smart-contracts#readme",
"author": "Filipe Soccol (doiim)",
"license": "MIT",
"bugs": {
"url": "https://github.com/doiim/p2pix-smart-contracts/issues"
},
"homepage": "https://github.com/doiim/p2pix-smart-contracts#readme",
"devDependencies": {
"@nomiclabs/hardhat-waffle": "^2.0.3",
"chai": "^4.3.6",
"hardhat": "^2.12.0"
"scripts": {
"clean": "shx rm -rf ./artifacts ./cache ./coverage ./src/types ./coverage.json && yarn typechain",
"commit": "git-cz",
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain",
"test": "hardhat test",
"deploy1:localhost": "hardhat run scripts/1-deploy-p2pix.ts --network localhost",
"deploy2:localhost": "hardhat run scripts/2-deploy-mockToken.ts --network localhost",
"coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && yarn typechain",
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
"lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .",
"_postinstall": "husky install",
"postpublish": "pinst --enable",
"prepublishOnly": "pinst --disable",
"prettier": "prettier --config ./.prettierrc.yaml --write \"**/*.{js,json,md,sol,ts,yaml,yml}\"",
"prettier:check": "prettier --check --config ./.prettierrc.yaml \"**/*.{js,json,md,sol,ts,yaml,yml}\""
},
"dependencies": {
"@openzeppelin/contracts": "^4.7.3"
"devDependencies": {
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.4",
"@nomicfoundation/hardhat-network-helpers": "1.0.6",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@nomiclabs/hardhat-etherscan": "^3.1.2",
"@trivago/prettier-plugin-sort-imports": "^3.4.0",
"@typechain/ethers-v5": "^10.1.1",
"@typechain/hardhat": "^6.1.4",
"@types/chai": "^4.3.3",
"@types/fs-extra": "^9.0.13",
"@types/mocha": "^9.1.1",
"@types/node": "^18.11.9",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"chai": "^4.3.6",
"commitizen": "^4.2.5",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^16.0.3",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"ethers": "^5.7.2",
"fs-extra": "^10.1.0",
"hardhat": "^2.12.2",
"hardhat-gas-reporter": "^1.0.9",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"lodash": "^4.17.21",
"mocha": "^10.1.0",
"pinst": "^3.0.0",
"prettier": "^2.7.1",
"prettier-plugin-solidity": "^1.0.0-rc.1",
"shx": "^0.3.4",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.8.2",
"ts-generator": "^0.1.1",
"ts-node": "^10.9.1",
"typechain": "^8.1.1",
"typescript": "^4.8.4"
},
"files": [
"/contracts"
],
"packageManager": "yarn@3.2.1",
"publishConfig": {
"access": "public"
}
}

View File

@ -1,31 +0,0 @@
const fs = require('fs');
const { network } = require("hardhat");
async function main() {
let deploysJson = {}
try {
const data = fs.readFileSync(`./deploys/${network.name}.json`, {encoding:"utf-8"});
deploysJson = JSON.parse(data);
} catch (err) {
console.log('Error loading Master address: ', err);
process.exit(1);
}
const P2PIX = await ethers.getContractFactory("P2PIX");
const p2pix = await P2PIX.deploy(2, deploysJson.signers);
await p2pix.deployed();
deploysJson.p2pix = p2pix.address
console.log("🚀 P2PIX Deployed:", p2pix.address);
fs.writeFileSync(`./deploys/${network.name}.json`, JSON.stringify(deploysJson, undefined, 2));
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

55
scripts/1-deploy-p2pix.ts Normal file
View File

@ -0,0 +1,55 @@
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import * as fs from "fs";
import { ethers, network } from "hardhat";
// import hre from "hardhat";
interface Deploys {
signers: string[];
p2pix: string;
token: string;
}
let deploysJson: Deploys;
const main = async () => {
try {
const data = fs.readFileSync(
`./deploys/${network.name}.json`,
{ encoding: "utf-8" },
);
deploysJson = JSON.parse(data);
} catch (err) {
console.log("Error loading Master address: ", err);
process.exit(1);
}
const [deployer] = await ethers.getSigners();
console.log(`Deploying contracts with ${deployer.address}`);
const P2PIX = await ethers.getContractFactory("P2PIX");
const p2pix = await P2PIX.deploy(2, deploysJson.signers);
await p2pix.deployed();
deploysJson.p2pix = p2pix.address;
console.log("🚀 P2PIX Deployed:", p2pix.address);
fs.writeFileSync(
`./deploys/${network.name}.json`,
JSON.stringify(deploysJson, undefined, 2),
);
/* UNCOMMENT WHEN DEPLOYING TO MAINNET */
//verify
// await hre.run("verify:verify", {
// address: p2pix.address,
// constructorArguments: [2, deploysJson.signers],
// });
};
main()
.then(() => process.exit(0))
.catch(error => {
console.log(error);
process.exit(1);
});

View File

@ -1,31 +0,0 @@
const fs = require('fs');
const { network } = require("hardhat");
async function main() {
let deploysJson = {}
try {
const data = fs.readFileSync(`./deploys/${network.name}.json`, {encoding:"utf-8"});
deploysJson = JSON.parse(data);
} catch (err) {
console.log('Error loading Master address: ', err);
process.exit(1);
}
const ERC20Factory = await ethers.getContractFactory("MockToken");
const erc20 = await ERC20Factory.deploy(ethers.utils.parseEther('20000000', 'wei'));
await erc20.deployed();
deploysJson.token = erc20.address
console.log("🚀 Mock Token Deployed:", erc20.address);
fs.writeFileSync(`./deploys/${network.name}.json`, JSON.stringify(deploysJson, undefined, 2));
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

View File

@ -0,0 +1,59 @@
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import { BigNumber } from "ethers";
import * as fs from "fs";
import { ethers, network } from "hardhat";
// import hre from "hardhat";
interface Deploys {
signers: string[];
p2pix: string;
token: string;
}
let deploysJson: Deploys;
const supply: BigNumber = ethers.utils.parseEther("20000000");
const main = async () => {
try {
const data = fs.readFileSync(
`./deploys/${network.name}.json`,
{ encoding: "utf-8" },
);
deploysJson = JSON.parse(data);
} catch (err) {
console.log("Error loading Master address: ", err);
process.exit(1);
}
const [deployer] = await ethers.getSigners();
console.log(`Deploying contracts with ${deployer.address}`);
const ERC20Factory = await ethers.getContractFactory(
"MockToken",
);
const erc20 = await ERC20Factory.deploy(supply);
await erc20.deployed();
deploysJson.token = erc20.address;
console.log("🚀 Mock Token Deployed:", erc20.address);
fs.writeFileSync(
`./deploys/${network.name}.json`,
JSON.stringify(deploysJson, undefined, 2),
);
/* UNCOMMENT WHEN DEPLOYING TO MAINNET */
//verify
// await hre.run("verify:verify", {
// address: erc20.address,
// constructorArguments: supply,
// });
};
main()
.then(() => process.exit(0))
.catch(error => {
console.log(error);
process.exit(1);
});

View File

@ -0,0 +1,176 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from "ethers";
import type {
FunctionFragment,
Result,
EventFragment,
} from "@ethersproject/abi";
import type { Listener, Provider } from "@ethersproject/providers";
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../../common";
export interface OwnableInterface extends utils.Interface {
functions: {
"owner()": FunctionFragment;
"renounceOwnership()": FunctionFragment;
"transferOwnership(address)": FunctionFragment;
};
getFunction(
nameOrSignatureOrTopic: "owner" | "renounceOwnership" | "transferOwnership"
): FunctionFragment;
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
encodeFunctionData(
functionFragment: "renounceOwnership",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "transferOwnership",
values: [PromiseOrValue<string>]
): string;
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "renounceOwnership",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "transferOwnership",
data: BytesLike
): Result;
events: {
"OwnershipTransferred(address,address)": EventFragment;
};
getEvent(nameOrSignatureOrTopic: "OwnershipTransferred"): EventFragment;
}
export interface OwnershipTransferredEventObject {
previousOwner: string;
newOwner: string;
}
export type OwnershipTransferredEvent = TypedEvent<
[string, string],
OwnershipTransferredEventObject
>;
export type OwnershipTransferredEventFilter =
TypedEventFilter<OwnershipTransferredEvent>;
export interface Ownable extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;
interface: OwnableInterface;
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;
functions: {
owner(overrides?: CallOverrides): Promise<[string]>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
};
owner(overrides?: CallOverrides): Promise<string>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
callStatic: {
owner(overrides?: CallOverrides): Promise<string>;
renounceOwnership(overrides?: CallOverrides): Promise<void>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<void>;
};
filters: {
"OwnershipTransferred(address,address)"(
previousOwner?: PromiseOrValue<string> | null,
newOwner?: PromiseOrValue<string> | null
): OwnershipTransferredEventFilter;
OwnershipTransferred(
previousOwner?: PromiseOrValue<string> | null,
newOwner?: PromiseOrValue<string> | null
): OwnershipTransferredEventFilter;
};
estimateGas: {
owner(overrides?: CallOverrides): Promise<BigNumber>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
};
populateTransaction: {
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
};
}

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Ownable } from "./Ownable";

View File

@ -0,0 +1,7 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as access from "./access";
export type { access };
import type * as token from "./token";
export type { token };

View File

@ -0,0 +1,464 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from "ethers";
import type {
FunctionFragment,
Result,
EventFragment,
} from "@ethersproject/abi";
import type { Listener, Provider } from "@ethersproject/providers";
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../../../common";
export interface ERC20Interface extends utils.Interface {
functions: {
"allowance(address,address)": FunctionFragment;
"approve(address,uint256)": FunctionFragment;
"balanceOf(address)": FunctionFragment;
"decimals()": FunctionFragment;
"decreaseAllowance(address,uint256)": FunctionFragment;
"increaseAllowance(address,uint256)": FunctionFragment;
"name()": FunctionFragment;
"symbol()": FunctionFragment;
"totalSupply()": FunctionFragment;
"transfer(address,uint256)": FunctionFragment;
"transferFrom(address,address,uint256)": FunctionFragment;
};
getFunction(
nameOrSignatureOrTopic:
| "allowance"
| "approve"
| "balanceOf"
| "decimals"
| "decreaseAllowance"
| "increaseAllowance"
| "name"
| "symbol"
| "totalSupply"
| "transfer"
| "transferFrom"
): FunctionFragment;
encodeFunctionData(
functionFragment: "allowance",
values: [PromiseOrValue<string>, PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "approve",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "balanceOf",
values: [PromiseOrValue<string>]
): string;
encodeFunctionData(functionFragment: "decimals", values?: undefined): string;
encodeFunctionData(
functionFragment: "decreaseAllowance",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "increaseAllowance",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(functionFragment: "name", values?: undefined): string;
encodeFunctionData(functionFragment: "symbol", values?: undefined): string;
encodeFunctionData(
functionFragment: "totalSupply",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "transfer",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "transferFrom",
values: [
PromiseOrValue<string>,
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>
]
): string;
decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "decreaseAllowance",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "increaseAllowance",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "name", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "totalSupply",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "transferFrom",
data: BytesLike
): Result;
events: {
"Approval(address,address,uint256)": EventFragment;
"Transfer(address,address,uint256)": EventFragment;
};
getEvent(nameOrSignatureOrTopic: "Approval"): EventFragment;
getEvent(nameOrSignatureOrTopic: "Transfer"): EventFragment;
}
export interface ApprovalEventObject {
owner: string;
spender: string;
value: BigNumber;
}
export type ApprovalEvent = TypedEvent<
[string, string, BigNumber],
ApprovalEventObject
>;
export type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;
export interface TransferEventObject {
from: string;
to: string;
value: BigNumber;
}
export type TransferEvent = TypedEvent<
[string, string, BigNumber],
TransferEventObject
>;
export type TransferEventFilter = TypedEventFilter<TransferEvent>;
export interface ERC20 extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;
interface: ERC20Interface;
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;
functions: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
decimals(overrides?: CallOverrides): Promise<[number]>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
name(overrides?: CallOverrides): Promise<[string]>;
symbol(overrides?: CallOverrides): Promise<[string]>;
totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
};
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<number>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
name(overrides?: CallOverrides): Promise<string>;
symbol(overrides?: CallOverrides): Promise<string>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
callStatic: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<number>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
name(overrides?: CallOverrides): Promise<string>;
symbol(overrides?: CallOverrides): Promise<string>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
};
filters: {
"Approval(address,address,uint256)"(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
Approval(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
"Transfer(address,address,uint256)"(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
Transfer(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
};
estimateGas: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<BigNumber>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
name(overrides?: CallOverrides): Promise<BigNumber>;
symbol(overrides?: CallOverrides): Promise<BigNumber>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
};
populateTransaction: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
decimals(overrides?: CallOverrides): Promise<PopulatedTransaction>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
name(overrides?: CallOverrides): Promise<PopulatedTransaction>;
symbol(overrides?: CallOverrides): Promise<PopulatedTransaction>;
totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
};
}

View File

@ -0,0 +1,342 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from "ethers";
import type {
FunctionFragment,
Result,
EventFragment,
} from "@ethersproject/abi";
import type { Listener, Provider } from "@ethersproject/providers";
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../../../common";
export interface IERC20Interface extends utils.Interface {
functions: {
"allowance(address,address)": FunctionFragment;
"approve(address,uint256)": FunctionFragment;
"balanceOf(address)": FunctionFragment;
"totalSupply()": FunctionFragment;
"transfer(address,uint256)": FunctionFragment;
"transferFrom(address,address,uint256)": FunctionFragment;
};
getFunction(
nameOrSignatureOrTopic:
| "allowance"
| "approve"
| "balanceOf"
| "totalSupply"
| "transfer"
| "transferFrom"
): FunctionFragment;
encodeFunctionData(
functionFragment: "allowance",
values: [PromiseOrValue<string>, PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "approve",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "balanceOf",
values: [PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "totalSupply",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "transfer",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "transferFrom",
values: [
PromiseOrValue<string>,
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>
]
): string;
decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "totalSupply",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "transferFrom",
data: BytesLike
): Result;
events: {
"Approval(address,address,uint256)": EventFragment;
"Transfer(address,address,uint256)": EventFragment;
};
getEvent(nameOrSignatureOrTopic: "Approval"): EventFragment;
getEvent(nameOrSignatureOrTopic: "Transfer"): EventFragment;
}
export interface ApprovalEventObject {
owner: string;
spender: string;
value: BigNumber;
}
export type ApprovalEvent = TypedEvent<
[string, string, BigNumber],
ApprovalEventObject
>;
export type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;
export interface TransferEventObject {
from: string;
to: string;
value: BigNumber;
}
export type TransferEvent = TypedEvent<
[string, string, BigNumber],
TransferEventObject
>;
export type TransferEventFilter = TypedEventFilter<TransferEvent>;
export interface IERC20 extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;
interface: IERC20Interface;
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;
functions: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
};
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
callStatic: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
};
filters: {
"Approval(address,address,uint256)"(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
Approval(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
"Transfer(address,address,uint256)"(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
Transfer(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
};
estimateGas: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
};
populateTransaction: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
};
}

View File

@ -0,0 +1,384 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from "ethers";
import type {
FunctionFragment,
Result,
EventFragment,
} from "@ethersproject/abi";
import type { Listener, Provider } from "@ethersproject/providers";
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../../../../../common";
export interface IERC20MetadataInterface extends utils.Interface {
functions: {
"allowance(address,address)": FunctionFragment;
"approve(address,uint256)": FunctionFragment;
"balanceOf(address)": FunctionFragment;
"decimals()": FunctionFragment;
"name()": FunctionFragment;
"symbol()": FunctionFragment;
"totalSupply()": FunctionFragment;
"transfer(address,uint256)": FunctionFragment;
"transferFrom(address,address,uint256)": FunctionFragment;
};
getFunction(
nameOrSignatureOrTopic:
| "allowance"
| "approve"
| "balanceOf"
| "decimals"
| "name"
| "symbol"
| "totalSupply"
| "transfer"
| "transferFrom"
): FunctionFragment;
encodeFunctionData(
functionFragment: "allowance",
values: [PromiseOrValue<string>, PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "approve",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "balanceOf",
values: [PromiseOrValue<string>]
): string;
encodeFunctionData(functionFragment: "decimals", values?: undefined): string;
encodeFunctionData(functionFragment: "name", values?: undefined): string;
encodeFunctionData(functionFragment: "symbol", values?: undefined): string;
encodeFunctionData(
functionFragment: "totalSupply",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "transfer",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "transferFrom",
values: [
PromiseOrValue<string>,
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>
]
): string;
decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "name", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "totalSupply",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "transferFrom",
data: BytesLike
): Result;
events: {
"Approval(address,address,uint256)": EventFragment;
"Transfer(address,address,uint256)": EventFragment;
};
getEvent(nameOrSignatureOrTopic: "Approval"): EventFragment;
getEvent(nameOrSignatureOrTopic: "Transfer"): EventFragment;
}
export interface ApprovalEventObject {
owner: string;
spender: string;
value: BigNumber;
}
export type ApprovalEvent = TypedEvent<
[string, string, BigNumber],
ApprovalEventObject
>;
export type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;
export interface TransferEventObject {
from: string;
to: string;
value: BigNumber;
}
export type TransferEvent = TypedEvent<
[string, string, BigNumber],
TransferEventObject
>;
export type TransferEventFilter = TypedEventFilter<TransferEvent>;
export interface IERC20Metadata extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;
interface: IERC20MetadataInterface;
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;
functions: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
decimals(overrides?: CallOverrides): Promise<[number]>;
name(overrides?: CallOverrides): Promise<[string]>;
symbol(overrides?: CallOverrides): Promise<[string]>;
totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
};
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<number>;
name(overrides?: CallOverrides): Promise<string>;
symbol(overrides?: CallOverrides): Promise<string>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
callStatic: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<number>;
name(overrides?: CallOverrides): Promise<string>;
symbol(overrides?: CallOverrides): Promise<string>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
};
filters: {
"Approval(address,address,uint256)"(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
Approval(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
"Transfer(address,address,uint256)"(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
Transfer(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
};
estimateGas: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<BigNumber>;
name(overrides?: CallOverrides): Promise<BigNumber>;
symbol(overrides?: CallOverrides): Promise<BigNumber>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
};
populateTransaction: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
decimals(overrides?: CallOverrides): Promise<PopulatedTransaction>;
name(overrides?: CallOverrides): Promise<PopulatedTransaction>;
symbol(overrides?: CallOverrides): Promise<PopulatedTransaction>;
totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
};
}

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { IERC20Metadata } from "./IERC20Metadata";

View File

@ -0,0 +1,7 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as extensions from "./extensions";
export type { extensions };
export type { ERC20 } from "./ERC20";
export type { IERC20 } from "./IERC20";

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as erc20 from "./ERC20";
export type { erc20 };

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as contracts from "./contracts";
export type { contracts };

46
src/types/common.ts Normal file
View File

@ -0,0 +1,46 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type { Listener } from "@ethersproject/providers";
import type { Event, EventFilter } from "ethers";
export interface TypedEvent<
TArgsArray extends Array<any> = any,
TArgsObject = any
> extends Event {
args: TArgsArray & TArgsObject;
}
export interface TypedEventFilter<_TEvent extends TypedEvent>
extends EventFilter {}
export interface TypedListener<TEvent extends TypedEvent> {
(...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void;
}
type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never;
export interface OnEvent<TRes> {
<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>,
listener: TypedListener<TEvent>
): TRes;
(eventName: string, listener: Listener): TRes;
}
export type MinEthersFactory<C, ARGS> = {
deploy(...a: ARGS[]): Promise<C>;
};
export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<
infer C,
any
>
? C
: never;
export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any>
? Parameters<F["deploy"]>
: never;
export type PromiseOrValue<T> = T | Promise<T>;

View File

@ -0,0 +1,78 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Contract, Signer, utils } from "ethers";
import type { Provider } from "@ethersproject/providers";
import type {
Ownable,
OwnableInterface,
} from "../../../../@openzeppelin/contracts/access/Ownable";
const _abi = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address",
},
],
name: "OwnershipTransferred",
type: "event",
},
{
inputs: [],
name: "owner",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "renounceOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "newOwner",
type: "address",
},
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
];
export class Ownable__factory {
static readonly abi = _abi;
static createInterface(): OwnableInterface {
return new utils.Interface(_abi) as OwnableInterface;
}
static connect(
address: string,
signerOrProvider: Signer | Provider
): Ownable {
return new Contract(address, _abi, signerOrProvider) as Ownable;
}
}

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { Ownable__factory } from "./Ownable__factory";

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as access from "./access";
export * as token from "./token";

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,206 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Contract, Signer, utils } from "ethers";
import type { Provider } from "@ethersproject/providers";
import type {
IERC20,
IERC20Interface,
} from "../../../../../@openzeppelin/contracts/token/ERC20/IERC20";
const _abi = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "owner",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "spender",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
],
name: "Approval",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "from",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "to",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
],
name: "Transfer",
type: "event",
},
{
inputs: [
{
internalType: "address",
name: "owner",
type: "address",
},
{
internalType: "address",
name: "spender",
type: "address",
},
],
name: "allowance",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "spender",
type: "address",
},
{
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "approve",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address",
},
],
name: "balanceOf",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "totalSupply",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "to",
type: "address",
},
{
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "transfer",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "from",
type: "address",
},
{
internalType: "address",
name: "to",
type: "address",
},
{
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "transferFrom",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "nonpayable",
type: "function",
},
];
export class IERC20__factory {
static readonly abi = _abi;
static createInterface(): IERC20Interface {
return new utils.Interface(_abi) as IERC20Interface;
}
static connect(address: string, signerOrProvider: Signer | Provider): IERC20 {
return new Contract(address, _abi, signerOrProvider) as IERC20;
}
}

View File

@ -0,0 +1,248 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Contract, Signer, utils } from "ethers";
import type { Provider } from "@ethersproject/providers";
import type {
IERC20Metadata,
IERC20MetadataInterface,
} from "../../../../../../@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata";
const _abi = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "owner",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "spender",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
],
name: "Approval",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "from",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "to",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "value",
type: "uint256",
},
],
name: "Transfer",
type: "event",
},
{
inputs: [
{
internalType: "address",
name: "owner",
type: "address",
},
{
internalType: "address",
name: "spender",
type: "address",
},
],
name: "allowance",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "spender",
type: "address",
},
{
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "approve",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "account",
type: "address",
},
],
name: "balanceOf",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "decimals",
outputs: [
{
internalType: "uint8",
name: "",
type: "uint8",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "name",
outputs: [
{
internalType: "string",
name: "",
type: "string",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "symbol",
outputs: [
{
internalType: "string",
name: "",
type: "string",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "totalSupply",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "to",
type: "address",
},
{
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "transfer",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "from",
type: "address",
},
{
internalType: "address",
name: "to",
type: "address",
},
{
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "transferFrom",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "nonpayable",
type: "function",
},
];
export class IERC20Metadata__factory {
static readonly abi = _abi;
static createInterface(): IERC20MetadataInterface {
return new utils.Interface(_abi) as IERC20MetadataInterface;
}
static connect(
address: string,
signerOrProvider: Signer | Provider
): IERC20Metadata {
return new Contract(address, _abi, signerOrProvider) as IERC20Metadata;
}
}

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { IERC20Metadata__factory } from "./IERC20Metadata__factory";

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as extensions from "./extensions";
export { ERC20__factory } from "./ERC20__factory";
export { IERC20__factory } from "./IERC20__factory";

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as erc20 from "./ERC20";

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as contracts from "./contracts";

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as openzeppelin from "./@openzeppelin";
export * as mockTokenSol from "./mockToken.sol";
export * as p2PixSol from "./p2pix.sol";

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { MockToken__factory } from "./MockToken__factory";

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { P2PIX__factory } from "./P2PIX__factory";

87
src/types/hardhat.d.ts vendored Normal file
View File

@ -0,0 +1,87 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { ethers } from "ethers";
import {
FactoryOptions,
HardhatEthersHelpers as HardhatEthersHelpersBase,
} from "@nomiclabs/hardhat-ethers/types";
import * as Contracts from ".";
declare module "hardhat/types/runtime" {
interface HardhatEthersHelpers extends HardhatEthersHelpersBase {
getContractFactory(
name: "Ownable",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.Ownable__factory>;
getContractFactory(
name: "ERC20",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.ERC20__factory>;
getContractFactory(
name: "IERC20Metadata",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.IERC20Metadata__factory>;
getContractFactory(
name: "IERC20",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.IERC20__factory>;
getContractFactory(
name: "MockToken",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.MockToken__factory>;
getContractFactory(
name: "P2PIX",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.P2PIX__factory>;
getContractAt(
name: "Ownable",
address: string,
signer?: ethers.Signer
): Promise<Contracts.Ownable>;
getContractAt(
name: "ERC20",
address: string,
signer?: ethers.Signer
): Promise<Contracts.ERC20>;
getContractAt(
name: "IERC20Metadata",
address: string,
signer?: ethers.Signer
): Promise<Contracts.IERC20Metadata>;
getContractAt(
name: "IERC20",
address: string,
signer?: ethers.Signer
): Promise<Contracts.IERC20>;
getContractAt(
name: "MockToken",
address: string,
signer?: ethers.Signer
): Promise<Contracts.MockToken>;
getContractAt(
name: "P2PIX",
address: string,
signer?: ethers.Signer
): Promise<Contracts.P2PIX>;
// default types
getContractFactory(
name: string,
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<ethers.ContractFactory>;
getContractFactory(
abi: any[],
bytecode: ethers.utils.BytesLike,
signer?: ethers.Signer
): Promise<ethers.ContractFactory>;
getContractAt(
nameOrAbi: string | any[],
address: string,
signer?: ethers.Signer
): Promise<ethers.Contract>;
}
}

22
src/types/index.ts Normal file
View File

@ -0,0 +1,22 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as openzeppelin from "./@openzeppelin";
export type { openzeppelin };
import type * as mockTokenSol from "./mockToken.sol";
export type { mockTokenSol };
import type * as p2PixSol from "./p2pix.sol";
export type { p2PixSol };
export * as factories from "./factories";
export type { Ownable } from "./@openzeppelin/contracts/access/Ownable";
export { Ownable__factory } from "./factories/@openzeppelin/contracts/access/Ownable__factory";
export type { ERC20 } from "./@openzeppelin/contracts/token/ERC20/ERC20";
export { ERC20__factory } from "./factories/@openzeppelin/contracts/token/ERC20/ERC20__factory";
export type { IERC20Metadata } from "./@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata";
export { IERC20Metadata__factory } from "./factories/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata__factory";
export type { IERC20 } from "./@openzeppelin/contracts/token/ERC20/IERC20";
export { IERC20__factory } from "./factories/@openzeppelin/contracts/token/ERC20/IERC20__factory";
export type { MockToken } from "./mockToken.sol/MockToken";
export { MockToken__factory } from "./factories/mockToken.sol/MockToken__factory";
export type { P2PIX } from "./p2pix.sol/P2PIX";
export { P2PIX__factory } from "./factories/p2pix.sol/P2PIX__factory";

View File

@ -0,0 +1,464 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from "ethers";
import type {
FunctionFragment,
Result,
EventFragment,
} from "@ethersproject/abi";
import type { Listener, Provider } from "@ethersproject/providers";
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../common";
export interface MockTokenInterface extends utils.Interface {
functions: {
"allowance(address,address)": FunctionFragment;
"approve(address,uint256)": FunctionFragment;
"balanceOf(address)": FunctionFragment;
"decimals()": FunctionFragment;
"decreaseAllowance(address,uint256)": FunctionFragment;
"increaseAllowance(address,uint256)": FunctionFragment;
"name()": FunctionFragment;
"symbol()": FunctionFragment;
"totalSupply()": FunctionFragment;
"transfer(address,uint256)": FunctionFragment;
"transferFrom(address,address,uint256)": FunctionFragment;
};
getFunction(
nameOrSignatureOrTopic:
| "allowance"
| "approve"
| "balanceOf"
| "decimals"
| "decreaseAllowance"
| "increaseAllowance"
| "name"
| "symbol"
| "totalSupply"
| "transfer"
| "transferFrom"
): FunctionFragment;
encodeFunctionData(
functionFragment: "allowance",
values: [PromiseOrValue<string>, PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "approve",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "balanceOf",
values: [PromiseOrValue<string>]
): string;
encodeFunctionData(functionFragment: "decimals", values?: undefined): string;
encodeFunctionData(
functionFragment: "decreaseAllowance",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "increaseAllowance",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(functionFragment: "name", values?: undefined): string;
encodeFunctionData(functionFragment: "symbol", values?: undefined): string;
encodeFunctionData(
functionFragment: "totalSupply",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "transfer",
values: [PromiseOrValue<string>, PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "transferFrom",
values: [
PromiseOrValue<string>,
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>
]
): string;
decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "decreaseAllowance",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "increaseAllowance",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "name", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "totalSupply",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "transferFrom",
data: BytesLike
): Result;
events: {
"Approval(address,address,uint256)": EventFragment;
"Transfer(address,address,uint256)": EventFragment;
};
getEvent(nameOrSignatureOrTopic: "Approval"): EventFragment;
getEvent(nameOrSignatureOrTopic: "Transfer"): EventFragment;
}
export interface ApprovalEventObject {
owner: string;
spender: string;
value: BigNumber;
}
export type ApprovalEvent = TypedEvent<
[string, string, BigNumber],
ApprovalEventObject
>;
export type ApprovalEventFilter = TypedEventFilter<ApprovalEvent>;
export interface TransferEventObject {
from: string;
to: string;
value: BigNumber;
}
export type TransferEvent = TypedEvent<
[string, string, BigNumber],
TransferEventObject
>;
export type TransferEventFilter = TypedEventFilter<TransferEvent>;
export interface MockToken extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;
interface: MockTokenInterface;
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;
functions: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[BigNumber]>;
decimals(overrides?: CallOverrides): Promise<[number]>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
name(overrides?: CallOverrides): Promise<[string]>;
symbol(overrides?: CallOverrides): Promise<[string]>;
totalSupply(overrides?: CallOverrides): Promise<[BigNumber]>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
};
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<number>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
name(overrides?: CallOverrides): Promise<string>;
symbol(overrides?: CallOverrides): Promise<string>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
callStatic: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<number>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
name(overrides?: CallOverrides): Promise<string>;
symbol(overrides?: CallOverrides): Promise<string>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<boolean>;
};
filters: {
"Approval(address,address,uint256)"(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
Approval(
owner?: PromiseOrValue<string> | null,
spender?: PromiseOrValue<string> | null,
value?: null
): ApprovalEventFilter;
"Transfer(address,address,uint256)"(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
Transfer(
from?: PromiseOrValue<string> | null,
to?: PromiseOrValue<string> | null,
value?: null
): TransferEventFilter;
};
estimateGas: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
decimals(overrides?: CallOverrides): Promise<BigNumber>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
name(overrides?: CallOverrides): Promise<BigNumber>;
symbol(overrides?: CallOverrides): Promise<BigNumber>;
totalSupply(overrides?: CallOverrides): Promise<BigNumber>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
};
populateTransaction: {
allowance(
owner: PromiseOrValue<string>,
spender: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
approve(
spender: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
balanceOf(
account: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
decimals(overrides?: CallOverrides): Promise<PopulatedTransaction>;
decreaseAllowance(
spender: PromiseOrValue<string>,
subtractedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
increaseAllowance(
spender: PromiseOrValue<string>,
addedValue: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
name(overrides?: CallOverrides): Promise<PopulatedTransaction>;
symbol(overrides?: CallOverrides): Promise<PopulatedTransaction>;
totalSupply(overrides?: CallOverrides): Promise<PopulatedTransaction>;
transfer(
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
transferFrom(
from: PromiseOrValue<string>,
to: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
};
}

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { MockToken } from "./MockToken";

View File

@ -0,0 +1,735 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PayableOverrides,
PopulatedTransaction,
Signer,
utils,
} from "ethers";
import type {
FunctionFragment,
Result,
EventFragment,
} from "@ethersproject/abi";
import type { Listener, Provider } from "@ethersproject/providers";
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from "../common";
export interface P2PIXInterface extends utils.Interface {
functions: {
"cancelDeposit(uint256)": FunctionFragment;
"defaultLockBlocks()": FunctionFragment;
"deposit(address,uint256,string)": FunctionFragment;
"depositCount()": FunctionFragment;
"lock(uint256,address,address,uint256,uint256,bytes32[])": FunctionFragment;
"owner()": FunctionFragment;
"release(bytes32,uint256,bytes32,bytes32,uint8)": FunctionFragment;
"renounceOwnership()": FunctionFragment;
"transferOwnership(address)": FunctionFragment;
"unlockExpired(bytes32[])": FunctionFragment;
"validBacenSigners(address)": FunctionFragment;
"withdraw(uint256,bytes32[])": FunctionFragment;
"withdrawPremiums()": FunctionFragment;
};
getFunction(
nameOrSignatureOrTopic:
| "cancelDeposit"
| "defaultLockBlocks"
| "deposit"
| "depositCount"
| "lock"
| "owner"
| "release"
| "renounceOwnership"
| "transferOwnership"
| "unlockExpired"
| "validBacenSigners"
| "withdraw"
| "withdrawPremiums"
): FunctionFragment;
encodeFunctionData(
functionFragment: "cancelDeposit",
values: [PromiseOrValue<BigNumberish>]
): string;
encodeFunctionData(
functionFragment: "defaultLockBlocks",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "deposit",
values: [
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<string>
]
): string;
encodeFunctionData(
functionFragment: "depositCount",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "lock",
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<string>,
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BytesLike>[]
]
): string;
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
encodeFunctionData(
functionFragment: "release",
values: [
PromiseOrValue<BytesLike>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BytesLike>,
PromiseOrValue<BytesLike>,
PromiseOrValue<BigNumberish>
]
): string;
encodeFunctionData(
functionFragment: "renounceOwnership",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "transferOwnership",
values: [PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "unlockExpired",
values: [PromiseOrValue<BytesLike>[]]
): string;
encodeFunctionData(
functionFragment: "validBacenSigners",
values: [PromiseOrValue<string>]
): string;
encodeFunctionData(
functionFragment: "withdraw",
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BytesLike>[]]
): string;
encodeFunctionData(
functionFragment: "withdrawPremiums",
values?: undefined
): string;
decodeFunctionResult(
functionFragment: "cancelDeposit",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "defaultLockBlocks",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "deposit", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "depositCount",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "lock", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "release", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "renounceOwnership",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "transferOwnership",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "unlockExpired",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "validBacenSigners",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "withdrawPremiums",
data: BytesLike
): Result;
events: {
"DepositAdded(address,uint256,address,uint256,uint256)": EventFragment;
"DepositClosed(address,uint256)": EventFragment;
"DepositWithdrawn(address,uint256,uint256)": EventFragment;
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
"LockReleased(address,bytes32)": EventFragment;
"LockReturned(address,bytes32)": EventFragment;
"OwnershipTransferred(address,address)": EventFragment;
"PremiumsWithdrawn(address,uint256)": EventFragment;
};
getEvent(nameOrSignatureOrTopic: "DepositAdded"): EventFragment;
getEvent(nameOrSignatureOrTopic: "DepositClosed"): EventFragment;
getEvent(nameOrSignatureOrTopic: "DepositWithdrawn"): EventFragment;
getEvent(nameOrSignatureOrTopic: "LockAdded"): EventFragment;
getEvent(nameOrSignatureOrTopic: "LockReleased"): EventFragment;
getEvent(nameOrSignatureOrTopic: "LockReturned"): EventFragment;
getEvent(nameOrSignatureOrTopic: "OwnershipTransferred"): EventFragment;
getEvent(nameOrSignatureOrTopic: "PremiumsWithdrawn"): EventFragment;
}
export interface DepositAddedEventObject {
seller: string;
depositID: BigNumber;
token: string;
premium: BigNumber;
amount: BigNumber;
}
export type DepositAddedEvent = TypedEvent<
[string, BigNumber, string, BigNumber, BigNumber],
DepositAddedEventObject
>;
export type DepositAddedEventFilter = TypedEventFilter<DepositAddedEvent>;
export interface DepositClosedEventObject {
seller: string;
depositID: BigNumber;
}
export type DepositClosedEvent = TypedEvent<
[string, BigNumber],
DepositClosedEventObject
>;
export type DepositClosedEventFilter = TypedEventFilter<DepositClosedEvent>;
export interface DepositWithdrawnEventObject {
seller: string;
depositID: BigNumber;
amount: BigNumber;
}
export type DepositWithdrawnEvent = TypedEvent<
[string, BigNumber, BigNumber],
DepositWithdrawnEventObject
>;
export type DepositWithdrawnEventFilter =
TypedEventFilter<DepositWithdrawnEvent>;
export interface LockAddedEventObject {
buyer: string;
lockID: string;
depositID: BigNumber;
amount: BigNumber;
}
export type LockAddedEvent = TypedEvent<
[string, string, BigNumber, BigNumber],
LockAddedEventObject
>;
export type LockAddedEventFilter = TypedEventFilter<LockAddedEvent>;
export interface LockReleasedEventObject {
buyer: string;
lockId: string;
}
export type LockReleasedEvent = TypedEvent<
[string, string],
LockReleasedEventObject
>;
export type LockReleasedEventFilter = TypedEventFilter<LockReleasedEvent>;
export interface LockReturnedEventObject {
buyer: string;
lockId: string;
}
export type LockReturnedEvent = TypedEvent<
[string, string],
LockReturnedEventObject
>;
export type LockReturnedEventFilter = TypedEventFilter<LockReturnedEvent>;
export interface OwnershipTransferredEventObject {
previousOwner: string;
newOwner: string;
}
export type OwnershipTransferredEvent = TypedEvent<
[string, string],
OwnershipTransferredEventObject
>;
export type OwnershipTransferredEventFilter =
TypedEventFilter<OwnershipTransferredEvent>;
export interface PremiumsWithdrawnEventObject {
owner: string;
amount: BigNumber;
}
export type PremiumsWithdrawnEvent = TypedEvent<
[string, BigNumber],
PremiumsWithdrawnEventObject
>;
export type PremiumsWithdrawnEventFilter =
TypedEventFilter<PremiumsWithdrawnEvent>;
export interface P2PIX extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this;
attach(addressOrName: string): this;
deployed(): Promise<this>;
interface: P2PIXInterface;
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined
): Promise<Array<TEvent>>;
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>
): Array<TypedListener<TEvent>>;
listeners(eventName?: string): Array<Listener>;
removeAllListeners<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>
): this;
removeAllListeners(eventName?: string): this;
off: OnEvent<this>;
on: OnEvent<this>;
once: OnEvent<this>;
removeListener: OnEvent<this>;
functions: {
cancelDeposit(
depositID: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
defaultLockBlocks(overrides?: CallOverrides): Promise<[BigNumber]>;
deposit(
token: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
pixTarget: PromiseOrValue<string>,
overrides?: PayableOverrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
depositCount(
overrides?: CallOverrides
): Promise<[BigNumber] & { _value: BigNumber }>;
lock(
depositID: PromiseOrValue<BigNumberish>,
targetAddress: PromiseOrValue<string>,
relayerAddress: PromiseOrValue<string>,
relayerPremium: PromiseOrValue<BigNumberish>,
amount: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
owner(overrides?: CallOverrides): Promise<[string]>;
release(
lockID: PromiseOrValue<BytesLike>,
pixTimestamp: PromiseOrValue<BigNumberish>,
r: PromiseOrValue<BytesLike>,
s: PromiseOrValue<BytesLike>,
v: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
unlockExpired(
lockIDs: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
validBacenSigners(
arg0: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<[boolean]>;
withdraw(
depositID: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
withdrawPremiums(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
};
cancelDeposit(
depositID: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
defaultLockBlocks(overrides?: CallOverrides): Promise<BigNumber>;
deposit(
token: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
pixTarget: PromiseOrValue<string>,
overrides?: PayableOverrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
depositCount(overrides?: CallOverrides): Promise<BigNumber>;
lock(
depositID: PromiseOrValue<BigNumberish>,
targetAddress: PromiseOrValue<string>,
relayerAddress: PromiseOrValue<string>,
relayerPremium: PromiseOrValue<BigNumberish>,
amount: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
owner(overrides?: CallOverrides): Promise<string>;
release(
lockID: PromiseOrValue<BytesLike>,
pixTimestamp: PromiseOrValue<BigNumberish>,
r: PromiseOrValue<BytesLike>,
s: PromiseOrValue<BytesLike>,
v: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
unlockExpired(
lockIDs: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
validBacenSigners(
arg0: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<boolean>;
withdraw(
depositID: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
withdrawPremiums(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<ContractTransaction>;
callStatic: {
cancelDeposit(
depositID: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<void>;
defaultLockBlocks(overrides?: CallOverrides): Promise<BigNumber>;
deposit(
token: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
pixTarget: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
depositCount(overrides?: CallOverrides): Promise<BigNumber>;
lock(
depositID: PromiseOrValue<BigNumberish>,
targetAddress: PromiseOrValue<string>,
relayerAddress: PromiseOrValue<string>,
relayerPremium: PromiseOrValue<BigNumberish>,
amount: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: CallOverrides
): Promise<string>;
owner(overrides?: CallOverrides): Promise<string>;
release(
lockID: PromiseOrValue<BytesLike>,
pixTimestamp: PromiseOrValue<BigNumberish>,
r: PromiseOrValue<BytesLike>,
s: PromiseOrValue<BytesLike>,
v: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides
): Promise<void>;
renounceOwnership(overrides?: CallOverrides): Promise<void>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<void>;
unlockExpired(
lockIDs: PromiseOrValue<BytesLike>[],
overrides?: CallOverrides
): Promise<void>;
validBacenSigners(
arg0: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<boolean>;
withdraw(
depositID: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: CallOverrides
): Promise<void>;
withdrawPremiums(overrides?: CallOverrides): Promise<void>;
};
filters: {
"DepositAdded(address,uint256,address,uint256,uint256)"(
seller?: PromiseOrValue<string> | null,
depositID?: null,
token?: null,
premium?: null,
amount?: null
): DepositAddedEventFilter;
DepositAdded(
seller?: PromiseOrValue<string> | null,
depositID?: null,
token?: null,
premium?: null,
amount?: null
): DepositAddedEventFilter;
"DepositClosed(address,uint256)"(
seller?: PromiseOrValue<string> | null,
depositID?: null
): DepositClosedEventFilter;
DepositClosed(
seller?: PromiseOrValue<string> | null,
depositID?: null
): DepositClosedEventFilter;
"DepositWithdrawn(address,uint256,uint256)"(
seller?: PromiseOrValue<string> | null,
depositID?: null,
amount?: null
): DepositWithdrawnEventFilter;
DepositWithdrawn(
seller?: PromiseOrValue<string> | null,
depositID?: null,
amount?: null
): DepositWithdrawnEventFilter;
"LockAdded(address,bytes32,uint256,uint256)"(
buyer?: PromiseOrValue<string> | null,
lockID?: PromiseOrValue<BytesLike> | null,
depositID?: null,
amount?: null
): LockAddedEventFilter;
LockAdded(
buyer?: PromiseOrValue<string> | null,
lockID?: PromiseOrValue<BytesLike> | null,
depositID?: null,
amount?: null
): LockAddedEventFilter;
"LockReleased(address,bytes32)"(
buyer?: PromiseOrValue<string> | null,
lockId?: null
): LockReleasedEventFilter;
LockReleased(
buyer?: PromiseOrValue<string> | null,
lockId?: null
): LockReleasedEventFilter;
"LockReturned(address,bytes32)"(
buyer?: PromiseOrValue<string> | null,
lockId?: null
): LockReturnedEventFilter;
LockReturned(
buyer?: PromiseOrValue<string> | null,
lockId?: null
): LockReturnedEventFilter;
"OwnershipTransferred(address,address)"(
previousOwner?: PromiseOrValue<string> | null,
newOwner?: PromiseOrValue<string> | null
): OwnershipTransferredEventFilter;
OwnershipTransferred(
previousOwner?: PromiseOrValue<string> | null,
newOwner?: PromiseOrValue<string> | null
): OwnershipTransferredEventFilter;
"PremiumsWithdrawn(address,uint256)"(
owner?: null,
amount?: null
): PremiumsWithdrawnEventFilter;
PremiumsWithdrawn(
owner?: null,
amount?: null
): PremiumsWithdrawnEventFilter;
};
estimateGas: {
cancelDeposit(
depositID: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
defaultLockBlocks(overrides?: CallOverrides): Promise<BigNumber>;
deposit(
token: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
pixTarget: PromiseOrValue<string>,
overrides?: PayableOverrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
depositCount(overrides?: CallOverrides): Promise<BigNumber>;
lock(
depositID: PromiseOrValue<BigNumberish>,
targetAddress: PromiseOrValue<string>,
relayerAddress: PromiseOrValue<string>,
relayerPremium: PromiseOrValue<BigNumberish>,
amount: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
owner(overrides?: CallOverrides): Promise<BigNumber>;
release(
lockID: PromiseOrValue<BytesLike>,
pixTimestamp: PromiseOrValue<BigNumberish>,
r: PromiseOrValue<BytesLike>,
s: PromiseOrValue<BytesLike>,
v: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
unlockExpired(
lockIDs: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
validBacenSigners(
arg0: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<BigNumber>;
withdraw(
depositID: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
withdrawPremiums(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<BigNumber>;
};
populateTransaction: {
cancelDeposit(
depositID: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
defaultLockBlocks(overrides?: CallOverrides): Promise<PopulatedTransaction>;
deposit(
token: PromiseOrValue<string>,
amount: PromiseOrValue<BigNumberish>,
pixTarget: PromiseOrValue<string>,
overrides?: PayableOverrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
depositCount(overrides?: CallOverrides): Promise<PopulatedTransaction>;
lock(
depositID: PromiseOrValue<BigNumberish>,
targetAddress: PromiseOrValue<string>,
relayerAddress: PromiseOrValue<string>,
relayerPremium: PromiseOrValue<BigNumberish>,
amount: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
release(
lockID: PromiseOrValue<BytesLike>,
pixTimestamp: PromiseOrValue<BigNumberish>,
r: PromiseOrValue<BytesLike>,
s: PromiseOrValue<BytesLike>,
v: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
renounceOwnership(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
transferOwnership(
newOwner: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
unlockExpired(
lockIDs: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
validBacenSigners(
arg0: PromiseOrValue<string>,
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
withdraw(
depositID: PromiseOrValue<BigNumberish>,
expiredLocks: PromiseOrValue<BytesLike>[],
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
withdrawPremiums(
overrides?: Overrides & { from?: PromiseOrValue<string> }
): Promise<PopulatedTransaction>;
};
}

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { P2PIX } from "./P2PIX";

View File

@ -1,86 +0,0 @@
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("P2PIX deposit test", function () {
let owner, wallet2, wallet3, wallet4;
let p2pix; // Contract instance
let erc20; // Token instance
it("Will deploy contracts", async function () {
[owner, wallet2, wallet3, wallet4] = await ethers.getSigners();
const ERC20Factory = await ethers.getContractFactory("MockToken");
erc20 = await ERC20Factory.deploy(ethers.utils.parseEther('20000000', 'wei'));
await erc20.deployed();
// Check initial balance
expect(await erc20.balanceOf(owner.address)).to.equal(ethers.utils.parseEther('20000000', 'wei'));
const P2PIX = await ethers.getContractFactory("P2PIX");
p2pix = await P2PIX.deploy(2, [owner.address, wallet2.address]);
await p2pix.deployed();
// Verify values at deployment
expect(await p2pix.validBacenSigners(owner.address)).to.equal(true);
expect(await p2pix.validBacenSigners(wallet2.address)).to.equal(true);
});
it("Should allow create a deposit", async function () {
let transaction = await erc20.approve(p2pix.address,ethers.utils.parseEther('2000'));
await expect(transaction).to.emit(erc20, 'Approval').withArgs(
owner.address,
p2pix.address,
ethers.utils.parseEther('2000')
)
transaction = await p2pix.deposit(
erc20.address,
ethers.utils.parseEther('1000'),
'SELLER PIX KEY',
{value:ethers.utils.parseEther('0.1')}
);
await expect(transaction).to.emit(p2pix, 'DepositAdded').withArgs(
owner.address,
0,
erc20.address,
ethers.utils.parseEther('0.1'),
ethers.utils.parseEther('1000')
)
})
it("Should allow create second deposit", async function () {
transaction = await p2pix.deposit(
erc20.address,
ethers.utils.parseEther('1000'),
'SELLER PIX KEY',
{value:ethers.utils.parseEther('0.1')}
)
await expect(transaction).to.emit(p2pix, 'DepositAdded').withArgs(
owner.address,
1,
erc20.address,
ethers.utils.parseEther('0.1'),
ethers.utils.parseEther('1000')
)
})
it("Should allow cancel first deposit", async function () {
const transaction = await p2pix.cancelDeposit(0);
await expect(transaction).to.emit(p2pix, 'DepositClosed').withArgs(
owner.address,
0
)
})
it("Should allow withdraw the deposit", async function () {
const transaction = await p2pix.withdraw(0, []);
await expect(transaction).to.emit(p2pix, 'DepositWithdrawn').withArgs(
owner.address,
0,
ethers.utils.parseEther('1000')
)
})
})

113
test/1-deposit.test.ts Normal file
View File

@ -0,0 +1,113 @@
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";
import { ethers } from "hardhat";
import { MockToken, P2PIX } from "../src/types";
describe("P2PIX deposit test", () => {
let owner: SignerWithAddress;
let wallet2: SignerWithAddress;
// let wallet3: SignerWithAddress;
// let wallet4: SignerWithAddress;
let p2pix: P2PIX; // Contract instance
let erc20: MockToken; // Token instance
it("Will deploy contracts", async () => {
[owner, wallet2 /* wallet3, wallet4 */] =
await ethers.getSigners();
const ERC20Factory = await ethers.getContractFactory(
"MockToken",
);
erc20 = await ERC20Factory.deploy(
ethers.utils.parseEther("20000000"),
);
await erc20.deployed();
// Check initial balance
expect(await erc20.balanceOf(owner.address)).to.equal(
ethers.utils.parseEther("20000000"),
);
const P2PIX = await ethers.getContractFactory("P2PIX");
p2pix = await P2PIX.deploy(2, [
owner.address,
wallet2.address,
]);
await p2pix.deployed();
// Verify values at deployment
expect(
await p2pix.validBacenSigners(owner.address),
).to.equal(true);
expect(
await p2pix.validBacenSigners(wallet2.address),
).to.equal(true);
});
it("Should allow create a deposit", async () => {
let transaction = await erc20.approve(
p2pix.address,
ethers.utils.parseEther("2000"),
);
await expect(transaction)
.to.emit(erc20, "Approval")
.withArgs(
owner.address,
p2pix.address,
ethers.utils.parseEther("2000"),
);
transaction = await p2pix.deposit(
erc20.address,
ethers.utils.parseEther("1000"),
"SELLER PIX KEY",
{ value: ethers.utils.parseEther("0.1") },
);
await expect(transaction)
.to.emit(p2pix, "DepositAdded")
.withArgs(
owner.address,
0,
erc20.address,
ethers.utils.parseEther("0.1"),
ethers.utils.parseEther("1000"),
);
});
it("Should allow create second deposit", async () => {
const transaction = await p2pix.deposit(
erc20.address,
ethers.utils.parseEther("1000"),
"SELLER PIX KEY",
{ value: ethers.utils.parseEther("0.1") },
);
await expect(transaction)
.to.emit(p2pix, "DepositAdded")
.withArgs(
owner.address,
1,
erc20.address,
ethers.utils.parseEther("0.1"),
ethers.utils.parseEther("1000"),
);
});
it("Should allow cancel first deposit", async () => {
const transaction = await p2pix.cancelDeposit(0);
await expect(transaction)
.to.emit(p2pix, "DepositClosed")
.withArgs(owner.address, 0);
});
it("Should allow withdraw the deposit", async () => {
const transaction = await p2pix.withdraw(0, []);
await expect(transaction)
.to.emit(p2pix, "DepositWithdrawn")
.withArgs(
owner.address,
0,
ethers.utils.parseEther("1000"),
);
});
});

View File

@ -1,240 +0,0 @@
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("P2PIX lock/release test", function () {
let owner, wallet2, wallet3, wallet4;
let p2pix; // Contract instance
let erc20; // Token instance
let lockID;
it("Will deploy contracts", async function () {
[owner, wallet2, wallet3, wallet4] = await ethers.getSigners();
const ERC20Factory = await ethers.getContractFactory("MockToken");
erc20 = await ERC20Factory.deploy(ethers.utils.parseEther('20000000', 'wei'));
await erc20.deployed();
// Check initial balance
expect(await erc20.balanceOf(owner.address)).to.equal(ethers.utils.parseEther('20000000', 'wei'));
const P2PIX = await ethers.getContractFactory("P2PIX");
p2pix = await P2PIX.deploy(3, [owner.address, wallet2.address]);
await p2pix.deployed();
// Verify values at deployment
expect(await p2pix.validBacenSigners(owner.address)).to.equal(true);
expect(await p2pix.validBacenSigners(wallet2.address)).to.equal(true);
expect(await p2pix.validBacenSigners(wallet3.address)).to.equal(false);
});
it("Should allow create a deposit", async function () {
let transaction = await erc20.approve(p2pix.address,ethers.utils.parseEther('1000'));
await expect(transaction).to.emit(erc20, 'Approval').withArgs(
owner.address,
p2pix.address,
ethers.utils.parseEther('1000')
)
transaction = await p2pix.deposit(
erc20.address,
ethers.utils.parseEther('1000'),
'SELLER PIX KEY',
{value:ethers.utils.parseEther('0.1')}
);
await expect(transaction).to.emit(p2pix, 'DepositAdded').withArgs(
owner.address,
0,
erc20.address,
ethers.utils.parseEther('0.1'),
ethers.utils.parseEther('1000')
)
console.log('GAS USED:', (await transaction.wait()).cumulativeGasUsed.toString())
})
it("Should allow create a new lock", async function () {
transaction = await p2pix.connect(wallet3).lock(
0,
wallet3.address,
ethers.constants.AddressZero,
'0',
ethers.utils.parseEther('100'),
[]
)
lockID = ethers.utils.solidityKeccak256(['uint256', 'uint256', 'address'], [
0,
ethers.utils.parseEther('100'),
wallet3.address
])
await expect(transaction).to.emit(p2pix, 'LockAdded').withArgs(
wallet3.address,
lockID,
0,
ethers.utils.parseEther('100')
)
console.log('GAS USED:', (await transaction.wait()).cumulativeGasUsed.toString())
})
it("Should release the locked amount to the buyer", async function () {
const endtoendID = '123';
const messageToSign = ethers.utils.solidityKeccak256(['string', 'uint256', 'uint256'], [
'SELLER PIX KEY',
ethers.utils.parseEther('100'),
endtoendID
])
// Note: messageToSign is a string, that is 66-bytes long, to sign the
// binary value, we must convert it to the 32 byte Array that
// the string represents
//
// i.e.
// // 66-byte string
// "0x592fa743889fc7f92ac2a37bb1f5ba1daf2a5c84741ca0e0061d243a2e6707ba"
// ... vs ...
// // 32 entry Uint8Array
// [ 89, 47, 167, 67, 136, 159, ... 103, 7, 186]
const messageHashBytes = ethers.utils.arrayify(messageToSign)
// Sign the string message
const flatSig = await owner.signMessage(messageHashBytes);
// For Solidity, we need the expanded-format of a signature
const sig = ethers.utils.splitSignature(flatSig);
transaction = await p2pix.connect(wallet3).release(
lockID,
endtoendID,
sig.r,
sig.s,
sig.v
)
await expect(transaction).to.emit(p2pix, 'LockReleased').withArgs(
wallet3.address,
lockID
)
console.log('GAS USED:', (await transaction.wait()).cumulativeGasUsed.toString())
expect(await erc20.balanceOf(wallet3.address)).to.equal(ethers.utils.parseEther('100'));
})
it("Should allow recreate same lock", async function () {
transaction = await p2pix.connect(wallet3).lock(
0,
wallet3.address,
ethers.constants.AddressZero,
'0',
ethers.utils.parseEther('100'),
[]
)
lockID = ethers.utils.solidityKeccak256(['uint256', 'uint256', 'address'], [
0,
ethers.utils.parseEther('100'),
wallet3.address
])
await expect(transaction).to.emit(p2pix, 'LockAdded').withArgs(
wallet3.address,
lockID,
0,
ethers.utils.parseEther('100'),
)
})
it("Should prevent create again same lock", async function () {
await expect(p2pix.connect(wallet3).lock(
0,
wallet3.address,
ethers.constants.AddressZero,
'0',
ethers.utils.parseEther('100'),
[]
)).to.be.revertedWith('P2PIX: Another lock with same ID is not expired yet');
})
it("Should release the locked amount to the buyer", async function () {
const endtoendID = '124';
const messageToSign = ethers.utils.solidityKeccak256(['string', 'uint256', 'uint256'], [
'SELLER PIX KEY',
ethers.utils.parseEther('100'),
endtoendID
])
const messageHashBytes = ethers.utils.arrayify(messageToSign)
const flatSig = await owner.signMessage(messageHashBytes);
const sig = ethers.utils.splitSignature(flatSig);
transaction = await p2pix.connect(wallet3).release(
lockID,
endtoendID,
sig.r,
sig.s,
sig.v
)
expect(await erc20.balanceOf(wallet3.address)).to.equal(ethers.utils.parseEther('200'));
})
it("Should prevent release again the lock", async function () {
const endtoendID = '125';
const messageToSign = ethers.utils.solidityKeccak256(['string', 'uint256', 'uint256'], [
'SELLER PIX KEY',
ethers.utils.parseEther('100'),
endtoendID
])
const messageHashBytes = ethers.utils.arrayify(messageToSign)
const flatSig = await owner.signMessage(messageHashBytes);
const sig = ethers.utils.splitSignature(flatSig);
await expect(p2pix.connect(wallet3).release(
lockID,
endtoendID,
sig.r,
sig.s,
sig.v
)).to.be.revertedWith('P2PIX: Lock already released or returned');
})
it("Should prevent create a 900 lock", async function () {
await expect(p2pix.connect(wallet3).lock(
0,
wallet3.address,
ethers.constants.AddressZero,
'0',
ethers.utils.parseEther('900'),
[]
)).to.be.revertedWith('P2PIX: Not enough token remaining on deposit');
})
it("Should allow recreate same lock again", async function () {
transaction = await p2pix.connect(wallet3).lock(
0,
wallet3.address,
ethers.constants.AddressZero,
'0',
ethers.utils.parseEther('100'),
[]
)
lockID = ethers.utils.solidityKeccak256(['uint256', 'uint256', 'address'], [
0,
ethers.utils.parseEther('100'),
wallet3.address
])
await expect(transaction).to.emit(p2pix, 'LockAdded').withArgs(
wallet3.address,
lockID,
0,
ethers.utils.parseEther('100')
)
})
it("Should allow unlock expired lock", async function () {
await expect(p2pix.unlockExpired([lockID]))
.to.be.revertedWith('P2PIX: Lock not expired or already released');
await network.provider.send("evm_mine");
await network.provider.send("evm_mine");
await network.provider.send("evm_mine");
transaction = await p2pix.unlockExpired([lockID])
await expect(transaction).to.emit(p2pix, 'LockReturned').withArgs(
wallet3.address,
lockID
)
})
it("Should prevent unlock again", async function () {
await expect(p2pix.unlockExpired([lockID]))
.to.be.revertedWith('P2PIX: Lock not expired or already released');
})
})

306
test/2-lock-release.test.ts Normal file
View File

@ -0,0 +1,306 @@
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";
import { ethers, network } from "hardhat";
import { MockToken, P2PIX } from "../src/types";
describe("P2PIX deposit test", () => {
let owner: SignerWithAddress;
let wallet2: SignerWithAddress;
let wallet3: SignerWithAddress;
// let wallet4: SignerWithAddress;
let p2pix: P2PIX; // Contract instance
let erc20: MockToken; // Token instance
let lockID: string;
it("Will deploy contracts", async () => {
[owner, wallet2, wallet3 /* , wallet4 */] =
await ethers.getSigners();
const ERC20Factory = await ethers.getContractFactory(
"MockToken",
);
erc20 = await ERC20Factory.deploy(
ethers.utils.parseEther("20000000"),
);
await erc20.deployed();
// Check initial balance
expect(await erc20.balanceOf(owner.address)).to.equal(
ethers.utils.parseEther("20000000"),
);
const P2PIX = await ethers.getContractFactory("P2PIX");
p2pix = await P2PIX.deploy(3, [
owner.address,
wallet2.address,
]);
await p2pix.deployed();
// Verify values at deployment
expect(
await p2pix.validBacenSigners(owner.address),
).to.equal(true);
expect(
await p2pix.validBacenSigners(wallet2.address),
).to.equal(true);
expect(
await p2pix.validBacenSigners(wallet3.address),
).to.equal(false);
});
it("Should allow create a deposit", async () => {
let transaction = await erc20.approve(
p2pix.address,
ethers.utils.parseEther("1000"),
);
await expect(transaction)
.to.emit(erc20, "Approval")
.withArgs(
owner.address,
p2pix.address,
ethers.utils.parseEther("1000"),
);
transaction = await p2pix.deposit(
erc20.address,
ethers.utils.parseEther("1000"),
"SELLER PIX KEY",
{ value: ethers.utils.parseEther("0.1") },
);
await expect(transaction)
.to.emit(p2pix, "DepositAdded")
.withArgs(
owner.address,
0,
erc20.address,
ethers.utils.parseEther("0.1"),
ethers.utils.parseEther("1000"),
);
console.log(
"GAS USED:",
(await transaction.wait()).cumulativeGasUsed.toString(),
);
});
it("Should allow create a new lock", async () => {
const transaction = await p2pix
.connect(wallet3)
.lock(
0,
wallet3.address,
ethers.constants.AddressZero,
"0",
ethers.utils.parseEther("100"),
[],
);
lockID = ethers.utils.solidityKeccak256(
["uint256", "uint256", "address"],
[0, ethers.utils.parseEther("100"), wallet3.address],
);
await expect(transaction)
.to.emit(p2pix, "LockAdded")
.withArgs(
wallet3.address,
lockID,
0,
ethers.utils.parseEther("100"),
);
console.log(
"GAS USED:",
(await transaction.wait()).cumulativeGasUsed.toString(),
);
});
it("Should release the locked amount to the buyer", async () => {
const endtoendID = "123";
const messageToSign = ethers.utils.solidityKeccak256(
["string", "uint256", "uint256"],
[
"SELLER PIX KEY",
ethers.utils.parseEther("100"),
endtoendID,
],
);
// Note: messageToSign is a string, that is 66-bytes long, to sign the
// binary value, we must convert it to the 32 byte Array that
// the string represents
//
// i.e.
// // 66-byte string
// "0x592fa743889fc7f92ac2a37bb1f5ba1daf2a5c84741ca0e0061d243a2e6707ba"
// ... vs ...
// // 32 entry Uint8Array
// [ 89, 47, 167, 67, 136, 159, ... 103, 7, 186]
const messageHashBytes =
ethers.utils.arrayify(messageToSign);
// Sign the string message
const flatSig = await owner.signMessage(messageHashBytes);
// For Solidity, we need the expanded-format of a signature
const sig = ethers.utils.splitSignature(flatSig);
const transaction = await p2pix
.connect(wallet3)
.release(lockID, endtoendID, sig.r, sig.s, sig.v);
await expect(transaction)
.to.emit(p2pix, "LockReleased")
.withArgs(wallet3.address, lockID);
console.log(
"GAS USED:",
(await transaction.wait()).cumulativeGasUsed.toString(),
);
expect(await erc20.balanceOf(wallet3.address)).to.equal(
ethers.utils.parseEther("100"),
);
});
it("Should allow recreate same lock", async () => {
const transaction = await p2pix
.connect(wallet3)
.lock(
0,
wallet3.address,
ethers.constants.AddressZero,
"0",
ethers.utils.parseEther("100"),
[],
);
lockID = ethers.utils.solidityKeccak256(
["uint256", "uint256", "address"],
[0, ethers.utils.parseEther("100"), wallet3.address],
);
await expect(transaction)
.to.emit(p2pix, "LockAdded")
.withArgs(
wallet3.address,
lockID,
0,
ethers.utils.parseEther("100"),
);
});
it("Should prevent create again same lock", async () => {
await expect(
p2pix
.connect(wallet3)
.lock(
0,
wallet3.address,
ethers.constants.AddressZero,
"0",
ethers.utils.parseEther("100"),
[],
),
).to.be.revertedWith(
"P2PIX: Another lock with same ID is not expired yet",
);
});
it("Should release the locked amount to the buyer", async () => {
const endtoendID = "124";
const messageToSign = ethers.utils.solidityKeccak256(
["string", "uint256", "uint256"],
[
"SELLER PIX KEY",
ethers.utils.parseEther("100"),
endtoendID,
],
);
const messageHashBytes =
ethers.utils.arrayify(messageToSign);
const flatSig = await owner.signMessage(messageHashBytes);
const sig = ethers.utils.splitSignature(flatSig);
await p2pix
.connect(wallet3)
.release(lockID, endtoendID, sig.r, sig.s, sig.v);
expect(await erc20.balanceOf(wallet3.address)).to.equal(
ethers.utils.parseEther("200"),
);
});
it("Should prevent release again the lock", async () => {
const endtoendID = "125";
const messageToSign = ethers.utils.solidityKeccak256(
["string", "uint256", "uint256"],
[
"SELLER PIX KEY",
ethers.utils.parseEther("100"),
endtoendID,
],
);
const messageHashBytes =
ethers.utils.arrayify(messageToSign);
const flatSig = await owner.signMessage(messageHashBytes);
const sig = ethers.utils.splitSignature(flatSig);
await expect(
p2pix
.connect(wallet3)
.release(lockID, endtoendID, sig.r, sig.s, sig.v),
).to.be.revertedWith(
"P2PIX: Lock already released or returned",
);
});
it("Should prevent create a 900 lock", async () => {
await expect(
p2pix
.connect(wallet3)
.lock(
0,
wallet3.address,
ethers.constants.AddressZero,
"0",
ethers.utils.parseEther("900"),
[],
),
).to.be.revertedWith(
"P2PIX: Not enough token remaining on deposit",
);
});
it("Should allow recreate same lock again", async () => {
const transaction = await p2pix
.connect(wallet3)
.lock(
0,
wallet3.address,
ethers.constants.AddressZero,
"0",
ethers.utils.parseEther("100"),
[],
);
lockID = ethers.utils.solidityKeccak256(
["uint256", "uint256", "address"],
[0, ethers.utils.parseEther("100"), wallet3.address],
);
await expect(transaction)
.to.emit(p2pix, "LockAdded")
.withArgs(
wallet3.address,
lockID,
0,
ethers.utils.parseEther("100"),
);
});
it("Should allow unlock expired lock", async () => {
await expect(
p2pix.unlockExpired([lockID]),
).to.be.revertedWith(
"P2PIX: Lock not expired or already released",
);
await network.provider.send("evm_mine");
await network.provider.send("evm_mine");
await network.provider.send("evm_mine");
const transaction = await p2pix.unlockExpired([lockID]);
await expect(transaction)
.to.emit(p2pix, "LockReturned")
.withArgs(wallet3.address, lockID);
});
it("Should prevent unlock again", async () => {
await expect(
p2pix.unlockExpired([lockID]),
).to.be.revertedWith(
"P2PIX: Lock not expired or already released",
);
});
});

22
tsconfig.json Normal file
View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es6"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"target": "es6"
},
"exclude": ["node_modules"],
"files": ["./hardhat.config.ts"],
"include": ["src/**/*", "test/**/*", "scripts/**/*"]
}

11140
yarn.lock Normal file

File diff suppressed because it is too large Load Diff