@aptos-labs/ts-sdk 0.0.6 → 0.0.8
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 +26 -5
- package/dist/browser/index.d.ts +1097 -519
- package/dist/browser/index.global.js +49 -28
- package/dist/browser/index.global.js.map +1 -1
- package/dist/common/index.d.ts +1097 -519
- package/dist/common/index.js +48 -27
- package/dist/common/index.js.map +1 -1
- package/dist/esm/api/account.d.mts +72 -47
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +214 -18
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +9 -0
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +2 -2
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +6 -5
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +24 -21
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +12 -14
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +4 -4
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +71 -30
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +12 -5
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +5 -0
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/staking.d.mts +13 -9
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +36 -2
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +54 -0
- package/dist/esm/api/transactionSubmission/build.mjs +2 -0
- package/dist/esm/api/transactionSubmission/sign.d.mts +51 -0
- package/dist/esm/api/transactionSubmission/sign.mjs +2 -0
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/simulate.d.mts +54 -0
- package/dist/esm/api/transactionSubmission/simulate.mjs +2 -0
- package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/submit.d.mts +52 -0
- package/dist/esm/api/transactionSubmission/submit.mjs +2 -0
- package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission.d.mts +25 -54
- package/dist/esm/api/transactionSubmission.mjs +1 -1
- package/dist/esm/api/utils.d.mts +21 -0
- package/dist/esm/api/utils.mjs +2 -0
- package/dist/esm/api/utils.mjs.map +1 -0
- package/dist/esm/bcs/deserializer.d.mts +4 -4
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +4 -4
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-UAAI3NCA.mjs → chunk-2SAKPC5Q.mjs} +2 -2
- package/dist/esm/chunk-2YQXX64E.mjs +2 -0
- package/dist/esm/chunk-2YQXX64E.mjs.map +1 -0
- package/dist/esm/chunk-3F5WV6US.mjs +2 -0
- package/dist/esm/chunk-3F5WV6US.mjs.map +1 -0
- package/dist/esm/{chunk-ARVSIDVB.mjs → chunk-3RMXGSHK.mjs} +2 -2
- package/dist/esm/chunk-3RMXGSHK.mjs.map +1 -0
- package/dist/esm/{chunk-4ADA5BE7.mjs → chunk-53DS6NBQ.mjs} +2 -2
- package/dist/esm/chunk-5CUNY7X2.mjs +2 -0
- package/dist/esm/chunk-5CUNY7X2.mjs.map +1 -0
- package/dist/esm/{chunk-QWVR4RCV.mjs → chunk-5OPOJ43H.mjs} +2 -2
- package/dist/esm/{chunk-V45RFKH7.mjs → chunk-5UY5OKXR.mjs} +2 -2
- package/dist/esm/chunk-5UY5OKXR.mjs.map +1 -0
- package/dist/esm/chunk-5ZVCSKFX.mjs +2 -0
- package/dist/esm/chunk-5ZVCSKFX.mjs.map +1 -0
- package/dist/esm/{chunk-HVADSXTB.mjs → chunk-73VWOS4Z.mjs} +2 -2
- package/dist/esm/chunk-ALFESCPU.mjs +2 -0
- package/dist/esm/chunk-ALFESCPU.mjs.map +1 -0
- package/dist/esm/chunk-APSQ4M23.mjs +2 -0
- package/dist/esm/chunk-APSQ4M23.mjs.map +1 -0
- package/dist/esm/{chunk-U25N2VWA.mjs → chunk-AZUWHKN5.mjs} +2 -2
- package/dist/esm/{chunk-WX43AJTD.mjs → chunk-BQSE5HHW.mjs} +45 -24
- package/dist/esm/chunk-BQSE5HHW.mjs.map +1 -0
- package/dist/esm/chunk-CCXMVVXD.mjs +2 -0
- package/dist/esm/chunk-CCXMVVXD.mjs.map +1 -0
- package/dist/esm/{chunk-JZNLZMUC.mjs → chunk-CJPCOS4R.mjs} +2 -2
- package/dist/esm/{chunk-S36IYY6K.mjs → chunk-CL5B2QNS.mjs} +2 -2
- package/dist/esm/chunk-CLJLQXFQ.mjs +2 -0
- package/dist/esm/chunk-CLJLQXFQ.mjs.map +1 -0
- package/dist/esm/{chunk-EWTHPMEE.mjs → chunk-CU2DINU4.mjs} +2 -2
- package/dist/esm/chunk-EFRFDFS4.mjs +2 -0
- package/dist/esm/chunk-EFRFDFS4.mjs.map +1 -0
- package/dist/esm/chunk-EOC4UI5B.mjs +2 -0
- package/dist/esm/{chunk-KC64ESLO.mjs.map → chunk-EOC4UI5B.mjs.map} +1 -1
- package/dist/esm/{chunk-HA6JD5R6.mjs → chunk-F6K26WV5.mjs} +2 -2
- package/dist/esm/{chunk-HA6JD5R6.mjs.map → chunk-F6K26WV5.mjs.map} +1 -1
- package/dist/esm/chunk-F7EWDYTE.mjs +2 -0
- package/dist/esm/chunk-F7EWDYTE.mjs.map +1 -0
- package/dist/esm/{chunk-44MGBJ73.mjs → chunk-FZ56IS3E.mjs} +2 -2
- package/dist/esm/chunk-G36AY4R7.mjs +2 -0
- package/dist/esm/chunk-G36AY4R7.mjs.map +1 -0
- package/dist/esm/chunk-GEZSEAL5.mjs +2 -0
- package/dist/esm/chunk-GEZSEAL5.mjs.map +1 -0
- package/dist/esm/chunk-GIZLK7M7.mjs +2 -0
- package/dist/esm/chunk-GIZLK7M7.mjs.map +1 -0
- package/dist/esm/chunk-GMG4VR3K.mjs +2 -0
- package/dist/esm/chunk-GMG4VR3K.mjs.map +1 -0
- package/dist/esm/{chunk-U6SZNNVL.mjs → chunk-GXPGRCSW.mjs} +2 -2
- package/dist/esm/{chunk-U6SZNNVL.mjs.map → chunk-GXPGRCSW.mjs.map} +1 -1
- package/dist/esm/{chunk-GEFQFRL3.mjs → chunk-HC5VMNXA.mjs} +2 -2
- package/dist/esm/chunk-HTI5LEST.mjs +2 -0
- package/dist/esm/chunk-HTI5LEST.mjs.map +1 -0
- package/dist/esm/chunk-IELTCGLP.mjs +2 -0
- package/dist/esm/chunk-IELTCGLP.mjs.map +1 -0
- package/dist/esm/chunk-IHYTP2EW.mjs +1 -0
- package/dist/esm/chunk-IHYTP2EW.mjs.map +1 -0
- package/dist/esm/chunk-JI2BBZ2W.mjs +2 -0
- package/dist/esm/{chunk-3JVGSFHP.mjs.map → chunk-JI2BBZ2W.mjs.map} +1 -1
- package/dist/esm/chunk-KKER5KL4.mjs +2 -0
- package/dist/esm/chunk-KKER5KL4.mjs.map +1 -0
- package/dist/esm/chunk-KNMWDGP4.mjs +2 -0
- package/dist/esm/chunk-KNMWDGP4.mjs.map +1 -0
- package/dist/esm/{chunk-YYRDFZE6.mjs → chunk-KZSJ5MFF.mjs} +2 -2
- package/dist/esm/{chunk-YYRDFZE6.mjs.map → chunk-KZSJ5MFF.mjs.map} +1 -1
- package/dist/esm/chunk-MWAMLQ25.mjs +2 -0
- package/dist/esm/chunk-MWAMLQ25.mjs.map +1 -0
- package/dist/esm/chunk-NL72WE3E.mjs +2 -0
- package/dist/esm/{chunk-TIH6ARYP.mjs.map → chunk-NL72WE3E.mjs.map} +1 -1
- package/dist/esm/chunk-NZSGGL25.mjs +2 -0
- package/dist/esm/chunk-NZSGGL25.mjs.map +1 -0
- package/dist/esm/chunk-OBOOY2QD.mjs +2 -0
- package/dist/esm/chunk-OBOOY2QD.mjs.map +1 -0
- package/dist/esm/chunk-OT2UDMUU.mjs +2 -0
- package/dist/esm/chunk-OT2UDMUU.mjs.map +1 -0
- package/dist/esm/chunk-OZZDXS26.mjs +2 -0
- package/dist/esm/chunk-OZZDXS26.mjs.map +1 -0
- package/dist/esm/chunk-P5747ZYC.mjs +2 -0
- package/dist/esm/chunk-P5747ZYC.mjs.map +1 -0
- package/dist/esm/{chunk-BPYLPPEQ.mjs → chunk-PL2VA73L.mjs} +2 -2
- package/dist/esm/chunk-PXTMLJKO.mjs +2 -0
- package/dist/esm/{chunk-JDS7K2WI.mjs → chunk-QCBIJCU4.mjs} +2 -2
- package/dist/esm/chunk-QEXAMHPU.mjs +2 -0
- package/dist/esm/chunk-QEXAMHPU.mjs.map +1 -0
- package/dist/esm/{chunk-KQXRH5FK.mjs → chunk-QNTV5NMH.mjs} +2 -2
- package/dist/esm/{chunk-EQ5BEDJ7.mjs → chunk-RCM3K5JL.mjs} +2 -2
- package/dist/esm/chunk-RLG3WOTH.mjs +2 -0
- package/dist/esm/chunk-RLG3WOTH.mjs.map +1 -0
- package/dist/esm/chunk-SDPICQ5B.mjs +2 -0
- package/dist/esm/{chunk-FYIFBLHU.mjs.map → chunk-SDPICQ5B.mjs.map} +1 -1
- package/dist/esm/chunk-SGTFMSOG.mjs +2 -0
- package/dist/esm/chunk-SGTFMSOG.mjs.map +1 -0
- package/dist/esm/chunk-SO6EE5DX.mjs +2 -0
- package/dist/esm/chunk-SO6EE5DX.mjs.map +1 -0
- package/dist/esm/chunk-SRGPSANH.mjs +2 -0
- package/dist/esm/chunk-SRGPSANH.mjs.map +1 -0
- package/dist/esm/{chunk-UPLWWSB4.mjs → chunk-SSJQOXEP.mjs} +2 -2
- package/dist/esm/chunk-TZ623H2V.mjs +2 -0
- package/dist/esm/chunk-TZ623H2V.mjs.map +1 -0
- package/dist/esm/chunk-U6Z4FNB7.mjs +2 -0
- package/dist/esm/chunk-U6Z4FNB7.mjs.map +1 -0
- package/dist/esm/{chunk-GTC7WHMV.mjs → chunk-UDMADMVO.mjs} +1 -1
- package/dist/esm/{chunk-GTC7WHMV.mjs.map → chunk-UDMADMVO.mjs.map} +1 -1
- package/dist/esm/chunk-UIVJXLRM.mjs +1 -0
- package/dist/esm/chunk-UIVJXLRM.mjs.map +1 -0
- package/dist/esm/chunk-UKSA4H2O.mjs +2 -0
- package/dist/esm/chunk-UKSA4H2O.mjs.map +1 -0
- package/dist/esm/chunk-UW6HQ643.mjs +2 -0
- package/dist/esm/chunk-UW6HQ643.mjs.map +1 -0
- package/dist/esm/chunk-UWXDXOFK.mjs +2 -0
- package/dist/esm/chunk-UWXDXOFK.mjs.map +1 -0
- package/dist/esm/chunk-VQ7LYNMD.mjs +2 -0
- package/dist/esm/chunk-VQ7LYNMD.mjs.map +1 -0
- package/dist/esm/{chunk-U3LO2FSJ.mjs → chunk-WTGGCH34.mjs} +2 -2
- package/dist/esm/{chunk-X32O46IB.mjs → chunk-XITLXPBK.mjs} +2 -2
- package/dist/esm/chunk-XMUUI6HG.mjs +2 -0
- package/dist/esm/{chunk-R3KWVOFG.mjs.map → chunk-XMUUI6HG.mjs.map} +1 -1
- package/dist/esm/chunk-XX2Z26FH.mjs +2 -0
- package/dist/esm/chunk-XX2Z26FH.mjs.map +1 -0
- package/dist/esm/chunk-Y6PVFMBS.mjs +2 -0
- package/dist/esm/chunk-Y6PVFMBS.mjs.map +1 -0
- package/dist/esm/{chunk-VWVEDCBM.mjs → chunk-YN6UIVFB.mjs} +2 -2
- package/dist/esm/chunk-ZFK7QD3B.mjs +2 -0
- package/dist/esm/chunk-ZFK7QD3B.mjs.map +1 -0
- package/dist/esm/chunk-ZJUDDSWN.mjs +2 -0
- package/dist/esm/chunk-ZJUDDSWN.mjs.map +1 -0
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +9 -9
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/anyPublicKey.d.mts +5 -0
- package/dist/esm/core/crypto/anyPublicKey.mjs +1 -1
- package/dist/esm/core/crypto/anySignature.mjs +1 -1
- package/dist/esm/core/crypto/asymmetricCrypto.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +3 -0
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +2 -2
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +2 -0
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +3 -0
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/index.d.mts +2 -2
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +17 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +20 -33
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +78 -14
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +6 -5
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +12 -21
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +5 -12
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +2 -2
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +40 -22
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +9 -5
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +4 -6
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +12 -4
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +29 -41
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +5 -0
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +1 -0
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +1 -0
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +5 -4
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +1 -0
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -0
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +89 -0
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +2 -0
- package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -0
- package/dist/esm/transactions/management/asyncQueue.d.mts +58 -0
- package/dist/esm/transactions/management/asyncQueue.mjs +2 -0
- package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -0
- package/dist/esm/transactions/management/index.d.mts +36 -0
- package/dist/esm/transactions/management/index.mjs +2 -0
- package/dist/esm/transactions/management/index.mjs.map +1 -0
- package/dist/esm/transactions/management/transactionWorker.d.mts +135 -0
- package/dist/esm/transactions/management/transactionWorker.mjs +2 -0
- package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +3 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +4 -3
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +3 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +6 -8
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +18 -43
- package/dist/esm/types/generated/operations.d.mts +30 -4
- package/dist/esm/types/generated/queries.d.mts +8 -5
- package/dist/esm/types/generated/queries.mjs +1 -1
- package/dist/esm/types/index.d.mts +27 -9
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/indexer.d.mts +3 -2
- package/dist/esm/utils/const.d.mts +18 -1
- package/dist/esm/utils/const.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/src/api/account.ts +150 -53
- package/src/api/ans.ts +252 -16
- package/src/api/aptos.ts +20 -0
- package/src/api/aptosConfig.ts +2 -2
- package/src/api/coin.ts +4 -8
- package/src/api/digitalAsset.ts +75 -25
- package/src/api/event.ts +28 -17
- package/src/api/faucet.ts +12 -9
- package/src/api/fungibleAsset.ts +76 -35
- package/src/api/general.ts +19 -3
- package/src/api/staking.ts +30 -11
- package/src/api/transaction.ts +16 -1
- package/src/api/transactionSubmission/build.ts +42 -0
- package/src/api/transactionSubmission/sign.ts +44 -0
- package/src/api/transactionSubmission/simulate.ts +56 -0
- package/src/api/transactionSubmission/submit.ts +53 -0
- package/src/api/transactionSubmission.ts +31 -128
- package/src/api/utils.ts +37 -0
- package/src/bcs/deserializer.ts +4 -4
- package/src/bcs/serializer.ts +4 -4
- package/src/client/core.ts +6 -4
- package/src/client/get.ts +7 -6
- package/src/core/accountAddress.ts +20 -22
- package/src/core/crypto/anyPublicKey.ts +12 -0
- package/src/core/crypto/ed25519.ts +13 -0
- package/src/core/crypto/index.ts +2 -0
- package/src/core/crypto/secp256k1.ts +12 -0
- package/src/core/hex.ts +5 -7
- package/src/index.ts +1 -0
- package/src/internal/account.ts +56 -50
- package/src/internal/ans.ts +423 -24
- package/src/internal/coin.ts +6 -8
- package/src/internal/digitalAsset.ts +15 -25
- package/src/internal/event.ts +7 -14
- package/src/internal/faucet.ts +10 -6
- package/src/internal/fungibleAsset.ts +36 -18
- package/src/internal/general.ts +30 -3
- package/src/internal/queries/ansTokenFragment.graphql +9 -0
- package/src/internal/queries/getNames.graphql +11 -0
- package/src/internal/queries/getNumberOfDelegatorsQuery.graphql +5 -5
- package/src/internal/queries/getProcessorStatus.graphql +2 -2
- package/src/internal/staking.ts +12 -14
- package/src/internal/transaction.ts +23 -26
- package/src/internal/transactionSubmission.ts +63 -25
- package/src/transactions/authenticator/account.ts +16 -0
- package/src/transactions/instances/moduleId.ts +1 -1
- package/src/transactions/management/accountSequenceNumber.ts +186 -0
- package/src/transactions/management/asyncQueue.ts +107 -0
- package/src/transactions/management/index.ts +2 -0
- package/src/transactions/management/transactionWorker.ts +275 -0
- package/src/transactions/transactionBuilder/helpers.ts +28 -1
- package/src/transactions/transactionBuilder/remoteAbi.ts +35 -28
- package/src/transactions/transactionBuilder/transactionBuilder.ts +46 -67
- package/src/transactions/typeTag/parser.ts +1 -1
- package/src/transactions/types.ts +16 -47
- package/src/types/generated/operations.ts +33 -2
- package/src/types/generated/queries.ts +38 -4
- package/src/types/index.ts +67 -11
- package/src/types/indexer.ts +3 -0
- package/src/utils/const.ts +18 -0
- package/src/version.ts +1 -1
- package/dist/esm/chunk-2W744GUN.mjs +0 -2
- package/dist/esm/chunk-2W744GUN.mjs.map +0 -1
- package/dist/esm/chunk-3JVGSFHP.mjs +0 -2
- package/dist/esm/chunk-4RVIA63I.mjs +0 -2
- package/dist/esm/chunk-4RVIA63I.mjs.map +0 -1
- package/dist/esm/chunk-62SCW5NH.mjs +0 -2
- package/dist/esm/chunk-62SCW5NH.mjs.map +0 -1
- package/dist/esm/chunk-7MNEEVXY.mjs +0 -2
- package/dist/esm/chunk-7MNEEVXY.mjs.map +0 -1
- package/dist/esm/chunk-AAIBCWZY.mjs +0 -2
- package/dist/esm/chunk-AAIBCWZY.mjs.map +0 -1
- package/dist/esm/chunk-ARVSIDVB.mjs.map +0 -1
- package/dist/esm/chunk-BFSEVKNA.mjs +0 -2
- package/dist/esm/chunk-BFSEVKNA.mjs.map +0 -1
- package/dist/esm/chunk-BP5ZO7NK.mjs +0 -2
- package/dist/esm/chunk-BP5ZO7NK.mjs.map +0 -1
- package/dist/esm/chunk-BV4OOU5Y.mjs +0 -2
- package/dist/esm/chunk-BV4OOU5Y.mjs.map +0 -1
- package/dist/esm/chunk-BWMNPUTK.mjs +0 -2
- package/dist/esm/chunk-BWMNPUTK.mjs.map +0 -1
- package/dist/esm/chunk-EFIYW4WK.mjs +0 -2
- package/dist/esm/chunk-EGOYLZBU.mjs +0 -2
- package/dist/esm/chunk-EGOYLZBU.mjs.map +0 -1
- package/dist/esm/chunk-EYXHVA6W.mjs +0 -2
- package/dist/esm/chunk-EYXHVA6W.mjs.map +0 -1
- package/dist/esm/chunk-FYIFBLHU.mjs +0 -2
- package/dist/esm/chunk-IG5CHHSI.mjs +0 -2
- package/dist/esm/chunk-IG5CHHSI.mjs.map +0 -1
- package/dist/esm/chunk-IXMB2GOK.mjs +0 -2
- package/dist/esm/chunk-IXMB2GOK.mjs.map +0 -1
- package/dist/esm/chunk-J5ZFOJN2.mjs +0 -2
- package/dist/esm/chunk-J5ZFOJN2.mjs.map +0 -1
- package/dist/esm/chunk-KC64ESLO.mjs +0 -2
- package/dist/esm/chunk-NGCFPQ22.mjs +0 -2
- package/dist/esm/chunk-NGCFPQ22.mjs.map +0 -1
- package/dist/esm/chunk-NTD3H2S4.mjs +0 -2
- package/dist/esm/chunk-NTD3H2S4.mjs.map +0 -1
- package/dist/esm/chunk-NYFVEKF6.mjs +0 -2
- package/dist/esm/chunk-NYFVEKF6.mjs.map +0 -1
- package/dist/esm/chunk-NZIJV4O2.mjs +0 -2
- package/dist/esm/chunk-NZIJV4O2.mjs.map +0 -1
- package/dist/esm/chunk-P32MY5YF.mjs +0 -2
- package/dist/esm/chunk-P32MY5YF.mjs.map +0 -1
- package/dist/esm/chunk-Q6N6QACD.mjs +0 -2
- package/dist/esm/chunk-Q6N6QACD.mjs.map +0 -1
- package/dist/esm/chunk-R26XML3D.mjs +0 -2
- package/dist/esm/chunk-R26XML3D.mjs.map +0 -1
- package/dist/esm/chunk-R3KWVOFG.mjs +0 -2
- package/dist/esm/chunk-RYETO74W.mjs +0 -2
- package/dist/esm/chunk-RYETO74W.mjs.map +0 -1
- package/dist/esm/chunk-TCTZCPQ6.mjs +0 -1
- package/dist/esm/chunk-TIH6ARYP.mjs +0 -2
- package/dist/esm/chunk-TQD4IGUM.mjs +0 -2
- package/dist/esm/chunk-TQD4IGUM.mjs.map +0 -1
- package/dist/esm/chunk-UNQNACJT.mjs +0 -2
- package/dist/esm/chunk-UNQNACJT.mjs.map +0 -1
- package/dist/esm/chunk-V45RFKH7.mjs.map +0 -1
- package/dist/esm/chunk-VMQWW5UT.mjs +0 -2
- package/dist/esm/chunk-VMQWW5UT.mjs.map +0 -1
- package/dist/esm/chunk-VOYW2TZW.mjs +0 -2
- package/dist/esm/chunk-VOYW2TZW.mjs.map +0 -1
- package/dist/esm/chunk-VYAVLUPJ.mjs +0 -2
- package/dist/esm/chunk-VYAVLUPJ.mjs.map +0 -1
- package/dist/esm/chunk-WKY5ENCK.mjs +0 -2
- package/dist/esm/chunk-WKY5ENCK.mjs.map +0 -1
- package/dist/esm/chunk-WX43AJTD.mjs.map +0 -1
- package/dist/esm/chunk-Y5DJPHJT.mjs +0 -2
- package/dist/esm/chunk-Y5DJPHJT.mjs.map +0 -1
- package/dist/esm/chunk-Y7VR7X5W.mjs +0 -2
- package/dist/esm/chunk-Y7VR7X5W.mjs.map +0 -1
- package/dist/esm/chunk-Z2UDRTHA.mjs +0 -2
- package/dist/esm/chunk-Z2UDRTHA.mjs.map +0 -1
- /package/dist/esm/{chunk-TCTZCPQ6.mjs.map → api/transactionSubmission/build.mjs.map} +0 -0
- /package/dist/esm/{chunk-UAAI3NCA.mjs.map → chunk-2SAKPC5Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ADA5BE7.mjs.map → chunk-53DS6NBQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-QWVR4RCV.mjs.map → chunk-5OPOJ43H.mjs.map} +0 -0
- /package/dist/esm/{chunk-HVADSXTB.mjs.map → chunk-73VWOS4Z.mjs.map} +0 -0
- /package/dist/esm/{chunk-U25N2VWA.mjs.map → chunk-AZUWHKN5.mjs.map} +0 -0
- /package/dist/esm/{chunk-JZNLZMUC.mjs.map → chunk-CJPCOS4R.mjs.map} +0 -0
- /package/dist/esm/{chunk-S36IYY6K.mjs.map → chunk-CL5B2QNS.mjs.map} +0 -0
- /package/dist/esm/{chunk-EWTHPMEE.mjs.map → chunk-CU2DINU4.mjs.map} +0 -0
- /package/dist/esm/{chunk-44MGBJ73.mjs.map → chunk-FZ56IS3E.mjs.map} +0 -0
- /package/dist/esm/{chunk-GEFQFRL3.mjs.map → chunk-HC5VMNXA.mjs.map} +0 -0
- /package/dist/esm/{chunk-BPYLPPEQ.mjs.map → chunk-PL2VA73L.mjs.map} +0 -0
- /package/dist/esm/{chunk-EFIYW4WK.mjs.map → chunk-PXTMLJKO.mjs.map} +0 -0
- /package/dist/esm/{chunk-JDS7K2WI.mjs.map → chunk-QCBIJCU4.mjs.map} +0 -0
- /package/dist/esm/{chunk-KQXRH5FK.mjs.map → chunk-QNTV5NMH.mjs.map} +0 -0
- /package/dist/esm/{chunk-EQ5BEDJ7.mjs.map → chunk-RCM3K5JL.mjs.map} +0 -0
- /package/dist/esm/{chunk-UPLWWSB4.mjs.map → chunk-SSJQOXEP.mjs.map} +0 -0
- /package/dist/esm/{chunk-U3LO2FSJ.mjs.map → chunk-WTGGCH34.mjs.map} +0 -0
- /package/dist/esm/{chunk-X32O46IB.mjs.map → chunk-XITLXPBK.mjs.map} +0 -0
- /package/dist/esm/{chunk-VWVEDCBM.mjs.map → chunk-YN6UIVFB.mjs.map} +0 -0
package/src/internal/ans.ts
CHANGED
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
12
|
+
import { Account, AccountAddress, AccountAddressInput } from "../core";
|
|
13
|
+
import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types";
|
|
14
|
+
import { GetANSNameResponse, MoveAddressType, MoveValue, OrderByArg, PaginationArgs, WhereArg } from "../types";
|
|
15
|
+
import { GetNamesQuery } from "../types/generated/operations";
|
|
16
|
+
import { GetNames } from "../types/generated/queries";
|
|
17
|
+
import { CurrentAptosNamesBoolExp } from "../types/generated/types";
|
|
16
18
|
import { Network } from "../utils/apiEndpoints";
|
|
17
|
-
import { view } from "./general";
|
|
19
|
+
import { queryIndexer, view } from "./general";
|
|
18
20
|
import { generateTransaction } from "./transactionSubmission";
|
|
19
21
|
|
|
20
22
|
export const VALIDATION_RULES_DESCRIPTION = [
|
|
@@ -82,8 +84,8 @@ function getRouterAddress(aptosConfig: AptosConfig): string {
|
|
|
82
84
|
return address;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
const Some = <T>(value: T): MoveValue => ({ vec: [value] })
|
|
86
|
-
const None = (): MoveValue => ({ vec: [] })
|
|
87
|
+
const Some = <T>(value: T): MoveValue => ({ vec: [value] });
|
|
88
|
+
const None = (): MoveValue => ({ vec: [] });
|
|
87
89
|
// != here is intentional, we want to check for null and undefined
|
|
88
90
|
// eslint-disable-next-line eqeqeq
|
|
89
91
|
const Option = <T>(value: T | undefined | null): MoveValue => (value != undefined ? Some(value) : None());
|
|
@@ -111,7 +113,7 @@ export async function getOwnerAddress(args: { aptosConfig: AptosConfig; name: st
|
|
|
111
113
|
|
|
112
114
|
const owner = unwrapOption<MoveAddressType>(res[0]);
|
|
113
115
|
|
|
114
|
-
return owner ? AccountAddress.
|
|
116
|
+
return owner ? AccountAddress.from(owner).toString() : undefined;
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
export interface RegisterNameParameters {
|
|
@@ -119,17 +121,17 @@ export interface RegisterNameParameters {
|
|
|
119
121
|
sender: Account;
|
|
120
122
|
name: string;
|
|
121
123
|
expiration:
|
|
122
|
-
| { policy: "domain"; years
|
|
124
|
+
| { policy: "domain"; years?: 1 }
|
|
123
125
|
| { policy: "subdomain:follow-domain" }
|
|
124
|
-
| { policy: "subdomain:independent"; expirationDate:
|
|
126
|
+
| { policy: "subdomain:independent"; expirationDate: number };
|
|
125
127
|
transferable?: boolean;
|
|
126
|
-
toAddress?:
|
|
127
|
-
targetAddress?:
|
|
128
|
+
toAddress?: AccountAddressInput;
|
|
129
|
+
targetAddress?: AccountAddressInput;
|
|
128
130
|
options?: InputGenerateTransactionOptions;
|
|
129
131
|
}
|
|
130
132
|
|
|
131
|
-
export async function registerName(args: RegisterNameParameters): Promise<
|
|
132
|
-
const { aptosConfig, expiration, name, sender, targetAddress, toAddress, options } = args;
|
|
133
|
+
export async function registerName(args: RegisterNameParameters): Promise<SingleSignerTransaction> {
|
|
134
|
+
const { aptosConfig, expiration, name, sender, targetAddress, toAddress, options, transferable } = args;
|
|
133
135
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
134
136
|
const { domainName, subdomainName } = isValidANSName(name);
|
|
135
137
|
|
|
@@ -147,29 +149,426 @@ export async function registerName(args: RegisterNameParameters): Promise<InputS
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
if (expiration.policy === "domain") {
|
|
150
|
-
|
|
152
|
+
const years = expiration.years ?? 1;
|
|
153
|
+
if (years !== 1) {
|
|
151
154
|
throw new Error("For now, names can only be registered for 1 year at a time");
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
const
|
|
157
|
+
const secondsInYear = 31536000;
|
|
158
|
+
const registrationDuration = years * secondsInYear;
|
|
155
159
|
|
|
156
160
|
const transaction = await generateTransaction({
|
|
157
161
|
aptosConfig,
|
|
158
162
|
sender: sender.accountAddress.toString(),
|
|
159
163
|
data: {
|
|
160
164
|
function: `${routerAddress}::router::register_domain`,
|
|
161
|
-
functionArguments: [
|
|
162
|
-
new MoveString(domainName),
|
|
163
|
-
new U64(registrationDuration),
|
|
164
|
-
new MoveOption(targetAddress ? AccountAddress.from(targetAddress) : null),
|
|
165
|
-
new MoveOption(toAddress ? AccountAddress.from(toAddress) : null),
|
|
166
|
-
],
|
|
165
|
+
functionArguments: [domainName, registrationDuration, targetAddress, toAddress],
|
|
167
166
|
},
|
|
168
167
|
options,
|
|
169
168
|
});
|
|
170
169
|
|
|
171
|
-
return transaction
|
|
170
|
+
return transaction;
|
|
172
171
|
}
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
// We are a subdomain
|
|
174
|
+
if (!subdomainName) {
|
|
175
|
+
throw new Error(`${expiration.policy} requires a subdomain to be provided.`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const tldExpiration = await getExpiration({ aptosConfig, name: domainName });
|
|
179
|
+
if (!tldExpiration) {
|
|
180
|
+
throw new Error("The domain does not exist");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const expirationDateInMillisecondsSinceEpoch =
|
|
184
|
+
expiration.policy === "subdomain:independent" ? expiration.expirationDate : tldExpiration;
|
|
185
|
+
|
|
186
|
+
if (expirationDateInMillisecondsSinceEpoch > tldExpiration) {
|
|
187
|
+
throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const transaction = await generateTransaction({
|
|
191
|
+
aptosConfig,
|
|
192
|
+
sender: sender.accountAddress.toString(),
|
|
193
|
+
data: {
|
|
194
|
+
function: `${routerAddress}::router::register_subdomain`,
|
|
195
|
+
functionArguments: [
|
|
196
|
+
domainName,
|
|
197
|
+
subdomainName,
|
|
198
|
+
Math.round(expirationDateInMillisecondsSinceEpoch / 1000),
|
|
199
|
+
expiration.policy === "subdomain:follow-domain" ? 1 : 0,
|
|
200
|
+
!!transferable,
|
|
201
|
+
targetAddress,
|
|
202
|
+
toAddress,
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
options,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return transaction;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export async function getExpiration(args: { aptosConfig: AptosConfig; name: string }): Promise<number | undefined> {
|
|
212
|
+
const { aptosConfig, name } = args;
|
|
213
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
214
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
215
|
+
|
|
216
|
+
try {
|
|
217
|
+
const res = await view({
|
|
218
|
+
aptosConfig,
|
|
219
|
+
payload: {
|
|
220
|
+
function: `${routerAddress}::router::get_expiration`,
|
|
221
|
+
functionArguments: [domainName, Option(subdomainName)],
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// Normalize expiration time from epoch seconds to epoch milliseconds
|
|
226
|
+
return Number(res[0]) * 1000;
|
|
227
|
+
} catch (e) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export async function getPrimaryName(args: {
|
|
233
|
+
aptosConfig: AptosConfig;
|
|
234
|
+
address: AccountAddressInput;
|
|
235
|
+
}): Promise<string | undefined> {
|
|
236
|
+
const { aptosConfig, address } = args;
|
|
237
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
238
|
+
|
|
239
|
+
const res = await view({
|
|
240
|
+
aptosConfig,
|
|
241
|
+
payload: {
|
|
242
|
+
function: `${routerAddress}::router::get_primary_name`,
|
|
243
|
+
functionArguments: [AccountAddress.from(address).toString()],
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
const domainName = unwrapOption<MoveAddressType>(res[1]);
|
|
248
|
+
const subdomainName = unwrapOption<MoveAddressType>(res[0]);
|
|
249
|
+
|
|
250
|
+
if (!domainName) return undefined;
|
|
251
|
+
|
|
252
|
+
return [subdomainName, domainName].filter(Boolean).join(".");
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export async function setPrimaryName(args: {
|
|
256
|
+
aptosConfig: AptosConfig;
|
|
257
|
+
sender: Account;
|
|
258
|
+
name?: string;
|
|
259
|
+
options?: InputGenerateTransactionOptions;
|
|
260
|
+
}): Promise<SingleSignerTransaction> {
|
|
261
|
+
const { aptosConfig, sender, name, options } = args;
|
|
262
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
263
|
+
|
|
264
|
+
if (!name) {
|
|
265
|
+
const transaction = await generateTransaction({
|
|
266
|
+
aptosConfig,
|
|
267
|
+
sender: sender.accountAddress.toString(),
|
|
268
|
+
data: {
|
|
269
|
+
function: `${routerAddress}::router::clear_primary_name`,
|
|
270
|
+
functionArguments: [],
|
|
271
|
+
},
|
|
272
|
+
options,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return transaction;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
279
|
+
|
|
280
|
+
const transaction = await generateTransaction({
|
|
281
|
+
aptosConfig,
|
|
282
|
+
sender: sender.accountAddress.toString(),
|
|
283
|
+
data: {
|
|
284
|
+
function: `${routerAddress}::router::set_primary_name`,
|
|
285
|
+
functionArguments: [domainName, subdomainName],
|
|
286
|
+
},
|
|
287
|
+
options,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return transaction;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export async function getTargetAddress(args: {
|
|
294
|
+
aptosConfig: AptosConfig;
|
|
295
|
+
name: string;
|
|
296
|
+
}): Promise<MoveAddressType | undefined> {
|
|
297
|
+
const { aptosConfig, name } = args;
|
|
298
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
299
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
300
|
+
|
|
301
|
+
const res = await view({
|
|
302
|
+
aptosConfig,
|
|
303
|
+
payload: {
|
|
304
|
+
function: `${routerAddress}::router::get_target_addr`,
|
|
305
|
+
functionArguments: [domainName, Option(subdomainName)],
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const target = unwrapOption<MoveAddressType>(res[0]);
|
|
310
|
+
return target ? AccountAddress.from(target).toString() : undefined;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export async function setTargetAddress(args: {
|
|
314
|
+
aptosConfig: AptosConfig;
|
|
315
|
+
sender: Account;
|
|
316
|
+
name: string;
|
|
317
|
+
address: AccountAddressInput;
|
|
318
|
+
options?: InputGenerateTransactionOptions;
|
|
319
|
+
}): Promise<SingleSignerTransaction> {
|
|
320
|
+
const { aptosConfig, sender, name, address, options } = args;
|
|
321
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
322
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
323
|
+
|
|
324
|
+
const transaction = await generateTransaction({
|
|
325
|
+
aptosConfig,
|
|
326
|
+
sender: sender.accountAddress.toString(),
|
|
327
|
+
data: {
|
|
328
|
+
function: `${routerAddress}::router::set_target_addr`,
|
|
329
|
+
functionArguments: [domainName, subdomainName, address],
|
|
330
|
+
},
|
|
331
|
+
options,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
return transaction;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export async function getName(args: {
|
|
338
|
+
aptosConfig: AptosConfig;
|
|
339
|
+
name: string;
|
|
340
|
+
}): Promise<GetANSNameResponse[0] | undefined> {
|
|
341
|
+
const { aptosConfig, name } = args;
|
|
342
|
+
const { domainName, subdomainName = "" } = isValidANSName(name);
|
|
343
|
+
|
|
344
|
+
const where: CurrentAptosNamesBoolExp = {
|
|
345
|
+
domain: { _eq: domainName },
|
|
346
|
+
subdomain: { _eq: subdomainName },
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
350
|
+
aptosConfig,
|
|
351
|
+
query: {
|
|
352
|
+
query: GetNames,
|
|
353
|
+
variables: {
|
|
354
|
+
where_condition: where,
|
|
355
|
+
limit: 1,
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
originMethod: "getName",
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// Convert the expiration_timestamp from an ISO string to milliseconds since epoch
|
|
362
|
+
let res = data.current_aptos_names[0];
|
|
363
|
+
if (res) {
|
|
364
|
+
res = sanitizeANSName(res);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return res;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
interface QueryNamesOptions {
|
|
371
|
+
options?: PaginationArgs & OrderByArg<GetANSNameResponse[0]> & WhereArg<CurrentAptosNamesBoolExp>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface GetAccountNamesArgs extends QueryNamesOptions {
|
|
375
|
+
accountAddress: AccountAddressInput;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export async function getAccountNames(
|
|
379
|
+
args: { aptosConfig: AptosConfig } & GetAccountNamesArgs,
|
|
380
|
+
): Promise<GetANSNameResponse> {
|
|
381
|
+
const { aptosConfig, options, accountAddress } = args;
|
|
382
|
+
|
|
383
|
+
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
384
|
+
|
|
385
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
386
|
+
aptosConfig,
|
|
387
|
+
originMethod: "getAccountNames",
|
|
388
|
+
query: {
|
|
389
|
+
query: GetNames,
|
|
390
|
+
variables: {
|
|
391
|
+
limit: options?.limit,
|
|
392
|
+
offset: options?.offset,
|
|
393
|
+
order_by: options?.orderBy,
|
|
394
|
+
where_condition: {
|
|
395
|
+
...(args.options?.where ?? {}),
|
|
396
|
+
owner_address: { _eq: accountAddress.toString() },
|
|
397
|
+
expiration_timestamp: { _gte: expirationDate },
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
return data.current_aptos_names.map(sanitizeANSName);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export interface GetAccountDomainsArgs extends QueryNamesOptions {
|
|
407
|
+
accountAddress: AccountAddressInput;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export async function getAccountDomains(
|
|
411
|
+
args: { aptosConfig: AptosConfig } & GetAccountDomainsArgs,
|
|
412
|
+
): Promise<GetANSNameResponse> {
|
|
413
|
+
const { aptosConfig, options, accountAddress } = args;
|
|
414
|
+
|
|
415
|
+
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
416
|
+
|
|
417
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
418
|
+
aptosConfig,
|
|
419
|
+
originMethod: "getAccountDomains",
|
|
420
|
+
query: {
|
|
421
|
+
query: GetNames,
|
|
422
|
+
variables: {
|
|
423
|
+
limit: options?.limit,
|
|
424
|
+
offset: options?.offset,
|
|
425
|
+
order_by: options?.orderBy,
|
|
426
|
+
where_condition: {
|
|
427
|
+
...(args.options?.where ?? {}),
|
|
428
|
+
owner_address: { _eq: accountAddress.toString() },
|
|
429
|
+
expiration_timestamp: { _gte: expirationDate },
|
|
430
|
+
subdomain: { _eq: "" },
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
return data.current_aptos_names.map(sanitizeANSName);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface GetAccountSubdomainsArgs extends QueryNamesOptions {
|
|
440
|
+
accountAddress: AccountAddressInput;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export async function getAccountSubdomains(
|
|
444
|
+
args: { aptosConfig: AptosConfig } & GetAccountSubdomainsArgs,
|
|
445
|
+
): Promise<GetANSNameResponse> {
|
|
446
|
+
const { aptosConfig, options, accountAddress } = args;
|
|
447
|
+
|
|
448
|
+
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
449
|
+
|
|
450
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
451
|
+
aptosConfig,
|
|
452
|
+
originMethod: "getAccountSubdomains",
|
|
453
|
+
query: {
|
|
454
|
+
query: GetNames,
|
|
455
|
+
variables: {
|
|
456
|
+
limit: options?.limit,
|
|
457
|
+
offset: options?.offset,
|
|
458
|
+
order_by: options?.orderBy,
|
|
459
|
+
where_condition: {
|
|
460
|
+
...(args.options?.where ?? {}),
|
|
461
|
+
owner_address: { _eq: accountAddress.toString() },
|
|
462
|
+
expiration_timestamp: { _gte: expirationDate },
|
|
463
|
+
subdomain: { _neq: "" },
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
return data.current_aptos_names.map(sanitizeANSName);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export interface GetDomainSubdomainsArgs extends QueryNamesOptions {
|
|
473
|
+
domain: string;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export async function getDomainSubdomains(
|
|
477
|
+
args: { aptosConfig: AptosConfig } & GetDomainSubdomainsArgs,
|
|
478
|
+
): Promise<GetANSNameResponse> {
|
|
479
|
+
const { aptosConfig, options, domain } = args;
|
|
480
|
+
|
|
481
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
482
|
+
aptosConfig,
|
|
483
|
+
originMethod: "getDomainSubdomains",
|
|
484
|
+
query: {
|
|
485
|
+
query: GetNames,
|
|
486
|
+
variables: {
|
|
487
|
+
limit: options?.limit,
|
|
488
|
+
offset: options?.offset,
|
|
489
|
+
order_by: options?.orderBy,
|
|
490
|
+
where_condition: {
|
|
491
|
+
...(args.options?.where ?? {}),
|
|
492
|
+
domain: { _eq: domain },
|
|
493
|
+
subdomain: { _neq: "" },
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
return data.current_aptos_names.map(sanitizeANSName);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* This function returns the expiration date in which a name is fully expired as
|
|
504
|
+
* defined by the contract. The grace period allows for names to be past
|
|
505
|
+
* expiration for a certain amount of time before they are released to the
|
|
506
|
+
* public. The names will not function as normal, but the owner can renew
|
|
507
|
+
* without others taking ownership of the name. At the time of writing, the
|
|
508
|
+
* contract specified 30 days.
|
|
509
|
+
*
|
|
510
|
+
* @param args.aptosConfig an AptosConfig object
|
|
511
|
+
* @returns
|
|
512
|
+
*/
|
|
513
|
+
async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise<string> {
|
|
514
|
+
const { aptosConfig } = args;
|
|
515
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
516
|
+
|
|
517
|
+
const [gracePeriodInSeconds] = await view<[number]>({
|
|
518
|
+
aptosConfig,
|
|
519
|
+
payload: {
|
|
520
|
+
function: `${routerAddress}::config::reregistration_grace_sec`,
|
|
521
|
+
functionArguments: [],
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
const gracePeriodInDays = gracePeriodInSeconds / 60 / 60 / 24;
|
|
526
|
+
const now = () => new Date();
|
|
527
|
+
return new Date(now().setDate(now().getDate() - gracePeriodInDays)).toISOString();
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export async function renewDomain(args: {
|
|
531
|
+
aptosConfig: AptosConfig;
|
|
532
|
+
sender: Account;
|
|
533
|
+
name: string;
|
|
534
|
+
years?: 1;
|
|
535
|
+
options?: InputGenerateTransactionOptions;
|
|
536
|
+
}): Promise<SingleSignerTransaction> {
|
|
537
|
+
const { aptosConfig, sender, name, years = 1, options } = args;
|
|
538
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
539
|
+
const renewalDuration = years * 31536000;
|
|
540
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
541
|
+
|
|
542
|
+
if (subdomainName) {
|
|
543
|
+
throw new Error("Subdomains cannot be renewed");
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (years !== 1) {
|
|
547
|
+
throw new Error("Currently, only 1 year renewals are supported");
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const transaction = await generateTransaction({
|
|
551
|
+
aptosConfig,
|
|
552
|
+
sender: sender.accountAddress.toString(),
|
|
553
|
+
data: {
|
|
554
|
+
function: `${routerAddress}::router::renew_domain`,
|
|
555
|
+
functionArguments: [domainName, renewalDuration],
|
|
556
|
+
},
|
|
557
|
+
options,
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
return transaction;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* The indexer returns ISO strings for expiration, however the contract works in
|
|
565
|
+
* epoch milliseconds. This function converts the ISO string to epoch
|
|
566
|
+
* milliseconds. In the future, if other properties need sanitization, this can
|
|
567
|
+
* be extended.
|
|
568
|
+
*/
|
|
569
|
+
function sanitizeANSName(name: GetANSNameResponse[0]): GetANSNameResponse[0] {
|
|
570
|
+
return {
|
|
571
|
+
...name,
|
|
572
|
+
expiration_timestamp: new Date(name.expiration_timestamp).valueOf(),
|
|
573
|
+
};
|
|
175
574
|
}
|
package/src/internal/coin.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { AptosConfig } from "../api/aptosConfig";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { InputGenerateTransactionOptions, InputSingleSignerTransaction } from "../transactions/types";
|
|
2
|
+
import { Account, AccountAddressInput } from "../core";
|
|
3
|
+
import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types";
|
|
5
4
|
import { AnyNumber, MoveStructId } from "../types";
|
|
6
5
|
import { APTOS_COIN } from "../utils/const";
|
|
7
6
|
import { generateTransaction } from "./transactionSubmission";
|
|
8
|
-
import { parseTypeTag } from "../transactions/typeTag/parser";
|
|
9
7
|
|
|
10
8
|
export async function transferCoinTransaction(args: {
|
|
11
9
|
aptosConfig: AptosConfig;
|
|
@@ -14,7 +12,7 @@ export async function transferCoinTransaction(args: {
|
|
|
14
12
|
amount: AnyNumber;
|
|
15
13
|
coinType?: MoveStructId;
|
|
16
14
|
options?: InputGenerateTransactionOptions;
|
|
17
|
-
}): Promise<
|
|
15
|
+
}): Promise<SingleSignerTransaction> {
|
|
18
16
|
const { aptosConfig, sender, recipient, amount, coinType, options } = args;
|
|
19
17
|
const coinStructType = coinType ?? APTOS_COIN;
|
|
20
18
|
const transaction = await generateTransaction({
|
|
@@ -22,11 +20,11 @@ export async function transferCoinTransaction(args: {
|
|
|
22
20
|
sender: sender.accountAddress,
|
|
23
21
|
data: {
|
|
24
22
|
function: "0x1::aptos_account::transfer_coins",
|
|
25
|
-
typeArguments: [
|
|
26
|
-
functionArguments: [
|
|
23
|
+
typeArguments: [coinStructType],
|
|
24
|
+
functionArguments: [recipient, amount],
|
|
27
25
|
},
|
|
28
26
|
options,
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
return transaction
|
|
29
|
+
return transaction;
|
|
32
30
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { AptosConfig } from "../api/aptosConfig";
|
|
12
12
|
import { MoveString, MoveVector, Bool, U64, U8 } from "../bcs";
|
|
13
13
|
import { Account, AccountAddress, AccountAddressInput } from "../core";
|
|
14
|
-
import { InputGenerateTransactionOptions,
|
|
14
|
+
import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types";
|
|
15
15
|
import {
|
|
16
16
|
AnyNumber,
|
|
17
17
|
GetCollectionDataResponse,
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
GetOwnedTokensResponse,
|
|
20
20
|
GetTokenActivityResponse,
|
|
21
21
|
GetTokenDataResponse,
|
|
22
|
-
|
|
22
|
+
OrderByArg,
|
|
23
23
|
PaginationArgs,
|
|
24
|
-
|
|
24
|
+
TokenStandardArg,
|
|
25
25
|
} from "../types";
|
|
26
26
|
import {
|
|
27
27
|
GetCollectionDataQuery,
|
|
@@ -55,7 +55,7 @@ export async function mintTokenTransaction(args: {
|
|
|
55
55
|
name: string;
|
|
56
56
|
uri: string;
|
|
57
57
|
options?: InputGenerateTransactionOptions;
|
|
58
|
-
}): Promise<
|
|
58
|
+
}): Promise<SingleSignerTransaction> {
|
|
59
59
|
const { aptosConfig, options, creator } = args;
|
|
60
60
|
const transaction = await generateTransaction({
|
|
61
61
|
aptosConfig,
|
|
@@ -74,7 +74,7 @@ export async function mintTokenTransaction(args: {
|
|
|
74
74
|
},
|
|
75
75
|
options,
|
|
76
76
|
});
|
|
77
|
-
return transaction
|
|
77
|
+
return transaction;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export async function getTokenData(args: {
|
|
@@ -132,10 +132,7 @@ export async function getCurrentTokenOwnership(args: {
|
|
|
132
132
|
export async function getOwnedTokens(args: {
|
|
133
133
|
aptosConfig: AptosConfig;
|
|
134
134
|
ownerAddress: AccountAddressInput;
|
|
135
|
-
options?:
|
|
136
|
-
pagination?: PaginationArgs;
|
|
137
|
-
orderBy?: OrderBy<GetTokenActivityResponse[0]>;
|
|
138
|
-
};
|
|
135
|
+
options?: PaginationArgs & OrderByArg<GetTokenActivityResponse[0]>;
|
|
139
136
|
}): Promise<GetOwnedTokensResponse> {
|
|
140
137
|
const { aptosConfig, ownerAddress, options } = args;
|
|
141
138
|
|
|
@@ -147,8 +144,8 @@ export async function getOwnedTokens(args: {
|
|
|
147
144
|
query: GetCurrentTokenOwnership,
|
|
148
145
|
variables: {
|
|
149
146
|
where_condition: whereCondition,
|
|
150
|
-
offset: options?.
|
|
151
|
-
limit: options?.
|
|
147
|
+
offset: options?.offset,
|
|
148
|
+
limit: options?.limit,
|
|
152
149
|
order_by: options?.orderBy,
|
|
153
150
|
},
|
|
154
151
|
};
|
|
@@ -165,10 +162,7 @@ export async function getOwnedTokens(args: {
|
|
|
165
162
|
export async function getTokenActivity(args: {
|
|
166
163
|
aptosConfig: AptosConfig;
|
|
167
164
|
tokenAddress: AccountAddressInput;
|
|
168
|
-
options?:
|
|
169
|
-
pagination?: PaginationArgs;
|
|
170
|
-
orderBy?: OrderBy<GetTokenActivityResponse[0]>;
|
|
171
|
-
};
|
|
165
|
+
options?: PaginationArgs & OrderByArg<GetTokenActivityResponse[0]>;
|
|
172
166
|
}): Promise<GetTokenActivityResponse> {
|
|
173
167
|
const { aptosConfig, tokenAddress, options } = args;
|
|
174
168
|
|
|
@@ -180,8 +174,8 @@ export async function getTokenActivity(args: {
|
|
|
180
174
|
query: GetTokenActivity,
|
|
181
175
|
variables: {
|
|
182
176
|
where_condition: whereCondition,
|
|
183
|
-
offset: options?.
|
|
184
|
-
limit: options?.
|
|
177
|
+
offset: options?.offset,
|
|
178
|
+
limit: options?.limit,
|
|
185
179
|
order_by: options?.orderBy,
|
|
186
180
|
},
|
|
187
181
|
};
|
|
@@ -219,7 +213,7 @@ export async function createCollectionTransaction(
|
|
|
219
213
|
uri: string;
|
|
220
214
|
options?: InputGenerateTransactionOptions;
|
|
221
215
|
} & CreateCollectionOptions,
|
|
222
|
-
): Promise<
|
|
216
|
+
): Promise<SingleSignerTransaction> {
|
|
223
217
|
const { aptosConfig, options, creator } = args;
|
|
224
218
|
const transaction = await generateTransaction({
|
|
225
219
|
aptosConfig,
|
|
@@ -247,16 +241,14 @@ export async function createCollectionTransaction(
|
|
|
247
241
|
},
|
|
248
242
|
options,
|
|
249
243
|
});
|
|
250
|
-
return transaction
|
|
244
|
+
return transaction;
|
|
251
245
|
}
|
|
252
246
|
|
|
253
247
|
export async function getCollectionData(args: {
|
|
254
248
|
aptosConfig: AptosConfig;
|
|
255
249
|
creatorAddress: AccountAddressInput;
|
|
256
250
|
collectionName: string;
|
|
257
|
-
options?:
|
|
258
|
-
tokenStandard?: TokenStandard;
|
|
259
|
-
};
|
|
251
|
+
options?: TokenStandardArg;
|
|
260
252
|
}): Promise<GetCollectionDataResponse> {
|
|
261
253
|
const { aptosConfig, creatorAddress, collectionName, options } = args;
|
|
262
254
|
const address = AccountAddress.from(creatorAddress);
|
|
@@ -289,9 +281,7 @@ export async function getCollectionId(args: {
|
|
|
289
281
|
aptosConfig: AptosConfig;
|
|
290
282
|
creatorAddress: AccountAddressInput;
|
|
291
283
|
collectionName: string;
|
|
292
|
-
options?:
|
|
293
|
-
tokenStandard?: TokenStandard;
|
|
294
|
-
};
|
|
284
|
+
options?: TokenStandardArg;
|
|
295
285
|
}): Promise<string> {
|
|
296
286
|
return (await getCollectionData(args)).collection_id;
|
|
297
287
|
}
|