Skip to content

Commit

Permalink
Merge pull request #212 from radixdlt/uuid
Browse files Browse the repository at this point in the history
refactor: use uuidv4 for wallet interaction id
  • Loading branch information
xstelea authored Jun 10, 2024
2 parents c36f644 + cea7fd0 commit ce2f00e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 32 deletions.
31 changes: 13 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"deploy:simple-dapp": "turbo deploy --filter simple-dapp"
},
"devDependencies": {
"prettier": "^3.2.5",
"turbo": "latest",
"husky": "^8.0.3",
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2"
"@commitlint/config-conventional": "^17.4.2",
"husky": "^8.0.3",
"prettier": "^3.2.5",
"turbo": "latest"
},
"engines": {
"node": ">=18"
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
"immer": "^10.0.4",
"lit": "^3.1.2",
"lit-html": "^3.1.2",
"nanoid": "^5.0.7",
"neverthrow": "^6.1.0",
"rxjs": "^7.8.1",
"tslog": ">=4.8.0",
"uuid": "^10.0.0",
"valibot": "^0.30.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ResultAsync } from 'neverthrow'
import { errAsync, okAsync } from 'neverthrow'
import type { IdentityModule } from '../identity/identity.module'
import { StorageModule } from '../../storage/local-storage.module'
import { nanoid } from 'nanoid'
import { v4 as uuidV4 } from 'uuid'

type Status = (typeof Status)[keyof typeof Status]
const Status = { Pending: 'Pending', Active: 'Active' } as const
Expand Down Expand Up @@ -53,7 +53,7 @@ export const SessionModule = (input: {
storageModule.getItemById(sessionId)

const createSession = (): ResultAsync<PendingSession, Error> => {
const sessionId = nanoid()
const sessionId = uuidV4()
const newSession: PendingSession = {
sessionId,
status: Status.Pending,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { RequestItemModule } from '../../request-items'
import { StorageModule } from '../../../storage'
import { SdkError } from '../../../../error'
import { TransportProvider } from '../../../../_types'
import { nanoid } from 'nanoid'
import { v4 as uuidV4 } from 'uuid'

export type ConnectorExtensionModule = ReturnType<
typeof ConnectorExtensionModule
Expand Down Expand Up @@ -109,7 +109,7 @@ export const ConnectorExtensionModule = (input: {
interaction.items.discriminator === 'authorizedRequest'

const sessionId = isAuthorizedRequest
? state?.sessionId || nanoid()
? state?.sessionId || uuidV4()
: state?.sessionId

const wrappedRequest = {
Expand Down Expand Up @@ -273,7 +273,7 @@ export const ConnectorExtensionModule = (input: {
const extensionStatus$ = of(true).pipe(
tap(() => {
subjects.outgoingMessageSubject.next({
interactionId: nanoid(),
interactionId: uuidV4(),
discriminator: 'extensionStatus',
})
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '../../schemas'
import { parse } from 'valibot'
import { SdkError } from '../../error'
import { nanoid } from 'nanoid'
import { v4 as uuidV4 } from 'uuid'

export type WalletRequestSdkInput = {
networkId: number
Expand Down Expand Up @@ -50,7 +50,7 @@ export const WalletRequestSdk = (input: WalletRequestSdkInput) => {

const createWalletInteraction = (
items: WalletInteractionItems,
interactionId = nanoid(),
interactionId = uuidV4(),
): WalletInteraction => ({
items,
interactionId,
Expand Down Expand Up @@ -82,7 +82,7 @@ export const WalletRequestSdk = (input: WalletRequestSdkInput) => {

const request = (
{
interactionId = nanoid(),
interactionId = uuidV4(),
items,
}: Pick<WalletInteraction, 'items'> & { interactionId?: string },
callbackFns: Partial<CallbackFns> = {},
Expand All @@ -101,7 +101,7 @@ export const WalletRequestSdk = (input: WalletRequestSdkInput) => {

const sendTransaction = (
{
interactionId = nanoid(),
interactionId = uuidV4(),
items,
}: { interactionId?: string; items: WalletInteraction['items'] },
callbackFns: Partial<CallbackFns> = {},
Expand Down

0 comments on commit ce2f00e

Please sign in to comment.