@wuwei-labs/srsly 2.0.0-beta.44 → 2.0.0-beta.46

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
@@ -80,13 +80,37 @@ const signature = await wallet.sendTransaction(transaction, connection);
80
80
 
81
81
  ## Core Features
82
82
 
83
+ ### Universal Signer Pattern
84
+
85
+ The SDK supports both CLI/Node.js and browser usage patterns through its Universal Signer functionality:
86
+
87
+ **Browser Usage** (String Addresses):
88
+ ```typescript
89
+ // Pass string addresses for browser wallets
90
+ const instruction = await acceptRental({
91
+ borrower: wallet.publicKey.toString(), // String address
92
+ // ... other params
93
+ });
94
+ // Browser wallet handles signing separately
95
+ ```
96
+
97
+ **CLI/Node.js Usage** (Signer Objects):
98
+ ```typescript
99
+ // Pass signer objects for full signing capability
100
+ const instruction = await acceptRental({
101
+ borrower: wallet, // Signer object
102
+ // ... other params
103
+ });
104
+ // Can sign transactions directly
105
+ ```
106
+
83
107
  ### Instruction Building & Format Conversion
84
108
 
85
109
  The SDK creates @solana/kit compatible instructions with seamless web3.js conversion:
86
110
 
87
111
  - **📦 Instruction-Only**: Focus on instruction building, users handle transaction assembly/sending
88
112
  - **🔄 Format Conversion**: Built-in `.web3js(PublicKey)` method for wallet compatibility
89
- - **🎯 String Addresses**: Simple string-based addressing for all inputs
113
+ - **🎯 Universal Signer**: Accepts both string addresses and signer objects
90
114
  - **⚡ Lightweight**: Uses @solana/kit internally with optional web3.js conversion
91
115
 
92
116
  ### Web3.js Format Conversion
@@ -464,3 +488,5 @@ The SDK provides optimized builds for different environments:
464
488
 
465
489
  - **NPM Package**: [@wuwei-labs/srsly](https://www.npmjs.com/package/@wuwei-labs/srsly)
466
490
  - **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
491
+ - **Browser Usage Examples**: [Browser Integration Guide](./examples/browser-usage.md)
492
+ - **Universal Signer Tests**: [Test Examples](./tests/features/universal-signer.test.mjs)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuwei-labs/srsly",
3
- "version": "2.0.0-beta.44",
3
+ "version": "2.0.0-beta.46",
4
4
  "description": "",
5
5
  "source": "./src/index.ts",
6
6
  "sideEffects": false,
@@ -9,6 +9,7 @@ const instruction_converter_1 = require("../utils/instruction-converter");
9
9
  const fetch_accounts_1 = require("../utils/fetch-accounts");
10
10
  const paymentFrequency_1 = require("../utils/paymentFrequency");
11
11
  const pda_1 = require("../utils/pda");
12
+ const signer_1 = require("../utils/signer");
12
13
  /**
13
14
  * Internal function to accept a rental instruction with configuration options.
14
15
  *
@@ -24,7 +25,7 @@ const pda_1 = require("../utils/pda");
24
25
  * @throws Error when contract is not found, duration constraints are violated, or account derivation fails
25
26
  */
26
27
  async function _acceptRental(params, config) {
27
- const { borrower, borrowerProfile, borrowerFaction, contract, duration, } = params;
28
+ const { borrowerProfile, borrowerFaction, contract, duration, } = params;
28
29
  // Get the resolved addresses from config (including network-specific addresses)
29
30
  // Use global config as fallback, same pattern as constants.ts
30
31
  const globalConfig = (0, config_1.getConfig)();
@@ -33,7 +34,7 @@ async function _acceptRental(params, config) {
33
34
  // Fetch contract state to get payment frequency and validate parameters
34
35
  let contractState;
35
36
  try {
36
- contractState = await (0, fetch_accounts_1.fetchContractState)(resolvedAddresses.rpcUrl, (0, constants_1.toAddress)(contract));
37
+ contractState = await (0, fetch_accounts_1.fetchContractState)(contract);
37
38
  }
38
39
  catch (error) {
39
40
  throw new Error(`Failed to fetch contract state: ${error}`);
@@ -57,15 +58,17 @@ async function _acceptRental(params, config) {
57
58
  // Manually derive ALL game accounts - they all use different program addresses than main SAGE program
58
59
  const { profileFaction, starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)((0, constants_1.toAddress)(borrowerProfile), borrowerFaction, resolvedAddresses.gameId, 0, // starbaseSeqId
59
60
  config);
61
+ // Handle borrower using smart signer handler for universal compatibility
62
+ const borrower = (0, signer_1.createTransactionSigner)(params.borrower);
60
63
  // Manually derive PDAs with correct program IDs
61
- const rentalStatePda = await (0, pda_1.deriveRentalState)((0, constants_1.toAddress)(contract), borrower.address, // Extract address from signer
64
+ const rentalStatePda = await (0, pda_1.deriveRentalState)((0, constants_1.toAddress)(contract), borrower.address, // Use TransactionSigner.address for PDA derivation
62
65
  resolvedAddresses.srslyProgramAddress);
63
66
  const rentalAuthorityPda = await (0, pda_1.deriveRentalAuthority)(resolvedAddresses.srslyProgramAddress);
64
67
  // 🔧 FIX: Derive rental thread PDA using Antegen program ID
65
68
  const rentalThreadPda = await (0, pda_1.deriveRentalThread)(rentalAuthorityPda, rentalStatePda, resolvedAddresses.antegenProgramAddress);
66
69
  // Create input with ALL manually derived game accounts - they use different program addresses
67
70
  const input = {
68
- borrower: borrower, // Pass signer directly to Codama
71
+ borrower: borrower, // TransactionSigner for Codama
69
72
  borrowerProfile: (0, constants_1.toAddress)(borrowerProfile), // Ensure string
70
73
  borrowerProfileFaction: (0, constants_1.toAddress)(profileFaction), // Manually derived (Profile program)
71
74
  fleet: (0, constants_1.toAddress)(fleet), // Ensure string
@@ -138,27 +141,36 @@ async function _acceptRental(params, config) {
138
141
  * ```typescript
139
142
  * import { acceptRental, days } from '@srsly/sdk';
140
143
  *
141
- * // Basic rental acceptance
144
+ * // CLI usage with wallet/signer object
142
145
  * const instruction = await acceptRental({
143
- * borrower: wallet, // Borrower's wallet
144
- * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
145
- * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
146
- * contract: "ContractAddr...", // Contract to accept
147
- * duration: days(7) // 7 days rental duration
146
+ * borrower: wallet, // Wallet object for signing
147
+ * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
148
+ * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
149
+ * contract: "ContractAddr...", // Contract to accept
150
+ * duration: days(7) // 7 days rental duration
148
151
  * });
149
152
  *
150
- * // Configure for mainnet
153
+ * // Browser usage with address string
154
+ * const browserInstruction = await acceptRental({
155
+ * borrower: wallet.publicKey.toString(), // Address string for browser
156
+ * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
157
+ * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
158
+ * contract: "ContractAddr...", // Contract to accept
159
+ * duration: days(7) // 7 days rental duration
160
+ * });
161
+ *
162
+ * // Configure for mainnet (both patterns work)
151
163
  * const mainnetInstruction = await acceptRental({
152
- * borrower: wallet,
164
+ * borrower: wallet, // Wallet object (CLI style)
153
165
  * borrowerProfile: "ProfileAddr...",
154
- * borrowerFaction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
166
+ * borrowerFaction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
155
167
  * contract: "ContractAddr...",
156
168
  * duration: days(7)
157
169
  * }).set({ programs: 'mainnet' });
158
170
  *
159
171
  * // Override specific game configuration
160
172
  * const customInstruction = await acceptRental({
161
- * borrower: wallet,
173
+ * borrower: "BorrowerAddress123...", // Address string (browser style)
162
174
  * borrowerProfile: "ProfileAddr...",
163
175
  * borrowerFaction: 'mud',
164
176
  * contract: "ContractAddr...",
@@ -170,7 +182,7 @@ async function _acceptRental(params, config) {
170
182
  *
171
183
  * // Convert to @solana/web3.js format
172
184
  * const web3jsInstruction = await acceptRental({
173
- * borrower: wallet,
185
+ * borrower: wallet, // Universal: works with both patterns
174
186
  * borrowerProfile: "ProfileAddr...",
175
187
  * borrowerFaction: 'mud',
176
188
  * contract: "ContractAddr...",
@@ -1 +1 @@
1
- {"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":";;AA+RA,oCAKC;AAcD,0EAKC;AAvTD,4CAA+I;AAC/I,kDAAkE;AAClE,oCAA8C;AAC9C,0EAAkK;AAClK,4DAA6D;AAC7D,gEAA4E;AAC5E,sCAA4F;AAyD5F;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAA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EAAE,+BAA+B,EAAE,GAAG,kBAAkB,CAAC;IAE/D,MAAM,cAAc,GAAG,MAAM,+BAA+B,CAC1D,KAAY,EACZ,EAAE,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,EAAE,CAC1D,CAAC;IACF,OAAO,IAAA,+CAAuB,EAAC,cAAc,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,SAAgB,YAAY,CAC1B,MAA0B;IAE1B,MAAM,YAAY,GAAG,IAAA,6BAAoB,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrF,OAAO,IAAA,uDAA+B,EAAC,YAAY,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,IAAA,6BAAoB,EAAC,KAAK,IAAI,EAAE;QACrC,MAAM,kBAAkB,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -4,6 +4,7 @@ exports.cancelRental = cancelRental;
4
4
  exports.getCancelRentalInstructionAsync = getCancelRentalInstructionAsync;
5
5
  const config_1 = require("../utils/config");
6
6
  const constants_1 = require("../utils/constants");
7
+ const signer_1 = require("../utils/signer");
7
8
  /**
8
9
  * Internal function to cancel a rental instruction with configuration options.
9
10
  *
@@ -18,13 +19,15 @@ const constants_1 = require("../utils/constants");
18
19
  * @throws Error when instruction generation fails or required parameters are missing
19
20
  */
20
21
  async function _cancelRental(params, config) {
21
- const { borrower, contract, } = params;
22
+ const { contract, } = params;
23
+ // Handle borrower using smart signer handler for universal compatibility
24
+ const borrower = (0, signer_1.createTransactionSigner)(params.borrower);
22
25
  // Get the resolved addresses from config (including network-specific addresses)
23
26
  // Note: resolvedAddresses not currently needed for this instruction but kept for consistency
24
27
  // const resolvedAddresses = resolveProgramAddresses(config || {});
25
28
  // Let codama derive all the optional accounts
26
29
  const input = {
27
- borrower, // Pass signer directly to Codama
30
+ borrower: borrower, // TransactionSigner for Codama
28
31
  contract: (0, constants_1.toAddress)(contract), // Ensure string
29
32
  };
30
33
  // Get network-specific codama functions from centralized config
@@ -1 +1 @@
1
- {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":";;AAiJA,oCAIC;AAcD,0EAKC;AAxKD,4CAAoI;AACpI,kDAA+C;AA+B/C;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,gFAAgF;IAChF,6FAA6F;IAC7F,mEAAmE;IAEnE,8CAA8C;IAC9C,MAAM,KAAK,GAAG;QACZ,QAAQ,EAAqB,iCAAiC;QAC9D,QAAQ,EAAE,IAAA,qBAAS,EAAC,QAAQ,CAAC,EAAE,gBAAgB;KAChD,CAAC;IAEF,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,IAAA,kBAAS,EAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,EAAE,+BAA+B,EAAE,GAAG,kBAAkB,CAAC;IAC/D,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,OAAO,+BAA+B,CACpC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC;IAC/D,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,OAAO,+BAA+B,CACpC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,SAAgB,YAAY,CAC1B,MAA0B;IAE1B,OAAO,IAAA,6BAAoB,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,IAAA,6BAAoB,EAAC,KAAK,IAAI,EAAE;QACrC,MAAM,kBAAkB,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -6,57 +6,39 @@ exports.fetchMultipleContractStates = fetchMultipleContractStates;
6
6
  exports.fetchMultipleRentalStates = fetchMultipleRentalStates;
7
7
  const kit_1 = require("@solana/kit");
8
8
  const accounts_1 = require("../codama/accounts");
9
- /**
10
- * Convenience wrapper functions for fetching account states with RPC URL strings.
11
- * These functions handle creating the RPC connection for you.
12
- */
13
- /**
14
- * Fetches contract state data from the blockchain using a simple RPC URL
15
- *
16
- * @param rpcUrl - The RPC endpoint URL as a string
17
- * @param contractAddress - The contract account address to fetch
18
- * @returns The deserialized contract state data
19
- *
20
- * @example
21
- * ```typescript
22
- * const contractState = await fetchContractState(
23
- * 'https://api.devnet.solana.com',
24
- * 'ContractAddress123...'
25
- * );
26
- *
27
- * console.log('Contract owner:', contractState.data.owner);
28
- * console.log('Contract rate:', contractState.data.rate);
29
- * ```
30
- */
31
- async function fetchContractState(rpcUrl, contractAddress) {
32
- // Create RPC connection
9
+ const config_1 = require("./config");
10
+ const constants_1 = require("./constants");
11
+ // Implementation
12
+ async function fetchContractState(rpcUrlOrAddress, contractAddress) {
13
+ // If only one argument, it's the contract address using default RPC
14
+ if (contractAddress === undefined) {
15
+ const address = (0, constants_1.toAddress)(rpcUrlOrAddress);
16
+ const config = (0, config_1.getConfig)();
17
+ const resolved = await (0, config_1.resolveProgramAddresses)(config);
18
+ const rpc = (0, kit_1.createSolanaRpc)(resolved.rpcUrl);
19
+ return (0, accounts_1.fetchContractState)(rpc, address);
20
+ }
21
+ // If two arguments, first is rpcUrl, second is address
22
+ const rpcUrl = rpcUrlOrAddress;
23
+ const address = (0, constants_1.toAddress)(contractAddress);
33
24
  const rpc = (0, kit_1.createSolanaRpc)(rpcUrl);
34
- // Fetch and return the contract state
35
- return (0, accounts_1.fetchContractState)(rpc, contractAddress);
25
+ return (0, accounts_1.fetchContractState)(rpc, address);
36
26
  }
37
- /**
38
- * Fetches rental state data from the blockchain using a simple RPC URL
39
- *
40
- * @param rpcUrl - The RPC endpoint URL as a string
41
- * @param rentalAddress - The rental account address to fetch
42
- * @returns The deserialized rental state data
43
- *
44
- * @example
45
- * ```typescript
46
- * const rentalState = await fetchRentalState(
47
- * 'https://api.devnet.solana.com',
48
- * 'RentalAddress123...'
49
- * );
50
- *
51
- * console.log('Rental borrower:', rentalState.data.borrower);
52
- * console.log('Rental start:', rentalState.data.start);
53
- * ```
54
- */
55
- async function fetchRentalState(rpcUrl, rentalAddress) {
56
- // Create RPC connection
27
+ // Implementation
28
+ async function fetchRentalState(rpcUrlOrAddress, rentalAddress) {
29
+ // If only one argument, it's the rental address using default RPC
30
+ if (rentalAddress === undefined) {
31
+ const address = (0, constants_1.toAddress)(rpcUrlOrAddress);
32
+ const config = (0, config_1.getConfig)();
33
+ const resolved = await (0, config_1.resolveProgramAddresses)(config);
34
+ const rpc = (0, kit_1.createSolanaRpc)(resolved.rpcUrl);
35
+ return (0, accounts_1.fetchRentalState)(rpc, address);
36
+ }
37
+ // If two arguments, first is rpcUrl, second is address
38
+ const rpcUrl = rpcUrlOrAddress;
39
+ const address = (0, constants_1.toAddress)(rentalAddress);
57
40
  const rpc = (0, kit_1.createSolanaRpc)(rpcUrl);
58
- // Fetch and return the rental state
59
- return (0, accounts_1.fetchRentalState)(rpc, rentalAddress);
41
+ return (0, accounts_1.fetchRentalState)(rpc, address);
60
42
  }
61
43
  /**
62
44
  * Fetches multiple contract states in a single RPC call
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-accounts.js","sourceRoot":"","sources":["../../../src/utils/fetch-accounts.ts"],"names":[],"mappings":";;AA+BA,gDASC;AAoBD,4CASC;AAuBD,kEASC;AAuBD,8DASC;AArID,qCAA4D;AAC5D,iDAK4B;AAE5B;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,eAAkC;IAElC,wBAAwB;IACxB,MAAM,GAAG,GAAG,IAAA,qBAAe,EAAC,MAAM,CAAC,CAAC;IAEpC,sCAAsC;IACtC,OAAO,IAAA,6BAAwB,EAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,aAAgC;IAEhC,wBAAwB;IACxB,MAAM,GAAG,GAAG,IAAA,qBAAe,EAAC,MAAM,CAAC,CAAC;IAEpC,oCAAoC;IACpC,OAAO,IAAA,2BAAsB,EAAC,GAAG,EAAE,aAAa,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,2BAA2B,CAC/C,MAAc,EACd,iBAAsC;IAEtC,wBAAwB;IACxB,MAAM,GAAG,GAAG,IAAA,qBAAe,EAAC,MAAM,CAAC,CAAC;IAEpC,uCAAuC;IACvC,OAAO,IAAA,gCAAqB,EAAC,GAAG,EAAE,i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
  __exportStar(require("./instruction-converter"), exports);
23
23
  __exportStar(require("./fetch-accounts"), exports);
24
24
  __exportStar(require("./pda"), exports);
25
+ __exportStar(require("./signer"), exports);
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,2CAAyB;AACzB,qDAAmC;AACnC,6CAA2B;AAC3B,0DAAwC;AACxC,mDAAiC;AACjC,wCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B;AAC3B,2CAAyB;AACzB,qDAAmC;AACnC,6CAA2B;AAC3B,0DAAwC;AACxC,mDAAiC;AACjC,wCAAsB;AACtB,2CAAyB"}
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ /**
3
+ * Universal signer handling utilities for @solana/kit compatibility
4
+ *
5
+ * This module provides utilities to handle different signer types in a unified way
6
+ * while ensuring compatibility with @solana/kit. Supports string addresses for
7
+ * browser usage and TransactionSigner objects for Node.js usage.
8
+ *
9
+ * Note: web3.js signers (Keypair, etc.) are explicitly not supported.
10
+ * Use address strings or @solana/kit TransactionSigner objects instead.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.InvalidSignerError = void 0;
14
+ exports.validateSigner = validateSigner;
15
+ exports.createTransactionSigner = createTransactionSigner;
16
+ exports.isSignerObject = isSignerObject;
17
+ exports.isAddressString = isAddressString;
18
+ const kit_1 = require("@solana/kit");
19
+ /**
20
+ * Error thrown when an invalid signer type is provided
21
+ */
22
+ class InvalidSignerError extends Error {
23
+ constructor(message) {
24
+ super(message);
25
+ this.name = 'InvalidSignerError';
26
+ }
27
+ }
28
+ exports.InvalidSignerError = InvalidSignerError;
29
+ /**
30
+ * Validates that a signer is compatible with @solana/kit
31
+ *
32
+ * @param signer - The signer to validate
33
+ * @throws {InvalidSignerError} If the signer is not compatible
34
+ */
35
+ function validateSigner(signer) {
36
+ if (typeof signer === 'string') {
37
+ // Validate that the string is a valid Solana address
38
+ try {
39
+ // Use @solana/kit's address() function to validate - it will throw if invalid
40
+ (0, kit_1.address)(signer);
41
+ return;
42
+ }
43
+ catch (error) {
44
+ throw new InvalidSignerError(`Invalid address string: "${signer}". ${error instanceof Error ? error.message : 'Unknown validation error'}\n\n` +
45
+ 'Expected a valid base58-encoded Solana address (32-44 characters).\n' +
46
+ 'Examples:\n' +
47
+ ' - "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"\n' +
48
+ ' - "So11111111111111111111111111111111111111112"');
49
+ }
50
+ }
51
+ if (signer && typeof signer === 'object') {
52
+ const signerObj = signer;
53
+ // Check for web3.js Keypair or similar patterns
54
+ if ('publicKey' in signerObj) {
55
+ throw new InvalidSignerError('web3.js signers (Keypair, etc.) are not supported. ' +
56
+ 'Use a base58 address string or TransactionSigner from @solana/kit instead.\n\n' +
57
+ 'Examples:\n' +
58
+ ' - Browser: "base58AddressString"\n' +
59
+ ' - Node.js: createNoopSigner(address("base58AddressString"))');
60
+ }
61
+ // Check for valid @solana/kit signer patterns
62
+ if ('address' in signerObj || typeof signerObj.signTransactions === 'function') {
63
+ // If it has an address property, validate that the address is valid
64
+ if ('address' in signerObj) {
65
+ try {
66
+ // Ensure the address property is a valid Address type
67
+ if (!(0, kit_1.isAddress)(signerObj.address)) {
68
+ throw new InvalidSignerError(`Signer object has invalid address property. Expected Address type from @solana/kit.`);
69
+ }
70
+ }
71
+ catch (error) {
72
+ throw new InvalidSignerError(`Signer object has invalid address property: ${error instanceof Error ? error.message : 'Unknown validation error'}`);
73
+ }
74
+ }
75
+ return;
76
+ }
77
+ // Unknown signer object format
78
+ throw new InvalidSignerError('Invalid signer format. Expected:\n' +
79
+ ' - base58 address string (browser usage)\n' +
80
+ ' - TransactionSigner from @solana/kit (Node.js usage)\n' +
81
+ ' - Object with address property');
82
+ }
83
+ throw new InvalidSignerError('Signer must be a string address or compatible signer object');
84
+ }
85
+ /**
86
+ * Creates TransactionSigner from UniversalSigner input with validation
87
+ *
88
+ * This function provides universal compatibility by:
89
+ * - Validating the signer is compatible with @solana/kit
90
+ * - Converting string addresses to TransactionSigner using createNoopSigner
91
+ * - Passing through existing TransactionSigner objects unchanged
92
+ *
93
+ * The returned TransactionSigner has both .address property and signing capability,
94
+ * making it suitable for both PDA derivation and codama instruction building.
95
+ *
96
+ * @param signer - The signer input (string address or @solana/kit compatible signer)
97
+ * @returns TransactionSigner that can be used directly for codama and has .address property
98
+ * @throws {InvalidSignerError} If the signer is not compatible (e.g., web3.js Keypair)
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * // Browser usage with string address
103
+ * const borrower = createTransactionSigner("base58AddressString");
104
+ * // borrower.address → Address object for PDA derivation
105
+ * // borrower → TransactionSigner for codama
106
+ *
107
+ * // Node.js usage with TransactionSigner
108
+ * const borrower = createTransactionSigner(wallet);
109
+ * // borrower.address → wallet.address for PDA derivation
110
+ * // borrower → wallet signer for codama
111
+ *
112
+ * // This will throw an error:
113
+ * // createTransactionSigner(keypair); // InvalidSignerError: web3.js signers not supported
114
+ * ```
115
+ */
116
+ function createTransactionSigner(signer) {
117
+ // Validate the signer first
118
+ validateSigner(signer);
119
+ // Handle string address case (browser usage)
120
+ if (typeof signer === 'string') {
121
+ return (0, kit_1.createNoopSigner)((0, kit_1.address)(signer)); // Returns TransactionSigner with .address property
122
+ }
123
+ // Handle signer object cases (already validated TransactionSigner objects)
124
+ return signer;
125
+ }
126
+ /**
127
+ * Type guard to check if a value is a signer object (not a string)
128
+ */
129
+ function isSignerObject(signer) {
130
+ return typeof signer !== 'string';
131
+ }
132
+ /**
133
+ * Type guard to check if a value is an address string
134
+ */
135
+ function isAddressString(signer) {
136
+ return typeof signer === 'string';
137
+ }
138
+ //# sourceMappingURL=signer.js.map
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wuwei-labs/srsly",
3
- "version": "2.0.0-beta.44",
3
+ "version": "2.0.0-beta.46",
4
4
  "description": "",
5
5
  "source": "./src/index.ts",
6
6
  "sideEffects": false,
@@ -5,6 +5,7 @@ import { createFluentInstruction, createSmartFluentConfigSelector } from '../uti
5
5
  import { fetchContractState } from '../utils/fetch-accounts';
6
6
  import { paymentFrequencyStringToSeconds } from '../utils/paymentFrequency';
7
7
  import { deriveRentalThread, deriveRentalState, deriveRentalAuthority } from '../utils/pda';
8
+ import { createTransactionSigner } from '../utils/signer';
8
9
  /**
9
10
  * Internal function to accept a rental instruction with configuration options.
10
11
  *
@@ -20,7 +21,7 @@ import { deriveRentalThread, deriveRentalState, deriveRentalAuthority } from '..
20
21
  * @throws Error when contract is not found, duration constraints are violated, or account derivation fails
21
22
  */
22
23
  async function _acceptRental(params, config) {
23
- const { borrower, borrowerProfile, borrowerFaction, contract, duration, } = params;
24
+ const { borrowerProfile, borrowerFaction, contract, duration, } = params;
24
25
  // Get the resolved addresses from config (including network-specific addresses)
25
26
  // Use global config as fallback, same pattern as constants.ts
26
27
  const globalConfig = getConfig();
@@ -29,7 +30,7 @@ async function _acceptRental(params, config) {
29
30
  // Fetch contract state to get payment frequency and validate parameters
30
31
  let contractState;
31
32
  try {
32
- contractState = await fetchContractState(resolvedAddresses.rpcUrl, toAddress(contract));
33
+ contractState = await fetchContractState(contract);
33
34
  }
34
35
  catch (error) {
35
36
  throw new Error(`Failed to fetch contract state: ${error}`);
@@ -53,15 +54,17 @@ async function _acceptRental(params, config) {
53
54
  // Manually derive ALL game accounts - they all use different program addresses than main SAGE program
54
55
  const { profileFaction, starbase, starbasePlayer } = await deriveGameAccounts(toAddress(borrowerProfile), borrowerFaction, resolvedAddresses.gameId, 0, // starbaseSeqId
55
56
  config);
57
+ // Handle borrower using smart signer handler for universal compatibility
58
+ const borrower = createTransactionSigner(params.borrower);
56
59
  // Manually derive PDAs with correct program IDs
57
- const rentalStatePda = await deriveRentalState(toAddress(contract), borrower.address, // Extract address from signer
60
+ const rentalStatePda = await deriveRentalState(toAddress(contract), borrower.address, // Use TransactionSigner.address for PDA derivation
58
61
  resolvedAddresses.srslyProgramAddress);
59
62
  const rentalAuthorityPda = await deriveRentalAuthority(resolvedAddresses.srslyProgramAddress);
60
63
  // 🔧 FIX: Derive rental thread PDA using Antegen program ID
61
64
  const rentalThreadPda = await deriveRentalThread(rentalAuthorityPda, rentalStatePda, resolvedAddresses.antegenProgramAddress);
62
65
  // Create input with ALL manually derived game accounts - they use different program addresses
63
66
  const input = {
64
- borrower: borrower, // Pass signer directly to Codama
67
+ borrower: borrower, // TransactionSigner for Codama
65
68
  borrowerProfile: toAddress(borrowerProfile), // Ensure string
66
69
  borrowerProfileFaction: toAddress(profileFaction), // Manually derived (Profile program)
67
70
  fleet: toAddress(fleet), // Ensure string
@@ -134,27 +137,36 @@ async function _acceptRental(params, config) {
134
137
  * ```typescript
135
138
  * import { acceptRental, days } from '@srsly/sdk';
136
139
  *
137
- * // Basic rental acceptance
140
+ * // CLI usage with wallet/signer object
138
141
  * const instruction = await acceptRental({
139
- * borrower: wallet, // Borrower's wallet
140
- * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
141
- * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
142
- * contract: "ContractAddr...", // Contract to accept
143
- * duration: days(7) // 7 days rental duration
142
+ * borrower: wallet, // Wallet object for signing
143
+ * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
144
+ * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
145
+ * contract: "ContractAddr...", // Contract to accept
146
+ * duration: days(7) // 7 days rental duration
144
147
  * });
145
148
  *
146
- * // Configure for mainnet
149
+ * // Browser usage with address string
150
+ * const browserInstruction = await acceptRental({
151
+ * borrower: wallet.publicKey.toString(), // Address string for browser
152
+ * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
153
+ * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
154
+ * contract: "ContractAddr...", // Contract to accept
155
+ * duration: days(7) // 7 days rental duration
156
+ * });
157
+ *
158
+ * // Configure for mainnet (both patterns work)
147
159
  * const mainnetInstruction = await acceptRental({
148
- * borrower: wallet,
160
+ * borrower: wallet, // Wallet object (CLI style)
149
161
  * borrowerProfile: "ProfileAddr...",
150
- * borrowerFaction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
162
+ * borrowerFaction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
151
163
  * contract: "ContractAddr...",
152
164
  * duration: days(7)
153
165
  * }).set({ programs: 'mainnet' });
154
166
  *
155
167
  * // Override specific game configuration
156
168
  * const customInstruction = await acceptRental({
157
- * borrower: wallet,
169
+ * borrower: "BorrowerAddress123...", // Address string (browser style)
158
170
  * borrowerProfile: "ProfileAddr...",
159
171
  * borrowerFaction: 'mud',
160
172
  * contract: "ContractAddr...",
@@ -166,7 +178,7 @@ async function _acceptRental(params, config) {
166
178
  *
167
179
  * // Convert to @solana/web3.js format
168
180
  * const web3jsInstruction = await acceptRental({
169
- * borrower: wallet,
181
+ * borrower: wallet, // Universal: works with both patterns
170
182
  * borrowerProfile: "ProfileAddr...",
171
183
  * borrowerFaction: 'mud',
172
184
  * contract: "ContractAddr...",
@@ -1 +1 @@
1
- {"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,SAAS,EAA2C,MAAM,iBAAiB,CAAC;AAC/I,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,+BAA+B,EAA0D,MAAM,gCAAgC,CAAC;AAClK,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,M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AC,qBAAqB,EAAE,8BAA8B;QAEvF,iDAAiD;QACjD,WAAW,EAAE,cAAc;QAC3B,eAAe,EAAE,kBAAkB;QACnC,YAAY,EAAE,eAAe,EAAmB,2BAA2B;QAE3E,MAAM,EAAyC,eAAe;QAC9D,QAAQ,EAAuC,eAAe;KAC/D,CAAC;IAEF,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,EAAE,+BAA+B,EAAE,GAAG,kBAAkB,CAAC;IAE/D,MAAM,cAAc,GAAG,MAAM,+BAA+B,CAC1D,KAAY,EACZ,EAAE,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,EAAE,CAC1D,CAAC;IACF,OAAO,uBAAuB,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAA0B;IAE1B,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrF,OAAO,+BAA+B,CAAC,YAAY,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,oBAAoB,CAAC,KAAK,IAAI,EAAE;QACrC,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { getModule, createConfigSelector } from '../utils/config';
2
2
  import { toAddress } from '../utils/constants';
3
+ import { createTransactionSigner } from '../utils/signer';
3
4
  /**
4
5
  * Internal function to cancel a rental instruction with configuration options.
5
6
  *
@@ -14,13 +15,15 @@ import { toAddress } from '../utils/constants';
14
15
  * @throws Error when instruction generation fails or required parameters are missing
15
16
  */
16
17
  async function _cancelRental(params, config) {
17
- const { borrower, contract, } = params;
18
+ const { contract, } = params;
19
+ // Handle borrower using smart signer handler for universal compatibility
20
+ const borrower = createTransactionSigner(params.borrower);
18
21
  // Get the resolved addresses from config (including network-specific addresses)
19
22
  // Note: resolvedAddresses not currently needed for this instruction but kept for consistency
20
23
  // const resolvedAddresses = resolveProgramAddresses(config || {});
21
24
  // Let codama derive all the optional accounts
22
25
  const input = {
23
- borrower, // Pass signer directly to Codama
26
+ borrower: borrower, // TransactionSigner for Codama
24
27
  contract: toAddress(contract), // Ensure string
25
28
  };
26
29
  // Get network-specific codama functions from centralized config
@@ -1 +1 @@
1
- {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAoE,MAAM,iBAAiB,CAAC;AACpI,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AA+B/C;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,gFAAgF;IAChF,6FAA6F;IAC7F,mEAAmE;IAEnE,8CAA8C;IAC9C,MAAM,KAAK,GAAG;QACZ,QAAQ,EAAqB,iCAAiC;QAC9D,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,gBAAgB;KAChD,CAAC;IAEF,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,EAAE,+BAA+B,EAAE,GAAG,kBAAkB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ACZ,QAAQ,EAAE,QAAQ,EAAE,+BAA+B;QACnD,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,gBAAgB;KAChD,CAAC;IAEF,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,EAAE,+BAA+B,EAAE,GAAG,kBAAkB,CAAC;IAC/D,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,OAAO,+BAA+B,CACpC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,UAAU,YAAY,CAC1B,MAA0B;IAE1B,OAAO,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,oBAAoB,CAAC,KAAK,IAAI,EAAE;QACrC,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,56 +1,38 @@
1
1
  import { createSolanaRpc } from '@solana/kit';
2
2
  import { fetchContractState as fetchContractStateCodama, fetchRentalState as fetchRentalStateCodama, fetchAllContractState, fetchAllRentalState } from '../codama/accounts';
3
- /**
4
- * Convenience wrapper functions for fetching account states with RPC URL strings.
5
- * These functions handle creating the RPC connection for you.
6
- */
7
- /**
8
- * Fetches contract state data from the blockchain using a simple RPC URL
9
- *
10
- * @param rpcUrl - The RPC endpoint URL as a string
11
- * @param contractAddress - The contract account address to fetch
12
- * @returns The deserialized contract state data
13
- *
14
- * @example
15
- * ```typescript
16
- * const contractState = await fetchContractState(
17
- * 'https://api.devnet.solana.com',
18
- * 'ContractAddress123...'
19
- * );
20
- *
21
- * console.log('Contract owner:', contractState.data.owner);
22
- * console.log('Contract rate:', contractState.data.rate);
23
- * ```
24
- */
25
- export async function fetchContractState(rpcUrl, contractAddress) {
26
- // Create RPC connection
3
+ import { getConfig, resolveProgramAddresses } from './config';
4
+ import { toAddress } from './constants';
5
+ // Implementation
6
+ export async function fetchContractState(rpcUrlOrAddress, contractAddress) {
7
+ // If only one argument, it's the contract address using default RPC
8
+ if (contractAddress === undefined) {
9
+ const address = toAddress(rpcUrlOrAddress);
10
+ const config = getConfig();
11
+ const resolved = await resolveProgramAddresses(config);
12
+ const rpc = createSolanaRpc(resolved.rpcUrl);
13
+ return fetchContractStateCodama(rpc, address);
14
+ }
15
+ // If two arguments, first is rpcUrl, second is address
16
+ const rpcUrl = rpcUrlOrAddress;
17
+ const address = toAddress(contractAddress);
27
18
  const rpc = createSolanaRpc(rpcUrl);
28
- // Fetch and return the contract state
29
- return fetchContractStateCodama(rpc, contractAddress);
19
+ return fetchContractStateCodama(rpc, address);
30
20
  }
31
- /**
32
- * Fetches rental state data from the blockchain using a simple RPC URL
33
- *
34
- * @param rpcUrl - The RPC endpoint URL as a string
35
- * @param rentalAddress - The rental account address to fetch
36
- * @returns The deserialized rental state data
37
- *
38
- * @example
39
- * ```typescript
40
- * const rentalState = await fetchRentalState(
41
- * 'https://api.devnet.solana.com',
42
- * 'RentalAddress123...'
43
- * );
44
- *
45
- * console.log('Rental borrower:', rentalState.data.borrower);
46
- * console.log('Rental start:', rentalState.data.start);
47
- * ```
48
- */
49
- export async function fetchRentalState(rpcUrl, rentalAddress) {
50
- // Create RPC connection
21
+ // Implementation
22
+ export async function fetchRentalState(rpcUrlOrAddress, rentalAddress) {
23
+ // If only one argument, it's the rental address using default RPC
24
+ if (rentalAddress === undefined) {
25
+ const address = toAddress(rpcUrlOrAddress);
26
+ const config = getConfig();
27
+ const resolved = await resolveProgramAddresses(config);
28
+ const rpc = createSolanaRpc(resolved.rpcUrl);
29
+ return fetchRentalStateCodama(rpc, address);
30
+ }
31
+ // If two arguments, first is rpcUrl, second is address
32
+ const rpcUrl = rpcUrlOrAddress;
33
+ const address = toAddress(rentalAddress);
51
34
  const rpc = createSolanaRpc(rpcUrl);
52
- // Fetch and return the rental state
53
- return fetchRentalStateCodama(rpc, rentalAddress);
35
+ return fetchRentalStateCodama(rpc, address);
54
36
  }
55
37
  /**
56
38
  * Fetches multiple contract states in a single RPC call
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-accounts.js","sourceRoot":"","sources":["../../../src/utils/fetch-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgB,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,kBAAkB,IAAI,wBAAwB,EAC9C,gBAAgB,IAAI,sBAAsB,EAC1C,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,eAAkC;IAElC,wBAAwB;IACxB,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAEpC,sCAAsC;IACtC,OAAO,wBAAwB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,aAAgC;IAEhC,wBAAwB;IACxB,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAEpC,oCAAoC;IACpC,OAAO,sBAAsB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;;;;;;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;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAc,EACd,eAAoC;IAEpC,wBAAwB;IACxB,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAEpC,qCAAqC;IACrC,OAAO,mBAAmB,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AACnD,CAAC"}
@@ -6,4 +6,5 @@ export * from "./duration";
6
6
  export * from "./instruction-converter";
7
7
  export * from "./fetch-accounts";
8
8
  export * from "./pda";
9
+ export * from "./signer";
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Universal signer handling utilities for @solana/kit compatibility
3
+ *
4
+ * This module provides utilities to handle different signer types in a unified way
5
+ * while ensuring compatibility with @solana/kit. Supports string addresses for
6
+ * browser usage and TransactionSigner objects for Node.js usage.
7
+ *
8
+ * Note: web3.js signers (Keypair, etc.) are explicitly not supported.
9
+ * Use address strings or @solana/kit TransactionSigner objects instead.
10
+ */
11
+ import { createNoopSigner, address, isAddress } from '@solana/kit';
12
+ /**
13
+ * Error thrown when an invalid signer type is provided
14
+ */
15
+ export class InvalidSignerError extends Error {
16
+ constructor(message) {
17
+ super(message);
18
+ this.name = 'InvalidSignerError';
19
+ }
20
+ }
21
+ /**
22
+ * Validates that a signer is compatible with @solana/kit
23
+ *
24
+ * @param signer - The signer to validate
25
+ * @throws {InvalidSignerError} If the signer is not compatible
26
+ */
27
+ export function validateSigner(signer) {
28
+ if (typeof signer === 'string') {
29
+ // Validate that the string is a valid Solana address
30
+ try {
31
+ // Use @solana/kit's address() function to validate - it will throw if invalid
32
+ address(signer);
33
+ return;
34
+ }
35
+ catch (error) {
36
+ throw new InvalidSignerError(`Invalid address string: "${signer}". ${error instanceof Error ? error.message : 'Unknown validation error'}\n\n` +
37
+ 'Expected a valid base58-encoded Solana address (32-44 characters).\n' +
38
+ 'Examples:\n' +
39
+ ' - "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"\n' +
40
+ ' - "So11111111111111111111111111111111111111112"');
41
+ }
42
+ }
43
+ if (signer && typeof signer === 'object') {
44
+ const signerObj = signer;
45
+ // Check for web3.js Keypair or similar patterns
46
+ if ('publicKey' in signerObj) {
47
+ throw new InvalidSignerError('web3.js signers (Keypair, etc.) are not supported. ' +
48
+ 'Use a base58 address string or TransactionSigner from @solana/kit instead.\n\n' +
49
+ 'Examples:\n' +
50
+ ' - Browser: "base58AddressString"\n' +
51
+ ' - Node.js: createNoopSigner(address("base58AddressString"))');
52
+ }
53
+ // Check for valid @solana/kit signer patterns
54
+ if ('address' in signerObj || typeof signerObj.signTransactions === 'function') {
55
+ // If it has an address property, validate that the address is valid
56
+ if ('address' in signerObj) {
57
+ try {
58
+ // Ensure the address property is a valid Address type
59
+ if (!isAddress(signerObj.address)) {
60
+ throw new InvalidSignerError(`Signer object has invalid address property. Expected Address type from @solana/kit.`);
61
+ }
62
+ }
63
+ catch (error) {
64
+ throw new InvalidSignerError(`Signer object has invalid address property: ${error instanceof Error ? error.message : 'Unknown validation error'}`);
65
+ }
66
+ }
67
+ return;
68
+ }
69
+ // Unknown signer object format
70
+ throw new InvalidSignerError('Invalid signer format. Expected:\n' +
71
+ ' - base58 address string (browser usage)\n' +
72
+ ' - TransactionSigner from @solana/kit (Node.js usage)\n' +
73
+ ' - Object with address property');
74
+ }
75
+ throw new InvalidSignerError('Signer must be a string address or compatible signer object');
76
+ }
77
+ /**
78
+ * Creates TransactionSigner from UniversalSigner input with validation
79
+ *
80
+ * This function provides universal compatibility by:
81
+ * - Validating the signer is compatible with @solana/kit
82
+ * - Converting string addresses to TransactionSigner using createNoopSigner
83
+ * - Passing through existing TransactionSigner objects unchanged
84
+ *
85
+ * The returned TransactionSigner has both .address property and signing capability,
86
+ * making it suitable for both PDA derivation and codama instruction building.
87
+ *
88
+ * @param signer - The signer input (string address or @solana/kit compatible signer)
89
+ * @returns TransactionSigner that can be used directly for codama and has .address property
90
+ * @throws {InvalidSignerError} If the signer is not compatible (e.g., web3.js Keypair)
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * // Browser usage with string address
95
+ * const borrower = createTransactionSigner("base58AddressString");
96
+ * // borrower.address → Address object for PDA derivation
97
+ * // borrower → TransactionSigner for codama
98
+ *
99
+ * // Node.js usage with TransactionSigner
100
+ * const borrower = createTransactionSigner(wallet);
101
+ * // borrower.address → wallet.address for PDA derivation
102
+ * // borrower → wallet signer for codama
103
+ *
104
+ * // This will throw an error:
105
+ * // createTransactionSigner(keypair); // InvalidSignerError: web3.js signers not supported
106
+ * ```
107
+ */
108
+ export function createTransactionSigner(signer) {
109
+ // Validate the signer first
110
+ validateSigner(signer);
111
+ // Handle string address case (browser usage)
112
+ if (typeof signer === 'string') {
113
+ return createNoopSigner(address(signer)); // Returns TransactionSigner with .address property
114
+ }
115
+ // Handle signer object cases (already validated TransactionSigner objects)
116
+ return signer;
117
+ }
118
+ /**
119
+ * Type guard to check if a value is a signer object (not a string)
120
+ */
121
+ export function isSignerObject(signer) {
122
+ return typeof signer !== 'string';
123
+ }
124
+ /**
125
+ * Type guard to check if a value is an address string
126
+ */
127
+ export function isAddressString(signer) {
128
+ return typeof signer === 'string';
129
+ }
130
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../src/utils/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAG3F;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAkBD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,qDAAqD;QACrD,IAAI,CAAC;YACH,8EAA8E;YAC9E,OAAO,CAAC,MAAM,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,kBAAkB,CAC1B,4BAA4B,MAAM,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,MAAM;gBACjH,sEAAsE;gBACtE,aAAa;gBACb,sDAAsD;gBACtD,mDAAmD,CACpD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,MAA6B,CAAC;QAEhD,gDAAgD;QAChD,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,kBAAkB,CAC1B,qDAAqD;gBACrD,gFAAgF;gBAChF,aAAa;gBACb,sCAAsC;gBACtC,+DAA+D,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GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC;AACpC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type ConfigSelector } from '../utils/config';
2
2
  import { type FluentInstruction, type SmartFluentConfigSelector } from '../utils/instruction-converter';
3
+ import { type UniversalSigner } from '../utils/signer';
3
4
  type UniversalAddress = string;
4
- type UniversalSigner = any;
5
5
  /**
6
6
  * Parameters for accepting a rental contract.
7
7
  *
@@ -13,8 +13,9 @@ type UniversalSigner = any;
13
13
  */
14
14
  export interface AcceptRentalParams {
15
15
  /**
16
- * The borrower who will rent the fleet (must be a signer object).
16
+ * The borrower who will rent the fleet (signer object or base58 string address).
17
17
  * This account will control the fleet during the rental period and make payments.
18
+ * Can be a wallet/signer object (CLI usage) or base58 address string (browser usage).
18
19
  */
19
20
  borrower: UniversalSigner;
20
21
  /**
@@ -96,27 +97,36 @@ export interface AcceptRentalParams {
96
97
  * ```typescript
97
98
  * import { acceptRental, days } from '@srsly/sdk';
98
99
  *
99
- * // Basic rental acceptance
100
+ * // CLI usage with wallet/signer object
100
101
  * const instruction = await acceptRental({
101
- * borrower: wallet, // Borrower's wallet
102
- * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
103
- * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
104
- * contract: "ContractAddr...", // Contract to accept
105
- * duration: days(7) // 7 days rental duration
102
+ * borrower: wallet, // Wallet object for signing
103
+ * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
104
+ * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
105
+ * contract: "ContractAddr...", // Contract to accept
106
+ * duration: days(7) // 7 days rental duration
106
107
  * });
107
108
  *
108
- * // Configure for mainnet
109
+ * // Browser usage with address string
110
+ * const browserInstruction = await acceptRental({
111
+ * borrower: wallet.publicKey.toString(), // Address string for browser
112
+ * borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
113
+ * borrowerFaction: 'mud', // Faction: 'mud', 'oni', or 'ustur'
114
+ * contract: "ContractAddr...", // Contract to accept
115
+ * duration: days(7) // 7 days rental duration
116
+ * });
117
+ *
118
+ * // Configure for mainnet (both patterns work)
109
119
  * const mainnetInstruction = await acceptRental({
110
- * borrower: wallet,
120
+ * borrower: wallet, // Wallet object (CLI style)
111
121
  * borrowerProfile: "ProfileAddr...",
112
- * borrowerFaction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
122
+ * borrowerFaction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
113
123
  * contract: "ContractAddr...",
114
124
  * duration: days(7)
115
125
  * }).set({ programs: 'mainnet' });
116
126
  *
117
127
  * // Override specific game configuration
118
128
  * const customInstruction = await acceptRental({
119
- * borrower: wallet,
129
+ * borrower: "BorrowerAddress123...", // Address string (browser style)
120
130
  * borrowerProfile: "ProfileAddr...",
121
131
  * borrowerFaction: 'mud',
122
132
  * contract: "ContractAddr...",
@@ -128,7 +138,7 @@ export interface AcceptRentalParams {
128
138
  *
129
139
  * // Convert to @solana/web3.js format
130
140
  * const web3jsInstruction = await acceptRental({
131
- * borrower: wallet,
141
+ * borrower: wallet, // Universal: works with both patterns
132
142
  * borrowerProfile: "ProfileAddr...",
133
143
  * borrowerFaction: 'mud',
134
144
  * contract: "ContractAddr...",
@@ -1 +1 @@
1
- {"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuE,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAG/I,OAAO,EAA4D,KAAK,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAMlK,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,eAAe,GAAG,GAAG,CAAC;AAG3B;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,EAAE,eAAe,CAAC;IAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,yBAAyB,CAAC,iBAAiB,CAAC,CAG9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK9F"}
@@ -1,6 +1,6 @@
1
1
  import { type ConfigSelector } from '../utils/config';
2
+ import { type UniversalSigner } from '../utils/signer';
2
3
  type UniversalAddress = string;
3
- type UniversalSigner = any;
4
4
  type CancelRentalInstruction = any;
5
5
  /**
6
6
  * Parameters for canceling an active rental.
@@ -13,9 +13,10 @@ type CancelRentalInstruction = any;
13
13
  */
14
14
  export interface CancelRentalParams {
15
15
  /**
16
- * The borrower who wants to cancel the rental (must be a signer object).
16
+ * The borrower who wants to cancel the rental (signer object or base58 string address).
17
17
  * Must be the original borrower who accepted the rental contract.
18
18
  * This account will pay any cancellation penalties.
19
+ * Can be a wallet/signer object (CLI usage) or base58 address string (browser usage).
19
20
  */
20
21
  borrower: UniversalSigner;
21
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAIpI,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,eAAe,GAAG,GAAG,CAAC;AAC3B,KAAK,uBAAuB,GAAG,GAAG,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,EAAE,eAAe,CAAC;IAE1B;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AA8CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,cAAc,CAAC,uBAAuB,CAAC,CAEzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK9F"}
1
+ {"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAEpI,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGhF,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAC/B,KAAK,uBAAuB,GAAG,GAAG,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,QAAQ,EAAE,eAAe,CAAC;IAE1B;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAgDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,cAAc,CAAC,uBAAuB,CAAC,CAEzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK9F"}
@@ -1,13 +1,28 @@
1
1
  import { type Address } from '@solana/kit';
2
+ import { fetchContractState as fetchContractStateCodama, fetchRentalState as fetchRentalStateCodama } from '../codama/accounts';
2
3
  /**
3
4
  * Convenience wrapper functions for fetching account states with RPC URL strings.
4
5
  * These functions handle creating the RPC connection for you.
5
6
  */
6
7
  /**
7
- * Fetches contract state data from the blockchain using a simple RPC URL
8
+ * Fetches contract state data from the blockchain using RPC URL from global config
9
+ *
10
+ * @param contractAddress - The contract account address to fetch (string or Address)
11
+ * @returns The deserialized contract state data
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Uses RPC URL from global config
16
+ * const contractState = await fetchContractState('ContractAddress123...');
17
+ * console.log('Contract owner:', contractState.data.owner);
18
+ * ```
19
+ */
20
+ export declare function fetchContractState<TAddress extends string = string>(contractAddress: string | Address<TAddress>): Promise<ReturnType<typeof fetchContractStateCodama>>;
21
+ /**
22
+ * Fetches contract state data from the blockchain using a specific RPC URL
8
23
  *
9
24
  * @param rpcUrl - The RPC endpoint URL as a string
10
- * @param contractAddress - The contract account address to fetch
25
+ * @param contractAddress - The contract account address to fetch (string or Address)
11
26
  * @returns The deserialized contract state data
12
27
  *
13
28
  * @example
@@ -21,12 +36,26 @@ import { type Address } from '@solana/kit';
21
36
  * console.log('Contract rate:', contractState.data.rate);
22
37
  * ```
23
38
  */
24
- export declare function fetchContractState<TAddress extends string = string>(rpcUrl: string, contractAddress: Address<TAddress>): Promise<import("@solana/kit").Account<import("../codama/accounts").ContractState, TAddress>>;
39
+ export declare function fetchContractState<TAddress extends string = string>(rpcUrl: string, contractAddress: string | Address<TAddress>): Promise<ReturnType<typeof fetchContractStateCodama>>;
40
+ /**
41
+ * Fetches rental state data from the blockchain using RPC URL from global config
42
+ *
43
+ * @param rentalAddress - The rental account address to fetch (string or Address)
44
+ * @returns The deserialized rental state data
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Uses RPC URL from global config
49
+ * const rentalState = await fetchRentalState('RentalAddress123...');
50
+ * console.log('Rental borrower:', rentalState.data.borrower);
51
+ * ```
52
+ */
53
+ export declare function fetchRentalState<TAddress extends string = string>(rentalAddress: string | Address<TAddress>): Promise<ReturnType<typeof fetchRentalStateCodama>>;
25
54
  /**
26
- * Fetches rental state data from the blockchain using a simple RPC URL
55
+ * Fetches rental state data from the blockchain using a specific RPC URL
27
56
  *
28
57
  * @param rpcUrl - The RPC endpoint URL as a string
29
- * @param rentalAddress - The rental account address to fetch
58
+ * @param rentalAddress - The rental account address to fetch (string or Address)
30
59
  * @returns The deserialized rental state data
31
60
  *
32
61
  * @example
@@ -40,7 +69,7 @@ export declare function fetchContractState<TAddress extends string = string>(rpc
40
69
  * console.log('Rental start:', rentalState.data.start);
41
70
  * ```
42
71
  */
43
- export declare function fetchRentalState<TAddress extends string = string>(rpcUrl: string, rentalAddress: Address<TAddress>): Promise<import("@solana/kit").Account<import("../codama/accounts").RentalState, TAddress>>;
72
+ export declare function fetchRentalState<TAddress extends string = string>(rpcUrl: string, rentalAddress: string | Address<TAddress>): Promise<ReturnType<typeof fetchRentalStateCodama>>;
44
73
  /**
45
74
  * Fetches multiple contract states in a single RPC call
46
75
  *
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-accounts.d.ts","sourceRoot":"","sources":["../../../src/utils/fetch-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAQ5D;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EACvE,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC,gGAOnC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EACrE,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,8FAOjC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChF,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,wFAOvC;AAED;;;;;;;;;;;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C,OAAO,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC;AAuBtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChF,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,wFAOvC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,yBAAyB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAC9E,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,sFAOrC"}
@@ -6,4 +6,5 @@ export * from "./duration";
6
6
  export * from "./instruction-converter";
7
7
  export * from "./fetch-accounts";
8
8
  export * from "./pda";
9
+ export * from "./signer";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Universal signer handling utilities for @solana/kit compatibility
3
+ *
4
+ * This module provides utilities to handle different signer types in a unified way
5
+ * while ensuring compatibility with @solana/kit. Supports string addresses for
6
+ * browser usage and TransactionSigner objects for Node.js usage.
7
+ *
8
+ * Note: web3.js signers (Keypair, etc.) are explicitly not supported.
9
+ * Use address strings or @solana/kit TransactionSigner objects instead.
10
+ */
11
+ import { type TransactionSigner } from '@solana/kit';
12
+ /**
13
+ * Error thrown when an invalid signer type is provided
14
+ */
15
+ export declare class InvalidSignerError extends Error {
16
+ constructor(message: string);
17
+ }
18
+ /**
19
+ * Universal signer type that supports @solana/kit compatible signers and address strings
20
+ *
21
+ * Supported types:
22
+ * - string: Base58 Solana address (for browser usage)
23
+ * - TransactionSigner: @solana/kit signer object (for Node.js usage)
24
+ * - { address: string }: Kit-compatible signer with address property
25
+ *
26
+ * Note: web3.js signers (Keypair, etc.) are not supported. Use address strings
27
+ * or TransactionSigner objects from @solana/kit instead.
28
+ */
29
+ export type UniversalSigner = string | TransactionSigner | {
30
+ address: string;
31
+ };
32
+ /**
33
+ * Validates that a signer is compatible with @solana/kit
34
+ *
35
+ * @param signer - The signer to validate
36
+ * @throws {InvalidSignerError} If the signer is not compatible
37
+ */
38
+ export declare function validateSigner(signer: unknown): asserts signer is UniversalSigner;
39
+ /**
40
+ * Creates TransactionSigner from UniversalSigner input with validation
41
+ *
42
+ * This function provides universal compatibility by:
43
+ * - Validating the signer is compatible with @solana/kit
44
+ * - Converting string addresses to TransactionSigner using createNoopSigner
45
+ * - Passing through existing TransactionSigner objects unchanged
46
+ *
47
+ * The returned TransactionSigner has both .address property and signing capability,
48
+ * making it suitable for both PDA derivation and codama instruction building.
49
+ *
50
+ * @param signer - The signer input (string address or @solana/kit compatible signer)
51
+ * @returns TransactionSigner that can be used directly for codama and has .address property
52
+ * @throws {InvalidSignerError} If the signer is not compatible (e.g., web3.js Keypair)
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // Browser usage with string address
57
+ * const borrower = createTransactionSigner("base58AddressString");
58
+ * // borrower.address → Address object for PDA derivation
59
+ * // borrower → TransactionSigner for codama
60
+ *
61
+ * // Node.js usage with TransactionSigner
62
+ * const borrower = createTransactionSigner(wallet);
63
+ * // borrower.address → wallet.address for PDA derivation
64
+ * // borrower → wallet signer for codama
65
+ *
66
+ * // This will throw an error:
67
+ * // createTransactionSigner(keypair); // InvalidSignerError: web3.js signers not supported
68
+ * ```
69
+ */
70
+ export declare function createTransactionSigner(signer: UniversalSigner): TransactionSigner;
71
+ /**
72
+ * Type guard to check if a value is a signer object (not a string)
73
+ */
74
+ export declare function isSignerObject(signer: UniversalSigner): signer is Exclude<UniversalSigner, string>;
75
+ /**
76
+ * Type guard to check if a value is an address string
77
+ */
78
+ export declare function isAddressString(signer: UniversalSigner): signer is string;
79
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/utils/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAwC,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG3F;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,iBAAiB,GACjB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,CAgEjF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,iBAAiB,CAWlF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAElG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,MAAM,CAEzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuwei-labs/srsly",
3
- "version": "2.0.0-beta.44",
3
+ "version": "2.0.0-beta.46",
4
4
  "description": "",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/types/index.d.ts",