Skip to content

Commit

Permalink
Update contracts (#2163)
Browse files Browse the repository at this point in the history
* feat: added vite template

* feat: added vite template

* feat: added vite template

* minor changes

* feat: change routing to react router

* chore: handle dependencies

* feat: update contracts

* chore: update tests

* chore: update node version on actions

* chore: remove env form test

* chore: update tests

* chore: update tests

* chore: add locks

* chore: release v8.1.0

---------

Co-authored-by: Matias Benary <[email protected]>
Co-authored-by: Guillermo Alejandro Gallardo Diez <[email protected]>
Co-authored-by: Guillermo Alejandro Gallardo Diez <[email protected]>
  • Loading branch information
4 people authored Jan 4, 2025
1 parent e3982e3 commit 8edb98b
Show file tree
Hide file tree
Showing 18 changed files with 4,183 additions and 3,603 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-contract-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '22'
- name: Install modules
run: npm install
- name: Create Contract TS
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '22'
- name: Install modules
run: npm install
- name: Run tests
env:
NEAR_ENV: ci
IS_GITHUB_ACTION: true
FORCE_COLOR: 1
run: npm test
44 changes: 4 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-near-app",
"version": "8.0.0",
"version": "8.1.0",
"description": "Quickly scaffold your dApp on NEAR Blockchain",
"main": "index.js",
"engines": {
Expand Down
27 changes: 27 additions & 0 deletions templates/contracts/rs/.github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy to production
on:
push:
branches: [main]

jobs:
test:
uses: ./.github/workflows/test.yml

deploy-staging:
name: Deploy to production
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-near CLI
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
- name: Deploy to production
run: |
cargo near deploy build-reproducible-wasm "${{ vars.NEAR_CONTRACT_PRODUCTION_ACCOUNT_ID }}" \
without-init-call \
network-config "${{ vars.NEAR_CONTRACT_PRODUCTION_NETWORK }}" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.NEAR_CONTRACT_PRODUCTION_ACCOUNT_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.NEAR_CONTRACT_PRODUCTION_ACCOUNT_PRIVATE_KEY }}" \
send
56 changes: 56 additions & 0 deletions templates/contracts/rs/.github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy to staging
on:
pull_request:

jobs:
test:
uses: ./.github/workflows/test.yml

deploy-staging:
name: Deploy to staging subaccount
permissions:
pull-requests: write
needs: [test]
runs-on: ubuntu-latest
env:
NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID: gh-${{ github.event.number }}.${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install near CLI
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
- name: Create staging account
if: github.event.action == 'opened' || github.event.action == 'reopened'
run: |
near account create-account fund-myself "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" '10 NEAR' \
use-manually-provided-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
sign-as "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}" \
network-config "${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
send
- name: Install cargo-near CLI
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
- name: Deploy to staging
# `--skip-git-remote-check` was used
# as pull request git refs `refs/pull/NUMBER/merge` are somewhat harder to access and live only as long as PRs do
#
# WASM reproducibility check akin to SourceScan won't be available for staging contracts, deployed from PRs
run: |
cargo near deploy build-reproducible-wasm --skip-git-remote-check "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
without-init-call \
network-config "${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
send
- name: Comment on pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
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 }})"
32 changes: 32 additions & 0 deletions templates/contracts/rs/.github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test
on:
workflow_call:

jobs:
code-formatting:
name: Code Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: cargo fmt --check

code-linter:
name: Code Linter
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo clippy
run: |
rustup component add clippy
cargo clippy --all-features --workspace --tests -- --warn clippy::all --warn clippy::nursery
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo test
run: cargo test
25 changes: 25 additions & 0 deletions templates/contracts/rs/.github/workflows/undeploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Undeploy staging
on:
pull_request:
types: [closed]

jobs:
cleanup-staging:
name: Cleanup staging account
runs-on: ubuntu-latest
env:
NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID: gh-${{ github.event.number }}.${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install near CLI
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
- name: Remove staging account
run: |
near account delete-account "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
beneficiary "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}" \
network-config "${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}" \
sign-with-plaintext-private-key \
--signer-public-key "${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_PUBLIC_KEY }}" \
--signer-private-key "${{ secrets.NEAR_CONTRACT_STAGING_ACCOUNT_PRIVATE_KEY }}" \
send
1 change: 1 addition & 0 deletions templates/contracts/rs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading

0 comments on commit 8edb98b

Please sign in to comment.