From 57674f868e7454c9f6b97f25d6a9951788d2336a Mon Sep 17 00:00:00 2001 From: Innocent Abdullahi Date: Tue, 1 Oct 2024 17:37:37 -0700 Subject: [PATCH] don't panic if entry doesn't exist --- escrow/contracts/Escrow.cdc | 5 ++- escrow/flow.json | 70 ++++++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/escrow/contracts/Escrow.cdc b/escrow/contracts/Escrow.cdc index 07f2858..1c3d89e 100644 --- a/escrow/contracts/Escrow.cdc +++ b/escrow/contracts/Escrow.cdc @@ -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)! diff --git a/escrow/flow.json b/escrow/flow.json index f8618bf..e93c4c8 100644 --- a/escrow/flow.json +++ b/escrow/flow.json @@ -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" } } }, @@ -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" + ] } } } \ No newline at end of file