Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ A breaking change will get clearly marked in this log.
* `rpc.Api.BalanceResponse` now can include a `revocable` field in its `balanceEntry` for when trustlines are fetched ([#1286](https://github.com/stellar/js-stellar-sdk/pull/1286/)).
* Added Timepoint and Duration support to `Spec` ([#1288](https://github.com/stellar/js-stellar-sdk/pull/1288))

### Fixed
* Remove `WebAssembly` usage in favor of manual wasm parsing ([#1300](https://github.com/stellar/js-stellar-sdk/pull/1300)).

## [v14.3.3](https://github.com/stellar/js-stellar-sdk/compare/v14.3.2...v14.3.3)

Expand Down
4 changes: 2 additions & 2 deletions src/contract/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ export class Spec {
* @returns {Promise<module:contract.Spec>} A Promise that resolves to a Spec instance.
* @throws {Error} If the contract spec cannot be obtained from the provided wasm binary.
*/
static async fromWasm(wasm: Buffer): Promise<Spec> {
const spec = await specFromWasm(wasm);
static fromWasm(wasm: Buffer): Spec {
const spec = specFromWasm(wasm);
return new Spec(spec);
}

Expand Down
16 changes: 3 additions & 13 deletions src/contract/wasm_spec_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,9 @@ import { parseWasmCustomSections } from "./utils";
* @returns The XDR buffer representing the contract spec.
* @throws {Error} If the contract spec cannot be obtained from the provided wasm binary.
*/
export async function specFromWasm(wasm: Buffer) {
let xdrSections: ArrayBuffer[] | undefined;

try {
const wasmModule = await WebAssembly.compile(wasm);
xdrSections = WebAssembly.Module.customSections(
wasmModule,
"contractspecv0",
);
} catch {
const customData = parseWasmCustomSections(wasm);
xdrSections = customData.get("contractspecv0");
}
export function specFromWasm(wasm: Buffer) {
const customData = parseWasmCustomSections(wasm);
let xdrSections = customData.get("contractspecv0");

if (!xdrSections || xdrSections.length === 0) {
throw new Error("Could not obtain contract spec from wasm");
Expand Down
12 changes: 8 additions & 4 deletions src/horizon/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,14 @@ export class HorizonServer {
);

return this.httpClient
.post(this.serverURL.clone().segment("transactions").toString(), `tx=${tx}`, {
timeout: SUBMIT_TRANSACTION_TIMEOUT,
headers: { "Content-Type": "application/x-www-form-urlencoded" },
})
.post(
this.serverURL.clone().segment("transactions").toString(),
`tx=${tx}`,
{
timeout: SUBMIT_TRANSACTION_TIMEOUT,
headers: { "Content-Type": "application/x-www-form-urlencoded" },
},
)
Comment thread
Ryang-21 marked this conversation as resolved.
.then((response) => {
if (!response.data.result_xdr) {
return response.data;
Expand Down
Loading