├── .cargo └── config ├── .flake8 ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── android-build.yml │ ├── audit.yml │ ├── bindings.yml │ ├── ci.yml │ ├── codeql.yml │ ├── docs.yml │ ├── ios-build.yml │ ├── lint.yml │ ├── linux-build.yml │ ├── mac-build.yml │ ├── test.yml │ └── win-build.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── SECURITY.md ├── android_build.sh ├── bindings ├── cpp │ ├── AndroidSecureStorage │ │ ├── app │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── cronos │ │ │ │ └── play │ │ │ │ └── SecureStorage.kt │ │ └── compile.md │ ├── Cargo.toml │ ├── LICENSE │ ├── README.md │ ├── build.rs │ ├── compile.sh │ ├── include │ │ ├── android.h │ │ └── nft.h │ └── src │ │ ├── android.cc │ │ ├── contract.rs │ │ ├── ethereum.rs │ │ ├── lib.rs │ │ ├── nft.cc │ │ ├── nft.rs │ │ └── uint.rs └── wasm │ ├── .cargo │ └── config │ ├── Cargo.toml │ ├── LICENSE │ ├── README.md │ ├── src │ ├── cosmos_sdk.rs │ ├── cosmos_sdk │ │ └── signer.rs │ ├── ethereum.rs │ ├── ethereum │ │ └── signer.rs │ ├── lib.rs │ └── utils.rs │ └── tests │ ├── account.rs │ ├── bank.rs │ ├── distribution.rs │ ├── ethereum.rs │ ├── ibc.rs │ ├── nft.rs │ ├── staking.rs │ └── test_helper.rs ├── checkmac.sh ├── clean.sh ├── common ├── Cargo.toml ├── LICENSE ├── README.md ├── build.rs ├── src │ ├── common.udl │ ├── contract.rs │ ├── contract │ │ ├── erc1155-abi.json │ │ ├── erc20-abi.json │ │ ├── erc4907-abi.json │ │ └── erc721-abi.json │ ├── lib.rs │ ├── login.rs │ ├── macros.rs │ ├── node.rs │ ├── node │ │ ├── cosmos_sdk.rs │ │ ├── cosmos_sdk │ │ │ └── balance_query.rs │ │ ├── error.rs │ │ ├── ethereum.rs │ │ ├── ethereum │ │ │ ├── abi.rs │ │ │ ├── eip712.rs │ │ │ ├── eip712 │ │ │ │ └── deserializer.rs │ │ │ ├── erc1155.rs │ │ │ ├── erc20.rs │ │ │ ├── erc4907.rs │ │ │ ├── erc721.rs │ │ │ ├── provider.rs │ │ │ └── utils.rs │ │ ├── nft.rs │ │ └── wasm_binding.rs │ ├── qr_code.rs │ ├── transaction.rs │ ├── transaction │ │ ├── cosmos_sdk.rs │ │ ├── cosmos_sdk │ │ │ ├── parser.rs │ │ │ ├── parser │ │ │ │ ├── base_parser.rs │ │ │ │ ├── crypto_org_parser.rs │ │ │ │ ├── luna_classic_parser.rs │ │ │ │ ├── structs.rs │ │ │ │ ├── structs │ │ │ │ │ └── cosmos_raw_msg.rs │ │ │ │ └── uniffi_binding.rs │ │ │ └── signer.rs │ │ ├── ethereum.rs │ │ ├── ethereum │ │ │ ├── abi_contract.rs │ │ │ ├── error.rs │ │ │ └── signer.rs │ │ ├── luna_classic.rs │ │ ├── luna_classic │ │ │ └── wasm.rs │ │ ├── nft.rs │ │ ├── uniffi_binding.rs │ │ └── wasm_binding.rs │ ├── utils.rs │ ├── wallet.rs │ └── wallet │ │ └── wasm_binding.rs ├── uniffi-bindgen.rs └── uniffi.toml ├── contracts ├── .gitignore ├── artifacts │ └── contracts │ │ ├── TestERC1155.sol │ │ ├── TestERC1155.dbg.json │ │ └── TestERC1155.json │ │ ├── TestERC20.sol │ │ ├── TestERC20.dbg.json │ │ └── TestERC20.json │ │ └── TestERC721.sol │ │ ├── TestERC721.dbg.json │ │ └── TestERC721.json ├── contracts │ ├── GameERC721.sol │ ├── TestERC1155.sol │ ├── TestERC20.sol │ └── TestERC721.sol ├── hardhat.config.ts ├── package-lock.json └── package.json ├── docs └── cpp │ ├── Doxyfile │ ├── README.md │ ├── SUMMARY.md.tmpl │ ├── config.json │ ├── gitbook │ └── src │ │ └── README.md │ ├── mdbook │ ├── .gitignore │ ├── book.toml │ └── src │ │ └── README.md │ ├── shell.nix │ └── sphinx │ ├── Makefile │ ├── conf.py │ └── index.rst ├── env └── android │ └── libgcc.a ├── example ├── android_example │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── android_example │ │ │ │ └── ExampleInstrumentedTest.kt │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── android_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── drawable │ │ │ │ └── ic_launcher_background.xml │ │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── themes.xml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── android_example │ │ │ └── ExampleUnitTest.kt │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── cpp-example │ ├── CMakeLists.txt │ ├── Makefile │ ├── chainmain.cc │ ├── chainmain.h │ ├── cronos.cc │ ├── cronos.h │ ├── helper.py │ ├── main.cc │ ├── sdk │ │ └── CMakeLists.txt │ ├── wallet.cc │ └── wallet.h ├── extension-example │ ├── .gitignore │ ├── Makefile │ ├── background.js │ ├── manifest.json │ ├── package-lock.json │ ├── package.json │ ├── test.html │ └── test.js ├── ios-example │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── build.sh │ ├── ios-example.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── ios-example │ │ ├── Assets.xcassets │ │ │ ├── AccentColor.colorset │ │ │ │ └── Contents.json │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── ContentView.swift │ │ ├── Preview Content │ │ │ └── Preview Assets.xcassets │ │ │ │ └── Contents.json │ │ ├── include │ │ │ └── module.modulemap │ │ └── ios_exampleApp.swift │ ├── ios-exampleTests │ │ └── ios_exampleTests.swift │ └── ios-exampleUITests │ │ ├── ios_exampleUITests.swift │ │ └── ios_exampleUITestsLaunchTests.swift ├── js-example │ ├── .bin │ │ └── create-wasm-app.js │ ├── .gitignore │ ├── .travis.yml │ ├── bootstrap.js │ ├── index.html │ ├── index.js │ ├── package-lock.json │ ├── package.json │ └── webpack.config.js └── vs-example │ ├── go.sh │ ├── vs-example.sln │ └── vs-example │ └── vs-example.vcxproj ├── integration_tests ├── .flake8 ├── .isort.cfg ├── __init__.py ├── conftest.py ├── network.py ├── poetry.lock ├── pyproject.toml ├── shell.nix ├── test_basic.py └── utils.py ├── ios_build.sh ├── js_build.sh ├── mobile_modules ├── .gitignore ├── android_module │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── crypto │ │ │ │ └── android_dwclib │ │ │ │ └── ExampleInstrumentedTest.kt │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ └── res │ │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── drawable │ │ │ │ └── ic_launcher_background.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.webp │ │ │ │ └── ic_launcher_round.webp │ │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── themes.xml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── crypto │ │ │ └── android_dwclib │ │ │ └── ExampleUnitTest.kt │ ├── build.gradle │ ├── dwclib │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── consumer-rules.pro │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── crypto │ │ │ │ └── dwclib │ │ │ │ └── ExampleInstrumentedTest.kt │ │ │ ├── main │ │ │ └── AndroidManifest.xml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── crypto │ │ │ └── dwclib │ │ │ └── ExampleUnitTest.kt │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle └── ios_module │ └── dwclib │ ├── dwclib.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── dwclib.xcscheme │ ├── dwclib │ ├── dwclib.h │ └── include │ │ └── module.modulemap │ └── dwclibTests │ └── dwclibTests.swift ├── nix ├── chainmain.nix ├── cronos.nix ├── default.nix ├── doxybook2.nix ├── hermes.nix ├── node │ ├── default.nix │ ├── node-env.nix │ ├── node-packages.json │ ├── node-packages.nix │ └── override.nix ├── pypkgs.nix ├── sources.json ├── sources.nix └── testenv.nix ├── proto-build ├── Cargo.toml ├── LICENSE ├── README.md └── src │ └── main.rs ├── proto ├── Cargo.toml ├── LICENSE ├── README.md └── src │ ├── lib.rs │ └── prost │ ├── CHAIN_MAIN_COMMIT │ ├── LUNA_CLASSIC_COMMIT │ ├── chainmain.chainmain.v1.rs │ ├── chainmain.nft.v1.rs │ ├── chainmain.supply.v1.rs │ ├── cosmos_proto.rs │ ├── terra.market.v1beta1.rs │ ├── terra.oracle.v1beta1.rs │ ├── terra.treasury.v1beta1.rs │ ├── terra.tx.v1beta1.rs │ ├── terra.vesting.v1beta1.rs │ └── terra.wasm.v1beta1.rs ├── rust-toolchain └── scripts ├── .env ├── chainmain-ctl ├── chainmain-devnet-alone.yaml ├── chainmain-devnet.yaml ├── cronos-ctl ├── cronos-devnet.yaml ├── full-wasm-tests ├── hermes-ctl ├── hermes.toml ├── python-tests ├── start-all ├── start-chainmain ├── start-cronos ├── start-hermes ├── stop-all └── wasm-tests /.cargo/config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/.cargo/config -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | extend-ignore = E203 4 | exclude = .git,__pycache__,./third_party 5 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @crypto-com/defi-wallet-core-maintainers 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻 2 | 3 | 4 | # PR Checklist: 5 | 6 | - [ ] Have you read the [CONTRIBUTING.md](https://github.com/crypto-com/defi-wallet-core-rs/blob/main/CONTRIBUTING.md)? 7 | - [ ] Does your PR follow the [C4 patch requirements](https://rfc.zeromq.org/spec:42/C4/#23-patch-requirements)? 8 | - [ ] Have you rebased your work on top of the latest main? 9 | - [ ] Have you checked your code compiles? (`cargo build`) 10 | - [ ] Have you included tests for any non-trivial functionality? 11 | - [ ] Have you checked your code passes the unit tests? (`cargo test`) 12 | - [ ] Have you checked your code formatting is correct? (`cargo fmt -- --check --color=auto`) 13 | - [ ] Have you checked your basic code style is fine? (`cargo clippy`) 14 | - [ ] If you added any dependencies, have you checked they do not contain any known vulnerabilities? (`cargo audit`) 15 | - [ ] If your changes affect public APIs, does your PR follow the [C4 evolution of public contracts](https://rfc.zeromq.org/spec:42/C4/#26-evolution-of-public-contracts)? 16 | - [ ] If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the [CHANGELOG.md](https://github.com/crypto-com/defi-wallet-core-rs/blob/main/CHANGELOG.md)? 17 | - [ ] If you are contributing for the first time, please read the agreement in [CONTRIBUTING.md](https://github.com/crypto-com/defi-wallet-core-rs/blob/main/CONTRIBUTING.md) now and add a comment to this pull request stating that your PR is in accordance with the [Developer's Certificate of Origin](https://github.com/crypto-com/defi-wallet-core-rs/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). 18 | 19 | Thank you for your code, it's appreciated! :) 20 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | open-pull-requests-limit: 10 -------------------------------------------------------------------------------- /.github/workflows/android-build.yml: -------------------------------------------------------------------------------- 1 | name: Android Build CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | merge_group: 7 | pull_request: 8 | branches: [ main ] 9 | 10 | jobs: 11 | android-build: 12 | runs-on: macos-11 13 | steps: 14 | - name: android_images cache 15 | uses: actions/cache@v2 16 | with: 17 | path: | 18 | $ANDROID_SDK_ROOT/system-images/ 19 | key: ${{ runner.os }}-android_images-${{ hashFiles('android_build.sh') }} 20 | restore-keys: | 21 | ${{ runner.os }}-android_images- 22 | - uses: actions/checkout@v3 23 | - run: | 24 | export JAVA_HOME=$JAVA_HOME_8_X64 25 | echo y | $ANDROID_SDK_ROOT/tools/bin/sdkmanager "system-images;android-31;google_apis;x86_64" 26 | echo no | $ANDROID_SDK_ROOT/tools/bin/avdmanager create avd -n testavd -c 2048M -k "system-images;android-31;google_apis;x86_64" 27 | $ANDROID_SDK_ROOT/tools/emulator @testavd -partition-size 2048 -wipe-data & 28 | - name: NDK cache 29 | uses: actions/cache@v2 30 | with: 31 | path: | 32 | NDK/ 33 | key: ${{ runner.os }}-ndk-${{ hashFiles('android_build.sh') }} 34 | restore-keys: | 35 | ${{ runner.os }}-ndk- 36 | - name: Android module cache 37 | uses: actions/cache@v2 38 | with: 39 | path: | 40 | mobile_modules/android_module/ 41 | key: ${{ runner.os }}-android-${{ hashFiles('**/Cargo.lock', '**/*.kt', 'android_build.sh') }} 42 | - name: Rust cache 43 | uses: Swatinem/rust-cache@v1 44 | - name: Gradle cache 45 | uses: actions/cache@v2 46 | with: 47 | path: | 48 | ~/.gradle/caches 49 | ~/.gradle/wrapper 50 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 51 | restore-keys: | 52 | ${{ runner.os }}-gradle- 53 | - run: | 54 | export ANDROID_HOME=$HOME/Library/Android/sdk 55 | export NDK_HOME=$ANDROID_NDK_HOME 56 | export JAVA_HOME=$JAVA_HOME_11_X64 57 | ./android_build.sh x86 58 | -------------------------------------------------------------------------------- /.github/workflows/audit.yml: -------------------------------------------------------------------------------- 1 | name: Security Audit 2 | on: 3 | pull_request: 4 | paths: 5 | - Cargo.lock 6 | push: 7 | branches: 8 | - main 9 | paths: 10 | - Cargo.lock 11 | merge_group: 12 | schedule: 13 | - cron: '0 0 * * *' 14 | 15 | jobs: 16 | security_audit: 17 | name: Security Audit 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v3 21 | - uses: dtolnay/rust-toolchain@stable 22 | - name: Install cargo audit 23 | run: cargo install cargo-audit 24 | # RUSTSEC-2021-0145: `atty` transitive dependency, only informational for Windows (not exploitable in practice) 25 | # RUSTSEC-2023-0033: fixed until https://github.com/near/borsh-rs/issues/19 26 | - run: cargo audit --deny warnings --ignore RUSTSEC-2021-0145 --ignore RUSTSEC-2023-0033 27 | -------------------------------------------------------------------------------- /.github/workflows/bindings.yml: -------------------------------------------------------------------------------- 1 | name: Bindings 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths-ignore: 7 | - README.md 8 | merge_group: 9 | pull_request: 10 | paths-ignore: 11 | - README.md 12 | 13 | jobs: 14 | test: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Install 19 | run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh 20 | - run: wasm-pack build --scope crypto-com bindings/wasm 21 | - run: cargo run --features=uniffi-bindgen -p defi-wallet-core-common --bin uniffi-bindgen -- generate common/src/common.udl --config common/uniffi.toml --language kotlin --out-dir bindings/android 22 | - run: cargo run --features=uniffi-bindgen -p defi-wallet-core-common --bin uniffi-bindgen -- generate common/src/common.udl --config common/uniffi.toml --language swift --out-dir bindings/ios 23 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths-ignore: 8 | - README.md 9 | merge_group: 10 | pull_request: 11 | paths-ignore: 12 | - README.md 13 | 14 | env: 15 | CARGO_TERM_COLOR: always 16 | RUSTFLAGS: -Dwarnings 17 | 18 | jobs: 19 | clippy: 20 | name: cargo clippy 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v3 24 | - uses: dtolnay/rust-toolchain@stable 25 | with: 26 | components: clippy 27 | targets: wasm32-unknown-unknown 28 | - uses: Swatinem/rust-cache@v1 29 | - name: Check with clippy 30 | run: cargo clippy --all-targets --all-features -- -D warnings 31 | - name: Check with clippy for defi-wallet-core-cpp 32 | run: cargo clippy -p defi-wallet-core-cpp --all-features -- -D warnings 33 | - name: Check with clippy for defi-wallet-core-wasm 34 | run: cargo clippy -p defi-wallet-core-wasm --target wasm32-unknown-unknown --all-features -- -D warnings 35 | test: 36 | name: cargo test 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v3 40 | - uses: dtolnay/rust-toolchain@stable 41 | with: 42 | components: llvm-tools-preview 43 | - uses: Swatinem/rust-cache@v1 44 | - name: Install cargo-llvm-cov 45 | uses: taiki-e/install-action@cargo-llvm-cov 46 | - name: Generate code coverage 47 | run: cargo llvm-cov --all-features --lcov --output-path lcov.info 48 | - name: Generate code coverage for defi-wallet-core-cpp 49 | run: cargo llvm-cov --all-features -p defi-wallet-core-cpp --lcov --output-path lcov-cpp.info 50 | - name: Upload coverage to Codecov 51 | uses: codecov/codecov-action@v3 52 | with: 53 | files: ./lcov.info,./lcov-cpp.info 54 | fail_ci_if_error: true 55 | 56 | fmt: 57 | name: cargo fmt 58 | runs-on: ubuntu-latest 59 | steps: 60 | - uses: actions/checkout@v3 61 | - uses: dtolnay/rust-toolchain@stable 62 | with: 63 | components: rustfmt 64 | - uses: Swatinem/rust-cache@v1 65 | - run: cargo fmt --all -- --check 66 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | merge_group: 9 | schedule: 10 | - cron: "7 11 * * 5" 11 | 12 | jobs: 13 | analyze: 14 | name: Analyze 15 | runs-on: ubuntu-latest 16 | permissions: 17 | actions: read 18 | contents: read 19 | security-events: write 20 | 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | language: [ javascript, python ] 25 | 26 | steps: 27 | - name: Checkout 28 | uses: actions/checkout@v3 29 | 30 | - name: Initialize CodeQL 31 | uses: github/codeql-action/init@v2 32 | with: 33 | languages: ${{ matrix.language }} 34 | queries: +security-and-quality 35 | 36 | - name: Autobuild 37 | uses: github/codeql-action/autobuild@v2 38 | 39 | - name: Perform CodeQL Analysis 40 | uses: github/codeql-action/analyze@v2 41 | with: 42 | category: "/language:${{ matrix.language }}" 43 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Documents 2 | on: 3 | pull_request: 4 | merge_group: 5 | push: 6 | branches: 7 | - main 8 | - release/** 9 | tags: 10 | - "*" 11 | 12 | jobs: 13 | cpp_documents: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | - uses: cachix/install-nix-action@v19 18 | with: 19 | # pin to nix-2.13 to workaround compability issue of 2.14, 20 | # see: https://github.com/cachix/install-nix-action/issues/161 21 | install_url: https://releases.nixos.org/nix/nix-2.13.3/install 22 | - uses: cachix/cachix-action@v10 23 | with: 24 | name: cronos 25 | extraPullNames: dapp 26 | # github don't pass secrets for pull request from fork repos, 27 | # in that case the push is disabled naturally. 28 | signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" 29 | - name: 'Tar debug files' 30 | if: failure() 31 | run: tar cfz debug_files.tar.gz -C /tmp/pytest-of-runner . 32 | - uses: actions/upload-artifact@v2 33 | if: failure() 34 | with: 35 | name: debug-files 36 | path: debug_files.tar.gz 37 | if-no-files-found: ignore 38 | - name: Generate doxygen 39 | run: make cpp-docs-doxygen 40 | - name: Generate sphinx 41 | run: make cpp-docs-sphinx 42 | - name: Generate gitbook 43 | run: make cpp-docs-gitbook 44 | - name: Generate mdbook 45 | run: make cpp-docs-mdbook 46 | -------------------------------------------------------------------------------- /.github/workflows/ios-build.yml: -------------------------------------------------------------------------------- 1 | name: IOS Build CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | merge_group: 7 | pull_request: 8 | branches: [ main ] 9 | 10 | jobs: 11 | ios-build: 12 | runs-on: macos-11 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: iOS module cache 16 | uses: actions/cache@v2 17 | with: 18 | path: | 19 | mobile_modules/ios_module/ 20 | key: ${{ runner.os }}-ios-${{ hashFiles('**/Cargo.lock', '**/*.swift', 'ios_build.sh') }} 21 | - name: Rust cache 22 | uses: Swatinem/rust-cache@v1 23 | - run: ./ios_build.sh x86 24 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Run Lint 2 | # Lint runs golangci-lint over the entire cronos repository This workflow is 3 | # run on every pull request and push to main The `golangci` will pass without 4 | # running if no *.{go, mod, sum} files have been changed. 5 | on: 6 | pull_request: 7 | merge_group: 8 | push: 9 | branches: 10 | - main 11 | jobs: 12 | lint-python: 13 | name: Lint python 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | - uses: cachix/install-nix-action@v19 18 | with: 19 | # pin to nix-2.13 to workaround compability issue of 2.14, 20 | # see: https://github.com/cachix/install-nix-action/issues/161 21 | install_url: https://releases.nixos.org/nix/nix-2.13.3/install 22 | - uses: cachix/cachix-action@v10 23 | with: 24 | name: cronos 25 | - run: nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py" 26 | 27 | lint-nix: 28 | name: Lint nix 29 | runs-on: ubuntu-latest 30 | steps: 31 | - uses: actions/checkout@v3 32 | - uses: cachix/install-nix-action@v19 33 | with: 34 | # pin to nix-2.13 to workaround compability issue of 2.14, 35 | # see: https://github.com/cachix/install-nix-action/issues/161 36 | install_url: https://releases.nixos.org/nix/nix-2.13.3/install 37 | - run: nix-shell -I nixpkgs=./nix -p nixpkgs-fmt --run "make lint-nix" 38 | -------------------------------------------------------------------------------- /.github/workflows/linux-build.yml: -------------------------------------------------------------------------------- 1 | name: Linux Build CI 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths-ignore: 7 | - README.md 8 | tags: 9 | - "v*.*.*" 10 | merge_group: 11 | pull_request: 12 | paths-ignore: 13 | - README.md 14 | 15 | jobs: 16 | build: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v3 20 | 21 | - name: Compile Cpp 22 | run: make build_cpp 23 | -------------------------------------------------------------------------------- /.github/workflows/mac-build.yml: -------------------------------------------------------------------------------- 1 | name: Mac Build CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths-ignore: 8 | - README.md 9 | tags: 10 | - "v*.*.*" 11 | merge_group: 12 | pull_request: 13 | paths-ignore: 14 | - README.md 15 | 16 | jobs: 17 | mac-build: 18 | runs-on: macos-11 19 | steps: 20 | - uses: actions/checkout@v3 21 | 22 | - name: Compile Cpp 23 | run: make build_cpp 24 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: integration tests 2 | on: 3 | pull_request: 4 | merge_group: 5 | push: 6 | branches: 7 | - main 8 | - release/** 9 | tags: 10 | - "*" 11 | 12 | jobs: 13 | integration_tests: 14 | runs-on: ubuntu-latest 15 | env: 16 | WASM_BINDGEN_TEST_TIMEOUT: 60 17 | steps: 18 | - uses: actions/checkout@v3 19 | - uses: cachix/install-nix-action@v19 20 | with: 21 | # pin to nix-2.13 to workaround compability issue of 2.14, 22 | # see: https://github.com/cachix/install-nix-action/issues/161 23 | install_url: https://releases.nixos.org/nix/nix-2.13.3/install 24 | - uses: cachix/cachix-action@v10 25 | with: 26 | name: cronos 27 | extraPullNames: dapp 28 | # github don't pass secrets for pull request from fork repos, 29 | # in that case the push is disabled naturally. 30 | signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" 31 | - name: 'Tar debug files' 32 | if: failure() 33 | run: tar cfz debug_files.tar.gz -C /tmp/pytest-of-runner . 34 | - uses: actions/upload-artifact@v2 35 | if: failure() 36 | with: 37 | name: debug-files 38 | path: debug_files.tar.gz 39 | if-no-files-found: ignore 40 | - name: Install wasm-pack 41 | run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh 42 | - name: Run wasm tests 43 | run: make wasm-ci-tests 44 | - name: Run cpp tests 45 | run: make cpp-ci-tests 46 | -------------------------------------------------------------------------------- /.github/workflows/win-build.yml: -------------------------------------------------------------------------------- 1 | name: Windows Build CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths-ignore: 8 | - README.md 9 | tags: 10 | - "v*.*.*" 11 | merge_group: 12 | pull_request: 13 | paths-ignore: 14 | - README.md 15 | 16 | jobs: 17 | build: 18 | runs-on: windows-latest 19 | steps: 20 | - uses: actions/checkout@v3 21 | - run: git config --global core.symlinks true 22 | 23 | - name: Add msbuild to PATH 24 | uses: microsoft/setup-msbuild@v1.1 25 | 26 | - name: prepare files in bash 27 | shell: bash 28 | run: | 29 | cd ./example/vs-example 30 | ./go.sh 31 | 32 | - name: compile 33 | working-directory: .\example\vs-example\vs-example 34 | run: msbuild .\vs-example.vcxproj -t:rebuild -property:Configuration=Release /p:Platform=x64 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | website/build 2 | target 3 | NDK 4 | bindings/android 5 | bindings/ios 6 | credentials.json 7 | *-engine.json 8 | *.db 9 | .*.swp 10 | 11 | # Android stuff. 12 | *.iml 13 | .gradle 14 | local.properties 15 | .idea 16 | build 17 | .DS_Store 18 | captures 19 | .externalNativeBuild 20 | .lastAutoPublishContentsHash 21 | 22 | # iOS stuff. 23 | xcuserdata 24 | 25 | # Protobuf Swift 26 | *.pb.swift 27 | 28 | # UniFFI generated artifacts 29 | components/**/ios/Generated 30 | 31 | # Carthage generated artifacts 32 | Carthage 33 | raw_xcodebuild.log 34 | raw_xcodetest.log 35 | 36 | # Generated debug symbols 37 | crashreporter-symbols* 38 | automation/symbols-generation/bin/ 39 | 40 | # Generated mdbook documentation files 41 | build/docs/* 42 | docs/book 43 | 44 | # Generated rustdocs 45 | docs/rust-docs 46 | 47 | # Generated cxx files 48 | example/cpp-example/cppexample 49 | example/cpp-example/cxx.h 50 | example/cpp-example/lib.rs.cc 51 | example/cpp-example/lib.rs.h 52 | example/cpp-example/libdefi_wallet_core_cpp.a 53 | 54 | # python stuff 55 | __pycache__ 56 | 57 | example/cpp-example/sdk/* 58 | example/vs-example/vs-example/* 59 | example/cpp-example/cppexamplestatic 60 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/chain-main"] 2 | path = third_party/chain-main 3 | url = https://github.com/crypto-org-chain/chain-main.git 4 | [submodule "third_party/luna_classic"] 5 | path = third_party/luna_classic 6 | url = https://github.com/terra-money/classic-core.git 7 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "proto-build", 5 | "proto", 6 | "common", 7 | "bindings/wasm", 8 | "bindings/cpp", 9 | ] 10 | default-members = [ 11 | "proto-build", 12 | "proto", 13 | "common", 14 | ] 15 | 16 | [profile.release] 17 | opt-level = "s" 18 | debug = true 19 | lto = "thin" 20 | # The following configuration minimizes the size of the output packet, Reference https://github.com/johnthagen/min-sized-rust 21 | # opt-level = "z" 22 | # debug = false 23 | # lto = true 24 | # codegen-units = 1 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022-present, Crypto.com. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | DeFi Wallet Core 2 | Copyright 2022-present, Crypto.com. 3 | 4 | This project contains portions of code derived from the following libraries: 5 | 6 | * Cosmos Rust 7 | * Copyright: Copyright (c) 2020-2022 Cosmos Rust authors 8 | * License: Apache License 2.0 9 | * Repository: https://github.com/cosmos/cosmos-rust 10 | 11 | The sample demo code bundles resources from the corresponding platform SDK: 12 | 13 | * Material Icons / Material Symbols (from Android SDK) 14 | * Copyright: Copyright (c) 2016-2022 Google Inc. 15 | * License: Apache 2.0 16 | * Repository: https://github.com/google/material-design-icons 17 | 18 | * Gradle build scripts 19 | * Copyright: Copyright (c) 2007-2019 Gradle, Inc. 20 | * License: Apache 2.0 21 | * Repository: https://github.com/gradle/ 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | ## Coordinated Vulnerability Disclosure Policy 2 | We ask security researchers to keep vulnerabilities and communications around vulnerability submissions private and confidential until a patch is developed to protect the people using Crypto.com’s protocols. In addition to this, we ask that you: 3 | 4 | - Allow us a reasonable amount of time to correct or address security vulnerabilities. 5 | - Avoid exploiting any vulnerabilities that you discover. 6 | - Demonstrate good faith by not disrupting or degrading Crypto.com’s data or services. 7 | 8 | ## Vulnerability Disclosure Process 9 | Once we receive a vulnerability report, Crypto.com will take these steps to address it: 10 | 11 | 1. Crypto.com will confirm receipt of the vulnerability report within 5 business days. The timing of our response may depend on when a report is submitted. As our daily operations are distributed in time zones across the globe, response times may vary. If you have not received a response to a vulnerability report from us within 5 business days, we encourage you to follow up with us again for a response. 12 | 2. Crypto.com will investigate and validate the security issue submitted to us as quickly as we can, usually within 10 business days of receipt. Submitting a thorough report with clear steps to recreate the vulnerability and/or a proof-of-concept will move the process along in a timely manner. 13 | 3. Crypto.com will acknowledge the bug, and make the necessary code changes to patch it. Some issues may require more time than others to patch, but we will strive to patch each vulnerability as quickly as our resources and development process allow. 14 | 4. Crypto.com will publicly release the security patch for the vulnerability, and acknowledge the security fix in the release notes once the issue has been resolved. Public release notes can reference to the person or people who reported the vulnerability, unless they wish to stay anonymous. 15 | 16 | ## Contact Us 17 | If you find a security issue, you can report it on the [Crypto.com HackerOne Bug Bounty Program](https://hackerone.com/crypto) or you can contact our team directly at [oss@crypto.com](mailto:oss@crypto.com). 18 | To communicate sensitive information, you can use the latest key in the 19 | [cryptocom's Keybase account](https://keybase.io/cryptocom/pgp_keys.asc) or use its [chat functionality](https://keybase.io/cryptocom/chat). -------------------------------------------------------------------------------- /bindings/cpp/AndroidSecureStorage/compile.md: -------------------------------------------------------------------------------- 1 | # compile 2 | - kotlin source can be compilied in any android project. 3 | - copy the SecureStorage.kt file to your project. 4 | - path would be `yourproject/app/src/main/java/com/cronos/play/SecureStorage.kt` 5 | 6 | 7 | # packaging jar file 8 | for unreal engine, we need to package the kotlin class file into a jar file. 9 | ``` 10 | ./gradlew assembleRelease 11 | jar cvf SecureStorage.jar ./app/build/tmp/kotlin-classes/release/com/cronos/play/SecureStorage.class 12 | ``` -------------------------------------------------------------------------------- /bindings/cpp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "defi-wallet-core-cpp" 3 | version = "0.3.6" 4 | edition = "2021" 5 | rust-version = "1.57" 6 | license = "Apache-2.0" 7 | 8 | [dependencies] 9 | defi-wallet-core-common = { path = "../../common" , features=["login","abi-contract"]} 10 | defi-wallet-core-proto = { version = "0.1", path = "../../proto" } 11 | cosmos-sdk-proto = { git = "https://github.com/crypto-com/cosmos-rust.git" } 12 | cxx = "1" 13 | anyhow = "1" 14 | serde="1" 15 | serde_json="1" 16 | siwe = { version = "0.5" } 17 | ethers = { version = "2.0", features = ["rustls"] } 18 | ethers-addressbook = { version = "2.0"} 19 | ethers-contract = { version = "2.0" } 20 | ethers-core = { version = "2.0" } 21 | ethers-etherscan = { version = "2.0" } 22 | ethers-middleware = { version = "2.0" } 23 | ethers-providers = { version = "2.0"} 24 | ethers-signers = { version = "2.0" } 25 | ethers-solc = { version = "2.0"} 26 | hex = "0.4" 27 | tokio = { version = "1", features = ["rt"] } 28 | 29 | 30 | [target.'cfg(not(target_os="android"))'.dependencies] 31 | keyring="2" 32 | 33 | 34 | 35 | 36 | [build-dependencies] 37 | cxx-build = "1" 38 | 39 | [lib] 40 | crate-type = ["staticlib", "cdylib", "rlib"] 41 | -------------------------------------------------------------------------------- /bindings/cpp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022-present, Crypto.com. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /bindings/cpp/README.md: -------------------------------------------------------------------------------- 1 | # defi-wallet-core-cpp 2 | 3 | `defi-wallet-core-cpp` is the c++ bindings for [defi-wallet-core-rs](https://github.com/crypto-com/defi-wallet-core-rs). 4 | -------------------------------------------------------------------------------- /bindings/cpp/build.rs: -------------------------------------------------------------------------------- 1 | const BRIDGES: &[&str] = &[ 2 | "src/lib.rs", 3 | "src/nft.rs", 4 | "src/contract.rs", 5 | "src/ethereum.rs", 6 | "src/uint.rs", 7 | ]; 8 | 9 | // condition compilation for android not working 10 | // #[cfg(target_os = "android")] 11 | // #[cfg(not(target_os = "android"))] 12 | // used env var TARGET instead 13 | fn main() { 14 | cxx_build::CFG.doxygen = true; 15 | let mut command = cxx_build::bridges(BRIDGES); 16 | 17 | command.file("src/nft.cc"); 18 | 19 | let target = std::env::var("TARGET").unwrap(); 20 | let is_android = target.contains("android"); 21 | if is_android { 22 | command.file("src/android.cc"); 23 | } 24 | command.flag_if_supported("-std=c++11"); 25 | command.compile("defi_wallet_core"); 26 | 27 | for bridge in BRIDGES { 28 | println!("cargo:rerun-if-changed={}", bridge); 29 | } 30 | 31 | println!("cargo:rerun-if-changed=src/nft.cc"); 32 | if is_android { 33 | println!("cargo:rerun-if-changed=src/android.cc"); 34 | } 35 | println!("cargo:rerun-if-changed=include/nft.h"); 36 | } 37 | -------------------------------------------------------------------------------- /bindings/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | export NDK_VERSION=25.1.8937393 2 | export API=21 3 | export NDK_HOME=$HOME/Library/Android/sdk/ndk/$NDK_VERSION 4 | export TARGET=aarch64-linux-android 5 | export TOOLCHAIN=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64 6 | export TARGET_CC=$TOOLCHAIN/bin/$TARGET$API-clang 7 | export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++ 8 | export TARGET_AR=$TOOLCHAIN/bin/llvm-ar 9 | export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$TOOLCHAIN/bin/$TARGET$API-clang 10 | export RUSTFLAGS+=" -L`pwd`/../../env/android" 11 | cargo build --target=$TARGET --release 12 | 13 | -------------------------------------------------------------------------------- /bindings/cpp/include/android.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022, Cronos Labs. All Rights Reserved 2 | 3 | #ifdef __ANDROID__ 4 | #include "rust/cxx.h" 5 | #include 6 | namespace org { 7 | namespace defi_wallet_core { 8 | int secureStorageSetJavaEnv( 9 | JNIEnv *userenv); // call this first when android app begins 10 | int secureStorageWrite(rust::String userkey, rust::String uservalue); 11 | rust::String secureStorageRead(rust::String userkey); 12 | } // namespace defi_wallet_core 13 | } // namespace org 14 | #endif 15 | -------------------------------------------------------------------------------- /bindings/cpp/include/nft.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "rust/cxx.h" 3 | #include 4 | 5 | namespace org { 6 | namespace defi_wallet_core { 7 | 8 | /// struct for efficient pagination 9 | struct Pagination { 10 | /// Set true to enable the pagination 11 | /// 12 | /// A workaround filed for enabling pagination. It could be changed to 13 | /// std::optional if https://github.com/dtolnay/cxx/issues/87 14 | /// fixed 15 | bool enable; 16 | /// key is a value returned in PageResponse.next_key to begin 17 | /// querying the next page most efficiently. Only one of offset or key 18 | /// should be set. 19 | rust::Vec key; 20 | /// offset is a numeric offset that can be used when key is 21 | /// unavailable. It is less efficient than using key. Only 22 | /// one of offset or key should be set. 23 | uint64_t offset; 24 | /// limit is the total number of results to be returned in the 25 | /// result page. If left empty it will default to a value to be 26 | /// set by each app. 27 | uint64_t limit; 28 | /// count_total is set to true to indicate that the result set 29 | /// should include a count of the total number of items available 30 | /// for pagination in UIs. count_total is only respected when 31 | /// offset is used. It is ignored when key is set. 32 | bool count_total; 33 | /// reverse is set to true if results are to be 34 | /// returned in the descending order. 35 | /// 36 | /// Since: cosmos-sdk 0.43 37 | bool reverse; 38 | 39 | Pagination(); 40 | 41 | bool get_enable() const; 42 | rust::Vec get_key() const; 43 | uint64_t get_offset() const; 44 | uint64_t get_limit() const; 45 | bool get_count_total() const; 46 | bool get_reverse() const; 47 | }; 48 | 49 | } // namespace defi_wallet_core 50 | } // namespace org 51 | -------------------------------------------------------------------------------- /bindings/cpp/src/nft.cc: -------------------------------------------------------------------------------- 1 | #include "defi-wallet-core-cpp/include/nft.h" 2 | 3 | namespace org { 4 | namespace defi_wallet_core { 5 | Pagination::Pagination() 6 | : enable{false}, offset{0}, limit{100}, count_total{false}, reverse{false} { 7 | } 8 | 9 | bool Pagination::get_enable() const { return enable; } 10 | rust::Vec Pagination::get_key() const { return key; } 11 | uint64_t Pagination::get_offset() const { return offset; } 12 | uint64_t Pagination::get_limit() const { return limit; } 13 | bool Pagination::get_count_total() const { return count_total; } 14 | bool Pagination::get_reverse() const { return reverse; } 15 | } // namespace defi_wallet_core 16 | } // namespace org 17 | -------------------------------------------------------------------------------- /bindings/wasm/.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-unknown-unknown" 3 | 4 | [target.wasm32-unknown-unknown] 5 | runner = 'wasm-bindgen-test-runner' 6 | -------------------------------------------------------------------------------- /bindings/wasm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "defi-wallet-core-wasm" 3 | version = "0.3.6" 4 | edition = "2021" 5 | rust-version = "1.57" 6 | license = "Apache-2.0" 7 | 8 | [lib] 9 | crate-type = ["cdylib", "rlib"] 10 | 11 | [features] 12 | default = ["console_error_panic_hook"] 13 | # This feature is used to restrict test cases of ibc. The ibc cases only be 14 | # tested when running with `--features ibc-test`. 15 | # Since both `--skip` (cargo test) and `#[ignore]` attribute have no effect for 16 | # `wasm-pack test`. So use this feature as an alternative. 17 | ibc-test = [] 18 | cronos-test = [] 19 | 20 | [dependencies] 21 | defi-wallet-core-common = { path = "../../common", features = ["abi-contract"] } 22 | js-sys = "0.3" 23 | serde = { version = "1", features = ["derive"] } 24 | serde-wasm-bindgen = "0.5" 25 | wasm-bindgen-futures = "0.4" 26 | wasm-bindgen = "0.2" 27 | # The `console_error_panic_hook` crate provides better debugging of panics by 28 | # logging them with `console.error`. This is great for development, but requires 29 | # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for 30 | # code size when deploying. 31 | console_error_panic_hook = { version = "0.1", optional = true } 32 | cosmos-sdk-proto = { git = "https://github.com/crypto-com/cosmos-rust.git", default-features = false, features = ["cosmwasm"] } 33 | 34 | tendermint = "0.29" 35 | async-std = "1.12.0" 36 | 37 | [dev-dependencies] 38 | wasm-bindgen-test = "0.3" 39 | ethers = { version = "2.0", features = ["rustls"] } 40 | ethers-addressbook = { version = "2.0"} 41 | ethers-contract = { version = "2.0" } 42 | ethers-core = { version = "2.0" } 43 | ethers-etherscan = { version = "2.0" } 44 | ethers-middleware = { version = "2.0" } 45 | ethers-providers = { version = "2.0"} 46 | ethers-signers = { version = "2.0" } 47 | ethers-solc = { version = "2.0"} 48 | wasm-timer = "0.2" 49 | tendermint-rpc = "0.29" 50 | defi-wallet-core-proto = { version = "0.1", path = "../../proto" } 51 | tonic-web-wasm-client = "0.3" 52 | -------------------------------------------------------------------------------- /bindings/wasm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022-present, Crypto.com. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /bindings/wasm/README.md: -------------------------------------------------------------------------------- 1 | # defi-wallet-core-wasm 2 | 3 | `defi-wallet-core-wasm` is the wasm bindings for [defi-wallet-core-rs](https://github.com/crypto-com/defi-wallet-core-rs). 4 | -------------------------------------------------------------------------------- /bindings/wasm/src/cosmos_sdk/signer.rs: -------------------------------------------------------------------------------- 1 | use crate::PrivateKey; 2 | use defi_wallet_core_common::CosmosSigner; 3 | use wasm_bindgen::prelude::*; 4 | 5 | /// Sign the protobuf bytes directly. 6 | /// As an example, arguments should like: 7 | /// { 8 | /// "chainId": "cosmoshub-4", 9 | /// "accountNumber": "1" 10 | /// "authInfoBytes": "0a0a0a00 ...", 11 | /// "bodyBytes": "0a90010a ...", 12 | /// } 13 | #[wasm_bindgen(js_name = cosmos_signDirect)] 14 | pub fn cosmos_sign_direct( 15 | private_key: PrivateKey, 16 | chain_id: &str, 17 | account_number: &str, 18 | auth_info_bytes: &str, 19 | body_bytes: &str, 20 | ) -> Result { 21 | Ok(CosmosSigner::new(private_key.key).sign_direct( 22 | chain_id, 23 | account_number, 24 | auth_info_bytes, 25 | body_bytes, 26 | )?) 27 | } 28 | -------------------------------------------------------------------------------- /bindings/wasm/src/ethereum/signer.rs: -------------------------------------------------------------------------------- 1 | use crate::PrivateKey; 2 | use defi_wallet_core_common::EthSigner; 3 | use wasm_bindgen::prelude::*; 4 | 5 | /// Sign a hash value directly. 6 | /// Argument `hash` must be a hex value of 32 bytes (H256). 7 | /// Return a signature of hex string with prefix `0x`. 8 | /// The security concern around `eth_sign` is not that the signature could be forged or the key 9 | /// be stolen, but rather a malicious website could trick a user into signing a message that is 10 | /// actually a valid transaction, and use it to steal ether or tokens. 11 | /// `personal_sign` prefixes the message, preventing it from being a valid transaction. Because 12 | /// of this, it is safer for users. 13 | #[wasm_bindgen(js_name = eth_sign)] 14 | pub fn eth_sign_insecure(private_key: PrivateKey, hash: &str) -> Result { 15 | Ok(EthSigner::new(private_key.key).eth_sign_insecure(hash)?) 16 | } 17 | 18 | /// Sign an arbitrary message as per EIP-191. 19 | /// Return a signature of hex string with prefix `0x`. 20 | #[wasm_bindgen] 21 | pub fn personal_sign(private_key: PrivateKey, message: &str) -> String { 22 | EthSigner::new(private_key.key).personal_sign(message) 23 | } 24 | 25 | /// Sign an EIP-712 typed data from a JSON string of specified schema as below. The field 26 | /// `domain`, `message`, `primaryType` and `types` are all mandatory as described in 27 | /// [EIP-712](https://eips.ethereum.org/EIPS/eip-712). 28 | /// Return a signature of hex string with prefix `0x`. 29 | /// 30 | /// { 31 | /// "domain": { 32 | /// "name": "Ether Mail", 33 | /// "version": "1", 34 | /// "chainId": 1, 35 | /// "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" 36 | /// }, 37 | /// "message": { 38 | /// "from": { 39 | /// "name": "Cow", 40 | /// "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826" 41 | /// }, 42 | /// "to": { 43 | /// "name": "Bob", 44 | /// "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" 45 | /// }, 46 | /// "contents": "Hello, Bob!" 47 | /// }, 48 | /// "primaryType": "Mail", 49 | /// "types": { 50 | /// "EIP712Domain": [ 51 | /// { "name": "name", "type": "string" }, 52 | /// { "name": "version", "type": "string" }, 53 | /// { "name": "chainId", "type": "uint256" }, 54 | /// { "name": "verifyingContract", "type": "address" } 55 | /// ], 56 | /// "Mail": [ 57 | /// { "name": "from", "type": "Person" }, 58 | /// { "name": "to", "type": "Person" }, 59 | /// { "name": "contents", "type": "string" } 60 | /// ], 61 | /// "Person": [ 62 | /// { "name": "name", "type": "string" }, 63 | /// { "name": "wallet", "type": "address" } 64 | /// ] 65 | /// } 66 | /// } 67 | #[wasm_bindgen(js_name = eth_signTypedData)] 68 | pub fn eth_sign_typed_data( 69 | private_key: PrivateKey, 70 | json_typed_data: &str, 71 | ) -> Result { 72 | Ok(EthSigner::new(private_key.key).sign_typed_data(json_typed_data)?) 73 | } 74 | -------------------------------------------------------------------------------- /bindings/wasm/src/utils.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::Display; 2 | use wasm_bindgen::prelude::JsValue; 3 | 4 | #[allow(dead_code)] 5 | pub fn set_panic_hook() { 6 | // When the `console_error_panic_hook` feature is enabled, we can call the 7 | // `set_panic_hook` function at least once during initialization, and then 8 | // we will get better error messages if our code ever panics. 9 | // 10 | // For more details see 11 | // https://github.com/rustwasm/console_error_panic_hook#readme 12 | #[cfg(feature = "console_error_panic_hook")] 13 | console_error_panic_hook::set_once(); 14 | } 15 | 16 | #[inline] 17 | pub(crate) fn format_to_js_error(error: E) -> JsValue 18 | where 19 | E: Display, 20 | { 21 | JsValue::from_str(&format!("error: {error}")) 22 | } 23 | -------------------------------------------------------------------------------- /bindings/wasm/tests/account.rs: -------------------------------------------------------------------------------- 1 | //! Test suite for account queries. 2 | 3 | #![cfg(target_arch = "wasm32")] 4 | 5 | mod test_helper; 6 | 7 | use std::assert_eq; 8 | use test_helper::*; 9 | use wasm_bindgen_test::*; 10 | 11 | wasm_bindgen_test_configure!(run_in_browser); 12 | 13 | #[wasm_bindgen_test] 14 | async fn test_query_chainmain_account() { 15 | let account = query_chainmain_account(COMMUNITY).await; 16 | 17 | assert_eq!(account.account_type, "/cosmos.auth.v1beta1.BaseAccount"); 18 | assert_eq!(account.address, COMMUNITY); 19 | } 20 | 21 | #[wasm_bindgen_test] 22 | async fn test_query_chainmain_balance() { 23 | let balance = query_chainmain_balance(COMMUNITY).await; 24 | 25 | assert_eq!(balance.denom, CHAINMAIN_DENOM); 26 | assert!(balance.amount.parse::().unwrap() > 0); 27 | } 28 | -------------------------------------------------------------------------------- /bindings/wasm/tests/bank.rs: -------------------------------------------------------------------------------- 1 | //! Test suite for bank messages. 2 | 3 | #![cfg(target_arch = "wasm32")] 4 | 5 | mod test_helper; 6 | 7 | use defi_wallet_core_common::RawRpcBalance; 8 | use defi_wallet_core_wasm::{CosmosMsg, CosmosTx}; 9 | use ethers::types::U256; 10 | use std::assert_eq; 11 | use test_helper::*; 12 | use wasm_bindgen_futures::JsFuture; 13 | use wasm_bindgen_test::*; 14 | 15 | wasm_bindgen_test_configure!(run_in_browser); 16 | 17 | const BANK_SEND_AMOUNT: u64 = 100; 18 | 19 | #[wasm_bindgen_test] 20 | async fn test_get_single_bank_send_signed_tx() { 21 | let mut tx = CosmosTx::new(); 22 | tx.add_msg(CosmosMsg::build_bank_send_msg( 23 | SIGNER2.to_owned(), 24 | BANK_SEND_AMOUNT, 25 | CHAINMAIN_DENOM.to_owned(), 26 | )); 27 | let signed_data = tx 28 | .sign_into( 29 | get_private_key(SIGNER1_MNEMONIC), 30 | chainmain_tx_info(SIGNER1).await, 31 | ) 32 | .unwrap(); 33 | 34 | let balance1 = query_chainmain_balance(SIGNER2).await; 35 | JsFuture::from(chainmain_client().broadcast_tx(signed_data)) 36 | .await 37 | .unwrap(); 38 | wait_for_timeout(None).await; 39 | let balance2 = query_chainmain_balance(SIGNER2).await; 40 | 41 | assert_eq!( 42 | balance2, 43 | RawRpcBalance { 44 | denom: CHAINMAIN_DENOM.to_owned(), 45 | amount: (U256::from_dec_str(&balance1.amount).unwrap() + BANK_SEND_AMOUNT).to_string() 46 | } 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /bindings/wasm/tests/ethereum.rs: -------------------------------------------------------------------------------- 1 | //! Test suite for ethereum transactions. 2 | 3 | #![cfg(target_arch = "wasm32")] 4 | #![cfg(feature = "cronos-test")] 5 | 6 | mod test_helper; 7 | use defi_wallet_core_wasm::{ 8 | broadcast_eth_signed_raw_tx, broadcast_transfer_eth, build_signed_eth_tx, 9 | get_eth_transaction_count, query_account_eth_balance, CoinType, EthTxAmount, EthTxInfo, Wallet, 10 | }; 11 | use test_helper::*; 12 | use wasm_bindgen_test::*; 13 | use wasm_timer::Instant; 14 | 15 | use js_sys::BigInt; 16 | 17 | wasm_bindgen_test_configure!(run_in_browser); 18 | #[wasm_bindgen_test] 19 | async fn test_ethereum() { 20 | let from_wallet = Wallet::recover_wallet(SIGNER1_MNEMONIC.to_owned(), None).unwrap(); 21 | let from_address = from_wallet.get_default_address(CoinType::Cronos).unwrap(); 22 | let private_key = from_wallet.get_key_from_index(CoinType::Cronos, 0).unwrap(); 23 | let to_wallet = Wallet::recover_wallet(SIGNER2_MNEMONIC.to_owned(), None).unwrap(); 24 | let to_address = to_wallet.get_default_address(CoinType::Cronos).unwrap(); 25 | let now = Instant::now(); 26 | let initial_balance: BigInt = 27 | query_account_eth_balance(CRONOS_RPC_URL.to_owned(), to_address.clone()) 28 | .await 29 | .unwrap(); 30 | broadcast_transfer_eth( 31 | CRONOS_RPC_URL.to_owned(), 32 | to_address.clone(), 33 | EthTxAmount::new("100".to_owned(), "wei".to_owned()), 34 | 777, 35 | 4000, 36 | true, 37 | private_key.clone(), 38 | ) 39 | .await 40 | .unwrap(); 41 | let second_balance: BigInt = 42 | query_account_eth_balance(CRONOS_RPC_URL.to_owned(), to_address.clone()) 43 | .await 44 | .unwrap(); 45 | assert_eq!(second_balance, initial_balance + BigInt::from(100)); 46 | assert!(now.elapsed().as_millis() > 4000); // test the interval works 47 | 48 | let nonce = get_eth_transaction_count(from_address, CRONOS_RPC_URL.to_string()) 49 | .await 50 | .unwrap(); 51 | let eth_tx_info = EthTxInfo::new( 52 | to_address.clone().into(), 53 | EthTxAmount::new("1".to_owned(), "gwei".to_owned()), 54 | nonce, 55 | BigInt::from(21000), 56 | EthTxAmount::new("7".to_owned(), "wei".to_owned()), 57 | None, 58 | true, 59 | ); 60 | let raw_tx = build_signed_eth_tx(eth_tx_info, 777, private_key).unwrap(); 61 | broadcast_eth_signed_raw_tx(raw_tx, CRONOS_RPC_URL.to_string(), 4000) 62 | .await 63 | .unwrap(); 64 | 65 | let final_balance: BigInt = 66 | query_account_eth_balance(CRONOS_RPC_URL.to_owned(), to_address.clone()) 67 | .await 68 | .unwrap(); 69 | assert_eq!(final_balance, second_balance + BigInt::from(1000000000)); 70 | } 71 | -------------------------------------------------------------------------------- /bindings/wasm/tests/ibc.rs: -------------------------------------------------------------------------------- 1 | //! Test suite for ibc messages. 2 | 3 | #![cfg(target_arch = "wasm32")] 4 | #![cfg(feature = "ibc-test")] 5 | 6 | mod test_helper; 7 | 8 | use core::time::Duration; 9 | use defi_wallet_core_common::RawRpcBalance; 10 | use defi_wallet_core_wasm::{CosmosMsg, CosmosTx}; 11 | use ethers::types::U256; 12 | use test_helper::*; 13 | use wasm_bindgen_futures::JsFuture; 14 | use wasm_bindgen_test::*; 15 | use wasm_timer::{SystemTime, UNIX_EPOCH}; 16 | 17 | // basecro is a 8 decimals token and basetcro is a 18 decimals token 18 | const DECIMAL_RATIO: u64 = 10_u64.pow(10); // basetcro to basecro 19 | 20 | const TRANSFER_AMOUNT: u64 = 5; // basecro 21 | 22 | wasm_bindgen_test_configure!(run_in_browser); 23 | 24 | // This test case only tests if message `MsgTransfer` could be processed for now. 25 | // Need to wait ibc configuration for full test. 26 | #[wasm_bindgen_test] 27 | async fn test_transfer() { 28 | let balance1 = query_cronos_balance(CRONOS_DELEGATOR1).await; 29 | send_transfer_msg().await; 30 | let balance2 = query_cronos_balance(CRONOS_DELEGATOR1).await; 31 | 32 | assert_eq!( 33 | balance2, 34 | RawRpcBalance { 35 | denom: CRONOS_DENOM.to_owned(), 36 | amount: (U256::from_dec_str(&balance1.amount).unwrap() 37 | + TRANSFER_AMOUNT * DECIMAL_RATIO) 38 | .to_string(), 39 | } 40 | ); 41 | } 42 | 43 | async fn send_transfer_msg() { 44 | let time_now = SystemTime::now(); 45 | let timeout = time_now.duration_since(UNIX_EPOCH).unwrap() + Duration::new(120, 0); 46 | 47 | let mut tx = CosmosTx::new(); 48 | tx.add_msg(CosmosMsg::build_ibc_transfer_msg( 49 | CRONOS_DELEGATOR1.to_owned(), 50 | "transfer".to_owned(), 51 | "channel-0".to_owned(), 52 | CHAINMAIN_DENOM.to_owned(), 53 | 5, 54 | 0, 55 | 0, 56 | timeout.as_nanos().try_into().unwrap(), 57 | )); 58 | let signed_data = tx 59 | .sign_into( 60 | get_private_key(SIGNER1_MNEMONIC), 61 | chainmain_tx_info(SIGNER1).await, 62 | ) 63 | .unwrap(); 64 | 65 | JsFuture::from(chainmain_client().broadcast_tx(signed_data)) 66 | .await 67 | .unwrap(); 68 | wait_for_timeout(Some(6)).await; 69 | } 70 | -------------------------------------------------------------------------------- /checkmac.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # to fix link error on macosx 3 | # cd example/cpp-example 4 | # otool -l libcxxbridge1.a > out 5 | # otool -l libdefi_wallet_core_cpp.dylib > out 6 | # check LC_BUILD_VERSION/minos is 10.15 7 | if [[ $(uname) == "Darwin" ]]; then 8 | export MACOSX_DEPLOYMENT_TARGET=10.15 9 | echo "MACOSX_DEPLOYMENT_TARGET="$MACOSX_DEPLOYMENT_TARGET 10 | fi 11 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd mobile_modules/android_module || exit 1 3 | ./gradlew clean || exit 1 4 | cd - 5 | 6 | cd example/android_example || exit 1 7 | make clean 8 | cd - 9 | 10 | cd mobile_modules/ios_module/dwclib || exit 1 11 | xcodebuild SYMROOT="./build" clean 12 | cd - 13 | 14 | rm -f mobile_modules/ios_module/lib.a/* || exit 1 15 | cd example/ios-example || exit 1 16 | make clean 17 | cd - 18 | 19 | rm -rf bindings/wasm/target 20 | rm -rf bindings/wasm/pkg/* 21 | rm -rf example/extension-example/node_modules 22 | rm -rf example/js-example/node_modules 23 | -------------------------------------------------------------------------------- /common/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022-present, Crypto.com. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /common/README.md: -------------------------------------------------------------------------------- 1 | # defi-wallet-core-common 2 | 3 | `defi-wallet-core-common` is the common module of [defi-wallet-core-rs](https://github.com/crypto-com/defi-wallet-core-rs). 4 | -------------------------------------------------------------------------------- /common/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | #[cfg(feature = "uniffi-binding")] 3 | uniffi_build::generate_scaffolding("./src/common.udl").unwrap(); 4 | } 5 | -------------------------------------------------------------------------------- /common/src/contract/erc4907-abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": true, 7 | "internalType": "uint256", 8 | "name": "tokenId", 9 | "type": "uint256" 10 | }, 11 | { 12 | "indexed": true, 13 | "internalType": "address", 14 | "name": "user", 15 | "type": "address" 16 | }, 17 | { 18 | "indexed": false, 19 | "internalType": "uint64", 20 | "name": "expires", 21 | "type": "uint64" 22 | } 23 | ], 24 | "name": "UpdateUser", 25 | "type": "event" 26 | }, 27 | { 28 | "inputs": [ 29 | { 30 | "internalType": "uint256", 31 | "name": "tokenId", 32 | "type": "uint256" 33 | }, 34 | { 35 | "internalType": "address", 36 | "name": "user", 37 | "type": "address" 38 | }, 39 | { 40 | "internalType": "uint64", 41 | "name": "expires", 42 | "type": "uint64" 43 | } 44 | ], 45 | "name": "setUser", 46 | "outputs": [], 47 | "stateMutability": "nonpayable", 48 | "type": "function" 49 | }, 50 | { 51 | "inputs": [ 52 | { 53 | "internalType": "uint256", 54 | "name": "tokenId", 55 | "type": "uint256" 56 | } 57 | ], 58 | "name": "userExpires", 59 | "outputs": [ 60 | { 61 | "internalType": "uint256", 62 | "name": "", 63 | "type": "uint256" 64 | } 65 | ], 66 | "stateMutability": "view", 67 | "type": "function" 68 | }, 69 | { 70 | "inputs": [ 71 | { 72 | "internalType": "uint256", 73 | "name": "tokenId", 74 | "type": "uint256" 75 | } 76 | ], 77 | "name": "userOf", 78 | "outputs": [ 79 | { 80 | "internalType": "address", 81 | "name": "", 82 | "type": "address" 83 | } 84 | ], 85 | "stateMutability": "view", 86 | "type": "function" 87 | } 88 | ] -------------------------------------------------------------------------------- /common/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(ambiguous_glob_reexports)] 2 | /// Eth contract types generated from ABI 3 | pub mod contract; 4 | /// interactions with remote node RPC / API (querying, broadcast etc.) 5 | pub mod node; 6 | /// transaction building etc. 7 | pub mod transaction; 8 | /// HD wallet-related functionality 9 | mod wallet; 10 | 11 | /// Login module: signing using EIP-4361 on Ethereum or ADR-036 on Cosmos SDK 12 | #[cfg(feature = "login")] 13 | mod login; 14 | 15 | /// QR code module: encoding and decoding of EIP-681 strings 16 | #[cfg(feature = "qr-code")] 17 | mod qr_code; 18 | 19 | /// Utility functions 20 | pub mod utils; 21 | 22 | // expose all proto related types (e.g. for uniffi) 23 | pub use cosmos_sdk_proto::cosmos::base::query::v1beta1::PageRequest; 24 | pub use defi_wallet_core_proto as proto; 25 | pub use proto::chainmain::nft::v1::*; 26 | pub use proto::luna_classic::wasm::v1beta1::*; 27 | 28 | pub use cosmrs::{tx::Msg, AccountId, Coin}; 29 | pub use eyre::{Report as ErrorReport, Result}; 30 | pub use ibc_proto::ibc::core::client::v1::Height; 31 | 32 | #[cfg(feature = "login")] 33 | pub use login::*; 34 | pub use node::*; 35 | #[cfg(feature = "qr-code")] 36 | pub use qr_code::EIP681Request; 37 | pub use transaction::*; 38 | pub use wallet::*; 39 | #[cfg(feature = "uniffi-binding")] 40 | uniffi_macros::include_scaffolding!("common"); 41 | 42 | #[macro_use] 43 | mod macros; 44 | -------------------------------------------------------------------------------- /common/src/macros.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! msg_wrapper { 3 | ($(#[$outer:meta])* 4 | $path:path => 5 | 6 | pub struct $name:ident {$($(#[$inner:meta])* pub $element: ident: $ty: ty),* $(,)? }) => { 7 | $(#[$outer])* 8 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 9 | pub struct $name { 10 | $($(#[$inner])* pub $element: $ty),* 11 | } 12 | 13 | impl Msg for $name { 14 | type Proto = $path; 15 | } 16 | 17 | impl TryFrom<$path> for $name { 18 | type Error = ErrorReport; 19 | 20 | fn try_from(proto: $path) -> Result<$name> { 21 | $name::try_from(&proto) 22 | } 23 | } 24 | 25 | impl TryFrom<&$path> for $name { 26 | type Error = ErrorReport; 27 | 28 | fn try_from(proto: &$path) -> Result<$name> { 29 | Ok($name { 30 | $($element: proto.$element.parse()?),* 31 | }) 32 | } 33 | } 34 | 35 | impl From<$name> for $path { 36 | fn from(denom: $name) -> $path { 37 | <$path>::from(&denom) 38 | } 39 | } 40 | 41 | impl From<&$name> for $path { 42 | fn from(msg: &$name) -> $path { 43 | $path { 44 | $($element: msg.$element.to_string()),* 45 | } 46 | } 47 | } 48 | 49 | 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /common/src/node.rs: -------------------------------------------------------------------------------- 1 | #![allow(ambiguous_glob_reexports)] 2 | 3 | /// wrappers around Cosmos SDK REST API and Tendermint RPC 4 | /// FIXME: switch to grpc when grpc-web works in CosmRS: https://github.com/cosmos/cosmos-rust/pull/157 5 | mod cosmos_sdk; 6 | /// wrappers around Web3 API + basic contract types 7 | pub mod ethereum; 8 | /// wrappers around chainmain NFT grpc/grpc-web API 9 | pub mod nft; 10 | /// wasm binding related functions 11 | mod wasm_binding; 12 | 13 | mod error; 14 | pub use cosmos_sdk::*; 15 | pub use error::*; 16 | pub use ethereum::*; 17 | pub use nft::*; 18 | #[cfg(target_arch = "wasm32")] 19 | pub use wasm_binding::*; 20 | -------------------------------------------------------------------------------- /common/src/node/cosmos_sdk/balance_query.rs: -------------------------------------------------------------------------------- 1 | use crate::RestError; 2 | use cosmos_sdk_proto::cosmos::bank::v1beta1::query_client::QueryClient; 3 | use cosmos_sdk_proto::cosmos::bank::v1beta1::{QueryBalanceRequest, QueryBalanceResponse}; 4 | use serde::{Deserialize, Serialize}; 5 | 6 | /// The raw balance data from the balance API 7 | #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] 8 | pub struct RawRpcBalance { 9 | /// denomination 10 | pub denom: String, 11 | /// the decimal number of coins of a given denomination 12 | pub amount: String, 13 | } 14 | 15 | impl From for RawRpcBalance { 16 | fn from(response: QueryBalanceResponse) -> Self { 17 | let balance = response.balance.unwrap_or_default(); 18 | Self { 19 | amount: balance.amount, 20 | denom: balance.denom, 21 | } 22 | } 23 | } 24 | 25 | /// return the balance (async for JS/WASM) 26 | #[cfg(target_arch = "wasm32")] 27 | pub async fn get_account_balance( 28 | grpc_web_url: &str, 29 | address: &str, 30 | denom: &str, 31 | ) -> Result { 32 | let mut client = QueryClient::new(tonic_web_wasm_client::Client::new(grpc_web_url.to_string())); 33 | let request = QueryBalanceRequest { 34 | address: address.to_string(), 35 | denom: denom.to_string(), 36 | }; 37 | Ok(client 38 | .balance(request) 39 | .await 40 | .map_err(RestError::GRPCError)? 41 | .into_inner() 42 | .into()) 43 | } 44 | 45 | /// return the balance (blocking for other platforms; 46 | /// platform-guarded as JS/WASM doesn't support the reqwest blocking) 47 | #[cfg(not(target_arch = "wasm32"))] 48 | pub fn get_account_balance_blocking( 49 | grpc_url: &str, 50 | address: &str, 51 | denom: &str, 52 | ) -> Result { 53 | tokio::runtime::Runtime::new() 54 | .map_err(|_err| RestError::AsyncRuntimeError)? 55 | .block_on(async move { 56 | let mut client = QueryClient::connect(grpc_url.to_string()) 57 | .await 58 | .map_err(RestError::GRPCTransportError)?; 59 | let request = QueryBalanceRequest { 60 | address: address.to_string(), 61 | denom: denom.to_string(), 62 | }; 63 | Ok(client 64 | .balance(request) 65 | .await 66 | .map_err(RestError::GRPCError)? 67 | .into_inner() 68 | .into()) 69 | }) 70 | } 71 | -------------------------------------------------------------------------------- /common/src/node/error.rs: -------------------------------------------------------------------------------- 1 | /// wrapper around API errors 2 | #[derive(Debug, thiserror::Error)] 3 | pub enum RestError { 4 | #[error("HTTP request error: {0}")] 5 | RequestError(reqwest::Error), 6 | #[error("Missing result in the JSON-RPC response")] 7 | MissingResult, 8 | #[error("Async Runtime error")] 9 | AsyncRuntimeError, 10 | #[cfg(not(target_arch = "wasm32"))] 11 | #[error("gRPC transport error: {0}")] 12 | GRPCTransportError(tonic::transport::Error), 13 | #[error("gRPC error: {0}")] 14 | GRPCError(tonic::Status), 15 | #[error("ErrorReport")] 16 | ErrorReport, 17 | } 18 | -------------------------------------------------------------------------------- /common/src/node/ethereum.rs: -------------------------------------------------------------------------------- 1 | pub mod abi; 2 | pub mod eip712; 3 | pub mod erc1155; 4 | pub mod erc20; 5 | #[cfg(feature = "erc4907")] 6 | pub mod erc4907; 7 | pub mod erc721; 8 | pub mod provider; 9 | pub mod utils; 10 | pub use utils::*; 11 | -------------------------------------------------------------------------------- /common/src/node/ethereum/erc4907.rs: -------------------------------------------------------------------------------- 1 | use crate::contract::{Contract, ContractCall}; 2 | use crate::provider::get_ethers_provider; 3 | use crate::{u256_from_str, EthError}; 4 | use ethers::prelude::{Address, U256}; 5 | 6 | pub async fn get_user_expires( 7 | contract_address: &str, 8 | token_id: &str, 9 | web3api_url: &str, 10 | ) -> Result { 11 | let client = get_ethers_provider(web3api_url).await?; 12 | let contract = Contract::new_erc4907(contract_address, client)?; 13 | let token_id = u256_from_str(token_id)?; 14 | let call = contract.user_expires(token_id); 15 | ContractCall::from(call).call().await 16 | } 17 | 18 | #[cfg(not(target_arch = "wasm32"))] 19 | pub fn get_user_expires_blocking( 20 | contract_address: &str, 21 | token_id: &str, 22 | web3api_url: &str, 23 | ) -> Result { 24 | let rt = tokio::runtime::Runtime::new().map_err(|_err| EthError::AsyncRuntimeError)?; 25 | rt.block_on(get_user_expires(contract_address, token_id, web3api_url)) 26 | } 27 | 28 | pub async fn get_user_of( 29 | contract_address: &str, 30 | token_id: &str, 31 | web3api_url: &str, 32 | ) -> Result { 33 | let client = get_ethers_provider(web3api_url).await?; 34 | let contract = Contract::new_erc4907(contract_address, client)?; 35 | let token_id = u256_from_str(token_id)?; 36 | let call = contract.user_of(token_id); 37 | ContractCall::from(call).call().await 38 | } 39 | 40 | #[cfg(not(target_arch = "wasm32"))] 41 | pub fn get_user_of_blocking( 42 | contract_address: &str, 43 | token_id: &str, 44 | web3api_url: &str, 45 | ) -> Result { 46 | let rt = tokio::runtime::Runtime::new().map_err(|_err| EthError::AsyncRuntimeError)?; 47 | rt.block_on(get_user_of(contract_address, token_id, web3api_url)) 48 | } 49 | -------------------------------------------------------------------------------- /common/src/node/ethereum/provider.rs: -------------------------------------------------------------------------------- 1 | use crate::EthError; 2 | use ethers::providers::{Http, Provider}; 3 | #[cfg(not(target_arch = "wasm32"))] 4 | use std::time::Duration; 5 | use url::Url; 6 | 7 | #[cfg(not(target_arch = "wasm32"))] 8 | use once_cell::sync::OnceCell; 9 | #[cfg(not(target_arch = "wasm32"))] 10 | static G_AGENTINFO: OnceCell = OnceCell::new(); 11 | 12 | #[cfg(not(target_arch = "wasm32"))] 13 | pub fn set_ethers_httpagent(agent: &str) -> Result<(), EthError> { 14 | if G_AGENTINFO.get().is_none() { 15 | if G_AGENTINFO.set(agent.to_string()).is_err() { 16 | return Err(EthError::HttpAgentError); 17 | } 18 | return Ok(()); 19 | } 20 | Err(EthError::HttpAgentError) 21 | } 22 | 23 | // urlinfo: url string of the node to connect to, "http://mynode:8545" 24 | // agentinfo: agent string for http header 25 | pub async fn get_ethers_provider(urlinfo: &str) -> Result, EthError> { 26 | let url = Url::parse(urlinfo).map_err(EthError::NodeUrl)?; 27 | 28 | #[cfg(target_arch = "wasm32")] 29 | let client = reqwest::Client::builder() 30 | .build() 31 | .map_err(EthError::ClientError)?; 32 | 33 | #[cfg(not(target_arch = "wasm32"))] 34 | let client = { 35 | match G_AGENTINFO.get() { 36 | Some(v) => reqwest::Client::builder() 37 | .user_agent(v) 38 | .timeout(Duration::from_millis(60000)) 39 | .build() 40 | .map_err(EthError::ClientError)?, 41 | None => reqwest::Client::builder() 42 | .user_agent( 43 | std::env::var("DEFIWALLETCORE_AGENTINFO") 44 | .unwrap_or_else(|_| "defiwalletcore".to_string()), 45 | ) 46 | .timeout(Duration::from_millis(60000)) 47 | .build() 48 | .map_err(EthError::ClientError)?, 49 | } 50 | }; 51 | 52 | let httpprovider = Http::new_with_client(url, client); 53 | let finalprovider = Provider::new(httpprovider); 54 | Ok(finalprovider) 55 | } 56 | -------------------------------------------------------------------------------- /common/src/node/wasm_binding.rs: -------------------------------------------------------------------------------- 1 | #![cfg(target_arch = "wasm32")] 2 | 3 | use crate::RestError; 4 | use wasm_bindgen::JsValue; 5 | 6 | impl From for JsValue { 7 | fn from(e: RestError) -> Self { 8 | JsValue::from_str(&format!("error: {}", e)) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /common/src/transaction.rs: -------------------------------------------------------------------------------- 1 | /// wrapper and helpers for CosmRS 2 | mod cosmos_sdk; 3 | /// wrapper and helpers for ethers 4 | mod ethereum; 5 | /// wrapper and helpers for LunaClassic chain 6 | mod luna_classic; 7 | /// wrapper and helper for NFT functionality 8 | pub mod nft; 9 | /// UniFFI binding related functions 10 | mod uniffi_binding; 11 | /// wasm binding related functions 12 | mod wasm_binding; 13 | 14 | pub use cosmos_sdk::*; 15 | pub use ethereum::*; 16 | pub use nft::*; 17 | #[cfg(feature = "uniffi-binding")] 18 | pub use uniffi_binding::*; 19 | #[cfg(target_arch = "wasm32")] 20 | pub use wasm_binding::*; 21 | -------------------------------------------------------------------------------- /common/src/transaction/cosmos_sdk/parser/luna_classic_parser.rs: -------------------------------------------------------------------------------- 1 | use crate::transaction::cosmos_sdk::parser::base_parser::BaseParser; 2 | use crate::transaction::cosmos_sdk::parser::structs::{CosmosRawMsg, CosmosTxBody}; 3 | use crate::transaction::cosmos_sdk::parser::CosmosParser; 4 | use crate::transaction::cosmos_sdk::CosmosError; 5 | use eyre::WrapErr; 6 | 7 | /// Cosmos parser for `LunaClassic` chain 8 | pub(crate) struct LunaClassicParser { 9 | pub base: BaseParser, 10 | } 11 | 12 | impl CosmosParser for LunaClassicParser { 13 | fn parse_proto_json_msg(&self, json_string: &str) -> Result { 14 | // TODO: Process `LunaClassic` special messages. 15 | Ok(CosmosRawMsg::Normal { 16 | msg: serde_json::from_str(json_string) 17 | .wrap_err("Failed to decode CosmosRawMsg from proto JSON mapping")?, 18 | }) 19 | } 20 | 21 | fn transform_tx_body(&self, tx_body: &mut CosmosTxBody) -> Result<(), CosmosError> { 22 | // TODO: Process `LunaClassic` special messages. 23 | self.base.transform_tx_body(tx_body) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/transaction/cosmos_sdk/parser/uniffi_binding.rs: -------------------------------------------------------------------------------- 1 | #![cfg(feature = "uniffi-binding")] 2 | 3 | use crate::transaction::cosmos_sdk::parser::base_parser::BaseParser; 4 | use crate::transaction::cosmos_sdk::parser::crypto_org_parser::CryptoOrgParser; 5 | use crate::transaction::cosmos_sdk::parser::luna_classic_parser::LunaClassicParser; 6 | use crate::transaction::cosmos_sdk::parser::structs::{ 7 | CosmosAuthInfo, CosmosFee, CosmosRawMsg, CosmosTxBody, 8 | }; 9 | use crate::transaction::cosmos_sdk::parser::CosmosParser; 10 | use crate::transaction::cosmos_sdk::CosmosError; 11 | 12 | pub struct CosmosParserWrapper { 13 | inner: Box, 14 | } 15 | 16 | impl CosmosParserWrapper { 17 | /// Create a base parser for decoding standard Cosmos messages. 18 | pub fn new_base_parser() -> Self { 19 | Self { 20 | inner: Box::new(BaseParser {}), 21 | } 22 | } 23 | 24 | /// Create a Cosmos parser for `crypto.org` chain. 25 | pub fn new_crypto_org_parser() -> Self { 26 | Self { 27 | inner: Box::new(CryptoOrgParser { 28 | base: BaseParser {}, 29 | }), 30 | } 31 | } 32 | 33 | /// Create a Cosmos parser for `LunaClassic` chain. 34 | pub fn new_luna_classic_parser() -> Self { 35 | Self { 36 | inner: Box::new(LunaClassicParser { 37 | base: BaseParser {}, 38 | }), 39 | } 40 | } 41 | 42 | /// Parse `CosmosFee` from data of proto JSON mapping. 43 | pub fn parse_proto_json_fee(&self, json_string: &str) -> Result { 44 | self.inner.parse_proto_json_fee(json_string) 45 | } 46 | 47 | /// Parse `CosmosRawMsg` from data of proto JSON mapping. 48 | pub fn parse_proto_json_msg(&self, json_string: &str) -> Result { 49 | self.inner.parse_proto_json_msg(json_string) 50 | } 51 | 52 | /// Parse `CosmosAuthInfo` from hex data of Protobuf. 53 | pub fn parse_protobuf_auto_info( 54 | &self, 55 | hex_string: &str, 56 | ) -> Result { 57 | self.inner.parse_protobuf_auto_info(hex_string) 58 | } 59 | 60 | /// Parse `CosmosTxBody` from hex data of Protobuf. 61 | pub fn parse_protobuf_tx_body(&self, hex_string: &str) -> Result { 62 | self.inner.parse_protobuf_tx_body(hex_string) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /common/src/transaction/luna_classic.rs: -------------------------------------------------------------------------------- 1 | mod wasm; 2 | 3 | pub use wasm::*; 4 | -------------------------------------------------------------------------------- /common/src/transaction/luna_classic/wasm.rs: -------------------------------------------------------------------------------- 1 | // ! Luna Classic wasm module support 2 | 3 | use crate::{proto, AccountId, Coin, ErrorReport, Msg, Result}; 4 | 5 | /// MsgExecuteContract submits the given message data to a smart contract 6 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 7 | pub struct MsgExecuteContract { 8 | /// Sender is the that actor that signed the messages 9 | pub sender: AccountId, 10 | 11 | /// Contract is the address of the smart contract 12 | pub contract: AccountId, 13 | 14 | /// ExecuteMsg json encoded message to be passed to the contract 15 | pub execute_msg: Vec, 16 | 17 | /// Coins that are transferred to the contract on execution 18 | pub coins: Vec, 19 | } 20 | 21 | impl Msg for MsgExecuteContract { 22 | type Proto = proto::luna_classic::wasm::v1beta1::MsgExecuteContract; 23 | } 24 | 25 | impl TryFrom for MsgExecuteContract { 26 | type Error = ErrorReport; 27 | 28 | fn try_from( 29 | proto: proto::luna_classic::wasm::v1beta1::MsgExecuteContract, 30 | ) -> Result { 31 | Ok(MsgExecuteContract { 32 | sender: proto.sender.parse()?, 33 | contract: proto.contract.parse()?, 34 | execute_msg: proto.execute_msg.into_iter().map(Into::into).collect(), 35 | coins: proto 36 | .coins 37 | .iter() 38 | .map(TryFrom::try_from) 39 | .collect::>()?, 40 | }) 41 | } 42 | } 43 | 44 | impl From for proto::luna_classic::wasm::v1beta1::MsgExecuteContract { 45 | fn from(msg: MsgExecuteContract) -> proto::luna_classic::wasm::v1beta1::MsgExecuteContract { 46 | proto::luna_classic::wasm::v1beta1::MsgExecuteContract { 47 | sender: msg.sender.to_string(), 48 | contract: msg.contract.to_string(), 49 | execute_msg: msg.execute_msg, 50 | coins: msg.coins.iter().map(Into::into).collect(), 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /common/src/transaction/uniffi_binding.rs: -------------------------------------------------------------------------------- 1 | #![cfg(feature = "uniffi-binding")] 2 | 3 | use crate::{ 4 | PublicKeyBytesError, PublicKeyBytesWrapper, UniffiCustomTypeConverter, 5 | COMPRESSED_SECP256K1_PUBKEY_SIZE, 6 | }; 7 | 8 | impl UniffiCustomTypeConverter for PublicKeyBytesWrapper { 9 | type Builtin = Vec; 10 | 11 | fn into_custom(val: Self::Builtin) -> uniffi::Result { 12 | if val.len() != COMPRESSED_SECP256K1_PUBKEY_SIZE { 13 | Err(PublicKeyBytesError::InvalidLength.into()) 14 | } else { 15 | Ok(PublicKeyBytesWrapper(val)) 16 | } 17 | } 18 | 19 | fn from_custom(obj: Self) -> Self::Builtin { 20 | obj.0 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/transaction/wasm_binding.rs: -------------------------------------------------------------------------------- 1 | #![cfg(target_arch = "wasm32")] 2 | 3 | use crate::{CosmosError, EthError}; 4 | use wasm_bindgen::JsValue; 5 | 6 | impl From for JsValue { 7 | fn from(error: CosmosError) -> Self { 8 | JsValue::from_str(&format!("error: {error}")) 9 | } 10 | } 11 | 12 | impl From for JsValue { 13 | fn from(error: EthError) -> Self { 14 | JsValue::from_str(&format!("error: {error}")) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/utils.rs: -------------------------------------------------------------------------------- 1 | use ethers::utils::hex::{self, FromHexError}; 2 | 3 | pub(crate) fn hex_decode(hex_string: &str) -> Result, FromHexError> { 4 | let hex_string = hex_string.strip_prefix("0x").unwrap_or(hex_string); 5 | hex::decode(hex_string) 6 | } 7 | 8 | #[cfg(test)] 9 | mod utils_tests { 10 | use super::*; 11 | 12 | #[test] 13 | fn test_utils_hex_decoding() { 14 | let hex_string = "0xaf6f293f2621bfb5a70d7cf123596bd14827f73769c24edf2688b3ce2c86d747"; 15 | let decoded_data = hex_decode(hex_string).unwrap(); 16 | assert_eq!( 17 | decoded_data, 18 | [ 19 | 175, 111, 41, 63, 38, 33, 191, 181, 167, 13, 124, 241, 35, 89, 107, 209, 72, 39, 20 | 247, 55, 105, 194, 78, 223, 38, 136, 179, 206, 44, 134, 215, 71 21 | ] 22 | ); 23 | 24 | assert_eq!(hex_decode(&hex_string[2..]).unwrap(), decoded_data); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/wallet/wasm_binding.rs: -------------------------------------------------------------------------------- 1 | #![cfg(target_arch = "wasm32")] 2 | 3 | use crate::{HdWrapError, SecretKeyWrapError}; 4 | use wasm_bindgen::JsValue; 5 | 6 | impl From for JsValue { 7 | fn from(error: HdWrapError) -> Self { 8 | JsValue::from_str(&format!("error: {error}")) 9 | } 10 | } 11 | 12 | impl From for JsValue { 13 | fn from(error: SecretKeyWrapError) -> Self { 14 | JsValue::from_str(&format!("error: {error}")) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/uniffi-bindgen.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | #[cfg(feature = "uniffi-bindgen")] 3 | uniffi::uniffi_bindgen_main() 4 | } 5 | -------------------------------------------------------------------------------- /common/uniffi.toml: -------------------------------------------------------------------------------- 1 | [bindings.kotlin] 2 | package_name = "com.defi.wallet.core.common" 3 | cdylib_name = "dwc-common" 4 | 5 | [bindings.swift] 6 | ffi_module_name = "DefiWalletCore" 7 | ffi_module_filename = "dwc_commonFFI" 8 | generate_module_map = false 9 | 10 | [bindings.python] 11 | cdylib_name = "defi_wallet_core_common" -------------------------------------------------------------------------------- /contracts/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /typechain 3 | /artifacts/* 4 | /cache 5 | 6 | !/artifacts 7 | /artifacts/* 8 | !/artifacts/contracts 9 | -------------------------------------------------------------------------------- /contracts/artifacts/contracts/TestERC1155.sol/TestERC1155.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../build-info/d47a5bee32a453c731079176807a1bfc.json" 4 | } 5 | -------------------------------------------------------------------------------- /contracts/artifacts/contracts/TestERC20.sol/TestERC20.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../build-info/d47a5bee32a453c731079176807a1bfc.json" 4 | } 5 | -------------------------------------------------------------------------------- /contracts/artifacts/contracts/TestERC721.sol/TestERC721.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../build-info/d47a5bee32a453c731079176807a1bfc.json" 4 | } 5 | -------------------------------------------------------------------------------- /contracts/contracts/GameERC721.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.2; 2 | 3 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 4 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; 5 | import "@openzeppelin/contracts/access/Ownable.sol"; 6 | import "@openzeppelin/contracts/utils/Counters.sol"; 7 | 8 | contract GameERC721 is ERC721, ERC721URIStorage, Ownable { 9 | using Counters for Counters.Counter; 10 | 11 | Counters.Counter public _tokenIdCounter; 12 | 13 | constructor() ERC721("MyArt", "ART") {} 14 | 15 | function _baseURI() internal pure override returns (string memory) { 16 | return "https://example.com/nft/"; 17 | } 18 | 19 | function safeMint(address to, string memory uri) public onlyOwner { 20 | uint256 tokenId = _tokenIdCounter.current(); 21 | _tokenIdCounter.increment(); 22 | _safeMint(to, tokenId); 23 | _setTokenURI(tokenId, uri); 24 | } 25 | 26 | // The following functions are overrides required by Solidity. 27 | 28 | function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { 29 | super._burn(tokenId); 30 | } 31 | 32 | function tokenURI(uint256 tokenId) 33 | public 34 | view 35 | override(ERC721, ERC721URIStorage) 36 | returns (string memory) 37 | { 38 | return super.tokenURI(tokenId); 39 | } 40 | } -------------------------------------------------------------------------------- /contracts/contracts/TestERC1155.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; 4 | 5 | contract TestERC1155 is ERC1155 { 6 | uint256 public constant GOLD = 0; 7 | uint256 public constant SILVER = 1; 8 | uint256 public constant THORS_HAMMER = 2; 9 | uint256 public constant SWORD = 3; 10 | uint256 public constant SHIELD = 4; 11 | 12 | constructor() ERC1155("https://game.example/api/item/{id}.json") { 13 | _mint(msg.sender, GOLD, 10**18, ""); 14 | _mint(msg.sender, SILVER, 10**27, ""); 15 | _mint(msg.sender, THORS_HAMMER, 1, ""); 16 | _mint(msg.sender, SWORD, 10**9, ""); 17 | _mint(msg.sender, SHIELD, 10**9, ""); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /contracts/contracts/TestERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | 6 | contract TestERC20 is ERC20 { 7 | constructor(uint256 initialSupply) ERC20("Gold", "GLD") { 8 | _mint(msg.sender, initialSupply); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/contracts/TestERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 5 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; 6 | import "@openzeppelin/contracts/utils/Counters.sol"; 7 | 8 | contract TestERC721 is ERC721URIStorage { 9 | using Counters for Counters.Counter; 10 | Counters.Counter private _tokenIds; 11 | 12 | constructor() ERC721("GameItem", "ITM") {} 13 | 14 | function awardItem(address player, string memory tokenURI) 15 | public 16 | returns (uint256) 17 | { 18 | _tokenIds.increment(); 19 | 20 | uint256 newItemId = _tokenIds.current(); 21 | _mint(player, newItemId); 22 | _setTokenURI(newItemId, tokenURI); 23 | 24 | return newItemId; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /contracts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gravity-contracts", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "evm": "npx hardhat node", 8 | "test": "npx hardhat test --network localhost", 9 | "typechain": "npx hardhat typechain", 10 | "compile-deployer": "npx tsc -p . ; pkg dist/contract-deployer.js --targets node10-linux-x64", 11 | "evm_fork": "npx hardhat node --fork https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID} --fork-block-number 11780000", 12 | "test_fork": "npx hardhat test --network localhost ./tests_mainnet_fork/*.ts" 13 | }, 14 | "author": "Jehan Tremback", 15 | "license": "None", 16 | "devDependencies": { 17 | "@commitlint/cli": "^17.6.1", 18 | "@commitlint/config-conventional": "^15.0.0", 19 | "@ethersproject/abstract-signer": "^5.0.6", 20 | "@ethersproject/bignumber": "^5.0.8", 21 | "@nomiclabs/hardhat-ethers": "^2.0.2", 22 | "@nomiclabs/hardhat-waffle": "^2.0.1", 23 | "@openzeppelin/contracts": "4.7.3", 24 | "@typechain/ethers-v5": "^5.0.0", 25 | "@types/chai": "^4.2.13", 26 | "@types/command-line-args": "^5.0.0", 27 | "@types/fs-extra": "^9.0.1", 28 | "@types/mocha": "^7.0.2", 29 | "@types/node": "^14.11.8", 30 | "@typescript-eslint/eslint-plugin": "^3.10.1", 31 | "@typescript-eslint/parser": "^3.10.1", 32 | "@uniswap/v2-periphery": "^1.1.0-beta.0", 33 | "axios": "^1.6.0", 34 | "chai": "^4.2.0", 35 | "command-line-args": "^5.1.1", 36 | "commitizen": "^4.2.4", 37 | "cz-conventional-changelog": "^3.0.1", 38 | "dotenv": "^8.2.0", 39 | "eslint": "^7.11.0", 40 | "eslint-config-prettier": "^6.12.0", 41 | "ethereum-waffle": "^2.2.0", 42 | "ethers": "^5.5.1", 43 | "fs-extra": "^9.0.1", 44 | "ganache": "^7.0.2", 45 | "hardhat": "^2.8.3", 46 | "hardhat-gas-reporter": "^1.0.4", 47 | "hardhat-typechain": "^0.3.4", 48 | "husky": "^8.0.3", 49 | "mocha": "^9.2.1", 50 | "nexe": "^4.0.0-rc.1", 51 | "prettier": "^2.4.1", 52 | "prettier-plugin-solidity": "^1.0.0-beta.18", 53 | "shelljs": "^0.8.4", 54 | "solc": "^0.8.10", 55 | "solhint": "^1.0.10", 56 | "solhint-plugin-prettier": "^0.0.5", 57 | "solidity-coverage": "^0.7.10", 58 | "ts-generator": "^0.1.1", 59 | "ts-node": "^10.4.0", 60 | "typechain": "^4.0.1", 61 | "typescript": "^4.4.4" 62 | }, 63 | "resolutions": { 64 | "web3": "1.6.1", 65 | "uuid": "8.3.2" 66 | }, 67 | "dependencies": { 68 | "@cosmjs/stargate": "^0.27.1", 69 | "@cosmjs/tendermint-rpc": "^0.27.1", 70 | "hardhat-deploy": "^0.10.5", 71 | "pkg": "^5.5.2", 72 | "ts-proto": "^1.106.1" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /docs/cpp/SUMMARY.md.tmpl: -------------------------------------------------------------------------------- 1 | # Defi Wallet Core Cpp 2 | 3 | * [Introduction](README.md) 4 | {{doxygen}} 5 | * [Crypto.com](https://crypto.com) 6 | -------------------------------------------------------------------------------- /docs/cpp/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "/", 3 | "indexInFolders": true, 4 | "linkSuffix": ".md", 5 | "linkLowercase": false, 6 | "indexClassesName": "README", 7 | "indexFilesName": "README", 8 | "indexGroupsName": "README", 9 | "indexNamespacesName": "README", 10 | "indexRelatedPagesName": "README", 11 | "indexExamplesName": "README", 12 | "mainPageInRoot": true, 13 | "mainPageName": "README" 14 | } 15 | -------------------------------------------------------------------------------- /docs/cpp/gitbook/src/README.md: -------------------------------------------------------------------------------- 1 | # Defi Wallet Core Cpp 2 | -------------------------------------------------------------------------------- /docs/cpp/mdbook/.gitignore: -------------------------------------------------------------------------------- 1 | book 2 | -------------------------------------------------------------------------------- /docs/cpp/mdbook/book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | authors = ["Crypto.com"] 3 | language = "en" 4 | multilingual = false 5 | src = "src" 6 | title = "Defi Wallet Core Cpp" 7 | -------------------------------------------------------------------------------- /docs/cpp/mdbook/src/README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | -------------------------------------------------------------------------------- /docs/cpp/shell.nix: -------------------------------------------------------------------------------- 1 | { system ? builtins.currentSystem 2 | , pkgs ? import ../../nix { inherit system; } 3 | }: 4 | 5 | with pkgs; 6 | 7 | let 8 | pypkgs = import ../../nix/pypkgs.nix { inherit pkgs; }; 9 | gitbook-cli = import ../../nix/node/override.nix { inherit pkgs system; }; 10 | doxybook2 = import ../../nix/doxybook2.nix { inherit pkgs; }; 11 | in 12 | mkShell { 13 | buildInputs = [ 14 | pkgs.doxygen 15 | pkgs.mdbook 16 | pkgs.sphinx 17 | pkgs.python39Packages.breathe 18 | python39Packages.sphinx_rtd_theme 19 | python39Packages.beautifulsoup4 20 | pypkgs.exhale 21 | xcbuild 22 | gitbook-cli 23 | doxybook2 24 | ]; 25 | } 26 | -------------------------------------------------------------------------------- /docs/cpp/sphinx/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/cpp/sphinx/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | # import os 14 | # import sys 15 | # sys.path.insert(0, os.path.abspath('.')) 16 | 17 | 18 | # -- Project information ----------------------------------------------------- 19 | 20 | project = "Defi Wallet Core Cpp" 21 | copyright = "2022-present, Crypto.com" 22 | author = "Crypto.com" 23 | 24 | # The full version, including alpha/beta/rc tags 25 | release = "0.1.12" 26 | 27 | 28 | # -- General configuration --------------------------------------------------- 29 | 30 | # Add any Sphinx extension module names here, as strings. They can be 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 32 | # ones. 33 | extensions = [ 34 | "breathe", 35 | "exhale", 36 | ] 37 | 38 | # Breathe Configuration 39 | breathe_default_project = "Defi Wallet Core Cpp" 40 | breathe_projects = {"Defi Wallet Core Cpp": "../doxygen/xml"} 41 | # Setup the exhale extension 42 | exhale_args = { 43 | # These arguments are required 44 | "containmentFolder": "./api", 45 | "rootFileName": "library_root.rst", 46 | "rootFileTitle": "Library API", 47 | "doxygenStripFromPath": "..", 48 | # Suggested optional arguments 49 | "createTreeView": True, 50 | # TIP: if using the sphinx-bootstrap-theme, you need 51 | # "treeViewIsBootstrap": True, 52 | } 53 | 54 | 55 | # Add any paths that contain templates here, relative to this directory. 56 | templates_path = ["_templates"] 57 | 58 | # List of patterns, relative to source directory, that match files and 59 | # directories to ignore when looking for source files. 60 | # This pattern also affects html_static_path and html_extra_path. 61 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 62 | 63 | 64 | # -- Options for HTML output ------------------------------------------------- 65 | 66 | # The theme to use for HTML and HTML Help pages. See the documentation for 67 | # a list of builtin themes. 68 | # 69 | html_theme = "sphinx_rtd_theme" 70 | 71 | # Add any paths that contain custom static files (such as style sheets) here, 72 | # relative to this directory. They are copied after the builtin static files, 73 | # so a file named "default.css" will overwrite the builtin "default.css". 74 | html_static_path = ["_static"] 75 | -------------------------------------------------------------------------------- /docs/cpp/sphinx/index.rst: -------------------------------------------------------------------------------- 1 | .. Defi Wallet Core Cpp documentation master file, created by 2 | sphinx-quickstart on Fri Apr 29 18:37:46 2022. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Defi Wallet Core Cpp's documentation! 7 | ================================================ 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Contents: 12 | 13 | 14 | 15 | Indices and tables 16 | ================== 17 | 18 | * :ref:`genindex` 19 | * :ref:`modindex` 20 | * :ref:`search` 21 | 22 | Docs 23 | ==== 24 | 25 | .. toctree:: 26 | :maxdepth: 2 27 | :caption: Contents: 28 | 29 | api/library_root 30 | -------------------------------------------------------------------------------- /env/android/libgcc.a: -------------------------------------------------------------------------------- 1 | INPUT(-lunwind) -------------------------------------------------------------------------------- /example/android_example/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /example/android_example/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: app init clean 2 | 3 | app: 4 | ./gradlew build 5 | 6 | clean: 7 | ./gradlew clean 8 | 9 | -------------------------------------------------------------------------------- /example/android_example/README.md: -------------------------------------------------------------------------------- 1 | # android example 2 | 3 | ## Building 4 | 5 | ``` 6 | cd ../.. 7 | make android 8 | cd - 9 | make app 10 | ``` 11 | -------------------------------------------------------------------------------- /example/android_example/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | common.kt 3 | *.so 4 | libs/* 5 | release 6 | -------------------------------------------------------------------------------- /example/android_example/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdk 31 8 | 9 | defaultConfig { 10 | applicationId "com.example.android_example" 11 | minSdk 26 12 | targetSdk 31 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | kotlinOptions { 30 | jvmTarget = '1.8' 31 | } 32 | } 33 | 34 | dependencies { 35 | implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs') 36 | // implementation 'net.java.dev.jna:jna:5.10.0@aar' 37 | implementation 'androidx.core:core-ktx:1.7.0' 38 | implementation 'androidx.appcompat:appcompat:1.4.0' 39 | implementation 'com.google.android.material:material:1.4.0' 40 | implementation 'androidx.constraintlayout:constraintlayout:2.1.2' 41 | testImplementation 'junit:junit:4.+' 42 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 44 | } -------------------------------------------------------------------------------- /example/android_example/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /example/android_example/app/src/androidTest/java/com/example/android_example/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.android_example 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.example.android_example", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /example/android_example/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/java/com/example/android_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.android_example 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.widget.TextView 6 | import com.defi.wallet.core.common.* 7 | 8 | class MainActivity : AppCompatActivity() { 9 | override fun onCreate(savedInstanceState: Bundle?) { 10 | super.onCreate(savedInstanceState) 11 | setContentView(R.layout.activity_main) 12 | val textview = findViewById(R.id.textview) 13 | 14 | val wallet = HdWallet.generateWallet("",MnemonicWordCount.TWELVE) 15 | val mnemonic = wallet.getBackupMnemonicPhrase() 16 | var text = "mnemonic:" + mnemonic + "\n" 17 | val address = wallet.getDefaultAddress(WalletCoin.CosmosSdk(Network.CosmosHub)) 18 | text += "address: " + address + "\n" 19 | 20 | val priv = wallet.getKey("m/44'/118'/0'/0/0") 21 | val txinfo = CosmosSdkTxInfo( 22 | 1UL, 23 | 1UL, 24 | 100UL, 25 | SingleCoin.Atom(100UL), 26 | 9000U, 27 | "memo", 28 | Network.CosmosHub 29 | ) 30 | val siged_tx = buildSignedSingleMsgTx( 31 | txinfo, 32 | CosmosSdkMsg.BankSend( 33 | "cosmos1rw2cc4hj6ahfk87pqh9znjzgmqwq8ec8nzt0e9", 34 | SingleCoin.Atom(20UL) 35 | ), 36 | priv 37 | ) 38 | 39 | text += "siged_tx: " 40 | for (b in siged_tx) { 41 | print(b) 42 | val h = String.format("%02x", b.toInt()) 43 | text += h 44 | } 45 | 46 | val rb = getAccountBalanceBlocking("https://mainnet.crypto.org:9090","cro1yjjlx5qsrj5rxn5xtd5rkm6dcqzlchxkrvsmg6","basecro") 47 | text += "\namount: " + rb.amount 48 | 49 | text += "\nend" 50 | textview.text = text 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | android_example 3 | -------------------------------------------------------------------------------- /example/android_example/app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /example/android_example/app/src/test/java/com/example/android_example/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.android_example 2 | 3 | import com.defi.wallet.core.common.* 4 | import org.junit.Test 5 | 6 | import org.junit.Assert.* 7 | 8 | /** 9 | * Example local unit test, which will execute on the development machine (host). 10 | * 11 | * See [testing documentation](http://d.android.com/tools/testing). 12 | */ 13 | class ExampleUnitTest { 14 | @Test 15 | fun addition_isCorrect() { 16 | assertEquals(4, 2 + 2) 17 | } 18 | } -------------------------------------------------------------------------------- /example/android_example/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath "com.android.tools.build:gradle:7.0.2" 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31" 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | task clean(type: Delete) { 17 | delete rootProject.buildDir 18 | } -------------------------------------------------------------------------------- /example/android_example/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /example/android_example/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/example/android_example/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android_example/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 21 02:12:21 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /example/android_example/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /example/android_example/settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() // Warning: this repository is going to shut down soon 7 | } 8 | } 9 | rootProject.name = "android_example" 10 | include ':app' 11 | -------------------------------------------------------------------------------- /example/cpp-example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(CMAKE_CXX_STANDARD 11) 3 | set(CMAKE_CXX_STANDARD_REQURIED ON) 4 | set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE) 5 | if (APPLE) 6 | set(CMAKE_CXX_FLAGS "-framework Security -framework CoreFoundation -framework SystemConfiguration") 7 | endif() 8 | 9 | project(cppexample VERSION 1.0) 10 | 11 | add_subdirectory(sdk) 12 | 13 | # static cppexample 14 | add_executable(cppexamplestatic main.cc chainmain.cc cronos.cc wallet.cc) 15 | if (UNIX AND NOT APPLE) 16 | target_link_libraries(cppexamplestatic PUBLIC ${DEFI_WALLET_CORE_CPP_LIB} pthread dl rt) 17 | else() 18 | target_link_libraries(cppexamplestatic PUBLIC ${DEFI_WALLET_CORE_CPP_LIB}) 19 | endif() 20 | 21 | # dynamic cppexample 22 | add_executable(cppexample main.cc chainmain.cc cronos.cc wallet.cc) 23 | target_link_libraries(cppexample PUBLIC ${RUST_LIB} ${DEFI_WALLET_CORE_CPP_DYLIB} defi_wallet_core_cpp) 24 | -------------------------------------------------------------------------------- /example/cpp-example/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | sdk_dir = ./sdk 3 | 4 | 5 | ifeq ($(shell uname -m), x86_64) 6 | CXX = g++ 7 | TARGET_DIR = ../../target/release 8 | endif 9 | 10 | ifeq ($(shell uname -m), arm64) 11 | CXX = arch -x86_64 g++ 12 | TARGET_DIR = ../../target/x86_64-apple-darwin/release 13 | else 14 | 15 | endif 16 | 17 | ifeq ($(UNAME), Darwin) 18 | FLAGS=-framework Security -framework CoreFoundation -framework SystemConfiguration 19 | endif 20 | 21 | ifeq ($(UNAME), Linux) 22 | FLAGS=-lpthread -ldl -lrt 23 | endif 24 | 25 | all: clean build 26 | build: prepare static dynamic cmake 27 | run: run_static run_dynamic 28 | 29 | prepare: 30 | python3 helper.py --target_dir $(TARGET_DIR) 31 | 32 | libdefi_wallet_core_cpp.dylib: 33 | ifeq ($(UNAME), Darwin) 34 | install_name_tool -id @rpath/libdefi_wallet_core_cpp.dylib $(sdk_dir)/lib/libdefi_wallet_core_cpp.dylib 35 | endif 36 | 37 | static: 38 | $(CXX) -o cppexamplestatic \ 39 | main.cc \ 40 | chainmain.cc \ 41 | cronos.cc \ 42 | wallet.cc \ 43 | $(sdk_dir)/lib/libdefi_wallet_core_cpp.a \ 44 | -std=c++11 \ 45 | $(FLAGS) 46 | 47 | dynamic: libdefi_wallet_core_cpp.dylib 48 | ifeq ($(UNAME), Linux) 49 | $(CXX) -o cppexample \ 50 | main.cc \ 51 | chainmain.cc \ 52 | wallet.cc \ 53 | cronos.cc \ 54 | $(sdk_dir)/include/*.cc \ 55 | $(sdk_dir)/include/defi-wallet-core-cpp/src/*.cc \ 56 | $(sdk_dir)/lib/libcxxbridge1.a \ 57 | -std=c++11 \ 58 | -L$(sdk_dir)/lib -Wl,-rpath=$(sdk_dir)/lib -Wall \ 59 | -ldefi_wallet_core_cpp \ 60 | $(FLAGS) 61 | endif 62 | ifeq ($(UNAME), Darwin) 63 | $(CXX) -o cppexample \ 64 | main.cc \ 65 | chainmain.cc \ 66 | wallet.cc \ 67 | cronos.cc \ 68 | $(sdk_dir)/include/*.cc \ 69 | $(sdk_dir)/include/defi-wallet-core-cpp/src/*.cc \ 70 | $(sdk_dir)/lib/libcxxbridge1.a \ 71 | -std=c++11 \ 72 | $(sdk_dir)/lib/libdefi_wallet_core_cpp.dylib \ 73 | -rpath $(sdk_dir)/lib \ 74 | $(FLAGS) 75 | endif 76 | 77 | cmake: 78 | mkdir -p build 79 | cd build && cmake .. && make 80 | 81 | run_static: 82 | ./cppexamplestatic && ./build/cppexamplestatic 83 | 84 | run_dynamic: 85 | export LD_LIBRARY_PATH=$(PWD) && ./cppexample && ./build/cppexample 86 | 87 | clean: 88 | rm -f cppexample cppexamplestatic 89 | rm -rf build 90 | rm -rf $(sdk_dir)/lib 91 | rm -rf $(sdk_dir)/include 92 | -------------------------------------------------------------------------------- /example/cpp-example/chainmain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void chainmain_process(); 4 | void test_login(); 5 | void test_chainmain_nft(); 6 | -------------------------------------------------------------------------------- /example/cpp-example/cronos.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void cronos_process(); 4 | void test_cronos_testnet(); 5 | void test_interval(); 6 | -------------------------------------------------------------------------------- /example/cpp-example/main.cc: -------------------------------------------------------------------------------- 1 | #include "chainmain.h" 2 | #include "cronos.h" 3 | #include "wallet.h" 4 | #include "sdk/include/defi-wallet-core-cpp/src/lib.rs.h" 5 | #include "sdk/include/defi-wallet-core-cpp/src/nft.rs.h" 6 | #include "sdk/include/rust/cxx.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int argc, char *argv[]) { 17 | try { 18 | org::defi_wallet_core::set_cronos_httpagent("cronos-wallet-cpp-example"); 19 | test_wallet(); 20 | chainmain_process(); // chain-main 21 | test_chainmain_nft(); // chainmain nft tests 22 | test_login(); // decentralized login 23 | cronos_process(); // cronos 24 | test_cronos_testnet(); // cronos testnet 25 | test_interval(); 26 | } catch (const rust::cxxbridge1::Error &e) { 27 | // Use `Assertion failed`, the same as `assert` function 28 | std::cout << "Assertion failed: " << e.what() << std::endl; 29 | } 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /example/cpp-example/sdk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | set(CMAKE_CXX_STANDARD 11) 3 | set(CMAKE_CXX_STANDARD_REQURIED ON) 4 | 5 | project(defi_wallet_core_cpp VERSION 0.2.0) 6 | 7 | # Find bindings source files 8 | file(GLOB_RECURSE DEFI_WALLET_CORE_CPP_BINDINGS include/defi-wallet-core-cpp/src/*.cc) 9 | file(GLOB DEFI_WALLET_CORE_CPP_SROUCES include/*.cc) 10 | 11 | # Find the rust types binding library 12 | find_library(RUST_LIB libcxxbridge1.a REQUIRED PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib) 13 | 14 | # Find the prebuilt static and dynamic libraries 15 | if (WIN32) 16 | find_library(DEFI_WALLET_CORE_CPP_LIB defi_wallet_core_cpp.lib PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib) 17 | find_library(DEFI_WALLET_CORE_CPP_DYLIB defi_wallet_core_cpp.dll.lib PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib) 18 | endif() 19 | 20 | if (APPLE) 21 | find_library(DEFI_WALLET_CORE_CPP_LIB libdefi_wallet_core_cpp.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib) 22 | find_library(DEFI_WALLET_CORE_CPP_DYLIB libdefi_wallet_core_cpp.dylib PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib) 23 | endif() 24 | 25 | if (UNIX AND NOT APPLE) 26 | find_library(DEFI_WALLET_CORE_CPP_LIB libdefi_wallet_core_cpp.a PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib) 27 | find_library(DEFI_WALLET_CORE_CPP_DYLIB libdefi_wallet_core_cpp.so PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib) 28 | endif() 29 | 30 | # Add library defi_wallet_core_cpp built from bindings source files 31 | add_library(defi_wallet_core_cpp ${DEFI_WALLET_CORE_CPP_BINDINGS} ${DEFI_WALLET_CORE_CPP_SROUCES}) 32 | -------------------------------------------------------------------------------- /example/cpp-example/wallet.cc: -------------------------------------------------------------------------------- 1 | #include "sdk/include/defi-wallet-core-cpp/src/contract.rs.h" 2 | #include "sdk/include/defi-wallet-core-cpp/src/lib.rs.h" 3 | #include "sdk/include/defi-wallet-core-cpp/src/uint.rs.h" 4 | #include "sdk/include/rust/cxx.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | using namespace org::defi_wallet_core; 12 | using namespace rust; 13 | String getEnv(String key); 14 | void test_wallet_restore(String password) { 15 | rust::String mymnemonics = getEnv("SIGNER1_MNEMONIC"); 16 | int index = 0; 17 | Box mywallet = restore_wallet(mymnemonics, ""); 18 | rust::String backupmnemonics = mywallet->get_backup_mnemonic_phrase(); 19 | assert(mymnemonics == backupmnemonics); 20 | } 21 | 22 | void test_wallet_generatemnemonics(String passowrd) { 23 | rust::String mymnemonics = 24 | generate_mnemonics("", MnemonicWordCount::TwentyFour); 25 | int index = 0; 26 | Box mywallet = restore_wallet(mymnemonics, ""); 27 | rust::String backupmnemonics = mywallet->get_backup_mnemonic_phrase(); 28 | assert(mymnemonics == backupmnemonics); 29 | } 30 | void test_wallet_new(String password) { 31 | Box mywallet = new_wallet("", MnemonicWordCount::Twelve); 32 | int index = 0; 33 | rust::String mymnemonics = mywallet->get_backup_mnemonic_phrase(); 34 | Box mywallet2 = restore_wallet(mymnemonics, ""); 35 | rust::String backupmnemonics = mywallet2->get_backup_mnemonic_phrase(); 36 | assert(mymnemonics == backupmnemonics); 37 | } 38 | void test_wallet_secure_storage() { 39 | std::cout << "secure storage" << std::endl; 40 | rust::String usermnemonics = getEnv("SIGNER1_MNEMONIC"); 41 | int index = 0; 42 | Box userwallet = restore_wallet_save_to_securestorage( 43 | usermnemonics, "", "mywalletservice", "mywalletuser"); 44 | Box userwallet2 = 45 | restore_wallet_load_from_securestorage("mywalletservice", "mywalletuser"); 46 | assert(userwallet->get_eth_address(0) == userwallet2->get_eth_address(0)); 47 | } 48 | void test_wallet() { 49 | test_wallet_restore(String("")); 50 | test_wallet_generatemnemonics(String("")); 51 | test_wallet_new(String("")); 52 | test_wallet_restore(String("mypassword")); 53 | test_wallet_generatemnemonics(String("mypassword")); 54 | test_wallet_new(String("mypassword")); 55 | } -------------------------------------------------------------------------------- /example/cpp-example/wallet.h: -------------------------------------------------------------------------------- 1 | void test_wallet(); -------------------------------------------------------------------------------- /example/extension-example/.gitignore: -------------------------------------------------------------------------------- 1 | doc/ 2 | node_modules 3 | package-lock.json -------------------------------------------------------------------------------- /example/extension-example/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: install doc clean 2 | 3 | install: 4 | npm install 5 | doc: 6 | jsdoc node_modules/@crypto-com/defi-wallet-core-wasm/defi_wallet_core_wasm.js -d doc 7 | clean: 8 | rm -rf doc 9 | -------------------------------------------------------------------------------- /example/extension-example/background.js: -------------------------------------------------------------------------------- 1 | // Extension event listeners are a little different from the patterns you may have seen in DOM or 2 | // Node.js APIs. The below event listener registration can be broken in to 4 distinct parts: 3 | // 4 | // * chrome - the global namespace for Chrome's extension APIs 5 | // * runtime – the namespace of the specific API we want to use 6 | // * onInstalled - the event we want to subscribe to 7 | // * addListener - what we want to do with this event 8 | // 9 | // See https://developer.chrome.com/docs/extensions/reference/events/ for additional details. 10 | chrome.runtime.onInstalled.addListener(async () => { 11 | 12 | // While we could have used `let url = "hello.html"`, using runtime.getURL is a bit more robust as 13 | // it returns a full URL rather than just a path that Chrome needs to be resolved contextually at 14 | // runtime. 15 | let url = chrome.runtime.getURL("test.html"); 16 | 17 | // Open a new tab pointing at our page's URL using JavaScript's object initializer shorthand. 18 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#new_notations_in_ecmascript_2015 19 | // 20 | // Many of the extension platform's APIs are asynchronous and can either take a callback argument 21 | // or return a promise. Since we're inside an async function, we can await the resolution of the 22 | // promise returned by the tabs.create call. See the following link for more info on async/await. 23 | // https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await 24 | let tab = await chrome.tabs.create({ url }); 25 | }); 26 | -------------------------------------------------------------------------------- /example/extension-example/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Extension test!", 3 | "version": "1.0", 4 | "manifest_version": 3, 5 | "background": { 6 | "service_worker": "background.js" 7 | }, 8 | "action": {} 9 | } 10 | -------------------------------------------------------------------------------- /example/extension-example/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "extension-example", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "@crypto-com/defi-wallet-core-wasm": "file:../../bindings/wasm/target/wasmweb" 9 | } 10 | }, 11 | "../../bindings/wasm/target/wasmweb": { 12 | "name": "@crypto-com/defi-wallet-core-wasm", 13 | "version": "0.2.0" 14 | }, 15 | "node_modules/@crypto-com/defi-wallet-core-wasm": { 16 | "resolved": "../../bindings/wasm/target/wasmweb", 17 | "link": true 18 | } 19 | }, 20 | "dependencies": { 21 | "@crypto-com/defi-wallet-core-wasm": { 22 | "version": "file:../../bindings/wasm/target/wasmweb" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/extension-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@crypto-com/defi-wallet-core-wasm": "file:../../bindings/wasm/target/wasmweb" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /example/extension-example/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test 5 | 6 | 7 |

test

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios-example/.gitignore: -------------------------------------------------------------------------------- 1 | xcuserdata/ 2 | dwc_commonFFI.h 3 | lib.a/ 4 | common.swift 5 | build/ 6 | dwclib.framework/ 7 | -------------------------------------------------------------------------------- /example/ios-example/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: x86_64 arm64 clean 2 | 3 | x86_64: 4 | ./build.sh x86_64 5 | arm64: 6 | ./build.sh arm64 7 | clean: 8 | rm -rf dwclib.framework 9 | xcodebuild SYMROOT="./build" clean 10 | -------------------------------------------------------------------------------- /example/ios-example/README.md: -------------------------------------------------------------------------------- 1 | # ios example 2 | 3 | ## Building 4 | 5 | ``` 6 | cd ../.. 7 | make ios 8 | cd - 9 | make x86_64 or make arm64 10 | ``` 11 | -------------------------------------------------------------------------------- /example/ios-example/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case $1 in 4 | x86_64) 5 | rm -rf dwclib.framework 6 | cp -r ../../mobile_modules/ios_module/dwclib/build/Release-iphonesimulator/dwclib.framework ./ || exit 1 7 | xcodebuild SYMROOT="./build" -configuration Debug -target ios-example -arch x86_64 -sdk `xcodebuild -showsdks | grep 'iphonesimulator' | awk 'BEGIN{FS="-sdk"} {print $2}'` || exit 1 8 | ;; 9 | arm64) 10 | rm -rf dwclib.framework 11 | cp -r ../../mobile_modules/ios_module/dwclib/build/Release-iphoneos/dwclib.framework ./ || exit 1 12 | xcodebuild SYMROOT="./build" -configuration Debug -target ios-example -arch arm64 -sdk `xcodebuild -showsdks | grep 'iphoneos' | awk 'BEGIN{FS="-sdk"} {print $2}'` || exit 1 13 | ;; 14 | *) 15 | echo "$1 is not supported" 16 | esac 17 | 18 | -------------------------------------------------------------------------------- /example/ios-example/ios-example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios-example/ios-example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios-example/ios-example/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /example/ios-example/ios-example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /example/ios-example/ios-example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios-example/ios-example/ContentView.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import dwclib 3 | 4 | struct ContentView: View { 5 | var body: some View { 6 | var wallet = try? HdWallet.generateWallet(password: "", wordCount: MnemonicWordCount.twelve) 7 | var mnemonic = try? wallet?.getBackupMnemonicPhrase() 8 | Text("mnemonic: " + mnemonic!) 9 | 10 | var address = try? wallet?.getDefaultAddress(coin: WalletCoin.cosmosSdk(network: Network.cosmosHub)) 11 | Text("address: " + address!) 12 | var priv = try? wallet?.getKey(derivationPath: "m/44'/118'/0'/0/0") 13 | 14 | var txinfo = CosmosSdkTxInfo.init(accountNumber: 1, sequenceNumber: 1, gasLimit: 100, feeAmount: SingleCoin.atom(amount: 100), timeoutHeight: 9000, memoNote: "memo", network: Network.cosmosHub) 15 | 16 | var siged_tx = try? buildSignedSingleMsgTx(txInfo: txinfo, msg: CosmosSdkMsg.bankSend(recipientAddress: "cosmos1rw2cc4hj6ahfk87pqh9znjzgmqwq8ec8nzt0e9", amount: SingleCoin.atom(amount: 20)), secretKey: priv!) 17 | 18 | 19 | let hexArray = siged_tx?.compactMap { String(format: "%02x", $0).lowercased()} 20 | let hexString = hexArray?.joined(separator: "") 21 | Text("siged_tx: " + hexString!) 22 | 23 | var br = try? getAccountBalanceBlocking(apiUrl: "https://mainnet.crypto.org:9090", address: "cro1yjjlx5qsrj5rxn5xtd5rkm6dcqzlchxkrvsmg6", denom: "basecro", version: BalanceApiVersion.new) 24 | Text("balance: " + br!.amount) 25 | Text("end") 26 | } 27 | } 28 | 29 | struct ContentView_Previews: PreviewProvider { 30 | static var previews: some View { 31 | ContentView() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /example/ios-example/ios-example/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios-example/ios-example/include/module.modulemap: -------------------------------------------------------------------------------- 1 | module DefiWalletCore [system] { 2 | header "dwc_commonFFI.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /example/ios-example/ios-example/ios_exampleApp.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | @main 4 | struct ios_exampleApp: App { 5 | var body: some Scene { 6 | WindowGroup { 7 | ContentView() 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example/ios-example/ios-exampleTests/ios_exampleTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import dwclib 3 | 4 | class ios_exampleTests: XCTestCase { 5 | 6 | override func setUpWithError() throws { 7 | // Put setup code here. This method is called before the invocation of each test method in the class. 8 | } 9 | 10 | override func tearDownWithError() throws { 11 | // Put teardown code here. This method is called after the invocation of each test method in the class. 12 | } 13 | 14 | func testMnemonic() throws { 15 | var wallet = try? HdWallet.generateWallet(password: "", wordCount: MnemonicWordCount.twelve) 16 | var mnemonic = try? wallet?.getBackupMnemonicPhrase() 17 | print(mnemonic) 18 | } 19 | 20 | func testPerformanceExample() throws { 21 | // This is an example of a performance test case. 22 | self.measure { 23 | // Put the code you want to measure the time of here. 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /example/ios-example/ios-exampleUITests/ios_exampleUITests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | class ios_exampleUITests: XCTestCase { 4 | 5 | override func setUpWithError() throws { 6 | // Put setup code here. This method is called before the invocation of each test method in the class. 7 | 8 | // In UI tests it is usually best to stop immediately when a failure occurs. 9 | continueAfterFailure = false 10 | 11 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 12 | } 13 | 14 | override func tearDownWithError() throws { 15 | // Put teardown code here. This method is called after the invocation of each test method in the class. 16 | } 17 | 18 | func testExample() throws { 19 | // UI tests must launch the application that they test. 20 | let app = XCUIApplication() 21 | app.launch() 22 | 23 | // Use recording to get started writing UI tests. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | } 26 | 27 | func testLaunchPerformance() throws { 28 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { 29 | // This measures how long it takes to launch your application. 30 | measure(metrics: [XCTApplicationLaunchMetric()]) { 31 | XCUIApplication().launch() 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /example/ios-example/ios-exampleUITests/ios_exampleUITestsLaunchTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | class ios_exampleUITestsLaunchTests: XCTestCase { 4 | 5 | override class var runsForEachTargetApplicationUIConfiguration: Bool { 6 | true 7 | } 8 | 9 | override func setUpWithError() throws { 10 | continueAfterFailure = false 11 | } 12 | 13 | func testLaunch() throws { 14 | let app = XCUIApplication() 15 | app.launch() 16 | 17 | // Insert steps here to perform after app launch but before taking a screenshot, 18 | // such as logging into a test account or navigating somewhere in the app 19 | 20 | let attachment = XCTAttachment(screenshot: app.screenshot()) 21 | attachment.name = "Launch Screen" 22 | attachment.lifetime = .keepAlways 23 | add(attachment) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/js-example/.bin/create-wasm-app.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { spawn } = require("child_process"); 4 | const fs = require("fs"); 5 | 6 | let folderName = '.'; 7 | 8 | if (process.argv.length >= 3) { 9 | folderName = process.argv[2]; 10 | if (!fs.existsSync(folderName)) { 11 | fs.mkdirSync(folderName); 12 | } 13 | } 14 | 15 | const clone = spawn("git", ["clone", "https://github.com/rustwasm/create-wasm-app.git", folderName]); 16 | 17 | clone.on("close", code => { 18 | if (code !== 0) { 19 | console.error("cloning the template failed!") 20 | process.exit(code); 21 | } else { 22 | console.log("🦀 Rust + 🕸 Wasm = ❤"); 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /example/js-example/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | -------------------------------------------------------------------------------- /example/js-example/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: "10" 3 | 4 | script: 5 | - ./node_modules/.bin/webpack 6 | -------------------------------------------------------------------------------- /example/js-example/bootstrap.js: -------------------------------------------------------------------------------- 1 | // A dependency graph that contains any wasm must all be imported 2 | // asynchronously. This `bootstrap.js` file does the single async import, so 3 | // that no one else needs to worry about it again. 4 | import("./index.js") 5 | .catch(e => console.error("Error importing `index.js`:", e)); 6 | -------------------------------------------------------------------------------- /example/js-example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello wasm-pack! 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /example/js-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-wasm-app", 3 | "version": "0.1.0", 4 | "description": "create an app to consume rust-generated wasm packages", 5 | "main": "index.js", 6 | "bin": { 7 | "create-wasm-app": ".bin/create-wasm-app.js" 8 | }, 9 | "scripts": { 10 | "build": "webpack --config webpack.config.js", 11 | "start": "webpack-dev-server" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/rustwasm/create-wasm-app.git" 16 | }, 17 | "keywords": [ 18 | "webassembly", 19 | "wasm", 20 | "rust", 21 | "webpack" 22 | ], 23 | "author": "Crypto.com", 24 | "license": "Apache-2.0", 25 | "bugs": { 26 | "url": "https://github.com/rustwasm/create-wasm-app/issues" 27 | }, 28 | "homepage": "https://github.com/rustwasm/create-wasm-app#readme", 29 | "dependencies": { 30 | "@crypto-com/defi-wallet-core-wasm": "file:../../bindings/wasm/pkg" 31 | }, 32 | "devDependencies": { 33 | "copy-webpack-plugin": "^10.0.0", 34 | "webpack": "^5.64.4", 35 | "webpack-cli": "^4.9.1", 36 | "webpack-dev-server": "^4.6.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example/js-example/webpack.config.js: -------------------------------------------------------------------------------- 1 | const CopyWebpackPlugin = require("copy-webpack-plugin"); 2 | const path = require('path'); 3 | 4 | module.exports = { 5 | entry: "./bootstrap.js", 6 | output: { 7 | path: path.resolve(__dirname, "dist"), 8 | filename: "bootstrap.js", 9 | }, 10 | mode: "development", 11 | experiments: { 12 | topLevelAwait: true, 13 | asyncWebAssembly: true 14 | }, 15 | // FIXME: https://github.com/rust-random/getrandom/issues/224 https://github.com/rustwasm/wasm-pack/issues/822 16 | ignoreWarnings: [ 17 | (warning) => 18 | warning.message === 19 | "Critical dependency: the request of a dependency is an expression", 20 | ], 21 | plugins: [ 22 | new CopyWebpackPlugin({patterns: ['index.html']}) 23 | ], 24 | }; 25 | -------------------------------------------------------------------------------- /example/vs-example/go.sh: -------------------------------------------------------------------------------- 1 | # run command in git shell of windows 2 | # or run in msys2 shell 3 | cargo build --package defi-wallet-core-cpp --release 4 | cd ../cpp-example 5 | python3 helper.py --target_dir ../../target/release 6 | 7 | -------------------------------------------------------------------------------- /example/vs-example/vs-example.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31727.386 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vs-example", "vs-example\vs-example.vcxproj", "{AD00F0ED-39E3-4901-A157-01D91C702A18}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Debug|x64.ActiveCfg = Debug|x64 17 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Debug|x64.Build.0 = Debug|x64 18 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Debug|x86.ActiveCfg = Debug|Win32 19 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Debug|x86.Build.0 = Debug|Win32 20 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Release|x64.ActiveCfg = Release|x64 21 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Release|x64.Build.0 = Release|x64 22 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Release|x86.ActiveCfg = Release|Win32 23 | {AD00F0ED-39E3-4901-A157-01D91C702A18}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {0663C9B8-E4D4-455D-924F-2DA56427BC9F} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /integration_tests/.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | extend-ignore = E203 4 | exclude = .git,__pycache__ 5 | -------------------------------------------------------------------------------- /integration_tests/.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | # compatible with black 3 | # https://black.readthedocs.io/en/stable/the_black_code_style.html 4 | multi_line_output = 3 5 | include_trailing_comma = True 6 | force_grid_wrap = 0 7 | use_parentheses = True 8 | ensure_newline_before_comments = True 9 | line_length = 88 10 | -------------------------------------------------------------------------------- /integration_tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/integration_tests/__init__.py -------------------------------------------------------------------------------- /integration_tests/conftest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import pytest 4 | 5 | from .network import setup_chainmain, setup_cronos 6 | 7 | 8 | @pytest.fixture(scope="session") 9 | def chainmain(tmp_path_factory): 10 | yield from setup_chainmain(tmp_path_factory.mktemp("chainmain"), 26800) 11 | 12 | 13 | @pytest.fixture(scope="session") 14 | def cronos(tmp_path_factory): 15 | yield from setup_cronos(tmp_path_factory.mktemp("cronos"), 26650) 16 | -------------------------------------------------------------------------------- /integration_tests/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "integration_tests" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Crypto.com"] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.8" 9 | pytest = "^5.4.0" 10 | flake8 = "^3.8.4" 11 | black = "^20.8b1" 12 | flake8-black = "^0.2.1" 13 | flake8-isort = "^4.0.0" 14 | pep8-naming = "^0.11.1" 15 | pytest-github-actions-annotate-failures = "^0.1.1" 16 | protobuf = "^3.13.0" 17 | grpcio = "^1.33.2" 18 | PyYAML = "^5.3.1" 19 | python-dateutil = "^2.8.1" 20 | web3 = "^5.20.1" 21 | eth-bloom = "^1.0.4" 22 | python-dotenv = "^0.19.2" 23 | pystarport = "^0.2.3" 24 | 25 | [tool.poetry.dev-dependencies] 26 | 27 | [build-system] 28 | requires = ["poetry>=0.12"] 29 | build-backend = "poetry.masonry.api" 30 | -------------------------------------------------------------------------------- /integration_tests/shell.nix: -------------------------------------------------------------------------------- 1 | { system ? builtins.currentSystem, pkgs ? import ../nix { inherit system; } }: 2 | 3 | with pkgs; 4 | 5 | mkShell { 6 | buildInputs = [ 7 | pkgs.jq 8 | pkgs.pystarport 9 | pkgs.poetry 10 | pkgs.test-env 11 | pkgs.python39Packages.supervisor 12 | (import ../nix/testenv.nix { inherit pkgs; }) 13 | (import ../nix/chainmain.nix { inherit pkgs; }) 14 | (import ../nix/cronos.nix { inherit pkgs; }) 15 | (import ../nix/hermes.nix { inherit pkgs; }) 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /ios_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "$1" == "x86" ]; then 3 | echo "Build x86 only" 4 | fi 5 | 6 | OS=`uname | tr 'A-Z' 'a-z'` 7 | if [ "$OS" != "darwin" ] 8 | then 9 | echo "not support for $OS" 10 | fi 11 | 12 | if [ "$1" != "x86" ]; then 13 | rustup target add x86_64-apple-ios || exit 1 14 | fi 15 | rustup target add x86_64-apple-ios || exit 1 16 | 17 | cargo run --features=uniffi-bindgen -p defi-wallet-core-common --bin uniffi-bindgen -- generate common/src/common.udl --config common/uniffi.toml --language swift --out-dir bindings/ios || exit 1 18 | if [ "$1" != "x86" ]; then 19 | cargo build --features uniffi-binding --target aarch64-apple-ios -p defi-wallet-core-common --release || exit 1 20 | fi 21 | cargo build --features uniffi-binding --target x86_64-apple-ios -p defi-wallet-core-common --release || exit 1 22 | mkdir -p mobile_modules/ios_module/dwclib/dwclib/lib.a 23 | if [ "$1" != "x86" ]; then 24 | lipo -create target/aarch64-apple-ios/release/libdefi_wallet_core_common.a target/x86_64-apple-ios/release/libdefi_wallet_core_common.a -output mobile_modules/ios_module/dwclib/dwclib/lib.a/libdefi_wallet_core_common.a || exit 1 25 | else 26 | cp target/x86_64-apple-ios/release/libdefi_wallet_core_common.a mobile_modules/ios_module/dwclib/dwclib/lib.a/libdefi_wallet_core_common.a 27 | fi 28 | mkdir -p mobile_modules/ios_module/dwclib/dwclib/include 29 | cp bindings/ios/dwc_commonFFI.h mobile_modules/ios_module/dwclib/dwclib/include/ || exit 1 30 | cp bindings/ios/common.swift mobile_modules/ios_module/dwclib/dwclib/ || exit 1 31 | cd mobile_modules/ios_module/dwclib/ 32 | type strip || exit 1 33 | # Because the build needs to be signed, so comment first 34 | # xcodebuild SYMROOT="./build" -configuration Release -target dwclib -arch arm64 -sdk iphoneos build || exit 1 35 | # strip build/Release-iphoneos/dwclib.framework/dwclib || exit 1 36 | xcodebuild SYMROOT="./build" -configuration Release -target dwclib -arch x86_64 -sdk iphonesimulator build || exit 1 37 | # Reduce package size 38 | # strip build/Release-iphonesimulator/dwclib.framework/dwclib || exit 1 39 | xcodebuild -scheme dwclib -destination 'platform=iOS Simulator,name=iPhone 12' test || exit 1 40 | cd - 41 | -------------------------------------------------------------------------------- /js_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OS=`uname | tr 'A-Z' 'a-z'` 4 | if [ "$OS" != "darwin" -a "$OS" != "linux" ] 5 | then 6 | echo "not support for $OS" 7 | exit 1 8 | fi 9 | 10 | BINARYENVERSION="105" 11 | 12 | if [ "$OS" == "linux" ] && [ ! -f target/binaryen-version_$BINARYENVERSION/bin/wasm2js ] 13 | then 14 | rm -f target/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz 15 | wget https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYENVERSION/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz -P target/ 16 | tar zxf target/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz -C target/ 17 | rm -f target/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz 18 | fi 19 | 20 | if [ "$OS" == "darwin" ] && [ ! -f target/binaryen-version_$BINARYENVERSION/bin/wasm2js ] 21 | then 22 | CPU=`uname -a | awk '{print $NF}'` 23 | if [ "$CPU" == "x86_64" ] 24 | then 25 | rm -f target/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz 26 | wget https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYENVERSION/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz -P target/ 27 | tar zxf target/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz -C target/ 28 | rm -f target/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz 29 | elif [ "$CPU" == "arm64" ] && [ ! -f target/binaryen-version_$BINARYENVERSION/bin/wasm2js ] 30 | then 31 | rm -f target/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz 32 | wget https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYENVERSION/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz -P target/ 33 | tar zxf target/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz -C target/ 34 | rm -f target/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz 35 | else 36 | echo "not support for $CPU" 37 | exit 1 38 | fi 39 | fi 40 | 41 | target/binaryen-version_$BINARYENVERSION/bin/wasm2js bindings/wasm/pkg/defi_wallet_core_wasm_bg.wasm -o bindings/wasm/pkg/defi_wallet_core_wasm_bg.wasm.js 42 | 43 | if [ "$OS" == "linux" ];then 44 | sed -i 's/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm_bg.js 45 | sed -i 's/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm.js 46 | sed -i '5i\ "defi_wallet_core_wasm_bg.wasm.js",' bindings/wasm/pkg/package.json 47 | sed -i '5i\ "snippets",' bindings/wasm/pkg/package.json 48 | elif [ "$OS" == "darwin" ];then 49 | sed -i '' -e $'s/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm_bg.js 50 | sed -i '' -e $'s/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm.js 51 | sed -i '' '5i\'$'\n'' "defi_wallet_core_wasm_bg.wasm.js",' bindings/wasm/pkg/package.json 52 | sed -i '' '5i\'$'\n'' "snippet",' bindings/wasm/pkg/package.json 53 | else 54 | echo "not support for $OS" 55 | exit 1 56 | fi 57 | 58 | echo "export var __wbindgen_export_2 = retasmFunc.__wbindgen_export_2;" >> bindings/wasm/pkg/defi_wallet_core_wasm_bg.wasm.js 59 | 60 | echo "finish" -------------------------------------------------------------------------------- /mobile_modules/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | 17 | dwc_commonFFI.h 18 | lib.a/ 19 | common.swift 20 | build/ 21 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /mobile_modules/android_module/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdk 31 8 | 9 | defaultConfig { 10 | applicationId "com.crypto.android_dwclib" 11 | minSdk 26 12 | targetSdk 31 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | kotlinOptions { 30 | jvmTarget = '1.8' 31 | } 32 | } 33 | 34 | dependencies { 35 | 36 | implementation 'androidx.core:core-ktx:1.7.0' 37 | implementation 'androidx.appcompat:appcompat:1.4.0' 38 | implementation 'com.google.android.material:material:1.4.0' 39 | testImplementation 'junit:junit:4.+' 40 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 41 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 42 | } -------------------------------------------------------------------------------- /mobile_modules/android_module/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/androidTest/java/com/crypto/android_dwclib/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.crypto.android_dwclib 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.crypto.android_dwclib", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | android_dwclib 3 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /mobile_modules/android_module/app/src/test/java/com/crypto/android_dwclib/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.crypto.android_dwclib 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /mobile_modules/android_module/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath "com.android.tools.build:gradle:7.0.2" 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31" 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | task clean(type: Delete) { 17 | delete rootProject.buildDir 18 | } -------------------------------------------------------------------------------- /mobile_modules/android_module/dwclib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | common.kt 3 | *.so 4 | libs/* -------------------------------------------------------------------------------- /mobile_modules/android_module/dwclib/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdk 31 8 | 9 | defaultConfig { 10 | minSdk 26 11 | targetSdk 31 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | consumerProguardFiles "consumer-rules.pro" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | kotlinOptions { 30 | jvmTarget = '1.8' 31 | } 32 | } 33 | 34 | dependencies { 35 | implementation 'net.java.dev.jna:jna:5.10.0@aar' 36 | implementation 'androidx.core:core-ktx:1.7.0' 37 | implementation 'androidx.appcompat:appcompat:1.4.0' 38 | implementation 'com.google.android.material:material:1.4.0' 39 | testImplementation 'junit:junit:4.+' 40 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 41 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 42 | } -------------------------------------------------------------------------------- /mobile_modules/android_module/dwclib/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/dwclib/consumer-rules.pro -------------------------------------------------------------------------------- /mobile_modules/android_module/dwclib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /mobile_modules/android_module/dwclib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /mobile_modules/android_module/dwclib/src/test/java/com/crypto/dwclib/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.crypto.dwclib 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | import com.defi.wallet.core.common.* 7 | 8 | /** 9 | * Example local unit test, which will execute on the development machine (host). 10 | * 11 | * See [testing documentation](http://d.android.com/tools/testing). 12 | */ 13 | class ExampleUnitTest { 14 | } -------------------------------------------------------------------------------- /mobile_modules/android_module/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /mobile_modules/android_module/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/mobile_modules/android_module/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /mobile_modules/android_module/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Dec 29 23:47:37 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /mobile_modules/android_module/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /mobile_modules/android_module/settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 3 | repositories { 4 | google() 5 | mavenCentral() 6 | jcenter() // Warning: this repository is going to shut down soon 7 | } 8 | } 9 | rootProject.name = "android_dwclib" 10 | include ':app' 11 | include ':dwclib' 12 | -------------------------------------------------------------------------------- /mobile_modules/ios_module/dwclib/dwclib.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mobile_modules/ios_module/dwclib/dwclib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /mobile_modules/ios_module/dwclib/dwclib.xcodeproj/xcshareddata/xcschemes/dwclib.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 54 | 60 | 61 | 67 | 68 | 69 | 70 | 72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /mobile_modules/ios_module/dwclib/dwclib/dwclib.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for dwclib. 4 | FOUNDATION_EXPORT double dwclibVersionNumber; 5 | 6 | //! Project version string for dwclib. 7 | FOUNDATION_EXPORT const unsigned char dwclibVersionString[]; 8 | 9 | // In this header, you should import all the public headers of your framework using statements like #import 10 | 11 | 12 | -------------------------------------------------------------------------------- /mobile_modules/ios_module/dwclib/dwclib/include/module.modulemap: -------------------------------------------------------------------------------- 1 | module DefiWalletCore [system] { 2 | header "dwc_commonFFI.h" 3 | export * 4 | } 5 | -------------------------------------------------------------------------------- /nix/chainmain.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import ./default.nix { } }: 2 | let 3 | pname = "chain-maind"; 4 | version = "3.3.3"; 5 | srcUrl = { 6 | x86_64-linux = { 7 | url = 8 | "https://github.com/crypto-org-chain/chain-main/releases/download/v${version}/chain-main_${version}_Linux_x86_64.tar.gz"; 9 | sha256 = "sha256-5si15+ni5Biix2oktNhMCR0pZmQNgXknUU8dcAfr2a8="; 10 | }; 11 | x86_64-darwin = { 12 | url = 13 | "https://github.com/crypto-org-chain/chain-main/releases/download/v${version}/chain-main_${version}_Darwin_x86_64.tar.gz"; 14 | sha256 = "sha256-ri7TH+FSajRDIW1CC5R33XSj835wQgNnDXa2kPGi5C4="; 15 | }; 16 | }.${pkgs.stdenv.system} or (throw 17 | "Unsupported system: ${pkgs.stdenv.system}"); 18 | in 19 | pkgs.stdenv.mkDerivation { 20 | name = "${pname}"; 21 | inherit version; 22 | src = pkgs.fetchurl srcUrl; 23 | sourceRoot = "."; 24 | installPhase = '' 25 | mkdir -p $out/bin 26 | cp bin/${pname} $out/bin/${pname} 27 | chmod +x $out/bin/${pname} 28 | ''; 29 | 30 | meta = with pkgs.lib; { platforms = with platforms; linux ++ darwin; }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /nix/cronos.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import ./default.nix { } }: 2 | let 3 | pname = "cronosd"; 4 | version = "0.6.5"; 5 | srcUrl = { 6 | x86_64-linux = { 7 | url = 8 | "https://github.com/crypto-org-chain/cronos/releases/download/v${version}/cronos_${version}_Linux_x86_64.tar.gz"; 9 | sha256 = "sha256-rwrDfEujtxc8sOTuKD0pPSB3PmcUe4Qc8jmtYVlrw00="; 10 | }; 11 | x86_64-darwin = { 12 | url = 13 | "https://github.com/crypto-org-chain/cronos/releases/download/v${version}/cronos_${version}_Darwin_x86_64.tar.gz"; 14 | sha256 = "sha256-l9AAW728xfQnRhHcqQN10oYlHZkib03RDHo9Kyh4PHc="; 15 | }; 16 | }.${pkgs.stdenv.system} or (throw 17 | "Unsupported system: ${pkgs.stdenv.system}"); 18 | in 19 | pkgs.stdenv.mkDerivation { 20 | name = "${pname}"; 21 | inherit version; 22 | src = pkgs.fetchurl srcUrl; 23 | sourceRoot = "."; 24 | installPhase = '' 25 | mkdir -p $out/bin 26 | cp bin/${pname} $out/bin/${pname} 27 | chmod +x $out/bin/${pname} 28 | ''; 29 | 30 | meta = with pkgs.lib; { platforms = with platforms; linux ++ darwin; }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /nix/default.nix: -------------------------------------------------------------------------------- 1 | { sources ? import ./sources.nix, system ? builtins.currentSystem, ... }: 2 | 3 | import sources.nixpkgs { 4 | overlays = [ 5 | 6 | (_: pkgs: { 7 | pystarport = pkgs.poetry2nix.mkPoetryApplication { 8 | projectDir = sources.pystarport; 9 | src = sources.pystarport; 10 | }; 11 | }) 12 | 13 | (_: pkgs: { test-env = import ./testenv.nix { inherit pkgs; }; }) 14 | 15 | ]; 16 | config = { }; 17 | inherit system; 18 | } 19 | -------------------------------------------------------------------------------- /nix/doxybook2.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import ./default.nix { } }: 2 | let 3 | pname = "doxybook2"; 4 | version = "1.4.0"; 5 | srcUrl = { 6 | x86_64-linux = { 7 | url = 8 | "https://github.com/matusnovak/doxybook2/releases/download/v${version}/doxybook2-linux-amd64-v${version}.zip"; 9 | sha256 = "sha256-urk1b12qVQy/IdjZtVTqWci+A5cWosr26W3uUnE/zLA="; 10 | }; 11 | x86_64-darwin = { 12 | url = 13 | "https://github.com/matusnovak/doxybook2/releases/download/v${version}/doxybook2-osx-amd64-v${version}.zip"; 14 | sha256 = "sha256-nfFEpA8Yk0+qA0ESAMlkOqqEjHbPZLUxGsRuvQwdNHk="; 15 | }; 16 | }.${pkgs.stdenv.system} or (throw 17 | "Unsupported system: ${pkgs.stdenv.system}"); 18 | in 19 | pkgs.stdenv.mkDerivation { 20 | name = "${pname}"; 21 | inherit version; 22 | src = pkgs.fetchurl srcUrl; 23 | sourceRoot = "."; 24 | installPhase = '' 25 | mkdir -p $out/bin 26 | cp bin/${pname} $out/bin/${pname} 27 | chmod +x $out/bin/${pname} 28 | ''; 29 | nativeBuildInputs = [ pkgs.unzip ]; 30 | meta = with pkgs.lib; { platforms = with platforms; linux ++ darwin; }; 31 | } 32 | -------------------------------------------------------------------------------- /nix/hermes.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import ./default.nix { } }: 2 | let 3 | version = "v0.12.0"; 4 | srcUrl = { 5 | x86_64-linux = { 6 | url = 7 | "https://github.com/informalsystems/ibc-rs/releases/download/${version}/hermes-${version}-x86_64-unknown-linux-gnu.tar.gz"; 8 | sha256 = "sha256-pqunu7oy1MmNjgEyUXctjQRLNo0DMA+YDL8B48aayLs="; 9 | }; 10 | x86_64-darwin = { 11 | url = 12 | "https://github.com/informalsystems/ibc-rs/releases/download/${version}/hermes-${version}-x86_64-apple-darwin.tar.gz"; 13 | sha256 = "sha256-RMqWSN9BVzIzvzrrfpLKJMfhYMdbNfwNJwbnJx7I7mU="; 14 | }; 15 | }.${pkgs.stdenv.system} or (throw 16 | "Unsupported system: ${pkgs.stdenv.system}"); 17 | in 18 | pkgs.stdenv.mkDerivation { 19 | name = "hermes"; 20 | inherit version; 21 | src = pkgs.fetchurl srcUrl; 22 | sourceRoot = "."; 23 | installPhase = '' 24 | echo "hermes" 25 | echo $out 26 | install -m755 -D hermes $out/bin/hermes 27 | ''; 28 | 29 | meta = with pkgs.lib; { platforms = with platforms; linux ++ darwin; }; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /nix/node/default.nix: -------------------------------------------------------------------------------- 1 | # This file has been generated by node2nix 1.11.0. Do not edit! 2 | 3 | { pkgs ? import { 4 | inherit system; 5 | } 6 | , system ? builtins.currentSystem 7 | , nodejs ? pkgs."nodejs-10_x" 8 | }: 9 | 10 | let 11 | nodeEnv = import ./node-env.nix { 12 | inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript; 13 | inherit pkgs nodejs; 14 | libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null; 15 | }; 16 | in 17 | import ./node-packages.nix { 18 | inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit; 19 | inherit nodeEnv; 20 | } 21 | -------------------------------------------------------------------------------- /nix/node/node-packages.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "gitbook-cli": "2.3.2" } 3 | ] 4 | -------------------------------------------------------------------------------- /nix/node/override.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } 2 | , system ? builtins.currentSystem 3 | }: 4 | 5 | let 6 | nodePackages = import ./default.nix { 7 | inherit pkgs system; 8 | }; 9 | frameworks = pkgs.darwin.apple_sdk.frameworks; 10 | in 11 | nodePackages."gitbook-cli-2.3.2".override { 12 | buildInputs = [ 13 | pkgs.nodePackages.node-gyp-build 14 | ] 15 | ++ pkgs.lib.optionals (system == "x86_64-darwin") [ frameworks.CoreServices ]; 16 | } 17 | -------------------------------------------------------------------------------- /nix/pypkgs.nix: -------------------------------------------------------------------------------- 1 | { pkgs }: 2 | pkgs.python39Packages.override { 3 | overrides = self: super: { 4 | exhale = super.buildPythonPackage rec { 5 | pname = "exhale"; 6 | # 0.3+ needs breath >= 4.32.0 7 | version = "0.2.4"; 8 | src = super.fetchPypi { 9 | inherit pname version; 10 | sha256 = "sha256-vD/1rXLLl8NGiUTB8OnQfmHDhrq6lzF625s4eEtrJpg="; 11 | }; 12 | buildInputs = with super; 13 | [ breathe lxml beautifulsoup4 ]; 14 | }; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /nix/sources.json: -------------------------------------------------------------------------------- 1 | { 2 | "niv": { 3 | "branch": "master", 4 | "description": "Easy dependency management for Nix projects", 5 | "homepage": "https://github.com/nmattia/niv", 6 | "owner": "nmattia", 7 | "repo": "niv", 8 | "rev": "5830a4dd348d77e39a0f3c4c762ff2663b602d4c", 9 | "sha256": "1d3lsrqvci4qz2hwjrcnd8h5vfkg8aypq3sjd4g3izbc8frwz5sm", 10 | "type": "tarball", 11 | "url": "https://github.com/nmattia/niv/archive/5830a4dd348d77e39a0f3c4c762ff2663b602d4c.tar.gz", 12 | "url_template": "https://github.com///archive/.tar.gz" 13 | }, 14 | "nixpkgs": { 15 | "branch": "release-21.11", 16 | "description": "Nix Packages collection", 17 | "homepage": "", 18 | "owner": "NixOS", 19 | "repo": "nixpkgs", 20 | "rev": "d2f47b7dcd558a7727606319fd8661a4c3311b4a", 21 | "sha256": "1kkykw8i80jcnw6iz7a4kndia3fig53jm1kzqi4xbfgxamfwqnzb", 22 | "type": "tarball", 23 | "url": "https://github.com/NixOS/nixpkgs/archive/d2f47b7dcd558a7727606319fd8661a4c3311b4a.tar.gz", 24 | "url_template": "https://github.com///archive/.tar.gz" 25 | }, 26 | "pystarport": { 27 | "branch": "main", 28 | "description": "pystarport setup and run local devnet for cosmos like blockchains", 29 | "homepage": null, 30 | "owner": "crypto-com", 31 | "repo": "pystarport", 32 | "rev": "e08c02d64b19140e1473dfe47cdc759001eff505", 33 | "sha256": "1h39ckb56br1cgznbr8xw054pg6vixdxhz2vbr4ypgvwh372sd4h", 34 | "type": "tarball", 35 | "url": "https://github.com/crypto-com/pystarport/archive/refs/tags/v0.2.3.tar.gz", 36 | "url_template": "https://github.com///archive/.tar.gz", 37 | "version": "v0.2.3" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /nix/testenv.nix: -------------------------------------------------------------------------------- 1 | { pkgs }: 2 | pkgs.poetry2nix.mkPoetryEnv { 3 | projectDir = ../integration_tests; 4 | overrides = pkgs.poetry2nix.overrides.withDefaults (self: super: { 5 | eth-bloom = super.eth-bloom.overridePythonAttrs { 6 | preConfigure = '' 7 | substituteInPlace setup.py --replace \'setuptools-markdown\' "" 8 | ''; 9 | }; 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /proto-build/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "proto-build" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | rust-version = "1.57" 7 | license = "Apache-2.0" 8 | 9 | [dependencies] 10 | prost = "0.11" 11 | prost-build = "0.11" 12 | regex = "1" 13 | tonic = { version = "0.8", default-features = false, features = ["codegen", "prost", "transport"] } 14 | tonic-build = { version = "0.9", default-features = false, features = ["prost", "transport"] } 15 | walkdir = "2" 16 | -------------------------------------------------------------------------------- /proto-build/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022-present, Crypto.com. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /proto-build/README.md: -------------------------------------------------------------------------------- 1 | # proto-build 2 | 3 | `proto-build` is a program for decoding proto files. 4 | -------------------------------------------------------------------------------- /proto/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "defi-wallet-core-proto" 3 | version = "0.1.0" # Also update html_root_url in lib.rs when bumping this 4 | license = "Apache-2.0" 5 | repository = "https://github.com/crypto-com/defi-wallet-core-rs/tree/main/proto" 6 | description = "Protobuf stuct defintions for interacting Cosmos SDK powered blockchains" 7 | readme = "README.md" 8 | categories = ["cryptography", "cryptography::cryptocurrencies", "database"] 9 | keywords = ["blockchain", "cosmos", "tendermint", "proto", "defi"] 10 | edition = "2021" 11 | rust-version = "1.57" 12 | 13 | [dependencies] 14 | # FIXME: switch to upstream crates.io when released 15 | cosmrs = { git = "https://github.com/crypto-com/cosmos-rust.git" } 16 | cosmos-sdk-proto = { git = "https://github.com/crypto-com/cosmos-rust.git", default-features = false } 17 | prost = "0.11" 18 | prost-types = "0.11" 19 | tendermint-proto = "0.30" 20 | tonic = { version = "0.8", default-features = false, features = ["codegen", "prost"] } 21 | serde = "1" 22 | 23 | [features] 24 | default = ["grpc"] 25 | grpc = [] 26 | transport = ["tonic/transport", "tonic/tls", "tonic/tls-roots"] 27 | 28 | [package.metadata.docs.rs] 29 | all-features = true 30 | rustdoc-args = ["--cfg", "docsrs"] 31 | -------------------------------------------------------------------------------- /proto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022-present, Crypto.com. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /proto/README.md: -------------------------------------------------------------------------------- 1 | # defi-wallet-core-proto 2 | 3 | Rust crate for interacting with Protobufs defined by the crypto.org chain. 4 | 5 | The goal of this crate is to provide complete proto struct definitions for interacting with 6 | crypto.org chain. 7 | -------------------------------------------------------------------------------- /proto/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Ignore this clippy issue for generated `prost` code. 2 | #![allow(clippy::derive_partial_eq_without_eq)] 3 | #![doc = include_str!("../README.md")] 4 | #![cfg_attr(docsrs, feature(doc_cfg))] 5 | #![forbid(unsafe_code)] 6 | #![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)] 7 | #![allow(clippy::derive_partial_eq_without_eq)] // FIXME: generate types with `Eq` 8 | 9 | use cosmos_sdk_proto::cosmos; 10 | pub use tendermint_proto as tendermint; 11 | 12 | use cosmos_sdk_proto::traits::TypeUrl; 13 | 14 | /// The version (commit hash) of the Cosmos SDK used when generating this library. 15 | pub const CHAIN_MAIN_VERSION: &str = include_str!("prost/CHAIN_MAIN_COMMIT"); 16 | 17 | /// chainmain protobuf definitions. 18 | pub mod chainmain { 19 | /// chainmain 20 | #[allow(clippy::module_inception)] 21 | pub mod chainmain { 22 | pub mod v1 { 23 | include!("prost/chainmain.chainmain.v1.rs"); 24 | } 25 | } 26 | 27 | /// nft 28 | pub mod nft { 29 | pub mod v1 { 30 | use serde::{Deserialize, Serialize}; 31 | include!("prost/chainmain.nft.v1.rs"); 32 | } 33 | } 34 | 35 | /// supply 36 | pub mod supply { 37 | pub mod v1 { 38 | include!("prost/chainmain.supply.v1.rs"); 39 | } 40 | } 41 | } 42 | 43 | impl TypeUrl for chainmain::nft::v1::MsgIssueDenom { 44 | const TYPE_URL: &'static str = "/chainmain.nft.v1.MsgIssueDenom"; 45 | } 46 | 47 | impl TypeUrl for chainmain::nft::v1::MsgMintNft { 48 | const TYPE_URL: &'static str = "/chainmain.nft.v1.MsgMintNFT"; 49 | } 50 | 51 | impl TypeUrl for chainmain::nft::v1::MsgEditNft { 52 | const TYPE_URL: &'static str = "/chainmain.nft.v1.MsgEditNFT"; 53 | } 54 | impl TypeUrl for chainmain::nft::v1::MsgTransferNft { 55 | const TYPE_URL: &'static str = "/chainmain.nft.v1.MsgTransferNFT"; 56 | } 57 | 58 | impl TypeUrl for chainmain::nft::v1::MsgBurnNft { 59 | const TYPE_URL: &'static str = "/chainmain.nft.v1.MsgBurnNFT"; 60 | } 61 | 62 | /// The version (commit hash) of the LunaClassic Core used when generating this library. 63 | pub const LUNA_CLASSIC_VERSION: &str = include_str!("prost/LUNA_CLASSIC_COMMIT"); 64 | 65 | /// luna_classic protobuf definitions. 66 | pub mod luna_classic { 67 | /// wasm 68 | pub mod wasm { 69 | pub mod v1beta1 { 70 | include!("prost/terra.wasm.v1beta1.rs"); 71 | } 72 | } 73 | } 74 | 75 | impl TypeUrl for luna_classic::wasm::v1beta1::MsgExecuteContract { 76 | const TYPE_URL: &'static str = "terra.wasm.v1beta1.MsgExecuteContract"; 77 | } 78 | -------------------------------------------------------------------------------- /proto/src/prost/CHAIN_MAIN_COMMIT: -------------------------------------------------------------------------------- 1 | v3.3.3 -------------------------------------------------------------------------------- /proto/src/prost/LUNA_CLASSIC_COMMIT: -------------------------------------------------------------------------------- 1 | v0.5.18 -------------------------------------------------------------------------------- /proto/src/prost/chainmain.chainmain.v1.rs: -------------------------------------------------------------------------------- 1 | /// GenesisState defines the capability module's genesis state. 2 | /// TODO: currently left empty (for versioning), 3 | /// later, it may include fields needed for custom capabilities 4 | /// (subscriptions, vaultable accounts, ...) 5 | #[derive(Clone, PartialEq, ::prost::Message)] 6 | pub struct GenesisState { 7 | } 8 | -------------------------------------------------------------------------------- /proto/src/prost/cosmos_proto.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crypto-com/defi-wallet-core-rs/52e6c5be2ce44085d7c0d94aabc901b13b8629b6/proto/src/prost/cosmos_proto.rs -------------------------------------------------------------------------------- /proto/src/prost/terra.vesting.v1beta1.rs: -------------------------------------------------------------------------------- 1 | /// LazyGradedVestingAccount implements the LazyGradedVestingAccount interface. It vests all 2 | /// coins according to a predefined schedule. 3 | #[derive(Clone, PartialEq, ::prost::Message)] 4 | pub struct LazyGradedVestingAccount { 5 | #[prost(message, optional, tag="1")] 6 | pub base_vesting_account: ::core::option::Option, 7 | #[prost(message, repeated, tag="2")] 8 | pub vesting_schedules: ::prost::alloc::vec::Vec, 9 | } 10 | /// Schedule - represent single schedule data for a vesting schedule 11 | #[derive(Clone, PartialEq, ::prost::Message)] 12 | pub struct Schedule { 13 | #[prost(int64, tag="1")] 14 | pub start_time: i64, 15 | #[prost(int64, tag="2")] 16 | pub end_time: i64, 17 | #[prost(string, tag="3")] 18 | pub ratio: ::prost::alloc::string::String, 19 | } 20 | /// VestingSchedule defines vesting schedule for a denom 21 | #[derive(Clone, PartialEq, ::prost::Message)] 22 | pub struct VestingSchedule { 23 | #[prost(string, tag="1")] 24 | pub denom: ::prost::alloc::string::String, 25 | #[prost(message, repeated, tag="2")] 26 | pub schedules: ::prost::alloc::vec::Vec, 27 | } 28 | -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | stable 2 | -------------------------------------------------------------------------------- /scripts/.env: -------------------------------------------------------------------------------- 1 | export PASSWORD='123456' 2 | export VALIDATOR1_MNEMONIC="visit craft resemble online window solution west chuckle music diesel vital settle comic tribe project blame bulb armed flower region sausage mercy arrive release" 3 | export VALIDATOR2_MNEMONIC="direct travel shrug hand twice agent sail sell jump phone velvet pilot mango charge usual multiply orient garment bleak virtual action mention panda vast" 4 | export COMMUNITY_MNEMONIC="notable error gospel wave pair ugly measure elite toddler cost various fly make eye ketchup despair slab throw tribe swarm word fruit into inmate" 5 | export DELEGATOR1_MNEMONIC="yard night airport critic main upper measure metal unhappy cliff pistol square upon access math owner enemy unfold scan small injury blind aunt million" 6 | export DELEGATOR2_MNEMONIC="strong pyramid worth tennis option wet broccoli smoke midnight maze hint soft hen ignore shuffle multiply room recycle hurt degree crouch drill economy surge" 7 | export SIGNER1_MNEMONIC="shed crumble dismiss loyal latin million oblige gesture shrug still oxygen custom remove ribbon disorder palace addict again blanket sad flock consider obey popular" 8 | export SIGNER2_MNEMONIC="night renew tonight dinner shaft scheme domain oppose echo summer broccoli agent face guitar surface belt veteran siren poem alcohol menu custom crunch index" 9 | export CRONOS_ADMIN="crc12luku6uxehhak02py4rcz65zu0swh7wjsrw0pp" 10 | export IBC_CRO_DENOM="ibc/6411AE2ADA1E73DB59DB151A8988F9B7D5E7E233D8414DB6817F8F1A01611F86" 11 | 12 | # For cpp-ci-tests or cpp-tests 13 | export MYMNEMONICS="shed crumble dismiss loyal latin million oblige gesture shrug still oxygen custom remove ribbon disorder palace addict again blanket sad flock consider obey popular" 14 | export MYCOSMOSRPC="http://127.0.0.1:26804" 15 | export MYCRONOSRPC="http://127.0.0.1:26651" 16 | export MYTENDERMINTRPC="http://127.0.0.1:26807" 17 | export MYGRPC="http://127.0.0.1:26803" 18 | export MYCHAINID=chainmain-1 19 | export MYFROM=cro1u08u5dvtnpmlpdq333uj9tcj75yceggszxpnsy 20 | export MYTO=cro1apdh4yc2lnpephevc6lmpvkyv6s5cjh652n6e4 21 | export MYAMOUNT=1 22 | 23 | export CPP_EXAMPLE_PATH='' 24 | -------------------------------------------------------------------------------- /scripts/chainmain-devnet-alone.yaml: -------------------------------------------------------------------------------- 1 | dotenv: .env 2 | chainmain-1: 3 | cmd: chain-maind 4 | start-flags: "--trace" 5 | app-config: 6 | minimum-gas-prices: 500basecro 7 | api: 8 | enable-unsafe-cors: false 9 | enabled-unsafe-cors: true 10 | grpc-web: 11 | enable: true 12 | enable-unsafe-cors: true 13 | validators: 14 | - coins: 2234240000000000000cro 15 | staked: 10000000000000cro 16 | mnemonic: ${VALIDATOR1_MNEMONIC} 17 | config: 18 | rpc: 19 | cors_allowed_origins: ["*"] 20 | - coins: 987870000000000000cro 21 | staked: 20000000000000cro 22 | mnemonic: ${VALIDATOR2_MNEMONIC} 23 | # min_self_delegation: 10000000 # 0.1cro 24 | accounts: 25 | - name: community 26 | coins: 10000000000000cro 27 | mnemonic: ${COMMUNITY_MNEMONIC} 28 | - name: delegator1 29 | coins: 10000000000000cro 30 | mnemonic: ${DELEGATOR1_MNEMONIC} 31 | - name: delegator2 32 | coins: 10000000000000cro 33 | mnemonic: ${DELEGATOR2_MNEMONIC} 34 | - name: signer1 35 | coins: 10000000000000cro 36 | mnemonic: ${SIGNER1_MNEMONIC} 37 | - name: signer2 38 | coins: 10000000000000cro 39 | mnemonic: ${SIGNER2_MNEMONIC} 40 | genesis: 41 | app_state: 42 | staking: 43 | params: 44 | # super-short unbonding time for unbonding test 45 | unbonding_time: "1s" 46 | gov: 47 | voting_params: 48 | voting_period: "1814400s" 49 | deposit_params: 50 | max_deposit_period: "1814400s" 51 | min_deposit: 52 | - denom: "basecro" 53 | amount: "10000000" 54 | transfer: 55 | params: 56 | receive_enabled: true 57 | send_enabled: true 58 | -------------------------------------------------------------------------------- /scripts/chainmain-devnet.yaml: -------------------------------------------------------------------------------- 1 | dotenv: .env 2 | chainmain-1: 3 | cmd: chain-maind 4 | start-flags: "--trace" 5 | app-config: 6 | minimum-gas-prices: 500basecro 7 | api: 8 | enable-unsafe-cors: false 9 | enabled-unsafe-cors: true 10 | grpc-web: 11 | enable: true 12 | enable-unsafe-cors: true 13 | validators: 14 | - coins: 2234240000000000000cro 15 | staked: 10000000000000cro 16 | mnemonic: ${VALIDATOR1_MNEMONIC} 17 | config: 18 | rpc: 19 | cors_allowed_origins: ["*"] 20 | - coins: 987870000000000000cro 21 | staked: 20000000000000cro 22 | mnemonic: ${VALIDATOR2_MNEMONIC} 23 | # min_self_delegation: 10000000 # 0.1cro 24 | accounts: 25 | - name: community 26 | coins: 10000000000000cro 27 | mnemonic: ${COMMUNITY_MNEMONIC} 28 | - name: delegator1 29 | coins: 10000000000000cro 30 | mnemonic: ${DELEGATOR1_MNEMONIC} 31 | - name: delegator2 32 | coins: 10000000000000cro 33 | mnemonic: ${DELEGATOR2_MNEMONIC} 34 | - name: signer1 35 | coins: 10000000000000cro 36 | mnemonic: ${SIGNER1_MNEMONIC} 37 | - name: signer2 38 | coins: 10000000000000cro 39 | mnemonic: ${SIGNER2_MNEMONIC} 40 | genesis: 41 | app_state: 42 | staking: 43 | params: 44 | unbonding_time: "1209700s" 45 | gov: 46 | voting_params: 47 | voting_period: "1814400s" 48 | deposit_params: 49 | max_deposit_period: "1814400s" 50 | min_deposit: 51 | - denom: "basecro" 52 | amount: "10000000" 53 | transfer: 54 | params: 55 | receive_enabled: true 56 | send_enabled: true 57 | -------------------------------------------------------------------------------- /scripts/cronos-devnet.yaml: -------------------------------------------------------------------------------- 1 | dotenv: .env 2 | cronos_777-1: 3 | cmd: cronosd 4 | start-flags: "--trace" 5 | app-config: 6 | minimum-gas-prices: 0basetcro 7 | json-rpc: 8 | address: "0.0.0.0:{EVMRPC_PORT}" 9 | ws-address: "0.0.0.0:{EVMRPC_PORT_WS}" 10 | api: "eth,net,web3,debug" 11 | api: 12 | enable-unsafe-cors: false 13 | enabled-unsafe-cors: true 14 | grpc-web: 15 | enable: true 16 | enable-unsafe-cors: true 17 | validators: 18 | - coins: 1000000000000000000stake,10000000000000000000000basetcro 19 | staked: 1000000000000000000stake 20 | mnemonic: ${VALIDATOR1_MNEMONIC} 21 | - coins: 1000000000000000000stake,10000000000000000000000basetcro 22 | staked: 1000000000000000000stake 23 | mnemonic: ${VALIDATOR2_MNEMONIC} 24 | accounts: 25 | - name: community 26 | coins: 10000000000000000000000basetcro 27 | mnemonic: ${COMMUNITY_MNEMONIC} 28 | - name: delegator1 29 | coins: 10000000000000000000000basetcro 30 | mnemonic: ${DELEGATOR1_MNEMONIC} 31 | - name: delegator2 32 | coins: 10000000000000000000000basetcro 33 | mnemonic: ${DELEGATOR2_MNEMONIC} 34 | - name: signer1 35 | coins: 20000000000000000000000basetcro 36 | mnemonic: ${SIGNER1_MNEMONIC} 37 | - name: signer2 38 | coins: 30000000000000000000000basetcro 39 | mnemonic: ${SIGNER2_MNEMONIC} 40 | 41 | genesis: 42 | consensus_params: 43 | block: 44 | max_bytes: "1048576" 45 | max_gas: "81500000" 46 | app_state: 47 | evm: 48 | params: 49 | evm_denom: basetcro 50 | cronos: 51 | params: 52 | cronos_admin: ${CRONOS_ADMIN} 53 | enable_auto_deployment: true 54 | ibc_cro_denom: ${IBC_CRO_DENOM} 55 | gov: 56 | voting_params: 57 | voting_period: "10s" 58 | deposit_params: 59 | max_deposit_period: "10s" 60 | min_deposit: 61 | - denom: "basetcro" 62 | amount: "1" 63 | transfer: 64 | params: 65 | receive_enabled: true 66 | send_enabled: true 67 | feemarket: 68 | params: 69 | no_base_fee: false 70 | initial_base_fee: 100000000000 71 | -------------------------------------------------------------------------------- /scripts/full-wasm-tests: -------------------------------------------------------------------------------- 1 | # !! This script must run in project root folder (same path as MakeFile) !! 2 | # Requirements: pystarport, supervisor, chain-maind, cronosd, hermes 3 | 4 | # Test basic cases 5 | ./scripts/wasm-tests 6 | 7 | # Test for ibc transfer 8 | ./scripts/start-all 9 | cd bindings/wasm/ 10 | wasm-pack test --firefox --headless -- --features ibc-test --test ibc 11 | cd ../.. 12 | ./scripts/stop-all 13 | -------------------------------------------------------------------------------- /scripts/hermes.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | log_level = 'error' 3 | 4 | [rest] 5 | enabled = true 6 | host = '127.0.0.1' 7 | port = 3000 8 | 9 | [[chains]] 10 | id = 'chainmain-1' 11 | rpc_addr = 'http://127.0.0.1:26807' 12 | grpc_addr = 'http://127.0.0.1:26803' 13 | websocket_addr = 'ws://localhost:26807/websocket' 14 | rpc_timeout = '10s' 15 | account_prefix = 'cro' 16 | key_name = 'testkey' 17 | store_prefix = 'ibc' 18 | max_gas = 9000000 19 | gas_price = { price = 1000000, denom = 'basecro' } 20 | max_msg_num = 4 21 | max_tx_size = 1048576 22 | clock_drift = '5s' 23 | trusting_period = '14days' 24 | trust_threshold = { numerator = '1', denominator = '3' } 25 | address_type = { derivation = 'cosmos' } 26 | 27 | [[chains]] 28 | id = 'cronos_777-1' 29 | rpc_addr = 'http://127.0.0.1:26657' 30 | grpc_addr = 'http://127.0.0.1:26653' 31 | websocket_addr = 'ws://localhost:26657/websocket' 32 | rpc_timeout = '10s' 33 | account_prefix = 'crc' 34 | key_name = 'testkey' 35 | store_prefix = 'ibc' 36 | max_gas = 9000000 37 | gas_price = { price = 10000000000000, denom = 'basetcro' } 38 | clock_drift = '5s' 39 | trusting_period = '14days' 40 | trust_threshold = { numerator = '1', denominator = '3' } 41 | address_type = { derivation = 'ethermint', proto_type = { pk_type = '/ethermint.crypto.v1.ethsecp256k1.PubKey' } } 42 | -------------------------------------------------------------------------------- /scripts/python-tests: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | cd "$(dirname "$0")" 4 | 5 | # explicitly set a short TMPDIR to prevent path too long issue on macosx 6 | export TMPDIR=/tmp 7 | 8 | cd ../integration_tests 9 | pytest -vv -s 10 | -------------------------------------------------------------------------------- /scripts/start-all: -------------------------------------------------------------------------------- 1 | # !! This script must run in project root folder (same path as MakeFile) !! 2 | # Requirements: pystarport, supervisor, chain-maind, cronosd, hermes 3 | 4 | cd scripts 5 | 6 | # Clear and restart chainmain 7 | ./chainmain-ctl stop 8 | ./chainmain-ctl clear 9 | ./chainmain-ctl start ./chainmain-devnet.yaml 10 | 11 | # Clear and restart cronos 12 | ./cronos-ctl stop 13 | ./cronos-ctl clear 14 | ./cronos-ctl start 15 | 16 | # Clear and restart hermes 17 | sleep 15 18 | ./hermes-ctl stop 19 | ./hermes-ctl clear 20 | ./hermes-ctl start 21 | 22 | for i in {1..60}; do 23 | hermes_status=$(curl -s -X GET 'http://127.0.0.1:3000/state' | jq ".status") 24 | success="\"success\"" 25 | echo $hermes_status 26 | if [ "$hermes_status" = "$success" ]; then 27 | break 28 | else 29 | echo "Waiting hermes..." 30 | sleep 1 31 | fi 32 | done 33 | 34 | cd ../ 35 | -------------------------------------------------------------------------------- /scripts/start-chainmain: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=$1 5 | if [ -z "$CONFIG" ]; then 6 | echo "No config file supplied" 7 | exit 1 8 | fi 9 | shift 10 | 11 | DOTENV=$1 12 | if [ -z "$DOTENV" ]; then 13 | echo "No dotenv file supplied" 14 | exit 1 15 | fi 16 | shift 17 | 18 | DATA=$1 19 | if [ -z "$DATA" ]; then 20 | echo "No data directory supplied" 21 | exit 1 22 | fi 23 | shift 24 | 25 | echo 'pystarport:' 26 | echo ' config: '$CONFIG 27 | echo ' dotenv: '$DOTENV 28 | echo ' data: '$DATA 29 | 30 | pystarport init --config $CONFIG --dotenv $DOTENV --data $DATA $@ 31 | supervisord -c $DATA/tasks.ini 32 | -------------------------------------------------------------------------------- /scripts/start-cronos: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=$1 5 | if [ -z "$CONFIG" ]; then 6 | echo "No config file supplied" 7 | exit 1 8 | fi 9 | shift 10 | 11 | DOTENV=$1 12 | if [ -z "$DOTENV" ]; then 13 | echo "No dotenv file supplied" 14 | exit 1 15 | fi 16 | shift 17 | 18 | DATA=$1 19 | if [ -z "$DATA" ]; then 20 | echo "No data directory supplied" 21 | exit 1 22 | fi 23 | shift 24 | 25 | echo 'pystarport:' 26 | echo ' config: '$CONFIG 27 | echo ' dotenv: '$DOTENV 28 | echo ' data: '$DATA 29 | 30 | pystarport init --config $CONFIG --dotenv $DOTENV --data $DATA $@ 31 | supervisord -c $DATA/tasks.ini 32 | -------------------------------------------------------------------------------- /scripts/start-hermes: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | CONFIG=$1 5 | if [ -z "$CONFIG" ]; then 6 | echo "No config file supplied" 7 | exit 1 8 | fi 9 | shift 10 | 11 | 12 | DATA=$1 13 | if [ -z "$DATA" ]; then 14 | echo "No data directory supplied" 15 | exit 1 16 | fi 17 | shift 18 | 19 | echo 'start-hermes' 20 | echo 'config= '$CONFIG 21 | echo 'data= '$DATA 22 | echo 'current folder= ' $PWD 23 | 24 | NEWCONFIG=$DATA/config.toml 25 | echo "hermes src config= "$CONFIG 26 | echo "hermes dst config= "$NEWCONFIG 27 | cp $CONFIG $NEWCONFIG 28 | 29 | hermes -c $NEWCONFIG keys restore chainmain-1 -m "${SIGNER1_MNEMONIC}" -p "m/44'/394'/0'/0/0" 30 | hermes -c $NEWCONFIG keys restore cronos_777-1 -m "${SIGNER1_MNEMONIC}" -p "m/44'/60'/0'/0/0" 31 | 32 | hermes -c $NEWCONFIG keys list chainmain-1 33 | hermes -c $NEWCONFIG keys list cronos_777-1 34 | 35 | hermes -c $NEWCONFIG create channel chainmain-1 cronos_777-1 --port-a transfer --port-b transfer 36 | hermes -c $NEWCONFIG start & 37 | echo $! > $DATA/supervisord.pid 38 | -------------------------------------------------------------------------------- /scripts/stop-all: -------------------------------------------------------------------------------- 1 | # !! This script must run in project root folder (same path as MakeFile) !! 2 | # Requirements: pystarport, supervisor, chain-maind, cronosd, hermes 3 | 4 | cd scripts 5 | 6 | # Stop and clear hermes 7 | ./hermes-ctl stop 8 | ./hermes-ctl clear 9 | 10 | # Stop and clear cronos 11 | ./cronos-ctl stop 12 | ./cronos-ctl clear 13 | 14 | # Stop and clear chainmain 15 | ./chainmain-ctl stop 16 | ./chainmain-ctl clear 17 | 18 | cd ../ 19 | -------------------------------------------------------------------------------- /scripts/wasm-tests: -------------------------------------------------------------------------------- 1 | # !! This script must run in project root folder (same path as MakeFile) !! 2 | # Requirements: pystarport, supervisor, chain-maind, cronosd 3 | 4 | cd scripts 5 | 6 | script_dir=$(pwd) 7 | 8 | # Set timeout to wasm tests 9 | export WASM_BINDGEN_TEST_TIMEOUT=60 10 | 11 | # Stop chainmain 12 | ./chainmain-ctl stop 13 | 14 | # Clear chainmain 15 | ./chainmain-ctl clear 16 | 17 | # Start chainmain 18 | ./chainmain-ctl start 19 | 20 | # Do wasm tests 21 | sleep 5 22 | cd ../bindings/wasm/ 23 | wasm-pack test --firefox --headless 24 | 25 | cd $script_dir 26 | 27 | # Stop chainmain 28 | ./chainmain-ctl stop 29 | 30 | # Clear chainmain 31 | ./chainmain-ctl clear 32 | --------------------------------------------------------------------------------