Skip to content

Enable batch claiming from a Safe #39

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged
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
22 changes: 16 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ export class HypercertClient implements HypercertClientInterface {
* This function handles the batch claiming of fractions from multiple allowlists for the connected account.
* It verifies the Merkle proofs if roots are provided and then submits the batch minting request.
*
* If you provide `overrides.safeAddress`, the transaction will be sent as a Safe transaction instead.
*
* @param params - The parameters for the batch claim operation.
* @param params.hypercertTokenIds - The IDs of the hypercert tokens to claim.
* @param params.units - The number of units to claim for each token.
Expand Down Expand Up @@ -563,12 +565,20 @@ export class HypercertClient implements HypercertClientInterface {
);
}

const request = await this.simulateRequest(
account,
"batchMintClaimsFromAllowlists",
[account.address, proofs, hypercertTokenIds, units],
overrides,
);
const accountAddress = overrides?.safeAddress ?? account.address;
const params = [accountAddress, proofs, hypercertTokenIds, units];

// If a safe address is provided, use the SafeTransactions class
if (overrides?.safeAddress) {
if (!this._walletClient) {
throw new ClientError("Safe address provided but no wallet client found");
}

const safeTransactions = new SafeTransactions(overrides.safeAddress, this._walletClient, this._getContract());
return safeTransactions.sendTransaction("batchMintClaimsFromAllowlists", params, overrides);
}

const request = await this.simulateRequest(account, "batchMintClaimsFromAllowlists", params, overrides);

return this.submitRequest(request);
};
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig({
reportOnFailure: true,
thresholds: {
lines: 78,
branches: 85,
branches: 84,
functions: 77,
statements: 78,
},
Expand Down
Loading