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

fix: send exn to actual recipient only #273

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions examples/integration-scripts/multisig-holder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ test('multisig', async function run() {
rpy: [rpy, atc],
};
let recp = [aid2['state']].map((state) => state['i']);
let res = await client1
await client1
.exchanges()
.send(
'member1',
Expand All @@ -182,7 +182,7 @@ test('multisig', async function run() {
console.log(
'Member2 received exchange message to join the end role authorization'
);
res = await client2.groups().getRequest(msgSaid);
let res = await client2.groups().getRequest(msgSaid);
let exn = res[0].exn;
// stamp, eid and role are provided in the exn message
let rpystamp = exn.e.rpy.dt;
Expand Down Expand Up @@ -215,7 +215,7 @@ test('multisig', async function run() {
rpy: [rpy, atc],
};
recp = [aid1['state']].map((state) => state['i']);
res = await client2
await client2
.exchanges()
.send(
'member2',
Expand Down Expand Up @@ -262,7 +262,7 @@ test('multisig', async function run() {
rpy: [rpy, atc],
};
recp = [aid2['state']].map((state) => state['i']);
res = await client1
await client1
.exchanges()
.send(
'member1',
Expand Down Expand Up @@ -316,7 +316,7 @@ test('multisig', async function run() {
rpy: [rpy, atc],
};
recp = [aid1['state']].map((state) => state['i']);
res = await client2
await client2
.exchanges()
.send(
'member2',
Expand Down
8 changes: 4 additions & 4 deletions examples/integration-scripts/multisig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ test('multisig', async function run() {
rpy: [rpy, atc],
};
recp = [aid2['state'], aid3['state']].map((state) => state['i']);
res = await client1
await client1
.exchanges()
.send(
'member1',
Expand Down Expand Up @@ -382,7 +382,7 @@ test('multisig', async function run() {
rpy: [rpy, atc],
};
recp = [aid1['state'], aid3['state']].map((state) => state['i']);
res = await client2
await client2
.exchanges()
.send(
'member2',
Expand Down Expand Up @@ -429,7 +429,7 @@ test('multisig', async function run() {
rpy: [rpy, atc],
};
recp = [aid1['state'], aid2['state']].map((state) => state['i']);
res = await client3
await client3
.exchanges()
.send(
'member3',
Expand Down Expand Up @@ -770,7 +770,7 @@ test('multisig', async function run() {
};

recp = [aid2['state'], aid3['state']].map((state) => state['i']);
res = await client1
await client1
.exchanges()
.send(
'member1',
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/keri/app/contacting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class Challenges {
{},
[recipient]
);
return resp;
return resp[0]; // Only one recipient
}

/**
Expand Down
15 changes: 7 additions & 8 deletions src/keri/app/exchanging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export class Exchanges {
payload: Dict<any>,
embeds: Dict<any>,
recipients: string[]
): Promise<any> {
): Promise<any[]> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should get proper types here instead of any - don't have capacity right now but will try to sweep things in coming weeks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this actually now returns an array of Promise. So more correct would be Promise<any>[].

However, a better option could be to change this method to have one recipient and adjust from the call site accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, it was right and i incorrectly refactored and TS didnt pick it up due to any - will fix.

But not so sure on changing the method to only have one recipient as this brings a lot of for loops at the call sites, which will make every wallet/app using multi-sig need to refactor everywhere.

Copy link
Contributor Author

@iFergal iFergal Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and i broke tests again - weird, seems adding the end role doesn't like these changes

const responses: any[] = [];
for (const recipient of recipients) {
const [exn, sigs, atc] = await this.createExchangeMessage(
sender,
Expand All @@ -87,15 +88,13 @@ export class Exchanges {
embeds,
recipient
);
return await this.sendFromEvents(
name,
topic,
exn,
sigs,
atc,
recipients
responses.push(
await this.sendFromEvents(name, topic, exn, sigs, atc, [
recipient,
])
);
}
return responses;
}

/**
Expand Down
Loading