Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mobile aurora #382

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/utils/arc_ipfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,45 @@ export async function mintSingleToCelo(singleMintProps) {

export async function mintSingleToAurora(singleMintProps) {
const { file, metadata, price, account, connector, dispatch, setLoader, mainnet } = singleMintProps;
if (connector.isWalletConnect) {
const provider = new ethers.providers.Web3Provider(connector);
const signer = provider.getSigner();
dispatch(setLoader("uploading 1 of 1"));
const asset = await connectAndMint(file, metadata, file.name, dispatch);
const uintArray = asset.metadata.toLocaleString();
const id = parseInt(uintArray.slice(0, 7).replace(/,/g, ""));
dispatch(setLoader("minting 1 of 1"));
const contract = new ethers.Contract(
mainnet
? process.env.REACT_APP_AURORA_MAINNET_SINGLE_ADDRESS
: process.env.REACT_APP_AURORA_TESTNET_SINGLE_ADDRESS,
mintSingle,
signer
);
const ethNonce = await signer.getTransactionCount();
const tx = {
from: account,
to: mainnet
? process.env.REACT_APP_AURORA_MAINNET_SINGLE_ADDRESS
: process.env.REACT_APP_AURORA_TESTNET_SINGLE_ADDRESS,
// gasLimit: ethers.utils.hexlify(250000), change tx from legacy later
// gasPrice: ethers.utils.parseUnits('5', "gwei"),
data: contract.interface.encodeFunctionData("mint", [account, id, 1, asset.url, "0x"]),
nonce: ethNonce,
};
try {
const result = await signer.sendTransaction(tx);
await result.wait();
dispatch(setLoader(""));
return mainnet ? `https://aurorascan.dev/tx/${result.hash}` : `https://testnet.aurorascan.dev/tx/${result.hash}`;
} catch (error) {
dispatch(setLoader(""));
return {
error,
message: error.message ? error.message : "something went wrong! check your connected network and try again.",
};
}
}
const signer = await connector.getSigner();
dispatch(setLoader("uploading 1 of 1"));
const asset = await connectAndMint(file, metadata, file.name, 4);
Expand Down