diff --git a/package.json b/package.json index e0b86cf..094a3e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redstone-smartweave", - "version": "0.3.10-alpha.19", + "version": "0.4.0", "description": "An implementation of the SmartWeave SDK.", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", @@ -67,7 +67,7 @@ "@types/node": "^16.7.1", "@typescript-eslint/eslint-plugin": "^4.29.2", "@typescript-eslint/parser": "^4.29.2", - "arlocal": "1.1.4", + "arlocal": "1.1.13", "cheerio": "^1.0.0-rc.10", "cors": "^2.8.5", "eslint": "^7.32.0", diff --git a/src/__tests__/integration/deploy-write-read.test.ts b/src/__tests__/integration/deploy-write-read.test.ts index d067a2d..3715f55 100644 --- a/src/__tests__/integration/deploy-write-read.test.ts +++ b/src/__tests__/integration/deploy-write-read.test.ts @@ -52,12 +52,14 @@ describe('Testing the SmartWeave client', () => { initialState = fs.readFileSync(path.join(__dirname, 'data/example-contract-state.json'), 'utf8'); // deploying contract using the new SDK. + await addFunds(); const contractTxId = await smartweave.createContract.deploy({ wallet, initState: initialState, src: contractSrc }); + contract = smartweave.contract(contractTxId); contract.connect(wallet); @@ -99,4 +101,9 @@ describe('Testing the SmartWeave client', () => { async function mine() { await arweave.api.get('mine'); } + + async function addFunds() { + const walletAddress = await arweave.wallets.getAddress(wallet); + await arweave.api.get(`/mint/${walletAddress}/1000`); + } }); diff --git a/src/core/SmartWeaveBuilder.ts b/src/core/SmartWeaveBuilder.ts index 3d3b824..f80622c 100644 --- a/src/core/SmartWeaveBuilder.ts +++ b/src/core/SmartWeaveBuilder.ts @@ -1,5 +1,6 @@ import Arweave from 'arweave'; import { + BlockHeightSwCache, DebuggableExecutorFactory, DefinitionLoader, ExecutorFactory, diff --git a/src/core/modules/impl/DefaultCreateContract.ts b/src/core/modules/impl/DefaultCreateContract.ts index 6f78779..0e1fc7c 100644 --- a/src/core/modules/impl/DefaultCreateContract.ts +++ b/src/core/modules/impl/DefaultCreateContract.ts @@ -9,7 +9,7 @@ export class DefaultCreateContract implements CreateContract { this.deployFromSourceTx = this.deployFromSourceTx.bind(this); } - async deploy(contractData: ContractData) { + async deploy(contractData: ContractData): Promise { this.logger.debug('Creating new contract'); const { wallet, src, initState, tags, transfer } = contractData; diff --git a/src/core/web/SmartWeaveWebFactory.ts b/src/core/web/SmartWeaveWebFactory.ts index 07b6fdb..a0afb43 100644 --- a/src/core/web/SmartWeaveWebFactory.ts +++ b/src/core/web/SmartWeaveWebFactory.ts @@ -67,7 +67,11 @@ export class SmartWeaveWebFactory { * Returns a preconfigured, memCached {@link SmartWeaveBuilder}, that allows for customization of the SmartWeave instance. * Use {@link SmartWeaveBuilder.build()} to finish the configuration. */ - static memCachedBased(arweave: Arweave, maxStoredBlockHeights: number = Number.MAX_SAFE_INTEGER): SmartWeaveBuilder { + static memCachedBased( + arweave: Arweave, + maxStoredBlockHeights: number = Number.MAX_SAFE_INTEGER, + stateCache?: MemBlockHeightSwCache> + ): SmartWeaveBuilder { const definitionLoader = new ContractDefinitionLoader(arweave, new MemCache()); const interactionsLoader = new CacheableContractInteractionsLoader( @@ -79,7 +83,7 @@ export class SmartWeaveWebFactory { const stateEvaluator = new CacheableStateEvaluator( arweave, - new MemBlockHeightSwCache>(maxStoredBlockHeights), + stateCache ? stateCache : new MemBlockHeightSwCache>(maxStoredBlockHeights), [new Evolve(definitionLoader, executorFactory)] ); diff --git a/yarn.lock b/yarn.lock index f41c9ea..fac17e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1539,10 +1539,10 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -arlocal@1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/arlocal/-/arlocal-1.1.4.tgz#853d371573d1e055f13d0178b02a75de7927d129" - integrity sha512-SnQZ4MeRDnnLbkZRaDcq8gZeD1jBbTR6YEpOYD8gV/OhsNhURX/WuzKyzjiNdQCAs+mXpkpnRUNCnGDQE4gfMQ== +arlocal@1.1.13: + version "1.1.13" + resolved "https://registry.yarnpkg.com/arlocal/-/arlocal-1.1.13.tgz#a6875631c867bd377129b964a3aac4253964cf8a" + integrity sha512-zT8EZm71UTNtRw2FoxRRuojuUlfCTZOj9dz1uV9Z5tw5jTzB6ZUGCISo4W/G8iTvjAjZFmvFcq0OQW16x8gjEg== dependencies: "@koa/cors" "^3.1.0" apollo-server-koa "^2.25.1"