Skip to content

Commit

Permalink
add @beta & minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Oct 4, 2023
1 parent 3bd2070 commit 8cb416a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
27 changes: 16 additions & 11 deletions src/iden3comm/handlers/contract-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { PROTOCOL_MESSAGE_TYPE } from '../constants';
import { IPackageManager, ZeroKnowledgeProofRequest, ZeroKnowledgeProofResponse } from '../types';

import { ProofQuery } from '../../verifiable';
import {
ContractInvokeHandlerOptions,
ContractInvokeRequest
} from '../types/protocol/contract-request';
import { ContractInvokeRequest } from '../types/protocol/contract-request';
import { DID } from '@iden3/js-iden3-core';
import { IOnChainZKPVerifier } from '../../storage';
import { Signer } from 'ethers';

/**
* Interface that allows the processing of the contract request
Expand All @@ -21,15 +19,15 @@ import { IOnChainZKPVerifier } from '../../storage';
export interface IContractRequestHandler {
/**
* unpacks contract invoker request
* @public
* @beta
* @param {Uint8Array} request - raw byte message
* @returns `Promise<ContractInvokeRequest>`
*/
parseContractInvokeRequest(request: Uint8Array): Promise<ContractInvokeRequest>;

/**
* handle contract invoker request
* @public
* @beta
* @param {did} did - sender DID
* @param {Uint8Array} request - raw byte message
* @param {ContractInvokeHandlerOptions} opts - handler options
Expand All @@ -41,11 +39,18 @@ export interface IContractRequestHandler {
opts?: ContractInvokeHandlerOptions
): Promise<Map<string, ZeroKnowledgeProofResponse>>;
}

/** ContractInvokeHandlerOptions represents contract invoke handler options */
export type ContractInvokeHandlerOptions = {
ethSigner: Signer;
challenge?: bigint;
};

/**
*
* Allows to process ContractInvokeRequest protocol message
*
* @public
* @beta
* @class ContractRequestHandler
* @implements implements IContractRequestHandler interface
Expand All @@ -71,8 +76,8 @@ export class ContractRequestHandler implements IContractRequestHandler {
) {}

/**
* unpacks contract-request request
* @public
* unpacks contract-invoke request
* @beta
* @param {Uint8Array} request - raw byte message
* @returns `Promise<ContractInvokeRequest>`
*/
Expand All @@ -87,7 +92,7 @@ export class ContractRequestHandler implements IContractRequestHandler {

/**
* handle contract invoker request
* @public
* @beta
* @param {did} did - sender DID
* @param {ContractInvokeRequest} request - contract invoke request
* @param {ContractInvokeHandlerOptions} opts - handler options
Expand All @@ -112,7 +117,7 @@ export class ContractRequestHandler implements IContractRequestHandler {
for (const proofReq of ciRequest.body.scope) {
if (!this._allowedCircuits.includes(proofReq.circuitId as CircuitId)) {
throw new Error(
`Can't handle circuit ${proofReq.circuitId}. Only onchain circuits allowed.`
`Can't handle circuit ${proofReq.circuitId}. Only onchain circuits are allowed.`
);
}

Expand Down
7 changes: 0 additions & 7 deletions src/iden3comm/types/protocol/contract-request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Signer } from 'ethers';
import { ZeroKnowledgeProofRequest } from './auth';

/** ContractInvokeRequest represents structure of contract invoke request object */
Expand All @@ -24,9 +23,3 @@ export type ContractInvokeTransactionData = {
chain_id: number;
network?: string;
};

/** ContractInvokeHandlerOptions represents contract invoke handler options */
export type ContractInvokeHandlerOptions = {
ethSigner: Signer;
challenge?: bigint;
};
4 changes: 2 additions & 2 deletions src/storage/blockchain/onchain-zkp-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export class OnChainZKPVerifier implements IOnChainZKPVerifier {
/**
*
* Creates an instance of OnChainZKPVerifier.
* @public
* @beta
* @param {EthConnectionConfig[]} - array of ETH configs
*/

constructor(private readonly _configs: EthConnectionConfig[]) {}

/**
* Submit ZKP Responses to OnChainZKPVerifier contract.
* @public
* @beta
* @param {string} address - OnChainZKPVerifier contract address
* @param {Signer} ethSigner - tx signer
* @param {number} chainId - chain Id
Expand Down
2 changes: 1 addition & 1 deletion src/storage/interfaces/onchain-zkp-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ZeroKnowledgeProofResponse } from '../../iden3comm';
export interface IOnChainZKPVerifier {
/**
* Submit ZKP Responses to OnChainZKPVerifier contract.
* @public
* @beta
* @param {string} address - OnChainZKPVerifier contract address
* @param {Signer} ethSigner - tx signer
* @param {number} chainId - chain Id
Expand Down

0 comments on commit 8cb416a

Please sign in to comment.