@typus/typus-sdk 1.4.3-c → 1.4.3-e
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/package.json +10 -2
- package/src/_dependencies/source/0x1/ascii/structs.ts +135 -0
- package/src/_dependencies/source/0x1/bit-vector/structs.ts +70 -0
- package/src/_dependencies/source/0x1/fixed-point32/structs.ts +69 -0
- package/src/_dependencies/source/0x1/index.ts +1 -0
- package/src/_dependencies/source/0x1/init.ts +16 -0
- package/src/_dependencies/source/0x1/option/structs.ts +74 -0
- package/src/_dependencies/source/0x1/string/structs.ts +70 -0
- package/src/_dependencies/source/0x1/type-name/structs.ts +70 -0
- package/src/_dependencies/source/0x1d17058789bd1e1e79f1a92424519a88146f191f58a06cc4d9ab23d17d46ab73/index.ts +1 -0
- package/src/_dependencies/source/0x1d17058789bd1e1e79f1a92424519a88146f191f58a06cc4d9ab23d17d46ab73/init.ts +14 -0
- package/src/_dependencies/source/0x1d17058789bd1e1e79f1a92424519a88146f191f58a06cc4d9ab23d17d46ab73/oracle/structs.ts +203 -0
- package/src/_dependencies/source/0x1d17058789bd1e1e79f1a92424519a88146f191f58a06cc4d9ab23d17d46ab73/pyth-parser/structs.ts +317 -0
- package/src/_dependencies/source/0x1d17058789bd1e1e79f1a92424519a88146f191f58a06cc4d9ab23d17d46ab73/supra/structs.ts +69 -0
- package/src/_dependencies/source/0x1d17058789bd1e1e79f1a92424519a88146f191f58a06cc4d9ab23d17d46ab73/switchboard-feed-parser/structs.ts +69 -0
- package/src/_dependencies/source/0x2/authenticator-state/structs.ts +332 -0
- package/src/_dependencies/source/0x2/bag/structs.ts +70 -0
- package/src/_dependencies/source/0x2/balance/structs.ts +134 -0
- package/src/_dependencies/source/0x2/bcs/structs.ts +70 -0
- package/src/_dependencies/source/0x2/bls12381/structs.ts +264 -0
- package/src/_dependencies/source/0x2/borrow/structs.ts +138 -0
- package/src/_dependencies/source/0x2/clock/structs.ts +70 -0
- package/src/_dependencies/source/0x2/coin/structs.ts +400 -0
- package/src/_dependencies/source/0x2/deny-list/structs.ts +139 -0
- package/src/_dependencies/source/0x2/display/structs.ts +202 -0
- package/src/_dependencies/source/0x2/dynamic-field/structs.ts +70 -0
- package/src/_dependencies/source/0x2/dynamic-object-field/structs.ts +71 -0
- package/src/_dependencies/source/0x2/groth16/structs.ts +265 -0
- package/src/_dependencies/source/0x2/group-ops/structs.ts +70 -0
- package/src/_dependencies/source/0x2/index.ts +1 -0
- package/src/_dependencies/source/0x2/init.ts +125 -0
- package/src/_dependencies/source/0x2/kiosk/structs.ts +658 -0
- package/src/_dependencies/source/0x2/kiosk-extension/structs.ts +135 -0
- package/src/_dependencies/source/0x2/linked-table/structs.ts +136 -0
- package/src/_dependencies/source/0x2/object/structs.ts +134 -0
- package/src/_dependencies/source/0x2/object-bag/structs.ts +70 -0
- package/src/_dependencies/source/0x2/object-table/structs.ts +70 -0
- package/src/_dependencies/source/0x2/package/structs.ts +267 -0
- package/src/_dependencies/source/0x2/priority-queue/structs.ts +139 -0
- package/src/_dependencies/source/0x2/random/structs.ts +202 -0
- package/src/_dependencies/source/0x2/sui/structs.ts +69 -0
- package/src/_dependencies/source/0x2/table/structs.ts +70 -0
- package/src/_dependencies/source/0x2/table-vec/structs.ts +71 -0
- package/src/_dependencies/source/0x2/token/structs.ts +401 -0
- package/src/_dependencies/source/0x2/transfer/structs.ts +70 -0
- package/src/_dependencies/source/0x2/transfer-policy/structs.ts +400 -0
- package/src/_dependencies/source/0x2/tx-context/structs.ts +70 -0
- package/src/_dependencies/source/0x2/url/structs.ts +70 -0
- package/src/_dependencies/source/0x2/vec-map/structs.ts +135 -0
- package/src/_dependencies/source/0x2/vec-set/structs.ts +72 -0
- package/src/_dependencies/source/0x2/versioned/structs.ts +135 -0
- package/src/_dependencies/source/0x2/zklogin-verified-id/structs.ts +71 -0
- package/src/_dependencies/source/0x2/zklogin-verified-issuer/structs.ts +71 -0
- package/src/_dependencies/source/0x277f90d256d1015a78cad646db091bec451c5bbab834b9fb70bace7885b5c698/index.ts +1 -0
- package/src/_dependencies/source/0x277f90d256d1015a78cad646db091bec451c5bbab834b9fb70bace7885b5c698/init.ts +5 -0
- package/src/_dependencies/source/0x277f90d256d1015a78cad646db091bec451c5bbab834b9fb70bace7885b5c698/validator/structs.ts +70 -0
- package/src/_dependencies/source/0x2fdff17b86e34ab722c8ba5e63f0da070d9a4163705b3fdc6a95802cab40a72a/index.ts +1 -0
- package/src/_dependencies/source/0x2fdff17b86e34ab722c8ba5e63f0da070d9a4163705b3fdc6a95802cab40a72a/init.ts +8 -0
- package/src/_dependencies/source/0x2fdff17b86e34ab722c8ba5e63f0da070d9a4163705b3fdc6a95802cab40a72a/price-data-pull/structs.ts +69 -0
- package/src/_dependencies/source/0x2fdff17b86e34ab722c8ba5e63f0da070d9a4163705b3fdc6a95802cab40a72a/suprasvaluefeed/structs.ts +135 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/airdrop/structs.ts +400 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/big-vector/structs.ts +372 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/critbit/structs.ts +205 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/ecosystem/structs.ts +333 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/index.ts +1 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/init.ts +48 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/leaderboard/structs.ts +465 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/linked-object-table/structs.ts +136 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/linked-set/structs.ts +140 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/tgld/structs.ts +268 -0
- package/src/_dependencies/source/0x4213e12a2220f15f1837a76897110d2260786558169bd8d0847f21e9b551f277/user/structs.ts +332 -0
- package/src/_dependencies/source/0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828/discount-mint/structs.ts +466 -0
- package/src/_dependencies/source/0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828/index.ts +1 -0
- package/src/_dependencies/source/0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828/init.ts +36 -0
- package/src/_dependencies/source/0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828/royalty-rule/structs.ts +134 -0
- package/src/_dependencies/source/0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828/staking/structs.ts +333 -0
- package/src/_dependencies/source/0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828/table-vec/structs.ts +71 -0
- package/src/_dependencies/source/0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828/typus-nft/structs.ts +856 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/auto-bid/structs.ts +1049 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/index.ts +1 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/init.ts +104 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/tails-staking/structs.ts +1054 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/tds-authorized-entry/structs.ts +592 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/tds-fee-pool-entry/structs.ts +461 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/tds-registry-authorized-entry/structs.ts +592 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/tds-view-function/structs.ts +69 -0
- package/src/_dependencies/source/0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f/typus-dov-single/structs.ts +2351 -0
- package/src/_dependencies/source/0x7237ec8436ef7e927c45470db6db3a834dd84cf903aedee3844e847fe4805399/index.ts +1 -0
- package/src/_dependencies/source/0x7237ec8436ef7e927c45470db6db3a834dd84cf903aedee3844e847fe4805399/init.ts +3 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/authority/structs.ts +71 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/balance-pool/structs.ts +203 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/big-vector/structs.ts +70 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/dutch/structs.ts +528 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/i64/structs.ts +69 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/index.ts +1 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/init.ts +54 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/linked-list/structs.ts +136 -0
- package/src/_dependencies/source/0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded/vault/structs.ts +1829 -0
- package/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/aggregator/structs.ts +398 -0
- package/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/index.ts +1 -0
- package/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/init.ts +18 -0
- package/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/job/structs.ts +71 -0
- package/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/math/structs.ts +69 -0
- package/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/quote/structs.ts +71 -0
- package/src/_dependencies/source/0x98670585b87e06628ef2d7f7cb1e7bee8ada65b43b82997935225a7e6e21d18e/switchboard/structs.ts +70 -0
- package/src/_dependencies/source/0xbd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585/index.ts +1 -0
- package/src/_dependencies/source/0xbd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585/init.ts +11 -0
- package/src/_dependencies/source/0xbd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585/kiosk-lock-rule/structs.ts +134 -0
- package/src/_dependencies/source/0xbd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585/royalty-rule/structs.ts +134 -0
- package/src/_dependencies/source/0xbd8fc1947cf119350184107a3087e2dc27efefa0dd82e25a1f699069fe81a585/witness-rule/structs.ts +69 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/bytes20/structs.ts +70 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/bytes32/structs.ts +70 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/consumed-vaas/structs.ts +72 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/cursor/structs.ts +72 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/emitter/structs.ts +200 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/external-address/structs.ts +70 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/fee-collector/structs.ts +72 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/governance-message/structs.ts +137 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/guardian/structs.ts +70 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/guardian-set/structs.ts +71 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/guardian-signature/structs.ts +70 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/index.ts +1 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/init.ts +65 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/migrate/structs.ts +70 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/package-utils/structs.ts +266 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/publish-message/structs.ts +136 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/set/structs.ts +136 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/set-fee/structs.ts +134 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/setup/structs.ts +70 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/state/structs.ts +142 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/transfer-fee/structs.ts +134 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/update-guardian-set/structs.ts +201 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/upgrade-contract/structs.ts +201 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/vaa/structs.ts +72 -0
- package/src/_dependencies/source/0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e/version-control/structs.ts +134 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/batch-price-attestation/structs.ts +136 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/contract-upgrade/structs.ts +136 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/data-source/structs.ts +70 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/event/structs.ts +135 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/governance/structs.ts +71 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/governance-action/structs.ts +69 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/governance-instruction/structs.ts +71 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/hot-potato-vector/structs.ts +72 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/i64/structs.ts +69 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/index.ts +1 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/init.ts +59 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/migrate/structs.ts +70 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/price/structs.ts +70 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/price-feed/structs.ts +71 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/price-identifier/structs.ts +70 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/price-info/structs.ts +136 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/price-status/structs.ts +69 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/set/structs.ts +138 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/set-data-sources/structs.ts +71 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/set-fee-recipient/structs.ts +69 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/set-governance-data-source/structs.ts +70 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/set-stale-price-threshold/structs.ts +69 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/set-update-fee/structs.ts +69 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/setup/structs.ts +70 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/state/structs.ts +203 -0
- package/src/_dependencies/source/0xe76d8a37d4132278a7a752183e90e04890b9e7d0f6657eadb68821609a2a56a3/version-control/structs.ts +134 -0
- package/src/_framework/init-source.ts +39 -0
- package/src/_framework/loader.ts +69 -0
- package/src/_framework/reified.ts +442 -0
- package/src/_framework/util.ts +265 -0
- package/src/airdrop/authority-entry.ts +101 -0
- package/src/airdrop/index.ts +3 -0
- package/src/airdrop/user-entry.ts +24 -0
- package/src/airdrop/view-function.ts +36 -0
- package/src/auto-bid/index.ts +2 -0
- package/src/auto-bid/user-entry.ts +256 -0
- package/src/auto-bid/view-function.ts +285 -0
- package/src/constants/constant.ts +32 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/token.ts +194 -0
- package/src/index.ts +11 -0
- package/src/leaderboard/authority-entry.ts +63 -0
- package/src/leaderboard/index.ts +2 -0
- package/src/leaderboard/view-function.ts +66 -0
- package/src/tails-exp-dice/api.ts +46 -0
- package/src/tails-exp-dice/fetch.ts +347 -0
- package/src/tails-exp-dice/index.ts +4 -0
- package/src/tails-exp-dice/user-entry.ts +241 -0
- package/src/tails-exp-dice/view-function.ts +111 -0
- package/src/tails-staking/authority-entry.ts +333 -0
- package/src/tails-staking/index.ts +3 -0
- package/src/tails-staking/user-entry.ts +401 -0
- package/src/tails-staking/view-function.ts +86 -0
- package/src/typus-dov-single-v2/entry/authority-entry.ts +171 -0
- package/src/typus-dov-single-v2/entry/index.ts +3 -0
- package/src/typus-dov-single-v2/entry/mfud-user-entry.ts +591 -0
- package/src/typus-dov-single-v2/entry/user-entry.ts +573 -0
- package/src/typus-dov-single-v2/function/bidding.ts +823 -0
- package/src/typus-dov-single-v2/function/index.ts +3 -0
- package/src/typus-dov-single-v2/function/token.ts +38 -0
- package/src/typus-dov-single-v2/function/vault.ts +24 -0
- package/src/typus-dov-single-v2/history/index.ts +2 -0
- package/src/typus-dov-single-v2/history/user-history.ts +929 -0
- package/src/typus-dov-single-v2/history/vault-history.ts +452 -0
- package/src/typus-dov-single-v2/index.ts +4 -0
- package/src/typus-dov-single-v2/view-function.ts +705 -0
- package/src/typus-nft/fetch.ts +428 -0
- package/src/typus-nft/index.ts +2 -0
- package/src/typus-nft/user-entry.ts +113 -0
- package/src/typus-perp/admin/functions.ts +141 -0
- package/src/typus-perp/admin/structs.ts +793 -0
- package/src/typus-perp/fetch.ts +253 -0
- package/src/typus-perp/index.ts +9 -0
- package/src/typus-perp/init.ts +96 -0
- package/src/typus-perp/lp-pool/functions.ts +694 -0
- package/src/typus-perp/lp-pool/structs.ts +3884 -0
- package/src/typus-perp/math/functions.ts +53 -0
- package/src/typus-perp/oracle/functions.ts +32 -0
- package/src/typus-perp/oracle/structs.ts +317 -0
- package/src/typus-perp/position/functions.ts +887 -0
- package/src/typus-perp/position/structs.ts +1637 -0
- package/src/typus-perp/readVec.ts +118 -0
- package/src/typus-perp/stake-pool/functions.ts +421 -0
- package/src/typus-perp/stake-pool/structs.ts +3873 -0
- package/src/typus-perp/symbol/functions.ts +24 -0
- package/src/typus-perp/symbol/structs.ts +165 -0
- package/src/typus-perp/tlp/functions.ts +50 -0
- package/src/typus-perp/tlp/structs.ts +287 -0
- package/src/typus-perp/token-interface/functions.ts +29 -0
- package/src/typus-perp/trading/functions.ts +1046 -0
- package/src/typus-perp/trading/structs.ts +4541 -0
- package/src/typus-perp/treasury-caps/functions.ts +36 -0
- package/src/typus-perp/treasury-caps/structs.ts +151 -0
- package/src/typus-perp/user/order.ts +221 -0
- package/src/typus-perp/user/orderWithBidReceipt.ts +176 -0
- package/src/typus-perp/user/tlp.ts +234 -0
- package/src/user/index.ts +1 -0
- package/src/user/view-function.ts +33 -0
- package/src/utils/.DS_Store +0 -0
- package/src/utils/api/defillama/index.ts +1 -0
- package/src/utils/api/defillama/tvl.ts +11 -0
- package/src/utils/api/index.ts +3 -0
- package/src/utils/api/price.ts +101 -0
- package/src/utils/api/sentio/index.ts +2 -0
- package/src/utils/api/sentio/leader-board.ts +259 -0
- package/src/utils/api/sentio/reward-generated.ts +392 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/load_env.ts +5 -0
- package/src/utils/mint.ts +16 -0
- package/src/utils/pyth/constant.ts +71 -0
- package/src/utils/pyth/index.ts +2 -0
- package/src/utils/pyth/pythClient.ts +52 -0
- package/src/utils/tools.ts +38 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr, assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom} from "../../../../_framework/reified";
|
|
2
|
+
import {FieldsWithTypes, composeSuiType, compressSuiType} from "../../../../_framework/util";
|
|
3
|
+
import {Bag} from "../bag/structs";
|
|
4
|
+
import {bcs, fromB64} from "@mysten/bcs";
|
|
5
|
+
import {SuiClient, SuiParsedData} from "@mysten/sui.js/client";
|
|
6
|
+
|
|
7
|
+
/* ============================== Extension =============================== */
|
|
8
|
+
|
|
9
|
+
export function isExtension(type: string): boolean { type = compressSuiType(type); return type === "0x2::kiosk_extension::Extension"; }
|
|
10
|
+
|
|
11
|
+
export interface ExtensionFields { storage: ToField<Bag>; permissions: ToField<"u128">; isEnabled: ToField<"bool"> }
|
|
12
|
+
|
|
13
|
+
export type ExtensionReified = Reified< Extension, ExtensionFields >;
|
|
14
|
+
|
|
15
|
+
export class Extension implements StructClass { static readonly $typeName = "0x2::kiosk_extension::Extension"; static readonly $numTypeParams = 0;
|
|
16
|
+
|
|
17
|
+
readonly $typeName = Extension.$typeName;
|
|
18
|
+
|
|
19
|
+
readonly $fullTypeName: "0x2::kiosk_extension::Extension";
|
|
20
|
+
|
|
21
|
+
readonly $typeArgs: [];
|
|
22
|
+
|
|
23
|
+
readonly storage: ToField<Bag>; readonly permissions: ToField<"u128">; readonly isEnabled: ToField<"bool">
|
|
24
|
+
|
|
25
|
+
private constructor(typeArgs: [], fields: ExtensionFields, ) { this.$fullTypeName = composeSuiType( Extension.$typeName, ...typeArgs ) as "0x2::kiosk_extension::Extension"; this.$typeArgs = typeArgs;
|
|
26
|
+
|
|
27
|
+
this.storage = fields.storage;; this.permissions = fields.permissions;; this.isEnabled = fields.isEnabled; }
|
|
28
|
+
|
|
29
|
+
static reified( ): ExtensionReified { return { typeName: Extension.$typeName, fullTypeName: composeSuiType( Extension.$typeName, ...[] ) as "0x2::kiosk_extension::Extension", typeArgs: [ ] as [], reifiedTypeArgs: [], fromFields: (fields: Record<string, any>) => Extension.fromFields( fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => Extension.fromFieldsWithTypes( item, ), fromBcs: (data: Uint8Array) => Extension.fromBcs( data, ), bcs: Extension.bcs, fromJSONField: (field: any) => Extension.fromJSONField( field, ), fromJSON: (json: Record<string, any>) => Extension.fromJSON( json, ), fromSuiParsedData: (content: SuiParsedData) => Extension.fromSuiParsedData( content, ), fetch: async (client: SuiClient, id: string) => Extension.fetch( client, id, ), new: ( fields: ExtensionFields, ) => { return new Extension( [], fields ) }, kind: "StructClassReified", } }
|
|
30
|
+
|
|
31
|
+
static get r() { return Extension.reified() }
|
|
32
|
+
|
|
33
|
+
static phantom( ): PhantomReified<ToTypeStr<Extension>> { return phantom(Extension.reified( )); } static get p() { return Extension.phantom() }
|
|
34
|
+
|
|
35
|
+
static get bcs() { return bcs.struct("Extension", {
|
|
36
|
+
|
|
37
|
+
storage: Bag.bcs, permissions: bcs.u128(), is_enabled: bcs.bool()
|
|
38
|
+
|
|
39
|
+
}) };
|
|
40
|
+
|
|
41
|
+
static fromFields( fields: Record<string, any> ): Extension { return Extension.reified( ).new( { storage: decodeFromFields(Bag.reified(), fields.storage), permissions: decodeFromFields("u128", fields.permissions), isEnabled: decodeFromFields("bool", fields.is_enabled) } ) }
|
|
42
|
+
|
|
43
|
+
static fromFieldsWithTypes( item: FieldsWithTypes ): Extension { if (!isExtension(item.type)) { throw new Error("not a Extension type");
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return Extension.reified( ).new( { storage: decodeFromFieldsWithTypes(Bag.reified(), item.fields.storage), permissions: decodeFromFieldsWithTypes("u128", item.fields.permissions), isEnabled: decodeFromFieldsWithTypes("bool", item.fields.is_enabled) } ) }
|
|
48
|
+
|
|
49
|
+
static fromBcs( data: Uint8Array ): Extension { return Extension.fromFields( Extension.bcs.parse(data) ) }
|
|
50
|
+
|
|
51
|
+
toJSONField() { return {
|
|
52
|
+
|
|
53
|
+
storage: this.storage.toJSONField(),permissions: this.permissions.toString(),isEnabled: this.isEnabled,
|
|
54
|
+
|
|
55
|
+
} }
|
|
56
|
+
|
|
57
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
58
|
+
|
|
59
|
+
static fromJSONField( field: any ): Extension { return Extension.reified( ).new( { storage: decodeFromJSONField(Bag.reified(), field.storage), permissions: decodeFromJSONField("u128", field.permissions), isEnabled: decodeFromJSONField("bool", field.isEnabled) } ) }
|
|
60
|
+
|
|
61
|
+
static fromJSON( json: Record<string, any> ): Extension { if (json.$typeName !== Extension.$typeName) { throw new Error("not a WithTwoGenerics json object") };
|
|
62
|
+
|
|
63
|
+
return Extension.fromJSONField( json, ) }
|
|
64
|
+
|
|
65
|
+
static fromSuiParsedData( content: SuiParsedData ): Extension { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isExtension(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a Extension object`); } return Extension.fromFieldsWithTypes( content ); }
|
|
66
|
+
|
|
67
|
+
static async fetch( client: SuiClient, id: string ): Promise<Extension> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching Extension object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isExtension(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a Extension object`); }
|
|
68
|
+
return Extension.fromBcs( fromB64(res.data.bcs.bcsBytes) ); }
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ============================== ExtensionKey =============================== */
|
|
73
|
+
|
|
74
|
+
export function isExtensionKey(type: string): boolean { type = compressSuiType(type); return type.startsWith("0x2::kiosk_extension::ExtensionKey<"); }
|
|
75
|
+
|
|
76
|
+
export interface ExtensionKeyFields<Ext extends PhantomTypeArgument> { dummyField: ToField<"bool"> }
|
|
77
|
+
|
|
78
|
+
export type ExtensionKeyReified<Ext extends PhantomTypeArgument> = Reified< ExtensionKey<Ext>, ExtensionKeyFields<Ext> >;
|
|
79
|
+
|
|
80
|
+
export class ExtensionKey<Ext extends PhantomTypeArgument> implements StructClass { static readonly $typeName = "0x2::kiosk_extension::ExtensionKey"; static readonly $numTypeParams = 1;
|
|
81
|
+
|
|
82
|
+
readonly $typeName = ExtensionKey.$typeName;
|
|
83
|
+
|
|
84
|
+
readonly $fullTypeName: `0x2::kiosk_extension::ExtensionKey<${PhantomToTypeStr<Ext>}>`;
|
|
85
|
+
|
|
86
|
+
readonly $typeArgs: [PhantomToTypeStr<Ext>];
|
|
87
|
+
|
|
88
|
+
readonly dummyField: ToField<"bool">
|
|
89
|
+
|
|
90
|
+
private constructor(typeArgs: [PhantomToTypeStr<Ext>], fields: ExtensionKeyFields<Ext>, ) { this.$fullTypeName = composeSuiType( ExtensionKey.$typeName, ...typeArgs ) as `0x2::kiosk_extension::ExtensionKey<${PhantomToTypeStr<Ext>}>`; this.$typeArgs = typeArgs;
|
|
91
|
+
|
|
92
|
+
this.dummyField = fields.dummyField; }
|
|
93
|
+
|
|
94
|
+
static reified<Ext extends PhantomReified<PhantomTypeArgument>>( Ext: Ext ): ExtensionKeyReified<ToPhantomTypeArgument<Ext>> { return { typeName: ExtensionKey.$typeName, fullTypeName: composeSuiType( ExtensionKey.$typeName, ...[extractType(Ext)] ) as `0x2::kiosk_extension::ExtensionKey<${PhantomToTypeStr<ToPhantomTypeArgument<Ext>>}>`, typeArgs: [ extractType(Ext) ] as [PhantomToTypeStr<ToPhantomTypeArgument<Ext>>], reifiedTypeArgs: [Ext], fromFields: (fields: Record<string, any>) => ExtensionKey.fromFields( Ext, fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => ExtensionKey.fromFieldsWithTypes( Ext, item, ), fromBcs: (data: Uint8Array) => ExtensionKey.fromBcs( Ext, data, ), bcs: ExtensionKey.bcs, fromJSONField: (field: any) => ExtensionKey.fromJSONField( Ext, field, ), fromJSON: (json: Record<string, any>) => ExtensionKey.fromJSON( Ext, json, ), fromSuiParsedData: (content: SuiParsedData) => ExtensionKey.fromSuiParsedData( Ext, content, ), fetch: async (client: SuiClient, id: string) => ExtensionKey.fetch( client, Ext, id, ), new: ( fields: ExtensionKeyFields<ToPhantomTypeArgument<Ext>>, ) => { return new ExtensionKey( [extractType(Ext)], fields ) }, kind: "StructClassReified", } }
|
|
95
|
+
|
|
96
|
+
static get r() { return ExtensionKey.reified }
|
|
97
|
+
|
|
98
|
+
static phantom<Ext extends PhantomReified<PhantomTypeArgument>>( Ext: Ext ): PhantomReified<ToTypeStr<ExtensionKey<ToPhantomTypeArgument<Ext>>>> { return phantom(ExtensionKey.reified( Ext )); } static get p() { return ExtensionKey.phantom }
|
|
99
|
+
|
|
100
|
+
static get bcs() { return bcs.struct("ExtensionKey", {
|
|
101
|
+
|
|
102
|
+
dummy_field: bcs.bool()
|
|
103
|
+
|
|
104
|
+
}) };
|
|
105
|
+
|
|
106
|
+
static fromFields<Ext extends PhantomReified<PhantomTypeArgument>>( typeArg: Ext, fields: Record<string, any> ): ExtensionKey<ToPhantomTypeArgument<Ext>> { return ExtensionKey.reified( typeArg, ).new( { dummyField: decodeFromFields("bool", fields.dummy_field) } ) }
|
|
107
|
+
|
|
108
|
+
static fromFieldsWithTypes<Ext extends PhantomReified<PhantomTypeArgument>>( typeArg: Ext, item: FieldsWithTypes ): ExtensionKey<ToPhantomTypeArgument<Ext>> { if (!isExtensionKey(item.type)) { throw new Error("not a ExtensionKey type");
|
|
109
|
+
|
|
110
|
+
} assertFieldsWithTypesArgsMatch(item, [typeArg]);
|
|
111
|
+
|
|
112
|
+
return ExtensionKey.reified( typeArg, ).new( { dummyField: decodeFromFieldsWithTypes("bool", item.fields.dummy_field) } ) }
|
|
113
|
+
|
|
114
|
+
static fromBcs<Ext extends PhantomReified<PhantomTypeArgument>>( typeArg: Ext, data: Uint8Array ): ExtensionKey<ToPhantomTypeArgument<Ext>> { return ExtensionKey.fromFields( typeArg, ExtensionKey.bcs.parse(data) ) }
|
|
115
|
+
|
|
116
|
+
toJSONField() { return {
|
|
117
|
+
|
|
118
|
+
dummyField: this.dummyField,
|
|
119
|
+
|
|
120
|
+
} }
|
|
121
|
+
|
|
122
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
123
|
+
|
|
124
|
+
static fromJSONField<Ext extends PhantomReified<PhantomTypeArgument>>( typeArg: Ext, field: any ): ExtensionKey<ToPhantomTypeArgument<Ext>> { return ExtensionKey.reified( typeArg, ).new( { dummyField: decodeFromJSONField("bool", field.dummyField) } ) }
|
|
125
|
+
|
|
126
|
+
static fromJSON<Ext extends PhantomReified<PhantomTypeArgument>>( typeArg: Ext, json: Record<string, any> ): ExtensionKey<ToPhantomTypeArgument<Ext>> { if (json.$typeName !== ExtensionKey.$typeName) { throw new Error("not a WithTwoGenerics json object") }; assertReifiedTypeArgsMatch( composeSuiType(ExtensionKey.$typeName, extractType(typeArg)), json.$typeArgs, [typeArg], )
|
|
127
|
+
|
|
128
|
+
return ExtensionKey.fromJSONField( typeArg, json, ) }
|
|
129
|
+
|
|
130
|
+
static fromSuiParsedData<Ext extends PhantomReified<PhantomTypeArgument>>( typeArg: Ext, content: SuiParsedData ): ExtensionKey<ToPhantomTypeArgument<Ext>> { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isExtensionKey(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a ExtensionKey object`); } return ExtensionKey.fromFieldsWithTypes( typeArg, content ); }
|
|
131
|
+
|
|
132
|
+
static async fetch<Ext extends PhantomReified<PhantomTypeArgument>>( client: SuiClient, typeArg: Ext, id: string ): Promise<ExtensionKey<ToPhantomTypeArgument<Ext>>> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching ExtensionKey object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isExtensionKey(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a ExtensionKey object`); }
|
|
133
|
+
return ExtensionKey.fromBcs( typeArg, fromB64(res.data.bcs.bcsBytes) ); }
|
|
134
|
+
|
|
135
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeArgument, ToTypeStr, TypeArgument, assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs} from "../../../../_framework/reified";
|
|
2
|
+
import {FieldsWithTypes, composeSuiType, compressSuiType} from "../../../../_framework/util";
|
|
3
|
+
import {Option} from "../../0x1/option/structs";
|
|
4
|
+
import {UID} from "../object/structs";
|
|
5
|
+
import {BcsType, bcs, fromB64} from "@mysten/bcs";
|
|
6
|
+
import {SuiClient, SuiParsedData} from "@mysten/sui.js/client";
|
|
7
|
+
|
|
8
|
+
/* ============================== LinkedTable =============================== */
|
|
9
|
+
|
|
10
|
+
export function isLinkedTable(type: string): boolean { type = compressSuiType(type); return type.startsWith("0x2::linked_table::LinkedTable<"); }
|
|
11
|
+
|
|
12
|
+
export interface LinkedTableFields<K extends TypeArgument, V extends PhantomTypeArgument> { id: ToField<UID>; size: ToField<"u64">; head: ToField<Option<K>>; tail: ToField<Option<K>> }
|
|
13
|
+
|
|
14
|
+
export type LinkedTableReified<K extends TypeArgument, V extends PhantomTypeArgument> = Reified< LinkedTable<K, V>, LinkedTableFields<K, V> >;
|
|
15
|
+
|
|
16
|
+
export class LinkedTable<K extends TypeArgument, V extends PhantomTypeArgument> implements StructClass { static readonly $typeName = "0x2::linked_table::LinkedTable"; static readonly $numTypeParams = 2;
|
|
17
|
+
|
|
18
|
+
readonly $typeName = LinkedTable.$typeName;
|
|
19
|
+
|
|
20
|
+
readonly $fullTypeName: `0x2::linked_table::LinkedTable<${ToTypeStr<K>}, ${PhantomToTypeStr<V>}>`;
|
|
21
|
+
|
|
22
|
+
readonly $typeArgs: [ToTypeStr<K>, PhantomToTypeStr<V>];
|
|
23
|
+
|
|
24
|
+
readonly id: ToField<UID>; readonly size: ToField<"u64">; readonly head: ToField<Option<K>>; readonly tail: ToField<Option<K>>
|
|
25
|
+
|
|
26
|
+
private constructor(typeArgs: [ToTypeStr<K>, PhantomToTypeStr<V>], fields: LinkedTableFields<K, V>, ) { this.$fullTypeName = composeSuiType( LinkedTable.$typeName, ...typeArgs ) as `0x2::linked_table::LinkedTable<${ToTypeStr<K>}, ${PhantomToTypeStr<V>}>`; this.$typeArgs = typeArgs;
|
|
27
|
+
|
|
28
|
+
this.id = fields.id;; this.size = fields.size;; this.head = fields.head;; this.tail = fields.tail; }
|
|
29
|
+
|
|
30
|
+
static reified<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( K: K, V: V ): LinkedTableReified<ToTypeArgument<K>, ToPhantomTypeArgument<V>> { return { typeName: LinkedTable.$typeName, fullTypeName: composeSuiType( LinkedTable.$typeName, ...[extractType(K), extractType(V)] ) as `0x2::linked_table::LinkedTable<${ToTypeStr<ToTypeArgument<K>>}, ${PhantomToTypeStr<ToPhantomTypeArgument<V>>}>`, typeArgs: [ extractType(K), extractType(V) ] as [ToTypeStr<ToTypeArgument<K>>, PhantomToTypeStr<ToPhantomTypeArgument<V>>], reifiedTypeArgs: [K, V], fromFields: (fields: Record<string, any>) => LinkedTable.fromFields( [K, V], fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => LinkedTable.fromFieldsWithTypes( [K, V], item, ), fromBcs: (data: Uint8Array) => LinkedTable.fromBcs( [K, V], data, ), bcs: LinkedTable.bcs(toBcs(K)), fromJSONField: (field: any) => LinkedTable.fromJSONField( [K, V], field, ), fromJSON: (json: Record<string, any>) => LinkedTable.fromJSON( [K, V], json, ), fromSuiParsedData: (content: SuiParsedData) => LinkedTable.fromSuiParsedData( [K, V], content, ), fetch: async (client: SuiClient, id: string) => LinkedTable.fetch( client, [K, V], id, ), new: ( fields: LinkedTableFields<ToTypeArgument<K>, ToPhantomTypeArgument<V>>, ) => { return new LinkedTable( [extractType(K), extractType(V)], fields ) }, kind: "StructClassReified", } }
|
|
31
|
+
|
|
32
|
+
static get r() { return LinkedTable.reified }
|
|
33
|
+
|
|
34
|
+
static phantom<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( K: K, V: V ): PhantomReified<ToTypeStr<LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>>>> { return phantom(LinkedTable.reified( K, V )); } static get p() { return LinkedTable.phantom }
|
|
35
|
+
|
|
36
|
+
static get bcs() { return <K extends BcsType<any>>(K: K) => bcs.struct(`LinkedTable<${K.name}>`, {
|
|
37
|
+
|
|
38
|
+
id: UID.bcs, size: bcs.u64(), head: Option.bcs(K), tail: Option.bcs(K)
|
|
39
|
+
|
|
40
|
+
}) };
|
|
41
|
+
|
|
42
|
+
static fromFields<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], fields: Record<string, any> ): LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>> { return LinkedTable.reified( typeArgs[0], typeArgs[1], ).new( { id: decodeFromFields(UID.reified(), fields.id), size: decodeFromFields("u64", fields.size), head: decodeFromFields(Option.reified(typeArgs[0]), fields.head), tail: decodeFromFields(Option.reified(typeArgs[0]), fields.tail) } ) }
|
|
43
|
+
|
|
44
|
+
static fromFieldsWithTypes<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], item: FieldsWithTypes ): LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>> { if (!isLinkedTable(item.type)) { throw new Error("not a LinkedTable type");
|
|
45
|
+
|
|
46
|
+
} assertFieldsWithTypesArgsMatch(item, typeArgs);
|
|
47
|
+
|
|
48
|
+
return LinkedTable.reified( typeArgs[0], typeArgs[1], ).new( { id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id), size: decodeFromFieldsWithTypes("u64", item.fields.size), head: decodeFromFieldsWithTypes(Option.reified(typeArgs[0]), item.fields.head), tail: decodeFromFieldsWithTypes(Option.reified(typeArgs[0]), item.fields.tail) } ) }
|
|
49
|
+
|
|
50
|
+
static fromBcs<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], data: Uint8Array ): LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>> { return LinkedTable.fromFields( typeArgs, LinkedTable.bcs( toBcs(typeArgs[0]) ).parse(data) ) }
|
|
51
|
+
|
|
52
|
+
toJSONField() { return {
|
|
53
|
+
|
|
54
|
+
id: this.id,size: this.size.toString(),head: fieldToJSON<Option<K>>(`0x1::option::Option<${this.$typeArgs[0]}>`, this.head),tail: fieldToJSON<Option<K>>(`0x1::option::Option<${this.$typeArgs[0]}>`, this.tail),
|
|
55
|
+
|
|
56
|
+
} }
|
|
57
|
+
|
|
58
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
59
|
+
|
|
60
|
+
static fromJSONField<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], field: any ): LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>> { return LinkedTable.reified( typeArgs[0], typeArgs[1], ).new( { id: decodeFromJSONField(UID.reified(), field.id), size: decodeFromJSONField("u64", field.size), head: decodeFromJSONField(Option.reified(typeArgs[0]), field.head), tail: decodeFromJSONField(Option.reified(typeArgs[0]), field.tail) } ) }
|
|
61
|
+
|
|
62
|
+
static fromJSON<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], json: Record<string, any> ): LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>> { if (json.$typeName !== LinkedTable.$typeName) { throw new Error("not a WithTwoGenerics json object") }; assertReifiedTypeArgsMatch( composeSuiType(LinkedTable.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs, )
|
|
63
|
+
|
|
64
|
+
return LinkedTable.fromJSONField( typeArgs, json, ) }
|
|
65
|
+
|
|
66
|
+
static fromSuiParsedData<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], content: SuiParsedData ): LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>> { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isLinkedTable(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a LinkedTable object`); } return LinkedTable.fromFieldsWithTypes( typeArgs, content ); }
|
|
67
|
+
|
|
68
|
+
static async fetch<K extends Reified<TypeArgument, any>, V extends PhantomReified<PhantomTypeArgument>>( client: SuiClient, typeArgs: [K, V], id: string ): Promise<LinkedTable<ToTypeArgument<K>, ToPhantomTypeArgument<V>>> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching LinkedTable object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isLinkedTable(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a LinkedTable object`); }
|
|
69
|
+
return LinkedTable.fromBcs( typeArgs, fromB64(res.data.bcs.bcsBytes) ); }
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* ============================== Node =============================== */
|
|
74
|
+
|
|
75
|
+
export function isNode(type: string): boolean { type = compressSuiType(type); return type.startsWith("0x2::linked_table::Node<"); }
|
|
76
|
+
|
|
77
|
+
export interface NodeFields<K extends TypeArgument, V extends TypeArgument> { prev: ToField<Option<K>>; next: ToField<Option<K>>; value: ToField<V> }
|
|
78
|
+
|
|
79
|
+
export type NodeReified<K extends TypeArgument, V extends TypeArgument> = Reified< Node<K, V>, NodeFields<K, V> >;
|
|
80
|
+
|
|
81
|
+
export class Node<K extends TypeArgument, V extends TypeArgument> implements StructClass { static readonly $typeName = "0x2::linked_table::Node"; static readonly $numTypeParams = 2;
|
|
82
|
+
|
|
83
|
+
readonly $typeName = Node.$typeName;
|
|
84
|
+
|
|
85
|
+
readonly $fullTypeName: `0x2::linked_table::Node<${ToTypeStr<K>}, ${ToTypeStr<V>}>`;
|
|
86
|
+
|
|
87
|
+
readonly $typeArgs: [ToTypeStr<K>, ToTypeStr<V>];
|
|
88
|
+
|
|
89
|
+
readonly prev: ToField<Option<K>>; readonly next: ToField<Option<K>>; readonly value: ToField<V>
|
|
90
|
+
|
|
91
|
+
private constructor(typeArgs: [ToTypeStr<K>, ToTypeStr<V>], fields: NodeFields<K, V>, ) { this.$fullTypeName = composeSuiType( Node.$typeName, ...typeArgs ) as `0x2::linked_table::Node<${ToTypeStr<K>}, ${ToTypeStr<V>}>`; this.$typeArgs = typeArgs;
|
|
92
|
+
|
|
93
|
+
this.prev = fields.prev;; this.next = fields.next;; this.value = fields.value; }
|
|
94
|
+
|
|
95
|
+
static reified<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( K: K, V: V ): NodeReified<ToTypeArgument<K>, ToTypeArgument<V>> { return { typeName: Node.$typeName, fullTypeName: composeSuiType( Node.$typeName, ...[extractType(K), extractType(V)] ) as `0x2::linked_table::Node<${ToTypeStr<ToTypeArgument<K>>}, ${ToTypeStr<ToTypeArgument<V>>}>`, typeArgs: [ extractType(K), extractType(V) ] as [ToTypeStr<ToTypeArgument<K>>, ToTypeStr<ToTypeArgument<V>>], reifiedTypeArgs: [K, V], fromFields: (fields: Record<string, any>) => Node.fromFields( [K, V], fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => Node.fromFieldsWithTypes( [K, V], item, ), fromBcs: (data: Uint8Array) => Node.fromBcs( [K, V], data, ), bcs: Node.bcs(toBcs(K), toBcs(V)), fromJSONField: (field: any) => Node.fromJSONField( [K, V], field, ), fromJSON: (json: Record<string, any>) => Node.fromJSON( [K, V], json, ), fromSuiParsedData: (content: SuiParsedData) => Node.fromSuiParsedData( [K, V], content, ), fetch: async (client: SuiClient, id: string) => Node.fetch( client, [K, V], id, ), new: ( fields: NodeFields<ToTypeArgument<K>, ToTypeArgument<V>>, ) => { return new Node( [extractType(K), extractType(V)], fields ) }, kind: "StructClassReified", } }
|
|
96
|
+
|
|
97
|
+
static get r() { return Node.reified }
|
|
98
|
+
|
|
99
|
+
static phantom<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( K: K, V: V ): PhantomReified<ToTypeStr<Node<ToTypeArgument<K>, ToTypeArgument<V>>>> { return phantom(Node.reified( K, V )); } static get p() { return Node.phantom }
|
|
100
|
+
|
|
101
|
+
static get bcs() { return <K extends BcsType<any>, V extends BcsType<any>>(K: K, V: V) => bcs.struct(`Node<${K.name}, ${V.name}>`, {
|
|
102
|
+
|
|
103
|
+
prev: Option.bcs(K), next: Option.bcs(K), value: V
|
|
104
|
+
|
|
105
|
+
}) };
|
|
106
|
+
|
|
107
|
+
static fromFields<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( typeArgs: [K, V], fields: Record<string, any> ): Node<ToTypeArgument<K>, ToTypeArgument<V>> { return Node.reified( typeArgs[0], typeArgs[1], ).new( { prev: decodeFromFields(Option.reified(typeArgs[0]), fields.prev), next: decodeFromFields(Option.reified(typeArgs[0]), fields.next), value: decodeFromFields(typeArgs[1], fields.value) } ) }
|
|
108
|
+
|
|
109
|
+
static fromFieldsWithTypes<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( typeArgs: [K, V], item: FieldsWithTypes ): Node<ToTypeArgument<K>, ToTypeArgument<V>> { if (!isNode(item.type)) { throw new Error("not a Node type");
|
|
110
|
+
|
|
111
|
+
} assertFieldsWithTypesArgsMatch(item, typeArgs);
|
|
112
|
+
|
|
113
|
+
return Node.reified( typeArgs[0], typeArgs[1], ).new( { prev: decodeFromFieldsWithTypes(Option.reified(typeArgs[0]), item.fields.prev), next: decodeFromFieldsWithTypes(Option.reified(typeArgs[0]), item.fields.next), value: decodeFromFieldsWithTypes(typeArgs[1], item.fields.value) } ) }
|
|
114
|
+
|
|
115
|
+
static fromBcs<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( typeArgs: [K, V], data: Uint8Array ): Node<ToTypeArgument<K>, ToTypeArgument<V>> { return Node.fromFields( typeArgs, Node.bcs( toBcs(typeArgs[0]), toBcs(typeArgs[1]) ).parse(data) ) }
|
|
116
|
+
|
|
117
|
+
toJSONField() { return {
|
|
118
|
+
|
|
119
|
+
prev: fieldToJSON<Option<K>>(`0x1::option::Option<${this.$typeArgs[0]}>`, this.prev),next: fieldToJSON<Option<K>>(`0x1::option::Option<${this.$typeArgs[0]}>`, this.next),value: fieldToJSON<V>(this.$typeArgs[1], this.value),
|
|
120
|
+
|
|
121
|
+
} }
|
|
122
|
+
|
|
123
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
124
|
+
|
|
125
|
+
static fromJSONField<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( typeArgs: [K, V], field: any ): Node<ToTypeArgument<K>, ToTypeArgument<V>> { return Node.reified( typeArgs[0], typeArgs[1], ).new( { prev: decodeFromJSONField(Option.reified(typeArgs[0]), field.prev), next: decodeFromJSONField(Option.reified(typeArgs[0]), field.next), value: decodeFromJSONField(typeArgs[1], field.value) } ) }
|
|
126
|
+
|
|
127
|
+
static fromJSON<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( typeArgs: [K, V], json: Record<string, any> ): Node<ToTypeArgument<K>, ToTypeArgument<V>> { if (json.$typeName !== Node.$typeName) { throw new Error("not a WithTwoGenerics json object") }; assertReifiedTypeArgsMatch( composeSuiType(Node.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs, )
|
|
128
|
+
|
|
129
|
+
return Node.fromJSONField( typeArgs, json, ) }
|
|
130
|
+
|
|
131
|
+
static fromSuiParsedData<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( typeArgs: [K, V], content: SuiParsedData ): Node<ToTypeArgument<K>, ToTypeArgument<V>> { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isNode(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a Node object`); } return Node.fromFieldsWithTypes( typeArgs, content ); }
|
|
132
|
+
|
|
133
|
+
static async fetch<K extends Reified<TypeArgument, any>, V extends Reified<TypeArgument, any>>( client: SuiClient, typeArgs: [K, V], id: string ): Promise<Node<ToTypeArgument<K>, ToTypeArgument<V>>> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching Node object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isNode(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a Node object`); }
|
|
134
|
+
return Node.fromBcs( typeArgs, fromB64(res.data.bcs.bcsBytes) ); }
|
|
135
|
+
|
|
136
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {PhantomReified, Reified, StructClass, ToField, ToTypeStr, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom} from "../../../../_framework/reified";
|
|
2
|
+
import {FieldsWithTypes, composeSuiType, compressSuiType} from "../../../../_framework/util";
|
|
3
|
+
import {bcs, fromB64, fromHEX, toHEX} from "@mysten/bcs";
|
|
4
|
+
import {SuiClient, SuiParsedData} from "@mysten/sui.js/client";
|
|
5
|
+
|
|
6
|
+
/* ============================== ID =============================== */
|
|
7
|
+
|
|
8
|
+
export function isID(type: string): boolean { type = compressSuiType(type); return type === "0x2::object::ID"; }
|
|
9
|
+
|
|
10
|
+
export interface IDFields { bytes: ToField<"address"> }
|
|
11
|
+
|
|
12
|
+
export type IDReified = Reified< ID, IDFields >;
|
|
13
|
+
|
|
14
|
+
export class ID implements StructClass { static readonly $typeName = "0x2::object::ID"; static readonly $numTypeParams = 0;
|
|
15
|
+
|
|
16
|
+
readonly $typeName = ID.$typeName;
|
|
17
|
+
|
|
18
|
+
readonly $fullTypeName: "0x2::object::ID";
|
|
19
|
+
|
|
20
|
+
readonly $typeArgs: [];
|
|
21
|
+
|
|
22
|
+
readonly bytes: ToField<"address">
|
|
23
|
+
|
|
24
|
+
private constructor(typeArgs: [], fields: IDFields, ) { this.$fullTypeName = composeSuiType( ID.$typeName, ...typeArgs ) as "0x2::object::ID"; this.$typeArgs = typeArgs;
|
|
25
|
+
|
|
26
|
+
this.bytes = fields.bytes; }
|
|
27
|
+
|
|
28
|
+
static reified( ): IDReified { return { typeName: ID.$typeName, fullTypeName: composeSuiType( ID.$typeName, ...[] ) as "0x2::object::ID", typeArgs: [ ] as [], reifiedTypeArgs: [], fromFields: (fields: Record<string, any>) => ID.fromFields( fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => ID.fromFieldsWithTypes( item, ), fromBcs: (data: Uint8Array) => ID.fromBcs( data, ), bcs: ID.bcs, fromJSONField: (field: any) => ID.fromJSONField( field, ), fromJSON: (json: Record<string, any>) => ID.fromJSON( json, ), fromSuiParsedData: (content: SuiParsedData) => ID.fromSuiParsedData( content, ), fetch: async (client: SuiClient, id: string) => ID.fetch( client, id, ), new: ( fields: IDFields, ) => { return new ID( [], fields ) }, kind: "StructClassReified", } }
|
|
29
|
+
|
|
30
|
+
static get r() { return ID.reified() }
|
|
31
|
+
|
|
32
|
+
static phantom( ): PhantomReified<ToTypeStr<ID>> { return phantom(ID.reified( )); } static get p() { return ID.phantom() }
|
|
33
|
+
|
|
34
|
+
static get bcs() { return bcs.struct("ID", {
|
|
35
|
+
|
|
36
|
+
bytes: bcs.bytes(32).transform({ input: (val: string) => fromHEX(val), output: (val: Uint8Array) => toHEX(val), })
|
|
37
|
+
|
|
38
|
+
}) };
|
|
39
|
+
|
|
40
|
+
static fromFields( fields: Record<string, any> ): ID { return ID.reified( ).new( { bytes: decodeFromFields("address", fields.bytes) } ) }
|
|
41
|
+
|
|
42
|
+
static fromFieldsWithTypes( item: FieldsWithTypes ): ID { if (!isID(item.type)) { throw new Error("not a ID type");
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return ID.reified( ).new( { bytes: decodeFromFieldsWithTypes("address", item.fields.bytes) } ) }
|
|
47
|
+
|
|
48
|
+
static fromBcs( data: Uint8Array ): ID { return ID.fromFields( ID.bcs.parse(data) ) }
|
|
49
|
+
|
|
50
|
+
toJSONField() { return {
|
|
51
|
+
|
|
52
|
+
bytes: this.bytes,
|
|
53
|
+
|
|
54
|
+
} }
|
|
55
|
+
|
|
56
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
57
|
+
|
|
58
|
+
static fromJSONField( field: any ): ID { return ID.reified( ).new( { bytes: decodeFromJSONField("address", field.bytes) } ) }
|
|
59
|
+
|
|
60
|
+
static fromJSON( json: Record<string, any> ): ID { if (json.$typeName !== ID.$typeName) { throw new Error("not a WithTwoGenerics json object") };
|
|
61
|
+
|
|
62
|
+
return ID.fromJSONField( json, ) }
|
|
63
|
+
|
|
64
|
+
static fromSuiParsedData( content: SuiParsedData ): ID { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isID(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a ID object`); } return ID.fromFieldsWithTypes( content ); }
|
|
65
|
+
|
|
66
|
+
static async fetch( client: SuiClient, id: string ): Promise<ID> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching ID object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isID(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a ID object`); }
|
|
67
|
+
return ID.fromBcs( fromB64(res.data.bcs.bcsBytes) ); }
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ============================== UID =============================== */
|
|
72
|
+
|
|
73
|
+
export function isUID(type: string): boolean { type = compressSuiType(type); return type === "0x2::object::UID"; }
|
|
74
|
+
|
|
75
|
+
export interface UIDFields { id: ToField<ID> }
|
|
76
|
+
|
|
77
|
+
export type UIDReified = Reified< UID, UIDFields >;
|
|
78
|
+
|
|
79
|
+
export class UID implements StructClass { static readonly $typeName = "0x2::object::UID"; static readonly $numTypeParams = 0;
|
|
80
|
+
|
|
81
|
+
readonly $typeName = UID.$typeName;
|
|
82
|
+
|
|
83
|
+
readonly $fullTypeName: "0x2::object::UID";
|
|
84
|
+
|
|
85
|
+
readonly $typeArgs: [];
|
|
86
|
+
|
|
87
|
+
readonly id: ToField<ID>
|
|
88
|
+
|
|
89
|
+
private constructor(typeArgs: [], fields: UIDFields, ) { this.$fullTypeName = composeSuiType( UID.$typeName, ...typeArgs ) as "0x2::object::UID"; this.$typeArgs = typeArgs;
|
|
90
|
+
|
|
91
|
+
this.id = fields.id; }
|
|
92
|
+
|
|
93
|
+
static reified( ): UIDReified { return { typeName: UID.$typeName, fullTypeName: composeSuiType( UID.$typeName, ...[] ) as "0x2::object::UID", typeArgs: [ ] as [], reifiedTypeArgs: [], fromFields: (fields: Record<string, any>) => UID.fromFields( fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => UID.fromFieldsWithTypes( item, ), fromBcs: (data: Uint8Array) => UID.fromBcs( data, ), bcs: UID.bcs, fromJSONField: (field: any) => UID.fromJSONField( field, ), fromJSON: (json: Record<string, any>) => UID.fromJSON( json, ), fromSuiParsedData: (content: SuiParsedData) => UID.fromSuiParsedData( content, ), fetch: async (client: SuiClient, id: string) => UID.fetch( client, id, ), new: ( fields: UIDFields, ) => { return new UID( [], fields ) }, kind: "StructClassReified", } }
|
|
94
|
+
|
|
95
|
+
static get r() { return UID.reified() }
|
|
96
|
+
|
|
97
|
+
static phantom( ): PhantomReified<ToTypeStr<UID>> { return phantom(UID.reified( )); } static get p() { return UID.phantom() }
|
|
98
|
+
|
|
99
|
+
static get bcs() { return bcs.struct("UID", {
|
|
100
|
+
|
|
101
|
+
id: ID.bcs
|
|
102
|
+
|
|
103
|
+
}) };
|
|
104
|
+
|
|
105
|
+
static fromFields( fields: Record<string, any> ): UID { return UID.reified( ).new( { id: decodeFromFields(ID.reified(), fields.id) } ) }
|
|
106
|
+
|
|
107
|
+
static fromFieldsWithTypes( item: FieldsWithTypes ): UID { if (!isUID(item.type)) { throw new Error("not a UID type");
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return UID.reified( ).new( { id: decodeFromFieldsWithTypes(ID.reified(), item.fields.id) } ) }
|
|
112
|
+
|
|
113
|
+
static fromBcs( data: Uint8Array ): UID { return UID.fromFields( UID.bcs.parse(data) ) }
|
|
114
|
+
|
|
115
|
+
toJSONField() { return {
|
|
116
|
+
|
|
117
|
+
id: this.id,
|
|
118
|
+
|
|
119
|
+
} }
|
|
120
|
+
|
|
121
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
122
|
+
|
|
123
|
+
static fromJSONField( field: any ): UID { return UID.reified( ).new( { id: decodeFromJSONField(ID.reified(), field.id) } ) }
|
|
124
|
+
|
|
125
|
+
static fromJSON( json: Record<string, any> ): UID { if (json.$typeName !== UID.$typeName) { throw new Error("not a WithTwoGenerics json object") };
|
|
126
|
+
|
|
127
|
+
return UID.fromJSONField( json, ) }
|
|
128
|
+
|
|
129
|
+
static fromSuiParsedData( content: SuiParsedData ): UID { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isUID(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a UID object`); } return UID.fromFieldsWithTypes( content ); }
|
|
130
|
+
|
|
131
|
+
static async fetch( client: SuiClient, id: string ): Promise<UID> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching UID object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isUID(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a UID object`); }
|
|
132
|
+
return UID.fromBcs( fromB64(res.data.bcs.bcsBytes) ); }
|
|
133
|
+
|
|
134
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {PhantomReified, Reified, StructClass, ToField, ToTypeStr, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom} from "../../../../_framework/reified";
|
|
2
|
+
import {FieldsWithTypes, composeSuiType, compressSuiType} from "../../../../_framework/util";
|
|
3
|
+
import {UID} from "../object/structs";
|
|
4
|
+
import {bcs, fromB64} from "@mysten/bcs";
|
|
5
|
+
import {SuiClient, SuiParsedData} from "@mysten/sui.js/client";
|
|
6
|
+
|
|
7
|
+
/* ============================== ObjectBag =============================== */
|
|
8
|
+
|
|
9
|
+
export function isObjectBag(type: string): boolean { type = compressSuiType(type); return type === "0x2::object_bag::ObjectBag"; }
|
|
10
|
+
|
|
11
|
+
export interface ObjectBagFields { id: ToField<UID>; size: ToField<"u64"> }
|
|
12
|
+
|
|
13
|
+
export type ObjectBagReified = Reified< ObjectBag, ObjectBagFields >;
|
|
14
|
+
|
|
15
|
+
export class ObjectBag implements StructClass { static readonly $typeName = "0x2::object_bag::ObjectBag"; static readonly $numTypeParams = 0;
|
|
16
|
+
|
|
17
|
+
readonly $typeName = ObjectBag.$typeName;
|
|
18
|
+
|
|
19
|
+
readonly $fullTypeName: "0x2::object_bag::ObjectBag";
|
|
20
|
+
|
|
21
|
+
readonly $typeArgs: [];
|
|
22
|
+
|
|
23
|
+
readonly id: ToField<UID>; readonly size: ToField<"u64">
|
|
24
|
+
|
|
25
|
+
private constructor(typeArgs: [], fields: ObjectBagFields, ) { this.$fullTypeName = composeSuiType( ObjectBag.$typeName, ...typeArgs ) as "0x2::object_bag::ObjectBag"; this.$typeArgs = typeArgs;
|
|
26
|
+
|
|
27
|
+
this.id = fields.id;; this.size = fields.size; }
|
|
28
|
+
|
|
29
|
+
static reified( ): ObjectBagReified { return { typeName: ObjectBag.$typeName, fullTypeName: composeSuiType( ObjectBag.$typeName, ...[] ) as "0x2::object_bag::ObjectBag", typeArgs: [ ] as [], reifiedTypeArgs: [], fromFields: (fields: Record<string, any>) => ObjectBag.fromFields( fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => ObjectBag.fromFieldsWithTypes( item, ), fromBcs: (data: Uint8Array) => ObjectBag.fromBcs( data, ), bcs: ObjectBag.bcs, fromJSONField: (field: any) => ObjectBag.fromJSONField( field, ), fromJSON: (json: Record<string, any>) => ObjectBag.fromJSON( json, ), fromSuiParsedData: (content: SuiParsedData) => ObjectBag.fromSuiParsedData( content, ), fetch: async (client: SuiClient, id: string) => ObjectBag.fetch( client, id, ), new: ( fields: ObjectBagFields, ) => { return new ObjectBag( [], fields ) }, kind: "StructClassReified", } }
|
|
30
|
+
|
|
31
|
+
static get r() { return ObjectBag.reified() }
|
|
32
|
+
|
|
33
|
+
static phantom( ): PhantomReified<ToTypeStr<ObjectBag>> { return phantom(ObjectBag.reified( )); } static get p() { return ObjectBag.phantom() }
|
|
34
|
+
|
|
35
|
+
static get bcs() { return bcs.struct("ObjectBag", {
|
|
36
|
+
|
|
37
|
+
id: UID.bcs, size: bcs.u64()
|
|
38
|
+
|
|
39
|
+
}) };
|
|
40
|
+
|
|
41
|
+
static fromFields( fields: Record<string, any> ): ObjectBag { return ObjectBag.reified( ).new( { id: decodeFromFields(UID.reified(), fields.id), size: decodeFromFields("u64", fields.size) } ) }
|
|
42
|
+
|
|
43
|
+
static fromFieldsWithTypes( item: FieldsWithTypes ): ObjectBag { if (!isObjectBag(item.type)) { throw new Error("not a ObjectBag type");
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return ObjectBag.reified( ).new( { id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id), size: decodeFromFieldsWithTypes("u64", item.fields.size) } ) }
|
|
48
|
+
|
|
49
|
+
static fromBcs( data: Uint8Array ): ObjectBag { return ObjectBag.fromFields( ObjectBag.bcs.parse(data) ) }
|
|
50
|
+
|
|
51
|
+
toJSONField() { return {
|
|
52
|
+
|
|
53
|
+
id: this.id,size: this.size.toString(),
|
|
54
|
+
|
|
55
|
+
} }
|
|
56
|
+
|
|
57
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
58
|
+
|
|
59
|
+
static fromJSONField( field: any ): ObjectBag { return ObjectBag.reified( ).new( { id: decodeFromJSONField(UID.reified(), field.id), size: decodeFromJSONField("u64", field.size) } ) }
|
|
60
|
+
|
|
61
|
+
static fromJSON( json: Record<string, any> ): ObjectBag { if (json.$typeName !== ObjectBag.$typeName) { throw new Error("not a WithTwoGenerics json object") };
|
|
62
|
+
|
|
63
|
+
return ObjectBag.fromJSONField( json, ) }
|
|
64
|
+
|
|
65
|
+
static fromSuiParsedData( content: SuiParsedData ): ObjectBag { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isObjectBag(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a ObjectBag object`); } return ObjectBag.fromFieldsWithTypes( content ); }
|
|
66
|
+
|
|
67
|
+
static async fetch( client: SuiClient, id: string ): Promise<ObjectBag> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching ObjectBag object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isObjectBag(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a ObjectBag object`); }
|
|
68
|
+
return ObjectBag.fromBcs( fromB64(res.data.bcs.bcsBytes) ); }
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {PhantomReified, PhantomToTypeStr, PhantomTypeArgument, Reified, StructClass, ToField, ToPhantomTypeArgument, ToTypeStr, assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom} from "../../../../_framework/reified";
|
|
2
|
+
import {FieldsWithTypes, composeSuiType, compressSuiType} from "../../../../_framework/util";
|
|
3
|
+
import {UID} from "../object/structs";
|
|
4
|
+
import {bcs, fromB64} from "@mysten/bcs";
|
|
5
|
+
import {SuiClient, SuiParsedData} from "@mysten/sui.js/client";
|
|
6
|
+
|
|
7
|
+
/* ============================== ObjectTable =============================== */
|
|
8
|
+
|
|
9
|
+
export function isObjectTable(type: string): boolean { type = compressSuiType(type); return type.startsWith("0x2::object_table::ObjectTable<"); }
|
|
10
|
+
|
|
11
|
+
export interface ObjectTableFields<K extends PhantomTypeArgument, V extends PhantomTypeArgument> { id: ToField<UID>; size: ToField<"u64"> }
|
|
12
|
+
|
|
13
|
+
export type ObjectTableReified<K extends PhantomTypeArgument, V extends PhantomTypeArgument> = Reified< ObjectTable<K, V>, ObjectTableFields<K, V> >;
|
|
14
|
+
|
|
15
|
+
export class ObjectTable<K extends PhantomTypeArgument, V extends PhantomTypeArgument> implements StructClass { static readonly $typeName = "0x2::object_table::ObjectTable"; static readonly $numTypeParams = 2;
|
|
16
|
+
|
|
17
|
+
readonly $typeName = ObjectTable.$typeName;
|
|
18
|
+
|
|
19
|
+
readonly $fullTypeName: `0x2::object_table::ObjectTable<${PhantomToTypeStr<K>}, ${PhantomToTypeStr<V>}>`;
|
|
20
|
+
|
|
21
|
+
readonly $typeArgs: [PhantomToTypeStr<K>, PhantomToTypeStr<V>];
|
|
22
|
+
|
|
23
|
+
readonly id: ToField<UID>; readonly size: ToField<"u64">
|
|
24
|
+
|
|
25
|
+
private constructor(typeArgs: [PhantomToTypeStr<K>, PhantomToTypeStr<V>], fields: ObjectTableFields<K, V>, ) { this.$fullTypeName = composeSuiType( ObjectTable.$typeName, ...typeArgs ) as `0x2::object_table::ObjectTable<${PhantomToTypeStr<K>}, ${PhantomToTypeStr<V>}>`; this.$typeArgs = typeArgs;
|
|
26
|
+
|
|
27
|
+
this.id = fields.id;; this.size = fields.size; }
|
|
28
|
+
|
|
29
|
+
static reified<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( K: K, V: V ): ObjectTableReified<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>> { return { typeName: ObjectTable.$typeName, fullTypeName: composeSuiType( ObjectTable.$typeName, ...[extractType(K), extractType(V)] ) as `0x2::object_table::ObjectTable<${PhantomToTypeStr<ToPhantomTypeArgument<K>>}, ${PhantomToTypeStr<ToPhantomTypeArgument<V>>}>`, typeArgs: [ extractType(K), extractType(V) ] as [PhantomToTypeStr<ToPhantomTypeArgument<K>>, PhantomToTypeStr<ToPhantomTypeArgument<V>>], reifiedTypeArgs: [K, V], fromFields: (fields: Record<string, any>) => ObjectTable.fromFields( [K, V], fields, ), fromFieldsWithTypes: (item: FieldsWithTypes) => ObjectTable.fromFieldsWithTypes( [K, V], item, ), fromBcs: (data: Uint8Array) => ObjectTable.fromBcs( [K, V], data, ), bcs: ObjectTable.bcs, fromJSONField: (field: any) => ObjectTable.fromJSONField( [K, V], field, ), fromJSON: (json: Record<string, any>) => ObjectTable.fromJSON( [K, V], json, ), fromSuiParsedData: (content: SuiParsedData) => ObjectTable.fromSuiParsedData( [K, V], content, ), fetch: async (client: SuiClient, id: string) => ObjectTable.fetch( client, [K, V], id, ), new: ( fields: ObjectTableFields<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>, ) => { return new ObjectTable( [extractType(K), extractType(V)], fields ) }, kind: "StructClassReified", } }
|
|
30
|
+
|
|
31
|
+
static get r() { return ObjectTable.reified }
|
|
32
|
+
|
|
33
|
+
static phantom<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( K: K, V: V ): PhantomReified<ToTypeStr<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>>> { return phantom(ObjectTable.reified( K, V )); } static get p() { return ObjectTable.phantom }
|
|
34
|
+
|
|
35
|
+
static get bcs() { return bcs.struct("ObjectTable", {
|
|
36
|
+
|
|
37
|
+
id: UID.bcs, size: bcs.u64()
|
|
38
|
+
|
|
39
|
+
}) };
|
|
40
|
+
|
|
41
|
+
static fromFields<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], fields: Record<string, any> ): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>> { return ObjectTable.reified( typeArgs[0], typeArgs[1], ).new( { id: decodeFromFields(UID.reified(), fields.id), size: decodeFromFields("u64", fields.size) } ) }
|
|
42
|
+
|
|
43
|
+
static fromFieldsWithTypes<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], item: FieldsWithTypes ): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>> { if (!isObjectTable(item.type)) { throw new Error("not a ObjectTable type");
|
|
44
|
+
|
|
45
|
+
} assertFieldsWithTypesArgsMatch(item, typeArgs);
|
|
46
|
+
|
|
47
|
+
return ObjectTable.reified( typeArgs[0], typeArgs[1], ).new( { id: decodeFromFieldsWithTypes(UID.reified(), item.fields.id), size: decodeFromFieldsWithTypes("u64", item.fields.size) } ) }
|
|
48
|
+
|
|
49
|
+
static fromBcs<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], data: Uint8Array ): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>> { return ObjectTable.fromFields( typeArgs, ObjectTable.bcs.parse(data) ) }
|
|
50
|
+
|
|
51
|
+
toJSONField() { return {
|
|
52
|
+
|
|
53
|
+
id: this.id,size: this.size.toString(),
|
|
54
|
+
|
|
55
|
+
} }
|
|
56
|
+
|
|
57
|
+
toJSON() { return { $typeName: this.$typeName, $typeArgs: this.$typeArgs, ...this.toJSONField() } }
|
|
58
|
+
|
|
59
|
+
static fromJSONField<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], field: any ): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>> { return ObjectTable.reified( typeArgs[0], typeArgs[1], ).new( { id: decodeFromJSONField(UID.reified(), field.id), size: decodeFromJSONField("u64", field.size) } ) }
|
|
60
|
+
|
|
61
|
+
static fromJSON<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], json: Record<string, any> ): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>> { if (json.$typeName !== ObjectTable.$typeName) { throw new Error("not a WithTwoGenerics json object") }; assertReifiedTypeArgsMatch( composeSuiType(ObjectTable.$typeName, ...typeArgs.map(extractType)), json.$typeArgs, typeArgs, )
|
|
62
|
+
|
|
63
|
+
return ObjectTable.fromJSONField( typeArgs, json, ) }
|
|
64
|
+
|
|
65
|
+
static fromSuiParsedData<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( typeArgs: [K, V], content: SuiParsedData ): ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>> { if (content.dataType !== "moveObject") { throw new Error("not an object"); } if (!isObjectTable(content.type)) { throw new Error(`object at ${(content.fields as any).id} is not a ObjectTable object`); } return ObjectTable.fromFieldsWithTypes( typeArgs, content ); }
|
|
66
|
+
|
|
67
|
+
static async fetch<K extends PhantomReified<PhantomTypeArgument>, V extends PhantomReified<PhantomTypeArgument>>( client: SuiClient, typeArgs: [K, V], id: string ): Promise<ObjectTable<ToPhantomTypeArgument<K>, ToPhantomTypeArgument<V>>> { const res = await client.getObject({ id, options: { showBcs: true, }, }); if (res.error) { throw new Error(`error fetching ObjectTable object at id ${id}: ${res.error.code}`); } if (res.data?.bcs?.dataType !== "moveObject" || !isObjectTable(res.data.bcs.type)) { throw new Error(`object at id ${id} is not a ObjectTable object`); }
|
|
68
|
+
return ObjectTable.fromBcs( typeArgs, fromB64(res.data.bcs.bcsBytes) ); }
|
|
69
|
+
|
|
70
|
+
}
|