@thalalabs/surf 0.0.16 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +44 -45
  3. package/build/cjs/core/Client.js +55 -41
  4. package/build/cjs/core/Client.js.map +1 -1
  5. package/build/cjs/core/WalletClient.js +20 -31
  6. package/build/cjs/core/WalletClient.js.map +1 -1
  7. package/build/cjs/core/createEntryPayload.js +9 -91
  8. package/build/cjs/core/createEntryPayload.js.map +1 -1
  9. package/build/cjs/core/createViewPayload.js +26 -52
  10. package/build/cjs/core/createViewPayload.js.map +1 -1
  11. package/build/cjs/core/index.js +2 -2
  12. package/build/cjs/core/index.js.map +1 -1
  13. package/build/cjs/ensureTypes.js.map +1 -1
  14. package/build/cjs/hooks/index.js.map +1 -1
  15. package/build/cjs/hooks/useSubmitTransaction.js +25 -46
  16. package/build/cjs/hooks/useSubmitTransaction.js.map +1 -1
  17. package/build/cjs/hooks/useWalletClient.js +2 -2
  18. package/build/cjs/hooks/useWalletClient.js.map +1 -1
  19. package/build/cjs/index.js +2 -2
  20. package/build/cjs/index.js.map +1 -1
  21. package/build/esm/core/Client.js +53 -39
  22. package/build/esm/core/Client.js.map +1 -1
  23. package/build/esm/core/WalletClient.js +20 -31
  24. package/build/esm/core/WalletClient.js.map +1 -1
  25. package/build/esm/core/createEntryPayload.js +9 -91
  26. package/build/esm/core/createEntryPayload.js.map +1 -1
  27. package/build/esm/core/createViewPayload.js +26 -52
  28. package/build/esm/core/createViewPayload.js.map +1 -1
  29. package/build/esm/core/index.js +1 -1
  30. package/build/esm/core/index.js.map +1 -1
  31. package/build/esm/ensureTypes.js.map +1 -1
  32. package/build/esm/hooks/index.js.map +1 -1
  33. package/build/esm/hooks/useSubmitTransaction.js +25 -46
  34. package/build/esm/hooks/useSubmitTransaction.js.map +1 -1
  35. package/build/esm/hooks/useWalletClient.js +2 -2
  36. package/build/esm/hooks/useWalletClient.js.map +1 -1
  37. package/build/esm/index.js +1 -1
  38. package/build/esm/index.js.map +1 -1
  39. package/build/types/core/Client.d.ts +61 -48
  40. package/build/types/core/Client.d.ts.map +1 -1
  41. package/build/types/core/WalletClient.d.ts +3 -5
  42. package/build/types/core/WalletClient.d.ts.map +1 -1
  43. package/build/types/core/createEntryPayload.d.ts +8 -8
  44. package/build/types/core/createEntryPayload.d.ts.map +1 -1
  45. package/build/types/core/createViewPayload.d.ts +4 -4
  46. package/build/types/core/createViewPayload.d.ts.map +1 -1
  47. package/build/types/core/index.d.ts +1 -1
  48. package/build/types/core/index.d.ts.map +1 -1
  49. package/build/types/ensureTypes.d.ts.map +1 -1
  50. package/build/types/hooks/index.d.ts +1 -1
  51. package/build/types/hooks/index.d.ts.map +1 -1
  52. package/build/types/hooks/useSubmitTransaction.d.ts +3 -11
  53. package/build/types/hooks/useSubmitTransaction.d.ts.map +1 -1
  54. package/build/types/hooks/useWalletClient.d.ts +1 -3
  55. package/build/types/hooks/useWalletClient.d.ts.map +1 -1
  56. package/build/types/index.d.ts +1 -1
  57. package/build/types/index.d.ts.map +1 -1
  58. package/build/types/types/abi.d.ts.map +1 -1
  59. package/build/types/types/client/abiClient.d.ts +12 -16
  60. package/build/types/types/client/abiClient.d.ts.map +1 -1
  61. package/build/types/types/client/client.d.ts +11 -23
  62. package/build/types/types/client/client.d.ts.map +1 -1
  63. package/build/types/types/convertor/argsConvertor.d.ts +1 -1
  64. package/build/types/types/convertor/argsConvertor.d.ts.map +1 -1
  65. package/build/types/types/convertor/genericConvertor.d.ts.map +1 -1
  66. package/build/types/types/convertor/returnConvertor.d.ts +1 -1
  67. package/build/types/types/index.d.ts +1 -1
  68. package/build/types/types/index.d.ts.map +1 -1
  69. package/package.json +8 -9
  70. package/src/core/Client.ts +110 -114
  71. package/src/core/WalletClient.ts +21 -31
  72. package/src/core/__tests__/accountResource.test.ts +56 -54
  73. package/src/core/__tests__/createEntryPayload.test.ts +34 -34
  74. package/src/core/__tests__/createViewPayload.test.ts +94 -111
  75. package/src/core/__tests__/option.test.ts +38 -31
  76. package/src/core/__tests__/submitTransaction.test.ts +58 -26
  77. package/src/core/__tests__/useABI.test.ts +38 -38
  78. package/src/core/__tests__/view.test.ts +36 -30
  79. package/src/core/__tests__/view_vector.test.ts +52 -50
  80. package/src/core/createEntryPayload.ts +24 -143
  81. package/src/core/createViewPayload.ts +40 -68
  82. package/src/core/index.ts +1 -1
  83. package/src/ensureTypes.ts +1 -0
  84. package/src/hooks/index.ts +0 -1
  85. package/src/hooks/useSubmitTransaction.ts +35 -68
  86. package/src/hooks/useWalletClient.ts +2 -2
  87. package/src/index.ts +1 -1
  88. package/src/types/abi.ts +1 -0
  89. package/src/types/client/abiClient.ts +12 -16
  90. package/src/types/client/client.ts +11 -25
  91. package/src/types/convertor/argsConvertor.ts +1 -1
  92. package/src/types/convertor/genericConvertor.ts +2 -0
  93. package/src/types/convertor/returnConvertor.ts +3 -3
  94. package/src/types/index.ts +0 -2
@@ -2,7 +2,6 @@
2
2
  * The types for the `Client` class.
3
3
  */
4
4
 
5
- import { AptosAccount, TxnBuilderTypes } from 'aptos';
6
5
  import { ABIRoot } from '../abi.js';
7
6
  import {
8
7
  EntryFunctionName,
@@ -11,29 +10,19 @@ import {
11
10
  ViewFunctionName,
12
11
  ExtractArgsType,
13
12
  } from '../extractor/functionExtractor.js';
13
+ import { EntryFunctionArgumentTypes, MoveFunctionId, MoveStructId, MoveValue, SimpleEntryFunctionArgumentTypes } from '@aptos-labs/ts-sdk';
14
14
 
15
15
  export type TransactionResponse = {
16
16
  hash: string;
17
17
  };
18
18
 
19
- export type EntryOptions = {
20
- account: AptosAccount;
21
- };
22
-
23
- export type ViewOptions = {
24
- ledger_version?: string;
25
- };
26
-
27
19
  /**
28
20
  * The return payload type of `createEntryPayload`
29
21
  */
30
22
  export type EntryPayload = {
31
- rawPayload: {
32
- function: string;
33
- type_arguments: string[];
34
- arguments: any[];
35
- };
36
- entryRequest: TxnBuilderTypes.EntryFunction;
23
+ function: MoveFunctionId;
24
+ typeArguments: Array<string>;
25
+ functionArguments: Array<EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes>;
37
26
  };
38
27
 
39
28
  /**
@@ -44,8 +33,8 @@ export type EntryRequestPayload<
44
33
  TFuncName extends EntryFunctionName<T>,
45
34
  > = {
46
35
  function: TFuncName;
47
- arguments: ExtractArgsTypeOmitSigner<T, TFuncName>;
48
- type_arguments: ExtractGenericArgsType<T, TFuncName>;
36
+ functionArguments: ExtractArgsTypeOmitSigner<T, TFuncName>;
37
+ typeArguments: ExtractGenericArgsType<T, TFuncName>;
49
38
  };
50
39
 
51
40
  /**
@@ -56,18 +45,15 @@ export type ViewRequestPayload<
56
45
  TFuncName extends ViewFunctionName<T>,
57
46
  > = {
58
47
  function: TFuncName;
59
- arguments: ExtractArgsType<T, TFuncName>;
60
- type_arguments: ExtractGenericArgsType<T, TFuncName>;
48
+ functionArguments: ExtractArgsType<T, TFuncName>;
49
+ typeArguments: ExtractGenericArgsType<T, TFuncName>;
61
50
  };
62
51
 
63
52
  /**
64
53
  * The return payload type of `createViewPayload`
65
54
  */
66
55
  export type ViewPayload<_TReturn> = {
67
- viewRequest: {
68
- function: string;
69
- type_arguments: string[];
70
- arguments: any[];
71
- };
72
- decoders: (((value: any) => any) | null)[];
56
+ function: MoveFunctionId;
57
+ typeArguments?: Array<MoveStructId>;
58
+ functionArguments?: Array<MoveValue>;
73
59
  };
@@ -57,5 +57,5 @@ type ConvertNonStructArgType<TMoveType extends MoveNonStructTypes> =
57
57
  : TMoveType extends `0x1::object::Object<${string}>`
58
58
  ? `0x${string}`
59
59
  : TMoveType extends `0x1::option::Option<${infer TInner}>`
60
- ? [ConvertArgType<TInner>] | []
60
+ ? ConvertArgType<TInner> | null
61
61
  : UnknownStruct<TMoveType>;
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Convert an array of generic arguments from Move type to TypeScript type.
3
3
  */
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
5
  export type ConvertGenerics<T extends readonly any[]> = T extends readonly [
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
7
  any,
6
8
  ...infer TRest,
7
9
  ]
@@ -36,11 +36,11 @@ type ConvertPrimitiveReturnType<TMoveType extends MovePrimitive> =
36
36
  : TMoveType extends 'u32'
37
37
  ? number
38
38
  : TMoveType extends 'u64'
39
- ? bigint
39
+ ? string
40
40
  : TMoveType extends 'u128'
41
- ? bigint
41
+ ? string
42
42
  : TMoveType extends 'u256'
43
- ? bigint
43
+ ? string
44
44
  : TMoveType extends 'address'
45
45
  ? `0x${string}`
46
46
  : TMoveType extends '0x1::string::String'
@@ -7,8 +7,6 @@ export type {
7
7
  export type {
8
8
  ViewPayload,
9
9
  EntryPayload,
10
- ViewOptions,
11
- EntryOptions,
12
10
  ViewRequestPayload,
13
11
  EntryRequestPayload,
14
12
  TransactionResponse,