diff --git a/src/flow/cadence/FLOAT.cdc b/src/flow/cadence/FLOAT.cdc index c0671b64..b70ab1a3 100644 --- a/src/flow/cadence/FLOAT.cdc +++ b/src/flow/cadence/FLOAT.cdc @@ -195,7 +195,7 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { case Type(): return MetadataViews.Royalties([ MetadataViews.Royalty( - receiver: getAccount(0x5643fd47a29770e7).capabilities.get<&{FungibleToken.Receiver}>(/public/flowTokenReceiver) ?? panic("Beneficiary does not have receiver."), + receiver: getAccount(0x5643fd47a29770e7).capabilities.get<&{FungibleToken.Receiver}>(/public/flowTokenReceiver), cut: 0.05, // 5% royalty on secondary sales description: "Emerald City DAO receives a 5% royalty from secondary sales because this NFT was created using FLOAT (https://floats.city/), a proof of attendance platform created by Emerald City DAO." ) @@ -268,8 +268,7 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { // Stores a capability to the FLOATEvents of its creator self.eventsCap = getAccount(_eventHost).capabilities.get<&FLOATEvents>(FLOAT.FLOATEventsPublicPath) - ?? panic("The associated event does not exist.") - + emit FLOATMinted( id: self.id, eventHost: _eventHost, @@ -372,14 +371,17 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { // from `ownedNFTs` (not possible after June 2022 spork), // but this makes sure the returned // ids are all actually owned by this account. - access(all) fun ownedIdsFromEvent(eventId: UInt64): [UInt64] { - let answer: [UInt64] = [] + access(all) view fun ownedIdsFromEvent(eventId: UInt64): [UInt64] { + let ownedNFTRef = &self.ownedNFTs as &{UInt64: {NonFungibleToken.NFT}} + var answer: [UInt64] = [] if let idsInEvent = self.events[eventId]?.keys { - for id in idsInEvent { - if self.ownedNFTs[id] != nil { - answer.append(id) + answer = idsInEvent.filter(view fun(_ id: UInt64): Bool { + if ownedNFTRef[id] != nil { + return true + } else { + return false } - } + }) } return answer } @@ -409,7 +411,7 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { } } - access(all) fun borrowFLOAT(id: UInt64): &NFT? { + access(all) view fun borrowFLOAT(id: UInt64): &NFT? { if let nft = &self.ownedNFTs[id] as &{NonFungibleToken.NFT}? { return nft as! &NFT } @@ -442,7 +444,7 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { // A function every verifier must implement. // Will have `assert`s in it to make sure // the user fits some criteria. - access(account) fun verify(_ params: {String: AnyStruct}) + access(all) fun verify(_ params: {String: AnyStruct}) } // A public interface to read the FLOATEvent @@ -461,16 +463,16 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { access(all) fun claim(recipient: &Collection, params: {String: AnyStruct}) access(all) fun purchase(recipient: &Collection, params: {String: AnyStruct}, payment: @{FungibleToken.Vault}) - access(all) fun getExtraMetadata(): {String: AnyStruct} - access(all) fun getSpecificExtraMetadata(key: String): AnyStruct? - access(all) fun getVerifiers(): {String: [{IVerifier}]} - access(all) fun getPrices(): {String: TokenInfo}? - access(all) fun getExtraFloatMetadata(serial: UInt64): {String: AnyStruct} - access(all) fun getSpecificExtraFloatMetadata(serial: UInt64, key: String): AnyStruct? - access(all) fun getClaims(): {UInt64: TokenIdentifier} - access(all) fun getSerialsUserClaimed(address: Address): [UInt64] - access(all) fun userHasClaimed(address: Address): Bool - access(all) fun userCanMint(address: Address): Bool + access(all) view fun getExtraMetadata(): {String: AnyStruct} + access(all) view fun getSpecificExtraMetadata(key: String): AnyStruct? + access(all) view fun getVerifiers(): {String: [{IVerifier}]} + access(all) view fun getPrices(): {String: TokenInfo}? + access(all) view fun getExtraFloatMetadata(serial: UInt64): {String: AnyStruct} + access(all) view fun getSpecificExtraFloatMetadata(serial: UInt64, key: String): AnyStruct? + access(all) view fun getClaims(): {UInt64: TokenIdentifier} + access(all) view fun getSerialsUserClaimed(address: Address): [UInt64] + access(all) view fun userHasClaimed(address: Address): Bool + access(all) view fun userCanMint(address: Address): Bool } // @@ -1049,10 +1051,10 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { // `dict[key] == nil` means: // 1. the key doesn't exist // 2. the value for the key is nil - if dict[key] == nil || dict[key]!!.getType() != Type() { + if dict[key] == nil || dict[key]!.getType() != Type() { return nil } - return dict[key]!! as! String + return dict[key]! as! String } /// Function that returns all the Metadata Views implemented by a Non Fungible Token @@ -1163,5 +1165,4 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver { FLOATEvents.createEvent(claimable: true, description: "Test description for a Discord meeting. This is soooo fun! Woohoo!", image: "bafybeifpsnwb2vkz4p6nxhgsbwgyslmlfd7jyicx5ukbj3tp7qsz7myzrq", name: "Discord Meeting", transferrable: true, url: "", verifiers: verifiers, allowMultipleClaim: false, certificateType: "ticket", visibilityMode: "picture", extraMetadata: extraMetadata) } -} - \ No newline at end of file +} \ No newline at end of file diff --git a/src/flow/cadence/utility/ArrayUtils.cdc b/src/flow/cadence/utility/ArrayUtils.cdc index 9afc65d0..9b4d3d39 100644 --- a/src/flow/cadence/utility/ArrayUtils.cdc +++ b/src/flow/cadence/utility/ArrayUtils.cdc @@ -2,7 +2,7 @@ access(all) contract ArrayUtils { - access(all) fun rangeFunc(_ start: Int, _ end: Int, _ f : ((Int):Void) ) { + access(all) fun rangeFunc(_ start: Int, _ end: Int, _ f : (fun(Int): Void) ) { var current = start while current < end{ f(current) @@ -18,13 +18,13 @@ access(all) contract ArrayUtils { return res } - access(all) fun transform(_ array: &[AnyStruct], _ f : ((AnyStruct): AnyStruct)){ + access(all) fun transform(_ array: auth(Mutate) &[AnyStruct], _ f : (fun(AnyStruct): AnyStruct)){ for i in self.range(0, array.length){ array[i] = f(array[i]) } } - access(all) fun iterate(_ array: [AnyStruct], _ f : ((AnyStruct): Bool)){ + access(all) fun iterate(_ array: [AnyStruct], _ f : (fun(AnyStruct): Bool)){ for item in array{ if !f(item){ break @@ -32,7 +32,7 @@ access(all) contract ArrayUtils { } } - access(all) fun map(_ array: [AnyStruct], _ f : ((AnyStruct): AnyStruct)) : [AnyStruct] { + access(all) fun map(_ array: [AnyStruct], _ f : (fun(AnyStruct): AnyStruct)) : [AnyStruct] { var res : [AnyStruct] = [] for item in array{ res.append(f(item)) @@ -40,7 +40,7 @@ access(all) contract ArrayUtils { return res } - access(all) fun mapStrings(_ array: [String], _ f: ((String) : String) ) : [String] { + access(all) fun mapStrings(_ array: [String], _ f: (fun(String): String) ) : [String] { var res : [String] = [] for item in array{ res.append(f(item)) @@ -48,7 +48,7 @@ access(all) contract ArrayUtils { return res } - access(all) fun reduce(_ array: [AnyStruct], _ initial: AnyStruct, _ f : ((AnyStruct, AnyStruct): AnyStruct)) : AnyStruct{ + access(all) fun reduce(_ array: [AnyStruct], _ initial: AnyStruct, _ f : (fun(AnyStruct, AnyStruct): AnyStruct)) : AnyStruct{ var res: AnyStruct = f(initial, array[0]) for i in self.range(1, array.length){ res = f(res, array[i]) diff --git a/src/flow/cadence/utility/FCLCrypto.cdc b/src/flow/cadence/utility/FCLCrypto.cdc index e8861ee4..b2d7edb4 100644 --- a/src/flow/cadence/utility/FCLCrypto.cdc +++ b/src/flow/cadence/utility/FCLCrypto.cdc @@ -37,7 +37,7 @@ access(all) contract FCLCrypto { ) } - priv fun verifySignatures( + access(self) fun verifySignatures( address: Address, message: String, keyIndices: [Int], @@ -92,9 +92,9 @@ access(all) contract FCLCrypto { return totalWeight >= 1000.0 } - priv let domainSeparationTagFlowUser: String - priv let domainSeparationTagFCLUser: String - priv let domainSeparationTagAccountProof: String + access(self) let domainSeparationTagFlowUser: String + access(self) let domainSeparationTagFCLUser: String + access(self) let domainSeparationTagAccountProof: String init() { self.domainSeparationTagFlowUser = "FLOW-V0.0-user"