Skip to content
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

BAT gating for Web3 Brave Talk #1079

Merged
merged 22 commits into from
Jul 19, 2023
Merged

BAT gating for Web3 Brave Talk #1079

merged 22 commits into from
Jul 19, 2023

Conversation

dvdhs
Copy link
Contributor

@dvdhs dvdhs commented Jun 30, 2023

This the PR that (pending sec review) will add the client side code for #943 (BAT gating) for Web3 Brave Talk. This will allow users to select a third (after NFTs and POAPs) option for gating their Web3 Calls in Brave Talk, which will only allow users with non zero BAT balance to join the call. Works as expected on desktop (dev2).

David Suh and others added 10 commits June 18, 2023 23:13
* Use renovate for dependency updates (#1054)

1. Disable dependabot for normal dependency updates. Note the dependabot PRs will need to be manually closed, and the "security" dependabot PRs will continue.

2. Use renovateapp instead.

The renovate configuration included here is based on that from ads-serve, and:

a. waits for updates to have been published for 4 days before raising a PR - this both reduces churn and also avoids the 3 day period where npm-published entries can be "unpublished"
b. combines all minor and patch updates into a single PR

* removed as *[bot] is not accepted by AWS (#1055)

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>

* Update all non-major dependencies

---------

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Co-authored-by: Graham Tackley <gtackley@brave.com>
Co-authored-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Use renovate for dependency updates (#1054)

1. Disable dependabot for normal dependency updates. Note the dependabot PRs will need to be manually closed, and the "security" dependabot PRs will continue.

2. Use renovateapp instead.

The renovate configuration included here is based on that from ads-serve, and:

a. waits for updates to have been published for 4 days before raising a PR - this both reduces churn and also avoids the 3 day period where npm-published entries can be "unpublished"
b. combines all minor and patch updates into a single PR

* removed as *[bot] is not accepted by AWS (#1055)

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>

* Update all non-major dependencies (#1057)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Pin dependencies (#1056)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update all non-major dependencies (#1063)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update Node.js to v18.16.1

---------

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Co-authored-by: Graham Tackley <gtackley@brave.com>
Co-authored-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Copy link
Contributor

@bcaller bcaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.
Part of security review https://github.com/brave/reviews/issues/1328

Comment on lines 155 to 158
header={"Non Zero BAT gating will be applied."}
subhead={
"Only participants with non-zero BAT balance can join the call"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably make these translatable text using useTranslation, see examples such as

{t("subscribe_login_link")}
and other palces.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in newest commit 7512714

Comment on lines 34 to 36
network: string; // Use enum instead?
token: string; //optional
minimum: string; // in wei, e.g. 10e-18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are great, but even better if the code doesn't require a comment.

so something like:

Suggested change
network: string; // Use enum instead?
token: string; //optional
minimum: string; // in wei, e.g. 10e-18
network: "ETH";
token?: string;
minimum: string; // in wei, e.g. 10e-18

(In the example below network is always ETH, but if you supported others then I'd declare this type as e.g. network: "ETH" | "BAT". In typescript this is as good as where you'd need to use an enum in other languages.)

I'd usually suggest putting the units in the variable name where it's unclear what the unit value is (so minimumWEI rather than just minimum) but it looks like in this case this is an external API so you can't change the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in newest commit 7512714

@@ -48,6 +48,10 @@ export function useWeb3CallState(
const [moderatorNFTCollections, setModeratorNFTCollections] = useState<
NFTcollection[]
>([]);
const [minimumParticipantBATBalance, setMinimumParticipantBATBalance] =
useState<string>("1");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above you say minimum is in WEI, but here you set it to 1 which is either a huge amount or a tiny amount if I've understood what WEI means correctly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do setModeratorNFTCollections and setMinimumParticipantBATBalance get called from? If they're only needed for potential future expansion, you do not need to store them in state: hard code the hardcoded values in the json below.

Ideally code should reflect what it is doing now, not what it might do in some point in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in newest commit 7512714. The unit is wei, thus 1 is very small (1e-18) but is sufficient for now since we are just doing non-zero BAT balance at the moment.

src/components/web3/OptionalSettings.tsx Show resolved Hide resolved
Copy link
Collaborator

@tackley tackley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, thanks for taking on board the feedback!

header,
subhead,
loading = false,
children,
Copy link
Contributor

@johnhalbert johnhalbert Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children looks like it's not used - if that's what was intended we should remove it.

@mrose17 mrose17 merged commit 2d814da into main Jul 19, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants