Skip to content

Commit

Permalink
Add integration tests to ci, rename Network enum to Chain, rename…
Browse files Browse the repository at this point in the history
… `API_KEY` env var to `OPENSEA_API_KEY` (#1003)

* rename API_KEY to OPENSEA_API_KEY

* rename Network enum to Chain

* add alchemy api key

* bump to seaport-js v2.0.0
  • Loading branch information
ryanio authored May 31, 2023
1 parent d7ef00c commit 955f197
Show file tree
Hide file tree
Showing 23 changed files with 504 additions and 242 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: npm install

- name: Run linters
run: npm run lint:check
run: npm run lint

test:
runs-on: ubuntu-latest
Expand All @@ -38,29 +38,29 @@ jobs:

- name: Run tests
env:
API_KEY: ${{ secrets.API_KEY }}
OPENSEA_API_KEY: ${{ secrets.OPENSEA_API_KEY }}
run: npm run test

# integration-test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version-file: .nvmrc
# cache: npm
test-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: npm

# - name: Install dependencies
# run: npm install
- name: Install dependencies
run: npm install

# - name: Run integration tests
# env:
# API_KEY: ${{ secrets.API_KEY }}
# SELL_ORDER_CONTRACT_ADDRESS: ${{ secrets.SELL_ORDER_CONTRACT_ADDRESS }}
# SELL_ORDER_TOKEN_ID: ${{ secrets.SELL_ORDER_TOKEN_ID }}
# LISTING_AMOUNT: ${{ secrets.LISTING_AMOUNT }}
# ETH_TO_WRAP: ${{ secrets.ETH_TO_WRAP }}
# run: npm run test:integration
- name: Run integration tests
env:
OPENSEA_API_KEY: ${{ secrets.OPENSEA_API_KEY }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
WALLET_PRIV_KEY: ${{ secrets.WALLET_PRIV_KEY }}
SELL_ORDER_CONTRACT_ADDRESS: ${{ secrets.SELL_ORDER_CONTRACT_ADDRESS }}
SELL_ORDER_TOKEN_ID: ${{ secrets.SELL_ORDER_TOKEN_ID }}
run: npm run test:integration

test-earliest-node-engine-support:
runs-on: ubuntu-latest
Expand All @@ -76,5 +76,5 @@ jobs:

- name: Run tests
env:
API_KEY: ${{ secrets.API_KEY }}
OPENSEA_API_KEY: ${{ secrets.OPENSEA_API_KEY }}
run: npm run test
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
[![Docs][docs-badge]][docs-link]
[![Discussions][discussions-badge]][discussions-link]

A JavaScript library for crypto-native ecommerce: buying, selling, and bidding on any cryptogood. With OpenSea.js, you can easily build your own native marketplace for your non-fungible tokens, or NFTs. These can be ERC-721 or ERC-1155 (semi-fungible) items. You don't have to deploy your own smart contracts or backend orderbooks.

Published on [GitHub](https://github.com/ProjectOpenSea/opensea-js) and [npm](https://www.npmjs.com/package/opensea-js)
A JavaScript library for crypto-native e-commerce: buying, selling, and bidding on NFTs (non-fungible tokens). With OpenSea.js, you can easily build your own native marketplace. These can be ERC-721 or ERC-1155 (semi-fungible) items. You don't have to deploy your own smart contracts or manage backend orderbooks.

- [Synopsis](#synopsis)
- [Installation](#installation)
Expand All @@ -37,7 +35,7 @@ Published on [GitHub](https://github.com/ProjectOpenSea/opensea-js) and [npm](ht
- [Private Auctions](#private-auctions)
- [Listening to Events](#listening-to-events)
- [Learning More](#learning-more)
- [Migrating to version 1.0](#migrating-to-version-10)
- [Changelog](#changelog)
- [Development Information](#development-information)
- [Diagnosing Common Issues](#diagnosing-common-issues)
- [Testing your branch locally](#testing-your-branch-locally)
Expand All @@ -60,6 +58,8 @@ Then, in your project, run:

```bash
npm install --save opensea-js
# or
yarn add opensea-js
```

## Getting Started
Expand All @@ -70,22 +70,22 @@ Then, create a new OpenSeaJS client, called an OpenSeaSDK 🚢, using your web3

```typescript
import { ethers } from "ethers";
import { OpenSeaSDK, Network } from "opensea-js";
import { OpenSeaSDK, Chain } from "opensea-js";

// This example provider won't let you make transactions, only read-only calls:
const provider = new ethers.providers.JsonRpcProvider(
"https://mainnet.infura.io"
);

const openseaSDK = new OpenSeaSDK(provider, {
networkName: Network.Main,
chain: Chain.Mainnet,
apiKey: YOUR_API_KEY,
});
```

**NOTE:** for testnet, please use `Network.Goerli` as the `networkName` - Rinkeby was deprecated in 2022.
**NOTE:** For testnet, please use `Chain.Goerli` as the `chain`. Rinkeby was deprecated in 2022.

**NOTE:** Using the sample Infura provider above won't let you authorize transactions, which are needed when approving and trading assets and currency. To make transactions, you need a provider with a private key or mnemonic set.
**NOTE:** Using the sample provider above won't let you authorize transactions, which are needed when approving and trading assets and currency. To make transactions, you need a provider with a private key or mnemonic set.

In a browser with web3 or an extension like [MetaMask](https://metamask.io/) or [Coinbase Wallet](https://www.coinbase.com/wallet), you can use `window.ethereum` to access the native provider.

Expand Down Expand Up @@ -120,7 +120,7 @@ You can fetch an asset using the `OpenSeaAPI`, which will return an `OpenSeaAsse
```TypeScript
const asset: OpenSeaAsset = await openseaSDK.api.getAsset({
tokenAddress, // string
tokenId, // string | number | null
tokenId, // string | number | BigNumber | null
})
```

Expand Down Expand Up @@ -375,7 +375,7 @@ Example for transferring 2 DAI ($2) to another address:
```typescript
const paymentToken = (await openseaSDK.api.getPaymentTokens({ symbol: "DAI" }))
.tokens[0];
const quantity = BigNumber.from(Math.pow(10, paymentToken.decimals)).times(2);
const quantity = ethers.utils.parseUnits("2", paymentToken.decimals);
const transactionHash = await openseaSDK.transfer({
asset: {
tokenId: null,
Expand Down Expand Up @@ -487,9 +487,8 @@ Events are fired whenever transactions or orders are being created, and when tra
Our recommendation is that you "forward" OpenSea events to your own store or state management system. Here's an example of doing that with a Redux action:

```typescript
import { EventType } from 'opensea-js'
import { openSeaSDK, EventType } from 'opensea-js'
import * as ActionTypes from './index'
import { openSeaSDK } from '../globalSingletons'

// ...

Expand Down Expand Up @@ -564,7 +563,7 @@ To remove all listeners and start over, just call `openseaSDK.removeAllListeners

Auto-generated documentation for each export is available [here](https://projectopensea.github.io/opensea-js/).

## Migrating to version 1.0
## Changelog

See the [Changelog](CHANGELOG.md).

Expand Down Expand Up @@ -598,7 +597,7 @@ Or run the tests:
npm test
```

Note that the tests require access to both Infura and the OpenSea API. The timeout is adjustable via the `test` script in `package.json`.
Note that the tests require access to Alchemy and the OpenSea API. The timeout is adjustable via the `test` script in `package.json`.

**Generate Documentation**

Expand Down
Loading

0 comments on commit 955f197

Please sign in to comment.