@hiero-ledger/sdk 2.80.0 → 2.81.0-beta.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 (182) hide show
  1. package/README.md +34 -7
  2. package/dist/umd.js +2213 -318
  3. package/dist/umd.js.map +1 -0
  4. package/dist/umd.min.js +6 -5
  5. package/dist/umd.min.js.map +1 -0
  6. package/lib/Executable.cjs +7 -4
  7. package/lib/Executable.js +1 -1
  8. package/lib/Executable.js.map +1 -1
  9. package/lib/PublicKey.cjs +45 -26
  10. package/lib/PublicKey.d.ts +12 -0
  11. package/lib/PublicKey.js +1 -1
  12. package/lib/PublicKey.js.map +1 -1
  13. package/lib/RequestType.cjs +19 -1
  14. package/lib/RequestType.d.ts +2 -0
  15. package/lib/RequestType.js +1 -1
  16. package/lib/RequestType.js.map +1 -1
  17. package/lib/Status.cjs +203 -252
  18. package/lib/Status.d.ts +8 -6
  19. package/lib/Status.js +1 -1
  20. package/lib/Status.js.map +1 -1
  21. package/lib/Transfer.cjs +25 -2
  22. package/lib/Transfer.d.ts +4 -0
  23. package/lib/Transfer.js +1 -1
  24. package/lib/Transfer.js.map +1 -1
  25. package/lib/account/AccountCreateTransaction.cjs +38 -0
  26. package/lib/account/AccountCreateTransaction.d.ts +21 -0
  27. package/lib/account/AccountCreateTransaction.js +1 -1
  28. package/lib/account/AccountCreateTransaction.js.map +1 -1
  29. package/lib/account/AccountUpdateTransaction.cjs +74 -1
  30. package/lib/account/AccountUpdateTransaction.d.ts +43 -0
  31. package/lib/account/AccountUpdateTransaction.js +1 -1
  32. package/lib/account/AccountUpdateTransaction.js.map +1 -1
  33. package/lib/account/TransferTransaction.cjs +57 -9
  34. package/lib/account/TransferTransaction.d.ts +31 -1
  35. package/lib/account/TransferTransaction.js +1 -1
  36. package/lib/account/TransferTransaction.js.map +1 -1
  37. package/lib/browser.js +1 -1
  38. package/lib/client/Client.cjs +38 -0
  39. package/lib/client/Client.d.ts +30 -0
  40. package/lib/client/Client.js +1 -1
  41. package/lib/client/Client.js.map +1 -1
  42. package/lib/client/addressbooks/mainnet.cjs +1 -1
  43. package/lib/client/addressbooks/mainnet.d.ts +1 -1
  44. package/lib/client/addressbooks/mainnet.js +1 -1
  45. package/lib/client/addressbooks/mainnet.js.map +1 -1
  46. package/lib/client/addressbooks/previewnet.cjs +1 -1
  47. package/lib/client/addressbooks/previewnet.d.ts +1 -1
  48. package/lib/client/addressbooks/previewnet.js +1 -1
  49. package/lib/client/addressbooks/previewnet.js.map +1 -1
  50. package/lib/client/addressbooks/testnet.cjs +1 -1
  51. package/lib/client/addressbooks/testnet.d.ts +1 -1
  52. package/lib/client/addressbooks/testnet.js +1 -1
  53. package/lib/client/addressbooks/testnet.js.map +1 -1
  54. package/lib/contract/ContractCreateTransaction.cjs +37 -1
  55. package/lib/contract/ContractCreateTransaction.d.ts +21 -0
  56. package/lib/contract/ContractCreateTransaction.js +1 -1
  57. package/lib/contract/ContractCreateTransaction.js.map +1 -1
  58. package/lib/contract/ContractUpdateTransaction.cjs +74 -1
  59. package/lib/contract/ContractUpdateTransaction.d.ts +43 -0
  60. package/lib/contract/ContractUpdateTransaction.js +1 -1
  61. package/lib/contract/ContractUpdateTransaction.js.map +1 -1
  62. package/lib/exports.cjs +103 -0
  63. package/lib/exports.d.ts +13 -0
  64. package/lib/exports.js +1 -1
  65. package/lib/exports.js.map +1 -1
  66. package/lib/hooks/EvmHook.cjs +84 -0
  67. package/lib/hooks/EvmHook.d.ts +51 -0
  68. package/lib/hooks/EvmHook.js +2 -0
  69. package/lib/hooks/EvmHook.js.map +1 -0
  70. package/lib/hooks/EvmHookCall.cjs +103 -0
  71. package/lib/hooks/EvmHookCall.d.ts +69 -0
  72. package/lib/hooks/EvmHookCall.js +2 -0
  73. package/lib/hooks/EvmHookCall.js.map +1 -0
  74. package/lib/hooks/EvmHookMappingEntry.cjs +135 -0
  75. package/lib/hooks/EvmHookMappingEntry.d.ts +84 -0
  76. package/lib/hooks/EvmHookMappingEntry.js +2 -0
  77. package/lib/hooks/EvmHookMappingEntry.js.map +1 -0
  78. package/lib/hooks/EvmHookStorageUpdate.cjs +238 -0
  79. package/lib/hooks/EvmHookStorageUpdate.d.ts +144 -0
  80. package/lib/hooks/EvmHookStorageUpdate.js +2 -0
  81. package/lib/hooks/EvmHookStorageUpdate.js.map +1 -0
  82. package/lib/hooks/FungibleHookCall.cjs +67 -0
  83. package/lib/hooks/FungibleHookCall.d.ts +50 -0
  84. package/lib/hooks/FungibleHookCall.js +2 -0
  85. package/lib/hooks/FungibleHookCall.js.map +1 -0
  86. package/lib/hooks/FungibleHookType.cjs +11 -0
  87. package/lib/hooks/FungibleHookType.d.ts +5 -0
  88. package/lib/hooks/FungibleHookType.js +2 -0
  89. package/lib/hooks/FungibleHookType.js.map +1 -0
  90. package/lib/hooks/HookCall.cjs +99 -0
  91. package/lib/hooks/HookCall.d.ts +64 -0
  92. package/lib/hooks/HookCall.js +2 -0
  93. package/lib/hooks/HookCall.js.map +1 -0
  94. package/lib/hooks/HookCreationDetails.cjs +149 -0
  95. package/lib/hooks/HookCreationDetails.d.ts +91 -0
  96. package/lib/hooks/HookCreationDetails.js +2 -0
  97. package/lib/hooks/HookCreationDetails.js.map +1 -0
  98. package/lib/hooks/HookEntityId.cjs +67 -0
  99. package/lib/hooks/HookEntityId.d.ts +41 -0
  100. package/lib/hooks/HookEntityId.js +2 -0
  101. package/lib/hooks/HookEntityId.js.map +1 -0
  102. package/lib/hooks/HookExtensionPoint.cjs +31 -0
  103. package/lib/hooks/HookExtensionPoint.d.ts +16 -0
  104. package/lib/hooks/HookExtensionPoint.js +2 -0
  105. package/lib/hooks/HookExtensionPoint.js.map +1 -0
  106. package/lib/hooks/HookId.cjs +101 -0
  107. package/lib/hooks/HookId.d.ts +63 -0
  108. package/lib/hooks/HookId.js +2 -0
  109. package/lib/hooks/HookId.js.map +1 -0
  110. package/lib/hooks/HookStoreTransaction.cjs +157 -0
  111. package/lib/hooks/HookStoreTransaction.d.ts +77 -0
  112. package/lib/hooks/HookStoreTransaction.js +2 -0
  113. package/lib/hooks/HookStoreTransaction.js.map +1 -0
  114. package/lib/hooks/NftHookCall.cjs +67 -0
  115. package/lib/hooks/NftHookCall.d.ts +50 -0
  116. package/lib/hooks/NftHookCall.js +2 -0
  117. package/lib/hooks/NftHookCall.js.map +1 -0
  118. package/lib/hooks/NftHookType.cjs +13 -0
  119. package/lib/hooks/NftHookType.d.ts +7 -0
  120. package/lib/hooks/NftHookType.js +2 -0
  121. package/lib/hooks/NftHookType.js.map +1 -0
  122. package/lib/index.js +1 -1
  123. package/lib/native.js +1 -1
  124. package/lib/token/AbstractTokenTransferTransaction.cjs +17 -5
  125. package/lib/token/AbstractTokenTransferTransaction.d.ts +13 -2
  126. package/lib/token/AbstractTokenTransferTransaction.js +1 -1
  127. package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
  128. package/lib/token/TokenAirdropTransaction.cjs +1 -1
  129. package/lib/token/TokenAirdropTransaction.js +1 -1
  130. package/lib/token/TokenAirdropTransaction.js.map +1 -1
  131. package/lib/token/TokenNftTransfer.cjs +51 -2
  132. package/lib/token/TokenNftTransfer.d.ts +7 -0
  133. package/lib/token/TokenNftTransfer.js +1 -1
  134. package/lib/token/TokenNftTransfer.js.map +1 -1
  135. package/lib/token/TokenTransfer.cjs +26 -2
  136. package/lib/token/TokenTransfer.d.ts +4 -0
  137. package/lib/token/TokenTransfer.js +1 -1
  138. package/lib/token/TokenTransfer.js.map +1 -1
  139. package/lib/transaction/Transaction.cjs +2 -1
  140. package/lib/transaction/Transaction.js +1 -1
  141. package/lib/transaction/Transaction.js.map +1 -1
  142. package/lib/transaction/TransactionResponse.cjs +82 -9
  143. package/lib/transaction/TransactionResponse.d.ts +33 -2
  144. package/lib/transaction/TransactionResponse.js +1 -1
  145. package/lib/transaction/TransactionResponse.js.map +1 -1
  146. package/lib/version.js +1 -1
  147. package/package.json +15 -13
  148. package/src/Executable.js +10 -7
  149. package/src/PublicKey.js +53 -36
  150. package/src/RequestType.js +18 -0
  151. package/src/Status.js +201 -252
  152. package/src/Transfer.js +33 -1
  153. package/src/account/AccountCreateTransaction.js +39 -0
  154. package/src/account/AccountUpdateTransaction.js +78 -0
  155. package/src/account/TransferTransaction.js +84 -8
  156. package/src/client/Client.js +38 -0
  157. package/src/client/addressbooks/mainnet.js +1 -1
  158. package/src/client/addressbooks/previewnet.js +1 -1
  159. package/src/client/addressbooks/testnet.js +1 -1
  160. package/src/contract/ContractCreateTransaction.js +37 -0
  161. package/src/contract/ContractUpdateTransaction.js +80 -0
  162. package/src/exports.js +17 -0
  163. package/src/hooks/EvmHook.js +83 -0
  164. package/src/hooks/EvmHookCall.js +100 -0
  165. package/src/hooks/EvmHookMappingEntry.js +140 -0
  166. package/src/hooks/EvmHookStorageUpdate.js +257 -0
  167. package/src/hooks/FungibleHookCall.js +65 -0
  168. package/src/hooks/FungibleHookType.js +6 -0
  169. package/src/hooks/HookCall.js +97 -0
  170. package/src/hooks/HookCreationDetails.js +155 -0
  171. package/src/hooks/HookEntityId.js +67 -0
  172. package/src/hooks/HookExtensionPoint.js +25 -0
  173. package/src/hooks/HookId.js +102 -0
  174. package/src/hooks/HookStoreTransaction.js +185 -0
  175. package/src/hooks/NftHookCall.js +64 -0
  176. package/src/hooks/NftHookType.js +8 -0
  177. package/src/token/AbstractTokenTransferTransaction.js +16 -1
  178. package/src/token/TokenAirdropTransaction.js +1 -0
  179. package/src/token/TokenNftTransfer.js +68 -1
  180. package/src/token/TokenTransfer.js +34 -1
  181. package/src/transaction/Transaction.js +3 -0
  182. package/src/transaction/TransactionResponse.js +98 -13
@@ -54,6 +54,8 @@ export default class ContractUpdateTransaction extends Transaction {
54
54
  * @param {Long | number} [props.stakedNodeId]
55
55
  * @param {boolean} [props.declineStakingReward]
56
56
  * @param {AccountId} [props.autoRenewAccountId]
57
+ * @param {import("../hooks/HookCreationDetails.js").default[]} [props.hooksToBeCreated]
58
+ * @param {Long[]} [props.hooksToBeDeleted]
57
59
  */
58
60
  constructor(props = {}) {
59
61
  super();
@@ -129,6 +131,18 @@ export default class ContractUpdateTransaction extends Transaction {
129
131
  */
130
132
  this._autoRenewAccountId = null;
131
133
 
134
+ /**
135
+ * @private
136
+ * @type {import("../hooks/HookCreationDetails.js").default[]}
137
+ */
138
+ this._hooksToBeCreated = [];
139
+
140
+ /**
141
+ * @private
142
+ * @type {Long[]}
143
+ */
144
+ this._hooksToBeDeleted = [];
145
+
132
146
  if (props.contractId != null) {
133
147
  this.setContractId(props.contractId);
134
148
  }
@@ -179,6 +193,14 @@ export default class ContractUpdateTransaction extends Transaction {
179
193
  if (props.autoRenewAccountId != null) {
180
194
  this.setAutoRenewAccountId(props.autoRenewAccountId);
181
195
  }
196
+
197
+ if (props.hooksToBeCreated != null) {
198
+ this.setHooksToCreate(props.hooksToBeCreated);
199
+ }
200
+
201
+ if (props.hooksToBeDeleted != null) {
202
+ this.setHooksToDelete(props.hooksToBeDeleted);
203
+ }
182
204
  }
183
205
 
184
206
  /**
@@ -572,6 +594,57 @@ export default class ContractUpdateTransaction extends Transaction {
572
594
  }
573
595
  }
574
596
 
597
+ /**
598
+ * @param {import("../hooks/HookCreationDetails.js").default} hook
599
+ * @returns {this}
600
+ */
601
+ addHookToCreate(hook) {
602
+ this._hooksToBeCreated.push(hook);
603
+ return this;
604
+ }
605
+
606
+ /**
607
+ * @param {import("../hooks/HookCreationDetails.js").default[]} hooks
608
+ * @returns {this}
609
+ */
610
+ setHooksToCreate(hooks) {
611
+ this._hooksToBeCreated = hooks;
612
+ return this;
613
+ }
614
+
615
+ /**
616
+ * @returns {import("../hooks/HookCreationDetails.js").default[]}
617
+ */
618
+ get hooksToCreate() {
619
+ return this._hooksToBeCreated;
620
+ }
621
+
622
+ /**
623
+ *
624
+ * @param {Long} hook
625
+ * @returns {this}
626
+ */
627
+ addHookToDelete(hook) {
628
+ this._hooksToBeDeleted.push(hook);
629
+ return this;
630
+ }
631
+
632
+ /**
633
+ * @param {Long[]} hookIds
634
+ * @returns {this}
635
+ */
636
+ setHooksToDelete(hookIds) {
637
+ this._hooksToBeDeleted = hookIds;
638
+ return this;
639
+ }
640
+
641
+ /**
642
+ * @returns {Long[]}
643
+ */
644
+ get hooksToDelete() {
645
+ return this._hooksToBeDeleted;
646
+ }
647
+
575
648
  /**
576
649
  * @override
577
650
  * @internal
@@ -647,6 +720,13 @@ export default class ContractUpdateTransaction extends Transaction {
647
720
  ? Proto.proto.AccountID.create()
648
721
  : this._autoRenewAccountId._toProtobuf()
649
722
  : null,
723
+
724
+ hookIdsToDelete:
725
+ this._hooksToBeDeleted != null ? this._hooksToBeDeleted : null,
726
+ hookCreationDetails:
727
+ this._hooksToBeCreated != null
728
+ ? this._hooksToBeCreated.map((hook) => hook._toProtobuf())
729
+ : null,
650
730
  };
651
731
  }
652
732
 
package/src/exports.js CHANGED
@@ -73,6 +73,23 @@ export { default as FeeDataType } from "./FeeDataType.js";
73
73
  export { default as FeeSchedule } from "./FeeSchedule.js";
74
74
  export { default as FeeSchedules } from "./FeeSchedules.js";
75
75
  export { default as FileAppendTransaction } from "./file/FileAppendTransaction.js";
76
+ export { default as HookCreationDetails } from "./hooks/HookCreationDetails.js";
77
+ export { default as EvmHook } from "./hooks/EvmHook.js";
78
+ export { HookExtensionPoint } from "./hooks/HookExtensionPoint.js";
79
+ export { default as FungibleHookCall } from "./hooks/FungibleHookCall.js";
80
+ export { default as NftHookCall } from "./hooks/NftHookCall.js";
81
+ export { default as EvmHookCall } from "./hooks/EvmHookCall.js";
82
+ export { default as FungibleHookType } from "./hooks/FungibleHookType.js";
83
+ export { default as NftHookType } from "./hooks/NftHookType.js";
84
+ export { default as HookId } from "./hooks/HookId.js";
85
+ export { default as HookEntityId } from "./hooks/HookEntityId.js";
86
+ export { default as HookStoreTransaction } from "./hooks/HookStoreTransaction.js";
87
+ export {
88
+ EvmHookStorageUpdate,
89
+ EvmHookStorageSlot,
90
+ EvmHookMappingEntries,
91
+ } from "./hooks/EvmHookStorageUpdate.js";
92
+ export { default as EvmHookMappingEntry } from "./hooks/EvmHookMappingEntry.js";
76
93
  export { default as FileContentsQuery } from "./file/FileContentsQuery.js";
77
94
  export { default as FileCreateTransaction } from "./file/FileCreateTransaction.js";
78
95
  export { default as FileDeleteTransaction } from "./file/FileDeleteTransaction.js";
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Definition of an EVM hook extending shared specifications for an EVM hook.
3
+ */
4
+ class EvmHook {
5
+ /**
6
+ *
7
+ * @param {object} [props]
8
+ * @param {import("./../contract/ContractId").default} [props.contractId]
9
+ * @param {import("./EvmHookStorageUpdate.js").EvmHookStorageUpdate[]} [props.storageUpdates]
10
+ */
11
+ constructor(props = {}) {
12
+ /**
13
+ * @private
14
+ * @type {?import("./../contract/ContractId.js").default}
15
+ */
16
+ this._contractId = null;
17
+
18
+ /**
19
+ * @private
20
+ * @type {import("./EvmHookStorageUpdate.js").EvmHookStorageUpdate[]}
21
+ */
22
+ this._storageUpdates = [];
23
+
24
+ if (props.storageUpdates != null) {
25
+ this.setStorageUpdates(props.storageUpdates);
26
+ }
27
+
28
+ if (props.contractId != null) {
29
+ this.setContractId(props.contractId);
30
+ }
31
+ }
32
+
33
+ /**
34
+ * @param {import("./../contract/ContractId.js").default} contractId
35
+ * @returns {this}
36
+ */
37
+ setContractId(contractId) {
38
+ this._contractId = contractId;
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * @param {import("./EvmHookStorageUpdate.js").EvmHookStorageUpdate[]} storageUpdates
44
+ * @returns {this}
45
+ */
46
+ setStorageUpdates(storageUpdates) {
47
+ this._storageUpdates = storageUpdates;
48
+ return this;
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @returns {import("./EvmHookStorageUpdate.js").EvmHookStorageUpdate[]}
54
+ */
55
+ get storageUpdates() {
56
+ return this._storageUpdates;
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @returns {import("./../contract/ContractId.js").default | null}
62
+ */
63
+ get contractId() {
64
+ return this._contractId;
65
+ }
66
+
67
+ /**
68
+ *
69
+ * @returns {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.IEvmHook}
70
+ */
71
+ _toProtobuf() {
72
+ return {
73
+ spec: {
74
+ contractId: this._contractId?._toProtobuf(),
75
+ },
76
+ storageUpdates: this._storageUpdates.map((update) =>
77
+ update._toProtobuf(),
78
+ ),
79
+ };
80
+ }
81
+ }
82
+
83
+ export default EvmHook;
@@ -0,0 +1,100 @@
1
+ import Long from "long";
2
+
3
+ /**
4
+ * @namespace proto
5
+ * @typedef {import("@hiero-ledger/proto").proto.IEvmHookCall} HieroProto.proto.IEvmHookCall
6
+ */
7
+
8
+ /**
9
+ * Specifies details of a call to an EVM hook.
10
+ */
11
+ class EvmHookCall {
12
+ /**
13
+ *
14
+ * @param {object} props
15
+ * @param {Uint8Array} [props.data]
16
+ * @param {Long} [props.gasLimit]
17
+ */
18
+ constructor(props = {}) {
19
+ /**
20
+ * @private
21
+ * @type {?Uint8Array}
22
+ */
23
+ this._data = null;
24
+
25
+ /**
26
+ * @private
27
+ * @type {?Long}
28
+ */
29
+ this._gasLimit = null;
30
+
31
+ if (props.data != null) {
32
+ this.setData(props.data);
33
+ }
34
+
35
+ if (props.gasLimit != null) {
36
+ this.setGasLimit(props.gasLimit);
37
+ }
38
+ }
39
+
40
+ /**
41
+ *
42
+ * @param {Uint8Array} data
43
+ * @returns {this}
44
+ */
45
+ setData(data) {
46
+ this._data = data;
47
+ return this;
48
+ }
49
+
50
+ /**
51
+ *
52
+ * @param {Long} gasLimit
53
+ * @returns {this}
54
+ */
55
+ setGasLimit(gasLimit) {
56
+ this._gasLimit = gasLimit;
57
+ return this;
58
+ }
59
+
60
+ /**
61
+ *
62
+ * @returns {Uint8Array | null}
63
+ */
64
+ get data() {
65
+ return this._data;
66
+ }
67
+
68
+ /**
69
+ *
70
+ * @returns {Long | null}
71
+ */
72
+ get gasLimit() {
73
+ return this._gasLimit;
74
+ }
75
+
76
+ /**
77
+ *
78
+ * @param {HieroProto.proto.IEvmHookCall} evmHookCall
79
+ * @returns {EvmHookCall}
80
+ */
81
+ static _fromProtobuf(evmHookCall) {
82
+ return new EvmHookCall({
83
+ data: evmHookCall.data ? evmHookCall.data : undefined,
84
+ gasLimit: evmHookCall.gasLimit ? evmHookCall.gasLimit : undefined,
85
+ });
86
+ }
87
+
88
+ /**
89
+ *
90
+ * @returns {import("@hiero-ledger/proto").proto.IEvmHookCall}
91
+ */
92
+ _toProtobuf() {
93
+ return {
94
+ data: this._data,
95
+ gasLimit: this._gasLimit ? this._gasLimit : null,
96
+ };
97
+ }
98
+ }
99
+
100
+ export default EvmHookCall;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * An entry in a Solidity mapping. Very helpful for protocols that apply
3
+ * `HookStore` to manage the entries of a hook contract's mapping instead
4
+ * its raw storage slots.
5
+ * <p>
6
+ * This is especially attractive when the mapping value itself fits in a single
7
+ * word; for more complicated value storage layouts it becomes necessary to
8
+ * combine the mapping update with additional `EvmHookStorageSlot` updates that
9
+ * specify the complete storage slots of the value type.
10
+ */
11
+ class EvmHookMappingEntry {
12
+ /**
13
+ *
14
+ * @param {object} props
15
+ * @param {Uint8Array} [props.key]
16
+ * @param {Uint8Array} [props.value]
17
+ * @param {Uint8Array} [props.preimage]
18
+ */
19
+ constructor(props = {}) {
20
+ /**
21
+ * @private
22
+ * @type {?Uint8Array}
23
+ */
24
+ this._key = null;
25
+
26
+ /**
27
+ * @private
28
+ * @type {?Uint8Array}
29
+ */
30
+ this._value = null;
31
+
32
+ /**
33
+ * @private
34
+ * @type {?Uint8Array}
35
+ */
36
+ this._preimage = null;
37
+
38
+ if (props.preimage != null) {
39
+ this.setPreimage(props.preimage);
40
+ }
41
+
42
+ if (props.key != null) {
43
+ this.setKey(props.key);
44
+ }
45
+
46
+ if (props.value != null) {
47
+ this.setValue(props.value);
48
+ }
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @param {Uint8Array} key
54
+ * @returns {this}
55
+ */
56
+ setKey(key) {
57
+ this._key = key;
58
+ this._preimage = null;
59
+ return this;
60
+ }
61
+
62
+ /**
63
+ *
64
+ * @param {Uint8Array} value
65
+ * @returns {this}
66
+ */
67
+ setValue(value) {
68
+ this._value = value;
69
+ return this;
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @param {Uint8Array} preimage
75
+ * @returns {this}
76
+ */
77
+ setPreimage(preimage) {
78
+ this._preimage = preimage;
79
+ this._key = null;
80
+ return this;
81
+ }
82
+
83
+ /**
84
+ *
85
+ * @returns {Uint8Array | null}
86
+ */
87
+ get key() {
88
+ return this._key;
89
+ }
90
+
91
+ /**
92
+ *
93
+ * @returns {Uint8Array | null}
94
+ */
95
+ get value() {
96
+ return this._value;
97
+ }
98
+
99
+ /**
100
+ *
101
+ * @returns {Uint8Array | null}
102
+ */
103
+ get preimage() {
104
+ return this._preimage;
105
+ }
106
+
107
+ /**
108
+ *
109
+ * @param {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.IEvmHookMappingEntry} hookMappingEntry
110
+ * @returns {EvmHookMappingEntry}
111
+ */
112
+ static _fromProtobuf(hookMappingEntry) {
113
+ return new EvmHookMappingEntry({
114
+ key:
115
+ hookMappingEntry.key != null ? hookMappingEntry.key : undefined,
116
+ value:
117
+ hookMappingEntry.value != null
118
+ ? hookMappingEntry.value
119
+ : undefined,
120
+ preimage:
121
+ hookMappingEntry.preimage != null
122
+ ? hookMappingEntry.preimage
123
+ : undefined,
124
+ });
125
+ }
126
+
127
+ /**
128
+ *
129
+ * @returns {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.IEvmHookMappingEntry}
130
+ */
131
+ _toProtobuf() {
132
+ return {
133
+ key: this._key,
134
+ value: this._value,
135
+ preimage: this._preimage,
136
+ };
137
+ }
138
+ }
139
+
140
+ export default EvmHookMappingEntry;
@@ -0,0 +1,257 @@
1
+ import EvmHookMappingEntry from "./EvmHookMappingEntry.js";
2
+
3
+ /**
4
+ *
5
+ * @abstract
6
+ * Specifies a key/value pair in the storage of a EVM hook, either by the explicit storage
7
+ * slot contents; or by a combination of a Solidity mapping's slot key and the key into
8
+ * that mapping.
9
+ */
10
+ class EvmHookStorageUpdate {
11
+ /**
12
+ *
13
+ * @param {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.IEvmHookStorageUpdate} hookStorageUpdate
14
+ * @returns {EvmHookStorageUpdate}
15
+ */
16
+ static _fromProtobuf(hookStorageUpdate) {
17
+ if (hookStorageUpdate.storageSlot != null) {
18
+ return EvmHookStorageSlot._fromProtobuf(hookStorageUpdate);
19
+ }
20
+
21
+ if (hookStorageUpdate.mappingEntries != null) {
22
+ return EvmHookMappingEntries._fromProtobuf(hookStorageUpdate);
23
+ }
24
+
25
+ throw new Error(
26
+ "EvmHookStorageUpdate must have either storage_slot or mapping_entries set",
27
+ );
28
+ }
29
+
30
+ /**
31
+ * @abstract
32
+ * @returns {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.IEvmHookStorageUpdate}
33
+ */
34
+ _toProtobuf() {
35
+ throw new Error(
36
+ "EvmHookStorageUpdate._toProtobuf must be implemented by a subclass",
37
+ );
38
+ }
39
+ }
40
+
41
+ /**
42
+ * A slot in the storage of a EVM hook.
43
+ */
44
+ class EvmHookStorageSlot extends EvmHookStorageUpdate {
45
+ /**
46
+ * @param {object} props
47
+ * @param {Uint8Array} [props.key]
48
+ * @param {Uint8Array} [props.value]
49
+ */
50
+ constructor(props = {}) {
51
+ super();
52
+ /**
53
+ * @private
54
+ * @type {?Uint8Array}
55
+ */
56
+ this._key = null;
57
+
58
+ /**
59
+ * @private
60
+ * @type {?Uint8Array}
61
+ */
62
+ this._value = null;
63
+
64
+ if (props.key != null) {
65
+ this.setKey(props.key);
66
+ }
67
+
68
+ if (props.value != null) {
69
+ this.setValue(props.value);
70
+ }
71
+ }
72
+
73
+ /**
74
+ *
75
+ * @param {Uint8Array} key
76
+ * @returns {this}
77
+ */
78
+ setKey(key) {
79
+ this._key = key;
80
+ return this;
81
+ }
82
+
83
+ /**
84
+ *
85
+ * @param {Uint8Array} value
86
+ * @returns {this}
87
+ */
88
+ setValue(value) {
89
+ this._value = value;
90
+ return this;
91
+ }
92
+
93
+ /**
94
+ *
95
+ * @returns {Uint8Array | null}
96
+ */
97
+ get key() {
98
+ return this._key;
99
+ }
100
+
101
+ /**
102
+ *
103
+ * @returns {Uint8Array | null}
104
+ */
105
+ get value() {
106
+ return this._value;
107
+ }
108
+
109
+ /**
110
+ *
111
+ * @param {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.IEvmHookStorageUpdate} hookStorageSlot
112
+ * @returns {EvmHookStorageSlot}
113
+ */
114
+ static _fromProtobuf(hookStorageSlot) {
115
+ if (hookStorageSlot.storageSlot != null) {
116
+ return new EvmHookStorageSlot({
117
+ key:
118
+ hookStorageSlot.storageSlot.key != null
119
+ ? hookStorageSlot.storageSlot.key
120
+ : undefined,
121
+ value:
122
+ hookStorageSlot.storageSlot.value != null
123
+ ? hookStorageSlot.storageSlot.value
124
+ : undefined,
125
+ });
126
+ }
127
+ throw new Error(
128
+ "EvmHookStorageSlot._fromProtobuf must be implemented by a subclass",
129
+ );
130
+ }
131
+
132
+ /**
133
+ * @returns {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.EvmHookStorageUpdate}
134
+ */
135
+ _toProtobuf() {
136
+ return {
137
+ storageSlot: {
138
+ key: this._key,
139
+ value: this._value,
140
+ },
141
+ };
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Specifies storage slot updates via indirection into a Solidity mapping.
147
+ * <p>
148
+ * Concretely, if the Solidity mapping is itself at slot `mapping_slot`, then
149
+ * the * storage slot for key `key` in the mapping is defined by the relationship
150
+ * `key_storage_slot = keccak256(abi.encodePacked(mapping_slot, key))`.
151
+ * <p>
152
+ * This message lets a metaprotocol be specified in terms of changes to a
153
+ * Solidity mapping's entries. If only raw slots could be updated, then a block
154
+ * stream consumer following the metaprotocol would have to invert the Keccak256
155
+ * hash to determine which mapping entry was being updated, which is not possible.
156
+ */
157
+ class EvmHookMappingEntries extends EvmHookStorageUpdate {
158
+ /**
159
+ *
160
+ * @param {object} props
161
+ * @param {Uint8Array} [props.mappingSlot]
162
+ * @param {import("./EvmHookMappingEntry.js").default[]} [props.entries]
163
+ */
164
+ constructor(props = {}) {
165
+ super();
166
+ /**
167
+ * @private
168
+ * @type {?Uint8Array}
169
+ */
170
+ this._mappingSlot = null;
171
+
172
+ /**
173
+ * @private
174
+ * @type {?import("./EvmHookMappingEntry.js").default[]}
175
+ */
176
+ this._entries = null;
177
+
178
+ if (props.mappingSlot != null) {
179
+ this.setMappingSlot(props.mappingSlot);
180
+ }
181
+
182
+ if (props.entries != null) {
183
+ this.setEntries(props.entries);
184
+ }
185
+ }
186
+
187
+ /**
188
+ *
189
+ * @param {Uint8Array} mappingSlot
190
+ * @returns {this}
191
+ */
192
+ setMappingSlot(mappingSlot) {
193
+ this._mappingSlot = mappingSlot;
194
+ return this;
195
+ }
196
+
197
+ /**
198
+ *
199
+ * @param {import("./EvmHookMappingEntry.js").default[]} entries
200
+ * @returns {this}
201
+ */
202
+ setEntries(entries) {
203
+ this._entries = entries;
204
+ return this;
205
+ }
206
+
207
+ /**
208
+ *
209
+ * @returns {Uint8Array | null}
210
+ */
211
+ get mappingSlot() {
212
+ return this._mappingSlot;
213
+ }
214
+
215
+ /**
216
+ *
217
+ * @returns {import("./EvmHookMappingEntry.js").default[] | null}
218
+ */
219
+ get entries() {
220
+ return this._entries;
221
+ }
222
+
223
+ /**
224
+ *
225
+ * @param {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.IEvmHookStorageUpdate} hookStorageUpdate
226
+ * @returns {EvmHookMappingEntries}
227
+ */
228
+ static _fromProtobuf(hookStorageUpdate) {
229
+ return new EvmHookMappingEntries({
230
+ mappingSlot:
231
+ hookStorageUpdate.mappingEntries?.mappingSlot != null
232
+ ? hookStorageUpdate.mappingEntries.mappingSlot
233
+ : undefined,
234
+ entries: hookStorageUpdate.mappingEntries?.entries?.map((entry) =>
235
+ EvmHookMappingEntry._fromProtobuf(entry),
236
+ ),
237
+ });
238
+ }
239
+
240
+ /**
241
+ *
242
+ * @returns {import("@hiero-ledger/proto").com.hedera.hapi.node.hooks.EvmHookStorageUpdate}
243
+ */
244
+ _toProtobuf() {
245
+ return {
246
+ mappingEntries: {
247
+ mappingSlot: this._mappingSlot,
248
+ entries:
249
+ this._entries != null
250
+ ? this._entries.map((entry) => entry._toProtobuf())
251
+ : null,
252
+ },
253
+ };
254
+ }
255
+ }
256
+
257
+ export { EvmHookStorageUpdate, EvmHookStorageSlot, EvmHookMappingEntries };