Skip to content

Commit

Permalink
move eager connect to internal part of wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
NorbertBodziony committed Jun 3, 2022
1 parent 2e85056 commit 6633aee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
12 changes: 0 additions & 12 deletions examples/react/src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ const Content: React.FC = () => {
const [messages, setMessages] = useState<Array<Message>>([]);
const [loading, setLoading] = useState<boolean>(false);

// Try eager connect on app launch
useEffect(() => {
const eagerConnect = async () => {
const state = selector.store.getState();
if (state.selectedWalletId === "nightly") {
const wallet = (await selector.wallet()) as InjectedWallet;
wallet.signIn({ contractId: CONTRACT_ID });
}
};
eagerConnect();
}, []);

const getAccount = useCallback(async (): Promise<Account | null> => {
if (!accountId) {
return null;
Expand Down
5 changes: 5 additions & 0 deletions packages/nightly/src/lib/nightly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ const Nightly: WalletBehaviourFactory<InjectedWallet> = async ({
}) => {
const _state = setupNightlyState(metadata);
const provider = new JsonRpcProvider({ url: options.network.nodeUrl });
const state = store.getState();

if (state.selectedWalletId === "nightly") {
await _state.wallet.connect();
}
return {
// nightly does not support delegating signing right now
async signIn() {
Expand Down

0 comments on commit 6633aee

Please sign in to comment.