#wallet.isConnected is not a function

91 messages · Page 1 of 1 (latest)

wispy coyote
#
  1. Create an App: https://soroban.stellar.org/docs/getting-started/create-an-app

When executing 'npm run dev', I receive the following output and titled error:

| async function getAccount(wallet, server) {

8 | if (!(await wallet.isConnected()) || !(await wallet.isAllowed())) {
| ^
9 | return null;
10 | }
11 | const { publicKey } = await wallet.getUserInfo();

I'm using soroban 20.0.0-rc.4.1 and I no longer use config.toml in the .cargo directory or any
reference to that directory. I read somewhere that getAccount was deprecated but didn't
find instructions on what to replace it with.

========================================================================================

Finally, I was able to get the Hello Soroban web page. The following changes were made:

invoke.js: Here, I changed wallet.isConnected() to wallet.isViewCall. I literally used what I found available without knowing
what it does or if it's the correct attribute to use. I just know it must be a boolean value.

async function getAccount(wallet, server) {
if (!(await wallet.isViewCall) || !(await wallet.isAllowed())) {
return null;
}

index.astro: ...networks.telnet produced an error in VScode and when running the app via npm, I received the error, "Invalid contract ID: undefined"
in lib;contract.js:38:13

const greeter = new Contract({
...networks.unknown,
rpcUrl: 'https://soroban-testnet.stellar.org', // from https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers
});

I then tried the following, which worked: Even though the outcome was positive, I don't know
whether it was technically correct or not. If it is, then what do I need to do, and where, to insure
that correction is made in the documentation? If it's not, point me in the right direction to the solution.

Thanks.

Make a frontend web app that interacts with your smart contracts.

The RPC service allows you to communicate directly with Soroban via a JSON RPC interface.

hoary gyro
#

Hmmm interesting! could you share your code? I'm a little confused what you're trying to do. Is this about disconnecting a wallet still? Can you explain why you want to disconnect the wallet from the app and can we consider whether it's actually necessary to do?

wispy coyote
hoary gyro
#

Oh sorry someone was asking me about disconnecting a freighter wallet a couple days ago i thought this was related to that just got mixed up. I assumed that was why you dm'ed me like this was something we had talked about previously or something

wispy coyote
hoary gyro
#

I'd have to look at it deeper,, it sounds like you're having an issue with freighter do you have freighter installed

hoary gyro
#

yeah if you push your code to git it might help, the message you posted above is hard for me to read so i'm just a bit confused there

#

one sec

wispy coyote
hoary gyro
#

thanks

#

yeah i don't think you wanna replace the wallet.isconnected in invoke.js i have no idea what wallet.isviewcall is

#

also if you used networks.telnet that is a problem. it should be networks.TESTNET and it's all caps

#

that is a enum that returns the network passphrase

wispy coyote
hoary gyro
#

😄

#

yeah figuring out the wallet integrations can be a pain but perhaps you might wanna look at creditechs stellar-wallets-kit made by @lyric plover or the tool called "simple-signer" from PlutoDAO
Both of these make integrating wallets easier.

#

Basically think of it this way for the wallets, you wanna generate the transaction xdr and pass that to the wallet to get signed and submitted

#

still if you put your code on your gh it will make it easier to answer other questions you might have

wispy coyote
hoary gyro
#

ya absolutely make sure to change that wallet.isconnected back

#

i have no idea what isviewcall is supposed to be for but it sounds like an internal method

wispy coyote
hoary gyro
#

no that's not case sensitive

#

make sure you've done your soroban config network ...

#

for that to work

#

i think it's like soroban config network add testnet --network-passphrase "thenetworkpassphrase(lookitup)" --rpc-url https:://the.rpc.url

wispy coyote
hoary gyro
#

check the getting started section

#

i can try to link you hold

#

Take some time to read through t he getting started sections (other than just create-an-dapp)

wispy coyote
wispy coyote
# hoary gyro check the getting started section

The link to my repo is https://github.com/nagashi/soroban-smart-contract/tree/main
There're 3 spots where the message is "wallet.isConnected is not a function" which denote
the pain points. Thanks for your help. I'd still like to know where to find TESTNET. The stack trace is:

TypeError: wallet.isConnected is not a function
at getAccount (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/hello-soroban-client/dist/esm/invoke.js:8:24)
at invoke (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/hello-soroban-client/dist/esm/invoke.js:27:33)
at async Contract.hello (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/hello-soroban-client/dist/esm/index.js:86:16)
at async eval (/Users/chas/coding-environment/src/rust/projects/soroban-tutorial/src/pages/index.astro:11:18)
at async callComponentAsTemplateResultOrResponse (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/astro/dist/runtime/server/render/astro/render.js:85:25)
at async renderToReadableStream (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/astro/dist/runtime/server/render/astro/render.js:35:26)
at async renderPage (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/astro/dist/runtime/server/render/page.js:29:12)
at async renderPage (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/astro/dist/core/render/core.js:46:20)
at async #tryRenderRoute (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/astro/dist/core/pipeline.js:105:18)
at async DevPipeline.renderRoute (file:///Users/chas/coding-environment/src/rust/projects/soroban-tutorial/node_modules/astro/dist/core/pipeline.js:52:20)

GitHub

Soroban smart contract tutorial. Contribute to nagashi/soroban-smart-contract development by creating an account on GitHub.

knotty wraith
#

I'm getting the same error and can't proceed with the tutorial😅

wispy coyote
hoary gyro
#

Do you have freighter installed? wallet.isconnected is referring to freighter and wallet needs to be instantiated and the wallet needs to be connected. Have you looked at soroban-example-dapp? I can try to look at this in more detail when i have some extra time today

wispy coyote
#

I’ll look into it and keep you posted. Tonight is over for me. Thanks so much for the help. Have a great weekend.

wispy coyote
knotty wraith
# wispy coyote Do you have errors in any other part of the app as well?

I commented out greeting in index.astro and it was possible to build.

However, I get an error when I press the Increment button.
I am thinking that node_modules/hello-soroban-client might be the cause.

invoke.js:8 Uncaught (in promise) TypeError: wallet.isConnected is not a function at getAccount (invoke.js:8:24) at invoke (invoke.js:27:33) at async Contract2.increment (index.js:85:16) at async HTMLButtonElement.<anonymous> (Counter.astro:24:22)

The same was true when I cloned and built the following official repository
https://github.com/AhaLabs/soroban-tutorial-project

I wonder if the version of freighter-api is relevant.

GitHub

Contribute to AhaLabs/soroban-tutorial-project development by creating an account on GitHub.

wispy coyote
winter dock
#

hey, i'm running into the same error, changing it to ...networks.unknown also did not fix things for me! Looking for a solution

winter dock
#

@hoary gyro apologies for the tag, but could you please take a look here whenever you get some time 🤞🏻

knotty wraith
#

/node_modules/hello-soroban-client/dist/esm/invoke.js.
After looking into it, all I know is that this file seems to be causing the error.
I still don't understand astro very well, so I didn't know how to debug it 😅.I asked AI in the cursor editor and it didn't understand 😔

hoary gyro
#

I don't understand the issue you guys are having, but it sure sounds like you aren't connecting to your freighter wallet. are you sure you're using the correct version of freighter, it's on the network you want, and so forth

wispy coyote
knotty wraith
hoary gyro
#

Im gonna try to repro this on monday and see if we can figure it out. Sorry for the trouble been very busy

dreamy yarrow
dreamy yarrow
knotty wraith
# dreamy yarrow Yes. Freighter api version is important. Do you have a repo I can take a look?

https://soroban.stellar.org/docs/category/getting-started
I just followed "getting started".

https://github.com/AhaLabs/soroban-tutorial-project
I am getting the same "wallet.isConnected is not a function" error when I try this repository as is.

GitHub

Contribute to AhaLabs/soroban-tutorial-project development by creating an account on GitHub.

winter dock
#

exactly followed the guide, did not modify/change on my end

dreamy yarrow
dreamy yarrow
knotty wraith
dreamy yarrow
#

If I move the the "bindings" out of "node_modules" and use import { Contract, networks } from "../incrementor-client/src"; works
My theory is that there is a mismatch of freighter-api versions between the frontend (astro) and the contract bindings

knotty wraith
dreamy yarrow
#

I checked and it's not about the versions.
Some how, by having the contract bindings scripts inside node_modules it breaks, if I bring it out (hence, using the main project's packages; does not break)
Maybe @worthy hinge can have a clue?

worthy hinge
#

it's the .default that you need, btw

hoary gyro
#

That fixes the wallet. Error?

worthy hinge
#

for now, you could install the version from the release branch directly cargo install --git https://github.com/stellar/soroban-tools/pull/1070 --branch release/v20.0.0-rc.4.2 soroban-cli

worthy hinge
#

if I understand the problem correctly

#

can you try that branch of the CLI and see if it works?

hoary gyro
#

Im gonna try today to reproduce it finally

#

Alot of people been asking me

#

Thank you

worthy hinge
#

there's also currently a bug with the rc4.1 release where the networks export from your generated library does not handle testnet correctly

#

it might be in there as networks.unknown instead of networks.testnet

#

the typeahead in your editor should help figure that out

#

not sure if that will still be a problem if you build from the branch

wispy coyote
worthy hinge
#

It will install it globally on your system. There is a way to pin a specific version to a specific repository, but this is not gonna do that

wispy coyote
wispy coyote
wispy coyote
worthy hinge
winter dock
#

helloo, i still run into this wallet.isConnected is not a function

swift talon
# winter dock helloo, i still run into this `wallet.isConnected is not a function`

is it for server side simulation?
While using the typescript bindings, if I only need the result of a simulation I use this fake wallet:

const FakeWallet = {
  isConnected: function()  { return false },
};

// then:
const contract = new Contract({
    ...networks.localnet,
    rpcUrl: 'http://localhost:8000/soroban/rpc',
    wallet: FakeWallet,
  });
winter dock
#

haha nice, i also used something similar since i only wanted to call a read method

#

and it worked gg

hoary gyro
wispy coyote
hoary gyro