Skip to content

Commit

Permalink
Merge pull request #93 from ubiquity-os/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
gentlementlegen authored Oct 22, 2024
2 parents 9a69437 + 72b2b99 commit 4f2fa2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
9 changes: 1 addition & 8 deletions src/handlers/generate-erc20-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,8 @@ export async function generateErc20PermitSignature(

const { domain, types, values } = SignatureTransfer.getPermitData(permitTransferFromData, PERMIT2_ADDRESS, evmNetworkId);

const domainData = {
name: domain.name,
version: domain.version || "1", // default to 1 if it's undefined
chainId: domain.chainId,
verifyingContract: domain.verifyingContract,
};

try {
const signature = await adminWallet._signTypedData(domainData, types, values);
const signature = await adminWallet._signTypedData(domain, types, values);

const erc20Permit: PermitReward = {
tokenType: TokenType.ERC20,
Expand Down
17 changes: 14 additions & 3 deletions tests/generate-erc20-permit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,21 @@ describe("generateErc20PermitSignature", () => {

const result = await generateErc20PermitSignature(context, SPENDER, amount, ERC20_REWARD_TOKEN_ADDRESS);

expect(result).toBeDefined();
expect(result).not.toContain("Permit not generated");
expect(result).toBeInstanceOf(Object);
const expectedResult = {
tokenType: 'ERC20',
tokenAddress: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
beneficiary: '0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd',
nonce: '28290789875493039658039458533958603742651083423638415458747066904844975862062',
deadline: '115792089237316195423570985008687907853269984665640564039457584007913129639935',
amount: '100000000000000000000',
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
signature: '0xad87653fb0ecf740c73b78a8f414cdd5b1ffb18670cde5a1d21c65e43d6bb2a36c5470c5529334dc11566f0c380889b734a8539d69ec74cc2abf37af0ea7a7781b',
networkId: 100
};

expect(result).toEqual(expectedResult);
expect(context.logger.info).toHaveBeenCalledWith("Generated ERC20 permit2 signature", expect.any(Object));

});

it("should throw error when evmPrivateEncrypted is not defined", async () => {
Expand Down

0 comments on commit 4f2fa2f

Please sign in to comment.