@wuwei-labs/srsly 2.0.0-beta.26 → 2.0.0-beta.29

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.
Files changed (72) hide show
  1. package/README.md +189 -97
  2. package/dist/cjs/contract/close.js +33 -24
  3. package/dist/cjs/contract/close.js.map +1 -1
  4. package/dist/cjs/contract/create.js +67 -52
  5. package/dist/cjs/contract/create.js.map +1 -1
  6. package/dist/cjs/package.json +6 -14
  7. package/dist/cjs/rental/accept.js +35 -29
  8. package/dist/cjs/rental/accept.js.map +1 -1
  9. package/dist/cjs/rental/cancel.js +13 -9
  10. package/dist/cjs/rental/cancel.js.map +1 -1
  11. package/dist/cjs/rental/close.js +15 -11
  12. package/dist/cjs/rental/close.js.map +1 -1
  13. package/dist/cjs/rental/reset.js +20 -17
  14. package/dist/cjs/rental/reset.js.map +1 -1
  15. package/dist/cjs/utils/config.js +0 -88
  16. package/dist/cjs/utils/config.js.map +1 -1
  17. package/dist/cjs/utils/index.js +1 -0
  18. package/dist/cjs/utils/index.js.map +1 -1
  19. package/dist/cjs/utils/instruction-converter.js +49 -0
  20. package/dist/cjs/utils/instruction-converter.js.map +1 -0
  21. package/dist/esm/contract/close.js +34 -25
  22. package/dist/esm/contract/close.js.map +1 -1
  23. package/dist/esm/contract/create.js +67 -51
  24. package/dist/esm/contract/create.js.map +1 -1
  25. package/dist/esm/package.json +6 -14
  26. package/dist/esm/rental/accept.js +36 -30
  27. package/dist/esm/rental/accept.js.map +1 -1
  28. package/dist/esm/rental/cancel.js +13 -9
  29. package/dist/esm/rental/cancel.js.map +1 -1
  30. package/dist/esm/rental/close.js +15 -11
  31. package/dist/esm/rental/close.js.map +1 -1
  32. package/dist/esm/rental/reset.js +22 -19
  33. package/dist/esm/rental/reset.js.map +1 -1
  34. package/dist/esm/utils/config.js +0 -88
  35. package/dist/esm/utils/config.js.map +1 -1
  36. package/dist/esm/utils/index.js +1 -0
  37. package/dist/esm/utils/index.js.map +1 -1
  38. package/dist/esm/utils/instruction-converter.js +45 -0
  39. package/dist/esm/utils/instruction-converter.js.map +1 -0
  40. package/dist/types/contract/close.d.ts +12 -11
  41. package/dist/types/contract/close.d.ts.map +1 -1
  42. package/dist/types/contract/create.d.ts +49 -65
  43. package/dist/types/contract/create.d.ts.map +1 -1
  44. package/dist/types/rental/accept.d.ts +32 -28
  45. package/dist/types/rental/accept.d.ts.map +1 -1
  46. package/dist/types/rental/cancel.d.ts +16 -12
  47. package/dist/types/rental/cancel.d.ts.map +1 -1
  48. package/dist/types/rental/close.d.ts +16 -13
  49. package/dist/types/rental/close.d.ts.map +1 -1
  50. package/dist/types/rental/reset.d.ts +19 -16
  51. package/dist/types/rental/reset.d.ts.map +1 -1
  52. package/dist/types/utils/config.d.ts +0 -95
  53. package/dist/types/utils/config.d.ts.map +1 -1
  54. package/dist/types/utils/index.d.ts +1 -0
  55. package/dist/types/utils/index.d.ts.map +1 -1
  56. package/dist/types/utils/instruction-converter.d.ts +76 -0
  57. package/dist/types/utils/instruction-converter.d.ts.map +1 -0
  58. package/dist/types/utils/types.d.ts +0 -8
  59. package/dist/types/utils/types.d.ts.map +1 -1
  60. package/package.json +6 -14
  61. package/dist/cjs/utils/pack-functions.js +0 -148
  62. package/dist/cjs/utils/pack-functions.js.map +0 -1
  63. package/dist/cjs/utils/solana-adapter.js +0 -120
  64. package/dist/cjs/utils/solana-adapter.js.map +0 -1
  65. package/dist/esm/utils/pack-functions.js +0 -110
  66. package/dist/esm/utils/pack-functions.js.map +0 -1
  67. package/dist/esm/utils/solana-adapter.js +0 -82
  68. package/dist/esm/utils/solana-adapter.js.map +0 -1
  69. package/dist/types/utils/pack-functions.d.ts +0 -18
  70. package/dist/types/utils/pack-functions.d.ts.map +0 -1
  71. package/dist/types/utils/solana-adapter.d.ts +0 -26
  72. package/dist/types/utils/solana-adapter.d.ts.map +0 -1
@@ -1,87 +1,102 @@
1
1
  "use strict";
2
+ /**
3
+ * Unified contract creation - works with both @solana/kit and @solana/web3.js
4
+ * Uses strings for all addresses to eliminate library-specific type complexity
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.createContract = createContract;
4
- exports.getCreateContractInstructionAsync = getCreateContractInstructionAsync;
5
8
  const config_1 = require("../utils/config");
6
9
  const constants_1 = require("../utils/constants");
7
10
  const paymentFrequency_1 = require("../utils/paymentFrequency");
8
11
  const paymentFrequency_2 = require("../types/paymentFrequency");
12
+ const instruction_converter_1 = require("../utils/instruction-converter");
9
13
  /**
10
- * Internal function to create a contract instruction with configuration options
14
+ * Internal function to create a rental contract instruction with configuration options
11
15
  */
12
16
  async function _createContract(params, config) {
13
- const { owner, fleet, ownerProfile, rate, durationMax, paymentsFreq, ownerKeyIndex = 0, gameId, mint, } = params;
14
- // Validate payment frequency using auto-generated validation
17
+ const { owner, fleet, ownerProfile, rate, durationMax, paymentsFreq, gameId, sageProgramAddress, atlasMint, ownerKeyIndex = 0, } = params;
18
+ // Validate payment frequency
15
19
  if (!(0, paymentFrequency_2.isValidPaymentFrequency)(paymentsFreq)) {
16
- throw new Error(`Invalid payment frequency: ${paymentsFreq}. Valid values are auto-generated from Rust PaymentFrequency enum.`);
20
+ throw new Error(`Invalid payment frequency: "${paymentsFreq}". Valid values are: ${JSON.stringify(Object.keys({ daily: true, weekly: true, monthly: true, hourly: true }))}`);
17
21
  }
18
- // Calculate durationMin from payment frequency
22
+ // Validate duration alignment
23
+ (0, paymentFrequency_1.validateDurationAlignment)(Number(durationMax), paymentsFreq);
24
+ // Get the payment frequency interval (this will be the minimum duration)
19
25
  const durationMin = (0, paymentFrequency_1.paymentFrequencyStringToSeconds)(paymentsFreq);
20
- // Validate that durationMax is a multiple of the payment frequency
21
- // Uses the codama-generated PaymentFrequency enum and mirrors Rust implementation
22
- (0, paymentFrequency_1.validateDurationAlignment)(durationMax, paymentsFreq);
23
- // Get the actual game ID to use (param override, config override, or network default)
26
+ // Convert the payment frequency to the format expected by the Rust program (with @ prefix)
27
+ const paymentsFreqWithPrefix = `@${paymentsFreq}`;
28
+ // Get network-specific addresses (param override, config override, or network default)
24
29
  const actualGameId = gameId ? (0, constants_1.toAddress)(gameId) : await (0, constants_1.getSageGameId)(config);
25
- // Get codama functions
30
+ const actualSageProgramAddress = sageProgramAddress ? (0, constants_1.toAddress)(sageProgramAddress) : await (0, constants_1.getSageProgramAddress)(config);
31
+ const actualAtlasMint = atlasMint ? (0, constants_1.toAddress)(atlasMint) : await (0, constants_1.getAtlasMint)(config);
32
+ const input = {
33
+ owner, // Pass as-is (string or signer)
34
+ fleet: (0, constants_1.toAddress)(fleet), // Ensure string
35
+ ownerProfile: (0, constants_1.toAddress)(ownerProfile), // Ensure string
36
+ gameId: actualGameId, // Already string
37
+ sageProgram: actualSageProgramAddress, // Fixed: use sageProgram instead of sageProgramAddress
38
+ mint: actualAtlasMint, // Fixed: use mint instead of atlasMint
39
+ durationMin,
40
+ durationMax,
41
+ rate,
42
+ paymentsFeq: paymentsFreqWithPrefix, // Fixed: use paymentsFeq as expected by codama
43
+ ownerKeyIndex,
44
+ };
45
+ // Get network-specific codama functions from centralized config
26
46
  const instructionsModule = (0, config_1.getModule)('instructions');
27
47
  const programsModule = (0, config_1.getModule)('programs');
28
48
  const { getCreateContractInstructionAsync } = instructionsModule;
29
49
  const { SRSLY_PROGRAM_ADDRESS } = programsModule;
30
- // Default ATLAS mint address if not provided (uses config)
31
- const atlasMint = mint ? (0, constants_1.toAddress)(mint) : await (0, constants_1.getAtlasMint)(config);
32
- // Let codama derive the rest (contract, rentalAuthority, ownerTokenAccount, etc.)
33
- const input = {
34
- mint: atlasMint,
35
- owner, // Keep as TransactionSigner
36
- fleet: (0, constants_1.toAddress)(fleet),
37
- ownerProfile: (0, constants_1.toAddress)(ownerProfile),
38
- gameId: actualGameId,
39
- rate: BigInt(rate),
40
- durationMin: BigInt(durationMin),
41
- durationMax: BigInt(durationMax),
42
- paymentsFeq: `@${paymentsFreq}`,
43
- ownerKeyIndex,
44
- sageProgram: (0, constants_1.toAddress)(await (0, constants_1.getSageProgramAddress)(config)),
45
- };
46
- return getCreateContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
50
+ const rawInstruction = await getCreateContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
51
+ return (0, instruction_converter_1.createFluentInstruction)(rawInstruction);
47
52
  }
48
53
  /**
49
54
  * Creates an instruction to create a rental contract with fluent configuration.
55
+ * This unified version works with both @solana/kit and @solana/web3.js using strings for addresses.
50
56
  *
51
57
  * @example
52
58
  * ```typescript
53
- * // Use devnet defaults
54
- * const ix = await createContract(params);
55
- *
56
- * // Use mainnet configuration
57
- * const ix = await createContract(params).set({ network: 'mainnet' });
59
+ * // Works with any library - just use strings for addresses!
58
60
  *
59
- * // Override specific constants
60
- * const ix = await createContract(params).set({
61
- * network: 'mainnet',
62
- * gameId: 'custom-game-id...',
63
- * sageProgramAddress: 'custom-sage...'
61
+ * // Default returns @solana/kit format
62
+ * const kitInstruction = await createContract({
63
+ * owner: wallet, // Can be signer object or string
64
+ * fleet: "FleetAddress123...", // String address
65
+ * ownerProfile: "ProfileAddr...", // String address
66
+ * rate: 1000,
67
+ * durationMax: days(7),
68
+ * paymentsFreq: 'daily'
64
69
  * });
65
70
  *
66
- * // Chain configurations
67
- * const ix = await createContract(params)
68
- * .set({ network: 'devnet' })
69
- * .set({ gameId: 'override-game...' });
71
+ * // Convert to @solana/web3.js format using fluent interface
72
+ * const web3jsInstruction = await createContract({
73
+ * owner: wallet,
74
+ * fleet: "FleetAddress123...",
75
+ * ownerProfile: "ProfileAddr...",
76
+ * rate: 1000,
77
+ * durationMax: days(7),
78
+ * paymentsFreq: 'daily'
79
+ * }).web3js();
80
+ *
81
+ * // Chain configuration and format conversion
82
+ * const web3jsInstructionWithConfig = await createContract({
83
+ * owner: wallet,
84
+ * fleet: "FleetAddress123...",
85
+ * ownerProfile: "ProfileAddr...",
86
+ * rate: 1000,
87
+ * durationMax: days(7),
88
+ * paymentsFreq: 'daily'
89
+ * }).set({ programs: 'mainnet' }).web3js();
90
+ *
91
+ * // Use with your preferred Solana library
92
+ * const transaction = new Transaction().add(web3jsInstruction);
70
93
  * ```
71
94
  *
72
95
  * @param params The simplified parameters for creating a rental contract
73
96
  * @returns A ConfigSelector that can be configured with .set() or awaited directly
74
97
  */
75
98
  function createContract(params) {
76
- return (0, config_1.createConfigSelector)((config) => _createContract(params, config));
77
- }
78
- /**
79
- * Export config selector for getCreateContractInstructionAsync
80
- */
81
- function getCreateContractInstructionAsync(input, options) {
82
- return (0, config_1.createConfigSelector)(async (config) => {
83
- const instructionsModule = (0, config_1.getModule)('instructions');
84
- return instructionsModule.getCreateContractInstructionAsync(input, options);
85
- });
99
+ const baseSelector = (0, config_1.createConfigSelector)((config) => _createContract(params, config));
100
+ return (0, instruction_converter_1.createFluentConfigSelector)(baseSelector);
86
101
  }
87
102
  //# sourceMappingURL=create.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":";;AAkKA,wCAIC;AAKD,8EAKC;AA3KD,4CAA2G;AAC3G,kDAAmG;AACnG,gEAAuG;AACvG,gEAA4F;AA+D5F;;GAEG;AACH,KAAK,UAAU,eAAe,CAC5B,MAA4B,EAC5B,MAAsB;IAEtB,MAAM,EACJ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,aAAa,GAAG,CAAC,EACjB,MAAM,EACN,IAAI,GACL,GAAG,MAAM,CAAC;IAEX,6DAA6D;IAC7D,IAAI,CAAC,IAAA,0CAAuB,EAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,8BAA8B,YAAY,oEAAoE,CAAC,CAAC;IAClI,CAAC;IAED,+CAA+C;IAC/C,MAAM,WAAW,GAAG,IAAA,kDAA+B,EAAC,YAAY,CAAC,CAAC;IAElE,mEAAmE;IACnE,kFAAkF;IA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AM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,MAAM,cAAc,GAAG,MAAM,iCAAiC,CAAC,KAAK,EAAE,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAAC,CAAC;IACjH,OAAO,IAAA,+CAAuB,EAAC,cAAc,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,SAAgB,cAAc,CAAC,MAA4B;IACzD,MAAM,YAAY,GAAG,IAAA,6BAAoB,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvF,OAAO,IAAA,kDAA0B,EAAC,YAAY,CAAC,CAAC;AAClD,CAAC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuwei-labs/srsly",
3
- "version": "2.0.0-beta.26",
3
+ "version": "2.0.0-beta.29",
4
4
  "description": "",
5
5
  "source": "./src/index.ts",
6
6
  "sideEffects": false,
@@ -35,6 +35,9 @@
35
35
  "author": "",
36
36
  "license": "ISC",
37
37
  "packageManager": "pnpm@10.6.5",
38
+ "dependencies": {
39
+ "@solana/kit": "^2.0.0"
40
+ },
38
41
  "devDependencies": {
39
42
  "@codama/nodes-from-anchor": "^1.1.13",
40
43
  "@codama/renderers": "^1.0.21",
@@ -43,19 +46,8 @@
43
46
  "tsconfig-to-dual-package": "^1.2.0",
44
47
  "typedoc": "^0.28.3",
45
48
  "typescript": "^5.8.3",
46
- "vitest": "^3.2.4"
47
- },
48
- "peerDependencies": {
49
- "@solana/kit": ">=2.0.0",
50
- "@solana/web3.js": ">=1.95.0"
51
- },
52
- "peerDependenciesMeta": {
53
- "@solana/kit": {
54
- "optional": true
55
- },
56
- "@solana/web3.js": {
57
- "optional": true
58
- }
49
+ "vitest": "^3.2.4",
50
+ "webpack": "^5.99.9"
59
51
  },
60
52
  "type": "commonjs"
61
53
  }
@@ -5,6 +5,7 @@ exports.getAcceptRentalInstructionAsync = getAcceptRentalInstructionAsync;
5
5
  const config_1 = require("../utils/config");
6
6
  const constants_1 = require("../utils/constants");
7
7
  const utils_1 = require("../utils");
8
+ const instruction_converter_1 = require("../utils/instruction-converter");
8
9
  /**
9
10
  * Internal function to accept a rental instruction with configuration options
10
11
  */
@@ -20,16 +21,16 @@ async function _acceptRental(params, config) {
20
21
  config);
21
22
  // Let codama derive the rest (rentalThread, rentalState, rentalAuthority, etc.)
22
23
  const input = {
23
- borrower,
24
- borrowerProfile: (0, constants_1.toAddress)(borrowerProfile),
25
- borrowerProfileFaction: profileFaction,
26
- fleet: (0, constants_1.toAddress)(fleet),
27
- contract: (0, constants_1.toAddress)(contract),
28
- gameId: actualGameId,
29
- starbase,
30
- starbasePlayer,
31
- amount,
32
- duration,
24
+ borrower, // Pass as-is (string or signer)
25
+ borrowerProfile: (0, constants_1.toAddress)(borrowerProfile), // Ensure string
26
+ borrowerProfileFaction: profileFaction, // Already string from deriveGameAccounts
27
+ fleet: (0, constants_1.toAddress)(fleet), // Ensure string
28
+ contract: (0, constants_1.toAddress)(contract), // Ensure string
29
+ gameId: actualGameId, // Already string
30
+ starbase, // Already string from deriveGameAccounts
31
+ starbasePlayer, // Already string from deriveGameAccounts
32
+ amount, // BigInt value
33
+ duration, // BigInt value
33
34
  referralTokenAccount: referralTokenAccount ? (0, constants_1.toAddress)(referralTokenAccount) : undefined,
34
35
  };
35
36
  // Get network-specific codama functions from centralized config
@@ -37,51 +38,56 @@ async function _acceptRental(params, config) {
37
38
  const programsModule = (0, config_1.getModule)('programs');
38
39
  const { getAcceptRentalInstructionAsync } = instructionsModule;
39
40
  const { SRSLY_PROGRAM_ADDRESS } = programsModule;
40
- return getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
41
+ const rawInstruction = await getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
42
+ return (0, instruction_converter_1.createFluentInstruction)(rawInstruction);
41
43
  }
42
44
  /**
43
45
  * Creates an instruction to accept a rental with fluent configuration.
44
46
  *
45
47
  * @example
46
48
  * ```typescript
47
- * // Use devnet defaults
48
- * const ix = await acceptRental({
49
- * borrower: wallet,
50
- * borrowerProfile: profileAddress,
51
- * borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
52
- * fleet: fleetAddress,
53
- * contract: contractAddress,
54
- * rate: 1000, // ATLAS tokens
55
- * duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
49
+ * // Works with any library - just use strings for addresses!
50
+ * const instruction = await acceptRental({
51
+ * borrower: wallet, // Can be signer object or string
52
+ * borrowerProfile: "ProfileAddr...", // String address
53
+ * borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
54
+ * fleet: "FleetAddress123...", // String address
55
+ * contract: "ContractAddr...", // String address
56
+ * rate: 1000, // ATLAS tokens
57
+ * duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
56
58
  * });
57
59
  *
58
60
  * // With referral (referrer gets 5% of platform fees)
59
- * const ix = await acceptRental({
61
+ * const instruction = await acceptRental({
60
62
  * borrower: wallet,
61
- * borrowerProfile: profileAddress,
63
+ * borrowerProfile: "ProfileAddr...",
62
64
  * borrowerFaction: 1,
63
- * fleet: fleetAddress,
64
- * contract: contractAddress,
65
+ * fleet: "FleetAddress123...",
66
+ * contract: "ContractAddr...",
65
67
  * rate: 1000,
66
68
  * duration: 86400,
67
- * referralTokenAccount: referrerTokenAddress
69
+ * referralTokenAccount: "ReferralAddr..."
68
70
  * });
69
71
  *
70
72
  * // Use mainnet configuration
71
- * const ix = await acceptRental(params).set({ network: 'mainnet' });
73
+ * const instruction = await acceptRental(params).set({ programs: 'mainnet' });
72
74
  *
73
75
  * // Override specific constants
74
- * const ix = await acceptRental(params).set({
75
- * network: 'mainnet',
76
+ * const instruction = await acceptRental(params).set({
77
+ * programs: 'mainnet',
76
78
  * gameId: 'custom-game-id...'
77
79
  * });
80
+ *
81
+ * // Use the instruction with your preferred Solana library
82
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
78
83
  * ```
79
84
  *
80
85
  * @param params The simplified parameters for accepting a rental
81
86
  * @returns A ConfigSelector that can be configured with .set() or awaited directly
82
87
  */
83
88
  function acceptRental(params) {
84
- return (0, config_1.createConfigSelector)((config) => _acceptRental(params, config));
89
+ const baseSelector = (0, config_1.createConfigSelector)((config) => _acceptRental(params, config));
90
+ return (0, instruction_converter_1.createFluentConfigSelector)(baseSelector);
85
91
  }
86
92
  function getAcceptRentalInstructionAsync(input, options) {
87
93
  return (0, config_1.createConfigSelector)(async (config) => {
@@ -1 +1 @@
1
- {"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":";;AAgLA,oCAIC;AAED,0EAKC;AAtLD,4CAA2G;AAC3G,kDAAiF;AAMjF,oCAEkB;AAuDlB;;GAEG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,eAAe,EACf,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,oBAAoB,GACrB,GAAG,MAAM,CAAC;IAEX,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,yBAAa,EAAC,MAAM,CAAC,CAAC;IAE9E,oDAAoD;IACpD,4EAA4E;IAC5E,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,6BAAiB,CAAC,CAAC;IAE3E,oCAAoC;IACpC,MAAM,EACJ,cAAc,EACd,QAAQ,EACR,cAAc,EACf,GAAG,MAAM,IAAA,0BAAkB,EAC1B,IAAA,qBAAS,EAAC,eAAe,CAAC,EAC1B,eAAe,EACf,YAAY,EACZ,CAAC,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AAC,CAAC,CAAC;AACL,CAAC"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cancelRental = cancelRental;
4
4
  exports.getCancelRentalInstructionAsync = getCancelRentalInstructionAsync;
5
5
  const config_1 = require("../utils/config");
6
+ const constants_1 = require("../utils/constants");
6
7
  /**
7
8
  * Internal function to cancel a rental instruction with configuration options
8
9
  */
@@ -10,8 +11,8 @@ async function _cancelRental(params, config) {
10
11
  const { borrower, contract, } = params;
11
12
  // Let codama derive all the optional accounts
12
13
  const input = {
13
- borrower,
14
- contract,
14
+ borrower, // Pass as-is (string or signer)
15
+ contract: (0, constants_1.toAddress)(contract), // Ensure string
15
16
  };
16
17
  // Get network-specific codama functions from centralized config
17
18
  const instructionsModule = (0, config_1.getModule)('instructions');
@@ -25,20 +26,23 @@ async function _cancelRental(params, config) {
25
26
  *
26
27
  * @example
27
28
  * ```typescript
28
- * // Use devnet defaults
29
- * const ix = await cancelRental({
30
- * borrower: wallet,
31
- * contract: contractAddress
29
+ * // Works with any library - just use strings for addresses!
30
+ * const instruction = await cancelRental({
31
+ * borrower: wallet, // Can be signer object or string
32
+ * contract: "ContractAddr..." // String address
32
33
  * });
33
34
  *
34
35
  * // Use mainnet configuration
35
- * const ix = await cancelRental(params).set({ network: 'mainnet' });
36
+ * const instruction = await cancelRental(params).set({ programs: 'mainnet' });
36
37
  *
37
38
  * // Override specific constants
38
- * const ix = await cancelRental(params).set({
39
- * network: 'mainnet',
39
+ * const instruction = await cancelRental(params).set({
40
+ * programs: 'mainnet',
40
41
  * sageProgramAddress: 'custom...'
41
42
  * });
43
+ *
44
+ * // Use the instruction with your preferred Solana library
45
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
42
46
  * ```
43
47
  *
44
48
  * @param params The simplified parameters for canceling a rental
@@ -1 +1 @@
1
- {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":";;AA+EA,oCAIC;AAED,0EAK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AAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,8CAA8C;IAC9C,MAAM,KAAK,GAAG;QACZ,QAAQ,EAAqB,gCAAgC;QAC7D,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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;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,SAAgB,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,IAAA,6BAAoB,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,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"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.closeRental = closeRental;
4
4
  exports.getCloseRentalInstructionAsync = getCloseRentalInstructionAsync;
5
5
  const config_1 = require("../utils/config");
6
+ const constants_1 = require("../utils/constants");
6
7
  /**
7
8
  * Internal function to close a rental instruction with configuration options
8
9
  */
@@ -10,9 +11,9 @@ async function _closeRental(params, config) {
10
11
  const { borrower, ownerTokenAccount, contract, } = params;
11
12
  // Let codama derive the optional accounts
12
13
  const input = {
13
- borrower,
14
- ownerTokenAccount,
15
- contract,
14
+ borrower: (0, constants_1.toAddress)(borrower), // Ensure string
15
+ ownerTokenAccount: (0, constants_1.toAddress)(ownerTokenAccount), // Ensure string
16
+ contract: (0, constants_1.toAddress)(contract), // Ensure string
16
17
  };
17
18
  // Get network-specific codama functions from centralized config
18
19
  const instructionsModule = (0, config_1.getModule)('instructions');
@@ -26,21 +27,24 @@ async function _closeRental(params, config) {
26
27
  *
27
28
  * @example
28
29
  * ```typescript
29
- * // Use devnet defaults
30
- * const ix = await closeRental({
31
- * borrower: borrowerAddress,
32
- * ownerTokenAccount: ownerTokenAccountAddress,
33
- * contract: contractAddress
30
+ * // Works with any library - just use strings for addresses!
31
+ * const instruction = await closeRental({
32
+ * borrower: "BorrowerAddr...", // String address
33
+ * ownerTokenAccount: "TokenAcct...", // String address
34
+ * contract: "ContractAddr..." // String address
34
35
  * });
35
36
  *
36
37
  * // Use mainnet configuration
37
- * const ix = await closeRental(params).set({ network: 'mainnet' });
38
+ * const instruction = await closeRental(params).set({ programs: 'mainnet' });
38
39
  *
39
40
  * // Override specific constants
40
- * const ix = await closeRental(params).set({
41
- * network: 'mainnet',
41
+ * const instruction = await closeRental(params).set({
42
+ * programs: 'mainnet',
42
43
  * sageProgramAddress: 'custom...'
43
44
  * });
45
+ *
46
+ * // Use the instruction with your preferred Solana library
47
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
44
48
  * ```
45
49
  *
46
50
  * @param params The simplified parameters for closing a rental
@@ -1 +1 @@
1
- {"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":";;AAsFA,kCAIC;AAED,wEAKC;AA7FD,4CAA2G;AAyB3G;;GAEG;AACH,KAAK,UAAU,YAAY,CACzB,MAAyB,EACzB,M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,GACT,GAAG,MAAM,CAAC;IAEX,0CAA0C;IAC1C,MAAM,KAAK,GAAG;QACZ,QAAQ,EAAE,IAAA,qBAAS,EAAC,QAAQ,CAAC,EAAgB,gBAAgB;QAC7D,iBAAiB,EAAE,IAAA,qBAAS,EAAC,iBAAiB,CAAC,EAAE,gBAAgB;QACjE,QAAQ,EAAE,IAAA,qBAAS,EAAC,QAAQ,CAAC,EAAe,gBAAgB;KAC7D,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,8BAA8B,EAAE,GAAG,kBAAkB,CAAC;IAC9D,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC;IAEjD,OAAO,8BAA8B,CACnC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,WAAW,CACzB,MAAyB;IAEzB,OAAO,IAAA,6BAAoB,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,SAAgB,8BAA8B,CAAC,KAAU,EAAE,OAAa;IACtE,OAAO,IAAA,6BAAoB,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -11,9 +11,9 @@ const utils_1 = require("../utils");
11
11
  async function _resetRental(params, config) {
12
12
  const { fleet, contract, rentalState, gameId, faction, ownerProfile, } = params;
13
13
  // Get the actual game ID to use (param override, config override, or network default)
14
- const actualGameId = gameId || await (0, constants_1.getSageGameId)(config);
14
+ const actualGameId = gameId ? (0, constants_1.toAddress)(gameId) : await (0, constants_1.getSageGameId)(config);
15
15
  // Derive the three accounts we need
16
- const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(ownerProfile, faction, actualGameId, 0, // starbaseSeqId
16
+ const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)((0, constants_1.toAddress)(ownerProfile), faction, actualGameId, 0, // starbaseSeqId
17
17
  config);
18
18
  // Get network-specific codama functions from centralized config
19
19
  const instructionsModule = (0, config_1.getModule)('instructions');
@@ -22,12 +22,12 @@ async function _resetRental(params, config) {
22
22
  const { SRSLY_PROGRAM_ADDRESS } = programsModule;
23
23
  // Let codama derive the rest (rentalAuthority)
24
24
  const input = {
25
- fleet,
26
- contract,
27
- rentalState,
28
- gameId: actualGameId,
29
- starbase,
30
- starbasePlayer,
25
+ fleet: (0, constants_1.toAddress)(fleet), // Ensure string
26
+ contract: (0, constants_1.toAddress)(contract), // Ensure string
27
+ rentalState: (0, constants_1.toAddress)(rentalState), // Ensure string
28
+ gameId: actualGameId, // Already string
29
+ starbase, // Already string from deriveGameAccounts
30
+ starbasePlayer, // Already string from deriveGameAccounts
31
31
  };
32
32
  return getResetRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
33
33
  }
@@ -36,24 +36,27 @@ async function _resetRental(params, config) {
36
36
  *
37
37
  * @example
38
38
  * ```typescript
39
- * // Use devnet defaults
40
- * const ix = await resetRental({
41
- * fleet: fleetAddress,
42
- * contract: contractAddress,
43
- * rentalState: rentalStateAddress,
39
+ * // Works with any library - just use strings for addresses!
40
+ * const instruction = await resetRental({
41
+ * fleet: "FleetAddress123...", // String address
42
+ * contract: "ContractAddr...", // String address
43
+ * rentalState: "RentalStateAddr...", // String address
44
44
  * faction: 'mud',
45
- * ownerProfile: ownerProfileAddress
45
+ * ownerProfile: "OwnerProfileAddr..." // String address
46
46
  * });
47
47
  *
48
48
  * // Use mainnet configuration
49
- * const ix = await resetRental(params).set({ network: 'mainnet' });
49
+ * const instruction = await resetRental(params).set({ programs: 'mainnet' });
50
50
  *
51
51
  * // Override specific constants
52
- * const ix = await resetRental(params).set({
53
- * network: 'mainnet',
52
+ * const instruction = await resetRental(params).set({
53
+ * programs: 'mainnet',
54
54
  * gameId: 'custom-game-id...',
55
55
  * sageProgramAddress: 'custom...'
56
56
  * });
57
+ *
58
+ * // Use the instruction with your preferred Solana library
59
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
57
60
  * ```
58
61
  *
59
62
  * @param params The simplified parameters for resetting a rental
@@ -1 +1 @@
1
- {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":";;AAsIA,kCAIC;AAED,wEAKC;AA7ID,4CAA2G;AAC3G,kDAAmD;AAKnD,oCAEkB;AAyClB;;GAEG;AACH,KAAK,UAAU,YAAY,CACzB,MAAyB,EACzB,MAAsB;IAEtB,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,EACN,OAAO,EACP,YAAY,GACb,GAAG,MAAM,CAAC;IAEX,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,IAAI,MAAM,IAAA,yBAAa,EAAC,MAAM,CAAC,CAAC;IAE3D,oCAAoC;IACpC,MAAM,EACJ,QAAQ,EACR,cAAc,EACf,GAAG,MAAM,IAAA,0BAAkB,EAC1B,YAAY,EACZ,OAAO,EACP,YAA+B,EAC/B,CAAC,EAAE,gBAAgB;IACnB,MAAM,CACP,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,8BAA8B,EAAE,GAAG,kBAAkB,CAAC;IAC9D,MAAM,EAAE,qBAAqB,EAAE,GAAG,cAAc,CAAC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