@typemove/aptos 1.13.5-rc.2 → 2.0.0-rc.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 (96) hide show
  1. package/dist/esm/codegen/run.js +2 -2
  2. package/package.json +3 -3
  3. package/dist/esm/account-resource-client.d.ts +0 -28
  4. package/dist/esm/account-resource-client.d.ts.map +0 -1
  5. package/dist/esm/account-resource-client.js +0 -47
  6. package/dist/esm/account-resource-client.js.map +0 -1
  7. package/dist/esm/account-resource-client.test.d.ts +0 -2
  8. package/dist/esm/account-resource-client.test.d.ts.map +0 -1
  9. package/dist/esm/account-resource-client.test.js.map +0 -1
  10. package/dist/esm/aptos-chain-adapter.d.ts +0 -19
  11. package/dist/esm/aptos-chain-adapter.d.ts.map +0 -1
  12. package/dist/esm/aptos-chain-adapter.js +0 -101
  13. package/dist/esm/aptos-chain-adapter.js.map +0 -1
  14. package/dist/esm/builtin/0x1.d.ts +0 -7522
  15. package/dist/esm/builtin/0x1.d.ts.map +0 -1
  16. package/dist/esm/builtin/0x1.js +0 -11632
  17. package/dist/esm/builtin/0x1.js.map +0 -1
  18. package/dist/esm/builtin/0x3.d.ts +0 -1087
  19. package/dist/esm/builtin/0x3.d.ts.map +0 -1
  20. package/dist/esm/builtin/0x3.js +0 -926
  21. package/dist/esm/builtin/0x3.js.map +0 -1
  22. package/dist/esm/builtin/0x4.d.ts +0 -535
  23. package/dist/esm/builtin/0x4.d.ts.map +0 -1
  24. package/dist/esm/builtin/0x4.js +0 -884
  25. package/dist/esm/builtin/0x4.js.map +0 -1
  26. package/dist/esm/builtin/index.d.ts +0 -4
  27. package/dist/esm/builtin/index.d.ts.map +0 -1
  28. package/dist/esm/builtin/index.js +0 -7
  29. package/dist/esm/builtin/index.js.map +0 -1
  30. package/dist/esm/client.test.d.ts +0 -2
  31. package/dist/esm/client.test.d.ts.map +0 -1
  32. package/dist/esm/client.test.js.map +0 -1
  33. package/dist/esm/codegen/codegen.d.ts +0 -18
  34. package/dist/esm/codegen/codegen.d.ts.map +0 -1
  35. package/dist/esm/codegen/codegen.js +0 -161
  36. package/dist/esm/codegen/codegen.js.map +0 -1
  37. package/dist/esm/codegen/index.d.ts +0 -2
  38. package/dist/esm/codegen/index.d.ts.map +0 -1
  39. package/dist/esm/codegen/index.js +0 -2
  40. package/dist/esm/codegen/index.js.map +0 -1
  41. package/dist/esm/codegen/run.d.ts +0 -3
  42. package/dist/esm/codegen/run.d.ts.map +0 -1
  43. package/dist/esm/codegen/run.js.map +0 -1
  44. package/dist/esm/codegen/types.test.d.ts +0 -2
  45. package/dist/esm/codegen/types.test.d.ts.map +0 -1
  46. package/dist/esm/codegen/types.test.js.map +0 -1
  47. package/dist/esm/coder-helpers.d.ts +0 -6
  48. package/dist/esm/coder-helpers.d.ts.map +0 -1
  49. package/dist/esm/coder-helpers.js +0 -8
  50. package/dist/esm/coder-helpers.js.map +0 -1
  51. package/dist/esm/index.d.ts +0 -5
  52. package/dist/esm/index.d.ts.map +0 -1
  53. package/dist/esm/index.js +0 -5
  54. package/dist/esm/index.js.map +0 -1
  55. package/dist/esm/models.d.ts +0 -12
  56. package/dist/esm/models.d.ts.map +0 -1
  57. package/dist/esm/models.js +0 -2
  58. package/dist/esm/models.js.map +0 -1
  59. package/dist/esm/move-coder.d.ts +0 -17
  60. package/dist/esm/move-coder.d.ts.map +0 -1
  61. package/dist/esm/move-coder.js +0 -97
  62. package/dist/esm/move-coder.js.map +0 -1
  63. package/dist/esm/to-internal.d.ts +0 -7
  64. package/dist/esm/to-internal.d.ts.map +0 -1
  65. package/dist/esm/to-internal.js +0 -55
  66. package/dist/esm/to-internal.js.map +0 -1
  67. package/src/abis/0x1.json +0 -43414
  68. package/src/abis/0x3.json +0 -3976
  69. package/src/abis/0x4.json +0 -2844
  70. package/src/account-resource-client.ts +0 -69
  71. package/src/aptos-chain-adapter.ts +0 -129
  72. package/src/builtin/0x1.ts +0 -19976
  73. package/src/builtin/0x3.ts +0 -2083
  74. package/src/builtin/0x4.ts +0 -1503
  75. package/src/builtin/index.ts +0 -6
  76. package/src/codegen/codegen.ts +0 -190
  77. package/src/codegen/index.ts +0 -1
  78. package/src/codegen/run.ts +0 -70
  79. package/src/coder-helpers.ts +0 -15
  80. package/src/index.ts +0 -4
  81. package/src/models.ts +0 -23
  82. package/src/move-coder.ts +0 -124
  83. package/src/tests/abis/0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af.json +0 -3265
  84. package/src/tests/abis/0x4dcae85fc5559071906cd5c76b7420fcbb4b0a92f00ab40ffc394aadbbff5ee9.json +0 -637
  85. package/src/tests/abis/0x6b3720cd988adeaf721ed9d4730da4324d52364871a68eac62b46d21e4d2fa99.json +0 -1099
  86. package/src/tests/abis/0x7fd500c11216f0fe3095d0c4b8aa4d64a4e2e04f83758462f2b127255643615.json +0 -409
  87. package/src/tests/abis/0x87978b35bf1eb73ae6cf04cfedcaa1f48254a683ebd00a21e7516a991edae3ac.json +0 -219
  88. package/src/tests/abis/0xbd35135844473187163ca197ca93b2ab014370587bb0ed3befff9e902d6bb541.json +0 -3717
  89. package/src/tests/types/0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af.ts +0 -2805
  90. package/src/tests/types/0x4dcae85fc5559071906cd5c76b7420fcbb4b0a92f00ab40ffc394aadbbff5ee9.ts +0 -89
  91. package/src/tests/types/0x6b3720cd988adeaf721ed9d4730da4324d52364871a68eac62b46d21e4d2fa99.ts +0 -1649
  92. package/src/tests/types/0x7fd500c11216f0fe3095d0c4b8aa4d64a4e2e04f83758462f2b127255643615.ts +0 -744
  93. package/src/tests/types/0x87978b35bf1eb73ae6cf04cfedcaa1f48254a683ebd00a21e7516a991edae3ac.ts +0 -126
  94. package/src/tests/types/0xbd35135844473187163ca197ca93b2ab014370587bb0ed3befff9e902d6bb541.ts +0 -2165
  95. package/src/tests/types/index.ts +0 -9
  96. package/src/to-internal.ts +0 -71
@@ -1,69 +0,0 @@
1
- import {
2
- AccountAddressInput,
3
- Aptos,
4
- MoveStructId,
5
- LedgerVersionArg,
6
- PaginationArgs,
7
- MoveResource
8
- } from '@aptos-labs/ts-sdk'
9
- import { TypeDescriptor } from '@typemove/move'
10
- import { defaultMoveCoder } from './move-coder.js'
11
- import { TypedMoveResource } from './models.js'
12
-
13
- // type ResourceQuery = {
14
- // ledgerVersion?: bigint | number
15
- // }
16
-
17
- export class AccountResourceClient {
18
- client: Aptos
19
- constructor(client: Aptos) {
20
- this.client = client
21
- }
22
-
23
- /**
24
- * Get all resources of an account, same as `getAccountResources` in aptos client
25
- * @param accountAddress
26
- * @param query
27
- */
28
- async getAll(accountAddress: AccountAddressInput, options?: PaginationArgs & LedgerVersionArg) {
29
- return this.client.getAccountResources({ accountAddress, options })
30
- }
31
-
32
- /**
33
- * Match a single resource with exact type, resource type should not contain any type
34
- * @param accountAddress
35
- * @param resourceType
36
- * @param options
37
- */
38
- async matchExact<T>(
39
- accountAddress: AccountAddressInput,
40
- resourceType: TypeDescriptor<T>,
41
- options?: LedgerVersionArg
42
- ): Promise<TypedMoveResource<T> | undefined> {
43
- if (resourceType.existAnyType()) {
44
- throw new Error('resource type for match call should not contain any type')
45
- }
46
- const typeStr = resourceType.getSignature() as MoveStructId
47
- const result = await this.client.getAccountResource({ accountAddress, resourceType: typeStr, options })
48
- const resource: MoveResource = {
49
- type: typeStr,
50
- data: result
51
- }
52
- return defaultMoveCoder(this.client.config).decodeResource<T>(resource)
53
- }
54
-
55
- /**
56
- * Match all resources with type pattern, it could be a partial type like `amm.Pool<aptos_coin.AptosCoin.type(), ANY_TYPE>`
57
- * @param accountAddress
58
- * @param resourceType
59
- * @param options
60
- */
61
- async matchAll<T>(
62
- accountAddress: AccountAddressInput,
63
- resourceType: TypeDescriptor<T>,
64
- options?: PaginationArgs & LedgerVersionArg
65
- ): Promise<TypedMoveResource<T>[]> {
66
- const result = await this.client.getAccountResources({ accountAddress, options })
67
- return defaultMoveCoder(this.client.config).filterAndDecodeResources<T>(resourceType, result)
68
- }
69
- }
@@ -1,129 +0,0 @@
1
- import {
2
- ChainAdapter,
3
- moduleQname,
4
- SPLITTER,
5
- TypeDescriptor,
6
- InternalMoveModule,
7
- InternalMoveStruct
8
- } from '@typemove/move'
9
-
10
- import { Aptos, Event, MoveModuleBytecode, MoveResource } from '@aptos-labs/ts-sdk'
11
- import { toInternalModule } from './to-internal.js'
12
-
13
- export class AptosChainAdapter extends ChainAdapter<MoveModuleBytecode, Event | MoveResource> {
14
- // static INSTANCE = new AptosChainAdapter()
15
- client: Aptos
16
- private optimisticEventDetection: boolean = true
17
-
18
- constructor(client: Aptos, optimisticEventDetection = true) {
19
- super()
20
- this.client = client
21
- this.optimisticEventDetection = optimisticEventDetection
22
- }
23
-
24
- async fetchModules(account: string): Promise<MoveModuleBytecode[]> {
25
- return await this.client.getAccountModules({
26
- accountAddress: account
27
- })
28
- }
29
-
30
- async fetchModule(account: string, module: string): Promise<MoveModuleBytecode> {
31
- return await this.client.getAccountModule({
32
- accountAddress: account,
33
- moduleName: module
34
- })
35
- }
36
-
37
- toInternalModules(modules: MoveModuleBytecode[]): InternalMoveModule[] {
38
- return modules.flatMap((m) => (m.abi ? [toInternalModule(m)] : []))
39
- }
40
-
41
- // Drop bytecode from cached ABI files — only `abi` is consumed by codegen,
42
- // and bytecode is ~50% of each Aptos ABI JSON's bytes.
43
- override toPersistableModules(modules: MoveModuleBytecode[]) {
44
- return modules.map(({ abi }) => ({ abi }))
45
- }
46
-
47
- getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
48
- if (params.length === 0) {
49
- return params
50
- }
51
- if (params[0].qname === 'signer' && params[0].reference) {
52
- params = params.slice(1)
53
- }
54
- return params
55
- }
56
-
57
- getAllEventStructs(modules: InternalMoveModule[]) {
58
- const eventMap = new Map<string, InternalMoveStruct>()
59
- const structMap = new Map<string, InternalMoveStruct>()
60
- for (const module of modules) {
61
- const qname = moduleQname(module)
62
- for (const struct of module.structs) {
63
- const typeName = qname + SPLITTER + struct.name
64
-
65
- // Skip deprecated v2 events
66
- if (typeName == '0x1::coin::Deposit' || typeName == '0x1::coin::Withdraw') {
67
- continue
68
- }
69
-
70
- structMap.set(typeName, struct)
71
-
72
- // Check if struct is explicitly marked as event
73
- if (struct.isEvent) {
74
- eventMap.set(typeName, struct)
75
- continue
76
- }
77
-
78
- if (struct.name.endsWith('Event')) {
79
- // this is a hack to support some old events
80
- eventMap.set(typeName, struct)
81
- continue
82
- }
83
-
84
- // Check for native events: structs with EXACTLY drop and store abilities
85
- if (this.optimisticEventDetection) {
86
- const abilities = new Set(struct.abilities)
87
- if (abilities.size === 2 && abilities.has('drop') && abilities.has('store')) {
88
- eventMap.set(typeName, struct)
89
- }
90
- }
91
- }
92
- }
93
-
94
- // Also check for legacy events (in EventHandle fields)
95
- for (const module of modules) {
96
- for (const struct of module.structs) {
97
- for (const field of struct.fields) {
98
- const t = field.type
99
- if (t.qname === '0x1::event::EventHandle') {
100
- const event = t.typeArgs[0].qname
101
- const eventStruct = structMap.get(event)
102
- if (eventStruct) {
103
- eventMap.set(event, eventStruct)
104
- }
105
- }
106
- }
107
- }
108
- }
109
- return eventMap
110
- }
111
-
112
- getType(data: Event | MoveResource): string {
113
- return data.type
114
- }
115
-
116
- getData(data: Event | MoveResource) {
117
- if ('data' in data && 'type' in data) {
118
- return data.data
119
- }
120
- return data
121
- }
122
-
123
- async getChainId(): Promise<string> {
124
- return (await this.client.getChainId()).toString()
125
- }
126
- // validateAndNormalizeAddress(address: string): string {
127
- // return validateAndNormalizeAddress(address)
128
- // }
129
- }