@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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network configuration for the SRSLY SDK
|
|
3
|
+
*/
|
|
4
|
+
// Default network when none is specified
|
|
5
|
+
const DEFAULT_NETWORK = 'devnet';
|
|
6
|
+
// Global configuration state
|
|
7
|
+
let globalConfig = {};
|
|
8
|
+
/**
|
|
9
|
+
* Set global configuration options that will be used as defaults for all SDK operations
|
|
10
|
+
* @param config Configuration options to set globally
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Set mainnet as default for all operations
|
|
15
|
+
* setConfig({ network: 'mainnet' });
|
|
16
|
+
*
|
|
17
|
+
* // Now all operations use mainnet by default
|
|
18
|
+
* await createContract(params); // Uses mainnet
|
|
19
|
+
* await acceptRental(params); // Uses mainnet
|
|
20
|
+
*
|
|
21
|
+
* // Can still override per instruction
|
|
22
|
+
* await createContract(params).set({ network: 'devnet' }); // Uses devnet
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function setConfig(config) {
|
|
26
|
+
globalConfig = { ...config };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the current global configuration
|
|
30
|
+
* @returns Current global configuration options
|
|
31
|
+
*/
|
|
32
|
+
export function getConfig() {
|
|
33
|
+
return { ...globalConfig };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Clear global configuration (resets to devnet defaults)
|
|
37
|
+
*/
|
|
38
|
+
export function clearConfig() {
|
|
39
|
+
globalConfig = {};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set global network (convenience function for backward compatibility)
|
|
43
|
+
* @param network Network to set as global default
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // Set mainnet as default for all operations
|
|
48
|
+
* setNetwork('mainnet');
|
|
49
|
+
*
|
|
50
|
+
* // Equivalent to:
|
|
51
|
+
* setConfig({ network: 'mainnet' });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function setNetwork(network) {
|
|
55
|
+
setConfig({ network });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get current global network (convenience function for backward compatibility)
|
|
59
|
+
* @returns Current global network or 'devnet' if not set
|
|
60
|
+
*/
|
|
61
|
+
export function getNetwork() {
|
|
62
|
+
return globalConfig.network || 'devnet';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get the effective configuration by merging global config with provided overrides
|
|
66
|
+
* @param overrides Optional configuration overrides
|
|
67
|
+
* @returns Merged configuration with global defaults and any overrides
|
|
68
|
+
*/
|
|
69
|
+
function getEffectiveConfig(overrides) {
|
|
70
|
+
return { ...globalConfig, ...overrides };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Dynamically import network-specific codama modules
|
|
74
|
+
* @param modulePath The module path relative to the network directory
|
|
75
|
+
* @param network Network to use (defaults to devnet if not specified)
|
|
76
|
+
* @returns Promise resolving to the imported module
|
|
77
|
+
*/
|
|
78
|
+
export async function importNetworkModule(modulePath, network) {
|
|
79
|
+
const targetNetwork = network || DEFAULT_NETWORK;
|
|
80
|
+
const fullPath = `./codama/${targetNetwork}/${modulePath}`;
|
|
81
|
+
try {
|
|
82
|
+
// Use dynamic import which works in both ESM and CJS with ES2020+
|
|
83
|
+
const module = await import(fullPath);
|
|
84
|
+
return module;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new Error(`Failed to import ${fullPath} for network ${targetNetwork}: ${error}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const moduleCache = {};
|
|
91
|
+
/**
|
|
92
|
+
* Cached import for better performance
|
|
93
|
+
* Uses global config network as default if no network specified
|
|
94
|
+
*/
|
|
95
|
+
export async function getCachedNetworkModule(modulePath, network) {
|
|
96
|
+
const targetNetwork = network || globalConfig.network || DEFAULT_NETWORK;
|
|
97
|
+
const cacheKey = `${targetNetwork}:${modulePath}`;
|
|
98
|
+
if (moduleCache[cacheKey]) {
|
|
99
|
+
return moduleCache[cacheKey];
|
|
100
|
+
}
|
|
101
|
+
const module = await importNetworkModule(modulePath, targetNetwork);
|
|
102
|
+
moduleCache[cacheKey] = module;
|
|
103
|
+
return module;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create a chainable config selector with existing configuration state.
|
|
107
|
+
* This enables config chaining by merging new options with existing ones.
|
|
108
|
+
*
|
|
109
|
+
* Used internally when .set() is called on an existing ConfigSelector.
|
|
110
|
+
*
|
|
111
|
+
* @param executeFn - The function to execute with merged configuration
|
|
112
|
+
* @param existingConfig - The current configuration state to merge with
|
|
113
|
+
* @returns A ConfigSelector that can chain additional .set() calls
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* // This creates a chainable selector that merges { network: 'devnet' }
|
|
117
|
+
* // with any additional config options passed to subsequent .set() calls
|
|
118
|
+
* createChainableConfigSelector(executeFn, { network: 'devnet' })
|
|
119
|
+
*/
|
|
120
|
+
function createChainableConfigSelector(executeFn, existingConfig) {
|
|
121
|
+
const selector = {
|
|
122
|
+
set: (additionalOptions) => createChainableConfigSelector(executeFn, { ...existingConfig, ...additionalOptions }),
|
|
123
|
+
build: () => executeFn(existingConfig),
|
|
124
|
+
// Implement PromiseLike to allow direct awaiting
|
|
125
|
+
then(onfulfilled, onrejected) {
|
|
126
|
+
return executeFn(existingConfig).then(onfulfilled, onrejected);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return selector;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Create the initial fluent config selector for a function.
|
|
133
|
+
* This is the main entry point for the fluent configuration API.
|
|
134
|
+
*
|
|
135
|
+
* The returned selector can be:
|
|
136
|
+
* - Awaited directly (uses global config + devnet fallback)
|
|
137
|
+
* - Configured with .set() to override network/constants
|
|
138
|
+
* - Chained with multiple .set() calls
|
|
139
|
+
*
|
|
140
|
+
* @param executeFn - The function to execute with optional configuration
|
|
141
|
+
* @returns A ConfigSelector that supports fluent configuration
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* // Usage patterns:
|
|
145
|
+
* setConfig({ network: 'mainnet' });
|
|
146
|
+
* await createConfigSelector(executeFn) // Direct await (uses global mainnet)
|
|
147
|
+
* await createConfigSelector(executeFn).set({...}) // Override global config
|
|
148
|
+
* await createConfigSelector(executeFn).set({...}).set({...}) // Chained configs
|
|
149
|
+
*/
|
|
150
|
+
export function createConfigSelector(executeFn) {
|
|
151
|
+
const selector = {
|
|
152
|
+
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
153
|
+
build: () => executeFn(getEffectiveConfig()),
|
|
154
|
+
// Implement PromiseLike to allow direct awaiting
|
|
155
|
+
then(onfulfilled, onrejected) {
|
|
156
|
+
return executeFn(getEffectiveConfig()).then(onfulfilled, onrejected);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return selector;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,yCAAyC;AACzC,MAAM,eAAe,GAAY,QAAQ,CAAC;AAE1C,6BAA6B;AAC7B,IAAI,YAAY,GAAkB,EAAE,CAAC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS,CAAC,MAAqB;IAC7C,YAAY,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,YAAY,GA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,EAAE,aAAa,CAAC,CAAC;IACvE,WAAW,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IAC/B,OAAO,MAAM,CAAC;AAChB,CAAC;AAkBD;;;;;;;;;;;;;;GAcG;AACH,SAAS,6BAA6B,CACpC,SAAiD,EACjD,cAA6B;IAE7B,MAAM,QAAQ,GAAG;QACf,GAAG,EAAE,CAAC,iBAAgC,EAAE,EAAE,CACxC,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAAC;QACvF,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC;QACtC,iDAAiD;QACjD,IAAI,CACF,WAAqE,EACrE,UAAuE;YAEvE,OAAO,SAAS,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAiD;IAEjD,MAAM,QAAQ,GAAG;QACf,GAAG,EAAE,CAAC,OAAsB,EAAE,EAAE,CAAC,6BAA6B,CAAC,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACtG,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC5C,iDAAiD;QACjD,IAAI,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"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { getCachedNetworkModule } from '
|
|
1
|
+
import { getCachedNetworkModule, getConfig } from './config';
|
|
2
|
+
// Seed constants
|
|
3
|
+
export const STARBASE_SEED = 'Starbase';
|
|
4
|
+
export const STARBASE_PLAYER_SEED = 'starbase_player';
|
|
5
|
+
export const SAGE_PLAYER_PROFILE_SEED = 'sage_player_profile';
|
|
6
|
+
export const PROFILE_FACTION_SEED = 'profile_faction';
|
|
7
|
+
// Token conversion constants
|
|
8
|
+
export const ATLAS_TO_STARDUST = 100_000_000; // 1 ATLAS = 100,000,000 stardust
|
|
2
9
|
// Export async functions to get network-specific constants
|
|
3
10
|
export async function getPaymentFrequency() {
|
|
4
11
|
const module = await getCachedNetworkModule('types');
|
|
@@ -12,15 +19,58 @@ export async function getSrslyProgramAddress() {
|
|
|
12
19
|
export async function getProgramId() {
|
|
13
20
|
return await getSrslyProgramAddress();
|
|
14
21
|
}
|
|
15
|
-
//
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Network-specific constants with configuration support
|
|
23
|
+
export async function getSageProgramAddress(config) {
|
|
24
|
+
// Merge global config with provided config
|
|
25
|
+
const globalConfig = getConfig();
|
|
26
|
+
const effectiveConfig = { ...globalConfig, ...config };
|
|
27
|
+
if (effectiveConfig?.sageProgramAddress)
|
|
28
|
+
return effectiveConfig.sageProgramAddress;
|
|
29
|
+
const targetNetwork = effectiveConfig?.network; // Uses global config or devnet default
|
|
30
|
+
try {
|
|
31
|
+
const constantsModule = await getCachedNetworkModule('constants', targetNetwork);
|
|
32
|
+
return constantsModule.SAGE_PROGRAM_ADDRESS;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Fallback to programs module or hardcoded default
|
|
36
|
+
const programsModule = await getCachedNetworkModule('programs', targetNetwork);
|
|
37
|
+
return programsModule.SAGE_PROGRAM_ADDRESS || 'sAgezwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function getProfileFactionProgramAddress(config) {
|
|
41
|
+
// Merge global config with provided config
|
|
42
|
+
const globalConfig = getConfig();
|
|
43
|
+
const effectiveConfig = { ...globalConfig, ...config };
|
|
44
|
+
if (effectiveConfig?.profileFactionProgramAddress)
|
|
45
|
+
return effectiveConfig.profileFactionProgramAddress;
|
|
46
|
+
const targetNetwork = effectiveConfig?.network; // Uses global config or devnet default
|
|
47
|
+
try {
|
|
48
|
+
const constantsModule = await getCachedNetworkModule('constants', targetNetwork);
|
|
49
|
+
return constantsModule.PROFILE_FACTION_PROGRAM_ADDRESS;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Fallback to programs module or hardcoded default
|
|
53
|
+
const programsModule = await getCachedNetworkModule('programs', targetNetwork);
|
|
54
|
+
return programsModule.PROFILE_FACTION_PROGRAM_ADDRESS || 'pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function getSageGameId(config) {
|
|
58
|
+
// Merge global config with provided config
|
|
59
|
+
const globalConfig = getConfig();
|
|
60
|
+
const effectiveConfig = { ...globalConfig, ...config };
|
|
61
|
+
if (effectiveConfig?.gameId)
|
|
62
|
+
return effectiveConfig.gameId;
|
|
63
|
+
const targetNetwork = effectiveConfig?.network; // Uses global config or devnet default
|
|
64
|
+
try {
|
|
65
|
+
const constantsModule = await getCachedNetworkModule('constants', targetNetwork);
|
|
66
|
+
return constantsModule.SAGE_GAME_ID;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Fallback to programs module or hardcoded default
|
|
70
|
+
const programsModule = await getCachedNetworkModule('programs', targetNetwork);
|
|
71
|
+
return programsModule.SAGE_GAME_ID || 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
24
74
|
// Faction-specific CSS coordinates for starbase derivation
|
|
25
75
|
export const FACTION_SPECIFIC_CSS = {
|
|
26
76
|
mud: { x: 0, y: -39 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AAEjF,iBAAiB;AACjB,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AACxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AACtD,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAEtD,6BAA6B;AAC7B,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC,CAAC,iCAAiC;AAE/E,2DAA2D;AAC3D,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,gBAAgB,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,qBAAqB,CAAC;AACtC,CAAC;AAGD,0CAA0C;AAC1C,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,OAAO,MAAM,sBAAsB,EAAE,CAAC;AACxC,CAAC;AAED,wDAAwD;AACxD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAsB;IAChE,2CAA2C;IAC3C,MAAM,YAAY,GAAG,SAAS,EAAE,CAAC;IACjC,MAAM,eAAe,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IAEvD,IAAI,eAAe,EAAE,kBAAkB;QAAE,OAA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,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getBytesEncoder, getAddressEncoder, getProgramDerivedAddress } from '@solana/kit';
|
|
2
|
-
import {
|
|
2
|
+
import { FACTION_MAPPING, FACTION_SPECIFIC_CSS, PROFILE_FACTION_SEED, SAGE_PLAYER_PROFILE_SEED, STARBASE_PLAYER_SEED, STARBASE_SEED } from './constants';
|
|
3
|
+
import { getSageGameId, getSageProgramAddress, getProfileFactionProgramAddress } from './constants';
|
|
3
4
|
/**
|
|
4
5
|
* Helper function to convert a string seed to a Uint8Array
|
|
5
6
|
* This is necessary for @solana/kit's getBytesEncoder().encode()
|
|
@@ -14,11 +15,13 @@ function seedToBytes(seed) {
|
|
|
14
15
|
* Helper function to derive the borrower's profile faction account
|
|
15
16
|
*
|
|
16
17
|
* @param profile The borrower's profile address
|
|
18
|
+
* @param config Optional configuration for network-specific constants
|
|
17
19
|
* @returns Promise that resolves to the derived profile faction address
|
|
18
20
|
*/
|
|
19
|
-
export async function deriveProfileFaction(profile) {
|
|
21
|
+
export async function deriveProfileFaction(profile, config) {
|
|
22
|
+
const programAddress = await getProfileFactionProgramAddress(config);
|
|
20
23
|
const [address] = await getProgramDerivedAddress({
|
|
21
|
-
programAddress:
|
|
24
|
+
programAddress: programAddress,
|
|
22
25
|
seeds: [
|
|
23
26
|
seedToBytes(PROFILE_FACTION_SEED),
|
|
24
27
|
getAddressEncoder().encode(profile)
|
|
@@ -30,16 +33,21 @@ export async function deriveProfileFaction(profile) {
|
|
|
30
33
|
* Helper function to derive the sage player profile
|
|
31
34
|
*
|
|
32
35
|
* @param borrowerProfile The borrower's profile address
|
|
33
|
-
* @param gameId The game ID (
|
|
36
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
37
|
+
* @param config Optional configuration for network-specific constants
|
|
34
38
|
* @returns Promise that resolves to the derived sage player profile address
|
|
35
39
|
*/
|
|
36
|
-
export async function deriveSagePlayerProfile(borrowerProfile, gameId
|
|
40
|
+
export async function deriveSagePlayerProfile(borrowerProfile, gameId, config) {
|
|
41
|
+
const [programAddress, actualGameId] = await Promise.all([
|
|
42
|
+
getSageProgramAddress(config),
|
|
43
|
+
gameId || getSageGameId(config)
|
|
44
|
+
]);
|
|
37
45
|
const [address] = await getProgramDerivedAddress({
|
|
38
|
-
programAddress:
|
|
46
|
+
programAddress: programAddress,
|
|
39
47
|
seeds: [
|
|
40
48
|
seedToBytes(SAGE_PLAYER_PROFILE_SEED),
|
|
41
49
|
getAddressEncoder().encode(borrowerProfile),
|
|
42
|
-
getAddressEncoder().encode(
|
|
50
|
+
getAddressEncoder().encode(actualGameId)
|
|
43
51
|
]
|
|
44
52
|
});
|
|
45
53
|
return address;
|
|
@@ -48,10 +56,11 @@ export async function deriveSagePlayerProfile(borrowerProfile, gameId = DEFAULT_
|
|
|
48
56
|
* Helper function to derive the starbase address based on faction
|
|
49
57
|
*
|
|
50
58
|
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
51
|
-
* @param gameId The game ID (
|
|
59
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
60
|
+
* @param config Optional configuration for network-specific constants
|
|
52
61
|
* @returns Promise that resolves to the derived starbase address
|
|
53
62
|
*/
|
|
54
|
-
export async function deriveStarbase(faction, gameId
|
|
63
|
+
export async function deriveStarbase(faction, gameId, config) {
|
|
55
64
|
// Convert faction to string representation if it's a number
|
|
56
65
|
const factionName = typeof faction === 'number'
|
|
57
66
|
? FACTION_MAPPING[faction]
|
|
@@ -62,6 +71,11 @@ export async function deriveStarbase(faction, gameId = DEFAULT_GAME_ID) {
|
|
|
62
71
|
}
|
|
63
72
|
// Get coordinates for the faction
|
|
64
73
|
const coords = FACTION_SPECIFIC_CSS[factionName];
|
|
74
|
+
// Get network-specific constants
|
|
75
|
+
const [programAddress, actualGameId] = await Promise.all([
|
|
76
|
+
getSageProgramAddress(config),
|
|
77
|
+
gameId || getSageGameId(config)
|
|
78
|
+
]);
|
|
65
79
|
// Convert coordinates to bytes (little-endian, two's complement)
|
|
66
80
|
const xCoord = new DataView(new ArrayBuffer(8));
|
|
67
81
|
const yCoord = new DataView(new ArrayBuffer(8));
|
|
@@ -71,10 +85,10 @@ export async function deriveStarbase(faction, gameId = DEFAULT_GAME_ID) {
|
|
|
71
85
|
const xBytes = new Uint8Array(xCoord.buffer);
|
|
72
86
|
const yBytes = new Uint8Array(yCoord.buffer);
|
|
73
87
|
const [address] = await getProgramDerivedAddress({
|
|
74
|
-
programAddress:
|
|
88
|
+
programAddress: programAddress,
|
|
75
89
|
seeds: [
|
|
76
90
|
seedToBytes(STARBASE_SEED),
|
|
77
|
-
getAddressEncoder().encode(
|
|
91
|
+
getAddressEncoder().encode(actualGameId),
|
|
78
92
|
getBytesEncoder().encode(xBytes),
|
|
79
93
|
getBytesEncoder().encode(yBytes)
|
|
80
94
|
]
|
|
@@ -87,15 +101,18 @@ export async function deriveStarbase(faction, gameId = DEFAULT_GAME_ID) {
|
|
|
87
101
|
* @param sagePlayerProfile The sage player profile address
|
|
88
102
|
* @param starbase The starbase address
|
|
89
103
|
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
104
|
+
* @param config Optional configuration for network-specific constants
|
|
90
105
|
* @returns Promise that resolves to the derived starbase player address
|
|
91
106
|
*/
|
|
92
|
-
export async function deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId = 0) {
|
|
107
|
+
export async function deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId = 0, config) {
|
|
108
|
+
// Get network-specific SAGE program address
|
|
109
|
+
const programAddress = await getSageProgramAddress(config);
|
|
93
110
|
// Convert sequence ID to bytes (little-endian uint16)
|
|
94
111
|
const seqIdView = new DataView(new ArrayBuffer(2));
|
|
95
112
|
seqIdView.setUint16(0, starbaseSeqId, true);
|
|
96
113
|
const seqIdBytes = new Uint8Array(seqIdView.buffer);
|
|
97
114
|
const [address] = await getProgramDerivedAddress({
|
|
98
|
-
programAddress:
|
|
115
|
+
programAddress: programAddress,
|
|
99
116
|
seeds: [
|
|
100
117
|
seedToBytes(STARBASE_PLAYER_SEED),
|
|
101
118
|
getAddressEncoder().encode(starbase),
|
|
@@ -110,19 +127,22 @@ export async function deriveStarbasePlayer(sagePlayerProfile, starbase, starbase
|
|
|
110
127
|
*
|
|
111
128
|
* @param profile The borrower's profile address
|
|
112
129
|
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
113
|
-
* @param gameId The game ID (
|
|
130
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
114
131
|
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
132
|
+
* @param config Optional configuration for network-specific constants
|
|
115
133
|
* @returns Promise that resolves to the three derived addresses
|
|
116
134
|
*/
|
|
117
|
-
export async function deriveGameAccounts(profile, faction, gameId
|
|
135
|
+
export async function deriveGameAccounts(profile, faction, gameId, starbaseSeqId = 0, config) {
|
|
136
|
+
// Get the actual game ID to use
|
|
137
|
+
const actualGameId = gameId || await getSageGameId(config);
|
|
118
138
|
// Derive the three accounts in parallel
|
|
119
139
|
const [profileFaction, sagePlayerProfile, starbase] = await Promise.all([
|
|
120
|
-
deriveProfileFaction(profile),
|
|
121
|
-
deriveSagePlayerProfile(profile,
|
|
122
|
-
deriveStarbase(faction,
|
|
140
|
+
deriveProfileFaction(profile, config),
|
|
141
|
+
deriveSagePlayerProfile(profile, actualGameId, config),
|
|
142
|
+
deriveStarbase(faction, actualGameId, config)
|
|
123
143
|
]);
|
|
124
144
|
// Derive starbasePlayer using the results from above
|
|
125
|
-
const starbasePlayer = await deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId);
|
|
145
|
+
const starbasePlayer = await deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId, config);
|
|
126
146
|
return {
|
|
127
147
|
profileFaction,
|
|
128
148
|
starbase,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/utils/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/utils/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzJ,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAGpG;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAwB,EACxB,MAAsB;IAEtB,MAAM,cAAc,GAAG,MAAM,+BAA+B,CAAC,MAAM,CAAC,CAAC;IAErE,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,wBAAwB,CAAC;QAC/C,cAAc,EAAE,cAAiC;QACjD,KAAK,EAAE;YACL,WAAW,CAAC,oBAAoB,CAAC;YACjC,iBAAiB,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;SACpC;KACF,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,eAAgC,EAChC,MAAwB,EACxB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AAC;IAEpD,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,wBAAwB,CAAC;QAC/C,cAAc,EAAE,cAAiC;QACjD,KAAK,EAAE;YACL,WAAW,CAAC,oBAAoB,CAAC;YACjC,iBAAiB,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;YACpC,iBAAiB,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC7C,eAAe,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;SACrC;KACF,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAwB,EACxB,OAAwB,EACxB,MAAwB,EACxB,gBAAwB,CAAC,EACzB,MAAsB;IAMtB,gCAAgC;IAChC,MAAM,YAAY,GAAG,MAAM,IAAI,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAE3D,wCAAwC;IACxC,MAAM,CACJ,cAAc,EACd,iBAAiB,EACjB,QAAQ,CACT,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpB,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC;QACrC,uBAAuB,CAAC,OAAO,EAAE,YAA+B,EAAE,MAAM,CAAC;QACzE,cAAc,CAAC,OAAO,EAAE,YAA+B,EAAE,MAAM,CAAC;KACjE,CAAC,CAAC;IAEH,qDAAqD;IACrD,MAAM,cAAc,GAAG,MAAM,oBAAoB,CAC/C,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACb,MAAM,CACP,CAAC;IAEF,OAAO;QACL,cAAc;QACd,QAAQ;QACR,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network-specific constants for devnet
|
|
3
|
+
*
|
|
4
|
+
* This file is auto-generated from network-configs.mjs
|
|
5
|
+
* DO NOT EDIT MANUALLY - your changes will be overwritten
|
|
6
|
+
*
|
|
7
|
+
* To update these constants:
|
|
8
|
+
* 1. Edit network-configs.mjs
|
|
9
|
+
* 2. Run `pnpm build` to regenerate
|
|
10
|
+
*
|
|
11
|
+
* Generated on: 2025-06-21T19:10:08.579Z
|
|
12
|
+
*/
|
|
13
|
+
export declare const SAGE_PROGRAM_ADDRESS = "sAgeDEVzwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi";
|
|
14
|
+
export declare const PROFILE_FACTION_PROGRAM_ADDRESS = "pFACDEVobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq";
|
|
15
|
+
export declare const SAGE_GAME_ID = "GAMEDEVJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr";
|
|
16
|
+
export declare const SRSLY_PROGRAM_ADDRESS = "SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT";
|
|
17
|
+
export declare const ATLAS_TOKEN_MINT = "ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx";
|
|
18
|
+
/**
|
|
19
|
+
* Complete network configuration object
|
|
20
|
+
* Useful for runtime access to all constants
|
|
21
|
+
*/
|
|
22
|
+
export declare const NETWORK_CONFIG: {
|
|
23
|
+
readonly SAGE_PROGRAM_ADDRESS: "sAgeDEVzwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi";
|
|
24
|
+
readonly PROFILE_FACTION_PROGRAM_ADDRESS: "pFACDEVobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq";
|
|
25
|
+
readonly SAGE_GAME_ID: "GAMEDEVJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr";
|
|
26
|
+
readonly SRSLY_PROGRAM_ADDRESS: "SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT";
|
|
27
|
+
readonly ATLAS_TOKEN_MINT: "ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Type-safe access to network configuration
|
|
31
|
+
*/
|
|
32
|
+
export type NetworkConfig = typeof NETWORK_CONFIG;
|
|
33
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/codama/devnet/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,oBAAoB,mDAAmD,CAAC;AACrF,eAAO,MAAM,+BAA+B,gDAAgD,CAAC;AAC7F,eAAO,MAAM,YAAY,kDAAkD,CAAC;AAC5E,eAAO,MAAM,qBAAqB,gDAAgD,CAAC;AACnF,eAAO,MAAM,gBAAgB,iDAAiD,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network-specific constants for mainnet
|
|
3
|
+
*
|
|
4
|
+
* This file is auto-generated from network-configs.mjs
|
|
5
|
+
* DO NOT EDIT MANUALLY - your changes will be overwritten
|
|
6
|
+
*
|
|
7
|
+
* To update these constants:
|
|
8
|
+
* 1. Edit network-configs.mjs
|
|
9
|
+
* 2. Run `pnpm build` to regenerate
|
|
10
|
+
*
|
|
11
|
+
* Generated on: 2025-06-21T19:10:03.037Z
|
|
12
|
+
*/
|
|
13
|
+
export declare const SAGE_PROGRAM_ADDRESS = "sAgezwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi";
|
|
14
|
+
export declare const PROFILE_FACTION_PROGRAM_ADDRESS = "pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq";
|
|
15
|
+
export declare const SAGE_GAME_ID = "GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr";
|
|
16
|
+
export declare const SRSLY_PROGRAM_ADDRESS = "SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT";
|
|
17
|
+
export declare const ATLAS_TOKEN_MINT = "ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx";
|
|
18
|
+
/**
|
|
19
|
+
* Complete network configuration object
|
|
20
|
+
* Useful for runtime access to all constants
|
|
21
|
+
*/
|
|
22
|
+
export declare const NETWORK_CONFIG: {
|
|
23
|
+
readonly SAGE_PROGRAM_ADDRESS: "sAgezwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi";
|
|
24
|
+
readonly PROFILE_FACTION_PROGRAM_ADDRESS: "pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq";
|
|
25
|
+
readonly SAGE_GAME_ID: "GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr";
|
|
26
|
+
readonly SRSLY_PROGRAM_ADDRESS: "SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT";
|
|
27
|
+
readonly ATLAS_TOKEN_MINT: "ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Type-safe access to network configuration
|
|
31
|
+
*/
|
|
32
|
+
export type NetworkConfig = typeof NETWORK_CONFIG;
|
|
33
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/codama/mainnet/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,oBAAoB,gDAAgD,CAAC;AAClF,eAAO,MAAM,+BAA+B,gDAAgD,CAAC;AAC7F,eAAO,MAAM,YAAY,iDAAiD,CAAC;AAC3E,eAAO,MAAM,qBAAqB,gDAAgD,CAAC;AACnF,eAAO,MAAM,gBAAgB,iDAAiD,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, TransactionSigner } from '@solana/kit';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ConfigSelector } from '../utils/config';
|
|
3
3
|
type CloseContractInstruction = any;
|
|
4
4
|
/**
|
|
5
5
|
* Simplified parameters for closing a rental contract
|
|
@@ -24,14 +24,29 @@ export interface CloseContractParams {
|
|
|
24
24
|
faction: number | string;
|
|
25
25
|
/**
|
|
26
26
|
* The game ID account address
|
|
27
|
-
*
|
|
27
|
+
* If not provided, will use network-specific default
|
|
28
28
|
*/
|
|
29
29
|
gameId?: Address<string>;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Creates an instruction to close a rental contract with fluent
|
|
32
|
+
* Creates an instruction to close a rental contract with fluent configuration.
|
|
33
|
+
*
|
|
34
|
+
* @param params The contract closing parameters
|
|
35
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Use devnet defaults
|
|
40
|
+
* await closeContract(params);
|
|
41
|
+
*
|
|
42
|
+
* // Use mainnet
|
|
43
|
+
* await closeContract(params).set({ network: 'mainnet' });
|
|
44
|
+
*
|
|
45
|
+
* // Override game ID
|
|
46
|
+
* await closeContract(params).set({ gameId: 'custom...' });
|
|
47
|
+
* ```
|
|
33
48
|
*/
|
|
34
|
-
export declare function closeContract(params: CloseContractParams):
|
|
35
|
-
export declare function getCloseContractInstructionAsync(input: any, options?: any):
|
|
49
|
+
export declare function closeContract(params: CloseContractParams): ConfigSelector<CloseContractInstruction>;
|
|
50
|
+
export declare function getCloseContractInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
36
51
|
export {};
|
|
37
52
|
//# sourceMappingURL=close.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/contract/close.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/contract/close.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAgD,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAIxH,KAAK,wBAAwB,GAAG,GAAG,CAAC;AAMpC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEjC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1B;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1B;AAwFD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,mBAAmB,GAC1B,cAAc,CAAC,wBAAwB,CAAC,CAE1C;AAGD,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK/F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, TransactionSigner } from '@solana/kit';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ConfigSelector } from '../utils/config';
|
|
3
3
|
type CreateContractInstruction = any;
|
|
4
4
|
/**
|
|
5
5
|
* Simplified parameters for creating a rental contract
|
|
@@ -40,31 +40,41 @@ export interface CreateContractParams {
|
|
|
40
40
|
ownerKeyIndex?: number;
|
|
41
41
|
/**
|
|
42
42
|
* The game ID account address
|
|
43
|
-
*
|
|
43
|
+
* If not provided, will use network-specific default
|
|
44
44
|
*/
|
|
45
45
|
gameId?: Address<string>;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Creates an instruction to create a rental contract with fluent
|
|
48
|
+
* Creates an instruction to create a rental contract with fluent configuration.
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```typescript
|
|
52
|
-
* // Use
|
|
53
|
-
* const ix = await createContract(params)
|
|
52
|
+
* // Use devnet defaults
|
|
53
|
+
* const ix = await createContract(params);
|
|
54
54
|
*
|
|
55
|
-
* // Use
|
|
56
|
-
* const ix = await createContract(params).mainnet
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
* // Use mainnet configuration
|
|
56
|
+
* const ix = await createContract(params).set({ network: 'mainnet' });
|
|
57
|
+
*
|
|
58
|
+
* // Override specific constants
|
|
59
|
+
* const ix = await createContract(params).set({
|
|
60
|
+
* network: 'mainnet',
|
|
61
|
+
* gameId: 'custom-game-id...',
|
|
62
|
+
* sageProgramAddress: 'custom-sage...'
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* // Chain configurations
|
|
66
|
+
* const ix = await createContract(params)
|
|
67
|
+
* .set({ network: 'devnet' })
|
|
68
|
+
* .set({ gameId: 'override-game...' });
|
|
59
69
|
* ```
|
|
60
70
|
*
|
|
61
71
|
* @param params The simplified parameters for creating a rental contract
|
|
62
|
-
* @returns A
|
|
72
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
63
73
|
*/
|
|
64
|
-
export declare function createContract(params: CreateContractParams):
|
|
74
|
+
export declare function createContract(params: CreateContractParams): ConfigSelector<CreateContractInstruction>;
|
|
65
75
|
/**
|
|
66
|
-
* Export
|
|
76
|
+
* Export config selector for getCreateContractInstructionAsync
|
|
67
77
|
*/
|
|
68
|
-
export declare function getCreateContractInstructionAsync(input: any, options?: any):
|
|
78
|
+
export declare function getCreateContractInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
69
79
|
export {};
|
|
70
80
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/contract/create.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAgD,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAIxH,KAAK,yBAAyB,GAAG,GAAG,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEjC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9B;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAE7B;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAE7B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1B;AA+CD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,GAC3B,cAAc,CAAC,yBAAyB,CAAC,CAE3C;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAKhG"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AAIxB,YAAY,EAEV,aAAa,EACb,WAAW,EACX,KAAK,EAGL,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EAGtB,gBAAgB,EAChB,SAAS,EACT,cAAc,EACf,MAAM,iBAAiB,CAAC"}
|