Giter VIP home page Giter VIP logo

solana-svelte-counter's People

Contributors

cogoo avatar silvestrevivo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

solana-svelte-counter's Issues

Front end error

$'npm run dev'

'
TypeError: Cannot read properties of undefined (reading 'address')
at eval (/src/lib/AnchorConnectionProvider.svelte:27:47)
at Object.$$render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1684:22)
at eval (/src/routes/__layout.svelte:46:103)
at Object.$$render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1684:22)
at root.svelte:37:45
at $$render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1684:22)
at Object.render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1692:26)
at render_response (file:///mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/@sveltejs/kit/dist/chunks/index.js:1070:28)
at async respond_with_error (file:///mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/@sveltejs/kit/dist/chunks/index.js:1691:10)
at async respond$1 (file:///mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/@sveltejs/kit/dist/chunks/index.js:1942:4)

TypeError: Cannot read properties of undefined (reading 'address')
at eval (/src/lib/AnchorConnectionProvider.svelte:27:47)
at Object.$$render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1684:22)
at eval (/src/routes/__layout.svelte:46:103)
at Object.$$render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1684:22)
at root.svelte:37:45
at $$render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1684:22)
at Object.render (/mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/svelte/internal/index.js:1692:26)
at render_response (file:///mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/@sveltejs/kit/dist/chunks/index.js:1070:28)
at async respond_with_error (file:///mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/@sveltejs/kit/dist/chunks/index.js:1691:10)
at async respond$1 (file:///mnt/c/Users/shane/Desktop/solana-svelte-counter/solana-svelte-counter/app/node_modules/@sveltejs/kit/dist/chunks/index.js:1942:4)

'

Some instances of `localhost` may need to be `localnet`

Just following the instructions:

Make sure that you have Solana locally in localhost and change all the devnet references to localhost

$ npx anchor localnet
Workspace configuration error: Cluster must be one of [localnet, testnet, mainnet, devnet] or be an http or https url

What I ended up doing was setting this in my Anchor.toml - I'm not 100% sure it's correct (I have little Anchor experience, hence not sending a PR) but it worked:

[programs.localnet]
solana_svelte_counter = "C7SGr2s3HdBuEveTahL9H3CsXQDwxkYEUSRPeJAVeDN5"

[registry]
url = "https://anchor.projectserum.com"

[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "mocha -t 1000000 tests/"

Does that sound correct? If so let me know and I will add the to the PR I will send - I have a bunch of small fixes to contribute! ๐Ÿ˜Š

autoConnect is not working

AutoConnect is not working correctly. There are two possibilities:

    1. It is a UI issue
    1. It is an issue coming from the adapter.

My theory is that is an UI error of the current solution I made. Checking the code, it seems that we are clicking on select() and, since autoConnect is true, automatically the connect() function is triggered. That's why when autoConnect is false, the wallet is not popping up.

I made a change locally and it is working. Even in the Vue implementation works like that. The select() function is to select the adapter, and the connect() is to popup the wallet selected. See here the Vue implementation:

https://github.com/solana-labs/wallet-adapter/pull/118/files

The change I made was:

<script>
.... 

type WalletProvider = { id: number; text: string };

    let walletProviders: WalletProvider[] = [
        { id: 1, text: `Phantom` },
        { id: 2, text: `Slope` },
        { id: 3, text: `Solflare` }
    ];

    let selected;

    $: selected && selectWallet(selected.text);
</script>

<div class="wrapper-content">
		{#if $walletStore?.connected}
			<button on:click={() => $walletStore.disconnect()}>disconnect wallet</button>
		{:else}
			<p>Select wallet</p>
			<select bind:value={selected}>
				{#each walletProviders as walletProvider}
					<option value={walletProvider}>
						{walletProvider.text}
					</option>
				{/each}
			</select>
			{#if selected}
				<button on:click={() => $walletStore.connect()}>connect {selected.text}</button>
			{/if}
		{/if}
	</div>

Fetching Data "Error: Cannot read properties of undefined (reading 'program')"

Hey, hello.

It's great to have work as yours as a reference. Working with new technologies with little documentation and examples I'm feeling deep appreciation for having people who provide like that.

Using your groundwork form your demo-app and the svele-on-solana packages I'm trying to deepen my knowledge. Where I'm running into some problems is trying to fetch data.

How would you access the program variable to only fetch data?

let data
const getData = async () => {
  data = await $workSpace.program.account.baseAccount.all()

  // alternatively something like
  data = await $workSpace.program.account.baseAccount.fetch(
    $workSpace.baseAccount.publicKey
  );
  
  console.log(data);
  return data;
  };

Executing something like the example function above gives the error TypeError: Cannot read properties of undefined (reading 'program')

I know, this is an issue that isn't really related to the repo. It's more just me having difficulties to get ahead with something I don't quiet understand yet. Which is a rather egoistic thing to ask here. Anyway I'm opening this and hoping you can maybe provide an example inside the packages or demo app how fetch data outside the already provided RPC functions.

Sending love and blessings

Edit:
Trying for two more hours, and coming back more confused that the same code works in some situations when I'm connected to a wallet. But most of the time trying to fetch it's the Error: Uncaught (in promise) TypeError: can't access property "program", $workSpace is undefined. Possibly someone can tell what I am doing wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.