Skip to content

Commit

Permalink
New version
Browse files Browse the repository at this point in the history
  • Loading branch information
evilgoku committed Aug 12, 2023
1 parent 3dbf852 commit c9cb97d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions web3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ async function sendContract(method, abi, contract, args, value, gasLimit, gasPri
// const from = (await web3.eth.getAccounts())[0];
try{
if (parseInt(window.web3ChainId) === 503129905 && method === 'addMoto') {
if (window.ethereum) {
await window.ethereum.request({method: 'eth_requestAccounts'});
window.web3 = new Web3(window.ethereum);
}
const usdc = new window.web3.eth.Contract(JSON.parse(usdcABI), "0x717d43399ab3a8aada669CDC9560a6BAfdeA9796");
const core = new window.web3.eth.Contract(JSON.parse(abi), contract);
let getMinimalFee = await core.methods.getMinimalFee().call();
Expand Down Expand Up @@ -1109,6 +1113,10 @@ async function methodCall(abi, nftUniV3ContractAddress, method, args, value) {
if (parseInt(window.web3ChainId) === 503129905) {
// let ws = getWebSocketPublicClient;
if (method === "valueInMainCoin") {
if (window.ethereum) {
await window.ethereum.request({method: 'eth_requestAccounts'});
window.web3 = new Web3(window.ethereum);
}
const nft = new window.web3.eth.Contract(JSON.parse(abi), nftUniV3ContractAddress);

const type = await nft.methods.getTypeForId(args[0]).call()
Expand Down Expand Up @@ -1267,6 +1275,10 @@ async function getTxStatus(transactionHash) {
if (parseInt(window.web3ChainId) === 503129905) {
let response;
try {
if (window.ethereum) {
await window.ethereum.request({method: 'eth_requestAccounts'});
window.web3 = new Web3(window.ethereum);
}
const from = (await window.web3.eth.getAccounts())[0];
response = await window.web3.eth.getTransactionReceipt(transactionHash);
} catch (error) {
Expand Down

0 comments on commit c9cb97d

Please sign in to comment.