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;
|
||||||
@@ -3,10 +3,10 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import ArLocal from 'arlocal';
|
import ArLocal from 'arlocal';
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {JWKInterface} from 'arweave/node/lib/wallet';
|
import { JWKInterface } from 'arweave/node/lib/wallet';
|
||||||
import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave';
|
import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {addFunds, mineBlock} from '../_helpers';
|
import { addFunds, mineBlock } from '../_helpers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test verifies "write-backs" between contracts:
|
* This test verifies "write-backs" between contracts:
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import ArLocal from 'arlocal';
|
import ArLocal from 'arlocal';
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {JWKInterface} from 'arweave/node/lib/wallet';
|
import { JWKInterface } from 'arweave/node/lib/wallet';
|
||||||
import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave';
|
import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {addFunds, mineBlock} from '../_helpers';
|
import { addFunds, mineBlock } from '../_helpers';
|
||||||
|
|
||||||
interface ExampleContractState {
|
interface ExampleContractState {
|
||||||
counter: number;
|
counter: number;
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import ArLocal from 'arlocal';
|
import ArLocal from 'arlocal';
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {JWKInterface} from 'arweave/node/lib/wallet';
|
import { JWKInterface } from 'arweave/node/lib/wallet';
|
||||||
import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave';
|
import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {TsLogFactory} from '../../../logging/node/TsLogFactory';
|
import { TsLogFactory } from '../../../logging/node/TsLogFactory';
|
||||||
import {addFunds, mineBlock} from '../_helpers';
|
import { addFunds, mineBlock } from '../_helpers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This verifies whether combination of read and write state works properly.
|
* This verifies whether combination of read and write state works properly.
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import ArLocal from 'arlocal';
|
import ArLocal from 'arlocal';
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {JWKInterface} from 'arweave/node/lib/wallet';
|
import { JWKInterface } from 'arweave/node/lib/wallet';
|
||||||
import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave';
|
import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {TsLogFactory} from '../../../logging/node/TsLogFactory';
|
import { TsLogFactory } from '../../../logging/node/TsLogFactory';
|
||||||
import {addFunds, mineBlock} from '../_helpers';
|
import { addFunds, mineBlock } from '../_helpers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test verifies "deep" writes between
|
* This test verifies "deep" writes between
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import ArLocal from 'arlocal';
|
import ArLocal from 'arlocal';
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {JWKInterface} from 'arweave/node/lib/wallet';
|
import { JWKInterface } from 'arweave/node/lib/wallet';
|
||||||
import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave';
|
import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {TsLogFactory} from '../../../logging/node/TsLogFactory';
|
import { TsLogFactory } from '../../../logging/node/TsLogFactory';
|
||||||
import {addFunds, mineBlock} from '../_helpers';
|
import { addFunds, mineBlock } from '../_helpers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test verifies multiple internal calls from
|
* This test verifies multiple internal calls from
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import ArLocal from 'arlocal';
|
import ArLocal from 'arlocal';
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {JWKInterface} from 'arweave/node/lib/wallet';
|
import { JWKInterface } from 'arweave/node/lib/wallet';
|
||||||
import {Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory} from '@smartweave';
|
import { Contract, LoggerFactory, SmartWeave, SmartWeaveNodeFactory } from '@smartweave';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {TsLogFactory} from '../../../logging/node/TsLogFactory';
|
import { TsLogFactory } from '../../../logging/node/TsLogFactory';
|
||||||
import {addFunds, mineBlock} from '../_helpers';
|
import { addFunds, mineBlock } from '../_helpers';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tests verifies a standard approve/transferFrom workflow for a ERC-20ish token contract
|
* This tests verifies a standard approve/transferFrom workflow for a ERC-20ish token contract
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {interactRead, readContract} from 'smartweave';
|
import { interactRead, readContract } from 'smartweave';
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {LoggerFactory, SmartWeaveNodeFactory, SmartWeaveWebFactory, SourceType} from '@smartweave';
|
import { LoggerFactory, SmartWeaveNodeFactory, SmartWeaveWebFactory, SourceType } from '@smartweave';
|
||||||
|
|
||||||
const stringify = require('safe-stable-stringify');
|
const stringify = require('safe-stable-stringify');
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* eslint-disable */
|
/* 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 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,13 +188,13 @@ 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.
|
||||||
});
|
});
|
||||||
archive.on('error', function(err) {
|
archive.on('error', function (err) {
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
archive.pipe(outputStreamBuffer);
|
archive.pipe(outputStreamBuffer);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/* YOLO */
|
/* YOLO */
|
||||||
import {LoggerFactory, SmartWeaveGlobal} from '@smartweave';
|
import { LoggerFactory, SmartWeaveGlobal } from '@smartweave';
|
||||||
|
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const decoder = new TextDecoder('utf-8');
|
const decoder = new TextDecoder('utf-8');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/* a kind of magic */
|
/* a kind of magic */
|
||||||
import {LoggerFactory} from '@smartweave';
|
import { LoggerFactory } from '@smartweave';
|
||||||
|
|
||||||
// note: this is (somewhat heavily) modified code
|
// note: this is (somewhat heavily) modified code
|
||||||
// of the js that is normally generated by the wasm-bindgen
|
// of the js that is normally generated by the wasm-bindgen
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import Arweave from 'arweave';
|
import Arweave from 'arweave';
|
||||||
import {GQLNodeInterface, GQLTagInterface} from './gqlResult';
|
import { GQLNodeInterface, GQLTagInterface } from './gqlResult';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import {LoggerSettings, LogLevel, lvlToOrder, RedStoneLogger} from '@smartweave';
|
import { LoggerSettings, LogLevel, lvlToOrder, RedStoneLogger } from '@smartweave';
|
||||||
|
|
||||||
export class ConsoleLogger implements RedStoneLogger {
|
export class ConsoleLogger implements RedStoneLogger {
|
||||||
constructor(private readonly moduleName, public settings: LoggerSettings) {}
|
constructor(private readonly moduleName, public settings: LoggerSettings) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user