Skip to content

Commit

Permalink
feat: add contract address overrides to refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
simodrws committed Jul 27, 2023
1 parent bd345d5 commit 0010c33
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
6 changes: 1 addition & 5 deletions src/provider/masa-context-provider.tsx
Expand Up @@ -68,10 +68,6 @@ export interface MasaContextProviderProps extends MasaShape {
// signer?: Signer;
// chainsToUse?: Array<keyof MasaNetworks>;
// walletsToUse?: string[];
// contractAddressOverrides?: {
// SoulNameAddress: string;
// SoulStoreAddress: string;
// };
soulNameStyle?: string;
}

Expand All @@ -96,7 +92,7 @@ export const MasaContextProvider = ({
fullScreenGallery,
// api url override
// apiUrl,
// contractAddressOverrides,

useRainbowKitWalletConnect = false,
soulNameStyle,
}: MasaContextProviderProps): JSX.Element => {
Expand Down
6 changes: 6 additions & 0 deletions src/provider/masa-provider.tsx
Expand Up @@ -16,11 +16,16 @@ export const MasaProvider = ({
chainsToUse,
walletsToUse,
rainbowKitModalSize,
contractAddressOverrides,
...args
}: MasaContextProviderProps & {
chainsToUse?: Array<keyof MasaNetworks>;
walletsToUse?: ('metamask' | 'valora' | 'walletconnect')[];
rainbowKitModalSize?: 'compact' | 'wide';
contractAddressOverrides?: {
SoulNameAddress: string;
SoulStoreAddress: string;
};
}): JSX.Element => {
const { forceNetwork, environmentName, company, verbose } = args;
return (
Expand Down Expand Up @@ -49,6 +54,7 @@ export const MasaProvider = ({
'basegoerli',
'unknown',
],
contractAddressOverrides,
masaConfig: {
networkName: 'ethereum',
environment: environmentName ?? 'dev',
Expand Down
10 changes: 7 additions & 3 deletions src/refactor/config.ts
Expand Up @@ -3,6 +3,7 @@ import type {
MasaArgs,
NetworkName,
} from '@masa-finance/masa-sdk';
import type { WagmiConfigProps } from 'wagmi';

export interface ArweaveConfig {
port?: string;
Expand All @@ -18,8 +19,11 @@ export interface MasaReactConfig {
arweaveConfig?: ArweaveConfig;
forceChain?: NetworkName;
verbose?: boolean;
wagmiConfig?: unknown;

wagmiConfig?: WagmiConfigProps;
contractAddressOverrides?: {
SoulNameAddress: string;
SoulStoreAddress: string;
};
rainbowkitConfig?: {
modalSize: 'compact' | 'wide';
};
Expand Down Expand Up @@ -62,4 +66,4 @@ export const mergeConfigWithDefault = (config: Partial<MasaReactConfig>) =>
...defaultConfig.masaConfig,
...config.masaConfig,
},
} as MasaReactConfig);
}) as MasaReactConfig;
14 changes: 5 additions & 9 deletions src/refactor/masa-client/use-masa-client.ts
Expand Up @@ -6,27 +6,23 @@ import { useMasaSDK } from './use-masa-sdk';
import { useNetwork } from '../wallet-client/network';

export const useMasaClient = () => {
const { masaConfig } = useConfig();
const { masaConfig, contractAddressOverrides } = useConfig();
const { signer, isDisconnected, address } = useWallet();

const { activeChainId, currentNetwork, activeNetwork } = useNetwork();


const networkName = activeNetwork === "homestead"
? 'ethereum'
: currentNetwork?.networkName;



const networkName =
activeNetwork === 'homestead' ? 'ethereum' : currentNetwork?.networkName;

const masa = useMasaSDK(
{
address,
signer: isDisconnected ? undefined : signer,
...masaConfig,
environmentName: masaConfig.environment,
contractAddressOverrides,
// NOTE: mismatch of homestead (wagmi) vs ethereum (masa)
networkName
networkName,
},
[
address,
Expand Down

0 comments on commit 0010c33

Please sign in to comment.