Commit 01cd9020 authored by Bitcoin Please's avatar Bitcoin Please
Browse files

Added `model` to campaign creation.

parent ae766aea
......@@ -15,7 +15,7 @@ const getAsset = (state) => (_ownerSlug, _assetId) => {
}
/* Set owner. */
const owner = msgpack.decode(Buffer.from(state.assets[_ownerSlug], 'hex'))
const owner = state.assets[_ownerSlug]
// console.log('GET ASSET (owner):', owner)
/* Validate owner. */
......@@ -24,7 +24,7 @@ const getAsset = (state) => (_ownerSlug, _assetId) => {
}
/* Set asset. */
const asset = owner[_assetId]
const asset = msgpack.decode(Buffer.from(owner[_assetId], 'hex'))
// console.log('GET ASSET (asset):', asset)
/* Return asset. */
......
......@@ -238,62 +238,6 @@ export default {
}
},
/**
* Encode Output Value
*
* Encodes a number of satoshis to be used as part of an output
* structure in a raw transaction.
*/
encodeOutputValue(_satoshis) {
// Check if the provided satoshis is of the correct type.
if (isNaN(_satoshis)) {
throw `Cannot encode output value, provided satoshis '${_satoshis}' is not a number.`
}
// Check if the provided satoshis is an integer.
if (!Number.isInteger(_satoshis)) {
throw `Cannot encode output value, provided satoshis '${_satoshis}' is not an integer.`
}
// Check if the provided satoshis is a positive number.
if (_satoshis < 0) {
throw `Cannot encode output value, provided satoshis '${_satoshis}' is negative.`
}
// Check if the provided satoshis is within our accepted number range.
if (_satoshis > Math.pow(2, 53)) {
throw `Cannot encode output value, provided satoshis '${_satoshis}' is larger than javacripts 53bit limit.`
}
/* Allocate 8 bytes. */
const value = Buffer.alloc(8)
/* Split the number into high and low bits. */
const highValue = Math.floor(_satoshis / Math.pow(2, 32))
const lowValue = _satoshis % Math.pow(2, 32)
/* Write the satoshi number to the buffer in 64bit. */
value.writeUInt32LE(highValue, 4)
value.writeUInt32LE(lowValue, 0)
// Return the encoded value.
return value
},
/**
* Decode Output Value
*/
decodeOutputValue(_value) {
// TODO: Properly validate and error check.
// Parhse the high and low value sets.
const highValue = _value.readUInt32LE(4);
const lowValue = _value.readUInt32LE(0);
// Return the decoded value.
return highValue * Math.pow(2, 32) + lowValue;
},
/**
* Assemble Signature Hash Digest
*/
......@@ -314,7 +258,7 @@ export default {
console.log('Campaign value:', campaignValue)
/* Set value. */
value = this.encodeOutputValue(campaignValue)
value = Nito.Utils.encodeNumber(campaignValue)
console.log('Encoded value:', value)
/* Set campaign address. */
......@@ -605,7 +549,7 @@ export default {
}
const previousTransactionHash = _coin.txid
const previousTransactionOutputValue = this.encodeOutputValue(_coin.satoshis)
const previousTransactionOutputValue = Nito.Utils.encodeNumber(_coin.satoshis)
const previousTransactionOutputIndex = '00000000'
const inputLockScript = Nito.Address.toPubKeyHash(cashAddress)
......
......@@ -31,16 +31,18 @@
<div class="field">
<label for="title">
Title
Campaign Title
</label>
<span class="label-desc">What is the title of your campaign?</span>
<span class="label-desc">
What is the title of your campaign?
</span>
<input
type="text"
id="title"
name="title"
placeholder="The Unstoppable Campaign"
placeholder="Bitcoin Killer App"
v-model="title"
@keyup="titleValidation($event)"
/>
......@@ -55,18 +57,40 @@
</div>
<div class="field">
<label for="ccat">
Category
<label for="model">
Funding Model
</label>
<span class="label-desc">
Please choose from 1 of 3 funding models.
How do you want to receive your donations?
</span>
<div class="field-select">
<select id="model" v-model="model">
<option value="">Select a Campaign Type</option>
<option value="direct">Direct Payment</option>
<option value="assurance">Community Pledge</option>
<option value="payouts">Daily Payouts</option>
</select>
</div>
</div>
<div class="field">
<label for="category">
Campaign Category
</label>
<span class="label-desc">To help backers find your campaign, select a category that best represents your campaign.</span>
<span class="label-desc">
To help backers find your campaign, select a category that best represents your campaign.
</span>
<div class="field-select">
<select v-model="category">
<select id="category" v-model="category">
<option value="">Select a Category</option>
<option value="adoption">Adoption</option>
<option value="community">Community</option>
<option value="dapps">DApps</option>
<option value="dapp">Decentralized Apps</option>
<option value="design-art">Design & Art</option>
<option value="education">Education</option>
<option value="film-video">Film & Video</option>
......@@ -85,21 +109,9 @@
</div>
</div>
<!-- <div class="field">
<label for="campaigndesc">
Summary
</label>
<span class="label-desc">
Provide a short summary (500 characters or less) that best describes your campaign to your audience.
</span>
<textarea rows="4" v-model="summary" placeholder="Enter a brief summary of your campaign"></textarea>
</div> -->
<div class="field clearfix">
<label for="clocation">
Primary Residence
<label for="location">
Primary Location
<a href="javascript://" class="view-residence">(why do we ask for this?)</a>
</label>
......@@ -107,7 +119,7 @@
<div class="field">
<div class="field-select">
<select v-model="location">
<select id="location" v-model="location">
<option value="">Select Your Campaign's Residence</option>
<option value="Worldwide">Worldwide</option>
<option value="">------------------------------</option>
......@@ -399,7 +411,9 @@
</div>
</div>
<button @click="createNew" class="btn-primary">Save &amp; Launch</button>
<button @click="createNew" class="btn-primary">
Create My New Campaign
</button>
</form>
</div>
</section>
......@@ -431,7 +445,7 @@ export default {
title: null,
category: null,
// summary: null,
model: null,
location: null,
}
},
......@@ -470,16 +484,16 @@ export default {
return alert('Enter a title')
}
// /* Validate model. */
if (!this.model) {
return alert('Enter a model')
}
/* Validate category. */
if (!this.category) {
return alert('Enter a category')
}
// /* Validate summary. */
// if (!this.summary) {
// return alert('Enter a summary')
// }
/* Validate location. */
if (!this.location) {
return alert('Enter a location')
......@@ -489,8 +503,8 @@ export default {
campaignId: 'NEW',
slug: this.slug,
title: this.title,
model: this.model,
category: this.category,
// summary: this.summary,
owner: {
slug: this.ownerSlug,
},
......
......@@ -91,10 +91,12 @@ export default {
const summary = this.campaign.summary
/* Validate summary. */
if (summary.slice(0, 2) === 'Qm' && summary.length === 46) {
if (summary && summary.slice(0, 2) === 'Qm' && summary.length === 46) {
target = summary
} else {
} else if (summary) {
body = summary
} else {
body = 'no campaign summary found'
}
/* Build (summary) package. */
......@@ -118,10 +120,12 @@ export default {
const description = this.campaign.description
/* Validate description. */
if (description.slice(0, 2) === 'Qm' && description.length === 46) {
if (description && description.slice(0, 2) === 'Qm' && description.length === 46) {
target = description
} else {
} else if (description) {
body = description
} else {
body = 'no campaign description found'
}
/* Build (description) package. */
......@@ -134,8 +138,6 @@ export default {
/* Request (description) update. */
this.updateAsset(pkg)
console.log();
},
},
......
......@@ -222,7 +222,44 @@ export default {
category() {
if (this.campaign && this.campaign.category) {
return this.campaign.category
switch(this.campaign.category) {
case 'adoption':
return 'Adoption'
case 'community':
return 'Community'
case 'dapp':
return 'Decentralized App'
case 'design-art':
return 'Design & Art'
case 'education':
return 'Education'
case 'film-video':
return 'Film & Video'
case 'fun-games':
return 'Fun & Games'
case 'hardware':
return 'Hardware'
case 'health-wellness':
return 'Health & Wellness'
case 'infrastructure':
return 'Infrastructure'
case 'music':
return 'Music'
case 'privacy':
return 'Privacy'
case 'publishing':
return 'Publishing'
case 'security':
return 'Security'
case 'software':
return 'Software'
case 'world-view':
return 'World View'
case 'youth':
return 'Youth'
default:
return 'Unknown Category'
}
} else {
return null
}
......@@ -387,12 +424,12 @@ export default {
const images = []
/* Validate main image. */
if (this.campaign.images.main) {
if (this.campaign.images && this.campaign.images.main) {
images.push(this.campaign.images.main)
}
// /* Validate gallery images. */
if (this.campaign.images.gallery) {
if (this.campaign.images && this.campaign.images.gallery) {
let max = 2
for (let i = 0; i < this.campaign.images.gallery.length; i++) {
images.push(this.campaign.images.gallery[i])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment