create-near-app 8.1.0 → 8.3.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/dist/app.js +11 -1
- package/dist/make.js +23 -1
- package/dist/messages.js +48 -27
- package/dist/tracking.js +1 -1
- package/dist/utils/checkCargoNear.js +15 -0
- package/dist/utils/donwloadFile.js +25 -0
- package/dist/utils/index.js +11 -0
- package/package.json +2 -1
- package/templates/contracts/rs/.github/workflows/deploy-production.yml +2 -4
- package/templates/contracts/rs/.github/workflows/deploy-staging.yml +4 -8
- package/templates/contracts/rs/.github/workflows/test.yml +2 -0
- package/templates/contracts/rs/.github/workflows/undeploy-staging.yml +2 -4
- package/templates/contracts/rs/Cargo.toml +15 -9
- package/templates/contracts/rs/README.md +6 -0
- package/templates/contracts/rs/rust-toolchain.toml +2 -2
- package/templates/frontend/next-app/next.config.js +1 -0
- package/templates/frontend/next-app/package.json +23 -17
- package/templates/frontend/next-app/src/app/hello-near/page.js +7 -9
- package/templates/frontend/next-app/src/app/layout.js +34 -9
- package/templates/frontend/next-app/src/components/navigation.js +7 -9
- package/templates/frontend/next-app/src/config.js +1 -18
- package/templates/frontend/next-app/src/wallets/web3modal.js +24 -40
- package/templates/frontend/next-page/next.config.js +1 -0
- package/templates/frontend/next-page/package.json +23 -17
- package/templates/frontend/next-page/src/components/navigation.js +7 -9
- package/templates/frontend/next-page/src/config.js +1 -18
- package/templates/frontend/next-page/src/pages/_app.js +34 -11
- package/templates/frontend/next-page/src/pages/hello-near/index.js +7 -9
- package/templates/frontend/next-page/src/wallets/web3modal.js +24 -40
- package/templates/frontend/vite-react/package.json +26 -26
- package/templates/frontend/vite-react/src/App.jsx +35 -15
- package/templates/frontend/vite-react/src/components/navigation.jsx +8 -10
- package/templates/frontend/vite-react/src/config.js +1 -18
- package/templates/frontend/vite-react/src/pages/hello_near.jsx +7 -9
- package/templates/frontend/vite-react/src/wallets/web3modal.js +24 -38
- package/templates/frontend/vite-react/vite.config.js +2 -15
- package/templates/contracts/rs/Cargo.lock +0 -4348
- package/templates/frontend/next-app/src/wallets/near.js +0 -216
- package/templates/frontend/next-page/src/wallets/near.js +0 -216
- package/templates/frontend/vite-react/src/wallets/near.js +0 -228
package/dist/app.js
CHANGED
|
@@ -31,6 +31,7 @@ const semver_1 = __importDefault(require("semver"));
|
|
|
31
31
|
const make_1 = require("./make");
|
|
32
32
|
const user_input_1 = require("./user-input");
|
|
33
33
|
const show = __importStar(require("./messages"));
|
|
34
|
+
const utils_1 = require("./utils");
|
|
34
35
|
(async function () {
|
|
35
36
|
const supportedNodeVersion = require('../package.json').engines.node;
|
|
36
37
|
if (!semver_1.default.satisfies(process.version, supportedNodeVersion)) {
|
|
@@ -54,9 +55,18 @@ const show = __importStar(require("./messages"));
|
|
|
54
55
|
console.error(e);
|
|
55
56
|
createSuccess = false;
|
|
56
57
|
}
|
|
58
|
+
let needsToInstallCargoNear = false;
|
|
59
|
+
if (contract === 'rs') {
|
|
60
|
+
show.checkingCargoNear();
|
|
61
|
+
let cargoNearInstalled = await (0, utils_1.isCargoNearInstalled)();
|
|
62
|
+
if (!cargoNearInstalled) {
|
|
63
|
+
needsToInstallCargoNear = true;
|
|
64
|
+
show.cargoNearIsNotInstalled();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
57
67
|
if (createSuccess) {
|
|
58
68
|
install && await (0, make_1.runDepsInstall)(projectPath);
|
|
59
|
-
show.setupSuccess(projectName, contract, frontend, install);
|
|
69
|
+
show.setupSuccess(projectName, contract, frontend, install, needsToInstallCargoNear);
|
|
60
70
|
}
|
|
61
71
|
else {
|
|
62
72
|
return show.setupFailed();
|
package/dist/make.js
CHANGED
|
@@ -27,11 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.runDepsInstall = exports.copyDir = exports.createProject = void 0;
|
|
30
|
-
const show = __importStar(require("./messages"));
|
|
31
30
|
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
32
31
|
const fs_1 = __importDefault(require("fs"));
|
|
33
32
|
const ncp_1 = require("ncp");
|
|
34
33
|
const path_1 = __importDefault(require("path"));
|
|
34
|
+
const show = __importStar(require("./messages"));
|
|
35
|
+
const utils_1 = require("./utils");
|
|
35
36
|
async function createProject({ contract, frontend, projectPath, templatesDir }) {
|
|
36
37
|
if (contract !== 'none') {
|
|
37
38
|
await createContract({ contract, projectPath, templatesDir });
|
|
@@ -43,11 +44,32 @@ async function createProject({ contract, frontend, projectPath, templatesDir })
|
|
|
43
44
|
}
|
|
44
45
|
exports.createProject = createProject;
|
|
45
46
|
async function createContract({ contract, projectPath, templatesDir }) {
|
|
47
|
+
await createContractFromTemplate({ contract, projectPath, templatesDir });
|
|
48
|
+
if (contract === 'rs') {
|
|
49
|
+
await updateTemplateFiles(projectPath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function createContractFromTemplate({ contract, projectPath, templatesDir }) {
|
|
46
53
|
// contract folder
|
|
47
54
|
const sourceContractDir = path_1.default.resolve(templatesDir, 'contracts', contract);
|
|
48
55
|
fs_1.default.mkdirSync(projectPath, { recursive: true });
|
|
49
56
|
await copyDir(sourceContractDir, projectPath);
|
|
50
57
|
}
|
|
58
|
+
async function updateTemplateFiles(projectPath) {
|
|
59
|
+
const targetDir = path_1.default.join(projectPath);
|
|
60
|
+
const cargoTomlRemotePath = 'https://raw.githubusercontent.com/near/cargo-near/refs/heads/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml';
|
|
61
|
+
const cargoTomlFilePath = path_1.default.join(targetDir, 'Cargo.toml');
|
|
62
|
+
const rustToolchainRemotePath = 'https://raw.githubusercontent.com/near/cargo-near/refs/heads/main/cargo-near/src/commands/new/new-project-template/rust-toolchain.toml';
|
|
63
|
+
const rustToolchainFilePath = path_1.default.join(targetDir, 'rust-toolchain.toml');
|
|
64
|
+
show.updatingFiles();
|
|
65
|
+
try {
|
|
66
|
+
await (0, utils_1.downloadFile)(cargoTomlRemotePath, cargoTomlFilePath);
|
|
67
|
+
await (0, utils_1.downloadFile)(rustToolchainRemotePath, rustToolchainFilePath);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
show.updateFilesFailed();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
51
73
|
async function createGateway({ frontend, projectPath, templatesDir }) {
|
|
52
74
|
const sourceFrontendDir = path_1.default.resolve(`${templatesDir}/frontend/${frontend}`);
|
|
53
75
|
fs_1.default.mkdirSync(projectPath, { recursive: true });
|
package/dist/messages.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.depsInstallError = exports.depsInstall = exports.creatingApp = exports.directoryExists = exports.windowsWarning = exports.unsupportedNodeVersion = exports.argsError = exports.gatewayInstructions = exports.contractInstructions = exports.setupSuccess = exports.successFrontendToText = exports.successContractToText = exports.setupFailed = exports.welcome = exports.show = void 0;
|
|
6
|
+
exports.cargoNearIsNotInstalled = exports.checkingCargoNear = exports.updateFilesFailed = exports.updatingFiles = exports.depsInstallError = exports.depsInstall = exports.creatingApp = exports.directoryExists = exports.windowsWarning = exports.unsupportedNodeVersion = exports.argsError = exports.gatewayInstructions = exports.contractInstructions = exports.setupSuccess = exports.successFrontendToText = exports.successContractToText = exports.setupFailed = exports.welcome = exports.show = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const tracking_1 = require("./tracking");
|
|
9
9
|
if (process.env.NEAR_NO_COLOR) {
|
|
@@ -37,34 +37,46 @@ const successFrontendToText = (frontend) => frontend === 'none'
|
|
|
37
37
|
? ''
|
|
38
38
|
: (0, chalk_1.default) `a web-app using ${frontendTemplates[frontend]}`;
|
|
39
39
|
exports.successFrontendToText = successFrontendToText;
|
|
40
|
-
const setupSuccess = (projectName, contract, frontend, install) => (0, exports.show)((0, chalk_1.default) `
|
|
41
|
-
{green ======================================================}
|
|
40
|
+
const setupSuccess = (projectName, contract, frontend, install, needsToInstallCargoNear) => (0, exports.show)((0, chalk_1.default) `
|
|
42
41
|
✅ Success! Created '${projectName}', ${(0, exports.successContractToText)(contract)}${(0, exports.successFrontendToText)(frontend)}.
|
|
43
42
|
${contract === 'rs'
|
|
44
43
|
? (0, chalk_1.default) `🦀 If you are new to Rust please visit {bold {green https://www.rust-lang.org }}\n`
|
|
45
44
|
: ''}
|
|
46
45
|
{bold {bgYellow {black Next steps}}}:
|
|
47
|
-
${(0, exports.contractInstructions)(projectName, contract, install)}${(0, exports.gatewayInstructions)(projectName, frontend, install)}`);
|
|
46
|
+
${(0, exports.contractInstructions)(projectName, contract, install, needsToInstallCargoNear)}${(0, exports.gatewayInstructions)(projectName, frontend, install)}`);
|
|
48
47
|
exports.setupSuccess = setupSuccess;
|
|
49
|
-
const contractInstructions = (projectName, contract, install) =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{blue
|
|
57
|
-
|
|
58
|
-
- {inverse
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
const contractInstructions = (projectName, contract, install, needsToInstallCargoNear) => {
|
|
49
|
+
if (contract === 'none') {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
let message = '';
|
|
53
|
+
if (needsToInstallCargoNear) {
|
|
54
|
+
message += (0, chalk_1.default) ` - {inverse Install cargo-near}:
|
|
55
|
+
{blue Go to {bold https://github.com/near/cargo-near}}\n`;
|
|
56
|
+
}
|
|
57
|
+
message += (0, chalk_1.default) ` - {inverse Navigate to your project}:
|
|
58
|
+
{blue cd {bold ${projectName}}}\n`;
|
|
59
|
+
if (contract === 'ts' && !install) {
|
|
60
|
+
message += (0, chalk_1.default) ` - {inverse Install all dependencies}
|
|
61
|
+
{blue npm {bold install}}\n`;
|
|
62
|
+
}
|
|
63
|
+
message += (0, chalk_1.default) ` - {inverse Build your contract}:\n`;
|
|
64
|
+
if (contract === 'ts') {
|
|
65
|
+
message += (0, chalk_1.default) ` {blue npm {bold run build}}\n`;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
message += (0, chalk_1.default) ` {blue {bold cargo near build}}\n`;
|
|
69
|
+
}
|
|
70
|
+
message += (0, chalk_1.default) ` - {inverse Test your contract} in the Sandbox:\n`;
|
|
71
|
+
if (contract === 'ts') {
|
|
72
|
+
message += (0, chalk_1.default) ` {blue npm {bold run test}}\n`;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
message += (0, chalk_1.default) ` {blue {bold cargo near test}}\n`;
|
|
76
|
+
}
|
|
77
|
+
message += (0, chalk_1.default) `\n🧠 Read {bold {greenBright README.md}} to explore further`;
|
|
78
|
+
return message;
|
|
79
|
+
};
|
|
68
80
|
exports.contractInstructions = contractInstructions;
|
|
69
81
|
const gatewayInstructions = (projectName, frontend, install) => frontend === 'none'
|
|
70
82
|
? ''
|
|
@@ -91,12 +103,21 @@ const windowsWarning = () => (0, exports.show)((0, chalk_1.default) `{red Please
|
|
|
91
103
|
exports.windowsWarning = windowsWarning;
|
|
92
104
|
const directoryExists = (dirName) => (0, exports.show)((0, chalk_1.default) `{red This directory already exists! ${dirName}}`);
|
|
93
105
|
exports.directoryExists = directoryExists;
|
|
94
|
-
const creatingApp = () => (0, exports.show)((0, chalk_1.default) `\
|
|
106
|
+
const creatingApp = () => (0, exports.show)((0, chalk_1.default) `\n- Creating a new {bold NEAR dApp}...`);
|
|
95
107
|
exports.creatingApp = creatingApp;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`);
|
|
108
|
+
// Installing dependencies messages
|
|
109
|
+
const depsInstall = () => (0, exports.show)((0, chalk_1.default) `- Installing dependencies in a few folders, this might take a while...`);
|
|
99
110
|
exports.depsInstall = depsInstall;
|
|
100
111
|
const depsInstallError = () => (0, exports.show)(chalk_1.default.red('Error installing NEAR project dependencies'));
|
|
101
112
|
exports.depsInstallError = depsInstallError;
|
|
113
|
+
// Updating files messages
|
|
114
|
+
const updatingFiles = () => (0, exports.show)((0, chalk_1.default) `- Updating Cargo.toml and rust-toolchain.toml files from the remote source...`);
|
|
115
|
+
exports.updatingFiles = updatingFiles;
|
|
116
|
+
const updateFilesFailed = () => (0, exports.show)((0, chalk_1.default) ` {yellow There was a problem during the Cargo.toml and rust-toolchain.toml files remote updating. Check your internet connection.}\n`);
|
|
117
|
+
exports.updateFilesFailed = updateFilesFailed;
|
|
118
|
+
// Checking cargo-near messages
|
|
119
|
+
const checkingCargoNear = () => (0, exports.show)((0, chalk_1.default) `- Checking if cargo-near extension is installed...`);
|
|
120
|
+
exports.checkingCargoNear = checkingCargoNear;
|
|
121
|
+
const cargoNearIsNotInstalled = () => (0, exports.show)((0, chalk_1.default) ` {bold {yellow Did not find cargo-near, please install it to build and deploy Rust contracts: https://github.com/near/cargo-near}}`);
|
|
122
|
+
exports.cargoNearIsNotInstalled = cargoNearIsNotInstalled;
|
|
102
123
|
//# sourceMappingURL=messages.js.map
|
package/dist/tracking.js
CHANGED
|
@@ -45,7 +45,7 @@ const trackUsage = async (frontend, contract) => {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
catch (e) {
|
|
48
|
-
console.error('Warning: problem while sending tracking data
|
|
48
|
+
console.error(' Warning: problem while sending tracking data\n');
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
exports.trackUsage = trackUsage;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
function isCargoNearInstalled() {
|
|
5
|
+
try {
|
|
6
|
+
// execute but hide output
|
|
7
|
+
execSync('cargo near --version', { stdio: 'ignore' });
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = isCargoNearInstalled;
|
|
15
|
+
//# sourceMappingURL=checkCargoNear.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const https_1 = __importDefault(require("https"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const stream_1 = require("stream");
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const streamPipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
11
|
+
async function downloadFile(url, destination) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
https_1.default.get(url, (response) => {
|
|
14
|
+
if (response.statusCode !== 200) {
|
|
15
|
+
reject(new Error(`Downloading failed: ${response.statusCode}`));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
streamPipeline(response, fs_1.default.createWriteStream(destination))
|
|
19
|
+
.then(resolve)
|
|
20
|
+
.catch(reject);
|
|
21
|
+
}).on('error', reject);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.default = downloadFile;
|
|
25
|
+
//# sourceMappingURL=donwloadFile.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isCargoNearInstalled = exports.downloadFile = void 0;
|
|
7
|
+
const donwloadFile_1 = __importDefault(require("./donwloadFile"));
|
|
8
|
+
exports.downloadFile = donwloadFile_1.default;
|
|
9
|
+
const checkCargoNear_1 = __importDefault(require("./checkCargoNear"));
|
|
10
|
+
exports.isCargoNearInstalled = checkCargoNear_1.default;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-near-app",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "Quickly scaffold your dApp on NEAR Blockchain",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"build": "tsc",
|
|
19
19
|
"test": "npm run build && FORCE_COLOR=1 jest --runInBand",
|
|
20
20
|
"test-e2e": "npm run build && ./test/e2e.sh",
|
|
21
|
+
"test:update": "jest -u",
|
|
21
22
|
"lint": "eslint .",
|
|
22
23
|
"fix": "eslint . --fix",
|
|
23
24
|
"release": "npm run build && release-it",
|
|
@@ -15,13 +15,11 @@ jobs:
|
|
|
15
15
|
- name: Checkout repository
|
|
16
16
|
uses: actions/checkout@v4
|
|
17
17
|
- name: Install cargo-near CLI
|
|
18
|
-
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/download/cargo-near-
|
|
18
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh
|
|
19
19
|
- name: Deploy to production
|
|
20
20
|
run: |
|
|
21
21
|
cargo near deploy build-reproducible-wasm "${{ vars.NEAR_CONTRACT_PRODUCTION_ACCOUNT_ID }}" \
|
|
22
22
|
without-init-call \
|
|
23
23
|
network-config "${{ vars.NEAR_CONTRACT_PRODUCTION_NETWORK }}" \
|
|
24
|
-
sign-with-plaintext-private-key \
|
|
25
|
-
--signer-public-key "${{ vars.NEAR_CONTRACT_PRODUCTION_ACCOUNT_PUBLIC_KEY }}" \
|
|
26
|
-
--signer-private-key "${{ secrets.NEAR_CONTRACT_PRODUCTION_ACCOUNT_PRIVATE_KEY }}" \
|
|
24
|
+
sign-with-plaintext-private-key "${{ secrets.NEAR_CONTRACT_PRODUCTION_ACCOUNT_PRIVATE_KEY }}" \
|
|
27
25
|
send
|
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
uses: actions/checkout@v4
|
|
21
21
|
|
|
22
22
|
- name: Install near CLI
|
|
23
|
-
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.
|
|
23
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.20.0/near-cli-rs-installer.sh | sh
|
|
24
24
|
- name: Create staging account
|
|
25
25
|
if: github.event.action == 'opened' || github.event.action == 'reopened'
|
|
26
26
|
run: |
|
|
@@ -28,13 +28,11 @@ jobs:
|
|
|
28
28
|
use-manually-provided-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
|
|
29
29
|
sign-as "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}" \
|
|
30
30
|
network-config "${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}" \
|
|
31
|
-
sign-with-plaintext-private-key \
|
|
32
|
-
--signer-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
|
|
33
|
-
--signer-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
|
|
31
|
+
sign-with-plaintext-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
|
|
34
32
|
send
|
|
35
33
|
|
|
36
34
|
- name: Install cargo-near CLI
|
|
37
|
-
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/download/cargo-near-
|
|
35
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh
|
|
38
36
|
- name: Deploy to staging
|
|
39
37
|
# `--skip-git-remote-check` was used
|
|
40
38
|
# as pull request git refs `refs/pull/NUMBER/merge` are somewhat harder to access and live only as long as PRs do
|
|
@@ -44,9 +42,7 @@ jobs:
|
|
|
44
42
|
cargo near deploy build-reproducible-wasm --skip-git-remote-check "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
|
|
45
43
|
without-init-call \
|
|
46
44
|
network-config "${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}" \
|
|
47
|
-
sign-with-plaintext-private-key \
|
|
48
|
-
--signer-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
|
|
49
|
-
--signer-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
|
|
45
|
+
sign-with-plaintext-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
|
|
50
46
|
send
|
|
51
47
|
|
|
52
48
|
- name: Comment on pull request
|
|
@@ -28,5 +28,7 @@ jobs:
|
|
|
28
28
|
steps:
|
|
29
29
|
- name: Checkout repository
|
|
30
30
|
uses: actions/checkout@v4
|
|
31
|
+
- name: Install cargo-near CLI
|
|
32
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/download/cargo-near-vcargo-near-new-ci-tool-version-self/cargo-near-installer.sh | sh
|
|
31
33
|
- name: Run cargo test
|
|
32
34
|
run: cargo test
|
|
@@ -13,13 +13,11 @@ jobs:
|
|
|
13
13
|
- name: Checkout repository
|
|
14
14
|
uses: actions/checkout@v4
|
|
15
15
|
- name: Install near CLI
|
|
16
|
-
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.
|
|
16
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.20.0/near-cli-rs-installer.sh | sh
|
|
17
17
|
- name: Remove staging account
|
|
18
18
|
run: |
|
|
19
19
|
near account delete-account "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
|
|
20
20
|
beneficiary "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}" \
|
|
21
21
|
network-config "${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}" \
|
|
22
|
-
sign-with-plaintext-private-key \
|
|
23
|
-
--signer-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
|
|
24
|
-
--signer-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
|
|
22
|
+
sign-with-plaintext-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
|
|
25
23
|
send
|
|
@@ -11,30 +11,36 @@ repository = "https://github.com/<xxx>/<xxx>"
|
|
|
11
11
|
[lib]
|
|
12
12
|
crate-type = ["cdylib", "rlib"]
|
|
13
13
|
|
|
14
|
-
# fields to configure build with WASM reproducibility, according to specs
|
|
15
|
-
# in https://github.com/near/NEPs/blob/master/neps/nep-0330.md
|
|
14
|
+
# fields to configure build with WASM reproducibility, according to specs
|
|
15
|
+
# in https://github.com/near/NEPs/blob/master/neps/nep-0330.md
|
|
16
16
|
[package.metadata.near.reproducible_build]
|
|
17
17
|
# docker image, descriptor of build environment
|
|
18
|
-
image = "sourcescan/cargo-near:0.
|
|
18
|
+
image = "sourcescan/cargo-near:0.16.0-rust-1.86.0"
|
|
19
19
|
# tag after colon above serves only descriptive purpose; image is identified by digest
|
|
20
|
-
image_digest = "sha256:
|
|
20
|
+
image_digest = "sha256:3220302ebb7036c1942e772810f21edd9381edf9a339983da43487c77fbad488"
|
|
21
21
|
# list of environment variables names, whose values, if set, will be used as external build parameters
|
|
22
22
|
# in a reproducible manner
|
|
23
23
|
# supported by `sourcescan/cargo-near:0.10.1-rust-1.82.0` image or later images
|
|
24
24
|
passed_env = []
|
|
25
|
-
# build command inside of docker container
|
|
25
|
+
# build command inside of docker container
|
|
26
26
|
# if docker image from default gallery is used https://hub.docker.com/r/sourcescan/cargo-near/tags,
|
|
27
27
|
# the command may be any combination of flags of `cargo-near`,
|
|
28
28
|
# supported by respective version of binary inside the container besides `--no-locked` flag
|
|
29
|
-
container_build_command = [
|
|
29
|
+
container_build_command = [
|
|
30
|
+
"cargo",
|
|
31
|
+
"near",
|
|
32
|
+
"build",
|
|
33
|
+
"non-reproducible-wasm",
|
|
34
|
+
"--locked",
|
|
35
|
+
]
|
|
30
36
|
|
|
31
37
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
32
38
|
[dependencies]
|
|
33
|
-
near-sdk = "5.
|
|
39
|
+
near-sdk = "5.14"
|
|
34
40
|
|
|
35
41
|
[dev-dependencies]
|
|
36
|
-
near-sdk = { version = "5.
|
|
37
|
-
near-workspaces = { version = "0.
|
|
42
|
+
near-sdk = { version = "5.14", features = ["unit-testing"] }
|
|
43
|
+
near-workspaces = { version = "0.20", features = ["unstable"] }
|
|
38
44
|
tokio = { version = "1.12.0", features = ["full"] }
|
|
39
45
|
serde_json = "1"
|
|
40
46
|
|
|
@@ -21,6 +21,12 @@ cargo test
|
|
|
21
21
|
Deployment is automated with GitHub Actions CI/CD pipeline.
|
|
22
22
|
To deploy manually, install [`cargo-near`](https://github.com/near/cargo-near) and run:
|
|
23
23
|
|
|
24
|
+
If you deploy for debugging purposes:
|
|
25
|
+
```bash
|
|
26
|
+
cargo near deploy build-non-reproducible-wasm <account-id>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If you deploy a production ready smart contract:
|
|
24
30
|
```bash
|
|
25
31
|
cargo near deploy build-reproducible-wasm <account-id>
|
|
26
32
|
```
|
|
@@ -12,29 +12,35 @@
|
|
|
12
12
|
"lint": "next lint"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@near-
|
|
16
|
-
"@near-wallet-selector/
|
|
17
|
-
"@near-wallet-selector/
|
|
18
|
-
"@near-wallet-selector/
|
|
19
|
-
"@near-wallet-selector/
|
|
20
|
-
"@near-wallet-selector/ledger": "^
|
|
21
|
-
"@near-wallet-selector/meteor-wallet": "^
|
|
22
|
-
"@near-wallet-selector/
|
|
23
|
-
"@near-wallet-selector/
|
|
24
|
-
"@near-wallet-selector/
|
|
25
|
-
"@
|
|
15
|
+
"@near-wallet-selector/bitte-wallet": "^9.0.2",
|
|
16
|
+
"@near-wallet-selector/core": "^9.0.2",
|
|
17
|
+
"@near-wallet-selector/ethereum-wallets": "^9.0.2",
|
|
18
|
+
"@near-wallet-selector/here-wallet": "^9.0.2",
|
|
19
|
+
"@near-wallet-selector/hot-wallet": "^9.0.2",
|
|
20
|
+
"@near-wallet-selector/ledger": "^9.0.2",
|
|
21
|
+
"@near-wallet-selector/meteor-wallet": "^9.0.2",
|
|
22
|
+
"@near-wallet-selector/meteor-wallet-app": "^9.0.2",
|
|
23
|
+
"@near-wallet-selector/modal-ui": "^9.0.2",
|
|
24
|
+
"@near-wallet-selector/my-near-wallet": "^9.0.2",
|
|
25
|
+
"@near-wallet-selector/near-mobile-wallet": "^9.0.2",
|
|
26
|
+
"@near-wallet-selector/react-hook": "^9.0.2",
|
|
27
|
+
"@near-wallet-selector/sender": "^9.0.2",
|
|
28
|
+
"@near-wallet-selector/welldone-wallet": "^9.0.2",
|
|
29
|
+
"@reown/appkit": "^1.7.7",
|
|
30
|
+
"@reown/appkit-adapter-wagmi": "^1.7.7",
|
|
31
|
+
"@wagmi/core": "^2.17.2",
|
|
26
32
|
"bootstrap": "^5",
|
|
27
33
|
"bootstrap-icons": "^1.11.3",
|
|
28
|
-
"near-api-js": "^
|
|
29
|
-
"next": "
|
|
34
|
+
"near-api-js": "^5.0.0",
|
|
35
|
+
"next": "^15",
|
|
30
36
|
"react": "^18",
|
|
31
37
|
"react-dom": "^18",
|
|
32
|
-
"
|
|
38
|
+
"viem": "^2.30.5"
|
|
33
39
|
},
|
|
34
40
|
"devDependencies": {
|
|
35
41
|
"encoding": "^0.1.13",
|
|
36
|
-
"eslint": "^
|
|
37
|
-
"eslint-config-next": "
|
|
42
|
+
"eslint": "^9",
|
|
43
|
+
"eslint-config-next": "^15",
|
|
38
44
|
"pino-pretty": "^11.2.2"
|
|
39
45
|
}
|
|
40
|
-
}
|
|
46
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useState, useEffect
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
import styles from '@/app/app.module.css';
|
|
5
5
|
import { Cards } from '@/components/cards';
|
|
6
6
|
|
|
7
|
-
import { NearContext } from '@/wallets/near';
|
|
8
7
|
import { HelloNearContract } from '@/config';
|
|
8
|
+
import { useWalletSelector } from '@near-wallet-selector/react-hook';
|
|
9
9
|
|
|
10
10
|
// Contract that the app will interact with
|
|
11
11
|
const CONTRACT = HelloNearContract;
|
|
12
12
|
|
|
13
13
|
export default function HelloNear() {
|
|
14
|
-
const { signedAccountId,
|
|
14
|
+
const { signedAccountId, viewFunction, callFunction } = useWalletSelector();
|
|
15
15
|
|
|
16
16
|
const [greeting, setGreeting] = useState('loading...');
|
|
17
17
|
const [newGreeting, setNewGreeting] = useState('loading...');
|
|
@@ -19,11 +19,9 @@ export default function HelloNear() {
|
|
|
19
19
|
const [showSpinner, setShowSpinner] = useState(false);
|
|
20
20
|
|
|
21
21
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
wallet.viewMethod({ contractId: CONTRACT, method: 'get_greeting' })
|
|
22
|
+
viewFunction({ contractId: CONTRACT, method: 'get_greeting' })
|
|
25
23
|
.then(greeting => setGreeting(greeting));
|
|
26
|
-
}, [
|
|
24
|
+
}, [viewFunction]);
|
|
27
25
|
|
|
28
26
|
useEffect(() => {
|
|
29
27
|
setLoggedIn(!!signedAccountId);
|
|
@@ -31,8 +29,8 @@ export default function HelloNear() {
|
|
|
31
29
|
|
|
32
30
|
const storeGreeting = async () => {
|
|
33
31
|
setShowSpinner(true);
|
|
34
|
-
await
|
|
35
|
-
const greeting = await
|
|
32
|
+
await callFunction({ contractId: CONTRACT, method: 'set_greeting', args: { greeting: newGreeting } });
|
|
33
|
+
const greeting = await viewFunction({ contractId: CONTRACT, method: 'get_greeting' });
|
|
36
34
|
setGreeting(greeting);
|
|
37
35
|
setShowSpinner(false);
|
|
38
36
|
};
|
|
@@ -4,25 +4,50 @@ import { useEffect, useState } from 'react';
|
|
|
4
4
|
|
|
5
5
|
import '@/app/globals.css';
|
|
6
6
|
import { Navigation } from '@/components/navigation';
|
|
7
|
-
import
|
|
7
|
+
import '@near-wallet-selector/modal-ui/styles.css';
|
|
8
|
+
import { setupMyNearWallet } from '@near-wallet-selector/my-near-wallet';
|
|
9
|
+
import { setupMeteorWallet } from '@near-wallet-selector/meteor-wallet';
|
|
10
|
+
import { setupMeteorWalletApp } from '@near-wallet-selector/meteor-wallet-app';
|
|
11
|
+
import { setupBitteWallet } from '@near-wallet-selector/bitte-wallet';
|
|
12
|
+
import { setupEthereumWallets } from '@near-wallet-selector/ethereum-wallets';
|
|
13
|
+
import { setupHotWallet } from '@near-wallet-selector/hot-wallet';
|
|
14
|
+
import { setupLedger } from '@near-wallet-selector/ledger';
|
|
15
|
+
import { setupSender } from '@near-wallet-selector/sender';
|
|
16
|
+
import { setupHereWallet } from '@near-wallet-selector/here-wallet';
|
|
17
|
+
import { setupNearMobileWallet } from '@near-wallet-selector/near-mobile-wallet';
|
|
18
|
+
import { setupWelldoneWallet } from '@near-wallet-selector/welldone-wallet';
|
|
19
|
+
import { HelloNearContract, NetworkId } from '@/config';
|
|
20
|
+
import { WalletSelectorProvider } from '@near-wallet-selector/react-hook';
|
|
21
|
+
import { wagmiAdapter, web3Modal } from '@/wallets/web3modal';
|
|
8
22
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
const walletSelectorConfig = {
|
|
24
|
+
network: NetworkId,
|
|
25
|
+
// createAccessKeyFor: HelloNearContract,
|
|
26
|
+
modules: [
|
|
27
|
+
setupMeteorWallet(),
|
|
28
|
+
setupEthereumWallets({ wagmiConfig: wagmiAdapter.wagmiConfig, web3Modal }),
|
|
29
|
+
setupBitteWallet(),
|
|
30
|
+
setupMeteorWalletApp({ contractId: HelloNearContract }),
|
|
31
|
+
setupHotWallet(),
|
|
32
|
+
setupLedger(),
|
|
33
|
+
setupSender(),
|
|
34
|
+
setupHereWallet(),
|
|
35
|
+
setupNearMobileWallet(),
|
|
36
|
+
setupWelldoneWallet(),
|
|
37
|
+
setupMyNearWallet(),
|
|
38
|
+
],
|
|
39
|
+
}
|
|
12
40
|
|
|
13
41
|
// Layout Component
|
|
14
42
|
export default function RootLayout({ children }) {
|
|
15
|
-
const [signedAccountId, setSignedAccountId] = useState('');
|
|
16
|
-
|
|
17
|
-
useEffect(() => { wallet.startUp(setSignedAccountId); }, []);
|
|
18
43
|
|
|
19
44
|
return (
|
|
20
45
|
<html lang="en">
|
|
21
46
|
<body>
|
|
22
|
-
<
|
|
47
|
+
<WalletSelectorProvider config={walletSelectorConfig}>
|
|
23
48
|
<Navigation />
|
|
24
49
|
{children}
|
|
25
|
-
</
|
|
50
|
+
</WalletSelectorProvider>
|
|
26
51
|
</body>
|
|
27
52
|
</html>
|
|
28
53
|
);
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import Image from 'next/image';
|
|
2
2
|
import Link from 'next/link';
|
|
3
|
-
import { useEffect, useState
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
4
|
|
|
5
|
-
import { NearContext } from '@/wallets/near';
|
|
6
5
|
import NearLogo from '/public/near-logo.svg';
|
|
6
|
+
import { useWalletSelector } from '@near-wallet-selector/react-hook';
|
|
7
7
|
|
|
8
8
|
export const Navigation = () => {
|
|
9
|
-
const { signedAccountId,
|
|
9
|
+
const { signedAccountId, signIn, signOut } = useWalletSelector();
|
|
10
10
|
const [action, setAction] = useState(() => { });
|
|
11
11
|
const [label, setLabel] = useState('Loading...');
|
|
12
12
|
|
|
13
13
|
useEffect(() => {
|
|
14
|
-
if (!wallet) return;
|
|
15
|
-
|
|
16
14
|
if (signedAccountId) {
|
|
17
|
-
setAction(() =>
|
|
15
|
+
setAction(() => signOut);
|
|
18
16
|
setLabel(`Logout ${signedAccountId}`);
|
|
19
17
|
} else {
|
|
20
|
-
setAction(() =>
|
|
18
|
+
setAction(() => signIn);
|
|
21
19
|
setLabel('Login');
|
|
22
20
|
}
|
|
23
|
-
}, [signedAccountId,
|
|
21
|
+
}, [signedAccountId, signIn, signOut]);
|
|
24
22
|
|
|
25
23
|
return (
|
|
26
24
|
<nav className="navbar navbar-expand-lg">
|
|
27
25
|
<div className="container-fluid">
|
|
28
|
-
<Link href="/" passHref
|
|
26
|
+
<Link href="/" passHref>
|
|
29
27
|
<Image priority src={NearLogo} alt="NEAR" width="30" height="24" className="d-inline-block align-text-top" />
|
|
30
28
|
</Link>
|
|
31
29
|
<div className='navbar-nav pt-1'>
|