@aptos-labs/ts-sdk 5.2.1 → 6.0.0
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/dist/common/{account-Dxsj5MIn.d.ts → account-Dpz_N9h-.d.ts} +7 -2
- package/dist/common/{chunk-3KK6QRXD.js → chunk-4RHBBU7C.js} +3 -3
- package/dist/common/{chunk-3KK6QRXD.js.map → chunk-4RHBBU7C.js.map} +1 -1
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +198 -28
- package/dist/common/index.js +37 -32
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-DIIE2Drw.d.mts → Ed25519Account-BW_kXHC2.d.mts} +1 -1
- package/dist/esm/account/AbstractKeylessAccount.d.mts +3 -3
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +2 -2
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +2 -2
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +3 -3
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.d.mts +2 -2
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +2 -2
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +3 -3
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.d.mts +2 -2
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +3 -3
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +3 -3
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.d.mts +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/{account-CMR8C31P.d.mts → account-CcxnCdYZ.d.mts} +1 -1
- package/dist/esm/api/account/abstraction.d.mts +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.d.mts +2 -2
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +92 -26
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +4 -3
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -1
- package/dist/esm/api/coin.d.mts +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +2 -2
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +2 -2
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +4 -3
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +3 -3
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +2 -2
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +1 -1
- package/dist/esm/bcs/deserializer.d.mts +1 -1
- package/dist/esm/bcs/index.d.mts +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +1 -1
- package/dist/esm/chunk-2DPQMXUG.mjs +4 -0
- package/dist/esm/chunk-2DPQMXUG.mjs.map +1 -0
- package/dist/esm/{chunk-VO3JD6U6.mjs → chunk-2LCPW76G.mjs} +2 -2
- package/dist/esm/{chunk-GRF3NBRO.mjs → chunk-52PWWLJJ.mjs} +2 -2
- package/dist/esm/{chunk-3GNYDMRA.mjs → chunk-76SVQZDX.mjs} +2 -2
- package/dist/esm/{chunk-Z6PXP6MJ.mjs → chunk-BGZDJ5SM.mjs} +2 -2
- package/dist/esm/{chunk-DLD62OFZ.mjs → chunk-CUXCVNES.mjs} +2 -2
- package/dist/esm/chunk-DE5K76I2.mjs +1 -0
- package/dist/esm/{chunk-EIQBQ62N.mjs → chunk-F3NI6N7R.mjs} +2 -2
- package/dist/esm/chunk-FW6UHAQV.mjs +2 -0
- package/dist/esm/{chunk-VS5NYRHW.mjs.map → chunk-FW6UHAQV.mjs.map} +1 -1
- package/dist/esm/{chunk-C622NWP7.mjs → chunk-JN65XG2P.mjs} +2 -2
- package/dist/esm/{chunk-UL777LTI.mjs → chunk-LS2HRAVW.mjs} +24 -19
- package/dist/esm/chunk-LS2HRAVW.mjs.map +1 -0
- package/dist/esm/chunk-NP2IAUME.mjs +2 -0
- package/dist/esm/chunk-NP2IAUME.mjs.map +1 -0
- package/dist/esm/{chunk-TBOR2W2F.mjs → chunk-NTLOKAPD.mjs} +2 -2
- package/dist/esm/{chunk-KY4GDJA6.mjs → chunk-PXJEKGEG.mjs} +2 -2
- package/dist/esm/chunk-RQN6LA7E.mjs +2 -0
- package/dist/esm/{chunk-K3Q5EONX.mjs.map → chunk-RQN6LA7E.mjs.map} +1 -1
- package/dist/esm/{chunk-WBG25H7H.mjs → chunk-WZ6FL7CH.mjs} +2 -2
- package/dist/esm/{chunk-QITAALVJ.mjs → chunk-X674XJNJ.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +1 -1
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +1 -1
- package/dist/esm/client/core.d.mts +1 -1
- 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.d.mts +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +1 -1
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.d.mts +1 -1
- package/dist/esm/core/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/deserializationUtils.d.mts +1 -1
- package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
- package/dist/esm/core/crypto/federatedKeyless.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/keyless.d.mts +2 -2
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +1 -1
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/secp256r1.d.mts +1 -1
- package/dist/esm/core/crypto/secp256r1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/types.d.mts +1 -1
- package/dist/esm/core/crypto/utils.d.mts +1 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.d.mts +1 -1
- package/dist/esm/core/index.d.mts +2 -2
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/{federatedKeyless-DE7i_6s_.d.mts → federatedKeyless-BzaYmP03.d.mts} +1 -1
- package/dist/esm/index.d.mts +4 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.d.mts +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +2 -2
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +85 -33
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +2 -2
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +3 -3
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +2 -2
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.d.mts +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.d.mts +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.d.mts +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +1 -1
- package/dist/esm/transactions/instances/index.d.mts +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +2 -2
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +1 -1
- package/dist/esm/types/ans.d.mts +109 -0
- package/dist/esm/types/ans.mjs +2 -0
- package/dist/esm/types/ans.mjs.map +1 -0
- package/dist/esm/types/generated/operations.d.mts +5 -0
- package/dist/esm/types/generated/queries.d.mts +27 -27
- package/dist/esm/types/generated/queries.mjs +1 -1
- package/dist/esm/types/generated/types.d.mts +191 -7
- package/dist/esm/types/generated/types.mjs +1 -1
- package/dist/esm/types/generated/types.mjs.map +1 -1
- package/dist/esm/types/index.d.mts +2 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +1 -1
- package/dist/esm/utils/helpers.d.mts +1 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
- package/src/api/ans.ts +70 -25
- package/src/internal/ans.ts +279 -109
- package/src/internal/queries/getNames.graphql +5 -0
- package/src/transactions/transactionBuilder/transactionBuilder.ts +4 -4
- package/src/transactions/types.ts +1 -1
- package/src/types/ans.ts +110 -0
- package/src/types/generated/operations.ts +1 -0
- package/src/types/generated/queries.ts +163 -76
- package/src/types/generated/types.ts +216 -6
- package/src/types/index.ts +1 -0
- package/src/version.ts +1 -1
- package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
- package/dist/esm/chunk-K3Q5EONX.mjs +0 -2
- package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
- package/dist/esm/chunk-VS5NYRHW.mjs +0 -2
- package/dist/esm/chunk-ZSO5R7FV.mjs +0 -4
- package/dist/esm/chunk-ZSO5R7FV.mjs.map +0 -1
- /package/dist/esm/{chunk-VO3JD6U6.mjs.map → chunk-2LCPW76G.mjs.map} +0 -0
- /package/dist/esm/{chunk-GRF3NBRO.mjs.map → chunk-52PWWLJJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-3GNYDMRA.mjs.map → chunk-76SVQZDX.mjs.map} +0 -0
- /package/dist/esm/{chunk-Z6PXP6MJ.mjs.map → chunk-BGZDJ5SM.mjs.map} +0 -0
- /package/dist/esm/{chunk-DLD62OFZ.mjs.map → chunk-CUXCVNES.mjs.map} +0 -0
- /package/dist/esm/{chunk-FD6FGKYY.mjs.map → chunk-DE5K76I2.mjs.map} +0 -0
- /package/dist/esm/{chunk-EIQBQ62N.mjs.map → chunk-F3NI6N7R.mjs.map} +0 -0
- /package/dist/esm/{chunk-C622NWP7.mjs.map → chunk-JN65XG2P.mjs.map} +0 -0
- /package/dist/esm/{chunk-TBOR2W2F.mjs.map → chunk-NTLOKAPD.mjs.map} +0 -0
- /package/dist/esm/{chunk-KY4GDJA6.mjs.map → chunk-PXJEKGEG.mjs.map} +0 -0
- /package/dist/esm/{chunk-WBG25H7H.mjs.map → chunk-WZ6FL7CH.mjs.map} +0 -0
- /package/dist/esm/{chunk-QITAALVJ.mjs.map → chunk-X674XJNJ.mjs.map} +0 -0
package/src/internal/ans.ts
CHANGED
|
@@ -10,10 +10,19 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { AptosConfig } from "../api/aptosConfig";
|
|
13
|
-
import { Account } from "../account";
|
|
14
13
|
import { AccountAddress, AccountAddressInput } from "../core";
|
|
15
|
-
import { InputGenerateTransactionOptions } from "../transactions/types";
|
|
16
|
-
import {
|
|
14
|
+
import { InputGenerateTransactionOptions, InputEntryFunctionData } from "../transactions/types";
|
|
15
|
+
import {
|
|
16
|
+
AnsName,
|
|
17
|
+
AnsTokenStandard,
|
|
18
|
+
ExpirationStatus,
|
|
19
|
+
MoveAddressType,
|
|
20
|
+
OrderByArg,
|
|
21
|
+
PaginationArgs,
|
|
22
|
+
RawANSName,
|
|
23
|
+
SubdomainExpirationPolicy,
|
|
24
|
+
WhereArg,
|
|
25
|
+
} from "../types";
|
|
17
26
|
import { GetNamesQuery } from "../types/generated/operations";
|
|
18
27
|
import { GetNames } from "../types/generated/queries";
|
|
19
28
|
import { CurrentAptosNamesBoolExp } from "../types/generated/types";
|
|
@@ -23,6 +32,10 @@ import { view } from "./view";
|
|
|
23
32
|
import { generateTransaction } from "./transactionSubmission";
|
|
24
33
|
import { SimpleTransaction } from "../transactions/instances/simpleTransaction";
|
|
25
34
|
|
|
35
|
+
let GRACE_PERIOD_IN_SECONDS: number | undefined;
|
|
36
|
+
|
|
37
|
+
const RENEWAL_MONTHS_WINDOW = 6;
|
|
38
|
+
|
|
26
39
|
export const VALIDATION_RULES_DESCRIPTION = [
|
|
27
40
|
"A name must be between 3 and 63 characters long,",
|
|
28
41
|
"and can only contain lowercase a-z, 0-9, and hyphens.",
|
|
@@ -74,40 +87,52 @@ export function isValidANSName(name: string): { domainName: string; subdomainNam
|
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @group Implementation
|
|
79
|
-
*/
|
|
80
|
-
export enum SubdomainExpirationPolicy {
|
|
81
|
-
Independent = 0,
|
|
82
|
-
FollowsDomain = 1,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Determine if a given ANS name is considered active based on its expiration dates.
|
|
87
|
-
* Domains are active if their expiration date is in the future, while subdomains may
|
|
88
|
-
* follow their parent's expiration policy (1) or expire independently (0).
|
|
89
|
-
* If the subdomain is expiring independently, it can expire before their parent, but not after.
|
|
90
|
+
* Determines the status of an ANS name's expiration.
|
|
90
91
|
*
|
|
91
92
|
* @param name - An ANS name returned from one of the functions of the SDK.
|
|
92
|
-
* @returns
|
|
93
|
+
* @returns An ExpirationStatus indicating whether the name is Active, InGracePeriod, or Expired.
|
|
93
94
|
* @group Implementation
|
|
94
95
|
*/
|
|
95
|
-
export function
|
|
96
|
-
|
|
96
|
+
export function getANSExpirationStatus({
|
|
97
|
+
aptosConfig,
|
|
98
|
+
name,
|
|
99
|
+
gracePeriod,
|
|
100
|
+
}: {
|
|
101
|
+
name: RawANSName;
|
|
102
|
+
aptosConfig: AptosConfig;
|
|
103
|
+
gracePeriod: number;
|
|
104
|
+
}): ExpirationStatus {
|
|
105
|
+
if (!name) return ExpirationStatus.Expired;
|
|
106
|
+
|
|
107
|
+
const gracePeriodMs = gracePeriod * 1000; // Convert to milliseconds
|
|
108
|
+
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
|
|
111
|
+
const tldExpirationTime = new Date(name.domain_expiration_timestamp).getTime();
|
|
112
|
+
const nameExpirationTime = new Date(name.expiration_timestamp).getTime();
|
|
97
113
|
|
|
98
|
-
const isTLDExpired =
|
|
99
|
-
const
|
|
114
|
+
const isTLDExpired = tldExpirationTime < now;
|
|
115
|
+
const isNameExpired = nameExpirationTime < now;
|
|
116
|
+
const isInGracePeriod = isNameExpired && now - nameExpirationTime < gracePeriodMs;
|
|
117
|
+
const isTLDInGracePeriod = isTLDExpired && now - tldExpirationTime < gracePeriodMs;
|
|
100
118
|
|
|
101
119
|
// If we are a subdomain, if our parent is expired we are always expired
|
|
102
|
-
if (name.subdomain && isTLDExpired)
|
|
120
|
+
if (name.subdomain && isTLDExpired && !isTLDInGracePeriod) {
|
|
121
|
+
return ExpirationStatus.Expired;
|
|
122
|
+
}
|
|
103
123
|
|
|
104
124
|
// If we are a subdomain and our expiration policy is to follow the domain, we
|
|
105
|
-
//
|
|
106
|
-
if (name.subdomain && name.subdomain_expiration_policy === SubdomainExpirationPolicy.FollowsDomain)
|
|
125
|
+
// follow the parent's status (since we know our parent is not fully expired by this point)
|
|
126
|
+
if (name.subdomain && name.subdomain_expiration_policy === SubdomainExpirationPolicy.FollowsDomain) {
|
|
127
|
+
if (isTLDInGracePeriod) return ExpirationStatus.InGracePeriod;
|
|
128
|
+
return ExpirationStatus.Active;
|
|
129
|
+
}
|
|
107
130
|
|
|
108
131
|
// At this point, we are either a TLD or a subdomain with an independent
|
|
109
|
-
// expiration policy,
|
|
110
|
-
return
|
|
132
|
+
// expiration policy, check the name's expiration status
|
|
133
|
+
if (isInGracePeriod) return ExpirationStatus.InGracePeriod;
|
|
134
|
+
if (isNameExpired) return ExpirationStatus.Expired;
|
|
135
|
+
return ExpirationStatus.Active;
|
|
111
136
|
}
|
|
112
137
|
|
|
113
138
|
export const LOCAL_ANS_ACCOUNT_PK =
|
|
@@ -193,7 +218,7 @@ export async function getOwnerAddress(args: {
|
|
|
193
218
|
*/
|
|
194
219
|
export interface RegisterNameParameters {
|
|
195
220
|
aptosConfig: AptosConfig;
|
|
196
|
-
sender:
|
|
221
|
+
sender: AccountAddressInput;
|
|
197
222
|
name: string;
|
|
198
223
|
expiration:
|
|
199
224
|
| { policy: "domain"; years?: 1 }
|
|
@@ -226,7 +251,9 @@ export interface RegisterNameParameters {
|
|
|
226
251
|
* @returns A transaction object representing the registration process.
|
|
227
252
|
* @group Implementation
|
|
228
253
|
*/
|
|
229
|
-
export async function registerName(
|
|
254
|
+
export async function registerName(
|
|
255
|
+
args: RegisterNameParameters,
|
|
256
|
+
): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
|
|
230
257
|
const { aptosConfig, expiration, name, sender, targetAddress, toAddress, options, transferable } = args;
|
|
231
258
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
232
259
|
const { domainName, subdomainName } = isValidANSName(name);
|
|
@@ -253,17 +280,22 @@ export async function registerName(args: RegisterNameParameters): Promise<Simple
|
|
|
253
280
|
const secondsInYear = 31536000;
|
|
254
281
|
const registrationDuration = years * secondsInYear;
|
|
255
282
|
|
|
283
|
+
const data: InputEntryFunctionData = {
|
|
284
|
+
function: `${routerAddress}::router::register_domain`,
|
|
285
|
+
functionArguments: [domainName, registrationDuration, targetAddress, toAddress],
|
|
286
|
+
};
|
|
287
|
+
|
|
256
288
|
const transaction = await generateTransaction({
|
|
257
289
|
aptosConfig,
|
|
258
|
-
sender: sender.
|
|
259
|
-
data
|
|
260
|
-
function: `${routerAddress}::router::register_domain`,
|
|
261
|
-
functionArguments: [domainName, registrationDuration, targetAddress, toAddress],
|
|
262
|
-
},
|
|
290
|
+
sender: AccountAddress.from(sender).toString(),
|
|
291
|
+
data,
|
|
263
292
|
options,
|
|
264
293
|
});
|
|
265
294
|
|
|
266
|
-
return
|
|
295
|
+
return {
|
|
296
|
+
transaction,
|
|
297
|
+
data,
|
|
298
|
+
};
|
|
267
299
|
}
|
|
268
300
|
|
|
269
301
|
// We are a subdomain
|
|
@@ -283,25 +315,30 @@ export async function registerName(args: RegisterNameParameters): Promise<Simple
|
|
|
283
315
|
throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");
|
|
284
316
|
}
|
|
285
317
|
|
|
318
|
+
const data: InputEntryFunctionData = {
|
|
319
|
+
function: `${routerAddress}::router::register_subdomain`,
|
|
320
|
+
functionArguments: [
|
|
321
|
+
domainName,
|
|
322
|
+
subdomainName,
|
|
323
|
+
Math.round(expirationDateInMillisecondsSinceEpoch / 1000),
|
|
324
|
+
expiration.policy === "subdomain:follow-domain" ? 1 : 0,
|
|
325
|
+
!!transferable,
|
|
326
|
+
targetAddress,
|
|
327
|
+
toAddress,
|
|
328
|
+
],
|
|
329
|
+
};
|
|
330
|
+
|
|
286
331
|
const transaction = await generateTransaction({
|
|
287
332
|
aptosConfig,
|
|
288
|
-
sender: sender.
|
|
289
|
-
data
|
|
290
|
-
function: `${routerAddress}::router::register_subdomain`,
|
|
291
|
-
functionArguments: [
|
|
292
|
-
domainName,
|
|
293
|
-
subdomainName,
|
|
294
|
-
Math.round(expirationDateInMillisecondsSinceEpoch / 1000),
|
|
295
|
-
expiration.policy === "subdomain:follow-domain" ? 1 : 0,
|
|
296
|
-
!!transferable,
|
|
297
|
-
targetAddress,
|
|
298
|
-
toAddress,
|
|
299
|
-
],
|
|
300
|
-
},
|
|
333
|
+
sender: AccountAddress.from(sender).toString(),
|
|
334
|
+
data,
|
|
301
335
|
options,
|
|
302
336
|
});
|
|
303
337
|
|
|
304
|
-
return
|
|
338
|
+
return {
|
|
339
|
+
transaction,
|
|
340
|
+
data,
|
|
341
|
+
};
|
|
305
342
|
}
|
|
306
343
|
|
|
307
344
|
/**
|
|
@@ -381,40 +418,50 @@ export async function getPrimaryName(args: {
|
|
|
381
418
|
*/
|
|
382
419
|
export async function setPrimaryName(args: {
|
|
383
420
|
aptosConfig: AptosConfig;
|
|
384
|
-
sender:
|
|
421
|
+
sender: AccountAddressInput;
|
|
385
422
|
name?: string;
|
|
386
423
|
options?: InputGenerateTransactionOptions;
|
|
387
|
-
}): Promise<SimpleTransaction> {
|
|
424
|
+
}): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
|
|
388
425
|
const { aptosConfig, sender, name, options } = args;
|
|
389
426
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
390
427
|
|
|
391
428
|
if (!name) {
|
|
429
|
+
const data: InputEntryFunctionData = {
|
|
430
|
+
function: `${routerAddress}::router::clear_primary_name`,
|
|
431
|
+
functionArguments: [],
|
|
432
|
+
};
|
|
433
|
+
|
|
392
434
|
const transaction = await generateTransaction({
|
|
393
435
|
aptosConfig,
|
|
394
|
-
sender: sender.
|
|
395
|
-
data
|
|
396
|
-
function: `${routerAddress}::router::clear_primary_name`,
|
|
397
|
-
functionArguments: [],
|
|
398
|
-
},
|
|
436
|
+
sender: AccountAddress.from(sender).toString(),
|
|
437
|
+
data,
|
|
399
438
|
options,
|
|
400
439
|
});
|
|
401
440
|
|
|
402
|
-
return
|
|
441
|
+
return {
|
|
442
|
+
transaction,
|
|
443
|
+
data,
|
|
444
|
+
};
|
|
403
445
|
}
|
|
404
446
|
|
|
405
447
|
const { domainName, subdomainName } = isValidANSName(name);
|
|
406
448
|
|
|
449
|
+
const data: InputEntryFunctionData = {
|
|
450
|
+
function: `${routerAddress}::router::set_primary_name`,
|
|
451
|
+
functionArguments: [domainName, subdomainName],
|
|
452
|
+
};
|
|
453
|
+
|
|
407
454
|
const transaction = await generateTransaction({
|
|
408
455
|
aptosConfig,
|
|
409
|
-
sender: sender.
|
|
410
|
-
data
|
|
411
|
-
function: `${routerAddress}::router::set_primary_name`,
|
|
412
|
-
functionArguments: [domainName, subdomainName],
|
|
413
|
-
},
|
|
456
|
+
sender: AccountAddress.from(sender).toString(),
|
|
457
|
+
data,
|
|
414
458
|
options,
|
|
415
459
|
});
|
|
416
460
|
|
|
417
|
-
return
|
|
461
|
+
return {
|
|
462
|
+
transaction,
|
|
463
|
+
data,
|
|
464
|
+
};
|
|
418
465
|
}
|
|
419
466
|
|
|
420
467
|
/**
|
|
@@ -464,26 +511,72 @@ export async function getTargetAddress(args: {
|
|
|
464
511
|
*/
|
|
465
512
|
export async function setTargetAddress(args: {
|
|
466
513
|
aptosConfig: AptosConfig;
|
|
467
|
-
sender:
|
|
514
|
+
sender: AccountAddressInput;
|
|
468
515
|
name: string;
|
|
469
516
|
address: AccountAddressInput;
|
|
470
517
|
options?: InputGenerateTransactionOptions;
|
|
471
|
-
}): Promise<SimpleTransaction> {
|
|
518
|
+
}): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
|
|
472
519
|
const { aptosConfig, sender, name, address, options } = args;
|
|
473
520
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
474
521
|
const { domainName, subdomainName } = isValidANSName(name);
|
|
475
522
|
|
|
523
|
+
const data: InputEntryFunctionData = {
|
|
524
|
+
function: `${routerAddress}::router::set_target_addr`,
|
|
525
|
+
functionArguments: [domainName, subdomainName, address],
|
|
526
|
+
};
|
|
527
|
+
|
|
476
528
|
const transaction = await generateTransaction({
|
|
477
529
|
aptosConfig,
|
|
478
|
-
sender: sender.
|
|
479
|
-
data
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
530
|
+
sender: AccountAddress.from(sender).toString(),
|
|
531
|
+
data,
|
|
532
|
+
options,
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
return {
|
|
536
|
+
transaction,
|
|
537
|
+
data,
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Clears the target address for a specified domain and subdomain in the Aptos network.
|
|
543
|
+
* This function removes the target address association, effectively clearing where the name resolves to.
|
|
544
|
+
*
|
|
545
|
+
* @param args - The arguments for clearing the target address.
|
|
546
|
+
* @param args.aptosConfig - The configuration settings for the Aptos network.
|
|
547
|
+
* @param args.sender - The account that is sending the transaction.
|
|
548
|
+
* @param args.name - The name of the domain or subdomain to clear the target address for.
|
|
549
|
+
* @param args.options - Optional parameters for generating the transaction.
|
|
550
|
+
*
|
|
551
|
+
* @returns A transaction object representing the clear target address operation.
|
|
552
|
+
* @group Implementation
|
|
553
|
+
*/
|
|
554
|
+
export async function clearTargetAddress(args: {
|
|
555
|
+
aptosConfig: AptosConfig;
|
|
556
|
+
sender: AccountAddressInput;
|
|
557
|
+
name: string;
|
|
558
|
+
options?: InputGenerateTransactionOptions;
|
|
559
|
+
}): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
|
|
560
|
+
const { aptosConfig, sender, name, options } = args;
|
|
561
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
562
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
563
|
+
|
|
564
|
+
const data: InputEntryFunctionData = {
|
|
565
|
+
function: `${routerAddress}::router::clear_target_addr`,
|
|
566
|
+
functionArguments: [domainName, subdomainName ?? null],
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
const transaction = await generateTransaction({
|
|
570
|
+
aptosConfig,
|
|
571
|
+
sender: AccountAddress.from(sender).toString(),
|
|
572
|
+
data,
|
|
483
573
|
options,
|
|
484
574
|
});
|
|
485
575
|
|
|
486
|
-
return
|
|
576
|
+
return {
|
|
577
|
+
transaction,
|
|
578
|
+
data,
|
|
579
|
+
};
|
|
487
580
|
}
|
|
488
581
|
|
|
489
582
|
/**
|
|
@@ -495,11 +588,11 @@ export async function setTargetAddress(args: {
|
|
|
495
588
|
* @returns The active Aptos name if it exists; otherwise, returns undefined.
|
|
496
589
|
* @group Implementation
|
|
497
590
|
*/
|
|
498
|
-
export async function getName(args: {
|
|
499
|
-
aptosConfig: AptosConfig;
|
|
500
|
-
name: string;
|
|
501
|
-
}): Promise<GetANSNameResponse[0] | undefined> {
|
|
591
|
+
export async function getName(args: { aptosConfig: AptosConfig; name: string }): Promise<AnsName | undefined> {
|
|
502
592
|
const { aptosConfig, name } = args;
|
|
593
|
+
|
|
594
|
+
const gracePeriod = await getANSGracePeriod({ aptosConfig });
|
|
595
|
+
|
|
503
596
|
const { domainName, subdomainName = "" } = isValidANSName(name);
|
|
504
597
|
|
|
505
598
|
const where: CurrentAptosNamesBoolExp = {
|
|
@@ -521,11 +614,7 @@ export async function getName(args: {
|
|
|
521
614
|
|
|
522
615
|
// Convert the expiration_timestamp from an ISO string to milliseconds since epoch
|
|
523
616
|
let res = data.current_aptos_names[0];
|
|
524
|
-
|
|
525
|
-
res = sanitizeANSName(res);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
return isActiveANSName(res) ? res : undefined;
|
|
617
|
+
return res ? sanitizeANSName({ aptosConfig, name: res, gracePeriod }) : undefined;
|
|
529
618
|
}
|
|
530
619
|
|
|
531
620
|
/**
|
|
@@ -535,7 +624,7 @@ export async function getName(args: {
|
|
|
535
624
|
* @group Implementation
|
|
536
625
|
*/
|
|
537
626
|
interface QueryNamesOptions {
|
|
538
|
-
options?: PaginationArgs & OrderByArg<
|
|
627
|
+
options?: PaginationArgs & OrderByArg<AnsName> & WhereArg<CurrentAptosNamesBoolExp>;
|
|
539
628
|
}
|
|
540
629
|
|
|
541
630
|
/**
|
|
@@ -566,9 +655,11 @@ export interface GetAccountNamesArgs extends QueryNamesOptions {
|
|
|
566
655
|
*/
|
|
567
656
|
export async function getAccountNames(
|
|
568
657
|
args: { aptosConfig: AptosConfig } & GetAccountNamesArgs,
|
|
569
|
-
): Promise<
|
|
658
|
+
): Promise<{ names: AnsName[]; total: number }> {
|
|
570
659
|
const { aptosConfig, options, accountAddress } = args;
|
|
571
660
|
|
|
661
|
+
const gracePeriod = await getANSGracePeriod({ aptosConfig });
|
|
662
|
+
|
|
572
663
|
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
573
664
|
|
|
574
665
|
const data = await queryIndexer<GetNamesQuery>({
|
|
@@ -581,15 +672,16 @@ export async function getAccountNames(
|
|
|
581
672
|
offset: options?.offset,
|
|
582
673
|
order_by: options?.orderBy,
|
|
583
674
|
where_condition: {
|
|
584
|
-
...(args.options?.where ?? {}),
|
|
585
675
|
owner_address: { _eq: accountAddress.toString() },
|
|
586
676
|
expiration_timestamp: { _gte: expirationDate },
|
|
677
|
+
...(args.options?.where ?? {}),
|
|
587
678
|
},
|
|
588
679
|
},
|
|
589
680
|
},
|
|
590
681
|
});
|
|
591
|
-
|
|
592
|
-
|
|
682
|
+
const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
|
|
683
|
+
const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
|
|
684
|
+
return { names, total };
|
|
593
685
|
}
|
|
594
686
|
|
|
595
687
|
/**
|
|
@@ -622,9 +714,11 @@ export interface GetAccountDomainsArgs extends QueryNamesOptions {
|
|
|
622
714
|
*/
|
|
623
715
|
export async function getAccountDomains(
|
|
624
716
|
args: { aptosConfig: AptosConfig } & GetAccountDomainsArgs,
|
|
625
|
-
): Promise<
|
|
717
|
+
): Promise<{ names: AnsName[]; total: number }> {
|
|
626
718
|
const { aptosConfig, options, accountAddress } = args;
|
|
627
719
|
|
|
720
|
+
const gracePeriod = await getANSGracePeriod({ aptosConfig });
|
|
721
|
+
|
|
628
722
|
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
629
723
|
|
|
630
724
|
const data = await queryIndexer<GetNamesQuery>({
|
|
@@ -637,16 +731,19 @@ export async function getAccountDomains(
|
|
|
637
731
|
offset: options?.offset,
|
|
638
732
|
order_by: options?.orderBy,
|
|
639
733
|
where_condition: {
|
|
640
|
-
...(args.options?.where ?? {}),
|
|
641
734
|
owner_address: { _eq: accountAddress.toString() },
|
|
642
735
|
expiration_timestamp: { _gte: expirationDate },
|
|
643
736
|
subdomain: { _eq: "" },
|
|
737
|
+
...(args.options?.where ?? {}),
|
|
644
738
|
},
|
|
645
739
|
},
|
|
646
740
|
},
|
|
647
741
|
});
|
|
648
742
|
|
|
649
|
-
|
|
743
|
+
const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
|
|
744
|
+
const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
|
|
745
|
+
|
|
746
|
+
return { names, total };
|
|
650
747
|
}
|
|
651
748
|
|
|
652
749
|
/**
|
|
@@ -678,10 +775,10 @@ export interface GetAccountSubdomainsArgs extends QueryNamesOptions {
|
|
|
678
775
|
*/
|
|
679
776
|
export async function getAccountSubdomains(
|
|
680
777
|
args: { aptosConfig: AptosConfig } & GetAccountSubdomainsArgs,
|
|
681
|
-
): Promise<
|
|
778
|
+
): Promise<{ names: AnsName[]; total: number }> {
|
|
682
779
|
const { aptosConfig, options, accountAddress } = args;
|
|
683
780
|
|
|
684
|
-
const
|
|
781
|
+
const gracePeriod = await getANSGracePeriod({ aptosConfig });
|
|
685
782
|
|
|
686
783
|
const data = await queryIndexer<GetNamesQuery>({
|
|
687
784
|
aptosConfig,
|
|
@@ -693,16 +790,17 @@ export async function getAccountSubdomains(
|
|
|
693
790
|
offset: options?.offset,
|
|
694
791
|
order_by: options?.orderBy,
|
|
695
792
|
where_condition: {
|
|
696
|
-
...(args.options?.where ?? {}),
|
|
697
793
|
owner_address: { _eq: accountAddress.toString() },
|
|
698
|
-
expiration_timestamp: { _gte: expirationDate },
|
|
699
794
|
subdomain: { _neq: "" },
|
|
795
|
+
...(args.options?.where ?? {}),
|
|
700
796
|
},
|
|
701
797
|
},
|
|
702
798
|
},
|
|
703
799
|
});
|
|
704
800
|
|
|
705
|
-
|
|
801
|
+
const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
|
|
802
|
+
const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
|
|
803
|
+
return { names, total };
|
|
706
804
|
}
|
|
707
805
|
|
|
708
806
|
/**
|
|
@@ -736,9 +834,11 @@ export interface GetDomainSubdomainsArgs extends QueryNamesOptions {
|
|
|
736
834
|
*/
|
|
737
835
|
export async function getDomainSubdomains(
|
|
738
836
|
args: { aptosConfig: AptosConfig } & GetDomainSubdomainsArgs,
|
|
739
|
-
): Promise<
|
|
837
|
+
): Promise<{ names: AnsName[]; total: number }> {
|
|
740
838
|
const { aptosConfig, options, domain } = args;
|
|
741
839
|
|
|
840
|
+
const gracePeriod = await getANSGracePeriod({ aptosConfig });
|
|
841
|
+
|
|
742
842
|
const data = await queryIndexer<GetNamesQuery>({
|
|
743
843
|
aptosConfig,
|
|
744
844
|
originMethod: "getDomainSubdomains",
|
|
@@ -749,15 +849,17 @@ export async function getDomainSubdomains(
|
|
|
749
849
|
offset: options?.offset,
|
|
750
850
|
order_by: options?.orderBy,
|
|
751
851
|
where_condition: {
|
|
752
|
-
...(args.options?.where ?? {}),
|
|
753
852
|
domain: { _eq: domain },
|
|
754
853
|
subdomain: { _neq: "" },
|
|
854
|
+
...(args.options?.where ?? {}),
|
|
755
855
|
},
|
|
756
856
|
},
|
|
757
857
|
},
|
|
758
858
|
});
|
|
759
859
|
|
|
760
|
-
|
|
860
|
+
const names = data.current_aptos_names.map((name) => sanitizeANSName({ aptosConfig, name, gracePeriod }));
|
|
861
|
+
const total = data.current_aptos_names_aggregate.aggregate?.count ?? 0;
|
|
862
|
+
return { names, total };
|
|
761
863
|
}
|
|
762
864
|
|
|
763
865
|
/**
|
|
@@ -774,6 +876,28 @@ export async function getDomainSubdomains(
|
|
|
774
876
|
* @group Implementation
|
|
775
877
|
*/
|
|
776
878
|
async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise<string> {
|
|
879
|
+
const { aptosConfig } = args;
|
|
880
|
+
const gracePeriodInSeconds = await getANSGracePeriod({ aptosConfig });
|
|
881
|
+
const gracePeriodInDays = gracePeriodInSeconds / 60 / 60 / 24;
|
|
882
|
+
const now = () => new Date();
|
|
883
|
+
return new Date(now().setDate(now().getDate() - gracePeriodInDays)).toISOString();
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* This function returns the grace period in seconds as defined by the contract.
|
|
888
|
+
* A name that is past expiration but within the grace period is considered in
|
|
889
|
+
* grace period and can't be claimed by others.
|
|
890
|
+
*
|
|
891
|
+
* @param args - The arguments for the function.
|
|
892
|
+
* @param args.aptosConfig - An AptosConfig object containing the configuration settings.
|
|
893
|
+
* @returns The grace period in seconds.
|
|
894
|
+
* @group Implementation
|
|
895
|
+
*/
|
|
896
|
+
export async function getANSGracePeriod(args: { aptosConfig: AptosConfig }): Promise<number> {
|
|
897
|
+
if (GRACE_PERIOD_IN_SECONDS) {
|
|
898
|
+
return GRACE_PERIOD_IN_SECONDS;
|
|
899
|
+
}
|
|
900
|
+
|
|
777
901
|
const { aptosConfig } = args;
|
|
778
902
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
779
903
|
|
|
@@ -785,9 +909,8 @@ async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise
|
|
|
785
909
|
},
|
|
786
910
|
});
|
|
787
911
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
return new Date(now().setDate(now().getDate() - gracePeriodInDays)).toISOString();
|
|
912
|
+
GRACE_PERIOD_IN_SECONDS = gracePeriodInSeconds;
|
|
913
|
+
return gracePeriodInSeconds;
|
|
791
914
|
}
|
|
792
915
|
|
|
793
916
|
/**
|
|
@@ -804,11 +927,11 @@ async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise
|
|
|
804
927
|
*/
|
|
805
928
|
export async function renewDomain(args: {
|
|
806
929
|
aptosConfig: AptosConfig;
|
|
807
|
-
sender:
|
|
930
|
+
sender: AccountAddressInput;
|
|
808
931
|
name: string;
|
|
809
932
|
years?: 1;
|
|
810
933
|
options?: InputGenerateTransactionOptions;
|
|
811
|
-
}): Promise<SimpleTransaction> {
|
|
934
|
+
}): Promise<{ transaction: SimpleTransaction; data: InputEntryFunctionData }> {
|
|
812
935
|
const { aptosConfig, sender, name, years = 1, options } = args;
|
|
813
936
|
const routerAddress = getRouterAddress(aptosConfig);
|
|
814
937
|
const renewalDuration = years * 31536000;
|
|
@@ -822,17 +945,22 @@ export async function renewDomain(args: {
|
|
|
822
945
|
throw new Error("Currently, only 1 year renewals are supported");
|
|
823
946
|
}
|
|
824
947
|
|
|
948
|
+
const data: InputEntryFunctionData = {
|
|
949
|
+
function: `${routerAddress}::router::renew_domain`,
|
|
950
|
+
functionArguments: [domainName, renewalDuration],
|
|
951
|
+
};
|
|
952
|
+
|
|
825
953
|
const transaction = await generateTransaction({
|
|
826
954
|
aptosConfig,
|
|
827
|
-
sender: sender.
|
|
828
|
-
data
|
|
829
|
-
function: `${routerAddress}::router::renew_domain`,
|
|
830
|
-
functionArguments: [domainName, renewalDuration],
|
|
831
|
-
},
|
|
955
|
+
sender: AccountAddress.from(sender).toString(),
|
|
956
|
+
data,
|
|
832
957
|
options,
|
|
833
958
|
});
|
|
834
959
|
|
|
835
|
-
return
|
|
960
|
+
return {
|
|
961
|
+
transaction,
|
|
962
|
+
data,
|
|
963
|
+
};
|
|
836
964
|
}
|
|
837
965
|
|
|
838
966
|
/**
|
|
@@ -845,9 +973,51 @@ export async function renewDomain(args: {
|
|
|
845
973
|
* @param name.expiration_timestamp - The expiration timestamp in ISO string format.
|
|
846
974
|
* @group Implementation
|
|
847
975
|
*/
|
|
848
|
-
function sanitizeANSName(
|
|
976
|
+
function sanitizeANSName({
|
|
977
|
+
name,
|
|
978
|
+
aptosConfig,
|
|
979
|
+
gracePeriod,
|
|
980
|
+
}: {
|
|
981
|
+
aptosConfig: AptosConfig;
|
|
982
|
+
name: RawANSName;
|
|
983
|
+
gracePeriod: number;
|
|
984
|
+
}): AnsName {
|
|
985
|
+
const expiration_timestamp = name.expiration_timestamp + "Z";
|
|
986
|
+
const domain_expiration_timestamp = name.domain_expiration_timestamp + "Z";
|
|
987
|
+
|
|
988
|
+
const isSubdomain = !!name.subdomain;
|
|
989
|
+
const expirationPolicy = name.subdomain_expiration_policy as SubdomainExpirationPolicy;
|
|
990
|
+
const expiration =
|
|
991
|
+
isSubdomain && expirationPolicy === SubdomainExpirationPolicy.FollowsDomain
|
|
992
|
+
? domain_expiration_timestamp
|
|
993
|
+
: expiration_timestamp;
|
|
994
|
+
|
|
995
|
+
const expiration_status = getANSExpirationStatus({ aptosConfig, name, gracePeriod });
|
|
996
|
+
|
|
997
|
+
let isInRenewablePeriod = false;
|
|
998
|
+
if (expiration_status === ExpirationStatus.InGracePeriod) {
|
|
999
|
+
isInRenewablePeriod = true;
|
|
1000
|
+
} else if (expiration_status === ExpirationStatus.Active) {
|
|
1001
|
+
// Check if the name is within the renewal window (6 months before expiration)
|
|
1002
|
+
const renewalWindowDate = new Date();
|
|
1003
|
+
renewalWindowDate.setMonth(renewalWindowDate.getMonth() + RENEWAL_MONTHS_WINDOW);
|
|
1004
|
+
|
|
1005
|
+
const expirationDate = new Date(expiration);
|
|
1006
|
+
isInRenewablePeriod = expirationDate < renewalWindowDate;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
849
1009
|
return {
|
|
850
|
-
|
|
851
|
-
|
|
1010
|
+
domain: name.domain!,
|
|
1011
|
+
subdomain: name.subdomain || undefined,
|
|
1012
|
+
expiration_timestamp: expiration_timestamp,
|
|
1013
|
+
expiration_status,
|
|
1014
|
+
domain_expiration_timestamp: domain_expiration_timestamp!,
|
|
1015
|
+
expiration: new Date(expiration),
|
|
1016
|
+
token_standard: name.token_standard! as AnsTokenStandard,
|
|
1017
|
+
is_primary: name.is_primary!,
|
|
1018
|
+
subdomain_expiration_policy: name.subdomain_expiration_policy ?? SubdomainExpirationPolicy.FollowsDomain,
|
|
1019
|
+
owner_address: name.owner_address ?? "",
|
|
1020
|
+
registered_address: name.registered_address!,
|
|
1021
|
+
isInRenewablePeriod,
|
|
852
1022
|
};
|
|
853
1023
|
}
|
|
@@ -201,7 +201,7 @@ export function generateTransactionPayloadWithABI(
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
// Check all BCS types, and convert any non-BCS types
|
|
204
|
-
const functionArguments: Array<EntryFunctionArgumentTypes> = args.functionArguments
|
|
204
|
+
const functionArguments: Array<EntryFunctionArgumentTypes> | undefined = args.functionArguments?.map((arg, i) =>
|
|
205
205
|
/**
|
|
206
206
|
* Converts the argument for a specified function using its ABI and type arguments.
|
|
207
207
|
* This function helps ensure that the correct number of arguments is provided for the function call.
|
|
@@ -220,10 +220,10 @@ export function generateTransactionPayloadWithABI(
|
|
|
220
220
|
);
|
|
221
221
|
|
|
222
222
|
// Check that all arguments are accounted for
|
|
223
|
-
if (functionArguments
|
|
223
|
+
if ((functionArguments?.length ?? 0) !== functionAbi.parameters.length) {
|
|
224
224
|
throw new Error(
|
|
225
225
|
// eslint-disable-next-line max-len
|
|
226
|
-
`Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments
|
|
226
|
+
`Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments?.length ?? 0}`,
|
|
227
227
|
);
|
|
228
228
|
}
|
|
229
229
|
|
|
@@ -232,7 +232,7 @@ export function generateTransactionPayloadWithABI(
|
|
|
232
232
|
`${moduleAddress}::${moduleName}`,
|
|
233
233
|
functionName,
|
|
234
234
|
typeArguments,
|
|
235
|
-
functionArguments,
|
|
235
|
+
functionArguments ?? [],
|
|
236
236
|
);
|
|
237
237
|
|
|
238
238
|
// Send it as multi sig if it's a multisig payload
|