Skip to content

Commit

Permalink
Merge branch 'main' into improve-confirm-safe-txs
Browse files Browse the repository at this point in the history
  • Loading branch information
ezynda3 authored Mar 3, 2025
2 parents 259d925 + 958cf06 commit 2df798b
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 458 deletions.
39 changes: 34 additions & 5 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,41 @@
}
],
"code-complexity": ["error", 20],
"compiler-version": ["error", "^0.8.17"],
"const-name-snakecase": "off",
"func-name-mixedcase": "off",
"explicit-types": ["error", "explicit"],
"max-states-count": ["error", 15],
"no-empty-blocks": "error",
"no-global-import": "error",
"no-unused-import": "error",
"no-unused-vars": "error",
"one-contract-per-file": "off",
"payable-fallback": "error",
"reason-string": ["error", { "maxLength": 64 }],
"interface-starts-with-i": "error",
"const-name-snakecase": "error",
"constructor-syntax": "error",
"func-visibility": ["error", { "ignoreConstructors": true }],
"not-rely-on-time": "off",
"reason-string": ["warn", { "maxLength": 64 }]
"contract-name-capwords": "error",
"event-name-capwords": "error",
"func-name-mixedcase": "error",
"immutable-vars-naming": ["error", { "immutablesAsConstants": true }],
"use-forbidden-name": "error",
"var-name-mixedcase": "error",
"imports-on-top": "error",
"visibility-modifier-order": "error",
"gas-custom-errors": "error",
"quotes": ["error","double"],
"avoid-call-value": "off",
"avoid-low-level-calls": "off",
"avoid-sha3": "error",
"avoid-suicide": "error",
"avoid-throw": "error",
"avoid-tx-origin": "error",
"check-send-result": "error",
"compiler-version": ["error", "^0.8.17"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"no-inline-assembly": "off",
"not-rely-on-block-hash": "error",
"reentrancy": "error",
"state-visibility": "error"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.6.0",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"solhint": "^3.3.7",
"solhint": "^5.0.5",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.8.14",
"ts-generator": "^0.1.1",
Expand Down Expand Up @@ -110,7 +110,7 @@
],
"*.sol": [
"prettier --write",
"solhint --fix"
"solhint --noPrompt --fix"
]
}
}
3 changes: 3 additions & 0 deletions script/config.example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ COMPILE_ON_STARTUP=false

# if this flag is set to true, diamondCut and registerPeriphery tx will not be proposed to SAFE but executed directly
DEPLOY_NEW_NETWORK_MODE=true

# webhook URL for sending messages to Slack 'dev-sc-general' channel
SLACK_WEBHOOK_SC_GENERAL=
16 changes: 7 additions & 9 deletions script/helperFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3389,33 +3389,31 @@ function compareAddresses() {
return 1
fi
}
function sendMessageToDiscordSmartContractsChannel() {
function sendMessageToSlackSmartContractsChannel() {
# read function arguments into variable
local MESSAGE=$1

if [ -z "$DISCORD_WEBHOOK_DEV_SMARTCONTRACTS" ]; then
if [ -z "$SLACK_WEBHOOK_SC_GENERAL" ]; then
echo ""
warning "Discord webhook URL for dev-smartcontracts is missing. Cannot send log message."
warning "Slack webhook URL for dev-sc-general is missing. Cannot send log message."
echo ""
return 1
fi

echo ""
echoDebug "sending the following message to Discord webhook ('dev-smartcontracts' channel):"
echoDebug "sending the following message to Slack webhook ('dev-sc-general' channel):"
echoDebug "$MESSAGE"
echo ""

# Send the message
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"$MESSAGE\"}" \
$DISCORD_WEBHOOK_DEV_SMARTCONTRACTS
-d "{\"text\": \"$MESSAGE\"}" \
$SLACK_WEBHOOK_SC_GENERAL

echoDebug "Log message sent to Discord"
echoDebug "Log message sent to Slack"

return 0


}

function getUserInfo() {
Expand Down
2 changes: 1 addition & 1 deletion script/tasks/diamondEMERGENCYPause.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function diamondEMERGENCYPause {

# get user info and send message to discord server
local USER_INFO=$(getUserInfo)
sendMessageToDiscordSmartContractsChannel ":warning: an emergency diamond action was just triggered (action: $ACTION, user info: $USER_INFO). Please immediately investigate if this action was not planned. :warning:"
sendMessageToSlackSmartContractsChannel ":warning: an emergency diamond action was just triggered (action: $ACTION, user info: $USER_INFO). Please immediately investigate if this action was not planned. :warning:"

# Initialize return status
local RETURN=0
Expand Down
36 changes: 36 additions & 0 deletions test/solidity/Facets/CalldataVerificationFacet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,42 @@ contract CalldataVerificationFacetTest is TestBase {
assertFalse(badCall);
}

function testRevert_WhenCallToAddressIsTooShort() public {
uint16 ASSET_ID_USDC = 1;
address STARGATE_POOL_USDC = 0xc026395860Db2d07ee33e05fE50ed7bD583189C7;

StargateFacetV2.StargateData memory stargateData = StargateFacetV2
.StargateData({
assetId: ASSET_ID_USDC,
sendParams: IStargate.SendParam({
dstEid: 30150,
to: USER_RECEIVER.addressToBytes32(),
amountLD: defaultUSDCAmount,
minAmountLD: (defaultUSDCAmount * 9e4) / 1e5,
extraOptions: "",
composeMsg: bytes("foobarbytes"),
oftCmd: OftCmdHelper.bus()
}),
fee: IStargate.MessagingFee({ nativeFee: 0, lzTokenFee: 0 }),
refundAddress: payable(USER_REFUND)
});
bytes memory callData = abi.encodeWithSelector(
StargateFacetV2.startBridgeTokensViaStargate.selector,
bridgeData,
stargateData
);

bytes memory invalidCallTo = hex"1234"; // too short (length < 20)

vm.expectRevert("Invalid callTo length; expected at least 20 bytes");

calldataVerificationFacet.validateDestinationCalldata(
callData,
invalidCallTo,
bytes("foobarbytes")
);
}

function test_CanValidateCelerIMDestinationCalldata() public {
CelerIM.CelerIMData memory cimData = CelerIM.CelerIMData({
maxSlippage: 1,
Expand Down
Loading

0 comments on commit 2df798b

Please sign in to comment.