Skip to content

Commit

Permalink
add func to import rainbow wallet directly
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 authored Apr 28, 2024
1 parent cebe21a commit 53274bc
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 63 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-mirrors-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"burner-connector-test01": patch
---

export rainbowkit burner wallet directly
4 changes: 2 additions & 2 deletions example/app/ScaffoldETHProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { mainnet, polygon, optimism, arbitrum, base } from "wagmi/chains";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
import { metaMaskWallet } from "@rainbow-me/rainbowkit/wallets";
import { createClient, http } from "viem";
import { burnerWallet } from "./burnerWallet";
import { rainbowkitBurnerWallet } from "burner-connector-test01";

const wallets = [metaMaskWallet, burnerWallet];
const wallets = [metaMaskWallet, rainbowkitBurnerWallet];
const walletConnectProjectID = "3a8170812b534d0ff9d794f19a901d64";
const wagmiConnectors = connectorsForWallets(
[
Expand Down
24 changes: 0 additions & 24 deletions example/app/burnerWallet.ts

This file was deleted.

32 changes: 0 additions & 32 deletions example/app/rainbowkitBurnerConnector.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/burner-connector-test01/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"typescript": "^5.4.5"
},
"dependencies": {
"@rainbow-me/rainbowkit": "2.0.2",
"@wagmi/core": "2.6.9",
"viem": "2.8.16"
}
Expand Down
12 changes: 8 additions & 4 deletions packages/burner-connector-test01/src/burnerConnector/burner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { getHttpRpcClient, hexToBigInt, numberToHex } from "viem/utils";
import { loadBurnerPK } from "../utils/index.js";
import {
burnerWalletId,
burnerWalletName,
loadBurnerPK,
} from "../utils/index.js";

export class ConnectorNotConnectedError extends BaseError {
override name = "ConnectorNotConnectedError";
Expand All @@ -42,9 +46,9 @@ export const burner = () => {
let connected = true;
let connectedChainId: number;
return createConnector<Provider>((config) => ({
id: "burnerWallet",
name: "Burner Wallet",
type: "burnerWallet",
id: burnerWalletId,
name: burnerWalletName,
type: burnerWalletId,
async connect({ chainId } = {}) {
const provider = await this.getProvider();
const accounts = await provider.request({
Expand Down
3 changes: 2 additions & 1 deletion packages/burner-connector-test01/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./burnerConnector/burner.js";
export { burner } from "./burnerConnector/burner.js";
export { rainbowkitBurnerWallet } from "./wallets/rainbowkit/index.js";
2 changes: 2 additions & 0 deletions packages/burner-connector-test01/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { Hex } from "viem";
import { generatePrivateKey } from "viem/accounts";

const burnerStorageKey = "burnerWallet.pk";
export const burnerWalletId = "burnerWallet" as const;
export const burnerWalletName = "Burner Wallet" as const;

/**
* Checks if the private key is valid
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { rainbowkitBurnerWallet } from "./rainbowkitBurnerWallet.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { WalletDetailsParams } from "@rainbow-me/rainbowkit";
import type { EIP1193RequestFn, Transport, WalletRpcSchema } from "viem";
import { createConnector } from "@wagmi/core";
import { burner } from "../../burnerConnector/burner.js";

type Provider = ReturnType<
Transport<"custom", Record<any, any>, EIP1193RequestFn<WalletRpcSchema>>
>;

export const rainbowkitBurnerConnector = (
walletDetails: WalletDetailsParams,
) => {
return createConnector<Provider>((config) => ({
...burner()(config),
...walletDetails,
}));
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Wallet } from "@rainbow-me/rainbowkit";
import { burnerWalletId, burnerWalletName } from "../../utils/index.js";
import { rainbowkitBurnerConnector } from "./rainbowkitBurnerConnector.js";

const burnerWalletIcon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W50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZGRjI3OSIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNGRkQzMzYiLz4KPC9saW5lYXJHcmFkaWVudD4KPHJhZGlhbEdyYWRpZW50IGlkPSJwYWludDFfcmFkaWFsXzNfMTUxIiBjeD0iMCIgY3k9IjAiIHI9IjEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDIxOC4wNDggMjQ5LjM0Nykgcm90YXRlKDEyNC4wMTgpIHNjYWxlKDg5LjI5NTUgMjY0LjgwOSkiPgo8c3RvcCBvZmZzZXQ9IjAuNjQwODUiIHN0b3AtY29sb3I9IiNGRjY2MEEiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRkZCRTE1Ii8+CjwvcmFkaWFsR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQyX2xpbmVhcl8zXzE1MSIgeDE9IjE3Ni40ODIiIHkxPSI0MC4xODQxIiB4Mj0iMTc2LjQ4MiIgeTI9IjMxNy4yNzgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agb2Zmc2V0PSIwLjMzODU0MiIgc3RvcC1jb2xvcj0iI0ZGOEYzRiIvPgo8c3RvcCBvZmZzZXQ9IjAuNjU2MjUiIHN0b3AtY29sb3I9IiNGRjcwMjAiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRkYzRDAwIi8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg==";

/**
* Wagmi config for burner wallet
*/
export const rainbowkitBurnerWallet = (): Wallet => ({
id: burnerWalletId,
name: burnerWalletName,
iconUrl: burnerWalletIconBase64,
iconBackground: "#ffffff",
createConnector: rainbowkitBurnerConnector,
});
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 53274bc

Please sign in to comment.