diff --git a/examples/example-react-native-wallet/bottomsheets/AuthenticationScreen.tsx b/examples/example-react-native-wallet/bottomsheets/AuthenticationScreen.tsx index bd3cbdd07..5a1ddc30c 100644 --- a/examples/example-react-native-wallet/bottomsheets/AuthenticationScreen.tsx +++ b/examples/example-react-native-wallet/bottomsheets/AuthenticationScreen.tsx @@ -54,8 +54,13 @@ export default function AuthenticationScreen({ style={styles.actionButton} onPress={() => { resolve(request, { - publicKey: wallet.publicKey.toBytes(), - accountLabel: 'Backpack', + accounts: [{ + publicKey: wallet.publicKey.toBytes(), + accountLabel: 'Backpack', + icon: 'data:text/plain;base64', + chains: ['solana:devnet', 'solana:testnet'], + features: ['solana:signTransactions'] + }], authorizationScope: new TextEncoder().encode(verificationState?.authorizationScope) } as AuthorizeDappCompleteResponse); }} diff --git a/examples/example-react-native-wallet/package.json b/examples/example-react-native-wallet/package.json index 18eee4380..1f4c4e89f 100644 --- a/examples/example-react-native-wallet/package.json +++ b/examples/example-react-native-wallet/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@react-native-async-storage/async-storage": "^1.18.1", - "@solana-mobile/mobile-wallet-adapter-protocol": "^2.0.0", + "@solana-mobile/mobile-wallet-adapter-protocol": "file:../../js/packages/mobile-wallet-adapter-protocol", "@solana-mobile/mobile-wallet-adapter-walletlib": "file:../../js/packages/mobile-wallet-adapter-walletlib", "@solana/wallet-adapter-base": "^0.9.17", "@solana/wallet-adapter-react": "^0.15.7", diff --git a/examples/example-react-native-wallet/screens/MobileWalletAdapterEntrypointBottomSheet.tsx b/examples/example-react-native-wallet/screens/MobileWalletAdapterEntrypointBottomSheet.tsx index 2766bec2d..585bb20ff 100644 --- a/examples/example-react-native-wallet/screens/MobileWalletAdapterEntrypointBottomSheet.tsx +++ b/examples/example-react-native-wallet/screens/MobileWalletAdapterEntrypointBottomSheet.tsx @@ -37,6 +37,7 @@ import { VerificationFailed, VerificationSucceeded, } from '../utils/ClientTrustUseCase'; +import { SolanaSignTransactions } from '@solana-mobile/mobile-wallet-adapter-protocol'; type SignPayloadsRequest = SignTransactionsRequest | SignMessagesRequest; @@ -80,11 +81,11 @@ export default function MobileWalletAdapterEntrypointBottomSheet() { const config: MobileWalletAdapterConfig = useMemo(() => { return { - supportsSignAndSendTransactions: true, maxTransactionsPerSigningRequest: 10, maxMessagesPerSigningRequest: 10, supportedTransactionVersions: [0, 'legacy'], noConnectionWarningTimeoutMs: 3000, + optionalFeatures: [SolanaSignTransactions] }; }, []); diff --git a/examples/example-react-native-wallet/yarn.lock b/examples/example-react-native-wallet/yarn.lock index 8b39a2653..098daf0ff 100644 --- a/examples/example-react-native-wallet/yarn.lock +++ b/examples/example-react-native-wallet/yarn.lock @@ -1520,15 +1520,22 @@ dependencies: eslint-scope "5.1.1" +"@noble/curves@^1.1.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.3.0.tgz#01be46da4fd195822dab821e72f71bf4aeec635e" + integrity sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA== + dependencies: + "@noble/hashes" "1.3.3" + "@noble/ed25519@^1.7.0": version "1.7.3" resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.3.tgz#57e1677bf6885354b466c38e2b620c62f45a7123" integrity sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ== -"@noble/hashes@^1.1.2": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.0.tgz#085fd70f6d7d9d109671090ccae1d3bec62554a1" - integrity sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg== +"@noble/hashes@1.3.3", "@noble/hashes@^1.1.2": + version "1.3.3" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" + integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== "@noble/secp256k1@^1.6.3": version "1.7.1" @@ -1818,18 +1825,21 @@ "@sinonjs/commons" "^2.0.0" "@solana-mobile/mobile-wallet-adapter-protocol-web3js@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@solana-mobile/mobile-wallet-adapter-protocol-web3js/-/mobile-wallet-adapter-protocol-web3js-2.0.0.tgz#5433705c174f59a177280f85396df051711be09d" - integrity sha512-cMADp/UIAN42QJVCM1oyj1wFM/9DTZNIa5z5eHXUXBksw/bNv2fWkiO+4ZUoQj1P4UoMoZJUBx9+qMVl18sPOA== + version "2.1.1" + resolved "https://registry.yarnpkg.com/@solana-mobile/mobile-wallet-adapter-protocol-web3js/-/mobile-wallet-adapter-protocol-web3js-2.1.1.tgz#e7160fcae939a2e1a354d2d2ac1c6e7264eb9e30" + integrity sha512-APP/fbPq4lUwUPWj+3Icja8N3eooaoyJLtB/1dlMTq8QyxftrBnOEygAHQv09Cb1fhD5FIvHnTjPcB9Evm1v7Q== dependencies: - "@solana-mobile/mobile-wallet-adapter-protocol" "^2.0.0" + "@solana-mobile/mobile-wallet-adapter-protocol" "^2.1.1" bs58 "^5.0.0" - js-base64 "^3.7.2" + js-base64 "^3.7.5" -"@solana-mobile/mobile-wallet-adapter-protocol@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@solana-mobile/mobile-wallet-adapter-protocol/-/mobile-wallet-adapter-protocol-2.0.0.tgz#75a3e8163544f659803260cb1dd7aede6da96b36" - integrity sha512-mLK9B/AQgOxzbdRoOMH3G5wB5akWgGSBoVqIZ/6iDWY37uu/CuyX4lTwRyoRlOb8Cxs/tDwiovIGobkti2qF/w== +"@solana-mobile/mobile-wallet-adapter-protocol@^2.1.1", "@solana-mobile/mobile-wallet-adapter-protocol@file:../../js/packages/mobile-wallet-adapter-protocol": + version "2.1.1" + dependencies: + "@solana/wallet-standard" "^1.1.2" + "@solana/wallet-standard-util" "^1.1.1" + "@wallet-standard/core" "^1.0.3" + js-base64 "^3.7.5" "@solana-mobile/mobile-wallet-adapter-walletlib@file:../../js/packages/mobile-wallet-adapter-walletlib": version "1.0.3" @@ -1851,12 +1861,12 @@ dependencies: buffer "~6.0.3" -"@solana/wallet-adapter-base@^0.9.17", "@solana/wallet-adapter-base@^0.9.21", "@solana/wallet-adapter-base@^0.9.22": - version "0.9.22" - resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.22.tgz#97812eaf6aebe01e5fe714326b3c9a0614ae6112" - integrity sha512-xbLEZPGSJFvgTeldG9D55evhl7QK/3e/F7vhvcA97mEt1eieTgeKMnGlmmjs3yivI3/gtZNZeSk1XZLnhKcQvw== +"@solana/wallet-adapter-base@^0.9.17", "@solana/wallet-adapter-base@^0.9.22", "@solana/wallet-adapter-base@^0.9.23": + version "0.9.23" + resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.23.tgz#3b17c28afd44e173f44f658bf9700fd637e12a11" + integrity sha512-apqMuYwFp1jFi55NxDfvXUX2x1T0Zh07MxhZ/nCCTGys5raSfYUh82zen2BLv8BSDj/JxZ2P/s7jrQZGrX8uAw== dependencies: - "@solana/wallet-standard-features" "^1.0.1" + "@solana/wallet-standard-features" "^1.1.0" "@wallet-standard/base" "^1.0.1" "@wallet-standard/features" "^1.0.3" eventemitter3 "^4.0.7" @@ -1870,52 +1880,78 @@ "@solana/wallet-adapter-base" "^0.9.22" "@solana/wallet-standard-wallet-adapter-react" "^1.0.1" -"@solana/wallet-standard-chains@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@solana/wallet-standard-chains/-/wallet-standard-chains-1.0.0.tgz#4c291a2f79f0e105ce0a47b30d98dbd7f8ba69be" - integrity sha512-kr3+JAo7mEBhVCH9cYzjn/vXeUiZeYfB4BF6E8u3U2jq3KlZA/KB+YM976+zGumTfN0NmMXUm066pTTG9kJsNQ== +"@solana/wallet-standard-chains@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-chains/-/wallet-standard-chains-1.1.0.tgz#459b297e71b0d9c1196c11a0578b38c85998be7d" + integrity sha512-IRJHf94UZM8AaRRmY18d34xCJiVPJej1XVwXiTjihHnmwD0cxdQbc/CKjrawyqFyQAKJx7raE5g9mnJsAdspTg== dependencies: - "@wallet-standard/base" "^1.0.0" + "@wallet-standard/base" "^1.0.1" -"@solana/wallet-standard-features@^1.0.0", "@solana/wallet-standard-features@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@solana/wallet-standard-features/-/wallet-standard-features-1.0.1.tgz#36270a646f74a80e51b9e21fb360edb64f840c68" - integrity sha512-SUfx7KtBJ55XIj0qAhhVcC1I6MklAXqWFEz9hDHW+6YcJIyvfix/EilBhaBik1FJ2JT0zukpOfFv8zpuAbFRbw== +"@solana/wallet-standard-core@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-core/-/wallet-standard-core-1.1.1.tgz#7187c085dcee38719902217a7ecdd1bf3f27afa3" + integrity sha512-DoQ5Ryly4GAZtxRUmW2rIWrgNvTYVCWrFCFFjZI5s4zu2QNsP7sHZUax3kc1GbmFLXNL1FWRZlPOXRs6e0ZEng== + dependencies: + "@solana/wallet-standard-chains" "^1.1.0" + "@solana/wallet-standard-features" "^1.2.0" + "@solana/wallet-standard-util" "^1.1.1" + +"@solana/wallet-standard-features@^1.1.0", "@solana/wallet-standard-features@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-features/-/wallet-standard-features-1.2.0.tgz#be8b3824abf5ebcfeaa7298445bf53f76a27c935" + integrity sha512-tUd9srDLkRpe1BYg7we+c4UhRQkq+XQWswsr/L1xfGmoRDF47BPSXf4zE7ZU2GRBGvxtGt7lwJVAufQyQYhxTQ== dependencies: "@wallet-standard/base" "^1.0.1" "@wallet-standard/features" "^1.0.3" -"@solana/wallet-standard-util@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@solana/wallet-standard-util/-/wallet-standard-util-1.0.0.tgz#597b3a240f1855d25d93c2cd7efe8631a1a241ac" - integrity sha512-qRAOBXnN7dwvtgzTtxIHsSeJAMbGNZdSWs57TT8pCyBrKL5dVxaK2u95Dm17SRSzwfKl/EByV1lTjOxXyKWS+g== +"@solana/wallet-standard-util@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-util/-/wallet-standard-util-1.1.1.tgz#f645fdd8b7d3c553a3b59aa19c25c51a1badce66" + integrity sha512-dPObl4ntmfOc0VAGGyyFvrqhL8UkHXmVsgbj0K9RcznKV4KB3MgjGwzo8CTSX5El5lkb0rDeEzFqvToJXRz3dw== dependencies: - "@solana/wallet-standard-chains" "^1.0.0" - "@solana/wallet-standard-features" "^1.0.0" + "@noble/curves" "^1.1.0" + "@solana/wallet-standard-chains" "^1.1.0" + "@solana/wallet-standard-features" "^1.2.0" -"@solana/wallet-standard-wallet-adapter-base@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@solana/wallet-standard-wallet-adapter-base/-/wallet-standard-wallet-adapter-base-1.0.2.tgz#d6028c27381fe384a34a7426b3eb828a1da6bff0" - integrity sha512-QqkupdWvWuihX87W6ijt174u6ZdP5OSFlNhZhuhoMlIdyI/sj7MhGsdppuRlMh65oVO2WNWTL9y2bO5Pbx+dfg== +"@solana/wallet-standard-wallet-adapter-base@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-wallet-adapter-base/-/wallet-standard-wallet-adapter-base-1.1.2.tgz#f030f412cd16b06e95c6da5548a03113319d3620" + integrity sha512-DqhzYbgh3disHMgcz6Du7fmpG29BYVapNEEiL+JoVMa+bU9d4P1wfwXUNyJyRpGGNXtwhyZjIk2umWbe5ZBNaQ== dependencies: - "@solana/wallet-adapter-base" "^0.9.21" - "@solana/wallet-standard-chains" "^1.0.0" - "@solana/wallet-standard-features" "^1.0.1" - "@solana/wallet-standard-util" "^1.0.0" + "@solana/wallet-adapter-base" "^0.9.23" + "@solana/wallet-standard-chains" "^1.1.0" + "@solana/wallet-standard-features" "^1.2.0" + "@solana/wallet-standard-util" "^1.1.1" "@wallet-standard/app" "^1.0.1" "@wallet-standard/base" "^1.0.1" "@wallet-standard/features" "^1.0.3" "@wallet-standard/wallet" "^1.0.1" -"@solana/wallet-standard-wallet-adapter-react@^1.0.1": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@solana/wallet-standard-wallet-adapter-react/-/wallet-standard-wallet-adapter-react-1.0.2.tgz#8359900de37b05f921eb2318162a4dc179ce9864" - integrity sha512-0YTPUnjiSG5ajDP2hK8EipxkeHhO3+nCtXeF1eS/ZP2QcFAgS/4luywrn/6CdfzQ2cQYPCFdnG/QculpUp6bBg== +"@solana/wallet-standard-wallet-adapter-react@^1.0.1", "@solana/wallet-standard-wallet-adapter-react@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-wallet-adapter-react/-/wallet-standard-wallet-adapter-react-1.1.2.tgz#a7bc71786e8f891d2dd83f7de30db4708767a56a" + integrity sha512-bN6W4QkzenyjUoUz3sC5PAed+z29icGtPh9VSmLl1ZrRO7NbFB49a8uwUUVXNxhL/ZbMsyVKhb9bNj47/p8uhQ== dependencies: - "@solana/wallet-standard-wallet-adapter-base" "^1.0.2" + "@solana/wallet-standard-wallet-adapter-base" "^1.1.2" "@wallet-standard/app" "^1.0.1" "@wallet-standard/base" "^1.0.1" +"@solana/wallet-standard-wallet-adapter@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard-wallet-adapter/-/wallet-standard-wallet-adapter-1.1.2.tgz#a9ff9e4d5c379e4f38c03a2b69c9a221904181b6" + integrity sha512-lCwoA+vhPfmvjcmJOhSRV94wouVWTfJv1Z7eeULAe+GodCeKA/0T9/uBYgXHUxQjLHd7o8LpLYIkfm+xjA5sMA== + dependencies: + "@solana/wallet-standard-wallet-adapter-base" "^1.1.2" + "@solana/wallet-standard-wallet-adapter-react" "^1.1.2" + +"@solana/wallet-standard@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@solana/wallet-standard/-/wallet-standard-1.1.2.tgz#b68e38db863f6945979fe278f2cecc2e21f84c2d" + integrity sha512-o7wk+zr5/QgyE393cGRC04K1hacR4EkBu3MB925ddaLvCVaXjwr2asgdviGzN9PEm3FiEJp3sMmMKYHFnwOITQ== + dependencies: + "@solana/wallet-standard-core" "^1.1.1" + "@solana/wallet-standard-wallet-adapter" "^1.1.2" + "@solana/web3.js@^1.58.0": version "1.74.0" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.74.0.tgz#dbcbeabb830dd7cbbcf5e31404ca79c9785cbf2d" @@ -2197,11 +2233,21 @@ dependencies: "@wallet-standard/base" "^1.0.1" -"@wallet-standard/base@^1.0.0", "@wallet-standard/base@^1.0.1": +"@wallet-standard/base@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@wallet-standard/base/-/base-1.0.1.tgz#860dd94d47c9e3c5c43b79d91c6afdbd7a36264e" integrity sha512-1To3ekMfzhYxe0Yhkpri+Fedq0SYcfrOfJi3vbLjMwF2qiKPjTGLwZkf2C9ftdQmxES+hmxhBzTwF4KgcOwf8w== +"@wallet-standard/core@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@wallet-standard/core/-/core-1.0.3.tgz#3b6743e207ca4e1e725ae20f1838b400fb0694ff" + integrity sha512-Jb33IIjC1wM1HoKkYD7xQ6d6PZ8EmMZvyc8R7dFgX66n/xkvksVTW04g9yLvQXrLFbcIjHrCxW6TXMhvpsAAzg== + dependencies: + "@wallet-standard/app" "^1.0.1" + "@wallet-standard/base" "^1.0.1" + "@wallet-standard/features" "^1.0.3" + "@wallet-standard/wallet" "^1.0.1" + "@wallet-standard/features@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@wallet-standard/features/-/features-1.0.3.tgz#c992876c5e4f7a0672f8869c4146c87e0dfe48c8" @@ -5033,10 +5079,10 @@ joi@^17.2.1: "@sideway/formula" "^3.0.1" "@sideway/pinpoint" "^2.0.0" -js-base64@^3.7.2: - version "3.7.5" - resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.5.tgz#21e24cf6b886f76d6f5f165bfcd69cc55b9e3fca" - integrity sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA== +js-base64@^3.7.2, js-base64@^3.7.5: + version "3.7.6" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.6.tgz#6ccb5d761b48381fd819f9ce04998866dbcbbc99" + integrity sha512-NPrWuHFxFUknr1KqJRDgUQPexQF0uIJWjeT+2KjEePhitQxQEx5EJBG1lVn5/hc8aLycTpXrDOgPQ6Zq+EDiTA== js-sdsl@^4.1.4: version "4.4.0" diff --git a/js/packages/mobile-wallet-adapter-walletlib/android/build.gradle b/js/packages/mobile-wallet-adapter-walletlib/android/build.gradle index c689501fd..91d560ba7 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/android/build.gradle +++ b/js/packages/mobile-wallet-adapter-walletlib/android/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.2.2' // noinspection DifferentKotlinGradleVersion classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" @@ -135,11 +135,11 @@ def kotlin_version = getExtOrDefault('kotlinVersion') dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules - implementation 'com.solanamobile:digital-asset-links-android:1.0.2' - implementation "com.solanamobile:mobile-wallet-adapter-walletlib:1.1.0" + implementation 'com.solanamobile:digital-asset-links-android:1.0.3' + implementation "com.solanamobile:mobile-wallet-adapter-walletlib:2.0.1" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2" } if (isNewArchitectureEnabled()) { diff --git a/js/packages/mobile-wallet-adapter-walletlib/android/gradle/wrapper/gradle-wrapper.properties b/js/packages/mobile-wallet-adapter-walletlib/android/gradle/wrapper/gradle-wrapper.properties index 8049c684f..15de90249 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/android/gradle/wrapper/gradle-wrapper.properties +++ b/js/packages/mobile-wallet-adapter-walletlib/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/JsonSerializationUtils.kt b/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/JsonSerializationUtils.kt index 6687964b0..2f953060c 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/JsonSerializationUtils.kt +++ b/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/JsonSerializationUtils.kt @@ -76,7 +76,7 @@ internal object FailReasonTransformingSerializer internal object MobileWalletAdapterResponseSerializer : JsonContentPolymorphicSerializer(MobileWalletAdapterResponse::class) { override fun selectDeserializer(element: JsonElement): DeserializationStrategy = if ((element as? JsonObject)?.containsKey("failReason") == true) FailReasonTransformingSerializer - else if ((element as? JsonObject)?.containsKey("publicKey") == true) AuthorizeDappResponse.serializer() + else if ((element as? JsonObject)?.containsKey("accounts") == true) AuthorizeDappResponse.serializer() else if ((element as? JsonObject)?.containsKey("authorizationScope") == true) ReauthorizeDappResponse.serializer() else if ((element as? JsonObject)?.containsKey("signedPayloads") == true) SignedPayloads.serializer() else if ((element as? JsonObject)?.containsKey("signedTransactions") == true) SignedAndSentTransactions.serializer() diff --git a/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/SolanaMobileWalletAdapterWalletLibModule.kt b/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/SolanaMobileWalletAdapterWalletLibModule.kt index 90fdd858d..1b822414e 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/SolanaMobileWalletAdapterWalletLibModule.kt +++ b/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/SolanaMobileWalletAdapterWalletLibModule.kt @@ -187,10 +187,13 @@ class SolanaMobileWalletAdapterWalletLibModule(val reactContext: ReactApplicatio is AuthorizeDappResponse -> (pendingRequest as? MobileWalletAdapterRemoteRequest.AuthorizeDapp) ?.request?.completeWithAuthorize( - response.publicKey, - response.accountLabel, - null, //Uri.parse(response.walletUriBase), - response.authorizationScope + response.accounts.first().let { account -> + AuthorizedAccount(account.publicKey, account.accountLabel, account.icon?.let{ Uri.parse(it) }, + account.chains?.toTypedArray(), account.features?.toTypedArray()) + }, + response.walletUriBase?.let { Uri.parse(response.walletUriBase) }, + response.authorizationScope, + null // TODO: SignInResult ) else -> completeWithInvalidResponse() } diff --git a/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterConfig.kt b/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterConfig.kt index 82ea2d804..883a3056b 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterConfig.kt +++ b/js/packages/mobile-wallet-adapter-walletlib/android/src/main/java/com/solanamobile/mobilewalletadapterwalletlib/reactnative/model/MobileWalletAdapterConfig.kt @@ -16,12 +16,12 @@ import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonPrimitive @Serializable -data class MobileWalletAdapterConfigSurrogate( - val supportsSignAndSendTransactions: Boolean, +private data class MobileWalletAdapterConfigSurrogate( val maxTransactionsPerSigningRequest: Int, val maxMessagesPerSigningRequest: Int, val supportedTransactionVersions: List<@Serializable(with = TransactionVersionSerializer::class) Any>, val noConnectionWarningTimeoutMs: Long, + val optionalFeatures: List ) object TransactionVersionSerializer : JsonContentPolymorphicSerializer(Any::class) { @@ -38,22 +38,22 @@ object MobileWalletAdapterConfigSerializer : KSerializer? = null, + val features: List? = null +) + +@Serializable +data class AuthorizeDappResponse( + val accounts: List, val walletUriBase: String? = null, @Serializable(with = ByteArrayAsMapSerializer::class) val authorizationScope: ByteArray ) : MobileWalletAdapterResponse() diff --git a/js/packages/mobile-wallet-adapter-walletlib/package.json b/js/packages/mobile-wallet-adapter-walletlib/package.json index d7e931e3a..470887344 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/package.json +++ b/js/packages/mobile-wallet-adapter-walletlib/package.json @@ -34,6 +34,7 @@ "@release-it/conventional-changelog": "^7.0.0", "@solana/web3.js": "^1.58.0", "@types/react-native": "^0.69.3", + "@wallet-standard/core": "^1.0.3", "react-native-builder-bob": "^0.20.4", "release-it": "^16.3.0" }, diff --git a/js/packages/mobile-wallet-adapter-walletlib/src/resolve.ts b/js/packages/mobile-wallet-adapter-walletlib/src/resolve.ts index 567b95525..c9dd26c2f 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/src/resolve.ts +++ b/js/packages/mobile-wallet-adapter-walletlib/src/resolve.ts @@ -1,3 +1,4 @@ +import type { IdentifierArray } from '@wallet-standard/core'; import { NativeModules, Platform } from 'react-native'; const LINKING_ERROR = @@ -30,6 +31,9 @@ type AppIdentity = Readonly<{ identityName?: string; }>; +export type Base64EncodedAddress = string; +type Base64EncodedSignedMessage = string; + /** * Mobile Wallet Adapter Requests are remote requests coming from * the dApp for authorization, signing, and sending services. @@ -101,6 +105,10 @@ export type SignAndSendTransactionsRequest = Readonly<{ __type: MWARequestType.SignAndSendTransactionsRequest; payloads: Uint8Array[]; minContextSlot?: number; + commitment?: string; + skipPreflight?: boolean; + maxRetries?: number; + waitForCommitmentToSendNextTransaction?: boolean; }> & IMWARequest & IVerifiableIdentityRequest; @@ -143,11 +151,24 @@ export type InvalidSignaturesResponse = Readonly<{ }>; /* Authorize Dapp */ -export type AuthorizeDappCompleteResponse = Readonly<{ - publicKey: Uint8Array; +export type AuthorizedAccount = Readonly<{ + publicKey: Base64EncodedAddress; accountLabel?: string; + icon?: string; + chains?: IdentifierArray; + features?: IdentifierArray; +}>; +export type SignInResult = Readonly<{ + address: Base64EncodedAddress; + signed_message: Base64EncodedSignedMessage; + signature: Base64EncodedAddress; + signature_type?: string; +}>; +export type AuthorizeDappCompleteResponse = Readonly<{ + accounts: Array walletUriBase?: string; authorizationScope?: Uint8Array; + signInResult?: SignInResult; }>; export type AuthorizeDappResponse = AuthorizeDappCompleteResponse | UserDeclinedResponse; diff --git a/js/packages/mobile-wallet-adapter-walletlib/src/useMobileWalletAdapterSession.ts b/js/packages/mobile-wallet-adapter-walletlib/src/useMobileWalletAdapterSession.ts index ee84f5818..673319069 100644 --- a/js/packages/mobile-wallet-adapter-walletlib/src/useMobileWalletAdapterSession.ts +++ b/js/packages/mobile-wallet-adapter-walletlib/src/useMobileWalletAdapterSession.ts @@ -1,4 +1,5 @@ import type { TransactionVersion } from '@solana/web3.js'; +import type { IdentifierArray } from '@wallet-standard/core'; import { useEffect } from 'react'; import { Linking, NativeEventEmitter, NativeModules, Platform } from 'react-native'; @@ -32,11 +33,11 @@ const SolanaMobileWalletAdapterWalletLib = const MOBILE_WALLET_ADAPTER_EVENT_BRIDGE_NAME = 'MobileWalletAdapterServiceRequestBridge'; export interface MobileWalletAdapterConfig { - supportsSignAndSendTransactions: boolean; maxTransactionsPerSigningRequest: number; maxMessagesPerSigningRequest: number; supportedTransactionVersions: Array; noConnectionWarningTimeoutMs: number; + optionalFeatures: IdentifierArray; } export function useMobileWalletAdapterSession(