@wuwei-labs/srsly 1.0.0-beta.1 → 2.0.0-beta.11
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 +695 -17
- package/dist/cjs/codama/{accounts → devnet/accounts}/contractState.js +2 -7
- package/dist/cjs/codama/devnet/accounts/contractState.js.map +1 -0
- package/dist/cjs/codama/devnet/accounts/fleet.js.map +1 -0
- package/dist/cjs/codama/devnet/accounts/index.js.map +1 -0
- package/dist/cjs/codama/{accounts → devnet/accounts}/rentalState.js +3 -1
- package/dist/cjs/codama/devnet/accounts/rentalState.js.map +1 -0
- package/dist/cjs/codama/devnet/accounts/thread.js.map +1 -0
- package/dist/cjs/codama/devnet/constants.js +32 -0
- package/dist/cjs/codama/devnet/constants.js.map +1 -0
- package/dist/cjs/codama/devnet/errors/index.js.map +1 -0
- package/dist/cjs/codama/{errors → devnet/errors}/srsly.js +4 -1
- package/dist/cjs/codama/devnet/errors/srsly.js.map +1 -0
- package/dist/cjs/codama/devnet/index.js.map +1 -0
- package/dist/cjs/codama/{instructions → devnet/instructions}/acceptRental.js +17 -23
- package/dist/cjs/codama/devnet/instructions/acceptRental.js.map +1 -0
- package/dist/cjs/codama/devnet/instructions/cancelRental.js.map +1 -0
- package/dist/cjs/codama/{instructions → devnet/instructions}/closeContract.js +28 -1
- package/dist/cjs/codama/devnet/instructions/closeContract.js.map +1 -0
- package/dist/cjs/codama/{instructions → devnet/instructions}/closeRental.js +28 -1
- package/dist/cjs/codama/devnet/instructions/closeRental.js.map +1 -0
- package/dist/cjs/codama/devnet/instructions/createContract.js.map +1 -0
- package/dist/cjs/codama/{instructions → devnet/instructions}/index.js +0 -1
- package/dist/cjs/codama/devnet/instructions/index.js.map +1 -0
- package/dist/cjs/codama/{instructions → devnet/instructions}/payRental.js +45 -1
- package/dist/cjs/codama/devnet/instructions/payRental.js.map +1 -0
- package/dist/cjs/codama/devnet/instructions/resetRental.js.map +1 -0
- package/dist/cjs/codama/devnet/programs/index.js.map +1 -0
- package/dist/cjs/codama/{programs → devnet/programs}/srsly.js +2 -6
- package/dist/cjs/codama/devnet/programs/srsly.js.map +1 -0
- package/dist/cjs/codama/devnet/shared/index.js.map +1 -0
- package/dist/cjs/codama/devnet/types/clockData.js.map +1 -0
- package/dist/cjs/codama/devnet/types/equality.js.map +1 -0
- package/dist/cjs/codama/devnet/types/execContext.js.map +1 -0
- package/dist/cjs/codama/{types → devnet/types}/index.js +0 -1
- package/dist/cjs/codama/devnet/types/index.js.map +1 -0
- package/dist/cjs/codama/devnet/types/serializableAccount.js.map +1 -0
- package/dist/cjs/codama/devnet/types/serializableInstruction.js.map +1 -0
- package/dist/cjs/codama/devnet/types/threadResponse.js.map +1 -0
- package/dist/cjs/codama/devnet/types/trigger.js.map +1 -0
- package/dist/cjs/codama/devnet/types/triggerContext.js.map +1 -0
- package/dist/cjs/codama/mainnet/accounts/contractState.js +87 -0
- package/dist/cjs/codama/mainnet/accounts/contractState.js.map +1 -0
- package/dist/cjs/codama/mainnet/accounts/fleet.js +77 -0
- package/dist/cjs/codama/mainnet/accounts/fleet.js.map +1 -0
- package/dist/cjs/codama/mainnet/accounts/index.js +28 -0
- package/dist/cjs/codama/mainnet/accounts/index.js.map +1 -0
- package/dist/cjs/codama/mainnet/accounts/rentalState.js +87 -0
- package/dist/cjs/codama/mainnet/accounts/rentalState.js.map +1 -0
- package/dist/cjs/codama/mainnet/accounts/thread.js +89 -0
- package/dist/cjs/codama/mainnet/accounts/thread.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/codama/mainnet/errors/index.js +25 -0
- package/dist/cjs/codama/mainnet/errors/index.js.map +1 -0
- package/dist/cjs/codama/mainnet/errors/srsly.js +74 -0
- package/dist/cjs/codama/mainnet/errors/srsly.js.map +1 -0
- package/dist/cjs/codama/mainnet/index.js +29 -0
- package/dist/cjs/codama/mainnet/index.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/acceptRental.js +357 -0
- package/dist/cjs/codama/mainnet/instructions/acceptRental.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/cancelRental.js +225 -0
- package/dist/cjs/codama/mainnet/instructions/cancelRental.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/closeContract.js +246 -0
- package/dist/cjs/codama/mainnet/instructions/closeContract.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/closeRental.js +260 -0
- package/dist/cjs/codama/mainnet/instructions/closeRental.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/createContract.js +261 -0
- package/dist/cjs/codama/mainnet/instructions/createContract.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/index.js +31 -0
- package/dist/cjs/codama/mainnet/instructions/index.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/payRental.js +280 -0
- package/dist/cjs/codama/mainnet/instructions/payRental.js.map +1 -0
- package/dist/cjs/codama/mainnet/instructions/resetRental.js +155 -0
- package/dist/cjs/codama/mainnet/instructions/resetRental.js.map +1 -0
- package/dist/cjs/codama/mainnet/programs/index.js +25 -0
- package/dist/cjs/codama/mainnet/programs/index.js.map +1 -0
- package/dist/cjs/codama/mainnet/programs/srsly.js +73 -0
- package/dist/cjs/codama/mainnet/programs/srsly.js.map +1 -0
- package/dist/cjs/codama/mainnet/shared/index.js +95 -0
- package/dist/cjs/codama/mainnet/shared/index.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/clockData.js +31 -0
- package/dist/cjs/codama/mainnet/types/clockData.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/equality.js +30 -0
- package/dist/cjs/codama/mainnet/types/equality.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/execContext.js +38 -0
- package/dist/cjs/codama/mainnet/types/execContext.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/index.js +32 -0
- package/dist/cjs/codama/mainnet/types/index.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/serializableAccount.js +31 -0
- package/dist/cjs/codama/mainnet/types/serializableAccount.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/serializableInstruction.js +32 -0
- package/dist/cjs/codama/mainnet/types/serializableInstruction.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/threadResponse.js +38 -0
- package/dist/cjs/codama/mainnet/types/threadResponse.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/trigger.js +90 -0
- package/dist/cjs/codama/mainnet/types/trigger.js.map +1 -0
- package/dist/cjs/codama/mainnet/types/triggerContext.js +49 -0
- package/dist/cjs/codama/mainnet/types/triggerContext.js.map +1 -0
- package/dist/cjs/contract/close.js +67 -15
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +54 -31
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +60 -0
- package/dist/cjs/rental/accept.js +70 -31
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +38 -19
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +39 -20
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +48 -33
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +214 -0
- package/dist/cjs/utils/config.js.map +1 -0
- package/dist/cjs/utils/constants.js +65 -9
- 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/{accounts → devnet/accounts}/contractState.js +3 -7
- package/dist/esm/codama/devnet/accounts/contractState.js.map +1 -0
- package/dist/esm/codama/devnet/accounts/fleet.js.map +1 -0
- package/dist/esm/codama/devnet/accounts/index.js.map +1 -0
- package/dist/esm/codama/{accounts → devnet/accounts}/rentalState.js +3 -1
- package/dist/esm/codama/devnet/accounts/rentalState.js.map +1 -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.map +1 -0
- package/dist/esm/codama/{errors → devnet/errors}/srsly.js +3 -0
- package/dist/esm/codama/devnet/errors/srsly.js.map +1 -0
- package/dist/esm/codama/devnet/index.js.map +1 -0
- package/dist/esm/codama/{instructions → devnet/instructions}/acceptRental.js +17 -23
- package/dist/esm/codama/devnet/instructions/acceptRental.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/cancelRental.js.map +1 -0
- package/dist/esm/codama/{instructions → devnet/instructions}/closeContract.js +28 -1
- package/dist/esm/codama/devnet/instructions/closeContract.js.map +1 -0
- package/dist/esm/codama/{instructions → devnet/instructions}/closeRental.js +28 -1
- package/dist/esm/codama/devnet/instructions/closeRental.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/createContract.js.map +1 -0
- package/dist/esm/codama/{instructions → devnet/instructions}/index.js +0 -1
- package/dist/esm/codama/devnet/instructions/index.js.map +1 -0
- package/dist/esm/codama/{instructions → devnet/instructions}/payRental.js +45 -1
- package/dist/esm/codama/devnet/instructions/payRental.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/resetRental.js.map +1 -0
- package/dist/esm/codama/devnet/programs/index.js.map +1 -0
- package/dist/esm/codama/{programs → devnet/programs}/srsly.js +2 -6
- package/dist/esm/codama/devnet/programs/srsly.js.map +1 -0
- package/dist/esm/codama/devnet/shared/index.js.map +1 -0
- package/dist/esm/codama/devnet/types/clockData.js.map +1 -0
- package/dist/esm/codama/devnet/types/equality.js.map +1 -0
- package/dist/esm/codama/devnet/types/execContext.js.map +1 -0
- package/dist/esm/codama/{types → devnet/types}/index.js +0 -1
- package/dist/esm/codama/devnet/types/index.js.map +1 -0
- package/dist/esm/codama/devnet/types/serializableAccount.js.map +1 -0
- package/dist/esm/codama/devnet/types/serializableInstruction.js.map +1 -0
- package/dist/esm/codama/devnet/types/threadResponse.js.map +1 -0
- package/dist/esm/codama/devnet/types/trigger.js.map +1 -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/{instructions/normalizeAdmin.js → mainnet/instructions/resetRental.js} +61 -58
- 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 +66 -14
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +52 -29
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +60 -0
- package/dist/esm/rental/accept.js +70 -31
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +37 -18
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +38 -19
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +48 -33
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +171 -0
- package/dist/esm/utils/config.js.map +1 -0
- package/dist/esm/utils/constants.js +58 -7
- 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/{accounts → devnet/accounts}/contractState.d.ts +2 -4
- package/dist/types/codama/devnet/accounts/contractState.d.ts.map +1 -0
- package/dist/types/codama/devnet/accounts/fleet.d.ts.map +1 -0
- package/dist/types/codama/devnet/accounts/index.d.ts.map +1 -0
- package/dist/types/codama/{accounts → devnet/accounts}/rentalState.d.ts +2 -0
- package/dist/types/codama/devnet/accounts/rentalState.d.ts.map +1 -0
- package/dist/types/codama/devnet/accounts/thread.d.ts.map +1 -0
- package/dist/types/codama/devnet/constants.d.ts +34 -0
- package/dist/types/codama/devnet/constants.d.ts.map +1 -0
- package/dist/types/codama/devnet/errors/index.d.ts.map +1 -0
- package/dist/types/codama/{errors → devnet/errors}/srsly.d.ts +3 -1
- package/dist/types/codama/devnet/errors/srsly.d.ts.map +1 -0
- package/dist/types/codama/devnet/index.d.ts.map +1 -0
- package/dist/types/codama/{instructions → devnet/instructions}/acceptRental.d.ts +14 -11
- package/dist/types/codama/devnet/instructions/acceptRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/cancelRental.d.ts.map +1 -0
- package/dist/types/codama/{instructions → devnet/instructions}/closeContract.d.ts +12 -8
- package/dist/types/codama/devnet/instructions/closeContract.d.ts.map +1 -0
- package/dist/types/codama/{instructions → devnet/instructions}/closeRental.d.ts +15 -11
- package/dist/types/codama/devnet/instructions/closeRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/createContract.d.ts.map +1 -0
- package/dist/types/codama/{instructions → devnet/instructions}/index.d.ts +0 -1
- package/dist/types/codama/devnet/instructions/index.d.ts.map +1 -0
- package/dist/types/codama/{instructions → devnet/instructions}/payRental.d.ts +21 -10
- package/dist/types/codama/devnet/instructions/payRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/resetRental.d.ts.map +1 -0
- package/dist/types/codama/devnet/programs/index.d.ts.map +1 -0
- package/dist/types/codama/{programs → devnet/programs}/srsly.d.ts +3 -6
- package/dist/types/codama/devnet/programs/srsly.d.ts.map +1 -0
- package/dist/types/codama/devnet/shared/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/clockData.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/equality.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/execContext.d.ts.map +1 -0
- package/dist/types/codama/{types → devnet/types}/index.d.ts +0 -1
- package/dist/types/codama/devnet/types/index.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/serializableAccount.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/serializableInstruction.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/threadResponse.d.ts.map +1 -0
- package/dist/types/codama/devnet/types/trigger.d.ts.map +1 -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 +34 -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 +17 -21
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +26 -19
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts +38 -16
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +16 -11
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +16 -11
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +17 -20
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +114 -0
- package/dist/types/utils/config.d.ts.map +1 -0
- package/dist/types/utils/constants.d.ts +17 -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 +31 -14
- package/target/idl/srsly-devnet.json +3275 -0
- package/target/idl/srsly-mainnet.json +3275 -0
- package/target/types/srsly-devnet.ts +1 -0
- package/target/types/srsly-mainnet.ts +1 -0
- package/dist/cjs/codama/accounts/contractState.js.map +0 -1
- package/dist/cjs/codama/accounts/fleet.js.map +0 -1
- package/dist/cjs/codama/accounts/index.js.map +0 -1
- package/dist/cjs/codama/accounts/rentalState.js.map +0 -1
- package/dist/cjs/codama/accounts/thread.js.map +0 -1
- package/dist/cjs/codama/errors/index.js.map +0 -1
- package/dist/cjs/codama/errors/srsly.js.map +0 -1
- package/dist/cjs/codama/index.js.map +0 -1
- package/dist/cjs/codama/instructions/acceptRental.js.map +0 -1
- package/dist/cjs/codama/instructions/cancelRental.js.map +0 -1
- package/dist/cjs/codama/instructions/closeContract.js.map +0 -1
- package/dist/cjs/codama/instructions/closeRental.js.map +0 -1
- package/dist/cjs/codama/instructions/createContract.js.map +0 -1
- package/dist/cjs/codama/instructions/index.js.map +0 -1
- package/dist/cjs/codama/instructions/normalizeAdmin.js +0 -152
- package/dist/cjs/codama/instructions/normalizeAdmin.js.map +0 -1
- package/dist/cjs/codama/instructions/payRental.js.map +0 -1
- package/dist/cjs/codama/instructions/resetRental.js.map +0 -1
- package/dist/cjs/codama/programs/index.js.map +0 -1
- package/dist/cjs/codama/programs/srsly.js.map +0 -1
- package/dist/cjs/codama/shared/index.js.map +0 -1
- package/dist/cjs/codama/types/clockData.js.map +0 -1
- package/dist/cjs/codama/types/equality.js.map +0 -1
- package/dist/cjs/codama/types/execContext.js.map +0 -1
- package/dist/cjs/codama/types/index.js.map +0 -1
- package/dist/cjs/codama/types/paymentFrequency.js +0 -34
- package/dist/cjs/codama/types/paymentFrequency.js.map +0 -1
- package/dist/cjs/codama/types/serializableAccount.js.map +0 -1
- package/dist/cjs/codama/types/serializableInstruction.js.map +0 -1
- package/dist/cjs/codama/types/threadResponse.js.map +0 -1
- package/dist/cjs/codama/types/trigger.js.map +0 -1
- package/dist/cjs/codama/types/triggerContext.js.map +0 -1
- package/dist/cjs/types.js +0 -2
- package/dist/cjs/types.js.map +0 -1
- package/dist/esm/codama/accounts/contractState.js.map +0 -1
- package/dist/esm/codama/accounts/fleet.js.map +0 -1
- package/dist/esm/codama/accounts/index.js.map +0 -1
- package/dist/esm/codama/accounts/rentalState.js.map +0 -1
- package/dist/esm/codama/accounts/thread.js.map +0 -1
- package/dist/esm/codama/errors/index.js.map +0 -1
- package/dist/esm/codama/errors/srsly.js.map +0 -1
- package/dist/esm/codama/index.js.map +0 -1
- package/dist/esm/codama/instructions/acceptRental.js.map +0 -1
- package/dist/esm/codama/instructions/cancelRental.js.map +0 -1
- package/dist/esm/codama/instructions/closeContract.js.map +0 -1
- package/dist/esm/codama/instructions/closeRental.js.map +0 -1
- package/dist/esm/codama/instructions/createContract.js.map +0 -1
- package/dist/esm/codama/instructions/index.js.map +0 -1
- package/dist/esm/codama/instructions/normalizeAdmin.js.map +0 -1
- package/dist/esm/codama/instructions/payRental.js.map +0 -1
- package/dist/esm/codama/instructions/resetRental.js.map +0 -1
- package/dist/esm/codama/programs/index.js.map +0 -1
- package/dist/esm/codama/programs/srsly.js.map +0 -1
- package/dist/esm/codama/shared/index.js.map +0 -1
- package/dist/esm/codama/types/clockData.js.map +0 -1
- package/dist/esm/codama/types/equality.js.map +0 -1
- package/dist/esm/codama/types/execContext.js.map +0 -1
- package/dist/esm/codama/types/index.js.map +0 -1
- package/dist/esm/codama/types/paymentFrequency.js +0 -28
- package/dist/esm/codama/types/paymentFrequency.js.map +0 -1
- package/dist/esm/codama/types/serializableAccount.js.map +0 -1
- package/dist/esm/codama/types/serializableInstruction.js.map +0 -1
- package/dist/esm/codama/types/threadResponse.js.map +0 -1
- package/dist/esm/codama/types/trigger.js.map +0 -1
- package/dist/esm/codama/types/triggerContext.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/types/codama/accounts/contractState.d.ts.map +0 -1
- package/dist/types/codama/accounts/fleet.d.ts.map +0 -1
- package/dist/types/codama/accounts/index.d.ts.map +0 -1
- package/dist/types/codama/accounts/rentalState.d.ts.map +0 -1
- package/dist/types/codama/accounts/thread.d.ts.map +0 -1
- package/dist/types/codama/errors/index.d.ts.map +0 -1
- package/dist/types/codama/errors/srsly.d.ts.map +0 -1
- package/dist/types/codama/index.d.ts.map +0 -1
- package/dist/types/codama/instructions/acceptRental.d.ts.map +0 -1
- package/dist/types/codama/instructions/cancelRental.d.ts.map +0 -1
- package/dist/types/codama/instructions/closeContract.d.ts.map +0 -1
- package/dist/types/codama/instructions/closeRental.d.ts.map +0 -1
- package/dist/types/codama/instructions/createContract.d.ts.map +0 -1
- package/dist/types/codama/instructions/index.d.ts.map +0 -1
- package/dist/types/codama/instructions/normalizeAdmin.d.ts +0 -67
- package/dist/types/codama/instructions/normalizeAdmin.d.ts.map +0 -1
- package/dist/types/codama/instructions/payRental.d.ts.map +0 -1
- package/dist/types/codama/instructions/resetRental.d.ts.map +0 -1
- package/dist/types/codama/programs/index.d.ts.map +0 -1
- package/dist/types/codama/programs/srsly.d.ts.map +0 -1
- package/dist/types/codama/shared/index.d.ts.map +0 -1
- package/dist/types/codama/types/clockData.d.ts.map +0 -1
- package/dist/types/codama/types/equality.d.ts.map +0 -1
- package/dist/types/codama/types/execContext.d.ts.map +0 -1
- package/dist/types/codama/types/index.d.ts.map +0 -1
- package/dist/types/codama/types/paymentFrequency.d.ts +0 -22
- package/dist/types/codama/types/paymentFrequency.d.ts.map +0 -1
- package/dist/types/codama/types/serializableAccount.d.ts.map +0 -1
- package/dist/types/codama/types/serializableInstruction.d.ts.map +0 -1
- package/dist/types/codama/types/threadResponse.d.ts.map +0 -1
- package/dist/types/codama/types/trigger.d.ts.map +0 -1
- package/dist/types/codama/types/triggerContext.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -1
- package/dist/types/types.d.ts.map +0 -1
- /package/dist/cjs/codama/{accounts → devnet/accounts}/fleet.js +0 -0
- /package/dist/cjs/codama/{accounts → devnet/accounts}/index.js +0 -0
- /package/dist/cjs/codama/{accounts → devnet/accounts}/thread.js +0 -0
- /package/dist/cjs/codama/{errors → devnet/errors}/index.js +0 -0
- /package/dist/cjs/codama/{index.js → devnet/index.js} +0 -0
- /package/dist/cjs/codama/{instructions → devnet/instructions}/cancelRental.js +0 -0
- /package/dist/cjs/codama/{instructions → devnet/instructions}/createContract.js +0 -0
- /package/dist/cjs/codama/{instructions → devnet/instructions}/resetRental.js +0 -0
- /package/dist/cjs/codama/{programs → devnet/programs}/index.js +0 -0
- /package/dist/cjs/codama/{shared → devnet/shared}/index.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/clockData.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/equality.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/execContext.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/serializableAccount.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/serializableInstruction.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/threadResponse.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/trigger.js +0 -0
- /package/dist/cjs/codama/{types → devnet/types}/triggerContext.js +0 -0
- /package/dist/esm/codama/{accounts → devnet/accounts}/fleet.js +0 -0
- /package/dist/esm/codama/{accounts → devnet/accounts}/index.js +0 -0
- /package/dist/esm/codama/{accounts → devnet/accounts}/thread.js +0 -0
- /package/dist/esm/codama/{errors → devnet/errors}/index.js +0 -0
- /package/dist/esm/codama/{index.js → devnet/index.js} +0 -0
- /package/dist/esm/codama/{instructions → devnet/instructions}/cancelRental.js +0 -0
- /package/dist/esm/codama/{instructions → devnet/instructions}/createContract.js +0 -0
- /package/dist/esm/codama/{instructions → devnet/instructions}/resetRental.js +0 -0
- /package/dist/esm/codama/{programs → devnet/programs}/index.js +0 -0
- /package/dist/esm/codama/{shared → devnet/shared}/index.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/clockData.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/equality.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/execContext.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/serializableAccount.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/serializableInstruction.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/threadResponse.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/trigger.js +0 -0
- /package/dist/esm/codama/{types → devnet/types}/triggerContext.js +0 -0
- /package/dist/types/codama/{accounts → devnet/accounts}/fleet.d.ts +0 -0
- /package/dist/types/codama/{accounts → devnet/accounts}/index.d.ts +0 -0
- /package/dist/types/codama/{accounts → devnet/accounts}/thread.d.ts +0 -0
- /package/dist/types/codama/{errors → devnet/errors}/index.d.ts +0 -0
- /package/dist/types/codama/{index.d.ts → devnet/index.d.ts} +0 -0
- /package/dist/types/codama/{instructions → devnet/instructions}/cancelRental.d.ts +0 -0
- /package/dist/types/codama/{instructions → devnet/instructions}/createContract.d.ts +0 -0
- /package/dist/types/codama/{instructions → devnet/instructions}/resetRental.d.ts +0 -0
- /package/dist/types/codama/{programs → devnet/programs}/index.d.ts +0 -0
- /package/dist/types/codama/{shared → devnet/shared}/index.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/clockData.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/equality.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/execContext.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/serializableAccount.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/serializableInstruction.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/threadResponse.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/trigger.d.ts +0 -0
- /package/dist/types/codama/{types → devnet/types}/triggerContext.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,33 +1,711 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SRSLY SDK
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@wuwei-labs/srsly)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](https://solana.com/)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
A TypeScript SDK for interacting with the SRSLY (Space Rental from SLY) Solana program - a decentralized rental system for Star Atlas fleets with network-specific configuration support.
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
### NPM
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @wuwei-labs/srsly
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### PNPM
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm add @wuwei-labs/srsly
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Yarn
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn add @wuwei-labs/srsly
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import {
|
|
33
|
+
createContract,
|
|
34
|
+
acceptRental,
|
|
35
|
+
setConfig,
|
|
36
|
+
setNetwork,
|
|
37
|
+
ATLAS_TO_STARDUST
|
|
38
|
+
} from '@wuwei-labs/srsly';
|
|
39
|
+
|
|
40
|
+
// Option 1: Set global configuration (recommended for most apps)
|
|
41
|
+
setConfig({ network: 'mainnet' });
|
|
42
|
+
// or use the convenience function: setNetwork('mainnet');
|
|
43
|
+
|
|
44
|
+
// Now all operations use mainnet by default
|
|
45
|
+
const contractInstruction = await createContract({
|
|
46
|
+
owner: wallet,
|
|
47
|
+
fleet: fleetAddress,
|
|
48
|
+
ownerProfile: profileAddress,
|
|
49
|
+
rate: 1000000, // Rate in ATLAS tokens
|
|
50
|
+
durationMin: 86400, // 1 day in seconds
|
|
51
|
+
durationMax: 604800, // 1 week in seconds
|
|
52
|
+
paymentsFreq: 'daily'
|
|
53
|
+
}); // Uses mainnet from global config
|
|
54
|
+
|
|
55
|
+
// Accept a rental with automatic ATLAS to stardust conversion
|
|
56
|
+
const acceptInstruction = await acceptRental({
|
|
57
|
+
borrower: borrowerWallet,
|
|
58
|
+
borrowerProfile: borrowerProfileAddress,
|
|
59
|
+
borrowerFaction: 'mud', // or 1, 2, 3
|
|
60
|
+
fleet: fleetAddress,
|
|
61
|
+
contract: contractAddress,
|
|
62
|
+
rate: 100, // ATLAS tokens per duration
|
|
63
|
+
duration: 86400 // 1 day in seconds
|
|
64
|
+
// amount is automatically calculated: rate * duration * ATLAS_TO_STARDUST
|
|
65
|
+
}); // Uses mainnet from global config
|
|
66
|
+
|
|
67
|
+
// Option 2: Override global config for specific instructions
|
|
68
|
+
const devnetInstruction = await createContract(params).set({ network: 'devnet' });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Core Features
|
|
72
|
+
|
|
73
|
+
### Contract Management
|
|
74
|
+
|
|
75
|
+
Create and manage rental contracts for Star Atlas fleets:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { createContract, closeContract } from '@wuwei-labs/srsly';
|
|
79
|
+
|
|
80
|
+
// Create a new rental contract with network configuration
|
|
81
|
+
const createIx = await createContract({
|
|
82
|
+
owner: wallet,
|
|
83
|
+
fleet: fleetAddress,
|
|
84
|
+
ownerProfile: profileAddress,
|
|
85
|
+
rate: 5000000, // Rate in ATLAS tokens
|
|
86
|
+
durationMin: 86400, // Minimum 1 day
|
|
87
|
+
durationMax: 2592000, // Maximum 30 days
|
|
88
|
+
paymentsFreq: 'daily',
|
|
89
|
+
ownerKeyIndex: 0
|
|
90
|
+
}).set({ network: 'mainnet' }); // Use mainnet configuration
|
|
91
|
+
|
|
92
|
+
// Close an existing contract using devnet defaults (direct await)
|
|
93
|
+
const closeIx = await closeContract({
|
|
94
|
+
owner: wallet,
|
|
95
|
+
fleet: fleetAddress,
|
|
96
|
+
contract: contractAddress,
|
|
97
|
+
faction: 'mud' // or faction number: 1, 2, 3
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Rental Operations
|
|
102
|
+
|
|
103
|
+
Handle rental lifecycle operations with automatic token conversion:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import {
|
|
107
|
+
acceptRental,
|
|
108
|
+
cancelRental,
|
|
109
|
+
closeRental,
|
|
110
|
+
resetRental,
|
|
111
|
+
ATLAS_TO_STARDUST
|
|
112
|
+
} from '@wuwei-labs/srsly';
|
|
113
|
+
|
|
114
|
+
// Accept a rental offer on devnet (rate-based with automatic conversion)
|
|
115
|
+
const acceptIx = await acceptRental({
|
|
116
|
+
borrower: borrowerWallet,
|
|
117
|
+
borrowerProfile: borrowerProfileAddress,
|
|
118
|
+
borrowerFaction: 'oni', // or faction number: 1=mud, 2=oni, 3=ustur
|
|
119
|
+
fleet: fleetAddress,
|
|
120
|
+
contract: contractAddress,
|
|
121
|
+
rate: 100, // ATLAS tokens (not per second, just ATLAS)
|
|
122
|
+
duration: 86400 // 1 day in seconds
|
|
123
|
+
// amount = rate * duration * ATLAS_TO_STARDUST automatically calculated
|
|
124
|
+
}).set({ network: 'devnet' });
|
|
125
|
+
|
|
126
|
+
// Cancel an active rental using devnet defaults (direct await)
|
|
127
|
+
const cancelIx = await cancelRental({
|
|
128
|
+
borrower: borrowerWallet,
|
|
129
|
+
contract: contractAddress,
|
|
130
|
+
rentalState: rentalStateAddress
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Close a completed rental on mainnet
|
|
134
|
+
const closeIx = await closeRental({
|
|
135
|
+
borrower: borrowerWallet,
|
|
136
|
+
contract: contractAddress,
|
|
137
|
+
rentalState: rentalStateAddress,
|
|
138
|
+
ownerTokenAccount: ownerTokenAccountAddress
|
|
139
|
+
}).set({ network: 'mainnet' });
|
|
140
|
+
|
|
141
|
+
// Reset rental state with custom configuration
|
|
142
|
+
const resetIx = await resetRental({
|
|
143
|
+
fleet: fleetAddress,
|
|
144
|
+
contract: contractAddress,
|
|
145
|
+
rentalState: rentalStateAddress,
|
|
146
|
+
faction: 'mud',
|
|
147
|
+
ownerProfile: ownerProfileAddress
|
|
148
|
+
}).set({
|
|
149
|
+
network: 'mainnet',
|
|
150
|
+
sageProgramAddress: 'custom...',
|
|
151
|
+
gameId: 'custom...'
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Account State Management
|
|
156
|
+
|
|
157
|
+
Fetch and decode account states using network-specific functions:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { getCachedNetworkModule } from '@wuwei-labs/srsly';
|
|
161
|
+
|
|
162
|
+
// Get network-specific account functions (defaults to devnet)
|
|
163
|
+
const accountsModule = await getCachedNetworkModule('accounts');
|
|
164
|
+
const { fetchContractState, fetchRentalState } = accountsModule;
|
|
165
|
+
|
|
166
|
+
// Or specify network explicitly
|
|
167
|
+
const mainnetAccountsModule = await getCachedNetworkModule('accounts', 'mainnet');
|
|
168
|
+
|
|
169
|
+
// Fetch contract state
|
|
170
|
+
const contractState = await fetchContractState(rpc, contractPublicKey);
|
|
171
|
+
console.log('Contract rate:', contractState.rate.toString());
|
|
172
|
+
console.log('Duration range:', contractState.durationMin.toString(), '-', contractState.durationMax.toString());
|
|
173
|
+
|
|
174
|
+
// Fetch rental state
|
|
175
|
+
const rentalState = await fetchRentalState(rpc, rentalPublicKey);
|
|
176
|
+
console.log('Rental status:', rentalState.status);
|
|
177
|
+
console.log('Start time:', new Date(rentalState.startTime.toNumber() * 1000));
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Token Conversion
|
|
181
|
+
|
|
182
|
+
The SDK includes automatic ATLAS to stardust conversion for rental operations:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import { ATLAS_TO_STARDUST } from '@wuwei-labs/srsly';
|
|
186
|
+
|
|
187
|
+
// ATLAS_TO_STARDUST = 100_000_000 (1 ATLAS = 100 million stardust)
|
|
188
|
+
console.log('Conversion rate:', ATLAS_TO_STARDUST);
|
|
189
|
+
|
|
190
|
+
// When using acceptRental with rate and duration:
|
|
191
|
+
// Final amount = rate * duration * ATLAS_TO_STARDUST
|
|
192
|
+
// Example: 100 ATLAS * 86400 seconds * 100_000_000 = 864,000,000,000,000 stardust
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Program Information
|
|
196
|
+
|
|
197
|
+
- **Program ID**: `SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT`
|
|
198
|
+
- **Network**: Solana Mainnet or Atlasnet
|
|
199
|
+
- **Built with**: Anchor Framework
|
|
200
|
+
|
|
201
|
+
## Payment Structure
|
|
202
|
+
|
|
203
|
+
The SRSLY program implements a comprehensive payment system with escrow deposits, periodic payments, fees, and refunds. Understanding this structure is crucial for integrating rental functionality.
|
|
204
|
+
|
|
205
|
+
### Overview
|
|
206
|
+
|
|
207
|
+
```text
|
|
208
|
+
Rental Lifecycle:
|
|
209
|
+
1. Escrow Deposit (Full Payment Upfront)
|
|
210
|
+
2. Periodic Payments (Based on Payment Frequency)
|
|
211
|
+
3. Fee Collection (Platform + Referral Fees)
|
|
212
|
+
4. Owner Payments (After Fee Deduction)
|
|
213
|
+
5. Refunds (For Early Cancellation)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 1. Escrow Deposit
|
|
217
|
+
|
|
218
|
+
When a borrower accepts a rental, they deposit the **full rental amount upfront** into an escrow account:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
// Example: 1000 ATLAS for 10 days = 10,000 ATLAS total
|
|
222
|
+
const acceptIx = await acceptRental({
|
|
223
|
+
borrower: wallet,
|
|
224
|
+
borrowerProfile: profileAddress,
|
|
225
|
+
borrowerFaction: 'mud',
|
|
226
|
+
fleet: fleetAddress,
|
|
227
|
+
contract: contractAddress,
|
|
228
|
+
rate: 1000, // ATLAS tokens per day
|
|
229
|
+
duration: 864000, // 10 days in seconds
|
|
230
|
+
referralTokenAccount: referrerAddress // Optional referral
|
|
231
|
+
});
|
|
232
|
+
// Total escrowed: 1000 * 10 * 100,000,000 = 1,000,000,000,000 stardust
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Key Points:**
|
|
236
|
+
|
|
237
|
+
- Full payment calculated as: `rate × duration × ATLAS_TO_STARDUST`
|
|
238
|
+
- Funds are held in a rental-specific escrow account
|
|
239
|
+
- Escrow is controlled by the rental state PDA
|
|
240
|
+
- No payments to owner until periodic execution
|
|
241
|
+
- **Minimum enforcement**: 24 hours from start time (if no payments) or last payment time
|
|
242
|
+
|
|
243
|
+
### 2. Periodic Payments
|
|
244
|
+
|
|
245
|
+
The system creates an automated thread that executes payments based on the contract's payment frequency:
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
// Contract with daily payments
|
|
249
|
+
const contractIx = await createContract({
|
|
250
|
+
owner: wallet,
|
|
251
|
+
fleet: fleetAddress,
|
|
252
|
+
ownerProfile: profileAddress,
|
|
253
|
+
rate: 1000,
|
|
254
|
+
durationMin: 86400, // 1 day minimum
|
|
255
|
+
durationMax: 2592000, // 30 days maximum
|
|
256
|
+
paymentsFreq: 'daily' // Payments every 24 hours
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Payment Schedule:**
|
|
261
|
+
|
|
262
|
+
- **Daily**: Payments execute daily at 00:00 UTC (not every 24 hours from creation)
|
|
263
|
+
- **Weekly**: Payments execute weekly at specific day/time
|
|
264
|
+
- **Monthly**: Payments execute monthly at specific day/time
|
|
265
|
+
|
|
266
|
+
**Pro-rata Calculation:**
|
|
267
|
+
|
|
268
|
+
Each payment is calculated based on elapsed time since the last payment:
|
|
269
|
+
|
|
270
|
+
```text
|
|
271
|
+
payment_amount = (elapsed_time / frequency_seconds) × rate × ATLAS_TO_STARDUST
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### 3. Fee Structure
|
|
275
|
+
|
|
276
|
+
Each payment is subject to a **10% platform fee** with optional **10% referral sharing**:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
// Constants from the program
|
|
280
|
+
const SERVICE_FEE_BPS = 1000; // 10% platform fee
|
|
281
|
+
const REFERRAL_BPS = 1000; // 10% of total fee to referral
|
|
282
|
+
const BASE_BPS = 10000; // 100% in basis points
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Fee Calculation:**
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
// For each payment amount
|
|
289
|
+
const totalFee = paymentAmount * SERVICE_FEE_BPS / BASE_BPS; // 10% of payment
|
|
290
|
+
const referralFee = totalFee * REFERRAL_BPS / BASE_BPS; // 10% of total fee
|
|
291
|
+
const platformFee = totalFee - referralFee; // 90% of total fee
|
|
292
|
+
const ownerPayment = paymentAmount - totalFee; // 90% of payment
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Example Payment Breakdown:**
|
|
296
|
+
|
|
297
|
+
```text
|
|
298
|
+
Payment Amount: 1000 ATLAS
|
|
299
|
+
├── Total Fee (10%): 100 ATLAS
|
|
300
|
+
│ ├── Referral Fee (10% of total fee): 10 ATLAS → Referrer
|
|
301
|
+
│ └── Platform Fee (90% of total fee): 90 ATLAS → Platform
|
|
302
|
+
└── Owner Payment (90%): 900 ATLAS → Fleet Owner
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### 4. Payment Distribution
|
|
306
|
+
|
|
307
|
+
Each periodic payment is distributed in this order:
|
|
308
|
+
|
|
309
|
+
1. **Referral Payment** (if referrer exists and ≠ system_program::ID)
|
|
310
|
+
- Amount: `total_fee × REFERRAL_BPS ÷ BASE_BPS`
|
|
311
|
+
- Destination: Referrer's token account
|
|
312
|
+
|
|
313
|
+
2. **Platform Fee Payment**
|
|
314
|
+
- Amount: `total_fee - referral_payment`
|
|
315
|
+
- Destination: Platform fee account
|
|
316
|
+
|
|
317
|
+
3. **Owner Payment**
|
|
318
|
+
- Amount: `payment_amount - total_fee`
|
|
319
|
+
- Destination: Fleet owner's token account
|
|
320
|
+
|
|
321
|
+
**Code Example:**
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
// Accept rental with referral
|
|
325
|
+
const acceptIx = await acceptRental({
|
|
326
|
+
borrower: wallet,
|
|
327
|
+
borrowerProfile: profileAddress,
|
|
328
|
+
borrowerFaction: 'mud',
|
|
329
|
+
fleet: fleetAddress,
|
|
330
|
+
contract: contractAddress,
|
|
331
|
+
rate: 1000,
|
|
332
|
+
duration: 86400,
|
|
333
|
+
referralTokenAccount: referrerTokenAccount // 10% of fees
|
|
334
|
+
});
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### 5. Refund Mechanism
|
|
338
|
+
|
|
339
|
+
Refunds occur when rentals are cancelled early or when contracts are closed. **Important: All rentals enforce a minimum 24-hour active period from either the start time (if no payments made) or the last payment time.**
|
|
340
|
+
|
|
341
|
+
**Early Cancellation:**
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
const cancelIx = await cancelRental({
|
|
345
|
+
borrower: wallet,
|
|
346
|
+
contract: contractAddress,
|
|
347
|
+
rentalState: rentalStateAddress
|
|
348
|
+
});
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Refund Scenarios:**
|
|
352
|
+
|
|
353
|
+
- **Before First Payment**: Rental remains active for 24 hours from start time, pro-rata refund for remaining time
|
|
354
|
+
- **After Payment(s) Made**: Rental remains active for 24 hours from last payment time, pro-rata refund for remaining time
|
|
355
|
+
- **Contract Closure**: Any remaining escrow returned to borrower
|
|
356
|
+
|
|
357
|
+
### 6. Payment Timeline Example
|
|
358
|
+
|
|
359
|
+
**Scenario**: 10-day rental with daily payments, 1000 ATLAS/day rate
|
|
360
|
+
|
|
361
|
+
```text
|
|
362
|
+
Day 0: Rental Accepted
|
|
363
|
+
├── Escrow: 10,000 ATLAS deposited
|
|
364
|
+
├── Thread: Created for daily execution at 00:00 UTC
|
|
365
|
+
├── Fleet: Transferred to borrower
|
|
366
|
+
└── Minimum 24-hour commitment begins (from start time)
|
|
367
|
+
|
|
368
|
+
00:00 UTC Next Day: First Payment
|
|
369
|
+
├── Amount: 1,000 ATLAS from escrow
|
|
370
|
+
├── Total Fee (10%): 100 ATLAS
|
|
371
|
+
│ ├── Referrer: 10 ATLAS (10% of total fee)
|
|
372
|
+
│ └── Platform: 90 ATLAS (90% of total fee)
|
|
373
|
+
├── Owner: 900 ATLAS (90% of payment)
|
|
374
|
+
├── Escrow: 9,000 ATLAS remaining
|
|
375
|
+
└── New 24-hour minimum period begins (from payment time)
|
|
376
|
+
|
|
377
|
+
Daily at 00:00 UTC: Subsequent Payments
|
|
378
|
+
├── Same distribution pattern
|
|
379
|
+
├── Escrow decreases by 1,000 ATLAS each day
|
|
380
|
+
└── Each payment resets 24-hour minimum period
|
|
381
|
+
|
|
382
|
+
Final Day at 00:00 UTC: Final Payment & Cleanup
|
|
383
|
+
├── Final payment processed
|
|
384
|
+
├── Thread: Automatically closed
|
|
385
|
+
├── Rental State: Closed, lamports to borrower
|
|
386
|
+
└── Fleet: Returned to owner or contract
|
|
387
|
+
|
|
388
|
+
Early Cancellation Examples:
|
|
389
|
+
|
|
390
|
+
Scenario A - Cancel before first payment (Day 0 at 6 PM):
|
|
391
|
+
├── Cancelled 6 hours after start
|
|
392
|
+
├── Rental extends until 24 hours from start time (Day 1 at start time)
|
|
393
|
+
├── Pro-rata refund calculated from Day 1 extended end onwards
|
|
394
|
+
└── Borrower receives refund for Days 1-10
|
|
395
|
+
|
|
396
|
+
Scenario B - Cancel after payments made (Day 3 at 6 PM):
|
|
397
|
+
├── Cancelled 18 hours after Day 3 payment (00:00 UTC)
|
|
398
|
+
├── Rental extends until 24 hours from last payment (Day 4 at 00:00 UTC)
|
|
399
|
+
├── Pro-rata refund calculated from Day 4 onwards
|
|
400
|
+
└── Borrower receives refund for Days 4-10
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### 7. Edge Cases
|
|
404
|
+
|
|
405
|
+
**Insufficient Escrow Balance:**
|
|
406
|
+
|
|
407
|
+
- Payment amount is limited to available escrow balance
|
|
408
|
+
- Remaining balance distributed proportionally
|
|
409
|
+
|
|
410
|
+
**Early Termination:**
|
|
411
|
+
|
|
412
|
+
- **Cancellation Notice**: Must have more than one payment period remaining to cancel
|
|
413
|
+
- **Minimum Period Enforcement**:
|
|
414
|
+
- Before first payment: Active for 24 hours from start time
|
|
415
|
+
- After payment(s): Active for 24 hours from last payment time
|
|
416
|
+
- **Pro-rata Refund**: Refund calculated from the enforced minimum end time
|
|
417
|
+
- Fleet returned to owner when minimum period expires
|
|
418
|
+
- Payment thread continues until minimum period ends
|
|
419
|
+
|
|
420
|
+
**Contract Closure:**
|
|
421
|
+
|
|
422
|
+
- Final payment processed if rental active
|
|
423
|
+
- All remaining resources cleaned up
|
|
424
|
+
- Fleet rental capability removed
|
|
425
|
+
|
|
426
|
+
## Payment Frequencies
|
|
427
|
+
|
|
428
|
+
The SDK supports multiple payment frequencies:
|
|
429
|
+
|
|
430
|
+
- `daily` - Daily payments at 00:00 UTC
|
|
431
|
+
- `weekly` - Weekly payments at specific day/time
|
|
432
|
+
- `monthly` - Monthly payments at specific day/time
|
|
433
|
+
|
|
434
|
+
## Error Handling
|
|
435
|
+
|
|
436
|
+
The SDK includes comprehensive error types:
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
import { SrslyError } from '@wuwei-labs/srsly';
|
|
440
|
+
|
|
441
|
+
try {
|
|
442
|
+
const instruction = await createContract({...});
|
|
443
|
+
} catch (error) {
|
|
444
|
+
if (error instanceof SrslyError) {
|
|
445
|
+
console.error('SRSLY Error:', error.message);
|
|
446
|
+
console.error('Error code:', error.code);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
## Network Configuration
|
|
452
|
+
|
|
453
|
+
The SDK supports both Solana mainnet and devnet with network-specific program configurations. You can set global configuration for convenience or override per instruction for flexibility.
|
|
454
|
+
|
|
455
|
+
### Global Configuration (Recommended)
|
|
456
|
+
|
|
457
|
+
Set default configuration once for all SDK operations:
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import { setConfig, setNetwork, getConfig, createContract } from '@wuwei-labs/srsly';
|
|
461
|
+
|
|
462
|
+
// Option 1: Full configuration
|
|
463
|
+
setConfig({
|
|
464
|
+
network: 'mainnet',
|
|
465
|
+
gameId: 'custom-game-id...'
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Option 2: Network-only (convenience function)
|
|
469
|
+
setNetwork('mainnet');
|
|
470
|
+
|
|
471
|
+
// Check current configuration
|
|
472
|
+
console.log(getConfig()); // { network: 'mainnet' }
|
|
473
|
+
|
|
474
|
+
// All operations now use mainnet by default
|
|
475
|
+
const ix1 = await createContract(params);
|
|
476
|
+
const ix2 = await acceptRental(params);
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Per-Instruction Configuration
|
|
480
|
+
|
|
481
|
+
Override global configuration for specific instructions using the fluent `.set()` interface:
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
import { createContract, acceptRental } from '@wuwei-labs/srsly';
|
|
485
|
+
|
|
486
|
+
// Assume global config is set to mainnet
|
|
487
|
+
setConfig({ network: 'mainnet' });
|
|
488
|
+
|
|
489
|
+
// Use global mainnet config
|
|
490
|
+
const mainnetIx = await createContract(params);
|
|
491
|
+
|
|
492
|
+
// Override to use devnet for this specific instruction
|
|
493
|
+
const devnetIx = await createContract(params).set({ network: 'devnet' });
|
|
494
|
+
|
|
495
|
+
// Override specific constants while keeping global network
|
|
496
|
+
const customIx = await createContract(params).set({
|
|
497
|
+
sageProgramAddress: 'custom...',
|
|
498
|
+
gameId: 'custom...'
|
|
499
|
+
// network: 'mainnet' inherited from global config
|
|
500
|
+
});
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
### Configuration Options
|
|
504
|
+
|
|
505
|
+
All SDK functions support these usage patterns:
|
|
506
|
+
|
|
507
|
+
**Direct await (uses global config or devnet fallback):**
|
|
508
|
+
|
|
509
|
+
```typescript
|
|
510
|
+
// Uses global configuration if set, otherwise devnet
|
|
511
|
+
await createContract(params);
|
|
512
|
+
await acceptRental(params);
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Global configuration functions:**
|
|
516
|
+
|
|
517
|
+
- `setConfig({ network: 'mainnet', gameId: '...' })` - Set full global config
|
|
518
|
+
- `setNetwork('mainnet')` - Set global network only (convenience)
|
|
519
|
+
- `getConfig()` - Get current global configuration
|
|
520
|
+
- `clearConfig()` - Reset to devnet defaults
|
|
521
|
+
|
|
522
|
+
**Per-instruction overrides with `.set()` method:**
|
|
523
|
+
|
|
524
|
+
- `.set({ network: 'mainnet' })` - Override global network
|
|
525
|
+
- `.set({ sageProgramAddress: '...' })` - Override specific constants only
|
|
526
|
+
- `.set({ network: 'mainnet', sageProgramAddress: '...' })` - Multiple overrides
|
|
527
|
+
|
|
528
|
+
**Chainable configurations:**
|
|
529
|
+
|
|
530
|
+
```typescript
|
|
531
|
+
// Chain multiple configurations (later ones override earlier ones)
|
|
532
|
+
await createContract(params)
|
|
533
|
+
.set({ network: 'devnet' })
|
|
534
|
+
.set({ sageProgramAddress: 'override...' });
|
|
535
|
+
|
|
536
|
+
// Examples with global config
|
|
537
|
+
setConfig({ network: 'mainnet' });
|
|
538
|
+
await createContract(params); // Uses mainnet
|
|
539
|
+
await acceptRental(params).set({ network: 'devnet' }); // Override to devnet
|
|
540
|
+
await closeContract(params).set({ gameId: 'custom...' }); // Custom gameId, mainnet network
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### Available Configuration Options
|
|
544
|
+
|
|
545
|
+
```typescript
|
|
546
|
+
interface ConfigOptions {
|
|
547
|
+
network?: 'mainnet' | 'devnet'; // Set/override network
|
|
548
|
+
sageProgramAddress?: string; // Set/override SAGE program address
|
|
549
|
+
profileFactionProgramAddress?: string; // Set/override Profile Faction program address
|
|
550
|
+
gameId?: string; // Set/override SAGE game ID
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### Network-Specific Constants
|
|
555
|
+
|
|
556
|
+
The SDK automatically resolves network-specific constants:
|
|
557
|
+
|
|
558
|
+
```typescript
|
|
559
|
+
import {
|
|
560
|
+
getSageProgramAddress,
|
|
561
|
+
getProfileFactionProgramAddress,
|
|
562
|
+
getSageGameId
|
|
563
|
+
} from '@wuwei-labs/srsly';
|
|
564
|
+
|
|
565
|
+
// Get constants for devnet (default)
|
|
566
|
+
const sageProgram = await getSageProgramAddress();
|
|
567
|
+
const gameId = await getSageGameId();
|
|
568
|
+
|
|
569
|
+
// Get constants for specific network
|
|
570
|
+
const mainnetSageProgram = await getSageProgramAddress({ network: 'mainnet' });
|
|
571
|
+
const mainnetGameId = await getSageGameId({ network: 'mainnet' });
|
|
11
572
|
```
|
|
12
573
|
|
|
13
|
-
##
|
|
574
|
+
## IDL and Types
|
|
575
|
+
|
|
576
|
+
### Network-Specific IDLs
|
|
577
|
+
|
|
578
|
+
The SDK provides network-specific IDLs since program configurations differ between networks:
|
|
579
|
+
|
|
580
|
+
```typescript
|
|
581
|
+
// Mainnet IDL
|
|
582
|
+
import mainnetIdl from '@wuwei-labs/srsly/idl/mainnet';
|
|
14
583
|
|
|
15
|
-
|
|
584
|
+
// Devnet IDL
|
|
585
|
+
import devnetIdl from '@wuwei-labs/srsly/idl/devnet';
|
|
16
586
|
|
|
17
|
-
|
|
18
|
-
import {
|
|
587
|
+
// Use with Anchor
|
|
588
|
+
import { Program } from '@coral-xyz/anchor';
|
|
589
|
+
const program = new Program(mainnetIdl, provider);
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Network-Specific Types
|
|
19
593
|
|
|
20
|
-
|
|
21
|
-
const message = "TS SDK";
|
|
22
|
-
const greetMsg = greetHello(message);
|
|
594
|
+
Import TypeScript types that match your target network:
|
|
23
595
|
|
|
24
|
-
|
|
596
|
+
```typescript
|
|
597
|
+
import type {
|
|
598
|
+
ContractState,
|
|
599
|
+
RentalState,
|
|
600
|
+
PaymentFrequency,
|
|
601
|
+
ClockData,
|
|
602
|
+
ThreadResponse,
|
|
603
|
+
ConfigOptions
|
|
604
|
+
} from '@wuwei-labs/srsly';
|
|
25
605
|
|
|
26
|
-
//
|
|
606
|
+
// Import network-specific Anchor types
|
|
607
|
+
import type { Srsly as SrslyMainnet } from '@wuwei-labs/srsly/types/mainnet';
|
|
608
|
+
import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/devnet';
|
|
27
609
|
```
|
|
28
610
|
|
|
29
|
-
|
|
611
|
+
## Constants and Utilities
|
|
612
|
+
|
|
613
|
+
### Available Constants
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
import {
|
|
617
|
+
ATLAS_TO_STARDUST,
|
|
618
|
+
STARBASE_SEED,
|
|
619
|
+
STARBASE_PLAYER_SEED,
|
|
620
|
+
SAGE_PLAYER_PROFILE_SEED,
|
|
621
|
+
PROFILE_FACTION_SEED,
|
|
622
|
+
FACTION_MAPPING,
|
|
623
|
+
FACTION_SPECIFIC_CSS
|
|
624
|
+
} from '@wuwei-labs/srsly';
|
|
625
|
+
|
|
626
|
+
// Token conversion
|
|
627
|
+
console.log(ATLAS_TO_STARDUST); // 100_000_000
|
|
628
|
+
|
|
629
|
+
// Faction mappings
|
|
630
|
+
console.log(FACTION_MAPPING[1]); // 'mud'
|
|
631
|
+
console.log(FACTION_MAPPING[2]); // 'oni'
|
|
632
|
+
console.log(FACTION_MAPPING[3]); // 'ustur'
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
### Profile Derivation
|
|
636
|
+
|
|
637
|
+
```typescript
|
|
638
|
+
import {
|
|
639
|
+
deriveProfileFaction,
|
|
640
|
+
deriveSagePlayerProfile,
|
|
641
|
+
deriveStarbase,
|
|
642
|
+
deriveStarbasePlayer,
|
|
643
|
+
deriveGameAccounts
|
|
644
|
+
} from '@wuwei-labs/srsly';
|
|
645
|
+
|
|
646
|
+
// Derive individual accounts with network configuration
|
|
647
|
+
const profileFaction = await deriveProfileFaction(profile, { network: 'mainnet' });
|
|
648
|
+
const starbase = await deriveStarbase('mud', gameId, { network: 'mainnet' });
|
|
649
|
+
|
|
650
|
+
// Derive all game accounts at once
|
|
651
|
+
const gameAccounts = await deriveGameAccounts(
|
|
652
|
+
profile,
|
|
653
|
+
'mud',
|
|
654
|
+
gameId,
|
|
655
|
+
0, // starbaseSeqId
|
|
656
|
+
{ network: 'mainnet' }
|
|
657
|
+
);
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
## Webpack Compatibility
|
|
661
|
+
|
|
662
|
+
The SRSLY SDK is fully compatible with webpack bundlers. The package includes both CommonJS and ESM builds:
|
|
663
|
+
|
|
664
|
+
- **CommonJS**: `./dist/cjs/index.cjs` (default for Node.js and webpack)
|
|
665
|
+
- **ESM**: `./dist/esm/index.js` (for modern ES modules)
|
|
666
|
+
- **Types**: `./dist/types/index.d.ts` (TypeScript definitions)
|
|
667
|
+
|
|
668
|
+
### Webpack Configuration
|
|
669
|
+
|
|
670
|
+
For optimal webpack compatibility, the SDK includes:
|
|
671
|
+
|
|
672
|
+
- `sideEffects: false` for better tree-shaking
|
|
673
|
+
- Proper CommonJS exports with `.cjs` extensions for webpack bundling
|
|
674
|
+
- ES module interoperability
|
|
675
|
+
- Correct module resolution for mixed ESM/CommonJS environments
|
|
676
|
+
|
|
677
|
+
No special webpack configuration is required. The SDK will work out-of-the-box with most webpack setups.
|
|
678
|
+
|
|
679
|
+
**Note**: As of version 2.0.0-beta.9, the CommonJS build uses `.cjs` file extensions to ensure proper module resolution in environments where the package.json contains `"type": "module"`.
|
|
680
|
+
|
|
681
|
+
### Testing Webpack Compatibility
|
|
682
|
+
|
|
683
|
+
```bash
|
|
684
|
+
# Test local CommonJS exports (fast)
|
|
685
|
+
npm run test:webpack
|
|
686
|
+
|
|
687
|
+
# Test actual npm package installation (comprehensive)
|
|
688
|
+
npm run test:npm-install
|
|
689
|
+
|
|
690
|
+
# Test actual pnpm package installation with webpack bundling
|
|
691
|
+
npm run test:pnpm-install
|
|
692
|
+
|
|
693
|
+
# Test both package managers
|
|
694
|
+
npm run test:package-managers
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
These commands test different aspects:
|
|
698
|
+
- `test:webpack`: Tests local CommonJS exports that webpack uses
|
|
699
|
+
- `test:npm-install`: Installs the actual published package via npm and tests functionality
|
|
700
|
+
- `test:pnpm-install`: Installs via pnpm and includes a real webpack bundling test
|
|
701
|
+
- `test:package-managers`: Runs both npm and pnpm tests
|
|
702
|
+
|
|
703
|
+
## Documentation
|
|
704
|
+
|
|
705
|
+
- **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
|
|
30
706
|
|
|
31
|
-
##
|
|
707
|
+
## Related Projects
|
|
32
708
|
|
|
33
|
-
|
|
709
|
+
- **Star Atlas**: The metaverse gaming ecosystem
|
|
710
|
+
- **Solana**: The blockchain platform powering SRSLY
|
|
711
|
+
- **Anchor**: The framework used to build the SRSLY program
|