Commit 2ccccb1f authored by Bitcoin Please's avatar Bitcoin Please

Refactored to match api changes.

parent 2d92d930
......@@ -5,19 +5,19 @@ import superagent from 'superagent'
* Add Payout
*/
const addPayout = async ({ rootGetters }, _payout) => {
console.log('ADD PAYOUT:', _payout)
/* Sign message. */
const signedPkg = rootGetters['profile/getSignedMessage'](JSON.stringify(_payout))
console.log('SIGNED PACKAGE', signedPkg)
// console.log('SIGNED PACKAGE', signedPkg)
/* Set api target. */
const target = 'http://localhost:6767/v1/payouts'
// const target = 'https://api.causes.cash/v1/payouts'
/* Make remote call. */
const result = await superagent
.post(target)
.send(signedPkg)
console.log('RESULT', result)
// console.log('RESULT', result)
/* Return result. */
return result
......
......@@ -6,13 +6,11 @@ import Nito from 'nitojs'
* Get Signed Message
*/
const getSignedMessage = (state, getters, rootState, rootGetters) => (_message) => {
console.log('DEBUG', _message)
/* Validate message. */
if (!_message || !(typeof _message === 'string')) {
throw new Error('Signed message MUST be a string.')
}
console.log('ROOT GETTERS', rootGetters['wallet/getAccounts'])
/* Validate accounts. */
if (!rootGetters['wallet/getAccounts']) {
return null
......
......@@ -38,7 +38,7 @@
</div>
<div class="campaign-category">
{{formatCategory(campaign.category)}}
{{formatCategory(campaign.category)}} | {{formatModel(campaign.model)}}
</div>
<div class="campaign-title">
......@@ -190,6 +190,20 @@ export default {
}
},
/**
* Format Model
*/
formatModel(_model) {
switch(_model) {
case 'assurance':
return 'Community Pledge'
case 'direct':
return 'Direct Cash'
case 'payouts':
return 'Daily Payouts'
}
}
},
created: async function () {
/* Set owner slug. */
......
......@@ -89,7 +89,7 @@
<option value="">Select a Category</option>
<option value="adoption">Adoption</option>
<option value="community">Community</option>
<option value="dapp">Decentralized Apps</option>
<option value="dapp">Decentralized App</option>
<option value="design-art">Design & Art</option>
<option value="education">Education</option>
<option value="film-video">Film & Video</option>
......
......@@ -450,7 +450,7 @@ export default {
const model = this.campaign.model
if (model === 'assurance') {
return this.campaign.assurance.recipients[0].satoshis
return this.campaign.assurance.recipient.satoshis
}
return 0
......@@ -468,7 +468,7 @@ export default {
const model = this.campaign.model
if (model === 'assurance') {
return this.campaign.assurance.recipients[0].address
return this.campaign.assurance.recipient.address
}
return 0
......@@ -504,14 +504,14 @@ export default {
fundingGoal() {
if (this.campaign && this.campaign.assurance) {
/* Set recipients. */
const recipients = this.campaign.assurance.recipients
const recipient = this.campaign.assurance.recipient
/* Validate recipients. */
if (!recipients) {
if (!recipient) {
return '$0.00'
}
const calc = (recipients[0].satoshis / 100000000 * this.usd)
const calc = (recipient.satoshis / 100000000 * this.usd)
return numeral(calc).format('$0,0[.]00')
}
......@@ -525,15 +525,15 @@ export default {
fundingPledged() {
if (this.campaign && this.campaign.assurance) {
/* Set recipients. */
const recipients = this.campaign.assurance.recipients
const recipient = this.campaign.assurance.recipient
/* Validate recipients. */
if (!recipients) {
if (!recipient) {
return '$0.00'
}
// FOR DEV ONLY
const calc = (recipients[0].satoshis / 100000000 * this.usd) / 2.5
const calc = (recipient.satoshis / 100000000 * this.usd) / 2.5
return numeral(calc).format('$0,0[.]00')
}
......
......@@ -215,8 +215,8 @@ export default {
const pkg = {
outputs: [
{
value: this.campaign.assurance.recipients[0].satoshis,
address: this.campaign.assurance.recipients[0].address
value: this.campaign.assurance.recipient.satoshis,
address: this.campaign.assurance.recipient.address
}
],
data: {
......@@ -448,7 +448,7 @@ export default {
/* Validate assurance. */
if (this.campaign.assurance) {
/* Set pledge goal. */
this.pledgeGoal = this.campaign.assurance.recipients[0].satoshis
this.pledgeGoal = this.campaign.assurance.recipient.satoshis
console.log('PLEDGE GOAL', this.pledgeGoal)
}
},
......
......@@ -212,8 +212,8 @@ export default {
const pkg = {
outputs: [
{
value: this.campaign.direct.recipients[0].satoshis,
address: this.campaign.direct.recipients[0].address
value: this.campaign.direct.recipient.satoshis,
address: this.campaign.direct.recipient.address
}
],
data: {
......@@ -380,7 +380,7 @@ export default {
/* Validate direct. */
if (this.campaign.direct) {
/* Set pledge goal. */
this.pledgeGoal = this.campaign.direct.recipients[0].satoshis
this.pledgeGoal = this.campaign.direct.recipient.satoshis
console.log('PLEDGE GOAL', this.pledgeGoal)
}
},
......
......@@ -70,7 +70,7 @@
placeholder="pledge amount (usd)"
v-model="pledgeUSD"
@blur="onPledgeUpdate"
@keyup.enter="$refs.pledgeName.focus()"
@keyup.enter="$refs.pledgeAlias.focus()"
/>
</div>
</div>
......@@ -82,12 +82,12 @@
<div class="col-md-8">
<input
ref="pledgeName"
ref="pledgeAlias"
class="form-control"
type="text"
id="input-name"
placeholder="(optional)"
v-model="pledgeName"
v-model="pledgeAlias"
@keyup.enter="$refs.pledgeComment.focus()"
/>
</div>
......@@ -191,7 +191,7 @@ export default {
pledgeUSD: null,
pledgeSatoshis: null,
pledgeName: null,
pledgeAlias: null,
pledgeComment: null,
pledgeRange: null,
pledgeGoal: null,
......@@ -326,13 +326,37 @@ export default {
this._setPledgeUSD(satoshis)
},
savePledge() {
async savePledge() {
this.setClipboard()
/* Set campaign id. */
const campaignid = this.campaign.id
/* Set funder address. */
// NOTE: Generated from next unused causes address.
const funderAddress = this.getAddress('causes')
const publicKeyHash = Nito.Address
.toPubKeyHash(funderAddress).slice(6, -4)
// console.log('publicKeyHash', publicKeyHash)
/* Set alias. */
const alias = this.pledgeAlias
/* Set comment. */
const comment = this.pledgeComment
const pledgeUSD = numeral(this.pledgeUSD).value()
const monthlyPledgeAmt = Math.round(pledgeUSD * 100)
const pkg = {
hi: 'there'
campaignid,
publicKeyHash,
alias,
comment,
monthlyPledgeAmt,
}
/* Add payout. */
this.addPayout(pkg)
},
......@@ -506,11 +530,11 @@ export default {
/* Validate payouts. */
if (this.campaign.payouts) {
/* Set pledge goal. */
this.pledgeGoal = this.campaign.payouts.recipients[0].satoshis
this.pledgeGoal = this.campaign.payouts.recipient.satoshis
console.log('PLEDGE GOAL', this.pledgeGoal)
/* Set pledge goal. */
this.receipientAddress = this.campaign.payouts.recipients[0].address
this.receipientAddress = this.campaign.payouts.recipient.address
console.log('RECIPIENT ADDRESS', this.receipientAddress)
}
......
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