diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..5f969dd --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +node_modules +lib +src/__tests__/integration/data diff --git a/package.json b/package.json index f7e58c6..40c1783 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redstone-smartweave", - "version": "0.4.48", + "version": "0.4.50", "description": "An implementation of the SmartWeave smart contract protocol.", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/src/__tests__/integration/data/wasm/as/assembly/contract.d.ts b/src/__tests__/integration/data/wasm/as/assembly/contract.d.ts new file mode 100644 index 0000000..05fa6bd --- /dev/null +++ b/src/__tests__/integration/data/wasm/as/assembly/contract.d.ts @@ -0,0 +1 @@ +declare function contract(a: any): any; diff --git a/src/__tests__/integration/internal-writes/internal-write-back.test.ts b/src/__tests__/integration/internal-writes/internal-write-back.test.ts index abdec1d..046c437 100644 --- a/src/__tests__/integration/internal-writes/internal-write-back.test.ts +++ b/src/__tests__/integration/internal-writes/internal-write-back.test.ts @@ -3,10 +3,10 @@ import fs from 'fs'; import ArLocal from 'arlocal'; import Arweave from 'arweave'; -import {JWKInterface} from 'arweave/node/lib/wallet'; -import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave'; +import { JWKInterface } from 'arweave/node/lib/wallet'; +import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import {addFunds, mineBlock} from '../_helpers'; +import { addFunds, mineBlock } from '../_helpers'; /** * This test verifies "write-backs" between contracts: diff --git a/src/__tests__/integration/internal-writes/internal-write-callee.test.ts b/src/__tests__/integration/internal-writes/internal-write-callee.test.ts index a80f9d9..9f2bd84 100644 --- a/src/__tests__/integration/internal-writes/internal-write-callee.test.ts +++ b/src/__tests__/integration/internal-writes/internal-write-callee.test.ts @@ -3,10 +3,10 @@ import fs from 'fs'; import ArLocal from 'arlocal'; import Arweave from 'arweave'; -import {JWKInterface} from 'arweave/node/lib/wallet'; -import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave'; +import { JWKInterface } from 'arweave/node/lib/wallet'; +import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import {addFunds, mineBlock} from '../_helpers'; +import { addFunds, mineBlock } from '../_helpers'; interface ExampleContractState { counter: number; diff --git a/src/__tests__/integration/internal-writes/internal-write-caller.test.ts b/src/__tests__/integration/internal-writes/internal-write-caller.test.ts index 323ec04..367035a 100644 --- a/src/__tests__/integration/internal-writes/internal-write-caller.test.ts +++ b/src/__tests__/integration/internal-writes/internal-write-caller.test.ts @@ -3,11 +3,11 @@ import fs from 'fs'; import ArLocal from 'arlocal'; import Arweave from 'arweave'; -import {JWKInterface} from 'arweave/node/lib/wallet'; -import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave'; +import { JWKInterface } from 'arweave/node/lib/wallet'; +import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import {TsLogFactory} from '../../../logging/node/TsLogFactory'; -import {addFunds, mineBlock} from '../_helpers'; +import { TsLogFactory } from '../../../logging/node/TsLogFactory'; +import { addFunds, mineBlock } from '../_helpers'; /** * This verifies whether combination of read and write state works properly. diff --git a/src/__tests__/integration/internal-writes/internal-write-depth.test.ts b/src/__tests__/integration/internal-writes/internal-write-depth.test.ts index f56a4db..b5bf27a 100644 --- a/src/__tests__/integration/internal-writes/internal-write-depth.test.ts +++ b/src/__tests__/integration/internal-writes/internal-write-depth.test.ts @@ -3,11 +3,11 @@ import fs from 'fs'; import ArLocal from 'arlocal'; import Arweave from 'arweave'; -import {JWKInterface} from 'arweave/node/lib/wallet'; -import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave'; +import { JWKInterface } from 'arweave/node/lib/wallet'; +import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import {TsLogFactory} from '../../../logging/node/TsLogFactory'; -import {addFunds, mineBlock} from '../_helpers'; +import { TsLogFactory } from '../../../logging/node/TsLogFactory'; +import { addFunds, mineBlock } from '../_helpers'; /** * This test verifies "deep" writes between diff --git a/src/__tests__/integration/internal-writes/multi-internal-calls.test.ts b/src/__tests__/integration/internal-writes/multi-internal-calls.test.ts index 679c5da..ed6f0d2 100644 --- a/src/__tests__/integration/internal-writes/multi-internal-calls.test.ts +++ b/src/__tests__/integration/internal-writes/multi-internal-calls.test.ts @@ -3,11 +3,11 @@ import fs from 'fs'; import ArLocal from 'arlocal'; import Arweave from 'arweave'; -import {JWKInterface} from 'arweave/node/lib/wallet'; -import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave'; +import { JWKInterface } from 'arweave/node/lib/wallet'; +import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import {TsLogFactory} from '../../../logging/node/TsLogFactory'; -import {addFunds, mineBlock} from '../_helpers'; +import { TsLogFactory } from '../../../logging/node/TsLogFactory'; +import { addFunds, mineBlock } from '../_helpers'; /** * This test verifies multiple internal calls from diff --git a/src/__tests__/integration/internal-writes/staking.test.ts b/src/__tests__/integration/internal-writes/staking.test.ts index ad7d76f..8ec6380 100644 --- a/src/__tests__/integration/internal-writes/staking.test.ts +++ b/src/__tests__/integration/internal-writes/staking.test.ts @@ -3,11 +3,11 @@ import fs from 'fs'; import ArLocal from 'arlocal'; import Arweave from 'arweave'; -import {JWKInterface} from 'arweave/node/lib/wallet'; -import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave'; +import { JWKInterface } from 'arweave/node/lib/wallet'; +import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave'; import path from 'path'; -import {TsLogFactory} from '../../../logging/node/TsLogFactory'; -import {addFunds, mineBlock} from '../_helpers'; +import { TsLogFactory } from '../../../logging/node/TsLogFactory'; +import { addFunds, mineBlock } from '../_helpers'; /** * This tests verifies a standard approve/transferFrom workflow for a ERC-20ish token contract diff --git a/src/__tests__/regression/read-state.test.ts b/src/__tests__/regression/read-state.test.ts index 1e2c732..1f25619 100644 --- a/src/__tests__/regression/read-state.test.ts +++ b/src/__tests__/regression/read-state.test.ts @@ -1,9 +1,9 @@ /* eslint-disable */ import fs from 'fs'; import path from 'path'; -import {interactRead, readContract} from 'smartweave'; +import { interactRead, readContract } from 'smartweave'; import Arweave from 'arweave'; -import {LoggerFactory, SmartWeaveNodeFactory, SmartWeaveWebFactory, SourceType} from '@smartweave'; +import { LoggerFactory, SmartWeaveNodeFactory, SmartWeaveWebFactory, SourceType } from '@smartweave'; const stringify = require('safe-stable-stringify'); diff --git a/src/core/modules/impl/DefaultCreateContract.ts b/src/core/modules/impl/DefaultCreateContract.ts index 720a7ec..6373758 100644 --- a/src/core/modules/impl/DefaultCreateContract.ts +++ b/src/core/modules/impl/DefaultCreateContract.ts @@ -1,12 +1,12 @@ /* eslint-disable */ -import {ContractData, ContractType, CreateContract, FromSrcTxContractData, SmartWeaveTags} from '@smartweave/core'; +import { ContractData, ContractType, CreateContract, FromSrcTxContractData, SmartWeaveTags } from '@smartweave/core'; import Arweave from 'arweave'; -import {LoggerFactory} from '@smartweave/logging'; -import {Go} from './wasm/go-wasm-imports'; +import { LoggerFactory } from '@smartweave/logging'; +import { Go } from './wasm/go-wasm-imports'; import metering from 'redstone-wasm-metering'; -import fs, {PathOrFileDescriptor} from "fs"; -import {matchMutClosureDtor} from "./wasm/wasm-bindgen-tools"; -import {parseInt} from "lodash"; +import fs, { PathOrFileDescriptor } from 'fs'; +import { matchMutClosureDtor } from './wasm/wasm-bindgen-tools'; +import { parseInt } from 'lodash'; const wasmTypeMapping: Map = new Map([ [1, 'assemblyscript'], @@ -69,19 +69,19 @@ export class DefaultCreateContract implements CreateContract { wasmLang = wasmTypeMapping.get(lang); 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); data.push(zippedSourceCode); - if (wasmLang == "rust") { + if (wasmLang == 'rust') { 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); - metadata["dtor"] = parseInt(dtor); + metadata['dtor'] = parseInt(dtor); data.push(Buffer.from(wasmBindgenSrc)); } } @@ -174,11 +174,11 @@ export class DefaultCreateContract implements CreateContract { private joinBuffers(buffers: Buffer[]): Buffer { const length = buffers.length; const result = []; - result.push(Buffer.from(length.toString())) - result.push(Buffer.from("|")) - buffers.forEach(b => { + result.push(Buffer.from(length.toString())); + result.push(Buffer.from('|')); + buffers.forEach((b) => { result.push(Buffer.from(b.length.toString())); - result.push(Buffer.from("|")) + result.push(Buffer.from('|')); }); result.push(...buffers); return result.reduce((prev, b) => Buffer.concat([prev, b])); @@ -188,13 +188,13 @@ export class DefaultCreateContract implements CreateContract { const archiver = require('archiver'), streamBuffers = require('stream-buffers'); const outputStreamBuffer = new streamBuffers.WritableStreamBuffer({ - initialSize: (1000 * 1024), // start at 1000 kilobytes. - incrementAmount: (1000 * 1024) // grow by 1000 kilobytes each time buffer overflows. + initialSize: 1000 * 1024, // start at 1000 kilobytes. + 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) { + archive.on('error', function (err) { throw err; }); archive.pipe(outputStreamBuffer); diff --git a/src/core/modules/impl/wasm/go-wasm-imports.ts b/src/core/modules/impl/wasm/go-wasm-imports.ts index e3493ad..caabb36 100644 --- a/src/core/modules/impl/wasm/go-wasm-imports.ts +++ b/src/core/modules/impl/wasm/go-wasm-imports.ts @@ -9,7 +9,7 @@ /* tslint:disable */ /* eslint-disable */ /* YOLO */ -import {LoggerFactory, SmartWeaveGlobal} from '@smartweave'; +import { LoggerFactory, SmartWeaveGlobal } from '@smartweave'; const encoder = new TextEncoder(); const decoder = new TextDecoder('utf-8'); diff --git a/src/core/modules/impl/wasm/rust-wasm-imports.ts b/src/core/modules/impl/wasm/rust-wasm-imports.ts index 014ef03..8d62217 100644 --- a/src/core/modules/impl/wasm/rust-wasm-imports.ts +++ b/src/core/modules/impl/wasm/rust-wasm-imports.ts @@ -1,7 +1,7 @@ /* tslint:disable */ /* eslint-disable */ /* a kind of magic */ -import {LoggerFactory} from '@smartweave'; +import { LoggerFactory } from '@smartweave'; // note: this is (somewhat heavily) modified code // of the js that is normally generated by the wasm-bindgen diff --git a/src/legacy/smartweave-global.ts b/src/legacy/smartweave-global.ts index 781bcef..74803b2 100644 --- a/src/legacy/smartweave-global.ts +++ b/src/legacy/smartweave-global.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import Arweave from 'arweave'; -import {GQLNodeInterface, GQLTagInterface} from './gqlResult'; +import { GQLNodeInterface, GQLTagInterface } from './gqlResult'; /** * diff --git a/src/logging/web/ConsoleLogger.ts b/src/logging/web/ConsoleLogger.ts index 9ec75b9..199c31c 100644 --- a/src/logging/web/ConsoleLogger.ts +++ b/src/logging/web/ConsoleLogger.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import {LoggerSettings, LogLevel, lvlToOrder, RedStoneLogger} from '@smartweave'; +import { LoggerSettings, LogLevel, lvlToOrder, RedStoneLogger } from '@smartweave'; export class ConsoleLogger implements RedStoneLogger { constructor(private readonly moduleName, public settings: LoggerSettings) {}