Skip to content

Commit 89390e2

Browse files
authored
Merge pull request #39 from hypercerts-org/safe-support-batch-claiming
Enable batch claiming from a Safe
2 parents 6d8641c + 1483f6e commit 89390e2

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Diff for: src/client.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ export class HypercertClient implements HypercertClientInterface {
535535
* This function handles the batch claiming of fractions from multiple allowlists for the connected account.
536536
* It verifies the Merkle proofs if roots are provided and then submits the batch minting request.
537537
*
538+
* If you provide `overrides.safeAddress`, the transaction will be sent as a Safe transaction instead.
539+
*
538540
* @param params - The parameters for the batch claim operation.
539541
* @param params.hypercertTokenIds - The IDs of the hypercert tokens to claim.
540542
* @param params.units - The number of units to claim for each token.
@@ -563,12 +565,20 @@ export class HypercertClient implements HypercertClientInterface {
563565
);
564566
}
565567

566-
const request = await this.simulateRequest(
567-
account,
568-
"batchMintClaimsFromAllowlists",
569-
[account.address, proofs, hypercertTokenIds, units],
570-
overrides,
571-
);
568+
const accountAddress = overrides?.safeAddress ?? account.address;
569+
const params = [accountAddress, proofs, hypercertTokenIds, units];
570+
571+
// If a safe address is provided, use the SafeTransactions class
572+
if (overrides?.safeAddress) {
573+
if (!this._walletClient) {
574+
throw new ClientError("Safe address provided but no wallet client found");
575+
}
576+
577+
const safeTransactions = new SafeTransactions(overrides.safeAddress, this._walletClient, this._getContract());
578+
return safeTransactions.sendTransaction("batchMintClaimsFromAllowlists", params, overrides);
579+
}
580+
581+
const request = await this.simulateRequest(account, "batchMintClaimsFromAllowlists", params, overrides);
572582

573583
return this.submitRequest(request);
574584
};

Diff for: vitest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineConfig({
1111
reportOnFailure: true,
1212
thresholds: {
1313
lines: 78,
14-
branches: 85,
14+
branches: 84,
1515
functions: 77,
1616
statements: 78,
1717
},

0 commit comments

Comments
 (0)