From ff76482b4df75e20566dbab5fde9f78e4f258d63 Mon Sep 17 00:00:00 2001 From: Yacine Badiss Date: Sun, 11 Feb 2024 20:07:26 +0100 Subject: [PATCH 1/2] [extension] update contract abis and use supply + contract constants --- .../src/pages/createNote.js | 4 +- .../src/pages/mintFactchainNote.js | 19 +-- fc-community-extension/src/pages/mintXNote.js | 3 +- fc-community-extension/src/pages/rateNotes.js | 3 +- fc-community-extension/src/utils/constants.js | 149 +++++++++++++++--- 5 files changed, 135 insertions(+), 43 deletions(-) diff --git a/fc-community-extension/src/pages/createNote.js b/fc-community-extension/src/pages/createNote.js index bdb1946b..b57bd2c5 100644 --- a/fc-community-extension/src/pages/createNote.js +++ b/fc-community-extension/src/pages/createNote.js @@ -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 }) ); }; diff --git a/fc-community-extension/src/pages/mintFactchainNote.js b/fc-community-extension/src/pages/mintFactchainNote.js index 3e2b5880..fcf69820 100644 --- a/fc-community-extension/src/pages/mintFactchainNote.js +++ b/fc-community-extension/src/pages/mintFactchainNote.js @@ -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, @@ -76,9 +68,9 @@ export function FCMintFactchainNote({
- All NFTs have already been minted for this note + All NFTs have already been minted for this note.
-
+
Head over to{' '} OpenSea @@ -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(); @@ -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 }) ); }; diff --git a/fc-community-extension/src/pages/mintXNote.js b/fc-community-extension/src/pages/mintXNote.js index 9962babf..124f4455 100644 --- a/fc-community-extension/src/pages/mintXNote.js +++ b/fc-community-extension/src/pages/mintXNote.js @@ -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) => @@ -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 } ) ); }; diff --git a/fc-community-extension/src/pages/rateNotes.js b/fc-community-extension/src/pages/rateNotes.js index b3709ed4..9d018f80 100644 --- a/fc-community-extension/src/pages/rateNotes.js +++ b/fc-community-extension/src/pages/rateNotes.js @@ -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, }) ); }; diff --git a/fc-community-extension/src/utils/constants.js b/fc-community-extension/src/utils/constants.js index b5392165..d9b06c3d 100644 --- a/fc-community-extension/src/utils/constants.js +++ b/fc-community-extension/src/utils/constants.js @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', @@ -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', From f56c7a041070dae004c31e768d3a97bdc526a964 Mon Sep 17 00:00:00 2001 From: Yacine Badiss Date: Sun, 11 Feb 2024 20:09:14 +0100 Subject: [PATCH 2/2] [contracts] update default owner for NFT contracts --- .github/workflows/deploy-nft-contract.yml | 2 +- .github/workflows/deploy-sft-contract.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-nft-contract.yml b/.github/workflows/deploy-nft-contract.yml index dcf390ec..8bf89779 100644 --- a/.github/workflows/deploy-nft-contract.yml +++ b/.github/workflows/deploy-nft-contract.yml @@ -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 }} diff --git a/.github/workflows/deploy-sft-contract.yml b/.github/workflows/deploy-sft-contract.yml index 312106bb..55a29c1b 100644 --- a/.github/workflows/deploy-sft-contract.yml +++ b/.github/workflows/deploy-sft-contract.yml @@ -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 }}