@wuwei-labs/srsly 2.0.0-beta.34 → 2.0.0-beta.37
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 +30 -0
- package/dist/cjs/codama/instructions/closeContract.js +1 -111
- package/dist/cjs/codama/instructions/closeContract.js.map +1 -1
- package/dist/cjs/codama/instructions/index.js +0 -1
- package/dist/cjs/codama/instructions/index.js.map +1 -1
- package/dist/cjs/codama/programs/srsly.js +8 -12
- package/dist/cjs/codama/programs/srsly.js.map +1 -1
- package/dist/cjs/contract/close.js +15 -15
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +8 -10
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/contract/index.js +0 -1
- package/dist/cjs/contract/index.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/rental/accept.js +6 -6
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +3 -2
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +3 -2
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +6 -7
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +6 -5
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/constants.js +10 -5
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/esm/codama/instructions/closeContract.js +3 -113
- package/dist/esm/codama/instructions/closeContract.js.map +1 -1
- package/dist/esm/codama/instructions/index.js +0 -1
- package/dist/esm/codama/instructions/index.js.map +1 -1
- package/dist/esm/codama/programs/srsly.js +8 -12
- package/dist/esm/codama/programs/srsly.js.map +1 -1
- package/dist/esm/contract/close.js +17 -17
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +10 -12
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/contract/index.js +0 -1
- package/dist/esm/contract/index.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/rental/accept.js +8 -8
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +4 -3
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +4 -3
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +8 -9
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +6 -5
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/constants.js +10 -5
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/types/codama/instructions/closeContract.d.ts +14 -59
- package/dist/types/codama/instructions/closeContract.d.ts.map +1 -1
- package/dist/types/codama/instructions/index.d.ts +0 -1
- package/dist/types/codama/instructions/index.d.ts.map +1 -1
- package/dist/types/codama/programs/srsly.d.ts +9 -12
- package/dist/types/codama/programs/srsly.d.ts.map +1 -1
- package/dist/types/contract/close.d.ts +1 -6
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +0 -3
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/contract/index.d.ts +0 -1
- package/dist/types/contract/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +1 -6
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +1 -2
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +1 -2
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +1 -7
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +5 -5
- package/dist/types/utils/config.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +0 -1
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/package.json +1 -1
- package/target/idl/srsly.json +0 -413
- package/dist/cjs/codama/instructions/cancelContract.js +0 -131
- package/dist/cjs/codama/instructions/cancelContract.js.map +0 -1
- package/dist/cjs/contract/cancel.js +0 -77
- package/dist/cjs/contract/cancel.js.map +0 -1
- package/dist/esm/codama/instructions/cancelContract.js +0 -121
- package/dist/esm/codama/instructions/cancelContract.js.map +0 -1
- package/dist/esm/contract/cancel.js +0 -73
- package/dist/esm/contract/cancel.js.map +0 -1
- package/dist/types/codama/instructions/cancelContract.d.ts +0 -59
- package/dist/types/codama/instructions/cancelContract.d.ts.map +0 -1
- package/dist/types/contract/cancel.d.ts +0 -66
- package/dist/types/contract/cancel.d.ts.map +0 -1
package/dist/cjs/rental/reset.js
CHANGED
|
@@ -9,11 +9,11 @@ const utils_1 = require("../utils");
|
|
|
9
9
|
* Internal function to reset a rental instruction with configuration options
|
|
10
10
|
*/
|
|
11
11
|
async function _resetRental(params, config) {
|
|
12
|
-
const { fleet, contract, rentalState,
|
|
13
|
-
// Get the
|
|
14
|
-
const
|
|
12
|
+
const { fleet, contract, rentalState, faction, ownerProfile, } = params;
|
|
13
|
+
// Get the resolved addresses from config (including network-specific addresses)
|
|
14
|
+
const resolvedAddresses = (0, config_1.resolveProgramAddresses)(config || {});
|
|
15
15
|
// Derive the three accounts we need
|
|
16
|
-
const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)((0, constants_1.toAddress)(ownerProfile), faction,
|
|
16
|
+
const { starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)((0, constants_1.toAddress)(ownerProfile), faction, resolvedAddresses.gameId, 0, // starbaseSeqId
|
|
17
17
|
config);
|
|
18
18
|
// Get network-specific codama functions from centralized config
|
|
19
19
|
const instructionsModule = (0, config_1.getModule)('instructions');
|
|
@@ -25,7 +25,7 @@ async function _resetRental(params, config) {
|
|
|
25
25
|
fleet: (0, constants_1.toAddress)(fleet), // Ensure string
|
|
26
26
|
contract: (0, constants_1.toAddress)(contract), // Ensure string
|
|
27
27
|
rentalState: (0, constants_1.toAddress)(rentalState), // Ensure string
|
|
28
|
-
gameId:
|
|
28
|
+
gameId: resolvedAddresses.gameId, // Already Address from resolveProgramAddresses
|
|
29
29
|
starbase, // Already string from deriveGameAccounts
|
|
30
30
|
starbasePlayer, // Already string from deriveGameAccounts
|
|
31
31
|
};
|
|
@@ -51,8 +51,7 @@ async function _resetRental(params, config) {
|
|
|
51
51
|
* // Override specific constants
|
|
52
52
|
* const instruction = await resetRental(params).set({
|
|
53
53
|
* programs: 'mainnet',
|
|
54
|
-
* gameId: 'custom-game-id...'
|
|
55
|
-
* sageProgramAddress: 'custom...'
|
|
54
|
+
* gameId: 'custom-game-id...' // gameId configured via .set()
|
|
56
55
|
* });
|
|
57
56
|
*
|
|
58
57
|
* // Use the instruction with your preferred Solana library
|
|
@@ -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":";;AA2HA,kCAIC;AAED,wEAKC;AAtID,4CAAoI;AACpI,kDAA+C;AAC/C,oCAA8C;AAuC9C;;GAEG;AACH,KAAK,UAAU,YAAY,CACzB,MAAyB,EACzB,MAAsB;IAEtB,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,YAAY,GACb,GAAG,MAAM,CAAC;IAEX,gFAAgF;IAChF,MAAM,iBAAiB,GAAG,IAAA,gCAAuB,EAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IAEhE,oCAAoC;IACpC,MAAM,EACJ,QAAQ,EACR,cAAc,EACf,GAAG,MAAM,IAAA,0BAAkB,EAC1B,IAAA,qBAAS,EAAC,YAAY,CAAC,EACvB,OAAO,EACP,iBAAiB,CAAC,MAAM,EACxB,CAAC,EAAE,gBAAgB;IACnB,MAAM,CACP,CAAC;IAEF,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,IAA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= __importStar(require("../codama/programs"));
|
|
50
50
|
const accounts = __importStar(require("../codama/accounts"));
|
|
51
51
|
const kit_1 = require("@solana/kit");
|
|
52
|
+
const constants_1 = require("./constants");
|
|
52
53
|
const PROGRAM_SETS = {
|
|
53
54
|
mainnet: {
|
|
54
55
|
SAGE_PROGRAM_ADDRESS: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
@@ -88,11 +89,11 @@ function resolveProgramAddresses(config) {
|
|
|
88
89
|
throw new Error(`Unknown program set: ${programSet}. Available: ${Object.keys(PROGRAM_SETS).join(', ')}`);
|
|
89
90
|
}
|
|
90
91
|
return {
|
|
91
|
-
srslyProgramAddress: config.srslyProgramAddress || 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT',
|
|
92
|
-
sageProgramAddress: programConfig.SAGE_PROGRAM_ADDRESS, // Fixed - cannot be overridden
|
|
93
|
-
profileFactionProgramAddress: config.profileFactionProgramAddress || programConfig.PROFILE_FACTION_PROGRAM_ADDRESS,
|
|
94
|
-
gameId: config.gameId || programConfig.SAGE_GAME_ID,
|
|
95
|
-
atlasMint: config.atlasMint || programConfig.ATLAS_MINT,
|
|
92
|
+
srslyProgramAddress: (0, constants_1.toAddress)(config.srslyProgramAddress || 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT'),
|
|
93
|
+
sageProgramAddress: (0, constants_1.toAddress)(programConfig.SAGE_PROGRAM_ADDRESS), // Fixed - cannot be overridden
|
|
94
|
+
profileFactionProgramAddress: (0, constants_1.toAddress)(config.profileFactionProgramAddress || programConfig.PROFILE_FACTION_PROGRAM_ADDRESS),
|
|
95
|
+
gameId: (0, constants_1.toAddress)(config.gameId || programConfig.SAGE_GAME_ID),
|
|
96
|
+
atlasMint: (0, constants_1.toAddress)(config.atlasMint || programConfig.ATLAS_MINT),
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDH,0DAiBC;AAwBD,8BAEC;AAMD,8BAEC;AAKD,kCAEC;AAQD,gDAEC;AAOD,8BAaC;AAMD,wDAKC;AA2ED,oDAgBC;AAnPD,0CAA0C;AAC1C,qEAAuD;AACvD,6DAA+C;AAC/C,6DAA+C;AAC/C,qCAA8C;AAC9C,2CAAwC;AAIxC,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE;QACP,oBAAoB,EAAE,6CAA6C;QACnE,+BAA+B,EAAE,6CAA6C;QAC9E,YAAY,EAAE,8CAA8C;QAC5D,UAAU,EAAE,8CAA8C;QAC1D,OAAO,EAAE,qCAAqC;KAC/C;IACD,QAAQ,EAAE;QACR,oBAAoB,EAAE,6CAA6C;QACnE,+BAA+B,EAAE,6CAA6C;QAC9E,YAAY,EAAE,8CAA8C;QAC5D,UAAU,EAAE,8CAA8C;KAC3D;IACD,OAAO,EAAE;QACP,oBAAoB,EAAE,6CAA6C;QACnE,+BAA+B,EAAE,6CAA6C;QAC9E,YAAY,EAAE,8CAA8C;QAC5D,UAAU,EAAE,8CAA8C;KAC3D;CACO,CAAC;AAaX,6CAA6C;AAC7C,MAAM,mBAAmB,GAAe,UAAU,CAAC;AAEnD,6BAA6B;AAC7B,IAAI,YAAY,GAAkB,EAAE,CAAC;AAErC;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,MAAqB;IAC3D,qCAAqC;IACrC,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,IAAI,mBAAmB,CAAC;IAE1D,0CAA0C;IAC1C,MAAM,aAAa,GAAG,YAAY,CAAC,UAAU,C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AAI,CACF,WAAqE,EACrE,UAAuE;YAEvE,OAAO,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -9,13 +9,18 @@ exports.getProfileFactionProgramAddress = getProfileFactionProgramAddress;
|
|
|
9
9
|
exports.getSageGameId = getSageGameId;
|
|
10
10
|
exports.getAtlasMint = getAtlasMint;
|
|
11
11
|
const config_1 = require("./config");
|
|
12
|
+
const kit_1 = require("@solana/kit");
|
|
12
13
|
/**
|
|
13
14
|
* Converts a string or Address to an Address type
|
|
14
15
|
* This utility ensures consistent address handling across the SDK
|
|
15
|
-
* Note: This is a simple passthrough now since pack functions handle library-specific conversions
|
|
16
16
|
*/
|
|
17
17
|
function toAddress(value) {
|
|
18
|
-
return
|
|
18
|
+
// If it's already an Address type, return as-is
|
|
19
|
+
if ((0, kit_1.isAddress)(value)) {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
// Convert string to Address using @solana/kit
|
|
23
|
+
return (0, kit_1.address)(value);
|
|
19
24
|
}
|
|
20
25
|
// Seed constants
|
|
21
26
|
exports.STARBASE_SEED = 'Starbase';
|
|
@@ -42,7 +47,7 @@ async function getSageProgramAddress(config) {
|
|
|
42
47
|
const effectiveConfig = { ...globalConfig, ...config };
|
|
43
48
|
const resolved = (0, config_1.resolveProgramAddresses)(effectiveConfig);
|
|
44
49
|
// Note: SAGE program address is fixed based on network and cannot be overridden
|
|
45
|
-
return
|
|
50
|
+
return resolved.sageProgramAddress; // Already converted to Address in resolveProgramAddresses
|
|
46
51
|
}
|
|
47
52
|
async function getProfileFactionProgramAddress(config) {
|
|
48
53
|
const globalConfig = (0, config_1.getConfig)();
|
|
@@ -54,13 +59,13 @@ async function getSageGameId(config) {
|
|
|
54
59
|
const globalConfig = (0, config_1.getConfig)();
|
|
55
60
|
const effectiveConfig = { ...globalConfig, ...config };
|
|
56
61
|
const resolved = (0, config_1.resolveProgramAddresses)(effectiveConfig);
|
|
57
|
-
return
|
|
62
|
+
return resolved.gameId; // Already converted to Address in resolveProgramAddresses
|
|
58
63
|
}
|
|
59
64
|
async function getAtlasMint(config) {
|
|
60
65
|
const globalConfig = (0, config_1.getConfig)();
|
|
61
66
|
const effectiveConfig = { ...globalConfig, ...config };
|
|
62
67
|
const resolved = (0, config_1.resolveProgramAddresses)(effectiveConfig);
|
|
63
|
-
return
|
|
68
|
+
return resolved.atlasMint; // Already converted to Address in resolveProgramAddresses
|
|
64
69
|
}
|
|
65
70
|
// Faction-specific CSS coordinates for starbase derivation
|
|
66
71
|
exports.FACTION_SPECIFIC_CSS = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":";;;AAOA,8BAOC;AAeD,wDAMC;AAGD,oCAEC;AAGD,sDAOC;AAED,0EAMC;AAED,sCAMC;AAED,oCAMC;AA1ED,qCAAkF;AAClF,qCAAiD;AAEjD;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAmB;IAC3C,gDAAgD;IAChD,IAAI,IAAA,eAAS,EAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,8CAA8C;IAC9C,OAAO,IAAA,aAAO,EAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,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,6BAA6B;AAChB,QAAA,iBAAiB,GAAG,WAAW,CAAC,CAAC,iCAAiC;AAE/E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EAAC,eAAe,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,0DAA0D;AACpF,CAAC;AAEM,KAAK,UAAU,YAAY,CAAC,MAAsB;IACvD,MAAM,YAAY,GAAG,IAAA,kBAAS,GAAE,CAAC;IACjC,MAAM,eAAe,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IAEvD,MAAM,QAAQ,GAAG,IAAA,gCAAuB,EAAC,eAAe,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,0DAA0D;AACvF,CAAC;AAED,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,kEAAkE"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
|
-
import { combineCodec, fixDecoderSize, fixEncoderSize,
|
|
8
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getProgramDerivedAddress, getStructDecoder, getStructEncoder, transformEncoder, } from '@solana/kit';
|
|
9
9
|
import { SRSLY_PROGRAM_ADDRESS } from '../programs';
|
|
10
|
-
import {
|
|
10
|
+
import { getAccountMetaFactory } from '../shared';
|
|
11
11
|
export const CLOSE_CONTRACT_DISCRIMINATOR = new Uint8Array([
|
|
12
12
|
37, 244, 34, 168, 92, 202, 80, 106,
|
|
13
13
|
]);
|
|
@@ -31,17 +31,6 @@ export async function getCloseContractInstructionAsync(input, config) {
|
|
|
31
31
|
// Original accounts.
|
|
32
32
|
const originalAccounts = {
|
|
33
33
|
owner: { value: input.owner ?? null, isWritable: true },
|
|
34
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
35
|
-
mint: { value: input.mint ?? null, isWritable: false },
|
|
36
|
-
ownerTokenAccount: {
|
|
37
|
-
value: input.ownerTokenAccount ?? null,
|
|
38
|
-
isWritable: true,
|
|
39
|
-
},
|
|
40
|
-
rentalTokenAccount: {
|
|
41
|
-
value: input.rentalTokenAccount ?? null,
|
|
42
|
-
isWritable: true,
|
|
43
|
-
},
|
|
44
|
-
rentalState: { value: input.rentalState ?? null, isWritable: true },
|
|
45
34
|
fleet: { value: input.fleet ?? null, isWritable: true },
|
|
46
35
|
gameId: { value: input.gameId ?? null, isWritable: false },
|
|
47
36
|
starbase: { value: input.starbase ?? null, isWritable: false },
|
|
@@ -52,38 +41,9 @@ export async function getCloseContractInstructionAsync(input, config) {
|
|
|
52
41
|
isWritable: false,
|
|
53
42
|
},
|
|
54
43
|
sageProgram: { value: input.sageProgram ?? null, isWritable: false },
|
|
55
|
-
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
56
|
-
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
57
|
-
associatedTokenProgram: {
|
|
58
|
-
value: input.associatedTokenProgram ?? null,
|
|
59
|
-
isWritable: false,
|
|
60
|
-
},
|
|
61
|
-
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
62
44
|
};
|
|
63
45
|
const accounts = originalAccounts;
|
|
64
46
|
// Resolve default values.
|
|
65
|
-
if (!accounts.config.value) {
|
|
66
|
-
accounts.config.value = await getProgramDerivedAddress({
|
|
67
|
-
programAddress,
|
|
68
|
-
seeds: [
|
|
69
|
-
getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
70
|
-
],
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (!accounts.ownerTokenAccount.value) {
|
|
74
|
-
accounts.ownerTokenAccount.value = await getProgramDerivedAddress({
|
|
75
|
-
programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
76
|
-
seeds: [
|
|
77
|
-
getAddressEncoder().encode(expectAddress(accounts.owner.value)),
|
|
78
|
-
getBytesEncoder().encode(new Uint8Array([
|
|
79
|
-
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
80
|
-
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
81
|
-
126, 255, 0, 169,
|
|
82
|
-
])),
|
|
83
|
-
getAddressEncoder().encode(expectAddress(accounts.mint.value)),
|
|
84
|
-
],
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
47
|
if (!accounts.rentalAuthority.value) {
|
|
88
48
|
accounts.rentalAuthority.value = await getProgramDerivedAddress({
|
|
89
49
|
programAddress,
|
|
@@ -95,27 +55,10 @@ export async function getCloseContractInstructionAsync(input, config) {
|
|
|
95
55
|
],
|
|
96
56
|
});
|
|
97
57
|
}
|
|
98
|
-
if (!accounts.tokenProgram.value) {
|
|
99
|
-
accounts.tokenProgram.value =
|
|
100
|
-
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
101
|
-
}
|
|
102
|
-
if (!accounts.associatedTokenProgram.value) {
|
|
103
|
-
accounts.associatedTokenProgram.value =
|
|
104
|
-
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
105
|
-
}
|
|
106
|
-
if (!accounts.systemProgram.value) {
|
|
107
|
-
accounts.systemProgram.value =
|
|
108
|
-
'11111111111111111111111111111111';
|
|
109
|
-
}
|
|
110
58
|
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
111
59
|
const instruction = {
|
|
112
60
|
accounts: [
|
|
113
61
|
getAccountMeta(accounts.owner),
|
|
114
|
-
getAccountMeta(accounts.config),
|
|
115
|
-
getAccountMeta(accounts.mint),
|
|
116
|
-
getAccountMeta(accounts.ownerTokenAccount),
|
|
117
|
-
getAccountMeta(accounts.rentalTokenAccount),
|
|
118
|
-
getAccountMeta(accounts.rentalState),
|
|
119
62
|
getAccountMeta(accounts.fleet),
|
|
120
63
|
getAccountMeta(accounts.gameId),
|
|
121
64
|
getAccountMeta(accounts.starbase),
|
|
@@ -123,10 +66,6 @@ export async function getCloseContractInstructionAsync(input, config) {
|
|
|
123
66
|
getAccountMeta(accounts.contract),
|
|
124
67
|
getAccountMeta(accounts.rentalAuthority),
|
|
125
68
|
getAccountMeta(accounts.sageProgram),
|
|
126
|
-
getAccountMeta(accounts.feeTokenAccount),
|
|
127
|
-
getAccountMeta(accounts.tokenProgram),
|
|
128
|
-
getAccountMeta(accounts.associatedTokenProgram),
|
|
129
|
-
getAccountMeta(accounts.systemProgram),
|
|
130
69
|
],
|
|
131
70
|
programAddress,
|
|
132
71
|
data: getCloseContractInstructionDataEncoder().encode({}),
|
|
@@ -139,17 +78,6 @@ export function getCloseContractInstruction(input, config) {
|
|
|
139
78
|
// Original accounts.
|
|
140
79
|
const originalAccounts = {
|
|
141
80
|
owner: { value: input.owner ?? null, isWritable: true },
|
|
142
|
-
config: { value: input.config ?? null, isWritable: false },
|
|
143
|
-
mint: { value: input.mint ?? null, isWritable: false },
|
|
144
|
-
ownerTokenAccount: {
|
|
145
|
-
value: input.ownerTokenAccount ?? null,
|
|
146
|
-
isWritable: true,
|
|
147
|
-
},
|
|
148
|
-
rentalTokenAccount: {
|
|
149
|
-
value: input.rentalTokenAccount ?? null,
|
|
150
|
-
isWritable: true,
|
|
151
|
-
},
|
|
152
|
-
rentalState: { value: input.rentalState ?? null, isWritable: true },
|
|
153
81
|
fleet: { value: input.fleet ?? null, isWritable: true },
|
|
154
82
|
gameId: { value: input.gameId ?? null, isWritable: false },
|
|
155
83
|
starbase: { value: input.starbase ?? null, isWritable: false },
|
|
@@ -160,37 +88,12 @@ export function getCloseContractInstruction(input, config) {
|
|
|
160
88
|
isWritable: false,
|
|
161
89
|
},
|
|
162
90
|
sageProgram: { value: input.sageProgram ?? null, isWritable: false },
|
|
163
|
-
feeTokenAccount: { value: input.feeTokenAccount ?? null, isWritable: true },
|
|
164
|
-
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
165
|
-
associatedTokenProgram: {
|
|
166
|
-
value: input.associatedTokenProgram ?? null,
|
|
167
|
-
isWritable: false,
|
|
168
|
-
},
|
|
169
|
-
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
170
91
|
};
|
|
171
92
|
const accounts = originalAccounts;
|
|
172
|
-
// Resolve default values.
|
|
173
|
-
if (!accounts.tokenProgram.value) {
|
|
174
|
-
accounts.tokenProgram.value =
|
|
175
|
-
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
|
|
176
|
-
}
|
|
177
|
-
if (!accounts.associatedTokenProgram.value) {
|
|
178
|
-
accounts.associatedTokenProgram.value =
|
|
179
|
-
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
180
|
-
}
|
|
181
|
-
if (!accounts.systemProgram.value) {
|
|
182
|
-
accounts.systemProgram.value =
|
|
183
|
-
'11111111111111111111111111111111';
|
|
184
|
-
}
|
|
185
93
|
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
186
94
|
const instruction = {
|
|
187
95
|
accounts: [
|
|
188
96
|
getAccountMeta(accounts.owner),
|
|
189
|
-
getAccountMeta(accounts.config),
|
|
190
|
-
getAccountMeta(accounts.mint),
|
|
191
|
-
getAccountMeta(accounts.ownerTokenAccount),
|
|
192
|
-
getAccountMeta(accounts.rentalTokenAccount),
|
|
193
|
-
getAccountMeta(accounts.rentalState),
|
|
194
97
|
getAccountMeta(accounts.fleet),
|
|
195
98
|
getAccountMeta(accounts.gameId),
|
|
196
99
|
getAccountMeta(accounts.starbase),
|
|
@@ -198,10 +101,6 @@ export function getCloseContractInstruction(input, config) {
|
|
|
198
101
|
getAccountMeta(accounts.contract),
|
|
199
102
|
getAccountMeta(accounts.rentalAuthority),
|
|
200
103
|
getAccountMeta(accounts.sageProgram),
|
|
201
|
-
getAccountMeta(accounts.feeTokenAccount),
|
|
202
|
-
getAccountMeta(accounts.tokenProgram),
|
|
203
|
-
getAccountMeta(accounts.associatedTokenProgram),
|
|
204
|
-
getAccountMeta(accounts.systemProgram),
|
|
205
104
|
],
|
|
206
105
|
programAddress,
|
|
207
106
|
data: getCloseContractInstructionDataEncoder().encode({}),
|
|
@@ -209,7 +108,7 @@ export function getCloseContractInstruction(input, config) {
|
|
|
209
108
|
return instruction;
|
|
210
109
|
}
|
|
211
110
|
export function parseCloseContractInstruction(instruction) {
|
|
212
|
-
if (instruction.accounts.length <
|
|
111
|
+
if (instruction.accounts.length < 8) {
|
|
213
112
|
// TODO: Coded error.
|
|
214
113
|
throw new Error('Not enough accounts');
|
|
215
114
|
}
|
|
@@ -223,11 +122,6 @@ export function parseCloseContractInstruction(instruction) {
|
|
|
223
122
|
programAddress: instruction.programAddress,
|
|
224
123
|
accounts: {
|
|
225
124
|
owner: getNextAccount(),
|
|
226
|
-
config: getNextAccount(),
|
|
227
|
-
mint: getNextAccount(),
|
|
228
|
-
ownerTokenAccount: getNextAccount(),
|
|
229
|
-
rentalTokenAccount: getNextAccount(),
|
|
230
|
-
rentalState: getNextAccount(),
|
|
231
125
|
fleet: getNextAccount(),
|
|
232
126
|
gameId: getNextAccount(),
|
|
233
127
|
starbase: getNextAccount(),
|
|
@@ -235,10 +129,6 @@ export function parseCloseContractInstruction(instruction) {
|
|
|
235
129
|
contract: getNextAccount(),
|
|
236
130
|
rentalAuthority: getNextAccount(),
|
|
237
131
|
sageProgram: getNextAccount(),
|
|
238
|
-
feeTokenAccount: getNextAccount(),
|
|
239
|
-
tokenProgram: getNextAccount(),
|
|
240
|
-
associatedTokenProgram: getNextAccount(),
|
|
241
|
-
systemProgram: getNextAccount(),
|
|
242
132
|
},
|
|
243
133
|
data: getCloseContractInstructionDataDecoder().decode(instruction.data),
|
|
244
134
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeContract.js","sourceRoot":"","sources":["../../../../src/codama/instructions/closeContract.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"closeContract.js","sourceRoot":"","sources":["../../../../src/codama/instructions/closeContract.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GAejB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAwB,MAAM,WAAW,CAAC;AAExE,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,UAAU,CAAC;IACzD,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG;CACnC,CAAC,CAAC;AAEH,MAAM,UAAU,kCAAkC;IAChD,OAAO,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAChD,4BAA4B,CAC7B,CAAC;AACJ,CAAC;AAoDD,MAAM,UAAU,sCAAsC;IACpD,OAAO,gBAAgB,CACrB,gBAAgB,CAAC,CAAC,CAAC,eAAe,EAAE,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3E,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,4BAA4B,EAAE,CAAC,CACvE,CAAC;AACJ,CAAC;AAED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,CAAC;YACjC,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC;YACxC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC;SACrC;QACD,cAAc;QACd,IAAI,EAAE,sCAAsC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;KAW1D,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAoBD,MAAM,UAAU,6BAA6B,CAI3C,WAEkC;IAElC,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,qBAAqB;QACrB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,MAAM,cAAc,GAAG,GAAG,EAAE;QAC1B,MAAM,WAAW,GAAG,WAAW,CAAC,QAAS,CAAC,YAAY,CAAE,CAAC;QACzD,YAAY,IAAI,CAAC,CAAC;QAClB,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IACF,OAAO;QACL,cAAc,EAAE,WAAW,CAAC,cAAc;QAC1C,QAAQ,EAAE;YACR,KAAK,EAAE,cAAc,EAAE;YACvB,KAAK,EAAE,cAAc,EAAE;YACvB,MAAM,EAAE,cAAc,EAAE;YACxB,QAAQ,EAAE,cAAc,EAAE;YAC1B,cAAc,EAAE,cAAc,EAAE;YAChC,QAAQ,EAAE,cAAc,EAAE;YAC1B,eAAe,EAAE,cAAc,EAAE;YACjC,WAAW,EAAE,cAAc,EAAE;SAC9B;QACD,IAAI,EAAE,sCAAsC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;KACxE,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/codama/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/codama/instructions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -33,24 +33,20 @@ export function identifySrslyAccount(account) {
|
|
|
33
33
|
export var SrslyInstruction;
|
|
34
34
|
(function (SrslyInstruction) {
|
|
35
35
|
SrslyInstruction[SrslyInstruction["AcceptRental"] = 0] = "AcceptRental";
|
|
36
|
-
SrslyInstruction[SrslyInstruction["
|
|
37
|
-
SrslyInstruction[SrslyInstruction["
|
|
38
|
-
SrslyInstruction[SrslyInstruction["
|
|
39
|
-
SrslyInstruction[SrslyInstruction["
|
|
40
|
-
SrslyInstruction[SrslyInstruction["
|
|
41
|
-
SrslyInstruction[SrslyInstruction["
|
|
42
|
-
SrslyInstruction[SrslyInstruction["
|
|
43
|
-
SrslyInstruction[SrslyInstruction["
|
|
44
|
-
SrslyInstruction[SrslyInstruction["UpdateConfig"] = 9] = "UpdateConfig";
|
|
36
|
+
SrslyInstruction[SrslyInstruction["CancelRental"] = 1] = "CancelRental";
|
|
37
|
+
SrslyInstruction[SrslyInstruction["CloseContract"] = 2] = "CloseContract";
|
|
38
|
+
SrslyInstruction[SrslyInstruction["CloseRental"] = 3] = "CloseRental";
|
|
39
|
+
SrslyInstruction[SrslyInstruction["CreateContract"] = 4] = "CreateContract";
|
|
40
|
+
SrslyInstruction[SrslyInstruction["InitializeConfig"] = 5] = "InitializeConfig";
|
|
41
|
+
SrslyInstruction[SrslyInstruction["PayRental"] = 6] = "PayRental";
|
|
42
|
+
SrslyInstruction[SrslyInstruction["ResetRental"] = 7] = "ResetRental";
|
|
43
|
+
SrslyInstruction[SrslyInstruction["UpdateConfig"] = 8] = "UpdateConfig";
|
|
45
44
|
})(SrslyInstruction || (SrslyInstruction = {}));
|
|
46
45
|
export function identifySrslyInstruction(instruction) {
|
|
47
46
|
const data = 'data' in instruction ? instruction.data : instruction;
|
|
48
47
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([192, 221, 241, 212, 141, 161, 36, 146])), 0)) {
|
|
49
48
|
return SrslyInstruction.AcceptRental;
|
|
50
49
|
}
|
|
51
|
-
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([3, 168, 37, 73, 140, 194, 156, 165])), 0)) {
|
|
52
|
-
return SrslyInstruction.CancelContract;
|
|
53
|
-
}
|
|
54
50
|
if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([97, 204, 63, 8, 84, 34, 28, 43])), 0)) {
|
|
55
51
|
return SrslyInstruction.CancelRental;
|
|
56
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"srsly.js","sourceRoot":"","sources":["../../../../src/codama/programs/srsly.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"srsly.js","sourceRoot":"","sources":["../../../../src/codama/programs/srsly.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAC;AAarB,MAAM,CAAC,MAAM,qBAAqB,GAChC,6CAAuG,CAAC;AAE1G,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mDAAM,CAAA;IACN,iEAAa,CAAA;IACb,6DAAW,CAAA;IACX,mDAAM,CAAA;AACR,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,MAAM,UAAU,oBAAoB,CAClC,OAA0D;IAE1D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,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CACxD,EACD,CAAC,CACF,EACD,CAAC;QACD,OAAO,gBAAgB,CAAC,SAAS,CAAC;IACpC,CAAC;IACD,IACE,aAAa,CACX,IAAI,EACJ,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACzC,IAAI,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CACtD,EACD,CAAC,CACF,EACD,CAAC;QACD,OAAO,gBAAgB,CAAC,WAAW,CAAC;IACtC,CAAC;IACD,IACE,aAAa,CACX,IAAI,EACJ,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACzC,IAAI,UAAU,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,CACrD,EACD,CAAC,CACF,EACD,CAAC;QACD,OAAO,gBAAgB,CAAC,YAAY,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getModule, createConfigSelector } from '../utils/config';
|
|
2
|
-
import {
|
|
1
|
+
import { getModule, createConfigSelector, resolveProgramAddresses } from '../utils/config';
|
|
2
|
+
import { toAddress } from '../utils/constants';
|
|
3
3
|
import { deriveGameAccounts } from '../utils';
|
|
4
4
|
import { createFluentInstruction, createFluentConfigSelector } from '../utils/instruction-converter';
|
|
5
5
|
/**
|
|
@@ -35,6 +35,9 @@ import { createFluentInstruction, createFluentConfigSelector } from '../utils/in
|
|
|
35
35
|
* gameId: 'custom-game-id...'
|
|
36
36
|
* });
|
|
37
37
|
*
|
|
38
|
+
* // Configure gameId via .set() instead of parameter
|
|
39
|
+
* await closeContract(params).set({ gameId: 'custom-game-id...' });
|
|
40
|
+
*
|
|
38
41
|
* // Use the instruction with your preferred Solana library
|
|
39
42
|
* // instruction is compatible with both @solana/kit and @solana/web3.js
|
|
40
43
|
* ```
|
|
@@ -46,28 +49,25 @@ import { createFluentInstruction, createFluentConfigSelector } from '../utils/in
|
|
|
46
49
|
* Internal function to close a contract instruction with configuration options
|
|
47
50
|
*/
|
|
48
51
|
async function _closeContract(params, config) {
|
|
49
|
-
const { owner, fleet, contract, faction,
|
|
50
|
-
// Get the
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const ownerAddress = typeof owner === 'string' ? owner :
|
|
54
|
-
(owner && typeof owner === 'object' && 'address' in owner) ? owner.address : owner;
|
|
55
|
-
const derivedAccounts = await deriveGameAccounts(ownerAddress, faction, actualGameId, 0, // starbaseSeqId
|
|
52
|
+
const { owner, fleet, contract, faction, } = params;
|
|
53
|
+
// Get the resolved addresses from config (including network-specific addresses)
|
|
54
|
+
const resolvedAddresses = resolveProgramAddresses(config || {});
|
|
55
|
+
const derivedAccounts = await deriveGameAccounts(toAddress(owner), faction, resolvedAddresses.gameId, 0, // starbaseSeqId
|
|
56
56
|
config);
|
|
57
57
|
// Get network-specific codama functions from centralized config
|
|
58
58
|
const instructionsModule = getModule('instructions');
|
|
59
59
|
const programsModule = getModule('programs');
|
|
60
60
|
const { getCloseContractInstructionAsync } = instructionsModule;
|
|
61
|
-
const { SRSLY_PROGRAM_ADDRESS
|
|
61
|
+
const { SRSLY_PROGRAM_ADDRESS } = programsModule;
|
|
62
62
|
// Let codama handle all the account derivation and instruction building
|
|
63
63
|
const input = {
|
|
64
64
|
owner, // Pass as-is (string or signer)
|
|
65
|
-
fleet: toAddress(fleet), //
|
|
66
|
-
contract: toAddress(contract), //
|
|
67
|
-
starbase: derivedAccounts.starbase, //
|
|
68
|
-
starbasePlayer: derivedAccounts.starbasePlayer, //
|
|
69
|
-
gameId:
|
|
70
|
-
sageProgram:
|
|
65
|
+
fleet: toAddress(fleet), // Convert fleet to Address
|
|
66
|
+
contract: toAddress(contract), // Convert contract to Address
|
|
67
|
+
starbase: toAddress(derivedAccounts.starbase), // Convert starbase to Address
|
|
68
|
+
starbasePlayer: toAddress(derivedAccounts.starbasePlayer), // Convert starbasePlayer to Address
|
|
69
|
+
gameId: resolvedAddresses.gameId, // Already Address from resolved config or param override
|
|
70
|
+
sageProgram: resolvedAddresses.sageProgramAddress, // Already Address from resolveProgramAddresses
|
|
71
71
|
};
|
|
72
72
|
const rawInstruction = await getCloseContractInstructionAsync(input, { programAddress: SRSLY_PROGRAM_ADDRESS });
|
|
73
73
|
return createFluentInstruction(rawInstruction);
|
|
@@ -87,7 +87,7 @@ async function _closeContract(params, config) {
|
|
|
87
87
|
* await closeContract(params).set({ programs: 'mainnet' });
|
|
88
88
|
*
|
|
89
89
|
* // Override game ID
|
|
90
|
-
* await closeContract(params).set({ gameId: 'custom...' });
|
|
90
|
+
* await closeContract(params).set({ gameId: 'custom...' }); // gameId configured via .set()
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
export function closeContract(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/contract/close.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAA2C,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/contract/close.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,uBAAuB,EAA2C,MAAM,iBAAiB,CAAC;AACpI,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAqD,MAA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qB,EAAE,CAC1C,CAAC;IACF,OAAO,uBAAuB,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA2B;IAE3B,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtF,OAAO,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAClD,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,gCAAgC,CAAC,KAAU,EAAE,OAAa;IACxE,OAAO,oBAAoB,CAAC,KAAK,IAAI,EAAE;QACrC,MAAM,kBAAkB,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,gCAAgC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Unified contract creation - works with both @solana/kit and @solana/web3.js
|
|
3
3
|
* Uses strings for all addresses to eliminate library-specific type complexity
|
|
4
4
|
*/
|
|
5
|
-
import { getModule, createConfigSelector } from '../utils/config';
|
|
6
|
-
import {
|
|
5
|
+
import { getModule, createConfigSelector, resolveProgramAddresses } from '../utils/config';
|
|
6
|
+
import { toAddress } from '../utils/constants';
|
|
7
7
|
import { validateDurationAlignment, paymentFrequencyStringToSeconds } from '../utils/paymentFrequency';
|
|
8
8
|
import { isValidPaymentFrequency } from '../types/paymentFrequency';
|
|
9
9
|
import { createFluentInstruction, createFluentConfigSelector } from '../utils/instruction-converter';
|
|
@@ -11,7 +11,7 @@ import { createFluentInstruction, createFluentConfigSelector } from '../utils/in
|
|
|
11
11
|
* Internal function to create a rental contract instruction with configuration options
|
|
12
12
|
*/
|
|
13
13
|
async function _createContract(params, config) {
|
|
14
|
-
const { owner, fleet, ownerProfile, rate, durationMax, paymentsFreq,
|
|
14
|
+
const { owner, fleet, ownerProfile, rate, durationMax, paymentsFreq, ownerKeyIndex = 0, } = params;
|
|
15
15
|
// Validate payment frequency
|
|
16
16
|
if (!isValidPaymentFrequency(paymentsFreq)) {
|
|
17
17
|
throw new Error(`Invalid payment frequency: "${paymentsFreq}". Valid values are: ${JSON.stringify(Object.keys({ daily: true, weekly: true, monthly: true, hourly: true }))}`);
|
|
@@ -22,17 +22,15 @@ async function _createContract(params, config) {
|
|
|
22
22
|
const durationMin = paymentFrequencyStringToSeconds(paymentsFreq);
|
|
23
23
|
// Convert the payment frequency to the format expected by the Rust program (with @ prefix)
|
|
24
24
|
const paymentsFreqWithPrefix = `@${paymentsFreq}`;
|
|
25
|
-
// Get
|
|
26
|
-
const
|
|
27
|
-
const actualSageProgramAddress = sageProgramAddress ? toAddress(sageProgramAddress) : await getSageProgramAddress(config);
|
|
28
|
-
const actualAtlasMint = atlasMint ? toAddress(atlasMint) : await getAtlasMint(config);
|
|
25
|
+
// Get the resolved addresses from config (including network-specific addresses)
|
|
26
|
+
const resolvedAddresses = resolveProgramAddresses(config || {});
|
|
29
27
|
const input = {
|
|
30
28
|
owner, // Pass as-is (string or signer)
|
|
31
|
-
fleet: toAddress(fleet), //
|
|
32
|
-
ownerProfile: toAddress(ownerProfile), //
|
|
33
|
-
gameId:
|
|
34
|
-
sageProgram:
|
|
35
|
-
mint:
|
|
29
|
+
fleet: toAddress(fleet), // Convert fleet to Address
|
|
30
|
+
ownerProfile: toAddress(ownerProfile), // Convert ownerProfile to Address
|
|
31
|
+
gameId: resolvedAddresses.gameId, // Already Address from resolveProgramAddresses
|
|
32
|
+
sageProgram: resolvedAddresses.sageProgramAddress, // Already Address from resolveProgramAddresses
|
|
33
|
+
mint: resolvedAddresses.atlasMint, // Already Address from resolveProgramAddresses
|
|
36
34
|
durationMin,
|
|
37
35
|
durationMax,
|
|
38
36
|
rate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,uBAAuB,EAAsB,MAAM,iBAAiB,CAAC;AAC/G,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAA0B,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAqD,MAAM,gCAAgC,CAAC;AAmBxJ;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,MAA4B,EAAE,MAAsB;IACjF,MAAM,EACJ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,aAAa,GAAG,CAAC,GAClB,GAAG,MAAM,CAAC;IAEX,6BAA6B;IAC7B,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,+BAA+B,YAAY,wBAAwB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAChL,CAAC;IAED,8BAA8B;IAC9B,yBAAyB,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC;IAE7D,yEAAyE;IACzE,MAAM,WAAW,GAAG,+BAA+B,CAAC,YAAY,CAAC,CAAC;IAElE,2FAA2F;IAC3F,MAAM,sBAAsB,GAAG,IAAI,YAAY,EAAE,CAA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sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|