mirror of
https://github.com/0xbow-io/privacy-pools-core.git
synced 2026-01-09 01:17:58 -05:00
fix(sdk): validate index on createDepositsSecrets (#73)
This commit is contained in:
@@ -226,6 +226,10 @@ export class AccountService {
|
||||
secret: Secret;
|
||||
precommitment: Hash;
|
||||
} {
|
||||
if(index && index < 0n) {
|
||||
throw AccountError.invalidIndex(index);
|
||||
}
|
||||
|
||||
const accounts = this.account.poolAccounts.get(scope);
|
||||
index = index || BigInt(accounts?.length || 0);
|
||||
|
||||
|
||||
@@ -32,4 +32,11 @@ export class AccountError extends SDKError {
|
||||
ErrorCode.OPERATION_FAILED,
|
||||
);
|
||||
}
|
||||
|
||||
public static invalidIndex(index: bigint): AccountError {
|
||||
return new AccountError(
|
||||
`Invalid index: ${index.toString()}`,
|
||||
ErrorCode.INVALID_INPUT,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user