Skip to content

Commit 645d665

Browse files
Merge pull request #139 from Arsh-Sandhu/migrate-scripts
add join function in groups class to join multisig rotation event
2 parents 02ffe8f + be31b15 commit 645d665

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/keri/app/grouping.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,39 @@ export class Groups {
5353
let res = await this.client.fetch(path, method, data);
5454
return await res.json();
5555
}
56+
57+
/**
58+
* Join multisig group using rotation event.
59+
* This can be used by participants being asked to contribute keys to a rotation event to join an existing group.
60+
* @async
61+
* @param {string} [name] human readable name of group AID
62+
* @param {any} [rot] rotation event
63+
* @param {any} [sigs] signatures
64+
* @param {string} [gid] prefix
65+
* @param {string[]} [smids] array of particpants
66+
* @param {string[]} [rmids] array of particpants
67+
* @returns {Promise<any>} A promise to the list of replay messages
68+
*/
69+
async join(
70+
name: string,
71+
rot: any,
72+
sigs: any, //string[],
73+
gid: string,
74+
smids: string[],
75+
rmids: string[]
76+
): Promise<any> {
77+
let path = `/identifiers/${name}/multisig/join`;
78+
let method = 'POST';
79+
let data = {
80+
tpc: 'multisig',
81+
rot: rot.ked,
82+
sigs: sigs,
83+
gid: gid,
84+
smids: smids,
85+
rmids: rmids
86+
};
87+
let res = await this.client.fetch(path, method, data);
88+
return await res.json();
89+
}
90+
5691
}

test/app/grouping.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,10 @@ describe('Grouping', () => {
181181
'/multisig/request/ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00'
182182
);
183183
assert.equal(lastCall[1]!.method, 'GET');
184+
185+
await groups.join('aid1', { 'ked': {} }, ['sig'], 'ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose00', ['1', '2', '3'], ['a', 'b', 'c']);
186+
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length - 1]!;
187+
assert.equal(lastCall[0]!, url + '/identifiers/aid1/multisig/join');
188+
assert.equal(lastCall[1]!.method, 'POST');
184189
});
185190
});

0 commit comments

Comments
 (0)