Skip to content

Commit

Permalink
add permit commnets
Browse files Browse the repository at this point in the history
  • Loading branch information
invocamanman committed Sep 2, 2022
1 parent 840af7b commit 055e574
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module.exports.ERC20PermitMock = require('./compiled-contracts/ERC20PermitMock.j
module.exports.GlobalExitRootManagerL2Mock = require('./compiled-contracts/GlobalExitRootManagerL2Mock.json');
module.exports.GlobalExitRootManagerMock = require('./compiled-contracts/GlobalExitRootManagerMock.json');
module.exports.ProofOfEfficiencyMock = require('./compiled-contracts/ProofOfEfficiencyMock.json');
module.exports.VerifierRollupHelperMock = require('./compiled-contracts/VerifierRollupHelperMock.json');
module.exports.VerifierRollupHelperMock = require('./compiled-contracts/VerifierRollupHelperMock.json');
module.exports.PermitHelper = require('./test/contracts/helpers/permit-helper.js');
13 changes: 13 additions & 0 deletions test/contracts/helpers/permit-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ const {
} = require('hardhat');
const { expect } = require('chai');

/**
* Create a permit signature with the EIP-712 standar
* @param {Object} tokenContractInstance - EthersJS contract instance of the token
* @param {Object} wallet - EthersJs wallet instance that will sign the permit
* @param {String} spenderAddress - Spender address, usually the contract that the permit will interact with
* @param {String} value - Value of the permit
* @param {String} nonce - Nonce of the permit
* @param {String} deadline - Deadline of the permit
* @returns {Object} - Signature obejct, { v, r, s}
*/
async function createPermitSignature(tokenContractInstance, wallet, spenderAddress, value, nonce, deadline) {
const chainId = (await tokenContractInstance.getChainId());
const name = await tokenContractInstance.name();
Expand Down Expand Up @@ -43,6 +53,9 @@ async function createPermitSignature(tokenContractInstance, wallet, spenderAddre
return signature;
}

/**
* Permit interface
*/
const ifacePermit = new ethers.utils.Interface(['function permit(address,address,uint256,uint256,uint8,bytes32,bytes32)']);

module.exports = {
Expand Down

0 comments on commit 055e574

Please sign in to comment.