diff --git a/blank_project/src/main.js b/blank_project/src/main.js index b7e41da4..4af6a771 100755 --- a/blank_project/src/main.js +++ b/blank_project/src/main.js @@ -4,7 +4,7 @@ async function initContract() { // Initializing connection to the NEAR DevNet. - window.near = await nearlib.dev.connect(nearConfig); + window.near = await nearlib.connect(nearConfig); // Initializing our contract APIs by contract name and configuration. window.contract = await near.loadContract(nearConfig.contractName, { diff --git a/test_environment.js b/test_environment.js index 087f0424..714c122c 100644 --- a/test_environment.js +++ b/test_environment.js @@ -1,8 +1,6 @@ const NodeEnvironment = require('jest-environment-node'); -const dev = require('nearlib/dev'); -const fs = require('fs'); const nearlib = require('nearlib'); - +const fs = require('fs'); class LocalTestEnvironment extends NodeEnvironment { constructor(config) { @@ -11,7 +9,6 @@ class LocalTestEnvironment extends NodeEnvironment { async setup() { this.global.nearlib = require('nearlib'); - this.global.nearlib.dev = require('nearlib/dev'); this.global.window = {}; let config = require('./get-config')(); this.global.testSettings = config; @@ -21,18 +18,15 @@ class LocalTestEnvironment extends NodeEnvironment { }); config.deps = Object.assign(config.deps || {}, { storage: this.createFakeStorage(), - keyStore: new nearlib.InMemoryKeyStore(), + keyStore: new nearlib.keyStores.InMemoryKeyStore(), }); - const near = await dev.connect(config); - - const keyWithRandomSeed = await nearlib.KeyPair.fromRandomSeed(); - await config.deps.createAccount(config.contractName, keyWithRandomSeed.getPublicKey()); - config.deps.keyStore.setKey(config.contractName, keyWithRandomSeed); + const near = await nearlib.connect(config); - // deploy contract + const masterAccount = near.account('test.near'); + const randomKey = await nearlib.KeyPair.fromRandom('ed25519'); const data = [...fs.readFileSync('./out/main.wasm')]; - await near.waitForTransactionResult( - await near.deployContract(config.contractName, data)); + await masterAccount.createAndDeployContract(config.contractName, randomKey.getPublicKey(), data, 1000000); + config.deps.keyStore.setKey(config.networkId, config.contractName, randomKey); await super.setup(); }