-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add ERC6909 support #447
Merged
Changes from all commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
f9820ed
forge install: erc-6909
jtriley2p b22dc74
migrate 1155 to 6909
jtriley2p ce37af4
rm old 6909
jtriley2p 00f4341
forge install: erc-6909
jtriley2p 3673856
add event arg
jtriley2p d771042
rm old 6909
jtriley2p a6ee17c
forge install: erc-6909
jtriley2p 5309c7f
update test event
jtriley2p 33fdf58
Add gas snaps
zhongeric 56d2d08
squash: support arbitrary calldata on test routers (#361)
saucepoint b67e3f3
Chore: update licenses (#364)
erin-koen 7d3c6ec
Migrate SwapMath tests to foundry (#363)
ewilz ba04e0f
add base hook for tests (#377)
snreynolds 3464902
change natspec to ILockCallback.lockAcquired (#376)
wildmolasses d6f0bb3
feat: update to solidity 0.8.22 (#378)
marktoda 9875e9f
Cache dynamic fee in slot0 (#360)
snreynolds 81e2f1f
Bug: Require different currencies (#380)
hensha256 fad1737
Replace MockERC20 with solmate's MockERC20 (#374)
saucepoint ebaa5d1
Fixing compiler warnings (#386)
hensha256 9a34f3e
fix: add gas snaps for swaps with 1155 as input/output (#383)
zhongeric 0fadf92
Delete Hardhat (#372)
ewilz fbd55b9
feat: use standard forge directory structure (#389)
marktoda a6c8e05
Improve forge tests (#391)
hensha256 33aaf5f
Fix Issue #397: Incorrect Documentation (#399)
sipox11 be80868
feat: move whitepapers to docs dir to cleanup root (#393)
marktoda 2743802
add snapshots to CI with tolerance (#401)
snreynolds 4e2996d
Implement Claims accounting as minimal balance (#379)
zhongeric 68c52a4
fix: whitepaper link (#400)
marktoda f5afe92
Add solc binaries and transient storage lock library (#395)
snreynolds 80a71bf
Updated solc setup and instructions (#406)
hensha256 7a09f10
feat: move JS scripts to subdir and add helper (#405)
marktoda 46e08e8
Set tick spacing range as constants (#369)
hyunchel 4271165
Part 1: Improve forge tests (#407)
hensha256 fb68e18
remove forge snapshot --check (#417)
snreynolds 874115d
feat: update justfile with custom solc (#418)
marktoda 1831ace
Fix typos (#365)
xiaolou86 6b2727d
Update just prep and build (#421)
hensha256 4b8e4e2
fix tests
zhongeric 2ce5840
remove totalsupply
zhongeric 748937c
remove lib
zhongeric c42aba8
remove solmate
zhongeric 1babbb6
forge install: solmate
zhongeric 30d6d7c
Add comment
zhongeric fcb4762
Add solmate 6909 and remove claims
zhongeric e2fef70
feat: add variadic args to justfile (#423)
marktoda 85dfe2f
move up settle and remove solmate
zhongeric b7f97a0
forge install: solmate
zhongeric be0d822
copy erc6909 locally and use _mint and _burn
zhongeric 932376b
forge fmt
zhongeric 482a146
remove lib
zhongeric 42445f2
forge install: solmate
zhongeric 1959c6a
rmeove solmate
zhongeric 8291f76
forge install: solmate
zhongeric 9bef4c7
fix gas snaps
zhongeric ae7c0db
remove unchecked without totalSupply
zhongeric 95a41e9
Lock on initialize (#424)
hensha256 477f1eb
NoOp implementation with flag (#324)
emmaguo13 2929b3c
update testss
zhongeric 88e7d57
rm solmate
zhongeric d3060e1
forge install: solmate
zhongeric 12e504f
Use solmate 6909
zhongeric df5f006
fmt
zhongeric 3cf69de
cache msg sender
zhongeric 0d327b8
Explain different solc options (#429)
hensha256 a319c1e
Access lock (#404)
snreynolds 56a1cd3
Fix broken tests that were using old claims balance format
zhongeric 5df80bc
Add V46909 and reorder params
zhongeric 37b0bd7
Add V46909 and Mock contract for test
zhongeric 3ecbe30
Add revert tests
zhongeric 72b52a3
burnFrom internal
zhongeric d2d9e07
remove old gas snaps and add native tests
zhongeric 22d4964
feat: add lock target (#300)
marktoda 521f381
fix tests and snaps
zhongeric b4764ed
forge fmt
zhongeric fdd52d2
expectEmit() all
zhongeric 9c70e2e
expect emit all
zhongeric 312467e
Prevent ProtocolFeeController from bricking pool initialization on re…
zhongeric 2081ddc
feedback
zhongeric 9e7735e
Add IERC69009, does not compile
zhongeric babc9b0
Revert "Add IERC69009, does not compile"
zhongeric 349b334
added delta overflow checks (#433)
aadams cf6f514
add pool getters (#438)
snreynolds e7db92e
A few cleanup tasks (#437)
hensha256 8aec8c3
Remove hook fees and protocol fee on withdrawal (#432)
hensha256 a669d68
refactor: hooks callsites (#439)
marktoda caa1166
merge conflicts
zhongeric c90b990
fix fialing test
zhongeric 2a719d5
Copy solmate 6909 locally to get interface inheritance
zhongeric c84c919
natspec
zhongeric 5338b3c
expose getters in pool interface
snreynolds 7ffbe50
Use id for mint/burn instead of currency
zhongeric 664209e
forge fmt
zhongeric a4d55c9
Add burnFrom no approval test
zhongeric 4ec5353
feedback
zhongeric 43c6725
feedback
zhongeric 182d500
forge install: ERC-6909
zhongeric 4f1dfd3
remove lib
zhongeric f4fa8f9
Add commit SHA
zhongeric b467fe0
Merge branch 'main' into wip-6909
zhongeric c8c12c8
merge conflicts galore
zhongeric a41cf51
forge install: solmate
zhongeric 3c18ea7
fix conflict
zhongeric a5e42f8
fix libs
zhongeric cf067dc
del
zhongeric db16ded
forge install: openzeppelin-contracts
zhongeric 0dc051f
fix tests from conflcits and gas
zhongeric ee57069
forge fmt
zhongeric 555e234
removed unused file
zhongeric 29bcdd5
fix: faling fuzz tests (#441)
zhongeric 63ded70
fix gas snap
zhongeric 8bb3fa8
Merge branch 'main' into wip-6909
zhongeric b81b9b3
forge test
zhongeric a0beb23
feedback
zhongeric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
323249 | ||
323277 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200141 | ||
200111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200109 | ||
200079 |
2 changes: 1 addition & 1 deletion
2
.forge-snapshots/before swap hook, already cached dynamic fee.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
194300 | ||
194367 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
146667 | ||
146705 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
137771 | ||
137750 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
185216 | ||
185163 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
27033 | ||
27001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
15224 | ||
15223 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
74200 | ||
74274 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
323262 | ||
323262 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200100 | ||
200100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200042 | ||
200042 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
255129 | ||
255189 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
58013 | ||
58076 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
38699 | ||
38667 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
23823 | ||
25102 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
106962 | ||
106952 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
208322 | ||
208312 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
204612 | ||
204602 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
195638 | ||
195676 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
204206 | ||
204244 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
173543 | ||
174149 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
172131 | ||
172798 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
126266 | ||
126304 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
113757 | ||
113795 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
133995 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
132930 | ||
132930 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
129926 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
198205 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
215075 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
216399 | ||
216399 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
193401 | ||
193468 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
113735 | ||
113773 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
51304 | ||
51425 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
200144 | ||
200232 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule forge-std
updated
11 files
+1 −1 | package.json | |
+11 −3 | src/StdChains.sol | |
+2 −2 | src/StdCheats.sol | |
+61 −33 | src/StdUtils.sol | |
+106 −1 | src/Vm.sol | |
+216 −0 | src/mocks/MockERC20.sol | |
+221 −0 | src/mocks/MockERC721.sol | |
+2 −6 | test/StdChains.t.sol | |
+2 −2 | test/Vm.t.sol | |
+441 −0 | test/mocks/MockERC20.t.sol | |
+721 −0 | test/mocks/MockERC721.t.sol |
Submodule solmate
updated
14 files
+211 −181 | .gas-snapshot | |
+1 −0 | README.md | |
+1 −1 | package-lock.json | |
+1 −1 | package.json | |
+26 −1 | src/test/CREATE3.t.sol | |
+378 −0 | src/test/ERC6909.t.sol | |
+1 −2 | src/test/SafeCastLib.t.sol | |
+14 −0 | src/test/SignedWadMath.t.sol | |
+22 −0 | src/test/utils/mocks/MockERC6909.sol | |
+118 −0 | src/tokens/ERC6909.sol | |
+5 −1 | src/utils/CREATE3.sol | |
+1 −1 | src/utils/SafeCastLib.sol | |
+7 −7 | src/utils/SafeTransferLib.sol | |
+12 −2 | src/utils/SignedWadMath.sol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
import {IERC6909Claims} from "./interfaces/external/IERC6909Claims.sol"; | ||
|
||
/// @notice Minimalist and gas efficient standard ERC6909 implementation. | ||
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC6909.sol) | ||
/// @dev Copied from the commit at 4b47a19038b798b4a33d9749d25e570443520647 | ||
/// @dev This contract has been modified from the implementation at the above link. | ||
abstract contract ERC6909 is IERC6909Claims { | ||
/*////////////////////////////////////////////////////////////// | ||
EVENTS | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
event OperatorSet(address indexed owner, address indexed operator, bool approved); | ||
|
||
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount); | ||
|
||
event Transfer(address caller, address indexed from, address indexed to, uint256 indexed id, uint256 amount); | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
ERC6909 STORAGE | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
mapping(address => mapping(address => bool)) public isOperator; | ||
|
||
mapping(address => mapping(uint256 => uint256)) public balanceOf; | ||
|
||
mapping(address => mapping(address => mapping(uint256 => uint256))) public allowance; | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
ERC6909 LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
function transfer(address receiver, uint256 id, uint256 amount) public virtual returns (bool) { | ||
balanceOf[msg.sender][id] -= amount; | ||
|
||
balanceOf[receiver][id] += amount; | ||
|
||
emit Transfer(msg.sender, msg.sender, receiver, id, amount); | ||
|
||
return true; | ||
} | ||
|
||
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) public virtual returns (bool) { | ||
if (msg.sender != sender && !isOperator[sender][msg.sender]) { | ||
uint256 allowed = allowance[sender][msg.sender][id]; | ||
if (allowed != type(uint256).max) allowance[sender][msg.sender][id] = allowed - amount; | ||
} | ||
|
||
balanceOf[sender][id] -= amount; | ||
|
||
balanceOf[receiver][id] += amount; | ||
|
||
emit Transfer(msg.sender, sender, receiver, id, amount); | ||
|
||
return true; | ||
} | ||
|
||
function approve(address spender, uint256 id, uint256 amount) public virtual returns (bool) { | ||
allowance[msg.sender][spender][id] = amount; | ||
|
||
emit Approval(msg.sender, spender, id, amount); | ||
|
||
return true; | ||
} | ||
|
||
function setOperator(address operator, bool approved) public virtual returns (bool) { | ||
isOperator[msg.sender][operator] = approved; | ||
|
||
emit OperatorSet(msg.sender, operator, approved); | ||
|
||
return true; | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
ERC165 LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { | ||
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165 | ||
|| interfaceId == 0x0f632fb3; // ERC165 Interface ID for ERC6909 | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////// | ||
INTERNAL MINT/BURN LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
function _mint(address receiver, uint256 id, uint256 amount) internal virtual { | ||
balanceOf[receiver][id] += amount; | ||
|
||
emit Transfer(msg.sender, address(0), receiver, id, amount); | ||
} | ||
|
||
function _burn(address sender, uint256 id, uint256 amount) internal virtual { | ||
balanceOf[sender][id] -= amount; | ||
|
||
emit Transfer(msg.sender, sender, address(0), id, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
import {ERC6909} from "./ERC6909.sol"; | ||
|
||
/// @notice ERC6909Claims inherits ERC6909 and implements an internal burnFrom function | ||
abstract contract ERC6909Claims is ERC6909 { | ||
/// @notice Burn `amount` tokens of token type `id` from `from`. | ||
/// @dev if sender is not `from` they must be an operator or have sufficient allowance. | ||
/// @param from The address to burn tokens from. | ||
/// @param id The currency to burn. | ||
/// @param amount The amount to burn. | ||
function _burnFrom(address from, uint256 id, uint256 amount) internal { | ||
address sender = msg.sender; | ||
if (from != sender && !isOperator[from][sender]) { | ||
uint256 senderAllowance = allowance[from][sender][id]; | ||
if (senderAllowance != type(uint256).max) { | ||
allowance[from][sender][id] = senderAllowance - amount; | ||
} | ||
} | ||
_burn(from, id, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think its important to note that if from !== msg.sender they must be operator or approved