Skip to content

Commit

Permalink
Merge pull request #410 from blocto/feat/rainbowkit-v2
Browse files Browse the repository at this point in the history
feat: rainbowkit v2
  • Loading branch information
sanyu1225 authored Apr 16, 2024
2 parents b478e7f + 5e023f3 commit 65dcb7c
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 107 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-candles-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blocto/wagmi-connector': patch
---

export wagmi createConnector function
5 changes: 5 additions & 0 deletions .changeset/smart-emus-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blocto/rainbowkit-connector': major
---

support rainbowkt v2
4 changes: 2 additions & 2 deletions adapters/rainbowkit-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"lint": "eslint src --ext .ts"
},
"dependencies": {
"@rainbow-me/rainbowkit": "^1.0.8",
"@blocto/wagmi-connector": "npm:@blocto/wagmi-connector@^1.3.1"
"@rainbow-me/rainbowkit": "^2.0.4",
"@blocto/wagmi-connector": "^2"
},
"devDependencies": {
"@types/jest": "^29.5.2",
Expand Down
37 changes: 23 additions & 14 deletions adapters/rainbowkit-connector/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import { bloctoWallet } from '../index';

describe('rainbowkit-connector', () => {
const chains = [
{
name: 'Ethereum',
id: 1,
network: 'mainnet',
nativeCurrency: { name: 'Ether', decimals: 18, symbol: 'ETH' },
rpcUrls: {
default: { http: ['https://mainnet.infura.io/v3/'] },
public: { http: ['https://mainnet.infura.io/v3/'] },
},
},
];
const wallet = bloctoWallet({ chains });

const wallet = bloctoWallet();

test('defines name', () => {
expect(typeof wallet.name).toBe('string');
Expand All @@ -31,7 +20,27 @@ describe('rainbowkit-connector', () => {
expect(typeof wallet.createConnector).toBe('function');
});

const { connector } = wallet.createConnector();
const { connector } = wallet.createConnector({
rkDetails: {
id: 'blocto',
name: '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4MTIgOS44MzIwMzEgQyA3LjY0MDYyNSAxMC44Nzg5MDYgNi44MDg1OTQgMTIuMTY0MDYyIDYuMTkxNDA2IDEzLjQzNzUgQyA2LjA3MDMxMiAxMy42ODc1IDUuNjkxNDA2IDEzLjU5NzY1NiA1LjY5MTQwNiAxMy4zMjAzMTIgTCA1LjY5MTQwNiA1LjkxNzk2OSBDIDUuNjkxNDA2IDQuMTk1MzEyIDcuMDg5ODQ0IDIuODAwNzgxIDguODEyNSAyLjgwMDc4MSBDIDEwLjUzNTE1NiAyLjgwMDc4MSAxMS45Mjk2ODggNC4xOTUzMTIgMTEuOTI5Njg4IDUuOTE3OTY5IFogTSAxMS45Mjk2ODggNS45MTc5NjkgIi8+CjwvZz4KPC9zdmc+Cg==',
downloadUrls: {
ios: 'https://apps.apple.com/app/blocto/id1481181682',
android:
'https://play.google.com/store/apps/details?id=com.portto.blocto',
},
installed: true,
index: 4,
groupIndex: 2,
groupName: 'Other',
isRainbowKitConnector: true,
},
});

test('defines account()', () => {
expect(typeof connector.connect).toBe('function');
Expand Down
50 changes: 24 additions & 26 deletions adapters/rainbowkit-connector/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import { Chain, Wallet } from '@rainbow-me/rainbowkit';
import { BloctoConnector } from '@blocto/wagmi-connector';
import { Wallet, WalletDetailsParams } from '@rainbow-me/rainbowkit';
import { blocto, createConnector } from '@blocto/wagmi-connector';

export interface BloctoWalletOptions {
chains: Chain[];
appId?: string;
}

export const bloctoWallet = ({
chains,
appId,
}: BloctoWalletOptions): Wallet => ({
id: 'blocto',
name: 'Blocto',
iconBackground: '#ffffff',
iconUrl:
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aW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g5ODQ0IDIuODAwNzgxIDguODEyNSAyLjgwMDc4MSBDIDEwLjUzNTE1NiAyLjgwMDc4MSAxMS45Mjk2ODggNC4xOTUzMTIgMTEuOTI5Njg4IDUuOTE3OTY5IFogTSAxMS45Mjk2ODggNS45MTc5NjkgIi8+CjwvZz4KPC9zdmc+Cg==',
downloadUrls: {
ios: 'https://apps.apple.com/app/blocto/id1481181682',
android: 'https://play.google.com/store/apps/details?id=com.portto.blocto',
},
installed: true,
createConnector: (): any => {
const connector = new BloctoConnector({ chains, options: { appId } });
export const bloctoWallet =
({ appId } = { appId: undefined }) =>
(): Wallet => {
return {
connector,
id: 'blocto',
name: 'Blocto',
shortName: 'Blocto',
rdns: 'io.blocto',
iconBackground: '#ffffff',
iconUrl:
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjhweCIgaGVpZ2h0PSIyOHB4IiB2aWV3Qm94PSIwIDAgMjggMjgiIHZlcnNpb249IjEuMSI+CjxnIGlkPSJzdXJmYWNlMSI+CjxyZWN0IHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCIgZmlsbD0id2hpdGUiLz4KPHBhdGggc3R5bGU9IiBzdHJva2U6bm9uZTtmaWxsLXJ1bGU6bm9uemVybztmaWxsOnJnYig3Ljg0MzEzNyUsNjYuNjY2NjY3JSwxMDAlKTtmaWxsLW9wYWNpdHk6MTsiIGQ9Ik0gMTUuMzU1NDY5IDguNTQyOTY5IEMgMTMuMjUgOC41NDI5NjkgMTEuMTk1MzEyIDkuMzU1NDY5IDkuNjU2MjUgMTAuNzkyOTY5IEMgNy45NzI2NTYgMTIuMzc1IDYuOTA2MjUgMTQuNzA3MDMxIDYuMjk2ODc1IDE2LjkwMjM0NC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ggMTUuMzU1NDY5IDIwLjY3OTY4OCBaIE0gMTUuMzU1NDY5IDIwLjY3OTY4OCAiLz4KPHBhdGggc3R5bGU9IiBzdHJva2U6bm9uZTtmaWxsLXJ1bGU6bm9uemVybztmaWxsOnJnYigwJSw0NS44ODIzNTMlLDEwMCUpO2ZpbGwtb3BhY2l0eToxOyIgZD0iTSAxMS45Mjk2ODggNS45MTc5NjkgQyAxMS45Mjk2ODggNy4wMTU2MjUgMTEuMzU1NDY5IDguMDM1MTU2IDEwLjQxMDE1NiA4LjU5Mzc1IEMgOS44MTY0MDYgOC45NDUzMTIgOS4yNjE3MTkgOS4zNTkzNzUgOC43NTc4MTIgOS44MzIwMzEgQyA3LjY0MDYyNSAxMC44Nzg5MDYgNi44MDg1OTQgMTIuMTY0MDYyIDYuMTkxNDA2IDEzLjQzNzUgQyA2LjA3MDMxMiAxMy42ODc1IDUuNjkxNDA2IDEzLjU5NzY1NiA1LjY5MTQwNiAxMy4zMjAzMTIgTCA1LjY5MTQwNiA1LjkxNzk2OSBDIDUuNjkxNDA2IDQuMTk1MzEyIDcuMDg5ODQ0IDIuODAwNzgxIDguODEyNSAyLjgwMDc4MSBDIDEwLjUzNTE1NiAyLjgwMDc4MSAxMS45Mjk2ODggNC4xOTUzMTIgMTEuOTI5Njg4IDUuOTE3OTY5IFogTSAxMS45Mjk2ODggNS45MTc5NjkgIi8+CjwvZz4KPC9zdmc+Cg==',
downloadUrls: {
ios: 'https://apps.apple.com/app/blocto/id1481181682',
android:
'https://play.google.com/store/apps/details?id=com.portto.blocto',
},
installed: true,
createConnector: (walletDetails: WalletDetailsParams) =>
createConnector((config) => ({
...blocto({ appId })(config),
...walletDetails,
})),
};
},
});
};
2 changes: 2 additions & 0 deletions adapters/wagmi-connector/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,5 @@ export function blocto({ appId }: BloctoParameters = {}) {
},
}));
}

export { createConnector };
2 changes: 1 addition & 1 deletion adapters/wagmi-connector/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { blocto } from './connector';
export { blocto, createConnector } from './connector';
export type * from './connector';
Loading

0 comments on commit 65dcb7c

Please sign in to comment.