@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
|
@@ -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 AcceptRentalInstruction = any;
|
|
4
4
|
/**
|
|
5
5
|
* Simplified parameters for accepting a rental
|
|
@@ -28,19 +28,48 @@ export interface AcceptRentalParams {
|
|
|
28
28
|
contract: Address<string>;
|
|
29
29
|
/**
|
|
30
30
|
* The game ID account address
|
|
31
|
-
*
|
|
31
|
+
* If not provided, will use network-specific default
|
|
32
32
|
*/
|
|
33
33
|
gameId?: Address<string>;
|
|
34
34
|
/**
|
|
35
|
-
* The rental
|
|
35
|
+
* The rental rate (in ATLAS tokens)
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
rate: number | bigint;
|
|
38
38
|
/**
|
|
39
39
|
* The rental duration (in seconds)
|
|
40
40
|
*/
|
|
41
41
|
duration: number | bigint;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Creates an instruction to accept a rental with fluent configuration.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Use devnet defaults
|
|
49
|
+
* const ix = await acceptRental({
|
|
50
|
+
* borrower: wallet,
|
|
51
|
+
* borrowerProfile: profileAddress,
|
|
52
|
+
* borrowerFaction: 1, // 1 = mud, 2 = oni, 3 = ustur
|
|
53
|
+
* fleet: fleetAddress,
|
|
54
|
+
* contract: contractAddress,
|
|
55
|
+
* rate: 1000, // ATLAS tokens
|
|
56
|
+
* duration: 86400 // 1 day in seconds (total: 1000 * 86400 * 100M stardust)
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Use mainnet configuration
|
|
60
|
+
* const ix = await acceptRental(params).set({ network: 'mainnet' });
|
|
61
|
+
*
|
|
62
|
+
* // Override specific constants
|
|
63
|
+
* const ix = await acceptRental(params).set({
|
|
64
|
+
* network: 'mainnet',
|
|
65
|
+
* gameId: 'custom-game-id...'
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param params The simplified parameters for accepting a rental
|
|
70
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
71
|
+
*/
|
|
72
|
+
export declare function acceptRental(params: AcceptRentalParams): ConfigSelector<AcceptRentalInstruction>;
|
|
73
|
+
export declare function getAcceptRentalInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
45
74
|
export {};
|
|
46
75
|
//# sourceMappingURL=accept.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAgD,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAKxH,KAAK,uBAAuB,GAAG,GAAG,CAAC;AAMnC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEpC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzB;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAgED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,cAAc,CAAC,uBAAuB,CAAC,CAEzC;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK9F"}
|
|
@@ -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 CancelRentalInstruction = any;
|
|
4
4
|
/**
|
|
5
5
|
* Simplified parameters for canceling a rental
|
|
@@ -14,7 +14,31 @@ export interface CancelRentalParams {
|
|
|
14
14
|
*/
|
|
15
15
|
contract: Address<string>;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instruction to cancel a rental with fluent configuration.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Use devnet defaults
|
|
23
|
+
* const ix = await cancelRental({
|
|
24
|
+
* borrower: wallet,
|
|
25
|
+
* contract: contractAddress
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Use mainnet configuration
|
|
29
|
+
* const ix = await cancelRental(params).set({ network: 'mainnet' });
|
|
30
|
+
*
|
|
31
|
+
* // Override specific constants
|
|
32
|
+
* const ix = await cancelRental(params).set({
|
|
33
|
+
* network: 'mainnet',
|
|
34
|
+
* sageProgramAddress: 'custom...'
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param params The simplified parameters for canceling a rental
|
|
39
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
40
|
+
*/
|
|
41
|
+
export declare function cancelRental(params: CancelRentalParams): ConfigSelector<CancelRentalInstruction>;
|
|
42
|
+
export declare function getCancelRentalInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
19
43
|
export {};
|
|
20
44
|
//# sourceMappingURL=cancel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"cancel.d.ts","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAgD,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAGxH,KAAK,uBAAuB,GAAG,GAAG,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEpC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3B;AA8BD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,GACzB,cAAc,CAAC,uBAAuB,CAAC,CAEzC;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK9F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address } from '@solana/kit';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ConfigSelector } from '../utils/config';
|
|
3
3
|
type CloseRentalInstruction = any;
|
|
4
4
|
/**
|
|
5
5
|
* Simplified parameters for closing a rental
|
|
@@ -18,7 +18,32 @@ export interface CloseRentalParams {
|
|
|
18
18
|
*/
|
|
19
19
|
contract: Address<string>;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instruction to close a rental with fluent configuration.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Use devnet defaults
|
|
27
|
+
* const ix = await closeRental({
|
|
28
|
+
* borrower: borrowerAddress,
|
|
29
|
+
* ownerTokenAccount: ownerTokenAccountAddress,
|
|
30
|
+
* contract: contractAddress
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Use mainnet configuration
|
|
34
|
+
* const ix = await closeRental(params).set({ network: 'mainnet' });
|
|
35
|
+
*
|
|
36
|
+
* // Override specific constants
|
|
37
|
+
* const ix = await closeRental(params).set({
|
|
38
|
+
* network: 'mainnet',
|
|
39
|
+
* sageProgramAddress: 'custom...'
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param params The simplified parameters for closing a rental
|
|
44
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
45
|
+
*/
|
|
46
|
+
export declare function closeRental(params: CloseRentalParams): ConfigSelector<CloseRentalInstruction>;
|
|
47
|
+
export declare function getCloseRentalInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
23
48
|
export {};
|
|
24
49
|
//# sourceMappingURL=close.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACR,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACR,MAAM,aAAa,CAAC;AAErB,OAAO,EAAgD,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAGxH,KAAK,sBAAsB,GAAG,GAAG,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1B;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3B;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,GACxB,cAAc,CAAC,sBAAsB,CAAC,CAExC;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK7F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address } from '@solana/kit';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ConfigSelector } from '../utils/config';
|
|
3
3
|
type ResetRentalInstruction = any;
|
|
4
4
|
/**
|
|
5
5
|
* Simplified parameters for resetting a rental
|
|
@@ -19,7 +19,7 @@ export interface ResetRentalParams {
|
|
|
19
19
|
rentalState: Address<string>;
|
|
20
20
|
/**
|
|
21
21
|
* The game ID account address
|
|
22
|
-
*
|
|
22
|
+
* If not provided, will use network-specific default
|
|
23
23
|
*/
|
|
24
24
|
gameId?: Address<string>;
|
|
25
25
|
/**
|
|
@@ -34,7 +34,35 @@ export interface ResetRentalParams {
|
|
|
34
34
|
*/
|
|
35
35
|
ownerProfile: Address<string>;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instruction to reset a rental with fluent configuration.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Use devnet defaults
|
|
43
|
+
* const ix = await resetRental({
|
|
44
|
+
* fleet: fleetAddress,
|
|
45
|
+
* contract: contractAddress,
|
|
46
|
+
* rentalState: rentalStateAddress,
|
|
47
|
+
* faction: 'mud',
|
|
48
|
+
* ownerProfile: ownerProfileAddress
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Use mainnet configuration
|
|
52
|
+
* const ix = await resetRental(params).set({ network: 'mainnet' });
|
|
53
|
+
*
|
|
54
|
+
* // Override specific constants
|
|
55
|
+
* const ix = await resetRental(params).set({
|
|
56
|
+
* network: 'mainnet',
|
|
57
|
+
* gameId: 'custom-game-id...',
|
|
58
|
+
* sageProgramAddress: 'custom...'
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param params The simplified parameters for resetting a rental
|
|
63
|
+
* @returns A ConfigSelector that can be configured with .set() or awaited directly
|
|
64
|
+
*/
|
|
65
|
+
export declare function resetRental(params: ResetRentalParams): ConfigSelector<ResetRentalInstruction>;
|
|
66
|
+
export declare function getResetRentalInstructionAsync(input: any, options?: any): ConfigSelector<any>;
|
|
39
67
|
export {};
|
|
40
68
|
//# sourceMappingURL=reset.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACR,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/rental/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACR,MAAM,aAAa,CAAC;AAErB,OAAO,EAAgD,KAAK,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAIxH,KAAK,sBAAsB,GAAG,GAAG,CAAC;AAMlC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzB;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/B;AAqDD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,GACxB,cAAc,CAAC,sBAAsB,CAAC,CAExC;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAK7F"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network configuration for the SRSLY SDK
|
|
3
|
+
*/
|
|
4
|
+
export type Network = 'mainnet' | 'devnet';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options that can be set globally or overridden per call
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfigOptions {
|
|
9
|
+
network?: Network;
|
|
10
|
+
sageProgramAddress?: string;
|
|
11
|
+
profileFactionProgramAddress?: string;
|
|
12
|
+
gameId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Set global configuration options that will be used as defaults for all SDK operations
|
|
16
|
+
* @param config Configuration options to set globally
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Set mainnet as default for all operations
|
|
21
|
+
* setConfig({ network: 'mainnet' });
|
|
22
|
+
*
|
|
23
|
+
* // Now all operations use mainnet by default
|
|
24
|
+
* await createContract(params); // Uses mainnet
|
|
25
|
+
* await acceptRental(params); // Uses mainnet
|
|
26
|
+
*
|
|
27
|
+
* // Can still override per instruction
|
|
28
|
+
* await createContract(params).set({ network: 'devnet' }); // Uses devnet
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function setConfig(config: ConfigOptions): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get the current global configuration
|
|
34
|
+
* @returns Current global configuration options
|
|
35
|
+
*/
|
|
36
|
+
export declare function getConfig(): ConfigOptions;
|
|
37
|
+
/**
|
|
38
|
+
* Clear global configuration (resets to devnet defaults)
|
|
39
|
+
*/
|
|
40
|
+
export declare function clearConfig(): void;
|
|
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 declare function setNetwork(network: Network): void;
|
|
55
|
+
/**
|
|
56
|
+
* Get current global network (convenience function for backward compatibility)
|
|
57
|
+
* @returns Current global network or 'devnet' if not set
|
|
58
|
+
*/
|
|
59
|
+
export declare function getNetwork(): Network;
|
|
60
|
+
/**
|
|
61
|
+
* Dynamically import network-specific codama modules
|
|
62
|
+
* @param modulePath The module path relative to the network directory
|
|
63
|
+
* @param network Network to use (defaults to devnet if not specified)
|
|
64
|
+
* @returns Promise resolving to the imported module
|
|
65
|
+
*/
|
|
66
|
+
export declare function importNetworkModule<T = any>(modulePath: string, network?: Network): Promise<T>;
|
|
67
|
+
/**
|
|
68
|
+
* Type-safe helper to get network-specific exports
|
|
69
|
+
*/
|
|
70
|
+
export interface NetworkModuleCache {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Cached import for better performance
|
|
75
|
+
* Uses global config network as default if no network specified
|
|
76
|
+
*/
|
|
77
|
+
export declare function getCachedNetworkModule<T = any>(modulePath: string, network?: Network): Promise<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Configuration selector for overriding network and constants
|
|
80
|
+
* Also implements PromiseLike to allow direct awaiting
|
|
81
|
+
*/
|
|
82
|
+
export interface ConfigSelector<T> extends PromiseLike<T> {
|
|
83
|
+
/**
|
|
84
|
+
* Set configuration options for this call
|
|
85
|
+
*/
|
|
86
|
+
set(options: ConfigOptions): ConfigSelector<T>;
|
|
87
|
+
/**
|
|
88
|
+
* Build with current configuration (explicit call)
|
|
89
|
+
*/
|
|
90
|
+
build(): Promise<T>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create the initial fluent config selector for a function.
|
|
94
|
+
* This is the main entry point for the fluent configuration API.
|
|
95
|
+
*
|
|
96
|
+
* The returned selector can be:
|
|
97
|
+
* - Awaited directly (uses global config + devnet fallback)
|
|
98
|
+
* - Configured with .set() to override network/constants
|
|
99
|
+
* - Chained with multiple .set() calls
|
|
100
|
+
*
|
|
101
|
+
* @param executeFn - The function to execute with optional configuration
|
|
102
|
+
* @returns A ConfigSelector that supports fluent configuration
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Usage patterns:
|
|
106
|
+
* setConfig({ network: 'mainnet' });
|
|
107
|
+
* await createConfigSelector(executeFn) // Direct await (uses global mainnet)
|
|
108
|
+
* await createConfigSelector(executeFn).set({...}) // Override global config
|
|
109
|
+
* await createConfigSelector(executeFn).set({...}).set({...}) // Chained configs
|
|
110
|
+
*/
|
|
111
|
+
export declare function createConfigSelector<T>(executeFn: (config?: ConfigOptions) => Promise<T>): ConfigSelector<T>;
|
|
112
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAErD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAEzC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAWD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAWpG;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAID;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAWvG;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACvD;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;IAE/C;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB;AAqCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAChD,cAAc,CAAC,CAAC,CAAC,CAcnB"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function getSrslyProgramAddress(): Promise<any>;
|
|
3
|
-
import { type Address } from "@solana/kit";
|
|
4
|
-
export declare function getProgramId(): Promise<Address>;
|
|
5
|
-
export declare const SAGE_PROGRAM_ADDRESS = "sAgezwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi";
|
|
6
|
-
export declare const PROFILE_FACTION_PROGRAM_ADDRESS = "pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq";
|
|
7
|
-
export declare const DEFAULT_GAME_ID = "GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr";
|
|
1
|
+
import { type ConfigOptions } from './config';
|
|
8
2
|
export declare const STARBASE_SEED = "Starbase";
|
|
9
3
|
export declare const STARBASE_PLAYER_SEED = "starbase_player";
|
|
10
4
|
export declare const SAGE_PLAYER_PROFILE_SEED = "sage_player_profile";
|
|
11
5
|
export declare const PROFILE_FACTION_SEED = "profile_faction";
|
|
6
|
+
export declare const ATLAS_TO_STARDUST = 100000000;
|
|
7
|
+
export declare function getPaymentFrequency(): Promise<any>;
|
|
8
|
+
export declare function getSrslyProgramAddress(): Promise<any>;
|
|
9
|
+
import { type Address } from "@solana/kit";
|
|
10
|
+
export declare function getProgramId(): Promise<Address>;
|
|
11
|
+
export declare function getSageProgramAddress(config?: ConfigOptions): Promise<any>;
|
|
12
|
+
export declare function getProfileFactionProgramAddress(config?: ConfigOptions): Promise<any>;
|
|
13
|
+
export declare function getSageGameId(config?: ConfigOptions): Promise<any>;
|
|
12
14
|
export declare const FACTION_SPECIFIC_CSS: Record<string, {
|
|
13
15
|
x: number;
|
|
14
16
|
y: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAGjF,eAAO,MAAM,aAAa,aAAa,CAAC;AACxC,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AACtD,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAGtD,eAAO,MAAM,iBAAiB,YAAc,CAAC;AAG7C,wBAAsB,mBAAmB,iBAGxC;AAED,wBAAsB,sBAAsB,iBAG3C;AACD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAErD;AAGD,wBAAsB,qBAAqB,CAAC,MAAM,CAAC,EAAE,aAAa,gBAgBjE;AAED,wBAAsB,+BAA+B,CAAC,MAAM,CAAC,EAAE,aAAa,gBAgB3E;AAED,wBAAsB,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,gBAgBzD;AAGD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAIzE,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIlD,CAAC;AAEF;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAGzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
import { Address } from '@solana/kit';
|
|
2
|
+
import type { ConfigOptions } from './config';
|
|
2
3
|
/**
|
|
3
4
|
* Helper function to derive the borrower's profile faction account
|
|
4
5
|
*
|
|
5
6
|
* @param profile The borrower's profile address
|
|
7
|
+
* @param config Optional configuration for network-specific constants
|
|
6
8
|
* @returns Promise that resolves to the derived profile faction address
|
|
7
9
|
*/
|
|
8
|
-
export declare function deriveProfileFaction(profile: Address<string
|
|
10
|
+
export declare function deriveProfileFaction(profile: Address<string>, config?: ConfigOptions): Promise<Address<string>>;
|
|
9
11
|
/**
|
|
10
12
|
* Helper function to derive the sage player profile
|
|
11
13
|
*
|
|
12
14
|
* @param borrowerProfile The borrower's profile address
|
|
13
|
-
* @param gameId The game ID (
|
|
15
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
16
|
+
* @param config Optional configuration for network-specific constants
|
|
14
17
|
* @returns Promise that resolves to the derived sage player profile address
|
|
15
18
|
*/
|
|
16
|
-
export declare function deriveSagePlayerProfile(borrowerProfile: Address<string>, gameId?: Address<string
|
|
19
|
+
export declare function deriveSagePlayerProfile(borrowerProfile: Address<string>, gameId?: Address<string>, config?: ConfigOptions): Promise<Address<string>>;
|
|
17
20
|
/**
|
|
18
21
|
* Helper function to derive the starbase address based on faction
|
|
19
22
|
*
|
|
20
23
|
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
21
|
-
* @param gameId The game ID (
|
|
24
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
25
|
+
* @param config Optional configuration for network-specific constants
|
|
22
26
|
* @returns Promise that resolves to the derived starbase address
|
|
23
27
|
*/
|
|
24
|
-
export declare function deriveStarbase(faction: number | string, gameId?: Address<string
|
|
28
|
+
export declare function deriveStarbase(faction: number | string, gameId?: Address<string>, config?: ConfigOptions): Promise<Address<string>>;
|
|
25
29
|
/**
|
|
26
30
|
* Helper function to derive the starbase player address
|
|
27
31
|
*
|
|
28
32
|
* @param sagePlayerProfile The sage player profile address
|
|
29
33
|
* @param starbase The starbase address
|
|
30
34
|
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
35
|
+
* @param config Optional configuration for network-specific constants
|
|
31
36
|
* @returns Promise that resolves to the derived starbase player address
|
|
32
37
|
*/
|
|
33
|
-
export declare function deriveStarbasePlayer(sagePlayerProfile: Address<string>, starbase: Address<string>, starbaseSeqId?: number): Promise<Address<string>>;
|
|
38
|
+
export declare function deriveStarbasePlayer(sagePlayerProfile: Address<string>, starbase: Address<string>, starbaseSeqId?: number, config?: ConfigOptions): Promise<Address<string>>;
|
|
34
39
|
/**
|
|
35
40
|
* Derives all three accounts needed: profileFaction, starbase, and starbasePlayer
|
|
36
41
|
*
|
|
37
42
|
* @param profile The borrower's profile address
|
|
38
43
|
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
39
|
-
* @param gameId The game ID (
|
|
44
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
40
45
|
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
46
|
+
* @param config Optional configuration for network-specific constants
|
|
41
47
|
* @returns Promise that resolves to the three derived addresses
|
|
42
48
|
*/
|
|
43
|
-
export declare function deriveGameAccounts(profile: Address<string>, faction: number | string, gameId?: Address<string>, starbaseSeqId?: number): Promise<{
|
|
49
|
+
export declare function deriveGameAccounts(profile: Address<string>, faction: number | string, gameId?: Address<string>, starbaseSeqId?: number, config?: ConfigOptions): Promise<{
|
|
44
50
|
profileFaction: Address<string>;
|
|
45
51
|
starbase: Address<string>;
|
|
46
52
|
starbasePlayer: Address<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/utils/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIR,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../../src/utils/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIR,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAa9C;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EACxB,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAW1B;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EACxB,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAe1B;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EACxB,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAyC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,EAClC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,EACzB,aAAa,GAAE,MAAU,EACzB,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAmB1B;AAED;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EACxB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EACxB,aAAa,GAAE,MAAU,EACzB,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC;IACT,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC,CAAC,CA4BD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wuwei-labs/srsly",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"vitest": "^3.1.2"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@
|
|
68
|
+
"@coral-xyz/anchor": "^0.31.1",
|
|
69
|
+
"@solana/kit": "^2.1.0",
|
|
70
|
+
"@solana/web3.js": "^1.98.2"
|
|
69
71
|
}
|
|
70
72
|
}
|
package/dist/cjs/network.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Network configuration for the SRSLY SDK
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.setNetwork = setNetwork;
|
|
40
|
-
exports.getNetwork = getNetwork;
|
|
41
|
-
exports.importNetworkModule = importNetworkModule;
|
|
42
|
-
exports.getCachedNetworkModule = getCachedNetworkModule;
|
|
43
|
-
exports.createNetworkSelector = createNetworkSelector;
|
|
44
|
-
let currentNetwork = 'devnet'; // Default to devnet
|
|
45
|
-
/**
|
|
46
|
-
* Set the global network for the SDK
|
|
47
|
-
* @param network The network to use ('mainnet' or 'devnet')
|
|
48
|
-
*/
|
|
49
|
-
function setNetwork(network) {
|
|
50
|
-
currentNetwork = network;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Get the current network
|
|
54
|
-
* @returns The currently selected network
|
|
55
|
-
*/
|
|
56
|
-
function getNetwork() {
|
|
57
|
-
return currentNetwork;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Dynamically import network-specific codama modules
|
|
61
|
-
* @param modulePath The module path relative to the network directory
|
|
62
|
-
* @param network Optional network override
|
|
63
|
-
* @returns Promise resolving to the imported module
|
|
64
|
-
*/
|
|
65
|
-
async function importNetworkModule(modulePath, network) {
|
|
66
|
-
const targetNetwork = network || getNetwork();
|
|
67
|
-
const fullPath = `./codama/${targetNetwork}/${modulePath}`;
|
|
68
|
-
try {
|
|
69
|
-
// Use dynamic import which works in both ESM and CJS with ES2020+
|
|
70
|
-
const module = await Promise.resolve(`${fullPath}`).then(s => __importStar(require(s)));
|
|
71
|
-
return module;
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
throw new Error(`Failed to import ${fullPath} for network ${targetNetwork}: ${error}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const moduleCache = {};
|
|
78
|
-
/**
|
|
79
|
-
* Cached import for better performance
|
|
80
|
-
*/
|
|
81
|
-
async function getCachedNetworkModule(modulePath, network) {
|
|
82
|
-
const targetNetwork = network || getNetwork();
|
|
83
|
-
const cacheKey = `${targetNetwork}:${modulePath}`;
|
|
84
|
-
if (moduleCache[cacheKey]) {
|
|
85
|
-
return moduleCache[cacheKey];
|
|
86
|
-
}
|
|
87
|
-
const module = await importNetworkModule(modulePath, targetNetwork);
|
|
88
|
-
moduleCache[cacheKey] = module;
|
|
89
|
-
return module;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Create a network selector for a function
|
|
93
|
-
*/
|
|
94
|
-
function createNetworkSelector(executeFn) {
|
|
95
|
-
const selector = {
|
|
96
|
-
mainnet: () => executeFn('mainnet'),
|
|
97
|
-
devnet: () => executeFn('devnet'),
|
|
98
|
-
network: (network) => executeFn(network),
|
|
99
|
-
build: () => executeFn(),
|
|
100
|
-
// Implement PromiseLike to allow direct awaiting
|
|
101
|
-
then(onfulfilled, onrejected) {
|
|
102
|
-
return executeFn().then(onfulfilled, onrejected);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return selector;
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=network.js.map
|
package/dist/cjs/network.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/network.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUH,gCAEC;AAMD,gCAEC;AAQD,kDAWC;AAcD,wDAWC;AA+BD,sDAkBC;AA7GD,IAAI,cAAc,GAAY,QAAQ,CAAC,CAAC,oBAAoB;AAE5D;;;GAGG;AACH,SAAgB,UAAU,CAAC,OAAgB;IACzC,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,SAAgB,UAAU;IACxB,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,mBAAmB,CAAU,UAAkB,EAAE,OAAiB;IACtF,MAAM,aAAa,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,YAAY,aAAa,IAAI,UAAU,EAAE,CAAC;IAE3D,IAAI,CAAC;QACH,kEAAkE;QAClE,MAAM,MAAM,GAAG,yBAAa,QAAQ,uCAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,gBAAgB,aAAa,KAAK,KAAK,EAAE,CAAC,CAAC;IACzF,CAAC;AACH,CAAC;AASD,MAAM,WAAW,GAAuB,EAAE,CAAC;AAE3C;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAAU,UAAkB,EAAE,OAAiB;IACzF,MAAM,aAAa,GAAG,OAAO,IAAI,UAAU,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,GAAG,aAAa,IAAI,UAAU,EAAE,CAAC;IAElD,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAI,UAAU,EAAE,aAAa,CAAC,CAAC;IACvE,WAAW,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IAC/B,OAAO,MAAM,CAAC;AAChB,CAAC;AA4BD;;GAEG;AACH,SAAgB,qBAAqB,CACnC,SAA4C;IAE5C,MAAM,QAAQ,GAAG;QACf,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;QACnC,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;QACjD,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE;QACxB,iDAAiD;QACjD,IAAI,CACF,WAAqE,EACrE,UAAuE;YAEvE,OAAO,SAAS,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|