@aptos-labs/ts-sdk 0.0.6 → 0.0.7
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 +9 -4
- package/dist/browser/index.d.ts +564 -338
- package/dist/browser/index.global.js +46 -25
- package/dist/browser/index.global.js.map +1 -1
- package/dist/common/index.d.ts +564 -338
- package/dist/common/index.js +45 -24
- package/dist/common/index.js.map +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +212 -18
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +8 -0
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.d.mts +2 -2
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +3 -3
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +4 -0
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +53 -0
- package/dist/esm/api/transactionSubmission/build.mjs +2 -0
- package/dist/esm/api/transactionSubmission/build.mjs.map +1 -0
- package/dist/esm/api/transactionSubmission/sign.d.mts +50 -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 +53 -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 +51 -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 +9 -60
- package/dist/esm/api/transactionSubmission.mjs +1 -1
- package/dist/esm/{chunk-NGCFPQ22.mjs → chunk-2OZRBXLM.mjs} +2 -2
- package/dist/esm/{chunk-TQD4IGUM.mjs → chunk-33T7WTB6.mjs} +2 -2
- package/dist/esm/chunk-3732I6BR.mjs +2 -0
- package/dist/esm/chunk-3732I6BR.mjs.map +1 -0
- package/dist/esm/chunk-3VZ3OZKC.mjs +2 -0
- package/dist/esm/chunk-3VZ3OZKC.mjs.map +1 -0
- package/dist/esm/chunk-4KTQIWUP.mjs +2 -0
- package/dist/esm/chunk-4KTQIWUP.mjs.map +1 -0
- package/dist/esm/chunk-5LO7FR2P.mjs +2 -0
- package/dist/esm/chunk-5LO7FR2P.mjs.map +1 -0
- package/dist/esm/{chunk-Q6N6QACD.mjs → chunk-67OGU66P.mjs} +2 -2
- package/dist/esm/{chunk-V45RFKH7.mjs → chunk-72F5YXGC.mjs} +2 -2
- package/dist/esm/chunk-72F5YXGC.mjs.map +1 -0
- package/dist/esm/{chunk-2W744GUN.mjs → chunk-BFQRMCY2.mjs} +2 -2
- package/dist/esm/{chunk-WKY5ENCK.mjs → chunk-BM4HBROC.mjs} +2 -2
- package/dist/esm/chunk-DRPMIJH7.mjs +2 -0
- package/dist/esm/chunk-DRPMIJH7.mjs.map +1 -0
- package/dist/esm/{chunk-UPLWWSB4.mjs → chunk-GAI75GOG.mjs} +2 -2
- package/dist/esm/{chunk-7MNEEVXY.mjs → chunk-GU4OUKAF.mjs} +2 -2
- package/dist/esm/{chunk-EQ5BEDJ7.mjs → chunk-HO7K2UAK.mjs} +2 -2
- package/dist/esm/{chunk-U3LO2FSJ.mjs → chunk-IBH7IOIM.mjs} +2 -2
- package/dist/esm/{chunk-R26XML3D.mjs → chunk-J5BH7V37.mjs} +2 -2
- package/dist/esm/chunk-L7AA75WZ.mjs +2 -0
- package/dist/esm/chunk-L7AA75WZ.mjs.map +1 -0
- package/dist/esm/chunk-LACQ537H.mjs +2 -0
- package/dist/esm/{chunk-NYFVEKF6.mjs.map → chunk-LACQ537H.mjs.map} +1 -1
- package/dist/esm/{chunk-EGOYLZBU.mjs → chunk-LDAD54H5.mjs} +2 -2
- package/dist/esm/chunk-LXW3A3MJ.mjs +2 -0
- package/dist/esm/chunk-LXW3A3MJ.mjs.map +1 -0
- package/dist/esm/{chunk-4RVIA63I.mjs → chunk-M2V2POWK.mjs} +2 -2
- package/dist/esm/{chunk-3JVGSFHP.mjs → chunk-ND3ZQKTT.mjs} +2 -2
- package/dist/esm/chunk-O2B54NZT.mjs +2 -0
- package/dist/esm/chunk-O2B54NZT.mjs.map +1 -0
- package/dist/esm/chunk-OCW2L33Q.mjs +2 -0
- package/dist/esm/chunk-OCW2L33Q.mjs.map +1 -0
- package/dist/esm/{chunk-VMQWW5UT.mjs → chunk-OCYS4V2V.mjs} +2 -2
- package/dist/esm/{chunk-BWMNPUTK.mjs → chunk-OSTH5JRX.mjs} +2 -2
- package/dist/esm/chunk-OSTH5JRX.mjs.map +1 -0
- package/dist/esm/{chunk-Z2UDRTHA.mjs → chunk-OVHY6ZUJ.mjs} +2 -2
- package/dist/esm/chunk-PZCMSHY6.mjs +2 -0
- package/dist/esm/{chunk-P32MY5YF.mjs → chunk-RHS5ROLP.mjs} +2 -2
- package/dist/esm/chunk-RHS5ROLP.mjs.map +1 -0
- package/dist/esm/{chunk-BFSEVKNA.mjs → chunk-RKKU2SY5.mjs} +2 -2
- package/dist/esm/chunk-TGKB6ALT.mjs +2 -0
- package/dist/esm/chunk-TGKB6ALT.mjs.map +1 -0
- package/dist/esm/{chunk-GEFQFRL3.mjs → chunk-TPWSHFFI.mjs} +2 -2
- package/dist/esm/{chunk-WX43AJTD.mjs → chunk-UDBH4CER.mjs} +42 -21
- package/dist/esm/chunk-UDBH4CER.mjs.map +1 -0
- package/dist/esm/{chunk-VYAVLUPJ.mjs → chunk-WEJAI26R.mjs} +2 -2
- package/dist/esm/{chunk-JDS7K2WI.mjs → chunk-WL4OXZLN.mjs} +2 -2
- package/dist/esm/{chunk-AAIBCWZY.mjs → chunk-Y2HRRUZ6.mjs} +2 -2
- package/dist/esm/{chunk-J5ZFOJN2.mjs → chunk-ZLW65YCO.mjs} +2 -2
- package/dist/esm/chunk-ZUHN56GM.mjs +2 -0
- package/dist/esm/chunk-ZUHN56GM.mjs.map +1 -0
- package/dist/esm/client/core.mjs +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/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +6 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +80 -13
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +2 -2
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +3 -3
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +3 -3
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +2 -2
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +13 -44
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +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/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/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +3 -6
- 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 +15 -41
- package/dist/esm/types/generated/operations.d.mts +28 -2
- package/dist/esm/types/generated/queries.d.mts +5 -2
- package/dist/esm/types/generated/queries.mjs +1 -1
- package/dist/esm/types/index.d.mts +1 -1
- package/dist/esm/types/indexer.d.mts +3 -2
- package/package.json +1 -1
- package/src/api/ans.ts +250 -11
- package/src/api/aptos.ts +20 -0
- package/src/api/coin.ts +2 -2
- package/src/api/digitalAsset.ts +3 -3
- 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 +4 -143
- package/src/internal/ans.ts +406 -20
- package/src/internal/coin.ts +3 -3
- package/src/internal/digitalAsset.ts +5 -5
- package/src/internal/queries/ansTokenFragment.graphql +9 -0
- package/src/internal/queries/getNames.graphql +11 -0
- package/src/internal/transactionSubmission.ts +29 -21
- package/src/transactions/transactionBuilder/transactionBuilder.ts +20 -43
- package/src/transactions/types.ts +14 -45
- package/src/types/generated/operations.ts +29 -0
- package/src/types/generated/queries.ts +34 -0
- package/src/types/indexer.ts +3 -0
- package/dist/esm/chunk-BP5ZO7NK.mjs +0 -2
- package/dist/esm/chunk-BP5ZO7NK.mjs.map +0 -1
- package/dist/esm/chunk-BWMNPUTK.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-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-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-P32MY5YF.mjs.map +0 -1
- package/dist/esm/chunk-UNQNACJT.mjs +0 -2
- package/dist/esm/chunk-V45RFKH7.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-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-NGCFPQ22.mjs.map → chunk-2OZRBXLM.mjs.map} +0 -0
- /package/dist/esm/{chunk-TQD4IGUM.mjs.map → chunk-33T7WTB6.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q6N6QACD.mjs.map → chunk-67OGU66P.mjs.map} +0 -0
- /package/dist/esm/{chunk-2W744GUN.mjs.map → chunk-BFQRMCY2.mjs.map} +0 -0
- /package/dist/esm/{chunk-WKY5ENCK.mjs.map → chunk-BM4HBROC.mjs.map} +0 -0
- /package/dist/esm/{chunk-UPLWWSB4.mjs.map → chunk-GAI75GOG.mjs.map} +0 -0
- /package/dist/esm/{chunk-7MNEEVXY.mjs.map → chunk-GU4OUKAF.mjs.map} +0 -0
- /package/dist/esm/{chunk-EQ5BEDJ7.mjs.map → chunk-HO7K2UAK.mjs.map} +0 -0
- /package/dist/esm/{chunk-U3LO2FSJ.mjs.map → chunk-IBH7IOIM.mjs.map} +0 -0
- /package/dist/esm/{chunk-R26XML3D.mjs.map → chunk-J5BH7V37.mjs.map} +0 -0
- /package/dist/esm/{chunk-EGOYLZBU.mjs.map → chunk-LDAD54H5.mjs.map} +0 -0
- /package/dist/esm/{chunk-4RVIA63I.mjs.map → chunk-M2V2POWK.mjs.map} +0 -0
- /package/dist/esm/{chunk-3JVGSFHP.mjs.map → chunk-ND3ZQKTT.mjs.map} +0 -0
- /package/dist/esm/{chunk-VMQWW5UT.mjs.map → chunk-OCYS4V2V.mjs.map} +0 -0
- /package/dist/esm/{chunk-Z2UDRTHA.mjs.map → chunk-OVHY6ZUJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-UNQNACJT.mjs.map → chunk-PZCMSHY6.mjs.map} +0 -0
- /package/dist/esm/{chunk-BFSEVKNA.mjs.map → chunk-RKKU2SY5.mjs.map} +0 -0
- /package/dist/esm/{chunk-GEFQFRL3.mjs.map → chunk-TPWSHFFI.mjs.map} +0 -0
- /package/dist/esm/{chunk-VYAVLUPJ.mjs.map → chunk-WEJAI26R.mjs.map} +0 -0
- /package/dist/esm/{chunk-JDS7K2WI.mjs.map → chunk-WL4OXZLN.mjs.map} +0 -0
- /package/dist/esm/{chunk-AAIBCWZY.mjs.map → chunk-Y2HRRUZ6.mjs.map} +0 -0
- /package/dist/esm/{chunk-J5ZFOJN2.mjs.map → chunk-ZLW65YCO.mjs.map} +0 -0
|
@@ -3,30 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
import { AptosConfig } from "./aptosConfig";
|
|
5
5
|
import { Account, AccountAddressInput, PrivateKey } from "../core";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
InputFeePayerTransaction,
|
|
10
|
-
InputGenerateMultiAgentRawTransactionData,
|
|
11
|
-
InputGenerateTransactionData,
|
|
12
|
-
InputGenerateFeePayerRawTransactionData,
|
|
13
|
-
InputGenerateSingleSignerRawTransactionData,
|
|
14
|
-
InputMultiAgentTransaction,
|
|
15
|
-
InputSingleSignerTransaction,
|
|
16
|
-
InputSimulateTransactionData,
|
|
17
|
-
InputGenerateTransactionOptions,
|
|
18
|
-
InputSubmitTransactionData,
|
|
19
|
-
} from "../transactions/types";
|
|
20
|
-
import { UserTransactionResponse, PendingTransactionResponse, HexInput, TransactionResponse } from "../types";
|
|
21
|
-
import {
|
|
22
|
-
generateTransaction,
|
|
23
|
-
publicPackageTransaction,
|
|
24
|
-
rotateAuthKey,
|
|
25
|
-
signAndSubmitTransaction,
|
|
26
|
-
signTransaction,
|
|
27
|
-
simulateTransaction,
|
|
28
|
-
submitTransaction,
|
|
29
|
-
} from "../internal/transactionSubmission";
|
|
6
|
+
import { AnyRawTransaction, SingleSignerTransaction, InputGenerateTransactionOptions } from "../transactions/types";
|
|
7
|
+
import { PendingTransactionResponse, HexInput, TransactionResponse } from "../types";
|
|
8
|
+
import { publicPackageTransaction, rotateAuthKey, signAndSubmitTransaction } from "../internal/transactionSubmission";
|
|
30
9
|
|
|
31
10
|
export class TransactionSubmission {
|
|
32
11
|
readonly config: AptosConfig;
|
|
@@ -35,124 +14,6 @@ export class TransactionSubmission {
|
|
|
35
14
|
this.config = config;
|
|
36
15
|
}
|
|
37
16
|
|
|
38
|
-
/**
|
|
39
|
-
* We are defining function signatures, each with its specific input and output.
|
|
40
|
-
* These are the possible function signature for `generateTransaction` function.
|
|
41
|
-
* When we call `generateTransaction` function with the relevant type properties,
|
|
42
|
-
* Typescript can infer the return type based on the appropriate function overload.
|
|
43
|
-
*/
|
|
44
|
-
async generateTransaction(args: InputGenerateSingleSignerRawTransactionData): Promise<InputSingleSignerTransaction>;
|
|
45
|
-
async generateTransaction(args: InputGenerateFeePayerRawTransactionData): Promise<InputFeePayerTransaction>;
|
|
46
|
-
async generateTransaction(args: InputGenerateMultiAgentRawTransactionData): Promise<InputMultiAgentTransaction>;
|
|
47
|
-
async generateTransaction(args: InputGenerateTransactionData): Promise<AnyRawTransaction>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Generates any transaction by passing in the required arguments
|
|
51
|
-
*
|
|
52
|
-
* @param args.sender The transaction sender's account address as a AccountAddressInput
|
|
53
|
-
* @param args.data EntryFunctionData | ScriptData | MultiSigData
|
|
54
|
-
* @param args.feePayerAddress optional. For a fee payer (aka sponsored) transaction
|
|
55
|
-
* @param args.secondarySignerAddresses optional. For a multi-agent or fee payer (aka sponsored) transactions
|
|
56
|
-
* @param args.options optional. GenerateTransactionOptions type
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* For a single signer entry function
|
|
60
|
-
* move function name, move function type arguments, move function arguments
|
|
61
|
-
* `
|
|
62
|
-
* data: {
|
|
63
|
-
* function: "0x1::aptos_account::transfer",
|
|
64
|
-
* typeArguments: []
|
|
65
|
-
* functionArguments: [receiverAddress,10]
|
|
66
|
-
* }
|
|
67
|
-
* `
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* For a single signer script function
|
|
71
|
-
* module bytecode, move function type arguments, move function arguments
|
|
72
|
-
* ```
|
|
73
|
-
* data: {
|
|
74
|
-
* bytecode: "0x001234567",
|
|
75
|
-
* typeArguments: [],
|
|
76
|
-
* functionArguments: [receiverAddress,10]
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
*
|
|
80
|
-
* @return An instance of a RawTransaction, plus optional secondary/fee payer addresses
|
|
81
|
-
* ```
|
|
82
|
-
* {
|
|
83
|
-
* rawTransaction: RawTransaction,
|
|
84
|
-
* secondarySignerAddresses? : Array<AccountAddress>,
|
|
85
|
-
* feePayerAddress?: AccountAddress
|
|
86
|
-
* }
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
async generateTransaction(args: InputGenerateTransactionData): Promise<AnyRawTransaction> {
|
|
90
|
-
return generateTransaction({ aptosConfig: this.config, ...args });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Sign a transaction that can later be submitted to chain
|
|
95
|
-
*
|
|
96
|
-
* @param args.signer The signer account to sign the transaction
|
|
97
|
-
* @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses
|
|
98
|
-
* @param args.asFeePayer optional. If the signer is also the fee payer
|
|
99
|
-
* ```
|
|
100
|
-
* {
|
|
101
|
-
* rawTransaction: RawTransaction,
|
|
102
|
-
* secondarySignerAddresses?: Array<AccountAddress>,
|
|
103
|
-
* feePayerAddress?: AccountAddress
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* @return The signer AccountAuthenticator
|
|
108
|
-
*/
|
|
109
|
-
/* eslint-disable class-methods-use-this */
|
|
110
|
-
signTransaction(args: {
|
|
111
|
-
signer: Account;
|
|
112
|
-
transaction: AnyRawTransaction;
|
|
113
|
-
asFeePayer?: boolean;
|
|
114
|
-
}): AccountAuthenticator {
|
|
115
|
-
const { signer, transaction, asFeePayer } = args;
|
|
116
|
-
|
|
117
|
-
// Account can only sign as fee payer if it's a fee payer transaction
|
|
118
|
-
if ("feePayerAddress" in transaction && asFeePayer) {
|
|
119
|
-
transaction.feePayerAddress = signer.accountAddress;
|
|
120
|
-
} else if (asFeePayer) {
|
|
121
|
-
throw new Error("Transaction being signed is not a Fee payer transaction, but `asFeePayer` is set to true");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return signTransaction({
|
|
125
|
-
signer,
|
|
126
|
-
transaction,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Simulates a transaction before singing it.
|
|
132
|
-
*
|
|
133
|
-
* @param args.signerPublicKey The signer public key
|
|
134
|
-
* @param args.transaction The raw transaction to simulate
|
|
135
|
-
* @param args.secondarySignersPublicKeys optional. For when the transaction is a multi signers transaction
|
|
136
|
-
* @param args.feePayerPublicKey optional. For when the transaction is a fee payer (aka sponsored) transaction
|
|
137
|
-
* @param args.options optional. A config to simulate the transaction with
|
|
138
|
-
*/
|
|
139
|
-
async simulateTransaction(args: InputSimulateTransactionData): Promise<Array<UserTransactionResponse>> {
|
|
140
|
-
return simulateTransaction({ aptosConfig: this.config, ...args });
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Submit transaction to chain
|
|
145
|
-
*
|
|
146
|
-
* @param args.transaction A aptos transaction type
|
|
147
|
-
* @param args.senderAuthenticator The account authenticator of the transaction sender
|
|
148
|
-
* @param args.secondarySignerAuthenticators optional. For when the transaction is a multi signers transaction
|
|
149
|
-
*
|
|
150
|
-
* @return PendingTransactionResponse
|
|
151
|
-
*/
|
|
152
|
-
async submitTransaction(args: InputSubmitTransactionData): Promise<PendingTransactionResponse> {
|
|
153
|
-
return submitTransaction({ aptosConfig: this.config, ...args });
|
|
154
|
-
}
|
|
155
|
-
|
|
156
17
|
/**
|
|
157
18
|
* Sign and submit a single signer transaction to chain
|
|
158
19
|
*
|
|
@@ -198,7 +59,7 @@ export class TransactionSubmission {
|
|
|
198
59
|
metadataBytes: HexInput;
|
|
199
60
|
moduleBytecode: Array<HexInput>;
|
|
200
61
|
options?: InputGenerateTransactionOptions;
|
|
201
|
-
}): Promise<
|
|
62
|
+
}): Promise<SingleSignerTransaction> {
|
|
202
63
|
return publicPackageTransaction({ aptosConfig: this.config, ...args });
|
|
203
64
|
}
|
|
204
65
|
|
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, OrderBy, PaginationArgs } 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 = [
|
|
@@ -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
126
|
| { policy: "subdomain:independent"; expirationDate: Date };
|
|
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,413 @@ 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 as
|
|
170
|
+
return transaction as SingleSignerTransaction;
|
|
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
|
+
let tldExpiration = await getExpiration({ aptosConfig, name: domainName });
|
|
179
|
+
if (!tldExpiration) {
|
|
180
|
+
throw new Error("The domain does not exist");
|
|
181
|
+
}
|
|
182
|
+
// The contract gives us seconds, but JS expects milliseconds
|
|
183
|
+
tldExpiration *= 1000;
|
|
184
|
+
|
|
185
|
+
const expirationDateInMillisecondsSinceEpoch =
|
|
186
|
+
expiration.policy === "subdomain:independent" ? expiration.expirationDate.valueOf() : tldExpiration;
|
|
187
|
+
|
|
188
|
+
if (expirationDateInMillisecondsSinceEpoch > tldExpiration) {
|
|
189
|
+
throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const transaction = await generateTransaction({
|
|
193
|
+
aptosConfig,
|
|
194
|
+
sender: sender.accountAddress.toString(),
|
|
195
|
+
data: {
|
|
196
|
+
function: `${routerAddress}::router::register_subdomain`,
|
|
197
|
+
functionArguments: [
|
|
198
|
+
domainName,
|
|
199
|
+
subdomainName,
|
|
200
|
+
Math.round(expirationDateInMillisecondsSinceEpoch / 1000),
|
|
201
|
+
expiration.policy === "subdomain:follow-domain" ? 1 : 0,
|
|
202
|
+
!!transferable,
|
|
203
|
+
targetAddress,
|
|
204
|
+
toAddress,
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
options,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
return transaction as SingleSignerTransaction;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export async function getExpiration(args: { aptosConfig: AptosConfig; name: string }): Promise<number | undefined> {
|
|
214
|
+
const { aptosConfig, name } = args;
|
|
215
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
216
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
const res = await view({
|
|
220
|
+
aptosConfig,
|
|
221
|
+
payload: {
|
|
222
|
+
function: `${routerAddress}::router::get_expiration`,
|
|
223
|
+
functionArguments: [domainName, Option(subdomainName)],
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
return res[0] as number;
|
|
228
|
+
} catch (e) {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export async function getPrimaryName(args: {
|
|
234
|
+
aptosConfig: AptosConfig;
|
|
235
|
+
address: AccountAddressInput;
|
|
236
|
+
}): Promise<string | undefined> {
|
|
237
|
+
const { aptosConfig, address } = args;
|
|
238
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
239
|
+
|
|
240
|
+
const res = await view({
|
|
241
|
+
aptosConfig,
|
|
242
|
+
payload: {
|
|
243
|
+
function: `${routerAddress}::router::get_primary_name`,
|
|
244
|
+
functionArguments: [AccountAddress.fromRelaxed(address).toString()],
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const domainName = unwrapOption<MoveAddressType>(res[1]);
|
|
249
|
+
const subdomainName = unwrapOption<MoveAddressType>(res[0]);
|
|
250
|
+
|
|
251
|
+
if (!domainName) return undefined;
|
|
252
|
+
|
|
253
|
+
return [subdomainName, domainName].filter(Boolean).join(".");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export async function setPrimaryName(args: {
|
|
257
|
+
aptosConfig: AptosConfig;
|
|
258
|
+
sender: Account;
|
|
259
|
+
name: string | null;
|
|
260
|
+
options?: InputGenerateTransactionOptions;
|
|
261
|
+
}): Promise<SingleSignerTransaction> {
|
|
262
|
+
const { aptosConfig, sender, name, options } = args;
|
|
263
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
264
|
+
|
|
265
|
+
if (!name) {
|
|
266
|
+
const transaction = await generateTransaction({
|
|
267
|
+
aptosConfig,
|
|
268
|
+
sender: sender.accountAddress.toString(),
|
|
269
|
+
data: {
|
|
270
|
+
function: `${routerAddress}::router::clear_primary_name`,
|
|
271
|
+
functionArguments: [],
|
|
272
|
+
},
|
|
273
|
+
options,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
return transaction as SingleSignerTransaction;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
280
|
+
|
|
281
|
+
const transaction = await generateTransaction({
|
|
282
|
+
aptosConfig,
|
|
283
|
+
sender: sender.accountAddress.toString(),
|
|
284
|
+
data: {
|
|
285
|
+
function: `${routerAddress}::router::set_primary_name`,
|
|
286
|
+
functionArguments: [domainName, subdomainName],
|
|
287
|
+
},
|
|
288
|
+
options,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
return transaction as SingleSignerTransaction;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export async function getTargetAddress(args: {
|
|
295
|
+
aptosConfig: AptosConfig;
|
|
296
|
+
name: string;
|
|
297
|
+
}): Promise<MoveAddressType | undefined> {
|
|
298
|
+
const { aptosConfig, name } = args;
|
|
299
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
300
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
301
|
+
|
|
302
|
+
const res = await view({
|
|
303
|
+
aptosConfig,
|
|
304
|
+
payload: {
|
|
305
|
+
function: `${routerAddress}::router::get_target_addr`,
|
|
306
|
+
functionArguments: [domainName, Option(subdomainName)],
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const target = unwrapOption<MoveAddressType>(res[0]);
|
|
311
|
+
return target ? AccountAddress.fromRelaxed(target).toString() : undefined;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export async function setTargetAddress(args: {
|
|
315
|
+
aptosConfig: AptosConfig;
|
|
316
|
+
sender: Account;
|
|
317
|
+
name: string;
|
|
318
|
+
address: AccountAddressInput;
|
|
319
|
+
options?: InputGenerateTransactionOptions;
|
|
320
|
+
}): Promise<SingleSignerTransaction> {
|
|
321
|
+
const { aptosConfig, sender, name, address, options } = args;
|
|
322
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
323
|
+
const { domainName, subdomainName } = isValidANSName(name);
|
|
324
|
+
|
|
325
|
+
const transaction = await generateTransaction({
|
|
326
|
+
aptosConfig,
|
|
327
|
+
sender: sender.accountAddress.toString(),
|
|
328
|
+
data: {
|
|
329
|
+
function: `${routerAddress}::router::set_target_addr`,
|
|
330
|
+
functionArguments: [domainName, subdomainName, address],
|
|
331
|
+
},
|
|
332
|
+
options,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
return transaction as SingleSignerTransaction;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export async function getName(args: {
|
|
339
|
+
aptosConfig: AptosConfig;
|
|
340
|
+
name: string;
|
|
341
|
+
}): Promise<GetANSNameResponse[0] | undefined> {
|
|
342
|
+
const { aptosConfig, name } = args;
|
|
343
|
+
const { domainName, subdomainName = "" } = isValidANSName(name);
|
|
344
|
+
|
|
345
|
+
const where: CurrentAptosNamesBoolExp = {
|
|
346
|
+
domain: { _eq: domainName },
|
|
347
|
+
subdomain: { _eq: subdomainName },
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
351
|
+
aptosConfig,
|
|
352
|
+
query: {
|
|
353
|
+
query: GetNames,
|
|
354
|
+
variables: {
|
|
355
|
+
where_condition: where,
|
|
356
|
+
limit: 1,
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
originMethod: "getName",
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
return data.current_aptos_names[0] as GetANSNameResponse[0] | undefined;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
interface QueryNamesOptions {
|
|
366
|
+
options?: {
|
|
367
|
+
pagination?: PaginationArgs;
|
|
368
|
+
orderBy?: OrderBy<GetANSNameResponse[0]>;
|
|
369
|
+
where?: CurrentAptosNamesBoolExp;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface GetAccountNamesArgs extends QueryNamesOptions {
|
|
374
|
+
accountAddress: AccountAddressInput;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export async function getAccountNames(
|
|
378
|
+
args: { aptosConfig: AptosConfig } & GetAccountNamesArgs,
|
|
379
|
+
): Promise<GetANSNameResponse> {
|
|
380
|
+
const { aptosConfig, options, accountAddress } = args;
|
|
381
|
+
|
|
382
|
+
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
383
|
+
|
|
384
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
385
|
+
aptosConfig,
|
|
386
|
+
originMethod: "getAccountNames",
|
|
387
|
+
query: {
|
|
388
|
+
query: GetNames,
|
|
389
|
+
variables: {
|
|
390
|
+
limit: options?.pagination?.limit,
|
|
391
|
+
offset: options?.pagination?.offset,
|
|
392
|
+
order_by: options?.orderBy,
|
|
393
|
+
where_condition: {
|
|
394
|
+
...(args.options?.where ?? {}),
|
|
395
|
+
owner_address: { _eq: accountAddress.toString() },
|
|
396
|
+
expiration_timestamp: { _gte: expirationDate },
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
return data.current_aptos_names;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export interface GetAccountDomainsArgs extends QueryNamesOptions {
|
|
406
|
+
accountAddress: AccountAddressInput;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export async function getAccountDomains(
|
|
410
|
+
args: { aptosConfig: AptosConfig } & GetAccountDomainsArgs,
|
|
411
|
+
): Promise<GetANSNameResponse> {
|
|
412
|
+
const { aptosConfig, options, accountAddress } = args;
|
|
413
|
+
|
|
414
|
+
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
415
|
+
|
|
416
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
417
|
+
aptosConfig,
|
|
418
|
+
originMethod: "getAccountDomains",
|
|
419
|
+
query: {
|
|
420
|
+
query: GetNames,
|
|
421
|
+
variables: {
|
|
422
|
+
limit: options?.pagination?.limit,
|
|
423
|
+
offset: options?.pagination?.offset,
|
|
424
|
+
order_by: options?.orderBy,
|
|
425
|
+
where_condition: {
|
|
426
|
+
...(args.options?.where ?? {}),
|
|
427
|
+
owner_address: { _eq: accountAddress.toString() },
|
|
428
|
+
expiration_timestamp: { _gte: expirationDate },
|
|
429
|
+
subdomain: { _eq: "" },
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
return data.current_aptos_names;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface GetAccountSubdomainsArgs extends QueryNamesOptions {
|
|
439
|
+
accountAddress: AccountAddressInput;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export async function getAccountSubdomains(
|
|
443
|
+
args: { aptosConfig: AptosConfig } & GetAccountSubdomainsArgs,
|
|
444
|
+
): Promise<GetANSNameResponse> {
|
|
445
|
+
const { aptosConfig, options, accountAddress } = args;
|
|
446
|
+
|
|
447
|
+
const expirationDate = await getANSExpirationDate({ aptosConfig });
|
|
448
|
+
|
|
449
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
450
|
+
aptosConfig,
|
|
451
|
+
originMethod: "getAccountSubdomains",
|
|
452
|
+
query: {
|
|
453
|
+
query: GetNames,
|
|
454
|
+
variables: {
|
|
455
|
+
limit: options?.pagination?.limit,
|
|
456
|
+
offset: options?.pagination?.offset,
|
|
457
|
+
order_by: options?.orderBy,
|
|
458
|
+
where_condition: {
|
|
459
|
+
...(args.options?.where ?? {}),
|
|
460
|
+
owner_address: { _eq: accountAddress.toString() },
|
|
461
|
+
expiration_timestamp: { _gte: expirationDate },
|
|
462
|
+
subdomain: { _neq: "" },
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
return data.current_aptos_names;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export interface GetDomainSubdomainsArgs extends QueryNamesOptions {
|
|
472
|
+
domain: string;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export async function getDomainSubdomains(
|
|
476
|
+
args: { aptosConfig: AptosConfig } & GetDomainSubdomainsArgs,
|
|
477
|
+
): Promise<GetANSNameResponse> {
|
|
478
|
+
const { aptosConfig, options, domain } = args;
|
|
479
|
+
|
|
480
|
+
const data = await queryIndexer<GetNamesQuery>({
|
|
481
|
+
aptosConfig,
|
|
482
|
+
originMethod: "getDomainSubdomains",
|
|
483
|
+
query: {
|
|
484
|
+
query: GetNames,
|
|
485
|
+
variables: {
|
|
486
|
+
limit: options?.pagination?.limit,
|
|
487
|
+
offset: options?.pagination?.offset,
|
|
488
|
+
order_by: options?.orderBy,
|
|
489
|
+
where_condition: {
|
|
490
|
+
...(args.options?.where ?? {}),
|
|
491
|
+
domain: { _eq: domain },
|
|
492
|
+
subdomain: { _neq: "" },
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
return data.current_aptos_names;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* This function returns the expiration date in which a name is fully expired as
|
|
503
|
+
* defined by the contract. The grace period allows for names to be past
|
|
504
|
+
* expiration for a certain amount of time before they are released to the
|
|
505
|
+
* public. The names will not function as normal, but the owner can renew
|
|
506
|
+
* without others taking ownership of the name. At the time of writing, the
|
|
507
|
+
* contract specified 30 days.
|
|
508
|
+
*
|
|
509
|
+
* @param args.aptosConfig an AptosConfig object
|
|
510
|
+
* @returns
|
|
511
|
+
*/
|
|
512
|
+
async function getANSExpirationDate(args: { aptosConfig: AptosConfig }): Promise<string> {
|
|
513
|
+
const { aptosConfig } = args;
|
|
514
|
+
const routerAddress = getRouterAddress(aptosConfig);
|
|
515
|
+
|
|
516
|
+
const res = await view({
|
|
517
|
+
aptosConfig,
|
|
518
|
+
payload: {
|
|
519
|
+
function: `${routerAddress}::config::reregistration_grace_sec`,
|
|
520
|
+
functionArguments: [],
|
|
521
|
+
},
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
const gracePeriodInSeconds = res[0] as number;
|
|
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 as SingleSignerTransaction;
|
|
175
561
|
}
|
package/src/internal/coin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AptosConfig } from "../api/aptosConfig";
|
|
2
2
|
import { U64 } from "../bcs/serializable/movePrimitives";
|
|
3
3
|
import { Account, AccountAddress, AccountAddressInput } from "../core";
|
|
4
|
-
import { InputGenerateTransactionOptions,
|
|
4
|
+
import { InputGenerateTransactionOptions, SingleSignerTransaction } from "../transactions/types";
|
|
5
5
|
import { AnyNumber, MoveStructId } from "../types";
|
|
6
6
|
import { APTOS_COIN } from "../utils/const";
|
|
7
7
|
import { generateTransaction } from "./transactionSubmission";
|
|
@@ -14,7 +14,7 @@ export async function transferCoinTransaction(args: {
|
|
|
14
14
|
amount: AnyNumber;
|
|
15
15
|
coinType?: MoveStructId;
|
|
16
16
|
options?: InputGenerateTransactionOptions;
|
|
17
|
-
}): Promise<
|
|
17
|
+
}): Promise<SingleSignerTransaction> {
|
|
18
18
|
const { aptosConfig, sender, recipient, amount, coinType, options } = args;
|
|
19
19
|
const coinStructType = coinType ?? APTOS_COIN;
|
|
20
20
|
const transaction = await generateTransaction({
|
|
@@ -28,5 +28,5 @@ export async function transferCoinTransaction(args: {
|
|
|
28
28
|
options,
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
return transaction as
|
|
31
|
+
return transaction as SingleSignerTransaction;
|
|
32
32
|
}
|
|
@@ -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,
|
|
@@ -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 as
|
|
77
|
+
return transaction as SingleSignerTransaction;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export async function getTokenData(args: {
|
|
@@ -219,7 +219,7 @@ export async function createCollectionTransaction(
|
|
|
219
219
|
uri: string;
|
|
220
220
|
options?: InputGenerateTransactionOptions;
|
|
221
221
|
} & CreateCollectionOptions,
|
|
222
|
-
): Promise<
|
|
222
|
+
): Promise<SingleSignerTransaction> {
|
|
223
223
|
const { aptosConfig, options, creator } = args;
|
|
224
224
|
const transaction = await generateTransaction({
|
|
225
225
|
aptosConfig,
|
|
@@ -247,7 +247,7 @@ export async function createCollectionTransaction(
|
|
|
247
247
|
},
|
|
248
248
|
options,
|
|
249
249
|
});
|
|
250
|
-
return transaction as
|
|
250
|
+
return transaction as SingleSignerTransaction;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
export async function getCollectionData(args: {
|