Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update viem peer version; tweak wallet connectors #13

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/agw-react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@abstract-foundation/agw-react",
"description": "Abstract Global Wallet React Components",
"version": "0.0.1-alpha.5",
"version": "0.0.1-alpha.6",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -49,7 +49,7 @@
"peerDependencies": {
"react": ">=18",
"typescript": ">=5.0.4",
"viem": "2.21.3",
"viem": "^2.21.8",
"@wagmi/core": "^2",
"@abstract-foundation/agw-sdk": "workspace:*"
},
Expand All @@ -59,7 +59,7 @@
"react-dom": ">=18.3.1",
"@types/react": ">=18.3.1",
"@types/react-dom": ">=18.3.0",
"viem": "2.21.3",
"viem": "^2.21.8",
"@wagmi/core": "^2",
"@rainbow-me/rainbowkit": "^2.1.6"
},
Expand Down
34 changes: 34 additions & 0 deletions packages/agw-react/src/abstractWallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client';
import { type Wallet } from '@rainbow-me/rainbowkit';

import { abstractWalletConnector } from './abstractWalletConnector.js';

/**
* Create a RainbowKit wallet for Abstract Global Wallet
*
* @example
* import { connectorsForWallets } from "@rainbow-me/rainbowkit";
* import { abstractWallet } from "@abstract-foundation/agw-react/connectors"
*
* const connectors = connectorsForWallets(
* [
* {
* groupName: "Abstract",
* wallets: [abstractWallet],
* },
* ]);
*/
const abstractWallet = (): Wallet => {
return {
id: 'abstract',
name: 'Abstract',
iconUrl:
'https://ipfs.io/ipfs/QmSpL14zz76qGCvxD5rd3SLTmQUmruY3DEZAw3a9GebZ4S',
iconBackground: '#ffffff',
installed: true,
shortName: 'Abstract',
createConnector: () => abstractWalletConnector(),
};
};

export { abstractWallet };
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,32 @@

import { AGW_APP_ID } from './constants.js';

export function createAbstractWalletConnector(): CreateConnectorFn<
/**
* Create a wagmi connector for the Abstract Global Wallet.
*
* Adapted from wagmi injected connector as a reference implementation:
* https://github.com/wevm/wagmi/blob/main/packages/core/src/connectors/injected.ts#L94
*
* @example
* import { createConfig, http } from "wagmi";
* import { abstract } from "wagmi/chains";
*
* const privyWalletConnector = toPrivyWalletConnector({
* providerAppId: <your-app-id>,
* providerName: 'Your app',
* providerIconUrl: 'https://example.com/image.png',
* })
*
* export const wagmiConfig = createConfig({
* chains: [mainnet],
* transports: {
* [mainnet.id]: http(),
* },
* connectors: [abstractWalletConnector],
* ssr: true,
* });
*/
function abstractWalletConnector(): CreateConnectorFn<
{
on: <event extends keyof EIP1193EventMap>(
event: event,
Expand Down Expand Up @@ -39,7 +64,7 @@
) => {
const provider = await getProvider(parameters);
const providerHandleRequest = provider.request;
const handler: EIP1193RequestFn<EIP1474Methods> = async (e: any) => {

Check warning on line 67 in packages/agw-react/src/abstractWalletConnector.ts

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type
const { method } = e;
console.log('Abstract provider processing', method);
switch (method) {
Expand Down Expand Up @@ -72,3 +97,5 @@
return abstractConnector;
};
}

export { abstractWalletConnector };
50 changes: 0 additions & 50 deletions packages/agw-react/src/createAbstractWallet.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/agw-react/src/exports/connectors.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { abstractWallet } from '../createAbstractWallet.js';
export { createAbstractWalletConnector } from '../createAbstractWalletConnector.js';
export { abstractWallet } from '../abstractWallet.js';
export { abstractWalletConnector } from '../abstractWalletConnector.js';
6 changes: 3 additions & 3 deletions packages/agw-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@abstract-foundation/agw-sdk",
"description": "Abstract Global Wallet SDK",
"version": "0.0.1-alpha.9",
"version": "0.0.1-alpha.10",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -39,12 +39,12 @@
"peerDependencies": {
"abitype": "^1.0.0",
"typescript": ">=5.0.4",
"viem": "^2.19.0"
"viem": "^2.21.8"
},
"devDependencies": {
"@types/node": "^22.5.5",
"prool": "^0.0.16",
"viem": "^2.19.0",
"viem": "^2.21.8",
"vitest": "^2.1.1"
},
"peerDependenciesMeta": {
Expand Down
Loading
Loading