Skip to content

Commit

Permalink
v1.2.52
Browse files Browse the repository at this point in the history
  • Loading branch information
ppedziwiatr committed Feb 6, 2023
1 parent e12182f commit d779edc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
43 changes: 21 additions & 22 deletions src/contract/deploy/impl/SourceImpl.ts
Original file line number Diff line number Diff line change
@@ -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<number, string> = new Map([
[1, 'assemblyscript'],
Expand All @@ -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<Transaction> {
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;
Expand All @@ -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
Expand All @@ -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');
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -197,7 +197,7 @@ export class SourceImpl implements Source {
private async postSource(srcTx: Transaction = null): Promise<any> {
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',
Expand All @@ -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;
Expand Down

0 comments on commit d779edc

Please sign in to comment.