refactor: remove type castings and handle errors instead#4600
Conversation
🦋 Changeset detectedLatest commit: 7fac1cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
10 Skipped Deployments
|
packages/experimental/src/smart-session/controllers/SmartSessionsController.ts
Outdated
Show resolved
Hide resolved
|
…ode-and-improve-error-handling
There was a problem hiding this comment.
Bug: Incorrect Data Type for Hex Fields
The data field, which represents arbitrary hex-encoded transaction calldata or bytecode, is incorrectly typed as Address instead of Hex. This is evident in instances where example data like 0xdeadbeef is cast as Address, despite Address being specifically for 20-byte Ethereum addresses.
apps/laboratory/src/components/Wagmi/WagmiSendCallsTest.tsx#L21-L22
appkit/apps/laboratory/src/components/Wagmi/WagmiSendCallsTest.tsx
Lines 21 to 22 in 7fac1cd
packages/controllers/src/utils/TypeUtil.ts#L326-L327
appkit/packages/controllers/src/utils/TypeUtil.ts
Lines 326 to 327 in 7fac1cd
packages/controllers/src/utils/TypeUtil.ts#L346-L347
appkit/packages/controllers/src/utils/TypeUtil.ts
Lines 346 to 347 in 7fac1cd
Bug: Type Mismatch: Private Keys as Addresses
Private keys are incorrectly cast as Address type instead of Hex. Private keys are hex-encoded secrets (32-byte values), distinct from Ethereum addresses (20-byte values). This type mismatch, particularly when passed to functions like privateKeyToAccount and executeActionsWithECDSAKey, can cause type errors or runtime issues.
apps/laboratory/src/components/Wagmi/WagmiPurchaseDonutAsyncPermissionsTest.tsx#L81-L82
apps/laboratory/src/components/Wagmi/WagmiCreatePasskeySignerTest.tsx#L39-L40
apps/laboratory/src/context/LocalEcdsaKeyContext.tsx#L46-L47
appkit/apps/laboratory/src/context/LocalEcdsaKeyContext.tsx
Lines 46 to 47 in 7fac1cd
Bug: Signature Type Mismatch Causes Verification Failures
The signature parameter is incorrectly cast as Address type. It should be Hex as cryptographic signatures are hex-encoded data (typically 65 bytes), not 20-byte Ethereum addresses. This type mismatch can cause verification failures.
packages/siwx/src/verifiers/EIP155Verifier.ts#L30-L31
appkit/packages/siwx/src/verifiers/EIP155Verifier.ts
Lines 30 to 31 in 7fac1cd
Bug: Incorrect Type Usage for Chain IDs
The Address type is incorrectly used where Hex is required for values representing chain IDs. This impacts:
WalletGetAssetsParams:assetFilterkeys andchainFiltervalues.WalletGetAssetsResponse: The top-levelRecordkey.EIP5792Utils.ts: Chain ID variables used with thefromHexfunction.
packages/controllers/src/utils/TypeUtil.ts#L1043-L1050
appkit/packages/controllers/src/utils/TypeUtil.ts
Lines 1043 to 1050 in 7fac1cd
apps/laboratory/src/utils/EIP5792Utils.ts#L40-L41
appkit/apps/laboratory/src/utils/EIP5792Utils.ts
Lines 40 to 41 in 7fac1cd
Bug: Incorrect Data Type for Transaction Calldata
The data field in BlockchainApiGenerateSwapCalldataResponse and BlockchainApiGenerateApproveCalldataResponse is incorrectly typed as Address. This field, which represents transaction calldata, should be typed as Hex as it contains encoded function calls and parameters, not an address.
packages/controllers/src/utils/TypeUtil.ts#L326-L327
appkit/packages/controllers/src/utils/TypeUtil.ts
Lines 326 to 327 in 7fac1cd
packages/controllers/src/utils/TypeUtil.ts#L346-L347
appkit/packages/controllers/src/utils/TypeUtil.ts
Lines 346 to 347 in 7fac1cd
Bug: Incorrect Type Casting for Public Keys
Public keys are incorrectly cast to Address type. As public keys are hex-encoded cryptographic data and not Ethereum addresses, they should be cast to Hex type instead.
apps/laboratory/src/utils/EncodingUtils.ts#L73-L74
appkit/apps/laboratory/src/utils/EncodingUtils.ts
Lines 73 to 74 in 7fac1cd
packages/experimental/tests/smart-session/requestValidation/mockRequest.ts#L11-L12
Bug: Incorrect Hex Typing in Transaction Interfaces
The data field in transaction-related interfaces is incorrectly typed as Address when it should be Hex. This field represents arbitrary hex-encoded bytes (such as bytecode or function call data), not an Ethereum address.
packages/controllers/src/utils/TypeUtil.ts#L346-L347
appkit/packages/controllers/src/utils/TypeUtil.ts
Lines 346 to 347 in 7fac1cd
Was this report helpful? Give feedback by reacting with 👍 or 👎
Description
0x${string}and use@reown/appkit-commonpackage for for types and namespace valuesType of change
Associated Issues
For Linear issues: Closes APKT-xxx
For GH issues: closes #...
Showcase (Optional)
If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.
Checklist