Skip to content

Commit

Permalink
Merge pull request #69 from aboutcircles/v0.3.7-patch20-calculate-end…
Browse files Browse the repository at this point in the history
…-of-invitation-period-in-deployment-script

(deploy, hub): have deployment script compute bootstrap period durati…
  • Loading branch information
jaensen authored Oct 11, 2024
2 parents e876c26 + a54a65d commit 82602a2
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 8 deletions.
37 changes: 34 additions & 3 deletions script/deployments/chiadoDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,33 @@ V1_HUB_ADDRESS='0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710'
# but like on mainnet we want to offset this to midnight to start day zero
# on the Feb 1 2023, which has unix time 1675209600
INFLATION_DAY_ZERO=1675209600
# put a long bootstrap time for testing bootstrap
BOOTSTRAP_ONE_YEAR=31540000

# Set the bootstrap end date to Nov 15, 2024 23:59:59 UTC
BOOTSTRAP_END_DATE="2024-11-15 23:59:59"

# Function to convert UTC date to seconds since epoch
utc_to_seconds() {
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
date -j -u -f "%Y-%m-%d %H:%M:%S" "$1" "+%s"
else
# GNU/Linux
date -u -d "$1" "+%s"
fi
}

# Calculate the bootstrap period
CURRENT_TIME=$(date -u +"%Y-%m-%d %H:%M:%S")
BOOTSTRAP_END_SECONDS=$(utc_to_seconds "$BOOTSTRAP_END_DATE")
CURRENT_TIME_SECONDS=$(utc_to_seconds "$CURRENT_TIME")
BOOTSTRAP_PERIOD=$((BOOTSTRAP_END_SECONDS - CURRENT_TIME_SECONDS))

# Ensure the bootstrap period is not negative
if [ $BOOTSTRAP_PERIOD -lt 0 ]; then
echo "Error: The specified end date is in the past. Please update the BOOTSTRAP_END_DATE." >&2
exit 1
fi

# fallback URI
URI='https://gateway.aboutcircles.com/v1/circles/{id}.json'

Expand Down Expand Up @@ -133,7 +158,7 @@ HUB=$(deploy_and_store_details "Hub" $HUB_ADDRESS_01 \
--constructor-args $V1_HUB_ADDRESS \
$NAMEREGISTRY_ADDRESS_03 $MIGRATION_ADDRESS_02 $ERC20LIFT_ADDRESS_04 \
$STANDARD_TREASURY_ADDRESS_05 $INFLATION_DAY_ZERO \
$BOOTSTRAP_ONE_YEAR $URI)
$BOOTSTRAP_PERIOD $URI)

MIGRATION=$(deploy_and_store_details "Migration" $MIGRATION_ADDRESS_02 \
src/migration/Migration.sol:Migration \
Expand Down Expand Up @@ -190,4 +215,10 @@ summary_file="${OUT_DIR}/chiado-${identifier}.log"
echo "MastercopyDemurrageERC20: ${MC_ERC20_DEMURRAGE}"
echo "MastercopyInflationaryERC20: ${MC_ERC20_INFLATION}"
echo "MastercopyStandardVault: ${MC_STANDARD_VAULT}"
echo ""
echo "Bootstrap End Date: $BOOTSTRAP_END_DATE UTC"
echo "Current Time: $CURRENT_TIME UTC"
echo "Bootstrap Period: ${BOOTSTRAP_PERIOD} seconds"
echo "Bootstrap End Date (Unix time): $BOOTSTRAP_END_SECONDS"
echo "Current Time (Unix time): $CURRENT_TIME_SECONDS"
} >> "$summary_file"
37 changes: 34 additions & 3 deletions script/deployments/gnosisChainDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,33 @@ V1_HUB_ADDRESS='0x29b9a7fBb8995b2423a71cC17cf9810798F6C543'
# but we want to offset this to midnight to start day zero
# on midnight 15 October 2020
INFLATION_DAY_ZERO=1602720000
# put a long bootstrap time for testing bootstrap to one year
BOOTSTRAP_ONE_YEAR=31540000

# Set the bootstrap end date to Nov 15, 2024 23:59:59 UTC
BOOTSTRAP_END_DATE="2024-11-15 23:59:59"

# Function to convert UTC date to seconds since epoch
utc_to_seconds() {
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
date -j -u -f "%Y-%m-%d %H:%M:%S" "$1" "+%s"
else
# GNU/Linux
date -u -d "$1" "+%s"
fi
}

# Calculate the bootstrap period
CURRENT_TIME=$(date -u +"%Y-%m-%d %H:%M:%S")
BOOTSTRAP_END_SECONDS=$(utc_to_seconds "$BOOTSTRAP_END_DATE")
CURRENT_TIME_SECONDS=$(utc_to_seconds "$CURRENT_TIME")
BOOTSTRAP_PERIOD=$((BOOTSTRAP_END_SECONDS - CURRENT_TIME_SECONDS))

# Ensure the bootstrap period is not negative
if [ $BOOTSTRAP_PERIOD -lt 0 ]; then
echo "Error: The specified end date is in the past. Please update the BOOTSTRAP_END_DATE." >&2
exit 1
fi

# fallback URI
URI='https://gateway.aboutcircles.com/v1/circles/{id}.json'

Expand Down Expand Up @@ -160,7 +185,7 @@ HUB=$(deploy_and_store_details "Hub" $HUB_ADDRESS_01 \
--constructor-args $V1_HUB_ADDRESS \
$NAMEREGISTRY_ADDRESS_03 $MIGRATION_ADDRESS_02 $ERC20LIFT_ADDRESS_04 \
$STANDARD_TREASURY_ADDRESS_05 $INFLATION_DAY_ZERO \
$BOOTSTRAP_ONE_YEAR $URI)
$BOOTSTRAP_PERIOD $URI)

NONCE_USED=$((NONCE_USED + 1))

Expand Down Expand Up @@ -233,4 +258,10 @@ summary_file="${OUT_DIR}/gnosischain-${identifier}.log"
echo "MastercopyDemurrageERC20: ${MC_ERC20_DEMURRAGE}"
echo "MastercopyInflationaryERC20: ${MC_ERC20_INFLATION}"
echo "MastercopyStandardVault: ${MC_STANDARD_VAULT}"
echo ""
echo "Bootstrap End Date: $BOOTSTRAP_END_DATE UTC"
echo "Current Time: $CURRENT_TIME UTC"
echo "Bootstrap Period: ${BOOTSTRAP_PERIOD} seconds"
echo "Bootstrap End Date (Unix time): $BOOTSTRAP_END_SECONDS"
echo "Current Time (Unix time): $CURRENT_TIME_SECONDS"
} >> "$summary_file"
2 changes: 1 addition & 1 deletion script/deployments/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deploy-circles",
"version": "rc-0.3.7-alpha",
"version": "rc-0.3.7-beta",
"type": "module",
"dependencies": {
"dotenv": "^16.4.5",
Expand Down
2 changes: 1 addition & 1 deletion src/hub/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract Hub is Circles, TypeDefinitions, IHubErrors {
* new avatars can be invited by registered avatars. After this time
* only registered avatars can invite new avatars.
*/
uint256 internal immutable invitationOnlyTime;
uint256 public immutable invitationOnlyTime;

/**
* @notice The standard treasury contract address used when
Expand Down

0 comments on commit 82602a2

Please sign in to comment.