diff --git a/src/main/kotlin/id/walt/nftkit/rest/AlgorandNftController.kt b/src/main/kotlin/id/walt/nftkit/rest/AlgorandNftController.kt index 68b59b18..8aeee2d8 100644 --- a/src/main/kotlin/id/walt/nftkit/rest/AlgorandNftController.kt +++ b/src/main/kotlin/id/walt/nftkit/rest/AlgorandNftController.kt @@ -177,7 +177,7 @@ object AlgorandNftController{ fun verifyNftOwnerShipBasedOnCreatorDocs()= document().operation { it.summary("Verifying NFT ownership based on creator ") .operationId("verifyNftOwnerShipBasedOnCreator") - .addTagsItem("NFT verification")} + .addTagsItem("NFT verification On Algorand")} .pathParam("chain") { it.schema{}} .pathParam("address"){} @@ -186,5 +186,27 @@ object AlgorandNftController{ it.description("Algorand NFT Metadata") } + + fun verifyPolicyOnAlgorand(ctx: Context){ + val chain =ctx.pathParam("chain") + val tokenid = ctx.pathParam("token id") + val policyName = ctx.pathParam("policyName") + + val result = VerificationService.verifyPolicyAlgorand(Common.getChain(chain) ,tokenid , policyName) + ctx.result(Json.encodeToString(result)) + + } + + fun doVerifyPolicyOnAlgorandDocs()= document().operation { + it.summary("Verify an NFT metadata against a dynamic policy") + .operationId("verifyNftagainstPolicy") + .addTagsItem("NFT verification On Algorand")} + .pathParam("chain") { + it.schema{}} + .pathParam("token id"){} + .pathParam("policyName"){} + .json(200.toString()) { + it.description("Algorand NFT Metadata") + } } diff --git a/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt b/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt index 1add9adf..1d60abd4 100644 --- a/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt +++ b/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt @@ -312,18 +312,8 @@ object NftKitApi { } } path("nft/verifier") { - get( - "chain/{chain}/verifyNftOwnership", - documented(VerificationController.verifyAlgorandNftOwnershipDocs(), VerificationController::verifyAlgorandNftOwnership) - ) - get( - "chain/{chain}/verifyNftOwnershipWithTraits", - documented(VerificationController.verifyAlgorandNftOwnershipWithTraitsDocs(), VerificationController::verifyAlgorandNftOwnershipWithTraits) - ) - get( - "chain/{chain}/{address}/verifyNftOwnershipBasedOnCreator/{creatorAddress}", - documented(AlgorandNftController.verifyNftOwnerShipBasedOnCreatorDocs(), AlgorandNftController::verifyNftOwnerShipBasedOnCreator) - ) + + get( "chain/{chain}/contract/{contractAddress}/verifyNftOwnership", documented(VerificationController.verifyNftOwnershipDocs(), VerificationController::verifyNftOwnership) @@ -409,6 +399,28 @@ object NftKitApi { ) + } + path("algorand"){ + get( + "chain/{chain}/verifyNftOwnership", + documented(VerificationController.verifyAlgorandNftOwnershipDocs(), VerificationController::verifyAlgorandNftOwnership) + ) + get( + "chain/{chain}/verifyNftOwnershipWithTraits", + documented(VerificationController.verifyAlgorandNftOwnershipWithTraitsDocs(), VerificationController::verifyAlgorandNftOwnershipWithTraits) + ) + + get( + "chain/{chain}/{address}/verifyNftOwnershipBasedOnCreator/{creatorAddress}", + documented(AlgorandNftController.verifyNftOwnerShipBasedOnCreatorDocs(), AlgorandNftController::verifyNftOwnerShipBasedOnCreator) + ) + + get( + "chain/{chain}/token/{token id}/policy/{policyName}/verification", + documented(AlgorandNftController.doVerifyPolicyOnAlgorandDocs(), AlgorandNftController::verifyPolicyOnAlgorand) + + ) + } } diff --git a/src/main/kotlin/id/walt/nftkit/rest/VerificationController.kt b/src/main/kotlin/id/walt/nftkit/rest/VerificationController.kt index ae8df15d..f54957d2 100644 --- a/src/main/kotlin/id/walt/nftkit/rest/VerificationController.kt +++ b/src/main/kotlin/id/walt/nftkit/rest/VerificationController.kt @@ -30,7 +30,7 @@ object VerificationController { fun verifyAlgorandNftOwnershipWithTraitsDocs() = document().operation { it.summary("NFT ownership verification on algorand with traits") - .operationId("verifyAlgorandNftOwnershipWithTraits").addTagsItem("NFT verification") + .operationId("verifyAlgorandNftOwnershipWithTraits").addTagsItem("NFT verification On Algorand") }.pathParam("chain") { it.schema { } }.queryParam("assetId") { @@ -52,7 +52,7 @@ object VerificationController { fun verifyAlgorandNftOwnershipDocs() = document().operation { it.summary("NFT ownership verification on algorand") - .operationId("verifyAlgorandNftOwnership").addTagsItem("NFT verification") + .operationId("verifyAlgorandNftOwnership").addTagsItem("NFT verification On Algorand") }.pathParam("chain") { it.schema { } }.queryParam("assetId") { diff --git a/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt b/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt index d18614ce..7b4c8647 100644 --- a/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt +++ b/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt @@ -244,6 +244,14 @@ object VerificationService { } } + fun verifyPolicyAlgorand(chain: Chain, tokenId: String, policyName: String): Boolean { + val policy = PolicyRegistry.listPolicies().get(policyName) + if(policy == null) throw Exception("The policy doesn't exist") + val algorandNftmetadata= AlgorandNftService.getNftMetadata(tokenId ,AlgorandChain.valueOf(chain.toString()) ) + val nftMetadata = NftMetadataWrapper(algorandNftMetadata= algorandNftmetadata) + return DynamicPolicy.doVerify(policy!!.input, policy.policy, policy.policyQuery, nftMetadata) + } + fun verifyPolicyWithCollectionId(chain: UniqueNetwork, collectionId : String, tokenId: String, policyName: String): Boolean { val policy = PolicyRegistry.listPolicies().get(policyName) if(policy == null) throw Exception("The policy doesn't exist")