@aptos-labs/ts-sdk 0.0.0 → 0.0.1

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.
Files changed (42) hide show
  1. package/README.md +12 -2
  2. package/dist/browser/index.global.js +25 -25
  3. package/dist/browser/index.global.js.map +1 -1
  4. package/dist/cjs/index.d.ts +50 -3
  5. package/dist/cjs/index.js +43 -16
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/esm/index.d.ts +50 -3
  8. package/dist/esm/index.mjs +42 -16
  9. package/dist/esm/index.mjs.map +1 -1
  10. package/dist/types/index.d.ts +24 -2
  11. package/dist/types/index.js.map +1 -1
  12. package/package.json +1 -1
  13. package/src/api/account.ts +26 -6
  14. package/src/api/aptosConfig.ts +8 -1
  15. package/src/api/fungibleAsset.ts +25 -0
  16. package/src/api/general.ts +2 -2
  17. package/src/api/transaction.ts +9 -2
  18. package/src/api/transactionSubmission.ts +34 -10
  19. package/src/bcs/serializable/fixedBytes.ts +1 -1
  20. package/src/client/core.ts +15 -17
  21. package/src/client/get.ts +1 -1
  22. package/src/client/post.ts +2 -2
  23. package/src/core/account.ts +74 -33
  24. package/src/core/authenticationKey.ts +29 -13
  25. package/src/core/crypto/anyPublicKey.ts +84 -0
  26. package/src/core/crypto/anySignature.ts +56 -0
  27. package/src/core/crypto/ed25519.ts +10 -0
  28. package/src/core/crypto/secp256k1.ts +11 -1
  29. package/src/internal/account.ts +78 -6
  30. package/src/internal/coin.ts +1 -1
  31. package/src/internal/digitalAsset.ts +2 -6
  32. package/src/internal/faucet.ts +5 -1
  33. package/src/internal/general.ts +1 -1
  34. package/src/internal/transaction.ts +2 -1
  35. package/src/internal/transactionSubmission.ts +47 -6
  36. package/src/transactions/authenticator/account.ts +16 -15
  37. package/src/transactions/authenticator/transaction.ts +15 -22
  38. package/src/transactions/transaction_builder/transaction_builder.ts +27 -28
  39. package/src/transactions/typeTag/parser.ts +285 -0
  40. package/src/transactions/types.ts +2 -2
  41. package/src/types/index.ts +93 -15
  42. package/src/version.ts +1 -1
@@ -87,7 +87,7 @@ export enum TransactionAuthenticatorVariant {
87
87
  MultiEd25519 = 1,
88
88
  MultiAgent = 2,
89
89
  FeePayer = 3,
90
- Secp256k1Ecdsa = 4,
90
+ SingleSenderTransactionAuthenticator = 4,
91
91
  }
92
92
 
93
93
  /**
@@ -97,7 +97,18 @@ export enum TransactionAuthenticatorVariant {
97
97
  export enum AccountAuthenticatorVariant {
98
98
  Ed25519 = 0,
99
99
  MultiEd25519 = 1,
100
- Secp256k1 = 2,
100
+ SingleKey = 2,
101
+ MultiKey = 3,
102
+ }
103
+
104
+ export enum AnyPublicKeyVariant {
105
+ Ed25519 = 0,
106
+ Secp256k1 = 1,
107
+ }
108
+
109
+ export enum AnySignatureVariant {
110
+ Ed25519 = 0,
111
+ Secp256k1 = 1,
101
112
  }
102
113
 
103
114
  /**
@@ -117,7 +128,7 @@ export type AnyNumber = number | bigint;
117
128
  * behavior and interaction with the Aptos network
118
129
  */
119
130
  export type AptosSettings = {
120
- readonly network: Network;
131
+ readonly network?: Network;
121
132
 
122
133
  readonly fullnode?: string;
123
134
 
@@ -126,6 +137,8 @@ export type AptosSettings = {
126
137
  readonly indexer?: string;
127
138
 
128
139
  readonly clientConfig?: ClientConfig;
140
+
141
+ readonly client?: Client;
129
142
  };
130
143
 
131
144
  /**
@@ -156,6 +169,30 @@ export type ClientConfig = {
156
169
  WITH_CREDENTIALS?: boolean;
157
170
  };
158
171
 
172
+ export interface ClientRequest<Req> {
173
+ url: string;
174
+ method: "GET" | "POST";
175
+ body?: Req;
176
+ contentType?: string;
177
+ params?: any;
178
+ overrides?: ClientConfig;
179
+ headers?: Record<string, any>;
180
+ }
181
+
182
+ export interface ClientResponse<Res> {
183
+ status: number;
184
+ statusText: string;
185
+ data: Res;
186
+ config?: any;
187
+ request?: any;
188
+ response?: any;
189
+ headers?: any;
190
+ }
191
+
192
+ export interface Client {
193
+ provider<Req, Res>(requestOptions: ClientRequest<Req>): Promise<ClientResponse<Res>>;
194
+ }
195
+
159
196
  /**
160
197
  * The API request type
161
198
  *
@@ -639,9 +676,9 @@ export type MoveUint32Type = number;
639
676
  export type MoveUint64Type = string;
640
677
  export type MoveUint128Type = string;
641
678
  export type MoveUint256Type = string;
642
- export type MoveAddressType = `0x${string}`;
643
- export type MoveObjectType = `0x${string}`;
644
- export type MoveStructType = `0x${string}::${string}::${string}`;
679
+ export type MoveAddressType = string;
680
+ export type MoveObjectType = string;
681
+ export type MoveStructType = `${string}::${string}::${string}`;
645
682
  export type MoveOptionType = MoveType | null | undefined;
646
683
  /**
647
684
  * String representation of a on-chain Move struct type.
@@ -840,7 +877,7 @@ export type LedgerInfo = {
840
877
  */
841
878
  export type Block = {
842
879
  block_height: string;
843
- block_hash: `0x${string}`;
880
+ block_hash: string;
844
881
  block_timestamp: string;
845
882
  first_version: string;
846
883
  last_version: string;
@@ -856,7 +893,7 @@ export type Block = {
856
893
  export type ViewRequestData = {
857
894
  function: MoveStructType;
858
895
  typeArguments?: Array<MoveResourceType>;
859
- arguments?: Array<MoveValue>;
896
+ functionArguments?: Array<MoveValue>;
860
897
  };
861
898
 
862
899
  // REQUEST TYPES
@@ -875,7 +912,7 @@ export type ViewRequest = {
875
912
  /**
876
913
  * Arguments of the function
877
914
  */
878
- arguments: Array<MoveValue>;
915
+ functionArguments: Array<MoveValue>;
879
916
  };
880
917
 
881
918
  /**
@@ -897,11 +934,6 @@ export type TableItemRequest = {
897
934
  */
898
935
  export type AuthenticationKeyScheme = SigningScheme | DeriveScheme;
899
936
 
900
- /**
901
- * A list of signing schemes that are supported by Aptos.
902
- *
903
- * https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L375-L378
904
- */
905
937
  export enum SigningScheme {
906
938
  /**
907
939
  * For Ed25519PublicKey
@@ -912,7 +944,22 @@ export enum SigningScheme {
912
944
  */
913
945
  MultiEd25519 = 1,
914
946
  /**
915
- * For Secp256k1 ecdsa
947
+ * For SingleKey ecdsa
948
+ */
949
+ SingleKey = 2,
950
+ }
951
+
952
+ export enum SigningSchemeInput {
953
+ /**
954
+ * For Ed25519PublicKey
955
+ */
956
+ Ed25519 = 0,
957
+ /**
958
+ * For MultiEd25519PublicKey
959
+ */
960
+ MultiEd25519 = 1,
961
+ /**
962
+ * For Secp256k1Ecdsa
916
963
  */
917
964
  Secp256k1Ecdsa = 2,
918
965
  }
@@ -942,3 +989,34 @@ export enum DeriveScheme {
942
989
  */
943
990
  DeriveResourceAccountAddress = 255,
944
991
  }
992
+
993
+ export type WaitForTransactionOptions = {
994
+ timeoutSecs?: number;
995
+ checkSuccess?: boolean;
996
+ indexerVersionCheck?: boolean;
997
+ };
998
+ /**
999
+ * Account input type to generate an account using Legacy
1000
+ * Ed25519 or MultiEd25519 keys or without a specified `scheme`.
1001
+ * If `scheme` is not specified, we default to ED25519
1002
+ * In this case `legacy` is always true
1003
+ */
1004
+ export type GenerateAccountWithLegacyKey = {
1005
+ scheme?: SigningSchemeInput.Ed25519 | SigningSchemeInput.MultiEd25519;
1006
+ legacy: true;
1007
+ };
1008
+
1009
+ /**
1010
+ * Account input type to generate an account using Unified
1011
+ * Secp256k1Ecdsa key
1012
+ * In this case `legacy` is always false
1013
+ */
1014
+ export type GenerateAccountWithUnifiedKey = {
1015
+ scheme: SigningSchemeInput.Secp256k1Ecdsa | SigningSchemeInput.Ed25519;
1016
+ legacy?: false;
1017
+ };
1018
+
1019
+ /**
1020
+ * Unify GenerateAccount type for Legacy and Unified keys
1021
+ */
1022
+ export type GenerateAccount = GenerateAccountWithLegacyKey | GenerateAccountWithUnifiedKey;
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * hardcoded for now, we would want to have it injected dynamically
8
8
  */
9
- export const VERSION = "0.0.0";
9
+ export const VERSION = "2.0.0";