From d779edc4bc4bf123a593bbf0204c510f0d26633a Mon Sep 17 00:00:00 2001 From: ppe Date: Mon, 6 Feb 2023 15:11:52 +0100 Subject: [PATCH] v1.2.52 --- package.json | 2 +- src/contract/deploy/impl/SourceImpl.ts | 43 +++++++++++++------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 594166fa..ae1f6621 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "warp-contracts", - "version": "1.2.52-beta.2", + "version": "1.2.52", "description": "An implementation of the SmartWeave smart contract protocol.", "types": "./lib/types/index.d.ts", "main": "./lib/cjs/index.js", diff --git a/src/contract/deploy/impl/SourceImpl.ts b/src/contract/deploy/impl/SourceImpl.ts index 2a6e6b83..c48dffb8 100644 --- a/src/contract/deploy/impl/SourceImpl.ts +++ b/src/contract/deploy/impl/SourceImpl.ts @@ -1,17 +1,17 @@ /* eslint-disable */ import metering from 'warp-wasm-metering'; -import fs, {PathOrFileDescriptor} from 'fs'; -import {matchMutClosureDtor} from '../../../core/modules/impl/wasm/wasm-bindgen-tools'; -import {ArWallet, ContractType} from '../CreateContract'; -import {SmartWeaveTags} from '../../../core/SmartWeaveTags'; -import {LoggerFactory} from '../../../logging/LoggerFactory'; -import {Source} from '../Source'; -import {Buffer} from 'warp-isomorphic'; -import {Warp} from '../../../core/Warp'; -import {CustomSignature, Signature} from '../../../contract/Signature'; -import {WARP_GW_URL} from '../../../core/WarpFactory'; -import {TagsParser} from '../../../core/modules/impl/TagsParser'; -import {Transaction} from '../../../utils/types/arweave-types'; +import fs, { PathOrFileDescriptor } from 'fs'; +import { matchMutClosureDtor } from '../../../core/modules/impl/wasm/wasm-bindgen-tools'; +import { ArWallet, ContractType } from '../CreateContract'; +import { SmartWeaveTags } from '../../../core/SmartWeaveTags'; +import { LoggerFactory } from '../../../logging/LoggerFactory'; +import { Source } from '../Source'; +import { Buffer } from 'warp-isomorphic'; +import { Warp } from '../../../core/Warp'; +import { CustomSignature, Signature } from '../../../contract/Signature'; +import { WARP_GW_URL } from '../../../core/WarpFactory'; +import { TagsParser } from '../../../core/modules/impl/TagsParser'; +import { Transaction } from '../../../utils/types/arweave-types'; const wasmTypeMapping: Map = new Map([ [1, 'assemblyscript'], @@ -31,13 +31,12 @@ export class SourceImpl implements Source { private readonly logger = LoggerFactory.INST.create('Source'); private signature: Signature; - constructor(private readonly warp: Warp) { - } + constructor(private readonly warp: Warp) {} async createSourceTx(sourceData: SourceData, wallet: ArWallet | CustomSignature): Promise { this.logger.debug('Creating new contract source'); - const {src, wasmSrcCodeDir, wasmGlueCode} = sourceData; + const { src, wasmSrcCodeDir, wasmGlueCode } = sourceData; this.signature = new Signature(this.warp, wallet); const signer = this.signature.signer; @@ -60,7 +59,6 @@ export class SourceImpl implements Source { const moduleImports = WebAssembly.Module.imports(wasmModule); let lang: number; - // @ts-ignore const module: WebAssembly.Instance = await WebAssembly.instantiate(src, dummyImports(moduleImports)); // @ts-ignore @@ -77,7 +75,9 @@ export class SourceImpl implements Source { wasmLang = wasmTypeMapping.get(lang); if (wasmLang != 'rust') { - throw new Error('Support for for Go and AssemblyScript contract has been dropped. See https://github.com/warp-contracts/warp/issues/348'); + throw new Error( + 'Support for for Go and AssemblyScript contract has been dropped. See https://github.com/warp-contracts/warp/issues/348' + ); } if (wasmSrcCodeDir == null) { throw new Error('No path to original wasm contract source code'); @@ -97,7 +97,7 @@ export class SourceImpl implements Source { const allData = contractType == 'wasm' ? this.joinBuffers(data) : src; - srcTx = await this.warp.arweave.createTransaction({data: allData}); + srcTx = await this.warp.arweave.createTransaction({ data: allData }); srcTx.addTag(SmartWeaveTags.APP_NAME, 'SmartWeaveContractSource'); // TODO: version should be taken from the current package.json version. @@ -181,7 +181,7 @@ export class SourceImpl implements Source { incrementAmount: 1000 * 1024 // grow by 1000 kilobytes each time buffer overflows. }); const archive = archiver('zip', { - zlib: {level: 9} // Sets the compression level. + zlib: { level: 9 } // Sets the compression level. }); archive.on('error', function (err: any) { throw err; @@ -197,7 +197,7 @@ export class SourceImpl implements Source { private async postSource(srcTx: Transaction = null): Promise { const response = await fetch(`${WARP_GW_URL}/gateway/sources/deploy`, { method: 'POST', - body: JSON.stringify({srcTx}), + body: JSON.stringify({ srcTx }), headers: { 'Accept-Encoding': 'gzip, deflate, br', 'Content-Type': 'application/json', @@ -222,8 +222,7 @@ function dummyImports(moduleImports: WebAssembly.ModuleImportDescriptor[]) { if (!Object.prototype.hasOwnProperty.call(imports, moduleImport.module)) { imports[moduleImport.module] = {}; } - imports[moduleImport.module][moduleImport.name] = function () { - }; + imports[moduleImport.module][moduleImport.name] = function () {}; }); return imports;