diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 4002489..da14979 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -378,6 +378,17 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.29.3.tgz#d7e1f381267e61b7d3219ebd75d46defc397cd43" integrity sha512-UuKoBN2xiRXcBpz7jzCwagKhOnLOsRmR8mu3IzY+Yx38i8rW52FSXMbxC/yE83X0vLea+zgMQFPwv0gy4QWUJw== +"@cosmostation/wc-modal@^0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@cosmostation/wc-modal/-/wc-modal-0.0.5.tgz#1d76e050dcd9eadc133ebc42aa547ee9b8e0c510" + integrity sha512-r/DjNIrmDkncGihLg6/wF9SeqKbPG4er4XPt8hTuHj1FR+MaVfYSpICd4ghagGMKHW9oB4u7kpHzbz3ns4JPxw== + dependencies: + "@walletconnect/browser-utils" "^1.6.5" + "@walletconnect/types" "^1.6.5" + qrcode.react "^1.0.1" + react "^16.14.0" + react-dom "^16.14.0" + "@discoveryjs/json-ext@^0.5.0": version "0.5.7" resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index dcac476..f3fdffd 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -114,6 +114,7 @@ kotlin { implementation(npm("@walletconnect/client", "^1.8.0")) implementation(npm("@keplr-wallet/wc-client", "^0.11.17")) implementation(npm("@keplr-wallet/wc-qrcode-modal", "^0.11.17")) + implementation(npm("@cosmostation/wc-modal", "^0.0.5")) implementation(npm("@babel/core", "^7.18.13")) implementation(npm("events", "^3.3.0")) diff --git a/sample/src/jsMain/kotlin/jslib/walletconnect/index.module_@cosmostation_wc-modal.kt b/sample/src/jsMain/kotlin/jslib/walletconnect/index.module_@cosmostation_wc-modal.kt new file mode 100644 index 0000000..1bcfff4 --- /dev/null +++ b/sample/src/jsMain/kotlin/jslib/walletconnect/index.module_@cosmostation_wc-modal.kt @@ -0,0 +1,23 @@ +@file:JsModule("@cosmostation/wc-modal") +@file:JsNonModule + +package jslib.walletconnect + +import org.khronos.webgl.* +import org.w3c.dom.* +import org.w3c.dom.events.* +import org.w3c.dom.parsing.* +import org.w3c.dom.svg.* +import org.w3c.dom.url.* +import org.w3c.fetch.* +import org.w3c.files.* +import org.w3c.notifications.* +import org.w3c.performance.* +import org.w3c.workers.* +import org.w3c.xhr.* +import kotlin.js.* + +external class CosmostationWCModal() : IQRCodeModal { + override fun open(uri: String, cb: Any, opts: Any) = definedExternally + override fun close() +} \ No newline at end of file diff --git a/sample/src/jsMain/kotlin/main.js.kt b/sample/src/jsMain/kotlin/main.js.kt index 2672cb4..f5a1d49 100644 --- a/sample/src/jsMain/kotlin/main.js.kt +++ b/sample/src/jsMain/kotlin/main.js.kt @@ -6,6 +6,7 @@ import io.eqoty.secretk.client.SigningCosmWasmClient import io.eqoty.wallet.MetaMaskWalletWrapper import io.eqoty.wallet.OfflineSignerOnlyAminoWalletWrapper import jslib.walletconnect.* +import jslib.walletconnect.IQRCodeModal import jslibs.secretjs.MetaMaskWallet import kotlinx.browser.window import kotlinx.coroutines.MainScope @@ -25,8 +26,8 @@ fun main() { application { // val client = getClientWithMetamaskWallet(Chain.Pulsar2) // val client = setupEthWalletConnectAndGetWallet(Chain.Pulsar2) - val client = getClientWithKeplrWallet(Chain.Pulsar2) -// val client = setupKeplrWalletConnectAndGetWallet(Chain.Secret4) +// val client = getClientWithKeplrWallet(Chain.Pulsar2) + val client = setupCosmosWalletConnectAndGetWallet(Chain.Secret4, WalletConnectModal.Cosmostation) console.log(client) onWasmReady { @@ -149,16 +150,31 @@ suspend fun getClientWithMetamaskWallet(chain: Chain): SigningCosmWasmClient { ) } +enum class WalletConnectModal(val signingMethods: Array, val qrcodeModal: IQRCodeModal){ + Keplr( + signingMethods = arrayOf( + "keplr_enable_wallet_connect_v1", + "keplr_sign_amino_wallet_connect_v1", + ), + qrcodeModal = KeplrQRCodeModalV1() + ), + Cosmostation( + signingMethods = arrayOf( +// "cosmostation_enable_wallet_connect_v1", +// "cosmostation_sign_amino_wallet_connect_v1", + "cosmostation_wc_accounts_v1", + "cosmostation_wc_sign_tx_v1", + ), + qrcodeModal = CosmostationWCModal() + ) +} -suspend fun setupKeplrWalletConnectAndGetWallet(chain: Chain): SigningCosmWasmClient { +suspend fun setupCosmosWalletConnectAndGetWallet(chain: Chain, wcModal: WalletConnectModal): SigningCosmWasmClient { val connector = WalletConnect( IWalletConnectOptionsInstance( bridge = "https://bridge.walletconnect.org", // Required - signingMethods = arrayOf( - "keplr_enable_wallet_connect_v1", - "keplr_sign_amino_wallet_connect_v1", - ), - qrcodeModal = KeplrQRCodeModalV1(), + signingMethods = wcModal.signingMethods, + qrcodeModal = wcModal.qrcodeModal, ) ) val keplr = if (!connector.connected) {