@recoillink/radix-sdk 0.0.0-stage → 45.0.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 (200) hide show
  1. package/LICENSE.md +193 -0
  2. package/README.md +42 -2
  3. package/dist/clients/protocol.d.ts +31 -0
  4. package/dist/clients/protocol.d.ts.map +1 -0
  5. package/dist/clients/protocol.js +95 -0
  6. package/dist/clients/protocol.js.map +1 -0
  7. package/dist/clients/provider.d.ts +60 -0
  8. package/dist/clients/provider.d.ts.map +1 -0
  9. package/dist/clients/provider.js +187 -0
  10. package/dist/clients/provider.js.map +1 -0
  11. package/dist/clients/signer.d.ts +24 -0
  12. package/dist/clients/signer.d.ts.map +1 -0
  13. package/dist/clients/signer.js +86 -0
  14. package/dist/clients/signer.js.map +1 -0
  15. package/dist/hook/hook-artifact-manager.d.ts +17 -0
  16. package/dist/hook/hook-artifact-manager.d.ts.map +1 -0
  17. package/dist/hook/hook-artifact-manager.js +60 -0
  18. package/dist/hook/hook-artifact-manager.js.map +1 -0
  19. package/dist/hook/hook-query.d.ts +22 -0
  20. package/dist/hook/hook-query.d.ts.map +1 -0
  21. package/dist/hook/hook-query.js +79 -0
  22. package/dist/hook/hook-query.js.map +1 -0
  23. package/dist/hook/hook-tx.d.ts +21 -0
  24. package/dist/hook/hook-tx.d.ts.map +1 -0
  25. package/dist/hook/hook-tx.js +26 -0
  26. package/dist/hook/hook-tx.js.map +1 -0
  27. package/dist/hook/igp-hook.d.ts +24 -0
  28. package/dist/hook/igp-hook.d.ts.map +1 -0
  29. package/dist/hook/igp-hook.js +148 -0
  30. package/dist/hook/igp-hook.js.map +1 -0
  31. package/dist/hook/merkle-tree-hook.d.ts +24 -0
  32. package/dist/hook/merkle-tree-hook.d.ts.map +1 -0
  33. package/dist/hook/merkle-tree-hook.js +51 -0
  34. package/dist/hook/merkle-tree-hook.js.map +1 -0
  35. package/dist/index.d.ts +13 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +12 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/ism/ism-artifact-manager.d.ts +14 -0
  40. package/dist/ism/ism-artifact-manager.d.ts.map +1 -0
  41. package/dist/ism/ism-artifact-manager.js +67 -0
  42. package/dist/ism/ism-artifact-manager.js.map +1 -0
  43. package/dist/ism/ism-query.d.ts +23 -0
  44. package/dist/ism/ism-query.d.ts.map +1 -0
  45. package/dist/ism/ism-query.js +84 -0
  46. package/dist/ism/ism-query.js.map +1 -0
  47. package/dist/ism/ism-tx.d.ts +31 -0
  48. package/dist/ism/ism-tx.d.ts.map +1 -0
  49. package/dist/ism/ism-tx.js +43 -0
  50. package/dist/ism/ism-tx.js.map +1 -0
  51. package/dist/ism/multisig-ism.d.ts +38 -0
  52. package/dist/ism/multisig-ism.d.ts.map +1 -0
  53. package/dist/ism/multisig-ism.js +107 -0
  54. package/dist/ism/multisig-ism.js.map +1 -0
  55. package/dist/ism/routing-ism.d.ts +23 -0
  56. package/dist/ism/routing-ism.d.ts.map +1 -0
  57. package/dist/ism/routing-ism.js +129 -0
  58. package/dist/ism/routing-ism.js.map +1 -0
  59. package/dist/ism/test-ism.d.ts +23 -0
  60. package/dist/ism/test-ism.d.ts.map +1 -0
  61. package/dist/ism/test-ism.js +49 -0
  62. package/dist/ism/test-ism.js.map +1 -0
  63. package/dist/mailbox/mailbox-artifact-manager.d.ts +15 -0
  64. package/dist/mailbox/mailbox-artifact-manager.d.ts.map +1 -0
  65. package/dist/mailbox/mailbox-artifact-manager.js +29 -0
  66. package/dist/mailbox/mailbox-artifact-manager.js.map +1 -0
  67. package/dist/mailbox/mailbox-query.d.ts +12 -0
  68. package/dist/mailbox/mailbox-query.d.ts.map +1 -0
  69. package/dist/mailbox/mailbox-query.js +72 -0
  70. package/dist/mailbox/mailbox-query.js.map +1 -0
  71. package/dist/mailbox/mailbox-query.test.d.ts +2 -0
  72. package/dist/mailbox/mailbox-query.test.d.ts.map +1 -0
  73. package/dist/mailbox/mailbox-query.test.js +65 -0
  74. package/dist/mailbox/mailbox-query.test.js.map +1 -0
  75. package/dist/mailbox/mailbox-tx.d.ts +21 -0
  76. package/dist/mailbox/mailbox-tx.d.ts.map +1 -0
  77. package/dist/mailbox/mailbox-tx.js +27 -0
  78. package/dist/mailbox/mailbox-tx.js.map +1 -0
  79. package/dist/mailbox/mailbox.d.ts +24 -0
  80. package/dist/mailbox/mailbox.d.ts.map +1 -0
  81. package/dist/mailbox/mailbox.js +171 -0
  82. package/dist/mailbox/mailbox.js.map +1 -0
  83. package/dist/runtime.d.ts +7 -0
  84. package/dist/runtime.d.ts.map +1 -0
  85. package/dist/runtime.js +6 -0
  86. package/dist/runtime.js.map +1 -0
  87. package/dist/testing/constants.d.ts +61 -0
  88. package/dist/testing/constants.d.ts.map +1 -0
  89. package/dist/testing/constants.js +65 -0
  90. package/dist/testing/constants.js.map +1 -0
  91. package/dist/testing/index.d.ts +8 -0
  92. package/dist/testing/index.d.ts.map +1 -0
  93. package/dist/testing/index.js +11 -0
  94. package/dist/testing/index.js.map +1 -0
  95. package/dist/testing/node.d.ts +13 -0
  96. package/dist/testing/node.d.ts.map +1 -0
  97. package/dist/testing/node.js +42 -0
  98. package/dist/testing/node.js.map +1 -0
  99. package/dist/testing/setup.d.ts +20 -0
  100. package/dist/testing/setup.d.ts.map +1 -0
  101. package/dist/testing/setup.js +57 -0
  102. package/dist/testing/setup.js.map +1 -0
  103. package/dist/tests/e2e-test.setup.d.ts +3 -0
  104. package/dist/tests/e2e-test.setup.d.ts.map +1 -0
  105. package/dist/tests/e2e-test.setup.js +32 -0
  106. package/dist/tests/e2e-test.setup.js.map +1 -0
  107. package/dist/tests/hook.e2e-test.d.ts +2 -0
  108. package/dist/tests/hook.e2e-test.d.ts.map +1 -0
  109. package/dist/tests/hook.e2e-test.js +374 -0
  110. package/dist/tests/hook.e2e-test.js.map +1 -0
  111. package/dist/tests/ism.e2e-test.d.ts +2 -0
  112. package/dist/tests/ism.e2e-test.d.ts.map +1 -0
  113. package/dist/tests/ism.e2e-test.js +256 -0
  114. package/dist/tests/ism.e2e-test.js.map +1 -0
  115. package/dist/tests/mailbox.e2e-test.d.ts +2 -0
  116. package/dist/tests/mailbox.e2e-test.d.ts.map +1 -0
  117. package/dist/tests/mailbox.e2e-test.js +250 -0
  118. package/dist/tests/mailbox.e2e-test.js.map +1 -0
  119. package/dist/tests/validator-announce.e2e-test.d.ts +2 -0
  120. package/dist/tests/validator-announce.e2e-test.d.ts.map +1 -0
  121. package/dist/tests/validator-announce.e2e-test.js +107 -0
  122. package/dist/tests/validator-announce.e2e-test.js.map +1 -0
  123. package/dist/tests/warp.e2e-test.d.ts +2 -0
  124. package/dist/tests/warp.e2e-test.d.ts.map +1 -0
  125. package/dist/tests/warp.e2e-test.js +597 -0
  126. package/dist/tests/warp.e2e-test.js.map +1 -0
  127. package/dist/utils/base-query.d.ts +188 -0
  128. package/dist/utils/base-query.d.ts.map +1 -0
  129. package/dist/utils/base-query.js +209 -0
  130. package/dist/utils/base-query.js.map +1 -0
  131. package/dist/utils/base.d.ts +67 -0
  132. package/dist/utils/base.d.ts.map +1 -0
  133. package/dist/utils/base.js +355 -0
  134. package/dist/utils/base.js.map +1 -0
  135. package/dist/utils/constants.d.ts +20 -0
  136. package/dist/utils/constants.d.ts.map +1 -0
  137. package/dist/utils/constants.js +20 -0
  138. package/dist/utils/constants.js.map +1 -0
  139. package/dist/utils/signer.d.ts +17 -0
  140. package/dist/utils/signer.d.ts.map +1 -0
  141. package/dist/utils/signer.js +60 -0
  142. package/dist/utils/signer.js.map +1 -0
  143. package/dist/utils/types.d.ts +141 -0
  144. package/dist/utils/types.d.ts.map +1 -0
  145. package/dist/utils/types.js +39 -0
  146. package/dist/utils/types.js.map +1 -0
  147. package/dist/utils/utils.d.ts +8 -0
  148. package/dist/utils/utils.d.ts.map +1 -0
  149. package/dist/utils/utils.js +47 -0
  150. package/dist/utils/utils.js.map +1 -0
  151. package/dist/utils/utils.test.d.ts +2 -0
  152. package/dist/utils/utils.test.d.ts.map +1 -0
  153. package/dist/utils/utils.test.js +27 -0
  154. package/dist/utils/utils.test.js.map +1 -0
  155. package/dist/validator-announce/validator-announce-artifact-manager.d.ts +14 -0
  156. package/dist/validator-announce/validator-announce-artifact-manager.d.ts.map +1 -0
  157. package/dist/validator-announce/validator-announce-artifact-manager.js +21 -0
  158. package/dist/validator-announce/validator-announce-artifact-manager.js.map +1 -0
  159. package/dist/validator-announce/validator-announce-query.d.ts +6 -0
  160. package/dist/validator-announce/validator-announce-query.d.ts.map +1 -0
  161. package/dist/validator-announce/validator-announce-query.js +10 -0
  162. package/dist/validator-announce/validator-announce-query.js.map +1 -0
  163. package/dist/validator-announce/validator-announce-tx.d.ts +4 -0
  164. package/dist/validator-announce/validator-announce-tx.d.ts.map +1 -0
  165. package/dist/validator-announce/validator-announce-tx.js +6 -0
  166. package/dist/validator-announce/validator-announce-tx.js.map +1 -0
  167. package/dist/validator-announce/validator-announce.d.ts +23 -0
  168. package/dist/validator-announce/validator-announce.d.ts.map +1 -0
  169. package/dist/validator-announce/validator-announce.js +52 -0
  170. package/dist/validator-announce/validator-announce.js.map +1 -0
  171. package/dist/warp/collateral-token.d.ts +23 -0
  172. package/dist/warp/collateral-token.d.ts.map +1 -0
  173. package/dist/warp/collateral-token.js +130 -0
  174. package/dist/warp/collateral-token.js.map +1 -0
  175. package/dist/warp/populate.d.ts +71 -0
  176. package/dist/warp/populate.d.ts.map +1 -0
  177. package/dist/warp/populate.js +110 -0
  178. package/dist/warp/populate.js.map +1 -0
  179. package/dist/warp/query.d.ts +44 -0
  180. package/dist/warp/query.d.ts.map +1 -0
  181. package/dist/warp/query.js +163 -0
  182. package/dist/warp/query.js.map +1 -0
  183. package/dist/warp/synthetic-token.d.ts +23 -0
  184. package/dist/warp/synthetic-token.d.ts.map +1 -0
  185. package/dist/warp/synthetic-token.js +131 -0
  186. package/dist/warp/synthetic-token.js.map +1 -0
  187. package/dist/warp/warp-artifact-manager.d.ts +15 -0
  188. package/dist/warp/warp-artifact-manager.d.ts.map +1 -0
  189. package/dist/warp/warp-artifact-manager.js +49 -0
  190. package/dist/warp/warp-artifact-manager.js.map +1 -0
  191. package/dist/warp/warp-query.d.ts +9 -0
  192. package/dist/warp/warp-query.d.ts.map +1 -0
  193. package/dist/warp/warp-query.js +130 -0
  194. package/dist/warp/warp-query.js.map +1 -0
  195. package/dist/warp/warp-tx.d.ts +48 -0
  196. package/dist/warp/warp-tx.d.ts.map +1 -0
  197. package/dist/warp/warp-tx.js +125 -0
  198. package/dist/warp/warp-tx.js.map +1 -0
  199. package/docker-compose.yml +139 -0
  200. package/package.json +74 -3
@@ -0,0 +1,188 @@
1
+ import { GatewayApiClient, ScryptoSborValue, StateEntityDetailsResponseItemDetails } from '@radixdlt/babylon-gateway-api-sdk';
2
+ import { EntityDetails, EntityField, RadixElement } from './types.js';
3
+ type RadixComponentDetails = Extract<StateEntityDetailsResponseItemDetails, {
4
+ type: 'Component';
5
+ }>;
6
+ /**
7
+ * Fetches and validates Radix component details from the gateway.
8
+ *
9
+ * @param gateway - The Radix Gateway API client
10
+ * @param entityAddress - The on-chain address of the component
11
+ * @param componentName - Human-readable name for error messages (e.g., "mailbox", "ISM", "hook")
12
+ *
13
+ * @throws {Error} If the entity is not a Radix component
14
+ */
15
+ export declare function getRadixComponentDetails(gateway: Readonly<GatewayApiClient>, entityAddress: string, componentName: string): Promise<RadixComponentDetails>;
16
+ /**
17
+ * Fetches all keys from a Radix key-value store.
18
+ *
19
+ * @param gateway - The Radix Gateway API client
20
+ * @param keyValueStoreAddress - The on-chain address of the key-value store
21
+ * @returns Array of all keys in the key-value store
22
+ */
23
+ export declare function getKeysFromKvStore(gateway: Readonly<GatewayApiClient>, keyValueStoreAddress: string): Promise<ScryptoSborValue[]>;
24
+ /**
25
+ * Extracts ownership information from a Radix component's details.
26
+ *
27
+ * @param entityAddress - The on-chain address of the component (used for error messages)
28
+ * @param entityDetails - The component details containing role assignment information
29
+ * @returns The ownership information including the access rule and proof requirements
30
+ *
31
+ * @throws {Error} If ownership information is not defined in the component details
32
+ */
33
+ export declare function getComponentOwnershipInfo(entityAddress: string, entityDetails: RadixComponentDetails): EntityDetails['role_assignments']['owner'];
34
+ /**
35
+ * Extracts the owner address of a Radix component.
36
+ *
37
+ * Radix components use role-based access control where ownership is represented
38
+ * by holding a specific resource. This function finds the holder of that resource.
39
+ *
40
+ * @param gateway - The Radix Gateway API client
41
+ * @param entityAddress - The on-chain address of the component (used for error messages)
42
+ * @param entityDetails - The component details containing ownership information
43
+ * @returns The address of the component owner
44
+ *
45
+ * @throws {Error} If ownership info is missing or if there are multiple resource holders
46
+ */
47
+ export declare function getComponentOwner(gateway: Readonly<GatewayApiClient>, entityAddress: string, entityDetails: RadixComponentDetails): Promise<string>;
48
+ /**
49
+ * Extracts the state object from Radix component details.
50
+ *
51
+ * @param entityAddress - The on-chain address of the component (used for error messages)
52
+ * @param entityDetails - The component details containing the state
53
+ * @returns The component state containing
54
+ *
55
+ * @throws {Error} If the state is not defined in the component details
56
+ */
57
+ export declare function getComponentState(entityAddress: string, entityDetails: RadixComponentDetails): EntityDetails['state'];
58
+ export declare function getFieldPropertyFromEntityState<TKey extends keyof EntityField, T>(fieldName: string, entityAddress: string, entityState: EntityDetails['state'], property: TKey, formatter?: (value: NonNullable<EntityField[TKey]>) => T): T | NonNullable<EntityField[TKey]>;
59
+ /**
60
+ * Tries to extracts a field value from a Radix component's entity state.
61
+ *
62
+ * Handles both regular fields and Radix Option enums. For Option enums, it automatically
63
+ * extracts the value from the Some variant.
64
+ *
65
+ * @param fieldName - The name of the field to extract
66
+ * @param entityState - The component state containing the fields
67
+ * @returns The field value as a string or undefined if it was not found
68
+ *
69
+ *
70
+ * @overload
71
+ * @param fieldName - The name of the field to extract
72
+ * @param entityState - The component state containing the fields
73
+ * @param formatter - Function to transform the string value into a different type
74
+ * @returns The formatted field value or undefined if it was not found
75
+ */
76
+ export declare function tryGetFieldValueFromEntityState(fieldName: string, entityState: EntityDetails['state']): string | undefined;
77
+ export declare function tryGetFieldValueFromEntityState<T>(fieldName: string, entityState: EntityDetails['state'], formatter: (value: string) => T): T | undefined;
78
+ /**
79
+ * Extracts a field value from a Radix component's entity state.
80
+ *
81
+ * Handles both regular fields and Radix Option enums. For Option enums, it automatically
82
+ * extracts the value from the Some variant.
83
+ *
84
+ * @param fieldName - The name of the field to extract
85
+ * @param entityAddress - The on-chain address of the component (used for error messages)
86
+ * @param entityState - The component state containing the fields
87
+ * @returns The field value as a string
88
+ *
89
+ * @throws {Error} If the field is not found in the state
90
+ *
91
+ * @overload
92
+ * @param fieldName - The name of the field to extract
93
+ * @param entityAddress - The on-chain address of the component (used for error messages)
94
+ * @param entityState - The component state containing the fields
95
+ * @param formatter - Function to transform the string value into a different type
96
+ * @returns The formatted field value
97
+ */
98
+ export declare function getFieldValueFromEntityState(fieldName: string, entityAddress: string, entityState: EntityDetails['state']): string;
99
+ export declare function getFieldValueFromEntityState<T>(fieldName: string, entityAddress: string, entityState: EntityDetails['state'], formatter: (value: string) => T): T;
100
+ /**
101
+ * Tries to extract a hex field value from a Radix component's entity state.
102
+ *
103
+ * Similar to tryGetFieldValueFromEntityState but extracts the hex representation
104
+ * instead of the regular value. Handles both regular fields and Radix Option enums.
105
+ *
106
+ * @param fieldName - The name of the field to extract
107
+ * @param entityState - The component state containing the fields
108
+ * @returns The field hex value as a string or undefined if it was not found
109
+ *
110
+ * @overload
111
+ * @param fieldName - The name of the field to extract
112
+ * @param entityState - The component state containing the fields
113
+ * @param formatter - Function to transform the hex string value into a different type
114
+ * @returns The formatted field hex value or undefined if it was not found
115
+ */
116
+ export declare function tryGetFieldHexValueFromEntityState(fieldName: string, entityState: EntityDetails['state']): string | undefined;
117
+ export declare function tryGetFieldHexValueFromEntityState<T>(fieldName: string, entityState: EntityDetails['state'], formatter: (value: string) => T): T | undefined;
118
+ /**
119
+ * Extracts a hex field value from a Radix component's entity state.
120
+ *
121
+ * Similar to getFieldValueFromEntityState but extracts the hex representation
122
+ * instead of the regular value. Handles both regular fields and Radix Option enums.
123
+ *
124
+ * @param fieldName - The name of the field to extract
125
+ * @param entityAddress - The on-chain address of the component (used for error messages)
126
+ * @param entityState - The component state containing the fields
127
+ * @returns The field hex value as a string
128
+ *
129
+ * @throws {Error} If the field is not found in the state
130
+ *
131
+ * @overload
132
+ * @param fieldName - The name of the field to extract
133
+ * @param entityAddress - The on-chain address of the component (used for error messages)
134
+ * @param entityState - The component state containing the fields
135
+ * @param formatter - Function to transform the hex string value into a different type
136
+ * @returns The formatted field hex value
137
+ */
138
+ export declare function getFieldHexValueFromEntityState(fieldName: string, entityAddress: string, entityState: EntityDetails['state']): string;
139
+ export declare function getFieldHexValueFromEntityState<T>(fieldName: string, entityAddress: string, entityState: EntityDetails['state'], formatter: (value: string) => T): T;
140
+ /**
141
+ * Extracts an optional field value from a Radix component's entity state.
142
+ *
143
+ * Similar to getFieldValueFromEntityState, but returns undefined instead of throwing
144
+ * if the field is not found or if it's an Option::None variant.
145
+ *
146
+ * @param fieldName - The name of the field to extract
147
+ * @param entityState - The component state containing the fields
148
+ * @returns The field value as a string, or undefined if not found/None
149
+ */
150
+ export declare function getOptionalFieldValueFromEntityState(fieldName: string, entityState: EntityDetails['state']): string | undefined;
151
+ export declare function getOptionalFieldValueFromEntityState<T>(fieldName: string, entityState: EntityDetails['state'], formatter: (value: string) => T): T | undefined;
152
+ /**
153
+ * Extracts field elements (array values) from a Radix component's entity state.
154
+ *
155
+ * Used for fields that contain arrays of elements, such as validator lists or
156
+ * multi-value configurations.
157
+ *
158
+ * @param fieldName - The name of the field to extract
159
+ * @param entityAddress - The on-chain address of the component (used for error messages)
160
+ * @param entityState - The component state containing the fields
161
+ * @returns Array of RadixElement objects
162
+ *
163
+ * @throws {Error} If the field is not found in the state
164
+ *
165
+ * @overload
166
+ * @param fieldName - The name of the field to extract
167
+ * @param entityAddress - The on-chain address of the component (used for error messages)
168
+ * @param entityState - The component state containing the fields
169
+ * @param formatter - Function to transform the RadixElement array into a different type
170
+ * @returns The formatted element array
171
+ */
172
+ export declare function getFieldElementsFromEntityState(fieldName: string, entityAddress: string, entityState: EntityDetails['state']): RadixElement[];
173
+ export declare function getFieldElementsFromEntityState<T>(fieldName: string, entityAddress: string, entityState: EntityDetails['state'], formatter: (value: RadixElement[]) => T[]): T[];
174
+ /**
175
+ * Extracts the resource address from a Radix component's entity state.
176
+ *
177
+ * Searches the component state fields for a ResourceAddress type and returns its value.
178
+ * Used for identifying token resources associated with warp route components.
179
+ *
180
+ * @param entityAddress - The on-chain address of the component (used for error messages)
181
+ * @param entityState - The component state containing the fields
182
+ * @returns The resource address as a string
183
+ *
184
+ * @throws {Error} If no ResourceAddress field is found in the component state
185
+ */
186
+ export declare function getResourceAddress(entityAddress: string, entityState: EntityDetails['state']): string;
187
+ export {};
188
+ //# sourceMappingURL=base-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-query.d.ts","sourceRoot":"","sources":["../../src/utils/base-query.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,gBAAgB,EAChB,qCAAqC,EACtC,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEtE,KAAK,qBAAqB,GAAG,OAAO,CAClC,qCAAqC,EACrC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CACtB,CAAC;AAuBF;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EACnC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,qBAAqB,CAAC,CAUhC;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EACnC,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAkC7B;AAED;;;;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KAAK,EAAE,MAAM,KAAK,CAAC,GAC9B,CAAC,GAAG,SAAS,CAAC;AA0BjB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,GAClC,YAAY,EAAE,CAAC;AAClB,wBAAgB,+BAA+B,CAAC,CAAC,EAC/C,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,EACnC,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,GACxC,CAAC,EAAE,CAAC;AAiBP;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,GAClC,MAAM,CAWR"}
@@ -0,0 +1,209 @@
1
+ import { assert, isNullish, sleep } from '@recoillink/utils';
2
+ function isComponentOwner(value) {
3
+ if (typeof value !== 'object' || value === null)
4
+ return false;
5
+ const rule = Reflect.get(value, 'rule');
6
+ if (typeof rule !== 'object' || rule === null)
7
+ return false;
8
+ const accessRule = Reflect.get(rule, 'access_rule');
9
+ if (typeof accessRule !== 'object' || accessRule === null)
10
+ return false;
11
+ const proofRule = Reflect.get(accessRule, 'proof_rule');
12
+ if (typeof proofRule !== 'object' || proofRule === null)
13
+ return false;
14
+ const requirement = Reflect.get(proofRule, 'requirement');
15
+ if (typeof requirement !== 'object' || requirement === null)
16
+ return false;
17
+ const resource = Reflect.get(requirement, 'resource');
18
+ return typeof resource === 'string';
19
+ }
20
+ function isComponentState(value) {
21
+ if (typeof value !== 'object' || value === null)
22
+ return false;
23
+ return Array.isArray(Reflect.get(value, 'fields'));
24
+ }
25
+ /**
26
+ * Fetches and validates Radix component details from the gateway.
27
+ *
28
+ * @param gateway - The Radix Gateway API client
29
+ * @param entityAddress - The on-chain address of the component
30
+ * @param componentName - Human-readable name for error messages (e.g., "mailbox", "ISM", "hook")
31
+ *
32
+ * @throws {Error} If the entity is not a Radix component
33
+ */
34
+ export async function getRadixComponentDetails(gateway, entityAddress, componentName) {
35
+ const { details: componentDetails } = await gateway.state.getEntityDetailsVaultAggregated(entityAddress);
36
+ assert(componentDetails?.type === 'Component', `Expected on chain details to be defined for radix ${componentName} at address ${entityAddress}`);
37
+ return componentDetails;
38
+ }
39
+ /**
40
+ * Fetches all keys from a Radix key-value store.
41
+ *
42
+ * @param gateway - The Radix Gateway API client
43
+ * @param keyValueStoreAddress - The on-chain address of the key-value store
44
+ * @returns Array of all keys in the key-value store
45
+ */
46
+ export async function getKeysFromKvStore(gateway, keyValueStoreAddress) {
47
+ let cursor = null;
48
+ let at_ledger_state = null;
49
+ const keys = [];
50
+ const requestLimit = 50;
51
+ for (let i = 0; i < requestLimit; i++) {
52
+ const { items, next_cursor, ledger_state } = await gateway.state.innerClient.keyValueStoreKeys({
53
+ stateKeyValueStoreKeysRequest: {
54
+ key_value_store_address: keyValueStoreAddress,
55
+ at_ledger_state,
56
+ cursor,
57
+ },
58
+ });
59
+ keys.push(...items.map((i) => i.key));
60
+ if (!next_cursor) {
61
+ return keys;
62
+ }
63
+ cursor = next_cursor;
64
+ // Set the ledger version so that subsequent requests use the same
65
+ // version as the first one
66
+ if (!at_ledger_state) {
67
+ at_ledger_state = { state_version: ledger_state.state_version };
68
+ }
69
+ await sleep(50);
70
+ }
71
+ throw new Error(`Failed to fetch keys from key value store ${keyValueStoreAddress}, reached request limit of ${requestLimit}`);
72
+ }
73
+ /**
74
+ * Extracts ownership information from a Radix component's details.
75
+ *
76
+ * @param entityAddress - The on-chain address of the component (used for error messages)
77
+ * @param entityDetails - The component details containing role assignment information
78
+ * @returns The ownership information including the access rule and proof requirements
79
+ *
80
+ * @throws {Error} If ownership information is not defined in the component details
81
+ */
82
+ export function getComponentOwnershipInfo(entityAddress, entityDetails) {
83
+ const ownershipInfo = entityDetails?.role_assignments?.owner;
84
+ assert(isComponentOwner(ownershipInfo), `Expected ownership info to be defined for radix component at address ${entityAddress}`);
85
+ return ownershipInfo;
86
+ }
87
+ /**
88
+ * Extracts the owner address of a Radix component.
89
+ *
90
+ * Radix components use role-based access control where ownership is represented
91
+ * by holding a specific resource. This function finds the holder of that resource.
92
+ *
93
+ * @param gateway - The Radix Gateway API client
94
+ * @param entityAddress - The on-chain address of the component (used for error messages)
95
+ * @param entityDetails - The component details containing ownership information
96
+ * @returns The address of the component owner
97
+ *
98
+ * @throws {Error} If ownership info is missing or if there are multiple resource holders
99
+ */
100
+ export async function getComponentOwner(gateway, entityAddress, entityDetails) {
101
+ const ownershipInfo = getComponentOwnershipInfo(entityAddress, entityDetails);
102
+ const ownerResource = ownershipInfo.rule.access_rule.proof_rule.requirement.resource;
103
+ const { items } = await gateway.extensions.getResourceHolders(ownerResource);
104
+ const resourceHolders = [
105
+ ...new Set(items.map((item) => item.holder_address)),
106
+ ];
107
+ assert(resourceHolders.length === 1, `Expected holders of resource ${ownerResource} to be one, found ${resourceHolders.length} holders instead ${resourceHolders.join(', ')}`);
108
+ const [resourceHolder] = resourceHolders;
109
+ assert(resourceHolder, `Expected a holder of resource ${ownerResource}`);
110
+ return resourceHolder;
111
+ }
112
+ /**
113
+ * Extracts the state object from Radix component details.
114
+ *
115
+ * @param entityAddress - The on-chain address of the component (used for error messages)
116
+ * @param entityDetails - The component details containing the state
117
+ * @returns The component state containing
118
+ *
119
+ * @throws {Error} If the state is not defined in the component details
120
+ */
121
+ export function getComponentState(entityAddress, entityDetails) {
122
+ assert(isComponentState(entityDetails.state), `Expected state to be defined for component at address ${entityAddress}`);
123
+ return entityDetails.state;
124
+ }
125
+ /**
126
+ * Internal helper to extract a field property from a Radix component's entity state.
127
+ *
128
+ * Handles both regular fields and Radix Option enums. For Option enums, it automatically
129
+ * extracts the property from the Some variant.
130
+ *
131
+ * @param fieldName - The name of the field to extract
132
+ * @param entityState - The component state containing the fields
133
+ * @param property - The property to extract ('value' or 'hex')
134
+ * @param formatter - Optional function to transform the string value into a different type
135
+ * @returns The field property value or undefined if not found
136
+ */
137
+ function tryGetFieldPropertyFromEntityState(fieldName, entityState, property, formatter) {
138
+ const [result] = entityState.fields
139
+ .filter((f) => f.field_name === fieldName)
140
+ .map((f) =>
141
+ // If the current value is an Option we need to extract
142
+ // its property otherwise we can use the property directly
143
+ f.kind === 'Enum' && f.type_name === 'Option'
144
+ ? f.fields?.at(0)?.[property]
145
+ : f[property]);
146
+ return !isNullish(result) && formatter ? formatter(result) : result;
147
+ }
148
+ export function getFieldPropertyFromEntityState(fieldName, entityAddress, entityState, property, formatter) {
149
+ const result = tryGetFieldPropertyFromEntityState(fieldName, entityState, property, formatter);
150
+ assert(!isNullish(result), `Expected ${fieldName} field to be defined on radix component at ${entityAddress}`);
151
+ return result;
152
+ }
153
+ export function tryGetFieldValueFromEntityState(fieldName, entityState, formatter) {
154
+ return tryGetFieldPropertyFromEntityState(fieldName, entityState, 'value', formatter);
155
+ }
156
+ export function getFieldValueFromEntityState(fieldName, entityAddress, entityState, formatter) {
157
+ const value = formatter
158
+ ? tryGetFieldValueFromEntityState(fieldName, entityState, formatter)
159
+ : tryGetFieldValueFromEntityState(fieldName, entityState);
160
+ assert(!isNullish(value), `Expected ${fieldName} field to be defined on radix component at ${entityAddress}`);
161
+ return value;
162
+ }
163
+ export function tryGetFieldHexValueFromEntityState(fieldName, entityState, formatter) {
164
+ return tryGetFieldPropertyFromEntityState(fieldName, entityState, 'hex', formatter);
165
+ }
166
+ export function getFieldHexValueFromEntityState(fieldName, entityAddress, entityState, formatter) {
167
+ const hexValue = formatter
168
+ ? tryGetFieldHexValueFromEntityState(fieldName, entityState, formatter)
169
+ : tryGetFieldHexValueFromEntityState(fieldName, entityState);
170
+ assert(!isNullish(hexValue), `Expected ${fieldName} hex field to be defined on radix component at ${entityAddress}`);
171
+ return hexValue;
172
+ }
173
+ export function getOptionalFieldValueFromEntityState(fieldName, entityState, formatter) {
174
+ const field = entityState.fields.find((f) => f.field_name === fieldName);
175
+ if (!field ||
176
+ (field.type_name === 'Option' && field.variant_name === 'None')) {
177
+ return undefined;
178
+ }
179
+ const value = field.kind === 'Enum' && field.type_name === 'Option'
180
+ ? field.fields?.at(0)?.value
181
+ : field.value;
182
+ if (isNullish(value)) {
183
+ return undefined;
184
+ }
185
+ return formatter ? formatter(value) : value;
186
+ }
187
+ export function getFieldElementsFromEntityState(fieldName, entityAddress, entityState, formatter) {
188
+ const value = entityState.fields.find((f) => f.field_name === fieldName)?.elements;
189
+ assert(!isNullish(value), `Expected ${fieldName} field to be defined on radix component at ${entityAddress}`);
190
+ return formatter ? formatter(value) : value;
191
+ }
192
+ /**
193
+ * Extracts the resource address from a Radix component's entity state.
194
+ *
195
+ * Searches the component state fields for a ResourceAddress type and returns its value.
196
+ * Used for identifying token resources associated with warp route components.
197
+ *
198
+ * @param entityAddress - The on-chain address of the component (used for error messages)
199
+ * @param entityState - The component state containing the fields
200
+ * @returns The resource address as a string
201
+ *
202
+ * @throws {Error} If no ResourceAddress field is found in the component state
203
+ */
204
+ export function getResourceAddress(entityAddress, entityState) {
205
+ const resourceAddress = entityState.fields.find((t) => t.type_name === 'ResourceAddress')?.value;
206
+ assert(typeof resourceAddress === 'string', `Expected a resource address to be defined on the state of the component at address ${entityAddress}`);
207
+ return resourceAddress;
208
+ }
209
+ //# sourceMappingURL=base-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-query.js","sourceRoot":"","sources":["../../src/utils/base-query.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAS7D,SAAS,gBAAgB,CACvB,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,M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AQ;QACnD,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK;QAC5B,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;IAElB,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC;AAiCD,MAAM,UAAU,+BAA+B,CAC7C,SAAiB,EACjB,aAAqB,EACrB,WAAmC,EACnC,SAA0C;IAE1C,MAAM,KAAK,GACT,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,SAAS,CAAC,EAAE,QAAQ,CAAC;IACvE,MAAM,CACJ,CAAC,SAAS,CAAC,KAAK,CAAC,EACjB,YAAY,SAAS,8CAA8C,aAAa,EAAE,CACnF,CAAC;IAEF,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,aAAqB,EACrB,WAAmC;IAEnC,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAC7C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,iBAAiB,CACzC,EAAE,KAAK,CAAC;IAET,MAAM,CACJ,OAAO,eAAe,KAAK,QAAQ,EACnC,sFAAsF,aAAa,EAAE,CACtG,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { GatewayApiClient } from '@radixdlt/babylon-gateway-api-sdk';
2
+ import { TransactionManifest, Value } from '@radixdlt/radix-engine-toolkit';
3
+ import { RadixSDKReceipt } from './types.js';
4
+ export declare class RadixBase {
5
+ protected networkId: number;
6
+ protected gateway: GatewayApiClient;
7
+ protected gasMultiplier: number;
8
+ protected hyperlanePackageDefAddress: string;
9
+ constructor(networkId: number, gateway: GatewayApiClient, gasMultiplier: number, hyperlanePackageDefAddress: string);
10
+ getNetworkId(): number;
11
+ getXrdAddress(): Promise<string>;
12
+ getHyperlanePackageDefAddress(): string;
13
+ isGatewayHealthy(): Promise<boolean>;
14
+ createXrdFaucetTransactionManifest(toAccount: string, amount?: number): Promise<TransactionManifest>;
15
+ getStateVersion(): Promise<number>;
16
+ estimateTransactionFee({ transactionManifest, }: {
17
+ transactionManifest: TransactionManifest | string;
18
+ }): Promise<{
19
+ gasUnits: bigint;
20
+ gasPrice: number;
21
+ fee: bigint;
22
+ }>;
23
+ getMetadata({ resource }: {
24
+ resource: string;
25
+ }): Promise<{
26
+ name: string;
27
+ symbol: string;
28
+ description: string;
29
+ decimals: number;
30
+ }>;
31
+ getXrdMetadata(): Promise<{
32
+ name: string;
33
+ symbol: string;
34
+ description: string;
35
+ decimals: number;
36
+ }>;
37
+ getBalance({ address, resource, }: {
38
+ address: string;
39
+ resource: string;
40
+ }): Promise<bigint>;
41
+ getXrdBalance({ address, }: {
42
+ address: string;
43
+ }): Promise<bigint>;
44
+ getTotalSupply({ resource, }: {
45
+ resource: string;
46
+ }): Promise<bigint>;
47
+ getXrdTotalSupply(): Promise<bigint>;
48
+ pollForCommit(intentHashTransactionId: string): Promise<RadixSDKReceipt>;
49
+ getNewComponent(receipt: RadixSDKReceipt): Promise<string>;
50
+ createCallFunctionManifest(from_address: string, package_address: string | number, blueprint_name: string, function_name: string, args: Value[]): Promise<TransactionManifest>;
51
+ createCallMethodManifestWithOwner(from_address: string, contract_address: string, method_name: string, args: Value[]): Promise<TransactionManifest>;
52
+ transfer({ from_address, to_address, resource_address, amount, }: {
53
+ from_address: string;
54
+ to_address: string;
55
+ resource_address: string;
56
+ /**
57
+ * The amount MUST be in decimal representation
58
+ */
59
+ amount: string;
60
+ }): Promise<TransactionManifest>;
61
+ createPublishPackageManifest(params: {
62
+ from_address: string;
63
+ code: Uint8Array;
64
+ packageDefinition: Uint8Array;
65
+ }): Promise<TransactionManifest>;
66
+ }
67
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/utils/base.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAEjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAKL,mBAAmB,EACnB,KAAK,EAON,MAAM,gCAAgC,CAAC;AAUxC,OAAO,EAA+B,eAAe,EAAE,MAAM,YAAY,CAAC;AAG1E,qBAAa,SAAS;IACpB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACpC,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC;IAChC,SAAS,CAAC,0BAA0B,EAAE,MAAM,CAAC;IAE7C,YACE,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,MAAM,EACrB,0BAA0B,EAAE,MAAM,EAMnC;IAEM,YAAY,IAAI,MAAM,CAE5B;IAEY,aAAa,oBAKzB;IAEM,6BAA6B,IAAI,MAAM,CAE7C;IAEY,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAGhD;IAIY,kCAAkC,CAC7C,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAc,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAqB9B;IAEY,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAG9C;IAEY,sBAAsB,CAAC,EAClC,mBAAmB,GACpB,EAAE;QACD,mBAAmB,EAAE,mBAAmB,GAAG,MAAM,CAAC;KACnD,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CA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