Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adds possibility to use holochain link language when sharing a perspective & Adds a new expression language: Junto Short Form #4

Open
wants to merge 48 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
374baac
add profiles dna
jdeepee Jan 4, 2021
df0f877
others fn in linkadapter to return promise
jdeepee Jan 4, 2021
c25c439
first pass of "social context" link language
jdeepee Jan 4, 2021
63b6784
cleanup of langs
jdeepee Jan 4, 2021
63899bb
remove gun-links & use bash oneliner for build-languages
jdeepee Jan 5, 2021
845a87f
ipfs links others() fn as async
jdeepee Jan 5, 2021
a66d20f
add missing rollup config for public social context links
jdeepee Jan 5, 2021
502295d
add dna.js to sc
jdeepee Jan 5, 2021
2a04526
script for cleaning holochain dir and building shortform
jdeepee Jan 5, 2021
a24c5f9
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 7, 2021
8be6f86
styling tweaks to ConstructorIcon.svelte
cubanmercury Jan 7, 2021
b79b376
Merge branch 'develop' of github.com:jdeepee/perspectivism into develop
cubanmercury Jan 7, 2021
458f412
Merge branch 'master' of https://github.com/lucksus/perspectivism int…
jdeepee Jan 7, 2021
032ae88
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 7, 2021
87e7de0
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 8, 2021
e39f986
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 8, 2021
4ba9d9a
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 9, 2021
229b361
lock file
jdeepee Jan 9, 2021
704317c
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 12, 2021
352ab54
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 12, 2021
02e3cbc
fix imports
jdeepee Jan 12, 2021
24333b1
wire up basic social context link store
jdeepee Jan 12, 2021
3e196e5
return get_others response from link language directly
jdeepee Jan 12, 2021
c89850b
holochain link language now an option for a shared perpective
jdeepee Jan 13, 2021
5af7fb0
short form dna now integrates with acai much more closely by storing …
jdeepee Jan 14, 2021
3218bb1
Merge remote-tracking branch 'upstream/develop' into develop
jdeepee Jan 14, 2021
2e37891
add back gun-links
jdeepee Jan 15, 2021
604f43b
added integration with update & delete zome functions for social context
jdeepee Jan 15, 2021
49aad64
add gun links rollup files
jdeepee Jan 15, 2021
25ab785
remove dev cleanup script
jdeepee Jan 15, 2021
4b41132
Merge pull request #5 from lucksus/develop
lucksus Jan 18, 2021
9c494c5
Added missing rollup files for social context
jdeepee Jan 19, 2021
204e144
added possibility to insert seed into holochain link language such th…
jdeepee Jan 20, 2021
81721a8
Merge branch 'master' of https://github.com/lucksus/perspectivism int…
jdeepee Feb 13, 2021
18b4f9f
Merge branch 'develop' of https://github.com/lucksus/perspectivism in…
jdeepee Feb 13, 2021
0ac4ef0
Updated social context dna
jdeepee Feb 13, 2021
baf2845
use lucksus remote for forked deps
jdeepee Feb 13, 2021
01af3d0
update package lock
jdeepee Feb 13, 2021
1018d9b
add languages dna js file
jdeepee Feb 13, 2021
b76e77b
add languages dna js file
jdeepee Feb 13, 2021
359a490
fix holochain link language
jdeepee Feb 13, 2021
a5d73a5
Merge branch 'develop'
lucksus Feb 24, 2021
c025fc6
Rename directory ACAI -> AD4M plus more string/doc/path replacements
lucksus Feb 24, 2021
b31d052
More path renaming acai -> ad4m
lucksus Feb 24, 2021
4b4eb64
Rewrite AD4M README
lucksus Feb 24, 2021
d7640ab
Replace old screenshots with logo in main readme
lucksus Feb 24, 2021
93bec0c
Fix typo
lucksus Feb 24, 2021
ab91494
Merge remote-tracking branch 'upstream/master' into develop
jdeepee Mar 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added possibility to insert seed into holochain link language such th…
…at unique perspectives are created upon sharing
  • Loading branch information
jdeepee committed Jan 20, 2021
commit 204e1443b1a68173e2842b10593056a16c7370b2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/src/languages/**/hc-dna/*.dna.gz
/src/stores/LinksStore.js
/src/main-thread
/src/languages/**/*.dna.workdir

holochain
lair-keystore
Expand Down
29 changes: 26 additions & 3 deletions src/core/LinkLanguageFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import fs from 'fs'
import path from 'path'
import multihashing from 'multihashing'
import baseX from 'base-x'
import child_process from "child_process"
import SharedPerspective, { SharingType } from "../acai/SharedPerspective";
import type AgentService from "./agent/AgentService";
import type Language from "../acai/Language";
import type { PublicSharing } from "../acai/Language";
import type LanguageRef from "../acai/LanguageRef";

const exec = child_process.execSync;

const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
const bs58 = baseX(BASE58)
Expand All @@ -28,7 +30,7 @@ export default class LinkLanguageFactory {
this.#agentService = agentService
}

async createLinkLanguageForSharedPerspective(sharedPerspective: SharedPerspective): Promise<LanguageRef> {
async createLinkLanguageForSharedPerspective(sharedPerspective: SharedPerspective, hcDnaSeed: string): Promise<LanguageRef> {
console.debug("LinkLanguageFactory: creating new link language for shared perspective:", sharedPerspective.name)

const name = `${sharedPerspective.name}-${sharedPerspective.type}-LinkLanguage`
Expand All @@ -49,8 +51,29 @@ export default class LinkLanguageFactory {
case SharingType.Holochain:
console.debug("LinkLanguageFactory: Holochain language")
const hcTemplateFilePath = path.join(process.env.PWD, templates.holochain)
console.debug("LinkLanguageFactory: reading template file", hcTemplateFilePath)
template = fs.readFileSync(hcTemplateFilePath).toString()
const hcDnaPath = path.join(process.env.PWD, "./src/languages/social-context/social-context.dna.gz")

if (hcDnaSeed != '') {
exec(`dna-util --expand ${hcDnaPath}`);
const hcDna = path.join(process.env.PWD, "./src/languages/social-context/social-context.dna.workdir")
const hcDnaJson = path.join(hcDna, "./dna.json")
var dnaJson = JSON.parse(fs.readFileSync(hcDnaJson).toString());
dnaJson["properties"] = {
"seed": hcDnaSeed
};
fs.writeFileSync(hcDnaJson, JSON.stringify(dnaJson));
exec(`dna-util --compress ${hcDna}`)

var base64 = fs.readFileSync(hcDnaPath, "base64").replace(/[\r\n]+/gm, '');
var dnaCode = `var dna = "${base64}";`.trim();
console.debug("LinkLanguageFactory: reading template file", hcTemplateFilePath)
template = fs.readFileSync(hcTemplateFilePath).toString()
const lines = template.split('\n')
lines.splice(4, 1, dnaCode)
template = lines.join('\n')
} else {
template = fs.readFileSync(hcTemplateFilePath).toString()
};
break;
default:
throw new Error(`SharingType ${sharedPerspective.type} not yet implementent`)
Expand Down
4 changes: 2 additions & 2 deletions src/core/PerspectivismCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class PerspectivismCore {
this.#linkLanguageFactory = new LinkLanguageFactory(this.#agentService, this.#languageController.getLanguageLanguage())
}

async publishPerspective(uuid: string, name: string, description: string, sharingType: SharingType): Promise<PerspectiveID> {
async publishPerspective(uuid: string, name: string, description: string, sharingType: SharingType, hcDnaSeed: string): Promise<PerspectiveID> {
// We only work on the PerspectiveID object.
// On PerspectiveController.update() below, the instance will get updated as well, but we don't need the
// instance object here
Expand All @@ -96,7 +96,7 @@ export default class PerspectivismCore {
const sharedPerspective = new SharedPerspective(name, description, sharingType)

// Create LinkLanguage
const linkLanguageRef = await this.#linkLanguageFactory.createLinkLanguageForSharedPerspective(sharedPerspective)
const linkLanguageRef = await this.#linkLanguageFactory.createLinkLanguageForSharedPerspective(sharedPerspective, hcDnaSeed)
sharedPerspective.linkLanguages = [linkLanguageRef]
await this.#languageController.installLanguage(linkLanguageRef.address)

Expand Down
5 changes: 3 additions & 2 deletions src/core/graphQL-interface/GraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ input PublishPerspectiveInput {
name: String
description: String
type: String
hcDnaSeed: String
}

input UpdateAgentProfileInput {
Expand Down Expand Up @@ -313,12 +314,12 @@ function createResolvers(core: PerspectivismCore) {
return perspective
},
publishPerspective: (parent, args, context, info) => {
const { uuid, name, description, type } = args.input
const { uuid, name, description, type, hcDnaSeed } = args.input
const perspective = core.perspectivesController.perspectiveID(uuid)
// @ts-ignore
if(perspective.sharedPerspective && perspective.sharedURL)
throw new Error(`Perspective ${name} (${uuid}) is already shared`)
return core.publishPerspective(uuid, name, description, type)
return core.publishPerspective(uuid, name, description, type, hcDnaSeed)
},
removePerspective: (parent, args, context, info) => {
const { uuid } = args
Expand Down
Binary file modified src/languages/social-context/social-context.dna.gz
Binary file not shown.
14 changes: 12 additions & 2 deletions src/ui/PerspectiveSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
let publishType = ''
let publishName = ''
let publishDescription = ''
let hcDnaSeed = ''
let isPublishing = false

const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -68,7 +69,8 @@
uuid: perspective.uuid,
name: publishName,
description: publishDescription,
type: publishType
type: publishType,
hcDnaSeed: hcDnaSeed
}
})
isPublishing = true
Expand Down Expand Up @@ -133,9 +135,17 @@
<Option value={'broadcast'} selected={false}>Broadcast</Option>
<Option value={'permissionless'} selected={true}>Permissionless</Option>
<Option value={'permissioned'} selected={false} deactivated={true}>Permissioned</Option>
<Option value={'holochain'} selected={false} deactivated={true}>Holochain</Option>
<Option value={'holochain'} selected={false}>Holochain</Option>
</Select>

{#if publishType === 'holochain'}
<Textfield fullwidth lineRipple={false} label="Holochain Perspective Password">
<Input bind:value={hcDnaSeed} id="input-hc-seed" aria-controls="input-hc-helper-text" aria-describedby="input-hc-helper-text" />
<FloatingLabel for="input-hc-seed">Holochain Perspective Password</FloatingLabel>
<LineRipple />
</Textfield>
{/if}

<p></p>

<Button variant="raised" on:click={publish} disabled={publishType==='permissioned' || isPublishing}>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/graphql_queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export const UPDATE_PERSPECTIVE = gql`
`

export const PUBLISH_PERSPECTIVE = gql`
mutation publishPerspective($uuid: String, $name: String, $description: String, $type: String) {
publishPerspective(input: {uuid: $uuid, name: $name, description: $description, type: $type}) {
mutation publishPerspective($uuid: String, $name: String, $description: String, $type: String, $hcDnaSeed: String) {
publishPerspective(input: {uuid: $uuid, name: $name, description: $description, type: $type, hcDnaSeed: $hcDnaSeed}) {
uuid
name
sharedURL
Expand Down