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: handle viem chains in wagmi adapter constructor #2955

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

enesozturk
Copy link
Contributor

@enesozturk enesozturk commented Sep 27, 2024

Description

The current Wagmi adapter doesn't handle the Viem chains well. Most of the users use viem's exported chains. The Wagmi adapter should be flexible to use all these chains as well.

This PR introduces changes to WagmiAdapter and lab examples to provide proper workaround handling both Viem chains and our exported network objects.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-1193, APKT-1194, APKT-1195
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

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

changeset-bot bot commented Sep 27, 2024

🦋 Changeset detected

Latest commit: d73524a

The changes in this PR will be included in the next version bump.

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

Copy link

vercel bot commented Sep 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
appkit-laboratory ✅ Ready (Inspect) Visit Preview Oct 6, 2024 10:23pm
web3modal-gallery ✅ Ready (Inspect) Visit Preview Oct 6, 2024 10:23pm

Copy link
Contributor

github-actions bot commented Sep 27, 2024

Coverage Report for Coverage

Status Category Percentage Covered / Total
🔵 Lines 231.5% 4078 / 18830
🔵 Statements 231.5% 4078 / 18830
🔵 Functions 253.64000000000001% 324 / 1000
🔵 Branches 307.7% 578 / 1246
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/appkit/src/client.ts 81.97% 74.22% 86.25% 81.97% 90-91, 110-111, 114-115, 118-119, 122-125, 128-131, 134-135, 256, 264, 302-305, 311-314, 316-317, 320, 415, 417-419, 422-423, 425-427, 442, 444-445, 458-459, 474-475, 478-479, 482-483, 492-494, 503, 524-527, 562, 571-583
packages/appkit/src/library/react/index.ts 0% 0% 0% 0% 1-2, 12, 35, 37-41, 44, 46-47, 49-50, 52-56, 58-61, 63-67, 69-73, 75-76, 78-82, 84-87, 89-95, 97-100, 102-104, 106-108, 110-111, 113-116, 118-122, 124-125, 127-130, 132, 134-137, 139-142, 144-145, 147-150, 152, 154-157, 159-162, 164-165
packages/appkit/src/library/vue/index.ts 0% 0% 0% 0% 1-2, 12, 38, 40-44, 47, 49-51, 53-54, 56-60, 62-65, 67-71, 73-77, 79-80, 82-85, 87-89, 91-97, 99-102, 104-106, 108-110, 112-116, 118-121, 123, 125-127, 129-131, 133-134, 136-139, 141-143, 145-148, 150-152, 154-155, 157-160, 162-166, 168-170, 172-173
packages/appkit/src/networks/index.ts 100% 100% 100% 100%
packages/appkit/src/networks/utils.ts 100% 100% 100% 100%
packages/appkit/src/networks/solana/index.ts 100% 100% 100% 100%
packages/appkit/src/networks/solana/solana.ts 100% 100% 100% 100%
packages/appkit/src/networks/solana/solanaDevnet.ts 100% 100% 100% 100%
packages/appkit/src/networks/solana/solanaTestnet.ts 100% 100% 100% 100%
packages/appkit/src/tests/mocks/UniversalProvider.ts 100% 100% 100% 100%
packages/appkit/src/universal-adapter/client.ts 55.33% 46.55% 53.12% 55.33% 102-106, 124-125, 128, 133-134, 136-138, 147-151, 153-155, 157-159, 161-163, 165-170, 172, 174-183, 185, 187-190, 192-197, 199, 201, 203-206, 219-221, 230-232, 234-236, 238-241, 243-244, 286-291, 295-300, 310, 312-315, 321-326, 328-329, 332-333, 335-344, 346, 348-349, 366-367, 369-374, 402-403, 405, 410-411, 433-434, 446-449, 451, 453-455, 458-461, 465-466, 468-485, 487-488, 490-493, 531-535, 540-543, 560-561, 573-575, 577-598
packages/appkit/src/utils/HelpersUtil.ts 100% 90.9% 100% 100%
packages/appkit/src/utils/TypesUtil.ts 100% 100% 100% 100%
packages/appkit-utils/exports/index.ts 0% 0% 0% 0% 1
packages/appkit-utils/src/CaipNetworkUtil.ts 0% 0% 0% 0% 1, 6-7, 9, 11-14, 16-17, 19-55, 62, 69-76, 78-82, 84-85, 87-88, 90-92, 94-97, 99-100, 102-105, 107-108, 110-111, 113-115, 117-118, 129-135, 137-152, 163-174
packages/appkit-utils/src/ethers/EthersHelpersUtil.ts 69.56% 100% 85.71% 69.56% 39-52
packages/appkit-utils/src/solana/SolanaConstantsUtil.ts 100% 100% 100% 100%
packages/appkit-utils/src/solana/SolanaHelpersUtils.ts 96.29% 85.71% 100% 96.29% 20-21
packages/common/index.ts 0% 0% 0% 0% 1
packages/common/src/utils/TypeUtil.ts 100% 100% 100% 100%
packages/core/exports/react.ts 100% 100% 100% 100%
packages/core/exports/vue.ts 0% 0% 0% 0% 1-3, 5-6, 9, 13-16, 18-20, 22-24, 26-31, 33-37, 39-41, 43-45, 47-50, 52-58
packages/core/src/controllers/AccountController.ts 47.51% 83.33% 38.46% 47.51% 60-61, 67-70, 72-74, 77-81, 83-96, 99-100, 103-104, 107-110, 152-153, 164-165, 168-169, 172-175, 178-181, 184-188, 198-204, 207-213, 216-222, 225-228, 230-232, 234-236, 238-244, 251-252
packages/core/src/controllers/ApiController.ts 91.84% 69.38% 80% 91.84% 56-57, 71-72, 129-130, 142, 180, 261-265, 281-286
packages/core/src/controllers/ChainController.ts 69.13% 59.67% 71.87% 69.13% 77-80, 83-87, 90-94, 96-97, 99-107, 113-114, 141, 143-153, 157-165, 188-189, 231-241, 246-247, 267-268, 272, 274-276, 278, 280-287, 290-293, 304-306, 308-309, 312-313, 318-319, 322-323, 338-340, 342-343, 346-347, 352-353, 356-357, 373-374, 379-380, 392-393, 426, 428-431, 433-434, 437-438, 441-442, 481-482, 501-504, 527-528
packages/core/src/controllers/ConnectionController.ts 48.12% 83.33% 26.08% 48.12% 73-77, 84-85, 91-94, 96-97, 99-100, 102-104, 106-121, 141-143, 146-162, 165-166, 169-170, 173-174, 177-178, 181-182, 185-186, 189-190, 193-194, 211-212, 215-217, 220-221, 224-225, 228-229, 238-239
packages/core/src/controllers/EnsController.ts 81.3% 57.89% 60% 81.3% 38-39, 42-43, 77-78, 95-97, 103-104, 109-110, 126-127, 134-135, 148-150, 159, 161-162
packages/core/src/controllers/SendController.ts 24.44% 100% 37.5% 24.44% 52-53, 56-57, 84-85, 88-89, 92-93, 96-98, 100-102, 104-108, 111-155, 158-161, 163-169, 171-208, 211-214, 216-219, 221-230, 232-246, 249-250, 252-253, 255-258, 260-270, 272-274
packages/core/src/controllers/SwapController.ts 47.61% 62.5% 56.66% 47.61% 40-43, 166-167, 170-171, 180-181, 211-213, 215-216, 242, 250-252, 261-265, 269-271, 273-276, 278-279, 281-284, 287-300, 311-312, 315-316, 320-321, 329-332, 365, 372, 377, 379-381, 383-391, 393, 395-396, 405, 407, 420-421, 432-433, 445, 452-453, 457-460, 462-465, 493-494, 516-517, 531, 540-542, 544-546, 548-555, 557, 559-563, 565-566, 568-575, 577-579, 582, 584-586, 588-590, 592-603, 605-612, 614-615, 617-623, 625-627, 630-632, 634-636, 638-641, 643-650, 652, 654-655, 657-664, 666, 668-669, 671-677, 679-681, 685, 687-688, 690-700, 702-709, 711-721, 724-726, 728, 730, 732-737, 739-750, 752-761, 763-783, 785-804, 806-808, 823-824, 839-840
packages/core/src/controllers/TransactionsController.ts 81.6% 87.5% 75% 81.6% 42-43, 46-47, 53-54, 91-107
packages/core/src/utils/AssetUtil.ts 76.27% 68.75% 71.42% 76.27% 18-19, 28-29, 43, 55, 59-61, 63-64, 75, 79-80
packages/core/src/utils/CoreHelperUtil.ts 42.16% 71.42% 35.29% 42.16% 11-16, 18-19, 22-23, 26, 28-29, 32, 34-35, 38-39, 42-43, 46-47, 50-51, 58-59, 73, 75-78, 80-85, 88-89, 92-102, 104, 106-108, 110-114, 117-124, 126-130, 133-135, 137-138, 140-141, 144-149, 155, 157, 159, 164-170, 172-173, 192, 194-201, 203-208, 223-225, 227-229, 231-233, 240-243, 245, 264, 266, 268-269, 279-282, 284-285, 288-289, 291-292, 301, 306, 311, 321-322, 330-337, 339-340
packages/core/src/utils/StorageUtil.ts 73.52% 74.07% 90.9% 73.52% 49-50, 59-60, 62, 69-70, 77-78, 80, 87-88, 95-96, 98, 105-106, 108, 112-118, 120-121
packages/core/src/utils/SwapApiUtil.ts 97.22% 79.16% 100% 97.22% 53-54, 107
packages/scaffold-ui/src/modal/w3m-account-button/index.ts 0% 0% 0% 0% 1, 8, 11-14, 16-17, 19, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 47-70, 72-74, 77-80, 82, 84, 86-95, 97-98, 102, 105-112
packages/scaffold-ui/src/modal/w3m-modal/index.ts 0% 0% 0% 0% 1, 12-16, 22, 25, 27-29, 32, 34, 37, 39, 41, 43, 45, 47-62, 64-67, 70-73, 75, 89-90, 93-97, 99-101, 103-114, 116-120, 122-128, 130-135, 137-140, 150-151, 153-158, 160-178, 180-183, 185-189, 191-196, 198-200, 202-210, 212-214, 216-217, 219-222, 224-225, 227-228, 230-232, 234-245, 247-249, 251-263
packages/scaffold-ui/src/modal/w3m-network-button/index.ts 0% 0% 0% 0% 1, 7, 9-13, 15-17, 20, 23, 25, 27, 29, 31, 33, 35, 38-60, 62-64, 67-70, 72, 75-78, 80, 84, 87-91, 93-94, 96-98, 100-102, 104-105, 107-113
packages/scaffold-ui/src/partials/w3m-account-wallet-features-widget/index.ts 0% 0% 0% 0% 1, 11-18, 20-22, 24-26, 29, 31, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52-74, 76-79, 81-83, 86-89, 91, 93, 95, 99-100, 102-104, 106-107, 110, 115, 119, 123, 131, 138-143, 145, 147, 150-151, 153-155, 157, 161, 167, 169-171, 173-182, 184-185, 187-190, 192-193, 195-196, 198-199, 201-207, 209-211, 214, 216-218, 220-222, 224-226, 228-249, 251-253, 255-267, 269-272
packages/scaffold-ui/src/partials/w3m-activity-list/index.ts 0% 0% 0% 0% 1, 11-14, 16, 18, 21-22, 24-26, 29, 31, 34, 36, 38, 40, 42, 44, 47-72, 74-77, 79-81, 83-85, 88-92, 95-97, 99-106, 108-109, 111-112, 114-118, 120-126, 128-129, 131-133, 135, 139, 144, 146, 149, 153-155, 157-161, 163-164, 166-172, 175, 177-180, 182-190, 192-193, 195, 197-203, 206, 208-210, 212-214, 216-217, 223, 232, 245, 247-248, 274, 276, 278-281, 283-284, 286-291, 293-294, 296-298, 300-301, 303-321, 323-324, 326-330, 332-334, 336-340, 342-353
packages/scaffold-ui/src/partials/w3m-onramp-provider-item/index.ts 0% 0% 0% 0% 1-6, 8-10, 13, 15, 17, 19, 21, 23, 25, 28-31, 33, 37, 43, 46-48, 51, 54-58, 60, 62-63, 65, 68, 71-72
packages/scaffold-ui/src/views/w3m-account-settings-view/index.ts 0% 0% 0% 0% 1, 15-20, 22-23, 25, 27, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48-73, 75-77, 80-83, 85, 87, 92, 95-97, 103-108, 114, 120-121, 124, 127-129, 133, 136, 141-143, 151, 154-160, 162, 168-169, 175, 177-183, 185, 187, 194, 196-199, 201-202, 204-213, 215-218, 220-222, 224-229, 231, 237-239, 242, 245, 247-249, 251-258, 260-262, 264-265, 267-271, 273-276, 278-282, 284-296, 298-302
packages/scaffold-ui/src/views/w3m-networks-view/index.ts 0% 0% 0% 0% 1, 11-16, 18-20, 22, 25, 27, 29, 31, 34-39, 41-43, 46-48, 51, 55, 64, 70, 73-75, 77, 85, 87-89, 91-93, 95-98, 100-106, 108-114, 116-117, 119-120, 122-125, 128-129, 131-139, 141-143, 145-146, 148-150, 152-154, 156-162, 164-180
packages/scaffold-ui/src/views/w3m-swap-view/index.ts 0% 0% 0% 0% 1-4, 15-17, 19-21, 23, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 59-97, 99-102, 104-107, 110-113, 116, 119-125, 127-128, 131-132, 134, 137, 139-142, 144-146, 148-150, 152-154, 156-157, 159-160, 162, 167, 169-170, 175, 177, 180, 182-188, 190-192, 194-203, 205, 207-210, 212-214, 216-217, 219-221, 223-224, 226-231, 233-234, 236-239, 241-242, 244-252, 254-258, 260, 267-270, 272, 275, 277-279, 281-283, 285-287, 289-307
packages/scaffold-ui/src/views/w3m-switch-address-view/index.ts 0% 0% 0% 0% 1, 9-14, 17-19, 21, 23, 25, 27, 29, 31, 34, 36, 38-43, 45-59, 61-64, 66-67, 70-72, 74-75, 79-80, 83, 87-88, 90, 97-99, 104-105, 107, 110-117, 120-122, 127-129, 131, 135, 138, 142, 144-151
packages/scaffold-ui/src/views/w3m-unsupported-chain-view/index.ts 0% 0% 0% 0% 1, 12, 14-18, 20-22, 25, 28, 31-32, 37, 41, 45, 54-56, 64, 67-69, 75, 77, 82, 84-86, 88-91, 93-97, 99-100, 102-104, 108-109, 111-126, 128-136, 138-149
packages/scaffold-ui/src/views/w3m-wallet-receive-view/index.ts 0% 0% 0% 0% 1, 9-14, 16-18, 21, 24, 26, 28, 30, 32-52, 54-56, 59-62, 64, 66, 68, 73-79, 82, 87, 92-95, 102, 104, 107-110, 112-118, 120-121, 123, 125-129, 131-132, 134, 136, 138-140, 142-152
packages/scaffold-ui/src/views/w3m-wallet-send-select-token-view/index.ts 0% 0% 0% 0% 1-3, 10, 12, 15-17, 20, 23, 25, 27, 29, 32-41, 43-45, 48-49, 51, 54, 58-59, 62, 70, 72-82, 84, 88, 90, 94-104, 106-108, 134-135, 139, 141-146, 148-150, 152-157
packages/ui/src/composites/wui-list-account/index.ts 0% 0% 0% 0%
Generated in workflow #6608 for commit d73524a by the Vitest Coverage Report Action

@@ -0,0 +1,17 @@
import type { CaipNetwork } from '@reown/appkit-common'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@@ -99,8 +99,7 @@ export function SolanaTests() {
<SolanaSignJupiterSwapTest />
</Box>

{(caipNetwork?.chainId === solanaTestnet.chainId ||
caipNetwork?.chainId === solanaDevnet.chainId) && (
{(caipNetwork?.id === solanaTestnet.id || caipNetwork?.id === solanaDevnet.id) && (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this ok?

apps/laboratory/src/pages/library/wagmi.tsx Outdated Show resolved Hide resolved
packages/adapters/ethers/src/client.ts Show resolved Hide resolved
packages/adapters/ethers/src/client.ts Show resolved Hide resolved
packages/adapters/ethers5/src/client.ts Show resolved Hide resolved
packages/appkit-utils/src/CaipNetworkUtil.ts Show resolved Hide resolved
packages/appkit/package.json Outdated Show resolved Hide resolved
@@ -0,0 +1,17 @@
import type { CaipNetwork } from '@reown/appkit-common'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

packages/appkit/src/networks/index.ts Outdated Show resolved Hide resolved
packages/wagmi/package.json Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants