Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/v3 #14

Merged
merged 15 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file modified .DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:@next/next/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand All @@ -18,7 +17,7 @@ module.exports = {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
plugins: ['@typescript-eslint'],
rules: {
'@next/next/no-document-import-in-page': 'off',
'@next/next/no-img-element': 'off',
Expand Down
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ config.configure({
ERC721_SUBGRAPH: 'custom-subgraph-endpoint',
},
urls: {
ALCHEMY_URL: 'custom-alchemy-url',
NFTX_API_URL: 'custom-url',
},
contracts: {
multicall: false,
Expand Down
6 changes: 2 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "0.9.5",
"packages": ["packages/*"],
"version": "1.0.0",
"useWorkspaces": true,
"command": {
"publish": {
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@types/jest": "^27.4.1",
"@types/node": "^18.15.1",
"@types/react": "^18.0.7",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"better-docs": "^2.7.2",
"eslint": "^8.12.0",
"eslint-config-next": "^12.1.4",
"eslint-config-prettier": "^8.5.0",
"ethers": "^5.6.2",
"isomorphic-fetch": "^3.0.0",
"jest": "^27.5.1",
"jsdoc": "^3.6.11",
"lerna": "^6.1.0",
"rollup": "^2.70.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"typedoc": "^0.23.23",
"typescript": "^4.6.3"
"typescript": "5.2.2"
},
"workspaces": [
"packages/*"
]
],
"dependencies": {}
}
9 changes: 9 additions & 0 deletions packages/abi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `@nftx/abi`

This package contains all ABI schemas used by nftx.js and the NFTX v3 ecosystem

## Usage

```ts
import { CreateVaultZap } from '@nftx/abi';
```
20 changes: 20 additions & 0 deletions packages/abi/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const isTest = process.env.NODE_ENV === 'test';

module.exports = {
presets: [
// "@babel/preset-react",
'@babel/preset-typescript',
[
'@babel/preset-env',
{
targets: {
browsers: ['> 2%'],
},
modules: isTest ? 'commonjs' : false,
useBuiltIns: false,
loose: true,
},
],
],
sourceMaps: isTest ? 'inline' : true,
};
11 changes: 11 additions & 0 deletions packages/abi/gen-hr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fs = require('fs');
const { Interface, FormatTypes } = require('ethers/lib/utils');

const files = fs.readdirSync('./src/json');

files.forEach((file) => {
const json = require(`./src/json/${file}`);
const iface = new Interface(json);
const abi = iface.format(FormatTypes.full);
fs.writeFileSync(`./src/abis/${file}`, JSON.stringify(abi, null, 2), 'utf-8');
});
33 changes: 33 additions & 0 deletions packages/abi/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fs = require('fs');
const { Interface, FormatTypes } = require('ethers/lib/utils');

const files = fs.readdirSync('./src/abis');

const output = files.map((file) => {
const name = file.split('.')[0];
const abi = require(`./src/abis/${file}`);
const iface = new Interface(abi);
const json = JSON.parse(iface.format(FormatTypes.json));
json.forEach((item) => {
if (!item.stateMutability) {
switch (item.type) {
case 'function':
case 'constructor':
item.stateMutability = item.constant
? 'view'
: item.payable
? 'payable'
: 'nonpayable';
break;
default:
item.stateMutability = 'view';
break;
}
}
});
const result = `export const ${name} = ${JSON.stringify(json)} as const`;

return result;
});

fs.writeFileSync(`./src/index.ts`, output.join('\n\n'), 'utf8');
30 changes: 30 additions & 0 deletions packages/abi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@nftx/abi",
"version": "0.9.0",
"description": "",
"author": "Jack Ellis <[email protected]>",
"homepage": "https://github.com/NFTX-project/nftxjs#readme",
"license": "MIT",
"main": "dist/cjs/abi.js",
"module": "dist/es/abi.js",
"types": "dist/ts/index.d.ts",
"typedoc": {
"entryPoint": "src/index.ts"
},
"scripts": {
"test": "echo \"no tests\"",
"build": "rm -rf dist && node gen-hr && node generate && rollup -c && tsc -d --outDir dist/ts --emitDeclarationOnly",
"prepublishOnly": "yarn build",
"docs": "jsdoc -c ../../jsdoc.js src"
},
"publishConfig": {
"registry": "https://registry.yarnpkg.com"
},
"repository": {
"type": "git",
"url": "git+https://github.com/NFTX-project/nftxjs.git"
},
"bugs": {
"url": "https://github.com/NFTX-project/nftxjs/issues"
}
}
3 changes: 3 additions & 0 deletions packages/abi/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import base from '../../rollup.base';

export default base;
11 changes: 11 additions & 0 deletions packages/abi/src/abis/AMMFactory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
"constructor(address _logic, address admin_, bytes _data) payable",
"event AdminChanged(address previousAdmin, address newAdmin)",
"event BeaconUpgraded(address indexed beacon)",
"event Upgraded(address indexed implementation)",
"function admin() returns (address admin_)",
"function changeAdmin(address newAdmin)",
"function implementation() returns (address implementation_)",
"function upgradeTo(address newImplementation)",
"function upgradeToAndCall(address newImplementation, bytes data) payable"
]
39 changes: 39 additions & 0 deletions packages/abi/src/abis/BaseRegistrarImplementation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[
"constructor(address _ens, bytes32 _baseNode)",
"event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)",
"event ApprovalForAll(address indexed owner, address indexed operator, bool approved)",
"event ControllerAdded(address indexed controller)",
"event ControllerRemoved(address indexed controller)",
"event NameMigrated(uint256 indexed id, address indexed owner, uint256 expires)",
"event NameRegistered(uint256 indexed id, address indexed owner, uint256 expires)",
"event NameRenewed(uint256 indexed id, uint256 expires)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)",
"function GRACE_PERIOD() view returns (uint256)",
"function addController(address controller)",
"function approve(address to, uint256 tokenId)",
"function available(uint256 id) view returns (bool)",
"function balanceOf(address owner) view returns (uint256)",
"function baseNode() view returns (bytes32)",
"function controllers(address) view returns (bool)",
"function ens() view returns (address)",
"function getApproved(uint256 tokenId) view returns (address)",
"function isApprovedForAll(address owner, address operator) view returns (bool)",
"function isOwner() view returns (bool)",
"function nameExpires(uint256 id) view returns (uint256)",
"function owner() view returns (address)",
"function ownerOf(uint256 tokenId) view returns (address)",
"function reclaim(uint256 id, address owner)",
"function register(uint256 id, address owner, uint256 duration) returns (uint256)",
"function registerOnly(uint256 id, address owner, uint256 duration) returns (uint256)",
"function removeController(address controller)",
"function renew(uint256 id, uint256 duration) returns (uint256)",
"function renounceOwnership()",
"function safeTransferFrom(address from, address to, uint256 tokenId)",
"function safeTransferFrom(address from, address to, uint256 tokenId, bytes _data)",
"function setApprovalForAll(address to, bool approved)",
"function setResolver(address resolver)",
"function supportsInterface(bytes4 interfaceID) view returns (bool)",
"function transferFrom(address from, address to, uint256 tokenId)",
"function transferOwnership(address newOwner)"
]
18 changes: 18 additions & 0 deletions packages/abi/src/abis/CreateVaultZap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
"constructor(address nftxRouter_, address ammFactory_, address inventoryStaking_)",
"error InsufficientETHSent()",
"error InsufficientVTokensMinted()",
"error NotNFTOwner()",
"error R()",
"error T()",
"error UnableToSendETH()",
"function WETH() view returns (address)",
"function ammFactory() view returns (address)",
"function createVault(tuple(tuple(address assetAddress, bool is1155, bool allowAllItems, string name, string symbol) vaultInfo, tuple(uint256 moduleIndex, bytes initData) eligibilityStorage, uint256[] nftIds, uint256[] nftAmounts, uint256 vaultFeaturesFlag, tuple(uint256 mintFee, uint256 redeemFee, uint256 swapFee) vaultFees, tuple(uint256 lowerNFTPriceInETH, uint256 upperNFTPriceInETH, uint24 fee, uint256 currentNFTPriceInETH, uint256 vTokenMin, uint256 wethMin, uint256 deadline) liquidityParams) params) payable returns (uint256 vaultId)",
"function inventoryStaking() view returns (address)",
"function nftxRouter() view returns (address)",
"function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) returns (bytes4)",
"function onERC1155Received(address, address, uint256, uint256, bytes) returns (bytes4)",
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
"function vaultFactory() view returns (address)"
]
38 changes: 38 additions & 0 deletions packages/abi/src/abis/CryptoPunks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
"function name() view returns (string)",
"function punksOfferedForSale(uint256) view returns (bool isForSale, uint256 punkIndex, address seller, uint256 minValue, address onlySellTo)",
"function enterBidForPunk(uint256 punkIndex) payable",
"function totalSupply() view returns (uint256)",
"function acceptBidForPunk(uint256 punkIndex, uint256 minPrice)",
"function decimals() view returns (uint8)",
"function setInitialOwners(address[] addresses, uint256[] indices)",
"function withdraw()",
"function imageHash() view returns (string)",
"function nextPunkIndexToAssign() view returns (uint256)",
"function punkIndexToAddress(uint256) view returns (address)",
"function standard() view returns (string)",
"function punkBids(uint256) view returns (bool hasBid, uint256 punkIndex, address bidder, uint256 value)",
"function balanceOf(address) view returns (uint256)",
"function allInitialOwnersAssigned()",
"function allPunksAssigned() view returns (bool)",
"function buyPunk(uint256 punkIndex) payable",
"function transferPunk(address to, uint256 punkIndex)",
"function symbol() view returns (string)",
"function withdrawBidForPunk(uint256 punkIndex)",
"function setInitialOwner(address to, uint256 punkIndex)",
"function offerPunkForSaleToAddress(uint256 punkIndex, uint256 minSalePriceInWei, address toAddress)",
"function punksRemainingToAssign() view returns (uint256)",
"function offerPunkForSale(uint256 punkIndex, uint256 minSalePriceInWei)",
"function getPunk(uint256 punkIndex)",
"function pendingWithdrawals(address) view returns (uint256)",
"function punkNoLongerForSale(uint256 punkIndex)",
"constructor() payable",
"event Assign(address indexed to, uint256 punkIndex)",
"event Transfer(address indexed from, address indexed to, uint256 value)",
"event PunkTransfer(address indexed from, address indexed to, uint256 punkIndex)",
"event PunkOffered(uint256 indexed punkIndex, uint256 minValue, address indexed toAddress)",
"event PunkBidEntered(uint256 indexed punkIndex, uint256 value, address indexed fromAddress)",
"event PunkBidWithdrawn(uint256 indexed punkIndex, uint256 value, address indexed fromAddress)",
"event PunkBought(uint256 indexed punkIndex, uint256 value, address indexed fromAddress, address indexed toAddress)",
"event PunkNoLongerForSale(uint256 indexed punkIndex)"
]
25 changes: 25 additions & 0 deletions packages/abi/src/abis/ERC20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
"event Approval(address indexed owner, address indexed spender, uint256 value)",
"event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
"event Transfer(address indexed from, address indexed to, uint256 value)",
"function allowance(address owner, address spender) view returns (uint256)",
"function approve(address spender, uint256 amount) returns (bool)",
"function balanceOf(address account) view returns (uint256)",
"function burn(uint256 amount)",
"function burnFrom(address account, uint256 amount)",
"function changeName(string name)",
"function changeSymbol(string symbol)",
"function decimals() view returns (uint8)",
"function decreaseAllowance(address spender, uint256 subtractedValue) returns (bool)",
"function increaseAllowance(address spender, uint256 addedValue) returns (bool)",
"function initialize(string name, string symbol)",
"function mint(address to, uint256 amount)",
"function name() view returns (string)",
"function owner() view returns (address)",
"function renounceOwnership()",
"function symbol() view returns (string)",
"function totalSupply() view returns (uint256)",
"function transfer(address recipient, uint256 amount) returns (bool)",
"function transferFrom(address sender, address recipient, uint256 amount) returns (bool)",
"function transferOwnership(address newOwner)"
]
24 changes: 24 additions & 0 deletions packages/abi/src/abis/ERC721.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
"constructor()",
"event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)",
"event ApprovalForAll(address indexed owner, address indexed operator, bool approved)",
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)",
"function approve(address to, uint256 tokenId)",
"function balanceOf(address owner) view returns (uint256)",
"function baseURI() view returns (string)",
"function getApproved(uint256 tokenId) view returns (address)",
"function isApprovedForAll(address owner, address operator) view returns (bool)",
"function mint(address to, string tokenURI) returns (uint256)",
"function name() view returns (string)",
"function ownerOf(uint256 tokenId) view returns (address)",
"function safeTransferFrom(address from, address to, uint256 tokenId)",
"function safeTransferFrom(address from, address to, uint256 tokenId, bytes _data)",
"function setApprovalForAll(address operator, bool approved)",
"function supportsInterface(bytes4 interfaceId) view returns (bool)",
"function symbol() view returns (string)",
"function tokenByIndex(uint256 index) view returns (uint256)",
"function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)",
"function tokenURI(uint256 tokenId) view returns (string)",
"function totalSupply() view returns (uint256)",
"function transferFrom(address from, address to, uint256 tokenId)"
]
Loading
Loading