Skip to content

Commit

Permalink
Changed option parameter in createAccount for properly having optio…
Browse files Browse the repository at this point in the history
…nal parameters and default values
  • Loading branch information
marcvelmer committed Aug 11, 2023
1 parent b433dae commit adc5be6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
28 changes: 17 additions & 11 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,29 +794,35 @@ export class VocdoniSDKClient {
* options, like extra information of the account, or the faucet package string
* @returns {Promise<AccountData>}
*/
createAccount(
options: { account?: Account; faucetPackage?: string; sik?: boolean; password?: string } = {
createAccount(options?: {
account?: Account;
faucetPackage?: string;
sik?: boolean;
password?: string;
}): Promise<AccountData> {
invariant(this.wallet, 'No wallet or signer set');
const settings = {
account: null,
faucetPackage: null,
sik: true,
password: '0',
}
): Promise<AccountData> {
invariant(this.wallet, 'No wallet or signer set');
...options,
};

return this.fetchAccountInfo().catch(() => {
if (options?.sik) {
if (settings?.sik) {
return this.signSIKPayload(this.wallet).then((signedPayload) =>
this.createAccountInfo({
account: options?.account ?? new Account(),
faucetPackage: options?.faucetPackage,
account: settings?.account ?? new Account(),
faucetPackage: settings?.faucetPackage,
signedSikPayload: signedPayload,
password: options.password,
password: settings.password,
})
);
}
return this.createAccountInfo({
account: options?.account ?? new Account(),
faucetPackage: options?.faucetPackage,
account: settings?.account ?? new Account(),
faucetPackage: settings?.faucetPackage,
});
});
}
Expand Down
4 changes: 0 additions & 4 deletions test/integration/zk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ describe('zkSNARK test', () => {
});

await client.createAccount({
account: null,
faucetPackage: null,
sik: true,
password: 'password123',
});
Expand Down Expand Up @@ -125,8 +123,6 @@ describe('zkSNARK test', () => {

if (i % 3 == 0) {
await client.createAccount({
account: null,
faucetPackage: null,
sik: true,
password: participants[i].address,
});
Expand Down

0 comments on commit adc5be6

Please sign in to comment.