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

Feat/nostr/community #523

Draft
wants to merge 30 commits into
base: is-sprint-26
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d31b61d
wip: nostr
emidev98 Sep 11, 2023
590e9c4
wip: nostr
emidev98 Sep 13, 2023
bfd49ae
feat: nostr-tools compatibility
emidev98 Sep 13, 2023
fb6e915
fix: include tax in max button calculation
mwmerz Sep 19, 2023
76a805e
wip: nostr community tab
emidev98 Sep 20, 2023
91249e6
Merge branch 'is-sprint-26' of https://github.com/terra-money/station…
emidev98 Sep 20, 2023
3bde7eb
wip: nostr workers
emidev98 Sep 20, 2023
b2184ce
Merge pull request #529 from terra-money/ST-809-Do-not-allow-user-to-…
mwmerz Sep 21, 2023
cfd88e0
Merge pull request #528 from terra-money/is-sprint-26
mwmerz Sep 21, 2023
9f54bbf
feat: nostr chat
emidev98 Sep 26, 2023
3102b65
fix: styles and actions
emidev98 Sep 26, 2023
ed6a294
fix: check for return type on osmosis api
mwmerz Sep 26, 2023
536d4ed
wip: nostr styling
emidev98 Sep 27, 2023
c84d1be
wip: community styles
emidev98 Sep 27, 2023
0b09a9f
wip: community styles and actions
emidev98 Sep 27, 2023
a38e8bb
feat: community styling
emidev98 Sep 27, 2023
c92b326
Merge pull request #530 from terra-money/fix/ST-808-Gracefully-Fail-O…
mwmerz Sep 29, 2023
638067c
feat: increment version to align with sprint 26
mwmerz Sep 20, 2023
be6f773
Fix read decimals (#525)
ericHgorski Sep 13, 2023
6eca332
fix: add pool asset length check for map (#526)
ericHgorski Sep 13, 2023
ef758f6
St 752 improve error hadnling (#527)
ericHgorski Sep 13, 2023
8b886d7
chore: increment version
mwmerz Sep 13, 2023
b328fcb
Merge branch 'main' into is-sprint-27
mwmerz Sep 29, 2023
e16e750
Merge pull request #531 from terra-money/is-sprint-27
mwmerz Oct 2, 2023
f5e8fd9
hotfix: osmosis api result issue.
mwmerz Oct 5, 2023
f02d51d
hotfix: better error handle on api failure.
mwmerz Oct 5, 2023
1d261ac
Merge pull request #533 from terra-money/hotfix/osmosis-api-issue
mwmerz Oct 5, 2023
5b5c5c2
Merge branch 'main' of https://github.com/terra-money/station into fe…
emidev98 Oct 7, 2023
b11ad74
wip: login
emidev98 Oct 7, 2023
83b0307
feat: community login
emidev98 Oct 8, 2023
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
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SASS_PATH=node_modules:src/styles
# Docker Compose
COMPOSE_PROJECT_NAME=localterra
COMPOSE_PROJECT_NAME=localterra

REACT_APP_GIPHY_KEY=Kal3vjWQLATLG64m1qPvSqYYc4XI6Wsv
4,985 changes: 3,485 additions & 1,500 deletions package-lock.json

Large diffs are not rendered by default.

47 changes: 39 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"hompage": "https://station.money",
"author": "Terra <[email protected]> (https://station.money)",
"repository": "github:terra-money/station",
"version": "7.3.4",
"version": "7.3.5",
"license": "MIT",
"scripts": {
"start": "echo \"$CF_PAGES_COMMIT_SHA\" > public/commit_hash && react-scripts start",
Expand All @@ -20,35 +20,63 @@
},
"dependencies": {
"@amplitude/analytics-browser": "^2.0.0",
"@anchor-protocol/anchor.js": "^5.1.1",
"@dicebear/collection": "^7.0.1",
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@giphy/js-types": "^4.4.0",
"@giphy/react-components": "^9.0.1",
"@ledgerhq/hw-transport-web-ble": "^6.27.1",
"@mui/icons-material": "^5.8.0",
"@mui/material": "^5.9.1",
"@noble/curves": "^1.2.0",
"@noble/secp256k1": "^2.0.0",
"@sentry/react": "^7.53.1",
"@terra-money/feather.js": "^1.0.11",
"@terra-money/ledger-station-js": "^1.3.8",
"@terra-money/log-finder-ruleset": "^3.0.3",
"@terra-money/msg-reader": "^3.0.1",
"@terra-money/nostr-tools": "^1.10.4",
"@terra-money/station-connector": "^1.0.5",
"@terra-money/terra-station-mobile": "^1.0.12",
"@terra-money/terra-utils": "^1.0.9",
"@terra-money/terra.js": "^3.1.9",
"@terra-money/terra.proto": "^2.0.0",
"@terra-money/wallet-kit": "^1.0.15",
"@tippyjs/react": "^4.2.6",
"@tiptap/extension-document": "^2.1.10",
"@tiptap/extension-history": "^2.1.10",
"@tiptap/extension-mention": "^2.1.10",
"@tiptap/extension-paragraph": "^2.1.10",
"@tiptap/extension-text": "^2.1.10",
"@tiptap/react": "^2.1.8",
"@tiptap/suggestion": "^2.1.8",
"@types/lodash.chunk": "^4.2.7",
"@types/lodash.toarray": "^4.4.7",
"@types/lodash.uniq": "^4.5.7",
"axios": "^0.27.2",
"bech32": "^2.0.0",
"bignumber.js": "^9.0.2",
"buffer": "^6.0.3",
"classnames": "^2.3.2",
"comlink": "^4.4.1",
"crypto-js": "^4.1.1",
"date-fns": "^2.28.0",
"emoji-mart": "^5.5.2",
"i18next": "^21.8.14",
"i18next-browser-languagedetector": "^6.1.4",
"immutability-helper": "^3.1.1",
"joi": "^17.11.0",
"jotai": "^2.4.2",
"js-base64": "^3.7.2",
"keccak256": "^1.0.6",
"linkify-react": "^4.1.1",
"lodash.chunk": "^4.2.0",
"lodash.isequal": "^4.5.0",
"lodash.toarray": "^4.4.0",
"lodash.uniq": "^4.5.0",
"lodash.uniqby": "^4.7.0",
"lottie-react": "^2.3.1",
"moment": "^2.29.4",
"numeral": "^2.0.6",
"prettier": "^2.6.2",
"qrcode.react": "^3.1.0",
Expand All @@ -62,17 +90,24 @@
"react-modal": "^3.15.1",
"react-query": "^3.39.3",
"react-router-dom": "^6.15.0",
"react-string-replace": "^1.1.1",
"recharts": "^2.1.16",
"recoil": "^0.7.2",
"sass": "^1.52.1",
"secp256k1": "^4.0.3",
"semver": "^7.5.2",
"sentence-case": "^3.0.4",
"webpack": "^4.44.2",
"xss": "1.0.11"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@types/crypto-js": "^4.1.1",
"@types/jest": "^27.5.1",
"@types/lodash.isequal": "^4.5.6",
"@types/lodash.uniqby": "^4.7.7",
"@types/node": "^17.0.35",
"@types/numeral": "^2.0.2",
"@types/qrcode.react": "^1.0.2",
Expand Down Expand Up @@ -107,14 +142,10 @@
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
"defaults"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
"defaults"
]
}
}
Binary file added public/giphy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/app/electron.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { Event } from "@terra-money/nostr-tools"
import { RelayDict } from "types/nostr"
import Raven from "utils/nostr/raven"

declare global {
interface Window {
require: NodeRequire
electron: any
raven: Raven | undefined
nostr?: {
getPublicKey: () => Promise<string>
signEvent: (event: Event) => Promise<Event>
getRelays: () => Promise<RelayDict>
nip04: {
encrypt: (pubkey: string, content: string) => Promise<string>
decrypt: (pubkey: string, content: string) => Promise<string>
}
}
requestPrivateKey: (data?: any) => Promise<string>
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/app/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import Labs from "pages/labs/Labs"
/* 404 */
import NotFound from "pages/NotFound"
import DonateAllVestingTokensTx from "txs/stake/DonateAllVestingTokensTx"
import { Group } from "@mui/icons-material"
import { Community } from "pages/community/Community"

const ICON_SIZE = { width: 20, height: 20 }

Expand Down Expand Up @@ -82,6 +84,12 @@ export const useNav = () => {
title: t("Governance"),
icon: <GovernanceIcon {...ICON_SIZE} />,
},
{
path: "/community",
element: <Community />,
title: t("Community"),
icon: <Group {...ICON_SIZE} />,
},
...(devMode
? [
{
Expand Down Expand Up @@ -129,6 +137,9 @@ export const useNav = () => {
//{ path: "/network/new", element: <AddNetworkPage /> },
{ path: "/settings", element: <Settings /> },

/* community */
{ path: "/community", element: <Community /> },

/* dev */
{ path: "/labs", element: <Labs /> },

Expand Down
4 changes: 4 additions & 0 deletions src/components/channel/Channel.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.ChannelView {
display: grid;
grid-auto-flow: column;
}
35 changes: 35 additions & 0 deletions src/components/channel/chat-input/ChatInput.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.ChatInputWrapper {
margin: 14px;
flex-grow: 0;
flex-shrink: 0;
border-radius: var(--border-radius);
background-color: var(--bg-muted);
}

.ChatInput {
padding: 1em;
}

.ToolsWrapper {
padding-left: 12px;
display: flex;
align-items: center;
gap: 0.75em;
}

.ChatActions {
border-top: 1px solid var(--input-border);
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px;
height: 60px;
}
.EditorContent {
padding: 1em;
}

.SendButton {
height: 38px;
min-width: 100px;
}
133 changes: 133 additions & 0 deletions src/components/channel/chat-input/editor/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { useRef } from "react"
import { Extension, ReactRenderer, useEditor } from "@tiptap/react"
import Document from "@tiptap/extension-document"
import Paragraph from "@tiptap/extension-paragraph"
import Text from "@tiptap/extension-text"
import History from "@tiptap/extension-history"
import { Mention } from "@tiptap/extension-mention"
import tippy, { GetReferenceClientRect, Instance } from "tippy.js"
import { SuggestionProps } from "@tiptap/suggestion"
import { MentionListRef } from "./types"
import MentionList from "./mention-list"

const useMakeEditor = ({
content,
onUpdate,
}: {
content: string
onUpdate: () => void
}) => {
const reactRenderer = useRef<ReactRenderer<MentionListRef> | null>(null)
let saveTimer: any = null

return useEditor({
extensions: [
Document,
Paragraph,
Text,
History,
Extension.create({
name: "ShiftEnterExtension",
addKeyboardShortcuts() {
return {
"Shift-Enter": () =>
this.editor.commands.first(({ commands }) => [
() => commands.createParagraphNear(),
() => commands.liftEmptyBlock(),
() => commands.splitBlock(),
]),
Enter: () => true,
}
},
}),
Mention.configure({
HTMLAttributes: {
class: "mention",
},
renderLabel({ options, node }) {
const label = (options?.suggestion?.char as string) || ""
return `${label}${String(node?.attrs?.label)}`
},
suggestion: {
render: () => {
let popup: Instance[]

return {
onStart: (
props: Pick<SuggestionProps, "editor" | "clientRect">
) => {
reactRenderer.current = new ReactRenderer(MentionList, {
props,
editor: props.editor,
})

if (!props.clientRect) {
return
}

popup = tippy("body", {
getReferenceClientRect:
props.clientRect as GetReferenceClientRect,
appendTo: () => document.body,
content: reactRenderer.current.element,
showOnCreate: true,
interactive: true,
trigger: "manual",
placement: "top-start",
})
},
onUpdate(props: Pick<SuggestionProps, "clientRect">) {
if (reactRenderer.current) {
reactRenderer.current.updateProps(props)
}

if (!props.clientRect) {
return
} else {
popup[0].setProps({
getReferenceClientRect:
props.clientRect as GetReferenceClientRect,
})
}
},
onKeyDown(props: { event: KeyboardEvent }) {
props.event.stopPropagation()
if (props.event.key === "Escape") {
popup[0].hide()

return true
}

if (reactRenderer.current && reactRenderer.current.ref) {
return reactRenderer.current.ref?.onKeyDown(props)
} else {
return false
}
},
onExit() {
if (popup) {
popup[0]?.destroy()
}
setTimeout(() => {
if (reactRenderer.current) {
reactRenderer.current.destroy()
}
reactRenderer.current = null
}, 0)
},
}
},
},
}),
],
content: content,
onUpdate: () => {
clearTimeout(saveTimer)
saveTimer = setTimeout(() => {
onUpdate()
}, 200)
},
})
}

export default useMakeEditor
Loading