From db735a0392c29f2d9d804335162001cf1afb74b9 Mon Sep 17 00:00:00 2001 From: SuperBatata Date: Fri, 1 Sep 2023 03:07:23 +0100 Subject: [PATCH] add opa support to algorand --- src/main/kotlin/id/walt/nftkit/opa/DynamicPolicy.kt | 5 +++++ .../kotlin/id/walt/nftkit/services/VerificationService.kt | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/kotlin/id/walt/nftkit/opa/DynamicPolicy.kt b/src/main/kotlin/id/walt/nftkit/opa/DynamicPolicy.kt index 5aa688b3..3badfa17 100644 --- a/src/main/kotlin/id/walt/nftkit/opa/DynamicPolicy.kt +++ b/src/main/kotlin/id/walt/nftkit/opa/DynamicPolicy.kt @@ -71,6 +71,11 @@ object DynamicPolicy { nftMetadata.uniqueNftMetadata.attributes?.forEach { data.put(it.name, it.value) } + }else if (nftMetadata.algorandNftMetadata != null){ + data.put("name", nftMetadata.algorandNftMetadata.name) + data.put("description", nftMetadata.algorandNftMetadata.description) + data.put("image", nftMetadata.algorandNftMetadata.image) + data.put("unitname", nftMetadata.algorandNftMetadata.unitName) } return data } diff --git a/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt b/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt index ed14b404..a169f088 100644 --- a/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt +++ b/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt @@ -235,6 +235,12 @@ object VerificationService { return DynamicPolicy.doVerify(policy!!.input, policy.policy, policy.policyQuery, nftMetadata) } + Common.isAlgorand(chain) -> { + val algorandNftmetadata= AlgorandNftService.getNftMetadata(tokenId ,AlgorandChain.valueOf(chain.toString()) ) + val nftMetadata = NftMetadataWrapper(null,null,null,null,null , algorandNftmetadata) + return DynamicPolicy.doVerify(policy!!.input, policy.policy, policy.policyQuery, nftMetadata) + } + else -> {throw Exception("Chain is not supported")} } }