Skip to content

Commit d1d3959

Browse files
committed
fix: userCalled check condition
1 parent 0c5b383 commit d1d3959

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

_deploy/r/demo/gnoswap/common/allow_non_gnoswap_contracts.gno

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func MustCallFromAdmin() {
2727
}
2828

2929
func DisallowCallFromUser() {
30-
isOrigin := std.IsOriginCall()
31-
if isOrigin {
30+
prevRealmPath := std.PrevRealm().PkgPath()
31+
if prevRealmPath == "" {
3232
panic("must be called by realm, not user")
3333
}
3434
}

router/router.gno

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ func SwapRoute(
3838
_tokenAmountLimit string, // uint256
3939
) (string, string) { // tokneIn, tokenOut
4040
if common.GetLimitCaller() {
41-
std.AssertOriginCall()
41+
isUserCalled := std.PrevRealm().PkgPath() == ""
42+
if !isUserCalled {
43+
panic("[ROUTER] router.gno__SwapRoute() || only user can call this function")
44+
}
4245
}
4346

4447
amountSpecified := i256.MustFromDecimal(_amountSpecified)

staker/staker.gno

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ func CreateExternalIncentive(
5757
endTimestamp int64,
5858
) {
5959
if common.GetLimitCaller() {
60-
std.AssertOriginCall()
60+
isUserCalled := std.PrevRealm().PkgPath() == ""
61+
if !isUserCalled {
62+
panic("[STAKER] staker.gno__CreateExternalIncentive() || only user can call this function")
63+
}
6164
}
6265

6366
rewardAmount := u256.MustFromDecimal(_rewardAmount)

0 commit comments

Comments
 (0)