From 99516e99a3e605b4f9aed48c30a15efcc61a135d Mon Sep 17 00:00:00 2001 From: Innocent Abdullahi Date: Wed, 11 Sep 2024 08:55:29 -0700 Subject: [PATCH 1/2] don't panic ig entries doesn't exist (#77) --- escrow/contracts/Escrow.cdc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/escrow/contracts/Escrow.cdc b/escrow/contracts/Escrow.cdc index 8497186..07f2858 100644 --- a/escrow/contracts/Escrow.cdc +++ b/escrow/contracts/Escrow.cdc @@ -77,10 +77,12 @@ access(all) contract Escrow { // Withdraws an NFT entry from the leaderboard. access(contract) fun transferNftToCollection(nftID: UInt64, depositCap: Capability<&{NonFungibleToken.Collection}>) { pre { - self.entriesData[nftID] != nil : "Entry does not exist with this NFT ID" 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 + } // Remove the NFT entry's data from the leaderboard. self.entriesData.remove(key: nftID)! @@ -97,8 +99,8 @@ access(all) contract Escrow { // Burns an NFT entry from the leaderboard. access(contract) fun burn(nftID: UInt64) { - pre { - self.entriesData[nftID] != nil : "Entry does not exist with this NFT ID" + if(self.entriesData[nftID] == nil) { + return } // Remove the NFT entry's data from the leaderboard. From 19ddf0b6afd10dcb81e4a8b2324ebaf0fee10546 Mon Sep 17 00:00:00 2001 From: Innocent Abdullahi Date: Wed, 11 Sep 2024 08:55:38 -0700 Subject: [PATCH 2/2] fix nft locker (#78) * Create PackNFT_Golazos.cdc * Update PackNFT_Golazos.cdc * fix NFTLocker --- locked-nft/contracts/NFTLocker.cdc | 2 +- locked-nft/flow.json | 1 + locked-nft/lib/go/test/Makefile | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/locked-nft/contracts/NFTLocker.cdc b/locked-nft/contracts/NFTLocker.cdc index 08ecfea..d826b21 100644 --- a/locked-nft/contracts/NFTLocker.cdc +++ b/locked-nft/contracts/NFTLocker.cdc @@ -79,7 +79,7 @@ access(all) contract NFTLocker { /// Determine if NFT can be unlocked /// access(all) view fun canUnlockToken(id: UInt64, nftType: Type): Bool { - if let lockedTokens = NFTLocker.lockedTokens[nftType] { + if let lockedTokens = &NFTLocker.lockedTokens[nftType] as &{UInt64: NFTLocker.LockedData}? { if let lockedToken = lockedTokens[id] { if lockedToken.lockedUntil <= UInt64(getCurrentBlock().timestamp) { return true diff --git a/locked-nft/flow.json b/locked-nft/flow.json index 567612b..ddc7df7 100644 --- a/locked-nft/flow.json +++ b/locked-nft/flow.json @@ -20,6 +20,7 @@ "source": "./contracts/NFTLocker.cdc", "aliases": { "emulator": "f8d6e0586b0a20c7", + "mainnet": "b6f2481eba4df97b", "testnet": "ef4cd3d07a7b43ce" } }, diff --git a/locked-nft/lib/go/test/Makefile b/locked-nft/lib/go/test/Makefile index b79c5c1..fa2dc33 100644 --- a/locked-nft/lib/go/test/Makefile +++ b/locked-nft/lib/go/test/Makefile @@ -1,6 +1,6 @@ .PHONY: test test: - go test ./... + CGO_ENABLED=0 go test -tags=no_cgo ./... .PHONY: ci ci: test \ No newline at end of file