kit-squared 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@ This library is in development, in a pre-release state. If you stumble across it
8
8
 
9
9
  [Skip to Contents](#contents)
10
10
 
11
- <!-- [Skip to Example Project](---) -->
11
+ [Skip to Example Project](https://github.com/AnAllergyToAnalogy/kit-squared/tree/main/example)
12
12
 
13
13
  ## Initialising
14
14
 
@@ -172,19 +172,19 @@ Kit² uses BigInts for dealing with integers, and will be accepted for all integ
172
172
 
173
173
  However, since PDAs pack data in a very specific way when deriving the address, when adding integers as seeds for PDAs, use the following format:
174
174
  ```typescript
175
- [value, size_in_bits]
175
+ [value, integer_type]
176
176
  ```
177
177
 
178
178
  so a `u16` with the value of `1234` would be passed as
179
179
  ```typescript
180
- [1234n,16n]
180
+ [1234n,"u16"]
181
181
  ```
182
182
 
183
183
  _example_
184
184
  ```typescript
185
185
  // Your PDA seeds are "user" and then the index of the user as a u32,
186
186
  // and you want to get user 67
187
- const address = await myProgram.pda(["user",[67n, 32n]]);
187
+ const address = await myProgram.pda(["user",[67n, "u32"]]);
188
188
  ```
189
189
 
190
190
  Full details available in the [PDA section of the docs](https://github.com/AnAllergyToAnalogy/kit-squared/blob/main/docs/PDAs.md).
@@ -210,8 +210,5 @@ Managing accounts included in instructions and transactions.
210
210
  ### [Utils](https://github.com/AnAllergyToAnalogy/kit-squared/blob/main/docs/utils/UTILS.md)
211
211
  Various utilities, some relating specific to Solana, others that are more broadly used by this library.
212
212
 
213
- <!-- ### [Example](TODO)
214
- An example repo showing basic usage of the Kit² library. -->
215
-
216
- ### Example
217
- TODO: example repo showing basic usage of the Kit² library.
213
+ ### [Example](https://github.com/AnAllergyToAnalogy/kit-squared/tree/main/example)
214
+ An example repo showing basic usage of the Kit² library.
package/dist/index.d.ts CHANGED
@@ -6,5 +6,3 @@ export { transacting, TRANSACTION_STATE, transactionState, onTransaction, clearA
6
6
  export * from "./library/utils.js";
7
7
  export { walletState, walletInitial, walletConnecting, walletConnected, walletError, signer, myKey, me, myKeyString, isMe, getStoredWalletSelection, disconnectWallet, unmountWallet } from "./library/wallet.js";
8
8
  export { availableWallets, selection, selectWallet, getWalletInfo, unmountTeardown, recheckWallets, } from "./library/walletSelection.js";
9
- export { requestAndConnectWallet, visible, showPrompt, hidePrompt, } from "./components/walletSelectionComponent.js";
10
- export * as WalletSelection from "./WalletSelection.svelte";
package/dist/index.js CHANGED
@@ -12,6 +12,12 @@ export { transacting, TRANSACTION_STATE, transactionState, onTransaction, clearA
12
12
  export * from "./library/utils.js";
13
13
  export { walletState, walletInitial, walletConnecting, walletConnected, walletError, signer, myKey, me, myKeyString, isMe, getStoredWalletSelection, disconnectWallet, unmountWallet } from "./library/wallet.js";
14
14
  export { availableWallets, selection, selectWallet, getWalletInfo, unmountTeardown, recheckWallets, } from "./library/walletSelection.js";
15
- export { requestAndConnectWallet, visible, showPrompt, hidePrompt, } from "./components/walletSelectionComponent.js";
15
+ // Todo: Example Component
16
+ // export {
17
+ // requestAndConnectWallet,
18
+ // visible,
19
+ // showPrompt,
20
+ // hidePrompt,
21
+ // } from "./components/walletSelectionComponent.js";
16
22
  //@ts-ignore
17
- export * as WalletSelection from "./WalletSelection.svelte";
23
+ // export * as WalletSelection from "./WalletSelection.svelte";
@@ -1,16 +1,13 @@
1
+ import { type Callback } from "./utils.js";
1
2
  export declare const connectIsScheduled: import("svelte/store").Writable<boolean>;
2
3
  export declare const disconnectIsScheduled: import("svelte/store").Writable<boolean>;
3
4
  type Action = "connect" | "disconnect";
4
5
  export declare function scheduleConnect(action: Action): void;
5
- export declare const onConnect: {
6
- (callback: import("./utils.js").Callback): () => void;
7
- trigger: (...args: any[]) => Promise<void>;
8
- killAll: () => void;
9
- };
10
6
  export declare const onDisconnect: {
11
- (callback: import("./utils.js").Callback): () => void;
7
+ (callback: Callback): () => void;
12
8
  trigger: (...args: any[]) => Promise<void>;
13
9
  killAll: () => void;
14
10
  };
11
+ export declare const onConnect: (callback: Callback, fireImmediatelyIfAlreadyConnected?: boolean) => () => void;
15
12
  export declare function startConnectSchedule(): void;
16
13
  export {};
@@ -1,5 +1,5 @@
1
- import { writable } from "svelte/store";
2
- import { onWalletConnect, onWalletDisconnect } from "./wallet.js";
1
+ import { get, writable } from "svelte/store";
2
+ import { onWalletConnect, onWalletDisconnect, walletConnected } from "./wallet.js";
3
3
  import { Event } from "./utils.js";
4
4
  export const connectIsScheduled = writable(false);
5
5
  export const disconnectIsScheduled = writable(false);
@@ -15,8 +15,19 @@ export function scheduleConnect(action) {
15
15
  }
16
16
  _checkSchedule();
17
17
  }
18
- export const onConnect = Event();
18
+ const onConnectEvent = Event();
19
19
  export const onDisconnect = Event();
20
+ //Special case where onConnects fire when they are registeredd if its already connected
21
+ export const onConnect = function (callback, fireImmediatelyIfAlreadyConnected = true) {
22
+ // if(connected){
23
+ if (get(walletConnected) && fireImmediatelyIfAlreadyConnected) {
24
+ callback();
25
+ }
26
+ return onConnectEvent(callback);
27
+ };
28
+ // export const onDisconnect = function(callback: Callback){
29
+ // if(disconnected)
30
+ // }
20
31
  async function _checkSchedule(loopback = false) {
21
32
  if (checkingQueue && !loopback)
22
33
  return;
@@ -26,7 +37,7 @@ async function _checkSchedule(loopback = false) {
26
37
  connectIsScheduled.set(connectQueue.includes("connect"));
27
38
  disconnectIsScheduled.set(connectQueue.includes("disconnect"));
28
39
  if (next === "connect") {
29
- await onConnect.trigger();
40
+ await onConnectEvent.trigger();
30
41
  }
31
42
  else if (next === "disconnect") {
32
43
  await onDisconnect.trigger();
@@ -160,7 +160,6 @@ export async function disconnectWallet() {
160
160
  myKey = null;
161
161
  me.set(null);
162
162
  _setWalletState(INITIAL);
163
- log("disconnected. triggering onWalletDisconnect");
164
163
  onWalletDisconnect.trigger();
165
164
  }
166
165
  function _buildTransactionSendingSigner(_networkType) {
@@ -207,7 +206,7 @@ export function initialiseWallet() {
207
206
  onSelectWallet(async () => {
208
207
  if (!_selection || !_selection.wallet)
209
208
  throw new Error("Wallet selection is null");
210
- // They just specified which wallet they are gonna use it didn't connect. Connect is done else where
209
+ // They just specified which wallet they are gonna use, it didn't connect. Connect is done else where
211
210
  // Connect wallet
212
211
  await connectWallet(_selection.wallet.uiWallet);
213
212
  signer = _buildTransactionSendingSigner(networkType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kit-squared",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "description": "Solana Kit functionality with SvelteKit",
5
5
  "license": "ISC",
6
6
  "author": "AnAllergyToAnalogy",