Skip to content

Commit

Permalink
don't panic if entry doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Deewai committed Oct 2, 2024
1 parent 87ec3d7 commit 57674f8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 21 deletions.
5 changes: 4 additions & 1 deletion escrow/contracts/Escrow.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ access(all) contract Escrow {
// Withdraws an NFT entry from the leaderboard.
access(contract) fun transferNftToCollection(nftID: UInt64, depositCap: Capability<&{NonFungibleToken.Collection}>) {
pre {
depositCap.address == self.entriesData[nftID]!.ownerAddress : "Only the owner of the entry can withdraw it"
depositCap.check() : "Deposit capability is not valid"
}
if(self.entriesData[nftID] == nil) {
return
}
if(depositCap.address != self.entriesData[nftID]!.ownerAddress){
panic("Only the owner of the entry can withdraw it")
}


// Remove the NFT entry's data from the leaderboard.
self.entriesData.remove(key: nftID)!
Expand Down
70 changes: 50 additions & 20 deletions escrow/flow.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
{
"contracts": {
"AllDay": {
"source": "./contracts/AllDay.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"Escrow": {
"source": "./contracts/Escrow.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "4da127056dc9ba3f",
"testnet": "b6dd1b8b21744bb5"
}
},
"FungibleToken": {
"source": "./contracts/imports/FungibleToken.cdc",
"aliases": {
"emulator": "ee82856bf20e2aa6",
"mainnet": "f233dcee88fe0abe",
"testnet": "9a0766d93b6608b7",
"emulator": "ee82856bf20e2aa6"
"testnet": "9a0766d93b6608b7"
}
},
"MetadataViews": {
"source": "./contracts/imports/MetadataViews.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20",
"emulator": "f8d6e0586b0a20c7"
"testnet": "631e88ae7f1d7c20"
}
},
"NonFungibleToken": {
"source": "./contracts/imports/NonFungibleToken.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20",
"emulator": "f8d6e0586b0a20c7"
"testnet": "631e88ae7f1d7c20"
}
},
"ViewResolver": {
"source": "./contracts/imports/ViewResolver.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20",
"emulator": "f8d6e0586b0a20c7"
}
},
"AllDay" : {
"source": "./contracts/AllDay.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
}
},
"Escrow" : {
"source": "./contracts/Escrow.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7"
"testnet": "631e88ae7f1d7c20"
}
}
},
Expand All @@ -55,6 +57,34 @@
"emulator-account": {
"address": "f8d6e0586b0a20c7",
"key": "e61daee1414c57a52a1f7120e89daaf71ce3e16f396273e08142313fc4eea1d7"
},
"mainnet-admin": {
"address": "4da127056dc9ba3f",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-studio-platform-production/locations/global/keyRings/flow-mainnet-cosigners/cryptoKeys/escrow-leaderboard-signer/cryptoKeyVersions/1"
}
},
"testnet-admin": {
"address": "b6dd1b8b21744bb5",
"key": {
"type": "google-kms",
"hashAlgorithm": "SHA2_256",
"resourceID": "projects/dl-studio-platform-staging/locations/global/keyRings/flow-testnet-cosigners/cryptoKeys/escrow-leaderboard-signer/cryptoKeyVersions/1"
}
}
},
"deployments": {
"mainnet": {
"mainnet-admin": [
"Escrow"
]
},
"testnet": {
"testnet-admin": [
"Escrow"
]
}
}
}

0 comments on commit 57674f8

Please sign in to comment.