SmartWeaveTags && SmartWeaveError
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
/* eslint-disable */
|
||||
import Arweave from 'arweave';
|
||||
import {
|
||||
LoggerFactory,
|
||||
WarpNodeFactory
|
||||
} from '../src';
|
||||
import { LoggerFactory, WarpNodeFactory } from '../src';
|
||||
import { TsLogFactory } from '../src/logging/node/TsLogFactory';
|
||||
import path from "path";
|
||||
import knex from "knex";
|
||||
import fs from "fs";
|
||||
import {JWKInterface} from "arweave/node/lib/wallet";
|
||||
import path from 'path';
|
||||
import knex from 'knex';
|
||||
import fs from 'fs';
|
||||
import { JWKInterface } from 'arweave/node/lib/wallet';
|
||||
|
||||
const logger = LoggerFactory.INST.create('Contract');
|
||||
|
||||
@@ -28,7 +25,6 @@ async function main() {
|
||||
logging: false // Enable network request logging
|
||||
});
|
||||
|
||||
|
||||
const cacheDir = path.join(__dirname, 'db');
|
||||
const knexConfig = knex({
|
||||
client: 'sqlite3',
|
||||
@@ -46,13 +42,16 @@ async function main() {
|
||||
const initialState = fs.readFileSync(path.join(__dirname, 'data/js/token-pst.json'), 'utf8');
|
||||
|
||||
// case 1 - full deploy, js contract
|
||||
const contractTxId = await warp.createContract.deploy({
|
||||
wallet,
|
||||
initState: initialState,
|
||||
src: jsContractSrc,
|
||||
}, true);
|
||||
const contractTxId = await warp.createContract.deploy(
|
||||
{
|
||||
wallet,
|
||||
initState: initialState,
|
||||
src: jsContractSrc
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
logger.info("tx id:", contractTxId);
|
||||
logger.info('tx id:', contractTxId);
|
||||
|
||||
// connecting to a given contract
|
||||
const token = warp
|
||||
@@ -61,25 +60,26 @@ async function main() {
|
||||
// calling "writeInteraction" without connecting to a wallet first will cause a runtime error.
|
||||
.connect(wallet);
|
||||
|
||||
const result = await token.bundleInteraction<any>({
|
||||
function: "vrf",
|
||||
}, {vrf: true});
|
||||
const result = await token.bundleInteraction<any>(
|
||||
{
|
||||
function: 'vrf'
|
||||
},
|
||||
{ vrf: true }
|
||||
);
|
||||
|
||||
console.log(result);
|
||||
const { state } = await token.readState();
|
||||
|
||||
const {state} = await token.readState();
|
||||
|
||||
logger.info("State", state.vrf);
|
||||
logger.info('State', state.vrf);
|
||||
|
||||
/*const result = await token.writeInteraction({
|
||||
function: "transfer",
|
||||
target: "33F0QHcb22W7LwWR1iRC8Az1ntZG09XQ03YWuw2ABqA",
|
||||
qty: 10
|
||||
}, [{
|
||||
name: WarpTags.INTERACT_WRITE,
|
||||
name: SmartWeaveTags.INTERACT_WRITE,
|
||||
value: "33F0QHcb22W7LwWR1iRC8Az1ntZG09XQ03YWuw2ABqA"
|
||||
},{
|
||||
name: WarpTags.INTERACT_WRITE,
|
||||
name: SmartWeaveTags.INTERACT_WRITE,
|
||||
value: "4MnaOd-GvsE5iVQD4OhdY8DOrH3vo0QEqOw31HeIzQ0"
|
||||
}
|
||||
]);*/
|
||||
@@ -88,7 +88,6 @@ async function main() {
|
||||
|
||||
//console.log(await redstoneLoader.load("33F0QHcb22W7LwWR1iRC8Az1ntZG09XQ03YWuw2ABqA", 0, 1_000_000));
|
||||
|
||||
|
||||
// UjZsNC0t5Ex7TjU8FIGLZcn_b3Af9OoNBuVmTAgp2_U
|
||||
/*const result1 = await token.readState();
|
||||
|
||||
@@ -111,8 +110,6 @@ async function main() {
|
||||
//await sleep(1);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
/*logger.info("Result from the sequencer", result);
|
||||
|
||||
// the new transaction is instantly available - ie. during the state read operation
|
||||
@@ -123,7 +120,7 @@ async function main() {
|
||||
}
|
||||
|
||||
function readJSON(path: string): JWKInterface {
|
||||
const content = fs.readFileSync(path, "utf-8");
|
||||
const content = fs.readFileSync(path, 'utf-8');
|
||||
try {
|
||||
return JSON.parse(content);
|
||||
} catch (e) {
|
||||
@@ -131,5 +128,4 @@ function readJSON(path: string): JWKInterface {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
main().catch((e) => console.error(e));
|
||||
|
||||
Reference in New Issue
Block a user