@1inch/solidity-utils 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -208
- package/contracts/interfaces/ICreate3Deployer.sol +16 -0
- package/contracts/interfaces/IDaiLikePermit.sol +13 -0
- package/contracts/interfaces/IERC20MetadataUppercase.sol +12 -0
- package/contracts/interfaces/IERC7597Permit.sol +13 -0
- package/contracts/interfaces/IPermit2.sol +45 -12
- package/contracts/interfaces/IWETH.sol +17 -0
- package/contracts/libraries/AddressArray.sol +73 -25
- package/contracts/libraries/AddressLib.sol +2 -1
- package/contracts/libraries/AddressSet.sol +52 -14
- package/contracts/libraries/BySigTraits.sol +37 -5
- package/contracts/libraries/BytesMemory.sol +2 -1
- package/contracts/libraries/BytesStorage.sol +2 -1
- package/contracts/libraries/ECDSA.sol +111 -0
- package/contracts/libraries/RevertReasonForwarder.sol +13 -3
- package/contracts/libraries/RevertReasonParser.sol +11 -2
- package/contracts/libraries/SafeERC20.sol +1 -1
- package/contracts/libraries/StringUtil.sol +21 -3
- package/contracts/libraries/UniERC20.sol +57 -12
- package/contracts/mixins/BySig.sol +220 -0
- package/contracts/mixins/EthReceiver.sol +27 -0
- package/contracts/mixins/OnlyWethReceiver.sol +31 -0
- package/contracts/mixins/PermitAndCall.sol +39 -0
- package/contracts/mixins/SelfdestructEthSender.sol +32 -0
- package/contracts/mocks/ERC20PermitMock.sol +12 -0
- package/contracts/mocks/SelfdestructEthSenderMock.sol +27 -0
- package/contracts/mocks/TokenCustomDecimalsMock.sol +25 -4
- package/contracts/mocks/TokenMock.sol +19 -0
- package/dist/docgen/index.d.ts +2 -0
- package/dist/docgen/index.js +7 -0
- package/dist/docgen/index.js.map +1 -0
- package/dist/docgen/templates.d.ts +6 -0
- package/dist/docgen/templates.js +15 -0
- package/dist/docgen/templates.js.map +1 -0
- package/dist/hardhat-setup/networks.d.ts +23 -0
- package/dist/hardhat-setup/networks.js +22 -0
- package/dist/hardhat-setup/networks.js.map +1 -1
- package/dist/src/expect.d.ts +12 -0
- package/dist/src/expect.js +12 -0
- package/dist/src/expect.js.map +1 -1
- package/dist/src/permit.d.ts +131 -2
- package/dist/src/permit.js +126 -9
- package/dist/src/permit.js.map +1 -1
- package/dist/src/prelude.d.ts +6 -0
- package/dist/src/prelude.js +6 -0
- package/dist/src/prelude.js.map +1 -1
- package/dist/src/profileEVM.d.ts +26 -0
- package/dist/src/profileEVM.js +30 -3
- package/dist/src/profileEVM.js.map +1 -1
- package/dist/src/utils.d.ts +79 -0
- package/dist/src/utils.js +92 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/typechain-types/contracts/mixins/SelfdestructEthSender.d.ts +29 -0
- package/dist/typechain-types/contracts/mixins/SelfdestructEthSender.js +3 -0
- package/dist/typechain-types/contracts/mixins/SelfdestructEthSender.js.map +1 -0
- package/dist/typechain-types/contracts/mixins/index.d.ts +1 -0
- package/dist/typechain-types/contracts/mocks/SelfdestructEthSenderMock.d.ts +37 -0
- package/dist/typechain-types/contracts/mocks/SelfdestructEthSenderMock.js +3 -0
- package/dist/typechain-types/contracts/mocks/SelfdestructEthSenderMock.js.map +1 -0
- package/dist/typechain-types/contracts/mocks/TokenCustomDecimalsMock.d.ts +1 -5
- package/dist/typechain-types/contracts/mocks/index.d.ts +1 -0
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Address__factory.js +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/ShortStrings__factory.js +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.js +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/cryptography/ECDSA__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/cryptography/ECDSA__factory.js +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/math/Math__factory.d.ts +1 -1
- package/dist/typechain-types/factories/@openzeppelin/contracts/utils/math/Math__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/AddressArray__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/AddressArray__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BySigTraits__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BySigTraits__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BytesMemory__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BytesMemory__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BytesStorage__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/BytesStorage__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/RevertReasonParser__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/RevertReasonParser__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/SafeERC20__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/SafeERC20__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/libraries/UniERC20__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/libraries/UniERC20__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/mixins/SelfdestructEthSender__factory.d.ts +17 -0
- package/dist/typechain-types/factories/contracts/mixins/SelfdestructEthSender__factory.js +33 -0
- package/dist/typechain-types/factories/contracts/mixins/SelfdestructEthSender__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/mixins/index.d.ts +1 -0
- package/dist/typechain-types/factories/contracts/mixins/index.js +3 -1
- package/dist/typechain-types/factories/contracts/mixins/index.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mocks/ERC20PermitMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/mocks/ERC20PermitMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/mocks/ERC20PermitMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.d.ts +49 -0
- package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.js +75 -0
- package/dist/typechain-types/factories/contracts/mocks/SelfdestructEthSenderMock__factory.js.map +1 -0
- package/dist/typechain-types/factories/contracts/mocks/TokenCustomDecimalsMock__factory.d.ts +1 -11
- package/dist/typechain-types/factories/contracts/mocks/TokenCustomDecimalsMock__factory.js +1 -14
- package/dist/typechain-types/factories/contracts/mocks/TokenCustomDecimalsMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mocks/TokenMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/mocks/TokenMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/mocks/TokenMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/mocks/index.d.ts +1 -0
- package/dist/typechain-types/factories/contracts/mocks/index.js +3 -1
- package/dist/typechain-types/factories/contracts/mocks/index.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/ECDSATest__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/ECDSATest__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/ECDSATest__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/RevertReasonParserTest__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/RevertReasonParserTest__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/RevertReasonParserTest__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/StringUtilTest__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/StringUtilTest__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/StringUtilTest__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressArrayMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressArrayMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressArrayMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressLibMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressLibMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressLibMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressSetMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressSetMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/AddressSetMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BySigTraitsMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesMemoryMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesMemoryMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesMemoryMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesStorageMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesStorageMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/BytesStorageMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/DaiLikePermitMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/DaiLikePermitMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/DaiLikePermitMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/ERC1271WalletMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/ERC1271WalletMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/ERC1271WalletMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthReceiverMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthReceiverMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthSenderMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthSenderMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/EthSenderMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitAndCallMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/PermitableMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20NoReturnMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20PermitNoRevertMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnFalseMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ReturnTrueMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20ThroughZeroApprove__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/ERC20WithSafeBalance__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/Permit2ReturnTrueMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeERC20Wrapper__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/SafeERC20Helper.sol/SafeWETHWrapper__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/TokenWithBySig__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/USDCLikePermitMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/USDCLikePermitMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/USDCLikePermitMock__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20Capitals__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32Capitals__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ERC20bytes32__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/ETHBadReceiver__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/UniERC20Helper.sol/UniERC20Wrapper__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WETH__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WETH__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WETH__factory.js.map +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WethReceiverMock__factory.d.ts +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WethReceiverMock__factory.js +1 -1
- package/dist/typechain-types/factories/contracts/tests/mocks/WethReceiverMock__factory.js.map +1 -1
- package/dist/typechain-types/index.d.ts +4 -0
- package/dist/typechain-types/index.js +6 -2
- package/dist/typechain-types/index.js.map +1 -1
- package/package.json +29 -21
- package/utils/README.md +198 -0
- package/utils/docify.utils.js +3 -34
- package/utils/file-dependencies.js +0 -0
- package/utils/test-docgen.js +0 -0
- package/utils/contract.hbs +0 -69
package/dist/src/expect.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import { Assertion, AssertionError, assert, expect, config, should } from 'chai';
|
|
2
|
+
/**
|
|
3
|
+
* @category expect
|
|
4
|
+
* @dev Asserts that two values are roughly equal within a specified relative difference.
|
|
5
|
+
* This function is useful for cases where precision issues might cause direct comparisons to fail.
|
|
6
|
+
* @param expected The expected value as a string, number, or bigint.
|
|
7
|
+
* @param actual The actual value obtained, to compare against the expected value.
|
|
8
|
+
* @param relativeDiff The maximum allowed relative difference between the expected and actual values.
|
|
9
|
+
* The relative difference is calculated as the absolute difference divided by the expected value,
|
|
10
|
+
* ensuring that the actual value is within this relative difference from the expected value.
|
|
11
|
+
* @notice This function will revert with a message if the values are of different signs
|
|
12
|
+
* or if the actual value deviates from the expected by more than the specified relative difference.
|
|
13
|
+
*/
|
|
2
14
|
export declare function assertRoughlyEqualValues(expected: string | number | bigint, actual: string | number | bigint, relativeDiff: number): void;
|
|
3
15
|
export { Assertion, AssertionError, assert, expect, config, should };
|
package/dist/src/expect.js
CHANGED
|
@@ -8,6 +8,18 @@ Object.defineProperty(exports, "assert", { enumerable: true, get: function () {
|
|
|
8
8
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return chai_1.expect; } });
|
|
9
9
|
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return chai_1.config; } });
|
|
10
10
|
Object.defineProperty(exports, "should", { enumerable: true, get: function () { return chai_1.should; } });
|
|
11
|
+
/**
|
|
12
|
+
* @category expect
|
|
13
|
+
* @dev Asserts that two values are roughly equal within a specified relative difference.
|
|
14
|
+
* This function is useful for cases where precision issues might cause direct comparisons to fail.
|
|
15
|
+
* @param expected The expected value as a string, number, or bigint.
|
|
16
|
+
* @param actual The actual value obtained, to compare against the expected value.
|
|
17
|
+
* @param relativeDiff The maximum allowed relative difference between the expected and actual values.
|
|
18
|
+
* The relative difference is calculated as the absolute difference divided by the expected value,
|
|
19
|
+
* ensuring that the actual value is within this relative difference from the expected value.
|
|
20
|
+
* @notice This function will revert with a message if the values are of different signs
|
|
21
|
+
* or if the actual value deviates from the expected by more than the specified relative difference.
|
|
22
|
+
*/
|
|
11
23
|
function assertRoughlyEqualValues(expected, actual, relativeDiff) {
|
|
12
24
|
let expectedBN = BigInt(expected);
|
|
13
25
|
let actualBN = BigInt(actual);
|
package/dist/src/expect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/expect.ts"],"names":[],"mappings":";;;AAAA,+BAAiF;
|
|
1
|
+
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/expect.ts"],"names":[],"mappings":";;;AAAA,+BAAiF;AAwCxE,0FAxCA,gBAAS,OAwCA;AAAE,+FAxCA,qBAAc,OAwCA;AAAE,uFAxCA,aAAM,OAwCA;AAAE,uFAxCA,aAAM,OAwCA;AAAE,uFAxCA,aAAM,OAwCA;AAAE,uFAxCA,aAAM,OAwCA;AAtClE;;;;;;;;;;;GAWG;AACH,SAAgB,wBAAwB,CACpC,QAAkC,EAClC,MAAgC,EAChC,YAAoB;IAEpB,IAAI,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAA,aAAM,EAAC,UAAU,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,8BAA8B,CAAC,CAAC;IAE3E,IAAI,UAAU,GAAG,CAAC;QAAE,UAAU,GAAG,CAAC,UAAU,CAAC;IAC7C,IAAI,QAAQ,GAAG,CAAC;QAAE,QAAQ,GAAG,CAAC,QAAQ,CAAC;IAEvC,IAAI,kBAAkB,GAAG,YAAY,CAAC;IACtC,IAAI,oBAAoB,GAAG,EAAE,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC3C,oBAAoB,GAAG,oBAAoB,GAAG,GAAG,CAAC;QAClD,kBAAkB,IAAI,EAAE,CAAC;IAC7B,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,UAAU,CAAC;IACnF,MAAM,QAAQ,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC,GAAG,oBAAoB,CAAC;IAClF,IAAI,IAAI,GAAG,QAAQ,EAAE,CAAC;QAClB,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,MAAM,OAAO,QAAQ,SAAS,YAAY,YAAY,CAAC,CAAC;IACxG,CAAC;AACL,CAAC;AAvBD,4DAuBC"}
|
package/dist/src/permit.d.ts
CHANGED
|
@@ -18,9 +18,43 @@ export declare const DaiLikePermit: {
|
|
|
18
18
|
name: string;
|
|
19
19
|
type: string;
|
|
20
20
|
}[];
|
|
21
|
+
/**
|
|
22
|
+
* @category permit
|
|
23
|
+
* @dev Removes the '0x' prefix from a string. If no '0x' prefix is found, returns the original string.
|
|
24
|
+
* @param bigNumber The number (as a bigint or string) from which to remove the '0x' prefix.
|
|
25
|
+
* @return The string without the '0x' prefix.
|
|
26
|
+
*/
|
|
21
27
|
export declare function trim0x(bigNumber: bigint | string): string;
|
|
28
|
+
/**
|
|
29
|
+
* @category permit
|
|
30
|
+
* @dev Trims the method selector from transaction data, removing the first 8 characters (4 bytes of hexable string) after '0x' prefix.
|
|
31
|
+
* @param data The transaction data string from which to trim the selector.
|
|
32
|
+
* @return The trimmed selector string.
|
|
33
|
+
*/
|
|
22
34
|
export declare function cutSelector(data: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* @category permit
|
|
37
|
+
* @dev Generates a domain separator for EIP-712 structured data using the provided parameters.
|
|
38
|
+
* @param name The user readable name of EIP-712 domain.
|
|
39
|
+
* @param version The version of the EIP-712 domain.
|
|
40
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
41
|
+
* @param verifyingContract The Ethereum address of the contract that will verify the signature. This ties the signature to a specific contract.
|
|
42
|
+
* @return The domain separator as a hex string.
|
|
43
|
+
*/
|
|
23
44
|
export declare function domainSeparator(name: string, version: string, chainId: string, verifyingContract: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* @category permit
|
|
47
|
+
* @dev Constructs structured data for EIP-2612 permit function, including types, domain, and message with details about the permit.
|
|
48
|
+
* @param name The user readable name of signing EIP-712 domain
|
|
49
|
+
* @param version The version of the signing EIP-712 domain.
|
|
50
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
51
|
+
* @param verifyingContract The Ethereum address of the contract that will verify the signature. This ties the signature to a specific contract.
|
|
52
|
+
* @param owner The Ethereum address of the token owner granting permission to spend tokens on their behalf.
|
|
53
|
+
* @param spender The Ethereum address of the party being granted permission to spend tokens on behalf of the owner.
|
|
54
|
+
* @param value The amount of tokens the spender is permitted to spend.
|
|
55
|
+
* @param nonce An arbitrary number used once to prevent replay attacks. Typically, this is the number of transactions sent by the owner.
|
|
56
|
+
* @param deadline The timestamp until which the permit is valid. This provides a window of time in which the permit can be used.
|
|
57
|
+
*/
|
|
24
58
|
export declare function buildData(name: string, version: string, chainId: number, verifyingContract: string, owner: string, spender: string, value: string, nonce: string, deadline?: string): {
|
|
25
59
|
readonly types: {
|
|
26
60
|
readonly Permit: {
|
|
@@ -42,6 +76,20 @@ export declare function buildData(name: string, version: string, chainId: number
|
|
|
42
76
|
readonly deadline: string;
|
|
43
77
|
};
|
|
44
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* @category permit
|
|
81
|
+
* @dev Prepares structured data similar to the Dai permit function, including types, domain, and message with permit details.
|
|
82
|
+
* @param name The user readable name of signing EIP-712 domain
|
|
83
|
+
* @param version The version of the signing EIP-712 domain.
|
|
84
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
85
|
+
* @param verifyingContract The Ethereum address of the contract that will verify the signature. This ties the signature to a specific contract.
|
|
86
|
+
* @param holder The address of the token holder who is giving permission, establishing the source of the funds.
|
|
87
|
+
* @param spender The address allowed to spend tokens on behalf of the holder, essentially the recipient of the permit.
|
|
88
|
+
* @param nonce An arbitrary number used once to prevent replay attacks. Typically, this is the number of transactions sent by the owner.
|
|
89
|
+
* @param allowed A boolean indicating whether the spender is allowed to spend the tokens, providing a clear permit status.
|
|
90
|
+
* @param expiry The time until which the permit is valid, offering a window during which the spender can use the permit.
|
|
91
|
+
* @return Structured data prepared for a Dai-like permit function.
|
|
92
|
+
*/
|
|
45
93
|
export declare function buildDataLikeDai(name: string, version: string, chainId: number, verifyingContract: string, holder: string, spender: string, nonce: string, allowed: boolean, expiry?: string): {
|
|
46
94
|
readonly types: {
|
|
47
95
|
readonly Permit: {
|
|
@@ -63,12 +111,93 @@ export declare function buildDataLikeDai(name: string, version: string, chainId:
|
|
|
63
111
|
readonly allowed: boolean;
|
|
64
112
|
};
|
|
65
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* @category permit
|
|
116
|
+
* @dev Ensures contract code is set for a given address and returns a contract instance.
|
|
117
|
+
* @return The contract instance of IPermit2.
|
|
118
|
+
*/
|
|
66
119
|
export declare function permit2Contract(): Promise<import("ethers").Contract>;
|
|
120
|
+
/**
|
|
121
|
+
* @category permit
|
|
122
|
+
* @notice Generates a permit signature for ERC20 tokens with EIP-2612 standard.
|
|
123
|
+
* @param owner The wallet or signer issuing the permit.
|
|
124
|
+
* @param permitContract The contract object with ERC20Permit type and token address for which the permit creating.
|
|
125
|
+
* @param tokenVersion The version of the token's EIP-712 domain.
|
|
126
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
127
|
+
* @param spender The address allowed to spend the tokens.
|
|
128
|
+
* @param value The amount of tokens the spender is allowed to use.
|
|
129
|
+
* @param deadline Time until when the permit is valid.
|
|
130
|
+
* @param compact Indicates if the permit should be compressed.
|
|
131
|
+
* @return A signed permit string.
|
|
132
|
+
*/
|
|
67
133
|
export declare function getPermit(owner: Wallet | SignerWithAddress, permitContract: ERC20Permit, tokenVersion: string, chainId: number, spender: string, value: string, deadline?: string, compact?: boolean): Promise<string>;
|
|
134
|
+
/**
|
|
135
|
+
* @category permit
|
|
136
|
+
* @notice Creates a permit for spending tokens on Permit2 standard contracts.
|
|
137
|
+
* @param owner The wallet or signer issuing the permit.
|
|
138
|
+
* @param token The address of the token for which the permit is creates.
|
|
139
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
140
|
+
* @param spender The address allowed to spend the tokens.
|
|
141
|
+
* @param amount The amount of tokens the spender is allowed to use.
|
|
142
|
+
* @param compact Indicates if the permit should be compressed.
|
|
143
|
+
* @param expiration The time until when the permit is valid for Permit2.
|
|
144
|
+
* @param sigDeadline Deadline for the signature to be considered valid.
|
|
145
|
+
* @return A signed permit string specific to Permit2 contracts.
|
|
146
|
+
*/
|
|
68
147
|
export declare function getPermit2(owner: Wallet | SignerWithAddress, token: string, chainId: number, spender: string, amount: bigint, compact?: boolean, expiration?: bigint, sigDeadline?: bigint): Promise<string>;
|
|
148
|
+
/**
|
|
149
|
+
* @category permit
|
|
150
|
+
* @notice Generates a Dai-like permit signature for tokens.
|
|
151
|
+
* @param holder The wallet or signer issuing the permit.
|
|
152
|
+
* @param permitContract The contract object with ERC20PermitLikeDai type and token address for which the permit creating.
|
|
153
|
+
* @param tokenVersion The version of the token's EIP-712 domain.
|
|
154
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
155
|
+
* @param spender The address allowed to spend the tokens.
|
|
156
|
+
* @param allowed Boolean indicating whether the spender is allowed to spend.
|
|
157
|
+
* @param expiry Time until when the permit is valid.
|
|
158
|
+
* @param compact Indicates if the permit should be compressed.
|
|
159
|
+
* @return A signed permit string in Dai-like format.
|
|
160
|
+
*/
|
|
69
161
|
export declare function getPermitLikeDai(holder: Wallet | SignerWithAddress, permitContract: DaiLikePermitMock, tokenVersion: string, chainId: number, spender: string, allowed: boolean, expiry?: string, compact?: boolean): Promise<string>;
|
|
70
|
-
|
|
71
|
-
|
|
162
|
+
/**
|
|
163
|
+
* @category permit
|
|
164
|
+
* @notice Generates a ERC-7597 permit signature for tokens.
|
|
165
|
+
* @param owner Contract with isValidSignature function.
|
|
166
|
+
* @param signer The wallet or signer issuing the permit.
|
|
167
|
+
* @param permitContract The contract object with ERC7597Permit type and token address for which the permit creating.
|
|
168
|
+
* @param tokenVersion The version of the token's EIP-712 domain.
|
|
169
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
170
|
+
* @param spender The address allowed to spend the tokens.
|
|
171
|
+
* @param value The amount of tokens the spender is allowed to use.
|
|
172
|
+
* @param deadline Time until when the permit is valid.
|
|
173
|
+
* @return A signed permit string in ERC7597Permit format.
|
|
174
|
+
*/
|
|
175
|
+
export declare function getPermitLikeUSDC(owner: string, signer: Wallet | SignerWithAddress, permitContract: USDCLikePermitMock, tokenVersion: string, chainId: number, spender: string, value: string, deadline?: string): Promise<string>;
|
|
176
|
+
/**
|
|
177
|
+
* @category permit
|
|
178
|
+
* @notice Concatenates a target address with data, trimming the '0x' prefix from the data.
|
|
179
|
+
* @param target The target address or value to prepend.
|
|
180
|
+
* @param data The data string to be concatenated after trimming.
|
|
181
|
+
* @return A concatenated string of target and data.
|
|
182
|
+
*/
|
|
72
183
|
export declare function withTarget(target: bigint | string, data: bigint | string): string;
|
|
184
|
+
/**
|
|
185
|
+
* @category permit
|
|
186
|
+
* @notice Compresses a permit function call to a shorter format based on its type.
|
|
187
|
+
* Type | EIP-2612 | DAI | Permit2
|
|
188
|
+
* Uncompressed | 224 | 256 | 352
|
|
189
|
+
* Compressed | 100 | 72 | 96
|
|
190
|
+
* @param permit The full permit function call string.
|
|
191
|
+
* @return A compressed permit string.
|
|
192
|
+
*/
|
|
73
193
|
export declare function compressPermit(permit: string): string;
|
|
194
|
+
/**
|
|
195
|
+
* @category permit
|
|
196
|
+
* @notice Decompresses a compressed permit function call back to its original full format.
|
|
197
|
+
* @param permit The compressed permit function call string.
|
|
198
|
+
* @param token The token address involved in the permit (for Permit2 type).
|
|
199
|
+
* @param owner The owner address involved in the permit.
|
|
200
|
+
* @param spender The spender address involved in the permit.
|
|
201
|
+
* @return The decompressed permit function call string.
|
|
202
|
+
*/
|
|
74
203
|
export declare function decompressPermit(permit: string, token: string, owner: string, spender: string): string;
|
package/dist/src/permit.js
CHANGED
|
@@ -31,6 +31,12 @@ exports.DaiLikePermit = [
|
|
|
31
31
|
{ name: 'expiry', type: 'uint256' },
|
|
32
32
|
{ name: 'allowed', type: 'bool' },
|
|
33
33
|
];
|
|
34
|
+
/**
|
|
35
|
+
* @category permit
|
|
36
|
+
* @dev Removes the '0x' prefix from a string. If no '0x' prefix is found, returns the original string.
|
|
37
|
+
* @param bigNumber The number (as a bigint or string) from which to remove the '0x' prefix.
|
|
38
|
+
* @return The string without the '0x' prefix.
|
|
39
|
+
*/
|
|
34
40
|
function trim0x(bigNumber) {
|
|
35
41
|
const s = bigNumber.toString();
|
|
36
42
|
if (s.startsWith('0x')) {
|
|
@@ -39,16 +45,44 @@ function trim0x(bigNumber) {
|
|
|
39
45
|
return s;
|
|
40
46
|
}
|
|
41
47
|
exports.trim0x = trim0x;
|
|
48
|
+
/**
|
|
49
|
+
* @category permit
|
|
50
|
+
* @dev Trims the method selector from transaction data, removing the first 8 characters (4 bytes of hexable string) after '0x' prefix.
|
|
51
|
+
* @param data The transaction data string from which to trim the selector.
|
|
52
|
+
* @return The trimmed selector string.
|
|
53
|
+
*/
|
|
42
54
|
function cutSelector(data) {
|
|
43
55
|
const hexPrefix = '0x';
|
|
44
56
|
return hexPrefix + data.substring(hexPrefix.length + 8);
|
|
45
57
|
}
|
|
46
58
|
exports.cutSelector = cutSelector;
|
|
59
|
+
/**
|
|
60
|
+
* @category permit
|
|
61
|
+
* @dev Generates a domain separator for EIP-712 structured data using the provided parameters.
|
|
62
|
+
* @param name The user readable name of EIP-712 domain.
|
|
63
|
+
* @param version The version of the EIP-712 domain.
|
|
64
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
65
|
+
* @param verifyingContract The Ethereum address of the contract that will verify the signature. This ties the signature to a specific contract.
|
|
66
|
+
* @return The domain separator as a hex string.
|
|
67
|
+
*/
|
|
47
68
|
function domainSeparator(name, version, chainId, verifyingContract) {
|
|
48
69
|
return ('0x' +
|
|
49
70
|
eth_sig_util_1.TypedDataUtils.hashStruct('EIP712Domain', { name, version, chainId, verifyingContract }, { EIP712Domain: exports.EIP712Domain }, exports.TypedDataVersion).toString('hex'));
|
|
50
71
|
}
|
|
51
72
|
exports.domainSeparator = domainSeparator;
|
|
73
|
+
/**
|
|
74
|
+
* @category permit
|
|
75
|
+
* @dev Constructs structured data for EIP-2612 permit function, including types, domain, and message with details about the permit.
|
|
76
|
+
* @param name The user readable name of signing EIP-712 domain
|
|
77
|
+
* @param version The version of the signing EIP-712 domain.
|
|
78
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
79
|
+
* @param verifyingContract The Ethereum address of the contract that will verify the signature. This ties the signature to a specific contract.
|
|
80
|
+
* @param owner The Ethereum address of the token owner granting permission to spend tokens on their behalf.
|
|
81
|
+
* @param spender The Ethereum address of the party being granted permission to spend tokens on behalf of the owner.
|
|
82
|
+
* @param value The amount of tokens the spender is permitted to spend.
|
|
83
|
+
* @param nonce An arbitrary number used once to prevent replay attacks. Typically, this is the number of transactions sent by the owner.
|
|
84
|
+
* @param deadline The timestamp until which the permit is valid. This provides a window of time in which the permit can be used.
|
|
85
|
+
*/
|
|
52
86
|
function buildData(name, version, chainId, verifyingContract, owner, spender, value, nonce, deadline = exports.defaultDeadline.toString()) {
|
|
53
87
|
return {
|
|
54
88
|
types: { Permit: exports.Permit },
|
|
@@ -57,6 +91,20 @@ function buildData(name, version, chainId, verifyingContract, owner, spender, va
|
|
|
57
91
|
};
|
|
58
92
|
}
|
|
59
93
|
exports.buildData = buildData;
|
|
94
|
+
/**
|
|
95
|
+
* @category permit
|
|
96
|
+
* @dev Prepares structured data similar to the Dai permit function, including types, domain, and message with permit details.
|
|
97
|
+
* @param name The user readable name of signing EIP-712 domain
|
|
98
|
+
* @param version The version of the signing EIP-712 domain.
|
|
99
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
100
|
+
* @param verifyingContract The Ethereum address of the contract that will verify the signature. This ties the signature to a specific contract.
|
|
101
|
+
* @param holder The address of the token holder who is giving permission, establishing the source of the funds.
|
|
102
|
+
* @param spender The address allowed to spend tokens on behalf of the holder, essentially the recipient of the permit.
|
|
103
|
+
* @param nonce An arbitrary number used once to prevent replay attacks. Typically, this is the number of transactions sent by the owner.
|
|
104
|
+
* @param allowed A boolean indicating whether the spender is allowed to spend the tokens, providing a clear permit status.
|
|
105
|
+
* @param expiry The time until which the permit is valid, offering a window during which the spender can use the permit.
|
|
106
|
+
* @return Structured data prepared for a Dai-like permit function.
|
|
107
|
+
*/
|
|
60
108
|
function buildDataLikeDai(name, version, chainId, verifyingContract, holder, spender, nonce, allowed, expiry = exports.defaultDeadline.toString()) {
|
|
61
109
|
return {
|
|
62
110
|
types: { Permit: exports.DaiLikePermit },
|
|
@@ -65,6 +113,11 @@ function buildDataLikeDai(name, version, chainId, verifyingContract, holder, spe
|
|
|
65
113
|
};
|
|
66
114
|
}
|
|
67
115
|
exports.buildDataLikeDai = buildDataLikeDai;
|
|
116
|
+
/**
|
|
117
|
+
* @category permit
|
|
118
|
+
* @dev Ensures contract code is set for a given address and returns a contract instance.
|
|
119
|
+
* @return The contract instance of IPermit2.
|
|
120
|
+
*/
|
|
68
121
|
async function permit2Contract() {
|
|
69
122
|
if ((await hardhat_1.ethers.provider.getCode(permit2_sdk_1.PERMIT2_ADDRESS)) === '0x') {
|
|
70
123
|
await hardhat_1.ethers.provider.send('hardhat_setCode', [permit2_sdk_1.PERMIT2_ADDRESS, permit2_json_1.bytecode]);
|
|
@@ -72,8 +125,18 @@ async function permit2Contract() {
|
|
|
72
125
|
return hardhat_1.ethers.getContractAt('IPermit2', permit2_sdk_1.PERMIT2_ADDRESS);
|
|
73
126
|
}
|
|
74
127
|
exports.permit2Contract = permit2Contract;
|
|
75
|
-
|
|
128
|
+
/**
|
|
129
|
+
* @category permit
|
|
130
|
+
* @notice Generates a permit signature for ERC20 tokens with EIP-2612 standard.
|
|
131
|
+
* @param owner The wallet or signer issuing the permit.
|
|
76
132
|
* @param permitContract The contract object with ERC20Permit type and token address for which the permit creating.
|
|
133
|
+
* @param tokenVersion The version of the token's EIP-712 domain.
|
|
134
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
135
|
+
* @param spender The address allowed to spend the tokens.
|
|
136
|
+
* @param value The amount of tokens the spender is allowed to use.
|
|
137
|
+
* @param deadline Time until when the permit is valid.
|
|
138
|
+
* @param compact Indicates if the permit should be compressed.
|
|
139
|
+
* @return A signed permit string.
|
|
77
140
|
*/
|
|
78
141
|
async function getPermit(owner, permitContract, tokenVersion, chainId, spender, value, deadline = exports.defaultDeadline.toString(), compact = false) {
|
|
79
142
|
const nonce = await permitContract.nonces(owner);
|
|
@@ -85,8 +148,18 @@ async function getPermit(owner, permitContract, tokenVersion, chainId, spender,
|
|
|
85
148
|
return compact ? compressPermit(permitCall) : decompressPermit(compressPermit(permitCall), prelude_1.constants.ZERO_ADDRESS, owner.address, spender);
|
|
86
149
|
}
|
|
87
150
|
exports.getPermit = getPermit;
|
|
88
|
-
|
|
89
|
-
* @
|
|
151
|
+
/**
|
|
152
|
+
* @category permit
|
|
153
|
+
* @notice Creates a permit for spending tokens on Permit2 standard contracts.
|
|
154
|
+
* @param owner The wallet or signer issuing the permit.
|
|
155
|
+
* @param token The address of the token for which the permit is creates.
|
|
156
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
157
|
+
* @param spender The address allowed to spend the tokens.
|
|
158
|
+
* @param amount The amount of tokens the spender is allowed to use.
|
|
159
|
+
* @param compact Indicates if the permit should be compressed.
|
|
160
|
+
* @param expiration The time until when the permit is valid for Permit2.
|
|
161
|
+
* @param sigDeadline Deadline for the signature to be considered valid.
|
|
162
|
+
* @return A signed permit string specific to Permit2 contracts.
|
|
90
163
|
*/
|
|
91
164
|
async function getPermit2(owner, token, chainId, spender, amount, compact = false, expiration = exports.defaultDeadlinePermit2, sigDeadline = exports.defaultDeadlinePermit2) {
|
|
92
165
|
const permitContract = await permit2Contract();
|
|
@@ -108,8 +181,18 @@ async function getPermit2(owner, token, chainId, spender, amount, compact = fals
|
|
|
108
181
|
return compact ? compressPermit(permitCall) : decompressPermit(compressPermit(permitCall), token, owner.address, spender);
|
|
109
182
|
}
|
|
110
183
|
exports.getPermit2 = getPermit2;
|
|
111
|
-
|
|
184
|
+
/**
|
|
185
|
+
* @category permit
|
|
186
|
+
* @notice Generates a Dai-like permit signature for tokens.
|
|
187
|
+
* @param holder The wallet or signer issuing the permit.
|
|
112
188
|
* @param permitContract The contract object with ERC20PermitLikeDai type and token address for which the permit creating.
|
|
189
|
+
* @param tokenVersion The version of the token's EIP-712 domain.
|
|
190
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
191
|
+
* @param spender The address allowed to spend the tokens.
|
|
192
|
+
* @param allowed Boolean indicating whether the spender is allowed to spend.
|
|
193
|
+
* @param expiry Time until when the permit is valid.
|
|
194
|
+
* @param compact Indicates if the permit should be compressed.
|
|
195
|
+
* @return A signed permit string in Dai-like format.
|
|
113
196
|
*/
|
|
114
197
|
async function getPermitLikeDai(holder, permitContract, tokenVersion, chainId, spender, allowed, expiry = exports.defaultDeadline.toString(), compact = false) {
|
|
115
198
|
const nonce = await permitContract.nonces(holder);
|
|
@@ -121,8 +204,20 @@ async function getPermitLikeDai(holder, permitContract, tokenVersion, chainId, s
|
|
|
121
204
|
return compact ? compressPermit(permitCall) : decompressPermit(compressPermit(permitCall), prelude_1.constants.ZERO_ADDRESS, holder.address, spender);
|
|
122
205
|
}
|
|
123
206
|
exports.getPermitLikeDai = getPermitLikeDai;
|
|
124
|
-
|
|
125
|
-
|
|
207
|
+
/**
|
|
208
|
+
* @category permit
|
|
209
|
+
* @notice Generates a ERC-7597 permit signature for tokens.
|
|
210
|
+
* @param owner Contract with isValidSignature function.
|
|
211
|
+
* @param signer The wallet or signer issuing the permit.
|
|
212
|
+
* @param permitContract The contract object with ERC7597Permit type and token address for which the permit creating.
|
|
213
|
+
* @param tokenVersion The version of the token's EIP-712 domain.
|
|
214
|
+
* @param chainId The unique identifier for the blockchain network.
|
|
215
|
+
* @param spender The address allowed to spend the tokens.
|
|
216
|
+
* @param value The amount of tokens the spender is allowed to use.
|
|
217
|
+
* @param deadline Time until when the permit is valid.
|
|
218
|
+
* @return A signed permit string in ERC7597Permit format.
|
|
219
|
+
*/
|
|
220
|
+
async function getPermitLikeUSDC(owner, signer, permitContract, tokenVersion, chainId, spender, value, deadline = exports.defaultDeadline.toString()) {
|
|
126
221
|
const nonce = await permitContract.nonces(owner);
|
|
127
222
|
const name = await permitContract.name();
|
|
128
223
|
const data = buildData(name, tokenVersion, chainId, await permitContract.getAddress(), owner, spender, value, nonce.toString(), deadline);
|
|
@@ -132,13 +227,26 @@ signer, permitContract, tokenVersion, chainId, spender, value, deadline = export
|
|
|
132
227
|
return cutSelector(permitContract.interface.encodeFunctionData('permit(address,address,uint256,uint256,bytes)', [owner, spender, value, deadline, signatureBytes]));
|
|
133
228
|
}
|
|
134
229
|
exports.getPermitLikeUSDC = getPermitLikeUSDC;
|
|
230
|
+
/**
|
|
231
|
+
* @category permit
|
|
232
|
+
* @notice Concatenates a target address with data, trimming the '0x' prefix from the data.
|
|
233
|
+
* @param target The target address or value to prepend.
|
|
234
|
+
* @param data The data string to be concatenated after trimming.
|
|
235
|
+
* @return A concatenated string of target and data.
|
|
236
|
+
*/
|
|
135
237
|
function withTarget(target, data) {
|
|
136
238
|
return target.toString() + trim0x(data);
|
|
137
239
|
}
|
|
138
240
|
exports.withTarget = withTarget;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
241
|
+
/**
|
|
242
|
+
* @category permit
|
|
243
|
+
* @notice Compresses a permit function call to a shorter format based on its type.
|
|
244
|
+
* Type | EIP-2612 | DAI | Permit2
|
|
245
|
+
* Uncompressed | 224 | 256 | 352
|
|
246
|
+
* Compressed | 100 | 72 | 96
|
|
247
|
+
* @param permit The full permit function call string.
|
|
248
|
+
* @return A compressed permit string.
|
|
249
|
+
*/
|
|
142
250
|
function compressPermit(permit) {
|
|
143
251
|
const abiCoder = hardhat_1.ethers.AbiCoder.defaultAbiCoder();
|
|
144
252
|
switch (permit.length) {
|
|
@@ -179,6 +287,15 @@ function compressPermit(permit) {
|
|
|
179
287
|
}
|
|
180
288
|
}
|
|
181
289
|
exports.compressPermit = compressPermit;
|
|
290
|
+
/**
|
|
291
|
+
* @category permit
|
|
292
|
+
* @notice Decompresses a compressed permit function call back to its original full format.
|
|
293
|
+
* @param permit The compressed permit function call string.
|
|
294
|
+
* @param token The token address involved in the permit (for Permit2 type).
|
|
295
|
+
* @param owner The owner address involved in the permit.
|
|
296
|
+
* @param spender The spender address involved in the permit.
|
|
297
|
+
* @return The decompressed permit function call string.
|
|
298
|
+
*/
|
|
182
299
|
function decompressPermit(permit, token, owner, spender) {
|
|
183
300
|
const abiCoder = hardhat_1.ethers.AbiCoder.defaultAbiCoder();
|
|
184
301
|
switch (permit.length) {
|
package/dist/src/permit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permit.js","sourceRoot":"","sources":["../../src/permit.ts"],"names":[],"mappings":";;;AAAA,yDAA8E;AAC9E,uCAAsC;AACtC,mCAA4D;AAC5D,2CAAyC,CAAE,iEAAiE;AAC5G,qCAAiC;AAEjC,sDAA0E;AAC1E,iDAA6D;AAGhD,QAAA,gBAAgB,GAAG,mCAAoB,CAAC,EAAE,CAAC;AAC3C,QAAA,eAAe,GAAG,mBAAS,CAAC,WAAW,CAAC;AACxC,QAAA,sBAAsB,GAAG,mBAAS,CAAC,UAAU,CAAC;AAE9C,QAAA,YAAY,GAAG;IACxB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;CACjD,CAAC;AAEW,QAAA,MAAM,GAAG;IAClB,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CACJ,CAAC;QACN,CAAC;QACD,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACJ,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACtD;YACI,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC7C,CAAC;AACL,CAAC;AAhFD,4CAgFC"}
|
package/dist/src/prelude.d.ts
CHANGED
|
@@ -12,4 +12,10 @@ export declare const constants: {
|
|
|
12
12
|
readonly DEV_CHAINS: string[];
|
|
13
13
|
};
|
|
14
14
|
export { time };
|
|
15
|
+
/**
|
|
16
|
+
* @category prelude
|
|
17
|
+
* @notice Converts an Ether amount represented as a string into its Wei equivalent as a bigint.
|
|
18
|
+
* @param n The amount of Ether to convert, specified as a string.
|
|
19
|
+
* @return The equivalent amount in Wei as a bigint.
|
|
20
|
+
*/
|
|
15
21
|
export declare function ether(n: string): bigint;
|
package/dist/src/prelude.js
CHANGED
|
@@ -16,6 +16,12 @@ exports.constants = {
|
|
|
16
16
|
MAX_UINT32: 2n ** 32n - 1n,
|
|
17
17
|
DEV_CHAINS: ['hardhat', 'localhost'],
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* @category prelude
|
|
21
|
+
* @notice Converts an Ether amount represented as a string into its Wei equivalent as a bigint.
|
|
22
|
+
* @param n The amount of Ether to convert, specified as a string.
|
|
23
|
+
* @return The equivalent amount in Wei as a bigint.
|
|
24
|
+
*/
|
|
19
25
|
function ether(n) {
|
|
20
26
|
return (0, ethers_1.parseUnits)(n);
|
|
21
27
|
}
|
package/dist/src/prelude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../src/prelude.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,sFAAgE;AAgBvD,qFAhBA,8BAAI,OAgBA;AAdA,QAAA,SAAS,GAAG;IACrB,YAAY,EAAE,4CAA4C;IAC1D,WAAW,EA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AEC"}
|
package/dist/src/profileEVM.d.ts
CHANGED
|
@@ -2,14 +2,40 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { PathLike, promises as fs } from 'fs';
|
|
4
4
|
import { JsonRpcProvider } from 'ethers';
|
|
5
|
+
/**
|
|
6
|
+
* @category profileEVM
|
|
7
|
+
* @dev Default configuration options for the `gasspectEVM` function to analyze gas usage in EVM transactions.
|
|
8
|
+
* @property minOpGasCost The minimal gas cost of operations to be returned in the analysis. Defaults to 300, filtering out less costly operations for clarity.
|
|
9
|
+
* @property args Boolean indicating whether to return the arguments of each operation in the analysis. Defaults to `false`, omitting arguments for simplicity.
|
|
10
|
+
* @property res Boolean indicating whether to return the results of each operation in the analysis. Defaults to `false`, omitting results to focus on gas usage.
|
|
11
|
+
*/
|
|
5
12
|
export declare const gasspectOptionsDefault: {
|
|
6
13
|
minOpGasCost: number;
|
|
7
14
|
args: boolean;
|
|
8
15
|
res: boolean;
|
|
9
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* @category profileEVM
|
|
19
|
+
* @notice Profiles EVM execution by counting occurrences of specified instructions in a transaction's execution trace.
|
|
20
|
+
* @param provider An Ethereum provider capable of sending custom RPC requests.
|
|
21
|
+
* @param txHash The hash of the transaction to profile.
|
|
22
|
+
* @param instruction An array of EVM instructions (opcodes) to count within the transaction's execution trace.
|
|
23
|
+
* @param optionalTraceFile An optional file path or handle where the full transaction trace will be saved.
|
|
24
|
+
* @return An array of numbers representing the counts of each instruction specified, in the order they were provided.
|
|
25
|
+
*/
|
|
10
26
|
export declare function profileEVM(provider: JsonRpcProvider | {
|
|
11
27
|
send: (method: string, params: unknown[]) => Promise<any>;
|
|
12
28
|
}, txHash: string, instruction: string[], optionalTraceFile?: PathLike | fs.FileHandle): Promise<number[]>;
|
|
29
|
+
/**
|
|
30
|
+
* @category profileEVM
|
|
31
|
+
* @notice Performs gas analysis on EVM transactions, highlighting operations that exceed a specified gas cost.
|
|
32
|
+
* Analyzes gas usage by operations within a transaction, applying filters and formatting based on options.
|
|
33
|
+
* @param provider The Ethereum JSON RPC provider or any custom provider with a `send` method.
|
|
34
|
+
* @param txHash Transaction hash to analyze.
|
|
35
|
+
* @param gasspectOptions Analysis configuration, specifying filters and formatting for gas analysis. See `gasspectOptionsDefault` for default values.
|
|
36
|
+
* @param optionalTraceFile Optional path or handle to save the detailed transaction trace.
|
|
37
|
+
* @return A detailed string array of operations meeting the criteria set in `gasspectOptions`.
|
|
38
|
+
*/
|
|
13
39
|
export declare function gasspectEVM(provider: JsonRpcProvider | {
|
|
14
40
|
send: (method: string, params: unknown[]) => Promise<any>;
|
|
15
41
|
}, txHash: string, gasspectOptions?: Record<string, unknown>, optionalTraceFile?: PathLike | fs.FileHandle): Promise<string[]>;
|
package/dist/src/profileEVM.js
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gasspectEVM = exports.profileEVM = exports.gasspectOptionsDefault = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
|
+
/**
|
|
6
|
+
* @category profileEVM
|
|
7
|
+
* @dev Default configuration options for the `gasspectEVM` function to analyze gas usage in EVM transactions.
|
|
8
|
+
* @property minOpGasCost The minimal gas cost of operations to be returned in the analysis. Defaults to 300, filtering out less costly operations for clarity.
|
|
9
|
+
* @property args Boolean indicating whether to return the arguments of each operation in the analysis. Defaults to `false`, omitting arguments for simplicity.
|
|
10
|
+
* @property res Boolean indicating whether to return the results of each operation in the analysis. Defaults to `false`, omitting results to focus on gas usage.
|
|
11
|
+
*/
|
|
5
12
|
exports.gasspectOptionsDefault = {
|
|
6
|
-
minOpGasCost: 300,
|
|
7
|
-
args: false,
|
|
8
|
-
res: false,
|
|
13
|
+
minOpGasCost: 300,
|
|
14
|
+
args: false,
|
|
15
|
+
res: false,
|
|
9
16
|
};
|
|
17
|
+
/** @internal */
|
|
10
18
|
function _normalizeOp(ops, i) {
|
|
11
19
|
if (ops[i].op === 'STATICCALL') {
|
|
12
20
|
ops[i].gasCost = ops[i].gasCost - ops[i + 1].gas;
|
|
@@ -68,6 +76,15 @@ function _normalizeOp(ops, i) {
|
|
|
68
76
|
ops[i].res = ops[i + 1].stack[ops[i + 1].stack.length - 1];
|
|
69
77
|
}
|
|
70
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* @category profileEVM
|
|
81
|
+
* @notice Profiles EVM execution by counting occurrences of specified instructions in a transaction's execution trace.
|
|
82
|
+
* @param provider An Ethereum provider capable of sending custom RPC requests.
|
|
83
|
+
* @param txHash The hash of the transaction to profile.
|
|
84
|
+
* @param instruction An array of EVM instructions (opcodes) to count within the transaction's execution trace.
|
|
85
|
+
* @param optionalTraceFile An optional file path or handle where the full transaction trace will be saved.
|
|
86
|
+
* @return An array of numbers representing the counts of each instruction specified, in the order they were provided.
|
|
87
|
+
*/
|
|
71
88
|
async function profileEVM(
|
|
72
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
90
|
provider, txHash, instruction, optionalTraceFile) {
|
|
@@ -81,6 +98,16 @@ provider, txHash, instruction, optionalTraceFile) {
|
|
|
81
98
|
});
|
|
82
99
|
}
|
|
83
100
|
exports.profileEVM = profileEVM;
|
|
101
|
+
/**
|
|
102
|
+
* @category profileEVM
|
|
103
|
+
* @notice Performs gas analysis on EVM transactions, highlighting operations that exceed a specified gas cost.
|
|
104
|
+
* Analyzes gas usage by operations within a transaction, applying filters and formatting based on options.
|
|
105
|
+
* @param provider The Ethereum JSON RPC provider or any custom provider with a `send` method.
|
|
106
|
+
* @param txHash Transaction hash to analyze.
|
|
107
|
+
* @param gasspectOptions Analysis configuration, specifying filters and formatting for gas analysis. See `gasspectOptionsDefault` for default values.
|
|
108
|
+
* @param optionalTraceFile Optional path or handle to save the detailed transaction trace.
|
|
109
|
+
* @return A detailed string array of operations meeting the criteria set in `gasspectOptions`.
|
|
110
|
+
*/
|
|
84
111
|
async function gasspectEVM(
|
|
85
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
113
|
provider, txHash, gasspectOptions = {}, optionalTraceFile) {
|