@effectstream/frontend-sdk 0.101.1 → 0.102.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/LICENSE-APACHE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024-2026 Midnight Foundation
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Midnight Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/mod.js CHANGED
@@ -14671,10 +14671,10 @@ var init_crypto = __esm(() => {
14671
14671
  exports.RSAPublicKey = RSAPublicKey;
14672
14672
  var AlgorithmIdentifier = asn1.define("AlgorithmIdentifier", function() {
14673
14673
  this.seq().obj(this.key("algorithm").objid(), this.key("none").null_().optional(), this.key("curve").objid().optional(), this.key("params").seq().obj(this.key("p").int(), this.key("q").int(), this.key("g").int()).optional());
14674
- }), PublicKey = asn1.define("SubjectPublicKeyInfo", function() {
14674
+ }), PublicKey2 = asn1.define("SubjectPublicKeyInfo", function() {
14675
14675
  this.seq().obj(this.key("algorithm").use(AlgorithmIdentifier), this.key("subjectPublicKey").bitstr());
14676
14676
  });
14677
- exports.PublicKey = PublicKey;
14677
+ exports.PublicKey = PublicKey2;
14678
14678
  var PrivateKeyInfo = asn1.define("PrivateKeyInfo", function() {
14679
14679
  this.seq().obj(this.key("version").int(), this.key("algorithm").use(AlgorithmIdentifier), this.key("subjectPrivateKey").octstr());
14680
14680
  });
@@ -18576,6 +18576,17 @@ var variableLengthDecode = (array) => {
18576
18576
  return { bytesRead, value };
18577
18577
  };
18578
18578
 
18579
+ // ../effectstream-sdk/utils/src/types/validators/solana.ts
18580
+ import bs582 from "bs58";
18581
+ var ADDRESS_BYTE_LENGTH3 = 32;
18582
+ function verifySolanaAddress(address) {
18583
+ const decoded = bs582.decode(address);
18584
+ if (decoded.length !== ADDRESS_BYTE_LENGTH3) {
18585
+ throw new Error(`Malformed Solana address: expected byte length ${ADDRESS_BYTE_LENGTH3}, got ${decoded.length}`);
18586
+ }
18587
+ return true;
18588
+ }
18589
+
18579
18590
  // ../effectstream-sdk/utils/src/types/typebox-helpers.ts
18580
18591
  function tryDecode(val, validator, checkResult = () => true) {
18581
18592
  try {
@@ -18594,6 +18605,7 @@ FormatRegistry.Set("cardano-address", (val) => tryDecode(val, verifyCardanoByron
18594
18605
  FormatRegistry.Set("ss58", (val) => tryDecode(val, ss58.decode));
18595
18606
  FormatRegistry.Set("bs58check", (val) => tryDecode(val, bs58check2.decode));
18596
18607
  FormatRegistry.Set("bech32", (val) => tryDecode(val, (val2) => bech322.decode(val2, Number.MAX_SAFE_INTEGER / 2)));
18608
+ FormatRegistry.Set("solana-address", (val) => tryDecode(val, verifySolanaAddress));
18597
18609
  function forceLowercase(schema) {
18598
18610
  return Type.Transform(schema).Decode((value) => value.toLowerCase()).Encode((value) => value.toLowerCase());
18599
18611
  }
@@ -18659,6 +18671,9 @@ var TypeboxHelpers = {
18659
18671
  Near: {
18660
18672
  Address: Type.Unsafe(Type.String())
18661
18673
  },
18674
+ Solana: {
18675
+ Address: Type.Unsafe(Type.String({ format: "solana-address" }))
18676
+ },
18662
18677
  Caip2: Type.Unsafe(Type.String()),
18663
18678
  WalletAddress: () => Type.Union(AddressTypebox),
18664
18679
  IntervalMs: (options) => Type.Unsafe(Type.Number(options)),
@@ -18685,7 +18700,8 @@ var AddressValidator = {
18685
18700
  [4 /* MINA */]: TypeboxHelpers.Mina.Address,
18686
18701
  [5 /* MIDNIGHT */]: TypeboxHelpers.Midnight.Address,
18687
18702
  [7 /* POLKADOT */]: TypeboxHelpers.Polkadot.Address,
18688
- [8 /* NEAR */]: TypeboxHelpers.Near.Address
18703
+ [8 /* NEAR */]: TypeboxHelpers.Near.Address,
18704
+ [9 /* SOLANA */]: TypeboxHelpers.Solana.Address
18689
18705
  };
18690
18706
  var AddressTypebox = [
18691
18707
  Type.Object({
@@ -18727,6 +18743,10 @@ var AddressTypebox = [
18727
18743
  Type.Object({
18728
18744
  type: Type.Literal(8 /* NEAR */),
18729
18745
  address: TypeboxHelpers.Near.Address
18746
+ }),
18747
+ Type.Object({
18748
+ type: Type.Literal(9 /* SOLANA */),
18749
+ address: TypeboxHelpers.Solana.Address
18730
18750
  })
18731
18751
  ];
18732
18752
  // ../effectstream-sdk/utils/src/viem.ts
@@ -18976,7 +18996,7 @@ class MidnightCrypto {
18976
18996
  return false;
18977
18997
  const [ledgerMod, addrMod] = await Promise.all([
18978
18998
  import("@midnight-ntwrk/ledger-v8"),
18979
- import("@midnight-ntwrk/wallet-sdk-address-format")
18999
+ import("@midnightntwrk/wallet-sdk-address-format")
18980
19000
  ]);
18981
19001
  const expectedHexAddress = ledgerMod.addressFromKey(verifyingKey).toLowerCase();
18982
19002
  let decodedHex;
@@ -19001,6 +19021,37 @@ class MidnightCrypto {
19001
19021
  }
19002
19022
  }
19003
19023
 
19024
+ // ../effectstream-sdk/crypto/src/chains/solana.ts
19025
+ import { PublicKey } from "@solana/web3.js";
19026
+ import nacl from "tweetnacl";
19027
+ import { Value as Value8 } from "@sinclair/typebox/value";
19028
+
19029
+ class SolanaCrypto {
19030
+ verifyAddress = (address) => {
19031
+ return Value8.Check(TypeboxHelpers.Solana.Address, address);
19032
+ };
19033
+ verifySignature = async (userAddress, message, sigStruct) => {
19034
+ try {
19035
+ if (!this.verifyAddress(userAddress)) {
19036
+ return false;
19037
+ }
19038
+ if (!sigStruct) {
19039
+ return false;
19040
+ }
19041
+ const publicKeyBytes = new PublicKey(userAddress).toBytes();
19042
+ const messageBytes = new TextEncoder().encode(message);
19043
+ const signatureBytes = new Uint8Array(Buffer.from(sigStruct, "base64"));
19044
+ return nacl.sign.detached.verify(messageBytes, signatureBytes, publicKeyBytes);
19045
+ } catch (err) {
19046
+ console.error("[address-validator] error verifying solana signature:", err);
19047
+ return false;
19048
+ }
19049
+ };
19050
+ decodeAddress(address) {
19051
+ return Value8.Decode(TypeboxHelpers.Solana.Address, address);
19052
+ }
19053
+ }
19054
+
19004
19055
  // ../effectstream-sdk/crypto/src/CryptoManager.ts
19005
19056
  class CryptoManager {
19006
19057
  static algorand;
@@ -19009,6 +19060,7 @@ class CryptoManager {
19009
19060
  static polkadot;
19010
19061
  static mina;
19011
19062
  static midnight;
19063
+ static solana;
19012
19064
  static Algorand() {
19013
19065
  if (CryptoManager.algorand == null) {
19014
19066
  CryptoManager.algorand = new AlgorandCrypto;
@@ -19045,6 +19097,12 @@ class CryptoManager {
19045
19097
  }
19046
19098
  return CryptoManager.midnight;
19047
19099
  }
19100
+ static Solana() {
19101
+ if (CryptoManager.solana == null) {
19102
+ CryptoManager.solana = new SolanaCrypto;
19103
+ }
19104
+ return CryptoManager.solana;
19105
+ }
19048
19106
  static getCryptoManager(addressType) {
19049
19107
  switch (addressType) {
19050
19108
  case 0 /* EVM */:
@@ -19059,6 +19117,8 @@ class CryptoManager {
19059
19117
  return CryptoManager.Mina();
19060
19118
  case 5 /* MIDNIGHT */:
19061
19119
  return CryptoManager.Midnight();
19120
+ case 9 /* SOLANA */:
19121
+ return CryptoManager.Solana();
19062
19122
  default:
19063
19123
  throw new Error(`Unsupported address type: ${addressType}`);
19064
19124
  }
@@ -19077,7 +19137,7 @@ function toKeyedJsonGrammar(grammar) {
19077
19137
  return keyedTypes;
19078
19138
  }
19079
19139
  // ../effectstream-sdk/concise/src/v2/inputs.ts
19080
- import { Value as Value8 } from "@sinclair/typebox/value";
19140
+ import { Value as Value9 } from "@sinclair/typebox/value";
19081
19141
  // ../effectstream-sdk/concise/src/v2/builtins/batcher.ts
19082
19142
  import { Type as Type3 } from "@sinclair/typebox";
19083
19143
  function userAddress(addr) {
@@ -19172,7 +19232,7 @@ function createMessageForBatcher(namespace, millisecondTimestamp, _walletAddress
19172
19232
  // ../effectstream-sdk/concise/src/delegate.ts
19173
19233
  import { privateKeyToAccount } from "viem/accounts";
19174
19234
  import { createWalletClient, http as http2 } from "viem";
19175
- import { Value as Value9 } from "@sinclair/typebox/value";
19235
+ import { Value as Value10 } from "@sinclair/typebox/value";
19176
19236
  var accountMessages = {
19177
19237
  linkAccount: (account_id, other_address, is_new_primary) => {
19178
19238
  return `link:${String(account_id)}:${other_address}:${is_new_primary ? "true" : "false"}`;
@@ -20682,11 +20742,11 @@ class MidnightLocalProvider {
20682
20742
  getUnshieldedKeystore = () => this.unshieldedKeystore;
20683
20743
  }
20684
20744
  async function loadKeystoreDeps() {
20685
- const hdMod = await import("@midnight-ntwrk/wallet-sdk-hd").catch(() => {
20686
- throw new Error("@midnight-ntwrk/wallet-sdk-hd is required for WalletMode.MidnightLocal.");
20745
+ const hdMod = await import("@midnightntwrk/wallet-sdk-hd").catch(() => {
20746
+ throw new Error("@midnightntwrk/wallet-sdk-hd is required for WalletMode.MidnightLocal.");
20687
20747
  });
20688
- const keystoreMod = await import("@midnight-ntwrk/wallet-sdk-unshielded-wallet").catch(() => {
20689
- throw new Error("@midnight-ntwrk/wallet-sdk-unshielded-wallet is required for WalletMode.MidnightLocal.");
20748
+ const keystoreMod = await import("@midnightntwrk/wallet-sdk-unshielded-wallet").catch(() => {
20749
+ throw new Error("@midnightntwrk/wallet-sdk-unshielded-wallet is required for WalletMode.MidnightLocal.");
20690
20750
  });
20691
20751
  return { hdMod, keystoreMod };
20692
20752
  }
@@ -20708,6 +20768,236 @@ function generateRandomHexSeed(byteLength2) {
20708
20768
  return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
20709
20769
  }
20710
20770
 
20771
+ // ../effectstream-sdk/wallets/src/solana/solana.ts
20772
+ import { getWallets } from "@wallet-standard/app";
20773
+ import { Transaction } from "@solana/web3.js";
20774
+ var STANDARD_CONNECT = "standard:connect";
20775
+ var STANDARD_DISCONNECT = "standard:disconnect";
20776
+ var SOLANA_SIGN_MESSAGE = "solana:signMessage";
20777
+ var SOLANA_SIGN_TRANSACTION = "solana:signTransaction";
20778
+
20779
+ class SolanaConnector {
20780
+ provider;
20781
+ static INSTANCE = undefined;
20782
+ static getWalletOptions() {
20783
+ const win = getWindow();
20784
+ const wallets = [];
20785
+ if (win?.phantom?.solana) {
20786
+ wallets.push({
20787
+ metadata: {
20788
+ name: "phantom",
20789
+ displayName: "Phantom",
20790
+ icon: win.phantom?.solana?.icon
20791
+ },
20792
+ api: async () => win.phantom.solana
20793
+ });
20794
+ }
20795
+ if (win?.backpack?.solana) {
20796
+ wallets.push({
20797
+ metadata: {
20798
+ name: "backpack",
20799
+ displayName: "Backpack"
20800
+ },
20801
+ api: async () => win.backpack.solana
20802
+ });
20803
+ }
20804
+ if (win?.solflare?.isSolflare) {
20805
+ wallets.push({
20806
+ metadata: {
20807
+ name: "solflare",
20808
+ displayName: "Solflare"
20809
+ },
20810
+ api: async () => win.solflare
20811
+ });
20812
+ }
20813
+ if (win?.solana && !win.solana.isPhantom && wallets.length === 0) {
20814
+ wallets.push({
20815
+ metadata: {
20816
+ name: "solana",
20817
+ displayName: "Solana Wallet"
20818
+ },
20819
+ api: async () => win.solana
20820
+ });
20821
+ }
20822
+ try {
20823
+ for (const w of getWallets().get()) {
20824
+ if (!isSolanaStandardWallet(w))
20825
+ continue;
20826
+ const name = (w.name ?? "").toLowerCase();
20827
+ const already = wallets.some((o) => o.metadata.displayName.toLowerCase() === name);
20828
+ if (already)
20829
+ continue;
20830
+ wallets.push({
20831
+ metadata: {
20832
+ name: `standard:${name}`,
20833
+ displayName: w.name,
20834
+ icon: w.icon
20835
+ },
20836
+ api: async () => new WalletStandardSolanaApi(w)
20837
+ });
20838
+ }
20839
+ } catch {}
20840
+ return wallets;
20841
+ }
20842
+ static instance() {
20843
+ if (SolanaConnector.INSTANCE == null) {
20844
+ const newInstance = new SolanaConnector;
20845
+ SolanaConnector.INSTANCE = newInstance;
20846
+ }
20847
+ return SolanaConnector.INSTANCE;
20848
+ }
20849
+ connectSimple = async () => {
20850
+ const options = SolanaConnector.getWalletOptions();
20851
+ if (options.length === 0) {
20852
+ throw new Error("No Solana wallet found. Please install a Solana wallet (Phantom, Backpack, or MetaMask).");
20853
+ }
20854
+ return this.connectNamed(options[0].metadata.name);
20855
+ };
20856
+ connectNamed = async (name) => {
20857
+ const options = SolanaConnector.getWalletOptions();
20858
+ const option = options.find((o) => o.metadata.name === name);
20859
+ if (!option) {
20860
+ throw new Error(`Wallet "${name}" not found`);
20861
+ }
20862
+ const active = await optionToActive(option);
20863
+ return this.connectExternal(active);
20864
+ };
20865
+ connectExternal = async (conn) => {
20866
+ const api = conn.api;
20867
+ if (api.isConnected === false) {
20868
+ await api.connect();
20869
+ }
20870
+ const address = api.publicKey.toBase58();
20871
+ this.provider = new SolanaProvider(conn, address);
20872
+ return this.provider;
20873
+ };
20874
+ getProvider() {
20875
+ return this.provider;
20876
+ }
20877
+ getOrThrowProvider() {
20878
+ if (!this.provider) {
20879
+ throw new Error("Solana wallet not connected");
20880
+ }
20881
+ return this.provider;
20882
+ }
20883
+ isConnected() {
20884
+ return this.provider != null;
20885
+ }
20886
+ }
20887
+
20888
+ class SolanaProvider {
20889
+ connection;
20890
+ address;
20891
+ constructor(connection, address) {
20892
+ this.connection = connection;
20893
+ this.address = address;
20894
+ }
20895
+ getConnection() {
20896
+ return this.connection;
20897
+ }
20898
+ async signMessage(message) {
20899
+ const encoded = new TextEncoder().encode(message);
20900
+ const { signature } = await this.connection.api.signMessage(encoded);
20901
+ return Buffer.from(signature).toString("base64");
20902
+ }
20903
+ getAddress() {
20904
+ return {
20905
+ type: 9 /* SOLANA */,
20906
+ address: this.address
20907
+ };
20908
+ }
20909
+ async signTransaction(txBase64) {
20910
+ if (!this.connection.api.signTransaction) {
20911
+ throw new Error("Wallet does not support signTransaction");
20912
+ }
20913
+ const tx = Transaction.from(Buffer.from(txBase64, "base64"));
20914
+ const signed = await this.connection.api.signTransaction(tx);
20915
+ return serializeSignedTx(signed);
20916
+ }
20917
+ }
20918
+ function serializeSignedTx(signed) {
20919
+ if (signed != null && typeof signed.serialize === "function") {
20920
+ const bytes = signed.serialize({
20921
+ requireAllSignatures: false,
20922
+ verifySignatures: false
20923
+ });
20924
+ return Buffer.from(bytes).toString("base64");
20925
+ }
20926
+ if (signed instanceof Uint8Array) {
20927
+ return Buffer.from(signed).toString("base64");
20928
+ }
20929
+ throw new Error("Wallet returned an unrecognised signTransaction result (expected a Transaction or bytes)");
20930
+ }
20931
+ function isSolanaStandardWallet(wallet) {
20932
+ const features = wallet?.features ?? {};
20933
+ return Boolean(features[STANDARD_CONNECT] && features[SOLANA_SIGN_MESSAGE]);
20934
+ }
20935
+ function pickSolanaChain(account, wallet) {
20936
+ const chains = account?.chains ?? wallet?.chains ?? [];
20937
+ return chains.find((c) => typeof c === "string" && c.startsWith("solana:"));
20938
+ }
20939
+
20940
+ class WalletStandardSolanaApi {
20941
+ wallet;
20942
+ isConnected = false;
20943
+ account;
20944
+ constructor(wallet) {
20945
+ this.wallet = wallet;
20946
+ }
20947
+ get publicKey() {
20948
+ const address = this.account?.address ?? "";
20949
+ return { toBase58: () => address };
20950
+ }
20951
+ async connect() {
20952
+ if (!this.account) {
20953
+ const result = await this.wallet.features[STANDARD_CONNECT].connect();
20954
+ this.account = (result?.accounts ?? this.wallet.accounts ?? [])[0];
20955
+ }
20956
+ if (!this.account) {
20957
+ throw new Error("Wallet returned no Solana account");
20958
+ }
20959
+ this.isConnected = true;
20960
+ }
20961
+ async disconnect() {
20962
+ const feature = this.wallet.features[STANDARD_DISCONNECT];
20963
+ if (feature?.disconnect) {
20964
+ await feature.disconnect();
20965
+ }
20966
+ this.account = undefined;
20967
+ this.isConnected = false;
20968
+ }
20969
+ async signMessage(message) {
20970
+ const feature = this.wallet.features[SOLANA_SIGN_MESSAGE];
20971
+ if (!feature) {
20972
+ throw new Error("Wallet does not support solana:signMessage");
20973
+ }
20974
+ const [output] = await feature.signMessage({
20975
+ account: this.account,
20976
+ message
20977
+ });
20978
+ return { signature: output.signature };
20979
+ }
20980
+ async signTransaction(tx) {
20981
+ const feature = this.wallet.features[SOLANA_SIGN_TRANSACTION];
20982
+ if (!feature) {
20983
+ throw new Error("Wallet does not support solana:signTransaction. The batcher flow " + "needs a sign-only signature, which this wallet does not provide.");
20984
+ }
20985
+ const asObject = tx != null && typeof tx.serialize === "function";
20986
+ const bytes = asObject ? tx.serialize({
20987
+ requireAllSignatures: false,
20988
+ verifySignatures: false
20989
+ }) : tx;
20990
+ const chain = pickSolanaChain(this.account, this.wallet);
20991
+ const [output] = await feature.signTransaction({
20992
+ account: this.account,
20993
+ transaction: Uint8Array.from(bytes),
20994
+ ...chain ? { chain } : {}
20995
+ });
20996
+ const signed = output.signedTransaction;
20997
+ return asObject ? { serialize: () => signed } : signed;
20998
+ }
20999
+ }
21000
+
20711
21001
  // ../effectstream-sdk/wallets/src/utils.ts
20712
21002
  var WalletMode;
20713
21003
  ((WalletMode2) => {
@@ -20722,6 +21012,7 @@ var WalletMode;
20722
21012
  WalletMode2[WalletMode2["Algorand"] = 8] = "Algorand";
20723
21013
  WalletMode2[WalletMode2["Mina"] = 9] = "Mina";
20724
21014
  WalletMode2[WalletMode2["AvailJs"] = 10] = "AvailJs";
21015
+ WalletMode2[WalletMode2["Solana"] = 11] = "Solana";
20725
21016
  })(WalletMode ||= {});
20726
21017
  var WalletNameMap = {
20727
21018
  [0 /* EvmInjected */]: "EVM",
@@ -20734,7 +21025,8 @@ var WalletNameMap = {
20734
21025
  [7 /* Polkadot */]: "Polkadot",
20735
21026
  [8 /* Algorand */]: "Algorand",
20736
21027
  [9 /* Mina */]: "Mina",
20737
- [10 /* AvailJs */]: "Avail"
21028
+ [10 /* AvailJs */]: "Avail",
21029
+ [11 /* Solana */]: "Solana"
20738
21030
  };
20739
21031
  var WalletModeMap = {
20740
21032
  [0 /* EvmInjected */]: EvmInjectedConnector.instance(),
@@ -20747,7 +21039,8 @@ var WalletModeMap = {
20747
21039
  [7 /* Polkadot */]: PolkadotConnector.instance(),
20748
21040
  [8 /* Algorand */]: AlgorandConnector.instance(),
20749
21041
  [9 /* Mina */]: MinaConnector.instance(),
20750
- [10 /* AvailJs */]: AvailConnector.instance()
21042
+ [10 /* AvailJs */]: AvailConnector.instance(),
21043
+ [11 /* Solana */]: SolanaConnector.instance()
20751
21044
  };
20752
21045
  async function allInjectedWallets(config = {
20753
21046
  signatureSupport: true,
@@ -20849,8 +21142,8 @@ function getAddressType(mode) {
20849
21142
  return 5 /* MIDNIGHT */;
20850
21143
  case 10 /* AvailJs */:
20851
21144
  return 6 /* AVAIL */;
20852
- case 7 /* Polkadot */:
20853
- return 7 /* POLKADOT */;
21145
+ case 11 /* Solana */:
21146
+ return 9 /* SOLANA */;
20854
21147
  default:
20855
21148
  throw new Error(`Unsupported wallet mode: ${mode}`);
20856
21149
  }
@@ -21080,6 +21373,18 @@ async function midnightLocalLoginWrapper(loginInfo) {
21080
21373
  }
21081
21374
  }
21082
21375
 
21376
+ // ../effectstream-sdk/wallets/src/solana/wrapper.ts
21377
+ async function solanaLoginWrapper(loginInfo) {
21378
+ const loginResult = await connectInjected("solanaLoginWrapper", loginInfo, SolanaConnector.instance());
21379
+ if (loginResult.success === false) {
21380
+ return loginResult;
21381
+ }
21382
+ return {
21383
+ success: true,
21384
+ result: loginResult.result
21385
+ };
21386
+ }
21387
+
21083
21388
  // ../effectstream-sdk/wallets/src/wallets.ts
21084
21389
  async function walletLogin(loginInfo) {
21085
21390
  const provider = await login(loginInfo);
@@ -21129,6 +21434,9 @@ async function login(loginInfo) {
21129
21434
  case 4 /* MidnightLocal */: {
21130
21435
  return await midnightLocalLoginWrapper(loginInfo);
21131
21436
  }
21437
+ case 11 /* Solana */: {
21438
+ return await solanaLoginWrapper(loginInfo);
21439
+ }
21132
21440
  default:
21133
21441
  throw new Error(`Unsupported wallet mode: ${loginInfo.mode}`);
21134
21442
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@effectstream/frontend-sdk",
3
- "version": "0.101.1",
4
- "license": "MIT",
3
+ "version": "0.102.0",
4
+ "license": "(MIT OR Apache-2.0)",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
7
7
  "type": "git",
@@ -15,7 +15,9 @@
15
15
  "dist",
16
16
  "src",
17
17
  "build.ts",
18
- "tsconfig.build.json"
18
+ "tsconfig.build.json",
19
+ "LICENSE-MIT",
20
+ "LICENSE-APACHE"
19
21
  ],
20
22
  "exports": {
21
23
  ".": {
@@ -27,7 +29,7 @@
27
29
  "build": "bun run build.ts"
28
30
  },
29
31
  "dependencies": {
30
- "@effectstream/wallets": "0.101.1"
32
+ "@effectstream/wallets": "0.102.0"
31
33
  },
32
34
  "description": "React frontend SDK for EffectStream"
33
35
  }