@opcat-labs/cat-sdk 1.0.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 +19 -0
- package/artifacts/.templates/cat20/cat20.scrypt.map +1 -0
- package/artifacts/.templates/cat20/cat20.scrypt.tpl +60 -0
- package/artifacts/.templates/cat20/cat20.transformer.json +9 -0
- package/artifacts/.templates/cat20/cat20Guard.scrypt.map +1 -0
- package/artifacts/.templates/cat20/cat20Guard.scrypt.tpl +117 -0
- package/artifacts/.templates/cat20/cat20Guard.transformer.json +9 -0
- package/artifacts/.templates/cat20/cat20GuardStateLib.scrypt.map +1 -0
- package/artifacts/.templates/cat20/cat20GuardStateLib.scrypt.tpl +36 -0
- package/artifacts/.templates/cat20/cat20GuardStateLib.transformer.json +7 -0
- package/artifacts/.templates/cat20/cat20StateLib.scrypt.map +1 -0
- package/artifacts/.templates/cat20/cat20StateLib.scrypt.tpl +21 -0
- package/artifacts/.templates/cat20/cat20StateLib.transformer.json +7 -0
- package/artifacts/.templates/cat20/minters/cat20ClosedMinter.scrypt.map +1 -0
- package/artifacts/.templates/cat20/minters/cat20ClosedMinter.scrypt.tpl +61 -0
- package/artifacts/.templates/cat20/minters/cat20ClosedMinter.transformer.json +9 -0
- package/artifacts/.templates/cat20/minters/cat20ClosedMinterMetadata.scrypt.map +1 -0
- package/artifacts/.templates/cat20/minters/cat20ClosedMinterMetadata.scrypt.tpl +11 -0
- package/artifacts/.templates/cat20/minters/cat20ClosedMinterMetadata.transformer.json +7 -0
- package/artifacts/.templates/cat20/minters/cat20OpenMinter.scrypt.map +1 -0
- package/artifacts/.templates/cat20/minters/cat20OpenMinter.scrypt.tpl +94 -0
- package/artifacts/.templates/cat20/minters/cat20OpenMinter.transformer.json +9 -0
- package/artifacts/.templates/cat20/minters/cat20OpenMinterMetadata.scrypt.map +1 -0
- package/artifacts/.templates/cat20/minters/cat20OpenMinterMetadata.scrypt.tpl +11 -0
- package/artifacts/.templates/cat20/minters/cat20OpenMinterMetadata.transformer.json +7 -0
- package/artifacts/.templates/cat20/types.scrypt.map +1 -0
- package/artifacts/.templates/cat20/types.scrypt.tpl +45 -0
- package/artifacts/.templates/cat20/types.transformer.json +7 -0
- package/artifacts/.templates/cat20Incinerator.scrypt.map +1 -0
- package/artifacts/.templates/cat20Incinerator.scrypt.tpl +31 -0
- package/artifacts/.templates/cat20Incinerator.transformer.json +9 -0
- package/artifacts/.templates/constants.scrypt.map +1 -0
- package/artifacts/.templates/constants.scrypt.tpl +16 -0
- package/artifacts/.templates/constants.transformer.json +7 -0
- package/artifacts/.templates/counter.scrypt.map +1 -0
- package/artifacts/.templates/counter.scrypt.tpl +36 -0
- package/artifacts/.templates/counter.transformer.json +9 -0
- package/artifacts/.templates/p2pkh.scrypt.map +1 -0
- package/artifacts/.templates/p2pkh.scrypt.tpl +11 -0
- package/artifacts/.templates/p2pkh.transformer.json +7 -0
- package/artifacts/.templates/types.scrypt.map +1 -0
- package/artifacts/.templates/types.scrypt.tpl +6 -0
- package/artifacts/.templates/types.transformer.json +7 -0
- package/artifacts/.templates/utils/ownerUtils.scrypt.map +1 -0
- package/artifacts/.templates/utils/ownerUtils.scrypt.tpl +26 -0
- package/artifacts/.templates/utils/ownerUtils.transformer.json +7 -0
- package/artifacts/.templates/utils/safeMath.scrypt.map +1 -0
- package/artifacts/.templates/utils/safeMath.scrypt.tpl +11 -0
- package/artifacts/.templates/utils/safeMath.transformer.json +7 -0
- package/artifacts/cat20/cat20.json +477 -0
- package/artifacts/cat20/cat20.scrypt +62 -0
- package/artifacts/cat20/cat20Guard.json +447 -0
- package/artifacts/cat20/cat20Guard.scrypt +119 -0
- package/artifacts/cat20/cat20GuardStateLib.json +361 -0
- package/artifacts/cat20/cat20GuardStateLib.scrypt +38 -0
- package/artifacts/cat20/cat20StateLib.json +373 -0
- package/artifacts/cat20/cat20StateLib.scrypt +23 -0
- package/artifacts/cat20/minters/cat20ClosedMinter.json +477 -0
- package/artifacts/cat20/minters/cat20ClosedMinter.scrypt +63 -0
- package/artifacts/cat20/minters/cat20ClosedMinterMetadata.json +173 -0
- package/artifacts/cat20/minters/cat20ClosedMinterMetadata.scrypt +13 -0
- package/artifacts/cat20/minters/cat20OpenMinter.json +508 -0
- package/artifacts/cat20/minters/cat20OpenMinter.scrypt +96 -0
- package/artifacts/cat20/minters/cat20OpenMinterMetadata.json +173 -0
- package/artifacts/cat20/minters/cat20OpenMinterMetadata.scrypt +13 -0
- package/artifacts/cat20/types.json +159 -0
- package/artifacts/cat20/types.scrypt +47 -0
- package/artifacts/cat20Incinerator.json +396 -0
- package/artifacts/cat20Incinerator.scrypt +33 -0
- package/artifacts/constants.json +26 -0
- package/artifacts/constants.scrypt +18 -0
- package/artifacts/counter.json +253 -0
- package/artifacts/counter.scrypt +38 -0
- package/artifacts/p2pkh.json +229 -0
- package/artifacts/p2pkh.scrypt +13 -0
- package/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/backtrace.scrypt +38 -0
- package/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/contextUtils.scrypt +93 -0
- package/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/stateUtils.scrypt +9 -0
- package/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/stdUtils.scrypt +96 -0
- package/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/txHashPreimageUtils.scrypt +20 -0
- package/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/txUtils.scrypt +48 -0
- package/artifacts/scrypt-ts-opcat/assets/smart-contract/types/structs.scrypt +50 -0
- package/artifacts/types.json +33 -0
- package/artifacts/types.scrypt +8 -0
- package/artifacts/utils/ownerUtils.json +215 -0
- package/artifacts/utils/ownerUtils.scrypt +28 -0
- package/artifacts/utils/safeMath.json +215 -0
- package/artifacts/utils/safeMath.scrypt +13 -0
- package/dist/artifacts/.templates/cat20/cat20.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/cat20.scrypt.tpl +60 -0
- package/dist/artifacts/.templates/cat20/cat20.transformer.json +9 -0
- package/dist/artifacts/.templates/cat20/cat20Guard.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/cat20Guard.scrypt.tpl +117 -0
- package/dist/artifacts/.templates/cat20/cat20Guard.transformer.json +9 -0
- package/dist/artifacts/.templates/cat20/cat20GuardStateLib.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/cat20GuardStateLib.scrypt.tpl +36 -0
- package/dist/artifacts/.templates/cat20/cat20GuardStateLib.transformer.json +7 -0
- package/dist/artifacts/.templates/cat20/cat20StateLib.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/cat20StateLib.scrypt.tpl +21 -0
- package/dist/artifacts/.templates/cat20/cat20StateLib.transformer.json +7 -0
- package/dist/artifacts/.templates/cat20/minters/cat20ClosedMinter.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/minters/cat20ClosedMinter.scrypt.tpl +61 -0
- package/dist/artifacts/.templates/cat20/minters/cat20ClosedMinter.transformer.json +9 -0
- package/dist/artifacts/.templates/cat20/minters/cat20ClosedMinterMetadata.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/minters/cat20ClosedMinterMetadata.scrypt.tpl +11 -0
- package/dist/artifacts/.templates/cat20/minters/cat20ClosedMinterMetadata.transformer.json +7 -0
- package/dist/artifacts/.templates/cat20/minters/cat20OpenMinter.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/minters/cat20OpenMinter.scrypt.tpl +94 -0
- package/dist/artifacts/.templates/cat20/minters/cat20OpenMinter.transformer.json +9 -0
- package/dist/artifacts/.templates/cat20/minters/cat20OpenMinterMetadata.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/minters/cat20OpenMinterMetadata.scrypt.tpl +11 -0
- package/dist/artifacts/.templates/cat20/minters/cat20OpenMinterMetadata.transformer.json +7 -0
- package/dist/artifacts/.templates/cat20/types.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20/types.scrypt.tpl +45 -0
- package/dist/artifacts/.templates/cat20/types.transformer.json +7 -0
- package/dist/artifacts/.templates/cat20Incinerator.scrypt.map +1 -0
- package/dist/artifacts/.templates/cat20Incinerator.scrypt.tpl +31 -0
- package/dist/artifacts/.templates/cat20Incinerator.transformer.json +9 -0
- package/dist/artifacts/.templates/constants.scrypt.map +1 -0
- package/dist/artifacts/.templates/constants.scrypt.tpl +16 -0
- package/dist/artifacts/.templates/constants.transformer.json +7 -0
- package/dist/artifacts/.templates/counter.scrypt.map +1 -0
- package/dist/artifacts/.templates/counter.scrypt.tpl +36 -0
- package/dist/artifacts/.templates/counter.transformer.json +9 -0
- package/dist/artifacts/.templates/p2pkh.scrypt.map +1 -0
- package/dist/artifacts/.templates/p2pkh.scrypt.tpl +11 -0
- package/dist/artifacts/.templates/p2pkh.transformer.json +7 -0
- package/dist/artifacts/.templates/types.scrypt.map +1 -0
- package/dist/artifacts/.templates/types.scrypt.tpl +6 -0
- package/dist/artifacts/.templates/types.transformer.json +7 -0
- package/dist/artifacts/.templates/utils/ownerUtils.scrypt.map +1 -0
- package/dist/artifacts/.templates/utils/ownerUtils.scrypt.tpl +26 -0
- package/dist/artifacts/.templates/utils/ownerUtils.transformer.json +7 -0
- package/dist/artifacts/.templates/utils/safeMath.scrypt.map +1 -0
- package/dist/artifacts/.templates/utils/safeMath.scrypt.tpl +11 -0
- package/dist/artifacts/.templates/utils/safeMath.transformer.json +7 -0
- package/dist/artifacts/cat20/cat20.json +477 -0
- package/dist/artifacts/cat20/cat20.scrypt +62 -0
- package/dist/artifacts/cat20/cat20Guard.json +447 -0
- package/dist/artifacts/cat20/cat20Guard.scrypt +119 -0
- package/dist/artifacts/cat20/cat20GuardStateLib.json +361 -0
- package/dist/artifacts/cat20/cat20GuardStateLib.scrypt +38 -0
- package/dist/artifacts/cat20/cat20StateLib.json +373 -0
- package/dist/artifacts/cat20/cat20StateLib.scrypt +23 -0
- package/dist/artifacts/cat20/minters/cat20ClosedMinter.json +477 -0
- package/dist/artifacts/cat20/minters/cat20ClosedMinter.scrypt +63 -0
- package/dist/artifacts/cat20/minters/cat20ClosedMinterMetadata.json +173 -0
- package/dist/artifacts/cat20/minters/cat20ClosedMinterMetadata.scrypt +13 -0
- package/dist/artifacts/cat20/minters/cat20OpenMinter.json +508 -0
- package/dist/artifacts/cat20/minters/cat20OpenMinter.scrypt +96 -0
- package/dist/artifacts/cat20/minters/cat20OpenMinterMetadata.json +173 -0
- package/dist/artifacts/cat20/minters/cat20OpenMinterMetadata.scrypt +13 -0
- package/dist/artifacts/cat20/types.json +159 -0
- package/dist/artifacts/cat20/types.scrypt +47 -0
- package/dist/artifacts/cat20Incinerator.json +396 -0
- package/dist/artifacts/cat20Incinerator.scrypt +33 -0
- package/dist/artifacts/constants.json +26 -0
- package/dist/artifacts/constants.scrypt +18 -0
- package/dist/artifacts/counter.json +253 -0
- package/dist/artifacts/counter.scrypt +38 -0
- package/dist/artifacts/p2pkh.json +229 -0
- package/dist/artifacts/p2pkh.scrypt +13 -0
- package/dist/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/backtrace.scrypt +38 -0
- package/dist/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/contextUtils.scrypt +93 -0
- package/dist/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/stateUtils.scrypt +9 -0
- package/dist/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/stdUtils.scrypt +96 -0
- package/dist/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/txHashPreimageUtils.scrypt +20 -0
- package/dist/artifacts/scrypt-ts-opcat/assets/smart-contract/builtin-libs/txUtils.scrypt +48 -0
- package/dist/artifacts/scrypt-ts-opcat/assets/smart-contract/types/structs.scrypt +50 -0
- package/dist/artifacts/types.json +33 -0
- package/dist/artifacts/types.scrypt +8 -0
- package/dist/artifacts/utils/ownerUtils.json +215 -0
- package/dist/artifacts/utils/ownerUtils.scrypt +28 -0
- package/dist/artifacts/utils/safeMath.json +215 -0
- package/dist/artifacts/utils/safeMath.scrypt +13 -0
- package/dist/cjs/contracts/cat20/cat20.js +74 -0
- package/dist/cjs/contracts/cat20/cat20.js.map +1 -0
- package/dist/cjs/contracts/cat20/cat20Guard.js +169 -0
- package/dist/cjs/contracts/cat20/cat20Guard.js.map +1 -0
- package/dist/cjs/contracts/cat20/cat20GuardStateLib.js +72 -0
- package/dist/cjs/contracts/cat20/cat20GuardStateLib.js.map +1 -0
- package/dist/cjs/contracts/cat20/cat20StateLib.js +37 -0
- package/dist/cjs/contracts/cat20/cat20StateLib.js.map +1 -0
- package/dist/cjs/contracts/cat20/minters/cat20ClosedMinter.js +77 -0
- package/dist/cjs/contracts/cat20/minters/cat20ClosedMinter.js.map +1 -0
- package/dist/cjs/contracts/cat20/minters/cat20ClosedMinterMetadata.js +18 -0
- package/dist/cjs/contracts/cat20/minters/cat20ClosedMinterMetadata.js.map +1 -0
- package/dist/cjs/contracts/cat20/minters/cat20OpenMinter.js +138 -0
- package/dist/cjs/contracts/cat20/minters/cat20OpenMinter.js.map +1 -0
- package/dist/cjs/contracts/cat20/minters/cat20OpenMinterMetadata.js +22 -0
- package/dist/cjs/contracts/cat20/minters/cat20OpenMinterMetadata.js.map +1 -0
- package/dist/cjs/contracts/cat20/types.js +3 -0
- package/dist/cjs/contracts/cat20/types.js.map +1 -0
- package/dist/cjs/contracts/cat20Incinerator.js +45 -0
- package/dist/cjs/contracts/cat20Incinerator.js.map +1 -0
- package/dist/cjs/contracts/constants.js +110 -0
- package/dist/cjs/contracts/constants.js.map +1 -0
- package/dist/cjs/contracts/counter.js +29 -0
- package/dist/cjs/contracts/counter.js.map +1 -0
- package/dist/cjs/contracts/index.js +32 -0
- package/dist/cjs/contracts/index.js.map +1 -0
- package/dist/cjs/contracts/p2pkh.js +35 -0
- package/dist/cjs/contracts/p2pkh.js.map +1 -0
- package/dist/cjs/contracts/types.js +3 -0
- package/dist/cjs/contracts/types.js.map +1 -0
- package/dist/cjs/contracts/utils/ownerUtils.js +78 -0
- package/dist/cjs/contracts/utils/ownerUtils.js.map +1 -0
- package/dist/cjs/contracts/utils/safeMath.js +28 -0
- package/dist/cjs/contracts/utils/safeMath.js.map +1 -0
- package/dist/cjs/features/cat20/burn/burn.js +91 -0
- package/dist/cjs/features/cat20/burn/burn.js.map +1 -0
- package/dist/cjs/features/cat20/deploy/openMinter.js +135 -0
- package/dist/cjs/features/cat20/deploy/openMinter.js.map +1 -0
- package/dist/cjs/features/cat20/incinerate.js +108 -0
- package/dist/cjs/features/cat20/incinerate.js.map +1 -0
- package/dist/cjs/features/cat20/mint/openMinter.js +37 -0
- package/dist/cjs/features/cat20/mint/openMinter.js.map +1 -0
- package/dist/cjs/features/cat20/send/contractSend.js +130 -0
- package/dist/cjs/features/cat20/send/contractSend.js.map +1 -0
- package/dist/cjs/features/cat20/send/singleSend.js +172 -0
- package/dist/cjs/features/cat20/send/singleSend.js.map +1 -0
- package/dist/cjs/features/index.js +19 -0
- package/dist/cjs/features/index.js.map +1 -0
- package/dist/cjs/index.js +35 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/index.js +19 -0
- package/dist/cjs/lib/index.js.map +1 -0
- package/dist/cjs/lib/metadata.js +32 -0
- package/dist/cjs/lib/metadata.js.map +1 -0
- package/dist/cjs/typeConstants.js +18 -0
- package/dist/cjs/typeConstants.js.map +1 -0
- package/dist/cjs/utils/check.js +24 -0
- package/dist/cjs/utils/check.js.map +1 -0
- package/dist/cjs/utils/contractPeripheral.js +189 -0
- package/dist/cjs/utils/contractPeripheral.js.map +1 -0
- package/dist/cjs/utils/index.js +223 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/loadAllArtifacts.js +39 -0
- package/dist/cjs/utils/loadAllArtifacts.js.map +1 -0
- package/dist/esm/contracts/cat20/cat20.js +72 -0
- package/dist/esm/contracts/cat20/cat20.js.map +1 -0
- package/dist/esm/contracts/cat20/cat20Guard.js +165 -0
- package/dist/esm/contracts/cat20/cat20Guard.js.map +1 -0
- package/dist/esm/contracts/cat20/cat20GuardStateLib.js +68 -0
- package/dist/esm/contracts/cat20/cat20GuardStateLib.js.map +1 -0
- package/dist/esm/contracts/cat20/cat20StateLib.js +33 -0
- package/dist/esm/contracts/cat20/cat20StateLib.js.map +1 -0
- package/dist/esm/contracts/cat20/minters/cat20ClosedMinter.js +75 -0
- package/dist/esm/contracts/cat20/minters/cat20ClosedMinter.js.map +1 -0
- package/dist/esm/contracts/cat20/minters/cat20ClosedMinterMetadata.js +14 -0
- package/dist/esm/contracts/cat20/minters/cat20ClosedMinterMetadata.js.map +1 -0
- package/dist/esm/contracts/cat20/minters/cat20OpenMinter.js +142 -0
- package/dist/esm/contracts/cat20/minters/cat20OpenMinter.js.map +1 -0
- package/dist/esm/contracts/cat20/minters/cat20OpenMinterMetadata.js +18 -0
- package/dist/esm/contracts/cat20/minters/cat20OpenMinterMetadata.js.map +1 -0
- package/dist/esm/contracts/cat20/types.js +2 -0
- package/dist/esm/contracts/cat20/types.js.map +1 -0
- package/dist/esm/contracts/cat20Incinerator.js +42 -0
- package/dist/esm/contracts/cat20Incinerator.js.map +1 -0
- package/dist/esm/contracts/constants.js +106 -0
- package/dist/esm/contracts/constants.js.map +1 -0
- package/dist/esm/contracts/counter.js +25 -0
- package/dist/esm/contracts/counter.js.map +1 -0
- package/dist/esm/contracts/index.js +16 -0
- package/dist/esm/contracts/index.js.map +1 -0
- package/dist/esm/contracts/p2pkh.js +32 -0
- package/dist/esm/contracts/p2pkh.js.map +1 -0
- package/dist/esm/contracts/types.js +2 -0
- package/dist/esm/contracts/types.js.map +1 -0
- package/dist/esm/contracts/utils/ownerUtils.js +74 -0
- package/dist/esm/contracts/utils/ownerUtils.js.map +1 -0
- package/dist/esm/contracts/utils/safeMath.js +24 -0
- package/dist/esm/contracts/utils/safeMath.js.map +1 -0
- package/dist/esm/features/cat20/burn/burn.js +87 -0
- package/dist/esm/features/cat20/burn/burn.js.map +1 -0
- package/dist/esm/features/cat20/deploy/openMinter.js +130 -0
- package/dist/esm/features/cat20/deploy/openMinter.js.map +1 -0
- package/dist/esm/features/cat20/incinerate.js +104 -0
- package/dist/esm/features/cat20/incinerate.js.map +1 -0
- package/dist/esm/features/cat20/mint/openMinter.js +33 -0
- package/dist/esm/features/cat20/mint/openMinter.js.map +1 -0
- package/dist/esm/features/cat20/send/contractSend.js +126 -0
- package/dist/esm/features/cat20/send/contractSend.js.map +1 -0
- package/dist/esm/features/cat20/send/singleSend.js +142 -0
- package/dist/esm/features/cat20/send/singleSend.js.map +1 -0
- package/dist/esm/features/index.js +7 -0
- package/dist/esm/features/index.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/index.js +3 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/metadata.js +28 -0
- package/dist/esm/lib/metadata.js.map +1 -0
- package/dist/esm/typeConstants.js +15 -0
- package/dist/esm/typeConstants.js.map +1 -0
- package/dist/esm/utils/check.js +19 -0
- package/dist/esm/utils/check.js.map +1 -0
- package/dist/esm/utils/contractPeripheral.js +183 -0
- package/dist/esm/utils/contractPeripheral.js.map +1 -0
- package/dist/esm/utils/index.js +184 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/loadAllArtifacts.js +32 -0
- package/dist/esm/utils/loadAllArtifacts.js.map +1 -0
- package/dist/types/contracts/cat20/cat20.d.ts +12 -0
- package/dist/types/contracts/cat20/cat20.d.ts.map +1 -0
- package/dist/types/contracts/cat20/cat20Guard.d.ts +8 -0
- package/dist/types/contracts/cat20/cat20Guard.d.ts.map +1 -0
- package/dist/types/contracts/cat20/cat20GuardStateLib.d.ts +13 -0
- package/dist/types/contracts/cat20/cat20GuardStateLib.d.ts.map +1 -0
- package/dist/types/contracts/cat20/cat20StateLib.d.ts +7 -0
- package/dist/types/contracts/cat20/cat20StateLib.d.ts.map +1 -0
- package/dist/types/contracts/cat20/minters/cat20ClosedMinter.d.ts +10 -0
- package/dist/types/contracts/cat20/minters/cat20ClosedMinter.d.ts.map +1 -0
- package/dist/types/contracts/cat20/minters/cat20ClosedMinterMetadata.d.ts +6 -0
- package/dist/types/contracts/cat20/minters/cat20ClosedMinterMetadata.d.ts.map +1 -0
- package/dist/types/contracts/cat20/minters/cat20OpenMinter.d.ts +16 -0
- package/dist/types/contracts/cat20/minters/cat20OpenMinter.d.ts.map +1 -0
- package/dist/types/contracts/cat20/minters/cat20OpenMinterMetadata.d.ts +6 -0
- package/dist/types/contracts/cat20/minters/cat20OpenMinterMetadata.d.ts.map +1 -0
- package/dist/types/contracts/cat20/types.d.ts +58 -0
- package/dist/types/contracts/cat20/types.d.ts.map +1 -0
- package/dist/types/contracts/cat20Incinerator.d.ts +8 -0
- package/dist/types/contracts/cat20Incinerator.d.ts.map +1 -0
- package/dist/types/contracts/constants.d.ts +33 -0
- package/dist/types/contracts/constants.d.ts.map +1 -0
- package/dist/types/contracts/counter.d.ts +8 -0
- package/dist/types/contracts/counter.d.ts.map +1 -0
- package/dist/types/contracts/index.d.ts +16 -0
- package/dist/types/contracts/index.d.ts.map +1 -0
- package/dist/types/contracts/p2pkh.d.ts +7 -0
- package/dist/types/contracts/p2pkh.d.ts.map +1 -0
- package/dist/types/contracts/types.d.ts +9 -0
- package/dist/types/contracts/types.d.ts.map +1 -0
- package/dist/types/contracts/utils/ownerUtils.d.ts +19 -0
- package/dist/types/contracts/utils/ownerUtils.d.ts.map +1 -0
- package/dist/types/contracts/utils/safeMath.d.ts +5 -0
- package/dist/types/contracts/utils/safeMath.d.ts.map +1 -0
- package/dist/types/features/cat20/burn/burn.d.ts +6 -0
- package/dist/types/features/cat20/burn/burn.d.ts.map +1 -0
- package/dist/types/features/cat20/deploy/openMinter.d.ts +11 -0
- package/dist/types/features/cat20/deploy/openMinter.d.ts.map +1 -0
- package/dist/types/features/cat20/incinerate.d.ts +6 -0
- package/dist/types/features/cat20/incinerate.d.ts.map +1 -0
- package/dist/types/features/cat20/mint/openMinter.d.ts +7 -0
- package/dist/types/features/cat20/mint/openMinter.d.ts.map +1 -0
- package/dist/types/features/cat20/send/contractSend.d.ts +14 -0
- package/dist/types/features/cat20/send/contractSend.d.ts.map +1 -0
- package/dist/types/features/cat20/send/singleSend.d.ts +33 -0
- package/dist/types/features/cat20/send/singleSend.d.ts.map +1 -0
- package/dist/types/features/index.d.ts +7 -0
- package/dist/types/features/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/index.d.ts.map +1 -0
- package/dist/types/lib/metadata.d.ts +18 -0
- package/dist/types/lib/metadata.d.ts.map +1 -0
- package/dist/types/typeConstants.d.ts +31 -0
- package/dist/types/typeConstants.d.ts.map +1 -0
- package/dist/types/utils/check.d.ts +3 -0
- package/dist/types/utils/check.d.ts.map +1 -0
- package/dist/types/utils/contractPeripheral.d.ts +45 -0
- package/dist/types/utils/contractPeripheral.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +29 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/loadAllArtifacts.d.ts +2 -0
- package/dist/types/utils/loadAllArtifacts.d.ts.map +1 -0
- package/package.json +76 -0
- package/scrypt.index.json +132 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 10,
|
|
3
|
+
"compilerVersion": "1.21.0+commit.2ada378",
|
|
4
|
+
"contract": "_opcat_labs_cat_sdk_1_0_1__rs__SafeMath",
|
|
5
|
+
"md5": "d41d8cd98f00b204e9800998ecf8427e",
|
|
6
|
+
"structs": [
|
|
7
|
+
{
|
|
8
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__TxOut",
|
|
9
|
+
"params": [
|
|
10
|
+
{
|
|
11
|
+
"name": "scriptHash",
|
|
12
|
+
"type": "bytes"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "dataHash",
|
|
16
|
+
"type": "bytes"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "satoshis",
|
|
20
|
+
"type": "int"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"genericTypes": []
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__TxIn",
|
|
27
|
+
"params": [
|
|
28
|
+
{
|
|
29
|
+
"name": "prevTxHash",
|
|
30
|
+
"type": "bytes"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "prevOutputIndex",
|
|
34
|
+
"type": "int"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "sequence",
|
|
38
|
+
"type": "int"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "scriptHash",
|
|
42
|
+
"type": "bytes"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"genericTypes": []
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__TxHashPreimage",
|
|
49
|
+
"params": [
|
|
50
|
+
{
|
|
51
|
+
"name": "version",
|
|
52
|
+
"type": "bytes"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "inputList",
|
|
56
|
+
"type": "bytes"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "outputList",
|
|
60
|
+
"type": "bytes"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "nLockTime",
|
|
64
|
+
"type": "bytes"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"genericTypes": []
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__BacktraceInfo",
|
|
71
|
+
"params": [
|
|
72
|
+
{
|
|
73
|
+
"name": "prevTxInput",
|
|
74
|
+
"type": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__TxIn"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "prevTxInputIndex",
|
|
78
|
+
"type": "int"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "prevPrevTxPreimage",
|
|
82
|
+
"type": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__TxHashPreimage"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"genericTypes": []
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__SHPreimage",
|
|
89
|
+
"params": [
|
|
90
|
+
{
|
|
91
|
+
"name": "nVersion",
|
|
92
|
+
"type": "bytes"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "hashPrevouts",
|
|
96
|
+
"type": "bytes"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "spentScriptHash",
|
|
100
|
+
"type": "bytes"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "spentDataHash",
|
|
104
|
+
"type": "bytes"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "value",
|
|
108
|
+
"type": "int"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "nSequence",
|
|
112
|
+
"type": "bytes"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "hashSpentAmounts",
|
|
116
|
+
"type": "bytes"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "hashSpentScriptHashes",
|
|
120
|
+
"type": "bytes"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "hashSpentDataHashes",
|
|
124
|
+
"type": "bytes"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "hashSequences",
|
|
128
|
+
"type": "bytes"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "hashOutputs",
|
|
132
|
+
"type": "bytes"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "inputIndex",
|
|
136
|
+
"type": "int"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "nLockTime",
|
|
140
|
+
"type": "int"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "sigHashType",
|
|
144
|
+
"type": "int"
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"genericTypes": []
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__Outpoint",
|
|
151
|
+
"params": [
|
|
152
|
+
{
|
|
153
|
+
"name": "txHash",
|
|
154
|
+
"type": "bytes"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "outputIndex",
|
|
158
|
+
"type": "int"
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"genericTypes": []
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__ReadVarintResult",
|
|
165
|
+
"params": [
|
|
166
|
+
{
|
|
167
|
+
"name": "data",
|
|
168
|
+
"type": "bytes"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "nextPos",
|
|
172
|
+
"type": "int"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"genericTypes": []
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"library": [
|
|
179
|
+
{
|
|
180
|
+
"name": "_opcat_labs_cat_sdk_1_0_1__rs__SafeMath",
|
|
181
|
+
"params": [],
|
|
182
|
+
"properties": [],
|
|
183
|
+
"genericTypes": []
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__TxUtils",
|
|
187
|
+
"params": [],
|
|
188
|
+
"properties": [],
|
|
189
|
+
"genericTypes": []
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__ContextUtils",
|
|
193
|
+
"params": [],
|
|
194
|
+
"properties": [],
|
|
195
|
+
"genericTypes": []
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"name": "_opcat_labs_scrypt_ts_opcat_1_0_3__rs__StdUtils",
|
|
199
|
+
"params": [],
|
|
200
|
+
"properties": [],
|
|
201
|
+
"genericTypes": []
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
"alias": [],
|
|
205
|
+
"abi": [
|
|
206
|
+
{
|
|
207
|
+
"type": "constructor",
|
|
208
|
+
"params": []
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
"stateProps": [],
|
|
212
|
+
"buildType": "release",
|
|
213
|
+
"file": "..\\safeMath.scrypt",
|
|
214
|
+
"hex": ""
|
|
215
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "../scrypt-ts-opcat/assets/smart-contract/builtin-libs/txUtils.scrypt";
|
|
2
|
+
import "../scrypt-ts-opcat/assets/smart-contract/builtin-libs/contextUtils.scrypt";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
library _opcat_labs_cat_sdk_1_0_1__rs__SafeMath {
|
|
8
|
+
static function add(int a, int b) : int {
|
|
9
|
+
int c = a + b;
|
|
10
|
+
require(c >= a && c >= b);
|
|
11
|
+
return c;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[[],[],[],[],[],[],[],[],[],[],[],[],[[9,0,22,13]],[[2,0,24,20],[8,0,24,2]],[[2,0,27,19],[8,0,27,2]],[[2,0,29,2],[14,0,29,32],[20,0,29,14],[38,0,29,61],[44,0,29,44]],[[4,0,31,4],[8,0,31,9],[26,0,31,4],[28,0,31,28]],[[4,0,32,4],[8,0,32,9],[25,0,32,4],[27,0,32,27]],[],[[2,0,36,2],[18,0,36,9],[25,0,37,16],[44,0,37,4],[56,0,39,16],[77,0,39,4],[89,0,40,21],[93,0,40,4],[110,0,42,19],[124,0,42,4]],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[[31,0,44,27],[46,0,44,42],[50,0,44,47]],[[4,0,47,4],[8,0,47,9],[20,0,48,6],[107,0,51,6]],[[4,0,56,4],[7,0,56,8],[32,0,56,23],[44,0,56,8],[47,0,56,37]],[[8,0,58,6],[37,0,59,19],[48,0,59,8],[81,0,60,42],[91,0,60,53],[111,0,60,42],[113,0,60,74],[119,0,60,102],[129,0,60,113],[149,0,60,102],[151,0,60,134],[154,0,60,101],[156,0,60,140]],[],[[8,0,64,6],[18,0,64,17],[34,0,64,32],[44,0,64,43],[78,0,64,66]],[[8,0,65,6],[16,0,65,18],[24,0,65,13],[25,0,65,27],[35,0,65,38],[45,0,65,47],[55,0,65,58],[66,0,65,13]],[],[],[],[[11,0,70,2],[22,0,71,16],[43,0,71,4],[55,0,72,23],[61,0,72,4],[80,0,73,26],[84,0,73,4],[106,0,74,24],[110,0,74,4],[130,0,75,23],[136,0,75,4],[155,0,76,26],[161,0,76,4]],[[4,0,80,4],[12,0,80,11],[24,0,80,24],[44,0,80,43],[63,0,80,62],[83,0,80,11],[86,0,80,85],[90,0,80,90]],[[4,0,81,4],[12,0,81,11],[24,0,81,24],[42,0,81,41],[64,0,81,63],[84,0,81,11],[87,0,81,86],[105,0,81,105],[116,0,81,115]],[[4,0,87,6],[8,0,86,10],[27,0,87,6],[37,0,87,17],[57,0,87,36],[58,0,87,43]],[[4,0,88,4],[12,0,89,6],[22,0,89,17],[41,0,89,35],[42,0,89,42],[61,0,89,6],[64,0,90,6]],[],[],[],[],[],[],[],[],[]]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import "./types.scrypt.tpl";
|
|
2
|
+
import "../types.scrypt.tpl";
|
|
3
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/types/structs.scrypt.tpl";
|
|
4
|
+
import "../utils/ownerUtils.scrypt.tpl";
|
|
5
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl";
|
|
6
|
+
import "./cat20GuardStateLib.scrypt.tpl";
|
|
7
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.tpl";
|
|
8
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl";
|
|
9
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/backtrace.scrypt.tpl";
|
|
10
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.tpl";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
contract CAT20 {
|
|
14
|
+
bytes minterScriptHash;
|
|
15
|
+
bytes guardScriptHash;
|
|
16
|
+
constructor(bytes minterScriptHash, bytes guardScriptHash) {
|
|
17
|
+
this.minterScriptHash = minterScriptHash;
|
|
18
|
+
this.guardScriptHash = guardScriptHash;
|
|
19
|
+
}
|
|
20
|
+
public function unlock(ContractUnlockArgs unlockArgs, CAT20GuardConstState guardState, int guardInputIndex, BacktraceInfo backtraceInfo, SHPreimage __scrypt_ts_shPreimage, CAT20State __scrypt_ts_curState, bytes __scrypt_ts_prevouts, bytes __scrypt_ts_spentAmounts, bytes __scrypt_ts_spentDataHashes, bytes __scrypt_ts_spentScriptHashes, TxHashPreimage __scrypt_ts_prevTxHashPreimage) {
|
|
21
|
+
require(Tx.checkPreimageSigHashType(ContextUtils.serializeSHPreimage(__scrypt_ts_shPreimage), SigHash.ALL));
|
|
22
|
+
|
|
23
|
+
int __scrypt_ts_inputCount = ContextUtils.checkSpentAmounts(__scrypt_ts_spentAmounts, __scrypt_ts_shPreimage.hashSpentAmounts);
|
|
24
|
+
|
|
25
|
+
Outpoint __scrypt_ts_prevout = ContextUtils.checkPrevouts(__scrypt_ts_prevouts, __scrypt_ts_shPreimage.hashPrevouts, __scrypt_ts_shPreimage.inputIndex, __scrypt_ts_inputCount);
|
|
26
|
+
|
|
27
|
+
ContextUtils.checkSpentScripts(__scrypt_ts_spentScriptHashes, __scrypt_ts_shPreimage.hashSpentScriptHashes, __scrypt_ts_inputCount);
|
|
28
|
+
|
|
29
|
+
ContextUtils.checkSpentDataHashes(__scrypt_ts_spentDataHashes, __scrypt_ts_shPreimage.hashSpentDataHashes, __scrypt_ts_inputCount);
|
|
30
|
+
|
|
31
|
+
CAT20State __scrypt_ts_nextState = __scrypt_ts_curState;
|
|
32
|
+
|
|
33
|
+
StateUtils.checkInputState(__scrypt_ts_shPreimage.inputIndex, CAT20.stateHash(__scrypt_ts_curState), __scrypt_ts_spentDataHashes);
|
|
34
|
+
|
|
35
|
+
Backtrace.checkPrevTxHashPreimage(__scrypt_ts_prevTxHashPreimage, __scrypt_ts_prevouts, __scrypt_ts_shPreimage.inputIndex);
|
|
36
|
+
|
|
37
|
+
Backtrace.verifyFromScript(backtraceInfo, this.minterScriptHash, __scrypt_ts_spentScriptHashes[__scrypt_ts_shPreimage.inputIndex * 32 : (__scrypt_ts_shPreimage.inputIndex + 1) * 32], __scrypt_ts_prevTxHashPreimage.inputList);
|
|
38
|
+
this.checkGuard(guardState, __scrypt_ts_shPreimage.spentScriptHash, __scrypt_ts_shPreimage.inputIndex, guardInputIndex, __scrypt_ts_spentScriptHashes, __scrypt_ts_spentDataHashes);
|
|
39
|
+
if(len(__scrypt_ts_nextState.ownerAddr) == 32) {
|
|
40
|
+
require(__scrypt_ts_nextState.ownerAddr == __scrypt_ts_spentScriptHashes[unlockArgs.contractInputIndex * 32 : (unlockArgs.contractInputIndex + 1) * 32]);
|
|
41
|
+
} else {
|
|
42
|
+
OwnerUtils.checkUserOwner(unlockArgs.userPubKey, __scrypt_ts_nextState.ownerAddr);
|
|
43
|
+
require(checkSig(unlockArgs.userSig, unlockArgs.userPubKey));
|
|
44
|
+
}
|
|
45
|
+
require(true);
|
|
46
|
+
}
|
|
47
|
+
function checkGuard(CAT20GuardConstState guardState, bytes t_cat20ScriptHash, int t_cat20InputIndexVal, int guardInputIndexVal, bytes t_spentScriptsCtx, bytes t_spentDataHashesCtx) : bool {
|
|
48
|
+
require(ContextUtils.getSpentScriptHash(t_spentScriptsCtx, guardInputIndexVal) == this.guardScriptHash);
|
|
49
|
+
require(ContextUtils.getSpentDataHash(t_spentDataHashesCtx, guardInputIndexVal) == CAT20GuardStateLib.stateHash(guardState));
|
|
50
|
+
int tokenScriptIndex = guardState.tokenScriptIndexes[(t_cat20InputIndexVal)];
|
|
51
|
+
require(guardState.tokenScriptHashes[(tokenScriptIndex)] == t_cat20ScriptHash);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
static function serializeState(CAT20State __scrypt_ts_curState): bytes {
|
|
55
|
+
return num2bin(len(__scrypt_ts_curState.tag), 2) + __scrypt_ts_curState.tag + num2bin(len(__scrypt_ts_curState.ownerAddr), 2) + __scrypt_ts_curState.ownerAddr + num2bin(len(pack(__scrypt_ts_curState.amount)), 2) + pack(__scrypt_ts_curState.amount) + hash160(hash160(__scrypt_ts_curState.tag) + hash160(__scrypt_ts_curState.ownerAddr) + hash160(pack(__scrypt_ts_curState.amount)));
|
|
56
|
+
}
|
|
57
|
+
static function stateHash(CAT20State __scrypt_ts_curState): bytes {
|
|
58
|
+
return sha256(num2bin(len(__scrypt_ts_curState.tag), 2) + __scrypt_ts_curState.tag + num2bin(len(__scrypt_ts_curState.ownerAddr), 2) + __scrypt_ts_curState.ownerAddr + num2bin(len(pack(__scrypt_ts_curState.amount)), 2) + pack(__scrypt_ts_curState.amount) + hash160(hash160(__scrypt_ts_curState.tag) + hash160(__scrypt_ts_curState.ownerAddr) + hash160(pack(__scrypt_ts_curState.amount))));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[[],[],[],[],[],[],[],[],[],[],[],[],[[9,0,27,13]],[],[[2,0,29,4],[18,0,29,11],[25,0,30,25],[30,0,30,25],[34,0,30,8],[51,0,34,33],[56,0,34,33],[60,0,34,8],[85,0,38,22],[88,0,38,22],[92,0,38,8],[106,0,44,32],[109,0,44,32],[113,0,44,8],[137,0,49,24],[140,0,49,24],[144,0,49,8],[160,0,53,21],[170,0,53,21],[174,0,53,8],[187,0,55,21],[191,0,55,8]],[],[],[],[],[],[],[],[],[],[],[],[],[[4,0,59,8],[22,0,59,27]],[[4,0,62,30],[8,0,62,12],[26,0,62,30]],[[4,0,63,39],[9,0,63,39],[13,0,63,14],[40,0,67,16],[52,0,67,29],[87,0,68,16],[99,0,68,29],[134,0,69,16],[146,0,69,29],[181,0,70,16],[193,0,70,29]],[[15,0,72,17]],[[8,0,73,12],[32,0,73,27],[51,0,73,45],[54,0,73,16],[57,0,73,51],[81,0,73,75]],[[10,0,74,16],[25,0,74,16]],[],[],[[15,0,78,17]],[[8,0,79,12],[11,0,79,16],[13,0,79,16],[15,0,79,20],[16,0,79,27]],[[10,0,80,16],[39,0,80,34],[58,0,80,52],[61,0,80,23],[64,0,80,58],[88,0,80,82]],[[10,0,81,16],[18,0,82,20],[43,0,82,35],[62,0,82,53],[66,0,82,20],[69,0,82,60]],[],[[10,0,85,16],[39,0,85,34],[58,0,85,52],[61,0,85,23],[64,0,85,58],[88,0,85,82]],[],[],[[4,0,88,8],[12,0,88,15],[28,0,88,15],[30,0,88,33]],[[4,0,94,31],[7,0,94,31],[11,0,94,14],[28,0,94,31],[35,0,94,36],[38,0,94,40]],[[4,0,95,34],[8,0,95,12],[30,0,95,34],[31,0,95,35]],[[4,0,96,27],[8,0,96,14]],[[15,0,97,17]],[[8,0,98,37],[12,0,98,18],[52,0,98,48],[72,0,98,67],[73,0,98,74]],[[8,0,99,12],[11,0,99,16],[13,0,99,16],[15,0,99,20]],[[10,0,100,16],[18,0,100,23],[35,0,100,23],[37,0,100,42]],[[10,0,101,16],[13,0,101,20],[30,0,101,20],[33,0,101,40],[34,0,101,41]],[[12,0,104,24],[18,0,103,26],[57,0,104,35],[76,0,104,53],[77,0,104,60]],[[12,0,105,20],[20,0,105,27],[36,0,105,27],[39,0,105,46],[51,0,105,59],[102,0,105,106],[103,0,105,113]],[[12,0,106,20],[25,0,106,34],[37,0,106,45],[49,0,106,57]],[[12,0,107,20],[20,0,107,27],[32,0,107,40],[79,0,107,83],[80,0,107,90],[84,0,107,27],[87,0,107,97],[100,0,107,111],[111,0,107,121],[123,0,107,133]],[[12,0,108,20],[27,0,108,35],[28,0,108,42],[47,0,108,20],[49,0,108,63],[57,0,108,72],[62,0,109,24],[77,0,109,39],[78,0,109,46],[98,0,110,24],[110,0,110,36],[112,0,110,39]],[[12,0,112,20],[32,0,112,20],[34,0,113,24],[51,0,113,24],[53,0,113,43],[75,0,114,30],[94,0,115,30]],[],[],[[10,0,118,16],[39,0,118,34],[59,0,118,53],[62,0,118,23],[65,0,118,59],[66,0,118,60]],[],[],[[4,0,124,8],[12,0,125,12],[32,0,125,12],[35,0,125,35],[37,0,125,12],[40,0,125,41],[60,0,125,41],[63,0,125,64],[79,0,125,64],[81,0,125,82]],[[4,0,130,8],[12,0,130,15],[24,0,130,15],[27,0,130,30],[29,0,130,15],[32,0,130,36],[44,0,130,36],[47,0,130,51]],[[4,0,131,32],[7,0,131,32],[11,0,131,14],[29,0,131,32],[36,0,131,37],[39,0,131,41]],[[4,0,132,22],[10,0,132,12],[20,0,132,35]],[[15,0,133,17]],[[8,0,134,12],[11,0,134,16],[13,0,134,16],[15,0,134,20]],[[10,0,135,46],[16,0,135,22],[40,0,135,46],[64,0,135,70]],[[10,0,136,16],[18,0,136,23],[22,0,136,27],[45,0,136,23],[47,0,136,52]],[[10,0,137,45],[14,0,137,22],[37,0,137,45],[60,0,137,68]],[[10,0,138,16],[18,0,138,23],[39,0,138,23],[41,0,138,46]],[[10,0,139,16],[13,0,139,20],[34,0,139,20],[37,0,139,44],[38,0,139,45]],[[12,0,141,40],[16,0,141,26],[30,0,141,40],[43,0,141,53]],[[12,0,142,20],[20,0,142,27],[32,0,142,27],[34,0,142,41]],[[12,0,143,20],[28,0,143,36],[29,0,143,43],[52,0,143,20],[54,0,143,68],[62,0,143,77],[67,0,144,24],[83,0,144,40],[84,0,144,47],[108,0,145,24]],[[12,0,147,43],[18,0,147,26],[35,0,147,43],[48,0,147,57],[59,0,147,67],[60,0,148,29],[72,0,148,42],[90,0,149,35],[113,0,150,32]],[[12,0,152,20],[20,0,152,27],[36,0,152,43],[39,0,152,27],[42,0,152,49]],[[12,0,154,24],[18,0,153,26],[57,0,154,35],[76,0,154,53],[77,0,154,60]],[[12,0,155,20],[20,0,155,20],[23,0,155,31],[30,0,155,39],[47,0,156,24],[64,0,157,24],[79,0,157,39],[83,0,158,24]],[],[[12,0,162,20],[20,0,162,27],[33,0,162,40],[36,0,162,27],[39,0,162,46]],[[23,0,164,29]],[[14,0,165,24],[22,0,165,31],[44,0,165,31],[68,0,165,67],[87,0,165,85]],[],[[12,0,167,20],[20,0,167,20],[23,0,167,31],[30,0,167,39],[47,0,168,24],[70,0,169,24],[85,0,169,39],[89,0,170,24],[105,0,170,40]],[],[],[[10,0,174,16],[18,0,174,23],[22,0,174,27],[46,0,174,51],[50,0,174,23],[53,0,174,58]],[[10,0,175,16],[18,0,175,23],[41,0,175,46],[44,0,175,23],[47,0,175,52],[48,0,175,53]],[[10,0,176,16],[18,0,176,23],[31,0,176,36],[34,0,176,23],[37,0,176,42]],[[10,0,177,16],[18,0,177,23],[34,0,177,39],[37,0,177,23],[40,0,177,58]],[[10,0,178,16],[18,0,178,23],[33,0,178,38],[36,0,178,23],[39,0,178,44]],[],[],[[15,0,183,17]],[[8,0,184,12],[16,0,184,19],[31,0,184,34],[34,0,184,19],[58,0,184,51],[72,0,184,64]],[[8,0,185,12],[16,0,186,16],[31,0,186,31],[34,0,186,16],[37,0,187,16],[45,0,187,25],[50,0,187,29],[66,0,187,45],[91,0,187,60],[109,0,187,77]],[[8,0,189,12],[11,0,189,16],[13,0,189,16],[15,0,189,20],[16,0,189,27]],[[10,0,190,16],[18,0,190,23],[33,0,190,38],[36,0,190,23],[38,0,190,43]],[],[[10,0,192,16],[18,0,192,23],[33,0,192,38],[36,0,192,23],[39,0,192,44]],[[10,0,193,16],[18,0,193,23],[34,0,193,39],[37,0,193,23],[40,0,193,45]],[[10,0,195,16],[39,0,195,34],[53,0,195,47],[56,0,195,23],[59,0,195,53]],[[10,0,196,16],[39,0,196,34],[57,0,196,51],[60,0,196,23],[63,0,196,57]],[],[],[[4,0,201,8],[20,0,201,33]],[],[],[],[],[],[],[],[]]
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import "./types.scrypt.tpl";
|
|
2
|
+
import "./cat20GuardStateLib.scrypt.tpl";
|
|
3
|
+
import "../constants.scrypt.tpl";
|
|
4
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl";
|
|
5
|
+
import "./cat20StateLib.scrypt.tpl";
|
|
6
|
+
import "../utils/safeMath.scrypt.tpl";
|
|
7
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl";
|
|
8
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.tpl";
|
|
9
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/types/structs.scrypt.tpl";
|
|
10
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.tpl";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
contract CAT20Guard {
|
|
14
|
+
constructor(){}
|
|
15
|
+
public function unlock(bytes[6] nextStateHashes, bytes[6] ownerAddrOrScriptHashes, int[6] outputTokens, int[6] tokenScriptHashIndexes, int[6] outputSatoshis, CAT20State[6] cat20States, int outputCount, SHPreimage __scrypt_ts_shPreimage, CAT20GuardConstState __scrypt_ts_curState, bytes __scrypt_ts_spentAmounts, bytes __scrypt_ts_spentDataHashes, bytes __scrypt_ts_spentScriptHashes) {
|
|
16
|
+
require(Tx.checkPreimageSigHashType(ContextUtils.serializeSHPreimage(__scrypt_ts_shPreimage), SigHash.ALL));
|
|
17
|
+
|
|
18
|
+
int __scrypt_ts_inputCount = ContextUtils.checkSpentAmounts(__scrypt_ts_spentAmounts, __scrypt_ts_shPreimage.hashSpentAmounts);
|
|
19
|
+
|
|
20
|
+
ContextUtils.checkSpentScripts(__scrypt_ts_spentScriptHashes, __scrypt_ts_shPreimage.hashSpentScriptHashes, __scrypt_ts_inputCount);
|
|
21
|
+
|
|
22
|
+
ContextUtils.checkSpentDataHashes(__scrypt_ts_spentDataHashes, __scrypt_ts_shPreimage.hashSpentDataHashes, __scrypt_ts_inputCount);
|
|
23
|
+
|
|
24
|
+
CAT20GuardConstState __scrypt_ts_nextState = __scrypt_ts_curState;
|
|
25
|
+
|
|
26
|
+
StateUtils.checkInputState(__scrypt_ts_shPreimage.inputIndex, CAT20Guard.stateHash(__scrypt_ts_curState), __scrypt_ts_spentDataHashes);
|
|
27
|
+
|
|
28
|
+
CAT20GuardStateLib.formalCheckState(__scrypt_ts_nextState);
|
|
29
|
+
int inputTokenTypes = 0;
|
|
30
|
+
bytes[4] tokenScriptPlaceholders = [ConstantsLib.TOKEN_SCRIPT_HASH_PLACEHOLDER_FF, ConstantsLib.TOKEN_SCRIPT_HASH_PLACEHOLDER_FE, ConstantsLib.TOKEN_SCRIPT_HASH_PLACEHOLDER_FD, ConstantsLib.TOKEN_SCRIPT_HASH_PLACEHOLDER_FC];
|
|
31
|
+
loop (4) : i {
|
|
32
|
+
if(__scrypt_ts_nextState.tokenScriptHashes[i] != tokenScriptPlaceholders[i]) {
|
|
33
|
+
inputTokenTypes++;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
loop (4) : i {
|
|
37
|
+
if(i < (inputTokenTypes)) {
|
|
38
|
+
require(__scrypt_ts_nextState.tokenScriptHashes[i] != tokenScriptPlaceholders[i]);
|
|
39
|
+
require(len(__scrypt_ts_nextState.tokenScriptHashes[i]) == 32);
|
|
40
|
+
} else {
|
|
41
|
+
require(__scrypt_ts_nextState.tokenScriptHashes[i] == tokenScriptPlaceholders[i]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
require(inputTokenTypes > 0);
|
|
45
|
+
int[4] sumInputTokens = repeat(0, 4);
|
|
46
|
+
int tokenScriptIndexMax = -1;
|
|
47
|
+
int inputCount = __scrypt_ts_inputCount;
|
|
48
|
+
loop (6) : i {
|
|
49
|
+
int tokenScriptIndex = __scrypt_ts_nextState.tokenScriptIndexes[(i)];
|
|
50
|
+
if(i < inputCount) {
|
|
51
|
+
require(tokenScriptIndex < inputTokenTypes);
|
|
52
|
+
if(tokenScriptIndex != -1) {
|
|
53
|
+
bytes tokenScriptHash = __scrypt_ts_nextState.tokenScriptHashes[(tokenScriptIndex)];
|
|
54
|
+
require(tokenScriptHash == ContextUtils.getSpentScriptHash(__scrypt_ts_spentScriptHashes, (i)));
|
|
55
|
+
CAT20StateLib.checkState(cat20States[i]);
|
|
56
|
+
require(ContextUtils.getSpentDataHash(__scrypt_ts_spentDataHashes, (i)) == CAT20StateLib.stateHash(cat20States[i]));
|
|
57
|
+
sumInputTokens[(tokenScriptIndex)] = SafeMath.add(sumInputTokens[(tokenScriptIndex)], cat20States[i].amount);
|
|
58
|
+
tokenScriptIndexMax = tokenScriptIndex > tokenScriptIndexMax ? tokenScriptIndex : tokenScriptIndexMax;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
require(__scrypt_ts_nextState.tokenScriptIndexes[i] == -1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
require(tokenScriptIndexMax >= 0 && tokenScriptIndexMax == inputTokenTypes - 1);
|
|
65
|
+
require(outputCount >= 0 && outputCount <= 6);
|
|
66
|
+
int[4] sumOutputTokens = repeat(0, 4);
|
|
67
|
+
bytes outputs = b'';
|
|
68
|
+
loop (6) : i {
|
|
69
|
+
if(i < outputCount) {
|
|
70
|
+
bytes ownerAddrOrScriptHash = ownerAddrOrScriptHashes[i];
|
|
71
|
+
require(len(ownerAddrOrScriptHash) > 0);
|
|
72
|
+
int tokenScriptHashIndex = tokenScriptHashIndexes[i];
|
|
73
|
+
require(tokenScriptHashIndex < inputTokenTypes);
|
|
74
|
+
if(tokenScriptHashIndex != -1) {
|
|
75
|
+
int tokenAmount = outputTokens[i];
|
|
76
|
+
require(tokenAmount > 0);
|
|
77
|
+
sumOutputTokens[(tokenScriptHashIndex)] = SafeMath.add(sumOutputTokens[(tokenScriptHashIndex)], tokenAmount);
|
|
78
|
+
bytes tokenStateHash = CAT20StateLib.stateHash({ConstantsLib.OPCAT_CAT20_TAG, ownerAddrOrScriptHash, tokenAmount});
|
|
79
|
+
require(nextStateHashes[i] == tokenStateHash);
|
|
80
|
+
bytes tokenScriptHash = __scrypt_ts_nextState.tokenScriptHashes[(tokenScriptHashIndex)];
|
|
81
|
+
outputs += TxUtils.buildDataOutput(tokenScriptHash, outputSatoshis[i], tokenStateHash);
|
|
82
|
+
} else {
|
|
83
|
+
require(outputTokens[i] == 0);
|
|
84
|
+
loop (4) : j {
|
|
85
|
+
require(ownerAddrOrScriptHash != __scrypt_ts_nextState.tokenScriptHashes[j]);
|
|
86
|
+
}
|
|
87
|
+
outputs += TxUtils.buildDataOutput(ownerAddrOrScriptHash, outputSatoshis[i], nextStateHashes[i]);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
require(len(ownerAddrOrScriptHashes[i]) == 0);
|
|
91
|
+
require(tokenScriptHashIndexes[i] == -1);
|
|
92
|
+
require(outputTokens[i] == 0);
|
|
93
|
+
require(nextStateHashes[i] == b'');
|
|
94
|
+
require(outputSatoshis[i] == 0);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
loop (4) : i {
|
|
98
|
+
require(sumInputTokens[i] == __scrypt_ts_nextState.tokenAmounts[i]);
|
|
99
|
+
require(sumInputTokens[i] == SafeMath.add(sumOutputTokens[i], __scrypt_ts_nextState.tokenBurnAmounts[i]));
|
|
100
|
+
if(i < (inputTokenTypes)) {
|
|
101
|
+
require(sumInputTokens[i] > 0);
|
|
102
|
+
} else {
|
|
103
|
+
require(sumInputTokens[i] == 0);
|
|
104
|
+
require(sumOutputTokens[i] == 0);
|
|
105
|
+
require(__scrypt_ts_nextState.tokenAmounts[i] == 0);
|
|
106
|
+
require(__scrypt_ts_nextState.tokenBurnAmounts[i] == 0);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
require(hash256(outputs) == __scrypt_ts_shPreimage.hashOutputs);
|
|
110
|
+
}
|
|
111
|
+
static function serializeState(CAT20GuardConstState __scrypt_ts_curState): bytes {
|
|
112
|
+
return num2bin(len(__scrypt_ts_curState.tokenScriptHashes[0]), 2) + __scrypt_ts_curState.tokenScriptHashes[0] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[1]), 2) + __scrypt_ts_curState.tokenScriptHashes[1] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[2]), 2) + __scrypt_ts_curState.tokenScriptHashes[2] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[3]), 2) + __scrypt_ts_curState.tokenScriptHashes[3] + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[0])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[1])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[2])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[3])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[4])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[4]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[5])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[5]) + hash160(hash160(__scrypt_ts_curState.tokenScriptHashes[0]) + hash160(__scrypt_ts_curState.tokenScriptHashes[1]) + hash160(__scrypt_ts_curState.tokenScriptHashes[2]) + hash160(__scrypt_ts_curState.tokenScriptHashes[3]) + hash160(pack(__scrypt_ts_curState.tokenAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[0])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[1])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[2])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[4])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[5])));
|
|
113
|
+
}
|
|
114
|
+
static function stateHash(CAT20GuardConstState __scrypt_ts_curState): bytes {
|
|
115
|
+
return sha256(num2bin(len(__scrypt_ts_curState.tokenScriptHashes[0]), 2) + __scrypt_ts_curState.tokenScriptHashes[0] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[1]), 2) + __scrypt_ts_curState.tokenScriptHashes[1] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[2]), 2) + __scrypt_ts_curState.tokenScriptHashes[2] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[3]), 2) + __scrypt_ts_curState.tokenScriptHashes[3] + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[0])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[1])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[2])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[3])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[4])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[4]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[5])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[5]) + hash160(hash160(__scrypt_ts_curState.tokenScriptHashes[0]) + hash160(__scrypt_ts_curState.tokenScriptHashes[1]) + hash160(__scrypt_ts_curState.tokenScriptHashes[2]) + hash160(__scrypt_ts_curState.tokenScriptHashes[3]) + hash160(pack(__scrypt_ts_curState.tokenAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[0])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[1])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[2])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[4])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[5]))));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[[],[],[],[],[],[[8,0,5,13]],[[2,0,8,2],[18,0,8,9],[35,0,8,34],[56,0,8,26],[66,0,8,57]],[[4,0,9,4],[22,0,9,23],[45,0,9,45],[51,0,9,52]],[[15,0,11,13]],[[8,0,12,24],[12,0,12,12],[24,0,12,24],[28,0,12,28],[34,0,12,35],[53,0,12,53]],[[8,0,13,6],[16,0,13,13],[26,0,13,13],[29,0,13,26]],[[8,0,15,6],[16,0,15,13],[22,0,15,20],[36,0,15,33],[39,0,15,13],[42,0,15,39]],[[8,0,16,6],[16,0,16,13],[22,0,16,20],[40,0,16,37],[43,0,16,13],[46,0,16,43]],[],[[15,0,19,13]],[[8,0,21,26],[12,0,21,12],[26,0,21,26],[32,0,21,33],[52,0,21,52]],[[8,0,22,6],[16,0,22,13],[28,0,22,13],[31,0,22,28],[32,0,22,29],[34,0,22,13],[37,0,22,34],[49,0,22,34],[51,0,22,48]],[],[[4,0,25,4],[11,0,25,24]],[],[[2,0,34,2],[18,0,34,9],[40,0,35,18],[45,0,35,18],[49,0,35,4]],[[4,0,38,4],[12,0,38,11],[25,0,38,24],[28,0,38,11],[31,0,38,30],[44,0,38,43]],[[4,0,39,4],[12,0,39,11],[25,0,39,24],[28,0,39,11],[31,0,39,30],[44,0,39,43]],[[4,0,40,4],[12,0,40,11],[25,0,40,24],[28,0,40,11],[31,0,40,30],[44,0,40,43]],[[4,0,41,4],[12,0,41,11],[25,0,41,24],[28,0,41,11],[31,0,41,30],[44,0,41,43]],[[4,0,42,4],[12,0,42,11],[25,0,42,24],[28,0,42,11],[31,0,42,30],[44,0,42,43]],[[4,0,43,4],[12,0,43,11],[25,0,43,24],[28,0,43,11],[31,0,43,30],[44,0,43,43]],[],[],[],[],[],[],[],[],[]]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "./types.scrypt.tpl";
|
|
2
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl";
|
|
3
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
library CAT20GuardStateLib {
|
|
7
|
+
static function formalCheckState(CAT20GuardConstState _state) : bytes {
|
|
8
|
+
CAT20GuardStateLib.checkTokenScriptsUniq(_state.tokenScriptHashes);
|
|
9
|
+
loop (4) : i {
|
|
10
|
+
int scriptLen = len(_state.tokenScriptHashes[i]);
|
|
11
|
+
require(scriptLen == 32);
|
|
12
|
+
require(_state.tokenAmounts[i] >= 0);
|
|
13
|
+
require(_state.tokenBurnAmounts[i] >= 0);
|
|
14
|
+
}
|
|
15
|
+
loop (6) : i {
|
|
16
|
+
int scriptIndex = _state.tokenScriptIndexes[i];
|
|
17
|
+
require(scriptIndex >= -1 && scriptIndex < 4);
|
|
18
|
+
}
|
|
19
|
+
return b'';
|
|
20
|
+
}
|
|
21
|
+
static function checkTokenScriptsUniq(bytes[4] tokenScripts) : bool {
|
|
22
|
+
require(tokenScripts[0] != tokenScripts[1]);
|
|
23
|
+
require(tokenScripts[0] != tokenScripts[2]);
|
|
24
|
+
require(tokenScripts[0] != tokenScripts[3]);
|
|
25
|
+
require(tokenScripts[1] != tokenScripts[2]);
|
|
26
|
+
require(tokenScripts[1] != tokenScripts[3]);
|
|
27
|
+
require(tokenScripts[2] != tokenScripts[3]);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
static function serializeState(CAT20GuardConstState __scrypt_ts_curState): bytes {
|
|
31
|
+
return num2bin(len(__scrypt_ts_curState.tokenScriptHashes[0]), 2) + __scrypt_ts_curState.tokenScriptHashes[0] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[1]), 2) + __scrypt_ts_curState.tokenScriptHashes[1] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[2]), 2) + __scrypt_ts_curState.tokenScriptHashes[2] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[3]), 2) + __scrypt_ts_curState.tokenScriptHashes[3] + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[0])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[1])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[2])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[3])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[4])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[4]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[5])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[5]) + hash160(hash160(__scrypt_ts_curState.tokenScriptHashes[0]) + hash160(__scrypt_ts_curState.tokenScriptHashes[1]) + hash160(__scrypt_ts_curState.tokenScriptHashes[2]) + hash160(__scrypt_ts_curState.tokenScriptHashes[3]) + hash160(pack(__scrypt_ts_curState.tokenAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[0])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[1])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[2])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[4])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[5])));
|
|
32
|
+
}
|
|
33
|
+
static function stateHash(CAT20GuardConstState __scrypt_ts_curState): bytes {
|
|
34
|
+
return sha256(num2bin(len(__scrypt_ts_curState.tokenScriptHashes[0]), 2) + __scrypt_ts_curState.tokenScriptHashes[0] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[1]), 2) + __scrypt_ts_curState.tokenScriptHashes[1] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[2]), 2) + __scrypt_ts_curState.tokenScriptHashes[2] + num2bin(len(__scrypt_ts_curState.tokenScriptHashes[3]), 2) + __scrypt_ts_curState.tokenScriptHashes[3] + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[0])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[1])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[2])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenBurnAmounts[3])), 2) + pack(__scrypt_ts_curState.tokenBurnAmounts[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[0])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[0]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[1])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[1]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[2])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[2]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[3])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[3]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[4])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[4]) + num2bin(len(pack(__scrypt_ts_curState.tokenScriptIndexes[5])), 2) + pack(__scrypt_ts_curState.tokenScriptIndexes[5]) + hash160(hash160(__scrypt_ts_curState.tokenScriptHashes[0]) + hash160(__scrypt_ts_curState.tokenScriptHashes[1]) + hash160(__scrypt_ts_curState.tokenScriptHashes[2]) + hash160(__scrypt_ts_curState.tokenScriptHashes[3]) + hash160(pack(__scrypt_ts_curState.tokenAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[0])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[1])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[2])) + hash160(pack(__scrypt_ts_curState.tokenBurnAmounts[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[0])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[1])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[2])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[3])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[4])) + hash160(pack(__scrypt_ts_curState.tokenScriptIndexes[5]))));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[[],[],[],[],[],[],[],[[8,0,5,13]],[[2,0,7,4],[18,0,7,11],[29,0,7,30],[40,0,7,22]],[[4,0,8,8],[14,0,8,19],[30,0,8,34],[36,0,8,41]],[[4,0,9,8],[12,0,9,15],[18,0,9,22],[26,0,9,15],[28,0,9,31]],[[4,0,10,8],[12,0,10,15],[18,0,10,22],[23,0,10,15],[26,0,10,29],[38,0,10,42]],[],[],[],[],[],[],[],[],[]]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./types.scrypt.tpl";
|
|
2
|
+
import "../utils/ownerUtils.scrypt.tpl";
|
|
3
|
+
import "../constants.scrypt.tpl";
|
|
4
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl";
|
|
5
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
library CAT20StateLib {
|
|
9
|
+
static function checkState(CAT20State _state) : bool {
|
|
10
|
+
OwnerUtils.checkOwnerAddr(_state.ownerAddr);
|
|
11
|
+
require(_state.amount > 0);
|
|
12
|
+
require(_state.tag == ConstantsLib.OPCAT_CAT20_TAG);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
static function serializeState(CAT20State __scrypt_ts_curState): bytes {
|
|
16
|
+
return num2bin(len(__scrypt_ts_curState.tag), 2) + __scrypt_ts_curState.tag + num2bin(len(__scrypt_ts_curState.ownerAddr), 2) + __scrypt_ts_curState.ownerAddr + num2bin(len(pack(__scrypt_ts_curState.amount)), 2) + pack(__scrypt_ts_curState.amount) + hash160(hash160(__scrypt_ts_curState.tag) + hash160(__scrypt_ts_curState.ownerAddr) + hash160(pack(__scrypt_ts_curState.amount)));
|
|
17
|
+
}
|
|
18
|
+
static function stateHash(CAT20State __scrypt_ts_curState): bytes {
|
|
19
|
+
return sha256(num2bin(len(__scrypt_ts_curState.tag), 2) + __scrypt_ts_curState.tag + num2bin(len(__scrypt_ts_curState.ownerAddr), 2) + __scrypt_ts_curState.ownerAddr + num2bin(len(pack(__scrypt_ts_curState.amount)), 2) + pack(__scrypt_ts_curState.amount) + hash160(hash160(__scrypt_ts_curState.tag) + hash160(__scrypt_ts_curState.ownerAddr) + hash160(pack(__scrypt_ts_curState.amount))));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[[],[],[],[],[],[],[],[],[],[],[],[[9,0,6,13]],[[2,0,8,17],[8,0,8,2]],[[2,0,11,19],[8,0,11,2]],[[2,0,13,2],[14,0,13,28],[20,0,13,14],[34,0,13,57],[40,0,13,40]],[[4,0,15,4],[8,0,15,9],[23,0,15,4],[25,0,15,25]],[[4,0,16,4],[8,0,16,9],[25,0,16,4],[27,0,16,27]],[],[[2,0,20,2],[18,0,20,9],[23,0,22,15],[34,0,22,4],[45,0,23,18],[52,0,23,4],[66,0,24,15],[70,0,24,4],[81,0,27,20],[85,0,27,4],[101,0,29,19],[105,0,29,4],[120,0,31,19],[134,0,31,4]],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[[4,0,35,25],[10,0,35,10]],[[33,0,37,6],[48,0,38,6],[52,0,38,11]],[[4,0,42,4],[14,0,42,15],[30,0,42,30],[44,0,42,44],[48,0,42,49]],[[4,0,43,4],[12,0,43,16],[20,0,43,11],[21,0,43,25],[32,0,43,36],[44,0,43,11]],[[4,0,45,4],[21,0,45,22]],[[4,0,49,23],[10,0,49,8],[25,0,49,36]],[[4,0,50,4],[7,0,50,8],[22,0,50,8],[24,0,50,25],[31,0,50,33]],[[8,0,51,6],[21,0,51,6],[23,0,51,21],[30,0,51,29],[47,0,52,8],[61,0,53,8]],[],[[4,0,58,4],[17,0,58,18],[29,0,58,29]],[[4,0,59,27],[10,0,59,10],[27,0,59,27],[40,0,59,41],[51,0,59,51]],[[4,0,60,24],[10,0,60,10],[24,0,60,24],[31,0,60,32],[69,0,61,17],[87,0,62,6],[102,0,63,6]],[[4,0,67,4],[20,0,67,29],[33,0,67,29],[35,0,67,44],[47,0,67,29]],[],[],[[2,0,72,2],[18,0,72,9],[29,0,72,28],[52,0,72,20]],[[4,0,73,4],[12,0,73,11],[16,0,73,15],[22,0,73,22],[40,0,73,11],[43,0,73,42]],[],[],[],[],[],[],[],[],[]]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import "../types.scrypt.tpl";
|
|
2
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/types/structs.scrypt.tpl";
|
|
3
|
+
import "../../utils/ownerUtils.scrypt.tpl";
|
|
4
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/txUtils.scrypt.tpl";
|
|
5
|
+
import "../cat20StateLib.scrypt.tpl";
|
|
6
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/stdUtils.scrypt.tpl";
|
|
7
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/backtrace.scrypt.tpl";
|
|
8
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/contextUtils.scrypt.tpl";
|
|
9
|
+
import "@opcat-labs/scrypt-ts-opcat/assets/.templates/smart-contract/builtin-libs/stateUtils.scrypt.tpl";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
contract CAT20ClosedMinter {
|
|
13
|
+
bytes issuerAddress;
|
|
14
|
+
bytes genesisOutpoint;
|
|
15
|
+
constructor(bytes ownerAddress, bytes genesisOutpoint) {
|
|
16
|
+
this.issuerAddress = ownerAddress;
|
|
17
|
+
this.genesisOutpoint = genesisOutpoint;
|
|
18
|
+
}
|
|
19
|
+
public function mint(CAT20State tokenMint, PubKey issuerPubKey, Sig issuerSig, int minterSatoshis, int tokenSatoshis, BacktraceInfo backtraceInfo, SHPreimage __scrypt_ts_shPreimage, TxOut __scrypt_ts_changeInfo, CAT20ClosedMinterState __scrypt_ts_curState, bytes __scrypt_ts_prevouts, bytes __scrypt_ts_spentAmounts, bytes __scrypt_ts_spentDataHashes, bytes __scrypt_ts_spentScriptHashes, TxHashPreimage __scrypt_ts_prevTxHashPreimage) {
|
|
20
|
+
require(Tx.checkPreimageSigHashType(ContextUtils.serializeSHPreimage(__scrypt_ts_shPreimage), SigHash.ALL));
|
|
21
|
+
|
|
22
|
+
int __scrypt_ts_inputCount = ContextUtils.checkSpentAmounts(__scrypt_ts_spentAmounts, __scrypt_ts_shPreimage.hashSpentAmounts);
|
|
23
|
+
|
|
24
|
+
Outpoint __scrypt_ts_prevout = ContextUtils.checkPrevouts(__scrypt_ts_prevouts, __scrypt_ts_shPreimage.hashPrevouts, __scrypt_ts_shPreimage.inputIndex, __scrypt_ts_inputCount);
|
|
25
|
+
|
|
26
|
+
ContextUtils.checkSpentScripts(__scrypt_ts_spentScriptHashes, __scrypt_ts_shPreimage.hashSpentScriptHashes, __scrypt_ts_inputCount);
|
|
27
|
+
|
|
28
|
+
ContextUtils.checkSpentDataHashes(__scrypt_ts_spentDataHashes, __scrypt_ts_shPreimage.hashSpentDataHashes, __scrypt_ts_inputCount);
|
|
29
|
+
|
|
30
|
+
CAT20ClosedMinterState __scrypt_ts_nextState = __scrypt_ts_curState;
|
|
31
|
+
|
|
32
|
+
StateUtils.checkInputState(__scrypt_ts_shPreimage.inputIndex, CAT20ClosedMinter.stateHash(__scrypt_ts_curState), __scrypt_ts_spentDataHashes);
|
|
33
|
+
|
|
34
|
+
Backtrace.checkPrevTxHashPreimage(__scrypt_ts_prevTxHashPreimage, __scrypt_ts_prevouts, __scrypt_ts_shPreimage.inputIndex);
|
|
35
|
+
|
|
36
|
+
bytes minterScript = __scrypt_ts_shPreimage.spentScriptHash;
|
|
37
|
+
Backtrace.verifyFromOutpoint(backtraceInfo, this.genesisOutpoint, __scrypt_ts_spentScriptHashes[__scrypt_ts_shPreimage.inputIndex * 32 : (__scrypt_ts_shPreimage.inputIndex + 1) * 32], __scrypt_ts_prevTxHashPreimage.inputList);
|
|
38
|
+
OwnerUtils.checkUserOwner(issuerPubKey, this.issuerAddress);
|
|
39
|
+
require(checkSig(issuerSig, issuerPubKey));
|
|
40
|
+
CAT20ClosedMinter.checkState(__scrypt_ts_nextState);
|
|
41
|
+
bytes minterOutput = b'';
|
|
42
|
+
if(minterSatoshis > TxUtils.ZERO_SATS) {
|
|
43
|
+
minterOutput = TxUtils.buildDataOutput(minterScript, minterSatoshis, __scrypt_ts_shPreimage.spentDataHash);
|
|
44
|
+
}
|
|
45
|
+
CAT20StateLib.checkState(tokenMint);
|
|
46
|
+
bytes tokenStateHash = CAT20StateLib.stateHash(tokenMint);
|
|
47
|
+
bytes tokenOutput = TxUtils.buildDataOutput(__scrypt_ts_nextState.tokenScriptHash, tokenSatoshis, tokenStateHash);
|
|
48
|
+
require(hash256(minterOutput + tokenOutput +
|
|
49
|
+
(__scrypt_ts_changeInfo.satoshis > 0 ? TxUtils.buildOutput(__scrypt_ts_changeInfo.scriptHash, __scrypt_ts_changeInfo.satoshis) : b'')) == __scrypt_ts_shPreimage.hashOutputs);
|
|
50
|
+
}
|
|
51
|
+
static function checkState(CAT20ClosedMinterState _state) : bool {
|
|
52
|
+
require(len(_state.tokenScriptHash) == 32);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
static function serializeState(CAT20ClosedMinterState __scrypt_ts_curState): bytes {
|
|
56
|
+
return num2bin(len(__scrypt_ts_curState.tag), 2) + __scrypt_ts_curState.tag + num2bin(len(__scrypt_ts_curState.tokenScriptHash), 2) + __scrypt_ts_curState.tokenScriptHash + hash160(hash160(__scrypt_ts_curState.tag) + hash160(__scrypt_ts_curState.tokenScriptHash));
|
|
57
|
+
}
|
|
58
|
+
static function stateHash(CAT20ClosedMinterState __scrypt_ts_curState): bytes {
|
|
59
|
+
return sha256(num2bin(len(__scrypt_ts_curState.tag), 2) + __scrypt_ts_curState.tag + num2bin(len(__scrypt_ts_curState.tokenScriptHash), 2) + __scrypt_ts_curState.tokenScriptHash + hash160(hash160(__scrypt_ts_curState.tag) + hash160(__scrypt_ts_curState.tokenScriptHash)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[[],[],[],[[8,0,5,13]],[],[],[],[],[],[],[]]
|