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
3 changes: 3 additions & 0 deletions pdf-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
As a minor extension, we also keep a semantic version for the `UNRELEASED`
changes.

## [v1.0.10-beta](https://www.npmjs.com/package/@intersect.mbo/pdf-ui/v/1.0.10-beta) 2025-07-29
- Submitting Governance Action with IPFS Metadata URL Fails Due to Unsupported URL Scheme #3979

## [v1.0.9-beta](https://www.npmjs.com/package/@intersect.mbo/pdf-ui/v/1.0.9-beta) 2025-07-03
- Support IPFS Links for Governance Action Submissions #3851

Expand Down
2 changes: 1 addition & 1 deletion pdf-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@intersect.mbo/pdf-ui",
"version": "1.0.9-beta",
"version": "1.0.10-beta",
"description": "Proposal discussion ui",
"main": "./src/index.js",
"exports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { IconExternalLink } from '@intersect.mbo/intersectmbo.org-icons-set';
import { useTheme } from '@emotion/react';

const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {

const theme = useTheme();
const navigate = useNavigate();
const { walletAPI, validateMetadata } = useAppContext();
Expand Down Expand Up @@ -112,12 +111,17 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {
const hash = await walletAPI.createHash(jsonLd);
setHashData(hash);
};
const proposalGATypeId= proposal?.attributes?.content?.attributes.gov_action_type_id;
const proposalGATypeId =
proposal?.attributes?.content?.attributes.gov_action_type_id;
const handleGASubmission = async () => {
try {
let url = fileURL;
setCheckingDataModal(true);
if (fileURL.startsWith('ipfs://')) {
url = `https://ipfs.io/ipfs/${fileURL.replace('ipfs://', '')}`;
}
const response = await validateMetadata({
url: fileURL,
url: url,
hash: hashData,
standard: 'CIP108',
});
Expand All @@ -135,43 +139,52 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {
await walletAPI.buildTreasuryGovernanceAction({
hash: hashData,
url: fileURL,
withdrawals: getWithdrawalsArray()
withdrawals: getWithdrawalsArray(),
});
}
else if (parseInt(proposalGATypeId) === 3)
{
const constitUrl = proposal?.attributes?.content?.attributes.proposal_constitution_content.data.attributes.prop_constitution_url;
} else if (parseInt(proposalGATypeId) === 3) {
const constitUrl =
proposal?.attributes?.content?.attributes
.proposal_constitution_content.data.attributes
.prop_constitution_url;
const constiUrlHash = await getHashFromUrl(constitUrl);
govActionBuilder =
await walletAPI.buildNewConstitutionGovernanceAction({
hash: hashData,
url: fileURL,
constitutionUrl: constitUrl,
constitutionHash: constiUrlHash
//prevGovernanceActionHash: string;
//prevGovernanceActionIndex: number;
//scriptHash: string;
});
}
else if(parseInt(proposalGATypeId) === 4)
{ ///Motion of No Confidence
govActionBuilder =
await walletAPI.buildNoConfidenceGovernanceAction({
await walletAPI.buildNewConstitutionGovernanceAction({
hash: hashData,
url: fileURL,
constitutionUrl: constitUrl,
constitutionHash: constiUrlHash,
//prevGovernanceActionHash: string;
//prevGovernanceActionIndex: number;
//scriptHash: string;
});
}
else if(parseInt(proposalGATypeId) === 6)
{ ///Hard Fork Initiation
} else if (parseInt(proposalGATypeId) === 4) {
///Motion of No Confidence
govActionBuilder =
await walletAPI.buildHardForkInitiationGovernanceActions({
prevGovernanceActionHash: proposal?.attributes?.content?.attributes?.proposal_hard_fork_content.previous_ga_hash,
prevGovernanceActionIndex: proposal?.attributes?.content?.attributes?.proposal_hard_fork_content.previous_ga_id,
major: proposal?.attributes?.content?.attributes?.proposal_hard_fork_content.major,
minor: proposal?.attributes?.content?.attributes?.proposal_hard_fork_content.minor,
await walletAPI.buildNoConfidenceGovernanceAction({
hash: hashData,
url: fileURL,
});
} else if (parseInt(proposalGATypeId) === 6) {
///Hard Fork Initiation
govActionBuilder =
await walletAPI.buildHardForkInitiationGovernanceActions(
{
prevGovernanceActionHash:
proposal?.attributes?.content?.attributes
?.proposal_hard_fork_content
.previous_ga_hash,
prevGovernanceActionIndex:
proposal?.attributes?.content?.attributes
?.proposal_hard_fork_content
.previous_ga_id,
major: proposal?.attributes?.content?.attributes
?.proposal_hard_fork_content.major,
minor: proposal?.attributes?.content?.attributes
?.proposal_hard_fork_content.minor,
hash: hashData,
url: fileURL,
}
);
}

if (govActionBuilder) {
Expand Down Expand Up @@ -212,12 +225,17 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {

const getWithdrawalsArray = () => {
let withdrawalsArray = [];
let x = proposal?.attributes?.content?.attributes?.proposal_withdrawals.forEach((withdrawal) =>
{
withdrawalsArray.push({receivingAddress:withdrawal.prop_receiving_address,amount:withdrawal.prop_amount.toString()})
});
let x =
proposal?.attributes?.content?.attributes?.proposal_withdrawals.forEach(
(withdrawal) => {
withdrawalsArray.push({
receivingAddress: withdrawal.prop_receiving_address,
amount: withdrawal.prop_amount.toString(),
});
}
);
return withdrawalsArray;
}
};

const handleDownloadJsonLD = () => {
const blob = new Blob([JSON.stringify(jsonLdData, null, 2)], {
Expand All @@ -239,7 +257,9 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {
throw new Error('url is not defined or null');
}
// Fetch the data from the URL
const response = (await fetch(url,{'User-Agent': "govtool-agent"}));
const response = await fetch(url, {
'User-Agent': 'govtool-agent',
});
// Check if the response is successful
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
Expand Down
4 changes: 3 additions & 1 deletion pdf-ui/src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export function isValidURLLength(s) {
}

export const openInNewTab = (url) => {
if (!url.startsWith('http://') && !url.startsWith('https://')) {
if (url.startsWith('ipfs://')) {
url = `https://ipfs.io/ipfs/${url.replace('ipfs://', '')}`;
} else if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = 'https://' + url;
}
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
Expand Down