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

chore(frontend): remix v2 upgrade #2349

Merged
merged 44 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
094e6f0
chore(frontend): update error boundaries to v2
BlairCurrey Jan 18, 2024
28d892b
chore(frontend): update meta to v2
BlairCurrey Jan 18, 2024
ef8760a
chore(frontend): update headers to v2
BlairCurrey Jan 18, 2024
6228d2c
chore(frontend): update form method to v2
BlairCurrey Jan 18, 2024
ca9ad2c
chore(frontend): update to v2 dev server
BlairCurrey Jan 18, 2024
38cfb94
chore(frontend): update server module format to v2
BlairCurrey Jan 18, 2024
6ded4de
feat(frontend): typecheck cmd
BlairCurrey Jan 19, 2024
1506658
fix(frontend): type only import
BlairCurrey Jan 19, 2024
00f4874
feat(frontend): ugprade remix to v2
BlairCurrey Jan 19, 2024
85b386a
feat: add frontend typecheck to ci
BlairCurrey Jan 19, 2024
3b32e7b
chore(MASE): upgrade routes to remix v2
BlairCurrey Jan 19, 2024
d45879b
chore(MASE): upgrade module format to v2
BlairCurrey Jan 19, 2024
91c22ca
chore(MASE): update to v2 dev server
BlairCurrey Jan 19, 2024
95870de
chore(MASE): update headers to v2
BlairCurrey Jan 19, 2024
b7e53ea
chore(MASE): update form method to v2
BlairCurrey Jan 19, 2024
47ee050
chore(MASE): update meta to v2
BlairCurrey Jan 19, 2024
adda951
chore(MASE): update error/catch boundary to v2
BlairCurrey Jan 19, 2024
3beabe9
feat(MASE): upgrade remix to v2
BlairCurrey Jan 19, 2024
3d115f3
fix(MASE): ts errors
BlairCurrey Jan 19, 2024
50d51c6
feat(MASE): add typecheck cmd to ci
BlairCurrey Jan 19, 2024
37f5fa8
fix(frontend, MASE): remix server start
BlairCurrey Jan 22, 2024
1a3bacb
Merge branch 'main' into bc/1464/remix-v2-updates
BlairCurrey Jan 22, 2024
32e29c1
fix(MASE): eslint
BlairCurrey Jan 22, 2024
29c4a24
refactor(MASE): parseQueryString to URLSearchParams
BlairCurrey Jan 22, 2024
9969315
Update .github/workflows/lint_test_build.yml
BlairCurrey Jan 23, 2024
0c660ae
fix(frontend,MASE): update entry.server request handlers
BlairCurrey Jan 23, 2024
8250581
chore(MASE): format
BlairCurrey Jan 23, 2024
41673bb
chore(MASE): rm unused quotes route
BlairCurrey Jan 23, 2024
f7149aa
Merge branch 'main' into bc/1464/remix-v2-updates
BlairCurrey Jan 24, 2024
632ad8c
Revert "Merge branch 'main' into bc/1464/remix-v2-updates"
BlairCurrey Jan 24, 2024
7a6ad8b
chore: cherry pick merge commit after reverting in f7149aa
BlairCurrey Jan 24, 2024
6b72997
Merge branch 'main' into bc/1464/remix-v2-updates
BlairCurrey Jan 24, 2024
fb4e5b7
fix(frontend,MASE): mobile view
BlairCurrey Jan 24, 2024
dab6502
fix(frontend): no flash on mobile
BlairCurrey Jan 24, 2024
2db091c
refactor: rework new cookie secure env var
BlairCurrey Jan 25, 2024
b35dc09
fix: move env var declaration from dockerfile to compose
BlairCurrey Jan 25, 2024
a51f877
Merge branch 'main' into bc/1464/remix-v2-updates
BlairCurrey Jan 25, 2024
58fb5e4
Merge branch 'main' into bc/1464/remix-v2-updates
BlairCurrey Jan 25, 2024
93c8318
feat(backend): upgrade Rafiki to open payments package v6.5 (#2337)
sabineschaller Jan 23, 2024
230d57e
chore(deps): update dependency autoprefixer to ^10.4.17 (#2352)
renovate[bot] Jan 23, 2024
e358d16
chore: update lockfile
BlairCurrey Jan 25, 2024
05f65f6
chore: rm extra space
BlairCurrey Jan 25, 2024
eaaee0e
chore: rm unnecessary eslint ignore
BlairCurrey Jan 25, 2024
455ebb8
Merge branch 'main' into bc/1464/remix-v2-updates
BlairCurrey Jan 25, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/lint_test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/rafiki/env-setup
- run: pnpm --filter frontend typecheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

- run: pnpm --filter frontend build

auth:
Expand All @@ -83,6 +84,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/rafiki/env-setup
- run: pnpm --filter mock-account-servicing-entity typecheck
- run: pnpm --filter mock-account-servicing-entity build

token-introspection:
Expand Down
2 changes: 1 addition & 1 deletion localenv/cloud-nine-wallet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ services:
ports:
- '3030:80'
environment:
NODE_ENV: ${NODE_ENV:-development}
LOG_LEVEL: debug
PORT: 80
SEED_FILE_LOCATION: /workspace/seed.yml
Expand Down Expand Up @@ -115,6 +114,7 @@ services:
PORT: 3010
GRAPHQL_URL: http://cloud-nine-wallet-backend:3001/graphql
OPEN_PAYMENTS_URL: https://cloud-nine-wallet-backend/
ENABLE_INSECURE_MESSAGE_COOKIE: true
depends_on:
- cloud-nine-backend

Expand Down
2 changes: 1 addition & 1 deletion localenv/happy-life-bank/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ services:
ports:
- '3031:80'
environment:
NODE_ENV: development
LOG_LEVEL: debug
PORT: 80
SEED_FILE_LOCATION: /workspace/seed.yml
Expand Down Expand Up @@ -83,6 +82,7 @@ services:
PORT: 4010
GRAPHQL_URL: http://happy-life-bank-backend:3001/graphql
OPEN_PAYMENTS_URL: https://happy-life-bank-backend/
ENABLE_INSECURE_MESSAGE_COOKIE: true
depends_on:
- cloud-nine-admin
- happy-life-backend
Expand Down
2 changes: 1 addition & 1 deletion localenv/mock-account-servicing-entity/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ COPY --from=builder /home/rafiki/localenv/mock-account-servicing-entity/build ./
COPY --from=builder /home/rafiki/localenv/mock-account-servicing-entity/public ./localenv/mock-account-servicing-entity/public

WORKDIR /home/rafiki/localenv/mock-account-servicing-entity
CMD ["sh", "./node_modules/.bin/remix-serve", "build"]
CMD ["sh", "./node_modules/.bin/remix-serve", "./build/index.js"]
20 changes: 13 additions & 7 deletions localenv/mock-account-servicing-entity/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PassThrough } from 'stream'
import type { EntryContext } from '@remix-run/node'
import { Response } from '@remix-run/node'
import { createReadableStreamFromReadable } from '@remix-run/node'
import { RemixServer } from '@remix-run/react'
import { renderToPipeableStream } from 'react-dom/server'
import { runSeed } from './lib/run_seed.server'
Expand Down Expand Up @@ -47,20 +47,22 @@ export default function handleRequest(
remixContext: EntryContext
) {
return new Promise((resolve, reject) => {
let didError = false
let shellRendered = false

const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} />,
{
onShellReady: () => {
shellRendered = true
const body = new PassThrough()
const stream = createReadableStreamFromReadable(body)

responseHeaders.set('Content-Type', 'text/html')

resolve(
new Response(body, {
new Response(stream, {
headers: responseHeaders,
status: didError ? 500 : responseStatusCode
status: responseStatusCode
})
)

Expand All @@ -70,9 +72,13 @@ export default function handleRequest(
reject(err)
},
onError: (error) => {
didError = true

console.error(error)
responseStatusCode = 500
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error)
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ interface Transaction {
}

export interface IncomingPayment extends Transaction {
incomingAmountValue: string
incomingAmountValue?: string
}

export interface OutgoingPayment extends Transaction {
receiver: string
sendAmountValue: string
sentAmountValue: string
receiveAmount: Amount
}

Expand All @@ -45,30 +45,36 @@ export async function getAccountTransactions(
const { incomingPayments, outgoingPayments } = await getWalletAddressPayments(
account.walletAddressID
)
const transactions = incomingPayments.edges.map(({ node }) => {
return {
id: node.id,
metadata: node.metadata,
incomingAmountValue: node.incomingAmount?.value,
amountValue: node.receivedAmount.value,
assetCode: node.receivedAmount.assetCode,
assetScale: node.receivedAmount.assetScale,
state: node.state,
createdAt: node.createdAt,
type: TransactionType.IncomingPayment
}
})

const incomingPaymentEdges = incomingPayments?.edges || []
const outgoingPaymentEdges = outgoingPayments?.edges || []

const transactions: Array<IncomingPayment | OutgoingPayment> =
incomingPaymentEdges.map(({ node }) => {
return {
id: node.id,
metadata: node.metadata,
incomingAmountValue: node.incomingAmount?.value?.toString(),
amountValue: node.receivedAmount.value.toString(),
assetCode: node.receivedAmount.assetCode,
assetScale: node.receivedAmount.assetScale,
state: node.state,
createdAt: node.createdAt,
type: TransactionType.IncomingPayment
}
})

return transactions.concat(
outgoingPayments.edges.map(({ node }) => {
outgoingPaymentEdges.map(({ node }) => {
return {
id: node.id,
receiver: node.receiver,
metadata: node.metadata,
debitAmountValue: node.debitAmount.value,
amountValue: node.sentAmount.value,
sentAmountValue: node.sentAmount.value.toString(),
amountValue: node.sentAmount.value.toString(),
receiveAmount: node.receiveAmount,
assetCode: node.debitAmount.assetCode,
assetScale: node.debitAmount.assetScale,
assetCode: node.sentAmount.assetCode,
assetScale: node.sentAmount.assetScale,
state: node.state,
createdAt: node.createdAt,
type: TransactionType.OutgoingPayment
Expand Down
39 changes: 0 additions & 39 deletions localenv/mock-account-servicing-entity/app/lib/utils.ts

This file was deleted.

10 changes: 5 additions & 5 deletions localenv/mock-account-servicing-entity/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
ScrollRestoration
} from '@remix-run/react'

export const meta: MetaFunction = () => ({
charset: 'utf-8',
title: 'Mock Account Servicing Entity',
viewport: 'width=device-width,initial-scale=1'
})
export const meta: MetaFunction = () => [
{ charset: 'utf-8' },
{ title: 'Mock Account Servicing Entity' },
{ name: 'viewport', content: 'width=device-width,initial-scale=1' }
]

export const links: LinksFunction = () => {
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json } from '@remix-run/node'
import { LoaderFunctionArgs, json } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
import { getAccountTransactions } from '../lib/transactions.server'
import tableStyle from '../styles/table.css'
Expand All @@ -7,9 +7,14 @@ type LoaderData = {
transactions: Awaited<ReturnType<typeof getAccountTransactions>>
}

export const loader = async ({ params }) => {
export const loader = async ({ params }: LoaderFunctionArgs) => {
const { accountId } = params

if (!accountId) {
throw json(null, { status: 400, statusText: 'Account not provided.' })
}
return json<LoaderData>({
transactions: await getAccountTransactions(params.accountId)
transactions: await getAccountTransactions(accountId)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { Dispatch, SetStateAction } from 'react'
import { useEffect, useState } from 'react'
import { ApiClient } from '~/lib/apiClient'
import type { Access } from '~/lib/types'
import { parseQueryString } from '~/lib/utils'

interface ConsentScreenContext {
ready: boolean
Expand Down Expand Up @@ -230,28 +229,29 @@ export default function ConsentScreen() {
errors: new Array<Error>()
} as ConsentScreenContext)
const location = useLocation()
const queryParams = parseQueryString(location.search)
const queryParams = new URLSearchParams(location.search)

useEffect(() => {
if (
ctx.errors.length === 0 &&
!ctx.ready &&
queryParams.has('interactId', 'nonce')
queryParams.has('interactId') &&
queryParams.has('nonce')
) {
const interactId = queryParams.getAsString('interactId')
const nonce = queryParams.getAsString('nonce')
const returnUrl = queryParams.getAsString('returnUrl')
const clientName = queryParams.getAsString('clientName') as string
const clientUri = queryParams.getAsString('clientUri') as string
const interactId = queryParams.get('interactId')
const nonce = queryParams.get('nonce')
const returnUrl = queryParams.get('returnUrl')
const clientName = queryParams.get('clientName')
const clientUri = queryParams.get('clientUri')
if (interactId && nonce) {
setCtx({
...ctx,
ready: true,
interactId,
nonce,
returnUrl: returnUrl || ctx.returnUrl,
thirdPartyName: clientName,
thirdPartyUri: clientUri
thirdPartyName: clientName || '',
thirdPartyUri: clientUri || ''
})
}
}
Expand All @@ -278,8 +278,10 @@ export default function ConsentScreen() {
})
} else {
const outgoingPaymentAccess =
response.payload.find((p) => p.type === 'outgoing-payment') ||
null
response.payload.find(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(p: Record<string, any>) => p.type === 'outgoing-payment'
) || null
const returnUrlObject = new URL(ctx.returnUrl)
returnUrlObject.searchParams.append(
'grantId',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { LoaderFunctionArgs } from '@remix-run/node'

export function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url)
return new Response(
JSON.stringify({
interact_ref: url.searchParams.get('interact_ref'),
hash: url.searchParams.get('hash')
})
)
}

This file was deleted.

Loading
Loading