Skip to content

Commit

Permalink
more blockchain code isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante committed Jun 30, 2023
1 parent 369dcdd commit f5900db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
12 changes: 12 additions & 0 deletions packages/common/src/blockchains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const BLOCKCHAIN_COMMON: Record<
{
PreferencesDefault: SolanaData | EclipseData | EthereumData;
validatePublicKey: (address: string) => boolean;
logoUri: string;
bip44CoinType: number;
}
> = {
[Blockchain.ETHEREUM]: {
Expand All @@ -29,6 +31,9 @@ export const BLOCKCHAIN_COMMON: Record<
}
return true;
},
logoUri:
"https://s3.us-east-1.amazonaws.com/app-assets.xnfts.dev/images/useBlockchainLogo/ethereum.png",
bip44CoinType: 60,
},
[Blockchain.SOLANA]: {
PreferencesDefault: {
Expand All @@ -44,6 +49,9 @@ export const BLOCKCHAIN_COMMON: Record<
}
return true;
},
logoUri:
"https://s3.us-east-1.amazonaws.com/app-assets.xnfts.dev/images/useBlockchainLogo/solana.png",
bip44CoinType: 504,
},
[Blockchain.ECLIPSE]: {
PreferencesDefault: {
Expand All @@ -59,5 +67,9 @@ export const BLOCKCHAIN_COMMON: Record<
}
return true;
},
// todo
logoUri:
"https://s3.us-east-1.amazonaws.com/app-assets.xnfts.dev/images/useBlockchainLogo/solana.png",
bip44CoinType: 504,
},
};
10 changes: 2 additions & 8 deletions packages/common/src/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import BIPPath from "bip32-path";

import { BLOCKCHAIN_COMMON } from "./blockchains";
import { LOAD_PUBLIC_KEY_AMOUNT } from "./constants";
import { Blockchain } from "./types";

export const HARDENING = 0x80000000;

// TODO could use SLIP44
export const blockchainCoinType = {
[Blockchain.ETHEREUM]: 60,
[Blockchain.SOLANA]: 501,
[Blockchain.ECLIPSE]: 501,
};

export const getCoinType = (blockchain: Blockchain) => {
const coinType = blockchainCoinType[blockchain];
const coinType = BLOCKCHAIN_COMMON[blockchain].bip44CoinType;
if (!coinType) {
throw new Error("Invalid blockchain");
}
Expand Down
25 changes: 3 additions & 22 deletions packages/tamagui-core/src/components/BlockchainLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
import { Image } from "react-native";
import { Blockchain } from "@coral-xyz/common";

// YES YOU'RE RIGHT THESE ARE HERE AND NOT SOMEWHERE ELSE!
// until we know the app-extension can handle relative import image paths or w/e, this stays in here on this url
const Images = {
ethereumLogo:
"https://s3.us-east-1.amazonaws.com/app-assets.xnfts.dev/images/useBlockchainLogo/ethereum.png",
solanaLogo:
"https://s3.us-east-1.amazonaws.com/app-assets.xnfts.dev/images/useBlockchainLogo/solana.png",
eclipseLogo:
"https://s3.us-east-1.amazonaws.com/app-assets.xnfts.dev/images/useBlockchainLogo/solana.png", // todo
};
import type { Blockchain} from "@coral-xyz/common";
import { BLOCKCHAIN_COMMON } from "@coral-xyz/common";

function getBlockchainLogo(blockchain: Blockchain) {
switch (blockchain) {
case Blockchain.ETHEREUM:
return Images.ethereumLogo;
case Blockchain.SOLANA:
return Images.solanaLogo;
case Blockchain.ECLIPSE:
return Images.eclipseLogo;
default:
return Images.solanaLogo;
}
return BLOCKCHAIN_COMMON[blockchain].logoUri;
}

export function BlockchainLogo({
Expand Down

1 comment on commit f5900db

@vercel
Copy link

@vercel vercel bot commented on f5900db Jun 30, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.