mirror of
https://github.com/fullstack-cash/fullstack-gatsby-theme-bch-wallet.git
synced 2026-09-21 16:52:06 -07:00
fix(IPFS): Phasing out memo-get-gatsby with bch-message-lib
This commit is contained in:
@@ -25,9 +25,13 @@ class Footer extends React.Component {
|
||||
ipfsHashLink: ''
|
||||
}
|
||||
|
||||
this.memo = new Memo({ bchWallet: props.bchWallet, bchAddr: siteConfig.memoAddr })
|
||||
this.memo = new Memo({
|
||||
bchWallet: props.bchWallet,
|
||||
bchAddr: siteConfig.memoAddr
|
||||
})
|
||||
|
||||
// memo-get-gatsby Instance
|
||||
this.memoGet = _this.instantiateMemoLib()
|
||||
// this.memoGet = _this.instantiateMemoLib()
|
||||
}
|
||||
|
||||
async componentDidMount () {
|
||||
@@ -39,131 +43,132 @@ class Footer extends React.Component {
|
||||
}
|
||||
|
||||
async handleMemoService () {
|
||||
// This is a hard-coded hash or 'checkpoint' to use in times when the
|
||||
// connection fails.
|
||||
let hash = 'QmXbaYeTMMsQnLYpthpfoUJhz8o1DWqjoUwLUhC9KFUrAW'
|
||||
|
||||
// Try to retrieve the hash from the BCH blockchain.
|
||||
try {
|
||||
const hash = await this.memo.findHash()
|
||||
console.log(`hash: ${hash}`)
|
||||
console.log(`IPFS hash found: ${hash}`)
|
||||
|
||||
if (!hash) {
|
||||
throw new Error('Hash not found!')
|
||||
throw new Error('Hash not found! Falling back to hard coded IPFS hash.')
|
||||
}
|
||||
this.setState({
|
||||
ipfsHash: hash,
|
||||
ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}`
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('Error trying to retrieve IPFS hash for the site: ', err)
|
||||
|
||||
// Manually set an old hash.
|
||||
const hash = 'QmVm1y1MX4YPzmgQiAafY96Pq7j6GTNMFNuvHki1jAwxYg'
|
||||
this.setState({
|
||||
ipfsHash: hash,
|
||||
ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}`
|
||||
})
|
||||
}
|
||||
|
||||
this.setState({
|
||||
ipfsHash: hash,
|
||||
ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}`
|
||||
})
|
||||
}
|
||||
|
||||
// Get hash using memo-get-gatsby
|
||||
async handleMemoGet () {
|
||||
try {
|
||||
const addr = 'bitcoincash:qq8mk8etntclfdkny2aknh4ylc0uaewalszh5eytnr'
|
||||
const hash = await _this.memoGet.read(addr)
|
||||
console.log(`hash: ${hash}`)
|
||||
this.setState({
|
||||
ipfsHash: hash,
|
||||
ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}`
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('Error trying to retrieve IPFS hash for the site: ', err)
|
||||
|
||||
// Manually set an old hash.
|
||||
const hash = 'QmVm1y1MX4YPzmgQiAafY96Pq7j6GTNMFNuvHki1jAwxYg'
|
||||
this.setState({
|
||||
ipfsHash: hash,
|
||||
ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}`
|
||||
})
|
||||
}
|
||||
|
||||
// const bchjs = new BCHJS()
|
||||
// const balance = await bchjs.Blockbook.balance(addr)
|
||||
// console.log(`balance: ${JSON.stringify(balance, null, 2)}`)
|
||||
}
|
||||
// async handleMemoGet () {
|
||||
// try {
|
||||
// const addr = 'bitcoincash:qq8mk8etntclfdkny2aknh4ylc0uaewalszh5eytnr'
|
||||
// const hash = await _this.memoGet.read(addr)
|
||||
// console.log(`hash: ${hash}`)
|
||||
//
|
||||
// this.setState({
|
||||
// ipfsHash: hash,
|
||||
// ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}`
|
||||
// })
|
||||
// } catch (err) {
|
||||
// console.error('Error trying to retrieve IPFS hash for the site: ', err)
|
||||
//
|
||||
// // Manually set an old hash.
|
||||
// const hash = 'QmVm1y1MX4YPzmgQiAafY96Pq7j6GTNMFNuvHki1jAwxYg'
|
||||
// this.setState({
|
||||
// ipfsHash: hash,
|
||||
// ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}`
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// // const bchjs = new BCHJS()
|
||||
// // const balance = await bchjs.Blockbook.balance(addr)
|
||||
// // console.log(`balance: ${JSON.stringify(balance, null, 2)}`)
|
||||
// }
|
||||
|
||||
// Instantiate the library with the
|
||||
// bchjs options established in the configuration section
|
||||
instantiateMemoLib () {
|
||||
// Get wallet info
|
||||
const localStorageInfo = getWalletInfo()
|
||||
|
||||
// Get bchjs options
|
||||
const jwtToken = localStorageInfo.JWT
|
||||
const restURL = localStorageInfo.selectedServer
|
||||
const bchjsOptions = {}
|
||||
|
||||
if (jwtToken) {
|
||||
bchjsOptions.apiToken = jwtToken
|
||||
}
|
||||
if (restURL) {
|
||||
bchjsOptions.restURL = restURL
|
||||
}
|
||||
return new MemoGet(bchjsOptions)
|
||||
}
|
||||
// instantiateMemoLib () {
|
||||
// // Get wallet info
|
||||
// const localStorageInfo = getWalletInfo()
|
||||
//
|
||||
// // Get bchjs options
|
||||
// const jwtToken = localStorageInfo.JWT
|
||||
// const restURL = localStorageInfo.selectedServer
|
||||
// const bchjsOptions = {}
|
||||
//
|
||||
// if (jwtToken) {
|
||||
// bchjsOptions.apiToken = jwtToken
|
||||
// }
|
||||
// if (restURL) {
|
||||
// bchjsOptions.restURL = restURL
|
||||
// }
|
||||
// return new MemoGet(bchjsOptions)
|
||||
// }
|
||||
|
||||
render () {
|
||||
return (
|
||||
<section id='footer'>
|
||||
<Row className='footer-container'>
|
||||
<Col md={5} className='footer-section'>
|
||||
<section id="footer">
|
||||
<Row className="footer-container">
|
||||
<Col md={5} className="footer-section">
|
||||
<Row>
|
||||
<Col md={12} className='mb-1'>
|
||||
<p className='section-tittle'>Produced By</p>
|
||||
<Col md={12} className="mb-1">
|
||||
<p className="section-tittle">Produced By</p>
|
||||
|
||||
<a
|
||||
href='https://psfoundation.cash/'
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
href="https://psfoundation.cash/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Permissionless Software Foundation
|
||||
</a>
|
||||
</Col>
|
||||
<Col md={12}>
|
||||
<p className='section-tittle'>Source Code</p>
|
||||
<FontAwesomeIcon className='' size='lg' icon={faGithub} />
|
||||
<p className="section-tittle">Source Code</p>
|
||||
<FontAwesomeIcon className="" size="lg" icon={faGithub} />
|
||||
<a
|
||||
href='https://github.com/Permissionless-Software-Foundation/gatsby-ipfs-web-wallet'
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
href="https://github.com/Permissionless-Software-Foundation/gatsby-ipfs-web-wallet"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Github
|
||||
</a>
|
||||
</Col>
|
||||
</Row>
|
||||
</Col>
|
||||
<Col md={7} className='footer-section'>
|
||||
<div className='pull-right'>
|
||||
<span className='section-tittle'>
|
||||
<Col md={7} className="footer-section">
|
||||
<div className="pull-right">
|
||||
<span className="section-tittle">
|
||||
Ways to access this web-app
|
||||
</span>
|
||||
<ul>
|
||||
<li id='web'>
|
||||
<li id="web">
|
||||
<span>
|
||||
<b>Web</b>
|
||||
</span>
|
||||
<b>|</b>
|
||||
<a href='https://wallet.fullstack.cash'>
|
||||
<a href="https://wallet.fullstack.cash">
|
||||
wallet.fullstack.cash
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li id='tor'>
|
||||
<li id="tor">
|
||||
<span>
|
||||
<b>Tor</b>
|
||||
</span>
|
||||
<b>|</b>
|
||||
<a href='http://puh2fyj2ly5b4p5m.onion/'>
|
||||
<a href="http://puh2fyj2ly5b4p5m.onion/">
|
||||
puh2fyj2ly5b4p5m.onion
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li id='ipfs'>
|
||||
<li id="ipfs">
|
||||
<span>
|
||||
<b>IPFS</b>
|
||||
</span>
|
||||
@@ -204,8 +209,10 @@ class Footer extends React.Component {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Props prvided by redux
|
||||
Footer.propTypes = {
|
||||
bchWallet: PropTypes.object // get minimal-slp-wallet instance
|
||||
}
|
||||
|
||||
export default Footer
|
||||
|
||||
Reference in New Issue
Block a user