Skip to content

Commit

Permalink
Merge branch 'staging' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
ckniffen authored Dec 6, 2023
2 parents 7f68b63 + db27c87 commit ebbcb6d
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 1,651 deletions.
2,022 changes: 421 additions & 1,601 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
"description": "XRPL Data Visualization",
"version": "1.5.0",
"dependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@google-cloud/bigquery": "^7.3.0",
"@paystring/utils": "^2.0.0",
"@redux-devtools/extension": "^3.2.6",
"@rollup/plugin-inject": "^5.0.5",
"@vitejs/plugin-react": "^3.0.0",
"@xrplf/prettier-config": "^1.9.1",
"@xrplf/isomorphic": "^1.0.0-beta.1",
"assert": "^2.1.0",
"autoprefixer": "^10.4.16",
"axios": "^1.5.1",
"body-parser": "^1.20.2",
"buffer": "^6.0.3",
"bunyan": "^1.8.15",
"classnames": "^2.3.2",
"compression": "^1.7.4",
"create-hash": "^1.2.0",
"d3": "^7.8.5",
"d3-geo": "^3.1.0",
"d3-hexbin": "^0.2.2",
Expand Down Expand Up @@ -47,19 +45,14 @@
"redux": "^4.2.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"rewire": "^6.0.0",
"ripple-address-codec": "^4.3.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-polyfill-node": "^0.12.0",
"stream-browserify": "^3.0.0",
"ripple-address-codec": "^5.0.0-beta.1",
"topojson-client": "^3.0.0",
"usehooks-ts": "^2.9.1",
"vite": "^4.2.3",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-html": "^3.2.0",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.2.0",
"ws": "^7.4.2",
"xrpl-client": "^2.1.0"
},
"devDependencies": {
Expand Down Expand Up @@ -112,7 +105,7 @@
"ts-jest": "^26.5.6",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"xrpl": "^2.10.0"
"xrpl": "^3.0.0-beta.1"
},
"resolutions": {
"jest-environment-jsdom": "29.3.1"
Expand Down
14 changes: 6 additions & 8 deletions src/containers/shared/amendmentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { sha512 } from '@xrplf/isomorphic/sha512'
import { hexToBytes, bytesToHex, stringToHex } from '@xrplf/isomorphic/utils'
import axios from 'axios'
import createHash from 'create-hash'

import { localizeDate } from './utils'

const cachedAmendmentIDs: any = {}
Expand Down Expand Up @@ -48,12 +50,8 @@ async function fetchAmendmentNames() {
return amendmentNames
}

function sha512Half(buffer: Buffer) {
return createHash('sha512')
.update(buffer)
.digest('hex')
.toUpperCase()
.slice(0, 64)
function sha512Half(buffer: Uint8Array) {
return bytesToHex(sha512(buffer)).slice(0, 64)
}

export async function nameOfAmendmentID(id: string) {
Expand All @@ -63,7 +61,7 @@ export async function nameOfAmendmentID(id: string) {
// The Amendment ID is the hash of the Amendment name
const amendmentNames = await fetchAmendmentNames()
amendmentNames.forEach((name) => {
cachedAmendmentIDs[sha512Half(Buffer.from(name, 'ascii'))] = name
cachedAmendmentIDs[sha512Half(hexToBytes(stringToHex(name)))] = name
})

return cachedAmendmentIDs[id]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ export const Description = ({
<Trans
i18nKey="amm_delete_description"
components={{
// @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451
Asset: <Currency currency={Asset.currency} issuer={Asset.issuer} />,
Asset2: (
<Currency
currency={Asset2.currency}
// @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451
issuer={Asset2.issuer}
/>
<Currency currency={Asset2.currency} issuer={Asset2.issuer} />
),
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ export const Simple = ({ data }: TransactionSimpleProps<AMMDelete>) => {
return (
<>
<SimpleRow label={t('asset1')} data-test="asset1">
{/* @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451 */}
<Currency currency={Asset.currency} issuer={Asset.issuer} />
</SimpleRow>
<SimpleRow label={t('asset2')} data-test="asset2">
{/* @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451 */}
<Currency currency={Asset2.currency} issuer={Asset2.issuer} />
</SimpleRow>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
getRippledVersion,
nameOfAmendmentID,
} from '../../../amendmentUtils'
import { AMENDMENT_ROUTE } from '../../../../App/routes'
import { RouteLink } from '../../../routing'

const states = {
loading: 'Loading',
Expand Down Expand Up @@ -46,7 +48,7 @@ export const Simple = ({ data }: TransactionSimpleProps<EnableAmendment>) => {
})
}, [data.instructions.Amendment])

let amendmentStatus
let amendmentStatus = states.unknown
let expectedDate: string | null = states.unknown

switch (data.instructions.Flags) {
Expand All @@ -67,7 +69,12 @@ export const Simple = ({ data }: TransactionSimpleProps<EnableAmendment>) => {
return (
<>
<SimpleRow label="Amendment Name" data-test="name">
{amendmentDetails.name}
<RouteLink
to={AMENDMENT_ROUTE}
params={{ identifier: data.instructions.Amendment }}
>
{amendmentDetails.name}
</RouteLink>
</SimpleRow>
<SimpleRow label="Amendment Status" data-test="status">
<a href="https://xrpl.org/enableamendment.html#enableamendment-flags">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ describe('EnableAmendment: Simple', () => {

expectSimpleRowText(wrapper, 'name', 'ExpandedSignerList')
expectSimpleRowText(wrapper, 'version', 'v1.9.1')
expect(wrapper.find('[data-test="name"] .value a')).toHaveProp(
'href',
'/amendment/B2A4DB846F0891BF2C76AB2F2ACC8F5B4EC64437135C6E56F3F859DE5FFD5856',
)

wrapper.unmount()
})
Expand Down
5 changes: 5 additions & 0 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'jest-enzyme'
import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-17-updated'

import { TextEncoder, TextDecoder } from 'util'

const mockStorage = {}

window.dataLayer = window.dataLayer || []
Expand All @@ -20,6 +22,9 @@ jest.spyOn(console, 'error')
// @ts-expect-error
// eslint-disable-next-line no-console -- only for tests
console.error.mockImplementation(() => {})
window.TextEncoder = TextEncoder
// @ts-expect-error -- TextDecoder needs to be defined for jest
window.TextDecoder = TextDecoder

afterEach(() => {
window.dataLayer = []
Expand Down
22 changes: 0 additions & 22 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import viteTsconfigPaths from 'vite-tsconfig-paths'
import svgrPlugin from 'vite-plugin-svgr'
import { createHtmlPlugin } from 'vite-plugin-html'
import EnvironmentPlugin from 'vite-plugin-environment'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import inject from '@rollup/plugin-inject'
import polyfillNode from 'rollup-plugin-polyfill-node'
import autoprefixer from 'autoprefixer'

import 'dotenv/config'
Expand All @@ -33,14 +30,6 @@ export default defineConfig({
rollupOptions: {
// improve CPU usage
cache: false,
plugins: [
// https://github.com/vitejs/vite/discussions/2785
inject({
modules: { Buffer: ['buffer', 'Buffer'] },
}),
// include polyfills
polyfillNode(),
],
},
},
// relative to the root
Expand All @@ -57,8 +46,6 @@ export default defineConfig({
// polyfills
alias: {
events: 'events',
stream: 'stream-browserify',
zlib: 'browserify-zlib',
},
},
optimizeDeps: {
Expand All @@ -67,12 +54,6 @@ export default defineConfig({
// Node.js global to browser globalThis
global: 'globalThis',
},
plugins: [
// activate Buffer
NodeGlobalsPolyfillPlugin({
buffer: true,
}),
],
},
},
plugins: [
Expand All @@ -98,9 +79,6 @@ export default defineConfig({
// use env vars
EnvironmentPlugin('all'),
// activate buffer and process
NodeGlobalsPolyfillPlugin({
buffer: true,
}),
// use TS paths
viteTsconfigPaths(),
],
Expand Down

0 comments on commit ebbcb6d

Please sign in to comment.