Skip to content

Commit e17ebd1

Browse files
authored
Change value to amount for consistency (#31)
1 parent 52c9d5f commit e17ebd1

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

contracts/token/ConfidentialFungibleToken.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
3030

3131
mapping(address holder => euint64) private _balances;
3232
mapping(address holder => mapping(address spender => uint48)) private _operators;
33-
mapping(uint256 requestId => euint64 encryptedValue) private _requestHandles;
33+
mapping(uint256 requestId => euint64 encryptedAmount) private _requestHandles;
3434
euint64 private _totalSupply;
3535
string private _name;
3636
string private _symbol;
@@ -49,11 +49,11 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
4949
error ConfidentialFungibleTokenZeroBalance(address holder);
5050

5151
/**
52-
* @dev The caller `user` does not have access to the encrypted value `amount`.
52+
* @dev The caller `user` does not have access to the encrypted amount `amount`.
5353
*
5454
* NOTE: Try using the equivalent transfer function with an input proof.
5555
*/
56-
error ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue(euint64 amount, address user);
56+
error ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(euint64 amount, address user);
5757

5858
/// @dev The given caller `caller` is not authorized for the current operation.
5959
error ConfidentialFungibleTokenUnauthorizedCaller(address caller);
@@ -129,7 +129,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
129129
function confidentialTransfer(address to, euint64 amount) public virtual returns (euint64 transferred) {
130130
require(
131131
amount.isAllowed(msg.sender),
132-
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue(amount, msg.sender)
132+
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, msg.sender)
133133
);
134134
transferred = _transfer(msg.sender, to, amount);
135135
transferred.allowTransient(msg.sender);
@@ -155,7 +155,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
155155
) public virtual returns (euint64 transferred) {
156156
require(
157157
amount.isAllowed(msg.sender),
158-
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue(amount, msg.sender)
158+
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, msg.sender)
159159
);
160160
require(isOperator(from, msg.sender), ConfidentialFungibleTokenUnauthorizedSpender(from, msg.sender));
161161
transferred = _transfer(from, to, amount);
@@ -181,7 +181,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
181181
) public virtual returns (euint64 transferred) {
182182
require(
183183
amount.isAllowed(msg.sender),
184-
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue(amount, msg.sender)
184+
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, msg.sender)
185185
);
186186
transferred = _transferAndCall(msg.sender, to, amount, data);
187187
transferred.allowTransient(msg.sender);
@@ -209,7 +209,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
209209
) public virtual returns (euint64 transferred) {
210210
require(
211211
amount.isAllowed(msg.sender),
212-
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue(amount, msg.sender)
212+
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, msg.sender)
213213
);
214214
require(isOperator(from, msg.sender), ConfidentialFungibleTokenUnauthorizedSpender(from, msg.sender));
215215
transferred = _transferAndCall(from, to, amount, data);
@@ -226,7 +226,7 @@ abstract contract ConfidentialFungibleToken is IConfidentialFungibleToken {
226226
function discloseEncryptedAmount(euint64 encryptedAmount) public virtual {
227227
require(
228228
encryptedAmount.isAllowed(msg.sender) && encryptedAmount.isAllowed(address(this)),
229-
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue(encryptedAmount, msg.sender)
229+
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(encryptedAmount, msg.sender)
230230
);
231231

232232
uint256[] memory cts = new uint256[](1);

contracts/token/extensions/ConfidentialFungibleTokenERC20Wrapper.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,35 @@ abstract contract ConfidentialFungibleTokenERC20Wrapper is ConfidentialFungibleT
7777
function onTransferReceived(
7878
address /*operator*/,
7979
address from,
80-
uint256 value,
80+
uint256 amount,
8181
bytes calldata data
8282
) public virtual returns (bytes4) {
8383
// check caller is the token contract
8484
require(address(underlying()) == msg.sender, ConfidentialFungibleTokenUnauthorizedCaller(msg.sender));
8585

8686
// transfer excess back to the sender
87-
uint256 excess = value % rate();
87+
uint256 excess = amount % rate();
8888
if (excess > 0) SafeERC20.safeTransfer(underlying(), from, excess);
8989

9090
// mint confidential token
9191
address to = data.length < 20 ? from : address(bytes20(data));
92-
_mint(to, (value / rate()).toUint64().asEuint64());
92+
_mint(to, (amount / rate()).toUint64().asEuint64());
9393

9494
// return magic value
9595
return IERC1363Receiver.onTransferReceived.selector;
9696
}
9797

9898
/**
99-
* @dev Wraps value `value` of the underlying token into a confidential token and sends it to
100-
* `to`. Tokens are exchanged at a fixed rate specified by {rate} such that `value / rate()` confidential
99+
* @dev Wraps amount `amount` of the underlying token into a confidential token and sends it to
100+
* `to`. Tokens are exchanged at a fixed rate specified by {rate} such that `amount / rate()` confidential
101101
* tokens are sent. Amount transferred in is rounded down to the nearest multiple of {rate}.
102102
*/
103-
function wrap(address to, uint256 value) public virtual {
103+
function wrap(address to, uint256 amount) public virtual {
104104
// take ownership of the tokens
105-
SafeERC20.safeTransferFrom(underlying(), msg.sender, address(this), value - (value % rate()));
105+
SafeERC20.safeTransferFrom(underlying(), msg.sender, address(this), amount - (amount % rate()));
106106

107107
// mint confidential token
108-
_mint(to, (value / rate()).toUint64().asEuint64());
108+
_mint(to, (amount / rate()).toUint64().asEuint64());
109109
}
110110

111111
/**
@@ -119,7 +119,7 @@ abstract contract ConfidentialFungibleTokenERC20Wrapper is ConfidentialFungibleT
119119
function unwrap(address from, address to, euint64 amount) public virtual {
120120
require(
121121
amount.isAllowed(msg.sender),
122-
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue(amount, msg.sender)
122+
ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount(amount, msg.sender)
123123
);
124124
_unwrap(from, to, amount);
125125
}

contracts/token/utils/ConfidentialFungibleTokenUtils.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ library ConfidentialFungibleTokenUtils {
2323
address operator,
2424
address from,
2525
address to,
26-
euint64 value,
26+
euint64 amount,
2727
bytes calldata data
2828
) internal returns (ebool) {
2929
if (to.code.length > 0) {
3030
try
31-
IConfidentialFungibleTokenReceiver(to).onConfidentialTransferReceived(operator, from, value, data)
31+
IConfidentialFungibleTokenReceiver(to).onConfidentialTransferReceived(operator, from, amount, data)
3232
returns (ebool retval) {
3333
return retval;
3434
} catch (bytes memory reason) {

test/token/ConfidentialFungibleToken.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ describe("ConfidentialFungibleToken", function () {
336336

337337
const recipientBalanceHandle = await this.token.balanceOf(this.recipient);
338338
await expect(callTransfer(this.token, this.holder, this.recipient, recipientBalanceHandle))
339-
.to.be.revertedWithCustomError(this.token, "ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue")
339+
.to.be.revertedWithCustomError(this.token, "ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount")
340340
.withArgs(recipientBalanceHandle, this.holder);
341341
});
342342
});
@@ -501,7 +501,7 @@ describe("ConfidentialFungibleToken", function () {
501501
const holderBalanceHandle = await this.token.balanceOf(this.holder);
502502

503503
await expect(this.token.connect(this.recipient).discloseEncryptedAmount(holderBalanceHandle))
504-
.to.be.revertedWithCustomError(this.token, "ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue")
504+
.to.be.revertedWithCustomError(this.token, "ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount")
505505
.withArgs(holderBalanceHandle, this.recipient);
506506
});
507507

test/token/extensions/ConfidentialFungibleWrapper.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe("ConfidentialFungibleTokenWrapper", function () {
229229
const totalSupplyHandle = await this.wrapper.totalSupply();
230230

231231
await expect(this.wrapper.connect(this.holder).unwrap(this.holder, this.holder, totalSupplyHandle))
232-
.to.be.revertedWithCustomError(this.wrapper, "ConfidentialFungibleTokenUnauthorizedUseOfEncryptedValue")
232+
.to.be.revertedWithCustomError(this.wrapper, "ConfidentialFungibleTokenUnauthorizedUseOfEncryptedAmount")
233233
.withArgs(totalSupplyHandle, this.holder);
234234
});
235235

0 commit comments

Comments
 (0)