Skip to content

Commit

Permalink
use paymentpointers.org payment pointer predicate
Browse files Browse the repository at this point in the history
this will make us compatible with other work happening in the Solid world around payment pointers
  • Loading branch information
travis committed Apr 27, 2021
1 parent f49216d commit 9bb9524
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/WebMonetization.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import Head from 'next/head'
import { useProfile } from 'swrlit'
import { getStringNoLocale } from '@inrupt/solid-client'
import { US } from '../vocab'
import { getPaymentPointer } from '../model/profile'

// itme's uphold USD payment pointer
const defaultPaymentPointer = "$ilp.uphold.com/DYPhbXPmDa2P"

export default function WebMonetization({webId}){
const { profile } = useProfile(webId)
const paymentPointer = profile && getStringNoLocale(profile, US.paymentPointer)
const paymentPointer = getPaymentPointer(profile)

return (
<Head>
Expand Down
10 changes: 10 additions & 0 deletions model/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { getStringNoLocale, setStringNoLocale } from '@inrupt/solid-client'
import { US, PP } from '../vocab'

export function getPaymentPointer(profile) {
return profile && (getStringNoLocale(profile, US.paymentPointer) || getStringNoLocale(profile, PP.paymentPointer))
}

export function setPaymentPointer(profile, newPaymentPointer) {
return setStringNoLocale(profile, PP.paymentPointer, newPaymentPointer)
}
7 changes: 4 additions & 3 deletions pages/profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import WebMonetization from '../components/WebMonetization'
import { profilePath } from '../utils/uris'
import { useImageUploadUri } from '../hooks/uris'
import { EditIcon } from '../components/icons'
import { ImageUploadAndEditor } from '../components/ImageUploader';
import { ImageUploadAndEditor } from '../components/ImageUploader'
import { getPaymentPointer, setPaymentPointer } from '../model/profile'

function Name({name, save, ...props}){
const [newName, setNewName] = useState()
Expand Down Expand Up @@ -51,7 +52,7 @@ function Name({name, save, ...props}){
}

function WebMonetizationPointer({profile, save, ...props}){
const paymentPointer = profile && getStringNoLocale(profile, US.paymentPointer)
const paymentPointer = getPaymentPointer(profile)
const [newPaymentPointer, setNewPaymentPointer] = useState()
const [editingPaymentPointer, setEditingPaymentPointer] = useState(false)
function savePaymentPointer(){
Expand Down Expand Up @@ -133,7 +134,7 @@ export default function Profile(){
return await saveProfile(setStringNoLocale(profile, FOAF.name, newName))
}
async function onSavePaymentPointer(newPaymentPointer){
return await saveProfile(setStringNoLocale(profile, US.paymentPointer, newPaymentPointer))
return await saveProfile(setPaymentPointer(profile, newPaymentPointer))
}
async function onSaveProfileImage(newProfileImage){
return await saveProfile(setUrl(profile, FOAF.img, newProfileImage))
Expand Down
4 changes: 4 additions & 0 deletions vocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const ITME = {
conceptPrefix: `${itmeRoot}conceptPrefix`
}

export const PP = {
paymentPointer: "http://paymentpointers.org/ns#PaymentPointer"
}

const understoryRoot = "https://understory.coop/vocab/garden#"
export const US = {
noteBody: `${understoryRoot}noteBody`,
Expand Down

0 comments on commit 9bb9524

Please sign in to comment.