Skip to content

Commit

Permalink
Merge pull request #108 from blackbeard002/deploy
Browse files Browse the repository at this point in the history
Deployed mock contracts #100 and  approve scripts to aid swaps #99
  • Loading branch information
0xneves authored Dec 21, 2023
2 parents 5ead9f9 + e40afe7 commit f691528
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/approve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ethers } from "ethers";

export async function approve(
contract: ethers.Contract,
spender: string,
amountOrId: bigint,
) {
try {
if (ethers.utils.isAddress(spender)) {
// Approve tokens
const tx = await contract.approve(spender, amountOrId);

// Wait for the transaction to be mined
await tx.wait();

// Return the transaction response
return tx;
} else {
throw new Error("Invalid Ethereum address");
}
} catch (error) {
console.error(error);
process.exitCode = 1;
}
}
34 changes: 34 additions & 0 deletions scripts/deployMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ethers } from "hardhat";
import { deploy } from "../test/utils/utils";

export async function deployMock(signer: any) {
// Deploy in the currrent network and return the contract instance
const MockERC20 = await deploy("MockERC20", signer);
const MockERC721 = await deploy("MockERC721", signer);

// Log Contract address, the Tx then return the Contract instance of MockERC20
console.log(
"\nDEPLOY:\nContract %s \nDeployed to %s \nAt Tx %s",
"MockERC20",
MockERC20.address,
MockERC20.deployTransaction.hash,
);

// Log Contract address, the Tx then return the Contract instance of MockERC721
console.log(
"\nContract %s \nDeployed to %s \nAt Tx %s",
"MockERC721",
MockERC721.address,
MockERC721.deployTransaction.hash,
);

// Return the transaction response
return { MockERC20, MockERC721 };
}

ethers.getSigners().then((signers) => {
deployMock(signers[0]).catch((error) => {
console.error(error);
process.exitCode = 1;
});
});
25 changes: 25 additions & 0 deletions scripts/mint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ethers } from "ethers";

export async function mint(
contract: ethers.Contract,
amountOrId: bigint,
receiver: string,
) {
try {
if (ethers.utils.isAddress(receiver)) {
// Mint ERC tokens
const tx = await contract.mintTo(receiver, amountOrId);

// Wait for the transaction to be mined
await tx.wait();

// Return the transaction response
return tx;
} else {
throw new Error("Invalid Ethereum address");
}
} catch (error) {
console.error(error);
process.exitCode = 1;
}
}

0 comments on commit f691528

Please sign in to comment.