Skip to content

Commit e2984a4

Browse files
committed
chore: appease linter
1 parent 4767ef6 commit e2984a4

File tree

1 file changed

+30
-35
lines changed

1 file changed

+30
-35
lines changed

src/contract/client.ts

+30-35
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import {
22
Operation,
3-
Transaction,
4-
TransactionBuilder,
53
xdr,
6-
Account,
74
hash,
85
Address,
96
} from "@stellar/stellar-base";
@@ -12,10 +9,38 @@ import { Server } from '../rpc';
129
import { AssembledTransaction } from "./assembled_transaction";
1310
import type { ClientOptions, MethodOptions } from "./types";
1411
import { processSpecEntryStream } from './utils';
15-
import { DEFAULT_TIMEOUT } from "./types";
1612

1713
const CONSTRUCTOR_FUNC = "__constructor";
1814

15+
async function specFromWasm(wasm: Buffer) {
16+
const wasmModule = await WebAssembly.compile(wasm);
17+
const xdrSections = WebAssembly.Module.customSections(
18+
wasmModule,
19+
"contractspecv0"
20+
);
21+
if (xdrSections.length === 0) {
22+
throw new Error("Could not obtain contract spec from wasm");
23+
}
24+
const bufferSection = Buffer.from(xdrSections[0]);
25+
const specEntryArray = processSpecEntryStream(bufferSection);
26+
const spec = new Spec(specEntryArray);
27+
return spec;
28+
}
29+
30+
async function specFromWasmHash(
31+
wasmHash: Buffer | string,
32+
options: Server.Options & { rpcUrl: string },
33+
format: "hex" | "base64" = "hex"
34+
): Promise<Spec> {
35+
if (!options || !options.rpcUrl) {
36+
throw new TypeError("options must contain rpcUrl");
37+
}
38+
const { rpcUrl, allowHttp } = options;
39+
const serverOpts: Server.Options = { allowHttp };
40+
const server = new Server(rpcUrl, serverOpts);
41+
const wasm = await server.getContractWasmByHash(wasmHash, format);
42+
return specFromWasm(wasm);
43+
}
1944

2045
/**
2146
* Generate a class from the contract spec that where each contract method
@@ -82,7 +107,7 @@ export class Client {
82107
...options,
83108
contractId,
84109
method: CONSTRUCTOR_FUNC,
85-
parseResultXdr: (result: xdr.ScVal) =>
110+
parseResultXdr: () =>
86111
new Client(spec, { ...options, contractId }),
87112
}) as unknown as AssembledTransaction<T>;
88113
}
@@ -193,34 +218,4 @@ export class Client {
193218
};
194219

195220
txFromXDR = <T>(xdrBase64: string): AssembledTransaction<T> => AssembledTransaction.fromXDR(this.options, xdrBase64, this.spec);
196-
197-
}
198-
async function specFromWasm(wasm: Buffer) {
199-
const wasmModule = await WebAssembly.compile(wasm);
200-
const xdrSections = WebAssembly.Module.customSections(
201-
wasmModule,
202-
"contractspecv0"
203-
);
204-
if (xdrSections.length === 0) {
205-
throw new Error("Could not obtain contract spec from wasm");
206-
}
207-
const bufferSection = Buffer.from(xdrSections[0]);
208-
const specEntryArray = processSpecEntryStream(bufferSection);
209-
const spec = new Spec(specEntryArray);
210-
return spec;
211-
}
212-
213-
async function specFromWasmHash(
214-
wasmHash: Buffer | string,
215-
options: Server.Options & { rpcUrl: string },
216-
format: "hex" | "base64" = "hex"
217-
): Promise<Spec> {
218-
if (!options || !options.rpcUrl) {
219-
throw new TypeError("options must contain rpcUrl");
220-
}
221-
const { rpcUrl, allowHttp } = options;
222-
const serverOpts: Server.Options = { allowHttp };
223-
const server = new Server(rpcUrl, serverOpts);
224-
const wasm = await server.getContractWasmByHash(wasmHash, format);
225-
return specFromWasm(wasm);
226221
}

0 commit comments

Comments
 (0)