From 6ac2fbc434ce6fb9f7176437c5389cfa6efaf935 Mon Sep 17 00:00:00 2001 From: Ilya Date: Sun, 25 Jun 2023 17:07:16 +0300 Subject: [PATCH] update abi --- src/credentials/status/on-chain-revocation.ts | 19 +- .../blockchain/onchain-revocation-abi.json | 197 +++++++++--------- src/storage/blockchain/onchain-revocation.ts | 4 +- 3 files changed, 118 insertions(+), 102 deletions(-) diff --git a/src/credentials/status/on-chain-revocation.ts b/src/credentials/status/on-chain-revocation.ts index 1c6a4323..5caa58e7 100644 --- a/src/credentials/status/on-chain-revocation.ts +++ b/src/credentials/status/on-chain-revocation.ts @@ -2,6 +2,7 @@ import { RevocationStatus, CredentialStatus } from '../../verifiable'; import { EthConnectionConfig } from '../../storage/blockchain'; import { CredentialStatusResolver } from './resolver'; import { OnChainRevocationStorage } from '../../storage/blockchain/onchain-revocation'; +import { DID } from '@iden3/js-iden3-core'; /** * OnChainIssuer is a class that allows to interact with the onchain contract @@ -32,13 +33,19 @@ export class OnChainResolver implements CredentialStatusResolver { * @returns Promise */ async getRevocationOnChain(credentialStatus: CredentialStatus): Promise { - const { contractAddress, chainId, revocationNonce } = this.parseOnChainId(credentialStatus.id); + const { contractAddress, chainId, revocationNonce, issuer } = this.parseOnChainId( + credentialStatus.id + ); if (revocationNonce !== credentialStatus.revocationNonce) { throw new Error('revocationNonce does not match'); } + const issuerDID = DID.parse(issuer); const networkConfig = this.networkByChainId(chainId); const onChainCaller = new OnChainRevocationStorage(networkConfig, contractAddress); - const revocationStatus = await onChainCaller.getRevocationStatus(revocationNonce); + const revocationStatus = await onChainCaller.getRevocationStatus( + issuerDID.id.bigInt(), + revocationNonce + ); return revocationStatus; } @@ -52,6 +59,7 @@ export class OnChainResolver implements CredentialStatusResolver { contractAddress: string; chainId: number; revocationNonce: number; + issuer: string; } { const url = new URL(id); if (!url.searchParams.has('contractAddress')) { @@ -60,6 +68,11 @@ export class OnChainResolver implements CredentialStatusResolver { if (!url.searchParams.has('revocationNonce')) { throw new Error('revocationNonce not found'); } + + const issuerDID = id.split('/')[0]; + if (!issuerDID) { + throw new Error('issuer not found in credentialStatus id'); + } // TODO (illia-korotia): after merging core v2 need to parse contract address from did if `contractAddress` is not present in id as param const contractId = url.searchParams.get('contractAddress'); const revocationNonce = parseInt(url.searchParams.get('revocationNonce'), 10); @@ -71,7 +84,7 @@ export class OnChainResolver implements CredentialStatusResolver { const chainId = parseInt(parts[0], 10); const contractAddress = parts[1]; - return { contractAddress, chainId, revocationNonce }; + return { contractAddress, chainId, revocationNonce, issuer: issuerDID }; } networkByChainId(chainId: number): EthConnectionConfig { diff --git a/src/storage/blockchain/onchain-revocation-abi.json b/src/storage/blockchain/onchain-revocation-abi.json index 11cf3bc6..5db6be20 100644 --- a/src/storage/blockchain/onchain-revocation-abi.json +++ b/src/storage/blockchain/onchain-revocation-abi.json @@ -1,97 +1,100 @@ -[ - { - "inputs": [ - { - "internalType": "uint64", - "name": "nonce", - "type": "uint64" - } - ], - "name": "getRevocationStatus", - "outputs": [ - { - "components": [ - { - "components": [ - { - "internalType": "uint256", - "name": "state", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "claimsTreeRoot", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "revocationTreeRoot", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rootOfRoots", - "type": "uint256" - } - ], - "internalType": "struct IdentityBase.IdentityStateRoots", - "name": "issuer", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "root", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "existence", - "type": "bool" - }, - { - "internalType": "uint256[]", - "name": "siblings", - "type": "uint256[]" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "auxExistence", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "auxIndex", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "auxValue", - "type": "uint256" - } - ], - "internalType": "struct SmtLib.Proof", - "name": "mtp", - "type": "tuple" - } - ], - "internalType": "struct IdentityBase.CredentialStatus", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - } -] \ No newline at end of file +[{ + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + } + ], + "name": "getRevocationStatus", + "outputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "state", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "claimsTreeRoot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "revocationTreeRoot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rootOfRoots", + "type": "uint256" + } + ], + "internalType": "struct IOnchainCredentialStatusResolver.IdentityStateRoots", + "name": "issuer", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "root", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "existence", + "type": "bool" + }, + { + "internalType": "uint256[]", + "name": "siblings", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "auxExistence", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "auxIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "auxValue", + "type": "uint256" + } + ], + "internalType": "struct IOnchainCredentialStatusResolver.Proof", + "name": "mtp", + "type": "tuple" + } + ], + "internalType": "struct IOnchainCredentialStatusResolver.CredentialStatus", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" +}] diff --git a/src/storage/blockchain/onchain-revocation.ts b/src/storage/blockchain/onchain-revocation.ts index e782725b..243c9beb 100644 --- a/src/storage/blockchain/onchain-revocation.ts +++ b/src/storage/blockchain/onchain-revocation.ts @@ -39,8 +39,8 @@ export class OnChainRevocationStorage { * * @returns Promise */ - public async getRevocationStatus(nonce: number): Promise { - const response = await this.onchainContract.getRevocationStatus(nonce); + public async getRevocationStatus(issuerID: bigint, nonce: number): Promise { + const response = await this.onchainContract.getRevocationStatus(issuerID, nonce); const issuer = OnChainRevocationStorage.convertIssuerInfo(response.issuer); const mtp = OnChainRevocationStorage.convertSmtProofToProof(response.mtp);