diff --git a/package.json b/package.json index 78a0fe8a..fd0d33f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "warp-contracts", - "version": "1.4.18", + "version": "1.4.19", "description": "An implementation of the SmartWeave smart contract protocol.", "types": "./lib/types/index.d.ts", "main": "./lib/cjs/index.js", diff --git a/src/__tests__/integration/internal-writes/internal-nested-read.test.ts b/src/__tests__/integration/internal-writes/internal-nested-read.test.ts index 5d3f1d93..e54ba7ee 100644 --- a/src/__tests__/integration/internal-writes/internal-nested-read.test.ts +++ b/src/__tests__/integration/internal-writes/internal-nested-read.test.ts @@ -6,9 +6,9 @@ import path from 'path'; import { mineBlock } from '../_helpers'; import { Contract } from '../../../contract/Contract'; import { Warp } from '../../../core/Warp'; -import { WarpFactory } from "../../../core/WarpFactory"; +import { WarpFactory } from '../../../core/WarpFactory'; import { LoggerFactory } from '../../../logging/LoggerFactory'; -import { DeployPlugin } from "warp-contracts-plugin-deploy"; +import { DeployPlugin } from 'warp-contracts-plugin-deploy'; /** * This test verifies "deep" reads between contracts. @@ -61,9 +61,15 @@ describe('Testing deep internal reads', () => { ({ jwk: wallet } = await warp.generateWallet()); const leafSrc = fs.readFileSync(path.join(__dirname, '../data/nested-read/leaf-contract.js'), 'utf8'); - const leafState = fs.readFileSync(path.join(__dirname, '../data/nested-read/leaf-contract-init-state.json'), 'utf8'); + const leafState = fs.readFileSync( + path.join(__dirname, '../data/nested-read/leaf-contract-init-state.json'), + 'utf8' + ); const nodeSrc = fs.readFileSync(path.join(__dirname, '../data/nested-read/node-contract.js'), 'utf8'); - const nodeState = fs.readFileSync(path.join(__dirname, '../data/nested-read/node-contract-init-state.json'), 'utf8'); + const nodeState = fs.readFileSync( + path.join(__dirname, '../data/nested-read/node-contract-init-state.json'), + 'utf8' + ); ({ contractTxId: leafId } = await warp.deploy({ wallet, @@ -101,24 +107,12 @@ describe('Testing deep internal reads', () => { src: nodeSrc })); - rootContract = warp - .contract(rootId) - .connect(wallet); - node20Contract = warp - .contract(node20Id) - .connect(wallet); - node21Contract = warp - .contract(node21Id) - .connect(wallet); - node22Contract = warp - .contract(node22Id) - .connect(wallet); - node1Contract = warp - .contract(nod1Id) - .connect(wallet); - leafContract = warp - .contract(leafId) - .connect(wallet); + rootContract = warp.contract(rootId).connect(wallet); + node20Contract = warp.contract(node20Id).connect(wallet); + node21Contract = warp.contract(node21Id).connect(wallet); + node22Contract = warp.contract(node22Id).connect(wallet); + node1Contract = warp.contract(nod1Id).connect(wallet); + leafContract = warp.contract(leafId).connect(wallet); await mineBlock(warp); await mineBlock(warp); @@ -158,20 +152,33 @@ describe('Testing deep internal reads', () => { await mineBlock(warp); await node21Contract.writeInteraction({ function: 'readBalanceFrom', tokenAddress: leafId, contractTxId: 'asd' }); await mineBlock(warp); - await node1Contract.writeInteraction({ function: 'readBalanceFrom', tokenAddress: node20Id, contractTxId: 'asd' }); + await node1Contract.writeInteraction({ + function: 'readBalanceFrom', + tokenAddress: node20Id, + contractTxId: 'asd' + }); await mineBlock(warp); - await node1Contract.writeInteraction({ function: 'readBalanceFrom', tokenAddress: node21Id, contractTxId: 'asd' }); + await node1Contract.writeInteraction({ + function: 'readBalanceFrom', + tokenAddress: node21Id, + contractTxId: 'asd' + }); await mineBlock(warp); - await node1Contract.writeInteraction({ function: 'readBalanceFrom', tokenAddress: node22Id, contractTxId: 'asd' }); + await node1Contract.writeInteraction({ + function: 'readBalanceFrom', + tokenAddress: node22Id, + contractTxId: 'asd' + }); await mineBlock(warp); await rootContract.writeInteraction({ function: 'readBalanceFrom', tokenAddress: nod1Id, contractTxId: 'asd' }); await mineBlock(warp); - - const rootResult = await warp.pst(rootId) + const rootResult = await warp + .pst(rootId) .setEvaluationOptions({ - cacheEveryNInteractions: 1, - }).readState(); + cacheEveryNInteractions: 1 + }) + .readState(); expect(rootResult.cachedValue.state.balances['asd']).toEqual(1100); const node20Result = await warp.pst(node20Id).readState(); 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 e45a145f..5d2b12f3 100644 --- a/src/__tests__/integration/internal-writes/internal-write-callee.test.ts +++ b/src/__tests__/integration/internal-writes/internal-write-callee.test.ts @@ -221,7 +221,7 @@ describe('Testing internal writes', () => { async function currentContractEntries(contractTxId: string): Promise<[[string, string]]> { const storage: MemoryLevel = await warp.stateEvaluator.getCache().storage(); - const sub = storage.sublevel(contractTxId, { valueEncoding: "json" }); + const sub = storage.sublevel(contractTxId, { valueEncoding: 'json' }); return await sub.iterator().all(); } @@ -271,7 +271,9 @@ describe('Testing internal writes', () => { expect(entries2.length).toEqual(5); const lastCacheValue = await warp.stateEvaluator.getCache().getLast(calleeContract.txId()); expect(lastCacheValue.cachedValue.state).toEqual(result1.cachedValue.state); - expect(Object.keys(result1.cachedValue.errorMessages).length + 1).toEqual(Object.keys(lastCacheValue.cachedValue.errorMessages).length); + expect(Object.keys(result1.cachedValue.errorMessages).length + 1).toEqual( + Object.keys(lastCacheValue.cachedValue.errorMessages).length + ); const blockHeight = (await warp.arweave.network.getInfo()).height; expect(lastCacheValue.sortKey).toContain(`${blockHeight}`.padStart(12, '0')); @@ -290,7 +292,6 @@ describe('Testing internal writes', () => { const entries2 = await currentContractEntries(calleeContract.txId()); expect(entries2.length).toEqual(7); }); - }); describe('with read state at the end', () => {