diff --git a/packages/stellar-wallet-snap/src/api/index.ts b/packages/stellar-wallet-snap/src/api/index.ts index 09c489b7..9411b998 100644 --- a/packages/stellar-wallet-snap/src/api/index.ts +++ b/packages/stellar-wallet-snap/src/api/index.ts @@ -1,7 +1,6 @@ export * from './network'; export * from './asset'; export * from './environment'; -export * from './uuid'; export * from './address'; export * from './json'; export * from './integer'; diff --git a/packages/stellar-wallet-snap/src/api/uuid.test.ts b/packages/stellar-wallet-snap/src/api/uuid.test.ts deleted file mode 100644 index 73f311e2..00000000 --- a/packages/stellar-wallet-snap/src/api/uuid.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { assert, StructError } from '@metamask/superstruct'; - -import { UuidStruct } from './uuid'; - -describe('UuidStruct', () => { - it.each([ - 'c747acb9-1b2b-4352-b9da-3d658fcc3cc7', - '2507a426-ac26-43c4-a82a-250f5d999398', - '52d181f4-d050-4971-b448-17c15107fa3b', - '52d181f4-d050-4971-b448-17c15107fa3b'.toUpperCase(), - ])('accepts valid UUID: %s', (uuid) => { - expect(() => assert(uuid, UuidStruct)).not.toThrow(); - }); - - it.each([ - 'not-a-uuid', - '12345678-1234-4234-8234-1234', - '12345678-1234-4234-8234-1234567890123', - ])('rejects invalid UUID: %s', (uuid) => { - expect(() => assert(uuid, UuidStruct)).toThrow(StructError); - }); -}); diff --git a/packages/stellar-wallet-snap/src/api/uuid.ts b/packages/stellar-wallet-snap/src/api/uuid.ts deleted file mode 100644 index 7ca0ea96..00000000 --- a/packages/stellar-wallet-snap/src/api/uuid.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { Infer } from '@metamask/superstruct'; -import { definePattern } from '@metamask/utils'; - -/** - * Validation struct for UUID: must be a string matching the UUID v4 format. - */ -export const UuidStruct = definePattern( - 'UuidV4', - /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu, -); - -export type UUID = Infer; diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts index c067fbf6..ac8342e0 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts @@ -1,4 +1,5 @@ import { AssetStruct, FeeType } from '@metamask/keyring-api'; +import { UuidStruct } from '@metamask/snap-networks-utils'; import type { Infer } from '@metamask/superstruct'; import { enums, @@ -26,7 +27,6 @@ import { KnownCaip19AssetIdOrSlip44IdStruct, KnownCaip19ClassicAssetStruct, StellarTransactionHashStruct, - UuidStruct, NonZeroValidStellarAmountStruct, KnownCaip19Sep41AssetStruct, KnownCaip19Slip44IdStruct, diff --git a/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts b/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts index 3d12dd62..39734154 100644 --- a/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/cronjob/api.ts @@ -1,3 +1,4 @@ +import { UuidStruct } from '@metamask/snap-networks-utils'; import type { Infer } from '@metamask/superstruct'; import { array, @@ -22,7 +23,6 @@ import { KnownCaip2ChainIdStruct, StellarAddressStruct, StellarTransactionHashStruct, - UuidStruct, } from '../../api'; import { AppConfig } from '../../config'; import { ConfirmationInterfaceKeyStruct } from '../../ui/confirmation/api'; diff --git a/packages/stellar-wallet-snap/src/handlers/keyring/api.ts b/packages/stellar-wallet-snap/src/handlers/keyring/api.ts index c03192f6..d98ebf3b 100644 --- a/packages/stellar-wallet-snap/src/handlers/keyring/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/keyring/api.ts @@ -1,4 +1,5 @@ import { KeyringRequestStruct } from '@metamask/keyring-api'; +import { UuidStruct } from '@metamask/snap-networks-utils'; import { object, min, @@ -27,7 +28,6 @@ import { import { StellarAddressStruct } from '../../api/address'; import { KnownCaip2ChainId, KnownCaip2ChainIdStruct } from '../../api/network'; import { Utf8StringStruct } from '../../api/string'; -import { UuidStruct } from '../../api/uuid'; import { HashIdPreimageXdrStruct, XdrStruct } from '../../api/xdr'; import { networkToCaip2ChainId } from '../../services/network/utils'; diff --git a/packages/stellar-wallet-snap/src/ui/confirmation/api.ts b/packages/stellar-wallet-snap/src/ui/confirmation/api.ts index a098a98c..3c412b4e 100644 --- a/packages/stellar-wallet-snap/src/ui/confirmation/api.ts +++ b/packages/stellar-wallet-snap/src/ui/confirmation/api.ts @@ -1,3 +1,4 @@ +import { UuidStruct } from '@metamask/snap-networks-utils'; import type { GetPreferencesResult } from '@metamask/snaps-sdk'; import type { Infer } from '@metamask/superstruct'; import { @@ -21,7 +22,6 @@ import { KnownCaip19Sep41AssetStruct, KnownCaip19Slip44IdStruct, KnownCaip2ChainIdStruct, - UuidStruct, XdrStruct, } from '../../api'; import {