Skip to content

Commit

Permalink
Merge pull request #64 from archethic-foundation/63-config---implemen…
Browse files Browse the repository at this point in the history
…tation-of-wallets-list-choice

feat: ✨ Config - implementation of wallets list choice
  • Loading branch information
redDwarf03 authored Oct 15, 2024
2 parents 76f10bf + cded37a commit 5e97e72
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0-rc.7
* Config - implementation of wallets list choice
* Add `includeWalletIds`, `featuredWalletIds`, `excludeWalletIds` properties in `Config` object

## 1.0.0-rc.6
* 🐛 Fix watchAccount method - Fix Attempting to rewrap a JS function error

Expand Down
11 changes: 10 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class _MyAppState extends State<MyApp> {
String tempWallet = '0xfAd3b616BCD747A12A7c0a6203E7a481606B12E8';

// TODO(dev): Add your own project ID to use example
static const _projectId = '<TO UPDATE>';
static const _projectId = 'd1a249a3f73bc73891ea505b2a30d5c2';

String txHash = '';
BigInt blockConfirmationNumber = BigInt.zero,
Expand Down Expand Up @@ -93,6 +93,11 @@ class _MyAppState extends State<MyApp> {
email: false, // email
showWallets: true, // showWallets
walletFeatures: true, // walletFeatures
// Use https://explorer.walletconnect.com/?type=wallet to find wallet ids
includeWalletIds: [
'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // MetaMask
'1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369', // Rainbow
],
);

// create config
Expand All @@ -119,6 +124,10 @@ class _MyAppState extends State<MyApp> {
url:
'https://polygon-amoy.g.alchemy.com/v2/', //TODO(dev): Add your own API Key to use example
),
// Use https://explorer.walletconnect.com/?type=wallet to find wallet ids
includeWalletIds: [
'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96', // MetaMask
],
);
await wagmi.Core.reconnect(
wagmi.ReconnectParameters(),
Expand Down
6 changes: 6 additions & 0 deletions lib/src/js/wagmi_web3modal.js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ extension type JSWagmiWeb3Modal(JSObject _) implements JSObject {
JSBoolean showWallets,
JSBoolean walletFeatures,
JSFunction? transportBuilder,
JSArray<JSString>? includedWalletIds,
JSArray<JSString>? featuredWalletIds,
JSArray<JSString>? excludedWalletIds,
);
// for create createConfig
external JSConfig createConfig(
Expand All @@ -25,6 +28,9 @@ extension type JSWagmiWeb3Modal(JSObject _) implements JSObject {
JSBoolean showWallets,
JSBoolean walletFeatures,
JSFunction? transportBuilder,
JSArray<JSString>? includedWalletIds,
JSArray<JSString>? featuredWalletIds,
JSArray<JSString>? excludedWalletIds,
);

external JSAppKit createWeb3Modal(
Expand Down
12 changes: 12 additions & 0 deletions lib/src/wagmi_web3modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Web3Modal {
required bool showWallets,
required bool walletFeatures,
TransportBuilder? transportBuilder,
List<String>? includeWalletIds,
List<String>? featuredWalletIds,
List<String>? excludeWalletIds,
}) {
window.web3modal.init(
projectId.toJS,
Expand All @@ -32,6 +35,9 @@ class Web3Modal {
showWallets.toJS,
walletFeatures.toJS,
transportBuilder?.toJS,
includeWalletIds?.jsify() as JSArray<JSString>?,
featuredWalletIds?.jsify() as JSArray<JSString>?,
excludeWalletIds?.jsify() as JSArray<JSString>?,
);
}

Expand All @@ -46,6 +52,9 @@ class Web3Modal {
required bool showWallets,
required bool walletFeatures,
TransportBuilder? transportBuilder,
List<String>? includeWalletIds,
List<String>? featuredWalletIds,
List<String>? excludeWalletIds,
}) =>
window.web3modal.createConfig(
projectId.toJS,
Expand All @@ -62,6 +71,9 @@ class Web3Modal {
showWallets.toJS,
walletFeatures.toJS,
transportBuilder?.toJS,
includeWalletIds?.jsify() as JSArray<JSString>?,
featuredWalletIds?.jsify() as JSArray<JSString>?,
excludeWalletIds?.jsify() as JSArray<JSString>?,
);

/// Opens the [Web3Modal]
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: wagmi_flutter_web
description: "Wagmi JS SDK wrapper for Dart Web"
version: 1.0.0-rc.6
version: 1.0.0-rc.7
homepage: https://github.com/archethic-foundation/wagmi_flutter_web

environment:
Expand Down
11 changes: 10 additions & 1 deletion typescript/src/web3_modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export class JSWeb3Modal {
socials: [] | undefined,
showWallets: boolean,
walletFeatures: boolean,
transportBuilder: JSTransportBuilder | undefined
transportBuilder: JSTransportBuilder | undefined,
includeWalletIds: string[] | undefined, // Warning the name is not the same with documentation... https://docs.reown.com/appkit/flutter/core/options
featuredWalletIds: string[] | undefined,
excludeWalletIds: string[] | undefined, // Warning the name is not the same with documentation... https://docs.reown.com/appkit/flutter/core/options

) {
JSWagmiContext.instance.config = Web3modal.defaultWagmiConfig({
chains: chainsFromIds(chains),
Expand All @@ -49,6 +53,9 @@ export class JSWeb3Modal {
projectId: projectId,
enableAnalytics: enableAnalytics, // Optional - defaults to your Cloud configuration
enableOnramp: enableOnRamp, // Optional - false as default
includeWalletIds: includeWalletIds, // Optional
featuredWalletIds: featuredWalletIds, // Optional
excludeWalletIds: excludeWalletIds, // Optional
})
}

Expand All @@ -68,6 +75,7 @@ export class JSWeb3Modal {
showWallets: boolean,
walletFeatures: boolean,
transportBuilder: JSTransportBuilder | undefined

): Config {
const config = Web3modal.defaultWagmiConfig({
chains: chainsFromIds(chains),
Expand All @@ -80,6 +88,7 @@ export class JSWeb3Modal {
walletFeatures: walletFeatures
},
client: !transportBuilder ? undefined : this.#clientBuilder(transportBuilder),

})
JSWagmiContext.instance.setConfig(configKey, config)
return config
Expand Down

0 comments on commit 5e97e72

Please sign in to comment.