@hashgraphonline/standards-agent-kit 0.2.137 → 0.2.138
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.
- package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/cjs/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/signing/bytes-registry.d.ts +17 -0
- package/dist/cjs/signing/signer-provider.d.ts +45 -0
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +1 -1
- package/dist/cjs/types/tx-results.d.ts +15 -0
- package/dist/cjs/utils/CodedError.d.ts +4 -0
- package/dist/cjs/validation/hip412-schemas.d.ts +2 -2
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/es/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/es/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/es/index.d.ts +4 -0
- package/dist/es/signing/bytes-registry.d.ts +17 -0
- package/dist/es/signing/signer-provider.d.ts +45 -0
- package/dist/es/standards-agent-kit.es.js +46 -42
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +24 -83
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +224 -20
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +78 -27
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +26 -36
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +17 -39
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +36 -58
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +45 -18
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +53 -16
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +18 -28
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +26 -12
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +38 -136
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +13 -24
- package/dist/es/standards-agent-kit.es21.js.map +1 -1
- package/dist/es/standards-agent-kit.es22.js +136 -39
- package/dist/es/standards-agent-kit.es22.js.map +1 -1
- package/dist/es/standards-agent-kit.es23.js +25 -41
- package/dist/es/standards-agent-kit.es23.js.map +1 -1
- package/dist/es/standards-agent-kit.es24.js +49 -31
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js +34 -18
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es26.js +35 -19
- package/dist/es/standards-agent-kit.es26.js.map +1 -1
- package/dist/es/standards-agent-kit.es27.js +45 -32
- package/dist/es/standards-agent-kit.es27.js.map +1 -1
- package/dist/es/standards-agent-kit.es28.js +54 -25
- package/dist/es/standards-agent-kit.es28.js.map +1 -1
- package/dist/es/standards-agent-kit.es29.js +35 -23
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +41 -1549
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +23 -39
- package/dist/es/standards-agent-kit.es30.js.map +1 -1
- package/dist/es/standards-agent-kit.es31.js +30 -28
- package/dist/es/standards-agent-kit.es31.js.map +1 -1
- package/dist/es/standards-agent-kit.es32.js +45 -32
- package/dist/es/standards-agent-kit.es32.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +50 -89
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +35 -234
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +87 -213
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +185 -129
- package/dist/es/standards-agent-kit.es36.js.map +1 -1
- package/dist/es/standards-agent-kit.es37.js +167 -563
- package/dist/es/standards-agent-kit.es37.js.map +1 -1
- package/dist/es/standards-agent-kit.es38.js +236 -30
- package/dist/es/standards-agent-kit.es38.js.map +1 -1
- package/dist/es/standards-agent-kit.es39.js +483 -206
- package/dist/es/standards-agent-kit.es39.js.map +1 -1
- package/dist/es/standards-agent-kit.es4.js +359 -81
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es40.js +39 -135
- package/dist/es/standards-agent-kit.es40.js.map +1 -1
- package/dist/es/standards-agent-kit.es41.js +244 -28
- package/dist/es/standards-agent-kit.es41.js.map +1 -1
- package/dist/es/standards-agent-kit.es42.js +132 -418
- package/dist/es/standards-agent-kit.es42.js.map +1 -1
- package/dist/es/standards-agent-kit.es43.js +28 -184
- package/dist/es/standards-agent-kit.es43.js.map +1 -1
- package/dist/es/standards-agent-kit.es44.js +423 -3
- package/dist/es/standards-agent-kit.es44.js.map +1 -1
- package/dist/es/standards-agent-kit.es45.js +185 -24
- package/dist/es/standards-agent-kit.es45.js.map +1 -1
- package/dist/es/standards-agent-kit.es46.js +3 -3
- package/dist/es/standards-agent-kit.es46.js.map +1 -1
- package/dist/es/standards-agent-kit.es47.js +24 -20
- package/dist/es/standards-agent-kit.es47.js.map +1 -1
- package/dist/es/standards-agent-kit.es48.js +6 -52
- package/dist/es/standards-agent-kit.es48.js.map +1 -1
- package/dist/es/standards-agent-kit.es49.js +4 -3
- package/dist/es/standards-agent-kit.es49.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +1747 -73
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es50.js +20 -39
- package/dist/es/standards-agent-kit.es50.js.map +1 -1
- package/dist/es/standards-agent-kit.es51.js +50 -15
- package/dist/es/standards-agent-kit.es51.js.map +1 -1
- package/dist/es/standards-agent-kit.es52.js +3 -74
- package/dist/es/standards-agent-kit.es52.js.map +1 -1
- package/dist/es/standards-agent-kit.es53.js +43 -0
- package/dist/es/standards-agent-kit.es53.js.map +1 -0
- package/dist/es/standards-agent-kit.es54.js +22 -0
- package/dist/es/standards-agent-kit.es54.js.map +1 -0
- package/dist/es/standards-agent-kit.es55.js +77 -0
- package/dist/es/standards-agent-kit.es55.js.map +1 -0
- package/dist/es/standards-agent-kit.es56.js +7 -0
- package/dist/es/standards-agent-kit.es56.js.map +1 -0
- package/dist/es/standards-agent-kit.es6.js +332 -173
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +142 -293
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +201 -21
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +301 -213
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +1 -1
- package/dist/es/types/tx-results.d.ts +15 -0
- package/dist/es/utils/CodedError.d.ts +4 -0
- package/dist/es/validation/hip412-schemas.d.ts +2 -2
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/umd/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/umd/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/umd/index.d.ts +4 -0
- package/dist/umd/signing/bytes-registry.d.ts +17 -0
- package/dist/umd/signing/signer-provider.d.ts +45 -0
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +1 -1
- package/dist/umd/types/tx-results.d.ts +15 -0
- package/dist/umd/utils/CodedError.d.ts +4 -0
- package/dist/umd/validation/hip412-schemas.d.ts +2 -2
- package/package.json +3 -3
- package/src/builders/hcs10/hcs10-builder.ts +239 -10
- package/src/builders/hcs2/hcs2-builder.ts +302 -9
- package/src/builders/hcs6/hcs6-builder.ts +79 -4
- package/src/hcs10/HCS10Client.ts +1 -1
- package/src/index.ts +5 -1
- package/src/lib/zod-render/schema-extension.ts +0 -1
- package/src/signing/bytes-registry.ts +501 -0
- package/src/signing/signer-provider.ts +120 -0
- package/src/tools/hcs2/CreateRegistryTool.ts +30 -5
- package/src/tools/hcs2/DeleteEntryTool.ts +16 -2
- package/src/tools/hcs2/MigrateRegistryTool.ts +16 -2
- package/src/tools/hcs2/QueryRegistryTool.ts +11 -2
- package/src/tools/hcs2/RegisterEntryTool.ts +17 -3
- package/src/tools/hcs2/UpdateEntryTool.ts +16 -2
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +17 -3
- package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +17 -3
- package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +17 -3
- package/src/tools/inscriber/InscribeFromBufferTool.ts +78 -2
- package/src/tools/inscriber/InscribeHashinalTool.ts +22 -131
- package/src/types/tx-results.ts +18 -0
- package/src/utils/CodedError.ts +8 -0
- package/src/utils/Encryption.ts +0 -2
- package/src/utils/ensure-agent-has-hbar.ts +4 -5
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
RegistryOperationResponse,
|
|
14
14
|
TopicRegistry,
|
|
15
15
|
NetworkType,
|
|
16
|
+
HederaMirrorNode,
|
|
16
17
|
} from '@hashgraphonline/standards-sdk';
|
|
18
|
+
import { SignerProviderRegistry, type NetworkString } from '../../signing/signer-provider';
|
|
19
|
+
import type { TopicRegistrationResult, RegistryOperationResult, SubmitMessageResult } from '../../types/tx-results';
|
|
20
|
+
import { CodedError } from '../../utils/CodedError';
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* Builder for HCS-2 operations that delegates to HCS2Client
|
|
@@ -40,10 +44,23 @@ export class HCS2Builder extends BaseServiceBuilder {
|
|
|
40
44
|
? 'mainnet'
|
|
41
45
|
: 'testnet';
|
|
42
46
|
|
|
47
|
+
let keyTypeHint: 'ed25519' | 'ecdsa' | undefined;
|
|
48
|
+
try {
|
|
49
|
+
const mirror = new HederaMirrorNode(networkType);
|
|
50
|
+
const info = await mirror.requestAccount(operatorId);
|
|
51
|
+
const t = (info as any)?.key?._type as string | undefined;
|
|
52
|
+
if (t) {
|
|
53
|
+
const upper = t.toUpperCase();
|
|
54
|
+
if (upper.includes('ED25519')) keyTypeHint = 'ed25519';
|
|
55
|
+
else if (upper.includes('ECDSA')) keyTypeHint = 'ecdsa';
|
|
56
|
+
}
|
|
57
|
+
} catch {}
|
|
58
|
+
|
|
43
59
|
const config: SDKHCS2ClientConfig = {
|
|
44
60
|
network: networkType,
|
|
45
61
|
operatorId: operatorId,
|
|
46
62
|
operatorKey: operatorPrivateKey,
|
|
63
|
+
...(keyTypeHint ? { keyType: keyTypeHint } : {}),
|
|
47
64
|
};
|
|
48
65
|
|
|
49
66
|
this.hcs2Client = new HCS2Client(config);
|
|
@@ -57,18 +74,96 @@ export class HCS2Builder extends BaseServiceBuilder {
|
|
|
57
74
|
*/
|
|
58
75
|
async createRegistry(
|
|
59
76
|
options: CreateRegistryOptions = {}
|
|
60
|
-
): Promise<
|
|
77
|
+
): Promise<TopicRegistrationResult> {
|
|
78
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
79
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
80
|
+
const hasPrivateKey = !!(this.hederaKit?.signer?.getOperatorPrivateKey && this.hederaKit.signer.getOperatorPrivateKey());
|
|
81
|
+
|
|
82
|
+
if (exec) {
|
|
83
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
84
|
+
if (start) {
|
|
85
|
+
try {
|
|
86
|
+
const request: Record<string, unknown> = { options };
|
|
87
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
88
|
+
const { transactionBytes } = await start('hcs2.createRegistry', request, network);
|
|
89
|
+
if (transactionBytes) {
|
|
90
|
+
return { success: true, transactionBytes };
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
if (preferWallet) {
|
|
94
|
+
throw new CodedError('wallet_submit_failed', `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (preferWallet) {
|
|
99
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs2.createRegistry');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!hasPrivateKey) {
|
|
104
|
+
throw new CodedError('wallet_unavailable', 'No wallet executor and no operator private key available for server execution');
|
|
105
|
+
}
|
|
61
106
|
const client = await this.getHCS2Client();
|
|
62
107
|
return await client.createRegistry(options);
|
|
63
108
|
}
|
|
64
|
-
|
|
65
109
|
/**
|
|
66
110
|
* Register a new entry in an HCS-2 registry
|
|
67
111
|
*/
|
|
68
112
|
async registerEntry(
|
|
69
113
|
registryTopicId: string,
|
|
70
114
|
options: RegisterEntryOptions
|
|
71
|
-
): Promise<
|
|
115
|
+
): Promise<RegistryOperationResult> {
|
|
116
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
117
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
118
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
119
|
+
const hasPrivateKey = !!(this.hederaKit?.signer?.getOperatorPrivateKey && this.hederaKit.signer.getOperatorPrivateKey());
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
const { ByteBuildRegistry } = await import('../../signing/bytes-registry');
|
|
123
|
+
if (ByteBuildRegistry.has('hcs2.registerEntry')) {
|
|
124
|
+
const built = await ByteBuildRegistry.build('hcs2.registerEntry', this.hederaKit, { registryTopicId, options });
|
|
125
|
+
if (built && built.transactionBytes) {
|
|
126
|
+
if (exec) {
|
|
127
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
128
|
+
}
|
|
129
|
+
if (!hasPrivateKey) {
|
|
130
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} catch {}
|
|
135
|
+
|
|
136
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
137
|
+
if (start) {
|
|
138
|
+
try {
|
|
139
|
+
const request: Record<string, unknown> = {
|
|
140
|
+
registryTopicId,
|
|
141
|
+
options,
|
|
142
|
+
};
|
|
143
|
+
const { transactionBytes } = await start('hcs2.registerEntry', request, network);
|
|
144
|
+
if (transactionBytes) {
|
|
145
|
+
if (exec) {
|
|
146
|
+
return { success: true, transactionBytes };
|
|
147
|
+
}
|
|
148
|
+
if (!hasPrivateKey) {
|
|
149
|
+
return { success: true, transactionBytes };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch (err) {
|
|
153
|
+
if (preferWallet) {
|
|
154
|
+
const msg = `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
155
|
+
throw new CodedError('wallet_submit_failed', msg);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (preferWallet) {
|
|
161
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs2.registerEntry');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!hasPrivateKey) {
|
|
165
|
+
throw new CodedError('wallet_unavailable', 'No wallet executor and no operator private key available for server execution');
|
|
166
|
+
}
|
|
72
167
|
const client = await this.getHCS2Client();
|
|
73
168
|
return await client.registerEntry(registryTopicId, options);
|
|
74
169
|
}
|
|
@@ -79,7 +174,58 @@ export class HCS2Builder extends BaseServiceBuilder {
|
|
|
79
174
|
async updateEntry(
|
|
80
175
|
registryTopicId: string,
|
|
81
176
|
options: UpdateEntryOptions
|
|
82
|
-
): Promise<
|
|
177
|
+
): Promise<RegistryOperationResult> {
|
|
178
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
179
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
180
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
181
|
+
const hasPrivateKey = !!(this.hederaKit?.signer?.getOperatorPrivateKey && this.hederaKit.signer.getOperatorPrivateKey());
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
const { ByteBuildRegistry } = await import('../../signing/bytes-registry');
|
|
185
|
+
if (ByteBuildRegistry.has('hcs2.updateEntry')) {
|
|
186
|
+
const built = await ByteBuildRegistry.build('hcs2.updateEntry', this.hederaKit, { registryTopicId, options });
|
|
187
|
+
if (built && built.transactionBytes) {
|
|
188
|
+
if (exec) {
|
|
189
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
190
|
+
}
|
|
191
|
+
if (!hasPrivateKey) {
|
|
192
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
} catch {}
|
|
197
|
+
|
|
198
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
199
|
+
if (start) {
|
|
200
|
+
try {
|
|
201
|
+
const request: Record<string, unknown> = {
|
|
202
|
+
registryTopicId,
|
|
203
|
+
options,
|
|
204
|
+
};
|
|
205
|
+
const { transactionBytes } = await start('hcs2.updateEntry', request, network);
|
|
206
|
+
if (transactionBytes) {
|
|
207
|
+
if (exec) {
|
|
208
|
+
return { success: true, transactionBytes };
|
|
209
|
+
}
|
|
210
|
+
if (!hasPrivateKey) {
|
|
211
|
+
return { success: true, transactionBytes };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} catch (err) {
|
|
215
|
+
if (preferWallet) {
|
|
216
|
+
const msg = `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
217
|
+
throw new CodedError('wallet_submit_failed', msg);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (preferWallet) {
|
|
223
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs2.updateEntry');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (!hasPrivateKey) {
|
|
227
|
+
throw new CodedError('wallet_unavailable', 'No wallet executor and no operator private key available for server execution');
|
|
228
|
+
}
|
|
83
229
|
const client = await this.getHCS2Client();
|
|
84
230
|
return await client.updateEntry(registryTopicId, options);
|
|
85
231
|
}
|
|
@@ -90,7 +236,58 @@ export class HCS2Builder extends BaseServiceBuilder {
|
|
|
90
236
|
async deleteEntry(
|
|
91
237
|
registryTopicId: string,
|
|
92
238
|
options: DeleteEntryOptions
|
|
93
|
-
): Promise<
|
|
239
|
+
): Promise<RegistryOperationResult> {
|
|
240
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
241
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
242
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
243
|
+
const hasPrivateKey = !!(this.hederaKit?.signer?.getOperatorPrivateKey && this.hederaKit.signer.getOperatorPrivateKey());
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
const { ByteBuildRegistry } = await import('../../signing/bytes-registry');
|
|
247
|
+
if (ByteBuildRegistry.has('hcs2.deleteEntry')) {
|
|
248
|
+
const built = await ByteBuildRegistry.build('hcs2.deleteEntry', this.hederaKit, { registryTopicId, options });
|
|
249
|
+
if (built && built.transactionBytes) {
|
|
250
|
+
if (exec) {
|
|
251
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
252
|
+
}
|
|
253
|
+
if (!hasPrivateKey) {
|
|
254
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
} catch {}
|
|
259
|
+
|
|
260
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
261
|
+
if (start) {
|
|
262
|
+
try {
|
|
263
|
+
const request: Record<string, unknown> = {
|
|
264
|
+
registryTopicId,
|
|
265
|
+
options,
|
|
266
|
+
};
|
|
267
|
+
const { transactionBytes } = await start('hcs2.deleteEntry', request, network);
|
|
268
|
+
if (transactionBytes) {
|
|
269
|
+
if (exec) {
|
|
270
|
+
return { success: true, transactionBytes };
|
|
271
|
+
}
|
|
272
|
+
if (!hasPrivateKey) {
|
|
273
|
+
return { success: true, transactionBytes };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} catch (err) {
|
|
277
|
+
if (preferWallet) {
|
|
278
|
+
const msg = `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
279
|
+
throw new CodedError('wallet_submit_failed', msg);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (preferWallet) {
|
|
285
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs2.deleteEntry');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (!hasPrivateKey) {
|
|
289
|
+
throw new CodedError('wallet_unavailable', 'No wallet executor and no operator private key available for server execution');
|
|
290
|
+
}
|
|
94
291
|
const client = await this.getHCS2Client();
|
|
95
292
|
return await client.deleteEntry(registryTopicId, options);
|
|
96
293
|
}
|
|
@@ -101,7 +298,55 @@ export class HCS2Builder extends BaseServiceBuilder {
|
|
|
101
298
|
async migrateRegistry(
|
|
102
299
|
registryTopicId: string,
|
|
103
300
|
options: MigrateTopicOptions
|
|
104
|
-
): Promise<
|
|
301
|
+
): Promise<RegistryOperationResult> {
|
|
302
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
303
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
304
|
+
const hasPrivateKey = !!(this.hederaKit?.signer?.getOperatorPrivateKey && this.hederaKit.signer.getOperatorPrivateKey());
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
const { ByteBuildRegistry } = await import('../../signing/bytes-registry');
|
|
308
|
+
if (ByteBuildRegistry.has('hcs2.migrateRegistry')) {
|
|
309
|
+
const built = await ByteBuildRegistry.build('hcs2.migrateRegistry', this.hederaKit, { registryTopicId, options });
|
|
310
|
+
if (built && built.transactionBytes) {
|
|
311
|
+
if (exec) {
|
|
312
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
313
|
+
}
|
|
314
|
+
if (!hasPrivateKey) {
|
|
315
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
} catch {}
|
|
320
|
+
|
|
321
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
322
|
+
if (start) {
|
|
323
|
+
try {
|
|
324
|
+
const request: Record<string, unknown> = { registryTopicId, options };
|
|
325
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
326
|
+
const { transactionBytes } = await start('hcs2.migrateRegistry', request, network);
|
|
327
|
+
if (transactionBytes) {
|
|
328
|
+
if (exec) {
|
|
329
|
+
return { success: true, transactionBytes };
|
|
330
|
+
}
|
|
331
|
+
if (!hasPrivateKey) {
|
|
332
|
+
return { success: true, transactionBytes };
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
} catch (err) {
|
|
336
|
+
if (preferWallet) {
|
|
337
|
+
const msg = `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
338
|
+
throw new CodedError('wallet_submit_failed', msg);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (preferWallet) {
|
|
344
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs2.migrateRegistry');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (!hasPrivateKey) {
|
|
348
|
+
throw new CodedError('wallet_unavailable', 'No wallet executor and no operator private key available for server execution');
|
|
349
|
+
}
|
|
105
350
|
const client = await this.getHCS2Client();
|
|
106
351
|
return await client.migrateRegistry(registryTopicId, options);
|
|
107
352
|
}
|
|
@@ -123,11 +368,59 @@ export class HCS2Builder extends BaseServiceBuilder {
|
|
|
123
368
|
async submitMessage(
|
|
124
369
|
topicId: string,
|
|
125
370
|
payload: any
|
|
126
|
-
): Promise<
|
|
371
|
+
): Promise<SubmitMessageResult> {
|
|
372
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
373
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
374
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
375
|
+
const hasPrivateKey = !!(this.hederaKit?.signer?.getOperatorPrivateKey && this.hederaKit.signer.getOperatorPrivateKey());
|
|
376
|
+
|
|
377
|
+
try {
|
|
378
|
+
const { ByteBuildRegistry } = await import('../../signing/bytes-registry');
|
|
379
|
+
if (ByteBuildRegistry.has('hcs2.submitMessage')) {
|
|
380
|
+
const built = await ByteBuildRegistry.build('hcs2.submitMessage', this.hederaKit, { topicId, payload });
|
|
381
|
+
if (built && built.transactionBytes) {
|
|
382
|
+
if (exec) {
|
|
383
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
384
|
+
}
|
|
385
|
+
if (!hasPrivateKey) {
|
|
386
|
+
return { success: true, transactionBytes: built.transactionBytes };
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} catch {}
|
|
391
|
+
|
|
392
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
393
|
+
if (start) {
|
|
394
|
+
try {
|
|
395
|
+
const request: Record<string, unknown> = { topicId, payload };
|
|
396
|
+
const { transactionBytes } = await start('hcs2.submitMessage', request, network);
|
|
397
|
+
if (transactionBytes) {
|
|
398
|
+
if (exec) {
|
|
399
|
+
return { success: true, transactionBytes };
|
|
400
|
+
}
|
|
401
|
+
if (!hasPrivateKey) {
|
|
402
|
+
return { success: true, transactionBytes };
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
} catch (err) {
|
|
406
|
+
if (preferWallet) {
|
|
407
|
+
const msg = `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
408
|
+
throw new CodedError('wallet_submit_failed', msg);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (preferWallet) {
|
|
414
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs2.submitMessage');
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (!hasPrivateKey) {
|
|
418
|
+
throw new CodedError('wallet_unavailable', 'No wallet executor and no operator private key available for server execution');
|
|
419
|
+
}
|
|
127
420
|
const client = await this.getHCS2Client();
|
|
128
|
-
|
|
421
|
+
await client.submitMessage(topicId, payload);
|
|
422
|
+
return { success: true };
|
|
129
423
|
}
|
|
130
|
-
|
|
131
424
|
/**
|
|
132
425
|
* Get topic info from mirror node
|
|
133
426
|
*/
|
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
HCS6CreateHashinalResponse,
|
|
15
15
|
NetworkType,
|
|
16
16
|
} from '@hashgraphonline/standards-sdk';
|
|
17
|
+
import { SignerProviderRegistry, type NetworkString } from '../../signing/signer-provider';
|
|
18
|
+
import type { HCS6TopicRegistrationResult, HCS6RegistryOperationResult, HCS6CreateHashinalResult } from '../../types/tx-results';
|
|
19
|
+
import { CodedError } from '../../utils/CodedError';
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
* Builder for HCS-6 operations that delegates to HCS6Client
|
|
@@ -57,7 +60,31 @@ export class HCS6Builder extends BaseServiceBuilder {
|
|
|
57
60
|
*/
|
|
58
61
|
async createRegistry(
|
|
59
62
|
options: HCS6CreateRegistryOptions = {}
|
|
60
|
-
): Promise<
|
|
63
|
+
): Promise<HCS6TopicRegistrationResult> {
|
|
64
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
65
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
66
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
67
|
+
|
|
68
|
+
if (exec) {
|
|
69
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
70
|
+
if (start) {
|
|
71
|
+
try {
|
|
72
|
+
const request: Record<string, unknown> = { options };
|
|
73
|
+
const { transactionBytes } = await start('hcs6.createRegistry', request, network);
|
|
74
|
+
if (transactionBytes) {
|
|
75
|
+
return { success: true, transactionBytes };
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
if (preferWallet) {
|
|
79
|
+
throw new CodedError('wallet_submit_failed', `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (preferWallet) {
|
|
84
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs6.createRegistry');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
61
88
|
const client = await this.getHCS6Client();
|
|
62
89
|
const sanitized = { ...options };
|
|
63
90
|
if ('adminKey' in sanitized) {
|
|
@@ -72,7 +99,31 @@ export class HCS6Builder extends BaseServiceBuilder {
|
|
|
72
99
|
async registerEntry(
|
|
73
100
|
registryTopicId: string,
|
|
74
101
|
options: HCS6RegisterEntryOptions
|
|
75
|
-
): Promise<
|
|
102
|
+
): Promise<HCS6RegistryOperationResult> {
|
|
103
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
104
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
105
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
106
|
+
|
|
107
|
+
if (exec) {
|
|
108
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
109
|
+
if (start) {
|
|
110
|
+
try {
|
|
111
|
+
const request: Record<string, unknown> = { registryTopicId, options };
|
|
112
|
+
const { transactionBytes } = await start('hcs6.registerEntry', request, network);
|
|
113
|
+
if (transactionBytes) {
|
|
114
|
+
return { success: true, transactionBytes };
|
|
115
|
+
}
|
|
116
|
+
} catch (err) {
|
|
117
|
+
if (preferWallet) {
|
|
118
|
+
throw new CodedError('wallet_submit_failed', `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (preferWallet) {
|
|
123
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs6.registerEntry');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
76
127
|
const client = await this.getHCS6Client();
|
|
77
128
|
return await client.registerEntry(registryTopicId, options);
|
|
78
129
|
}
|
|
@@ -140,9 +191,33 @@ export class HCS6Builder extends BaseServiceBuilder {
|
|
|
140
191
|
async submitMessage(
|
|
141
192
|
topicId: string,
|
|
142
193
|
payload: any
|
|
143
|
-
): Promise<
|
|
194
|
+
): Promise<HCS6RegistryOperationResult> {
|
|
195
|
+
const exec = SignerProviderRegistry.walletExecutor;
|
|
196
|
+
const preferWallet = SignerProviderRegistry.preferWalletOnly;
|
|
197
|
+
const network = (this.hederaKit.client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet') as NetworkString;
|
|
198
|
+
|
|
199
|
+
if (exec) {
|
|
200
|
+
const start = SignerProviderRegistry.startHCSDelegate;
|
|
201
|
+
if (start) {
|
|
202
|
+
try {
|
|
203
|
+
const request: Record<string, unknown> = { topicId, payload };
|
|
204
|
+
const { transactionBytes } = await start('hcs6.submitMessage', request, network);
|
|
205
|
+
if (transactionBytes) {
|
|
206
|
+
return { success: true, transactionBytes } as unknown as HCS6RegistryOperationResult;
|
|
207
|
+
}
|
|
208
|
+
} catch (err) {
|
|
209
|
+
if (preferWallet) {
|
|
210
|
+
throw new CodedError('wallet_submit_failed', `wallet_submit_failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (preferWallet) {
|
|
215
|
+
throw new CodedError('wallet_unavailable', 'WalletExecutor not configured for hcs6.submitMessage');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
144
219
|
const client = await this.getHCS6Client();
|
|
145
|
-
return await client.submitMessage(topicId, payload);
|
|
220
|
+
return await client.submitMessage(topicId, payload) as unknown as HCS6RegistryOperationResult;
|
|
146
221
|
}
|
|
147
222
|
|
|
148
223
|
/**
|
package/src/hcs10/HCS10Client.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,4 +8,8 @@ export { HCS10Builder, HCS2Builder, HCS6Builder, InscriberBuilder } from './buil
|
|
|
8
8
|
export type { ExecuteResult } from './builders';
|
|
9
9
|
export { HCS10Client } from './hcs10';
|
|
10
10
|
export type { ContentReferenceConfig } from './config/ContentReferenceConfig';
|
|
11
|
-
export { loadConfig } from './config/ContentReferenceConfig';
|
|
11
|
+
export { loadConfig } from './config/ContentReferenceConfig';
|
|
12
|
+
export { SignerProviderRegistry } from './signing/signer-provider';
|
|
13
|
+
export type { DAppSigner, WalletInfo, WalletExecutor, StartHCSDelegate, NetworkString } from './signing/signer-provider';
|
|
14
|
+
export { ByteBuildRegistry } from './signing/bytes-registry';
|
|
15
|
+
export type { ByteBuildHandler } from './signing/bytes-registry';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ZodType } from 'zod';
|
|
2
2
|
import { RenderConfigSchema, EnhancedRenderConfig, ZodSchemaWithRender, FormFieldType, FieldMetadata, SelectOption } from './types';
|
|
3
3
|
|
|
4
|
-
// Type definitions for extended Zod schemas - using Record to extend existing properties
|
|
5
4
|
interface ExtendedZodSchema {
|
|
6
5
|
description?: string;
|
|
7
6
|
merge?: (other: ZodType<unknown>) => ZodType<unknown>;
|