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

refactor: use rola library #115

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/helpers/hash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Buffer } from 'buffer'
import blake from 'blakejs'
import { bufferToUnit8Array } from '../rola/crypto/blake2b'
import { bufferToUnit8Array } from './blake2b'

export function hash(input: string): Buffer {
return Buffer.from(
Expand Down
18 changes: 7 additions & 11 deletions examples/rola/RolaPage.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Box, Button, Input } from '@mui/joy'
import { Box, Button } from '@mui/joy'
import * as React from 'react'
import { Card } from '../components/Card'
import { createChallenge } from '../helpers/create-challenge'
import { useRdt } from '../rdt/hooks/useRdt'
import { useLogger } from '../components/Logger'
import { Code } from '../components/Code'

import { useDAppDefinitionAddress } from '../rdt/rdt'
import { RolaError, RolaFactory } from './rola'
import { useNetworkId } from '../network/state'
import { GatewayService } from './gateway'
import { DataRequestBuilder } from '../../src'
import { Rola, RolaError } from '@radixdlt/rola'

export const RolaPage = () => {
const dAppDefinitionAddress = useDAppDefinitionAddress()
Expand All @@ -24,8 +22,8 @@ export const RolaPage = () => {
const rdt = useRdt()
const networkId = useNetworkId()
const { Logger, addLog } = useLogger()
const rola = RolaFactory({
gatewayService: GatewayService(),
const { verifySignedChallenge } = Rola({
applicationName: 'dApp Sandbox',
expectedOrigin: origin,
dAppDefinitionAddress,
networkId,
Expand Down Expand Up @@ -54,7 +52,7 @@ export const RolaPage = () => {
loading: false,
}))

return rola(response.proofs![0])
return verifySignedChallenge(response.proofs![0])
})
.map(() => {
setState((prev) => ({
Expand All @@ -63,9 +61,7 @@ export const RolaPage = () => {
}))
})
.mapErr((error) => {
addLog(
`ROLA error: ${(error as unknown as RolaError).reason}`
)
addLog(`ROLA error: ${(error as any).reason}`)
setState((prev) => ({
...prev,
loading: false,
Expand Down Expand Up @@ -94,7 +90,7 @@ export const RolaPage = () => {
loading: false,
}))

return rola(signedChallenge)
return verifySignedChallenge(signedChallenge)
})
.map(() => {
setState((prev) => ({
Expand Down
3 changes: 0 additions & 3 deletions examples/rola/crypto/curve25519.ts

This file was deleted.

3 changes: 0 additions & 3 deletions examples/rola/crypto/secp256k1.ts

This file was deleted.

9 changes: 0 additions & 9 deletions examples/rola/crypto/secure-random.ts

This file was deleted.

21 changes: 0 additions & 21 deletions examples/rola/gateway.ts

This file was deleted.

12 changes: 0 additions & 12 deletions examples/rola/helpers/create-public-key-hash.ts

This file was deleted.

18 changes: 0 additions & 18 deletions examples/rola/helpers/create-signature-message.spec.ts

This file was deleted.

47 changes: 0 additions & 47 deletions examples/rola/helpers/create-signature-message.ts

This file was deleted.

44 changes: 0 additions & 44 deletions examples/rola/helpers/derive-address-from-public-key.spec.ts

This file was deleted.

68 changes: 0 additions & 68 deletions examples/rola/helpers/derive-address-from-public-key.ts

This file was deleted.

Loading