Skip to content

Commit

Permalink
support decimals (#12812)
Browse files Browse the repository at this point in the history
* support decimals

* address comments

* use IERC20Metadata
  • Loading branch information
shileiwill committed Apr 18, 2024
1 parent aa57182 commit 5b33a32
Show file tree
Hide file tree
Showing 22 changed files with 335 additions and 167 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-peaches-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

support decimals #added
5 changes: 5 additions & 0 deletions contracts/.changeset/heavy-horses-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts": patch
---

support decimals #added

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC20} from "../../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata as IERC20} from "../../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/extensions/IERC20Metadata.sol";

interface IWrappedNative is IERC20 {
function deposit() external payable;
Expand Down
20 changes: 10 additions & 10 deletions contracts/src/v0.8/automation/dev/test/AutomationRegistrar2_3.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.19;
import {BaseTest} from "./BaseTest.t.sol";
import {IAutomationRegistryMaster2_3} from "../interfaces/v2_3/IAutomationRegistryMaster2_3.sol";
import {AutomationRegistrar2_3} from "../v2_3/AutomationRegistrar2_3.sol";
import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata as IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {AutomationRegistryBase2_3 as AutoBase} from "../v2_3/AutomationRegistryBase2_3.sol";
import {IWrappedNative} from "../interfaces/v2_3/IWrappedNative.sol";

Expand Down Expand Up @@ -51,8 +51,8 @@ contract RegisterUpkeep is SetUp {
function testUSDToken_autoApproveOff_happy() external {
vm.startPrank(UPKEEP_ADMIN);

uint96 amount = uint96(registrar.getMinimumRegistrationAmount(usdToken));
usdToken.approve(address(registrar), amount);
uint96 amount = uint96(registrar.getMinimumRegistrationAmount(usdToken18));
usdToken18.approve(address(registrar), amount);

registrar.registerUpkeep(
AutomationRegistrar2_3.RegistrationParams({
Expand All @@ -61,7 +61,7 @@ contract RegisterUpkeep is SetUp {
adminAddress: UPKEEP_ADMIN,
gasLimit: 10_000,
triggerType: 0,
billingToken: usdToken,
billingToken: usdToken18,
name: "foobar",
encryptedEmail: "",
checkData: bytes("check data"),
Expand All @@ -70,7 +70,7 @@ contract RegisterUpkeep is SetUp {
})
);

assertEq(usdToken.balanceOf(address(registrar)), amount);
assertEq(usdToken18.balanceOf(address(registrar)), amount);
assertEq(registry.getNumUpkeeps(), 0);
}

Expand Down Expand Up @@ -106,8 +106,8 @@ contract RegisterUpkeep is SetUp {
registrar.setTriggerConfig(0, AutomationRegistrar2_3.AutoApproveType.ENABLED_ALL, 1000);

vm.startPrank(UPKEEP_ADMIN);
uint96 amount = uint96(registrar.getMinimumRegistrationAmount(usdToken));
usdToken.approve(address(registrar), amount);
uint96 amount = uint96(registrar.getMinimumRegistrationAmount(usdToken18));
usdToken18.approve(address(registrar), amount);

registrar.registerUpkeep(
AutomationRegistrar2_3.RegistrationParams({
Expand All @@ -116,7 +116,7 @@ contract RegisterUpkeep is SetUp {
adminAddress: UPKEEP_ADMIN,
gasLimit: 10_000,
triggerType: 0,
billingToken: usdToken,
billingToken: usdToken18,
name: "foobar",
encryptedEmail: "",
checkData: bytes("check data"),
Expand All @@ -125,8 +125,8 @@ contract RegisterUpkeep is SetUp {
})
);

assertEq(usdToken.balanceOf(address(registrar)), 0);
assertEq(usdToken.balanceOf(address(registry)), amount);
assertEq(usdToken18.balanceOf(address(registrar)), 0);
assertEq(usdToken18.balanceOf(address(registry)), amount);
assertEq(registry.getNumUpkeeps(), 1);
}

Expand Down
Loading

0 comments on commit 5b33a32

Please sign in to comment.