-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add collection offer posting
- Loading branch information
Showing
11 changed files
with
359 additions
and
26 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,37 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.11.0 | ||
- run: npm ci | ||
- run: npm test | ||
- run: npm run build | ||
- run: yarn build | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.11.0 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
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
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,16 @@ | ||
# Integration Tests | ||
|
||
These tests were built to test the order posting functionality of the SDK. Signing and posting order requires a bit more setup than the other tests, so we detail that here. | ||
|
||
### Environment variables: | ||
|
||
- `API_KEY`: your OpenSea mainnet API key. | ||
- `WALLET_ADDRESS`: the wallet address to send your offer from. | ||
- `WALLET_PRIV_KEY`: the private key to your wallet. This is required to sign the order. | ||
- `ALCHEMY_API_KEY`: your Alchemy API key. | ||
|
||
### How to run: | ||
|
||
``` | ||
API_KEY="..." WALLET_ADDRESS="..." WALLET_PRIV_KEY="..." ALCHEMY_API_KEY="..." npm run integration_tests | ||
``` |
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,49 @@ | ||
import { ethers } from "ethers"; | ||
import { suite, test } from "mocha"; | ||
import Web3 from "web3"; | ||
import { | ||
MAINNET_API_KEY, | ||
WALLET_ADDRESS, | ||
WALLET_PRIV_KEY, | ||
ALCHEMY_API_KEY, | ||
WETH_ADDRESS, | ||
} from "../__tests__/constants"; | ||
import { OpenSeaSDK } from "../index"; | ||
import { Network } from "../types"; | ||
|
||
const webProvider = new Web3.providers.HttpProvider( | ||
`https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}` | ||
); | ||
|
||
const rpcProvider = new ethers.providers.JsonRpcProvider( | ||
`https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}` | ||
); | ||
|
||
const wallet = new ethers.Wallet( | ||
WALLET_PRIV_KEY ? WALLET_PRIV_KEY : "", | ||
rpcProvider | ||
); | ||
|
||
const sdk = new OpenSeaSDK( | ||
webProvider, | ||
{ | ||
networkName: Network.Main, | ||
apiKey: MAINNET_API_KEY, | ||
}, | ||
(line) => console.info(`MAINNET: ${line}`), | ||
wallet | ||
); | ||
|
||
suite("SDK: order posting", () => { | ||
test("Post collection offer", async () => { | ||
const collection = await sdk.api.getCollection("cool-cats-nft"); | ||
const postOrderRequest = { | ||
collectionSlug: collection.slug, | ||
accountAddress: WALLET_ADDRESS ? WALLET_ADDRESS : "", | ||
amount: "0.004", | ||
quantity: 1, | ||
paymentTokenAddress: WETH_ADDRESS, | ||
}; | ||
await sdk.createCollectionOffer(postOrderRequest); | ||
}); | ||
}); |
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
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
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
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
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
Oops, something went wrong.