3
.prettierignore
Normal file
3
.prettierignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
lib
|
||||||
|
src/__tests__/integration/data
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "redstone-smartweave",
|
"name": "redstone-smartweave",
|
||||||
"version": "0.4.48",
|
"version": "0.4.50",
|
||||||
"description": "An implementation of the SmartWeave smart contract protocol.",
|
"description": "An implementation of the SmartWeave smart contract protocol.",
|
||||||
"main": "./lib/cjs/index.js",
|
"main": "./lib/cjs/index.js",
|
||||||
"module": "./lib/esm/index.js",
|
"module": "./lib/esm/index.js",
|
||||||
|
|||||||
1
src/__tests__/integration/data/wasm/as/assembly/contract.d.ts
vendored
Normal file
1
src/__tests__/integration/data/wasm/as/assembly/contract.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
declare function contract(a: any): any;
|
||||||
@@ -4,9 +4,9 @@ import Arweave from 'arweave';
|
|||||||
import { LoggerFactory } from '@smartweave/logging';
|
import { LoggerFactory } from '@smartweave/logging';
|
||||||
import { Go } from './wasm/go-wasm-imports';
|
import { Go } from './wasm/go-wasm-imports';
|
||||||
import metering from 'redstone-wasm-metering';
|
import metering from 'redstone-wasm-metering';
|
||||||
import fs, {PathOrFileDescriptor} from "fs";
|
import fs, { PathOrFileDescriptor } from 'fs';
|
||||||
import {matchMutClosureDtor} from "./wasm/wasm-bindgen-tools";
|
import { matchMutClosureDtor } from './wasm/wasm-bindgen-tools';
|
||||||
import {parseInt} from "lodash";
|
import { parseInt } from 'lodash';
|
||||||
|
|
||||||
const wasmTypeMapping: Map<number, string> = new Map([
|
const wasmTypeMapping: Map<number, string> = new Map([
|
||||||
[1, 'assemblyscript'],
|
[1, 'assemblyscript'],
|
||||||
@@ -69,19 +69,19 @@ export class DefaultCreateContract implements CreateContract {
|
|||||||
|
|
||||||
wasmLang = wasmTypeMapping.get(lang);
|
wasmLang = wasmTypeMapping.get(lang);
|
||||||
if (wasmSrcCodeDir == null) {
|
if (wasmSrcCodeDir == null) {
|
||||||
throw new Error("No path to original wasm contract source code");
|
throw new Error('No path to original wasm contract source code');
|
||||||
}
|
}
|
||||||
|
|
||||||
const zippedSourceCode = await this.zipContents(wasmSrcCodeDir);
|
const zippedSourceCode = await this.zipContents(wasmSrcCodeDir);
|
||||||
data.push(zippedSourceCode);
|
data.push(zippedSourceCode);
|
||||||
|
|
||||||
if (wasmLang == "rust") {
|
if (wasmLang == 'rust') {
|
||||||
if (!wasmGlueCodePath) {
|
if (!wasmGlueCodePath) {
|
||||||
throw new Error("No path to generated wasm-bindgen js code");
|
throw new Error('No path to generated wasm-bindgen js code');
|
||||||
}
|
}
|
||||||
const wasmBindgenSrc = fs.readFileSync(wasmGlueCodePath, "utf-8");
|
const wasmBindgenSrc = fs.readFileSync(wasmGlueCodePath, 'utf-8');
|
||||||
const dtor = matchMutClosureDtor(wasmBindgenSrc);
|
const dtor = matchMutClosureDtor(wasmBindgenSrc);
|
||||||
metadata["dtor"] = parseInt(dtor);
|
metadata['dtor'] = parseInt(dtor);
|
||||||
data.push(Buffer.from(wasmBindgenSrc));
|
data.push(Buffer.from(wasmBindgenSrc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,11 +174,11 @@ export class DefaultCreateContract implements CreateContract {
|
|||||||
private joinBuffers(buffers: Buffer[]): Buffer {
|
private joinBuffers(buffers: Buffer[]): Buffer {
|
||||||
const length = buffers.length;
|
const length = buffers.length;
|
||||||
const result = [];
|
const result = [];
|
||||||
result.push(Buffer.from(length.toString()))
|
result.push(Buffer.from(length.toString()));
|
||||||
result.push(Buffer.from("|"))
|
result.push(Buffer.from('|'));
|
||||||
buffers.forEach(b => {
|
buffers.forEach((b) => {
|
||||||
result.push(Buffer.from(b.length.toString()));
|
result.push(Buffer.from(b.length.toString()));
|
||||||
result.push(Buffer.from("|"))
|
result.push(Buffer.from('|'));
|
||||||
});
|
});
|
||||||
result.push(...buffers);
|
result.push(...buffers);
|
||||||
return result.reduce((prev, b) => Buffer.concat([prev, b]));
|
return result.reduce((prev, b) => Buffer.concat([prev, b]));
|
||||||
@@ -188,8 +188,8 @@ export class DefaultCreateContract implements CreateContract {
|
|||||||
const archiver = require('archiver'),
|
const archiver = require('archiver'),
|
||||||
streamBuffers = require('stream-buffers');
|
streamBuffers = require('stream-buffers');
|
||||||
const outputStreamBuffer = new streamBuffers.WritableStreamBuffer({
|
const outputStreamBuffer = new streamBuffers.WritableStreamBuffer({
|
||||||
initialSize: (1000 * 1024), // start at 1000 kilobytes.
|
initialSize: 1000 * 1024, // start at 1000 kilobytes.
|
||||||
incrementAmount: (1000 * 1024) // grow by 1000 kilobytes each time buffer overflows.
|
incrementAmount: 1000 * 1024 // grow by 1000 kilobytes each time buffer overflows.
|
||||||
});
|
});
|
||||||
const archive = archiver('zip', {
|
const archive = archiver('zip', {
|
||||||
zlib: { level: 9 } // Sets the compression level.
|
zlib: { level: 9 } // Sets the compression level.
|
||||||
|
|||||||
Reference in New Issue
Block a user