@wuwei-labs/srsly 2.0.0-beta.2 → 2.0.0-beta.21
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 +305 -110
- package/dist/cjs/codama/accounts/config.js +88 -0
- package/dist/cjs/codama/accounts/config.js.map +1 -0
- package/dist/cjs/codama/accounts/contractState.js +17 -39
- package/dist/cjs/codama/accounts/contractState.js.map +1 -1
- package/dist/cjs/codama/accounts/index.js +1 -1
- package/dist/cjs/codama/accounts/index.js.map +1 -1
- package/dist/cjs/codama/accounts/rentalState.js +18 -33
- package/dist/cjs/codama/accounts/rentalState.js.map +1 -1
- package/dist/cjs/codama/accounts/thread.js +15 -32
- package/dist/cjs/codama/accounts/thread.js.map +1 -1
- package/dist/cjs/codama/errors/srsly.js +24 -3
- package/dist/cjs/codama/errors/srsly.js.map +1 -1
- package/dist/cjs/codama/instructions/acceptRental.js +202 -224
- package/dist/cjs/codama/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/codama/instructions/cancelRental.js +100 -136
- package/dist/cjs/codama/instructions/cancelRental.js.map +1 -1
- package/dist/cjs/codama/instructions/closeContract.js +95 -116
- package/dist/cjs/codama/instructions/closeContract.js.map +1 -1
- package/dist/cjs/codama/instructions/closeRental.js +119 -132
- package/dist/cjs/codama/instructions/closeRental.js.map +1 -1
- package/dist/cjs/codama/instructions/createContract.js +127 -143
- package/dist/cjs/codama/instructions/createContract.js.map +1 -1
- package/dist/cjs/codama/instructions/index.js +2 -1
- package/dist/cjs/codama/instructions/index.js.map +1 -1
- package/dist/cjs/codama/instructions/initializeConfig.js +131 -0
- package/dist/cjs/codama/instructions/initializeConfig.js.map +1 -0
- package/dist/cjs/codama/instructions/payRental.js +125 -129
- package/dist/cjs/codama/instructions/payRental.js.map +1 -1
- package/dist/cjs/codama/instructions/resetRental.js +55 -77
- package/dist/cjs/codama/instructions/resetRental.js.map +1 -1
- package/dist/cjs/codama/instructions/updateConfig.js +145 -0
- package/dist/cjs/codama/instructions/updateConfig.js.map +1 -0
- package/dist/cjs/codama/programs/srsly.js +12 -8
- package/dist/cjs/codama/programs/srsly.js.map +1 -1
- package/dist/cjs/codama/shared/index.js +6 -2
- package/dist/cjs/codama/shared/index.js.map +1 -1
- package/dist/cjs/codama/types/trigger.js +1 -1
- package/dist/cjs/codama/types/trigger.js.map +1 -1
- package/dist/cjs/codama/types/triggerContext.js +1 -1
- package/dist/cjs/codama/types/triggerContext.js.map +1 -1
- package/dist/cjs/contract/close.js +75 -34
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +59 -43
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +54 -0
- package/dist/cjs/rental/accept.js +68 -40
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +36 -28
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +37 -29
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +46 -42
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +319 -0
- package/dist/cjs/utils/config.js.map +1 -0
- package/dist/cjs/utils/constants.js +69 -9
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/profiles.js +96 -95
- package/dist/cjs/utils/profiles.js.map +1 -1
- package/dist/esm/codama/accounts/config.js +76 -0
- package/dist/esm/codama/accounts/config.js.map +1 -0
- package/dist/esm/codama/accounts/contractState.js +3 -7
- package/dist/esm/codama/accounts/contractState.js.map +1 -1
- package/dist/esm/codama/accounts/index.js +1 -1
- package/dist/esm/codama/accounts/index.js.map +1 -1
- package/dist/esm/codama/accounts/rentalState.js +3 -1
- package/dist/esm/codama/accounts/rentalState.js.map +1 -1
- package/dist/esm/codama/errors/srsly.js +23 -2
- package/dist/esm/codama/errors/srsly.js.map +1 -1
- package/dist/esm/codama/instructions/acceptRental.js +30 -39
- package/dist/esm/codama/instructions/acceptRental.js.map +1 -1
- package/dist/esm/codama/instructions/cancelRental.js +10 -33
- package/dist/esm/codama/instructions/cancelRental.js.map +1 -1
- package/dist/esm/codama/instructions/closeContract.js +17 -25
- package/dist/esm/codama/instructions/closeContract.js.map +1 -1
- package/dist/esm/codama/instructions/closeRental.js +19 -19
- package/dist/esm/codama/instructions/closeRental.js.map +1 -1
- package/dist/esm/codama/instructions/createContract.js +13 -16
- package/dist/esm/codama/instructions/createContract.js.map +1 -1
- package/dist/esm/codama/instructions/index.js +2 -1
- package/dist/esm/codama/instructions/index.js.map +1 -1
- package/dist/esm/codama/instructions/initializeConfig.js +121 -0
- package/dist/esm/codama/instructions/initializeConfig.js.map +1 -0
- package/dist/esm/codama/instructions/payRental.js +34 -25
- package/dist/esm/codama/instructions/payRental.js.map +1 -1
- package/dist/esm/codama/instructions/resetRental.js +0 -9
- package/dist/esm/codama/instructions/resetRental.js.map +1 -1
- package/dist/esm/codama/instructions/updateConfig.js +135 -0
- package/dist/esm/codama/instructions/updateConfig.js.map +1 -0
- package/dist/esm/codama/programs/srsly.js +12 -8
- package/dist/esm/codama/programs/srsly.js.map +1 -1
- package/dist/esm/contract/close.js +68 -16
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +60 -33
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +54 -0
- package/dist/esm/rental/accept.js +70 -31
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +37 -18
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +38 -19
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +48 -33
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +277 -0
- package/dist/esm/utils/config.js.map +1 -0
- package/dist/esm/utils/constants.js +60 -7
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/profiles.js +39 -19
- package/dist/esm/utils/profiles.js.map +1 -1
- package/dist/types/codama/accounts/config.d.ts +52 -0
- package/dist/types/codama/accounts/config.d.ts.map +1 -0
- package/dist/types/codama/accounts/contractState.d.ts +2 -4
- package/dist/types/codama/accounts/contractState.d.ts.map +1 -1
- package/dist/types/codama/accounts/index.d.ts +1 -1
- package/dist/types/codama/accounts/index.d.ts.map +1 -1
- package/dist/types/codama/accounts/rentalState.d.ts +2 -0
- package/dist/types/codama/accounts/rentalState.d.ts.map +1 -1
- package/dist/types/codama/errors/srsly.d.ts +16 -2
- package/dist/types/codama/errors/srsly.d.ts.map +1 -1
- package/dist/types/codama/instructions/acceptRental.d.ts +41 -34
- package/dist/types/codama/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/cancelRental.d.ts +14 -10
- package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/closeContract.d.ts +29 -21
- package/dist/types/codama/instructions/closeContract.d.ts.map +1 -1
- package/dist/types/codama/instructions/closeRental.d.ts +20 -12
- package/dist/types/codama/instructions/closeRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/createContract.d.ts +27 -23
- package/dist/types/codama/instructions/createContract.d.ts.map +1 -1
- package/dist/types/codama/instructions/index.d.ts +2 -1
- package/dist/types/codama/instructions/index.d.ts.map +1 -1
- package/dist/types/codama/instructions/initializeConfig.d.ts +60 -0
- package/dist/types/codama/instructions/initializeConfig.d.ts.map +1 -0
- package/dist/types/codama/instructions/payRental.d.ts +28 -13
- package/dist/types/codama/instructions/payRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/resetRental.d.ts +3 -3
- package/dist/types/codama/instructions/resetRental.d.ts.map +1 -1
- package/dist/types/codama/instructions/updateConfig.d.ts +93 -0
- package/dist/types/codama/instructions/updateConfig.d.ts.map +1 -0
- package/dist/types/codama/programs/srsly.d.ts +11 -8
- package/dist/types/codama/programs/srsly.d.ts.map +1 -1
- package/dist/types/contract/close.d.ts +20 -24
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +34 -22
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +42 -20
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +16 -11
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +16 -11
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +17 -20
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +167 -0
- package/dist/types/utils/config.d.ts.map +1 -0
- package/dist/types/utils/constants.d.ts +23 -7
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/profiles.d.ts +14 -8
- package/dist/types/utils/profiles.d.ts.map +1 -1
- package/package.json +36 -14
- package/target/idl/srsly.json +3279 -0
- package/target/types/srsly.ts +1 -0
- package/dist/cjs/codama/accounts/fleet.js +0 -94
- package/dist/cjs/codama/accounts/fleet.js.map +0 -1
- package/dist/cjs/codama/instructions/normalizeAdmin.js +0 -165
- package/dist/cjs/codama/instructions/normalizeAdmin.js.map +0 -1
- package/dist/esm/codama/accounts/fleet.js +0 -64
- package/dist/esm/codama/accounts/fleet.js.map +0 -1
- package/dist/esm/codama/instructions/normalizeAdmin.js +0 -142
- package/dist/esm/codama/instructions/normalizeAdmin.js.map +0 -1
- package/dist/types/codama/accounts/fleet.d.ts +0 -38
- package/dist/types/codama/accounts/fleet.d.ts.map +0 -1
- package/dist/types/codama/instructions/normalizeAdmin.d.ts +0 -67
- package/dist/types/codama/instructions/normalizeAdmin.d.ts.map +0 -1
|
@@ -1,49 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
+
import { getSageGameId, ATLAS_TO_STARDUST, toAddress } from '../utils/constants';
|
|
3
|
+
import { deriveGameAccounts, } from '../utils';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
5
|
+
* Internal function to accept a rental instruction with configuration options
|
|
6
|
+
*/
|
|
7
|
+
async function _acceptRental(params, config) {
|
|
8
|
+
const { borrower, borrowerProfile, borrowerFaction, fleet, contract, gameId, rate, duration, referralTokenAccount, } = params;
|
|
9
|
+
// Get the actual game ID to use (param override, config override, or network default)
|
|
10
|
+
const actualGameId = gameId ? toAddress(gameId) : await getSageGameId(config);
|
|
11
|
+
// Calculate the total amount from rate and duration
|
|
12
|
+
// Convert ATLAS to stardust (smallest unit): 1 ATLAS = 100,000,000 stardust
|
|
13
|
+
const amount = BigInt(rate) * BigInt(duration) * BigInt(ATLAS_TO_STARDUST);
|
|
14
|
+
// Derive the three accounts we need
|
|
15
|
+
const { profileFaction, starbase, starbasePlayer } = await deriveGameAccounts(toAddress(borrowerProfile), borrowerFaction, actualGameId, 0, // starbaseSeqId
|
|
16
|
+
config);
|
|
17
|
+
// Let codama derive the rest (rentalThread, rentalState, rentalAuthority, etc.)
|
|
18
|
+
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,
|
|
29
|
+
referralTokenAccount: referralTokenAccount ? toAddress(referralTokenAccount) : undefined,
|
|
30
|
+
};
|
|
31
|
+
// Get network-specific codama functions from centralized config
|
|
32
|
+
const instructionsModule = getModule('instructions');
|
|
33
|
+
const programsModule = getModule('programs');
|
|
34
|
+
const { getAcceptRentalInstructionAsync } = instructionsModule;
|
|
35
|
+
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
36
|
+
return getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates an instruction to accept a rental with fluent configuration.
|
|
6
40
|
*
|
|
7
41
|
* @example
|
|
8
42
|
* ```typescript
|
|
9
|
-
* //
|
|
43
|
+
* // Use devnet defaults
|
|
10
44
|
* const ix = await acceptRental({
|
|
11
45
|
* borrower: wallet,
|
|
12
46
|
* borrowerProfile: profileAddress,
|
|
13
47
|
* borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
|
|
14
48
|
* fleet: fleetAddress,
|
|
15
49
|
* contract: contractAddress,
|
|
16
|
-
*
|
|
17
|
-
* duration: 86400 // 1 day in seconds
|
|
18
|
-
* // gameId is optional and will default to the standard game ID
|
|
50
|
+
* rate: 1000, // ATLAS tokens
|
|
51
|
+
* duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
|
|
19
52
|
* });
|
|
20
53
|
*
|
|
21
|
-
* //
|
|
22
|
-
* const
|
|
23
|
-
*
|
|
54
|
+
* // With referral (referrer gets 5% of platform fees)
|
|
55
|
+
* const ix = await acceptRental({
|
|
56
|
+
* borrower: wallet,
|
|
57
|
+
* borrowerProfile: profileAddress,
|
|
58
|
+
* borrowerFaction: 1,
|
|
59
|
+
* fleet: fleetAddress,
|
|
60
|
+
* contract: contractAddress,
|
|
61
|
+
* rate: 1000,
|
|
62
|
+
* duration: 86400,
|
|
63
|
+
* referralTokenAccount: referrerTokenAddress
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* // Use mainnet configuration
|
|
67
|
+
* const ix = await acceptRental(params).set({ network: 'mainnet' });
|
|
68
|
+
*
|
|
69
|
+
* // Override specific constants
|
|
70
|
+
* const ix = await acceptRental(params).set({
|
|
71
|
+
* network: 'mainnet',
|
|
72
|
+
* gameId: 'custom-game-id...'
|
|
73
|
+
* });
|
|
24
74
|
* ```
|
|
25
75
|
*
|
|
26
76
|
* @param params The simplified parameters for accepting a rental
|
|
27
|
-
* @returns A
|
|
77
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
28
78
|
*/
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
borrowerProfileFaction: profileFaction,
|
|
38
|
-
fleet,
|
|
39
|
-
contract,
|
|
40
|
-
gameId,
|
|
41
|
-
starbase,
|
|
42
|
-
starbasePlayer,
|
|
43
|
-
amount,
|
|
44
|
-
duration,
|
|
45
|
-
};
|
|
46
|
-
return getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
79
|
+
export function acceptRental(params) {
|
|
80
|
+
return createConfigSelector((config) => _acceptRental(params, config));
|
|
81
|
+
}
|
|
82
|
+
export function getAcceptRentalInstructionAsync(input, options) {
|
|
83
|
+
return createConfigSelector(async (config) => {
|
|
84
|
+
const instructionsModule = getModule('instructions');
|
|
85
|
+
return instructionsModule.getAcceptRentalInstructionAsync(input, options);
|
|
86
|
+
});
|
|
47
87
|
}
|
|
48
|
-
export { getAcceptRentalInstructionAsync };
|
|
49
88
|
//# sourceMappingURL=accept.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,aAA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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,OAAO,+BAA+B,CACpC,KAAY,EACZ,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;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,33 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Internal function to cancel a rental instruction with configuration options
|
|
4
|
+
*/
|
|
5
|
+
async function _cancelRental(params, config) {
|
|
6
|
+
const { borrower, contract, } = params;
|
|
7
|
+
// Let codama derive all the optional accounts
|
|
8
|
+
const input = {
|
|
9
|
+
borrower,
|
|
10
|
+
contract,
|
|
11
|
+
};
|
|
12
|
+
// Get network-specific codama functions from centralized config
|
|
13
|
+
const instructionsModule = getModule('instructions');
|
|
14
|
+
const programsModule = getModule('programs');
|
|
15
|
+
const { getCancelRentalInstructionAsync } = instructionsModule;
|
|
16
|
+
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
17
|
+
return getCancelRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an instruction to cancel a rental with fluent configuration.
|
|
6
21
|
*
|
|
7
22
|
* @example
|
|
8
23
|
* ```typescript
|
|
9
|
-
* //
|
|
24
|
+
* // Use devnet defaults
|
|
10
25
|
* const ix = await cancelRental({
|
|
11
26
|
* borrower: wallet,
|
|
12
27
|
* contract: contractAddress
|
|
13
28
|
* });
|
|
14
29
|
*
|
|
15
|
-
* //
|
|
16
|
-
* const
|
|
17
|
-
*
|
|
30
|
+
* // Use mainnet configuration
|
|
31
|
+
* const ix = await cancelRental(params).set({ network: 'mainnet' });
|
|
32
|
+
*
|
|
33
|
+
* // Override specific constants
|
|
34
|
+
* const ix = await cancelRental(params).set({
|
|
35
|
+
* network: 'mainnet',
|
|
36
|
+
* sageProgramAddress: 'custom...'
|
|
37
|
+
* });
|
|
18
38
|
* ```
|
|
19
39
|
*
|
|
20
40
|
* @param params The simplified parameters for canceling a rental
|
|
21
|
-
* @returns A
|
|
41
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
22
42
|
*/
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
export function cancelRental(params) {
|
|
44
|
+
return createConfigSelector((config) => _cancelRental(params, config));
|
|
45
|
+
}
|
|
46
|
+
export function getCancelRentalInstructionAsync(input, options) {
|
|
47
|
+
return createConfigSelector(async (config) => {
|
|
48
|
+
const instructionsModule = getModule('instructions');
|
|
49
|
+
return instructionsModule.getCancelRentalInstructionAsync(input, options);
|
|
50
|
+
});
|
|
31
51
|
}
|
|
32
|
-
export { getCancelRentalInstructionAsync };
|
|
33
52
|
//# sourceMappingURL=cancel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
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;IAEjD,OAAO,+BAA+B,CACpC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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"}
|
package/dist/esm/rental/close.js
CHANGED
|
@@ -1,35 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
* Internal function to close a rental instruction with configuration options
|
|
4
|
+
*/
|
|
5
|
+
async function _closeRental(params, config) {
|
|
6
|
+
const { borrower, ownerTokenAccount, contract, } = params;
|
|
7
|
+
// Let codama derive the optional accounts
|
|
8
|
+
const input = {
|
|
9
|
+
borrower,
|
|
10
|
+
ownerTokenAccount,
|
|
11
|
+
contract,
|
|
12
|
+
};
|
|
13
|
+
// Get network-specific codama functions from centralized config
|
|
14
|
+
const instructionsModule = getModule('instructions');
|
|
15
|
+
const programsModule = getModule('programs');
|
|
16
|
+
const { getCloseRentalInstructionAsync } = instructionsModule;
|
|
17
|
+
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
18
|
+
return getCloseRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instruction to close a rental with fluent configuration.
|
|
6
22
|
*
|
|
7
23
|
* @example
|
|
8
24
|
* ```typescript
|
|
9
|
-
* //
|
|
25
|
+
* // Use devnet defaults
|
|
10
26
|
* const ix = await closeRental({
|
|
11
27
|
* borrower: borrowerAddress,
|
|
12
28
|
* ownerTokenAccount: ownerTokenAccountAddress,
|
|
13
29
|
* contract: contractAddress
|
|
14
30
|
* });
|
|
15
31
|
*
|
|
16
|
-
* //
|
|
17
|
-
* const
|
|
18
|
-
*
|
|
32
|
+
* // Use mainnet configuration
|
|
33
|
+
* const ix = await closeRental(params).set({ network: 'mainnet' });
|
|
34
|
+
*
|
|
35
|
+
* // Override specific constants
|
|
36
|
+
* const ix = await closeRental(params).set({
|
|
37
|
+
* network: 'mainnet',
|
|
38
|
+
* sageProgramAddress: 'custom...'
|
|
39
|
+
* });
|
|
19
40
|
* ```
|
|
20
41
|
*
|
|
21
42
|
* @param params The simplified parameters for closing a rental
|
|
22
|
-
* @returns A
|
|
43
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
23
44
|
*/
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
return getCloseRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
45
|
+
export function closeRental(params) {
|
|
46
|
+
return createConfigSelector((config) => _closeRental(params, config));
|
|
47
|
+
}
|
|
48
|
+
export function getCloseRentalInstructionAsync(input, options) {
|
|
49
|
+
return createConfigSelector(async (config) => {
|
|
50
|
+
const instructionsModule = getModule('instructions');
|
|
51
|
+
return instructionsModule.getCloseRentalInstructionAsync(input, options);
|
|
52
|
+
});
|
|
33
53
|
}
|
|
34
|
-
export { getCloseRentalInstructionAsync };
|
|
35
54
|
//# sourceMappingURL=close.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
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,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"}
|
package/dist/esm/rental/reset.js
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
+
import { getSageGameId } from '../utils/constants';
|
|
3
|
+
import { deriveGameAccounts, } from '../utils';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* Internal function to reset a rental instruction with configuration options
|
|
6
|
+
*/
|
|
7
|
+
async function _resetRental(params, config) {
|
|
8
|
+
const { fleet, contract, rentalState, gameId, faction, ownerProfile, } = params;
|
|
9
|
+
// Get the actual game ID to use (param override, config override, or network default)
|
|
10
|
+
const actualGameId = gameId || await getSageGameId(config);
|
|
11
|
+
// Derive the three accounts we need
|
|
12
|
+
const { starbase, starbasePlayer } = await deriveGameAccounts(ownerProfile, faction, actualGameId, 0, // starbaseSeqId
|
|
13
|
+
config);
|
|
14
|
+
// Get network-specific codama functions from centralized config
|
|
15
|
+
const instructionsModule = getModule('instructions');
|
|
16
|
+
const programsModule = getModule('programs');
|
|
17
|
+
const { getResetRentalInstructionAsync } = instructionsModule;
|
|
18
|
+
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
19
|
+
// Let codama derive the rest (rentalAuthority)
|
|
20
|
+
const input = {
|
|
21
|
+
fleet,
|
|
22
|
+
contract,
|
|
23
|
+
rentalState,
|
|
24
|
+
gameId: actualGameId,
|
|
25
|
+
starbase,
|
|
26
|
+
starbasePlayer,
|
|
27
|
+
};
|
|
28
|
+
return getResetRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instruction to reset a rental with fluent configuration.
|
|
7
32
|
*
|
|
8
33
|
* @example
|
|
9
34
|
* ```typescript
|
|
10
|
-
* //
|
|
35
|
+
* // Use devnet defaults
|
|
11
36
|
* const ix = await resetRental({
|
|
12
37
|
* fleet: fleetAddress,
|
|
13
38
|
* contract: contractAddress,
|
|
@@ -16,37 +41,27 @@ import { DEFAULT_GAME_ID, deriveGameAccounts, } from '../utils';
|
|
|
16
41
|
* ownerProfile: ownerProfileAddress
|
|
17
42
|
* });
|
|
18
43
|
*
|
|
19
|
-
* //
|
|
20
|
-
* const ix = await resetRental({
|
|
21
|
-
* fleet: fleetAddress,
|
|
22
|
-
* contract: contractAddress,
|
|
23
|
-
* rentalState: rentalStateAddress,
|
|
24
|
-
* starbase: starbaseAddress,
|
|
25
|
-
* starbasePlayer: starbasePlayerAddress
|
|
26
|
-
* });
|
|
44
|
+
* // Use mainnet configuration
|
|
45
|
+
* const ix = await resetRental(params).set({ network: 'mainnet' });
|
|
27
46
|
*
|
|
28
|
-
* //
|
|
29
|
-
* const
|
|
30
|
-
*
|
|
47
|
+
* // Override specific constants
|
|
48
|
+
* const ix = await resetRental(params).set({
|
|
49
|
+
* network: 'mainnet',
|
|
50
|
+
* gameId: 'custom-game-id...',
|
|
51
|
+
* sageProgramAddress: 'custom...'
|
|
52
|
+
* });
|
|
31
53
|
* ```
|
|
32
54
|
*
|
|
33
55
|
* @param params The simplified parameters for resetting a rental
|
|
34
|
-
* @returns A
|
|
56
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
35
57
|
*/
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
rentalState,
|
|
45
|
-
gameId,
|
|
46
|
-
starbase,
|
|
47
|
-
starbasePlayer,
|
|
48
|
-
};
|
|
49
|
-
return getResetRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
58
|
+
export function resetRental(params) {
|
|
59
|
+
return createConfigSelector((config) => _resetRental(params, config));
|
|
60
|
+
}
|
|
61
|
+
export function getResetRentalInstructionAsync(input, options) {
|
|
62
|
+
return createConfigSelector(async (config) => {
|
|
63
|
+
const instructionsModule = getModule('instructions');
|
|
64
|
+
return instructionsModule.getResetRentalInstructionAsync(input, options);
|
|
65
|
+
});
|
|
50
66
|
}
|
|
51
|
-
export { getResetRentalInstructionAsync };
|
|
52
67
|
//# sourceMappingURL=reset.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,OAAO,EACL,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAyClB;;GAEG;AACH,K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