Skip to content

Commit

Permalink
Add workflow and pull latest interface changes (#11)
Browse files Browse the repository at this point in the history
* Add workflow

* Modify yarn install

* Try this for access

* Try this for access

* Try yarnrc

* Try https

* Add yarn lock

* Try

* Try

* Try

* Support new interface

* All tests passing

* Comment out workflow file for now

* Add comment
  • Loading branch information
sunwrobert authored Apr 6, 2022
1 parent c6d6b4e commit bc30f8a
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 202 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# TODO: get back to this

# on:
# push:
# branches:
# - main
# pull_request:

# name: main workflow

# env:
# GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }}

# jobs:
# tests:
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v3

# - name: Setup Node.js
# uses: actions/setup-node@v2
# with:
# node-version: "16.11.0"
# cache: yarn
# registry-url: "https://npm.pkg.github.com"
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GH_PAT_TOKEN }}

# - name: Install dependencies
# run: yarn install --immutable --ignore-scripts
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
# PKG_AUTH_TOKEN: ${{ secrets.GH_PAT_TOKEN }}

# - name: Build
# run: yarn build

# - name: Run tests
# run: yarn test
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Consideration Javascript Library

This project contains a set of utilities to help interface with the Consideration contract.

## Installation

1. Ensure you have proper node version setup. Using `nvm` makes this really easy!
2. Run `yarn`

## Testing

### Running tests

To run the tests:

```bash
yarn test
```

The first run might fail due to typechain needing to compile. If so, just run the command again.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": {
"@0xsequence/multicall": "^0.36.7",
"consideration": "git+ssh://git@github.com/ProjectOpenSea/consideration.git#c29bb528bd803d44fe8d9d679833ca5f4b3b0fe8",
"consideration": "git+https://github.com/ProjectOpenSea/consideration.git#cc0357b14aded9d3d5b7fdc332aa13b9ee167d59",
"ethers": "^5.6.0",
"merkletreejs": "^0.2.31"
},
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/basic-fulfill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describeWithFixture(

// Should revert because signature is empty
await expect(action.transactionRequest.send()).to.be.revertedWith(
"BadSignatureLength"
"InvalidSigner"
);

await consideration.approveOrders([order], offerer.address);
Expand Down Expand Up @@ -436,7 +436,7 @@ describeWithFixture(

await expect(
fulfillAction.transactionRequest.send()
).to.be.revertedWith("BadSignatureLength");
).to.be.revertedWith("InvalidSigner");

await consideration.approveOrders([order], offerer.address);

Expand Down Expand Up @@ -847,7 +847,7 @@ describeWithFixture(
// Should revert because signature is empty
await expect(
fulfillAction.transactionRequest.send()
).to.be.revertedWith("BadSignatureLength");
).to.be.revertedWith("InvalidSigner");

await consideration.approveOrders([order], offerer.address);

Expand Down Expand Up @@ -1081,7 +1081,7 @@ describeWithFixture(

await expect(
fulfillAction.transactionRequest.send()
).to.be.revertedWith("BadSignatureLength");
).to.be.revertedWith("InvalidSigner");

await consideration.approveOrders([order], offerer.address);

Expand Down
56 changes: 48 additions & 8 deletions src/__tests__/create-order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: order.signature,
Expand All @@ -109,7 +110,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: order.parameters,
parameters: {
...order.parameters,
totalOriginalConsiderationItems:
order.parameters.consideration.length,
},
signature: order.signature,
},
]);
Expand Down Expand Up @@ -208,6 +213,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: order.signature,
Expand All @@ -218,7 +224,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: order.parameters,
parameters: {
...order.parameters,
totalOriginalConsiderationItems:
order.parameters.consideration.length,
},
signature: order.signature,
},
]);
Expand Down Expand Up @@ -366,6 +376,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: order.signature,
Expand All @@ -376,7 +387,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: order.parameters,
parameters: {
...order.parameters,
totalOriginalConsiderationItems:
order.parameters.consideration.length,
},
signature: order.signature,
},
]);
Expand Down Expand Up @@ -575,6 +590,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: order.signature,
Expand All @@ -585,7 +601,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: order.parameters,
parameters: {
...order.parameters,
totalOriginalConsiderationItems:
order.parameters.consideration.length,
},
signature: order.signature,
},
]);
Expand Down Expand Up @@ -677,6 +697,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN_VIA_PROXY,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: createdOrder.signature,
Expand All @@ -687,7 +708,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: createdOrder.parameters,
parameters: {
...createdOrder.parameters,
totalOriginalConsiderationItems:
createdOrder.parameters.consideration.length,
},
signature: createdOrder.signature,
},
]);
Expand Down Expand Up @@ -780,6 +805,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: order.signature,
Expand All @@ -790,7 +816,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: order.parameters,
parameters: {
...order.parameters,
totalOriginalConsiderationItems:
order.parameters.consideration.length,
},
signature: order.signature,
},
]);
Expand Down Expand Up @@ -905,6 +935,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: order.signature,
Expand All @@ -915,7 +946,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: order.parameters,
parameters: {
...order.parameters,
totalOriginalConsiderationItems:
order.parameters.consideration.length,
},
signature: order.signature,
},
]);
Expand Down Expand Up @@ -1028,6 +1063,7 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
orderType: OrderType.FULL_OPEN_VIA_PROXY,
salt,
startTime,
totalOriginalConsiderationItems: 2,
zone: ethers.constants.AddressZero,
},
signature: order.signature,
Expand All @@ -1038,7 +1074,11 @@ describeWithFixture("As a user I want to create an order", (fixture) => {
.connect(randomSigner)
.callStatic.validate([
{
parameters: order.parameters,
parameters: {
...order.parameters,
totalOriginalConsiderationItems:
order.parameters.consideration.length,
},
signature: order.signature,
},
]);
Expand Down
9 changes: 8 additions & 1 deletion src/__tests__/sign-order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describeWithFixture("As a user I want to sign an order", (fixture) => {
offer,
consideration: considerationData,
orderType: OrderType.FULL_OPEN,
totalOriginalConsiderationItems: considerationData.length,
salt,
startTime,
endTime,
Expand All @@ -55,7 +56,13 @@ describeWithFixture("As a user I want to sign an order", (fixture) => {
nonce.toNumber()
);

const order = { parameters: orderParameters, signature };
const order = {
parameters: {
...orderParameters,
totalOriginalConsiderationItems: orderParameters.consideration.length,
},
signature,
};

// Use a random address to verify that the signature is valid
const isValid = await considerationContract
Expand Down
Loading

0 comments on commit bc30f8a

Please sign in to comment.