@layerswap/wallet-fuel 1.2.0 → 1.3.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import { KnownInternalNames } from "@layerswap/widget/internal";
2
+ export const name = 'Fuel';
3
+ export const id = 'fuel';
4
+ export const commonSupportedNetworks = [
5
+ KnownInternalNames.Networks.FuelTestnet,
6
+ KnownInternalNames.Networks.FuelDevnet,
7
+ KnownInternalNames.Networks.FuelMainnet
8
+ ];
@@ -1,19 +1,25 @@
1
1
  import { KnownInternalNames } from "@layerswap/widget/internal";
2
+ import { name } from "./constants";
2
3
  export class FuelAddressUtilsProvider {
4
+ constructor() {
5
+ this.providerName = name;
6
+ }
3
7
  supportsNetwork(network) {
4
8
  return (KnownInternalNames.Networks.FuelMainnet.includes(network.name) || KnownInternalNames.Networks.FuelTestnet.includes(network.name));
5
9
  }
6
- isValidAddress(address) {
10
+ isValidAddress(props) {
11
+ const { address } = props;
7
12
  if (!address) {
8
13
  return false;
9
14
  }
10
15
  const hexRegex = /^[0-9a-fA-F]+$/;
11
- if (address.startsWith("0x")) {
12
- address = address.slice(2); // Remove the "0x" prefix
16
+ let addr = address;
17
+ if (addr.startsWith("0x")) {
18
+ addr = addr.slice(2); // Remove the "0x" prefix
13
19
  }
14
20
  else {
15
21
  return false;
16
22
  }
17
- return address.length === 64 && hexRegex.test(address);
23
+ return addr.length === 64 && hexRegex.test(addr);
18
24
  }
19
25
  }
@@ -1,19 +1,13 @@
1
1
  import { useConnectors, useFuel as useGlobalFuel } from '@fuels/react';
2
2
  import { FuelConnectorEventTypes } from '@fuel-ts/account';
3
3
  import { Address } from '@fuel-ts/address';
4
- import { useWalletStore, sleep, KnownInternalNames } from "@layerswap/widget/internal";
4
+ import { useWalletStore, sleep } from "@layerswap/widget/internal";
5
5
  import { useEffect, useMemo } from "react";
6
6
  import { BAKO_STATE } from "./connectors/bako-safe/Bako";
7
7
  import { resolveFuelWalletConnectorIcon } from './utils';
8
8
  import { useFuelTransfer } from './transferProvider/useFuelTransfer';
9
+ import { name, id, commonSupportedNetworks } from "./constants";
9
10
  export default function useFuelConnection({ networks }) {
10
- const commonSupportedNetworks = [
11
- KnownInternalNames.Networks.FuelTestnet,
12
- KnownInternalNames.Networks.FuelDevnet,
13
- KnownInternalNames.Networks.FuelMainnet
14
- ];
15
- const name = 'Fuel';
16
- const id = 'fuel';
17
11
  const { connectors } = useConnectors();
18
12
  const { fuel } = useGlobalFuel();
19
13
  const wallets = useWalletStore((state) => state.connectedWallets);
@@ -153,7 +147,7 @@ export default function useFuelConnection({ networks }) {
153
147
  });
154
148
  };
155
149
  }, [connectors]);
156
- const availableWalletsForConnect = connectors.map(c => {
150
+ const availableConnectors = connectors.map(c => {
157
151
  const isInstalled = c.installed && !c['dAppWindow'];
158
152
  return {
159
153
  name: c.name,
@@ -161,7 +155,8 @@ export default function useFuelConnection({ networks }) {
161
155
  icon: typeof c.metadata.image === 'string' ? c.metadata.image : (c.metadata.image?.dark.startsWith('data:') ? c.metadata.image.dark : `data:image/svg+xml;base64,${c.metadata.image && btoa(c.metadata.image.dark)}`),
162
156
  type: isInstalled ? 'injected' : 'other',
163
157
  installUrl: c.metadata.install.link,
164
- extensionNotFound: !c.installed
158
+ extensionNotFound: !c.installed,
159
+ providerName: name
165
160
  };
166
161
  });
167
162
  const provider = {
@@ -170,7 +165,7 @@ export default function useFuelConnection({ networks }) {
170
165
  switchAccount,
171
166
  switchChain,
172
167
  transfer,
173
- availableWalletsForConnect,
168
+ availableConnectors,
174
169
  autofillSupportedNetworks: commonSupportedNetworks,
175
170
  withdrawalSupportedNetworks: commonSupportedNetworks,
176
171
  asSourceSupportedNetworks: commonSupportedNetworks,