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

feat: upgrade web3modal #308

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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 .github/workflows/pr-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: 'Release PR to npm'
runs-on: buildjet-4vcpu-ubuntu-2204
# Comment if:false to enable release PR to npm
if: false
# if: false
permissions: write-all
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@playwright/test": "1.46.1",
"@types/node": "20.12.11",
"dotenv": "16.4.5",
"fuels": "0.93.0"
"fuels": "0.94.8"
},
"engines": {
"node": ">=18",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@wagmi/connectors": "5.1.7",
"@wagmi/core": "2.13.4",
"clsx": "2.1.1",
"fuels": "0.94.6",
"fuels": "0.94.8",
"react": "18.3.1",
"react-dom": "18.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@fuels/react": "workspace:*",
"@tanstack/react-query": "5.35.1",
"@wagmi/connectors": "5.1.7",
"fuels": "0.94.6",
"fuels": "0.94.8",
"next": "14.2.3",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/bako-safe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"socket.io-client": "4.7.2"
},
"peerDependencies": {
"fuels": ">=0.94.6",
"fuels": ">=0.94.98",
"socket.io-client": "4.7.2"
},
"devDependencies": {
"fuels": "0.94.6",
"fuels": "0.94.8",
"tsup": "8.0.2",
"typescript": "5.4.2",
"undici": "6.9.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/burner-wallet-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"test": "vitest"
},
"peerDependencies": {
"fuels": ">=0.94.6"
"fuels": ">=0.94.98"
},
"devDependencies": {
"@fuel-connectors/common": "workspace:*",
"fuels": "0.94.6",
"fuels": "0.94.8",
"jsdom": "24.0.0",
"tsup": "8.0.2",
"typescript": "5.4.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test": "vitest"
},
"peerDependencies": {
"fuels": ">=0.94.6"
"fuels": ">=0.94.98"
},
"dependencies": {
"@ethersproject/bytes": "5.7.0",
Expand All @@ -37,7 +37,7 @@
},
"devDependencies": {
"@types/memoizee": "0.4.11",
"fuels": "0.94.6",
"fuels": "0.94.8",
"terser": "5.31.0",
"tsup": "8.0.2",
"typescript": "5.4.5",
Expand Down
13 changes: 7 additions & 6 deletions packages/connectors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
"ts:check": "tsc --noEmit"
},
"peerDependencies": {
"fuels": ">=0.94.6"
"fuels": ">=0.94.98"
},
"dependencies": {
"@ethereumjs/util": "9.0.3",
"@ethersproject/bytes": "5.7.0",
"@fuels/connectors": "0.29.2",
"@solana/web3.js": "1.93.1",
"@wagmi/core": "2.13.4",
"@web3modal/core": "5.0.0",
"@web3modal/scaffold": "5.0.0",
"@web3modal/solana": "5.0.0",
"@web3modal/wagmi": "5.0.0",
"@web3modal/core": "5.1.10",
"@web3modal/scaffold": "5.1.1",
"@web3modal/solana": "5.1.10",
"@web3modal/wagmi": "5.1.10",
"rpc-websockets": "7.11.0",
"socket.io-client": "4.7.2",
"viem": "2.20.1"
Expand All @@ -42,7 +43,7 @@
"@fuel-connectors/fuelet-wallet": "workspace:*",
"@fuel-connectors/solana-connector": "workspace:*",
"@fuel-connectors/walletconnect-connector": "workspace:*",
"fuels": "0.94.6",
"fuels": "0.94.8",
"terser": "5.31.0",
"tsup": "8.0.2",
"typescript": "5.4.5"
Expand Down
9 changes: 6 additions & 3 deletions packages/connectors/src/defaultConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import { FueletWalletConnector } from '@fuel-connectors/fuelet-wallet';
import { SolanaConnector } from '@fuel-connectors/solana-connector';
import { WalletConnectConnector } from '@fuel-connectors/walletconnect-connector';
import type { Config } from '@wagmi/core';
import type { ProviderType } from '@web3modal/solana/dist/types/src/utils/scaffold';

import type { FuelConnector } from 'fuels';

type DefaultConnectors = {
devMode?: boolean;
wcProjectId?: string;
burnerWalletConfig?: BurnerWalletConfig;
ethWagmiConfig?: Config;
solanaConfig?: ProviderType;
solanaConfig?: ConstructorParameters<
typeof SolanaConnector
>[0]['solanaConfig'];
chainId?: number;
};

Expand All @@ -26,7 +28,7 @@ export function defaultConnectors({
wcProjectId,
burnerWalletConfig,
ethWagmiConfig,
solanaConfig: _solanaConfig,
solanaConfig,
chainId,
}: DefaultConnectors = {}): Array<FuelConnector> {
const connectors: Array<FuelConnector> = [
Expand All @@ -41,6 +43,7 @@ export function defaultConnectors({
new SolanaConnector({
projectId: wcProjectId,
chainId,
solanaConfig,
}),
];

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@fuel-ts/errors": "0.93.0",
"@fuel-ts/versions": "0.93.0",
"fuels": "0.94.6",
"fuels": "0.94.8",
"typedoc-plugin-markdown": "^3.15.3"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/evm-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test": "vitest"
},
"peerDependencies": {
"fuels": ">=0.94.6"
"fuels": ">=0.94.98"
},
"dependencies": {
"@ethereumjs/util": "9.0.3",
Expand All @@ -31,7 +31,7 @@
"@fuel-connectors/common": "workspace:*",
"@fuel-connectors/evm-predicates": "workspace:*",
"@types/memoizee": "0.4.11",
"fuels": "0.94.6",
"fuels": "0.94.8",
"jsdom": "24.0.0",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/evm-predicates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"devDependencies": {
"@fuel-connectors/common": "workspace:*",
"fuels": "0.94.4",
"fuels": "0.94.8",
"tsx": "4.9.3",
"typescript": "5.4.5"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/fuel-development-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"test": "vitest"
},
"peerDependencies": {
"fuels": ">=0.94.6"
"fuels": ">=0.94.98"
},
"devDependencies": {
"@fuel-connectors/fuel-wallet": "workspace:*",
"fuels": "0.94.6",
"fuels": "0.94.8",
"tsup": "8.0.2",
"typescript": "5.4.5",
"undici": "6.16.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/fuel-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"test": "vitest"
},
"peerDependencies": {
"fuels": ">=0.94.6"
"fuels": ">=0.94.98"
},
"dependencies": {
"json-rpc-2.0": "1.7.0"
},
"devDependencies": {
"events": "3.3.0",
"fuels": "0.94.6",
"fuels": "0.94.8",
"tsup": "8.0.2",
"typescript": "5.4.5",
"undici": "6.16.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/fuelet-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"test": "vitest"
},
"peerDependencies": {
"fuels": ">=0.94.6"
"fuels": ">=0.94.98"
},
"devDependencies": {
"@fuel-connectors/fuel-wallet": "workspace:*",
"fuels": "0.94.6",
"fuels": "0.94.8",
"tsup": "8.0.2",
"typescript": "5.4.5",
"undici": "6.16.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"peerDependencies": {
"@tanstack/react-query": ">=5.0.0",
"fuels": ">=0.94.6",
"fuels": ">=0.94.98",
"react": ">=18.0.0"
},
"dependencies": {
Expand All @@ -38,7 +38,7 @@
"@tanstack/react-query": "5.35.1",
"@types/react": "18.3.1",
"compare-versions": "6.1.0",
"fuels": "0.94.6",
"fuels": "0.94.8",
"react": "18.3.1",
"tsup": "7.3.0",
"tsx": "4.9.3",
Expand Down
10 changes: 5 additions & 5 deletions packages/solana-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"test": "vitest"
},
"peerDependencies": {
"@web3modal/core": ">=5.0.0",
"@web3modal/scaffold": ">=5.0.0",
"fuels": ">=0.94.6"
"@web3modal/core": ">=5.1.10",
"@web3modal/scaffold": ">=5.1.1",
"fuels": ">=0.94.98"
},
"dependencies": {
"@ethereumjs/util": "9.0.3",
Expand All @@ -38,8 +38,8 @@
"devDependencies": {
"@fuel-connectors/common": "workspace:*",
"@types/memoizee": "0.4.11",
"@web3modal/core": "5.0.0",
"fuels": "0.94.6",
"@web3modal/core": "5.1.10",
"fuels": "0.94.8",
"jsdom": "24.0.0",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
Expand Down
26 changes: 14 additions & 12 deletions packages/solana-connector/src/SolanaConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import {
} from '@fuel-connectors/common';
import { ApiController } from '@web3modal/core';
import type { Web3Modal } from '@web3modal/solana';
import type { Provider } from '@web3modal/solana/dist/types/src/utils/scaffold';
import {
CHAIN_IDS,
type ConnectorMetadata,
FuelConnectorEventTypes,
Provider as FuelProvider,
Provider,
type TransactionRequestLike,
} from 'fuels';
import { SOLANA_ICON, TESTNET_URL } from './constants';
import { PREDICATE_VERSIONS } from './generated/predicates';
import type { SolanaConfig } from './types';
import type { SolanaConfig, SolanaWalletProvider } from './types';
import { type SolanaPredicateRoot, txIdEncoders } from './utils';
import { createSolanaConfig, createSolanaWeb3ModalInstance } from './web3Modal';

Expand Down Expand Up @@ -90,7 +90,7 @@ export class SolanaConnector extends PredicateConnector {
switch (event.data.event) {
case 'MODAL_OPEN':
// Ensures that the Solana Web3Modal config is applied over pre-existing states (e.g. WC Connect Web3Modal)
this.createModal();
if (!this.web3Modal) this.createModal();
break;
case 'CONNECT_SUCCESS': {
const address = this.web3Modal.getAddress() || '';
Expand All @@ -100,10 +100,9 @@ export class SolanaConnector extends PredicateConnector {
this._emitConnected(true);
break;
}
case 'DISCONNECT_SUCCESS': {
case 'DISCONNECT_SUCCESS':
this._emitConnected(false);
break;
}
}
}),
);
Expand Down Expand Up @@ -136,7 +135,7 @@ export class SolanaConnector extends PredicateConnector {
}

protected async requireConnection() {
if (!this.web3Modal) this.createModal();
// if (!this.web3Modal) this.createModal();
}

protected getWalletAdapter(): PredicateWalletAdapter {
Expand Down Expand Up @@ -190,7 +189,7 @@ export class SolanaConnector extends PredicateConnector {
}

public async connect(): Promise<boolean> {
this.createModal();
if (!this.web3Modal) this.createModal();

return new Promise((resolve) => {
this.web3Modal.open();
Expand Down Expand Up @@ -245,15 +244,18 @@ export class SolanaConnector extends PredicateConnector {
);

const txId = await this.encodeTxId(transactionId);
const provider: Maybe<Provider> =
this.web3Modal.getWalletProvider() as Provider;
const provider: Maybe<SolanaWalletProvider> =
this.web3Modal.getWalletProvider();
if (!provider) {
throw new Error('No provider found');
}

const signedMessage: Uint8Array = (await provider.signMessage(
txId,
)) as Uint8Array;
const signedMessage: Uint8Array = (await provider.request({
method: 'signMessage',
params: {
message: txId,
},
})) as Uint8Array;
transactionRequest.witnesses[predicateSignatureIndex] = signedMessage;

// Send transaction
Expand Down
3 changes: 3 additions & 0 deletions packages/solana-connector/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PredicateConfig } from '@fuel-connectors/common';
import type { Web3Modal } from '@web3modal/solana';
import type { ProviderType } from '@web3modal/solana/dist/types/src/utils/scaffold';
import type { Provider as FuelProvider } from 'fuels';

Expand Down Expand Up @@ -38,3 +39,5 @@ export enum SolanaEvents {
SESSION_UPDATE = 'session_update',
SESSION_DELETE = 'session_delete',
}

export type SolanaWalletProvider = ReturnType<Web3Modal['getWalletProvider']>;
Loading
Loading