Skip to content
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

WIP: (for discussion) add topics to accept #1192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/request-client.js/src/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default class Request {
public async accept(
signerIdentity: IdentityTypes.IIdentity,
refundInformation?: any,
topics: any[] = [],
): Promise<Types.IRequestDataWithEvents> {
const extensionsData: any[] = [];
if (refundInformation) {
Expand All @@ -179,7 +180,7 @@ export default class Request {
requestId: this.requestId,
};

const acceptResult = await this.requestLogic.acceptRequest(parameters, signerIdentity, true);
const acceptResult = await this.requestLogic.acceptRequest(parameters, signerIdentity, true, topics);

return this.handleRequestDataEvents(acceptResult);
}
Expand Down
8 changes: 7 additions & 1 deletion packages/request-logic/src/request-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default class RequestLogic implements RequestLogicTypes.IRequestLogic {
requestParameters: RequestLogicTypes.IAcceptParameters,
signerIdentity: IdentityTypes.IIdentity,
validate = false,
topics: any[] = [],
): Promise<RequestLogicTypes.IRequestLogicReturnWithConfirmation> {
if (!this.signatureProvider) {
throw new Error('You must give a signature provider to create actions');
Expand All @@ -151,7 +152,12 @@ export default class RequestLogic implements RequestLogicTypes.IRequestLogic {
await this.validateAction(requestId, action);
}

return this.persistTransaction(requestId, action, undefined);
// hash all the topics
const hashedTopics = topics.map((topic) =>
MultiFormat.serialize(normalizeKeccak256Hash(topic)),
);

return this.persistTransaction(requestId, action, undefined, hashedTopics);
}

/**
Expand Down
Loading