0.0.1 • Published 2 years ago
svelte-dappstores v0.0.1
svelte-dappstores
Everything you need to build a Svelte dapp, powered by the following dependencies:
This package is in development. Once we publish a new version, make sure to check if it contains any commits that may change the behaviour of your dapp.
Provider & Signer
import { providerStore } from 'svelte-dappstores';
// Connect to an injected provider.
$providerStore.connect();
// Connect to a supported provider.
$providerStore.connect(<provider: SupportedProvider>);
// Disconnect the provider.
$providerStore.disconnect();
// Note that `provider` holds the actual provider that is connected.
// This allows you to access the native provider methods. Have a look at the demo site to see how we
// use this to determine if the connected provider is Metamask.
$providerStore.provider;
$providerStore.signer;
$providerStore.accounts;
$providerStore.chainId;
$providerStore.connected;
$providerStore.error;
Contracts
import { createContractStore } from 'svelte-dappstores';
import type { ContractStore } from 'svelte-dappstores';
let contract: ContractStore;
contract = createContractStore('<address>', <abi>);
// Subscribe to any contract instance changes.
$contract.contract;
await contract.call('<methodName>');
await contract.call('<methodName>', [<param1>, <param2>, ...]);
// Subscribe to errors that might occur during store creation or contract calls
$contract.error;
Sign-In with Ethereum
import { siweStore } from 'svelte-dappstores';
// Generate siwe object.
siweStore.get();
// Generate siwe object with overridden properties.
siweStore.get({ nonce: 1 });
$siweStore.object.message;
$siweStore.object.signature;
// Subscribe to errors that might occur during store or siwe object creation
$siweStore.error;
Demo
To check out the demo site for this package, download this repository and run the following commands:
yarn install
yarn dev
Publishing
If you want to modify and publish the package yourself, run the following commands:
yarn package
yarn publish
Developing
If you want to make any code contributions, make sure to run the following before you start to develop on your machine:
yarn install
Make sure you format the code and run the tests before you push to the remote repository:
yarn format
yarn lint
yarn test
Building
To create a production version of the demo app:
yarn build
You can preview the production build with yarn preview
.
0.0.1
2 years ago