Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Feb 7, 2024
1 parent 2f6a68c commit 9360b62
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
9 changes: 2 additions & 7 deletions src/circuits/verifiers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ export async function checkQueryRequest(
// validate selective disclosure
if (cq.isSelectiveDisclosure) {
try {
if (!verifiablePresentation) {
throw new Error(`no vp present in selective disclosure request`);
}
await validateDisclosure(verifiablePresentation, cq, outputs, schemaLoader);
await validateDisclosure(cq, outputs,verifiablePresentation, schemaLoader);
} catch (e) {
throw new Error(`failed to validate selective disclosure: ${(e as Error).message}`);
}
Expand Down Expand Up @@ -262,9 +259,9 @@ async function validateOperators(cq: CircuitQuery, outputs: ClaimOutputs) {
}

async function validateDisclosure(
verifiablePresentation: JSON,
cq: CircuitQuery,
outputs: ClaimOutputs,
verifiablePresentation?: JSON,
ldLoader?: DocumentLoader
) {
if (!verifiablePresentation) {
Expand Down Expand Up @@ -322,8 +319,6 @@ async function validateDisclosure(
if (bi !== outputs.value[0]) {
throw new Error(`value that was used is not equal to requested in query`);
}

return;
}

async function parsePredicate(
Expand Down
3 changes: 1 addition & 2 deletions src/iden3comm/handlers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as uuid from 'uuid';
import { ProofQuery, RevocationStatus, W3CCredential } from '../../verifiable';
import { byteDecoder, byteEncoder, mergeObjects } from '../../utils';
import { getRandomBytes } from '@iden3/js-crypto';
import { CircuitId } from '../../circuits';
import { PROTOCOL_CONSTANTS } from '..';

/**
Expand Down Expand Up @@ -403,7 +402,7 @@ export class AuthHandler implements IAuthHandler {
}
}

return Promise.resolve({ request, response });
return { request, response };
}

private verifyAuthRequest(request: AuthorizationRequestMessage) {
Expand Down
14 changes: 7 additions & 7 deletions src/storage/blockchain/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class EthStateStorage implements IStateStorage {
}

/** {@inheritdoc IStateStorage.getLatestStateById} */
async getLatestStateById(id: Id | bigint): Promise<StateInfo> {
async getLatestStateById(id: bigint): Promise<StateInfo> {
const { stateContract } = this._getStateContractAndProviderForId(id);
const rawData = await stateContract.getStateInfoById(id);
const stateInfo: StateInfo = {
Expand All @@ -85,7 +85,7 @@ export class EthStateStorage implements IStateStorage {
}

/** {@inheritdoc IStateStorage.getStateInfoByIdAndState} */
async getStateInfoByIdAndState(id: Id | bigint, state: bigint): Promise<StateInfo> {
async getStateInfoByIdAndState(id: bigint, state: bigint): Promise<StateInfo> {
const { stateContract } = this._getStateContractAndProviderForId(id);
const rawData = await stateContract.getStateInfoByIdAndState(id, state);
const stateInfo: StateInfo = {
Expand Down Expand Up @@ -161,7 +161,7 @@ export class EthStateStorage implements IStateStorage {
}

/** {@inheritdoc IStateStorage.getGISTProof} */
async getGISTProof(id: Id | bigint): Promise<StateProof> {
async getGISTProof(id: bigint): Promise<StateProof> {
const { stateContract } = this._getStateContractAndProviderForId(id);
const data = await stateContract.getGISTProof(id);

Expand All @@ -181,7 +181,7 @@ export class EthStateStorage implements IStateStorage {
}

/** {@inheritdoc IStateStorage.getGISTRootInfo} */
async getGISTRootInfo(id: Id | bigint): Promise<RootInfo> {
async getGISTRootInfo(id: bigint): Promise<RootInfo> {
const { stateContract } = this._getStateContractAndProviderForId(id);
const data = await stateContract.getGISTRootInfo(id);

Expand All @@ -195,19 +195,19 @@ export class EthStateStorage implements IStateStorage {
};
}

private _getStateContractAndProviderForId(id: Id | bigint): {
private _getStateContractAndProviderForId(id: bigint): {
stateContract: Contract;
provider: JsonRpcProvider;
} {
id = typeof id === 'bigint' ? Id.fromBigInt(id as bigint) : id;
const idTyped = Id.fromBigInt(id as bigint);
if (!Array.isArray(this.ethConfig)) {
return {
stateContract: this.stateContract,
provider: this.provider
};
}

const chainId = getChainId(DID.blockchainFromId(id), DID.networkIdFromId(id));
const chainId = getChainId(DID.blockchainFromId(idTyped), DID.networkIdFromId(idTyped));
const config = this._networkByChainId(chainId);

const provider = new JsonRpcProvider(config.url);
Expand Down

0 comments on commit 9360b62

Please sign in to comment.