@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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import "./AnsTokenFragment";
|
|
2
|
+
query getNames(
|
|
3
|
+
$offset: Int
|
|
4
|
+
$limit: Int
|
|
5
|
+
$where_condition: current_aptos_names_bool_exp
|
|
6
|
+
$order_by: [current_aptos_names_order_by!]
|
|
7
|
+
) {
|
|
8
|
+
current_aptos_names(limit: $limit, where: $where_condition, order_by: $order_by, offset: $offset) {
|
|
9
|
+
...AnsTokenFragment
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -25,15 +25,29 @@ import {
|
|
|
25
25
|
AnyRawTransaction,
|
|
26
26
|
InputSimulateTransactionData,
|
|
27
27
|
InputGenerateTransactionOptions,
|
|
28
|
-
|
|
28
|
+
SingleSignerTransaction,
|
|
29
29
|
InputGenerateTransactionPayloadDataWithRemoteABI,
|
|
30
30
|
InputSubmitTransactionData,
|
|
31
|
-
InputGenerateFeePayerRawTransactionData,
|
|
32
31
|
InputGenerateMultiAgentRawTransactionData,
|
|
32
|
+
InputGenerateSingleSignerRawTransactionData,
|
|
33
|
+
MultiAgentTransaction,
|
|
34
|
+
AnyTransactionPayloadInstance,
|
|
33
35
|
} from "../transactions/types";
|
|
34
36
|
import { getInfo } from "./account";
|
|
35
37
|
import { UserTransactionResponse, PendingTransactionResponse, MimeType, HexInput, TransactionResponse } from "../types";
|
|
36
38
|
|
|
39
|
+
/**
|
|
40
|
+
* We are defining function signatures, each with its specific input and output.
|
|
41
|
+
* These are the possible function signature for `generateTransaction` function.
|
|
42
|
+
* When we call `generateTransaction` function with the relevant type properties,
|
|
43
|
+
* Typescript can infer the return type based on the appropriate function overload.
|
|
44
|
+
*/
|
|
45
|
+
export async function generateTransaction(
|
|
46
|
+
args: { aptosConfig: AptosConfig } & InputGenerateSingleSignerRawTransactionData,
|
|
47
|
+
): Promise<SingleSignerTransaction>;
|
|
48
|
+
export async function generateTransaction(
|
|
49
|
+
args: { aptosConfig: AptosConfig } & InputGenerateMultiAgentRawTransactionData,
|
|
50
|
+
): Promise<MultiAgentTransaction>;
|
|
37
51
|
/**
|
|
38
52
|
* Generates any transaction by passing in the required arguments
|
|
39
53
|
*
|
|
@@ -81,8 +95,10 @@ export async function generateTransaction(
|
|
|
81
95
|
|
|
82
96
|
// Merge in aptosConfig for remote ABI on non-script payloads
|
|
83
97
|
let generateTransactionPayloadData: InputGenerateTransactionPayloadDataWithRemoteABI;
|
|
98
|
+
let payload: AnyTransactionPayloadInstance;
|
|
84
99
|
if ("bytecode" in data) {
|
|
85
100
|
generateTransactionPayloadData = data;
|
|
101
|
+
payload = await generateTransactionPayload(generateTransactionPayloadData);
|
|
86
102
|
} else if ("multisigAddress" in data) {
|
|
87
103
|
generateTransactionPayloadData = {
|
|
88
104
|
aptosConfig,
|
|
@@ -91,6 +107,7 @@ export async function generateTransaction(
|
|
|
91
107
|
functionArguments: data.functionArguments,
|
|
92
108
|
typeArguments: data.typeArguments,
|
|
93
109
|
};
|
|
110
|
+
payload = await generateTransactionPayload(generateTransactionPayloadData);
|
|
94
111
|
} else {
|
|
95
112
|
generateTransactionPayloadData = {
|
|
96
113
|
aptosConfig,
|
|
@@ -98,46 +115,37 @@ export async function generateTransaction(
|
|
|
98
115
|
functionArguments: data.functionArguments,
|
|
99
116
|
typeArguments: data.typeArguments,
|
|
100
117
|
};
|
|
118
|
+
payload = await generateTransactionPayload(generateTransactionPayloadData);
|
|
101
119
|
}
|
|
102
120
|
|
|
121
|
+
let feePayerAddress;
|
|
103
122
|
if (isFeePayerTransactionInput(args)) {
|
|
104
|
-
|
|
105
|
-
const feePayerAddress = args.hasFeePayer ? AccountAddress.ZERO : undefined;
|
|
106
|
-
const payload = await generateTransactionPayload(generateTransactionPayloadData);
|
|
107
|
-
return buildTransaction({
|
|
108
|
-
aptosConfig,
|
|
109
|
-
sender,
|
|
110
|
-
payload,
|
|
111
|
-
options,
|
|
112
|
-
secondarySignerAddresses,
|
|
113
|
-
feePayerAddress,
|
|
114
|
-
});
|
|
123
|
+
feePayerAddress = AccountAddress.ZERO.toString();
|
|
115
124
|
}
|
|
125
|
+
|
|
116
126
|
if (isMultiAgentTransactionInput(args)) {
|
|
117
127
|
const { secondarySignerAddresses } = args;
|
|
118
|
-
const payload = await generateTransactionPayload(generateTransactionPayloadData);
|
|
119
128
|
return buildTransaction({
|
|
120
129
|
aptosConfig,
|
|
121
130
|
sender,
|
|
122
131
|
payload,
|
|
123
132
|
options,
|
|
124
133
|
secondarySignerAddresses,
|
|
134
|
+
feePayerAddress,
|
|
125
135
|
});
|
|
126
136
|
}
|
|
127
137
|
|
|
128
|
-
const payload = await generateTransactionPayload(generateTransactionPayloadData);
|
|
129
138
|
return buildTransaction({
|
|
130
139
|
aptosConfig,
|
|
131
140
|
sender,
|
|
132
141
|
payload,
|
|
133
142
|
options,
|
|
143
|
+
feePayerAddress,
|
|
134
144
|
});
|
|
135
145
|
}
|
|
136
146
|
|
|
137
|
-
function isFeePayerTransactionInput(
|
|
138
|
-
data
|
|
139
|
-
): data is InputGenerateFeePayerRawTransactionData {
|
|
140
|
-
return "hasFeePayer" in data;
|
|
147
|
+
function isFeePayerTransactionInput(data: InputGenerateTransactionData): boolean {
|
|
148
|
+
return data.withFeePayer === true;
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
function isMultiAgentTransactionInput(
|
|
@@ -249,7 +257,7 @@ export async function publicPackageTransaction(args: {
|
|
|
249
257
|
metadataBytes: HexInput;
|
|
250
258
|
moduleBytecode: Array<HexInput>;
|
|
251
259
|
options?: InputGenerateTransactionOptions;
|
|
252
|
-
}): Promise<
|
|
260
|
+
}): Promise<SingleSignerTransaction> {
|
|
253
261
|
const { aptosConfig, account, metadataBytes, moduleBytecode, options } = args;
|
|
254
262
|
|
|
255
263
|
const totalByteCode = moduleBytecode.map((bytecode) => MoveVector.U8(bytecode));
|
|
@@ -263,7 +271,7 @@ export async function publicPackageTransaction(args: {
|
|
|
263
271
|
},
|
|
264
272
|
options,
|
|
265
273
|
});
|
|
266
|
-
return transaction as
|
|
274
|
+
return transaction as SingleSignerTransaction;
|
|
267
275
|
}
|
|
268
276
|
|
|
269
277
|
/**
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
|
|
10
10
|
import { AptosConfig } from "../../api/aptosConfig";
|
|
11
|
-
import { Deserializer } from "../../bcs/deserializer";
|
|
12
11
|
import { AccountAddress, AccountAddressInput, Hex, PublicKey } from "../../core";
|
|
13
12
|
import { Account } from "../../core/account";
|
|
14
13
|
import { AnyPublicKey } from "../../core/crypto/anyPublicKey";
|
|
@@ -57,14 +56,12 @@ import {
|
|
|
57
56
|
AnyRawTransactionInstance,
|
|
58
57
|
EntryFunctionArgumentTypes,
|
|
59
58
|
EntryFunctionABI,
|
|
60
|
-
InputGenerateFeePayerRawTransactionArgs,
|
|
61
59
|
InputGenerateMultiAgentRawTransactionArgs,
|
|
62
60
|
InputGenerateRawTransactionArgs,
|
|
63
61
|
InputGenerateSingleSignerRawTransactionArgs,
|
|
64
|
-
|
|
62
|
+
SingleSignerTransaction,
|
|
65
63
|
InputGenerateTransactionOptions,
|
|
66
|
-
|
|
67
|
-
InputMultiAgentTransaction,
|
|
64
|
+
MultiAgentTransaction,
|
|
68
65
|
InputScriptData,
|
|
69
66
|
InputSimulateTransactionData,
|
|
70
67
|
InputGenerateTransactionPayloadData,
|
|
@@ -93,9 +90,6 @@ export async function generateTransactionPayload(
|
|
|
93
90
|
export async function generateTransactionPayload(
|
|
94
91
|
args: InputMultiSigDataWithRemoteABI,
|
|
95
92
|
): Promise<TransactionPayloadMultisig>;
|
|
96
|
-
export async function generateTransactionPayload(
|
|
97
|
-
args: InputGenerateTransactionPayloadDataWithRemoteABI,
|
|
98
|
-
): Promise<AnyTransactionPayloadInstance>;
|
|
99
93
|
|
|
100
94
|
/**
|
|
101
95
|
* Builds a transaction payload based on the data argument and returns
|
|
@@ -257,14 +251,9 @@ export async function generateRawTransaction(args: {
|
|
|
257
251
|
*/
|
|
258
252
|
export async function buildTransaction(
|
|
259
253
|
args: InputGenerateSingleSignerRawTransactionArgs,
|
|
260
|
-
): Promise<
|
|
261
|
-
export async function buildTransaction(
|
|
262
|
-
|
|
263
|
-
): Promise<InputFeePayerTransaction>;
|
|
264
|
-
export async function buildTransaction(
|
|
265
|
-
args: InputGenerateMultiAgentRawTransactionArgs,
|
|
266
|
-
): Promise<InputMultiAgentTransaction>;
|
|
267
|
-
export async function buildTransaction(args: InputGenerateRawTransactionArgs): Promise<AnyRawTransaction>;
|
|
254
|
+
): Promise<SingleSignerTransaction>;
|
|
255
|
+
export async function buildTransaction(args: InputGenerateMultiAgentRawTransactionArgs): Promise<MultiAgentTransaction>;
|
|
256
|
+
|
|
268
257
|
/**
|
|
269
258
|
* Generates a transaction based on the provided arguments
|
|
270
259
|
*
|
|
@@ -297,18 +286,7 @@ export async function buildTransaction(args: InputGenerateRawTransactionArgs): P
|
|
|
297
286
|
options,
|
|
298
287
|
});
|
|
299
288
|
|
|
300
|
-
if
|
|
301
|
-
const signers: Array<AccountAddress> =
|
|
302
|
-
args.secondarySignerAddresses?.map((signer) => AccountAddress.fromRelaxed(signer)) ?? [];
|
|
303
|
-
|
|
304
|
-
return {
|
|
305
|
-
rawTransaction: rawTxn,
|
|
306
|
-
secondarySignerAddresses: signers,
|
|
307
|
-
feePayerAddress:
|
|
308
|
-
args?.feePayerAddress !== undefined ? AccountAddress.fromRelaxed(args.feePayerAddress) : undefined,
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
|
|
289
|
+
// if multi agent transaction
|
|
312
290
|
if ("secondarySignerAddresses" in args) {
|
|
313
291
|
const signers: Array<AccountAddress> =
|
|
314
292
|
args.secondarySignerAddresses?.map((signer) => AccountAddress.fromRelaxed(signer)) ?? [];
|
|
@@ -316,10 +294,14 @@ export async function buildTransaction(args: InputGenerateRawTransactionArgs): P
|
|
|
316
294
|
return {
|
|
317
295
|
rawTransaction: rawTxn,
|
|
318
296
|
secondarySignerAddresses: signers,
|
|
297
|
+
feePayerAddress: args.feePayerAddress ? AccountAddress.fromRelaxed(args.feePayerAddress) : undefined,
|
|
319
298
|
};
|
|
320
299
|
}
|
|
321
300
|
// return the raw transaction
|
|
322
|
-
return {
|
|
301
|
+
return {
|
|
302
|
+
rawTransaction: rawTxn,
|
|
303
|
+
feePayerAddress: args.feePayerAddress ? AccountAddress.fromRelaxed(args.feePayerAddress) : undefined,
|
|
304
|
+
};
|
|
323
305
|
}
|
|
324
306
|
|
|
325
307
|
/**
|
|
@@ -336,25 +318,21 @@ export async function buildTransaction(args: InputGenerateRawTransactionArgs): P
|
|
|
336
318
|
export function generateSignedTransactionForSimulation(args: InputSimulateTransactionData): Uint8Array {
|
|
337
319
|
const { signerPublicKey, transaction, secondarySignersPublicKeys, feePayerPublicKey } = args;
|
|
338
320
|
|
|
339
|
-
const deserializer = new Deserializer(transaction.rawTransaction.bcsToBytes());
|
|
340
|
-
const deserializedTransaction = RawTransaction.deserialize(deserializer);
|
|
341
|
-
|
|
342
321
|
const accountAuthenticator = getAuthenticatorForSimulation(signerPublicKey);
|
|
322
|
+
|
|
343
323
|
// fee payer transaction
|
|
344
|
-
if (
|
|
324
|
+
if (transaction.feePayerAddress) {
|
|
345
325
|
const transactionToSign = new FeePayerRawTransaction(
|
|
346
|
-
|
|
326
|
+
transaction.rawTransaction,
|
|
347
327
|
transaction.secondarySignerAddresses ?? [],
|
|
348
328
|
transaction.feePayerAddress,
|
|
349
329
|
);
|
|
350
|
-
|
|
351
330
|
let secondaryAccountAuthenticators: Array<AccountAuthenticator> = [];
|
|
352
331
|
if (secondarySignersPublicKeys) {
|
|
353
332
|
secondaryAccountAuthenticators = secondarySignersPublicKeys.map((publicKey) =>
|
|
354
333
|
getAuthenticatorForSimulation(publicKey),
|
|
355
334
|
);
|
|
356
335
|
}
|
|
357
|
-
|
|
358
336
|
const feePayerAuthenticator = getAuthenticatorForSimulation(feePayerPublicKey!);
|
|
359
337
|
|
|
360
338
|
const transactionAuthenticator = new TransactionAuthenticatorFeePayer(
|
|
@@ -370,9 +348,9 @@ export function generateSignedTransactionForSimulation(args: InputSimulateTransa
|
|
|
370
348
|
}
|
|
371
349
|
|
|
372
350
|
// multi agent transaction
|
|
373
|
-
if (
|
|
351
|
+
if (transaction.secondarySignerAddresses) {
|
|
374
352
|
const transactionToSign = new MultiAgentRawTransaction(
|
|
375
|
-
|
|
353
|
+
transaction.rawTransaction,
|
|
376
354
|
transaction.secondarySignerAddresses,
|
|
377
355
|
);
|
|
378
356
|
|
|
@@ -391,7 +369,7 @@ export function generateSignedTransactionForSimulation(args: InputSimulateTransa
|
|
|
391
369
|
return new SignedTransaction(transactionToSign.raw_txn, transactionAuthenticator).bcsToBytes();
|
|
392
370
|
}
|
|
393
371
|
|
|
394
|
-
// raw transaction
|
|
372
|
+
// single signer raw transaction
|
|
395
373
|
let transactionAuthenticator;
|
|
396
374
|
if (accountAuthenticator instanceof AccountAuthenticatorEd25519) {
|
|
397
375
|
transactionAuthenticator = new TransactionAuthenticatorEd25519(
|
|
@@ -403,7 +381,7 @@ export function generateSignedTransactionForSimulation(args: InputSimulateTransa
|
|
|
403
381
|
} else {
|
|
404
382
|
throw new Error("Invalid public key");
|
|
405
383
|
}
|
|
406
|
-
return new SignedTransaction(
|
|
384
|
+
return new SignedTransaction(transaction.rawTransaction, transactionAuthenticator).bcsToBytes();
|
|
407
385
|
}
|
|
408
386
|
|
|
409
387
|
export function getAuthenticatorForSimulation(publicKey: PublicKey) {
|
|
@@ -418,7 +396,6 @@ export function getAuthenticatorForSimulation(publicKey: PublicKey) {
|
|
|
418
396
|
}
|
|
419
397
|
|
|
420
398
|
// legacy code
|
|
421
|
-
// TODO add support to legacy multied25519
|
|
422
399
|
return new AccountAuthenticatorEd25519(
|
|
423
400
|
new Ed25519PublicKey(publicKey.toUint8Array()),
|
|
424
401
|
new Ed25519Signature(new Uint8Array(64)),
|
|
@@ -514,14 +491,14 @@ export function generateSignedTransaction(args: InputSubmitTransactionData): Uin
|
|
|
514
491
|
* @returns FeePayerRawTransaction | MultiAgentRawTransaction | RawTransaction
|
|
515
492
|
*/
|
|
516
493
|
export function deriveTransactionType(transaction: AnyRawTransaction): AnyRawTransactionInstance {
|
|
517
|
-
if (
|
|
494
|
+
if (transaction.feePayerAddress) {
|
|
518
495
|
return new FeePayerRawTransaction(
|
|
519
496
|
transaction.rawTransaction,
|
|
520
497
|
transaction.secondarySignerAddresses ?? [],
|
|
521
498
|
transaction.feePayerAddress,
|
|
522
499
|
);
|
|
523
500
|
}
|
|
524
|
-
if (
|
|
501
|
+
if (transaction.secondarySignerAddresses) {
|
|
525
502
|
return new MultiAgentRawTransaction(transaction.rawTransaction, transaction.secondarySignerAddresses);
|
|
526
503
|
}
|
|
527
504
|
|
|
@@ -153,19 +153,7 @@ export interface InputGenerateSingleSignerRawTransactionArgs {
|
|
|
153
153
|
sender: AccountAddressInput;
|
|
154
154
|
payload: AnyTransactionPayloadInstance;
|
|
155
155
|
options?: InputGenerateTransactionOptions;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Interface of the arguments to generate a fee payer transaction.
|
|
160
|
-
* Used to provide to `generateTransaction()` method in the transaction builder flow
|
|
161
|
-
*/
|
|
162
|
-
export interface InputGenerateFeePayerRawTransactionArgs {
|
|
163
|
-
aptosConfig: AptosConfig;
|
|
164
|
-
sender: AccountAddressInput;
|
|
165
|
-
payload: AnyTransactionPayloadInstance;
|
|
166
|
-
feePayerAddress: AccountAddressInput;
|
|
167
|
-
secondarySignerAddresses?: AccountAddressInput[];
|
|
168
|
-
options?: InputGenerateTransactionOptions;
|
|
156
|
+
feePayerAddress?: AccountAddressInput;
|
|
169
157
|
}
|
|
170
158
|
|
|
171
159
|
/**
|
|
@@ -178,6 +166,7 @@ export interface InputGenerateMultiAgentRawTransactionArgs {
|
|
|
178
166
|
payload: AnyTransactionPayloadInstance;
|
|
179
167
|
secondarySignerAddresses: AccountAddressInput[];
|
|
180
168
|
options?: InputGenerateTransactionOptions;
|
|
169
|
+
feePayerAddress?: AccountAddressInput;
|
|
181
170
|
}
|
|
182
171
|
|
|
183
172
|
/**
|
|
@@ -185,7 +174,6 @@ export interface InputGenerateMultiAgentRawTransactionArgs {
|
|
|
185
174
|
*/
|
|
186
175
|
export type InputGenerateRawTransactionArgs =
|
|
187
176
|
| InputGenerateSingleSignerRawTransactionArgs
|
|
188
|
-
| InputGenerateFeePayerRawTransactionArgs
|
|
189
177
|
| InputGenerateMultiAgentRawTransactionArgs;
|
|
190
178
|
|
|
191
179
|
/**
|
|
@@ -193,21 +181,10 @@ export type InputGenerateRawTransactionArgs =
|
|
|
193
181
|
*
|
|
194
182
|
* @param rawTransaction a bcs serialized raw transaction
|
|
195
183
|
*/
|
|
196
|
-
export interface
|
|
184
|
+
export interface SingleSignerTransaction {
|
|
197
185
|
rawTransaction: RawTransaction;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Interface that holds the return data when generating a fee payer transaction
|
|
202
|
-
*
|
|
203
|
-
* @param rawTransaction a bcs serialized raw transaction
|
|
204
|
-
* @param secondarySignerAddresses optional. secondary signer addresses for multi-agent transaction
|
|
205
|
-
* @param feePayerAddress fee payer address for a fee payer transaction (aka Sponsored Transaction)
|
|
206
|
-
*/
|
|
207
|
-
export interface InputFeePayerTransaction {
|
|
208
|
-
rawTransaction: RawTransaction;
|
|
209
|
-
feePayerAddress: AccountAddress;
|
|
210
|
-
secondarySignerAddresses?: AccountAddress[];
|
|
186
|
+
feePayerAddress?: AccountAddress;
|
|
187
|
+
secondarySignerAddresses?: undefined;
|
|
211
188
|
}
|
|
212
189
|
|
|
213
190
|
/**
|
|
@@ -216,15 +193,16 @@ export interface InputFeePayerTransaction {
|
|
|
216
193
|
* @param rawTransaction a bcs serialized raw transaction
|
|
217
194
|
* @param secondarySignerAddresses secondary signer addresses for multi-agent transaction
|
|
218
195
|
*/
|
|
219
|
-
export interface
|
|
196
|
+
export interface MultiAgentTransaction {
|
|
220
197
|
rawTransaction: RawTransaction;
|
|
221
198
|
secondarySignerAddresses: AccountAddress[];
|
|
199
|
+
feePayerAddress?: AccountAddress;
|
|
222
200
|
}
|
|
223
201
|
|
|
224
202
|
/**
|
|
225
203
|
* Unified type that holds all the return interfaces when generating different transaction types
|
|
226
204
|
*/
|
|
227
|
-
export type AnyRawTransaction =
|
|
205
|
+
export type AnyRawTransaction = SingleSignerTransaction | MultiAgentTransaction;
|
|
228
206
|
|
|
229
207
|
// TRANSACTION SIMULATION TYPES //
|
|
230
208
|
|
|
@@ -261,19 +239,10 @@ export type InputSimulateTransactionOptions = {
|
|
|
261
239
|
*/
|
|
262
240
|
export interface InputGenerateSingleSignerRawTransactionData {
|
|
263
241
|
sender: AccountAddressInput;
|
|
264
|
-
options?: InputGenerateTransactionOptions;
|
|
265
242
|
data: InputGenerateTransactionPayloadData;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Interface that holds the user data input when generating a fee payer transaction
|
|
270
|
-
*/
|
|
271
|
-
export interface InputGenerateFeePayerRawTransactionData {
|
|
272
|
-
sender: AccountAddressInput;
|
|
273
|
-
hasFeePayer: true;
|
|
274
|
-
secondarySignerAddresses?: AccountAddressInput[];
|
|
275
243
|
options?: InputGenerateTransactionOptions;
|
|
276
|
-
|
|
244
|
+
withFeePayer?: boolean;
|
|
245
|
+
secondarySignerAddresses?: undefined;
|
|
277
246
|
}
|
|
278
247
|
|
|
279
248
|
/**
|
|
@@ -281,18 +250,18 @@ export interface InputGenerateFeePayerRawTransactionData {
|
|
|
281
250
|
*/
|
|
282
251
|
export interface InputGenerateMultiAgentRawTransactionData {
|
|
283
252
|
sender: AccountAddressInput;
|
|
253
|
+
data: InputGenerateTransactionPayloadData;
|
|
284
254
|
secondarySignerAddresses: AccountAddressInput[];
|
|
285
255
|
options?: InputGenerateTransactionOptions;
|
|
286
|
-
|
|
256
|
+
withFeePayer?: boolean;
|
|
287
257
|
}
|
|
288
258
|
|
|
289
259
|
/**
|
|
290
260
|
* Unified type that holds all the user data input interfaces when generating different transaction types
|
|
291
261
|
*/
|
|
292
262
|
export type InputGenerateTransactionData =
|
|
293
|
-
|
|
|
294
|
-
|
|
|
295
|
-
| InputGenerateSingleSignerRawTransactionData;
|
|
263
|
+
| InputGenerateSingleSignerRawTransactionData
|
|
264
|
+
| InputGenerateMultiAgentRawTransactionData;
|
|
296
265
|
|
|
297
266
|
/**
|
|
298
267
|
* Interface that holds the user data input when submitting a transaction
|
|
@@ -18,6 +18,16 @@ export type TokenActivitiesFieldsFragment = {
|
|
|
18
18
|
type: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
export type AnsTokenFragmentFragment = {
|
|
22
|
+
domain?: string | null;
|
|
23
|
+
expiration_timestamp?: any | null;
|
|
24
|
+
registered_address?: string | null;
|
|
25
|
+
subdomain?: string | null;
|
|
26
|
+
token_standard?: string | null;
|
|
27
|
+
is_primary?: boolean | null;
|
|
28
|
+
owner_address?: string | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
21
31
|
export type CurrentTokenOwnershipFieldsFragment = {
|
|
22
32
|
token_standard: string;
|
|
23
33
|
token_properties_mutated_v1?: any | null;
|
|
@@ -485,6 +495,25 @@ export type GetFungibleAssetMetadataQuery = {
|
|
|
485
495
|
}>;
|
|
486
496
|
};
|
|
487
497
|
|
|
498
|
+
export type GetNamesQueryVariables = Types.Exact<{
|
|
499
|
+
offset?: Types.InputMaybe<Types.Scalars["Int"]["input"]>;
|
|
500
|
+
limit?: Types.InputMaybe<Types.Scalars["Int"]["input"]>;
|
|
501
|
+
where_condition?: Types.InputMaybe<Types.CurrentAptosNamesBoolExp>;
|
|
502
|
+
order_by?: Types.InputMaybe<Array<Types.CurrentAptosNamesOrderBy> | Types.CurrentAptosNamesOrderBy>;
|
|
503
|
+
}>;
|
|
504
|
+
|
|
505
|
+
export type GetNamesQuery = {
|
|
506
|
+
current_aptos_names: Array<{
|
|
507
|
+
domain?: string | null;
|
|
508
|
+
expiration_timestamp?: any | null;
|
|
509
|
+
registered_address?: string | null;
|
|
510
|
+
subdomain?: string | null;
|
|
511
|
+
token_standard?: string | null;
|
|
512
|
+
is_primary?: boolean | null;
|
|
513
|
+
owner_address?: string | null;
|
|
514
|
+
}>;
|
|
515
|
+
};
|
|
516
|
+
|
|
488
517
|
export type GetNumberOfDelegatorsQueryVariables = Types.Exact<{
|
|
489
518
|
where_condition: Types.NumActiveDelegatorPerPoolBoolExp;
|
|
490
519
|
order_by?: Types.InputMaybe<Array<Types.NumActiveDelegatorPerPoolOrderBy> | Types.NumActiveDelegatorPerPoolOrderBy>;
|
|
@@ -21,6 +21,17 @@ export const TokenActivitiesFieldsFragmentDoc = `
|
|
|
21
21
|
type
|
|
22
22
|
}
|
|
23
23
|
`;
|
|
24
|
+
export const AnsTokenFragmentFragmentDoc = `
|
|
25
|
+
fragment AnsTokenFragment on current_aptos_names {
|
|
26
|
+
domain
|
|
27
|
+
expiration_timestamp
|
|
28
|
+
registered_address
|
|
29
|
+
subdomain
|
|
30
|
+
token_standard
|
|
31
|
+
is_primary
|
|
32
|
+
owner_address
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
24
35
|
export const CurrentTokenOwnershipFieldsFragmentDoc = `
|
|
25
36
|
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
|
|
26
37
|
token_standard
|
|
@@ -348,6 +359,18 @@ export const GetFungibleAssetMetadata = `
|
|
|
348
359
|
}
|
|
349
360
|
}
|
|
350
361
|
`;
|
|
362
|
+
export const GetNames = `
|
|
363
|
+
query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
|
|
364
|
+
current_aptos_names(
|
|
365
|
+
limit: $limit
|
|
366
|
+
where: $where_condition
|
|
367
|
+
order_by: $order_by
|
|
368
|
+
offset: $offset
|
|
369
|
+
) {
|
|
370
|
+
...AnsTokenFragment
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
${AnsTokenFragmentFragmentDoc}`;
|
|
351
374
|
export const GetNumberOfDelegators = `
|
|
352
375
|
query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp!, $order_by: [num_active_delegator_per_pool_order_by!]) {
|
|
353
376
|
num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
|
|
@@ -663,6 +686,17 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper =
|
|
|
663
686
|
"query",
|
|
664
687
|
);
|
|
665
688
|
},
|
|
689
|
+
getNames(
|
|
690
|
+
variables?: Types.GetNamesQueryVariables,
|
|
691
|
+
requestHeaders?: GraphQLClientRequestHeaders,
|
|
692
|
+
): Promise<Types.GetNamesQuery> {
|
|
693
|
+
return withWrapper(
|
|
694
|
+
(wrappedRequestHeaders) =>
|
|
695
|
+
client.request<Types.GetNamesQuery>(GetNames, variables, { ...requestHeaders, ...wrappedRequestHeaders }),
|
|
696
|
+
"getNames",
|
|
697
|
+
"query",
|
|
698
|
+
);
|
|
699
|
+
},
|
|
666
700
|
getNumberOfDelegators(
|
|
667
701
|
variables: Types.GetNumberOfDelegatorsQueryVariables,
|
|
668
702
|
requestHeaders?: GraphQLClientRequestHeaders,
|
package/src/types/indexer.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
GetCurrentFungibleAssetBalancesQuery,
|
|
30
30
|
GetTokenActivityQuery,
|
|
31
31
|
GetCurrentTokenOwnershipQuery,
|
|
32
|
+
GetNamesQuery,
|
|
32
33
|
} from "./generated/operations";
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -66,6 +67,8 @@ export type GetTokenActivityResponse = GetTokenActivityQuery["token_activities_v
|
|
|
66
67
|
export type GetCurrentTokenOwnershipResponse = GetCurrentTokenOwnershipQuery["current_token_ownerships_v2"][0];
|
|
67
68
|
export type GetOwnedTokensResponse = GetCurrentTokenOwnershipQuery["current_token_ownerships_v2"];
|
|
68
69
|
|
|
70
|
+
export type GetANSNameResponse = GetNamesQuery["current_aptos_names"];
|
|
71
|
+
|
|
69
72
|
/**
|
|
70
73
|
* A generic type that being passed by each function and holds an
|
|
71
74
|
* array of properties we can sort the query by
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as A}from"./chunk-Y5DJPHJT.mjs";import{e as l}from"./chunk-7MNEEVXY.mjs";import{b as p,c}from"./chunk-4ADA5BE7.mjs";import{e as m}from"./chunk-X32O46IB.mjs";import{b as s}from"./chunk-NZIJV4O2.mjs";var g=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function w(e){return!(!e||e.length<3||e.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(e))}function y(e){let[o,n,...r]=e.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${e} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!w(o))throw new Error(`${o} is not valid. ${g}`);if(n&&!w(n))throw new Error(`${n} is not valid. ${g}`);return{domainName:n||o,subdomainName:n?o:void 0}}var L="0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221",h="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",v={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:h,custom:null,devnet:null};function b(e){let o=v[e.network];if(!o)throw new Error(`The ANS contract is not deployed to ${e.network}`);return o}var C=e=>({vec:[e]}),E=()=>({vec:[]}),x=e=>e!=null?C(e):E(),_=e=>{if(e&&typeof e=="object"&&"vec"in e&&Array.isArray(e.vec))return e.vec[0]};async function U(e){let{aptosConfig:o,name:n}=e,r=b(o),{domainName:d,subdomainName:t}=y(n),a=await l({aptosConfig:o,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[d,x(t)]}}),i=_(a[0]);return i?s.fromRelaxed(i).toString():void 0}async function k(e){let{aptosConfig:o,expiration:n,name:r,sender:d,targetAddress:t,toAddress:a,options:i}=e,N=b(o),{domainName:T,subdomainName:u}=y(r),f=n.policy==="subdomain:independent"||n.policy==="subdomain:follow-domain";if(u&&!f)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(f&&!u)throw new Error(`Policy is set to ${n.policy} but no subdomain was provided`);if(n.policy==="domain"){if(n.years!==1)throw new Error("For now, names can only be registered for 1 year at a time");let S=n.years*31536e3;return await A({aptosConfig:o,sender:d.accountAddress.toString(),data:{function:`${N}::router::register_domain`,functionArguments:[new p(T),new m(S),new c(t?s.from(t):null),new c(a?s.from(a):null)]},options:i})}throw new Error(`Policy ${n.policy} is not supported yet`)}export{g as a,w as b,y as c,L as d,h as e,U as f,k as g};
|
|
2
|
-
//# sourceMappingURL=chunk-BP5ZO7NK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/internal/ans.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/name}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * name namespace and without having a dependency cycle error.\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { MoveOption, MoveString, U64 } from \"../bcs\";\nimport { Account, AccountAddress } from \"../core\";\nimport { InputGenerateTransactionOptions, InputSingleSignerTransaction } from \"../transactions/types\";\nimport { HexInput, MoveAddressType, MoveValue } from \"../types\";\nimport { Network } from \"../utils/apiEndpoints\";\nimport { view } from \"./general\";\nimport { generateTransaction } from \"./transactionSubmission\";\n\nexport const VALIDATION_RULES_DESCRIPTION = [\n \"A name must be between 3 and 63 characters long,\",\n \"and can only contain lowercase a-z, 0-9, and hyphens.\",\n \"A name may not start or end with a hyphen.\",\n].join(\" \");\n\n/**\n *\n * @param fragment A fragment of a name, either the domain or subdomain\n * @returns boolean indicating if the fragment is a valid fragment\n */\nexport function isValidANSSegment(fragment: string): boolean {\n if (!fragment) return false;\n if (fragment.length < 3) return false;\n if (fragment.length > 63) return false;\n // only lowercase a-z and 0-9 are allowed, along with -. a domain may not start or end with a hyphen\n if (!/^[a-z\\d][a-z\\d-]{1,61}[a-z\\d]$/.test(fragment)) return false;\n return true;\n}\n\n/**\n * Checks if an ANS name is valid or not\n *\n * @param name A string of the domain name, can include or exclude the .apt suffix\n */\nexport function isValidANSName(name: string): { domainName: string; subdomainName?: string } {\n const [first, second, ...rest] = name.replace(/\\.apt$/, \"\").split(\".\");\n\n if (rest.length > 0) {\n throw new Error(`${name} is invalid. A name can only have two parts, a domain and a subdomain separated by a \".\"`);\n }\n\n if (!isValidANSSegment(first)) {\n throw new Error(`${first} is not valid. ${VALIDATION_RULES_DESCRIPTION}`);\n }\n\n if (second && !isValidANSSegment(second)) {\n throw new Error(`${second} is not valid. ${VALIDATION_RULES_DESCRIPTION}`);\n }\n\n return {\n domainName: second || first,\n subdomainName: second ? first : undefined,\n };\n}\n\nexport const LOCAL_ANS_ACCOUNT_PK =\n process.env.ANS_TEST_ACCOUNT_PRIVATE_KEY ?? \"0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221\";\nexport const LOCAL_ANS_ACCOUNT_ADDRESS =\n process.env.ANS_TEST_ACCOUNT_ADDRESS ?? \"0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82\";\n\nconst NetworkToAnsContract: Record<Network, string | null> = {\n [Network.TESTNET]: \"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c\",\n [Network.MAINNET]: \"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c\",\n [Network.LOCAL]: LOCAL_ANS_ACCOUNT_ADDRESS,\n [Network.CUSTOM]: null,\n [Network.DEVNET]: null,\n};\n\nfunction getRouterAddress(aptosConfig: AptosConfig): string {\n const address = NetworkToAnsContract[aptosConfig.network];\n if (!address) throw new Error(`The ANS contract is not deployed to ${aptosConfig.network}`);\n return address;\n}\n\nconst Some = <T>(value: T): MoveValue => ({ vec: [value] }) as any;\nconst None = (): MoveValue => ({ vec: [] }) as any;\n// != here is intentional, we want to check for null and undefined\n// eslint-disable-next-line eqeqeq\nconst Option = <T>(value: T | undefined | null): MoveValue => (value != undefined ? Some(value) : None());\n\nconst unwrapOption = <T>(option: any): T | undefined => {\n if (!!option && typeof option === \"object\" && \"vec\" in option && Array.isArray(option.vec)) {\n return option.vec[0];\n }\n\n return undefined;\n};\n\nexport async function getOwnerAddress(args: { aptosConfig: AptosConfig; name: string }): Promise<string | undefined> {\n const { aptosConfig, name } = args;\n const routerAddress = getRouterAddress(aptosConfig);\n const { domainName, subdomainName } = isValidANSName(name);\n\n const res = await view({\n aptosConfig,\n payload: {\n function: `${routerAddress}::router::get_owner_addr`,\n functionArguments: [domainName, Option(subdomainName)],\n },\n });\n\n const owner = unwrapOption<MoveAddressType>(res[0]);\n\n return owner ? AccountAddress.fromRelaxed(owner).toString() : undefined;\n}\n\nexport interface RegisterNameParameters {\n aptosConfig: AptosConfig;\n sender: Account;\n name: string;\n expiration:\n | { policy: \"domain\"; years: 1 }\n | { policy: \"subdomain:follow-domain\" }\n | { policy: \"subdomain:independent\"; expirationDate: Date };\n transferable?: boolean;\n toAddress?: HexInput;\n targetAddress?: HexInput;\n options?: InputGenerateTransactionOptions;\n}\n\nexport async function registerName(args: RegisterNameParameters): Promise<InputSingleSignerTransaction> {\n const { aptosConfig, expiration, name, sender, targetAddress, toAddress, options } = args;\n const routerAddress = getRouterAddress(aptosConfig);\n const { domainName, subdomainName } = isValidANSName(name);\n\n const hasSubdomainPolicy =\n expiration.policy === \"subdomain:independent\" || expiration.policy === \"subdomain:follow-domain\";\n\n if (subdomainName && !hasSubdomainPolicy) {\n throw new Error(\n \"Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'\",\n );\n }\n\n if (hasSubdomainPolicy && !subdomainName) {\n throw new Error(`Policy is set to ${expiration.policy} but no subdomain was provided`);\n }\n\n if (expiration.policy === \"domain\") {\n if (expiration.years !== 1) {\n throw new Error(\"For now, names can only be registered for 1 year at a time\");\n }\n\n const registrationDuration = expiration.years * 31536000;\n\n const transaction = await generateTransaction({\n aptosConfig,\n sender: sender.accountAddress.toString(),\n data: {\n function: `${routerAddress}::router::register_domain`,\n functionArguments: [\n new MoveString(domainName),\n new U64(registrationDuration),\n new MoveOption(targetAddress ? AccountAddress.from(targetAddress) : null),\n new MoveOption(toAddress ? AccountAddress.from(toAddress) : null),\n ],\n },\n options,\n });\n\n return transaction as InputSingleSignerTransaction;\n }\n\n throw new Error(`Policy ${expiration.policy} is not supported yet`);\n}\n"],"mappings":"+MAmBO,IAAMA,EAA+B,CAC1C,mDACA,wDACA,4CACF,EAAE,KAAK,GAAG,EAOH,SAASC,EAAkBC,EAA2B,CAK3D,MAJI,GAACA,GACDA,EAAS,OAAS,GAClBA,EAAS,OAAS,IAElB,CAAC,iCAAiC,KAAKA,CAAQ,EAErD,CAOO,SAASC,EAAeC,EAA8D,CAC3F,GAAM,CAACC,EAAOC,EAAQ,GAAGC,CAAI,EAAIH,EAAK,QAAQ,SAAU,EAAE,EAAE,MAAM,GAAG,EAErE,GAAIG,EAAK,OAAS,EAChB,MAAM,IAAI,MAAM,GAAGH,CAAI,0FAA0F,EAGnH,GAAI,CAACH,EAAkBI,CAAK,EAC1B,MAAM,IAAI,MAAM,GAAGA,CAAK,kBAAkBL,CAA4B,EAAE,EAG1E,GAAIM,GAAU,CAACL,EAAkBK,CAAM,EACrC,MAAM,IAAI,MAAM,GAAGA,CAAM,kBAAkBN,CAA4B,EAAE,EAG3E,MAAO,CACL,WAAYM,GAAUD,EACtB,cAAeC,EAASD,EAAQ,MAClC,CACF,CAEO,IAAMG,EACX,qEACWC,EACX,qEAEIC,EAAuD,CAC1D,QAAkB,qEAClB,QAAkB,qEAClB,MAAgBD,EAChB,OAAiB,KACjB,OAAiB,IACpB,EAEA,SAASE,EAAiBC,EAAkC,CAC1D,IAAMC,EAAUH,EAAqBE,EAAY,OAAO,EACxD,GAAI,CAACC,EAAS,MAAM,IAAI,MAAM,uCAAuCD,EAAY,OAAO,EAAE,EAC1F,OAAOC,CACT,CAEA,IAAMC,EAAWC,IAAyB,CAAE,IAAK,CAACA,CAAK,CAAE,GACnDC,EAAO,KAAkB,CAAE,IAAK,CAAC,CAAE,GAGnCC,EAAaF,GAA4CA,GAAS,KAAYD,EAAKC,CAAK,EAAIC,EAAK,EAEjGE,EAAmBC,GAA+B,CACtD,GAAMA,GAAU,OAAOA,GAAW,UAAY,QAASA,GAAU,MAAM,QAAQA,EAAO,GAAG,EACvF,OAAOA,EAAO,IAAI,CAAC,CAIvB,EAEA,eAAsBC,EAAgBC,EAA+E,CACnH,GAAM,CAAE,YAAAT,EAAa,KAAAR,CAAK,EAAIiB,EACxBC,EAAgBX,EAAiBC,CAAW,EAC5C,CAAE,WAAAW,EAAY,cAAAC,CAAc,EAAIrB,EAAeC,CAAI,EAEnDqB,EAAM,MAAMC,EAAK,CACrB,YAAAd,EACA,QAAS,CACP,SAAU,GAAGU,CAAa,2BAC1B,kBAAmB,CAACC,EAAYN,EAAOO,CAAa,CAAC,CACvD,CACF,CAAC,EAEKG,EAAQT,EAA8BO,EAAI,CAAC,CAAC,EAElD,OAAOE,EAAQC,EAAe,YAAYD,CAAK,EAAE,SAAS,EAAI,MAChE,CAgBA,eAAsBE,EAAaR,EAAqE,CACtG,GAAM,CAAE,YAAAT,EAAa,WAAAkB,EAAY,KAAA1B,EAAM,OAAA2B,EAAQ,cAAAC,EAAe,UAAAC,EAAW,QAAAC,CAAQ,EAAIb,EAC/EC,EAAgBX,EAAiBC,CAAW,EAC5C,CAAE,WAAAW,EAAY,cAAAC,CAAc,EAAIrB,EAAeC,CAAI,EAEnD+B,EACJL,EAAW,SAAW,yBAA2BA,EAAW,SAAW,0BAEzE,GAAIN,GAAiB,CAACW,EACpB,MAAM,IAAI,MACR,0GACF,EAGF,GAAIA,GAAsB,CAACX,EACzB,MAAM,IAAI,MAAM,oBAAoBM,EAAW,MAAM,gCAAgC,EAGvF,GAAIA,EAAW,SAAW,SAAU,CAClC,GAAIA,EAAW,QAAU,EACvB,MAAM,IAAI,MAAM,4DAA4D,EAG9E,IAAMM,EAAuBN,EAAW,MAAQ,QAiBhD,OAfoB,MAAMO,EAAoB,CAC5C,YAAAzB,EACA,OAAQmB,EAAO,eAAe,SAAS,EACvC,KAAM,CACJ,SAAU,GAAGT,CAAa,4BAC1B,kBAAmB,CACjB,IAAIgB,EAAWf,CAAU,EACzB,IAAIgB,EAAIH,CAAoB,EAC5B,IAAII,EAAWR,EAAgBJ,EAAe,KAAKI,CAAa,EAAI,IAAI,EACxE,IAAIQ,EAAWP,EAAYL,EAAe,KAAKK,CAAS,EAAI,IAAI,CAClE,CACF,EACA,QAAAC,CACF,CAAC,CAGH,CAEA,MAAM,IAAI,MAAM,UAAUJ,EAAW,MAAM,uBAAuB,CACpE","names":["VALIDATION_RULES_DESCRIPTION","isValidANSSegment","fragment","isValidANSName","name","first","second","rest","LOCAL_ANS_ACCOUNT_PK","LOCAL_ANS_ACCOUNT_ADDRESS","NetworkToAnsContract","getRouterAddress","aptosConfig","address","Some","value","None","Option","unwrapOption","option","getOwnerAddress","args","routerAddress","domainName","subdomainName","res","view","owner","AccountAddress","registerName","expiration","sender","targetAddress","toAddress","options","hasSubdomainPolicy","registrationDuration","generateTransaction","MoveString","U64","MoveOption"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/digitalAsset.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n GetCollectionDataResponse,\n GetCurrentTokenOwnershipResponse,\n GetOwnedTokensResponse,\n GetTokenActivityResponse,\n GetTokenDataResponse,\n OrderBy,\n PaginationArgs,\n TokenStandard,\n} from \"../types\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { Account, AccountAddressInput } from \"../core\";\nimport { InputGenerateTransactionOptions, InputSingleSignerTransaction } from \"../transactions/types\";\nimport {\n CreateCollectionOptions,\n createCollectionTransaction,\n getCollectionData,\n getCollectionId,\n getCurrentTokenOwnership,\n getOwnedTokens,\n getTokenActivity,\n getTokenData,\n mintTokenTransaction,\n} from \"../internal/digitalAsset\";\n\n/**\n * A class to query all `DigitalAsset` related queries on Aptos.\n */\nexport class DigitalAsset {\n readonly config: AptosConfig;\n\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Creates a new collection within the specified account\n *\n * @param args.creator the account of the collection's creator\n * @param args.description the description of the collection\n * @param args.name the name of the collection\n * @param args.uri the URI to additional info about the collection\n *\n * The parameters below are optional.\n * @param args.maxSupply controls the max supply of the tokens - defaults MAX_U64_BIG_INT\n * @param args.mutableDescription controls mutability of the collection's description - defaults true\n * @param args.mutableRoyalty controls mutability of the collection's description - defaults true\n * @param args.mutableUri controls mutability of the collection's URI - defaults true\n * @param args.mutableTokenDescription controls mutability of the token's description - defaults true\n * @param args.mutableTokenName controls mutability of the token's name - defaults true\n * @param args.mutableTokenProperties controls mutability of token's properties - defaults true\n * @param args.mutableTokenUri controls mutability of the token's URI - defaults true\n * @param args.tokensBurnableByCreator controls whether tokens can be burnable by the creator - defaults true\n * @param args.tokensFreezableByCreator controls whether tokens can be frozen by the creator - defaults true\n * @param args.royaltyNumerator the numerator of the royalty to be paid to the creator when a token is transferred - defaults 0\n * @param args.royaltyDenominator the denominator of the royalty to be paid to the creator when a token is transferred -\n * defaults 1\n *\n * @returns A SingleSignerTransaction that when submitted will create the collection.\n */\n async createCollectionTransaction(\n args: {\n creator: Account;\n description: string;\n name: string;\n uri: string;\n options?: InputGenerateTransactionOptions;\n } & CreateCollectionOptions,\n ): Promise<InputSingleSignerTransaction> {\n return createCollectionTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries data of a specific collection by the collection creator address and the collection name.\n *\n * If, for some reason, a creator account has 2 collections with the same name in v1 and v2,\n * can pass an optional `tokenStandard` parameter to query a specific standard\n *\n * @param args.creatorAddress the address of the collection's creator\n * @param args.collectionName the name of the collection\n * @param args.options.tokenStandard the token standard to query\n * @returns GetCollectionDataResponse response type\n */\n async getCollectionData(args: {\n creatorAddress: AccountAddressInput;\n collectionName: string;\n options?: {\n tokenStandard?: TokenStandard;\n };\n }): Promise<GetCollectionDataResponse> {\n return getCollectionData({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries a collection's ID.\n *\n * This is the same as the collection's object address in V2, but V1 does\n * not use objects, and does not have an address\n *\n * @param args.creatorAddress the address of the collection's creator\n * @param args.collectionName the name of the collection\n * @param args.options.tokenStandard the token standard to query\n * @returns the collection id\n */\n async getCollectionId(args: {\n creatorAddress: AccountAddressInput;\n collectionName: string;\n options?: {\n tokenStandard?: TokenStandard;\n };\n }): Promise<string> {\n return getCollectionId({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Create a transaction to mint a token into the creators account within an existing collection.\n *\n * @param args.creator the creator of the collection\n * @param args.collection the name of the collection the token belongs to\n * @param args.description the description of the token\n * @param args.name the name of the token\n * @param args.uri the URI to additional info about the token\n *\n * @returns A SingleSignerTransaction that can be simulated or submitted to chain\n */\n async mintTokenTransaction(args: {\n creator: Account;\n collection: string;\n description: string;\n name: string;\n uri: string;\n options?: InputGenerateTransactionOptions;\n }): Promise<InputSingleSignerTransaction> {\n return mintTokenTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Gets token data given the address of a token.\n *\n * @param args.tokenAddress The address of the token\n * @returns GetTokenDataResponse containing relevant data to the token.\n */\n async getTokenData(args: { tokenAddress: AccountAddressInput }): Promise<GetTokenDataResponse> {\n return getTokenData({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Gets token ownership data given the address of a token.\n *\n * @param args.tokenAddress The address of the token\n * @returns GetCurrentTokenOwnershipResponse containing relevant ownership data of the token.\n */\n async getCurrentTokenOwnership(args: {\n tokenAddress: AccountAddressInput;\n }): Promise<GetCurrentTokenOwnershipResponse> {\n return getCurrentTokenOwnership({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Gets the tokens that the given address owns.\n *\n * @param args.ownerAddress The address of the owner\n * @returns GetOwnedTokensResponse containing ownership data of the tokens belonging to the ownerAddresss.\n */\n async getOwnedTokens(args: {\n ownerAddress: AccountAddressInput;\n options?: {\n pagination?: PaginationArgs;\n orderBy?: OrderBy<GetOwnedTokensResponse[0]>;\n };\n }): Promise<GetOwnedTokensResponse> {\n return getOwnedTokens({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Gets the activity data given the address of a token.\n *\n * @param args.tokenAddress The address of the token\n * @returns GetTokenActivityResponse containing relevant activity data to the token.\n */\n async getTokenActivity(args: {\n tokenAddress: AccountAddressInput;\n options?: {\n pagination?: PaginationArgs;\n orderBy?: OrderBy<GetTokenActivityResponse[0]>;\n };\n }): Promise<GetTokenActivityResponse> {\n return getTokenActivity({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"0FA+BO,IAAMA,EAAN,KAAmB,CAGxB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CA2BA,MAAM,4BACJC,EAOuC,CACvC,OAAOC,EAA4B,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAC1E,CAaA,MAAM,kBAAkBA,EAMe,CACrC,OAAOE,EAAkB,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CAChE,CAaA,MAAM,gBAAgBA,EAMF,CAClB,OAAOG,EAAgB,CAAE,YAAa,KAAK,OAAQ,GAAGH,CAAK,CAAC,CAC9D,CAaA,MAAM,qBAAqBA,EAOe,CACxC,OAAOI,EAAqB,CAAE,YAAa,KAAK,OAAQ,GAAGJ,CAAK,CAAC,CACnE,CAQA,MAAM,aAAaA,EAA4E,CAC7F,OAAOK,EAAa,CAAE,YAAa,KAAK,OAAQ,GAAGL,CAAK,CAAC,CAC3D,CAQA,MAAM,yBAAyBA,EAEe,CAC5C,OAAOM,EAAyB,CAAE,YAAa,KAAK,OAAQ,GAAGN,CAAK,CAAC,CACvE,CAQA,MAAM,eAAeA,EAMe,CAClC,OAAOO,EAAe,CAAE,YAAa,KAAK,OAAQ,GAAGP,CAAK,CAAC,CAC7D,CAQA,MAAM,iBAAiBA,EAMe,CACpC,OAAOQ,EAAiB,CAAE,YAAa,KAAK,OAAQ,GAAGR,CAAK,CAAC,CAC/D,CACF","names":["DigitalAsset","config","args","createCollectionTransaction","getCollectionData","getCollectionId","mintTokenTransaction","getTokenData","getCurrentTokenOwnership","getOwnedTokens","getTokenActivity"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as r,b as s,c as i,d as o,e as c,f as u,g}from"./chunk-Y5DJPHJT.mjs";var p=class{constructor(n){this.config=n}async generateTransaction(n){return r({aptosConfig:this.config,...n})}signTransaction(n){let{signer:t,transaction:a,asFeePayer:e}=n;if("feePayerAddress"in a&&e)a.feePayerAddress=t.accountAddress;else if(e)throw new Error("Transaction being signed is not a Fee payer transaction, but `asFeePayer` is set to true");return s({signer:t,transaction:a})}async simulateTransaction(n){return i({aptosConfig:this.config,...n})}async submitTransaction(n){return o({aptosConfig:this.config,...n})}async signAndSubmitTransaction(n){let{signer:t,transaction:a}=n;return c({aptosConfig:this.config,signer:t,transaction:a})}async publishPackageTransaction(n){return u({aptosConfig:this.config,...n})}async rotateAuthKey(n){return g({aptosConfig:this.config,...n})}};export{p as a};
|
|
2
|
-
//# sourceMappingURL=chunk-EYXHVA6W.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/transactionSubmission.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"./aptosConfig\";\nimport { Account, AccountAddressInput, PrivateKey } from \"../core\";\nimport { AccountAuthenticator } from \"../transactions/authenticator/account\";\nimport {\n AnyRawTransaction,\n InputFeePayerTransaction,\n InputGenerateMultiAgentRawTransactionData,\n InputGenerateTransactionData,\n InputGenerateFeePayerRawTransactionData,\n InputGenerateSingleSignerRawTransactionData,\n InputMultiAgentTransaction,\n InputSingleSignerTransaction,\n InputSimulateTransactionData,\n InputGenerateTransactionOptions,\n InputSubmitTransactionData,\n} from \"../transactions/types\";\nimport { UserTransactionResponse, PendingTransactionResponse, HexInput, TransactionResponse } from \"../types\";\nimport {\n generateTransaction,\n publicPackageTransaction,\n rotateAuthKey,\n signAndSubmitTransaction,\n signTransaction,\n simulateTransaction,\n submitTransaction,\n} from \"../internal/transactionSubmission\";\n\nexport class TransactionSubmission {\n readonly config: AptosConfig;\n\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * We are defining function signatures, each with its specific input and output.\n * These are the possible function signature for `generateTransaction` function.\n * When we call `generateTransaction` function with the relevant type properties,\n * Typescript can infer the return type based on the appropriate function overload.\n */\n async generateTransaction(args: InputGenerateSingleSignerRawTransactionData): Promise<InputSingleSignerTransaction>;\n async generateTransaction(args: InputGenerateFeePayerRawTransactionData): Promise<InputFeePayerTransaction>;\n async generateTransaction(args: InputGenerateMultiAgentRawTransactionData): Promise<InputMultiAgentTransaction>;\n async generateTransaction(args: InputGenerateTransactionData): Promise<AnyRawTransaction>;\n\n /**\n * Generates any transaction by passing in the required arguments\n *\n * @param args.sender The transaction sender's account address as a AccountAddressInput\n * @param args.data EntryFunctionData | ScriptData | MultiSigData\n * @param args.feePayerAddress optional. For a fee payer (aka sponsored) transaction\n * @param args.secondarySignerAddresses optional. For a multi-agent or fee payer (aka sponsored) transactions\n * @param args.options optional. GenerateTransactionOptions type\n *\n * @example\n * For a single signer entry function\n * move function name, move function type arguments, move function arguments\n * `\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * typeArguments: []\n * functionArguments: [receiverAddress,10]\n * }\n * `\n *\n * @example\n * For a single signer script function\n * module bytecode, move function type arguments, move function arguments\n * ```\n * data: {\n * bytecode: \"0x001234567\",\n * typeArguments: [],\n * functionArguments: [receiverAddress,10]\n * }\n * ```\n *\n * @return An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses? : Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n */\n async generateTransaction(args: InputGenerateTransactionData): Promise<AnyRawTransaction> {\n return generateTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sign a transaction that can later be submitted to chain\n *\n * @param args.signer The signer account to sign the transaction\n * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * @param args.asFeePayer optional. If the signer is also the fee payer\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses?: Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n *\n * @return The signer AccountAuthenticator\n */\n /* eslint-disable class-methods-use-this */\n signTransaction(args: {\n signer: Account;\n transaction: AnyRawTransaction;\n asFeePayer?: boolean;\n }): AccountAuthenticator {\n const { signer, transaction, asFeePayer } = args;\n\n // Account can only sign as fee payer if it's a fee payer transaction\n if (\"feePayerAddress\" in transaction && asFeePayer) {\n transaction.feePayerAddress = signer.accountAddress;\n } else if (asFeePayer) {\n throw new Error(\"Transaction being signed is not a Fee payer transaction, but `asFeePayer` is set to true\");\n }\n\n return signTransaction({\n signer,\n transaction,\n });\n }\n\n /**\n * Simulates a transaction before singing it.\n *\n * @param args.signerPublicKey The signer public key\n * @param args.transaction The raw transaction to simulate\n * @param args.secondarySignersPublicKeys optional. For when the transaction is a multi signers transaction\n * @param args.feePayerPublicKey optional. For when the transaction is a fee payer (aka sponsored) transaction\n * @param args.options optional. A config to simulate the transaction with\n */\n async simulateTransaction(args: InputSimulateTransactionData): Promise<Array<UserTransactionResponse>> {\n return simulateTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Submit transaction to chain\n *\n * @param args.transaction A aptos transaction type\n * @param args.senderAuthenticator The account authenticator of the transaction sender\n * @param args.secondarySignerAuthenticators optional. For when the transaction is a multi signers transaction\n *\n * @return PendingTransactionResponse\n */\n async submitTransaction(args: InputSubmitTransactionData): Promise<PendingTransactionResponse> {\n return submitTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sign and submit a single signer transaction to chain\n *\n * @param args.signer The signer account to sign the transaction\n * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses? : Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n *\n * @return PendingTransactionResponse\n */\n async signAndSubmitTransaction(args: {\n signer: Account;\n transaction: AnyRawTransaction;\n }): Promise<PendingTransactionResponse> {\n const { signer, transaction } = args;\n return signAndSubmitTransaction({\n aptosConfig: this.config,\n signer,\n transaction,\n });\n }\n\n /**\n * Generates a transaction to publish a move package to chain.\n *\n * To get the `metadataBytes` and `byteCode`, can compile using Aptos CLI with command\n * `aptos move compile --save-metadata ...`,\n * For more info {@link https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module}\n *\n * @param args.account The publisher account\n * @param args.metadataBytes The package metadata bytes\n * @param args.moduleBytecode An array of the bytecode of each module in the package in compiler output order\n *\n * @returns A SingleSignerTransaction that can be simulated or submitted to chain\n */\n async publishPackageTransaction(args: {\n account: AccountAddressInput;\n metadataBytes: HexInput;\n moduleBytecode: Array<HexInput>;\n options?: InputGenerateTransactionOptions;\n }): Promise<InputSingleSignerTransaction> {\n return publicPackageTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Rotate an account's auth key. After rotation, only the new private key can be used to sign txns for\n * the account.\n * Note: Only legacy Ed25519 scheme is supported for now.\n * More info: {@link https://aptos.dev/guides/account-management/key-rotation/}\n * @param args.fromAccount The account to rotate the auth key for\n * @param args.toNewPrivateKey The new private key to rotate to\n *\n * @returns PendingTransactionResponse\n */\n async rotateAuthKey(args: { fromAccount: Account; toNewPrivateKey: PrivateKey }): Promise<TransactionResponse> {\n return rotateAuthKey({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"8EA8BO,IAAMA,EAAN,KAA4B,CAGjC,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAqDA,MAAM,oBAAoBC,EAAgE,CACxF,OAAOC,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAClE,CAmBA,gBAAgBA,EAIS,CACvB,GAAM,CAAE,OAAAE,EAAQ,YAAAC,EAAa,WAAAC,CAAW,EAAIJ,EAG5C,GAAI,oBAAqBG,GAAeC,EACtCD,EAAY,gBAAkBD,EAAO,uBAC5BE,EACT,MAAM,IAAI,MAAM,0FAA0F,EAG5G,OAAOC,EAAgB,CACrB,OAAAH,EACA,YAAAC,CACF,CAAC,CACH,CAWA,MAAM,oBAAoBH,EAA6E,CACrG,OAAOM,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGN,CAAK,CAAC,CAClE,CAWA,MAAM,kBAAkBA,EAAuE,CAC7F,OAAOO,EAAkB,CAAE,YAAa,KAAK,OAAQ,GAAGP,CAAK,CAAC,CAChE,CAiBA,MAAM,yBAAyBA,EAGS,CACtC,GAAM,CAAE,OAAAE,EAAQ,YAAAC,CAAY,EAAIH,EAChC,OAAOQ,EAAyB,CAC9B,YAAa,KAAK,OAClB,OAAAN,EACA,YAAAC,CACF,CAAC,CACH,CAeA,MAAM,0BAA0BH,EAKU,CACxC,OAAOS,EAAyB,CAAE,YAAa,KAAK,OAAQ,GAAGT,CAAK,CAAC,CACvE,CAYA,MAAM,cAAcA,EAA2F,CAC7G,OAAOU,EAAc,CAAE,YAAa,KAAK,OAAQ,GAAGV,CAAK,CAAC,CAC5D,CACF","names":["TransactionSubmission","config","args","generateTransaction","signer","transaction","asFeePayer","signTransaction","simulateTransaction","submitTransaction","signAndSubmitTransaction","publicPackageTransaction","rotateAuthKey"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{f as r,g as o}from"./chunk-BP5ZO7NK.mjs";var s=class{constructor(e){this.config=e}async getOwnerAddress(e){return r({aptosConfig:this.config,...e})}async registerName(e){return o({aptosConfig:this.config,...e})}};export{s as a};
|
|
2
|
-
//# sourceMappingURL=chunk-IG5CHHSI.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ans.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { RegisterNameParameters, getOwnerAddress, registerName } from \"../internal/ans\";\nimport { InputSingleSignerTransaction } from \"../transactions/types\";\nimport { MoveAddressType } from \"../types\";\nimport { AptosConfig } from \"./aptosConfig\";\n\n/**\n * A class to handle all `ANS` operations\n */\nexport class ANS {\n readonly config: AptosConfig;\n\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Retrieve the owner address of a domain name or subdomain name.\n *\n * ```ts\n * getOwnerAddress({name: \"test.aptos\"})\n * // Will return the owner address of \"test.aptos.apt\" or undefined\n * ```\n *\n * @param args.name - A string of the name to retrieve\n *\n * @returns MoveAddressType if the name is owned, undefined otherwise\n */\n async getOwnerAddress(args: { name: string }): Promise<MoveAddressType | undefined> {\n return getOwnerAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Registers a new domain or subdomain name\n *\n * @param args.sender - The sender account\n * @param args.name - A string or {domainName: string, subdomainName?: string} of the name to register. This\n * can be inclusive or exclusive of the .apt suffix.\n * Examples include: \"xyz\", \"xyz.apt\", \"xyz.kyc.apt\", {domainName: \"xyz\"}, {domainName: \"kyc\", subdomainName: \"xyz\"}.\n * @param args.expiration - An object with the expiration policy of the name.\n * @param args.expiration.policy - 'domain' | 'subdomain:follow-domain' | 'subdomain:independent'\n * - domain: Years is required and the name will expire after the given number of years.\n * - subdomain:follow-domain: The name will expire at the same time as the domain name.\n * - subdomain:independent: The name will expire at the given date.\n * @param args.transferable - Determines if the subdomain being minted is soul-bound. Applicable only to subdomains.\n * @param args.targetAddress optional - The address the domain name will resolve to. If not provided,\n * the sender's address will be used.\n * @param args.toAddress optional - The address to send the domain name to. If not provided,\n * the transaction will be sent to the router.\n *\n * @returns InputSingleSignerTransaction\n */\n async registerName(args: Omit<RegisterNameParameters, \"aptosConfig\">): Promise<InputSingleSignerTransaction> {\n return registerName({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"gDAWO,IAAMA,EAAN,KAAU,CAGf,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAcA,MAAM,gBAAgBC,EAA8D,CAClF,OAAOC,EAAgB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAC9D,CAsBA,MAAM,aAAaA,EAA0F,CAC3G,OAAOE,EAAa,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CAC3D,CACF","names":["ANS","config","args","getOwnerAddress","registerName"]}
|