Skip to content

Commit

Permalink
Merge pull request #350 from skip-mev/staging
Browse files Browse the repository at this point in the history
sync staging to main
  • Loading branch information
codingki authored Aug 1, 2024
2 parents 45a637c + baf2dac commit 58c169e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ Read more on all available environment variables in [`.env.example`](.env.exampl
- lint sources: `npm run lint`
- build production bundle: `npm run build`
- run production server: `npm run start` (must run `build` first)
- run dev server in https `npm run dev:https`

## Testing

`npm run test` will run the unit tests.
`npm run test:e2e` will run the automated end-to-end tests. Make sure you have `WORD_PHRASE_KEY=""`(12 word phrase key) in your `.env` file. This will be used to importing the wallet and perform the tests.

if you want to test prax wallet/penumbra, you need to run dev server in https `npm run dev:https` and set `APP_URL=https://localhost:3000` in your `.env` file.

## Contributing

Feel free to open an issue or submit a pull request for any bugs and/or improvements.
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"chains:update": "git submodule init && git submodule update --remote",
"chains:generate": "tsx ./src/scripts/codegen.ts",
"dev": "next dev",
"dev:https": "next dev --experimental-https",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx}\"",
"lint": "eslint --fix \"**/*.{js,jsx,ts,tsx}\"",
"postinstall": "patch-package && run-s chains:*",
Expand Down Expand Up @@ -35,7 +36,7 @@
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/nextjs": "^7.99.0",
"@skip-go/widget": "^2.3.0",
"@skip-go/widget": "^2.3.1",
"@solana/spl-token": "^0.4.1",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-wallets": "^0.19.31",
Expand Down
22 changes: 20 additions & 2 deletions src/lib/skip-go-widget.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { bech32mAddress } from "@penumbra-zone/bech32m/penumbra";
import { bech32CompatAddress } from "@penumbra-zone/bech32m/penumbracompat1";
import { ViewService } from "@penumbra-zone/protobuf";
import { MinimalWallet, SwapWidgetProviderProps } from "@skip-go/widget";
import toast from "react-hot-toast";
Expand All @@ -18,6 +19,18 @@ export const endpointOptions: SwapWidgetProviderProps["endpointOptions"] = {

export const apiURL = `${appUrl}/api/skip`;

const penumbraBech32ChainIDs = ["noble-1", "grand-1"];
const getPenumbraCompatibleAddress = ({
chainID,
address,
}: {
chainID?: string;
address: { inner: Uint8Array };
}): string => {
if (!chainID) return bech32mAddress(address);
return penumbraBech32ChainIDs.includes(chainID) ? bech32CompatAddress(address) : bech32mAddress(address);
};

export const praxWallet: MinimalWallet = {
walletName: "prax",
walletPrettyName: "Prax Wallet",
Expand All @@ -29,7 +42,9 @@ export const praxWallet: MinimalWallet = {
toast.error("Prax wallet is not supported for connect");
},
getAddress: async (props) => {
const penumbraWalletIndex = props?.penumbraWalletIndex;
const penumbraWalletIndex = props?.praxWallet?.index;
const sourceChainID = props?.praxWallet?.sourceChainID;

try {
const isInstalled = await isPraxInstalled();
if (!isInstalled) {
Expand All @@ -43,7 +58,10 @@ export const praxWallet: MinimalWallet = {
},
});
if (!address.address) throw new Error("No address found");
const bech32Address = bech32mAddress(address.address);
const bech32Address = getPenumbraCompatibleAddress({
address: address.address,
chainID: sourceChainID,
});
return bech32Address;
} catch (error) {
console.error(error);
Expand Down

0 comments on commit 58c169e

Please sign in to comment.