Skip to content

Commit

Permalink
fix: Remove items hashes from standard publishing (#3190)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Sep 25, 2024
1 parent 9799b31 commit 5ff3ff0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 56 deletions.
55 changes: 8 additions & 47 deletions src/modules/collection/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ describe('when executing the approval flow', () => {
describe('when publishing a collection', () => {
let collection: Collection
let items: Item[]
let itemsContentHash: string[]
const email = 'email@domain.com'

const address = '0xa'
Expand All @@ -912,7 +911,6 @@ describe('when publishing a collection', () => {
beforeEach(() => {
collection = { salt: 'some salt', id: 'someId', name: 'name' } as Collection
items = []
itemsContentHash = []
})

describe('when saving the collection fails', () => {
Expand Down Expand Up @@ -959,10 +957,7 @@ describe('when publishing a collection', () => {
[select(getAddress), [address]],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[retry(10, 500, mockBuilder.lockCollection, lockedCollection), newLock],
[
retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, lockedCollection, email, itemsContentHash),
undefined
],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, lockedCollection, email), undefined],
[matchers.call.fn(sendTransaction), Promise.resolve(txHash)]
])
.not.put(saveCollectionRequest(collection))
Expand Down Expand Up @@ -1123,7 +1118,6 @@ describe('when publishing a collection', () => {
{ ...mockedItem, id: 'fstItem', contents: { ...mockedItem.contents, 'aFile.png': 'QmOldHash' } },
{ ...mockedItem, id: 'sndItem', contents: { 'someFile.png': 'newHash' } }
]
itemsContentHash = items.map(item => item.currentContentHash ?? '').filter(Boolean)
})

it('should put an action to save each of the items that have contents hashed with an older version', () => {
Expand All @@ -1139,7 +1133,7 @@ describe('when publishing a collection', () => {
[select(getAddress), [address]],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[retry(10, 500, mockBuilder.lockCollection, collection), newLock],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email, itemsContentHash), undefined],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email), undefined],
[matchers.call.fn(sendTransaction), Promise.resolve(txHash)]
])
.put(saveItemRequest(items[0], {}))
Expand Down Expand Up @@ -1197,7 +1191,7 @@ describe('when publishing a collection', () => {
[select(getAddress), [address]],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[retry(10, 500, mockBuilder.lockCollection, collection), newLock],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email, itemsContentHash), undefined],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email), undefined],
[matchers.call.fn(sendTransaction), Promise.resolve(txHash)]
])
.put(saveCollectionRequest(collection))
Expand Down Expand Up @@ -2030,7 +2024,6 @@ describe('when publishing a collection with fiat', () => {
let subscribeToNewsletter: boolean
let collection: Collection
let items: Item[]
let itemsContentHash: string[]
let serverItems: Item[]
let email: string
let paymentMethod: PaymentMethod
Expand Down Expand Up @@ -2065,7 +2058,6 @@ describe('when publishing a collection with fiat', () => {
describe('when no items are provided', () => {
beforeEach(() => {
items = []
itemsContentHash = []
})

describe('when the collection has the same amount of items in the server as locally', () => {
Expand All @@ -2089,10 +2081,7 @@ describe('when publishing a collection with fiat', () => {
[call([mockBuilder, 'fetchCollectionItems'], collection.id), serverItems],
[select(getAddress), 'address'],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[
retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email, itemsContentHash),
undefined
],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email), undefined],
[call([config, config.get], 'WERT_PUBLISH_FEES_ENV'), wertEnv]
])
.dispatch(publishCollectionRequest(collection, items, email, subscribeToNewsletter, paymentMethod))
Expand All @@ -2112,10 +2101,7 @@ describe('when publishing a collection with fiat', () => {
[call([mockBuilder, 'fetchCollectionItems'], collection.id), serverItems],
[select(getAddress), 'address'],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[
retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email, itemsContentHash),
undefined
],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email), undefined],
[call([config, config.get], 'WERT_PUBLISH_FEES_ENV'), wertEnv]
])
.dispatch(publishCollectionRequest(collection, items, email, subscribeToNewsletter, paymentMethod))
Expand All @@ -2136,10 +2122,7 @@ describe('when publishing a collection with fiat', () => {
[call([mockBuilder, 'fetchCollectionItems'], collection.id), serverItems],
[select(getAddress), from],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[
retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email, itemsContentHash),
undefined
],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email), undefined],
[call([config, config.get], 'WERT_PUBLISH_FEES_ENV'), wertEnv],
[put(fetchRaritiesRequest()), undefined],
[
Expand All @@ -2165,18 +2148,7 @@ describe('when publishing a collection with fiat', () => {
[call([mockBuilder, 'fetchCollectionItems'], collection.id), serverItems],
[select(getAddress), from],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[
retry(
10,
500,
mockBuilder.saveTOS,
TermsOfServiceEvent.PUBLISH_COLLECTION,
collection,
email,
itemsContentHash
),
undefined
],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email), undefined],
[call([config, config.get], 'WERT_PUBLISH_FEES_ENV'), wertEnv],
[put(fetchRaritiesRequest()), undefined],
[
Expand All @@ -2202,18 +2174,7 @@ describe('when publishing a collection with fiat', () => {
[call([mockBuilder, 'fetchCollectionItems'], collection.id), serverItems],
[select(getAddress), from],
[call(getChainIdByNetwork, Network.MATIC), ChainId.MATIC_MUMBAI],
[
retry(
10,
500,
mockBuilder.saveTOS,
TermsOfServiceEvent.PUBLISH_COLLECTION,
collection,
email,
itemsContentHash
),
undefined
],
[retry(10, 500, mockBuilder.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email), undefined],
[call([config, config.get], 'WERT_PUBLISH_FEES_ENV'), wertEnv],
[put(fetchRaritiesRequest()), undefined],
[
Expand Down
10 changes: 1 addition & 9 deletions src/modules/collection/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,7 @@ export function* collectionSaga(legacyBuilderClient: BuilderAPI, client: Builder
const manager = getContract(ContractName.CollectionManager, maticChainId)

// We wait for TOS to end first to avoid locking the collection preemptively if this endpoint fails
yield retry(
10,
500,
legacyBuilderClient.saveTOS,
TermsOfServiceEvent.PUBLISH_COLLECTION,
collection,
email,
items.map(item => item.currentContentHash ?? '').filter(Boolean)
)
yield retry(10, 500, legacyBuilderClient.saveTOS, TermsOfServiceEvent.PUBLISH_COLLECTION, collection, email)

let txHash: string

Expand Down

0 comments on commit 5ff3ff0

Please sign in to comment.