create-near-app 7.0.3 → 8.1.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 +1 -2
- package/dist/make.js +3 -7
- package/dist/messages.js +3 -2
- package/dist/tracking.js +32 -15
- package/dist/types.js +1 -1
- package/dist/user-input.js +10 -20
- package/package.json +3 -4
- package/templates/contracts/rs/.github/workflows/deploy-production.yml +27 -0
- package/templates/contracts/rs/.github/workflows/deploy-staging.yml +56 -0
- package/templates/contracts/rs/.github/workflows/test.yml +32 -0
- package/templates/contracts/rs/.github/workflows/undeploy-staging.yml +25 -0
- package/templates/contracts/rs/Cargo.lock +973 -3244
- package/templates/contracts/rs/Cargo.toml +23 -6
- package/templates/contracts/rs/README.md +5 -7
- package/templates/contracts/rs/src/lib.rs +1 -1
- package/templates/contracts/rs/tests/test_basics.rs +11 -14
- package/templates/contracts/ts/package.json +1 -1
- package/templates/frontend/next-app/package.json +17 -14
- package/templates/frontend/next-app/src/app/hello-near/page.js +1 -1
- package/templates/frontend/next-app/src/app/layout.js +3 -4
- package/templates/frontend/next-app/src/components/navigation.js +1 -1
- package/templates/frontend/next-app/src/config.js +18 -1
- package/templates/frontend/next-app/src/wallets/near.js +48 -11
- package/templates/frontend/next-app/src/wallets/web3modal.js +44 -0
- package/templates/frontend/next-page/package.json +17 -14
- package/templates/frontend/next-page/src/components/navigation.js +1 -1
- package/templates/frontend/next-page/src/config.js +18 -1
- package/templates/frontend/next-page/src/pages/_app.js +3 -4
- package/templates/frontend/next-page/src/pages/hello-near/index.js +1 -1
- package/templates/frontend/next-page/src/wallets/near.js +48 -11
- package/templates/frontend/next-page/src/wallets/web3modal.js +44 -0
- package/templates/frontend/vite-react/eslint.config.js +38 -0
- package/templates/frontend/vite-react/index.html +13 -0
- package/templates/frontend/vite-react/package.json +50 -0
- package/templates/frontend/vite-react/public/favicon.ico +0 -0
- package/templates/frontend/vite-react/src/App.jsx +36 -0
- package/templates/frontend/vite-react/src/assets/near-logo.svg +43 -0
- package/templates/frontend/vite-react/src/assets/near.svg +1 -0
- package/templates/frontend/vite-react/src/assets/react.svg +1 -0
- package/templates/frontend/{components/next-page/src/components/cards.js → vite-react/src/components/cards.jsx} +6 -22
- package/templates/frontend/vite-react/src/components/navigation.jsx +39 -0
- package/templates/frontend/vite-react/src/config.js +24 -0
- package/templates/frontend/vite-react/src/main.jsx +11 -0
- package/templates/frontend/vite-react/src/pages/hello_near.jsx +75 -0
- package/templates/frontend/vite-react/src/pages/home.jsx +31 -0
- package/templates/frontend/vite-react/src/styles/app.module.css +226 -0
- package/templates/frontend/vite-react/src/styles/globals.css +88 -0
- package/templates/frontend/vite-react/src/wallets/near.js +228 -0
- package/templates/frontend/vite-react/src/wallets/web3modal.js +42 -0
- package/templates/frontend/vite-react/vite.config.js +27 -0
- package/dist/package-json.js +0 -130
- package/templates/frontend/components/next-app/package.json +0 -42
- package/templates/frontend/components/next-app/src/app/hello-components/page.js +0 -46
- package/templates/frontend/components/next-app/src/components/cards.js +0 -43
- package/templates/frontend/components/next-app/src/components/vm.js +0 -31
- package/templates/frontend/components/next-app/src/config.js +0 -23
- package/templates/frontend/components/next-app/src/wallets/eth.ts +0 -289
- package/templates/frontend/components/next-page/package.json +0 -42
- package/templates/frontend/components/next-page/src/components/vm.js +0 -29
- package/templates/frontend/components/next-page/src/config.js +0 -23
- package/templates/frontend/components/next-page/src/pages/hello-components/index.js +0 -46
- package/templates/frontend/components/next-page/src/wallets/eth.ts +0 -289
- package/templates/frontend/next-app/src/context.js +0 -13
- package/templates/frontend/next-page/src/context.js +0 -13
package/dist/app.js
CHANGED
|
@@ -39,14 +39,13 @@ const show = __importStar(require("./messages"));
|
|
|
39
39
|
const prompt = await (0, user_input_1.promptAndGetConfig)();
|
|
40
40
|
if (prompt === undefined)
|
|
41
41
|
return;
|
|
42
|
-
const { config: { projectName, contract, frontend,
|
|
42
|
+
const { config: { projectName, contract, frontend, install, }, projectPath, } = prompt;
|
|
43
43
|
show.creatingApp();
|
|
44
44
|
let createSuccess;
|
|
45
45
|
try {
|
|
46
46
|
createSuccess = await (0, make_1.createProject)({
|
|
47
47
|
contract,
|
|
48
48
|
frontend,
|
|
49
|
-
components,
|
|
50
49
|
templatesDir: path_1.default.resolve(__dirname, '../templates'),
|
|
51
50
|
projectPath,
|
|
52
51
|
});
|
package/dist/make.js
CHANGED
|
@@ -32,12 +32,12 @@ const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
|
32
32
|
const fs_1 = __importDefault(require("fs"));
|
|
33
33
|
const ncp_1 = require("ncp");
|
|
34
34
|
const path_1 = __importDefault(require("path"));
|
|
35
|
-
async function createProject({ contract, frontend,
|
|
35
|
+
async function createProject({ contract, frontend, projectPath, templatesDir }) {
|
|
36
36
|
if (contract !== 'none') {
|
|
37
37
|
await createContract({ contract, projectPath, templatesDir });
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
await createGateway({ frontend,
|
|
40
|
+
await createGateway({ frontend, projectPath, templatesDir });
|
|
41
41
|
}
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
@@ -48,14 +48,10 @@ async function createContract({ contract, projectPath, templatesDir }) {
|
|
|
48
48
|
fs_1.default.mkdirSync(projectPath, { recursive: true });
|
|
49
49
|
await copyDir(sourceContractDir, projectPath);
|
|
50
50
|
}
|
|
51
|
-
async function createGateway({ frontend,
|
|
51
|
+
async function createGateway({ frontend, projectPath, templatesDir }) {
|
|
52
52
|
const sourceFrontendDir = path_1.default.resolve(`${templatesDir}/frontend/${frontend}`);
|
|
53
53
|
fs_1.default.mkdirSync(projectPath, { recursive: true });
|
|
54
54
|
await copyDir(sourceFrontendDir, projectPath);
|
|
55
|
-
if (components) {
|
|
56
|
-
const sourceComponentsDir = path_1.default.resolve(`${templatesDir}/frontend/components/${frontend}`);
|
|
57
|
-
await copyDir(sourceComponentsDir, projectPath);
|
|
58
|
-
}
|
|
59
55
|
}
|
|
60
56
|
// Wrap `ncp` tool to wait for the copy to finish when using `await`
|
|
61
57
|
function copyDir(source, dest) {
|
package/dist/messages.js
CHANGED
|
@@ -16,7 +16,7 @@ const welcome = () => (0, exports.show)((0, chalk_1.default) `
|
|
|
16
16
|
👋 {bold {green Welcome to Near!}} Learn more: https://docs.near.org/
|
|
17
17
|
🔧 Let's get your project ready.
|
|
18
18
|
{blue ======================================================}
|
|
19
|
-
(${tracking_1.trackingMessage})`);
|
|
19
|
+
(${tracking_1.trackingMessage})\n`);
|
|
20
20
|
exports.welcome = welcome;
|
|
21
21
|
const setupFailed = () => (0, exports.show)((0, chalk_1.default) `{bold {red ==========================================}}
|
|
22
22
|
{red ⛔️ There was a problem during the project setup}.
|
|
@@ -30,7 +30,8 @@ const successContractToText = (contract) => contract === 'none'
|
|
|
30
30
|
exports.successContractToText = successContractToText;
|
|
31
31
|
const frontendTemplates = {
|
|
32
32
|
'next-page': 'NextJS (Classic)',
|
|
33
|
-
'next-app': 'NextJS (App Router)'
|
|
33
|
+
'next-app': 'NextJS (App Router)',
|
|
34
|
+
'vite-react': 'Vite React'
|
|
34
35
|
};
|
|
35
36
|
const successFrontendToText = (frontend) => frontend === 'none'
|
|
36
37
|
? ''
|
package/dist/tracking.js
CHANGED
|
@@ -5,27 +5,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.trackUsage = exports.trackingMessage = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
exports.trackingMessage = (0, chalk_1.default) `Near collects anonymous information on the commands used. No personal information that could identify you is shared`;
|
|
8
|
+
const POSTHOG_API_KEY = 'phc_95PGQnbyatmj2TBRPWYfhbHfqB6wgZj5QRL8WY9gW20';
|
|
9
|
+
const POSTHOG_API_URL = 'https://eu.i.posthog.com/capture';
|
|
10
|
+
exports.trackingMessage = chalk_1.default.italic('Near collects anonymous information on the commands used. No personal information that could identify you is shared');
|
|
12
11
|
// TODO: track different failures & install usage
|
|
13
|
-
const trackUsage = async (frontend,
|
|
12
|
+
const trackUsage = async (frontend, contract) => {
|
|
14
13
|
// prevents logging from CI
|
|
15
14
|
if (process.env.NEAR_ENV === 'ci' || process.env.NODE_ENV === 'ci') {
|
|
16
|
-
console.log('
|
|
15
|
+
console.log('PostHog logging is skipped in CI env');
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const payload = {
|
|
19
|
+
distinct_id: 'create-near-app',
|
|
20
|
+
event: 'error',
|
|
21
|
+
properties: {
|
|
22
|
+
engine: process.versions.node,
|
|
24
23
|
os: process.platform,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
},
|
|
25
|
+
timestamp: new Date(),
|
|
26
|
+
};
|
|
27
|
+
if (contract !== 'none') {
|
|
28
|
+
payload.event = 'contract';
|
|
29
|
+
payload.properties.language = contract;
|
|
30
|
+
}
|
|
31
|
+
if (frontend !== 'none') {
|
|
32
|
+
payload.event = 'frontend';
|
|
33
|
+
payload.properties.framework = frontend;
|
|
34
|
+
}
|
|
35
|
+
const headers = new Headers();
|
|
36
|
+
headers.append('Content-Type', 'application/json');
|
|
37
|
+
try {
|
|
38
|
+
await fetch(POSTHOG_API_URL, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
api_key: POSTHOG_API_KEY,
|
|
42
|
+
...payload,
|
|
43
|
+
}),
|
|
44
|
+
headers,
|
|
45
|
+
});
|
|
29
46
|
}
|
|
30
47
|
catch (e) {
|
|
31
48
|
console.error('Warning: problem while sending tracking data. Error: ', e);
|
package/dist/types.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.APPS = exports.FRONTENDS = exports.CONTRACTS = void 0;
|
|
4
4
|
exports.CONTRACTS = ['ts', 'rs', 'none'];
|
|
5
|
-
exports.FRONTENDS = ['next-app', 'next-page', 'none'];
|
|
5
|
+
exports.FRONTENDS = ['next-app', 'next-page', 'vite-react', 'none'];
|
|
6
6
|
exports.APPS = ['contract', 'gateway'];
|
|
7
7
|
//# sourceMappingURL=types.js.map
|
package/dist/user-input.js
CHANGED
|
@@ -39,14 +39,13 @@ async function getUserArgs() {
|
|
|
39
39
|
.argument('[projectName]')
|
|
40
40
|
.option('--frontend [next-page|next-app|none]')
|
|
41
41
|
.option('--contract [ts|rs|none]')
|
|
42
|
-
.option('--components')
|
|
43
42
|
.option('--install')
|
|
44
43
|
.addHelpText('after', 'You can create a frontend or a contract with tests');
|
|
45
44
|
commander_1.program.parse();
|
|
46
45
|
const options = commander_1.program.opts();
|
|
47
46
|
const [projectName] = commander_1.program.args;
|
|
48
|
-
const { contract, frontend, install
|
|
49
|
-
return { contract, frontend,
|
|
47
|
+
const { contract, frontend, install } = options;
|
|
48
|
+
return { contract, frontend, projectName, install, error: undefined };
|
|
50
49
|
}
|
|
51
50
|
exports.getUserArgs = getUserArgs;
|
|
52
51
|
const appChoices = [
|
|
@@ -62,10 +61,7 @@ const contractChoices = [
|
|
|
62
61
|
const frontendChoices = [
|
|
63
62
|
{ title: 'NextJs (Classic)', description: 'A web-app built using Next.js Page Router', value: 'next-page' },
|
|
64
63
|
{ title: 'NextJS (App Router)', description: 'A web-app built using Next.js new App Router', value: 'next-app' },
|
|
65
|
-
|
|
66
|
-
const componentChoices = [
|
|
67
|
-
{ title: 'No', value: false },
|
|
68
|
-
{ title: 'Yes', value: true },
|
|
64
|
+
{ title: 'Vite (React)', description: 'A web-app built using Vite with React', value: 'vite-react' },
|
|
69
65
|
];
|
|
70
66
|
const appPrompt = {
|
|
71
67
|
type: 'select',
|
|
@@ -79,12 +75,6 @@ const frontendPrompt = {
|
|
|
79
75
|
message: 'Select a framework for your frontend',
|
|
80
76
|
choices: frontendChoices,
|
|
81
77
|
};
|
|
82
|
-
const componentsPrompt = {
|
|
83
|
-
type: 'select',
|
|
84
|
-
name: 'components',
|
|
85
|
-
message: 'Are you planning in using on-chain NEAR Components (aka BOS Components)?',
|
|
86
|
-
choices: componentChoices,
|
|
87
|
-
};
|
|
88
78
|
const contractPrompt = [
|
|
89
79
|
{
|
|
90
80
|
type: 'select',
|
|
@@ -114,19 +104,19 @@ async function getUserAnswers() {
|
|
|
114
104
|
const { app } = await promptUser(appPrompt);
|
|
115
105
|
if (app === 'gateway') {
|
|
116
106
|
// If gateway, ask for the framework to use
|
|
117
|
-
const { frontend,
|
|
118
|
-
return { frontend,
|
|
107
|
+
const { frontend, projectName, install } = await promptUser([frontendPrompt, namePrompts, npmPrompt]);
|
|
108
|
+
return { frontend, contract: 'none', projectName, install, error: undefined };
|
|
119
109
|
}
|
|
120
110
|
else {
|
|
121
111
|
// If platform is Window, return the error
|
|
122
112
|
if (process.platform === 'win32') {
|
|
123
|
-
return { frontend: 'none',
|
|
113
|
+
return { frontend: 'none', contract: 'none', projectName: '', install: false, error: show.windowsWarning };
|
|
124
114
|
}
|
|
125
115
|
// If contract, ask for the language for the contract
|
|
126
116
|
let { contract } = await promptUser(contractPrompt);
|
|
127
117
|
const { projectName } = await promptUser(namePrompts);
|
|
128
118
|
const install = contract === 'ts' ? (await promptUser(npmPrompt)).install : false;
|
|
129
|
-
return { frontend: 'none',
|
|
119
|
+
return { frontend: 'none', contract, projectName, install, error: undefined };
|
|
130
120
|
}
|
|
131
121
|
}
|
|
132
122
|
exports.getUserAnswers = getUserAnswers;
|
|
@@ -139,7 +129,7 @@ async function promptAndGetConfig() {
|
|
|
139
129
|
args = await getUserAnswers();
|
|
140
130
|
}
|
|
141
131
|
if (args.error) {
|
|
142
|
-
(0, tracking_1.trackUsage)('none',
|
|
132
|
+
(0, tracking_1.trackUsage)('none', 'none');
|
|
143
133
|
return args.error();
|
|
144
134
|
}
|
|
145
135
|
// Homogenizing terminal args with prompt args
|
|
@@ -148,8 +138,8 @@ async function promptAndGetConfig() {
|
|
|
148
138
|
if (!validateUserArgs(args))
|
|
149
139
|
return;
|
|
150
140
|
// track user input
|
|
151
|
-
const { frontend,
|
|
152
|
-
(0, tracking_1.trackUsage)(frontend,
|
|
141
|
+
const { frontend, contract } = args;
|
|
142
|
+
(0, tracking_1.trackUsage)(frontend, contract);
|
|
153
143
|
let path = (0, exports.projectPath)(args.projectName);
|
|
154
144
|
if (fs_1.default.existsSync(path)) {
|
|
155
145
|
return show.directoryExists(path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-near-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Quickly scaffold your dApp on NEAR Blockchain",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -27,16 +27,15 @@
|
|
|
27
27
|
"chalk": "^4.1.2",
|
|
28
28
|
"commander": "^11.0.0",
|
|
29
29
|
"cross-spawn": "^7.0.3",
|
|
30
|
-
"mixpanel": "^0.18.0",
|
|
31
30
|
"ncp": "^2.0.0",
|
|
32
31
|
"prompts": "^2.4.2",
|
|
33
32
|
"semver": "^7.5.3"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@babel/eslint-parser": "^7.22.5",
|
|
37
35
|
"@babel/core": "^7.23.2",
|
|
38
|
-
"@babel/
|
|
36
|
+
"@babel/eslint-parser": "^7.22.5",
|
|
39
37
|
"@babel/plugin-syntax-flow": "^7.22.5",
|
|
38
|
+
"@babel/plugin-transform-react-jsx": "^7.22.15",
|
|
40
39
|
"@commitlint/cli": "^17.6.6",
|
|
41
40
|
"@commitlint/config-conventional": "^17.6.6",
|
|
42
41
|
"@release-it/conventional-changelog": "^5.1.1",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Deploy to production
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
uses: ./.github/workflows/test.yml
|
|
9
|
+
|
|
10
|
+
deploy-staging:
|
|
11
|
+
name: Deploy to production
|
|
12
|
+
needs: [test]
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout repository
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
- name: Install cargo-near CLI
|
|
18
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/download/cargo-near-v0.13.2/cargo-near-installer.sh | sh
|
|
19
|
+
- name: Deploy to production
|
|
20
|
+
run: |
|
|
21
|
+
cargo near deploy build-reproducible-wasm "${{ vars.NEAR_CONTRACT_PRODUCTION_ACCOUNT_ID }}" \
|
|
22
|
+
without-init-call \
|
|
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 }}" \
|
|
27
|
+
send
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: Deploy to staging
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
uses: ./.github/workflows/test.yml
|
|
8
|
+
|
|
9
|
+
deploy-staging:
|
|
10
|
+
name: Deploy to staging subaccount
|
|
11
|
+
permissions:
|
|
12
|
+
pull-requests: write
|
|
13
|
+
needs: [test]
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
env:
|
|
16
|
+
NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID: gh-${{ github.event.number }}.${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout repository
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Install near CLI
|
|
23
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.11.1/near-cli-rs-installer.sh | sh
|
|
24
|
+
- name: Create staging account
|
|
25
|
+
if: github.event.action == 'opened' || github.event.action == 'reopened'
|
|
26
|
+
run: |
|
|
27
|
+
near account create-account fund-myself "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" '10 NEAR' \
|
|
28
|
+
use-manually-provided-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
|
|
29
|
+
sign-as "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}" \
|
|
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 }}" \
|
|
34
|
+
send
|
|
35
|
+
|
|
36
|
+
- name: Install cargo-near CLI
|
|
37
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/download/cargo-near-v0.13.2/cargo-near-installer.sh | sh
|
|
38
|
+
- name: Deploy to staging
|
|
39
|
+
# `--skip-git-remote-check` was used
|
|
40
|
+
# as pull request git refs `refs/pull/NUMBER/merge` are somewhat harder to access and live only as long as PRs do
|
|
41
|
+
#
|
|
42
|
+
# WASM reproducibility check akin to SourceScan won't be available for staging contracts, deployed from PRs
|
|
43
|
+
run: |
|
|
44
|
+
cargo near deploy build-reproducible-wasm --skip-git-remote-check "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
|
|
45
|
+
without-init-call \
|
|
46
|
+
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 }}" \
|
|
50
|
+
send
|
|
51
|
+
|
|
52
|
+
- name: Comment on pull request
|
|
53
|
+
env:
|
|
54
|
+
GH_TOKEN: ${{ github.token }}
|
|
55
|
+
run: |
|
|
56
|
+
gh pr comment "${{ github.event.number }}" --body "Staging contract is deployed to ["'`'"${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}"'`'" account](https://explorer.${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}.near.org/accounts/${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }})"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
workflow_call:
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
code-formatting:
|
|
7
|
+
name: Code Formatting
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Checkout repository
|
|
11
|
+
uses: actions/checkout@v4
|
|
12
|
+
- run: cargo fmt --check
|
|
13
|
+
|
|
14
|
+
code-linter:
|
|
15
|
+
name: Code Linter
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
- name: Run cargo clippy
|
|
21
|
+
run: |
|
|
22
|
+
rustup component add clippy
|
|
23
|
+
cargo clippy --all-features --workspace --tests -- --warn clippy::all --warn clippy::nursery
|
|
24
|
+
|
|
25
|
+
tests:
|
|
26
|
+
name: Tests
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- name: Checkout repository
|
|
30
|
+
uses: actions/checkout@v4
|
|
31
|
+
- name: Run cargo test
|
|
32
|
+
run: cargo test
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Undeploy staging
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types: [closed]
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
cleanup-staging:
|
|
8
|
+
name: Cleanup staging account
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
env:
|
|
11
|
+
NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID: gh-${{ github.event.number }}.${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
- name: Install near CLI
|
|
16
|
+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.11.1/near-cli-rs-installer.sh | sh
|
|
17
|
+
- name: Remove staging account
|
|
18
|
+
run: |
|
|
19
|
+
near account delete-account "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
|
|
20
|
+
beneficiary "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}" \
|
|
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 }}" \
|
|
25
|
+
send
|