kit-squared 0.1.2 → 0.2.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.
@@ -1,7 +1,8 @@
1
1
  import { type Address } from "@solana/kit";
2
2
  export declare const ZERO_ADDRESS = "11111111111111111111111111111111";
3
3
  export declare function integerTypeToSize(type: string): string;
4
- export declare function isIntergerType(type: string): boolean;
4
+ export declare function isIntegerType(type: string): boolean;
5
+ export declare function isNumberType(type: string): boolean;
5
6
  export declare const typeEncoder: {
6
7
  [key: string]: any;
7
8
  };
@@ -5,7 +5,7 @@ export const ZERO_ADDRESS = "11111111111111111111111111111111";
5
5
  export function integerTypeToSize(type) {
6
6
  return type.substring(1);
7
7
  }
8
- export function isIntergerType(type) {
8
+ export function isIntegerType(type) {
9
9
  const types = ["isize", "usize"];
10
10
  for (let i = 0; i < 8; i++) {
11
11
  const s = 8 * (2 ** i);
@@ -14,6 +14,10 @@ export function isIntergerType(type) {
14
14
  }
15
15
  return types.includes(type);
16
16
  }
17
+ export function isNumberType(type) {
18
+ const types = ["f32", "f64"];
19
+ return types.includes(type) || isIntegerType(type);
20
+ }
17
21
  // Encoders
18
22
  // export const typeEncoder = (()=>{
19
23
  // //TODO: types probably not complete
@@ -33,7 +37,7 @@ export function isIntergerType(type) {
33
37
  // return e;
34
38
  // })();
35
39
  export const typeEncoder = (() => {
36
- const types = ["Address"];
40
+ const types = ["Address", "f32", "f64"];
37
41
  for (let i = 0; i < 5; i++) {
38
42
  const s = 8 * (2 ** i);
39
43
  types.push("U" + s);
@@ -154,8 +158,8 @@ export async function getPDA(seeds, programId) {
154
158
  }
155
159
  const value = seed[0];
156
160
  const t = seed[1];
157
- if (!isIntergerType(t)) {
158
- throw new Error("Not an integer type: " + t);
161
+ if (!isNumberType(t)) {
162
+ throw new Error("Not a valid number type: " + t);
159
163
  }
160
164
  seeds_parsed.push(typeEncoder[t].encode(value));
161
165
  // if(!isIntegerType)
@@ -1,4 +1,3 @@
1
- let log = console.log;
2
1
  import { writable, derived } from "svelte/store";
3
2
  import { Event } from "./utils.js";
4
3
  import { getNetworkType } from "./connection.js";
@@ -74,21 +73,12 @@ function uiWalletAccountsAreSame(a, b) {
74
73
  return underlyingWalletA === underlyingWalletB;
75
74
  }
76
75
  async function connectWallet(uiWallet) {
77
- // log("===---===---===")
78
- // log("connect ui wallet", uiWallet);
79
76
  _setWalletState(CONNECTING);
80
- // Get some sorta thing
81
77
  const wallet = getWalletForHandle_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(uiWallet);
82
- // log(2)
83
- // log(wallet);
84
78
  // Accounts that are available?
85
79
  const existingAccounts = [...uiWallet.accounts];
86
- // log(3)
87
- // log(existingAccounts);
88
80
  // Do some stuff to get the ability to connect
89
81
  const connectFeature = getWalletFeature(uiWallet, StandardConnect);
90
- // log(4)
91
- // log(connectFeature)
92
82
  // Wallet accounts for all the wallets in this connected one maybe
93
83
  const accountsPromise = connectFeature
94
84
  .connect()
@@ -97,51 +87,29 @@ async function connectWallet(uiWallet) {
97
87
  // return accounts;
98
88
  return accounts.map(getOrCreateUiWalletAccountForStandardWalletAccount_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.bind(null, wallet));
99
89
  });
100
- // log(5)
101
- // log(accountsPromise);
102
- // I don't know whhy this is called nextAccounts. Some other layer of wallet type.
103
90
  const nextAccounts = await accountsPromise;
104
- // console.log("next accounts", nextAccounts);
105
- // log(6)
106
- // log(nextAccounts)
107
91
  // Just set connectedWallet
108
92
  connectedWallet = uiWallet;
109
93
  hasConnectedWallet.set(true);
110
- //TODO: not sure what this is doing
111
94
  // Try to choose the first never-before-seen account. Gonna assume this is the right move for now
112
95
  for (const nextAccount of nextAccounts) {
113
96
  if (!existingAccounts.some((existingAccount) => uiWalletAccountsAreSame(nextAccount, existingAccount))) {
114
- // onAccountSelect(nextAccount);
115
- // console.error("Found not seen account, set as connectedWalletAccount");
116
97
  connectedWalletAccount = nextAccount;
117
98
  hasConnectedWalletAccount.set(true);
118
99
  _setWalletState(CONNECTED);
119
- // localStorage.setItem(
120
- // STORAGE_KEY,
121
- // `${wallet.name}:${connectedWalletAccount.address}`,
122
- // );
123
- // console.log("compare accounts", connectedWalletAccount);
124
100
  return;
125
101
  }
126
102
  }
127
103
  if (nextAccounts.length > 0) {
128
- // onAccountSelect(nextAccounts[0]);
129
- // console.error("Fallback to just using the first one available")
130
104
  connectedWalletAccount = nextAccounts[0];
131
105
  hasConnectedWalletAccount.set(true);
132
106
  _setWalletState(CONNECTED);
133
- // localStorage.setItem(
134
- // STORAGE_KEY,
135
- // `${wallet.name}:${connectedWalletAccount.address}`,
136
- // );
137
- // console.log("default accounts", connectedWalletAccount);
138
107
  return;
139
108
  }
140
109
  console.error("No available wallets found for unspecified reason");
141
110
  _setWalletState(INITIAL);
142
111
  }
143
112
  export async function disconnectWallet() {
144
- log("disconnect wallet..");
145
113
  clearStoredWalletSelection();
146
114
  clearSelectedVars();
147
115
  if (!connectedWallet) {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "kit-squared",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Solana Kit functionality with SvelteKit",
5
5
  "license": "ISC",
6
- "author": "AnAllergyToAnalogy",
6
+ "author": "AnAllergyToAnalogy",
7
7
  "scripts": {
8
8
  "dev": "vite dev",
9
9
  "build": "vite build && npm run prepack",
@@ -62,7 +62,6 @@
62
62
  "@wallet-standard/base": "^1.1.0",
63
63
  "@wallet-standard/features": "^1.1.0",
64
64
  "@wallet-standard/ui": "^1.0.1",
65
- "@wallet-standard/ui-registry": "^1.0.1",
66
- "buffer": "^6.0.3"
65
+ "@wallet-standard/ui-registry": "^1.0.1"
67
66
  }
68
67
  }