@moveindustries/ts-sdk 5.1.4 → 5.1.6
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 +241 -43
- package/dist/common/{accountAddress-DoqkxUqw.d.ts → accountAddress-CQEq9RVR.d.ts} +6 -2
- package/dist/common/chunk-56DGDNEY.js.map +1 -1
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +393 -55
- package/dist/common/index.js +32 -32
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.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 +2 -2
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/{ans.d.mts → mns.d.mts} +390 -52
- package/dist/esm/api/mns.mjs +2 -0
- package/dist/esm/api/movement.d.mts +4 -4
- package/dist/esm/api/movement.mjs +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/{chunk-SYXDZA4K.mjs → chunk-46MDTYYN.mjs} +2 -2
- package/dist/esm/chunk-4OOPIIBY.mjs +4 -0
- package/dist/esm/{chunk-47V7UGV5.mjs.map → chunk-4OOPIIBY.mjs.map} +1 -1
- package/dist/esm/{chunk-RUIFVDWM.mjs → chunk-5KMDJLYM.mjs} +2 -2
- package/dist/esm/{chunk-FJRPU2NH.mjs → chunk-7KIJGBLL.mjs} +2 -2
- package/dist/esm/{chunk-S4D2KBYN.mjs → chunk-7KOS7CFM.mjs} +2 -2
- package/dist/esm/{chunk-V3O2SBO4.mjs → chunk-ESZIZDLP.mjs} +2 -2
- package/dist/esm/{chunk-YFFYA5U3.mjs → chunk-HU7GK5PL.mjs} +2 -2
- package/dist/esm/chunk-P6MFR7W6.mjs +2 -0
- package/dist/esm/{chunk-PCESRJYO.mjs.map → chunk-P6MFR7W6.mjs.map} +1 -1
- package/dist/esm/{chunk-MEWW7VTQ.mjs → chunk-P7DJNENM.mjs} +2 -2
- package/dist/esm/{chunk-PHRRBT44.mjs → chunk-PG4MJ3CJ.mjs} +2 -2
- package/dist/esm/{chunk-NMFJJOGW.mjs → chunk-QT3RHJP2.mjs} +2 -2
- package/dist/esm/{chunk-CRCE7R4D.mjs → chunk-SZG3ZZGN.mjs} +2 -2
- package/dist/esm/{chunk-R2G23RIY.mjs → chunk-ZGBIH6MJ.mjs} +2 -2
- package/dist/esm/{chunk-NQUZ4UHR.mjs → chunk-ZZEJESMY.mjs} +2 -2
- 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/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/secp256r1.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/index.d.mts +3 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- 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/keyless.mjs +1 -1
- package/dist/esm/internal/{ans.d.mts → mns.d.mts} +237 -19
- package/dist/esm/internal/mns.mjs +2 -0
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.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.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/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.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/signingMessage.mjs +1 -1
- 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/types/index.d.mts +1 -1
- package/dist/esm/types/indexer.d.mts +6 -2
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +19 -18
- package/src/api/{ans.ts → mns.ts} +437 -51
- package/src/api/movement.ts +5 -5
- package/src/internal/{ans.ts → mns.ts} +642 -84
- package/src/types/indexer.ts +6 -1
- package/src/version.ts +1 -1
- package/dist/esm/api/ans.mjs +0 -2
- package/dist/esm/chunk-47V7UGV5.mjs +0 -4
- package/dist/esm/chunk-PCESRJYO.mjs +0 -2
- package/dist/esm/internal/ans.mjs +0 -2
- /package/dist/esm/api/{ans.mjs.map → mns.mjs.map} +0 -0
- /package/dist/esm/{chunk-SYXDZA4K.mjs.map → chunk-46MDTYYN.mjs.map} +0 -0
- /package/dist/esm/{chunk-RUIFVDWM.mjs.map → chunk-5KMDJLYM.mjs.map} +0 -0
- /package/dist/esm/{chunk-FJRPU2NH.mjs.map → chunk-7KIJGBLL.mjs.map} +0 -0
- /package/dist/esm/{chunk-S4D2KBYN.mjs.map → chunk-7KOS7CFM.mjs.map} +0 -0
- /package/dist/esm/{chunk-V3O2SBO4.mjs.map → chunk-ESZIZDLP.mjs.map} +0 -0
- /package/dist/esm/{chunk-YFFYA5U3.mjs.map → chunk-HU7GK5PL.mjs.map} +0 -0
- /package/dist/esm/{chunk-MEWW7VTQ.mjs.map → chunk-P7DJNENM.mjs.map} +0 -0
- /package/dist/esm/{chunk-PHRRBT44.mjs.map → chunk-PG4MJ3CJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-NMFJJOGW.mjs.map → chunk-QT3RHJP2.mjs.map} +0 -0
- /package/dist/esm/{chunk-CRCE7R4D.mjs.map → chunk-SZG3ZZGN.mjs.map} +0 -0
- /package/dist/esm/{chunk-R2G23RIY.mjs.map → chunk-ZGBIH6MJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-NQUZ4UHR.mjs.map → chunk-ZZEJESMY.mjs.map} +0 -0
- /package/dist/esm/internal/{ans.mjs.map → mns.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -1,66 +1,264 @@
|
|
|
1
|
-
# TypeScript SDK
|
|
1
|
+
# Movement TypeScript SDK
|
|
2
|
+
|
|
3
|
+
The official TypeScript SDK for interacting with the Movement blockchain.
|
|
2
4
|
|
|
3
5
|
> [!NOTE]
|
|
4
|
-
> This Movement TS SDK repo is forked from github.com/aptos-labs prior to the date on which the Aptos Foundation implemented its Innovation-Enabling Source Code License in substitution for the prior Apache License, Version 2.0
|
|
6
|
+
> This Movement TS SDK repo is forked from github.com/aptos-labs prior to the date on which the Aptos Foundation implemented its Innovation-Enabling Source Code License in substitution for the prior Apache License, Version 2.0 governing this repository.
|
|
5
7
|
>
|
|
6
8
|
> Move Industries continues to maintain, develop, modify, and distribute this repository solely under the Apache License, Version 2.0, as existed at the time of the fork and without application of the license instituted by the Aptos Foundation.
|
|
7
9
|
|
|
8
|
-
##
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @moveindustries/ts-sdk
|
|
14
|
+
# or
|
|
15
|
+
pnpm add @moveindustries/ts-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Movement, MovementConfig, Network } from "@moveindustries/ts-sdk";
|
|
22
|
+
|
|
23
|
+
// Initialize the client
|
|
24
|
+
const config = new MovementConfig({ network: Network.TESTNET });
|
|
25
|
+
const movement = new Movement(config);
|
|
26
|
+
|
|
27
|
+
// Get account balance
|
|
28
|
+
const balance = await movement.getAccountAPTAmount({
|
|
29
|
+
accountAddress: "0x1",
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
### Account Management
|
|
36
|
+
|
|
37
|
+
Create and manage accounts on Movement:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Account, Ed25519PrivateKey } from "@moveindustries/ts-sdk";
|
|
41
|
+
|
|
42
|
+
// Generate a new account
|
|
43
|
+
const account = Account.generate();
|
|
44
|
+
|
|
45
|
+
// Or from an existing private key
|
|
46
|
+
const privateKey = new Ed25519PrivateKey("0x...");
|
|
47
|
+
const account = Account.fromPrivateKey({ privateKey });
|
|
48
|
+
|
|
49
|
+
// Fund account on testnet
|
|
50
|
+
await movement.fundAccount({
|
|
51
|
+
accountAddress: account.accountAddress,
|
|
52
|
+
amount: 100_000_000, // 1 MOVE
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Transactions
|
|
57
|
+
|
|
58
|
+
Build, sign, and submit transactions:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Simple coin transfer
|
|
62
|
+
const txn = await movement.transaction.build.simple({
|
|
63
|
+
sender: sender.accountAddress,
|
|
64
|
+
data: {
|
|
65
|
+
function: "0x1::aptos_account::transfer",
|
|
66
|
+
functionArguments: [recipientAddress, 1_000_000],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const signedTxn = await movement.transaction.sign({ signer: sender, transaction: txn });
|
|
71
|
+
const result = await movement.transaction.submit.simple({ transaction: signedTxn });
|
|
72
|
+
await movement.waitForTransaction({ transactionHash: result.hash });
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Movement Name Service (MNS)
|
|
76
|
+
|
|
77
|
+
The SDK includes full support for Movement Name Service (MNS), allowing you to register and manage `.move` domain names.
|
|
78
|
+
|
|
79
|
+
#### Domain Registration
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Check registration price before registering
|
|
83
|
+
const price = await movement.getDomainPrice({ name: "mydomain", years: 1 });
|
|
84
|
+
console.log(`Registration cost: ${Number(price) / 1e8} MOVE`);
|
|
85
|
+
|
|
86
|
+
// Check if a name is available
|
|
87
|
+
const canRegister = await movement.canRegister({ name: "mydomain" });
|
|
88
|
+
|
|
89
|
+
// Register a domain
|
|
90
|
+
const txn = await movement.registerName({
|
|
91
|
+
name: "mydomain.move",
|
|
92
|
+
sender: account,
|
|
93
|
+
expiration: { policy: "domain" },
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Name Resolution
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// Resolve name to address
|
|
101
|
+
const address = await movement.getTargetAddress({ name: "mydomain.move" });
|
|
102
|
+
|
|
103
|
+
// Reverse lookup - get primary name for address
|
|
104
|
+
const name = await movement.getPrimaryName({ address: "0x123..." });
|
|
105
|
+
|
|
106
|
+
// Get all names owned by an address
|
|
107
|
+
const names = await movement.getAccountNames({ accountAddress: "0x123..." });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Managing Names
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Set target address for name resolution
|
|
114
|
+
await movement.setTargetAddress({
|
|
115
|
+
sender: account,
|
|
116
|
+
name: "mydomain.move",
|
|
117
|
+
address: targetAddress,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Clear target address
|
|
121
|
+
await movement.clearTargetAddress({
|
|
122
|
+
sender: account,
|
|
123
|
+
name: "mydomain.move",
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Set primary name for account
|
|
127
|
+
await movement.setPrimaryName({
|
|
128
|
+
sender: account,
|
|
129
|
+
name: "mydomain.move",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Check if address owns a name
|
|
133
|
+
const isOwner = await movement.isNameOwner({
|
|
134
|
+
name: "mydomain.move",
|
|
135
|
+
address: account.accountAddress,
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Fungible Assets
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
// Get fungible asset balance
|
|
143
|
+
const balance = await movement.getCurrentFungibleAssetBalances({
|
|
144
|
+
ownerAddress: account.accountAddress,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Transfer fungible assets
|
|
148
|
+
const txn = await movement.transferFungibleAsset({
|
|
149
|
+
sender: account,
|
|
150
|
+
fungibleAssetMetadataAddress: assetAddress,
|
|
151
|
+
recipient: recipientAddress,
|
|
152
|
+
amount: 1000,
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Digital Assets (NFTs)
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// Get owned digital assets
|
|
160
|
+
const assets = await movement.getOwnedDigitalAssets({
|
|
161
|
+
ownerAddress: account.accountAddress,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Transfer digital asset
|
|
165
|
+
const txn = await movement.transferDigitalAssetTransaction({
|
|
166
|
+
sender: account,
|
|
167
|
+
digitalAssetAddress: assetAddress,
|
|
168
|
+
recipient: recipientAddress,
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### View Functions
|
|
173
|
+
|
|
174
|
+
Call read-only Move functions:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
const result = await movement.view({
|
|
178
|
+
payload: {
|
|
179
|
+
function: "0x1::coin::balance",
|
|
180
|
+
typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
181
|
+
functionArguments: [accountAddress],
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Networks
|
|
9
187
|
|
|
10
|
-
|
|
188
|
+
The SDK supports multiple networks:
|
|
11
189
|
|
|
12
|
-
|
|
190
|
+
```typescript
|
|
191
|
+
import { Network } from "@moveindustries/ts-sdk";
|
|
13
192
|
|
|
14
|
-
|
|
15
|
-
|
|
193
|
+
// Testnet
|
|
194
|
+
const testnetConfig = new MovementConfig({ network: Network.TESTNET });
|
|
16
195
|
|
|
17
|
-
|
|
196
|
+
// Mainnet
|
|
197
|
+
const mainnetConfig = new MovementConfig({ network: Network.MAINNET });
|
|
18
198
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- derives the keyless account with async proof fetch and submits a transaction
|
|
26
|
-
- deriving keyless account using all parameters
|
|
27
|
-
- keyless account verifies signature for arbitrary message correctly
|
|
199
|
+
// Custom network
|
|
200
|
+
const customConfig = new MovementConfig({
|
|
201
|
+
fullnode: "https://your-node-url",
|
|
202
|
+
indexer: "https://your-indexer-url",
|
|
203
|
+
});
|
|
204
|
+
```
|
|
28
205
|
|
|
29
|
-
|
|
30
|
-
- derives the keyless account and submits a transaction
|
|
31
|
-
- creates the keyless account via the static constructor and submits a transaction
|
|
32
|
-
- derives the keyless account with email uidKey and submits a transaction
|
|
33
|
-
- derives the keyless account with custom pepper and submits a transaction
|
|
34
|
-
- deriving keyless account with async proof fetch executes callback
|
|
35
|
-
- derives the keyless account with async proof fetch and submits a transaction
|
|
36
|
-
- deriving keyless account using all parameters
|
|
37
|
-
- keyless account verifies signature for arbitrary message correctly
|
|
206
|
+
## API Reference
|
|
38
207
|
|
|
39
|
-
|
|
208
|
+
### Movement Client
|
|
40
209
|
|
|
41
|
-
|
|
210
|
+
The main entry point providing access to all SDK functionality:
|
|
42
211
|
|
|
43
|
-
|
|
212
|
+
| Namespace | Description |
|
|
213
|
+
|-----------|-------------|
|
|
214
|
+
| `movement.account` | Account management and queries |
|
|
215
|
+
| `movement.mns` | Movement Name Service operations |
|
|
216
|
+
| `movement.coin` | Coin operations |
|
|
217
|
+
| `movement.transaction` | Transaction building, signing, and submission |
|
|
218
|
+
| `movement.fungibleAsset` | Fungible asset operations |
|
|
219
|
+
| `movement.digitalAsset` | Digital asset (NFT) operations |
|
|
220
|
+
| `movement.staking` | Staking operations |
|
|
221
|
+
| `movement.general` | General blockchain queries |
|
|
222
|
+
| `movement.faucet` | Testnet faucet |
|
|
223
|
+
| `movement.keyless` | Keyless account operations |
|
|
44
224
|
|
|
45
|
-
|
|
46
|
-
- should be able to send a transaction using custom signer
|
|
47
|
-
- should be able to send a transaction with permissioned signer
|
|
48
|
-
- should be able to send a transaction with derivable account abstraction
|
|
225
|
+
### MNS Methods
|
|
49
226
|
|
|
50
|
-
|
|
227
|
+
| Method | Description |
|
|
228
|
+
|--------|-------------|
|
|
229
|
+
| `registerName` | Register a new domain name |
|
|
230
|
+
| `getTargetAddress` | Resolve name to address |
|
|
231
|
+
| `getPrimaryName` | Get primary name for address |
|
|
232
|
+
| `setTargetAddress` | Set resolution target for name |
|
|
233
|
+
| `clearTargetAddress` | Remove resolution target |
|
|
234
|
+
| `setPrimaryName` | Set primary name for account |
|
|
235
|
+
| `getName` | Get name details |
|
|
236
|
+
| `getOwnerAddress` | Get owner of a name |
|
|
237
|
+
| `getExpiration` | Get expiration timestamp |
|
|
238
|
+
| `getAccountNames` | Get all names owned by address |
|
|
239
|
+
| `getAccountDomains` | Get domains owned by address |
|
|
240
|
+
| `renewDomain` | Renew domain registration |
|
|
241
|
+
| `canRegister` | Check if name is available |
|
|
242
|
+
| `isNameOwner` | Check if address owns name |
|
|
243
|
+
| `getTokenAddress` | Get token address for name |
|
|
244
|
+
| `getDomainPrice` | Get registration cost |
|
|
51
245
|
|
|
52
|
-
|
|
246
|
+
## Development
|
|
53
247
|
|
|
54
|
-
|
|
248
|
+
```bash
|
|
249
|
+
# Install dependencies
|
|
250
|
+
pnpm install
|
|
55
251
|
|
|
56
|
-
|
|
57
|
-
|
|
252
|
+
# Build
|
|
253
|
+
pnpm build
|
|
58
254
|
|
|
59
|
-
|
|
60
|
-
|
|
255
|
+
# Run tests
|
|
256
|
+
pnpm test
|
|
61
257
|
|
|
62
|
-
|
|
258
|
+
# Run tests on testnet
|
|
259
|
+
MOVEMENT_NETWORK=testnet pnpm test
|
|
260
|
+
```
|
|
63
261
|
|
|
64
|
-
|
|
262
|
+
## License
|
|
65
263
|
|
|
66
|
-
|
|
264
|
+
Apache License 2.0
|
|
@@ -571,7 +571,11 @@ type GetTableItemsMetadataResponse = GetTableItemsMetadataQuery["table_metadatas
|
|
|
571
571
|
* @group Implementation
|
|
572
572
|
* @category Types
|
|
573
573
|
*/
|
|
574
|
-
type
|
|
574
|
+
type GetMNSNameResponse = GetNamesQuery["current_aptos_names"];
|
|
575
|
+
/**
|
|
576
|
+
* @deprecated Use GetMNSNameResponse instead
|
|
577
|
+
*/
|
|
578
|
+
type GetANSNameResponse = GetMNSNameResponse;
|
|
575
579
|
/**
|
|
576
580
|
* A generic type that being passed by each function and holds an
|
|
577
581
|
* array of properties we can sort the query by
|
|
@@ -7766,4 +7770,4 @@ declare class AccountAddress extends Serializable implements TransactionArgument
|
|
|
7766
7770
|
equals(other: AccountAddress): boolean;
|
|
7767
7771
|
}
|
|
7768
7772
|
|
|
7769
|
-
export { TransactionPayloadScript as $, AccountPublicKey as A, Bool as B, U256 as C, Deserializer as D, type EntryFunctionArgument as E, FixedBytes as F, type InputGenerateTransactionPayloadData as G, type HexInput as H, type InputGenerateTransactionPayloadDataWithRemoteABI as I, type InputScriptData as J, type MoveFunction as K, type LedgerVersionArg as L, MovementConfig as M, TypeTag as N, type MoveModule as O, PublicKey as P, type FunctionABI as Q, RawTransaction as R, Serializable as S, type TypeArgument as T, U8 as U, type VerifySignatureArgs as V, type EntryFunctionABI as W, type ViewFunctionABI as X, type AnyRawTransaction as Y, ZkpVariant as Z, type AnyRawTransactionInstance as _, Serializer as a, type GetDelegatedStakingActivitiesResponse as a$, type InputEntryFunctionDataWithRemoteABI as a0, TransactionPayloadEntryFunction as a1, type InputMultiSigDataWithRemoteABI as a2, TransactionPayloadMultiSig as a3, type InputEntryFunctionDataWithABI as a4, type InputMultiSigDataWithABI as a5, type InputViewFunctionDataWithRemoteABI as a6, EntryFunction as a7, type InputViewFunctionDataWithABI as a8, type AnyTransactionPayloadInstance as a9, type GetObjectDataQueryResponse as aA, type PrivateKeyInput as aB, type GetANSNameResponse as aC, type GetCollectionDataResponse as aD, type GetTokenDataResponse as aE, type GetCurrentTokenOwnershipResponse as aF, type GetOwnedTokensResponse as aG, type GetTokenActivityResponse as aH, type WaitForTransactionOptions as aI, type UserTransactionResponse as aJ, type GetFungibleAssetMetadataResponse as aK, type GetFungibleAssetActivitiesResponse as aL, type GetCurrentFungibleAssetBalancesResponse as aM, type LedgerInfo as aN, type Block as aO, type MoveValue as aP, type InputViewFunctionData as aQ, type InputViewFunctionJsonData as aR, type GetChainTopUserTransactionsResponse as aS, type GraphqlQuery as aT, ProcessorType as aU, type GetProcessorStatusResponse as aV, SigningScheme as aW, SigningSchemeInput as aX, AnySignature as aY, Ed25519PrivateKey as aZ, type GetNumberOfDelegatorsResponse as a_, type InputGenerateTransactionOptions as aa, TransactionInnerPayload as ab, type InputGenerateSingleSignerRawTransactionArgs as ac, SimpleTransaction as ad, type InputGenerateMultiAgentRawTransactionArgs as ae, MultiAgentTransaction as af, type InputSimulateTransactionData as ag, AccountAuthenticatorEd25519 as ah, AccountAuthenticatorSingleKey as ai, AccountAuthenticatorMultiKey as aj, AccountAuthenticatorNoAccountAuthenticator as ak, type InputSubmitTransactionData as al, type AccountData as am, type MoveModuleBytecode as an, type CursorPaginationArgs as ao, type PaginationArgs as ap, type TransactionResponse as aq, type MoveResource as ar, type MoveStructId as as, type TokenStandardArg as at, type OrderByArg as au, type GetAccountOwnedTokensQueryResponse as av, type GetAccountOwnedTokensFromCollectionResponse as aw, type GetAccountCollectionsWithOwnedTokenResponse as ax, type GetAccountCoinsDataResponse as ay, type WhereArg as az, AccountAddress as b, type ScriptFunctionArgumentTypes as b$, type TableItemRequest as b0, type GetTableItemsDataResponse as b1, type GetTableItemsMetadataResponse as b2, type PendingTransactionResponse as b3, type InputSimulateTransactionOptions as b4, type InputTransactionPluginData as b5, type CommittedTransactionResponse as b6, type GasEstimation as b7, MultiKeySignature as b8, AccountAuthenticatorMultiEd25519 as b9, AbstractMultiKey as bA, Secp256k1PublicKey as bB, Secp256k1PrivateKey as bC, Secp256k1Signature as bD, HexInvalidReason as bE, hexToAsciiString as bF, AccountAbstractionMessage as bG, ChainId as bH, Identifier as bI, ModuleId as bJ, RawTransactionWithData as bK, MultiAgentRawTransaction as bL, FeePayerRawTransaction as bM, type TransactionArgument as bN, type ScriptFunctionArgument as bO, deserializeFromScriptArgument as bP, TransactionPayload as bQ, Script as bR, MultiSig as bS, MultiSigTransactionPayload as bT, TransactionInnerPayloadV1 as bU, TransactionExecutable as bV, TransactionExecutableScript as bW, TransactionExecutableEntryFunction as bX, TransactionExecutableEmpty as bY, TransactionExtraConfig as bZ, TransactionExtraConfigV1 as b_, AccountAuthenticatorAbstraction as ba, type MoveFunctionId as bb, type ClientRequest as bc, type Client as bd, type ClientResponse as be, type MovementRequest as bf, MovementApiType as bg, type MovementResponse as bh, MimeType as bi, type ClientConfig as bj, type Deserializable as bk, I8 as bl, I16 as bm, I32 as bn, I64 as bo, I128 as bp, I256 as bq, Serialized as br, MoveOption as bs, ensureBoolean as bt, outOfRangeErrorMessage as bu, validateNumberInRange as bv, AddressInvalidReason as bw, ParsingError as bx, type ParsingResult as by, isCanonicalEd25519Signature as bz, AuthenticationKey as c, type Int128 as c$, type InputGenerateSequenceNumberTransactionOptions as c0, type InputGenerateOrderlessTransactionOptions as c1, type InputEntryFunctionData as c2, type InputGenerateTransactionPayloadDataWithABI as c3, type InputMultiSigData as c4, type ViewFunctionJsonPayload as c5, type InputGenerateRawTransactionArgs as c6, type InputGenerateSingleSignerRawTransactionData as c7, type InputGenerateMultiAgentRawTransactionData as c8, type InputGenerateTransactionData as c9, type OrderBy as cA, type OrderByValue as cB, type TokenStandard as cC, TypeTagVariants as cD, ScriptTransactionArgumentVariants as cE, TransactionPayloadVariants as cF, TransactionInnerPayloadVariants as cG, TransactionExecutableVariants as cH, TransactionExtraConfigVariants as cI, TransactionVariants as cJ, TransactionAuthenticatorVariant as cK, AccountAuthenticatorVariant as cL, PrivateKeyVariants as cM, AnyPublicKeyVariant as cN, anyPublicKeyVariantToString as cO, AnySignatureVariant as cP, EphemeralSignatureVariant as cQ, type Uint8 as cR, type Uint16 as cS, type Uint32 as cT, type Uint64 as cU, type Uint128 as cV, type Uint256 as cW, type Int8 as cX, type Int16 as cY, type Int32 as cZ, type Int64 as c_, TypeTagBool as ca, TypeTagU8 as cb, TypeTagI8 as cc, TypeTagU16 as cd, TypeTagI16 as ce, TypeTagU32 as cf, TypeTagI32 as cg, TypeTagU64 as ch, TypeTagI64 as ci, TypeTagU128 as cj, TypeTagI128 as ck, TypeTagU256 as cl, TypeTagI256 as cm, TypeTagAddress as cn, TypeTagSigner as co, TypeTagReference as cp, TypeTagGeneric as cq, TypeTagVector as cr, TypeTagStruct as cs, StructTag as ct, aptosCoinStructTag as cu, stringStructTag as cv, optionStructTag as cw, objectStructTag as cx, type GetAccountAddressesForAuthKeyResponse as cy, type GetEventsResponse as cz, type VerifySignatureAsyncArgs as d, type MoveUint128Type as d$, type Int256 as d0, type MovementSettings as d1, type FullNodeConfig as d2, type IndexerConfig as d3, type FaucetConfig as d4, type TransactionGenerationConfig as d5, type ClientHeadersType as d6, type PluginConfig as d7, type PluginSettings as d8, type TransactionSubmitter as d9, type ScriptPayloadResponse as dA, type MultisigPayloadResponse as dB, type GenesisPayload as dC, type MoveScriptBytecode as dD, type TransactionSignature as dE, isEd25519Signature as dF, isSecp256k1Signature as dG, isMultiAgentSignature as dH, isFeePayerSignature as dI, isMultiEd25519Signature as dJ, isSingleSenderSignature as dK, type TransactionEd25519Signature as dL, type TransactionSecp256k1Signature as dM, type TransactionSingleSenderSignature as dN, type TransactionMultiEd25519Signature as dO, type TransactionMultiAgentSignature as dP, type TransactionFeePayerSignature as dQ, type AccountSignature as dR, type WriteSet as dS, type ScriptWriteSet as dT, type DirectWriteSet as dU, type EventGuid as dV, type Event as dW, type MoveUint8Type as dX, type MoveUint16Type as dY, type MoveUint32Type as dZ, type MoveUint64Type as d_, TransactionResponseType as da, isPendingTransactionResponse as db, isUserTransactionResponse as dc, isGenesisTransactionResponse as dd, isBlockMetadataTransactionResponse as de, isStateCheckpointTransactionResponse as df, isValidatorTransactionResponse as dg, isBlockEpilogueTransactionResponse as dh, type GenesisTransactionResponse as di, type BlockMetadataTransactionResponse as dj, type StateCheckpointTransactionResponse as dk, type ValidatorTransactionResponse as dl, type BlockEndInfo as dm, type BlockEpilogueTransactionResponse as dn, type WriteSetChange as dp, type WriteSetChangeDeleteModule as dq, type WriteSetChangeDeleteResource as dr, type WriteSetChangeDeleteTableItem as ds, type WriteSetChangeWriteModule as dt, type WriteSetChangeWriteResource as du, type WriteSetChangeWriteTableItem as dv, type DecodedTableData as dw, type DeletedTableData as dx, type TransactionPayloadResponse as dy, type EntryFunctionPayloadResponse as dz, Signature as e, type MoveUint256Type as e0, type MoveAddressType as e1, type MoveObjectType as e2, type MoveOptionType as e3, type MoveStructType as e4, type MoveType as e5, type MoveModuleId as e6, MoveFunctionVisibility as e7, MoveAbility as e8, type MoveFunctionGenericTypeParam as e9, type MoveStructField as ea, type MoveStruct as eb, RoleType as ec, type AuthenticationKeyScheme as ed, DeriveScheme as ee, type GenerateAccountWithEd25519 as ef, type GenerateAccountWithSingleSignerSecp256k1Key as eg, type GenerateAccount as eh, NetworkToIndexerAPI as ei, NetworkToNodeAPI as ej, NetworkToFaucetAPI as ek, NetworkToPepperAPI as el, NetworkToProverAPI as em, Network as en, NetworkToChainId as eo, NetworkToNetworkName as ep, DEFAULT_MAX_GAS_AMOUNT as eq, DEFAULT_TXN_EXP_SEC_FROM_NOW as er, DEFAULT_TXN_TIMEOUT_SEC as es, MOVEMENT_COIN as et, MOVEMENT_FA as eu, RAW_TRANSACTION_SALT as ev, RAW_TRANSACTION_WITH_DATA_SALT as ew, ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT as ex, FIREBASE_AUTH_ISS_PATTERN as ey, EphemeralPublicKeyVariant as f, EphemeralCertificateVariant as g, type AccountAddressInput as h, PrivateKey as i, Hex as j, Ed25519PublicKey as k, AnyPublicKey as l, MultiKey as m, MultiEd25519PublicKey as n, Ed25519Signature as o, MultiEd25519Signature as p, AccountAuthenticator as q, MoveString as r, MoveVector as s, U64 as t, type AnyNumber as u, type SimpleEntryFunctionArgumentTypes as v, type EntryFunctionArgumentTypes as w, U16 as x, U32 as y, U128 as z };
|
|
7773
|
+
export { TransactionPayloadScript as $, AccountPublicKey as A, Bool as B, U256 as C, Deserializer as D, type EntryFunctionArgument as E, FixedBytes as F, type InputGenerateTransactionPayloadData as G, type HexInput as H, type InputGenerateTransactionPayloadDataWithRemoteABI as I, type InputScriptData as J, type MoveFunction as K, type LedgerVersionArg as L, MovementConfig as M, TypeTag as N, type MoveModule as O, PublicKey as P, type FunctionABI as Q, RawTransaction as R, Serializable as S, type TypeArgument as T, U8 as U, type VerifySignatureArgs as V, type EntryFunctionABI as W, type ViewFunctionABI as X, type AnyRawTransaction as Y, ZkpVariant as Z, type AnyRawTransactionInstance as _, Serializer as a, type GetDelegatedStakingActivitiesResponse as a$, type InputEntryFunctionDataWithRemoteABI as a0, TransactionPayloadEntryFunction as a1, type InputMultiSigDataWithRemoteABI as a2, TransactionPayloadMultiSig as a3, type InputEntryFunctionDataWithABI as a4, type InputMultiSigDataWithABI as a5, type InputViewFunctionDataWithRemoteABI as a6, EntryFunction as a7, type InputViewFunctionDataWithABI as a8, type AnyTransactionPayloadInstance as a9, type GetObjectDataQueryResponse as aA, type PrivateKeyInput as aB, type GetMNSNameResponse as aC, type GetCollectionDataResponse as aD, type GetTokenDataResponse as aE, type GetCurrentTokenOwnershipResponse as aF, type GetOwnedTokensResponse as aG, type GetTokenActivityResponse as aH, type WaitForTransactionOptions as aI, type UserTransactionResponse as aJ, type GetFungibleAssetMetadataResponse as aK, type GetFungibleAssetActivitiesResponse as aL, type GetCurrentFungibleAssetBalancesResponse as aM, type LedgerInfo as aN, type Block as aO, type MoveValue as aP, type InputViewFunctionData as aQ, type InputViewFunctionJsonData as aR, type GetChainTopUserTransactionsResponse as aS, type GraphqlQuery as aT, ProcessorType as aU, type GetProcessorStatusResponse as aV, SigningScheme as aW, SigningSchemeInput as aX, AnySignature as aY, Ed25519PrivateKey as aZ, type GetNumberOfDelegatorsResponse as a_, type InputGenerateTransactionOptions as aa, TransactionInnerPayload as ab, type InputGenerateSingleSignerRawTransactionArgs as ac, SimpleTransaction as ad, type InputGenerateMultiAgentRawTransactionArgs as ae, MultiAgentTransaction as af, type InputSimulateTransactionData as ag, AccountAuthenticatorEd25519 as ah, AccountAuthenticatorSingleKey as ai, AccountAuthenticatorMultiKey as aj, AccountAuthenticatorNoAccountAuthenticator as ak, type InputSubmitTransactionData as al, type AccountData as am, type MoveModuleBytecode as an, type CursorPaginationArgs as ao, type PaginationArgs as ap, type TransactionResponse as aq, type MoveResource as ar, type MoveStructId as as, type TokenStandardArg as at, type OrderByArg as au, type GetAccountOwnedTokensQueryResponse as av, type GetAccountOwnedTokensFromCollectionResponse as aw, type GetAccountCollectionsWithOwnedTokenResponse as ax, type GetAccountCoinsDataResponse as ay, type WhereArg as az, AccountAddress as b, type ScriptFunctionArgumentTypes as b$, type TableItemRequest as b0, type GetTableItemsDataResponse as b1, type GetTableItemsMetadataResponse as b2, type PendingTransactionResponse as b3, type InputSimulateTransactionOptions as b4, type InputTransactionPluginData as b5, type CommittedTransactionResponse as b6, type GasEstimation as b7, MultiKeySignature as b8, AccountAuthenticatorMultiEd25519 as b9, AbstractMultiKey as bA, Secp256k1PublicKey as bB, Secp256k1PrivateKey as bC, Secp256k1Signature as bD, HexInvalidReason as bE, hexToAsciiString as bF, AccountAbstractionMessage as bG, ChainId as bH, Identifier as bI, ModuleId as bJ, RawTransactionWithData as bK, MultiAgentRawTransaction as bL, FeePayerRawTransaction as bM, type TransactionArgument as bN, type ScriptFunctionArgument as bO, deserializeFromScriptArgument as bP, TransactionPayload as bQ, Script as bR, MultiSig as bS, MultiSigTransactionPayload as bT, TransactionInnerPayloadV1 as bU, TransactionExecutable as bV, TransactionExecutableScript as bW, TransactionExecutableEntryFunction as bX, TransactionExecutableEmpty as bY, TransactionExtraConfig as bZ, TransactionExtraConfigV1 as b_, AccountAuthenticatorAbstraction as ba, type MoveFunctionId as bb, type ClientRequest as bc, type Client as bd, type ClientResponse as be, type MovementRequest as bf, MovementApiType as bg, type MovementResponse as bh, MimeType as bi, type ClientConfig as bj, type Deserializable as bk, I8 as bl, I16 as bm, I32 as bn, I64 as bo, I128 as bp, I256 as bq, Serialized as br, MoveOption as bs, ensureBoolean as bt, outOfRangeErrorMessage as bu, validateNumberInRange as bv, AddressInvalidReason as bw, ParsingError as bx, type ParsingResult as by, isCanonicalEd25519Signature as bz, AuthenticationKey as c, type Int64 as c$, type InputGenerateSequenceNumberTransactionOptions as c0, type InputGenerateOrderlessTransactionOptions as c1, type InputEntryFunctionData as c2, type InputGenerateTransactionPayloadDataWithABI as c3, type InputMultiSigData as c4, type ViewFunctionJsonPayload as c5, type InputGenerateRawTransactionArgs as c6, type InputGenerateSingleSignerRawTransactionData as c7, type InputGenerateMultiAgentRawTransactionData as c8, type InputGenerateTransactionData as c9, type GetANSNameResponse as cA, type OrderBy as cB, type OrderByValue as cC, type TokenStandard as cD, TypeTagVariants as cE, ScriptTransactionArgumentVariants as cF, TransactionPayloadVariants as cG, TransactionInnerPayloadVariants as cH, TransactionExecutableVariants as cI, TransactionExtraConfigVariants as cJ, TransactionVariants as cK, TransactionAuthenticatorVariant as cL, AccountAuthenticatorVariant as cM, PrivateKeyVariants as cN, AnyPublicKeyVariant as cO, anyPublicKeyVariantToString as cP, AnySignatureVariant as cQ, EphemeralSignatureVariant as cR, type Uint8 as cS, type Uint16 as cT, type Uint32 as cU, type Uint64 as cV, type Uint128 as cW, type Uint256 as cX, type Int8 as cY, type Int16 as cZ, type Int32 as c_, TypeTagBool as ca, TypeTagU8 as cb, TypeTagI8 as cc, TypeTagU16 as cd, TypeTagI16 as ce, TypeTagU32 as cf, TypeTagI32 as cg, TypeTagU64 as ch, TypeTagI64 as ci, TypeTagU128 as cj, TypeTagI128 as ck, TypeTagU256 as cl, TypeTagI256 as cm, TypeTagAddress as cn, TypeTagSigner as co, TypeTagReference as cp, TypeTagGeneric as cq, TypeTagVector as cr, TypeTagStruct as cs, StructTag as ct, aptosCoinStructTag as cu, stringStructTag as cv, optionStructTag as cw, objectStructTag as cx, type GetAccountAddressesForAuthKeyResponse as cy, type GetEventsResponse as cz, type VerifySignatureAsyncArgs as d, type MoveUint64Type as d$, type Int128 as d0, type Int256 as d1, type MovementSettings as d2, type FullNodeConfig as d3, type IndexerConfig as d4, type FaucetConfig as d5, type TransactionGenerationConfig as d6, type ClientHeadersType as d7, type PluginConfig as d8, type PluginSettings as d9, type EntryFunctionPayloadResponse as dA, type ScriptPayloadResponse as dB, type MultisigPayloadResponse as dC, type GenesisPayload as dD, type MoveScriptBytecode as dE, type TransactionSignature as dF, isEd25519Signature as dG, isSecp256k1Signature as dH, isMultiAgentSignature as dI, isFeePayerSignature as dJ, isMultiEd25519Signature as dK, isSingleSenderSignature as dL, type TransactionEd25519Signature as dM, type TransactionSecp256k1Signature as dN, type TransactionSingleSenderSignature as dO, type TransactionMultiEd25519Signature as dP, type TransactionMultiAgentSignature as dQ, type TransactionFeePayerSignature as dR, type AccountSignature as dS, type WriteSet as dT, type ScriptWriteSet as dU, type DirectWriteSet as dV, type EventGuid as dW, type Event as dX, type MoveUint8Type as dY, type MoveUint16Type as dZ, type MoveUint32Type as d_, type TransactionSubmitter as da, TransactionResponseType as db, isPendingTransactionResponse as dc, isUserTransactionResponse as dd, isGenesisTransactionResponse as de, isBlockMetadataTransactionResponse as df, isStateCheckpointTransactionResponse as dg, isValidatorTransactionResponse as dh, isBlockEpilogueTransactionResponse as di, type GenesisTransactionResponse as dj, type BlockMetadataTransactionResponse as dk, type StateCheckpointTransactionResponse as dl, type ValidatorTransactionResponse as dm, type BlockEndInfo as dn, type BlockEpilogueTransactionResponse as dp, type WriteSetChange as dq, type WriteSetChangeDeleteModule as dr, type WriteSetChangeDeleteResource as ds, type WriteSetChangeDeleteTableItem as dt, type WriteSetChangeWriteModule as du, type WriteSetChangeWriteResource as dv, type WriteSetChangeWriteTableItem as dw, type DecodedTableData as dx, type DeletedTableData as dy, type TransactionPayloadResponse as dz, Signature as e, type MoveUint128Type as e0, type MoveUint256Type as e1, type MoveAddressType as e2, type MoveObjectType as e3, type MoveOptionType as e4, type MoveStructType as e5, type MoveType as e6, type MoveModuleId as e7, MoveFunctionVisibility as e8, MoveAbility as e9, type MoveFunctionGenericTypeParam as ea, type MoveStructField as eb, type MoveStruct as ec, RoleType as ed, type AuthenticationKeyScheme as ee, DeriveScheme as ef, type GenerateAccountWithEd25519 as eg, type GenerateAccountWithSingleSignerSecp256k1Key as eh, type GenerateAccount as ei, NetworkToIndexerAPI as ej, NetworkToNodeAPI as ek, NetworkToFaucetAPI as el, NetworkToPepperAPI as em, NetworkToProverAPI as en, Network as eo, NetworkToChainId as ep, NetworkToNetworkName as eq, DEFAULT_MAX_GAS_AMOUNT as er, DEFAULT_TXN_EXP_SEC_FROM_NOW as es, DEFAULT_TXN_TIMEOUT_SEC as et, MOVEMENT_COIN as eu, MOVEMENT_FA as ev, RAW_TRANSACTION_SALT as ew, RAW_TRANSACTION_WITH_DATA_SALT as ex, ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT as ey, FIREBASE_AUTH_ISS_PATTERN as ez, EphemeralPublicKeyVariant as f, EphemeralCertificateVariant as g, type AccountAddressInput as h, PrivateKey as i, Hex as j, Ed25519PublicKey as k, AnyPublicKey as l, MultiKey as m, MultiEd25519PublicKey as n, Ed25519Signature as o, MultiEd25519Signature as p, AccountAuthenticator as q, MoveString as r, MoveVector as s, U64 as t, type AnyNumber as u, type SimpleEntryFunctionArgumentTypes as v, type EntryFunctionArgumentTypes as w, U16 as x, U32 as y, U128 as z };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/andygmove/Downloads/repos/movement-ts-sdk/dist/common/chunk-56DGDNEY.js","../../src/core/common.ts","../../src/core/hex.ts","../../src/core/accountAddress.ts"],"names":["ParsingError","message","invalidReason","HexInvalidReason","Hex","_Hex","data","bytesToHex"],"mappings":"AAAA,ilBAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCQhM,IAAMA,CAAAA,CAAN,MAAA,QAA8B,KAAM,CAkBzC,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAkB,CAC7C,KAAA,CAAMD,CAAO,CAAA,CACb,IAAA,CAAK,aAAA,CAAgBC,CACvB,CACF,CAAA,CC3BA,4CAAuC,IAS3BC,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,iBAAA,CAAoB,mBAAA,CAHVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgCCC,CAAAA,aAAN,MAAMC,CAAI,CAUf,WAAA,CAAYC,CAAAA,CAAkB,CAC5B,IAAA,CAAK,IAAA,CAAOA,CACd,CAaA,YAAA,CAAA,CAA2B,CACzB,OAAO,IAAA,CAAK,IACd,CASA,qBAAA,CAAA,CAAgC,CAC9B,OAAOC,+BAAAA,IAAW,CAAK,IAAI,CAC7B,CASA,QAAA,CAAA,CAAmB,CACjB,MAAO,CAAA,EAAA,EAAK,IAAA,CAAK,qBAAA,CAAsB,CAAC,CAAA,CAAA;ACkVsB;AAnWV,SAAA","file":"/Users/andygmove/Downloads/repos/movement-ts-sdk/dist/common/chunk-56DGDNEY.js","sourcesContent":[null,"// Copyright © Move Industries\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n","// Copyright © Move Industries\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { HexInput } from \"../types\";\nimport { ParsingError, ParsingResult } from \"./common\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n","// Copyright © Move Industries\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { Deserializer } from \"../bcs/deserializer\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { TransactionArgument } from \"../transactions/instances/transactionArgument\";\nimport { HexInput, ScriptTransactionArgumentVariants } from \"../types\";\nimport { ParsingError, ParsingResult } from \"./common\";\n\n/**\n * Provides reasons for an address was invalid.\n * @group Implementation\n * @category Serialization\n */\nexport enum AddressInvalidReason {\n INCORRECT_NUMBER_OF_BYTES = \"incorrect_number_of_bytes\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n TOO_SHORT = \"too_short\",\n TOO_LONG = \"too_long\",\n LEADING_ZERO_X_REQUIRED = \"leading_zero_x_required\",\n LONG_FORM_REQUIRED_UNLESS_SPECIAL = \"long_form_required_unless_special\",\n INVALID_PADDING_ZEROES = \"INVALID_PADDING_ZEROES\",\n INVALID_PADDING_STRICTNESS = \"INVALID_PADDING_STRICTNESS\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n * @group Implementation\n * @category Serialization\n */\nexport type AccountAddressInput = HexInput | AccountAddress;\n\n/**\n * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction\n * hashes, use the Hex class.\n *\n * AccountAddress is used for working with account addresses. Account addresses, when\n * represented as a string, generally look like these examples:\n * - 0x1\n * - 0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c\n *\n * Proper formatting and parsing of account addresses is defined by AIP-40.\n * To learn more about the standard, read the AIP here:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * The comments in this class make frequent reference to the LONG and SHORT formats,\n * as well as \"special\" addresses. To learn what these refer to see AIP-40.\n * @group Implementation\n * @category Serialization\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n * @group Implementation\n * @category Serialization\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n * @group Implementation\n * @category Serialization\n */\n static readonly LONG_STRING_LENGTH: number = 64;\n\n static ZERO: AccountAddress = AccountAddress.from(\"0x0\");\n\n static ONE: AccountAddress = AccountAddress.from(\"0x1\");\n\n static TWO: AccountAddress = AccountAddress.from(\"0x2\");\n\n static THREE: AccountAddress = AccountAddress.from(\"0x3\");\n\n static FOUR: AccountAddress = AccountAddress.from(\"0x4\");\n\n static A: AccountAddress = AccountAddress.from(\"0xA\");\n\n /**\n * Creates an instance of AccountAddress from a Uint8Array.\n *\n * This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.\n *\n * @param input A Uint8Array representing an account address.\n * @throws ParsingError if the input length is not equal to 32 bytes.\n * @group Implementation\n * @category Serialization\n */\n constructor(input: Uint8Array) {\n super();\n if (input.length !== AccountAddress.LENGTH) {\n throw new ParsingError(\n \"AccountAddress data should be exactly 32 bytes long\",\n AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,\n );\n }\n this.data = input;\n }\n\n /**\n * Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive.\n * In other words, the last byte of the address must be < 0b10000 (16)\n * and every other byte must be zero.\n *\n * For more information on how special addresses are defined, see AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns true if the address is special, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n isSpecial(): boolean {\n return (\n this.data.slice(0, this.data.length - 1).every((byte) => byte === 0) && this.data[this.data.length - 1] < 0b10000\n );\n }\n // ===\n // Methods for representing an instance of AccountAddress as other types.\n // ===\n\n /**\n * Return the AccountAddress as a string as per AIP-40.\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n * This representation returns special addresses in SHORT form (0xf)\n * and other addresses in LONG form (0x + 64 characters).\n *\n * @returns AccountAddress as a string conforming to AIP-40.\n * @group Implementation\n * @category Serialization\n */\n toString(): `0x${string}` {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n /**\n * Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.\n *\n * NOTE: Prefer to use `toString` where possible.\n *\n * @returns AccountAddress as a string without the leading 0x.\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n let hex = bytesToHex(this.data);\n if (this.isSpecial()) {\n hex = hex[hex.length - 1];\n }\n return hex;\n }\n\n /**\n * Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns AccountAddress as a string in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLong(): `0x${string}` {\n return `0x${this.toStringLongWithoutPrefix()}`;\n }\n\n /**\n * Returns the account address as a string in LONG form without a leading 0x.\n * This function will include leading zeroes and will produce a string of 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns {string} The account address in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLongWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Convert the account address to a string in SHORT format, which is 0x followed by the shortest\n * possible representation (no leading zeros).\n *\n * @returns AccountAddress as a string in SHORT form.\n * @group Implementation\n * @category Serialization\n */\n toStringShort(): `0x${string}` {\n return `0x${this.toStringShortWithoutPrefix()}`;\n }\n\n /**\n * Returns a lossless short string representation of the address by trimming leading zeros.\n * If the address consists of all zeros, returns \"0\".\n *\n * @returns A string representation of the address without leading zeros\n * @group Implementation\n * @category Serialization\n */\n toStringShortWithoutPrefix(): string {\n const hex = bytesToHex(this.data).replace(/^0+/, \"\");\n return hex === \"\" ? \"0\" : hex;\n }\n\n /**\n * Get the inner data as a Uint8Array.\n * The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Serialize the AccountAddress to a Serializer instance's data buffer.\n * @param serializer The serializer to serialize the AccountAddress to.\n * @returns void\n * @example\n * const serializer = new Serializer();\n * const address = AccountAddress.fromString(\"0x1\");\n * address.serialize(serializer);\n * const bytes = serializer.toUint8Array();\n * // `bytes` is now the BCS-serialized address.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows for the proper encoding of data when interacting with entry functions in the blockchain.\n *\n * @param serializer - The serializer instance used to convert the data into bytes.\n * @group Implementation\n * @category Serialization\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function by encoding it into a byte sequence.\n * This process involves serializing the variant index and the instance data, making it suitable for transmission.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Address);\n serializer.serialize(this);\n }\n\n /**\n * Deserialize an AccountAddress from the byte buffer in a Deserializer instance.\n * This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.\n * @param deserializer The deserializer to deserialize the AccountAddress from.\n * @returns An instance of AccountAddress.\n * @example\n * const bytes = hexToBytes(\"0x0102030405060708091011121314151617181920212223242526272829303132\");\n * const deserializer = new Deserializer(bytes);\n * const address = AccountAddress.deserialize(deserializer);\n * // `address` is now an instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AccountAddress {\n const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);\n return new AccountAddress(bytes);\n }\n\n // ===\n // Methods for creating an instance of AccountAddress from other types.\n // ===\n\n /**\n * NOTE: This function has strict parsing behavior. For relaxed behavior, please use\n * the `fromString` function.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows only the strictest formats defined by AIP-40. In short this\n * means only the following formats are accepted:\n *\n * - LONG\n * - SHORT for special addresses\n *\n * Where:\n * - LONG is defined as 0x + 64 hex characters.\n * - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.\n *\n * This means the following are not accepted:\n * - SHORT for non-special addresses.\n * - Any address without a leading 0x.\n *\n * @param input - A hex string representing an account address.\n *\n * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.\n *\n * @remarks\n *\n * This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.\n *\n * @see AIP-40 documentation for more details on address formats:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns An instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStringStrict(input: string): AccountAddress {\n // Assert the string starts with 0x.\n if (!input.startsWith(\"0x\")) {\n throw new ParsingError(\"Hex string must start with a leading 0x.\", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);\n }\n\n const address = AccountAddress.fromString(input);\n\n // Check if the address is in LONG form. If it is not, this is only allowed for\n // special addresses, in which case we check it is in proper SHORT form.\n if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,\n AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,\n );\n } else if (input.length !== 3) {\n // 0x + one hex char is the only valid SHORT form for special addresses.\n throw new ParsingError(\n // eslint-disable-next-line max-len\n `The given hex string ${input} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,\n AddressInvalidReason.INVALID_PADDING_ZEROES,\n );\n }\n }\n\n return address;\n }\n\n /**\n * NOTE: This function has relaxed parsing behavior. For strict behavior, please use\n * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this\n * function, `fromString`.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows all formats defined by AIP-40. In short this means the\n * following formats are accepted:\n *\n * - LONG, with or without leading 0x\n * - SHORT*, with or without leading 0x\n *\n * Where:\n * - LONG is 64 hex characters.\n * - SHORT* is 1 to 63 hex characters inclusive. The address can have missing values up to `maxMissingChars` before it is padded.\n * - Padding zeroes are allowed, e.g. 0x0123 is valid.\n *\n * Learn more about the different address formats by reading AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @param input A hex string representing an account address.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n *\n * @returns An instance of AccountAddress.\n *\n * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.\n * @group Implementation\n * @category Serialization\n */\n static fromString(input: string, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n let parsedInput = input;\n // Remove leading 0x for parsing.\n if (input.startsWith(\"0x\")) {\n parsedInput = input.slice(2);\n }\n\n // Ensure the address string is at least 1 character long.\n if (parsedInput.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_SHORT,\n );\n }\n\n // Ensure the address string is not longer than 64 characters.\n if (parsedInput.length > 64) {\n throw new ParsingError(\n \"Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_LONG,\n );\n }\n\n // Ensure that the maxMissingChars is between or equal to 0 and 63.\n if (maxMissingChars > 63 || maxMissingChars < 0) {\n throw new ParsingError(\n `maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`,\n AddressInvalidReason.INVALID_PADDING_STRICTNESS,\n );\n }\n\n let addressBytes: Uint8Array;\n try {\n // Pad the address with leading zeroes, so it is 64 chars long and then convert\n // the hex string to bytes. Every two characters in a hex string constitutes a\n // single byte. So a 64 length hex string becomes a 32 byte array.\n addressBytes = hexToBytes(parsedInput.padStart(64, \"0\"));\n } catch (error: any) {\n // At this point the only way this can fail is if the hex string contains\n // invalid characters.\n throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);\n }\n\n const address = new AccountAddress(addressBytes);\n\n // Cannot pad the address if it has more than maxMissingChars missing.\n if (parsedInput.length < 64 - maxMissingChars) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `Hex string is too short, must be ${64 - maxMissingChars} to 64 chars long, excluding the leading 0x. You may need to fix \nthe addresss by padding it with 0s before passing it to \\`fromString\\` (e.g. <addressString>.padStart(64, '0')). \nReceived ${input}`,\n AddressInvalidReason.TOO_SHORT,\n );\n }\n }\n\n return address;\n }\n\n /**\n * Convenience method for creating an AccountAddress from various input types.\n * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding\n * AccountAddress.\n *\n * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,\n * or an existing AccountAddress.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n * @group Implementation\n * @category Serialization\n */\n static from(input: AccountAddressInput, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input, { maxMissingChars });\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n\n /**\n * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.\n *\n * @param input - The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStrict(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromStringStrict(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided input is a valid AccountAddress.\n *\n * @param args - The arguments for validation.\n * @param args.input - A hex string representing an account address.\n * @param args.strict - If true, use strict parsing behavior; if false, use relaxed parsing behavior.\n *\n * @returns An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details.\n * If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.\n * @group Implementation\n * @category Serialization\n */\n static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {\n try {\n if (args.strict) {\n AccountAddress.fromStrict(args.input);\n } else {\n AccountAddress.from(args.input);\n }\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two AccountAddresses are equal based on their underlying byte data.\n *\n * @param other - The AccountAddress to compare to.\n * @returns true if the AccountAddresses are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: AccountAddress): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/andygmove/Downloads/repos/ts-sdk/dist/common/chunk-56DGDNEY.js","../../src/core/common.ts","../../src/core/hex.ts","../../src/core/accountAddress.ts"],"names":["ParsingError","message","invalidReason","HexInvalidReason","Hex","_Hex","data","bytesToHex"],"mappings":"AAAA,ilBAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCQhM,IAAMA,CAAAA,CAAN,MAAA,QAA8B,KAAM,CAkBzC,WAAA,CAAYC,CAAAA,CAAiBC,CAAAA,CAAkB,CAC7C,KAAA,CAAMD,CAAO,CAAA,CACb,IAAA,CAAK,aAAA,CAAgBC,CACvB,CACF,CAAA,CC3BA,4CAAuC,IAS3BC,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,CACVA,CAAAA,CAAA,SAAA,CAAY,WAAA,CACZA,CAAAA,CAAA,cAAA,CAAiB,gBAAA,CACjBA,CAAAA,CAAA,iBAAA,CAAoB,mBAAA,CAHVA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAA,CAAA,CAAA,CAAA,CAgCCC,CAAAA,aAAN,MAAMC,CAAI,CAUf,WAAA,CAAYC,CAAAA,CAAkB,CAC5B,IAAA,CAAK,IAAA,CAAOA,CACd,CAaA,YAAA,CAAA,CAA2B,CACzB,OAAO,IAAA,CAAK,IACd,CASA,qBAAA,CAAA,CAAgC,CAC9B,OAAOC,+BAAAA,IAAW,CAAK,IAAI,CAC7B,CASA,QAAA,CAAA,CAAmB,CACjB,MAAO,CAAA,EAAA,EAAK,IAAA,CAAK,qBAAA,CAAsB,CAAC,CAAA,CAAA;ACkVsB;AAnWV,SAAA","file":"/Users/andygmove/Downloads/repos/ts-sdk/dist/common/chunk-56DGDNEY.js","sourcesContent":[null,"// Copyright © Move Industries\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n","// Copyright © Move Industries\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { HexInput } from \"../types\";\nimport { ParsingError, ParsingResult } from \"./common\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n","// Copyright © Move Industries\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { Deserializer } from \"../bcs/deserializer\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { TransactionArgument } from \"../transactions/instances/transactionArgument\";\nimport { HexInput, ScriptTransactionArgumentVariants } from \"../types\";\nimport { ParsingError, ParsingResult } from \"./common\";\n\n/**\n * Provides reasons for an address was invalid.\n * @group Implementation\n * @category Serialization\n */\nexport enum AddressInvalidReason {\n INCORRECT_NUMBER_OF_BYTES = \"incorrect_number_of_bytes\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n TOO_SHORT = \"too_short\",\n TOO_LONG = \"too_long\",\n LEADING_ZERO_X_REQUIRED = \"leading_zero_x_required\",\n LONG_FORM_REQUIRED_UNLESS_SPECIAL = \"long_form_required_unless_special\",\n INVALID_PADDING_ZEROES = \"INVALID_PADDING_ZEROES\",\n INVALID_PADDING_STRICTNESS = \"INVALID_PADDING_STRICTNESS\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n * @group Implementation\n * @category Serialization\n */\nexport type AccountAddressInput = HexInput | AccountAddress;\n\n/**\n * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction\n * hashes, use the Hex class.\n *\n * AccountAddress is used for working with account addresses. Account addresses, when\n * represented as a string, generally look like these examples:\n * - 0x1\n * - 0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c\n *\n * Proper formatting and parsing of account addresses is defined by AIP-40.\n * To learn more about the standard, read the AIP here:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * The comments in this class make frequent reference to the LONG and SHORT formats,\n * as well as \"special\" addresses. To learn what these refer to see AIP-40.\n * @group Implementation\n * @category Serialization\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n * @group Implementation\n * @category Serialization\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n * @group Implementation\n * @category Serialization\n */\n static readonly LONG_STRING_LENGTH: number = 64;\n\n static ZERO: AccountAddress = AccountAddress.from(\"0x0\");\n\n static ONE: AccountAddress = AccountAddress.from(\"0x1\");\n\n static TWO: AccountAddress = AccountAddress.from(\"0x2\");\n\n static THREE: AccountAddress = AccountAddress.from(\"0x3\");\n\n static FOUR: AccountAddress = AccountAddress.from(\"0x4\");\n\n static A: AccountAddress = AccountAddress.from(\"0xA\");\n\n /**\n * Creates an instance of AccountAddress from a Uint8Array.\n *\n * This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.\n *\n * @param input A Uint8Array representing an account address.\n * @throws ParsingError if the input length is not equal to 32 bytes.\n * @group Implementation\n * @category Serialization\n */\n constructor(input: Uint8Array) {\n super();\n if (input.length !== AccountAddress.LENGTH) {\n throw new ParsingError(\n \"AccountAddress data should be exactly 32 bytes long\",\n AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,\n );\n }\n this.data = input;\n }\n\n /**\n * Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive.\n * In other words, the last byte of the address must be < 0b10000 (16)\n * and every other byte must be zero.\n *\n * For more information on how special addresses are defined, see AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns true if the address is special, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n isSpecial(): boolean {\n return (\n this.data.slice(0, this.data.length - 1).every((byte) => byte === 0) && this.data[this.data.length - 1] < 0b10000\n );\n }\n // ===\n // Methods for representing an instance of AccountAddress as other types.\n // ===\n\n /**\n * Return the AccountAddress as a string as per AIP-40.\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n * This representation returns special addresses in SHORT form (0xf)\n * and other addresses in LONG form (0x + 64 characters).\n *\n * @returns AccountAddress as a string conforming to AIP-40.\n * @group Implementation\n * @category Serialization\n */\n toString(): `0x${string}` {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n /**\n * Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.\n *\n * NOTE: Prefer to use `toString` where possible.\n *\n * @returns AccountAddress as a string without the leading 0x.\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n let hex = bytesToHex(this.data);\n if (this.isSpecial()) {\n hex = hex[hex.length - 1];\n }\n return hex;\n }\n\n /**\n * Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns AccountAddress as a string in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLong(): `0x${string}` {\n return `0x${this.toStringLongWithoutPrefix()}`;\n }\n\n /**\n * Returns the account address as a string in LONG form without a leading 0x.\n * This function will include leading zeroes and will produce a string of 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns {string} The account address in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLongWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Convert the account address to a string in SHORT format, which is 0x followed by the shortest\n * possible representation (no leading zeros).\n *\n * @returns AccountAddress as a string in SHORT form.\n * @group Implementation\n * @category Serialization\n */\n toStringShort(): `0x${string}` {\n return `0x${this.toStringShortWithoutPrefix()}`;\n }\n\n /**\n * Returns a lossless short string representation of the address by trimming leading zeros.\n * If the address consists of all zeros, returns \"0\".\n *\n * @returns A string representation of the address without leading zeros\n * @group Implementation\n * @category Serialization\n */\n toStringShortWithoutPrefix(): string {\n const hex = bytesToHex(this.data).replace(/^0+/, \"\");\n return hex === \"\" ? \"0\" : hex;\n }\n\n /**\n * Get the inner data as a Uint8Array.\n * The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Serialize the AccountAddress to a Serializer instance's data buffer.\n * @param serializer The serializer to serialize the AccountAddress to.\n * @returns void\n * @example\n * const serializer = new Serializer();\n * const address = AccountAddress.fromString(\"0x1\");\n * address.serialize(serializer);\n * const bytes = serializer.toUint8Array();\n * // `bytes` is now the BCS-serialized address.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows for the proper encoding of data when interacting with entry functions in the blockchain.\n *\n * @param serializer - The serializer instance used to convert the data into bytes.\n * @group Implementation\n * @category Serialization\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function by encoding it into a byte sequence.\n * This process involves serializing the variant index and the instance data, making it suitable for transmission.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Address);\n serializer.serialize(this);\n }\n\n /**\n * Deserialize an AccountAddress from the byte buffer in a Deserializer instance.\n * This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.\n * @param deserializer The deserializer to deserialize the AccountAddress from.\n * @returns An instance of AccountAddress.\n * @example\n * const bytes = hexToBytes(\"0x0102030405060708091011121314151617181920212223242526272829303132\");\n * const deserializer = new Deserializer(bytes);\n * const address = AccountAddress.deserialize(deserializer);\n * // `address` is now an instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AccountAddress {\n const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);\n return new AccountAddress(bytes);\n }\n\n // ===\n // Methods for creating an instance of AccountAddress from other types.\n // ===\n\n /**\n * NOTE: This function has strict parsing behavior. For relaxed behavior, please use\n * the `fromString` function.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows only the strictest formats defined by AIP-40. In short this\n * means only the following formats are accepted:\n *\n * - LONG\n * - SHORT for special addresses\n *\n * Where:\n * - LONG is defined as 0x + 64 hex characters.\n * - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.\n *\n * This means the following are not accepted:\n * - SHORT for non-special addresses.\n * - Any address without a leading 0x.\n *\n * @param input - A hex string representing an account address.\n *\n * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.\n *\n * @remarks\n *\n * This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.\n *\n * @see AIP-40 documentation for more details on address formats:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns An instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStringStrict(input: string): AccountAddress {\n // Assert the string starts with 0x.\n if (!input.startsWith(\"0x\")) {\n throw new ParsingError(\"Hex string must start with a leading 0x.\", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);\n }\n\n const address = AccountAddress.fromString(input);\n\n // Check if the address is in LONG form. If it is not, this is only allowed for\n // special addresses, in which case we check it is in proper SHORT form.\n if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,\n AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,\n );\n } else if (input.length !== 3) {\n // 0x + one hex char is the only valid SHORT form for special addresses.\n throw new ParsingError(\n // eslint-disable-next-line max-len\n `The given hex string ${input} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,\n AddressInvalidReason.INVALID_PADDING_ZEROES,\n );\n }\n }\n\n return address;\n }\n\n /**\n * NOTE: This function has relaxed parsing behavior. For strict behavior, please use\n * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this\n * function, `fromString`.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows all formats defined by AIP-40. In short this means the\n * following formats are accepted:\n *\n * - LONG, with or without leading 0x\n * - SHORT*, with or without leading 0x\n *\n * Where:\n * - LONG is 64 hex characters.\n * - SHORT* is 1 to 63 hex characters inclusive. The address can have missing values up to `maxMissingChars` before it is padded.\n * - Padding zeroes are allowed, e.g. 0x0123 is valid.\n *\n * Learn more about the different address formats by reading AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @param input A hex string representing an account address.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n *\n * @returns An instance of AccountAddress.\n *\n * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.\n * @group Implementation\n * @category Serialization\n */\n static fromString(input: string, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n let parsedInput = input;\n // Remove leading 0x for parsing.\n if (input.startsWith(\"0x\")) {\n parsedInput = input.slice(2);\n }\n\n // Ensure the address string is at least 1 character long.\n if (parsedInput.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_SHORT,\n );\n }\n\n // Ensure the address string is not longer than 64 characters.\n if (parsedInput.length > 64) {\n throw new ParsingError(\n \"Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_LONG,\n );\n }\n\n // Ensure that the maxMissingChars is between or equal to 0 and 63.\n if (maxMissingChars > 63 || maxMissingChars < 0) {\n throw new ParsingError(\n `maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`,\n AddressInvalidReason.INVALID_PADDING_STRICTNESS,\n );\n }\n\n let addressBytes: Uint8Array;\n try {\n // Pad the address with leading zeroes, so it is 64 chars long and then convert\n // the hex string to bytes. Every two characters in a hex string constitutes a\n // single byte. So a 64 length hex string becomes a 32 byte array.\n addressBytes = hexToBytes(parsedInput.padStart(64, \"0\"));\n } catch (error: any) {\n // At this point the only way this can fail is if the hex string contains\n // invalid characters.\n throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);\n }\n\n const address = new AccountAddress(addressBytes);\n\n // Cannot pad the address if it has more than maxMissingChars missing.\n if (parsedInput.length < 64 - maxMissingChars) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `Hex string is too short, must be ${64 - maxMissingChars} to 64 chars long, excluding the leading 0x. You may need to fix \nthe addresss by padding it with 0s before passing it to \\`fromString\\` (e.g. <addressString>.padStart(64, '0')). \nReceived ${input}`,\n AddressInvalidReason.TOO_SHORT,\n );\n }\n }\n\n return address;\n }\n\n /**\n * Convenience method for creating an AccountAddress from various input types.\n * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding\n * AccountAddress.\n *\n * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,\n * or an existing AccountAddress.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n * @group Implementation\n * @category Serialization\n */\n static from(input: AccountAddressInput, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input, { maxMissingChars });\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n\n /**\n * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.\n *\n * @param input - The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStrict(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromStringStrict(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided input is a valid AccountAddress.\n *\n * @param args - The arguments for validation.\n * @param args.input - A hex string representing an account address.\n * @param args.strict - If true, use strict parsing behavior; if false, use relaxed parsing behavior.\n *\n * @returns An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details.\n * If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.\n * @group Implementation\n * @category Serialization\n */\n static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {\n try {\n if (args.strict) {\n AccountAddress.fromStrict(args.input);\n } else {\n AccountAddress.from(args.input);\n }\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two AccountAddresses are equal based on their underlying byte data.\n *\n * @param other - The AccountAddress to compare to.\n * @returns true if the AccountAddresses are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: AccountAddress): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChildProcessWithoutNullStreams } from 'child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { eo as Network, b as AccountAddress } from '../accountAddress-CQEq9RVR.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents a local node for running a localnet environment.
|