diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..1c9e52cd --- /dev/null +++ b/.github/workflows/main.yaml @@ -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 diff --git a/README.md b/README.md index 9004ee3e..a5faefc8 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index 70633834..640605fe 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/__tests__/basic-fulfill.spec.ts b/src/__tests__/basic-fulfill.spec.ts index 634322b6..6bc9eb85 100644 --- a/src/__tests__/basic-fulfill.spec.ts +++ b/src/__tests__/basic-fulfill.spec.ts @@ -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); @@ -436,7 +436,7 @@ describeWithFixture( await expect( fulfillAction.transactionRequest.send() - ).to.be.revertedWith("BadSignatureLength"); + ).to.be.revertedWith("InvalidSigner"); await consideration.approveOrders([order], offerer.address); @@ -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); @@ -1081,7 +1081,7 @@ describeWithFixture( await expect( fulfillAction.transactionRequest.send() - ).to.be.revertedWith("BadSignatureLength"); + ).to.be.revertedWith("InvalidSigner"); await consideration.approveOrders([order], offerer.address); diff --git a/src/__tests__/create-order.spec.ts b/src/__tests__/create-order.spec.ts index f92c0eab..8861811c 100644 --- a/src/__tests__/create-order.spec.ts +++ b/src/__tests__/create-order.spec.ts @@ -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, @@ -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, }, ]); @@ -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, @@ -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, }, ]); @@ -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, @@ -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, }, ]); @@ -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, @@ -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, }, ]); @@ -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, @@ -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, }, ]); @@ -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, @@ -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, }, ]); @@ -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, @@ -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, }, ]); @@ -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, @@ -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, }, ]); diff --git a/src/__tests__/sign-order.spec.ts b/src/__tests__/sign-order.spec.ts index 7ee98398..bef63f4c 100644 --- a/src/__tests__/sign-order.spec.ts +++ b/src/__tests__/sign-order.spec.ts @@ -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, @@ -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 diff --git a/src/consideration.ts b/src/consideration.ts index 77273f78..dffe7cea 100644 --- a/src/consideration.ts +++ b/src/consideration.ts @@ -20,6 +20,7 @@ import type { OrderParameters, OrderUseCase, InputCriteria, + ConsiderationInputItem, } from "./types"; import { getApprovalActions } from "./utils/approval"; import { @@ -187,6 +188,20 @@ export class Consideration { useProxy, }); + const considerationItemsWithFees = [ + ...deductFees(considerationItems, fees), + ...(currencies.length + ? fees?.map((fee) => + feeToConsiderationItem({ + fee, + token: currencies[0].token, + baseAmount: totalCurrencyAmount.startAmount, + baseEndAmount: totalCurrencyAmount.endAmount, + }) + ) ?? [] + : []), + ]; + const orderParameters: OrderParameters = { offerer, zone, @@ -194,7 +209,8 @@ export class Consideration { endTime, orderType, offer: offerItems, - consideration: considerationItems, + consideration: considerationItemsWithFees, + totalOriginalConsiderationItems: considerationItemsWithFees.length, salt, }; @@ -209,27 +225,6 @@ export class Consideration { proxyStrategy: this.config.proxyStrategy, }); - // Construct the order such that fees are deducted from the consideration amounts - const orderParametersWithDeductedFees = { - ...orderParameters, - offer: offerItems, - consideration: [ - ...deductFees(considerationItems, fees), - ...(currencies.length - ? fees?.map((fee) => - feeToConsiderationItem({ - fee, - token: currencies[0].token, - baseAmount: totalCurrencyAmount.startAmount, - baseEndAmount: totalCurrencyAmount.endAmount, - }) - ) ?? [] - : []), - ], - }; - - const signOrder = this.signOrder.bind(this); - const approvalActions = checkBalancesAndApprovals ? await getApprovalActions(insufficientApprovals, { signer, @@ -239,14 +234,14 @@ export class Consideration { const createOrderAction = { type: "create", createOrder: async () => { - const signature = await signOrder( - orderParametersWithDeductedFees, + const signature = await this.signOrder( + orderParameters, resolvedNonce, accountAddress ); return { - parameters: orderParametersWithDeductedFees, + parameters: orderParameters, nonce: resolvedNonce, signature, }; @@ -455,10 +450,12 @@ export class Consideration { unitsToFill, offerCriteria = [], considerationCriteria = [], + tips = [], }: { unitsToFill?: BigNumberish; offerCriteria?: InputCriteria[]; considerationCriteria?: InputCriteria[]; + tips?: ConsiderationInputItem[]; } = {}, accountAddress?: string ): Promise> { @@ -530,6 +527,11 @@ export class Consideration { this.config.ascendingAmountFulfillmentBuffer, }; + const tipConsiderationItems = tips.map((tip) => ({ + ...mapInputItemToOfferItem(tip), + recipient: tip.recipient ?? offerer, + })); + // We use basic fulfills as they are more optimal for simple and "hot" use cases // We cannot use basic fulfill if user is trying to partially fill though. if (!unitsToFill && shouldUseBasicFulfill(order.parameters, totalFilled)) { @@ -542,6 +544,7 @@ export class Consideration { proxy: fulfillerProxy, proxyStrategy: this.config.proxyStrategy, signer: fulfiller, + tips: tipConsiderationItems, }); } @@ -554,6 +557,7 @@ export class Consideration { totalSize: totalSize.eq(0) ? getMaximumSizeForOrder(order) : totalSize, offerCriteria, considerationCriteria, + tips: tipConsiderationItems, }, { considerationContract: this.contract, diff --git a/src/constants.ts b/src/constants.ts index ff1d2d4c..9adb116c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -2,7 +2,7 @@ import { BigNumber } from "ethers"; /* eslint-disable no-unused-vars */ export const CONSIDERATION_CONTRACT_NAME = "Consideration"; -export const CONSIDERATION_CONTRACT_VERSION = "1"; +export const CONSIDERATION_CONTRACT_VERSION = "rc.1"; export const EIP_712_ORDER_TYPE = { OrderComponents: [ { name: "offerer", type: "address" }, diff --git a/src/types.ts b/src/types.ts index 129cb05b..bbe58445 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,6 +54,7 @@ export type OrderParameters = { salt: string; offer: OfferItem[]; consideration: ConsiderationItem[]; + totalOriginalConsiderationItems: BigNumberish; }; export type OrderComponents = OrderParameters & { nonce: number }; diff --git a/src/utils/approval.ts b/src/utils/approval.ts index 21947128..2bb9dbed 100644 --- a/src/utils/approval.ts +++ b/src/utils/approval.ts @@ -4,7 +4,7 @@ import { ERC20ABI } from "../abi/ERC20"; import { ERC721ABI } from "../abi/ERC721"; import { ItemType, MAX_INT } from "../constants"; import type { ERC20, ERC721 } from "../typechain"; -import type { ApprovalAction, InputCriteria, Item } from "../types"; +import type { ApprovalAction, Item } from "../types"; import type { InsufficientApprovals } from "./balancesAndApprovals"; import { isErc1155Item, isErc721Item } from "./item"; diff --git a/src/utils/fulfill.ts b/src/utils/fulfill.ts index 238357c4..cb101dc5 100644 --- a/src/utils/fulfill.ts +++ b/src/utils/fulfill.ts @@ -10,8 +10,10 @@ import { BasicFulfillOrder, ItemType, ProxyStrategy } from "../constants"; import type { BasicOrderParametersStruct, Consideration, + OrderStruct, } from "../typechain/Consideration"; import type { + ConsiderationItem, ExchangeAction, InputCriteria, Order, @@ -196,6 +198,7 @@ export async function fulfillBasicOrder( proxy, proxyStrategy, signer, + tips = [], }: { considerationContract: Consideration; offererBalancesAndApprovals: BalancesAndApprovals; @@ -204,12 +207,14 @@ export async function fulfillBasicOrder( proxy: string; proxyStrategy: ProxyStrategy; signer: providers.JsonRpcSigner; + tips?: ConsiderationItem[]; } ): Promise> { const { offer, consideration, orderType } = orderParameters; + const considerationIncludingTips = [...consideration, ...tips]; const offerItem = offer[0]; - const [forOfferer, ...forAdditionalRecipients] = consideration; + const [forOfferer, ...forAdditionalRecipients] = considerationIncludingTips; const basicFulfillOrder = offerAndConsiderationFulfillmentMapping[offerItem.itemType]?.[ @@ -223,10 +228,13 @@ export async function fulfillBasicOrder( } const additionalRecipients = forAdditionalRecipients.map( - ({ startAmount, recipient }) => ({ amount: startAmount, recipient }) + ({ startAmount, recipient }) => ({ + amount: startAmount, + recipient, + }) ); - const considerationWithoutOfferItemType = consideration.filter( + const considerationWithoutOfferItemType = considerationIncludingTips.filter( (item) => item.itemType !== offer[0].itemType ); @@ -255,7 +263,7 @@ export async function fulfillBasicOrder( { offer, orderType, - consideration, + consideration: considerationIncludingTips, }, { offererBalancesAndApprovals, @@ -267,27 +275,32 @@ export async function fulfillBasicOrder( } ); - const useProxyForFulfiller = useProxyFromApprovals({ + const useFulfillerProxy = useProxyFromApprovals({ insufficientOwnerApprovals, insufficientProxyApprovals, proxyStrategy, }); - const approvalsToUse = useProxyForFulfiller + const approvalsToUse = useFulfillerProxy ? insufficientProxyApprovals : insufficientOwnerApprovals; - const basicOrderParameters: Omit< - BasicOrderParametersStruct, - "token" | "identifier" - > = { + const basicOrderParameters: BasicOrderParametersStruct = { offerer: orderParameters.offerer, zone: orderParameters.zone, - orderType, + orderType: orderParameters.orderType, + offerToken: offerItem.token, + offerIdentifier: offerItem.identifierOrCriteria, + offerAmount: offerItem.endAmount, + considerationToken: forOfferer.token, + considerationIdentifier: forOfferer.identifierOrCriteria, + considerationAmount: forOfferer.endAmount, startTime: orderParameters.startTime, endTime: orderParameters.endTime, salt: orderParameters.salt, + totalOriginalAdditionalRecipients: orderParameters.consideration.length - 1, signature, + useFulfillerProxy, additionalRecipients, }; @@ -303,156 +316,70 @@ export async function fulfillBasicOrder( switch (basicFulfillOrder) { case BasicFulfillOrder.ETH_FOR_ERC721: sendTransaction = () => - considerationContract.connect(signer).fulfillBasicEthForERC721Order( - forOfferer.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - }, - payableOverrides - ); + considerationContract + .connect(signer) + .fulfillBasicEthForERC721Order( + basicOrderParameters, + payableOverrides + ); populatedTransaction = considerationContract.populateTransaction.fulfillBasicEthForERC721Order( - forOfferer.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - }, + basicOrderParameters, payableOverrides ); break; case BasicFulfillOrder.ETH_FOR_ERC1155: sendTransaction = () => - considerationContract.connect(signer).fulfillBasicEthForERC1155Order( - forOfferer.endAmount, - // The order offer is ERC1155 - offerItem.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - }, - payableOverrides - ); + considerationContract + .connect(signer) + .fulfillBasicEthForERC1155Order( + basicOrderParameters, + payableOverrides + ); populatedTransaction = considerationContract.populateTransaction.fulfillBasicEthForERC1155Order( - forOfferer.endAmount, - // The order offer is ERC1155 - offerItem.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - }, + basicOrderParameters, payableOverrides ); break; case BasicFulfillOrder.ERC20_FOR_ERC721: sendTransaction = () => - considerationContract.connect(signer).fulfillBasicERC20ForERC721Order( - // The order consideration is ERC20 - forOfferer.token, - forOfferer.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - } - ); + considerationContract + .connect(signer) + .fulfillBasicERC20ForERC721Order(basicOrderParameters); populatedTransaction = considerationContract.populateTransaction.fulfillBasicERC20ForERC721Order( - // The order consideration is ERC20 - forOfferer.token, - forOfferer.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - } + basicOrderParameters ); break; case BasicFulfillOrder.ERC20_FOR_ERC1155: sendTransaction = () => - considerationContract.connect(signer).fulfillBasicERC20ForERC1155Order( - // The order consideration is ERC20 - forOfferer.token, - forOfferer.endAmount, - offerItem.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - } - ); + considerationContract + .connect(signer) + .fulfillBasicERC20ForERC1155Order(basicOrderParameters); populatedTransaction = considerationContract.populateTransaction.fulfillBasicERC20ForERC1155Order( - // The order consideration is ERC20 - forOfferer.token, - forOfferer.endAmount, - offerItem.endAmount, - { - ...basicOrderParameters, - token: offerItem.token, - identifier: offerItem.identifierOrCriteria, - } + basicOrderParameters ); break; case BasicFulfillOrder.ERC721_FOR_ERC20: sendTransaction = () => - considerationContract.connect(signer).fulfillBasicERC721ForERC20Order( - // The order offer is ERC20 - offerItem.token, - offerItem.endAmount, - { - ...basicOrderParameters, - token: forOfferer.token, - identifier: forOfferer.identifierOrCriteria, - }, - useProxyForFulfiller - ); + considerationContract + .connect(signer) + .fulfillBasicERC721ForERC20Order(basicOrderParameters); populatedTransaction = considerationContract.populateTransaction.fulfillBasicERC721ForERC20Order( - // The order offer is ERC20 - offerItem.token, - offerItem.endAmount, - { - ...basicOrderParameters, - token: forOfferer.token, - identifier: forOfferer.identifierOrCriteria, - }, - useProxyForFulfiller + basicOrderParameters ); break; case BasicFulfillOrder.ERC1155_FOR_ERC20: sendTransaction = () => - considerationContract.connect(signer).fulfillBasicERC1155ForERC20Order( - // The order offer is ERC20 - offerItem.token, - offerItem.endAmount, - // The order consideration is ERC1155 - forOfferer.endAmount, - { - ...basicOrderParameters, - token: forOfferer.token, - identifier: forOfferer.identifierOrCriteria, - }, - useProxyForFulfiller - ); + considerationContract + .connect(signer) + .fulfillBasicERC1155ForERC20Order(basicOrderParameters); populatedTransaction = considerationContract.populateTransaction.fulfillBasicERC1155ForERC20Order( - // The order offer is ERC20 - offerItem.token, - offerItem.endAmount, - // The order consideration is ERC1155 - forOfferer.endAmount, - { - ...basicOrderParameters, - token: forOfferer.token, - identifier: forOfferer.identifierOrCriteria, - }, - useProxyForFulfiller + basicOrderParameters ); } @@ -487,12 +414,14 @@ export async function fulfillStandardOrder( totalSize, offerCriteria, considerationCriteria, + tips = [], }: { unitsToFill?: BigNumberish; totalFilled: BigNumber; totalSize: BigNumber; offerCriteria: InputCriteria[]; considerationCriteria: InputCriteria[]; + tips?: ConsiderationItem[]; }, { considerationContract, @@ -531,13 +460,18 @@ export async function fulfillStandardOrder( parameters: { offer, consideration, orderType }, } = orderWithAdjustedFills; - const totalNativeAmount = getSummedTokenAndIdentifierAmounts(consideration, { - criterias: considerationCriteria, - timeBasedItemParams: { - ...timeBasedItemParams, - isConsiderationItem: true, - }, - })[ethers.constants.AddressZero]?.["0"]; + const considerationIncludingTips = [...consideration, ...tips]; + + const totalNativeAmount = getSummedTokenAndIdentifierAmounts( + considerationIncludingTips, + { + criterias: considerationCriteria, + timeBasedItemParams: { + ...timeBasedItemParams, + isConsiderationItem: true, + }, + } + )[ethers.constants.AddressZero]?.["0"]; validateOrderParameters(order.parameters, offerCriteria, { balancesAndApprovals: offererBalancesAndApprovals, @@ -553,7 +487,7 @@ export async function fulfillStandardOrder( { offer, orderType, - consideration, + consideration: considerationIncludingTips, offerCriteria, considerationCriteria, }, @@ -587,7 +521,7 @@ export async function fulfillStandardOrder( itemType === ItemType.ERC721_WITH_CRITERIA ); - const considerationCriteriaItems = consideration.filter( + const considerationCriteriaItems = considerationIncludingTips.filter( ({ itemType }) => itemType === ItemType.ERC1155_WITH_CRITERIA || itemType === ItemType.ERC721_WITH_CRITERIA @@ -619,13 +553,25 @@ export async function fulfillStandardOrder( : BigNumber.from(1); const denominator = unitsToFill ? maxUnits.div(unitsGcd) : BigNumber.from(1); + const orderAccountingForTips: OrderStruct = { + ...order, + parameters: { + ...order.parameters, + totalOriginalConsiderationItems: consideration.length, + }, + }; + const exchangeAction = { type: "exchange", transactionRequest: { send: () => useAdvanced ? considerationContract.connect(signer).fulfillAdvancedOrder( - { ...order, numerator, denominator }, + { + ...orderAccountingForTips, + numerator, + denominator, + }, hasCriteriaItems ? generateCriteriaResolvers([order], { offerCriterias: [offerCriteria], @@ -637,10 +583,14 @@ export async function fulfillStandardOrder( ) : considerationContract .connect(signer) - .fulfillOrder(order, useProxyForFulfiller, payableOverrides), + .fulfillOrder( + orderAccountingForTips, + useProxyForFulfiller, + payableOverrides + ), populatedTransaction: useAdvanced ? considerationContract.populateTransaction.fulfillAdvancedOrder( - { ...order, numerator, denominator }, + { ...orderAccountingForTips, numerator, denominator }, hasCriteriaItems ? generateCriteriaResolvers([order], { offerCriterias: [offerCriteria], @@ -651,7 +601,7 @@ export async function fulfillStandardOrder( payableOverrides ) : considerationContract.populateTransaction.fulfillOrder( - order, + orderAccountingForTips, useProxyForFulfiller, payableOverrides ), diff --git a/yarn.lock b/yarn.lock index d704d524..22f9a4e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2634,14 +2634,6 @@ buffer@^5.0.5, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0: base64-js "^1.3.1" ieee754 "^1.1.13" -buffer@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - bufferutil@^4.0.1: version "4.0.6" resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.6.tgz#ebd6c67c7922a0e902f053e5d8be5ec850e48433" @@ -3115,9 +3107,9 @@ concat-stream@^1.5.1, concat-stream@^1.6.0, concat-stream@^1.6.2: readable-stream "^2.2.2" typedarray "^0.0.6" -"consideration@git+ssh://git@github.com/ProjectOpenSea/consideration.git#c29bb528bd803d44fe8d9d679833ca5f4b3b0fe8": +"consideration@git+https://github.com/ProjectOpenSea/consideration.git#cc0357b14aded9d3d5b7fdc332aa13b9ee167d59": version "0.0.1" - resolved "git+ssh://git@github.com/ProjectOpenSea/consideration.git#c29bb528bd803d44fe8d9d679833ca5f4b3b0fe8" + resolved "git+https://github.com/ProjectOpenSea/consideration.git#cc0357b14aded9d3d5b7fdc332aa13b9ee167d59" dependencies: "@openzeppelin/contracts" "^4.4.2" eip-712 "^0.4.3" @@ -5851,7 +5843,7 @@ idna-uts46-hx@^2.3.1: dependencies: punycode "2.1.0" -ieee754@^1.1.13, ieee754@^1.2.1: +ieee754@^1.1.13: version "1.2.1" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== @@ -6548,15 +6540,6 @@ just-extend@^4.0.2: resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-4.2.1.tgz#ef5e589afb61e5d66b24eca749409a8939a8c744" integrity sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg== -keccak256@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.6.tgz#dd32fb771558fed51ce4e45a035ae7515573da58" - integrity sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw== - dependencies: - bn.js "^5.2.0" - buffer "^6.0.3" - keccak "^3.0.2" - keccak@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" @@ -6575,7 +6558,7 @@ keccak@^2.0.0: nan "^2.14.0" safe-buffer "^5.2.0" -keccak@^3.0.0, keccak@^3.0.1, keccak@^3.0.2: +keccak@^3.0.0, keccak@^3.0.1: version "3.0.2" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ==