@caatinga/client 2.0.0 → 2.0.1

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
@@ -22,7 +22,7 @@ The `@caatinga/client/freighter` subpath is optional and only needed when you wa
22
22
  For multi-wallet support, add Stellar Wallets Kit:
23
23
 
24
24
  ```bash
25
- pnpm add github:Creit-Tech/Stellar-Wallets-Kit#v0.0.7
25
+ pnpm add @creit.tech/stellar-wallets-kit
26
26
  ```
27
27
 
28
28
  ```ts
@@ -20,90 +20,88 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/stellar-wallets-kit.ts
21
21
  var stellar_wallets_kit_exports = {};
22
22
  __export(stellar_wallets_kit_exports, {
23
+ WalletNetwork: () => import_stellar_wallets_kit.WalletNetwork,
23
24
  createStellarWalletsKitAdapter: () => createStellarWalletsKitAdapter
24
25
  });
25
26
  module.exports = __toCommonJS(stellar_wallets_kit_exports);
26
27
 
27
28
  // src/adapters/stellar-wallets-kit.ts
28
- var import_stellar_wallets_kit = require("stellar-wallets-kit");
29
+ var import_stellar_wallets_kit = require("@creit.tech/stellar-wallets-kit");
30
+ var import_walletconnect = require("@creit.tech/stellar-wallets-kit/modules/walletconnect.module");
29
31
  function createStellarWalletsKitAdapter(options = {}) {
32
+ const network = options.network ?? import_stellar_wallets_kit.WalletNetwork.TESTNET;
30
33
  const kit = options.kit ?? new import_stellar_wallets_kit.StellarWalletsKit({
31
- network: options.network ?? import_stellar_wallets_kit.WalletNetwork.TESTNET,
32
- selectedWallet: options.selectedWallet ?? import_stellar_wallets_kit.WalletType.XBULL
34
+ network,
35
+ selectedWalletId: options.selectedWalletId ?? import_stellar_wallets_kit.FREIGHTER_ID,
36
+ modules: options.modules ?? buildModules(network, options.walletConnectMetadata)
33
37
  });
34
- let publicKey;
35
- let isWalletConnectStarted = false;
36
- const sessionDeletedCallbacks = /* @__PURE__ */ new Set();
38
+ let address;
37
39
  return {
38
40
  kit,
39
- async setWallet(wallet) {
40
- await kit.setWallet(wallet);
41
- publicKey = void 0;
41
+ setWallet(walletId) {
42
+ kit.setWallet(walletId);
43
+ address = void 0;
42
44
  },
43
- async setNetwork(network) {
44
- await kit.setNetwork(network);
45
- publicKey = void 0;
45
+ getSupportedWallets() {
46
+ return kit.getSupportedWallets();
46
47
  },
47
- async getPublicKey() {
48
- publicKey = await kit.getPublicKey();
49
- return publicKey;
50
- },
51
- async signTransaction({ xdr, networkPassphrase }) {
52
- const walletNetwork = resolveWalletNetwork(networkPassphrase);
53
- if (walletNetwork) {
54
- await kit.setNetwork(walletNetwork);
55
- }
56
- const signer = publicKey ?? await kit.getPublicKey();
57
- publicKey = signer;
58
- const response = await kit.sign({ xdr, publicKey: signer });
59
- return response.signedXDR;
60
- },
61
- async startWalletConnect(metadata = options.walletConnectMetadata) {
62
- if (!metadata) {
63
- throw new Error("WalletConnect metadata is required before starting WalletConnect.");
64
- }
65
- await kit.startWalletConnect(metadata);
66
- isWalletConnectStarted = true;
67
- for (const callback of sessionDeletedCallbacks) {
68
- kit.onSessionDeleted((sessionId) => {
69
- publicKey = void 0;
70
- callback(sessionId);
48
+ openModal(modalOptions = {}) {
49
+ return new Promise((resolve, reject) => {
50
+ void kit.openModal({
51
+ ...modalOptions.modalTitle ? { modalTitle: modalOptions.modalTitle } : {},
52
+ ...modalOptions.notAvailableText ? { notAvailableText: modalOptions.notAvailableText } : {},
53
+ onWalletSelected: (option) => {
54
+ kit.setWallet(option.id);
55
+ kit.getAddress().then((result) => {
56
+ address = result.address;
57
+ resolve(result.address);
58
+ }).catch((error) => {
59
+ reject(error instanceof Error ? error : new Error(String(error)));
60
+ });
61
+ },
62
+ onClosed: (error) => {
63
+ modalOptions.onClosed?.(error);
64
+ reject(error);
65
+ }
71
66
  });
72
- }
73
- },
74
- async connectWalletConnect(connectOptions) {
75
- await kit.connectWalletConnect(connectOptions);
76
- publicKey = void 0;
77
- },
78
- async getWalletConnectSessions() {
79
- return kit.getSessions();
67
+ });
80
68
  },
81
- setWalletConnectSession(sessionId) {
82
- kit.setSession(sessionId);
83
- publicKey = void 0;
69
+ async getPublicKey() {
70
+ const result = await kit.getAddress();
71
+ address = result.address;
72
+ return result.address;
84
73
  },
85
- onWalletConnectSessionDeleted(callback) {
86
- sessionDeletedCallbacks.add(callback);
87
- if (!isWalletConnectStarted) {
88
- return;
89
- }
90
- kit.onSessionDeleted((sessionId) => {
91
- publicKey = void 0;
92
- callback(sessionId);
74
+ async signTransaction({ xdr, networkPassphrase }) {
75
+ const result = await kit.signTransaction(xdr, {
76
+ networkPassphrase,
77
+ ...address ? { address } : {}
93
78
  });
79
+ return result.signedTxXdr;
80
+ },
81
+ async disconnect() {
82
+ await kit.disconnect();
83
+ address = void 0;
94
84
  }
95
85
  };
96
86
  }
97
- function resolveWalletNetwork(networkPassphrase) {
98
- if (networkPassphrase === "Test SDF Network ; September 2015") {
99
- return import_stellar_wallets_kit.WalletNetwork.TESTNET;
100
- }
101
- if (networkPassphrase === "Public Global Stellar Network ; September 2015") {
102
- return import_stellar_wallets_kit.WalletNetwork.PUBLIC;
87
+ var HOTWALLET_ID = "hot-wallet";
88
+ function buildModules(network, walletConnectMetadata) {
89
+ const modules = (0, import_stellar_wallets_kit.allowAllModules)({
90
+ filterBy: (module2) => module2.productId !== HOTWALLET_ID
91
+ });
92
+ if (walletConnectMetadata) {
93
+ modules.push(
94
+ new import_walletconnect.WalletConnectModule({
95
+ ...walletConnectMetadata,
96
+ network,
97
+ method: import_walletconnect.WalletConnectAllowedMethods.SIGN
98
+ })
99
+ );
103
100
  }
104
- return void 0;
101
+ return modules;
105
102
  }
106
103
  // Annotate the CommonJS export names for ESM import in node:
107
104
  0 && (module.exports = {
105
+ WalletNetwork,
108
106
  createStellarWalletsKitAdapter
109
107
  });
@@ -1,7 +1,12 @@
1
- import { StellarWalletsKit, WalletType, WalletNetwork, IConnectWalletConnectParams } from 'stellar-wallets-kit';
1
+ import { StellarWalletsKit, ISupportedWallet, WalletNetwork, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
2
+ export { WalletNetwork } from '@creit.tech/stellar-wallets-kit';
2
3
  import { C as CaatingaWalletAdapter } from './types-D4XEyX4J.cjs';
3
4
  import '@caatinga/core/browser';
4
5
 
6
+ /**
7
+ * Optional WalletConnect metadata. When provided, a WalletConnect module is
8
+ * registered alongside the auto-detected wallets so it shows up in the modal.
9
+ */
5
10
  interface StellarWalletsKitMetadata {
6
11
  name: string;
7
12
  description: string;
@@ -12,35 +17,29 @@ interface StellarWalletsKitMetadata {
12
17
  interface StellarWalletsKitAdapterOptions {
13
18
  kit?: StellarWalletsKit;
14
19
  network?: WalletNetwork;
15
- selectedWallet?: WalletType;
20
+ /** Wallet pre-selected before the user opens the modal. Defaults to Freighter. */
21
+ selectedWalletId?: string;
22
+ /** Override the registered modules. Defaults to every auto-detectable wallet. */
23
+ modules?: ModuleInterface[];
16
24
  walletConnectMetadata?: StellarWalletsKitMetadata;
17
25
  }
18
- interface StellarWalletsKitConnectOptions {
19
- chains?: IConnectWalletConnectParams["chains"];
20
- methods?: IConnectWalletConnectParams["methods"];
21
- pairingTopic?: IConnectWalletConnectParams["pairingTopic"];
22
- }
23
- interface StellarWalletsKitSession {
24
- id: string;
25
- name: string;
26
- description: string;
27
- url: string;
28
- icons: string;
29
- accounts: Array<{
30
- network: "pubnet" | "testnet";
31
- publicKey: string;
32
- }>;
26
+ interface StellarWalletsKitOpenModalOptions {
27
+ modalTitle?: string;
28
+ notAvailableText?: string;
29
+ onClosed?: (error: Error) => void;
33
30
  }
34
31
  interface StellarWalletsKitAdapter extends CaatingaWalletAdapter {
35
32
  kit: StellarWalletsKit;
36
- setWallet(wallet: WalletType): Promise<void>;
37
- setNetwork(network: WalletNetwork): Promise<void>;
38
- startWalletConnect(metadata?: StellarWalletsKitMetadata): Promise<void>;
39
- connectWalletConnect(options?: StellarWalletsKitConnectOptions): Promise<void>;
40
- getWalletConnectSessions(): Promise<StellarWalletsKitSession[]>;
41
- setWalletConnectSession(sessionId: string): void;
42
- onWalletConnectSessionDeleted(callback: (sessionId: string) => void): void;
33
+ /**
34
+ * Opens the wallet-selection modal (lists only installed/available wallets),
35
+ * sets the chosen wallet as active, and resolves with the connected address.
36
+ * Rejects if the user closes the modal without selecting a wallet.
37
+ */
38
+ openModal(options?: StellarWalletsKitOpenModalOptions): Promise<string>;
39
+ setWallet(walletId: string): void;
40
+ getSupportedWallets(): Promise<ISupportedWallet[]>;
41
+ disconnect(): Promise<void>;
43
42
  }
44
43
  declare function createStellarWalletsKitAdapter(options?: StellarWalletsKitAdapterOptions): StellarWalletsKitAdapter;
45
44
 
46
- export { type StellarWalletsKitAdapter, type StellarWalletsKitAdapterOptions, type StellarWalletsKitConnectOptions, type StellarWalletsKitMetadata, type StellarWalletsKitSession, createStellarWalletsKitAdapter };
45
+ export { type StellarWalletsKitAdapter, type StellarWalletsKitAdapterOptions, type StellarWalletsKitMetadata, type StellarWalletsKitOpenModalOptions, createStellarWalletsKitAdapter };
@@ -1,7 +1,12 @@
1
- import { StellarWalletsKit, WalletType, WalletNetwork, IConnectWalletConnectParams } from 'stellar-wallets-kit';
1
+ import { StellarWalletsKit, ISupportedWallet, WalletNetwork, ModuleInterface } from '@creit.tech/stellar-wallets-kit';
2
+ export { WalletNetwork } from '@creit.tech/stellar-wallets-kit';
2
3
  import { C as CaatingaWalletAdapter } from './types-D4XEyX4J.js';
3
4
  import '@caatinga/core/browser';
4
5
 
6
+ /**
7
+ * Optional WalletConnect metadata. When provided, a WalletConnect module is
8
+ * registered alongside the auto-detected wallets so it shows up in the modal.
9
+ */
5
10
  interface StellarWalletsKitMetadata {
6
11
  name: string;
7
12
  description: string;
@@ -12,35 +17,29 @@ interface StellarWalletsKitMetadata {
12
17
  interface StellarWalletsKitAdapterOptions {
13
18
  kit?: StellarWalletsKit;
14
19
  network?: WalletNetwork;
15
- selectedWallet?: WalletType;
20
+ /** Wallet pre-selected before the user opens the modal. Defaults to Freighter. */
21
+ selectedWalletId?: string;
22
+ /** Override the registered modules. Defaults to every auto-detectable wallet. */
23
+ modules?: ModuleInterface[];
16
24
  walletConnectMetadata?: StellarWalletsKitMetadata;
17
25
  }
18
- interface StellarWalletsKitConnectOptions {
19
- chains?: IConnectWalletConnectParams["chains"];
20
- methods?: IConnectWalletConnectParams["methods"];
21
- pairingTopic?: IConnectWalletConnectParams["pairingTopic"];
22
- }
23
- interface StellarWalletsKitSession {
24
- id: string;
25
- name: string;
26
- description: string;
27
- url: string;
28
- icons: string;
29
- accounts: Array<{
30
- network: "pubnet" | "testnet";
31
- publicKey: string;
32
- }>;
26
+ interface StellarWalletsKitOpenModalOptions {
27
+ modalTitle?: string;
28
+ notAvailableText?: string;
29
+ onClosed?: (error: Error) => void;
33
30
  }
34
31
  interface StellarWalletsKitAdapter extends CaatingaWalletAdapter {
35
32
  kit: StellarWalletsKit;
36
- setWallet(wallet: WalletType): Promise<void>;
37
- setNetwork(network: WalletNetwork): Promise<void>;
38
- startWalletConnect(metadata?: StellarWalletsKitMetadata): Promise<void>;
39
- connectWalletConnect(options?: StellarWalletsKitConnectOptions): Promise<void>;
40
- getWalletConnectSessions(): Promise<StellarWalletsKitSession[]>;
41
- setWalletConnectSession(sessionId: string): void;
42
- onWalletConnectSessionDeleted(callback: (sessionId: string) => void): void;
33
+ /**
34
+ * Opens the wallet-selection modal (lists only installed/available wallets),
35
+ * sets the chosen wallet as active, and resolves with the connected address.
36
+ * Rejects if the user closes the modal without selecting a wallet.
37
+ */
38
+ openModal(options?: StellarWalletsKitOpenModalOptions): Promise<string>;
39
+ setWallet(walletId: string): void;
40
+ getSupportedWallets(): Promise<ISupportedWallet[]>;
41
+ disconnect(): Promise<void>;
43
42
  }
44
43
  declare function createStellarWalletsKitAdapter(options?: StellarWalletsKitAdapterOptions): StellarWalletsKitAdapter;
45
44
 
46
- export { type StellarWalletsKitAdapter, type StellarWalletsKitAdapterOptions, type StellarWalletsKitConnectOptions, type StellarWalletsKitMetadata, type StellarWalletsKitSession, createStellarWalletsKitAdapter };
45
+ export { type StellarWalletsKitAdapter, type StellarWalletsKitAdapterOptions, type StellarWalletsKitMetadata, type StellarWalletsKitOpenModalOptions, createStellarWalletsKitAdapter };
@@ -2,85 +2,86 @@
2
2
  import {
3
3
  StellarWalletsKit,
4
4
  WalletNetwork,
5
- WalletType
6
- } from "stellar-wallets-kit";
5
+ allowAllModules,
6
+ FREIGHTER_ID
7
+ } from "@creit.tech/stellar-wallets-kit";
8
+ import {
9
+ WalletConnectAllowedMethods,
10
+ WalletConnectModule
11
+ } from "@creit.tech/stellar-wallets-kit/modules/walletconnect.module";
7
12
  function createStellarWalletsKitAdapter(options = {}) {
13
+ const network = options.network ?? WalletNetwork.TESTNET;
8
14
  const kit = options.kit ?? new StellarWalletsKit({
9
- network: options.network ?? WalletNetwork.TESTNET,
10
- selectedWallet: options.selectedWallet ?? WalletType.XBULL
15
+ network,
16
+ selectedWalletId: options.selectedWalletId ?? FREIGHTER_ID,
17
+ modules: options.modules ?? buildModules(network, options.walletConnectMetadata)
11
18
  });
12
- let publicKey;
13
- let isWalletConnectStarted = false;
14
- const sessionDeletedCallbacks = /* @__PURE__ */ new Set();
19
+ let address;
15
20
  return {
16
21
  kit,
17
- async setWallet(wallet) {
18
- await kit.setWallet(wallet);
19
- publicKey = void 0;
20
- },
21
- async setNetwork(network) {
22
- await kit.setNetwork(network);
23
- publicKey = void 0;
22
+ setWallet(walletId) {
23
+ kit.setWallet(walletId);
24
+ address = void 0;
24
25
  },
25
- async getPublicKey() {
26
- publicKey = await kit.getPublicKey();
27
- return publicKey;
26
+ getSupportedWallets() {
27
+ return kit.getSupportedWallets();
28
28
  },
29
- async signTransaction({ xdr, networkPassphrase }) {
30
- const walletNetwork = resolveWalletNetwork(networkPassphrase);
31
- if (walletNetwork) {
32
- await kit.setNetwork(walletNetwork);
33
- }
34
- const signer = publicKey ?? await kit.getPublicKey();
35
- publicKey = signer;
36
- const response = await kit.sign({ xdr, publicKey: signer });
37
- return response.signedXDR;
38
- },
39
- async startWalletConnect(metadata = options.walletConnectMetadata) {
40
- if (!metadata) {
41
- throw new Error("WalletConnect metadata is required before starting WalletConnect.");
42
- }
43
- await kit.startWalletConnect(metadata);
44
- isWalletConnectStarted = true;
45
- for (const callback of sessionDeletedCallbacks) {
46
- kit.onSessionDeleted((sessionId) => {
47
- publicKey = void 0;
48
- callback(sessionId);
29
+ openModal(modalOptions = {}) {
30
+ return new Promise((resolve, reject) => {
31
+ void kit.openModal({
32
+ ...modalOptions.modalTitle ? { modalTitle: modalOptions.modalTitle } : {},
33
+ ...modalOptions.notAvailableText ? { notAvailableText: modalOptions.notAvailableText } : {},
34
+ onWalletSelected: (option) => {
35
+ kit.setWallet(option.id);
36
+ kit.getAddress().then((result) => {
37
+ address = result.address;
38
+ resolve(result.address);
39
+ }).catch((error) => {
40
+ reject(error instanceof Error ? error : new Error(String(error)));
41
+ });
42
+ },
43
+ onClosed: (error) => {
44
+ modalOptions.onClosed?.(error);
45
+ reject(error);
46
+ }
49
47
  });
50
- }
51
- },
52
- async connectWalletConnect(connectOptions) {
53
- await kit.connectWalletConnect(connectOptions);
54
- publicKey = void 0;
55
- },
56
- async getWalletConnectSessions() {
57
- return kit.getSessions();
48
+ });
58
49
  },
59
- setWalletConnectSession(sessionId) {
60
- kit.setSession(sessionId);
61
- publicKey = void 0;
50
+ async getPublicKey() {
51
+ const result = await kit.getAddress();
52
+ address = result.address;
53
+ return result.address;
62
54
  },
63
- onWalletConnectSessionDeleted(callback) {
64
- sessionDeletedCallbacks.add(callback);
65
- if (!isWalletConnectStarted) {
66
- return;
67
- }
68
- kit.onSessionDeleted((sessionId) => {
69
- publicKey = void 0;
70
- callback(sessionId);
55
+ async signTransaction({ xdr, networkPassphrase }) {
56
+ const result = await kit.signTransaction(xdr, {
57
+ networkPassphrase,
58
+ ...address ? { address } : {}
71
59
  });
60
+ return result.signedTxXdr;
61
+ },
62
+ async disconnect() {
63
+ await kit.disconnect();
64
+ address = void 0;
72
65
  }
73
66
  };
74
67
  }
75
- function resolveWalletNetwork(networkPassphrase) {
76
- if (networkPassphrase === "Test SDF Network ; September 2015") {
77
- return WalletNetwork.TESTNET;
78
- }
79
- if (networkPassphrase === "Public Global Stellar Network ; September 2015") {
80
- return WalletNetwork.PUBLIC;
68
+ var HOTWALLET_ID = "hot-wallet";
69
+ function buildModules(network, walletConnectMetadata) {
70
+ const modules = allowAllModules({
71
+ filterBy: (module) => module.productId !== HOTWALLET_ID
72
+ });
73
+ if (walletConnectMetadata) {
74
+ modules.push(
75
+ new WalletConnectModule({
76
+ ...walletConnectMetadata,
77
+ network,
78
+ method: WalletConnectAllowedMethods.SIGN
79
+ })
80
+ );
81
81
  }
82
- return void 0;
82
+ return modules;
83
83
  }
84
84
  export {
85
+ WalletNetwork,
85
86
  createStellarWalletsKitAdapter
86
87
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caatinga/client",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Browser and Node client for Soroban smart contracts — connects generated bindings, Caatinga artifacts, and wallet adapters",
5
5
  "keywords": [
6
6
  "stellar",
@@ -51,23 +51,23 @@
51
51
  "LICENSE"
52
52
  ],
53
53
  "dependencies": {
54
- "@caatinga/core": "^2.0.0"
54
+ "@caatinga/core": "^2.0.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "tsup": "^8.3.5",
58
- "stellar-wallets-kit": "github:Creit-Tech/Stellar-Wallets-Kit#v0.0.7",
58
+ "@creit.tech/stellar-wallets-kit": "^1.9.5",
59
59
  "typescript": "^5.7.2",
60
60
  "vitest": "^2.1.8"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@stellar/freighter-api": "^4.0.0",
64
- "stellar-wallets-kit": "github:Creit-Tech/Stellar-Wallets-Kit#v0.0.7"
64
+ "@creit.tech/stellar-wallets-kit": "^1.9.5"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@stellar/freighter-api": {
68
68
  "optional": true
69
69
  },
70
- "stellar-wallets-kit": {
70
+ "@creit.tech/stellar-wallets-kit": {
71
71
  "optional": true
72
72
  }
73
73
  },