Skip to content

Commit

Permalink
fix: Post condition mode is removed for deploying the contract.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raja Ilayaperumal authored and Raja Ilayaperumal committed Nov 10, 2024
1 parent 8accb9d commit 0408851
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
23 changes: 20 additions & 3 deletions components/builder/BuilderComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export default function BuilderComponent(props) {
votingStrategyFlag: true,
strategyTokenType: "nft",
strategyContractName: "",
startAtBlock: 0,
endAtBlock: 0,
// startAtBlock: 0,
// endAtBlock: 0,
startAtDate: 0,
endAtDate: 0,

Expand Down Expand Up @@ -289,7 +289,7 @@ export default function BuilderComponent(props) {
if (!pollObject?.startAtBlock || !pollObject?.endAtBlock) {
return "Please enter start and end block height."
} else if (pollObject?.startAtBlock < currentBlockHeight) {
return "Start block should be greater than current block height."
return `Start block should be greater than or equal to current block height (${currentBlockHeight}).`
} else if (pollObject?.startAtBlock > pollObject?.endAtBlock) {
return "End block should be greater than start block height."
} else if (pollObject?.endAtBlock <= pollObject?.startAtBlock) {
Expand Down Expand Up @@ -560,12 +560,14 @@ export default function BuilderComponent(props) {
<Form.Group>
<Form.Label style={{ width: "150px" }} className='ballot_labels'>Start block height *</Form.Label>
<Form.Control type="number" name="startAtBlock" value={pollObject.startAtBlock} style={{ width: "250px" }}
placeholder="0"
onChange={handleChange} className="ballot_input" />
</Form.Group>

<Form.Group>
<Form.Label style={{ width: "150px" }} className='ballot_labels'>End block height *</Form.Label>
<Form.Control type="number" name="endAtBlock" value={pollObject.endAtBlock} style={{ width: "250px" }}
placeholder="0"
onChange={handleChange} className="ballot_input" />
</Form.Group>
</div>
Expand Down Expand Up @@ -677,6 +679,21 @@ export default function BuilderComponent(props) {
<div className={styles.builder_right}>
<div style={{ position: "sticky", top: "119px" }}>
<div className={styles.builder_right_section}>
{/* Statement: I support ballot.gg with a 5 STX contribution. */}
<div style={{ fontSize: "14px", marginBottom: "6px" }}>
{/* Checkbox with ticked */}
<Form.Group>
<Form.Check
inline
type="checkbox"
name="votingStrategyFlag"
label="I support ballot.gg with a 5 STX contribution."
checked={true}
/>
</Form.Group>

</div>

{
pollId !== "new" &&
<Button style={{ width: "100%", marginBottom: "10px" }} className="action_secondary_btn"
Expand Down
9 changes: 1 addition & 8 deletions services/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ const cancelCallbackFunction = (data) => {
export async function deployContract(pollObject, contractName, callbackFunction) {
const contract = getContract(pollObject);

// this post-condition ensures that our recipient receives at least 5000 STX tokens
const myPostCondition = makeStandardSTXPostCondition(
Constants.STACKS_MAINNET_FLAG ? Constants.MAINNET_DONATION_ADDRESS : Constants.TESTNET_DONATION_ADDRESS,
FungibleConditionCode.Equal,
5000000 // 1STX = 1000000 micro-STX (denoted in micro-STX)
);

// Transaction options
const txOptions = {
network: getNetworkType(), // Testnet or Mainnet
Expand All @@ -31,7 +24,7 @@ export async function deployContract(pollObject, contractName, callbackFunction)
},

postConditionMode: PostConditionMode.Allow, // whether the tx should fail when unexpected assets are transferred
postConditions: [myPostCondition], // for an example using post-conditions, see next example
postConditions: [], // for an example using post-conditions, see next example

onFinish: callbackFunction,
onCancel: cancelCallbackFunction
Expand Down

0 comments on commit 0408851

Please sign in to comment.