@wuwei-labs/srsly 1.0.0-beta.1
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 +33 -0
- package/dist/cjs/codama/accounts/contractState.js +92 -0
- package/dist/cjs/codama/accounts/contractState.js.map +1 -0
- package/dist/cjs/codama/accounts/fleet.js +77 -0
- package/dist/cjs/codama/accounts/fleet.js.map +1 -0
- package/dist/cjs/codama/accounts/index.js +28 -0
- package/dist/cjs/codama/accounts/index.js.map +1 -0
- package/dist/cjs/codama/accounts/rentalState.js +85 -0
- package/dist/cjs/codama/accounts/rentalState.js.map +1 -0
- package/dist/cjs/codama/accounts/thread.js +89 -0
- package/dist/cjs/codama/accounts/thread.js.map +1 -0
- package/dist/cjs/codama/errors/index.js +25 -0
- package/dist/cjs/codama/errors/index.js.map +1 -0
- package/dist/cjs/codama/errors/srsly.js +71 -0
- package/dist/cjs/codama/errors/srsly.js.map +1 -0
- package/dist/cjs/codama/index.js +29 -0
- package/dist/cjs/codama/index.js.map +1 -0
- package/dist/cjs/codama/instructions/acceptRental.js +363 -0
- package/dist/cjs/codama/instructions/acceptRental.js.map +1 -0
- package/dist/cjs/codama/instructions/cancelRental.js +225 -0
- package/dist/cjs/codama/instructions/cancelRental.js.map +1 -0
- package/dist/cjs/codama/instructions/closeContract.js +219 -0
- package/dist/cjs/codama/instructions/closeContract.js.map +1 -0
- package/dist/cjs/codama/instructions/closeRental.js +233 -0
- package/dist/cjs/codama/instructions/closeRental.js.map +1 -0
- package/dist/cjs/codama/instructions/createContract.js +261 -0
- package/dist/cjs/codama/instructions/createContract.js.map +1 -0
- package/dist/cjs/codama/instructions/index.js +32 -0
- package/dist/cjs/codama/instructions/index.js.map +1 -0
- package/dist/cjs/codama/instructions/normalizeAdmin.js +152 -0
- package/dist/cjs/codama/instructions/normalizeAdmin.js.map +1 -0
- package/dist/cjs/codama/instructions/payRental.js +236 -0
- package/dist/cjs/codama/instructions/payRental.js.map +1 -0
- package/dist/cjs/codama/instructions/resetRental.js +155 -0
- package/dist/cjs/codama/instructions/resetRental.js.map +1 -0
- package/dist/cjs/codama/programs/index.js +25 -0
- package/dist/cjs/codama/programs/index.js.map +1 -0
- package/dist/cjs/codama/programs/srsly.js +77 -0
- package/dist/cjs/codama/programs/srsly.js.map +1 -0
- package/dist/cjs/codama/shared/index.js +95 -0
- package/dist/cjs/codama/shared/index.js.map +1 -0
- package/dist/cjs/codama/types/clockData.js +31 -0
- package/dist/cjs/codama/types/clockData.js.map +1 -0
- package/dist/cjs/codama/types/equality.js +30 -0
- package/dist/cjs/codama/types/equality.js.map +1 -0
- package/dist/cjs/codama/types/execContext.js +38 -0
- package/dist/cjs/codama/types/execContext.js.map +1 -0
- package/dist/cjs/codama/types/index.js +33 -0
- package/dist/cjs/codama/types/index.js.map +1 -0
- package/dist/cjs/codama/types/paymentFrequency.js +34 -0
- package/dist/cjs/codama/types/paymentFrequency.js.map +1 -0
- package/dist/cjs/codama/types/serializableAccount.js +31 -0
- package/dist/cjs/codama/types/serializableAccount.js.map +1 -0
- package/dist/cjs/codama/types/serializableInstruction.js +32 -0
- package/dist/cjs/codama/types/serializableInstruction.js.map +1 -0
- package/dist/cjs/codama/types/threadResponse.js +38 -0
- package/dist/cjs/codama/types/threadResponse.js.map +1 -0
- package/dist/cjs/codama/types/trigger.js +90 -0
- package/dist/cjs/codama/types/trigger.js.map +1 -0
- package/dist/cjs/codama/types/triggerContext.js +49 -0
- package/dist/cjs/codama/types/triggerContext.js.map +1 -0
- package/dist/cjs/contract/close.js +48 -0
- package/dist/cjs/contract/close.js.map +1 -0
- package/dist/cjs/contract/create.js +49 -0
- package/dist/cjs/contract/create.js.map +1 -0
- package/dist/cjs/contract/index.js +19 -0
- package/dist/cjs/contract/index.js.map +1 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/rental/accept.js +53 -0
- package/dist/cjs/rental/accept.js.map +1 -0
- package/dist/cjs/rental/cancel.js +37 -0
- package/dist/cjs/rental/cancel.js.map +1 -0
- package/dist/cjs/rental/close.js +39 -0
- package/dist/cjs/rental/close.js.map +1 -0
- package/dist/cjs/rental/index.js +21 -0
- package/dist/cjs/rental/index.js.map +1 -0
- package/dist/cjs/rental/reset.js +56 -0
- package/dist/cjs/rental/reset.js.map +1 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/constants.js +34 -0
- package/dist/cjs/utils/constants.js.map +1 -0
- package/dist/cjs/utils/index.js +19 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/profiles.js +139 -0
- package/dist/cjs/utils/profiles.js.map +1 -0
- package/dist/esm/codama/accounts/contractState.js +79 -0
- package/dist/esm/codama/accounts/contractState.js.map +1 -0
- package/dist/esm/codama/accounts/fleet.js +64 -0
- package/dist/esm/codama/accounts/fleet.js.map +1 -0
- package/dist/esm/codama/accounts/index.js +12 -0
- package/dist/esm/codama/accounts/index.js.map +1 -0
- package/dist/esm/codama/accounts/rentalState.js +72 -0
- package/dist/esm/codama/accounts/rentalState.js.map +1 -0
- package/dist/esm/codama/accounts/thread.js +77 -0
- package/dist/esm/codama/accounts/thread.js.map +1 -0
- package/dist/esm/codama/errors/index.js +9 -0
- package/dist/esm/codama/errors/index.js.map +1 -0
- package/dist/esm/codama/errors/srsly.js +66 -0
- package/dist/esm/codama/errors/srsly.js.map +1 -0
- package/dist/esm/codama/index.js +13 -0
- package/dist/esm/codama/index.js.map +1 -0
- package/dist/esm/codama/instructions/acceptRental.js +353 -0
- package/dist/esm/codama/instructions/acceptRental.js.map +1 -0
- package/dist/esm/codama/instructions/cancelRental.js +215 -0
- package/dist/esm/codama/instructions/cancelRental.js.map +1 -0
- package/dist/esm/codama/instructions/closeContract.js +209 -0
- package/dist/esm/codama/instructions/closeContract.js.map +1 -0
- package/dist/esm/codama/instructions/closeRental.js +223 -0
- package/dist/esm/codama/instructions/closeRental.js.map +1 -0
- package/dist/esm/codama/instructions/createContract.js +251 -0
- package/dist/esm/codama/instructions/createContract.js.map +1 -0
- package/dist/esm/codama/instructions/index.js +16 -0
- package/dist/esm/codama/instructions/index.js.map +1 -0
- package/dist/esm/codama/instructions/normalizeAdmin.js +142 -0
- package/dist/esm/codama/instructions/normalizeAdmin.js.map +1 -0
- package/dist/esm/codama/instructions/payRental.js +226 -0
- package/dist/esm/codama/instructions/payRental.js.map +1 -0
- package/dist/esm/codama/instructions/resetRental.js +145 -0
- package/dist/esm/codama/instructions/resetRental.js.map +1 -0
- package/dist/esm/codama/programs/index.js +9 -0
- package/dist/esm/codama/programs/index.js.map +1 -0
- package/dist/esm/codama/programs/srsly.js +72 -0
- package/dist/esm/codama/programs/srsly.js.map +1 -0
- package/dist/esm/codama/shared/index.js +87 -0
- package/dist/esm/codama/shared/index.js.map +1 -0
- package/dist/esm/codama/types/clockData.js +26 -0
- package/dist/esm/codama/types/clockData.js.map +1 -0
- package/dist/esm/codama/types/equality.js +24 -0
- package/dist/esm/codama/types/equality.js.map +1 -0
- package/dist/esm/codama/types/execContext.js +33 -0
- package/dist/esm/codama/types/execContext.js.map +1 -0
- package/dist/esm/codama/types/index.js +17 -0
- package/dist/esm/codama/types/index.js.map +1 -0
- package/dist/esm/codama/types/paymentFrequency.js +28 -0
- package/dist/esm/codama/types/paymentFrequency.js.map +1 -0
- package/dist/esm/codama/types/serializableAccount.js +26 -0
- package/dist/esm/codama/types/serializableAccount.js.map +1 -0
- package/dist/esm/codama/types/serializableInstruction.js +27 -0
- package/dist/esm/codama/types/serializableInstruction.js.map +1 -0
- package/dist/esm/codama/types/threadResponse.js +33 -0
- package/dist/esm/codama/types/threadResponse.js.map +1 -0
- package/dist/esm/codama/types/trigger.js +83 -0
- package/dist/esm/codama/types/trigger.js.map +1 -0
- package/dist/esm/codama/types/triggerContext.js +42 -0
- package/dist/esm/codama/types/triggerContext.js.map +1 -0
- package/dist/esm/contract/close.js +44 -0
- package/dist/esm/contract/close.js.map +1 -0
- package/dist/esm/contract/create.js +45 -0
- package/dist/esm/contract/create.js.map +1 -0
- package/dist/esm/contract/index.js +3 -0
- package/dist/esm/contract/index.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/rental/accept.js +49 -0
- package/dist/esm/rental/accept.js.map +1 -0
- package/dist/esm/rental/cancel.js +33 -0
- package/dist/esm/rental/cancel.js.map +1 -0
- package/dist/esm/rental/close.js +35 -0
- package/dist/esm/rental/close.js.map +1 -0
- package/dist/esm/rental/index.js +5 -0
- package/dist/esm/rental/index.js.map +1 -0
- package/dist/esm/rental/reset.js +52 -0
- package/dist/esm/rental/reset.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/constants.js +30 -0
- package/dist/esm/utils/constants.js.map +1 -0
- package/dist/esm/utils/index.js +3 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/profiles.js +132 -0
- package/dist/esm/utils/profiles.js.map +1 -0
- package/dist/types/codama/accounts/contractState.d.ts +53 -0
- package/dist/types/codama/accounts/contractState.d.ts.map +1 -0
- package/dist/types/codama/accounts/fleet.d.ts +38 -0
- package/dist/types/codama/accounts/fleet.d.ts.map +1 -0
- package/dist/types/codama/accounts/index.d.ts +12 -0
- package/dist/types/codama/accounts/index.d.ts.map +1 -0
- package/dist/types/codama/accounts/rentalState.d.ts +46 -0
- package/dist/types/codama/accounts/rentalState.d.ts.map +1 -0
- package/dist/types/codama/accounts/thread.d.ts +74 -0
- package/dist/types/codama/accounts/thread.d.ts.map +1 -0
- package/dist/types/codama/errors/index.d.ts +9 -0
- package/dist/types/codama/errors/index.d.ts.map +1 -0
- package/dist/types/codama/errors/srsly.d.ts +48 -0
- package/dist/types/codama/errors/srsly.d.ts.map +1 -0
- package/dist/types/codama/index.d.ts +13 -0
- package/dist/types/codama/index.d.ts.map +1 -0
- package/dist/types/codama/instructions/acceptRental.d.ts +128 -0
- package/dist/types/codama/instructions/acceptRental.d.ts.map +1 -0
- package/dist/types/codama/instructions/cancelRental.d.ts +71 -0
- package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -0
- package/dist/types/codama/instructions/closeContract.d.ts +96 -0
- package/dist/types/codama/instructions/closeContract.d.ts.map +1 -0
- package/dist/types/codama/instructions/closeRental.d.ts +79 -0
- package/dist/types/codama/instructions/closeRental.d.ts.map +1 -0
- package/dist/types/codama/instructions/createContract.d.ts +108 -0
- package/dist/types/codama/instructions/createContract.d.ts.map +1 -0
- package/dist/types/codama/instructions/index.d.ts +16 -0
- package/dist/types/codama/instructions/index.d.ts.map +1 -0
- package/dist/types/codama/instructions/normalizeAdmin.d.ts +67 -0
- package/dist/types/codama/instructions/normalizeAdmin.d.ts.map +1 -0
- package/dist/types/codama/instructions/payRental.d.ts +99 -0
- package/dist/types/codama/instructions/payRental.d.ts.map +1 -0
- package/dist/types/codama/instructions/resetRental.d.ts +71 -0
- package/dist/types/codama/instructions/resetRental.d.ts.map +1 -0
- package/dist/types/codama/programs/index.d.ts +9 -0
- package/dist/types/codama/programs/index.d.ts.map +1 -0
- package/dist/types/codama/programs/srsly.d.ts +50 -0
- package/dist/types/codama/programs/srsly.d.ts.map +1 -0
- package/dist/types/codama/shared/index.d.ts +50 -0
- package/dist/types/codama/shared/index.d.ts.map +1 -0
- package/dist/types/codama/types/clockData.d.ts +29 -0
- package/dist/types/codama/types/clockData.d.ts.map +1 -0
- package/dist/types/codama/types/equality.d.ts +18 -0
- package/dist/types/codama/types/equality.d.ts.map +1 -0
- package/dist/types/codama/types/execContext.d.ts +48 -0
- package/dist/types/codama/types/execContext.d.ts.map +1 -0
- package/dist/types/codama/types/index.d.ts +17 -0
- package/dist/types/codama/types/index.d.ts.map +1 -0
- package/dist/types/codama/types/paymentFrequency.d.ts +22 -0
- package/dist/types/codama/types/paymentFrequency.d.ts.map +1 -0
- package/dist/types/codama/types/serializableAccount.d.ts +22 -0
- package/dist/types/codama/types/serializableAccount.d.ts.map +1 -0
- package/dist/types/codama/types/serializableInstruction.d.ts +30 -0
- package/dist/types/codama/types/serializableInstruction.d.ts.map +1 -0
- package/dist/types/codama/types/threadResponse.d.ts +42 -0
- package/dist/types/codama/types/threadResponse.d.ts.map +1 -0
- package/dist/types/codama/types/trigger.d.ts +98 -0
- package/dist/types/codama/types/trigger.d.ts.map +1 -0
- package/dist/types/codama/types/triggerContext.d.ts +75 -0
- package/dist/types/codama/types/triggerContext.d.ts.map +1 -0
- package/dist/types/contract/close.d.ts +56 -0
- package/dist/types/contract/close.d.ts.map +1 -0
- package/dist/types/contract/create.d.ts +73 -0
- package/dist/types/contract/create.d.ts.map +1 -0
- package/dist/types/contract/index.d.ts +3 -0
- package/dist/types/contract/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rental/accept.d.ts +70 -0
- package/dist/types/rental/accept.d.ts.map +1 -0
- package/dist/types/rental/cancel.d.ts +39 -0
- package/dist/types/rental/cancel.d.ts.map +1 -0
- package/dist/types/rental/close.d.ts +44 -0
- package/dist/types/rental/close.d.ts.map +1 -0
- package/dist/types/rental/index.d.ts +5 -0
- package/dist/types/rental/index.d.ts.map +1 -0
- package/dist/types/rental/reset.d.ts +71 -0
- package/dist/types/rental/reset.d.ts.map +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/constants.d.ts +21 -0
- package/dist/types/utils/constants.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/profiles.d.ts +48 -0
- package/dist/types/utils/profiles.d.ts.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAcceptRentalInstructionAsync = void 0;
|
|
4
|
+
exports.acceptRental = acceptRental;
|
|
5
|
+
const codama_1 = require("../codama");
|
|
6
|
+
Object.defineProperty(exports, "getAcceptRentalInstructionAsync", { enumerable: true, get: function () { return codama_1.getAcceptRentalInstructionAsync; } });
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
/**
|
|
9
|
+
* Asynchronously creates an instruction to accept a rental with minimal required parameters.
|
|
10
|
+
* Derives borrowerProfileFaction, starbase, and starbasePlayer automatically.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Create the instruction with automatic account derivation
|
|
15
|
+
* const ix = await acceptRental({
|
|
16
|
+
* borrower: wallet,
|
|
17
|
+
* borrowerProfile: profileAddress,
|
|
18
|
+
* borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
|
|
19
|
+
* fleet: fleetAddress,
|
|
20
|
+
* contract: contractAddress,
|
|
21
|
+
* amount: 1000,
|
|
22
|
+
* duration: 86400 // 1 day in seconds
|
|
23
|
+
* // gameId is optional and will default to the standard game ID
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Add to transaction and sign
|
|
27
|
+
* const tx = new Transaction().add(ix);
|
|
28
|
+
* await sendAndConfirmTransaction(connection, tx, [wallet]);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param params The simplified parameters for accepting a rental
|
|
32
|
+
* @returns A promise that resolves to the instruction to accept a rental
|
|
33
|
+
*/
|
|
34
|
+
async function acceptRental(params) {
|
|
35
|
+
const { borrower, borrowerProfile, borrowerFaction, fleet, contract, gameId = utils_1.DEFAULT_GAME_ID, amount, duration, } = params;
|
|
36
|
+
// Derive the three accounts we need
|
|
37
|
+
const { profileFaction, starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(borrowerProfile, borrowerFaction, gameId);
|
|
38
|
+
// Let codama derive the rest (rentalThread, rentalState, rentalAuthority, etc.)
|
|
39
|
+
const input = {
|
|
40
|
+
borrower,
|
|
41
|
+
borrowerProfile,
|
|
42
|
+
borrowerProfileFaction: profileFaction,
|
|
43
|
+
fleet,
|
|
44
|
+
contract,
|
|
45
|
+
gameId,
|
|
46
|
+
starbase,
|
|
47
|
+
starbasePlayer,
|
|
48
|
+
amount,
|
|
49
|
+
duration,
|
|
50
|
+
};
|
|
51
|
+
return (0, codama_1.getAcceptRentalInstructionAsync)(input, { programAddress: codama_1.SRSLY_PROGRAM_ADDRESS });
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=accept.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":";;;AA0FA,oCA2CC;AAhID,sCAKmB;AA6HV,gHA/HP,wCAA+B,OA+HO;AA3HxC,oCAGkB;AAiDlB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,KAAK,UAAU,YAAY,CAChC,MAA0B;IAE1B,MAAM,EACJ,QAAQ,EACR,eAAe,EACf,eAAe,EACf,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,uBAAkC,EAC3C,MAAM,EACN,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,oCAAoC;IACpC,MAAM,EACJ,cAAc,EACd,QAAQ,EACR,cAAc,EACf,GAAG,MAAM,IAAA,0BAAkB,EAC1B,eAAe,EACf,eAAe,EACf,MAAM,CACP,CAAC;IAEF,gFAAgF;IAChF,MAAM,KAAK,GAAoC;QAC7C,QAAQ;QACR,eAAe;QACf,sBAAsB,EAAE,cAAc;QACtC,KAAK;QACL,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,cAAc;QACd,MAAM;QACN,QAAQ;KACT,CAAC;IAEF,OAAO,IAAA,wCAA+B,EACpC,KAAY,EACZ,EAAE,cAAc,EAAE,8BAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCancelRentalInstructionAsync = void 0;
|
|
4
|
+
exports.cancelRental = cancelRental;
|
|
5
|
+
const codama_1 = require("../codama");
|
|
6
|
+
Object.defineProperty(exports, "getCancelRentalInstructionAsync", { enumerable: true, get: function () { return codama_1.getCancelRentalInstructionAsync; } });
|
|
7
|
+
/**
|
|
8
|
+
* Asynchronously creates an instruction to cancel a rental with minimal required parameters.
|
|
9
|
+
* Derives rentalState, rentalThread, borrowerTokenAccount, rentalTokenAccount and
|
|
10
|
+
* rentalAuthority automatically if not provided.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Create the instruction with minimal parameters - just borrower and contract
|
|
15
|
+
* const ix = await cancelRental({
|
|
16
|
+
* borrower: wallet,
|
|
17
|
+
* contract: contractAddress
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Add to transaction and sign
|
|
21
|
+
* const tx = new Transaction().add(ix);
|
|
22
|
+
* await sendAndConfirmTransaction(connection, tx, [wallet]);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param params The simplified parameters for canceling a rental
|
|
26
|
+
* @returns A promise that resolves to the instruction to cancel a rental
|
|
27
|
+
*/
|
|
28
|
+
async function cancelRental(params) {
|
|
29
|
+
const { borrower, contract, } = params;
|
|
30
|
+
// Let codama derive all the optional accounts
|
|
31
|
+
const input = {
|
|
32
|
+
borrower,
|
|
33
|
+
contract,
|
|
34
|
+
};
|
|
35
|
+
return (0, codama_1.getCancelRentalInstructionAsync)(input, { programAddress: codama_1.SRSLY_PROGRAM_ADDRESS });
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=cancel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":";;;AA+CA,oCAkBC;AA5DD,sCAImB;AA0DV,gHA5DP,wCAA+B,OA4DO;AAzCxC;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,YAAY,CAChC,MAA0B;IAE1B,MAAM,EACJ,QAAQ,EACR,QAAQ,GACT,GAAG,MAAM,CAAC;IAEX,8CAA8C;IAC9C,MAAM,KAAK,GAAG;QACZ,QAAQ;QACR,QAAQ;KACT,CAAC;IAEF,OAAO,IAAA,wCAA+B,EACpC,KAAK,EACL,EAAE,cAAc,EAAE,8BAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCloseRentalInstructionAsync = void 0;
|
|
4
|
+
exports.closeRental = closeRental;
|
|
5
|
+
const codama_1 = require("../codama");
|
|
6
|
+
Object.defineProperty(exports, "getCloseRentalInstructionAsync", { enumerable: true, get: function () { return codama_1.getCloseRentalInstructionAsync; } });
|
|
7
|
+
/**
|
|
8
|
+
* Asynchronously creates an instruction to close a rental with minimal required parameters.
|
|
9
|
+
* This is called by an owner to close a rental that was previously accepted by a borrower.
|
|
10
|
+
* Derives rentalState, rentalThread, rentalTokenAccount and rentalAuthority automatically if not provided.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Create the instruction with minimal parameters
|
|
15
|
+
* const ix = await closeRental({
|
|
16
|
+
* borrower: borrowerAddress,
|
|
17
|
+
* ownerTokenAccount: ownerTokenAccountAddress,
|
|
18
|
+
* contract: contractAddress
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Add to transaction and sign
|
|
22
|
+
* const tx = new Transaction().add(ix);
|
|
23
|
+
* await sendAndConfirmTransaction(connection, tx, [owner]);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param params The simplified parameters for closing a rental
|
|
27
|
+
* @returns A promise that resolves to the instruction to close a rental
|
|
28
|
+
*/
|
|
29
|
+
async function closeRental(params) {
|
|
30
|
+
const { borrower, ownerTokenAccount, contract, } = params;
|
|
31
|
+
// Let codama derive the optional accounts
|
|
32
|
+
const input = {
|
|
33
|
+
borrower,
|
|
34
|
+
ownerTokenAccount,
|
|
35
|
+
contract,
|
|
36
|
+
};
|
|
37
|
+
return (0, codama_1.getCloseRentalInstructionAsync)(input, { programAddress: codama_1.SRSLY_PROGRAM_ADDRESS });
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=close.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":";;;AAoDA,kCAoBC;AApED,sCAImB;AAkEV,+GApEP,uCAA8B,OAoEO;AA5CvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAyB;IAEzB,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,OAAO,IAAA,uCAA8B,EACnC,KAAK,EACL,EAAE,cAAc,EAAE,8BAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./accept"), exports);
|
|
18
|
+
__exportStar(require("./cancel"), exports);
|
|
19
|
+
__exportStar(require("./close"), exports);
|
|
20
|
+
__exportStar(require("./reset"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rental/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,0CAAwB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResetRentalInstructionAsync = void 0;
|
|
4
|
+
exports.resetRental = resetRental;
|
|
5
|
+
const codama_1 = require("../codama");
|
|
6
|
+
Object.defineProperty(exports, "getResetRentalInstructionAsync", { enumerable: true, get: function () { return codama_1.getResetRentalInstructionAsync; } });
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
/**
|
|
9
|
+
* Asynchronously creates an instruction to reset a rental with minimal required parameters.
|
|
10
|
+
* This is used to reset a fleet's rental state after a rental has ended.
|
|
11
|
+
* Can derive starbase, starbasePlayer, and rentalAuthority automatically.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Create the instruction with minimum required parameters and faction
|
|
16
|
+
* const ix = await resetRental({
|
|
17
|
+
* fleet: fleetAddress,
|
|
18
|
+
* contract: contractAddress,
|
|
19
|
+
* rentalState: rentalStateAddress,
|
|
20
|
+
* faction: 'mud',
|
|
21
|
+
* ownerProfile: ownerProfileAddress
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Or with explicit starbase and starbasePlayer
|
|
25
|
+
* const ix = await resetRental({
|
|
26
|
+
* fleet: fleetAddress,
|
|
27
|
+
* contract: contractAddress,
|
|
28
|
+
* rentalState: rentalStateAddress,
|
|
29
|
+
* starbase: starbaseAddress,
|
|
30
|
+
* starbasePlayer: starbasePlayerAddress
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Add to transaction and sign
|
|
34
|
+
* const tx = new Transaction().add(ix);
|
|
35
|
+
* await sendAndConfirmTransaction(connection, tx, [owner]);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param params The simplified parameters for resetting a rental
|
|
39
|
+
* @returns A promise that resolves to the instruction to reset a rental
|
|
40
|
+
*/
|
|
41
|
+
async function resetRental(params) {
|
|
42
|
+
const { fleet, contract, rentalState, gameId = utils_1.DEFAULT_GAME_ID, faction, ownerProfile, } = params;
|
|
43
|
+
// Derive the three accounts we need
|
|
44
|
+
const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)(ownerProfile, faction, gameId);
|
|
45
|
+
// Let codama derive the rest (rentalAuthority)
|
|
46
|
+
const input = {
|
|
47
|
+
fleet,
|
|
48
|
+
contract,
|
|
49
|
+
rentalState,
|
|
50
|
+
gameId,
|
|
51
|
+
starbase,
|
|
52
|
+
starbasePlayer,
|
|
53
|
+
};
|
|
54
|
+
return (0, codama_1.getResetRentalInstructionAsync)(input, { programAddress: codama_1.SRSLY_PROGRAM_ADDRESS });
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":";;;AAuFA,kCAoCC;AAvHD,sCAImB;AAqHV,+GAvHP,uCAA8B,OAuHO;AAnHvC,oCAGkB;AAyClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAyB;IAEzB,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,WAAW,EACX,MAAM,GAAG,uBAAkC,EAC3C,OAAO,EACP,YAAY,GACb,GAAG,MAAM,CAAC;IAEX,oCAAoC;IACpC,MAAM,EACJ,QAAQ,EACR,cAAc,EACf,GAAG,MAAM,IAAA,0BAAkB,EAC1B,YAAY,EACZ,OAAO,EACP,MAAM,CACP,CAAC;IAEF,+CAA+C;IAC/C,MAAM,KAAK,GAAG;QACZ,KAAK;QACL,QAAQ;QACR,WAAW;QACX,MAAM;QACN,QAAQ;QACR,cAAc;KACf,CAAC;IAEF,OAAO,IAAA,uCAA8B,EACnC,KAAK,EACL,EAAE,cAAc,EAAE,8BAAqB,EAAE,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentFrequency = exports.FACTION_MAPPING = exports.FACTION_SPECIFIC_CSS = exports.PROFILE_FACTION_SEED = exports.SAGE_PLAYER_PROFILE_SEED = exports.STARBASE_PLAYER_SEED = exports.STARBASE_SEED = exports.DEFAULT_GAME_ID = exports.PROFILE_FACTION_PROGRAM_ADDRESS = exports.SAGE_PROGRAM_ADDRESS = exports.PROGRAM_ID = void 0;
|
|
4
|
+
exports.paymentFrequencyToString = paymentFrequencyToString;
|
|
5
|
+
const codama_1 = require("../codama");
|
|
6
|
+
Object.defineProperty(exports, "PaymentFrequency", { enumerable: true, get: function () { return codama_1.PaymentFrequency; } });
|
|
7
|
+
exports.PROGRAM_ID = codama_1.SRSLY_PROGRAM_ADDRESS;
|
|
8
|
+
// Constants for program IDs
|
|
9
|
+
exports.SAGE_PROGRAM_ADDRESS = 'sAgezwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi';
|
|
10
|
+
exports.PROFILE_FACTION_PROGRAM_ADDRESS = 'pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq';
|
|
11
|
+
exports.DEFAULT_GAME_ID = 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr';
|
|
12
|
+
// Seed constants
|
|
13
|
+
exports.STARBASE_SEED = 'Starbase';
|
|
14
|
+
exports.STARBASE_PLAYER_SEED = 'starbase_player';
|
|
15
|
+
exports.SAGE_PLAYER_PROFILE_SEED = 'sage_player_profile';
|
|
16
|
+
exports.PROFILE_FACTION_SEED = 'profile_faction';
|
|
17
|
+
// Faction-specific CSS coordinates for starbase derivation
|
|
18
|
+
exports.FACTION_SPECIFIC_CSS = {
|
|
19
|
+
mud: { x: 0, y: -39 },
|
|
20
|
+
oni: { x: -40, y: 30 },
|
|
21
|
+
ustur: { x: 40, y: 30 },
|
|
22
|
+
};
|
|
23
|
+
exports.FACTION_MAPPING = {
|
|
24
|
+
1: 'mud',
|
|
25
|
+
2: 'oni',
|
|
26
|
+
3: 'ustur'
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Convert PaymentFrequency enum to string
|
|
30
|
+
*/
|
|
31
|
+
function paymentFrequencyToString(freq) {
|
|
32
|
+
return codama_1.PaymentFrequency[freq].toLowerCase();
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":";;;AAgCA,4DAEC;AAlCD,sCAAoE;AAmC3D,iGAnCA,yBAAgB,OAmCA;AAhCZ,QAAA,UAAU,GAAY,8BAAqB,CAAC;AAEzD,4BAA4B;AACf,QAAA,oBAAoB,GAAG,6CAA6C,CAAC;AACrE,QAAA,+BAA+B,GAAG,6CAA6C,CAAC;AAChF,QAAA,eAAe,GAAG,8CAA8C,CAAC;AAE9E,iBAAiB;AACJ,QAAA,aAAa,GAAG,UAAU,CAAC;AAC3B,QAAA,oBAAoB,GAAG,iBAAiB,CAAC;AACzC,QAAA,wBAAwB,GAAG,qBAAqB,CAAC;AACjD,QAAA,oBAAoB,GAAG,iBAAiB,CAAC;AAEtD,2DAA2D;AAC9C,QAAA,oBAAoB,GAA6C;IAC5E,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;IACrB,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;IACtB,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;CACxB,CAAC;AAEW,QAAA,eAAe,GAA2B;IACrD,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,OAAO;CACX,CAAC;AAEF;;GAEG;AACH,SAAgB,wBAAwB,CAAC,IAAsB;IAC7D,OAAO,yBAAgB,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./profiles"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6CAA2B"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveProfileFaction = deriveProfileFaction;
|
|
4
|
+
exports.deriveSagePlayerProfile = deriveSagePlayerProfile;
|
|
5
|
+
exports.deriveStarbase = deriveStarbase;
|
|
6
|
+
exports.deriveStarbasePlayer = deriveStarbasePlayer;
|
|
7
|
+
exports.deriveGameAccounts = deriveGameAccounts;
|
|
8
|
+
const kit_1 = require("@solana/kit");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to convert a string seed to a Uint8Array
|
|
12
|
+
* This is necessary for @solana/kit's getBytesEncoder().encode()
|
|
13
|
+
*
|
|
14
|
+
* @param seed The string seed to convert
|
|
15
|
+
* @returns A Uint8Array containing the UTF-8 encoded seed
|
|
16
|
+
*/
|
|
17
|
+
function seedToBytes(seed) {
|
|
18
|
+
return new Uint8Array(Buffer.from(seed));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Helper function to derive the borrower's profile faction account
|
|
22
|
+
*
|
|
23
|
+
* @param profile The borrower's profile address
|
|
24
|
+
* @returns Promise that resolves to the derived profile faction address
|
|
25
|
+
*/
|
|
26
|
+
async function deriveProfileFaction(profile) {
|
|
27
|
+
const [address] = await (0, kit_1.getProgramDerivedAddress)({
|
|
28
|
+
programAddress: constants_1.PROFILE_FACTION_PROGRAM_ADDRESS,
|
|
29
|
+
seeds: [
|
|
30
|
+
seedToBytes(constants_1.PROFILE_FACTION_SEED),
|
|
31
|
+
(0, kit_1.getAddressEncoder)().encode(profile)
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
return address;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to derive the sage player profile
|
|
38
|
+
*
|
|
39
|
+
* @param borrowerProfile The borrower's profile address
|
|
40
|
+
* @param gameId The game ID (defaults to the standard game ID)
|
|
41
|
+
* @returns Promise that resolves to the derived sage player profile address
|
|
42
|
+
*/
|
|
43
|
+
async function deriveSagePlayerProfile(borrowerProfile, gameId = constants_1.DEFAULT_GAME_ID) {
|
|
44
|
+
const [address] = await (0, kit_1.getProgramDerivedAddress)({
|
|
45
|
+
programAddress: constants_1.SAGE_PROGRAM_ADDRESS,
|
|
46
|
+
seeds: [
|
|
47
|
+
seedToBytes(constants_1.SAGE_PLAYER_PROFILE_SEED),
|
|
48
|
+
(0, kit_1.getAddressEncoder)().encode(borrowerProfile),
|
|
49
|
+
(0, kit_1.getAddressEncoder)().encode(gameId)
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
return address;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Helper function to derive the starbase address based on faction
|
|
56
|
+
*
|
|
57
|
+
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
58
|
+
* @param gameId The game ID (defaults to the standard game ID)
|
|
59
|
+
* @returns Promise that resolves to the derived starbase address
|
|
60
|
+
*/
|
|
61
|
+
async function deriveStarbase(faction, gameId = constants_1.DEFAULT_GAME_ID) {
|
|
62
|
+
// Convert faction to string representation if it's a number
|
|
63
|
+
const factionName = typeof faction === 'number'
|
|
64
|
+
? constants_1.FACTION_MAPPING[faction]
|
|
65
|
+
: faction;
|
|
66
|
+
// Validate faction
|
|
67
|
+
if (!factionName || !constants_1.FACTION_SPECIFIC_CSS[factionName]) {
|
|
68
|
+
throw new Error(`Unsupported faction: ${faction}`);
|
|
69
|
+
}
|
|
70
|
+
// Get coordinates for the faction
|
|
71
|
+
const coords = constants_1.FACTION_SPECIFIC_CSS[factionName];
|
|
72
|
+
// Convert coordinates to bytes (little-endian, two's complement)
|
|
73
|
+
const xCoord = new DataView(new ArrayBuffer(8));
|
|
74
|
+
const yCoord = new DataView(new ArrayBuffer(8));
|
|
75
|
+
xCoord.setBigInt64(0, BigInt(coords.x), true);
|
|
76
|
+
yCoord.setBigInt64(0, BigInt(coords.y), true);
|
|
77
|
+
// Create Uint8Array from DataView
|
|
78
|
+
const xBytes = new Uint8Array(xCoord.buffer);
|
|
79
|
+
const yBytes = new Uint8Array(yCoord.buffer);
|
|
80
|
+
const [address] = await (0, kit_1.getProgramDerivedAddress)({
|
|
81
|
+
programAddress: constants_1.SAGE_PROGRAM_ADDRESS,
|
|
82
|
+
seeds: [
|
|
83
|
+
seedToBytes(constants_1.STARBASE_SEED),
|
|
84
|
+
(0, kit_1.getAddressEncoder)().encode(gameId),
|
|
85
|
+
(0, kit_1.getBytesEncoder)().encode(xBytes),
|
|
86
|
+
(0, kit_1.getBytesEncoder)().encode(yBytes)
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
return address;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Helper function to derive the starbase player address
|
|
93
|
+
*
|
|
94
|
+
* @param sagePlayerProfile The sage player profile address
|
|
95
|
+
* @param starbase The starbase address
|
|
96
|
+
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
97
|
+
* @returns Promise that resolves to the derived starbase player address
|
|
98
|
+
*/
|
|
99
|
+
async function deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId = 0) {
|
|
100
|
+
// Convert sequence ID to bytes (little-endian uint16)
|
|
101
|
+
const seqIdView = new DataView(new ArrayBuffer(2));
|
|
102
|
+
seqIdView.setUint16(0, starbaseSeqId, true);
|
|
103
|
+
const seqIdBytes = new Uint8Array(seqIdView.buffer);
|
|
104
|
+
const [address] = await (0, kit_1.getProgramDerivedAddress)({
|
|
105
|
+
programAddress: constants_1.SAGE_PROGRAM_ADDRESS,
|
|
106
|
+
seeds: [
|
|
107
|
+
seedToBytes(constants_1.STARBASE_PLAYER_SEED),
|
|
108
|
+
(0, kit_1.getAddressEncoder)().encode(starbase),
|
|
109
|
+
(0, kit_1.getAddressEncoder)().encode(sagePlayerProfile),
|
|
110
|
+
(0, kit_1.getBytesEncoder)().encode(seqIdBytes)
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
return address;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Derives all three accounts needed: profileFaction, starbase, and starbasePlayer
|
|
117
|
+
*
|
|
118
|
+
* @param profile The borrower's profile address
|
|
119
|
+
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
120
|
+
* @param gameId The game ID (defaults to the standard game ID)
|
|
121
|
+
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
122
|
+
* @returns Promise that resolves to the three derived addresses
|
|
123
|
+
*/
|
|
124
|
+
async function deriveGameAccounts(profile, faction, gameId = constants_1.DEFAULT_GAME_ID, starbaseSeqId = 0) {
|
|
125
|
+
// Derive the three accounts in parallel
|
|
126
|
+
const [profileFaction, sagePlayerProfile, starbase] = await Promise.all([
|
|
127
|
+
deriveProfileFaction(profile),
|
|
128
|
+
deriveSagePlayerProfile(profile, gameId),
|
|
129
|
+
deriveStarbase(faction, gameId)
|
|
130
|
+
]);
|
|
131
|
+
// Derive starbasePlayer using the results from above
|
|
132
|
+
const starbasePlayer = await deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId);
|
|
133
|
+
return {
|
|
134
|
+
profileFaction,
|
|
135
|
+
starbase,
|
|
136
|
+
starbasePlayer
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.js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Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBooleanDecoder, getBooleanEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, } from '@solana/kit';
|
|
9
|
+
import { getPaymentFrequencyDecoder, getPaymentFrequencyEncoder, } from '../types';
|
|
10
|
+
export const CONTRACT_STATE_DISCRIMINATOR = new Uint8Array([
|
|
11
|
+
190, 138, 10, 223, 189, 116, 222, 115,
|
|
12
|
+
]);
|
|
13
|
+
export function getContractStateDiscriminatorBytes() {
|
|
14
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(CONTRACT_STATE_DISCRIMINATOR);
|
|
15
|
+
}
|
|
16
|
+
export function getContractStateEncoder() {
|
|
17
|
+
return transformEncoder(getStructEncoder([
|
|
18
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
19
|
+
['version', getU8Encoder()],
|
|
20
|
+
['toClose', getBooleanEncoder()],
|
|
21
|
+
['rate', getU64Encoder()],
|
|
22
|
+
['durationMin', getU64Encoder()],
|
|
23
|
+
['durationMax', getU64Encoder()],
|
|
24
|
+
['paymentsFeq', getPaymentFrequencyEncoder()],
|
|
25
|
+
['fleet', getAddressEncoder()],
|
|
26
|
+
['gameId', getAddressEncoder()],
|
|
27
|
+
['currentRentalState', getAddressEncoder()],
|
|
28
|
+
['owner', getAddressEncoder()],
|
|
29
|
+
['ownerTokenAccount', getAddressEncoder()],
|
|
30
|
+
['ownerProfile', getAddressEncoder()],
|
|
31
|
+
['bump', getU8Encoder()],
|
|
32
|
+
]), (value) => ({ ...value, discriminator: CONTRACT_STATE_DISCRIMINATOR }));
|
|
33
|
+
}
|
|
34
|
+
export function getContractStateDecoder() {
|
|
35
|
+
return getStructDecoder([
|
|
36
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
37
|
+
['version', getU8Decoder()],
|
|
38
|
+
['toClose', getBooleanDecoder()],
|
|
39
|
+
['rate', getU64Decoder()],
|
|
40
|
+
['durationMin', getU64Decoder()],
|
|
41
|
+
['durationMax', getU64Decoder()],
|
|
42
|
+
['paymentsFeq', getPaymentFrequencyDecoder()],
|
|
43
|
+
['fleet', getAddressDecoder()],
|
|
44
|
+
['gameId', getAddressDecoder()],
|
|
45
|
+
['currentRentalState', getAddressDecoder()],
|
|
46
|
+
['owner', getAddressDecoder()],
|
|
47
|
+
['ownerTokenAccount', getAddressDecoder()],
|
|
48
|
+
['ownerProfile', getAddressDecoder()],
|
|
49
|
+
['bump', getU8Decoder()],
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
export function getContractStateCodec() {
|
|
53
|
+
return combineCodec(getContractStateEncoder(), getContractStateDecoder());
|
|
54
|
+
}
|
|
55
|
+
export function decodeContractState(encodedAccount) {
|
|
56
|
+
return decodeAccount(encodedAccount, getContractStateDecoder());
|
|
57
|
+
}
|
|
58
|
+
export async function fetchContractState(rpc, address, config) {
|
|
59
|
+
const maybeAccount = await fetchMaybeContractState(rpc, address, config);
|
|
60
|
+
assertAccountExists(maybeAccount);
|
|
61
|
+
return maybeAccount;
|
|
62
|
+
}
|
|
63
|
+
export async function fetchMaybeContractState(rpc, address, config) {
|
|
64
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
65
|
+
return decodeContractState(maybeAccount);
|
|
66
|
+
}
|
|
67
|
+
export async function fetchAllContractState(rpc, addresses, config) {
|
|
68
|
+
const maybeAccounts = await fetchAllMaybeContractState(rpc, addresses, config);
|
|
69
|
+
assertAccountsExist(maybeAccounts);
|
|
70
|
+
return maybeAccounts;
|
|
71
|
+
}
|
|
72
|
+
export async function fetchAllMaybeContractState(rpc, addresses, config) {
|
|
73
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
74
|
+
return maybeAccounts.map((maybeAccount) => decodeContractState(maybeAccount));
|
|
75
|
+
}
|
|
76
|
+
export function getContractStateSize() {
|
|
77
|
+
return 228;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=contractState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractState.js","sourceRoot":"","sources":["../../../../src/codama/accounts/contractState.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,gBAAgB,GAYjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAG3B,MAAM,UAAU,CAAC;AAElB,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,UAAU,CAAC;IACzD,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CACtC,CAAC,CAAC;AAEH,MAAM,UAAU,kCAAkC;IAChD,OAAO,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAChD,4BAA4B,CAC7B,CAAC;AACJ,CAAC;AAmCD,MAAM,UAAU,uBAAuB;IACrC,OAAO,gBAAgB,CACrB,gBAAgB,CAAC;QACf,CAAC,eAAe,EAAE,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC,SAAS,EAAE,YAAY,EAAE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CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACzE,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU8Decoder, getU8Encoder, transformEncoder, } from '@solana/kit';
|
|
9
|
+
export const FLEET_DISCRIMINATOR = new Uint8Array([
|
|
10
|
+
109, 207, 251, 48, 106, 2, 136, 163,
|
|
11
|
+
]);
|
|
12
|
+
export function getFleetDiscriminatorBytes() {
|
|
13
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(FLEET_DISCRIMINATOR);
|
|
14
|
+
}
|
|
15
|
+
export function getFleetEncoder() {
|
|
16
|
+
return transformEncoder(getStructEncoder([
|
|
17
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
18
|
+
['version', getU8Encoder()],
|
|
19
|
+
['gameId', getAddressEncoder()],
|
|
20
|
+
['ownerProfile', getAddressEncoder()],
|
|
21
|
+
['fleetShips', getAddressEncoder()],
|
|
22
|
+
['subProfile', getAddressEncoder()],
|
|
23
|
+
['subProfileInvalidator', getAddressEncoder()],
|
|
24
|
+
]), (value) => ({ ...value, discriminator: FLEET_DISCRIMINATOR }));
|
|
25
|
+
}
|
|
26
|
+
export function getFleetDecoder() {
|
|
27
|
+
return getStructDecoder([
|
|
28
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
29
|
+
['version', getU8Decoder()],
|
|
30
|
+
['gameId', getAddressDecoder()],
|
|
31
|
+
['ownerProfile', getAddressDecoder()],
|
|
32
|
+
['fleetShips', getAddressDecoder()],
|
|
33
|
+
['subProfile', getAddressDecoder()],
|
|
34
|
+
['subProfileInvalidator', getAddressDecoder()],
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
export function getFleetCodec() {
|
|
38
|
+
return combineCodec(getFleetEncoder(), getFleetDecoder());
|
|
39
|
+
}
|
|
40
|
+
export function decodeFleet(encodedAccount) {
|
|
41
|
+
return decodeAccount(encodedAccount, getFleetDecoder());
|
|
42
|
+
}
|
|
43
|
+
export async function fetchFleet(rpc, address, config) {
|
|
44
|
+
const maybeAccount = await fetchMaybeFleet(rpc, address, config);
|
|
45
|
+
assertAccountExists(maybeAccount);
|
|
46
|
+
return maybeAccount;
|
|
47
|
+
}
|
|
48
|
+
export async function fetchMaybeFleet(rpc, address, config) {
|
|
49
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
50
|
+
return decodeFleet(maybeAccount);
|
|
51
|
+
}
|
|
52
|
+
export async function fetchAllFleet(rpc, addresses, config) {
|
|
53
|
+
const maybeAccounts = await fetchAllMaybeFleet(rpc, addresses, config);
|
|
54
|
+
assertAccountsExist(maybeAccounts);
|
|
55
|
+
return maybeAccounts;
|
|
56
|
+
}
|
|
57
|
+
export async function fetchAllMaybeFleet(rpc, addresses, config) {
|
|
58
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
59
|
+
return maybeAccounts.map((maybeAccount) => decodeFleet(maybeAccount));
|
|
60
|
+
}
|
|
61
|
+
export function getFleetSize() {
|
|
62
|
+
return 169;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=fleet.js.map
|
|
@@ -0,0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M,CAAC,CAAC;IACvE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACnC,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAA+C,EAC/C,SAAyB,EACzB,MAA4B;IAE5B,MAAM,aAAa,GAAG,MAAM,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACzE,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
export * from './contractState';
|
|
9
|
+
export * from './fleet';
|
|
10
|
+
export * from './rentalState';
|
|
11
|
+
export * from './thread';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/codama/accounts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
|