Skip to content

Commit

Permalink
fix: userCalled check condition
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s committed May 2, 2024
1 parent 0c5b383 commit d1d3959
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions _deploy/r/demo/gnoswap/common/allow_non_gnoswap_contracts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func MustCallFromAdmin() {
}

func DisallowCallFromUser() {
isOrigin := std.IsOriginCall()
if isOrigin {
prevRealmPath := std.PrevRealm().PkgPath()
if prevRealmPath == "" {
panic("must be called by realm, not user")
}
}
Expand Down
5 changes: 4 additions & 1 deletion router/router.gno
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ func SwapRoute(
_tokenAmountLimit string, // uint256
) (string, string) { // tokneIn, tokenOut
if common.GetLimitCaller() {
std.AssertOriginCall()
isUserCalled := std.PrevRealm().PkgPath() == ""
if !isUserCalled {
panic("[ROUTER] router.gno__SwapRoute() || only user can call this function")
}
}

amountSpecified := i256.MustFromDecimal(_amountSpecified)
Expand Down
5 changes: 4 additions & 1 deletion staker/staker.gno
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ func CreateExternalIncentive(
endTimestamp int64,
) {
if common.GetLimitCaller() {
std.AssertOriginCall()
isUserCalled := std.PrevRealm().PkgPath() == ""
if !isUserCalled {
panic("[STAKER] staker.gno__CreateExternalIncentive() || only user can call this function")
}
}

rewardAmount := u256.MustFromDecimal(_rewardAmount)
Expand Down

0 comments on commit d1d3959

Please sign in to comment.