Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into run-on-master-and-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
janedegtiareva committed Sep 9, 2019
2 parents e228986 + 3025f4f commit 1f3cd22
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 52 deletions.
3 changes: 1 addition & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ run_tests:
- yarn
- NODE_ENV=ci yarn test


run_tests_staging:
stage: test
tags:
- gcloud
script:
- yarn
- NODE_ENV=ci-staging yarn test
- NODE_ENV=ci-staging yarn test
7 changes: 4 additions & 3 deletions blank_project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "",
"version": "0.0.1",
"scripts": {
"build": "gulp",
"build": "mkdir -p out/ && gulp",
"deploy:contract": "near deploy",
"deploy:pages": "gh-pages -d src",
"deploy": "npm run build && npm run deploy:contract && npm run deploy:pages",
Expand All @@ -12,12 +12,13 @@
"test": "npm run build && jest test --env=near-shell/test_environment"
},
"devDependencies": {
"assemblyscript-json": "github:nearprotocol/assemblyscript-json",
"bignum": "github:MaxGraey/bignum.wasm",
"gh-pages": "^2.1.1",
"gulp": "^4.0.2",
"jest": "^24.8.0",
"jest-environment-node": "^24.8.0",
"near-runtime-ts": "github:nearprotocol/near-runtime-ts#staging",
"near-shell": "file:.."
"near-shell": "github:nearprotocol/near-shell"
},
"wasmStudio": {
"name": "Hello World Example",
Expand Down
2 changes: 1 addition & 1 deletion blank_project/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h3>Hi, <i id="account-id"></i>!</h3>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/gh/nearprotocol/nearlib@0.11.0/dist/nearlib.js"></script>
<script src="https://cdn.jsdelivr.net/gh/nearprotocol/nearlib@0.13.2/dist/nearlib.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
<script src="./config.js"></script>
<script src="./main.js"></script>
Expand Down
9 changes: 3 additions & 6 deletions blank_project/src/wallet/login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
</head>
<body style="background: #fff; margin-top: 3em">
<div>Please run the following command in shell, then enter account id here.
<div>Please run the following command in shell, then enter account id here. masterAccountId default: test.near
</div>
<div>
<code id="shell-command"></code>
</div>
<input type="text" id="accountId" name="accountId" placeholder="Account id"></input>
<button type="button" onClick="done()">done</button>
<script src="https://cdn.jsdelivr.net/gh/nearprotocol/nearlib@82eed3127d56984e850cf1581344bc098b9f83ab/dist/nearlib.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
<script src="./config.js"></script>
<script>
const currentUrl = new URL(window.location.href);
const message = `near create_account {newAccountId} --masterAccount {masterAccountId} --publicKey ${currentUrl.searchParams.get('public_key')} --initialAmount 1000`;
const message = `NODE_ENV=local near create_account {newAccountId} --masterAccount {masterAccountId} --publicKey ${currentUrl.searchParams.get('public_key')} --initialAmount 10000000000000000000`;
document.getElementById('shell-command').innerText = message;

function done() {
Expand All @@ -28,4 +25,4 @@
}
</script>
</body>
</html>
</html>
40 changes: 14 additions & 26 deletions gulp-utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// FUTURE PEOPLE: This file is called "gulp-utils" but it's not related to the deprecated library called "gulp-utils". Don't panic.
// function generateBindings(inputFile, outputFile, callback) {
// const asc = getAsc();
// asc.main([
// inputFile,
// "--baseDir", process.cwd(),
// "--nearFile", outputFile,
// "--measure"
// ], callback);
// }
var path = require("path");

function compile(inputFile, outputFile, callback) {
Expand All @@ -21,25 +31,9 @@ function getAsc() {
}

asc = require("assemblyscript/bin/asc");

const fs = require("fs");
const pathModule = require("path");

// Create parent directories if they don't exist
function mkdirp(path){
let dirname = pathModule.dirname(path);
let paths = []
while (!fs.existsSync(dirname)){
paths.unshift(pathModule.basename(dirname));
dirname = pathModule.dirname(dirname);
}
if (paths.length > 0){
for (const i in paths){
fs.mkdirSync(pathModule.join(dirname, ...paths.slice(0,i + 1)))
}
}
}

asc.main = (main => (args, options, fn) => {
if (typeof options === "function") {
fn = options;
Expand All @@ -51,28 +45,22 @@ function getAsc() {
stdout: process.stdout || asc.createMemoryStream(logLn),
stderr: process.stderr || asc.createMemoryStream(logLn),
readFile: (filename, baseDir) => {
baseDir = pathModule.relative(process.cwd(), baseDir);
let path = pathModule.join(baseDir, filename);
if (!fs.existsSync(path)) {
return null;
}

return fs.readFileSync(path).toString("utf8");
},
writeFile: (filename, contents) => {
const name = filename.startsWith("../") ? filename.substring(3) : filename;
mkdirp(name);
fs.writeFileSync(name, contents);
},
listFiles: (dirname, baseDir) => {
try {
return fs.readdirSync(path.join(baseDir, dirname)).filter(file => /^(?!.*\.d\.ts$).*\.ts$/.test(file));
} catch (e) {
return null;
}
}
listFiles: () => []
}, fn);
})(asc.main);
return asc;
}


module.exports = { compile };
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-shell",
"version": "0.10.0",
"version": "0.10.5",
"description": "Command line utilities to interact with near blockchain",
"main": "index.js",
"scripts": {
Expand All @@ -23,12 +23,12 @@
},
"devDependencies": {},
"dependencies": {
"assemblyscript": "github:nearprotocol/assemblyscript#staging",
"assemblyscript": "github:nearprotocol/assemblyscript",
"bs58": "^4.0.1",
"jest-environment-node": "^24.5.0",
"ncp": "^2.0.0",
"near-runtime-ts": "github:nearprotocol/near-runtime-ts#staging",
"nearlib": "github:nearprotocol/nearlib#staging",
"near-runtime-ts": "github:nearprotocol/near-runtime-ts",
"nearlib": "^0.13.1",
"rimraf": "^2.6.3",
"yargs": "^13.2.1"
},
Expand Down
14 changes: 14 additions & 0 deletions test/account_operations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ex
cd tmp-project
timestamp=$(date +%s)
testaccount=testaccount$timestamp
echo Create account
../bin/near create_account $testaccount

echo Get account state
RESULT=$(../bin/near state $testaccount)
if [[ $RESULT != *"Account $testaccount"*"amount: '100000000'"* ]]; then
echo FAILURE Unexpected output from near state
exit 1
fi
20 changes: 20 additions & 0 deletions test/contract_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -ex
cd tmp-project
rm -rf assembly
mkdir assembly
timestamp=$(date +%s)
testaccount=testaccount$timestamp
../bin/near create_account $testaccount
echo Building contract
cp ../node_modules/near-runtime-ts/tests/assembly/*.ts assembly/
yarn
yarn build
echo Deploying contract
../bin/near deploy --accountId=$testaccount --wasmFile=out/main.wasm
echo Calling functions
RESULT=$(../bin/near call $testaccount hello "{}" --accountId=test.near)
if [[ $RESULT != *"Result: helloa"* ]]; then
echo FAILURE Unexpected output from near call
exit 1
fi
7 changes: 0 additions & 7 deletions test/create_account.sh

This file was deleted.

5 changes: 3 additions & 2 deletions test/index.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/bin/bash
set -ex
./test/new_project.sh
./test/create_account.sh
./test/account_operations.sh
./test/contract_tests.sh
2 changes: 1 addition & 1 deletion test/new_project.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -ex

# remove temporary blank project
Expand Down

0 comments on commit 1f3cd22

Please sign in to comment.