Skip to content

Commit

Permalink
Remove AnyCeloTokenInstance and polish code
Browse files Browse the repository at this point in the history
  • Loading branch information
longnguyencircle committed Jan 31, 2024
1 parent c07f2b1 commit 63c42be
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 37 deletions.
26 changes: 0 additions & 26 deletions @types/AnyFiatTokenCeloInstance.d.ts

This file was deleted.

13 changes: 6 additions & 7 deletions @types/AnyFiatTokenV2Instance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ import {
FiatTokenCeloV22Instance,
} from "./generated";

export interface FiatTokenV22InstanceExtended extends FiatTokenV22Instance {
export interface OverloadedAAFunctions {
permit?: typeof FiatTokenV2Instance.permit;
transferWithAuthorization?: typeof FiatTokenV2Instance.transferWithAuthorization;
receiveWithAuthorization?: typeof FiatTokenV2Instance.receiveWithAuthorization;
cancelAuthorization?: typeof FiatTokenV2Instance.cancelAuthorization;
}

export interface FiatTokenV22InstanceExtended
extends FiatTokenV22Instance,
OverloadedAAFunctions {}
export interface FiatTokenCeloV22InstanceExtended
extends FiatTokenCeloV22Instance {
permit?: typeof FiatTokenV2Instance.permit;
transferWithAuthorization?: typeof FiatTokenV2Instance.transferWithAuthorization;
receiveWithAuthorization?: typeof FiatTokenV2Instance.receiveWithAuthorization;
cancelAuthorization?: typeof FiatTokenV2Instance.cancelAuthorization;
}
extends FiatTokenCeloV22Instance,
OverloadedAAFunctions {}

export type AnyFiatTokenV2Instance =
| FiatTokenV2Instance
Expand Down
12 changes: 9 additions & 3 deletions contracts/v2/celo/FiatTokenCeloV2_2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ contract FiatTokenCeloV2_2 is FiatTokenV2_2, ICeloGasToken {
bytes32
private constant FEE_CALLER_SLOT = 0xdca914aef3e4e19727959ebb1e70b58822e2c7b796d303902adc19513fcb4af5;

/**
* @notice Returns the current fee caller address allowed on `debitGasFees` and `creditGasFees`.
* @dev Though Solidity generates implicit viewers/getters on contract state, because we
* store the fee caller in a custom Keccak256 slot instead of a standard declaration, we
* need an explicit getter for that slot.
*/
function feeCaller() public view returns (address value) {
assembly {
value := sload(FEE_CALLER_SLOT)
Expand All @@ -49,7 +55,7 @@ contract FiatTokenCeloV2_2 is FiatTokenV2_2, ICeloGasToken {
modifier onlyFeeCaller() virtual {
require(
msg.sender == feeCaller(),
"FiatTokenCeloV2_2: Only fee caller can call"
"FiatTokenCeloV2_2: caller is not the fee caller"
);
_;
}
Expand Down Expand Up @@ -116,12 +122,12 @@ contract FiatTokenCeloV2_2 is FiatTokenV2_2, ICeloGasToken {
function creditGasFees(
address from,
address feeRecipient,
// solhint-disable-next-line
// solhint-disable-next-line no-unused-vars
address gatewayFeeRecipient,
address communityFund,
uint256 refund,
uint256 tipTxFee,
// solhint-disable-next-line
// solhint-disable-next-line no-unused-vars
uint256 gatewayFee,
uint256 baseTxFee
)
Expand Down
2 changes: 1 addition & 1 deletion test/v2/celo/FiatTokenCeloV2_2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract("FiatTokenCeloV2_2", (accounts) => {
});

describe("onlyFeeCaller", () => {
const errorMessage = "FiatTokenCeloV2_2: Only fee caller can call";
const errorMessage = "FiatTokenCeloV2_2: caller is not the fee caller";

it("should fail to call debitGasFees when caller is not fee caller", async () => {
await expectRevert(
Expand Down

0 comments on commit 63c42be

Please sign in to comment.