@wuwei-labs/srsly 2.0.0-beta.4 → 2.0.0-beta.5
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 +214 -68
- package/dist/cjs/codama/devnet/constants.js +32 -0
- package/dist/cjs/codama/devnet/constants.js.map +1 -0
- package/dist/cjs/codama/mainnet/constants.js +32 -0
- package/dist/cjs/codama/mainnet/constants.js.map +1 -0
- package/dist/cjs/contract/close.js +51 -19
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +31 -19
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/rental/accept.js +46 -33
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +30 -24
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +31 -25
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +40 -38
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +204 -0
- package/dist/cjs/utils/config.js.map +1 -0
- package/dist/cjs/utils/constants.js +66 -13
- 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 +38 -18
- package/dist/cjs/utils/profiles.js.map +1 -1
- package/dist/esm/codama/devnet/constants.js +29 -0
- package/dist/esm/codama/devnet/constants.js.map +1 -0
- package/dist/esm/codama/mainnet/constants.js +29 -0
- package/dist/esm/codama/mainnet/constants.js.map +1 -0
- package/dist/esm/contract/close.js +52 -20
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +31 -19
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/rental/accept.js +47 -34
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +30 -24
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +31 -25
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +41 -39
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +161 -0
- package/dist/esm/utils/config.js.map +1 -0
- package/dist/esm/utils/constants.js +60 -10
- 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/devnet/constants.d.ts +33 -0
- package/dist/types/codama/devnet/constants.d.ts.map +1 -0
- package/dist/types/codama/mainnet/constants.d.ts +33 -0
- package/dist/types/codama/mainnet/constants.d.ts.map +1 -0
- package/dist/types/contract/close.d.ts +20 -5
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +23 -13
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +35 -6
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +27 -3
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +28 -3
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +32 -4
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +112 -0
- package/dist/types/utils/config.d.ts.map +1 -0
- package/dist/types/utils/constants.d.ts +9 -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 +4 -2
- package/dist/cjs/network.js +0 -107
- package/dist/cjs/network.js.map +0 -1
- package/dist/esm/network.js +0 -67
- package/dist/esm/network.js.map +0 -1
- package/dist/types/network.d.ts +0 -58
- package/dist/types/network.d.ts.map +0 -1
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createContract = createContract;
|
|
4
4
|
exports.getCreateContractInstructionAsync = getCreateContractInstructionAsync;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const config_1 = require("../utils/config");
|
|
6
|
+
const constants_1 = require("../utils/constants");
|
|
7
7
|
/**
|
|
8
|
-
* Internal function to create a contract instruction
|
|
8
|
+
* Internal function to create a contract instruction with configuration options
|
|
9
9
|
*/
|
|
10
|
-
async function _createContract(params,
|
|
11
|
-
const { owner, fleet, ownerProfile, rate, durationMin, durationMax, paymentsFreq, ownerKeyIndex = 0, gameId
|
|
10
|
+
async function _createContract(params, config) {
|
|
11
|
+
const { owner, fleet, ownerProfile, rate, durationMin, durationMax, paymentsFreq, ownerKeyIndex = 0, gameId, } = params;
|
|
12
|
+
// Get the actual game ID to use (param override, config override, or network default)
|
|
13
|
+
const actualGameId = gameId || await (0, constants_1.getSageGameId)(config);
|
|
12
14
|
// Dynamically import network-specific codama functions
|
|
13
|
-
const codamaModule = await (0,
|
|
15
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
14
16
|
const { getCreateContractInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
15
17
|
// Let codama derive the rest (contract, rentalAuthority, ownerTokenAccount, etc.)
|
|
16
18
|
const input = {
|
|
17
19
|
owner,
|
|
18
20
|
fleet,
|
|
19
21
|
ownerProfile,
|
|
20
|
-
gameId,
|
|
22
|
+
gameId: actualGameId,
|
|
21
23
|
rate,
|
|
22
24
|
durationMin,
|
|
23
25
|
durationMax,
|
|
@@ -27,31 +29,41 @@ async function _createContract(params, network) {
|
|
|
27
29
|
return getCreateContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
|
-
* Creates an instruction to create a rental contract with fluent
|
|
32
|
+
* Creates an instruction to create a rental contract with fluent configuration.
|
|
31
33
|
*
|
|
32
34
|
* @example
|
|
33
35
|
* ```typescript
|
|
34
|
-
* // Use
|
|
35
|
-
* const ix = await createContract(params)
|
|
36
|
+
* // Use devnet defaults
|
|
37
|
+
* const ix = await createContract(params);
|
|
36
38
|
*
|
|
37
|
-
* // Use
|
|
38
|
-
* const ix = await createContract(params).mainnet
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* // Use mainnet configuration
|
|
40
|
+
* const ix = await createContract(params).set({ network: 'mainnet' });
|
|
41
|
+
*
|
|
42
|
+
* // Override specific constants
|
|
43
|
+
* const ix = await createContract(params).set({
|
|
44
|
+
* network: 'mainnet',
|
|
45
|
+
* gameId: 'custom-game-id...',
|
|
46
|
+
* sageProgramAddress: 'custom-sage...'
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Chain configurations
|
|
50
|
+
* const ix = await createContract(params)
|
|
51
|
+
* .set({ network: 'devnet' })
|
|
52
|
+
* .set({ gameId: 'override-game...' });
|
|
41
53
|
* ```
|
|
42
54
|
*
|
|
43
55
|
* @param params The simplified parameters for creating a rental contract
|
|
44
|
-
* @returns A
|
|
56
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
45
57
|
*/
|
|
46
58
|
function createContract(params) {
|
|
47
|
-
return (0,
|
|
59
|
+
return (0, config_1.createConfigSelector)((config) => _createContract(params, config));
|
|
48
60
|
}
|
|
49
61
|
/**
|
|
50
|
-
* Export
|
|
62
|
+
* Export config selector for getCreateContractInstructionAsync
|
|
51
63
|
*/
|
|
52
64
|
function getCreateContractInstructionAsync(input, options) {
|
|
53
|
-
return (0,
|
|
54
|
-
const codamaModule = await (0,
|
|
65
|
+
return (0, config_1.createConfigSelector)(async (config) => {
|
|
66
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
55
67
|
return codamaModule.getCreateContractInstructionAsync(input, options);
|
|
56
68
|
});
|
|
57
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":";;AAuIA,wCAIC;AAKD,8EAKC;AAhJD,4CAAwH;AACxH,kDAAmD;AAyDnD;;GAEG;AACH,KAAK,UAAU,eAAe,CAC5B,MAA4B,EAC5B,MAAsB;IAEtB,MAAM,EACJ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,GAAG,CAAC,EACjB,MAAM,GACP,GAAG,MAAM,CAAC;IAEX,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,IAAI,MAAM,IAAA,yBAAa,EAAC,MAAM,CAAC,CAAC;IAE3D,uDAAuD;IACvD,MAAM,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,MAAM,EAAE,iCAAiC,EAAE,qBAAqB,EAAE,GAAG,YAAY,CAAC;IAElF,kFAAkF;IAClF,MAAM,KAAK,GAAG;QACZ,KAAK;QACL,KAAK;QACL,YAAY;QACZ,MAAM,EAAE,YAAY;QACpB,IAAI;QACJ,WAAW;QACX,WAAW;QACX,WAAW,EAAE,YAAY;QACzB,aAAa;KACd,CAAC;IAEF,OAAO,iCAAiC,CACtC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,cAAc,CAC5B,MAA4B;IAE5B,OAAO,IAAA,6BAAoB,EAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,KAAU,EAAE,OAAa;IACzE,OAAO,IAAA,6BAAoB,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,YAAY,CAAC,iCAAiC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,8 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// Export network configuration
|
|
18
|
-
__exportStar(require("./network"), exports);
|
|
19
17
|
// Export main SDK functions
|
|
20
18
|
__exportStar(require("./contract"), exports);
|
|
21
19
|
__exportStar(require("./rental"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4BAA4B;AAC5B,6CAA2B;AAC3B,2CAAyB;AACzB,0CAAwB"}
|
|
@@ -2,38 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.acceptRental = acceptRental;
|
|
4
4
|
exports.getAcceptRentalInstructionAsync = getAcceptRentalInstructionAsync;
|
|
5
|
-
const
|
|
5
|
+
const config_1 = require("../utils/config");
|
|
6
|
+
const constants_1 = require("../utils/constants");
|
|
6
7
|
const utils_1 = require("../utils");
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Derives borrowerProfileFaction, starbase, and starbasePlayer automatically.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // Create the instruction with automatic account derivation
|
|
14
|
-
* const ix = await acceptRental({
|
|
15
|
-
* borrower: wallet,
|
|
16
|
-
* borrowerProfile: profileAddress,
|
|
17
|
-
* borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
|
|
18
|
-
* fleet: fleetAddress,
|
|
19
|
-
* contract: contractAddress,
|
|
20
|
-
* amount: 1000,
|
|
21
|
-
* duration: 86400 // 1 day in seconds
|
|
22
|
-
* // gameId is optional and will default to the standard game ID
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* // Add to transaction and sign
|
|
26
|
-
* const tx = new Transaction().add(ix);
|
|
27
|
-
* await sendAndConfirmTransaction(connection, tx, [wallet]);
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @param params The simplified parameters for accepting a rental
|
|
31
|
-
* @returns A promise that resolves to the instruction to accept a rental
|
|
9
|
+
* Internal function to accept a rental instruction with configuration options
|
|
32
10
|
*/
|
|
33
|
-
async function _acceptRental(params,
|
|
34
|
-
const { borrower, borrowerProfile, borrowerFaction, fleet, contract, gameId
|
|
11
|
+
async function _acceptRental(params, config) {
|
|
12
|
+
const { borrower, borrowerProfile, borrowerFaction, fleet, contract, gameId, rate, duration, } = params;
|
|
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);
|
|
15
|
+
// Calculate the total amount from rate and duration
|
|
16
|
+
// Convert ATLAS to stardust (smallest unit): 1 ATLAS = 100,000,000 stardust
|
|
17
|
+
const amount = BigInt(rate) * BigInt(duration) * BigInt(constants_1.ATLAS_TO_STARDUST);
|
|
35
18
|
// Derive the three accounts we need
|
|
36
|
-
const { profileFaction, starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(borrowerProfile, borrowerFaction,
|
|
19
|
+
const { profileFaction, starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(borrowerProfile, borrowerFaction, actualGameId, 0, // starbaseSeqId
|
|
20
|
+
config);
|
|
37
21
|
// Let codama derive the rest (rentalThread, rentalState, rentalAuthority, etc.)
|
|
38
22
|
const input = {
|
|
39
23
|
borrower,
|
|
@@ -41,23 +25,52 @@ async function _acceptRental(params, network) {
|
|
|
41
25
|
borrowerProfileFaction: profileFaction,
|
|
42
26
|
fleet,
|
|
43
27
|
contract,
|
|
44
|
-
gameId,
|
|
28
|
+
gameId: actualGameId,
|
|
45
29
|
starbase,
|
|
46
30
|
starbasePlayer,
|
|
47
31
|
amount,
|
|
48
32
|
duration,
|
|
49
33
|
};
|
|
50
34
|
// Dynamically import network-specific codama functions
|
|
51
|
-
const codamaModule = await (0,
|
|
35
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
52
36
|
const { getAcceptRentalInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
53
37
|
return getAcceptRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
54
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an instruction to accept a rental with fluent configuration.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Use devnet defaults
|
|
45
|
+
* const ix = await acceptRental({
|
|
46
|
+
* borrower: wallet,
|
|
47
|
+
* borrowerProfile: profileAddress,
|
|
48
|
+
* borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
|
|
49
|
+
* fleet: fleetAddress,
|
|
50
|
+
* contract: contractAddress,
|
|
51
|
+
* rate: 1000, // ATLAS tokens
|
|
52
|
+
* duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // Use mainnet configuration
|
|
56
|
+
* const ix = await acceptRental(params).set({ network: 'mainnet' });
|
|
57
|
+
*
|
|
58
|
+
* // Override specific constants
|
|
59
|
+
* const ix = await acceptRental(params).set({
|
|
60
|
+
* network: 'mainnet',
|
|
61
|
+
* gameId: 'custom-game-id...'
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param params The simplified parameters for accepting a rental
|
|
66
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
67
|
+
*/
|
|
55
68
|
function acceptRental(params) {
|
|
56
|
-
return (0,
|
|
69
|
+
return (0, config_1.createConfigSelector)((config) => _acceptRental(params, config));
|
|
57
70
|
}
|
|
58
71
|
function getAcceptRentalInstructionAsync(input, options) {
|
|
59
|
-
return (0,
|
|
60
|
-
const codamaModule = await (0,
|
|
72
|
+
return (0, config_1.createConfigSelector)(async (config) => {
|
|
73
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
61
74
|
return codamaModule.getAcceptRentalInstructionAsync(input, options);
|
|
62
75
|
});
|
|
63
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":";;AA0JA,oCAIC;AAED,0EAKC;AAhKD,4CAAwH;AACxH,kDAAsE;AAMtE,oCAEkB;AAiDlB;;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,GACT,GAAG,MAAM,CAAC;IAEX,sFAAsF;IACtF,MAAM,YAAY,GAAG,MAAM,IAAI,MAAM,IAAA,yBAAa,EAAC,MAAM,CAAC,CAAC;IAE3D,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,eAAe,EACf,eAAe,EACf,YAA+B,EAC/B,CAAC,EAAE,gBAAgB;IACnB,MAAM,CACP,CAAC;IAEF,gFAAgF;IAChF,MAAM,KAAK,GAAoC;QAC7C,QAAQ;QACR,eAAe;QACf,sBAAsB,EAAE,cAAc;QACtC,KAAK;QACL,QAAQ;QACR,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,cAAc;QACd,MAAM;QACN,QAAQ;KACT,CAAC;IAEF,uDAAuD;IACvD,MAAM,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,MAAM,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,GAAG,YAAY,CAAC;IAEhF,OAAO,+BAA+B,CACpC,KAAY,EACZ,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,YAAY,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,46 +2,52 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cancelRental = cancelRental;
|
|
4
4
|
exports.getCancelRentalInstructionAsync = getCancelRentalInstructionAsync;
|
|
5
|
-
const
|
|
5
|
+
const config_1 = require("../utils/config");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
* Internal function to cancel a rental instruction with configuration options
|
|
8
|
+
*/
|
|
9
|
+
async function _cancelRental(params, config) {
|
|
10
|
+
const { borrower, contract, } = params;
|
|
11
|
+
// Let codama derive all the optional accounts
|
|
12
|
+
const input = {
|
|
13
|
+
borrower,
|
|
14
|
+
contract,
|
|
15
|
+
};
|
|
16
|
+
// Dynamically import network-specific codama functions
|
|
17
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
18
|
+
const { getCancelRentalInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
19
|
+
return getCancelRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instruction to cancel a rental with fluent configuration.
|
|
10
23
|
*
|
|
11
24
|
* @example
|
|
12
25
|
* ```typescript
|
|
13
|
-
* //
|
|
26
|
+
* // Use devnet defaults
|
|
14
27
|
* const ix = await cancelRental({
|
|
15
28
|
* borrower: wallet,
|
|
16
29
|
* contract: contractAddress
|
|
17
30
|
* });
|
|
18
31
|
*
|
|
19
|
-
* //
|
|
20
|
-
* const
|
|
21
|
-
*
|
|
32
|
+
* // Use mainnet configuration
|
|
33
|
+
* const ix = await cancelRental(params).set({ network: 'mainnet' });
|
|
34
|
+
*
|
|
35
|
+
* // Override specific constants
|
|
36
|
+
* const ix = await cancelRental(params).set({
|
|
37
|
+
* network: 'mainnet',
|
|
38
|
+
* sageProgramAddress: 'custom...'
|
|
39
|
+
* });
|
|
22
40
|
* ```
|
|
23
41
|
*
|
|
24
42
|
* @param params The simplified parameters for canceling a rental
|
|
25
|
-
* @returns A
|
|
43
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
26
44
|
*/
|
|
27
|
-
async function _cancelRental(params, network) {
|
|
28
|
-
const { borrower, contract, } = params;
|
|
29
|
-
// Let codama derive all the optional accounts
|
|
30
|
-
const input = {
|
|
31
|
-
borrower,
|
|
32
|
-
contract,
|
|
33
|
-
};
|
|
34
|
-
// Dynamically import network-specific codama functions
|
|
35
|
-
const codamaModule = await (0, network_1.getCachedNetworkModule)('instructions');
|
|
36
|
-
const { getCancelRentalInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
37
|
-
return getCancelRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
38
|
-
}
|
|
39
45
|
function cancelRental(params) {
|
|
40
|
-
return (0,
|
|
46
|
+
return (0, config_1.createConfigSelector)((config) => _cancelRental(params, config));
|
|
41
47
|
}
|
|
42
48
|
function getCancelRentalInstructionAsync(input, options) {
|
|
43
|
-
return (0,
|
|
44
|
-
const codamaModule = await (0,
|
|
49
|
+
return (0, config_1.createConfigSelector)(async (config) => {
|
|
50
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
45
51
|
return codamaModule.getCancelRentalInstructionAsync(input, options);
|
|
46
52
|
});
|
|
47
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":";;AA6EA,oCAIC;AAED,0EAKC;AAnFD,4CAAwH;AAoBxH;;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,uDAAuD;IACvD,MAAM,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,MAAM,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,GAAG,YAAY,CAAC;IAEhF,OAAO,+BAA+B,CACpC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,YAAY,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cjs/rental/close.js
CHANGED
|
@@ -2,48 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.closeRental = closeRental;
|
|
4
4
|
exports.getCloseRentalInstructionAsync = getCloseRentalInstructionAsync;
|
|
5
|
-
const
|
|
5
|
+
const config_1 = require("../utils/config");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
* Internal function to close a rental instruction with configuration options
|
|
8
|
+
*/
|
|
9
|
+
async function _closeRental(params, config) {
|
|
10
|
+
const { borrower, ownerTokenAccount, contract, } = params;
|
|
11
|
+
// Let codama derive the optional accounts
|
|
12
|
+
const input = {
|
|
13
|
+
borrower,
|
|
14
|
+
ownerTokenAccount,
|
|
15
|
+
contract,
|
|
16
|
+
};
|
|
17
|
+
// Dynamically import network-specific codama functions
|
|
18
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
19
|
+
const { getCloseRentalInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
20
|
+
return getCloseRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instruction to close a rental with fluent configuration.
|
|
10
24
|
*
|
|
11
25
|
* @example
|
|
12
26
|
* ```typescript
|
|
13
|
-
* //
|
|
27
|
+
* // Use devnet defaults
|
|
14
28
|
* const ix = await closeRental({
|
|
15
29
|
* borrower: borrowerAddress,
|
|
16
30
|
* ownerTokenAccount: ownerTokenAccountAddress,
|
|
17
31
|
* contract: contractAddress
|
|
18
32
|
* });
|
|
19
33
|
*
|
|
20
|
-
* //
|
|
21
|
-
* const
|
|
22
|
-
*
|
|
34
|
+
* // Use mainnet configuration
|
|
35
|
+
* const ix = await closeRental(params).set({ network: 'mainnet' });
|
|
36
|
+
*
|
|
37
|
+
* // Override specific constants
|
|
38
|
+
* const ix = await closeRental(params).set({
|
|
39
|
+
* network: 'mainnet',
|
|
40
|
+
* sageProgramAddress: 'custom...'
|
|
41
|
+
* });
|
|
23
42
|
* ```
|
|
24
43
|
*
|
|
25
44
|
* @param params The simplified parameters for closing a rental
|
|
26
|
-
* @returns A
|
|
45
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
27
46
|
*/
|
|
28
|
-
async function _closeRental(params, network) {
|
|
29
|
-
const { borrower, ownerTokenAccount, contract, } = params;
|
|
30
|
-
// Let codama derive the optional accounts
|
|
31
|
-
const input = {
|
|
32
|
-
borrower,
|
|
33
|
-
ownerTokenAccount,
|
|
34
|
-
contract,
|
|
35
|
-
};
|
|
36
|
-
// Dynamically import network-specific codama functions
|
|
37
|
-
const codamaModule = await (0, network_1.getCachedNetworkModule)('instructions');
|
|
38
|
-
const { getCloseRentalInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
39
|
-
return getCloseRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
40
|
-
}
|
|
41
47
|
function closeRental(params) {
|
|
42
|
-
return (0,
|
|
48
|
+
return (0, config_1.createConfigSelector)((config) => _closeRental(params, config));
|
|
43
49
|
}
|
|
44
50
|
function getCloseRentalInstructionAsync(input, options) {
|
|
45
|
-
return (0,
|
|
46
|
-
const codamaModule = await (0,
|
|
51
|
+
return (0, config_1.createConfigSelector)(async (config) => {
|
|
52
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
47
53
|
return codamaModule.getCloseRentalInstructionAsync(input, options);
|
|
48
54
|
});
|
|
49
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":";;AAoFA,kCAIC;AAED,wEAKC;AA3FD,4CAAwH;AAyBxH;;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,uDAAuD;IACvD,MAAM,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,MAAM,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,GAAG,YAAY,CAAC;IAE/E,OAAO,8BAA8B,CACnC,KAAK,EACL,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;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,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,YAAY,CAAC,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cjs/rental/reset.js
CHANGED
|
@@ -2,16 +2,39 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resetRental = resetRental;
|
|
4
4
|
exports.getResetRentalInstructionAsync = getResetRentalInstructionAsync;
|
|
5
|
-
const
|
|
5
|
+
const config_1 = require("../utils/config");
|
|
6
|
+
const constants_1 = require("../utils/constants");
|
|
6
7
|
const utils_1 = require("../utils");
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
* Internal function to reset a rental instruction with configuration options
|
|
10
|
+
*/
|
|
11
|
+
async function _resetRental(params, config) {
|
|
12
|
+
const { fleet, contract, rentalState, gameId, faction, ownerProfile, } = params;
|
|
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);
|
|
15
|
+
// Derive the three accounts we need
|
|
16
|
+
const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(ownerProfile, faction, actualGameId, 0, // starbaseSeqId
|
|
17
|
+
config);
|
|
18
|
+
// Dynamically import network-specific codama functions
|
|
19
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
20
|
+
const { getResetRentalInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
21
|
+
// Let codama derive the rest (rentalAuthority)
|
|
22
|
+
const input = {
|
|
23
|
+
fleet,
|
|
24
|
+
contract,
|
|
25
|
+
rentalState,
|
|
26
|
+
gameId: actualGameId,
|
|
27
|
+
starbase,
|
|
28
|
+
starbasePlayer,
|
|
29
|
+
};
|
|
30
|
+
return getResetRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates an instruction to reset a rental with fluent configuration.
|
|
11
34
|
*
|
|
12
35
|
* @example
|
|
13
36
|
* ```typescript
|
|
14
|
-
* //
|
|
37
|
+
* // Use devnet defaults
|
|
15
38
|
* const ix = await resetRental({
|
|
16
39
|
* fleet: fleetAddress,
|
|
17
40
|
* contract: contractAddress,
|
|
@@ -20,47 +43,26 @@ const utils_1 = require("../utils");
|
|
|
20
43
|
* ownerProfile: ownerProfileAddress
|
|
21
44
|
* });
|
|
22
45
|
*
|
|
23
|
-
* //
|
|
24
|
-
* const ix = await resetRental({
|
|
25
|
-
* fleet: fleetAddress,
|
|
26
|
-
* contract: contractAddress,
|
|
27
|
-
* rentalState: rentalStateAddress,
|
|
28
|
-
* starbase: starbaseAddress,
|
|
29
|
-
* starbasePlayer: starbasePlayerAddress
|
|
30
|
-
* });
|
|
46
|
+
* // Use mainnet configuration
|
|
47
|
+
* const ix = await resetRental(params).set({ network: 'mainnet' });
|
|
31
48
|
*
|
|
32
|
-
* //
|
|
33
|
-
* const
|
|
34
|
-
*
|
|
49
|
+
* // Override specific constants
|
|
50
|
+
* const ix = await resetRental(params).set({
|
|
51
|
+
* network: 'mainnet',
|
|
52
|
+
* gameId: 'custom-game-id...',
|
|
53
|
+
* sageProgramAddress: 'custom...'
|
|
54
|
+
* });
|
|
35
55
|
* ```
|
|
36
56
|
*
|
|
37
57
|
* @param params The simplified parameters for resetting a rental
|
|
38
|
-
* @returns A
|
|
58
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
39
59
|
*/
|
|
40
|
-
async function _resetRental(params, network) {
|
|
41
|
-
const { fleet, contract, rentalState, gameId = utils_1.DEFAULT_GAME_ID, faction, ownerProfile, } = params;
|
|
42
|
-
// Derive the three accounts we need
|
|
43
|
-
const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(ownerProfile, faction, gameId);
|
|
44
|
-
// Dynamically import network-specific codama functions
|
|
45
|
-
const codamaModule = await (0, network_1.getCachedNetworkModule)('instructions');
|
|
46
|
-
const { getResetRentalInstructionAsync, SRSLY_PROGRAM_ADDRESS } = codamaModule;
|
|
47
|
-
// Let codama derive the rest (rentalAuthority)
|
|
48
|
-
const input = {
|
|
49
|
-
fleet,
|
|
50
|
-
contract,
|
|
51
|
-
rentalState,
|
|
52
|
-
gameId,
|
|
53
|
-
starbase,
|
|
54
|
-
starbasePlayer,
|
|
55
|
-
};
|
|
56
|
-
return getResetRentalInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
57
|
-
}
|
|
58
60
|
function resetRental(params) {
|
|
59
|
-
return (0,
|
|
61
|
+
return (0, config_1.createConfigSelector)((config) => _resetRental(params, config));
|
|
60
62
|
}
|
|
61
63
|
function getResetRentalInstructionAsync(input, options) {
|
|
62
|
-
return (0,
|
|
63
|
-
const codamaModule = await (0,
|
|
64
|
+
return (0, config_1.createConfigSelector)(async (config) => {
|
|
65
|
+
const codamaModule = await (0, config_1.getCachedNetworkModule)('instructions', config?.network);
|
|
64
66
|
return codamaModule.getResetRentalInstructionAsync(input, options);
|
|
65
67
|
});
|
|
66
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":";;AAoIA,kCAIC;AAED,wEAKC;AA3ID,4CAAwH;AACxH,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,uDAAuD;IACvD,MAAM,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,MAAM,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,GAAG,YAAY,CAAC;IAE/E,+CAA+C;IAC/C,MAAM,KAAK,GAAG;QACZ,KAAK;QACL,QAAQ;QACR,WAAW;QACX,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,cAAc;KACf,CAAC;IAEF,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,YAAY,GAAG,MAAM,IAAA,+BAAsB,EAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,YAAY,CAAC,8BAA8B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC"}
|