diff --git a/.github/actions/diffs/action.yml b/.github/actions/diffs/action.yml index c7bc240b392..f940c9b26d9 100644 --- a/.github/actions/diffs/action.yml +++ b/.github/actions/diffs/action.yml @@ -59,6 +59,9 @@ runs: - "examples/**" - "iota_programmability/**" - ".github/workflows/_move_tests.yml" + isRosetta: + - ".github/scripts/rosetta/**" + - "crates/iota-rosetta/**" isExternalCrates: - "external-crates/move/crates/**" isReleaseNotesEligible: diff --git a/.github/scripts/rosetta/setup.sh b/.github/scripts/rosetta/setup.sh index 6ad5bef07a6..308006ca289 100755 --- a/.github/scripts/rosetta/setup.sh +++ b/.github/scripts/rosetta/setup.sh @@ -7,11 +7,15 @@ echo "Install binaries" cargo install --locked --bin iota --path crates/iota cargo install --locked --bin iota-rosetta --path crates/iota-rosetta +echo "create dedicated config dir for IOTA genesis" +CONFIG_DIR="~/.iota/rosetta_config" +mkdir -p $CONFIG_DIR + echo "run IOTA genesis" -iota genesis +iota genesis -f --working-dir $CONFIG_DIR echo "generate rosetta configuration" iota-rosetta generate-rosetta-cli-config --online-url http://127.0.0.1:9002 --offline-url http://127.0.0.1:9003 echo "install rosetta-cli" -curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s \ No newline at end of file +curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s diff --git a/.github/workflows/_rosetta.yml b/.github/workflows/_rosetta.yml new file mode 100644 index 00000000000..423158a1f47 --- /dev/null +++ b/.github/workflows/_rosetta.yml @@ -0,0 +1,55 @@ +name: Rosetta validation + +on: workflow_call + +concurrency: + group: rosetta-validation-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/develop' }} + +env: + CARGO_TERM_COLOR: always + RUST_LOG: "error" + # Don't emit giant backtraces in the CI logs. + RUST_BACKTRACE: short + CARGO_INCREMENTAL: 0 + # Allow more retries for network requests in cargo (downloading crates) and + # rustup (installing toolchains). This should help to reduce flaky CI failures + # from transient network timeouts or other issues. + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + # RUSTFLAGS: -D warnings + RUSTDOCFLAGS: -D warnings + +jobs: + validation: + timeout-minutes: 45 + runs-on: [self-hosted] + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + + - name: Setup environment + run: .github/scripts/rosetta/setup.sh + shell: bash + + - name: Start local IOTA network + run: | + iota start --no-full-node & + shell: bash + + - name: Start Rosetta servers + run: .github/scripts/rosetta/start_rosetta.sh + shell: bash + + - name: Sleep for 20 seconds + run: sleep 20s + shell: bash + + - name: Run check:construction test + run: | + ./bin/rosetta-cli --configuration-file rosetta_cli.json check:construction + shell: bash + + - name: Run check:data test + run: | + ./bin/rosetta-cli --configuration-file rosetta_cli.json check:data + shell: bash diff --git a/.github/workflows/_rust_tests.yml b/.github/workflows/_rust_tests.yml index da2303c56e4..75a96614c06 100644 --- a/.github/workflows/_rust_tests.yml +++ b/.github/workflows/_rust_tests.yml @@ -159,39 +159,6 @@ jobs: eval ${command} - rosetta-validation: - timeout-minutes: 45 - runs-on: [self-hosted] - steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - - - name: Setup environment - run: .github/scripts/rosetta/setup.sh - shell: bash - - - name: Start local IOTA network - run: | - iota start --no-full-node & - shell: bash - - - name: Start Rosetta servers - run: .github/scripts/rosetta/start_rosetta.sh - shell: bash - - - name: Sleep for 20 seconds - run: sleep 20s - shell: bash - - - name: Run check:construction test - run: | - ./bin/rosetta-cli --configuration-file rosetta_cli.json check:construction - shell: bash - - - name: Run check:data test - run: | - ./bin/rosetta-cli --configuration-file rosetta_cli.json check:data - shell: bash - graphql-rpc: name: graphql-rpc timeout-minutes: 45 diff --git a/.github/workflows/hierarchy.yml b/.github/workflows/hierarchy.yml index 9c61f02a77d..c5def7a8b1b 100644 --- a/.github/workflows/hierarchy.yml +++ b/.github/workflows/hierarchy.yml @@ -20,6 +20,7 @@ jobs: outputs: isRust: ${{ steps.diff.outputs.isRust }} isMove: ${{ steps.diff.outputs.isMove }} + isRosetta: ${{ steps.diff.outputs.isRosetta }} isDoc: ${{ steps.diff.outputs.isDoc }} isReleaseNotesEligible: ${{ steps.diff.outputs.isReleaseNotesEligible }} isExternalCrates: ${{ steps.diff.outputs.isExternalCrates }} @@ -107,6 +108,17 @@ jobs: with: isRust: ${{ needs.diff.outputs.isRust == 'true' }} + rosetta: + needs: + - diff + - dprint-format + - license-check + - typos + if: | + !cancelled() && !failure() && + (needs.diff.outputs.isRosetta == 'true' || needs.diff.outputs.isRust == 'true') + uses: ./.github/workflows/_rosetta.yml + e2e: if: (!cancelled() && !failure() && (!github.event.pull_request.draft || github.ref_name == 'develop')) needs: diff --git a/.github/workflows/release_move_ide.yml b/.github/workflows/release_move_ide.yml new file mode 100644 index 00000000000..553b02e1f86 --- /dev/null +++ b/.github/workflows/release_move_ide.yml @@ -0,0 +1,143 @@ +name: Release Move IDE to VS Marketplace + +on: + ## Allow triggering this workflow manually via GitHub CLI/web + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + # Disable incremental compilation. + # + # Incremental compilation is useful as part of an edit-build-test-edit cycle, + # as it lets the compiler avoid recompiling code that hasn't changed. However, + # on CI, we're not making small edits; we're almost always building the entire + # project from scratch. Thus, incremental compilation on CI actually + # introduces *additional* overhead to support making future builds + # faster...but no future builds will ever occur in any given CI environment. + # + # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow + # for details. + CARGO_INCREMENTAL: 0 + # Allow more retries for network requests in cargo (downloading crates) and + # rustup (installing toolchains). This should help to reduce flaky CI failures + # from transient network timeouts or other issues. + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + # Don't emit giant backtraces in the CI logs. + RUST_BACKTRACE: short + TMP_BUILD_DIR: "./tmp/" + +jobs: + build-move-analyzer: + name: Build move-analyzer + strategy: + matrix: + os: [ + self-hosted, # ubuntu-x86_64 + macos-latest, # macos-arm64 + macos-latest-large, # macos-x86_64 + windows-latest, # windows-x86_64 + ] + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # pin@v4 + - name: Set os/arch variables (Windows) + if: ${{ matrix.os == 'windows-latest' }} + shell: bash + run: | + export arch=$(uname -m) + export os_type="windows-${arch}" + echo "os_type=${os_type}" >> $GITHUB_ENV + echo "extention=$(echo ".exe")" >> $GITHUB_ENV + + - name: Set os/arch variables (self hosted ubuntu) + if: ${{ matrix.os == 'self-hosted' }} + shell: bash + run: | + export arch=$(uname -m) + export os_type="linux-${arch}" + echo "os_type=${os_type}" >> $GITHUB_ENV + + - name: Set os/arch variables + if: ${{ matrix.os == 'macos-latest' }} + shell: bash + run: | + export arch=$(uname -m) + export system_os=$(echo ${{ matrix.os }} | cut -d- -f1) + export os_type="${system_os}-${arch}" + echo "os_type=${system_os}-${arch}" >> $GITHUB_ENV + + - name: Cargo build for ${{ matrix.os }} platform + shell: bash + run: | + [ -f ~/.cargo/env ] && source ~/.cargo/env ; cargo build --bin move-analyzer --release + + # Filenames need to match external-crates/move/crates/move-analyzer/editors/code/scripts/create_from_local.sh + - name: Rename binaries for ${{ matrix.os }} + shell: bash + run: | + if [ ${{ matrix.os }} == "macos-latest" ]; then + OS_TARGET="macos-arm64" + elif [ ${{ matrix.os }} == "macos-latest-large" ]; then + OS_TARGET="macos-x86_64" + elif [ ${{ matrix.os }} == "windows-latest" ]; then + OS_TARGET="windows-x86_64" + elif [ ${{ matrix.os }} == "self-hosted" ]; then + OS_TARGET="ubuntu-x86_64" + else + echo "Unknown OS" ${{ matrix.os }} + exit 1 + fi + + mkdir -p ${{ env.TMP_BUILD_DIR }} + mv ./target/release/move-analyzer${{ env.extention }} ${{ env.TMP_BUILD_DIR }}/move-analyzer-$OS_TARGET${{ env.extention }} + + - name: Print built file + run: ls -R ${{ env.TMP_BUILD_DIR }} + + - name: Upload move-analyzer binary + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.os }}-move-analyzer + path: ${{ env.TMP_BUILD_DIR }} + if-no-files-found: error + + build-and-publish-vs-code-extension: + name: Build and publish VS Code extension with move-analyzer binaries + needs: build-move-analyzer + runs-on: self-hosted + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 + with: + ref: ${{ github.event.inputs.iota_repo_ref || github.ref }} + + - name: Download move-analyzer binaries + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: "external-crates/move/crates/move-analyzer/editors/code/move-analyzer-binaries" + + - name: Print downloaded binaries + run: ls -R external-crates/move/crates/move-analyzer/editors/code/move-analyzer-binaries + + - name: Setup Node + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin@v4.0.2 + with: + node-version: "20" + + - name: Install dependencies + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + run: | + npm install + npm install --save-dev @types/node @types/semver + npm install -g vsce + sudo apt install zsh -y + + - name: Build and publish VS Code extension with move-analyzer binaries + working-directory: external-crates/move/crates/move-analyzer/editors/code/ + run: | + # Set the Personal Access Token to publish to the Visual Studio Marketplace + export VSCE_PAT=${{ secrets.VS_MARKETPLACE_TOKEN }} + ./scripts/create_from_local.sh -pub move-analyzer-binaries diff --git a/apps/wallet-dashboard/components/transactions/StakeTransactionCard.tsx b/apps/wallet-dashboard/components/transactions/StakeTransactionCard.tsx deleted file mode 100644 index adfc74a33ec..00000000000 --- a/apps/wallet-dashboard/components/transactions/StakeTransactionCard.tsx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { Box } from '..'; -import { TransactionAmount } from './'; -import { formatPercentageDisplay, useGetValidatorsApy } from '@iota/core'; -import type { IotaEvent } from '@iota/iota-sdk/client'; -import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; - -interface StakeTransactionCardProps { - event: IotaEvent; -} - -export default function StakeTransactionCard({ event }: StakeTransactionCardProps) { - const json = event.parsedJson as { amount: string; validator_address: string; epoch: string }; - const validatorAddress = json?.validator_address; - const stakedAmount = json?.amount; - - const { data: rollingAverageApys } = useGetValidatorsApy(); - - const { apy, isApyApproxZero } = rollingAverageApys?.[validatorAddress] ?? { - apy: null, - }; - - return ( - -
- {stakedAmount && ( - - )} -
-
-
- APY -
- {formatPercentageDisplay(apy, '--', isApyApproxZero)} -
-
-
-
- ); -} diff --git a/apps/wallet-dashboard/components/transactions/UnstakeTransactionCard.tsx b/apps/wallet-dashboard/components/transactions/UnstakeTransactionCard.tsx deleted file mode 100644 index 92419a8c3ec..00000000000 --- a/apps/wallet-dashboard/components/transactions/UnstakeTransactionCard.tsx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Mysten Labs, Inc. -// Modifications Copyright (c) 2024 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { useFormatCoin } from '@iota/core'; -import type { IotaEvent } from '@iota/iota-sdk/client'; -import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; -import { Box } from '..'; -import { TransactionAmount } from './'; - -interface UnstakeTransactionCardProps { - event: IotaEvent; -} - -export default function UnstakeTransactionCard({ event }: UnstakeTransactionCardProps) { - const eventJson = event.parsedJson as { - principal_amount?: number; - reward_amount?: number; - validator_address?: string; - }; - const principalAmount = eventJson?.principal_amount || 0; - const rewardAmount = eventJson?.reward_amount || 0; - const totalAmount = Number(principalAmount) + Number(rewardAmount); - const [formatPrinciple, symbol] = useFormatCoin(principalAmount, IOTA_TYPE_ARG); - const [formattedRewards] = useFormatCoin(rewardAmount || 0, IOTA_TYPE_ARG); - - return ( - -
- {totalAmount && ( - - )} - -
-
Your IOTA Stake
- -
- {formatPrinciple} {symbol} -
-
- -
-
- Staking Rewards Earned -
- -
- {formattedRewards} {symbol} -
-
-
-
- ); -} diff --git a/apps/wallet-dashboard/components/transactions/index.ts b/apps/wallet-dashboard/components/transactions/index.ts index 509933e7c10..1dc714be773 100644 --- a/apps/wallet-dashboard/components/transactions/index.ts +++ b/apps/wallet-dashboard/components/transactions/index.ts @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 export { default as TransactionAmount } from './TransactionAmount'; -export { default as StakeTransactionCard } from './StakeTransactionCard'; -export { default as UnstakeTransactionCard } from './UnstakeTransactionCard'; export { default as TransactionSummary } from './TransactionSummary'; export * from './TransactionTile'; export { default as TransactionIcon } from './TransactionIcon'; diff --git a/external-crates/move/crates/move-analyzer/editors/code/package.json b/external-crates/move/crates/move-analyzer/editors/code/package.json index 7d23d4246b1..c5199da4812 100644 --- a/external-crates/move/crates/move-analyzer/editors/code/package.json +++ b/external-crates/move/crates/move-analyzer/editors/code/package.json @@ -23,6 +23,7 @@ "keywords": [ "move", "Iota", + "iotaledger", "IOTA Foundation" ], "main": "./out/src/main.js", @@ -124,13 +125,13 @@ "menus": { "commandPalette": [ { - "command": "iota.serverVersion" + "command": "iota-move.serverVersion" }, { - "command": "iota.build" + "command": "iota-move.build" }, { - "command": "iota.test" + "command": "iota-move.test" } ] } diff --git a/external-crates/move/crates/move-analyzer/editors/code/scripts/create_from_local.sh b/external-crates/move/crates/move-analyzer/editors/code/scripts/create_from_local.sh new file mode 100755 index 00000000000..0f9cd3c89e2 --- /dev/null +++ b/external-crates/move/crates/move-analyzer/editors/code/scripts/create_from_local.sh @@ -0,0 +1,119 @@ +#!/bin/zsh +# Copyright (c) Mysten Labs, Inc. +# Modifications Copyright (c) 2024 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 + +set -e + +usage() { + SCRIPT_NAME=$(basename "$1") + >&2 echo "Usage: $SCRIPT_NAME -pkg|-pub [-h] BINDIR" + >&2 echo "" + >&2 echo "Options:" + >&2 echo " -pub Publish extensions for all targets" + >&2 echo " -pkg Package extensions for all targets" + >&2 echo " -h Print this message" + >&2 echo " BINDIR Directory containing pre-built IOTA move-analyzer binaries" +} + +clean_tmp_dir() { + test -d "$TMP_DIR" && rm -fr "$TMP_DIR" +} + +if [[ "$@" == "" ]]; then + usage $0 + exit 1 +fi + +BIN_DIR="" +for cmd in "$@" +do + if [[ "$cmd" == "-h" ]]; then + usage $0 + exit 0 + elif [[ "$cmd" == "-pkg" ]]; then + OP="package" + OPTS="-omove-VSCODE_OS.vsix" + elif [[ "$cmd" == "-pub" ]]; then + OP="publish" + OPTS="" + else + BIN_DIR=$cmd + + if [[ ! -d "$BIN_DIR" ]]; then + echo IOTA binary directory $BIN_DIR does not exist + usage $0 + exit 1 + fi + fi +done + +if [[ $BIN_DIR == "" ]]; then + # directory storing IOTA binaries have not been defined + usage $0 + exit 1 +fi + +# a map from os version identifiers in IOTA's binary distribution to os version identifiers +# representing VSCode's target platforms used for creating platform-specific plugin distributions +declare -A SUPPORTED_OS +SUPPORTED_OS[macos-arm64]=darwin-arm64 +SUPPORTED_OS[macos-x86_64]=darwin-x64 +SUPPORTED_OS[ubuntu-x86_64]=linux-x64 +SUPPORTED_OS[windows-x86_64]=win32-x64 + +TMP_DIR=$( mktemp -d -t vscode-createXXX ) +trap "clean_tmp_dir $TMP_DIR" EXIT + +BIN_FILES=($BIN_DIR/*) + +if (( ${#BIN_FILES[@]} != 4 )); then + echo "IOTA binary directory $BIN_DIR should only contain binaries for the four supported platforms" + exit 1 +fi + + +for IOTA_MOVE_ANALYZER_BIN in "${BIN_FILES[@]}"; do + echo "Processing" $IOTA_MOVE_ANALYZER_BIN + # Extract just the file name + FILE_NAME=${IOTA_MOVE_ANALYZER_BIN##*/} + # Get the OS target + OS_TARGET="${FILE_NAME#move-analyzer-}" + # Remove ".exe" for Windows + OS_TARGET="${OS_TARGET%.exe}" + + if [[ ! -v SUPPORTED_OS[$OS_TARGET] ]]; then + echo "Found IOTA binary archive for a platform that is not supported: $IOTA_MOVE_ANALYZER_BIN" + echo "Supported platforms:" + for PLATFORM in ${(k)SUPPORTED_OS}; do + echo "\t$PLATFORM" + done + exit 1 + fi + + # copy move-analyzer binary to the appropriate location where it's picked up when bundling the + # extension + LANG_SERVER_DIR="language-server" + # remove existing one to have only the binary for the target OS + rm -rf $LANG_SERVER_DIR + mkdir $LANG_SERVER_DIR + + # Copy renamed + if [[ "$IOTA_MOVE_ANALYZER_BIN" == *.exe ]]; then + cp $IOTA_MOVE_ANALYZER_BIN $LANG_SERVER_DIR/move-analyzer.exe + else + cp $IOTA_MOVE_ANALYZER_BIN $LANG_SERVER_DIR/move-analyzer + # Make binaries executable + chmod +x $LANG_SERVER_DIR/move-analyzer + fi + + VSCODE_OS=${SUPPORTED_OS[$OS_TARGET]} + vsce "$OP" ${OPTS//VSCODE_OS/$VSCODE_OS} --target "$VSCODE_OS" + + rm -rf $LANG_SERVER_DIR + +done + + +# build a "generic" version of the extension that does not bundle the move-analyzer binary +vsce "$OP" ${OPTS//VSCODE_OS/generic} diff --git a/external-crates/move/crates/move-analyzer/editors/code/src/context.ts b/external-crates/move/crates/move-analyzer/editors/code/src/context.ts index 686af1638a2..c377e52a620 100644 --- a/external-crates/move/crates/move-analyzer/editors/code/src/context.ts +++ b/external-crates/move/crates/move-analyzer/editors/code/src/context.ts @@ -359,7 +359,7 @@ export class Context { await vscode.window.showInformationMessage( `The move-analyzer binary at the user-specified path ('${this.configuration.serverPath}') ` + 'is not working. See troubleshooting instructions in the README file accompanying ' + - 'Move VSCode extension by IOTA Foundation in the VSCode marketplace', + 'Move VSCode extension by iotaledger in the VSCode marketplace', { modal: true }, items, ); @@ -410,7 +410,7 @@ export class Context { await vscode.window.showErrorMessage( 'Pre-built move-analyzer binary is not available for this platform. ' + 'Follow the instructions to manually install the language server in the README ' + - 'file accompanying Move VSCode extension by IOTA Foundation in the VSCode marketplace', + 'file accompanying Move VSCode extension by iotaledger in the VSCode marketplace', { modal: true }, items, ); diff --git a/sdk/typescript/src/version.ts b/sdk/typescript/src/version.ts index 5f991cdfb70..8e619f300a4 100644 --- a/sdk/typescript/src/version.ts +++ b/sdk/typescript/src/version.ts @@ -5,4 +5,4 @@ // This file is generated by genversion.mjs. Do not edit it directly. export const PACKAGE_VERSION = '0.3.1'; -export const TARGETED_RPC_VERSION = '0.7.0-alpha'; +export const TARGETED_RPC_VERSION = '0.8.0-alpha';