From c2061e56be7f1722b779027f225719bfeccf37bd Mon Sep 17 00:00:00 2001 From: ppe Date: Tue, 10 May 2022 21:43:48 +0200 Subject: [PATCH] docs: readme update --- README.md | 12 ++++++++++++ tools/deploytest.ts | 28 ++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index dd3b839..5aecdf9 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,18 @@ All exports are stored under `rsdk` global variable. ``` ### Using the RedStone Gateway + +#### SDK version >= `0.5.0` +From version `0.5.0`, the RedStone Gateway is the default gateway used by the SDK. +By default, the `{notCorrupted: true}` mode is used (as describe below). +If you want to use the Arweave gateway in version >= `0.5.0`: +```ts +const smartweave = SmartWeaveNodeFactory.memCachedBased(arweave) + .useArweaveGateway() + .build(); +``` + +#### SDK version < `0.5.0` In order to use the [Redstone Gateway](https://github.com/redstone-finance/redstone-sw-gateway) for loading the contract interactions, configure the smartweave instance in the following way: ```ts diff --git a/tools/deploytest.ts b/tools/deploytest.ts index 404619f..6782c86 100644 --- a/tools/deploytest.ts +++ b/tools/deploytest.ts @@ -18,21 +18,18 @@ async function main() { }); try { - const smartweave = SmartWeaveNodeFactory - .memCachedBased(arweave) - .useRedStoneGateway() - .build(); + const smartweave = SmartWeaveNodeFactory.memCached(arweave); const jsContractSrc = fs.readFileSync(path.join(__dirname, 'data/js/token-pst.js'), 'utf8'); const wasmContractSrc = fs.readFileSync(path.join(__dirname, 'data/rust/rust-pst_bg.wasm')); const initialState = fs.readFileSync(path.join(__dirname, 'data/js/token-pst.json'), 'utf8'); // case 1 - full deploy, js contract - /* const contractTxId = await smartweave.createContract.deploy({ + const contractTxId = await smartweave.createContract.deploy({ wallet, initState: initialState, src: jsContractSrc, - }, true);*/ + }, true); // case 2 - deploy from source, js contract /*const contractTxId = await smartweave.createContract.deployFromSourceTx({ @@ -57,16 +54,27 @@ async function main() { srcTxId: "5wXT-A0iugP9pWEyw-iTbB0plZ_AbmvlNKyBfGS3AUY", }, true);*/ - const contract = smartweave.contract("CRMRwP-poSTYI7f9fI-vF0CKaTTJTIl74KQYbnJ4hnE").connect(wallet); + const contract = smartweave.contract(contractTxId).connect(wallet); - const result = await contract.writeInteraction({ + await contract.bundleInteraction({ function: "storeBalance", target: "M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI", }); - //const {state, validity} = await contract.readState(); + await contract.bundleInteraction({ + function: "storeBalance", + target: "M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI", + }); - //logger.info("Result", state); + await contract.bundleInteraction({ + function: "storeBalance", + target: "M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI", + }); + + const {state, validity} = await contract.readState(); + + logger.info("Result", state); + logger.info("Validity", validity); } catch (e) { logger.error(e)