Skip to content

Instantly share code, notes, and snippets.

@Ashoat
Created March 12, 2023 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ashoat/53b85cb8dba07873423b0bf0b2a01791 to your computer and use it in GitHub Desktop.
Save Ashoat/53b85cb8dba07873423b0bf0b2a01791 to your computer and use it in GitHub Desktop.
diff --git a/native/components/color-splotch.react.js b/native/components/color-splotch.react.js
index 3626c4ce0..fc98601a2 100644
--- a/native/components/color-splotch.react.js
+++ b/native/components/color-splotch.react.js
@@ -3,6 +3,12 @@
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { SquircleView } from 'react-native-figma-squircle';
+import { SvgXml } from 'react-native-svg';
+import base64 from 'base-64';
+
+import { ENSCacheContext } from 'lib/components/ens-cache-provider.react.js';
+
+import { fetchBlob } from '../media/blob-utils.js';
type Props = {
+color: string,
@@ -20,14 +26,41 @@ function ColorSplotch(props: Props): React.Node {
return styles.large;
}, [size]);
+ const [xml, setXML] = React.useState();
+ const cacheContext = React.useContext(ENSCacheContext);
+ const { ensCache } = cacheContext;
+ React.useEffect(() => {
+ if (!ensCache) {
+ return;
+ }
+ (async () => {
+ const ensAvatarURI = await ensCache.getAvatarURIForAddress(
+ '0x07124c3b6687e78aec8f13a2312cba72a0bed387',
+ );
+ const firstComma = ensAvatarURI.indexOf(',');
+ const base64String = ensAvatarURI.substring(firstComma + 1);
+ const xml = base64.decode(base64String);
+ setXML(xml);
+ })();
+ }, [ensCache]);
+
+ if (size !== 'profile' || !xml) {
+ return (
+ <SquircleView
+ style={style}
+ squircleParams={{
+ cornerSmoothing: 0.95,
+ cornerRadius: 10,
+ fillColor: `#${color}`,
+ }}
+ />
+ );
+ }
+
return (
- <SquircleView
- style={style}
- squircleParams={{
- cornerSmoothing: 0.95,
- cornerRadius: 10,
- fillColor: `#${color}`,
- }}
+ <SvgXml
+ {...style}
+ xml={xml}
/>
);
}
diff --git a/native/utils/ethers-utils.js b/native/utils/ethers-utils.js
index 93bac9cd4..3e14d172e 100644
--- a/native/utils/ethers-utils.js
+++ b/native/utils/ethers-utils.js
@@ -15,7 +15,7 @@ try {
let provider: ?EthersProvider;
if (alchemyKey) {
- provider = new ethers.providers.AlchemyProvider('mainnet', alchemyKey);
+ provider = new ethers.providers.AlchemyProvider('goerli', alchemyKey);
}
export { provider };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment