gn-provider 1.1.4 → 1.1.5
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/gn-provider.d.ts +1 -0
- package/dist/gn-provider.js +24 -0
- package/package.json +1 -1
package/dist/gn-provider.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare class GNProvider extends Provider {
|
|
|
20
20
|
getNetwork: () => scryptlib.bsv.Networks.Network;
|
|
21
21
|
protected _ready: () => Promise<void>;
|
|
22
22
|
sendRawTransaction: (rawTxHex: string) => Promise<TxHash>;
|
|
23
|
+
sendTransaction: (signedTx: scryptlib.bsv.Transaction) => Promise<string>;
|
|
23
24
|
listUnspent: (address: AddressOption, options?: UtxoQueryOptions) => Promise<UTXO[]>;
|
|
24
25
|
getBalance: (address: AddressOption) => Promise<{
|
|
25
26
|
confirmed: number;
|
package/dist/gn-provider.js
CHANGED
|
@@ -182,6 +182,30 @@ class GNProvider extends abstract_provider_1.Provider {
|
|
|
182
182
|
throw new Error(`GNProvider ERROR: ${error.message}`);
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
|
+
// Implementación correcta de sendTransaction
|
|
186
|
+
this.sendTransaction = (signedTx) => __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
try {
|
|
188
|
+
const txHex = signedTx.serialize({ disableIsFullySigned: true });
|
|
189
|
+
return yield this.sendRawTransaction(txHex);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
// Manejo seguro del error unknown
|
|
193
|
+
let errorMessage = "Unknown error occurred";
|
|
194
|
+
if (error instanceof Error) {
|
|
195
|
+
errorMessage = error.message;
|
|
196
|
+
}
|
|
197
|
+
else if (typeof error === "string") {
|
|
198
|
+
errorMessage = error;
|
|
199
|
+
}
|
|
200
|
+
else if (error && typeof error === "object" && "message" in error) {
|
|
201
|
+
errorMessage = String(error.message);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
errorMessage = JSON.stringify(error);
|
|
205
|
+
}
|
|
206
|
+
throw new Error(`GNProvider ERROR: failed to send transaction: ${errorMessage}`);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
185
209
|
//async listUnspent(address: AddressOption, options?: UtxoQueryOptions): Promise<UTXO[]> {
|
|
186
210
|
this.listUnspent = (address, options) => __awaiter(this, void 0, void 0, function* () {
|
|
187
211
|
yield this._ready();
|