@openzeppelin/adapter-stellar 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +272 -0
  2. package/dist/config.cjs +21 -0
  3. package/dist/config.cjs.map +1 -0
  4. package/dist/config.d.cts +8 -0
  5. package/dist/config.d.cts.map +1 -0
  6. package/dist/config.d.mts +8 -0
  7. package/dist/config.d.mts.map +1 -0
  8. package/dist/config.mjs +20 -0
  9. package/dist/config.mjs.map +1 -0
  10. package/dist/index.cjs +7564 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +261 -0
  13. package/dist/index.d.cts.map +1 -0
  14. package/dist/index.d.mts +263 -0
  15. package/dist/index.d.mts.map +1 -0
  16. package/dist/index.mjs +7529 -0
  17. package/dist/index.mjs.map +1 -0
  18. package/dist/metadata.cjs +22 -0
  19. package/dist/metadata.cjs.map +1 -0
  20. package/dist/metadata.d.cts +7 -0
  21. package/dist/metadata.d.cts.map +1 -0
  22. package/dist/metadata.d.mts +7 -0
  23. package/dist/metadata.d.mts.map +1 -0
  24. package/dist/metadata.mjs +21 -0
  25. package/dist/metadata.mjs.map +1 -0
  26. package/dist/networks-BrV516-R.d.cts +15 -0
  27. package/dist/networks-BrV516-R.d.cts.map +1 -0
  28. package/dist/networks-C0MmhJcu.d.mts +15 -0
  29. package/dist/networks-C0MmhJcu.d.mts.map +1 -0
  30. package/dist/networks-DgUFSTiC.cjs +76 -0
  31. package/dist/networks-DgUFSTiC.cjs.map +1 -0
  32. package/dist/networks-QbEPbaGT.mjs +46 -0
  33. package/dist/networks-QbEPbaGT.mjs.map +1 -0
  34. package/dist/networks.cjs +8 -0
  35. package/dist/networks.d.cts +2 -0
  36. package/dist/networks.d.mts +2 -0
  37. package/dist/networks.mjs +3 -0
  38. package/dist/vite-config.cjs +43 -0
  39. package/dist/vite-config.cjs.map +1 -0
  40. package/dist/vite-config.d.cts +35 -0
  41. package/dist/vite-config.d.cts.map +1 -0
  42. package/dist/vite-config.d.mts +35 -0
  43. package/dist/vite-config.d.mts.map +1 -0
  44. package/dist/vite-config.mjs +42 -0
  45. package/dist/vite-config.mjs.map +1 -0
  46. package/package.json +114 -0
  47. package/src/__tests__/getDefaultServiceConfig.test.ts +105 -0
  48. package/src/access-control/actions.ts +214 -0
  49. package/src/access-control/feature-detection.ts +238 -0
  50. package/src/access-control/index.ts +54 -0
  51. package/src/access-control/indexer-client.ts +1474 -0
  52. package/src/access-control/onchain-reader.ts +446 -0
  53. package/src/access-control/service.ts +1431 -0
  54. package/src/access-control/validation.ts +256 -0
  55. package/src/adapter.ts +659 -0
  56. package/src/config.ts +43 -0
  57. package/src/configuration/__tests__/explorer.test.ts +80 -0
  58. package/src/configuration/__tests__/rpc.test.ts +355 -0
  59. package/src/configuration/execution.ts +83 -0
  60. package/src/configuration/explorer.ts +105 -0
  61. package/src/configuration/index.ts +5 -0
  62. package/src/configuration/network-services.ts +210 -0
  63. package/src/configuration/rpc.ts +270 -0
  64. package/src/configuration.ts +2 -0
  65. package/src/contract/__tests__/complete-type-coverage.test.ts +78 -0
  66. package/src/contract/index.ts +3 -0
  67. package/src/contract/loader.ts +498 -0
  68. package/src/contract/transformer.ts +1 -0
  69. package/src/contract/type.ts +65 -0
  70. package/src/index.ts +23 -0
  71. package/src/mapping/constants.ts +89 -0
  72. package/src/mapping/enum-metadata.ts +237 -0
  73. package/src/mapping/field-generator.ts +296 -0
  74. package/src/mapping/index.ts +5 -0
  75. package/src/mapping/struct-fields.ts +106 -0
  76. package/src/mapping/tuple-components.ts +43 -0
  77. package/src/mapping/type-coverage-validator.ts +151 -0
  78. package/src/mapping/type-mapper.ts +203 -0
  79. package/src/metadata.ts +16 -0
  80. package/src/networks/README.md +84 -0
  81. package/src/networks/index.ts +19 -0
  82. package/src/networks/mainnet.ts +20 -0
  83. package/src/networks/testnet.ts +20 -0
  84. package/src/networks.ts +2 -0
  85. package/src/query/handler.ts +411 -0
  86. package/src/query/index.ts +4 -0
  87. package/src/query/view-checker.ts +32 -0
  88. package/src/sac/spec-cache.ts +68 -0
  89. package/src/sac/spec-source.ts +35 -0
  90. package/src/sac/xdr.ts +101 -0
  91. package/src/transaction/components/AdvancedInfo.tsx +34 -0
  92. package/src/transaction/components/FeeConfiguration.tsx +41 -0
  93. package/src/transaction/components/StellarRelayerOptions.tsx +60 -0
  94. package/src/transaction/components/TransactionTiming.tsx +77 -0
  95. package/src/transaction/components/index.ts +5 -0
  96. package/src/transaction/components/useStellarRelayerOptions.ts +114 -0
  97. package/src/transaction/eoa.ts +229 -0
  98. package/src/transaction/execution-strategy.ts +33 -0
  99. package/src/transaction/formatter.ts +296 -0
  100. package/src/transaction/index.ts +4 -0
  101. package/src/transaction/relayer.ts +575 -0
  102. package/src/transaction/sender.ts +156 -0
  103. package/src/transform/index.ts +4 -0
  104. package/src/transform/input-parser.ts +9 -0
  105. package/src/transform/output-formatter.ts +133 -0
  106. package/src/transform/parsers/complex-parser.ts +157 -0
  107. package/src/transform/parsers/generic-parser.ts +171 -0
  108. package/src/transform/parsers/index.ts +86 -0
  109. package/src/transform/parsers/primitive-parser.ts +123 -0
  110. package/src/transform/parsers/scval-converter.ts +405 -0
  111. package/src/transform/parsers/struct-parser.ts +324 -0
  112. package/src/transform/parsers/types.ts +35 -0
  113. package/src/types/__tests__/artifacts.test.ts +89 -0
  114. package/src/types/artifacts.ts +19 -0
  115. package/src/utils/__tests__/artifacts.test.ts +77 -0
  116. package/src/utils/artifacts.ts +30 -0
  117. package/src/utils/formatting.ts +122 -0
  118. package/src/utils/index.ts +6 -0
  119. package/src/utils/input-parsing.ts +336 -0
  120. package/src/utils/safe-type-parser.ts +303 -0
  121. package/src/utils/stellar-types.ts +35 -0
  122. package/src/utils/type-detection.ts +163 -0
  123. package/src/utils/xdr-ordering.ts +36 -0
  124. package/src/validation/__tests__/address.test.ts +267 -0
  125. package/src/validation/address.ts +136 -0
  126. package/src/validation/eoa.ts +33 -0
  127. package/src/validation/index.ts +3 -0
  128. package/src/validation/relayer.ts +13 -0
  129. package/src/vite-config.ts +67 -0
  130. package/src/wallet/README.md +93 -0
  131. package/src/wallet/__tests__/connection.test.ts +72 -0
  132. package/src/wallet/components/StellarWalletUiRoot.tsx +161 -0
  133. package/src/wallet/components/account/AccountDisplay.tsx +50 -0
  134. package/src/wallet/components/connect/ConnectButton.tsx +100 -0
  135. package/src/wallet/components/connect/ConnectorDialog.tsx +125 -0
  136. package/src/wallet/components/index.ts +3 -0
  137. package/src/wallet/connection.ts +151 -0
  138. package/src/wallet/context/StellarWalletContext.ts +32 -0
  139. package/src/wallet/context/index.ts +4 -0
  140. package/src/wallet/context/useStellarWalletContext.ts +17 -0
  141. package/src/wallet/hooks/facade-hooks.ts +31 -0
  142. package/src/wallet/hooks/index.ts +7 -0
  143. package/src/wallet/hooks/useStellarAccount.ts +27 -0
  144. package/src/wallet/hooks/useStellarConnect.ts +60 -0
  145. package/src/wallet/hooks/useStellarDisconnect.ts +47 -0
  146. package/src/wallet/hooks/useUiKitConfig.ts +40 -0
  147. package/src/wallet/implementation/wallets-kit-implementation.ts +379 -0
  148. package/src/wallet/index.ts +11 -0
  149. package/src/wallet/services/__tests__/configResolutionService.test.ts +163 -0
  150. package/src/wallet/services/configResolutionService.ts +65 -0
  151. package/src/wallet/stellar-wallets-kit/StellarWalletsKitConnectButton.tsx +82 -0
  152. package/src/wallet/stellar-wallets-kit/__mocks__/@creit.tech/stellar-wallets-kit.ts +48 -0
  153. package/src/wallet/stellar-wallets-kit/__tests__/export-service.test.ts +93 -0
  154. package/src/wallet/stellar-wallets-kit/__tests__/stellarUiKitManager.test.ts +0 -0
  155. package/src/wallet/stellar-wallets-kit/config-generator.ts +75 -0
  156. package/src/wallet/stellar-wallets-kit/export-service.ts +19 -0
  157. package/src/wallet/stellar-wallets-kit/index.ts +3 -0
  158. package/src/wallet/stellar-wallets-kit/stellarUiKitManager.ts +235 -0
  159. package/src/wallet/types.ts +19 -0
  160. package/src/wallet/utils/__tests__/filterWalletComponents.test.ts +150 -0
  161. package/src/wallet/utils/__tests__/uiKitService.test.ts +189 -0
  162. package/src/wallet/utils/filterWalletComponents.ts +89 -0
  163. package/src/wallet/utils/index.ts +3 -0
  164. package/src/wallet/utils/stellarWalletImplementationManager.ts +118 -0
  165. package/src/wallet/utils/uiKitService.ts +74 -0
@@ -0,0 +1,151 @@
1
+ import type { FieldType } from '@openzeppelin/ui-types';
2
+ import { logger } from '@openzeppelin/ui-utils';
3
+
4
+ import { STELLAR_TYPE_TO_FIELD_TYPE } from './constants';
5
+ import { mapStellarParameterTypeToFieldType } from './type-mapper';
6
+
7
+ /**
8
+ * Known Stellar/Soroban types that should have explicit mappings
9
+ * This list should be updated when new types are added to the Stellar SDK
10
+ */
11
+ export const KNOWN_STELLAR_TYPES = [
12
+ // Primitives
13
+ 'Val',
14
+ 'Bool',
15
+ 'Void',
16
+ 'Error',
17
+ 'U32',
18
+ 'I32',
19
+ 'U64',
20
+ 'I64',
21
+ 'U128',
22
+ 'I128',
23
+ 'U256',
24
+ 'I256',
25
+ 'Timepoint',
26
+ 'Duration',
27
+
28
+ // Strings & Bytes
29
+ 'ScString',
30
+ 'ScSymbol',
31
+ 'Bytes',
32
+
33
+ // Addresses
34
+ 'Address',
35
+ 'MuxedAddress',
36
+
37
+ // Note: Vec, Map, Tuple, Option, Result, BytesN are handled dynamically
38
+ ] as const;
39
+
40
+ /**
41
+ * Validate that all known Stellar types have appropriate field type mappings
42
+ */
43
+ export function validateTypeMappingCompleteness(): {
44
+ success: boolean;
45
+ missing: string[];
46
+ warnings: string[];
47
+ } {
48
+ const missing: string[] = [];
49
+ const warnings: string[] = [];
50
+
51
+ // Check explicit mappings
52
+ for (const stellarType of KNOWN_STELLAR_TYPES) {
53
+ if (!STELLAR_TYPE_TO_FIELD_TYPE[stellarType]) {
54
+ // Try the dynamic mapper
55
+ try {
56
+ const fieldType = mapStellarParameterTypeToFieldType(stellarType);
57
+ if (
58
+ fieldType === 'text' &&
59
+ !stellarType.includes('String') &&
60
+ !stellarType.includes('Symbol')
61
+ ) {
62
+ warnings.push(
63
+ `Type "${stellarType}" defaults to 'text' - consider adding explicit mapping`
64
+ );
65
+ }
66
+ } catch {
67
+ missing.push(stellarType);
68
+ logger.warn('validateTypeMappingCompleteness', `No mapping for type: ${stellarType}`);
69
+ }
70
+ }
71
+ }
72
+
73
+ // Validate field type consistency
74
+ const fieldTypes = Object.values(STELLAR_TYPE_TO_FIELD_TYPE) as FieldType[];
75
+ const validFieldTypes: FieldType[] = [
76
+ 'text',
77
+ 'number',
78
+ 'textarea',
79
+ 'checkbox',
80
+ 'select',
81
+ 'radio',
82
+ 'blockchain-address',
83
+ 'object',
84
+ 'array',
85
+ 'array-object',
86
+ ];
87
+
88
+ for (const fieldType of fieldTypes) {
89
+ if (!validFieldTypes.includes(fieldType)) {
90
+ warnings.push(`Unknown field type used: ${fieldType}`);
91
+ }
92
+ }
93
+
94
+ const success = missing.length === 0;
95
+
96
+ if (!success) {
97
+ logger.error('validateTypeMappingCompleteness', 'Missing type mappings found!', {
98
+ missing,
99
+ warnings,
100
+ knownTypesCount: KNOWN_STELLAR_TYPES.length,
101
+ explicitMappingsCount: Object.keys(STELLAR_TYPE_TO_FIELD_TYPE).length,
102
+ });
103
+ }
104
+
105
+ return { success, missing, warnings };
106
+ }
107
+
108
+ /**
109
+ * Runtime type discovery - tracks types encountered during contract loading
110
+ */
111
+ class TypeTracker {
112
+ private encounteredTypes = new Set<string>();
113
+ private missedTypes = new Set<string>();
114
+
115
+ trackType(type: string, wasHandled: boolean) {
116
+ this.encounteredTypes.add(type);
117
+ if (!wasHandled) {
118
+ this.missedTypes.add(type);
119
+ }
120
+ }
121
+
122
+ getReport() {
123
+ return {
124
+ totalTypes: this.encounteredTypes.size,
125
+ encounteredTypes: Array.from(this.encounteredTypes).sort(),
126
+ missedTypes: Array.from(this.missedTypes).sort(),
127
+ coveragePercentage:
128
+ ((this.encounteredTypes.size - this.missedTypes.size) / this.encounteredTypes.size) * 100,
129
+ };
130
+ }
131
+
132
+ reset() {
133
+ this.encounteredTypes.clear();
134
+ this.missedTypes.clear();
135
+ }
136
+ }
137
+
138
+ export const globalTypeTracker = new TypeTracker();
139
+
140
+ // Auto-validate on module load in development
141
+ if (process.env.NODE_ENV === 'development') {
142
+ const validation = validateTypeMappingCompleteness();
143
+ if (validation.warnings.length > 0) {
144
+ console.warn('🟡 Stellar Type Mapping Warnings:', validation.warnings);
145
+ }
146
+ if (!validation.success) {
147
+ console.error('🔴 Stellar Type Mapping Validation Failed:', validation);
148
+ } else {
149
+ console.log('✅ Stellar Type Mapping Validation Passed');
150
+ }
151
+ }
@@ -0,0 +1,203 @@
1
+ import type { FieldType } from '@openzeppelin/ui-types';
2
+
3
+ import { isBytesNType, isLikelyEnumType } from '../utils/type-detection';
4
+ import { STELLAR_TYPE_TO_FIELD_TYPE } from './constants';
5
+
6
+ /**
7
+ * Map a Stellar-specific parameter type to a default form field type.
8
+ * @param parameterType The Stellar parameter type (e.g., 'U128', 'Address', 'Vec<U32>')
9
+ * @returns The appropriate default form field type (e.g., 'number', 'blockchain-address', 'array')
10
+ */
11
+ export function mapStellarParameterTypeToFieldType(parameterType: string): FieldType {
12
+ // Check if this is a Vec of custom/complex types (e.g., Vec<CustomStruct>)
13
+ const vecComplexMatch = parameterType.match(/^Vec<([^>]+)>$/);
14
+ if (vecComplexMatch) {
15
+ const innerType = vecComplexMatch[1];
16
+ // If inner type is not a primitive, treat as array of objects
17
+ if (!STELLAR_TYPE_TO_FIELD_TYPE[innerType]) {
18
+ return 'array-object';
19
+ }
20
+ return 'array';
21
+ }
22
+
23
+ // Check if this is a simple Vec type
24
+ if (parameterType === 'Vec' || parameterType.startsWith('Vec<')) {
25
+ return 'array';
26
+ }
27
+
28
+ // Check if this is a Map type
29
+ if (parameterType === 'Map' || parameterType.startsWith('Map<')) {
30
+ return 'map' as FieldType;
31
+ }
32
+
33
+ // Extract base type for generic types (e.g., Option<U32> -> U32)
34
+ const genericMatch = parameterType.match(/^(\w+)<(.+)>$/);
35
+ if (genericMatch) {
36
+ const baseType = genericMatch[1];
37
+ // For Option and Result types, use the inner type
38
+ if (baseType === 'Option' || baseType === 'Result') {
39
+ const innerType = genericMatch[2];
40
+ return mapStellarParameterTypeToFieldType(innerType);
41
+ }
42
+ }
43
+
44
+ // Map known Stellar/Soroban types to appropriate field types
45
+ const mappedType = STELLAR_TYPE_TO_FIELD_TYPE[parameterType];
46
+ if (mappedType) {
47
+ return mappedType;
48
+ }
49
+
50
+ // Handle BytesN types (fixed-size byte arrays like BytesN<32> for hashes)
51
+ if (isBytesNType(parameterType)) {
52
+ return 'bytes';
53
+ }
54
+
55
+ // Handle custom types (structs, enums) - default to object unless it's clearly an enum
56
+ if (isLikelyEnumType(parameterType)) {
57
+ return 'select';
58
+ }
59
+
60
+ // Check if this looks like a custom struct (capitalized name and not a known primitive)
61
+ if (parameterType[0] && parameterType[0] === parameterType[0].toUpperCase()) {
62
+ // Check if it's not a known Stellar primitive type that starts with uppercase
63
+ const knownUppercaseTypes = [
64
+ 'U32',
65
+ 'U64',
66
+ 'U128',
67
+ 'U256',
68
+ 'I32',
69
+ 'I64',
70
+ 'I128',
71
+ 'I256',
72
+ 'Bool',
73
+ 'Bytes',
74
+ ];
75
+ if (
76
+ !knownUppercaseTypes.includes(parameterType) &&
77
+ !parameterType.startsWith('Vec') &&
78
+ !parameterType.startsWith('Map') &&
79
+ !parameterType.includes('Unknown')
80
+ ) {
81
+ // Don't treat Unknown* as structs
82
+ return 'object';
83
+ }
84
+ }
85
+
86
+ // Final fallback to text for truly unknown types
87
+ return 'text';
88
+ }
89
+
90
+ /**
91
+ * Get field types compatible with a specific parameter type.
92
+ * @param parameterType The Stellar parameter type.
93
+ * @returns Array of compatible form field types.
94
+ */
95
+ export function getStellarCompatibleFieldTypes(parameterType: string): FieldType[] {
96
+ // Handle Vec of complex types
97
+ const vecComplexMatch = parameterType.match(/^Vec<([^>]+)>$/);
98
+ if (vecComplexMatch) {
99
+ const innerType = vecComplexMatch[1];
100
+ if (!STELLAR_TYPE_TO_FIELD_TYPE[innerType]) {
101
+ return ['array-object', 'textarea', 'text'];
102
+ }
103
+ return ['array', 'textarea', 'text'];
104
+ }
105
+
106
+ if (isBytesNType(parameterType)) {
107
+ return ['bytes', 'textarea', 'text'];
108
+ }
109
+
110
+ // Handle Vec types - allow array field or fallback to textarea/text
111
+ if (parameterType === 'Vec' || parameterType.startsWith('Vec<')) {
112
+ return ['array', 'textarea', 'text'];
113
+ }
114
+
115
+ // Handle Map types
116
+ if (parameterType === 'Map' || parameterType.startsWith('Map<')) {
117
+ return ['map' as FieldType, 'textarea', 'text'];
118
+ }
119
+
120
+ // Handle generic types
121
+ const genericMatch = parameterType.match(/^(\w+)<(.+)>$/);
122
+ if (genericMatch) {
123
+ const baseType = genericMatch[1];
124
+ if (baseType === 'Option' || baseType === 'Result') {
125
+ const innerType = genericMatch[2];
126
+ return getStellarCompatibleFieldTypes(innerType);
127
+ }
128
+ }
129
+
130
+ // Define compatibility map for known types
131
+ const compatibilityMap: Record<string, FieldType[]> = {
132
+ Address: ['blockchain-address', 'text'],
133
+
134
+ // Unsigned integers
135
+ U32: ['number', 'amount', 'text'],
136
+ U64: ['bigint', 'number', 'amount', 'text'],
137
+ U128: ['bigint', 'number', 'amount', 'text'],
138
+ U256: ['bigint', 'number', 'amount', 'text'],
139
+
140
+ // Signed integers
141
+ I32: ['number', 'amount', 'text'],
142
+ I64: ['bigint', 'number', 'text'],
143
+ I128: ['bigint', 'number', 'text'],
144
+ I256: ['bigint', 'number', 'text'],
145
+
146
+ // Boolean
147
+ Bool: ['checkbox', 'select', 'radio', 'text'],
148
+
149
+ // String types
150
+ ScString: ['text', 'textarea', 'email', 'password'],
151
+ ScSymbol: ['text', 'textarea'],
152
+
153
+ // Byte types
154
+ Bytes: ['bytes', 'textarea', 'text'],
155
+ DataUrl: ['bytes', 'textarea', 'text'],
156
+ // BytesN types like BytesN<32> for hashes
157
+ 'BytesN<32>': ['bytes', 'textarea', 'text'],
158
+
159
+ // Complex types
160
+ Tuple: ['object', 'textarea', 'text'],
161
+ Instance: ['object', 'textarea', 'text'],
162
+ };
163
+
164
+ // Check if we have a specific compatibility mapping
165
+ const compatibleTypes = compatibilityMap[parameterType];
166
+ if (compatibleTypes) {
167
+ return compatibleTypes;
168
+ }
169
+
170
+ // Handle enums
171
+ if (isLikelyEnumType(parameterType)) {
172
+ return ['enum', 'select', 'radio', 'text'];
173
+ }
174
+
175
+ // Handle custom types (assumed to be structs)
176
+ if (parameterType[0] && parameterType[0] === parameterType[0].toUpperCase()) {
177
+ // Check if it's not a known Stellar primitive type that starts with uppercase
178
+ const knownUppercaseTypes = [
179
+ 'U32',
180
+ 'U64',
181
+ 'U128',
182
+ 'U256',
183
+ 'I32',
184
+ 'I64',
185
+ 'I128',
186
+ 'I256',
187
+ 'Bool',
188
+ 'Bytes',
189
+ ];
190
+ if (
191
+ !knownUppercaseTypes.includes(parameterType) &&
192
+ !parameterType.startsWith('Vec') &&
193
+ !parameterType.startsWith('Map') &&
194
+ !parameterType.includes('Unknown')
195
+ ) {
196
+ // Don't treat Unknown* as structs
197
+ return ['object', 'textarea', 'text'];
198
+ }
199
+ }
200
+
201
+ // Default fallback for truly unknown types
202
+ return ['text'];
203
+ }
@@ -0,0 +1,16 @@
1
+ import { NetworkStellar } from '@web3icons/react';
2
+
3
+ import type { EcosystemMetadata } from '@openzeppelin/ui-types';
4
+
5
+ export const ecosystemMetadata: EcosystemMetadata = {
6
+ id: 'stellar',
7
+ name: 'Stellar',
8
+ description:
9
+ 'Stellar is a fast, energy-efficient blockchain network designed for real-world financial applications. It enables near-instant global payments at low cost, connects digital assets to traditional finance, and supports smart contracts through Soroban.',
10
+ explorerGuidance: 'contract IDs on Stellar Expert',
11
+ addressExample: 'GCKFBEIYV2U22IO2BJ4KVJOIP7XPWQGQFKKWXR6DOSJBV7STMAQSMTGG',
12
+ iconComponent: NetworkStellar,
13
+ bgColorClass: 'bg-sky-100',
14
+ textColorClass: 'text-sky-900',
15
+ defaultFeatureConfig: { enabled: true, showInUI: true },
16
+ };
@@ -0,0 +1,84 @@
1
+ # Stellar Adapter Networks
2
+
3
+ This directory defines the Stellar network configurations exported by the adapter.
4
+
5
+ ## Available Networks
6
+
7
+ Exports from `index.ts`:
8
+
9
+ - `stellarPublic` (mainnet)
10
+ - `stellarTestnet` (testnet)
11
+ - `stellarMainnetNetworks`: `StellarNetworkConfig[]` containing all mainnet networks
12
+ - `stellarTestnetNetworks`: `StellarNetworkConfig[]` containing all testnet networks
13
+ - `stellarNetworks`: union of all supported networks
14
+
15
+ Each `StellarNetworkConfig` includes:
16
+
17
+ - `id`: Unique identifier (e.g., `"stellar-public"`, `"stellar-testnet"`)
18
+ - `name`: Display name
19
+ - `ecosystem`: `"stellar"`
20
+ - `network`: `"stellar"`
21
+ - `type`: `"mainnet" | "testnet"`
22
+ - `isTestnet`: boolean
23
+ - `horizonUrl`: Horizon REST URL
24
+ - `sorobanRpcUrl`: Soroban JSON-RPC URL
25
+ - `networkPassphrase`: Network passphrase
26
+ - `explorerUrl`: Base explorer URL (for display links)
27
+ - `icon`: Icon identifier
28
+
29
+ ## Soroban RPC URL Overrides
30
+
31
+ You can override the default `sorobanRpcUrl` at runtime through `AppConfigService`.
32
+
33
+ In `.env` (Builder app):
34
+ `VITE_APP_CFG_RPC_ENDPOINT_STELLAR_TESTNET="https://your-custom-soroban-rpc.testnet.example"`
35
+
36
+ In `public/app.config.json` (exported apps):
37
+
38
+ ```json
39
+ {
40
+ "rpcEndpoints": {
41
+ "stellar-testnet": "https://your-custom-soroban-rpc.testnet.example",
42
+ "stellar-public": "https://your-custom-soroban-rpc.public.example"
43
+ }
44
+ }
45
+ ```
46
+
47
+ Resolution order used by the adapter:
48
+
49
+ 1. User RPC from `UserRpcConfigService`
50
+ 2. `AppConfigService.getRpcEndpointOverride(networkId)`
51
+ 3. Default `sorobanRpcUrl` from the network config
52
+
53
+ ## Adding a New Stellar Network
54
+
55
+ 1. Add the network to `mainnet.ts` or `testnet.ts`:
56
+
57
+ ```typescript
58
+ export const stellarCustom: StellarNetworkConfig = {
59
+ id: 'stellar-custom',
60
+ exportConstName: 'stellarCustom',
61
+ name: 'Stellar Custom',
62
+ ecosystem: 'stellar',
63
+ network: 'stellar',
64
+ type: 'testnet',
65
+ isTestnet: true,
66
+ horizonUrl: 'https://horizon.custom.example',
67
+ sorobanRpcUrl: 'https://soroban.custom.example',
68
+ networkPassphrase: 'Custom Network Passphrase',
69
+ explorerUrl: 'https://stellar.expert/explorer/custom',
70
+ iconComponent: NetworkStellarCustom,
71
+ };
72
+ ```
73
+
74
+ 1. Include it in the appropriate array and export it from `index.ts`.
75
+ 2. Re-export from the package root in `src/index.ts` if you want it available to consumers.
76
+
77
+ ## Explorer URLs
78
+
79
+ Explorers are used for display only. The adapter builds links using `explorerUrl`:
80
+
81
+ - Address or contract: `.../account/{address}` or `.../contract/{id}`
82
+ - Transaction: `.../tx/{hash}`
83
+
84
+ No explorer API keys are required for Stellar adapter functionality.
@@ -0,0 +1,19 @@
1
+ import { StellarNetworkConfig } from '@openzeppelin/ui-types';
2
+
3
+ import { stellarPublic } from './mainnet';
4
+ import { stellarTestnet } from './testnet';
5
+
6
+ // All mainnet networks
7
+ export const stellarMainnetNetworks: StellarNetworkConfig[] = [stellarPublic];
8
+
9
+ // All testnet networks
10
+ export const stellarTestnetNetworks: StellarNetworkConfig[] = [stellarTestnet];
11
+
12
+ // All Stellar networks
13
+ export const stellarNetworks: StellarNetworkConfig[] = [
14
+ ...stellarMainnetNetworks,
15
+ ...stellarTestnetNetworks,
16
+ ];
17
+
18
+ // Export individual networks as well
19
+ export { stellarPublic, stellarTestnet };
@@ -0,0 +1,20 @@
1
+ import { NetworkStellar } from '@web3icons/react';
2
+
3
+ import { StellarNetworkConfig } from '@openzeppelin/ui-types';
4
+
5
+ // Stellar Public Network (Mainnet)
6
+ export const stellarPublic: StellarNetworkConfig = {
7
+ id: 'stellar-public',
8
+ exportConstName: 'stellarPublic',
9
+ name: 'Stellar',
10
+ ecosystem: 'stellar',
11
+ network: 'stellar',
12
+ type: 'mainnet',
13
+ isTestnet: false,
14
+ horizonUrl: 'https://horizon.stellar.org',
15
+ sorobanRpcUrl: 'https://mainnet.sorobanrpc.com',
16
+ networkPassphrase: 'Public Global Stellar Network ; September 2015',
17
+ explorerUrl: 'https://stellar.expert/explorer/public',
18
+ iconComponent: NetworkStellar,
19
+ accessControlIndexerUrl: 'https://openzeppelin-stellar-mainnet.graphql.subquery.network',
20
+ };
@@ -0,0 +1,20 @@
1
+ import { NetworkStellar } from '@web3icons/react';
2
+
3
+ import { StellarNetworkConfig } from '@openzeppelin/ui-types';
4
+
5
+ // Stellar Testnet
6
+ export const stellarTestnet: StellarNetworkConfig = {
7
+ id: 'stellar-testnet',
8
+ exportConstName: 'stellarTestnet',
9
+ name: 'Stellar Testnet',
10
+ ecosystem: 'stellar',
11
+ network: 'stellar',
12
+ type: 'testnet',
13
+ isTestnet: true,
14
+ horizonUrl: 'https://horizon-testnet.stellar.org',
15
+ sorobanRpcUrl: 'https://soroban-testnet.stellar.org',
16
+ networkPassphrase: 'Test SDF Network ; September 2015',
17
+ explorerUrl: 'https://stellar.expert/explorer/testnet',
18
+ iconComponent: NetworkStellar,
19
+ accessControlIndexerUrl: 'https://openzeppelin-stellar-testnet.graphql.subquery.network',
20
+ };
@@ -0,0 +1,2 @@
1
+ export * from './networks/index';
2
+ export { stellarNetworks as networks } from './networks/index';