Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #77 from factchain/use-new-contract-methods
Browse files Browse the repository at this point in the history
Use new contract methods
  • Loading branch information
YBadiss authored Feb 11, 2024
2 parents 64a1739 + f56c7a0 commit b75ccaf
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-nft-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
chain-id: '11155111'
rpc-url: ${{ secrets.RPC_ETH_SEPOLIA_HTTPS }}
deployer-pk: ${{ secrets.DEPLOYER_PK }}
constructor-args: '${{ vars.OWNER_ADDRESS }} ${{ vars.FACTCHAINSFT_ADDRESS }} https://gateway.pinata.cloud/ipfs/'
constructor-args: '${{ vars.NFT_OWNER_ADDRESS }} ${{ vars.FACTCHAINSFT_ADDRESS }} https://gateway.pinata.cloud/ipfs/'
verify: true
etherscan-url: 'https://sepolia.etherscan.io'
etherscan-api-key: ${{ secrets.ETHERSCAN_SEPOLIA_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/deploy-sft-contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
chain-id: '11155111'
rpc-url: ${{ secrets.RPC_ETH_SEPOLIA_HTTPS }}
deployer-pk: ${{ secrets.DEPLOYER_PK }}
constructor-args: '${{ vars.OWNER_ADDRESS }}'
constructor-args: '${{ vars.NFT_OWNER_ADDRESS }}'
verify: true
etherscan-url: 'https://sepolia.etherscan.io'
etherscan-api-key: ${{ secrets.ETHERSCAN_SEPOLIA_API_KEY }}
4 changes: 3 additions & 1 deletion fc-community-extension/src/pages/createNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ const createNote = async (content) => {
const address = await provider.requestAddress();
logger.log('Creator address', address);
const contract = await provider.getMainContract();
const minimumStakePerNote = await contract.minimumStakePerNote();
return await makeTransactionCall(
contract,
async (c) => await c.createNote(postUrl, content, { value: 100_000 })
async (c) =>
await c.createNote(postUrl, content, { value: minimumStakePerNote })
);
};

Expand Down
19 changes: 5 additions & 14 deletions fc-community-extension/src/pages/mintFactchainNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import { makeOpenseaUrl, makeTransactionUrl } from '../utils/constants';
import { createFactchainProvider, makeTransactionCall } from '../utils/web3';
import { FCHero, FCLoader } from './components';

// TODO
// 1. Find NFT id, if does not exist show error
// 2. Get NFT image and Opensea URL
// 3. If can still mint
// 3.a. Create mint transaction
// 3.b. Show success!
// 4. Else, show a "sorry" message, and direct the user to buy from Opensea

export function FCMintFactchainNote({
postUrl,
creatorAddress,
Expand Down Expand Up @@ -76,9 +68,9 @@ export function FCMintFactchainNote({
</Match>
<Match when={factchainNftId() && !nftSupply() && openseaUrl()}>
<div style="margin-bottom: 50px; font-size: 150%; text-align: center; position: relative; top:50%; left: 50%; transform: translate(-50%, -50%);">
All NFTs have already been minted for this note
All NFTs have already been minted for this note.
</div>
<div style="margin-bottom: 10px; font-size: 110%; text-align: center; position: relative; top:50%; left: 50%; transform: translate(-50%, -50%);">
<div style="margin-bottom: 10px; font-size: 150%; text-align: center; position: relative; top:50%; left: 50%; transform: translate(-50%, -50%);">
Head over to{' '}
<a href={openseaUrl()} target="_blank">
OpenSea
Expand Down Expand Up @@ -132,7 +124,6 @@ const creatorAddress = await chrome.runtime.sendMessage({
target: 'creatorAddress',
});
const provider = await createFactchainProvider();
// TODO get correct contract
const nftContract = await provider.getNftContract();
console.log(`nftContract (${nftContract.target})`, nftContract);
const sftContract = await provider.getSftContract();
Expand All @@ -141,18 +132,18 @@ console.log(`sftContract (${sftContract.target})`, sftContract);
const getFactchainNftInfo = async (postUrl, creatorAddress) => {
console.log('Getting factchain note info', postUrl, creatorAddress);
const id = await nftContract.noteIds(postUrl, creatorAddress);
// TODO get supply from contract
const supply = 20;
const supply = await nftContract.supply(id);
return { id, supply };
};

const mintFactchainNote = async (factchainNoteId) => {
const value = 1;
console.log('Minting Factchain Note');
const mintPrice = await sftContract.mintPrice();
return await makeTransactionCall(
sftContract,
async (c) =>
await c.mint(factchainNoteId, value, { value: value * 1_000_000 })
await c.mint(factchainNoteId, value, { value: value * mintPrice })
);
};

Expand Down
3 changes: 2 additions & 1 deletion fc-community-extension/src/pages/mintXNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ console.log(`contract address ${contract.target}`);
const mintXNote = async (xNoteId) => {
const value = 1;
console.log('Minting X Note');
const mintPrice = await contract.mintPrice();
return await makeTransactionCall(
contract,
async (c) =>
Expand All @@ -121,7 +122,7 @@ const mintXNote = async (xNoteId) => {
value,
xNoteId.hash.startsWith('0x') ? xNoteId.hash : `0x${xNoteId.hash}`,
xNoteId.signature,
{ value: value * 1_000_000 }
{ value: value * mintPrice }
)
);
};
Expand Down
3 changes: 2 additions & 1 deletion fc-community-extension/src/pages/rateNotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ const rateNote = async (note, rating) => {
);

const contract = await provider.getMainContract();
const minimumStakePerRating = await contract.minimumStakePerRating();
return await makeTransactionCall(
contract,
async (c) =>
await c.rateNote(note.postUrl, note.creatorAddress, rating, {
value: 10_000,
value: minimumStakePerRating,
})
);
};
Expand Down
149 changes: 123 additions & 26 deletions fc-community-extension/src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,32 @@ export const FC_MAIN_CONTRACT_ABI = [
],
stateMutability: 'view',
},
{
type: 'function',
name: 'minimumStakePerNote',
inputs: [],
outputs: [
{
name: '',
type: 'uint64',
internalType: 'uint64',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'minimumStakePerRating',
inputs: [],
outputs: [
{
name: '',
type: 'uint64',
internalType: 'uint64',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'noteRaters',
Expand Down Expand Up @@ -240,6 +266,32 @@ export const FC_MAIN_CONTRACT_ABI = [
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'setMinimumStakePerNote',
inputs: [
{
name: '_miniumStakePerNote',
type: 'uint64',
internalType: 'uint64',
},
],
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'setMinimumStakePerRating',
inputs: [
{
name: '_minimumStakePerRating',
type: 'uint64',
internalType: 'uint64',
},
],
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'supportsInterface',
Expand Down Expand Up @@ -653,19 +705,6 @@ export const FC_X_CONTRACT_ABI = [
],
stateMutability: 'view',
},
{
type: 'function',
name: 'MINT_PRICE',
inputs: [],
outputs: [
{
name: '',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'SUPPLY_EXHAUSTED',
Expand Down Expand Up @@ -829,6 +868,19 @@ export const FC_X_CONTRACT_ABI = [
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'mintPrice',
inputs: [],
outputs: [
{
name: '',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'owner',
Expand Down Expand Up @@ -939,6 +991,19 @@ export const FC_X_CONTRACT_ABI = [
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'setMintPrice',
inputs: [
{
name: '_mintPrice',
type: 'uint256',
internalType: 'uint256',
},
],
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'setURI',
Expand Down Expand Up @@ -2115,19 +2180,6 @@ export const FC_SFT_CONTRACT_ABI = [
],
stateMutability: 'view',
},
{
type: 'function',
name: 'MINT_PRICE',
inputs: [],
outputs: [
{
name: '',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'balanceOf',
Expand Down Expand Up @@ -2252,6 +2304,19 @@ export const FC_SFT_CONTRACT_ABI = [
outputs: [],
stateMutability: 'payable',
},
{
type: 'function',
name: 'mintPrice',
inputs: [],
outputs: [
{
name: '',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'owner',
Expand Down Expand Up @@ -2362,6 +2427,38 @@ export const FC_SFT_CONTRACT_ABI = [
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'setMintPrice',
inputs: [
{
name: '_mintPrice',
type: 'uint256',
internalType: 'uint256',
},
],
outputs: [],
stateMutability: 'nonpayable',
},
{
type: 'function',
name: 'supply',
inputs: [
{
name: '',
type: 'uint256',
internalType: 'uint256',
},
],
outputs: [
{
name: '',
type: 'uint256',
internalType: 'uint256',
},
],
stateMutability: 'view',
},
{
type: 'function',
name: 'supportsInterface',
Expand Down

0 comments on commit b75ccaf

Please sign in to comment.