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

Integrated Mods contract #194

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/components/common/TokensGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const TokensGrid = () => {
ndcContributor,
ndcChampion,
gwgCoreContributor,
modToken,
} = useSelector((state) => state[ReducerNames.SBT]);

return (
Expand Down Expand Up @@ -98,6 +99,15 @@ const TokensGrid = () => {
<TokenDetails data={ndcContributor} />
</Item>
)}
{modToken && (
<Item imageSrc={ImageSrc.MOD}>
<ValidTokenComponent />
<h2 className="font-bold text-3xl my-1 mb-5">
My Mod Soul Bound Token
</h2>
<TokenDetails data={modToken} />
</Item>
)}
</div>
);
};
Expand Down
26 changes: 26 additions & 0 deletions src/pages/auth/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const Home = () => {
regen_issuer_contract,
vibe_issuer_contract,
kudos_issuer_contract,
mods_issuer,
} = getConfig();
useEffect(() => {
// fetching only when logged in (without steps) state active
Expand All @@ -36,6 +37,7 @@ const Home = () => {
fetchRegenToken();
fetchVibeToken();
fetchKudosToken();
fetchModsToken();
}
}, [activePageIndex]);

Expand Down Expand Up @@ -106,6 +108,30 @@ const Home = () => {
}
};

const fetchModsToken = async () => {
try {
const data = await wallet.viewMethod({
contractId: app_contract,
method: 'sbt_tokens_by_owner',
args: {
account: wallet.accountId,
issuer: mods_issuer,
},
});

if (data?.[0]?.[1]) {
for (const token of data[0][1]) {
// if class = 5 => Mods token
if (token.metadata.class === 5) {
dispatch(updateTokens({ type: TokenTypes.MOD, value: token }));
}
}
}
} catch (error) {
toast.error('An error occured while fetching Mods SBT details');
}
};

const fetchVibeToken = async () => {
try {
const data = await wallet.viewMethod({
Expand Down
8 changes: 7 additions & 1 deletion src/redux/reducer/sbtsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const sbtReducer = createSlice({
ndcContributor: null,
ndcChampion: null,
gwgCoreContributor: null,
modToken: null,
},
reducers: {
updateTokens: (state, action) => {
Expand Down Expand Up @@ -90,6 +91,9 @@ export const sbtReducer = createSlice({
case TokenTypes.NDC_Contributor:
state.ndcContributor = value;
break;
case TokenTypes.MOD:
state.modToken = value;
break;
default:
break;
}
Expand All @@ -102,7 +106,8 @@ export const sbtReducer = createSlice({
state.kudosToken ||
state.ndcChampion ||
state.ndcContributor ||
state.gwgCoreContributor;
state.gwgCoreContributor ||
state.modToken;
},
handleErrorMessage: (state, action) => {
state.error = action.payload;
Expand All @@ -118,6 +123,7 @@ export const sbtReducer = createSlice({
state.gwgCoreContributor = null;
state.ndcChampion = null;
state.ndcContributor = null;
state.modToken = null;
},
updateTokenRemoveStatus: (state, action) => {
state.tokenRemoveSuccess = !state.tokenRemoveSuccess;
Expand Down
1 change: 1 addition & 0 deletions src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function getConfig() {
succes_fractal_state: 'facescan',
regen_issuer_contract: 'issuer.regens.near',
vibe_issuer_contract: 'issuer.proofofvibes.near',
mods_issuer: 'gwg.sputnik-dao.near',
};
switch (environment) {
case 'prod':
Expand Down
1 change: 1 addition & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const TokenTypes = {
NDC_Champion: 'NDC Champion',
NDC_Contributor: 'NDC Contributor',
GWG__Core_Contributor: 'GWG Core Contributor',
MOD: 'Mod',
};

export const ReducerNames = {
Expand Down
Loading