@flashbacktech/flashbackclient 0.1.34 → 0.1.36

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.
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withSignature = withSignature;
4
+ exports.withSignatureProperty = withSignatureProperty;
5
+ function withSignature(method) {
6
+ return async function (...args) {
7
+ const context = this.getContext();
8
+ if (!context.signTransaction) {
9
+ throw new Error("FlashOnStellarClient: signTransaction method is required for write operations");
10
+ }
11
+ return method.apply(this, args);
12
+ };
13
+ }
14
+ // For arrow functions/properties
15
+ function withSignatureProperty(target, propertyKey) {
16
+ const value = target[propertyKey];
17
+ Object.defineProperty(target, propertyKey, {
18
+ configurable: true,
19
+ enumerable: true,
20
+ get() {
21
+ return async (...args) => {
22
+ const context = this.getContext();
23
+ if (!context.signTransaction) {
24
+ throw new Error("FlashOnStellarClient: signTransaction method is required for write operations");
25
+ }
26
+ return value.apply(this, args);
27
+ };
28
+ },
29
+ });
30
+ }
@@ -0,0 +1,13 @@
1
+ export type Environment = "node" | "browser";
2
+ /**
3
+ * Detects the current runtime environment
4
+ */
5
+ export declare function getEnvironment(): Environment;
6
+ /**
7
+ * Checks if the code is running in a browser environment
8
+ */
9
+ export declare function isBrowser(): boolean;
10
+ /**
11
+ * Checks if the code is running in a Node.js environment
12
+ */
13
+ export declare function isNode(): boolean;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnvironment = getEnvironment;
4
+ exports.isBrowser = isBrowser;
5
+ exports.isNode = isNode;
6
+ /**
7
+ * Detects the current runtime environment
8
+ */
9
+ function getEnvironment() {
10
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
11
+ return "browser";
12
+ }
13
+ return "node";
14
+ }
15
+ /**
16
+ * Checks if the code is running in a browser environment
17
+ */
18
+ function isBrowser() {
19
+ return getEnvironment() === "browser";
20
+ }
21
+ /**
22
+ * Checks if the code is running in a Node.js environment
23
+ */
24
+ function isNode() {
25
+ return getEnvironment() === "node";
26
+ }
@@ -0,0 +1 @@
1
+ export declare const sleep: (ms: number) => Promise<void>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = void 0;
4
+ const getGlobalThis = () => {
5
+ if (typeof globalThis !== "undefined")
6
+ return globalThis;
7
+ if (typeof self !== "undefined")
8
+ return self;
9
+ if (typeof window !== "undefined")
10
+ return window;
11
+ if (typeof global !== "undefined")
12
+ return global;
13
+ throw new Error("Unable to locate global object");
14
+ };
15
+ const sleep = (ms) => {
16
+ const globalScope = getGlobalThis();
17
+ return new Promise((resolve) => globalScope.setTimeout(resolve, ms));
18
+ };
19
+ exports.sleep = sleep;
@@ -0,0 +1,2 @@
1
+ import { AccountResponse } from "@stellar/stellar-sdk/lib/horizon";
2
+ export declare function getBalances(accountAddress: string, network: string): Promise<AccountResponse["balances"]>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBalances = getBalances;
4
+ const transaction_1 = require("./transaction");
5
+ async function getBalances(accountAddress, network) {
6
+ const server = (0, transaction_1.getHorizonServer)(network);
7
+ const account = await server.loadAccount(accountAddress);
8
+ return account.balances;
9
+ }
@@ -0,0 +1,44 @@
1
+ import { ClientContext } from "../client/index";
2
+ export type ContractArg = {
3
+ value: string | number | bigint | boolean | null | undefined;
4
+ type: "string" | "symbol" | "address" | "u32" | "i32" | "u64" | "i64" | "bool";
5
+ };
6
+ export type ReadOperation<T> = {
7
+ method: string;
8
+ getArgs: (wallet_address: string, ...extraParams: any[]) => ContractArg[];
9
+ transformResult: (result: any) => T;
10
+ };
11
+ export type BatchedOperation<T> = {
12
+ operation: string;
13
+ params: any[];
14
+ transform: (result: any) => T;
15
+ };
16
+ export type BatchedWriteOperation = {
17
+ operation: string;
18
+ params: any[];
19
+ };
20
+ /**
21
+ * Executes multiple read operations in a single transaction
22
+ * @param context The client context
23
+ * @param wallet_address The wallet address to use for the operations
24
+ * @param operations Array of operations with their parameters to execute
25
+ * @returns Array of results in the same order as the input operations
26
+ */
27
+ export declare function batchReadOperations<T>(context: ClientContext, wallet_address: string, operations: BatchedOperation<T>[]): Promise<T[]>;
28
+ /**
29
+ * Creates a read operation with the given method and transform function
30
+ * @param method The contract method to call
31
+ * @param getArgs Function that generates the arguments for the method
32
+ * @param transformResult Function that transforms the raw result into the expected type
33
+ * @returns A ReadOperation object
34
+ */
35
+ export declare function createReadOperation<T>(method: string, getArgs: (wallet_address: string, ...extraParams: any[]) => ContractArg[], transformResult: (result: any) => T): ReadOperation<T>;
36
+ export declare function createOperationFromMethod<T>(method: string, transformResult: (result: any) => T): ReadOperation<T>;
37
+ /**
38
+ * Executes multiple write operations in a single transaction
39
+ * @param context The client context
40
+ * @param wallet_address The wallet address to use for the operations
41
+ * @param operations Array of operations with their parameters to execute
42
+ * @returns void
43
+ */
44
+ export declare function batchWriteOperations(context: ClientContext, wallet_address: string, operations: BatchedWriteOperation[]): Promise<void>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.batchReadOperations = batchReadOperations;
4
+ exports.createReadOperation = createReadOperation;
5
+ exports.createOperationFromMethod = createOperationFromMethod;
6
+ exports.batchWriteOperations = batchWriteOperations;
7
+ const transaction_1 = require("./transaction");
8
+ /**
9
+ * Executes multiple read operations in a single transaction
10
+ * @param context The client context
11
+ * @param wallet_address The wallet address to use for the operations
12
+ * @param operations Array of operations with their parameters to execute
13
+ * @returns Array of results in the same order as the input operations
14
+ */
15
+ async function batchReadOperations(context, wallet_address, operations) {
16
+ const contractCalls = operations.map(({ operation, params }) => ({
17
+ method: operation,
18
+ args: [
19
+ { value: wallet_address, type: "address" },
20
+ ...params.map((param) => ({ value: param, type: "string" })),
21
+ ],
22
+ }));
23
+ const response = await (0, transaction_1.prepareTransaction)(context, wallet_address, contractCalls);
24
+ if (!response.isSuccess || !response.isReadOnly) {
25
+ throw new Error("Batch read operation failed");
26
+ }
27
+ const results = Array.isArray(response.result)
28
+ ? response.result
29
+ : [response.result];
30
+ return operations.map(({ transform }, index) => transform(results[index]));
31
+ }
32
+ /**
33
+ * Creates a read operation with the given method and transform function
34
+ * @param method The contract method to call
35
+ * @param getArgs Function that generates the arguments for the method
36
+ * @param transformResult Function that transforms the raw result into the expected type
37
+ * @returns A ReadOperation object
38
+ */
39
+ function createReadOperation(method, getArgs, transformResult) {
40
+ return {
41
+ method,
42
+ getArgs,
43
+ transformResult,
44
+ };
45
+ }
46
+ function createOperationFromMethod(method, transformResult) {
47
+ return createReadOperation(method, (wallet_address, ...extraParams) => {
48
+ // First arg is always wallet_address
49
+ const args = [{ value: wallet_address, type: "address" }];
50
+ // Add any extra params as strings (or we could make this more sophisticated)
51
+ extraParams.forEach((param) => {
52
+ args.push({ value: param, type: "string" });
53
+ });
54
+ return args;
55
+ }, transformResult);
56
+ }
57
+ /**
58
+ * Executes multiple write operations in a single transaction
59
+ * @param context The client context
60
+ * @param wallet_address The wallet address to use for the operations
61
+ * @param operations Array of operations with their parameters to execute
62
+ * @returns void
63
+ */
64
+ async function batchWriteOperations(context, wallet_address, operations) {
65
+ const contractCalls = operations.map(({ operation, params }) => ({
66
+ method: operation,
67
+ args: [
68
+ { value: wallet_address, type: "address" },
69
+ ...params.map((param) => ({ value: param, type: "string" })),
70
+ ],
71
+ }));
72
+ const response = await (0, transaction_1.prepareTransaction)(context, wallet_address, contractCalls);
73
+ if (response.isSuccess && !response.isReadOnly) {
74
+ const signedTxXDR = await context.signTransaction(response.result);
75
+ await (0, transaction_1.sendTransaction)(context, signedTxXDR);
76
+ }
77
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./token";
2
+ export * from "./transaction";
3
+ export * from "./balance";
4
+ export * from "./batch";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./token"), exports);
18
+ __exportStar(require("./transaction"), exports);
19
+ __exportStar(require("./balance"), exports);
20
+ __exportStar(require("./batch"), exports);
@@ -0,0 +1,3 @@
1
+ import { StellarNetwork } from "./transaction";
2
+ declare const changeTrustXDR: (network: StellarNetwork, source: string, issuerPublikKey: string, asset_ticker: string, bRemove: boolean) => Promise<string>;
3
+ export { changeTrustXDR };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.changeTrustXDR = void 0;
4
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
5
+ const transaction_1 = require("./transaction");
6
+ const changeTrustXDR = async (network, source, issuerPublikKey, asset_ticker, bRemove) => {
7
+ const server = (0, transaction_1.getServer)(network);
8
+ const account = await server.getAccount(source);
9
+ const asset = new stellar_sdk_1.Asset(asset_ticker, issuerPublikKey);
10
+ const changeParams = bRemove ? { limit: "0" } : {};
11
+ const transaction = new stellar_sdk_1.TransactionBuilder(account, {
12
+ fee: stellar_sdk_1.BASE_FEE,
13
+ networkPassphrase: network.networkPassphrase,
14
+ })
15
+ .addOperation(stellar_sdk_1.Operation.changeTrust({
16
+ asset,
17
+ ...changeParams,
18
+ }))
19
+ .setTimeout(30)
20
+ .build();
21
+ return transaction.toXDR();
22
+ };
23
+ exports.changeTrustXDR = changeTrustXDR;
@@ -0,0 +1,38 @@
1
+ import { Transaction, Memo, MemoType, Operation, FeeBumpTransaction, Horizon } from "@stellar/stellar-sdk";
2
+ import { rpc } from "@stellar/stellar-sdk";
3
+ import { ClientContext } from "../client";
4
+ export interface StellarNetwork {
5
+ network: string;
6
+ networkPassphrase: string;
7
+ }
8
+ declare const getNetwork: (network: string) => StellarNetwork;
9
+ declare const getPublicKeyFromPrivateKey: (privateKey: string) => string;
10
+ declare const getServer: (network: StellarNetwork) => rpc.Server;
11
+ interface ContractMethodCall {
12
+ method: string;
13
+ args?: Array<{
14
+ value: number | string | bigint | boolean | null | undefined | Array<unknown>;
15
+ type: "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "string" | "symbol" | "address" | "bool" | "vec";
16
+ }>;
17
+ }
18
+ interface ContractMethodResponse {
19
+ isSuccess: boolean;
20
+ isReadOnly: boolean;
21
+ result: string | unknown;
22
+ }
23
+ export declare const getHorizonServer: (network: string) => Horizon.Server;
24
+ export declare const executeWalletTransaction: (context: ClientContext, wallet_address: string, method: string, additionalArgs?: Array<{
25
+ value: string | number | bigint | boolean | null | Array<unknown> | undefined;
26
+ type: "string" | "symbol" | "address" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bool" | "vec";
27
+ }>) => Promise<ContractMethodResponse>;
28
+ export declare const executeMultiWalletTransactions: (context: ClientContext, wallet_address: string, methods: Array<{
29
+ method: string;
30
+ additionalArgs?: Array<{
31
+ value: string | number | bigint | boolean | null | undefined;
32
+ type: "string" | "symbol" | "address" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bool" | "vec";
33
+ }>;
34
+ }>) => Promise<ContractMethodResponse>;
35
+ declare const prepareTransaction: (context: ClientContext, address: string, contractCalls: ContractMethodCall | ContractMethodCall[]) => Promise<ContractMethodResponse>;
36
+ declare const signTransaction: (context: ClientContext, xdrToSign: string, privateKey: string) => Promise<Transaction<Memo<MemoType>, Operation[]> | FeeBumpTransaction>;
37
+ declare const sendTransaction: (context: ClientContext, signedTransactionXDR: string, bDebug?: boolean) => Promise<any>;
38
+ export { prepareTransaction, sendTransaction, signTransaction, getNetwork, getPublicKeyFromPrivateKey, getServer, };
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getServer = exports.getPublicKeyFromPrivateKey = exports.getNetwork = exports.signTransaction = exports.sendTransaction = exports.prepareTransaction = exports.executeMultiWalletTransactions = exports.executeWalletTransaction = exports.getHorizonServer = void 0;
4
+ const timing_1 = require("../utils/timing");
5
+ // Polyfill for BigInt JSON serialization
6
+ BigInt.prototype.toJSON = function () {
7
+ return this.toString();
8
+ };
9
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
10
+ const stellar_sdk_2 = require("@stellar/stellar-sdk");
11
+ const getNetwork = (network) => {
12
+ let networkPassphrase = "";
13
+ switch (network) {
14
+ case "TESTNET":
15
+ networkPassphrase = "Test SDF Network ; September 2015";
16
+ break;
17
+ case "PUBLIC":
18
+ networkPassphrase = "Public Global Stellar Network ; September 2015";
19
+ break;
20
+ }
21
+ return { network, networkPassphrase };
22
+ };
23
+ exports.getNetwork = getNetwork;
24
+ const getPublicKeyFromPrivateKey = (privateKey) => {
25
+ const keypair = stellar_sdk_1.Keypair.fromSecret(privateKey);
26
+ return keypair.publicKey();
27
+ };
28
+ exports.getPublicKeyFromPrivateKey = getPublicKeyFromPrivateKey;
29
+ const getServer = (network) => {
30
+ let serverUrl = "";
31
+ switch (network.network) {
32
+ case "TESTNET":
33
+ serverUrl = "https://soroban-testnet.stellar.org";
34
+ break;
35
+ case "PUBLIC":
36
+ serverUrl = "https://rpc.stellar.org";
37
+ break;
38
+ }
39
+ // For newer versions of Stellar SDK, we need to allow HTTP connections
40
+ // even for HTTPS URLs due to how the SDK handles server connections
41
+ const server = new stellar_sdk_2.rpc.Server(serverUrl, {
42
+ allowHttp: true
43
+ });
44
+ return server;
45
+ };
46
+ exports.getServer = getServer;
47
+ const TIMEOUT_TRANSACTION = 60;
48
+ const getHorizonServer = (network) => {
49
+ if (network === "TESTNET") {
50
+ return new stellar_sdk_1.Horizon.Server("https://horizon-testnet.stellar.org", {
51
+ allowHttp: true
52
+ });
53
+ }
54
+ else {
55
+ return new stellar_sdk_1.Horizon.Server("https://horizon.stellar.org", {
56
+ allowHttp: true
57
+ });
58
+ }
59
+ };
60
+ exports.getHorizonServer = getHorizonServer;
61
+ const executeWalletTransaction = async (context, wallet_address, method, additionalArgs = []) => {
62
+ const response = await prepareTransaction(context, wallet_address, {
63
+ method,
64
+ args: [{ value: wallet_address, type: "address" }, ...additionalArgs],
65
+ });
66
+ if (response.isSuccess) {
67
+ if (response.isReadOnly) {
68
+ return response;
69
+ }
70
+ const signedTxXDR = await context.signTransaction(response.result);
71
+ const sendResponse = await sendTransaction(context, signedTxXDR);
72
+ return {
73
+ isSuccess: true,
74
+ isReadOnly: false,
75
+ result: sendResponse,
76
+ };
77
+ }
78
+ return response;
79
+ };
80
+ exports.executeWalletTransaction = executeWalletTransaction;
81
+ const executeMultiWalletTransactions = async (context, wallet_address, methods) => {
82
+ const contractCalls = methods.map(({ method, additionalArgs = [] }) => ({
83
+ method,
84
+ args: [
85
+ { value: wallet_address, type: "address" },
86
+ ...additionalArgs,
87
+ ],
88
+ }));
89
+ const response = await prepareTransaction(context, wallet_address, contractCalls);
90
+ if (response.isSuccess) {
91
+ if (response.isReadOnly) {
92
+ return response;
93
+ }
94
+ const signedTxXDR = await context.signTransaction(response.result);
95
+ const sendResponse = await sendTransaction(context, signedTxXDR);
96
+ return {
97
+ isSuccess: true,
98
+ isReadOnly: false,
99
+ result: sendResponse,
100
+ };
101
+ }
102
+ return response;
103
+ };
104
+ exports.executeMultiWalletTransactions = executeMultiWalletTransactions;
105
+ const prepareTransaction = async (context, address, contractCalls) => {
106
+ const contractAddress = context.contractAddress;
107
+ const contract = new stellar_sdk_1.Contract(contractAddress);
108
+ const server = getServer(context.network);
109
+ const sourceAccount = await server.getAccount(address);
110
+ const response = {
111
+ isSuccess: false,
112
+ isReadOnly: false,
113
+ result: "",
114
+ };
115
+ // Ensure contractCalls is an array
116
+ const calls = Array.isArray(contractCalls) ? contractCalls : [contractCalls];
117
+ // Convert raw values to ScVal for all calls
118
+ const convertedCalls = calls.map((call) => {
119
+ const converted = {
120
+ method: call.method,
121
+ args: call.args?.map((arg) => {
122
+ let scVal;
123
+ if (arg.type === "vec") {
124
+ if (arg.value === null) {
125
+ // Handle null vectors as None
126
+ scVal = (0, stellar_sdk_1.nativeToScVal)(null, { type: "vec" });
127
+ }
128
+ else if (Array.isArray(arg.value)) {
129
+ // Handle non-empty vectors
130
+ const vecScVals = arg.value.map((item) => (0, stellar_sdk_1.nativeToScVal)(item.value, { type: item.type }));
131
+ scVal = (0, stellar_sdk_1.nativeToScVal)({ vec: vecScVals }, { type: "vec" });
132
+ }
133
+ else {
134
+ // Fallback for invalid vector values
135
+ scVal = (0, stellar_sdk_1.nativeToScVal)(null, { type: "vec" });
136
+ }
137
+ }
138
+ else {
139
+ scVal = (0, stellar_sdk_1.nativeToScVal)(arg.value, { type: arg.type });
140
+ }
141
+ return scVal;
142
+ }) || [],
143
+ };
144
+ return converted;
145
+ });
146
+ const transactionBuilder = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
147
+ fee: stellar_sdk_1.BASE_FEE,
148
+ networkPassphrase: context.network.networkPassphrase,
149
+ });
150
+ // Add all operations to the transaction
151
+ convertedCalls.forEach((call) => {
152
+ transactionBuilder.addOperation(contract.call(call.method, ...call.args));
153
+ });
154
+ const builtTransaction = transactionBuilder
155
+ .setTimeout(TIMEOUT_TRANSACTION)
156
+ .build();
157
+ const sim = await server.simulateTransaction(builtTransaction);
158
+ if (stellar_sdk_2.rpc.Api.isSimulationSuccess(sim)) {
159
+ response.isSuccess = true;
160
+ const result = sim.result && sim.result.retval
161
+ ? (0, stellar_sdk_1.scValToNative)(sim.result.retval)
162
+ : undefined;
163
+ const footprint = sim.transactionData.getFootprint();
164
+ const isReadOnly = footprint.readOnly().length > 0 && footprint.readWrite().length === 0;
165
+ if (isReadOnly) {
166
+ response.isReadOnly = true;
167
+ response.result = result;
168
+ return response;
169
+ }
170
+ // For write operations, continue with the normal flow of returning the XDR
171
+ const preparedTransaction = await server.prepareTransaction(builtTransaction);
172
+ response.result = preparedTransaction.toXDR();
173
+ return response;
174
+ }
175
+ else {
176
+ if (stellar_sdk_2.rpc.Api.isSimulationError(sim)) {
177
+ throw new Error(`Transaction simulation error: ${JSON.stringify(sim.error)}`);
178
+ }
179
+ throw new Error("Transaction simulation failed");
180
+ }
181
+ };
182
+ exports.prepareTransaction = prepareTransaction;
183
+ const signTransaction = async (context, xdrToSign, privateKey) => {
184
+ const preparedTransaction = stellar_sdk_1.TransactionBuilder.fromXDR(xdrToSign, context.network.networkPassphrase);
185
+ const sourceKeypair = stellar_sdk_1.Keypair.fromSecret(privateKey);
186
+ preparedTransaction.sign(sourceKeypair);
187
+ return preparedTransaction;
188
+ };
189
+ exports.signTransaction = signTransaction;
190
+ const sendTransaction = async (context, signedTransactionXDR, bDebug = false) => {
191
+ const server = getServer(context.network);
192
+ const signedTransaction = stellar_sdk_1.TransactionBuilder.fromXDR(signedTransactionXDR, context.network.networkPassphrase);
193
+ // Submit the transaction to the Stellar-RPC server. The RPC server will
194
+ // then submit the transaction into the network for us. Then we will have to
195
+ // wait, polling `getTransaction` until the transaction completes.
196
+ try {
197
+ const sendResponse = await server.sendTransaction(signedTransaction);
198
+ if (sendResponse.status === "PENDING") {
199
+ let getResponse = await server.getTransaction(sendResponse.hash);
200
+ while (getResponse.status === "NOT_FOUND") {
201
+ // See if the transaction is complete
202
+ getResponse = await server.getTransaction(sendResponse.hash);
203
+ // Wait one second
204
+ await (0, timing_1.sleep)(1000);
205
+ }
206
+ if (getResponse.status === "SUCCESS") {
207
+ // Make sure the transaction's resultMetaXDR is not empty
208
+ if (!getResponse.resultMetaXdr) {
209
+ throw new Error("Empty resultMetaXDR in getTransaction response");
210
+ }
211
+ // Find the return value from the contract and return it
212
+ const transactionMeta = getResponse.resultMetaXdr;
213
+ const returnValue = transactionMeta.v3().sorobanMeta()?.returnValue();
214
+ if (returnValue) {
215
+ return (0, stellar_sdk_1.scValToNative)(returnValue);
216
+ }
217
+ return getResponse; // Return the full transaction response
218
+ }
219
+ else {
220
+ throw new Error(`Transaction failed: ${getResponse.resultXdr}`);
221
+ }
222
+ }
223
+ else {
224
+ throw new Error(sendResponse.errorResult?.toString() || "Unknown error");
225
+ }
226
+ }
227
+ catch (err) {
228
+ // Catch and report any errors we've thrown
229
+ throw new Error(`Transaction sending error: ${JSON.stringify(err)}`);
230
+ }
231
+ };
232
+ exports.sendTransaction = sendTransaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashbacktech/flashbackclient",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"