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

chore: update wagmi example #535

Merged
merged 2 commits into from
Dec 12, 2023
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
2 changes: 1 addition & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"initialVersions": {
"example-safe-apps-wagmi-cra": "0.2.0",
"@safe-global/cra-template-safe-app": "5.0.0",
"@safe-global/safe-apps-provider": "0.18.0",
"@safe-global/safe-apps-provider": "0.18.1",
"@safe-global/safe-apps-react-sdk": "4.7.0",
"@safe-global/safe-apps-sdk": "8.1.0",
"@safe-global/safe-apps-test-app": "0.2.0",
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
- run: |
yarn global add lerna
# approach taken from https://github.com/actions/setup-node/issues/85
echo "$(yarn global bin)" >> $GITHUB_PATH
- run: yarn install --frozen-lockfile
- run: lerna run test
- run: yarn test:sdk
4 changes: 2 additions & 2 deletions examples/wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"util": "^0.12.5",
"viem": "^1.0.0",
"wagmi": "^1.3.9",
"viem": "^1.19.13",
"wagmi": "^1.4.10",
"web-vitals": "^3.4.0"
},
"devDependencies": {
Expand Down
30 changes: 28 additions & 2 deletions examples/wagmi/src/components/Connect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { useAccount, useConnect, useDisconnect, usePrepareSendTransaction, useSendTransaction } from 'wagmi';
import {
useAccount,
useConnect,
useContractWrite,
useDisconnect,
usePrepareContractWrite,
usePrepareSendTransaction,
useSendTransaction,
} from 'wagmi';

import { useAutoConnect } from '../useAutoConnect';

Expand All @@ -13,6 +21,23 @@ export function Connect() {

const { sendTransactionAsync } = useSendTransaction(config);

const { config: config2 } = usePrepareContractWrite({
// wagmi mint example contract
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
abi: [
{
name: 'mint',
type: 'function',
stateMutability: 'nonpayable',
inputs: [],
outputs: [],
},
],
functionName: 'mint',
});

const { write } = useContractWrite(config2);

useAutoConnect();

return (
Expand All @@ -21,7 +46,8 @@ export function Connect() {
{activeConnector && (
<>
<button onClick={() => disconnect()}>Disconnect from {activeConnector.name}</button>
<button onClick={() => sendTransactionAsync?.()}>Test transaction</button>
<button onClick={() => write?.()}>Test WagmiMintExample write contract transaction</button>
<button onClick={() => sendTransactionAsync?.()}>Test send transaction</button>
</>
)}

Expand Down
4 changes: 2 additions & 2 deletions examples/wagmi/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';

import { mainnet, goerli } from 'viem/chains';
import { WagmiConfig, createConfig, configureChains, Connector } from 'wagmi';
import { mainnet, goerli } from 'wagmi/chains';
import { publicProvider } from 'wagmi/providers/public';
import { SafeConnector } from 'wagmi/connectors/safe';
import { InjectedConnector } from 'wagmi/connectors/injected';
Expand All @@ -19,7 +19,7 @@ if (!window.Buffer) {
window.Buffer = Buffer;
}

const WALLETCONNECT_PROJECT_ID = process.env.REACT_APP_WALLETCONNECT_PROJECT_ID
const WALLETCONNECT_PROJECT_ID = process.env.REACT_APP_WALLETCONNECT_PROJECT_ID;

const defaultChains = [mainnet, goerli];

Expand Down
4 changes: 2 additions & 2 deletions packages/safe-apps-sdk/dist/cjs/communication/methods.js

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

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

2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/dist/cjs/safe/index.js

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

2 changes: 1 addition & 1 deletion packages/safe-apps-sdk/dist/cjs/safe/index.js.map

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

2 changes: 2 additions & 0 deletions packages/safe-apps-sdk/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module.exports = {
moduleDirectories: ['node_modules', 'src'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
// fix isows CJS + ESM compatibility
isows: '<rootDir>/../../node_modules/isows/_cjs/index.js',
},
transform: {
'^.+\\.[tj]sx?$': [
Expand Down
2 changes: 1 addition & 1 deletion packages/safe-apps-web3modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"web3modal": "^1.9.9"
},
"dependencies": {
"@safe-global/safe-apps-provider": "^0.18.1-next.0"
"@safe-global/safe-apps-provider": "^0.18.2-next.0"
},
"publishConfig": {
"access": "public"
Expand Down
Loading