-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21be313
commit 45079e7
Showing
312 changed files
with
14,071 additions
and
5,756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Deploy | ||
on: | ||
push: | ||
branches: [main, develop] | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
- name: Build | ||
run: yarn ci | ||
- name: Deploy | ||
env: GH_TOKEN ${{secrets.GH_TOKEN}} | ||
NPM_TOKEN ${{secrets.NPM_TOKEN}} | ||
run: yarn lerna publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
# nftxjs | ||
# nftxjs | ||
|
||
## Development | ||
|
||
1. do your changes in the nftx.js repo | ||
2. run `yarn yalc` | ||
> this will publish each package in the repo (@nftx/core @nftx/react etc.) to the local yalc repository on your machine | ||
3. head to <insert-app> | ||
4. run `yalc add @nftx/<specific-nftxjs-package>` for each package you've changed | ||
5. run `rm -rf node_modules .next && yarn install` | ||
> because of how yalc does its symlinking, yarn/npm doesn't realise that node_modules needs rebuilding so we have to manually wipe it | ||
6. profit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
{ | ||
"packages": ["packages/*"], | ||
"version": "0.1.0", | ||
"version": "0.0.0", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"command": { | ||
"publish": { | ||
"allowBranch": "main", | ||
"allowBranch": "develop", | ||
"conventionalCommits": true, | ||
"yes": true, | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"version": { | ||
"allowBranch": "main", | ||
"conventionalCommits": true, | ||
"yes": true | ||
"allowBranch": "develop", | ||
"conventionalCommits": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
src/constants/abis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# @nftx/core | ||
|
||
## assets | ||
|
||
### fetchUserAssets | ||
|
||
### fetchAssetMetadata | ||
|
||
### isCryptoPunk | ||
|
||
### isCryptoKitty | ||
|
||
### isNonStandard721 | ||
|
||
## pools | ||
|
||
### fetchPool | ||
|
||
### fetchPools | ||
|
||
## tokens | ||
|
||
### fetchReservesForToken | ||
|
||
### fetchReservesForTokens | ||
|
||
## vaults | ||
|
||
### fetchVaultActivity | ||
|
||
### fetchVaultHoldings | ||
|
||
### fetchVaults | ||
|
||
### fetchVault | ||
|
||
### fetchVaultApy | ||
|
||
### fetchVaultApys | ||
|
||
### fetchVaultFees | ||
|
||
### fetchXTokenShare | ||
|
||
### fetchXTokenShares | ||
|
||
### isVaultSwappable | ||
|
||
### doesVaultHaveTargetSwapFee | ||
|
||
### doesVAutHaveRandomSwapFee | ||
|
||
### searchVaults | ||
|
||
### matchVault | ||
|
||
### prices | ||
|
||
### fetch0xQuote | ||
|
||
### fetchBuyPrice | ||
|
||
### fetchEthPrice | ||
|
||
### fetchSellPrice | ||
|
||
### fetchSpotPrice | ||
|
||
### fetchVaultBuyPrice | ||
|
||
### fetchVaultSellPrice | ||
|
||
### fetchVaultSwapPrice | ||
|
||
### doesNetworkSupport0x | ||
|
||
## trade | ||
|
||
### approve | ||
|
||
### buyFromVault | ||
|
||
### estimateGasAndFees | ||
|
||
### increaseGasLimit | ||
|
||
### isApproved | ||
|
||
### mintIntoVault | ||
|
||
### redeemFromVault | ||
|
||
### sellIntoVault | ||
|
||
### swapWithVault | ||
|
||
## web3 | ||
|
||
### addressEqual | ||
|
||
### fetchTokenBalance | ||
|
||
### fetchTotalSupply | ||
|
||
### getContract | ||
|
||
### MulticallContract | ||
|
||
### parseLogEvent | ||
|
||
### getChainConstant | ||
|
||
## Environment Variables | ||
|
||
`NFTX_MULTICALL=true|false` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "@nftx/api", | ||
"version": "0.0.0", | ||
"description": "", | ||
"homepage": "https://github.com/NFTX-project/nftxjs", | ||
"license": "MIT", | ||
"main": "dist/cjs/api.js", | ||
"module": "dist/es/api.js", | ||
"types": "dist/ts/index.d.ts", | ||
"publishConfig": { | ||
"registry": "https://registry.yarnpkg.com", | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/NFTX-project/nftxjs.git" | ||
}, | ||
"scripts": { | ||
"lint": "eslint --fix -c ../../.eslintrc.js --ext ts,tsx src && tsc --noEmit", | ||
"test": "echo \"no tests\" #jest --config ../../jest.config.js", | ||
"build": "rm -rf dist && rollup -c && tsc -d --outDir dist/ts --emitDeclarationOnly", | ||
"prepublishOnly": "yarn build" | ||
}, | ||
"peerDependencies": { | ||
"@ethersproject/bignumber": "^5.6.0", | ||
"@nftx/config": "<1.0.0", | ||
"@nftx/types": "<1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ethersproject/bignumber": "^5.6.0", | ||
"@nftx/config": "*", | ||
"@nftx/types": "*" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/NFTX-project/nftxjs/issues" | ||
}, | ||
"sideEffects": false, | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { readdirSync } from 'fs'; | ||
import base from '../../rollup.base'; | ||
|
||
const abis = readdirSync('../constants/abis') | ||
.filter((filename) => filename.endsWith('.json')) | ||
.map((filename) => `@nftx/constants/abis/${filename}`); | ||
|
||
const config = { | ||
...base, | ||
external: [...base.external, ...abis], | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
export interface IStream<T> { | ||
errored: boolean; | ||
ended: boolean; | ||
|
||
on(e: 'data', cb: (data: T) => any): void; | ||
on(e: 'end', cb: () => any): void; | ||
on(e: 'error', cb: (e: any) => void): any; | ||
|
||
read(): Promise<T>; | ||
} | ||
|
||
type ReadEvt = 'data' | 'end' | 'error'; | ||
type WriteEvt = 'read'; | ||
|
||
export default class Stream<T> implements IStream<T> { | ||
listeners: { | ||
[K in ReadEvt | WriteEvt]?: (...args: any[]) => any; | ||
}; | ||
errored: boolean; | ||
ended: boolean; | ||
reading: boolean; | ||
|
||
constructor() { | ||
this.reading = false; | ||
this.errored = false; | ||
this.ended = false; | ||
this.listeners = {}; | ||
} | ||
|
||
on(e: ReadEvt | WriteEvt, cb: (...args: any[]) => void) { | ||
this.listeners[e] = cb; | ||
|
||
if (e === 'data') { | ||
this.reading = true; | ||
this.listeners.read?.(); | ||
} | ||
} | ||
|
||
read() { | ||
return new Promise<T>((res, rej) => { | ||
if (this.listeners.data) { | ||
return rej( | ||
new Error( | ||
'stream is automatically reading as there is a data listener' | ||
) | ||
); | ||
} | ||
if (this.ended) { | ||
return rej(new Error('stream has ended')); | ||
} | ||
if (this.reading) { | ||
return rej(new Error('stream is already reading')); | ||
} | ||
|
||
const onEnd = this.listeners.end; | ||
const onError = this.listeners.error; | ||
|
||
const revert = () => { | ||
this.reading = false; | ||
this.listeners.data = null; | ||
this.listeners.error = onError; | ||
this.listeners.end = onEnd; | ||
}; | ||
|
||
this.listeners.data = (data) => { | ||
revert(); | ||
res(data); | ||
}; | ||
this.listeners.error = (e) => { | ||
revert(); | ||
onError?.(e); | ||
rej(e); | ||
}; | ||
this.listeners.end = () => { | ||
revert(); | ||
onEnd?.(); | ||
}; | ||
|
||
this.reading = true; | ||
this.listeners.read?.(); | ||
}); | ||
} | ||
|
||
write(data: T) { | ||
if (this.ended) { | ||
return; | ||
} | ||
|
||
this.listeners.data?.(data); | ||
|
||
if (this.listeners.data) { | ||
this.listeners.read?.(); | ||
} | ||
} | ||
|
||
error(e: any) { | ||
if (!this.ended) { | ||
this.errored = true; | ||
this.ended = true; | ||
this.listeners.error?.(e); | ||
} | ||
} | ||
|
||
end(data: T) { | ||
if (this.ended) { | ||
return; | ||
} | ||
|
||
this.listeners.data?.(data); | ||
|
||
this.ended = true; | ||
this.reading = false; | ||
this.listeners.end?.(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import config from '@nftx/config'; | ||
import type { Collection } from '@nftx/types'; | ||
import { queryApi } from '../utils'; | ||
|
||
type Response = Collection[]; | ||
|
||
const fetchUserCollections = ({ | ||
network = config.network, | ||
userAddress, | ||
}: { | ||
network?: number; | ||
userAddress: string; | ||
}) => { | ||
const url = `/${network}/users/${userAddress}/collections`; | ||
return queryApi<Response>({ | ||
url, | ||
}); | ||
}; | ||
|
||
export default fetchUserCollections; |
Oops, something went wrong.