From c1305beec39291abae265ae50e46728e6c4233d1 Mon Sep 17 00:00:00 2001 From: yourmoonlight Date: Mon, 27 May 2024 15:56:44 +0800 Subject: [PATCH 1/5] build and deploy debug image to dev (#1747) --- .github/workflows/docker_build.yml | 29 +++++++++++++++-------------- scripts/check_dev_deploy_status.sh | 8 ++++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index ea2e8e0520..a04ae77c8f 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -9,7 +9,7 @@ on: jobs: build-rooch-docker: - name: build rooch docker + name: Build Rooch Docker runs-on: self-hosted steps: - name: Checkout @@ -20,7 +20,6 @@ jobs: id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 with: - # images: rooch/rooch,ghcr.io/rooch-network/rooch images: ghcr.io/rooch-network/rooch tag-sha: true # add git short SHA as Docker tag - name: Set up Docker Buildx @@ -39,8 +38,10 @@ jobs: context: . file: docker/Dockerfile push: true - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + tags: | + ghcr.io/rooch-network/rooch:${{ steps.docker_meta.outputs.version }} + ghcr.io/rooch-network/rooch:main + build-debug-rooch-docker: name: Build and Deploy Debug Rooch Docker runs-on: self-hosted @@ -49,11 +50,11 @@ jobs: uses: actions/checkout@v1 with: submodules: recursive - - name: Docker meta - id: docker_meta + - name: Docker meta debug + id: docker_meta_debug uses: crazy-max/ghaction-docker-meta@v1 with: - images: ghcr.io/rooch-network/rooch-debug + images: ghcr.io/rooch-network/rooch tag-sha: true # add git short SHA as Docker tag - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -65,15 +66,16 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GIT_PACKAGE_TOKEN }} - - name: Build and push + - name: Build and push debug uses: docker/build-push-action@v2 with: context: . file: docker/DockerfileDebug push: true - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} - - name: Deploy to GCP DEV VM + tags: | + ghcr.io/rooch-network/rooch:${{ steps.docker_meta_debug.outputs.version }}_debug + ghcr.io/rooch-network/rooch:main_debug + - name: Deploy debug to GCP DEV VM env: PRIVATE_KEY: ${{ secrets.GCP_SSH_PRIVATE_KEY }} HOST: ${{ secrets.GCP_VM_HOST }} @@ -83,6 +85,5 @@ jobs: chmod 600 private_key.pem sudo apt update sudo apt install -y --no-install-recommends openssh-server - ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep rooch | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep rooch | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch-debug:${{ steps.docker_meta.outputs.version }}' && docker run --rm -v /root:/root ghcr.io/rooch-network/rooch-debug:${{ steps.docker_meta.outputs.version }} server clean -n dev && docker run -d -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch-debug:${{ steps.docker_meta.outputs.version }}' server start -n dev --btc-rpc-url '${{secrets.BTC_REGTEST_RPC_URL}}' --btc-rpc-username rooch-regtest --btc-rpc-password '${{secrets.BTC_REGTEST_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"fs\"}}]}}'" - ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST "cd /root/rooch && git pull origin main && bash scripts/check_dev_deploy_status.sh ${{ steps.docker_meta.outputs.version }} '${{ secrets.DEV_MNEMONIC_PHRASE }}'" - + ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST bash -c "'sleep 30' && docker image prune -a -f && docker ps | grep main_debug | awk '{print \$1}' | xargs -r docker stop && docker ps -a | grep main_debug | awk '{print \$1}' | xargs -r docker rm -f && docker pull 'ghcr.io/rooch-network/rooch:main_debug' && docker run --rm -v /root:/root ghcr.io/rooch-network/rooch:main_debug server clean -n dev && docker run -d -v /root:/root -p 50051:50051 'ghcr.io/rooch-network/rooch:main_debug' server start -n dev --btc-rpc-url '${{secrets.BTC_REGTEST_RPC_URL}}' --btc-rpc-username rooch-regtest --btc-rpc-password '${{secrets.BTC_REGTEST_RPC_PWD}}' --da '{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"fs\"}}]}}'" + ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST "cd /root/rooch && git pull origin main && bash scripts/check_dev_deploy_status.sh main_debug '${{ secrets.DEV_MNEMONIC_PHRASE }}'" diff --git a/scripts/check_dev_deploy_status.sh b/scripts/check_dev_deploy_status.sh index 3437336024..f0bff56070 100644 --- a/scripts/check_dev_deploy_status.sh +++ b/scripts/check_dev_deploy_status.sh @@ -27,9 +27,9 @@ STATUS=$(docker inspect --format "{{.State.Status}}" $CONTAINER_ID) if [ "$STATUS" != "running" ]; then echo "!!! Container $CONTAINER_ID is not running, trying to clean data and restart" echo "Start cleaning the data with image_tag: $IMAGE_TAG" - docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch-debug:$IMAGE_TAG server clean -n dev + docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG server clean -n dev rm -rf ~/.rooch - docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch-debug:$IMAGE_TAG init -m "$(echo $DEV_MNEMONIC_PHRASE)" --skip-password + docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG init -m "$(echo $DEV_MNEMONIC_PHRASE)" --skip-password docker start $CONTAINER_ID if [ $? -eq 0 ]; then echo "Container $CONTAINER_ID Successfully restarted." @@ -38,8 +38,8 @@ if [ "$STATUS" != "running" ]; then dir=${dir%*/} name_addr=$(basename $dir) echo $name_addr - docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch-debug:$IMAGE_TAG move build -p "$dir" --named-addresses rooch_examples=default,$name_addr=default - docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch-debug:$IMAGE_TAG move publish -p "$dir" --named-addresses rooch_examples=default,$name_addr=default + docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG move build -p "$dir" --named-addresses rooch_examples=default,$name_addr=default + docker run --rm -v "/root:/root" ghcr.io/rooch-network/rooch:$IMAGE_TAG move publish -p "$dir" --named-addresses rooch_examples=default,$name_addr=default done else echo "Container $CONTAINER_ID Startup failed, please check the reason." From db29caa8cb202c909acc0dd8075b5536ba5aa402 Mon Sep 17 00:00:00 2001 From: jolestar Date: Mon, 27 May 2024 21:27:33 +0800 Subject: [PATCH 2/5] [types] Unify address format to bech32 (#1749) * [types] Unify address format to bech32 * [cli] Output both bech32 and hex address --- crates/rooch-faucet/src/web.rs | 8 +- crates/rooch-indexer/src/models/events.rs | 4 +- crates/rooch-indexer/src/models/states.rs | 7 +- .../rooch-indexer/src/tests/test_indexer.rs | 6 +- .../rooch-open-rpc-spec/schemas/openrpc.json | 33 ++-- crates/rooch-rpc-api/src/api/rooch_api.rs | 19 +- .../src/jsonrpc_types/address.rs | 30 ++- .../src/jsonrpc_types/btc/ord.rs | 15 +- .../src/jsonrpc_types/btc/utxo.rs | 11 +- .../src/jsonrpc_types/event_view.rs | 7 +- crates/rooch-rpc-api/src/jsonrpc_types/mod.rs | 1 + .../src/jsonrpc_types/move_types.rs | 6 +- .../src/jsonrpc_types/state_view.rs | 16 +- .../src/jsonrpc_types/str_view.rs | 8 + .../src/jsonrpc_types/tests/str_view_tests.rs | 13 ++ .../src/jsonrpc_types/transaction_view.rs | 4 +- crates/rooch-rpc-client/src/rooch_client.rs | 8 +- crates/rooch-rpc-client/src/wallet_context.rs | 10 +- crates/rooch-rpc-server/src/lib.rs | 3 +- .../rooch-rpc-server/src/server/btc_server.rs | 4 +- .../src/server/rooch_server.rs | 15 +- .../src/service/aggregate_service.rs | 12 +- .../src/service/rpc_service.rs | 18 +- crates/rooch-types/src/address.rs | 186 ++++++++++++++++-- crates/rooch-types/src/bitcoin/ord.rs | 4 +- crates/rooch-types/src/bitcoin/utxo.rs | 4 +- crates/rooch-types/src/crypto.rs | 2 +- crates/rooch-types/src/function_arg.rs | 3 +- .../rooch-types/src/indexer/event_filter.rs | 8 +- crates/rooch-types/src/indexer/state.rs | 12 +- .../src/indexer/transaction_filter.rs | 4 +- crates/rooch/src/cli_types.rs | 2 +- .../src/commands/account/commands/balance.rs | 2 +- .../src/commands/account/commands/list.rs | 110 +++++++---- .../src/commands/account/commands/transfer.rs | 2 +- crates/rooch/src/commands/resource.rs | 4 +- .../rooch-sdk/test/e2e/cli/rooch-cli.ts | 2 +- 37 files changed, 423 insertions(+), 180 deletions(-) diff --git a/crates/rooch-faucet/src/web.rs b/crates/rooch-faucet/src/web.rs index 3bef89e0a4..f724256d58 100644 --- a/crates/rooch-faucet/src/web.rs +++ b/crates/rooch-faucet/src/web.rs @@ -26,9 +26,9 @@ use axum::{ }; use clap::Parser; use http::Method; -use move_core_types::account_address::AccountAddress; + use prometheus::{Registry, TextEncoder}; -use rooch_rpc_api::jsonrpc_types::{AccountAddressView, StructTagView}; +use rooch_rpc_api::jsonrpc_types::StructTagView; use rooch_rpc_client::wallet_context::WalletContext; use tokio::sync::RwLock; @@ -99,12 +99,12 @@ impl App { let context = WalletContext::new(self.wallet_config_dir.clone()) .map_err(|e| FaucetError::Wallet(e.to_string()))?; let client = context.get_client().await.unwrap(); - let faucet_address: AccountAddress = context.client_config.active_address.unwrap().into(); + let faucet_address = context.client_config.active_address.unwrap(); let s = client .rooch .get_balance( - AccountAddressView::from(faucet_address), + faucet_address.into(), StructTagView::from_str("0x3::gas_coin::GasCoin").unwrap(), ) .await diff --git a/crates/rooch-indexer/src/models/events.rs b/crates/rooch-indexer/src/models/events.rs index 33ebade917..031b5d6940 100644 --- a/crates/rooch-indexer/src/models/events.rs +++ b/crates/rooch-indexer/src/models/events.rs @@ -4,11 +4,11 @@ use crate::types::IndexedEvent; use crate::{schema::events, utils}; use diesel::prelude::*; -use move_core_types::account_address::AccountAddress; use move_core_types::language_storage::StructTag; use moveos_types::h256::H256; use moveos_types::moveos_std::event::EventID; use moveos_types::moveos_std::object::ObjectID; +use rooch_types::address::RoochAddress; use rooch_types::indexer::event_filter::{IndexerEvent, IndexerEventID}; use std::str::FromStr; @@ -65,7 +65,7 @@ impl From for StoredEvent { impl StoredEvent { pub fn try_into_indexer_event(&self) -> Result { let event_handle_id = ObjectID::from_str(self.event_handle_id.as_str())?; - let sender = AccountAddress::from_hex_literal(self.sender.as_str())?; + let sender = RoochAddress::from_str(self.sender.as_str())?; let tx_hash = H256::from_str(self.tx_hash.as_str())?; let event_type = StructTag::from_str(self.event_type.as_str())?; diff --git a/crates/rooch-indexer/src/models/states.rs b/crates/rooch-indexer/src/models/states.rs index 7bc8cdf5ec..26abcd476e 100644 --- a/crates/rooch-indexer/src/models/states.rs +++ b/crates/rooch-indexer/src/models/states.rs @@ -6,9 +6,10 @@ use crate::schema::object_states; use crate::types::{IndexedFieldState, IndexedObjectState}; use crate::utils; use diesel::prelude::*; -use move_core_types::account_address::AccountAddress; +use ethers::types::H256; use move_core_types::language_storage::{StructTag, TypeTag}; use moveos_types::moveos_std::object::ObjectID; +use rooch_types::address::RoochAddress; use rooch_types::indexer::state::{IndexerFieldState, IndexerObjectState}; use std::str::FromStr; @@ -67,10 +68,10 @@ impl From for StoredObjectState { impl StoredObjectState { pub fn try_into_indexer_global_state(&self) -> Result { let object_id = ObjectID::from_str(self.object_id.as_str())?; - let owner = AccountAddress::from_hex_literal(self.owner.as_str())?; + let owner = RoochAddress::from_str(self.owner.as_str())?; let object_type = StructTag::from_str(self.object_type.as_str())?; - let state_root = AccountAddress::from_hex_literal(self.state_root.as_str())?; + let state_root = H256::from_str(self.state_root.as_str())?; let state = IndexerObjectState { object_id, diff --git a/crates/rooch-indexer/src/tests/test_indexer.rs b/crates/rooch-indexer/src/tests/test_indexer.rs index 0afc7b3b1c..5a25b0c414 100644 --- a/crates/rooch-indexer/src/tests/test_indexer.rs +++ b/crates/rooch-indexer/src/tests/test_indexer.rs @@ -161,7 +161,7 @@ fn test_transaction_store() -> Result<()> { let transactions = vec![indexed_transaction]; let _ = indexer_store.persist_transactions(transactions)?; - let filter = TransactionFilter::Sender(random_moveos_tx.ctx.sender); + let filter = TransactionFilter::Sender(random_moveos_tx.ctx.sender.into()); let query_transactions = indexer_reader.query_transactions_with_filter(filter, None, 1, true)?; assert_eq!(query_transactions.len(), 1); @@ -194,7 +194,7 @@ fn test_event_store() -> Result<()> { let events = vec![indexed_event]; let _ = indexer_store.persist_events(events)?; - let filter = EventFilter::Sender(random_moveos_tx.ctx.sender); + let filter = EventFilter::Sender(random_moveos_tx.ctx.sender.into()); let query_events = indexer_reader.query_events_with_filter(filter, None, 1, true)?; assert_eq!(query_events.len(), 1); Ok(()) @@ -269,7 +269,7 @@ fn test_object_type_query() -> Result<()> { // filter by object type and owner let filter = ObjectStateFilter::ObjectTypeWithOwner { object_type: CoinStore::::struct_tag(), - owner, + owner: owner.into(), }; let query_object_states = indexer_reader.query_object_states_with_filter(filter, None, 1, true)?; diff --git a/crates/rooch-open-rpc-spec/schemas/openrpc.json b/crates/rooch-open-rpc-spec/schemas/openrpc.json index dff547b7df..ba6ee8a1e4 100644 --- a/crates/rooch-open-rpc-spec/schemas/openrpc.json +++ b/crates/rooch-open-rpc-spec/schemas/openrpc.json @@ -139,13 +139,13 @@ }, { "name": "rooch_getBalance", - "description": "get account balance by AccountAddress and CoinType", + "description": "get account balance by RoochAddress and CoinType", "params": [ { "name": "account_addr", "required": true, "schema": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" } }, { @@ -166,13 +166,13 @@ }, { "name": "rooch_getBalances", - "description": "get account balances by AccountAddress", + "description": "get account balances by RoochAddress", "params": [ { "name": "account_addr", "required": true, "schema": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" } }, { @@ -745,7 +745,7 @@ ], "properties": { "sender": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" } }, "additionalProperties": false @@ -1102,7 +1102,7 @@ "$ref": "#/components/schemas/IndexerEventID" }, "sender": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" }, "tx_hash": { "$ref": "#/components/schemas/primitive_types::H256" @@ -1208,7 +1208,7 @@ "$ref": "#/components/schemas/move_core_types::language_storage::StructTag" }, "owner": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" }, "size": { "type": "integer", @@ -1221,7 +1221,7 @@ "minimum": 0.0 }, "state_root": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/primitive_types::H256" }, "tx_order": { "type": "integer", @@ -1359,7 +1359,7 @@ "$ref": "#/components/schemas/move_core_types::language_storage::StructTag" }, "owner": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" }, "owner_bitcoin_address": { "type": [ @@ -1466,7 +1466,7 @@ "minimum": 0.0 }, "txid": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/primitive_types::H256" } } }, @@ -1799,7 +1799,7 @@ "$ref": "#/components/schemas/move_core_types::language_storage::StructTag" }, "owner": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" } } } @@ -1827,7 +1827,7 @@ ], "properties": { "owner": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" } }, "additionalProperties": false @@ -2410,7 +2410,7 @@ ], "properties": { "sender": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" } }, "additionalProperties": false @@ -2682,7 +2682,7 @@ "$ref": "#/components/schemas/move_core_types::language_storage::StructTag" }, "owner": { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/rooch_types::address::RoochAddress" }, "owner_bitcoin_address": { "type": [ @@ -2743,7 +2743,7 @@ "description": "The txid of the UTXO", "allOf": [ { - "$ref": "#/components/schemas/move_core_types::account_address::AccountAddress" + "$ref": "#/components/schemas/primitive_types::H256" } ] }, @@ -2879,6 +2879,9 @@ "rooch_types::address::BitcoinAddress": { "type": "string" }, + "rooch_types::address::RoochAddress": { + "type": "string" + }, "u128": { "type": "string" }, diff --git a/crates/rooch-rpc-api/src/api/rooch_api.rs b/crates/rooch-rpc-api/src/api/rooch_api.rs index 70344f031e..0bf92dad3e 100644 --- a/crates/rooch-rpc-api/src/api/rooch_api.rs +++ b/crates/rooch-rpc-api/src/api/rooch_api.rs @@ -2,15 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 use crate::jsonrpc_types::account_view::BalanceInfoView; +use crate::jsonrpc_types::address::RoochAddressView; use crate::jsonrpc_types::event_view::EventFilterView; use crate::jsonrpc_types::transaction_view::{TransactionFilterView, TransactionWithInfoView}; use crate::jsonrpc_types::TxOptions; use crate::jsonrpc_types::{ - AccessPathView, AccountAddressView, AnnotatedFunctionResultView, BalanceInfoPageView, - BytesView, EventOptions, EventPageView, ExecuteTransactionResponseView, FieldStateFilterView, - FunctionCallView, H256View, IndexerEventPageView, IndexerFieldStatePageView, - IndexerObjectStatePageView, ObjectStateFilterView, QueryOptions, StateOptions, StatePageView, - StateView, StrView, StructTagView, TransactionWithInfoPageView, + AccessPathView, AnnotatedFunctionResultView, BalanceInfoPageView, BytesView, EventOptions, + EventPageView, ExecuteTransactionResponseView, FieldStateFilterView, FunctionCallView, + H256View, IndexerEventPageView, IndexerFieldStatePageView, IndexerObjectStatePageView, + ObjectStateFilterView, QueryOptions, StateOptions, StatePageView, StateView, StrView, + StructTagView, TransactionWithInfoPageView, }; use jsonrpsee::core::RpcResult; use jsonrpsee::proc_macros::rpc; @@ -92,19 +93,19 @@ pub trait RoochAPI { descending_order: Option, ) -> RpcResult; - /// get account balance by AccountAddress and CoinType + /// get account balance by RoochAddress and CoinType #[method(name = "getBalance")] async fn get_balance( &self, - account_addr: AccountAddressView, + account_addr: RoochAddressView, coin_type: StructTagView, ) -> RpcResult; - /// get account balances by AccountAddress + /// get account balances by RoochAddress #[method(name = "getBalances")] async fn get_balances( &self, - account_addr: AccountAddressView, + account_addr: RoochAddressView, cursor: Option, limit: Option>, ) -> RpcResult; diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/address.rs b/crates/rooch-rpc-api/src/jsonrpc_types/address.rs index a41c75c19e..05b3472d78 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/address.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/address.rs @@ -3,7 +3,8 @@ use crate::jsonrpc_types::StrView; use anyhow::Result; -use rooch_types::address::BitcoinAddress; +use move_core_types::account_address::AccountAddress; +use rooch_types::address::{BitcoinAddress, RoochAddress}; use std::str::FromStr; pub type BitcoinAddressView = StrView; @@ -27,3 +28,30 @@ impl From for BitcoinAddress { value.0 } } + +pub type RoochAddressView = StrView; + +impl std::fmt::Display for RoochAddressView { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl FromStr for RoochAddressView { + type Err = anyhow::Error; + fn from_str(s: &str) -> Result { + Ok(StrView(RoochAddress::from_str(s)?)) + } +} + +impl From for RoochAddress { + fn from(value: RoochAddressView) -> Self { + value.0 + } +} + +impl From for RoochAddressView { + fn from(value: AccountAddress) -> Self { + StrView(RoochAddress::from(value)) + } +} diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/btc/ord.rs b/crates/rooch-rpc-api/src/jsonrpc_types/btc/ord.rs index b44a57d0ed..e5d58e0f03 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/btc/ord.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/btc/ord.rs @@ -3,13 +3,16 @@ use crate::jsonrpc_types::address::BitcoinAddressView; use crate::jsonrpc_types::btc::transaction::{hex_to_txid, TxidView}; -use crate::jsonrpc_types::{AccountAddressView, BytesView, MoveStringView, StrView, StructTagView}; +use crate::jsonrpc_types::{ + BytesView, H256View, MoveStringView, RoochAddressView, StrView, StructTagView, +}; use anyhow::Result; use bitcoin::hashes::Hash; use bitcoin::Txid; -use move_core_types::account_address::AccountAddress; + use moveos_types::move_std::string::MoveString; use moveos_types::{moveos_std::object::ObjectID, state::MoveStructType}; +use rooch_types::address::RoochAddress; use rooch_types::bitcoin::ord; use rooch_types::bitcoin::ord::{ BitcoinInscriptionID, Inscription, InscriptionID, InscriptionState, @@ -50,7 +53,7 @@ pub enum InscriptionFilterView { impl InscriptionFilterView { pub fn into_global_state_filter( filter: InscriptionFilterView, - resolve_address: AccountAddress, + resolve_address: RoochAddress, ) -> Result { Ok(match filter { InscriptionFilterView::Owner(_owner) => ObjectStateFilter::ObjectTypeWithOwner { @@ -73,13 +76,13 @@ impl InscriptionFilterView { #[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] pub struct InscriptionIDView { - pub txid: AccountAddressView, + pub txid: H256View, pub index: u32, } #[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] pub struct InscriptionView { - pub txid: AccountAddressView, + pub txid: H256View, pub bitcoin_txid: TxidView, pub index: u32, pub offset: u64, @@ -113,7 +116,7 @@ impl From for InscriptionView { #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] pub struct InscriptionStateView { pub object_id: ObjectID, - pub owner: AccountAddressView, + pub owner: RoochAddressView, pub owner_bitcoin_address: Option, pub flag: u8, pub value: InscriptionView, diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/btc/utxo.rs b/crates/rooch-rpc-api/src/jsonrpc_types/btc/utxo.rs index b744d6803d..3efda7207e 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/btc/utxo.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/btc/utxo.rs @@ -3,13 +3,14 @@ use crate::jsonrpc_types::address::BitcoinAddressView; use crate::jsonrpc_types::btc::transaction::{hex_to_txid, TxidView}; -use crate::jsonrpc_types::{AccountAddressView, StructTagView}; +use crate::jsonrpc_types::{H256View, RoochAddressView, StructTagView}; use anyhow::Result; use bitcoin::hashes::Hash; use bitcoin::Txid; -use move_core_types::account_address::AccountAddress; + use moveos_types::moveos_std::object::ObjectID; use moveos_types::state::MoveStructType; +use rooch_types::address::RoochAddress; use rooch_types::bitcoin::utxo::{self, UTXOState, UTXO}; use rooch_types::indexer::state::ObjectStateFilter; use rooch_types::into_address::IntoAddress; @@ -44,7 +45,7 @@ pub enum UTXOFilterView { impl UTXOFilterView { pub fn into_global_state_filter( filter_opt: UTXOFilterView, - resolve_address: AccountAddress, + resolve_address: RoochAddress, ) -> Result { Ok(match filter_opt { UTXOFilterView::Owner(_owner) => ObjectStateFilter::ObjectTypeWithOwner { @@ -67,7 +68,7 @@ impl UTXOFilterView { #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] pub struct UTXOView { /// The txid of the UTXO - txid: AccountAddressView, + txid: H256View, /// The txid of the UTXO bitcoin_txid: TxidView, /// The vout of the UTXO @@ -97,7 +98,7 @@ impl UTXOView { #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] pub struct UTXOStateView { pub object_id: ObjectID, - pub owner: AccountAddressView, + pub owner: RoochAddressView, pub owner_bitcoin_address: Option, pub flag: u8, pub value: Option, diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/event_view.rs b/crates/rooch-rpc-api/src/jsonrpc_types/event_view.rs index a4b89804c3..949f087c0c 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/event_view.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/event_view.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::jsonrpc_types::{ - AccountAddressView, AnnotatedMoveStructView, H256View, StrView, StructTagView, + AnnotatedMoveStructView, H256View, RoochAddressView, StrView, StructTagView, }; use moveos_types::moveos_std::event::{AnnotatedEvent, Event, EventID, TransactionEvent}; use rooch_types::indexer::event_filter::{EventFilter, IndexerEvent, IndexerEventID}; @@ -79,9 +79,8 @@ pub struct IndexerEventView { pub event_type: StructTagView, pub event_data: StrView>, pub tx_hash: H256View, - pub sender: AccountAddressView, + pub sender: RoochAddressView, pub created_at: u64, - pub decoded_event_data: Option, } @@ -107,7 +106,7 @@ pub enum EventFilterView { /// Query by event type. EventType(StructTagView), /// Query by sender address. - Sender(AccountAddressView), + Sender(RoochAddressView), /// Return events emitted by the given transaction hash. TxHash(H256View), /// Return events emitted in [start_time, end_time) interval diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/mod.rs b/crates/rooch-rpc-api/src/jsonrpc_types/mod.rs index 86385e977e..0546d9ccc5 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/mod.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/mod.rs @@ -22,6 +22,7 @@ pub mod address; pub mod btc; pub use self::rooch_types::*; +pub use address::*; pub use execute_tx_response::*; pub use function_return_value_view::*; pub use move_types::*; diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/move_types.rs b/crates/rooch-rpc-api/src/jsonrpc_types/move_types.rs index 2f224686fd..bb6d7982f9 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/move_types.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/move_types.rs @@ -27,6 +27,8 @@ use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::str::FromStr; +use super::{H256View, RoochAddressView}; + pub type ModuleIdView = StrView; pub type TypeTagView = StrView; pub type StructTagView = StrView; @@ -194,9 +196,9 @@ impl From for AnnotatedMoveValueView { #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AnnotatedObjectView { pub id: ObjectID, - pub owner: AccountAddressView, + pub owner: RoochAddressView, pub flag: u8, - pub state_root: AccountAddressView, + pub state_root: H256View, pub size: u64, pub value: AnnotatedMoveStructView, } diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/state_view.rs b/crates/rooch-rpc-api/src/jsonrpc_types/state_view.rs index 8ab9afa5d4..1c99fb9cfb 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/state_view.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/state_view.rs @@ -2,10 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 use super::{ - AccountAddressView, AnnotatedMoveValueView, BytesView, StrView, StructTagView, TypeTagView, + AnnotatedMoveValueView, BytesView, H256View, RoochAddressView, StrView, StructTagView, + TypeTagView, }; use anyhow::Result; -use move_core_types::account_address::AccountAddress; + use move_core_types::effects::Op; use moveos_types::state::{ AnnotatedKeyState, FieldChange, KeyState, NormalFieldChange, ObjectChange, @@ -15,6 +16,7 @@ use moveos_types::{ moveos_std::object::ObjectID, state::{AnnotatedState, State, StateChangeSet, TableTypeInfo}, }; +use rooch_types::address::RoochAddress; use rooch_types::indexer::state::{ FieldStateFilter, IndexerFieldState, IndexerObjectState, IndexerStateChangeSet, ObjectStateFilter, StateSyncFilter, @@ -371,11 +373,11 @@ impl From for StateSyncFilter { #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)] pub struct IndexerObjectStateView { pub object_id: ObjectID, - pub owner: AccountAddressView, + pub owner: RoochAddressView, pub flag: u8, pub value: Option, pub object_type: StructTagView, - pub state_root: AccountAddressView, + pub state_root: H256View, pub size: u64, pub tx_order: u64, pub state_index: u64, @@ -417,12 +419,12 @@ pub enum ObjectStateFilterView { /// Query by object value type and owner. ObjectTypeWithOwner { object_type: StructTagView, - owner: AccountAddressView, + owner: RoochAddressView, }, /// Query by object value type. ObjectType(StructTagView), /// Query by owner. - Owner(AccountAddressView), + Owner(RoochAddressView), /// Query by object id. ObjectId(Vec), /// Query by multi chain address @@ -432,7 +434,7 @@ pub enum ObjectStateFilterView { impl ObjectStateFilterView { pub fn into_object_state_filter( state_filter: ObjectStateFilterView, - resolve_address: AccountAddress, + resolve_address: RoochAddress, ) -> ObjectStateFilter { match state_filter { ObjectStateFilterView::ObjectTypeWithOwner { object_type, owner } => { diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/str_view.rs b/crates/rooch-rpc-api/src/jsonrpc_types/str_view.rs index 6c6f796d6c..a657bfc90c 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/str_view.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/str_view.rs @@ -4,6 +4,7 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 +use move_core_types::account_address::AccountAddress; use moveos_types::move_std::string::MoveString; use schemars::gen::SchemaGenerator; use schemars::schema::{InstanceType, Schema, SchemaObject}; @@ -223,6 +224,13 @@ impl From for ethers::types::H256 { } } +/// In Move Struct, we use AccountAddress to represent H256 +impl From for H256View { + fn from(value: AccountAddress) -> Self { + StrView(ethers::types::H256::from(value.into_bytes())) + } +} + impl std::fmt::Display for H256View { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { //The H256 should display fully hex string with `0x` prefix diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/tests/str_view_tests.rs b/crates/rooch-rpc-api/src/jsonrpc_types/tests/str_view_tests.rs index e8ff41cb9e..bc5ee97997 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/tests/str_view_tests.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/tests/str_view_tests.rs @@ -116,3 +116,16 @@ fn test_account_address_view() { let address_result = AccountAddressView::from_str("11"); assert!(address_result.is_err()); } + +#[test] +fn test_rooch_address_view() { + str_view_test_round_trip( + RoochAddressView::from( + RoochAddressView::from_str( + "rooch16kg65sgpy497wc4j09ds6tha6e48cg45303fnxxxua6khevfa8sqwnxk0l", + ) + .unwrap(), + ), + "rooch16kg65sgpy497wc4j09ds6tha6e48cg45303fnxxxua6khevfa8sqwnxk0l", + ); +} diff --git a/crates/rooch-rpc-api/src/jsonrpc_types/transaction_view.rs b/crates/rooch-rpc-api/src/jsonrpc_types/transaction_view.rs index 52c4e16a05..2b93bcc462 100644 --- a/crates/rooch-rpc-api/src/jsonrpc_types/transaction_view.rs +++ b/crates/rooch-rpc-api/src/jsonrpc_types/transaction_view.rs @@ -3,7 +3,7 @@ use super::BytesView; use crate::jsonrpc_types::{ - AccountAddressView, H256View, TransactionExecutionInfoView, TransactionSequenceInfoView, + H256View, RoochAddressView, TransactionExecutionInfoView, TransactionSequenceInfoView, TransactionView, }; use rooch_types::indexer::transaction_filter::TransactionFilter; @@ -78,7 +78,7 @@ impl From for TransactionWithInfoView { #[serde(rename_all = "snake_case")] pub enum TransactionFilterView { /// Query by sender address. - Sender(AccountAddressView), + Sender(RoochAddressView), /// Query by multi chain original address. OriginalAddress(String), /// Query by the given transaction hash. diff --git a/crates/rooch-rpc-client/src/rooch_client.rs b/crates/rooch-rpc-client/src/rooch_client.rs index b83f3481f7..dfbdee8785 100644 --- a/crates/rooch-rpc-client/src/rooch_client.rs +++ b/crates/rooch-rpc-client/src/rooch_client.rs @@ -11,8 +11,8 @@ use rooch_rpc_api::jsonrpc_types::{ account_view::BalanceInfoView, transaction_view::TransactionWithInfoView, }; use rooch_rpc_api::jsonrpc_types::{ - AccessPathView, AccountAddressView, AnnotatedFunctionResultView, BalanceInfoPageView, - EventOptions, EventPageView, StateOptions, StatePageView, StructTagView, + AccessPathView, AnnotatedFunctionResultView, BalanceInfoPageView, EventOptions, EventPageView, + RoochAddressView, StateOptions, StatePageView, StructTagView, }; use rooch_rpc_api::jsonrpc_types::{ExecuteTransactionResponseView, StateView}; use rooch_rpc_api::jsonrpc_types::{TransactionWithInfoPageView, TxOptions}; @@ -183,7 +183,7 @@ impl RoochRpcClient { pub async fn get_balance( &self, - account_addr: AccountAddressView, + account_addr: RoochAddressView, coin_type: StructTagView, ) -> Result { Ok(self.http.get_balance(account_addr, coin_type).await?) @@ -191,7 +191,7 @@ impl RoochRpcClient { pub async fn get_balances( &self, - account_addr: AccountAddressView, + account_addr: RoochAddressView, cursor: Option, limit: Option, ) -> Result { diff --git a/crates/rooch-rpc-client/src/wallet_context.rs b/crates/rooch-rpc-client/src/wallet_context.rs index e89f995100..271bd6b791 100644 --- a/crates/rooch-rpc-client/src/wallet_context.rs +++ b/crates/rooch-rpc-client/src/wallet_context.rs @@ -4,7 +4,6 @@ use crate::client_config::{ClientConfig, DEFAULT_EXPIRATION_SECS}; use crate::Client; use anyhow::{anyhow, Result}; -use move_command_line_common::address::ParsedAddress; use move_core_types::account_address::AccountAddress; use moveos_types::moveos_std::gas_schedule::GasScheduleConfig; use moveos_types::transaction::MoveAction; @@ -15,6 +14,7 @@ use rooch_key::keystore::account_keystore::AccountKeystore; use rooch_key::keystore::file_keystore::FileBasedKeystore; use rooch_key::keystore::Keystore; use rooch_rpc_api::jsonrpc_types::{ExecuteTransactionResponseView, KeptVMStatusView, TxOptions}; +use rooch_types::address::ParsedAddress; use rooch_types::address::RoochAddress; use rooch_types::addresses; use rooch_types::crypto::Signature; @@ -71,7 +71,7 @@ impl WalletContext { //TODO support account name alias name. if let Some(active_address) = client_config.active_address { - address_mapping.insert("default".to_string(), AccountAddress::from(active_address)); + address_mapping.insert("default".to_string(), active_address.into()); } Ok(Self { @@ -83,8 +83,8 @@ impl WalletContext { }) } - pub fn add_address_mapping(&mut self, name: String, address: AccountAddress) { - self.address_mapping.insert(name, address); + pub fn add_address_mapping(&mut self, name: String, address: RoochAddress) { + self.address_mapping.insert(name, address.into()); } pub fn address_mapping(&self) -> AddressMappingFn { @@ -94,7 +94,7 @@ impl WalletContext { pub fn resolve_address(&self, parsed_address: ParsedAddress) -> RoochResult { match parsed_address { - ParsedAddress::Numerical(address) => Ok(address.into_inner()), + ParsedAddress::Numerical(address) => Ok(address.into()), ParsedAddress::Named(name) => { self.address_mapping.get(&name).cloned().ok_or_else(|| { RoochError::CommandArgumentError(format!("Unknown named address: {}", name)) diff --git a/crates/rooch-rpc-server/src/lib.rs b/crates/rooch-rpc-server/src/lib.rs index c00581b5b1..f8b2402c28 100644 --- a/crates/rooch-rpc-server/src/lib.rs +++ b/crates/rooch-rpc-server/src/lib.rs @@ -200,12 +200,13 @@ pub async fn run_start_server(opt: &RoochOpt, server_opt: ServerOpt) -> Result { diff --git a/crates/rooch-rpc-server/src/server/btc_server.rs b/crates/rooch-rpc-server/src/server/btc_server.rs index 5f5a27918e..9df537397c 100644 --- a/crates/rooch-rpc-server/src/server/btc_server.rs +++ b/crates/rooch-rpc-server/src/server/btc_server.rs @@ -61,7 +61,7 @@ impl BtcAPIServer for BtcServer { .resolve_address(multi_chain_address) .await? } - _ => AccountAddress::ZERO, + _ => AccountAddress::ZERO.into(), }; let global_state_filter = @@ -116,7 +116,7 @@ impl BtcAPIServer for BtcServer { .resolve_address(multi_chain_address) .await? } - _ => AccountAddress::ZERO, + _ => AccountAddress::ZERO.into(), }; let global_state_filter = diff --git a/crates/rooch-rpc-server/src/server/rooch_server.rs b/crates/rooch-rpc-server/src/server/rooch_server.rs index 52d34934f4..3facfc46a8 100644 --- a/crates/rooch-rpc-server/src/server/rooch_server.rs +++ b/crates/rooch-rpc-server/src/server/rooch_server.rs @@ -18,7 +18,6 @@ use moveos_types::{ }, state::{AnnotatedKeyState, AnnotatedState, KeyState}, }; -use rooch_rpc_api::jsonrpc_types::event_view::{EventFilterView, EventView, IndexerEventView}; use rooch_rpc_api::jsonrpc_types::transaction_view::TransactionFilterView; use rooch_rpc_api::jsonrpc_types::{ account_view::BalanceInfoView, FieldStateFilterView, IndexerEventPageView, @@ -26,9 +25,13 @@ use rooch_rpc_api::jsonrpc_types::{ IndexerObjectStateView, KeyStateView, ObjectStateFilterView, QueryOptions, StateKVView, StateOptions, TxOptions, }; +use rooch_rpc_api::jsonrpc_types::{ + event_view::{EventFilterView, EventView, IndexerEventView}, + RoochAddressView, +}; use rooch_rpc_api::jsonrpc_types::{transaction_view::TransactionWithInfoView, EventOptions}; use rooch_rpc_api::jsonrpc_types::{ - AccessPathView, AccountAddressView, BalanceInfoPageView, DisplayFieldsView, EventPageView, + AccessPathView, BalanceInfoPageView, DisplayFieldsView, EventPageView, ExecuteTransactionResponseView, FunctionCallView, H256View, StatePageView, StateView, StrView, StructTagView, TransactionWithInfoPageView, }; @@ -442,7 +445,7 @@ impl RoochAPIServer for RoochServer { async fn get_balance( &self, - account_addr: AccountAddressView, + account_addr: RoochAddressView, coin_type: StructTagView, ) -> RpcResult { Ok(self @@ -452,10 +455,10 @@ impl RoochAPIServer for RoochServer { .map(Into::into)?) } - /// get account balances by AccountAddress + /// get account balances by RoochAddress async fn get_balances( &self, - account_addr: AccountAddressView, + account_addr: RoochAddressView, cursor: Option, limit: Option>, ) -> RpcResult { @@ -590,7 +593,7 @@ impl RoochAPIServer for RoochServer { .resolve_address(multi_chain_address) .await? } - _ => AccountAddress::ZERO, + _ => AccountAddress::ZERO.into(), }; let global_state_filter = ObjectStateFilterView::into_object_state_filter(filter, resolve_address); diff --git a/crates/rooch-rpc-server/src/service/aggregate_service.rs b/crates/rooch-rpc-server/src/service/aggregate_service.rs index 6e6db97ff1..fe76145597 100644 --- a/crates/rooch-rpc-server/src/service/aggregate_service.rs +++ b/crates/rooch-rpc-server/src/service/aggregate_service.rs @@ -3,7 +3,6 @@ use crate::service::rpc_service::RpcService; use anyhow::Result; -use move_core_types::account_address::AccountAddress; use move_core_types::language_storage::{StructTag, TypeTag}; use moveos_types::access_path::AccessPath; use moveos_types::h256::H256; @@ -13,7 +12,7 @@ use moveos_types::moveos_std::object::RawObject; use moveos_types::state::{KeyState, PlaceholderStruct}; use rooch_rpc_api::jsonrpc_types::account_view::BalanceInfoView; use rooch_rpc_api::jsonrpc_types::CoinInfoView; -use rooch_types::address::{BitcoinAddress, MultiChainAddress}; +use rooch_types::address::{BitcoinAddress, MultiChainAddress, RoochAddress}; use rooch_types::bitcoin::ord::{Inscription, InscriptionState}; use rooch_types::bitcoin::utxo::{UTXOState, UTXO}; use rooch_types::framework::account_coin_store::AccountCoinStoreModule; @@ -86,7 +85,7 @@ impl AggregateService { pub async fn get_balance( &self, - account_addr: AccountAddress, + account_addr: RoochAddress, coin_type: StructTag, ) -> Result { let coin_info = self @@ -99,7 +98,8 @@ impl AggregateService { anyhow::anyhow!("Can not find CoinInfo with coin_type: {}", coin_type) })?; - let coin_store_id = AccountCoinStoreModule::account_coin_store_id(account_addr, coin_type); + let coin_store_id = + AccountCoinStoreModule::account_coin_store_id(account_addr.into(), coin_type); let balance = self .get_coin_stores(vec![coin_store_id]) .await? @@ -113,7 +113,7 @@ impl AggregateService { pub async fn query_account_coin_stores( &self, - owner: AccountAddress, + owner: RoochAddress, cursor: Option, limit: usize, ) -> Result> { @@ -133,7 +133,7 @@ impl AggregateService { pub async fn get_balances( &self, - owner: AccountAddress, + owner: RoochAddress, cursor: Option, limit: usize, ) -> Result, BalanceInfoView)>> { diff --git a/crates/rooch-rpc-server/src/service/rpc_service.rs b/crates/rooch-rpc-server/src/service/rpc_service.rs index 9956bab906..41c69283fc 100644 --- a/crates/rooch-rpc-server/src/service/rpc_service.rs +++ b/crates/rooch-rpc-server/src/service/rpc_service.rs @@ -2,21 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; -use move_core_types::account_address::AccountAddress; use move_core_types::language_storage::{ModuleId, StructTag}; use moveos_types::access_path::AccessPath; use moveos_types::function_return_value::AnnotatedFunctionResult; use moveos_types::h256::H256; -use moveos_types::moveos_std::account::Account; + use moveos_types::moveos_std::event::{AnnotatedEvent, Event, EventID}; -use moveos_types::state::{AnnotatedState, KeyState, MoveStructType, State}; +use moveos_types::state::{AnnotatedState, KeyState, State}; use moveos_types::state_resolver::{AnnotatedStateKV, StateKV}; use moveos_types::transaction::{FunctionCall, TransactionExecutionInfo}; use rooch_executor::proxy::ExecutorProxy; use rooch_indexer::proxy::IndexerProxy; use rooch_pipeline_processor::proxy::PipelineProcessorProxy; use rooch_sequencer::proxy::SequencerProxy; -use rooch_types::address::MultiChainAddress; +use rooch_types::address::{MultiChainAddress, RoochAddress}; use rooch_types::indexer::event_filter::{EventFilter, IndexerEvent, IndexerEventID}; use rooch_types::indexer::state::{ FieldStateFilter, IndexerFieldState, IndexerObjectState, IndexerStateID, ObjectStateFilter, @@ -86,21 +85,14 @@ impl RpcService { Ok(resp) } - pub async fn resolve_address(&self, mca: MultiChainAddress) -> Result { - self.executor.resolve_address(mca).await + pub async fn resolve_address(&self, mca: MultiChainAddress) -> Result { + self.executor.resolve_address(mca).await.map(Into::into) } pub async fn get_states(&self, access_path: AccessPath) -> Result>> { self.executor.get_states(access_path).await } - pub async fn exists_account(&self, address: AccountAddress) -> Result { - let mut resp = self - .get_states(AccessPath::resource(address, Account::struct_tag())) - .await?; - Ok(resp.pop().flatten().is_some()) - } - pub async fn exists_module(&self, module_id: ModuleId) -> Result { let mut resp = self.get_states(AccessPath::module(&module_id)).await?; Ok(resp.pop().flatten().is_some()) diff --git a/crates/rooch-types/src/address.rs b/crates/rooch-types/src/address.rs index e1690025b9..081847f6fd 100644 --- a/crates/rooch-types/src/address.rs +++ b/crates/rooch-types/src/address.rs @@ -7,17 +7,18 @@ use crate::{ multichain_id::{MultiChainID, RoochMultiChainID}, }; use anyhow::{bail, Result}; +use bech32::{Bech32m, Hrp}; use bitcoin::bech32::segwit::encode_to_fmt_unchecked; use bitcoin::script::PushBytesBuf; use bitcoin::{ address::Address, secp256k1::Secp256k1, Network, PrivateKey, Script, WitnessProgram, WitnessVersion, }; - use ethers::types::H160; use fastcrypto::hash::Blake2b256; use fastcrypto::hash::HashFunction; use fastcrypto::secp256k1::Secp256k1PublicKey; +use hex::FromHex; use move_core_types::language_storage::TypeTag; use move_core_types::{ account_address::AccountAddress, @@ -34,6 +35,7 @@ use moveos_types::{ }; use nostr::secp256k1::XOnlyPublicKey; use nostr::Keys; +use once_cell::sync::Lazy; #[cfg(any(test, feature = "fuzzing"))] use proptest::{collection::vec, prelude::*}; use rand::{seq::SliceRandom, thread_rng}; @@ -205,10 +207,79 @@ impl MoveStructState for MultiChainAddress { } } +pub static ROOCH_HRP: Lazy = Lazy::new(|| Hrp::parse("rooch").expect("rooch is a valid HRP")); + /// Rooch address type #[derive(Copy, Clone, Ord, PartialOrd, PartialEq, Eq, Hash)] pub struct RoochAddress(pub H256); +impl RoochAddress { + /// RoochAddress length in bytes + pub const LENGTH: usize = 32; + + /// RoochAddress length in bech32 string length: 5 hrp + 59 data + pub const LENGTH_BECH32: usize = 64; + + /// RoochAddress length in hex string length: 0x + 64 data + pub const LENGTH_HEX: usize = 66; + + pub fn from_bech32(bech32: &str) -> Result { + let (hrp, data) = bech32::decode(bech32)?; + anyhow::ensure!(hrp == *ROOCH_HRP, "invalid rooch hrp"); + anyhow::ensure!(data.len() == Self::LENGTH, "invalid rooch address length"); + let hash = H256::from_slice(data.as_slice()); + Ok(Self(hash)) + } + + pub fn to_bech32(&self) -> String { + let data = self.0.as_bytes(); + bech32::encode::(*ROOCH_HRP, data).expect("bech32 encode should success") + } + + pub fn to_vec(&self) -> Vec { + self.0.as_bytes().to_vec() + } + + pub fn into_bytes(self) -> [u8; Self::LENGTH] { + self.0.to_fixed_bytes() + } + + /// RoochAddress from_hex_literal support short hex string, such as 0x1, 0x2, 0x3 + pub fn from_hex_literal(literal: &str) -> Result { + anyhow::ensure!(literal.starts_with("0x"), "Hex literal must start with 0x"); + + let hex_len = literal.len() - 2; + + // If the string is too short, pad it + if hex_len < Self::LENGTH * 2 { + let mut hex_str = String::with_capacity(Self::LENGTH * 2); + for _ in 0..Self::LENGTH * 2 - hex_len { + hex_str.push('0'); + } + hex_str.push_str(&literal[2..]); + RoochAddress::from_hex(hex_str) + } else { + RoochAddress::from_hex(&literal[2..]) + } + } + + /// RoochAddress to_hex_literal always return full hex string + pub fn to_hex_literal(&self) -> String { + format!("0x{:x}", self.0) + } + + pub fn from_hex>(hex: T) -> Result { + <[u8; Self::LENGTH]>::from_hex(hex) + .map_err(|_| anyhow::anyhow!("Invalid address hex string")) + .map(H256) + .map(Self) + } + + pub fn to_hex(&self) -> String { + format!("{:x}", self.0) + } +} + impl RoochSupportedAddress for RoochAddress { fn random() -> Self { Self(H256::random()) @@ -253,14 +324,43 @@ impl TryFrom for RoochAddress { impl fmt::Display for RoochAddress { fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result { - //Use full address and 0x prefix for address display - write!(f, "0x{}", AccountAddress::from(*self)) + //Use bech32 as default display format + write!(f, "{}", self.to_bech32()) + } +} + +impl fmt::LowerHex for RoochAddress { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if f.alternate() { + write!(f, "0x")?; + } + + for byte in self.0.as_bytes() { + write!(f, "{:02x}", byte)?; + } + + Ok(()) + } +} + +impl fmt::UpperHex for RoochAddress { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if f.alternate() { + write!(f, "0x")?; + } + + for byte in self.0.as_bytes() { + write!(f, "{:02X}", byte)?; + } + + Ok(()) } } impl fmt::Debug for RoochAddress { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", AccountAddress::from(*self).to_hex_literal()) + // Display the address in bech32 and hex format for debug + write!(f, "{}({})", self.to_bech32(), self.to_hex_literal()) } } @@ -268,8 +368,11 @@ impl FromStr for RoochAddress { type Err = anyhow::Error; fn from_str(s: &str) -> Result { - let address = AccountAddress::from_str(s)?; - Ok(Self::from(address)) + if s.starts_with("0x") { + RoochAddress::from_hex_literal(s) + } else { + RoochAddress::from_bech32(s) + } } } @@ -296,6 +399,7 @@ impl Serialize for RoochAddress { if serializer.is_human_readable() { self.to_string().serialize(serializer) } else { + //Use Move AccountAddress as default binary serialize format let account_address: AccountAddress = (*self).into(); account_address.serialize(serializer) } @@ -699,12 +803,63 @@ impl fmt::Display for NostrAddress { } } +// Parsed Address, either a name or a numerical address +#[derive(Eq, PartialEq, Debug, Clone)] +pub enum ParsedAddress { + Named(String), + Numerical(RoochAddress), +} + +impl ParsedAddress { + pub fn into_rooch_address( + self, + mapping: &impl Fn(&str) -> Option, + ) -> anyhow::Result { + match self { + Self::Named(n) => mapping(n.as_str()) + .map(Into::into) + .ok_or_else(|| anyhow::anyhow!("Unbound named address: '{}'", n)), + Self::Numerical(a) => Ok(a), + } + } + + pub fn into_account_address( + self, + mapping: &impl Fn(&str) -> Option, + ) -> anyhow::Result { + self.into_rooch_address(mapping).map(AccountAddress::from) + } + + pub fn parse(s: &str) -> anyhow::Result { + if s.starts_with("0x") { + Ok(Self::Numerical(RoochAddress::from_hex_literal(s)?)) + } else if s.starts_with(ROOCH_HRP.as_str()) && s.len() == RoochAddress::LENGTH_BECH32 { + Ok(Self::Numerical(RoochAddress::from_bech32(s)?)) + } else { + Ok(Self::Named(s.to_string())) + } + } +} + #[cfg(test)] mod test { use super::*; use bitcoin::hex::DisplayHex; use std::fmt::Debug; + #[test] + fn test_bech32() { + let address = RoochAddress::random(); + let hex = address.to_hex_literal(); + let bech32 = address.to_bech32(); + println!("bech32: {}, hex: {}", bech32, hex); + assert_eq!(bech32.len(), RoochAddress::LENGTH_BECH32); + let address2 = RoochAddress::from_bech32(&bech32).unwrap(); + assert_eq!(address, address2); + let address3 = RoochAddress::from_hex_literal(&hex).unwrap(); + assert_eq!(address, address3); + } + fn test_sdk_multi_chain_address(address_str: &str, expect_address_bytes: Vec) { let address = bitcoin::Address::from_str(address_str) .unwrap() @@ -800,16 +955,21 @@ mod test { } fn test_rooch_address_roundtrip(rooch_address: RoochAddress) { - let rooch_str = rooch_address.to_string(); - //ensure the rooch to string is hex with 0x prefix + let rooch_hex_str = rooch_address.to_hex_literal(); + //ensure the rooch to_hex_literal is hex with 0x prefix //and is full 32 bytes output - assert!(rooch_str.starts_with("0x")); - assert_eq!(rooch_str.len(), 66); - let rooch_address_from_str = RoochAddress::from_str(&rooch_str).unwrap(); + assert!(rooch_hex_str.starts_with("0x")); + assert_eq!(rooch_hex_str.len(), RoochAddress::LENGTH_HEX); + let rooch_address_from_str = RoochAddress::from_str(&rooch_hex_str).unwrap(); assert_eq!(rooch_address, rooch_address_from_str); + let rooch_bech32_str = rooch_address.to_bech32(); + assert_eq!(rooch_bech32_str.len(), RoochAddress::LENGTH_BECH32); + let rooch_address_from_bech32 = RoochAddress::from_bech32(&rooch_bech32_str).unwrap(); + assert_eq!(rooch_address, rooch_address_from_bech32); + let json_str = serde_json::to_string(&rooch_address).unwrap(); - assert_eq!(format!("\"{}\"", rooch_str), json_str); + assert_eq!(format!("\"{}\"", rooch_bech32_str), json_str); let rooch_address_from_json: RoochAddress = serde_json::from_str(&json_str).unwrap(); assert_eq!(rooch_address, rooch_address_from_json); @@ -943,7 +1103,7 @@ mod test { ); assert_eq!( rooch_address.to_string(), - "0x7fe695faf7047ccfbc85f7dccb6c405d4e9b7b44788e71a71c3891a06ce0ca12" + "rooch10lnft7hhq37vl0y97lwvkmzqt48fk76y0z88rfcu8zg6qm8qegfqx0rq2h" ); Ok(()) diff --git a/crates/rooch-types/src/bitcoin/ord.rs b/crates/rooch-types/src/bitcoin/ord.rs index 1c6d212f9f..fdaaa4cedf 100644 --- a/crates/rooch-types/src/bitcoin/ord.rs +++ b/crates/rooch-types/src/bitcoin/ord.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use super::types::{OutPoint, Transaction}; -use crate::address::BitcoinAddress; +use crate::address::{BitcoinAddress, RoochAddress}; use crate::addresses::BITCOIN_MOVE_ADDRESS; use crate::indexer::state::IndexerObjectState; use crate::into_address::IntoAddress; @@ -231,7 +231,7 @@ impl<'a> ModuleBinding<'a> for OrdModule<'a> { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct InscriptionState { pub object_id: ObjectID, - pub owner: AccountAddress, + pub owner: RoochAddress, pub owner_bitcoin_address: Option, pub flag: u8, pub value: Inscription, diff --git a/crates/rooch-types/src/bitcoin/utxo.rs b/crates/rooch-types/src/bitcoin/utxo.rs index 53c89590e6..7a394fa472 100644 --- a/crates/rooch-types/src/bitcoin/utxo.rs +++ b/crates/rooch-types/src/bitcoin/utxo.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use super::types; -use crate::address::BitcoinAddress; +use crate::address::{BitcoinAddress, RoochAddress}; use crate::addresses::BITCOIN_MOVE_ADDRESS; use crate::indexer::state::IndexerObjectState; use anyhow::Result; @@ -93,7 +93,7 @@ pub fn derive_utxo_id(outpoint: &types::OutPoint) -> ObjectID { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct UTXOState { pub object_id: ObjectID, - pub owner: AccountAddress, + pub owner: RoochAddress, pub owner_bitcoin_address: Option, pub flag: u8, // There is a case when rooch bitcoin relayer synchronizes the bitcoin node data and processes the `process_block` diff --git a/crates/rooch-types/src/crypto.rs b/crates/rooch-types/src/crypto.rs index e4c5c0ec40..7347cd94ab 100644 --- a/crates/rooch-types/src/crypto.rs +++ b/crates/rooch-types/src/crypto.rs @@ -563,7 +563,7 @@ mod tests { let keypair: Ed25519KeyPair = private_key.into(); let address: RoochAddress = keypair.public().into(); assert_eq!( - address.to_string(), + address.to_hex_literal(), "0x7a1378aafadef8ce743b72e8b248295c8f61c102c94040161146ea4d51a182b6" ); } diff --git a/crates/rooch-types/src/function_arg.rs b/crates/rooch-types/src/function_arg.rs index 5a03262d11..6fe02a1618 100644 --- a/crates/rooch-types/src/function_arg.rs +++ b/crates/rooch-types/src/function_arg.rs @@ -1,10 +1,9 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use crate::error::RoochError; +use crate::{address::ParsedAddress, error::RoochError}; use anyhow::{anyhow, Result}; use move_command_line_common::{ - address::ParsedAddress, parser::Parser, types::ParsedStructType, values::{ParsableValue, ValueToken}, diff --git a/crates/rooch-types/src/indexer/event_filter.rs b/crates/rooch-types/src/indexer/event_filter.rs index 0ea0d31991..6c7dd7056a 100644 --- a/crates/rooch-types/src/indexer/event_filter.rs +++ b/crates/rooch-types/src/indexer/event_filter.rs @@ -1,9 +1,9 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use crate::indexer::Filter; +use crate::{address::RoochAddress, indexer::Filter}; use anyhow::Result; -use move_core_types::account_address::AccountAddress; + use move_core_types::language_storage::StructTag; use moveos_types::h256::H256; use moveos_types::move_types::struct_tag_match; @@ -52,7 +52,7 @@ pub struct IndexerEvent { /// the hash of this transaction. pub tx_hash: H256, /// the account address of sender who emit the event - pub sender: AccountAddress, + pub sender: RoochAddress, /// the event created timestamp on chain pub created_at: u64, @@ -64,7 +64,7 @@ pub enum EventFilter { /// Query by event type. EventType(StructTag), /// Query by sender address. - Sender(AccountAddress), + Sender(RoochAddress), /// Return events emitted by the given transaction hash. TxHash(H256), /// Return events emitted in [start_time, end_time) interval diff --git a/crates/rooch-types/src/indexer/state.rs b/crates/rooch-types/src/indexer/state.rs index 99abde0847..5401cb7618 100644 --- a/crates/rooch-types/src/indexer/state.rs +++ b/crates/rooch-types/src/indexer/state.rs @@ -1,9 +1,11 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 +use crate::address::RoochAddress; use crate::indexer::Filter; use anyhow::Result; -use move_core_types::account_address::AccountAddress; +use ethers::types::H256; + use move_core_types::language_storage::{StructTag, TypeTag}; use moveos_types::moveos_std::object::ObjectID; use moveos_types::state::StateChangeSet; @@ -47,10 +49,10 @@ impl IndexerStateID { #[derive(Clone, Debug)] pub struct IndexerObjectState { pub object_id: ObjectID, - pub owner: AccountAddress, + pub owner: RoochAddress, pub flag: u8, pub object_type: StructTag, - pub state_root: AccountAddress, + pub state_root: H256, pub size: u64, pub tx_order: u64, pub state_index: u64, @@ -82,12 +84,12 @@ pub enum ObjectStateFilter { /// Query by object type and owner. ObjectTypeWithOwner { object_type: StructTag, - owner: AccountAddress, + owner: RoochAddress, }, /// Query by object type. ObjectType(StructTag), /// Query by owner. - Owner(AccountAddress), + Owner(RoochAddress), /// Query by object ids. ObjectId(Vec), } diff --git a/crates/rooch-types/src/indexer/transaction_filter.rs b/crates/rooch-types/src/indexer/transaction_filter.rs index 2218eff56d..ce0ff6e523 100644 --- a/crates/rooch-types/src/indexer/transaction_filter.rs +++ b/crates/rooch-types/src/indexer/transaction_filter.rs @@ -1,7 +1,7 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use move_core_types::account_address::AccountAddress; +use crate::address::RoochAddress; use moveos_types::h256::H256; use serde::{Deserialize, Serialize}; @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; #[serde(rename_all = "camelCase")] pub enum TransactionFilter { /// Query by sender address. - Sender(AccountAddress), + Sender(RoochAddress), /// Query by multi chain original address. OriginalAddress(String), /// Query by the transaction hash list. diff --git a/crates/rooch/src/cli_types.rs b/crates/rooch/src/cli_types.rs index 1e45aba34c..731ac337ce 100644 --- a/crates/rooch/src/cli_types.rs +++ b/crates/rooch/src/cli_types.rs @@ -3,8 +3,8 @@ use async_trait::async_trait; use clap::Parser; -use move_command_line_common::address::ParsedAddress; use rooch_rpc_client::wallet_context::WalletContext; +use rooch_types::address::ParsedAddress; use rooch_types::authentication_key::AuthenticationKey; use rooch_types::error::{RoochError, RoochResult}; use rooch_types::transaction::authenticator::Authenticator; diff --git a/crates/rooch/src/commands/account/commands/balance.rs b/crates/rooch/src/commands/account/commands/balance.rs index 17d5aafbb0..fc07232846 100644 --- a/crates/rooch/src/commands/account/commands/balance.rs +++ b/crates/rooch/src/commands/account/commands/balance.rs @@ -7,9 +7,9 @@ use crate::cli_types::{CommandAction, WalletContextOptions}; use async_trait::async_trait; use clap::Parser; -use move_command_line_common::address::ParsedAddress; use move_command_line_common::types::ParsedStructType; use rooch_rpc_api::api::MAX_RESULT_LIMIT_USIZE; +use rooch_types::address::ParsedAddress; use rooch_types::error::RoochResult; /// Show account balance, only the accounts managed by the current node are supported diff --git a/crates/rooch/src/commands/account/commands/list.rs b/crates/rooch/src/commands/account/commands/list.rs index b85c2a0724..296d555f10 100644 --- a/crates/rooch/src/commands/account/commands/list.rs +++ b/crates/rooch/src/commands/account/commands/list.rs @@ -6,7 +6,11 @@ use async_trait::async_trait; use clap::Parser; use rooch_key::keystore::account_keystore::AccountKeystore; use rooch_key::keystore::types::LocalAccount; -use rooch_types::{crypto::EncodeDecodeBase64, error::RoochResult}; +use rooch_types::{ + address::MultiChainAddress, + crypto::{EncodeDecodeBase64, PublicKey}, + error::RoochResult, +}; use rpassword::prompt_password; use serde::{Deserialize, Serialize}; use std::fmt::Debug; @@ -22,9 +26,30 @@ pub struct ListCommand { json: bool, } +#[derive(Serialize, Deserialize, Debug)] +pub struct LocalAccountView { + pub address: String, + pub hex_address: String, + pub multichain_address: Option, + pub public_key: Option, + pub has_session_key: bool, +} + +impl From for LocalAccountView { + fn from(account: LocalAccount) -> Self { + LocalAccountView { + address: account.address.to_bech32(), + hex_address: account.address.to_hex_literal(), + multichain_address: account.multichain_address, + public_key: account.public_key, + has_session_key: account.has_session_key, + } + } +} + #[derive(Serialize, Deserialize, Debug)] pub struct AccountView { - pub local_account: LocalAccount, + pub local_account: LocalAccountView, pub active: bool, } @@ -43,52 +68,51 @@ impl CommandAction<()> for ListCommand { }; let accounts: Vec = context.keystore.get_accounts(password)?; + let accont_views: Vec = accounts + .into_iter() + .map(|account: LocalAccount| { + let active = Some(account.address) == active_address; + AccountView { + local_account: account.into(), + active, + } + }) + .collect(); if self.json { - let accont_views: Vec = accounts - .into_iter() - .map(|account: LocalAccount| AccountView { - local_account: account.clone(), - active: Some(account.address) == active_address, - }) - .collect(); - println!("{}", serde_json::to_string_pretty(&accont_views).unwrap()); - return Ok(()); - } - - println!( - "{:^66} | {:^66} | {:^48} | {:^16} | {:^12}", - "Rooch Address (Ed25519)", - "Multichain Address", - "Public Key (Base64)", - "Has session key", - "Active Address" - ); - println!("{}", ["-"; 153].join("")); - - for account in accounts { - let address = account.address; - let active = if active_address == Some(address) { - "True" - } else { - "" - }; - + } else { + //TODO optimize the output format println!( - "{:^66} | {:^66} | {:^48} | {:^16} | {:^12}", - address, - account - .multichain_address - .map(|multichain_address| multichain_address.to_string()) - .unwrap_or_default(), - account - .public_key - .map(|public_key| public_key.encode_base64()) - .unwrap_or_default(), - account.has_session_key.to_string(), - active + "{:^66} | {:^66} | {:^48} | {:^48} | {:^10} | {:^10}", + "Address (bech32)", + "Address (hex)", + "Multichain Address", + "Public Key(base64)", + "Session key", + "Active" ); + println!("{}", ["-"; 68].join("")); + + for account in accont_views { + println!( + "{:^66} | {:^66} | {:^48} | {:^48} | {:^10} | {:^10}", + account.local_account.address, + account.local_account.hex_address, + account + .local_account + .multichain_address + .map(|multichain_address| multichain_address.to_string()) + .unwrap_or_default(), + account + .local_account + .public_key + .map(|public_key| public_key.encode_base64()) + .unwrap_or_default(), + account.local_account.has_session_key.to_string(), + account.active + ); + } } Ok(()) diff --git a/crates/rooch/src/commands/account/commands/transfer.rs b/crates/rooch/src/commands/account/commands/transfer.rs index 15d095c1d5..387e2f265b 100644 --- a/crates/rooch/src/commands/account/commands/transfer.rs +++ b/crates/rooch/src/commands/account/commands/transfer.rs @@ -4,12 +4,12 @@ use crate::cli_types::{CommandAction, TransactionOptions, WalletContextOptions}; use async_trait::async_trait; use clap::Parser; -use move_command_line_common::address::ParsedAddress; use move_command_line_common::types::ParsedStructType; use move_core_types::u256::U256; use rooch_key::key_derive::verify_password; use rooch_key::keystore::account_keystore::AccountKeystore; use rooch_rpc_api::jsonrpc_types::ExecuteTransactionResponseView; +use rooch_types::address::ParsedAddress; use rooch_types::address::RoochAddress; use rooch_types::framework::transfer::TransferModule; use rooch_types::{ diff --git a/crates/rooch/src/commands/resource.rs b/crates/rooch/src/commands/resource.rs index 73d3571373..c50e62dd8d 100644 --- a/crates/rooch/src/commands/resource.rs +++ b/crates/rooch/src/commands/resource.rs @@ -4,10 +4,10 @@ use crate::cli_types::{CommandAction, WalletContextOptions}; use async_trait::async_trait; use clap::Parser; -use move_command_line_common::{address::ParsedAddress, types::ParsedStructType}; +use move_command_line_common::types::ParsedStructType; use moveos_types::access_path::AccessPath; use rooch_rpc_api::jsonrpc_types::StateView; -use rooch_types::error::RoochResult; +use rooch_types::{address::ParsedAddress, error::RoochResult}; #[derive(Debug, Parser)] diff --git a/sdk/typescript/rooch-sdk/test/e2e/cli/rooch-cli.ts b/sdk/typescript/rooch-sdk/test/e2e/cli/rooch-cli.ts index 20faa67c98..f92d5bd8b1 100644 --- a/sdk/typescript/rooch-sdk/test/e2e/cli/rooch-cli.ts +++ b/sdk/typescript/rooch-sdk/test/e2e/cli/rooch-cli.ts @@ -85,7 +85,7 @@ export class RoochCli { const accounts = await this.execute(['account', 'list', '--json']) for (const account of accounts) { if (account.active) { - return account.local_account.address + return account.local_account.hex_address } } From 2fe915f35c19a25fd4eb054140510397da70de24 Mon Sep 17 00:00:00 2001 From: sven Tan Date: Mon, 27 May 2024 21:28:00 +0800 Subject: [PATCH 3/5] fix (#1750) --- .eslintrc.js | 14 ++++ pnpm-lock.yaml | 8 +-- sdk/typescript/rooch-create/bin/index.js | 2 +- sdk/typescript/rooch-create/package.json | 2 +- sdk/typescript/rooch-create/src/index.ts | 72 +++++++++---------- .../rooch-create/tsconfig.tsbuildinfo | 2 +- 6 files changed, 55 insertions(+), 45 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 751fb8ad71..15590259d1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -225,5 +225,19 @@ module.exports = { 'arrow-body-style': ['error', 'as-needed'], }, }, + { + files: ['sdk/typescript/rooch-create/**/*'], + rules: { + '@typescript-eslint/ban-types': 'off', + 'no-restricted-globals': 'off', + }, + }, + { + files: ['sdk/typescript/templates/**/*'], + rules: { + 'header/header': 'off', + 'require-extensions/require-extensions': 'off', + }, + }, ], } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b8810b1b07..74c7097f53 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -563,8 +563,8 @@ importers: version: 5.2.2 devDependencies: '@types/node': - specifier: ^18.15.13 - version: 18.15.13 + specifier: ^20.4.2 + version: 20.11.24 sdk/typescript/rooch-sdk: dependencies: @@ -8709,10 +8709,6 @@ packages: resolution: {integrity: sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==} dev: true - /@types/node@18.15.13: - resolution: {integrity: sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==} - dev: true - /@types/node@18.15.3: resolution: {integrity: sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==} dev: true diff --git a/sdk/typescript/rooch-create/bin/index.js b/sdk/typescript/rooch-create/bin/index.js index fab8e6831c..fbd6b677d9 100755 --- a/sdk/typescript/rooch-create/bin/index.js +++ b/sdk/typescript/rooch-create/bin/index.js @@ -1,3 +1,3 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -require('../dist/index.js'); +require('../dist/index.js') diff --git a/sdk/typescript/rooch-create/package.json b/sdk/typescript/rooch-create/package.json index d739662a3b..f3437fa40e 100644 --- a/sdk/typescript/rooch-create/package.json +++ b/sdk/typescript/rooch-create/package.json @@ -29,7 +29,7 @@ "enquirer": "^2.4.1" }, "devDependencies": { - "@types/node": "^18.15.13" + "@types/node": "^20.4.2" }, "publishConfig": { "access": "public", diff --git a/sdk/typescript/rooch-create/src/index.ts b/sdk/typescript/rooch-create/src/index.ts index 0c6c88b2c4..fce5513b6f 100644 --- a/sdk/typescript/rooch-create/src/index.ts +++ b/sdk/typescript/rooch-create/src/index.ts @@ -2,11 +2,11 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -import { existsSync, statSync } from 'fs'; -import { mkdir, readdir, readFile, writeFile } from 'fs/promises'; -import { relative, resolve } from 'path'; -import { parseArgs } from 'util'; -import { prompt } from 'enquirer'; +import { existsSync, statSync } from 'fs' +import { mkdir, readdir, readFile, writeFile } from 'fs/promises' +import { relative, resolve } from 'path' +import { parseArgs } from 'util' +import { prompt } from 'enquirer' const { values: args } = parseArgs({ options: { @@ -16,12 +16,12 @@ const { values: args } = parseArgs({ short: 't', }, }, -}); +}) async function main() { const results = await prompt<{ - template: string; - dAppName: string; + template: string + dAppName: string }>( [ { @@ -42,59 +42,59 @@ async function main() { initial: 'my-first-dapp', }, ].filter((question) => !args[question.name as 'template']), - ); + ) - const outDir = resolve(process.cwd(), results.dAppName); + const outDir = resolve(process.cwd(), results.dAppName) if (existsSync(outDir)) { - throw new Error(`Directory ${outDir} already exists`); + throw new Error(`Directory ${outDir} already exists`) } - const files = await collectFiles(results.template ?? args.template, results.dAppName); - await writeFiles(files, outDir); + const files = await collectFiles(results.template ?? args.template, results.dAppName) + await writeFiles(files, outDir) } -main(); +main() async function collectFiles(template: string, dAppName: string) { // const dependencies = await getDependencyVersions(); - const templateDir = resolve(__dirname, '../dist/templates', template); + const templateDir = resolve(__dirname, '../dist/templates', template) const files = new Array<{ - path: string; - content: Buffer; - }>(); + path: string + content: Buffer + }>() if (!statSync(templateDir).isDirectory()) { - throw new Error(`Template ${templateDir} could not be found`); + throw new Error(`Template ${templateDir} could not be found`) } - await addDir(templateDir); + await addDir(templateDir) - return files; + return files async function addDir(dir: string) { - const entries = await readdir(dir); + const entries = await readdir(dir) for (const entry of entries) { if (entry === 'node_modules') { - continue; + continue } - const entryPath = resolve(dir, entry); - const stat = statSync(entryPath); + const entryPath = resolve(dir, entry) + const stat = statSync(entryPath) if (stat.isDirectory()) { - await addDir(entryPath); + await addDir(entryPath) } else { - let content = await readFile(entryPath); + let content = await readFile(entryPath) if (entry === 'package.json') { - const json = JSON.parse(content.toString()); - json.name = dAppName; + const json = JSON.parse(content.toString()) + json.name = dAppName - content = Buffer.from(JSON.stringify(json, null, 2)); + content = Buffer.from(JSON.stringify(json, null, 2)) } - files.push({ path: relative(templateDir, entryPath), content }); + files.push({ path: relative(templateDir, entryPath), content }) } } } @@ -102,12 +102,12 @@ async function collectFiles(template: string, dAppName: string) { async function writeFiles(files: Array<{ path: string; content: Buffer }>, outDir: string) { for (const file of files) { - const filePath = resolve(outDir, file.path); - const dirPath = resolve(filePath, '..'); + const filePath = resolve(outDir, file.path) + const dirPath = resolve(filePath, '..') if (!existsSync(dirPath)) { - await mkdir(dirPath, { recursive: true }); + await mkdir(dirPath, { recursive: true }) } - await writeFile(filePath, file.content); + await writeFile(filePath, file.content) } -} \ No newline at end of file +} diff --git a/sdk/typescript/rooch-create/tsconfig.tsbuildinfo b/sdk/typescript/rooch-create/tsconfig.tsbuildinfo index 8eb06d3956..8b4c1964b8 100644 --- a/sdk/typescript/rooch-create/tsconfig.tsbuildinfo +++ b/sdk/typescript/rooch-create/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"program":{"fileNames":["../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2023.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2023.array.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2023.collection.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/enquirer@2.4.1/node_modules/enquirer/index.d.ts","./src/index.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/assert.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/assert/strict.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/globals.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/async_hooks.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/buffer.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/child_process.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/cluster.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/console.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/constants.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/crypto.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/dgram.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/dns.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/dns/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/domain.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/dom-events.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/events.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/fs.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/fs/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/http.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/http2.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/https.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/inspector.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/module.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/net.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/os.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/path.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/process.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/punycode.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/querystring.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/readline.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/readline/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/repl.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/stream.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/stream/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/stream/web.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/string_decoder.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/test.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/timers.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/timers/promises.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/tls.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/trace_events.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/tty.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/url.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/util.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/v8.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/vm.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/wasi.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/worker_threads.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/zlib.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/globals.global.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/index.d.ts","../../../../../../node_modules/@types/yargs-parser/index.d.ts","../../../../../../node_modules/@types/yargs/index.d.ts","../../../../../../node_modules/@types/yargs-interactive/index.d.ts"],"fileInfos":[{"version":"2ac9cdcfb8f8875c18d14ec5796a8b029c426f73ad6dc3ffb580c228b58d1c44","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","bed7b7ba0eb5a160b69af72814b4dde371968e40b6c5e73d3a9f7bee407d158c",{"version":"0075fa5ceda385bcdf3488e37786b5a33be730e8bc4aa3cf1e78c63891752ce8","affectsGlobalScope":true},{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true},{"version":"09226e53d1cfda217317074a97724da3e71e2c545e18774484b61562afc53cd2","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"8b41361862022eb72fcc8a7f34680ac842aca802cf4bc1f915e8c620c9ce4331","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"b7e9f95a7387e3f66be0ed6db43600c49cec33a3900437ce2fd350d9b7cb16f2","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"bc496ef4377553e461efcf7cc5a5a57cf59f9962aea06b5e722d54a36bf66ea1","affectsGlobalScope":true},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"930b0e15811f84e203d3c23508674d5ded88266df4b10abee7b31b2ac77632d2","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"65be38e881453e16f128a12a8d36f8b012aa279381bf3d4dc4332a4905ceec83","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"e1913f656c156a9e4245aa111fbb436d357d9e1fe0379b9a802da7fe3f03d736","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"f35a831e4f0fe3b3697f4a0fe0e3caa7624c92b78afbecaf142c0f93abfaf379","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"d94fb8e72df086792fe3ea7bcedbfe35d740a00003e2c6580be1cecab369d509",{"version":"2bfb03f893af621ae1e5344da2094cac9c062a18c8d0cd67e3e95f467adca2cf","signature":"43e818adf60173644896298637f47b01d5819b17eda46eaa32d0c7d64724d012"},"7e771891adaa85b690266bc37bd6eb43bc57eecc4b54693ead36467e7369952a","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"8d81612302e009aacd595b125ae1530b6342f690eb83da7788503617d1362185","affectsGlobalScope":true},"11e2d554398d2bd460e7d06b2fa5827a297c8acfbe00b4f894a224ac0862857f",{"version":"e193e634a99c9c1d71f1c6e4e1567a4a73584328d21ea02dd5cddbaad6693f61","affectsGlobalScope":true},"374ca798f244e464346f14301dc2a8b4b111af1a83b49fffef5906c338a1f922","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","e596c9bb2f29a2699fdd4ae89139612652245192f67f45617c5a4b20832aaae9","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","1cdcfc1f624d6c08aa12c73935f6e13f095919cd99edf95752951796eb225729","216717f17c095cde1dc19375e1ab3af0a4a485355860c077a4f9d6ea59fab5b5","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"816ad2e607a96de5bcac7d437f843f5afd8957f1fa5eefa6bba8e4ed7ca8fd84","affectsGlobalScope":true},"80473bd0dd90ca1e166514c2dfead9d5803f9c51418864ca35abbeec6e6847e1","1c84b46267610a34028edfd0d035509341751262bac1062857f3c8df7aff7153","e6c86d83bd526c8bdb5d0bf935b8e72ce983763d600743f74d812fdf4abf4df6","a3d541d303ee505053f5dcbf9fafb65cac3d5631037501cd616195863a6c5740","8d3c583a07e0c37e876908c2d5da575019f689df8d9fa4c081d99119d53dba22","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e630e5528e899219ae319e83bef54bf3bcb91b01d76861ecf881e8e614b167f0","affectsGlobalScope":true},"bcebb922784739bdb34c18ee51095d25a92b560c78ccd2eaacd6bd00f7443d83","7ee6ed878c4528215c82b664fe0cfe80e8b4da6c0d4cc80869367868774db8b1","b0973c3cbcdc59b37bf477731d468696ecaf442593ec51bab497a613a580fe30",{"version":"4989e92ba5b69b182d2caaea6295af52b7dc73a4f7a2e336a676722884e7139d","affectsGlobalScope":true},{"version":"0715e4cd28ad471b2a93f3e552ff51a3ae423417a01a10aa1d3bc7c6b95059d6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","210d54cd652ec0fec8c8916e4af59bb341065576ecda039842f9ffb2e908507c","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","4f3fdeba4e28e21aa719c081b8dc8f91d47e12e773389b9d35679c08151c9d37","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","69ee23dd0d215b09907ad30d23f88b7790c93329d1faf31d7835552a10cf7cbf","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","f69ff39996a61a0dd10f4bce73272b52e8024a4d58b13ab32bf4712909d0a2b7",{"version":"3c4ba1dd9b12ffa284b565063108f2f031d150ea15b8fafbdc17f5d2a07251f3","affectsGlobalScope":true},"e10177274a35a9d07c825615340b2fcde2f610f53f3fb40269fd196b4288dda6","c4577fb855ca259bdbf3ea663ca73988ce5f84251a92b4aef80a1f4122b6f98e","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"f0900cd5d00fe1263ff41201fb8073dbeb984397e4af3b8002a5c207a30bdc33","affectsGlobalScope":true},{"version":"ff07a9a03c65732ccc59b3c65bc584173da093bd563a6565411c01f5703bd3cb","affectsGlobalScope":true},"6de4a219df57d2b27274d59b67708f13c2cbf7ed211abe57d8f9ab8b25cde776","0fe8985a28f82c450a04a6edf1279d7181c0893f37da7d2a27f8efd4fd5edb03","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa",{"version":"da26af7362f53d122283bc69fed862b9a9fe27e01bc6a69d1d682e0e5a4df3e6","affectsGlobalScope":true},"8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"d8d555f3d607ecaa18d55de6995ea8f206342ecc93305919eac945c7c78c78c6","bae8d023ef6b23df7da26f51cea44321f95817c190342a36882e93b80d07a960","5d30d04a14ed8527ac5d654dc345a4db11b593334c11a65efb6e4facc5484a0e","6a704c16c203c217f936e7482754844f9e7dc90c2bf1df8f34df7132952d8f5e"],"root":[66],"options":{"composite":true,"declaration":true,"emitDeclarationOnly":false,"esModuleInterop":true,"jsx":2,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7},"fileIdsList":[[67,113],[70,113],[71,76,104,113],[72,83,84,91,101,112,113],[72,73,83,91,113],[74,113],[75,76,84,92,113],[76,101,109,113],[77,79,83,91,113],[78,113],[79,80,113],[83,113],[81,83,113],[83,84,85,101,112,113],[83,84,85,98,101,104,113],[113,117],[113],[79,86,91,101,112,113],[83,84,86,87,91,101,109,112,113],[86,88,101,109,112,113],[67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119],[83,89,113],[90,112,113],[79,83,91,101,113],[92,113],[93,113],[70,94,113],[95,111,113,117],[96,113],[97,113],[83,98,99,113],[98,100,113,115],[71,83,101,102,103,104,113],[71,101,103,113],[101,102,113],[104,113],[105,113],[83,107,108,113],[107,108,113],[76,91,101,109,113],[110,113],[91,111,113],[71,86,97,112,113],[76,113],[101,113,114],[113,115],[113,116],[71,76,83,85,94,101,112,113,115,117],[101,113,118],[65,84,85,93,113],[113,122],[113,121]],"referencedMap":[[67,1],[68,1],[70,2],[71,3],[72,4],[73,5],[74,6],[75,7],[76,8],[77,9],[78,10],[79,11],[80,11],[82,12],[81,13],[83,12],[84,14],[85,15],[69,16],[119,17],[86,18],[87,19],[88,20],[120,21],[89,22],[90,23],[91,24],[92,25],[93,26],[94,27],[95,28],[96,29],[97,30],[98,31],[99,31],[100,32],[101,33],[103,34],[102,35],[104,36],[105,37],[106,17],[107,38],[108,39],[109,40],[110,41],[111,42],[112,43],[113,44],[114,45],[115,46],[116,47],[117,48],[118,49],[65,12],[63,17],[64,17],[12,17],[14,17],[13,17],[2,17],[15,17],[16,17],[17,17],[18,17],[19,17],[20,17],[21,17],[22,17],[3,17],[4,17],[23,17],[27,17],[24,17],[25,17],[26,17],[28,17],[29,17],[30,17],[5,17],[31,17],[32,17],[33,17],[34,17],[6,17],[38,17],[35,17],[36,17],[37,17],[39,17],[7,17],[40,17],[45,17],[46,17],[41,17],[42,17],[43,17],[44,17],[8,17],[50,17],[47,17],[48,17],[49,17],[51,17],[9,17],[52,17],[53,17],[54,17],[57,17],[55,17],[56,17],[58,17],[59,17],[10,17],[1,17],[11,17],[62,17],[61,17],[60,17],[66,50],[123,51],[121,17],[122,52]],"exportedModulesMap":[[67,1],[68,1],[70,2],[71,3],[72,4],[73,5],[74,6],[75,7],[76,8],[77,9],[78,10],[79,11],[80,11],[82,12],[81,13],[83,12],[84,14],[85,15],[69,16],[119,17],[86,18],[87,19],[88,20],[120,21],[89,22],[90,23],[91,24],[92,25],[93,26],[94,27],[95,28],[96,29],[97,30],[98,31],[99,31],[100,32],[101,33],[103,34],[102,35],[104,36],[105,37],[106,17],[107,38],[108,39],[109,40],[110,41],[111,42],[112,43],[113,44],[114,45],[115,46],[116,47],[117,48],[118,49],[65,12],[63,17],[64,17],[12,17],[14,17],[13,17],[2,17],[15,17],[16,17],[17,17],[18,17],[19,17],[20,17],[21,17],[22,17],[3,17],[4,17],[23,17],[27,17],[24,17],[25,17],[26,17],[28,17],[29,17],[30,17],[5,17],[31,17],[32,17],[33,17],[34,17],[6,17],[38,17],[35,17],[36,17],[37,17],[39,17],[7,17],[40,17],[45,17],[46,17],[41,17],[42,17],[43,17],[44,17],[8,17],[50,17],[47,17],[48,17],[49,17],[51,17],[9,17],[52,17],[53,17],[54,17],[57,17],[55,17],[56,17],[58,17],[59,17],[10,17],[1,17],[11,17],[62,17],[61,17],[60,17],[123,51],[121,17],[122,52]],"semanticDiagnosticsPerFile":[67,68,70,71,72,73,74,75,76,77,78,79,80,82,81,83,84,85,69,119,86,87,88,120,89,90,91,92,93,94,95,96,97,98,99,100,101,103,102,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,65,63,64,12,14,13,2,15,16,17,18,19,20,21,22,3,4,23,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,59,10,1,11,62,61,60,66,123,121,122],"latestChangedDtsFile":"./dist/index.d.ts"},"version":"5.2.2"} \ No newline at end of file +{"program":{"fileNames":["../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2023.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2023.array.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es2023.collection.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/enquirer@2.4.1/node_modules/enquirer/index.d.ts","./src/index.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/assert.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/assert/strict.d.ts","../../../node_modules/.pnpm/buffer@6.0.0/node_modules/buffer/index.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/header.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/readable.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/file.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/fetch.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/formdata.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/connector.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/client.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/errors.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/dispatcher.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/global-dispatcher.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/global-origin.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/pool-stats.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/pool.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/handlers.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/balanced-pool.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/agent.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/mock-interceptor.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/mock-agent.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/mock-client.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/mock-pool.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/mock-errors.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/proxy-agent.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/api.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/cookies.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/patch.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/filereader.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/diagnostics-channel.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/websocket.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/content-type.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/cache.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/interceptors.d.ts","../../../node_modules/.pnpm/undici-types@5.26.5/node_modules/undici-types/index.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/globals.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/async_hooks.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/buffer.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/child_process.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/cluster.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/console.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/constants.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/crypto.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/dgram.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/dns.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/dns/promises.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/domain.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/dom-events.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/events.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/fs.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/fs/promises.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/http.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/http2.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/https.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/inspector.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/module.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/net.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/os.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/path.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/process.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/punycode.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/querystring.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/readline.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/readline/promises.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/repl.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/stream.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/stream/promises.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/stream/web.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/string_decoder.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/test.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/timers.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/timers/promises.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/tls.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/trace_events.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/tty.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/url.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/util.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/v8.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/vm.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/wasi.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/worker_threads.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/zlib.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/globals.global.d.ts","../../../node_modules/.pnpm/@types+node@20.11.24/node_modules/@types/node/index.d.ts","../../../../../../node_modules/@types/yargs-parser/index.d.ts","../../../../../../node_modules/@types/yargs/index.d.ts","../../../../../../node_modules/@types/yargs-interactive/index.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/events.d.ts","../../../node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/util.d.ts"],"fileInfos":[{"version":"2ac9cdcfb8f8875c18d14ec5796a8b029c426f73ad6dc3ffb580c228b58d1c44","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","bed7b7ba0eb5a160b69af72814b4dde371968e40b6c5e73d3a9f7bee407d158c",{"version":"0075fa5ceda385bcdf3488e37786b5a33be730e8bc4aa3cf1e78c63891752ce8","affectsGlobalScope":true},{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true},{"version":"09226e53d1cfda217317074a97724da3e71e2c545e18774484b61562afc53cd2","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"8b41361862022eb72fcc8a7f34680ac842aca802cf4bc1f915e8c620c9ce4331","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"b7e9f95a7387e3f66be0ed6db43600c49cec33a3900437ce2fd350d9b7cb16f2","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"bc496ef4377553e461efcf7cc5a5a57cf59f9962aea06b5e722d54a36bf66ea1","affectsGlobalScope":true},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"930b0e15811f84e203d3c23508674d5ded88266df4b10abee7b31b2ac77632d2","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"65be38e881453e16f128a12a8d36f8b012aa279381bf3d4dc4332a4905ceec83","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"e1913f656c156a9e4245aa111fbb436d357d9e1fe0379b9a802da7fe3f03d736","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"f35a831e4f0fe3b3697f4a0fe0e3caa7624c92b78afbecaf142c0f93abfaf379","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"d94fb8e72df086792fe3ea7bcedbfe35d740a00003e2c6580be1cecab369d509",{"version":"de543454d64d05209686472a2e604a53140755644fd50df7d35a7dcb14ebc593","signature":"43e818adf60173644896298637f47b01d5819b17eda46eaa32d0c7d64724d012"},"efc7d584a33fe3422847783d228f315c4cd1afe74bd7cf8e3f0e4c1125129fef","7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","8e9c23ba78aabc2e0a27033f18737a6df754067731e69dc5f52823957d60a4b6","5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","7180c03fd3cb6e22f911ce9ba0f8a7008b1a6ddbe88ccf16a9c8140ef9ac1686","25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","54cb85a47d760da1c13c00add10d26b5118280d44d58e6908d8e89abbd9d7725","3e4825171442666d31c845aeb47fcd34b62e14041bb353ae2b874285d78482aa","c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","a967bfe3ad4e62243eb604bf956101e4c740f5921277c60debaf325c1320bf88","e9775e97ac4877aebf963a0289c81abe76d1ec9a2a7778dbe637e5151f25c5f3","471e1da5a78350bc55ef8cef24eb3aca6174143c281b8b214ca2beda51f5e04a","cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","db3435f3525cd785bf21ec6769bf8da7e8a776be1a99e2e7efb5f244a2ef5fee","c3b170c45fc031db31f782e612adf7314b167e60439d304b49e704010e7bafe5","40383ebef22b943d503c6ce2cb2e060282936b952a01bea5f9f493d5fb487cc7","4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","3a84b7cb891141824bd00ef8a50b6a44596aded4075da937f180c90e362fe5f6","13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","33203609eba548914dc83ddf6cadbc0bcb6e8ef89f6d648ca0908ae887f9fcc5","0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","9f0a92164925aa37d4a5d9dd3e0134cff8177208dba55fd2310cd74beea40ee2","8bfdb79bf1a9d435ec48d9372dc93291161f152c0865b81fc0b2694aedb4578d","2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","d32275be3546f252e3ad33976caf8c5e842c09cb87d468cb40d5f4cf092d1acc","4a0c3504813a3289f7fb1115db13967c8e004aa8e4f8a9021b95285502221bd1",{"version":"a14ed46fa3f5ffc7a8336b497cd07b45c2084213aaca933a22443fcb2eef0d07","affectsGlobalScope":true},"cce1f5f86974c1e916ec4a8cab6eec9aa8e31e8148845bf07fbaa8e1d97b1a2c",{"version":"7fd7fcbf021a5845bdd9397d4649fcf2fe17152d2098140fc723099a215d19ad","affectsGlobalScope":true},"df3389f71a71a38bc931aaf1ef97a65fada98f0a27f19dd12f8b8de2b0f4e461","7b43160a49cf2c6082da0465876c4a0b164e160b81187caeb0a6ca7a281e85ba",{"version":"41fb2a1c108fbf46609ce5a451b7ec78eb9b5ada95fd5b94643e4b26397de0b3","affectsGlobalScope":true},"a40826e8476694e90da94aa008283a7de50d1dafd37beada623863f1901cb7fb",{"version":"a1d2988ad9d2aef7b9915a22b5e52c165c83a878f2851c35621409046bbe3c05","affectsGlobalScope":true},"bd3f5d05b6b5e4bfcea7739a45f3ffb4a7f4a3442ba7baf93e0200799285b8f1","4c775c2fccabf49483c03cd5e3673f87c1ffb6079d98e7b81089c3def79e29c6","8806ae97308ef26363bd7ec8071bca4d07fb575f905ee3d8a91aff226df6d618","af5bf1db6f1804fb0069039ae77a05d60133c77a2158d9635ea27b6bb2828a8f","b7fe70be794e13d1b7940e318b8770cd1fb3eced7707805318a2e3aaac2c3e9e",{"version":"2c71199d1fc83bf17636ad5bf63a945633406b7b94887612bba4ef027c662b3e","affectsGlobalScope":true},{"version":"674168aa3db414ea0a19b2a31d901b2d49705c7a495e43ffdc96928543010f8c","affectsGlobalScope":true},"fe1fd6afdfe77976d4c702f3746c05fb05a7e566845c890e0e970fe9376d6a90","313a0b063f5188037db113509de1b934a0e286f14e9479af24fada241435e707","afb1701fd4be413a8a5a88df6befdd4510c30a31372c07a4138facf61594c66d","87ef1a23caa071b07157c72077fa42b86d30568f9dc9e31eed24d5d14fc30ba8","396a8939b5e177542bdf9b5262b4eee85d29851b2d57681fa9d7eae30e225830","21773f5ac69ddf5a05636ba1f50b5239f4f2d27e4420db147fc2f76a5ae598ac",{"version":"ea455cc68871b049bcecd9f56d4cf27b852d6dafd5e3b54468ca87cc11604e4d","affectsGlobalScope":true},"c07146dbbbd8b347241b5df250a51e48f2d7bef19b1e187b1a3f20c849988ff1","45b1053e691c5af9bfe85060a3e1542835f8d84a7e6e2e77ca305251eda0cb3c","0f05c06ff6196958d76b865ae17245b52d8fe01773626ac3c43214a2458ea7b7",{"version":"ae5507fc333d637dec9f37c6b3f4d423105421ea2820a64818de55db85214d66","affectsGlobalScope":true},{"version":"0666f4c99b8688c7be5956df8fecf5d1779d3b22f8f2a88258ae7072c7b6026f","affectsGlobalScope":true},"8abd0566d2854c4bd1c5e48e05df5c74927187f1541e6770001d9637ac41542e","54e854615c4eafbdd3fd7688bd02a3aafd0ccf0e87c98f79d3e9109f047ce6b8","d8dba11dc34d50cb4202de5effa9a1b296d7a2f4a029eec871f894bddfb6430d","8b71dd18e7e63b6f991b511a201fad7c3bf8d1e0dd98acb5e3d844f335a73634","01d8e1419c84affad359cc240b2b551fb9812b450b4d3d456b64cda8102d4f60","8221b00f271cf7f535a8eeec03b0f80f0929c7a16116e2d2df089b41066de69b","269929a24b2816343a178008ac9ae9248304d92a8ba8e233055e0ed6dbe6ef71","93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","7424817d5eb498771e6d1808d726ec38f75d2eaf3fa359edd5c0c540c52725c1","9a9634296cca836c3308923ba7aa094fa6ed76bb1e366d8ddcf5c65888ab1024",{"version":"bddce945d552a963c9733db106b17a25474eefcab7fc990157a2134ef55d4954","affectsGlobalScope":true},{"version":"7052b7b0c3829df3b4985bab2fd74531074b4835d5a7b263b75c82f0916ad62f","affectsGlobalScope":true},"aa34c3aa493d1c699601027c441b9664547c3024f9dbab1639df7701d63d18fa","4b55240c2a03b2c71e98a7fc528b16136faa762211c92e781a01c37821915ea6","7c651f8dce91a927ab62925e73f190763574c46098f2b11fb8ddc1b147a6709a","7440ab60f4cb031812940cc38166b8bb6fbf2540cfe599f87c41c08011f0c1df",{"version":"94c086dff8dbc5998749326bc69b520e8e4273fb5b7b58b50e0210e0885dfcde","affectsGlobalScope":true},{"version":"f5b5dc128973498b75f52b1b8c2d5f8629869104899733ae485100c2309b4c12","affectsGlobalScope":true},"ebe5facd12fd7745cda5f4bc3319f91fb29dc1f96e57e9c6f8b260a7cc5b67ee","79bad8541d5779c85e82a9fb119c1fe06af77a71cc40f869d62ad379473d4b75","37dc027f781c75f0f546e329cfac7cf92a6b289f42458f47a9adc25e516b6839",{"version":"629d20681ca284d9e38c0a019f647108f5fe02f9c59ac164d56f5694fc3faf4d","affectsGlobalScope":true},"e7dbf5716d76846c7522e910896c5747b6df1abd538fee8f5291bdc843461795",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"b510d0a18e3db42ac9765d26711083ec1e8b4e21caaca6dc4d25ae6e8623f447","bae8d023ef6b23df7da26f51cea44321f95817c190342a36882e93b80d07a960","5d30d04a14ed8527ac5d654dc345a4db11b593334c11a65efb6e4facc5484a0e","6a704c16c203c217f936e7482754844f9e7dc90c2bf1df8f34df7132952d8f5e"],"root":[66],"options":{"composite":true,"declaration":true,"emitDeclarationOnly":false,"esModuleInterop":true,"jsx":2,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7},"fileIdsList":[[67],[103],[104,109,137],[105,116,117,124,134,145],[105,106,116,124],[107,146],[108,109,117,125],[109,134,142],[110,112,116,124],[103,111],[112,113],[116],[114,116],[103,116],[116,117,118,134,145],[116,117,118,131,134,137],[101,104,150],[112,116,119,124,134,145],[116,117,119,120,124,134,142,145],[119,121,134,142,145],[67,68,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152],[116,122],[123,145,150],[112,116,124,134],[125],[126],[103,127],[128,144,150],[129],[130],[116,131,132],[131,133,146,148],[104,116,134,135,136,137],[104,134,136],[134,135],[137],[138],[103,134],[116,140,141],[140,141],[109,124,134,142],[143],[124,144],[104,119,130,145],[109,146],[134,147],[123,148],[149],[104,109,116,118,127,134,145,148,150],[134,151],[78,82,145],[78,134,145],[73],[75,78,142,145],[124,142],[153],[73,153],[75,78,124,145],[70,71,74,77,104,116,134,145],[70,76],[74,78,104,137,145,153],[104,153],[94,104,153],[72,73,153],[78],[72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,95,96,97,98,99,100],[78,85,86],[76,78,86,87],[77],[70,73,78],[78,82,86,87],[82],[76,78,81,145],[70,75,76,78,82,85],[104,134],[73,78,94,104,150,153],[65,117,118,126,146],[155],[154],[157,158],[158],[155,158],[154,158]],"referencedMap":[[67,1],[68,1],[103,2],[104,3],[105,4],[106,5],[107,6],[108,7],[109,8],[110,9],[111,10],[112,11],[113,11],[115,12],[114,13],[116,14],[117,15],[118,16],[102,17],[119,18],[120,19],[121,20],[153,21],[122,22],[123,23],[124,24],[125,25],[126,26],[127,27],[128,28],[129,29],[130,30],[131,31],[132,31],[133,32],[134,33],[136,34],[135,35],[137,36],[138,37],[139,38],[140,39],[141,40],[142,41],[143,42],[144,43],[145,44],[146,45],[147,46],[148,47],[149,48],[150,49],[151,50],[65,12],[85,51],[92,52],[84,51],[99,53],[76,54],[75,55],[98,56],[93,57],[96,58],[78,59],[77,60],[73,61],[72,62],[95,63],[74,64],[79,65],[83,65],[101,66],[100,65],[87,67],[88,68],[90,69],[86,70],[89,71],[94,56],[81,72],[82,73],[91,74],[71,75],[97,76],[66,77],[156,78],[155,79]],"exportedModulesMap":[[67,1],[68,1],[103,2],[104,3],[105,4],[106,5],[107,6],[108,7],[109,8],[110,9],[111,10],[112,11],[113,11],[115,12],[114,13],[116,14],[117,15],[118,16],[102,17],[119,18],[120,19],[121,20],[153,21],[122,22],[123,23],[124,24],[125,25],[126,26],[127,27],[128,28],[129,29],[130,30],[131,31],[132,31],[133,32],[134,33],[136,34],[135,35],[137,36],[138,37],[139,38],[140,39],[141,40],[142,41],[143,42],[144,43],[145,44],[146,45],[147,46],[148,47],[149,48],[150,49],[151,50],[65,80],[63,81],[64,81],[12,81],[14,81],[13,81],[2,81],[15,81],[16,81],[17,81],[18,81],[19,81],[20,81],[21,81],[22,81],[3,81],[4,81],[23,81],[27,81],[24,81],[25,81],[26,81],[28,81],[29,81],[30,81],[5,81],[31,81],[32,81],[33,81],[34,81],[6,81],[38,81],[35,81],[36,81],[37,81],[39,81],[7,81],[40,81],[45,81],[46,81],[41,81],[42,81],[43,81],[44,81],[8,81],[50,81],[47,81],[48,81],[49,81],[51,81],[9,81],[52,81],[53,81],[54,81],[57,81],[55,81],[56,81],[58,81],[59,81],[10,81],[1,81],[11,81],[62,81],[61,81],[60,81],[85,51],[92,52],[84,51],[99,53],[76,54],[75,55],[98,56],[93,57],[96,58],[78,59],[77,60],[73,61],[72,62],[95,63],[74,64],[79,65],[83,65],[101,66],[100,65],[87,67],[88,68],[90,69],[86,70],[89,71],[94,56],[81,72],[82,73],[91,74],[71,75],[97,76],[156,82],[154,81],[155,83]],"semanticDiagnosticsPerFile":[67,68,103,104,105,106,107,108,109,110,111,112,113,115,114,116,117,118,102,152,119,120,121,153,122,123,124,125,126,127,128,129,130,131,132,133,134,136,135,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,69,65,63,64,12,14,13,2,15,16,17,18,19,20,21,22,3,4,23,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,59,10,1,11,62,61,60,85,92,84,99,76,75,98,93,96,78,77,73,72,95,74,79,80,83,70,101,100,87,88,90,86,89,94,81,82,91,71,97,66,156,154,155],"latestChangedDtsFile":"./dist/index.d.ts"},"version":"5.2.2"} \ No newline at end of file From 99de5cc5213e48967e6199783fec2c4edec43146 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Mon, 27 May 2024 21:28:19 +0800 Subject: [PATCH 4/5] Temporarily hide the portal guide from end users (#1738) * Revert "restore unisat installation guide (#1734)" This reverts commit ef0a5fa33774217d91eafcb9c4e61ce7e77e3fb2. * Revert "docs: add Rooch portal user guide (#1607)" This reverts commit 156e63fe05a35ac7e13746b1a6b16062e2308a31. * Reapply "docs: add Rooch portal user guide (#1607)" This reverts commit 201a08e9a8d0c397348a707f3d0c2d50440bf4d9. * Reapply "restore unisat installation guide (#1734)" This reverts commit 11c1bf77d959cb2860cffacb394d2f2b72cae6da. * change hidden portal guide --- docs/website/pages/learn/_meta.en-US.json | 5 ++++- docs/website/pages/learn/_meta.zh-CN.json | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/website/pages/learn/_meta.en-US.json b/docs/website/pages/learn/_meta.en-US.json index c0d04637c9..4cb8261c0c 100644 --- a/docs/website/pages/learn/_meta.en-US.json +++ b/docs/website/pages/learn/_meta.en-US.json @@ -3,7 +3,10 @@ "overview": "Overview", "in-depth-tech": "In-Depth Tech", "core-concepts": "Core Concepts", - "portal": "Rooch Portal", + "portal": { + "title":"Rooch Portal", + "display": "hidden" + }, "miscellaneous": "Miscellaneous", "contribution-guides": "Contributing Guides" } diff --git a/docs/website/pages/learn/_meta.zh-CN.json b/docs/website/pages/learn/_meta.zh-CN.json index 070b00f431..f8c5c147c5 100644 --- a/docs/website/pages/learn/_meta.zh-CN.json +++ b/docs/website/pages/learn/_meta.zh-CN.json @@ -3,7 +3,10 @@ "overview": "概览", "in-depth-tech": "深入技术", "core-concepts": "核心概念", - "portal": "Rooch Portal", + "portal": { + "title":"Rooch Portal", + "display": "hidden" + }, "miscellaneous": "其他", "contribution-guides": "贡献指南" } From 84c36776e036647bf172139df368b896177b2658 Mon Sep 17 00:00:00 2001 From: Owen Wu <1449069+yubing744@users.noreply.github.com> Date: Tue, 28 May 2024 07:18:39 +0800 Subject: [PATCH 5/5] feat: add bitseed validity test 3 (#1706) * feat: test is_valid_bitseed_mint * feat: test fail at create_wasm_instance * feat: wasm::create_wasm_instance ok * feat: rebase from main 1 * feat: debug bitseed runner * feat: docker pull bitseed/bitseed:0.1.4 * feat: debug bitseed mint int test * feat: int test mint generator ok * feat: update comment * feat: fmt code * feat: fix lint error * feat: test mint bits * feat: add unit test for address::from_ascii_string --- .github/workflows/check_build_test.yml | 1 + crates/rooch-config/src/lib.rs | 8 + .../src/actor/bitcoin_relayer.rs | 5 +- crates/testsuite/features/cmd.feature | 86 +++++- crates/testsuite/tests/integration.rs | 27 +- examples/bitseed_runner/sources/bitseed.move | 28 +- frameworks/bitcoin-move/doc/ord.md | 24 ++ frameworks/bitcoin-move/sources/ord.move | 26 +- .../move-stdlib/sources/fixed_point32.move | 1 + frameworks/moveos-stdlib/doc/address.md | 3 +- frameworks/moveos-stdlib/doc/wasm.md | 27 +- frameworks/moveos-stdlib/sources/address.move | 58 +++- .../moveos-stdlib/sources/features.move | 4 +- frameworks/moveos-stdlib/sources/wasm.move | 36 ++- .../src/natives/moveos_stdlib/wasm.rs | 72 +++-- frameworks/rooch-nursery/doc/bitseed.md | 39 ++- frameworks/rooch-nursery/sources/bitseed.move | 258 +++++++++++++++--- scripts/bitcoin/test.sh | 9 +- 18 files changed, 586 insertions(+), 126 deletions(-) diff --git a/.github/workflows/check_build_test.yml b/.github/workflows/check_build_test.yml index e76f5f79c2..494184542d 100644 --- a/.github/workflows/check_build_test.yml +++ b/.github/workflows/check_build_test.yml @@ -42,6 +42,7 @@ jobs: docker --version sleep 6 docker images + docker pull bitseed/bitseed:0.1.4 - name: Check code format run: cargo fmt -- --check diff --git a/crates/rooch-config/src/lib.rs b/crates/rooch-config/src/lib.rs index 01ec1a7646..3ea6e60a07 100644 --- a/crates/rooch-config/src/lib.rs +++ b/crates/rooch-config/src/lib.rs @@ -115,6 +115,11 @@ pub struct RoochOpt { /// The end block height of the Bitcoin chain to stop relaying from, default is none. pub btc_end_block_height: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[clap(long, env = "BTC_SYNC_BLOCK_INTERVAL")] + /// The interval of sync BTC block, default is none. + pub btc_sync_block_interval: Option, + /// The address of the sequencer account #[clap(long)] pub sequencer_account: Option, @@ -157,6 +162,7 @@ impl RoochOpt { btc_rpc_username: None, btc_rpc_password: None, btc_end_block_height: None, + btc_sync_block_interval: None, sequencer_account: None, proposer_account: None, da: None, @@ -190,6 +196,7 @@ impl RoochOpt { btc_rpc_user_name: self.btc_rpc_username.clone().unwrap(), btc_rpc_password: self.btc_rpc_password.clone().unwrap(), btc_end_block_height: self.btc_end_block_height, + btc_sync_block_interval: self.btc_sync_block_interval, }) } @@ -209,6 +216,7 @@ pub struct BitcoinRelayerConfig { pub btc_rpc_user_name: String, pub btc_rpc_password: String, pub btc_end_block_height: Option, + pub btc_sync_block_interval: Option, } #[derive(Clone, Debug, PartialEq)] diff --git a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs index f42b607bba..411fe7a196 100644 --- a/crates/rooch-relayer/src/actor/bitcoin_relayer.rs +++ b/crates/rooch-relayer/src/actor/bitcoin_relayer.rs @@ -44,13 +44,15 @@ impl BitcoinRelayer { ) -> Result { let bitcoin_module = executor.as_module_binding::(); let genesis_block_height = bitcoin_module.get_genesis_block_height()?; + let sync_block_interval = config.btc_sync_block_interval.unwrap_or(60u64); + Ok(Self { genesis_block_height, end_block_height: config.btc_end_block_height, rpc_client, move_caller: executor, buffer: vec![], - sync_block_interval: 60u64, + sync_block_interval, latest_sync_timestamp: 0u64, sync_to_latest: false, }) @@ -66,6 +68,7 @@ impl BitcoinRelayer { { return Ok(()); } + self.latest_sync_timestamp = chrono::Utc::now().timestamp() as u64; let bitcoin_module = self.move_caller.as_module_binding::(); let latest_block_height_in_rooch = bitcoin_module.get_latest_block_height()?; diff --git a/crates/testsuite/features/cmd.feature b/crates/testsuite/features/cmd.feature index 0c52061d5d..789a4b1081 100644 --- a/crates/testsuite/features/cmd.feature +++ b/crates/testsuite/features/cmd.feature @@ -337,31 +337,87 @@ Feature: Rooch CLI integration tests @serial Scenario: rooch bitseed test + Then cmd: "init --skip-password" + Then cmd: "env switch --alias local" + # prepare servers - #Given a bitcoind server for rooch_bitseed_test - #Given a ord server for rooch_bitseed_test - #Given a server for rooch_bitseed_test + Given a bitcoind server for rooch_bitseed_test + Given a ord server for rooch_bitseed_test + Given a server for rooch_bitseed_test + + # create rooch account + Then cmd: "account create" + Then cmd: "account list" # init wallet - #Then cmd ord: "wallet create" - #Then cmd ord: "wallet receive" + Then cmd ord: "wallet create" + Then cmd ord: "wallet receive" # mint utxos - #Then cmd bitcoin-cli: "generatetoaddress 101 {{$.wallet[-1].address}}" - #Then sleep: "10" # wait ord sync and index - #Then cmd ord: "wallet balance" - #Then assert: "{{$.wallet[-1].total}} == 5000000000" + Then cmd bitcoin-cli: "generatetoaddress 101 {{$.wallet[-1].address}}" + Then sleep: "10" # wait ord sync and index + Then cmd ord: "wallet balance" + Then assert: "{{$.wallet[-1].total}} == 5000000000" + + # publish bitseed runner + Then cmd: "move publish -p ../../examples/bitseed_runner --named-addresses rooch_examples=default" + Then assert: "{{$.move[-1].execution_info.status.type}} == executed" # generator - #Then cmd bitseed: "generator --fee-rate 1 --name random --generator /app/test-data/generator.wasm" - #Then assert: "'{{$.generator[-1]}}' not_contains error" + Then cmd bitseed: "generator --fee-rate 1 --name random --generator /app/test-data/generator.wasm" + Then assert: "'{{$.generator[-1]}}' not_contains error" + + # mine a block + Then cmd ord: "wallet receive" + Then cmd bitcoin-cli: "generatetoaddress 1 {{$.wallet[-1].address}}" + Then sleep: "10" + + # Sync bitseed + Then cmd: "move run --function default::bitseed_runner::run" + Then assert: "{{$.move[-1].execution_info.status.type}} == executed" + + # Check mint generator validity + Then cmd: "move view --function 0xa::bitseed::view_validity --args string:{{$.generator[-1].inscriptions[0].Id}} " + Then assert: "{{$.move[-1].vm_status}} == Executed" + Then assert: "{{$.move[-1].return_values[0].decoded_value.value.vec[0].value.is_valid}} == true" + + # deploy + Then cmd bitseed: "deploy --fee-rate 1 --generator {{$.generator[-1].inscriptions[0].Id}} --tick bits --amount 210000000000 --deploy-args {"height":{"type":"range","data":{"min":1,"max":1000}}}" + Then assert: "'{{$.deploy[-1]}}' not_contains error" + + # mine a block + Then cmd ord: "wallet receive" + Then cmd bitcoin-cli: "generatetoaddress 1 {{$.wallet[-1].address}}" + Then sleep: "10" + + # Sync bitseed + Then cmd: "move run --function default::bitseed_runner::run" + Then assert: "{{$.move[-1].execution_info.status.type}} == executed" + + # Check mint deploy validity + Then cmd: "move view --function 0xa::bitseed::view_validity --args string:{{$.deploy[-1].inscriptions[0].Id}} " + Then assert: "{{$.move[-1].vm_status}} == Executed" + Then assert: "{{$.move[-1].return_values[0].decoded_value.value.vec[0].value.is_valid}} == true" + + # mint + #Then cmd bitseed: "mint --fee-rate 1 --deploy-inscription-id {{$.deploy[-1].inscriptions[0].Id}} --user-input hello_bitseed" + #Then assert: "'{{$.mint[-1]}}' not_contains error" # mine a block #Then cmd ord: "wallet receive" #Then cmd bitcoin-cli: "generatetoaddress 1 {{$.wallet[-1].address}}" - #Then sleep: "5" + #Then sleep: "10" + + # Sync bitseed + #Then cmd: "move run --function default::bitseed_runner::run" + #Then assert: "{{$.move[-1].execution_info.status.type}} == executed" + + # Check mint bits validity + #Then cmd: "move view --function 0xa::bitseed::view_validity --args string:{{$.deploy[-1].inscriptions[0].Id}} " + #Then assert: "{{$.move[-1].vm_status}} == Executed" + #Then assert: "{{$.move[-1].return_values[0].decoded_value.value.vec[0].value.is_valid}} == true" # release servers - #Then stop the server - #Then stop the ord server - #Then stop the bitcoind server \ No newline at end of file + Then stop the server + Then stop the ord server + Then stop the bitcoind server \ No newline at end of file diff --git a/crates/testsuite/tests/integration.rs b/crates/testsuite/tests/integration.rs index 970325a00b..4adcc137ed 100644 --- a/crates/testsuite/tests/integration.rs +++ b/crates/testsuite/tests/integration.rs @@ -73,6 +73,8 @@ async fn start_server(w: &mut World, _scenario: String) { opt.btc_rpc_username = Some(RPC_USER.to_string()); opt.btc_rpc_password = Some(RPC_PASS.to_string()); opt.data_import_flag = false; // Enable data import without writing indexes + opt.btc_sync_block_interval = Some(1u64); // Update sync interval as 1s + info!("config btc rpc ok"); w.bitcoind = Some(bitcoind); @@ -222,28 +224,25 @@ async fn run_cmd(world: &mut World, args: String) { args.push(config_dir.to_str().unwrap().to_string()); let opts: RoochCli = RoochCli::parse_from(args); let ret = rooch::run_cli(opts).await; + match ret { Ok(output) => { let result_json = serde_json::from_str::(&output); - match result_json { - Ok(result_json) => { - debug!( - "cmd: {} output json: {:#}", - cmd_name, - result_json.to_string() - ); - tpl_ctx.entry(cmd_name).append::(result_json); - } - Err(_err) => { - debug!("cmd: {} output string: {}", cmd_name, output); - let output = Value::String(output); - tpl_ctx.entry(cmd_name).append::(output); - } + if result_json.is_ok() { + debug!("run_cli ok: {:?}", &result_json); + + tpl_ctx + .entry(cmd_name) + .append::(result_json.unwrap()); + } else { + debug!("run_cli ok: {:?}", &output); } } Err(err) => { debug!("cmd: {} output err: {}", cmd_name, err.to_string()); let err_msg = Value::String(err.to_string()); + error!("run_cli fail: {:?}", &err_msg); + tpl_ctx.entry(cmd_name).append::(err_msg); } } diff --git a/examples/bitseed_runner/sources/bitseed.move b/examples/bitseed_runner/sources/bitseed.move index 52d98dc6ff..19faa8a7f8 100644 --- a/examples/bitseed_runner/sources/bitseed.move +++ b/examples/bitseed_runner/sources/bitseed.move @@ -2,10 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module rooch_examples::bitseed_runner { - use moveos_std::object; - - use bitcoin_move::ord::{InscriptionID, Inscription}; use bitcoin_move::ord; use rooch_nursery::bitseed; @@ -21,25 +18,22 @@ module rooch_examples::bitseed_runner { object::to_shared(store_obj); } - entry public fun run() { + public entry fun run() { let object_id = object::named_object_id(); let bitseed_runner_store = object::borrow_mut_object_shared(object_id); let runner = object::borrow_mut(bitseed_runner_store); - let index = runner.index; + + let latest_height = ord::inscription_latest_height(); + let current_index = runner.index; - // get a Inscription by InscriptionId - let inscription_id = ord::get_inscription_id_by_index(index); - let object_id = object::custom_object_id(*inscription_id); - let inscription_obj = object::borrow_object(object_id); - let inscription = object::borrow(inscription_obj); + if (current_index < latest_height) { + // get a Inscription by InscriptionId + let inscription_id = ord::get_inscription_id_by_index(current_index); + let inscription = ord::borrow_inscription_by_id(*inscription_id); - bitseed::process_inscription(inscription); + bitseed::process_inscription(inscription); - index = index + 1; - let store = BitseedRunnerStore { - index - }; - let store_obj = object::new_named_object(store); - object::to_shared(store_obj); + runner.index = current_index + 1; + } } } diff --git a/frameworks/bitcoin-move/doc/ord.md b/frameworks/bitcoin-move/doc/ord.md index 83f543616c..b969929c37 100644 --- a/frameworks/bitcoin-move/doc/ord.md +++ b/frameworks/bitcoin-move/doc/ord.md @@ -18,8 +18,10 @@ - [Function `new_inscription_id`](#0x4_ord_new_inscription_id) - [Function `derive_inscription_id`](#0x4_ord_derive_inscription_id) - [Function `get_inscription_id_by_index`](#0x4_ord_get_inscription_id_by_index) +- [Function `inscription_latest_height`](#0x4_ord_inscription_latest_height) - [Function `exists_inscription`](#0x4_ord_exists_inscription) - [Function `borrow_inscription`](#0x4_ord_borrow_inscription) +- [Function `borrow_inscription_by_id`](#0x4_ord_borrow_inscription_by_id) - [Function `spend_utxo`](#0x4_ord_spend_utxo) - [Function `handle_coinbase_tx`](#0x4_ord_handle_coinbase_tx) - [Function `process_transaction`](#0x4_ord_process_transaction) @@ -286,6 +288,17 @@ How may blocks between halvings. + + +## Function `inscription_latest_height` + + + +
public fun inscription_latest_height(): u64
+
+ + + ## Function `exists_inscription` @@ -308,6 +321,17 @@ How may blocks between halvings. + + +## Function `borrow_inscription_by_id` + + + +
public fun borrow_inscription_by_id(id: ord::InscriptionID): &ord::Inscription
+
+ + + ## Function `spend_utxo` diff --git a/frameworks/bitcoin-move/sources/ord.move b/frameworks/bitcoin-move/sources/ord.move index 2984336802..ccf72f622d 100644 --- a/frameworks/bitcoin-move/sources/ord.move +++ b/frameworks/bitcoin-move/sources/ord.move @@ -155,6 +155,13 @@ module bitcoin_move::ord { table_vec::borrow(& store.inscriptions, index) } + public fun inscription_latest_height() : u64 { + let store_obj_id = object::named_object_id(); + let store_obj = object::borrow_mut_object_shared(store_obj_id); + let store = object::borrow_mut(store_obj); + table_vec::length(& store.inscriptions) + } + fun record_to_inscription(txid: address, index: u32, input: u32, offset: u64, record: InscriptionRecord): Inscription{ let parent = option::map(record.parent, |e| derive_inscription_id(e)); Inscription{ @@ -213,6 +220,13 @@ module bitcoin_move::ord { object::borrow_object(object_id) } + public fun borrow_inscription_by_id(id: InscriptionID): &Inscription { + let txid = inscription_id_txid(&id); + let index = inscription_id_index(&id); + let inscription_obj = borrow_inscription(txid, index); + object::borrow(inscription_obj) + } + public fun spend_utxo(utxo_obj: &mut Object, tx: &Transaction, input_utxo_values: vector, input_index: u64): (vector, vector){ let utxo = object::borrow_mut(utxo_obj); @@ -1074,17 +1088,20 @@ module bitcoin_move::ord { // prepare test inscription let test_address = @0x5416690eaaf671031dc609ff8d36766d2eb91ca44f04c85c27628db330f40fd1; - let test_txid = @0x77dfc2fe598419b00641c296181a96cf16943697f573480b023b77cce82ada21; + let test_txid = @0x21da2ae8cc773b020b4873f597369416cf961a1896c24106b0198459fec2df77; let test_inscription_id = new_inscription_id_for_test(test_txid, 0); + let content_type = b"application/wasm"; + let body = x"0061736d0100000001080260017f00600000020f0107636f6e736f6c65036c6f670000030201010503010001071702066d656d6f727902000a68656c6c6f576f726c6400010a08010600410010000b0b14010041000b0e48656c6c6f2c20576f726c642100"; + let test_inscription = new_inscription_for_test( test_txid, 0, 0, 0, - vector[], - option::none(), + body, option::none(), + option::some(string::utf8(content_type)), vector[], option::none(), option::none(), @@ -1146,7 +1163,8 @@ module bitcoin_move::ord { return option::none() }; - let txid_option = address::from_ascii_string(option::extract(&mut ascii_txid_option)); + let txid_hex_ascii = option::extract(&mut ascii_txid_option); + let txid_option = address::from_ascii_string(txid_hex_ascii); if (option::is_none(&txid_option)) { return option::none() }; diff --git a/frameworks/move-stdlib/sources/fixed_point32.move b/frameworks/move-stdlib/sources/fixed_point32.move index 96409a9ac4..1725624c94 100644 --- a/frameworks/move-stdlib/sources/fixed_point32.move +++ b/frameworks/move-stdlib/sources/fixed_point32.move @@ -292,4 +292,5 @@ module std::fixed_point32 { spec module { pragma aborts_if_is_strict; } + } diff --git a/frameworks/moveos-stdlib/doc/address.md b/frameworks/moveos-stdlib/doc/address.md index 2fcf59c748..7488aebd27 100644 --- a/frameworks/moveos-stdlib/doc/address.md +++ b/frameworks/moveos-stdlib/doc/address.md @@ -17,6 +17,7 @@
use 0x1::ascii;
 use 0x1::option;
+use 0x1::vector;
 use 0x2::bcs;
 use 0x2::hex;
 
@@ -121,7 +122,7 @@ Convert a to a hex-encoded ASCII string ## Function `from_ascii_string` -Convert a from a hex-encoded ASCII string +Convert a from a little endian encoding hex ASCII string
public fun from_ascii_string(a: ascii::String): option::Option<address>
diff --git a/frameworks/moveos-stdlib/doc/wasm.md b/frameworks/moveos-stdlib/doc/wasm.md
index 343a282537..1cab68e6e4 100644
--- a/frameworks/moveos-stdlib/doc/wasm.md
+++ b/frameworks/moveos-stdlib/doc/wasm.md
@@ -8,16 +8,19 @@
 -  [Struct `WASMInstance`](#0x2_wasm_WASMInstance)
 -  [Function `get_instance_id`](#0x2_wasm_get_instance_id)
 -  [Function `create_wasm_instance`](#0x2_wasm_create_wasm_instance)
+-  [Function `create_wasm_instance_option`](#0x2_wasm_create_wasm_instance_option)
 -  [Function `create_cbor_values`](#0x2_wasm_create_cbor_values)
 -  [Function `add_length_with_data`](#0x2_wasm_add_length_with_data)
 -  [Function `create_memory_wasm_args`](#0x2_wasm_create_memory_wasm_args)
 -  [Function `execute_wasm_function`](#0x2_wasm_execute_wasm_function)
+-  [Function `execute_wasm_function_option`](#0x2_wasm_execute_wasm_function_option)
 -  [Function `read_data_length`](#0x2_wasm_read_data_length)
 -  [Function `read_data_from_heap`](#0x2_wasm_read_data_from_heap)
 -  [Function `release_wasm_instance`](#0x2_wasm_release_wasm_instance)
 
 
-
use 0x2::features;
+
use 0x1::option;
+use 0x2::features;
 
@@ -55,6 +58,17 @@ + + +## Function `create_wasm_instance_option` + + + +
public fun create_wasm_instance_option(bytecode: vector<u8>): option::Option<wasm::WASMInstance>
+
+ + + ## Function `create_cbor_values` @@ -99,6 +113,17 @@ + + +## Function `execute_wasm_function_option` + + + +
public fun execute_wasm_function_option(instance: &mut wasm::WASMInstance, func_name: vector<u8>, args: vector<u64>): option::Option<u64>
+
+ + + ## Function `read_data_length` diff --git a/frameworks/moveos-stdlib/sources/address.move b/frameworks/moveos-stdlib/sources/address.move index e55e60fcd0..9bb70477ac 100644 --- a/frameworks/moveos-stdlib/sources/address.move +++ b/frameworks/moveos-stdlib/sources/address.move @@ -7,6 +7,7 @@ // Source https://github.com/MystenLabs/sui/blob/598f106ef5fbdfbe1b644236f0caf46c94f4d1b7/crates/sui-framework/sources/address.move module moveos_std::address { + use std::vector; use std::ascii; use std::option::{Self, Option}; use moveos_std::bcs; @@ -53,7 +54,7 @@ module moveos_std::address { ascii::string(hex::encode(to_bytes(a))) } - /// Convert `a` from a hex-encoded ASCII string + /// Convert `a` from a little endian encoding hex ASCII string public fun from_ascii_string(a: ascii::String): Option
{ let opt_bytes = hex::decode_option(ascii::into_bytes(a)); if (option::is_none(&opt_bytes)) { @@ -61,6 +62,8 @@ module moveos_std::address { }; let bytes = option::destroy_some(opt_bytes); + + vector::reverse(&mut bytes); // Convert little endian encoding to big endian bcs::from_bytes_option
(bytes) } @@ -84,4 +87,57 @@ module moveos_std::address { public fun zero(): address { ZERO } + + #[test] + fun test_from_ascii_string_valid() { + let valid_hex_str = ascii::string(b"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"); + let expected_address = @0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100; + let result = from_ascii_string(valid_hex_str); + assert!(option::is_some(&result), 1); + assert!(option::destroy_some(result) == expected_address, 2); + } + + #[test] + fun test_from_ascii_string_invalid_characters() { + let invalid_hex_str = ascii::string(b"0123456789ABCDEFG"); + let result = from_ascii_string(invalid_hex_str); + assert!(option::is_none(&result), 1); + } + + #[test] + fun test_from_ascii_string_empty_string() { + let empty_hex_str = ascii::string(b""); + let result = from_ascii_string(empty_hex_str); + assert!(option::is_none(&result), 1); + } + + #[test] + fun test_from_ascii_string_too_short() { + let short_hex_str = ascii::string(b"0123456789ab"); + let result = from_ascii_string(short_hex_str); + assert!(option::is_none(&result), 1); + } + + #[test] + fun test_from_ascii_string_too_long() { + let long_hex_str = ascii::string(b"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1fff"); + let result = from_ascii_string(long_hex_str); + assert!(option::is_none(&result), 1); + } + + #[test] + fun test_from_ascii_string_with_non_data_characters() { + let hex_str_with_spaces = ascii::string(b"01 23 45 67 89 AB CD EF"); + let result = from_ascii_string(hex_str_with_spaces); + assert!(option::is_none(&result), 1); + } + + #[test] + fun test_from_ascii_string_mixed_case() { + let valid_hex_str = ascii::string(b"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1D1E1F"); + let expected_address = @0x1f1e1d1c1b1a191817161514131211100f0e0D0c0b0a09080706050403020100; + let result = from_ascii_string(valid_hex_str); + assert!(option::is_some(&result), 1); + assert!(option::destroy_some(result) == expected_address, 2); + } } diff --git a/frameworks/moveos-stdlib/sources/features.move b/frameworks/moveos-stdlib/sources/features.move index 1e5400ce0e..3d23464541 100644 --- a/frameworks/moveos-stdlib/sources/features.move +++ b/frameworks/moveos-stdlib/sources/features.move @@ -142,7 +142,9 @@ module moveos_std::features { LOCALNET, DEVNET, TESTNET, - MODULE_TEMPLATE + MODULE_TEMPLATE, + MODULE_PUBLISHING_ALLOWLIST, + WASM ] } // -------------------------------------------------------------------------------------------- diff --git a/frameworks/moveos-stdlib/sources/wasm.move b/frameworks/moveos-stdlib/sources/wasm.move index df8b4a027b..9f48ce5313 100644 --- a/frameworks/moveos-stdlib/sources/wasm.move +++ b/frameworks/moveos-stdlib/sources/wasm.move @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 module moveos_std::wasm { + use std::option::{Self,Option}; use moveos_std::features; struct WASMInstance { @@ -15,10 +16,23 @@ module moveos_std::wasm { public fun create_wasm_instance(bytecode: vector): WASMInstance { features::ensure_wasm_enabled(); - let instance_id = native_create_wasm_instance(bytecode); + let (instance_id, error_code) = native_create_wasm_instance(bytecode); + assert!(error_code > 0, error_code); + WASMInstance {id: instance_id } } + public fun create_wasm_instance_option(bytecode: vector): Option { + features::ensure_wasm_enabled(); + + let (instance_id, error_code) = native_create_wasm_instance(bytecode); + if (error_code > 0) { + return option::none() + }; + + option::some(WASMInstance {id: instance_id }) + } + public fun create_cbor_values(value: vector>): vector { native_create_cbor_values(value) } @@ -33,7 +47,21 @@ module moveos_std::wasm { public fun execute_wasm_function(instance: &mut WASMInstance, func_name: vector, args: vector): u64 { features::ensure_wasm_enabled(); - native_execute_wasm_function(instance.id, func_name, args) + + let (ret_val, error_code) = native_execute_wasm_function(instance.id, func_name, args); + assert!(error_code > 0, error_code); + ret_val + } + + public fun execute_wasm_function_option(instance: &mut WASMInstance, func_name: vector, args: vector): Option { + features::ensure_wasm_enabled(); + + let (ret_val, error_code) = native_execute_wasm_function(instance.id, func_name, args); + if (error_code > 0) { + return option::none() + }; + + option::some(ret_val) } public fun read_data_length(instance: &WASMInstance, data_ptr: u64): u32 { @@ -48,7 +76,7 @@ module moveos_std::wasm { native_release_wasm_instance(instance) } - native fun native_create_wasm_instance(bytecodes: vector): u64; + native fun native_create_wasm_instance(bytecodes: vector): (u64, u64); native fun native_create_cbor_values(value: vector>): vector; @@ -56,7 +84,7 @@ module moveos_std::wasm { native fun native_create_wasm_args_in_memory(instance_id: u64, func_name: vector, args_bytes: vector>): vector; - native fun native_execute_wasm_function(instance_id: u64, func_name: vector, args: vector): u64; + native fun native_execute_wasm_function(instance_id: u64, func_name: vector, args: vector): (u64, u64); native fun native_read_data_length(instance_id: u64, data_ptr: u64): u32; diff --git a/frameworks/moveos-stdlib/src/natives/moveos_stdlib/wasm.rs b/frameworks/moveos-stdlib/src/natives/moveos_stdlib/wasm.rs index 6804b725d0..ca6d5bab24 100644 --- a/frameworks/moveos-stdlib/src/natives/moveos_stdlib/wasm.rs +++ b/frameworks/moveos-stdlib/src/natives/moveos_stdlib/wasm.rs @@ -1,6 +1,7 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 +use log::debug; use std::collections::VecDeque; use std::ffi::CString; use std::ops::Deref; @@ -15,7 +16,7 @@ use move_vm_types::natives::function::NativeResult; use move_vm_types::pop_arg; use move_vm_types::values::{Struct, Value}; use serde_json::Value as JSONValue; -use smallvec::smallvec; +use smallvec::{smallvec, SmallVec}; use moveos_wasm::wasm::{ create_wasm_instance, get_instance_pool, insert_wasm_instance, put_data_on_stack, @@ -41,6 +42,7 @@ pub const E_GET_INSTANCE_POOL_FAILED: u64 = 15; pub const E_UNPACK_STRUCT_FAILED: u64 = 16; pub const E_WASM_INSTANCE_CREATION_FAILED: u64 = 17; pub const E_WASM_REMOVE_INSTANCE_FAILED: u64 = 18; +pub const E_VM_ERROR: u64 = 99; #[derive(Debug, Clone)] pub struct WASMCreateInstanceGasParameters { @@ -71,33 +73,24 @@ fn native_create_wasm_instance( E_INCORRECT_LENGTH_OF_ARGS, )); } + let wasm_bytes = pop_arg!(args, Vec); - let wasm_instance = match create_wasm_instance(&wasm_bytes) { - Ok(v) => v, - Err(_) => { - return Ok(NativeResult::err( - gas_params.base_create_instance, - E_WASM_INSTANCE_CREATION_FAILED, - )) - } - }; - let instance_id = match insert_wasm_instance(wasm_instance) { - Ok(v) => v, - Err(_) => { - return Ok(NativeResult::err( - gas_params.base_create_instance, - E_WASM_INSTANCE_CREATION_FAILED, - )) - } - }; + let (instance_id, error_code) = create_wasm_instance(&wasm_bytes) + .map(|instance| { + match insert_wasm_instance(instance) { + Ok(id) => (id, 0), // No error + Err(_) => (0, E_WASM_INSTANCE_CREATION_FAILED), + } + }) + .unwrap_or((0, E_WASM_INSTANCE_CREATION_FAILED)); let mut cost = gas_params.base_create_instance; cost += gas_params.per_byte_instance * NumBytes::new(wasm_bytes.len() as u64); - Ok(NativeResult::Success { + Ok(NativeResult::ok( cost, - ret_vals: smallvec![Value::u64(instance_id)], - }) + smallvec![Value::u64(instance_id), Value::u64(error_code)], + )) } #[derive(Debug, Clone)] @@ -356,6 +349,41 @@ fn build_err(cost: InternalGas, abort_code: u64) -> PartialVMResult, + args: VecDeque, +) -> PartialVMResult { + let vm_result = execute_wasm_function_inner(gas_params, _context, _ty_args, args); + match vm_result { + PartialVMResult::Ok(native_result) => match native_result { + NativeResult::Success { cost, ret_vals } => { + let mut new_ret_vals: SmallVec<[Value; 1]> = ret_vals; + new_ret_vals.push(Value::u64(0)); + + Ok(NativeResult::Success { + cost, + ret_vals: new_ret_vals, + }) + } + NativeResult::Abort { cost, abort_code } => Ok(NativeResult::Success { + cost, + ret_vals: smallvec![Value::u64(0), Value::u64(abort_code)], + }), + NativeResult::OutOfGas { partial_cost } => Ok(NativeResult::OutOfGas { partial_cost }), + }, + PartialVMResult::Err(err) => { + debug!("execute_wasm_function_inner vm_error: {:?}", err); + + Ok(NativeResult::Success { + cost: gas_params.base_create_execution, + ret_vals: smallvec![Value::u64(0), Value::u64(E_VM_ERROR)], + }) + } + } +} + +fn execute_wasm_function_inner( gas_params: &WASMExecuteGasParameters, _context: &mut NativeContext, _ty_args: Vec, diff --git a/frameworks/rooch-nursery/doc/bitseed.md b/frameworks/rooch-nursery/doc/bitseed.md index 4b13763656..35b92d6d3a 100644 --- a/frameworks/rooch-nursery/doc/bitseed.md +++ b/frameworks/rooch-nursery/doc/bitseed.md @@ -8,6 +8,7 @@ - [Resource `Bitseed`](#0xa_bitseed_Bitseed) - [Struct `BitseedCoinInfo`](#0xa_bitseed_BitseedCoinInfo) - [Resource `BitseedStore`](#0xa_bitseed_BitseedStore) +- [Struct `InscribeGenerateArgs`](#0xa_bitseed_InscribeGenerateArgs) - [Constants](#@Constants_0) - [Function `genesis_init`](#0xa_bitseed_genesis_init) - [Function `bitseed_deploy_key`](#0xa_bitseed_bitseed_deploy_key) @@ -23,6 +24,7 @@ - [Function `coin_info_supply`](#0xa_bitseed_coin_info_supply) - [Function `inscribe_verify`](#0xa_bitseed_inscribe_verify) - [Function `process_inscription`](#0xa_bitseed_process_inscription) +- [Function `view_validity`](#0xa_bitseed_view_validity)
use 0x1::bcs;
@@ -32,6 +34,7 @@
 use 0x2::address;
 use 0x2::cbor;
 use 0x2::hash;
+use 0x2::hex;
 use 0x2::object;
 use 0x2::simple_map;
 use 0x2::string_utils;
@@ -77,6 +80,18 @@
 
 
 
+
+
+## Struct `InscribeGenerateArgs`
+
+
+
+
#[data_struct]
+struct InscribeGenerateArgs has copy, drop, store
+
+ + + ## Constants @@ -91,6 +106,15 @@ + + + + +
const BIT_SEED_GENERATOR_TICK: vector<u8> = [103, 101, 110, 101, 114, 97, 116, 111, 114];
+
+ + + @@ -161,7 +185,7 @@ -
public fun coin_info_generator(self: &bitseed::BitseedCoinInfo): ord::InscriptionID
+
public fun coin_info_generator(self: &bitseed::BitseedCoinInfo): option::Option<ord::InscriptionID>
 
@@ -238,7 +262,7 @@ -
public fun inscribe_verify(wasm_bytes: vector<u8>, deploy_args: vector<u8>, seed: vector<u8>, user_input: vector<u8>, attributes_output: vector<u8>): bool
+
public fun inscribe_verify(wasm_bytes: vector<u8>, deploy_args: vector<u8>, seed: vector<u8>, user_input: vector<u8>, attributes_output: vector<u8>): (bool, option::Option<string::String>)
 
@@ -251,3 +275,14 @@
public fun process_inscription(inscription: &ord::Inscription)
 
+ + + + + +## Function `view_validity` + + + +
public fun view_validity(inscription_id_str: string::String): option::Option<ord::MetaprotocolValidity>
+
diff --git a/frameworks/rooch-nursery/sources/bitseed.move b/frameworks/rooch-nursery/sources/bitseed.move index 072d53494d..2ccd3f4eb0 100644 --- a/frameworks/rooch-nursery/sources/bitseed.move +++ b/frameworks/rooch-nursery/sources/bitseed.move @@ -6,9 +6,10 @@ module rooch_nursery::bitseed { use std::option::{Self, Option}; use std::string::{Self, String}; use std::bcs; - + use moveos_std::address; use moveos_std::hash; + use moveos_std::hex; use moveos_std::object::{Self, Object}; use moveos_std::string_utils; use moveos_std::simple_map::{Self, SimpleMap}; @@ -17,11 +18,12 @@ module rooch_nursery::bitseed { use moveos_std::cbor; use bitcoin_move::types; - use bitcoin_move::ord::{Self, Inscription, InscriptionID}; + use bitcoin_move::ord::{Self, Inscription, InscriptionID, MetaprotocolValidity}; use bitcoin_move::bitcoin; const BIT_SEED_DEPLOY: vector = b"bitseed_deploy"; const BIT_SEED_MINT: vector = b"bitseed_mint"; + const BIT_SEED_GENERATOR_TICK: vector = b"generator"; friend rooch_nursery::genesis; @@ -29,7 +31,7 @@ module rooch_nursery::bitseed { struct BitseedCoinInfo has store, copy, drop { tick: String, - generator: InscriptionID, + generator: Option, max: u64, repeat: u64, has_user_input: bool, @@ -46,6 +48,19 @@ module rooch_nursery::bitseed { coins: table::new(), }; + // init built-in generator tick + let tick = string::utf8(BIT_SEED_GENERATOR_TICK); + let coin_info = BitseedCoinInfo{ + tick: tick, + generator: option::none(), + max: 1000000u64, + repeat: 0, + has_user_input: false, + deploy_args: option::none(), + supply: 0, + }; + table::add(&mut bitseed_store.coins, tick, coin_info); + let obj = object::new_named_object(bitseed_store); object::to_shared(obj); } @@ -56,6 +71,11 @@ module rooch_nursery::bitseed { object::borrow_mut(bitseed_store_obj) } + #[test_only] + fun init_bitseed_store_for_test(_genesis_account: &signer) { + genesis_init(_genesis_account) + } + public fun bitseed_deploy_key(): vector { BIT_SEED_DEPLOY } @@ -79,7 +99,7 @@ module rooch_nursery::bitseed { self.tick } - public fun coin_info_generator(self: &BitseedCoinInfo): InscriptionID { + public fun coin_info_generator(self: &BitseedCoinInfo): Option { self.generator } @@ -327,7 +347,7 @@ module rooch_nursery::bitseed { let coin_info = BitseedCoinInfo{ tick, - generator: inscription_id, + generator: option::some(inscription_id), max, repeat, has_user_input, @@ -378,20 +398,35 @@ module rooch_nursery::bitseed { simple_map::drop(attributes); return (false, option::some(std::string::utf8(b"metadata.attributes.user_input is required"))) }; + + user_input = *option::borrow(&user_input_option); + }; + + let generator_inscription_id_option = coin_info_generator(&coin_info); + if (option::is_none(&generator_inscription_id_option)) { + simple_map::drop(attributes); + return (true, option::none()) + }; + + let generator_inscription_id = option::destroy_some(generator_inscription_id_option); + if (!ord::exists_metaprotocol_validity(generator_inscription_id)) { + simple_map::drop(attributes); + return (false, option::some(std::string::utf8(b"generator_inscription_id is not validity bitseed"))) }; - let generator_inscription_id = coin_info_generator(&coin_info); - let object_id = object::custom_object_id(generator_inscription_id); - let inscription_obj = object::borrow_object(object_id); + let generator_txid = ord::inscription_id_txid(&generator_inscription_id); + let generator_index = ord::inscription_id_index(&generator_inscription_id); + let inscription_obj = ord::borrow_inscription(generator_txid, generator_index); + let inscrption = object::borrow(inscription_obj); let wasm_bytes = ord::body(inscrption); let attributes_bytes = simple_map::borrow(metadata, &string::utf8(b"attributes")); - let is_valid = inscribe_verify(wasm_bytes, deploy_args, seed, user_input, *attributes_bytes); + let (is_valid, reason) = inscribe_verify(wasm_bytes, deploy_args, seed, user_input, *attributes_bytes); if (!is_valid) { simple_map::drop(attributes); - return (false, option::some(std::string::utf8(b"inscribe verify fail"))) + return (false, reason) }; simple_map::drop(attributes); @@ -399,9 +434,14 @@ module rooch_nursery::bitseed { } public fun inscribe_verify(wasm_bytes: vector, deploy_args: vector, - seed: vector, user_input: vector, attributes_output: vector): bool { - let wasm_instance = wasm::create_wasm_instance(wasm_bytes); + seed: vector, user_input: vector, attributes_output: vector): (bool, Option) { + let wasm_instance_option = wasm::create_wasm_instance_option(wasm_bytes); + if (option::is_none(&wasm_instance_option)) { + option::destroy_none(wasm_instance_option); + return (false, option::some(std::string::utf8(b"create wasm instance fail"))) + }; + let wasm_instance = option::destroy_some(wasm_instance_option); let function_name = b"inscribe_verify"; let buffer = pack_inscribe_generate_args(deploy_args, seed, user_input); @@ -412,34 +452,48 @@ module rooch_nursery::bitseed { vector::push_back(&mut arg_list, attributes_output); let memory_args_list = wasm::create_memory_wasm_args(&mut wasm_instance, function_name, arg_list); - let ret_val = wasm::execute_wasm_function(&mut wasm_instance, function_name, memory_args_list); + let ret_val_option = wasm::execute_wasm_function_option(&mut wasm_instance, function_name, memory_args_list); wasm::release_wasm_instance(wasm_instance); - if (ret_val == 0 ) { - true - } else { - false - } + + if (option::is_none(&ret_val_option)) { + option::destroy_none(ret_val_option); + return (false, option::some(std::string::utf8(b"inscribe verify execute_wasm_function fail"))) + }; + + let ret_val = option::destroy_some(ret_val_option); + if (ret_val != 1 ) { + return (false, option::some(std::string::utf8(b"inscribe verify fail"))) + }; + + (true, option::none()) } - fun pack_inscribe_generate_args(deploy_args: vector, seed: vector, user_input: vector): vector{ - native_pack_inscribe_generate_args(deploy_args, b"attrs", seed, b"seed", - user_input, b"user_input") + #[data_struct] + struct InscribeGenerateArgs has copy, drop, store { + attrs: vector, + seed: std::string::String, + user_input: std::string::String, } - native fun native_pack_inscribe_generate_args( - deploy_args: vector, deploy_args_key: vector, - seed: vector, seed_key: vector, - user_input: vector, user_input_key: vector, - ): vector; + fun pack_inscribe_generate_args(deploy_args: vector, seed: vector, user_input: vector): vector{ + let args = InscribeGenerateArgs{ + attrs: deploy_args, + seed: string::utf8(seed), + user_input: string::utf8(user_input) + }; + + cbor::to_cbor(&args) + } fun generate_seed_from_inscription(inscription: &Inscription): vector { let inscription_txid = ord::txid(inscription); - let tx = bitcoin::get_tx(inscription_txid); - if (option::is_none(&tx)) { + let tx_option = bitcoin::get_tx(inscription_txid); + if (option::is_none(&tx_option)) { return vector::empty() }; - let tx = option::destroy_some(tx); + + let tx = option::destroy_some(tx_option); let input = types::tx_input(&tx); let index = ord::input(inscription); let txin = vector::borrow(input, (index as u64)); @@ -472,7 +526,7 @@ module rooch_nursery::bitseed { vector::append(&mut buf, address::to_bytes(block_hash)); vector::append(&mut buf, address::to_bytes(txid)); vector::append(&mut buf, bcs::to_bytes(&vout)); //TODO vout to le_bytes - hash::sha3_256(buf) + hex::encode(hash::sha3_256(buf)) } // ==== Process Bitseed Entry ==== // @@ -524,6 +578,21 @@ module rooch_nursery::bitseed { } } + public fun view_validity(inscription_id_str: String) : Option { + let inscription_id_option = ord::parse_inscription_id(&inscription_id_str); + if (option::is_none(&inscription_id_option)) { + return option::none() + }; + + let inscription_id = option::destroy_some(inscription_id_option); + if (!ord::exists_metaprotocol_validity(inscription_id)) { + return option::none() + }; + + let validity = ord::borrow_metaprotocol_validity(inscription_id); + + option::some(*validity) + } #[test_only] struct TestProtocol has key {} @@ -701,41 +770,150 @@ module rooch_nursery::bitseed { assert!(tick == string::utf8(b"move"), 2); // check generator - let generator = coin_info_generator(&coin_info); - let test_txid = @0x77dfc2fe598419b00641c296181a96cf16943697f573480b023b77cce82ada21; + let generator_option = coin_info_generator(&coin_info); + assert!(option::is_some(&generator_option), 3); + + let generator = option::destroy_some(generator_option); + let test_txid = @0x21da2ae8cc773b020b4873f597369416cf961a1896c24106b0198459fec2df77; let test_index = 0; - assert!(ord::inscription_id_txid(&generator) == test_txid, 3); - assert!(ord::inscription_id_index(&generator) == test_index, 4); + assert!(ord::inscription_id_txid(&generator) == test_txid, 4); + assert!(ord::inscription_id_index(&generator) == test_index, 5); // check max let max = coin_info_max(&coin_info); - assert!(max == 1u64, 5); + assert!(max == 1u64, 6); // check repeat let repeat = coin_info_repeat(&coin_info); - assert!(repeat == 0, 6); + assert!(repeat == 0, 7); // check has_user_input let has_user_input = coin_info_has_user_input(&coin_info); - assert!(!has_user_input, 7); + assert!(!has_user_input, 8); // check deploy_args let deploy_args = coin_info_deploy_args_option(&coin_info); - assert!(option::is_none(&deploy_args), 8) + assert!(option::is_none(&deploy_args), 9) } + #[test_only] + use moveos_std::features; + #[test(genesis_account=@0x4)] - fun test_is_valid_bitseed_mint_ok(genesis_account: &signer){ + fun test_is_valid_bitseed_mint_fail_with_tick_not_deploy(genesis_account: &signer){ + genesis_init(genesis_account); + + let (_test_address, test_inscription_id) = ord::setup_inscription_for_test(genesis_account); + ord::seal_metaprotocol_validity(test_inscription_id, true, option::none()); + + let metadata_bytes = x"a4626f70666465706c6f79647469636b646d6f766566616d6f756e74016a61747472696275746573a16967656e657261746f72784f2f696e736372697074696f6e2f373764666332666535393834313962303036343163323936313831613936636631363934333639376635373334383062303233623737636365383261646132316930"; + let metadata = cbor::to_map(metadata_bytes); + let seed = vector::empty(); + let (is_valid, reason) = is_valid_bitseed_mint(&metadata, seed); + simple_map::drop(metadata); + + assert!(!is_valid, 1); + assert!(option::borrow(&reason) == &std::string::utf8(b"tick not deploy"), 1); + } + + #[test(genesis_account=@0x4)] + fun test_is_valid_bitseed_mint_fail_with_maximum_supply_exceeded(genesis_account: &signer){ + genesis_init(genesis_account); + let (_test_address, test_inscription_id) = ord::setup_inscription_for_test(genesis_account); ord::seal_metaprotocol_validity(test_inscription_id, true, option::none()); let metadata_bytes = x"a4626f70666465706c6f79647469636b646d6f766566616d6f756e74016a61747472696275746573a16967656e657261746f72784f2f696e736372697074696f6e2f373764666332666535393834313962303036343163323936313831613936636631363934333639376635373334383062303233623737636365383261646132316930"; let metadata = cbor::to_map(metadata_bytes); let (is_valid, reason) = is_valid_bitseed_deploy(&metadata); + + assert!(is_valid, 1); + assert!(option::is_none(&reason), 1); + + let (ok, reason) = deploy_tick(&metadata); + assert!(ok, 1); + assert!(option::is_none(&reason), 1); + + simple_map::drop(metadata); + + let metadata_bytes = x"a4626f70646d696e74647469636b646d6f766566616d6f756e7418646a61747472696275746573a16967656e657261746f72784f2f696e736372697074696f6e2f377864666332666535393834313962303036343163323936313831613936636631363934333639376635373334383062303233623737636365383261646132316930"; + let metadata = cbor::to_map(metadata_bytes); + let seed = vector::empty(); + let (is_valid, reason) = is_valid_bitseed_mint(&metadata, seed); + simple_map::drop(metadata); + + assert!(!is_valid, 1); + assert!(option::borrow(&reason) == &std::string::utf8(b"maximum supply exceeded"), 1); + } + + #[test(genesis_account=@0x4)] + fun test_is_valid_bitseed_mint_fail_with_user_input_is_required(genesis_account: &signer){ + genesis_init(genesis_account); + + let (_test_address, test_inscription_id) = ord::setup_inscription_for_test(genesis_account); + ord::seal_metaprotocol_validity(test_inscription_id, true, option::none()); + + let metadata_bytes = x"a4626f70666465706c6f79647469636b646d6f766566616d6f756e741927106a61747472696275746573a466726570656174056967656e657261746f72784f2f696e736372697074696f6e2f3737646663326665353938343139623030363431633239363138316139366366313639343336393766353733343830623032336237376363653832616461323169306e6861735f757365725f696e707574f56b6465706c6f795f617267738178377b22686569676874223a7b2274797065223a2272616e6765222c2264617461223a7b226d696e223a312c226d6178223a313030307d7d7d"; + let metadata = cbor::to_map(metadata_bytes); + let (is_valid, reason) = is_valid_bitseed_deploy(&metadata); + + assert!(is_valid, 1); + assert!(option::is_none(&reason), 1); + + let (ok, reason) = deploy_tick(&metadata); + assert!(ok, 1); + assert!(option::is_none(&reason), 1); + + simple_map::drop(metadata); + + let metadata_bytes = x"a4626f70646d696e74647469636b646d6f766566616d6f756e7418646a61747472696275746573a16967656e657261746f72784f2f696e736372697074696f6e2f377864666332666535393834313962303036343163323936313831613936636631363934333639376635373334383062303233623737636365383261646132316930"; + let metadata = cbor::to_map(metadata_bytes); + let seed = vector::empty(); + let (is_valid, reason) = is_valid_bitseed_mint(&metadata, seed); simple_map::drop(metadata); + assert!(!is_valid, 1); + assert!(option::borrow(&reason) == &std::string::utf8(b"metadata.attributes.user_input is required"), 1); + } + + #[test(genesis_account=@0x4)] + fun test_is_valid_bitseed_mint_fail_with_wasm_verify_fail(genesis_account: &signer){ + features::init_and_enable_all_features_for_test(); + + let (_test_address, test_inscription_id) = ord::setup_inscription_for_test(genesis_account); + ord::seal_metaprotocol_validity(test_inscription_id, true, option::none()); + + init_bitseed_store_for_test(genesis_account); + + let metadata_bytes = x"a4626f70666465706c6f79647469636b646d6f766566616d6f756e741927106a61747472696275746573a466726570656174056967656e657261746f72784f2f696e736372697074696f6e2f3737646663326665353938343139623030363431633239363138316139366366313639343336393766353733343830623032336237376363653832616461323169306e6861735f757365725f696e707574f56b6465706c6f795f617267738178377b22686569676874223a7b2274797065223a2272616e6765222c2264617461223a7b226d696e223a312c226d6178223a313030307d7d7d"; + let metadata = cbor::to_map(metadata_bytes); + let (is_valid, reason) = is_valid_bitseed_deploy(&metadata); + assert!(is_valid, 1); assert!(option::is_none(&reason), 1); + + let (ok, reason) = deploy_tick(&metadata); + assert!(ok, 1); + assert!(option::is_none(&reason), 1); + + simple_map::drop(metadata); + + let metadata_bytes = x"a4626f70646d696e74647469636b646d6f766566616d6f756e74016a61747472696275746573a16a757365725f696e70757463787878"; + let metadata = cbor::to_map(metadata_bytes); + let seed = vector::empty(); + let (is_valid, reason) = is_valid_bitseed_mint(&metadata, seed); + simple_map::drop(metadata); + + assert!(!is_valid, 1); + assert!(option::borrow(&reason) == &std::string::utf8(b"create wasm instance fail"), 1); } -} + #[test] + fun test_pack_inscribe_generate_args() { + let deploy_args = x"8178377b22686569676874223a7b2274797065223a2272616e6765222c2264617461223a7b226d696e223a312c226d6178223a313030307d7d7d"; + let seed = b"0xe4b6de2407ad9455a364ba0227a8591631d1253508bc41f7d1992d218dd29b47"; + let user_input = b""; + + pack_inscribe_generate_args(deploy_args, seed, user_input); + } +} \ No newline at end of file diff --git a/scripts/bitcoin/test.sh b/scripts/bitcoin/test.sh index 760568eae9..c5419fbbe7 100644 --- a/scripts/bitcoin/test.sh +++ b/scripts/bitcoin/test.sh @@ -4,7 +4,7 @@ set -e -while getopts "huia" opt; do +while getopts "hubsa" opt; do case $opt in h) cat <