Skip to content

Commit 6554d5b

Browse files
feat: wagmi v2 upgrade to v1 svelte-wagmi
1 parent 6717f11 commit 6554d5b

File tree

6 files changed

+13373
-4338
lines changed

6 files changed

+13373
-4338
lines changed

README.md

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Svelte Wagmi is a package that provides a collection of Svelte stores and functi
77
To install the package and its peer dependencies, run the following command:
88

99
```bash
10-
npm install svelte-wagmi viem @wagmi/core
10+
npm install svelte-wagmi viem @wagmi/core @wagmi/connectors
1111
```
1212

1313
## Usages
@@ -113,7 +113,7 @@ Example usage:
113113
</script>
114114

115115
{#if $web3Modal}
116-
<button on:click="{()" ="">$web3Modal.openModal()}> Connect to Ethereum</button>
116+
<button on:click="{()" ="">$web3Modal.open()}> Connect to Ethereum</button>
117117
{:else}
118118

119119
<p>Web3Modal not yet available</p>
@@ -126,15 +126,9 @@ The `defaultConfig` function is used to configure the `@wagmi/core` library and
126126

127127
- `autoConnect` (boolean, default: `true`): Specifies whether the Ethereum client should automatically connect to a provider upon initialization. If set to `true`, the client will attempt to connect automatically.
128128
- `appName` (string, default: `'Erc.Kit'`): Specifies the name of the application using the Ethereum client.
129-
- `appIcon` (string): Specifies the URL or path to an icon representing the application.
130-
- `appDescription` (string): Specifies the description of the application.
131-
- `appUrl` (string): Specifies the URL of the application.
132129
- `chains` (array, default: `defaultChains`): An array of chain configurations to connect with. If not provided, the function will use default chain configurations.
133-
- `alchemyId` (string): The API key for the Alchemy provider, used for connecting to the Alchemy service.
134-
- `infuraId` (string): The API key for the Infura provider, used for connecting to the Infura service.
130+
- `alchemyId` (optional) (string): The API key for the Alchemy provider, used for connecting to the Alchemy service.
135131
- `connectors` (object): An object containing customized connector configurations for the Ethereum client.
136-
- `publicClient` (object): Specifies a pre-configured public client object.
137-
- `stallTimeout` (number): Specifies the stall timeout value for the Ethereum client.
138132
- `walletConnectProjectId` (string): The project ID used for the WalletConnect integration.
139133

140134
### Return Value:
@@ -150,77 +144,33 @@ Example usage:
150144
import { defaultConfig } from 'svelte-wagmi';
151145
import { onMount } from 'svelte';
152146
import { PUBLIC_WALLETCONNECT_ID, PUBLIC_ALCHEMY_ID } from '$env/static/public';
147+
import { injected } from '@wagmi/connectors';
153148
154149
onMount(async () => {
155150
const erckit = defaultConfig({
156151
appName: 'erc.kit',
157152
walletConnectProjectId: PUBLIC_WALLETCONNECT_ID,
158-
alchemyId: PUBLIC_ALCHEMY_ID
153+
alchemyId: PUBLIC_ALCHEMY_ID,
154+
connectors: [injected()]
159155
});
156+
});
160157
161158
await erckit.init();
162159
</script>
163160
```
164161

165-
### configureWagmi (deprecated)
166-
167-
The `configureWagmi` function is used to configure the `@wagmi/core` library and initialize the Svelte stores. It takes an optional options object that can be used to configure the behavior of the function.
168-
169-
- `walletconnect` (optional): A boolean that indicates whether to enable WalletConnect support. If this is set to true, the
170-
walletconnectProjectID option must also be provided.
171-
- `walletconnectProjectID` (optional): A string that contains the Project ID for the WalletConnect service. This is required if walletconnect is set to true.
172-
- `alchemyKey` (optional): A string that contains the API key for the Alchemy service. This is required if you want to use the Alchemy provider.
173-
- `autoConnect` (optional): A boolean that indicates whether to automatically connect to the Ethereum provider on page load.
174-
175-
Example usage:
176-
177-
```html
178-
<script>
179-
import { configureWagmi } from 'svelte-wagmi';
180-
181-
configureWagmi({
182-
walletconnect: true,
183-
walletconnectProjectID: '1234567890',
184-
alchemyKey: 'abcdefghijklmnopqrstuvwxyz123456',
185-
autoConnect: true
186-
});
187-
</script>
188-
```
189162
### configuredConnectors
190163

191-
The `configuredConnectors` are store value array
192-
164+
The `configuredConnectors` are store value array
193165

194-
195-
Example usage:
166+
Example usage:
196167

197168
```html
198169
<script>
199170
import { configuredConnectors } from 'svelte-wagmi';
200171
201172
for (const connector of $configuredConnectors) {
202-
console.log(connector)
203-
}
204-
</script>
205-
206-
<button on:click="{connectToEthereum}">Connect to Ethereum</button>
207-
```
208-
209-
### connection
210-
211-
The `connection` function is used to connect to an Ethereum provider using the InjectedConnector from @wagmi/core. It takes two parameters:
212-
213-
- `chainId` (optional): A number that specifies the chain ID to connect to. The default is 1 (mainnet).
214-
- `statement` (optional): A string that specifies the statement to be signed by the user when logging in.
215-
216-
Example usage:
217-
218-
```html
219-
<script>
220-
import { connection } from 'svelte-wagmi';
221-
222-
async function connectToEthereum() {
223-
await connection();
173+
console.log(connector);
224174
}
225175
</script>
226176

0 commit comments

Comments
 (0)