@wuwei-labs/srsly 2.0.0-beta.13 → 2.0.0-beta.3
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 +102 -641
- package/dist/cjs/codama/devnet/accounts/contractState.js +7 -2
- package/dist/cjs/codama/devnet/accounts/contractState.js.map +1 -1
- package/dist/cjs/codama/devnet/accounts/rentalState.js +1 -3
- package/dist/cjs/codama/devnet/accounts/rentalState.js.map +1 -1
- package/dist/cjs/codama/devnet/errors/srsly.js +1 -4
- package/dist/cjs/codama/devnet/errors/srsly.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/acceptRental.js +23 -17
- package/dist/cjs/codama/devnet/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/closeContract.js +1 -28
- package/dist/cjs/codama/devnet/instructions/closeContract.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/closeRental.js +1 -28
- package/dist/cjs/codama/devnet/instructions/closeRental.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/index.js +1 -0
- package/dist/cjs/codama/devnet/instructions/index.js.map +1 -1
- package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js +152 -0
- package/dist/cjs/codama/devnet/instructions/normalizeAdmin.js.map +1 -0
- package/dist/cjs/codama/devnet/instructions/payRental.js +1 -45
- package/dist/cjs/codama/devnet/instructions/payRental.js.map +1 -1
- package/dist/cjs/codama/devnet/programs/srsly.js +6 -2
- package/dist/cjs/codama/devnet/programs/srsly.js.map +1 -1
- package/dist/cjs/codama/devnet/types/index.js +1 -0
- package/dist/cjs/codama/devnet/types/index.js.map +1 -1
- package/dist/cjs/codama/devnet/types/paymentFrequency.js +34 -0
- package/dist/cjs/codama/devnet/types/paymentFrequency.js.map +1 -0
- package/dist/cjs/contract/close.js +22 -56
- package/dist/cjs/contract/close.js.map +1 -1
- package/dist/cjs/contract/create.js +22 -36
- package/dist/cjs/contract/create.js.map +1 -1
- package/dist/cjs/index.js +2 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/network.js +107 -0
- package/dist/cjs/network.js.map +1 -0
- package/dist/cjs/rental/accept.js +36 -64
- package/dist/cjs/rental/accept.js.map +1 -1
- package/dist/cjs/rental/cancel.js +25 -33
- package/dist/cjs/rental/cancel.js.map +1 -1
- package/dist/cjs/rental/close.js +26 -34
- package/dist/cjs/rental/close.js.map +1 -1
- package/dist/cjs/rental/reset.js +39 -43
- package/dist/cjs/rental/reset.js.map +1 -1
- package/dist/cjs/utils/constants.js +23 -51
- package/dist/cjs/utils/constants.js.map +1 -1
- package/dist/cjs/utils/index.js +0 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/profiles.js +18 -38
- package/dist/cjs/utils/profiles.js.map +1 -1
- package/dist/esm/codama/devnet/accounts/contractState.js +7 -3
- package/dist/esm/codama/devnet/accounts/contractState.js.map +1 -1
- package/dist/esm/codama/devnet/accounts/rentalState.js +1 -3
- package/dist/esm/codama/devnet/accounts/rentalState.js.map +1 -1
- package/dist/esm/codama/devnet/errors/srsly.js +0 -3
- package/dist/esm/codama/devnet/errors/srsly.js.map +1 -1
- package/dist/esm/codama/devnet/instructions/acceptRental.js +23 -17
- package/dist/esm/codama/devnet/instructions/acceptRental.js.map +1 -1
- package/dist/esm/codama/devnet/instructions/closeContract.js +1 -28
- package/dist/esm/codama/devnet/instructions/closeContract.js.map +1 -1
- package/dist/esm/codama/devnet/instructions/closeRental.js +1 -28
- package/dist/esm/codama/devnet/instructions/closeRental.js.map +1 -1
- package/dist/esm/codama/devnet/instructions/index.js +1 -0
- package/dist/esm/codama/devnet/instructions/index.js.map +1 -1
- package/dist/esm/codama/{atlasnet/instructions/resetRental.js → devnet/instructions/normalizeAdmin.js} +58 -61
- package/dist/esm/codama/devnet/instructions/normalizeAdmin.js.map +1 -0
- package/dist/esm/codama/devnet/instructions/payRental.js +1 -45
- package/dist/esm/codama/devnet/instructions/payRental.js.map +1 -1
- package/dist/esm/codama/devnet/programs/srsly.js +6 -2
- package/dist/esm/codama/devnet/programs/srsly.js.map +1 -1
- package/dist/esm/codama/devnet/types/index.js +1 -0
- package/dist/esm/codama/devnet/types/index.js.map +1 -1
- package/dist/esm/codama/devnet/types/paymentFrequency.js +28 -0
- package/dist/esm/codama/devnet/types/paymentFrequency.js.map +1 -0
- package/dist/esm/contract/close.js +23 -57
- package/dist/esm/contract/close.js.map +1 -1
- package/dist/esm/contract/create.js +22 -36
- package/dist/esm/contract/create.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/network.js +67 -0
- package/dist/esm/network.js.map +1 -0
- package/dist/esm/rental/accept.js +37 -65
- package/dist/esm/rental/accept.js.map +1 -1
- package/dist/esm/rental/cancel.js +25 -33
- package/dist/esm/rental/cancel.js.map +1 -1
- package/dist/esm/rental/close.js +26 -34
- package/dist/esm/rental/close.js.map +1 -1
- package/dist/esm/rental/reset.js +40 -44
- package/dist/esm/rental/reset.js.map +1 -1
- package/dist/esm/utils/constants.js +21 -47
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/index.js +0 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/profiles.js +19 -39
- package/dist/esm/utils/profiles.js.map +1 -1
- package/dist/types/codama/devnet/accounts/contractState.d.ts +4 -2
- package/dist/types/codama/devnet/accounts/contractState.d.ts.map +1 -1
- package/dist/types/codama/devnet/accounts/rentalState.d.ts +0 -2
- package/dist/types/codama/devnet/accounts/rentalState.d.ts.map +1 -1
- package/dist/types/codama/devnet/errors/srsly.d.ts +1 -3
- package/dist/types/codama/devnet/errors/srsly.d.ts.map +1 -1
- package/dist/types/codama/devnet/instructions/acceptRental.d.ts +11 -14
- package/dist/types/codama/devnet/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/codama/devnet/instructions/closeContract.d.ts +8 -12
- package/dist/types/codama/devnet/instructions/closeContract.d.ts.map +1 -1
- package/dist/types/codama/devnet/instructions/closeRental.d.ts +11 -15
- package/dist/types/codama/devnet/instructions/closeRental.d.ts.map +1 -1
- package/dist/types/codama/devnet/instructions/index.d.ts +1 -0
- package/dist/types/codama/devnet/instructions/index.d.ts.map +1 -1
- package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts +67 -0
- package/dist/types/codama/devnet/instructions/normalizeAdmin.d.ts.map +1 -0
- package/dist/types/codama/devnet/instructions/payRental.d.ts +10 -21
- package/dist/types/codama/devnet/instructions/payRental.d.ts.map +1 -1
- package/dist/types/codama/devnet/programs/srsly.d.ts +6 -3
- package/dist/types/codama/devnet/programs/srsly.d.ts.map +1 -1
- package/dist/types/codama/devnet/types/index.d.ts +1 -0
- package/dist/types/codama/devnet/types/index.d.ts.map +1 -1
- package/dist/types/codama/devnet/types/paymentFrequency.d.ts +22 -0
- package/dist/types/codama/devnet/types/paymentFrequency.d.ts.map +1 -0
- package/dist/types/contract/close.d.ts +5 -20
- package/dist/types/contract/close.d.ts.map +1 -1
- package/dist/types/contract/create.d.ts +13 -23
- package/dist/types/contract/create.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/network.d.ts +58 -0
- package/dist/types/network.d.ts.map +1 -0
- package/dist/types/rental/accept.d.ts +6 -52
- package/dist/types/rental/accept.d.ts.map +1 -1
- package/dist/types/rental/cancel.d.ts +3 -27
- package/dist/types/rental/cancel.d.ts.map +1 -1
- package/dist/types/rental/close.d.ts +3 -28
- package/dist/types/rental/close.d.ts.map +1 -1
- package/dist/types/rental/reset.d.ts +4 -32
- package/dist/types/rental/reset.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +9 -19
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +0 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/profiles.d.ts +8 -14
- package/dist/types/utils/profiles.d.ts.map +1 -1
- package/package.json +18 -21
- package/target/idl/{srsly-atlasnet.json → srsly-devnet.json} +334 -592
- package/target/idl/srsly-mainnet.json +229 -493
- package/dist/cjs/codama/atlasnet/accounts/contractState.js +0 -87
- package/dist/cjs/codama/atlasnet/accounts/contractState.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/fleet.js +0 -77
- package/dist/cjs/codama/atlasnet/accounts/fleet.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/index.js +0 -28
- package/dist/cjs/codama/atlasnet/accounts/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/rentalState.js +0 -87
- package/dist/cjs/codama/atlasnet/accounts/rentalState.js.map +0 -1
- package/dist/cjs/codama/atlasnet/accounts/thread.js +0 -89
- package/dist/cjs/codama/atlasnet/accounts/thread.js.map +0 -1
- package/dist/cjs/codama/atlasnet/errors/index.js +0 -25
- 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 +0 -29
- package/dist/cjs/codama/atlasnet/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/acceptRental.js +0 -357
- 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 -246
- 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 +0 -261
- 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 -280
- package/dist/cjs/codama/atlasnet/instructions/payRental.js.map +0 -1
- package/dist/cjs/codama/atlasnet/instructions/resetRental.js +0 -155
- package/dist/cjs/codama/atlasnet/instructions/resetRental.js.map +0 -1
- package/dist/cjs/codama/atlasnet/programs/index.js +0 -25
- package/dist/cjs/codama/atlasnet/programs/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/programs/srsly.js +0 -73
- package/dist/cjs/codama/atlasnet/programs/srsly.js.map +0 -1
- package/dist/cjs/codama/atlasnet/shared/index.js +0 -95
- package/dist/cjs/codama/atlasnet/shared/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/clockData.js +0 -31
- package/dist/cjs/codama/atlasnet/types/clockData.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/equality.js +0 -30
- package/dist/cjs/codama/atlasnet/types/equality.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/execContext.js +0 -38
- package/dist/cjs/codama/atlasnet/types/execContext.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/index.js +0 -32
- package/dist/cjs/codama/atlasnet/types/index.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/serializableAccount.js +0 -31
- package/dist/cjs/codama/atlasnet/types/serializableAccount.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/serializableInstruction.js +0 -32
- package/dist/cjs/codama/atlasnet/types/serializableInstruction.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/threadResponse.js +0 -38
- package/dist/cjs/codama/atlasnet/types/threadResponse.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/trigger.js +0 -90
- package/dist/cjs/codama/atlasnet/types/trigger.js.map +0 -1
- package/dist/cjs/codama/atlasnet/types/triggerContext.js +0 -49
- package/dist/cjs/codama/atlasnet/types/triggerContext.js.map +0 -1
- package/dist/cjs/codama/devnet/constants.js +0 -32
- package/dist/cjs/codama/devnet/constants.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 +0 -74
- 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 -357
- package/dist/cjs/codama/mainnet/instructions/acceptRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/cancelRental.js +0 -225
- package/dist/cjs/codama/mainnet/instructions/cancelRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/closeContract.js +0 -246
- package/dist/cjs/codama/mainnet/instructions/closeContract.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/closeRental.js +0 -260
- package/dist/cjs/codama/mainnet/instructions/closeRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/createContract.js +0 -261
- package/dist/cjs/codama/mainnet/instructions/createContract.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/index.js +0 -31
- package/dist/cjs/codama/mainnet/instructions/index.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/payRental.js +0 -280
- package/dist/cjs/codama/mainnet/instructions/payRental.js.map +0 -1
- package/dist/cjs/codama/mainnet/instructions/resetRental.js +0 -155
- 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/cjs/package.json +0 -58
- package/dist/cjs/utils/config.js +0 -232
- package/dist/cjs/utils/config.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/contractState.js +0 -75
- package/dist/esm/codama/atlasnet/accounts/contractState.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/fleet.js +0 -64
- package/dist/esm/codama/atlasnet/accounts/fleet.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/index.js +0 -12
- package/dist/esm/codama/atlasnet/accounts/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/rentalState.js +0 -74
- package/dist/esm/codama/atlasnet/accounts/rentalState.js.map +0 -1
- package/dist/esm/codama/atlasnet/accounts/thread.js +0 -77
- package/dist/esm/codama/atlasnet/accounts/thread.js.map +0 -1
- package/dist/esm/codama/atlasnet/errors/index.js +0 -9
- package/dist/esm/codama/atlasnet/errors/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/errors/srsly.js +0 -69
- package/dist/esm/codama/atlasnet/errors/srsly.js.map +0 -1
- package/dist/esm/codama/atlasnet/index.js +0 -13
- package/dist/esm/codama/atlasnet/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/instructions/acceptRental.js +0 -347
- 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 -236
- 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 -251
- 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 -270
- 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 +0 -9
- package/dist/esm/codama/atlasnet/programs/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/programs/srsly.js +0 -68
- package/dist/esm/codama/atlasnet/programs/srsly.js.map +0 -1
- package/dist/esm/codama/atlasnet/shared/index.js +0 -87
- package/dist/esm/codama/atlasnet/shared/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/clockData.js +0 -26
- package/dist/esm/codama/atlasnet/types/clockData.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/equality.js +0 -24
- package/dist/esm/codama/atlasnet/types/equality.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/execContext.js +0 -33
- package/dist/esm/codama/atlasnet/types/execContext.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/index.js +0 -16
- package/dist/esm/codama/atlasnet/types/index.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/serializableAccount.js +0 -26
- package/dist/esm/codama/atlasnet/types/serializableAccount.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/serializableInstruction.js +0 -27
- package/dist/esm/codama/atlasnet/types/serializableInstruction.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/threadResponse.js +0 -33
- package/dist/esm/codama/atlasnet/types/threadResponse.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/trigger.js +0 -83
- package/dist/esm/codama/atlasnet/types/trigger.js.map +0 -1
- package/dist/esm/codama/atlasnet/types/triggerContext.js +0 -42
- package/dist/esm/codama/atlasnet/types/triggerContext.js.map +0 -1
- package/dist/esm/codama/devnet/constants.js +0 -29
- package/dist/esm/codama/devnet/constants.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 -347
- 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 -236
- package/dist/esm/codama/mainnet/instructions/closeContract.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/closeRental.js +0 -250
- 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 -15
- package/dist/esm/codama/mainnet/instructions/index.js.map +0 -1
- package/dist/esm/codama/mainnet/instructions/payRental.js +0 -270
- 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 -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/esm/package.json +0 -58
- package/dist/esm/utils/config.js +0 -190
- package/dist/esm/utils/config.js.map +0 -1
- package/dist/types/codama/atlasnet/accounts/contractState.d.ts +0 -51
- package/dist/types/codama/atlasnet/accounts/contractState.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/fleet.d.ts +0 -38
- package/dist/types/codama/atlasnet/accounts/fleet.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/index.d.ts +0 -12
- package/dist/types/codama/atlasnet/accounts/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/rentalState.d.ts +0 -48
- package/dist/types/codama/atlasnet/accounts/rentalState.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/accounts/thread.d.ts +0 -74
- package/dist/types/codama/atlasnet/accounts/thread.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/errors/index.d.ts +0 -9
- package/dist/types/codama/atlasnet/errors/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/errors/srsly.d.ts +0 -50
- package/dist/types/codama/atlasnet/errors/srsly.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/index.d.ts +0 -13
- package/dist/types/codama/atlasnet/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/acceptRental.d.ts +0 -131
- 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 +0 -100
- 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 +0 -108
- package/dist/types/codama/atlasnet/instructions/createContract.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/index.d.ts +0 -15
- package/dist/types/codama/atlasnet/instructions/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/payRental.d.ts +0 -110
- package/dist/types/codama/atlasnet/instructions/payRental.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/instructions/resetRental.d.ts +0 -71
- package/dist/types/codama/atlasnet/instructions/resetRental.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/programs/index.d.ts +0 -9
- 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 +0 -50
- package/dist/types/codama/atlasnet/shared/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/clockData.d.ts +0 -29
- package/dist/types/codama/atlasnet/types/clockData.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/equality.d.ts +0 -18
- package/dist/types/codama/atlasnet/types/equality.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/execContext.d.ts +0 -48
- package/dist/types/codama/atlasnet/types/execContext.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/index.d.ts +0 -16
- package/dist/types/codama/atlasnet/types/index.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/serializableAccount.d.ts +0 -22
- package/dist/types/codama/atlasnet/types/serializableAccount.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/serializableInstruction.d.ts +0 -30
- package/dist/types/codama/atlasnet/types/serializableInstruction.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/threadResponse.d.ts +0 -42
- package/dist/types/codama/atlasnet/types/threadResponse.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/trigger.d.ts +0 -98
- package/dist/types/codama/atlasnet/types/trigger.d.ts.map +0 -1
- package/dist/types/codama/atlasnet/types/triggerContext.d.ts +0 -75
- package/dist/types/codama/atlasnet/types/triggerContext.d.ts.map +0 -1
- package/dist/types/codama/devnet/constants.d.ts +0 -34
- package/dist/types/codama/devnet/constants.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 +0 -71
- 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 +0 -83
- 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 +0 -47
- 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/dist/types/utils/config.d.ts +0 -117
- package/dist/types/utils/config.d.ts.map +0 -1
- /package/target/types/{srsly-atlasnet.ts → srsly-devnet.ts} +0 -0
package/README.md
CHANGED
|
@@ -4,25 +4,7 @@
|
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://solana.com/)
|
|
6
6
|
|
|
7
|
-
A TypeScript SDK for
|
|
8
|
-
|
|
9
|
-
## What This SDK Does
|
|
10
|
-
|
|
11
|
-
The SRSLY SDK is an **instruction builder** that helps you create properly formatted Solana instructions for the SRSLY rental program. It handles:
|
|
12
|
-
|
|
13
|
-
- ✅ Network-specific program addresses and configurations
|
|
14
|
-
- ✅ Account derivation and validation
|
|
15
|
-
- ✅ Instruction data encoding
|
|
16
|
-
- ✅ Type-safe parameter handling
|
|
17
|
-
|
|
18
|
-
## What You Need to Provide
|
|
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
|
|
7
|
+
A TypeScript SDK for interacting with the SRSLY (Space Rental from SLY) Solana program - a decentralized rental system for Star Atlas.
|
|
26
8
|
|
|
27
9
|
## Installation
|
|
28
10
|
|
|
@@ -47,666 +29,226 @@ yarn add @wuwei-labs/srsly
|
|
|
47
29
|
## Quick Start
|
|
48
30
|
|
|
49
31
|
```typescript
|
|
32
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
50
33
|
import {
|
|
51
34
|
createContract,
|
|
52
|
-
|
|
35
|
+
acceptRental,
|
|
36
|
+
setNetwork,
|
|
37
|
+
ContractState,
|
|
38
|
+
RentalState
|
|
53
39
|
} from '@wuwei-labs/srsly';
|
|
54
40
|
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
41
|
+
// Set global network (optional - defaults to devnet)
|
|
42
|
+
setNetwork('mainnet');
|
|
69
43
|
|
|
70
|
-
//
|
|
71
|
-
setConfig({ network: 'atlasnet' });
|
|
72
|
-
|
|
73
|
-
// Step 4: Build the instruction using SRSLY SDK
|
|
44
|
+
// Create a rental contract using global network setting (direct await)
|
|
74
45
|
const contractInstruction = await createContract({
|
|
75
|
-
owner: wallet
|
|
46
|
+
owner: wallet,
|
|
76
47
|
fleet: fleetAddress,
|
|
77
48
|
ownerProfile: profileAddress,
|
|
78
|
-
rate: 1000000, // Rate in
|
|
49
|
+
rate: 1000000, // Rate in lamports
|
|
79
50
|
durationMin: 86400, // 1 day in seconds
|
|
80
51
|
durationMax: 604800, // 1 week in seconds
|
|
81
52
|
paymentsFreq: 'daily',
|
|
82
53
|
ownerKeyIndex: 0
|
|
83
54
|
});
|
|
84
55
|
|
|
85
|
-
//
|
|
86
|
-
const
|
|
87
|
-
|
|
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);
|
|
56
|
+
// Or override network for specific instruction
|
|
57
|
+
const mainnetInstruction = await createContract(params).mainnet();
|
|
58
|
+
const devnetInstruction = await createContract(params).devnet();
|
|
94
59
|
```
|
|
95
60
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
import { Connection, Transaction } from '@solana/web3.js';
|
|
100
|
-
|
|
101
|
-
const connection = new Connection('https://api.atlasnet.solana.com');
|
|
102
|
-
const transaction = new Transaction().add(contractInstruction);
|
|
103
|
-
|
|
104
|
-
// Sign and send with wallet extension
|
|
105
|
-
const signature = await window.solana.signAndSendTransaction(transaction);
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
> **Note**: The SRSLY SDK only creates instructions. You're responsible for:
|
|
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`).
|
|
61
|
+
## Core Features
|
|
119
62
|
|
|
120
63
|
### Contract Management
|
|
121
64
|
|
|
122
|
-
Create and manage rental contracts for Star Atlas
|
|
65
|
+
Create and manage rental contracts for Star Atlas:
|
|
123
66
|
|
|
124
67
|
```typescript
|
|
125
68
|
import { createContract, closeContract } from '@wuwei-labs/srsly';
|
|
126
69
|
|
|
127
|
-
// Create a new rental contract with network
|
|
70
|
+
// Create a new rental contract with network selection
|
|
128
71
|
const createIx = await createContract({
|
|
129
72
|
owner: wallet,
|
|
130
73
|
fleet: fleetAddress,
|
|
131
74
|
ownerProfile: profileAddress,
|
|
132
|
-
rate: 5000000, //
|
|
75
|
+
rate: 5000000, // 0.005 SOL per day
|
|
133
76
|
durationMin: 86400, // Minimum 1 day
|
|
134
77
|
durationMax: 2592000, // Maximum 30 days
|
|
135
78
|
paymentsFreq: 'daily',
|
|
136
79
|
ownerKeyIndex: 0
|
|
137
|
-
}).
|
|
80
|
+
}).mainnet(); // Use mainnet for this instruction
|
|
138
81
|
|
|
139
|
-
// Close an existing contract using
|
|
82
|
+
// Close an existing contract using global network setting (direct await)
|
|
140
83
|
const closeIx = await closeContract({
|
|
141
84
|
owner: wallet,
|
|
142
85
|
fleet: fleetAddress,
|
|
143
86
|
contract: contractAddress,
|
|
144
|
-
faction: 'mud'
|
|
87
|
+
faction: 'mud',
|
|
88
|
+
ownerProfile: profileAddress
|
|
145
89
|
});
|
|
146
90
|
```
|
|
147
91
|
|
|
148
92
|
### Rental Operations
|
|
149
93
|
|
|
150
|
-
Handle rental lifecycle operations
|
|
94
|
+
Handle rental lifecycle operations:
|
|
151
95
|
|
|
152
96
|
```typescript
|
|
153
97
|
import {
|
|
154
98
|
acceptRental,
|
|
155
99
|
cancelRental,
|
|
156
100
|
closeRental,
|
|
157
|
-
resetRental
|
|
158
|
-
ATLAS_TO_STARDUST
|
|
101
|
+
resetRental
|
|
159
102
|
} from '@wuwei-labs/srsly';
|
|
160
103
|
|
|
161
|
-
// Accept a rental offer on
|
|
104
|
+
// Accept a rental offer on devnet
|
|
162
105
|
const acceptIx = await acceptRental({
|
|
163
106
|
borrower: borrowerWallet,
|
|
164
107
|
borrowerProfile: borrowerProfileAddress,
|
|
165
|
-
borrowerFaction: 'oni', // or faction number: 1=mud, 2=oni, 3=ustur
|
|
166
|
-
fleet: fleetAddress,
|
|
167
108
|
contract: contractAddress,
|
|
168
|
-
|
|
169
|
-
duration: 86400
|
|
170
|
-
|
|
171
|
-
}).
|
|
109
|
+
borrowerFaction: 'oni',
|
|
110
|
+
duration: 86400,
|
|
111
|
+
amount: 1000000
|
|
112
|
+
}).devnet();
|
|
172
113
|
|
|
173
|
-
// Cancel an active rental using
|
|
114
|
+
// Cancel an active rental using current network setting (direct await)
|
|
174
115
|
const cancelIx = await cancelRental({
|
|
175
116
|
borrower: borrowerWallet,
|
|
176
|
-
|
|
177
|
-
rentalState: rentalStateAddress
|
|
117
|
+
rental: rentalAddress
|
|
178
118
|
});
|
|
179
119
|
|
|
180
120
|
// Close a completed rental on mainnet
|
|
181
121
|
const closeIx = await closeRental({
|
|
182
122
|
borrower: borrowerWallet,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
ownerTokenAccount: ownerTokenAccountAddress
|
|
186
|
-
}).set({ network: 'mainnet' });
|
|
123
|
+
rental: rentalAddress
|
|
124
|
+
}).mainnet();
|
|
187
125
|
|
|
188
|
-
// Reset rental state with
|
|
126
|
+
// Reset rental state (admin only) with specific network
|
|
189
127
|
const resetIx = await resetRental({
|
|
190
128
|
fleet: fleetAddress,
|
|
191
129
|
contract: contractAddress,
|
|
192
130
|
rentalState: rentalStateAddress,
|
|
193
131
|
faction: 'mud',
|
|
194
132
|
ownerProfile: ownerProfileAddress
|
|
195
|
-
}).
|
|
196
|
-
network: 'mainnet',
|
|
197
|
-
sageProgramAddress: 'custom...',
|
|
198
|
-
gameId: 'custom...'
|
|
199
|
-
});
|
|
133
|
+
}).network('mainnet');
|
|
200
134
|
```
|
|
201
135
|
|
|
202
136
|
### Account State Management
|
|
203
137
|
|
|
204
|
-
Fetch and decode account states
|
|
138
|
+
Fetch and decode account states:
|
|
205
139
|
|
|
206
140
|
```typescript
|
|
207
|
-
import {
|
|
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');
|
|
141
|
+
import { ContractState, RentalState } from '@wuwei-labs/srsly';
|
|
215
142
|
|
|
216
143
|
// Fetch contract state
|
|
217
|
-
const
|
|
144
|
+
const contractAccount = await connection.getAccountInfo(contractPublicKey);
|
|
145
|
+
const contractState = ContractState.fromAccountInfo(contractAccount)[0];
|
|
146
|
+
|
|
218
147
|
console.log('Contract rate:', contractState.rate.toString());
|
|
219
148
|
console.log('Duration range:', contractState.durationMin.toString(), '-', contractState.durationMax.toString());
|
|
220
149
|
|
|
221
150
|
// Fetch rental state
|
|
222
|
-
const
|
|
151
|
+
const rentalAccount = await connection.getAccountInfo(rentalPublicKey);
|
|
152
|
+
const rentalState = RentalState.fromAccountInfo(rentalAccount)[0];
|
|
153
|
+
|
|
223
154
|
console.log('Rental status:', rentalState.status);
|
|
224
155
|
console.log('Start time:', new Date(rentalState.startTime.toNumber() * 1000));
|
|
225
156
|
```
|
|
226
157
|
|
|
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
158
|
## Program Information
|
|
262
159
|
|
|
263
160
|
- **Program ID**: `SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT`
|
|
264
161
|
- **Network**: Solana Mainnet or Atlasnet
|
|
265
162
|
- **Built with**: Anchor Framework
|
|
266
163
|
|
|
267
|
-
## Payment
|
|
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:**
|
|
164
|
+
## Payment Frequencies
|
|
388
165
|
|
|
389
|
-
|
|
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
|
-
```
|
|
166
|
+
The SDK supports multiple payment frequencies:
|
|
402
167
|
|
|
403
|
-
|
|
168
|
+
- `daily` - Daily payments
|
|
169
|
+
- `weekly` - Weekly payments
|
|
170
|
+
- `monthly` - Monthly payments
|
|
404
171
|
|
|
405
|
-
|
|
172
|
+
## Error Handling
|
|
406
173
|
|
|
407
|
-
|
|
174
|
+
The SDK includes comprehensive error types:
|
|
408
175
|
|
|
409
176
|
```typescript
|
|
410
|
-
|
|
411
|
-
borrower: wallet,
|
|
412
|
-
contract: contractAddress,
|
|
413
|
-
rentalState: rentalStateAddress
|
|
414
|
-
});
|
|
415
|
-
```
|
|
177
|
+
import { SrslyError } from '@wuwei-labs/srsly';
|
|
416
178
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
|
179
|
+
try {
|
|
180
|
+
const instruction = await createContract({...});
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (error instanceof SrslyError) {
|
|
183
|
+
console.error('SRSLY Error:', error.message);
|
|
184
|
+
console.error('Error code:', error.code);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
467
187
|
```
|
|
468
188
|
|
|
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
189
|
## Network Configuration
|
|
502
190
|
|
|
503
|
-
The SDK supports both Solana mainnet and
|
|
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
|
|
191
|
+
The SDK supports both Solana mainnet and devnet with network-specific program configurations. You can configure networks globally or per instruction.
|
|
522
192
|
|
|
523
|
-
### Global Configuration
|
|
193
|
+
### Global Network Configuration
|
|
524
194
|
|
|
525
|
-
Set default
|
|
195
|
+
Set the default network for all SDK operations:
|
|
526
196
|
|
|
527
197
|
```typescript
|
|
528
|
-
import {
|
|
198
|
+
import { setNetwork, getNetwork } from '@wuwei-labs/srsly';
|
|
529
199
|
|
|
530
|
-
//
|
|
531
|
-
|
|
532
|
-
network: 'mainnet'
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
// Example 2: Use atlasnet IDL with default atlasnet program addresses
|
|
536
|
-
setConfig({
|
|
537
|
-
network: 'atlasnet'
|
|
538
|
-
});
|
|
200
|
+
// Set global network (defaults to 'devnet')
|
|
201
|
+
setNetwork('mainnet');
|
|
539
202
|
|
|
540
|
-
//
|
|
541
|
-
|
|
542
|
-
network: 'atlasnet',
|
|
543
|
-
programs: 'holosim'
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
// Example 4: Use atlasnet IDL with holosim programs but custom SAGE
|
|
547
|
-
setConfig({
|
|
548
|
-
network: 'atlasnet',
|
|
549
|
-
programs: 'holosim',
|
|
550
|
-
sageProgramAddress: 'custom-sage-program-id...'
|
|
551
|
-
});
|
|
203
|
+
// Check current network
|
|
204
|
+
console.log(getNetwork()); // 'mainnet'
|
|
552
205
|
|
|
553
|
-
//
|
|
554
|
-
|
|
555
|
-
network: 'mainnet',
|
|
556
|
-
programs: 'atlasnet'
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
// Example 6: Custom overrides only
|
|
560
|
-
setConfig({
|
|
561
|
-
network: 'atlasnet',
|
|
562
|
-
srslyProgramAddress: 'custom-srsly-program-id...',
|
|
563
|
-
sageProgramAddress: 'custom-sage-program-id...',
|
|
564
|
-
gameId: 'custom-game-id...'
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
// Check current configuration
|
|
568
|
-
console.log(getConfig());
|
|
569
|
-
|
|
570
|
-
// All operations now use configured settings
|
|
571
|
-
const ix1 = await createContract(params); // Uses configured SRSLY program
|
|
572
|
-
const ix2 = await acceptRental(params); // Uses configured SAGE program
|
|
206
|
+
// All instructions will now use mainnet by default (direct await)
|
|
207
|
+
const ix = await createContract(params);
|
|
573
208
|
```
|
|
574
209
|
|
|
575
|
-
### Per-Instruction
|
|
210
|
+
### Per-Instruction Network Selection
|
|
576
211
|
|
|
577
|
-
Override
|
|
212
|
+
Override the network for specific instructions using the fluent interface:
|
|
578
213
|
|
|
579
214
|
```typescript
|
|
580
|
-
import { createContract
|
|
215
|
+
import { createContract } from '@wuwei-labs/srsly';
|
|
581
216
|
|
|
582
|
-
//
|
|
583
|
-
|
|
217
|
+
// Use mainnet for this specific instruction
|
|
218
|
+
const mainnetIx = await createContract(params).mainnet();
|
|
584
219
|
|
|
585
|
-
// Use
|
|
586
|
-
const
|
|
220
|
+
// Use devnet for this specific instruction
|
|
221
|
+
const devnetIx = await createContract(params).devnet();
|
|
587
222
|
|
|
588
|
-
//
|
|
589
|
-
const
|
|
223
|
+
// Use a specific network
|
|
224
|
+
const specificIx = await createContract(params).network('mainnet');
|
|
590
225
|
|
|
591
|
-
//
|
|
592
|
-
const
|
|
593
|
-
sageProgramAddress: 'custom-sage-program-id...',
|
|
594
|
-
gameId: 'custom-game-id...'
|
|
595
|
-
// network: 'mainnet' inherited from global config
|
|
596
|
-
});
|
|
226
|
+
// Use global network setting (direct await - no .build() needed!)
|
|
227
|
+
const globalIx = await createContract(params);
|
|
597
228
|
```
|
|
598
229
|
|
|
599
|
-
###
|
|
230
|
+
### Network Selection Methods
|
|
600
231
|
|
|
601
232
|
All SDK functions support these usage patterns:
|
|
602
233
|
|
|
603
|
-
**Direct await (uses global
|
|
604
|
-
|
|
234
|
+
**Direct await (uses global network):**
|
|
605
235
|
```typescript
|
|
606
|
-
// Uses global program addresses if set, otherwise atlasnet programs
|
|
607
236
|
await createContract(params);
|
|
608
237
|
await acceptRental(params);
|
|
609
238
|
```
|
|
610
239
|
|
|
611
|
-
**
|
|
612
|
-
|
|
613
|
-
-
|
|
614
|
-
-
|
|
615
|
-
-
|
|
616
|
-
|
|
617
|
-
**Per-instruction overrides with `.set()` method:**
|
|
618
|
-
|
|
619
|
-
- `.set({ network: 'mainnet' })` - Override to mainnet program addresses
|
|
620
|
-
- `.set({ sageProgramAddress: '...' })` - Override specific program address only
|
|
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
|
|
639
|
-
|
|
640
|
-
```typescript
|
|
641
|
-
interface ConfigOptions {
|
|
642
|
-
network?: 'mainnet' | 'atlasnet'; // Which IDL artifacts to use
|
|
643
|
-
programs?: 'mainnet' | 'atlasnet' | 'holosim'; // Which program address set to use
|
|
644
|
-
srslyProgramAddress?: string; // Override SRSLY program address
|
|
645
|
-
sageProgramAddress?: string; // Override SAGE program address
|
|
646
|
-
profileFactionProgramAddress?: string; // Override Profile Faction program address
|
|
647
|
-
gameId?: string; // Override SAGE game ID
|
|
648
|
-
}
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
**Available Program Address Sets:**
|
|
652
|
-
|
|
653
|
-
```typescript
|
|
654
|
-
// mainnet
|
|
655
|
-
{
|
|
656
|
-
srslyProgram: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT',
|
|
657
|
-
sageProgram: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
658
|
-
profileFactionProgram: 'pFACSRuobDmvfMKq1bAzwj27t6d2GJhSCHb1VcfnRmq',
|
|
659
|
-
gameId: 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr'
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
// atlasnet (default) - values currently empty, to be filled
|
|
663
|
-
{
|
|
664
|
-
srslyProgram: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT',
|
|
665
|
-
sageProgram: '',
|
|
666
|
-
profileFactionProgram: '',
|
|
667
|
-
gameId: ''
|
|
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:
|
|
240
|
+
**Network-specific methods:**
|
|
241
|
+
- `.mainnet()` - Build with mainnet configuration
|
|
242
|
+
- `.devnet()` - Build with devnet configuration
|
|
243
|
+
- `.network(network)` - Build with specified network
|
|
244
|
+
- `.build()` - Build with current global network setting (explicit)
|
|
695
245
|
|
|
696
246
|
```typescript
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
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' });
|
|
247
|
+
// Examples across different functions
|
|
248
|
+
await createContract(params).mainnet();
|
|
249
|
+
await acceptRental(params).devnet();
|
|
250
|
+
await closeContract(params).network('mainnet');
|
|
251
|
+
await resetRental(params); // Direct await uses global network
|
|
710
252
|
```
|
|
711
253
|
|
|
712
254
|
## IDL and Types
|
|
@@ -720,7 +262,7 @@ The SDK provides network-specific IDLs since program configurations differ betwe
|
|
|
720
262
|
import mainnetIdl from '@wuwei-labs/srsly/idl/mainnet';
|
|
721
263
|
|
|
722
264
|
// Devnet IDL
|
|
723
|
-
import
|
|
265
|
+
import devnetIdl from '@wuwei-labs/srsly/idl/devnet';
|
|
724
266
|
|
|
725
267
|
// Use with Anchor
|
|
726
268
|
import { Program } from '@coral-xyz/anchor';
|
|
@@ -737,107 +279,26 @@ import type {
|
|
|
737
279
|
RentalState,
|
|
738
280
|
PaymentFrequency,
|
|
739
281
|
ClockData,
|
|
740
|
-
ThreadResponse
|
|
741
|
-
ConfigOptions
|
|
282
|
+
ThreadResponse
|
|
742
283
|
} from '@wuwei-labs/srsly';
|
|
743
284
|
|
|
744
285
|
// Import network-specific Anchor types
|
|
745
286
|
import type { Srsly as SrslyMainnet } from '@wuwei-labs/srsly/types/mainnet';
|
|
746
|
-
import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/
|
|
287
|
+
import type { Srsly as SrslyDevnet } from '@wuwei-labs/srsly/types/devnet';
|
|
747
288
|
```
|
|
748
289
|
|
|
749
|
-
|
|
290
|
+
### Building Network-Specific Assets
|
|
750
291
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
```typescript
|
|
754
|
-
import {
|
|
755
|
-
ATLAS_TO_STARDUST,
|
|
756
|
-
STARBASE_SEED,
|
|
757
|
-
STARBASE_PLAYER_SEED,
|
|
758
|
-
SAGE_PLAYER_PROFILE_SEED,
|
|
759
|
-
PROFILE_FACTION_SEED,
|
|
760
|
-
FACTION_MAPPING,
|
|
761
|
-
FACTION_SPECIFIC_CSS
|
|
762
|
-
} from '@wuwei-labs/srsly';
|
|
763
|
-
|
|
764
|
-
// Token conversion
|
|
765
|
-
console.log(ATLAS_TO_STARDUST); // 100_000_000
|
|
766
|
-
|
|
767
|
-
// Faction mappings
|
|
768
|
-
console.log(FACTION_MAPPING[1]); // 'mud'
|
|
769
|
-
console.log(FACTION_MAPPING[2]); // 'oni'
|
|
770
|
-
console.log(FACTION_MAPPING[3]); // 'ustur'
|
|
771
|
-
```
|
|
772
|
-
|
|
773
|
-
### Profile Derivation
|
|
774
|
-
|
|
775
|
-
```typescript
|
|
776
|
-
import {
|
|
777
|
-
deriveProfileFaction,
|
|
778
|
-
deriveSagePlayerProfile,
|
|
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
|
-
);
|
|
796
|
-
```
|
|
797
|
-
|
|
798
|
-
## Webpack Compatibility
|
|
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
|
|
292
|
+
To generate IDLs and types for different networks:
|
|
820
293
|
|
|
821
294
|
```bash
|
|
822
|
-
#
|
|
823
|
-
|
|
295
|
+
# Generate mainnet IDL and types
|
|
296
|
+
pnpm run generate:mainnet
|
|
824
297
|
|
|
825
|
-
#
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
# Test actual pnpm package installation with webpack bundling
|
|
829
|
-
npm run test:pnpm-install
|
|
830
|
-
|
|
831
|
-
# Test both package managers
|
|
832
|
-
npm run test:package-managers
|
|
298
|
+
# Generate devnet IDL and types
|
|
299
|
+
pnpm run generate:devnet
|
|
833
300
|
```
|
|
834
301
|
|
|
835
|
-
These commands test different aspects:
|
|
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
|
|
840
|
-
|
|
841
302
|
## Documentation
|
|
842
303
|
|
|
843
304
|
- **TypeDoc Documentation**: [API Reference](https://wuwei-labs.github.io/srsly/)
|
|
@@ -846,4 +307,4 @@ These commands test different aspects:
|
|
|
846
307
|
|
|
847
308
|
- **Star Atlas**: The metaverse gaming ecosystem
|
|
848
309
|
- **Solana**: The blockchain platform powering SRSLY
|
|
849
|
-
- **Anchor**: The framework used to build the SRSLY program
|
|
310
|
+
- **Anchor**: The framework used to build the SRSLY program
|