@wuwei-labs/srsly 2.0.0-beta.25 → 2.0.0-beta.28

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 (70) hide show
  1. package/README.md +200 -99
  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 +2 -6
  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 +1 -180
  16. package/dist/cjs/utils/config.js.map +1 -1
  17. package/dist/cjs/utils/constants.js +2 -2
  18. package/dist/cjs/utils/constants.js.map +1 -1
  19. package/dist/cjs/utils/index.js +1 -0
  20. package/dist/cjs/utils/index.js.map +1 -1
  21. package/dist/cjs/utils/instruction-converter.js +49 -0
  22. package/dist/cjs/utils/instruction-converter.js.map +1 -0
  23. package/dist/cjs/utils/types.js +6 -0
  24. package/dist/cjs/utils/types.js.map +1 -0
  25. package/dist/esm/contract/close.js +34 -25
  26. package/dist/esm/contract/close.js.map +1 -1
  27. package/dist/esm/contract/create.js +67 -51
  28. package/dist/esm/contract/create.js.map +1 -1
  29. package/dist/esm/package.json +2 -6
  30. package/dist/esm/rental/accept.js +36 -30
  31. package/dist/esm/rental/accept.js.map +1 -1
  32. package/dist/esm/rental/cancel.js +13 -9
  33. package/dist/esm/rental/cancel.js.map +1 -1
  34. package/dist/esm/rental/close.js +15 -11
  35. package/dist/esm/rental/close.js.map +1 -1
  36. package/dist/esm/rental/reset.js +22 -19
  37. package/dist/esm/rental/reset.js.map +1 -1
  38. package/dist/esm/utils/config.js +1 -181
  39. package/dist/esm/utils/config.js.map +1 -1
  40. package/dist/esm/utils/constants.js +2 -2
  41. package/dist/esm/utils/constants.js.map +1 -1
  42. package/dist/esm/utils/index.js +1 -0
  43. package/dist/esm/utils/index.js.map +1 -1
  44. package/dist/esm/utils/instruction-converter.js +45 -0
  45. package/dist/esm/utils/instruction-converter.js.map +1 -0
  46. package/dist/esm/utils/types.js +5 -0
  47. package/dist/esm/utils/types.js.map +1 -0
  48. package/dist/types/contract/close.d.ts +12 -11
  49. package/dist/types/contract/close.d.ts.map +1 -1
  50. package/dist/types/contract/create.d.ts +49 -65
  51. package/dist/types/contract/create.d.ts.map +1 -1
  52. package/dist/types/rental/accept.d.ts +32 -28
  53. package/dist/types/rental/accept.d.ts.map +1 -1
  54. package/dist/types/rental/cancel.d.ts +16 -12
  55. package/dist/types/rental/cancel.d.ts.map +1 -1
  56. package/dist/types/rental/close.d.ts +16 -13
  57. package/dist/types/rental/close.d.ts.map +1 -1
  58. package/dist/types/rental/reset.d.ts +19 -16
  59. package/dist/types/rental/reset.d.ts.map +1 -1
  60. package/dist/types/utils/config.d.ts +6 -84
  61. package/dist/types/utils/config.d.ts.map +1 -1
  62. package/dist/types/utils/constants.d.ts +8 -8
  63. package/dist/types/utils/constants.d.ts.map +1 -1
  64. package/dist/types/utils/index.d.ts +1 -0
  65. package/dist/types/utils/index.d.ts.map +1 -1
  66. package/dist/types/utils/instruction-converter.d.ts +76 -0
  67. package/dist/types/utils/instruction-converter.d.ts.map +1 -0
  68. package/dist/types/utils/types.d.ts +6 -0
  69. package/dist/types/utils/types.d.ts.map +1 -0
  70. package/package.json +2 -6
@@ -1,83 +1,99 @@
1
+ /**
2
+ * Unified contract creation - works with both @solana/kit and @solana/web3.js
3
+ * Uses strings for all addresses to eliminate library-specific type complexity
4
+ */
1
5
  import { getModule, createConfigSelector } from '../utils/config';
2
6
  import { getSageGameId, getSageProgramAddress, getAtlasMint, toAddress } from '../utils/constants';
3
7
  import { validateDurationAlignment, paymentFrequencyStringToSeconds } from '../utils/paymentFrequency';
4
8
  import { isValidPaymentFrequency } from '../types/paymentFrequency';
9
+ import { createFluentInstruction, createFluentConfigSelector } from '../utils/instruction-converter';
5
10
  /**
6
- * Internal function to create a contract instruction with configuration options
11
+ * Internal function to create a rental contract instruction with configuration options
7
12
  */
8
13
  async function _createContract(params, config) {
9
- const { owner, fleet, ownerProfile, rate, durationMax, paymentsFreq, ownerKeyIndex = 0, gameId, mint, } = params;
10
- // Validate payment frequency using auto-generated validation
14
+ const { owner, fleet, ownerProfile, rate, durationMax, paymentsFreq, gameId, sageProgramAddress, atlasMint, ownerKeyIndex = 0, } = params;
15
+ // Validate payment frequency
11
16
  if (!isValidPaymentFrequency(paymentsFreq)) {
12
- throw new Error(`Invalid payment frequency: ${paymentsFreq}. Valid values are auto-generated from Rust PaymentFrequency enum.`);
17
+ throw new Error(`Invalid payment frequency: "${paymentsFreq}". Valid values are: ${JSON.stringify(Object.keys({ daily: true, weekly: true, monthly: true, hourly: true }))}`);
13
18
  }
14
- // Calculate durationMin from payment frequency
19
+ // Validate duration alignment
20
+ validateDurationAlignment(Number(durationMax), paymentsFreq);
21
+ // Get the payment frequency interval (this will be the minimum duration)
15
22
  const durationMin = paymentFrequencyStringToSeconds(paymentsFreq);
16
- // Validate that durationMax is a multiple of the payment frequency
17
- // Uses the codama-generated PaymentFrequency enum and mirrors Rust implementation
18
- validateDurationAlignment(durationMax, paymentsFreq);
19
- // Get the actual game ID to use (param override, config override, or network default)
23
+ // Convert the payment frequency to the format expected by the Rust program (with @ prefix)
24
+ const paymentsFreqWithPrefix = `@${paymentsFreq}`;
25
+ // Get network-specific addresses (param override, config override, or network default)
20
26
  const actualGameId = gameId ? toAddress(gameId) : await getSageGameId(config);
21
- // Get codama functions
27
+ const actualSageProgramAddress = sageProgramAddress ? toAddress(sageProgramAddress) : await getSageProgramAddress(config);
28
+ const actualAtlasMint = atlasMint ? toAddress(atlasMint) : await getAtlasMint(config);
29
+ const input = {
30
+ owner, // Pass as-is (string or signer)
31
+ fleet: toAddress(fleet), // Ensure string
32
+ ownerProfile: toAddress(ownerProfile), // Ensure string
33
+ gameId: actualGameId, // Already string
34
+ sageProgram: actualSageProgramAddress, // Fixed: use sageProgram instead of sageProgramAddress
35
+ mint: actualAtlasMint, // Fixed: use mint instead of atlasMint
36
+ durationMin,
37
+ durationMax,
38
+ rate,
39
+ paymentsFeq: paymentsFreqWithPrefix, // Fixed: use paymentsFeq as expected by codama
40
+ ownerKeyIndex,
41
+ };
42
+ // Get network-specific codama functions from centralized config
22
43
  const instructionsModule = getModule('instructions');
23
44
  const programsModule = getModule('programs');
24
45
  const { getCreateContractInstructionAsync } = instructionsModule;
25
46
  const { SRSLY_PROGRAM_ADDRESS } = programsModule;
26
- // Default ATLAS mint address if not provided (uses config)
27
- const atlasMint = mint ? toAddress(mint) : await getAtlasMint(config);
28
- // Let codama derive the rest (contract, rentalAuthority, ownerTokenAccount, etc.)
29
- const input = {
30
- mint: atlasMint,
31
- owner, // Keep as TransactionSigner
32
- fleet: toAddress(fleet),
33
- ownerProfile: toAddress(ownerProfile),
34
- gameId: actualGameId,
35
- rate: BigInt(rate),
36
- durationMin: BigInt(durationMin),
37
- durationMax: BigInt(durationMax),
38
- paymentsFeq: `@${paymentsFreq}`,
39
- ownerKeyIndex,
40
- sageProgram: toAddress(await getSageProgramAddress(config)),
41
- };
42
- return getCreateContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
47
+ const rawInstruction = await getCreateContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
48
+ return createFluentInstruction(rawInstruction);
43
49
  }
44
50
  /**
45
51
  * Creates an instruction to create a rental contract with fluent configuration.
52
+ * This unified version works with both @solana/kit and @solana/web3.js using strings for addresses.
46
53
  *
47
54
  * @example
48
55
  * ```typescript
49
- * // Use devnet defaults
50
- * const ix = await createContract(params);
51
- *
52
- * // Use mainnet configuration
53
- * const ix = await createContract(params).set({ network: 'mainnet' });
56
+ * // Works with any library - just use strings for addresses!
54
57
  *
55
- * // Override specific constants
56
- * const ix = await createContract(params).set({
57
- * network: 'mainnet',
58
- * gameId: 'custom-game-id...',
59
- * sageProgramAddress: 'custom-sage...'
58
+ * // Default returns @solana/kit format
59
+ * const kitInstruction = await createContract({
60
+ * owner: wallet, // Can be signer object or string
61
+ * fleet: "FleetAddress123...", // String address
62
+ * ownerProfile: "ProfileAddr...", // String address
63
+ * rate: 1000,
64
+ * durationMax: days(7),
65
+ * paymentsFreq: 'daily'
60
66
  * });
61
67
  *
62
- * // Chain configurations
63
- * const ix = await createContract(params)
64
- * .set({ network: 'devnet' })
65
- * .set({ gameId: 'override-game...' });
68
+ * // Convert to @solana/web3.js format using fluent interface
69
+ * const web3jsInstruction = await createContract({
70
+ * owner: wallet,
71
+ * fleet: "FleetAddress123...",
72
+ * ownerProfile: "ProfileAddr...",
73
+ * rate: 1000,
74
+ * durationMax: days(7),
75
+ * paymentsFreq: 'daily'
76
+ * }).web3js();
77
+ *
78
+ * // Chain configuration and format conversion
79
+ * const web3jsInstructionWithConfig = await createContract({
80
+ * owner: wallet,
81
+ * fleet: "FleetAddress123...",
82
+ * ownerProfile: "ProfileAddr...",
83
+ * rate: 1000,
84
+ * durationMax: days(7),
85
+ * paymentsFreq: 'daily'
86
+ * }).set({ programs: 'mainnet' }).web3js();
87
+ *
88
+ * // Use with your preferred Solana library
89
+ * const transaction = new Transaction().add(web3jsInstruction);
66
90
  * ```
67
91
  *
68
92
  * @param params The simplified parameters for creating a rental contract
69
93
  * @returns A ConfigSelector that can be configured with .set() or awaited directly
70
94
  */
71
95
  export function createContract(params) {
72
- return createConfigSelector((config) => _createContract(params, config));
73
- }
74
- /**
75
- * Export config selector for getCreateContractInstructionAsync
76
- */
77
- export function getCreateContractInstructionAsync(input, options) {
78
- return createConfigSelector(async (config) => {
79
- const instructionsModule = getModule('instructions');
80
- return instructionsModule.getCreateContractInstructionAsync(input, options);
81
- });
96
+ const baseSelector = createConfigSelector((config) => _createContract(params, config));
97
+ return createFluentConfigSelector(baseSelector);
82
98
  }
83
99
  //# sourceMappingURL=create.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAA0B,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;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,uBAAuB,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,8BAA8B,YAAY,oEAAoE,CAAC,CAAC;IAClI,CAAC;IAED,+CAA+C;IAC/C,MAAM,WAAW,GAAG,+BAA+B,CAAC,YAAY,CAAC,CAAC;IAElE,mEAAmE;IACnE,kFAAkF;IAClF,yBAAyB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAErD,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAE9E,uBAAuB;IACvB,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,UAAU,cAAc,CAAC,MAA4B;IACzD,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvF,OAAO,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAClD,CAAC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuwei-labs/srsly",
3
- "version": "2.0.0-beta.25",
3
+ "version": "2.0.0-beta.28",
4
4
  "description": "",
5
5
  "source": "./src/index.ts",
6
6
  "sideEffects": false,
@@ -38,7 +38,7 @@
38
38
  "devDependencies": {
39
39
  "@codama/nodes-from-anchor": "^1.1.13",
40
40
  "@codama/renderers": "^1.0.21",
41
- "@solana/web3.js": "^1.98.2",
41
+ "@solana/kit": "^2.0.0",
42
42
  "@types/node": "^24.0.3",
43
43
  "codama": "^1.2.13",
44
44
  "tsconfig-to-dual-package": "^1.2.0",
@@ -46,9 +46,5 @@
46
46
  "typescript": "^5.8.3",
47
47
  "vitest": "^3.2.4"
48
48
  },
49
- "dependencies": {
50
- "@solana/kit": "^2.1.0",
51
- "@wuwei-labs/srsly": "2.0.0-beta.12"
52
- },
53
49
  "type": "module"
54
50
  }
@@ -1,6 +1,7 @@
1
1
  import { getModule, createConfigSelector } from '../utils/config';
2
2
  import { getSageGameId, ATLAS_TO_STARDUST, toAddress } from '../utils/constants';
3
- import { deriveGameAccounts, } from '../utils';
3
+ import { deriveGameAccounts } from '../utils';
4
+ import { createFluentInstruction, createFluentConfigSelector } from '../utils/instruction-converter';
4
5
  /**
5
6
  * Internal function to accept a rental instruction with configuration options
6
7
  */
@@ -16,16 +17,16 @@ async function _acceptRental(params, config) {
16
17
  config);
17
18
  // Let codama derive the rest (rentalThread, rentalState, rentalAuthority, etc.)
18
19
  const input = {
19
- borrower,
20
- borrowerProfile: toAddress(borrowerProfile),
21
- borrowerProfileFaction: profileFaction,
22
- fleet: toAddress(fleet),
23
- contract: toAddress(contract),
24
- gameId: actualGameId,
25
- starbase,
26
- starbasePlayer,
27
- amount,
28
- duration,
20
+ borrower, // Pass as-is (string or signer)
21
+ borrowerProfile: toAddress(borrowerProfile), // Ensure string
22
+ borrowerProfileFaction: profileFaction, // Already string from deriveGameAccounts
23
+ fleet: toAddress(fleet), // Ensure string
24
+ contract: toAddress(contract), // Ensure string
25
+ gameId: actualGameId, // Already string
26
+ starbase, // Already string from deriveGameAccounts
27
+ starbasePlayer, // Already string from deriveGameAccounts
28
+ amount, // BigInt value
29
+ duration, // BigInt value
29
30
  referralTokenAccount: referralTokenAccount ? toAddress(referralTokenAccount) : undefined,
30
31
  };
31
32
  // Get network-specific codama functions from centralized config
@@ -33,51 +34,56 @@ async function _acceptRental(params, config) {
33
34
  const programsModule = getModule('programs');
34
35
  const { getAcceptRentalInstructionAsync } = instructionsModule;
35
36
  const { SRSLY_PROGRAM_ADDRESS } = programsModule;
36
- return getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
37
+ const rawInstruction = await getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
38
+ return createFluentInstruction(rawInstruction);
37
39
  }
38
40
  /**
39
41
  * Creates an instruction to accept a rental with fluent configuration.
40
42
  *
41
43
  * @example
42
44
  * ```typescript
43
- * // Use devnet defaults
44
- * const ix = await acceptRental({
45
- * borrower: wallet,
46
- * borrowerProfile: profileAddress,
47
- * borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
48
- * fleet: fleetAddress,
49
- * contract: contractAddress,
50
- * rate: 1000, // ATLAS tokens
51
- * duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
45
+ * // Works with any library - just use strings for addresses!
46
+ * const instruction = await acceptRental({
47
+ * borrower: wallet, // Can be signer object or string
48
+ * borrowerProfile: "ProfileAddr...", // String address
49
+ * borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
50
+ * fleet: "FleetAddress123...", // String address
51
+ * contract: "ContractAddr...", // String address
52
+ * rate: 1000, // ATLAS tokens
53
+ * duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
52
54
  * });
53
55
  *
54
56
  * // With referral (referrer gets 5% of platform fees)
55
- * const ix = await acceptRental({
57
+ * const instruction = await acceptRental({
56
58
  * borrower: wallet,
57
- * borrowerProfile: profileAddress,
59
+ * borrowerProfile: "ProfileAddr...",
58
60
  * borrowerFaction: 1,
59
- * fleet: fleetAddress,
60
- * contract: contractAddress,
61
+ * fleet: "FleetAddress123...",
62
+ * contract: "ContractAddr...",
61
63
  * rate: 1000,
62
64
  * duration: 86400,
63
- * referralTokenAccount: referrerTokenAddress
65
+ * referralTokenAccount: "ReferralAddr..."
64
66
  * });
65
67
  *
66
68
  * // Use mainnet configuration
67
- * const ix = await acceptRental(params).set({ network: 'mainnet' });
69
+ * const instruction = await acceptRental(params).set({ programs: 'mainnet' });
68
70
  *
69
71
  * // Override specific constants
70
- * const ix = await acceptRental(params).set({
71
- * network: 'mainnet',
72
+ * const instruction = await acceptRental(params).set({
73
+ * programs: 'mainnet',
72
74
  * gameId: 'custom-game-id...'
73
75
  * });
76
+ *
77
+ * // Use the instruction with your preferred Solana library
78
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
74
79
  * ```
75
80
  *
76
81
  * @param params The simplified parameters for accepting a rental
77
82
  * @returns A ConfigSelector that can be configured with .set() or awaited directly
78
83
  */
79
84
  export function acceptRental(params) {
80
- return createConfigSelector((config) => _acceptRental(params, config));
85
+ const baseSelector = createConfigSelector((config) => _acceptRental(params, config));
86
+ return createFluentConfigSelector(baseSelector);
81
87
  }
82
88
  export function getAcceptRentalInstructionAsync(input, options) {
83
89
  return createConfigSelector(async (config) => {
@@ -1 +1 @@
1
- {"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAKA,OAAO,EA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AS,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,MAAM,cAAc,GAAG,MAAM,+BAA+B,CAC1D,KAAY,EACZ,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;IACF,OAAO,uBAAuB,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;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,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,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,4 +1,5 @@
1
1
  import { getModule, createConfigSelector } from '../utils/config';
2
+ import { toAddress } from '../utils/constants';
2
3
  /**
3
4
  * Internal function to cancel a rental instruction with configuration options
4
5
  */
@@ -6,8 +7,8 @@ async function _cancelRental(params, config) {
6
7
  const { borrower, contract, } = params;
7
8
  // Let codama derive all the optional accounts
8
9
  const input = {
9
- borrower,
10
- contract,
10
+ borrower, // Pass as-is (string or signer)
11
+ contract: toAddress(contract), // Ensure string
11
12
  };
12
13
  // Get network-specific codama functions from centralized config
13
14
  const instructionsModule = getModule('instructions');
@@ -21,20 +22,23 @@ async function _cancelRental(params, config) {
21
22
  *
22
23
  * @example
23
24
  * ```typescript
24
- * // Use devnet defaults
25
- * const ix = await cancelRental({
26
- * borrower: wallet,
27
- * contract: contractAddress
25
+ * // Works with any library - just use strings for addresses!
26
+ * const instruction = await cancelRental({
27
+ * borrower: wallet, // Can be signer object or string
28
+ * contract: "ContractAddr..." // String address
28
29
  * });
29
30
  *
30
31
  * // Use mainnet configuration
31
- * const ix = await cancelRental(params).set({ network: 'mainnet' });
32
+ * const instruction = await cancelRental(params).set({ programs: 'mainnet' });
32
33
  *
33
34
  * // Override specific constants
34
- * const ix = await cancelRental(params).set({
35
- * network: 'mainnet',
35
+ * const instruction = await cancelRental(params).set({
36
+ * programs: 'mainnet',
36
37
  * sageProgramAddress: 'custom...'
37
38
  * });
39
+ *
40
+ * // Use the instruction with your preferred Solana library
41
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
38
42
  * ```
39
43
  *
40
44
  * @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":"AAKA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAoB3G;;GAEG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,8CAA8C;IAC9C,MAAM,KAAK,GAAG;QACZ,QAAQ;QACR,QAAQ;KACT,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;IA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,GAAG,cAAc,CAAC;IAEjD,OAAO,+BAA+B,CACpC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;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,MAAM,UAAU,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,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,4 +1,5 @@
1
1
  import { getModule, createConfigSelector } from '../utils/config';
2
+ import { toAddress } from '../utils/constants';
2
3
  /**
3
4
  * Internal function to close a rental instruction with configuration options
4
5
  */
@@ -6,9 +7,9 @@ async function _closeRental(params, config) {
6
7
  const { borrower, ownerTokenAccount, contract, } = params;
7
8
  // Let codama derive the optional accounts
8
9
  const input = {
9
- borrower,
10
- ownerTokenAccount,
11
- contract,
10
+ borrower: toAddress(borrower), // Ensure string
11
+ ownerTokenAccount: toAddress(ownerTokenAccount), // Ensure string
12
+ contract: toAddress(contract), // Ensure string
12
13
  };
13
14
  // Get network-specific codama functions from centralized config
14
15
  const instructionsModule = getModule('instructions');
@@ -22,21 +23,24 @@ async function _closeRental(params, config) {
22
23
  *
23
24
  * @example
24
25
  * ```typescript
25
- * // Use devnet defaults
26
- * const ix = await closeRental({
27
- * borrower: borrowerAddress,
28
- * ownerTokenAccount: ownerTokenAccountAddress,
29
- * contract: contractAddress
26
+ * // Works with any library - just use strings for addresses!
27
+ * const instruction = await closeRental({
28
+ * borrower: "BorrowerAddr...", // String address
29
+ * ownerTokenAccount: "TokenAcct...", // String address
30
+ * contract: "ContractAddr..." // String address
30
31
  * });
31
32
  *
32
33
  * // Use mainnet configuration
33
- * const ix = await closeRental(params).set({ network: 'mainnet' });
34
+ * const instruction = await closeRental(params).set({ programs: 'mainnet' });
34
35
  *
35
36
  * // Override specific constants
36
- * const ix = await closeRental(params).set({
37
- * network: 'mainnet',
37
+ * const instruction = await closeRental(params).set({
38
+ * programs: 'mainnet',
38
39
  * sageProgramAddress: 'custom...'
39
40
  * });
41
+ *
42
+ * // Use the instruction with your preferred Solana library
43
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
40
44
  * ```
41
45
  *
42
46
  * @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":"AAIA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAyB3G;;GAEG;AACH,KAAK,UAAU,YAAY,CACzB,MAAyB,EACzB,MAAsB;IAEtB,MAAM,EACJ,QAAQ,EACR,iBAAiB,EACjB,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,0CAA0C;IAC1C,MAAM,KAAK,GAAG;QACZ,QAAQ;QACR,iBAAiB;QACjB,QAAQ;KACT,CAAC;IAEF,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,SAAS,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,WAA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EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,WAAW,CACzB,MAAyB;IAEzB,OAAO,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,KAAU,EAAE,OAAa;IACtE,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import { getModule, createConfigSelector } from '../utils/config';
2
- import { getSageGameId } from '../utils/constants';
3
- import { deriveGameAccounts, } from '../utils';
2
+ import { getSageGameId, toAddress } from '../utils/constants';
3
+ import { deriveGameAccounts } from '../utils';
4
4
  /**
5
5
  * Internal function to reset a rental instruction with configuration options
6
6
  */
7
7
  async function _resetRental(params, config) {
8
8
  const { fleet, contract, rentalState, gameId, faction, ownerProfile, } = params;
9
9
  // Get the actual game ID to use (param override, config override, or network default)
10
- const actualGameId = gameId || await getSageGameId(config);
10
+ const actualGameId = gameId ? toAddress(gameId) : await getSageGameId(config);
11
11
  // Derive the three accounts we need
12
- const { starbase, starbasePlayer } = await deriveGameAccounts(ownerProfile, faction, actualGameId, 0, // starbaseSeqId
12
+ const { starbase, starbasePlayer } = await deriveGameAccounts(toAddress(ownerProfile), faction, actualGameId, 0, // starbaseSeqId
13
13
  config);
14
14
  // Get network-specific codama functions from centralized config
15
15
  const instructionsModule = getModule('instructions');
@@ -18,12 +18,12 @@ async function _resetRental(params, config) {
18
18
  const { SRSLY_PROGRAM_ADDRESS } = programsModule;
19
19
  // Let codama derive the rest (rentalAuthority)
20
20
  const input = {
21
- fleet,
22
- contract,
23
- rentalState,
24
- gameId: actualGameId,
25
- starbase,
26
- starbasePlayer,
21
+ fleet: toAddress(fleet), // Ensure string
22
+ contract: toAddress(contract), // Ensure string
23
+ rentalState: toAddress(rentalState), // Ensure string
24
+ gameId: actualGameId, // Already string
25
+ starbase, // Already string from deriveGameAccounts
26
+ starbasePlayer, // Already string from deriveGameAccounts
27
27
  };
28
28
  return getResetRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
29
29
  }
@@ -32,24 +32,27 @@ async function _resetRental(params, config) {
32
32
  *
33
33
  * @example
34
34
  * ```typescript
35
- * // Use devnet defaults
36
- * const ix = await resetRental({
37
- * fleet: fleetAddress,
38
- * contract: contractAddress,
39
- * rentalState: rentalStateAddress,
35
+ * // Works with any library - just use strings for addresses!
36
+ * const instruction = await resetRental({
37
+ * fleet: "FleetAddress123...", // String address
38
+ * contract: "ContractAddr...", // String address
39
+ * rentalState: "RentalStateAddr...", // String address
40
40
  * faction: 'mud',
41
- * ownerProfile: ownerProfileAddress
41
+ * ownerProfile: "OwnerProfileAddr..." // String address
42
42
  * });
43
43
  *
44
44
  * // Use mainnet configuration
45
- * const ix = await resetRental(params).set({ network: 'mainnet' });
45
+ * const instruction = await resetRental(params).set({ programs: 'mainnet' });
46
46
  *
47
47
  * // Override specific constants
48
- * const ix = await resetRental(params).set({
49
- * network: 'mainnet',
48
+ * const instruction = await resetRental(params).set({
49
+ * programs: 'mainnet',
50
50
  * gameId: 'custom-game-id...',
51
51
  * sageProgramAddress: 'custom...'
52
52
  * });
53
+ *
54
+ * // Use the instruction with your preferred Solana library
55
+ * // instruction is compatible with both @solana/kit and @solana/web3.js
53
56
  * ```
54
57
  *
55
58
  * @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":"AAIA,OAAO,EA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