Commit 1dbdfd68 authored by Bitcoin Please's avatar Bitcoin Please

Fixed coin update.

parent 77d24ab1
/* Import modules. */
const moment = require('moment')
import moment from 'moment'
import Nito from 'nitojs'
/**
......
/* Import modules. */
const crypto = require('crypto')
import crypto from 'crypto'
import superagent from 'superagent'
/**
......@@ -37,7 +37,6 @@ const updateMeta = async ({ commit, getters }, _meta) => {
commit('setMeta', _meta)
const key = getters.getMasterSeed
console.log('MASTER SEED (key)', key)
/**
* Encrypt Metadata
......@@ -53,7 +52,8 @@ const updateMeta = async ({ commit, getters }, _meta) => {
// console.log('SIGNED PACKAGE', signedPkg)
/* Set api target. */
const target = 'https://api.causes.cash/v1/meta'
const target = 'http://localhost:6767/v1/profiles'
// const target = 'https://api.causes.cash/v1/meta'
/* Call api. */
await superagent
......
/* Import modules. */
import crypto from 'crypto'
import msgpack from 'msgpack-lite'
import Nito from 'nitojs'
import superagent from 'superagent'
......@@ -54,20 +55,32 @@ const getMeta = async (state, getters, rootState, rootGetters) => {
// console.log('GET SIGNED MESSAGE (address):', address)
/* Set target. */
const target = `https://api.causes.cash/v1/meta/${address}`
const target = `http://localhost:6767/v1/profiles/${address}`
// const target = `https://api.causes.cash/v1/profiles/${address}`
/* Set contract path. */
const response = await superagent.get(target)
// console.log('GET META', response)
/* Request decryption key. */
const key = getters.getMasterSeed
/* Decrypt metadata. */
const meta = _decrypt(response, key)
/* Return metadata. */
return meta
/* Validate resopnse. */
if (response && response.body && response.body.meta) {
/* Request decryption key. */
const key = getters.getMasterSeed
try {
/* Decrypt metadata. */
const meta = _decrypt(response.body.meta, key)
/* Return metadata. */
return meta
} catch (err) {
console.error(err) // eslint-disable-line no-console
}
return null
} else {
return null
}
} else {
/* Return metadata. */
return msgpack.decode(Buffer.from(state.meta, 'hex'))
......
......@@ -10,6 +10,9 @@ const destroyProfile = (state) => {
/* Reset master seed. */
state.masterSeed = null
/* Reset metadata. */
state.meta = null
/* Reset nickname. */
state.nickname = null
}
......
/* Import modules (getters). */
import getApiProvider from './system/getters/getApiProvider'
import getAssetSource from './system/getters/getAssetSource'
import getEternalDbAddr from './system/getters/getEternalDbAddr'
import getFlags from './system/getters/getFlags'
......@@ -87,6 +88,7 @@ const state = {
/* Getters. */
const getters = {
getApiProvider,
getAssetSource,
getEternalDbAddr,
getFlags,
......
/**
* Get API Provider
*
* Returns the target url for the API endpoint used for platform data.
*/
const getApiProvider = () => {
/* Return url endpoint. */
return 'http://localhost:6767/v1/'
// return 'https://api.causes.cash/v1/'
}
/* Export module. */
export default getApiProvider
/* Import modules. */
// const numeral = require('numeral')
import numeral from 'numeral'
/**
......
......@@ -32,7 +32,8 @@ const updateStatus = (_coins, _meta, dispatch) => {
dispatch('updateCoin', coin)
}
} else {
if (!_meta.coins[coinid]) {
/* Validate metadata coins. */
if (!_meta || !_meta.coins[coinid]) {
return
}
......
......@@ -125,7 +125,7 @@
<div class="col-12 col-md-5">
<a href="javascript://" class="btn-danger float-right" @click="$emit('cancel')">
<i class="fa fa-times-circle" aria-hidden="true"></i>
Cancel Community Pledge
Close Community Pledge
</a>
<h3>Community Pledge</h3>
......
......@@ -122,7 +122,7 @@
<div class="col-12 col-md-5">
<a href="javascript://" class="btn-danger float-right" @click="$emit('cancel')">
<i class="fa fa-times-circle" aria-hidden="true"></i>
Cancel Direct Donation
Close Direct Donation
</a>
<h3>Direct Donation</h3>
......
......@@ -172,7 +172,8 @@ import QRCode from 'qrcode'
import superagent from 'superagent'
import Swal from 'sweetalert2'
const { Contract, SignatureTemplate } = require('cashscript')
// const { Contract, SignatureTemplate } = require('cashscript')
import { Contract, SignatureTemplate } from 'cashscript'
export default {
props: {
......
......@@ -122,7 +122,7 @@
<div class="col-12 col-md-5">
<a href="javascript://" class="btn-danger float-right" @click="$emit('cancel')">
<i class="fa fa-times-circle" aria-hidden="true"></i>
Cancel Reminder
Close Reminder
</a>
<h3>Campaign Reminder</h3>
......
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