diff --git a/src/contract/Contract.ts b/src/contract/Contract.ts index 38ebbf7..0e3a604 100644 --- a/src/contract/Contract.ts +++ b/src/contract/Contract.ts @@ -17,6 +17,16 @@ export type BenchmarkStats = { gatewayCommunication: number; stateEvaluation: nu export type SigningFunction = (tx: Transaction) => Promise; +interface BundlrResponse { + id: string; + public: string; + signature: string; + block: number; +} +export interface BundleInteractionResponse { + bundlrResponse: BundlrResponse; + originalTxId: string; +} /** * Interface describing state for all Evolve-compatible contracts. */ @@ -171,7 +181,7 @@ export interface Contract extends Source { strict?: boolean; vrf?: boolean; } - ): Promise; + ): Promise; /** * Returns the full call tree report the last @@ -243,5 +253,5 @@ export interface Contract extends Source { * and its transaction to be confirmed by the network. * @param newSrcTxId - result of the {@link save} method call. */ - evolve(newSrcTxId: string, useBundler?: boolean): Promise; + evolve(newSrcTxId: string, useBundler?: boolean): Promise; } diff --git a/src/contract/HandlerBasedContract.ts b/src/contract/HandlerBasedContract.ts index 5fb3a5f..ed7561a 100644 --- a/src/contract/HandlerBasedContract.ts +++ b/src/contract/HandlerBasedContract.ts @@ -31,7 +31,8 @@ import { SourceType, Tags, SourceImpl, - SourceData + SourceData, + BundleInteractionResponse } from '@warp'; import { TransactionStatusResponse } from 'arweave/node/transactions'; import { NetworkInfoInterface } from 'arweave/node/network'; @@ -239,7 +240,7 @@ export class HandlerBasedContract implements Contract { strict: false, vrf: false } - ): Promise { + ): Promise { this.logger.info('Bundle interaction input', input); if (!this.signer) { throw new Error("Wallet not connected. Use 'connect' method first."); @@ -758,7 +759,7 @@ export class HandlerBasedContract implements Contract { return this; } - async evolve(newSrcTxId: string, useBundler = false): Promise { + async evolve(newSrcTxId: string, useBundler = false): Promise { if (useBundler) { return await this.bundleInteraction({ function: 'evolve', value: newSrcTxId }); } else { diff --git a/tools/bundle.ts b/tools/bundle.ts index a15c988..30876cf 100644 --- a/tools/bundle.ts +++ b/tools/bundle.ts @@ -1,6 +1,6 @@ /* eslint-disable */ import Arweave from 'arweave'; -import { LoggerFactory, WarpNodeFactory } from '../src'; +import {BundleInteractionResponse, LoggerFactory, WarpNodeFactory} from '../src'; import { TsLogFactory } from '../src/logging/node/TsLogFactory'; import path from 'path'; import knex from 'knex'; @@ -34,7 +34,7 @@ async function main() { useNullAsDefault: true }); - const warp = await WarpNodeFactory.knexCached(arweave, knexConfig); + const warp = await WarpNodeFactory.memCached(arweave); const wallet: JWKInterface = readJSON('.secrets/33F0QHcb22W7LwWR1iRC8Az1ntZG09XQ03YWuw2ABqA.json'); @@ -42,7 +42,7 @@ 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( + const {contractTxId, srcTxId} = await warp.createContract.deploy( { wallet, initState: initialState, @@ -52,6 +52,7 @@ async function main() { ); logger.info('tx id:', contractTxId); + logger.info('src tx id:', srcTxId); // connecting to a given contract const token = warp @@ -60,16 +61,18 @@ async function main() { // calling "writeInteraction" without connecting to a wallet first will cause a runtime error. .connect(wallet); - const result = await token.bundleInteraction( + const result: BundleInteractionResponse = await token.bundleInteraction( { function: 'vrf' }, { vrf: true } ); - const { state } = await token.readState(); + console.log(result.bundlrResponse); - logger.info('State', state.vrf); + /*const { state } = await token.readState(); + + logger.info('State', state.vrf);*/ /*const result = await token.writeInteraction({ function: "transfer",