-
Notifications
You must be signed in to change notification settings - Fork 984
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
Resolve contract from ens name #11055
Conversation
Jenkins BuildsClick to see older builds (14)
|
@Ferossgp @Serhy Adding expected behavior here as guidance for testing Expected behaviorWhen ENS name in backend service is empty:
|
Check ahead of release 1.6 which is to include advertiser flow for referral program only (based on new contract) plus only high-prio fixes that would otherwise go into a Does this PR include any dependencies on |
If we want that behavior then it means the feature should be toggle from backend, ENS can be used as a kill switch to all program cc @andremedeiros |
{::json-rpc/eth-call [{:contract contract | ||
:method "getDefaultPack()" | ||
:outputs ["address" "uint256" "address[]" "uint256[]" "uint256[]"] | ||
:on-success #(re-frame/dispatch [::starter-pack-amount (vec %) (prn %)])}]}) | ||
|
||
(re-frame/reg-sub-raw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please elaborate on this? why would you want to have raw subs and dispatch from them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice approach to use just subscription for external data, this way we do not need to trigger events on some actions but they will be triggered when the data is requested by the subscription. There is a similar example in the docs https://github.com/day8/re-frame/blob/master/docs/Subscribing-To-External-Data.md#some-code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure i understand the reason why you can't dispatch event in the place where you set value in app-db ? i mean the cool thing about re-frame its simple, and predictable, this one just looks like can be done in "regular" way but just adds one more case for devs to know an remember , not sure if it worth it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for me it looks like unpredictable thing, i don't expect that event will be dispatched when i use subscription, instead i'll be looking to component-will-mount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably if we really want to use this approach at least we could give a names for such subscriptions, like ::get-starter-pack-and-dispatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's described in re-frame documentation, so it is correct in terms of the re-frame flow. The problem with the dispatching event is that we show it in 3 places, and we need then to dispatch it every time before showing any of these screens. Also as a user of API, you should no care from where this data is resolved. Mostly you will look at this subscription as "give me the starter pack" and the subscription will give you the value. The underline implementation makes sense only if you want to change it. But as this event doesn't involve data mutation it can be interpreted as a pure pulling of data.
Dispatch actually is not needed here at all, I can call the fx directly, the dispatch call is here because firstly it was implemented with dispatch during navigation to the invite screen, then refactored to raw when it became needed in other places. So I think I can remove the dispatch by replacing it with the fx call directly, and keep the name as it is.
@@ -248,7 +247,7 @@ | |||
(i18n/label :t/invite-reward {:value (str (get reward :eth-amount) " ETH")})]])]]))) | |||
|
|||
(defn list-item [{:keys [accessibility-label]}] | |||
(if-not config/referrals-invite-enabled? | |||
(if-not @(re-frame/subscribe [::events/enabled]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
events looks too general, probably ::invite.events
could work better
(fn [] | ||
(get-in @db [:acquisition :starter-pack :pack])))))) | ||
|
||
(re-frame/reg-sub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still don't have a decision on moving subs from subs.cljs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I wanted to keep the referral program code fully isolated from the app, as we do not know how it will evolve later, and how much time it will be there.
{::json-rpc/eth-call [{:contract contract | ||
:method "getDefaultPack()" | ||
:outputs ["address" "uint256" "address[]" "uint256[]" "uint256[]"] | ||
:on-success #(re-frame/dispatch [::starter-pack-amount (vec %) (prn %)])}]}) | ||
|
||
(re-frame/reg-sub-raw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure i understand the reason why you can't dispatch event in the place where you set value in app-db ? i mean the cool thing about re-frame its simple, and predictable, this one just looks like can be done in "regular" way but just adds one more case for devs to know an remember , not sure if it worth it
{::json-rpc/eth-call [{:contract contract | ||
:method "getDefaultPack()" | ||
:outputs ["address" "uint256" "address[]" "uint256[]" "uint256[]"] | ||
:on-success #(re-frame/dispatch [::starter-pack-amount (vec %) (prn %)])}]}) | ||
|
||
(re-frame/reg-sub-raw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for me it looks like unpredictable thing, i don't expect that event will be dispatched when i use subscription, instead i'll be looking to component-will-mount
{::json-rpc/eth-call [{:contract contract | ||
:method "getDefaultPack()" | ||
:outputs ["address" "uint256" "address[]" "uint256[]" "uint256[]"] | ||
:on-success #(re-frame/dispatch [::starter-pack-amount (vec %) (prn %)])}]}) | ||
|
||
(re-frame/reg-sub-raw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably if we really want to use this approach at least we could give a names for such subscriptions, like ::get-starter-pack-and-dispatch
1% of end-end tests have passed
Failed tests (96)Click to expand
Passed tests (1) |
67a6a83
to
40f6e9a
Compare
Thanks you, @Ferossgp |
Do not show referrals if contract is not available Do not check contract for referral accept Rename invite event namespace require Remove dispatch from raw subs Do nothing if there is no contract Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
40f6e9a
to
c644ab3
Compare
Use ENS name for the acquisition contract. So it can be switched or removed dynamically without store release. Also checks for referrals after login, as the network is not available before and we cannot fetch the ens name