create-near-app 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "near-sdk-js build src/contract.ts build/hello_near.wasm",
|
|
11
11
|
"deploy": "near dev-deploy --wasmFile build/hello_near.wasm",
|
|
12
|
-
"test": "$npm_execpath run build && cd sandbox-ts && $npm_execpath run test -- ../build/hello_near.wasm",
|
|
12
|
+
"test": "$npm_execpath run build && cd sandbox-ts && $npm_execpath run test -- -- ../build/hello_near.wasm",
|
|
13
13
|
"postinstall": "cd sandbox-ts && $npm_execpath install"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
@@ -5,18 +5,10 @@ publish = false
|
|
|
5
5
|
edition = "2021"
|
|
6
6
|
|
|
7
7
|
[dev-dependencies]
|
|
8
|
-
anyhow = "1.0"
|
|
9
|
-
borsh = "0.9"
|
|
10
|
-
maplit = "1.0"
|
|
11
|
-
near-units = "0.2.0"
|
|
12
8
|
tokio = { version = "1.18.1", features = ["full"] }
|
|
13
|
-
|
|
14
|
-
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
|
|
15
|
-
workspaces = "0.6.0"
|
|
16
|
-
pkg-config = "0.3.1"
|
|
9
|
+
near-workspaces = "0.9.0"
|
|
17
10
|
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
|
|
18
|
-
# arbitrary_precision enabled for u128 types that workspaces requires for Balance types
|
|
19
11
|
|
|
20
12
|
[[example]]
|
|
21
13
|
name = "sandbox"
|
|
22
|
-
path = "src/tests.rs"
|
|
14
|
+
path = "src/tests.rs"
|
|
@@ -1,65 +1,64 @@
|
|
|
1
|
-
use
|
|
2
|
-
use near_units::parse_near;
|
|
1
|
+
use near_workspaces::{types::NearToken, Account, Contract};
|
|
3
2
|
use serde_json::json;
|
|
4
|
-
use
|
|
5
|
-
|
|
3
|
+
use std::{env, fs};
|
|
4
|
+
|
|
6
5
|
#[tokio::main]
|
|
7
|
-
async fn main() ->
|
|
6
|
+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
8
7
|
let wasm_arg: &str = &(env::args().nth(1).unwrap());
|
|
9
8
|
let wasm_filepath = fs::canonicalize(env::current_dir()?.join(wasm_arg))?;
|
|
10
|
-
|
|
11
|
-
let worker =
|
|
9
|
+
|
|
10
|
+
let worker = near_workspaces::sandbox().await?;
|
|
12
11
|
let wasm = std::fs::read(wasm_filepath)?;
|
|
13
12
|
let contract = worker.dev_deploy(&wasm).await?;
|
|
14
|
-
|
|
13
|
+
|
|
15
14
|
// create accounts
|
|
16
15
|
let account = worker.dev_create_account().await?;
|
|
17
16
|
let alice = account
|
|
18
|
-
.create_subaccount(
|
|
19
|
-
.initial_balance(
|
|
17
|
+
.create_subaccount("alice")
|
|
18
|
+
.initial_balance(NearToken::from_near(30))
|
|
20
19
|
.transact()
|
|
21
20
|
.await?
|
|
22
21
|
.into_result()?;
|
|
23
|
-
|
|
22
|
+
|
|
24
23
|
// begin tests
|
|
25
24
|
test_default_message(&alice, &contract).await?;
|
|
26
25
|
test_changes_message(&alice, &contract).await?;
|
|
27
26
|
Ok(())
|
|
28
27
|
}
|
|
29
|
-
|
|
28
|
+
|
|
30
29
|
async fn test_default_message(
|
|
31
30
|
user: &Account,
|
|
32
31
|
contract: &Contract,
|
|
33
|
-
) ->
|
|
32
|
+
) -> Result<(), Box<dyn std::error::Error>> {
|
|
34
33
|
let greeting: String = user
|
|
35
|
-
.call(
|
|
34
|
+
.call(contract.id(), "get_greeting")
|
|
36
35
|
.args_json(json!({}))
|
|
37
36
|
.transact()
|
|
38
37
|
.await?
|
|
39
38
|
.json()?;
|
|
40
|
-
|
|
39
|
+
|
|
41
40
|
assert_eq!(greeting, "Hello".to_string());
|
|
42
41
|
println!(" Passed ✅ gets default greeting");
|
|
43
42
|
Ok(())
|
|
44
43
|
}
|
|
45
|
-
|
|
44
|
+
|
|
46
45
|
async fn test_changes_message(
|
|
47
46
|
user: &Account,
|
|
48
47
|
contract: &Contract,
|
|
49
|
-
) ->
|
|
48
|
+
) -> Result<(), Box<dyn std::error::Error>> {
|
|
50
49
|
user.call(contract.id(), "set_greeting")
|
|
51
50
|
.args_json(json!({"greeting": "Howdy"}))
|
|
52
51
|
.transact()
|
|
53
52
|
.await?
|
|
54
53
|
.into_result()?;
|
|
55
|
-
|
|
54
|
+
|
|
56
55
|
let greeting: String = user
|
|
57
56
|
.call(contract.id(), "get_greeting")
|
|
58
57
|
.args_json(json!({}))
|
|
59
58
|
.transact()
|
|
60
59
|
.await?
|
|
61
60
|
.json()?;
|
|
62
|
-
|
|
61
|
+
|
|
63
62
|
assert_eq!(greeting, "Howdy".to_string());
|
|
64
63
|
println!(" Passed ✅ changes greeting");
|
|
65
64
|
Ok(())
|