Skip to content

Commit

Permalink
add new coupon type to the lib (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
adridadou authored Oct 28, 2024
1 parent 6f24342 commit 7a27a65
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export const getDomainDefinition = (
actionId,
chainId
);
case "coupon-update-delegate-key":
return getCouponUpdateDelegateKeyDomainDefinition(
verifyingContract,
actionId,
chainId
);
default:
throw new Error("unknown type " + message.type);
}
Expand Down Expand Up @@ -365,6 +371,25 @@ export const getCouponBurnDomainDefinition = (
return { domain, types };
};

export const getCouponUpdateDelegateKeyDomainDefinition = (
verifyingContract: string,
actionId: string,
chainId: number
) => {
const domain = getMessageDomainType(chainId, verifyingContract, actionId);

const types = {
Message: [
{ name: "authorizedMember", type: "address" },
{ name: "newDelegateKey", type: "address" },
{ name: "nonce", type: "uint256" },
],
EIP712Domain: getDomainType(),
};

return { domain, types };
};

export const getDomainType = () => {
return [
{ name: "name", type: "string" },
Expand Down Expand Up @@ -400,6 +425,8 @@ export const prepareMessage = (message: MessageWithType) => {
return message;
case "coupon-burn":
return message;
case "coupon-update-delegate-key":
return message;
default:
throw new Error("unknown type " + message.type);
}
Expand Down
3 changes: 2 additions & 1 deletion types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export type MessageWithType = Record<string, any> & {
| "coupon-kyc"
| "manager-coupon"
| "coupon-nft"
| "coupon-burn";
| "coupon-burn"
| "coupon-update-delegate-key";
};

export type VoteEntry = {
Expand Down

0 comments on commit 7a27a65

Please sign in to comment.