From 6f5fe49e34254d80c0917aa1cdc7f5ac05f1721e Mon Sep 17 00:00:00 2001 From: ppedziwiatr Date: Tue, 31 Aug 2021 10:20:36 +0200 Subject: [PATCH] testcase for issues with YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE contract --- _scripts/test-case.ts | 19 +++++++++++++++++++ package.json | 3 ++- src/contract-read.ts | 13 +++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 _scripts/test-case.ts diff --git a/_scripts/test-case.ts b/_scripts/test-case.ts new file mode 100644 index 0000000..e6655d0 --- /dev/null +++ b/_scripts/test-case.ts @@ -0,0 +1,19 @@ +import Arweave from 'arweave'; +import { readContract } from '../src'; + +async function main() { + const arweave = Arweave.init({ + host: 'arweave.net', // Hostname or IP address for a Arweave host + port: 443, // Port + protocol: 'https', // Network protocol http or https + timeout: 60000, // Network request timeouts in milliseconds + logging: false // Enable network request logging + }); + const contractTxId = 'YLVpmhSq5JmLltfg6R-5fL04rIRPrlSU22f6RQ6VyYE'; + + const { state, validity } = await readContract(arweave, contractTxId); +} + +main().catch((e) => { + console.error(e); +}); diff --git a/package.json b/package.json index fc56334..5c9e338 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "ts-node": "^10.2.1", "tslint": "^6.1.3", "tslint-config-prettier": "^1.18.0", - "typescript": "^4.3.4" + "typescript": "^4.3.4", + "ts-node": "^10.2.1" } } diff --git a/src/contract-read.ts b/src/contract-read.ts index b6c520a..4f7432f 100644 --- a/src/contract-read.ts +++ b/src/contract-read.ts @@ -107,6 +107,19 @@ export async function readContract( state = result.state; + // console.log('State before await', state); + console.log('Regulator account before await:', { + balance: state.accounts.regulator.balance, + vaults: state.accounts.regulator.vaults, + }); + await (async () => Promise.resolve()); + console.log('\nRegulator account after await:', { + balance: state.accounts.regulator.balance, + vaults: state.accounts.regulator.vaults, + }); + // console.log('\n\nState after await', state); + process.exit(0); + const settings = state.settings ? new Map(state.settings) : new Map(); const evolve: string = state.evolve || settings.get('evolve');