From 6d0971b1f373322da4ac56cf864a2eab309e0f60 Mon Sep 17 00:00:00 2001 From: Bjarte Stien Karlsen Date: Thu, 25 Jul 2024 13:24:02 +0200 Subject: [PATCH] update script to include lost and found and wearables --- lib/find.json | 78 +++++++++++++++++++-------------------- lib/package.json | 2 +- scripts/getFindStatus.cdc | 8 ++-- 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/lib/find.json b/lib/find.json index c51503e1..56ebff2c 100644 --- a/lib/find.json +++ b/lib/find.json @@ -55,17 +55,6 @@ }, "code": "import FIND from 0xf3fcd2c1a78f5eee\n\naccess(all) struct FINDReport{\n\n access(all) let leases: [FIND.LeaseInformation]\n access(all) let leasesBids: [FIND.BidInfo]\n\n init(\n bids: [FIND.BidInfo],\n leases : [FIND.LeaseInformation],\n leasesBids: [FIND.BidInfo],\n ) {\n\n self.leases=leases\n self.leasesBids=leasesBids\n }\n}\n\n\naccess(all) fun main(user: String) : FINDReport? {\n\n let maybeAddress=FIND.resolve(user)\n if maybeAddress == nil{\n return nil\n }\n\n let address=maybeAddress!\n\n let account=getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n\n let bidCap=account.capabilities.borrow\u003c\u0026FIND.BidCollection\u003e(FIND.BidPublicPath)!\n let leaseCap = account.capabilities.borrow\u003c\u0026FIND.LeaseCollection\u003e(FIND.LeasePublicPath)!\n\n let leases = leaseCap.getLeaseInformation() \n let oldLeaseBid = bidCap.getBids() \n\n return FINDReport(\n bids: oldLeaseBid,\n leases: leases,\n leasesBids: oldLeaseBid,\n )\n}" }, - "getFindStatus": { - "spec": { - "parameters": { - "user": "String" - }, - "order": [ - "user" - ] - }, - "code": "import FIND from 0xf3fcd2c1a78f5eee\nimport Profile from 0xf3fcd2c1a78f5eee\nimport FindRelatedAccounts from 0xf3fcd2c1a78f5eee\nimport NonFungibleToken from 0xf8d6e0586b0a20c7\nimport MetadataViews from 0xf8d6e0586b0a20c7\nimport EmeraldIdentity from 0xf8d6e0586b0a20c7\nimport TokenForwarding from 0xf8d6e0586b0a20c7\nimport FungibleToken from 0xee82856bf20e2aa6\n//import \"Wearables\"\nimport FindUtils from 0xf3fcd2c1a78f5eee\nimport Clock from 0xf3fcd2c1a78f5eee\n//import \"LostAndFound\"\n\naccess(all) \nstruct FINDReport{\n access(all) let isDapper: Bool\n access(all) let profile:Profile.UserReport?\n access(all) let privateMode: Bool\n access(all) let activatedAccount: Bool\n access(all) let hasLostAndFoundItem: Bool\n access(all) let accounts : [AccountInformation]?\n //not sure\n access(all) let readyForWearables : Bool?\n\n init(profile: Profile.UserReport?,\n privateMode: Bool,\n activatedAccount: Bool,\n isDapper: Bool,\n hasLostAndFoundItem: Bool,\n accounts: [AccountInformation]?,\n readyForWearables: Bool?\n) {\n\n self.hasLostAndFoundItem=hasLostAndFoundItem\n self.profile=profile\n self.privateMode=privateMode\n self.activatedAccount=activatedAccount\n self.isDapper=isDapper\n self.accounts=accounts\n self.readyForWearables=readyForWearables\n}\n}\n\naccess(all) struct AccountInformation {\n access(all) let name: String\n access(all) let address: String\n access(all) let network: String\n access(all) let trusted: Bool\n access(all) let node: String\n\n init(name: String, address: String, network: String, trusted: Bool, node: String) {\n self.name = name\n self.address = address\n self.network = network\n self.trusted = trusted\n self.node = node\n }\n}\n\n\naccess(all) \nfun main(user: String) : FINDReport? {\n\n let maybeAddress=FIND.resolve(user)\n if maybeAddress == nil{\n return nil\n }\n\n let address=maybeAddress!\n\n //why not auth account here?\n let account=getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n\n var isDapper=false\n if let receiver =account.capabilities.borrow\u003c\u0026{FungibleToken.Receiver}\u003e(/public/flowTokenReceiver) {\n isDapper=receiver.isInstance(Type\u003c@TokenForwarding.Forwarder\u003e())\n } else {\n if let duc = account.capabilities.borrow\u003c\u0026{FungibleToken.Receiver}\u003e(/public/dapperUtilityCoinReceiver){\n isDapper = duc.isInstance(Type\u003c@TokenForwarding.Forwarder\u003e())\n } else {\n isDapper = false\n }\n }\n\n let profile=account.capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)\n var profileReport = profile?.asReport()\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets,\n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n let discordID = EmeraldIdentity.getDiscordFromAccount(account: address) ?? \"\"\n //?? EmeraldIdentityDapper.getDiscordFromAccount(account: address)\n //?? EmeraldIdentityLilico.getDiscordFromAccount(account: address)\n // ?? \"\"\n\n let emeraldIDAccounts : {String : Address} = {}\n emeraldIDAccounts[\"blocto\"] = EmeraldIdentity.getAccountFromDiscord(discordID: discordID)\n // emeraldIDAccounts[\"lilico\"] = EmeraldIdentityLilico.getAccountFromDiscord(discordID: discordID)\n // emeraldIDAccounts[\"dapper\"] = EmeraldIdentityDapper.getAccountFromDiscord(discordID: discordID)\n\n let accounts : [AccountInformation] = []\n for wallet in [\"blocto\", \"lilico\", \"dapper\"] {\n if let w = emeraldIDAccounts[wallet] {\n if w == address {\n continue\n }\n\n accounts.append(\n AccountInformation(\n name: wallet,\n address: w.toString(),\n network: \"Flow\",\n trusted: true,\n node: \"EmeraldID\")\n )\n }\n }\n\n if let allAcctsCap = FindRelatedAccounts.getCapability(address) {\n let allAcctsRef = allAcctsCap.borrow()!\n let allAccts = allAcctsRef.getAllRelatedAccountInfo()\n for acct in allAccts.values {\n // We only verify flow accounts that are mutually linked\n var trusted = false\n if acct.address != nil {\n if acct.address! == address {\n continue\n }\n trusted = allAcctsRef.linked(name: acct.name, network: acct.network, address: acct.address!)\n }\n accounts.append(AccountInformation(\n name: acct.name,\n address: acct.stringAddress,\n network: acct.network,\n trusted: trusted,\n node: \"FindRelatedAccounts\")\n )\n }\n }\n\n var readyForWearables = false\n var hasLostAndFoundItem : Bool = false\n /*\n let wearablesRef= account.storage.borrow\u003c\u0026Wearables.Collection\u003e(from: Wearables.CollectionStoragePath)\n if wearablesRef == nil {\n readyForWearables = false\n }\n\n let wearablesCap= account.capabilities.borrow\u003c\u0026{NonFungibleToken.Collection, NonFungibleToken.Receiver, ViewResolver.ResolverCollection}\u003e(Wearables.CollectionPublicPath)\n if wearablesCap == nil {\n readyForWearables = false\n }\n\n let wearablesProviderCap= account.capabilities.get\u003c\u0026{NonFungibleToken.Provider,NonFungibleToken.Collection, NonFungibleToken.Receiver, ViewResolver.ResolverCollection}\u003e(Wearables.CollectionPrivatePath)\n if !wearablesCap.check() {\n readyForWearables = false\n }\n\n for t in LostAndFound.getRedeemableTypes(address) {\n if t.isSubtype(of: Type\u003c@NonFungibleToken.NFT\u003e()) {\n hasLostAndFoundItem = true\n break\n }\n }\n */\n\n return FINDReport(\n profile: profileReport,\n privateMode: profile?.isPrivateModeEnabled() ?? false,\n activatedAccount: true,\n isDapper:isDapper,\n hasLostAndFoundItem: hasLostAndFoundItem,\n accounts: accounts,\n readyForWearables: readyForWearables,\n )\n }" - }, "getFindThoughts": { "spec": { "parameters": { @@ -327,7 +316,18 @@ "user" ] }, - "code": "import Profile from 0xf3fcd2c1a78f5eee\nimport FIND from 0xf3fcd2c1a78f5eee\n\naccess(all) fun main(user: String) : Profile.UserReport? {\n let resolveAddress = FIND.resolve(user) \n if resolveAddress == nil {return nil}\n let address = resolveAddress!\n let account = getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n var profileReport = account\n .getCapability\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)\n .borrow()?.asReport()\n\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets, \n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n return profileReport\n\n\n}" + "code": "import Profile from 0xf3fcd2c1a78f5eee\nimport FIND from 0xf3fcd2c1a78f5eee\n\naccess(all) fun main(user: String) : Profile.UserReport? {\n let resolveAddress = FIND.resolve(user) \n if resolveAddress == nil {return nil}\n let address = resolveAddress!\n let account = getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n var profileReport = account.capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)?.asReport()\n\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets, \n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n return profileReport\n\n\n}" + }, + "getProfileTest": { + "spec": { + "parameters": { + "address": "Address" + }, + "order": [ + "address" + ] + }, + "code": "//❯ flow scripts execute scripts/getProfileTest.cdc 0x70df6ccc9632a4dd -n migrationnetimport\nimport Profile from 0xf3fcd2c1a78f5eee\n\naccess(all) fun main(address: Address) : AnyStruct {\n var wallets = getAccount(address).capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)?.getWallets() ?? []\n\n for wallet in wallets {\n if wallet.name == \"USDC\" {\n return wallet.balance.id\n }\n }\n return nil\n}" }, "getRoyaltyChangedIds": { "spec": { @@ -2554,7 +2554,7 @@ "parameters": {}, "order": [] }, - "code": "import PublicPriceOracle from 0xec67451f8a58216a\n\naccess(all) fun main():UFix64? {\n\n let feeds = PublicPriceOracle.getAllSupportedOracles()\n for address in feeds.keys {\n\n let name= feeds[address]\n // let name = feeds[address]\n if name==\"FLOW/USD\" {\n return PublicPriceOracle.getLatestPrice(oracleAddr: address)\n }\n\n }\n return nil\n}" + "code": "import PublicPriceOracle from 0xec67451f8a58216a\n\naccess(all) fun main():UFix64? {\n\n let feeds = PublicPriceOracle.getAllSupportedOracles()\n for address in feeds.keys {\n\n let name= feeds[address]\n if name==\"FLOW/USD\" {\n return PublicPriceOracle.getLatestPrice(oracleAddr: address)\n }\n\n }\n return nil\n}" }, "getFlowToUSDC": { "spec": { @@ -2693,17 +2693,6 @@ }, "code": "import FIND from 0x35717efbbce11c74\n\naccess(all) struct FINDReport{\n\n access(all) let leases: [FIND.LeaseInformation]\n access(all) let leasesBids: [FIND.BidInfo]\n\n init(\n bids: [FIND.BidInfo],\n leases : [FIND.LeaseInformation],\n leasesBids: [FIND.BidInfo],\n ) {\n\n self.leases=leases\n self.leasesBids=leasesBids\n }\n}\n\n\naccess(all) fun main(user: String) : FINDReport? {\n\n let maybeAddress=FIND.resolve(user)\n if maybeAddress == nil{\n return nil\n }\n\n let address=maybeAddress!\n\n let account=getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n\n let bidCap=account.capabilities.borrow\u003c\u0026FIND.BidCollection\u003e(FIND.BidPublicPath)!\n let leaseCap = account.capabilities.borrow\u003c\u0026FIND.LeaseCollection\u003e(FIND.LeasePublicPath)!\n\n let leases = leaseCap.getLeaseInformation() \n let oldLeaseBid = bidCap.getBids() \n\n return FINDReport(\n bids: oldLeaseBid,\n leases: leases,\n leasesBids: oldLeaseBid,\n )\n}" }, - "getFindStatus": { - "spec": { - "parameters": { - "user": "String" - }, - "order": [ - "user" - ] - }, - "code": "import FIND from 0x35717efbbce11c74\nimport Profile from 0x35717efbbce11c74\nimport FindRelatedAccounts from 0x35717efbbce11c74\nimport NonFungibleToken from 0x631e88ae7f1d7c20\nimport MetadataViews from 0x631e88ae7f1d7c20\nimport EmeraldIdentity from 0xfe433270356d985c\nimport TokenForwarding from 0x51ea0e37c27a1f1a\nimport FungibleToken from 0x9a0766d93b6608b7\n//import \"Wearables\"\nimport FindUtils from 0x35717efbbce11c74\nimport Clock from 0x35717efbbce11c74\n//import \"LostAndFound\"\n\naccess(all) \nstruct FINDReport{\n access(all) let isDapper: Bool\n access(all) let profile:Profile.UserReport?\n access(all) let privateMode: Bool\n access(all) let activatedAccount: Bool\n access(all) let hasLostAndFoundItem: Bool\n access(all) let accounts : [AccountInformation]?\n //not sure\n access(all) let readyForWearables : Bool?\n\n init(profile: Profile.UserReport?,\n privateMode: Bool,\n activatedAccount: Bool,\n isDapper: Bool,\n hasLostAndFoundItem: Bool,\n accounts: [AccountInformation]?,\n readyForWearables: Bool?\n) {\n\n self.hasLostAndFoundItem=hasLostAndFoundItem\n self.profile=profile\n self.privateMode=privateMode\n self.activatedAccount=activatedAccount\n self.isDapper=isDapper\n self.accounts=accounts\n self.readyForWearables=readyForWearables\n}\n}\n\naccess(all) struct AccountInformation {\n access(all) let name: String\n access(all) let address: String\n access(all) let network: String\n access(all) let trusted: Bool\n access(all) let node: String\n\n init(name: String, address: String, network: String, trusted: Bool, node: String) {\n self.name = name\n self.address = address\n self.network = network\n self.trusted = trusted\n self.node = node\n }\n}\n\n\naccess(all) \nfun main(user: String) : FINDReport? {\n\n let maybeAddress=FIND.resolve(user)\n if maybeAddress == nil{\n return nil\n }\n\n let address=maybeAddress!\n\n //why not auth account here?\n let account=getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n\n var isDapper=false\n if let receiver =account.capabilities.borrow\u003c\u0026{FungibleToken.Receiver}\u003e(/public/flowTokenReceiver) {\n isDapper=receiver.isInstance(Type\u003c@TokenForwarding.Forwarder\u003e())\n } else {\n if let duc = account.capabilities.borrow\u003c\u0026{FungibleToken.Receiver}\u003e(/public/dapperUtilityCoinReceiver){\n isDapper = duc.isInstance(Type\u003c@TokenForwarding.Forwarder\u003e())\n } else {\n isDapper = false\n }\n }\n\n let profile=account.capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)\n var profileReport = profile?.asReport()\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets,\n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n let discordID = EmeraldIdentity.getDiscordFromAccount(account: address) ?? \"\"\n //?? EmeraldIdentityDapper.getDiscordFromAccount(account: address)\n //?? EmeraldIdentityLilico.getDiscordFromAccount(account: address)\n // ?? \"\"\n\n let emeraldIDAccounts : {String : Address} = {}\n emeraldIDAccounts[\"blocto\"] = EmeraldIdentity.getAccountFromDiscord(discordID: discordID)\n // emeraldIDAccounts[\"lilico\"] = EmeraldIdentityLilico.getAccountFromDiscord(discordID: discordID)\n // emeraldIDAccounts[\"dapper\"] = EmeraldIdentityDapper.getAccountFromDiscord(discordID: discordID)\n\n let accounts : [AccountInformation] = []\n for wallet in [\"blocto\", \"lilico\", \"dapper\"] {\n if let w = emeraldIDAccounts[wallet] {\n if w == address {\n continue\n }\n\n accounts.append(\n AccountInformation(\n name: wallet,\n address: w.toString(),\n network: \"Flow\",\n trusted: true,\n node: \"EmeraldID\")\n )\n }\n }\n\n if let allAcctsCap = FindRelatedAccounts.getCapability(address) {\n let allAcctsRef = allAcctsCap.borrow()!\n let allAccts = allAcctsRef.getAllRelatedAccountInfo()\n for acct in allAccts.values {\n // We only verify flow accounts that are mutually linked\n var trusted = false\n if acct.address != nil {\n if acct.address! == address {\n continue\n }\n trusted = allAcctsRef.linked(name: acct.name, network: acct.network, address: acct.address!)\n }\n accounts.append(AccountInformation(\n name: acct.name,\n address: acct.stringAddress,\n network: acct.network,\n trusted: trusted,\n node: \"FindRelatedAccounts\")\n )\n }\n }\n\n var readyForWearables = false\n var hasLostAndFoundItem : Bool = false\n /*\n let wearablesRef= account.storage.borrow\u003c\u0026Wearables.Collection\u003e(from: Wearables.CollectionStoragePath)\n if wearablesRef == nil {\n readyForWearables = false\n }\n\n let wearablesCap= account.capabilities.borrow\u003c\u0026{NonFungibleToken.Collection, NonFungibleToken.Receiver, ViewResolver.ResolverCollection}\u003e(Wearables.CollectionPublicPath)\n if wearablesCap == nil {\n readyForWearables = false\n }\n\n let wearablesProviderCap= account.capabilities.get\u003c\u0026{NonFungibleToken.Provider,NonFungibleToken.Collection, NonFungibleToken.Receiver, ViewResolver.ResolverCollection}\u003e(Wearables.CollectionPrivatePath)\n if !wearablesCap.check() {\n readyForWearables = false\n }\n\n for t in LostAndFound.getRedeemableTypes(address) {\n if t.isSubtype(of: Type\u003c@NonFungibleToken.NFT\u003e()) {\n hasLostAndFoundItem = true\n break\n }\n }\n */\n\n return FINDReport(\n profile: profileReport,\n privateMode: profile?.isPrivateModeEnabled() ?? false,\n activatedAccount: true,\n isDapper:isDapper,\n hasLostAndFoundItem: hasLostAndFoundItem,\n accounts: accounts,\n readyForWearables: readyForWearables,\n )\n }" - }, "getFindThoughts": { "spec": { "parameters": { @@ -2722,7 +2711,7 @@ "parameters": {}, "order": [] }, - "code": "import PublicPriceOracle from 0x8232ce4a3aff4e94\n\naccess(all) fun main():UFix64? {\n\n let feeds = PublicPriceOracle.getAllSupportedOracles()\n for address in feeds.keys {\n\n let name= feeds[address]\n // let name = feeds[address]\n if name==\"FLOW/USD\" {\n return PublicPriceOracle.getLatestPrice(oracleAddr: address)\n }\n\n }\n return nil\n}" + "code": "import PublicPriceOracle from 0x8232ce4a3aff4e94\n\naccess(all) fun main():UFix64? {\n\n let feeds = PublicPriceOracle.getAllSupportedOracles()\n for address in feeds.keys {\n\n let name= feeds[address]\n if name==\"FLOW/USD\" {\n return PublicPriceOracle.getLatestPrice(oracleAddr: address)\n }\n\n }\n return nil\n}" }, "getFlowToUSDC": { "spec": { @@ -2990,7 +2979,18 @@ "user" ] }, - "code": "import Profile from 0x35717efbbce11c74\nimport FIND from 0x35717efbbce11c74\n\naccess(all) fun main(user: String) : Profile.UserReport? {\n let resolveAddress = FIND.resolve(user) \n if resolveAddress == nil {return nil}\n let address = resolveAddress!\n let account = getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n var profileReport = account\n .getCapability\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)\n .borrow()?.asReport()\n\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets, \n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n return profileReport\n\n\n}" + "code": "import Profile from 0x35717efbbce11c74\nimport FIND from 0x35717efbbce11c74\n\naccess(all) fun main(user: String) : Profile.UserReport? {\n let resolveAddress = FIND.resolve(user) \n if resolveAddress == nil {return nil}\n let address = resolveAddress!\n let account = getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n var profileReport = account.capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)?.asReport()\n\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets, \n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n return profileReport\n\n\n}" + }, + "getProfileTest": { + "spec": { + "parameters": { + "address": "Address" + }, + "order": [ + "address" + ] + }, + "code": "//❯ flow scripts execute scripts/getProfileTest.cdc 0x70df6ccc9632a4dd -n migrationnetimport\nimport Profile from 0x35717efbbce11c74\n\naccess(all) fun main(address: Address) : AnyStruct {\n var wallets = getAccount(address).capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)?.getWallets() ?? []\n\n for wallet in wallets {\n if wallet.name == \"USDC\" {\n return wallet.balance.id\n }\n }\n return nil\n}" }, "getRoyaltyChangedIds": { "spec": { @@ -5399,17 +5399,6 @@ }, "code": "import FIND from 0x35717efbbce11c74\n\naccess(all) struct FINDReport{\n\n access(all) let leases: [FIND.LeaseInformation]\n access(all) let leasesBids: [FIND.BidInfo]\n\n init(\n bids: [FIND.BidInfo],\n leases : [FIND.LeaseInformation],\n leasesBids: [FIND.BidInfo],\n ) {\n\n self.leases=leases\n self.leasesBids=leasesBids\n }\n}\n\n\naccess(all) fun main(user: String) : FINDReport? {\n\n let maybeAddress=FIND.resolve(user)\n if maybeAddress == nil{\n return nil\n }\n\n let address=maybeAddress!\n\n let account=getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n\n let bidCap=account.capabilities.borrow\u003c\u0026FIND.BidCollection\u003e(FIND.BidPublicPath)!\n let leaseCap = account.capabilities.borrow\u003c\u0026FIND.LeaseCollection\u003e(FIND.LeasePublicPath)!\n\n let leases = leaseCap.getLeaseInformation() \n let oldLeaseBid = bidCap.getBids() \n\n return FINDReport(\n bids: oldLeaseBid,\n leases: leases,\n leasesBids: oldLeaseBid,\n )\n}" }, - "getFindStatus": { - "spec": { - "parameters": { - "user": "String" - }, - "order": [ - "user" - ] - }, - "code": "import FIND from 0x35717efbbce11c74\nimport Profile from 0x35717efbbce11c74\nimport FindRelatedAccounts from 0x35717efbbce11c74\nimport NonFungibleToken from 0x631e88ae7f1d7c20\nimport MetadataViews from 0x631e88ae7f1d7c20\nimport EmeraldIdentity from 0xfe433270356d985c\nimport TokenForwarding from 0x51ea0e37c27a1f1a\nimport FungibleToken from 0x9a0766d93b6608b7\n//import \"Wearables\"\nimport FindUtils from 0x35717efbbce11c74\nimport Clock from 0x35717efbbce11c74\n//import \"LostAndFound\"\n\naccess(all) \nstruct FINDReport{\n access(all) let isDapper: Bool\n access(all) let profile:Profile.UserReport?\n access(all) let privateMode: Bool\n access(all) let activatedAccount: Bool\n access(all) let hasLostAndFoundItem: Bool\n access(all) let accounts : [AccountInformation]?\n //not sure\n access(all) let readyForWearables : Bool?\n\n init(profile: Profile.UserReport?,\n privateMode: Bool,\n activatedAccount: Bool,\n isDapper: Bool,\n hasLostAndFoundItem: Bool,\n accounts: [AccountInformation]?,\n readyForWearables: Bool?\n) {\n\n self.hasLostAndFoundItem=hasLostAndFoundItem\n self.profile=profile\n self.privateMode=privateMode\n self.activatedAccount=activatedAccount\n self.isDapper=isDapper\n self.accounts=accounts\n self.readyForWearables=readyForWearables\n}\n}\n\naccess(all) struct AccountInformation {\n access(all) let name: String\n access(all) let address: String\n access(all) let network: String\n access(all) let trusted: Bool\n access(all) let node: String\n\n init(name: String, address: String, network: String, trusted: Bool, node: String) {\n self.name = name\n self.address = address\n self.network = network\n self.trusted = trusted\n self.node = node\n }\n}\n\n\naccess(all) \nfun main(user: String) : FINDReport? {\n\n let maybeAddress=FIND.resolve(user)\n if maybeAddress == nil{\n return nil\n }\n\n let address=maybeAddress!\n\n //why not auth account here?\n let account=getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n\n var isDapper=false\n if let receiver =account.capabilities.borrow\u003c\u0026{FungibleToken.Receiver}\u003e(/public/flowTokenReceiver) {\n isDapper=receiver.isInstance(Type\u003c@TokenForwarding.Forwarder\u003e())\n } else {\n if let duc = account.capabilities.borrow\u003c\u0026{FungibleToken.Receiver}\u003e(/public/dapperUtilityCoinReceiver){\n isDapper = duc.isInstance(Type\u003c@TokenForwarding.Forwarder\u003e())\n } else {\n isDapper = false\n }\n }\n\n let profile=account.capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)\n var profileReport = profile?.asReport()\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets,\n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n let discordID = EmeraldIdentity.getDiscordFromAccount(account: address) ?? \"\"\n //?? EmeraldIdentityDapper.getDiscordFromAccount(account: address)\n //?? EmeraldIdentityLilico.getDiscordFromAccount(account: address)\n // ?? \"\"\n\n let emeraldIDAccounts : {String : Address} = {}\n emeraldIDAccounts[\"blocto\"] = EmeraldIdentity.getAccountFromDiscord(discordID: discordID)\n // emeraldIDAccounts[\"lilico\"] = EmeraldIdentityLilico.getAccountFromDiscord(discordID: discordID)\n // emeraldIDAccounts[\"dapper\"] = EmeraldIdentityDapper.getAccountFromDiscord(discordID: discordID)\n\n let accounts : [AccountInformation] = []\n for wallet in [\"blocto\", \"lilico\", \"dapper\"] {\n if let w = emeraldIDAccounts[wallet] {\n if w == address {\n continue\n }\n\n accounts.append(\n AccountInformation(\n name: wallet,\n address: w.toString(),\n network: \"Flow\",\n trusted: true,\n node: \"EmeraldID\")\n )\n }\n }\n\n if let allAcctsCap = FindRelatedAccounts.getCapability(address) {\n let allAcctsRef = allAcctsCap.borrow()!\n let allAccts = allAcctsRef.getAllRelatedAccountInfo()\n for acct in allAccts.values {\n // We only verify flow accounts that are mutually linked\n var trusted = false\n if acct.address != nil {\n if acct.address! == address {\n continue\n }\n trusted = allAcctsRef.linked(name: acct.name, network: acct.network, address: acct.address!)\n }\n accounts.append(AccountInformation(\n name: acct.name,\n address: acct.stringAddress,\n network: acct.network,\n trusted: trusted,\n node: \"FindRelatedAccounts\")\n )\n }\n }\n\n var readyForWearables = false\n var hasLostAndFoundItem : Bool = false\n /*\n let wearablesRef= account.storage.borrow\u003c\u0026Wearables.Collection\u003e(from: Wearables.CollectionStoragePath)\n if wearablesRef == nil {\n readyForWearables = false\n }\n\n let wearablesCap= account.capabilities.borrow\u003c\u0026{NonFungibleToken.Collection, NonFungibleToken.Receiver, ViewResolver.ResolverCollection}\u003e(Wearables.CollectionPublicPath)\n if wearablesCap == nil {\n readyForWearables = false\n }\n\n let wearablesProviderCap= account.capabilities.get\u003c\u0026{NonFungibleToken.Provider,NonFungibleToken.Collection, NonFungibleToken.Receiver, ViewResolver.ResolverCollection}\u003e(Wearables.CollectionPrivatePath)\n if !wearablesCap.check() {\n readyForWearables = false\n }\n\n for t in LostAndFound.getRedeemableTypes(address) {\n if t.isSubtype(of: Type\u003c@NonFungibleToken.NFT\u003e()) {\n hasLostAndFoundItem = true\n break\n }\n }\n */\n\n return FINDReport(\n profile: profileReport,\n privateMode: profile?.isPrivateModeEnabled() ?? false,\n activatedAccount: true,\n isDapper:isDapper,\n hasLostAndFoundItem: hasLostAndFoundItem,\n accounts: accounts,\n readyForWearables: readyForWearables,\n )\n }" - }, "getFindThoughts": { "spec": { "parameters": { @@ -5428,7 +5417,7 @@ "parameters": {}, "order": [] }, - "code": "import PublicPriceOracle from 0x8232ce4a3aff4e94\n\naccess(all) fun main():UFix64? {\n\n let feeds = PublicPriceOracle.getAllSupportedOracles()\n for address in feeds.keys {\n\n let name= feeds[address]\n // let name = feeds[address]\n if name==\"FLOW/USD\" {\n return PublicPriceOracle.getLatestPrice(oracleAddr: address)\n }\n\n }\n return nil\n}" + "code": "import PublicPriceOracle from 0x8232ce4a3aff4e94\n\naccess(all) fun main():UFix64? {\n\n let feeds = PublicPriceOracle.getAllSupportedOracles()\n for address in feeds.keys {\n\n let name= feeds[address]\n if name==\"FLOW/USD\" {\n return PublicPriceOracle.getLatestPrice(oracleAddr: address)\n }\n\n }\n return nil\n}" }, "getFlowToUSDC": { "spec": { @@ -5764,7 +5753,18 @@ "user" ] }, - "code": "import Profile from 0x35717efbbce11c74\nimport FIND from 0x35717efbbce11c74\n\naccess(all) fun main(user: String) : Profile.UserReport? {\n let resolveAddress = FIND.resolve(user) \n if resolveAddress == nil {return nil}\n let address = resolveAddress!\n let account = getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n var profileReport = account\n .getCapability\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)\n .borrow()?.asReport()\n\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets, \n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n return profileReport\n\n\n}" + "code": "import Profile from 0x35717efbbce11c74\nimport FIND from 0x35717efbbce11c74\n\naccess(all) fun main(user: String) : Profile.UserReport? {\n let resolveAddress = FIND.resolve(user) \n if resolveAddress == nil {return nil}\n let address = resolveAddress!\n let account = getAccount(address)\n if account.balance == 0.0 {\n return nil\n }\n\n var profileReport = account.capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)?.asReport()\n\n if profileReport != nil \u0026\u0026 profileReport!.findName != FIND.reverseLookup(address) {\n profileReport = Profile.UserReport(\n findName: \"\",\n address: profileReport!.address,\n name: profileReport!.name,\n gender: profileReport!.gender,\n description: profileReport!.description,\n tags: profileReport!.tags,\n avatar: profileReport!.avatar,\n links: profileReport!.links,\n wallets: profileReport!.wallets, \n following: profileReport!.following,\n followers: profileReport!.followers,\n allowStoringFollowers: profileReport!.allowStoringFollowers,\n createdAt: profileReport!.createdAt\n )\n }\n\n return profileReport\n\n\n}" + }, + "getProfileTest": { + "spec": { + "parameters": { + "address": "Address" + }, + "order": [ + "address" + ] + }, + "code": "//❯ flow scripts execute scripts/getProfileTest.cdc 0x70df6ccc9632a4dd -n migrationnetimport\nimport Profile from 0x35717efbbce11c74\n\naccess(all) fun main(address: Address) : AnyStruct {\n var wallets = getAccount(address).capabilities.borrow\u003c\u0026{Profile.Public}\u003e(Profile.publicPath)?.getWallets() ?? []\n\n for wallet in wallets {\n if wallet.name == \"USDC\" {\n return wallet.balance.id\n }\n }\n return nil\n}" }, "getRoyaltyChangedIds": { "spec": { diff --git a/lib/package.json b/lib/package.json index 0ac16872..cbaf6dfb 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "@findonflow/find-flow-contracts-1.0", - "version": "1.0.2", + "version": "1.0.3", "description": "Cadence transactions and scripts to work with https://find.xyz for cadence 1.0", "main": "index.js", "scripts": { diff --git a/scripts/getFindStatus.cdc b/scripts/getFindStatus.cdc index 517d48db..78bace73 100644 --- a/scripts/getFindStatus.cdc +++ b/scripts/getFindStatus.cdc @@ -6,10 +6,10 @@ import "MetadataViews" import "EmeraldIdentity" import "TokenForwarding" import "FungibleToken" -//import "Wearables" +import "Wearables" import "FindUtils" import "Clock" -//import "LostAndFound" +import "LostAndFound" access(all) struct FINDReport{ @@ -158,7 +158,6 @@ fun main(user: String) : FINDReport? { var readyForWearables = false var hasLostAndFoundItem : Bool = false - /* let wearablesRef= account.storage.borrow<&Wearables.Collection>(from: Wearables.CollectionStoragePath) if wearablesRef == nil { readyForWearables = false @@ -175,12 +174,11 @@ fun main(user: String) : FINDReport? { } for t in LostAndFound.getRedeemableTypes(address) { - if t.isSubtype(of: Type<@NonFungibleToken.NFT>()) { + if t.isSubtype(of: Type<@{NonFungibleToken.NFT}>()) { hasLostAndFoundItem = true break } } - */ return FINDReport( profile: profileReport,