Skip to content
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
4 changes: 2 additions & 2 deletions frontend/packages/client/src/hooks/useCommunity.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export default function useCommunity({
category: categorySelected?.value,
termsAndConditionsUrl,
creatorAddr,
additionalAuthors: listAddrAuthors?.map((ele) => ele.addr),
additionalAdmins: listAddrAdmins?.map((ele) => ele.addr),
additionalAuthors: listAddrAuthors,
additionalAdmins: listAddrAdmins,
slug,
githubUrl,
instagramUrl,
Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/client/src/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const networksConfig = {
},
},
testnet: {
accessApi: 'https://access-testnet.onflow.org',
accessApi: 'https://rest-testnet.onflow.org',
walletDiscovery: 'https://fcl-discovery.onflow.org/testnet/authn',
walletDiscoveryApi: 'https://fcl-discovery.onflow.org/api/testnet/authn',
walletDiscoveryInclude: [
Expand All @@ -31,7 +31,7 @@ const networksConfig = {
},
},
mainnet: {
accessApi: 'https://mainnet.onflow.org',
accessApi: 'https://rest-mainnet.onflow.org',
walletDiscovery: 'https://fcl-discovery.onflow.org/authn',
walletDiscoveryApi: 'https://fcl-discovery.onflow.org/api/authn',
walletDiscoveryInclude: [
Expand Down
37 changes: 26 additions & 11 deletions frontend/packages/client/src/pages/CommunityCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,44 @@ export default function CommunityCreate() {
strategies = [],
} = fields;

const addrAdmins = listAddrAdmins
.map((e) => e.addr)
.filter((addr) => !!addr);
const addrAuthors = listAddrAuthors
.map((e) => e.addr)
.filter((addr) => !!addr);

// validate Flow Addresses used
const addressesToValidate = {
'Contract Address': [contractAddress],
'Admin List': listAddrAdmins.map((e) => e.addr),
'Author List': listAddrAuthors.map((e) => e.addr),
'Contract Address': contractAddress ? [contractAddress] : [],
'Admin List': addrAdmins,
'Author List': addrAuthors,
Strategies: strategies.map(({ contract }) => contract.addr),
};

const validation = Object.entries(addressesToValidate);
const errorMessages = [];
await Promise.all(
validation.map(async (ele) => {
validation.map(async ([name, addrs]) => {
try {
await Promise.all(
ele[1].map(async (addr) => {
await isValidFlowAddress(addr);
})
);
await Promise.all(addrs.map((addr) => isValidFlowAddress(addr)));
} catch (error) {
errorMessages.push(ele[0]);
// This is to bypass error on local
// emulator when keys field is not present
// on flow emulator response
if (
process.env.APP_ENV !== 'PRODUCTION' &&
!error?.message.includes(
"Cannot read properties of undefined (reading 'map')"
)
) {
errorMessages.push(name);
}
}
})
);
// open modal if there are errors on addresses
if (errorMessages.lenght) {
if (errorMessages.length) {
modalContext.openModal(
React.createElement(Error, {
error: (
Expand Down Expand Up @@ -127,6 +140,8 @@ export default function CommunityCreate() {
const communityData = {
creatorAddr,
...fields,
listAddrAdmins: addrAdmins,
listAddrAuthors: addrAuthors,
slug: generateSlug(),
};

Expand Down