@wuwei-labs/srsly 2.0.0-beta.6 → 2.0.0-beta.7
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/dist/cjs/codama/devnet/constants.js +1 -1
- package/dist/cjs/codama/mainnet/constants.js +1 -1
- package/dist/esm/codama/devnet/accounts/contractState.js +75 -0
- package/dist/esm/codama/devnet/accounts/contractState.js.map +1 -0
- package/dist/esm/codama/devnet/accounts/fleet.js +64 -0
- package/dist/esm/codama/devnet/accounts/fleet.js.map +1 -0
- package/dist/esm/codama/devnet/accounts/index.js +12 -0
- package/dist/esm/codama/devnet/accounts/index.js.map +1 -0
- package/dist/esm/codama/devnet/accounts/rentalState.js +74 -0
- package/dist/esm/codama/devnet/accounts/rentalState.js.map +1 -0
- package/dist/esm/codama/devnet/accounts/thread.js +77 -0
- package/dist/esm/codama/devnet/accounts/thread.js.map +1 -0
- package/dist/esm/codama/devnet/constants.js +29 -0
- package/dist/esm/codama/devnet/constants.js.map +1 -0
- package/dist/esm/codama/devnet/errors/index.js +9 -0
- package/dist/esm/codama/devnet/errors/index.js.map +1 -0
- package/dist/esm/codama/devnet/errors/srsly.js +69 -0
- package/dist/esm/codama/devnet/errors/srsly.js.map +1 -0
- package/dist/esm/codama/devnet/index.js +13 -0
- package/dist/esm/codama/devnet/index.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/acceptRental.js +347 -0
- package/dist/esm/codama/devnet/instructions/acceptRental.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/cancelRental.js +215 -0
- package/dist/esm/codama/devnet/instructions/cancelRental.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/closeContract.js +236 -0
- package/dist/esm/codama/devnet/instructions/closeContract.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/closeRental.js +250 -0
- package/dist/esm/codama/devnet/instructions/closeRental.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/createContract.js +251 -0
- package/dist/esm/codama/devnet/instructions/createContract.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/index.js +15 -0
- package/dist/esm/codama/devnet/instructions/index.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/payRental.js +270 -0
- package/dist/esm/codama/devnet/instructions/payRental.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/resetRental.js +145 -0
- package/dist/esm/codama/devnet/instructions/resetRental.js.map +1 -0
- package/dist/esm/codama/devnet/programs/index.js +9 -0
- package/dist/esm/codama/devnet/programs/index.js.map +1 -0
- package/dist/esm/codama/devnet/programs/srsly.js +68 -0
- package/dist/esm/codama/devnet/programs/srsly.js.map +1 -0
- package/dist/esm/codama/devnet/shared/index.js +87 -0
- package/dist/esm/codama/devnet/shared/index.js.map +1 -0
- package/dist/esm/codama/devnet/types/clockData.js +26 -0
- package/dist/esm/codama/devnet/types/clockData.js.map +1 -0
- package/dist/esm/codama/devnet/types/equality.js +24 -0
- package/dist/esm/codama/devnet/types/equality.js.map +1 -0
- package/dist/esm/codama/devnet/types/execContext.js +33 -0
- package/dist/esm/codama/devnet/types/execContext.js.map +1 -0
- package/dist/esm/codama/devnet/types/index.js +16 -0
- package/dist/esm/codama/devnet/types/index.js.map +1 -0
- package/dist/esm/codama/devnet/types/serializableAccount.js +26 -0
- package/dist/esm/codama/devnet/types/serializableAccount.js.map +1 -0
- package/dist/esm/codama/devnet/types/serializableInstruction.js +27 -0
- package/dist/esm/codama/devnet/types/serializableInstruction.js.map +1 -0
- package/dist/esm/codama/devnet/types/threadResponse.js +33 -0
- package/dist/esm/codama/devnet/types/threadResponse.js.map +1 -0
- package/dist/esm/codama/devnet/types/trigger.js +83 -0
- package/dist/esm/codama/devnet/types/trigger.js.map +1 -0
- package/dist/esm/codama/devnet/types/triggerContext.js +42 -0
- package/dist/esm/codama/devnet/types/triggerContext.js.map +1 -0
- package/dist/esm/codama/mainnet/accounts/contractState.js +75 -0
- package/dist/esm/codama/mainnet/accounts/contractState.js.map +1 -0
- package/dist/esm/codama/mainnet/accounts/fleet.js +64 -0
- package/dist/esm/codama/mainnet/accounts/fleet.js.map +1 -0
- package/dist/esm/codama/mainnet/accounts/index.js +12 -0
- package/dist/esm/codama/mainnet/accounts/index.js.map +1 -0
- package/dist/esm/codama/mainnet/accounts/rentalState.js +74 -0
- package/dist/esm/codama/mainnet/accounts/rentalState.js.map +1 -0
- package/dist/esm/codama/mainnet/accounts/thread.js +77 -0
- package/dist/esm/codama/mainnet/accounts/thread.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/codama/mainnet/errors/index.js +9 -0
- package/dist/esm/codama/mainnet/errors/index.js.map +1 -0
- package/dist/esm/codama/mainnet/errors/srsly.js +69 -0
- package/dist/esm/codama/mainnet/errors/srsly.js.map +1 -0
- package/dist/esm/codama/mainnet/index.js +13 -0
- package/dist/esm/codama/mainnet/index.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/acceptRental.js +347 -0
- package/dist/esm/codama/mainnet/instructions/acceptRental.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/cancelRental.js +215 -0
- package/dist/esm/codama/mainnet/instructions/cancelRental.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/closeContract.js +236 -0
- package/dist/esm/codama/mainnet/instructions/closeContract.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/closeRental.js +250 -0
- package/dist/esm/codama/mainnet/instructions/closeRental.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/createContract.js +251 -0
- package/dist/esm/codama/mainnet/instructions/createContract.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/index.js +15 -0
- package/dist/esm/codama/mainnet/instructions/index.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/payRental.js +270 -0
- package/dist/esm/codama/mainnet/instructions/payRental.js.map +1 -0
- package/dist/esm/codama/mainnet/instructions/resetRental.js +145 -0
- package/dist/esm/codama/mainnet/instructions/resetRental.js.map +1 -0
- package/dist/esm/codama/mainnet/programs/index.js +9 -0
- package/dist/esm/codama/mainnet/programs/index.js.map +1 -0
- package/dist/esm/codama/mainnet/programs/srsly.js +68 -0
- package/dist/esm/codama/mainnet/programs/srsly.js.map +1 -0
- package/dist/esm/codama/mainnet/shared/index.js +87 -0
- package/dist/esm/codama/mainnet/shared/index.js.map +1 -0
- package/dist/esm/codama/mainnet/types/clockData.js +26 -0
- package/dist/esm/codama/mainnet/types/clockData.js.map +1 -0
- package/dist/esm/codama/mainnet/types/equality.js +24 -0
- package/dist/esm/codama/mainnet/types/equality.js.map +1 -0
- package/dist/esm/codama/mainnet/types/execContext.js +33 -0
- package/dist/esm/codama/mainnet/types/execContext.js.map +1 -0
- package/dist/esm/codama/mainnet/types/index.js +16 -0
- package/dist/esm/codama/mainnet/types/index.js.map +1 -0
- package/dist/esm/codama/mainnet/types/serializableAccount.js +26 -0
- package/dist/esm/codama/mainnet/types/serializableAccount.js.map +1 -0
- package/dist/esm/codama/mainnet/types/serializableInstruction.js +27 -0
- package/dist/esm/codama/mainnet/types/serializableInstruction.js.map +1 -0
- package/dist/esm/codama/mainnet/types/threadResponse.js +33 -0
- package/dist/esm/codama/mainnet/types/threadResponse.js.map +1 -0
- package/dist/esm/codama/mainnet/types/trigger.js +83 -0
- package/dist/esm/codama/mainnet/types/trigger.js.map +1 -0
- package/dist/esm/codama/mainnet/types/triggerContext.js +42 -0
- package/dist/esm/codama/mainnet/types/triggerContext.js.map +1 -0
- package/dist/esm/contract/close.js +94 -0
- package/dist/esm/contract/close.js.map +1 -0
- package/dist/esm/contract/create.js +66 -0
- package/dist/esm/contract/create.js.map +1 -0
- package/dist/esm/contract/index.js +3 -0
- package/dist/esm/contract/index.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/rental/accept.js +86 -0
- package/dist/esm/rental/accept.js.map +1 -0
- package/dist/esm/rental/cancel.js +50 -0
- package/dist/esm/rental/cancel.js.map +1 -0
- package/dist/esm/rental/close.js +52 -0
- package/dist/esm/rental/close.js.map +1 -0
- package/dist/esm/rental/index.js +5 -0
- package/dist/esm/rental/index.js.map +1 -0
- package/dist/esm/rental/reset.js +65 -0
- package/dist/esm/rental/reset.js.map +1 -0
- package/dist/esm/utils/config.js +161 -0
- package/dist/esm/utils/config.js.map +1 -0
- package/dist/esm/utils/constants.js +104 -0
- package/dist/esm/utils/constants.js.map +1 -0
- package/dist/esm/utils/index.js +4 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/profiles.js +152 -0
- package/dist/esm/utils/profiles.js.map +1 -0
- package/dist/types/codama/devnet/accounts/contractState.d.ts +51 -0
- package/dist/types/codama/devnet/accounts/contractState.d.ts.map +1 -0
- package/dist/types/codama/devnet/accounts/fleet.d.ts +38 -0
- package/dist/types/codama/devnet/accounts/fleet.d.ts.map +1 -0
- package/dist/types/codama/devnet/accounts/index.d.ts +12 -0
- package/dist/types/codama/devnet/accounts/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/accounts/rentalState.d.ts +48 -0
- package/dist/types/codama/devnet/accounts/rentalState.d.ts.map +1 -0
- package/dist/types/codama/devnet/accounts/thread.d.ts +74 -0
- package/dist/types/codama/devnet/accounts/thread.d.ts.map +1 -0
- 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/devnet/errors/index.d.ts +9 -0
- package/dist/types/codama/devnet/errors/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/errors/srsly.d.ts +50 -0
- package/dist/types/codama/devnet/errors/srsly.d.ts.map +1 -0
- package/dist/types/codama/devnet/index.d.ts +13 -0
- package/dist/types/codama/devnet/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/acceptRental.d.ts +131 -0
- package/dist/types/codama/devnet/instructions/acceptRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/cancelRental.d.ts +71 -0
- package/dist/types/codama/devnet/instructions/cancelRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/closeContract.d.ts +100 -0
- package/dist/types/codama/devnet/instructions/closeContract.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/closeRental.d.ts +83 -0
- package/dist/types/codama/devnet/instructions/closeRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/createContract.d.ts +108 -0
- package/dist/types/codama/devnet/instructions/createContract.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/index.d.ts +15 -0
- package/dist/types/codama/devnet/instructions/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/payRental.d.ts +110 -0
- package/dist/types/codama/devnet/instructions/payRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/resetRental.d.ts +71 -0
- package/dist/types/codama/devnet/instructions/resetRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/programs/index.d.ts +9 -0
- package/dist/types/codama/devnet/programs/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/programs/srsly.d.ts +47 -0
- package/dist/types/codama/devnet/programs/srsly.d.ts.map +1 -0
- package/dist/types/codama/devnet/shared/index.d.ts +50 -0
- package/dist/types/codama/devnet/shared/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/clockData.d.ts +29 -0
- package/dist/types/codama/devnet/types/clockData.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/equality.d.ts +18 -0
- package/dist/types/codama/devnet/types/equality.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/execContext.d.ts +48 -0
- package/dist/types/codama/devnet/types/execContext.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/index.d.ts +16 -0
- package/dist/types/codama/devnet/types/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/serializableAccount.d.ts +22 -0
- package/dist/types/codama/devnet/types/serializableAccount.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/serializableInstruction.d.ts +30 -0
- package/dist/types/codama/devnet/types/serializableInstruction.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/threadResponse.d.ts +42 -0
- package/dist/types/codama/devnet/types/threadResponse.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/trigger.d.ts +98 -0
- package/dist/types/codama/devnet/types/trigger.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/triggerContext.d.ts +75 -0
- package/dist/types/codama/devnet/types/triggerContext.d.ts.map +1 -0
- package/dist/types/codama/mainnet/accounts/contractState.d.ts +51 -0
- package/dist/types/codama/mainnet/accounts/contractState.d.ts.map +1 -0
- package/dist/types/codama/mainnet/accounts/fleet.d.ts +38 -0
- package/dist/types/codama/mainnet/accounts/fleet.d.ts.map +1 -0
- package/dist/types/codama/mainnet/accounts/index.d.ts +12 -0
- package/dist/types/codama/mainnet/accounts/index.d.ts.map +1 -0
- package/dist/types/codama/mainnet/accounts/rentalState.d.ts +48 -0
- package/dist/types/codama/mainnet/accounts/rentalState.d.ts.map +1 -0
- package/dist/types/codama/mainnet/accounts/thread.d.ts +74 -0
- package/dist/types/codama/mainnet/accounts/thread.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/codama/mainnet/errors/index.d.ts +9 -0
- package/dist/types/codama/mainnet/errors/index.d.ts.map +1 -0
- package/dist/types/codama/mainnet/errors/srsly.d.ts +50 -0
- package/dist/types/codama/mainnet/errors/srsly.d.ts.map +1 -0
- package/dist/types/codama/mainnet/index.d.ts +13 -0
- package/dist/types/codama/mainnet/index.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/acceptRental.d.ts +131 -0
- package/dist/types/codama/mainnet/instructions/acceptRental.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/cancelRental.d.ts +71 -0
- package/dist/types/codama/mainnet/instructions/cancelRental.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/closeContract.d.ts +100 -0
- package/dist/types/codama/mainnet/instructions/closeContract.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/closeRental.d.ts +83 -0
- package/dist/types/codama/mainnet/instructions/closeRental.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/createContract.d.ts +108 -0
- package/dist/types/codama/mainnet/instructions/createContract.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/index.d.ts +15 -0
- package/dist/types/codama/mainnet/instructions/index.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/payRental.d.ts +110 -0
- package/dist/types/codama/mainnet/instructions/payRental.d.ts.map +1 -0
- package/dist/types/codama/mainnet/instructions/resetRental.d.ts +71 -0
- package/dist/types/codama/mainnet/instructions/resetRental.d.ts.map +1 -0
- package/dist/types/codama/mainnet/programs/index.d.ts +9 -0
- package/dist/types/codama/mainnet/programs/index.d.ts.map +1 -0
- package/dist/types/codama/mainnet/programs/srsly.d.ts +47 -0
- package/dist/types/codama/mainnet/programs/srsly.d.ts.map +1 -0
- package/dist/types/codama/mainnet/shared/index.d.ts +50 -0
- package/dist/types/codama/mainnet/shared/index.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/clockData.d.ts +29 -0
- package/dist/types/codama/mainnet/types/clockData.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/equality.d.ts +18 -0
- package/dist/types/codama/mainnet/types/equality.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/execContext.d.ts +48 -0
- package/dist/types/codama/mainnet/types/execContext.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/index.d.ts +16 -0
- package/dist/types/codama/mainnet/types/index.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/serializableAccount.d.ts +22 -0
- package/dist/types/codama/mainnet/types/serializableAccount.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/serializableInstruction.d.ts +30 -0
- package/dist/types/codama/mainnet/types/serializableInstruction.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/threadResponse.d.ts +42 -0
- package/dist/types/codama/mainnet/types/threadResponse.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/trigger.d.ts +98 -0
- package/dist/types/codama/mainnet/types/trigger.d.ts.map +1 -0
- package/dist/types/codama/mainnet/types/triggerContext.d.ts +75 -0
- package/dist/types/codama/mainnet/types/triggerContext.d.ts.map +1 -0
- package/dist/types/contract/close.d.ts +52 -0
- package/dist/types/contract/close.d.ts.map +1 -0
- package/dist/types/contract/create.d.ts +80 -0
- package/dist/types/contract/create.d.ts.map +1 -0
- package/dist/types/contract/index.d.ts +3 -0
- package/dist/types/contract/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rental/accept.d.ts +92 -0
- package/dist/types/rental/accept.d.ts.map +1 -0
- package/dist/types/rental/cancel.d.ts +44 -0
- package/dist/types/rental/cancel.d.ts.map +1 -0
- package/dist/types/rental/close.d.ts +49 -0
- package/dist/types/rental/close.d.ts.map +1 -0
- package/dist/types/rental/index.d.ts +5 -0
- package/dist/types/rental/index.d.ts.map +1 -0
- package/dist/types/rental/reset.d.ts +68 -0
- package/dist/types/rental/reset.d.ts.map +1 -0
- 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 +32 -0
- package/dist/types/utils/constants.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/profiles.d.ts +54 -0
- package/dist/types/utils/profiles.d.ts.map +1 -0
- package/package.json +1 -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,GAAG,EAAE,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,YAAY,CAAC,OAAO,IAAI,QAAQ,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,SAAyB;IACnD,OAAO,EAAE,GAAG,YAAY,EAAE,GAAG,SAAS,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAU,UAAkB,EAAE,OAAiB;IACtF,M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EvE,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"}
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
|
9
|
+
// PaymentFrequency enum to match the Rust program
|
|
10
|
+
export var PaymentFrequency;
|
|
11
|
+
(function (PaymentFrequency) {
|
|
12
|
+
PaymentFrequency[PaymentFrequency["Hourly"] = 0] = "Hourly";
|
|
13
|
+
PaymentFrequency[PaymentFrequency["Daily"] = 1] = "Daily";
|
|
14
|
+
PaymentFrequency[PaymentFrequency["DailyOld"] = 2] = "DailyOld";
|
|
15
|
+
PaymentFrequency[PaymentFrequency["Weekly"] = 3] = "Weekly";
|
|
16
|
+
PaymentFrequency[PaymentFrequency["Monthly"] = 4] = "Monthly";
|
|
17
|
+
// Development-only frequencies (not available on mainnet)
|
|
18
|
+
PaymentFrequency[PaymentFrequency["Decasecond"] = 5] = "Decasecond";
|
|
19
|
+
PaymentFrequency[PaymentFrequency["Minute"] = 6] = "Minute";
|
|
20
|
+
})(PaymentFrequency || (PaymentFrequency = {}));
|
|
21
|
+
// Export async functions to get network-specific constants
|
|
22
|
+
export async function getPaymentFrequency() {
|
|
23
|
+
const module = await getCachedNetworkModule('types');
|
|
24
|
+
return module.PaymentFrequency;
|
|
25
|
+
}
|
|
26
|
+
export async function getSrslyProgramAddress() {
|
|
27
|
+
const module = await getCachedNetworkModule('programs');
|
|
28
|
+
return module.SRSLY_PROGRAM_ADDRESS;
|
|
29
|
+
}
|
|
30
|
+
// Export async function to get program ID
|
|
31
|
+
export async function getProgramId() {
|
|
32
|
+
return await getSrslyProgramAddress();
|
|
33
|
+
}
|
|
34
|
+
// Network-specific constants with configuration support
|
|
35
|
+
export async function getSageProgramAddress(config) {
|
|
36
|
+
// Merge global config with provided config
|
|
37
|
+
const globalConfig = getConfig();
|
|
38
|
+
const effectiveConfig = { ...globalConfig, ...config };
|
|
39
|
+
if (effectiveConfig?.sageProgramAddress)
|
|
40
|
+
return effectiveConfig.sageProgramAddress;
|
|
41
|
+
const targetNetwork = effectiveConfig?.network; // Uses global config or devnet default
|
|
42
|
+
try {
|
|
43
|
+
const constantsModule = await getCachedNetworkModule('constants', targetNetwork);
|
|
44
|
+
return constantsModule.SAGE_PROGRAM_ADDRESS;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Fallback to programs module or hardcoded default
|
|
48
|
+
const programsModule = await getCachedNetworkModule('programs', targetNetwork);
|
|
49
|
+
return programsModule.SAGE_PROGRAM_ADDRESS || 'sAgezwJpDb1aHvzNr3o24cKjsETmFEKghBEyJ1askDi';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export async function getProfileFactionProgramAddress(config) {
|
|
53
|
+
// Merge global config with provided config
|
|
54
|
+
const globalConfig = getConfig();
|
|
55
|
+
const effectiveConfig = { ...globalConfig, ...config };
|
|
56
|
+
if (effectiveConfig?.profileFactionProgramAddress)
|
|
57
|
+
return effectiveConfig.profileFactionProgramAddress;
|
|
58
|
+
const targetNetwork = effectiveConfig?.network; // Uses global config or devnet default
|
|
59
|
+
try {
|
|
60
|
+
const constantsModule = await getCachedNetworkModule('constants', targetNetwork);
|
|
61
|
+
return constantsModule.PROFILE_FACTION_PROGRAM_ADDRESS;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Fallback to programs module or hardcoded default
|
|
65
|
+
const programsModule = await getCachedNetworkModule('programs', targetNetwork);
|
|
66
|
+
return programsModule.PROFILE_FACTION_PROGRAM_ADDRESS || 'pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export async function getSageGameId(config) {
|
|
70
|
+
// Merge global config with provided config
|
|
71
|
+
const globalConfig = getConfig();
|
|
72
|
+
const effectiveConfig = { ...globalConfig, ...config };
|
|
73
|
+
if (effectiveConfig?.gameId)
|
|
74
|
+
return effectiveConfig.gameId;
|
|
75
|
+
const targetNetwork = effectiveConfig?.network; // Uses global config or devnet default
|
|
76
|
+
try {
|
|
77
|
+
const constantsModule = await getCachedNetworkModule('constants', targetNetwork);
|
|
78
|
+
return constantsModule.SAGE_GAME_ID;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Fallback to programs module or hardcoded default
|
|
82
|
+
const programsModule = await getCachedNetworkModule('programs', targetNetwork);
|
|
83
|
+
return programsModule.SAGE_GAME_ID || 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Faction-specific CSS coordinates for starbase derivation
|
|
87
|
+
export const FACTION_SPECIFIC_CSS = {
|
|
88
|
+
mud: { x: 0, y: -39 },
|
|
89
|
+
oni: { x: -40, y: 30 },
|
|
90
|
+
ustur: { x: 40, y: 30 },
|
|
91
|
+
};
|
|
92
|
+
export const FACTION_MAPPING = {
|
|
93
|
+
1: 'mud',
|
|
94
|
+
2: 'oni',
|
|
95
|
+
3: 'ustur'
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Convert PaymentFrequency enum to string (async version)
|
|
99
|
+
*/
|
|
100
|
+
export async function paymentFrequencyToString(freq) {
|
|
101
|
+
const PaymentFrequency = await getPaymentFrequency();
|
|
102
|
+
return PaymentFrequency[freq].toLowerCase();
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,kDAAkD;AAClD,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,2DAAU,CAAA;IACV,yDAAS,CAAA;IACT,+DAAY,CAAA;IACZ,2DAAU,CAAA;IACV,6DAAW,CAAA;IACX,0DAA0D;IAC1D,mEAAc,CAAA;IACd,2DAAU,CAAA;AACZ,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;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E,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;AAEF,MAAM,CAAC,MAAM,eAAe,GAA2B;IACrD,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,OAAO;CACX,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAS;IACtD,MAAM,gBAAgB,GAAG,MAAM,mBAAmB,EAAE,CAAC;IACrD,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { getBytesEncoder, getAddressEncoder, getProgramDerivedAddress } from '@solana/kit';
|
|
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';
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to convert a string seed to a Uint8Array
|
|
6
|
+
* This is necessary for @solana/kit's getBytesEncoder().encode()
|
|
7
|
+
*
|
|
8
|
+
* @param seed The string seed to convert
|
|
9
|
+
* @returns A Uint8Array containing the UTF-8 encoded seed
|
|
10
|
+
*/
|
|
11
|
+
function seedToBytes(seed) {
|
|
12
|
+
return new Uint8Array(Buffer.from(seed));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to derive the borrower's profile faction account
|
|
16
|
+
*
|
|
17
|
+
* @param profile The borrower's profile address
|
|
18
|
+
* @param config Optional configuration for network-specific constants
|
|
19
|
+
* @returns Promise that resolves to the derived profile faction address
|
|
20
|
+
*/
|
|
21
|
+
export async function deriveProfileFaction(profile, config) {
|
|
22
|
+
const programAddress = await getProfileFactionProgramAddress(config);
|
|
23
|
+
const [address] = await getProgramDerivedAddress({
|
|
24
|
+
programAddress: programAddress,
|
|
25
|
+
seeds: [
|
|
26
|
+
seedToBytes(PROFILE_FACTION_SEED),
|
|
27
|
+
getAddressEncoder().encode(profile)
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
return address;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Helper function to derive the sage player profile
|
|
34
|
+
*
|
|
35
|
+
* @param borrowerProfile The borrower's profile address
|
|
36
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
37
|
+
* @param config Optional configuration for network-specific constants
|
|
38
|
+
* @returns Promise that resolves to the derived sage player profile address
|
|
39
|
+
*/
|
|
40
|
+
export async function deriveSagePlayerProfile(borrowerProfile, gameId, config) {
|
|
41
|
+
const [programAddress, actualGameId] = await Promise.all([
|
|
42
|
+
getSageProgramAddress(config),
|
|
43
|
+
gameId || getSageGameId(config)
|
|
44
|
+
]);
|
|
45
|
+
const [address] = await getProgramDerivedAddress({
|
|
46
|
+
programAddress: programAddress,
|
|
47
|
+
seeds: [
|
|
48
|
+
seedToBytes(SAGE_PLAYER_PROFILE_SEED),
|
|
49
|
+
getAddressEncoder().encode(borrowerProfile),
|
|
50
|
+
getAddressEncoder().encode(actualGameId)
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
return address;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Helper function to derive the starbase address based on faction
|
|
57
|
+
*
|
|
58
|
+
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
59
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
60
|
+
* @param config Optional configuration for network-specific constants
|
|
61
|
+
* @returns Promise that resolves to the derived starbase address
|
|
62
|
+
*/
|
|
63
|
+
export async function deriveStarbase(faction, gameId, config) {
|
|
64
|
+
// Convert faction to string representation if it's a number
|
|
65
|
+
const factionName = typeof faction === 'number'
|
|
66
|
+
? FACTION_MAPPING[faction]
|
|
67
|
+
: faction;
|
|
68
|
+
// Validate faction
|
|
69
|
+
if (!factionName || !FACTION_SPECIFIC_CSS[factionName]) {
|
|
70
|
+
throw new Error(`Unsupported faction: ${faction}`);
|
|
71
|
+
}
|
|
72
|
+
// Get coordinates for the faction
|
|
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
|
+
]);
|
|
79
|
+
// Convert coordinates to bytes (little-endian, two's complement)
|
|
80
|
+
const xCoord = new DataView(new ArrayBuffer(8));
|
|
81
|
+
const yCoord = new DataView(new ArrayBuffer(8));
|
|
82
|
+
xCoord.setBigInt64(0, BigInt(coords.x), true);
|
|
83
|
+
yCoord.setBigInt64(0, BigInt(coords.y), true);
|
|
84
|
+
// Create Uint8Array from DataView
|
|
85
|
+
const xBytes = new Uint8Array(xCoord.buffer);
|
|
86
|
+
const yBytes = new Uint8Array(yCoord.buffer);
|
|
87
|
+
const [address] = await getProgramDerivedAddress({
|
|
88
|
+
programAddress: programAddress,
|
|
89
|
+
seeds: [
|
|
90
|
+
seedToBytes(STARBASE_SEED),
|
|
91
|
+
getAddressEncoder().encode(actualGameId),
|
|
92
|
+
getBytesEncoder().encode(xBytes),
|
|
93
|
+
getBytesEncoder().encode(yBytes)
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
return address;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Helper function to derive the starbase player address
|
|
100
|
+
*
|
|
101
|
+
* @param sagePlayerProfile The sage player profile address
|
|
102
|
+
* @param starbase The starbase address
|
|
103
|
+
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
104
|
+
* @param config Optional configuration for network-specific constants
|
|
105
|
+
* @returns Promise that resolves to the derived starbase player address
|
|
106
|
+
*/
|
|
107
|
+
export async function deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId = 0, config) {
|
|
108
|
+
// Get network-specific SAGE program address
|
|
109
|
+
const programAddress = await getSageProgramAddress(config);
|
|
110
|
+
// Convert sequence ID to bytes (little-endian uint16)
|
|
111
|
+
const seqIdView = new DataView(new ArrayBuffer(2));
|
|
112
|
+
seqIdView.setUint16(0, starbaseSeqId, true);
|
|
113
|
+
const seqIdBytes = new Uint8Array(seqIdView.buffer);
|
|
114
|
+
const [address] = await getProgramDerivedAddress({
|
|
115
|
+
programAddress: programAddress,
|
|
116
|
+
seeds: [
|
|
117
|
+
seedToBytes(STARBASE_PLAYER_SEED),
|
|
118
|
+
getAddressEncoder().encode(starbase),
|
|
119
|
+
getAddressEncoder().encode(sagePlayerProfile),
|
|
120
|
+
getBytesEncoder().encode(seqIdBytes)
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
return address;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Derives all three accounts needed: profileFaction, starbase, and starbasePlayer
|
|
127
|
+
*
|
|
128
|
+
* @param profile The borrower's profile address
|
|
129
|
+
* @param faction The faction (1/2/3 or 'mud'/'oni'/'ustur')
|
|
130
|
+
* @param gameId The game ID (if not provided, uses network-specific default)
|
|
131
|
+
* @param starbaseSeqId The starbase sequence ID (defaults to 0)
|
|
132
|
+
* @param config Optional configuration for network-specific constants
|
|
133
|
+
* @returns Promise that resolves to the three derived addresses
|
|
134
|
+
*/
|
|
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);
|
|
138
|
+
// Derive the three accounts in parallel
|
|
139
|
+
const [profileFaction, sagePlayerProfile, starbase] = await Promise.all([
|
|
140
|
+
deriveProfileFaction(profile, config),
|
|
141
|
+
deriveSagePlayerProfile(profile, actualGameId, config),
|
|
142
|
+
deriveStarbase(faction, actualGameId, config)
|
|
143
|
+
]);
|
|
144
|
+
// Derive starbasePlayer using the results from above
|
|
145
|
+
const starbasePlayer = await deriveStarbasePlayer(sagePlayerProfile, starbase, starbaseSeqId, config);
|
|
146
|
+
return {
|
|
147
|
+
profileFaction,
|
|
148
|
+
starbase,
|
|
149
|
+
starbasePlayer
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +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,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,K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AAQ;QACR,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { fetchEncodedAccount, fetchEncodedAccounts, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
|
|
9
|
+
export declare const CONTRACT_STATE_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
10
|
+
export declare function getContractStateDiscriminatorBytes(): ReadonlyUint8Array;
|
|
11
|
+
export type ContractState = {
|
|
12
|
+
discriminator: ReadonlyUint8Array;
|
|
13
|
+
version: number;
|
|
14
|
+
toClose: boolean;
|
|
15
|
+
rate: bigint;
|
|
16
|
+
durationMin: bigint;
|
|
17
|
+
durationMax: bigint;
|
|
18
|
+
paymentsFeq: string;
|
|
19
|
+
fleet: Address;
|
|
20
|
+
gameId: Address;
|
|
21
|
+
currentRentalState: Address;
|
|
22
|
+
owner: Address;
|
|
23
|
+
ownerTokenAccount: Address;
|
|
24
|
+
ownerProfile: Address;
|
|
25
|
+
bump: number;
|
|
26
|
+
};
|
|
27
|
+
export type ContractStateArgs = {
|
|
28
|
+
version: number;
|
|
29
|
+
toClose: boolean;
|
|
30
|
+
rate: number | bigint;
|
|
31
|
+
durationMin: number | bigint;
|
|
32
|
+
durationMax: number | bigint;
|
|
33
|
+
paymentsFeq: string;
|
|
34
|
+
fleet: Address;
|
|
35
|
+
gameId: Address;
|
|
36
|
+
currentRentalState: Address;
|
|
37
|
+
owner: Address;
|
|
38
|
+
ownerTokenAccount: Address;
|
|
39
|
+
ownerProfile: Address;
|
|
40
|
+
bump: number;
|
|
41
|
+
};
|
|
42
|
+
export declare function getContractStateEncoder(): Encoder<ContractStateArgs>;
|
|
43
|
+
export declare function getContractStateDecoder(): Decoder<ContractState>;
|
|
44
|
+
export declare function getContractStateCodec(): Codec<ContractStateArgs, ContractState>;
|
|
45
|
+
export declare function decodeContractState<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<ContractState, TAddress>;
|
|
46
|
+
export declare function decodeContractState<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<ContractState, TAddress>;
|
|
47
|
+
export declare function fetchContractState<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<Account<ContractState, TAddress>>;
|
|
48
|
+
export declare function fetchMaybeContractState<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeAccount<ContractState, TAddress>>;
|
|
49
|
+
export declare function fetchAllContractState(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<Account<ContractState>[]>;
|
|
50
|
+
export declare function fetchAllMaybeContractState(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<MaybeAccount<ContractState>[]>;
|
|
51
|
+
//# sourceMappingURL=contractState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractState.d.ts","sourceRoot":"","sources":["../../../../../src/codama/devnet/accounts/contractState.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAOL,mBAAmB,EACnB,oBAAoB,EAoBpB,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK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,EAAE,KAAK,CAAC,OAAO,CAAC,EACzB,MAAM,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,CAAC,CAGxC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { fetchEncodedAccount, fetchEncodedAccounts, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
|
|
9
|
+
export declare const FLEET_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
10
|
+
export declare function getFleetDiscriminatorBytes(): ReadonlyUint8Array;
|
|
11
|
+
export type Fleet = {
|
|
12
|
+
discriminator: ReadonlyUint8Array;
|
|
13
|
+
version: number;
|
|
14
|
+
gameId: Address;
|
|
15
|
+
ownerProfile: Address;
|
|
16
|
+
fleetShips: Address;
|
|
17
|
+
subProfile: Address;
|
|
18
|
+
subProfileInvalidator: Address;
|
|
19
|
+
};
|
|
20
|
+
export type FleetArgs = {
|
|
21
|
+
version: number;
|
|
22
|
+
gameId: Address;
|
|
23
|
+
ownerProfile: Address;
|
|
24
|
+
fleetShips: Address;
|
|
25
|
+
subProfile: Address;
|
|
26
|
+
subProfileInvalidator: Address;
|
|
27
|
+
};
|
|
28
|
+
export declare function getFleetEncoder(): Encoder<FleetArgs>;
|
|
29
|
+
export declare function getFleetDecoder(): Decoder<Fleet>;
|
|
30
|
+
export declare function getFleetCodec(): Codec<FleetArgs, Fleet>;
|
|
31
|
+
export declare function decodeFleet<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<Fleet, TAddress>;
|
|
32
|
+
export declare function decodeFleet<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<Fleet, TAddress>;
|
|
33
|
+
export declare function fetchFleet<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<Account<Fleet, TAddress>>;
|
|
34
|
+
export declare function fetchMaybeFleet<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeAccount<Fleet, TAddress>>;
|
|
35
|
+
export declare function fetchAllFleet(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<Account<Fleet>[]>;
|
|
36
|
+
export declare function fetchAllMaybeFleet(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<MaybeAccount<Fleet>[]>;
|
|
37
|
+
export declare function getFleetSize(): number;
|
|
38
|
+
//# sourceMappingURL=fleet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet.d.ts","sourceRoot":"","sources":["../../../../../src/codama/devnet/accounts/fleet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAKL,mBAAmB,EACnB,oBAAoB,EAYpB,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,mBAAmB,yBAE9B,CAAC;AAEH,wBAAgB,0BAA0B,uBAEzC;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,aAAa,EAAE,kBAAkB,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MA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OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAC9C,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAC1B,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAGxC;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAC/C,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,EACzB,MAAM,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAI3B;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAC/C,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,EACzB,MAAM,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAGhC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
export * from './contractState';
|
|
9
|
+
export * from './fleet';
|
|
10
|
+
export * from './rentalState';
|
|
11
|
+
export * from './thread';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/codama/devnet/accounts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { fetchEncodedAccount, fetchEncodedAccounts, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
|
|
9
|
+
export declare const RENTAL_STATE_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
10
|
+
export declare function getRentalStateDiscriminatorBytes(): ReadonlyUint8Array;
|
|
11
|
+
export type RentalState = {
|
|
12
|
+
discriminator: ReadonlyUint8Array;
|
|
13
|
+
version: number;
|
|
14
|
+
borrower: Address;
|
|
15
|
+
thread: Address;
|
|
16
|
+
contract: Address;
|
|
17
|
+
ownerTokenAccount: Address;
|
|
18
|
+
referralTokenAccount: Address;
|
|
19
|
+
rate: number;
|
|
20
|
+
startTime: bigint;
|
|
21
|
+
endTime: bigint;
|
|
22
|
+
cancelled: boolean;
|
|
23
|
+
bump: number;
|
|
24
|
+
};
|
|
25
|
+
export type RentalStateArgs = {
|
|
26
|
+
version: number;
|
|
27
|
+
borrower: Address;
|
|
28
|
+
thread: Address;
|
|
29
|
+
contract: Address;
|
|
30
|
+
ownerTokenAccount: Address;
|
|
31
|
+
referralTokenAccount: Address;
|
|
32
|
+
rate: number;
|
|
33
|
+
startTime: number | bigint;
|
|
34
|
+
endTime: number | bigint;
|
|
35
|
+
cancelled: boolean;
|
|
36
|
+
bump: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function getRentalStateEncoder(): Encoder<RentalStateArgs>;
|
|
39
|
+
export declare function getRentalStateDecoder(): Decoder<RentalState>;
|
|
40
|
+
export declare function getRentalStateCodec(): Codec<RentalStateArgs, RentalState>;
|
|
41
|
+
export declare function decodeRentalState<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<RentalState, TAddress>;
|
|
42
|
+
export declare function decodeRentalState<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<RentalState, TAddress>;
|
|
43
|
+
export declare function fetchRentalState<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<Account<RentalState, TAddress>>;
|
|
44
|
+
export declare function fetchMaybeRentalState<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeAccount<RentalState, TAddress>>;
|
|
45
|
+
export declare function fetchAllRentalState(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<Account<RentalState>[]>;
|
|
46
|
+
export declare function fetchAllMaybeRentalState(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<MaybeAccount<RentalState>[]>;
|
|
47
|
+
export declare function getRentalStateSize(): number;
|
|
48
|
+
//# sourceMappingURL=rentalState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rentalState.d.ts","sourceRoot":"","sources":["../../../../../src/codama/devnet/accounts/rentalState.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAKL,mBAAmB,EACnB,oBAAoB,EAkBpB,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,0BA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