Skip to content

Commit

Permalink
feat: error message and avoid saving locked collections
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosantangelo committed Oct 6, 2021
1 parent 8c37aac commit da590e8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
35 changes: 19 additions & 16 deletions src/modules/collection/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,25 @@ export function* collectionSaga(builder: BuilderAPI) {
function* handlePublishCollectionRequest(action: PublishCollectionRequestAction) {
let { collection, items, email } = action.payload
try {
// To ensure the contract address of the collection is correct, we pre-emptively save it to the server and store the response.
// This will re-generate the address and any other data generated on the server (like the salt) before actually publishing it.
yield put(saveCollectionRequest(collection))

const saveCollection: {
success: SaveCollectionSuccessAction
failure: SaveCollectionFailureAction
} = yield race({
success: take(SAVE_COLLECTION_SUCCESS),
failure: take(SAVE_COLLECTION_FAILURE)
})

if (saveCollection.success) {
collection = saveCollection.success.payload.collection
} else {
throw saveCollection.failure.payload.error
if (!isLocked(collection)) {
// To ensure the contract address of the collection is correct, we pre-emptively save it to the server and store the response.
// This will re-generate the address and any other data generated on the server (like the salt) before actually publishing it.
// We skip this step if the collection is locked to avoid an error from the server while trying to save the collection
yield put(saveCollectionRequest(collection))

const saveCollection: {
success: SaveCollectionSuccessAction
failure: SaveCollectionFailureAction
} = yield race({
success: take(SAVE_COLLECTION_SUCCESS),
failure: take(SAVE_COLLECTION_FAILURE)
})

if (saveCollection.success) {
collection = saveCollection.success.payload.collection
} else {
throw saveCollection.failure.payload.error
}
}

if (!collection.salt) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/translation/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@
"collection": {
"invalid_character": "Invalid character! The \":\" is not allowed in names",
"missing_salt": "The collection has no salt",
"locked": "The collection is locked"
"collection_locked": "The collection is locked"
},
"item": {
"Invalid identity": "Invalid Identity",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/translation/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@
"collection": {
"invalid_character": "¡Carácter invalido! El \":\" no está permitido en los nombres",
"missing_salt": "La colección no tiene salt",
"locked": "La colección está bloqueada"
"collection_locked": "La colección está bloqueada"
},
"item": {
"Invalid identity": "Identidad inválida",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/translation/languages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@
"collection": {
"invalid_character": "无效字符! 名称中不允许使用 \":\"",
"missing_salt": "集合没有盐",
"locked": "收藏已锁定"
"collection_locked": "收藏已锁定"
},
"item": {
"Invalid identity": "无效身份",
Expand Down

0 comments on commit da590e8

Please sign in to comment.