-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add to
as string[]
#303
base: main
Are you sure you want to change the base?
add to
as string[]
#303
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import { CircuitId } from '../../circuits/models'; | ||
import { IProofService } from '../../proof/proof-service'; | ||
import { PROTOCOL_MESSAGE_TYPE } from '../constants'; | ||
import { BasicMessage, IPackageManager, ZeroKnowledgeProofResponse } from '../types'; | ||
import { | ||
BasicMessage, | ||
getIden3CommSingleRecipient, | ||
Iden3DIDcommCompatibilityOptions, | ||
IPackageManager, | ||
ZeroKnowledgeProofResponse | ||
} from '../types'; | ||
import { ContractInvokeRequest, ContractInvokeResponse } from '../types/protocol/contract-request'; | ||
import { DID, ChainIds, getUnixTimestamp } from '@iden3/js-iden3-core'; | ||
import { FunctionSignatures, IOnChainZKPVerifier } from '../../storage'; | ||
|
@@ -52,7 +58,7 @@ export type ContractMessageHandlerOptions = { | |
senderDid: DID; | ||
ethSigner: Signer; | ||
challenge?: bigint; | ||
}; | ||
} & Iden3DIDcommCompatibilityOptions; | ||
|
||
/** | ||
* | ||
|
@@ -98,7 +104,7 @@ export class ContractRequestHandler | |
case PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: { | ||
const ciMessage = message as ContractInvokeRequest; | ||
const txHashResponsesMap = await this.handleContractInvoke(ciMessage, ctx); | ||
return this.createContractInvokeResponse(ciMessage, txHashResponsesMap); | ||
return this.createContractInvokeResponse(ciMessage, txHashResponsesMap, ctx); | ||
} | ||
default: | ||
return super.handle(message, ctx); | ||
|
@@ -193,14 +199,17 @@ export class ContractRequestHandler | |
*/ | ||
private async createContractInvokeResponse( | ||
request: ContractInvokeRequest, | ||
txHashToZkpResponseMap: Map<string, ZeroKnowledgeProofResponse[]> | ||
txHashToZkpResponseMap: Map<string, ZeroKnowledgeProofResponse[]>, | ||
ctx: ContractMessageHandlerOptions | ||
): Promise<ContractInvokeResponse> { | ||
const recipient = getIden3CommSingleRecipient(request); | ||
const target = request.from && ctx.multipleRecipientsFormat ? [request.from] : request.from; | ||
const contractInvokeResponse: ContractInvokeResponse = { | ||
id: request.id, | ||
thid: request.thid, | ||
type: PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_RESPONSE_MESSAGE_TYPE, | ||
from: request.to, | ||
to: request.from, | ||
from: recipient ? recipient.string() : undefined, | ||
to: target, | ||
Comment on lines
208
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe it's make sense to create helper function ...createBasicMsg(thid, to, isMultipleRecipients..., typ),
body: {...}
type: ide3MsgType
} |
||
body: { | ||
transaction_data: request.body.transaction_data, | ||
scope: [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import { | |
CredentialOffer, | ||
CredentialsOfferMessage, | ||
DIDDocument, | ||
getIden3CommSingleRecipient, | ||
Iden3DIDcommCompatibilityOptions, | ||
IPackageManager, | ||
PackerParams | ||
} from '../types'; | ||
|
@@ -143,7 +145,7 @@ export interface ICredentialProposalHandler { | |
} | ||
|
||
/** @beta ProposalRequestHandlerOptions represents proposal-request handler options */ | ||
export type ProposalRequestHandlerOptions = BasicHandlerOptions; | ||
export type ProposalRequestHandlerOptions = BasicHandlerOptions & Iden3DIDcommCompatibilityOptions; | ||
|
||
/** @beta ProposalHandlerOptions represents proposal handler options */ | ||
export type ProposalHandlerOptions = BasicHandlerOptions & { | ||
|
@@ -216,7 +218,8 @@ export class CredentialProposalHandler | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
ctx?: ProposalRequestHandlerOptions | ||
): Promise<ProposalMessage | CredentialsOfferMessage | undefined> { | ||
if (!proposalRequest.to) { | ||
const to = getIden3CommSingleRecipient(proposalRequest); | ||
if (!to) { | ||
throw new Error(`failed request. empty 'to' field`); | ||
} | ||
|
||
|
@@ -246,7 +249,7 @@ export class CredentialProposalHandler | |
}, | ||
type: cred.type, | ||
context: cred.context, | ||
allowedIssuers: [proposalRequest.to] | ||
allowedIssuers: [to?.string()] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allowedIssuers: [to.string()] |
||
}); | ||
} catch (e) { | ||
if ((e as Error).message !== 'no credential satisfied query') { | ||
|
@@ -266,8 +269,8 @@ export class CredentialProposalHandler | |
url: this._params.agentUrl, | ||
credentials: [] | ||
}, | ||
from: proposalRequest.to, | ||
to: proposalRequest.from | ||
from: to.string(), | ||
to: ctx?.multipleRecipientsFormat ? [proposalRequest.from] : proposalRequest.from | ||
}; | ||
} | ||
|
||
|
@@ -295,8 +298,8 @@ export class CredentialProposalHandler | |
body: { | ||
proposals: [] | ||
}, | ||
from: proposalRequest.to, | ||
to: proposalRequest.from | ||
from: to.string(), | ||
to: ctx?.multipleRecipientsFormat ? [proposalRequest.from] : proposalRequest.from | ||
}; | ||
} | ||
proposalMessage.body?.proposals.push(proposal); | ||
|
@@ -329,7 +332,7 @@ export class CredentialProposalHandler | |
} | ||
|
||
const senderDID = DID.parse(proposalRequest.from); | ||
const message = await this.handleProposalRequestMessage(proposalRequest); | ||
const message = await this.handleProposalRequestMessage(proposalRequest, opts); | ||
const response = byteEncoder.encode(JSON.stringify(message)); | ||
|
||
const packerOpts = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks loke we can extend
BasicHandlerOptions
with Iden3DIDcommCompatibilityOptions. Than it's automatically addsIden3DIDcommCompatibilityOptions
where we hadBasicHandlerOptions
.