@wuwei-labs/srsly 2.0.0-beta.4 → 2.0.0-beta.6
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 +443 -73
- package/dist/cjs/codama/devnet/accounts/contractState.js +2 -7
- package/dist/cjs/codama/devnet/accounts/contractState.js.map +1 -1
- package/dist/cjs/codama/devnet/accounts/rentalState.js +3 -1
- package/dist/cjs/codama/devnet/accounts/rentalState.js.map +1 -1
- 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/srsly.js +4 -1
- package/dist/cjs/codama/devnet/errors/srsly.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/acceptRental.js +17 -23
- package/dist/cjs/codama/devnet/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/closeContract.js +28 -1
- package/dist/cjs/codama/devnet/instructions/closeContract.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/closeRental.js +28 -1
- package/dist/cjs/codama/devnet/instructions/closeRental.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/index.js +0 -1
- package/dist/cjs/codama/devnet/instructions/index.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/payRental.js +45 -1
- package/dist/cjs/codama/devnet/instructions/payRental.js.map +1 -1
- package/dist/cjs/codama/devnet/programs/srsly.js +2 -6
- package/dist/cjs/codama/devnet/programs/srsly.js.map +1 -1
- package/dist/cjs/codama/devnet/types/index.js +0 -1
- package/dist/cjs/codama/devnet/types/index.js.map +1 -1
- package/dist/cjs/codama/mainnet/accounts/contractState.js +2 -7
- package/dist/cjs/codama/mainnet/accounts/contractState.js.map +1 -1
- package/dist/cjs/codama/mainnet/accounts/rentalState.js +3 -1
- package/dist/cjs/codama/mainnet/accounts/rentalState.js.map +1 -1
- 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/srsly.js +4 -1
- package/dist/cjs/codama/mainnet/errors/srsly.js.map +1 -1
- package/dist/cjs/codama/mainnet/instructions/acceptRental.js +17 -23
- package/dist/cjs/codama/mainnet/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/codama/mainnet/instructions/closeContract.js +28 -1
- package/dist/cjs/codama/mainnet/instructions/closeContract.js.map +1 -1
- package/dist/cjs/codama/mainnet/instructions/closeRental.js +28 -1
- package/dist/cjs/codama/mainnet/instructions/closeRental.js.map +1 -1
- package/dist/cjs/codama/mainnet/instructions/index.js +0 -1
- package/dist/cjs/codama/mainnet/instructions/index.js.map +1 -1
- package/dist/cjs/codama/mainnet/instructions/payRental.js +45 -1
- package/dist/cjs/codama/mainnet/instructions/payRental.js.map +1 -1
- package/dist/cjs/codama/mainnet/programs/srsly.js +2 -6
- package/dist/cjs/codama/mainnet/programs/srsly.js.map +1 -1
- package/dist/cjs/codama/mainnet/types/index.js +0 -1
- package/dist/cjs/codama/mainnet/types/index.js.map +1 -1
- package/dist/cjs/contract/close.js +51 -19
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +31 -19
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/rental/accept.js +59 -33
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +30 -24
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +31 -25
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +40 -38
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/config.js +204 -0
- package/dist/cjs/utils/config.js.map +1 -0
- package/dist/cjs/utils/constants.js +78 -13
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/profiles.js +38 -18
- package/dist/cjs/utils/profiles.js.map +1 -1
- package/package.json +4 -2
- package/target/idl/srsly-devnet.json +649 -391
- package/target/idl/srsly-mainnet.json +493 -229
- package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js +0 -152
- package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js.map +0 -1
- package/dist/cjs/codama/devnet/types/paymentFrequency.js +0 -34
- package/dist/cjs/codama/devnet/types/paymentFrequency.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/normalizeAdmin.js +0 -152
- package/dist/cjs/codama/mainnet/instructions/normalizeAdmin.js.map +0 -1
- package/dist/cjs/codama/mainnet/types/paymentFrequency.js +0 -32
- package/dist/cjs/codama/mainnet/types/paymentFrequency.js.map +0 -1
- package/dist/cjs/network.js +0 -107
- package/dist/cjs/network.js.map +0 -1
- package/dist/esm/codama/devnet/accounts/contractState.js +0 -79
- package/dist/esm/codama/devnet/accounts/contractState.js.map +0 -1
- package/dist/esm/codama/devnet/accounts/fleet.js +0 -64
- package/dist/esm/codama/devnet/accounts/fleet.js.map +0 -1
- package/dist/esm/codama/devnet/accounts/index.js +0 -12
- package/dist/esm/codama/devnet/accounts/index.js.map +0 -1
- package/dist/esm/codama/devnet/accounts/rentalState.js +0 -72
- package/dist/esm/codama/devnet/accounts/rentalState.js.map +0 -1
- package/dist/esm/codama/devnet/accounts/thread.js +0 -77
- package/dist/esm/codama/devnet/accounts/thread.js.map +0 -1
- package/dist/esm/codama/devnet/errors/index.js +0 -9
- package/dist/esm/codama/devnet/errors/index.js.map +0 -1
- package/dist/esm/codama/devnet/errors/srsly.js +0 -66
- package/dist/esm/codama/devnet/errors/srsly.js.map +0 -1
- package/dist/esm/codama/devnet/index.js +0 -13
- package/dist/esm/codama/devnet/index.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/acceptRental.js +0 -353
- package/dist/esm/codama/devnet/instructions/acceptRental.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/cancelRental.js +0 -215
- package/dist/esm/codama/devnet/instructions/cancelRental.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/closeContract.js +0 -209
- package/dist/esm/codama/devnet/instructions/closeContract.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/closeRental.js +0 -223
- package/dist/esm/codama/devnet/instructions/closeRental.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/createContract.js +0 -251
- package/dist/esm/codama/devnet/instructions/createContract.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/index.js +0 -16
- package/dist/esm/codama/devnet/instructions/index.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/normalizeAdmin.js +0 -142
- package/dist/esm/codama/devnet/instructions/normalizeAdmin.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/payRental.js +0 -226
- package/dist/esm/codama/devnet/instructions/payRental.js.map +0 -1
- package/dist/esm/codama/devnet/instructions/resetRental.js +0 -145
- package/dist/esm/codama/devnet/instructions/resetRental.js.map +0 -1
- package/dist/esm/codama/devnet/programs/index.js +0 -9
- package/dist/esm/codama/devnet/programs/index.js.map +0 -1
- package/dist/esm/codama/devnet/programs/srsly.js +0 -72
- package/dist/esm/codama/devnet/programs/srsly.js.map +0 -1
- package/dist/esm/codama/devnet/shared/index.js +0 -87
- package/dist/esm/codama/devnet/shared/index.js.map +0 -1
- package/dist/esm/codama/devnet/types/clockData.js +0 -26
- package/dist/esm/codama/devnet/types/clockData.js.map +0 -1
- package/dist/esm/codama/devnet/types/equality.js +0 -24
- package/dist/esm/codama/devnet/types/equality.js.map +0 -1
- package/dist/esm/codama/devnet/types/execContext.js +0 -33
- package/dist/esm/codama/devnet/types/execContext.js.map +0 -1
- package/dist/esm/codama/devnet/types/index.js +0 -17
- package/dist/esm/codama/devnet/types/index.js.map +0 -1
- package/dist/esm/codama/devnet/types/paymentFrequency.js +0 -28
- package/dist/esm/codama/devnet/types/paymentFrequency.js.map +0 -1
- package/dist/esm/codama/devnet/types/serializableAccount.js +0 -26
- package/dist/esm/codama/devnet/types/serializableAccount.js.map +0 -1
- package/dist/esm/codama/devnet/types/serializableInstruction.js +0 -27
- package/dist/esm/codama/devnet/types/serializableInstruction.js.map +0 -1
- package/dist/esm/codama/devnet/types/threadResponse.js +0 -33
- package/dist/esm/codama/devnet/types/threadResponse.js.map +0 -1
- package/dist/esm/codama/devnet/types/trigger.js +0 -83
- package/dist/esm/codama/devnet/types/trigger.js.map +0 -1
- package/dist/esm/codama/devnet/types/triggerContext.js +0 -42
- package/dist/esm/codama/devnet/types/triggerContext.js.map +0 -1
- package/dist/esm/codama/mainnet/accounts/contractState.js +0 -79
- 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 -72
- 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 -66
- 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 -353
- package/dist/esm/codama/mainnet/instructions/acceptRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/cancelRental.js +0 -215
- package/dist/esm/codama/mainnet/instructions/cancelRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/closeContract.js +0 -209
- package/dist/esm/codama/mainnet/instructions/closeContract.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/closeRental.js +0 -223
- package/dist/esm/codama/mainnet/instructions/closeRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/createContract.js +0 -251
- package/dist/esm/codama/mainnet/instructions/createContract.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/index.js +0 -16
- package/dist/esm/codama/mainnet/instructions/index.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/normalizeAdmin.js +0 -142
- package/dist/esm/codama/mainnet/instructions/normalizeAdmin.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/payRental.js +0 -226
- package/dist/esm/codama/mainnet/instructions/payRental.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/resetRental.js +0 -145
- 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 -72
- 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 -17
- package/dist/esm/codama/mainnet/types/index.js.map +0 -1
- package/dist/esm/codama/mainnet/types/paymentFrequency.js +0 -26
- package/dist/esm/codama/mainnet/types/paymentFrequency.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/esm/contract/close.js +0 -62
- package/dist/esm/contract/close.js.map +0 -1
- package/dist/esm/contract/create.js +0 -54
- package/dist/esm/contract/create.js.map +0 -1
- package/dist/esm/contract/index.js +0 -3
- package/dist/esm/contract/index.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/network.js +0 -67
- package/dist/esm/network.js.map +0 -1
- package/dist/esm/rental/accept.js +0 -60
- package/dist/esm/rental/accept.js.map +0 -1
- package/dist/esm/rental/cancel.js +0 -44
- package/dist/esm/rental/cancel.js.map +0 -1
- package/dist/esm/rental/close.js +0 -46
- package/dist/esm/rental/close.js.map +0 -1
- package/dist/esm/rental/index.js +0 -5
- package/dist/esm/rental/index.js.map +0 -1
- package/dist/esm/rental/reset.js +0 -63
- package/dist/esm/rental/reset.js.map +0 -1
- package/dist/esm/utils/constants.js +0 -42
- package/dist/esm/utils/constants.js.map +0 -1
- package/dist/esm/utils/index.js +0 -3
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/profiles.js +0 -132
- package/dist/esm/utils/profiles.js.map +0 -1
- package/dist/types/codama/devnet/accounts/contractState.d.ts +0 -53
- package/dist/types/codama/devnet/accounts/contractState.d.ts.map +0 -1
- package/dist/types/codama/devnet/accounts/fleet.d.ts +0 -38
- package/dist/types/codama/devnet/accounts/fleet.d.ts.map +0 -1
- package/dist/types/codama/devnet/accounts/index.d.ts +0 -12
- package/dist/types/codama/devnet/accounts/index.d.ts.map +0 -1
- package/dist/types/codama/devnet/accounts/rentalState.d.ts +0 -46
- package/dist/types/codama/devnet/accounts/rentalState.d.ts.map +0 -1
- package/dist/types/codama/devnet/accounts/thread.d.ts +0 -74
- package/dist/types/codama/devnet/accounts/thread.d.ts.map +0 -1
- package/dist/types/codama/devnet/errors/index.d.ts +0 -9
- package/dist/types/codama/devnet/errors/index.d.ts.map +0 -1
- package/dist/types/codama/devnet/errors/srsly.d.ts +0 -48
- package/dist/types/codama/devnet/errors/srsly.d.ts.map +0 -1
- package/dist/types/codama/devnet/index.d.ts +0 -13
- package/dist/types/codama/devnet/index.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/acceptRental.d.ts +0 -128
- package/dist/types/codama/devnet/instructions/acceptRental.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/cancelRental.d.ts +0 -71
- package/dist/types/codama/devnet/instructions/cancelRental.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/closeContract.d.ts +0 -96
- package/dist/types/codama/devnet/instructions/closeContract.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/closeRental.d.ts +0 -79
- package/dist/types/codama/devnet/instructions/closeRental.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/createContract.d.ts +0 -108
- package/dist/types/codama/devnet/instructions/createContract.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/index.d.ts +0 -16
- package/dist/types/codama/devnet/instructions/index.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts +0 -67
- package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/payRental.d.ts +0 -99
- package/dist/types/codama/devnet/instructions/payRental.d.ts.map +0 -1
- package/dist/types/codama/devnet/instructions/resetRental.d.ts +0 -71
- package/dist/types/codama/devnet/instructions/resetRental.d.ts.map +0 -1
- package/dist/types/codama/devnet/programs/index.d.ts +0 -9
- package/dist/types/codama/devnet/programs/index.d.ts.map +0 -1
- package/dist/types/codama/devnet/programs/srsly.d.ts +0 -50
- package/dist/types/codama/devnet/programs/srsly.d.ts.map +0 -1
- package/dist/types/codama/devnet/shared/index.d.ts +0 -50
- package/dist/types/codama/devnet/shared/index.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/clockData.d.ts +0 -29
- package/dist/types/codama/devnet/types/clockData.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/equality.d.ts +0 -18
- package/dist/types/codama/devnet/types/equality.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/execContext.d.ts +0 -48
- package/dist/types/codama/devnet/types/execContext.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/index.d.ts +0 -17
- package/dist/types/codama/devnet/types/index.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/paymentFrequency.d.ts +0 -22
- package/dist/types/codama/devnet/types/paymentFrequency.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/serializableAccount.d.ts +0 -22
- package/dist/types/codama/devnet/types/serializableAccount.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/serializableInstruction.d.ts +0 -30
- package/dist/types/codama/devnet/types/serializableInstruction.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/threadResponse.d.ts +0 -42
- package/dist/types/codama/devnet/types/threadResponse.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/trigger.d.ts +0 -98
- package/dist/types/codama/devnet/types/trigger.d.ts.map +0 -1
- package/dist/types/codama/devnet/types/triggerContext.d.ts +0 -75
- package/dist/types/codama/devnet/types/triggerContext.d.ts.map +0 -1
- package/dist/types/codama/mainnet/accounts/contractState.d.ts +0 -53
- 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 -46
- 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 -48
- 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 -128
- package/dist/types/codama/mainnet/instructions/acceptRental.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/cancelRental.d.ts +0 -71
- package/dist/types/codama/mainnet/instructions/cancelRental.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/closeContract.d.ts +0 -96
- package/dist/types/codama/mainnet/instructions/closeContract.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/closeRental.d.ts +0 -79
- 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 -16
- package/dist/types/codama/mainnet/instructions/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/normalizeAdmin.d.ts +0 -67
- package/dist/types/codama/mainnet/instructions/normalizeAdmin.d.ts.map +0 -1
- package/dist/types/codama/mainnet/instructions/payRental.d.ts +0 -99
- 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 +0 -50
- 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 -17
- package/dist/types/codama/mainnet/types/index.d.ts.map +0 -1
- package/dist/types/codama/mainnet/types/paymentFrequency.d.ts +0 -20
- package/dist/types/codama/mainnet/types/paymentFrequency.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/dist/types/contract/close.d.ts +0 -37
- package/dist/types/contract/close.d.ts.map +0 -1
- package/dist/types/contract/create.d.ts +0 -70
- package/dist/types/contract/create.d.ts.map +0 -1
- package/dist/types/contract/index.d.ts +0 -3
- package/dist/types/contract/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -6
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/network.d.ts +0 -58
- package/dist/types/network.d.ts.map +0 -1
- package/dist/types/rental/accept.d.ts +0 -46
- package/dist/types/rental/accept.d.ts.map +0 -1
- package/dist/types/rental/cancel.d.ts +0 -20
- package/dist/types/rental/cancel.d.ts.map +0 -1
- package/dist/types/rental/close.d.ts +0 -24
- package/dist/types/rental/close.d.ts.map +0 -1
- package/dist/types/rental/index.d.ts +0 -5
- package/dist/types/rental/index.d.ts.map +0 -1
- package/dist/types/rental/reset.d.ts +0 -40
- package/dist/types/rental/reset.d.ts.map +0 -1
- package/dist/types/utils/constants.d.ts +0 -21
- package/dist/types/utils/constants.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -3
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/profiles.d.ts +0 -48
- package/dist/types/utils/profiles.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://solana.com/)
|
|
6
6
|
|
|
7
|
-
A TypeScript SDK for interacting with the SRSLY (Space Rental from SLY) Solana program - a decentralized rental system for Star Atlas.
|
|
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.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -31,14 +31,17 @@ yarn add @wuwei-labs/srsly
|
|
|
31
31
|
```typescript
|
|
32
32
|
import {
|
|
33
33
|
createContract,
|
|
34
|
-
acceptRental,
|
|
35
|
-
|
|
34
|
+
acceptRental,
|
|
35
|
+
setConfig,
|
|
36
|
+
setNetwork,
|
|
37
|
+
ATLAS_TO_STARDUST
|
|
36
38
|
} from '@wuwei-labs/srsly';
|
|
37
39
|
|
|
38
|
-
// Set global
|
|
39
|
-
|
|
40
|
+
// Option 1: Set global configuration (recommended for most apps)
|
|
41
|
+
setConfig({ network: 'mainnet' });
|
|
42
|
+
// or use the convenience function: setNetwork('mainnet');
|
|
40
43
|
|
|
41
|
-
//
|
|
44
|
+
// Now all operations use mainnet by default
|
|
42
45
|
const contractInstruction = await createContract({
|
|
43
46
|
owner: wallet,
|
|
44
47
|
fleet: fleetAddress,
|
|
@@ -46,25 +49,35 @@ const contractInstruction = await createContract({
|
|
|
46
49
|
rate: 1000000, // Rate in ATLAS tokens
|
|
47
50
|
durationMin: 86400, // 1 day in seconds
|
|
48
51
|
durationMax: 604800, // 1 week in seconds
|
|
49
|
-
paymentsFreq: 'daily'
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
52
66
|
|
|
53
|
-
//
|
|
54
|
-
const
|
|
55
|
-
const devnetInstruction = await createContract(params).devnet();
|
|
67
|
+
// Option 2: Override global config for specific instructions
|
|
68
|
+
const devnetInstruction = await createContract(params).set({ network: 'devnet' });
|
|
56
69
|
```
|
|
57
70
|
|
|
58
71
|
## Core Features
|
|
59
72
|
|
|
60
73
|
### Contract Management
|
|
61
74
|
|
|
62
|
-
Create and manage rental contracts for Star Atlas:
|
|
75
|
+
Create and manage rental contracts for Star Atlas fleets:
|
|
63
76
|
|
|
64
77
|
```typescript
|
|
65
78
|
import { createContract, closeContract } from '@wuwei-labs/srsly';
|
|
66
79
|
|
|
67
|
-
// Create a new rental contract with network
|
|
80
|
+
// Create a new rental contract with network configuration
|
|
68
81
|
const createIx = await createContract({
|
|
69
82
|
owner: wallet,
|
|
70
83
|
fleet: fleetAddress,
|
|
@@ -74,60 +87,69 @@ const createIx = await createContract({
|
|
|
74
87
|
durationMax: 2592000, // Maximum 30 days
|
|
75
88
|
paymentsFreq: 'daily',
|
|
76
89
|
ownerKeyIndex: 0
|
|
77
|
-
}).mainnet
|
|
90
|
+
}).set({ network: 'mainnet' }); // Use mainnet configuration
|
|
78
91
|
|
|
79
|
-
// Close an existing contract using
|
|
92
|
+
// Close an existing contract using devnet defaults (direct await)
|
|
80
93
|
const closeIx = await closeContract({
|
|
81
94
|
owner: wallet,
|
|
82
95
|
fleet: fleetAddress,
|
|
83
96
|
contract: contractAddress,
|
|
84
|
-
faction: 'mud',
|
|
85
|
-
ownerProfile: profileAddress
|
|
97
|
+
faction: 'mud' // or faction number: 1, 2, 3
|
|
86
98
|
});
|
|
87
99
|
```
|
|
88
100
|
|
|
89
101
|
### Rental Operations
|
|
90
102
|
|
|
91
|
-
Handle rental lifecycle operations:
|
|
103
|
+
Handle rental lifecycle operations with automatic token conversion:
|
|
92
104
|
|
|
93
105
|
```typescript
|
|
94
106
|
import {
|
|
95
107
|
acceptRental,
|
|
96
108
|
cancelRental,
|
|
97
109
|
closeRental,
|
|
98
|
-
resetRental
|
|
110
|
+
resetRental,
|
|
111
|
+
ATLAS_TO_STARDUST
|
|
99
112
|
} from '@wuwei-labs/srsly';
|
|
100
113
|
|
|
101
|
-
// Accept a rental offer on devnet
|
|
114
|
+
// Accept a rental offer on devnet (rate-based with automatic conversion)
|
|
102
115
|
const acceptIx = await acceptRental({
|
|
103
116
|
borrower: borrowerWallet,
|
|
104
117
|
borrowerProfile: borrowerProfileAddress,
|
|
118
|
+
borrowerFaction: 'oni', // or faction number: 1=mud, 2=oni, 3=ustur
|
|
119
|
+
fleet: fleetAddress,
|
|
105
120
|
contract: contractAddress,
|
|
106
|
-
|
|
107
|
-
duration: 86400
|
|
108
|
-
amount
|
|
109
|
-
}).devnet
|
|
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' });
|
|
110
125
|
|
|
111
|
-
// Cancel an active rental using
|
|
126
|
+
// Cancel an active rental using devnet defaults (direct await)
|
|
112
127
|
const cancelIx = await cancelRental({
|
|
113
128
|
borrower: borrowerWallet,
|
|
114
|
-
|
|
129
|
+
contract: contractAddress,
|
|
130
|
+
rentalState: rentalStateAddress
|
|
115
131
|
});
|
|
116
132
|
|
|
117
133
|
// Close a completed rental on mainnet
|
|
118
134
|
const closeIx = await closeRental({
|
|
119
135
|
borrower: borrowerWallet,
|
|
120
|
-
|
|
121
|
-
|
|
136
|
+
contract: contractAddress,
|
|
137
|
+
rentalState: rentalStateAddress,
|
|
138
|
+
ownerTokenAccount: ownerTokenAccountAddress
|
|
139
|
+
}).set({ network: 'mainnet' });
|
|
122
140
|
|
|
123
|
-
// Reset rental state
|
|
141
|
+
// Reset rental state with custom configuration
|
|
124
142
|
const resetIx = await resetRental({
|
|
125
143
|
fleet: fleetAddress,
|
|
126
144
|
contract: contractAddress,
|
|
127
145
|
rentalState: rentalStateAddress,
|
|
128
146
|
faction: 'mud',
|
|
129
147
|
ownerProfile: ownerProfileAddress
|
|
130
|
-
}).
|
|
148
|
+
}).set({
|
|
149
|
+
network: 'mainnet',
|
|
150
|
+
sageProgramAddress: 'custom...',
|
|
151
|
+
gameId: 'custom...'
|
|
152
|
+
});
|
|
131
153
|
```
|
|
132
154
|
|
|
133
155
|
### Account State Management
|
|
@@ -135,15 +157,15 @@ const resetIx = await resetRental({
|
|
|
135
157
|
Fetch and decode account states using network-specific functions:
|
|
136
158
|
|
|
137
159
|
```typescript
|
|
138
|
-
import { getCachedNetworkModule
|
|
160
|
+
import { getCachedNetworkModule } from '@wuwei-labs/srsly';
|
|
139
161
|
|
|
140
|
-
//
|
|
141
|
-
setNetwork('mainnet');
|
|
142
|
-
|
|
143
|
-
// Get network-specific account functions
|
|
162
|
+
// Get network-specific account functions (defaults to devnet)
|
|
144
163
|
const accountsModule = await getCachedNetworkModule('accounts');
|
|
145
164
|
const { fetchContractState, fetchRentalState } = accountsModule;
|
|
146
165
|
|
|
166
|
+
// Or specify network explicitly
|
|
167
|
+
const mainnetAccountsModule = await getCachedNetworkModule('accounts', 'mainnet');
|
|
168
|
+
|
|
147
169
|
// Fetch contract state
|
|
148
170
|
const contractState = await fetchContractState(rpc, contractPublicKey);
|
|
149
171
|
console.log('Contract rate:', contractState.rate.toString());
|
|
@@ -155,19 +177,259 @@ console.log('Rental status:', rentalState.status);
|
|
|
155
177
|
console.log('Start time:', new Date(rentalState.startTime.toNumber() * 1000));
|
|
156
178
|
```
|
|
157
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
|
+
|
|
158
195
|
## Program Information
|
|
159
196
|
|
|
160
197
|
- **Program ID**: `SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT`
|
|
161
198
|
- **Network**: Solana Mainnet or Atlasnet
|
|
162
199
|
- **Built with**: Anchor Framework
|
|
163
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
|
+
|
|
164
426
|
## Payment Frequencies
|
|
165
427
|
|
|
166
428
|
The SDK supports multiple payment frequencies:
|
|
167
429
|
|
|
168
|
-
- `daily` - Daily payments
|
|
169
|
-
- `weekly` - Weekly payments
|
|
170
|
-
- `monthly` - Monthly payments
|
|
430
|
+
- `daily` - Daily payments at 00:00 UTC
|
|
431
|
+
- `weekly` - Weekly payments at specific day/time
|
|
432
|
+
- `monthly` - Monthly payments at specific day/time
|
|
171
433
|
|
|
172
434
|
## Error Handling
|
|
173
435
|
|
|
@@ -188,67 +450,125 @@ try {
|
|
|
188
450
|
|
|
189
451
|
## Network Configuration
|
|
190
452
|
|
|
191
|
-
The SDK supports both Solana mainnet and devnet with network-specific program configurations. You can
|
|
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.
|
|
192
454
|
|
|
193
|
-
### Global
|
|
455
|
+
### Global Configuration (Recommended)
|
|
194
456
|
|
|
195
|
-
Set
|
|
457
|
+
Set default configuration once for all SDK operations:
|
|
196
458
|
|
|
197
459
|
```typescript
|
|
198
|
-
import { setNetwork,
|
|
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
|
+
});
|
|
199
467
|
|
|
200
|
-
//
|
|
468
|
+
// Option 2: Network-only (convenience function)
|
|
201
469
|
setNetwork('mainnet');
|
|
202
470
|
|
|
203
|
-
// Check current
|
|
204
|
-
console.log(
|
|
471
|
+
// Check current configuration
|
|
472
|
+
console.log(getConfig()); // { network: 'mainnet' }
|
|
205
473
|
|
|
206
|
-
// All
|
|
207
|
-
const
|
|
474
|
+
// All operations now use mainnet by default
|
|
475
|
+
const ix1 = await createContract(params);
|
|
476
|
+
const ix2 = await acceptRental(params);
|
|
208
477
|
```
|
|
209
478
|
|
|
210
|
-
### Per-Instruction
|
|
479
|
+
### Per-Instruction Configuration
|
|
211
480
|
|
|
212
|
-
Override
|
|
481
|
+
Override global configuration for specific instructions using the fluent `.set()` interface:
|
|
213
482
|
|
|
214
483
|
```typescript
|
|
215
|
-
import { createContract } from '@wuwei-labs/srsly';
|
|
484
|
+
import { createContract, acceptRental } from '@wuwei-labs/srsly';
|
|
216
485
|
|
|
217
|
-
//
|
|
218
|
-
|
|
486
|
+
// Assume global config is set to mainnet
|
|
487
|
+
setConfig({ network: 'mainnet' });
|
|
219
488
|
|
|
220
|
-
// Use
|
|
221
|
-
const
|
|
489
|
+
// Use global mainnet config
|
|
490
|
+
const mainnetIx = await createContract(params);
|
|
222
491
|
|
|
223
|
-
//
|
|
224
|
-
const
|
|
492
|
+
// Override to use devnet for this specific instruction
|
|
493
|
+
const devnetIx = await createContract(params).set({ network: 'devnet' });
|
|
225
494
|
|
|
226
|
-
//
|
|
227
|
-
const
|
|
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
|
+
});
|
|
228
501
|
```
|
|
229
502
|
|
|
230
|
-
###
|
|
503
|
+
### Configuration Options
|
|
231
504
|
|
|
232
505
|
All SDK functions support these usage patterns:
|
|
233
506
|
|
|
234
|
-
**Direct await (uses global
|
|
507
|
+
**Direct await (uses global config or devnet fallback):**
|
|
508
|
+
|
|
235
509
|
```typescript
|
|
510
|
+
// Uses global configuration if set, otherwise devnet
|
|
236
511
|
await createContract(params);
|
|
237
512
|
await acceptRental(params);
|
|
238
513
|
```
|
|
239
514
|
|
|
240
|
-
**
|
|
241
|
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
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
|
|
245
544
|
|
|
246
545
|
```typescript
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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' });
|
|
252
572
|
```
|
|
253
573
|
|
|
254
574
|
## IDL and Types
|
|
@@ -279,7 +599,8 @@ import type {
|
|
|
279
599
|
RentalState,
|
|
280
600
|
PaymentFrequency,
|
|
281
601
|
ClockData,
|
|
282
|
-
ThreadResponse
|
|
602
|
+
ThreadResponse,
|
|
603
|
+
ConfigOptions
|
|
283
604
|
} from '@wuwei-labs/srsly';
|
|
284
605
|
|
|
285
606
|
// Import network-specific Anchor types
|
|
@@ -287,6 +608,55 @@ import type { Srsly as SrslyMainnet } from '@wuwei-labs/srsly/types/mainnet';
|
|
|
287
608
|
import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/devnet';
|
|
288
609
|
```
|
|
289
610
|
|
|
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
|
+
|
|
290
660
|
## Documentation
|
|
291
661
|
|
|
292
662
|
- **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
|
|
@@ -295,4 +665,4 @@ import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/devnet';
|
|
|
295
665
|
|
|
296
666
|
- **Star Atlas**: The metaverse gaming ecosystem
|
|
297
667
|
- **Solana**: The blockchain platform powering SRSLY
|
|
298
|
-
- **Anchor**: The framework used to build the SRSLY program
|
|
668
|
+
- **Anchor**: The framework used to build the SRSLY program
|