@wuwei-labs/srsly 2.0.0-beta.14 → 2.0.0-beta.16
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 +117 -712
- package/dist/cjs/codama/accounts/config.js +88 -0
- package/dist/cjs/codama/accounts/config.js.map +1 -0
- package/dist/cjs/codama/accounts/contractState.js.map +1 -0
- package/dist/cjs/codama/accounts/fleet.js.map +1 -0
- package/dist/cjs/codama/{atlasnet/accounts → accounts}/index.js +1 -0
- package/dist/cjs/codama/accounts/index.js.map +1 -0
- package/dist/cjs/codama/accounts/rentalState.js.map +1 -0
- package/dist/cjs/codama/accounts/thread.js.map +1 -0
- package/dist/cjs/codama/errors/index.js.map +1 -0
- package/dist/cjs/codama/{mainnet/errors → errors}/srsly.js +15 -3
- package/dist/cjs/codama/errors/srsly.js.map +1 -0
- package/dist/cjs/codama/index.js.map +1 -0
- package/dist/cjs/codama/{atlasnet/instructions → instructions}/acceptRental.js +14 -9
- package/dist/cjs/codama/instructions/acceptRental.js.map +1 -0
- package/dist/cjs/codama/{mainnet/instructions → instructions}/cancelRental.js +10 -33
- package/dist/cjs/codama/instructions/cancelRental.js.map +1 -0
- package/dist/cjs/codama/{mainnet/instructions → instructions}/closeContract.js +10 -37
- package/dist/cjs/codama/instructions/closeContract.js.map +1 -0
- package/dist/cjs/codama/{mainnet/instructions → instructions}/closeRental.js +14 -41
- package/dist/cjs/codama/instructions/closeRental.js.map +1 -0
- package/dist/cjs/codama/{atlasnet/instructions → instructions}/createContract.js +14 -9
- package/dist/cjs/codama/instructions/createContract.js.map +1 -0
- package/dist/cjs/codama/{mainnet/instructions → instructions}/index.js +2 -0
- package/dist/cjs/codama/instructions/index.js.map +1 -0
- package/dist/cjs/codama/instructions/initializeConfig.js +131 -0
- package/dist/cjs/codama/instructions/initializeConfig.js.map +1 -0
- package/dist/cjs/codama/{mainnet/instructions → instructions}/payRental.js +10 -37
- package/dist/cjs/codama/instructions/payRental.js.map +1 -0
- package/dist/cjs/codama/instructions/resetRental.js.map +1 -0
- package/dist/cjs/codama/instructions/updateConfig.js +145 -0
- package/dist/cjs/codama/instructions/updateConfig.js.map +1 -0
- package/dist/cjs/codama/programs/index.js.map +1 -0
- package/dist/cjs/codama/{atlasnet/programs → programs}/srsly.js +18 -6
- package/dist/cjs/codama/programs/srsly.js.map +1 -0
- package/dist/cjs/codama/shared/index.js.map +1 -0
- package/dist/cjs/codama/types/clockData.js.map +1 -0
- package/dist/cjs/codama/types/equality.js.map +1 -0
- package/dist/cjs/codama/types/execContext.js.map +1 -0
- package/dist/cjs/codama/{atlasnet/types → types}/index.js +1 -0
- package/dist/cjs/codama/types/index.js.map +1 -0
- package/dist/cjs/codama/types/paymentFrequency.js +34 -0
- package/dist/cjs/codama/types/paymentFrequency.js.map +1 -0
- package/dist/cjs/codama/types/serializableAccount.js.map +1 -0
- package/dist/cjs/codama/types/serializableInstruction.js.map +1 -0
- package/dist/cjs/codama/types/threadResponse.js.map +1 -0
- package/dist/cjs/codama/types/trigger.js.map +1 -0
- package/dist/cjs/codama/types/triggerContext.js.map +1 -0
- package/dist/cjs/contract/close.js +3 -3
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +4 -4
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/package.json +5 -9
- package/dist/cjs/rental/accept.js +3 -3
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +3 -3
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +3 -3
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +3 -3
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +27 -49
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/constants.js +1 -0
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/esm/codama/accounts/config.js +76 -0
- package/dist/esm/codama/accounts/config.js.map +1 -0
- package/dist/esm/codama/accounts/contractState.js.map +1 -0
- package/dist/esm/codama/accounts/fleet.js.map +1 -0
- package/dist/esm/codama/{atlasnet/accounts → accounts}/index.js +1 -0
- package/dist/esm/codama/accounts/index.js.map +1 -0
- package/dist/esm/codama/accounts/rentalState.js.map +1 -0
- package/dist/esm/codama/accounts/thread.js.map +1 -0
- package/dist/esm/codama/errors/index.js.map +1 -0
- package/dist/esm/codama/{atlasnet/errors → errors}/srsly.js +14 -2
- package/dist/esm/codama/errors/srsly.js.map +1 -0
- package/dist/esm/codama/index.js.map +1 -0
- package/dist/esm/codama/{atlasnet/instructions → instructions}/acceptRental.js +14 -9
- package/dist/esm/codama/instructions/acceptRental.js.map +1 -0
- package/dist/esm/codama/{mainnet/instructions → instructions}/cancelRental.js +10 -33
- package/dist/esm/codama/instructions/cancelRental.js.map +1 -0
- package/dist/esm/codama/{mainnet/instructions → instructions}/closeContract.js +12 -39
- package/dist/esm/codama/instructions/closeContract.js.map +1 -0
- package/dist/esm/codama/{mainnet/instructions → instructions}/closeRental.js +14 -41
- package/dist/esm/codama/instructions/closeRental.js.map +1 -0
- package/dist/esm/codama/{mainnet/instructions → instructions}/createContract.js +14 -9
- package/dist/esm/codama/instructions/createContract.js.map +1 -0
- package/dist/esm/codama/{mainnet/instructions → instructions}/index.js +2 -0
- package/dist/esm/codama/instructions/index.js.map +1 -0
- package/dist/esm/codama/instructions/initializeConfig.js +121 -0
- package/dist/esm/codama/instructions/initializeConfig.js.map +1 -0
- package/dist/esm/codama/{mainnet/instructions → instructions}/payRental.js +12 -39
- package/dist/esm/codama/instructions/payRental.js.map +1 -0
- package/dist/esm/codama/instructions/resetRental.js.map +1 -0
- package/dist/esm/codama/instructions/updateConfig.js +135 -0
- package/dist/esm/codama/instructions/updateConfig.js.map +1 -0
- package/dist/esm/codama/programs/index.js.map +1 -0
- package/dist/esm/codama/{atlasnet/programs → programs}/srsly.js +18 -6
- package/dist/esm/codama/programs/srsly.js.map +1 -0
- package/dist/esm/codama/shared/index.js.map +1 -0
- package/dist/esm/codama/types/clockData.js.map +1 -0
- package/dist/esm/codama/types/equality.js.map +1 -0
- package/dist/esm/codama/types/execContext.js.map +1 -0
- package/dist/esm/codama/{atlasnet/types → types}/index.js +1 -0
- package/dist/esm/codama/types/index.js.map +1 -0
- package/dist/esm/codama/types/paymentFrequency.js +28 -0
- package/dist/esm/codama/types/paymentFrequency.js.map +1 -0
- package/dist/esm/codama/types/serializableAccount.js.map +1 -0
- package/dist/esm/codama/types/serializableInstruction.js.map +1 -0
- package/dist/esm/codama/types/threadResponse.js.map +1 -0
- package/dist/esm/codama/types/trigger.js.map +1 -0
- package/dist/esm/codama/types/triggerContext.js.map +1 -0
- package/dist/esm/contract/close.js +4 -4
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +5 -5
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/package.json +5 -9
- package/dist/esm/rental/accept.js +4 -4
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +4 -4
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +4 -4
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +4 -4
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/config.js +26 -48
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/constants.js +1 -0
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/types/codama/accounts/config.d.ts +52 -0
- package/dist/types/codama/accounts/config.d.ts.map +1 -0
- package/dist/types/codama/accounts/contractState.d.ts.map +1 -0
- package/dist/types/codama/accounts/fleet.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/accounts → accounts}/index.d.ts +1 -0
- package/dist/types/codama/accounts/index.d.ts.map +1 -0
- package/dist/types/codama/accounts/rentalState.d.ts.map +1 -0
- package/dist/types/codama/accounts/thread.d.ts.map +1 -0
- package/dist/types/codama/errors/index.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/errors → errors}/srsly.d.ts +10 -2
- package/dist/types/codama/errors/srsly.d.ts.map +1 -0
- package/dist/types/codama/index.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/instructions → instructions}/acceptRental.d.ts +18 -14
- package/dist/types/codama/instructions/acceptRental.d.ts.map +1 -0
- package/dist/types/codama/{mainnet/instructions → instructions}/cancelRental.d.ts +14 -10
- package/dist/types/codama/instructions/cancelRental.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/instructions → instructions}/closeContract.d.ts +14 -10
- package/dist/types/codama/instructions/closeContract.d.ts.map +1 -0
- package/dist/types/codama/{mainnet/instructions → instructions}/closeRental.d.ts +16 -12
- package/dist/types/codama/instructions/closeRental.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/instructions → instructions}/createContract.d.ts +17 -13
- package/dist/types/codama/instructions/createContract.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/instructions → instructions}/index.d.ts +2 -0
- package/dist/types/codama/instructions/index.d.ts.map +1 -0
- package/dist/types/codama/instructions/initializeConfig.d.ts +60 -0
- package/dist/types/codama/instructions/initializeConfig.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/instructions → instructions}/payRental.d.ts +16 -12
- package/dist/types/codama/instructions/payRental.d.ts.map +1 -0
- package/dist/types/codama/instructions/resetRental.d.ts.map +1 -0
- package/dist/types/codama/instructions/updateConfig.d.ts +93 -0
- package/dist/types/codama/instructions/updateConfig.d.ts.map +1 -0
- package/dist/types/codama/programs/index.d.ts.map +1 -0
- package/dist/types/codama/{mainnet/programs → programs}/srsly.d.ts +15 -8
- package/dist/types/codama/programs/srsly.d.ts.map +1 -0
- package/dist/types/codama/shared/index.d.ts.map +1 -0
- package/dist/types/codama/types/clockData.d.ts.map +1 -0
- package/dist/types/codama/types/equality.d.ts.map +1 -0
- package/dist/types/codama/types/execContext.d.ts.map +1 -0
- package/dist/types/codama/{atlasnet/types → types}/index.d.ts +1 -0
- package/dist/types/codama/types/index.d.ts.map +1 -0
- package/dist/types/codama/types/paymentFrequency.d.ts +22 -0
- package/dist/types/codama/types/paymentFrequency.d.ts.map +1 -0
- package/dist/types/codama/types/serializableAccount.d.ts.map +1 -0
- package/dist/types/codama/types/serializableInstruction.d.ts.map +1 -0
- package/dist/types/codama/types/threadResponse.d.ts.map +1 -0
- package/dist/types/codama/types/trigger.d.ts.map +1 -0
- package/dist/types/codama/types/triggerContext.d.ts.map +1 -0
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +16 -31
- package/dist/types/utils/config.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/package.json +19 -13
- package/target/idl/{srsly-mainnet.json → srsly.json} +479 -428
- package/dist/cjs/codama/atlasnet/accounts/contractState.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/fleet.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/rentalState.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/thread.js.map +0 -1
- package/dist/cjs/codama/atlasnet/errors/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/errors/srsly.js +0 -74
- package/dist/cjs/codama/atlasnet/errors/srsly.js.map +0 -1
- package/dist/cjs/codama/atlasnet/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/acceptRental.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/cancelRental.js +0 -225
- package/dist/cjs/codama/atlasnet/instructions/cancelRental.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/closeContract.js +0 -238
- package/dist/cjs/codama/atlasnet/instructions/closeContract.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/closeRental.js +0 -260
- package/dist/cjs/codama/atlasnet/instructions/closeRental.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/createContract.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/index.js +0 -31
- package/dist/cjs/codama/atlasnet/instructions/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/payRental.js +0 -272
- package/dist/cjs/codama/atlasnet/instructions/payRental.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/resetRental.js.map +0 -1
- package/dist/cjs/codama/atlasnet/programs/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/programs/srsly.js.map +0 -1
- package/dist/cjs/codama/atlasnet/shared/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/clockData.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/equality.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/execContext.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/serializableAccount.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/serializableInstruction.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/threadResponse.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/trigger.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/triggerContext.js.map +0 -1
- package/dist/cjs/codama/mainnet/accounts/contractState.js +0 -87
- package/dist/cjs/codama/mainnet/accounts/contractState.js.map +0 -1
- package/dist/cjs/codama/mainnet/accounts/fleet.js +0 -77
- package/dist/cjs/codama/mainnet/accounts/fleet.js.map +0 -1
- package/dist/cjs/codama/mainnet/accounts/index.js +0 -28
- package/dist/cjs/codama/mainnet/accounts/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/accounts/rentalState.js +0 -87
- package/dist/cjs/codama/mainnet/accounts/rentalState.js.map +0 -1
- package/dist/cjs/codama/mainnet/accounts/thread.js +0 -89
- package/dist/cjs/codama/mainnet/accounts/thread.js.map +0 -1
- package/dist/cjs/codama/mainnet/errors/index.js +0 -25
- package/dist/cjs/codama/mainnet/errors/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/errors/srsly.js.map +0 -1
- package/dist/cjs/codama/mainnet/index.js +0 -29
- package/dist/cjs/codama/mainnet/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/acceptRental.js +0 -349
- package/dist/cjs/codama/mainnet/instructions/acceptRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/cancelRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/closeContract.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/closeRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/createContract.js +0 -253
- package/dist/cjs/codama/mainnet/instructions/createContract.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/payRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/resetRental.js +0 -146
- package/dist/cjs/codama/mainnet/instructions/resetRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/programs/index.js +0 -25
- package/dist/cjs/codama/mainnet/programs/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/programs/srsly.js +0 -73
- package/dist/cjs/codama/mainnet/programs/srsly.js.map +0 -1
- package/dist/cjs/codama/mainnet/shared/index.js +0 -95
- package/dist/cjs/codama/mainnet/shared/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/clockData.js +0 -31
- package/dist/cjs/codama/mainnet/types/clockData.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/equality.js +0 -30
- package/dist/cjs/codama/mainnet/types/equality.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/execContext.js +0 -38
- package/dist/cjs/codama/mainnet/types/execContext.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/index.js +0 -32
- package/dist/cjs/codama/mainnet/types/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/serializableAccount.js +0 -31
- package/dist/cjs/codama/mainnet/types/serializableAccount.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/serializableInstruction.js +0 -32
- package/dist/cjs/codama/mainnet/types/serializableInstruction.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/threadResponse.js +0 -38
- package/dist/cjs/codama/mainnet/types/threadResponse.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/trigger.js +0 -90
- package/dist/cjs/codama/mainnet/types/trigger.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/triggerContext.js +0 -49
- package/dist/cjs/codama/mainnet/types/triggerContext.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/contractState.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/fleet.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/rentalState.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/thread.js.map +0 -1
- package/dist/esm/codama/atlasnet/errors/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/errors/srsly.js.map +0 -1
- package/dist/esm/codama/atlasnet/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/acceptRental.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/cancelRental.js +0 -215
- package/dist/esm/codama/atlasnet/instructions/cancelRental.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/closeContract.js +0 -228
- package/dist/esm/codama/atlasnet/instructions/closeContract.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/closeRental.js +0 -250
- package/dist/esm/codama/atlasnet/instructions/closeRental.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/createContract.js +0 -243
- package/dist/esm/codama/atlasnet/instructions/createContract.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/index.js +0 -15
- package/dist/esm/codama/atlasnet/instructions/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/payRental.js +0 -262
- package/dist/esm/codama/atlasnet/instructions/payRental.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/resetRental.js.map +0 -1
- package/dist/esm/codama/atlasnet/programs/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/programs/srsly.js.map +0 -1
- package/dist/esm/codama/atlasnet/shared/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/clockData.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/equality.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/execContext.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/serializableAccount.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/serializableInstruction.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/threadResponse.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/trigger.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/triggerContext.js.map +0 -1
- package/dist/esm/codama/mainnet/accounts/contractState.js +0 -75
- package/dist/esm/codama/mainnet/accounts/contractState.js.map +0 -1
- package/dist/esm/codama/mainnet/accounts/fleet.js +0 -64
- package/dist/esm/codama/mainnet/accounts/fleet.js.map +0 -1
- package/dist/esm/codama/mainnet/accounts/index.js +0 -12
- package/dist/esm/codama/mainnet/accounts/index.js.map +0 -1
- package/dist/esm/codama/mainnet/accounts/rentalState.js +0 -74
- package/dist/esm/codama/mainnet/accounts/rentalState.js.map +0 -1
- package/dist/esm/codama/mainnet/accounts/thread.js +0 -77
- package/dist/esm/codama/mainnet/accounts/thread.js.map +0 -1
- package/dist/esm/codama/mainnet/errors/index.js +0 -9
- package/dist/esm/codama/mainnet/errors/index.js.map +0 -1
- package/dist/esm/codama/mainnet/errors/srsly.js +0 -69
- package/dist/esm/codama/mainnet/errors/srsly.js.map +0 -1
- package/dist/esm/codama/mainnet/index.js +0 -13
- package/dist/esm/codama/mainnet/index.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/acceptRental.js +0 -339
- package/dist/esm/codama/mainnet/instructions/acceptRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/cancelRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/closeContract.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/closeRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/createContract.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/index.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/payRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/resetRental.js +0 -136
- package/dist/esm/codama/mainnet/instructions/resetRental.js.map +0 -1
- package/dist/esm/codama/mainnet/programs/index.js +0 -9
- package/dist/esm/codama/mainnet/programs/index.js.map +0 -1
- package/dist/esm/codama/mainnet/programs/srsly.js +0 -68
- package/dist/esm/codama/mainnet/programs/srsly.js.map +0 -1
- package/dist/esm/codama/mainnet/shared/index.js +0 -87
- package/dist/esm/codama/mainnet/shared/index.js.map +0 -1
- package/dist/esm/codama/mainnet/types/clockData.js +0 -26
- package/dist/esm/codama/mainnet/types/clockData.js.map +0 -1
- package/dist/esm/codama/mainnet/types/equality.js +0 -24
- package/dist/esm/codama/mainnet/types/equality.js.map +0 -1
- package/dist/esm/codama/mainnet/types/execContext.js +0 -33
- package/dist/esm/codama/mainnet/types/execContext.js.map +0 -1
- package/dist/esm/codama/mainnet/types/index.js +0 -16
- package/dist/esm/codama/mainnet/types/index.js.map +0 -1
- package/dist/esm/codama/mainnet/types/serializableAccount.js +0 -26
- package/dist/esm/codama/mainnet/types/serializableAccount.js.map +0 -1
- package/dist/esm/codama/mainnet/types/serializableInstruction.js +0 -27
- package/dist/esm/codama/mainnet/types/serializableInstruction.js.map +0 -1
- package/dist/esm/codama/mainnet/types/threadResponse.js +0 -33
- package/dist/esm/codama/mainnet/types/threadResponse.js.map +0 -1
- package/dist/esm/codama/mainnet/types/trigger.js +0 -83
- package/dist/esm/codama/mainnet/types/trigger.js.map +0 -1
- package/dist/esm/codama/mainnet/types/triggerContext.js +0 -42
- package/dist/esm/codama/mainnet/types/triggerContext.js.map +0 -1
- package/dist/types/codama/atlasnet/accounts/contractState.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/fleet.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/rentalState.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/thread.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/errors/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/errors/srsly.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/acceptRental.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/cancelRental.d.ts +0 -71
- package/dist/types/codama/atlasnet/instructions/cancelRental.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/closeContract.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/closeRental.d.ts +0 -83
- package/dist/types/codama/atlasnet/instructions/closeRental.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/createContract.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/payRental.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/resetRental.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/programs/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/programs/srsly.d.ts +0 -47
- package/dist/types/codama/atlasnet/programs/srsly.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/shared/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/clockData.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/equality.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/execContext.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/serializableAccount.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/serializableInstruction.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/threadResponse.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/trigger.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/triggerContext.d.ts.map +0 -1
- package/dist/types/codama/mainnet/accounts/contractState.d.ts +0 -51
- package/dist/types/codama/mainnet/accounts/contractState.d.ts.map +0 -1
- package/dist/types/codama/mainnet/accounts/fleet.d.ts +0 -38
- package/dist/types/codama/mainnet/accounts/fleet.d.ts.map +0 -1
- package/dist/types/codama/mainnet/accounts/index.d.ts +0 -12
- package/dist/types/codama/mainnet/accounts/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/accounts/rentalState.d.ts +0 -48
- package/dist/types/codama/mainnet/accounts/rentalState.d.ts.map +0 -1
- package/dist/types/codama/mainnet/accounts/thread.d.ts +0 -74
- package/dist/types/codama/mainnet/accounts/thread.d.ts.map +0 -1
- package/dist/types/codama/mainnet/errors/index.d.ts +0 -9
- package/dist/types/codama/mainnet/errors/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/errors/srsly.d.ts +0 -50
- package/dist/types/codama/mainnet/errors/srsly.d.ts.map +0 -1
- package/dist/types/codama/mainnet/index.d.ts +0 -13
- package/dist/types/codama/mainnet/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/acceptRental.d.ts +0 -131
- package/dist/types/codama/mainnet/instructions/acceptRental.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/cancelRental.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/closeContract.d.ts +0 -100
- package/dist/types/codama/mainnet/instructions/closeContract.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/closeRental.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/createContract.d.ts +0 -108
- package/dist/types/codama/mainnet/instructions/createContract.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/index.d.ts +0 -15
- package/dist/types/codama/mainnet/instructions/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/payRental.d.ts +0 -110
- package/dist/types/codama/mainnet/instructions/payRental.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/resetRental.d.ts +0 -71
- package/dist/types/codama/mainnet/instructions/resetRental.d.ts.map +0 -1
- package/dist/types/codama/mainnet/programs/index.d.ts +0 -9
- package/dist/types/codama/mainnet/programs/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/programs/srsly.d.ts.map +0 -1
- package/dist/types/codama/mainnet/shared/index.d.ts +0 -50
- package/dist/types/codama/mainnet/shared/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/clockData.d.ts +0 -29
- package/dist/types/codama/mainnet/types/clockData.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/equality.d.ts +0 -18
- package/dist/types/codama/mainnet/types/equality.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/execContext.d.ts +0 -48
- package/dist/types/codama/mainnet/types/execContext.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/index.d.ts +0 -16
- package/dist/types/codama/mainnet/types/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/serializableAccount.d.ts +0 -22
- package/dist/types/codama/mainnet/types/serializableAccount.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/serializableInstruction.d.ts +0 -30
- package/dist/types/codama/mainnet/types/serializableInstruction.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/threadResponse.d.ts +0 -42
- package/dist/types/codama/mainnet/types/threadResponse.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/trigger.d.ts +0 -98
- package/dist/types/codama/mainnet/types/trigger.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/triggerContext.d.ts +0 -75
- package/dist/types/codama/mainnet/types/triggerContext.d.ts.map +0 -1
- package/target/idl/srsly-atlasnet.json +0 -3270
- package/target/types/srsly-mainnet.ts +0 -1
- /package/dist/cjs/codama/{atlasnet/accounts → accounts}/contractState.js +0 -0
- /package/dist/cjs/codama/{atlasnet/accounts → accounts}/fleet.js +0 -0
- /package/dist/cjs/codama/{atlasnet/accounts → accounts}/rentalState.js +0 -0
- /package/dist/cjs/codama/{atlasnet/accounts → accounts}/thread.js +0 -0
- /package/dist/cjs/codama/{atlasnet/errors → errors}/index.js +0 -0
- /package/dist/cjs/codama/{atlasnet/index.js → index.js} +0 -0
- /package/dist/cjs/codama/{atlasnet/instructions → instructions}/resetRental.js +0 -0
- /package/dist/cjs/codama/{atlasnet/programs → programs}/index.js +0 -0
- /package/dist/cjs/codama/{atlasnet/shared → shared}/index.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/clockData.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/equality.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/execContext.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/serializableAccount.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/serializableInstruction.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/threadResponse.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/trigger.js +0 -0
- /package/dist/cjs/codama/{atlasnet/types → types}/triggerContext.js +0 -0
- /package/dist/esm/codama/{atlasnet/accounts → accounts}/contractState.js +0 -0
- /package/dist/esm/codama/{atlasnet/accounts → accounts}/fleet.js +0 -0
- /package/dist/esm/codama/{atlasnet/accounts → accounts}/rentalState.js +0 -0
- /package/dist/esm/codama/{atlasnet/accounts → accounts}/thread.js +0 -0
- /package/dist/esm/codama/{atlasnet/errors → errors}/index.js +0 -0
- /package/dist/esm/codama/{atlasnet/index.js → index.js} +0 -0
- /package/dist/esm/codama/{atlasnet/instructions → instructions}/resetRental.js +0 -0
- /package/dist/esm/codama/{atlasnet/programs → programs}/index.js +0 -0
- /package/dist/esm/codama/{atlasnet/shared → shared}/index.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/clockData.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/equality.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/execContext.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/serializableAccount.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/serializableInstruction.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/threadResponse.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/trigger.js +0 -0
- /package/dist/esm/codama/{atlasnet/types → types}/triggerContext.js +0 -0
- /package/dist/types/codama/{atlasnet/accounts → accounts}/contractState.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/accounts → accounts}/fleet.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/accounts → accounts}/rentalState.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/accounts → accounts}/thread.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/errors → errors}/index.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/index.d.ts → index.d.ts} +0 -0
- /package/dist/types/codama/{atlasnet/instructions → instructions}/resetRental.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/programs → programs}/index.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/shared → shared}/index.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/clockData.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/equality.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/execContext.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/serializableAccount.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/serializableInstruction.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/threadResponse.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/trigger.d.ts +0 -0
- /package/dist/types/codama/{atlasnet/types → types}/triggerContext.d.ts +0 -0
- /package/target/types/{srsly-atlasnet.ts → srsly.ts} +0 -0
package/README.md
CHANGED
|
@@ -8,842 +8,247 @@ A TypeScript SDK for building Solana instructions to interact with the SRSLY (Sp
|
|
|
8
8
|
|
|
9
9
|
## What This SDK Does
|
|
10
10
|
|
|
11
|
-
The SRSLY SDK is an **instruction builder** that helps you create properly formatted Solana instructions for
|
|
11
|
+
The SRSLY SDK is an **instruction builder** that helps you create properly formatted Solana instructions for fleet rentals. It handles:
|
|
12
12
|
|
|
13
|
-
- ✅
|
|
14
|
-
- ✅ Account derivation and validation
|
|
13
|
+
- ✅ Account derivation and validation
|
|
15
14
|
- ✅ Instruction data encoding
|
|
16
15
|
- ✅ Type-safe parameter handling
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
The SDK **does not** handle transaction creation, signing, or submission. You'll need to:
|
|
21
|
-
|
|
22
|
-
- 🔧 Choose a transaction library (`@solana/web3.js` or `@solana/kit`)
|
|
23
|
-
- 🔧 Connect to a Solana RPC endpoint
|
|
24
|
-
- 🔧 Handle wallet integration (Phantom, Solflare, etc.)
|
|
25
|
-
- 🔧 Build, sign, and send transactions
|
|
17
|
+
**What you provide**: RPC connection, wallet integration, transaction handling.
|
|
26
18
|
|
|
27
19
|
## Installation
|
|
28
20
|
|
|
29
|
-
### NPM
|
|
30
|
-
|
|
31
21
|
```bash
|
|
32
22
|
npm install @wuwei-labs/srsly
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### PNPM
|
|
36
|
-
|
|
37
|
-
```bash
|
|
23
|
+
# or
|
|
38
24
|
pnpm add @wuwei-labs/srsly
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Yarn
|
|
42
|
-
|
|
43
|
-
```bash
|
|
25
|
+
# or
|
|
44
26
|
yarn add @wuwei-labs/srsly
|
|
45
27
|
```
|
|
46
28
|
|
|
47
29
|
## Quick Start
|
|
48
30
|
|
|
49
31
|
```typescript
|
|
50
|
-
import {
|
|
51
|
-
|
|
52
|
-
setConfig
|
|
53
|
-
} from '@wuwei-labs/srsly';
|
|
54
|
-
|
|
55
|
-
import {
|
|
56
|
-
createDefaultSolanaRpc,
|
|
57
|
-
createTransaction,
|
|
58
|
-
appendInstructions,
|
|
59
|
-
signAndSendTransaction,
|
|
60
|
-
pipe
|
|
61
|
-
} from '@solana/kit';
|
|
62
|
-
|
|
63
|
-
// Step 1: Set up RPC connection
|
|
64
|
-
const rpc = createDefaultSolanaRpc('https://api.atlasnet.solana.com');
|
|
65
|
-
|
|
66
|
-
// Step 2: Get wallet from browser extension (Phantom, Solflare, etc.)
|
|
67
|
-
// Assumes you've already connected to the user's wallet
|
|
68
|
-
const wallet = window.solana; // or your wallet adapter
|
|
32
|
+
import { createContract, setConfig } from '@wuwei-labs/srsly';
|
|
33
|
+
import { Connection, Transaction } from '@solana/web3.js';
|
|
69
34
|
|
|
70
|
-
//
|
|
71
|
-
setConfig({
|
|
35
|
+
// 1. Configure SDK for your network
|
|
36
|
+
setConfig({ programs: 'atlasnet' });
|
|
72
37
|
|
|
73
|
-
//
|
|
74
|
-
const
|
|
75
|
-
owner:
|
|
38
|
+
// 2. Build instruction
|
|
39
|
+
const instruction = await createContract({
|
|
40
|
+
owner: walletPublicKey,
|
|
76
41
|
fleet: fleetAddress,
|
|
77
42
|
ownerProfile: profileAddress,
|
|
78
|
-
rate: 1000000, //
|
|
79
|
-
durationMin: 86400, // 1 day
|
|
80
|
-
durationMax: 604800, // 1 week
|
|
81
|
-
paymentsFreq: 'daily'
|
|
82
|
-
ownerKeyIndex: 0
|
|
43
|
+
rate: 1000000, // ATLAS tokens
|
|
44
|
+
durationMin: 86400, // 1 day
|
|
45
|
+
durationMax: 604800, // 1 week
|
|
46
|
+
paymentsFreq: 'daily'
|
|
83
47
|
});
|
|
84
48
|
|
|
85
|
-
//
|
|
86
|
-
const transaction = pipe(
|
|
87
|
-
createTransaction({ version: 0 }),
|
|
88
|
-
tx => appendInstructions([contractInstruction], tx)
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// Sign and send using wallet extension
|
|
92
|
-
const signature = await signAndSendTransaction(rpc, transaction, wallet);
|
|
93
|
-
console.log('Transaction signature:', signature);
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Alternative with @solana/web3.js:**
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
import { Connection, Transaction } from '@solana/web3.js';
|
|
100
|
-
|
|
49
|
+
// 3. Build and send transaction
|
|
101
50
|
const connection = new Connection('https://api.atlasnet.solana.com');
|
|
102
|
-
const transaction = new Transaction().add(
|
|
103
|
-
|
|
104
|
-
// Sign and send with wallet extension
|
|
105
|
-
const signature = await window.solana.signAndSendTransaction(transaction);
|
|
51
|
+
const transaction = new Transaction().add(instruction);
|
|
52
|
+
const signature = await wallet.signAndSendTransaction(transaction);
|
|
106
53
|
```
|
|
107
54
|
|
|
108
|
-
|
|
109
|
-
> - Setting up RPC connections
|
|
110
|
-
> - Managing wallet connections (Phantom, Solflare, etc.)
|
|
111
|
-
> - Building, signing, and sending transactions
|
|
112
|
-
> - Handling transaction confirmation and errors
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## SDK Features
|
|
117
|
-
|
|
118
|
-
The following examples show how to use the SRSLY SDK to build instructions. Add these instructions to transactions using your preferred Solana library (`@solana/web3.js` or `@solana/kit`).
|
|
55
|
+
## Core Features
|
|
119
56
|
|
|
120
57
|
### Contract Management
|
|
121
58
|
|
|
122
|
-
Create and manage rental contracts for Star Atlas fleets:
|
|
123
|
-
|
|
124
59
|
```typescript
|
|
125
60
|
import { createContract, closeContract } from '@wuwei-labs/srsly';
|
|
126
61
|
|
|
127
|
-
// Create
|
|
62
|
+
// Create rental contract
|
|
128
63
|
const createIx = await createContract({
|
|
129
64
|
owner: wallet,
|
|
130
65
|
fleet: fleetAddress,
|
|
131
66
|
ownerProfile: profileAddress,
|
|
132
|
-
rate: 5000000,
|
|
133
|
-
durationMin: 86400,
|
|
134
|
-
durationMax: 2592000,
|
|
135
|
-
paymentsFreq: 'daily'
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// Close an existing contract using atlasnet programs (direct await)
|
|
67
|
+
rate: 5000000,
|
|
68
|
+
durationMin: 86400,
|
|
69
|
+
durationMax: 2592000,
|
|
70
|
+
paymentsFreq: 'daily'
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Close contract
|
|
140
74
|
const closeIx = await closeContract({
|
|
141
75
|
owner: wallet,
|
|
142
76
|
fleet: fleetAddress,
|
|
143
|
-
contract: contractAddress
|
|
144
|
-
faction: 'mud' // or faction number: 1, 2, 3
|
|
77
|
+
contract: contractAddress
|
|
145
78
|
});
|
|
146
79
|
```
|
|
147
80
|
|
|
148
81
|
### Rental Operations
|
|
149
82
|
|
|
150
|
-
Handle rental lifecycle operations with automatic token conversion:
|
|
151
|
-
|
|
152
83
|
```typescript
|
|
153
|
-
import {
|
|
154
|
-
acceptRental,
|
|
155
|
-
cancelRental,
|
|
156
|
-
closeRental,
|
|
157
|
-
resetRental,
|
|
158
|
-
ATLAS_TO_STARDUST
|
|
159
|
-
} from '@wuwei-labs/srsly';
|
|
84
|
+
import { acceptRental, cancelRental, closeRental } from '@wuwei-labs/srsly';
|
|
160
85
|
|
|
161
|
-
// Accept
|
|
86
|
+
// Accept rental offer
|
|
162
87
|
const acceptIx = await acceptRental({
|
|
163
88
|
borrower: borrowerWallet,
|
|
164
89
|
borrowerProfile: borrowerProfileAddress,
|
|
165
|
-
borrowerFaction: '
|
|
90
|
+
borrowerFaction: 'mud', // or 1, 2, 3
|
|
166
91
|
fleet: fleetAddress,
|
|
167
92
|
contract: contractAddress,
|
|
168
|
-
rate: 100, // ATLAS
|
|
93
|
+
rate: 100, // ATLAS per day
|
|
169
94
|
duration: 86400 // 1 day in seconds
|
|
170
|
-
|
|
171
|
-
}).set({ network: 'atlasnet' });
|
|
95
|
+
});
|
|
172
96
|
|
|
173
|
-
// Cancel
|
|
97
|
+
// Cancel active rental
|
|
174
98
|
const cancelIx = await cancelRental({
|
|
175
99
|
borrower: borrowerWallet,
|
|
176
100
|
contract: contractAddress,
|
|
177
101
|
rentalState: rentalStateAddress
|
|
178
102
|
});
|
|
179
103
|
|
|
180
|
-
// Close
|
|
104
|
+
// Close completed rental
|
|
181
105
|
const closeIx = await closeRental({
|
|
182
106
|
borrower: borrowerWallet,
|
|
183
107
|
contract: contractAddress,
|
|
184
108
|
rentalState: rentalStateAddress,
|
|
185
109
|
ownerTokenAccount: ownerTokenAccountAddress
|
|
186
|
-
}).set({ network: 'mainnet' });
|
|
187
|
-
|
|
188
|
-
// Reset rental state with custom configuration
|
|
189
|
-
const resetIx = await resetRental({
|
|
190
|
-
fleet: fleetAddress,
|
|
191
|
-
contract: contractAddress,
|
|
192
|
-
rentalState: rentalStateAddress,
|
|
193
|
-
faction: 'mud',
|
|
194
|
-
ownerProfile: ownerProfileAddress
|
|
195
|
-
}).set({
|
|
196
|
-
network: 'mainnet',
|
|
197
|
-
sageProgramAddress: 'custom...',
|
|
198
|
-
gameId: 'custom...'
|
|
199
|
-
});
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Account State Management
|
|
203
|
-
|
|
204
|
-
Fetch and decode account states using network-specific functions:
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
import { getCachedNetworkModule } from '@wuwei-labs/srsly';
|
|
208
|
-
|
|
209
|
-
// Get network-specific account functions (programs to atlasnet)
|
|
210
|
-
const accountsModule = await getCachedNetworkModule('accounts');
|
|
211
|
-
const { fetchContractState, fetchRentalState } = accountsModule;
|
|
212
|
-
|
|
213
|
-
// Or specify network explicitly
|
|
214
|
-
const mainnetAccountsModule = await getCachedNetworkModule('accounts', 'mainnet');
|
|
215
|
-
|
|
216
|
-
// Fetch contract state
|
|
217
|
-
const contractState = await fetchContractState(rpc, contractPublicKey);
|
|
218
|
-
console.log('Contract rate:', contractState.rate.toString());
|
|
219
|
-
console.log('Duration range:', contractState.durationMin.toString(), '-', contractState.durationMax.toString());
|
|
220
|
-
|
|
221
|
-
// Fetch rental state
|
|
222
|
-
const rentalState = await fetchRentalState(rpc, rentalPublicKey);
|
|
223
|
-
console.log('Rental status:', rentalState.status);
|
|
224
|
-
console.log('Start time:', new Date(rentalState.startTime.toNumber() * 1000));
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Error Handling
|
|
228
|
-
|
|
229
|
-
The SDK provides custom error types for better debugging:
|
|
230
|
-
|
|
231
|
-
```typescript
|
|
232
|
-
import { SrslyError } from '@wuwei-labs/srsly';
|
|
233
|
-
|
|
234
|
-
try {
|
|
235
|
-
const instruction = await createContract(params);
|
|
236
|
-
// Add to transaction and send...
|
|
237
|
-
} catch (error) {
|
|
238
|
-
if (error instanceof SrslyError) {
|
|
239
|
-
console.error('SRSLY SDK Error:', error.message, error.code);
|
|
240
|
-
} else {
|
|
241
|
-
console.error('Other Error:', error);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### Token Conversion
|
|
247
|
-
|
|
248
|
-
The SDK includes automatic ATLAS to stardust conversion for rental operations:
|
|
249
|
-
|
|
250
|
-
```typescript
|
|
251
|
-
import { ATLAS_TO_STARDUST } from '@wuwei-labs/srsly';
|
|
252
|
-
|
|
253
|
-
// ATLAS_TO_STARDUST = 100_000_000 (1 ATLAS = 100 million stardust)
|
|
254
|
-
console.log('Conversion rate:', ATLAS_TO_STARDUST);
|
|
255
|
-
|
|
256
|
-
// When using acceptRental with rate and duration:
|
|
257
|
-
// Final amount = rate * duration * ATLAS_TO_STARDUST
|
|
258
|
-
// Example: 100 ATLAS * 86400 seconds * 100_000_000 = 864,000,000,000,000 stardust
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## Program Information
|
|
262
|
-
|
|
263
|
-
- **Program ID**: `SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT`
|
|
264
|
-
- **Network**: Solana Mainnet or Atlasnet
|
|
265
|
-
- **Built with**: Anchor Framework
|
|
266
|
-
|
|
267
|
-
## Payment Structure
|
|
268
|
-
|
|
269
|
-
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.
|
|
270
|
-
|
|
271
|
-
### Overview
|
|
272
|
-
|
|
273
|
-
```text
|
|
274
|
-
Rental Lifecycle:
|
|
275
|
-
1. Escrow Deposit (Full Payment Upfront)
|
|
276
|
-
2. Periodic Payments (Based on Payment Frequency)
|
|
277
|
-
3. Fee Collection (Platform + Referral Fees)
|
|
278
|
-
4. Owner Payments (After Fee Deduction)
|
|
279
|
-
5. Refunds (For Early Cancellation)
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### 1. Escrow Deposit
|
|
283
|
-
|
|
284
|
-
When a borrower accepts a rental, they deposit the **full rental amount upfront** into an escrow account:
|
|
285
|
-
|
|
286
|
-
```typescript
|
|
287
|
-
// Example: 1000 ATLAS for 10 days = 10,000 ATLAS total
|
|
288
|
-
const acceptIx = await acceptRental({
|
|
289
|
-
borrower: wallet,
|
|
290
|
-
borrowerProfile: profileAddress,
|
|
291
|
-
borrowerFaction: 'mud',
|
|
292
|
-
fleet: fleetAddress,
|
|
293
|
-
contract: contractAddress,
|
|
294
|
-
rate: 1000, // ATLAS tokens per day
|
|
295
|
-
duration: 864000, // 10 days in seconds
|
|
296
|
-
referralTokenAccount: referrerAddress // Optional referral
|
|
297
|
-
});
|
|
298
|
-
// Total escrowed: 1000 * 10 * 100,000,000 = 1,000,000,000,000 stardust
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
**Key Points:**
|
|
302
|
-
|
|
303
|
-
- Full payment calculated as: `rate × duration × ATLAS_TO_STARDUST`
|
|
304
|
-
- Funds are held in a rental-specific escrow account
|
|
305
|
-
- Escrow is controlled by the rental state PDA
|
|
306
|
-
- No payments to owner until periodic execution
|
|
307
|
-
- **Minimum enforcement**: 24 hours from start time (if no payments) or last payment time
|
|
308
|
-
|
|
309
|
-
### 2. Periodic Payments
|
|
310
|
-
|
|
311
|
-
The system creates an automated thread that executes payments based on the contract's payment frequency:
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
|
-
// Contract with daily payments
|
|
315
|
-
const contractIx = await createContract({
|
|
316
|
-
owner: wallet,
|
|
317
|
-
fleet: fleetAddress,
|
|
318
|
-
ownerProfile: profileAddress,
|
|
319
|
-
rate: 1000,
|
|
320
|
-
durationMin: 86400, // 1 day minimum
|
|
321
|
-
durationMax: 2592000, // 30 days maximum
|
|
322
|
-
paymentsFreq: 'daily' // Payments every 24 hours
|
|
323
|
-
});
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
**Payment Schedule:**
|
|
327
|
-
|
|
328
|
-
- **Daily**: Payments execute daily at 00:00 UTC (not every 24 hours from creation)
|
|
329
|
-
- **Weekly**: Payments execute weekly at specific day/time
|
|
330
|
-
- **Monthly**: Payments execute monthly at specific day/time
|
|
331
|
-
|
|
332
|
-
**Pro-rata Calculation:**
|
|
333
|
-
|
|
334
|
-
Each payment is calculated based on elapsed time since the last payment:
|
|
335
|
-
|
|
336
|
-
```text
|
|
337
|
-
payment_amount = (elapsed_time / frequency_seconds) × rate × ATLAS_TO_STARDUST
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
### 3. Fee Structure
|
|
341
|
-
|
|
342
|
-
Each payment is subject to a **10% platform fee** with optional **10% referral sharing**:
|
|
343
|
-
|
|
344
|
-
```typescript
|
|
345
|
-
// Constants from the program
|
|
346
|
-
const SERVICE_FEE_BPS = 1000; // 10% platform fee
|
|
347
|
-
const REFERRAL_BPS = 1000; // 10% of total fee to referral
|
|
348
|
-
const BASE_BPS = 10000; // 100% in basis points
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
**Fee Calculation:**
|
|
352
|
-
|
|
353
|
-
```typescript
|
|
354
|
-
// For each payment amount
|
|
355
|
-
const totalFee = paymentAmount * SERVICE_FEE_BPS / BASE_BPS; // 10% of payment
|
|
356
|
-
const referralFee = totalFee * REFERRAL_BPS / BASE_BPS; // 10% of total fee
|
|
357
|
-
const platformFee = totalFee - referralFee; // 90% of total fee
|
|
358
|
-
const ownerPayment = paymentAmount - totalFee; // 90% of payment
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
**Example Payment Breakdown:**
|
|
362
|
-
|
|
363
|
-
```text
|
|
364
|
-
Payment Amount: 1000 ATLAS
|
|
365
|
-
├── Total Fee (10%): 100 ATLAS
|
|
366
|
-
│ ├── Referral Fee (10% of total fee): 10 ATLAS → Referrer
|
|
367
|
-
│ └── Platform Fee (90% of total fee): 90 ATLAS → Platform
|
|
368
|
-
└── Owner Payment (90%): 900 ATLAS → Fleet Owner
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### 4. Payment Distribution
|
|
372
|
-
|
|
373
|
-
Each periodic payment is distributed in this order:
|
|
374
|
-
|
|
375
|
-
1. **Referral Payment** (if referrer exists and ≠ system_program::ID)
|
|
376
|
-
- Amount: `total_fee × REFERRAL_BPS ÷ BASE_BPS`
|
|
377
|
-
- Destination: Referrer's token account
|
|
378
|
-
|
|
379
|
-
2. **Platform Fee Payment**
|
|
380
|
-
- Amount: `total_fee - referral_payment`
|
|
381
|
-
- Destination: Platform fee account
|
|
382
|
-
|
|
383
|
-
3. **Owner Payment**
|
|
384
|
-
- Amount: `payment_amount - total_fee`
|
|
385
|
-
- Destination: Fleet owner's token account
|
|
386
|
-
|
|
387
|
-
**Code Example:**
|
|
388
|
-
|
|
389
|
-
```typescript
|
|
390
|
-
// Accept rental with referral
|
|
391
|
-
const acceptIx = await acceptRental({
|
|
392
|
-
borrower: wallet,
|
|
393
|
-
borrowerProfile: profileAddress,
|
|
394
|
-
borrowerFaction: 'mud',
|
|
395
|
-
fleet: fleetAddress,
|
|
396
|
-
contract: contractAddress,
|
|
397
|
-
rate: 1000,
|
|
398
|
-
duration: 86400,
|
|
399
|
-
referralTokenAccount: referrerTokenAccount // 10% of fees
|
|
400
|
-
});
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
### 5. Refund Mechanism
|
|
404
|
-
|
|
405
|
-
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.**
|
|
406
|
-
|
|
407
|
-
**Early Cancellation:**
|
|
408
|
-
|
|
409
|
-
```typescript
|
|
410
|
-
const cancelIx = await cancelRental({
|
|
411
|
-
borrower: wallet,
|
|
412
|
-
contract: contractAddress,
|
|
413
|
-
rentalState: rentalStateAddress
|
|
414
110
|
});
|
|
415
111
|
```
|
|
416
112
|
|
|
417
|
-
**Refund Scenarios:**
|
|
418
|
-
|
|
419
|
-
- **Before First Payment**: Rental remains active for 24 hours from start time, pro-rata refund for remaining time
|
|
420
|
-
- **After Payment(s) Made**: Rental remains active for 24 hours from last payment time, pro-rata refund for remaining time
|
|
421
|
-
- **Contract Closure**: Any remaining escrow returned to borrower
|
|
422
|
-
|
|
423
|
-
### 6. Payment Timeline Example
|
|
424
|
-
|
|
425
|
-
**Scenario**: 10-day rental with daily payments, 1000 ATLAS/day rate
|
|
426
|
-
|
|
427
|
-
```text
|
|
428
|
-
Day 0: Rental Accepted
|
|
429
|
-
├── Escrow: 10,000 ATLAS deposited
|
|
430
|
-
├── Thread: Created for daily execution at 00:00 UTC
|
|
431
|
-
├── Fleet: Transferred to borrower
|
|
432
|
-
└── Minimum 24-hour commitment begins (from start time)
|
|
433
|
-
|
|
434
|
-
00:00 UTC Next Day: First Payment
|
|
435
|
-
├── Amount: 1,000 ATLAS from escrow
|
|
436
|
-
├── Total Fee (10%): 100 ATLAS
|
|
437
|
-
│ ├── Referrer: 10 ATLAS (10% of total fee)
|
|
438
|
-
│ └── Platform: 90 ATLAS (90% of total fee)
|
|
439
|
-
├── Owner: 900 ATLAS (90% of payment)
|
|
440
|
-
├── Escrow: 9,000 ATLAS remaining
|
|
441
|
-
└── New 24-hour minimum period begins (from payment time)
|
|
442
|
-
|
|
443
|
-
Daily at 00:00 UTC: Subsequent Payments
|
|
444
|
-
├── Same distribution pattern
|
|
445
|
-
├── Escrow decreases by 1,000 ATLAS each day
|
|
446
|
-
└── Each payment resets 24-hour minimum period
|
|
447
|
-
|
|
448
|
-
Final Day at 00:00 UTC: Final Payment & Cleanup
|
|
449
|
-
├── Final payment processed
|
|
450
|
-
├── Thread: Automatically closed
|
|
451
|
-
├── Rental State: Closed, lamports to borrower
|
|
452
|
-
└── Fleet: Returned to owner or contract
|
|
453
|
-
|
|
454
|
-
Early Cancellation Examples:
|
|
455
|
-
|
|
456
|
-
Scenario A - Cancel before first payment (Day 0 at 6 PM):
|
|
457
|
-
├── Cancelled 6 hours after start
|
|
458
|
-
├── Rental extends until 24 hours from start time (Day 1 at start time)
|
|
459
|
-
├── Pro-rata refund calculated from Day 1 extended end onwards
|
|
460
|
-
└── Borrower receives refund for Days 1-10
|
|
461
|
-
|
|
462
|
-
Scenario B - Cancel after payments made (Day 3 at 6 PM):
|
|
463
|
-
├── Cancelled 18 hours after Day 3 payment (00:00 UTC)
|
|
464
|
-
├── Rental extends until 24 hours from last payment (Day 4 at 00:00 UTC)
|
|
465
|
-
├── Pro-rata refund calculated from Day 4 onwards
|
|
466
|
-
└── Borrower receives refund for Days 4-10
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
### 7. Edge Cases
|
|
470
|
-
|
|
471
|
-
**Insufficient Escrow Balance:**
|
|
472
|
-
|
|
473
|
-
- Payment amount is limited to available escrow balance
|
|
474
|
-
- Remaining balance distributed proportionally
|
|
475
|
-
|
|
476
|
-
**Early Termination:**
|
|
477
|
-
|
|
478
|
-
- **Cancellation Notice**: Must have more than one payment period remaining to cancel
|
|
479
|
-
- **Minimum Period Enforcement**:
|
|
480
|
-
- Before first payment: Active for 24 hours from start time
|
|
481
|
-
- After payment(s): Active for 24 hours from last payment time
|
|
482
|
-
- **Pro-rata Refund**: Refund calculated from the enforced minimum end time
|
|
483
|
-
- Fleet returned to owner when minimum period expires
|
|
484
|
-
- Payment thread continues until minimum period ends
|
|
485
|
-
|
|
486
|
-
**Contract Closure:**
|
|
487
|
-
|
|
488
|
-
- Final payment processed if rental active
|
|
489
|
-
- All remaining resources cleaned up
|
|
490
|
-
- Fleet rental capability removed
|
|
491
|
-
|
|
492
|
-
## Payment Frequencies
|
|
493
|
-
|
|
494
|
-
The SDK supports multiple payment frequencies:
|
|
495
|
-
|
|
496
|
-
- `daily` - Daily payments at 00:00 UTC
|
|
497
|
-
- `weekly` - Weekly payments at specific day/time
|
|
498
|
-
- `monthly` - Monthly payments at specific day/time
|
|
499
|
-
|
|
500
|
-
|
|
501
113
|
## Network Configuration
|
|
502
114
|
|
|
503
|
-
The SDK supports
|
|
504
|
-
|
|
505
|
-
### What `setConfig` Does:
|
|
506
|
-
|
|
507
|
-
**1. Network Selection (IDL/Module Loading):**
|
|
508
|
-
- ✅ Selects which IDL artifacts to use (`mainnet` vs `atlasnet`)
|
|
509
|
-
- ✅ Loads appropriate codama-generated instruction builders
|
|
510
|
-
- ✅ Determines default program addresses for the network
|
|
511
|
-
|
|
512
|
-
**2. Program Address Selection:**
|
|
513
|
-
- ✅ Select predefined program address sets (mainnet, atlasnet, holosim)
|
|
514
|
-
- ✅ Override specific program addresses (SRSLY, SAGE, Profile Faction)
|
|
515
|
-
- ✅ Override game IDs and other network constants
|
|
516
|
-
- ✅ Mix and match programs across networks if needed
|
|
517
|
-
|
|
518
|
-
**What it does NOT do:**
|
|
519
|
-
- ❌ Configure RPC endpoints
|
|
520
|
-
- ❌ Handle wallet connections
|
|
521
|
-
- ❌ Manage transactions
|
|
522
|
-
|
|
523
|
-
### Global Configuration (Recommended)
|
|
115
|
+
The SDK supports multiple network configurations:
|
|
524
116
|
|
|
525
|
-
|
|
117
|
+
### Global Configuration
|
|
526
118
|
|
|
527
119
|
```typescript
|
|
528
|
-
import { setConfig, getConfig,
|
|
120
|
+
import { setConfig, getConfig, clearConfig } from '@wuwei-labs/srsly';
|
|
529
121
|
|
|
530
|
-
//
|
|
531
|
-
setConfig({
|
|
532
|
-
network: 'mainnet'
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
// Example 2: Use atlasnet IDL with default atlasnet program addresses
|
|
536
|
-
setConfig({
|
|
537
|
-
network: 'atlasnet'
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
// Example 3: Use atlasnet IDL with holosim program addresses
|
|
541
|
-
setConfig({
|
|
542
|
-
network: 'atlasnet',
|
|
543
|
-
programs: 'holosim'
|
|
544
|
-
});
|
|
122
|
+
// Use mainnet programs
|
|
123
|
+
setConfig({ programs: 'mainnet' });
|
|
545
124
|
|
|
546
|
-
//
|
|
547
|
-
setConfig({
|
|
548
|
-
network: 'atlasnet',
|
|
549
|
-
programs: 'holosim',
|
|
550
|
-
sageProgramAddress: 'custom-sage-program-id...'
|
|
551
|
-
});
|
|
125
|
+
// Use atlasnet programs (default)
|
|
126
|
+
setConfig({ programs: 'atlasnet' });
|
|
552
127
|
|
|
553
|
-
//
|
|
554
|
-
setConfig({
|
|
555
|
-
network: 'mainnet',
|
|
556
|
-
programs: 'atlasnet'
|
|
557
|
-
});
|
|
128
|
+
// Use holosim test programs
|
|
129
|
+
setConfig({ programs: 'holosim' });
|
|
558
130
|
|
|
559
|
-
//
|
|
131
|
+
// Custom configuration
|
|
560
132
|
setConfig({
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
sageProgramAddress: 'custom-sage-program-id...',
|
|
133
|
+
programs: 'mainnet',
|
|
134
|
+
sageProgramAddress: 'custom-sage-program...',
|
|
564
135
|
gameId: 'custom-game-id...'
|
|
565
136
|
});
|
|
566
137
|
|
|
567
|
-
// Check current
|
|
138
|
+
// Check current config
|
|
568
139
|
console.log(getConfig());
|
|
569
140
|
|
|
570
|
-
//
|
|
571
|
-
|
|
572
|
-
const ix2 = await acceptRental(params); // Uses configured SAGE program
|
|
141
|
+
// Reset to defaults
|
|
142
|
+
clearConfig();
|
|
573
143
|
```
|
|
574
144
|
|
|
575
145
|
### Per-Instruction Configuration
|
|
576
146
|
|
|
577
|
-
Override global program address configuration for specific instructions using the fluent `.set()` interface:
|
|
578
|
-
|
|
579
147
|
```typescript
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
// Assume global config is set to mainnet program addresses
|
|
583
|
-
setConfig({ network: 'mainnet' });
|
|
584
|
-
|
|
585
|
-
// Use global mainnet program addresses
|
|
586
|
-
const mainnetIx = await createContract(params);
|
|
587
|
-
|
|
588
|
-
// Override to use atlasnet program addresses for this specific instruction
|
|
589
|
-
const atlasnetIx = await createContract(params).set({ network: 'atlasnet' });
|
|
148
|
+
// Override global config for specific instructions
|
|
149
|
+
const ix = await createContract(params).set({ programs: 'mainnet' });
|
|
590
150
|
|
|
591
|
-
//
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
gameId: 'custom-game-id...'
|
|
595
|
-
// network: 'mainnet' inherited from global config
|
|
596
|
-
});
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
### Configuration Options
|
|
600
|
-
|
|
601
|
-
All SDK functions support these usage patterns:
|
|
602
|
-
|
|
603
|
-
**Direct await (uses global config or atlasnet fallback):**
|
|
604
|
-
|
|
605
|
-
```typescript
|
|
606
|
-
// Uses global program addresses if set, otherwise atlasnet programs
|
|
607
|
-
await createContract(params);
|
|
608
|
-
await acceptRental(params);
|
|
151
|
+
// Chain multiple configurations
|
|
152
|
+
const ix2 = await acceptRental(params)
|
|
153
|
+
.set({ programs: 'holosim' })
|
|
154
|
+
.set({ gameId: 'custom-game-id...' });
|
|
609
155
|
```
|
|
610
156
|
|
|
611
|
-
|
|
157
|
+
## Payment System
|
|
612
158
|
|
|
613
|
-
|
|
614
|
-
- `getConfig()` - Get current global configuration
|
|
615
|
-
- `clearConfig()` - Reset to atlasnet programs
|
|
159
|
+
SRSLY implements an escrow-based payment system:
|
|
616
160
|
|
|
617
|
-
**
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
-
|
|
621
|
-
- `.set({ network: 'mainnet', sageProgramAddress: '...' })` - Multiple overrides
|
|
622
|
-
|
|
623
|
-
**Chainable configurations:**
|
|
624
|
-
|
|
625
|
-
```typescript
|
|
626
|
-
// Chain multiple configurations (later ones override earlier ones)
|
|
627
|
-
await createContract(params)
|
|
628
|
-
.set({ network: 'atlasnet' })
|
|
629
|
-
.set({ sageProgramAddress: 'override...' });
|
|
630
|
-
|
|
631
|
-
// Examples with global config
|
|
632
|
-
setConfig({ network: 'mainnet' });
|
|
633
|
-
await createContract(params); // Uses mainnet program addresses
|
|
634
|
-
await acceptRental(params).set({ network: 'atlasnet' }); // Override to atlasnet programs
|
|
635
|
-
await closeContract(params).set({ gameId: 'custom...' }); // Custom gameId, mainnet programs
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
### Available Configuration Options
|
|
161
|
+
1. **Escrow**: Borrower deposits full rental amount upfront
|
|
162
|
+
2. **Periodic Payments**: Automated payments based on frequency (daily/weekly/monthly)
|
|
163
|
+
3. **Fees**: 10% platform fee, optional 10% referral sharing
|
|
164
|
+
4. **Refunds**: Pro-rata refunds for early cancellation (24-hour minimum)
|
|
639
165
|
|
|
640
166
|
```typescript
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
sageProgramAddress?: string; // Override SAGE program address
|
|
646
|
-
profileFactionProgramAddress?: string; // Override Profile Faction program address
|
|
647
|
-
gameId?: string; // Override SAGE game ID
|
|
648
|
-
}
|
|
167
|
+
// Payment calculation
|
|
168
|
+
const rate = 1000; // ATLAS per day
|
|
169
|
+
const duration = 86400; // 1 day in seconds
|
|
170
|
+
const totalAmount = rate * duration * ATLAS_TO_STARDUST; // in stardust
|
|
649
171
|
```
|
|
650
172
|
|
|
651
|
-
|
|
173
|
+
## Available Networks
|
|
652
174
|
|
|
653
175
|
```typescript
|
|
654
|
-
//
|
|
655
|
-
{
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
// holosim
|
|
671
|
-
{
|
|
672
|
-
srslyProgram: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT',
|
|
673
|
-
sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
|
|
674
|
-
profileFactionProgram: 'PprofUW1pURCnMW2si88GWPXEEK3Bvh9Tksy8WtnoYJ',
|
|
675
|
-
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k'
|
|
676
|
-
}
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
**Priority Order:**
|
|
680
|
-
1. Individual overrides (highest priority)
|
|
681
|
-
2. programs configuration
|
|
682
|
-
3. Network default (if programs not specified)
|
|
683
|
-
|
|
684
|
-
**Key Concepts:**
|
|
685
|
-
|
|
686
|
-
- **Network** = Which IDL/codama artifacts to load (affects instruction structure)
|
|
687
|
-
- **programs** = Which predefined program address set to use (mainnet, atlasnet, holosim)
|
|
688
|
-
- **Program Overrides** = Override individual program addresses (highest priority)
|
|
689
|
-
- **Default Behavior** = If programs not specified, uses network's program addresses
|
|
690
|
-
- **Flexibility** = Mix any IDL with any program set, plus individual overrides
|
|
691
|
-
|
|
692
|
-
### Network-Specific Constants
|
|
693
|
-
|
|
694
|
-
The SDK automatically resolves network-specific constants:
|
|
695
|
-
|
|
696
|
-
```typescript
|
|
697
|
-
import {
|
|
698
|
-
getSageProgramAddress,
|
|
699
|
-
getProfileFactionProgramAddress,
|
|
700
|
-
getSageGameId
|
|
701
|
-
} from '@wuwei-labs/srsly';
|
|
702
|
-
|
|
703
|
-
// Get constants for atlasnet (default)
|
|
704
|
-
const sageProgram = await getSageProgramAddress();
|
|
705
|
-
const gameId = await getSageGameId();
|
|
706
|
-
|
|
707
|
-
// Get constants for specific network
|
|
708
|
-
const mainnetSageProgram = await getSageProgramAddress({ network: 'mainnet' });
|
|
709
|
-
const mainnetGameId = await getSageGameId({ network: 'mainnet' });
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
## IDL and Types
|
|
713
|
-
|
|
714
|
-
### Network-Specific IDLs
|
|
715
|
-
|
|
716
|
-
The SDK provides network-specific IDLs since program configurations differ between networks:
|
|
717
|
-
|
|
718
|
-
```typescript
|
|
719
|
-
// Mainnet IDL
|
|
720
|
-
import mainnetIdl from '@wuwei-labs/srsly/idl/mainnet';
|
|
721
|
-
|
|
722
|
-
// Devnet IDL
|
|
723
|
-
import atlasnetIdl from '@wuwei-labs/srsly/idl/atlasnet';
|
|
724
|
-
|
|
725
|
-
// Use with Anchor
|
|
726
|
-
import { Program } from '@coral-xyz/anchor';
|
|
727
|
-
const program = new Program(mainnetIdl, provider);
|
|
176
|
+
// Program address sets
|
|
177
|
+
const networks = {
|
|
178
|
+
mainnet: {
|
|
179
|
+
sageProgram: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
180
|
+
gameId: 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr'
|
|
181
|
+
},
|
|
182
|
+
atlasnet: {
|
|
183
|
+
sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
|
|
184
|
+
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k'
|
|
185
|
+
},
|
|
186
|
+
holosim: {
|
|
187
|
+
sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
|
|
188
|
+
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k'
|
|
189
|
+
}
|
|
190
|
+
};
|
|
728
191
|
```
|
|
729
192
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
Import TypeScript types that match your target network:
|
|
193
|
+
## Types and Constants
|
|
733
194
|
|
|
734
195
|
```typescript
|
|
735
196
|
import type {
|
|
736
|
-
ContractState,
|
|
737
|
-
RentalState,
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
ThreadResponse,
|
|
741
|
-
ConfigOptions
|
|
197
|
+
ContractState,
|
|
198
|
+
RentalState,
|
|
199
|
+
ConfigOptions,
|
|
200
|
+
PaymentFrequency
|
|
742
201
|
} from '@wuwei-labs/srsly';
|
|
743
202
|
|
|
744
|
-
// Import network-specific Anchor types
|
|
745
|
-
import type { Srsly as SrslyMainnet } from '@wuwei-labs/srsly/types/mainnet';
|
|
746
|
-
import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/atlasnet';
|
|
747
|
-
```
|
|
748
|
-
|
|
749
|
-
## Constants and Utilities
|
|
750
|
-
|
|
751
|
-
### Available Constants
|
|
752
|
-
|
|
753
|
-
```typescript
|
|
754
203
|
import {
|
|
755
204
|
ATLAS_TO_STARDUST,
|
|
756
|
-
|
|
757
|
-
STARBASE_PLAYER_SEED,
|
|
758
|
-
SAGE_PLAYER_PROFILE_SEED,
|
|
759
|
-
PROFILE_FACTION_SEED,
|
|
760
|
-
FACTION_MAPPING,
|
|
761
|
-
FACTION_SPECIFIC_CSS
|
|
205
|
+
FACTION_MAPPING
|
|
762
206
|
} from '@wuwei-labs/srsly';
|
|
763
207
|
|
|
764
|
-
//
|
|
208
|
+
// Conversion rate: 1 ATLAS = 100,000,000 stardust
|
|
765
209
|
console.log(ATLAS_TO_STARDUST); // 100_000_000
|
|
766
210
|
|
|
767
211
|
// Faction mappings
|
|
768
212
|
console.log(FACTION_MAPPING[1]); // 'mud'
|
|
769
|
-
console.log(FACTION_MAPPING[2]); // 'oni'
|
|
213
|
+
console.log(FACTION_MAPPING[2]); // 'oni'
|
|
770
214
|
console.log(FACTION_MAPPING[3]); // 'ustur'
|
|
771
215
|
```
|
|
772
216
|
|
|
773
|
-
|
|
217
|
+
## IDL and Program Information
|
|
774
218
|
|
|
775
219
|
```typescript
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
deriveStarbase,
|
|
780
|
-
deriveStarbasePlayer,
|
|
781
|
-
deriveGameAccounts
|
|
782
|
-
} from '@wuwei-labs/srsly';
|
|
783
|
-
|
|
784
|
-
// Derive individual accounts with network configuration
|
|
785
|
-
const profileFaction = await deriveProfileFaction(profile, { network: 'mainnet' });
|
|
786
|
-
const starbase = await deriveStarbase('mud', gameId, { network: 'mainnet' });
|
|
787
|
-
|
|
788
|
-
// Derive all game accounts at once
|
|
789
|
-
const gameAccounts = await deriveGameAccounts(
|
|
790
|
-
profile,
|
|
791
|
-
'mud',
|
|
792
|
-
gameId,
|
|
793
|
-
0, // starbaseSeqId
|
|
794
|
-
{ network: 'mainnet' }
|
|
795
|
-
);
|
|
220
|
+
// Access program IDLs
|
|
221
|
+
import mainnetIdl from '@wuwei-labs/srsly/idl/mainnet';
|
|
222
|
+
import atlasnetIdl from '@wuwei-labs/srsly/idl/atlasnet';
|
|
796
223
|
```
|
|
797
224
|
|
|
798
|
-
##
|
|
799
|
-
|
|
800
|
-
The SRSLY SDK is fully compatible with webpack bundlers. The package includes both CommonJS and ESM builds:
|
|
801
|
-
|
|
802
|
-
- **CommonJS**: `./dist/cjs/index.cjs` (default for Node.js and webpack)
|
|
803
|
-
- **ESM**: `./dist/esm/index.js` (for modern ES modules)
|
|
804
|
-
- **Types**: `./dist/types/index.d.ts` (TypeScript definitions)
|
|
805
|
-
|
|
806
|
-
### Webpack Configuration
|
|
807
|
-
|
|
808
|
-
For optimal webpack compatibility, the SDK includes:
|
|
809
|
-
|
|
810
|
-
- `sideEffects: false` for better tree-shaking
|
|
811
|
-
- Proper CommonJS exports with `.cjs` extensions for webpack bundling
|
|
812
|
-
- ES module interoperability
|
|
813
|
-
- Correct module resolution for mixed ESM/CommonJS environments
|
|
814
|
-
|
|
815
|
-
No special webpack configuration is required. The SDK will work out-of-the-box with most webpack setups.
|
|
816
|
-
|
|
817
|
-
**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"`.
|
|
818
|
-
|
|
819
|
-
### Testing Webpack Compatibility
|
|
820
|
-
|
|
821
|
-
```bash
|
|
822
|
-
# Test local CommonJS exports (fast)
|
|
823
|
-
npm run test:webpack
|
|
225
|
+
## Error Handling
|
|
824
226
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
# Test actual pnpm package installation with webpack bundling
|
|
829
|
-
npm run test:pnpm-install
|
|
227
|
+
```typescript
|
|
228
|
+
import { SrslyError } from '@wuwei-labs/srsly';
|
|
830
229
|
|
|
831
|
-
|
|
832
|
-
|
|
230
|
+
try {
|
|
231
|
+
const instruction = await createContract(params);
|
|
232
|
+
// Add to transaction and send...
|
|
233
|
+
} catch (error) {
|
|
234
|
+
if (error instanceof SrslyError) {
|
|
235
|
+
console.error('SRSLY SDK Error:', error.message, error.code);
|
|
236
|
+
} else {
|
|
237
|
+
console.error('Other Error:', error);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
833
240
|
```
|
|
834
241
|
|
|
835
|
-
|
|
836
|
-
- `test:webpack`: Tests local CommonJS exports that webpack uses
|
|
837
|
-
- `test:npm-install`: Installs the actual published package via npm and tests functionality
|
|
838
|
-
- `test:pnpm-install`: Installs via pnpm and includes a real webpack bundling test
|
|
839
|
-
- `test:package-managers`: Runs both npm and pnpm tests
|
|
242
|
+
## Package Structure
|
|
840
243
|
|
|
841
|
-
|
|
244
|
+
The SDK provides optimized builds for different environments:
|
|
842
245
|
|
|
843
|
-
- **
|
|
246
|
+
- **CommonJS**: `./dist/cjs/` (Node.js, webpack)
|
|
247
|
+
- **ESM**: `./dist/esm/` (Modern ES modules)
|
|
248
|
+
- **Types**: `./dist/types/` (TypeScript definitions)
|
|
249
|
+
- **Shared**: `./dist/shared/codama/` (Optimized codama exports)
|
|
844
250
|
|
|
845
|
-
##
|
|
251
|
+
## Links
|
|
846
252
|
|
|
847
|
-
- **
|
|
848
|
-
- **
|
|
849
|
-
- **Anchor**: The framework used to build the SRSLY program
|
|
253
|
+
- **NPM Package**: [@wuwei-labs/srsly](https://www.npmjs.com/package/@wuwei-labs/srsly)
|
|
254
|
+
- **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
|