Skip to content

Commit

Permalink
Abdul sol nft gating (#1077)
Browse files Browse the repository at this point in the history
* 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 (#1059)

* first mockup on dev2

* remove cluttered talk, add request payload

* change permission name from BAT-gating to balance as per spec sheet

* Renovate/all minor patch (#1062)

* 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>

* Update Node.js to v18.16.1

---------

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Co-authored-by: David Suh <davidsuh@Davids-MacBook-Pro.local>
Co-authored-by: David Suh <suhdavid11@gmail.com>
Co-authored-by: Marshall T. Rose <mrose17@gmail.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>

* Revert "Update Node.js to v18.16.1 (#1059)"

This reverts commit 0dc1969.

* this is what should have happened (#1070)

* Update dependency react-i18next to v13 (#1060)

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

* Address word-wrap audit warning (#1073)

Addresses: GHSA-j8xg-fqg3-53r7

* reduce impact of web3 dependencies on non-web3 users (#1066)

* dynamically loading ethers library

* syncing package-lock.json with main

* removed short-circuit code

* removed short-circuit code

* fixed dynamic hexilify for solana

* phantom fallback option in solana

---------

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>
Co-authored-by: David Suh <davidsuh@Davids-MacBook-Pro.local>
Co-authored-by: David Suh <suhdavid11@gmail.com>
Co-authored-by: Marshall T. Rose <mrose17@gmail.com>
  • Loading branch information
7 people authored Jun 30, 2023
1 parent ac78170 commit 255e446
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 30 deletions.
12 changes: 11 additions & 1 deletion src/components/web3/SolLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ export const SolLogin: React.FC<Props> = ({
const { t } = useTranslation();

useEffect(() => {
window.braveSolana?.on("!!! accountChanged", () => setNotice(undefined));
try{
window.braveSolana?.on("!!! accountChanged", () => setNotice(undefined));
}catch {
console.warn("!!! Brave Wallet does not exists")
}

try{
window.phantom?.solana.on("!!! accountChanged", () => setNotice(undefined));
}catch {
console.warn("!!! Phantom Wallet does not exists")
}
}, []);

useEffect(() => {
Expand Down
27 changes: 8 additions & 19 deletions src/components/web3/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,15 @@ export const web3Login = async (): Promise<string> => {
};

export const web3LoginSol = async (): Promise<string> => {
let result;

try {
result = await window.braveSolana.connect();
// Code to execute if the connection is successful
} catch (error) {
console.error("!!! Error connecting to braveSolana:", error);

try {
result = await window.solana.connect();
// Code to execute if the connection using solana is successful
} catch (error) {
console.error("!!! Error connecting to solana:", error);
throw new Error("!!! Failed to connect to both braveSolana and solana");
}
try{
const result = await window.braveSolana.connect();
console.log("!!! allAddresses", result);
return result.publicKey.toBase58();
}catch{
const result = await window.phantom.solana.connect();
console.log("!!! allAddresses", result);
return result.publicKey.toBase58();
}

console.log("!!! allAddresses", result);

return result.publicKey.toBase58();
};

export const web3NFTs = async (address: string): Promise<NFT[]> => {
Expand Down
40 changes: 30 additions & 10 deletions src/hooks/use-web3-call-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,36 @@ export function useWeb3CallState(
setWeb3Address(accounts[0], "accountsChanged");
});

window.braveSolana?.on("accountChanged", (account: any) => {
setWeb3Account("SOL");
if (account) {
console.log("!!! SOL accountChanged", account.toBase58());
setWeb3Address(account.toBase58(), "accountsChanged");
} else {
console.log("!!! SOL accountChanged", account);
setWeb3Address(account, "accountsChanged");
}
});
try{
window.braveSolana?.on("accountChanged", (account: any) => {
setWeb3Account("SOL");
if (account) {
console.log("!!! SOL accountChanged", account.toBase58());
setWeb3Address(account.toBase58(), "accountsChanged");
} else {
console.log("!!! SOL accountChanged", account);
setWeb3Address(account, "accountsChanged");
}
});
}catch{
console.warn("!!! Brave Wallet does not exists")
}

try{
window.phantom?.solana.on("accountChanged", (account: any) => {
setWeb3Account("SOL");
console.log(account);
if (account) {
console.log("!!! SOL accountChanged", account.toBase58());
setWeb3Address(account.toBase58(), "accountsChanged");
} else {
console.log("!!! SOL accountChanged", account);
setWeb3Address(account, "accountsChanged");
}
});
}catch {
console.warn("!!! Phantom Wallet does not exists")
}

const joinCall = async (
roomName: string
Expand Down
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ declare function jwt_decode(input: string): any;

interface Window {
braveSolana: any;
phantom: any;
ethereum: any;
chrome?: {
braveRequestAdsEnabled?: () => Promise<boolean>;
Expand Down

0 comments on commit 255e446

Please sign in to comment.