Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bulk-renew): implement add-bulk-renew #278

Open
wants to merge 16 commits into
base: feature/bulk-renew
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
13 changes: 4 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
branches:
- mainnet
- testnet
- 'feature/*'
- 'features/*'
- "feature/*"
- "features/*"
pull_request:
branches:
- mainnet
- testnet
- 'feature/*'
- 'features/*'
- "feature/*"
- "features/*"

env:
FOUNDRY_PROFILE: ci
Expand All @@ -37,11 +37,6 @@ jobs:
- name: Update package with soldeer
run: forge soldeer update

- name: Recursively update dependencies
run: |
chmod +x ./update-deps.sh
./update-deps.sh

- name: Run Forge build
run: |
forge --version
Expand Down
20 changes: 20 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,23 @@ runs = 256
"@fdk" = { version = "0.3.0-beta", url = "https://github.com/axieinfinity/foundry-deployment-kit/archive/refs/tags/v0.3.0-beta.zip" }
TuDo1403 marked this conversation as resolved.
Show resolved Hide resolved
"@pythnetwork-pyth-sdk-solidity" = { version = "2.2.0" }
"@openzeppelin-contracts" = { version = "4.9.3" }

[soldeer]
# whether soldeer manages remappings
remappings_generate = false

# whether soldeer re-generates all remappings when installing, updating or uninstalling deps
remappings_regenerate = false

# whether to suffix the remapping with the version: `name-a.b.c`
remappings_version = true

# a prefix to add to the remappings ("@" would give `@name`)
remappings_prefix = "@"

# where to store the remappings ("txt" for `remappings.txt` or "config" for `foundry.toml`)
# ignored when `soldeer.toml` is used as config (uses `remappings.txt`)
remappings_location = "txt"

# whether to install sub-dependencies or not. If true this wil install the dependencies of dependencies 1 level down.
recursive_deps = true
19 changes: 11 additions & 8 deletions soldeer.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
[[dependencies]]
name = "@fdk"
version = "0.3.0-beta"
source = "https://github.com/axieinfinity/foundry-deployment-kit/archive/refs/tags/v0.3.0-beta.zip"
url = "https://github.com/axieinfinity/foundry-deployment-kit/archive/refs/tags/v0.3.0-beta.zip"
checksum = "aabeda6cc1fe02227d26f3edd86d4af6c91e2167e8b9f1971cc1ea7ce33d34f9"

[[dependencies]]
name = "@pythnetwork-pyth-sdk-solidity"
version = "2.2.0"
source = "https://soldeer-revisions.s3.amazonaws.com/@pythnetwork-pyth-sdk-solidity/2_2_0_15-04-2024_18:50:54_pyth-sdk-solidity.zip"
checksum = "54e3bda3b27467f84c1605722f58e1d2b5a19d6ca3c24840550f1d6cf3bc2231"
integrity = "436f06791b10ed0ce2363d3dde8e520e79376df1b81b00f0787670ad03941661"

[[dependencies]]
name = "@openzeppelin-contracts"
version = "4.9.3"
source = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/4_9_3_22-01-2024_13:13:53_contracts.zip"
url = "https://soldeer-revisions.s3.amazonaws.com/@openzeppelin-contracts/4_9_3_22-01-2024_13:13:53_contracts.zip"
TuDo1403 marked this conversation as resolved.
Show resolved Hide resolved
checksum = "95886307069cf73310b41396c49df51801a73f31f18f62e7d05adfc2031e7725"
integrity = "6daa959732c1bceabda7f2823d1baa097b96509b48db78cb2e3ddd38bd4fd030"

[[dependencies]]
name = "@pythnetwork-pyth-sdk-solidity"
version = "2.2.0"
url = "https://soldeer-revisions.s3.amazonaws.com/@pythnetwork-pyth-sdk-solidity/2_2_0_15-04-2024_18:50:54_pyth-sdk-solidity.zip"
TuDo1403 marked this conversation as resolved.
Show resolved Hide resolved
checksum = "54e3bda3b27467f84c1605722f58e1d2b5a19d6ca3c24840550f1d6cf3bc2231"
integrity = "4a13c0cb110ee72e9f453835fcd63af6f13d5bbf4b102340ed454971d84c40fd"
28 changes: 28 additions & 0 deletions src/RONRegistrarController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,34 @@ contract RONRegistrarController is
_transferRONToTreasury();
}

/**
* @inheritdoc IRONRegistrarController
*/
function bulkRenew(string[] calldata names, uint64[] calldata durations) external payable whenNotPaused nonReentrant {
huyhuynh3103 marked this conversation as resolved.
Show resolved Hide resolved
uint256 length = names.length;
if (length == 0 || length != durations.length) revert InvalidArrayLength();

uint256 id;
uint256 totalPrice;
uint64 expiryTime;

for (uint256 i; i < length; ++i) {
(, uint256 ronPrice) = rentPrice(names[i], durations[i]);

totalPrice += ronPrice;
id = computeId(names[i]);
expiryTime = _rnsUnified.renew(id, durations[i]);

emit NameRenewed(names[i], id, ronPrice, expiryTime);
}

if (msg.value < totalPrice) revert InsufficientValue();
uint256 remainAmount = msg.value - totalPrice;

if (remainAmount != 0) RONTransferHelper.safeTransfer(payable(_msgSender()), remainAmount);
_transferRONToTreasury();
}

/**
* @inheritdoc IRONRegistrarController
*/
Expand Down
13 changes: 13 additions & 0 deletions src/interfaces/IRONRegistrarController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ interface IRONRegistrarController {
error InvalidArrayLength();
/// @dev Thrown when treasury address is set to null
error NullAddress();
/// @dev Thrown when the names is not sorted in ascending order
error InvalidOrderOfNames();
TuDo1403 marked this conversation as resolved.
Show resolved Hide resolved
TuDo1403 marked this conversation as resolved.
Show resolved Hide resolved

/**
* @dev Emitted when the min registration duration is updated.
Expand Down Expand Up @@ -176,6 +178,17 @@ interface IRONRegistrarController {
*/
function renew(string calldata name, uint64 duration) external payable;

/**
* @dev Renew multiple names in a single transaction.
* Requirements:
* - `names` and `durations` arrays must have the same length.
* - The caller must provide enough value to cover the total renewal cost.
* WARNING: The function does not check for duplicate names.
* @param names The array of names to be renewed.
* @param durations The array of durations for the renewal.
*/
function bulkRenew(string[] calldata names, uint64[] calldata durations) external payable;

/**
* @dev Registers a protected name.
*
Expand Down
Loading