@wuwei-labs/srsly 2.3.3-canary.36.16828894446.0 → 3.0.0-beta.1
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 +126 -462
- package/dist/cjs/accounts/borrower.js +47 -0
- package/dist/cjs/accounts/borrower.js.map +1 -0
- package/dist/cjs/accounts/config.js +47 -0
- package/dist/cjs/accounts/config.js.map +1 -0
- package/dist/cjs/accounts/contract.js +47 -0
- package/dist/cjs/accounts/contract.js.map +1 -0
- package/dist/cjs/accounts/fleet.js +77 -0
- package/dist/cjs/accounts/fleet.js.map +1 -0
- package/dist/cjs/accounts/rental.js +47 -0
- package/dist/cjs/accounts/rental.js.map +1 -0
- package/dist/cjs/demos.js +124 -59
- package/dist/cjs/demos.js.map +1 -1
- package/dist/cjs/generated/codama/accounts/borrowerState.js +84 -0
- package/dist/cjs/generated/codama/accounts/borrowerState.js.map +1 -0
- package/dist/cjs/generated/codama/accounts/configState.js +37 -52
- package/dist/cjs/generated/codama/accounts/configState.js.map +1 -1
- package/dist/cjs/generated/codama/accounts/contractState.js +27 -51
- package/dist/cjs/generated/codama/accounts/contractState.js.map +1 -1
- package/dist/cjs/generated/codama/accounts/index.js +5 -2
- package/dist/cjs/generated/codama/accounts/index.js.map +1 -1
- package/dist/cjs/generated/codama/accounts/memberState.js +78 -0
- package/dist/cjs/generated/codama/accounts/memberState.js.map +1 -0
- package/dist/cjs/generated/codama/accounts/rentalState.js +23 -59
- package/dist/cjs/generated/codama/accounts/rentalState.js.map +1 -1
- package/dist/cjs/generated/codama/accounts/thread.js +45 -61
- package/dist/cjs/generated/codama/accounts/thread.js.map +1 -1
- package/dist/cjs/generated/codama/accounts/vaultState.js +82 -0
- package/dist/cjs/generated/codama/accounts/vaultState.js.map +1 -0
- package/dist/cjs/generated/codama/errors/index.js +2 -2
- package/dist/cjs/generated/codama/errors/srsly.js +158 -19
- package/dist/cjs/generated/codama/errors/srsly.js.map +1 -1
- package/dist/cjs/generated/codama/index.js +2 -2
- package/dist/cjs/generated/codama/instructions/acceptRental.js +107 -40
- package/dist/cjs/generated/codama/instructions/acceptRental.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/cancelRental.js +53 -56
- package/dist/cjs/generated/codama/instructions/cancelRental.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/captureRental.js +129 -0
- package/dist/cjs/generated/codama/instructions/captureRental.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/claimBorrower.js +222 -0
- package/dist/cjs/generated/codama/instructions/claimBorrower.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/claimBorrowerPayments.js +225 -0
- package/dist/cjs/generated/codama/instructions/claimBorrowerPayments.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/claimContractPayments.js +230 -0
- package/dist/cjs/generated/codama/instructions/claimContractPayments.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/closeBorrower.js +84 -0
- package/dist/cjs/generated/codama/instructions/closeBorrower.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/closeContract.js +140 -31
- package/dist/cjs/generated/codama/instructions/closeContract.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/closeRental.js +31 -28
- package/dist/cjs/generated/codama/instructions/closeRental.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/createConfig.js +212 -0
- package/dist/cjs/generated/codama/instructions/createConfig.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/createContract.js +47 -45
- package/dist/cjs/generated/codama/instructions/createContract.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/deleteBorrower.js +126 -0
- package/dist/cjs/generated/codama/instructions/deleteBorrower.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/deleteConfig.js +193 -0
- package/dist/cjs/generated/codama/instructions/deleteConfig.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/deleteContract.js +115 -0
- package/dist/cjs/generated/codama/instructions/deleteContract.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/deleteRental.js +115 -0
- package/dist/cjs/generated/codama/instructions/deleteRental.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/discountBorrower.js +118 -0
- package/dist/cjs/generated/codama/instructions/discountBorrower.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/index.js +15 -4
- package/dist/cjs/generated/codama/instructions/index.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/payRental.js +95 -68
- package/dist/cjs/generated/codama/instructions/payRental.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/{resetRental.js → releaseRental.js} +79 -38
- package/dist/cjs/generated/codama/instructions/releaseRental.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/reserveRental.js +255 -0
- package/dist/cjs/generated/codama/instructions/reserveRental.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/{initializeConfig.js → updateBorrower.js} +45 -52
- package/dist/cjs/generated/codama/instructions/updateBorrower.js.map +1 -0
- package/dist/cjs/generated/codama/instructions/updateConfig.js +41 -32
- package/dist/cjs/generated/codama/instructions/updateConfig.js.map +1 -1
- package/dist/cjs/generated/codama/instructions/updateContract.js +134 -0
- package/dist/cjs/generated/codama/instructions/updateContract.js.map +1 -0
- package/dist/cjs/generated/codama/programs/index.js +2 -2
- package/dist/cjs/generated/codama/programs/srsly.js +74 -18
- package/dist/cjs/generated/codama/programs/srsly.js.map +1 -1
- package/dist/cjs/generated/codama/shared/index.js +2 -2
- package/dist/cjs/generated/codama/shared/index.js.map +1 -1
- package/dist/cjs/generated/codama/types/capturedFlagData.js +31 -0
- package/dist/cjs/generated/codama/types/capturedFlagData.js.map +1 -0
- package/dist/cjs/generated/codama/types/index.js +7 -9
- package/dist/cjs/generated/codama/types/index.js.map +1 -1
- package/dist/cjs/generated/codama/types/memberConfig.js +33 -0
- package/dist/cjs/generated/codama/types/memberConfig.js.map +1 -0
- package/dist/cjs/generated/codama/types/memberType.js +55 -0
- package/dist/cjs/generated/codama/types/memberType.js.map +1 -0
- package/dist/cjs/generated/codama/types/paymentFrequency.js +2 -2
- package/dist/cjs/generated/codama/types/schedule.js +65 -0
- package/dist/cjs/generated/codama/types/schedule.js.map +1 -0
- package/dist/cjs/generated/codama/types/signal.js +48 -0
- package/dist/cjs/generated/codama/types/signal.js.map +1 -0
- package/dist/cjs/generated/codama/types/trigger.js +36 -23
- package/dist/cjs/generated/codama/types/trigger.js.map +1 -1
- package/dist/cjs/index.js +172 -245
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instructions/acceptRental.js +153 -0
- package/dist/cjs/instructions/acceptRental.js.map +1 -0
- package/dist/cjs/instructions/cancelRental.js +100 -0
- package/dist/cjs/instructions/cancelRental.js.map +1 -0
- package/dist/cjs/instructions/captureRental.js +85 -0
- package/dist/cjs/instructions/captureRental.js.map +1 -0
- package/dist/cjs/instructions/claimBorrower.js +66 -0
- package/dist/cjs/instructions/claimBorrower.js.map +1 -0
- package/dist/cjs/instructions/claimBorrowerPayments.js +69 -0
- package/dist/cjs/instructions/claimBorrowerPayments.js.map +1 -0
- package/dist/cjs/instructions/claimContractPayments.js +79 -0
- package/dist/cjs/instructions/claimContractPayments.js.map +1 -0
- package/dist/cjs/instructions/closeBorrower.js +60 -0
- package/dist/cjs/instructions/closeBorrower.js.map +1 -0
- package/dist/cjs/instructions/closeContract.js +120 -0
- package/dist/cjs/instructions/closeContract.js.map +1 -0
- package/dist/cjs/instructions/closeRental.js +105 -0
- package/dist/cjs/instructions/closeRental.js.map +1 -0
- package/dist/cjs/instructions/createConfig.js +74 -0
- package/dist/cjs/instructions/createConfig.js.map +1 -0
- package/dist/cjs/instructions/createContract.js +131 -0
- package/dist/cjs/instructions/createContract.js.map +1 -0
- package/dist/cjs/instructions/deleteBorrower.js +60 -0
- package/dist/cjs/instructions/deleteBorrower.js.map +1 -0
- package/dist/cjs/instructions/deleteConfig.js +79 -0
- package/dist/cjs/instructions/deleteConfig.js.map +1 -0
- package/dist/cjs/instructions/deleteRental.js +75 -0
- package/dist/cjs/instructions/deleteRental.js.map +1 -0
- package/dist/cjs/instructions/discountBorrower.js +75 -0
- package/dist/cjs/instructions/discountBorrower.js.map +1 -0
- package/dist/cjs/instructions/releaseRental.js +132 -0
- package/dist/cjs/instructions/releaseRental.js.map +1 -0
- package/dist/cjs/instructions/reserveRental.js +135 -0
- package/dist/cjs/instructions/reserveRental.js.map +1 -0
- package/dist/cjs/instructions/updateBorrower.js +89 -0
- package/dist/cjs/instructions/updateBorrower.js.map +1 -0
- package/dist/cjs/instructions/updateConfig.js +103 -0
- package/dist/cjs/instructions/updateConfig.js.map +1 -0
- package/dist/cjs/instructions/updateContract.js +107 -0
- package/dist/cjs/instructions/updateContract.js.map +1 -0
- package/dist/cjs/package.json +30 -32
- package/dist/cjs/params/amount.js +125 -0
- package/dist/cjs/params/amount.js.map +1 -0
- package/dist/cjs/params/duration.js +120 -0
- package/dist/cjs/params/duration.js.map +1 -0
- package/dist/cjs/params/schedule.js +164 -0
- package/dist/cjs/params/schedule.js.map +1 -0
- package/dist/cjs/pda/constants.js +73 -0
- package/dist/cjs/pda/constants.js.map +1 -0
- package/dist/cjs/pda/index.js +73 -0
- package/dist/cjs/pda/index.js.map +1 -0
- package/dist/cjs/pda/sage.js +175 -0
- package/dist/cjs/pda/sage.js.map +1 -0
- package/dist/cjs/pda/slyvault.js +56 -0
- package/dist/cjs/pda/slyvault.js.map +1 -0
- package/dist/cjs/pda/srsly.js +120 -0
- package/dist/cjs/pda/srsly.js.map +1 -0
- package/dist/cjs/pda/thread.js +64 -0
- package/dist/cjs/pda/thread.js.map +1 -0
- package/dist/cjs/pda/token.js +62 -0
- package/dist/cjs/pda/token.js.map +1 -0
- package/dist/cjs/utils/addresses.js +90 -0
- package/dist/cjs/utils/addresses.js.map +1 -0
- package/dist/cjs/utils/config.js +100 -187
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/cjs/utils/index.js +32 -28
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/instructions.js +79 -0
- package/dist/cjs/utils/instructions.js.map +1 -0
- package/dist/cjs/utils/signer.js +113 -94
- package/dist/cjs/utils/signer.js.map +1 -1
- package/dist/cjs/utils/web3js.js +76 -0
- package/dist/cjs/utils/web3js.js.map +1 -0
- package/dist/cjs/version.js +7 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/accounts/borrower.js +44 -0
- package/dist/esm/accounts/borrower.js.map +1 -0
- package/dist/esm/accounts/config.js +44 -0
- package/dist/esm/accounts/config.js.map +1 -0
- package/dist/esm/accounts/contract.js +44 -0
- package/dist/esm/accounts/contract.js.map +1 -0
- package/dist/esm/accounts/fleet.js +74 -0
- package/dist/esm/accounts/fleet.js.map +1 -0
- package/dist/esm/accounts/rental.js +44 -0
- package/dist/esm/accounts/rental.js.map +1 -0
- package/dist/esm/demos.js +123 -18
- package/dist/esm/demos.js.map +1 -1
- package/dist/esm/generated/codama/accounts/borrowerState.js +72 -0
- package/dist/esm/generated/codama/accounts/borrowerState.js.map +1 -0
- package/dist/esm/generated/codama/accounts/configState.js +38 -53
- package/dist/esm/generated/codama/accounts/configState.js.map +1 -1
- package/dist/esm/generated/codama/accounts/contractState.js +28 -52
- package/dist/esm/generated/codama/accounts/contractState.js.map +1 -1
- package/dist/esm/generated/codama/accounts/index.js +5 -2
- package/dist/esm/generated/codama/accounts/index.js.map +1 -1
- package/dist/esm/generated/codama/accounts/memberState.js +66 -0
- package/dist/esm/generated/codama/accounts/memberState.js.map +1 -0
- package/dist/esm/generated/codama/accounts/rentalState.js +23 -60
- package/dist/esm/generated/codama/accounts/rentalState.js.map +1 -1
- package/dist/esm/generated/codama/accounts/thread.js +47 -63
- package/dist/esm/generated/codama/accounts/thread.js.map +1 -1
- package/dist/esm/generated/codama/accounts/vaultState.js +70 -0
- package/dist/esm/generated/codama/accounts/vaultState.js.map +1 -0
- package/dist/esm/generated/codama/errors/index.js +2 -2
- package/dist/esm/generated/codama/errors/srsly.js +156 -18
- package/dist/esm/generated/codama/errors/srsly.js.map +1 -1
- package/dist/esm/generated/codama/index.js +2 -2
- package/dist/esm/generated/codama/instructions/acceptRental.js +107 -40
- package/dist/esm/generated/codama/instructions/acceptRental.js.map +1 -1
- package/dist/esm/generated/codama/instructions/cancelRental.js +54 -57
- package/dist/esm/generated/codama/instructions/cancelRental.js.map +1 -1
- package/dist/esm/generated/codama/instructions/captureRental.js +119 -0
- package/dist/esm/generated/codama/instructions/captureRental.js.map +1 -0
- package/dist/esm/generated/codama/instructions/claimBorrower.js +212 -0
- package/dist/esm/generated/codama/instructions/claimBorrower.js.map +1 -0
- package/dist/esm/generated/codama/instructions/claimContractPayments.js +220 -0
- package/dist/esm/generated/codama/instructions/claimContractPayments.js.map +1 -0
- package/dist/esm/generated/codama/instructions/closeBorrower.js +75 -0
- package/dist/esm/generated/codama/instructions/closeBorrower.js.map +1 -0
- package/dist/esm/generated/codama/instructions/closeContract.js +142 -33
- package/dist/esm/generated/codama/instructions/closeContract.js.map +1 -1
- package/dist/esm/generated/codama/instructions/closeRental.js +31 -28
- package/dist/esm/generated/codama/instructions/closeRental.js.map +1 -1
- package/dist/esm/generated/codama/instructions/createConfig.js +202 -0
- package/dist/esm/generated/codama/instructions/createConfig.js.map +1 -0
- package/dist/esm/generated/codama/instructions/createContract.js +48 -46
- package/dist/esm/generated/codama/instructions/createContract.js.map +1 -1
- package/dist/esm/generated/codama/instructions/deleteBorrower.js +116 -0
- package/dist/esm/generated/codama/instructions/deleteBorrower.js.map +1 -0
- package/dist/esm/generated/codama/instructions/deleteConfig.js +183 -0
- package/dist/esm/generated/codama/instructions/deleteConfig.js.map +1 -0
- package/dist/esm/generated/codama/instructions/deleteContract.js +105 -0
- package/dist/esm/generated/codama/instructions/deleteContract.js.map +1 -0
- package/dist/esm/generated/codama/instructions/deleteRental.js +105 -0
- package/dist/esm/generated/codama/instructions/deleteRental.js.map +1 -0
- package/dist/esm/generated/codama/instructions/discountBorrower.js +108 -0
- package/dist/esm/generated/codama/instructions/discountBorrower.js.map +1 -0
- package/dist/esm/generated/codama/instructions/index.js +15 -4
- package/dist/esm/generated/codama/instructions/index.js.map +1 -1
- package/dist/esm/generated/codama/instructions/payRental.js +95 -68
- package/dist/esm/generated/codama/instructions/payRental.js.map +1 -1
- package/dist/esm/generated/codama/instructions/{resetRental.js → releaseRental.js} +73 -32
- package/dist/esm/generated/codama/instructions/releaseRental.js.map +1 -0
- package/dist/esm/generated/codama/instructions/reserveRental.js +245 -0
- package/dist/esm/generated/codama/instructions/reserveRental.js.map +1 -0
- package/dist/esm/generated/codama/instructions/{initializeConfig.js → updateBorrower.js} +38 -45
- package/dist/esm/generated/codama/instructions/updateBorrower.js.map +1 -0
- package/dist/esm/generated/codama/instructions/updateConfig.js +42 -33
- package/dist/esm/generated/codama/instructions/updateConfig.js.map +1 -1
- package/dist/esm/generated/codama/instructions/updateContract.js +124 -0
- package/dist/esm/generated/codama/instructions/updateContract.js.map +1 -0
- package/dist/esm/generated/codama/programs/index.js +2 -2
- package/dist/esm/generated/codama/programs/srsly.js +74 -18
- package/dist/esm/generated/codama/programs/srsly.js.map +1 -1
- package/dist/esm/generated/codama/shared/index.js +2 -2
- package/dist/esm/generated/codama/shared/index.js.map +1 -1
- package/dist/esm/generated/codama/types/capturedFlagData.js +26 -0
- package/dist/esm/generated/codama/types/capturedFlagData.js.map +1 -0
- package/dist/esm/generated/codama/types/index.js +7 -9
- package/dist/esm/generated/codama/types/index.js.map +1 -1
- package/dist/esm/generated/codama/types/memberConfig.js +28 -0
- package/dist/esm/generated/codama/types/memberConfig.js.map +1 -0
- package/dist/esm/generated/codama/types/memberType.js +48 -0
- package/dist/esm/generated/codama/types/memberType.js.map +1 -0
- package/dist/esm/generated/codama/types/paymentFrequency.js +2 -2
- package/dist/esm/generated/codama/types/schedule.js +58 -0
- package/dist/esm/generated/codama/types/schedule.js.map +1 -0
- package/dist/esm/generated/codama/types/signal.js +41 -0
- package/dist/esm/generated/codama/types/signal.js.map +1 -0
- package/dist/esm/generated/codama/types/trigger.js +37 -24
- package/dist/esm/generated/codama/types/trigger.js.map +1 -1
- package/dist/esm/index.js +78 -208
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instructions/acceptRental.js +150 -0
- package/dist/esm/instructions/acceptRental.js.map +1 -0
- package/dist/esm/instructions/cancelRental.js +97 -0
- package/dist/esm/instructions/cancelRental.js.map +1 -0
- package/dist/esm/instructions/captureRental.js +82 -0
- package/dist/esm/instructions/captureRental.js.map +1 -0
- package/dist/esm/instructions/claimBorrower.js +63 -0
- package/dist/esm/instructions/claimBorrower.js.map +1 -0
- package/dist/esm/instructions/claimContractPayments.js +76 -0
- package/dist/esm/instructions/claimContractPayments.js.map +1 -0
- package/dist/esm/instructions/closeBorrower.js +57 -0
- package/dist/esm/instructions/closeBorrower.js.map +1 -0
- package/dist/esm/instructions/closeContract.js +117 -0
- package/dist/esm/instructions/closeContract.js.map +1 -0
- package/dist/esm/instructions/closeRental.js +102 -0
- package/dist/esm/instructions/closeRental.js.map +1 -0
- package/dist/esm/instructions/createConfig.js +71 -0
- package/dist/esm/instructions/createConfig.js.map +1 -0
- package/dist/esm/instructions/createContract.js +128 -0
- package/dist/esm/instructions/createContract.js.map +1 -0
- package/dist/esm/instructions/deleteBorrower.js +57 -0
- package/dist/esm/instructions/deleteBorrower.js.map +1 -0
- package/dist/esm/instructions/deleteConfig.js +76 -0
- package/dist/esm/instructions/deleteConfig.js.map +1 -0
- package/dist/esm/instructions/deleteRental.js +72 -0
- package/dist/esm/instructions/deleteRental.js.map +1 -0
- package/dist/esm/instructions/discountBorrower.js +72 -0
- package/dist/esm/instructions/discountBorrower.js.map +1 -0
- package/dist/esm/instructions/releaseRental.js +129 -0
- package/dist/esm/instructions/releaseRental.js.map +1 -0
- package/dist/esm/instructions/reserveRental.js +132 -0
- package/dist/esm/instructions/reserveRental.js.map +1 -0
- package/dist/esm/instructions/updateBorrower.js +86 -0
- package/dist/esm/instructions/updateBorrower.js.map +1 -0
- package/dist/esm/instructions/updateConfig.js +100 -0
- package/dist/esm/instructions/updateConfig.js.map +1 -0
- package/dist/esm/instructions/updateContract.js +104 -0
- package/dist/esm/instructions/updateContract.js.map +1 -0
- package/dist/esm/package.json +30 -32
- package/dist/esm/params/amount.js +119 -0
- package/dist/esm/params/amount.js.map +1 -0
- package/dist/esm/params/duration.js +115 -0
- package/dist/esm/params/duration.js.map +1 -0
- package/dist/esm/params/schedule.js +157 -0
- package/dist/esm/params/schedule.js.map +1 -0
- package/dist/esm/pda/constants.js +67 -0
- package/dist/esm/pda/constants.js.map +1 -0
- package/dist/esm/pda/index.js +42 -0
- package/dist/esm/pda/index.js.map +1 -0
- package/dist/esm/pda/sage.js +168 -0
- package/dist/esm/pda/sage.js.map +1 -0
- package/dist/esm/pda/slyvault.js +53 -0
- package/dist/esm/pda/slyvault.js.map +1 -0
- package/dist/esm/pda/srsly.js +113 -0
- package/dist/esm/pda/srsly.js.map +1 -0
- package/dist/esm/pda/thread.js +61 -0
- package/dist/esm/pda/thread.js.map +1 -0
- package/dist/esm/pda/token.js +59 -0
- package/dist/esm/pda/token.js.map +1 -0
- package/dist/esm/utils/addresses.js +85 -0
- package/dist/esm/utils/addresses.js.map +1 -0
- package/dist/esm/utils/config.js +95 -149
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/esm/utils/index.js +12 -14
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/instructions.js +76 -0
- package/dist/esm/utils/instructions.js.map +1 -0
- package/dist/esm/utils/signer.js +109 -90
- package/dist/esm/utils/signer.js.map +1 -1
- package/dist/esm/utils/web3js.js +72 -0
- package/dist/esm/utils/web3js.js.map +1 -0
- package/dist/esm/version.js +4 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/accounts/borrower.d.ts +34 -0
- package/dist/types/accounts/borrower.d.ts.map +1 -0
- package/dist/types/accounts/config.d.ts +31 -0
- package/dist/types/accounts/config.d.ts.map +1 -0
- package/dist/types/accounts/contract.d.ts +34 -0
- package/dist/types/accounts/contract.d.ts.map +1 -0
- package/dist/types/accounts/fleet.d.ts +49 -0
- package/dist/types/accounts/fleet.d.ts.map +1 -0
- package/dist/types/accounts/rental.d.ts +34 -0
- package/dist/types/accounts/rental.d.ts.map +1 -0
- package/dist/types/demos.d.ts +20 -52
- package/dist/types/demos.d.ts.map +1 -1
- package/dist/types/generated/codama/accounts/borrowerState.d.ts +94 -0
- package/dist/types/generated/codama/accounts/borrowerState.d.ts.map +1 -0
- package/dist/types/generated/codama/accounts/configState.d.ts +65 -22
- package/dist/types/generated/codama/accounts/configState.d.ts.map +1 -1
- package/dist/types/generated/codama/accounts/contractState.d.ts +62 -23
- package/dist/types/generated/codama/accounts/contractState.d.ts.map +1 -1
- package/dist/types/generated/codama/accounts/index.d.ts +5 -2
- package/dist/types/generated/codama/accounts/index.d.ts.map +1 -1
- package/dist/types/generated/codama/accounts/memberState.d.ts +58 -0
- package/dist/types/generated/codama/accounts/memberState.d.ts.map +1 -0
- package/dist/types/generated/codama/accounts/rentalState.d.ts +35 -39
- package/dist/types/generated/codama/accounts/rentalState.d.ts.map +1 -1
- package/dist/types/generated/codama/accounts/thread.d.ts +44 -51
- package/dist/types/generated/codama/accounts/thread.d.ts.map +1 -1
- package/dist/types/generated/codama/accounts/vaultState.d.ts +66 -0
- package/dist/types/generated/codama/accounts/vaultState.d.ts.map +1 -0
- package/dist/types/generated/codama/errors/index.d.ts +2 -2
- package/dist/types/generated/codama/errors/srsly.d.ts +111 -19
- package/dist/types/generated/codama/errors/srsly.d.ts.map +1 -1
- package/dist/types/generated/codama/index.d.ts +2 -2
- package/dist/types/generated/codama/instructions/acceptRental.d.ts +60 -45
- package/dist/types/generated/codama/instructions/acceptRental.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/cancelRental.d.ts +37 -32
- package/dist/types/generated/codama/instructions/cancelRental.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/captureRental.d.ts +59 -0
- package/dist/types/generated/codama/instructions/captureRental.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/claimBorrower.d.ts +90 -0
- package/dist/types/generated/codama/instructions/claimBorrower.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/claimBorrowerPayments.d.ts +75 -0
- package/dist/types/generated/codama/instructions/claimBorrowerPayments.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/claimContractPayments.d.ts +98 -0
- package/dist/types/generated/codama/instructions/claimContractPayments.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/closeBorrower.d.ts +43 -0
- package/dist/types/generated/codama/instructions/closeBorrower.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/closeContract.d.ts +44 -28
- package/dist/types/generated/codama/instructions/closeContract.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/closeRental.d.ts +38 -34
- package/dist/types/generated/codama/instructions/closeRental.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/createConfig.d.ts +79 -0
- package/dist/types/generated/codama/instructions/createConfig.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/createContract.d.ts +38 -30
- package/dist/types/generated/codama/instructions/createContract.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/deleteBorrower.d.ts +55 -0
- package/dist/types/generated/codama/instructions/deleteBorrower.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/deleteConfig.d.ts +75 -0
- package/dist/types/generated/codama/instructions/deleteConfig.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/deleteContract.d.ts +55 -0
- package/dist/types/generated/codama/instructions/deleteContract.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/deleteRental.d.ts +55 -0
- package/dist/types/generated/codama/instructions/deleteRental.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/discountBorrower.d.ts +56 -0
- package/dist/types/generated/codama/instructions/discountBorrower.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/index.d.ts +15 -4
- package/dist/types/generated/codama/instructions/index.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/payRental.d.ts +61 -46
- package/dist/types/generated/codama/instructions/payRental.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/releaseRental.d.ts +105 -0
- package/dist/types/generated/codama/instructions/releaseRental.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/reserveRental.d.ts +129 -0
- package/dist/types/generated/codama/instructions/reserveRental.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/updateBorrower.d.ts +62 -0
- package/dist/types/generated/codama/instructions/updateBorrower.d.ts.map +1 -0
- package/dist/types/generated/codama/instructions/updateConfig.d.ts +88 -28
- package/dist/types/generated/codama/instructions/updateConfig.d.ts.map +1 -1
- package/dist/types/generated/codama/instructions/updateContract.d.ts +88 -0
- package/dist/types/generated/codama/instructions/updateContract.d.ts.map +1 -0
- package/dist/types/generated/codama/programs/index.d.ts +2 -2
- package/dist/types/generated/codama/programs/srsly.d.ts +57 -21
- package/dist/types/generated/codama/programs/srsly.d.ts.map +1 -1
- package/dist/types/generated/codama/shared/index.d.ts +2 -13
- package/dist/types/generated/codama/shared/index.d.ts.map +1 -1
- package/dist/types/generated/codama/types/capturedFlagData.d.ts +35 -0
- package/dist/types/generated/codama/types/capturedFlagData.d.ts.map +1 -0
- package/dist/types/generated/codama/types/index.d.ts +7 -9
- package/dist/types/generated/codama/types/index.d.ts.map +1 -1
- package/dist/types/generated/codama/types/memberConfig.d.ts +33 -0
- package/dist/types/generated/codama/types/memberConfig.d.ts.map +1 -0
- package/dist/types/generated/codama/types/memberType.d.ts +48 -0
- package/dist/types/generated/codama/types/memberType.d.ts.map +1 -0
- package/dist/types/generated/codama/types/paymentFrequency.d.ts +2 -2
- package/dist/types/generated/codama/types/schedule.d.ts +46 -0
- package/dist/types/generated/codama/types/schedule.d.ts.map +1 -0
- package/dist/types/generated/codama/types/signal.d.ts +56 -0
- package/dist/types/generated/codama/types/signal.d.ts.map +1 -0
- package/dist/types/generated/codama/types/trigger.d.ts +45 -34
- package/dist/types/generated/codama/types/trigger.d.ts.map +1 -1
- package/dist/types/index.d.ts +37 -207
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/instructions/acceptRental.d.ts +99 -0
- package/dist/types/instructions/acceptRental.d.ts.map +1 -0
- package/dist/types/instructions/cancelRental.d.ts +90 -0
- package/dist/types/instructions/cancelRental.d.ts.map +1 -0
- package/dist/types/instructions/captureRental.d.ts +58 -0
- package/dist/types/instructions/captureRental.d.ts.map +1 -0
- package/dist/types/instructions/claimBorrower.d.ts +53 -0
- package/dist/types/instructions/claimBorrower.d.ts.map +1 -0
- package/dist/types/instructions/claimBorrowerPayments.d.ts +59 -0
- package/dist/types/instructions/claimBorrowerPayments.d.ts.map +1 -0
- package/dist/types/instructions/claimContractPayments.d.ts +78 -0
- package/dist/types/instructions/claimContractPayments.d.ts.map +1 -0
- package/dist/types/instructions/closeBorrower.d.ts +45 -0
- package/dist/types/instructions/closeBorrower.d.ts.map +1 -0
- package/dist/types/instructions/closeContract.d.ts +91 -0
- package/dist/types/instructions/closeContract.d.ts.map +1 -0
- package/dist/types/instructions/closeRental.d.ts +62 -0
- package/dist/types/instructions/closeRental.d.ts.map +1 -0
- package/dist/types/instructions/createConfig.d.ts +62 -0
- package/dist/types/instructions/createConfig.d.ts.map +1 -0
- package/dist/types/instructions/createContract.d.ts +127 -0
- package/dist/types/instructions/createContract.d.ts.map +1 -0
- package/dist/types/instructions/deleteBorrower.d.ts +53 -0
- package/dist/types/instructions/deleteBorrower.d.ts.map +1 -0
- package/dist/types/instructions/deleteConfig.d.ts +64 -0
- package/dist/types/instructions/deleteConfig.d.ts.map +1 -0
- package/dist/types/instructions/deleteRental.d.ts +67 -0
- package/dist/types/instructions/deleteRental.d.ts.map +1 -0
- package/dist/types/instructions/discountBorrower.d.ts +64 -0
- package/dist/types/instructions/discountBorrower.d.ts.map +1 -0
- package/dist/types/instructions/releaseRental.d.ts +104 -0
- package/dist/types/instructions/releaseRental.d.ts.map +1 -0
- package/dist/types/instructions/reserveRental.d.ts +80 -0
- package/dist/types/instructions/reserveRental.d.ts.map +1 -0
- package/dist/types/instructions/updateBorrower.d.ts +81 -0
- package/dist/types/instructions/updateBorrower.d.ts.map +1 -0
- package/dist/types/instructions/updateConfig.d.ts +142 -0
- package/dist/types/instructions/updateConfig.d.ts.map +1 -0
- package/dist/types/instructions/updateContract.d.ts +113 -0
- package/dist/types/instructions/updateContract.d.ts.map +1 -0
- package/dist/types/params/amount.d.ts +70 -0
- package/dist/types/params/amount.d.ts.map +1 -0
- package/dist/types/params/duration.d.ts +65 -0
- package/dist/types/params/duration.d.ts.map +1 -0
- package/dist/types/params/schedule.d.ts +74 -0
- package/dist/types/params/schedule.d.ts.map +1 -0
- package/dist/types/pda/constants.d.ts +51 -0
- package/dist/types/pda/constants.d.ts.map +1 -0
- package/dist/types/pda/index.d.ts +36 -0
- package/dist/types/pda/index.d.ts.map +1 -0
- package/dist/types/pda/sage.d.ts +69 -0
- package/dist/types/pda/sage.d.ts.map +1 -0
- package/dist/types/pda/slyvault.d.ts +29 -0
- package/dist/types/pda/slyvault.d.ts.map +1 -0
- package/dist/types/pda/srsly.d.ts +40 -0
- package/dist/types/pda/srsly.d.ts.map +1 -0
- package/dist/types/pda/thread.d.ts +31 -0
- package/dist/types/pda/thread.d.ts.map +1 -0
- package/dist/types/pda/token.d.ts +29 -0
- package/dist/types/pda/token.d.ts.map +1 -0
- package/dist/types/utils/addresses.d.ts +75 -0
- package/dist/types/utils/addresses.d.ts.map +1 -0
- package/dist/types/utils/config.d.ts +103 -83
- package/dist/types/utils/config.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +7 -14
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/instructions.d.ts +52 -0
- package/dist/types/utils/instructions.d.ts.map +1 -0
- package/dist/types/utils/signer.d.ts +78 -39
- package/dist/types/utils/signer.d.ts.map +1 -1
- package/dist/types/utils/web3js.d.ts +85 -0
- package/dist/types/utils/web3js.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +32 -47
- package/dist/cjs/config/index.js +0 -12
- package/dist/cjs/config/index.js.map +0 -1
- package/dist/cjs/config/initialize.js +0 -95
- package/dist/cjs/config/initialize.js.map +0 -1
- package/dist/cjs/config/update.js +0 -163
- package/dist/cjs/config/update.js.map +0 -1
- package/dist/cjs/contract/close.js +0 -159
- package/dist/cjs/contract/close.js.map +0 -1
- package/dist/cjs/contract/create.js +0 -259
- package/dist/cjs/contract/create.js.map +0 -1
- package/dist/cjs/contract/index.js +0 -68
- package/dist/cjs/contract/index.js.map +0 -1
- package/dist/cjs/generated/codama/instructions/initializeConfig.js.map +0 -1
- package/dist/cjs/generated/codama/instructions/resetRental.js.map +0 -1
- package/dist/cjs/generated/codama/types/clockData.js +0 -58
- package/dist/cjs/generated/codama/types/clockData.js.map +0 -1
- package/dist/cjs/generated/codama/types/equality.js +0 -30
- package/dist/cjs/generated/codama/types/equality.js.map +0 -1
- package/dist/cjs/generated/codama/types/execContext.js +0 -68
- package/dist/cjs/generated/codama/types/execContext.js.map +0 -1
- package/dist/cjs/generated/codama/types/serializableAccount.js +0 -58
- package/dist/cjs/generated/codama/types/serializableAccount.js.map +0 -1
- package/dist/cjs/generated/codama/types/serializableInstruction.js +0 -59
- package/dist/cjs/generated/codama/types/serializableInstruction.js.map +0 -1
- package/dist/cjs/generated/codama/types/threadResponse.js +0 -68
- package/dist/cjs/generated/codama/types/threadResponse.js.map +0 -1
- package/dist/cjs/generated/codama/types/triggerContext.js +0 -49
- package/dist/cjs/generated/codama/types/triggerContext.js.map +0 -1
- package/dist/cjs/idl/index.js +0 -27
- package/dist/cjs/idl/index.js.map +0 -1
- package/dist/cjs/idl/srsly-data.js +0 -3140
- package/dist/cjs/idl/srsly-data.js.map +0 -1
- package/dist/cjs/idl/srsly.json +0 -3104
- package/dist/cjs/rental/accept.js +0 -263
- package/dist/cjs/rental/accept.js.map +0 -1
- package/dist/cjs/rental/cancel.js +0 -184
- package/dist/cjs/rental/cancel.js.map +0 -1
- package/dist/cjs/rental/close.js +0 -184
- package/dist/cjs/rental/close.js.map +0 -1
- package/dist/cjs/rental/index.js +0 -105
- package/dist/cjs/rental/index.js.map +0 -1
- package/dist/cjs/rental/reset.js +0 -192
- package/dist/cjs/rental/reset.js.map +0 -1
- package/dist/cjs/types/payment-frequency.js +0 -87
- package/dist/cjs/types/payment-frequency.js.map +0 -1
- package/dist/cjs/types/srsly.js +0 -3
- package/dist/cjs/types/srsly.js.map +0 -1
- package/dist/cjs/utils/constants.js +0 -78
- package/dist/cjs/utils/constants.js.map +0 -1
- package/dist/cjs/utils/cron.js +0 -204
- package/dist/cjs/utils/cron.js.map +0 -1
- package/dist/cjs/utils/derive-pda.js +0 -415
- package/dist/cjs/utils/derive-pda.js.map +0 -1
- package/dist/cjs/utils/fetch-accounts.js +0 -241
- package/dist/cjs/utils/fetch-accounts.js.map +0 -1
- package/dist/cjs/utils/instruction-converter.js +0 -125
- package/dist/cjs/utils/instruction-converter.js.map +0 -1
- package/dist/cjs/utils/param-converters.js +0 -190
- package/dist/cjs/utils/param-converters.js.map +0 -1
- package/dist/cjs/utils/payment-frequency.js +0 -111
- package/dist/cjs/utils/payment-frequency.js.map +0 -1
- package/dist/cjs/utils/schedule-builder.js +0 -158
- package/dist/cjs/utils/schedule-builder.js.map +0 -1
- package/dist/cjs/utils/schedule-validation.js +0 -136
- package/dist/cjs/utils/schedule-validation.js.map +0 -1
- package/dist/cjs/utils/smart-params.js +0 -52
- package/dist/cjs/utils/smart-params.js.map +0 -1
- package/dist/esm/config/index.js +0 -7
- package/dist/esm/config/index.js.map +0 -1
- package/dist/esm/config/initialize.js +0 -92
- package/dist/esm/config/initialize.js.map +0 -1
- package/dist/esm/config/update.js +0 -159
- package/dist/esm/config/update.js.map +0 -1
- package/dist/esm/contract/close.js +0 -154
- package/dist/esm/contract/close.js.map +0 -1
- package/dist/esm/contract/create.js +0 -255
- package/dist/esm/contract/create.js.map +0 -1
- package/dist/esm/contract/index.js +0 -52
- package/dist/esm/contract/index.js.map +0 -1
- package/dist/esm/generated/codama/instructions/initializeConfig.js.map +0 -1
- package/dist/esm/generated/codama/instructions/resetRental.js.map +0 -1
- package/dist/esm/generated/codama/types/clockData.js +0 -53
- package/dist/esm/generated/codama/types/clockData.js.map +0 -1
- package/dist/esm/generated/codama/types/equality.js +0 -24
- package/dist/esm/generated/codama/types/equality.js.map +0 -1
- package/dist/esm/generated/codama/types/execContext.js +0 -63
- package/dist/esm/generated/codama/types/execContext.js.map +0 -1
- package/dist/esm/generated/codama/types/serializableAccount.js +0 -53
- package/dist/esm/generated/codama/types/serializableAccount.js.map +0 -1
- package/dist/esm/generated/codama/types/serializableInstruction.js +0 -54
- package/dist/esm/generated/codama/types/serializableInstruction.js.map +0 -1
- package/dist/esm/generated/codama/types/threadResponse.js +0 -63
- package/dist/esm/generated/codama/types/threadResponse.js.map +0 -1
- package/dist/esm/generated/codama/types/triggerContext.js +0 -42
- package/dist/esm/generated/codama/types/triggerContext.js.map +0 -1
- package/dist/esm/idl/index.js +0 -21
- package/dist/esm/idl/index.js.map +0 -1
- package/dist/esm/idl/srsly-data.js +0 -3137
- package/dist/esm/idl/srsly-data.js.map +0 -1
- package/dist/esm/idl/srsly.json +0 -3104
- package/dist/esm/rental/accept.js +0 -258
- package/dist/esm/rental/accept.js.map +0 -1
- package/dist/esm/rental/cancel.js +0 -179
- package/dist/esm/rental/cancel.js.map +0 -1
- package/dist/esm/rental/close.js +0 -179
- package/dist/esm/rental/close.js.map +0 -1
- package/dist/esm/rental/index.js +0 -89
- package/dist/esm/rental/index.js.map +0 -1
- package/dist/esm/rental/reset.js +0 -187
- package/dist/esm/rental/reset.js.map +0 -1
- package/dist/esm/types/payment-frequency.js +0 -83
- package/dist/esm/types/payment-frequency.js.map +0 -1
- package/dist/esm/types/srsly.js +0 -2
- package/dist/esm/types/srsly.js.map +0 -1
- package/dist/esm/utils/constants.js +0 -70
- package/dist/esm/utils/constants.js.map +0 -1
- package/dist/esm/utils/cron.js +0 -195
- package/dist/esm/utils/cron.js.map +0 -1
- package/dist/esm/utils/derive-pda.js +0 -402
- package/dist/esm/utils/derive-pda.js.map +0 -1
- package/dist/esm/utils/fetch-accounts.js +0 -233
- package/dist/esm/utils/fetch-accounts.js.map +0 -1
- package/dist/esm/utils/instruction-converter.js +0 -120
- package/dist/esm/utils/instruction-converter.js.map +0 -1
- package/dist/esm/utils/param-converters.js +0 -182
- package/dist/esm/utils/param-converters.js.map +0 -1
- package/dist/esm/utils/payment-frequency.js +0 -104
- package/dist/esm/utils/payment-frequency.js.map +0 -1
- package/dist/esm/utils/schedule-builder.js +0 -153
- package/dist/esm/utils/schedule-builder.js.map +0 -1
- package/dist/esm/utils/schedule-validation.js +0 -132
- package/dist/esm/utils/schedule-validation.js.map +0 -1
- package/dist/esm/utils/smart-params.js +0 -49
- package/dist/esm/utils/smart-params.js.map +0 -1
- package/dist/types/config/index.d.ts +0 -7
- package/dist/types/config/index.d.ts.map +0 -1
- package/dist/types/config/initialize.d.ts +0 -66
- package/dist/types/config/initialize.d.ts.map +0 -1
- package/dist/types/config/update.d.ts +0 -143
- package/dist/types/config/update.d.ts.map +0 -1
- package/dist/types/contract/close.d.ts +0 -124
- package/dist/types/contract/close.d.ts.map +0 -1
- package/dist/types/contract/create.d.ts +0 -150
- package/dist/types/contract/create.d.ts.map +0 -1
- package/dist/types/contract/index.d.ts +0 -52
- package/dist/types/contract/index.d.ts.map +0 -1
- package/dist/types/generated/codama/instructions/initializeConfig.d.ts +0 -60
- package/dist/types/generated/codama/instructions/initializeConfig.d.ts.map +0 -1
- package/dist/types/generated/codama/instructions/resetRental.d.ts +0 -79
- package/dist/types/generated/codama/instructions/resetRental.d.ts.map +0 -1
- package/dist/types/generated/codama/types/clockData.d.ts +0 -30
- package/dist/types/generated/codama/types/clockData.d.ts.map +0 -1
- package/dist/types/generated/codama/types/equality.d.ts +0 -18
- package/dist/types/generated/codama/types/equality.d.ts.map +0 -1
- package/dist/types/generated/codama/types/execContext.d.ts +0 -49
- package/dist/types/generated/codama/types/execContext.d.ts.map +0 -1
- package/dist/types/generated/codama/types/serializableAccount.d.ts +0 -23
- package/dist/types/generated/codama/types/serializableAccount.d.ts.map +0 -1
- package/dist/types/generated/codama/types/serializableInstruction.d.ts +0 -31
- package/dist/types/generated/codama/types/serializableInstruction.d.ts.map +0 -1
- package/dist/types/generated/codama/types/threadResponse.d.ts +0 -43
- package/dist/types/generated/codama/types/threadResponse.d.ts.map +0 -1
- package/dist/types/generated/codama/types/triggerContext.d.ts +0 -75
- package/dist/types/generated/codama/types/triggerContext.d.ts.map +0 -1
- package/dist/types/idl/index.d.ts +0 -21
- package/dist/types/idl/index.d.ts.map +0 -1
- package/dist/types/idl/srsly-data.d.ts +0 -1458
- package/dist/types/idl/srsly-data.d.ts.map +0 -1
- package/dist/types/rental/accept.d.ts +0 -196
- package/dist/types/rental/accept.d.ts.map +0 -1
- package/dist/types/rental/cancel.d.ts +0 -141
- package/dist/types/rental/cancel.d.ts.map +0 -1
- package/dist/types/rental/close.d.ts +0 -130
- package/dist/types/rental/close.d.ts.map +0 -1
- package/dist/types/rental/index.d.ts +0 -89
- package/dist/types/rental/index.d.ts.map +0 -1
- package/dist/types/rental/reset.d.ts +0 -166
- package/dist/types/rental/reset.d.ts.map +0 -1
- package/dist/types/types/payment-frequency.d.ts +0 -55
- package/dist/types/types/payment-frequency.d.ts.map +0 -1
- package/dist/types/types/srsly.d.ts +0 -3111
- package/dist/types/types/srsly.d.ts.map +0 -1
- package/dist/types/utils/constants.d.ts +0 -26
- package/dist/types/utils/constants.d.ts.map +0 -1
- package/dist/types/utils/cron.d.ts +0 -77
- package/dist/types/utils/cron.d.ts.map +0 -1
- package/dist/types/utils/derive-pda.d.ts +0 -213
- package/dist/types/utils/derive-pda.d.ts.map +0 -1
- package/dist/types/utils/fetch-accounts.d.ts +0 -158
- package/dist/types/utils/fetch-accounts.d.ts.map +0 -1
- package/dist/types/utils/instruction-converter.d.ts +0 -171
- package/dist/types/utils/instruction-converter.d.ts.map +0 -1
- package/dist/types/utils/param-converters.d.ts +0 -67
- package/dist/types/utils/param-converters.d.ts.map +0 -1
- package/dist/types/utils/payment-frequency.d.ts +0 -38
- package/dist/types/utils/payment-frequency.d.ts.map +0 -1
- package/dist/types/utils/schedule-builder.d.ts +0 -64
- package/dist/types/utils/schedule-builder.d.ts.map +0 -1
- package/dist/types/utils/schedule-validation.d.ts +0 -36
- package/dist/types/utils/schedule-validation.d.ts.map +0 -1
- package/dist/types/utils/smart-params.d.ts +0 -112
- package/dist/types/utils/smart-params.d.ts.map +0 -1
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @purpose Rental contract acceptance with payment calculation and SAGE integration
|
|
4
|
-
* @reviewed 2025-07-29
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.acceptRentalDemo = void 0;
|
|
8
|
-
exports.acceptRental = acceptRental;
|
|
9
|
-
exports.getAcceptRentalInstructionAsync = getAcceptRentalInstructionAsync;
|
|
10
|
-
const config_1 = require("../utils/config");
|
|
11
|
-
const constants_1 = require("../utils/constants");
|
|
12
|
-
const utils_1 = require("../utils");
|
|
13
|
-
const instruction_converter_1 = require("../utils/instruction-converter");
|
|
14
|
-
const fetch_accounts_1 = require("../utils/fetch-accounts");
|
|
15
|
-
const cron_1 = require("../utils/cron");
|
|
16
|
-
const derive_pda_1 = require("../utils/derive-pda");
|
|
17
|
-
const signer_1 = require("../utils/signer");
|
|
18
|
-
const param_converters_1 = require("../utils/param-converters");
|
|
19
|
-
/**
|
|
20
|
-
* Internal function to accept a rental instruction with configuration options.
|
|
21
|
-
*
|
|
22
|
-
* This function handles the core logic of creating a rental acceptance instruction,
|
|
23
|
-
* including contract state fetching, payment calculation, account derivation, and
|
|
24
|
-
* instruction generation. It automatically validates contract constraints and
|
|
25
|
-
* calculates the required payment amount.
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
|
-
* @param params - The rental acceptance parameters
|
|
29
|
-
* @param config - Optional configuration for network and program settings
|
|
30
|
-
* @returns Promise resolving to a fluent instruction object
|
|
31
|
-
* @throws Error when contract is not found, duration constraints are violated, or account derivation fails
|
|
32
|
-
*/
|
|
33
|
-
async function _acceptRental(params, config) {
|
|
34
|
-
let { borrowerProfile, borrowerFaction, contract, duration } = params;
|
|
35
|
-
// Get the resolved addresses from config (including network-specific addresses)
|
|
36
|
-
const globalConfig = (0, config_1.getSdkConfig)();
|
|
37
|
-
const effectiveConfig = { ...globalConfig, ...config };
|
|
38
|
-
const resolvedAddresses = (0, config_1.resolveProgramAddresses)(effectiveConfig);
|
|
39
|
-
// Fetch contract state to get payment frequency and validate parameters
|
|
40
|
-
const contractState = await (0, fetch_accounts_1.fetchContractState)(contract);
|
|
41
|
-
const configState = await (0, fetch_accounts_1.fetchConfigState)();
|
|
42
|
-
// Extract data from contract state
|
|
43
|
-
const rate = contractState.rate; // Keep as bigint
|
|
44
|
-
const fleet = contractState.fleet;
|
|
45
|
-
// Resolve faction - use provided faction or fetch from fleet
|
|
46
|
-
if (!borrowerFaction) {
|
|
47
|
-
const fleetState = await (0, fetch_accounts_1.fetchFleetState)(fleet);
|
|
48
|
-
borrowerFaction = fleetState.faction;
|
|
49
|
-
}
|
|
50
|
-
// Convert duration to seconds using smart parameter converter
|
|
51
|
-
const durationSeconds = await (0, param_converters_1.convertDurationToSeconds)(duration);
|
|
52
|
-
// Get the actual period duration using prev/next method
|
|
53
|
-
const currentTime = Math.floor(Date.now() / 1000);
|
|
54
|
-
// Normalize the payment frequency for JavaScript cron-parser
|
|
55
|
-
const normalizedFreq = contractState.paymentsFeq.startsWith('@')
|
|
56
|
-
? {
|
|
57
|
-
'@hourly': '0 * * * *',
|
|
58
|
-
'@daily': '0 0 * * *',
|
|
59
|
-
'@weekly': '0 0 * * 0',
|
|
60
|
-
'@monthly': '0 0 1 * *',
|
|
61
|
-
'@decasecond': '*/10 * * * * *',
|
|
62
|
-
'@minute': '0 * * * * *',
|
|
63
|
-
}[contractState.paymentsFeq] || contractState.paymentsFeq
|
|
64
|
-
: contractState.paymentsFeq;
|
|
65
|
-
// Get actual period duration (not time-to-first-payment)
|
|
66
|
-
const actualPeriodDuration = (0, cron_1.getActualPeriodDuration)(normalizedFreq, currentTime);
|
|
67
|
-
// Calculate proportional amount using integer math
|
|
68
|
-
// amount = rate * duration / period * stardust_to_atlas
|
|
69
|
-
const amount = rate
|
|
70
|
-
* BigInt(durationSeconds)
|
|
71
|
-
/ BigInt(actualPeriodDuration)
|
|
72
|
-
* configState.stardustToAtlas;
|
|
73
|
-
// Derive the fee_token_account from config state
|
|
74
|
-
const feeTokenAccount = await (0, derive_pda_1.deriveFeeTokenAccount)(configState);
|
|
75
|
-
// Manually derive ALL game accounts - they all use different program addresses than main SAGE program
|
|
76
|
-
const { profileFaction, starbase, starbasePlayer } = await (0, utils_1.deriveGameAccounts)((0, constants_1.toAddress)(borrowerProfile), borrowerFaction, 0, // starbaseSeqId
|
|
77
|
-
contractState.gameId);
|
|
78
|
-
// Handle borrower using smart signer handler for universal compatibility
|
|
79
|
-
const borrower = (0, signer_1.createTransactionSigner)(params.borrower);
|
|
80
|
-
// Manually derive PDAs with correct program IDs
|
|
81
|
-
const rentalStatePda = await (0, derive_pda_1.deriveRental)((0, constants_1.toAddress)(contract), borrower.address, // Use TransactionSigner.address for PDA derivation
|
|
82
|
-
resolvedAddresses.srslyProgramAddress);
|
|
83
|
-
const rentalAuthorityPda = await (0, derive_pda_1.deriveRentalAuthority)(resolvedAddresses.srslyProgramAddress);
|
|
84
|
-
const rentalThreadPda = await (0, derive_pda_1.deriveRentalThread)(rentalAuthorityPda, rentalStatePda, resolvedAddresses.antegenProgramAddress);
|
|
85
|
-
const input = {
|
|
86
|
-
borrower: borrower,
|
|
87
|
-
borrowerProfile: (0, constants_1.toAddress)(borrowerProfile),
|
|
88
|
-
borrowerProfileFaction: (0, constants_1.toAddress)(profileFaction),
|
|
89
|
-
fleet: (0, constants_1.toAddress)(fleet),
|
|
90
|
-
contract: (0, constants_1.toAddress)(contract),
|
|
91
|
-
gameId: contractState.gameId,
|
|
92
|
-
starbase: (0, constants_1.toAddress)(starbase),
|
|
93
|
-
starbasePlayer: (0, constants_1.toAddress)(starbasePlayer),
|
|
94
|
-
// Override PDAs with correctly derived addresses
|
|
95
|
-
rentalState: rentalStatePda,
|
|
96
|
-
rentalAuthority: rentalAuthorityPda,
|
|
97
|
-
rentalThread: rentalThreadPda,
|
|
98
|
-
amount,
|
|
99
|
-
duration: durationSeconds,
|
|
100
|
-
feeTokenAccount,
|
|
101
|
-
mint: resolvedAddresses.atlasMint,
|
|
102
|
-
sageProgram: resolvedAddresses.sageProgramAddress,
|
|
103
|
-
antegenProgram: resolvedAddresses.antegenProgramAddress,
|
|
104
|
-
};
|
|
105
|
-
// Get network-specific codama functions from centralized config
|
|
106
|
-
const instructionsModule = (0, config_1.getModule)('instructions');
|
|
107
|
-
const { getAcceptRentalInstructionAsync } = instructionsModule;
|
|
108
|
-
const rawInstruction = await getAcceptRentalInstructionAsync(input, {
|
|
109
|
-
programAddress: resolvedAddresses.srslyProgramAddress,
|
|
110
|
-
});
|
|
111
|
-
return (0, instruction_converter_1.createFluentInstruction)(rawInstruction);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Creates an instruction to accept a rental contract with fluent configuration.
|
|
115
|
-
*
|
|
116
|
-
* This function allows a borrower to accept an existing rental contract, automatically
|
|
117
|
-
* calculating the required payment amount based on the contract's rate and payment frequency.
|
|
118
|
-
* The SDK fetches contract details, validates duration constraints, and derives all
|
|
119
|
-
* necessary accounts for the rental operation.
|
|
120
|
-
*
|
|
121
|
-
* ## Features
|
|
122
|
-
*
|
|
123
|
-
* - **Automatic Payment Calculation**: Fetches contract state and calculates exact payment amount
|
|
124
|
-
* - **Automatic Faction Resolution**: Optionally fetches faction from fleet account if not provided
|
|
125
|
-
* - **Duration Validation**: Ensures rental duration meets contract constraints
|
|
126
|
-
* - **Account Derivation**: Automatically derives all required game accounts
|
|
127
|
-
* - **SAGE Integration**: Sets up fleet ownership transfer in the Star Atlas ecosystem
|
|
128
|
-
* - **Clockwork Integration**: Configures automated payment scheduling
|
|
129
|
-
* - **Universal Library Support**: Works with both @solana/kit and @solana/web3.js
|
|
130
|
-
*
|
|
131
|
-
* ## Process
|
|
132
|
-
*
|
|
133
|
-
* 1. **Fetch Contract**: Retrieves contract state from the blockchain
|
|
134
|
-
* 2. **Validate Duration**: Checks that rental duration meets contract constraints
|
|
135
|
-
* 3. **Calculate Payment**: Computes payment amount using contract rate and payment frequency
|
|
136
|
-
* 4. **Derive Accounts**: Generates required game accounts (starbase, faction, etc.)
|
|
137
|
-
* 5. **Create Instruction**: Builds the rental acceptance instruction
|
|
138
|
-
* 6. **Setup Threading**: Configures automated payment processing
|
|
139
|
-
*
|
|
140
|
-
* ## Payment Calculation
|
|
141
|
-
*
|
|
142
|
-
* The payment amount is calculated using the formula:
|
|
143
|
-
* ```text
|
|
144
|
-
* payment = rate × payment_periods × stardust_to_atlas_conversion
|
|
145
|
-
* ```
|
|
146
|
-
*
|
|
147
|
-
* Where:
|
|
148
|
-
* - `rate`: Contract's rental rate per payment period
|
|
149
|
-
* - `payment_periods`: Duration divided by payment frequency interval
|
|
150
|
-
* - `stardust_to_atlas_conversion`: Network-specific conversion factor
|
|
151
|
-
*
|
|
152
|
-
* ## Requirements
|
|
153
|
-
*
|
|
154
|
-
* - Contract must exist and be active
|
|
155
|
-
* - Duration must be within contract's min/max limits
|
|
156
|
-
* - Duration must be multiple of payment frequency
|
|
157
|
-
* - Borrower must have sufficient ATLAS tokens for payment
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* import { acceptRental } from '@srsly/sdk';
|
|
162
|
-
*
|
|
163
|
-
* // Using smart duration parameters (recommended)
|
|
164
|
-
* const instruction = await acceptRental({
|
|
165
|
-
* borrower: wallet, // Wallet object for signing
|
|
166
|
-
* borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
|
|
167
|
-
* contract: "ContractAddr...", // Contract to accept
|
|
168
|
-
* duration: { days: 7 } // 7 days rental duration
|
|
169
|
-
* // borrowerFaction auto-resolved from fleet account
|
|
170
|
-
* });
|
|
171
|
-
*
|
|
172
|
-
* // Different duration formats
|
|
173
|
-
* const hourlyRental = await acceptRental({
|
|
174
|
-
* borrower: wallet,
|
|
175
|
-
* borrowerProfile: "ProfileAddr...",
|
|
176
|
-
* contract: "ContractAddr...",
|
|
177
|
-
* duration: { hours: 12 } // 12 hours
|
|
178
|
-
* });
|
|
179
|
-
*
|
|
180
|
-
* const weeklyRental = await acceptRental({
|
|
181
|
-
* borrower: wallet,
|
|
182
|
-
* borrowerProfile: "ProfileAddr...",
|
|
183
|
-
* contract: "ContractAddr...",
|
|
184
|
-
* duration: { weeks: 2 } // 2 weeks
|
|
185
|
-
* });
|
|
186
|
-
*
|
|
187
|
-
* const monthlyRental = await acceptRental({
|
|
188
|
-
* borrower: wallet,
|
|
189
|
-
* borrowerProfile: "ProfileAddr...",
|
|
190
|
-
* contract: "ContractAddr...",
|
|
191
|
-
* duration: { months: 1 } // 1 month
|
|
192
|
-
* });
|
|
193
|
-
*
|
|
194
|
-
* // Backwards compatible - raw seconds
|
|
195
|
-
* const legacyRental = await acceptRental({
|
|
196
|
-
* borrower: wallet,
|
|
197
|
-
* borrowerProfile: "ProfileAddr...",
|
|
198
|
-
* contract: "ContractAddr...",
|
|
199
|
-
* duration: 604800 // 7 days in seconds
|
|
200
|
-
* });
|
|
201
|
-
*
|
|
202
|
-
* // Manual faction specification (optional)
|
|
203
|
-
* const manualInstruction = await acceptRental({
|
|
204
|
-
* borrower: wallet.publicKey.toString(), // Address string for browser
|
|
205
|
-
* borrowerProfile: "ProfileAddr...", // Borrower's Star Atlas profile
|
|
206
|
-
* borrowerFaction: 'mud', // Optional: 'mud', 'oni', or 'ustur'
|
|
207
|
-
* contract: "ContractAddr...", // Contract to accept
|
|
208
|
-
* duration: { days: 7 } // 7 days rental duration
|
|
209
|
-
* });
|
|
210
|
-
*
|
|
211
|
-
* // Configure for mainnet
|
|
212
|
-
* const mainnetInstruction = await acceptRental({
|
|
213
|
-
* borrower: wallet, // Wallet object (CLI style)
|
|
214
|
-
* borrowerProfile: "ProfileAddr...",
|
|
215
|
-
* borrowerFaction: 1, // Can use numbers: 1=mud, 2=oni, 3=ustur
|
|
216
|
-
* contract: "ContractAddr...",
|
|
217
|
-
* duration: { days: 7 }
|
|
218
|
-
* }).set({ programs: 'mainnet' });
|
|
219
|
-
*
|
|
220
|
-
* // Use with your preferred Solana library
|
|
221
|
-
* const transaction = new Transaction().add(mainnetInstruction);
|
|
222
|
-
* await sendAndConfirmTransaction(connection, transaction, [wallet]);
|
|
223
|
-
* ```
|
|
224
|
-
*
|
|
225
|
-
* @param params - The rental acceptance parameters including borrower, contract, and duration
|
|
226
|
-
* @returns A SmartFluentConfigSelector that can be configured with .set() or awaited directly
|
|
227
|
-
* @throws Error when contract is not found, duration constraints are violated, or payment calculation fails
|
|
228
|
-
*/
|
|
229
|
-
function acceptRental(params) {
|
|
230
|
-
const baseSelector = (0, config_1.createSdkConfigSelector)(config => _acceptRental(params, config));
|
|
231
|
-
return (0, instruction_converter_1.createSmartFluentConfigSelector)(baseSelector);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Low-level function to create a rental acceptance instruction with raw input parameters.
|
|
235
|
-
*
|
|
236
|
-
* This function provides direct access to the underlying codama-generated instruction
|
|
237
|
-
* builder. It's primarily used internally by the SDK but can be used for advanced
|
|
238
|
-
* use cases where full control over instruction parameters is needed.
|
|
239
|
-
*
|
|
240
|
-
* @internal
|
|
241
|
-
* @param input - Raw instruction input parameters as expected by codama
|
|
242
|
-
* @param options - Optional instruction options including program address
|
|
243
|
-
* @returns A SdkConfigSelector for the raw instruction
|
|
244
|
-
*/
|
|
245
|
-
function getAcceptRentalInstructionAsync(input, options) {
|
|
246
|
-
return (0, config_1.createSdkConfigSelector)(async () => {
|
|
247
|
-
const instructionsModule = (0, config_1.getModule)('instructions');
|
|
248
|
-
return instructionsModule.getAcceptRentalInstructionAsync(input, options);
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
// Demo export for documentation site
|
|
252
|
-
exports.acceptRentalDemo = {
|
|
253
|
-
tabName: 'accept',
|
|
254
|
-
description: 'Accept a rental offer from an existing contract',
|
|
255
|
-
imports: `import { acceptRental } from '@wuwei-labs/srsly';`,
|
|
256
|
-
instruction: `const instruction = await acceptRental({
|
|
257
|
-
borrower: {{signerType}}.publicKey?.toBase58(),
|
|
258
|
-
borrowerProfile: "BORROWER_PROFILE_ADDRESS",
|
|
259
|
-
contract: "CONTRACT_ADDRESS",
|
|
260
|
-
duration: { days: 7 }
|
|
261
|
-
});`,
|
|
262
|
-
};
|
|
263
|
-
//# sourceMappingURL=accept.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/rental/accept.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwUH,oCAKC;AAcD,0EAKC;AA9VD,4CAOyB;AACzB,kDAAkE;AAClE,oCAA8C;AAC9C,0EAKwC;AACxC,4DAAgG;AAChG,wCAAwD;AACxD,oDAAqH;AACrH,4CAAgF;AAEhF,gEAAqE;AA4DrE;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,aAAa,CAC1B,MAA0B,EAC1B,MAAyB;IAEzB,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAEtE,gFAAgF;IAChF,MAAM,YAAY,GAAG,IAAA,qBAAY,GAAE,CAAC;IACpC,MAAM,eAAe,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACvD,MAAM,iBAAiB,GAAG,IAAA,gCAAuB,EAAC,eAAe,CAAC,CAAC;IAEnE,wEAAwE;IACxE,MAAM,aAAa,GAAG,MAAM,IAAA,mCAAkB,EAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG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@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @purpose Rental cancellation with penalty processing and thread cleanup
|
|
4
|
-
* @reviewed 2025-07-29
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.cancelRentalDemo = void 0;
|
|
8
|
-
exports.cancelRental = cancelRental;
|
|
9
|
-
exports.getCancelRentalInstructionAsync = getCancelRentalInstructionAsync;
|
|
10
|
-
const config_1 = require("../utils/config");
|
|
11
|
-
const constants_1 = require("../utils/constants");
|
|
12
|
-
const signer_1 = require("../utils/signer");
|
|
13
|
-
const instruction_converter_1 = require("../utils/instruction-converter");
|
|
14
|
-
const fetch_accounts_1 = require("../utils/fetch-accounts");
|
|
15
|
-
const derive_pda_1 = require("../utils/derive-pda");
|
|
16
|
-
/**
|
|
17
|
-
* Internal function to cancel a rental instruction with configuration options.
|
|
18
|
-
*
|
|
19
|
-
* This function handles the core logic of creating a rental cancellation instruction,
|
|
20
|
-
* including address resolution and instruction generation. The cancellation stops
|
|
21
|
-
* automated payments and may incur penalty fees.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
* @param params - The rental cancellation parameters
|
|
25
|
-
* @param config - Optional configuration for network and program settings
|
|
26
|
-
* @returns Promise resolving to a cancellation instruction
|
|
27
|
-
* @throws Error when instruction generation fails or required parameters are missing
|
|
28
|
-
*/
|
|
29
|
-
async function _cancelRental(params, config) {
|
|
30
|
-
let { contract, rental } = params;
|
|
31
|
-
// Validate that at least one parameter is provided
|
|
32
|
-
if (!contract && !rental) {
|
|
33
|
-
throw new Error('Either contract or rental must be provided');
|
|
34
|
-
}
|
|
35
|
-
// Prioritize rental over contract if both are provided
|
|
36
|
-
if (rental || !contract) {
|
|
37
|
-
const rentalState = await (0, fetch_accounts_1.fetchRentalState)((0, constants_1.toAddress)(rental));
|
|
38
|
-
contract = rentalState.contract;
|
|
39
|
-
}
|
|
40
|
-
// Handle borrower using smart signer handler for universal compatibility
|
|
41
|
-
const borrower = (0, signer_1.createTransactionSigner)(params.borrower);
|
|
42
|
-
// Get the resolved addresses from config (including network-specific addresses)
|
|
43
|
-
const globalConfig = (0, config_1.getSdkConfig)();
|
|
44
|
-
const effectiveConfig = { ...globalConfig, ...config };
|
|
45
|
-
const resolvedAddresses = (0, config_1.resolveProgramAddresses)(effectiveConfig);
|
|
46
|
-
// Fetch contract state using high-level function (same pattern as close contract)
|
|
47
|
-
const contractState = await (0, fetch_accounts_1.fetchContractState)((0, constants_1.toAddress)(contract));
|
|
48
|
-
// Fetch config state to get the authority using zero-argument overload
|
|
49
|
-
const configState = await (0, fetch_accounts_1.fetchConfigState)();
|
|
50
|
-
const authorityAddress = configState.authority;
|
|
51
|
-
// Derive PDAs individually (same pattern as accept rental to ensure consistency)
|
|
52
|
-
if (!rental) {
|
|
53
|
-
rental = await (0, derive_pda_1.deriveRental)((0, constants_1.toAddress)(contract), (0, constants_1.toAddress)(borrower.address), resolvedAddresses.srslyProgramAddress);
|
|
54
|
-
}
|
|
55
|
-
const rentalAuthorityPda = await (0, derive_pda_1.deriveRentalAuthority)(resolvedAddresses.srslyProgramAddress);
|
|
56
|
-
const rentalThreadPda = await (0, derive_pda_1.deriveRentalThread)(rentalAuthorityPda, (0, constants_1.toAddress)(rental), resolvedAddresses.antegenProgramAddress);
|
|
57
|
-
// Build the input with all required accounts (same pattern as accept rental)
|
|
58
|
-
const input = {
|
|
59
|
-
borrower: borrower,
|
|
60
|
-
owner: (0, constants_1.toAddress)(contractState.owner),
|
|
61
|
-
contract: (0, constants_1.toAddress)(contract),
|
|
62
|
-
authority: (0, constants_1.toAddress)(authorityAddress),
|
|
63
|
-
mint: resolvedAddresses.atlasMint,
|
|
64
|
-
// Override the auto-generated PDAs with our manually derived ones (same as accept rental)
|
|
65
|
-
rentalState: (0, constants_1.toAddress)(rental),
|
|
66
|
-
rentalAuthority: rentalAuthorityPda,
|
|
67
|
-
rentalThread: rentalThreadPda,
|
|
68
|
-
};
|
|
69
|
-
// Get network-specific codama functions from centralized config
|
|
70
|
-
const instructionsModule = (0, config_1.getModule)('instructions');
|
|
71
|
-
const { getCancelRentalInstructionAsync } = instructionsModule;
|
|
72
|
-
const rawInstruction = await getCancelRentalInstructionAsync(input, {
|
|
73
|
-
programAddress: resolvedAddresses.srslyProgramAddress,
|
|
74
|
-
});
|
|
75
|
-
return (0, instruction_converter_1.createFluentInstruction)(rawInstruction);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Creates an instruction to cancel a rental with fluent configuration.
|
|
79
|
-
*
|
|
80
|
-
* This function allows a borrower to cancel their active rental before the
|
|
81
|
-
* rental period expires. Canceling a rental stops automated payments but
|
|
82
|
-
* may incur penalty fees as defined in the contract terms. The fleet ownership
|
|
83
|
-
* is immediately returned to the original owner.
|
|
84
|
-
*
|
|
85
|
-
* ## Features
|
|
86
|
-
*
|
|
87
|
-
* - **Immediate Cancellation**: Stops the rental and automated payments immediately
|
|
88
|
-
* - **Fleet Transfer**: Returns fleet control to the original owner
|
|
89
|
-
* - **Thread Cleanup**: Cancels the automated payment thread
|
|
90
|
-
* - **Penalty Processing**: Handles any cancellation fees as defined in the contract
|
|
91
|
-
* - **Universal Library Support**: Works with both @solana/kit and @solana/web3.js
|
|
92
|
-
*
|
|
93
|
-
* ## Process
|
|
94
|
-
*
|
|
95
|
-
* 1. **Validate Authority**: Ensures only the borrower can cancel their rental
|
|
96
|
-
* 2. **Calculate Penalties**: Computes any cancellation fees owed
|
|
97
|
-
* 3. **Transfer Fleet**: Returns fleet ownership to the original owner
|
|
98
|
-
* 4. **Cancel Thread**: Stops automated payment processing
|
|
99
|
-
* 5. **Update State**: Marks rental as canceled in the rental state account
|
|
100
|
-
*
|
|
101
|
-
* ## Requirements
|
|
102
|
-
*
|
|
103
|
-
* - Rental must be active (not already canceled or completed)
|
|
104
|
-
* - Caller must be the original borrower
|
|
105
|
-
* - Borrower must have sufficient funds for any cancellation penalties
|
|
106
|
-
*
|
|
107
|
-
* ## Cancellation Effects
|
|
108
|
-
*
|
|
109
|
-
* - **Fleet Control**: Immediately returned to owner
|
|
110
|
-
* - **Automated Payments**: Stopped permanently
|
|
111
|
-
* - **Rental State**: Marked as canceled
|
|
112
|
-
* - **Thread Account**: Cleaned up and closed
|
|
113
|
-
* - **Penalties**: Charged according to contract terms
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* import { cancelRental } from '@srsly/sdk';
|
|
118
|
-
*
|
|
119
|
-
* // Cancel rental using contract address
|
|
120
|
-
* const instruction = await cancelRental({
|
|
121
|
-
* borrower: wallet,
|
|
122
|
-
* contract: "ContractAddr..."
|
|
123
|
-
* });
|
|
124
|
-
*
|
|
125
|
-
* // Cancel rental using rental state address (alternative approach)
|
|
126
|
-
* const instruction2 = await cancelRental({
|
|
127
|
-
* borrower: wallet,
|
|
128
|
-
* rental: "RentalStateAddr..."
|
|
129
|
-
* });
|
|
130
|
-
*
|
|
131
|
-
* // Configure for mainnet
|
|
132
|
-
* const mainnetInstruction = await cancelRental({
|
|
133
|
-
* borrower: wallet,
|
|
134
|
-
* contract: "ContractAddr..."
|
|
135
|
-
* }).set({ programs: 'mainnet' });
|
|
136
|
-
*
|
|
137
|
-
* // Convert to @solana/web3.js format
|
|
138
|
-
* const web3jsInstruction = await cancelRental({
|
|
139
|
-
* borrower: wallet,
|
|
140
|
-
* rental: "RentalStateAddr..."
|
|
141
|
-
* }).web3js();
|
|
142
|
-
*
|
|
143
|
-
* // Use with your preferred Solana library
|
|
144
|
-
* const transaction = new Transaction().add(web3jsInstruction);
|
|
145
|
-
* await sendAndConfirmTransaction(connection, transaction, [wallet]);
|
|
146
|
-
* ```
|
|
147
|
-
*
|
|
148
|
-
* @param params - The rental cancellation parameters including borrower and either contract or rentalState
|
|
149
|
-
* @returns A SmartFluentConfigSelector that can be configured with .set() or awaited directly
|
|
150
|
-
* @throws Error when rental is not active, caller is not the borrower, or instruction generation fails
|
|
151
|
-
*/
|
|
152
|
-
function cancelRental(params) {
|
|
153
|
-
const baseSelector = (0, config_1.createSdkConfigSelector)(config => _cancelRental(params, config));
|
|
154
|
-
return (0, instruction_converter_1.createSmartFluentConfigSelector)(baseSelector);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Low-level function to create a rental cancellation instruction with raw input parameters.
|
|
158
|
-
*
|
|
159
|
-
* This function provides direct access to the underlying codama-generated instruction
|
|
160
|
-
* builder. It's primarily used internally by the SDK but can be used for advanced
|
|
161
|
-
* use cases where full control over instruction parameters is needed.
|
|
162
|
-
*
|
|
163
|
-
* @internal
|
|
164
|
-
* @param input - Raw instruction input parameters as expected by codama
|
|
165
|
-
* @param options - Optional instruction options including program address
|
|
166
|
-
* @returns A SdkConfigSelector for the raw instruction
|
|
167
|
-
*/
|
|
168
|
-
function getCancelRentalInstructionAsync(input, options) {
|
|
169
|
-
return (0, config_1.createSdkConfigSelector)(async () => {
|
|
170
|
-
const instructionsModule = (0, config_1.getModule)('instructions');
|
|
171
|
-
return instructionsModule.getCancelRentalInstructionAsync(input, options);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
// Demo export for documentation site
|
|
175
|
-
exports.cancelRentalDemo = {
|
|
176
|
-
tabName: 'cancel',
|
|
177
|
-
description: 'Cancel an active rental (using contract address)',
|
|
178
|
-
imports: `import { cancelRental } from '@wuwei-labs/srsly';`,
|
|
179
|
-
instruction: `const instruction = await cancelRental({
|
|
180
|
-
borrower: {{signerType}}.publicKey?.toBase58(),
|
|
181
|
-
rental: "RENTAL_STATE_ADDRESS" // or contract: "CONTRACT_ADDRESS"
|
|
182
|
-
});`,
|
|
183
|
-
};
|
|
184
|
-
//# sourceMappingURL=cancel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/rental/cancel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmOH,oCAKC;AA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MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtF,OAAO,IAAA,uDAA+B,EAAC,YAAY,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,+BAA+B,CAAC,KAAU,EAAE,OAAa;IACvE,OAAO,IAAA,gCAAuB,EAAC,KAAK,IAAI,EAAE;QACxC,MAAM,kBAAkB,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,CAAC;QACrD,OAAO,kBAAkB,CAAC,+BAA+B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,qCAAqC;AACxB,QAAA,gBAAgB,GAAG;IAC9B,OAAO,EAAE,QAAQ;IACjB,WAAW,EAAE,kDAAkD;IAC/D,OAAO,EAAE,mDAAmD;IAC5D,WAAW,EAAE;;;IAGX;CACH,CAAC"}
|
package/dist/cjs/rental/close.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @purpose Rental closure with fund transfer and thread cleanup
|
|
4
|
-
* @reviewed 2025-07-29
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.closeRentalDemo = void 0;
|
|
8
|
-
exports.closeRental = closeRental;
|
|
9
|
-
exports.getCloseRentalInstructionAsync = getCloseRentalInstructionAsync;
|
|
10
|
-
const config_1 = require("../utils/config");
|
|
11
|
-
const constants_1 = require("../utils/constants");
|
|
12
|
-
const instruction_converter_1 = require("../utils/instruction-converter");
|
|
13
|
-
const fetch_accounts_1 = require("../utils/fetch-accounts");
|
|
14
|
-
const derive_pda_1 = require("../utils/derive-pda");
|
|
15
|
-
const signer_1 = require("../utils/signer");
|
|
16
|
-
/**
|
|
17
|
-
* Internal function to close a rental instruction with configuration options.
|
|
18
|
-
*
|
|
19
|
-
* This function handles the core logic of creating a rental closure instruction,
|
|
20
|
-
* including address resolution and instruction generation. The closure finalizes
|
|
21
|
-
* the rental period and transfers any remaining funds to the owner.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
* @param params - The rental closure parameters
|
|
25
|
-
* @param config - Optional configuration for network and program settings
|
|
26
|
-
* @returns Promise resolving to a closure instruction
|
|
27
|
-
* @throws Error when instruction generation fails or required parameters are missing
|
|
28
|
-
*/
|
|
29
|
-
async function _closeRental(params, config) {
|
|
30
|
-
let { payer, rental, borrowerProfile, borrowerFaction } = params;
|
|
31
|
-
// Get the resolved addresses from config (including network-specific addresses)
|
|
32
|
-
const globalConfig = (0, config_1.getSdkConfig)();
|
|
33
|
-
const effectiveConfig = { ...globalConfig, ...config };
|
|
34
|
-
const resolvedAddresses = (0, config_1.resolveProgramAddresses)(effectiveConfig);
|
|
35
|
-
const rentalState = await (0, fetch_accounts_1.fetchRentalState)(rental);
|
|
36
|
-
// Extract required addresses from rental state
|
|
37
|
-
const contract = rentalState.contract;
|
|
38
|
-
const borrower = rentalState.borrower;
|
|
39
|
-
const rentalAuthorityPda = await (0, derive_pda_1.deriveRentalAuthority)(resolvedAddresses.srslyProgramAddress.toString());
|
|
40
|
-
const rentalThreadPda = await (0, derive_pda_1.deriveRentalThread)(rentalAuthorityPda, (0, constants_1.toAddress)(rental), // Use the passed-in rental state address
|
|
41
|
-
resolvedAddresses.antegenProgramAddress);
|
|
42
|
-
// Fetch contract state to get owner and SAGE-related accounts
|
|
43
|
-
const contractState = await (0, fetch_accounts_1.fetchContractState)(contract);
|
|
44
|
-
// Fetch config state to get the authority using zero-argument overload
|
|
45
|
-
const configState = await (0, fetch_accounts_1.fetchConfigState)();
|
|
46
|
-
// Handle payer using smart signer handler for universal compatibility
|
|
47
|
-
const payerSigner = (0, signer_1.createTransactionSigner)(payer);
|
|
48
|
-
// Resolve faction - use provided faction or fetch from fleet
|
|
49
|
-
if (!borrowerFaction) {
|
|
50
|
-
const fleetState = await (0, fetch_accounts_1.fetchFleetState)(contractState.fleet);
|
|
51
|
-
borrowerFaction = fleetState.faction;
|
|
52
|
-
}
|
|
53
|
-
// Derive game accounts for the BORROWER (not the owner)
|
|
54
|
-
const gameAccounts = await (0, derive_pda_1.deriveGameAccounts)((0, constants_1.toAddress)(borrowerProfile), borrowerFaction, 0, // starbaseSeqId
|
|
55
|
-
contractState.gameId);
|
|
56
|
-
const starbase = (0, constants_1.toAddress)(gameAccounts.starbase);
|
|
57
|
-
const starbasePlayer = (0, constants_1.toAddress)(gameAccounts.starbasePlayer);
|
|
58
|
-
// Only provide required fields - let Codama auto-generate the rest except rental_thread
|
|
59
|
-
const input = {
|
|
60
|
-
payer: payerSigner, // Pass TransactionSigner for proper handling
|
|
61
|
-
mint: resolvedAddresses.atlasMint, // Use resolved ATLAS mint from config
|
|
62
|
-
authority: (0, constants_1.toAddress)(configState.authority), // Config authority for fee collection
|
|
63
|
-
borrower: (0, constants_1.toAddress)(borrower),
|
|
64
|
-
owner: (0, constants_1.toAddress)(contractState.owner),
|
|
65
|
-
contract: (0, constants_1.toAddress)(contract),
|
|
66
|
-
// Only override rental_thread since Codama can't auto-generate this one
|
|
67
|
-
rentalThread: rentalThreadPda, // Uses Antegen program ID!
|
|
68
|
-
// Add SAGE-related accounts
|
|
69
|
-
fleet: (0, constants_1.toAddress)(contractState.fleet),
|
|
70
|
-
gameId: contractState.gameId,
|
|
71
|
-
starbase: (0, constants_1.toAddress)(starbase),
|
|
72
|
-
starbasePlayer: (0, constants_1.toAddress)(starbasePlayer),
|
|
73
|
-
sageProgram: resolvedAddresses.sageProgramAddress,
|
|
74
|
-
};
|
|
75
|
-
// Get network-specific codama functions from centralized config
|
|
76
|
-
const instructionsModule = (0, config_1.getModule)('instructions');
|
|
77
|
-
const { getCloseRentalInstructionAsync } = instructionsModule;
|
|
78
|
-
const rawInstruction = await getCloseRentalInstructionAsync(input, {
|
|
79
|
-
programAddress: resolvedAddresses.srslyProgramAddress,
|
|
80
|
-
});
|
|
81
|
-
return (0, instruction_converter_1.createFluentInstruction)(rawInstruction);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates an instruction to close a completed rental with fluent configuration.
|
|
85
|
-
*
|
|
86
|
-
* This function finalizes a rental that has reached its expiration or been fully paid.
|
|
87
|
-
* It transfers any remaining funds to the owner, returns fleet control, and cleans up
|
|
88
|
-
* the rental state account. This instruction can be called by anyone once the rental
|
|
89
|
-
* period has ended.
|
|
90
|
-
*
|
|
91
|
-
* ## Features
|
|
92
|
-
*
|
|
93
|
-
* - **Rental Finalization**: Properly closes completed or expired rentals
|
|
94
|
-
* - **Fund Transfer**: Moves any remaining payments or deposits to the owner
|
|
95
|
-
* - **Fleet Return**: Ensures fleet ownership is returned to the original owner
|
|
96
|
-
* - **State Cleanup**: Closes rental state account and returns lamports
|
|
97
|
-
* - **Thread Cleanup**: Cleans up automated payment threads
|
|
98
|
-
* - **Universal Library Support**: Works with both @solana/kit and @solana/web3.js
|
|
99
|
-
*
|
|
100
|
-
* ## Process
|
|
101
|
-
*
|
|
102
|
-
* 1. **Validate Completion**: Ensures rental period has ended or been fully paid
|
|
103
|
-
* 2. **Transfer Funds**: Moves any remaining ATLAS tokens to owner's account
|
|
104
|
-
* 3. **Return Fleet**: Transfers fleet ownership back to original owner
|
|
105
|
-
* 4. **Clean State**: Closes rental state account and returns SOL to payer
|
|
106
|
-
* 5. **Cancel Thread**: Cleans up any remaining automated payment threads
|
|
107
|
-
*
|
|
108
|
-
* ## Requirements
|
|
109
|
-
*
|
|
110
|
-
* - Rental must be completed or expired
|
|
111
|
-
* - Owner token account must be valid ATLAS token account
|
|
112
|
-
* - Rental state account must exist and be properly initialized
|
|
113
|
-
*
|
|
114
|
-
* ## When to Use
|
|
115
|
-
*
|
|
116
|
-
* - **Natural Expiration**: When rental period has ended
|
|
117
|
-
* - **Full Payment**: When all required payments have been made
|
|
118
|
-
* - **Account Cleanup**: To close expired rental accounts and recover SOL
|
|
119
|
-
* - **Fleet Recovery**: When fleet needs to be returned to owner
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* import { closeRental } from '@srsly/sdk';
|
|
124
|
-
*
|
|
125
|
-
* // Close a completed rental
|
|
126
|
-
* const instruction = await closeRental({
|
|
127
|
-
* payer: wallet, // Transaction payer
|
|
128
|
-
* rental: "RentalState..." // Rental state address
|
|
129
|
-
* });
|
|
130
|
-
*
|
|
131
|
-
* // Configure for mainnet
|
|
132
|
-
* const mainnetInstruction = await closeRental({
|
|
133
|
-
* payer: wallet,
|
|
134
|
-
* rental: "RentalState..."
|
|
135
|
-
* }).set({ programs: 'mainnet' });
|
|
136
|
-
*
|
|
137
|
-
* // Convert to @solana/web3.js format
|
|
138
|
-
* const web3jsInstruction = await closeRental({
|
|
139
|
-
* payer: wallet,
|
|
140
|
-
* rental: "RentalState..."
|
|
141
|
-
* }).web3js(PublicKey);
|
|
142
|
-
*
|
|
143
|
-
* // Use with your preferred Solana library
|
|
144
|
-
* const transaction = new Transaction().add(web3jsInstruction);
|
|
145
|
-
* await sendAndConfirmTransaction(connection, transaction, [wallet]);
|
|
146
|
-
* ```
|
|
147
|
-
*
|
|
148
|
-
* @param params - The rental closure parameters including payer and rental state address
|
|
149
|
-
* @returns A FluentConfigSelector that can be configured with .set() or awaited directly
|
|
150
|
-
* @throws Error when rental is not ready for closure or instruction generation fails
|
|
151
|
-
*/
|
|
152
|
-
function closeRental(params) {
|
|
153
|
-
const baseSelector = (0, config_1.createSdkConfigSelector)(config => _closeRental(params, config));
|
|
154
|
-
return (0, instruction_converter_1.createSmartFluentConfigSelector)(baseSelector);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Low-level function to create a rental closure instruction with raw input parameters.
|
|
158
|
-
*
|
|
159
|
-
* This function provides direct access to the underlying codama-generated instruction
|
|
160
|
-
* builder. It's primarily used internally by the SDK but can be used for advanced
|
|
161
|
-
* use cases where full control over instruction parameters is needed.
|
|
162
|
-
*
|
|
163
|
-
* @internal
|
|
164
|
-
* @param input - Raw instruction input parameters as expected by codama
|
|
165
|
-
* @param options - Optional instruction options including program address
|
|
166
|
-
* @returns A SdkConfigSelector for the raw instruction
|
|
167
|
-
*/
|
|
168
|
-
function getCloseRentalInstructionAsync(input, options) {
|
|
169
|
-
return (0, config_1.createSdkConfigSelector)(async () => {
|
|
170
|
-
const instructionsModule = (0, config_1.getModule)('instructions');
|
|
171
|
-
return instructionsModule.getCloseRentalInstructionAsync(input, options);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
// Demo export for documentation site
|
|
175
|
-
exports.closeRentalDemo = {
|
|
176
|
-
tabName: 'close',
|
|
177
|
-
description: 'Close a completed rental',
|
|
178
|
-
imports: `import { closeRental } from '@wuwei-labs/srsly';`,
|
|
179
|
-
instruction: `const instruction = await closeRental({
|
|
180
|
-
payer: {{signerType}}.publicKey?.toBase58(),
|
|
181
|
-
rental: "RENTAL_STATE_ADDRESS"
|
|
182
|
-
});`,
|
|
183
|
-
};
|
|
184
|
-
//# sourceMappingURL=close.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/rental/close.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+NH,kCAKC;AAcD,wEAKC;AArPD,4CAOyB;AACzB,kDAA+C;AAC/C,0EAKwC;AACxC,4DAAkH;AAClH,oDAAoG;AACpG,4CAAgF;AAwChF;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,YAAY,CACzB,MAAyB,EACzB,MAAyB;IAEzB,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAEjE,gFAAgF;IAChF,MAAM,YAAY,GAAG,IAAA,qBAAY,GAAE,CAAC;IACpC,MAAM,eAAe,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC;IACvD,MAAM,iBAAiB,GAAG,IAAA,gCAAuB,EA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