@arkiv-network/sdk 0.0.36-dev.6 → 0.1.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 (269) hide show
  1. package/README.md +96 -16
  2. package/dist/_cjs/actions/public/buildQuery.js.map +1 -1
  3. package/dist/_cjs/actions/public/getBlockTiming.d.ts.map +1 -1
  4. package/dist/_cjs/actions/public/getBlockTiming.js.map +1 -1
  5. package/dist/_cjs/actions/public/getEntity.js.map +1 -1
  6. package/dist/_cjs/actions/public/getEntityCount.js.map +1 -1
  7. package/dist/_cjs/actions/public/query.js.map +1 -1
  8. package/dist/_cjs/actions/public/subscribeEntityEvents.d.ts.map +1 -1
  9. package/dist/_cjs/actions/public/subscribeEntityEvents.js.map +1 -1
  10. package/dist/_cjs/actions/wallet/changeOwnership.d.ts +22 -0
  11. package/dist/_cjs/actions/wallet/changeOwnership.d.ts.map +1 -0
  12. package/dist/_cjs/actions/wallet/changeOwnership.js +15 -0
  13. package/dist/_cjs/actions/wallet/changeOwnership.js.map +1 -0
  14. package/dist/_cjs/actions/wallet/createEntity.d.ts +5 -3
  15. package/dist/_cjs/actions/wallet/createEntity.d.ts.map +1 -1
  16. package/dist/_cjs/actions/wallet/createEntity.js.map +1 -1
  17. package/dist/_cjs/actions/wallet/deleteEntity.d.ts.map +1 -1
  18. package/dist/_cjs/actions/wallet/deleteEntity.js.map +1 -1
  19. package/dist/_cjs/actions/wallet/extendEntity.d.ts.map +1 -1
  20. package/dist/_cjs/actions/wallet/extendEntity.js.map +1 -1
  21. package/dist/_cjs/actions/wallet/mutateEntities.d.ts.map +1 -1
  22. package/dist/_cjs/actions/wallet/mutateEntities.js.map +1 -1
  23. package/dist/_cjs/actions/wallet/updateEntity.d.ts +6 -4
  24. package/dist/_cjs/actions/wallet/updateEntity.d.ts.map +1 -1
  25. package/dist/_cjs/actions/wallet/updateEntity.js.map +1 -1
  26. package/dist/_cjs/chains/kaolin.js.map +1 -1
  27. package/dist/_cjs/chains/localhost.js.map +1 -1
  28. package/dist/_cjs/chains/marketplace.js.map +1 -1
  29. package/dist/_cjs/clients/baseClient.d.ts.map +1 -1
  30. package/dist/_cjs/clients/createPublicClient.d.ts.map +1 -1
  31. package/dist/_cjs/clients/createPublicClient.js.map +1 -1
  32. package/dist/_cjs/clients/createWalletClient.d.ts.map +1 -1
  33. package/dist/_cjs/clients/createWalletClient.js.map +1 -1
  34. package/dist/_cjs/clients/decorators/arkivPublic.d.ts +0 -2
  35. package/dist/_cjs/clients/decorators/arkivPublic.d.ts.map +1 -1
  36. package/dist/_cjs/clients/decorators/arkivPublic.js.map +1 -1
  37. package/dist/_cjs/clients/decorators/arkivWallet.d.ts +15 -5
  38. package/dist/_cjs/clients/decorators/arkivWallet.d.ts.map +1 -1
  39. package/dist/_cjs/clients/decorators/arkivWallet.js +2 -0
  40. package/dist/_cjs/clients/decorators/arkivWallet.js.map +1 -1
  41. package/dist/_cjs/consts.js +1 -1
  42. package/dist/_cjs/index.d.ts +1 -1
  43. package/dist/_cjs/index.d.ts.map +1 -1
  44. package/dist/_cjs/query/engine.d.ts +1 -1
  45. package/dist/_cjs/query/engine.d.ts.map +1 -1
  46. package/dist/_cjs/query/engine.js +5 -4
  47. package/dist/_cjs/query/engine.js.map +1 -1
  48. package/dist/_cjs/query/errors.js.map +1 -1
  49. package/dist/_cjs/query/predicate.d.ts.map +1 -1
  50. package/dist/_cjs/query/predicate.js.map +1 -1
  51. package/dist/_cjs/query/queryBuilder.d.ts +5 -5
  52. package/dist/_cjs/query/queryBuilder.d.ts.map +1 -1
  53. package/dist/_cjs/query/queryBuilder.js +8 -8
  54. package/dist/_cjs/query/queryBuilder.js.map +1 -1
  55. package/dist/_cjs/query/queryResult.d.ts.map +1 -1
  56. package/dist/_cjs/query/queryResult.js.map +1 -1
  57. package/dist/_cjs/types/attributes.d.ts +5 -0
  58. package/dist/_cjs/types/attributes.d.ts.map +1 -0
  59. package/dist/_cjs/types/{annotation.js → attributes.js} +1 -1
  60. package/dist/_cjs/types/attributes.js.map +1 -0
  61. package/dist/_cjs/types/entity.d.ts +5 -3
  62. package/dist/_cjs/types/entity.d.ts.map +1 -1
  63. package/dist/_cjs/types/entity.js +5 -3
  64. package/dist/_cjs/types/entity.js.map +1 -1
  65. package/dist/_cjs/types/events.d.ts.map +1 -1
  66. package/dist/_cjs/types/index.d.ts +2 -1
  67. package/dist/_cjs/types/index.d.ts.map +1 -1
  68. package/dist/_cjs/types/mimeTypes.d.ts +2 -0
  69. package/dist/_cjs/types/mimeTypes.d.ts.map +1 -0
  70. package/dist/_cjs/types/mimeTypes.js +3 -0
  71. package/dist/_cjs/types/mimeTypes.js.map +1 -0
  72. package/dist/_cjs/types/rpcSchema.d.ts +6 -19
  73. package/dist/_cjs/types/rpcSchema.d.ts.map +1 -1
  74. package/dist/_cjs/types/txParams.d.ts.map +1 -1
  75. package/dist/_cjs/utils/arkivTransactions.d.ts +3 -1
  76. package/dist/_cjs/utils/arkivTransactions.d.ts.map +1 -1
  77. package/dist/_cjs/utils/arkivTransactions.js +23 -17
  78. package/dist/_cjs/utils/arkivTransactions.js.map +1 -1
  79. package/dist/_cjs/utils/compression.d.ts +3 -0
  80. package/dist/_cjs/utils/compression.d.ts.map +1 -0
  81. package/dist/_cjs/utils/compression.js +24 -0
  82. package/dist/_cjs/utils/compression.js.map +1 -0
  83. package/dist/_cjs/utils/entities.d.ts.map +1 -1
  84. package/dist/_cjs/utils/entities.js +4 -4
  85. package/dist/_cjs/utils/entities.js.map +1 -1
  86. package/dist/_cjs/utils/expirationTime.d.ts.map +1 -1
  87. package/dist/_cjs/utils/expirationTime.js.map +1 -1
  88. package/dist/_cjs/utils/payload.js.map +1 -1
  89. package/dist/_esm/actions/public/buildQuery.js.map +1 -1
  90. package/dist/_esm/actions/public/getBlockTiming.d.ts.map +1 -1
  91. package/dist/_esm/actions/public/getBlockTiming.js.map +1 -1
  92. package/dist/_esm/actions/public/getEntity.js.map +1 -1
  93. package/dist/_esm/actions/public/getEntityCount.js.map +1 -1
  94. package/dist/_esm/actions/public/query.js.map +1 -1
  95. package/dist/_esm/actions/public/subscribeEntityEvents.d.ts.map +1 -1
  96. package/dist/_esm/actions/public/subscribeEntityEvents.js.map +1 -1
  97. package/dist/_esm/actions/wallet/changeOwnership.d.ts +22 -0
  98. package/dist/_esm/actions/wallet/changeOwnership.d.ts.map +1 -0
  99. package/dist/_esm/actions/wallet/changeOwnership.js +12 -0
  100. package/dist/_esm/actions/wallet/changeOwnership.js.map +1 -0
  101. package/dist/_esm/actions/wallet/createEntity.d.ts +5 -3
  102. package/dist/_esm/actions/wallet/createEntity.d.ts.map +1 -1
  103. package/dist/_esm/actions/wallet/createEntity.js.map +1 -1
  104. package/dist/_esm/actions/wallet/deleteEntity.d.ts.map +1 -1
  105. package/dist/_esm/actions/wallet/deleteEntity.js.map +1 -1
  106. package/dist/_esm/actions/wallet/extendEntity.d.ts.map +1 -1
  107. package/dist/_esm/actions/wallet/extendEntity.js.map +1 -1
  108. package/dist/_esm/actions/wallet/mutateEntities.d.ts.map +1 -1
  109. package/dist/_esm/actions/wallet/mutateEntities.js.map +1 -1
  110. package/dist/_esm/actions/wallet/updateEntity.d.ts +6 -4
  111. package/dist/_esm/actions/wallet/updateEntity.d.ts.map +1 -1
  112. package/dist/_esm/actions/wallet/updateEntity.js.map +1 -1
  113. package/dist/_esm/chains/kaolin.js.map +1 -1
  114. package/dist/_esm/chains/localhost.js.map +1 -1
  115. package/dist/_esm/chains/marketplace.js.map +1 -1
  116. package/dist/_esm/clients/baseClient.d.ts.map +1 -1
  117. package/dist/_esm/clients/createPublicClient.d.ts.map +1 -1
  118. package/dist/_esm/clients/createPublicClient.js.map +1 -1
  119. package/dist/_esm/clients/createWalletClient.d.ts.map +1 -1
  120. package/dist/_esm/clients/createWalletClient.js.map +1 -1
  121. package/dist/_esm/clients/decorators/arkivPublic.d.ts +0 -2
  122. package/dist/_esm/clients/decorators/arkivPublic.d.ts.map +1 -1
  123. package/dist/_esm/clients/decorators/arkivPublic.js.map +1 -1
  124. package/dist/_esm/clients/decorators/arkivWallet.d.ts +15 -5
  125. package/dist/_esm/clients/decorators/arkivWallet.d.ts.map +1 -1
  126. package/dist/_esm/clients/decorators/arkivWallet.js +2 -0
  127. package/dist/_esm/clients/decorators/arkivWallet.js.map +1 -1
  128. package/dist/_esm/consts.js +1 -1
  129. package/dist/_esm/index.d.ts +1 -1
  130. package/dist/_esm/index.d.ts.map +1 -1
  131. package/dist/_esm/query/engine.d.ts +1 -1
  132. package/dist/_esm/query/engine.d.ts.map +1 -1
  133. package/dist/_esm/query/engine.js +5 -4
  134. package/dist/_esm/query/engine.js.map +1 -1
  135. package/dist/_esm/query/errors.js.map +1 -1
  136. package/dist/_esm/query/predicate.d.ts.map +1 -1
  137. package/dist/_esm/query/predicate.js.map +1 -1
  138. package/dist/_esm/query/queryBuilder.d.ts +5 -5
  139. package/dist/_esm/query/queryBuilder.d.ts.map +1 -1
  140. package/dist/_esm/query/queryBuilder.js +8 -8
  141. package/dist/_esm/query/queryBuilder.js.map +1 -1
  142. package/dist/_esm/query/queryResult.d.ts.map +1 -1
  143. package/dist/_esm/query/queryResult.js.map +1 -1
  144. package/dist/_esm/types/attributes.d.ts +5 -0
  145. package/dist/_esm/types/attributes.d.ts.map +1 -0
  146. package/dist/_esm/types/attributes.js +2 -0
  147. package/dist/_esm/types/attributes.js.map +1 -0
  148. package/dist/_esm/types/entity.d.ts +5 -3
  149. package/dist/_esm/types/entity.d.ts.map +1 -1
  150. package/dist/_esm/types/entity.js +5 -3
  151. package/dist/_esm/types/entity.js.map +1 -1
  152. package/dist/_esm/types/events.d.ts.map +1 -1
  153. package/dist/_esm/types/index.d.ts +2 -1
  154. package/dist/_esm/types/index.d.ts.map +1 -1
  155. package/dist/_esm/types/mimeTypes.d.ts +2 -0
  156. package/dist/_esm/types/mimeTypes.d.ts.map +1 -0
  157. package/dist/_esm/types/mimeTypes.js +2 -0
  158. package/dist/_esm/types/mimeTypes.js.map +1 -0
  159. package/dist/_esm/types/rpcSchema.d.ts +6 -19
  160. package/dist/_esm/types/rpcSchema.d.ts.map +1 -1
  161. package/dist/_esm/types/txParams.d.ts.map +1 -1
  162. package/dist/_esm/utils/arkivTransactions.d.ts +3 -1
  163. package/dist/_esm/utils/arkivTransactions.d.ts.map +1 -1
  164. package/dist/_esm/utils/arkivTransactions.js +24 -18
  165. package/dist/_esm/utils/arkivTransactions.js.map +1 -1
  166. package/dist/_esm/utils/compression.d.ts +3 -0
  167. package/dist/_esm/utils/compression.d.ts.map +1 -0
  168. package/dist/_esm/utils/compression.js +20 -0
  169. package/dist/_esm/utils/compression.js.map +1 -0
  170. package/dist/_esm/utils/entities.d.ts.map +1 -1
  171. package/dist/_esm/utils/entities.js +4 -4
  172. package/dist/_esm/utils/entities.js.map +1 -1
  173. package/dist/_esm/utils/expirationTime.d.ts.map +1 -1
  174. package/dist/_esm/utils/expirationTime.js.map +1 -1
  175. package/dist/_esm/utils/payload.js.map +1 -1
  176. package/dist/_types/actions/public/getBlockTiming.d.ts.map +1 -1
  177. package/dist/_types/actions/public/subscribeEntityEvents.d.ts.map +1 -1
  178. package/dist/_types/actions/wallet/changeOwnership.d.ts +22 -0
  179. package/dist/_types/actions/wallet/changeOwnership.d.ts.map +1 -0
  180. package/dist/_types/actions/wallet/createEntity.d.ts +5 -3
  181. package/dist/_types/actions/wallet/createEntity.d.ts.map +1 -1
  182. package/dist/_types/actions/wallet/deleteEntity.d.ts.map +1 -1
  183. package/dist/_types/actions/wallet/extendEntity.d.ts.map +1 -1
  184. package/dist/_types/actions/wallet/mutateEntities.d.ts.map +1 -1
  185. package/dist/_types/actions/wallet/updateEntity.d.ts +6 -4
  186. package/dist/_types/actions/wallet/updateEntity.d.ts.map +1 -1
  187. package/dist/_types/clients/baseClient.d.ts.map +1 -1
  188. package/dist/_types/clients/createPublicClient.d.ts.map +1 -1
  189. package/dist/_types/clients/createWalletClient.d.ts.map +1 -1
  190. package/dist/_types/clients/decorators/arkivPublic.d.ts +0 -2
  191. package/dist/_types/clients/decorators/arkivPublic.d.ts.map +1 -1
  192. package/dist/_types/clients/decorators/arkivWallet.d.ts +15 -5
  193. package/dist/_types/clients/decorators/arkivWallet.d.ts.map +1 -1
  194. package/dist/_types/index.d.ts +1 -1
  195. package/dist/_types/index.d.ts.map +1 -1
  196. package/dist/_types/query/engine.d.ts +1 -1
  197. package/dist/_types/query/engine.d.ts.map +1 -1
  198. package/dist/_types/query/predicate.d.ts.map +1 -1
  199. package/dist/_types/query/queryBuilder.d.ts +5 -5
  200. package/dist/_types/query/queryBuilder.d.ts.map +1 -1
  201. package/dist/_types/query/queryResult.d.ts.map +1 -1
  202. package/dist/_types/types/attributes.d.ts +5 -0
  203. package/dist/_types/types/attributes.d.ts.map +1 -0
  204. package/dist/_types/types/entity.d.ts +5 -3
  205. package/dist/_types/types/entity.d.ts.map +1 -1
  206. package/dist/_types/types/events.d.ts.map +1 -1
  207. package/dist/_types/types/index.d.ts +2 -1
  208. package/dist/_types/types/index.d.ts.map +1 -1
  209. package/dist/_types/types/mimeTypes.d.ts +2 -0
  210. package/dist/_types/types/mimeTypes.d.ts.map +1 -0
  211. package/dist/_types/types/rpcSchema.d.ts +6 -19
  212. package/dist/_types/types/rpcSchema.d.ts.map +1 -1
  213. package/dist/_types/types/txParams.d.ts.map +1 -1
  214. package/dist/_types/utils/arkivTransactions.d.ts +3 -1
  215. package/dist/_types/utils/arkivTransactions.d.ts.map +1 -1
  216. package/dist/_types/utils/compression.d.ts +3 -0
  217. package/dist/_types/utils/compression.d.ts.map +1 -0
  218. package/dist/_types/utils/entities.d.ts.map +1 -1
  219. package/dist/_types/utils/expirationTime.d.ts.map +1 -1
  220. package/package.json +118 -116
  221. package/src/actions/public/buildQuery.ts +1 -1
  222. package/src/actions/public/getBlockTiming.ts +13 -13
  223. package/src/actions/public/getEntity.ts +9 -9
  224. package/src/actions/public/getEntityCount.ts +5 -5
  225. package/src/actions/public/query.ts +6 -6
  226. package/src/actions/public/subscribeEntityEvents.ts +92 -92
  227. package/src/actions/wallet/changeOwnership.ts +40 -0
  228. package/src/actions/wallet/createEntity.ts +20 -18
  229. package/src/actions/wallet/deleteEntity.ts +14 -14
  230. package/src/actions/wallet/extendEntity.ts +15 -15
  231. package/src/actions/wallet/mutateEntities.ts +58 -58
  232. package/src/actions/wallet/updateEntity.ts +21 -19
  233. package/src/chains/kaolin.ts +22 -22
  234. package/src/chains/localhost.ts +10 -10
  235. package/src/chains/marketplace.ts +22 -22
  236. package/src/clients/baseClient.ts +4 -4
  237. package/src/clients/createPublicClient.ts +31 -31
  238. package/src/clients/createWalletClient.ts +35 -35
  239. package/src/clients/decorators/arkivPublic.ts +179 -181
  240. package/src/clients/decorators/arkivWallet.ts +222 -204
  241. package/src/consts.ts +1 -1
  242. package/src/index.ts +8 -8
  243. package/src/query/engine.ts +93 -92
  244. package/src/query/errors.ts +12 -12
  245. package/src/query/predicate.ts +18 -18
  246. package/src/query/queryBuilder.ts +194 -194
  247. package/src/query/queryResult.ts +49 -49
  248. package/src/types/attributes.ts +4 -0
  249. package/src/types/entity.ts +29 -25
  250. package/src/types/events.ts +18 -18
  251. package/src/types/index.ts +2 -1
  252. package/src/types/mimeTypes.ts +27 -0
  253. package/src/types/rpcSchema.ts +46 -53
  254. package/src/types/txParams.ts +14 -14
  255. package/src/utils/arkivTransactions.ts +76 -67
  256. package/src/utils/compression.ts +21 -0
  257. package/src/utils/entities.ts +17 -10
  258. package/src/utils/expirationTime.ts +9 -9
  259. package/src/utils/payload.ts +2 -2
  260. package/dist/_cjs/types/annotation.d.ts +0 -5
  261. package/dist/_cjs/types/annotation.d.ts.map +0 -1
  262. package/dist/_cjs/types/annotation.js.map +0 -1
  263. package/dist/_esm/types/annotation.d.ts +0 -5
  264. package/dist/_esm/types/annotation.d.ts.map +0 -1
  265. package/dist/_esm/types/annotation.js +0 -2
  266. package/dist/_esm/types/annotation.js.map +0 -1
  267. package/dist/_types/types/annotation.d.ts +0 -5
  268. package/dist/_types/types/annotation.d.ts.map +0 -1
  269. package/src/types/annotation.ts +0 -4
@@ -1,68 +1,61 @@
1
1
  import type { Hex, PublicRpcSchema } from "viem"
2
+ import type { MimeType } from "./mimeTypes"
2
3
 
3
4
  export type RpcEntity = {
4
- key: Hex
5
- value: string
6
- expiresAt: bigint
7
- owner: Hex
8
- stringAnnotations?: [{ key: string; value: string }]
9
- numericAnnotations?: [{ key: string; value: number }]
5
+ key: Hex
6
+ contentType: MimeType
7
+ value: string
8
+ expiresAt: bigint
9
+ owner: Hex
10
+ stringAttributes?: [{ key: string; value: string }]
11
+ numericAttributes?: [{ key: string; value: number }]
10
12
  }
11
13
 
12
14
  export type RpcQueryOptions = {
13
- atBlock?: number
14
- includeData?: RpcIncludeData
15
- resultsPerPage?: number
16
- cursor?: string
15
+ atBlock?: number
16
+ includeData?: RpcIncludeData
17
+ resultsPerPage?: number
18
+ cursor?: string
17
19
  }
18
20
 
19
21
  export type RpcIncludeData = {
20
- key: boolean
21
- annotations: boolean
22
- payload: boolean
23
- expiration: boolean
24
- owner: boolean
22
+ key: boolean
23
+ attributes: boolean
24
+ payload: boolean
25
+ contentType: boolean
26
+ expiration: boolean
27
+ owner: boolean
25
28
  }
26
29
 
27
30
  export type ArkivRpcSchema = [
28
- {
29
- Method: "golembase_getStorageValue"
30
- Parameters?: [entityId: Hex]
31
- ReturnType: string
32
- },
33
- {
34
- Method: "arkiv_query"
35
- Parameters?: [query: string, queryOptions?: RpcQueryOptions]
36
- ReturnType: {
37
- data: [RpcEntity]
38
- blockNumber: bigint
39
- cursor: string
40
- }
41
- },
42
- {
43
- Method: "golembase_getEntityMetaData"
44
- Parameters?: [entityId: Hex]
45
- ReturnType: {
46
- expiresAtBlock: number
47
- owner: Hex
48
- numericAnnotations: [{ key: string; value: number }]
49
- stringAnnotations: [{ key: string; value: string }]
50
- }
51
- },
52
- {
53
- Method: "arkiv_getBlockTiming"
54
- Parameters?: []
55
- ReturnType: {
56
- current_block: bigint
57
- current_block_time: number
58
- duration: number
59
- }
60
- },
61
- {
62
- Method: "arkiv_getEntityCount"
63
- Parameters?: []
64
- ReturnType: number
65
- },
31
+ {
32
+ Method: "golembase_getStorageValue"
33
+ Parameters?: [entityId: Hex]
34
+ ReturnType: string
35
+ },
36
+ {
37
+ Method: "arkiv_query"
38
+ Parameters?: [query: string, queryOptions?: RpcQueryOptions]
39
+ ReturnType: {
40
+ data: [RpcEntity]
41
+ blockNumber: bigint
42
+ cursor: string
43
+ }
44
+ },
45
+ {
46
+ Method: "arkiv_getBlockTiming"
47
+ Parameters?: []
48
+ ReturnType: {
49
+ current_block: bigint
50
+ current_block_time: number
51
+ duration: number
52
+ }
53
+ },
54
+ {
55
+ Method: "arkiv_getEntityCount"
56
+ Parameters?: []
57
+ ReturnType: number
58
+ },
66
59
  ]
67
60
 
68
61
  export type PublicArkivRpcSchema = [...PublicRpcSchema, ...ArkivRpcSchema]
@@ -1,15 +1,15 @@
1
1
  export type TxParams =
2
- | {
3
- gas?: bigint
4
- nonce?: number
5
- gasPrice?: bigint
6
- maxFeePerGas?: never
7
- maxPriorityFeePerGas?: never
8
- }
9
- | {
10
- gas?: bigint
11
- nonce?: number
12
- maxFeePerGas?: bigint
13
- maxPriorityFeePerGas?: bigint
14
- gasPrice?: never
15
- }
2
+ | {
3
+ gas?: bigint
4
+ nonce?: number
5
+ gasPrice?: bigint
6
+ maxFeePerGas?: never
7
+ maxPriorityFeePerGas?: never
8
+ }
9
+ | {
10
+ gas?: bigint
11
+ nonce?: number
12
+ maxFeePerGas?: bigint
13
+ maxPriorityFeePerGas?: bigint
14
+ gasPrice?: never
15
+ }
@@ -1,4 +1,5 @@
1
- import { type Hex, toHex, toRlp } from "viem"
1
+ import { type Hex, toBytes, toHex, toRlp } from "viem"
2
+ import type { ChangeOwnershipParameters } from "../actions/wallet/changeOwnership"
2
3
  import type { CreateEntityParameters } from "../actions/wallet/createEntity"
3
4
  import type { DeleteEntityParameters } from "../actions/wallet/deleteEntity"
4
5
  import type { ExtendEntityParameters } from "../actions/wallet/extendEntity"
@@ -7,85 +8,93 @@ import type { ArkivClient } from "../clients/baseClient"
7
8
  import type { WalletArkivClient } from "../clients/createWalletClient"
8
9
  import { ARKIV_ADDRESS, BLOCK_TIME } from "../consts"
9
10
  import type { TxParams } from "../types"
11
+ import { compress } from "./compression"
10
12
 
11
13
  export function opsToTxData({
12
- creates,
13
- updates,
14
- deletes,
15
- extensions,
14
+ creates,
15
+ updates,
16
+ deletes,
17
+ extensions,
18
+ ownershipChanges,
16
19
  }: {
17
- creates?: CreateEntityParameters[]
18
- updates?: UpdateEntityParameters[]
19
- deletes?: DeleteEntityParameters[]
20
- extensions?: ExtendEntityParameters[]
20
+ creates?: CreateEntityParameters[]
21
+ updates?: UpdateEntityParameters[]
22
+ deletes?: DeleteEntityParameters[]
23
+ extensions?: ExtendEntityParameters[]
24
+ ownershipChanges?: ChangeOwnershipParameters[]
21
25
  }) {
22
- function formatAnnotation<T extends string | number | bigint | boolean>(annotation: {
23
- key: string
24
- value: T
25
- }): [Hex, Hex] {
26
- return [toHex(annotation.key), toHex(annotation.value)]
27
- }
26
+ function formatAttributes<T extends string | number | bigint | boolean>(attribute: {
27
+ key: string
28
+ value: T
29
+ }): [Hex, Hex] {
30
+ return [toHex(attribute.key), toHex(attribute.value)]
31
+ }
28
32
 
29
- const payload = [
30
- //creates
31
- (creates ?? []).map((item) => [
32
- toHex(item.expiresIn / BLOCK_TIME),
33
- toHex(item.payload),
34
- item.annotations
35
- .filter((annotation) => typeof annotation.value === "string")
36
- .map(formatAnnotation),
37
- item.annotations
38
- .filter((annotation) => typeof annotation.value === "number")
39
- .map(formatAnnotation),
40
- ]),
41
- //updates
42
- (updates ?? []).map((item) => [
43
- item.entityKey,
44
- toHex(item.expiresIn / BLOCK_TIME),
45
- toHex(item.payload),
46
- item.annotations
47
- .filter((annotation) => typeof annotation.value === "string")
48
- .map(formatAnnotation),
49
- item.annotations
50
- .filter((annotation) => typeof annotation.value === "number")
51
- .map(formatAnnotation),
52
- ]),
53
- //deletes
54
- (deletes ?? []).map((item) => item.entityKey),
55
- //extends
56
- (extensions ?? []).map((item) => [item.entityKey, toHex(item.expiresIn / BLOCK_TIME)]),
57
- ]
33
+ const payload = [
34
+ //creates
35
+ (creates ?? []).map((item) => [
36
+ toHex(item.expiresIn / BLOCK_TIME),
37
+ toHex(item.contentType),
38
+ toHex(item.payload),
39
+ item.attributes
40
+ .filter((attribute) => typeof attribute.value === "string")
41
+ .map(formatAttributes),
42
+ item.attributes
43
+ .filter((attribute) => typeof attribute.value === "number")
44
+ .map(formatAttributes),
45
+ ]),
46
+ //updates
47
+ (updates ?? []).map((item) => [
48
+ item.entityKey,
49
+ toHex(item.contentType),
50
+ toHex(item.expiresIn / BLOCK_TIME),
51
+ toHex(item.payload),
52
+ item.attributes
53
+ .filter((attribute) => typeof attribute.value === "string")
54
+ .map(formatAttributes),
55
+ item.attributes
56
+ .filter((attribute) => typeof attribute.value === "number")
57
+ .map(formatAttributes),
58
+ ]),
59
+ //deletes
60
+ (deletes ?? []).map((item) => item.entityKey),
61
+ //extends
62
+ (extensions ?? []).map((item) => [item.entityKey, toHex(item.expiresIn / BLOCK_TIME)]),
63
+ //ownershipChanges TODO
64
+ (ownershipChanges ?? []).map((item) => [item.entityKey, item.newOwner]),
65
+ ]
58
66
 
59
- console.debug("txData to send as RLP", payload)
67
+ console.debug("txData to send as RLP", payload, payload.length)
60
68
 
61
- return toRlp(payload)
69
+ return toRlp(payload)
62
70
  }
63
71
 
64
72
  export async function sendArkivTransaction(client: ArkivClient, data: Hex, txParams?: TxParams) {
65
- if (!client.account) throw new Error("Account required")
66
- const walletClient = client as WalletArkivClient
73
+ if (!client.account) throw new Error("Account required")
74
+ const walletClient = client as WalletArkivClient
67
75
 
68
- console.debug("Sending transaction", {
69
- account: client.account,
70
- chain: client.chain,
71
- to: ARKIV_ADDRESS,
72
- value: 0n,
73
- data,
74
- ...txParams,
75
- })
76
+ console.debug("Sending transaction", {
77
+ account: client.account,
78
+ chain: client.chain,
79
+ to: ARKIV_ADDRESS,
80
+ value: 0n,
81
+ data,
82
+ ...txParams,
83
+ })
76
84
 
77
- const txHash = await walletClient.sendTransaction({
78
- account: client.account,
79
- chain: client.chain,
80
- to: ARKIV_ADDRESS,
81
- value: 0n,
82
- data,
83
- ...txParams,
84
- })
85
+ const compressed = await compress(toBytes(data))
86
+ const txHash = await walletClient.sendTransaction({
87
+ account: client.account,
88
+ chain: client.chain,
89
+ to: ARKIV_ADDRESS,
90
+ value: 0n,
91
+ data: toHex(compressed),
92
+ ...txParams,
93
+ })
85
94
 
86
- const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash })
95
+ const receipt = await walletClient.waitForTransactionReceipt({ hash: txHash })
87
96
 
88
- console.debug("Tx receipt", receipt)
97
+ console.debug("Tx receipt", receipt)
89
98
 
90
- return receipt
99
+ return receipt
91
100
  }
@@ -0,0 +1,21 @@
1
+ import { init, compress as zstdCompress, decompress as zstdDecompress } from "@bokuweb/zstd-wasm"
2
+
3
+ let initialized = false
4
+ export async function compress(data: Uint8Array): Promise<Uint8Array> {
5
+ if (!initialized) {
6
+ await init()
7
+ initialized = true
8
+ }
9
+ console.debug(`Compressing data (size: ${data.length})`)
10
+ const compressed = await zstdCompress(data)
11
+ console.debug(`Compressed data (size: ${compressed.length})`)
12
+ return new Uint8Array(compressed)
13
+ }
14
+
15
+ export async function decompress(data: Uint8Array): Promise<Uint8Array> {
16
+ if (!initialized) {
17
+ await init()
18
+ initialized = true
19
+ }
20
+ return await zstdDecompress(data)
21
+ }
@@ -3,14 +3,21 @@ import { Entity } from "../types/entity"
3
3
  import type { RpcEntity } from "../types/rpcSchema"
4
4
 
5
5
  export async function entityFromRpcResult(rpcEntity: RpcEntity) {
6
- return new Entity(rpcEntity.key, rpcEntity.owner, rpcEntity.expiresAt, toBytes(rpcEntity.value), [
7
- ...(rpcEntity.stringAnnotations ?? []).map(({ key, value }) => ({
8
- key,
9
- value,
10
- })),
11
- ...(rpcEntity.numericAnnotations ?? []).map(({ key, value }) => ({
12
- key,
13
- value: value,
14
- })),
15
- ])
6
+ return new Entity(
7
+ rpcEntity.key,
8
+ rpcEntity.contentType,
9
+ rpcEntity.owner,
10
+ rpcEntity.expiresAt,
11
+ toBytes(rpcEntity.value),
12
+ [
13
+ ...(rpcEntity.stringAttributes ?? []).map(({ key, value }) => ({
14
+ key,
15
+ value,
16
+ })),
17
+ ...(rpcEntity.numericAttributes ?? []).map(({ key, value }) => ({
18
+ key,
19
+ value: Number(value),
20
+ })),
21
+ ],
22
+ )
16
23
  }
@@ -1,13 +1,13 @@
1
1
  import { BLOCK_TIME } from "../consts"
2
2
 
3
3
  export const ExpirationTime = {
4
- fromSeconds: (seconds: number) => seconds,
5
- fromMinutes: (minutes: number) => minutes * 60,
6
- fromHours: (hours: number) => hours * 60 * 60,
7
- fromDays: (days: number) => days * 24 * 60 * 60,
8
- fromWeeks: (weeks: number) => weeks * 7 * 24 * 60 * 60,
9
- fromMonths: (months: number) => months * 30 * 24 * 60 * 60,
10
- fromYears: (years: number) => years * 365 * 24 * 60 * 60,
11
- fromBlocks: (blocks: number) => blocks * BLOCK_TIME,
12
- fromDate: (date: Date) => Math.floor(date.getTime() / 1000) - Math.floor(Date.now() / 1000),
4
+ fromSeconds: (seconds: number) => seconds,
5
+ fromMinutes: (minutes: number) => minutes * 60,
6
+ fromHours: (hours: number) => hours * 60 * 60,
7
+ fromDays: (days: number) => days * 24 * 60 * 60,
8
+ fromWeeks: (weeks: number) => weeks * 7 * 24 * 60 * 60,
9
+ fromMonths: (months: number) => months * 30 * 24 * 60 * 60,
10
+ fromYears: (years: number) => years * 365 * 24 * 60 * 60,
11
+ fromBlocks: (blocks: number) => blocks * BLOCK_TIME,
12
+ fromDate: (date: Date) => Math.floor(date.getTime() / 1000) - Math.floor(Date.now() / 1000),
13
13
  }
@@ -1,9 +1,9 @@
1
1
  import { toBytes } from "viem"
2
2
 
3
3
  export function jsonToPayload(json: object): Uint8Array {
4
- return toBytes(JSON.stringify(json))
4
+ return toBytes(JSON.stringify(json))
5
5
  }
6
6
 
7
7
  export function stringToPayload(data: string): Uint8Array {
8
- return toBytes(data)
8
+ return toBytes(data)
9
9
  }
@@ -1,5 +0,0 @@
1
- export type Annotation = {
2
- key: string;
3
- value: string | number;
4
- };
5
- //# sourceMappingURL=annotation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../../src/types/annotation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotation.js","sourceRoot":"","sources":["../../../src/types/annotation.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- export type Annotation = {
2
- key: string;
3
- value: string | number;
4
- };
5
- //# sourceMappingURL=annotation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../../src/types/annotation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=annotation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotation.js","sourceRoot":"","sources":["../../../src/types/annotation.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- export type Annotation = {
2
- key: string;
3
- value: string | number;
4
- };
5
- //# sourceMappingURL=annotation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../../src/types/annotation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA"}
@@ -1,4 +0,0 @@
1
- export type Annotation = {
2
- key: string
3
- value: string | number
4
- }