Skip to content

Commit

Permalink
add join function in groups class to join multisig rotation event
Browse files Browse the repository at this point in the history
Signed-off-by: arshdeep singh <[email protected]>
  • Loading branch information
Arsh-Sandhu committed Nov 16, 2023
1 parent 370d7b8 commit be31b15
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/keri/app/grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,39 @@ export class Groups {
let res = await this.client.fetch(path, method, data);
return await res.json();
}

/**
* Join multisig group using rotation event.
* This can be used by participants being asked to contribute keys to a rotation event to join an existing group.
* @async
* @param {string} [name] human readable name of group AID
* @param {any} [rot] rotation event
* @param {any} [sigs] signatures
* @param {string} [gid] prefix
* @param {string[]} [smids] array of particpants
* @param {string[]} [rmids] array of particpants
* @returns {Promise<any>} A promise to the list of replay messages
*/
async join(
name: string,
rot: any,
sigs: any, //string[],
gid: string,
smids: string[],
rmids: string[]
): Promise<any> {
let path = `/identifiers/${name}/multisig/join`;
let method = 'POST';
let data = {
tpc: 'multisig',
rot: rot.ked,
sigs: sigs,
gid: gid,
smids: smids,
rmids: rmids
};
let res = await this.client.fetch(path, method, data);
return await res.json();
}

}
5 changes: 5 additions & 0 deletions test/app/grouping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,10 @@ describe('Grouping', () => {
'/multisig/request/ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00'
);
assert.equal(lastCall[1]!.method, 'GET');

await groups.join('aid1', { 'ked': {} }, ['sig'], 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', ['1', '2', '3'], ['a', 'b', 'c']);
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
assert.equal(lastCall[0]!, url + '/identifiers/aid1/multisig/join');
assert.equal(lastCall[1]!.method, 'POST');
});
});

0 comments on commit be31b15

Please sign in to comment.