Skip to content

Commit b04e781

Browse files
committed
feat: enable claiming from a Safe
Akin to the mintHypercert method, enable the claimFractionFromAllowlist() method to follow the same pattern.
1 parent f032333 commit b04e781

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/client.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ export class HypercertClient implements HypercertClientInterface {
469469
* This function handles the claiming of a fraction from an allowlist for the connected account.
470470
* It verifies the Merkle proof if a root is provided and then submits the minting request.
471471
*
472+
* If you provide `overrides.safeAddress`, the transaction will be sent as a Safe transaction instead.
473+
*
472474
* @param params - The parameters for the claim operation.
473475
* @param params.hypercertTokenId - The ID of the hypercert token to claim.
474476
* @param params.units - The number of units to claim.
@@ -497,12 +499,20 @@ export class HypercertClient implements HypercertClientInterface {
497499
);
498500
}
499501

500-
const request = await this.simulateRequest(
501-
account,
502-
"mintClaimFromAllowlist",
503-
[account.address, proof, hypercertTokenId, units],
504-
overrides,
505-
);
502+
const accountAddress = overrides?.safeAddress ?? account.address;
503+
const params = [accountAddress, proof, hypercertTokenId, units];
504+
505+
// If a safe address is provided, use the SafeTransactions class
506+
if (overrides?.safeAddress) {
507+
if (!this._walletClient) {
508+
throw new ClientError("Safe address provided but no wallet client found");
509+
}
510+
511+
const safeTransactions = new SafeTransactions(overrides.safeAddress, this._walletClient, this._getContract());
512+
return safeTransactions.sendTransaction("mintClaimFromAllowlist", params, overrides);
513+
}
514+
515+
const request = await this.simulateRequest(account, "mintClaimFromAllowlist", params, overrides);
506516
return this.submitRequest(request);
507517
};
508518

0 commit comments

Comments
 (0)