Skip to content

Commit 5a1120c

Browse files
committed
renaming of ETH to gas token
1 parent fa2b171 commit 5a1120c

11 files changed

Lines changed: 136 additions & 128 deletions

File tree

.github/agents/cnf-token-auditor.agent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Focus: nonce consumption, signature domain separation, validity windows, receive
9494
Focus: hashing `bytes value` in typed data, nonce consumption before CTX finality, encrypted vs plaintext authorization differences, relayer and payee griefing.
9595

9696
### Phase 4 — ConfidentialToken external/public surface
97-
`receive`, `burn`, `onDecrypt`, `encryptedTransfer`, `encryptedTransferFrom`, `requestDecryptHistoricTransfer`, `requestDecryptHistoricTransferFor`, `removeHistoricViewAuth`, `removeHistoricViewTimeRange`, `removeHistoricViewTransferId`, `authorizeHistoricViewTimeRange`, `authorizeHistoricViewTransferId`, `setViewerPublicKey`, `setCallbackFee`, `setSubmitCTXAddress`, `setEncryptECIESAddress`, `setEncryptTEAddress`, `withdraw`, `encryptedBalanceOf`, `ethBalanceOf`, `canDecryptHistoricTransfer`, `deposit`, `transferFrom`, `registerPublicKey`, `setViewerAddress`, `totalSupply`, `balanceOf`
97+
`receive`, `burn`, `onDecrypt`, `encryptedTransfer`, `encryptedTransferFrom`, `requestDecryptHistoricTransfer`, `requestDecryptHistoricTransferFor`, `removeHistoricViewAuth`, `removeHistoricViewTimeRange`, `removeHistoricViewTransferId`, `authorizeHistoricViewTimeRange`, `authorizeHistoricViewTransferId`, `setViewerPublicKey`, `setCallbackFee`, `setSubmitCTXAddress`, `setEncryptECIESAddress`, `setEncryptTEAddress`, `withdraw`, `encryptedBalanceOf`, `gasTokenBalanceOf`, `canDecryptHistoricTransfer`, `deposit`, `transferFrom`, `registerPublicKey`, `setViewerAddress`, `totalSupply`, `balanceOf`
9898

9999
Also trace inherited entry points: `transfer`, `approve`, `allowance`, `increaseAllowance`/`decreaseAllowance`, `permit`, `nonces`, `DOMAIN_SEPARATOR`, ERC20 metadata.
100100

@@ -123,7 +123,7 @@ Focus: 1:1 backing, `requestedMints`, failed mint callback recovery, withdrawal
123123

124124
**Input patterns:** zero address, self-transfer, zero amount, max amount, amount exceeding balance, valid TE ciphertext, malformed ciphertext length, empty decrypted value, malformed plaintext arguments, stale encrypted balances, missing public key, viewer key changed between submission and callback, historic auth revoked between submission and callback, expired/not-yet-valid authorization, reused nonce.
125125

126-
**State patterns:** no ETH deposited for callback fees, exact fee deposited, fee changed before next operation, multiple concurrent CTXs for same account, multiple concurrent CTXs for both accounts involved in transfer, account changed after CTX submission, callback succeeds, callback reverts, callback sender attempts replay, underlying token transfer succeeds, underlying token transfer fails.
126+
**State patterns:** no gas token deposited for callback fees, exact fee deposited, fee changed before next operation, multiple concurrent CTXs for same account, multiple concurrent CTXs for both accounts involved in transfer, account changed after CTX submission, callback succeeds, callback reverts, callback sender attempts replay, underlying token transfer succeeds, underlying token transfer fails.
127127

128128
**Inheritance patterns:** direct call, call through inherited ERC20, call through ERC20Permit allowance path, call through EIP3009 signed path, call through wrapper override.
129129

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The main contract implementing the confidential token functionality. It extends
5252
- `encryptedTransfer(to, value)`: Transfer tokens using an encrypted value (bytes)
5353
- `encryptedTransferFrom(from, to, value)`: Transfer tokens on behalf of another using an encrypted value (bytes)
5454
- `encryptedBalanceOf(holder)`: Get the encrypted balance representation (must be decrypted off-chain)
55-
- `ethBalanceOf(holder)`: Get the gas token balance for callback funding
55+
- `gasTokenBalanceOf(holder)`: Get the gas token balance for callback funding
5656

5757
**Historic Transfer Decryption:**
5858

@@ -62,7 +62,7 @@ Additionally, if the recipient has a registered public key at the time of transf
6262

6363
For third-party viewers (auditors, accounting tools, delegated observers), holders can grant selective decryption access to their own transfers:
6464

65-
- `requestDecryptHistoricTransfer(encryptedTransferData)`: Submit a TE-encrypted transfer payload for decryption. Requires the caller to be a registered user and have sufficient ETH balance for the callback fee. On successful callback, emits a `ReEncryptedTransfer` event with the value ECIES-encrypted for the requester's public key. The fee is charged even if the requester turns out not to be authorized — authorization is only checked inside the callback.
65+
- `requestDecryptHistoricTransfer(encryptedTransferData)`: Submit a TE-encrypted transfer payload for decryption. Requires the caller to be a registered user and have sufficient gas token balance for the callback fee. On successful callback, emits a `ReEncryptedTransfer` event with the value ECIES-encrypted for the requester's public key. The fee is charged even if the requester turns out not to be authorized — authorization is only checked inside the callback.
6666
- `requestDecryptHistoricTransferFor(encryptedTransferData, historicViewer)`: Submit a TE-encrypted transfer payload for decryption on behalf of another registered viewer. Callback fee is charged from the caller (`msg.sender`), while successful callback emits `ReEncryptedTransfer` encrypted for `historicViewer`.
6767
- `authorizeHistoricViewTimeRange(viewer, fromTimestamp, toTimestamp)`: Grant a viewer decryption access to all transfers whose timestamp falls within `[fromTimestamp, toTimestamp)` (inclusive of `fromTimestamp`, exclusive of `toTimestamp`). To revoke this time-range access, call `removeHistoricViewTimeRange(viewer)`; to revoke all historic-view permissions for the viewer, call `removeHistoricViewAuth(viewer)`. Emits `HistoricViewTimeRangeAuthorized`.
6868
- `authorizeHistoricViewTransferId(viewer, transferId)`: Grant a viewer access to one specific transfer by its on-chain ID. The transfer ID must already exist. Emits `HistoricViewTransferIdAuthorized`.

contracts/ConfidentialToken.sol

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
5959
uint8 private constant _TRANSFER_ACTION = 0;
6060
uint8 private constant _HISTORIC_VIEW_ACTION = 1;
6161

62-
/// @notice Specifies number of ETH to be sent to pay for callback execution
62+
/// @notice Specifies amount of gas token to be sent to pay for callback execution
6363
uint256 public callbackFee = 1_000 gwei;
6464

6565
/// @notice Address of the EncryptECIES precompiled contract
@@ -90,7 +90,7 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
9090
/// @notice Encrypted with User's Public Key (U_Key) - Used for local viewing
9191
mapping(address holder => bytes encryptedBalance) private _userBalances;
9292

93-
mapping(address holder => uint256 eth) private _ethBalance;
93+
mapping(address holder => uint256 gasToken) private _gasTokenBalance;
9494

9595
mapping(address holder => uint256 blockNumber) private _lastChanged;
9696

@@ -107,7 +107,7 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
107107
error AccessViolation();
108108
error ActionNotRecognized();
109109
error InsufficientBalance();
110-
error InsufficientEth(uint256 required, uint256 available);
110+
error InsufficientGasToken(uint256 required, uint256 available);
111111
error InvalidPublicKey();
112112
error InvalidTransferId(uint256 transferId);
113113
error NoViewerRegisteredForHolder(address holder);
@@ -290,10 +290,14 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
290290
function withdraw(uint256 value, address receiver) external override {
291291
// value is not a constant
292292
// so no ability to save some gas here
293-
// solhint-disable-next-line gas-strict-inequalities
294-
require(_ethBalance[msg.sender] >= value, InsufficientEth(value, _ethBalance[msg.sender]));
295-
_ethBalance[msg.sender] -= value;
296-
emit EthWithdrawn(receiver, value);
293+
// solhint-disable gas-strict-inequalities
294+
require(
295+
_gasTokenBalance[msg.sender] >= value,
296+
InsufficientGasToken(value, _gasTokenBalance[msg.sender])
297+
);
298+
// solhint-enable gas-strict-inequalities
299+
_gasTokenBalance[msg.sender] -= value;
300+
emit GasTokenWithdrawn(receiver, value);
297301
payable(receiver).sendValue(value);
298302
}
299303

@@ -304,8 +308,8 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
304308
}
305309

306310
/// @inheritdoc IConfidentialToken
307-
function ethBalanceOf(address holder) external view override returns (uint256 balance) {
308-
return _ethBalance[holder];
311+
function gasTokenBalanceOf(address holder) external view override returns (uint256 balance) {
312+
return _gasTokenBalance[holder];
309313
}
310314

311315
///@inheritdoc IConfidentialToken
@@ -355,8 +359,8 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
355359
function deposit(address receiver) public payable override {
356360
uint256 value = msg.value;
357361
if (value > 0) {
358-
_ethBalance[receiver] += value;
359-
emit EthBalanceToppedUp(msg.sender, receiver, value);
362+
_gasTokenBalance[receiver] += value;
363+
emit GasTokenBalanceToppedUp(msg.sender, receiver, value);
360364
}
361365
}
362366

@@ -784,9 +788,13 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
784788
{
785789
// callbackFee is not a constant
786790
// so no ability to save some gas here
787-
// solhint-disable-next-line gas-strict-inequalities
788-
require(_ethBalance[gasPayer] >= callbackFee, InsufficientEth(callbackFee, _ethBalance[gasPayer]));
789-
_ethBalance[gasPayer] -= callbackFee;
791+
// solhint-disable gas-strict-inequalities
792+
require(
793+
_gasTokenBalance[gasPayer] >= callbackFee,
794+
InsufficientGasToken(callbackFee, _gasTokenBalance[gasPayer])
795+
);
796+
// solhint-enable gas-strict-inequalities
797+
_gasTokenBalance[gasPayer] -= callbackFee;
790798

791799
address payable callback = BITE.submitCTX(
792800
submitCTXAddress,

contracts/interfaces/IConfidentialToken.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ interface IConfidentialToken is IBiteSupplicant {
4242
/// @param callbackSender Address of the CTX sender that triggered the resubmission
4343
event CTXResubmitted(address indexed callbackSender);
4444

45-
/// @notice Emitted when ETH balance is topped up
45+
/// @notice Emitted when gas token balance is topped up
4646
/// @param sender Address of the sender
4747
/// @param receiver Address of the receiver
48-
/// @param value Amount of ETH topped up
49-
event EthBalanceToppedUp(address indexed sender, address indexed receiver, uint256 indexed value);
48+
/// @param value Amount of gas token topped up
49+
event GasTokenBalanceToppedUp(address indexed sender, address indexed receiver, uint256 indexed value);
5050

51-
/// @notice Emitted when ETH is withdrawn
51+
/// @notice Emitted when gas token is withdrawn
5252
/// @param receiver Address of the receiver
53-
/// @param value Amount of ETH withdrawn
54-
event EthWithdrawn(address indexed receiver, uint256 indexed value);
53+
/// @param value Amount of gas token withdrawn
54+
event GasTokenWithdrawn(address indexed receiver, uint256 indexed value);
5555

5656
/// @notice Emitted when tokens (value omitted) are moved from one account (`from`) to another (`to`)
5757
/// @param from Address tokens are moved from
@@ -161,10 +161,10 @@ interface IConfidentialToken is IBiteSupplicant {
161161
/// @param newViewer Address of the new viewer
162162
event ViewerChanged(address indexed holder, address indexed newViewer);
163163

164-
/// @notice Allows the contract to receive ETH to pay for callback execution
164+
/// @notice Allows the contract to receive gas token to pay for callback execution
165165
receive() external payable;
166166

167-
/// @notice Deposits ETH to any holder balance
167+
/// @notice Deposits gas token to any holder balance
168168
/// @param receiver The address of the receiver holder
169169
function deposit(address receiver) external payable;
170170

@@ -183,7 +183,7 @@ interface IConfidentialToken is IBiteSupplicant {
183183
/// @param viewer The address of the viewer
184184
function setViewerAddress(address viewer) external payable;
185185

186-
/// @notice Sets number of ETH to be sent to pay for callback execution
186+
/// @notice Sets amount of gas token to be sent to pay for callback execution
187187
/// @param newFee New callback fee
188188
function setCallbackFee(uint256 newFee) external;
189189

@@ -199,9 +199,9 @@ interface IConfidentialToken is IBiteSupplicant {
199199
/// @param newAddress New address of the SubmitCTX precompiled contract
200200
function setSubmitCTXAddress(address newAddress) external;
201201

202-
/// @notice Withdraws ETH from the caller's balance
203-
/// @param amount Amount of ETH to withdraw
204-
/// @param receiver Address to send the withdrawn ETH to
202+
/// @notice Withdraws gas token from the caller's balance
203+
/// @param amount Amount of gas token to withdraw
204+
/// @param receiver Address to send the withdrawn gas token to
205205
function withdraw(uint256 amount, address receiver) external;
206206

207207
/// @notice Transfers tokens to another holder
@@ -283,8 +283,8 @@ interface IConfidentialToken is IBiteSupplicant {
283283
/// @return encryptedBalance The encrypted balance of the holder
284284
function encryptedBalanceOf(address holder) external view returns (bytes memory encryptedBalance);
285285

286-
/// @notice Gets the ETH balance of a holder
286+
/// @notice Gets the gas token balance of a holder
287287
/// @param holder The address of the holder
288-
/// @return balance The ETH balance of the holder
289-
function ethBalanceOf(address holder) external view returns (uint256 balance);
288+
/// @return balance The gas token balance of the holder
289+
function gasTokenBalanceOf(address holder) external view returns (uint256 balance);
290290
}

docs/ConfidentialToken.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct TransferInfo {
1818

1919
### callbackFee
2020

21-
Specifies number of ETH to be sent to pay for callback execution
21+
Specifies amount of gas token to be sent to pay for callback execution
2222

2323
```solidity
2424
uint256 callbackFee
@@ -92,10 +92,10 @@ error ActionNotRecognized()
9292
error InsufficientBalance()
9393
```
9494

95-
### InsufficientEth
95+
### InsufficientGasToken
9696

9797
```solidity
98-
error InsufficientEth(uint256 required, uint256 available)
98+
error InsufficientGasToken(uint256 required, uint256 available)
9999
```
100100

101101
### InvalidPublicKey
@@ -173,7 +173,7 @@ constructor(string name_, string symbol_, string version_, address initialAuthor
173173

174174
### receive
175175

176-
Allows the contract to receive ETH to pay for callback execution
176+
Allows the contract to receive gas token to pay for callback execution
177177

178178
```solidity
179179
receive() external payable
@@ -367,7 +367,7 @@ function setViewerPublicKey(struct PublicKey publicKey) external payable
367367

368368
### setCallbackFee
369369

370-
Sets number of ETH to be sent to pay for callback execution
370+
Sets amount of gas token to be sent to pay for callback execution
371371

372372
```solidity
373373
function setCallbackFee(uint256 newFee) external
@@ -423,7 +423,7 @@ function setEncryptTEAddress(address newAddress) external
423423

424424
### withdraw
425425

426-
Withdraws ETH from the caller's balance
426+
Withdraws gas token from the caller's balance
427427

428428
```solidity
429429
function withdraw(uint256 value, address receiver) external
@@ -434,7 +434,7 @@ function withdraw(uint256 value, address receiver) external
434434
| Name | Type | Description |
435435
| ---- | ---- | ----------- |
436436
| value | uint256 | |
437-
| receiver | address | Address to send the withdrawn ETH to |
437+
| receiver | address | Address to send the withdrawn gas token to |
438438

439439
### encryptedBalanceOf
440440

@@ -456,12 +456,12 @@ function encryptedBalanceOf(address holder) external view returns (bytes encrypt
456456
| ---- | ---- | ----------- |
457457
| encryptedBalance | bytes | The encrypted balance of the holder |
458458

459-
### ethBalanceOf
459+
### gasTokenBalanceOf
460460

461-
Gets the ETH balance of a holder
461+
Gets the gas token balance of a holder
462462

463463
```solidity
464-
function ethBalanceOf(address holder) external view returns (uint256 balance)
464+
function gasTokenBalanceOf(address holder) external view returns (uint256 balance)
465465
```
466466

467467
#### Parameters
@@ -474,7 +474,7 @@ function ethBalanceOf(address holder) external view returns (uint256 balance)
474474

475475
| Name | Type | Description |
476476
| ---- | ---- | ----------- |
477-
| balance | uint256 | The ETH balance of the holder |
477+
| balance | uint256 | The gas token balance of the holder |
478478

479479
### canDecryptHistoricTransfer
480480

@@ -521,7 +521,7 @@ function requestDecryptHistoricTransferFor(bytes encryptedTransferData, address
521521

522522
### deposit
523523

524-
Deposits ETH to any holder balance
524+
Deposits gas token to any holder balance
525525

526526
```solidity
527527
function deposit(address receiver) public payable

docs/interfaces/IConfidentialToken.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ event CTXResubmitted(address callbackSender)
3232
| ---- | ---- | ----------- |
3333
| callbackSender | address | Address of the CTX sender that triggered the resubmission |
3434

35-
### EthBalanceToppedUp
35+
### GasTokenBalanceToppedUp
3636

37-
Emitted when ETH balance is topped up
37+
Emitted when gas token balance is topped up
3838

3939
```solidity
40-
event EthBalanceToppedUp(address sender, address receiver, uint256 value)
40+
event GasTokenBalanceToppedUp(address sender, address receiver, uint256 value)
4141
```
4242

4343
#### Parameters
@@ -46,22 +46,22 @@ event EthBalanceToppedUp(address sender, address receiver, uint256 value)
4646
| ---- | ---- | ----------- |
4747
| sender | address | Address of the sender |
4848
| receiver | address | Address of the receiver |
49-
| value | uint256 | Amount of ETH topped up |
49+
| value | uint256 | Amount of gas token topped up |
5050

51-
### EthWithdrawn
51+
### GasTokenWithdrawn
5252

53-
Emitted when ETH is withdrawn
53+
Emitted when gas token is withdrawn
5454

5555
```solidity
56-
event EthWithdrawn(address receiver, uint256 value)
56+
event GasTokenWithdrawn(address receiver, uint256 value)
5757
```
5858

5959
#### Parameters
6060

6161
| Name | Type | Description |
6262
| ---- | ---- | ----------- |
6363
| receiver | address | Address of the receiver |
64-
| value | uint256 | Amount of ETH withdrawn |
64+
| value | uint256 | Amount of gas token withdrawn |
6565

6666
### Transfer
6767

@@ -302,15 +302,15 @@ event ViewerChanged(address holder, address newViewer)
302302

303303
### receive
304304

305-
Allows the contract to receive ETH to pay for callback execution
305+
Allows the contract to receive gas token to pay for callback execution
306306

307307
```solidity
308308
receive() external payable
309309
```
310310

311311
### deposit
312312

313-
Deposits ETH to any holder balance
313+
Deposits gas token to any holder balance
314314

315315
```solidity
316316
function deposit(address receiver) external payable
@@ -372,7 +372,7 @@ function setViewerAddress(address viewer) external payable
372372

373373
### setCallbackFee
374374

375-
Sets number of ETH to be sent to pay for callback execution
375+
Sets amount of gas token to be sent to pay for callback execution
376376

377377
```solidity
378378
function setCallbackFee(uint256 newFee) external
@@ -428,7 +428,7 @@ function setSubmitCTXAddress(address newAddress) external
428428

429429
### withdraw
430430

431-
Withdraws ETH from the caller's balance
431+
Withdraws gas token from the caller's balance
432432

433433
```solidity
434434
function withdraw(uint256 amount, address receiver) external
@@ -438,8 +438,8 @@ function withdraw(uint256 amount, address receiver) external
438438

439439
| Name | Type | Description |
440440
| ---- | ---- | ----------- |
441-
| amount | uint256 | Amount of ETH to withdraw |
442-
| receiver | address | Address to send the withdrawn ETH to |
441+
| amount | uint256 | Amount of gas token to withdraw |
442+
| receiver | address | Address to send the withdrawn gas token to |
443443

444444
### encryptedTransfer
445445

@@ -659,12 +659,12 @@ function encryptedBalanceOf(address holder) external view returns (bytes encrypt
659659
| ---- | ---- | ----------- |
660660
| encryptedBalance | bytes | The encrypted balance of the holder |
661661

662-
### ethBalanceOf
662+
### gasTokenBalanceOf
663663

664-
Gets the ETH balance of a holder
664+
Gets the gas token balance of a holder
665665

666666
```solidity
667-
function ethBalanceOf(address holder) external view returns (uint256 balance)
667+
function gasTokenBalanceOf(address holder) external view returns (uint256 balance)
668668
```
669669

670670
#### Parameters
@@ -677,5 +677,5 @@ function ethBalanceOf(address holder) external view returns (uint256 balance)
677677

678678
| Name | Type | Description |
679679
| ---- | ---- | ----------- |
680-
| balance | uint256 | The ETH balance of the holder |
680+
| balance | uint256 | The gas token balance of the holder |
681681

0 commit comments

Comments
 (0)