t-isol 0.0.9 → 0.0.10

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.
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+
6
+ /**
7
+ * @title BasexERC20 (Base)
8
+ * @notice Provides a simple and efficient way to deploy your own ERC20 token with custom parameters, saving time and reducing errors.
9
+ * @dev Inherit this contract to quickly deploy an ERC20 token using OpenZeppelin's implementation.
10
+ * Set name, symbol, and initial supply via constructor. Mints all supply to deployer.
11
+ *
12
+ * Arguments:
13
+ * - name (string): Token name
14
+ * - symbol (string): Token symbol
15
+ * - initialSupply (uint256): Initial token supply (Integer number)
16
+ *
17
+ * Example:
18
+ * contract MyToken is BasexERC20 {
19
+ * constructor()
20
+ * BasexERC20(
21
+ * "MyToken",
22
+ * "MTK",
23
+ * 1000000 // 1 million tokens
24
+ * )
25
+ * {}
26
+ * }
27
+ */
28
+ abstract contract BasexERC20 is ERC20 {
29
+ constructor(
30
+ string memory name,
31
+ string memory symbol,
32
+ uint256 initialSupply
33
+ )
34
+ ERC20(name, symbol)
35
+ {
36
+ _mint(msg.sender, initialSupply * 10 ** decimals());
37
+ }
38
+ }
@@ -0,0 +1,112 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol";
6
+ import "../TransferAuthorize.sol";
7
+ import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
8
+ import "@openzeppelin/contracts/access/Ownable.sol";
9
+
10
+ /**
11
+ * @title ERC20WrappedxWithAuthorize (Kit)
12
+ * @notice ERC20 wrapper with EIP-712 based off-chain authorized transfers and burns.
13
+ * @dev Wraps an existing ERC20 token, adding `transferWithAuthorize` and `burnWithAuthorize` functions.
14
+ * Enables gasless transfers and advanced flows using signatures. Integrates OpenZeppelin ERC20Wrapper, ReentrancyGuard, and Ownable.
15
+ *
16
+ * Arguments:
17
+ * - underlyingToken (address): Address of the underlying ERC20 token to wrap
18
+ * - name (string): Token name
19
+ * - symbol (string): Token symbol
20
+ * - domainName (string): EIP-712 domain name
21
+ * - domainVersion (string): EIP-712 domain version
22
+ *
23
+ * Example:
24
+ * contract MyWrappedToken is ERC20WrappedxWithAuthorize {
25
+ * constructor()
26
+ * ERC20WrappedxWithAuthorize(
27
+ * 0x123...abc, // underlying token address
28
+ * "MyWrappedToken",
29
+ * "MWTK",
30
+ * "MyWrappedToken",
31
+ * "1"
32
+ * )
33
+ * {}
34
+ * }
35
+ */
36
+ abstract contract ERC20WrappedxWithAuthorize is ERC20, ERC20Wrapper, TransferAuthorize, ReentrancyGuard, Ownable {
37
+ constructor(
38
+ address _underlyingToken,
39
+ string memory _name,
40
+ string memory _symbol,
41
+ string memory _domainName,
42
+ string memory _domainVersion
43
+ )
44
+ ERC20(_name, _symbol)
45
+ ERC20Wrapper(IERC20(_underlyingToken))
46
+ TransferAuthorize(_domainName, _domainVersion)
47
+ Ownable(msg.sender)
48
+ {}
49
+
50
+ /**
51
+ * @notice Returns the token decimals
52
+ * @dev Overrides both ERC20 and ERC20Wrapper decimals function
53
+ * @return uint8 decimals of the token (usually matches underlying token)
54
+ */
55
+ function decimals()
56
+ public
57
+ view
58
+ virtual
59
+ override(ERC20, ERC20Wrapper)
60
+ returns (uint8)
61
+ {
62
+ return super.decimals();
63
+ }
64
+
65
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
66
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
67
+ function transferWithAuthorize(
68
+ address from,
69
+ address to,
70
+ uint256 value,
71
+ uint256 createTime,
72
+ uint256 expireTime,
73
+ bytes32 nonce,
74
+ bytes calldata auth
75
+ ) external override nonReentrant {
76
+ address signer = _verifyTransfer(
77
+ from,
78
+ to,
79
+ value,
80
+ createTime,
81
+ expireTime,
82
+ nonce,
83
+ auth
84
+ );
85
+ require(signer == from, "transferWithAuthorize: invalid signature");
86
+ _useAuthorize(from, nonce);
87
+ _transfer(from, to, value);
88
+ }
89
+
90
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
91
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
92
+ function burnWithAuthorize(
93
+ address from,
94
+ uint256 value,
95
+ uint256 createTime,
96
+ uint256 expireTime,
97
+ bytes32 nonce,
98
+ bytes calldata auth
99
+ ) external override nonReentrant {
100
+ address signer = _verifyBurn(
101
+ from,
102
+ value,
103
+ createTime,
104
+ expireTime,
105
+ nonce,
106
+ auth
107
+ );
108
+ require(signer == from, "burnWithAuthorize: invalid signature");
109
+ _useAuthorize(from, nonce);
110
+ _burn(from, value);
111
+ }
112
+ }
@@ -6,9 +6,32 @@ import "../TransferAuthorize.sol";
6
6
  import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
7
7
  import "@openzeppelin/contracts/access/Ownable.sol";
8
8
 
9
- /// @title ERC20xTransferWithAuthorize
10
- /// @notice ERC20 extension that supports EIP-712 based `transferWithAuthorize` and `receiveWithAuthorize` flows
11
- /// @dev `receiveWithAuthorize` restricts the caller to the `to` address (recipient submits the proof). `transferWithAuthorize` is open to relayers.
9
+ /**
10
+ * @title ERC20xTransferWithAuthorize (Kit)
11
+ * @notice ERC20 extension for fast, secure, and flexible off-chain authorized transfers and burns (EIP-712).
12
+ * @dev Adds `transferWithAuthorize` and `burnWithAuthorize` for meta-transactions and relayer support.
13
+ * Enables gasless transfers and advanced flows using signatures. Integrates OpenZeppelin ERC20, ReentrancyGuard, and Ownable.
14
+ *
15
+ * Arguments:
16
+ * - name (string): Token name
17
+ * - symbol (string): Token symbol
18
+ * - initialSupply (uint256): Initial token supply (Integer number)
19
+ * - domainName (string): EIP-712 domain name
20
+ * - domainVersion (string): EIP-712 domain version
21
+ *
22
+ * Example:
23
+ * contract MyToken is ERC20xTransferWithAuthorize {
24
+ * constructor()
25
+ * ERC20xTransferWithAuthorize(
26
+ * "MyToken",
27
+ * "MTK",
28
+ * 1000000, // 1 million tokens
29
+ * "MyToken",
30
+ * "1"
31
+ * )
32
+ * {}
33
+ * }
34
+ */
12
35
  abstract contract ERC20xTransferWithAuthorize is ERC20, TransferAuthorize, ReentrancyGuard, Ownable {
13
36
  constructor(
14
37
  string memory name,
@@ -0,0 +1,41 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
6
+ import "@openzeppelin/contracts/access/Ownable.sol";
7
+
8
+ /**
9
+ * @title KitxERC20 (Kit)
10
+ * @notice Fast ERC20 foundation with burnable and ownable features for rapid token creation.
11
+ * @dev Inherit to quickly deploy a custom ERC20 token with burn and ownership control.
12
+ * Set name, symbol, and initial supply via constructor. Mints all supply to deployer.
13
+ *
14
+ * Arguments:
15
+ * - name (string): Token name
16
+ * - symbol (string): Token symbol
17
+ * - initialSupply (uint256): Initial token supply (Integer number)
18
+ *
19
+ * Example:
20
+ * contract MyToken is KitxERC20 {
21
+ * constructor()
22
+ * KitxERC20(
23
+ * "MyToken",
24
+ * "MTK",
25
+ * 1000000 // 1 million tokens
26
+ * )
27
+ * {}
28
+ * }
29
+ */
30
+ abstract contract KitxERC20 is ERC20, ERC20Burnable, Ownable {
31
+ constructor(
32
+ string memory name,
33
+ string memory symbol,
34
+ uint256 initialSupply
35
+ )
36
+ ERC20(name, symbol)
37
+ Ownable(msg.sender)
38
+ {
39
+ _mint(msg.sender, initialSupply * 10 ** decimals());
40
+ }
41
+ }
@@ -0,0 +1,83 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import "../TransferAuthorize.sol";
6
+ import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
7
+
8
+ /**
9
+ * @title ERC20xTransferWithAuthorize (Modular)
10
+ * @notice ERC20 extension for modular, off-chain authorized transfers and burns (EIP-712).
11
+ * @dev Adds `transferWithAuthorize` and `burnWithAuthorize` for meta-transactions and relayer support.
12
+ * Enables gasless transfers and advanced flows using signatures. Integrates OpenZeppelin ERC20 and ReentrancyGuard.
13
+ *
14
+ * Arguments:
15
+ * - domainName (string): EIP-712 domain name
16
+ * - domainVersion (string): EIP-712 domain version
17
+ *
18
+ * Example:
19
+ * contract MyToken is ERC20xTransferWithAuthorize {
20
+ * constructor()
21
+ * ERC20xTransferWithAuthorize(
22
+ * "MyToken",
23
+ * "1"
24
+ * )
25
+ * {}
26
+ * }
27
+ */
28
+ abstract contract ERC20xTransferWithAuthorize is ERC20, TransferAuthorize, ReentrancyGuard {
29
+ constructor(
30
+ string memory domainName,
31
+ string memory domainVersion
32
+ )
33
+ TransferAuthorize(domainName, domainVersion)
34
+ {}
35
+
36
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
37
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
38
+ function transferWithAuthorize(
39
+ address from,
40
+ address to,
41
+ uint256 value,
42
+ uint256 createTime,
43
+ uint256 expireTime,
44
+ bytes32 nonce,
45
+ bytes calldata auth
46
+ ) external override nonReentrant {
47
+ address signer = _verifyTransfer(
48
+ from,
49
+ to,
50
+ value,
51
+ createTime,
52
+ expireTime,
53
+ nonce,
54
+ auth
55
+ );
56
+ require(signer == from, "transferWithAuthorize: invalid signature");
57
+ _useAuthorize(from, nonce);
58
+ _transfer(from, to, value);
59
+ }
60
+
61
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
62
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
63
+ function burnWithAuthorize(
64
+ address from,
65
+ uint256 value,
66
+ uint256 createTime,
67
+ uint256 expireTime,
68
+ bytes32 nonce,
69
+ bytes calldata auth
70
+ ) external override nonReentrant {
71
+ address signer = _verifyBurn(
72
+ from,
73
+ value,
74
+ createTime,
75
+ expireTime,
76
+ nonce,
77
+ auth
78
+ );
79
+ require(signer == from, "burnWithAuthorize: invalid signature");
80
+ _useAuthorize(from, nonce);
81
+ _burn(from, value);
82
+ }
83
+ }
@@ -0,0 +1,49 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ /// @title ITransferAuthorize
5
+ /// @notice Interface for EIP-712 based transfer/receive authorizations (signed approvals)
6
+ /// @dev Events and function signatures used by TransferAuthorize/implementations
7
+ interface ITransferAuthorize {
8
+ /// @notice Emitted when an authorization (nonce) has been consumed for an authorizer
9
+ /// @param authorizer the account that signed the authorization
10
+ /// @param nonce unique nonce used by the authorization
11
+ event AuthorizeUsed(address authorizer, bytes32 nonce);
12
+
13
+ /// @notice Emitted when a transfer with authorization is executed
14
+ event TransferWithAuthorize(address sender, address from, address to, uint256 value, uint256 createTime, uint256 expireTime, bytes32 nonce, bytes auth);
15
+
16
+ /// @notice Emitted when a burn with authorization is executed
17
+ event BurnWithAuthorize(address sender, address from, uint256 value, uint256 createTime, uint256 expireTime, bytes32 nonce, bytes auth);
18
+
19
+ /// @notice Returns whether a nonce has been used for a given authorizer
20
+ /// @param authorizer the account that signed the authorization
21
+ /// @param nonce the nonce to check
22
+ /// @return true if the nonce was already used/consumed, false otherwise
23
+ function authorizeState(
24
+ address authorizer,
25
+ bytes32 nonce
26
+ ) external view returns (bool);
27
+
28
+ /// @notice Execute a "transfer with authorization" - typically any relayer may submit
29
+ function transferWithAuthorize(
30
+ address from,
31
+ address to,
32
+ uint256 value,
33
+ uint256 createTime,
34
+ uint256 expireTime,
35
+ bytes32 nonce,
36
+ bytes calldata auth
37
+ ) external;
38
+
39
+ /// @notice Execute a "approve with authorization" - typically any relayer may submit
40
+ function burnWithAuthorize(
41
+ address from,
42
+ // address to,
43
+ uint256 value,
44
+ uint256 validAfter,
45
+ uint256 validBefore,
46
+ bytes32 nonce,
47
+ bytes calldata signature
48
+ ) external;
49
+ }
@@ -0,0 +1,100 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
5
+ import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
6
+ import "./ITransferAuthorize.sol";
7
+
8
+ /// @title TransferAuthorize
9
+ /// @notice Abstract helper implementing EIP-712 verification and nonce tracking for off-chain signed authorizations
10
+ /// @dev Implementations should call `_verify` and `_useAuthorize` before performing state changes
11
+ abstract contract TransferAuthorize is ITransferAuthorize, EIP712 {
12
+ using ECDSA for bytes32;
13
+
14
+ /// @dev mapping to track used nonces per authorizer: authorizer => nonce => used
15
+ mapping(address => mapping(bytes32 => bool)) private _authorizeState;
16
+
17
+ bytes32 public constant TRANSFER_TYPEHASH =
18
+ keccak256("TransferWithAuthorize(address from,address to,uint256 value,uint256 createTime,uint256 expireTime,bytes32 nonce)");
19
+
20
+ bytes32 public constant BURN_TYPEHASH =
21
+ keccak256("BurnWithAuthorize(address from,uint256 value,uint256 createTime,uint256 expireTime,bytes32 nonce)");
22
+
23
+ /// @param name EIP-712 domain name
24
+ /// @param version EIP-712 domain version
25
+ constructor(string memory name, string memory version) EIP712(name, version) {}
26
+
27
+ /// @notice Check whether a nonce has been used for an authorizer
28
+ /// @param authorizer signer address
29
+ /// @param nonce nonce value
30
+ /// @return true if used
31
+ function authorizeState(address authorizer, bytes32 nonce)
32
+ public
33
+ view
34
+ override
35
+ returns (bool)
36
+ {
37
+ return _authorizeState[authorizer][nonce];
38
+ }
39
+
40
+ /// @dev Mark an authorization (authorizer + nonce) as used. Emits AuthorizeUsed.
41
+ /// @param authorizer the signer of the authorization
42
+ /// @param nonce the nonce used in the signed authorization
43
+ function _useAuthorize(address authorizer, bytes32 nonce) internal {
44
+ require(!_authorizeState[authorizer][nonce], "TransferAuthorize: authorization already used");
45
+ _authorizeState[authorizer][nonce] = true;
46
+ emit AuthorizeUsed(authorizer, nonce);
47
+ }
48
+
49
+ /// @dev Verify an EIP-712 typed signature (auth) for TransferWithAuthorize and return the recovered signer
50
+ function _verifyTransfer(
51
+ address from,
52
+ address to,
53
+ uint256 value,
54
+ uint256 createTime,
55
+ uint256 expireTime,
56
+ bytes32 nonce,
57
+ bytes calldata auth
58
+ ) internal returns (address signer) {
59
+ require(block.timestamp >= createTime, "TransferAuthorize: not yet created");
60
+ require(block.timestamp <= expireTime, "TransferAuthorize: not yet expired");
61
+ bytes32 structHash = keccak256(
62
+ abi.encode(
63
+ TRANSFER_TYPEHASH,
64
+ from,
65
+ to,
66
+ value,
67
+ createTime,
68
+ expireTime,
69
+ nonce
70
+ )
71
+ );
72
+ signer = ECDSA.recover(_hashTypedDataV4(structHash), auth);
73
+ emit TransferWithAuthorize(msg.sender, from, to, value, createTime, expireTime, nonce, auth);
74
+ }
75
+
76
+ /// @dev Verify an EIP-712 typed signature (auth) for BurnWithAuthorize and return the recovered signer
77
+ function _verifyBurn(
78
+ address from,
79
+ uint256 value,
80
+ uint256 createTime,
81
+ uint256 expireTime,
82
+ bytes32 nonce,
83
+ bytes calldata auth
84
+ ) internal returns (address signer) {
85
+ require(block.timestamp >= createTime, "TransferAuthorize: not yet valid");
86
+ require(block.timestamp <= expireTime, "TransferAuthorize: expired");
87
+ bytes32 structHash = keccak256(
88
+ abi.encode(
89
+ BURN_TYPEHASH,
90
+ from,
91
+ value,
92
+ createTime,
93
+ expireTime,
94
+ nonce
95
+ )
96
+ );
97
+ signer = ECDSA.recover(_hashTypedDataV4(structHash), auth);
98
+ emit BurnWithAuthorize(msg.sender, from, value, createTime, expireTime, nonce, auth);
99
+ }
100
+ }
@@ -0,0 +1,74 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import "../TransferAuthorize.sol";
6
+ import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
7
+ import "@openzeppelin/contracts/access/Ownable.sol";
8
+
9
+ /// @title ERC20xTransferWithAuthorize
10
+ /// @notice ERC20 extension that supports EIP-712 based `transferWithAuthorize` and `receiveWithAuthorize` flows
11
+ /// @dev `receiveWithAuthorize` restricts the caller to the `to` address (recipient submits the proof). `transferWithAuthorize` is open to relayers.
12
+ abstract contract ERC20xTransferWithAuthorize is ERC20, TransferAuthorize, ReentrancyGuard, Ownable {
13
+ constructor(
14
+ string memory name,
15
+ string memory symbol,
16
+ uint256 initialSupply,
17
+ string memory domainName,
18
+ string memory domainVersion
19
+ )
20
+ ERC20(name, symbol)
21
+ TransferAuthorize(domainName, domainVersion)
22
+ Ownable(msg.sender)
23
+ {
24
+ _mint(msg.sender, initialSupply * 10 ** decimals());
25
+ }
26
+
27
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
28
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
29
+ function transferWithAuthorize(
30
+ address from,
31
+ address to,
32
+ uint256 value,
33
+ uint256 createTime,
34
+ uint256 expireTime,
35
+ bytes32 nonce,
36
+ bytes calldata auth
37
+ ) external override nonReentrant {
38
+ address signer = _verifyTransfer(
39
+ from,
40
+ to,
41
+ value,
42
+ createTime,
43
+ expireTime,
44
+ nonce,
45
+ auth
46
+ );
47
+ require(signer == from, "transferWithAuthorize: invalid signature");
48
+ _useAuthorize(from, nonce);
49
+ _transfer(from, to, value);
50
+ }
51
+
52
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
53
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
54
+ function burnWithAuthorize(
55
+ address from,
56
+ uint256 value,
57
+ uint256 createTime,
58
+ uint256 expireTime,
59
+ bytes32 nonce,
60
+ bytes calldata auth
61
+ ) external override nonReentrant {
62
+ address signer = _verifyBurn(
63
+ from,
64
+ value,
65
+ createTime,
66
+ expireTime,
67
+ nonce,
68
+ auth
69
+ );
70
+ require(signer == from, "burnWithAuthorize: invalid signature");
71
+ _useAuthorize(from, nonce);
72
+ _burn(from, value);
73
+ }
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t-isol",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {