Skip to content

Commit

Permalink
fix: use wallet provider for all provider calls (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-ziv authored May 1, 2022
1 parent d68004e commit 7d75dc8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/providers/BlockHashProvider/BlockHashProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useState} from 'react';

import {useConfig} from '../../hooks';
import {starknet} from '../../libs';
import {getStarknet} from '../../libs';
import {BlockHashContext} from './block-hash-context';

export const BlockHashProvider = ({children}) => {
const {pollBlockNumberInterval} = useConfig();
const [blockHash, setBlockHash] = useState();

const fetchBlockHash = useCallback(async () => {
const {block_hash} = await starknet.defaultProvider.getBlock();
const {block_hash} = await getStarknet().provider.getBlock();
setBlockHash(block_hash);
}, []);

Expand Down
4 changes: 2 additions & 2 deletions src/providers/TransfersLogProvider/TransfersLogProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useDeepCompareEffect from 'use-deep-compare-effect';
import envs from '../../config/envs';
import {isCompleted, isConsumed} from '../../enums';
import {useLogger} from '../../hooks';
import {starknet} from '../../libs';
import {getStarknet} from '../../libs';
import utils from '../../utils';
import {useBlockHash} from '../BlockHashProvider';
import {useTokens} from '../TokensProvider';
Expand Down Expand Up @@ -38,7 +38,7 @@ export const TransfersLogProvider = ({children}) => {
}
try {
logger.log(`Checking tx status ${transfer.l2hash}`);
const {tx_status} = await starknet.defaultProvider.getTransactionStatus(transfer.l2hash);
const {tx_status} = await getStarknet().provider.getTransactionStatus(transfer.l2hash);
if (transfer.status !== tx_status) {
logger.log(`Status changed from ${transfer.status}->${tx_status}`);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/blockchain/starknet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ChainInfo, isRejected, TransactionStatusStep} from '../../enums';
import {getStarknet, starknet} from '../../libs';

const {Contract, defaultProvider, stark, hash, number} = starknet;
const {Contract, stark, hash, number} = starknet;

export const createContract = (address, ABI) => {
return new Contract(ABI, address, getStarknet().provider);
Expand Down Expand Up @@ -34,7 +34,7 @@ export const waitForTransaction = async (transactionHash, requiredStatus, retryI
let processing = false;
const intervalId = setInterval(async () => {
if (processing) return;
const statusPromise = defaultProvider.getTransactionStatus(transactionHash);
const statusPromise = getStarknet().provider.getTransactionStatus(transactionHash);
processing = true;
try {
const {tx_status} = await statusPromise;
Expand Down

0 comments on commit 7d75dc8

Please sign in to comment.