Skip to content

Commit

Permalink
add test case for empty domain tag (#232)
Browse files Browse the repository at this point in the history
* add test case for empty domain tag

* gh actions: remove need for node auth token

* bump patch version
  • Loading branch information
ryanio authored May 9, 2023
1 parent b51f27e commit 59bcd77
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@ on:
- main
pull_request:

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

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16.11.0
cache: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT_TOKEN }}

- name: Install dependencies
run: npm ci --ignore-scripts
Expand All @@ -38,12 +33,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16.11.0
cache: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT_TOKEN }}

- name: Install dependencies
run: npm ci --ignore-scripts
Expand All @@ -60,12 +53,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16.11.0
cache: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT_TOKEN }}

- name: Install dependencies
run: npm ci --ignore-scripts
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opensea/seaport-js",
"version": "1.2.0",
"version": "1.2.1",
"description": "[Seaport](https://github.com/ProjectOpenSea/seaport) is a new marketplace protocol for safely and efficiently buying and selling NFTs. This is a JavaScript library intended to make interfacing with the contract reasonable and easy.",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down
19 changes: 12 additions & 7 deletions src/__tests__/fulfill-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ItemType, MAX_INT } from "../constants";
import { TestERC1155, TestERC721 } from "../typechain";
import { CreateOrderInput, CurrencyItem } from "../types";
import * as fulfill from "../utils/fulfill";
import { getTagFromDomain } from "../utils/usecase";
import { describeWithFixture } from "./utils/setup";

describeWithFixture(
Expand Down Expand Up @@ -849,7 +850,8 @@ describeWithFixture(
{ order: thirdOrder },
],
accountAddress: fulfiller.address,
domain: OPENSEA_DOMAIN,
// When domain is empty or undefined, it should not append any tag to the calldata.
domain: undefined,
});

const approvalAction = actions[0];
Expand Down Expand Up @@ -919,15 +921,18 @@ describeWithFixture(
transactionMethods: fulfillAction.transactionMethods,
});

expect(
(
await fulfillAction.transactionMethods.buildTransaction()
).data?.slice(-8)
).to.eq(OPENSEA_TAG);
// When domain is empty or undefined, it should not append any tag to the calldata.
const emptyDomainTag = getTagFromDomain("");
const dataForBuildTransaction = (
await fulfillAction.transactionMethods.buildTransaction()
).data?.slice(-8);
expect(dataForBuildTransaction).to.not.eq(emptyDomainTag);
expect(dataForBuildTransaction).to.not.eq(OPENSEA_TAG);

const transaction = await fulfillAction.transactionMethods.transact();

expect(transaction.data.slice(-8)).to.eq(OPENSEA_TAG);
expect(transaction.data.slice(-8)).to.not.eq(emptyDomainTag);
expect(transaction.data.slice(-8)).to.not.eq(OPENSEA_TAG);

const balances = await Promise.all([
testErc1155.balanceOf(offerer.address, nftId),
Expand Down
2 changes: 2 additions & 0 deletions src/utils/usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ export const getTransactionMethods = <
const populatedTransaction = await contract.populateTransaction[
method as string
](...[...args, mergedOverrides]);

if (domain) {
const tag = getTagFromDomain(domain);
populatedTransaction.data = populatedTransaction.data + tag;
}

return populatedTransaction;
};

Expand Down

0 comments on commit 59bcd77

Please sign in to comment.