Skip to content

Commit

Permalink
feat: implement celo campaigns flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Another-DevX committed Jan 22, 2024
1 parent 6b1d092 commit 374f1e2
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ VITE_DOMAIN=localhost:8080
VITE_IPFS_NODE=cloudflare-ipfs.com
VITE_BLOCKNATIVE_DAPP_ID=032e2fb8-6c66-46a5-bf1c-a049ac7eded2
VITE_FATHOM_SITE_ID=xxx
VITE_COINGECKO_API_KEY=
VITE_COINGECKO_API_KEY="CG-hvqpJ5VxrKZr6zVNX9eJMotW"




Expand Down
5 changes: 4 additions & 1 deletion src/assets/data/contracts/celo.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@
"WeightedPool2TokensFactory": "",
"WeightedPoolFactory": "0xEB1055c017a1427726F01368C8247649c5A79bF9",
"YearnLinearPoolFactory": "",
"Multicall": "0xca11bde05977b3631167028862be2a173976ca11"
"Multicall": "0xca11bde05977b3631167028862be2a173976ca11",
"SimpleMinter": "0xd437fa025E43ca4578aD682Bcfb1B003041d48D1",
"RFNFT": "0xBA7d3fB1BBD73f4289C7FB42e8EC268EC9C32bE3",
"RFP": "0x74072b693f1Da8B74b24563Cbded727228c0A898"
}
7 changes: 5 additions & 2 deletions src/composables/campaigns/useAllocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { campaignsService } from '@/services/campaigns/campaigns.service';
import useWeb3 from '@/services/web3/useWeb3';

export function useAllocations() {
const { account } = useWeb3();
const { account, chainId } = useWeb3();
const queryKey = reactive(['currentAllocation']);
const queryFn = async () => {
return await campaignsService.getCurrentAllocation(account.value);
return await campaignsService.getCurrentAllocation(
chainId.value,
account.value
);
};

const { data: currentAllocation, isLoading } = useQuery(
Expand Down
7 changes: 5 additions & 2 deletions src/composables/campaigns/useRFNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useTransactions from '../useTransactions';
export function useRFNFT() {
const { addNotification } = useNotifications();
const { addTransaction } = useTransactions();
const { account } = useWeb3();
const { account, chainId } = useWeb3();
const isMintingNFT = ref(false);

const fetchNFTImage = async (ipfsHash: string) => {
Expand All @@ -28,7 +28,10 @@ export function useRFNFT() {

const queryFn = async () => {
try {
const data = await campaignsService.getCurrentNFT(account.value);
const data = await campaignsService.getCurrentNFT(
chainId.value,
account.value
);
if (data?.image) {
const ipfsHash = data.image.split('ipfs://')[1];
const imageData = await fetchNFTImage(ipfsHash);
Expand Down
67 changes: 61 additions & 6 deletions src/lib/abi/KolektivoRNFT.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "InsufficientPoints",
"type": "error"
},
{
"inputs": [],
"name": "InvalidTier",
Expand Down Expand Up @@ -85,6 +90,25 @@
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "LevelUp",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -137,12 +161,6 @@
"internalType": "uint256",
"name": "points",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newTier",
"type": "uint256"
}
],
"name": "PointsAdded",
Expand Down Expand Up @@ -254,6 +272,30 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "canLevelUp",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -376,6 +418,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "levelUp",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
3 changes: 3 additions & 0 deletions src/lib/config/celo/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const contracts: Contracts = {
gaugeRewardsHelper: '',
gaugeWorkingBalanceHelper: '',
gaugeCheckpointer: '',
simpleMinter: celo.SimpleMinter,
RFNFT: celo.RFNFT,
RFP: celo.RFP,
};

export default contracts;
8 changes: 4 additions & 4 deletions src/services/campaigns/campaigns.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default class CampaignsService {
this.addresses = configService.network.addresses;
}

public async getCurrentAllocation(userAddress?: Address) {
const provider = getRpcProviderService().getJsonProvider(Network.ALFAJORES);
public async getCurrentAllocation(chainId: Network, userAddress?: Address) {
const provider = getRpcProviderService().getJsonProvider(chainId);
if (!userAddress) return 0;
const currentUserAddress = await this.walletService.getUserAddress();
if (!currentUserAddress) return 0;
Expand All @@ -48,8 +48,8 @@ export default class CampaignsService {
return 0;
}

public async getCurrentNFT(userAddress?: Address) {
const provider = getRpcProviderService().getJsonProvider(Network.ALFAJORES);
public async getCurrentNFT(chainId: Network, userAddress?: Address) {
const provider = getRpcProviderService().getJsonProvider(chainId);
if (this.addresses.RFNFT) {
const currentNFTId = await call(provider, RFNFTAbi, [
this.addresses.RFNFT,
Expand Down

0 comments on commit 374f1e2

Please sign in to comment.