@arkiv-network/sdk 0.7.0 → 0.8.0-advanced.3

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 (240) hide show
  1. package/README.md +71 -16
  2. package/dist/actions/advanced/index.cjs +13 -0
  3. package/dist/actions/advanced/index.d.cts +8 -0
  4. package/dist/actions/advanced/index.d.ts +9 -0
  5. package/dist/actions/advanced/index.js +9 -0
  6. package/dist/advanced-Ds2XRflQ.cjs +656 -0
  7. package/dist/advanced-FZy7WoYR.js +598 -0
  8. package/dist/advanced-FZy7WoYR.js.map +1 -0
  9. package/dist/arkivTransactions-BpARZOsH.d.cts +584 -0
  10. package/dist/arkivTransactions-BpARZOsH.d.cts.map +1 -0
  11. package/dist/arkivTransactions-DfZ_yVDD.d.ts +584 -0
  12. package/dist/arkivTransactions-DfZ_yVDD.d.ts.map +1 -0
  13. package/dist/attr/index.cjs +35 -0
  14. package/dist/attr/index.d.cts +2 -0
  15. package/dist/attr/index.d.ts +3 -0
  16. package/dist/attr/index.js +4 -0
  17. package/dist/attributes-BJGuhsqp.js +819 -0
  18. package/dist/attributes-BJGuhsqp.js.map +1 -0
  19. package/dist/attributes-CMJlp1wn.cjs +1039 -0
  20. package/dist/chains/index.cjs +2 -3
  21. package/dist/chains/index.d.cts +41 -76
  22. package/dist/chains/index.d.cts.map +1 -1
  23. package/dist/chains/index.d.ts +24 -59
  24. package/dist/chains/index.d.ts.map +1 -1
  25. package/dist/chains/index.js +2 -2
  26. package/dist/chains-BfNQliHU.cjs +76 -0
  27. package/dist/chains-Du8tql7I.js +60 -0
  28. package/dist/chains-Du8tql7I.js.map +1 -0
  29. package/dist/codec-M74UR1_0.d.ts +101 -0
  30. package/dist/codec-M74UR1_0.d.ts.map +1 -0
  31. package/dist/entity/index.cjs +21 -0
  32. package/dist/entity/index.d.cts +4 -0
  33. package/dist/entity/index.d.ts +5 -0
  34. package/dist/entity/index.js +7 -0
  35. package/dist/entity-B00Li04j.cjs +71 -0
  36. package/dist/entity-B7G8q_Eo.cjs +0 -0
  37. package/dist/entity-BYQR1uoe.js +67 -0
  38. package/dist/entity-BYQR1uoe.js.map +1 -0
  39. package/dist/entity-CD_qFF2M.js +0 -0
  40. package/dist/errors-51znTSB1.cjs +56 -0
  41. package/dist/errors-CwPJ16bn.js +33 -0
  42. package/dist/errors-CwPJ16bn.js.map +1 -0
  43. package/dist/expiry-CZErShX6.js +95 -0
  44. package/dist/expiry-CZErShX6.js.map +1 -0
  45. package/dist/expiry-DRV29F1r.d.cts +79 -0
  46. package/dist/expiry-DRV29F1r.d.cts.map +1 -0
  47. package/dist/expiry-nDbCgZX4.d.ts +79 -0
  48. package/dist/expiry-nDbCgZX4.d.ts.map +1 -0
  49. package/dist/expiry-xr6mx4f7.cjs +135 -0
  50. package/dist/flags-5dTNRnow.d.ts +41 -0
  51. package/dist/flags-5dTNRnow.d.ts.map +1 -0
  52. package/dist/flags-Bh0HJldY.cjs +43 -0
  53. package/dist/flags-CRjPpoh3.d.cts +41 -0
  54. package/dist/flags-CRjPpoh3.d.cts.map +1 -0
  55. package/dist/flags-Cr76ldwF.js +33 -0
  56. package/dist/flags-Cr76ldwF.js.map +1 -0
  57. package/dist/index-CMeD8uEq.d.cts +280 -0
  58. package/dist/index-CMeD8uEq.d.cts.map +1 -0
  59. package/dist/index-CTDI5pXZ.d.ts +184 -0
  60. package/dist/index-CTDI5pXZ.d.ts.map +1 -0
  61. package/dist/index-CekGjkRx.d.cts +184 -0
  62. package/dist/index-CekGjkRx.d.cts.map +1 -0
  63. package/dist/index-D0IzFwMX.d.ts +328 -0
  64. package/dist/index-D0IzFwMX.d.ts.map +1 -0
  65. package/dist/index-DZxwz2Ky.d.cts +177 -0
  66. package/dist/index-DZxwz2Ky.d.cts.map +1 -0
  67. package/dist/index-Dz4SkQWg.d.ts +280 -0
  68. package/dist/index-Dz4SkQWg.d.ts.map +1 -0
  69. package/dist/index-JP31fjyM.d.ts +177 -0
  70. package/dist/index-JP31fjyM.d.ts.map +1 -0
  71. package/dist/index-NbfnXxgr.d.cts +424 -0
  72. package/dist/index-NbfnXxgr.d.cts.map +1 -0
  73. package/dist/index.cjs +434 -412
  74. package/dist/index.d.cts +401 -235
  75. package/dist/index.d.cts.map +1 -1
  76. package/dist/index.d.ts +402 -235
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +370 -404
  79. package/dist/index.js.map +1 -1
  80. package/dist/key-E7mv0BYf.cjs +116 -0
  81. package/dist/key-XQkpw2xh.js +82 -0
  82. package/dist/key-XQkpw2xh.js.map +1 -0
  83. package/dist/logger-CVpvU8ik.js +153 -0
  84. package/dist/logger-CVpvU8ik.js.map +1 -0
  85. package/dist/logger-Cr15lPAQ.cjs +188 -0
  86. package/dist/payload-Cvrir3Q-.cjs +108 -0
  87. package/dist/payload-D53ms-Mg.d.ts +153 -0
  88. package/dist/payload-D53ms-Mg.d.ts.map +1 -0
  89. package/dist/payload-DaPzUvEh.js +92 -0
  90. package/dist/payload-DaPzUvEh.js.map +1 -0
  91. package/dist/payload-hluX1rc0.d.cts +153 -0
  92. package/dist/payload-hluX1rc0.d.cts.map +1 -0
  93. package/dist/query/index.cjs +26 -149
  94. package/dist/query/index.d.cts +5 -3
  95. package/dist/query/index.d.ts +6 -3
  96. package/dist/query/index.js +8 -137
  97. package/dist/queryBuilder-BXR-HxD9.cjs +947 -0
  98. package/dist/queryBuilder-BwauPaGO.js +823 -0
  99. package/dist/queryBuilder-BwauPaGO.js.map +1 -0
  100. package/dist/selection-C6KeWJ7g.d.cts +441 -0
  101. package/dist/selection-C6KeWJ7g.d.cts.map +1 -0
  102. package/dist/selection-mjiiAGDO.d.ts +442 -0
  103. package/dist/selection-mjiiAGDO.d.ts.map +1 -0
  104. package/dist/types/index.cjs +4 -1
  105. package/dist/types/index.d.cts +7 -2
  106. package/dist/types/index.d.ts +8 -2
  107. package/dist/types/index.js +4 -1
  108. package/dist/types-Bu_ZwMbZ.js +0 -0
  109. package/dist/types-NRqymi6S.cjs +0 -0
  110. package/dist/utils/index.cjs +4 -17
  111. package/dist/utils/index.d.cts +3 -17
  112. package/dist/utils/index.d.ts +3 -17
  113. package/dist/utils/index.js +4 -18
  114. package/package.json +26 -9
  115. package/src/actions/advanced/advanced.test.ts +258 -0
  116. package/src/actions/advanced/buildMutation.ts +104 -0
  117. package/src/actions/advanced/getMutationResult.ts +112 -0
  118. package/src/actions/advanced/index.ts +21 -0
  119. package/src/actions/advanced/pingTransaction.ts +43 -0
  120. package/src/actions/advanced/sendMutation.ts +59 -0
  121. package/src/actions/public/getEntity.ts +28 -43
  122. package/src/actions/public/getEntityNonce.ts +30 -0
  123. package/src/actions/public/predictEntityKeys.test.ts +159 -0
  124. package/src/actions/public/predictEntityKeys.ts +152 -0
  125. package/src/actions/public/query.ts +35 -67
  126. package/src/actions/public/watchEntityEvents.test.ts +414 -0
  127. package/src/actions/public/watchEntityEvents.ts +225 -0
  128. package/src/actions/wallet/changeOwnership.ts +8 -8
  129. package/src/actions/wallet/createEntity.ts +105 -26
  130. package/src/actions/wallet/deleteEntity.ts +2 -3
  131. package/src/actions/wallet/executeBatch.test.ts +76 -0
  132. package/src/actions/wallet/executeBatch.ts +51 -0
  133. package/src/actions/wallet/extendEntity.ts +40 -16
  134. package/src/actions/wallet/patchEntity.ts +90 -0
  135. package/src/attr/attributes.test.ts +120 -0
  136. package/src/attr/attributes.ts +196 -0
  137. package/src/attr/codec.test.ts +162 -0
  138. package/src/attr/codec.ts +220 -0
  139. package/src/attr/decimal.ts +86 -0
  140. package/src/attr/errors.ts +145 -0
  141. package/src/attr/index.ts +50 -0
  142. package/src/attr/names.ts +106 -0
  143. package/src/attr/types.ts +150 -0
  144. package/src/attr/values.test.ts +271 -0
  145. package/src/attr/values.ts +506 -0
  146. package/src/chains/cheesecake.ts +22 -0
  147. package/src/chains/index.ts +1 -2
  148. package/src/chains/localhost.ts +3 -0
  149. package/src/clients/createPublicClient.test.ts +4 -6
  150. package/src/clients/createPublicClient.ts +9 -8
  151. package/src/clients/createWalletClient.test.ts +4 -4
  152. package/src/clients/createWalletClient.ts +13 -9
  153. package/src/clients/decorators/arkivAdvanced.ts +144 -0
  154. package/src/clients/decorators/arkivPublic.ts +181 -147
  155. package/src/clients/decorators/arkivWallet.ts +141 -122
  156. package/src/consts.ts +2 -1
  157. package/src/entity/create.test.ts +203 -0
  158. package/src/entity/errors.ts +39 -0
  159. package/src/entity/events.ts +16 -0
  160. package/src/entity/expiry.test.ts +195 -0
  161. package/src/entity/expiry.ts +182 -0
  162. package/src/entity/flags.ts +65 -0
  163. package/src/entity/index.ts +16 -0
  164. package/src/entity/key.ts +88 -0
  165. package/src/entity/operations.ts +135 -0
  166. package/src/entity/params.ts +15 -0
  167. package/src/errors.ts +33 -28
  168. package/src/index.ts +19 -0
  169. package/src/query/engine.ts +68 -132
  170. package/src/query/errors.ts +151 -0
  171. package/src/query/expression.test.ts +286 -0
  172. package/src/query/expression.ts +500 -0
  173. package/src/query/index.ts +40 -4
  174. package/src/query/injection.test.ts +151 -0
  175. package/src/query/queryBuilder.test.ts +342 -637
  176. package/src/query/queryBuilder.ts +133 -359
  177. package/src/query/queryResult.ts +54 -51
  178. package/src/query/selection.test.ts +48 -98
  179. package/src/query/selection.ts +77 -65
  180. package/src/types/entity.test.ts +44 -155
  181. package/src/types/entity.ts +62 -44
  182. package/src/types/events.ts +64 -23
  183. package/src/types/index.ts +24 -20
  184. package/src/types/rpcSchema.ts +71 -33
  185. package/src/types/txParams.ts +8 -0
  186. package/src/utils/arkivTransactions.test.ts +687 -38
  187. package/src/utils/arkivTransactions.ts +400 -115
  188. package/src/utils/chains.test.ts +21 -24
  189. package/src/utils/compression.ts +1 -1
  190. package/src/utils/entities.test.ts +62 -0
  191. package/src/utils/entities.ts +111 -29
  192. package/src/utils/expirationTime.ts +153 -10
  193. package/src/utils/logger.ts +2 -2
  194. package/src/utils/payload.ts +29 -2
  195. package/src/utils/revert.test.ts +99 -0
  196. package/src/utils/revert.ts +145 -0
  197. package/dist/chains-BifaY04V.cjs +0 -108
  198. package/dist/chains-CrtkVbBh.js +0 -86
  199. package/dist/chains-CrtkVbBh.js.map +0 -1
  200. package/dist/consts-AUoL-v42.cjs +0 -18
  201. package/dist/consts-BV4PR-de.js +0 -7
  202. package/dist/consts-BV4PR-de.js.map +0 -1
  203. package/dist/entity-B6g_EPm1.d.cts +0 -382
  204. package/dist/entity-B6g_EPm1.d.cts.map +0 -1
  205. package/dist/entity-qoLMAuuk.d.ts +0 -382
  206. package/dist/entity-qoLMAuuk.d.ts.map +0 -1
  207. package/dist/index-DdspxNAA.d.ts +0 -481
  208. package/dist/index-DdspxNAA.d.ts.map +0 -1
  209. package/dist/index-Ds9dwqb5.d.cts +0 -481
  210. package/dist/index-Ds9dwqb5.d.cts.map +0 -1
  211. package/dist/payload-B2kFJyah.d.ts +0 -6
  212. package/dist/payload-B2kFJyah.d.ts.map +0 -1
  213. package/dist/payload-CJN8fTvX.d.cts +0 -6
  214. package/dist/payload-CJN8fTvX.d.cts.map +0 -1
  215. package/dist/payload-Claf2jUO.js +0 -13
  216. package/dist/payload-Claf2jUO.js.map +0 -1
  217. package/dist/payload-DpA5PA-w.cjs +0 -23
  218. package/dist/query/index.js.map +0 -1
  219. package/dist/queryBuilder-D2uwP9jI.js +0 -704
  220. package/dist/queryBuilder-D2uwP9jI.js.map +0 -1
  221. package/dist/queryBuilder-UW2MCaX4.cjs +0 -792
  222. package/dist/utils/index.d.cts.map +0 -1
  223. package/dist/utils/index.d.ts.map +0 -1
  224. package/dist/utils/index.js.map +0 -1
  225. package/src/actions/public/buildQuery.ts +0 -10
  226. package/src/actions/public/subscribeEntityEvents.ts +0 -119
  227. package/src/actions/wallet/mutateEntities.ts +0 -111
  228. package/src/actions/wallet/updateEntity.ts +0 -60
  229. package/src/chains/braga.ts +0 -26
  230. package/src/chains/kaolin.ts +0 -29
  231. package/src/query/engine.test.ts +0 -526
  232. package/src/query/predicate.test.ts +0 -461
  233. package/src/query/predicate.ts +0 -144
  234. package/src/query/queryResult.test.ts +0 -270
  235. package/src/query/selectQueryBuilder.test.ts +0 -210
  236. package/src/types/attributes.ts +0 -16
  237. package/src/utils/validation.test.ts +0 -60
  238. package/src/utils/validation.ts +0 -32
  239. /package/dist/{types-H-TSmRpm.js → attr-DlmErkvR.cjs} +0 -0
  240. /package/dist/{types-o3zWarRp.cjs → attr-GcQKatub.js} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;;;mBAAJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":[],"mappings":";;;cAEa;;;EAAA,SAAA,EAAA,CAAA,KAUZ,EAAA,MAAA,EAAA,GADkB,MAAI;;;;;;mBAAJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/expirationTime.ts"],"sourcesContent":["import { BLOCK_TIME } from \"../consts\"\n\nexport const ExpirationTime = {\n fromSeconds: (seconds: number) => seconds,\n fromMinutes: (minutes: number) => minutes * 60,\n fromHours: (hours: number) => hours * 60 * 60,\n fromDays: (days: number) => days * 24 * 60 * 60,\n fromWeeks: (weeks: number) => weeks * 7 * 24 * 60 * 60,\n fromMonths: (months: number) => months * 30 * 24 * 60 * 60,\n fromYears: (years: number) => years * 365 * 24 * 60 * 60,\n fromBlocks: (blocks: number) => blocks * BLOCK_TIME,\n fromDate: (date: Date) => Math.floor(date.getTime() / 1000) - Math.floor(Date.now() / 1000),\n}\n"],"mappings":";;;;AAEA,MAAa,iBAAiB;CAC5B,cAAc,YAAoB;CAClC,cAAc,YAAoB,UAAU;CAC5C,YAAY,UAAkB,QAAQ,KAAK;CAC3C,WAAW,SAAiB,OAAO,KAAK,KAAK;CAC7C,YAAY,UAAkB,QAAQ,IAAI,KAAK,KAAK;CACpD,aAAa,WAAmB,SAAS,KAAK,KAAK,KAAK;CACxD,YAAY,UAAkB,QAAQ,MAAM,KAAK,KAAK;CACtD,aAAa,WAAmB,SAAS;CACzC,WAAW,SAAe,KAAK,MAAM,KAAK,SAAS,GAAG,IAAK,GAAG,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;CAC5F"}
@@ -1,10 +0,0 @@
1
- import type { ArkivClient } from "../../clients/baseClient"
2
- import { QueryBuilder } from "../../query/queryBuilder"
3
-
4
- /**
5
- * @deprecated Use `client.select()` (see SelectQueryBuilder) instead. `buildQuery()` returns
6
- * only the entity `key` unless data is explicitly opted in to, which is an easy mistake.
7
- */
8
- export async function buildQuery(client: ArkivClient) {
9
- return new QueryBuilder(client)
10
- }
@@ -1,119 +0,0 @@
1
- import { decodeEventLog, type Hex, parseAbi, toHex } from "viem"
2
- import type { ArkivClient } from "../../clients/baseClient"
3
- import type { PublicArkivClient } from "../../clients/createPublicClient"
4
- import type {
5
- OnEntityCreatedEvent,
6
- OnEntityDeletedEvent,
7
- OnEntityExpiredEvent,
8
- OnEntityExpiresInExtendedEvent,
9
- OnEntityOwnerChangedEvent,
10
- OnEntityUpdatedEvent,
11
- } from "../../types/events"
12
- import { getLogger } from "../../utils/logger"
13
-
14
- const logger = getLogger("actions:public:subscribe-entity-events")
15
-
16
- export const arkivABI = parseAbi([
17
- "event ArkivEntityCreated(uint256 indexed entityKey, address indexed ownerAddress, uint256 expirationBlock, uint256 cost)",
18
- "event ArkivEntityUpdated(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
19
- "event ArkivEntityExpired(uint256 indexed entityKey, address indexed ownerAddress)",
20
- "event ArkivEntityDeleted(uint256 indexed entityKey, address indexed ownerAddress)",
21
- "event ArkivEntityBTLExtended(uint256 indexed entityKey, address indexed ownerAddress, uint256 oldExpirationBlock, uint256 newExpirationBlock, uint256 cost)",
22
- "event ArkivEntityOwnerChanged(uint256 indexed entityKey, address indexed oldOwnerAddress, address indexed newOwnerAddress)",
23
- ])
24
-
25
- export async function subscribeEntityEvents(
26
- client: ArkivClient,
27
- {
28
- onError,
29
- onEntityCreated,
30
- onEntityUpdated,
31
- onEntityDeleted,
32
- onEntityExpired,
33
- onEntityExpiresInExtended,
34
- onEntityOwnerChanged,
35
- }: {
36
- onError: ((error: Error) => void) | undefined
37
- onEntityCreated?: ((event: OnEntityCreatedEvent) => void) | undefined
38
- onEntityUpdated?: ((event: OnEntityUpdatedEvent) => void) | undefined
39
- onEntityDeleted?: ((event: OnEntityDeletedEvent) => void) | undefined
40
- onEntityExpired?: ((event: OnEntityExpiredEvent) => void) | undefined
41
- onEntityExpiresInExtended?: ((event: OnEntityExpiresInExtendedEvent) => void) | undefined
42
- onEntityOwnerChanged?: ((event: OnEntityOwnerChangedEvent) => void) | undefined
43
- },
44
- pollingInterval?: number,
45
- fromBlock?: bigint,
46
- ): Promise<() => void> {
47
- const unsubscribe = (client as PublicArkivClient).watchEvent({
48
- pollingInterval: pollingInterval ?? 1000,
49
- fromBlock,
50
- events: arkivABI,
51
- onLogs: (logs) => {
52
- logger("logs from subscribeEntityEvents %o", logs)
53
- for (const log of logs) {
54
- const event = decodeEventLog({
55
- abi: arkivABI,
56
- topics: log.topics as [Hex, ...Hex[]] | [],
57
- data: log.data,
58
- })
59
- logger("event from subscribeEntityEvents %o", event)
60
- switch (event.eventName) {
61
- case "ArkivEntityCreated":
62
- onEntityCreated?.({
63
- entityKey: toHex(event.args.entityKey, { size: 32 }),
64
- owner: event.args.ownerAddress,
65
- expirationBlock: Number(event.args.expirationBlock),
66
- cost: event.args.cost,
67
- })
68
- break
69
- case "ArkivEntityUpdated":
70
- onEntityUpdated?.({
71
- entityKey: toHex(event.args.entityKey, { size: 32 }),
72
- owner: event.args.ownerAddress,
73
- oldExpirationBlock: Number(event.args.oldExpirationBlock),
74
- newExpirationBlock: Number(event.args.newExpirationBlock),
75
- cost: event.args.cost,
76
- })
77
- break
78
- case "ArkivEntityDeleted":
79
- onEntityDeleted?.({
80
- entityKey: toHex(event.args.entityKey, { size: 32 }),
81
- owner: event.args.ownerAddress,
82
- })
83
- break
84
- case "ArkivEntityBTLExtended":
85
- onEntityExpiresInExtended?.({
86
- entityKey: toHex(event.args.entityKey, { size: 32 }),
87
- owner: event.args.ownerAddress,
88
- oldExpirationBlock: Number(event.args.oldExpirationBlock),
89
- newExpirationBlock: Number(event.args.newExpirationBlock),
90
- cost: event.args.cost,
91
- })
92
- break
93
- case "ArkivEntityExpired":
94
- onEntityExpired?.({
95
- entityKey: toHex(event.args.entityKey, { size: 32 }),
96
- owner: event.args.ownerAddress,
97
- })
98
- break
99
- case "ArkivEntityOwnerChanged":
100
- onEntityOwnerChanged?.({
101
- entityKey: toHex(event.args.entityKey, { size: 32 }),
102
- oldOwner: event.args.oldOwnerAddress,
103
- newOwner: event.args.newOwnerAddress,
104
- })
105
- break
106
- default:
107
- console.warn("unknown event from subscribeEntityEvents", event)
108
- break
109
- }
110
- }
111
- },
112
- onError: (error) => {
113
- console.error("error from subscribeEntityEvents", error)
114
- onError?.(error)
115
- },
116
- })
117
-
118
- return unsubscribe
119
- }
@@ -1,111 +0,0 @@
1
- import type { Hash, Hex, TransactionReceipt } from "viem"
2
- import type { ArkivClient } from "../../clients/baseClient"
3
- import type { TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
5
- import { getLogger } from "../../utils/logger"
6
- import type { ChangeOwnershipParameters } from "./changeOwnership"
7
-
8
- const logger = getLogger("actions:wallet:mutate-entities")
9
-
10
- import type { CreateEntityParameters } from "./createEntity"
11
- import type { DeleteEntityParameters } from "./deleteEntity"
12
- import type { ExtendEntityParameters } from "./extendEntity"
13
- import type { UpdateEntityParameters } from "./updateEntity"
14
-
15
- /**
16
- * Parameters for the mutateEntities function.
17
- * - creates: The creates to perform.
18
- * - updates: The updates to perform.
19
- * - deletes: The deletes to perform.
20
- * - extensions: The extensions to perform.
21
- */
22
- export type MutateEntitiesParameters = {
23
- creates?: CreateEntityParameters[]
24
- updates?: UpdateEntityParameters[]
25
- deletes?: DeleteEntityParameters[]
26
- extensions?: ExtendEntityParameters[]
27
- ownershipChanges?: ChangeOwnershipParameters[]
28
- }
29
-
30
- function parseReceipt(receipt: TransactionReceipt, params: MutateEntitiesParameters) {
31
- const createdEntities: Hex[] = []
32
- const updatedEntities: Hex[] = []
33
- const deletedEntities: Hex[] = []
34
- const extendedEntities: Hex[] = []
35
- const ownershipChanges: Hex[] = []
36
-
37
- const totalCreates = params.creates?.length ?? 0
38
- const totalUpdates = params.updates?.length ?? 0
39
- const totalDeletes = params.deletes?.length ?? 0
40
- const totalExtensions = params.extensions?.length ?? 0
41
-
42
- // iterate over all logs and parse the event
43
- // logs go in the following order: creates, deleted, updates, extends, ownership changes
44
- for (let index = 0; index < receipt.logs.length; index++) {
45
- const log = receipt.logs[index]
46
-
47
- if (index < totalCreates) {
48
- createdEntities.push(log.topics[1] as Hex)
49
- } else if (index < totalCreates + totalDeletes) {
50
- deletedEntities.push(log.topics[1] as Hex)
51
- } else if (index < totalCreates + totalUpdates + totalDeletes) {
52
- updatedEntities.push(log.topics[1] as Hex)
53
- } else if (index < totalCreates + totalUpdates + totalDeletes + totalExtensions) {
54
- extendedEntities.push(log.topics[1] as Hex)
55
- } else {
56
- ownershipChanges.push(log.topics[1] as Hex)
57
- }
58
- }
59
-
60
- return { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges }
61
- }
62
-
63
- /**
64
- * Return type for the mutateEntities function.
65
- * - txHash: The transaction hash.
66
- * - createdEntities: The keys of the created entities.
67
- * - updatedEntities: The keys of the updated entities.
68
- * - deletedEntities: The keys of the deleted entities.
69
- * - extendedEntities: The keys of the extended entities.
70
- * - ownershipChanges: The keys of the ownership changes.
71
- */
72
- export type MutateEntitiesReturnType = {
73
- txHash: Hash
74
- createdEntities: Hex[]
75
- updatedEntities: Hex[]
76
- deletedEntities: Hex[]
77
- extendedEntities: Hex[]
78
- ownershipChanges: Hex[]
79
- }
80
- export async function mutateEntities(
81
- client: ArkivClient,
82
- data: MutateEntitiesParameters,
83
- txParams?: TxParams,
84
- ): Promise<MutateEntitiesReturnType> {
85
- if (!data.creates && !data.updates && !data.deletes && !data.extensions) {
86
- throw new Error("No operations to perform")
87
- }
88
-
89
- const txData = opsToTxData({
90
- creates: data.creates ?? [],
91
- updates: data.updates ?? [],
92
- deletes: data.deletes ?? [],
93
- extensions: data.extensions ?? [],
94
- ownershipChanges: data.ownershipChanges ?? [],
95
- })
96
-
97
- const receipt = await sendArkivTransaction(client, txData, txParams)
98
-
99
- logger("Receipt from mutateEntities %o", receipt)
100
-
101
- const { createdEntities, updatedEntities, deletedEntities, extendedEntities, ownershipChanges } =
102
- parseReceipt(receipt, data)
103
- return {
104
- txHash: receipt.transactionHash as Hash,
105
- createdEntities,
106
- updatedEntities,
107
- deletedEntities,
108
- extendedEntities,
109
- ownershipChanges,
110
- }
111
- }
@@ -1,60 +0,0 @@
1
- import type { Hash, Hex } from "viem"
2
- import type { ArkivClient } from "../../clients/baseClient"
3
- import type { Attribute, MimeType, TxParams } from "../../types"
4
- import { opsToTxData, sendArkivTransaction } from "../../utils/arkivTransactions"
5
- import { getLogger } from "../../utils/logger"
6
-
7
- const logger = getLogger("actions:wallet:update-entity")
8
-
9
- /**
10
- * Parameters for the updateEntity function.
11
- * - entityKey: The key of the entity to update.
12
- * - payload: The payload of the entity.
13
- * - attributes: The attributes of the entity. Attribute values may be strings
14
- * or numbers, but numeric values **must be integers**. To store a non-integer,
15
- * scale it to an integer (e.g. `1.5` -> `1500`) to preserve numeric ordering,
16
- * or pass it as a string (e.g. `"1.5"`). A non-integer numeric value throws an
17
- * {@link InvalidAttributeError}.
18
- * - contentType: The content type of the entity.
19
- * - expiresIn: How long until the entity expires, in seconds. Because Arkiv
20
- * measures expiration in blocks (1 block = 2 seconds), this **must be a
21
- * positive integer and a multiple of the block time (2 seconds)**.
22
- * Invalid values throw an {@link InvalidExpirationError}.
23
- */
24
- export type UpdateEntityParameters = {
25
- entityKey: Hex
26
- payload: Uint8Array
27
- /** Entity attributes. Numeric values must be integers (scale non-integers, e.g. `1.5` -> `1500`, or use a string). Throws {@link InvalidAttributeError} otherwise. */
28
- attributes: Attribute[]
29
- contentType: MimeType | string
30
- /** Seconds until expiry. Must be a positive integer and a multiple of the 2s block time.
31
- * Throws {@link InvalidExpirationError} otherwise. */
32
- expiresIn: number
33
- }
34
-
35
- /**
36
- * Return type for the updateEntity function.
37
- * - entityKey: The key of the entity.
38
- * - txHash: The transaction hash.
39
- */
40
- export type UpdateEntityReturnType = {
41
- entityKey: Hex
42
- txHash: Hash
43
- }
44
-
45
- export async function updateEntity(
46
- client: ArkivClient,
47
- data: UpdateEntityParameters,
48
- txParams?: TxParams,
49
- ): Promise<UpdateEntityReturnType> {
50
- logger("updateEntity %o", data)
51
- const txData = opsToTxData({ updates: [data] })
52
- const receipt = await sendArkivTransaction(client, txData, txParams)
53
-
54
- logger("Receipt from updateEntity %o", receipt)
55
-
56
- return {
57
- txHash: receipt.transactionHash as Hash,
58
- entityKey: receipt.logs[0].topics[1] as Hex,
59
- }
60
- }
@@ -1,26 +0,0 @@
1
- import { defineChain } from "viem"
2
-
3
- export const braga = defineChain({
4
- id: 60138453102,
5
- name: "Braga",
6
- network: "braga",
7
- nativeCurrency: {
8
- name: "Golem",
9
- symbol: "GLM",
10
- decimals: 18,
11
- },
12
- rpcUrls: {
13
- default: {
14
- http: ["https://braga.hoodi.arkiv.network/rpc"],
15
- webSocket: ["wss://braga.hoodi.arkiv.network/rpc/ws"],
16
- },
17
- },
18
- blockExplorers: {
19
- default: {
20
- name: "Braga Arkiv Explorer",
21
- url: "https://explorer.braga.hoodi.arkiv.network",
22
- apiUrl: "https://explorer.braga.hoodi.arkiv.network/api",
23
- },
24
- },
25
- testnet: true,
26
- })
@@ -1,29 +0,0 @@
1
- import { defineChain } from "viem"
2
-
3
- /**
4
- * @deprecated The kaolin network is getting removed on may 15th 2026. Migration guide: https://docs.arkiv.network/networks/migrate-from-kaolin/
5
- */
6
- export const kaolin = defineChain({
7
- id: 60138453025,
8
- name: "Kaolin",
9
- network: "kaolin",
10
- nativeCurrency: {
11
- name: "Ethereum",
12
- symbol: "ETH",
13
- decimals: 18,
14
- },
15
- rpcUrls: {
16
- default: {
17
- http: ["https://kaolin.hoodi.arkiv.network/rpc"],
18
- webSocket: ["wss://kaolin.hoodi.arkiv.network/rpc/ws"],
19
- },
20
- },
21
- blockExplorers: {
22
- default: {
23
- name: "Kaolin Arkiv Explorer",
24
- url: "https://explorer.kaolin.hoodi.arkiv.network",
25
- apiUrl: "https://explorer.kaolin.hoodi.arkiv.network/api",
26
- },
27
- },
28
- testnet: true,
29
- })