Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 52 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

##############################
# Private Key Configurations #
##############################=
##############################
# The address of the deployer
DEPLOYER_ADDRESS=

# The key to a pre-funded deployer address
DEPLOYER_PRIVATE_KEY=

Expand Down Expand Up @@ -44,20 +47,35 @@ TOKEN_DECIMALS=6
# The address of the FiatTokenProxy's admin.
PROXY_ADMIN_ADDRESS=

# [OPTIONAL] The private key of the proxy admin.
# PROXY_ADMIN_PRIVATE_KEY=

# The address of the FiatToken's owner.
OWNER_ADDRESS=

# [OPTIONAL] The private key of the FiatToken owner.
# OWNER_PRIVATE_KEY=

# The address of the MasterMinter's owner.
MASTER_MINTER_OWNER_ADDRESS=

# [OPTIONAL] The private key of the master minter owner.
# MASTER_MINTER_OWNER_PRIVATE_KEY=

# [OPTIONAL] The address of a deployed MasterMinter contract.
# MASTER_MINTER_CONTRACT_ADDRESS=

# [OPTIONAL] The address of the FiatToken's pauser. Defaults to the owner address.
# PAUSER_ADDRESS=

# [OPTIONAL] The address of the FiatToken's blacklister. Defaults to the owner address.
# BLACKLISTER_ADDRESS=

# [OPTIONAL] The address to which locked funds are sent to. Only applicable for version 2 -> 2.1 upgrades. Defaults to the owner address.
# LOST_AND_FOUND_ADDRESS=
# [OPTIONAL] The private key of the blacklister
# BLACKLISTER_PRIVATE_KEY=

# [OPTIONAL] The address of the FiatToken's rescuer. Defaults to the zero address.
# RESCUER_ADDRESS=

##########################
# Network Configurations #
Expand Down Expand Up @@ -93,8 +111,39 @@ GAS_MULTIPLIER=110
# The file name from which to read the list of addresses to blacklist
BLACKLIST_FILE_NAME=blacklist.remote.json

# The chain id to use for the deployment. Defaults to the network's chain id. Default is 31337 for anvil localnet.
CHAIN_ID=

# [OPTIONAL] The API key to an Etherscan flavor block explorer.
# ETHERSCAN_KEY=

####################################
# Recommended local Configurations #
####################################
# [OPTIONAL] The number of runs the Solidity optimizers should perform. Defaults to 10000000.
# local only suggestion: 200
# OPTIMIZER_RUNS=

# Compilation settings - defaults to true for optimized builds
# local only suggestion: false (less optimization but faster compilation)
# ENABLE_VIA_IR=

# Compilation settings - defaults to true for optimized builds
# local only suggestion: local
# FOUNDRY_PROFILE=


######################################
# Injective Specific Configurations #
######################################
# Account 1 - Policy Admin
# POLICY_ADMIN_INJ=

# Account 2 - Contract Hook Admin
# CONTRACT_HOOK_ADMIN_INJ=

# Account 3 - Role Permissions Admin
# ROLE_PERMISSIONS_ADMIN_INJ=

# Account 4 - Role Managers Admin
# ROLE_MANAGERS_ADMIN_INJ=
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ verification_artifacts/

blacklist.*.json

# Auto-generated protobuf files
scripts/injective/proto/namespace_pb.ts

LICENSE
4 changes: 2 additions & 2 deletions .github/composite-actions/setup-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ runs:
node-version: "20.18.0"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1.5.0
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
version: "v1.2.3"

- name: Update submodules
run: git submodule update --init --recursive
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ jobs:
- grep: "FiatTokenV2:.*"
- grep: "FiatTokenV2_1:.*"
- grep: "FiatTokenV2_2:.*"
- grep: "FiatTokenV1:.*|FiatTokenV1_1:.*|FiatTokenV2:.*|FiatTokenV2_1:.*|FiatTokenV2_2:.*|gas costs"
- grep: "FiatTokenInjectiveV2_2:.*"
- grep: "FiatTokenV1:.*|FiatTokenV1_1:.*|FiatTokenV2:.*|FiatTokenV2_1:.*|FiatTokenV2_2:.*|FiatTokenInjectiveV2_2:.*|gas costs"
invert: true
steps:
- name: Check out repository code
Expand All @@ -87,6 +88,27 @@ jobs:
name: junit-report-${{ hashFiles('report/junit.xml') }}
path: report/junit.xml

run_injective_integration_tests:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Setup CI Environment
uses: ./.github/composite-actions/setup-ci

- name: Compile contracts
run: yarn compile

- name: Start Injective localnet
run: ./scripts/injective/start_network.sh

- name: Run Injective integration tests
run: yarn test:injective

- name: Stop Injective localnet
run: ./scripts/injective/stop_network.sh

scan:
if: github.event_name == 'pull_request'
uses: circlefin/circle-public-github-workflows/.github/workflows/pr-scan.yaml@v1
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ coverage/
coverage.json

blacklist.*.json
minters.json

6 changes: 6 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ pkg:npm/web3-providers-ipc@1.10.1
pkg:npm/web3-providers-ws@1.10.1
pkg:npm/web3-shh@1.10.1
pkg:npm/web3-utils@1.10.1
pkg:npm/google-protobuf
pkg:npm/protobufjs
pkg:npm/bignumber.js
pkg:npm/@pkgjs/parseargs@0.11.0
pkg:npm/@protobuf-ts/runtime@2.11.1
pkg:npm/%40bufbuild/protobuf
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ verification_artifacts/

blacklist.*.json

# Auto-generated protobuf files
scripts/injective/proto/namespace_pb.ts

LICENSE
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.sol",
"options": {
"tabWidth": 4,
"explicitTypes": "always"
"tabWidth": 4
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.6.0"],
"compiler-version": ["error", ">=0.6.0 <=0.8.26"],
"contract-name-camelcase": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"no-empty-blocks": "off",
"no-inline-assembly": "off",
"not-rely-on-time": "off",
Expand Down
18 changes: 11 additions & 7 deletions @types/AnyFiatTokenV2Instance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,29 @@ import { FiatTokenV2Instance } from "./generated/FiatTokenV2";
import { FiatTokenV2_1Instance } from "./generated/FiatTokenV2_1";
import { FiatTokenV2_2Instance } from "./generated/FiatTokenV2_2";
import { FiatTokenCeloV2_2Instance } from "./generated/FiatTokenCeloV2_2";
import { FiatTokenInjectiveV2_2Instance } from "./generated/FiatTokenInjectiveV2_2";

export interface FiatTokenV2_2InstanceExtended extends FiatTokenV2_2Instance {
export interface V2_2ExtendedInterface {
permit?: typeof FiatTokenV2Instance.permit;
transferWithAuthorization?: typeof FiatTokenV2Instance.transferWithAuthorization;
receiveWithAuthorization?: typeof FiatTokenV2Instance.receiveWithAuthorization;
cancelAuthorization?: typeof FiatTokenV2Instance.cancelAuthorization;
}

export interface FiatTokenV2_2InstanceExtended
extends FiatTokenV2_2Instance, V2_2ExtendedInterface {}

export interface FiatTokenCeloV2_2InstanceExtended
extends FiatTokenCeloV2_2Instance {
permit?: typeof FiatTokenV2Instance.permit;
transferWithAuthorization?: typeof FiatTokenV2Instance.transferWithAuthorization;
receiveWithAuthorization?: typeof FiatTokenV2Instance.receiveWithAuthorization;
cancelAuthorization?: typeof FiatTokenV2Instance.cancelAuthorization;
extends FiatTokenCeloV2_2Instance, V2_2ExtendedInterface {
mint: typeof FiatTokenV2Instance.mint;
}

export interface FiatTokenInjectiveV2_2InstanceExtended
extends FiatTokenInjectiveV2_2Instance, V2_2ExtendedInterface {}

export type AnyFiatTokenV2Instance =
| FiatTokenV2Instance
| FiatTokenV2_1Instance
| FiatTokenV2_2InstanceExtended
| FiatTokenCeloV2_2InstanceExtended;
| FiatTokenCeloV2_2InstanceExtended
| FiatTokenInjectiveV2_2InstanceExtended;
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 2.2.0, Injective variant (2026-01-14)

- Add `IBankModule` interface per Injective documentation
- Add `FiatTokenInjectiveV2_2` extending `FiatTokenV2_2` with Injective bank
precompile integration
- Override `initialize()` to set token metadata in the bank module via
`setMetadata(name, symbol, decimals)`
- Override `_balanceOf()` and `totalSupply()` to read from the bank precompile
- Override `_mint()` and `_burn()` to delegate token minting and burning to
the bank precompile
- Override `_transfer()` to delegate token transfer to the bank precompile

## 2.2.0, Flattened variant (2026-01-02)

- Upgraded `FiatTokenV2_2` to solidity version 0.8.24
- Enabled viaIR compiling
- Update OpenZeppelin to v5.4.0
- Removed safeMath
- Now → block.timestamp
- Address.isContract() → address.code.length > 0
- Flattened `FiatTokenV2_2` into a single contract file
- Consolidated all FiatToken functionality from V1, V1.1, V2, V2.1, and V2.2
while maintaining storage layout compatibility for proxy upgrades
- Refactored `mint` and `burn` for better extensibility
- Extracted internal `_mint()` and `_burn()` function to allow derived
contracts to override token minting logic
- Updated initialization interface
- `initialize(InitializeData)` - Single-step initialization for new
deployments
- `initializeV2_2(...)` - Unchanged upgader function
- `initializeNext()` - View-only stub for upgrade compatibility

## 2.2.0, Celo variant (2024-04-08)

- Add `ICeloGasToken` and `IFiatTokenFeeAdapter` per Celo documentation
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ by the [Hardhat](https://hardhat.org/) framework.
- [Blacklist](#blacklist)
- [Minting/Burning](#mintingburning)
- [Ownable](#ownable)
- [Bridge USDC Standard](#bridge-usdc-standard)
- [Additional Documentations](#additional-documentations)
- [Solidity 0.8 upgrade impact on compiling speed](#solidity-08-upgrade-impact-on-compiling-speed)

## Setup

Expand Down Expand Up @@ -59,7 +61,7 @@ We recommend using VSCode for the project here with these
Types are automatically generated as a part of contract compilation:

```sh
$ yarn compile
$ yarn compile:fast
```

To generate typing without re-compiling, run
Expand Down Expand Up @@ -117,6 +119,15 @@ To check the size of contracts in the repo, run the following command.
$ yarn contract-size # Ignores tests
```

The above commands use hardhat for testing. Hardhat is only used for testing
.js/ts files. To test .t.sol files we need to use the following forge command.

```sh
$ forge test [-vvvv]
```

Adjust the number of v's to increase the verbosity of test logs.

## Deployment

1. Create a copy of the file `.env.example`, and name it `.env`. Fill in
Expand Down Expand Up @@ -227,3 +238,18 @@ guide rather than the general README.
- [Preparing an upgrade](./doc/upgrade.md)
- [Upgrading from v2.1 to v2.2](./doc/v2.2_upgrade.md)
- [Celo FiatToken extension](./doc/celo.md)
- [Injective FiatToken extension](./doc/injective.md)

## Solidity 0.8 upgrade impact on compiling speed

The Solidity 0.8 upgrade introduced the `viaIR` (Intermediate Representation)
compilation option, which significantly reduces contract size through advanced
optimizations. However, this comes at the cost of much slower compilation times
during local development.

It is suggested to use `yarn compile:fast` locally to disable the viaIR and to
speed up the compile. Production/github CI workflow should continue to use the
`viaIR=true` option.

Refer to the `Recommended local Configurations` on `.env.example` for
recommended configs on local environments.
10 changes: 5 additions & 5 deletions contracts/interface/IERC1271.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

pragma solidity 0.6.12;
pragma solidity 0.8.24;

/**
* @dev Interface of the ERC1271 standard signature validation method for
Expand All @@ -29,8 +29,8 @@ interface IERC1271 {
* @param signature Signature byte array associated with the provided data hash
* @return magicValue bytes4 magic value 0x1626ba7e when function passes
*/
function isValidSignature(bytes32 hash, bytes memory signature)
external
view
returns (bytes4 magicValue);
function isValidSignature(
bytes32 hash,
bytes memory signature
) external view returns (bytes4 magicValue);
}
2 changes: 1 addition & 1 deletion contracts/interface/celo/ICeloGasToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

pragma solidity 0.6.12;
pragma solidity 0.8.24;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/interface/celo/IDecimals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

pragma solidity 0.6.12;
pragma solidity 0.8.24;

/**
* @dev Interface for a contract, namely a currency token, that
Expand Down
2 changes: 1 addition & 1 deletion contracts/interface/celo/IFiatTokenFeeAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

pragma solidity 0.6.12;
pragma solidity 0.8.24;

/**
* @dev Barebones interface of the fee currency adapter standard for
Expand Down
Loading
Loading