Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cadence 1.0: conform to latest capabilities apis #196

Open
wants to merge 2 commits into
base: cadence-1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/flow/cadence/FLOAT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ access(all) contract FLOAT: NonFungibleToken, ViewResolver {
case Type<MetadataViews.Royalties>():
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."
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -442,7 +441,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})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacob-tucker is it the correct auth change here? Why was it made account-access previously?

}

// A public interface to read the FLOATEvent
Expand Down Expand Up @@ -1049,10 +1048,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<String>() {
if dict[key] == nil || dict[key]!.getType() != Type<String>() {
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
Expand Down Expand Up @@ -1164,4 +1163,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)
}
}

12 changes: 6 additions & 6 deletions src/flow/cadence/utility/ArrayUtils.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -18,37 +18,37 @@ 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
}
}
}

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))
}
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))
}
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])
Expand Down
8 changes: 4 additions & 4 deletions src/flow/cadence/utility/FCLCrypto.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ access(all) contract FCLCrypto {
)
}

priv fun verifySignatures(
access(self) fun verifySignatures(
address: Address,
message: String,
keyIndices: [Int],
Expand Down Expand Up @@ -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"
Expand Down