create-near-app 5.3.1 → 6.0.0-beta.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.
Files changed (112) hide show
  1. package/dist/make.js +19 -15
  2. package/dist/messages.js +2 -2
  3. package/dist/package-json.js +17 -1
  4. package/dist/types.js +1 -1
  5. package/dist/user-input.js +16 -15
  6. package/package.json +4 -1
  7. package/templates/contracts/js/deploy.sh +6 -1
  8. package/templates/contracts/js/package-lock.json +5966 -0
  9. package/templates/contracts/js/src/contract.ts +5 -5
  10. package/templates/contracts/rust/Cargo.toml +1 -1
  11. package/templates/contracts/rust/README.md +2 -2
  12. package/templates/contracts/rust/deploy.sh +5 -0
  13. package/templates/contracts/rust/src/lib.rs +11 -11
  14. package/templates/frontend/gateway/.nvmrc +1 -0
  15. package/templates/frontend/gateway/.prettierrc +6 -0
  16. package/templates/frontend/gateway/next.config.js +15 -0
  17. package/templates/frontend/gateway/package.json +74 -0
  18. package/templates/frontend/gateway/public/apple-touch-icon.png +0 -0
  19. package/templates/frontend/gateway/public/bos-meta.png +0 -0
  20. package/templates/frontend/gateway/public/favicon.ico +0 -0
  21. package/templates/frontend/gateway/public/favicon.png +0 -0
  22. package/templates/frontend/gateway/public/fonts/FKGrotesk.woff2 +0 -0
  23. package/templates/frontend/gateway/public/fonts/Mona-Sans.woff2 +0 -0
  24. package/templates/frontend/gateway/public/logo192.png +0 -0
  25. package/templates/frontend/gateway/public/next.svg +1 -0
  26. package/templates/frontend/gateway/public/robots.txt +3 -0
  27. package/templates/frontend/gateway/public/site.webmanifest +8 -0
  28. package/templates/frontend/gateway/public/vercel.svg +1 -0
  29. package/templates/frontend/gateway/src/assets/images/near-icon.svg +3 -0
  30. package/templates/frontend/gateway/src/components/MetaTags.tsx +22 -0
  31. package/templates/frontend/gateway/src/components/component/ComponentWrapperPage.tsx +27 -0
  32. package/templates/frontend/gateway/src/components/layouts/DefaultLayout.tsx +16 -0
  33. package/templates/frontend/gateway/src/components/layouts/SimpleLayout.tsx +9 -0
  34. package/templates/frontend/gateway/src/components/lib/Button/Button.tsx +379 -0
  35. package/templates/frontend/gateway/src/components/lib/Button/index.tsx +1 -0
  36. package/templates/frontend/gateway/src/components/lib/Spinner/Spinner.tsx +33 -0
  37. package/templates/frontend/gateway/src/components/lib/Spinner/index.ts +1 -0
  38. package/templates/frontend/gateway/src/components/lib/Text/Text.tsx +14 -0
  39. package/templates/frontend/gateway/src/components/lib/Text/index.tsx +1 -0
  40. package/templates/frontend/gateway/src/components/lib/Toast/README.md +83 -0
  41. package/templates/frontend/gateway/src/components/lib/Toast/Toast.tsx +25 -0
  42. package/templates/frontend/gateway/src/components/lib/Toast/Toaster.tsx +48 -0
  43. package/templates/frontend/gateway/src/components/lib/Toast/api.ts +6 -0
  44. package/templates/frontend/gateway/src/components/lib/Toast/index.ts +3 -0
  45. package/templates/frontend/gateway/src/components/lib/Toast/store.ts +83 -0
  46. package/templates/frontend/gateway/src/components/lib/Toast/styles.ts +126 -0
  47. package/templates/frontend/gateway/src/components/navigation/Navigation.tsx +23 -0
  48. package/templates/frontend/gateway/src/components/navigation/UserDropdownMenu.tsx +209 -0
  49. package/templates/frontend/gateway/src/components/navigation/desktop/DesktopNavigation.tsx +109 -0
  50. package/templates/frontend/gateway/src/components/navigation/desktop/MainNavigationMenu.tsx +170 -0
  51. package/templates/frontend/gateway/src/components/navigation/icons/close.svg +22 -0
  52. package/templates/frontend/gateway/src/components/navigation/icons/near-icon.svg +3 -0
  53. package/templates/frontend/gateway/src/components/navigation/icons/near-logo.svg +14 -0
  54. package/templates/frontend/gateway/src/components/navigation/icons/return.svg +29 -0
  55. package/templates/frontend/gateway/src/components/navigation/icons/search.svg +3 -0
  56. package/templates/frontend/gateway/src/components/navigation/mobile/AccordionMenu.tsx +141 -0
  57. package/templates/frontend/gateway/src/components/navigation/mobile/Menu.tsx +86 -0
  58. package/templates/frontend/gateway/src/components/navigation/mobile/MobileNavigation.tsx +131 -0
  59. package/templates/frontend/gateway/src/components/navigation/navigation-categories.ts +75 -0
  60. package/templates/frontend/gateway/src/components/vm/VmCommitButton.tsx +20 -0
  61. package/templates/frontend/gateway/src/components/vm/VmComponent.tsx +29 -0
  62. package/templates/frontend/gateway/src/components/vm/VmInitializer.tsx +124 -0
  63. package/templates/frontend/gateway/src/data/components.ts +50 -0
  64. package/templates/frontend/gateway/src/data/web3.ts +292 -0
  65. package/templates/frontend/gateway/src/hooks/useBosComponents.ts +14 -0
  66. package/templates/frontend/gateway/src/hooks/useBosLoaderInitializer.ts +60 -0
  67. package/templates/frontend/gateway/src/hooks/useFlags.ts +40 -0
  68. package/templates/frontend/gateway/src/hooks/useLayout.tsx +12 -0
  69. package/templates/frontend/gateway/src/index.d.ts +9 -0
  70. package/templates/frontend/gateway/src/pages/_app.tsx +47 -0
  71. package/templates/frontend/gateway/src/pages/_document.tsx +27 -0
  72. package/templates/frontend/gateway/src/pages/dig.tsx +25 -0
  73. package/templates/frontend/gateway/src/pages/flags.tsx +83 -0
  74. package/templates/frontend/gateway/src/pages/hello-api.tsx +105 -0
  75. package/templates/frontend/gateway/src/pages/hello-component.tsx +23 -0
  76. package/templates/frontend/gateway/src/pages/hello-ethereum.tsx +23 -0
  77. package/templates/frontend/gateway/src/pages/hello-social.tsx +31 -0
  78. package/templates/frontend/gateway/src/pages/index.tsx +51 -0
  79. package/templates/frontend/gateway/src/pages/nui.tsx +25 -0
  80. package/templates/frontend/gateway/src/stores/auth.ts +29 -0
  81. package/templates/frontend/gateway/src/stores/bos-loader.ts +20 -0
  82. package/templates/frontend/gateway/src/stores/current-component.ts +11 -0
  83. package/templates/frontend/gateway/src/stores/vm.ts +24 -0
  84. package/templates/frontend/gateway/src/styles/globals.css +68 -0
  85. package/templates/frontend/gateway/src/styles/theme.css +129 -0
  86. package/templates/frontend/gateway/src/utils/config.ts +49 -0
  87. package/templates/frontend/gateway/src/utils/form-validation.ts +18 -0
  88. package/templates/frontend/gateway/src/utils/keypom-options.ts +59 -0
  89. package/templates/frontend/gateway/src/utils/route/privateRoute.tsx +20 -0
  90. package/templates/frontend/gateway/src/utils/route/signedOutRoute.tsx +21 -0
  91. package/templates/frontend/gateway/src/utils/types.ts +33 -0
  92. package/templates/frontend/gateway/tsconfig.json +24 -0
  93. package/templates/frontend/vanilla/.env +1 -0
  94. package/templates/frontend/vanilla/index.html +15 -6
  95. package/templates/frontend/vanilla/index.js +1 -1
  96. package/templates/frontend/{shared → vanilla}/near-wallet.js +2 -2
  97. package/templates/frontend/vanilla/package.json +9 -8
  98. package/templates/integration-tests/js-tests/package-lock.json +5014 -0
  99. package/templates/integration-tests/js-tests/package.json +3 -0
  100. package/templates/integration-tests/js-tests/src/main.ava.ts +6 -6
  101. package/templates/integration-tests/rust-tests/src/tests.rs +7 -7
  102. package/templates/frontend/react/App.js +0 -75
  103. package/templates/frontend/react/assets/favicon.ico +0 -0
  104. package/templates/frontend/react/assets/global.css +0 -231
  105. package/templates/frontend/react/assets/logo-black.svg +0 -1
  106. package/templates/frontend/react/assets/logo-white.svg +0 -1
  107. package/templates/frontend/react/index.html +0 -15
  108. package/templates/frontend/react/index.js +0 -23
  109. package/templates/frontend/react/package.json +0 -52
  110. package/templates/frontend/react/ui-components.js +0 -59
  111. package/templates/frontend/shared/start.sh +0 -26
  112. /package/templates/{shared → contracts/rust}/rust-toolchain.toml +0 -0
@@ -2,6 +2,9 @@
2
2
  "name": "ava-testing",
3
3
  "version": "1.0.0",
4
4
  "license": "(MIT AND Apache-2.0)",
5
+ "engines": {
6
+ "node": "16.x"
7
+ },
5
8
  "scripts": {
6
9
  "test": "ava"
7
10
  },
@@ -32,13 +32,13 @@ test.afterEach.always(async (t) => {
32
32
 
33
33
  test('returns the default greeting', async (t) => {
34
34
  const { contract } = t.context.accounts;
35
- const message: string = await contract.view('get_greeting', {});
36
- t.is(message, 'Hello');
35
+ const greeting: string = await contract.view('get_greeting', {});
36
+ t.is(greeting, 'Hello');
37
37
  });
38
38
 
39
- test('changes the message', async (t) => {
39
+ test('changes the greeting', async (t) => {
40
40
  const { root, contract } = t.context.accounts;
41
- await root.call(contract, 'set_greeting', { message: 'Howdy' });
42
- const message: string = await contract.view('get_greeting', {});
43
- t.is(message, 'Howdy');
41
+ await root.call(contract, 'set_greeting', { greeting: 'Howdy' });
42
+ const greeting: string = await contract.view('get_greeting', {});
43
+ t.is(greeting, 'Howdy');
44
44
  });
@@ -31,15 +31,15 @@ async fn test_default_message(
31
31
  user: &Account,
32
32
  contract: &Contract,
33
33
  ) -> anyhow::Result<()> {
34
- let message: String = user
34
+ let greeting: String = user
35
35
  .call( contract.id(), "get_greeting")
36
36
  .args_json(json!({}))
37
37
  .transact()
38
38
  .await?
39
39
  .json()?;
40
40
 
41
- assert_eq!(message, "Hello".to_string());
42
- println!(" Passed ✅ gets default message");
41
+ assert_eq!(greeting, "Hello".to_string());
42
+ println!(" Passed ✅ gets default greeting");
43
43
  Ok(())
44
44
  }
45
45
 
@@ -48,19 +48,19 @@ async fn test_changes_message(
48
48
  contract: &Contract,
49
49
  ) -> anyhow::Result<()> {
50
50
  user.call(contract.id(), "set_greeting")
51
- .args_json(json!({"message": "Howdy"}))
51
+ .args_json(json!({"greeting": "Howdy"}))
52
52
  .transact()
53
53
  .await?
54
54
  .into_result()?;
55
55
 
56
- let message: String = user
56
+ let greeting: String = user
57
57
  .call(contract.id(), "get_greeting")
58
58
  .args_json(json!({}))
59
59
  .transact()
60
60
  .await?
61
61
  .json()?;
62
62
 
63
- assert_eq!(message, "Howdy".to_string());
64
- println!(" Passed ✅ changes message");
63
+ assert_eq!(greeting, "Howdy".to_string());
64
+ println!(" Passed ✅ changes greeting");
65
65
  Ok(())
66
66
  }
@@ -1,75 +0,0 @@
1
- import 'regenerator-runtime/runtime';
2
- import React from 'react';
3
-
4
- import './assets/global.css';
5
-
6
- import { EducationalText, SignInPrompt, SignOutButton } from './ui-components';
7
-
8
-
9
- export default function App({ isSignedIn, contractId, wallet }) {
10
- const [valueFromBlockchain, setValueFromBlockchain] = React.useState();
11
-
12
- const [uiPleaseWait, setUiPleaseWait] = React.useState(true);
13
-
14
- // Get blockchian state once on component load
15
- React.useEffect(() => {
16
- getGreeting()
17
- .then(setValueFromBlockchain)
18
- .catch(alert)
19
- .finally(() => {
20
- setUiPleaseWait(false);
21
- });
22
- }
23
- , []);
24
-
25
- /// If user not signed-in with wallet - show prompt
26
- if (!isSignedIn) {
27
- // Sign-in flow will reload the page later
28
- return <SignInPrompt greeting={valueFromBlockchain} onClick={() => wallet.signIn()}/>;
29
- }
30
-
31
- function changeGreeting(e) {
32
- e.preventDefault();
33
- setUiPleaseWait(true);
34
- const { greetingInput } = e.target.elements;
35
-
36
- // use the wallet to send the greeting to the contract
37
- wallet.callMethod({ method: 'set_greeting', args: { message: greetingInput.value }, contractId })
38
- .then(async () => {return getGreeting();})
39
- .then(setValueFromBlockchain)
40
- .finally(() => {
41
- setUiPleaseWait(false);
42
- });
43
- }
44
-
45
- function getGreeting(){
46
- // use the wallet to query the contract's greeting
47
- return wallet.viewMethod({ method: 'get_greeting', contractId })
48
- }
49
-
50
- return (
51
- <>
52
- <SignOutButton accountId={wallet.accountId} onClick={() => wallet.signOut()}/>
53
- <main className={uiPleaseWait ? 'please-wait' : ''}>
54
- <h1>
55
- The contract says: <span className="greeting">{valueFromBlockchain}</span>
56
- </h1>
57
- <form onSubmit={changeGreeting} className="change">
58
- <label>Change greeting:</label>
59
- <div>
60
- <input
61
- autoComplete="off"
62
- defaultValue={valueFromBlockchain}
63
- id="greetingInput"
64
- />
65
- <button>
66
- <span>Save</span>
67
- <div className="loader"></div>
68
- </button>
69
- </div>
70
- </form>
71
- <EducationalText/>
72
- </main>
73
- </>
74
- );
75
- }
@@ -1,231 +0,0 @@
1
- * {
2
- box-sizing: border-box;
3
- }
4
-
5
- html {
6
- --bg: #efefef;
7
- --fg: #1e1e1e;
8
- --gray: #555;
9
- --light-gray: #ccc;
10
- --shadow: #e6e6e6;
11
- --success: rgb(90, 206, 132);
12
- --primary: #FF585D;
13
- --secondary: #0072CE;
14
-
15
- background-color: var(--bg);
16
- color: var(--fg);
17
- font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
18
- font-size: calc(0.9em + 0.5vw);
19
- line-height: 1.3;
20
- }
21
-
22
- body {
23
- margin: 0;
24
- padding: 1em;
25
- }
26
-
27
- main {
28
- margin: 0 auto;
29
- max-width: 26em;
30
- }
31
-
32
- main.please-wait {
33
- }
34
-
35
- h1 {
36
- background-image: url(./logo-black.svg);
37
- background-position: center 1em;
38
- background-repeat: no-repeat;
39
- background-size: auto 1.5em;
40
- margin-top: 0;
41
- padding: 3.5em 0 0;
42
- text-align: center;
43
- font-size: 1.5em;
44
- }
45
- .greeting {
46
- color: var(--secondary);
47
- text-decoration: underline;
48
- }
49
- h2 {
50
- text-align: center;
51
- }
52
-
53
- .please-wait .change {
54
- pointer-events: none;
55
- }
56
-
57
- ul.information {
58
- margin: 2em 0 2em 0;
59
- padding: 0;
60
- text-align: left;
61
- font-size: 0.8em;
62
-
63
- }
64
- .information li:first-child {
65
- border-top: 1px solid var(--light-gray);
66
- }
67
- .information li {
68
- padding: 0.5em 0;
69
- border-bottom: 1px solid var(--light-gray);
70
- list-style: none;
71
- }
72
-
73
- .change {
74
- display: flex;
75
- flex-direction: column;
76
- align-content: stretch;
77
- justify-content: space-evenly;
78
- align-items: stretch;
79
- font-size: 1em;
80
- border: 2px solid var(--light-gray);
81
- padding: 0.5em;
82
- }
83
- .change > div {
84
- display: flex;
85
- align-content: stretch;
86
- justify-content: space-evenly;
87
- align-items: stretch;
88
- }
89
- .change input {
90
- flex: 1;
91
- border-bottom-right-radius: 0;
92
- border-top-right-radius: 0;
93
- }
94
- .change label {
95
- display: block;
96
- text-align: left;
97
- margin-right: 10px;
98
- padding-bottom: 0.5em;
99
- }
100
- .change button {
101
- border-bottom-left-radius: 0;
102
- border-top-left-radius: 0;
103
- }
104
-
105
- a,
106
- .link {
107
- color: var(--primary);
108
- text-decoration: none;
109
- }
110
- a:hover,
111
- a:focus,
112
- .link:hover,
113
- .link:focus {
114
- text-decoration: underline;
115
- }
116
- a:active,
117
- .link:active {
118
- color: var(--secondary);
119
- }
120
-
121
- button, input {
122
- font: inherit;
123
- outline: none;
124
- }
125
- main.please-wait .change button {
126
- position: relative;
127
- pointer-events: none;
128
- background-color: white;
129
- }
130
- main.please-wait .change button span {
131
- visibility: hidden;
132
- }
133
- button {
134
- background-color: var(--secondary);
135
- border-radius: 5px;
136
- border: none;
137
- color: #efefef;
138
- cursor: pointer;
139
- padding: 0.3em 0.75em;
140
- transition: transform 30ms;
141
- }
142
- button:hover, button:focus {
143
- box-shadow: 0 0 10em rgba(255, 255, 255, 0.2) inset;
144
- }
145
- input {
146
- background-color: var(--light-gray);
147
- border: none;
148
- border-radius: 5px 0 0 5px;
149
- caret-color: var(--primary);
150
- color: inherit;
151
- padding: 0.25em 0.5em;
152
- }
153
- input::selection {
154
- background-color: var(--secondary);
155
- color: #efefef;
156
- }
157
- input:focus {
158
- box-shadow: 0 0 10em rgba(0, 0, 0, 0.02) inset;
159
- }
160
-
161
- code {
162
- color: var(--gray);
163
- }
164
-
165
- li {
166
- padding-bottom: 1em;
167
- }
168
-
169
- @media (prefers-color-scheme: dark) {
170
- html {
171
- --bg: #1e1e1e;
172
- --fg: #efefef;
173
- --gray: #aaa;
174
- --shadow: #2a2a2a;
175
- --light-gray: #444;
176
- }
177
- h1 {
178
- background-image: url(./logo-white.svg);
179
- }
180
- input:focus {
181
- box-shadow: 0 0 10em rgba(255, 255, 255, 0.02) inset;
182
- }
183
- }
184
-
185
- main.please-wait .loader,
186
- main.please-wait .loader:after{
187
- display: inline-block;
188
- }
189
- .loader,
190
- .loader:after {
191
- display: none;
192
- border-radius: 50%;
193
- width: 20px;
194
- height: 20px;
195
- }
196
- .loader {
197
- font-size: 10px;
198
- position: absolute;
199
- top: calc(50% - 10px);
200
- left: calc(50% - 10px);
201
- text-indent: -9999em;
202
- border-top: 3px solid var(--secondary);
203
- border-right: 3px solid var(--secondary);
204
- border-bottom: 3px solid var(--secondary);
205
- border-left: 3px solid #ffffff;
206
- -webkit-transform: translateZ(0);
207
- -ms-transform: translateZ(0);
208
- transform: translateZ(0);
209
- -webkit-animation: load8 1.1s infinite linear;
210
- animation: load8 1.1s infinite linear;
211
- }
212
- @-webkit-keyframes load8 {
213
- 0% {
214
- -webkit-transform: rotate(0deg);
215
- transform: rotate(0deg);
216
- }
217
- 100% {
218
- -webkit-transform: rotate(360deg);
219
- transform: rotate(360deg);
220
- }
221
- }
222
- @keyframes load8 {
223
- 0% {
224
- -webkit-transform: rotate(0deg);
225
- transform: rotate(0deg);
226
- }
227
- 100% {
228
- -webkit-transform: rotate(360deg);
229
- transform: rotate(360deg);
230
- }
231
- }
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 288 288" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="76.81" x2="211.16" y1="211.17" y2="76.81"><stop offset=".21" stop-color="#24272a"/><stop offset=".42" stop-color="#24272a" stop-opacity="0"/><stop offset=".59" stop-color="#24272a" stop-opacity="0"/><stop offset=".81" stop-color="#24272a"/></linearGradient><path d="m88.46 216a16.45 16.45 0 0 0 12.46-5.71l112.56-130.57a16.42 16.42 0 0 0 -13.94-7.72 16.46 16.46 0 0 0 -12.41 5.65l-113.13 129.8a16.46 16.46 0 0 0 14.46 8.55z" fill="url(#a)"/><path d="m88.46 216a16.46 16.46 0 0 0 7.54-1.83v-109l87.45 104.94a16.44 16.44 0 0 0 12.64 5.89h3.45a16.46 16.46 0 0 0 16.46-16.46v-111.08a16.46 16.46 0 0 0 -16.46-16.46 16.36 16.36 0 0 0 -7.54 1.81v109.05l-87.45-104.94a16.44 16.44 0 0 0 -12.64-5.92h-3.45a16.46 16.46 0 0 0 -16.46 16.46v111.08a16.46 16.46 0 0 0 16.46 16.46z" fill="#24272a"/></svg>
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 288 288" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="76.81" x2="211.16" y1="211.17" y2="76.81"><stop offset=".21" stop-color="#fff"/><stop offset=".42" stop-color="#fff" stop-opacity="0"/><stop offset=".59" stop-color="#fff" stop-opacity="0"/><stop offset=".81" stop-color="#fff"/></linearGradient><path d="m88.46 216a16.45 16.45 0 0 0 12.46-5.71l112.56-130.57a16.42 16.42 0 0 0 -13.94-7.72 16.46 16.46 0 0 0 -12.41 5.65l-113.13 129.8a16.46 16.46 0 0 0 14.46 8.55z" fill="url(#a)"/><path d="m88.46 216a16.46 16.46 0 0 0 7.54-1.83v-109l87.45 104.94a16.44 16.44 0 0 0 12.64 5.89h3.45a16.46 16.46 0 0 0 16.46-16.46v-111.08a16.46 16.46 0 0 0 -16.46-16.46 16.36 16.36 0 0 0 -7.54 1.81v109.05l-87.45-104.94a16.44 16.44 0 0 0 -12.64-5.92h-3.45a16.46 16.46 0 0 0 -16.46 16.46v111.08a16.46 16.46 0 0 0 16.46 16.46z" fill="#fff"/></svg>
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="assets/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <link rel="apple-touch-icon" href="assets/favicon.ico" />
8
- <title>Welcome to NEAR with React</title>
9
- </head>
10
- <body>
11
- <noscript>You need to enable JavaScript to run this app.</noscript>
12
- <div id="root"></div>
13
- <script src="./index.js" type="module"></script>
14
- </body>
15
- </html>
@@ -1,23 +0,0 @@
1
- // React
2
- import React from 'react';
3
- import ReactDOM from 'react-dom';
4
- import App from './App';
5
-
6
- // NEAR
7
- import { Wallet } from './near-wallet';
8
-
9
- const CONTRACT_ADDRESS = process.env.CONTRACT_NAME
10
-
11
- // When creating the wallet you can optionally ask to create an access key
12
- // Having the key enables to call non-payable methods without interrupting the user to sign
13
- const wallet = new Wallet({ createAccessKeyFor: CONTRACT_ADDRESS })
14
-
15
- // Setup on page load
16
- window.onload = async () => {
17
- const isSignedIn = await wallet.startUp()
18
-
19
- ReactDOM.render(
20
- <App isSignedIn={isSignedIn} contractId={CONTRACT_ADDRESS} wallet={wallet} />,
21
- document.getElementById('root')
22
- );
23
- }
@@ -1,52 +0,0 @@
1
- {
2
- "name": "my-near-app",
3
- "version": "1.0.0",
4
- "license": "(MIT AND Apache-2.0)",
5
- "scripts": {
6
- "start": "./start.sh",
7
- "build": "parcel build index.html --public-url ./"
8
- },
9
- "devDependencies": {
10
- "@babel/core": "^7.22.5",
11
- "@babel/preset-env": "^7.22.5",
12
- "@babel/preset-react": "^7.22.5",
13
- "@types/node": "^20.3.2",
14
- "buffer": "^5.5.0||^6.0.0",
15
- "env-cmd": "^10.1.0",
16
- "events": "^3.1.0",
17
- "https-browserify": "^1.0.0",
18
- "nodemon": "^2.0.22",
19
- "parcel": "^2.9.3",
20
- "process": "^0.11.10",
21
- "punycode": "^1.4.1",
22
- "react-test-renderer": "^18.2.0",
23
- "stream-http": "^3.1.0",
24
- "ts-node": "^10.9.1",
25
- "typescript": "^5.1.3",
26
- "url": "^0.11.0"
27
- },
28
- "dependencies": {
29
- "@near-wallet-selector/core": "^8.1.4",
30
- "@near-wallet-selector/modal-ui": "^8.1.4",
31
- "@near-wallet-selector/my-near-wallet": "^8.1.4",
32
- "near-api-js": "^2.1.4",
33
- "react": "^18.2.0",
34
- "react-dom": "^18.2.0",
35
- "regenerator-runtime": "^0.13.11"
36
- },
37
- "resolutions": {
38
- "@babel/preset-env": "7.13.8"
39
- },
40
- "browserslist": {
41
- "production": [
42
- ">0.2%",
43
- "not dead",
44
- "not op_mini all"
45
- ],
46
- "development": [
47
- "last 1 chrome version",
48
- "last 1 firefox version",
49
- "last 1 safari version"
50
- ]
51
- }
52
- }
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
-
3
- export function SignInPrompt({greeting, onClick}) {
4
- return (
5
- <main>
6
- <h1>
7
- The contract says: <span className="greeting">{greeting}</span>
8
- </h1>
9
- <h3>
10
- Welcome to NEAR!
11
- </h3>
12
- <p>
13
- Your contract is storing a greeting message in the NEAR blockchain. To
14
- change it you need to sign in using the NEAR Wallet. It is very simple,
15
- just use the button below.
16
- </p>
17
- <p>
18
- Do not worry, this app runs in the test network ("testnet"). It works
19
- just like the main network ("mainnet"), but using NEAR Tokens that are
20
- only for testing!
21
- </p>
22
- <br/>
23
- <p style={{ textAlign: 'center' }}>
24
- <button onClick={onClick}>Sign in with NEAR Wallet</button>
25
- </p>
26
- </main>
27
- );
28
- }
29
-
30
- export function SignOutButton({accountId, onClick}) {
31
- return (
32
- <button style={{ float: 'right' }} onClick={onClick}>
33
- Sign out {accountId}
34
- </button>
35
- );
36
- }
37
-
38
- export function EducationalText() {
39
- return (
40
- <>
41
- <p>
42
- Look at that! A Hello World app! This greeting is stored on the NEAR blockchain. Check it out:
43
- </p>
44
- <ol>
45
- <li>
46
- Look in <code>frontend/App.js</code> - you'll see <code>getGreeting</code> and <code>setGreeting</code> being called on <code>contract</code>. What's this?
47
- </li>
48
- <li>
49
- Ultimately, this <code>contract</code> code is defined in <code>./contract</code> – this is the source code for your <a target="_blank" rel="noreferrer" href="https://docs.near.org/docs/develop/contracts/overview">smart contract</a>.</li>
50
- <li>
51
- When you run <code>npm run deploy</code>, the code in <code>./contract</code> gets deployed to the NEAR testnet. You can see how this happens by looking in <code>package.json</code>.</li>
52
- </ol>
53
- <hr />
54
- <p>
55
- To keep learning, check out <a target="_blank" rel="noreferrer" href="https://docs.near.org">the NEAR docs</a> or look through some <a target="_blank" rel="noreferrer" href="https://examples.near.org">example apps</a>.
56
- </p>
57
- </>
58
- );
59
- }
@@ -1,26 +0,0 @@
1
- #!/bin/sh
2
-
3
- CONTRACT_DIRECTORY=../contract
4
- DEV_ACCOUNT_FILE="${CONTRACT_DIRECTORY}/neardev/dev-account.env"
5
-
6
- start () {
7
- echo The app is starting!
8
- env-cmd -f $DEV_ACCOUNT_FILE parcel index.html --open
9
- }
10
-
11
- alert () {
12
- GREEN='\033[1;32m'
13
- NC='\033[0m' # No Color
14
-
15
- echo "======================================================"
16
- echo "It looks like you didn't deploy your contract"
17
- echo ">> Run ${GREEN}'npm run deploy'${NC} from the your project's root directory"
18
- echo "This frontend template works with contracts deployed to NEAR TestNet"
19
- echo "======================================================"
20
- }
21
-
22
- if [ -f "$DEV_ACCOUNT_FILE" ]; then
23
- start
24
- else
25
- alert
26
- fi